Fix i40e/ice/iavf VF bonding after netdev lock changes
Subsystems (4)
v2 cover Fix i40e/ice/iavf VF bonding after netdev lock changes
This series fixes VF bonding failures introduced by commit ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations").
When adding VFs to a bond immediately after setting trust mode, MAC address changes fail with -EAGAIN, preventing bonding setup. This affects both i40e (700-series) and ice (800-series) Intel NICs.
The core issue is lock contention: iavf_set_mac() is now called with the netdev lock held and waits for MAC change completion while holding it. However, both the watchdog task that sends the request and the adminq_task that processes PF responses also need this lock, creating a deadlock where neither can run, causing timeouts.
Additionally, setting VF trust triggers an unnecessary ~10 second VF reset in i40e driver that delays bonding setup, even though filter synchronization happens naturally during normal VF operation. For ice driver, the delay is not so big, but in the same way the operation is not necessary.
This series:
1. Adds safety guard to prevent MAC changes during reset or early initialization (before VF is ready)
2. Eliminates unnecessary VF reset when setting trust in i40e
3. Fixes lock contention by polling admin queue synchronously
4. Eliminates unnecessary VF reset when setting trust in ice
The key fix (patch 3/4) implements a synchronous MAC change operation similar to the approach used for ndo_change_mtu deadlock fix:
https://lore.kernel.org/intel-wired-lan/[email protected]/
Instead of scheduling work and waiting, it:
- Sends the virtchnl message directly (not via watchdog)
- Polls the admin queue hardware directly for responses
- Processes all messages inline (including non-MAC messages)
- Returns when complete or times out
This allows the operation to complete synchronously while holding netdev_lock, without relying on watchdog or adminq_task. A new generic iavf_poll_virtchnl_response() function is introduced that can be reused for future synchronous virtchnl operations.
The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable since netdev_lock is per-device and only serializes operations on the same interface.
Testing shows VF bonding now works reliably in ~5 seconds vs 15+ seconds before (i40e), without timeouts or errors (i40e and ice).
Tested on Intel 700-series (i40e) and 800-series (ice) dual-port NICs with iavf driver.
Thanks to Jan Tluka <[email protected]> and Yuying Ma <[email protected]> for reporting the issues.
Jose Ignacio Tornos Martinez (4):
iavf: return EBUSY if reset in progress during MAC change
i40e: skip unnecessary VF reset when setting trust
iavf: send MAC change request synchronously
ice: skip unnecessary VF reset when setting trust
---
v2:
- Patch 1: Add state check to prevent MAC changes during early initialization (before __IAVF_DOWN state)
- Patch 3: Use synchronous polling approach instead of dropping lock, following the pattern from ndo_change_mtu deadlock fix
- Introduce generic iavf_poll_virtchnl_response() for code reuse
- Add patch 4/4 to fix the same trust reset issue in ice driver
- Add testing confirmation for both i40e and ice hardware
- No changes to patch 2 from v1
v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 17 ++- drivers/net/ethernet/intel/iavf/iavf.h | 2 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 98 +++++++++++++++++- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 15 +-- drivers/net/ethernet/intel/ice/ice_sriov.c | 15 ++- 5 files changed, 123 insertions(+), 24 deletions(-)
--
2.43.0
PATCH v2 1/4 iavf: return EBUSY if reset in progress or not ready during MAC change
When a MAC address change is requested while the VF is resetting or still initializing, return -EBUSY immediately instead of attempting the operation.
Additionally, during early initialization states (before __IAVF_DOWN), the PF may be slow to respond to MAC change requests, causing long delays. Only allow MAC changes once the VF reaches __IAVF_DOWN state or later, when the watchdog is running and the VF is ready for operations.
After commit ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations"), MAC changes are called with the netdev lock held, so we should not wait with the lock held during reset or initialization. This allows the caller to retry or handle the busy state appropriately without blocking other operations.
---
v2: Add state check to prevent MAC changes during early initialization
states (before __IAVF_DOWN). In v1 this patch only checked for reset in progress.
v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_main.c +3 -0
@@ -1060,6 +1060,9 @@ static int iavf_set_mac(struct net_device *netdev, void *p)struct sockaddr *addr = p;int ret; +if (iavf_is_reset_in_progress (adapter) || adapter->state < __IAVF_DOWN) +return -EBUSY ; +if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ;
Signature · 1 line
2.53.0
PATCH v2 2/4 i40e: skip unnecessary VF reset when setting trust
In reply to Jose Ignacio Tornos MartinezWhen VF trust is changed, i40e_ndo_set_vf_trust() always calls i40e_vc_reset_vf() to sync MAC/VLAN filters. However, this reset is only necessary when trust is removed from a VF that has ADQ (advanced queue) filters, which need to be deleted
In all other cases, the reset causes a ~10 second delay during which:
- VF must reinitialize completely
- Any in-progress operations (like bonding enslave) fail with timeouts
- VF is unavailable
The MAC/VLAN filter sync will happen naturally through the normal VF operations and doesn't require a forced reset.
Fix by only resetting when actually needed: when removing trust from a VF that has ADQ cloud filters. For all other trust changes, just update the trust flag and let normal operation continue.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -1
@@ -4987,16 +4987,21 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)set_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state); pf->vsi[vf->lan_vsi_idx]->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; -i40e_vc_reset_vf (vf, true);dev_info (&pf->pdev->dev,"VF %u is now %strusted\n" , vf_id, setting ?"" :"un" ); +/* Only reset VF if we're removing trust and it has ADQ cloud filters. +* Cloud filters can only be added when trusted, so they must be +* removed when trust is revoked. Other trust changes don't require +* reset - MAC/VLAN filter sync happens through normal operation. +*/ if (vf->adq_enabled) {if (!vf->trusted) {dev_info (&pf->pdev->dev,"VF %u no longer Trusted, deleting all cloud filters\n" , vf_id);i40e_del_all_cloud_filters (vf); +i40e_vc_reset_vf (vf, true); } }
Signature · 1 line
2.53.0
PATCH v2 3/4 iavf: send MAC change request synchronously
In reply to Jose Ignacio Tornos MartinezAfter commit ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations"), iavf_set_mac() is called with the netdev instance lock already held.
The function queues a MAC address change request via iavf_replace_primary_mac() and then waits for completion. However, in the current flow, the actual virtchnl message is sent by the watchdog task, which also needs to acquire the netdev lock to run. Additionally, the adminq_task which processes virtchnl responses also needs the netdev lock.
This creates a deadlock scenario:
1. iavf_set_mac() holds netdev lock and waits for MAC change
2. Watchdog needs netdev lock to send the request -> blocked
3. Even if request is sent, adminq_task needs netdev lock to process PF response -> blocked
4. MAC change times out after 2.5 seconds
5. iavf_set_mac() returns -EAGAIN
This particularly affects VFs during bonding setup when multiple VFs are enslaved in quick succession.
Fix by implementing a synchronous MAC change operation similar to the approach used in commit fdadbf6e84c4 ("iavf: fix incorrect reset handling in callbacks").
The solution:
1. Send the virtchnl ADD_ETH_ADDR message directly (not via watchdog)
2. Poll the admin queue hardware directly for responses
3. Process all received messages (including non-MAC messages)
4. Return when MAC change completes or times out
A new generic function iavf_poll_virtchnl_response() is introduced that can be reused for any future synchronous virtchnl operations. It takes a callback to check completion, allowing flexible condition checking.
This allows the operation to complete synchronously while holding netdev_lock, without relying on watchdog or adminq_task. The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable since netdev_lock is per-device and only serializes operations on the same interface.
To support this, change iavf_add_ether_addrs() to return an error code instead of void, allowing callers to detect failures.
---
v2: Complete rewrite using synchronous polling approach instead of dropping
the netdev lock. New approach:
- Polls admin queue hardware directly (similar to iavf_reset_step)
- Processes all virtchnl messages inline while holding netdev_lock
- Introduced generic iavf_poll_virtchnl_response() for code reuse
- No lock dropping, following accepted pattern from ndo_change_mtu fix
v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/intel/iavf/iavf.h | 2 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 118 +++++++++++++++--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 11 +- 3 files changed, 110 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -1
@@ -589,7 +589,7 @@ void iavf_configure_queues(struct iavf_adapter *adapter);void iavf_enable_queues (struct iavf_adapter *adapter);void iavf_disable_queues (struct iavf_adapter *adapter);void iavf_map_queues (struct iavf_adapter *adapter); -void iavf_add_ether_addrs (struct iavf_adapter *adapter); +int iavf_add_ether_addrs (struct iavf_adapter *adapter);void iavf_del_ether_addrs (struct iavf_adapter *adapter);void iavf_add_vlans (struct iavf_adapter *adapter);void iavf_del_vlans (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +102 -16
133 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +7 -4
@@ -555,8 +555,10 @@ iavf_set_mac_addr_type(struct virtchnl_ether_addr *virtchnl_ether_addr,* @adapter: adapter structure * * Request that the PF add one or more addresses to our filters. +* +* Returns 0 on success or error **/ -void iavf_add_ether_addrs (struct iavf_adapter *adapter) +int iavf_add_ether_addrs (struct iavf_adapter *adapter) {struct virtchnl_ether_addr_list *veal;struct iavf_mac_filter *f;
@@ -568,7 +570,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter)/* bail because we already have a command pending */ dev_err (&adapter->pdev->dev,"Cannot add filters, command %d pending\n" , adapter->current_op); -return ; +return -EBUSY ; }spin_lock_bh (&adapter->mac_vlan_list_lock);
@@ -580,7 +582,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter)if (!count) { adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER ;spin_unlock_bh (&adapter->mac_vlan_list_lock); -return ; +return 0 ; } adapter->current_op =VIRTCHNL_OP_ADD_ETH_ADDR ;
@@ -595,7 +597,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) veal =kzalloc (len,GFP_ATOMIC );if (!veal) {spin_unlock_bh (&adapter->mac_vlan_list_lock); -return ; +return -ENOMEM ; } veal->vsi_id = adapter->vsi_res->vsi_id;
@@ -617,6 +619,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter)iavf_send_pf_msg (adapter,VIRTCHNL_OP_ADD_ETH_ADDR , (u8 *)veal, len);kfree (veal); +return 0 ; }/**
Signature · 1 line
2.53.0
Przemek Kitszel
maintainerRe: [Intel-wired-lan] [PATCH net v2 3/4] iavf: send MAC change request synchronously
Quoted 89 lines · Jose Ignacio Tornos Martinez
After commit
ad7c7b2172c3("net: hold netdev instance lock during sysfs operations"),iavf_set_mac()is called with the netdev instance lock already held.The function queues a MAC address change request via
iavf_replace_primary_mac()and then waits for completion. However, in the current flow, the actual virtchnl message is sent by the watchdog task, which also needs to acquire the netdev lock to run. Additionally, theadminq_taskwhich processes virtchnl responses also needs the netdev lock.This creates a deadlock scenario:
1.iavf_set_mac()holds netdev lock and waits for MAC change
2. Watchdog needs netdev lock to send the request -> blocked
3. Even if request is sent,adminq_taskneeds netdev lock to processPF response -> blocked4. MAC change times out after 2.5 seconds
5.iavf_set_mac()returns-EAGAINThis particularly affects VFs during bonding setup when multiple VFs are enslaved in quick succession.
Fix by implementing a synchronous MAC change operation similar to the approach used in commit
fdadbf6e84c4("iavf: fix incorrect reset handling in callbacks").The solution:
1. Send the virtchnlADD_ETH_ADDRmessage directly (not via watchdog)
2. Poll the admin queue hardware directly for responses
3. Process all received messages (including non-MAC messages)
4. Return when MAC change completes or times outA new generic function
iavf_poll_virtchnl_response()is introduced that can be reused for any future synchronous virtchnl operations. It takes a callback to check completion, allowing flexible condition checking.This allows the operation to complete synchronously while holding
netdev_lock, without relying on watchdog oradminq_task. The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable sincenetdev_lockis per-device and only serializes operations on the same interface.To support this, change
iavf_add_ether_addrs()to return an error code instead of void, allowing callers to detect failures.Fixes ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations")Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>---
v2: Complete rewrite using synchronous polling approach instead of dropping
the netdev lock. New approach:
- Polls admin queue hardware directly (similar toiavf_reset_step)
- Processes all virtchnl messages inline while holdingnetdev_lock
- Introduced genericiavf_poll_virtchnl_response()for code reuse
- No lock dropping, following accepted pattern fromndo_change_mtufix
v1: https://lore.kernel.org/netdev/[email protected]/drivers/net/ethernet/intel/iavf/iavf.h | 2 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 118 +++++++++++++++--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 11 +- 3 files changed, 110 insertions(+), 21 deletions(-)drivers/net/ethernet/intel/iavf/iavf.h +1
-1@@ -589,7 +589,7 @@ void iavf_configure_queues(struct iavf_adapter *adapter);void iavf_enable_queues (struct iavf_adapter *adapter);void iavf_disable_queues (struct iavf_adapter *adapter);void iavf_map_queues (struct iavf_adapter *adapter); -void iavf_add_ether_addrs (struct iavf_adapter *adapter); +int iavf_add_ether_addrs (struct iavf_adapter *adapter);void iavf_del_ether_addrs (struct iavf_adapter *adapter);void iavf_add_vlans (struct iavf_adapter *adapter);void iavf_del_vlans (struct iavf_adapter *adapter);drivers/net/ethernet/intel/iavf/iavf_main.c +6
-0@@ -1047,6 +1047,105 @@ static bool iavf_is_mac_set_handled(struct net_device *netdev,return ret; } +/** +* iavf_poll_virtchnl_response - Poll admin queue for virtchnl response +* @adapter: board private structure +* @condition: callback to check if desired response received +* @cond_data: context data passed to condition callback +* @timeout_ms: maximum time to wait in milliseconds
drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1065
Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10
-0+* +* Polls admin queue and processes all messages until condition returns true +* or timeout expires. Caller must hold netdev_lock. This can sleep for up to +* timeout_ms while polling hardware. +* +* Returns 0 on success (condition met), -EAGAIN on timeout or error +*/ +static int iavf_poll_virtchnl_response(struct iavf_adapter *adapter, + bool (*condition)(struct iavf_adapter *, void *), + void *cond_data,
this could be const, then no cast on the callsite
Quoted 9 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +9
-0+ unsigned int timeout_ms) +{ +struct iavf_hw *hw = &adapter->hw; +struct iavf_arq_event_info event; +enum virtchnl_ops v_op; +enum iavf_status v_ret; +unsigned long timeout; +int ret; +
drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1084
Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10
-0+netdev_assert_locked (adapter->netdev); + + event.buf_len =IAVF_MAX_AQ_BUF_SIZE ; + event.msg_buf =kzalloc (event.buf_len,GFP_KERNEL ); +if (!event.msg_buf) +return -ENOMEM ; + + timeout = jiffies +msecs_to_jiffies (timeout_ms); +while (time_before (jiffies, timeout)) { +if (condition (adapter, cond_data)) {
if condition is met, but timed out, there should be no error
Quoted 6 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +6
-0+ ret =0 ; + goto out; + } + + ret =iavf_clean_arq_element (hw, &event,NULL ); +if (!ret) {
drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1100
Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10
-0+ v_op = (enum virtchnl_ops )le32_to_cpu (event.desc.cookie_high); + v_ret = (enum iavf_status )le32_to_cpu (event.desc.cookie_low); + +iavf_virtchnl_completion (adapter, v_op, v_ret, + event.msg_buf, event.msg_len); + +memset (event.msg_buf,0 ,IAVF_MAX_AQ_BUF_SIZE ); + } + +usleep_range (1000 ,2000 );
no sleep after message received (ok to do on empty queue)
Quoted 36 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +36
-0+ } + + ret = -EAGAIN ; +out: +kfree (event.msg_buf); +return ret; +} + +/** +* iavf_mac_change_done - Check if MAC change completed +* @adapter: board private structure +* @data: MAC address being checked (as void *) +* +* Callback for iavf_poll_virtchnl_response() to check if MAC change completed. +* +* Returns true if MAC change completed, false otherwise +*/ +static bool iavf_mac_change_done (struct iavf_adapter *adapter,void *data) +{ +const u8 *addr = data; + +return iavf_is_mac_set_handled (adapter->netdev, addr); +} + +/** +* iavf_set_mac_sync - Synchronously change MAC address +* @adapter: board private structure +* @addr: MAC address to set +* +* Sends MAC change request to PF and polls admin queue for response. +* Caller must hold netdev_lock. This can sleep for up to 2.5 seconds. +* +* Returns 0 on success or error +*/ +static int iavf_set_mac_sync (struct iavf_adapter *adapter,const u8 *addr) +{
drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1146
Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10
-0+int ret; + +netdev_assert_locked (adapter->netdev); + + ret =iavf_add_ether_addrs (adapter); +if (ret) +return ret; + +return iavf_poll_virtchnl_response (adapter, iavf_mac_change_done, + (void *)addr,2500 );
this function looks elegant, thank you
I'm a little affraid that this model (if applied to other things than setting MAC) will skip some of our "much needed" logic in the watchdog.
I have not thinked about much yet.
unrelated: callback looks elegant, but for virtchnl, it is almost always the case that we wait for some VC OPCODE to come back, and this is just a number. It could be easily coded as a callback too, passing wanted value masked in pointer, but I would say that just passing a normal u32 param will be most clean
Re: [Intel-wired-lan] [PATCH net v2 3/4] iavf: send MAC change request synchronously
Hello Przemek,
Thank you for your comments.
I will try to include them in a next version.
Best regards
Jose Ignacio
Przemek Kitszel
maintainerRe: [Intel-wired-lan] [PATCH net v2 3/4] iavf: send MAC change request synchronously
In reply to Przemek KitszelI believe this is a move in right direction,
please also find some more comments
Quoted 6 lines
Quoted 6 lines
+/**
+ *iavf_poll_virtchnl_response- Poll admin queue for virtchnl response
+ * @adapter: board private structure
+ * @condition: callback to check if desired response received
+ * @cond_data: context data passed to condition callback
+ * @timeout_ms: maximum time to wait in milliseconds
Quoted 8 lines
Quoted 8 lines
+ *
+ * Polls admin queue and processes all messages until condition returns true
+ * or timeout expires. Caller must holdnetdev_lock. This can sleep for up to
+ *timeout_mswhile polling hardware.
+ *
+ * Returns 0 on success (condition met),-EAGAINon timeout or error
kdoc requires "Return:"
Quoted 2 lines
Quoted 2 lines
+ */
+static int iavf_poll_virtchnl_response(structiavf_adapter*adapter,
please move it to iavf_virtchnl.[ch], could be useful for other also, not need to move it then and loose your authorship in default blame view
one more thing is that this could be perhaps integrated with existing iavf_poll_virtchnl_msg(), which does not call iavf_virtchnl_completion(), but likely could
Quoted 15 lines
Quoted 2 lines
+ bool (*condition)(struct
iavf_adapter*, void *), + void*cond_data,this could be const, then no cast on the callsite
Quoted 10 lines
+ unsigned int
timeout_ms)drivers/net/ethernet/intel/iavf/iavf_main.c +9
-0+{ + struct iavf_hw *hw = &adapter->hw; + struct iavf_arq_event_info event; + enum virtchnl_ops v_op; + enum iavf_status v_ret; + unsigned long timeout; + int ret; + + netdev_assert_locked(adapter->netdev);
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1083
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +8
-0+ + event.buf_len = IAVF_MAX_AQ_BUF_SIZE; + event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); + if (!event.msg_buf) + return -ENOMEM; + + timeout = jiffies + msecs_to_jiffies(timeout_ms); + while (time_before(jiffies, timeout)) {
please consider do-while (after the rest of changes could be better)
Quoted 9 lines
Quoted 1 line
+ if (
condition(adapter, cond_data)) {if condition is met, but timed out, there should be no error
Quoted 5 lines
+ ret = 0;
+ goto out;
+ }
+
+ ret =iavf_clean_arq_element(hw, &event, NULL);
instead of NULL pass "pending" param, if not zero you could omit next sleep
Quoted 5 lines
Quoted 5 lines
+ if (!ret) {
+v_op= (enum
virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
+v_ret= (enum
iavf_status)le32_to_cpu(event.desc.cookie_low);
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1100
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +8
-0+ + iavf_virtchnl_completion(adapter, v_op, v_ret, + event.msg_buf, event.msg_len); + + memset(event.msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE); + } + + usleep_range(1000, 2000);
very old commit 9e3f23f44f32 ("i40e: reduce wait time for adminq command completion") said that 50usec is right amount to sleep between checks
Quoted 67 lines
no sleep after message received (ok to do on empty queue)
Quoted 39 lines
+ }
drivers/net/ethernet/intel/iavf/iavf_main.c +13
-0+ + ret = -EAGAIN; +out: + kfree(event.msg_buf); + return ret; +} + +/** +* iavf_mac_change_done - Check if MAC change completed +* @adapter: board private structure +* @data: MAC address being checked (as void *) +* +* Callback for iavf_poll_virtchnl_response() to check if MAC change completed.
+ *
+ * Returns true if MAC change completed, false otherwise
+ */
+static booliavf_mac_change_done(struct iavf_adapter *adapter, void *data)drivers/net/ethernet/intel/iavf/iavf_main.c +17
-0+{ + const u8 *addr = data; + + return iavf_is_mac_set_handled(adapter->netdev, addr); +} + +/** +* iavf_set_mac_sync - Synchronously change MAC address +* @adapter: board private structure +* @addr: MAC address to set +* +* Sends MAC change request to PF and polls admin queue for response. +* Caller must hold netdev_lock. This can sleep for up to 2.5 seconds. +* +* Returns 0 on success or error +*/ +static int iavf_set_mac_sync(struct iavf_adapter *adapter, const u8*addr)
drivers/net/ethernet/intel/iavf/iavf_main.c +1
-0+{drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_mac_set_handled(struct net_device *netdev, · line 1146
Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10
-0+ int ret; + + netdev_assert_locked(adapter->netdev); + + ret = iavf_add_ether_addrs(adapter); + if (ret) + return ret; + + return iavf_poll_virtchnl_response(adapter, iavf_mac_change_done, + (void *)addr, 2500);this function looks elegant, thank you
I'm a little affraid that this model (if applied to other things than setting MAC) will skip some of our "much needed" logic in the watchdog.
I have not thinked about much yet.
unrelated: callback looks elegant, but for virtchnl, it is almost always the case that we wait for some VC OPCODE to come back, and this is just a number. It could be easily coded as a callback too, passing wanted value masked in pointer, but I would say that just passing a normal u32 param will be most clean
Re: [Intel-wired-lan] [PATCH net v2 3/4] iavf: send MAC change request synchronously
Hello Przemek,
Thank you again for your comments.
I will try to include the new ones too in the next version. In addition, I will analyze the suggested integration with existing iavf_poll_virtchnl_msg() and possibly iavf_virtchnl_completion, but maybe better in a new patch of the series as a refactoring.
Best regards
Jose Ignacio
PATCH v2 4/4 ice: skip unnecessary VF reset when setting trust
In reply to Jose Ignacio Tornos MartinezSimilar to the i40e fix, ice_set_vf_trust() unconditionally calls ice_reset_vf() when the trust setting changes.
The ice driver already has logic to clean up MAC LLDP filters when removing trust, which is the only operation that requires filter synchronization. After this cleanup, the VF reset is only necessary if there were actually filters to remove.
For all other trust state changes (setting trust, or removing trust when no filters exist), the reset is unnecessary as filter synchronization happens naturally through normal VF operations.
Fix by only triggering the VF reset when removing trust AND filters were actually cleaned up (num_mac_lldp was non-zero).
This saves some time and eliminates unnecessary service disruption when changing VF trust settings if not necessary.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +9 -4
@@ -1399,14 +1399,19 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)mutex_lock (&vf->cfg_lock); -while (!trusted && vf->num_mac_lldp) -ice_vf_update_mac_lldp_num (vf,ice_get_vf_vsi (vf), false); - vf->trusted = trusted; -ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );dev_info (ice_pf_to_dev (pf),"VF %u is now %strusted\n" , vf_id, trusted ?"" :"un" ); +/* Only reset VF if removing trust and there are MAC LLDP filters +* to clean up. Reset is needed to ensure filter removal completes. +*/ +if (!trusted && vf->num_mac_lldp) { +while (vf->num_mac_lldp) +ice_vf_update_mac_lldp_num (vf,ice_get_vf_vsi (vf), false); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); + } +mutex_unlock (&vf->cfg_lock); out_put_vf:
Signature · 1 line
2.53.0
RE: [Intel-wired-lan] [PATCH net v2 4/4] ice: skip unnecessary VF reset when setting trust
Quoted 72 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jose Ignacio Tornos Martinez
Sent: Tuesday, April 7, 2026 6:52 PM
To: [email protected]
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jose Ignacio Tornos Martinez <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 4/4] ice: skip unnecessary VF reset when setting trustSimilar to the i40e fix,
ice_set_vf_trust()unconditionally callsice_reset_vf()when the trust setting changes.The ice driver already has logic to clean up MAC LLDP filters when removing trust, which is the only operation that requires filter synchronization. After this cleanup, the VF reset is only necessary if there were actually filters to remove.
For all other trust state changes (setting trust, or removing trust when no filters exist), the reset is unnecessary as filter synchronization happens naturally through normal VF operations.
Fix by only triggering the VF reset when removing trust AND filters were actually cleaned up (
num_mac_lldpwas non-zero).This saves some time and eliminates unnecessary service disruption when changing VF trust settings if not necessary.
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +1
-4@@ -1399,14 +1399,19 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)mutex_lock (&vf->cfg_lock); -while (!trusted && vf->num_mac_lldp) -ice_vf_update_mac_lldp_num (vf,ice_get_vf_vsi (vf), false); - vf->trusted = trusted; -ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );dev_info (ice_pf_to_dev (pf),"VF %u is now %strusted\n" , vf_id, trusted ?"" :"un" ); +/* Only reset VF if removing trust and there are MAC LLDP filters
drivers/net/ethernet/intel/ice/ice_sriov.c +1
-0+* to clean up. Reset is needed to ensure filter removal completes.
drivers/net/ethernet/intel/ice/ice_sriov.c +4
-0+*/ +if (!trusted && vf->num_mac_lldp) { +while (vf->num_mac_lldp) + ice_vf_update_mac_lldp_num(vf,
ice_get_vf_vsi(vf), false);drivers/net/ethernet/intel/ice/ice_sriov.c +3
-1+ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); + } +mutex_unlock (&vf->cfg_lock); out_put_vf: --
Quoted 1 line
2.53.0