Skip to content

Commit 848e5d6

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-11-15 This series contains updates to iavf driver only. Mateusz adds a wait for reset completion when changing queue count which could otherwise cause issues with VF reset. Nick adds a null check for vf_res in iavf_fix_features(), corrects ordering of function calls to resolve dependency issues, and prevents possible freeing of a lock which isn't being held. Piotr fixes logic that did not allow setting all multicast mode without promiscuous mode. Jake prevents possible accidental freeing of filter structure. Mitch adds null checks for key and indir parameters in iavf_get_rxfh(). Surabhi adds an additional check that would, previously, cause the driver to print a false error due to values obtained while the VF is in reset. Grzegorz prevents a queue request of 0 which would cause queue count to reset to default values. Akeem restores VLAN filters when bringing the interface back up. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents cf4f553 + 4293014 commit 848e5d6

File tree

3 files changed

+64
-22
lines changed

3 files changed

+64
-22
lines changed

drivers/net/ethernet/intel/iavf/iavf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "iavf_txrx.h"
4040
#include "iavf_fdir.h"
4141
#include "iavf_adv_rss.h"
42+
#include <linux/bitmap.h>
4243

4344
#define DEFAULT_DEBUG_LEVEL_SHIFT 3
4445
#define PFX "iavf: "

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,7 @@ static int iavf_set_channels(struct net_device *netdev,
17761776
{
17771777
struct iavf_adapter *adapter = netdev_priv(netdev);
17781778
u32 num_req = ch->combined_count;
1779+
int i;
17791780

17801781
if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) &&
17811782
adapter->num_tc) {
@@ -1786,7 +1787,7 @@ static int iavf_set_channels(struct net_device *netdev,
17861787
/* All of these should have already been checked by ethtool before this
17871788
* even gets to us, but just to be sure.
17881789
*/
1789-
if (num_req > adapter->vsi_res->num_queue_pairs)
1790+
if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs)
17901791
return -EINVAL;
17911792

17921793
if (num_req == adapter->num_active_queues)
@@ -1798,6 +1799,20 @@ static int iavf_set_channels(struct net_device *netdev,
17981799
adapter->num_req_queues = num_req;
17991800
adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
18001801
iavf_schedule_reset(adapter);
1802+
1803+
/* wait for the reset is done */
1804+
for (i = 0; i < IAVF_RESET_WAIT_COMPLETE_COUNT; i++) {
1805+
msleep(IAVF_RESET_WAIT_MS);
1806+
if (adapter->flags & IAVF_FLAG_RESET_PENDING)
1807+
continue;
1808+
break;
1809+
}
1810+
if (i == IAVF_RESET_WAIT_COMPLETE_COUNT) {
1811+
adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1812+
adapter->num_active_queues = num_req;
1813+
return -EOPNOTSUPP;
1814+
}
1815+
18011816
return 0;
18021817
}
18031818

@@ -1844,14 +1859,13 @@ static int iavf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
18441859

18451860
if (hfunc)
18461861
*hfunc = ETH_RSS_HASH_TOP;
1847-
if (!indir)
1848-
return 0;
1849-
1850-
memcpy(key, adapter->rss_key, adapter->rss_key_size);
1862+
if (key)
1863+
memcpy(key, adapter->rss_key, adapter->rss_key_size);
18511864

1852-
/* Each 32 bits pointed by 'indir' is stored with a lut entry */
1853-
for (i = 0; i < adapter->rss_lut_size; i++)
1854-
indir[i] = (u32)adapter->rss_lut[i];
1865+
if (indir)
1866+
/* Each 32 bits pointed by 'indir' is stored with a lut entry */
1867+
for (i = 0; i < adapter->rss_lut_size; i++)
1868+
indir[i] = (u32)adapter->rss_lut[i];
18551869

18561870
return 0;
18571871
}

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

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,23 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, u16 vlan)
696696
spin_unlock_bh(&adapter->mac_vlan_list_lock);
697697
}
698698

699+
/**
700+
* iavf_restore_filters
701+
* @adapter: board private structure
702+
*
703+
* Restore existing non MAC filters when VF netdev comes back up
704+
**/
705+
static void iavf_restore_filters(struct iavf_adapter *adapter)
706+
{
707+
/* re-add all VLAN filters */
708+
if (VLAN_ALLOWED(adapter)) {
709+
u16 vid;
710+
711+
for_each_set_bit(vid, adapter->vsi.active_vlans, VLAN_N_VID)
712+
iavf_add_vlan(adapter, vid);
713+
}
714+
}
715+
699716
/**
700717
* iavf_vlan_rx_add_vid - Add a VLAN filter to a device
701718
* @netdev: network device struct
@@ -709,8 +726,11 @@ static int iavf_vlan_rx_add_vid(struct net_device *netdev,
709726

710727
if (!VLAN_ALLOWED(adapter))
711728
return -EIO;
729+
712730
if (iavf_add_vlan(adapter, vid) == NULL)
713731
return -ENOMEM;
732+
733+
set_bit(vid, adapter->vsi.active_vlans);
714734
return 0;
715735
}
716736

@@ -725,11 +745,13 @@ static int iavf_vlan_rx_kill_vid(struct net_device *netdev,
725745
{
726746
struct iavf_adapter *adapter = netdev_priv(netdev);
727747

728-
if (VLAN_ALLOWED(adapter)) {
729-
iavf_del_vlan(adapter, vid);
730-
return 0;
731-
}
732-
return -EIO;
748+
if (!VLAN_ALLOWED(adapter))
749+
return -EIO;
750+
751+
iavf_del_vlan(adapter, vid);
752+
clear_bit(vid, adapter->vsi.active_vlans);
753+
754+
return 0;
733755
}
734756

735757
/**
@@ -1639,8 +1661,7 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
16391661
iavf_set_promiscuous(adapter, FLAG_VF_MULTICAST_PROMISC);
16401662
return 0;
16411663
}
1642-
1643-
if ((adapter->aq_required & IAVF_FLAG_AQ_RELEASE_PROMISC) &&
1664+
if ((adapter->aq_required & IAVF_FLAG_AQ_RELEASE_PROMISC) ||
16441665
(adapter->aq_required & IAVF_FLAG_AQ_RELEASE_ALLMULTI)) {
16451666
iavf_set_promiscuous(adapter, 0);
16461667
return 0;
@@ -2123,8 +2144,8 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
21232144

21242145
iavf_free_misc_irq(adapter);
21252146
iavf_reset_interrupt_capability(adapter);
2126-
iavf_free_queues(adapter);
21272147
iavf_free_q_vectors(adapter);
2148+
iavf_free_queues(adapter);
21282149
memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);
21292150
iavf_shutdown_adminq(&adapter->hw);
21302151
adapter->netdev->flags &= ~IFF_UP;
@@ -2410,7 +2431,7 @@ static void iavf_adminq_task(struct work_struct *work)
24102431

24112432
/* check for error indications */
24122433
val = rd32(hw, hw->aq.arq.len);
2413-
if (val == 0xdeadbeef) /* indicates device in reset */
2434+
if (val == 0xdeadbeef || val == 0xffffffff) /* device in reset */
24142435
goto freedom;
24152436
oldval = val;
24162437
if (val & IAVF_VF_ARQLEN1_ARQVFE_MASK) {
@@ -3095,8 +3116,10 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
30953116
return -ENOMEM;
30963117

30973118
while (!mutex_trylock(&adapter->crit_lock)) {
3098-
if (--count == 0)
3099-
goto err;
3119+
if (--count == 0) {
3120+
kfree(filter);
3121+
return err;
3122+
}
31003123
udelay(1);
31013124
}
31023125

@@ -3107,11 +3130,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
31073130
/* start out with flow type and eth type IPv4 to begin with */
31083131
filter->f.flow_type = VIRTCHNL_TCP_V4_FLOW;
31093132
err = iavf_parse_cls_flower(adapter, cls_flower, filter);
3110-
if (err < 0)
3133+
if (err)
31113134
goto err;
31123135

31133136
err = iavf_handle_tclass(adapter, tc, filter);
3114-
if (err < 0)
3137+
if (err)
31153138
goto err;
31163139

31173140
/* add filter to the list */
@@ -3308,6 +3331,9 @@ static int iavf_open(struct net_device *netdev)
33083331

33093332
spin_unlock_bh(&adapter->mac_vlan_list_lock);
33103333

3334+
/* Restore VLAN filters that were removed with IFF_DOWN */
3335+
iavf_restore_filters(adapter);
3336+
33113337
iavf_configure(adapter);
33123338

33133339
iavf_up_complete(adapter);
@@ -3503,7 +3529,8 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev,
35033529
{
35043530
struct iavf_adapter *adapter = netdev_priv(netdev);
35053531

3506-
if (!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN))
3532+
if (adapter->vf_res &&
3533+
!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN))
35073534
features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
35083535
NETIF_F_HW_VLAN_CTAG_RX |
35093536
NETIF_F_HW_VLAN_CTAG_FILTER);

0 commit comments

Comments
 (0)