[PATCH net-next v5 6/6] enic: configure V2 VF receive mode over mailbox
From: Satish Kharat
Date: Mon Nov 30 2026 - 19:58:29 EST
V2 VFs cannot program receive filters directly. Add an asynchronous
receive-mode callback that sends unicast and multicast address changes and
packet-filter settings through the VF's one-request-at-a-time mailbox
path.
Complete all phases required for one address-list snapshot before
reporting success from the callback. Retryable errors request the bounded
netdev-core retry path. Send stale DELETEs before new ADDs in one
exact-filter batch and send packet-filter mode updates separately.
Reserve capacity for 31 secondary unicast and 32 multicast entries
because deployed async PFs count the station address in the same 32-entry
unicast table. Install the finite exact-filter subset even when broad
coverage is required or denied, leaving overflow entries unsynchronized
for later convergence.
Use the validated applied mask to order broad-mode transitions. Request
newly needed broad coverage before exact-filter work and withdraw stale
broad coverage before installing its finite replacement. If a command
fails while obsolete broad coverage may remain, require reconnect unless
recovery is already pending or the send queue is poisoned. A validated
policy denial of the new broad mode leaves degraded coverage and still
allows withdrawal of the old mode. Report policy denials during open and
runtime updates.
Track detailed per-address results so idempotent outcomes converge and
stable ADD policy denials do not consume the retry budget. Preserve an
installed-filter counter inconsistency across later ADD results. Compatible
PFs reject whole requests before applying operations and report individual
operation failures separately. Require fresh registration after a request-
wide -EIO involving DELETE, retiring stale filters from the previous
snapshot. Keep local pre-submit and add-only rejections on the normal
retry path. Keep the station address out of both secondary address lists.
Exclude an all-zero MAC from requested counts and operation collection
before projecting exact-filter occupancy. The PF rejects that address as
INVALID, so reserving capacity for it would crowd out a later valid
address on every update.
Require the individual/group bit to match the netdev address-list class
before counting an address or collecting its operations. The PF tracks
a single filter per raw MAC. Counting the same MAC in both lists can
reserve capacity twice and removing one reference can delete the filter
while the other list still considers it synchronized.
Select the asynchronous netdev operations only for V2 VFs. Schedule
receive-mode replay after successful internal reopen on reset, hang reset,
or a direct MTU change.
Signed-off-by: Satish Kharat <satishkh@xxxxxxxxx>
---
drivers/net/ethernet/cisco/enic/enic.h | 3 +
drivers/net/ethernet/cisco/enic/enic_main.c | 493 +++++++++++++++++++++++++++-
2 files changed, 484 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
index 7f1367de6611..d148a75ce0aa 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -398,6 +398,9 @@ struct enic {
*/
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 */
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index a2186f65c74a..4a9b4bf9e16b 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1048,6 +1048,8 @@ void enic_reset_addr_lists(struct enic *enic)
enic->uc_count = 0;
enic->flags = 0;
netif_addr_unlock_bh(netdev);
+
+ enic->vf_pkt_filter_valid = false;
}
static int enic_set_mac_addr(struct net_device *netdev, char *addr)
@@ -1653,17 +1655,419 @@ 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 - 1;
+}
+
+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 bool
+enic_vf_secondary_addr_valid(const struct enic *enic,
+ const struct netdev_hw_addr *ha)
+{
+ u8 type = is_multicast_ether_addr(ha->addr) ?
+ NETDEV_HW_ADDR_T_MULTICAST : NETDEV_HW_ADDR_T_UNICAST;
+
+ /* The PF stores one exact filter per MAC. Admit it from the list
+ * matching its Ethernet address class, and leave the station separate.
+ */
+ return ha->type == type && !is_zero_ether_addr(ha->addr) &&
+ !(enic->vf_station_addr_valid &&
+ ether_addr_equal(ha->addr, enic->vf_station_addr));
+}
+
+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_secondary_addr_valid(enic, ha))
+ count++;
+
+ return count;
+}
+
+static int enic_vf_collect_mac_ops(struct enic *enic,
+ struct netdev_hw_addr_list *list,
+ bool add,
+ unsigned int *filter_count,
+ unsigned int *projected_count,
+ unsigned int max_filters,
+ struct enic_mac_addr *macs,
+ struct enic_vf_mac_op *ops,
+ u16 *num_ops)
+{
+ struct netdev_hw_addr *ha;
+ u16 pos = *num_ops;
+
+ netdev_hw_addr_list_for_each(ha, list) {
+ if (!enic_vf_secondary_addr_valid(enic, ha))
+ continue;
+ if (add) {
+ if (ha->sync_cnt || *projected_count >= max_filters)
+ continue;
+ } else {
+ if (!ha->sync_cnt || ha->refcount != ha->sync_cnt)
+ continue;
+ WARN_ON_ONCE(!*projected_count);
+ }
+ if (pos == ENIC_MBOX_MAX_MAC_OPS)
+ return -E2BIG;
+
+ ether_addr_copy(macs[pos].addr, ha->addr);
+ macs[pos].flags = add ?
+ cpu_to_le16(ENIC_MAC_ADDR_FLAG_ADD) : 0;
+ ops[pos].ha = ha;
+ ops[pos].filter_count = filter_count;
+ pos++;
+ if (add)
+ (*projected_count)++;
+ else if (*projected_count)
+ (*projected_count)--;
+ }
+
+ *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)
+{
+ unsigned int projected_mc = enic->mc_count;
+ unsigned int projected_uc = enic->uc_count;
+ struct enic_vf_mac_op *ops;
+ struct enic_mac_addr *macs;
+ bool permanent_add = false;
+ bool retryable_add = false;
+ bool has_delete = false;
+ bool reconnect = 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 - 1 +
+ 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;
+ }
+
+ /* Collect all stale deletes before any add. Projected occupancy reserves
+ * only replies which could fit after those deletes; actual counts change
+ * below only for successful per-operation results.
+ */
+ err = enic_vf_collect_mac_ops(enic, uc, false, &enic->uc_count,
+ &projected_uc, 0,
+ macs, ops, &num_ops);
+ if (err)
+ goto free_ops;
+ err = enic_vf_collect_mac_ops(enic, mc, false, &enic->mc_count,
+ &projected_mc, 0,
+ macs, ops, &num_ops);
+ if (err)
+ goto free_ops;
+ has_delete = num_ops != 0;
+
+ err = enic_vf_collect_mac_ops(enic, uc, true, &enic->uc_count,
+ &projected_uc,
+ ENIC_UNICAST_PERFECT_FILTERS - 1,
+ macs, ops, &num_ops);
+ if (err)
+ goto free_ops;
+ err = enic_vf_collect_mac_ops(enic, mc, true, &enic->mc_count,
+ &projected_mc,
+ ENIC_MULTICAST_PERFECT_FILTERS,
+ macs, ops, &num_ops);
+ if (err || !num_ops)
+ goto free_ops;
+
+ /* Keep exact-filter operations in one MAC request. Packet-filter mode
+ * transitions may issue separate requests in the same callback.
+ */
+ err = enic_mbox_vf_add_del_macs(enic, macs, num_ops);
+ if (err) {
+ /* Supported PFs reject a whole request before applying operations.
+ * A rejected DELETE batch leaves stale acceptance from the previous
+ * snapshot. Fresh registration retires it; ADD-only rejections retry.
+ */
+ if (err == -EIO && has_delete &&
+ !READ_ONCE(enic->mbox_tx_poisoned) &&
+ !READ_ONCE(enic->vf_mbox_reconnect_required))
+ enic_mbox_vf_require_reconnect(enic);
+ 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 (err != -EIO) {
+ /* Do not let a retryable or permanently-denied ADD overwrite an
+ * installed-filter counter inconsistency (-EIO) detected above.
+ */
+ 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);
+ u16 broad_modes = CMD_PFILTER_PROMISCUOUS |
+ CMD_PFILTER_ALL_MULTICAST;
+ bool target_filter_updated = false;
+ bool broad_enable_needed;
+ bool broad_withdrawal;
+ u16 prefilter_flags;
+ bool filter_needed;
+ u16 applied_broad;
+ 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);
+ applied_broad = enic->vf_pkt_filter_valid ?
+ enic->vf_pkt_filter_applied & broad_modes : 0;
+ broad_enable_needed = flags & broad_modes & ~applied_broad;
+ broad_withdrawal = applied_broad & ~flags;
+ if (broad_enable_needed) {
+ /* Establish newly required broad coverage before an independent
+ * exact-address rejection can block it. Retain currently applied
+ * broad modes while establishing the newly required modes.
+ */
+ prefilter_flags = flags;
+ prefilter_flags |= applied_broad;
+ err = enic_vf_set_pkt_filter(enic, prefilter_flags,
+ &applied_flags);
+ if (err) {
+ /* A combined transition retains the old applied broad mode
+ * until the new one is established. If that request fails, the
+ * stale mode may remain active outside the requested policy.
+ */
+ if (broad_withdrawal &&
+ !READ_ONCE(enic->mbox_tx_poisoned) &&
+ !READ_ONCE(enic->vf_mbox_reconnect_required))
+ enic_mbox_vf_require_reconnect(enic);
+ 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);
+ }
+
+ /* Install and retain the finite exact-filter subset even for an
+ * overflowing class. Broad mode covers the remaining addresses when PF
+ * policy permits it. Deletes are applied first so later updates can fill
+ * newly available exact-filter slots.
+ */
+ err = enic_vf_sync_mac_filters(enic, uc, mc);
+ 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);
@@ -2283,9 +2687,13 @@ static int __enic_open(struct net_device *netdev,
{
struct enic *enic = netdev_priv(netdev);
bool vf_mac_added = false;
+ unsigned int vf_mc_count;
+ unsigned int vf_uc_count;
bool clear_cqs = false;
- unsigned int i;
+ u16 vf_filter_applied;
+ u16 vf_filter_flags;
int stop_err = 0;
+ unsigned int i;
int err, ret;
unsigned int max_pkt_len = netdev->mtu + VLAN_ETH_HLEN;
struct page_pool_params pp_params = {
@@ -2379,7 +2787,6 @@ 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");
@@ -2412,9 +2819,31 @@ static int __enic_open(struct net_device *netdev,
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;
+ }
+ enic_vf_report_pkt_filter_denial(netdev, vf_filter_flags,
+ vf_filter_applied);
}
- enic_set_rx_mode(netdev);
+ if (!enic_is_sriov_vf_v2(enic))
+ enic_set_rx_mode(netdev);
netif_tx_wake_all_queues(netdev);
@@ -2622,6 +3051,7 @@ static int enic_stop(struct net_device *netdev)
static int _enic_change_mtu(struct net_device *netdev, int new_mtu)
{
+ struct enic *enic = netdev_priv(netdev);
bool running = netif_running(netdev);
int err = 0;
@@ -2638,6 +3068,8 @@ static int _enic_change_mtu(struct net_device *netdev, int new_mtu)
err = enic_open(netdev);
if (err)
return err;
+ if (enic_is_sriov_vf_v2(enic))
+ netif_rx_mode_schedule_update(netdev);
}
return 0;
@@ -3275,6 +3707,12 @@ static void enic_reset(struct work_struct *work)
netdev_err(enic->netdev,
"Failed to reopen datapath after reset: %d\n", err);
goto reset_out;
+ } else if (reopen && 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);
}
/* A PF reopens its admin channel after the datapath and re-pushes link
@@ -3412,6 +3850,8 @@ static void enic_hang_reset(struct enic *enic, bool mailbox_recovery)
netdev_err(enic->netdev,
"Failed to reopen datapath after hang reset: %d\n", err);
goto hang_reset_out;
+ } else if (reopen && enic_is_sriov_vf_v2(enic)) {
+ netif_rx_mode_schedule_update(enic->netdev);
}
/* A PF reopens its admin channel after the datapath and re-pushes link
@@ -3695,6 +4135,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,
@@ -4381,7 +4845,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;
@@ -4545,9 +5011,12 @@ 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. VF_UNREGISTER is the
+ * 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);
--
2.43.0