Skip to content

Commit 6dc75fc

Browse files
sriramykuba-moo
authored andcommitted
igb: Introduce igb_xdp_is_enabled()
Introduce igb_xdp_is_enabled() to check if an XDP program is assigned to the device. Use that wherever xdp_prog is read and evaluated. Signed-off-by: Sriram Yagnaraman <[email protected]> [Kurt: Split patches and use READ_ONCE()] Signed-off-by: Kurt Kanzenbach <[email protected]> Acked-by: Maciej Fijalkowski <[email protected]> Tested-by: George Kuruvinakunnel <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f70b864 commit 6dc75fc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/net/ethernet/intel/igb/igb.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ static inline struct igb_ring *igb_xdp_tx_queue_mapping(struct igb_adapter *adap
826826
return adapter->tx_ring[r_idx];
827827
}
828828

829+
static inline bool igb_xdp_is_enabled(struct igb_adapter *adapter)
830+
{
831+
return !!READ_ONCE(adapter->xdp_prog);
832+
}
833+
829834
int igb_add_filter(struct igb_adapter *adapter,
830835
struct igb_nfc_filter *input);
831836
int igb_erase_filter(struct igb_adapter *adapter,

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,7 +2930,8 @@ int igb_xdp_xmit_back(struct igb_adapter *adapter, struct xdp_buff *xdp)
29302930
/* During program transitions its possible adapter->xdp_prog is assigned
29312931
* but ring has not been configured yet. In this case simply abort xmit.
29322932
*/
2933-
tx_ring = adapter->xdp_prog ? igb_xdp_tx_queue_mapping(adapter) : NULL;
2933+
tx_ring = igb_xdp_is_enabled(adapter) ?
2934+
igb_xdp_tx_queue_mapping(adapter) : NULL;
29342935
if (unlikely(!tx_ring))
29352936
return IGB_XDP_CONSUMED;
29362937

@@ -2963,7 +2964,8 @@ static int igb_xdp_xmit(struct net_device *dev, int n,
29632964
/* During program transitions its possible adapter->xdp_prog is assigned
29642965
* but ring has not been configured yet. In this case simply abort xmit.
29652966
*/
2966-
tx_ring = adapter->xdp_prog ? igb_xdp_tx_queue_mapping(adapter) : NULL;
2967+
tx_ring = igb_xdp_is_enabled(adapter) ?
2968+
igb_xdp_tx_queue_mapping(adapter) : NULL;
29672969
if (unlikely(!tx_ring))
29682970
return -ENXIO;
29692971

@@ -6597,7 +6599,7 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
65976599
struct igb_adapter *adapter = netdev_priv(netdev);
65986600
int max_frame = new_mtu + IGB_ETH_PKT_HDR_PAD;
65996601

6600-
if (adapter->xdp_prog) {
6602+
if (igb_xdp_is_enabled(adapter)) {
66016603
int i;
66026604

66036605
for (i = 0; i < adapter->num_rx_queues; i++) {

0 commit comments

Comments
 (0)