Skip to content

Commit 58b0b3e

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
ixgbe: Add code to populate and use macvlan TC to Tx queue map
This patch makes it so that we use the tc_to_txq mapping in the macvlan device in order to select the Tx queue for outgoing packets. The idea here is to try and move away from using ixgbe_select_queue and to come up with a generic way to make this work for devices going forward. By encoding this information in the netdev this can become something that can be used generically as a solution for similar setups going forward. Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent ffcfe25 commit 58b0b3e

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

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

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5275,6 +5275,8 @@ static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring)
52755275
static int ixgbe_fwd_ring_up(struct ixgbe_adapter *adapter,
52765276
struct ixgbe_fwd_adapter *accel)
52775277
{
5278+
u16 rss_i = adapter->ring_feature[RING_F_RSS].indices;
5279+
int num_tc = netdev_get_num_tc(adapter->netdev);
52785280
struct net_device *vdev = accel->netdev;
52795281
int i, baseq, err;
52805282

@@ -5286,6 +5288,11 @@ static int ixgbe_fwd_ring_up(struct ixgbe_adapter *adapter,
52865288
accel->rx_base_queue = baseq;
52875289
accel->tx_base_queue = baseq;
52885290

5291+
/* record configuration for macvlan interface in vdev */
5292+
for (i = 0; i < num_tc; i++)
5293+
netdev_bind_sb_channel_queue(adapter->netdev, vdev,
5294+
i, rss_i, baseq + (rss_i * i));
5295+
52895296
for (i = 0; i < adapter->num_rx_queues_per_pool; i++)
52905297
adapter->rx_ring[baseq + i]->netdev = vdev;
52915298

@@ -5310,6 +5317,10 @@ static int ixgbe_fwd_ring_up(struct ixgbe_adapter *adapter,
53105317

53115318
netdev_err(vdev, "L2FW offload disabled due to L2 filter error\n");
53125319

5320+
/* unbind the queues and drop the subordinate channel config */
5321+
netdev_unbind_sb_channel(adapter->netdev, vdev);
5322+
netdev_set_sb_channel(vdev, 0);
5323+
53135324
clear_bit(accel->pool, adapter->fwd_bitmask);
53145325
kfree(accel);
53155326

@@ -8201,18 +8212,22 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
82018212
void *accel_priv, select_queue_fallback_t fallback)
82028213
{
82038214
struct ixgbe_fwd_adapter *fwd_adapter = accel_priv;
8204-
struct ixgbe_adapter *adapter;
8205-
int txq;
82068215
#ifdef IXGBE_FCOE
8216+
struct ixgbe_adapter *adapter;
82078217
struct ixgbe_ring_feature *f;
82088218
#endif
8219+
int txq;
82098220

82108221
if (fwd_adapter) {
8211-
adapter = netdev_priv(dev);
8212-
txq = reciprocal_scale(skb_get_hash(skb),
8213-
adapter->num_rx_queues_per_pool);
8222+
u8 tc = netdev_get_num_tc(dev) ?
8223+
netdev_get_prio_tc_map(dev, skb->priority) : 0;
8224+
struct net_device *vdev = fwd_adapter->netdev;
8225+
8226+
txq = vdev->tc_to_txq[tc].offset;
8227+
txq += reciprocal_scale(skb_get_hash(skb),
8228+
vdev->tc_to_txq[tc].count);
82148229

8215-
return txq + fwd_adapter->tx_base_queue;
8230+
return txq;
82168231
}
82178232

82188233
#ifdef IXGBE_FCOE
@@ -8766,6 +8781,11 @@ static int ixgbe_reassign_macvlan_pool(struct net_device *vdev, void *data)
87668781
/* if we cannot find a free pool then disable the offload */
87678782
netdev_err(vdev, "L2FW offload disabled due to lack of queue resources\n");
87688783
macvlan_release_l2fw_offload(vdev);
8784+
8785+
/* unbind the queues and drop the subordinate channel config */
8786+
netdev_unbind_sb_channel(adapter->netdev, vdev);
8787+
netdev_set_sb_channel(vdev, 0);
8788+
87698789
kfree(accel);
87708790

87718791
return 0;
@@ -9769,6 +9789,13 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
97699789
if (!macvlan_supports_dest_filter(vdev))
97709790
return ERR_PTR(-EMEDIUMTYPE);
97719791

9792+
/* We need to lock down the macvlan to be a single queue device so that
9793+
* we can reuse the tc_to_txq field in the macvlan netdev to represent
9794+
* the queue mapping to our netdev.
9795+
*/
9796+
if (netif_is_multiqueue(vdev))
9797+
return ERR_PTR(-ERANGE);
9798+
97729799
pool = find_first_zero_bit(adapter->fwd_bitmask, adapter->num_rx_pools);
97739800
if (pool == adapter->num_rx_pools) {
97749801
u16 used_pools = adapter->num_vfs + adapter->num_rx_pools;
@@ -9825,6 +9852,7 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
98259852
return ERR_PTR(-ENOMEM);
98269853

98279854
set_bit(pool, adapter->fwd_bitmask);
9855+
netdev_set_sb_channel(vdev, pool);
98289856
accel->pool = pool;
98299857
accel->netdev = vdev;
98309858

@@ -9866,6 +9894,10 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
98669894
ring->netdev = NULL;
98679895
}
98689896

9897+
/* unbind the queues and drop the subordinate channel config */
9898+
netdev_unbind_sb_channel(pdev, accel->netdev);
9899+
netdev_set_sb_channel(accel->netdev, 0);
9900+
98699901
clear_bit(accel->pool, adapter->fwd_bitmask);
98709902
kfree(accel);
98719903
}

0 commit comments

Comments
 (0)