Skip to content

Commit 61572d5

Browse files
vcgomesanguy11
authored andcommitted
igc: Simplify TSN flags handling
Separates the procedure done during reset from applying a configuration, knowing when the code is executing allow us to separate the better what changes the hardware state from what changes only the driver state. Introduces a flag for bookkeeping the driver state of TSN features. When Qav and frame-preemption is also implemented this flag makes it easier to keep track on whether a TSN feature driver state is enabled or not though controller state changes, say, during a reset. Signed-off-by: Vinicius Costa Gomes <[email protected]> Signed-off-by: Aravindhan Gunasekaran <[email protected]> Signed-off-by: Mallikarjuna Chilakala <[email protected]> Tested-by: Dvora Fuxbrumer <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent c814a2d commit 61572d5

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ extern char igc_driver_name[];
291291
#define IGC_FLAG_RX_LEGACY BIT(16)
292292
#define IGC_FLAG_TSN_QBV_ENABLED BIT(17)
293293

294+
#define IGC_FLAG_TSN_ANY_ENABLED IGC_FLAG_TSN_QBV_ENABLED
295+
294296
#define IGC_FLAG_RSS_FIELD_IPV4_UDP BIT(6)
295297
#define IGC_FLAG_RSS_FIELD_IPV6_UDP BIT(7)
296298

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void igc_reset(struct igc_adapter *adapter)
120120
igc_ptp_reset(adapter);
121121

122122
/* Re-enable TSN offloading, where applicable. */
123-
igc_tsn_offload_apply(adapter);
123+
igc_tsn_reset(adapter);
124124

125125
igc_get_phy_info(hw);
126126
}

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

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,28 @@ static bool is_any_launchtime(struct igc_adapter *adapter)
1818
return false;
1919
}
2020

21+
static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
22+
{
23+
unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED;
24+
25+
if (adapter->base_time)
26+
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
27+
28+
if (is_any_launchtime(adapter))
29+
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
30+
31+
return new_flags;
32+
}
33+
2134
/* Returns the TSN specific registers to their default values after
22-
* TSN offloading is disabled.
35+
* the adapter is reset.
2336
*/
2437
static int igc_tsn_disable_offload(struct igc_adapter *adapter)
2538
{
2639
struct igc_hw *hw = &adapter->hw;
2740
u32 tqavctrl;
2841
int i;
2942

30-
if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED))
31-
return 0;
32-
33-
adapter->cycle_time = 0;
34-
3543
wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT);
3644
wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT);
3745

@@ -62,9 +70,6 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
6270
ktime_t base_time, systim;
6371
int i;
6472

65-
if (adapter->flags & IGC_FLAG_TSN_QBV_ENABLED)
66-
return 0;
67-
6873
cycle = adapter->cycle_time;
6974
base_time = adapter->base_time;
7075

@@ -119,33 +124,41 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
119124
wr32(IGC_BASET_H, baset_h);
120125
wr32(IGC_BASET_L, baset_l);
121126

122-
adapter->flags |= IGC_FLAG_TSN_QBV_ENABLED;
123-
124127
return 0;
125128
}
126129

127-
int igc_tsn_offload_apply(struct igc_adapter *adapter)
130+
int igc_tsn_reset(struct igc_adapter *adapter)
128131
{
129-
bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter);
132+
unsigned int new_flags;
133+
int err = 0;
130134

131-
if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled)
132-
return 0;
135+
new_flags = igc_tsn_new_flags(adapter);
136+
137+
if (!(new_flags & IGC_FLAG_TSN_ANY_ENABLED))
138+
return igc_tsn_disable_offload(adapter);
139+
140+
err = igc_tsn_enable_offload(adapter);
141+
if (err < 0)
142+
return err;
133143

134-
if (!is_any_enabled) {
135-
int err = igc_tsn_disable_offload(adapter);
144+
adapter->flags = new_flags;
136145

137-
if (err < 0)
138-
return err;
146+
return err;
147+
}
139148

140-
/* The BASET registers aren't cleared when writing
141-
* into them, force a reset if the interface is
142-
* running.
143-
*/
144-
if (netif_running(adapter->netdev))
145-
schedule_work(&adapter->reset_task);
149+
int igc_tsn_offload_apply(struct igc_adapter *adapter)
150+
{
151+
int err;
146152

153+
if (netif_running(adapter->netdev)) {
154+
schedule_work(&adapter->reset_task);
147155
return 0;
148156
}
149157

150-
return igc_tsn_enable_offload(adapter);
158+
err = igc_tsn_enable_offload(adapter);
159+
if (err < 0)
160+
return err;
161+
162+
adapter->flags = igc_tsn_new_flags(adapter);
163+
return 0;
151164
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
#define _IGC_TSN_H_
66

77
int igc_tsn_offload_apply(struct igc_adapter *adapter);
8+
int igc_tsn_reset(struct igc_adapter *adapter);
89

910
#endif /* _IGC_BASE_H */

0 commit comments

Comments
 (0)