Skip to content

Commit b6c9ebd

Browse files
committed
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== igc: Fix corner cases for TSN offload Florian Kauer says: The igc driver supports several different offloading capabilities relevant in the TSN context. Recent patches in this area introduced regressions for certain corner cases that are fixed in this series. Each of the patches (except the first one) addresses a different regression that can be separately reproduced. Still, they have overlapping code changes so they should not be separately applied. Especially #4 and #6 address the same observation, but both need to be applied to avoid TX hang occurrences in the scenario described in the patches. ==================== Signed-off-by: Florian Kauer <[email protected]> Reviewed-by: Kurt Kanzenbach <[email protected]> Acked-by: Vinicius Costa Gomes <[email protected]> Reviewed-by: Muhammad Husaini Zulkifli <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents e522c1b + 0bcc628 commit b6c9ebd

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct igc_adapter {
191191
int tc_setup_type;
192192
ktime_t base_time;
193193
ktime_t cycle_time;
194-
bool qbv_enable;
194+
bool taprio_offload_enable;
195195
u32 qbv_config_change_errors;
196196
bool qbv_transition;
197197
unsigned int qbv_count;

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime,
10161016
ktime_t base_time = adapter->base_time;
10171017
ktime_t now = ktime_get_clocktai();
10181018
ktime_t baset_est, end_of_cycle;
1019-
u32 launchtime;
1019+
s32 launchtime;
10201020
s64 n;
10211021

10221022
n = div64_s64(ktime_sub_ns(now, base_time), cycle_time);
@@ -1029,7 +1029,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime,
10291029
*first_flag = true;
10301030
ring->last_ff_cycle = baset_est;
10311031

1032-
if (ktime_compare(txtime, ring->last_tx_cycle) > 0)
1032+
if (ktime_compare(end_of_cycle, ring->last_tx_cycle) > 0)
10331033
*insert_empty = true;
10341034
}
10351035
}
@@ -6097,6 +6097,7 @@ static int igc_tsn_clear_schedule(struct igc_adapter *adapter)
60976097

60986098
adapter->base_time = 0;
60996099
adapter->cycle_time = NSEC_PER_SEC;
6100+
adapter->taprio_offload_enable = false;
61006101
adapter->qbv_config_change_errors = 0;
61016102
adapter->qbv_transition = false;
61026103
adapter->qbv_count = 0;
@@ -6124,31 +6125,24 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,
61246125
size_t n;
61256126
int i;
61266127

6127-
switch (qopt->cmd) {
6128-
case TAPRIO_CMD_REPLACE:
6129-
adapter->qbv_enable = true;
6130-
break;
6131-
case TAPRIO_CMD_DESTROY:
6132-
adapter->qbv_enable = false;
6133-
break;
6134-
default:
6135-
return -EOPNOTSUPP;
6136-
}
6137-
6138-
if (!adapter->qbv_enable)
6128+
if (qopt->cmd == TAPRIO_CMD_DESTROY)
61396129
return igc_tsn_clear_schedule(adapter);
61406130

6131+
if (qopt->cmd != TAPRIO_CMD_REPLACE)
6132+
return -EOPNOTSUPP;
6133+
61416134
if (qopt->base_time < 0)
61426135
return -ERANGE;
61436136

6144-
if (igc_is_device_id_i225(hw) && adapter->base_time)
6137+
if (igc_is_device_id_i225(hw) && adapter->taprio_offload_enable)
61456138
return -EALREADY;
61466139

61476140
if (!validate_schedule(adapter, qopt))
61486141
return -EINVAL;
61496142

61506143
adapter->cycle_time = qopt->cycle_time;
61516144
adapter->base_time = qopt->base_time;
6145+
adapter->taprio_offload_enable = true;
61526146

61536147
igc_ptp_read(adapter, &now);
61546148

drivers/net/ethernet/intel/igc/igc_tsn.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
3737
{
3838
unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED;
3939

40-
if (adapter->qbv_enable)
40+
if (adapter->taprio_offload_enable)
4141
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
4242

4343
if (is_any_launchtime(adapter))
@@ -132,8 +132,28 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
132132
wr32(IGC_STQT(i), ring->start_time);
133133
wr32(IGC_ENDQT(i), ring->end_time);
134134

135-
txqctl |= IGC_TXQCTL_STRICT_CYCLE |
136-
IGC_TXQCTL_STRICT_END;
135+
if (adapter->taprio_offload_enable) {
136+
/* If taprio_offload_enable is set we are in "taprio"
137+
* mode and we need to be strict about the
138+
* cycles: only transmit a packet if it can be
139+
* completed during that cycle.
140+
*
141+
* If taprio_offload_enable is NOT true when
142+
* enabling TSN offload, the cycle should have
143+
* no external effects, but is only used internally
144+
* to adapt the base time register after a second
145+
* has passed.
146+
*
147+
* Enabling strict mode in this case would
148+
* unnecessarily prevent the transmission of
149+
* certain packets (i.e. at the boundary of a
150+
* second) and thus interfere with the launchtime
151+
* feature that promises transmission at a
152+
* certain point in time.
153+
*/
154+
txqctl |= IGC_TXQCTL_STRICT_CYCLE |
155+
IGC_TXQCTL_STRICT_END;
156+
}
137157

138158
if (ring->launchtime_enable)
139159
txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT;

0 commit comments

Comments
 (0)