[dpdk-dev] [PATCH v2] net/igc: fix Rx packet size error
Alvin Zhang
alvinx.zhang at intel.com
Tue Apr 20 04:05:20 CEST 2021
When DEV_RX_OFFLOAD_KEEP_CRC is enabled, the PMD will minus 4 bytes
of CRC from the size of a packet, but the NIC will strip the CRC
because the CRC strip bit in DVMOLR register is not cleared. This
will cause the size of a packet to be 4 bytes less.
This patch updates the CRC strip bit according to whether
DEV_RX_OFFLOAD_KEEP_CRC is enabled.
Fixes: a5aeb2b9e225 ("net/igc: support Rx and Tx")
Cc: stable at dpdk.org
Signed-off-by: Alvin Zhang <alvinx.zhang at intel.com>
---
v2: Refine the codes.
---
drivers/net/igc/igc_txrx.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/net/igc/igc_txrx.c b/drivers/net/igc/igc_txrx.c
index 8eaed72..b5489ee 100644
--- a/drivers/net/igc/igc_txrx.c
+++ b/drivers/net/igc/igc_txrx.c
@@ -1291,20 +1291,24 @@ int eth_igc_rx_descriptor_status(void *rx_queue, uint16_t offset)
* This needs to be done after enable.
*/
for (i = 0; i < dev->data->nb_rx_queues; i++) {
+ uint32_t dvmolr;
+
rxq = dev->data->rx_queues[i];
IGC_WRITE_REG(hw, IGC_RDH(rxq->reg_idx), 0);
- IGC_WRITE_REG(hw, IGC_RDT(rxq->reg_idx),
- rxq->nb_rx_desc - 1);
+ IGC_WRITE_REG(hw, IGC_RDT(rxq->reg_idx), rxq->nb_rx_desc - 1);
- /* strip queue vlan offload */
- if (rxq->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) {
- uint32_t dvmolr;
- dvmolr = IGC_READ_REG(hw, IGC_DVMOLR(rxq->queue_id));
+ dvmolr = IGC_READ_REG(hw, IGC_DVMOLR(rxq->reg_idx));
+ if (rxq->offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
+ dvmolr |= IGC_DVMOLR_STRVLAN;
+ else
+ dvmolr &= ~IGC_DVMOLR_STRVLAN;
- /* If vlan been stripped off, the CRC is meaningless. */
- dvmolr |= IGC_DVMOLR_STRVLAN | IGC_DVMOLR_STRCRC;
- IGC_WRITE_REG(hw, IGC_DVMOLR(rxq->reg_idx), dvmolr);
- }
+ if (offloads & DEV_RX_OFFLOAD_KEEP_CRC)
+ dvmolr &= ~IGC_DVMOLR_STRCRC;
+ else
+ dvmolr |= IGC_DVMOLR_STRCRC;
+
+ IGC_WRITE_REG(hw, IGC_DVMOLR(rxq->reg_idx), dvmolr);
}
return 0;
@@ -2267,12 +2271,10 @@ int eth_igc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
reg_val = IGC_READ_REG(hw, IGC_DVMOLR(rx_queue_id));
if (on) {
- /* If vlan been stripped off, the CRC is meaningless. */
- reg_val |= IGC_DVMOLR_STRVLAN | IGC_DVMOLR_STRCRC;
+ reg_val |= IGC_DVMOLR_STRVLAN;
rxq->offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
} else {
- reg_val &= ~(IGC_DVMOLR_STRVLAN | IGC_DVMOLR_HIDVLAN |
- IGC_DVMOLR_STRCRC);
+ reg_val &= ~(IGC_DVMOLR_STRVLAN | IGC_DVMOLR_HIDVLAN);
rxq->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
}
--
1.8.3.1
More information about the dev
mailing list