From 3fe1d0a48d21944e4ba98e2cbdae4b0753bbc25b Mon Sep 17 00:00:00 2001 From: Jesse Brandeburg Date: Tue, 22 Nov 2022 15:48:25 -0800 Subject: [PATCH 1/2] ixgbe: XDP: fix checker warning from rcu pointer The ixgbe driver uses an older style failure mode when initializing the XDP program and the queues. It causes some warnings when running C=2 checking builds (and it's the last one in the ethernet/intel tree). $ make W=1 C=2 M=`pwd`/drivers/net/ethernet/intel modules .../ixgbe_main.c:10301:25: error: incompatible types in comparison expression (different address spaces): .../ixgbe_main.c:10301:25: struct bpf_prog [noderef] __rcu * .../ixgbe_main.c:10301:25: struct bpf_prog * Fix the problem by removing the line that tried to re-xchg "the old_prog pointer" if there was an error, to make this driver act like the other drivers which return the error code without "pointer restoration." Also, update the "copy the pointer" logic to use WRITE_ONCE as many/all the other drivers do, which required making a change in two separate functions that write the xdp_prog variable in the ring. The code here was modeled after the code in i40e/i40e_xdp_setup(). NOTE: Compile-tested only. CC: Maciej Fijalkowski CC: Magnus Karlsson Signed-off-by: Jesse Brandeburg Acked-by: Maciej Fijalkowski Tested-by: Chandan Kumar Rout (A Contingent Worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index ab8370c413f3..93699d2ae051 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6647,7 +6647,7 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter, rx_ring->queue_index, ixgbe_rx_napi_id(rx_ring)) < 0) goto err; - rx_ring->xdp_prog = adapter->xdp_prog; + WRITE_ONCE(rx_ring->xdp_prog, adapter->xdp_prog); return 0; err: @@ -10297,14 +10297,13 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) synchronize_rcu(); err = ixgbe_setup_tc(dev, adapter->hw_tcs); - if (err) { - rcu_assign_pointer(adapter->xdp_prog, old_prog); + if (err) return -EINVAL; - } } else { - for (i = 0; i < adapter->num_rx_queues; i++) - (void)xchg(&adapter->rx_ring[i]->xdp_prog, - adapter->xdp_prog); + for (i = 0; i < adapter->num_rx_queues; i++) { + WRITE_ONCE(adapter->rx_ring[i]->xdp_prog, + adapter->xdp_prog); + } } if (old_prog) From 6f8179c192345b91fb643a6ce4d9396ba6ddd77e Mon Sep 17 00:00:00 2001 From: Sebastian Czapla Date: Mon, 12 Dec 2022 10:59:38 +0100 Subject: [PATCH 2/2] ixgbe: Filter out spurious link up indication Add delayed link state recheck to filter false link up indication caused by transceiver with no fiber cable attached. Signed-off-by: Sebastian Czapla Tested-by: Sunitha Mekala (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- .../net/ethernet/intel/ixgbe/ixgbe_common.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 38c4609bd429..878dd8dff528 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -3292,13 +3292,14 @@ static bool ixgbe_need_crosstalk_fix(struct ixgbe_hw *hw) s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, bool *link_up, bool link_up_wait_to_complete) { + bool crosstalk_fix_active = ixgbe_need_crosstalk_fix(hw); u32 links_reg, links_orig; u32 i; /* If Crosstalk fix enabled do the sanity check of making sure * the SFP+ cage is full. */ - if (ixgbe_need_crosstalk_fix(hw)) { + if (crosstalk_fix_active) { u32 sfp_cage_full; switch (hw->mac.type) { @@ -3346,10 +3347,24 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); } } else { - if (links_reg & IXGBE_LINKS_UP) + if (links_reg & IXGBE_LINKS_UP) { + if (crosstalk_fix_active) { + /* Check the link state again after a delay + * to filter out spurious link up + * notifications. + */ + mdelay(5); + links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); + if (!(links_reg & IXGBE_LINKS_UP)) { + *link_up = false; + *speed = IXGBE_LINK_SPEED_UNKNOWN; + return 0; + } + } *link_up = true; - else + } else { *link_up = false; + } } switch (links_reg & IXGBE_LINKS_SPEED_82599) {