Commit 4ae63730 authored by Alexander Duyck's avatar Alexander Duyck Committed by Jeff Kirsher

ixgbe: Update the logic for ixgbe_cache_ring_dcb and DCB RSS configuration

This change cleans up some of the logic in an attempt to try and simplify
things for how we are configuring DCB w/ RSS.

In this patch I basically did 3 things.  I updated the logic for getting
the first register index.  I applied the fact that all TCs get the same
number of queues to simplify the looping logic in caching the DCB ring
register.  Finally I updated how we configure the RQTC register to match
the fact that all TCs are assigned the same number of queues.

Cc: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Tested-by: default avatarRoss Brattain <ross.b.brattain@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent ac802f5d
...@@ -42,42 +42,37 @@ static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc, ...@@ -42,42 +42,37 @@ static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc,
switch (hw->mac.type) { switch (hw->mac.type) {
case ixgbe_mac_82598EB: case ixgbe_mac_82598EB:
*tx = tc << 2; /* TxQs/TC: 4 RxQs/TC: 8 */
*rx = tc << 3; *tx = tc << 2; /* 0, 4, 8, 12, 16, 20, 24, 28 */
*rx = tc << 3; /* 0, 8, 16, 24, 32, 40, 48, 56 */
break; break;
case ixgbe_mac_82599EB: case ixgbe_mac_82599EB:
case ixgbe_mac_X540: case ixgbe_mac_X540:
if (num_tcs > 4) { if (num_tcs > 4) {
if (tc < 3) { /*
*tx = tc << 5; * TCs : TC0/1 TC2/3 TC4-7
*rx = tc << 4; * TxQs/TC: 32 16 8
} else if (tc < 5) { * RxQs/TC: 16 16 16
*tx = ((tc + 2) << 4); */
*rx = tc << 4; *rx = tc << 4;
} else if (tc < num_tcs) { if (tc < 3)
*tx = ((tc + 8) << 3); *tx = tc << 5; /* 0, 32, 64 */
*rx = tc << 4; else if (tc < 5)
} *tx = (tc + 2) << 4; /* 80, 96 */
else
*tx = (tc + 8) << 3; /* 104, 112, 120 */
} else { } else {
*rx = tc << 5; /*
switch (tc) { * TCs : TC0 TC1 TC2/3
case 0: * TxQs/TC: 64 32 16
*tx = 0; * RxQs/TC: 32 32 32
break; */
case 1: *rx = tc << 5;
*tx = 64; if (tc < 2)
break; *tx = tc << 6; /* 0, 64 */
case 2: else
*tx = 96; *tx = (tc + 4) << 4; /* 96, 112 */
break;
case 3:
*tx = 112;
break;
default:
break;
}
} }
break;
default: default:
break; break;
} }
...@@ -90,25 +85,26 @@ static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc, ...@@ -90,25 +85,26 @@ static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc,
* Cache the descriptor ring offsets for DCB to the assigned rings. * Cache the descriptor ring offsets for DCB to the assigned rings.
* *
**/ **/
static inline bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter) static bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter)
{ {
struct net_device *dev = adapter->netdev; struct net_device *dev = adapter->netdev;
int i, j, k; unsigned int tx_idx, rx_idx;
int tc, offset, rss_i, i;
u8 num_tcs = netdev_get_num_tc(dev); u8 num_tcs = netdev_get_num_tc(dev);
if (!num_tcs) /* verify we have DCB queueing enabled before proceeding */
if (num_tcs <= 1)
return false; return false;
for (i = 0, k = 0; i < num_tcs; i++) { rss_i = adapter->ring_feature[RING_F_RSS].indices;
unsigned int tx_s, rx_s;
u16 count = dev->tc_to_txq[i].count;
ixgbe_get_first_reg_idx(adapter, i, &tx_s, &rx_s); for (tc = 0, offset = 0; tc < num_tcs; tc++, offset += rss_i) {
for (j = 0; j < count; j++, k++) { ixgbe_get_first_reg_idx(adapter, tc, &tx_idx, &rx_idx);
adapter->tx_ring[k]->reg_idx = tx_s + j; for (i = 0; i < rss_i; i++, tx_idx++, rx_idx++) {
adapter->rx_ring[k]->reg_idx = rx_s + j; adapter->tx_ring[offset + i]->reg_idx = tx_idx;
adapter->tx_ring[k]->dcb_tc = i; adapter->rx_ring[offset + i]->reg_idx = rx_idx;
adapter->rx_ring[k]->dcb_tc = i; adapter->tx_ring[offset + i]->dcb_tc = tc;
adapter->rx_ring[offset + i]->dcb_tc = tc;
} }
} }
......
...@@ -3608,20 +3608,16 @@ static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter) ...@@ -3608,20 +3608,16 @@ static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter)
/* Enable RSS Hash per TC */ /* Enable RSS Hash per TC */
if (hw->mac.type != ixgbe_mac_82598EB) { if (hw->mac.type != ixgbe_mac_82598EB) {
int i; u32 msb = 0;
u32 reg = 0; u16 rss_i = adapter->ring_feature[RING_F_RSS].indices - 1;
u8 msb = 0;
u8 rss_i = adapter->netdev->tc_to_txq[0].count - 1;
while (rss_i) { while (rss_i) {
msb++; msb++;
rss_i >>= 1; rss_i >>= 1;
} }
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) /* write msb to all 8 TCs in one write */
reg |= msb << IXGBE_RQTC_SHIFT_TC(i); IXGBE_WRITE_REG(hw, IXGBE_RQTC, msb * 0x11111111);
IXGBE_WRITE_REG(hw, IXGBE_RQTC, reg);
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment