Skip to content

Commit 4e039c1

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
ixgbe: Fix limitations on macvlan so we can support up to 63 offloaded devices
This change is a fix of the macvlan offload so that we correctly handle macvlan offloaded devices. Specifically we were configuring our limits based on the assumption that we were going to max out the RSS indices for every mode. As a result when we went to 15 or more macvlan interfaces we were forced into the 2 queue RSS mode on VFs even though they could have still supported 4. This change splits the logic up so that we limit either the total number of macvlan instances if DCB is enabled, or limit the number of RSS queues used per macvlan (instead of per pool) if SR-IOV is enabled. By doing this we can make best use of the part. In addition I have increased the maximum number of supported interfaces to 63 with one queue per offloaded interface as this more closely reflects the actual values supported by the interface. Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent ff815fb commit 4e039c1

File tree

4 files changed

+34
-43
lines changed

4 files changed

+34
-43
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ enum ixgbe_ring_f_enum {
397397
#define MAX_XDP_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
398398
#define IXGBE_MAX_L2A_QUEUES 4
399399
#define IXGBE_BAD_L2A_QUEUE 3
400-
#define IXGBE_MAX_MACVLANS 31
401-
#define IXGBE_MAX_DCBMACVLANS 8
400+
#define IXGBE_MAX_MACVLANS 63
402401

403402
struct ixgbe_ring_feature {
404403
u16 limit; /* upper limit on feature indices */
@@ -767,7 +766,8 @@ struct ixgbe_adapter {
767766
#endif /*CONFIG_DEBUG_FS*/
768767

769768
u8 default_up;
770-
unsigned long fwd_bitmask; /* Bitmask indicating in use pools */
769+
/* Bitmask indicating in use pools */
770+
DECLARE_BITMAP(fwd_bitmask, IXGBE_MAX_MACVLANS + 1);
771771

772772
#define IXGBE_MAX_LINK_HANDLE 10
773773
struct ixgbe_jump_table *jump_tables[IXGBE_MAX_LINK_HANDLE];

drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ static bool ixgbe_set_dcb_sriov_queues(struct ixgbe_adapter *adapter)
350350
if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
351351
return false;
352352

353+
/* limit VMDq instances on the PF by number of Tx queues */
354+
vmdq_i = min_t(u16, vmdq_i, MAX_TX_QUEUES / tcs);
355+
353356
/* Add starting offset to total pool count */
354357
vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
355358

@@ -512,20 +515,22 @@ static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
512515
#ifdef IXGBE_FCOE
513516
u16 fcoe_i = 0;
514517
#endif
515-
bool pools = (find_first_zero_bit(&adapter->fwd_bitmask, 32) > 1);
516518

517519
/* only proceed if SR-IOV is enabled */
518520
if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
519521
return false;
520522

523+
/* limit l2fwd RSS based on total Tx queue limit */
524+
rss_i = min_t(u16, rss_i, MAX_TX_QUEUES / vmdq_i);
525+
521526
/* Add starting offset to total pool count */
522527
vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
523528

524529
/* double check we are limited to maximum pools */
525530
vmdq_i = min_t(u16, IXGBE_MAX_VMDQ_INDICES, vmdq_i);
526531

527532
/* 64 pool mode with 2 queues per pool */
528-
if ((vmdq_i > 32) || (vmdq_i > 16 && pools)) {
533+
if (vmdq_i > 32) {
529534
vmdq_m = IXGBE_82599_VMDQ_2Q_MASK;
530535
rss_m = IXGBE_RSS_2Q_MASK;
531536
rss_i = min_t(u16, rss_i, 2);

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5379,14 +5379,13 @@ static int ixgbe_fwd_ring_up(struct net_device *vdev,
53795379
unsigned int rxbase, txbase, queues;
53805380
int i, baseq, err = 0;
53815381

5382-
if (!test_bit(accel->pool, &adapter->fwd_bitmask))
5382+
if (!test_bit(accel->pool, adapter->fwd_bitmask))
53835383
return 0;
53845384

53855385
baseq = accel->pool * adapter->num_rx_queues_per_pool;
5386-
netdev_dbg(vdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n",
5386+
netdev_dbg(vdev, "pool %i:%i queues %i:%i\n",
53875387
accel->pool, adapter->num_rx_pools,
5388-
baseq, baseq + adapter->num_rx_queues_per_pool,
5389-
adapter->fwd_bitmask);
5388+
baseq, baseq + adapter->num_rx_queues_per_pool);
53905389

53915390
accel->netdev = vdev;
53925391
accel->rx_base_queue = rxbase = baseq;
@@ -6284,7 +6283,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,
62846283
}
62856284

62866285
/* PF holds first pool slot */
6287-
set_bit(0, &adapter->fwd_bitmask);
6286+
set_bit(0, adapter->fwd_bitmask);
62886287
set_bit(__IXGBE_DOWN, &adapter->state);
62896288

62906289
return 0;
@@ -8856,7 +8855,6 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
88568855
{
88578856
struct ixgbe_adapter *adapter = netdev_priv(dev);
88588857
struct ixgbe_hw *hw = &adapter->hw;
8859-
bool pools;
88608858

88618859
/* Hardware supports up to 8 traffic classes */
88628860
if (tc > adapter->dcb_cfg.num_tcs.pg_tcs)
@@ -8865,10 +8863,6 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
88658863
if (hw->mac.type == ixgbe_mac_82598EB && tc && tc < MAX_TRAFFIC_CLASS)
88668864
return -EINVAL;
88678865

8868-
pools = (find_first_zero_bit(&adapter->fwd_bitmask, 32) > 1);
8869-
if (tc && pools && adapter->num_rx_pools > IXGBE_MAX_DCBMACVLANS)
8870-
return -EBUSY;
8871-
88728866
/* Hardware has to reinitialize queues and interrupts to
88738867
* match packet buffer alignment. Unfortunately, the
88748868
* hardware is not flexible enough to do this dynamically.
@@ -9807,6 +9801,7 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
98079801
struct ixgbe_fwd_adapter *fwd_adapter = NULL;
98089802
struct ixgbe_adapter *adapter = netdev_priv(pdev);
98099803
int used_pools = adapter->num_vfs + adapter->num_rx_pools;
9804+
int tcs = netdev_get_num_tc(pdev) ? : 1;
98109805
unsigned int limit;
98119806
int pool, err;
98129807

@@ -9834,17 +9829,17 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
98349829
}
98359830

98369831
if (((adapter->flags & IXGBE_FLAG_DCB_ENABLED) &&
9837-
adapter->num_rx_pools > IXGBE_MAX_DCBMACVLANS - 1) ||
9832+
adapter->num_rx_pools >= (MAX_TX_QUEUES / tcs)) ||
98389833
(adapter->num_rx_pools > IXGBE_MAX_MACVLANS))
98399834
return ERR_PTR(-EBUSY);
98409835

98419836
fwd_adapter = kzalloc(sizeof(*fwd_adapter), GFP_KERNEL);
98429837
if (!fwd_adapter)
98439838
return ERR_PTR(-ENOMEM);
98449839

9845-
pool = find_first_zero_bit(&adapter->fwd_bitmask, 32);
9846-
set_bit(pool, &adapter->fwd_bitmask);
9847-
limit = find_last_bit(&adapter->fwd_bitmask, 32);
9840+
pool = find_first_zero_bit(adapter->fwd_bitmask, adapter->num_rx_pools);
9841+
set_bit(pool, adapter->fwd_bitmask);
9842+
limit = find_last_bit(adapter->fwd_bitmask, adapter->num_rx_pools + 1);
98489843

98499844
/* Enable VMDq flag so device will be set in VM mode */
98509845
adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED | IXGBE_FLAG_SRIOV_ENABLED;
@@ -9870,7 +9865,7 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
98709865
/* unwind counter and free adapter struct */
98719866
netdev_info(pdev,
98729867
"%s: dfwd hardware acceleration failed\n", vdev->name);
9873-
clear_bit(pool, &adapter->fwd_bitmask);
9868+
clear_bit(pool, adapter->fwd_bitmask);
98749869
kfree(fwd_adapter);
98759870
return ERR_PTR(err);
98769871
}
@@ -9881,9 +9876,9 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
98819876
struct ixgbe_adapter *adapter = fwd_adapter->real_adapter;
98829877
unsigned int limit;
98839878

9884-
clear_bit(fwd_adapter->pool, &adapter->fwd_bitmask);
9879+
clear_bit(fwd_adapter->pool, adapter->fwd_bitmask);
98859880

9886-
limit = find_last_bit(&adapter->fwd_bitmask, 32);
9881+
limit = find_last_bit(adapter->fwd_bitmask, adapter->num_rx_pools);
98879882
adapter->ring_feature[RING_F_VMDQ].limit = limit + 1;
98889883
ixgbe_fwd_ring_down(fwd_adapter->netdev, fwd_adapter);
98899884

@@ -9898,11 +9893,11 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
98989893
}
98999894

99009895
ixgbe_setup_tc(pdev, netdev_get_num_tc(pdev));
9901-
netdev_dbg(pdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n",
9896+
netdev_dbg(pdev, "pool %i:%i queues %i:%i\n",
99029897
fwd_adapter->pool, adapter->num_rx_pools,
99039898
fwd_adapter->rx_base_queue,
9904-
fwd_adapter->rx_base_queue + adapter->num_rx_queues_per_pool,
9905-
adapter->fwd_bitmask);
9899+
fwd_adapter->rx_base_queue +
9900+
adapter->num_rx_queues_per_pool);
99069901
kfree(fwd_adapter);
99079902
}
99089903

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,9 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)
290290
{
291291
#ifdef CONFIG_PCI_IOV
292292
struct ixgbe_adapter *adapter = pci_get_drvdata(dev);
293-
int err = 0;
294-
u8 num_tc;
295-
int i;
296293
int pre_existing_vfs = pci_num_vf(dev);
294+
int err = 0, num_rx_pools, i, limit;
295+
u8 num_tc;
297296

298297
if (pre_existing_vfs && pre_existing_vfs != num_vfs)
299298
err = ixgbe_disable_sriov(adapter);
@@ -316,22 +315,14 @@ static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)
316315
* other values out of range.
317316
*/
318317
num_tc = netdev_get_num_tc(adapter->netdev);
318+
num_rx_pools = adapter->num_rx_pools;
319+
limit = (num_tc > 4) ? IXGBE_MAX_VFS_8TC :
320+
(num_tc > 1) ? IXGBE_MAX_VFS_4TC : IXGBE_MAX_VFS_1TC;
319321

320-
if (num_tc > 4) {
321-
if ((num_vfs + adapter->num_rx_pools) > IXGBE_MAX_VFS_8TC) {
322-
e_dev_err("Currently the device is configured with %d TCs, Creating more than %d VFs is not allowed\n", num_tc, IXGBE_MAX_VFS_8TC);
323-
return -EPERM;
324-
}
325-
} else if ((num_tc > 1) && (num_tc <= 4)) {
326-
if ((num_vfs + adapter->num_rx_pools) > IXGBE_MAX_VFS_4TC) {
327-
e_dev_err("Currently the device is configured with %d TCs, Creating more than %d VFs is not allowed\n", num_tc, IXGBE_MAX_VFS_4TC);
328-
return -EPERM;
329-
}
330-
} else {
331-
if ((num_vfs + adapter->num_rx_pools) > IXGBE_MAX_VFS_1TC) {
332-
e_dev_err("Currently the device is configured with %d TCs, Creating more than %d VFs is not allowed\n", num_tc, IXGBE_MAX_VFS_1TC);
333-
return -EPERM;
334-
}
322+
if (num_vfs > (limit - num_rx_pools)) {
323+
e_dev_err("Currently configured with %d TCs, and %d offloaded macvlans. Creating more than %d VFs is not allowed\n",
324+
num_tc, num_rx_pools - 1, limit - num_rx_pools);
325+
return -EPERM;
335326
}
336327

337328
err = __ixgbe_enable_sriov(adapter, num_vfs);

0 commit comments

Comments
 (0)