i40e: rename index to port to avoid confusion
Subsystems (2)
PATCH 1/10 i40e: rename index to port to avoid confusion
From: Jacob Keller <[email protected]>
The .index field of i40e_udp_port_config represents the udp port number. Rename this variable to port so that it is more obvious.
--- drivers/net/ethernet/intel/i40e/i40e.h | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -1
@@ -245,7 +245,7 @@ struct i40e_tc_configuration {struct i40e_udp_port_config {/* AdminQ command interface expects port number in Host byte order */ -u16 index; +u16 port;u8 type; };
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -5
@@ -7349,7 +7349,7 @@ static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)for (i =0 ; i <I40E_MAX_PF_UDP_OFFLOAD_PORTS ; i++) {if (pf->pending_udp_bitmap &BIT_ULL (i)) { pf->pending_udp_bitmap &= ~BIT_ULL (i); - port = pf->udp_ports[i].index; + port = pf->udp_ports[i].port;if (port) ret = i40e_aq_add_udp_tunnel(hw, port, pf->udp_ports[i].type,
@@ -7366,7 +7366,7 @@ static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)i40e_stat_str (&pf->hw, ret),i40e_aq_str (&pf->hw, pf->hw.aq.asq_last_status)); - pf->udp_ports[i].index =0 ; + pf->udp_ports[i].port =0 ; } } }
@@ -8953,7 +8953,7 @@ static u8 i40e_get_udp_port_idx(struct i40e_pf *pf, u16 port)u8 i;for (i =0 ; i <I40E_MAX_PF_UDP_OFFLOAD_PORTS ; i++) { -if (pf->udp_ports[i].index == port) +if (pf->udp_ports[i].port == port)return i; }
@@ -9006,7 +9006,7 @@ static void i40e_udp_tunnel_add(struct net_device *netdev, }/* New port: add it and mark its index in the bitmap */ - pf->udp_ports[next_idx].index = port; + pf->udp_ports[next_idx].port = port; pf->pending_udp_bitmap |=BIT_ULL (next_idx); pf->flags |=I40E_FLAG_UDP_FILTER_SYNC ; }
@@ -9047,7 +9047,7 @@ static void i40e_udp_tunnel_del(struct net_device *netdev,/* if port exists, set it to 0 (mark for deletion) * and make it pending */ - pf->udp_ports[idx].index =0 ; + pf->udp_ports[idx].port =0 ; pf->pending_udp_bitmap |=BIT_ULL (idx); pf->flags |=I40E_FLAG_UDP_FILTER_SYNC ;
Signature · 1 line
2.9.3
PATCH 2/10 i40e: Reprogram port offloads after reset
From: Alexander Duyck <[email protected]>
This patch corrects a major oversight in that we were not reprogramming the ports after a reset. As a result we completely lost all of the Rx tunnel offloads on receive including Rx checksum, RSS on inner headers, and ATR.
The fix for this is pretty standard as all we needed to do is reset the filter bits to pending for all active filters and schedule the sync event.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +20 -0
@@ -7331,6 +7331,23 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf) }/** +* i40e_sync_udp_filters - Trigger a sync event for existing UDP filters +* @pf: board private structure +**/ +static void i40e_sync_udp_filters (struct i40e_pf *pf) +{ +int i; + +/* loop through and set pending bit for all active UDP filters */ +for (i =0 ; i <I40E_MAX_PF_UDP_OFFLOAD_PORTS ; i++) { +if (pf->udp_ports[i].port) + pf->pending_udp_bitmap |=BIT_ULL (i); + } + + pf->flags |=I40E_FLAG_UDP_FILTER_SYNC ; +} + +/** * i40e_sync_udp_filters_subtask - Sync the VSI filter list with HW * @pf: board private structure **/
@@ -10738,6 +10755,9 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)i40e_ptp_init (pf); +/* repopulate tunnel port filters */ +i40e_sync_udp_filters (pf); +return ret; }
Signature · 1 line
2.9.3
Bowers
PATCH 2/10 i40e: Reprogram port offloads after reset
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 02/10] i40e: Reprogram port offloads after resetFrom: Alexander Duyck <[email protected]>
This patch corrects a major oversight in that we were not reprogramming the ports after a reset. As a result we completely lost all of the Rx tunnel offloads on receive including Rx checksum, RSS on inner headers, and ATR.
Quoted 7 lines
The fix for this is pretty standard as all we needed to do is reset the filter bits to pending for all active filters and schedule the sync event.
Signed-off-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
PATCH 3/10 i40e: amortize wait time when disabling lots of VFs
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Just as we do in i40e_reset_all_vfs, save some time when freeing VFs by amortizing the wait time for stopping queues. We can use i40e_vsi_stop_rings_no_wait() to begin the process of stopping all the VF rings at once. Then, once we've started the process on each VF we can begin waiting for the VFs to stop. This helps reduce the total wait time by a large factor.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +14 -2
@@ -1194,9 +1194,21 @@ void i40e_free_vfs(struct i40e_pf *pf)usleep_range (1000 ,2000 );i40e_notify_client_of_vf_enable (pf,0 ); -for (i =0 ; i < pf->num_alloc_vfs; i++) + +/* Amortize wait time by stopping all VFs at the same time */ +for (i =0 ; i < pf->num_alloc_vfs; i++) { +if (test_bit (I40E_VF_STATE_INIT , &pf->vf[i].vf_states)) +continue ; + +i40e_vsi_stop_rings_no_wait (pf->vsi[pf->vf[i].lan_vsi_idx]); + } + +for (i =0 ; i < pf->num_alloc_vfs; i++) {if (test_bit (I40E_VF_STATE_INIT , &pf->vf[i].vf_states)) -i40e_vsi_stop_rings (pf->vsi[pf->vf[i].lan_vsi_idx]); +continue ; + +i40e_vsi_wait_queues_disabled (pf->vsi[pf->vf[i].lan_vsi_idx]); + }/* Disable IOV before freeing resources. This lets any VF drivers * running in the host get themselves cleaned up before we yank
Signature · 1 line
2.9.3
Bowers
PATCH 3/10 i40e: amortize wait time when disabling lots of VFs
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 03/10] i40e: amortize wait time when disabling lots of VFsFrom: Jacob Keller <[email protected]>
Just as we do in
i40e_reset_all_vfs, save some time when freeing VFs by amortizing the wait time for stopping queues. We can usei40e_vsi_stop_rings_no_wait()to begin the process of stopping all the VF rings at once. Then, once we've started the process on each VF we can begin waiting for the VFs to stop. This helps reduce the total wait time by a large factor.
Quoted 4 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
PATCH 4/10 i40e: remove unnecessary msleep() delay in i40e_free_vfs
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The delay was added because of a desire to ensure that the VF driver can finish up removing. However, pci_disable_sriov already has its own ssleep() call that will sleep for an entire second, so there is no reason to add extra delay on top of this by using msleep here. In practice, an msleep() won't have a huge impact on timing but there is no real value in keeping it, so lets just simplify the code and remove it.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 -- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -47,7 +47,7 @@ static const char i40e_driver_string[] =#define DRV_VERSION_MAJOR 2#define DRV_VERSION_MINOR 1 -#define DRV_VERSION_BUILD 7 +#define DRV_VERSION_BUILD 14#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ __stringify(DRV_VERSION_MINOR) "." \ __stringify(DRV_VERSION_BUILD) DRV_KERN
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -2
@@ -1219,8 +1219,6 @@ void i40e_free_vfs(struct i40e_pf *pf)else dev_warn (&pf->pdev->dev,"VFs are assigned - not disabling SR-IOV\n" ); -msleep (20 );/* let any messages in transit get finished up */ -/* free up VF resources */ tmp = pf->num_alloc_vfs; pf->num_alloc_vfs =0 ;
drivers/net/ethernet/intel/i40evf/i40evf_main.c +1 -1
@@ -46,7 +46,7 @@ static const char i40evf_driver_string[] =#define DRV_VERSION_MAJOR 2#define DRV_VERSION_MINOR 1 -#define DRV_VERSION_BUILD 7 +#define DRV_VERSION_BUILD 14#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ __stringify(DRV_VERSION_MINOR) "." \ __stringify(DRV_VERSION_BUILD) \
Signature · 1 line
2.9.3
PATCH 4/10 i40e: remove unnecessary msleep() delay in i40e_free_vfs
Quoted 21 lines · Alice Michael
From: Jacob Keller <[email protected]>
The delay was added because of a desire to ensure that the VF driver can finish up removing. However,
pci_disable_sriovalready has its ownssleep()call that will sleep for an entire second, so there is no reason to add extra delay on top of this by using msleep here. In practice, anmsleep()won't have a huge impact on timing but there is no real value in keeping it, so lets just simplify the code and remove it.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 -- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/i40e/i40e_main.c +0
-0
drivers/net/ethernet/intel/i40e/i40e_main.c static const char i40e_driver_string[] = · line 50
Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1
-1@@ -47,7 +47,7 @@ static const char i40e_driver_string[] =#define DRV_VERSION_MAJOR 2#define DRV_VERSION_MINOR 1 -#define DRV_VERSION_BUILD 7 +#define DRV_VERSION_BUILD 14
The version number changes should be a separate patch. sln
Quoted 30 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +0
-0#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ __stringify(DRV_VERSION_MINOR) "." \ __stringify(DRV_VERSION_BUILD) DRV_KERNdrivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0
-2@@ -1219,8 +1219,6 @@ void i40e_free_vfs(struct i40e_pf *pf)else dev_warn (&pf->pdev->dev,"VFs are assigned - not disabling SR-IOV\n" ); -msleep (20 );/* let any messages in transit get finished up */ -/* free up VF resources */ tmp = pf->num_alloc_vfs; pf->num_alloc_vfs =0 ;drivers/net/ethernet/intel/i40evf/i40evf_main.c +1
-1@@ -46,7 +46,7 @@ static const char i40evf_driver_string[] =#define DRV_VERSION_MAJOR 2#define DRV_VERSION_MINOR 1 -#define DRV_VERSION_BUILD 7 +#define DRV_VERSION_BUILD 14#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ __stringify(DRV_VERSION_MINOR) "." \ __stringify(DRV_VERSION_BUILD) \
Bowers
PATCH 4/10 i40e: remove unnecessary msleep() delay in i40e_free_vfs
In reply to Alice MichaelQuoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 04/10] i40e: remove unnecessarymsleep()delay ini40e_free_vfsFrom: Jacob Keller <[email protected]>
The delay was added because of a desire to ensure that the VF driver can finish up removing. However,
pci_disable_sriovalready has its ownssleep()call that will sleep for an entire second, so there is no reason to add extra delay on top of this by using msleep here. In practice, anmsleep()won't have a huge impact on timing but there is no real value in keeping it, so lets just simplify the code and remove it.
Quoted 6 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 -- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-)
PATCH 5/10 i40e: separate PF and VSI state flags
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Avoid using the same named flags for both vsi->state and pf->state. This makes code review easier, as it is more likely that future authors will use the correct state field when checking bits. Previous commits already found issues with at least one check, and possibly others may be incorrect.
This reduces confusion as it is more clear what each flag represents, and which flags are valid for which state field.
--- drivers/net/ethernet/intel/i40e/i40e.h | 12 ++- drivers/net/ethernet/intel/i40e/i40e_client.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 104 ++++++++++++------------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40evf.h | 7 +- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 10 +-- 8 files changed, 83 insertions(+), 74 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +10 -2
@@ -125,7 +125,6 @@ enum i40e_state_t { __I40E_CONFIG_BUSY, __I40E_CONFIG_DONE, __I40E_DOWN, - __I40E_NEEDS_RESTART, __I40E_SERVICE_SCHED, __I40E_ADMINQ_EVENT_PENDING, __I40E_MDD_EVENT_PENDING,
@@ -138,7 +137,6 @@ enum i40e_state_t { __I40E_GLOBAL_RESET_REQUESTED, __I40E_EMP_RESET_REQUESTED, __I40E_EMP_RESET_INTR_RECEIVED, - __I40E_FILTER_OVERFLOW_PROMISC, __I40E_SUSPENDED, __I40E_PTP_TX_IN_PROGRESS, __I40E_BAD_EEPROM,
@@ -149,6 +147,16 @@ enum i40e_state_t { __I40E_VF_DISABLE, }; +/* VSI state flags */ +enum i40e_vsi_state_t { + __I40E_VSI_DOWN, + __I40E_VSI_NEEDS_RESTART, + __I40E_VSI_SYNCING_FILTERS, + __I40E_VSI_OVERFLOW_PROMISC, + __I40E_VSI_REINIT_REQUESTED, + __I40E_VSI_DOWN_REQUESTED, +}; +enum i40e_interrupt_policy {I40E_INTERRUPT_BEST_CASE ,I40E_INTERRUPT_MEDIUM ,
drivers/net/ethernet/intel/i40e/i40e_client.c +2 -2
@@ -382,7 +382,7 @@ void i40e_client_subtask(struct i40e_pf *pf)* the netdev is up, then open the client. */ if (!test_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) { -if (!test_bit (__I40E_DOWN, &vsi->state) && +if (!test_bit (__I40E_VSI_DOWN, &vsi->state) && client->ops && client->ops->open) {set_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state); ret = client->ops->open (&cdev->lan_info, client);
@@ -397,7 +397,7 @@ void i40e_client_subtask(struct i40e_pf *pf)/* Likewise for client close. If the client is up, but the netdev * is down, then close the client. */ -if (test_bit (__I40E_DOWN, &vsi->state) && +if (test_bit (__I40E_VSI_DOWN, &vsi->state) && client->ops && client->ops->close) {clear_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state); client->ops->close (&cdev->lan_info, client, false);
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +2 -2
@@ -174,7 +174,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid) }dev_info (&pf->pdev->dev," active_filters %u, promisc_threshold %u, overflow promisc %s\n" , vsi->active_filters, vsi->promisc_threshold, - (test_bit (__I40E_FILTER_OVERFLOW_PROMISC, &vsi->state) ? + (test_bit (__I40E_VSI_OVERFLOW_PROMISC, &vsi->state) ?"ON" :"OFF" )); nstat =i40e_get_vsi_stats_struct (vsi); dev_info(&pf->pdev->dev,
@@ -1706,7 +1706,7 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp, }else if (!vsi->netdev) {dev_info (&pf->pdev->dev,"tx_timeout: no netdev for VSI %d\n" , vsi_seid); - }else if (test_bit (__I40E_DOWN, &vsi->state)) { + }else if (test_bit (__I40E_VSI_DOWN, &vsi->state)) {dev_info (&pf->pdev->dev,"tx_timeout: VSI %d not UP\n" , vsi_seid); }else if (rtnl_trylock ()) {
drivers/net/ethernet/intel/i40e/i40e_main.c +51 -53
368 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.c +4 -4
@@ -850,7 +850,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,if (budget && ((j /WB_STRIDE ) ==0 ) && (j >0 ) && - !test_bit (__I40E_DOWN, &vsi->state) && + !test_bit (__I40E_VSI_DOWN, &vsi->state) && (I40E_DESC_UNUSED (tx_ring) != tx_ring->count)) tx_ring->arm_wb = true; }
@@ -868,7 +868,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,smp_mb ();if (__netif_subqueue_stopped (tx_ring->netdev, tx_ring->queue_index) && - !test_bit (__I40E_DOWN, &vsi->state)) { + !test_bit (__I40E_VSI_DOWN, &vsi->state)) {netif_wake_subqueue (tx_ring->netdev, tx_ring->queue_index); ++tx_ring->tx_stats.restart_queue;
@@ -2178,7 +2178,7 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi, } enable_int: -if (!test_bit (__I40E_DOWN, &vsi->state)) +if (!test_bit (__I40E_VSI_DOWN, &vsi->state))wr32 (hw,INTREG (vector -1 ), txval);if (q_vector->itr_countdown)
@@ -2207,7 +2207,7 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)int budget_per_ring;int work_done =0 ; -if (test_bit (__I40E_DOWN, &vsi->state)) { +if (test_bit (__I40E_VSI_DOWN, &vsi->state)) {napi_complete (napi);return 0 ; }
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +4 -4
@@ -266,7 +266,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,if (budget && ((j /WB_STRIDE ) ==0 ) && (j >0 ) && - !test_bit (__I40E_DOWN, &vsi->state) && + !test_bit (__I40E_VSI_DOWN, &vsi->state) && (I40E_DESC_UNUSED (tx_ring) != tx_ring->count)) tx_ring->arm_wb = true; }
@@ -284,7 +284,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,smp_mb ();if (__netif_subqueue_stopped (tx_ring->netdev, tx_ring->queue_index) && - !test_bit (__I40E_DOWN, &vsi->state)) { + !test_bit (__I40E_VSI_DOWN, &vsi->state)) {netif_wake_subqueue (tx_ring->netdev, tx_ring->queue_index); ++tx_ring->tx_stats.restart_queue;
@@ -1508,7 +1508,7 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi, } enable_int: -if (!test_bit (__I40E_DOWN, &vsi->state)) +if (!test_bit (__I40E_VSI_DOWN, &vsi->state))wr32 (hw,INTREG (vector -1 ), txval);if (q_vector->itr_countdown)
@@ -1537,7 +1537,7 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)int budget_per_ring;int work_done =0 ; -if (test_bit (__I40E_DOWN, &vsi->state)) { +if (test_bit (__I40E_VSI_DOWN, &vsi->state)) {napi_complete (napi);return 0 ; }
drivers/net/ethernet/intel/i40evf/i40evf.h +5 -2
@@ -49,6 +49,11 @@#define DEFAULT_DEBUG_LEVEL_SHIFT 3#define PFX "i40evf: " +/* VSI state flags shared with common code */ +enum i40evf_vsi_state_t { + __I40E_VSI_DOWN, +}; +/* dummy struct to make common code less painful */ struct i40e_vsi {struct i40evf_adapter *back;
@@ -168,8 +173,6 @@ enum i40evf_critical_section_t { __I40EVF_IN_CRITICAL_TASK,/* cannot be interrupted */ __I40EVF_IN_CLIENT_TASK, }; -/* make common code happy */ -#define __I40E_DOWN __I40EVF_DOWN/* board specific private data structure */ struct i40evf_adapter {
drivers/net/ethernet/intel/i40evf/i40evf_main.c +5 -5
@@ -497,7 +497,7 @@ static void i40evf_netpoll(struct net_device *netdev)int i;/* if interface is down do nothing */ -if (test_bit (__I40E_DOWN, &adapter->vsi.state)) +if (test_bit (__I40E_VSI_DOWN, &adapter->vsi.state))return ;for (i =0 ; i < q_vectors; i++)
@@ -1087,7 +1087,7 @@ static void i40evf_configure(struct i40evf_adapter *adapter)static void i40evf_up_complete (struct i40evf_adapter *adapter) { adapter->state = __I40EVF_RUNNING; -clear_bit (__I40E_DOWN, &adapter->vsi.state); +clear_bit (__I40E_VSI_DOWN, &adapter->vsi.state);i40evf_napi_enable_all (adapter);
@@ -1753,7 +1753,7 @@ static void i40evf_disable_vf(struct i40evf_adapter *adapter) adapter->flags |=I40EVF_FLAG_PF_COMMS_FAILED ;if (netif_running (adapter->netdev)) { -set_bit (__I40E_DOWN, &adapter->vsi.state); +set_bit (__I40E_VSI_DOWN, &adapter->vsi.state);netif_carrier_off (adapter->netdev);netif_tx_disable (adapter->netdev); adapter->link_up = false;
@@ -2233,7 +2233,7 @@ static int i40evf_close(struct net_device *netdev)return 0 ; -set_bit (__I40E_DOWN, &adapter->vsi.state); +set_bit (__I40E_VSI_DOWN, &adapter->vsi.state);if (CLIENT_ENABLED (adapter)) adapter->flags |=I40EVF_FLAG_CLIENT_NEEDS_CLOSE ;
@@ -2674,7 +2674,7 @@ static void i40evf_init_task(struct work_struct *work)dev_info (&pdev->dev,"GRO is enabled\n" ); adapter->state = __I40EVF_DOWN; -set_bit (__I40E_DOWN, &adapter->vsi.state); +set_bit (__I40E_VSI_DOWN, &adapter->vsi.state);i40evf_misc_irq_enable (adapter); adapter->rss_key =kzalloc (adapter->rss_key_size,GFP_KERNEL );
Signature · 1 line
2.9.3
Bowers
PATCH 5/10 i40e: separate PF and VSI state flags
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 05/10] i40e: separate PF and VSI state flagsFrom: Jacob Keller <[email protected]>
Avoid using the same named flags for both
vsi->stateandpf->state. This makes code review easier, as it is more likely that future authors will use the correct state field when checking bits. Previous commits already found issues with at least one check, and possibly others may be incorrect.This reduces confusion as it is more clear what each flag represents, and which flags are valid for which state field.
Signed-off-by Jacob Keller <[email protected]>
Quoted 11 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 12 ++- drivers/net/ethernet/intel/i40e/i40e_client.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 104 ++++++++++++--------- --- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40evf.h | 7 +- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 10 +-- 8 files changed, 83 insertions(+), 74 deletions(-)
Keller
PATCH 5/10 i40e: separate PF and VSI state flags
Quoted 42 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bowers, AndrewX
Sent: Thursday, April 20, 2017 4:01 PM
To: intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [next PATCH S71 05/10] i40e: separate PF and VSI state flagsQuoted 20 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 05/10] i40e: separate PF and VSI state flagsFrom: Jacob Keller <[email protected]>
Avoid using the same named flags for both
vsi->stateandpf->state. This makes code review easier, as it is more likely that future authors will use the correct state field when checking bits. Previous commits already found issues with at least one check, and possibly others may be incorrect.This reduces confusion as it is more clear what each flag represents, and which flags are valid for which state field.
Signed-off-by Jacob Keller <[email protected]>Quoted 11 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 12 ++- drivers/net/ethernet/intel/i40e/i40e_client.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 104 ++++++++++++--------- --- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40evf.h | 7 +- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 10 +-- 8 files changed, 83 insertions(+), 74 deletions(-)
Quoted 3 lines
Tested-by Andrew Bowers <[email protected]>
This patch is incorrect. I will send a v2, and I will try to make it fit within the same place in the current dev-queue as it does now.
Thanks,
Jake
PATCH 6/10 i40e: use DECLARE_BITMAP for state fields
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Instead of assuming our flags fit within an unsigned long, use DECLARE_BITMAP which will ensure that we always allocate enough space. Additionally, use __I40E_STATE_SIZE__ markers as the last element of the enumeration so that the size of the BITMAP is compile-time assigned rather than programmer-time assigned. This ensures that potential future flag additions do not actually overrun the array. This is especially important as 32bit systems would only have 32bit longs instead of 64bit longs as we generally have assumed in the prior code.
This change also removes a dereference of the state fields throughout the code, so it does have a bit of code churn. The conversions were automated using sed replacements with an alternation
s/&(vsi->back|vsi|pf)->state/\1->state/
s/&adapter->vsi.state/adapter->vsi.state/
For debugfs, we modify the printing so that we can display chunks of the state value on new lines. This ensures that we can print the entire set of state values. Additionally, we now print them as 08lx to ensure that they display nicely.
--- drivers/net/ethernet/intel/i40e/i40e.h | 8 +- drivers/net/ethernet/intel/i40e/i40e_client.c | 16 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 13 +- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 42 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 231 ++++++++++----------- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 14 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 18 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40evf.h | 4 +- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 10 +- 11 files changed, 188 insertions(+), 180 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +6 -2
@@ -145,6 +145,8 @@ enum i40e_state_t { __I40E_RESET_FAILED, __I40E_PORT_SUSPENDED, __I40E_VF_DISABLE, +/* This must be last as it determines the size of the BITMAP */ + __I40E_STATE_SIZE__, };/* VSI state flags */
@@ -155,6 +157,8 @@ enum i40e_vsi_state_t { __I40E_VSI_OVERFLOW_PROMISC, __I40E_VSI_REINIT_REQUESTED, __I40E_VSI_DOWN_REQUESTED, +/* This must be last as it determines the size of the BITMAP */ + __I40E_VSI_STATE_SIZE__, }; enum i40e_interrupt_policy {
@@ -330,7 +334,7 @@ struct i40e_flex_pit {struct i40e_pf {struct pci_dev *pdev;struct i40e_hw hw; -unsigned long state; + DECLARE_BITMAP(state, __I40E_STATE_SIZE__);struct msix_entry *msix_entries;bool fc_autoneg_status;
@@ -601,7 +605,7 @@ struct i40e_vsi {bool stat_offsets_loaded;u32 current_netdev_flags; -unsigned long state; +DECLARE_BITMAP (state, __I40E_VSI_STATE_SIZE__);#define I40E_VSI_FLAG_FILTER_CHANGED BIT(0)#define I40E_VSI_FLAG_VEB_OWNER BIT(1)unsigned long flags;
drivers/net/ethernet/intel/i40e/i40e_client.c +8 -8
@@ -371,8 +371,8 @@ void i40e_client_subtask(struct i40e_pf *pf) cdev = pf->cinst;/* If we're down or resetting, just bail */ -if (test_bit (__I40E_DOWN, &pf->state) || -test_bit (__I40E_CONFIG_BUSY, &pf->state)) +if (test_bit (__I40E_DOWN, pf->state) || +test_bit (__I40E_CONFIG_BUSY, pf->state))return ;if (!client || !cdev)
@@ -382,7 +382,7 @@ void i40e_client_subtask(struct i40e_pf *pf)* the netdev is up, then open the client. */ if (!test_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) { -if (!test_bit (__I40E_VSI_DOWN, &vsi->state) && +if (!test_bit (__I40E_VSI_DOWN, vsi->state) && client->ops && client->ops->open) {set_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state); ret = client->ops->open (&cdev->lan_info, client);
@@ -397,7 +397,7 @@ void i40e_client_subtask(struct i40e_pf *pf)/* Likewise for client close. If the client is up, but the netdev * is down, then close the client. */ -if (test_bit (__I40E_VSI_DOWN, &vsi->state) && +if (test_bit (__I40E_VSI_DOWN, vsi->state) && client->ops && client->ops->close) {clear_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state); client->ops->close (&cdev->lan_info, client, false);
@@ -503,7 +503,7 @@ static void i40e_client_release(struct i40e_client *client)continue ;while (test_and_set_bit (__I40E_SERVICE_SCHED, - &pf->state)) + pf->state))usleep_range (500 ,1000 );if (test_bit (__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
@@ -521,7 +521,7 @@ static void i40e_client_release(struct i40e_client *client)i40e_client_del_instance (pf);dev_info (&pf->pdev->dev,"Deleted client instance of Client %s\n" , client->name); -clear_bit (__I40E_SERVICE_SCHED, &pf->state); +clear_bit (__I40E_SERVICE_SCHED, pf->state); }mutex_unlock (&i40e_device_mutex); }
@@ -661,10 +661,10 @@ static void i40e_client_request_reset(struct i40e_info *ldev,switch (reset_level) {case I40E_CLIENT_RESET_LEVEL_PF : -set_bit (__I40E_PF_RESET_REQUESTED, &pf->state); +set_bit (__I40E_PF_RESET_REQUESTED, pf->state);break ;case I40E_CLIENT_RESET_LEVEL_CORE : -set_bit (__I40E_PF_RESET_REQUESTED, &pf->state); +set_bit (__I40E_PF_RESET_REQUESTED, pf->state);break ;default : dev_warn(&pf->pdev->dev,
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +8 -5
@@ -158,9 +158,12 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)dev_info (&pf->pdev->dev," vlgrp: & = %p\n" , vsi->active_vlans);dev_info (&pf->pdev->dev, -" state = %li flags = 0x%08lx, netdev_registered = %i, current_netdev_flags = 0x%04x\n" , - vsi->state, vsi->flags, - vsi->netdev_registered, vsi->current_netdev_flags); +" flags = 0x%08lx, netdev_registered = %i, current_netdev_flags = 0x%04x\n" , + vsi->flags, vsi->netdev_registered, vsi->current_netdev_flags); +for (i =0 ; i <BITS_TO_LONGS (__I40E_VSI_STATE_SIZE__); i++) +dev_info (&pf->pdev->dev, +" state[%d] = %08lx\n" , + i, vsi->state[i]);if (vsi == pf->vsi[pf->lan_vsi]) dev_info(&pf->pdev->dev, " MAC address: %pM SAN MAC: %pM Port MAC: %pM\n", pf->hw.mac.addr,
@@ -174,7 +177,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid) }dev_info (&pf->pdev->dev," active_filters %u, promisc_threshold %u, overflow promisc %s\n" , vsi->active_filters, vsi->promisc_threshold, - (test_bit (__I40E_VSI_OVERFLOW_PROMISC, &vsi->state) ? + (test_bit (__I40E_VSI_OVERFLOW_PROMISC, vsi->state) ?"ON" :"OFF" )); nstat =i40e_get_vsi_stats_struct (vsi); dev_info(&pf->pdev->dev,
@@ -1706,7 +1709,7 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp, }else if (!vsi->netdev) {dev_info (&pf->pdev->dev,"tx_timeout: no netdev for VSI %d\n" , vsi_seid); - }else if (test_bit (__I40E_VSI_DOWN, &vsi->state)) { + }else if (test_bit (__I40E_VSI_DOWN, vsi->state)) {dev_info (&pf->pdev->dev,"tx_timeout: VSI %d not UP\n" , vsi_seid); }else if (rtnl_trylock ()) {
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +21 -21
132 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_main.c +115 -116
725 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_ptp.c +2 -2
@@ -358,7 +358,7 @@ void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf)skb_tstamp_tx (pf->ptp_tx_skb, &shhwtstamps);dev_kfree_skb_any (pf->ptp_tx_skb); pf->ptp_tx_skb =NULL ; -clear_bit_unlock (__I40E_PTP_TX_IN_PROGRESS, &pf->state); +clear_bit_unlock (__I40E_PTP_TX_IN_PROGRESS, pf->state); }/**
@@ -768,7 +768,7 @@ void i40e_ptp_stop(struct i40e_pf *pf)if (pf->ptp_tx_skb) {dev_kfree_skb_any (pf->ptp_tx_skb); pf->ptp_tx_skb =NULL ; -clear_bit_unlock (__I40E_PTP_TX_IN_PROGRESS, &pf->state); +clear_bit_unlock (__I40E_PTP_TX_IN_PROGRESS, pf->state); }if (pf->ptp_clock) {
drivers/net/ethernet/intel/i40e/i40e_txrx.c +7 -7
@@ -589,7 +589,7 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring,* progress do nothing, once flush is complete the state will * be cleared. */ -if (test_bit (__I40E_FD_FLUSH_REQUESTED, &pf->state)) +if (test_bit (__I40E_FD_FLUSH_REQUESTED, pf->state))return ; pf->fd_add_err++;
@@ -599,7 +599,7 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring,if ((rx_desc->wb.qword0.hi_dword.fd_id ==0 ) && (pf->hw_disabled_flags &I40E_FLAG_FD_SB_ENABLED )) { pf->hw_disabled_flags |=I40E_FLAG_FD_ATR_ENABLED ; -set_bit (__I40E_FD_FLUSH_REQUESTED, &pf->state); +set_bit (__I40E_FD_FLUSH_REQUESTED, pf->state); }/* filter programming failed most likely due to table full */
@@ -850,7 +850,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,if (budget && ((j /WB_STRIDE ) ==0 ) && (j >0 ) && - !test_bit (__I40E_VSI_DOWN, &vsi->state) && + !test_bit (__I40E_VSI_DOWN, vsi->state) && (I40E_DESC_UNUSED (tx_ring) != tx_ring->count)) tx_ring->arm_wb = true; }
@@ -868,7 +868,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,smp_mb ();if (__netif_subqueue_stopped (tx_ring->netdev, tx_ring->queue_index) && - !test_bit (__I40E_VSI_DOWN, &vsi->state)) { + !test_bit (__I40E_VSI_DOWN, vsi->state)) {netif_wake_subqueue (tx_ring->netdev, tx_ring->queue_index); ++tx_ring->tx_stats.restart_queue;
@@ -2178,7 +2178,7 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi, } enable_int: -if (!test_bit (__I40E_VSI_DOWN, &vsi->state)) +if (!test_bit (__I40E_VSI_DOWN, vsi->state))wr32 (hw,INTREG (vector -1 ), txval);if (q_vector->itr_countdown)
@@ -2207,7 +2207,7 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)int budget_per_ring;int work_done =0 ; -if (test_bit (__I40E_VSI_DOWN, &vsi->state)) { +if (test_bit (__I40E_VSI_DOWN, vsi->state)) {napi_complete (napi);return 0 ; }
@@ -2633,7 +2633,7 @@ static int i40e_tsyn(struct i40e_ring *tx_ring, struct sk_buff *skb,return 0 ;if (pf->ptp_tx && - !test_and_set_bit_lock (__I40E_PTP_TX_IN_PROGRESS, &pf->state)) { + !test_and_set_bit_lock (__I40E_PTP_TX_IN_PROGRESS, pf->state)) {skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; pf->ptp_tx_skb =skb_get (skb); }else {
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +9 -9
@@ -1036,7 +1036,7 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)int i;/* If VFs have been disabled, there is no need to reset */ -if (test_and_set_bit (__I40E_VF_DISABLE, &pf->state)) +if (test_and_set_bit (__I40E_VF_DISABLE, pf->state))return ;i40e_trigger_vf_reset (vf, flr);
@@ -1073,7 +1073,7 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)i40e_cleanup_reset_vf (vf);i40e_flush (hw); -clear_bit (__I40E_VF_DISABLE, &pf->state); +clear_bit (__I40E_VF_DISABLE, pf->state); }/**
@@ -1098,7 +1098,7 @@ void i40e_reset_all_vfs(struct i40e_pf *pf, bool flr)return ;/* If VFs have been disabled, there is no need to reset */ -if (test_and_set_bit (__I40E_VF_DISABLE, &pf->state)) +if (test_and_set_bit (__I40E_VF_DISABLE, pf->state))return ;/* Begin reset on all VFs at once */
@@ -1173,7 +1173,7 @@ void i40e_reset_all_vfs(struct i40e_pf *pf, bool flr)i40e_cleanup_reset_vf (&pf->vf[v]);i40e_flush (hw); -clear_bit (__I40E_VF_DISABLE, &pf->state); +clear_bit (__I40E_VF_DISABLE, pf->state); }/**
@@ -1190,7 +1190,7 @@ void i40e_free_vfs(struct i40e_pf *pf)if (!pf->vf)return ; -while (test_and_set_bit (__I40E_VF_DISABLE, &pf->state)) +while (test_and_set_bit (__I40E_VF_DISABLE, pf->state))usleep_range (1000 ,2000 );i40e_notify_client_of_vf_enable (pf,0 );
@@ -1246,7 +1246,7 @@ void i40e_free_vfs(struct i40e_pf *pf)wr32 (hw,I40E_GLGEN_VFLRSTAT (reg_idx),BIT (bit_idx)); } } -clear_bit (__I40E_VF_DISABLE, &pf->state); +clear_bit (__I40E_VF_DISABLE, pf->state); }#ifdef CONFIG_PCI_IOV
@@ -1326,7 +1326,7 @@ static int i40e_pci_sriov_enable(struct pci_dev *pdev, int num_vfs)int pre_existing_vfs =pci_num_vf (pdev);int err =0 ; -if (test_bit (__I40E_TESTING, &pf->state)) { +if (test_bit (__I40E_TESTING, pf->state)) {dev_warn (&pdev->dev,"Cannot enable SR-IOV virtual functions while the device is undergoing diagnostic testing\n" ); err = -EPERM ;
@@ -2818,7 +2818,7 @@ int i40e_vc_process_vflr_event(struct i40e_pf *pf)struct i40e_vf *vf;int vf_id; -if (!test_bit (__I40E_VFLR_EVENT_PENDING, &pf->state)) +if (!test_bit (__I40E_VFLR_EVENT_PENDING, pf->state))return 0 ;/* Re-enable the VFLR interrupt cause here, before looking for which
@@ -2831,7 +2831,7 @@ int i40e_vc_process_vflr_event(struct i40e_pf *pf)wr32 (hw,I40E_PFINT_ICR0_ENA , reg);i40e_flush (hw); -clear_bit (__I40E_VFLR_EVENT_PENDING, &pf->state); +clear_bit (__I40E_VFLR_EVENT_PENDING, pf->state);for (vf_id =0 ; vf_id < pf->num_alloc_vfs; vf_id++) { reg_idx = (hw->func_caps.vf_base_id + vf_id) /32 ; bit_idx = (hw->func_caps.vf_base_id + vf_id) %32 ;
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +4 -4
@@ -266,7 +266,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,if (budget && ((j /WB_STRIDE ) ==0 ) && (j >0 ) && - !test_bit (__I40E_VSI_DOWN, &vsi->state) && + !test_bit (__I40E_VSI_DOWN, vsi->state) && (I40E_DESC_UNUSED (tx_ring) != tx_ring->count)) tx_ring->arm_wb = true; }
@@ -284,7 +284,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,smp_mb ();if (__netif_subqueue_stopped (tx_ring->netdev, tx_ring->queue_index) && - !test_bit (__I40E_VSI_DOWN, &vsi->state)) { + !test_bit (__I40E_VSI_DOWN, vsi->state)) {netif_wake_subqueue (tx_ring->netdev, tx_ring->queue_index); ++tx_ring->tx_stats.restart_queue;
@@ -1508,7 +1508,7 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi, } enable_int: -if (!test_bit (__I40E_VSI_DOWN, &vsi->state)) +if (!test_bit (__I40E_VSI_DOWN, vsi->state))wr32 (hw,INTREG (vector -1 ), txval);if (q_vector->itr_countdown)
@@ -1537,7 +1537,7 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)int budget_per_ring;int work_done =0 ; -if (test_bit (__I40E_VSI_DOWN, &vsi->state)) { +if (test_bit (__I40E_VSI_DOWN, vsi->state)) {napi_complete (napi);return 0 ; }
drivers/net/ethernet/intel/i40evf/i40evf.h +3 -1
@@ -52,6 +52,8 @@/* VSI state flags shared with common code */ enum i40evf_vsi_state_t { __I40E_VSI_DOWN, +/* This must be last as it determines the size of the BITMAP */ + __I40E_VSI_STATE_SIZE__, };/* dummy struct to make common code less painful */
@@ -61,7 +63,7 @@ struct i40e_vsi {unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];u16 seid;u16 id; -unsigned long state; +DECLARE_BITMAP (state, __I40E_VSI_STATE_SIZE__);int base_vector;u16 work_limit;u16 qs_handle;
drivers/net/ethernet/intel/i40evf/i40evf_main.c +5 -5
@@ -497,7 +497,7 @@ static void i40evf_netpoll(struct net_device *netdev)int i;/* if interface is down do nothing */ -if (test_bit (__I40E_VSI_DOWN, &adapter->vsi.state)) +if (test_bit (__I40E_VSI_DOWN, adapter->vsi.state))return ;for (i =0 ; i < q_vectors; i++)
@@ -1087,7 +1087,7 @@ static void i40evf_configure(struct i40evf_adapter *adapter)static void i40evf_up_complete (struct i40evf_adapter *adapter) { adapter->state = __I40EVF_RUNNING; -clear_bit (__I40E_VSI_DOWN, &adapter->vsi.state); +clear_bit (__I40E_VSI_DOWN, adapter->vsi.state);i40evf_napi_enable_all (adapter);
@@ -1753,7 +1753,7 @@ static void i40evf_disable_vf(struct i40evf_adapter *adapter) adapter->flags |=I40EVF_FLAG_PF_COMMS_FAILED ;if (netif_running (adapter->netdev)) { -set_bit (__I40E_VSI_DOWN, &adapter->vsi.state); +set_bit (__I40E_VSI_DOWN, adapter->vsi.state);netif_carrier_off (adapter->netdev);netif_tx_disable (adapter->netdev); adapter->link_up = false;
@@ -2233,7 +2233,7 @@ static int i40evf_close(struct net_device *netdev)return 0 ; -set_bit (__I40E_VSI_DOWN, &adapter->vsi.state); +set_bit (__I40E_VSI_DOWN, adapter->vsi.state);if (CLIENT_ENABLED (adapter)) adapter->flags |=I40EVF_FLAG_CLIENT_NEEDS_CLOSE ;
@@ -2674,7 +2674,7 @@ static void i40evf_init_task(struct work_struct *work)dev_info (&pdev->dev,"GRO is enabled\n" ); adapter->state = __I40EVF_DOWN; -set_bit (__I40E_VSI_DOWN, &adapter->vsi.state); +set_bit (__I40E_VSI_DOWN, adapter->vsi.state);i40evf_misc_irq_enable (adapter); adapter->rss_key =kzalloc (adapter->rss_key_size,GFP_KERNEL );
Signature · 1 line
2.9.3
Bowers
PATCH 6/10 i40e: use DECLARE_BITMAP for state fields
Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 06/10] i40e: useDECLARE_BITMAPfor state fieldsFrom: Jacob Keller <[email protected]>
Instead of assuming our flags fit within an unsigned long, use
DECLARE_BITMAPwhich will ensure that we always allocate enough space. Additionally, use__I40E_STATE_SIZE__markers as the last element of the enumeration so that the size of the BITMAP is compile-time assigned rather than programmer-time assigned. This ensures that potential future flag additions do not actually overrun the array. This is especially important as 32bit systems would only have 32bit longs instead of 64bit longs as we generally have assumed in the prior code.This change also removes a dereference of the state fields throughout the code, so it does have a bit of code churn. The conversions were automated using sed replacements with an alternation
s/&(vsi->back|vsi|pf)->state/\1->state/
s/&adapter->vsi.state/adapter->vsi.state/For debugfs, we modify the printing so that we can display chunks of the state value on new lines. This ensures that we can print the entire set of state values. Additionally, we now print them as 08lx to ensure that they display nicely.
Signed-off-by Jacob Keller <[email protected]>
Quoted 13 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 8 +- drivers/net/ethernet/intel/i40e/i40e_client.c | 16 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 13 +- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 42 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 231 ++++++++++----------- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 14 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 18 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 8 +- drivers/net/ethernet/intel/i40evf/i40evf.h | 4 +- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 10 +- 11 files changed, 188 insertions(+), 180 deletions(-)
PATCH 7/10 i40evf: remove needless min_t() on num_online_cpus()*2
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
We already set pairs to the value of adapter->num_active_queues. This value is limited by vsi_res->num_queue_pairs and num_online_cpus(). This means that pairs by definition is already smaller than num_online_cpus()*2, so we don't even need to bother with this check.
Lets just remove it and update the comment.
--- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40evf/i40evf_main.c +6 -6
@@ -1271,13 +1271,13 @@ static int i40evf_set_interrupt_capability(struct i40evf_adapter *adapter) } pairs = adapter->num_active_queues; -/* It's easy to be greedy for MSI-X vectors, but it really -* doesn't do us much good if we have a lot more vectors -* than CPU's. So let's be conservative and only ask for -* (roughly) twice the number of vectors as there are CPU's. +/* It's easy to be greedy for MSI-X vectors, but it really doesn't do +* us much good if we have more vectors than CPUs. However, we already +* limit the total number of queues by the number of CPUs so we do not +* need any further limiting here. */ - v_budget =min_t (int, pairs, (int )(num_online_cpus () *2 )) +NONQ_VECS ; - v_budget =min_t (int, v_budget, (int )adapter->vf_res->max_vectors); + v_budget =min_t (int, pairs +NONQ_VECS , + (int )adapter->vf_res->max_vectors); adapter->msix_entries =kcalloc (v_budget,sizeof (struct msix_entry ),GFP_KERNEL );
Signature · 1 line
2.9.3
Bowers
PATCH 7/10 i40evf: remove needless min_t() on num_online_cpus()*2
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 07/10] i40evf: remove needlessmin_t()on num_online_cpus()*2From: Jacob Keller <[email protected]>
We already set pairs to the value of
adapter->num_active_queues. This value is limited byvsi_res->num_queue_pairsandnum_online_cpus(). This means that pairs by definition is already smaller than num_online_cpus()*2, so we don't even need to bother with this check.
Quoted 6 lines
Lets just remove it and update the comment.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
PATCH 8/10 i40e: remove hw_disabled_flags in favor of using separate flag bits
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The hw_disabled_flags field was added as a way of signifying that a feature was automatically or temporarily disabled. However, we actually only use this for FDir features. Replace its use with new _AUTO_DISABLED flags instead. This is more readable, because you aren't setting an *_ENABLED flag to *disable* the feature.
Additionally, clean up a few areas where we used these bits. First, we don't really need to set the auto-disable flag for ATR if we're fully disabling the feature via ethtool.
Second, we should always clear the auto-disable bits incase they somehow got set when the feature was disabled. However, avoid displaying a message that we've re-enabled the feature.
Third, we shouldn't be re-enabling ATR in the SB ntuple add flow, because it might have been disabled due to space constraints. Instead, we should just wait for the fdir_check_and_reenable to be called by the watchdog.
Overall, this change allows us to simplify some code by removing an extra field we didn't need, and the result should make it more clear as to what we're actually doing with these flags.
--- drivers/net/ethernet/intel/i40e/i40e.h | 9 +---- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 6 +-- drivers/net/ethernet/intel/i40e/i40e_main.c | 53 +++++++++++++------------- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 22 ++++------- 4 files changed, 38 insertions(+), 52 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -7
@@ -408,6 +408,8 @@ struct i40e_pf {#define I40E_FLAG_DCB_ENABLED BIT_ULL(20)#define I40E_FLAG_FD_SB_ENABLED BIT_ULL(21)#define I40E_FLAG_FD_ATR_ENABLED BIT_ULL(22) +#define I40E_FLAG_FD_SB_AUTO_DISABLED BIT_ULL(23) +#define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT_ULL(24)#define I40E_FLAG_PTP BIT_ULL(25)#define I40E_FLAG_MFP_ENABLED BIT_ULL(26)#define I40E_FLAG_UDP_FILTER_SYNC BIT_ULL(27)
@@ -440,13 +442,6 @@ struct i40e_pf {#define I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(57)#define I40E_FLAG_LEGACY_RX BIT_ULL(58) -/* Tracks features that are disabled due to hw limitations. -* If a bit is set here, it means that the corresponding -* bit in the 'flags' field is cleared i.e that feature -* is disabled -*/ -u64 hw_disabled_flags; -struct i40e_client_instance *cinst;bool stat_offsets_loaded;struct i40e_hw_port_stats stats;
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +3 -3
@@ -3643,7 +3643,7 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,if (!(pf->flags &I40E_FLAG_FD_SB_ENABLED ))return -EOPNOTSUPP ; -if (pf->hw_disabled_flags &I40E_FLAG_FD_SB_ENABLED ) +if (pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED )return -ENOSPC ; if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
@@ -4086,12 +4086,12 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)/* Flush current ATR settings if ATR was disabled */ if ((changed_flags &I40E_FLAG_FD_ATR_ENABLED ) && !(pf->flags &I40E_FLAG_FD_ATR_ENABLED )) { - pf->hw_disabled_flags |=I40E_FLAG_FD_ATR_ENABLED ; + pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ;set_bit (__I40E_FD_FLUSH_REQUESTED, pf->state); }/* Only allow ATR evict on hardware that is capable of handling it */ -if (pf->hw_disabled_flags &I40E_FLAG_HW_ATR_EVICT_CAPABLE ) +if (pf->flags &I40E_FLAG_HW_ATR_EVICT_CAPABLE ) pf->flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE ;if (changed_flags &I40E_FLAG_TRUE_PROMISC_SUPPORT ) {
drivers/net/ethernet/intel/i40e/i40e_main.c +26 -27
109 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.c +7 -15
@@ -333,15 +333,9 @@ static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) &&I40E_DEBUG_FD & pf->hw.debug_mask)dev_info (&pf->pdev->dev,"Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n" ); - pf->hw_disabled_flags |=I40E_FLAG_FD_ATR_ENABLED ; + pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ; }else { pf->fd_tcp4_filter_cnt--; -if (pf->fd_tcp4_filter_cnt ==0 ) { -if ((pf->flags &I40E_FLAG_FD_ATR_ENABLED ) && -I40E_DEBUG_FD & pf->hw.debug_mask) -dev_info (&pf->pdev->dev,"ATR re-enabled due to no sideband TCP/IPv4 rules\n" ); - pf->hw_disabled_flags &= ~I40E_FLAG_FD_ATR_ENABLED ; - } }return 0 ;
@@ -597,8 +591,8 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring, pf->fd_atr_cnt =i40e_get_current_atr_cnt (pf);if ((rx_desc->wb.qword0.hi_dword.fd_id ==0 ) && - (pf->hw_disabled_flags &I40E_FLAG_FD_SB_ENABLED )) { - pf->hw_disabled_flags |=I40E_FLAG_FD_ATR_ENABLED ; + pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED ) { + pf->flags |=I40E_FLAG_FD_ATR_AUTO_DISABLED ;set_bit (__I40E_FD_FLUSH_REQUESTED, pf->state); }
@@ -611,12 +605,10 @@ static void i40e_fd_handle_status(struct i40e_ring *rx_ring,*/ if (fcnt_prog >= (fcnt_avail -I40E_FDIR_BUFFER_FULL_MARGIN )) {if ((pf->flags &I40E_FLAG_FD_SB_ENABLED ) && - !(pf->hw_disabled_flags & -I40E_FLAG_FD_SB_ENABLED )) { + !(pf->flags &I40E_FLAG_FD_SB_AUTO_DISABLED )) { + pf->flags |=I40E_FLAG_FD_SB_AUTO_DISABLED ;if (I40E_DEBUG_FD & pf->hw.debug_mask)dev_warn (&pdev->dev,"FD filter space full, new ntuple rules will not be added\n" ); - pf->hw_disabled_flags |= -I40E_FLAG_FD_SB_ENABLED ; } } }else if (error ==BIT (I40E_RX_PROG_STATUS_DESC_NO_FD_ENTRY_SHIFT )) {
@@ -2311,7 +2303,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,if (!(pf->flags &I40E_FLAG_FD_ATR_ENABLED ))return ; -if ((pf->hw_disabled_flags &I40E_FLAG_FD_ATR_ENABLED )) +if (pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED )return ;/* if sampling is disabled do nothing */
@@ -2345,7 +2337,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb, th = (struct tcphdr *)(hdr.network + hlen);/* Due to lack of space, no more new filters can be programmed */ -if (th->syn && (pf->hw_disabled_flags &I40E_FLAG_FD_ATR_ENABLED )) +if (th->syn && (pf->flags &I40E_FLAG_FD_ATR_AUTO_DISABLED ))return ;if (pf->flags &I40E_FLAG_HW_ATR_EVICT_CAPABLE ) {/* HW ATR eviction will take care of removing filters on FIN
Signature · 1 line
2.9.3
PATCH 9/10 i40evf: remove I40E_FLAG_FDIR_ATR_ENABLED
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The flag used by the common code and PF code is I40E_FLAG_FD_ATR_ENABLED, not *FDIR*. It turns out none of the txrx code actually shared with the VF driver actually checks the ATR flag. This is made even more obvious by the typo in the VF header file.
Let's just remove the flag from the VF driver since it's not needed.
--- drivers/net/ethernet/intel/i40evf/i40evf.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/intel/i40evf/i40evf.h +0 -1
@@ -223,7 +223,6 @@ struct i40evf_adapter {#define I40EVF_FLAG_ALLMULTI_ON BIT(19)#define I40EVF_FLAG_LEGACY_RX BIT(20)/* duplicates for common code */ -#define I40E_FLAG_FDIR_ATR_ENABLED 0#define I40E_FLAG_DCB_ENABLED 0#define I40E_FLAG_RX_CSUM_ENABLED I40EVF_FLAG_RX_CSUM_ENABLED#define I40E_FLAG_WB_ON_ITR_CAPABLE I40EVF_FLAG_WB_ON_ITR_CAPABLE
Signature · 1 line
2.9.3
Bowers
PATCH 9/10 i40evf: remove I40E_FLAG_FDIR_ATR_ENABLED
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 09/10] i40evf: removeI40E_FLAG_FDIR_ATR_ENABLEDFrom: Jacob Keller <[email protected]>
The flag used by the common code and PF code is
I40E_FLAG_FD_ATR_ENABLED, not *FDIR*. It turns out none of the txrx code actually shared with the VF driver actually checks the ATR flag. This is made even more obvious by the typo in the VF header file.
Quoted 6 lines
Let's just remove the flag from the VF driver since it's not needed.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40evf/i40evf.h | 1 - 1 file changed, 1 deletion(-)
PATCH 10/10 i40evf: allocate queues before we setup the interrupts and q_vectors
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
This matches the ordering of how we free stuff during reset and remove. It also makes logical sense because we set the interrupts based on the number of queues. Currently this doesn't really matter in practice. However a future patch moves the assignment of num_active_queues into i40evf_alloc_queues, which is required by i40evf_set_interrupt_capability.
--- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/i40evf/i40evf_main.c +9 -9
@@ -1508,6 +1508,13 @@ int i40evf_init_interrupt_scheme(struct i40evf_adapter *adapter) {int err; + err =i40evf_alloc_queues (adapter); +if (err) { +dev_err (&adapter->pdev->dev, +"Unable to allocate memory for queues\n" ); + goto err_alloc_queues; + } +rtnl_lock (); err =i40evf_set_interrupt_capability (adapter);rtnl_unlock ();
@@ -1524,23 +1531,16 @@ int i40evf_init_interrupt_scheme(struct i40evf_adapter *adapter) goto err_alloc_q_vectors; } - err =i40evf_alloc_queues (adapter); -if (err) { -dev_err (&adapter->pdev->dev, -"Unable to allocate memory for queues\n" ); - goto err_alloc_queues; - } -dev_info (&adapter->pdev->dev,"Multiqueue %s: Queue pair count = %u" , (adapter->num_active_queues >1 ) ?"Enabled" :"Disabled" , adapter->num_active_queues);return 0 ; -err_alloc_queues: -i40evf_free_q_vectors (adapter); err_alloc_q_vectors:i40evf_reset_interrupt_capability (adapter); err_set_interrupt: +i40evf_free_queues (adapter); +err_alloc_queues:return err; }
Signature · 1 line
2.9.3
Bowers
PATCH 10/10 i40evf: allocate queues before we setup the interrupts and q_vectors
Quoted 17 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 10/10] i40evf: allocate queues before we setup the interrupts andq_vectorsFrom: Jacob Keller <[email protected]>
This matches the ordering of how we free stuff during reset and remove. It also makes logical sense because we set the interrupts based on the number of queues. Currently this doesn't really matter in practice. However a future patch moves the assignment of
num_active_queuesintoi40evf_alloc_queues, which is required byi40evf_set_interrupt_capability.
Quoted 4 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
Bowers
PATCH 1/10 i40e: rename index to port to avoid confusion
In reply to Alice MichaelQuoted 11 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alice Michael
Sent: Wednesday, April 19, 2017 6:26 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S71 01/10] i40e: rename index to port to avoid confusionFrom: Jacob Keller <[email protected]>
Quoted 8 lines
The .index field of
i40e_udp_port_configrepresents the udp port number. Rename this variable to port so that it is more obvious.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)