Skip to content

Commit b3c8e0d

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 2022-01-04 This series contains updates to i40e and iavf drivers. Mateusz adjusts displaying of failed VF MAC message when the failure is expected as well as modifying an NVM info message to not confuse the user for i40e. Di Zhu fixes a use-after-free issue MAC filters for i40e. Jedrzej fixes an issue with misreporting of Rx and Tx queues during reinitialization for i40e. Karen correct checking of channel queue configuration to occur against active queues for iavf. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1d5a474 + b712941 commit b3c8e0d

File tree

3 files changed

+87
-18
lines changed

3 files changed

+87
-18
lines changed

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

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ MODULE_LICENSE("GPL v2");
9999

100100
static struct workqueue_struct *i40e_wq;
101101

102+
static void netdev_hw_addr_refcnt(struct i40e_mac_filter *f,
103+
struct net_device *netdev, int delta)
104+
{
105+
struct netdev_hw_addr *ha;
106+
107+
if (!f || !netdev)
108+
return;
109+
110+
netdev_for_each_mc_addr(ha, netdev) {
111+
if (ether_addr_equal(ha->addr, f->macaddr)) {
112+
ha->refcount += delta;
113+
if (ha->refcount <= 0)
114+
ha->refcount = 1;
115+
break;
116+
}
117+
}
118+
}
119+
102120
/**
103121
* i40e_allocate_dma_mem_d - OS specific memory alloc for shared code
104122
* @hw: pointer to the HW structure
@@ -2036,6 +2054,7 @@ static void i40e_undo_add_filter_entries(struct i40e_vsi *vsi,
20362054
hlist_for_each_entry_safe(new, h, from, hlist) {
20372055
/* We can simply free the wrapper structure */
20382056
hlist_del(&new->hlist);
2057+
netdev_hw_addr_refcnt(new->f, vsi->netdev, -1);
20392058
kfree(new);
20402059
}
20412060
}
@@ -2383,6 +2402,10 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
23832402
&tmp_add_list,
23842403
&tmp_del_list,
23852404
vlan_filters);
2405+
2406+
hlist_for_each_entry(new, &tmp_add_list, hlist)
2407+
netdev_hw_addr_refcnt(new->f, vsi->netdev, 1);
2408+
23862409
if (retval)
23872410
goto err_no_memory_locked;
23882411

@@ -2515,6 +2538,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
25152538
if (new->f->state == I40E_FILTER_NEW)
25162539
new->f->state = new->state;
25172540
hlist_del(&new->hlist);
2541+
netdev_hw_addr_refcnt(new->f, vsi->netdev, -1);
25182542
kfree(new);
25192543
}
25202544
spin_unlock_bh(&vsi->mac_filter_hash_lock);
@@ -8716,6 +8740,27 @@ int i40e_open(struct net_device *netdev)
87168740
return 0;
87178741
}
87188742

8743+
/**
8744+
* i40e_netif_set_realnum_tx_rx_queues - Update number of tx/rx queues
8745+
* @vsi: vsi structure
8746+
*
8747+
* This updates netdev's number of tx/rx queues
8748+
*
8749+
* Returns status of setting tx/rx queues
8750+
**/
8751+
static int i40e_netif_set_realnum_tx_rx_queues(struct i40e_vsi *vsi)
8752+
{
8753+
int ret;
8754+
8755+
ret = netif_set_real_num_rx_queues(vsi->netdev,
8756+
vsi->num_queue_pairs);
8757+
if (ret)
8758+
return ret;
8759+
8760+
return netif_set_real_num_tx_queues(vsi->netdev,
8761+
vsi->num_queue_pairs);
8762+
}
8763+
87198764
/**
87208765
* i40e_vsi_open -
87218766
* @vsi: the VSI to open
@@ -8752,13 +8797,7 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
87528797
goto err_setup_rx;
87538798

87548799
/* Notify the stack of the actual queue counts. */
8755-
err = netif_set_real_num_tx_queues(vsi->netdev,
8756-
vsi->num_queue_pairs);
8757-
if (err)
8758-
goto err_set_queues;
8759-
8760-
err = netif_set_real_num_rx_queues(vsi->netdev,
8761-
vsi->num_queue_pairs);
8800+
err = i40e_netif_set_realnum_tx_rx_queues(vsi);
87628801
if (err)
87638802
goto err_set_queues;
87648803

@@ -14149,6 +14188,9 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
1414914188
case I40E_VSI_MAIN:
1415014189
case I40E_VSI_VMDQ2:
1415114190
ret = i40e_config_netdev(vsi);
14191+
if (ret)
14192+
goto err_netdev;
14193+
ret = i40e_netif_set_realnum_tx_rx_queues(vsi);
1415214194
if (ret)
1415314195
goto err_netdev;
1415414196
ret = register_netdev(vsi->netdev);
@@ -15451,8 +15493,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1545115493

1545215494
if (hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
1545315495
hw->aq.api_min_ver > I40E_FW_MINOR_VERSION(hw))
15454-
dev_info(&pdev->dev,
15455-
"The driver for the device detected a newer version of the NVM image v%u.%u than expected v%u.%u. Please install the most recent version of the network driver.\n",
15496+
dev_dbg(&pdev->dev,
15497+
"The driver for the device detected a newer version of the NVM image v%u.%u than v%u.%u.\n",
1545615498
hw->aq.api_maj_ver,
1545715499
hw->aq.api_min_ver,
1545815500
I40E_FW_API_VERSION_MAJOR,

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,17 +1877,19 @@ int i40e_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
18771877
/***********************virtual channel routines******************/
18781878

18791879
/**
1880-
* i40e_vc_send_msg_to_vf
1880+
* i40e_vc_send_msg_to_vf_ex
18811881
* @vf: pointer to the VF info
18821882
* @v_opcode: virtual channel opcode
18831883
* @v_retval: virtual channel return value
18841884
* @msg: pointer to the msg buffer
18851885
* @msglen: msg length
1886+
* @is_quiet: true for not printing unsuccessful return values, false otherwise
18861887
*
18871888
* send msg to VF
18881889
**/
1889-
static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
1890-
u32 v_retval, u8 *msg, u16 msglen)
1890+
static int i40e_vc_send_msg_to_vf_ex(struct i40e_vf *vf, u32 v_opcode,
1891+
u32 v_retval, u8 *msg, u16 msglen,
1892+
bool is_quiet)
18911893
{
18921894
struct i40e_pf *pf;
18931895
struct i40e_hw *hw;
@@ -1903,7 +1905,7 @@ static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
19031905
abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;
19041906

19051907
/* single place to detect unsuccessful return values */
1906-
if (v_retval) {
1908+
if (v_retval && !is_quiet) {
19071909
vf->num_invalid_msgs++;
19081910
dev_info(&pf->pdev->dev, "VF %d failed opcode %d, retval: %d\n",
19091911
vf->vf_id, v_opcode, v_retval);
@@ -1933,6 +1935,23 @@ static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
19331935
return 0;
19341936
}
19351937

1938+
/**
1939+
* i40e_vc_send_msg_to_vf
1940+
* @vf: pointer to the VF info
1941+
* @v_opcode: virtual channel opcode
1942+
* @v_retval: virtual channel return value
1943+
* @msg: pointer to the msg buffer
1944+
* @msglen: msg length
1945+
*
1946+
* send msg to VF
1947+
**/
1948+
static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
1949+
u32 v_retval, u8 *msg, u16 msglen)
1950+
{
1951+
return i40e_vc_send_msg_to_vf_ex(vf, v_opcode, v_retval,
1952+
msg, msglen, false);
1953+
}
1954+
19361955
/**
19371956
* i40e_vc_send_resp_to_vf
19381957
* @vf: pointer to the VF info
@@ -2695,6 +2714,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
26952714
* i40e_check_vf_permission
26962715
* @vf: pointer to the VF info
26972716
* @al: MAC address list from virtchnl
2717+
* @is_quiet: set true for printing msg without opcode info, false otherwise
26982718
*
26992719
* Check that the given list of MAC addresses is allowed. Will return -EPERM
27002720
* if any address in the list is not valid. Checks the following conditions:
@@ -2709,13 +2729,15 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
27092729
* addresses might not be accurate.
27102730
**/
27112731
static inline int i40e_check_vf_permission(struct i40e_vf *vf,
2712-
struct virtchnl_ether_addr_list *al)
2732+
struct virtchnl_ether_addr_list *al,
2733+
bool *is_quiet)
27132734
{
27142735
struct i40e_pf *pf = vf->pf;
27152736
struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx];
27162737
int mac2add_cnt = 0;
27172738
int i;
27182739

2740+
*is_quiet = false;
27192741
for (i = 0; i < al->num_elements; i++) {
27202742
struct i40e_mac_filter *f;
27212743
u8 *addr = al->list[i].addr;
@@ -2739,6 +2761,7 @@ static inline int i40e_check_vf_permission(struct i40e_vf *vf,
27392761
!ether_addr_equal(addr, vf->default_lan_addr.addr)) {
27402762
dev_err(&pf->pdev->dev,
27412763
"VF attempting to override administratively set MAC address, bring down and up the VF interface to resume normal operation\n");
2764+
*is_quiet = true;
27422765
return -EPERM;
27432766
}
27442767

@@ -2775,6 +2798,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27752798
(struct virtchnl_ether_addr_list *)msg;
27762799
struct i40e_pf *pf = vf->pf;
27772800
struct i40e_vsi *vsi = NULL;
2801+
bool is_quiet = false;
27782802
i40e_status ret = 0;
27792803
int i;
27802804

@@ -2791,7 +2815,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27912815
*/
27922816
spin_lock_bh(&vsi->mac_filter_hash_lock);
27932817

2794-
ret = i40e_check_vf_permission(vf, al);
2818+
ret = i40e_check_vf_permission(vf, al, &is_quiet);
27952819
if (ret) {
27962820
spin_unlock_bh(&vsi->mac_filter_hash_lock);
27972821
goto error_param;
@@ -2829,8 +2853,8 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
28292853

28302854
error_param:
28312855
/* send the response to the VF */
2832-
return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_ETH_ADDR,
2833-
ret);
2856+
return i40e_vc_send_msg_to_vf_ex(vf, VIRTCHNL_OP_ADD_ETH_ADDR,
2857+
ret, NULL, 0, is_quiet);
28342858
}
28352859

28362860
/**

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2708,8 +2708,11 @@ static int iavf_validate_ch_config(struct iavf_adapter *adapter,
27082708
total_max_rate += tx_rate;
27092709
num_qps += mqprio_qopt->qopt.count[i];
27102710
}
2711-
if (num_qps > IAVF_MAX_REQ_QUEUES)
2711+
if (num_qps > adapter->num_active_queues) {
2712+
dev_err(&adapter->pdev->dev,
2713+
"Cannot support requested number of queues\n");
27122714
return -EINVAL;
2715+
}
27132716

27142717
ret = iavf_validate_tx_bandwidth(adapter, total_max_rate);
27152718
return ret;

0 commit comments

Comments
 (0)