Skip to contentSkip to conversation

igc: Add initial TSN qdiscs offloading

PATCH Superseded Vinicius Costa Gomes 2 participants 11 messages Feb 7, 2020 – Feb 13, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover igc: Add initial TSN qdiscs offloading

Hi,

Changes from v1:
- Fixed review comments (Andre Guedes);

Original cover letter:

This adds support for offloading taprio (which handles what was formerly known as Qbv) and ETF (using the LaunchTime feature) to i225.

To try and keep things organized, a new file is added: igc_tsn.c. The idea is that the more TSN specific code will live here, in the future this will include frame-preemption support, and CBS (formerly Qav) support.

The current support has a few limitations:
- because the BASET registers can only be written once per reset,

    when removing taprio or ETF, we force the NIC to reset;
  - In part because of the above limitation, we don't support changing
    schedules;

- The way the registers for the schedule are organized, each queue can only be opened and closed once per cycle, so some schedules provided by the user are going to be rejected by the driver;

Future improvements:
- When configuring a Qbv cycle, when we detect that a queue would

    stay open for two intervals, we could want to merge them;
  - More testing with taprio and ETF together, when ETF is installed
    under taprio (when using them separately, it works fine);

--
Cheers,

Vinicius Costa Gomes (2):
igc: Add support for taprio offloading
igc: Add support for ETF offloading

 drivers/net/ethernet/intel/igc/Makefile      |   2 +-
 drivers/net/ethernet/intel/igc/igc.h         |   7 +
 drivers/net/ethernet/intel/igc/igc_defines.h |  14 ++
 drivers/net/ethernet/intel/igc/igc_main.c    | 184 ++++++++++++++++++-
 drivers/net/ethernet/intel/igc/igc_regs.h    |  12 ++
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 156 ++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_tsn.h     |   9 +
 7 files changed, 380 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/igc/igc_tsn.c
 create mode 100644 drivers/net/ethernet/intel/igc/igc_tsn.h
Signature · 1 line
2.25.0
#1 lore raw

PATCH v2 1/2 igc: Add support for taprio offloading

Adds support for translating taprio schedules into i225 cycles. This will allow schedules to run in the hardware, making the schedules enforcement more precise and saving CPU time.

Right now, the only simple schedules are allowed, complex schedules are rejected. "simple" in this context are schedules that each HW queue is opened and closed only once in each cycle.

Changing schedules is still not supported as well.

---
 drivers/net/ethernet/intel/igc/Makefile      |   2 +-
 drivers/net/ethernet/intel/igc/igc.h         |   7 +
 drivers/net/ethernet/intel/igc/igc_defines.h |  13 ++
 drivers/net/ethernet/intel/igc/igc_main.c    | 114 +++++++++++++++
 drivers/net/ethernet/intel/igc/igc_regs.h    |  12 ++
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 139 +++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_tsn.h     |   9 ++
 7 files changed, 295 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/intel/igc/igc_tsn.c
 create mode 100644 drivers/net/ethernet/intel/igc/igc_tsn.h
drivers/net/ethernet/intel/igc/Makefile +1 -1
index e3c164c12e10..3652f211f351 100644
@@ -8,4 +8,4 @@
 obj-$(CONFIG_IGC) += igc.o
 
 igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o igc_phy.o \
-igc_ethtool.o igc_ptp.o igc_dump.o
+igc_ethtool.o igc_ptp.o igc_dump.o igc_tsn.o
drivers/net/ethernet/intel/igc/igc.h +7 -0
index 0014828eec46..4c40dc8f276c 100644
@@ -70,6 +70,7 @@ extern char igc_driver_version[];
 #define IGC_FLAG_HAS_MSIX		BIT(13)
 #define IGC_FLAG_VLAN_PROMISC		BIT(15)
 #define IGC_FLAG_RX_LEGACY		BIT(16)
+#define IGC_FLAG_TSN_QBV_ENABLED	BIT(17)
 
 #define IGC_FLAG_RSS_FIELD_IPV4_UDP	BIT(6)
 #define IGC_FLAG_RSS_FIELD_IPV6_UDP	BIT(7)
@@ -287,6 +288,9 @@ struct igc_ring {
 	u8 reg_idx;                     /* physical index of the ring */
 	bool launchtime_enable;		/* true if LaunchTime is enabled */
 
+	u32 start_time;
+	u32 end_time;
+
 	/* everything past this point are written often */
 	u16 next_to_clean;
 	u16 next_to_use;
@@ -421,6 +425,9 @@ struct igc_adapter {
 	u32 max_frame_size;
 	u32 min_frame_size;
 
+	ktime_t base_time;
+	ktime_t cycle_time;
+
 	/* OS defined structs */
 	struct pci_dev *pdev;
 	/* lock for statistics */
drivers/net/ethernet/intel/igc/igc_defines.h +13 -0
index 044c0f8d4c16..976fa97b082a 100644
@@ -377,6 +377,11 @@
 #define I225_TXPBSIZE_DEFAULT	0x04000014 /* TXPBSIZE default */
 #define IGC_RXPBS_CFG_TS_EN	0x80000000 /* Timestamp in Rx buffer */
 
+#define IGC_TXPBSIZE_TSN	0x04145145 /* 5k bytes buffer for each queue */
+
+#define IGC_DTXMXPKTSZ_TSN	0x19 /* 1600 bytes of max TX DMA packet size */
+#define IGC_DTXMXPKTSZ_DEFAULT	0x98 /* 9728-byte Jumbo frames */
+
 /* Time Sync Interrupt Causes */
 #define IGC_TSICR_SYS_WRAP	BIT(0) /* SYSTIM Wrap around. */
 #define IGC_TSICR_TXTS		BIT(1) /* Transmit Timestamp. */
@@ -431,6 +436,14 @@
 #define IGC_TSYNCTXCTL_START_SYNC		0x80000000  /* initiate sync */
 #define IGC_TSYNCTXCTL_TXSYNSIG			0x00000020  /* Sample TX tstamp in PHY sop */
 
+/* Transmit Scheduling */
+#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN	0x00000001
+#define IGC_TQAVCTRL_ENHANCED_QAV	0x00000008
+
+#define IGC_TXQCTL_STRICT_CYCLE		0x00000002
+#define IGC_TXQCTL_STRICT_END		0x00000004
+#define IGC_TXQCTL_PREEMPTIBLE		0x00000008
+
 /* Receive Checksum Control */
 #define IGC_RXCSUM_CRCOFL	0x00000800   /* CRC32 offload enable */
 #define IGC_RXCSUM_PCSD		0x00002000   /* packet checksum disabled */
drivers/net/ethernet/intel/igc/igc_main.c +114 -0

143 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_regs.h +12 -0
index d4af53a80f11..96dee3c1a5f7 100644
@@ -231,6 +231,18 @@
 
 #define IGC_RXPBS	0x02404  /* Rx Packet Buffer Size - RW */
 
+/* Transmit Scheduling Registers */
+#define IGC_TQAVCTRL                   0x3570
+#define IGC_TXQCTL(_n)                 (0x3344 + 0x4 * (_n))
+#define IGC_BASET_L                    0x3314
+#define IGC_BASET_H                    0x3318
+#define IGC_QBVCYCLET                  0x331C
+#define IGC_QBVCYCLET_S                0x3320
+
+#define IGC_STQT(_n)                   (0x3324 + 0x4 * (_n))
+#define IGC_ENDQT(_n)                  (0x3334 + 0x4 * (_n))
+#define IGC_DTXMXPKTSZ                 0x355C
+
 /* System Time Registers */
 #define IGC_SYSTIML	0x0B600  /* System time register Low - RO */
 #define IGC_SYSTIMH	0x0B604  /* System time register High - RO */
drivers/net/ethernet/intel/igc/igc_tsn.c new file +139 -0

139 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_tsn.h new file +9 -0
new file mode 100644
index 000000000000..8c34be0d9aae
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c)  2018 Intel Corporation */
+
+#ifndef _IGC_TSN_H_
+#define _IGC_TSN_H_
+
+int igc_tsn_offload_apply(struct igc_adapter *adapter);
+
+#endif /* _IGC_BASE_H */
Signature · 1 line
2.25.0
#2 lore raw

PATCH v2 1/2 igc: Add support for taprio offloading

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-07 10:24:42)
...

Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_defines.h +0 -0

...

drivers/net/ethernet/intel/igc/igc_defines.h line 445

Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_defines.h +7 -0
+/* Transmit Scheduling */
+#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001
+#define IGC_TQAVCTRL_ENHANCED_QAV      0x00000008
+
+#define IGC_TXQCTL_STRICT_CYCLE                0x00000002
+#define IGC_TXQCTL_STRICT_END          0x00000004
+#define IGC_TXQCTL_PREEMPTIBLE         0x00000008

It seems you missed removing IGC_TXQCTL_PREEMPTIBLE here. This macro is not used anywhere in the code.

drivers/net/ethernet/intel/igc/igc_tsn.h line 2

Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_tsn.h new file +2 -0
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c)  2018 Intel Corporation */

s/2018/2020 ?

Regards,

Andre

#3 lore raw

PATCH v2 1/2 igc: Add support for taprio offloading

Quoted 7 lines · Andre Guedes

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-07 10:24:42)
...

Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_defines.h +0 -0

...

Quoted 10 lines

drivers/net/ethernet/intel/igc/igc_defines.h line 445

Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_defines.h +7 -0
+/* Transmit Scheduling */
+#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001
+#define IGC_TQAVCTRL_ENHANCED_QAV      0x00000008
+
+#define IGC_TXQCTL_STRICT_CYCLE                0x00000002
+#define IGC_TXQCTL_STRICT_END          0x00000004
+#define IGC_TXQCTL_PREEMPTIBLE         0x00000008

It seems you missed removing IGC_TXQCTL_PREEMPTIBLE here. This macro is not used anywhere in the code.

Will fix.

Quoted 8 lines

drivers/net/ethernet/intel/igc/igc_tsn.h line 2

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_tsn.h new file +2 -0
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c)  2018 Intel Corporation */

s/2018/2020 ?

Ugh, will fix.

Quoted 4 lines

Regards,

Andre

Signature · 1 line
Vinicius
#4 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

In reply to Vinicius Costa Gomes

This adds support for ETF offloading for the i225 controller.

For i225, the LaunchTime feature is almost a subset of the Qbv feature. The main change from the i210 is that the launchtime of each packet is specified as an offset applied to the BASET register. BASET is automatically incremented each cycle.

For i225, the approach chosen is to re-use most of the setup used for taprio offloading. With a few changes:

- The more or less obvious one is that when ETF is enabled, we should set add the expected launchtime to the (advanced) transmit descriptor;

- The less obvious, is that when taprio offloading is not enabled, we add a dummy schedule (all queues are open all the time, with a cycle time of 1 second).

---
 drivers/net/ethernet/intel/igc/igc_defines.h |  1 +
 drivers/net/ethernet/intel/igc/igc_main.c    | 70 +++++++++++++++++++-
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 19 +++++-
 3 files changed, 86 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igc/igc_defines.h +1 -0
index 976fa97b082a..6c8850b43951 100644
@@ -440,6 +440,7 @@
 #define IGC_TQAVCTRL_TRANSMIT_MODE_TSN	0x00000001
 #define IGC_TQAVCTRL_ENHANCED_QAV	0x00000008
 
+#define IGC_TXQCTL_QUEUE_MODE_LAUNCHT	0x00000001
 #define IGC_TXQCTL_STRICT_CYCLE		0x00000002
 #define IGC_TXQCTL_STRICT_END		0x00000004
 #define IGC_TXQCTL_PREEMPTIBLE		0x00000008
drivers/net/ethernet/intel/igc/igc_main.c +67 -3

107 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_tsn.c +18 -1
index ebd61b89d90e..05beb6b8ca00 100644
@@ -3,6 +3,20 @@
 
 #include "igc.h"
 
+static bool is_any_launchtime(struct igc_adapter *adapter)
+{
+	int i;
+
+	for (i = 0; i < adapter->num_tx_queues; i++) {
+		struct igc_ring *ring = adapter->tx_ring[i];
+
+		if (ring->launchtime_enable)
+			return true;
+	}
+
+	return false;
+}
+
 /* Returns the TSN specific registers to their default values after
  * TSN offloading is disabled.
  */
@@ -87,6 +101,9 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 				IGC_TXQCTL_STRICT_END;
 		}
 
+		if (ring->launchtime_enable)
+			txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT;
+
 		wr32(IGC_TXQCTL(i), txqctl);
 	}
 
@@ -114,7 +131,7 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 
 int igc_tsn_offload_apply(struct igc_adapter *adapter)
 {
-	bool is_any_enabled = adapter->base_time;
+	bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter);
 
 	if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled)
 		return 0;
Signature · 1 line
2.25.0
#5 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-07 10:24:43)
...

Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_main.c +0 -0

...

drivers/net/ethernet/intel/igc/igc_main.c static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) · line 4526

Quoted 12 lines
drivers/net/ethernet/intel/igc/igc_main.c +8 -0
@@ -4497,6 +4516,32 @@ static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
        }
 }
 
+static int igc_save_launchtime_params(struct igc_adapter *adapter, int queue,
+                                     bool enable)
+{
+       struct igc_ring *ring;
+       int i;
+
+       if (queue < 0 || queue > adapter->num_tx_queues)
+               return -EINVAL;

I believe we have an off-by-one bug here. Shouldn't it be queue >= adapter->num_tx_queues instead?

drivers/net/ethernet/intel/igc/igc_main.c static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, · line 4665

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
@@ -4600,6 +4661,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
        case TC_SETUP_QDISC_TAPRIO:
                return igc_tsn_enable_qbv_scheduling(adapter, type_data);
 
+       case TC_SETUP_QDISC_ETF:
+               return igc_tsn_enable_launchtime(adapter, type_data);

Consider the scenario where both TAPRIO and ETF offloads are disabled and we want to enable ETF offload. ETF depends on adapter->base_time is set to work properly, but I couldn't find where in this patch it is set. Could you please clarify that?

Regards,

Andre

#6 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

Quoted 11 lines · Andre Guedes

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-07 10:24:43)
...

Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_main.c +0 -0

...

Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_main.c +0 -0
@@ -4497,6 +4516,32 @@ static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
        }
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) · line 4526

Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_main.c +8 -0
+static int igc_save_launchtime_params(struct igc_adapter *adapter, int queue,
+                                     bool enable)
+{
+       struct igc_ring *ring;
+       int i;
+
+       if (queue < 0 || queue > adapter->num_tx_queues)
+               return -EINVAL;

I believe we have an off-by-one bug here. Shouldn't it be queue >= adapter->num_tx_queues instead?

I will test this. Thanks for noticing.

Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_main.c +0 -0
@@ -4600,6 +4661,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
        case TC_SETUP_QDISC_TAPRIO:
                return igc_tsn_enable_qbv_scheduling(adapter, type_data);
 
Quoted 7 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, · line 4665

Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
+       case TC_SETUP_QDISC_ETF:
+               return igc_tsn_enable_launchtime(adapter, type_data);

Consider the scenario where both TAPRIO and ETF offloads are disabled and we want to enable ETF offload. ETF depends on adapter->base_time is set to work properly, but I couldn't find where in this patch it is set. Could you please clarify that?

'->base_time' doesn't need to be set, i.e. if it's zero (which is the case that only ETF offloading is enabled), it should be fine. H

ow we calculate the launchtime in igc_tx_launchtime() is able to handle 'base_time_ being zero just fine, and the BASET_{L,H} registers will have sane values when it's zero as well.

Cheers,
--
Vinicius

#7 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-10 17:13:13)

Quoted 12 lines
Quoted 11 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, · line 4665

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
@@ -4600,6 +4661,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
        case TC_SETUP_QDISC_TAPRIO:
                return igc_tsn_enable_qbv_scheduling(adapter, type_data);
 
+       case TC_SETUP_QDISC_ETF:
+               return igc_tsn_enable_launchtime(adapter, type_data);

Consider the scenario where both TAPRIO and ETF offloads are disabled and we want to enable ETF offload. ETF depends on adapter->base_time is set to work properly, but I couldn't find where in this patch it is set. Could you please clarify that?

Quoted 6 lines

'->base_time' doesn't need to be set, i.e. if it's zero (which is the case that only ETF offloading is enabled), it should be fine. H

ow we calculate the launchtime in igc_tx_launchtime() is able to handle 'base_time_ being zero just fine, and the BASET_{L,H} registers will have sane values when it's zero as well.

If '->base_time' is never set, I suspect ETF disabling has an issue. See this piece of code:

int igc_tsn_offload_apply(struct igc_adapter *adapter)

{
        bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter);

        if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled)
                return 0;

        ...
}

By the time igc_tsn_offload_apply() is called, we had already set 'ring->launchtime' to false. Since IGC_FLAG_TSN_QBV_ENABLED isn't set and 'is_any_enabled' is false, we return without calling igc_tsn_disable_offload().

What am I missing?

Thanks,

Andre

#8 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

Quoted 35 lines · Andre Guedes

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-10 17:13:13)

Quoted 12 lines
Quoted 11 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, · line 4665

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
@@ -4600,6 +4661,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
        case TC_SETUP_QDISC_TAPRIO:
                return igc_tsn_enable_qbv_scheduling(adapter, type_data);
 
+       case TC_SETUP_QDISC_ETF:
+               return igc_tsn_enable_launchtime(adapter, type_data);

Consider the scenario where both TAPRIO and ETF offloads are disabled and we want to enable ETF offload. ETF depends on adapter->base_time is set to work properly, but I couldn't find where in this patch it is set. Could you please clarify that?

Quoted 6 lines

'->base_time' doesn't need to be set, i.e. if it's zero (which is the case that only ETF offloading is enabled), it should be fine. H

ow we calculate the launchtime in igc_tx_launchtime() is able to handle 'base_time_ being zero just fine, and the BASET_{L,H} registers will have sane values when it's zero as well.

If '->base_time' is never set, I suspect ETF disabling has an issue. See this piece of code:

int igc_tsn_offload_apply(struct igc_adapter *adapter)

{
        bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter);

        if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled)
                return 0;

        ...
}
Quoted 4 lines

By the time igc_tsn_offload_apply() is called, we had already set 'ring->launchtime' to false. Since IGC_FLAG_TSN_QBV_ENABLED isn't set and 'is_any_enabled' is false, we return without calling igc_tsn_disable_offload().

I am still not seeing the problem.

If ETF offloading was disabled, and then enabled, igc_save_launchtime_params() got called and some of the queues have launchtime_enable bit set. igc_save_launchtime_params() calls igc_tsn_offload_apply() and IGC_FLAG_TSN_QBV_ENABLED is set. Later, when the user wants to disable ETF offloading (the only way is to remove the qdisc, remember), the same thing happens: save_launchtime() and then offload_apply(), but now the IGC_FLAG_TSN_QBV_ENABLED is enabled, but there's no user, so igc_tsn_disable_offload() is called and the controller is reset if necessary.

Signature · 1 line
Vinicius
#9 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-12 16:13:14)

Quoted 39 lines
Quoted 32 lines
Quoted 12 lines
Quoted 11 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, · line 4665

Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
@@ -4600,6 +4661,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
        case TC_SETUP_QDISC_TAPRIO:
                return igc_tsn_enable_qbv_scheduling(adapter, type_data);
 
+       case TC_SETUP_QDISC_ETF:
+               return igc_tsn_enable_launchtime(adapter, type_data);

Consider the scenario where both TAPRIO and ETF offloads are disabled and we want to enable ETF offload. ETF depends on adapter->base_time is set to work properly, but I couldn't find where in this patch it is set. Could you please clarify that?

Quoted 6 lines

'->base_time' doesn't need to be set, i.e. if it's zero (which is the case that only ETF offloading is enabled), it should be fine. H

ow we calculate the launchtime in igc_tx_launchtime() is able to handle 'base_time_ being zero just fine, and the BASET_{L,H} registers will have sane values when it's zero as well.

If '->base_time' is never set, I suspect ETF disabling has an issue. See this piece of code:

int igc_tsn_offload_apply(struct igc_adapter *adapter)

{
        bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter);

        if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled)
                return 0;

        ...
}
Quoted 4 lines

By the time igc_tsn_offload_apply() is called, we had already set 'ring->launchtime' to false. Since IGC_FLAG_TSN_QBV_ENABLED isn't set and 'is_any_enabled' is false, we return without calling igc_tsn_disable_offload().

I am still not seeing the problem.

Quoted 9 lines

If ETF offloading was disabled, and then enabled, igc_save_launchtime_params() got called and some of the queues have launchtime_enable bit set. igc_save_launchtime_params() calls igc_tsn_offload_apply() and IGC_FLAG_TSN_QBV_ENABLED is set. Later, when the user wants to disable ETF offloading (the only way is to remove the qdisc, remember), the same thing happens: save_launchtime() and then offload_apply(), but now the IGC_FLAG_TSN_QBV_ENABLED is enabled, but there's no user, so igc_tsn_disable_offload() is called and the controller is reset if necessary.

Oh, I see it now, thanks.

The source of my misunderstanding was the fact that I was not expecting IGC_FLAG_TSN_QBV_ENABLED flag to be set since we are not enabling Qbv, but launchtime. I understand these features share configuration registers, but they are different features after all.

- Andre

#10 lore raw

PATCH v2 2/2 igc: Add support for ETF offloading

In reply to Andre Guedes
Quoted 11 lines · Andre Guedes

Hi Vinicius,

Quoting Vinicius Costa Gomes (2020-02-07 10:24:43)
...

Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_main.c +0 -0

...

Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_main.c +0 -0
@@ -4497,6 +4516,32 @@ static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
        }
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) · line 4526

Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_main.c +8 -0
+static int igc_save_launchtime_params(struct igc_adapter *adapter, int queue,
+                                     bool enable)
+{
+       struct igc_ring *ring;
+       int i;
+
+       if (queue < 0 || queue > adapter->num_tx_queues)
+               return -EINVAL;

I believe we have an off-by-one bug here. Shouldn't it be queue >= adapter->num_tx_queues instead?

Will fix this. (just a note that this off-by-one cannot be exploited by luck almost, mqprio/taprio do the check correctly on their side)

Quoted 16 lines

drivers/net/ethernet/intel/igc/igc_main.c static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, · line 4665

Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_main.c +2 -0
@@ -4600,6 +4661,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
        case TC_SETUP_QDISC_TAPRIO:
                return igc_tsn_enable_qbv_scheduling(adapter, type_data);
 
+       case TC_SETUP_QDISC_ETF:
+               return igc_tsn_enable_launchtime(adapter, type_data);

Consider the scenario where both TAPRIO and ETF offloads are disabled and we want to enable ETF offload. ETF depends on adapter->base_time is set to work properly, but I couldn't find where in this patch it is set. Could you please clarify that?

Regards,

Andre

Signature · 1 line
Vinicius