Skip to content

Commit 134201a

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
i40e: move AUTO_DISABLED flags into the state field
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(). Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 41898c6 commit 134201a

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ enum i40e_state_t {
159159
__I40E_BAD_EEPROM,
160160
__I40E_DOWN_REQUESTED,
161161
__I40E_FD_FLUSH_REQUESTED,
162+
__I40E_FD_ATR_AUTO_DISABLED,
163+
__I40E_FD_SB_AUTO_DISABLED,
162164
__I40E_RESET_FAILED,
163165
__I40E_PORT_SUSPENDED,
164166
__I40E_VF_DISABLE,
@@ -524,8 +526,7 @@ struct i40e_pf {
524526
#define I40E_FLAG_DCB_ENABLED BIT_ULL(8)
525527
#define I40E_FLAG_FD_SB_ENABLED BIT_ULL(9)
526528
#define I40E_FLAG_FD_ATR_ENABLED BIT_ULL(10)
527-
#define I40E_FLAG_FD_SB_AUTO_DISABLED BIT_ULL(11)
528-
#define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT_ULL(12)
529+
/* Gap for BIT_ULL(11) and BIT_ULL(12) */
529530
#define I40E_FLAG_MFP_ENABLED BIT_ULL(13)
530531
/* Gap for BIT_ULL(14) */
531532
#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(15)

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3951,7 +3951,7 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
39513951
if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
39523952
return -EOPNOTSUPP;
39533953

3954-
if (pf->flags & I40E_FLAG_FD_SB_AUTO_DISABLED)
3954+
if (test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state))
39553955
return -ENOSPC;
39563956

39573957
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)
44604460
/* Flush current ATR settings if ATR was disabled */
44614461
if ((changed_flags & I40E_FLAG_FD_ATR_ENABLED) &&
44624462
!(pf->flags & I40E_FLAG_FD_ATR_ENABLED)) {
4463-
pf->flags |= I40E_FLAG_FD_ATR_AUTO_DISABLED;
4463+
set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
44644464
set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
44654465
}
44664466

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,13 +1083,13 @@ static void i40e_update_pf_stats(struct i40e_pf *pf)
10831083
&osd->rx_lpi_count, &nsd->rx_lpi_count);
10841084

10851085
if (pf->flags & I40E_FLAG_FD_SB_ENABLED &&
1086-
!(pf->flags & I40E_FLAG_FD_SB_AUTO_DISABLED))
1086+
!test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state))
10871087
nsd->fd_sb_status = true;
10881088
else
10891089
nsd->fd_sb_status = false;
10901090

10911091
if (pf->flags & I40E_FLAG_FD_ATR_ENABLED &&
1092-
!(pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED))
1092+
!test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state))
10931093
nsd->fd_atr_status = true;
10941094
else
10951095
nsd->fd_atr_status = false;
@@ -8144,12 +8144,10 @@ u32 i40e_get_global_fd_count(struct i40e_pf *pf)
81448144
**/
81458145
static void i40e_reenable_fdir_sb(struct i40e_pf *pf)
81468146
{
8147-
if (pf->flags & I40E_FLAG_FD_SB_AUTO_DISABLED) {
8148-
pf->flags &= ~I40E_FLAG_FD_SB_AUTO_DISABLED;
8147+
if (test_and_clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state))
81498148
if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
81508149
(I40E_DEBUG_FD & pf->hw.debug_mask))
81518150
dev_info(&pf->pdev->dev, "FD Sideband/ntuple is being enabled since we have space in the table now\n");
8152-
}
81538151
}
81548152

81558153
/**
@@ -8158,7 +8156,7 @@ static void i40e_reenable_fdir_sb(struct i40e_pf *pf)
81588156
**/
81598157
static void i40e_reenable_fdir_atr(struct i40e_pf *pf)
81608158
{
8161-
if (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED) {
8159+
if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) {
81628160
/* ATR uses the same filtering logic as SB rules. It only
81638161
* functions properly if the input set mask is at the default
81648162
* settings. It is safe to restore the default input set
@@ -8168,7 +8166,6 @@ static void i40e_reenable_fdir_atr(struct i40e_pf *pf)
81688166
I40E_L3_SRC_MASK | I40E_L3_DST_MASK |
81698167
I40E_L4_SRC_MASK | I40E_L4_DST_MASK);
81708168

8171-
pf->flags &= ~I40E_FLAG_FD_ATR_AUTO_DISABLED;
81728169
if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) &&
81738170
(I40E_DEBUG_FD & pf->hw.debug_mask))
81748171
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)
82918288
}
82928289

82938290
pf->fd_flush_timestamp = jiffies;
8294-
pf->flags |= I40E_FLAG_FD_ATR_AUTO_DISABLED;
8291+
set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
82958292
/* flush all filters */
82968293
wr32(&pf->hw, I40E_PFQF_CTL_1,
82978294
I40E_PFQF_CTL_1_CLEARFDTABLE_MASK);
@@ -8311,7 +8308,7 @@ static void i40e_fdir_flush_and_replay(struct i40e_pf *pf)
83118308
/* replay sideband filters */
83128309
i40e_fdir_filter_restore(pf->vsi[pf->lan_vsi]);
83138310
if (!disable_atr && !pf->fd_tcp4_filter_cnt)
8314-
pf->flags &= ~I40E_FLAG_FD_ATR_AUTO_DISABLED;
8311+
clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
83158312
clear_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
83168313
if (I40E_DEBUG_FD & pf->hw.debug_mask)
83178314
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)
1129111288
need_reset = true;
1129211289
i40e_fdir_filter_exit(pf);
1129311290
}
11294-
pf->flags &= ~(I40E_FLAG_FD_SB_ENABLED |
11295-
I40E_FLAG_FD_SB_AUTO_DISABLED);
11291+
pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
11292+
clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state);
1129611293
pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
1129711294

1129811295
/* reset fd counters */
1129911296
pf->fd_add_err = 0;
1130011297
pf->fd_atr_cnt = 0;
1130111298
/* if ATR was auto disabled it can be re-enabled. */
11302-
if (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED) {
11303-
pf->flags &= ~I40E_FLAG_FD_ATR_AUTO_DISABLED;
11299+
if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state))
1130411300
if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) &&
1130511301
(I40E_DEBUG_FD & pf->hw.debug_mask))
1130611302
dev_info(&pf->pdev->dev, "ATR re-enabled.\n");
11307-
}
1130811303
}
1130911304
return need_reset;
1131011305
}

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,
336336
if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) &&
337337
I40E_DEBUG_FD & pf->hw.debug_mask)
338338
dev_info(&pf->pdev->dev, "Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n");
339-
pf->flags |= I40E_FLAG_FD_ATR_AUTO_DISABLED;
339+
set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
340340
} else {
341341
pf->fd_tcp4_filter_cnt--;
342342
}
@@ -594,8 +594,14 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring,
594594
pf->fd_atr_cnt = i40e_get_current_atr_cnt(pf);
595595

596596
if ((rx_desc->wb.qword0.hi_dword.fd_id == 0) &&
597-
pf->flags & I40E_FLAG_FD_SB_AUTO_DISABLED) {
598-
pf->flags |= I40E_FLAG_FD_ATR_AUTO_DISABLED;
597+
test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) {
598+
/* These set_bit() calls aren't atomic with the
599+
* test_bit() here, but worse case we potentially
600+
* disable ATR and queue a flush right after SB
601+
* support is re-enabled. That shouldn't cause an
602+
* issue in practice
603+
*/
604+
set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
599605
set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
600606
}
601607

@@ -608,11 +614,10 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring,
608614
*/
609615
if (fcnt_prog >= (fcnt_avail - I40E_FDIR_BUFFER_FULL_MARGIN)) {
610616
if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
611-
!(pf->flags & I40E_FLAG_FD_SB_AUTO_DISABLED)) {
612-
pf->flags |= I40E_FLAG_FD_SB_AUTO_DISABLED;
617+
!test_and_set_bit(__I40E_FD_SB_AUTO_DISABLED,
618+
pf->state))
613619
if (I40E_DEBUG_FD & pf->hw.debug_mask)
614620
dev_warn(&pdev->dev, "FD filter space full, new ntuple rules will not be added\n");
615-
}
616621
}
617622
} else if (error == BIT(I40E_RX_PROG_STATUS_DESC_NO_FD_ENTRY_SHIFT)) {
618623
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,
26472652
if (!(pf->flags & I40E_FLAG_FD_ATR_ENABLED))
26482653
return;
26492654

2650-
if (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED)
2655+
if (test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state))
26512656
return;
26522657

26532658
/* if sampling is disabled do nothing */
@@ -2687,7 +2692,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
26872692
th = (struct tcphdr *)(hdr.network + hlen);
26882693

26892694
/* Due to lack of space, no more new filters can be programmed */
2690-
if (th->syn && (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED))
2695+
if (th->syn && test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state))
26912696
return;
26922697
if (pf->flags & I40E_FLAG_HW_ATR_EVICT_ENABLED) {
26932698
/* HW ATR eviction will take care of removing filters on FIN

0 commit comments

Comments
 (0)