Skip to content

Commit c88ee6c

Browse files
atenartclaudiubeznea
authored andcommitted
net: macb: use GRO
This patch updates the macb driver to use NAPI GRO helpers when receiving SKBs. This improves performances. Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
1 parent d40397b commit c88ee6c

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

drivers/net/ethernet/cadence/macb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,8 @@ struct macb_or_gem_ops {
10631063
int (*mog_alloc_rx_buffers)(struct macb *bp);
10641064
void (*mog_free_rx_buffers)(struct macb *bp);
10651065
void (*mog_init_rings)(struct macb *bp);
1066-
int (*mog_rx)(struct macb_queue *queue, int budget);
1066+
int (*mog_rx)(struct macb_queue *queue, struct napi_struct *napi,
1067+
int budget);
10671068
};
10681069

10691070
/* MACB-PTP interface: adapt to platform needs. */

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ static void discard_partial_frame(struct macb_queue *queue, unsigned int begin,
10181018
*/
10191019
}
10201020

1021-
static int gem_rx(struct macb_queue *queue, int budget)
1021+
static int gem_rx(struct macb_queue *queue, struct napi_struct *napi,
1022+
int budget)
10221023
{
10231024
struct macb *bp = queue->bp;
10241025
unsigned int len;
@@ -1100,16 +1101,16 @@ static int gem_rx(struct macb_queue *queue, int budget)
11001101
skb->data, 32, true);
11011102
#endif
11021103

1103-
netif_receive_skb(skb);
1104+
napi_gro_receive(napi, skb);
11041105
}
11051106

11061107
gem_rx_refill(queue);
11071108

11081109
return count;
11091110
}
11101111

1111-
static int macb_rx_frame(struct macb_queue *queue, unsigned int first_frag,
1112-
unsigned int last_frag)
1112+
static int macb_rx_frame(struct macb_queue *queue, struct napi_struct *napi,
1113+
unsigned int first_frag, unsigned int last_frag)
11131114
{
11141115
unsigned int len;
11151116
unsigned int frag;
@@ -1185,7 +1186,7 @@ static int macb_rx_frame(struct macb_queue *queue, unsigned int first_frag,
11851186
bp->dev->stats.rx_bytes += skb->len;
11861187
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
11871188
skb->len, skb->csum);
1188-
netif_receive_skb(skb);
1189+
napi_gro_receive(napi, skb);
11891190

11901191
return 0;
11911192
}
@@ -1208,7 +1209,8 @@ static inline void macb_init_rx_ring(struct macb_queue *queue)
12081209
queue->rx_tail = 0;
12091210
}
12101211

1211-
static int macb_rx(struct macb_queue *queue, int budget)
1212+
static int macb_rx(struct macb_queue *queue, struct napi_struct *napi,
1213+
int budget)
12121214
{
12131215
struct macb *bp = queue->bp;
12141216
bool reset_rx_queue = false;
@@ -1245,7 +1247,7 @@ static int macb_rx(struct macb_queue *queue, int budget)
12451247
continue;
12461248
}
12471249

1248-
dropped = macb_rx_frame(queue, first_frag, tail);
1250+
dropped = macb_rx_frame(queue, napi, first_frag, tail);
12491251
first_frag = -1;
12501252
if (unlikely(dropped < 0)) {
12511253
reset_rx_queue = true;
@@ -1299,7 +1301,7 @@ static int macb_poll(struct napi_struct *napi, int budget)
12991301
netdev_vdbg(bp->dev, "poll: status = %08lx, budget = %d\n",
13001302
(unsigned long)status, budget);
13011303

1302-
work_done = bp->macbgem_ops.mog_rx(queue, budget);
1304+
work_done = bp->macbgem_ops.mog_rx(queue, napi, budget);
13031305
if (work_done < budget) {
13041306
napi_complete_done(napi, work_done);
13051307

0 commit comments

Comments
 (0)