Skip to content

Commit 49107fc

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 40GbE Intel Wired LAN Driver Updates 2017-08-25 This series contains updates to i40e and i40evf only. Mitch adjusts the max packet size to account for two VLAN tags. Sudheer provides a fix to ensure that the watchdog timer is scheduled immediately after admin queue operations are scheduled in i40evf_down(). Fixes an issue by adding locking around the admin queue command and update of state variables so that adminq_subtask will have the accurate information whenever it gets scheduled. Anjali fixes a bug where the PF flag setup should happen before the VMDq RSS queue count is initialized for VMDq VSI to get the right number of queues for RSS in the case of x722 devices. Fixed a problem with the hardware ATR eviction feature where the NVM setting was incorrect. Jake separates the flags into two types, hw_features and flags. The hw_features flags contain a set of features which are enabled at init time and will not contain feature flags that can be toggled. Everything else will remain in the flags variable, and can be modified anytime during run time. We should not be directly copying a cpumask_t, since it is bitmap and might not be copied correctly, so use cpumask_copy() instead. Stefan Assmann makes vf _offload_flags more "generic" by renaming it to vf_cap_flags, which allows other capabilities besides offloading to be added. Alan makes it such that if adaptive-rx/tx is enabled, the user cannot make any manual adjustments to interrupt moderation. Also makes it so that if ITR is disabled by adaptive-rx/tx is then enabled, ITR will be re-enabled. v2: Dropped patches raspberrypi#1 & raspberrypi#8 from the original patch series submission, while Jesse and Jake re-work their patches based on feedback from David Miller. Also removed the duplicate patch 3 that was accidentally sent out twice in the previous submission. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents fac0cef + 2bf0193 commit 49107fc

14 files changed

Lines changed: 291 additions & 251 deletions

File tree

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@
7575
#define I40E_MIN_VSI_ALLOC 83 /* LAN, ATR, FCOE, 64 VF */
7676
/* max 16 qps */
7777
#define i40e_default_queues_per_vmdq(pf) \
78-
(((pf)->flags & I40E_FLAG_RSS_AQ_CAPABLE) ? 4 : 1)
78+
(((pf)->hw_features & I40E_HW_RSS_AQ_CAPABLE) ? 4 : 1)
7979
#define I40E_DEFAULT_QUEUES_PER_VF 4
8080
#define I40E_DEFAULT_QUEUES_PER_TC 1 /* should be a power of 2 */
8181
#define i40e_pf_get_max_q_per_tc(pf) \
82-
(((pf)->flags & I40E_FLAG_128_QP_RSS_CAPABLE) ? 128 : 64)
82+
(((pf)->hw_features & I40E_HW_128_QP_RSS_CAPABLE) ? 128 : 64)
8383
#define I40E_FDIR_RING 0
8484
#define I40E_FDIR_RING_COUNT 32
8585
#define I40E_MAX_AQ_BUF_SIZE 4096
@@ -401,6 +401,27 @@ struct i40e_pf {
401401
struct timer_list service_timer;
402402
struct work_struct service_task;
403403

404+
u64 hw_features;
405+
#define I40E_HW_RSS_AQ_CAPABLE BIT_ULL(0)
406+
#define I40E_HW_128_QP_RSS_CAPABLE BIT_ULL(1)
407+
#define I40E_HW_ATR_EVICT_CAPABLE BIT_ULL(2)
408+
#define I40E_HW_WB_ON_ITR_CAPABLE BIT_ULL(3)
409+
#define I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE BIT_ULL(4)
410+
#define I40E_HW_NO_PCI_LINK_CHECK BIT_ULL(5)
411+
#define I40E_HW_100M_SGMII_CAPABLE BIT_ULL(6)
412+
#define I40E_HW_NO_DCB_SUPPORT BIT_ULL(7)
413+
#define I40E_HW_USE_SET_LLDP_MIB BIT_ULL(8)
414+
#define I40E_HW_GENEVE_OFFLOAD_CAPABLE BIT_ULL(9)
415+
#define I40E_HW_PTP_L4_CAPABLE BIT_ULL(10)
416+
#define I40E_HW_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(11)
417+
#define I40E_HW_MPLS_HDR_OFFLOAD_CAPABLE BIT_ULL(12)
418+
#define I40E_HW_HAVE_CRT_RETIMER BIT_ULL(13)
419+
#define I40E_HW_OUTER_UDP_CSUM_CAPABLE BIT_ULL(14)
420+
#define I40E_HW_PHY_CONTROLS_LEDS BIT_ULL(15)
421+
#define I40E_HW_STOP_FW_LLDP BIT_ULL(16)
422+
#define I40E_HW_PORT_ID_VALID BIT_ULL(17)
423+
#define I40E_HW_RESTART_AUTONEG BIT_ULL(18)
424+
404425
u64 flags;
405426
#define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(1)
406427
#define I40E_FLAG_MSI_ENABLED BIT_ULL(2)
@@ -420,33 +441,14 @@ struct i40e_pf {
420441
#define I40E_FLAG_PTP BIT_ULL(25)
421442
#define I40E_FLAG_MFP_ENABLED BIT_ULL(26)
422443
#define I40E_FLAG_UDP_FILTER_SYNC BIT_ULL(27)
423-
#define I40E_FLAG_PORT_ID_VALID BIT_ULL(28)
424444
#define I40E_FLAG_DCB_CAPABLE BIT_ULL(29)
425-
#define I40E_FLAG_RSS_AQ_CAPABLE BIT_ULL(31)
426-
#define I40E_FLAG_HW_ATR_EVICT_CAPABLE BIT_ULL(32)
427-
#define I40E_FLAG_OUTER_UDP_CSUM_CAPABLE BIT_ULL(33)
428-
#define I40E_FLAG_128_QP_RSS_CAPABLE BIT_ULL(34)
429-
#define I40E_FLAG_WB_ON_ITR_CAPABLE BIT_ULL(35)
430445
#define I40E_FLAG_VEB_STATS_ENABLED BIT_ULL(37)
431-
#define I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE BIT_ULL(38)
432446
#define I40E_FLAG_LINK_POLLING_ENABLED BIT_ULL(39)
433447
#define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(40)
434-
#define I40E_FLAG_GENEVE_OFFLOAD_CAPABLE BIT_ULL(41)
435-
#define I40E_FLAG_NO_PCI_LINK_CHECK BIT_ULL(42)
436-
#define I40E_FLAG_100M_SGMII_CAPABLE BIT_ULL(43)
437-
#define I40E_FLAG_RESTART_AUTONEG BIT_ULL(44)
438-
#define I40E_FLAG_NO_DCB_SUPPORT BIT_ULL(45)
439-
#define I40E_FLAG_USE_SET_LLDP_MIB BIT_ULL(46)
440-
#define I40E_FLAG_STOP_FW_LLDP BIT_ULL(47)
441-
#define I40E_FLAG_PHY_CONTROLS_LEDS BIT_ULL(48)
442-
#define I40E_FLAG_PF_MAC BIT_ULL(50)
443448
#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(51)
444-
#define I40E_FLAG_HAVE_CRT_RETIMER BIT_ULL(52)
445-
#define I40E_FLAG_PTP_L4_CAPABLE BIT_ULL(53)
446449
#define I40E_FLAG_CLIENT_RESET BIT_ULL(54)
447450
#define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(55)
448451
#define I40E_FLAG_CLIENT_L2_CHANGE BIT_ULL(56)
449-
#define I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(57)
450452
#define I40E_FLAG_LEGACY_RX BIT_ULL(58)
451453

452454
struct i40e_client_instance *cinst;

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

Lines changed: 98 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static void i40e_phy_type_to_ethtool(struct i40e_pf *pf, u32 *supported,
271271
*advertising |= ADVERTISED_Autoneg;
272272
if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
273273
*advertising |= ADVERTISED_1000baseT_Full;
274-
if (pf->flags & I40E_FLAG_100M_SGMII_CAPABLE) {
274+
if (pf->hw_features & I40E_HW_100M_SGMII_CAPABLE) {
275275
*supported |= SUPPORTED_100baseT_Full;
276276
*advertising |= ADVERTISED_100baseT_Full;
277277
}
@@ -340,12 +340,12 @@ static void i40e_phy_type_to_ethtool(struct i40e_pf *pf, u32 *supported,
340340
*advertising |= ADVERTISED_20000baseKR2_Full;
341341
}
342342
if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_KR) {
343-
if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
343+
if (!(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER))
344344
*supported |= SUPPORTED_10000baseKR_Full |
345345
SUPPORTED_Autoneg;
346346
*advertising |= ADVERTISED_Autoneg;
347347
if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
348-
if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
348+
if (!(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER))
349349
*advertising |= ADVERTISED_10000baseKR_Full;
350350
}
351351
if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_KX4) {
@@ -356,12 +356,12 @@ static void i40e_phy_type_to_ethtool(struct i40e_pf *pf, u32 *supported,
356356
*advertising |= ADVERTISED_10000baseKX4_Full;
357357
}
358358
if (phy_types & I40E_CAP_PHY_TYPE_1000BASE_KX) {
359-
if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
359+
if (!(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER))
360360
*supported |= SUPPORTED_1000baseKX_Full |
361361
SUPPORTED_Autoneg;
362362
*advertising |= ADVERTISED_Autoneg;
363363
if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
364-
if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
364+
if (!(pf->hw_features & I40E_HW_HAVE_CRT_RETIMER))
365365
*advertising |= ADVERTISED_1000baseKX_Full;
366366
}
367367
if (phy_types & I40E_CAP_PHY_TYPE_25GBASE_KR ||
@@ -474,7 +474,7 @@ static void i40e_get_settings_link_up(struct i40e_hw *hw,
474474
SUPPORTED_1000baseT_Full;
475475
if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
476476
advertising |= ADVERTISED_1000baseT_Full;
477-
if (pf->flags & I40E_FLAG_100M_SGMII_CAPABLE) {
477+
if (pf->hw_features & I40E_HW_100M_SGMII_CAPABLE) {
478478
supported |= SUPPORTED_100baseT_Full;
479479
if (hw_link_info->requested_speeds &
480480
I40E_LINK_SPEED_100MB)
@@ -1765,7 +1765,7 @@ static int i40e_get_ts_info(struct net_device *dev,
17651765
BIT(HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
17661766
BIT(HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ);
17671767

1768-
if (pf->flags & I40E_FLAG_PTP_L4_CAPABLE)
1768+
if (pf->hw_features & I40E_HW_PTP_L4_CAPABLE)
17691769
info->rx_filters |= BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
17701770
BIT(HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
17711771
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) |
@@ -2005,7 +2005,7 @@ static int i40e_set_phys_id(struct net_device *netdev,
20052005

20062006
switch (state) {
20072007
case ETHTOOL_ID_ACTIVE:
2008-
if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS)) {
2008+
if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) {
20092009
pf->led_status = i40e_led_get(hw);
20102010
} else {
20112011
i40e_aq_set_phy_debug(hw, I40E_PHY_DEBUG_ALL, NULL);
@@ -2015,19 +2015,19 @@ static int i40e_set_phys_id(struct net_device *netdev,
20152015
}
20162016
return blink_freq;
20172017
case ETHTOOL_ID_ON:
2018-
if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS))
2018+
if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS))
20192019
i40e_led_set(hw, 0xf, false);
20202020
else
20212021
ret = i40e_led_set_phy(hw, true, pf->led_status, 0);
20222022
break;
20232023
case ETHTOOL_ID_OFF:
2024-
if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS))
2024+
if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS))
20252025
i40e_led_set(hw, 0x0, false);
20262026
else
20272027
ret = i40e_led_set_phy(hw, false, pf->led_status, 0);
20282028
break;
20292029
case ETHTOOL_ID_INACTIVE:
2030-
if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS)) {
2030+
if (!(pf->hw_features & I40E_HW_PHY_CONTROLS_LEDS)) {
20312031
i40e_led_set(hw, pf->led_status, false);
20322032
} else {
20332033
ret = i40e_led_set_phy(hw, false, pf->led_status,
@@ -2194,14 +2194,29 @@ static int __i40e_set_coalesce(struct net_device *netdev,
21942194
int queue)
21952195
{
21962196
struct i40e_netdev_priv *np = netdev_priv(netdev);
2197+
u16 intrl_reg, cur_rx_itr, cur_tx_itr;
21972198
struct i40e_vsi *vsi = np->vsi;
21982199
struct i40e_pf *pf = vsi->back;
2199-
u16 intrl_reg;
22002200
int i;
22012201

22022202
if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
22032203
vsi->work_limit = ec->tx_max_coalesced_frames_irq;
22042204

2205+
if (queue < 0) {
2206+
cur_rx_itr = vsi->rx_rings[0]->rx_itr_setting;
2207+
cur_tx_itr = vsi->tx_rings[0]->tx_itr_setting;
2208+
} else if (queue < vsi->num_queue_pairs) {
2209+
cur_rx_itr = vsi->rx_rings[queue]->rx_itr_setting;
2210+
cur_tx_itr = vsi->tx_rings[queue]->tx_itr_setting;
2211+
} else {
2212+
netif_info(pf, drv, netdev, "Invalid queue value, queue range is 0 - %d\n",
2213+
vsi->num_queue_pairs - 1);
2214+
return -EINVAL;
2215+
}
2216+
2217+
cur_tx_itr &= ~I40E_ITR_DYNAMIC;
2218+
cur_rx_itr &= ~I40E_ITR_DYNAMIC;
2219+
22052220
/* tx_coalesce_usecs_high is ignored, use rx-usecs-high instead */
22062221
if (ec->tx_coalesce_usecs_high != vsi->int_rate_limit) {
22072222
netif_info(pf, drv, netdev, "tx-usecs-high is not used, please program rx-usecs-high\n");
@@ -2214,43 +2229,49 @@ static int __i40e_set_coalesce(struct net_device *netdev,
22142229
return -EINVAL;
22152230
}
22162231

2217-
if (ec->rx_coalesce_usecs == 0) {
2218-
if (ec->use_adaptive_rx_coalesce)
2219-
netif_info(pf, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
2220-
} else if ((ec->rx_coalesce_usecs < (I40E_MIN_ITR << 1)) ||
2221-
(ec->rx_coalesce_usecs > (I40E_MAX_ITR << 1))) {
2222-
netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
2223-
return -EINVAL;
2232+
if (ec->rx_coalesce_usecs != cur_rx_itr &&
2233+
ec->use_adaptive_rx_coalesce) {
2234+
netif_info(pf, drv, netdev, "RX interrupt moderation cannot be changed if adaptive-rx is enabled.\n");
2235+
return -EINVAL;
2236+
}
2237+
2238+
if (ec->rx_coalesce_usecs > (I40E_MAX_ITR << 1)) {
2239+
netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
2240+
return -EINVAL;
2241+
}
2242+
2243+
if (ec->tx_coalesce_usecs != cur_tx_itr &&
2244+
ec->use_adaptive_tx_coalesce) {
2245+
netif_info(pf, drv, netdev, "TX interrupt moderation cannot be changed if adaptive-tx is enabled.\n");
2246+
return -EINVAL;
2247+
}
2248+
2249+
if (ec->tx_coalesce_usecs > (I40E_MAX_ITR << 1)) {
2250+
netif_info(pf, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");
2251+
return -EINVAL;
22242252
}
22252253

2254+
if (ec->use_adaptive_rx_coalesce && !cur_rx_itr)
2255+
ec->rx_coalesce_usecs = I40E_MIN_ITR << 1;
2256+
2257+
if (ec->use_adaptive_tx_coalesce && !cur_tx_itr)
2258+
ec->tx_coalesce_usecs = I40E_MIN_ITR << 1;
2259+
22262260
intrl_reg = i40e_intrl_usec_to_reg(ec->rx_coalesce_usecs_high);
22272261
vsi->int_rate_limit = INTRL_REG_TO_USEC(intrl_reg);
22282262
if (vsi->int_rate_limit != ec->rx_coalesce_usecs_high) {
22292263
netif_info(pf, drv, netdev, "Interrupt rate limit rounded down to %d\n",
22302264
vsi->int_rate_limit);
22312265
}
22322266

2233-
if (ec->tx_coalesce_usecs == 0) {
2234-
if (ec->use_adaptive_tx_coalesce)
2235-
netif_info(pf, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
2236-
} else if ((ec->tx_coalesce_usecs < (I40E_MIN_ITR << 1)) ||
2237-
(ec->tx_coalesce_usecs > (I40E_MAX_ITR << 1))) {
2238-
netif_info(pf, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");
2239-
return -EINVAL;
2240-
}
2241-
22422267
/* rx and tx usecs has per queue value. If user doesn't specify the queue,
22432268
* apply to all queues.
22442269
*/
22452270
if (queue < 0) {
22462271
for (i = 0; i < vsi->num_queue_pairs; i++)
22472272
i40e_set_itr_per_queue(vsi, ec, i);
2248-
} else if (queue < vsi->num_queue_pairs) {
2249-
i40e_set_itr_per_queue(vsi, ec, queue);
22502273
} else {
2251-
netif_info(pf, drv, netdev, "Invalid queue value, queue range is 0 - %d\n",
2252-
vsi->num_queue_pairs - 1);
2253-
return -EINVAL;
2274+
i40e_set_itr_per_queue(vsi, ec, queue);
22542275
}
22552276

22562277
return 0;
@@ -2727,22 +2748,22 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
27272748
switch (nfc->flow_type) {
27282749
case TCP_V4_FLOW:
27292750
flow_pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP;
2730-
if (pf->flags & I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE)
2751+
if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE)
27312752
hena |=
27322753
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK);
27332754
break;
27342755
case TCP_V6_FLOW:
27352756
flow_pctype = I40E_FILTER_PCTYPE_NONF_IPV6_TCP;
2736-
if (pf->flags & I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE)
2757+
if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE)
27372758
hena |=
27382759
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK);
2739-
if (pf->flags & I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE)
2760+
if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE)
27402761
hena |=
27412762
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK);
27422763
break;
27432764
case UDP_V4_FLOW:
27442765
flow_pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
2745-
if (pf->flags & I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE)
2766+
if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE)
27462767
hena |=
27472768
BIT_ULL(I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) |
27482769
BIT_ULL(I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP);
@@ -2751,7 +2772,7 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
27512772
break;
27522773
case UDP_V6_FLOW:
27532774
flow_pctype = I40E_FILTER_PCTYPE_NONF_IPV6_UDP;
2754-
if (pf->flags & I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE)
2775+
if (pf->hw_features & I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE)
27552776
hena |=
27562777
BIT_ULL(I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) |
27572778
BIT_ULL(I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP);
@@ -4069,23 +4090,26 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
40694090
struct i40e_netdev_priv *np = netdev_priv(dev);
40704091
struct i40e_vsi *vsi = np->vsi;
40714092
struct i40e_pf *pf = vsi->back;
4072-
u64 changed_flags;
4093+
u64 orig_flags, new_flags, changed_flags;
40734094
u32 i, j;
40744095

4075-
changed_flags = pf->flags;
4096+
orig_flags = READ_ONCE(pf->flags);
4097+
new_flags = orig_flags;
40764098

40774099
for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {
40784100
const struct i40e_priv_flags *priv_flags;
40794101

40804102
priv_flags = &i40e_gstrings_priv_flags[i];
40814103

4082-
if (priv_flags->read_only)
4083-
continue;
4084-
40854104
if (flags & BIT(i))
4086-
pf->flags |= priv_flags->flag;
4105+
new_flags |= priv_flags->flag;
40874106
else
4088-
pf->flags &= ~(priv_flags->flag);
4107+
new_flags &= ~(priv_flags->flag);
4108+
4109+
/* If this is a read-only flag, it can't be changed */
4110+
if (priv_flags->read_only &&
4111+
((orig_flags ^ new_flags) & ~BIT(i)))
4112+
return -EOPNOTSUPP;
40894113
}
40904114

40914115
if (pf->hw.pf_id != 0)
@@ -4096,18 +4120,40 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
40964120

40974121
priv_flags = &i40e_gl_gstrings_priv_flags[j];
40984122

4099-
if (priv_flags->read_only)
4100-
continue;
4101-
41024123
if (flags & BIT(i + j))
4103-
pf->flags |= priv_flags->flag;
4124+
new_flags |= priv_flags->flag;
41044125
else
4105-
pf->flags &= ~(priv_flags->flag);
4126+
new_flags &= ~(priv_flags->flag);
4127+
4128+
/* If this is a read-only flag, it can't be changed */
4129+
if (priv_flags->read_only &&
4130+
((orig_flags ^ new_flags) & ~BIT(i)))
4131+
return -EOPNOTSUPP;
41064132
}
41074133

41084134
flags_complete:
4109-
/* check for flags that changed */
4110-
changed_flags ^= pf->flags;
4135+
/* Before we finalize any flag changes, we need to perform some
4136+
* checks to ensure that the changes are supported and safe.
4137+
*/
4138+
4139+
/* ATR eviction is not supported on all devices */
4140+
if ((new_flags & I40E_FLAG_HW_ATR_EVICT_ENABLED) &&
4141+
!(pf->hw_features & I40E_HW_ATR_EVICT_CAPABLE))
4142+
return -EOPNOTSUPP;
4143+
4144+
/* Compare and exchange the new flags into place. If we failed, that
4145+
* is if cmpxchg64 returns anything but the old value, this means that
4146+
* something else has modified the flags variable since we copied it
4147+
* originally. We'll just punt with an error and log something in the
4148+
* message buffer.
4149+
*/
4150+
if (cmpxchg64(&pf->flags, orig_flags, new_flags) != orig_flags) {
4151+
dev_warn(&pf->pdev->dev,
4152+
"Unable to update pf->flags as it was modified by another thread...\n");
4153+
return -EAGAIN;
4154+
}
4155+
4156+
changed_flags = orig_flags ^ new_flags;
41114157

41124158
/* Process any additional changes needed as a result of flag changes.
41134159
* The changed_flags value reflects the list of bits that were
@@ -4121,10 +4167,6 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
41214167
set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
41224168
}
41234169

4124-
/* Only allow ATR evict on hardware that is capable of handling it */
4125-
if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE)
4126-
pf->flags &= ~I40E_FLAG_HW_ATR_EVICT_ENABLED;
4127-
41284170
if (changed_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT) {
41294171
u16 sw_flags = 0, valid_flags = 0;
41304172
int ret;

0 commit comments

Comments
 (0)