Skip to contentSkip to conversation

iavf: Add waiting for response from PF in set mac

PATCH Superseded Mateusz Palczewski 2 participants 5 messages Jan 24, 2022 – Jan 25, 2022

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iavf: Add waiting for response from PF in set mac

Make iavf_set_mac synchronous by waiting for a response from a PF. Without this iavf_set_mac is always returning success even though set_mac can be rejected by a PF. This ensures that when set_mac exits netdev MAC is updated. This is needed for sending ARPs with correct MAC after changing VF's MAC. This is also needed by bonding module.

---
 drivers/net/ethernet/intel/iavf/iavf.h        |  11 +-
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 123 +++++++++++++++---
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  77 +++++++++--
 3 files changed, 183 insertions(+), 28 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +10 -1
index a746f44..2854af1 100644
@@ -143,7 +143,8 @@ struct iavf_mac_filter {
 		u8 remove:1;        /* filter needs to be removed */
 		u8 add:1;           /* filter needs to be added */
 		u8 is_primary:1;    /* filter is a default VF MAC */
-		u8 padding:4;
+		u8 add_handled:1;   /* received response for filter add */
+		u8 padding:3;
 	};
 };
 
@@ -201,6 +202,10 @@ enum iavf_state_t {
 	__IAVF_RUNNING,		/* opened, working */
 };
 
+enum iavf_critical_section_t {
+	__IAVF_IN_CRITICAL_TASK		/* cannot be interrupted */
+};
+
 #define IAVF_CLOUD_FIELD_OMAC		0x01
 #define IAVF_CLOUD_FIELD_IMAC		0x02
 #define IAVF_CLOUD_FIELD_IVLAN	0x04
@@ -240,6 +245,7 @@ struct iavf_adapter {
 	struct work_struct adminq_task;
 	struct delayed_work client_task;
 	wait_queue_head_t down_waitqueue;
+	wait_queue_head_t vc_waitqueue;
 	struct iavf_q_vector *q_vectors;
 	struct list_head vlan_filter_list;
 	struct list_head mac_filter_list;
@@ -283,6 +289,7 @@ struct iavf_adapter {
 #define IAVF_FLAG_LEGACY_RX			BIT(15)
 #define IAVF_FLAG_REINIT_ITR_NEEDED		BIT(16)
 #define IAVF_FLAG_QUEUES_DISABLED		BIT(17)
+#define IAVF_FLAG_INITIAL_MAC_SET		BIT(23)
 /* duplicates for common code */
 #define IAVF_FLAG_DCB_ENABLED			0
 	/* flags for admin queue service task */
@@ -550,6 +557,8 @@ void iavf_enable_vlan_stripping_v2(struct iavf_adapter *adapter, u16 tpid);
 void iavf_disable_vlan_stripping_v2(struct iavf_adapter *adapter, u16 tpid);
 void iavf_enable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid);
 void iavf_disable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid);
+int iavf_replace_primary_mac(struct iavf_adapter *adapter,
+			     const u8 *new_mac);
 void
 iavf_set_vlan_offload_features(struct iavf_adapter *adapter,
 			       netdev_features_t prev_features,
drivers/net/ethernet/intel/iavf/iavf_main.c +105 -18

170 lines not on this page · raw message

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +68 -9

135 lines not on this page · raw message

Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 iavf: Add waiting for response from PF in set mac

Quoted 6 lines · Mateusz Palczewski

Make iavf_set_mac synchronous by waiting for a response from a PF. Without this iavf_set_mac is always returning success even though set_mac can be rejected by a PF. This ensures that when set_mac exits netdev MAC is updated. This is needed for sending ARPs with correct MAC after changing VF's MAC. This is also needed by bonding module.

This sounds very much like this patch [1] or is this resolving a different issue?

Quoted 3 lines

---

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?
id=c5c922b3e09b6e5eeb9cd2b1122f3e49c0bf2283

#2 lore raw

PATCH 1/1 iavf: Add waiting for response from PF in set mac

Quoted 9 lines · Mateusz Palczewski
Quoted 6 lines

Make iavf_set_mac synchronous by waiting for a response from a PF. Without this iavf_set_mac is always returning success even though set_mac can be rejected by a PF.
This ensures that when set_mac exits netdev MAC is updated. This is needed for sending ARPs with correct MAC after changing VF's MAC. This is also needed by bonding module.

This sounds very much like this patch [1] or is this resolving a different issue?

Hi,
this is resolving a different issue that is being currently tracked on bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1938635

Quoted 8 lines
Quoted 4 lines

---

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?
id=c5c922b3e09b6e5eeb9cd2b1122f3e49c0bf2283

#3 lore raw

PATCH 1/1 iavf: Add waiting for response from PF in set mac

Quoted 10 lines · Mateusz
Quoted 10 lines · Mateusz Palczewski
Quoted 8 lines

Make iavf_set_mac synchronous by waiting for a response from a PF.
Without this iavf_set_mac is always returning success even though set_mac can be rejected by a PF.
This ensures that when set_mac exits netdev MAC is updated. This is needed for sending ARPs with correct MAC after changing VF's
MAC. This is also needed by bonding module.

Quoted 6 lines
Quoted 2 lines

This sounds very much like this patch [1] or is this resolving a different issue?

Hi,
this is resolving a different issue that is being currently tracked on bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1938635

Thanks for providing that info. I do have some feedback on the patch, I'll reply to the original so that I can make them inline.

Thanks,
Tony

Quoted 11 lines
Quoted 10 lines
Quoted 5 lines

Signed-off-by: Sylwester Dziedziuch
<[email protected]>

---

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/
?
id=c5c922b3e09b6e5eeb9cd2b1122f3e49c0bf2283

#4 lore raw

PATCH 1/1 iavf: Add waiting for response from PF in set mac

In reply to Mateusz Palczewski
Quoted 1 line · Mateusz Palczewski

<snip>

drivers/net/ethernet/intel/iavf/iavf.h enum iavf_state_t { · line 207

Quoted 3 lines
drivers/net/ethernet/intel/iavf/iavf.h +3 -0
+enum iavf_critical_section_t {
+???????__IAVF_IN_CRITICAL_TASK?????????/* cannot be interrupted */
+};

This was removed by maintainer request. Please don't re-add it. Use the crit_lock.

Quoted 93 lines

?#define IAVF_CLOUD_FIELD_OMAC??????????0x01
?#define IAVF_CLOUD_FIELD_IMAC??????????0x02
?#define IAVF_CLOUD_FIELD_IVLAN?0x04

(quoted diff) +2 -0
@@ -240,6 +245,7 @@ struct iavf_adapter {
 ????????struct work_struct adminq_task;
 ????????struct delayed_work client_task;
 ????????wait_queue_head_t down_waitqueue;
+???????wait_queue_head_t vc_waitqueue;
 ????????struct iavf_q_vector *q_vectors;
 ????????struct list_head vlan_filter_list;
 ????????struct list_head mac_filter_list;
@@ -283,6 +289,7 @@ struct iavf_adapter {
 ?#define IAVF_FLAG_LEGACY_RX????????????????????BIT(15)
 ?#define IAVF_FLAG_REINIT_ITR_NEEDED????????????BIT(16)
 ?#define IAVF_FLAG_QUEUES_DISABLED??????????????BIT(17)
+#define IAVF_FLAG_INITIAL_MAC_SET??????????????BIT(23)

?/* duplicates for common code */
?#define IAVF_FLAG_DCB_ENABLED??????????????????0
????????/* flags for admin queue service task */

(quoted diff) +0 -0
@@ -550,6 +557,8 @@ void iavf_enable_vlan_stripping_v2(struct
 iavf_adapter *adapter, u16 tpid);
 ?void iavf_disable_vlan_stripping_v2(struct iavf_adapter *adapter,
 u16 tpid);

?void iavf_enable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid);
?void iavf_disable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid);
+int iavf_replace_primary_mac(struct iavf_adapter *adapter, +??????????????????????????? const u8 *new_mac);
?void
?iavf_set_vlan_offload_features(struct iavf_adapter *adapter, ?????????????????????????????? netdev_features_t prev_features,

drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
index a4c12a3..c816ecb 100644
@@ -873,6 +873,7 @@ struct iavf_mac_filter *iavf_add_filter(struct
 iavf_adapter *adapter,

?
????????????????list_add_tail(&f->list, &adapter->mac_filter_list); ????????????????f->add = true; +???????????????f->add_handled = false; ????????????????f->is_new_mac = true; ????????????????f->is_primary = false; ????????????????adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;

drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
@@ -884,47 +885,128 @@ struct iavf_mac_filter *iavf_add_filter(struct
 iavf_adapter *adapter,
 ?}

?
?/**
- * iavf_set_mac - NDO callback to set port mac address
- * @netdev: network interface device structure
- * @p: pointer to an address structure
+ * iavf_replace_primary_mac - Replace current primary address
+ * @adapter: board private structure
+ * @new_mac: new mac address to be applied
? *
- * Returns 0 on success, negative on failure
+ * Replace current dev_addr and send request to PF for removal of previous
+ * primary mac address filter and addition of new primary mac filter.
+ * Return 0 for success, -ENOMEM for failure.
+ *
+ * Do not call this with mac_vlan_list_lock!
? **/

drivers/net/ethernet/intel/iavf/iavf_main.c +2 -1
-static int iavf_set_mac(struct net_device *netdev, void *p)
+int iavf_replace_primary_mac(struct iavf_adapter *adapter,
+??????????????????????????? const u8 *new_mac)

?{
-???????struct iavf_adapter *adapter = netdev_priv(netdev); ????????struct iavf_hw *hw = &adapter->hw; ????????struct iavf_mac_filter *f;
-???????struct sockaddr *addr = p;

drivers/net/ethernet/intel/iavf/iavf_main.c +0 -6
-
-???????if (!is_valid_ether_addr(addr->sa_data))
-???????????????return -EADDRNOTAVAIL;
-
-???????if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
-???????????????return 0;

?
????????spin_lock_bh(&adapter->mac_vlan_list_lock);
?
+???????list_for_each_entry(f, &adapter->mac_filter_list, list) { +???????????????f->is_primary = false;
+???????}
+
????????f = iavf_find_filter(adapter, hw->mac.addr); ????????if (f) {
????????????????f->remove = true; -???????????????f->is_primary = true; ????????????????adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER;