Skip to content

Commit 65af674

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2021-12-06 This series contains updates to iavf and i40e drivers. Mitch adds restoration of MSI state during reset for iavf. Michal fixes checking and reporting of descriptor count changes to communicate changes and/or issues for iavf. Karen resolves an issue with failed handling of VF requests while a VF reset is occurring for i40e. Mateusz removes clearing of VF requested queue count when configuring VF ADQ for i40e. Norbert fixes a NULL pointer dereference that can occur when getting VSI descriptors for i40e. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 9e89268 + 23ec111 commit 65af674

File tree

5 files changed

+91
-38
lines changed

5 files changed

+91
-38
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
553553
dev_info(&pf->pdev->dev, "vsi %d not found\n", vsi_seid);
554554
return;
555555
}
556+
if (vsi->type != I40E_VSI_MAIN &&
557+
vsi->type != I40E_VSI_FDIR &&
558+
vsi->type != I40E_VSI_VMDQ2) {
559+
dev_info(&pf->pdev->dev,
560+
"vsi %d type %d descriptor rings not available\n",
561+
vsi_seid, vsi->type);
562+
return;
563+
}
556564
if (type == RING_TYPE_XDP && !i40e_enabled_xdp_vsi(vsi)) {
557565
dev_info(&pf->pdev->dev, "XDP not enabled on VSI %d\n", vsi_seid);
558566
return;

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

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,32 @@ static int i40e_vc_send_resp_to_vf(struct i40e_vf *vf,
19481948
return i40e_vc_send_msg_to_vf(vf, opcode, retval, NULL, 0);
19491949
}
19501950

1951+
/**
1952+
* i40e_sync_vf_state
1953+
* @vf: pointer to the VF info
1954+
* @state: VF state
1955+
*
1956+
* Called from a VF message to synchronize the service with a potential
1957+
* VF reset state
1958+
**/
1959+
static bool i40e_sync_vf_state(struct i40e_vf *vf, enum i40e_vf_states state)
1960+
{
1961+
int i;
1962+
1963+
/* When handling some messages, it needs VF state to be set.
1964+
* It is possible that this flag is cleared during VF reset,
1965+
* so there is a need to wait until the end of the reset to
1966+
* handle the request message correctly.
1967+
*/
1968+
for (i = 0; i < I40E_VF_STATE_WAIT_COUNT; i++) {
1969+
if (test_bit(state, &vf->vf_states))
1970+
return true;
1971+
usleep_range(10000, 20000);
1972+
}
1973+
1974+
return test_bit(state, &vf->vf_states);
1975+
}
1976+
19511977
/**
19521978
* i40e_vc_get_version_msg
19531979
* @vf: pointer to the VF info
@@ -2008,7 +2034,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
20082034
size_t len = 0;
20092035
int ret;
20102036

2011-
if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
2037+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_INIT)) {
20122038
aq_ret = I40E_ERR_PARAM;
20132039
goto err;
20142040
}
@@ -2131,7 +2157,7 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf, u8 *msg)
21312157
bool allmulti = false;
21322158
bool alluni = false;
21332159

2134-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
2160+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
21352161
aq_ret = I40E_ERR_PARAM;
21362162
goto err_out;
21372163
}
@@ -2219,7 +2245,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
22192245
struct i40e_vsi *vsi;
22202246
u16 num_qps_all = 0;
22212247

2222-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
2248+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
22232249
aq_ret = I40E_ERR_PARAM;
22242250
goto error_param;
22252251
}
@@ -2368,7 +2394,7 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg)
23682394
i40e_status aq_ret = 0;
23692395
int i;
23702396

2371-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
2397+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
23722398
aq_ret = I40E_ERR_PARAM;
23732399
goto error_param;
23742400
}
@@ -2540,7 +2566,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg)
25402566
struct i40e_pf *pf = vf->pf;
25412567
i40e_status aq_ret = 0;
25422568

2543-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
2569+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
25442570
aq_ret = I40E_ERR_PARAM;
25452571
goto error_param;
25462572
}
@@ -2590,7 +2616,7 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg)
25902616
u8 cur_pairs = vf->num_queue_pairs;
25912617
struct i40e_pf *pf = vf->pf;
25922618

2593-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
2619+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE))
25942620
return -EINVAL;
25952621

25962622
if (req_pairs > I40E_MAX_VF_QUEUES) {
@@ -2635,7 +2661,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
26352661

26362662
memset(&stats, 0, sizeof(struct i40e_eth_stats));
26372663

2638-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
2664+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
26392665
aq_ret = I40E_ERR_PARAM;
26402666
goto error_param;
26412667
}
@@ -2752,7 +2778,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27522778
i40e_status ret = 0;
27532779
int i;
27542780

2755-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
2781+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) ||
27562782
!i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) {
27572783
ret = I40E_ERR_PARAM;
27582784
goto error_param;
@@ -2824,7 +2850,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
28242850
i40e_status ret = 0;
28252851
int i;
28262852

2827-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
2853+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) ||
28282854
!i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) {
28292855
ret = I40E_ERR_PARAM;
28302856
goto error_param;
@@ -2968,7 +2994,7 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg)
29682994
i40e_status aq_ret = 0;
29692995
int i;
29702996

2971-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
2997+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) ||
29722998
!i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) {
29732999
aq_ret = I40E_ERR_PARAM;
29743000
goto error_param;
@@ -3088,9 +3114,9 @@ static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg)
30883114
struct i40e_vsi *vsi = NULL;
30893115
i40e_status aq_ret = 0;
30903116

3091-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
3117+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) ||
30923118
!i40e_vc_isvalid_vsi_id(vf, vrk->vsi_id) ||
3093-
(vrk->key_len != I40E_HKEY_ARRAY_SIZE)) {
3119+
vrk->key_len != I40E_HKEY_ARRAY_SIZE) {
30943120
aq_ret = I40E_ERR_PARAM;
30953121
goto err;
30963122
}
@@ -3119,9 +3145,9 @@ static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg)
31193145
i40e_status aq_ret = 0;
31203146
u16 i;
31213147

3122-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
3148+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) ||
31233149
!i40e_vc_isvalid_vsi_id(vf, vrl->vsi_id) ||
3124-
(vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)) {
3150+
vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE) {
31253151
aq_ret = I40E_ERR_PARAM;
31263152
goto err;
31273153
}
@@ -3154,7 +3180,7 @@ static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg)
31543180
i40e_status aq_ret = 0;
31553181
int len = 0;
31563182

3157-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3183+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
31583184
aq_ret = I40E_ERR_PARAM;
31593185
goto err;
31603186
}
@@ -3190,7 +3216,7 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg)
31903216
struct i40e_hw *hw = &pf->hw;
31913217
i40e_status aq_ret = 0;
31923218

3193-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3219+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
31943220
aq_ret = I40E_ERR_PARAM;
31953221
goto err;
31963222
}
@@ -3215,7 +3241,7 @@ static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
32153241
i40e_status aq_ret = 0;
32163242
struct i40e_vsi *vsi;
32173243

3218-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3244+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
32193245
aq_ret = I40E_ERR_PARAM;
32203246
goto err;
32213247
}
@@ -3241,7 +3267,7 @@ static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
32413267
i40e_status aq_ret = 0;
32423268
struct i40e_vsi *vsi;
32433269

3244-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3270+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
32453271
aq_ret = I40E_ERR_PARAM;
32463272
goto err;
32473273
}
@@ -3468,7 +3494,7 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
34683494
i40e_status aq_ret = 0;
34693495
int i, ret;
34703496

3471-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3497+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
34723498
aq_ret = I40E_ERR_PARAM;
34733499
goto err;
34743500
}
@@ -3599,7 +3625,7 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
35993625
i40e_status aq_ret = 0;
36003626
int i, ret;
36013627

3602-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3628+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
36033629
aq_ret = I40E_ERR_PARAM;
36043630
goto err_out;
36053631
}
@@ -3708,7 +3734,7 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
37083734
i40e_status aq_ret = 0;
37093735
u64 speed = 0;
37103736

3711-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3737+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
37123738
aq_ret = I40E_ERR_PARAM;
37133739
goto err;
37143740
}
@@ -3797,11 +3823,6 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
37973823

37983824
/* set this flag only after making sure all inputs are sane */
37993825
vf->adq_enabled = true;
3800-
/* num_req_queues is set when user changes number of queues via ethtool
3801-
* and this causes issue for default VSI(which depends on this variable)
3802-
* when ADq is enabled, hence reset it.
3803-
*/
3804-
vf->num_req_queues = 0;
38053826

38063827
/* reset the VF in order to allocate resources */
38073828
i40e_vc_reset_vf(vf, true);
@@ -3824,7 +3845,7 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg)
38243845
struct i40e_pf *pf = vf->pf;
38253846
i40e_status aq_ret = 0;
38263847

3827-
if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
3848+
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) {
38283849
aq_ret = I40E_ERR_PARAM;
38293850
goto err;
38303851
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#define I40E_MAX_VF_PROMISC_FLAGS 3
2020

21+
#define I40E_VF_STATE_WAIT_COUNT 20
22+
2123
/* Various queue ctrls */
2224
enum i40e_queue_ctrl {
2325
I40E_QUEUE_CTRL_UNKNOWN = 0,

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,23 +615,44 @@ static int iavf_set_ringparam(struct net_device *netdev,
615615
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
616616
return -EINVAL;
617617

618-
new_tx_count = clamp_t(u32, ring->tx_pending,
619-
IAVF_MIN_TXD,
620-
IAVF_MAX_TXD);
621-
new_tx_count = ALIGN(new_tx_count, IAVF_REQ_DESCRIPTOR_MULTIPLE);
618+
if (ring->tx_pending > IAVF_MAX_TXD ||
619+
ring->tx_pending < IAVF_MIN_TXD ||
620+
ring->rx_pending > IAVF_MAX_RXD ||
621+
ring->rx_pending < IAVF_MIN_RXD) {
622+
netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n",
623+
ring->tx_pending, ring->rx_pending, IAVF_MIN_TXD,
624+
IAVF_MAX_RXD, IAVF_REQ_DESCRIPTOR_MULTIPLE);
625+
return -EINVAL;
626+
}
622627

623-
new_rx_count = clamp_t(u32, ring->rx_pending,
624-
IAVF_MIN_RXD,
625-
IAVF_MAX_RXD);
626-
new_rx_count = ALIGN(new_rx_count, IAVF_REQ_DESCRIPTOR_MULTIPLE);
628+
new_tx_count = ALIGN(ring->tx_pending, IAVF_REQ_DESCRIPTOR_MULTIPLE);
629+
if (new_tx_count != ring->tx_pending)
630+
netdev_info(netdev, "Requested Tx descriptor count rounded up to %d\n",
631+
new_tx_count);
632+
633+
new_rx_count = ALIGN(ring->rx_pending, IAVF_REQ_DESCRIPTOR_MULTIPLE);
634+
if (new_rx_count != ring->rx_pending)
635+
netdev_info(netdev, "Requested Rx descriptor count rounded up to %d\n",
636+
new_rx_count);
627637

628638
/* if nothing to do return success */
629639
if ((new_tx_count == adapter->tx_desc_count) &&
630-
(new_rx_count == adapter->rx_desc_count))
640+
(new_rx_count == adapter->rx_desc_count)) {
641+
netdev_dbg(netdev, "Nothing to change, descriptor count is same as requested\n");
631642
return 0;
643+
}
632644

633-
adapter->tx_desc_count = new_tx_count;
634-
adapter->rx_desc_count = new_rx_count;
645+
if (new_tx_count != adapter->tx_desc_count) {
646+
netdev_dbg(netdev, "Changing Tx descriptor count from %d to %d\n",
647+
adapter->tx_desc_count, new_tx_count);
648+
adapter->tx_desc_count = new_tx_count;
649+
}
650+
651+
if (new_rx_count != adapter->rx_desc_count) {
652+
netdev_dbg(netdev, "Changing Rx descriptor count from %d to %d\n",
653+
adapter->rx_desc_count, new_rx_count);
654+
adapter->rx_desc_count = new_rx_count;
655+
}
635656

636657
if (netif_running(netdev)) {
637658
adapter->flags |= IAVF_FLAG_RESET_NEEDED;

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ static void iavf_reset_task(struct work_struct *work)
22482248
}
22492249

22502250
pci_set_master(adapter->pdev);
2251+
pci_restore_msi_state(adapter->pdev);
22512252

22522253
if (i == IAVF_RESET_WAIT_COMPLETE_COUNT) {
22532254
dev_err(&adapter->pdev->dev, "Reset never finished (%x)\n",

0 commit comments

Comments
 (0)