Skip to content

Commit c2d6469

Browse files
Gerhard Englederkuba-moo
authored andcommitted
tsnep: Move skb receive action to separate function
The function tsnep_rx_poll() is already pretty long and the skb receive action can be reused for XSK zero-copy support. Move page based skb receive to separate function. Signed-off-by: Gerhard Engleder <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2ea0a28 commit c2d6469

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

drivers/net/ethernet/engleder/tsnep_main.c

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,28 @@ static struct sk_buff *tsnep_build_skb(struct tsnep_rx *rx, struct page *page,
10761076
return skb;
10771077
}
10781078

1079+
static void tsnep_rx_page(struct tsnep_rx *rx, struct napi_struct *napi,
1080+
struct page *page, int length)
1081+
{
1082+
struct sk_buff *skb;
1083+
1084+
skb = tsnep_build_skb(rx, page, length);
1085+
if (skb) {
1086+
page_pool_release_page(rx->page_pool, page);
1087+
1088+
rx->packets++;
1089+
rx->bytes += length;
1090+
if (skb->pkt_type == PACKET_MULTICAST)
1091+
rx->multicast++;
1092+
1093+
napi_gro_receive(napi, skb);
1094+
} else {
1095+
page_pool_recycle_direct(rx->page_pool, page);
1096+
1097+
rx->dropped++;
1098+
}
1099+
}
1100+
10791101
static int tsnep_rx_poll(struct tsnep_rx *rx, struct napi_struct *napi,
10801102
int budget)
10811103
{
@@ -1085,7 +1107,6 @@ static int tsnep_rx_poll(struct tsnep_rx *rx, struct napi_struct *napi,
10851107
struct netdev_queue *tx_nq;
10861108
struct bpf_prog *prog;
10871109
struct xdp_buff xdp;
1088-
struct sk_buff *skb;
10891110
struct tsnep_tx *tx;
10901111
int desc_available;
10911112
int xdp_status = 0;
@@ -1170,21 +1191,7 @@ static int tsnep_rx_poll(struct tsnep_rx *rx, struct napi_struct *napi,
11701191
}
11711192
}
11721193

1173-
skb = tsnep_build_skb(rx, entry->page, length);
1174-
if (skb) {
1175-
page_pool_release_page(rx->page_pool, entry->page);
1176-
1177-
rx->packets++;
1178-
rx->bytes += length;
1179-
if (skb->pkt_type == PACKET_MULTICAST)
1180-
rx->multicast++;
1181-
1182-
napi_gro_receive(napi, skb);
1183-
} else {
1184-
page_pool_recycle_direct(rx->page_pool, entry->page);
1185-
1186-
rx->dropped++;
1187-
}
1194+
tsnep_rx_page(rx, napi, entry->page, length);
11881195
entry->page = NULL;
11891196
}
11901197

0 commit comments

Comments
 (0)