Skip to content

Commit 9116e5e

Browse files
magnus-karlssonborkmann
authored andcommitted
xsk: replace ndo_xsk_async_xmit with ndo_xsk_wakeup
This commit replaces ndo_xsk_async_xmit with ndo_xsk_wakeup. This new ndo provides the same functionality as before but with the addition of a new flags field that is used to specifiy if Rx, Tx or both should be woken up. The previous ndo only woke up Tx, as implied by the name. The i40e and ixgbe drivers (which are all the supported ones) are updated with this new interface. This new ndo will be used by the new need_wakeup functionality of XDP sockets that need to be able to wake up both Rx and Tx driver processing. Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent e032500 commit 9116e5e

12 files changed

Lines changed: 32 additions & 19 deletions

File tree

‎drivers/net/ethernet/intel/i40e/i40e_main.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12570,7 +12570,8 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi,
1257012570
if (need_reset && prog)
1257112571
for (i = 0; i < vsi->num_queue_pairs; i++)
1257212572
if (vsi->xdp_rings[i]->xsk_umem)
12573-
(void)i40e_xsk_async_xmit(vsi->netdev, i);
12573+
(void)i40e_xsk_wakeup(vsi->netdev, i,
12574+
XDP_WAKEUP_RX);
1257412575

1257512576
return 0;
1257612577
}
@@ -12892,7 +12893,7 @@ static const struct net_device_ops i40e_netdev_ops = {
1289212893
.ndo_bridge_setlink = i40e_ndo_bridge_setlink,
1289312894
.ndo_bpf = i40e_xdp,
1289412895
.ndo_xdp_xmit = i40e_xdp_xmit,
12895-
.ndo_xsk_async_xmit = i40e_xsk_async_xmit,
12896+
.ndo_xsk_wakeup = i40e_xsk_wakeup,
1289612897
.ndo_dfwd_add_station = i40e_fwd_add,
1289712898
.ndo_dfwd_del_station = i40e_fwd_del,
1289812899
};

‎drivers/net/ethernet/intel/i40e/i40e_xsk.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int i40e_xsk_umem_enable(struct i40e_vsi *vsi, struct xdp_umem *umem,
116116
return err;
117117

118118
/* Kick start the NAPI context so that receiving will start */
119-
err = i40e_xsk_async_xmit(vsi->netdev, qid);
119+
err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);
120120
if (err)
121121
return err;
122122
}
@@ -765,13 +765,14 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,
765765
}
766766

767767
/**
768-
* i40e_xsk_async_xmit - Implements the ndo_xsk_async_xmit
768+
* i40e_xsk_wakeup - Implements the ndo_xsk_wakeup
769769
* @dev: the netdevice
770770
* @queue_id: queue id to wake up
771+
* @flags: ignored in our case since we have Rx and Tx in the same NAPI.
771772
*
772773
* Returns <0 for errors, 0 otherwise.
773774
**/
774-
int i40e_xsk_async_xmit(struct net_device *dev, u32 queue_id)
775+
int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
775776
{
776777
struct i40e_netdev_priv *np = netdev_priv(dev);
777778
struct i40e_vsi *vsi = np->vsi;

‎drivers/net/ethernet/intel/i40e/i40e_xsk.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget);
1818

1919
bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,
2020
struct i40e_ring *tx_ring, int napi_budget);
21-
int i40e_xsk_async_xmit(struct net_device *dev, u32 queue_id);
21+
int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags);
2222

2323
#endif /* _I40E_XSK_H_ */

‎drivers/net/ethernet/intel/ixgbe/ixgbe_main.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10263,7 +10263,8 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
1026310263
if (need_reset && prog)
1026410264
for (i = 0; i < adapter->num_rx_queues; i++)
1026510265
if (adapter->xdp_ring[i]->xsk_umem)
10266-
(void)ixgbe_xsk_async_xmit(adapter->netdev, i);
10266+
(void)ixgbe_xsk_wakeup(adapter->netdev, i,
10267+
XDP_WAKEUP_RX);
1026710268

1026810269
return 0;
1026910270
}
@@ -10382,7 +10383,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
1038210383
.ndo_features_check = ixgbe_features_check,
1038310384
.ndo_bpf = ixgbe_xdp,
1038410385
.ndo_xdp_xmit = ixgbe_xdp_xmit,
10385-
.ndo_xsk_async_xmit = ixgbe_xsk_async_xmit,
10386+
.ndo_xsk_wakeup = ixgbe_xsk_wakeup,
1038610387
};
1038710388

1038810389
static void ixgbe_disable_txr_hw(struct ixgbe_adapter *adapter,

‎drivers/net/ethernet/intel/ixgbe/ixgbe_txrx_common.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int ixgbe_clean_rx_irq_zc(struct ixgbe_q_vector *q_vector,
4242
void ixgbe_xsk_clean_rx_ring(struct ixgbe_ring *rx_ring);
4343
bool ixgbe_clean_xdp_tx_irq(struct ixgbe_q_vector *q_vector,
4444
struct ixgbe_ring *tx_ring, int napi_budget);
45-
int ixgbe_xsk_async_xmit(struct net_device *dev, u32 queue_id);
45+
int ixgbe_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags);
4646
void ixgbe_xsk_clean_tx_ring(struct ixgbe_ring *tx_ring);
4747

4848
#endif /* #define _IXGBE_TXRX_COMMON_H_ */

‎drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
100100
ixgbe_txrx_ring_enable(adapter, qid);
101101

102102
/* Kick start the NAPI context so that receiving will start */
103-
err = ixgbe_xsk_async_xmit(adapter->netdev, qid);
103+
err = ixgbe_xsk_wakeup(adapter->netdev, qid, XDP_WAKEUP_RX);
104104
if (err)
105105
return err;
106106
}
@@ -692,7 +692,7 @@ bool ixgbe_clean_xdp_tx_irq(struct ixgbe_q_vector *q_vector,
692692
return budget > 0 && xmit_done;
693693
}
694694

695-
int ixgbe_xsk_async_xmit(struct net_device *dev, u32 qid)
695+
int ixgbe_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
696696
{
697697
struct ixgbe_adapter *adapter = netdev_priv(dev);
698698
struct ixgbe_ring *ring;

‎drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "en/params.h"
88
#include <net/xdp_sock.h>
99

10-
int mlx5e_xsk_async_xmit(struct net_device *dev, u32 qid)
10+
int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
1111
{
1212
struct mlx5e_priv *priv = netdev_priv(dev);
1313
struct mlx5e_params *params = &priv->channels.params;

‎drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* TX data path */
1010

11-
int mlx5e_xsk_async_xmit(struct net_device *dev, u32 qid);
11+
int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags);
1212

1313
bool mlx5e_xsk_tx(struct mlx5e_xdpsq *sq, unsigned int budget);
1414

‎drivers/net/ethernet/mellanox/mlx5/core/en_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4540,7 +4540,7 @@ const struct net_device_ops mlx5e_netdev_ops = {
45404540
.ndo_tx_timeout = mlx5e_tx_timeout,
45414541
.ndo_bpf = mlx5e_xdp,
45424542
.ndo_xdp_xmit = mlx5e_xdp_xmit,
4543-
.ndo_xsk_async_xmit = mlx5e_xsk_async_xmit,
4543+
.ndo_xsk_wakeup = mlx5e_xsk_wakeup,
45444544
#ifdef CONFIG_MLX5_EN_ARFS
45454545
.ndo_rx_flow_steer = mlx5e_rx_flow_steer,
45464546
#endif

‎include/linux/netdevice.h‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,10 @@ struct netdev_bpf {
901901
};
902902
};
903903

904+
/* Flags for ndo_xsk_wakeup. */
905+
#define XDP_WAKEUP_RX (1 << 0)
906+
#define XDP_WAKEUP_TX (1 << 1)
907+
904908
#ifdef CONFIG_XFRM_OFFLOAD
905909
struct xfrmdev_ops {
906910
int (*xdo_dev_state_add) (struct xfrm_state *x);
@@ -1227,6 +1231,12 @@ struct tlsdev_ops;
12271231
* that got dropped are freed/returned via xdp_return_frame().
12281232
* Returns negative number, means general error invoking ndo, meaning
12291233
* no frames were xmit'ed and core-caller will free all frames.
1234+
* int (*ndo_xsk_wakeup)(struct net_device *dev, u32 queue_id, u32 flags);
1235+
* This function is used to wake up the softirq, ksoftirqd or kthread
1236+
* responsible for sending and/or receiving packets on a specific
1237+
* queue id bound to an AF_XDP socket. The flags field specifies if
1238+
* only RX, only Tx, or both should be woken up using the flags
1239+
* XDP_WAKEUP_RX and XDP_WAKEUP_TX.
12301240
* struct devlink_port *(*ndo_get_devlink_port)(struct net_device *dev);
12311241
* Get devlink port instance associated with a given netdev.
12321242
* Called with a reference on the netdevice and devlink locks only,
@@ -1426,8 +1436,8 @@ struct net_device_ops {
14261436
int (*ndo_xdp_xmit)(struct net_device *dev, int n,
14271437
struct xdp_frame **xdp,
14281438
u32 flags);
1429-
int (*ndo_xsk_async_xmit)(struct net_device *dev,
1430-
u32 queue_id);
1439+
int (*ndo_xsk_wakeup)(struct net_device *dev,
1440+
u32 queue_id, u32 flags);
14311441
struct devlink_port * (*ndo_get_devlink_port)(struct net_device *dev);
14321442
};
14331443

0 commit comments

Comments
 (0)