Skip to contentSkip to conversation

Intel Wired LAN Driver Updates for 2023-10-23 (iavf)

PATCH In review Jacob Keller 3 participants 19 messages Oct 23, 2023 – Oct 27, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Intel Wired LAN Driver Updates for 2023-10-23 (iavf)

This series includes iAVF driver cleanups from Michal Schmidt.

Michal removes and updates stale comments, fixes some locking anti-patterns, improves handling of resets when the PF is slow, avoids unnecessary duplication of netdev state, refactors away some duplicate code, and finally removes the never-actually-used client interface.

Michal Schmidt (9):
iavf: fix comments about old bit locks
iavf: simplify mutex_trylock+sleep loops
iavf: in iavf_down, don't queue watchdog_task if comms failed
iavf: in iavf_down, disable queues when removing the driver
iavf: fix the waiting time for initial reset
iavf: rely on netdev's own registered state
iavf: use unregister_netdev
iavf: add a common function for undoing the interrupt scheme
iavf: delete the iavf client interface

 drivers/net/ethernet/intel/iavf/Makefile      |   2 +-
 drivers/net/ethernet/intel/iavf/iavf.h        |  28 -
 drivers/net/ethernet/intel/iavf/iavf_client.c | 578 ------------------
 drivers/net/ethernet/intel/iavf/iavf_client.h | 169 -----
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 139 +----
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  14 -
 6 files changed, 29 insertions(+), 901 deletions(-)
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.c
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.h

base-commit: d6e48462e88fe7efc78b455ecde5b0ca43ec50b7

Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/9 iavf: fix comments about old bit locks

From: Michal Schmidt <[email protected]>

Bit lock __IAVF_IN_CRITICAL_TASK does not exist anymore since commit 5ac49f3c2702 ("iavf: use mutexes for locking of critical sections"). Adjust the comments accordingly.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
index 7fb7dfe6e13f..8bfa928ab415 100644
@@ -1276,7 +1276,7 @@ static void iavf_configure(struct iavf_adapter *adapter)
  * iavf_up_complete - Finish the last steps of bringing up a connection
  * @adapter: board private structure
  *
- * Expects to be called while holding the __IAVF_IN_CRITICAL_TASK bit lock.
+ * Expects to be called while holding crit_lock.
  **/
 static void iavf_up_complete(struct iavf_adapter *adapter)
 {
@@ -1400,7 +1400,7 @@ static void iavf_clear_adv_rss_conf(struct iavf_adapter *adapter)
  * iavf_down - Shutdown the connection processing
  * @adapter: board private structure
  *
- * Expects to be called while holding the __IAVF_IN_CRITICAL_TASK bit lock.
+ * Expects to be called while holding crit_lock.
  **/
 void iavf_down(struct iavf_adapter *adapter)
 {
Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/9 iavf: simplify mutex_trylock+sleep loops

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

This pattern appears in two places in the iavf source code:
while (!mutex_trylock(...))

      usleep_range(...);

That's just mutex_lock with extra steps.
The pattern is a leftover from when iavf used bit flags instead of mutexes for locking. Commit 5ac49f3c2702 ("iavf: use mutexes for locking of critical sections") replaced test_and_set_bit with !mutex_trylock, preserving the pattern.

Simplify it to mutex_lock.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -4
index 8bfa928ab415..da9cd53afc24 100644
@@ -3011,8 +3011,7 @@ static void iavf_reset_task(struct work_struct *work)
 		return;
 	}
 
-	while (!mutex_trylock(&adapter->client_lock))
-		usleep_range(500, 1000);
+	mutex_lock(&adapter->client_lock);
 	if (CLIENT_ENABLED(adapter)) {
 		adapter->flags &= ~(IAVF_FLAG_CLIENT_NEEDS_OPEN |
 				    IAVF_FLAG_CLIENT_NEEDS_CLOSE |
@@ -5064,8 +5063,7 @@ static int __maybe_unused iavf_suspend(struct device *dev_d)
 
 	netif_device_detach(netdev);
 
-	while (!mutex_trylock(&adapter->crit_lock))
-		usleep_range(500, 1000);
+	mutex_lock(&adapter->crit_lock);
 
 	if (netif_running(netdev)) {
 		rtnl_lock();
Signature · 1 line
2.41.0
#3 lore raw

PATCH 3/9 iavf: in iavf_down, don't queue watchdog_task if comms failed

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

The reason for queueing watchdog_task is to have it process the aq_required flags that are being set here. If comms failed, there's nothing to do, so return early.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +4 -2
index da9cd53afc24..b30d703e26a1 100644
@@ -1420,8 +1420,10 @@ void iavf_down(struct iavf_adapter *adapter)
 	iavf_clear_fdir_filters(adapter);
 	iavf_clear_adv_rss_conf(adapter);
 
-	if (!(adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) &&
-	    !(test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))) {
+	if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
+		return;
+
+	if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
 		/* cancel any current operation */
 		adapter->current_op = VIRTCHNL_OP_UNKNOWN;
 		/* Schedule operations to close down the HW. Don't wait
Signature · 1 line
2.41.0
#4 lore raw

PATCH 1/1 iavf: delete the iavf client interface

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

The iavf client interface was added in 2017 by commit ed0e894de7c1 ("i40evf: add client interface"), but there have never been any in-tree callers.

It's not useful for future development either. The Intel out-of-tree iavf and irdma drivers instead use an auxiliary bus, which is a better solution.

Remove the iavf client interface code. Also gone are the client_task work and the client_lock mutex.

---
 drivers/net/ethernet/intel/iavf/Makefile      |   2 +-
 drivers/net/ethernet/intel/iavf/iavf.h        |  27 -
 drivers/net/ethernet/intel/iavf/iavf_client.c | 578 ------------------
 drivers/net/ethernet/intel/iavf/iavf_client.h | 169 -----
 drivers/net/ethernet/intel/iavf/iavf_main.c   |  82 ---
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  14 -
 6 files changed, 1 insertion(+), 871 deletions(-)
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.c
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.h
drivers/net/ethernet/intel/iavf/Makefile +1 -1
index 9c3e45c54d01..2d154a4e2fd7 100644
@@ -13,4 +13,4 @@ obj-$(CONFIG_IAVF) += iavf.o
 
 iavf-objs := iavf_main.o iavf_ethtool.o iavf_virtchnl.o iavf_fdir.o \
 	     iavf_adv_rss.o \
-	     iavf_txrx.o iavf_common.o iavf_adminq.o iavf_client.o
+	     iavf_txrx.o iavf_common.o iavf_adminq.o
drivers/net/ethernet/intel/iavf/iavf.h +0 -27
index f026d0670338..e7ab89dc883a 100644
@@ -63,7 +63,6 @@ struct iavf_vsi {
 	DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__);
 	int base_vector;
 	u16 qs_handle;
-	void *priv;     /* client driver data reference. */
 };
 
 /* How many Rx Buffers do we bundle into one write to the hardware ? */
@@ -256,7 +255,6 @@ struct iavf_adapter {
 	struct work_struct reset_task;
 	struct work_struct adminq_task;
 	struct work_struct finish_config;
-	struct delayed_work client_task;
 	wait_queue_head_t down_waitqueue;
 	wait_queue_head_t reset_waitqueue;
 	wait_queue_head_t vc_waitqueue;
@@ -265,7 +263,6 @@ struct iavf_adapter {
 	int num_vlan_filters;
 	struct list_head mac_filter_list;
 	struct mutex crit_lock;
-	struct mutex client_lock;
 	/* Lock to protect accesses to MAC and VLAN lists */
 	spinlock_t mac_vlan_list_lock;
 	char misc_vector_name[IFNAMSIZ + 9];
@@ -282,10 +279,6 @@ struct iavf_adapter {
 	u64 hw_csum_rx_error;
 	u32 rx_desc_count;
 	int num_msix_vectors;
-	int num_rdma_msix;
-	int rdma_base_vector;
-	u32 client_pending;
-	struct iavf_client_instance *cinst;
 	struct msix_entry *msix_entries;
 
 	u32 flags;
@@ -294,10 +287,6 @@ struct iavf_adapter {
 #define IAVF_FLAG_RESET_PENDING		BIT(4)
 #define IAVF_FLAG_RESET_NEEDED		BIT(5)
 #define IAVF_FLAG_WB_ON_ITR_CAPABLE		BIT(6)
-#define IAVF_FLAG_SERVICE_CLIENT_REQUESTED	BIT(9)
-#define IAVF_FLAG_CLIENT_NEEDS_OPEN		BIT(10)
-#define IAVF_FLAG_CLIENT_NEEDS_CLOSE		BIT(11)
-#define IAVF_FLAG_CLIENT_NEEDS_L2_PARAMS	BIT(12)
 #define IAVF_FLAG_LEGACY_RX			BIT(15)
 #define IAVF_FLAG_REINIT_ITR_NEEDED		BIT(16)
 #define IAVF_FLAG_QUEUES_DISABLED		BIT(17)
@@ -388,11 +377,6 @@ struct iavf_adapter {
 	u32 link_speed_mbps;
 
 	enum virtchnl_ops current_op;
-#define CLIENT_ALLOWED(_a) ((_a)->vf_res ? \
-			    (_a)->vf_res->vf_cap_flags & \
-				VIRTCHNL_VF_OFFLOAD_RDMA : \
-			    0)
-#define CLIENT_ENABLED(_a) ((_a)->cinst)
 /* RSS by the PF should be preferred over RSS via other methods. */
 #define RSS_PF(_a) ((_a)->vf_res->vf_cap_flags & \
 		    VIRTCHNL_VF_OFFLOAD_RSS_PF)
@@ -460,12 +444,6 @@ struct iavf_adapter {
 
 /* Ethtool Private Flags */
 
-/* lan device, used by client interface */
-struct iavf_device {
-	struct list_head list;
-	struct iavf_adapter *vf;
-};
-
 /* needed by iavf_ethtool.c */
 extern char iavf_driver_name[];
 
@@ -569,11 +547,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 int iavf_config_rss(struct iavf_adapter *adapter);
 int iavf_lan_add_device(struct iavf_adapter *adapter);
 int iavf_lan_del_device(struct iavf_adapter *adapter);
-void iavf_client_subtask(struct iavf_adapter *adapter);
-void iavf_notify_client_message(struct iavf_vsi *vsi, u8 *msg, u16 len);
-void iavf_notify_client_l2_params(struct iavf_vsi *vsi);
-void iavf_notify_client_open(struct iavf_vsi *vsi);
-void iavf_notify_client_close(struct iavf_vsi *vsi, bool reset);
 void iavf_enable_channels(struct iavf_adapter *adapter);
 void iavf_disable_channels(struct iavf_adapter *adapter);
 void iavf_add_cloud_filter(struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_client.c deleted +0 -578

578 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_client.h deleted +0 -169

169 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_main.c +0 -82

184 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +0 -14
index 82b84a93bcc8..64c4443dbef9 100644
@@ -3,7 +3,6 @@
 
 #include "iavf.h"
 #include "iavf_prototype.h"
-#include "iavf_client.h"
 
 /**
  * iavf_send_pf_msg
@@ -2309,19 +2308,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		if (v_opcode != adapter->current_op)
 			return;
 		break;
-	case VIRTCHNL_OP_RDMA:
-		/* Gobble zero-length replies from the PF. They indicate that
-		 * a previous message was received OK, and the client doesn't
-		 * care about that.
-		 */
-		if (msglen && CLIENT_ENABLED(adapter))
-			iavf_notify_client_message(&adapter->vsi, msg, msglen);
-		break;
-
-	case VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP:
-		adapter->client_pending &=
-				~(BIT(VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP));
-		break;
 	case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
 		struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
 
Signature · 1 line
2.41.0
#5 lore raw

PATCH 4/9 iavf: in iavf_down, disable queues when removing the driver

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

In iavf_down, we're skipping the scheduling of certain operations if the driver is being removed. However, the IAVF_FLAG_AQ_DISABLE_QUEUES request must not be skipped in this case, because iavf_close waits for the transition to the __IAVF_DOWN state, which happens in iavf_virtchnl_completion after the queues are released.

Without this fix, "rmmod iavf" takes half a second per interface that's up and prints the "Device resources not yet released" warning.

Fixes c8de44b577eb ("iavf: do not process adminq tasks when __IAVF_IN_REMOVE_TASK is set")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
index b30d703e26a1..7ca19dfea109 100644
@@ -1440,9 +1440,9 @@ void iavf_down(struct iavf_adapter *adapter)
 			adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER;
 		if (!list_empty(&adapter->adv_rss_list_head))
 			adapter->aq_required |= IAVF_FLAG_AQ_DEL_ADV_RSS_CFG;
-		adapter->aq_required |= IAVF_FLAG_AQ_DISABLE_QUEUES;
 	}
 
+	adapter->aq_required |= IAVF_FLAG_AQ_DISABLE_QUEUES;
 	mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
 }
 
Signature · 1 line
2.41.0
maintainer
#6 lore raw

Re: [PATCH net-next 4/9] iavf: in iavf_down, disable queues when removing the driver

Quoted 8 lines · On Mon, 23 Oct 2023 16:08:21 -0700 Jacob Keller wrote:

From: Michal Schmidt <[email protected]>

In iavf_down, we're skipping the scheduling of certain operations if the driver is being removed. However, the IAVF_FLAG_AQ_DISABLE_QUEUES request must not be skipped in this case, because iavf_close waits for the transition to the __IAVF_DOWN state, which happens in iavf_virtchnl_completion after the queues are released.

Quoted 4 lines

Without this fix, "rmmod iavf" takes half a second per interface that's up and prints the "Device resources not yet released" warning.

Fixes c8de44b577eb ("iavf: do not process adminq tasks when __IAVF_IN_REMOVE_TASK is set")

This looks like a 6.6 regression, why send it for net-next?

#7 lore raw

Re: [PATCH net-next 4/9] iavf: in iavf_down, disable queues when removing the driver

Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 23 Oct 2023 16:08:21 -0700 Jacob Keller wrote:

From: Michal Schmidt <[email protected]>

In iavf_down, we're skipping the scheduling of certain operations if the driver is being removed. However, the IAVF_FLAG_AQ_DISABLE_QUEUES request must not be skipped in this case, because iavf_close waits for the transition to the __IAVF_DOWN state, which happens in iavf_virtchnl_completion after the queues are released.

Quoted 6 lines
Quoted 4 lines

Without this fix, "rmmod iavf" takes half a second per interface that's up and prints the "Device resources not yet released" warning.

Fixes c8de44b577eb ("iavf: do not process adminq tasks when __IAVF_IN_REMOVE_TASK is set")

This looks like a 6.6 regression, why send it for net-next?

Hi Jakub,
At first I thought I had a dependency on the preceding patch in the series, but after rethinking and retesting it, it's actually fine to put this patch in net.git.
Can you please do that, or will you require resending?

Thanks,
Michal

maintainer
#8 lore raw

Re: [PATCH net-next 4/9] iavf: in iavf_down, disable queues when removing the driver

Quoted 7 lines · On Wed, 25 Oct 2023 17:24:59 +0200 Michal Schmidt wrote:
Quoted 1 line

This looks like a 6.6 regression, why send it for net-next?

Hi Jakub,
At first I thought I had a dependency on the preceding patch in the series, but after rethinking and retesting it, it's actually fine to put this patch in net.git.
Can you please do that, or will you require resending?

I'd prefer if Jake could resend just the fix for net, after re-testing that it indeed works right. I'll make sure that it makes tomorrow's PR from net, in case the net-next stuff would conflict.

#9 lore raw

Re: [PATCH net-next 4/9] iavf: in iavf_down, disable queues when removing the driver

Quoted 9 lines · Jakub Kicinski
Quoted 7 lines · On Wed, 25 Oct 2023 17:24:59 +0200 Michal Schmidt wrote:
Quoted 1 line

This looks like a 6.6 regression, why send it for net-next?

Hi Jakub,
At first I thought I had a dependency on the preceding patch in the series, but after rethinking and retesting it, it's actually fine to put this patch in net.git.
Can you please do that, or will you require resending?

Quoted 4 lines

I'd prefer if Jake could resend just the fix for net, after re-testing that it indeed works right. I'll make sure that it makes tomorrow's PR from net, in case the net-next stuff would conflict.

Will do, thanks.

#10 lore raw

Re: [PATCH net-next 4/9] iavf: in iavf_down, disable queues when removing the driver

Quoted 12 lines · Jacob Keller
Quoted 9 lines · Jakub Kicinski
Quoted 7 lines · On Wed, 25 Oct 2023 17:24:59 +0200 Michal Schmidt wrote:
Quoted 1 line

This looks like a 6.6 regression, why send it for net-next?

Hi Jakub,
At first I thought I had a dependency on the preceding patch in the series, but after rethinking and retesting it, it's actually fine to put this patch in net.git.
Can you please do that, or will you require resending?

Quoted 7 lines
Quoted 4 lines

I'd prefer if Jake could resend just the fix for net, after re-testing that it indeed works right. I'll make sure that it makes tomorrow's PR from net, in case the net-next stuff would conflict.

Will do, thanks.

I tested this on one of my dev systems with 128 VFs. Without the fix applied:

$ time rmmod iavf
real    1m19.132s
user    0m0.007s
sys     0m1.974s

With the fix applied:

$ time rmmod iavf
real    0m17.951s
user    0m0.006s
sys     0m0.827s

I'll send this out to net shortly.

Thanks,
Jake

#11 lore raw

PATCH 5/9 iavf: fix the waiting time for initial reset

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

Every time I create VFs on ice, I receive at least one "Device is still in reset (-16), retrying" message per VF. It recovers fine, but typical usecases should not trigger scary-looking messages.

The waiting for reset is too short. It makes no sense to check every 10 microseconds. Typical reset waiting times are at least tens of milliseconds and can be several seconds. I suspect the polling interval was meant to be 10 milliseconds all along.

IAVF_RESET_WAIT_COMPLETE_COUNT is defined as 2000, so the total waiting time could be over 20 seconds. I have seen resets take 5 seconds (with 128 VFs on ice).

The added benefit of not triggering the "Device is still in reset" path is that we avoid going through the __IAVF_INIT_FAILED state, which would take a full second before retrying.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
index 7ca19dfea109..36d72f30ffce 100644
@@ -4786,7 +4786,7 @@ static int iavf_check_reset_complete(struct iavf_hw *hw)
 		if ((rstat == VIRTCHNL_VFR_VFACTIVE) ||
 		    (rstat == VIRTCHNL_VFR_COMPLETED))
 			return 0;
-		usleep_range(10, 20);
+		msleep(IAVF_RESET_WAIT_MS);
 	}
 	return -EBUSY;
 }
Signature · 1 line
2.41.0
#12 lore raw

PATCH 6/9 iavf: rely on netdev's own registered state

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

The information whether a netdev has been registered is already present in the netdev itself. There's no need for a driver flag with the same meaning.

---
 drivers/net/ethernet/intel/iavf/iavf.h      | 1 -
 drivers/net/ethernet/intel/iavf/iavf_main.c | 9 +++------
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +0 -1
index 44daf335e8c5..f026d0670338 100644
@@ -377,7 +377,6 @@ struct iavf_adapter {
 	unsigned long crit_section;
 
 	struct delayed_work watchdog_task;
-	bool netdev_registered;
 	bool link_up;
 	enum virtchnl_link_speed link_speed;
 	/* This is only populated if the VIRTCHNL_VF_CAP_ADV_LINK_SPEED is set
drivers/net/ethernet/intel/iavf/iavf_main.c +3 -6
index 36d72f30ffce..6e93e73385b3 100644
@@ -2021,7 +2021,7 @@ static void iavf_finish_config(struct work_struct *work)
 	mutex_lock(&adapter->crit_lock);
 
 	if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) &&
-	    adapter->netdev_registered &&
+	    adapter->netdev->reg_state == NETREG_REGISTERED &&
 	    !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
 		netdev_update_features(adapter->netdev);
 		adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES;
@@ -2029,7 +2029,7 @@ static void iavf_finish_config(struct work_struct *work)
 
 	switch (adapter->state) {
 	case __IAVF_DOWN:
-		if (!adapter->netdev_registered) {
+		if (adapter->netdev->reg_state != NETREG_REGISTERED) {
 			err = register_netdevice(adapter->netdev);
 			if (err) {
 				dev_err(&adapter->pdev->dev, "Unable to register netdev (%d)\n",
@@ -2043,7 +2043,6 @@ static void iavf_finish_config(struct work_struct *work)
 						  __IAVF_INIT_CONFIG_ADAPTER);
 				goto out;
 			}
-			adapter->netdev_registered = true;
 		}
 
 		/* Set the real number of queues when reset occurs while
@@ -5168,10 +5167,8 @@ static void iavf_remove(struct pci_dev *pdev)
 	cancel_work_sync(&adapter->finish_config);
 
 	rtnl_lock();
-	if (adapter->netdev_registered) {
+	if (netdev->reg_state == NETREG_REGISTERED)
 		unregister_netdevice(netdev);
-		adapter->netdev_registered = false;
-	}
 	rtnl_unlock();
 
 	if (CLIENT_ALLOWED(adapter)) {
Signature · 1 line
2.41.0
#13 lore raw

PATCH 7/9 iavf: use unregister_netdev

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

Use unregister_netdev, which takes rtnl_lock for us. We don't have to check the reg_state under rtnl_lock. There's nothing to race with. We have just cancelled the finish_config work.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -3
index 6e93e73385b3..85252b9dce50 100644
@@ -5166,10 +5166,8 @@ static void iavf_remove(struct pci_dev *pdev)
 	cancel_delayed_work_sync(&adapter->watchdog_task);
 	cancel_work_sync(&adapter->finish_config);
 
-	rtnl_lock();
 	if (netdev->reg_state == NETREG_REGISTERED)
-		unregister_netdevice(netdev);
-	rtnl_unlock();
+		unregister_netdev(netdev);
 
 	if (CLIENT_ALLOWED(adapter)) {
 		err = iavf_lan_del_device(adapter);
Signature · 1 line
2.41.0
maintainer
#14 lore raw

Re: [PATCH net-next 7/9] iavf: use unregister_netdev

Quoted 3 lines · On Mon, 23 Oct 2023 16:08:24 -0700 Jacob Keller wrote:

Use unregister_netdev, which takes rtnl_lock for us. We don't have to check the reg_state under rtnl_lock. There's nothing to race with. We have just cancelled the finish_config work.

I can't really convince myself that its indeed the case... but either way if something can register the netdev past the check - the code is buggy with or without rtnl_lock, so patch seems sane.

#15 lore raw

PATCH 8/9 iavf: add a common function for undoing the interrupt scheme

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

Add a new function iavf_free_interrupt_scheme that does the inverse of iavf_init_interrupt_scheme. Symmetry is nice. And there will be three callers already.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 26 ++++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +15 -11
index 85252b9dce50..49a764ca5e36 100644
@@ -1954,6 +1954,17 @@ static int iavf_init_interrupt_scheme(struct iavf_adapter *adapter)
 	return err;
 }
 
+/**
+ * iavf_free_interrupt_scheme - Undo what iavf_init_interrupt_scheme does
+ * @adapter: board private structure
+ **/
+static void iavf_free_interrupt_scheme(struct iavf_adapter *adapter)
+{
+	iavf_free_q_vectors(adapter);
+	iavf_reset_interrupt_capability(adapter);
+	iavf_free_queues(adapter);
+}
+
 /**
  * iavf_free_rss - Free memory used by RSS structs
  * @adapter: board private structure
@@ -1982,11 +1993,9 @@ static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool runni
 	if (running)
 		iavf_free_traffic_irqs(adapter);
 	iavf_free_misc_irq(adapter);
-	iavf_reset_interrupt_capability(adapter);
-	iavf_free_q_vectors(adapter);
-	iavf_free_queues(adapter);
+	iavf_free_interrupt_scheme(adapter);
 
-	err =  iavf_init_interrupt_scheme(adapter);
+	err = iavf_init_interrupt_scheme(adapter);
 	if (err)
 		goto err;
 
@@ -2968,9 +2977,7 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
 	spin_unlock_bh(&adapter->cloud_filter_list_lock);
 
 	iavf_free_misc_irq(adapter);
-	iavf_reset_interrupt_capability(adapter);
-	iavf_free_q_vectors(adapter);
-	iavf_free_queues(adapter);
+	iavf_free_interrupt_scheme(adapter);
 	memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);
 	iavf_shutdown_adminq(&adapter->hw);
 	adapter->flags &= ~IAVF_FLAG_RESET_PENDING;
@@ -5201,9 +5208,7 @@ static void iavf_remove(struct pci_dev *pdev)
 	iavf_free_all_tx_resources(adapter);
 	iavf_free_all_rx_resources(adapter);
 	iavf_free_misc_irq(adapter);
-
-	iavf_reset_interrupt_capability(adapter);
-	iavf_free_q_vectors(adapter);
+	iavf_free_interrupt_scheme(adapter);
 
 	iavf_free_rss(adapter);
 
@@ -5219,7 +5224,6 @@ static void iavf_remove(struct pci_dev *pdev)
 
 	iounmap(hw->hw_addr);
 	pci_release_regions(pdev);
-	iavf_free_queues(adapter);
 	kfree(adapter->vf_res);
 	spin_lock_bh(&adapter->mac_vlan_list_lock);
 	/* If we got removed before an up/down sequence, we've got a filter
Signature · 1 line
2.41.0
#16 lore raw

PATCH 9/9 iavf: delete the iavf client interface

In reply to Jacob Keller

From: Michal Schmidt <[email protected]>

The iavf client interface was added in 2017 by commit ed0e894de7c1 ("i40evf: add client interface"), but there have never been any in-tree callers.

It's not useful for future development either. The Intel out-of-tree iavf and irdma drivers instead use an auxiliary bus, which is a better solution.

Remove the iavf client interface code. Also gone are the client_task work and the client_lock mutex.

---
 drivers/net/ethernet/intel/iavf/Makefile      |   2 +-
 drivers/net/ethernet/intel/iavf/iavf.h        |  27 -
 drivers/net/ethernet/intel/iavf/iavf_client.c | 578 ------------------
 drivers/net/ethernet/intel/iavf/iavf_client.h | 169 -----
 drivers/net/ethernet/intel/iavf/iavf_main.c   |  82 ---
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  14 -
 6 files changed, 1 insertion(+), 871 deletions(-)
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.c
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.h
drivers/net/ethernet/intel/iavf/Makefile +1 -1
index 9c3e45c54d01..2d154a4e2fd7 100644
@@ -13,4 +13,4 @@ obj-$(CONFIG_IAVF) += iavf.o
 
 iavf-objs := iavf_main.o iavf_ethtool.o iavf_virtchnl.o iavf_fdir.o \
 	     iavf_adv_rss.o \
-	     iavf_txrx.o iavf_common.o iavf_adminq.o iavf_client.o
+	     iavf_txrx.o iavf_common.o iavf_adminq.o
drivers/net/ethernet/intel/iavf/iavf.h +0 -27
index f026d0670338..e7ab89dc883a 100644
@@ -63,7 +63,6 @@ struct iavf_vsi {
 	DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__);
 	int base_vector;
 	u16 qs_handle;
-	void *priv;     /* client driver data reference. */
 };
 
 /* How many Rx Buffers do we bundle into one write to the hardware ? */
@@ -256,7 +255,6 @@ struct iavf_adapter {
 	struct work_struct reset_task;
 	struct work_struct adminq_task;
 	struct work_struct finish_config;
-	struct delayed_work client_task;
 	wait_queue_head_t down_waitqueue;
 	wait_queue_head_t reset_waitqueue;
 	wait_queue_head_t vc_waitqueue;
@@ -265,7 +263,6 @@ struct iavf_adapter {
 	int num_vlan_filters;
 	struct list_head mac_filter_list;
 	struct mutex crit_lock;
-	struct mutex client_lock;
 	/* Lock to protect accesses to MAC and VLAN lists */
 	spinlock_t mac_vlan_list_lock;
 	char misc_vector_name[IFNAMSIZ + 9];
@@ -282,10 +279,6 @@ struct iavf_adapter {
 	u64 hw_csum_rx_error;
 	u32 rx_desc_count;
 	int num_msix_vectors;
-	int num_rdma_msix;
-	int rdma_base_vector;
-	u32 client_pending;
-	struct iavf_client_instance *cinst;
 	struct msix_entry *msix_entries;
 
 	u32 flags;
@@ -294,10 +287,6 @@ struct iavf_adapter {
 #define IAVF_FLAG_RESET_PENDING		BIT(4)
 #define IAVF_FLAG_RESET_NEEDED		BIT(5)
 #define IAVF_FLAG_WB_ON_ITR_CAPABLE		BIT(6)
-#define IAVF_FLAG_SERVICE_CLIENT_REQUESTED	BIT(9)
-#define IAVF_FLAG_CLIENT_NEEDS_OPEN		BIT(10)
-#define IAVF_FLAG_CLIENT_NEEDS_CLOSE		BIT(11)
-#define IAVF_FLAG_CLIENT_NEEDS_L2_PARAMS	BIT(12)
 #define IAVF_FLAG_LEGACY_RX			BIT(15)
 #define IAVF_FLAG_REINIT_ITR_NEEDED		BIT(16)
 #define IAVF_FLAG_QUEUES_DISABLED		BIT(17)
@@ -388,11 +377,6 @@ struct iavf_adapter {
 	u32 link_speed_mbps;
 
 	enum virtchnl_ops current_op;
-#define CLIENT_ALLOWED(_a) ((_a)->vf_res ? \
-			    (_a)->vf_res->vf_cap_flags & \
-				VIRTCHNL_VF_OFFLOAD_RDMA : \
-			    0)
-#define CLIENT_ENABLED(_a) ((_a)->cinst)
 /* RSS by the PF should be preferred over RSS via other methods. */
 #define RSS_PF(_a) ((_a)->vf_res->vf_cap_flags & \
 		    VIRTCHNL_VF_OFFLOAD_RSS_PF)
@@ -460,12 +444,6 @@ struct iavf_adapter {
 
 /* Ethtool Private Flags */
 
-/* lan device, used by client interface */
-struct iavf_device {
-	struct list_head list;
-	struct iavf_adapter *vf;
-};
-
 /* needed by iavf_ethtool.c */
 extern char iavf_driver_name[];
 
@@ -569,11 +547,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 int iavf_config_rss(struct iavf_adapter *adapter);
 int iavf_lan_add_device(struct iavf_adapter *adapter);
 int iavf_lan_del_device(struct iavf_adapter *adapter);
-void iavf_client_subtask(struct iavf_adapter *adapter);
-void iavf_notify_client_message(struct iavf_vsi *vsi, u8 *msg, u16 len);
-void iavf_notify_client_l2_params(struct iavf_vsi *vsi);
-void iavf_notify_client_open(struct iavf_vsi *vsi);
-void iavf_notify_client_close(struct iavf_vsi *vsi, bool reset);
 void iavf_enable_channels(struct iavf_adapter *adapter);
 void iavf_disable_channels(struct iavf_adapter *adapter);
 void iavf_add_cloud_filter(struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_client.c deleted +0 -578

578 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_client.h deleted +0 -169

169 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_main.c +0 -82

184 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +0 -14
index 82b84a93bcc8..64c4443dbef9 100644
@@ -3,7 +3,6 @@
 
 #include "iavf.h"
 #include "iavf_prototype.h"
-#include "iavf_client.h"
 
 /**
  * iavf_send_pf_msg
@@ -2309,19 +2308,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		if (v_opcode != adapter->current_op)
 			return;
 		break;
-	case VIRTCHNL_OP_RDMA:
-		/* Gobble zero-length replies from the PF. They indicate that
-		 * a previous message was received OK, and the client doesn't
-		 * care about that.
-		 */
-		if (msglen && CLIENT_ENABLED(adapter))
-			iavf_notify_client_message(&adapter->vsi, msg, msglen);
-		break;
-
-	case VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP:
-		adapter->client_pending &=
-				~(BIT(VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP));
-		break;
 	case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
 		struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
 
Signature · 1 line
2.41.0
#17 lore raw
In reply to Jacob Keller
Quoted 29 lines · Jacob Keller

This series includes iAVF driver cleanups from Michal Schmidt.

Michal removes and updates stale comments, fixes some locking anti-patterns, improves handling of resets when the PF is slow, avoids unnecessary duplication of netdev state, refactors away some duplicate code, and finally removes the never-actually-used client interface.

Michal Schmidt (9):
iavf: fix comments about old bit locks
iavf: simplify mutex_trylock+sleep loops
iavf: in iavf_down, don't queue watchdog_task if comms failed
iavf: in iavf_down, disable queues when removing the driver
iavf: fix the waiting time for initial reset
iavf: rely on netdev's own registered state
iavf: use unregister_netdev
iavf: add a common function for undoing the interrupt scheme
iavf: delete the iavf client interface

 drivers/net/ethernet/intel/iavf/Makefile      |   2 +-
 drivers/net/ethernet/intel/iavf/iavf.h        |  28 -
 drivers/net/ethernet/intel/iavf/iavf_client.c | 578 ------------------
 drivers/net/ethernet/intel/iavf/iavf_client.h | 169 -----
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 139 +----
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  14 -
 6 files changed, 29 insertions(+), 901 deletions(-)
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.c
 delete mode 100644 drivers/net/ethernet/intel/iavf/iavf_client.h
Quoted 1 line

base-commit: d6e48462e88fe7efc78b455ecde5b0ca43ec50b7

Since we pulled the fix out into net, I assume I should resend a rebased v2 of this series?

Thanks,
Jake

maintainer
#18 lore raw
Quoted 2 lines · On Fri, 27 Oct 2023 09:58:38 -0700 Jacob Keller wrote:

Since we pulled the fix out into net, I assume I should resend a rebased v2 of this series?

Yes, please