diff mbox series

[iwl-next] igc: Change Tx mode for MQPRIO offloading

Message ID 20250217-igc_mqprio_tx_mode-v1-1-3a402fe1f326@linutronix.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [iwl-next] igc: Change Tx mode for MQPRIO offloading | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 109 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 29 this patch: 29
netdev/source_inline success Was 0 now: 0

Commit Message

Kurt Kanzenbach Feb. 17, 2025, 11:45 a.m. UTC
The current MQPRIO offload implementation uses the legacy TSN Tx mode. In
this mode the hardware uses four packet buffers and considers queue
priorities.

In order to harmonize the TAPRIO implementation with MQPRIO switch to the
regular TSN Tx mode. In addition to the legacy mode, transmission is always
coupled to Qbv. The driver already has mechanisms to use a dummy schedule
of 1 second with all gates open for ETF. Simply use this for MQPRIO too.

This reduces code and makes it easier to add support for frame preemption
later.

While at it limit the netdev_tc calls to MQPRIO only.

Tested on i225 with real time application using high priority queue, iperf3
using low priority queue and network TAP device.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 drivers/net/ethernet/intel/igc/igc.h      |  4 +---
 drivers/net/ethernet/intel/igc/igc_main.c | 18 ++++++++++++++++-
 drivers/net/ethernet/intel/igc/igc_tsn.c  | 33 +------------------------------
 3 files changed, 19 insertions(+), 36 deletions(-)


---
base-commit: 0784d83df3bfc977c13252a0599be924f0afa68d
change-id: 20250214-igc_mqprio_tx_mode-22c19c564605

Best regards,

Comments

Abdul Rahim, Faizal Feb. 21, 2025, 7:23 a.m. UTC | #1
On 17/2/2025 7:45 pm, Kurt Kanzenbach wrote:
> The current MQPRIO offload implementation uses the legacy TSN Tx mode. In
> this mode the hardware uses four packet buffers and considers queue
> priorities.
> 
> In order to harmonize the TAPRIO implementation with MQPRIO switch to the
Missed "," ?
In order to harmonize the TAPRIO implementation with MQPRIO, switch to the

> diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c
> index 1e44374ca1ffbb86e9893266c590f318984ef574..6e4582de9602db2c6667f1736cc2acaa4d4b5201 100644
> --- a/drivers/net/ethernet/intel/igc/igc_tsn.c
> +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
> @@ -47,7 +47,7 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
>   		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
>   
>   	if (adapter->strict_priority_enable)
> -		new_flags |= IGC_FLAG_TSN_LEGACY_ENABLED;
> +		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>   
>   	return new_flags;
>   }

IGC_FLAG_TSN_QBV_ENABLED is set multiple times in different lines:

	if (adapter->taprio_offload_enable)
		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;

	if (is_any_launchtime(adapter))
		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;

	if (is_cbs_enabled(adapter))
		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;

	if (adapter->strict_priority_enable)
		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;

	return new_flags;
}

We can combine the conditions to simplify:
	if (adapter->taprio_offload_enable ||
             is_any_launchtime(adapter) ||
             adapter->strict_priority_enable)
		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
Kurt Kanzenbach Feb. 21, 2025, 9:01 a.m. UTC | #2
On Fri Feb 21 2025, Abdul Rahim, Faizal wrote:
> On 17/2/2025 7:45 pm, Kurt Kanzenbach wrote:
>> The current MQPRIO offload implementation uses the legacy TSN Tx mode. In
>> this mode the hardware uses four packet buffers and considers queue
>> priorities.
>> 
>> In order to harmonize the TAPRIO implementation with MQPRIO switch to the
> Missed "," ?
> In order to harmonize the TAPRIO implementation with MQPRIO, switch to the

Ok.

>
>> diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c
>> index 1e44374ca1ffbb86e9893266c590f318984ef574..6e4582de9602db2c6667f1736cc2acaa4d4b5201 100644
>> --- a/drivers/net/ethernet/intel/igc/igc_tsn.c
>> +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
>> @@ -47,7 +47,7 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
>>   		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
>>   
>>   	if (adapter->strict_priority_enable)
>> -		new_flags |= IGC_FLAG_TSN_LEGACY_ENABLED;
>> +		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>>   
>>   	return new_flags;
>>   }
>
> IGC_FLAG_TSN_QBV_ENABLED is set multiple times in different lines:
>
> 	if (adapter->taprio_offload_enable)
> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>
> 	if (is_any_launchtime(adapter))
> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>
> 	if (is_cbs_enabled(adapter))
> 		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
>
> 	if (adapter->strict_priority_enable)
> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>
> 	return new_flags;
> }
>
> We can combine the conditions to simplify:
> 	if (adapter->taprio_offload_enable ||
>              is_any_launchtime(adapter) ||
>              adapter->strict_priority_enable)
> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;

Sure.

Should I send a v2 or do you want to carry this patch in your next fpe
series?
Abdul Rahim, Faizal Feb. 21, 2025, 9:39 a.m. UTC | #3
>>> diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c
>>> index 1e44374ca1ffbb86e9893266c590f318984ef574..6e4582de9602db2c6667f1736cc2acaa4d4b5201 100644
>>> --- a/drivers/net/ethernet/intel/igc/igc_tsn.c
>>> +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
>>> @@ -47,7 +47,7 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
>>>    		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
>>>    
>>>    	if (adapter->strict_priority_enable)
>>> -		new_flags |= IGC_FLAG_TSN_LEGACY_ENABLED;
>>> +		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>>>    
>>>    	return new_flags;
>>>    }
>>
>> IGC_FLAG_TSN_QBV_ENABLED is set multiple times in different lines:
>>
>> 	if (adapter->taprio_offload_enable)
>> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>>
>> 	if (is_any_launchtime(adapter))
>> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>>
>> 	if (is_cbs_enabled(adapter))
>> 		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
>>
>> 	if (adapter->strict_priority_enable)
>> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
>>
>> 	return new_flags;
>> }
>>
>> We can combine the conditions to simplify:
>> 	if (adapter->taprio_offload_enable ||
>>               is_any_launchtime(adapter) ||
>>               adapter->strict_priority_enable)
>> 		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
> 
> Sure.
> 
> Should I send a v2 or do you want to carry this patch in your next fpe
> series?

I think you can go ahead with v2. It shouldn’t conflict much with the next 
fpe series, and if my future series gets stalled, at least yours won’t be 
affected.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index b8111ad9a9a83dbe1257d8011e046cbd263022c3..95f503f7a41f42358302d4726ef82032278fbd29 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -388,11 +388,9 @@  extern char igc_driver_name[];
 #define IGC_FLAG_RX_LEGACY		BIT(16)
 #define IGC_FLAG_TSN_QBV_ENABLED	BIT(17)
 #define IGC_FLAG_TSN_QAV_ENABLED	BIT(18)
-#define IGC_FLAG_TSN_LEGACY_ENABLED	BIT(19)
 
 #define IGC_FLAG_TSN_ANY_ENABLED				\
-	(IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED |	\
-	 IGC_FLAG_TSN_LEGACY_ENABLED)
+	(IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED)
 
 #define IGC_FLAG_RSS_FIELD_IPV4_UDP	BIT(6)
 #define IGC_FLAG_RSS_FIELD_IPV6_UDP	BIT(7)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 84307bb7313e0fcb7d598e67586f1ea076c1d942..7a37a54c5aa9f36505a98a42959ba8276469ce36 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -6603,13 +6603,14 @@  static int igc_tsn_enable_mqprio(struct igc_adapter *adapter,
 				 struct tc_mqprio_qopt_offload *mqprio)
 {
 	struct igc_hw *hw = &adapter->hw;
-	int i;
+	int err, i;
 
 	if (hw->mac.type != igc_i225)
 		return -EOPNOTSUPP;
 
 	if (!mqprio->qopt.num_tc) {
 		adapter->strict_priority_enable = false;
+		netdev_reset_tc(adapter->netdev);
 		goto apply;
 	}
 
@@ -6640,6 +6641,21 @@  static int igc_tsn_enable_mqprio(struct igc_adapter *adapter,
 	igc_save_mqprio_params(adapter, mqprio->qopt.num_tc,
 			       mqprio->qopt.offset);
 
+	err = netdev_set_num_tc(adapter->netdev, adapter->num_tc);
+	if (err)
+		return err;
+
+	for (i = 0; i < adapter->num_tc; i++) {
+		err = netdev_set_tc_queue(adapter->netdev, i, 1,
+					  adapter->queue_per_tc[i]);
+		if (err)
+			return err;
+	}
+
+	/* In case the card is configured with less than four queues. */
+	for (; i < IGC_MAX_TX_QUEUES; i++)
+		adapter->queue_per_tc[i] = i;
+
 	mqprio->qopt.hw = TC_MQPRIO_HW_OFFLOAD_TCS;
 
 apply:
diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c
index 1e44374ca1ffbb86e9893266c590f318984ef574..6e4582de9602db2c6667f1736cc2acaa4d4b5201 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -47,7 +47,7 @@  static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
 		new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
 
 	if (adapter->strict_priority_enable)
-		new_flags |= IGC_FLAG_TSN_LEGACY_ENABLED;
+		new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
 
 	return new_flags;
 }
@@ -157,16 +157,12 @@  static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 	wr32(IGC_QBVCYCLET_S, 0);
 	wr32(IGC_QBVCYCLET, NSEC_PER_SEC);
 
-	/* Reset mqprio TC configuration. */
-	netdev_reset_tc(adapter->netdev);
-
 	/* Restore the default Tx arbitration: Priority 0 has the highest
 	 * priority and is assigned to queue 0 and so on and so forth.
 	 */
 	igc_tsn_tx_arb(adapter, queue_per_tc);
 
 	adapter->flags &= ~IGC_FLAG_TSN_QBV_ENABLED;
-	adapter->flags &= ~IGC_FLAG_TSN_LEGACY_ENABLED;
 
 	return 0;
 }
@@ -206,37 +202,10 @@  static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 		igc_tsn_set_retx_qbvfullthreshold(adapter);
 
 	if (adapter->strict_priority_enable) {
-		int err;
-
-		err = netdev_set_num_tc(adapter->netdev, adapter->num_tc);
-		if (err)
-			return err;
-
-		for (i = 0; i < adapter->num_tc; i++) {
-			err = netdev_set_tc_queue(adapter->netdev, i, 1,
-						  adapter->queue_per_tc[i]);
-			if (err)
-				return err;
-		}
-
-		/* In case the card is configured with less than four queues. */
-		for (; i < IGC_MAX_TX_QUEUES; i++)
-			adapter->queue_per_tc[i] = i;
-
 		/* Configure queue priorities according to the user provided
 		 * mapping.
 		 */
 		igc_tsn_tx_arb(adapter, adapter->queue_per_tc);
-
-		/* Enable legacy TSN mode which will do strict priority without
-		 * any other TSN features.
-		 */
-		tqavctrl = rd32(IGC_TQAVCTRL);
-		tqavctrl |= IGC_TQAVCTRL_TRANSMIT_MODE_TSN;
-		tqavctrl &= ~IGC_TQAVCTRL_ENHANCED_QAV;
-		wr32(IGC_TQAVCTRL, tqavctrl);
-
-		return 0;
 	}
 
 	for (i = 0; i < adapter->num_tx_queues; i++) {