Skip to content

Commit c424d4a

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
i40e/i40evf: Add legacy-rx private flag to allow fallback to old Rx flow
This patch adds a control which will allow us to toggle into and out of the legacy Rx mode. The legacy Rx mode is what we currently do when performing Rx. As I make further changes what should happen is that the driver will fall back to the behavior for Rx as of this patch should the "legacy-rx" flag be set to on. Change-ID: I0342998849bbb31351cce05f6e182c99174e7751 Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent fa2343e commit c424d4a

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ struct i40e_pf {
430430
#define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(55)
431431
#define I40E_FLAG_CLIENT_L2_CHANGE BIT_ULL(56)
432432
#define I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(57)
433+
#define I40E_FLAG_LEGACY_RX BIT_ULL(58)
433434

434435
/* Tracks features that are disabled due to hw limitations.
435436
* If a bit is set here, it means that the corresponding

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ static const struct i40e_priv_flags i40e_gstrings_priv_flags[] = {
226226
I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0),
227227
I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0),
228228
I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_CAPABLE, 0),
229+
I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0),
229230
};
230231

231232
#define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gstrings_priv_flags)
@@ -4055,6 +4056,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
40554056
}
40564057

40574058
flags_complete:
4059+
/* check for flags that changed */
40584060
changed_flags ^= pf->flags;
40594061

40604062
/* Process any additional changes needed as a result of flag changes.
@@ -4095,7 +4097,8 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
40954097
/* Issue reset to cause things to take effect, as additional bits
40964098
* are added we will need to create a mask of bits requiring reset
40974099
*/
4098-
if (changed_flags & I40E_FLAG_VEB_STATS_ENABLED)
4100+
if ((changed_flags & I40E_FLAG_VEB_STATS_ENABLED) ||
4101+
((changed_flags & I40E_FLAG_LEGACY_RX) && netif_running(dev)))
40994102
i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));
41004103

41014104
return 0;

drivers/net/ethernet/intel/i40evf/i40evf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,15 @@ struct i40evf_adapter {
222222
#define I40EVF_FLAG_CLIENT_NEEDS_L2_PARAMS BIT(17)
223223
#define I40EVF_FLAG_PROMISC_ON BIT(18)
224224
#define I40EVF_FLAG_ALLMULTI_ON BIT(19)
225+
#define I40EVF_FLAG_LEGACY_RX BIT(20)
225226
/* duplicates for common code */
226227
#define I40E_FLAG_FDIR_ATR_ENABLED 0
227228
#define I40E_FLAG_DCB_ENABLED 0
228229
#define I40E_FLAG_IN_NETPOLL I40EVF_FLAG_IN_NETPOLL
229230
#define I40E_FLAG_RX_CSUM_ENABLED I40EVF_FLAG_RX_CSUM_ENABLED
230231
#define I40E_FLAG_WB_ON_ITR_CAPABLE I40EVF_FLAG_WB_ON_ITR_CAPABLE
231232
#define I40E_FLAG_OUTER_UDP_CSUM_CAPABLE I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE
233+
#define I40E_FLAG_LEGACY_RX I40EVF_FLAG_LEGACY_RX
232234
/* flags for admin queue service task */
233235
u32 aq_required;
234236
#define I40EVF_FLAG_AQ_ENABLE_QUEUES BIT(0)

drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,29 @@ static const struct i40evf_stats i40evf_gstrings_stats[] = {
6363
#define I40EVF_STATS_LEN(_dev) \
6464
(I40EVF_GLOBAL_STATS_LEN + I40EVF_QUEUE_STATS_LEN(_dev))
6565

66+
/* For now we have one and only one private flag and it is only defined
67+
* when we have support for the SKIP_CPU_SYNC DMA attribute. Instead
68+
* of leaving all this code sitting around empty we will strip it unless
69+
* our one private flag is actually available.
70+
*/
71+
struct i40evf_priv_flags {
72+
char flag_string[ETH_GSTRING_LEN];
73+
u32 flag;
74+
bool read_only;
75+
};
76+
77+
#define I40EVF_PRIV_FLAG(_name, _flag, _read_only) { \
78+
.flag_string = _name, \
79+
.flag = _flag, \
80+
.read_only = _read_only, \
81+
}
82+
83+
static const struct i40evf_priv_flags i40evf_gstrings_priv_flags[] = {
84+
I40EVF_PRIV_FLAG("legacy-rx", I40EVF_FLAG_LEGACY_RX, 0),
85+
};
86+
87+
#define I40EVF_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40evf_gstrings_priv_flags)
88+
6689
/**
6790
* i40evf_get_link_ksettings - Get Link Speed and Duplex settings
6891
* @netdev: network interface device structure
@@ -124,6 +147,8 @@ static int i40evf_get_sset_count(struct net_device *netdev, int sset)
124147
{
125148
if (sset == ETH_SS_STATS)
126149
return I40EVF_STATS_LEN(netdev);
150+
else if (sset == ETH_SS_PRIV_FLAGS)
151+
return I40EVF_PRIV_FLAGS_STR_LEN;
127152
else
128153
return -EINVAL;
129154
}
@@ -189,7 +214,83 @@ static void i40evf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
189214
snprintf(p, ETH_GSTRING_LEN, "rx-%u.bytes", i);
190215
p += ETH_GSTRING_LEN;
191216
}
217+
} else if (sset == ETH_SS_PRIV_FLAGS) {
218+
for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
219+
snprintf(p, ETH_GSTRING_LEN, "%s",
220+
i40evf_gstrings_priv_flags[i].flag_string);
221+
p += ETH_GSTRING_LEN;
222+
}
223+
}
224+
}
225+
226+
/**
227+
* i40evf_get_priv_flags - report device private flags
228+
* @dev: network interface device structure
229+
*
230+
* The get string set count and the string set should be matched for each
231+
* flag returned. Add new strings for each flag to the i40e_gstrings_priv_flags
232+
* array.
233+
*
234+
* Returns a u32 bitmap of flags.
235+
**/
236+
static u32 i40evf_get_priv_flags(struct net_device *netdev)
237+
{
238+
struct i40evf_adapter *adapter = netdev_priv(netdev);
239+
u32 i, ret_flags = 0;
240+
241+
for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
242+
const struct i40evf_priv_flags *priv_flags;
243+
244+
priv_flags = &i40evf_gstrings_priv_flags[i];
245+
246+
if (priv_flags->flag & adapter->flags)
247+
ret_flags |= BIT(i);
248+
}
249+
250+
return ret_flags;
251+
}
252+
253+
/**
254+
* i40evf_set_priv_flags - set private flags
255+
* @dev: network interface device structure
256+
* @flags: bit flags to be set
257+
**/
258+
static int i40evf_set_priv_flags(struct net_device *netdev, u32 flags)
259+
{
260+
struct i40evf_adapter *adapter = netdev_priv(netdev);
261+
u64 changed_flags;
262+
u32 i;
263+
264+
changed_flags = adapter->flags;
265+
266+
for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
267+
const struct i40evf_priv_flags *priv_flags;
268+
269+
priv_flags = &i40evf_gstrings_priv_flags[i];
270+
271+
if (priv_flags->read_only)
272+
continue;
273+
274+
if (flags & BIT(i))
275+
adapter->flags |= priv_flags->flag;
276+
else
277+
adapter->flags &= ~(priv_flags->flag);
278+
}
279+
280+
/* check for flags that changed */
281+
changed_flags ^= adapter->flags;
282+
283+
/* Process any additional changes needed as a result of flag changes. */
284+
285+
/* issue a reset to force legacy-rx change to take effect */
286+
if (changed_flags & I40EVF_FLAG_LEGACY_RX) {
287+
if (netif_running(netdev)) {
288+
adapter->flags |= I40EVF_FLAG_RESET_NEEDED;
289+
schedule_work(&adapter->reset_task);
290+
}
192291
}
292+
293+
return 0;
193294
}
194295

195296
/**
@@ -238,6 +339,7 @@ static void i40evf_get_drvinfo(struct net_device *netdev,
238339
strlcpy(drvinfo->version, i40evf_driver_version, 32);
239340
strlcpy(drvinfo->fw_version, "N/A", 4);
240341
strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
342+
drvinfo->n_priv_flags = I40EVF_PRIV_FLAGS_STR_LEN;
241343
}
242344

243345
/**
@@ -649,6 +751,8 @@ static const struct ethtool_ops i40evf_ethtool_ops = {
649751
.get_strings = i40evf_get_strings,
650752
.get_ethtool_stats = i40evf_get_ethtool_stats,
651753
.get_sset_count = i40evf_get_sset_count,
754+
.get_priv_flags = i40evf_get_priv_flags,
755+
.set_priv_flags = i40evf_set_priv_flags,
652756
.get_msglevel = i40evf_get_msglevel,
653757
.set_msglevel = i40evf_set_msglevel,
654758
.get_coalesce = i40evf_get_coalesce,

0 commit comments

Comments
 (0)