Commit 61572d5f authored by Vinicius Costa Gomes's avatar Vinicius Costa Gomes Committed by Tony Nguyen

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: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: default avatarAravindhan Gunasekaran <aravindhan.gunasekaran@intel.com>
Signed-off-by: default avatarMallikarjuna Chilakala <mallikarjuna.chilakala@intel.com>
Tested-by: default avatarDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent c814a2d2
...@@ -291,6 +291,8 @@ extern char igc_driver_name[]; ...@@ -291,6 +291,8 @@ extern char igc_driver_name[];
#define IGC_FLAG_RX_LEGACY BIT(16) #define IGC_FLAG_RX_LEGACY BIT(16)
#define IGC_FLAG_TSN_QBV_ENABLED BIT(17) #define IGC_FLAG_TSN_QBV_ENABLED BIT(17)
#define IGC_FLAG_TSN_ANY_ENABLED IGC_FLAG_TSN_QBV_ENABLED
#define IGC_FLAG_RSS_FIELD_IPV4_UDP BIT(6) #define IGC_FLAG_RSS_FIELD_IPV4_UDP BIT(6)
#define IGC_FLAG_RSS_FIELD_IPV6_UDP BIT(7) #define IGC_FLAG_RSS_FIELD_IPV6_UDP BIT(7)
......
...@@ -120,7 +120,7 @@ void igc_reset(struct igc_adapter *adapter) ...@@ -120,7 +120,7 @@ void igc_reset(struct igc_adapter *adapter)
igc_ptp_reset(adapter); igc_ptp_reset(adapter);
/* Re-enable TSN offloading, where applicable. */ /* Re-enable TSN offloading, where applicable. */
igc_tsn_offload_apply(adapter); igc_tsn_reset(adapter);
igc_get_phy_info(hw); igc_get_phy_info(hw);
} }
......
...@@ -18,8 +18,21 @@ static bool is_any_launchtime(struct igc_adapter *adapter) ...@@ -18,8 +18,21 @@ static bool is_any_launchtime(struct igc_adapter *adapter)
return false; return false;
} }
static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter)
{
unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED;
if (adapter->base_time)
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
if (is_any_launchtime(adapter))
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
return new_flags;
}
/* Returns the TSN specific registers to their default values after /* Returns the TSN specific registers to their default values after
* TSN offloading is disabled. * the adapter is reset.
*/ */
static int igc_tsn_disable_offload(struct igc_adapter *adapter) static int igc_tsn_disable_offload(struct igc_adapter *adapter)
{ {
...@@ -27,11 +40,6 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter) ...@@ -27,11 +40,6 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)
u32 tqavctrl; u32 tqavctrl;
int i; int i;
if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED))
return 0;
adapter->cycle_time = 0;
wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT); wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT);
wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT); wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT);
...@@ -62,9 +70,6 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter) ...@@ -62,9 +70,6 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
ktime_t base_time, systim; ktime_t base_time, systim;
int i; int i;
if (adapter->flags & IGC_FLAG_TSN_QBV_ENABLED)
return 0;
cycle = adapter->cycle_time; cycle = adapter->cycle_time;
base_time = adapter->base_time; base_time = adapter->base_time;
...@@ -119,33 +124,41 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter) ...@@ -119,33 +124,41 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
wr32(IGC_BASET_H, baset_h); wr32(IGC_BASET_H, baset_h);
wr32(IGC_BASET_L, baset_l); wr32(IGC_BASET_L, baset_l);
adapter->flags |= IGC_FLAG_TSN_QBV_ENABLED;
return 0; return 0;
} }
int igc_tsn_offload_apply(struct igc_adapter *adapter) int igc_tsn_reset(struct igc_adapter *adapter)
{ {
bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter); unsigned int new_flags;
int err = 0;
if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled) new_flags = igc_tsn_new_flags(adapter);
return 0;
if (!(new_flags & IGC_FLAG_TSN_ANY_ENABLED))
return igc_tsn_disable_offload(adapter);
err = igc_tsn_enable_offload(adapter);
if (err < 0)
return err;
if (!is_any_enabled) { adapter->flags = new_flags;
int err = igc_tsn_disable_offload(adapter);
if (err < 0) return err;
return err; }
/* The BASET registers aren't cleared when writing int igc_tsn_offload_apply(struct igc_adapter *adapter)
* into them, force a reset if the interface is {
* running. int err;
*/
if (netif_running(adapter->netdev))
schedule_work(&adapter->reset_task);
if (netif_running(adapter->netdev)) {
schedule_work(&adapter->reset_task);
return 0; return 0;
} }
return igc_tsn_enable_offload(adapter); err = igc_tsn_enable_offload(adapter);
if (err < 0)
return err;
adapter->flags = igc_tsn_new_flags(adapter);
return 0;
} }
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
#define _IGC_TSN_H_ #define _IGC_TSN_H_
int igc_tsn_offload_apply(struct igc_adapter *adapter); int igc_tsn_offload_apply(struct igc_adapter *adapter);
int igc_tsn_reset(struct igc_adapter *adapter);
#endif /* _IGC_BASE_H */ #endif /* _IGC_BASE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment