i40e: move I40E_FLAG_FILTER_SYNC to a state bit
Subsystems (2)
PATCH 1/8 i40e: move I40E_FLAG_FILTER_SYNC to a state bit
From: Jacob Keller <[email protected]>
The I40E_FLAG_FILTER_SYNC flag is modified during run time possibly when the RTNL lock is not held. Thus, it should not be part of pf->flags, and instead should be using atomic bit operations in the pf->state field.
Create a __I40E_MACVLAN_SYNC_PENDING state bit, and use it instead of the old I40E_FLAG_FILTER_SYNC flag.
This is part of a larger effort to remove the need for cmpxchg64 in i40e_set_priv_flags().
--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -1
@@ -162,6 +162,7 @@ enum i40e_state_t { __I40E_RESET_FAILED, __I40E_PORT_SUSPENDED, __I40E_VF_DISABLE, + __I40E_MACVLAN_SYNC_PENDING,/* This must be last as it determines the size of the BITMAP */ __I40E_STATE_SIZE__, };
@@ -516,7 +517,7 @@ struct i40e_pf {#define I40E_FLAG_MSIX_ENABLED BIT_ULL(2)#define I40E_FLAG_RSS_ENABLED BIT_ULL(3)#define I40E_FLAG_VMDQ_ENABLED BIT_ULL(4) -#define I40E_FLAG_FILTER_SYNC BIT_ULL(5) +/* Gap for BIT_ULL(5) */ #define I40E_FLAG_SRIOV_ENABLED BIT_ULL(6)#define I40E_FLAG_DCB_CAPABLE BIT_ULL(7)#define I40E_FLAG_DCB_ENABLED BIT_ULL(8)
drivers/net/ethernet/intel/i40e/i40e_main.c +9 -7
@@ -1382,7 +1382,7 @@ struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,hash_add (vsi->mac_filter_hash, &f->hlist, key); vsi->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; - vsi->back->flags |=I40E_FLAG_FILTER_SYNC ; +set_bit (__I40E_MACVLAN_SYNC_PENDING, vsi->back->state); }/* If we're asked to add a filter that has been marked for removal, it
@@ -1432,7 +1432,7 @@ void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f) } vsi->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; - vsi->back->flags |=I40E_FLAG_FILTER_SYNC ; +set_bit (__I40E_MACVLAN_SYNC_PENDING, vsi->state); }/**
@@ -1955,7 +1955,7 @@ static void i40e_set_rx_mode(struct net_device *netdev)/* check for other flag changes */ if (vsi->current_netdev_flags != vsi->netdev->flags) { vsi->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; - vsi->back->flags |=I40E_FLAG_FILTER_SYNC ; +set_bit (__I40E_MACVLAN_SYNC_PENDING, vsi->back->state); } }
@@ -2577,9 +2577,10 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf) {int v; -if (!pf || !(pf->flags &I40E_FLAG_FILTER_SYNC )) +if (!pf) +return ; +if (!test_and_clear_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state))return ; - pf->flags &= ~I40E_FLAG_FILTER_SYNC ;for (v =0 ; v < pf->num_alloc_vsi; v++) { if (pf->vsi[v] &&
@@ -2588,7 +2589,8 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)if (ret) {/* come back and try again later */ - pf->flags |=I40E_FLAG_FILTER_SYNC ; +set_bit (__I40E_MACVLAN_SYNC_PENDING, + pf->state);break ; } }
@@ -12240,7 +12242,7 @@ static int i40e_add_vsi(struct i40e_vsi *vsi)if (f_count) { vsi->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; - pf->flags |=I40E_FLAG_FILTER_SYNC ; +set_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state); }/* Update VSI BW information */
Signature · 1 line
2.9.5
PATCH 2/8 i40e: move I40E_FLAG_UDP_FILTER_SYNC to the state field
From: Jacob Keller <[email protected]>
This flag is modified during run time, possibly even when the RTNL lock is not held. Additionally it has a few places which should be using test_and_set or test_and_clear atomic bit operations.
Create a new state bit __I40E_UDP_SYNC_PENDING and use it instead of the ole I40E_FLAG_UDP_FILTER_SYNC flag.
This is part of a larger effort to remove the need for using cmpxchg64 in i40e_set_priv_flags.
--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -1
@@ -163,6 +163,7 @@ enum i40e_state_t { __I40E_PORT_SUSPENDED, __I40E_VF_DISABLE, __I40E_MACVLAN_SYNC_PENDING, + __I40E_UDP_FILTER_SYNC_PENDING,/* This must be last as it determines the size of the BITMAP */ __I40E_STATE_SIZE__, };
@@ -526,7 +527,7 @@ struct i40e_pf {#define I40E_FLAG_FD_SB_AUTO_DISABLED BIT_ULL(11)#define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT_ULL(12)#define I40E_FLAG_MFP_ENABLED BIT_ULL(13) -#define I40E_FLAG_UDP_FILTER_SYNC BIT_ULL(14) +/* Gap for BIT_ULL(14) */ #define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(15)#define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(16)#define I40E_FLAG_VEB_STATS_ENABLED BIT_ULL(17)
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -6
@@ -9721,7 +9721,7 @@ static void i40e_sync_udp_filters(struct i40e_pf *pf) pf->pending_udp_bitmap |=BIT_ULL (i); } - pf->flags |=I40E_FLAG_UDP_FILTER_SYNC ; +set_bit (__I40E_UDP_FILTER_SYNC_PENDING, pf->state); }/**
@@ -9735,11 +9735,9 @@ static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)u16 port;int i; -if (!(pf->flags &I40E_FLAG_UDP_FILTER_SYNC )) +if (!test_and_clear_bit (__I40E_UDP_FILTER_SYNC_PENDING, pf->state))return ; - pf->flags &= ~I40E_FLAG_UDP_FILTER_SYNC ; -for (i =0 ; i <I40E_MAX_PF_UDP_OFFLOAD_PORTS ; i++) {if (pf->pending_udp_bitmap &BIT_ULL (i)) { pf->pending_udp_bitmap &= ~BIT_ULL (i);
@@ -11439,7 +11437,7 @@ static void i40e_udp_tunnel_add(struct net_device *netdev,/* New port: add it and mark its index in the bitmap */ pf->udp_ports[next_idx].port = port; pf->pending_udp_bitmap |=BIT_ULL (next_idx); - pf->flags |=I40E_FLAG_UDP_FILTER_SYNC ; +set_bit (__I40E_UDP_FILTER_SYNC_PENDING, pf->state); }/**
@@ -11480,7 +11478,7 @@ static void i40e_udp_tunnel_del(struct net_device *netdev,*/ pf->udp_ports[idx].port =0 ; pf->pending_udp_bitmap |=BIT_ULL (idx); - pf->flags |=I40E_FLAG_UDP_FILTER_SYNC ; +set_bit (__I40E_UDP_FILTER_SYNC_PENDING, pf->state);return ; not_found:
Signature · 1 line
2.9.5
Bowers
PATCH 2/8 i40e: move I40E_FLAG_UDP_FILTER_SYNC to the state field
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 2/8] i40e: moveI40E_FLAG_UDP_FILTER_SYNCto the state fieldFrom: Jacob Keller <[email protected]>
This flag is modified during run time, possibly even when the RTNL lock is not held. Additionally it has a few places which should be using
test_and_setortest_and_clearatomic bit operations.Create a new state bit
__I40E_UDP_SYNC_PENDINGand use it instead of the oleI40E_FLAG_UDP_FILTER_SYNCflag.
Quoted 8 lines
This is part of a larger effort to remove the need for using cmpxchg64 in
i40e_set_priv_flags.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-)
PATCH 3/8 i40e: move AUTO_DISABLED flags into the state field
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The two Flow Directory auto disable flags are used at run time to mark when the flow director features needed to be disabled. Thus the flags could change even when the RTNL lock is not held.
They also have some code constructions which really should be test_and_set or test_and_clear using atomic bit operations.
Create new state fields to mark this, and stop including them in pf->flags.
This is part of a larger effort to remove the need for cmpxchg64 in i40e_set_priv_flags().
--- drivers/net/ethernet/intel/i40e/i40e.h | 5 +++-- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 23 +++++++++-------------- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 21 +++++++++++++-------- 4 files changed, 27 insertions(+), 26 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +3 -2
@@ -159,6 +159,8 @@ enum i40e_state_t { __I40E_BAD_EEPROM, __I40E_DOWN_REQUESTED, __I40E_FD_FLUSH_REQUESTED, + __I40E_FD_ATR_AUTO_DISABLED, + __I40E_FD_SB_AUTO_DISABLED, __I40E_RESET_FAILED, __I40E_PORT_SUSPENDED, __I40E_VF_DISABLE,
@@ -524,8 +526,7 @@ struct i40e_pf {#define I40E_FLAG_DCB_ENABLED BIT_ULL(8)#define I40E_FLAG_FD_SB_ENABLED BIT_ULL(9)#define I40E_FLAG_FD_ATR_ENABLED BIT_ULL(10) -#define I40E_FLAG_FD_SB_AUTO_DISABLED BIT_ULL(11) -#define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT_ULL(12) +/* Gap for BIT_ULL(11) and BIT_ULL(12) */ #define I40E_FLAG_MFP_ENABLED BIT_ULL(13)/* Gap for BIT_ULL(14) */ #define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(15)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +2 -2
@@ -3951,7 +3951,7 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,if (!(pf->flags &I40E_FLAG_FD_SB_ENABLED ))return -EOPNOTSUPP ; -if (pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED ) +if (test_bit (__I40E_FD_SB_AUTO_DISABLED, pf->state))return -ENOSPC ; if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
@@ -4460,7 +4460,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)/* Flush current ATR settings if ATR was disabled */ if ((changed_flags &I40E_FLAG_FD_ATR_ENABLED ) && !(pf->flags &I40E_FLAG_FD_ATR_ENABLED )) { - pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ; +set_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state);set_bit (__I40E_FD_FLUSH_REQUESTED, pf->state); }
drivers/net/ethernet/intel/i40e/i40e_main.c +9 -14
@@ -1083,13 +1083,13 @@ static void i40e_update_pf_stats(struct i40e_pf *pf) &osd->rx_lpi_count, &nsd->rx_lpi_count);if (pf->flags &I40E_FLAG_FD_SB_ENABLED && - !(pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED )) + !test_bit (__I40E_FD_SB_AUTO_DISABLED, pf->state)) nsd->fd_sb_status = true;else nsd->fd_sb_status = false;if (pf->flags &I40E_FLAG_FD_ATR_ENABLED && - !(pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED )) + !test_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state)) nsd->fd_atr_status = true;else nsd->fd_atr_status = false;
@@ -8144,12 +8144,10 @@ u32 i40e_get_global_fd_count(struct i40e_pf *pf)**/ static void i40e_reenable_fdir_sb (struct i40e_pf *pf) { -if (pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED ) { - pf->flags &= ~I40E_FLAG_FD_SB_AUTO_DISABLED ; +if (test_and_clear_bit (__I40E_FD_SB_AUTO_DISABLED, pf->state))if ((pf->flags &I40E_FLAG_FD_SB_ENABLED ) && (I40E_DEBUG_FD & pf->hw.debug_mask))dev_info (&pf->pdev->dev,"FD Sideband/ntuple is being enabled since we have space in the table now\n" ); - } }/**
@@ -8158,7 +8156,7 @@ static void i40e_reenable_fdir_sb(struct i40e_pf *pf)**/ static void i40e_reenable_fdir_atr (struct i40e_pf *pf) { -if (pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED ) { +if (test_and_clear_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state)) {/* ATR uses the same filtering logic as SB rules. It only * functions properly if the input set mask is at the default * settings. It is safe to restore the default input set
@@ -8168,7 +8166,6 @@ static void i40e_reenable_fdir_atr(struct i40e_pf *pf)I40E_L3_SRC_MASK |I40E_L3_DST_MASK | I40E_L4_SRC_MASK | I40E_L4_DST_MASK); - pf->flags &= ~I40E_FLAG_FD_ATR_AUTO_DISABLED ;if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && (I40E_DEBUG_FD & pf->hw.debug_mask))dev_info (&pf->pdev->dev,"ATR is being enabled since we have space in the table and there are no conflicting ntuple rules\n" );
@@ -8291,7 +8288,7 @@ static void i40e_fdir_flush_and_replay(struct i40e_pf *pf) } pf->fd_flush_timestamp = jiffies; - pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ; +set_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state);/* flush all filters */ wr32 (&pf->hw,I40E_PFQF_CTL_1 ,I40E_PFQF_CTL_1_CLEARFDTABLE_MASK );
@@ -8311,7 +8308,7 @@ static void i40e_fdir_flush_and_replay(struct i40e_pf *pf)/* replay sideband filters */ i40e_fdir_filter_restore (pf->vsi[pf->lan_vsi]);if (!disable_atr && !pf->fd_tcp4_filter_cnt) - pf->flags &= ~I40E_FLAG_FD_ATR_AUTO_DISABLED ; +clear_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state);clear_bit (__I40E_FD_FLUSH_REQUESTED, pf->state);if (I40E_DEBUG_FD & pf->hw.debug_mask)dev_info (&pf->pdev->dev,"FD Filter table flushed and FD-SB replayed.\n" );
@@ -11291,20 +11288,18 @@ bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features) need_reset = true;i40e_fdir_filter_exit (pf); } - pf->flags &= ~(I40E_FLAG_FD_SB_ENABLED | -I40E_FLAG_FD_SB_AUTO_DISABLED ); + pf->flags &= ~I40E_FLAG_FD_SB_ENABLED ; +clear_bit (__I40E_FD_SB_AUTO_DISABLED, pf->state); pf->flags |=I40E_FLAG_FD_SB_INACTIVE ;/* reset fd counters */ pf->fd_add_err =0 ; pf->fd_atr_cnt =0 ;/* if ATR was auto disabled it can be re-enabled. */ -if (pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED ) { - pf->flags &= ~I40E_FLAG_FD_ATR_AUTO_DISABLED ; +if (test_and_clear_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state))if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && (I40E_DEBUG_FD & pf->hw.debug_mask))dev_info (&pf->pdev->dev,"ATR re-enabled.\n" ); - } }return need_reset; }
drivers/net/ethernet/intel/i40e/i40e_txrx.c +13 -8
@@ -336,7 +336,7 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) &&I40E_DEBUG_FD & pf->hw.debug_mask)dev_info (&pf->pdev->dev,"Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n" ); - pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ; +set_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state); }else { pf->fd_tcp4_filter_cnt--; }
@@ -594,8 +594,14 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring, pf->fd_atr_cnt =i40e_get_current_atr_cnt (pf);if ((rx_desc->wb.qword0.hi_dword.fd_id ==0 ) && - pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED ) { - pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ; +test_bit (__I40E_FD_SB_AUTO_DISABLED, pf->state)) { +/* These set_bit() calls aren't atomic with the +* test_bit() here, but worse case we potentially +* disable ATR and queue a flush right after SB +* support is re-enabled. That shouldn't cause an +* issue in practice +*/ +set_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state);set_bit (__I40E_FD_FLUSH_REQUESTED, pf->state); }
@@ -608,11 +614,10 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring,*/ if (fcnt_prog >= (fcnt_avail -I40E_FDIR_BUFFER_FULL_MARGIN )) {if ((pf->flags &I40E_FLAG_FD_SB_ENABLED ) && - !(pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED )) { - pf->flags |=I40E_FLAG_FD_SB_AUTO_DISABLED ; + !test_and_set_bit (__I40E_FD_SB_AUTO_DISABLED, + pf->state))if (I40E_DEBUG_FD & pf->hw.debug_mask)dev_warn (&pdev->dev,"FD filter space full, new ntuple rules will not be added\n" ); - } } }else if (error ==BIT (I40E_RX_PROG_STATUS_DESC_NO_FD_ENTRY_SHIFT )) {if (I40E_DEBUG_FD & pf->hw.debug_mask)
@@ -2647,7 +2652,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,if (!(pf->flags &I40E_FLAG_FD_ATR_ENABLED ))return ; -if (pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED ) +if (test_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state))return ;/* if sampling is disabled do nothing */
@@ -2687,7 +2692,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb, th = (struct tcphdr *)(hdr.network + hlen);/* Due to lack of space, no more new filters can be programmed */ -if (th->syn && (pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED )) +if (th->syn &&test_bit (__I40E_FD_ATR_AUTO_DISABLED, pf->state))return ;if (pf->flags &I40E_FLAG_HW_ATR_EVICT_ENABLED ) {/* HW ATR eviction will take care of removing filters on FIN
Signature · 1 line
2.9.5
Bowers
PATCH 3/8 i40e: move AUTO_DISABLED flags into the state field
Quoted 24 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 3/8] i40e: moveAUTO_DISABLEDflags into the state fieldFrom: Jacob Keller <[email protected]>
The two Flow Directory auto disable flags are used at run time to mark when the flow director features needed to be disabled. Thus the flags could change even when the RTNL lock is not held.
They also have some code constructions which really should be
test_and_setortest_and_clearusing atomic bit operations.Create new state fields to mark this, and stop including them in
pf->flags.This is part of a larger effort to remove the need for cmpxchg64 in
i40e_set_priv_flags().
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 5 +++-- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 23 +++++++++-------------- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 21 +++++++++++++-------- 4 files changed, 27 insertions(+), 26 deletions(-)
PATCH 4/8 i40e: move I40E_FLAG_TEMP_LINK_POLLING to state field
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
This flag is modified outside of the RTNL lock and thus should not be part of the pf->flags variable.
Use a state bit instead, so that we can use atomic bit operations.
This is part of a larger effort to remove cmpxchg64 in i40e_set_priv_flags()
--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -1
@@ -166,6 +166,7 @@ enum i40e_state_t { __I40E_VF_DISABLE, __I40E_MACVLAN_SYNC_PENDING, __I40E_UDP_FILTER_SYNC_PENDING, + __I40E_TEMP_LINK_POLLING,/* This must be last as it determines the size of the BITMAP */ __I40E_STATE_SIZE__, };
@@ -534,7 +535,7 @@ struct i40e_pf {#define I40E_FLAG_VEB_STATS_ENABLED BIT_ULL(17)#define I40E_FLAG_LINK_POLLING_ENABLED BIT_ULL(18)#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(19) -#define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(20) +/* Gap for BIT_ULL(20) */ #define I40E_FLAG_LEGACY_RX BIT_ULL(21)#define I40E_FLAG_PTP BIT_ULL(22)#define I40E_FLAG_IWARP_ENABLED BIT_ULL(23)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -4
@@ -8432,13 +8432,12 @@ static void i40e_link_event(struct i40e_pf *pf)/* On success, disable temp link polling */ if (status ==I40E_SUCCESS ) { -if (pf->flags &I40E_FLAG_TEMP_LINK_POLLING ) - pf->flags &= ~I40E_FLAG_TEMP_LINK_POLLING ; +clear_bit (__I40E_TEMP_LINK_POLLING, pf->state); }else {/* Enable link polling temporarily until i40e_get_link_status * returns I40E_SUCCESS */ - pf->flags |=I40E_FLAG_TEMP_LINK_POLLING ; +set_bit (__I40E_TEMP_LINK_POLLING, pf->state);dev_dbg (&pf->pdev->dev,"couldn't get link state, status: %d\n" , status);return ;
@@ -8490,7 +8489,7 @@ static void i40e_watchdog_subtask(struct i40e_pf *pf) pf->service_timer_previous = jiffies;if ((pf->flags &I40E_FLAG_LINK_POLLING_ENABLED ) || - (pf->flags &I40E_FLAG_TEMP_LINK_POLLING )) +test_bit (__I40E_TEMP_LINK_POLLING, pf->state))i40e_link_event (pf);/* Update the stats for active netdevs so the network stack
Signature · 1 line
2.9.5
Bowers
PATCH 4/8 i40e: move I40E_FLAG_TEMP_LINK_POLLING to state field
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 4/8] i40e: moveI40E_FLAG_TEMP_LINK_POLLINGto state fieldFrom: Jacob Keller <[email protected]>
This flag is modified outside of the RTNL lock and thus should not be part of the
pf->flagsvariable.Use a state bit instead, so that we can use atomic bit operations.
Quoted 8 lines
This is part of a larger effort to remove cmpxchg64 in
i40e_set_priv_flags()Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-)
PATCH 5/8 i40e: move client flags into state bits
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The iWarp client flags are all potentially changed when the RTNL lock is not held, so they should not be part of the pf->flags variable. Instead, move them into the state field so that we can use atomic bit operations.
This is part of a larger effort to remove cmpxchg64 in i40e_set_priv_flags()
--- drivers/net/ethernet/intel/i40e/i40e.h | 7 ++++--- drivers/net/ethernet/intel/i40e/i40e_client.c | 7 +++---- drivers/net/ethernet/intel/i40e/i40e_main.c | 22 ++++++++++------------ 3 files changed, 17 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +4 -3
@@ -167,6 +167,9 @@ enum i40e_state_t { __I40E_MACVLAN_SYNC_PENDING, __I40E_UDP_FILTER_SYNC_PENDING, __I40E_TEMP_LINK_POLLING, + __I40E_CLIENT_SERVICE_REQUESTED, + __I40E_CLIENT_L2_CHANGE, + __I40E_CLIENT_RESET,/* This must be last as it determines the size of the BITMAP */ __I40E_STATE_SIZE__, };
@@ -539,9 +542,7 @@ struct i40e_pf {#define I40E_FLAG_LEGACY_RX BIT_ULL(21)#define I40E_FLAG_PTP BIT_ULL(22)#define I40E_FLAG_IWARP_ENABLED BIT_ULL(23) -#define I40E_FLAG_SERVICE_CLIENT_REQUESTED BIT_ULL(24) -#define I40E_FLAG_CLIENT_L2_CHANGE BIT_ULL(25) -#define I40E_FLAG_CLIENT_RESET BIT_ULL(26) +/* Gap for BIT_ULL(24) through BIT_ULL(26) */ #define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT_ULL(27)#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT_ULL(28)#define I40E_FLAG_TC_MQPRIO BIT_ULL(29)
drivers/net/ethernet/intel/i40e/i40e_client.c +3 -4
@@ -376,9 +376,8 @@ void i40e_client_subtask(struct i40e_pf *pf)struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];int ret =0 ; -if (!(pf->flags &I40E_FLAG_SERVICE_CLIENT_REQUESTED )) +if (!test_and_clear_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state))return ; - pf->flags &= ~I40E_FLAG_SERVICE_CLIENT_REQUESTED ; cdev = pf->cinst;/* If we're down or resetting, just bail */
@@ -459,7 +458,7 @@ int i40e_lan_add_device(struct i40e_pf *pf)* added, we can schedule a subtask to go initiate the clients if * they can be launched at probe time. */ - pf->flags |=I40E_FLAG_SERVICE_CLIENT_REQUESTED ; +set_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state);i40e_service_event_schedule (pf); out:
@@ -554,7 +553,7 @@ static void i40e_client_prepare(struct i40e_client *client) pf = ldev->pf;i40e_client_add_instance (pf);/* Start the client subtask */ - pf->flags |=I40E_FLAG_SERVICE_CLIENT_REQUESTED ; +set_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state);i40e_service_event_schedule (pf); }mutex_unlock (&i40e_device_mutex);
drivers/net/ethernet/intel/i40e/i40e_main.c +10 -12
@@ -2634,8 +2634,8 @@ static int i40e_change_mtu(struct net_device *netdev, int new_mtu) netdev->mtu = new_mtu;if (netif_running (netdev))i40e_vsi_reinit_locked (vsi); - pf->flags |= (I40E_FLAG_SERVICE_CLIENT_REQUESTED | -I40E_FLAG_CLIENT_L2_CHANGE ); +set_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state); +set_bit (__I40E_CLIENT_L2_CHANGE, pf->state);return 0 ; }
@@ -4722,9 +4722,9 @@ static void i40e_vsi_close(struct i40e_vsi *vsi)i40e_vsi_free_tx_resources (vsi);i40e_vsi_free_rx_resources (vsi); vsi->current_netdev_flags =0 ; - pf->flags |=I40E_FLAG_SERVICE_CLIENT_REQUESTED ; +set_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state);if (test_bit (__I40E_RESET_RECOVERY_PENDING, pf->state)) - pf->flags |=I40E_FLAG_CLIENT_RESET ; +set_bit (__I40E_CLIENT_RESET, pf->state); }/**
@@ -6495,7 +6495,7 @@ static int i40e_up_complete(struct i40e_vsi *vsi)/* On the next run of the service_task, notify any clients of the new * opened netdev */ - pf->flags |=I40E_FLAG_SERVICE_CLIENT_REQUESTED ; +set_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state);i40e_service_event_schedule (pf);return 0 ;
@@ -8037,8 +8037,8 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,i40e_service_event_schedule (pf); }else {i40e_pf_unquiesce_all_vsi (pf); - pf->flags |= (I40E_FLAG_SERVICE_CLIENT_REQUESTED | -I40E_FLAG_CLIENT_L2_CHANGE ); +set_bit (__I40E_CLIENT_SERVICE_REQUESTED, pf->state); +set_bit (__I40E_CLIENT_L2_CHANGE, pf->state); } exit:
@@ -9785,17 +9785,15 @@ static void i40e_service_task(struct work_struct *work)i40e_vc_process_vflr_event (pf);i40e_watchdog_subtask (pf);i40e_fdir_reinit_subtask (pf); -if (pf->flags &I40E_FLAG_CLIENT_RESET ) { +if (test_and_clear_bit (__I40E_CLIENT_RESET, pf->state)) {/* Client subtask will reopen next time through. */ i40e_notify_client_of_netdev_close (pf->vsi[pf->lan_vsi], true); - pf->flags &= ~I40E_FLAG_CLIENT_RESET ; }else {i40e_client_subtask (pf); -if (pf->flags &I40E_FLAG_CLIENT_L2_CHANGE ) { +if (test_and_clear_bit (__I40E_CLIENT_L2_CHANGE, + pf->state))i40e_notify_client_of_l2_param_changes ( pf->vsi[pf->lan_vsi]); - pf->flags &= ~I40E_FLAG_CLIENT_L2_CHANGE ; - } }i40e_sync_filters_subtask (pf);i40e_sync_udp_filters_subtask (pf);
Signature · 1 line
2.9.5
Bowers
PATCH 5/8 i40e: move client flags into state bits
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 5/8] i40e: move client flags into state bitsFrom: Jacob Keller <[email protected]>
The iWarp client flags are all potentially changed when the RTNL lock is not held, so they should not be part of the
pf->flagsvariable. Instead, move them into the state field so that we can use atomic bit operations.This is part of a larger effort to remove cmpxchg64 in
i40e_set_priv_flags()
Quoted 6 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 7 ++++--- drivers/net/ethernet/intel/i40e/i40e_client.c | 7 +++---- drivers/net/ethernet/intel/i40e/i40e_main.c | 22 ++++++++++------------ 3 files changed, 17 insertions(+), 19 deletions(-)
PATCH 6/8 i40e: hold the RTNL lock while changing interrupt schemes
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
When we suspend and resume, we need to clear and re-enable the interrupt scheme. This was previously not done while holding the RTNL lock, which could be problematic, because we are actually destroying and re-creating queues.
Hold the RTNL lock for the entire sequence of preparing for reset, and when resuming. This additionally protects the flags related to interrupt scheme under RTNL lock so that their modification is properly threaded.
This is part of a larger effort to remove the need for cmpxchg64 in i40e_set_priv_flags().
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +17 -2
@@ -14348,7 +14348,13 @@ static int __maybe_unused i40e_suspend(struct device *dev)if (pf->wol_en && (pf->hw_features &I40E_HW_WOL_MC_MAGIC_PKT_WAKE ))i40e_enable_mc_magic_wake (pf); -i40e_prep_for_reset (pf, false); +/* Since we're going to destroy queues during the +* i40e_clear_interrupt_scheme() we should hold the RTNL lock for this +* whole section +*/ +rtnl_lock (); + +i40e_prep_for_reset (pf, true);wr32 (hw,I40E_PFPM_APM , (pf->wol_en ?I40E_PFPM_APM_APME_MASK :0 ));wr32 (hw,I40E_PFPM_WUFC , (pf->wol_en ?I40E_PFPM_WUFC_MAG_MASK :0 ));
@@ -14360,6 +14366,8 @@ static int __maybe_unused i40e_suspend(struct device *dev)*/ i40e_clear_interrupt_scheme (pf); +rtnl_unlock (); +return 0 ; }
@@ -14377,6 +14385,11 @@ static int __maybe_unused i40e_resume(struct device *dev)if (!test_bit (__I40E_SUSPENDED, pf->state))return 0 ; +/* We need to hold the RTNL lock prior to restoring interrupt schemes, +* since we're going to be restoring queues +*/ +rtnl_lock (); +/* We cleared the interrupt scheme when we suspended, so we need to * restore it now to resume device functionality. */
@@ -14387,7 +14400,9 @@ static int __maybe_unused i40e_resume(struct device *dev) }clear_bit (__I40E_DOWN, pf->state); -i40e_reset_and_rebuild (pf, false, false); +i40e_reset_and_rebuild (pf, false, true); + +rtnl_unlock ();/* Clear suspended state last after everything is recovered */ clear_bit (__I40E_SUSPENDED, pf->state);
Signature · 1 line
2.9.5
Bowers
PATCH 6/8 i40e: hold the RTNL lock while changing interrupt schemes
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 6/8] i40e: hold the RTNL lock while changing interrupt schemesFrom: Jacob Keller <[email protected]>
When we suspend and resume, we need to clear and re-enable the interrupt scheme. This was previously not done while holding the RTNL lock, which could be problematic, because we are actually destroying and re-creating queues.
Hold the RTNL lock for the entire sequence of preparing for reset, and when resuming. This additionally protects the flags related to interrupt scheme under RTNL lock so that their modification is properly threaded.
Quoted 7 lines
This is part of a larger effort to remove the need for cmpxchg64 in
i40e_set_priv_flags().Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
PATCH 7/8 i40e: stop using cmpxchg flow in i40e_set_priv_flags()
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Now that the only places which modify flags are either (a) during initialization prior to creating a netdevice, or (b) while holding the rtnl lock, we no longer need the cmpxchg64 call in i40e_set_priv_flags.
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +5 -14
@@ -4436,21 +4436,12 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags) } } -/* Compare and exchange the new flags into place. If we failed, that -* is if cmpxchg returns anything but the old value, this means that -* something else has modified the flags variable since we copied it -* originally. We'll just punt with an error and log something in the -* message buffer. -* -* This is the point of no return for this function. We need to have -* checked any discrepancies or misconfigurations and returned -* EOPNOTSUPP before updating pf->flags here. +/* Now that we've checked to ensure that the new flags are valid, load +* them into place. Since we only modify flags either (a) during +* initialization or (b) while holding the RTNL lock, we don't need +* anything fancy here. */ -if (cmpxchg64 (&pf->flags, orig_flags, new_flags) != orig_flags) { -dev_warn (&pf->pdev->dev, -"Unable to update pf->flags as it was modified by another thread...\n" ); -return -EAGAIN ; - } + pf->flags = new_flags;/* Process any additional changes needed as a result of flag changes. * The changed_flags value reflects the list of bits that were
Signature · 1 line
2.9.5
Bowers
PATCH 7/8 i40e: stop using cmpxchg flow in i40e_set_priv_flags()
Quoted 11 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 7/8] i40e: stop using cmpxchg flow ini40e_set_priv_flags()From: Jacob Keller <[email protected]>
Quoted 8 lines
Now that the only places which modify flags are either (a) during initialization prior to creating a netdevice, or (b) while holding the rtnl lock, we no longer need the cmpxchg64 call in
i40e_set_priv_flags.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
PATCH 8/8 i40e: re-number feature flags to remove gaps
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Remove the gaps created by the recent refactor of various feature flags that have moved to the state field. Use only a u32 now that we have fewer than 32 flags in the field.
--- drivers/net/ethernet/intel/i40e/i40e.h | 57 ++++++++++++++++------------------ 1 file changed, 26 insertions(+), 31 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +26 -31
@@ -518,37 +518,32 @@ struct i40e_pf {#define I40E_HW_RESTART_AUTONEG BIT(18)#define I40E_HW_STOPPABLE_FW_LLDP BIT(19) -u64 flags; -#define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(0) -#define I40E_FLAG_MSI_ENABLED BIT_ULL(1) -#define I40E_FLAG_MSIX_ENABLED BIT_ULL(2) -#define I40E_FLAG_RSS_ENABLED BIT_ULL(3) -#define I40E_FLAG_VMDQ_ENABLED BIT_ULL(4) -/* Gap for BIT_ULL(5) */ -#define I40E_FLAG_SRIOV_ENABLED BIT_ULL(6) -#define I40E_FLAG_DCB_CAPABLE BIT_ULL(7) -#define I40E_FLAG_DCB_ENABLED BIT_ULL(8) -#define I40E_FLAG_FD_SB_ENABLED BIT_ULL(9) -#define I40E_FLAG_FD_ATR_ENABLED BIT_ULL(10) -/* Gap for BIT_ULL(11) and BIT_ULL(12) */ -#define I40E_FLAG_MFP_ENABLED BIT_ULL(13) -/* Gap for BIT_ULL(14) */ -#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(15) -#define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(16) -#define I40E_FLAG_VEB_STATS_ENABLED BIT_ULL(17) -#define I40E_FLAG_LINK_POLLING_ENABLED BIT_ULL(18) -#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(19) -/* Gap for BIT_ULL(20) */ -#define I40E_FLAG_LEGACY_RX BIT_ULL(21) -#define I40E_FLAG_PTP BIT_ULL(22) -#define I40E_FLAG_IWARP_ENABLED BIT_ULL(23) -/* Gap for BIT_ULL(24) through BIT_ULL(26) */ -#define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT_ULL(27) -#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT_ULL(28) -#define I40E_FLAG_TC_MQPRIO BIT_ULL(29) -#define I40E_FLAG_FD_SB_INACTIVE BIT_ULL(30) -#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT_ULL(31) -#define I40E_FLAG_DISABLE_FW_LLDP BIT_ULL(32) +u32 flags; +#define I40E_FLAG_RX_CSUM_ENABLED BIT(0) +#define I40E_FLAG_MSI_ENABLED BIT(1) +#define I40E_FLAG_MSIX_ENABLED BIT(2) +#define I40E_FLAG_RSS_ENABLED BIT(3) +#define I40E_FLAG_VMDQ_ENABLED BIT(4) +#define I40E_FLAG_SRIOV_ENABLED BIT(5) +#define I40E_FLAG_DCB_CAPABLE BIT(6) +#define I40E_FLAG_DCB_ENABLED BIT(7) +#define I40E_FLAG_FD_SB_ENABLED BIT(8) +#define I40E_FLAG_FD_ATR_ENABLED BIT(9) +#define I40E_FLAG_MFP_ENABLED BIT(10) +#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT(11) +#define I40E_FLAG_VEB_MODE_ENABLED BIT(12) +#define I40E_FLAG_VEB_STATS_ENABLED BIT(13) +#define I40E_FLAG_LINK_POLLING_ENABLED BIT(14) +#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT(15) +#define I40E_FLAG_LEGACY_RX BIT(16) +#define I40E_FLAG_PTP BIT(17) +#define I40E_FLAG_IWARP_ENABLED BIT(18) +#define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT(19) +#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT(20) +#define I40E_FLAG_TC_MQPRIO BIT(21) +#define I40E_FLAG_FD_SB_INACTIVE BIT(22) +#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT(23) +#define I40E_FLAG_DISABLE_FW_LLDP BIT(24)struct i40e_client_instance *cinst;bool stat_offsets_loaded;
Signature · 1 line
2.9.5
Bowers
PATCH 8/8 i40e: re-number feature flags to remove gaps
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 8/8] i40e: re-number feature flags to remove gapsFrom: Jacob Keller <[email protected]>
Remove the gaps created by the recent refactor of various feature flags that have moved to the state field. Use only a u32 now that we have fewer than 32 flags in the field.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 57 ++++++++++++++++-------------- ---- 1 file changed, 26 insertions(+), 31 deletions(-)
Bowers
PATCH 1/8 i40e: move I40E_FLAG_FILTER_SYNC to a state bit
In reply to Alice MichaelQuoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, March 16, 2018 1:27 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S89 1/8] i40e: moveI40E_FLAG_FILTER_SYNCto a state bitFrom: Jacob Keller <[email protected]>
The
I40E_FLAG_FILTER_SYNCflag is modified during run time possibly when the RTNL lock is not held. Thus, it should not be part ofpf->flags, and instead should be using atomic bit operations in thepf->statefield.Create a
__I40E_MACVLAN_SYNC_PENDINGstate bit, and use it instead of the oldI40E_FLAG_FILTER_SYNCflag.
Quoted 8 lines
This is part of a larger effort to remove the need for cmpxchg64 in
i40e_set_priv_flags().Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-)