net/e1000: fix igc RSS redirection table
PATCH 1/2 net/e1000: fix igc RSS redirection table
The IGC RETA register stores four 8-bit queue indexes. igc_rss_configure() and igc_add_rss_filter() used a fresh uninitialized union for each table entry and wrote the register only every fourth entry. As a result, three bytes of each RETA register came from stack garbage.
Build the register a word at a time and initialize all four queue indexes before writing it.
--- drivers/net/intel/e1000/igc_txrx.c | 49 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 23 deletions(-)
drivers/net/intel/e1000/igc_txrx.c +26 -23
@@ -828,17 +828,20 @@ igc_rss_configure(struct rte_eth_dev *dev)uint16_t i;/* Fill in redirection table. */ -for (i =0 ; i <IGC_RSS_RDT_SIZD ; i++) { -union igc_rss_reta_reg reta; -uint16_t q_idx, reta_idx; - - q_idx = (uint8_t )((dev->data->nb_rx_queues >1 ) ? - i % dev->data->nb_rx_queues :0 ); - reta_idx = i %sizeof (reta); - reta.bytes[reta_idx] = q_idx; -if (reta_idx ==sizeof (reta) -1 ) -E1000_WRITE_REG_LE_VALUE (hw, -E1000_RETA (i /sizeof (reta)), reta.dword); +for (i =0 ; i <IGC_RSS_RDT_SIZD ; i +=IGC_RSS_RDT_REG_SIZE ) { +union igc_rss_reta_reg reta = { .dword =0 }; +uint16_t reta_idx; + +RTE_BUILD_BUG_ON (sizeof (reta.bytes) !=IGC_RSS_RDT_REG_SIZE ); +for (reta_idx =0 ; reta_idx <IGC_RSS_RDT_REG_SIZE ; reta_idx++) { +uint16_t q_idx; + + q_idx = (uint8_t )((dev->data->nb_rx_queues >1 ) ? + (i + reta_idx) % dev->data->nb_rx_queues :0 ); + reta.bytes[reta_idx] = q_idx; + } +E1000_WRITE_REG_LE_VALUE (hw, +E1000_RETA (i /IGC_RSS_RDT_REG_SIZE ), reta.dword); }/*
@@ -944,18 +947,18 @@ igc_add_rss_filter(struct rte_eth_dev *dev, struct igc_rss_filter *rss)igc_rss_conf_set (rss_filter, &rss->conf);/* Fill in redirection table. */ -for (i =0 , j =0 ; i <IGC_RSS_RDT_SIZD ; i++, j++) { -union igc_rss_reta_reg reta; -uint16_t q_idx, reta_idx; - -if (j == rss->conf.queue_num) - j =0 ; - q_idx = rss->conf.queue[j]; - reta_idx = i %sizeof (reta); - reta.bytes[reta_idx] = q_idx; -if (reta_idx ==sizeof (reta) -1 ) -E1000_WRITE_REG_LE_VALUE (hw, -E1000_RETA (i /sizeof (reta)), reta.dword); +for (i =0 , j =0 ; i <IGC_RSS_RDT_SIZD ; i +=IGC_RSS_RDT_REG_SIZE ) { +union igc_rss_reta_reg reta = { .dword =0 }; +uint16_t reta_idx; + +RTE_BUILD_BUG_ON (sizeof (reta.bytes) !=IGC_RSS_RDT_REG_SIZE ); +for (reta_idx =0 ; reta_idx <IGC_RSS_RDT_REG_SIZE ; reta_idx++, j++) { +if (j == rss->conf.queue_num) + j =0 ; + reta.bytes[reta_idx] = rss->conf.queue[j]; + } +E1000_WRITE_REG_LE_VALUE (hw, +E1000_RETA (i /IGC_RSS_RDT_REG_SIZE ), reta.dword); }if (rss_conf.rss_key ==NULL )
Signature · 1 line
2.43.0
PATCH 2/2 net/e1000: fix igc Tx descriptor ring wrap
igc_xmit_pkts() reserves two extra descriptors for launch time. It indexed sw_ring[tx_last + 2] without wrapping the descriptor index first.
If tx_last is one of the last two descriptors in the ring, this reads past the software ring. Wrap the index before looking up last_id.
--- drivers/net/intel/e1000/igc_txrx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/intel/e1000/igc_txrx.c +5 -1
@@ -1834,7 +1834,11 @@ igc_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)* The "last descriptor" of the previously sent packet, if any, * which used the last descriptor to allocate. */ - tx_end = sw_ring[tx_last +2 ].last_id; + tx_end = (uint16_t )(tx_last +2 ); +if (tx_end >= txq->nb_tx_desc) + tx_end = (uint16_t )(tx_end - txq->nb_tx_desc); + + tx_end = sw_ring[tx_end].last_id;/* * The next descriptor following that "last descriptor" in the
Signature · 1 line
2.43.0
RE: [PATCH 2/2] net/e1000: fix igc Tx descriptor ring wrap
Quoted 11 lines · Shuzo Ichiyoshi
igc_xmit_pkts()reserves two extra descriptors for launch time. It indexed sw_ring[tx_last + 2] without wrapping the descriptor index first.If
tx_lastis one of the last two descriptors in the ring, this reads past the software ring. Wrap the index before looking uplast_id.Fixes 2e79349dcd07 ("net/e1000: fix igc launch time calculation")Signed-off-by Shuzo Ichiyoshi <[email protected]>
Thanks for the fix.
Quoted 25 lines
---
drivers/net/intel/e1000/igc_txrx.c| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)drivers/net/intel/e1000/igc_txrx.c +5
-1@@ -1834,7 +1834,11 @@ igc_xmit_pkts(void *tx_queue, struct rte_mbuf**tx_pkts, uint16_t nb_pkts) * The "last descriptor" of the previously sent packet, if any, * which used the last descriptor to allocate. */ - tx_end = sw_ring[tx_last +2 ].last_id; + tx_end = (uint16_t )(tx_last +2 ); +if (tx_end >= txq->nb_tx_desc) + tx_end = (uint16_t )(tx_end - txq->nb_tx_desc); + + tx_end = sw_ring[tx_end].last_id;/* * The next descriptor following that "last descriptor" in the
--
2.43.0
Bruce Richardson
Acked-byRe: [PATCH 2/2] net/e1000: fix igc Tx descriptor ring wrap
Quoted 9 lines · Yoong Siang
Quoted 8 lines · Shuzo Ichiyoshi
igc_xmit_pkts()reserves two extra descriptors for launch time. It indexed sw_ring[tx_last + 2] without wrapping the descriptor index first.If
tx_lastis one of the last two descriptors in the ring, this reads past the software ring. Wrap the index before looking uplast_id.
Quoted 8 lines
Quoted 3 lines
Fixes 2e79349dcd07 ("net/e1000: fix igc launch time calculation")Signed-off-by Shuzo Ichiyoshi <[email protected]>Reviewed-by Song Yoong Siang <[email protected]>Thanks for the fix.
Quoted 6 lines · Shuzo Ichiyoshi
The IGC RETA register stores four 8-bit queue indexes.
igc_rss_configure()andigc_add_rss_filter()used a fresh uninitialized union for each table entry and wrote the register only every fourth entry. As a result, three bytes of each RETA register came from stack garbage.
Quoted 7 lines
Build the register a word at a time and initialize all four queue indexes before writing it.
Fixes a5aeb2b9e225 ("net/igc: support Rx and Tx")Fixes 746664d546fb ("net/igc: support flow API")Signed-off-by Shuzo Ichiyoshi <[email protected]>
Quoted 10 lines · Bruce Richardson
Quoted 9 lines · Shuzo Ichiyoshi
The IGC RETA register stores four 8-bit queue indexes.
igc_rss_configure()andigc_add_rss_filter()used a fresh uninitialized union for each table entry and wrote the register only every fourth entry. As a result, three bytes of each RETA register came from stack garbage.Build the register a word at a time and initialize all four queue indexes before writing it.
Quoted 7 lines
Quoted 4 lines
Fixes a5aeb2b9e225 ("net/igc: support Rx and Tx")Fixes 746664d546fb ("net/igc: support flow API")Signed-off-by Shuzo Ichiyoshi <[email protected]>Acked-by Bruce Richardson <[email protected]>
Series applied to dpdk-next-net-intel.
Thanks,
/Bruce