eth_igc_link_update() unconditionally programs TIPG.IPGT to 0x0b
(15-byte inter-packet gap) whenever the link comes up at 2.5 Gb/s.

This is a workaround for an I225 erratum: when two I225 controllers are
connected back-to-back at 2.5 Gb/s, the receiving MAC can drop packets
that arrive with an inter-packet gap smaller than 8 bytes. Widening the
transmit IPG from the 12-byte default to 15 bytes keeps the link partner
above that threshold. The wider gap costs roughly 0.2% of transmit rate
with small frames.

The erratum is specific to early I225 steppings. Applying the workaround
to every 2.5G-capable device also penalises I226 and later I225
steppings, which do not need it, for no benefit.

Gate the workaround on the I225 device IDs and on revision_id below the
first fixed stepping, and restore the default gap at other speeds.

Fixes: 4f09bc55ac3d ("net/igc: implement device base operations")
Cc: [email protected]

Signed-off-by: Rajesh Kumar <[email protected]>
---
 drivers/net/intel/e1000/igc_ethdev.c | 39 +++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/net/intel/e1000/igc_ethdev.c 
b/drivers/net/intel/e1000/igc_ethdev.c
index 2c8ff57e6b..5fb245f46b 100644
--- a/drivers/net/intel/e1000/igc_ethdev.c
+++ b/drivers/net/intel/e1000/igc_ethdev.c
@@ -50,6 +50,10 @@
 #define IGC_CTRL_SPEED_MASK            (7u << 8)
 #define IGC_CTRL_SPEED_2500            (6u << 8)
 
+/* TIPG.IPGT values for the I225 2.5G inter-packet-gap erratum workaround */
+#define IGC_TIPG_IPGT_DEFAULT          0x08    /* 12-byte IPG (hardware 
default) */
+#define IGC_TIPG_IPGT_2500_WA          0x0b    /* 15-byte IPG */
+
 /* External VLAN Ether Type bit mask and shift */
 #define IGC_VET_EXT                    0xFFFF0000
 #define IGC_VET_EXT_SHIFT              16
@@ -469,6 +473,24 @@ eth_igc_interrupt_get_status(struct rte_eth_dev *dev)
                intr->flags |= IGC_FLAG_NEED_LINK_UPDATE;
 }
 
+/* I226 is a later stepping that does not carry the I225 IPG erratum. */
+static bool
+igc_is_i225(const struct e1000_hw *hw)
+{
+       switch (hw->device_id) {
+       case E1000_DEV_ID_I225_LM:
+       case E1000_DEV_ID_I225_V:
+       case E1000_DEV_ID_I225_I:
+       case E1000_DEV_ID_I225_K:
+       case E1000_DEV_ID_I225_K2:
+       case E1000_DEV_ID_I225_IT:
+       case E1000_DEV_ID_I225_LMVP:
+               return true;
+       default:
+               return false;
+       }
+}
+
 /* return 0 means link status changed, -1 means not changed */
 static int
 eth_igc_link_update(struct rte_eth_dev *dev, int wait_to_complete)
@@ -528,11 +550,22 @@ eth_igc_link_update(struct rte_eth_dev *dev, int 
wait_to_complete)
                link.link_speed = speed;
                link.link_status = RTE_ETH_LINK_UP;
 
-               if (speed == SPEED_2500) {
+               /*
+                * I225 back-to-back 2.5G receive-IPG erratum: widen the TX
+                * inter-packet gap (TIPG.IPGT) from the 0x08 default (12 byte
+                * times) to 0x0b (15 byte times) so a link-partner I225 does
+                * not drop packets; restore the default at other speeds. Only
+                * affected I225 steppings (revision_id < E1000_REVISION_2) need
+                * this; later I225 steppings and I226 are excluded.
+                */
+               if (igc_is_i225(hw) && hw->revision_id < E1000_REVISION_2) {
                        uint32_t tipg = E1000_READ_REG(hw, E1000_TIPG);
-                       if ((tipg & E1000_TIPG_IPGT_MASK) != 0x0b) {
+                       uint32_t ipgt = (speed == SPEED_2500) ?
+                               IGC_TIPG_IPGT_2500_WA : IGC_TIPG_IPGT_DEFAULT;
+
+                       if ((tipg & E1000_TIPG_IPGT_MASK) != ipgt) {
                                tipg &= ~E1000_TIPG_IPGT_MASK;
-                               tipg |= 0x0b;
+                               tipg |= ipgt;
                                E1000_WRITE_REG(hw, E1000_TIPG, tipg);
                        }
                }
-- 
2.43.0

Reply via email to