Skip to content

Commit 19b3bb5

Browse files
glevanddavem330
authored andcommitted
net/ps3_gelic_net: Fix RX sk_buff length
The Gelic Ethernet device needs to have the RX sk_buffs aligned to GELIC_NET_RXBUF_ALIGN, and also the length of the RX sk_buffs must be a multiple of GELIC_NET_RXBUF_ALIGN. The current Gelic Ethernet driver was not allocating sk_buffs large enough to allow for this alignment. Also, correct the maximum and minimum MTU sizes, and add a new preprocessor macro for the maximum frame size, GELIC_NET_MAX_FRAME. Fixes various randomly occurring runtime network errors. Fixes: 02c1889 ("ps3: gigabit ethernet driver for PS3, take3") Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7d722c9 commit 19b3bb5

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

drivers/net/ethernet/toshiba/ps3_gelic_net.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,26 +365,27 @@ static int gelic_card_init_chain(struct gelic_card *card,
365365
*
366366
* allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
367367
* Activate the descriptor state-wise
368+
*
369+
* Gelic RX sk_buffs must be aligned to GELIC_NET_RXBUF_ALIGN and the length
370+
* must be a multiple of GELIC_NET_RXBUF_ALIGN.
368371
*/
369372
static int gelic_descr_prepare_rx(struct gelic_card *card,
370373
struct gelic_descr *descr)
371374
{
375+
static const unsigned int rx_skb_size =
376+
ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) +
377+
GELIC_NET_RXBUF_ALIGN - 1;
372378
int offset;
373-
unsigned int bufsize;
374379

375380
if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
376381
dev_info(ctodev(card), "%s: ERROR status\n", __func__);
377-
/* we need to round up the buffer size to a multiple of 128 */
378-
bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
379382

380-
/* and we need to have it 128 byte aligned, therefore we allocate a
381-
* bit more */
382-
descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1);
383+
descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
383384
if (!descr->skb) {
384385
descr->buf_addr = 0; /* tell DMAC don't touch memory */
385386
return -ENOMEM;
386387
}
387-
descr->buf_size = cpu_to_be32(bufsize);
388+
descr->buf_size = cpu_to_be32(rx_skb_size);
388389
descr->dmac_cmd_status = 0;
389390
descr->result_size = 0;
390391
descr->valid_size = 0;
@@ -397,7 +398,7 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
397398
/* io-mmu-map the skb */
398399
descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card),
399400
descr->skb->data,
400-
GELIC_NET_MAX_MTU,
401+
GELIC_NET_MAX_FRAME,
401402
DMA_FROM_DEVICE));
402403
if (!descr->buf_addr) {
403404
dev_kfree_skb_any(descr->skb);
@@ -915,7 +916,7 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
915916
data_error = be32_to_cpu(descr->data_error);
916917
/* unmap skb buffer */
917918
dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr),
918-
GELIC_NET_MAX_MTU,
919+
GELIC_NET_MAX_FRAME,
919920
DMA_FROM_DEVICE);
920921

921922
skb_put(skb, be32_to_cpu(descr->valid_size)?

drivers/net/ethernet/toshiba/ps3_gelic_net.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#define GELIC_NET_RX_DESCRIPTORS 128 /* num of descriptors */
2020
#define GELIC_NET_TX_DESCRIPTORS 128 /* num of descriptors */
2121

22-
#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN
23-
#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN
22+
#define GELIC_NET_MAX_FRAME 2312
23+
#define GELIC_NET_MAX_MTU 2294
24+
#define GELIC_NET_MIN_MTU 64
2425
#define GELIC_NET_RXBUF_ALIGN 128
2526
#define GELIC_CARD_RX_CSUM_DEFAULT 1 /* hw chksum */
2627
#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ

0 commit comments

Comments
 (0)