Skip to content

Commit

Permalink
net/igc: fix Rx packet size
Browse files Browse the repository at this point in the history
[ upstream commit be1fb9f ]

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: a5aeb2b ("net/igc: support Rx and Tx")

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
  • Loading branch information
Alvin Zhang authored and steevenlee committed May 8, 2021
1 parent 608d69a commit 8d6377e
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions drivers/net/igc/igc_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,20 +1290,24 @@ igc_rx_init(struct rte_eth_dev *dev)
* 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;
Expand Down Expand Up @@ -2266,12 +2270,10 @@ eth_igc_vlan_strip_queue_set(struct rte_eth_dev *dev,

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;
}

Expand Down

0 comments on commit 8d6377e

Please sign in to comment.