.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * PS3 gelic network driver. |
---|
3 | 4 | * |
---|
.. | .. |
---|
10 | 11 | * |
---|
11 | 12 | * Authors : Utz Bacher <utz.bacher@de.ibm.com> |
---|
12 | 13 | * Jens Osterkamp <Jens.Osterkamp@de.ibm.com> |
---|
13 | | - * |
---|
14 | | - * This program is free software; you can redistribute it and/or modify |
---|
15 | | - * it under the terms of the GNU General Public License as published by |
---|
16 | | - * the Free Software Foundation; either version 2, or (at your option) |
---|
17 | | - * any later version. |
---|
18 | | - * |
---|
19 | | - * This program is distributed in the hope that it will be useful, |
---|
20 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | | - * GNU General Public License for more details. |
---|
23 | | - * |
---|
24 | | - * You should have received a copy of the GNU General Public License |
---|
25 | | - * along with this program; if not, write to the Free Software |
---|
26 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
27 | 14 | */ |
---|
28 | 15 | |
---|
29 | 16 | #undef DEBUG |
---|
.. | .. |
---|
330 | 317 | |
---|
331 | 318 | /* set up the hardware pointers in each descriptor */ |
---|
332 | 319 | for (i = 0; i < no; i++, descr++) { |
---|
333 | | - gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); |
---|
334 | | - descr->bus_addr = |
---|
335 | | - dma_map_single(ctodev(card), descr, |
---|
336 | | - GELIC_DESCR_SIZE, |
---|
337 | | - DMA_BIDIRECTIONAL); |
---|
| 320 | + dma_addr_t cpu_addr; |
---|
338 | 321 | |
---|
339 | | - if (!descr->bus_addr) |
---|
| 322 | + gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); |
---|
| 323 | + |
---|
| 324 | + cpu_addr = dma_map_single(ctodev(card), descr, |
---|
| 325 | + GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL); |
---|
| 326 | + |
---|
| 327 | + if (dma_mapping_error(ctodev(card), cpu_addr)) |
---|
340 | 328 | goto iommu_error; |
---|
341 | 329 | |
---|
| 330 | + descr->bus_addr = cpu_to_be32(cpu_addr); |
---|
342 | 331 | descr->next = descr + 1; |
---|
343 | 332 | descr->prev = descr - 1; |
---|
344 | 333 | } |
---|
.. | .. |
---|
378 | 367 | * |
---|
379 | 368 | * allocates a new rx skb, iommu-maps it and attaches it to the descriptor. |
---|
380 | 369 | * Activate the descriptor state-wise |
---|
| 370 | + * |
---|
| 371 | + * Gelic RX sk_buffs must be aligned to GELIC_NET_RXBUF_ALIGN and the length |
---|
| 372 | + * must be a multiple of GELIC_NET_RXBUF_ALIGN. |
---|
381 | 373 | */ |
---|
382 | 374 | static int gelic_descr_prepare_rx(struct gelic_card *card, |
---|
383 | 375 | struct gelic_descr *descr) |
---|
384 | 376 | { |
---|
| 377 | + static const unsigned int rx_skb_size = |
---|
| 378 | + ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) + |
---|
| 379 | + GELIC_NET_RXBUF_ALIGN - 1; |
---|
| 380 | + dma_addr_t cpu_addr; |
---|
385 | 381 | int offset; |
---|
386 | | - unsigned int bufsize; |
---|
387 | 382 | |
---|
388 | 383 | if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) |
---|
389 | 384 | dev_info(ctodev(card), "%s: ERROR status\n", __func__); |
---|
390 | | - /* we need to round up the buffer size to a multiple of 128 */ |
---|
391 | | - bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN); |
---|
392 | 385 | |
---|
393 | | - /* and we need to have it 128 byte aligned, therefore we allocate a |
---|
394 | | - * bit more */ |
---|
395 | | - descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1); |
---|
| 386 | + descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size); |
---|
396 | 387 | if (!descr->skb) { |
---|
397 | 388 | descr->buf_addr = 0; /* tell DMAC don't touch memory */ |
---|
398 | | - dev_info(ctodev(card), |
---|
399 | | - "%s:allocate skb failed !!\n", __func__); |
---|
400 | 389 | return -ENOMEM; |
---|
401 | 390 | } |
---|
402 | | - descr->buf_size = cpu_to_be32(bufsize); |
---|
| 391 | + descr->buf_size = cpu_to_be32(rx_skb_size); |
---|
403 | 392 | descr->dmac_cmd_status = 0; |
---|
404 | 393 | descr->result_size = 0; |
---|
405 | 394 | descr->valid_size = 0; |
---|
.. | .. |
---|
410 | 399 | if (offset) |
---|
411 | 400 | skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset); |
---|
412 | 401 | /* io-mmu-map the skb */ |
---|
413 | | - descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card), |
---|
414 | | - descr->skb->data, |
---|
415 | | - GELIC_NET_MAX_MTU, |
---|
416 | | - DMA_FROM_DEVICE)); |
---|
417 | | - if (!descr->buf_addr) { |
---|
| 402 | + cpu_addr = dma_map_single(ctodev(card), descr->skb->data, |
---|
| 403 | + GELIC_NET_MAX_FRAME, DMA_FROM_DEVICE); |
---|
| 404 | + descr->buf_addr = cpu_to_be32(cpu_addr); |
---|
| 405 | + if (dma_mapping_error(ctodev(card), cpu_addr)) { |
---|
418 | 406 | dev_kfree_skb_any(descr->skb); |
---|
419 | 407 | descr->skb = NULL; |
---|
420 | 408 | dev_info(ctodev(card), |
---|
.. | .. |
---|
794 | 782 | |
---|
795 | 783 | buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE); |
---|
796 | 784 | |
---|
797 | | - if (!buf) { |
---|
| 785 | + if (dma_mapping_error(ctodev(card), buf)) { |
---|
798 | 786 | dev_err(ctodev(card), |
---|
799 | 787 | "dma map 2 failed (%p, %i). Dropping packet\n", |
---|
800 | 788 | skb->data, skb->len); |
---|
.. | .. |
---|
930 | 918 | data_error = be32_to_cpu(descr->data_error); |
---|
931 | 919 | /* unmap skb buffer */ |
---|
932 | 920 | dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr), |
---|
933 | | - GELIC_NET_MAX_MTU, |
---|
| 921 | + GELIC_NET_MAX_FRAME, |
---|
934 | 922 | DMA_FROM_DEVICE); |
---|
935 | 923 | |
---|
936 | 924 | skb_put(skb, be32_to_cpu(descr->valid_size)? |
---|
.. | .. |
---|
1163 | 1151 | * gelic_net_poll_controller - artificial interrupt for netconsole etc. |
---|
1164 | 1152 | * @netdev: interface device structure |
---|
1165 | 1153 | * |
---|
1166 | | - * see Documentation/networking/netconsole.txt |
---|
| 1154 | + * see Documentation/networking/netconsole.rst |
---|
1167 | 1155 | */ |
---|
1168 | 1156 | void gelic_net_poll_controller(struct net_device *netdev) |
---|
1169 | 1157 | { |
---|
.. | .. |
---|
1418 | 1406 | * |
---|
1419 | 1407 | * called, if tx hangs. Schedules a task that resets the interface |
---|
1420 | 1408 | */ |
---|
1421 | | -void gelic_net_tx_timeout(struct net_device *netdev) |
---|
| 1409 | +void gelic_net_tx_timeout(struct net_device *netdev, unsigned int txqueue) |
---|
1422 | 1410 | { |
---|
1423 | 1411 | struct gelic_card *card; |
---|
1424 | 1412 | |
---|