aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
diff options
context:
space:
mode:
authorHoratiu Vultur <horatiu.vultur@microchip.com>2022-11-23 21:31:38 +0100
committerDavid S. Miller <davem@davemloft.net>2022-11-25 10:38:10 +0000
commit19c6f534f63608fbf966897b2c64fefcb916dc08 (patch)
tree70ba61a591ba70f1d29ac42f101d4de0cbb907cc /drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
parent560c7223d6e48171d5a34ca07f6c886d364bcbdf (diff)
net: lan966x: Add support for XDP_TX
Extend lan966x XDP support with the action XDP_TX. In this case when the received buffer needs to execute XDP_TX, the buffer will be moved to the TX buffers. So a new RX buffer will be allocated. When the TX finish with the frame, it would give back the buffer to the page pool. Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c')
-rw-r--r--drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
index ba7aa6df9d0e..8996110a0846 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
@@ -54,6 +54,7 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len)
{
struct bpf_prog *xdp_prog = port->xdp_prog;
struct lan966x *lan966x = port->lan966x;
+ struct xdp_frame *xdpf;
struct xdp_buff xdp;
u32 act;
@@ -66,6 +67,13 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len)
switch (act) {
case XDP_PASS:
return FDMA_PASS;
+ case XDP_TX:
+ xdpf = xdp_convert_buff_to_frame(&xdp);
+ if (!xdpf)
+ return FDMA_DROP;
+
+ return lan966x_fdma_xmit_xdpf(port, xdpf, page) ?
+ FDMA_DROP : FDMA_TX;
default:
bpf_warn_invalid_xdp_action(port->dev, xdp_prog, act);
fallthrough;