AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/09/30 20:37 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series modifies the Cisco VIC Ethernet NIC driver (drivers/net/ethernet/cisco/enic/) to add SR-IOV V2 VF mailbox operations, packet filter configuration, and administrative MAC address handling. It also introduces a new helper function netif_rx_mode_schedule_update() in net/core/dev_addr_lists.c which is exclusively called by the enic driver. Cisco VIC is vendor-specific PCIe hardware that is not emulated in standard virtualized fuzzing environments (QEMU/GCE), and no existing core networking logic was altered. As a result, all modified code is structurally unreachable during fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/09/30 20:37 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 15bb502ae90afecfe2d1f1e6218447d80e7300eb\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Wed Sep 30 20:37:38 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h\nindex 7a509a0569900..80056b5f41245 100644\n--- a/drivers/net/ethernet/cisco/enic/enic.h\n+++ b/drivers/net/ethernet/cisco/enic/enic.h\n@@ -239,6 +239,8 @@ enum enic_vf_type {\n };\n \n /* Per-instance private data structure */\n+struct enic_mac_addr;\n+\n struct enic {\n \tstruct net_device *netdev;\n \tstruct pci_dev *pdev;\n@@ -303,8 +305,26 @@ struct enic {\n \t * left the resources freed.\n \t */\n \tbool admin_chan_up;\n-\t/* set on send timeout; cleared on channel re-open */\n+\t/* Blocks sends while the channel is closed or awaiting recovery. */\n \tbool mbox_send_disabled;\n+\t/* A send timeout leaves a descriptor hardware-owned.  Do not reopen the\n+\t * channel during this device lifetime until reset/DMA fencing is proven.\n+\t */\n+\tbool mbox_tx_poisoned;\n+\t/* After a lost or inconsistent reply, the VF cannot know whether the PF\n+\t * applied the request. Reconnect during the next open or reset.\n+\t */\n+\tbool vf_mbox_reconnect_required;\n+\t/* Suppress self-requeue while a reset worker is already attempting the\n+\t * reconnect. A failed handshake remains quarantined until a later external\n+\t * recovery event or administrative close/open.\n+\t */\n+\tbool vf_mbox_recovery_active;\n+\tu32 vf_mbox_fault_generation;\n+\t/* One slow-path-owned predicate keeps the RX hot path fail-closed while\n+\t * VF registration is lost or receive state may not match the PF.\n+\t */\n+\tbool vf_rx_quarantined;\n \tstruct vnic_wq admin_wq;\n \tstruct vnic_rq admin_rq;\n \tstruct vnic_cq admin_cq[2];\n@@ -325,6 +345,13 @@ struct enic {\n \tspinlock_t vf_link_state_lock;\n \tenum enic_vf_link_state vf_link_state;\n \tbool vf_link_running;\n+\t/* Last station address which may still be installed at the PF. */\n+\tu8 vf_station_addr[ETH_ALEN] __aligned(2);\n+\tbool vf_station_addr_valid;\n+\t/* Tracks a completely opened V2 VF datapath.  An internal reset can stop\n+\t * it while netif_running() remains true, then fail before reopen.\n+\t */\n+\tbool vf_datapath_open;\n \n \t/* MBOX protocol state — mbox_lock serializes admin WQ sends */\n \tstruct mutex mbox_lock;\n@@ -335,9 +362,34 @@ struct enic {\n \t * the requester.\n \t */\n \tstruct completion mbox_comp;\n+\tstruct mutex vf_mbox_request_lock; /* serializes VF request lifetimes */\n \tspinlock_t mbox_state_lock;\t/* protects expected reply state */\n+\tspinlock_t vf_ack_lock;\t\t/* protects vf_ack_list */\n+\tstruct list_head vf_ack_list;\n+\tstruct work_struct vf_ack_work;\n+\tunsigned int vf_ack_count;\n+\tstruct delayed_work vf_admin_mac_work;\n+\tspinlock_t vf_admin_mac_lock;\t/* protects pending admin MAC */\n+\tu8 vf_admin_mac[ETH_ALEN];\n+\tu8 vf_admin_mac_random_addr[ETH_ALEN];\n+\tbool vf_admin_mac_pending;\n+\tbool vf_admin_mac_random_valid;\n+\tbool vf_admin_mac_work_enabled;\n+\tbool vf_admin_mac_recovery_attempted;\n+\tu32 vf_admin_mac_generation;\n+\tu8 vf_admin_mac_retries;\n \tu64 mbox_expected_msg_num;\n \tu8 mbox_expected_reply;\n+\tint mbox_reply_status;\n+\tu16 mbox_reply_filter_flags;\n+\t/* The request mutex keeps this caller-owned reply array alive until the\n+\t * matching reply handler has copied all per-address result flags.\n+\t */\n+\tstruct enic_mac_addr *mbox_reply_mac_addrs;\n+\tu16 mbox_reply_mac_count;\n+\tu16 vf_pkt_filter_requested;\n+\tu16 vf_pkt_filter_applied;\n+\tbool vf_pkt_filter_valid;\n \tbool mbox_initialized;\n \n \t/* PF: per-VF MBOX state, allocated when SRIOV V2 is enabled */\n@@ -462,6 +514,10 @@ static inline int enic_dma_map_check(struct enic *enic, dma_addr_t dma_addr)\n }\n \n void enic_reset_addr_lists(struct enic *enic);\n+void enic_vf_admin_mac_notify(struct enic *enic, const u8 *addr);\n+void enic_vf_admin_mac_quiesce(struct enic *enic);\n+void enic_vf_admin_mac_rearm(struct enic *enic);\n+void enic_vf_admin_mac_purge(struct enic *enic);\n int enic_sriov_enabled(struct enic *enic);\n int enic_is_valid_vf(struct enic *enic, int vf);\n int enic_is_dynamic(struct enic *enic);\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_admin.c b/drivers/net/ethernet/cisco/enic/enic_admin.c\nindex 61c82b48044d0..5e52d4da8d3c9 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_admin.c\n+++ b/drivers/net/ethernet/cisco/enic/enic_admin.c\n@@ -132,14 +132,22 @@ unsigned int enic_admin_wq_cq_service(struct enic *enic)\n  */\n #define ENIC_ADMIN_MSG_MAX\t256\n \n+static void enic_admin_rx_lost(struct enic *enic)\n+{\n+\tif (enic_is_sriov_vf_v2(enic))\n+\t\tenic_mbox_vf_require_reconnect(enic);\n+}\n+\n static void enic_admin_msg_enqueue(struct enic *enic, void *buf,\n \t\t\t\t   unsigned int len)\n {\n \tstruct enic_admin_msg *msg;\n \n \tmsg = kmalloc_flex(*msg, data, len);\n-\tif (!msg)\n+\tif (!msg) {\n+\t\tenic_admin_rx_lost(enic);\n \t\treturn;\n+\t}\n \n \tmsg-\u003elen = len;\n \tmemcpy(msg-\u003edata, buf, len);\n@@ -152,6 +160,7 @@ static void enic_admin_msg_enqueue(struct enic *enic, void *buf,\n \t\t\tnetdev_warn(enic-\u003enetdev,\n \t\t\t\t    \"admin msg backlog full (%u); dropping\\n\",\n \t\t\t\t    ENIC_ADMIN_MSG_MAX);\n+\t\tenic_admin_rx_lost(enic);\n \t\treturn;\n \t}\n \tlist_add_tail(\u0026msg-\u003elist, \u0026enic-\u003eadmin_msg_list);\n@@ -194,8 +203,10 @@ unsigned int enic_admin_rq_cq_service(struct enic *enic)\n \t\trq_desc = desc;\n \t\tbwf = le16_to_cpu(rq_desc-\u003ebytes_written_flags);\n \t\tbytes_written = bwf \u0026 CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;\n-\t\tif (bytes_written \u003e buf-\u003elen)\n+\t\tif (bytes_written \u003e buf-\u003elen) {\n+\t\t\tenic_admin_rx_lost(enic);\n \t\t\tgoto next_desc;\n+\t\t}\n \n \t\tdma_sync_single_for_cpu(\u0026enic-\u003epdev-\u003edev,\n \t\t\t\t\tbuf-\u003edma_addr, buf-\u003elen,\n@@ -210,11 +221,13 @@ unsigned int enic_admin_rq_cq_service(struct enic *enic)\n \t\tif (bwf \u0026 CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) {\n \t\t\tnetdev_warn_once(enic-\u003enetdev,\n \t\t\t\t\t \"admin RQ: truncated message dropped\\n\");\n+\t\t\tenic_admin_rx_lost(enic);\n \t\t\tgoto next_desc;\n \t\t}\n \t\tif (!(rq_desc-\u003eflags \u0026 CQ_ENET_RQ_DESC_FLAGS_FCS_OK)) {\n \t\t\tnetdev_warn_once(enic-\u003enetdev,\n \t\t\t\t\t \"admin RQ: bad FCS, dropping message\\n\");\n+\t\t\tenic_admin_rx_lost(enic);\n \t\t\tgoto next_desc;\n \t\t}\n \n@@ -534,6 +547,11 @@ int enic_admin_channel_open(struct enic *enic)\n \n \tif (!enic-\u003ehas_admin_channel)\n \t\treturn -ENODEV;\n+\tif (READ_ONCE(enic-\u003embox_tx_poisoned)) {\n+\t\tnetdev_err(enic-\u003enetdev,\n+\t\t\t   \"Refusing to reopen admin channel after send timeout\\n\");\n+\t\treturn -EIO;\n+\t}\n \n \t/* Keep MBOX sends disabled for the entire open sequence.  It is\n \t * cleared only after every resource is allocated and enabled below,\n@@ -623,6 +641,8 @@ void enic_admin_channel_close(struct enic *enic)\n {\n \tint err;\n \n+\tif (enic_is_sriov_vf_v2(enic))\n+\t\tenic_vf_admin_mac_quiesce(enic);\n \tif (!enic-\u003ehas_admin_channel)\n \t\treturn;\n \n@@ -641,6 +661,11 @@ void enic_admin_channel_close(struct enic *enic)\n \tenic_admin_teardown_intr(enic);\n \tcancel_work_sync(\u0026enic-\u003elink_notify_work);\n \tcancel_work_sync(\u0026enic-\u003eadmin_msg_work);\n+\t/* admin_msg_work is the sole VF ACK producer.  Drain it before the ACK\n+\t * worker so an enqueue cannot race the final cancel and queue purge.\n+\t */\n+\tif (enic_is_sriov_vf_v2(enic))\n+\t\tenic_mbox_vf_ack_cancel(enic);\n \tenic_admin_msg_drain(enic);\n \n \tenic_admin_qp_type_set(enic, QP_DISABLE);\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_dev.c b/drivers/net/ethernet/cisco/enic/enic_dev.c\nindex 659787f73cf18..48c1ca9b40fb2 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_dev.c\n+++ b/drivers/net/ethernet/cisco/enic/enic_dev.c\n@@ -32,6 +32,17 @@ int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats)\n \treturn err;\n }\n \n+int enic_dev_get_mac_addr(struct enic *enic, u8 *mac_addr)\n+{\n+\tint err;\n+\n+\tspin_lock_bh(\u0026enic-\u003edevcmd_lock);\n+\terr = vnic_dev_get_mac_addr(enic-\u003evdev, mac_addr);\n+\tspin_unlock_bh(\u0026enic-\u003edevcmd_lock);\n+\n+\treturn err;\n+}\n+\n int enic_dev_add_station_addr(struct enic *enic)\n {\n \tint err;\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_dev.h b/drivers/net/ethernet/cisco/enic/enic_dev.h\nindex 698d0cb020644..66d0e51681f5a 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_dev.h\n+++ b/drivers/net/ethernet/cisco/enic/enic_dev.h\n@@ -26,6 +26,7 @@\n \n int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info);\n int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats);\n+int enic_dev_get_mac_addr(struct enic *enic, u8 *mac_addr);\n int enic_dev_add_station_addr(struct enic *enic);\n int enic_dev_del_station_addr(struct enic *enic);\n int enic_dev_packet_filter(struct enic *enic, int directed, int multicast,\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c\nindex 9086e6dd558aa..382bac6669bf3 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_main.c\n+++ b/drivers/net/ethernet/cisco/enic/enic_main.c\n@@ -71,6 +71,8 @@\n #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2   0x02b7  /* enet SRIOV V2 VF */\n #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_USNIC 0x00cf /* enet USNIC VF */\n \n+static int __enic_stop(struct net_device *netdev, bool remove_vf_station);\n+\n /* Supported devices */\n static const struct pci_device_id enic_id_table[] = {\n \t{ PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) },\n@@ -87,6 +89,9 @@ MODULE_DEVICE_TABLE(pci, enic_id_table);\n \n #define ENIC_LARGE_PKT_THRESHOLD\t\t1000\n #define ENIC_MAX_COALESCE_TIMERS\t\t10\n+#define ENIC_VF_ADMIN_MAC_MAX_RETRIES\t\t4\n+#define ENIC_VF_ADMIN_MAC_RETRY_MS\t\t100\n+#define ENIC_VF_ADMIN_MAC_REFRESH_RETRIES\t3\n /*  Interrupt moderation table, which will be used to decide the\n  *  coalescing timer values\n  *  {rx_rate in Mbps, mapping percentage of the range}\n@@ -1038,12 +1043,15 @@ void enic_reset_addr_lists(struct enic *enic)\n {\n \tstruct net_device *netdev = enic-\u003enetdev;\n \n+\tnetif_addr_lock_bh(netdev);\n \t__dev_uc_unsync(netdev, NULL);\n \t__dev_mc_unsync(netdev, NULL);\n+\tnetif_addr_unlock_bh(netdev);\n \n \tenic-\u003emc_count = 0;\n \tenic-\u003euc_count = 0;\n \tenic-\u003eflags = 0;\n+\tenic-\u003evf_pkt_filter_valid = false;\n }\n \n static int enic_set_mac_addr(struct net_device *netdev, char *addr)\n@@ -1063,6 +1071,465 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)\n \treturn 0;\n }\n \n+static void enic_vf_station_recovery_required(struct enic *enic)\n+{\n+\tenic_mbox_vf_require_reconnect(enic);\n+}\n+\n+static void enic_vf_station_addr_set(struct enic *enic, const u8 *addr)\n+{\n+\tether_addr_copy(enic-\u003evf_station_addr, addr);\n+\tenic-\u003evf_station_addr_valid = true;\n+}\n+\n+static int enic_vf_keep_nonstation_sync(struct net_device *netdev,\n+\t\t\t\t\tconst u8 *addr)\n+{\n+\tstruct enic *enic = netdev_priv(netdev);\n+\n+\tif (!ether_addr_equal(addr, enic-\u003evf_station_addr))\n+\t\treturn -ENOENT;\n+\tif (WARN_ON_ONCE(!enic-\u003euc_count))\n+\t\treturn 0;\n+\tenic-\u003euc_count--;\n+\n+\treturn 0;\n+}\n+\n+static void enic_vf_station_sync_reset(struct enic *enic)\n+{\n+\tif (!enic-\u003evf_station_addr_valid)\n+\t\treturn;\n+\n+\t/* The PF keys its MAC ledger by address. A station entry is also the\n+\t * receive filter for that address and must not retain a second core\n+\t * synchronization reference which could later delete the station.\n+\t */\n+\tnetif_addr_lock_bh(enic-\u003enetdev);\n+\t__dev_uc_unsync(enic-\u003enetdev, enic_vf_keep_nonstation_sync);\n+\tnetif_addr_unlock_bh(enic-\u003enetdev);\n+}\n+\n+static int enic_vf_station_addr_del(struct enic *enic)\n+{\n+\tint err;\n+\n+\tif (!enic-\u003evf_station_addr_valid)\n+\t\treturn 0;\n+\n+\terr = enic_mbox_vf_add_del_mac(enic, enic-\u003evf_station_addr,\n+\t\t\t\t       false, true);\n+\tif (!err) {\n+\t\tenic-\u003evf_station_addr_valid = false;\n+\t} else if (READ_ONCE(enic-\u003embox_tx_poisoned)) {\n+\t\tenic_mbox_vf_link_state_set_running(enic, false);\n+\t} else if (err == -EACCES) {\n+\t\t/* A definitive rejected DELETE leaves an unrequested station\n+\t\t * filter installed. Fresh registration is the cleanup boundary.\n+\t\t */\n+\t\tenic_vf_station_recovery_required(enic);\n+\t}\n+\n+\treturn err;\n+}\n+\n+/* End every replacement with an equal-address DEL+ADD pair. A bare ADD could\n+ * report DUPLICATE for a secondary exact filter without applying the current\n+ * station-address policy. If another station is tracked, delete it first in\n+ * the same compound request.\n+ */\n+static int enic_vf_station_addr_replace(struct enic *enic, const u8 *addr)\n+{\n+\tstruct enic_mac_addr macs[3] = {};\n+\tbool all_deletes_skipped = true;\n+\tbool deletes_converged = true;\n+\tu16 num_macs = 0;\n+\tunsigned int i;\n+\tu16 result;\n+\tint err;\n+\n+\tif (enic-\u003evf_station_addr_valid \u0026\u0026\n+\t    !ether_addr_equal(enic-\u003evf_station_addr, addr)) {\n+\t\tether_addr_copy(macs[num_macs].addr, enic-\u003evf_station_addr);\n+\t\tmacs[num_macs++].flags =\n+\t\t\tcpu_to_le16(ENIC_MAC_ADDR_FLAG_STATION);\n+\t}\n+\tether_addr_copy(macs[num_macs].addr, addr);\n+\tmacs[num_macs++].flags = cpu_to_le16(ENIC_MAC_ADDR_FLAG_STATION);\n+\tether_addr_copy(macs[num_macs].addr, addr);\n+\tmacs[num_macs++].flags = cpu_to_le16(ENIC_MAC_ADDR_FLAG_ADD |\n+\t\t\t\t\t    ENIC_MAC_ADDR_FLAG_STATION);\n+\n+\terr = enic_mbox_vf_add_del_macs(enic, macs, num_macs);\n+\tif (err) {\n+\t\tif (READ_ONCE(enic-\u003embox_tx_poisoned))\n+\t\t\tenic_mbox_vf_link_state_set_running(enic, false);\n+\t\treturn err;\n+\t}\n+\n+\tfor (i = 0; i \u003c num_macs - 1; i++) {\n+\t\tresult = le16_to_cpu(macs[i].flags) \u0026\n+\t\t\t ENIC_MAC_ADDR_FLAG_REPLY_MASK;\n+\t\tif (result != ENIC_MAC_ADDR_FLAG_SKIPPED)\n+\t\t\tall_deletes_skipped = false;\n+\t\tif (result \u0026\u0026 result != ENIC_MAC_ADDR_FLAG_NOT_FOUND)\n+\t\t\tdeletes_converged = false;\n+\t}\n+\tresult = le16_to_cpu(macs[num_macs - 1].flags) \u0026\n+\t\t ENIC_MAC_ADDR_FLAG_REPLY_MASK;\n+\tif (deletes_converged \u0026\u0026 !result)\n+\t\treturn 0;\n+\n+\t/* A policy-rejected ADD can be reported with all preceding DELETEs\n+\t * skipped. No operation changed state in that coherent result tuple.\n+\t */\n+\tif (all_deletes_skipped \u0026\u0026 result) {\n+\t\tif (result \u0026 (ENIC_MAC_ADDR_FLAG_DUPLICATE |\n+\t\t\t      ENIC_MAC_ADDR_FLAG_PERMANENT_MASK))\n+\t\t\treturn -EACCES;\n+\t\treturn -EIO;\n+\t}\n+\n+\t/* After any other partial or contradictory result, the VF does not know\n+\t * which station address the PF kept. Re-register before accepting traffic.\n+\t */\n+\tenic_vf_station_recovery_required(enic);\n+\tfor (i = 0; i \u003c num_macs; i++)\n+\t\tif (le16_to_cpu(macs[i].flags) \u0026\n+\t\t    ENIC_MAC_ADDR_FLAG_PERMANENT_MASK)\n+\t\t\treturn -EACCES;\n+\n+\treturn -EIO;\n+}\n+\n+static void enic_vf_admin_mac_cache_selected(struct enic *enic,\n+\t\t\t\t\t     const u8 *addr)\n+{\n+\t/* A zero administrative policy delegates the operational address to\n+\t * the VF. Preserve a successful user selection across reconnects.\n+\t */\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tif (is_zero_ether_addr(enic-\u003evf_admin_mac)) {\n+\t\tether_addr_copy(enic-\u003evf_admin_mac_random_addr, addr);\n+\t\tenic-\u003evf_admin_mac_random_valid = true;\n+\t}\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+}\n+\n+static void enic_vf_admin_mac_work(struct work_struct *work)\n+{\n+\tstruct enic *enic = container_of(to_delayed_work(work), struct enic,\n+\t\t\t\t\t vf_admin_mac_work);\n+\tu8 policy[ETH_ALEN];\n+\tu8 selected[ETH_ALEN];\n+\tunsigned long delay = 0;\n+\tu32 generation = 0;\n+\tbool changed;\n+\tbool mutated = false;\n+\tbool reschedule = false;\n+\tbool station_installed = false;\n+\tbool stale = false;\n+\tbool zero_policy;\n+\tbool pending;\n+\tint err = 0;\n+\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tpending = enic-\u003evf_admin_mac_pending \u0026\u0026\n+\t\tenic-\u003evf_admin_mac_work_enabled;\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tif (!pending)\n+\t\treturn;\n+\n+\t/* Teardown owns RTNL while synchronously cancelling this work. Do not\n+\t * block that owner.\n+\t */\n+\tif (!rtnl_trylock()) {\n+\t\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\tif (enic-\u003evf_admin_mac_pending \u0026\u0026\n+\t\t    enic-\u003evf_admin_mac_work_enabled)\n+\t\t\tmod_delayed_work(system_wq, \u0026enic-\u003evf_admin_mac_work,\n+\t\t\t\t\t msecs_to_jiffies(10));\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\treturn;\n+\t}\n+\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tpending = enic-\u003evf_admin_mac_pending \u0026\u0026\n+\t\tenic-\u003evf_admin_mac_work_enabled;\n+\tif (pending) {\n+\t\tether_addr_copy(policy, enic-\u003evf_admin_mac);\n+\t\tgeneration = enic-\u003evf_admin_mac_generation;\n+\t\tzero_policy = is_zero_ether_addr(policy);\n+\t\tif (zero_policy \u0026\u0026 enic-\u003evf_admin_mac_random_valid)\n+\t\t\tether_addr_copy(selected,\n+\t\t\t\t\tenic-\u003evf_admin_mac_random_addr);\n+\t}\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tif (!pending)\n+\t\tgoto unlock;\n+\n+\tif (zero_policy \u0026\u0026 !READ_ONCE(enic-\u003evf_admin_mac_random_valid)) {\n+\t\teth_random_addr(selected);\n+\t\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\tif (!enic-\u003evf_admin_mac_pending ||\n+\t\t    !enic-\u003evf_admin_mac_work_enabled ||\n+\t\t    enic-\u003evf_admin_mac_generation != generation ||\n+\t\t    !is_zero_ether_addr(enic-\u003evf_admin_mac)) {\n+\t\t\tstale = true;\n+\t\t} else if (enic-\u003evf_admin_mac_random_valid) {\n+\t\t\tether_addr_copy(selected,\n+\t\t\t\t\tenic-\u003evf_admin_mac_random_addr);\n+\t\t} else {\n+\t\t\tether_addr_copy(enic-\u003evf_admin_mac_random_addr, selected);\n+\t\t\tenic-\u003evf_admin_mac_random_valid = true;\n+\t\t}\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\tif (stale)\n+\t\t\tgoto unlock;\n+\t} else if (!zero_policy) {\n+\t\tether_addr_copy(selected, policy);\n+\t}\n+\n+\tif (!netif_device_present(enic-\u003enetdev) ||\n+\t    !READ_ONCE(enic-\u003evf_registered)) {\n+\t\terr = -EAGAIN;\n+\t\tgoto unlock;\n+\t}\n+\n+\t/* A nonzero notification describes a station address the PF has already\n+\t * installed. Zero delegates selection to the VF, which registers the\n+\t * selected random address through the policy-safe replacement request.\n+\t */\n+\tif (!READ_ONCE(enic-\u003evf_datapath_open)) {\n+\t\tstation_installed = !zero_policy \u0026\u0026\n+\t\t\t(!enic-\u003evf_station_addr_valid ||\n+\t\t\t ether_addr_equal(enic-\u003evf_station_addr, selected));\n+\t} else if (zero_policy) {\n+\t\tmutated = true;\n+\t\terr = enic_vf_station_addr_replace(enic, selected);\n+\t\tstation_installed = !err;\n+\t} else if (enic-\u003evf_station_addr_valid \u0026\u0026\n+\t\t   !ether_addr_equal(enic-\u003evf_station_addr, selected)) {\n+\t\tmutated = true;\n+\t\terr = enic_vf_station_addr_del(enic);\n+\t\tstation_installed = !err;\n+\t} else {\n+\t\tstation_installed = true;\n+\t}\n+\tif (err)\n+\t\tgoto unlock;\n+\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tif (!enic-\u003evf_admin_mac_pending ||\n+\t    !enic-\u003evf_admin_mac_work_enabled ||\n+\t    enic-\u003evf_admin_mac_generation != generation) {\n+\t\tstale = true;\n+\t\t/* If policy changed while the request was running, the completed\n+\t\t * station change may no longer match it. Record recovery while holding\n+\t\t * vf_admin_mac_lock, which also protects VF worker shutdown. Teardown\n+\t\t * therefore either suppresses the update or sees it first, and already\n+\t\t * uses unregister/register to clear old state.\n+\t\t */\n+\t\tif (mutated \u0026\u0026 enic-\u003evf_admin_mac_work_enabled)\n+\t\t\tenic_vf_station_recovery_required(enic);\n+\t} else {\n+\t\tenic-\u003evf_admin_mac_pending = false;\n+\t\tenic-\u003evf_admin_mac_retries = 0;\n+\t\tenic-\u003evf_admin_mac_recovery_attempted = false;\n+\t\tif (!zero_policy)\n+\t\t\tenic-\u003evf_admin_mac_random_valid = false;\n+\t}\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tif (stale)\n+\t\tgoto unlock;\n+\n+\tchanged = !ether_addr_equal(enic-\u003enetdev-\u003edev_addr, selected);\n+\tenic_vf_station_sync_reset(enic);\n+\teth_hw_addr_set(enic-\u003enetdev, selected);\n+\tif (!zero_policy || changed)\n+\t\tenic-\u003enetdev-\u003eaddr_assign_type = zero_policy ?\n+\t\t\tNET_ADDR_RANDOM : NET_ADDR_SET;\n+\tether_addr_copy(enic-\u003emac_addr, selected);\n+\tif (station_installed)\n+\t\tenic_vf_station_addr_set(enic, selected);\n+\tenic_vf_station_sync_reset(enic);\n+\tif (enic-\u003enetdev-\u003ereg_state == NETREG_REGISTERED) {\n+\t\tif (changed)\n+\t\t\tcall_netdevice_notifiers(NETDEV_CHANGEADDR,\n+\t\t\t\t\t\t enic-\u003enetdev);\n+\t\tnetif_rx_mode_schedule_update(enic-\u003enetdev);\n+\t}\n+\tnetdev_info(enic-\u003enetdev, \"MBOX: admin MAC set to %pM\\n\", selected);\n+\n+unlock:\n+\trtnl_unlock();\n+\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tif (err \u0026\u0026 enic-\u003evf_admin_mac_pending \u0026\u0026\n+\t    enic-\u003evf_admin_mac_work_enabled \u0026\u0026\n+\t    generation == enic-\u003evf_admin_mac_generation \u0026\u0026\n+\t    !READ_ONCE(enic-\u003embox_send_disabled)) {\n+\t\tif (enic-\u003evf_admin_mac_retries \u003c\n+\t\t    ENIC_VF_ADMIN_MAC_MAX_RETRIES) {\n+\t\t\tenic-\u003evf_admin_mac_retries++;\n+\t\t\treschedule = true;\n+\t\t\tdelay = msecs_to_jiffies(ENIC_VF_ADMIN_MAC_RETRY_MS);\n+\t\t} else if (!enic-\u003evf_admin_mac_recovery_attempted) {\n+\t\t\tenic-\u003evf_admin_mac_recovery_attempted = true;\n+\t\t\t/* vf_admin_mac_lock also protects VF worker shutdown. */\n+\t\t\tenic_vf_station_recovery_required(enic);\n+\t\t}\n+\t}\n+\tif (enic-\u003evf_admin_mac_pending \u0026\u0026\n+\t    enic-\u003evf_admin_mac_work_enabled \u0026\u0026\n+\t    generation != enic-\u003evf_admin_mac_generation) {\n+\t\treschedule = true;\n+\t\tdelay = 0;\n+\t}\n+\tif (enic-\u003evf_admin_mac_pending \u0026\u0026 reschedule)\n+\t\tmod_delayed_work(system_wq, \u0026enic-\u003evf_admin_mac_work, delay);\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+}\n+\n+void enic_vf_admin_mac_notify(struct enic *enic, const u8 *addr)\n+{\n+\tbool new_policy;\n+\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tnew_policy = !enic-\u003evf_admin_mac_pending ||\n+\t\t!ether_addr_equal(enic-\u003evf_admin_mac, addr);\n+\tif (new_policy) {\n+\t\tether_addr_copy(enic-\u003evf_admin_mac, addr);\n+\t\tif (!is_zero_ether_addr(addr))\n+\t\t\tenic-\u003evf_admin_mac_random_valid = false;\n+\t\tenic-\u003evf_admin_mac_pending = true;\n+\t\tenic-\u003evf_admin_mac_generation++;\n+\t\tenic-\u003evf_admin_mac_retries = 0;\n+\t\tenic-\u003evf_admin_mac_recovery_attempted = false;\n+\t}\n+\tif (new_policy \u0026\u0026 enic-\u003evf_admin_mac_work_enabled)\n+\t\tmod_delayed_work(system_wq, \u0026enic-\u003evf_admin_mac_work, 0);\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+}\n+\n+void enic_vf_admin_mac_quiesce(struct enic *enic)\n+{\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tenic-\u003evf_admin_mac_work_enabled = false;\n+\tenic-\u003evf_admin_mac_generation++;\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tcancel_delayed_work_sync(\u0026enic-\u003evf_admin_mac_work);\n+}\n+\n+void enic_vf_admin_mac_rearm(struct enic *enic)\n+{\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tenic-\u003evf_admin_mac_work_enabled = true;\n+\tif (enic-\u003evf_admin_mac_pending)\n+\t\tmod_delayed_work(system_wq, \u0026enic-\u003evf_admin_mac_work, 0);\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+}\n+\n+void enic_vf_admin_mac_purge(struct enic *enic)\n+{\n+\tenic_vf_admin_mac_quiesce(enic);\n+\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\tenic-\u003evf_admin_mac_pending = false;\n+\tenic-\u003evf_admin_mac_random_valid = false;\n+\tenic-\u003evf_admin_mac_recovery_attempted = false;\n+\tenic-\u003evf_admin_mac_retries = 0;\n+\tenic-\u003evf_admin_mac_generation++;\n+\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+}\n+\n+/* CMD_GET_MAC_ADDR is the PF-owned policy store. Re-read it after REGISTER so\n+ * a lost notification cannot leave the VF using stale administrative policy.\n+ */\n+static int enic_vf_admin_mac_refresh(struct enic *enic)\n+{\n+\tu8 previous_policy[ETH_ALEN];\n+\tu8 random_addr[ETH_ALEN];\n+\tu8 selected[ETH_ALEN];\n+\tu8 policy[ETH_ALEN];\n+\tu32 generation;\n+\tbool apply_policy;\n+\tbool changed;\n+\tbool pending;\n+\tbool policy_changed;\n+\tbool zero_policy;\n+\tunsigned int attempt;\n+\tint err;\n+\n+\tfor (attempt = 0; attempt \u003c ENIC_VF_ADMIN_MAC_REFRESH_RETRIES;\n+\t     attempt++) {\n+\t\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\tgeneration = enic-\u003evf_admin_mac_generation;\n+\t\tpending = enic-\u003evf_admin_mac_pending;\n+\t\tether_addr_copy(previous_policy, enic-\u003evf_admin_mac);\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\n+\t\terr = enic_dev_get_mac_addr(enic, policy);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t\tif (is_multicast_ether_addr(policy))\n+\t\t\treturn -EADDRNOTAVAIL;\n+\n+\t\tzero_policy = is_zero_ether_addr(policy);\n+\t\tif (zero_policy)\n+\t\t\teth_random_addr(random_addr);\n+\n+\t\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\tif (enic-\u003evf_admin_mac_generation != generation) {\n+\t\t\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tpolicy_changed = !ether_addr_equal(previous_policy, policy);\n+\t\tapply_policy = pending || policy_changed ||\n+\t\t\t!is_valid_ether_addr(enic-\u003enetdev-\u003edev_addr) ||\n+\t\t\t(!zero_policy \u0026\u0026\n+\t\t\t !ether_addr_equal(enic-\u003enetdev-\u003edev_addr, policy));\n+\t\tif (!apply_policy) {\n+\t\t\tether_addr_copy(selected, enic-\u003enetdev-\u003edev_addr);\n+\t\t\tif (zero_policy) {\n+\t\t\t\tether_addr_copy(enic-\u003evf_admin_mac_random_addr,\n+\t\t\t\t\t\tselected);\n+\t\t\t\tenic-\u003evf_admin_mac_random_valid = true;\n+\t\t\t}\n+\t\t} else if (zero_policy \u0026\u0026 enic-\u003evf_admin_mac_random_valid) {\n+\t\t\tether_addr_copy(selected,\n+\t\t\t\t\tenic-\u003evf_admin_mac_random_addr);\n+\t\t} else if (zero_policy) {\n+\t\t\tether_addr_copy(selected, random_addr);\n+\t\t\tether_addr_copy(enic-\u003evf_admin_mac_random_addr, selected);\n+\t\t\tenic-\u003evf_admin_mac_random_valid = true;\n+\t\t} else {\n+\t\t\tether_addr_copy(selected, policy);\n+\t\t\tenic-\u003evf_admin_mac_random_valid = false;\n+\t\t}\n+\t\tether_addr_copy(enic-\u003evf_admin_mac, policy);\n+\t\tenic-\u003evf_admin_mac_pending = false;\n+\t\tenic-\u003evf_admin_mac_recovery_attempted = false;\n+\t\tenic-\u003evf_admin_mac_retries = 0;\n+\t\tenic-\u003evf_admin_mac_generation++;\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\n+\t\tchanged = !ether_addr_equal(enic-\u003enetdev-\u003edev_addr, selected);\n+\t\teth_hw_addr_set(enic-\u003enetdev, selected);\n+\t\tif (!zero_policy || changed)\n+\t\t\tenic-\u003enetdev-\u003eaddr_assign_type = zero_policy ?\n+\t\t\t\tNET_ADDR_RANDOM : NET_ADDR_SET;\n+\t\tether_addr_copy(enic-\u003emac_addr, selected);\n+\t\tif (changed \u0026\u0026 enic-\u003enetdev-\u003ereg_state == NETREG_REGISTERED)\n+\t\t\tcall_netdevice_notifiers(NETDEV_CHANGEADDR,\n+\t\t\t\t\t\t enic-\u003enetdev);\n+\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EAGAIN;\n+}\n+\n static int enic_set_mac_address_dynamic(struct net_device *netdev, void *p)\n {\n \tstruct enic *enic = netdev_priv(netdev);\n@@ -1070,6 +1537,53 @@ static int enic_set_mac_address_dynamic(struct net_device *netdev, void *p)\n \tchar *addr = saddr-\u003esa_data;\n \tint err;\n \n+\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\tif (!is_valid_ether_addr(addr))\n+\t\t\treturn -EADDRNOTAVAIL;\n+\n+\t\tspin_lock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\terr = is_valid_ether_addr(enic-\u003evf_admin_mac) \u0026\u0026\n+\t\t      !ether_addr_equal(enic-\u003evf_admin_mac, addr);\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_admin_mac_lock);\n+\t\tif (err)\n+\t\t\treturn -EPERM;\n+\t\tif (ether_addr_equal(addr, netdev-\u003edev_addr))\n+\t\t\treturn 0;\n+\n+\t\tif (enic-\u003evf_datapath_open \u0026\u0026\n+\t\t    !READ_ONCE(enic-\u003evf_registered))\n+\t\t\treturn -ENODEV;\n+\n+\t\t/* An internal reset keeps IFF_UP set while its failed reopen leaves\n+\t\t * the datapath closed. Cache the requested address in that state; the\n+\t\t * next successful open installs it together with the datapath.\n+\t\t */\n+\t\tif (!enic-\u003evf_datapath_open) {\n+\t\t\terr = enic_set_mac_addr(netdev, addr);\n+\t\t\tif (!err)\n+\t\t\t\tenic_vf_admin_mac_cache_selected(enic, addr);\n+\t\t\treturn err;\n+\t\t}\n+\n+\t\t/* Keep the old software address visible until the complete station\n+\t\t * replacement proves convergence.\n+\t\t */\n+\t\terr = enic_vf_station_addr_replace(enic, addr);\n+\t\tif (err)\n+\t\t\treturn err;\n+\n+\t\tenic_vf_station_sync_reset(enic);\n+\t\terr = enic_set_mac_addr(netdev, addr);\n+\t\tif (!err) {\n+\t\t\tenic_vf_station_addr_set(enic, addr);\n+\t\t\tenic_vf_station_sync_reset(enic);\n+\t\t\tenic_vf_admin_mac_cache_selected(enic, addr);\n+\t\t\tnetif_rx_mode_schedule_update(netdev);\n+\t\t}\n+\n+\t\treturn err;\n+\t}\n+\n \tif (netif_running(enic-\u003enetdev)) {\n \t\terr = enic_dev_del_station_addr(enic);\n \t\tif (err)\n@@ -1107,17 +1621,380 @@ static int enic_set_mac_address(struct net_device *netdev, void *p)\n \treturn enic_dev_add_station_addr(enic);\n }\n \n+static u16 enic_rx_mode_to_pkt_filter(struct net_device *netdev,\n+\t\t\t\t      unsigned int uc_count,\n+\t\t\t\t      unsigned int mc_count)\n+{\n+\tu16 flags = CMD_PFILTER_DIRECTED;\n+\n+\tif (netdev-\u003eflags \u0026 IFF_MULTICAST)\n+\t\tflags |= CMD_PFILTER_MULTICAST;\n+\tif (netdev-\u003eflags \u0026 IFF_BROADCAST)\n+\t\tflags |= CMD_PFILTER_BROADCAST;\n+\tif ((netdev-\u003eflags \u0026 IFF_PROMISC) ||\n+\t    uc_count \u003e ENIC_UNICAST_PERFECT_FILTERS)\n+\t\tflags |= CMD_PFILTER_PROMISCUOUS;\n+\tif ((netdev-\u003eflags \u0026 IFF_ALLMULTI) ||\n+\t    mc_count \u003e ENIC_MULTICAST_PERFECT_FILTERS)\n+\t\tflags |= CMD_PFILTER_ALL_MULTICAST;\n+\n+\treturn flags;\n+}\n+\n+/* Deployed async PFs count the station MAC in the 32-entry UC table. */\n+static bool enic_vf_uc_needs_promisc(unsigned int uc_count)\n+{\n+\treturn uc_count \u003e= ENIC_UNICAST_PERFECT_FILTERS;\n+}\n+\n+static int enic_vf_set_pkt_filter(struct enic *enic, u16 flags,\n+\t\t\t\t  u16 *applied_flags)\n+{\n+\tu16 applied;\n+\tint err;\n+\n+\t/* The PF can change trust policy independently and thereby withdraw\n+\t * broad modes. Always refresh those requests so the returned applied\n+\t * flags remain authoritative. The other modes are not trust-gated and\n+\t * can be reused for ordinary address-list churn.\n+\t */\n+\tif (!(flags \u0026 (CMD_PFILTER_PROMISCUOUS |\n+\t\t       CMD_PFILTER_ALL_MULTICAST)) \u0026\u0026\n+\t    enic-\u003evf_pkt_filter_valid \u0026\u0026\n+\t    enic-\u003evf_pkt_filter_requested == flags) {\n+\t\tif (applied_flags)\n+\t\t\t*applied_flags = enic-\u003evf_pkt_filter_applied;\n+\t\treturn 0;\n+\t}\n+\n+\terr = enic_mbox_vf_set_pkt_filter(enic,\n+\t\t\t\t\t  !!(flags \u0026 CMD_PFILTER_DIRECTED),\n+\t\t\t\t\t  !!(flags \u0026 CMD_PFILTER_MULTICAST),\n+\t\t\t\t\t  !!(flags \u0026 CMD_PFILTER_BROADCAST),\n+\t\t\t\t\t  !!(flags \u0026 CMD_PFILTER_PROMISCUOUS),\n+\t\t\t\t\t  !!(flags \u0026 CMD_PFILTER_ALL_MULTICAST),\n+\t\t\t\t\t  \u0026applied);\n+\tif (err)\n+\t\treturn err;\n+\n+\tenic-\u003evf_pkt_filter_requested = flags;\n+\tenic-\u003evf_pkt_filter_applied = applied;\n+\tenic-\u003evf_pkt_filter_valid = true;\n+\tif (applied_flags)\n+\t\t*applied_flags = applied;\n+\n+\treturn 0;\n+}\n+\n+static void enic_vf_report_pkt_filter_denial(struct net_device *netdev,\n+\t\t\t\t\t     u16 requested, u16 applied)\n+{\n+\tif ((requested \u0026 CMD_PFILTER_PROMISCUOUS) \u0026\u0026\n+\t    !(applied \u0026 CMD_PFILTER_PROMISCUOUS))\n+\t\tnetdev_dbg(netdev, \"PF policy denied promiscuous receive mode\\n\");\n+\tif ((requested \u0026 CMD_PFILTER_ALL_MULTICAST) \u0026\u0026\n+\t    !(applied \u0026 CMD_PFILTER_ALL_MULTICAST))\n+\t\tnetdev_dbg(netdev,\n+\t\t\t   \"PF policy denied all-multicast receive mode\\n\");\n+}\n+\n+struct enic_vf_mac_op {\n+\tstruct netdev_hw_addr *ha;\n+\tunsigned int *filter_count;\n+};\n+\n+static unsigned int\n+enic_vf_addr_list_count(const struct enic *enic,\n+\t\t\tconst struct netdev_hw_addr_list *list)\n+{\n+\tconst struct netdev_hw_addr *ha;\n+\tunsigned int count = 0;\n+\n+\tnetdev_hw_addr_list_for_each(ha, list)\n+\t\tif (ha-\u003erefcount \u003e ha-\u003esync_cnt \u0026\u0026\n+\t\t    !(enic-\u003evf_station_addr_valid \u0026\u0026\n+\t\t      ether_addr_equal(ha-\u003eaddr, enic-\u003evf_station_addr)))\n+\t\t\tcount++;\n+\n+\treturn count;\n+}\n+\n+static int enic_vf_collect_mac_ops(struct enic *enic,\n+\t\t\t\t   struct netdev_hw_addr_list *list,\n+\t\t\t\t   bool install_new,\n+\t\t\t\t   unsigned int *filter_count,\n+\t\t\t\t   struct enic_mac_addr *macs,\n+\t\t\t\t   struct enic_vf_mac_op *ops,\n+\t\t\t\t   u16 *num_ops)\n+{\n+\tstruct netdev_hw_addr *ha;\n+\tu16 pos = *num_ops;\n+\n+\t/* Deletes precede adds so a full perfect-filter table has room for a\n+\t * replacement address in the same transaction.\n+\t */\n+\tnetdev_hw_addr_list_for_each(ha, list) {\n+\t\tif (enic-\u003evf_station_addr_valid \u0026\u0026\n+\t\t    ether_addr_equal(ha-\u003eaddr, enic-\u003evf_station_addr))\n+\t\t\tcontinue;\n+\t\tif (!ha-\u003esync_cnt ||\n+\t\t    ha-\u003erefcount != ha-\u003esync_cnt)\n+\t\t\tcontinue;\n+\t\tif (pos == ENIC_MBOX_MAX_MAC_OPS)\n+\t\t\treturn -E2BIG;\n+\n+\t\tether_addr_copy(macs[pos].addr, ha-\u003eaddr);\n+\t\tmacs[pos].flags = 0;\n+\t\tops[pos].ha = ha;\n+\t\tops[pos].filter_count = filter_count;\n+\t\tpos++;\n+\t}\n+\n+\tif (!install_new)\n+\t\tgoto done;\n+\n+\tnetdev_hw_addr_list_for_each(ha, list) {\n+\t\tif (enic-\u003evf_station_addr_valid \u0026\u0026\n+\t\t    ether_addr_equal(ha-\u003eaddr, enic-\u003evf_station_addr))\n+\t\t\tcontinue;\n+\t\tif (ha-\u003esync_cnt)\n+\t\t\tcontinue;\n+\t\tif (pos == ENIC_MBOX_MAX_MAC_OPS)\n+\t\t\treturn -E2BIG;\n+\n+\t\tether_addr_copy(macs[pos].addr, ha-\u003eaddr);\n+\t\tmacs[pos].flags = cpu_to_le16(ENIC_MAC_ADDR_FLAG_ADD);\n+\t\tops[pos].ha = ha;\n+\t\tops[pos].filter_count = filter_count;\n+\t\tpos++;\n+\t}\n+\n+done:\n+\t*num_ops = pos;\n+\treturn 0;\n+}\n+\n+static int enic_vf_sync_mac_filters(struct enic *enic,\n+\t\t\t\t    struct netdev_hw_addr_list *uc,\n+\t\t\t\t    struct netdev_hw_addr_list *mc,\n+\t\t\t\t    bool install_uc, bool install_mc)\n+{\n+\tstruct enic_vf_mac_op *ops;\n+\tstruct enic_mac_addr *macs;\n+\tbool permanent_add = false;\n+\tbool reconnect = false;\n+\tbool retryable_add = false;\n+\tu16 num_ops = 0;\n+\tunsigned int i;\n+\tint err = 0;\n+\n+\t/* A class can contribute at most its installed perfect filters as\n+\t * deletes and its finite perfect-filter limit as adds. Keep the wire\n+\t * batch large enough for both classes so an update always fits in one\n+\t * transaction and -E2BIG remains only a defensive state-corruption\n+\t * check.\n+\t */\n+\tBUILD_BUG_ON(ENIC_MBOX_MAX_MAC_OPS \u003c\n+\t\t     2 * (ENIC_UNICAST_PERFECT_FILTERS +\n+\t\t\t  ENIC_MULTICAST_PERFECT_FILTERS));\n+\n+\tmacs = kcalloc(ENIC_MBOX_MAX_MAC_OPS, sizeof(*macs), GFP_KERNEL);\n+\tif (!macs)\n+\t\treturn -ENOMEM;\n+\tops = kcalloc(ENIC_MBOX_MAX_MAC_OPS, sizeof(*ops), GFP_KERNEL);\n+\tif (!ops) {\n+\t\terr = -ENOMEM;\n+\t\tgoto free_macs;\n+\t}\n+\n+\terr = enic_vf_collect_mac_ops(enic, uc, install_uc,\n+\t\t\t\t      \u0026enic-\u003euc_count,\n+\t\t\t\t      macs, ops, \u0026num_ops);\n+\tif (err)\n+\t\tgoto free_ops;\n+\terr = enic_vf_collect_mac_ops(enic, mc, install_mc,\n+\t\t\t\t      \u0026enic-\u003emc_count,\n+\t\t\t\t      macs, ops, \u0026num_ops);\n+\tif (err || !num_ops)\n+\t\tgoto free_ops;\n+\n+\t/* The protocol carries all changed unicast and multicast addresses in\n+\t * one request.  Besides matching the native ABI, this bounds time spent\n+\t * in the RTNL-held asynchronous receive-mode callback to one MAC reply.\n+\t */\n+\terr = enic_mbox_vf_add_del_macs(enic, macs, num_ops);\n+\tif (err)\n+\t\tgoto free_ops;\n+\n+\tfor (i = 0; i \u003c num_ops; i++) {\n+\t\tu16 flags = le16_to_cpu(macs[i].flags);\n+\t\tbool add = flags \u0026 ENIC_MAC_ADDR_FLAG_ADD;\n+\n+\t\tif (flags \u0026 ENIC_MAC_ADDR_FLAG_SKIPPED) {\n+\t\t\tif (add)\n+\t\t\t\tretryable_add = true;\n+\t\t\telse\n+\t\t\t\treconnect = true;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (flags \u0026 ENIC_MAC_ADDR_FLAG_PERMANENT_MASK) {\n+\t\t\tif (add)\n+\t\t\t\tpermanent_add = true;\n+\t\t\telse\n+\t\t\t\treconnect = true;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (add) {\n+\t\t\tops[i].ha-\u003esync_cnt++;\n+\t\t\tops[i].ha-\u003erefcount++;\n+\t\t\t(*ops[i].filter_count)++;\n+\t\t} else {\n+\t\t\tops[i].ha-\u003esync_cnt--;\n+\t\t\tops[i].ha-\u003erefcount--;\n+\t\t\tif (WARN_ON_ONCE(!*ops[i].filter_count))\n+\t\t\t\terr = -EIO;\n+\t\t\telse\n+\t\t\t\t(*ops[i].filter_count)--;\n+\t\t}\n+\t}\n+\n+\t/* A failed DELETE can leave hardware accepting an address no longer in\n+\t * the requested list.  Registration is the fail-closed cleanup boundary.\n+\t * A skipped ADD changes no acceptance state and can use the bounded core\n+\t * retry path.  Permanent ADD denials remain stable policy results.\n+\t */\n+\tif (reconnect) {\n+\t\tenic_mbox_vf_require_reconnect(enic);\n+\t\terr = -EIO;\n+\t} else if (retryable_add) {\n+\t\terr = -EAGAIN;\n+\t} else if (permanent_add) {\n+\t\terr = -EACCES;\n+\t}\n+\n+free_ops:\n+\tkfree(ops);\n+free_macs:\n+\tkfree(macs);\n+\treturn err;\n+}\n+\n+static int enic_set_vf_rx_mode(struct net_device *netdev,\n+\t\t\t       struct netdev_hw_addr_list *uc,\n+\t\t\t       struct netdev_hw_addr_list *mc)\n+{\n+\tstruct enic *enic = netdev_priv(netdev);\n+\tunsigned int uc_count = enic_vf_addr_list_count(enic, uc);\n+\tunsigned int mc_count = enic_vf_addr_list_count(enic, mc);\n+\tu16 flags = enic_rx_mode_to_pkt_filter(netdev, uc_count, mc_count);\n+\tbool uc_overflow = enic_vf_uc_needs_promisc(uc_count);\n+\tbool mc_overflow = mc_count \u003e ENIC_MULTICAST_PERFECT_FILTERS;\n+\tu16 broad_modes = CMD_PFILTER_PROMISCUOUS |\n+\t\t\t  CMD_PFILTER_ALL_MULTICAST;\n+\tbool broad_enable_needed;\n+\tbool broad_withdrawal;\n+\tbool filter_needed;\n+\tbool target_filter_updated = false;\n+\tu16 prefilter_flags;\n+\tu16 applied_flags;\n+\tint err;\n+\n+\tif (uc_overflow)\n+\t\tflags |= CMD_PFILTER_PROMISCUOUS;\n+\n+\tif (!READ_ONCE(enic-\u003evf_registered))\n+\t\treturn -ENODEV;\n+\n+\tfilter_needed = !enic-\u003evf_pkt_filter_valid ||\n+\t\t\t enic-\u003evf_pkt_filter_requested != flags ||\n+\t\t\t (flags \u0026 broad_modes);\n+\tbroad_enable_needed =\n+\t\t(!enic-\u003evf_pkt_filter_valid \u0026\u0026 (flags \u0026 broad_modes)) ||\n+\t\t(flags \u0026 broad_modes \u0026 ~enic-\u003evf_pkt_filter_requested);\n+\tbroad_withdrawal = enic-\u003evf_pkt_filter_valid \u0026\u0026\n+\t\t(enic-\u003evf_pkt_filter_applied \u0026 broad_modes \u0026 ~flags);\n+\tif (broad_enable_needed) {\n+\t\t/* Establish newly required broad coverage before an independent\n+\t\t * exact-address rejection can block it. Retain any broad mode that\n+\t\t * is currently applied until its finite replacement is installed.\n+\t\t */\n+\t\tprefilter_flags = flags;\n+\t\tif (enic-\u003evf_pkt_filter_valid)\n+\t\t\tprefilter_flags |= enic-\u003evf_pkt_filter_applied \u0026 broad_modes;\n+\t\terr = enic_vf_set_pkt_filter(enic, prefilter_flags,\n+\t\t\t\t\t     \u0026applied_flags);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t\ttarget_filter_updated = prefilter_flags == flags;\n+\t\tenic_vf_report_pkt_filter_denial(netdev, flags, applied_flags);\n+\t}\n+\n+\tif (broad_withdrawal) {\n+\t\t/* Withdraw stale broad acceptance before installing its finite\n+\t\t * replacement. Complete both phases in this callback so a synchronous\n+\t\t * receive-mode operation cannot return between them.\n+\t\t */\n+\t\terr = enic_vf_set_pkt_filter(enic, flags, \u0026applied_flags);\n+\t\tif (err) {\n+\t\t\t/* The previously applied broad mode may still be active.  Do\n+\t\t\t * not rely on the core's bounded retry budget to narrow it.\n+\t\t\t * Fresh registration is the fail-closed policy boundary.  A\n+\t\t\t * local send timeout is already terminal and cannot use ordinary\n+\t\t\t * reconnect recovery.\n+\t\t\t */\n+\t\t\tif (!READ_ONCE(enic-\u003embox_tx_poisoned) \u0026\u0026\n+\t\t\t    !READ_ONCE(enic-\u003evf_mbox_reconnect_required))\n+\t\t\t\tenic_mbox_vf_require_reconnect(enic);\n+\t\t\treturn err;\n+\t\t}\n+\t\ttarget_filter_updated = true;\n+\t\tenic_vf_report_pkt_filter_denial(netdev, flags, applied_flags);\n+\t}\n+\n+\t/* Keep the finite subset of exact filters already installed for an\n+\t * overflowing class. Broad mode covers the remaining addresses when PF\n+\t * policy permits it, while the independent finite class can still make\n+\t * progress. When a class becomes finite again, stale broad acceptance was\n+\t * withdrawn above before this exact-filter reconciliation.\n+\t */\n+\terr = enic_vf_sync_mac_filters(enic, uc, mc, !uc_overflow,\n+\t\t\t\t       !mc_overflow);\n+\tif (err == -EACCES) {\n+\t\t/* Do not spend the core retry budget repeating an exact operation\n+\t\t * that the PF rejected permanently. Finish any independent packet\n+\t\t * policy change below before returning success.\n+\t\t */\n+\t\terr = 0;\n+\t}\n+\tif (err)\n+\t\treturn err;\n+\n+\tif (!target_filter_updated \u0026\u0026 filter_needed) {\n+\t\terr = enic_vf_set_pkt_filter(enic, flags, \u0026applied_flags);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t} else if (!target_filter_updated) {\n+\t\tapplied_flags = enic-\u003evf_pkt_filter_applied;\n+\t}\n+\n+\tenic_vf_report_pkt_filter_denial(netdev, flags, applied_flags);\n+\n+\treturn 0;\n+}\n+\n /* netif_tx_lock held, BHs disabled */\n static void enic_set_rx_mode(struct net_device *netdev)\n {\n \tstruct enic *enic = netdev_priv(netdev);\n-\tint directed = 1;\n-\tint multicast = (netdev-\u003eflags \u0026 IFF_MULTICAST) ? 1 : 0;\n-\tint broadcast = (netdev-\u003eflags \u0026 IFF_BROADCAST) ? 1 : 0;\n-\tint promisc = (netdev-\u003eflags \u0026 IFF_PROMISC) ||\n-\t\tnetdev_uc_count(netdev) \u003e ENIC_UNICAST_PERFECT_FILTERS;\n-\tint allmulti = (netdev-\u003eflags \u0026 IFF_ALLMULTI) ||\n-\t\tnetdev_mc_count(netdev) \u003e ENIC_MULTICAST_PERFECT_FILTERS;\n+\tu16 filter_flags = enic_rx_mode_to_pkt_filter(netdev,\n+\t\t\t\t\t       netdev_uc_count(netdev),\n+\t\t\t\t\t       netdev_mc_count(netdev));\n+\tint directed = !!(filter_flags \u0026 CMD_PFILTER_DIRECTED);\n+\tint multicast = !!(filter_flags \u0026 CMD_PFILTER_MULTICAST);\n+\tint broadcast = !!(filter_flags \u0026 CMD_PFILTER_BROADCAST);\n+\tint promisc = !!(filter_flags \u0026 CMD_PFILTER_PROMISCUOUS);\n+\tint allmulti = !!(filter_flags \u0026 CMD_PFILTER_ALL_MULTICAST);\n \tunsigned int flags = netdev-\u003eflags |\n \t\t(allmulti ? IFF_ALLMULTI : 0) |\n \t\t(promisc ? IFF_PROMISC : 0);\n@@ -1718,10 +2595,17 @@ static void enic_notify_timer_start(struct enic *enic)\n \t}\n }\n \n+static int enic_admin_chan_reopen(struct enic *enic);\n+\n /* rtnl lock is held, process context */\n static int enic_open(struct net_device *netdev)\n {\n \tstruct enic *enic = netdev_priv(netdev);\n+\tbool vf_mac_added = false;\n+\tu16 vf_filter_applied;\n+\tu16 vf_filter_flags;\n+\tunsigned int vf_mc_count;\n+\tunsigned int vf_uc_count;\n \tunsigned int i;\n \tint err, ret;\n \tunsigned int max_pkt_len = netdev-\u003emtu + VLAN_ETH_HLEN;\n@@ -1736,6 +2620,30 @@ static int enic_open(struct net_device *netdev)\n \t\t.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV,\n \t};\n \n+\t/* A reply timeout invalidates the current request generation.  Rebuild\n+\t * and re-register the channel before allocating datapath resources so a\n+\t * later userspace down/up can recover a failed open or reset handshake.\n+\t * A send timeout is intentionally not recoverable here because its WQ\n+\t * descriptor may still be hardware-owned.\n+\t */\n+\tif (enic_is_sriov_vf_v2(enic) \u0026\u0026\n+\t    READ_ONCE(enic-\u003embox_tx_poisoned))\n+\t\treturn -EIO;\n+\tif (enic_is_sriov_vf_v2(enic) \u0026\u0026\n+\t    (!enic-\u003eadmin_chan_up || !READ_ONCE(enic-\u003evf_registered) ||\n+\t     READ_ONCE(enic-\u003evf_mbox_reconnect_required))) {\n+\t\t/* Re-registration makes the PF discard the old VF-requested\n+\t\t * filters.  Clear the netdev-core synchronization state so the\n+\t\t * receive-mode callback replays the current address lists.\n+\t\t */\n+\t\tenic_reset_addr_lists(enic);\n+\t\tif (enic-\u003eadmin_chan_up)\n+\t\t\tenic_admin_channel_close(enic);\n+\t\terr = enic_admin_chan_reopen(enic);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t}\n+\n \terr = enic_request_intr(enic);\n \tif (err) {\n \t\tnetdev_err(netdev, \"Unable to request irq.\\n\");\n@@ -1778,8 +2686,55 @@ static int enic_open(struct net_device *netdev)\n \n \tif (!enic_is_dynamic(enic) \u0026\u0026 !enic_is_sriov_vf(enic))\n \t\tenic_dev_add_station_addr(enic);\n+\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\tif (!READ_ONCE(enic-\u003evf_registered)) {\n+\t\t\tnetdev_err(netdev, \"VF is not registered with its PF\\n\");\n+\t\t\terr = -ENODEV;\n+\t\t\tgoto err_out_disable_wq;\n+\t\t}\n+\n+\t\terr = enic_vf_station_addr_replace(enic, netdev-\u003edev_addr);\n+\t\tif (err) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"Failed to register VF station address: %d\\n\",\n+\t\t\t\t   err);\n+\t\t\tgoto err_out_disable_wq;\n+\t\t}\n+\t\tenic_vf_station_addr_set(enic, netdev-\u003edev_addr);\n+\t\tenic_vf_station_sync_reset(enic);\n+\t\tvf_mac_added = true;\n+\n+\t\tnetif_addr_lock_bh(netdev);\n+\t\tvf_uc_count = enic_vf_addr_list_count(enic, \u0026netdev-\u003euc);\n+\t\tvf_mc_count = enic_vf_addr_list_count(enic, \u0026netdev-\u003emc);\n+\t\tnetif_addr_unlock_bh(netdev);\n+\n+\t\tvf_filter_flags = enic_rx_mode_to_pkt_filter(netdev,\n+\t\t\t\t\t\t\t     vf_uc_count,\n+\t\t\t\t\t\t\t     vf_mc_count);\n+\t\tif (enic_vf_uc_needs_promisc(vf_uc_count))\n+\t\t\tvf_filter_flags |= CMD_PFILTER_PROMISCUOUS;\n+\t\terr = enic_vf_set_pkt_filter(enic, vf_filter_flags,\n+\t\t\t\t\t     \u0026vf_filter_applied);\n+\t\tif (err) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"Failed to configure VF packet filter: %d\\n\",\n+\t\t\t\t   err);\n+\t\t\tgoto err_out_disable_wq;\n+\t\t}\n+\t\tif ((enic_vf_uc_needs_promisc(vf_uc_count) \u0026\u0026\n+\t\t     !(vf_filter_applied \u0026 CMD_PFILTER_PROMISCUOUS)) ||\n+\t\t    (vf_mc_count \u003e ENIC_MULTICAST_PERFECT_FILTERS \u0026\u0026\n+\t\t     !(vf_filter_applied \u0026 CMD_PFILTER_ALL_MULTICAST))) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"PF denied receive mode required by VF address lists\\n\");\n+\t\t\terr = -EACCES;\n+\t\t\tgoto err_out_disable_wq;\n+\t\t}\n+\t}\n \n-\tenic_set_rx_mode(netdev);\n+\tif (!enic_is_sriov_vf_v2(enic))\n+\t\tenic_set_rx_mode(netdev);\n \n \tnetif_tx_wake_all_queues(netdev);\n \n@@ -1794,17 +2749,41 @@ static int enic_open(struct net_device *netdev)\n \t\tnetdev_err(netdev, \"Failed to enable device: %d\\n\", err);\n \t\tgoto err_out_dev_enable;\n \t}\n+\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\t/* Commit the replay only if no mailbox fault arrived while station\n+\t\t * and receive policy were being programmed.  Keep the state lock\n+\t\t * through the carrier transition so a later fault necessarily wins\n+\t\t * and turns carrier back off.\n+\t\t */\n+\t\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tif (!READ_ONCE(enic-\u003evf_registered) ||\n+\t\t    READ_ONCE(enic-\u003embox_send_disabled) ||\n+\t\t    READ_ONCE(enic-\u003embox_tx_poisoned) ||\n+\t\t    READ_ONCE(enic-\u003evf_mbox_reconnect_required)) {\n+\t\t\terr = -EIO;\n+\t\t} else {\n+\t\t\tWRITE_ONCE(enic-\u003evf_rx_quarantined, false);\n+\t\t\tenic_mbox_vf_link_state_set_running(enic, true);\n+\t\t}\n+\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tif (err) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"MBOX state changed during VF datapath open\\n\");\n+\t\t\tgoto err_out_dev_disable;\n+\t\t}\n+\t}\n \n \tfor (i = 0; i \u003c enic-\u003eintr_count; i++)\n \t\tvnic_intr_unmask(\u0026enic-\u003eintr[i]);\n-\n \tenic_notify_timer_start(enic);\n \tenic_rfs_timer_start(enic);\n \tif (enic_is_sriov_vf_v2(enic))\n-\t\tenic_mbox_vf_link_state_set_running(enic, true);\n+\t\tenic-\u003evf_datapath_open = true;\n \n \treturn 0;\n \n+err_out_dev_disable:\n+\tenic_dev_disable(enic);\n err_out_dev_enable:\n \tfor (i = 0; i \u003c enic-\u003erq_count; i++)\n \t\tnapi_disable(\u0026enic-\u003enapi[i]);\n@@ -1812,6 +2791,15 @@ static int enic_open(struct net_device *netdev)\n \t\tfor (i = 0; i \u003c enic-\u003ewq_count; i++)\n \t\t\tnapi_disable(\u0026enic-\u003enapi[enic_cq_wq(enic, i)]);\n \tnetif_tx_disable(netdev);\n+err_out_disable_wq:\n+\tif (vf_mac_added) {\n+\t\tret = enic_vf_station_addr_del(enic);\n+\t\tif (ret) {\n+\t\t\tnetdev_warn(netdev,\n+\t\t\t\t    \"Failed to remove VF station address during open rollback: %d\\n\",\n+\t\t\t\t    ret);\n+\t\t}\n+\t}\n \tif (!enic_is_dynamic(enic) \u0026\u0026 !enic_is_sriov_vf(enic))\n \t\tenic_dev_del_station_addr(enic);\n \tfor (i = 0; i \u003c enic-\u003ewq_count; i++)\n@@ -1834,12 +2822,19 @@ static int enic_open(struct net_device *netdev)\n }\n \n /* rtnl lock is held, process context */\n-static int enic_stop(struct net_device *netdev)\n+static int __enic_stop(struct net_device *netdev, bool remove_vf_station)\n {\n \tstruct enic *enic = netdev_priv(netdev);\n \tunsigned int i;\n \tint err;\n \n+\t/* Internal reset leaves netif_running() set while the datapath is down.\n+\t * If re-registration or reopen then fails, a later administrative close\n+\t * must not disable NAPI a second time.\n+\t */\n+\tif (enic_is_sriov_vf_v2(enic) \u0026\u0026 !enic-\u003evf_datapath_open)\n+\t\treturn 0;\n+\n \tfor (i = 0; i \u003c enic-\u003eintr_count; i++) {\n \t\tvnic_intr_mask(\u0026enic-\u003eintr[i]);\n \t\t(void)vnic_intr_masked(\u0026enic-\u003eintr[i]); /* flush write */\n@@ -1863,6 +2858,15 @@ static int enic_stop(struct net_device *netdev)\n \t\tfor (i = 0; i \u003c enic-\u003ewq_count; i++)\n \t\t\tnapi_disable(\u0026enic-\u003enapi[enic_cq_wq(enic, i)]);\n \tnetif_tx_disable(netdev);\n+\tif (remove_vf_station \u0026\u0026 enic_is_sriov_vf_v2(enic) \u0026\u0026\n+\t    READ_ONCE(enic-\u003evf_registered)) {\n+\t\terr = enic_vf_station_addr_del(enic);\n+\t\tif (err) {\n+\t\t\tnetdev_warn(netdev,\n+\t\t\t\t    \"Failed to remove VF station address: %d\\n\",\n+\t\t\t\t    err);\n+\t\t}\n+\t}\n \n \tif (!enic_is_dynamic(enic) \u0026\u0026 !enic_is_sriov_vf(enic))\n \t\tenic_dev_del_station_addr(enic);\n@@ -1893,10 +2897,17 @@ static int enic_stop(struct net_device *netdev)\n \t\tvnic_cq_clean(\u0026enic-\u003ecq[i]);\n \tfor (i = 0; i \u003c enic-\u003eintr_count; i++)\n \t\tvnic_intr_clean(\u0026enic-\u003eintr[i]);\n+\tif (enic_is_sriov_vf_v2(enic))\n+\t\tenic-\u003evf_datapath_open = false;\n \n \treturn 0;\n }\n \n+static int enic_stop(struct net_device *netdev)\n+{\n+\treturn __enic_stop(netdev, true);\n+}\n+\n static int _enic_change_mtu(struct net_device *netdev, int new_mtu)\n {\n \tbool running = netif_running(netdev);\n@@ -2196,14 +3207,15 @@ static bool enic_has_admin_chan(struct enic *enic)\n \t       (enic_sriov_enabled(enic) \u0026\u0026 enic-\u003evf_type == ENIC_VF_TYPE_V2);\n }\n \n-/* Re-establish the admin/MBOX channel after a reset has re-created the data\n- * path.  Mirrors the relevant part of the probe / SR-IOV-enable sequence:\n+/* Re-establish the admin/MBOX channel after a reset has re-created the vNIC\n+ * resources.  Mirrors the relevant part of the probe / SR-IOV-enable sequence:\n  * reinitialise MBOX and reopen the channel, then for a VF re-run the PF\n  * handshake (the reset wiped the VF's admin QP, so the VF must register\n  * again), or for a PF re-push the current link state to registered VFs.\n  */\n-static void enic_admin_chan_reopen(struct enic *enic)\n+static int enic_admin_chan_reopen(struct enic *enic)\n {\n+\tu32 recovery_generation = 0;\n \tint err;\n \n \t/* Install the MBOX receive handler and clear pending reply state before\n@@ -2222,12 +3234,17 @@ static void enic_admin_chan_reopen(struct enic *enic)\n \t */\n \tif (enic_is_sriov_vf_v2(enic))\n \t\tWRITE_ONCE(enic-\u003evf_registered, false);\n+\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\t\trecovery_generation = enic-\u003evf_mbox_fault_generation;\n+\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\t}\n \n \terr = enic_admin_channel_open(enic);\n \tif (err) {\n \t\tnetdev_err(enic-\u003enetdev,\n \t\t\t   \"admin channel reopen after reset failed: %d\\n\", err);\n-\t\treturn;\n+\t\treturn err;\n \t}\n \n \tif (enic_is_sriov_vf_v2(enic)) {\n@@ -2237,7 +3254,7 @@ static void enic_admin_chan_reopen(struct enic *enic)\n \t\t\t\t   \"MBOX capability check after reset failed: %d\\n\",\n \t\t\t\t   err);\n \t\t\tenic_admin_channel_close(enic);\n-\t\t\treturn;\n+\t\t\treturn err;\n \t\t}\n \t\terr = enic_mbox_vf_register(enic);\n \t\tif (err) {\n@@ -2245,7 +3262,37 @@ static void enic_admin_chan_reopen(struct enic *enic)\n \t\t\t\t   \"MBOX VF re-registration after reset failed: %d\\n\",\n \t\t\t\t   err);\n \t\t\tenic_admin_channel_close(enic);\n+\t\t\treturn err;\n+\t\t}\n+\t\tenic_reset_addr_lists(enic);\n+\t\tenic-\u003evf_station_addr_valid = false;\n+\t\terr = enic_vf_admin_mac_refresh(enic);\n+\t\tif (err) {\n+\t\t\tnetdev_err(enic-\u003enetdev,\n+\t\t\t\t   \"Failed to refresh VF admin MAC after reset: %d\\n\",\n+\t\t\t\t   err);\n+\t\t\tenic_admin_channel_close(enic);\n+\t\t\treturn err;\n+\t\t}\n+\t\t/* Capability negotiation and registration establish a new protocol\n+\t\t * generation after authoritative MAC policy is refreshed. RX remains\n+\t\t * quarantined until enic_open() replays station and receive policy.\n+\t\t */\n+\t\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tif (enic-\u003evf_mbox_fault_generation != recovery_generation ||\n+\t\t    READ_ONCE(enic-\u003embox_tx_poisoned)) {\n+\t\t\terr = -EAGAIN;\n+\t\t} else {\n+\t\t\tWRITE_ONCE(enic-\u003evf_mbox_reconnect_required, false);\n+\t\t}\n+\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tif (err) {\n+\t\t\tnetdev_warn(enic-\u003enetdev,\n+\t\t\t\t    \"MBOX state changed during VF re-registration\\n\");\n+\t\t\tenic_admin_channel_close(enic);\n+\t\t\treturn err;\n \t\t}\n+\t\tenic_vf_admin_mac_rearm(enic);\n \t} else {\n \t\t/* The link came back up during enic_open() above while MBOX\n \t\t * sends were still disabled (channel not yet reopened), so that\n@@ -2253,79 +3300,135 @@ static void enic_admin_chan_reopen(struct enic *enic)\n \t\t */\n \t\tschedule_work(\u0026enic-\u003elink_notify_work);\n \t}\n+\n+\treturn 0;\n }\n \n static void enic_reset(struct work_struct *work)\n {\n \tstruct enic *enic = container_of(work, struct enic, reset);\n+\tbool vf_recovery = enic_is_sriov_vf_v2(enic);\n+\tint err;\n \n \tif (!netif_running(enic-\u003enetdev))\n \t\treturn;\n+\tif (vf_recovery)\n+\t\tWRITE_ONCE(enic-\u003evf_mbox_recovery_active, true);\n \n \trtnl_lock();\n+\t/* V2 protocol recovery can be queued immediately before ndo_stop()\n+\t * acquires RTNL.  Recheck under RTNL so that new recovery path cannot\n+\t * reopen a device userspace just closed.  Preserve the existing reset\n+\t * behavior for every other ENIC device.\n+\t */\n+\tif (enic_is_sriov_vf_v2(enic) \u0026\u0026 !netif_running(enic-\u003enetdev))\n+\t\tgoto unlock;\n \n \t/* Stop any activity from infiniband */\n \tenic_set_api_busy(enic, true);\n \n-\t/* Fully tear down the V2 admin/MBOX channel before the soft reset.\n-\t * The reset wipes all hardware queues including the admin WQ/RQ;\n-\t * closing first tells firmware to stop the admin QP (so it no longer\n-\t * DMAs from the about-to-be-reset rings) and frees the admin resources\n-\t * so they are cleanly re-allocated afterwards.\n+\t/* Stop the datapath and existing admin/MBOX channel before the soft\n+\t * reset. Do not send DEL_MAC from this path: a timeout would poison the\n+\t * channel while reset and fresh registration already discard the old\n+\t * VF-requested protocol state before the station address is replayed.\n+\t * Reopen allocates fresh admin resources after reset recreates the vNIC.\n \t */\n+\t__enic_stop(enic-\u003enetdev, false);\n \tif (enic_has_admin_chan(enic))\n \t\tenic_admin_channel_close(enic);\n \n-\tenic_stop(enic-\u003enetdev);\n \tif (enic_is_sriov_vf_v2(enic))\n \t\tenic_mbox_vf_link_state_reset(enic);\n+\terr = enic_dev_soft_reset(enic);\n+\tif (err)\n+\t\tgoto reset_out;\n+\n+\tif (!enic_is_dynamic(enic)) {\n+\t\terr = vnic_dev_init(enic-\u003evdev, 0);\n+\t\tif (err) {\n+\t\t\tnetdev_err(enic-\u003enetdev,\n+\t\t\t\t   \"vNIC init after soft reset failed: %d\\n\",\n+\t\t\t\t   err);\n+\t\t\tgoto reset_out;\n+\t\t}\n+\t}\n \n-\tenic_dev_soft_reset(enic);\n \tenic_reset_addr_lists(enic);\n \tenic_init_vnic_resources(enic);\n \tenic_set_rss_nic_cfg(enic);\n \tenic_dev_set_ig_vlan_rewrite_mode(enic);\n \tenic_ext_cq(enic);\n \n-\tenic_open(enic-\u003enetdev);\n+\t/* A V2 VF needs PF registration before enic_open() can install its\n+\t * station address.  A V2 PF reopens afterwards and replays carrier.\n+\t */\n+\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\terr = enic_admin_chan_reopen(enic);\n+\t\tif (err)\n+\t\t\tgoto reset_out;\n+\t}\n+\n+\terr = enic_open(enic-\u003enetdev);\n+\tif (err)\n+\t\tnetdev_err(enic-\u003enetdev,\n+\t\t\t   \"Failed to reopen datapath after reset: %d\\n\", err);\n+\telse if (enic_is_sriov_vf_v2(enic)) {\n+\t\t/* Internal reset bypasses __dev_open(), which normally schedules the\n+\t\t * asynchronous receive-mode upload after ndo_open. Schedule an update\n+\t\t * after enic_reset_addr_lists() marked the lists unsynchronized.\n+\t\t */\n+\t\tnetif_rx_mode_schedule_update(enic-\u003enetdev);\n+\t}\n \n-\t/* Re-establish the admin/MBOX channel after the data path is back up.\n-\t * It was fully torn down by enic_admin_channel_close() above;\n-\t * enic_admin_chan_reopen() reopens it and, for a PF re-pushes link\n-\t * state, or for a VF re-runs the probe-time PF handshake.\n+\t/* A PF reopens its admin channel after the datapath and re-pushes link\n+\t * state.  The VF handshake, which open depends on, completed above.\n \t */\n-\tif (enic_has_admin_chan(enic))\n+\tif (enic_has_admin_chan(enic) \u0026\u0026 !enic_is_sriov_vf_v2(enic))\n \t\tenic_admin_chan_reopen(enic);\n \n+reset_out:\n \t/* Allow infiniband to fiddle with the device again */\n \tenic_set_api_busy(enic, false);\n \n \tcall_netdevice_notifiers(NETDEV_REBOOT, enic-\u003enetdev);\n \n+unlock:\n+\tif (vf_recovery)\n+\t\tWRITE_ONCE(enic-\u003evf_mbox_recovery_active, false);\n \trtnl_unlock();\n }\n \n static void enic_tx_hang_reset(struct work_struct *work)\n {\n \tstruct enic *enic = container_of(work, struct enic, tx_hang_reset);\n+\tbool vf_recovery = enic_is_sriov_vf_v2(enic);\n+\tint err;\n+\n+\tif (vf_recovery)\n+\t\tWRITE_ONCE(enic-\u003evf_mbox_recovery_active, true);\n \n \trtnl_lock();\n+\t/* The V2 changes below add admin-channel recovery to this worker.  Do not\n+\t * let that new path reopen a VF after userspace completed ndo_stop();\n+\t * leave the existing behavior for other ENIC devices unchanged.\n+\t */\n+\tif (enic_is_sriov_vf_v2(enic) \u0026\u0026 !netif_running(enic-\u003enetdev))\n+\t\tgoto unlock;\n \n \t/* Stop any activity from infiniband */\n \tenic_set_api_busy(enic, true);\n \n-\t/* Fully tear down the V2 admin/MBOX channel before the hang reset, for\n-\t * the same reason as the soft reset path: stop the admin QP and free\n-\t * the admin resources before the hardware queues are wiped.\n+\t/* Preserve the firmware hang-notification contract by reporting the hung\n+\t * queue before stopping and cleaning it. As in the soft-reset path, skip\n+\t * DEL_MAC because reset and fresh registration are the cleanup boundary.\n \t */\n+\tenic_dev_hang_notify(enic);\n+\t__enic_stop(enic-\u003enetdev, false);\n \tif (enic_has_admin_chan(enic))\n \t\tenic_admin_channel_close(enic);\n \n-\tenic_dev_hang_notify(enic);\n-\tenic_stop(enic-\u003enetdev);\n \tif (enic_is_sriov_vf_v2(enic))\n \t\tenic_mbox_vf_link_state_reset(enic);\n-\n \tenic_dev_hang_reset(enic);\n \tenic_reset_addr_lists(enic);\n \tenic_init_vnic_resources(enic);\n@@ -2333,21 +3436,34 @@ static void enic_tx_hang_reset(struct work_struct *work)\n \tenic_dev_set_ig_vlan_rewrite_mode(enic);\n \tenic_ext_cq(enic);\n \n-\tenic_open(enic-\u003enetdev);\n+\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\terr = enic_admin_chan_reopen(enic);\n+\t\tif (err)\n+\t\t\tgoto hang_reset_out;\n+\t}\n+\n+\terr = enic_open(enic-\u003enetdev);\n+\tif (err)\n+\t\tnetdev_err(enic-\u003enetdev,\n+\t\t\t   \"Failed to reopen datapath after hang reset: %d\\n\", err);\n+\telse if (enic_is_sriov_vf_v2(enic))\n+\t\tnetif_rx_mode_schedule_update(enic-\u003enetdev);\n \n-\t/* Re-establish the admin/MBOX channel after the data path is back up.\n-\t * It was fully torn down by enic_admin_channel_close() above;\n-\t * enic_admin_chan_reopen() reopens it and, for a PF re-pushes link\n-\t * state, or for a VF re-runs the probe-time PF handshake.\n+\t/* A PF reopens its admin channel after the datapath and re-pushes link\n+\t * state.  The VF handshake, which open depends on, completed above.\n \t */\n-\tif (enic_has_admin_chan(enic))\n+\tif (enic_has_admin_chan(enic) \u0026\u0026 !enic_is_sriov_vf_v2(enic))\n \t\tenic_admin_chan_reopen(enic);\n \n+hang_reset_out:\n \t/* Allow infiniband to fiddle with the device again */\n \tenic_set_api_busy(enic, false);\n \n \tcall_netdevice_notifiers(NETDEV_REBOOT, enic-\u003enetdev);\n \n+unlock:\n+\tif (vf_recovery)\n+\t\tWRITE_ONCE(enic-\u003evf_mbox_recovery_active, false);\n \trtnl_unlock();\n }\n \n@@ -2586,6 +3702,30 @@ static const struct net_device_ops enic_netdev_dynamic_ops = {\n \t.ndo_features_check\t= enic_features_check,\n };\n \n+static const struct net_device_ops enic_netdev_vf_v2_ops = {\n+\t.ndo_open\t\t= enic_open,\n+\t.ndo_stop\t\t= enic_stop,\n+\t.ndo_start_xmit\t\t= enic_hard_start_xmit,\n+\t.ndo_get_stats64\t= enic_get_stats,\n+\t.ndo_validate_addr\t= eth_validate_addr,\n+\t.ndo_set_rx_mode_async\t= enic_set_vf_rx_mode,\n+\t.ndo_set_mac_address\t= enic_set_mac_address_dynamic,\n+\t.ndo_change_mtu\t\t= enic_change_mtu,\n+\t.ndo_vlan_rx_add_vid\t= enic_vlan_rx_add_vid,\n+\t.ndo_vlan_rx_kill_vid\t= enic_vlan_rx_kill_vid,\n+\t.ndo_tx_timeout\t\t= enic_tx_timeout,\n+\t.ndo_set_vf_port\t= enic_set_vf_port,\n+\t.ndo_get_vf_port\t= enic_get_vf_port,\n+\t.ndo_set_vf_mac\t\t= enic_set_vf_mac,\n+#ifdef CONFIG_NET_POLL_CONTROLLER\n+\t.ndo_poll_controller\t= enic_poll_controller,\n+#endif\n+#ifdef CONFIG_RFS_ACCEL\n+\t.ndo_rx_flow_steer\t= enic_rx_flow_steer,\n+#endif\n+\t.ndo_features_check\t= enic_features_check,\n+};\n+\n static const struct net_device_ops enic_netdev_ops = {\n \t.ndo_open\t\t= enic_open,\n \t.ndo_stop\t\t= enic_stop,\n@@ -3180,6 +4320,9 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t * cancel_work_sync()) would otherwise act on an uninitialised work.\n \t */\n \tINIT_WORK(\u0026enic-\u003elink_notify_work, enic_link_notify_work_handler);\n+\tspin_lock_init(\u0026enic-\u003evf_admin_mac_lock);\n+\tINIT_DELAYED_WORK(\u0026enic-\u003evf_admin_mac_work,\n+\t\t\t  enic_vf_admin_mac_work);\n \n \t/* V2 VF: open admin channel and register with PF.\n \t * Must happen before register_netdev so the VF is fully\n@@ -3209,6 +4352,12 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t\t\t\t\"MBOX VF registration failed: %d\\n\", err);\n \t\t\tgoto err_out_admin_close;\n \t\t}\n+\t\terr = enic_vf_admin_mac_refresh(enic);\n+\t\tif (err) {\n+\t\t\tdev_err(dev,\n+\t\t\t\t\"MBOX VF admin MAC refresh failed: %d\\n\", err);\n+\t\t\tgoto err_out_admin_close;\n+\t\t}\n \t}\n \n \tnetif_set_real_num_tx_queues(netdev, enic-\u003ewq_count);\n@@ -3244,7 +4393,9 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t */\n \tenic-\u003erx_coalesce_usecs = enic-\u003etx_coalesce_usecs;\n \n-\tif (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))\n+\tif (enic_is_sriov_vf_v2(enic))\n+\t\tnetdev-\u003enetdev_ops = \u0026enic_netdev_vf_v2_ops;\n+\telse if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))\n \t\tnetdev-\u003enetdev_ops = \u0026enic_netdev_dynamic_ops;\n \telse\n \t\tnetdev-\u003enetdev_ops = \u0026enic_netdev_ops;\n@@ -3334,6 +4485,8 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t\tdev_err(dev, \"Cannot register net device, aborting\\n\");\n \t\tgoto err_out_admin_close;\n \t}\n+\tif (enic_is_sriov_vf_v2(enic))\n+\t\tenic_vf_admin_mac_rearm(enic);\n \n \treturn 0;\n \n@@ -3389,9 +4542,19 @@ static void enic_remove(struct pci_dev *pdev)\n \n \t\t/* Close the admin channel and unregister from the PF before\n \t\t * unregister_netdev() to prevent a late PF notification from\n-\t\t * touching a netdev that is being torn down.\n+\t\t * touching a netdev that is being torn down.  VF_UNREGISTER is the\n+\t\t * protocol teardown operation: the PF removes all VF-requested\n+\t\t * configuration, including the station address, before replying.\n+\t\t * Detach first while holding RTNL so any running asynchronous\n+\t\t * receive-mode update has completed and queued updates cannot enter\n+\t\t * the mailbox callback.\n \t\t */\n \t\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\t\tenic_vf_admin_mac_quiesce(enic);\n+\t\t\trtnl_lock();\n+\t\t\tnetif_device_detach(netdev);\n+\t\t\trtnl_unlock();\n+\n \t\t\tif (READ_ONCE(enic-\u003evf_registered)) {\n \t\t\t\tint unreg_err = enic_mbox_vf_unregister(enic);\n \n@@ -3410,6 +4573,8 @@ static void enic_remove(struct pci_dev *pdev)\n \t\t * enic_link_check() scheduled it just as SR-IOV was disabled.\n \t\t */\n \t\tcancel_work_sync(\u0026enic-\u003elink_notify_work);\n+\t\tif (enic_is_sriov_vf_v2(enic))\n+\t\t\tenic_vf_admin_mac_purge(enic);\n #ifdef CONFIG_PCI_IOV\n \t\tif (enic_sriov_enabled(enic)) {\n \t\t\tif (enic-\u003evf_type == ENIC_VF_TYPE_V2)\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_mbox.c b/drivers/net/ethernet/cisco/enic/enic_mbox.c\nindex 5c93ca49552ac..1fd2b23e2d8f0 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_mbox.c\n+++ b/drivers/net/ethernet/cisco/enic/enic_mbox.c\n@@ -6,6 +6,7 @@\n #include \u003clinux/dma-mapping.h\u003e\n #include \u003clinux/delay.h\u003e\n #include \u003clinux/completion.h\u003e\n+#include \u003clinux/etherdevice.h\u003e\n \n #include \"vnic_dev.h\"\n #include \"vnic_wq.h\"\n@@ -149,7 +150,20 @@ static int enic_mbox_send_msg_id(struct enic *enic, u8 msg_type,\n \t\t * or free the buffer: the device may still DMA from dma_addr.\n \t\t * Mark the channel unusable so no further sends are attempted.\n \t\t */\n+\t\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n \t\tWRITE_ONCE(enic-\u003embox_send_disabled, true);\n+\t\tWRITE_ONCE(enic-\u003embox_tx_poisoned, true);\n+\t\tif (enic_is_sriov_vf_v2(enic)) {\n+\t\t\t/* The request may have changed PF receive policy even though\n+\t\t\t * local descriptor ownership is still uncertain. Fail the VF\n+\t\t\t * closed and do not turn this into an ordinary protocol\n+\t\t\t * reconnect; the admin-channel lifecycle owns final reclamation.\n+\t\t\t */\n+\t\t\tWRITE_ONCE(enic-\u003evf_rx_quarantined, true);\n+\t\t}\n+\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tif (enic_is_sriov_vf_v2(enic))\n+\t\t\tenic_mbox_vf_link_state_set_running(enic, false);\n \t}\n \n \tnetdev_dbg(enic-\u003enetdev,\n@@ -184,6 +198,105 @@ static int enic_mbox_send_reply(struct enic *enic, u8 msg_type,\n \t\t\t\t     payload_len, msg_num, true, 0);\n }\n \n+struct enic_mbox_vf_ack {\n+\tstruct list_head list;\n+\tu64 msg_num;\n+\tu16 ret_major;\n+\tu8 msg_type;\n+};\n+\n+static void enic_mbox_vf_ack_work(struct work_struct *work)\n+{\n+\tstruct enic *enic = container_of(work, struct enic, vf_ack_work);\n+\tstruct enic_mbox_vf_ack *pending;\n+\n+\tfor (;;) {\n+\t\tstruct enic_mbox_generic_reply ack = {};\n+\t\tu8 msg_type;\n+\t\tint err;\n+\n+\t\tspin_lock_bh(\u0026enic-\u003evf_ack_lock);\n+\t\tif (list_empty(\u0026enic-\u003evf_ack_list)) {\n+\t\t\tspin_unlock_bh(\u0026enic-\u003evf_ack_lock);\n+\t\t\tbreak;\n+\t\t}\n+\t\tpending = list_first_entry(\u0026enic-\u003evf_ack_list,\n+\t\t\t\t\t   struct enic_mbox_vf_ack, list);\n+\t\tlist_del(\u0026pending-\u003elist);\n+\t\tenic-\u003evf_ack_count--;\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_ack_lock);\n+\n+\t\tif (READ_ONCE(enic-\u003embox_send_disabled)) {\n+\t\t\tkfree(pending);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tmsg_type = pending-\u003emsg_type;\n+\t\tack.ret_major = cpu_to_le16(pending-\u003eret_major);\n+\t\terr = enic_mbox_send_reply(enic, msg_type, ENIC_MBOX_DST_PF,\n+\t\t\t\t\t   \u0026ack, sizeof(ack), pending-\u003emsg_num);\n+\t\tkfree(pending);\n+\t\tif (err \u0026\u0026 net_ratelimit())\n+\t\t\tnetdev_warn(enic-\u003enetdev,\n+\t\t\t\t    \"MBOX: failed to send ACK type %u: %d\\n\",\n+\t\t\t\t    msg_type, err);\n+\t}\n+}\n+\n+static void enic_mbox_vf_queue_ack(struct enic *enic, u8 msg_type,\n+\t\t\t\t   u64 msg_num, u16 ret_major)\n+{\n+\tstruct enic_mbox_vf_ack *pending;\n+\n+\tif (READ_ONCE(enic-\u003embox_send_disabled))\n+\t\treturn;\n+\tpending = kmalloc_obj(*pending, GFP_ATOMIC);\n+\tif (!pending) {\n+\t\tif (net_ratelimit())\n+\t\t\tnetdev_warn(enic-\u003enetdev,\n+\t\t\t\t    \"MBOX: dropping ACK type %u: no memory\\n\",\n+\t\t\t\t    msg_type);\n+\t\treturn;\n+\t}\n+\tpending-\u003emsg_num = msg_num;\n+\tpending-\u003eret_major = ret_major;\n+\tpending-\u003emsg_type = msg_type;\n+\n+\tspin_lock_bh(\u0026enic-\u003evf_ack_lock);\n+\tif (READ_ONCE(enic-\u003embox_send_disabled) ||\n+\t    enic-\u003evf_ack_count \u003e= ENIC_ADMIN_DESC_COUNT) {\n+\t\tspin_unlock_bh(\u0026enic-\u003evf_ack_lock);\n+\t\tkfree(pending);\n+\t\tif (net_ratelimit())\n+\t\t\tnetdev_warn(enic-\u003enetdev,\n+\t\t\t\t    \"MBOX: dropping ACK type %u: queue unavailable\\n\",\n+\t\t\t\t    msg_type);\n+\t\treturn;\n+\t}\n+\tlist_add_tail(\u0026pending-\u003elist, \u0026enic-\u003evf_ack_list);\n+\tenic-\u003evf_ack_count++;\n+\tspin_unlock_bh(\u0026enic-\u003evf_ack_lock);\n+\tschedule_work(\u0026enic-\u003evf_ack_work);\n+}\n+\n+void enic_mbox_vf_ack_cancel(struct enic *enic)\n+{\n+\tstruct enic_mbox_vf_ack *pending, *tmp;\n+\tLIST_HEAD(discard);\n+\n+\tif (!enic-\u003embox_initialized)\n+\t\treturn;\n+\tcancel_work_sync(\u0026enic-\u003evf_ack_work);\n+\tspin_lock_bh(\u0026enic-\u003evf_ack_lock);\n+\tlist_splice_init(\u0026enic-\u003evf_ack_list, \u0026discard);\n+\tenic-\u003evf_ack_count = 0;\n+\tspin_unlock_bh(\u0026enic-\u003evf_ack_lock);\n+\tlist_for_each_entry_safe(pending, tmp, \u0026discard, list) {\n+\t\tlist_del(\u0026pending-\u003elist);\n+\t\tkfree(pending);\n+\t}\n+}\n+\n static int enic_mbox_vf_send_request(struct enic *enic, u8 request_type,\n \t\t\t\t     u8 expected_reply, void *payload,\n \t\t\t\t     u16 payload_len)\n@@ -193,6 +306,27 @@ static int enic_mbox_vf_send_request(struct enic *enic, u8 request_type,\n \t\t\t\t     expected_reply);\n }\n \n+static void enic_mbox_vf_mark_reconnect_locked(struct enic *enic,\n+\t\t\t\t\t       bool registration_lost)\n+{\n+\tlockdep_assert_held(\u0026enic-\u003embox_state_lock);\n+\n+\tif (registration_lost)\n+\t\tWRITE_ONCE(enic-\u003evf_registered, false);\n+\tenic-\u003evf_mbox_fault_generation++;\n+\tWRITE_ONCE(enic-\u003evf_mbox_reconnect_required, true);\n+\tWRITE_ONCE(enic-\u003embox_send_disabled, true);\n+\tWRITE_ONCE(enic-\u003evf_rx_quarantined, true);\n+}\n+\n+static void enic_mbox_vf_kick_recovery(struct enic *enic)\n+{\n+\tenic_mbox_vf_link_state_set_running(enic, false);\n+\tif (netif_running(enic-\u003enetdev) \u0026\u0026\n+\t    !READ_ONCE(enic-\u003evf_mbox_recovery_active))\n+\t\tschedule_work(\u0026enic-\u003ereset);\n+}\n+\n static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)\n {\n \tunsigned long left;\n@@ -203,9 +337,9 @@ static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)\n \tif (left)\n \t\treturn 0;\n \n-\t/* Invalidate a request that the handler has not already accepted.  A\n-\t * delayed reply cannot match a later request because message numbers are\n-\t * monotonic across channel reopen.\n+\t/* Invalidate a request that the handler has not already accepted. Whether\n+\t * losing the reply invalidates the current protocol generation is an\n+\t * operation-specific decision made by the caller.\n \t */\n \tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n \tif (enic-\u003embox_expected_reply) {\n@@ -218,6 +352,108 @@ static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)\n \treturn err;\n }\n \n+static void enic_mbox_vf_request_start(struct enic *enic)\n+{\n+\tmutex_lock(\u0026enic-\u003evf_mbox_request_lock);\n+\treinit_completion(\u0026enic-\u003embox_comp);\n+\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\tenic-\u003embox_expected_msg_num = 0;\n+\tenic-\u003embox_expected_reply = 0;\n+\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+}\n+\n+static void enic_mbox_vf_request_abort(struct enic *enic)\n+{\n+\tlockdep_assert_held(\u0026enic-\u003evf_mbox_request_lock);\n+\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\tenic-\u003embox_expected_reply = 0;\n+\tenic-\u003embox_expected_msg_num = 0;\n+\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\tmutex_unlock(\u0026enic-\u003evf_mbox_request_lock);\n+}\n+\n+static void enic_mbox_vf_request_finish(struct enic *enic)\n+{\n+\tlockdep_assert_held(\u0026enic-\u003evf_mbox_request_lock);\n+\tmutex_unlock(\u0026enic-\u003evf_mbox_request_lock);\n+}\n+\n+/* Return with mbox_state_lock held when this handler owns the reply. */\n+static bool enic_mbox_vf_reply_claim(struct enic *enic, u8 reply_type,\n+\t\t\t\t     u64 msg_num, u8 *expected)\n+{\n+\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\t*expected = enic-\u003embox_expected_reply;\n+\tif (*expected == reply_type \u0026\u0026\n+\t    enic-\u003embox_expected_msg_num == msg_num)\n+\t\treturn true;\n+\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\n+\treturn false;\n+}\n+\n+enum enic_mbox_vf_reply_recovery {\n+\tENIC_MBOX_VF_REPLY_OK,\n+\tENIC_MBOX_VF_REPLY_RECONNECT,\n+\tENIC_MBOX_VF_REPLY_REGISTRATION_LOST,\n+};\n+\n+static int\n+enic_mbox_vf_classify_reply(bool malformed, u16 ret_major,\n+\t\t\t    enum enic_mbox_vf_reply_recovery *recovery)\n+{\n+\t*recovery = ENIC_MBOX_VF_REPLY_OK;\n+\tif (malformed) {\n+\t\t*recovery = ENIC_MBOX_VF_REPLY_RECONNECT;\n+\t\treturn -EIO;\n+\t}\n+\t/* Some deployed peers return a negative errno in this 16-bit field.\n+\t * Interpret protocol bits only when no unknown bits are present; otherwise\n+\t * an errno such as -EINVAL could accidentally look like registration loss.\n+\t */\n+\tif (!(ret_major \u0026 ~ENIC_MBOX_ERR_MASK) \u0026\u0026\n+\t    (ret_major \u0026 ENIC_MBOX_ERR_VF_NOT_REGISTERED)) {\n+\t\t*recovery = ENIC_MBOX_VF_REPLY_REGISTRATION_LOST;\n+\t\treturn -ENODEV;\n+\t}\n+\tif (!(ret_major \u0026 ~ENIC_MBOX_ERR_MASK) \u0026\u0026\n+\t    (ret_major \u0026 ENIC_MBOX_ERR_MSG_NOT_SUPPORTED))\n+\t\treturn -EOPNOTSUPP;\n+\tif (ret_major)\n+\t\treturn -EIO;\n+\n+\treturn 0;\n+}\n+\n+static void\n+enic_mbox_vf_recover_reply_locked(struct enic *enic,\n+\t\t\t\t  enum enic_mbox_vf_reply_recovery recovery)\n+{\n+\tbool registration_lost;\n+\n+\tlockdep_assert_held(\u0026enic-\u003embox_state_lock);\n+\n+\tif (recovery != ENIC_MBOX_VF_REPLY_OK) {\n+\t\tregistration_lost =\n+\t\t\trecovery == ENIC_MBOX_VF_REPLY_REGISTRATION_LOST;\n+\t\tenic_mbox_vf_mark_reconnect_locked(enic, registration_lost);\n+\t}\n+}\n+\n+static void enic_mbox_vf_reply_complete(struct enic *enic)\n+{\n+\tlockdep_assert_held(\u0026enic-\u003embox_state_lock);\n+\tenic-\u003embox_expected_reply = 0;\n+\tenic-\u003embox_expected_msg_num = 0;\n+\t/* Publish completion before releasing the state lock.  A waiter that\n+\t * hit the timeout boundary may otherwise see the claimed state, finish the\n+\t * request, and let a new request reinitialize this completion before the\n+\t * old handler signals it.\n+\t */\n+\tcomplete(\u0026enic-\u003embox_comp);\n+\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+}\n+\n int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state)\n {\n \tstruct enic_mbox_pf_link_state_notif_msg notif = {};\n@@ -393,23 +629,21 @@ static void enic_mbox_vf_handle_reply(struct enic *enic, u8 reply_type,\n \t\t\t\t      void *payload, u64 msg_num)\n {\n \tstruct enic_mbox_generic_reply *reply = payload;\n+\tenum enic_mbox_vf_reply_recovery recovery;\n \tu16 ret_major = le16_to_cpu(reply-\u003eret_major);\n-\tu64 expected_msg_num;\n-\tu8 expected_type;\n+\tu8 expected;\n+\tint status;\n \n-\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n-\texpected_type = enic-\u003embox_expected_reply;\n-\texpected_msg_num = enic-\u003embox_expected_msg_num;\n-\tif (expected_type != reply_type || expected_msg_num != msg_num) {\n-\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\tstatus = enic_mbox_vf_classify_reply(false, ret_major, \u0026recovery);\n+\tif (!enic_mbox_vf_reply_claim(enic, reply_type, msg_num, \u0026expected)) {\n \t\tnetdev_warn(enic-\u003enetdev,\n-\t\t\t    \"MBOX: stale reply %u/%llu (expected %u/%llu), drop\\n\",\n+\t\t\t    \"MBOX: stale reply %u/%llu (expected %u), drop\\n\",\n \t\t\t    reply_type, (unsigned long long)msg_num,\n-\t\t\t    expected_type, (unsigned long long)expected_msg_num);\n+\t\t\t    expected);\n \t\treturn;\n \t}\n \n-\tif (!ret_major) {\n+\tif (!status) {\n \t\tswitch (reply_type) {\n \t\tcase ENIC_MBOX_VF_CAPABILITY_REPLY: {\n \t\t\tstruct enic_mbox_vf_capability_reply_msg *cap = payload;\n@@ -426,25 +660,174 @@ static void enic_mbox_vf_handle_reply(struct enic *enic, u8 reply_type,\n \t\t\tbreak;\n \t\t}\n \t}\n-\tenic-\u003embox_expected_reply = 0;\n-\tenic-\u003embox_expected_msg_num = 0;\n-\tcomplete(\u0026enic-\u003embox_comp);\n-\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\tenic_mbox_vf_recover_reply_locked(enic, recovery);\n+\tWRITE_ONCE(enic-\u003embox_reply_status, status);\n+\tenic_mbox_vf_reply_complete(enic);\n \n \tif (ret_major)\n \t\tnetdev_warn(enic-\u003enetdev,\n \t\t\t    \"MBOX: PF rejected reply type %u: %u/%u\\n\",\n \t\t\t    reply_type, ret_major,\n \t\t\t    le16_to_cpu(reply-\u003eret_minor));\n+\tif (recovery != ENIC_MBOX_VF_REPLY_OK)\n+\t\tenic_mbox_vf_kick_recovery(enic);\n+}\n+\n+static bool enic_mbox_vf_mac_reply_matches(const struct enic_mac_addr *request,\n+\t\t\t\t\t   const struct enic_mac_addr *reply)\n+{\n+\tu16 request_flags = le16_to_cpu(request-\u003eflags);\n+\tu16 reply_flags = le16_to_cpu(reply-\u003eflags);\n+\tu16 idempotent_result = reply_flags \u0026\n+\t\t(ENIC_MAC_ADDR_FLAG_DUPLICATE |\n+\t\t ENIC_MAC_ADDR_FLAG_NOT_FOUND);\n+\tu16 result = reply_flags \u0026 ENIC_MAC_ADDR_FLAG_REPLY_MASK;\n+\tu16 expected_result;\n+\n+\tif (!ether_addr_equal(request-\u003eaddr, reply-\u003eaddr) ||\n+\t    (request_flags \u0026 ENIC_MAC_ADDR_FLAG_REQUEST_MASK) !=\n+\t    (reply_flags \u0026 ENIC_MAC_ADDR_FLAG_REQUEST_MASK))\n+\t\treturn false;\n+\tif (hweight16(result) \u003e 1)\n+\t\treturn false;\n+\n+\t/* DUPLICATE is a successful ADD result and NOT_FOUND is a successful\n+\t * DELETE result.  Neither is valid for the opposite operation, and a\n+\t * reply cannot report both outcomes for one entry.\n+\t */\n+\texpected_result = request_flags \u0026 ENIC_MAC_ADDR_FLAG_ADD ?\n+\t\tENIC_MAC_ADDR_FLAG_DUPLICATE :\n+\t\tENIC_MAC_ADDR_FLAG_NOT_FOUND;\n+\n+\treturn !idempotent_result || idempotent_result == expected_result;\n+}\n+\n+static void enic_mbox_vf_handle_add_del_mac_reply(struct enic *enic,\n+\t\t\t\t\t\t  void *payload, u16 msg_len,\n+\t\t\t\t\t\t  u64 msg_num)\n+{\n+\tstruct enic_mbox_vf_add_del_mac_reply_msg *reply = payload;\n+\tenum enic_mbox_vf_reply_recovery recovery;\n+\tu16 reported_errors = 0;\n+\tu16 num_addrs = 0;\n+\tu16 ret_minor = 0;\n+\tu16 ret_major = 0;\n+\tu8 expected;\n+\tunsigned int i;\n+\tint status;\n+\n+\tif (msg_len \u003c sizeof(*reply)) {\n+\t\tstatus = enic_mbox_vf_classify_reply(true, 0, \u0026recovery);\n+\t} else {\n+\t\tret_major = le16_to_cpu(reply-\u003ereply.ret_major);\n+\t\tret_minor = le16_to_cpu(reply-\u003ereply.ret_minor);\n+\t\tstatus = enic_mbox_vf_classify_reply(false, ret_major,\n+\t\t\t\t\t\t     \u0026recovery);\n+\t}\n+\tif (status)\n+\t\tgoto claim;\n+\n+\tnum_addrs = le16_to_cpu(reply-\u003enum_addrs);\n+\tif (!num_addrs || num_addrs \u003e ENIC_MBOX_MAX_MAC_OPS ||\n+\t    struct_size(reply, mac_addr, num_addrs) \u003e msg_len) {\n+\t\tstatus = enic_mbox_vf_classify_reply(true, 0, \u0026recovery);\n+\t\tgoto claim;\n+\t}\n+\n+claim:\n+\tif (!enic_mbox_vf_reply_claim(enic, ENIC_MBOX_VF_ADD_DEL_MAC_REPLY,\n+\t\t\t\t      msg_num, \u0026expected))\n+\t\treturn;\n+\tif (!status \u0026\u0026\n+\t    (num_addrs != enic-\u003embox_reply_mac_count ||\n+\t     !enic-\u003embox_reply_mac_addrs)) {\n+\t\tstatus = enic_mbox_vf_classify_reply(true, 0, \u0026recovery);\n+\t} else if (!status) {\n+\t\t/* A detailed reply corresponds entry-for-entry with the request.\n+\t\t * Validate the echoed request fields and operation-specific results\n+\t\t * before exposing result flags to the waiting caller.\n+\t\t */\n+\t\tfor (i = 0; i \u003c num_addrs; i++) {\n+\t\t\tstruct enic_mac_addr *request =\n+\t\t\t\t\u0026enic-\u003embox_reply_mac_addrs[i];\n+\t\t\tu16 flags = le16_to_cpu(reply-\u003emac_addr[i].flags);\n+\n+\t\t\tif (!enic_mbox_vf_mac_reply_matches(request,\n+\t\t\t\t\t\t\t    \u0026reply-\u003emac_addr[i])) {\n+\t\t\t\tstatus = enic_mbox_vf_classify_reply(true, 0,\n+\t\t\t\t\t\t\t\t     \u0026recovery);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tif (flags \u0026 ENIC_MAC_ADDR_FLAG_INDETERMINATE_MASK) {\n+\t\t\t\tstatus = -EIO;\n+\t\t\t\trecovery = ENIC_MBOX_VF_REPLY_RECONNECT;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tif ((flags \u0026 ENIC_MAC_ADDR_FLAG_REPLY_MASK) \u0026\u0026\n+\t\t\t    !(flags \u0026 ENIC_MAC_ADDR_FLAG_SKIPPED))\n+\t\t\t\treported_errors++;\n+\t\t}\n+\t\tif (!status \u0026\u0026 reported_errors != ret_minor)\n+\t\t\tstatus = enic_mbox_vf_classify_reply(true, 0,\n+\t\t\t\t\t\t\t     \u0026recovery);\n+\n+\t\tif (!status)\n+\t\t\tfor (i = 0; i \u003c num_addrs; i++)\n+\t\t\t\tenic-\u003embox_reply_mac_addrs[i].flags =\n+\t\t\t\t\treply-\u003emac_addr[i].flags;\n+\t}\n+\t/* After a malformed reply, the VF cannot trust that its state matches the\n+\t * PF. VF_NOT_REGISTERED means the PF removed all VF state. Both require a\n+\t * new registration; an ordinary policy rejection does not.\n+\t */\n+\tenic_mbox_vf_recover_reply_locked(enic, recovery);\n+\tWRITE_ONCE(enic-\u003embox_reply_status, status);\n+\tenic_mbox_vf_reply_complete(enic);\n+\tif (recovery != ENIC_MBOX_VF_REPLY_OK)\n+\t\tenic_mbox_vf_kick_recovery(enic);\n+}\n+\n+static void enic_mbox_vf_handle_set_pkt_filter_reply(struct enic *enic,\n+\t\t\t\t\t\t     void *payload, u16 msg_len,\n+\t\t\t\t\t\t     u64 msg_num)\n+{\n+\tstruct enic_mbox_vf_set_pkt_filter_reply_msg *reply = payload;\n+\tenum enic_mbox_vf_reply_recovery recovery;\n+\tu16 applied = 0;\n+\tu16 ret_major = 0;\n+\tu8 expected;\n+\tint status;\n+\n+\tif (msg_len \u003c sizeof(*reply)) {\n+\t\tstatus = enic_mbox_vf_classify_reply(true, 0, \u0026recovery);\n+\t} else {\n+\t\tret_major = le16_to_cpu(reply-\u003ereply.ret_major);\n+\t\tstatus = enic_mbox_vf_classify_reply(false, ret_major,\n+\t\t\t\t\t\t     \u0026recovery);\n+\t\tif (status \u0026\u0026 (ret_major \u0026 ~ENIC_MBOX_ERR_MASK))\n+\t\t\trecovery = ENIC_MBOX_VF_REPLY_RECONNECT;\n+\t}\n+\tif (!status)\n+\t\tapplied = le16_to_cpu(reply-\u003ereply.ret_minor);\n+\n+\tif (!enic_mbox_vf_reply_claim(enic,\n+\t\t\t\t      ENIC_MBOX_VF_SET_PKT_FILTER_REPLY,\n+\t\t\t\t      msg_num, \u0026expected))\n+\t\treturn;\n+\tenic_mbox_vf_recover_reply_locked(enic, recovery);\n+\tWRITE_ONCE(enic-\u003embox_reply_status, status);\n+\tWRITE_ONCE(enic-\u003embox_reply_filter_flags, applied);\n+\tenic_mbox_vf_reply_complete(enic);\n+\tif (recovery != ENIC_MBOX_VF_REPLY_OK)\n+\t\tenic_mbox_vf_kick_recovery(enic);\n }\n \n static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload,\n \t\t\t\t\t   u64 msg_num)\n {\n \tstruct enic_mbox_pf_link_state_notif_msg *notif = payload;\n-\tstruct enic_mbox_pf_link_state_ack_msg ack = {};\n \tu32 link_state = le32_to_cpu(notif-\u003elink_state);\n-\tint err;\n+\tu16 ret_major = 0;\n \n \tspin_lock_bh(\u0026enic-\u003evf_link_state_lock);\n \tswitch (link_state) {\n@@ -465,16 +848,35 @@ static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload,\n \tdefault:\n \t\tnetdev_warn(enic-\u003enetdev, \"MBOX: unknown link state %u\\n\",\n \t\t\t    link_state);\n-\t\tack.ack.ret_major = cpu_to_le16(ENIC_MBOX_ERR_GENERIC);\n+\t\tret_major = ENIC_MBOX_ERR_GENERIC;\n \t\tbreak;\n \t}\n \tspin_unlock_bh(\u0026enic-\u003evf_link_state_lock);\n \n-\terr = enic_mbox_send_reply(enic, ENIC_MBOX_PF_LINK_STATE_ACK,\n-\t\t\t\t   ENIC_MBOX_DST_PF, \u0026ack, sizeof(ack), msg_num);\n-\tif (err \u0026\u0026 net_ratelimit())\n+\t/* Notification dispatch must not wait behind a synchronous request send:\n+\t * its matching reply may be queued behind this notification.\n+\t */\n+\tenic_mbox_vf_queue_ack(enic, ENIC_MBOX_PF_LINK_STATE_ACK, msg_num,\n+\t\t\t       ret_major);\n+}\n+\n+static void enic_mbox_vf_handle_admin_mac(struct enic *enic, void *payload,\n+\t\t\t\t\t  u64 msg_num)\n+{\n+\tstruct enic_mbox_pf_set_admin_mac_notif_msg *notif = payload;\n+\tu16 ret_major = 0;\n+\n+\tif (is_multicast_ether_addr(notif-\u003emac_addr)) {\n \t\tnetdev_warn(enic-\u003enetdev,\n-\t\t\t    \"MBOX: failed to send link state ACK: %d\\n\", err);\n+\t\t\t    \"MBOX: rejecting multicast admin MAC %pM\\n\",\n+\t\t\t    notif-\u003emac_addr);\n+\t\tret_major = ENIC_MBOX_ERR_GENERIC;\n+\t} else {\n+\t\tenic_vf_admin_mac_notify(enic, notif-\u003emac_addr);\n+\t}\n+\n+\tenic_mbox_vf_queue_ack(enic, ENIC_MBOX_PF_SET_ADMIN_MAC_ACK,\n+\t\t\t       msg_num, ret_major);\n }\n \n void enic_mbox_vf_link_state_reset(struct enic *enic)\n@@ -499,6 +901,17 @@ void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running)\n \tspin_unlock_bh(\u0026enic-\u003evf_link_state_lock);\n }\n \n+void enic_mbox_vf_require_reconnect(struct enic *enic)\n+{\n+\t/* A fresh REGISTER transaction lets the PF discard any VF-requested\n+\t * configuration whose final state became uncertain.\n+\t */\n+\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\tenic_mbox_vf_mark_reconnect_locked(enic, false);\n+\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\tenic_mbox_vf_kick_recovery(enic);\n+}\n+\n static bool enic_mbox_vf_payload_ok(struct enic *enic, u8 msg_type,\n \t\t\t\t    u16 payload_len, size_t min_len)\n {\n@@ -511,6 +924,34 @@ static bool enic_mbox_vf_payload_ok(struct enic *enic, u8 msg_type,\n \treturn true;\n }\n \n+static void enic_mbox_vf_malformed_msg(struct enic *enic, u8 msg_type,\n+\t\t\t\t       u64 msg_num)\n+{\n+\tu8 expected;\n+\n+\tswitch (msg_type) {\n+\tcase ENIC_MBOX_PF_LINK_STATE_NOTIF:\n+\tcase ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF:\n+\t\tenic_mbox_vf_require_reconnect(enic);\n+\t\treturn;\n+\tcase ENIC_MBOX_VF_CAPABILITY_REPLY:\n+\tcase ENIC_MBOX_VF_REGISTER_REPLY:\n+\tcase ENIC_MBOX_VF_UNREGISTER_REPLY:\n+\tcase ENIC_MBOX_VF_ADD_DEL_MAC_REPLY:\n+\tcase ENIC_MBOX_VF_SET_PKT_FILTER_REPLY:\n+\t\tbreak;\n+\tdefault:\n+\t\treturn;\n+\t}\n+\n+\tif (!enic_mbox_vf_reply_claim(enic, msg_type, msg_num, \u0026expected))\n+\t\treturn;\n+\tenic_mbox_vf_mark_reconnect_locked(enic, false);\n+\tWRITE_ONCE(enic-\u003embox_reply_status, -EIO);\n+\tenic_mbox_vf_reply_complete(enic);\n+\tenic_mbox_vf_kick_recovery(enic);\n+}\n+\n static void enic_mbox_vf_process_msg(struct enic *enic,\n \t\t\t\t     struct enic_mbox_hdr *hdr, void *payload,\n \t\t\t\t     u16 payload_len)\n@@ -522,8 +963,10 @@ static void enic_mbox_vf_process_msg(struct enic *enic,\n \t\tsize_t exp = sizeof(struct enic_mbox_vf_capability_reply_msg);\n \n \t\tif (!enic_mbox_vf_payload_ok(enic, hdr-\u003emsg_type,\n-\t\t\t\t\t     payload_len, exp))\n+\t\t\t\t\t     payload_len, exp)) {\n+\t\t\tenic_mbox_vf_malformed_msg(enic, hdr-\u003emsg_type, msg_num);\n \t\t\treturn;\n+\t\t}\n \t\tenic_mbox_vf_handle_reply(enic, hdr-\u003emsg_type, payload, msg_num);\n \t\tbreak;\n \t}\n@@ -531,8 +974,10 @@ static void enic_mbox_vf_process_msg(struct enic *enic,\n \t\tsize_t exp = sizeof(struct enic_mbox_vf_register_reply_msg);\n \n \t\tif (!enic_mbox_vf_payload_ok(enic, hdr-\u003emsg_type,\n-\t\t\t\t\t     payload_len, exp))\n+\t\t\t\t\t     payload_len, exp)) {\n+\t\t\tenic_mbox_vf_malformed_msg(enic, hdr-\u003emsg_type, msg_num);\n \t\t\treturn;\n+\t\t}\n \t\tenic_mbox_vf_handle_reply(enic, hdr-\u003emsg_type, payload, msg_num);\n \t\tbreak;\n \t}\n@@ -540,8 +985,10 @@ static void enic_mbox_vf_process_msg(struct enic *enic,\n \t\tsize_t exp = sizeof(struct enic_mbox_vf_register_reply_msg);\n \n \t\tif (!enic_mbox_vf_payload_ok(enic, hdr-\u003emsg_type,\n-\t\t\t\t\t     payload_len, exp))\n+\t\t\t\t\t     payload_len, exp)) {\n+\t\t\tenic_mbox_vf_malformed_msg(enic, hdr-\u003emsg_type, msg_num);\n \t\t\treturn;\n+\t\t}\n \t\tenic_mbox_vf_handle_reply(enic, hdr-\u003emsg_type, payload, msg_num);\n \t\tbreak;\n \t}\n@@ -549,11 +996,32 @@ static void enic_mbox_vf_process_msg(struct enic *enic,\n \t\tsize_t exp = sizeof(struct enic_mbox_pf_link_state_notif_msg);\n \n \t\tif (!enic_mbox_vf_payload_ok(enic, hdr-\u003emsg_type,\n-\t\t\t\t\t     payload_len, exp))\n+\t\t\t\t\t     payload_len, exp)) {\n+\t\t\tenic_mbox_vf_malformed_msg(enic, hdr-\u003emsg_type, msg_num);\n \t\t\treturn;\n+\t\t}\n \t\tenic_mbox_vf_handle_link_state(enic, payload, msg_num);\n \t\tbreak;\n \t}\n+\tcase ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF: {\n+\t\tsize_t exp = sizeof(struct enic_mbox_pf_set_admin_mac_notif_msg);\n+\n+\t\tif (!enic_mbox_vf_payload_ok(enic, hdr-\u003emsg_type,\n+\t\t\t\t\t     payload_len, exp)) {\n+\t\t\tenic_mbox_vf_malformed_msg(enic, hdr-\u003emsg_type, msg_num);\n+\t\t\treturn;\n+\t\t}\n+\t\tenic_mbox_vf_handle_admin_mac(enic, payload, msg_num);\n+\t\tbreak;\n+\t}\n+\tcase ENIC_MBOX_VF_ADD_DEL_MAC_REPLY:\n+\t\tenic_mbox_vf_handle_add_del_mac_reply(enic, payload,\n+\t\t\t\t\t\t      payload_len, msg_num);\n+\t\tbreak;\n+\tcase ENIC_MBOX_VF_SET_PKT_FILTER_REPLY:\n+\t\tenic_mbox_vf_handle_set_pkt_filter_reply(enic, payload,\n+\t\t\t\t\t\t\t payload_len, msg_num);\n+\t\tbreak;\n \tdefault:\n \t\tnetdev_dbg(enic-\u003enetdev,\n \t\t\t   \"MBOX: VF unhandled msg type %u\\n\",\n@@ -574,6 +1042,8 @@ static void enic_mbox_recv_handler(struct enic *enic, void *buf,\n \t\t\tnetdev_warn(enic-\u003enetdev,\n \t\t\t\t    \"MBOX: truncated message (len %u \u003c %zu)\\n\",\n \t\t\t\t    len, sizeof(*hdr));\n+\t\tif (!enic-\u003evf_state)\n+\t\t\tenic_mbox_vf_require_reconnect(enic);\n \t\treturn;\n \t}\n \n@@ -591,6 +1061,10 @@ static void enic_mbox_recv_handler(struct enic *enic, void *buf,\n \t\t\tnetdev_warn(enic-\u003enetdev,\n \t\t\t\t    \"MBOX: invalid msg_len %u (buf len %u)\\n\",\n \t\t\t\t    msg_len, len);\n+\t\tif (!enic-\u003evf_state \u0026\u0026\n+\t\t    le16_to_cpu(hdr-\u003esrc_vnic_id) == ENIC_MBOX_DST_PF)\n+\t\t\tenic_mbox_vf_malformed_msg(enic, hdr-\u003emsg_type,\n+\t\t\t\t\t\t   le64_to_cpu(hdr-\u003emsg_num));\n \t\treturn;\n \t}\n \n@@ -621,25 +1095,34 @@ int enic_mbox_vf_capability_check(struct enic *enic)\n {\n \tstruct enic_mbox_vf_capability_msg req = {};\n \tu32 version;\n+\tint status;\n \tint err;\n \n+\tenic_mbox_vf_request_start(enic);\n \tWRITE_ONCE(enic-\u003epf_cap_version, 0);\n+\tWRITE_ONCE(enic-\u003embox_reply_status, 0);\n \treq.version = cpu_to_le32(ENIC_MBOX_CAP_VERSION_1);\n \n \terr = enic_mbox_vf_send_request(enic,\n \t\t\t\t\tENIC_MBOX_VF_CAPABILITY_REQUEST,\n \t\t\t\t\tENIC_MBOX_VF_CAPABILITY_REPLY,\n \t\t\t\t\t\u0026req, sizeof(req));\n-\tif (err)\n+\tif (err) {\n+\t\tenic_mbox_vf_request_abort(enic);\n \t\treturn err;\n+\t}\n \n \terr = enic_mbox_wait_reply(enic, 3000);\n \tversion = READ_ONCE(enic-\u003epf_cap_version);\n+\tstatus = READ_ONCE(enic-\u003embox_reply_status);\n+\tenic_mbox_vf_request_finish(enic);\n \tif (err) {\n \t\tnetdev_warn(enic-\u003enetdev,\n \t\t\t    \"MBOX: no capability reply from PF\\n\");\n \t\treturn err;\n \t}\n+\tif (status)\n+\t\treturn status;\n \n \tif (version \u003c ENIC_MBOX_CAP_VERSION_1) {\n \t\tnetdev_warn(enic-\u003enetdev,\n@@ -654,22 +1137,31 @@ int enic_mbox_vf_capability_check(struct enic *enic)\n int enic_mbox_vf_register(struct enic *enic)\n {\n \tbool registered;\n+\tint status;\n \tint err;\n \n+\tenic_mbox_vf_request_start(enic);\n \tWRITE_ONCE(enic-\u003evf_registered, false);\n+\tWRITE_ONCE(enic-\u003embox_reply_status, 0);\n \n \terr = enic_mbox_vf_send_request(enic, ENIC_MBOX_VF_REGISTER_REQUEST,\n \t\t\t\t\tENIC_MBOX_VF_REGISTER_REPLY, NULL, 0);\n-\tif (err)\n+\tif (err) {\n+\t\tenic_mbox_vf_request_abort(enic);\n \t\treturn err;\n+\t}\n \n \terr = enic_mbox_wait_reply(enic, 3000);\n \tregistered = READ_ONCE(enic-\u003evf_registered);\n+\tstatus = READ_ONCE(enic-\u003embox_reply_status);\n+\tenic_mbox_vf_request_finish(enic);\n \tif (err) {\n \t\tnetdev_warn(enic-\u003enetdev,\n \t\t\t    \"MBOX: VF registration with PF timed out\\n\");\n \t\treturn err;\n \t}\n+\tif (status)\n+\t\treturn status;\n \n \tif (!registered)\n \t\treturn -ENODEV;\n@@ -680,27 +1172,206 @@ int enic_mbox_vf_register(struct enic *enic)\n int enic_mbox_vf_unregister(struct enic *enic)\n {\n \tbool registered;\n+\tint status;\n \tint err;\n \n \tif (!READ_ONCE(enic-\u003evf_registered))\n \t\treturn 0;\n \n+\tenic_mbox_vf_request_start(enic);\n+\tif (!READ_ONCE(enic-\u003evf_registered)) {\n+\t\tenic_mbox_vf_request_finish(enic);\n+\t\treturn 0;\n+\t}\n+\tWRITE_ONCE(enic-\u003embox_reply_status, 0);\n+\n \terr = enic_mbox_vf_send_request(enic,\n \t\t\t\t\tENIC_MBOX_VF_UNREGISTER_REQUEST,\n \t\t\t\t\tENIC_MBOX_VF_UNREGISTER_REPLY,\n \t\t\t\t\tNULL, 0);\n-\tif (err)\n+\tif (err) {\n+\t\tenic_mbox_vf_request_abort(enic);\n \t\treturn err;\n+\t}\n \n \terr = enic_mbox_wait_reply(enic, 3000);\n \tregistered = READ_ONCE(enic-\u003evf_registered);\n+\tstatus = READ_ONCE(enic-\u003embox_reply_status);\n+\tenic_mbox_vf_request_finish(enic);\n \tif (err)\n \t\treturn err;\n+\tif (status)\n+\t\treturn status;\n \tif (registered)\n \t\treturn -EACCES;\n \treturn 0;\n }\n \n+int enic_mbox_vf_add_del_macs(struct enic *enic,\n+\t\t\t      struct enic_mac_addr *macs, u16 num_macs)\n+{\n+\tstruct enic_mbox_vf_add_del_mac_msg *req;\n+\tunsigned int i;\n+\tint status;\n+\tint err;\n+\n+\tif (!READ_ONCE(enic-\u003evf_registered) || !enic-\u003ehas_admin_channel)\n+\t\treturn -ENODEV;\n+\tif (!num_macs || num_macs \u003e ENIC_MBOX_MAX_MAC_OPS)\n+\t\treturn -EINVAL;\n+\n+\treq = kzalloc_flex(*req, mac_addr, num_macs);\n+\tif (!req)\n+\t\treturn -ENOMEM;\n+\n+\treq-\u003enum_addrs = cpu_to_le16(num_macs);\n+\tfor (i = 0; i \u003c num_macs; i++)\n+\t\treq-\u003emac_addr[i] = macs[i];\n+\n+\tenic_mbox_vf_request_start(enic);\n+\tif (!READ_ONCE(enic-\u003evf_registered) || !enic-\u003ehas_admin_channel) {\n+\t\terr = -ENODEV;\n+\t} else {\n+\t\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tenic-\u003embox_reply_mac_addrs = macs;\n+\t\tenic-\u003embox_reply_mac_count = num_macs;\n+\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tWRITE_ONCE(enic-\u003embox_reply_status, 0);\n+\t\terr = enic_mbox_vf_send_request(enic,\n+\t\t\t\t\t\tENIC_MBOX_VF_ADD_DEL_MAC_REQUEST,\n+\t\t\t\t\t\tENIC_MBOX_VF_ADD_DEL_MAC_REPLY,\n+\t\t\t\t\t\treq,\n+\t\t\t\t\t\tstruct_size(req, mac_addr,\n+\t\t\t\t\t\t\t    num_macs));\n+\t}\n+\tkfree(req);\n+\tif (err) {\n+\t\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tenic-\u003embox_reply_mac_addrs = NULL;\n+\t\tenic-\u003embox_reply_mac_count = 0;\n+\t\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\t\tenic_mbox_vf_request_abort(enic);\n+\t\treturn err;\n+\t}\n+\n+\terr = enic_mbox_wait_reply(enic, 3000);\n+\tstatus = READ_ONCE(enic-\u003embox_reply_status);\n+\tspin_lock_bh(\u0026enic-\u003embox_state_lock);\n+\tenic-\u003embox_reply_mac_addrs = NULL;\n+\tenic-\u003embox_reply_mac_count = 0;\n+\tspin_unlock_bh(\u0026enic-\u003embox_state_lock);\n+\tif (err) {\n+\t\t/* The PF may have updated its software ledger before a hardware\n+\t\t * failure whose reply was lost. A repeated idempotent operation could\n+\t\t * then appear converged while hardware state is stale, so replay from\n+\t\t * a fresh registration generation.\n+\t\t */\n+\t\tenic_mbox_vf_require_reconnect(enic);\n+\t\tenic_mbox_vf_request_finish(enic);\n+\t\treturn err;\n+\t}\n+\tenic_mbox_vf_request_finish(enic);\n+\n+\treturn status;\n+}\n+\n+int enic_mbox_vf_add_del_mac(struct enic *enic, const u8 *addr, bool add,\n+\t\t\t     bool station)\n+{\n+\tstruct enic_mac_addr mac = {};\n+\tu16 flags = 0;\n+\tint err;\n+\n+\tether_addr_copy(mac.addr, addr);\n+\tif (add)\n+\t\tflags |= ENIC_MAC_ADDR_FLAG_ADD;\n+\tif (station)\n+\t\tflags |= ENIC_MAC_ADDR_FLAG_STATION;\n+\tmac.flags = cpu_to_le16(flags);\n+\n+\terr = enic_mbox_vf_add_del_macs(enic, \u0026mac, 1);\n+\tif (err)\n+\t\treturn err;\n+\tif (le16_to_cpu(mac.flags) \u0026 ENIC_MAC_ADDR_FLAG_ERROR_MASK)\n+\t\treturn -EACCES;\n+\n+\treturn 0;\n+}\n+\n+int enic_mbox_vf_set_pkt_filter(struct enic *enic, int directed,\n+\t\t\t\tint multicast, int broadcast,\n+\t\t\t\tint promisc, int allmulti, u16 *applied_flags)\n+{\n+\tstruct enic_mbox_vf_set_pkt_filter_msg req = {};\n+\tu16 applied;\n+\tu16 flags = 0;\n+\tu16 required;\n+\tint status;\n+\tint err;\n+\n+\tif (!READ_ONCE(enic-\u003evf_registered) || !enic-\u003ehas_admin_channel)\n+\t\treturn -ENODEV;\n+\n+\tif (directed)\n+\t\tflags |= CMD_PFILTER_DIRECTED;\n+\tif (multicast)\n+\t\tflags |= CMD_PFILTER_MULTICAST;\n+\tif (broadcast)\n+\t\tflags |= CMD_PFILTER_BROADCAST;\n+\tif (promisc)\n+\t\tflags |= CMD_PFILTER_PROMISCUOUS;\n+\tif (allmulti)\n+\t\tflags |= CMD_PFILTER_ALL_MULTICAST;\n+\treq.flags = cpu_to_le16(flags);\n+\n+\tenic_mbox_vf_request_start(enic);\n+\tif (!READ_ONCE(enic-\u003evf_registered) || !enic-\u003ehas_admin_channel) {\n+\t\tenic_mbox_vf_request_abort(enic);\n+\t\treturn -ENODEV;\n+\t}\n+\tWRITE_ONCE(enic-\u003embox_reply_status, 0);\n+\tWRITE_ONCE(enic-\u003embox_reply_filter_flags, 0);\n+\n+\terr = enic_mbox_vf_send_request(enic,\n+\t\t\t\t\tENIC_MBOX_VF_SET_PKT_FILTER_REQUEST,\n+\t\t\t\t\tENIC_MBOX_VF_SET_PKT_FILTER_REPLY,\n+\t\t\t\t\t\u0026req, sizeof(req));\n+\tif (err) {\n+\t\tenic_mbox_vf_request_abort(enic);\n+\t\treturn err;\n+\t}\n+\n+\terr = enic_mbox_wait_reply(enic, 3000);\n+\tstatus = READ_ONCE(enic-\u003embox_reply_status);\n+\tif (!err \u0026\u0026 !status) {\n+\t\tapplied = READ_ONCE(enic-\u003embox_reply_filter_flags);\n+\t\t/* Directed, multicast, and broadcast are not policy-gated.  The PF\n+\t\t * may only withhold the two broad receive modes, and may add directed\n+\t\t * reception because it is mandatory for a usable VF.\n+\t\t */\n+\t\trequired = (flags | CMD_PFILTER_DIRECTED) \u0026\n+\t\t\t   ~(CMD_PFILTER_PROMISCUOUS |\n+\t\t\t     CMD_PFILTER_ALL_MULTICAST);\n+\t\tif ((applied \u0026 ~(flags | CMD_PFILTER_DIRECTED)) ||\n+\t\t    (applied \u0026 required) != required) {\n+\t\t\tnetdev_warn(enic-\u003enetdev,\n+\t\t\t\t    \"MBOX: invalid packet filter reply %#x for request %#x\\n\",\n+\t\t\t\t    applied, flags);\n+\t\t\tenic_mbox_vf_require_reconnect(enic);\n+\t\t\tstatus = -EIO;\n+\t\t} else if (applied_flags) {\n+\t\t\t*applied_flags = applied;\n+\t\t}\n+\t}\n+\tif (err)\n+\t\tenic_mbox_vf_require_reconnect(enic);\n+\tenic_mbox_vf_request_finish(enic);\n+\tif (err)\n+\t\treturn err;\n+\n+\treturn status;\n+}\n+\n void enic_mbox_init(struct enic *enic)\n {\n \tbool reinit = enic-\u003embox_initialized;\n@@ -711,9 +1382,15 @@ void enic_mbox_init(struct enic *enic)\n \t */\n \tif (!reinit) {\n \t\tmutex_init(\u0026enic-\u003embox_lock);\n+\t\tmutex_init(\u0026enic-\u003evf_mbox_request_lock);\n \t\tinit_completion(\u0026enic-\u003embox_comp);\n \t\tspin_lock_init(\u0026enic-\u003embox_state_lock);\n+\t\tspin_lock_init(\u0026enic-\u003evf_ack_lock);\n+\t\tINIT_LIST_HEAD(\u0026enic-\u003evf_ack_list);\n+\t\tINIT_WORK(\u0026enic-\u003evf_ack_work, enic_mbox_vf_ack_work);\n \t\tenic-\u003embox_msg_num = 0;\n+\t\tif (enic_is_sriov_vf_v2(enic))\n+\t\t\tWRITE_ONCE(enic-\u003evf_rx_quarantined, true);\n \t\tenic-\u003embox_initialized = true;\n \t} else {\n \t\treinit_completion(\u0026enic-\u003embox_comp);\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_mbox.h b/drivers/net/ethernet/cisco/enic/enic_mbox.h\nindex 60409bad2f284..5eca3a25671e9 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_mbox.h\n+++ b/drivers/net/ethernet/cisco/enic/enic_mbox.h\n@@ -5,6 +5,7 @@\n #define _ENIC_MBOX_H_\n \n #include \u003clinux/bits.h\u003e\n+#include \u003clinux/if_ether.h\u003e\n #include \u003clinux/types.h\u003e\n \n /*\n@@ -22,6 +23,12 @@ enum enic_mbox_msg_type {\n \tENIC_MBOX_VF_UNREGISTER_REPLY\t\t= 5,\n \tENIC_MBOX_PF_LINK_STATE_NOTIF\t\t= 6,\n \tENIC_MBOX_PF_LINK_STATE_ACK\t\t= 7,\n+\tENIC_MBOX_VF_ADD_DEL_MAC_REQUEST\t= 10,\n+\tENIC_MBOX_VF_ADD_DEL_MAC_REPLY\t\t= 11,\n+\tENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF\t= 12,\n+\tENIC_MBOX_PF_SET_ADMIN_MAC_ACK\t\t= 13,\n+\tENIC_MBOX_VF_SET_PKT_FILTER_REQUEST\t= 14,\n+\tENIC_MBOX_VF_SET_PKT_FILTER_REPLY\t= 15,\n \tENIC_MBOX_MAX\n };\n \n@@ -42,6 +49,9 @@ struct enic_mbox_generic_reply {\n #define ENIC_MBOX_ERR_GENERIC\t\tBIT(0)\n #define ENIC_MBOX_ERR_VF_NOT_REGISTERED\tBIT(1)\n #define ENIC_MBOX_ERR_MSG_NOT_SUPPORTED\tBIT(2)\n+#define ENIC_MBOX_ERR_MASK\t\t(ENIC_MBOX_ERR_GENERIC | \\\n+\t\t\t\t\t ENIC_MBOX_ERR_VF_NOT_REGISTERED | \\\n+\t\t\t\t\t ENIC_MBOX_ERR_MSG_NOT_SUPPORTED)\n \n /* ENIC_MBOX_VF_CAPABILITY_REQUEST / _REPLY */\n #define ENIC_MBOX_CAP_VERSION_0\t\t0\n@@ -80,6 +90,71 @@ struct enic_mbox_pf_link_state_ack_msg {\n \tstruct enic_mbox_generic_reply ack;\n };\n \n+/* ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF / _ACK */\n+struct enic_mbox_pf_set_admin_mac_notif_msg {\n+\tu8 mac_addr[ETH_ALEN];\n+\t__le16 pad;\n+};\n+\n+/* ENIC_MBOX_VF_ADD_DEL_MAC_REQUEST / _REPLY */\n+#define ENIC_MAC_ADDR_FLAG_ADD\t\tBIT(0)\n+#define ENIC_MAC_ADDR_FLAG_STATION\tBIT(1)\n+#define ENIC_MAC_ADDR_FLAG_OVERFLOW\tBIT(8)\n+#define ENIC_MAC_ADDR_FLAG_DUPLICATE\tBIT(9)\n+#define ENIC_MAC_ADDR_FLAG_FAILED\tBIT(10)\n+#define ENIC_MAC_ADDR_FLAG_NOT_FOUND\tBIT(11)\n+#define ENIC_MAC_ADDR_FLAG_ERROR\tBIT(12)\n+#define ENIC_MAC_ADDR_FLAG_NOT_PERMITTED BIT(13)\n+#define ENIC_MAC_ADDR_FLAG_INVALID\tBIT(14)\n+#define ENIC_MAC_ADDR_FLAG_SKIPPED\tBIT(15)\n+\n+#define ENIC_MAC_ADDR_FLAG_REQUEST_MASK\tGENMASK(7, 0)\n+#define ENIC_MAC_ADDR_FLAG_REPLY_MASK\tGENMASK(15, 8)\n+#define ENIC_MAC_ADDR_FLAG_INDETERMINATE_MASK \\\n+\t(ENIC_MAC_ADDR_FLAG_FAILED | ENIC_MAC_ADDR_FLAG_ERROR)\n+#define ENIC_MAC_ADDR_FLAG_PERMANENT_MASK \\\n+\t(ENIC_MAC_ADDR_FLAG_OVERFLOW | ENIC_MAC_ADDR_FLAG_NOT_PERMITTED | \\\n+\t ENIC_MAC_ADDR_FLAG_INVALID)\n+#define ENIC_MAC_ADDR_FLAG_ERROR_MASK\t(ENIC_MAC_ADDR_FLAG_OVERFLOW | \\\n+\t\t\t\t\t ENIC_MAC_ADDR_FLAG_FAILED | \\\n+\t\t\t\t\t ENIC_MAC_ADDR_FLAG_ERROR | \\\n+\t\t\t\t\t ENIC_MAC_ADDR_FLAG_NOT_PERMITTED | \\\n+\t\t\t\t\t ENIC_MAC_ADDR_FLAG_INVALID | \\\n+\t\t\t\t\t ENIC_MAC_ADDR_FLAG_SKIPPED)\n+\n+/* The protocol permits replacing all perfect filters and the station address\n+ * in one request: one delete and one add operation for each address.\n+ */\n+#define ENIC_MBOX_MAX_MAC_OPS\t\t130\n+\n+struct enic_mac_addr {\n+\tu8 addr[ETH_ALEN];\n+\t__le16 flags;\n+};\n+\n+struct enic_mbox_vf_add_del_mac_msg {\n+\t__le16 num_addrs;\n+\t__le16 pad;\n+\tstruct enic_mac_addr mac_addr[];\n+};\n+\n+struct enic_mbox_vf_add_del_mac_reply_msg {\n+\tstruct enic_mbox_generic_reply reply;\n+\t__le16 num_addrs;\n+\t__le16 pad;\n+\tstruct enic_mac_addr mac_addr[];\n+};\n+\n+/* ENIC_MBOX_VF_SET_PKT_FILTER_REQUEST / _REPLY */\n+struct enic_mbox_vf_set_pkt_filter_msg {\n+\t__le16 flags;\n+\t__le16 pad;\n+};\n+\n+struct enic_mbox_vf_set_pkt_filter_reply_msg {\n+\tstruct enic_mbox_generic_reply reply;\n+};\n+\n #define ENIC_MBOX_DST_PF\t0xFFFF\n \n struct enic;\n@@ -90,8 +165,17 @@ int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id,\n int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state);\n void enic_mbox_vf_link_state_reset(struct enic *enic);\n void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running);\n+void enic_mbox_vf_ack_cancel(struct enic *enic);\n+void enic_mbox_vf_require_reconnect(struct enic *enic);\n int enic_mbox_vf_capability_check(struct enic *enic);\n int enic_mbox_vf_register(struct enic *enic);\n int enic_mbox_vf_unregister(struct enic *enic);\n+int enic_mbox_vf_add_del_macs(struct enic *enic,\n+\t\t\t      struct enic_mac_addr *macs, u16 num_macs);\n+int enic_mbox_vf_add_del_mac(struct enic *enic, const u8 *addr, bool add,\n+\t\t\t     bool station);\n+int enic_mbox_vf_set_pkt_filter(struct enic *enic, int directed, int multicast,\n+\t\t\t\tint broadcast, int promisc, int allmulti,\n+\t\t\t\tu16 *applied_flags);\n \n #endif /* _ENIC_MBOX_H_ */\ndiff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c\nindex ccbf5c9a21d0f..80fe7e819c375 100644\n--- a/drivers/net/ethernet/cisco/enic/enic_rq.c\n+++ b/drivers/net/ethernet/cisco/enic/enic_rq.c\n@@ -330,8 +330,6 @@ static void enic_rq_indicate_buf(struct enic *enic, struct vnic_rq *rq,\n \tu16 bytes_written, vlan_tci, checksum;\n \tu32 rss_hash;\n \n-\trqstats-\u003epackets++;\n-\n \tcq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc, \u0026ingress_port,\n \t\t\t    \u0026fcoe, \u0026eop, \u0026sop, \u0026rss_type, \u0026csum_not_calc,\n \t\t\t    \u0026rss_hash, \u0026bytes_written, \u0026packet_error,\n@@ -340,8 +338,15 @@ static void enic_rq_indicate_buf(struct enic *enic, struct vnic_rq *rq,\n \t\t\t    \u0026tcp_udp_csum_ok, \u0026udp, \u0026tcp, \u0026ipv4_csum_ok, \u0026ipv6,\n \t\t\t    \u0026ipv4, \u0026ipv4_fragment, \u0026fcs_ok);\n \n-\tif (enic_rq_pkt_error(rq, packet_error, fcs_ok, bytes_written))\n+\tif (enic_rq_pkt_error(rq, packet_error, fcs_ok, bytes_written)) {\n+\t\trqstats-\u003epackets++;\n+\t\treturn;\n+\t}\n+\tif (unlikely(READ_ONCE(enic-\u003evf_rx_quarantined))) {\n+\t\tdev_core_stats_rx_dropped_inc(enic-\u003enetdev);\n \t\treturn;\n+\t}\n+\trqstats-\u003epackets++;\n \n \tif (eop \u0026\u0026 bytes_written \u003e 0) {\n \t\t/* Good receive\ndiff --git a/include/linux/netdevice.h b/include/linux/netdevice.h\nindex 5d16737167eed..c1807a8f733bf 100644\n--- a/include/linux/netdevice.h\n+++ b/include/linux/netdevice.h\n@@ -5197,6 +5197,7 @@ static inline void __dev_mc_unsync(struct net_device *dev,\n \n /* Functions used for secondary unicast and multicast support */\n void dev_set_rx_mode(struct net_device *dev);\n+void netif_rx_mode_schedule_update(struct net_device *dev);\n void netif_rx_mode_schedule_retry(struct net_device *dev);\n int netif_set_promiscuity(struct net_device *dev, int inc);\n int dev_set_promiscuity(struct net_device *dev, int inc);\ndiff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c\nindex 08528ca0a8b31..17770a38b5ab2 100644\n--- a/net/core/dev_addr_lists.c\n+++ b/net/core/dev_addr_lists.c\n@@ -1337,6 +1337,27 @@ static void netif_rx_mode_queue(struct net_device *dev)\n \t__netdev_work_core_sched(dev, NETDEV_WORK_RX_MODE);\n }\n \n+/**\n+ * netif_rx_mode_schedule_update() - schedule a new receive-mode update\n+ * @dev: network device\n+ *\n+ * Cancel any pending retry and reset its backoff before scheduling an\n+ * immediate receive-mode update. This does not reset address-list\n+ * synchronization state. Callers which need to replay lost device state must\n+ * unsynchronize the affected address lists before scheduling the update.\n+ *\n+ * Context: sleepable. The caller must hold the device operations lock, or\n+ * RTNL for a device which still uses RTNL-compatible operations.\n+ */\n+void netif_rx_mode_schedule_update(struct net_device *dev)\n+{\n+\tmight_sleep();\n+\tnetdev_assert_locked_ops_compat(dev);\n+\tnetif_rx_mode_cancel_retry(dev);\n+\tnetif_rx_mode_queue(dev);\n+}\n+EXPORT_SYMBOL_GPL(netif_rx_mode_schedule_update);\n+\n static void netif_rx_mode_retry(struct timer_list *t)\n {\n \tstruct net_device *dev =\n"
}

2/1 2026/09/30 20:37 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies the Cisco VIC Ethernet NIC driver (drivers/net/ethernet/cisco/enic/) to add SR-IOV V2 VF mailbox operations, packet filter configuration, and administrative MAC address handling. It also introduces a new helper function netif_rx_mode_schedule_update() in net/core/dev_addr_lists.c which is exclusively called by the enic driver. Cisco VIC is vendor-specific PCIe hardware that is not emulated in standard virtualized fuzzing environments (QEMU/GCE), and no existing core networking logic was altered. As a result, all modified code is structurally unreachable during fuzzing.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 15bb502ae90afecfe2d1f1e6218447d80e7300eb
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Sep 30 20:37:38 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
index 7a509a0569900..80056b5f41245 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -239,6 +239,8 @@ enum enic_vf_type {
 };
 
 /* Per-instance private data structure */
+struct enic_mac_addr;
+
 struct enic {
 	struct net_device *netdev;
 	struct pci_dev *pdev;
@@ -303,8 +305,26 @@ struct enic {
 	 * left the resources freed.
 	 */
 	bool admin_chan_up;
-	/* set on send timeout; cleared on channel re-open */
+	/* Blocks sends while the channel is closed or awaiting recovery. */
 	bool mbox_send_disabled;
+	/* A send timeout leaves a descriptor hardware-owned.  Do not reopen the
+	 * channel during this device lifetime until reset/DMA fencing is proven.
+	 */
+	bool mbox_tx_poisoned;
+	/* After a lost or inconsistent reply, the VF cannot know whether the PF
+	 * applied the request. Reconnect during the next open or reset.
+	 */
+	bool vf_mbox_reconnect_required;
+	/* Suppress self-requeue while a reset worker is already attempting the
+	 * reconnect. A failed handshake remains quarantined until a later external
+	 * recovery event or administrative close/open.
+	 */
+	bool vf_mbox_recovery_active;
+	u32 vf_mbox_fault_generation;
+	/* One slow-path-owned predicate keeps the RX hot path fail-closed while
+	 * VF registration is lost or receive state may not match the PF.
+	 */
+	bool vf_rx_quarantined;
 	struct vnic_wq admin_wq;
 	struct vnic_rq admin_rq;
 	struct vnic_cq admin_cq[2];
@@ -325,6 +345,13 @@ struct enic {
 	spinlock_t vf_link_state_lock;
 	enum enic_vf_link_state vf_link_state;
 	bool vf_link_running;
+	/* Last station address which may still be installed at the PF. */
+	u8 vf_station_addr[ETH_ALEN] __aligned(2);
+	bool vf_station_addr_valid;
+	/* Tracks a completely opened V2 VF datapath.  An internal reset can stop
+	 * it while netif_running() remains true, then fail before reopen.
+	 */
+	bool vf_datapath_open;
 
 	/* MBOX protocol state — mbox_lock serializes admin WQ sends */
 	struct mutex mbox_lock;
@@ -335,9 +362,34 @@ struct enic {
 	 * the requester.
 	 */
 	struct completion mbox_comp;
+	struct mutex vf_mbox_request_lock; /* serializes VF request lifetimes */
 	spinlock_t mbox_state_lock;	/* protects expected reply state */
+	spinlock_t vf_ack_lock;		/* protects vf_ack_list */
+	struct list_head vf_ack_list;
+	struct work_struct vf_ack_work;
+	unsigned int vf_ack_count;
+	struct delayed_work vf_admin_mac_work;
+	spinlock_t vf_admin_mac_lock;	/* protects pending admin MAC */
+	u8 vf_admin_mac[ETH_ALEN];
+	u8 vf_admin_mac_random_addr[ETH_ALEN];
+	bool vf_admin_mac_pending;
+	bool vf_admin_mac_random_valid;
+	bool vf_admin_mac_work_enabled;
+	bool vf_admin_mac_recovery_attempted;
+	u32 vf_admin_mac_generation;
+	u8 vf_admin_mac_retries;
 	u64 mbox_expected_msg_num;
 	u8 mbox_expected_reply;
+	int mbox_reply_status;
+	u16 mbox_reply_filter_flags;
+	/* The request mutex keeps this caller-owned reply array alive until the
+	 * matching reply handler has copied all per-address result flags.
+	 */
+	struct enic_mac_addr *mbox_reply_mac_addrs;
+	u16 mbox_reply_mac_count;
+	u16 vf_pkt_filter_requested;
+	u16 vf_pkt_filter_applied;
+	bool vf_pkt_filter_valid;
 	bool mbox_initialized;
 
 	/* PF: per-VF MBOX state, allocated when SRIOV V2 is enabled */
@@ -462,6 +514,10 @@ static inline int enic_dma_map_check(struct enic *enic, dma_addr_t dma_addr)
 }
 
 void enic_reset_addr_lists(struct enic *enic);
+void enic_vf_admin_mac_notify(struct enic *enic, const u8 *addr);
+void enic_vf_admin_mac_quiesce(struct enic *enic);
+void enic_vf_admin_mac_rearm(struct enic *enic);
+void enic_vf_admin_mac_purge(struct enic *enic);
 int enic_sriov_enabled(struct enic *enic);
 int enic_is_valid_vf(struct enic *enic, int vf);
 int enic_is_dynamic(struct enic *enic);
diff --git a/drivers/net/ethernet/cisco/enic/enic_admin.c b/drivers/net/ethernet/cisco/enic/enic_admin.c
index 61c82b48044d0..5e52d4da8d3c9 100644
--- a/drivers/net/ethernet/cisco/enic/enic_admin.c
+++ b/drivers/net/ethernet/cisco/enic/enic_admin.c
@@ -132,14 +132,22 @@ unsigned int enic_admin_wq_cq_service(struct enic *enic)
  */
 #define ENIC_ADMIN_MSG_MAX	256
 
+static void enic_admin_rx_lost(struct enic *enic)
+{
+	if (enic_is_sriov_vf_v2(enic))
+		enic_mbox_vf_require_reconnect(enic);
+}
+
 static void enic_admin_msg_enqueue(struct enic *enic, void *buf,
 				   unsigned int len)
 {
 	struct enic_admin_msg *msg;
 
 	msg = kmalloc_flex(*msg, data, len);
-	if (!msg)
+	if (!msg) {
+		enic_admin_rx_lost(enic);
 		return;
+	}
 
 	msg->len = len;
 	memcpy(msg->data, buf, len);
@@ -152,6 +160,7 @@ static void enic_admin_msg_enqueue(struct enic *enic, void *buf,
 			netdev_warn(enic->netdev,
 				    "admin msg backlog full (%u); dropping\n",
 				    ENIC_ADMIN_MSG_MAX);
+		enic_admin_rx_lost(enic);
 		return;
 	}
 	list_add_tail(&msg->list, &enic->admin_msg_list);
@@ -194,8 +203,10 @@ unsigned int enic_admin_rq_cq_service(struct enic *enic)
 		rq_desc = desc;
 		bwf = le16_to_cpu(rq_desc->bytes_written_flags);
 		bytes_written = bwf & CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
-		if (bytes_written > buf->len)
+		if (bytes_written > buf->len) {
+			enic_admin_rx_lost(enic);
 			goto next_desc;
+		}
 
 		dma_sync_single_for_cpu(&enic->pdev->dev,
 					buf->dma_addr, buf->len,
@@ -210,11 +221,13 @@ unsigned int enic_admin_rq_cq_service(struct enic *enic)
 		if (bwf & CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) {
 			netdev_warn_once(enic->netdev,
 					 "admin RQ: truncated message dropped\n");
+			enic_admin_rx_lost(enic);
 			goto next_desc;
 		}
 		if (!(rq_desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK)) {
 			netdev_warn_once(enic->netdev,
 					 "admin RQ: bad FCS, dropping message\n");
+			enic_admin_rx_lost(enic);
 			goto next_desc;
 		}
 
@@ -534,6 +547,11 @@ int enic_admin_channel_open(struct enic *enic)
 
 	if (!enic->has_admin_channel)
 		return -ENODEV;
+	if (READ_ONCE(enic->mbox_tx_poisoned)) {
+		netdev_err(enic->netdev,
+			   "Refusing to reopen admin channel after send timeout\n");
+		return -EIO;
+	}
 
 	/* Keep MBOX sends disabled for the entire open sequence.  It is
 	 * cleared only after every resource is allocated and enabled below,
@@ -623,6 +641,8 @@ void enic_admin_channel_close(struct enic *enic)
 {
 	int err;
 
+	if (enic_is_sriov_vf_v2(enic))
+		enic_vf_admin_mac_quiesce(enic);
 	if (!enic->has_admin_channel)
 		return;
 
@@ -641,6 +661,11 @@ void enic_admin_channel_close(struct enic *enic)
 	enic_admin_teardown_intr(enic);
 	cancel_work_sync(&enic->link_notify_work);
 	cancel_work_sync(&enic->admin_msg_work);
+	/* admin_msg_work is the sole VF ACK producer.  Drain it before the ACK
+	 * worker so an enqueue cannot race the final cancel and queue purge.
+	 */
+	if (enic_is_sriov_vf_v2(enic))
+		enic_mbox_vf_ack_cancel(enic);
 	enic_admin_msg_drain(enic);
 
 	enic_admin_qp_type_set(enic, QP_DISABLE);
diff --git a/drivers/net/ethernet/cisco/enic/enic_dev.c b/drivers/net/ethernet/cisco/enic/enic_dev.c
index 659787f73cf18..48c1ca9b40fb2 100644
--- a/drivers/net/ethernet/cisco/enic/enic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/enic_dev.c
@@ -32,6 +32,17 @@ int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats)
 	return err;
 }
 
+int enic_dev_get_mac_addr(struct enic *enic, u8 *mac_addr)
+{
+	int err;
+
+	spin_lock_bh(&enic->devcmd_lock);
+	err = vnic_dev_get_mac_addr(enic->vdev, mac_addr);
+	spin_unlock_bh(&enic->devcmd_lock);
+
+	return err;
+}
+
 int enic_dev_add_station_addr(struct enic *enic)
 {
 	int err;
diff --git a/drivers/net/ethernet/cisco/enic/enic_dev.h b/drivers/net/ethernet/cisco/enic/enic_dev.h
index 698d0cb020644..66d0e51681f5a 100644
--- a/drivers/net/ethernet/cisco/enic/enic_dev.h
+++ b/drivers/net/ethernet/cisco/enic/enic_dev.h
@@ -26,6 +26,7 @@
 
 int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info);
 int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats);
+int enic_dev_get_mac_addr(struct enic *enic, u8 *mac_addr);
 int enic_dev_add_station_addr(struct enic *enic);
 int enic_dev_del_station_addr(struct enic *enic);
 int enic_dev_packet_filter(struct enic *enic, int directed, int multicast,
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 9086e6dd558aa..382bac6669bf3 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -71,6 +71,8 @@
 #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2   0x02b7  /* enet SRIOV V2 VF */
 #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_USNIC 0x00cf /* enet USNIC VF */
 
+static int __enic_stop(struct net_device *netdev, bool remove_vf_station);
+
 /* Supported devices */
 static const struct pci_device_id enic_id_table[] = {
 	{ PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) },
@@ -87,6 +89,9 @@ MODULE_DEVICE_TABLE(pci, enic_id_table);
 
 #define ENIC_LARGE_PKT_THRESHOLD		1000
 #define ENIC_MAX_COALESCE_TIMERS		10
+#define ENIC_VF_ADMIN_MAC_MAX_RETRIES		4
+#define ENIC_VF_ADMIN_MAC_RETRY_MS		100
+#define ENIC_VF_ADMIN_MAC_REFRESH_RETRIES	3
 /*  Interrupt moderation table, which will be used to decide the
  *  coalescing timer values
  *  {rx_rate in Mbps, mapping percentage of the range}
@@ -1038,12 +1043,15 @@ void enic_reset_addr_lists(struct enic *enic)
 {
 	struct net_device *netdev = enic->netdev;
 
+	netif_addr_lock_bh(netdev);
 	__dev_uc_unsync(netdev, NULL);
 	__dev_mc_unsync(netdev, NULL);
+	netif_addr_unlock_bh(netdev);
 
 	enic->mc_count = 0;
 	enic->uc_count = 0;
 	enic->flags = 0;
+	enic->vf_pkt_filter_valid = false;
 }
 
 static int enic_set_mac_addr(struct net_device *netdev, char *addr)
@@ -1063,6 +1071,465 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)
 	return 0;
 }
 
+static void enic_vf_station_recovery_required(struct enic *enic)
+{
+	enic_mbox_vf_require_reconnect(enic);
+}
+
+static void enic_vf_station_addr_set(struct enic *enic, const u8 *addr)
+{
+	ether_addr_copy(enic->vf_station_addr, addr);
+	enic->vf_station_addr_valid = true;
+}
+
+static int enic_vf_keep_nonstation_sync(struct net_device *netdev,
+					const u8 *addr)
+{
+	struct enic *enic = netdev_priv(netdev);
+
+	if (!ether_addr_equal(addr, enic->vf_station_addr))
+		return -ENOENT;
+	if (WARN_ON_ONCE(!enic->uc_count))
+		return 0;
+	enic->uc_count--;
+
+	return 0;
+}
+
+static void enic_vf_station_sync_reset(struct enic *enic)
+{
+	if (!enic->vf_station_addr_valid)
+		return;
+
+	/* The PF keys its MAC ledger by address. A station entry is also the
+	 * receive filter for that address and must not retain a second core
+	 * synchronization reference which could later delete the station.
+	 */
+	netif_addr_lock_bh(enic->netdev);
+	__dev_uc_unsync(enic->netdev, enic_vf_keep_nonstation_sync);
+	netif_addr_unlock_bh(enic->netdev);
+}
+
+static int enic_vf_station_addr_del(struct enic *enic)
+{
+	int err;
+
+	if (!enic->vf_station_addr_valid)
+		return 0;
+
+	err = enic_mbox_vf_add_del_mac(enic, enic->vf_station_addr,
+				       false, true);
+	if (!err) {
+		enic->vf_station_addr_valid = false;
+	} else if (READ_ONCE(enic->mbox_tx_poisoned)) {
+		enic_mbox_vf_link_state_set_running(enic, false);
+	} else if (err == -EACCES) {
+		/* A definitive rejected DELETE leaves an unrequested station
+		 * filter installed. Fresh registration is the cleanup boundary.
+		 */
+		enic_vf_station_recovery_required(enic);
+	}
+
+	return err;
+}
+
+/* End every replacement with an equal-address DEL+ADD pair. A bare ADD could
+ * report DUPLICATE for a secondary exact filter without applying the current
+ * station-address policy. If another station is tracked, delete it first in
+ * the same compound request.
+ */
+static int enic_vf_station_addr_replace(struct enic *enic, const u8 *addr)
+{
+	struct enic_mac_addr macs[3] = {};
+	bool all_deletes_skipped = true;
+	bool deletes_converged = true;
+	u16 num_macs = 0;
+	unsigned int i;
+	u16 result;
+	int err;
+
+	if (enic->vf_station_addr_valid &&
+	    !ether_addr_equal(enic->vf_station_addr, addr)) {
+		ether_addr_copy(macs[num_macs].addr, enic->vf_station_addr);
+		macs[num_macs++].flags =
+			cpu_to_le16(ENIC_MAC_ADDR_FLAG_STATION);
+	}
+	ether_addr_copy(macs[num_macs].addr, addr);
+	macs[num_macs++].flags = cpu_to_le16(ENIC_MAC_ADDR_FLAG_STATION);
+	ether_addr_copy(macs[num_macs].addr, addr);
+	macs[num_macs++].flags = cpu_to_le16(ENIC_MAC_ADDR_FLAG_ADD |
+					    ENIC_MAC_ADDR_FLAG_STATION);
+
+	err = enic_mbox_vf_add_del_macs(enic, macs, num_macs);
+	if (err) {
+		if (READ_ONCE(enic->mbox_tx_poisoned))
+			enic_mbox_vf_link_state_set_running(enic, false);
+		return err;
+	}
+
+	for (i = 0; i < num_macs - 1; i++) {
+		result = le16_to_cpu(macs[i].flags) &
+			 ENIC_MAC_ADDR_FLAG_REPLY_MASK;
+		if (result != ENIC_MAC_ADDR_FLAG_SKIPPED)
+			all_deletes_skipped = false;
+		if (result && result != ENIC_MAC_ADDR_FLAG_NOT_FOUND)
+			deletes_converged = false;
+	}
+	result = le16_to_cpu(macs[num_macs - 1].flags) &
+		 ENIC_MAC_ADDR_FLAG_REPLY_MASK;
+	if (deletes_converged && !result)
+		return 0;
+
+	/* A policy-rejected ADD can be reported with all preceding DELETEs
+	 * skipped. No operation changed state in that coherent result tuple.
+	 */
+	if (all_deletes_skipped && result) {
+		if (result & (ENIC_MAC_ADDR_FLAG_DUPLICATE |
+			      ENIC_MAC_ADDR_FLAG_PERMANENT_MASK))
+			return -EACCES;
+		return -EIO;
+	}
+
+	/* After any other partial or contradictory result, the VF does not know
+	 * which station address the PF kept. Re-register before accepting traffic.
+	 */
+	enic_vf_station_recovery_required(enic);
+	for (i = 0; i < num_macs; i++)
+		if (le16_to_cpu(macs[i].flags) &
+		    ENIC_MAC_ADDR_FLAG_PERMANENT_MASK)
+			return -EACCES;
+
+	return -EIO;
+}
+
+static void enic_vf_admin_mac_cache_selected(struct enic *enic,
+					     const u8 *addr)
+{
+	/* A zero administrative policy delegates the operational address to
+	 * the VF. Preserve a successful user selection across reconnects.
+	 */
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	if (is_zero_ether_addr(enic->vf_admin_mac)) {
+		ether_addr_copy(enic->vf_admin_mac_random_addr, addr);
+		enic->vf_admin_mac_random_valid = true;
+	}
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+}
+
+static void enic_vf_admin_mac_work(struct work_struct *work)
+{
+	struct enic *enic = container_of(to_delayed_work(work), struct enic,
+					 vf_admin_mac_work);
+	u8 policy[ETH_ALEN];
+	u8 selected[ETH_ALEN];
+	unsigned long delay = 0;
+	u32 generation = 0;
+	bool changed;
+	bool mutated = false;
+	bool reschedule = false;
+	bool station_installed = false;
+	bool stale = false;
+	bool zero_policy;
+	bool pending;
+	int err = 0;
+
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	pending = enic->vf_admin_mac_pending &&
+		enic->vf_admin_mac_work_enabled;
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+	if (!pending)
+		return;
+
+	/* Teardown owns RTNL while synchronously cancelling this work. Do not
+	 * block that owner.
+	 */
+	if (!rtnl_trylock()) {
+		spin_lock_bh(&enic->vf_admin_mac_lock);
+		if (enic->vf_admin_mac_pending &&
+		    enic->vf_admin_mac_work_enabled)
+			mod_delayed_work(system_wq, &enic->vf_admin_mac_work,
+					 msecs_to_jiffies(10));
+		spin_unlock_bh(&enic->vf_admin_mac_lock);
+		return;
+	}
+
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	pending = enic->vf_admin_mac_pending &&
+		enic->vf_admin_mac_work_enabled;
+	if (pending) {
+		ether_addr_copy(policy, enic->vf_admin_mac);
+		generation = enic->vf_admin_mac_generation;
+		zero_policy = is_zero_ether_addr(policy);
+		if (zero_policy && enic->vf_admin_mac_random_valid)
+			ether_addr_copy(selected,
+					enic->vf_admin_mac_random_addr);
+	}
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+	if (!pending)
+		goto unlock;
+
+	if (zero_policy && !READ_ONCE(enic->vf_admin_mac_random_valid)) {
+		eth_random_addr(selected);
+		spin_lock_bh(&enic->vf_admin_mac_lock);
+		if (!enic->vf_admin_mac_pending ||
+		    !enic->vf_admin_mac_work_enabled ||
+		    enic->vf_admin_mac_generation != generation ||
+		    !is_zero_ether_addr(enic->vf_admin_mac)) {
+			stale = true;
+		} else if (enic->vf_admin_mac_random_valid) {
+			ether_addr_copy(selected,
+					enic->vf_admin_mac_random_addr);
+		} else {
+			ether_addr_copy(enic->vf_admin_mac_random_addr, selected);
+			enic->vf_admin_mac_random_valid = true;
+		}
+		spin_unlock_bh(&enic->vf_admin_mac_lock);
+		if (stale)
+			goto unlock;
+	} else if (!zero_policy) {
+		ether_addr_copy(selected, policy);
+	}
+
+	if (!netif_device_present(enic->netdev) ||
+	    !READ_ONCE(enic->vf_registered)) {
+		err = -EAGAIN;
+		goto unlock;
+	}
+
+	/* A nonzero notification describes a station address the PF has already
+	 * installed. Zero delegates selection to the VF, which registers the
+	 * selected random address through the policy-safe replacement request.
+	 */
+	if (!READ_ONCE(enic->vf_datapath_open)) {
+		station_installed = !zero_policy &&
+			(!enic->vf_station_addr_valid ||
+			 ether_addr_equal(enic->vf_station_addr, selected));
+	} else if (zero_policy) {
+		mutated = true;
+		err = enic_vf_station_addr_replace(enic, selected);
+		station_installed = !err;
+	} else if (enic->vf_station_addr_valid &&
+		   !ether_addr_equal(enic->vf_station_addr, selected)) {
+		mutated = true;
+		err = enic_vf_station_addr_del(enic);
+		station_installed = !err;
+	} else {
+		station_installed = true;
+	}
+	if (err)
+		goto unlock;
+
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	if (!enic->vf_admin_mac_pending ||
+	    !enic->vf_admin_mac_work_enabled ||
+	    enic->vf_admin_mac_generation != generation) {
+		stale = true;
+		/* If policy changed while the request was running, the completed
+		 * station change may no longer match it. Record recovery while holding
+		 * vf_admin_mac_lock, which also protects VF worker shutdown. Teardown
+		 * therefore either suppresses the update or sees it first, and already
+		 * uses unregister/register to clear old state.
+		 */
+		if (mutated && enic->vf_admin_mac_work_enabled)
+			enic_vf_station_recovery_required(enic);
+	} else {
+		enic->vf_admin_mac_pending = false;
+		enic->vf_admin_mac_retries = 0;
+		enic->vf_admin_mac_recovery_attempted = false;
+		if (!zero_policy)
+			enic->vf_admin_mac_random_valid = false;
+	}
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+	if (stale)
+		goto unlock;
+
+	changed = !ether_addr_equal(enic->netdev->dev_addr, selected);
+	enic_vf_station_sync_reset(enic);
+	eth_hw_addr_set(enic->netdev, selected);
+	if (!zero_policy || changed)
+		enic->netdev->addr_assign_type = zero_policy ?
+			NET_ADDR_RANDOM : NET_ADDR_SET;
+	ether_addr_copy(enic->mac_addr, selected);
+	if (station_installed)
+		enic_vf_station_addr_set(enic, selected);
+	enic_vf_station_sync_reset(enic);
+	if (enic->netdev->reg_state == NETREG_REGISTERED) {
+		if (changed)
+			call_netdevice_notifiers(NETDEV_CHANGEADDR,
+						 enic->netdev);
+		netif_rx_mode_schedule_update(enic->netdev);
+	}
+	netdev_info(enic->netdev, "MBOX: admin MAC set to %pM\n", selected);
+
+unlock:
+	rtnl_unlock();
+
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	if (err && enic->vf_admin_mac_pending &&
+	    enic->vf_admin_mac_work_enabled &&
+	    generation == enic->vf_admin_mac_generation &&
+	    !READ_ONCE(enic->mbox_send_disabled)) {
+		if (enic->vf_admin_mac_retries <
+		    ENIC_VF_ADMIN_MAC_MAX_RETRIES) {
+			enic->vf_admin_mac_retries++;
+			reschedule = true;
+			delay = msecs_to_jiffies(ENIC_VF_ADMIN_MAC_RETRY_MS);
+		} else if (!enic->vf_admin_mac_recovery_attempted) {
+			enic->vf_admin_mac_recovery_attempted = true;
+			/* vf_admin_mac_lock also protects VF worker shutdown. */
+			enic_vf_station_recovery_required(enic);
+		}
+	}
+	if (enic->vf_admin_mac_pending &&
+	    enic->vf_admin_mac_work_enabled &&
+	    generation != enic->vf_admin_mac_generation) {
+		reschedule = true;
+		delay = 0;
+	}
+	if (enic->vf_admin_mac_pending && reschedule)
+		mod_delayed_work(system_wq, &enic->vf_admin_mac_work, delay);
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+}
+
+void enic_vf_admin_mac_notify(struct enic *enic, const u8 *addr)
+{
+	bool new_policy;
+
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	new_policy = !enic->vf_admin_mac_pending ||
+		!ether_addr_equal(enic->vf_admin_mac, addr);
+	if (new_policy) {
+		ether_addr_copy(enic->vf_admin_mac, addr);
+		if (!is_zero_ether_addr(addr))
+			enic->vf_admin_mac_random_valid = false;
+		enic->vf_admin_mac_pending = true;
+		enic->vf_admin_mac_generation++;
+		enic->vf_admin_mac_retries = 0;
+		enic->vf_admin_mac_recovery_attempted = false;
+	}
+	if (new_policy && enic->vf_admin_mac_work_enabled)
+		mod_delayed_work(system_wq, &enic->vf_admin_mac_work, 0);
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+}
+
+void enic_vf_admin_mac_quiesce(struct enic *enic)
+{
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	enic->vf_admin_mac_work_enabled = false;
+	enic->vf_admin_mac_generation++;
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+	cancel_delayed_work_sync(&enic->vf_admin_mac_work);
+}
+
+void enic_vf_admin_mac_rearm(struct enic *enic)
+{
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	enic->vf_admin_mac_work_enabled = true;
+	if (enic->vf_admin_mac_pending)
+		mod_delayed_work(system_wq, &enic->vf_admin_mac_work, 0);
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+}
+
+void enic_vf_admin_mac_purge(struct enic *enic)
+{
+	enic_vf_admin_mac_quiesce(enic);
+	spin_lock_bh(&enic->vf_admin_mac_lock);
+	enic->vf_admin_mac_pending = false;
+	enic->vf_admin_mac_random_valid = false;
+	enic->vf_admin_mac_recovery_attempted = false;
+	enic->vf_admin_mac_retries = 0;
+	enic->vf_admin_mac_generation++;
+	spin_unlock_bh(&enic->vf_admin_mac_lock);
+}
+
+/* CMD_GET_MAC_ADDR is the PF-owned policy store. Re-read it after REGISTER so
+ * a lost notification cannot leave the VF using stale administrative policy.
+ */
+static int enic_vf_admin_mac_refresh(struct enic *enic)
+{
+	u8 previous_policy[ETH_ALEN];
+	u8 random_addr[ETH_ALEN];
+	u8 selected[ETH_ALEN];
+	u8 policy[ETH_ALEN];
+	u32 generation;
+	bool apply_policy;
+	bool changed;
+	bool pending;
+	bool policy_changed;
+	bool zero_policy;
+	unsigned int attempt;
+	int err;
+
+	for (attempt = 0; attempt < ENIC_VF_ADMIN_MAC_REFRESH_RETRIES;
+	     attempt++) {
+		spin_lock_bh(&enic->vf_admin_mac_lock);
+		generation = enic->vf_admin_mac_generation;
+		pending = enic->vf_admin_mac_pending;
+		ether_addr_copy(previous_policy, enic->vf_admin_mac);
+		spin_unlock_bh(&enic->vf_admin_mac_lock);
+
+		err = enic_dev_get_mac_addr(enic, policy);
+		if (err)
+			return err;
+		if (is_multicast_ether_addr(policy))
+			return -EADDRNOTAVAIL;
+
+		zero_policy = is_zero_ether_addr(policy);
+		if (zero_policy)
+			eth_random_addr(random_addr);
+
+		spin_lock_bh(&enic->vf_admin_mac_lock);
+		if (enic->vf_admin_mac_generation != generation) {
+			spin_unlock_bh(&enic->vf_admin_mac_lock);
+			continue;
+		}
+
+		policy_changed = !ether_addr_equal(previous_policy, policy);
+		apply_policy = pending || policy_changed ||
+			!is_valid_ether_addr(enic->netdev->dev_addr) ||
+			(!zero_policy &&
+			 !ether_addr_equal(enic->netdev->dev_addr, policy));
+		if (!apply_policy) {
+			ether_addr_copy(selected, enic->netdev->dev_addr);
+			if (zero_policy) {
+				ether_addr_copy(enic->vf_admin_mac_random_addr,
+						selected);
+				enic->vf_admin_mac_random_valid = true;
+			}
+		} else if (zero_policy && enic->vf_admin_mac_random_valid) {
+			ether_addr_copy(selected,
+					enic->vf_admin_mac_random_addr);
+		} else if (zero_policy) {
+			ether_addr_copy(selected, random_addr);
+			ether_addr_copy(enic->vf_admin_mac_random_addr, selected);
+			enic->vf_admin_mac_random_valid = true;
+		} else {
+			ether_addr_copy(selected, policy);
+			enic->vf_admin_mac_random_valid = false;
+		}
+		ether_addr_copy(enic->vf_admin_mac, policy);
+		enic->vf_admin_mac_pending = false;
+		enic->vf_admin_mac_recovery_attempted = false;
+		enic->vf_admin_mac_retries = 0;
+		enic->vf_admin_mac_generation++;
+		spin_unlock_bh(&enic->vf_admin_mac_lock);
+
+		changed = !ether_addr_equal(enic->netdev->dev_addr, selected);
+		eth_hw_addr_set(enic->netdev, selected);
+		if (!zero_policy || changed)
+			enic->netdev->addr_assign_type = zero_policy ?
+				NET_ADDR_RANDOM : NET_ADDR_SET;
+		ether_addr_copy(enic->mac_addr, selected);
+		if (changed && enic->netdev->reg_state == NETREG_REGISTERED)
+			call_netdevice_notifiers(NETDEV_CHANGEADDR,
+						 enic->netdev);
+
+		return 0;
+	}
+
+	return -EAGAIN;
+}
+
 static int enic_set_mac_address_dynamic(struct net_device *netdev, void *p)
 {
 	struct enic *enic = netdev_priv(netdev);
@@ -1070,6 +1537,53 @@ static int enic_set_mac_address_dynamic(struct net_device *netdev, void *p)
 	char *addr = saddr->sa_data;
 	int err;
 
+	if (enic_is_sriov_vf_v2(enic)) {
+		if (!is_valid_ether_addr(addr))
+			return -EADDRNOTAVAIL;
+
+		spin_lock_bh(&enic->vf_admin_mac_lock);
+		err = is_valid_ether_addr(enic->vf_admin_mac) &&
+		      !ether_addr_equal(enic->vf_admin_mac, addr);
+		spin_unlock_bh(&enic->vf_admin_mac_lock);
+		if (err)
+			return -EPERM;
+		if (ether_addr_equal(addr, netdev->dev_addr))
+			return 0;
+
+		if (enic->vf_datapath_open &&
+		    !READ_ONCE(enic->vf_registered))
+			return -ENODEV;
+
+		/* An internal reset keeps IFF_UP set while its failed reopen leaves
+		 * the datapath closed. Cache the requested address in that state; the
+		 * next successful open installs it together with the datapath.
+		 */
+		if (!enic->vf_datapath_open) {
+			err = enic_set_mac_addr(netdev, addr);
+			if (!err)
+				enic_vf_admin_mac_cache_selected(enic, addr);
+			return err;
+		}
+
+		/* Keep the old software address visible until the complete station
+		 * replacement proves convergence.
+		 */
+		err = enic_vf_station_addr_replace(enic, addr);
+		if (err)
+			return err;
+
+		enic_vf_station_sync_reset(enic);
+		err = enic_set_mac_addr(netdev, addr);
+		if (!err) {
+			enic_vf_station_addr_set(enic, addr);
+			enic_vf_station_sync_reset(enic);
+			enic_vf_admin_mac_cache_selected(enic, addr);
+			netif_rx_mode_schedule_update(netdev);
+		}
+
+		return err;
+	}
+
 	if (netif_running(enic->netdev)) {
 		err = enic_dev_del_station_addr(enic);
 		if (err)
@@ -1107,17 +1621,380 @@ static int enic_set_mac_address(struct net_device *netdev, void *p)
 	return enic_dev_add_station_addr(enic);
 }
 
+static u16 enic_rx_mode_to_pkt_filter(struct net_device *netdev,
+				      unsigned int uc_count,
+				      unsigned int mc_count)
+{
+	u16 flags = CMD_PFILTER_DIRECTED;
+
+	if (netdev->flags & IFF_MULTICAST)
+		flags |= CMD_PFILTER_MULTICAST;
+	if (netdev->flags & IFF_BROADCAST)
+		flags |= CMD_PFILTER_BROADCAST;
+	if ((netdev->flags & IFF_PROMISC) ||
+	    uc_count > ENIC_UNICAST_PERFECT_FILTERS)
+		flags |= CMD_PFILTER_PROMISCUOUS;
+	if ((netdev->flags & IFF_ALLMULTI) ||
+	    mc_count > ENIC_MULTICAST_PERFECT_FILTERS)
+		flags |= CMD_PFILTER_ALL_MULTICAST;
+
+	return flags;
+}
+
+/* Deployed async PFs count the station MAC in the 32-entry UC table. */
+static bool enic_vf_uc_needs_promisc(unsigned int uc_count)
+{
+	return uc_count >= ENIC_UNICAST_PERFECT_FILTERS;
+}
+
+static int enic_vf_set_pkt_filter(struct enic *enic, u16 flags,
+				  u16 *applied_flags)
+{
+	u16 applied;
+	int err;
+
+	/* The PF can change trust policy independently and thereby withdraw
+	 * broad modes. Always refresh those requests so the returned applied
+	 * flags remain authoritative. The other modes are not trust-gated and
+	 * can be reused for ordinary address-list churn.
+	 */
+	if (!(flags & (CMD_PFILTER_PROMISCUOUS |
+		       CMD_PFILTER_ALL_MULTICAST)) &&
+	    enic->vf_pkt_filter_valid &&
+	    enic->vf_pkt_filter_requested == flags) {
+		if (applied_flags)
+			*applied_flags = enic->vf_pkt_filter_applied;
+		return 0;
+	}
+
+	err = enic_mbox_vf_set_pkt_filter(enic,
+					  !!(flags & CMD_PFILTER_DIRECTED),
+					  !!(flags & CMD_PFILTER_MULTICAST),
+					  !!(flags & CMD_PFILTER_BROADCAST),
+					  !!(flags & CMD_PFILTER_PROMISCUOUS),
+					  !!(flags & CMD_PFILTER_ALL_MULTICAST),
+					  &applied);
+	if (err)
+		return err;
+
+	enic->vf_pkt_filter_requested = flags;
+	enic->vf_pkt_filter_applied = applied;
+	enic->vf_pkt_filter_valid = true;
+	if (applied_flags)
+		*applied_flags = applied;
+
+	return 0;
+}
+
+static void enic_vf_report_pkt_filter_denial(struct net_device *netdev,
+					     u16 requested, u16 applied)
+{
+	if ((requested & CMD_PFILTER_PROMISCUOUS) &&
+	    !(applied & CMD_PFILTER_PROMISCUOUS))
+		netdev_dbg(netdev, "PF policy denied promiscuous receive mode\n");
+	if ((requested & CMD_PFILTER_ALL_MULTICAST) &&
+	    !(applied & CMD_PFILTER_ALL_MULTICAST))
+		netdev_dbg(netdev,
+			   "PF policy denied all-multicast receive mode\n");
+}
+
+struct enic_vf_mac_op {
+	struct netdev_hw_addr *ha;
+	unsigned int *filter_count;
+};
+
+static unsigned int
+enic_vf_addr_list_count(const struct enic *enic,
+			const struct netdev_hw_addr_list *list)
+{
+	const struct netdev_hw_addr *ha;
+	unsigned int count = 0;
+
+	netdev_hw_addr_list_for_each(ha, list)
+		if (ha->refcount > ha->sync_cnt &&
+		    !(enic->vf_station_addr_valid &&
+		      ether_addr_equal(ha->addr, enic->vf_station_addr)))
+			count++;
+
+	return count;
+}
+
+static int enic_vf_collect_mac_ops(struct enic *enic,
+				   struct netdev_hw_addr_list *list,
+				   bool install_new,
+				   unsigned int *filter_count,
+				   struct enic_mac_addr *macs,
+				   struct enic_vf_mac_op *ops,
+				   u16 *num_ops)
+{
+	struct netdev_hw_addr *ha;
+	u16 pos = *num_ops;
+
+	/* Deletes precede adds so a full perfect-filter table has room for a
+	 * replacement address in the same transaction.
+	 */
+	netdev_hw_addr_list_for_each(ha, list) {
+		if (enic->vf_station_addr_valid &&
+		    ether_addr_equal(ha->addr, enic->vf_station_addr))
+			continue;
+		if (!ha->sync_cnt ||
+		    ha->refcount != ha->sync_cnt)
+			continue;
+		if (pos == ENIC_MBOX_MAX_MAC_OPS)
+			return -E2BIG;
+
+		ether_addr_copy(macs[pos].addr, ha->addr);
+		macs[pos].flags = 0;
+		ops[pos].ha = ha;
+		ops[pos].filter_count = filter_count;
+		pos++;
+	}
+
+	if (!install_new)
+		goto done;
+
+	netdev_hw_addr_list_for_each(ha, list) {
+		if (enic->vf_station_addr_valid &&
+		    ether_addr_equal(ha->addr, enic->vf_station_addr))
+			continue;
+		if (ha->sync_cnt)
+			continue;
+		if (pos == ENIC_MBOX_MAX_MAC_OPS)
+			return -E2BIG;
+
+		ether_addr_copy(macs[pos].addr, ha->addr);
+		macs[pos].flags = cpu_to_le16(ENIC_MAC_ADDR_FLAG_ADD);
+		ops[pos].ha = ha;
+		ops[pos].filter_count = filter_count;
+		pos++;
+	}
+
+done:
+	*num_ops = pos;
+	return 0;
+}
+
+static int enic_vf_sync_mac_filters(struct enic *enic,
+				    struct netdev_hw_addr_list *uc,
+				    struct netdev_hw_addr_list *mc,
+				    bool install_uc, bool install_mc)
+{
+	struct enic_vf_mac_op *ops;
+	struct enic_mac_addr *macs;
+	bool permanent_add = false;
+	bool reconnect = false;
+	bool retryable_add = false;
+	u16 num_ops = 0;
+	unsigned int i;
+	int err = 0;
+
+	/* A class can contribute at most its installed perfect filters as
+	 * deletes and its finite perfect-filter limit as adds. Keep the wire
+	 * batch large enough for both classes so an update always fits in one
+	 * transaction and -E2BIG remains only a defensive state-corruption
+	 * check.
+	 */
+	BUILD_BUG_ON(ENIC_MBOX_MAX_MAC_OPS <
+		     2 * (ENIC_UNICAST_PERFECT_FILTERS +
+			  ENIC_MULTICAST_PERFECT_FILTERS));
+
+	macs = kcalloc(ENIC_MBOX_MAX_MAC_OPS, sizeof(*macs), GFP_KERNEL);
+	if (!macs)
+		return -ENOMEM;
+	ops = kcalloc(ENIC_MBOX_MAX_MAC_OPS, sizeof(*ops), GFP_KERNEL);
+	if (!ops) {
+		err = -ENOMEM;
+		goto free_macs;
+	}
+
+	err = enic_vf_collect_mac_ops(enic, uc, install_uc,
+				      &enic->uc_count,
+				      macs, ops, &num_ops);
+	if (err)
+		goto free_ops;
+	err = enic_vf_collect_mac_ops(enic, mc, install_mc,
+				      &enic->mc_count,
+				      macs, ops, &num_ops);
+	if (err || !num_ops)
+		goto free_ops;
+
+	/* The protocol carries all changed unicast and multicast addresses in
+	 * one request.  Besides matching the native ABI, this bounds time spent
+	 * in the RTNL-held asynchronous receive-mode callback to one MAC reply.
+	 */
+	err = enic_mbox_vf_add_del_macs(enic, macs, num_ops);
+	if (err)
+		goto free_ops;
+
+	for (i = 0; i < num_ops; i++) {
+		u16 flags = le16_to_cpu(macs[i].flags);
+		bool add = flags & ENIC_MAC_ADDR_FLAG_ADD;
+
+		if (flags & ENIC_MAC_ADDR_FLAG_SKIPPED) {
+			if (add)
+				retryable_add = true;
+			else
+				reconnect = true;
+			continue;
+		}
+		if (flags & ENIC_MAC_ADDR_FLAG_PERMANENT_MASK) {
+			if (add)
+				permanent_add = true;
+			else
+				reconnect = true;
+			continue;
+		}
+
+		if (add) {
+			ops[i].ha->sync_cnt++;
+			ops[i].ha->refcount++;
+			(*ops[i].filter_count)++;
+		} else {
+			ops[i].ha->sync_cnt--;
+			ops[i].ha->refcount--;
+			if (WARN_ON_ONCE(!*ops[i].filter_count))
+				err = -EIO;
+			else
+				(*ops[i].filter_count)--;
+		}
+	}
+
+	/* A failed DELETE can leave hardware accepting an address no longer in
+	 * the requested list.  Registration is the fail-closed cleanup boundary.
+	 * A skipped ADD changes no acceptance state and can use the bounded core
+	 * retry path.  Permanent ADD denials remain stable policy results.
+	 */
+	if (reconnect) {
+		enic_mbox_vf_require_reconnect(enic);
+		err = -EIO;
+	} else if (retryable_add) {
+		err = -EAGAIN;
+	} else if (permanent_add) {
+		err = -EACCES;
+	}
+
+free_ops:
+	kfree(ops);
+free_macs:
+	kfree(macs);
+	return err;
+}
+
+static int enic_set_vf_rx_mode(struct net_device *netdev,
+			       struct netdev_hw_addr_list *uc,
+			       struct netdev_hw_addr_list *mc)
+{
+	struct enic *enic = netdev_priv(netdev);
+	unsigned int uc_count = enic_vf_addr_list_count(enic, uc);
+	unsigned int mc_count = enic_vf_addr_list_count(enic, mc);
+	u16 flags = enic_rx_mode_to_pkt_filter(netdev, uc_count, mc_count);
+	bool uc_overflow = enic_vf_uc_needs_promisc(uc_count);
+	bool mc_overflow = mc_count > ENIC_MULTICAST_PERFECT_FILTERS;
+	u16 broad_modes = CMD_PFILTER_PROMISCUOUS |
+			  CMD_PFILTER_ALL_MULTICAST;
+	bool broad_enable_needed;
+	bool broad_withdrawal;
+	bool filter_needed;
+	bool target_filter_updated = false;
+	u16 prefilter_flags;
+	u16 applied_flags;
+	int err;
+
+	if (uc_overflow)
+		flags |= CMD_PFILTER_PROMISCUOUS;
+
+	if (!READ_ONCE(enic->vf_registered))
+		return -ENODEV;
+
+	filter_needed = !enic->vf_pkt_filter_valid ||
+			 enic->vf_pkt_filter_requested != flags ||
+			 (flags & broad_modes);
+	broad_enable_needed =
+		(!enic->vf_pkt_filter_valid && (flags & broad_modes)) ||
+		(flags & broad_modes & ~enic->vf_pkt_filter_requested);
+	broad_withdrawal = enic->vf_pkt_filter_valid &&
+		(enic->vf_pkt_filter_applied & broad_modes & ~flags);
+	if (broad_enable_needed) {
+		/* Establish newly required broad coverage before an independent
+		 * exact-address rejection can block it. Retain any broad mode that
+		 * is currently applied until its finite replacement is installed.
+		 */
+		prefilter_flags = flags;
+		if (enic->vf_pkt_filter_valid)
+			prefilter_flags |= enic->vf_pkt_filter_applied & broad_modes;
+		err = enic_vf_set_pkt_filter(enic, prefilter_flags,
+					     &applied_flags);
+		if (err)
+			return err;
+		target_filter_updated = prefilter_flags == flags;
+		enic_vf_report_pkt_filter_denial(netdev, flags, applied_flags);
+	}
+
+	if (broad_withdrawal) {
+		/* Withdraw stale broad acceptance before installing its finite
+		 * replacement. Complete both phases in this callback so a synchronous
+		 * receive-mode operation cannot return between them.
+		 */
+		err = enic_vf_set_pkt_filter(enic, flags, &applied_flags);
+		if (err) {
+			/* The previously applied broad mode may still be active.  Do
+			 * not rely on the core's bounded retry budget to narrow it.
+			 * Fresh registration is the fail-closed policy boundary.  A
+			 * local send timeout is already terminal and cannot use ordinary
+			 * reconnect recovery.
+			 */
+			if (!READ_ONCE(enic->mbox_tx_poisoned) &&
+			    !READ_ONCE(enic->vf_mbox_reconnect_required))
+				enic_mbox_vf_require_reconnect(enic);
+			return err;
+		}
+		target_filter_updated = true;
+		enic_vf_report_pkt_filter_denial(netdev, flags, applied_flags);
+	}
+
+	/* Keep the finite subset of exact filters already installed for an
+	 * overflowing class. Broad mode covers the remaining addresses when PF
+	 * policy permits it, while the independent finite class can still make
+	 * progress. When a class becomes finite again, stale broad acceptance was
+	 * withdrawn above before this exact-filter reconciliation.
+	 */
+	err = enic_vf_sync_mac_filters(enic, uc, mc, !uc_overflow,
+				       !mc_overflow);
+	if (err == -EACCES) {
+		/* Do not spend the core retry budget repeating an exact operation
+		 * that the PF rejected permanently. Finish any independent packet
+		 * policy change below before returning success.
+		 */
+		err = 0;
+	}
+	if (err)
+		return err;
+
+	if (!target_filter_updated && filter_needed) {
+		err = enic_vf_set_pkt_filter(enic, flags, &applied_flags);
+		if (err)
+			return err;
+	} else if (!target_filter_updated) {
+		applied_flags = enic->vf_pkt_filter_applied;
+	}
+
+	enic_vf_report_pkt_filter_denial(netdev, flags, applied_flags);
+
+	return 0;
+}
+
 /* netif_tx_lock held, BHs disabled */
 static void enic_set_rx_mode(struct net_device *netdev)
 {
 	struct enic *enic = netdev_priv(netdev);
-	int directed = 1;
-	int multicast = (netdev->flags & IFF_MULTICAST) ? 1 : 0;
-	int broadcast = (netdev->flags & IFF_BROADCAST) ? 1 : 0;
-	int promisc = (netdev->flags & IFF_PROMISC) ||
-		netdev_uc_count(netdev) > ENIC_UNICAST_PERFECT_FILTERS;
-	int allmulti = (netdev->flags & IFF_ALLMULTI) ||
-		netdev_mc_count(netdev) > ENIC_MULTICAST_PERFECT_FILTERS;
+	u16 filter_flags = enic_rx_mode_to_pkt_filter(netdev,
+					       netdev_uc_count(netdev),
+					       netdev_mc_count(netdev));
+	int directed = !!(filter_flags & CMD_PFILTER_DIRECTED);
+	int multicast = !!(filter_flags & CMD_PFILTER_MULTICAST);
+	int broadcast = !!(filter_flags & CMD_PFILTER_BROADCAST);
+	int promisc = !!(filter_flags & CMD_PFILTER_PROMISCUOUS);
+	int allmulti = !!(filter_flags & CMD_PFILTER_ALL_MULTICAST);
 	unsigned int flags = netdev->flags |
 		(allmulti ? IFF_ALLMULTI : 0) |
 		(promisc ? IFF_PROMISC : 0);
@@ -1718,10 +2595,17 @@ static void enic_notify_timer_start(struct enic *enic)
 	}
 }
 
+static int enic_admin_chan_reopen(struct enic *enic);
+
 /* rtnl lock is held, process context */
 static int enic_open(struct net_device *netdev)
 {
 	struct enic *enic = netdev_priv(netdev);
+	bool vf_mac_added = false;
+	u16 vf_filter_applied;
+	u16 vf_filter_flags;
+	unsigned int vf_mc_count;
+	unsigned int vf_uc_count;
 	unsigned int i;
 	int err, ret;
 	unsigned int max_pkt_len = netdev->mtu + VLAN_ETH_HLEN;
@@ -1736,6 +2620,30 @@ static int enic_open(struct net_device *netdev)
 		.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV,
 	};
 
+	/* A reply timeout invalidates the current request generation.  Rebuild
+	 * and re-register the channel before allocating datapath resources so a
+	 * later userspace down/up can recover a failed open or reset handshake.
+	 * A send timeout is intentionally not recoverable here because its WQ
+	 * descriptor may still be hardware-owned.
+	 */
+	if (enic_is_sriov_vf_v2(enic) &&
+	    READ_ONCE(enic->mbox_tx_poisoned))
+		return -EIO;
+	if (enic_is_sriov_vf_v2(enic) &&
+	    (!enic->admin_chan_up || !READ_ONCE(enic->vf_registered) ||
+	     READ_ONCE(enic->vf_mbox_reconnect_required))) {
+		/* Re-registration makes the PF discard the old VF-requested
+		 * filters.  Clear the netdev-core synchronization state so the
+		 * receive-mode callback replays the current address lists.
+		 */
+		enic_reset_addr_lists(enic);
+		if (enic->admin_chan_up)
+			enic_admin_channel_close(enic);
+		err = enic_admin_chan_reopen(enic);
+		if (err)
+			return err;
+	}
+
 	err = enic_request_intr(enic);
 	if (err) {
 		netdev_err(netdev, "Unable to request irq.\n");
@@ -1778,8 +2686,55 @@ static int enic_open(struct net_device *netdev)
 
 	if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
 		enic_dev_add_station_addr(enic);
+	if (enic_is_sriov_vf_v2(enic)) {
+		if (!READ_ONCE(enic->vf_registered)) {
+			netdev_err(netdev, "VF is not registered with its PF\n");
+			err = -ENODEV;
+			goto err_out_disable_wq;
+		}
+
+		err = enic_vf_station_addr_replace(enic, netdev->dev_addr);
+		if (err) {
+			netdev_err(netdev,
+				   "Failed to register VF station address: %d\n",
+				   err);
+			goto err_out_disable_wq;
+		}
+		enic_vf_station_addr_set(enic, netdev->dev_addr);
+		enic_vf_station_sync_reset(enic);
+		vf_mac_added = true;
+
+		netif_addr_lock_bh(netdev);
+		vf_uc_count = enic_vf_addr_list_count(enic, &netdev->uc);
+		vf_mc_count = enic_vf_addr_list_count(enic, &netdev->mc);
+		netif_addr_unlock_bh(netdev);
+
+		vf_filter_flags = enic_rx_mode_to_pkt_filter(netdev,
+							     vf_uc_count,
+							     vf_mc_count);
+		if (enic_vf_uc_needs_promisc(vf_uc_count))
+			vf_filter_flags |= CMD_PFILTER_PROMISCUOUS;
+		err = enic_vf_set_pkt_filter(enic, vf_filter_flags,
+					     &vf_filter_applied);
+		if (err) {
+			netdev_err(netdev,
+				   "Failed to configure VF packet filter: %d\n",
+				   err);
+			goto err_out_disable_wq;
+		}
+		if ((enic_vf_uc_needs_promisc(vf_uc_count) &&
+		     !(vf_filter_applied & CMD_PFILTER_PROMISCUOUS)) ||
+		    (vf_mc_count > ENIC_MULTICAST_PERFECT_FILTERS &&
+		     !(vf_filter_applied & CMD_PFILTER_ALL_MULTICAST))) {
+			netdev_err(netdev,
+				   "PF denied receive mode required by VF address lists\n");
+			err = -EACCES;
+			goto err_out_disable_wq;
+		}
+	}
 
-	enic_set_rx_mode(netdev);
+	if (!enic_is_sriov_vf_v2(enic))
+		enic_set_rx_mode(netdev);
 
 	netif_tx_wake_all_queues(netdev);
 
@@ -1794,17 +2749,41 @@ static int enic_open(struct net_device *netdev)
 		netdev_err(netdev, "Failed to enable device: %d\n", err);
 		goto err_out_dev_enable;
 	}
+	if (enic_is_sriov_vf_v2(enic)) {
+		/* Commit the replay only if no mailbox fault arrived while station
+		 * and receive policy were being programmed.  Keep the state lock
+		 * through the carrier transition so a later fault necessarily wins
+		 * and turns carrier back off.
+		 */
+		spin_lock_bh(&enic->mbox_state_lock);
+		if (!READ_ONCE(enic->vf_registered) ||
+		    READ_ONCE(enic->mbox_send_disabled) ||
+		    READ_ONCE(enic->mbox_tx_poisoned) ||
+		    READ_ONCE(enic->vf_mbox_reconnect_required)) {
+			err = -EIO;
+		} else {
+			WRITE_ONCE(enic->vf_rx_quarantined, false);
+			enic_mbox_vf_link_state_set_running(enic, true);
+		}
+		spin_unlock_bh(&enic->mbox_state_lock);
+		if (err) {
+			netdev_err(netdev,
+				   "MBOX state changed during VF datapath open\n");
+			goto err_out_dev_disable;
+		}
+	}
 
 	for (i = 0; i < enic->intr_count; i++)
 		vnic_intr_unmask(&enic->intr[i]);
-
 	enic_notify_timer_start(enic);
 	enic_rfs_timer_start(enic);
 	if (enic_is_sriov_vf_v2(enic))
-		enic_mbox_vf_link_state_set_running(enic, true);
+		enic->vf_datapath_open = true;
 
 	return 0;
 
+err_out_dev_disable:
+	enic_dev_disable(enic);
 err_out_dev_enable:
 	for (i = 0; i < enic->rq_count; i++)
 		napi_disable(&enic->napi[i]);
@@ -1812,6 +2791,15 @@ static int enic_open(struct net_device *netdev)
 		for (i = 0; i < enic->wq_count; i++)
 			napi_disable(&enic->napi[enic_cq_wq(enic, i)]);
 	netif_tx_disable(netdev);
+err_out_disable_wq:
+	if (vf_mac_added) {
+		ret = enic_vf_station_addr_del(enic);
+		if (ret) {
+			netdev_warn(netdev,
+				    "Failed to remove VF station address during open rollback: %d\n",
+				    ret);
+		}
+	}
 	if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
 		enic_dev_del_station_addr(enic);
 	for (i = 0; i < enic->wq_count; i++)
@@ -1834,12 +2822,19 @@ static int enic_open(struct net_device *netdev)
 }
 
 /* rtnl lock is held, process context */
-static int enic_stop(struct net_device *netdev)
+static int __enic_stop(struct net_device *netdev, bool remove_vf_station)
 {
 	struct enic *enic = netdev_priv(netdev);
 	unsigned int i;
 	int err;
 
+	/* Internal reset leaves netif_running() set while the datapath is down.
+	 * If re-registration or reopen then fails, a later administrative close
+	 * must not disable NAPI a second time.
+	 */
+	if (enic_is_sriov_vf_v2(enic) && !enic->vf_datapath_open)
+		return 0;
+
 	for (i = 0; i < enic->intr_count; i++) {
 		vnic_intr_mask(&enic->intr[i]);
 		(void)vnic_intr_masked(&enic->intr[i]); /* flush write */
@@ -1863,6 +2858,15 @@ static int enic_stop(struct net_device *netdev)
 		for (i = 0; i < enic->wq_count; i++)
 			napi_disable(&enic->napi[enic_cq_wq(enic, i)]);
 	netif_tx_disable(netdev);
+	if (remove_vf_station && enic_is_sriov_vf_v2(enic) &&
+	    READ_ONCE(enic->vf_registered)) {
+		err = enic_vf_station_addr_del(enic);
+		if (err) {
+			netdev_warn(netdev,
+				    "Failed to remove VF station address: %d\n",
+				    err);
+		}
+	}
 
 	if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
 		enic_dev_del_station_addr(enic);
@@ -1893,10 +2897,17 @@ static int enic_stop(struct net_device *netdev)
 		vnic_cq_clean(&enic->cq[i]);
 	for (i = 0; i < enic->intr_count; i++)
 		vnic_intr_clean(&enic->intr[i]);
+	if (enic_is_sriov_vf_v2(enic))
+		enic->vf_datapath_open = false;
 
 	return 0;
 }
 
+static int enic_stop(struct net_device *netdev)
+{
+	return __enic_stop(netdev, true);
+}
+
 static int _enic_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	bool running = netif_running(netdev);
@@ -2196,14 +3207,15 @@ static bool enic_has_admin_chan(struct enic *enic)
 	       (enic_sriov_enabled(enic) && enic->vf_type == ENIC_VF_TYPE_V2);
 }
 
-/* Re-establish the admin/MBOX channel after a reset has re-created the data
- * path.  Mirrors the relevant part of the probe / SR-IOV-enable sequence:
+/* Re-establish the admin/MBOX channel after a reset has re-created the vNIC
+ * resources.  Mirrors the relevant part of the probe / SR-IOV-enable sequence:
  * reinitialise MBOX and reopen the channel, then for a VF re-run the PF
  * handshake (the reset wiped the VF's admin QP, so the VF must register
  * again), or for a PF re-push the current link state to registered VFs.
  */
-static void enic_admin_chan_reopen(struct enic *enic)
+static int enic_admin_chan_reopen(struct enic *enic)
 {
+	u32 recovery_generation = 0;
 	int err;
 
 	/* Install the MBOX receive handler and clear pending reply state before
@@ -2222,12 +3234,17 @@ static void enic_admin_chan_reopen(struct enic *enic)
 	 */
 	if (enic_is_sriov_vf_v2(enic))
 		WRITE_ONCE(enic->vf_registered, false);
+	if (enic_is_sriov_vf_v2(enic)) {
+		spin_lock_bh(&enic->mbox_state_lock);
+		recovery_generation = enic->vf_mbox_fault_generation;
+		spin_unlock_bh(&enic->mbox_state_lock);
+	}
 
 	err = enic_admin_channel_open(enic);
 	if (err) {
 		netdev_err(enic->netdev,
 			   "admin channel reopen after reset failed: %d\n", err);
-		return;
+		return err;
 	}
 
 	if (enic_is_sriov_vf_v2(enic)) {
@@ -2237,7 +3254,7 @@ static void enic_admin_chan_reopen(struct enic *enic)
 				   "MBOX capability check after reset failed: %d\n",
 				   err);
 			enic_admin_channel_close(enic);
-			return;
+			return err;
 		}
 		err = enic_mbox_vf_register(enic);
 		if (err) {
@@ -2245,7 +3262,37 @@ static void enic_admin_chan_reopen(struct enic *enic)
 				   "MBOX VF re-registration after reset failed: %d\n",
 				   err);
 			enic_admin_channel_close(enic);
+			return err;
+		}
+		enic_reset_addr_lists(enic);
+		enic->vf_station_addr_valid = false;
+		err = enic_vf_admin_mac_refresh(enic);
+		if (err) {
+			netdev_err(enic->netdev,
+				   "Failed to refresh VF admin MAC after reset: %d\n",
+				   err);
+			enic_admin_channel_close(enic);
+			return err;
+		}
+		/* Capability negotiation and registration establish a new protocol
+		 * generation after authoritative MAC policy is refreshed. RX remains
+		 * quarantined until enic_open() replays station and receive policy.
+		 */
+		spin_lock_bh(&enic->mbox_state_lock);
+		if (enic->vf_mbox_fault_generation != recovery_generation ||
+		    READ_ONCE(enic->mbox_tx_poisoned)) {
+			err = -EAGAIN;
+		} else {
+			WRITE_ONCE(enic->vf_mbox_reconnect_required, false);
+		}
+		spin_unlock_bh(&enic->mbox_state_lock);
+		if (err) {
+			netdev_warn(enic->netdev,
+				    "MBOX state changed during VF re-registration\n");
+			enic_admin_channel_close(enic);
+			return err;
 		}
+		enic_vf_admin_mac_rearm(enic);
 	} else {
 		/* The link came back up during enic_open() above while MBOX
 		 * sends were still disabled (channel not yet reopened), so that
@@ -2253,79 +3300,135 @@ static void enic_admin_chan_reopen(struct enic *enic)
 		 */
 		schedule_work(&enic->link_notify_work);
 	}
+
+	return 0;
 }
 
 static void enic_reset(struct work_struct *work)
 {
 	struct enic *enic = container_of(work, struct enic, reset);
+	bool vf_recovery = enic_is_sriov_vf_v2(enic);
+	int err;
 
 	if (!netif_running(enic->netdev))
 		return;
+	if (vf_recovery)
+		WRITE_ONCE(enic->vf_mbox_recovery_active, true);
 
 	rtnl_lock();
+	/* V2 protocol recovery can be queued immediately before ndo_stop()
+	 * acquires RTNL.  Recheck under RTNL so that new recovery path cannot
+	 * reopen a device userspace just closed.  Preserve the existing reset
+	 * behavior for every other ENIC device.
+	 */
+	if (enic_is_sriov_vf_v2(enic) && !netif_running(enic->netdev))
+		goto unlock;
 
 	/* Stop any activity from infiniband */
 	enic_set_api_busy(enic, true);
 
-	/* Fully tear down the V2 admin/MBOX channel before the soft reset.
-	 * The reset wipes all hardware queues including the admin WQ/RQ;
-	 * closing first tells firmware to stop the admin QP (so it no longer
-	 * DMAs from the about-to-be-reset rings) and frees the admin resources
-	 * so they are cleanly re-allocated afterwards.
+	/* Stop the datapath and existing admin/MBOX channel before the soft
+	 * reset. Do not send DEL_MAC from this path: a timeout would poison the
+	 * channel while reset and fresh registration already discard the old
+	 * VF-requested protocol state before the station address is replayed.
+	 * Reopen allocates fresh admin resources after reset recreates the vNIC.
 	 */
+	__enic_stop(enic->netdev, false);
 	if (enic_has_admin_chan(enic))
 		enic_admin_channel_close(enic);
 
-	enic_stop(enic->netdev);
 	if (enic_is_sriov_vf_v2(enic))
 		enic_mbox_vf_link_state_reset(enic);
+	err = enic_dev_soft_reset(enic);
+	if (err)
+		goto reset_out;
+
+	if (!enic_is_dynamic(enic)) {
+		err = vnic_dev_init(enic->vdev, 0);
+		if (err) {
+			netdev_err(enic->netdev,
+				   "vNIC init after soft reset failed: %d\n",
+				   err);
+			goto reset_out;
+		}
+	}
 
-	enic_dev_soft_reset(enic);
 	enic_reset_addr_lists(enic);
 	enic_init_vnic_resources(enic);
 	enic_set_rss_nic_cfg(enic);
 	enic_dev_set_ig_vlan_rewrite_mode(enic);
 	enic_ext_cq(enic);
 
-	enic_open(enic->netdev);
+	/* A V2 VF needs PF registration before enic_open() can install its
+	 * station address.  A V2 PF reopens afterwards and replays carrier.
+	 */
+	if (enic_is_sriov_vf_v2(enic)) {
+		err = enic_admin_chan_reopen(enic);
+		if (err)
+			goto reset_out;
+	}
+
+	err = enic_open(enic->netdev);
+	if (err)
+		netdev_err(enic->netdev,
+			   "Failed to reopen datapath after reset: %d\n", err);
+	else if (enic_is_sriov_vf_v2(enic)) {
+		/* Internal reset bypasses __dev_open(), which normally schedules the
+		 * asynchronous receive-mode upload after ndo_open. Schedule an update
+		 * after enic_reset_addr_lists() marked the lists unsynchronized.
+		 */
+		netif_rx_mode_schedule_update(enic->netdev);
+	}
 
-	/* Re-establish the admin/MBOX channel after the data path is back up.
-	 * It was fully torn down by enic_admin_channel_close() above;
-	 * enic_admin_chan_reopen() reopens it and, for a PF re-pushes link
-	 * state, or for a VF re-runs the probe-time PF handshake.
+	/* A PF reopens its admin channel after the datapath and re-pushes link
+	 * state.  The VF handshake, which open depends on, completed above.
 	 */
-	if (enic_has_admin_chan(enic))
+	if (enic_has_admin_chan(enic) && !enic_is_sriov_vf_v2(enic))
 		enic_admin_chan_reopen(enic);
 
+reset_out:
 	/* Allow infiniband to fiddle with the device again */
 	enic_set_api_busy(enic, false);
 
 	call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev);
 
+unlock:
+	if (vf_recovery)
+		WRITE_ONCE(enic->vf_mbox_recovery_active, false);
 	rtnl_unlock();
 }
 
 static void enic_tx_hang_reset(struct work_struct *work)
 {
 	struct enic *enic = container_of(work, struct enic, tx_hang_reset);
+	bool vf_recovery = enic_is_sriov_vf_v2(enic);
+	int err;
+
+	if (vf_recovery)
+		WRITE_ONCE(enic->vf_mbox_recovery_active, true);
 
 	rtnl_lock();
+	/* The V2 changes below add admin-channel recovery to this worker.  Do not
+	 * let that new path reopen a VF after userspace completed ndo_stop();
+	 * leave the existing behavior for other ENIC devices unchanged.
+	 */
+	if (enic_is_sriov_vf_v2(enic) && !netif_running(enic->netdev))
+		goto unlock;
 
 	/* Stop any activity from infiniband */
 	enic_set_api_busy(enic, true);
 
-	/* Fully tear down the V2 admin/MBOX channel before the hang reset, for
-	 * the same reason as the soft reset path: stop the admin QP and free
-	 * the admin resources before the hardware queues are wiped.
+	/* Preserve the firmware hang-notification contract by reporting the hung
+	 * queue before stopping and cleaning it. As in the soft-reset path, skip
+	 * DEL_MAC because reset and fresh registration are the cleanup boundary.
 	 */
+	enic_dev_hang_notify(enic);
+	__enic_stop(enic->netdev, false);
 	if (enic_has_admin_chan(enic))
 		enic_admin_channel_close(enic);
 
-	enic_dev_hang_notify(enic);
-	enic_stop(enic->netdev);
 	if (enic_is_sriov_vf_v2(enic))
 		enic_mbox_vf_link_state_reset(enic);
-
 	enic_dev_hang_reset(enic);
 	enic_reset_addr_lists(enic);
 	enic_init_vnic_resources(enic);
@@ -2333,21 +3436,34 @@ static void enic_tx_hang_reset(struct work_struct *work)
 	enic_dev_set_ig_vlan_rewrite_mode(enic);
 	enic_ext_cq(enic);
 
-	enic_open(enic->netdev);
+	if (enic_is_sriov_vf_v2(enic)) {
+		err = enic_admin_chan_reopen(enic);
+		if (err)
+			goto hang_reset_out;
+	}
+
+	err = enic_open(enic->netdev);
+	if (err)
+		netdev_err(enic->netdev,
+			   "Failed to reopen datapath after hang reset: %d\n", err);
+	else if (enic_is_sriov_vf_v2(enic))
+		netif_rx_mode_schedule_update(enic->netdev);
 
-	/* Re-establish the admin/MBOX channel after the data path is back up.
-	 * It was fully torn down by enic_admin_channel_close() above;
-	 * enic_admin_chan_reopen() reopens it and, for a PF re-pushes link
-	 * state, or for a VF re-runs the probe-time PF handshake.
+	/* A PF reopens its admin channel after the datapath and re-pushes link
+	 * state.  The VF handshake, which open depends on, completed above.
 	 */
-	if (enic_has_admin_chan(enic))
+	if (enic_has_admin_chan(enic) && !enic_is_sriov_vf_v2(enic))
 		enic_admin_chan_reopen(enic);
 
+hang_reset_out:
 	/* Allow infiniband to fiddle with the device again */
 	enic_set_api_busy(enic, false);
 
 	call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev);
 
+unlock:
+	if (vf_recovery)
+		WRITE_ONCE(enic->vf_mbox_recovery_active, false);
 	rtnl_unlock();
 }
 
@@ -2586,6 +3702,30 @@ static const struct net_device_ops enic_netdev_dynamic_ops = {
 	.ndo_features_check	= enic_features_check,
 };
 
+static const struct net_device_ops enic_netdev_vf_v2_ops = {
+	.ndo_open		= enic_open,
+	.ndo_stop		= enic_stop,
+	.ndo_start_xmit		= enic_hard_start_xmit,
+	.ndo_get_stats64	= enic_get_stats,
+	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_set_rx_mode_async	= enic_set_vf_rx_mode,
+	.ndo_set_mac_address	= enic_set_mac_address_dynamic,
+	.ndo_change_mtu		= enic_change_mtu,
+	.ndo_vlan_rx_add_vid	= enic_vlan_rx_add_vid,
+	.ndo_vlan_rx_kill_vid	= enic_vlan_rx_kill_vid,
+	.ndo_tx_timeout		= enic_tx_timeout,
+	.ndo_set_vf_port	= enic_set_vf_port,
+	.ndo_get_vf_port	= enic_get_vf_port,
+	.ndo_set_vf_mac		= enic_set_vf_mac,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= enic_poll_controller,
+#endif
+#ifdef CONFIG_RFS_ACCEL
+	.ndo_rx_flow_steer	= enic_rx_flow_steer,
+#endif
+	.ndo_features_check	= enic_features_check,
+};
+
 static const struct net_device_ops enic_netdev_ops = {
 	.ndo_open		= enic_open,
 	.ndo_stop		= enic_stop,
@@ -3180,6 +4320,9 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * cancel_work_sync()) would otherwise act on an uninitialised work.
 	 */
 	INIT_WORK(&enic->link_notify_work, enic_link_notify_work_handler);
+	spin_lock_init(&enic->vf_admin_mac_lock);
+	INIT_DELAYED_WORK(&enic->vf_admin_mac_work,
+			  enic_vf_admin_mac_work);
 
 	/* V2 VF: open admin channel and register with PF.
 	 * Must happen before register_netdev so the VF is fully
@@ -3209,6 +4352,12 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 				"MBOX VF registration failed: %d\n", err);
 			goto err_out_admin_close;
 		}
+		err = enic_vf_admin_mac_refresh(enic);
+		if (err) {
+			dev_err(dev,
+				"MBOX VF admin MAC refresh failed: %d\n", err);
+			goto err_out_admin_close;
+		}
 	}
 
 	netif_set_real_num_tx_queues(netdev, enic->wq_count);
@@ -3244,7 +4393,9 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 */
 	enic->rx_coalesce_usecs = enic->tx_coalesce_usecs;
 
-	if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))
+	if (enic_is_sriov_vf_v2(enic))
+		netdev->netdev_ops = &enic_netdev_vf_v2_ops;
+	else if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))
 		netdev->netdev_ops = &enic_netdev_dynamic_ops;
 	else
 		netdev->netdev_ops = &enic_netdev_ops;
@@ -3334,6 +4485,8 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		dev_err(dev, "Cannot register net device, aborting\n");
 		goto err_out_admin_close;
 	}
+	if (enic_is_sriov_vf_v2(enic))
+		enic_vf_admin_mac_rearm(enic);
 
 	return 0;
 
@@ -3389,9 +4542,19 @@ static void enic_remove(struct pci_dev *pdev)
 
 		/* Close the admin channel and unregister from the PF before
 		 * unregister_netdev() to prevent a late PF notification from
-		 * touching a netdev that is being torn down.
+		 * touching a netdev that is being torn down.  VF_UNREGISTER is the
+		 * protocol teardown operation: the PF removes all VF-requested
+		 * configuration, including the station address, before replying.
+		 * Detach first while holding RTNL so any running asynchronous
+		 * receive-mode update has completed and queued updates cannot enter
+		 * the mailbox callback.
 		 */
 		if (enic_is_sriov_vf_v2(enic)) {
+			enic_vf_admin_mac_quiesce(enic);
+			rtnl_lock();
+			netif_device_detach(netdev);
+			rtnl_unlock();
+
 			if (READ_ONCE(enic->vf_registered)) {
 				int unreg_err = enic_mbox_vf_unregister(enic);
 
@@ -3410,6 +4573,8 @@ static void enic_remove(struct pci_dev *pdev)
 		 * enic_link_check() scheduled it just as SR-IOV was disabled.
 		 */
 		cancel_work_sync(&enic->link_notify_work);
+		if (enic_is_sriov_vf_v2(enic))
+			enic_vf_admin_mac_purge(enic);
 #ifdef CONFIG_PCI_IOV
 		if (enic_sriov_enabled(enic)) {
 			if (enic->vf_type == ENIC_VF_TYPE_V2)
diff --git a/drivers/net/ethernet/cisco/enic/enic_mbox.c b/drivers/net/ethernet/cisco/enic/enic_mbox.c
index 5c93ca49552ac..1fd2b23e2d8f0 100644
--- a/drivers/net/ethernet/cisco/enic/enic_mbox.c
+++ b/drivers/net/ethernet/cisco/enic/enic_mbox.c
@@ -6,6 +6,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/completion.h>
+#include <linux/etherdevice.h>
 
 #include "vnic_dev.h"
 #include "vnic_wq.h"
@@ -149,7 +150,20 @@ static int enic_mbox_send_msg_id(struct enic *enic, u8 msg_type,
 		 * or free the buffer: the device may still DMA from dma_addr.
 		 * Mark the channel unusable so no further sends are attempted.
 		 */
+		spin_lock_bh(&enic->mbox_state_lock);
 		WRITE_ONCE(enic->mbox_send_disabled, true);
+		WRITE_ONCE(enic->mbox_tx_poisoned, true);
+		if (enic_is_sriov_vf_v2(enic)) {
+			/* The request may have changed PF receive policy even though
+			 * local descriptor ownership is still uncertain. Fail the VF
+			 * closed and do not turn this into an ordinary protocol
+			 * reconnect; the admin-channel lifecycle owns final reclamation.
+			 */
+			WRITE_ONCE(enic->vf_rx_quarantined, true);
+		}
+		spin_unlock_bh(&enic->mbox_state_lock);
+		if (enic_is_sriov_vf_v2(enic))
+			enic_mbox_vf_link_state_set_running(enic, false);
 	}
 
 	netdev_dbg(enic->netdev,
@@ -184,6 +198,105 @@ static int enic_mbox_send_reply(struct enic *enic, u8 msg_type,
 				     payload_len, msg_num, true, 0);
 }
 
+struct enic_mbox_vf_ack {
+	struct list_head list;
+	u64 msg_num;
+	u16 ret_major;
+	u8 msg_type;
+};
+
+static void enic_mbox_vf_ack_work(struct work_struct *work)
+{
+	struct enic *enic = container_of(work, struct enic, vf_ack_work);
+	struct enic_mbox_vf_ack *pending;
+
+	for (;;) {
+		struct enic_mbox_generic_reply ack = {};
+		u8 msg_type;
+		int err;
+
+		spin_lock_bh(&enic->vf_ack_lock);
+		if (list_empty(&enic->vf_ack_list)) {
+			spin_unlock_bh(&enic->vf_ack_lock);
+			break;
+		}
+		pending = list_first_entry(&enic->vf_ack_list,
+					   struct enic_mbox_vf_ack, list);
+		list_del(&pending->list);
+		enic->vf_ack_count--;
+		spin_unlock_bh(&enic->vf_ack_lock);
+
+		if (READ_ONCE(enic->mbox_send_disabled)) {
+			kfree(pending);
+			continue;
+		}
+
+		msg_type = pending->msg_type;
+		ack.ret_major = cpu_to_le16(pending->ret_major);
+		err = enic_mbox_send_reply(enic, msg_type, ENIC_MBOX_DST_PF,
+					   &ack, sizeof(ack), pending->msg_num);
+		kfree(pending);
+		if (err && net_ratelimit())
+			netdev_warn(enic->netdev,
+				    "MBOX: failed to send ACK type %u: %d\n",
+				    msg_type, err);
+	}
+}
+
+static void enic_mbox_vf_queue_ack(struct enic *enic, u8 msg_type,
+				   u64 msg_num, u16 ret_major)
+{
+	struct enic_mbox_vf_ack *pending;
+
+	if (READ_ONCE(enic->mbox_send_disabled))
+		return;
+	pending = kmalloc_obj(*pending, GFP_ATOMIC);
+	if (!pending) {
+		if (net_ratelimit())
+			netdev_warn(enic->netdev,
+				    "MBOX: dropping ACK type %u: no memory\n",
+				    msg_type);
+		return;
+	}
+	pending->msg_num = msg_num;
+	pending->ret_major = ret_major;
+	pending->msg_type = msg_type;
+
+	spin_lock_bh(&enic->vf_ack_lock);
+	if (READ_ONCE(enic->mbox_send_disabled) ||
+	    enic->vf_ack_count >= ENIC_ADMIN_DESC_COUNT) {
+		spin_unlock_bh(&enic->vf_ack_lock);
+		kfree(pending);
+		if (net_ratelimit())
+			netdev_warn(enic->netdev,
+				    "MBOX: dropping ACK type %u: queue unavailable\n",
+				    msg_type);
+		return;
+	}
+	list_add_tail(&pending->list, &enic->vf_ack_list);
+	enic->vf_ack_count++;
+	spin_unlock_bh(&enic->vf_ack_lock);
+	schedule_work(&enic->vf_ack_work);
+}
+
+void enic_mbox_vf_ack_cancel(struct enic *enic)
+{
+	struct enic_mbox_vf_ack *pending, *tmp;
+	LIST_HEAD(discard);
+
+	if (!enic->mbox_initialized)
+		return;
+	cancel_work_sync(&enic->vf_ack_work);
+	spin_lock_bh(&enic->vf_ack_lock);
+	list_splice_init(&enic->vf_ack_list, &discard);
+	enic->vf_ack_count = 0;
+	spin_unlock_bh(&enic->vf_ack_lock);
+	list_for_each_entry_safe(pending, tmp, &discard, list) {
+		list_del(&pending->list);
+		kfree(pending);
+	}
+}
+
 static int enic_mbox_vf_send_request(struct enic *enic, u8 request_type,
 				     u8 expected_reply, void *payload,
 				     u16 payload_len)
@@ -193,6 +306,27 @@ static int enic_mbox_vf_send_request(struct enic *enic, u8 request_type,
 				     expected_reply);
 }
 
+static void enic_mbox_vf_mark_reconnect_locked(struct enic *enic,
+					       bool registration_lost)
+{
+	lockdep_assert_held(&enic->mbox_state_lock);
+
+	if (registration_lost)
+		WRITE_ONCE(enic->vf_registered, false);
+	enic->vf_mbox_fault_generation++;
+	WRITE_ONCE(enic->vf_mbox_reconnect_required, true);
+	WRITE_ONCE(enic->mbox_send_disabled, true);
+	WRITE_ONCE(enic->vf_rx_quarantined, true);
+}
+
+static void enic_mbox_vf_kick_recovery(struct enic *enic)
+{
+	enic_mbox_vf_link_state_set_running(enic, false);
+	if (netif_running(enic->netdev) &&
+	    !READ_ONCE(enic->vf_mbox_recovery_active))
+		schedule_work(&enic->reset);
+}
+
 static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)
 {
 	unsigned long left;
@@ -203,9 +337,9 @@ static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)
 	if (left)
 		return 0;
 
-	/* Invalidate a request that the handler has not already accepted.  A
-	 * delayed reply cannot match a later request because message numbers are
-	 * monotonic across channel reopen.
+	/* Invalidate a request that the handler has not already accepted. Whether
+	 * losing the reply invalidates the current protocol generation is an
+	 * operation-specific decision made by the caller.
 	 */
 	spin_lock_bh(&enic->mbox_state_lock);
 	if (enic->mbox_expected_reply) {
@@ -218,6 +352,108 @@ static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)
 	return err;
 }
 
+static void enic_mbox_vf_request_start(struct enic *enic)
+{
+	mutex_lock(&enic->vf_mbox_request_lock);
+	reinit_completion(&enic->mbox_comp);
+	spin_lock_bh(&enic->mbox_state_lock);
+	enic->mbox_expected_msg_num = 0;
+	enic->mbox_expected_reply = 0;
+	spin_unlock_bh(&enic->mbox_state_lock);
+}
+
+static void enic_mbox_vf_request_abort(struct enic *enic)
+{
+	lockdep_assert_held(&enic->vf_mbox_request_lock);
+	spin_lock_bh(&enic->mbox_state_lock);
+	enic->mbox_expected_reply = 0;
+	enic->mbox_expected_msg_num = 0;
+	spin_unlock_bh(&enic->mbox_state_lock);
+	mutex_unlock(&enic->vf_mbox_request_lock);
+}
+
+static void enic_mbox_vf_request_finish(struct enic *enic)
+{
+	lockdep_assert_held(&enic->vf_mbox_request_lock);
+	mutex_unlock(&enic->vf_mbox_request_lock);
+}
+
+/* Return with mbox_state_lock held when this handler owns the reply. */
+static bool enic_mbox_vf_reply_claim(struct enic *enic, u8 reply_type,
+				     u64 msg_num, u8 *expected)
+{
+	spin_lock_bh(&enic->mbox_state_lock);
+	*expected = enic->mbox_expected_reply;
+	if (*expected == reply_type &&
+	    enic->mbox_expected_msg_num == msg_num)
+		return true;
+	spin_unlock_bh(&enic->mbox_state_lock);
+
+	return false;
+}
+
+enum enic_mbox_vf_reply_recovery {
+	ENIC_MBOX_VF_REPLY_OK,
+	ENIC_MBOX_VF_REPLY_RECONNECT,
+	ENIC_MBOX_VF_REPLY_REGISTRATION_LOST,
+};
+
+static int
+enic_mbox_vf_classify_reply(bool malformed, u16 ret_major,
+			    enum enic_mbox_vf_reply_recovery *recovery)
+{
+	*recovery = ENIC_MBOX_VF_REPLY_OK;
+	if (malformed) {
+		*recovery = ENIC_MBOX_VF_REPLY_RECONNECT;
+		return -EIO;
+	}
+	/* Some deployed peers return a negative errno in this 16-bit field.
+	 * Interpret protocol bits only when no unknown bits are present; otherwise
+	 * an errno such as -EINVAL could accidentally look like registration loss.
+	 */
+	if (!(ret_major & ~ENIC_MBOX_ERR_MASK) &&
+	    (ret_major & ENIC_MBOX_ERR_VF_NOT_REGISTERED)) {
+		*recovery = ENIC_MBOX_VF_REPLY_REGISTRATION_LOST;
+		return -ENODEV;
+	}
+	if (!(ret_major & ~ENIC_MBOX_ERR_MASK) &&
+	    (ret_major & ENIC_MBOX_ERR_MSG_NOT_SUPPORTED))
+		return -EOPNOTSUPP;
+	if (ret_major)
+		return -EIO;
+
+	return 0;
+}
+
+static void
+enic_mbox_vf_recover_reply_locked(struct enic *enic,
+				  enum enic_mbox_vf_reply_recovery recovery)
+{
+	bool registration_lost;
+
+	lockdep_assert_held(&enic->mbox_state_lock);
+
+	if (recovery != ENIC_MBOX_VF_REPLY_OK) {
+		registration_lost =
+			recovery == ENIC_MBOX_VF_REPLY_REGISTRATION_LOST;
+		enic_mbox_vf_mark_reconnect_locked(enic, registration_lost);
+	}
+}
+
+static void enic_mbox_vf_reply_complete(struct enic *enic)
+{
+	lockdep_assert_held(&enic->mbox_state_lock);
+	enic->mbox_expected_reply = 0;
+	enic->mbox_expected_msg_num = 0;
+	/* Publish completion before releasing the state lock.  A waiter that
+	 * hit the timeout boundary may otherwise see the claimed state, finish the
+	 * request, and let a new request reinitialize this completion before the
+	 * old handler signals it.
+	 */
+	complete(&enic->mbox_comp);
+	spin_unlock_bh(&enic->mbox_state_lock);
+}
+
 int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state)
 {
 	struct enic_mbox_pf_link_state_notif_msg notif = {};
@@ -393,23 +629,21 @@ static void enic_mbox_vf_handle_reply(struct enic *enic, u8 reply_type,
 				      void *payload, u64 msg_num)
 {
 	struct enic_mbox_generic_reply *reply = payload;
+	enum enic_mbox_vf_reply_recovery recovery;
 	u16 ret_major = le16_to_cpu(reply->ret_major);
-	u64 expected_msg_num;
-	u8 expected_type;
+	u8 expected;
+	int status;
 
-	spin_lock_bh(&enic->mbox_state_lock);
-	expected_type = enic->mbox_expected_reply;
-	expected_msg_num = enic->mbox_expected_msg_num;
-	if (expected_type != reply_type || expected_msg_num != msg_num) {
-		spin_unlock_bh(&enic->mbox_state_lock);
+	status = enic_mbox_vf_classify_reply(false, ret_major, &recovery);
+	if (!enic_mbox_vf_reply_claim(enic, reply_type, msg_num, &expected)) {
 		netdev_warn(enic->netdev,
-			    "MBOX: stale reply %u/%llu (expected %u/%llu), drop\n",
+			    "MBOX: stale reply %u/%llu (expected %u), drop\n",
 			    reply_type, (unsigned long long)msg_num,
-			    expected_type, (unsigned long long)expected_msg_num);
+			    expected);
 		return;
 	}
 
-	if (!ret_major) {
+	if (!status) {
 		switch (reply_type) {
 		case ENIC_MBOX_VF_CAPABILITY_REPLY: {
 			struct enic_mbox_vf_capability_reply_msg *cap = payload;
@@ -426,25 +660,174 @@ static void enic_mbox_vf_handle_reply(struct enic *enic, u8 reply_type,
 			break;
 		}
 	}
-	enic->mbox_expected_reply = 0;
-	enic->mbox_expected_msg_num = 0;
-	complete(&enic->mbox_comp);
-	spin_unlock_bh(&enic->mbox_state_lock);
+	enic_mbox_vf_recover_reply_locked(enic, recovery);
+	WRITE_ONCE(enic->mbox_reply_status, status);
+	enic_mbox_vf_reply_complete(enic);
 
 	if (ret_major)
 		netdev_warn(enic->netdev,
 			    "MBOX: PF rejected reply type %u: %u/%u\n",
 			    reply_type, ret_major,
 			    le16_to_cpu(reply->ret_minor));
+	if (recovery != ENIC_MBOX_VF_REPLY_OK)
+		enic_mbox_vf_kick_recovery(enic);
+}
+
+static bool enic_mbox_vf_mac_reply_matches(const struct enic_mac_addr *request,
+					   const struct enic_mac_addr *reply)
+{
+	u16 request_flags = le16_to_cpu(request->flags);
+	u16 reply_flags = le16_to_cpu(reply->flags);
+	u16 idempotent_result = reply_flags &
+		(ENIC_MAC_ADDR_FLAG_DUPLICATE |
+		 ENIC_MAC_ADDR_FLAG_NOT_FOUND);
+	u16 result = reply_flags & ENIC_MAC_ADDR_FLAG_REPLY_MASK;
+	u16 expected_result;
+
+	if (!ether_addr_equal(request->addr, reply->addr) ||
+	    (request_flags & ENIC_MAC_ADDR_FLAG_REQUEST_MASK) !=
+	    (reply_flags & ENIC_MAC_ADDR_FLAG_REQUEST_MASK))
+		return false;
+	if (hweight16(result) > 1)
+		return false;
+
+	/* DUPLICATE is a successful ADD result and NOT_FOUND is a successful
+	 * DELETE result.  Neither is valid for the opposite operation, and a
+	 * reply cannot report both outcomes for one entry.
+	 */
+	expected_result = request_flags & ENIC_MAC_ADDR_FLAG_ADD ?
+		ENIC_MAC_ADDR_FLAG_DUPLICATE :
+		ENIC_MAC_ADDR_FLAG_NOT_FOUND;
+
+	return !idempotent_result || idempotent_result == expected_result;
+}
+
+static void enic_mbox_vf_handle_add_del_mac_reply(struct enic *enic,
+						  void *payload, u16 msg_len,
+						  u64 msg_num)
+{
+	struct enic_mbox_vf_add_del_mac_reply_msg *reply = payload;
+	enum enic_mbox_vf_reply_recovery recovery;
+	u16 reported_errors = 0;
+	u16 num_addrs = 0;
+	u16 ret_minor = 0;
+	u16 ret_major = 0;
+	u8 expected;
+	unsigned int i;
+	int status;
+
+	if (msg_len < sizeof(*reply)) {
+		status = enic_mbox_vf_classify_reply(true, 0, &recovery);
+	} else {
+		ret_major = le16_to_cpu(reply->reply.ret_major);
+		ret_minor = le16_to_cpu(reply->reply.ret_minor);
+		status = enic_mbox_vf_classify_reply(false, ret_major,
+						     &recovery);
+	}
+	if (status)
+		goto claim;
+
+	num_addrs = le16_to_cpu(reply->num_addrs);
+	if (!num_addrs || num_addrs > ENIC_MBOX_MAX_MAC_OPS ||
+	    struct_size(reply, mac_addr, num_addrs) > msg_len) {
+		status = enic_mbox_vf_classify_reply(true, 0, &recovery);
+		goto claim;
+	}
+
+claim:
+	if (!enic_mbox_vf_reply_claim(enic, ENIC_MBOX_VF_ADD_DEL_MAC_REPLY,
+				      msg_num, &expected))
+		return;
+	if (!status &&
+	    (num_addrs != enic->mbox_reply_mac_count ||
+	     !enic->mbox_reply_mac_addrs)) {
+		status = enic_mbox_vf_classify_reply(true, 0, &recovery);
+	} else if (!status) {
+		/* A detailed reply corresponds entry-for-entry with the request.
+		 * Validate the echoed request fields and operation-specific results
+		 * before exposing result flags to the waiting caller.
+		 */
+		for (i = 0; i < num_addrs; i++) {
+			struct enic_mac_addr *request =
+				&enic->mbox_reply_mac_addrs[i];
+			u16 flags = le16_to_cpu(reply->mac_addr[i].flags);
+
+			if (!enic_mbox_vf_mac_reply_matches(request,
+							    &reply->mac_addr[i])) {
+				status = enic_mbox_vf_classify_reply(true, 0,
+								     &recovery);
+				break;
+			}
+			if (flags & ENIC_MAC_ADDR_FLAG_INDETERMINATE_MASK) {
+				status = -EIO;
+				recovery = ENIC_MBOX_VF_REPLY_RECONNECT;
+				break;
+			}
+			if ((flags & ENIC_MAC_ADDR_FLAG_REPLY_MASK) &&
+			    !(flags & ENIC_MAC_ADDR_FLAG_SKIPPED))
+				reported_errors++;
+		}
+		if (!status && reported_errors != ret_minor)
+			status = enic_mbox_vf_classify_reply(true, 0,
+							     &recovery);
+
+		if (!status)
+			for (i = 0; i < num_addrs; i++)
+				enic->mbox_reply_mac_addrs[i].flags =
+					reply->mac_addr[i].flags;
+	}
+	/* After a malformed reply, the VF cannot trust that its state matches the
+	 * PF. VF_NOT_REGISTERED means the PF removed all VF state. Both require a
+	 * new registration; an ordinary policy rejection does not.
+	 */
+	enic_mbox_vf_recover_reply_locked(enic, recovery);
+	WRITE_ONCE(enic->mbox_reply_status, status);
+	enic_mbox_vf_reply_complete(enic);
+	if (recovery != ENIC_MBOX_VF_REPLY_OK)
+		enic_mbox_vf_kick_recovery(enic);
+}
+
+static void enic_mbox_vf_handle_set_pkt_filter_reply(struct enic *enic,
+						     void *payload, u16 msg_len,
+						     u64 msg_num)
+{
+	struct enic_mbox_vf_set_pkt_filter_reply_msg *reply = payload;
+	enum enic_mbox_vf_reply_recovery recovery;
+	u16 applied = 0;
+	u16 ret_major = 0;
+	u8 expected;
+	int status;
+
+	if (msg_len < sizeof(*reply)) {
+		status = enic_mbox_vf_classify_reply(true, 0, &recovery);
+	} else {
+		ret_major = le16_to_cpu(reply->reply.ret_major);
+		status = enic_mbox_vf_classify_reply(false, ret_major,
+						     &recovery);
+		if (status && (ret_major & ~ENIC_MBOX_ERR_MASK))
+			recovery = ENIC_MBOX_VF_REPLY_RECONNECT;
+	}
+	if (!status)
+		applied = le16_to_cpu(reply->reply.ret_minor);
+
+	if (!enic_mbox_vf_reply_claim(enic,
+				      ENIC_MBOX_VF_SET_PKT_FILTER_REPLY,
+				      msg_num, &expected))
+		return;
+	enic_mbox_vf_recover_reply_locked(enic, recovery);
+	WRITE_ONCE(enic->mbox_reply_status, status);
+	WRITE_ONCE(enic->mbox_reply_filter_flags, applied);
+	enic_mbox_vf_reply_complete(enic);
+	if (recovery != ENIC_MBOX_VF_REPLY_OK)
+		enic_mbox_vf_kick_recovery(enic);
 }
 
 static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload,
 					   u64 msg_num)
 {
 	struct enic_mbox_pf_link_state_notif_msg *notif = payload;
-	struct enic_mbox_pf_link_state_ack_msg ack = {};
 	u32 link_state = le32_to_cpu(notif->link_state);
-	int err;
+	u16 ret_major = 0;
 
 	spin_lock_bh(&enic->vf_link_state_lock);
 	switch (link_state) {
@@ -465,16 +848,35 @@ static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload,
 	default:
 		netdev_warn(enic->netdev, "MBOX: unknown link state %u\n",
 			    link_state);
-		ack.ack.ret_major = cpu_to_le16(ENIC_MBOX_ERR_GENERIC);
+		ret_major = ENIC_MBOX_ERR_GENERIC;
 		break;
 	}
 	spin_unlock_bh(&enic->vf_link_state_lock);
 
-	err = enic_mbox_send_reply(enic, ENIC_MBOX_PF_LINK_STATE_ACK,
-				   ENIC_MBOX_DST_PF, &ack, sizeof(ack), msg_num);
-	if (err && net_ratelimit())
+	/* Notification dispatch must not wait behind a synchronous request send:
+	 * its matching reply may be queued behind this notification.
+	 */
+	enic_mbox_vf_queue_ack(enic, ENIC_MBOX_PF_LINK_STATE_ACK, msg_num,
+			       ret_major);
+}
+
+static void enic_mbox_vf_handle_admin_mac(struct enic *enic, void *payload,
+					  u64 msg_num)
+{
+	struct enic_mbox_pf_set_admin_mac_notif_msg *notif = payload;
+	u16 ret_major = 0;
+
+	if (is_multicast_ether_addr(notif->mac_addr)) {
 		netdev_warn(enic->netdev,
-			    "MBOX: failed to send link state ACK: %d\n", err);
+			    "MBOX: rejecting multicast admin MAC %pM\n",
+			    notif->mac_addr);
+		ret_major = ENIC_MBOX_ERR_GENERIC;
+	} else {
+		enic_vf_admin_mac_notify(enic, notif->mac_addr);
+	}
+
+	enic_mbox_vf_queue_ack(enic, ENIC_MBOX_PF_SET_ADMIN_MAC_ACK,
+			       msg_num, ret_major);
 }
 
 void enic_mbox_vf_link_state_reset(struct enic *enic)
@@ -499,6 +901,17 @@ void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running)
 	spin_unlock_bh(&enic->vf_link_state_lock);
 }
 
+void enic_mbox_vf_require_reconnect(struct enic *enic)
+{
+	/* A fresh REGISTER transaction lets the PF discard any VF-requested
+	 * configuration whose final state became uncertain.
+	 */
+	spin_lock_bh(&enic->mbox_state_lock);
+	enic_mbox_vf_mark_reconnect_locked(enic, false);
+	spin_unlock_bh(&enic->mbox_state_lock);
+	enic_mbox_vf_kick_recovery(enic);
+}
+
 static bool enic_mbox_vf_payload_ok(struct enic *enic, u8 msg_type,
 				    u16 payload_len, size_t min_len)
 {
@@ -511,6 +924,34 @@ static bool enic_mbox_vf_payload_ok(struct enic *enic, u8 msg_type,
 	return true;
 }
 
+static void enic_mbox_vf_malformed_msg(struct enic *enic, u8 msg_type,
+				       u64 msg_num)
+{
+	u8 expected;
+
+	switch (msg_type) {
+	case ENIC_MBOX_PF_LINK_STATE_NOTIF:
+	case ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF:
+		enic_mbox_vf_require_reconnect(enic);
+		return;
+	case ENIC_MBOX_VF_CAPABILITY_REPLY:
+	case ENIC_MBOX_VF_REGISTER_REPLY:
+	case ENIC_MBOX_VF_UNREGISTER_REPLY:
+	case ENIC_MBOX_VF_ADD_DEL_MAC_REPLY:
+	case ENIC_MBOX_VF_SET_PKT_FILTER_REPLY:
+		break;
+	default:
+		return;
+	}
+
+	if (!enic_mbox_vf_reply_claim(enic, msg_type, msg_num, &expected))
+		return;
+	enic_mbox_vf_mark_reconnect_locked(enic, false);
+	WRITE_ONCE(enic->mbox_reply_status, -EIO);
+	enic_mbox_vf_reply_complete(enic);
+	enic_mbox_vf_kick_recovery(enic);
+}
+
 static void enic_mbox_vf_process_msg(struct enic *enic,
 				     struct enic_mbox_hdr *hdr, void *payload,
 				     u16 payload_len)
@@ -522,8 +963,10 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
 		size_t exp = sizeof(struct enic_mbox_vf_capability_reply_msg);
 
 		if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
-					     payload_len, exp))
+					     payload_len, exp)) {
+			enic_mbox_vf_malformed_msg(enic, hdr->msg_type, msg_num);
 			return;
+		}
 		enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num);
 		break;
 	}
@@ -531,8 +974,10 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
 		size_t exp = sizeof(struct enic_mbox_vf_register_reply_msg);
 
 		if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
-					     payload_len, exp))
+					     payload_len, exp)) {
+			enic_mbox_vf_malformed_msg(enic, hdr->msg_type, msg_num);
 			return;
+		}
 		enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num);
 		break;
 	}
@@ -540,8 +985,10 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
 		size_t exp = sizeof(struct enic_mbox_vf_register_reply_msg);
 
 		if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
-					     payload_len, exp))
+					     payload_len, exp)) {
+			enic_mbox_vf_malformed_msg(enic, hdr->msg_type, msg_num);
 			return;
+		}
 		enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num);
 		break;
 	}
@@ -549,11 +996,32 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
 		size_t exp = sizeof(struct enic_mbox_pf_link_state_notif_msg);
 
 		if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
-					     payload_len, exp))
+					     payload_len, exp)) {
+			enic_mbox_vf_malformed_msg(enic, hdr->msg_type, msg_num);
 			return;
+		}
 		enic_mbox_vf_handle_link_state(enic, payload, msg_num);
 		break;
 	}
+	case ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF: {
+		size_t exp = sizeof(struct enic_mbox_pf_set_admin_mac_notif_msg);
+
+		if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
+					     payload_len, exp)) {
+			enic_mbox_vf_malformed_msg(enic, hdr->msg_type, msg_num);
+			return;
+		}
+		enic_mbox_vf_handle_admin_mac(enic, payload, msg_num);
+		break;
+	}
+	case ENIC_MBOX_VF_ADD_DEL_MAC_REPLY:
+		enic_mbox_vf_handle_add_del_mac_reply(enic, payload,
+						      payload_len, msg_num);
+		break;
+	case ENIC_MBOX_VF_SET_PKT_FILTER_REPLY:
+		enic_mbox_vf_handle_set_pkt_filter_reply(enic, payload,
+							 payload_len, msg_num);
+		break;
 	default:
 		netdev_dbg(enic->netdev,
 			   "MBOX: VF unhandled msg type %u\n",
@@ -574,6 +1042,8 @@ static void enic_mbox_recv_handler(struct enic *enic, void *buf,
 			netdev_warn(enic->netdev,
 				    "MBOX: truncated message (len %u < %zu)\n",
 				    len, sizeof(*hdr));
+		if (!enic->vf_state)
+			enic_mbox_vf_require_reconnect(enic);
 		return;
 	}
 
@@ -591,6 +1061,10 @@ static void enic_mbox_recv_handler(struct enic *enic, void *buf,
 			netdev_warn(enic->netdev,
 				    "MBOX: invalid msg_len %u (buf len %u)\n",
 				    msg_len, len);
+		if (!enic->vf_state &&
+		    le16_to_cpu(hdr->src_vnic_id) == ENIC_MBOX_DST_PF)
+			enic_mbox_vf_malformed_msg(enic, hdr->msg_type,
+						   le64_to_cpu(hdr->msg_num));
 		return;
 	}
 
@@ -621,25 +1095,34 @@ int enic_mbox_vf_capability_check(struct enic *enic)
 {
 	struct enic_mbox_vf_capability_msg req = {};
 	u32 version;
+	int status;
 	int err;
 
+	enic_mbox_vf_request_start(enic);
 	WRITE_ONCE(enic->pf_cap_version, 0);
+	WRITE_ONCE(enic->mbox_reply_status, 0);
 	req.version = cpu_to_le32(ENIC_MBOX_CAP_VERSION_1);
 
 	err = enic_mbox_vf_send_request(enic,
 					ENIC_MBOX_VF_CAPABILITY_REQUEST,
 					ENIC_MBOX_VF_CAPABILITY_REPLY,
 					&req, sizeof(req));
-	if (err)
+	if (err) {
+		enic_mbox_vf_request_abort(enic);
 		return err;
+	}
 
 	err = enic_mbox_wait_reply(enic, 3000);
 	version = READ_ONCE(enic->pf_cap_version);
+	status = READ_ONCE(enic->mbox_reply_status);
+	enic_mbox_vf_request_finish(enic);
 	if (err) {
 		netdev_warn(enic->netdev,
 			    "MBOX: no capability reply from PF\n");
 		return err;
 	}
+	if (status)
+		return status;
 
 	if (version < ENIC_MBOX_CAP_VERSION_1) {
 		netdev_warn(enic->netdev,
@@ -654,22 +1137,31 @@ int enic_mbox_vf_capability_check(struct enic *enic)
 int enic_mbox_vf_register(struct enic *enic)
 {
 	bool registered;
+	int status;
 	int err;
 
+	enic_mbox_vf_request_start(enic);
 	WRITE_ONCE(enic->vf_registered, false);
+	WRITE_ONCE(enic->mbox_reply_status, 0);
 
 	err = enic_mbox_vf_send_request(enic, ENIC_MBOX_VF_REGISTER_REQUEST,
 					ENIC_MBOX_VF_REGISTER_REPLY, NULL, 0);
-	if (err)
+	if (err) {
+		enic_mbox_vf_request_abort(enic);
 		return err;
+	}
 
 	err = enic_mbox_wait_reply(enic, 3000);
 	registered = READ_ONCE(enic->vf_registered);
+	status = READ_ONCE(enic->mbox_reply_status);
+	enic_mbox_vf_request_finish(enic);
 	if (err) {
 		netdev_warn(enic->netdev,
 			    "MBOX: VF registration with PF timed out\n");
 		return err;
 	}
+	if (status)
+		return status;
 
 	if (!registered)
 		return -ENODEV;
@@ -680,27 +1172,206 @@ int enic_mbox_vf_register(struct enic *enic)
 int enic_mbox_vf_unregister(struct enic *enic)
 {
 	bool registered;
+	int status;
 	int err;
 
 	if (!READ_ONCE(enic->vf_registered))
 		return 0;
 
+	enic_mbox_vf_request_start(enic);
+	if (!READ_ONCE(enic->vf_registered)) {
+		enic_mbox_vf_request_finish(enic);
+		return 0;
+	}
+	WRITE_ONCE(enic->mbox_reply_status, 0);
+
 	err = enic_mbox_vf_send_request(enic,
 					ENIC_MBOX_VF_UNREGISTER_REQUEST,
 					ENIC_MBOX_VF_UNREGISTER_REPLY,
 					NULL, 0);
-	if (err)
+	if (err) {
+		enic_mbox_vf_request_abort(enic);
 		return err;
+	}
 
 	err = enic_mbox_wait_reply(enic, 3000);
 	registered = READ_ONCE(enic->vf_registered);
+	status = READ_ONCE(enic->mbox_reply_status);
+	enic_mbox_vf_request_finish(enic);
 	if (err)
 		return err;
+	if (status)
+		return status;
 	if (registered)
 		return -EACCES;
 	return 0;
 }
 
+int enic_mbox_vf_add_del_macs(struct enic *enic,
+			      struct enic_mac_addr *macs, u16 num_macs)
+{
+	struct enic_mbox_vf_add_del_mac_msg *req;
+	unsigned int i;
+	int status;
+	int err;
+
+	if (!READ_ONCE(enic->vf_registered) || !enic->has_admin_channel)
+		return -ENODEV;
+	if (!num_macs || num_macs > ENIC_MBOX_MAX_MAC_OPS)
+		return -EINVAL;
+
+	req = kzalloc_flex(*req, mac_addr, num_macs);
+	if (!req)
+		return -ENOMEM;
+
+	req->num_addrs = cpu_to_le16(num_macs);
+	for (i = 0; i < num_macs; i++)
+		req->mac_addr[i] = macs[i];
+
+	enic_mbox_vf_request_start(enic);
+	if (!READ_ONCE(enic->vf_registered) || !enic->has_admin_channel) {
+		err = -ENODEV;
+	} else {
+		spin_lock_bh(&enic->mbox_state_lock);
+		enic->mbox_reply_mac_addrs = macs;
+		enic->mbox_reply_mac_count = num_macs;
+		spin_unlock_bh(&enic->mbox_state_lock);
+		WRITE_ONCE(enic->mbox_reply_status, 0);
+		err = enic_mbox_vf_send_request(enic,
+						ENIC_MBOX_VF_ADD_DEL_MAC_REQUEST,
+						ENIC_MBOX_VF_ADD_DEL_MAC_REPLY,
+						req,
+						struct_size(req, mac_addr,
+							    num_macs));
+	}
+	kfree(req);
+	if (err) {
+		spin_lock_bh(&enic->mbox_state_lock);
+		enic->mbox_reply_mac_addrs = NULL;
+		enic->mbox_reply_mac_count = 0;
+		spin_unlock_bh(&enic->mbox_state_lock);
+		enic_mbox_vf_request_abort(enic);
+		return err;
+	}
+
+	err = enic_mbox_wait_reply(enic, 3000);
+	status = READ_ONCE(enic->mbox_reply_status);
+	spin_lock_bh(&enic->mbox_state_lock);
+	enic->mbox_reply_mac_addrs = NULL;
+	enic->mbox_reply_mac_count = 0;
+	spin_unlock_bh(&enic->mbox_state_lock);
+	if (err) {
+		/* The PF may have updated its software ledger before a hardware
+		 * failure whose reply was lost. A repeated idempotent operation could
+		 * then appear converged while hardware state is stale, so replay from
+		 * a fresh registration generation.
+		 */
+		enic_mbox_vf_require_reconnect(enic);
+		enic_mbox_vf_request_finish(enic);
+		return err;
+	}
+	enic_mbox_vf_request_finish(enic);
+
+	return status;
+}
+
+int enic_mbox_vf_add_del_mac(struct enic *enic, const u8 *addr, bool add,
+			     bool station)
+{
+	struct enic_mac_addr mac = {};
+	u16 flags = 0;
+	int err;
+
+	ether_addr_copy(mac.addr, addr);
+	if (add)
+		flags |= ENIC_MAC_ADDR_FLAG_ADD;
+	if (station)
+		flags |= ENIC_MAC_ADDR_FLAG_STATION;
+	mac.flags = cpu_to_le16(flags);
+
+	err = enic_mbox_vf_add_del_macs(enic, &mac, 1);
+	if (err)
+		return err;
+	if (le16_to_cpu(mac.flags) & ENIC_MAC_ADDR_FLAG_ERROR_MASK)
+		return -EACCES;
+
+	return 0;
+}
+
+int enic_mbox_vf_set_pkt_filter(struct enic *enic, int directed,
+				int multicast, int broadcast,
+				int promisc, int allmulti, u16 *applied_flags)
+{
+	struct enic_mbox_vf_set_pkt_filter_msg req = {};
+	u16 applied;
+	u16 flags = 0;
+	u16 required;
+	int status;
+	int err;
+
+	if (!READ_ONCE(enic->vf_registered) || !enic->has_admin_channel)
+		return -ENODEV;
+
+	if (directed)
+		flags |= CMD_PFILTER_DIRECTED;
+	if (multicast)
+		flags |= CMD_PFILTER_MULTICAST;
+	if (broadcast)
+		flags |= CMD_PFILTER_BROADCAST;
+	if (promisc)
+		flags |= CMD_PFILTER_PROMISCUOUS;
+	if (allmulti)
+		flags |= CMD_PFILTER_ALL_MULTICAST;
+	req.flags = cpu_to_le16(flags);
+
+	enic_mbox_vf_request_start(enic);
+	if (!READ_ONCE(enic->vf_registered) || !enic->has_admin_channel) {
+		enic_mbox_vf_request_abort(enic);
+		return -ENODEV;
+	}
+	WRITE_ONCE(enic->mbox_reply_status, 0);
+	WRITE_ONCE(enic->mbox_reply_filter_flags, 0);
+
+	err = enic_mbox_vf_send_request(enic,
+					ENIC_MBOX_VF_SET_PKT_FILTER_REQUEST,
+					ENIC_MBOX_VF_SET_PKT_FILTER_REPLY,
+					&req, sizeof(req));
+	if (err) {
+		enic_mbox_vf_request_abort(enic);
+		return err;
+	}
+
+	err = enic_mbox_wait_reply(enic, 3000);
+	status = READ_ONCE(enic->mbox_reply_status);
+	if (!err && !status) {
+		applied = READ_ONCE(enic->mbox_reply_filter_flags);
+		/* Directed, multicast, and broadcast are not policy-gated.  The PF
+		 * may only withhold the two broad receive modes, and may add directed
+		 * reception because it is mandatory for a usable VF.
+		 */
+		required = (flags | CMD_PFILTER_DIRECTED) &
+			   ~(CMD_PFILTER_PROMISCUOUS |
+			     CMD_PFILTER_ALL_MULTICAST);
+		if ((applied & ~(flags | CMD_PFILTER_DIRECTED)) ||
+		    (applied & required) != required) {
+			netdev_warn(enic->netdev,
+				    "MBOX: invalid packet filter reply %#x for request %#x\n",
+				    applied, flags);
+			enic_mbox_vf_require_reconnect(enic);
+			status = -EIO;
+		} else if (applied_flags) {
+			*applied_flags = applied;
+		}
+	}
+	if (err)
+		enic_mbox_vf_require_reconnect(enic);
+	enic_mbox_vf_request_finish(enic);
+	if (err)
+		return err;
+
+	return status;
+}
+
 void enic_mbox_init(struct enic *enic)
 {
 	bool reinit = enic->mbox_initialized;
@@ -711,9 +1382,15 @@ void enic_mbox_init(struct enic *enic)
 	 */
 	if (!reinit) {
 		mutex_init(&enic->mbox_lock);
+		mutex_init(&enic->vf_mbox_request_lock);
 		init_completion(&enic->mbox_comp);
 		spin_lock_init(&enic->mbox_state_lock);
+		spin_lock_init(&enic->vf_ack_lock);
+		INIT_LIST_HEAD(&enic->vf_ack_list);
+		INIT_WORK(&enic->vf_ack_work, enic_mbox_vf_ack_work);
 		enic->mbox_msg_num = 0;
+		if (enic_is_sriov_vf_v2(enic))
+			WRITE_ONCE(enic->vf_rx_quarantined, true);
 		enic->mbox_initialized = true;
 	} else {
 		reinit_completion(&enic->mbox_comp);
diff --git a/drivers/net/ethernet/cisco/enic/enic_mbox.h b/drivers/net/ethernet/cisco/enic/enic_mbox.h
index 60409bad2f284..5eca3a25671e9 100644
--- a/drivers/net/ethernet/cisco/enic/enic_mbox.h
+++ b/drivers/net/ethernet/cisco/enic/enic_mbox.h
@@ -5,6 +5,7 @@
 #define _ENIC_MBOX_H_
 
 #include <linux/bits.h>
+#include <linux/if_ether.h>
 #include <linux/types.h>
 
 /*
@@ -22,6 +23,12 @@ enum enic_mbox_msg_type {
 	ENIC_MBOX_VF_UNREGISTER_REPLY		= 5,
 	ENIC_MBOX_PF_LINK_STATE_NOTIF		= 6,
 	ENIC_MBOX_PF_LINK_STATE_ACK		= 7,
+	ENIC_MBOX_VF_ADD_DEL_MAC_REQUEST	= 10,
+	ENIC_MBOX_VF_ADD_DEL_MAC_REPLY		= 11,
+	ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF	= 12,
+	ENIC_MBOX_PF_SET_ADMIN_MAC_ACK		= 13,
+	ENIC_MBOX_VF_SET_PKT_FILTER_REQUEST	= 14,
+	ENIC_MBOX_VF_SET_PKT_FILTER_REPLY	= 15,
 	ENIC_MBOX_MAX
 };
 
@@ -42,6 +49,9 @@ struct enic_mbox_generic_reply {
 #define ENIC_MBOX_ERR_GENERIC		BIT(0)
 #define ENIC_MBOX_ERR_VF_NOT_REGISTERED	BIT(1)
 #define ENIC_MBOX_ERR_MSG_NOT_SUPPORTED	BIT(2)
+#define ENIC_MBOX_ERR_MASK		(ENIC_MBOX_ERR_GENERIC | \
+					 ENIC_MBOX_ERR_VF_NOT_REGISTERED | \
+					 ENIC_MBOX_ERR_MSG_NOT_SUPPORTED)
 
 /* ENIC_MBOX_VF_CAPABILITY_REQUEST / _REPLY */
 #define ENIC_MBOX_CAP_VERSION_0		0
@@ -80,6 +90,71 @@ struct enic_mbox_pf_link_state_ack_msg {
 	struct enic_mbox_generic_reply ack;
 };
 
+/* ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF / _ACK */
+struct enic_mbox_pf_set_admin_mac_notif_msg {
+	u8 mac_addr[ETH_ALEN];
+	__le16 pad;
+};
+
+/* ENIC_MBOX_VF_ADD_DEL_MAC_REQUEST / _REPLY */
+#define ENIC_MAC_ADDR_FLAG_ADD		BIT(0)
+#define ENIC_MAC_ADDR_FLAG_STATION	BIT(1)
+#define ENIC_MAC_ADDR_FLAG_OVERFLOW	BIT(8)
+#define ENIC_MAC_ADDR_FLAG_DUPLICATE	BIT(9)
+#define ENIC_MAC_ADDR_FLAG_FAILED	BIT(10)
+#define ENIC_MAC_ADDR_FLAG_NOT_FOUND	BIT(11)
+#define ENIC_MAC_ADDR_FLAG_ERROR	BIT(12)
+#define ENIC_MAC_ADDR_FLAG_NOT_PERMITTED BIT(13)
+#define ENIC_MAC_ADDR_FLAG_INVALID	BIT(14)
+#define ENIC_MAC_ADDR_FLAG_SKIPPED	BIT(15)
+
+#define ENIC_MAC_ADDR_FLAG_REQUEST_MASK	GENMASK(7, 0)
+#define ENIC_MAC_ADDR_FLAG_REPLY_MASK	GENMASK(15, 8)
+#define ENIC_MAC_ADDR_FLAG_INDETERMINATE_MASK \
+	(ENIC_MAC_ADDR_FLAG_FAILED | ENIC_MAC_ADDR_FLAG_ERROR)
+#define ENIC_MAC_ADDR_FLAG_PERMANENT_MASK \
+	(ENIC_MAC_ADDR_FLAG_OVERFLOW | ENIC_MAC_ADDR_FLAG_NOT_PERMITTED | \
+	 ENIC_MAC_ADDR_FLAG_INVALID)
+#define ENIC_MAC_ADDR_FLAG_ERROR_MASK	(ENIC_MAC_ADDR_FLAG_OVERFLOW | \
+					 ENIC_MAC_ADDR_FLAG_FAILED | \
+					 ENIC_MAC_ADDR_FLAG_ERROR | \
+					 ENIC_MAC_ADDR_FLAG_NOT_PERMITTED | \
+					 ENIC_MAC_ADDR_FLAG_INVALID | \
+					 ENIC_MAC_ADDR_FLAG_SKIPPED)
+
+/* The protocol permits replacing all perfect filters and the station address
+ * in one request: one delete and one add operation for each address.
+ */
+#define ENIC_MBOX_MAX_MAC_OPS		130
+
+struct enic_mac_addr {
+	u8 addr[ETH_ALEN];
+	__le16 flags;
+};
+
+struct enic_mbox_vf_add_del_mac_msg {
+	__le16 num_addrs;
+	__le16 pad;
+	struct enic_mac_addr mac_addr[];
+};
+
+struct enic_mbox_vf_add_del_mac_reply_msg {
+	struct enic_mbox_generic_reply reply;
+	__le16 num_addrs;
+	__le16 pad;
+	struct enic_mac_addr mac_addr[];
+};
+
+/* ENIC_MBOX_VF_SET_PKT_FILTER_REQUEST / _REPLY */
+struct enic_mbox_vf_set_pkt_filter_msg {
+	__le16 flags;
+	__le16 pad;
+};
+
+struct enic_mbox_vf_set_pkt_filter_reply_msg {
+	struct enic_mbox_generic_reply reply;
+};
+
 #define ENIC_MBOX_DST_PF	0xFFFF
 
 struct enic;
@@ -90,8 +165,17 @@ int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id,
 int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state);
 void enic_mbox_vf_link_state_reset(struct enic *enic);
 void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running);
+void enic_mbox_vf_ack_cancel(struct enic *enic);
+void enic_mbox_vf_require_reconnect(struct enic *enic);
 int enic_mbox_vf_capability_check(struct enic *enic);
 int enic_mbox_vf_register(struct enic *enic);
 int enic_mbox_vf_unregister(struct enic *enic);
+int enic_mbox_vf_add_del_macs(struct enic *enic,
+			      struct enic_mac_addr *macs, u16 num_macs);
+int enic_mbox_vf_add_del_mac(struct enic *enic, const u8 *addr, bool add,
+			     bool station);
+int enic_mbox_vf_set_pkt_filter(struct enic *enic, int directed, int multicast,
+				int broadcast, int promisc, int allmulti,
+				u16 *applied_flags);
 
 #endif /* _ENIC_MBOX_H_ */
diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c
index ccbf5c9a21d0f..80fe7e819c375 100644
--- a/drivers/net/ethernet/cisco/enic/enic_rq.c
+++ b/drivers/net/ethernet/cisco/enic/enic_rq.c
@@ -330,8 +330,6 @@ static void enic_rq_indicate_buf(struct enic *enic, struct vnic_rq *rq,
 	u16 bytes_written, vlan_tci, checksum;
 	u32 rss_hash;
 
-	rqstats->packets++;
-
 	cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc, &ingress_port,
 			    &fcoe, &eop, &sop, &rss_type, &csum_not_calc,
 			    &rss_hash, &bytes_written, &packet_error,
@@ -340,8 +338,15 @@ static void enic_rq_indicate_buf(struct enic *enic, struct vnic_rq *rq,
 			    &tcp_udp_csum_ok, &udp, &tcp, &ipv4_csum_ok, &ipv6,
 			    &ipv4, &ipv4_fragment, &fcs_ok);
 
-	if (enic_rq_pkt_error(rq, packet_error, fcs_ok, bytes_written))
+	if (enic_rq_pkt_error(rq, packet_error, fcs_ok, bytes_written)) {
+		rqstats->packets++;
+		return;
+	}
+	if (unlikely(READ_ONCE(enic->vf_rx_quarantined))) {
+		dev_core_stats_rx_dropped_inc(enic->netdev);
 		return;
+	}
+	rqstats->packets++;
 
 	if (eop && bytes_written > 0) {
 		/* Good receive
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5d16737167eed..c1807a8f733bf 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -5197,6 +5197,7 @@ static inline void __dev_mc_unsync(struct net_device *dev,
 
 /* Functions used for secondary unicast and multicast support */
 void dev_set_rx_mode(struct net_device *dev);
+void netif_rx_mode_schedule_update(struct net_device *dev);
 void netif_rx_mode_schedule_retry(struct net_device *dev);
 int netif_set_promiscuity(struct net_device *dev, int inc);
 int dev_set_promiscuity(struct net_device *dev, int inc);
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 08528ca0a8b31..17770a38b5ab2 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -1337,6 +1337,27 @@ static void netif_rx_mode_queue(struct net_device *dev)
 	__netdev_work_core_sched(dev, NETDEV_WORK_RX_MODE);
 }
 
+/**
+ * netif_rx_mode_schedule_update() - schedule a new receive-mode update
+ * @dev: network device
+ *
+ * Cancel any pending retry and reset its backoff before scheduling an
+ * immediate receive-mode update. This does not reset address-list
+ * synchronization state. Callers which need to replay lost device state must
+ * unsynchronize the affected address lists before scheduling the update.
+ *
+ * Context: sleepable. The caller must hold the device operations lock, or
+ * RTNL for a device which still uses RTNL-compatible operations.
+ */
+void netif_rx_mode_schedule_update(struct net_device *dev)
+{
+	might_sleep();
+	netdev_assert_locked_ops_compat(dev);
+	netif_rx_mode_cancel_retry(dev);
+	netif_rx_mode_queue(dev);
+}
+EXPORT_SYMBOL_GPL(netif_rx_mode_schedule_update);
+
 static void netif_rx_mode_retry(struct timer_list *t)
 {
 	struct net_device *dev =

3/2 2026/09/30 20:37 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41755
							output: 24
							thoughts: 716
						

Thoughts:
**Analyzing the Patch for Fuzzing Suitability**

Okay, let's dive into this patch and the associated instructions. My initial instinct is to proceed methodically. First, I need to understand the scope of the modifications. A quick glance reveals changes across several files within the Cisco ENIC driver: `enic.h`, `enic_admin.c`, `enic_dev.c`, `enic_dev.h`, `enic_main.c`, `enic_mbox.c`, `enic_mbox.h`, and `enic_rq.c`. That's a decent chunk of the driver.

But wait a minute... I see `include/linux/netdevice.h` and `net/core/dev_addr_lists.c` listed as modified files as well! That immediately raises a flag. Why would core networking files be touched in a patch primarily targeting a vendor-specific driver? Is this more than meets the eye? Is this Cisco ENIC driver truly hardware-specific? I better be careful...

Right, back to the instructions. The guiding principle is "REACHABILITY IS THE PRIMARY GATE." If the code isn't accessible in a standard virtualized environment (like GCE or QEMU using software-emulated devices), it's off-limits for fuzzing, no matter how complex it seems. Specifically, Section 2 flags "Structurally unreachable hardware" – things like vendor-specific PCIe switches, SmartNICs, or GPU drivers that need specialized hardware not emulated by QEMU. That's a key negative criterion.

Okay, back to the code. What's changed in `net/core/dev_addr_lists.c` and `include/linux/netdevice.h`? Let's take a look. Ah, I see a new function, `netif_rx_mode_schedule_update`:

```c
+void netif_rx_mode_schedule_update(struct net_device *dev)
+{
+	might_sleep();
+	netdev_assert_locked_ops_compat(dev);
+	netif_rx_mode_cancel_retry(dev);
+	netif_rx_mode_queue(dev);
+}
+EXPORT_SYMBOL_GPL(netif_rx_mode_schedule_update);
```

My concern now is whether this `netif_rx_mode_schedule_update` function is *only* used within the Cisco ENIC driver, or if it's part of a more general networking subsystem update. If it's solely tied to ENIC, then it might fall under the "unreachable hardware" category. If it's used more broadly, it's more interesting from a fuzzing perspective, because it is more accessible.

Alright, time to use `grepper`. I'll run a quick search across the kernel tree to see where `netif_rx_mode_schedule_update` is called. The results of that search will be critical. That will inform my decision on whether this patch is a good candidate for fuzzing.



4/2 2026/09/30 20:37 tool grepper
0m Args:
{
  "Expression": "netif_rx_mode_schedule_update"
}

Results:
{
  "Output": "drivers/net/ethernet/cisco/enic/enic_main.c=1219=static void enic_vf_admin_mac_work(struct work_struct *work)\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c-1359-\t\t\t\t\t\t enic-\u003enetdev);\ndrivers/net/ethernet/cisco/enic/enic_main.c:1360:\t\tnetif_rx_mode_schedule_update(enic-\u003enetdev);\ndrivers/net/ethernet/cisco/enic/enic_main.c-1361-\t}\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c=1533=static int enic_set_mac_address_dynamic(struct net_device *netdev, void *p)\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c-1580-\t\t\tenic_vf_admin_mac_cache_selected(enic, addr);\ndrivers/net/ethernet/cisco/enic/enic_main.c:1581:\t\t\tnetif_rx_mode_schedule_update(netdev);\ndrivers/net/ethernet/cisco/enic/enic_main.c-1582-\t\t}\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c=3307=static void enic_reset(struct work_struct *work)\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c-3379-\t\t */\ndrivers/net/ethernet/cisco/enic/enic_main.c:3380:\t\tnetif_rx_mode_schedule_update(enic-\u003enetdev);\ndrivers/net/ethernet/cisco/enic/enic_main.c-3381-\t}\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c=3401=static void enic_tx_hang_reset(struct work_struct *work)\n--\ndrivers/net/ethernet/cisco/enic/enic_main.c-3449-\telse if (enic_is_sriov_vf_v2(enic))\ndrivers/net/ethernet/cisco/enic/enic_main.c:3450:\t\tnetif_rx_mode_schedule_update(enic-\u003enetdev);\ndrivers/net/ethernet/cisco/enic/enic_main.c-3451-\n--\ninclude/linux/netdevice.h=5199=void dev_set_rx_mode(struct net_device *dev);\ninclude/linux/netdevice.h:5200:void netif_rx_mode_schedule_update(struct net_device *dev);\ninclude/linux/netdevice.h-5201-void netif_rx_mode_schedule_retry(struct net_device *dev);\n--\nnet/core/dev_addr_lists.c=1335=static void netif_rx_mode_queue(struct net_device *dev)\n--\nnet/core/dev_addr_lists.c-1340-/**\nnet/core/dev_addr_lists.c:1341: * netif_rx_mode_schedule_update() - schedule a new receive-mode update\nnet/core/dev_addr_lists.c-1342- * @dev: network device\n--\nnet/core/dev_addr_lists.c-1351- */\nnet/core/dev_addr_lists.c:1352:void netif_rx_mode_schedule_update(struct net_device *dev)\nnet/core/dev_addr_lists.c-1353-{\n--\nnet/core/dev_addr_lists.c-1358-}\nnet/core/dev_addr_lists.c:1359:EXPORT_SYMBOL_GPL(netif_rx_mode_schedule_update);\nnet/core/dev_addr_lists.c-1360-\n"
}

5/2 2026/09/30 20:37 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 44126
							output: 33
							thoughts: 95
						

Thoughts:
Here's my thought process, as it stands:

**Debugging the `netif_rx_mode_schedule_update` Call**

Okay, first things first, `netif_rx_mode_schedule_update` seems to be exclusively called from `drivers/net/ethernet/cisco/enic/enic_main.c`. That narrows things down considerably. Now I need to refresh my memory on what `enic` *is*. My initial hunch is that it's related to Cisco VIC (Virtual Interface Card) PCIe Ethernet adapters. To confirm, I'll quickly check the relevant files within the `enic` driver directory: specifically `drivers/net/ethernet/cisco/enic/Kconfig` to see the configuration options, and of course, `enic_main.c` itself. These should give me a solid understanding of the component and its role.



6/2 2026/09/30 20:37 tool grepper
0m Args:
{
  "Expression": "config ENIC",
  "PathPrefix": "drivers/net/ethernet/cisco/"
}

Results:
{
  "Output": "drivers/net/ethernet/cisco/enic/Kconfig-5-\ndrivers/net/ethernet/cisco/enic/Kconfig:6:config ENIC\ndrivers/net/ethernet/cisco/enic/Kconfig-7-\ttristate \"Cisco VIC Ethernet NIC Support\"\n"
}

7/2 2026/09/30 20:37 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 44520
							output: 40
							thoughts: 20
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary:

**Digging into the ENIC Kconfig**

Alright, let's dive into this `drivers/net/ethernet/cisco/enic/Kconfig` file. I immediately start assessing it within the context of the larger Cisco ENIC driver. I'm looking for the key configuration options, their dependencies, and any subtleties in how they're structured. My initial scan will focus on:

*   **The top-level configuration symbols:** What's the main entry point, the `CONFIG_ENIC` itself? Are there any sub-options tied directly to different ENIC features (e.g., hardware offloads, specific NIC generations)? I'm mentally building a hierarchy of the options, understanding the main switch and its branches.
*   **Dependencies:** What other kernel components or drivers need to be enabled for ENIC to function correctly? Are there dependencies on networking infrastructure like VLAN support or specific hardware features? These dependencies are crucial for understanding how the ENIC integrates with the broader system. I'll need to know whether its dependencies are straightforward or a bit convoluted.
*   **Tri-state values:** The Kconfig format lets you set things to either yes, no, or module. I'll be analyzing whether certain options are only built into the kernel or as modules, depending on the circumstances.
*   **Default values:** Are there sensible defaults for the ENIC options? Are these defaults based on some compile-time detection? Are they reasonable, or do I need to explicitly change them? I will be thinking of the defaults as a part of the driver's default behavior, and whether they can be adjusted at runtime.
*   **Help text:** The comments within the Kconfig are usually gold. I'm scanning for detailed explanations of what each option does, any implications of enabling or disabling it, and any potential caveats or limitations. I'm especially interested in any hints about performance tuning or debugging features.
*   **Conditional dependencies:** Look for any build-time checks or conditions that limit availability. I will look for hardware dependencies, operating system dependencies, or other drivers that need to be in place.

Basically, I want to gain a comprehensive understanding of what this Kconfig file exposes, what controls the ENIC driver's capabilities, and how it can be tailored to different hardware setups and kernel configurations. I'm not just reading; I'm mentally assembling a configuration knowledge base for this driver. I'll want to build my knowledge so that I can provide an expert-level evaluation, and provide my expert opinion, should there be any issues or areas for potential enhancement.



8/2 2026/09/30 20:38 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/cisco/enic/Kconfig",
  "FirstLine": 1,
  "LineCount": 40
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0-only\n   2:\t#\n   3:\t# Cisco device configuration\n   4:\t#\n   5:\t\n   6:\tconfig ENIC\n   7:\t\ttristate \"Cisco VIC Ethernet NIC Support\"\n   8:\t\tdepends on PCI\n   9:\t\tselect PAGE_POOL\n  10:\t\thelp\n  11:\t\t  This enables the support for the Cisco VIC Ethernet card.\n"
}

9/2 2026/09/30 20:38 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 45273
							output: 24
							thoughts: 931
						

Thoughts:
**WorthFuzzing=false: A Deep Dive into `enic` and Reachability**

Okay, so `ENIC`—that's "Cisco VIC Ethernet NIC Support"—is a vendor-specific PCIe NIC driver. It's explicitly designed for the Cisco VIC Ethernet card. My initial instinct, based on the documentation, is to apply the negative criteria for WorthFuzzing=false. Specifically, "Structurally unreachable hardware: Vendor-specific PCIe switches, SmartNICs, or GPU drivers requiring physical ASIC/PCIe cards not emulated in standard QEMU."

The core question is, is the Cisco VIC emulated in QEMU? And the answer is a resounding no. QEMU uses things like `e1000`, `e1000e`, `rtl8139`, `virtio-net`, `vmxnet3`, `igb`, etc. The Cisco VIC is proprietary hardware for Cisco UCS servers. It necessitates *physical* Cisco VIC hardware.

Then there's that helper function added in `net/core/dev_addr_lists.c`, `netif_rx_mode_schedule_update()`. Can that function ever be called *unless* the `enic` driver is loaded? Given that `enic` is only loaded when a Cisco VIC PCIe card is present, and since we're in a standard virtualized environment (QEMU/GCE), is that code even *reachable* during fuzzing?

Let's revisit the fundamental principle: "Fuzzing can only discover bugs in code that can actually execute in standard virtualized environments. If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed, regardless of whether it adds assertions or complex logic."

Alright, let's confirm the call sites for `netif_rx_mode_schedule_update()`. Grepper should show us everything.

*   Definition in `net/core/dev_addr_lists.c`.
*   Declaration in `include/linux/netdevice.h`.
*   Four call sites within `drivers/net/ethernet/cisco/enic/enic_main.c`:
    *   `enic_vf_admin_mac_work()`
    *   `enic_set_mac_address_dynamic()`
    *   `enic_reset()`
    *   `enic_tx_hang_reset()`

All of them, every single one, is in `enic_main.c`! They're all wrapped by `enic_is_sriov_vf_v2` or `enic` VF code. I have to definitively confirm, are there any calls to `netif_rx_mode_schedule_update` outside of these contexts?

Let's use Grepper to search the entire repository to confirm. Nope. Nothing. It is only in `net/core/dev_addr_lists.c`, `include/linux/netdevice.h`, and `enic_main.c`.

Okay, I need to check the git log and related commits. Gotta understand the broader context.



10/2 2026/09/30 20:38 tool grepper
0m Args:
{
  "Expression": "netif_rx_mode_schedule_retry"
}

Results:
{
  "Output": "drivers/net/ethernet/broadcom/bnge/bnge_netdev.c=2684=static int bnge_init_chip(struct bnge_net *bn)\n--\ndrivers/net/ethernet/broadcom/bnge/bnge_netdev.c-2751-\tif (rc == -EAGAIN) {\ndrivers/net/ethernet/broadcom/bnge/bnge_netdev.c:2752:\t\tnetif_rx_mode_schedule_retry(bn-\u003enetdev);\ndrivers/net/ethernet/broadcom/bnge/bnge_netdev.c-2753-\t\trc = 0;\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt.c=11239=static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)\n--\ndrivers/net/ethernet/broadcom/bnxt/bnxt.c-11332-\tif (rc == -EAGAIN) {\ndrivers/net/ethernet/broadcom/bnxt/bnxt.c:11333:\t\tnetif_rx_mode_schedule_retry(bp-\u003edev);\ndrivers/net/ethernet/broadcom/bnxt/bnxt.c-11334-\t\trc = 0;\n--\ninclude/linux/netdevice.h=5200=void netif_rx_mode_schedule_update(struct net_device *dev);\ninclude/linux/netdevice.h:5201:void netif_rx_mode_schedule_retry(struct net_device *dev);\ninclude/linux/netdevice.h-5202-int netif_set_promiscuity(struct net_device *dev, int inc);\n--\nnet/core/dev_addr_lists.c=1232=static int netif_uc_promisc_update(struct net_device *dev)\n--\nnet/core/dev_addr_lists.c-1250-\nnet/core/dev_addr_lists.c:1251:void netif_rx_mode_schedule_retry(struct net_device *dev)\nnet/core/dev_addr_lists.c-1252-{\n--\nnet/core/dev_addr_lists.c-1268-}\nnet/core/dev_addr_lists.c:1269:EXPORT_SYMBOL_GPL(netif_rx_mode_schedule_retry);\nnet/core/dev_addr_lists.c-1270-\n--\nnet/core/dev_addr_lists.c=1277=void netif_rx_mode_run(struct net_device *dev)\n--\nnet/core/dev_addr_lists.c-1300-\t\t\tnetif_addr_unlock_bh(dev);\nnet/core/dev_addr_lists.c:1301:\t\t\tnetif_rx_mode_schedule_retry(dev);\nnet/core/dev_addr_lists.c-1302-\t\t\treturn;\n--\nnet/core/dev_addr_lists.c-1324-\t\tif (err)\nnet/core/dev_addr_lists.c:1325:\t\t\tnetif_rx_mode_schedule_retry(dev);\nnet/core/dev_addr_lists.c-1326-\t\telse\n"
}

11/2 2026/09/30 20:38 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 47716
							output: 40
							thoughts: 31
						

Thoughts:
Here's a summary of my mental process:

**Diving into `dev_addr_lists.c`**

Okay, time to dig into the kernel source. I need to take a look at `net/core/dev_addr_lists.c`, specifically around lines 1330 to 1370. This area is likely dealing with [likely describes the topic based on the file name]. I'm expecting to find the implementation details related to [expected functionality/variable name]. I'll be looking for [specific indicators/variables/code patterns] to understand how this is handled, and how it interacts with the broader networking stack. I'm going to pay close attention to the data structures involved and any locking mechanisms used to ensure concurrency safety.



12/2 2026/09/30 20:38 tool read-file
0m Args:
{
  "File": "net/core/dev_addr_lists.c",
  "FirstLine": 1330,
  "LineCount": 45
}

Results:
{
  "Contents": "1330:\t\t\tops-\u003endo_set_rx_mode(dev);\n1331:\t\t\tnetif_addr_unlock_bh(dev);\n1332:\t\t}\n1333:\t}\n1334:\t\n1335:\tstatic void netif_rx_mode_queue(struct net_device *dev)\n1336:\t{\n1337:\t\t__netdev_work_core_sched(dev, NETDEV_WORK_RX_MODE);\n1338:\t}\n1339:\t\n1340:\t/**\n1341:\t * netif_rx_mode_schedule_update() - schedule a new receive-mode update\n1342:\t * @dev: network device\n1343:\t *\n1344:\t * Cancel any pending retry and reset its backoff before scheduling an\n1345:\t * immediate receive-mode update. This does not reset address-list\n1346:\t * synchronization state. Callers which need to replay lost device state must\n1347:\t * unsynchronize the affected address lists before scheduling the update.\n1348:\t *\n1349:\t * Context: sleepable. The caller must hold the device operations lock, or\n1350:\t * RTNL for a device which still uses RTNL-compatible operations.\n1351:\t */\n1352:\tvoid netif_rx_mode_schedule_update(struct net_device *dev)\n1353:\t{\n1354:\t\tmight_sleep();\n1355:\t\tnetdev_assert_locked_ops_compat(dev);\n1356:\t\tnetif_rx_mode_cancel_retry(dev);\n1357:\t\tnetif_rx_mode_queue(dev);\n1358:\t}\n1359:\tEXPORT_SYMBOL_GPL(netif_rx_mode_schedule_update);\n1360:\t\n1361:\tstatic void netif_rx_mode_retry(struct timer_list *t)\n1362:\t{\n1363:\t\tstruct net_device *dev =\n1364:\t\t\ttimer_container_of(dev, t, rx_mode_retry_timer);\n1365:\t\n1366:\t\tnetif_rx_mode_queue(dev);\n1367:\t}\n1368:\t\n1369:\tvoid netif_rx_mode_init(struct net_device *dev)\n1370:\t{\n1371:\t\t__hw_addr_init(\u0026dev-\u003erx_mode_addr_cache);\n1372:\t\ttimer_setup(\u0026dev-\u003erx_mode_retry_timer, netif_rx_mode_retry, 0);\n1373:\t}\n1374:\t\n"
}

13/2 2026/09/30 20:38 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 48656
							output: 167
							thoughts: 3237
						

Thoughts:
**Analysis of Code Reachability and Fuzzing Suitability**

My primary concern here is reachability for fuzzing purposes. I've analyzed the `netif_rx_mode_schedule_update` function and the surrounding changes. Initially, the code modification appears to introduce a new function within the `net/core` subsystem. However, after a thorough review, including tracing function calls, examining the diffs, and understanding the hardware context, it's clear the changes are not suitable for fuzzing in standard environments.

The `netif_rx_mode_schedule_update` function is exclusively called by the `enic` driver, which is specific to Cisco VIC Ethernet NICs. These NICs are part of Cisco's Unified Computing System (UCS) and rely on proprietary hardware that's not emulated in environments like QEMU or Google Compute Engine. Therefore, the modified code is fundamentally unreachable in the target fuzzing environments. While a new function is added to `net/core`, this addition does not influence or modify existing code flow that's reachable by standard means.

The analysis confirms that the execution path for the introduced code requires specific physical hardware that is unavailable in virtualized environments. While the code might be related to core networking, it has a strict dependency on proprietary hardware, making it functionally unreachable for fuzzing. Thus, according to the project's directives, fuzzing efforts for this patch series would be unproductive, and the "WorthFuzzing" flag should be set to false.



14/2 2026/09/30 20:38 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies the Cisco VIC Ethernet NIC driver (drivers/net/ethernet/cisco/enic/) to add SR-IOV V2 VF mailbox operations, packet filter configuration, and administrative MAC address handling. It also introduces a new helper function netif_rx_mode_schedule_update() in net/core/dev_addr_lists.c which is exclusively called by the enic driver. Cisco VIC is vendor-specific PCIe hardware that is not emulated in standard virtualized fuzzing environments (QEMU/GCE), and no existing core networking logic was altered. As a result, all modified code is structurally unreachable during fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies the Cisco VIC Ethernet NIC driver (drivers/net/ethernet/cisco/enic/) to add SR-IOV V2 VF mailbox operations, packet filter configuration, and administrative MAC address handling. It also introduces a new helper function netif_rx_mode_schedule_update() in net/core/dev_addr_lists.c which is exclusively called by the enic driver. Cisco VIC is vendor-specific PCIe hardware that is not emulated in standard virtualized fuzzing environments (QEMU/GCE), and no existing core networking logic was altered. As a result, all modified code is structurally unreachable during fuzzing.",
  "WorthFuzzing": false
}

15/1 2026/09/30 20:38 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)