From nobody Tue Apr 7 09:18:44 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 499C81C3C08 for ; Sat, 14 Mar 2026 18:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773512960; cv=none; b=gN3QdR6RyiApOXIeRBiqoN162UjBDIbXniBE98H7lXwKIENX4ymjyGrVzfL5nu+teASKKcTo0foFCJAnvIv25402XPbXCIZ6eLyiCLwlU3yZfcOMstha82PLs03yudV81wWoMWm3isYqOulSjYSeAhnMfSEIu/FRy4hlr2plusU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773512960; c=relaxed/simple; bh=dO/o0JMUv+1ZIvwhmT7hMk44yXS9kH2XOnxXr/908xQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uFsxp9FiPlTPR7iLI6ozzlxImH6G61P0wdqhyLr1EItu84Dd47jRwNT/qMJ4zwsvyz0IdecLUVrXN6yKH3jQQBWl9XuISRMboBI+9KiHrZtqdQdklztMNElw3TxvIR4v/kQKdD2/6rTONzoihcS6hmTEBqmg34vThv+qoCsycrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Brohx7Mc; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Brohx7Mc" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2b042533de1so3856825ad.0 for ; Sat, 14 Mar 2026 11:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773512959; x=1774117759; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HcUZRx+vC9EsPoreW0zaJm9GJsT/ODmp1Tzy9ZQGo5g=; b=Brohx7MccDU9TKHJVQ6jwhEuxgT8IHS2grEmygbD8Ziv+P/TywAabAjIuwFIia/uNc JXTvXCBON1LZnDjJwx5VkV/xdwM9uYJB61HWlievtZYpKYMFfFs0OQVKGuF+zgo4yuGp WlWsmr/5trnflvUnkvhKNq1Ahj6zEQBOUaJP1z/NXtWgBmrjQxpPgZ6NBPKbC4123uy+ wSbraUDANqQG2lZD05rARHJHVyHXWet+sV29TqvE0hFJA+0WVzvigvLpv4SOmcPr1YwH tpul6OJXGBqZ5eNoRMYMTTb+oRfiNWXBgIawDf0SGHRa4Y/iQ/Zb18toxKJp82a8xQVU aUMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773512959; x=1774117759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HcUZRx+vC9EsPoreW0zaJm9GJsT/ODmp1Tzy9ZQGo5g=; b=hMk/Z6jATdX1uRA/z/I2XV6Gn485Y21f6Yt5ElXk7jdlutF0C0LSwJ+sCo0dTMykqN N75J2ijn9cC1JgSoFnjUqM48xxBZUh0KloCSaf937VKb/MTHHXjZ+pSA+VKY/tcqkQTm 3Ron04CquCwA9eKSDaVNU2AyHMiOIUEe7vAPOvxpdhMNd+K4AVhw91dmVIzjLRZJmrnN 6Ww+Y+sPPvWPmbs/AF04N4iJoUt5LuI2j0FSFNQSB/WuF3NfdnshfXBPZLXsdWRb625m qgi1Zmr4ugMSsgqftTgKUXs3XN5w+b+QKdgz6BTO4u6fCn1eMCt1wTUHTbqcHta2YM4l H2Qg== X-Forwarded-Encrypted: i=1; AJvYcCVw1sNTCG617OxHpi9pVg3L7qY6MlCKW08GolzBk19i6og2SctYzIluGd1/mdzvjV/rnHkgj3/spBpmMX8=@vger.kernel.org X-Gm-Message-State: AOJu0YyL8MzOFEun7R74IDMfTrsBQ6dty1GUTTVrqG3ufAz149TDOzVg 4Z76RCNa8tKI6YoeP9s3EPILh4eb+x9f48e1tmDTFs4vspccRra2KJNL X-Gm-Gg: ATEYQzzCoDjfL36RKsXhW816mR3l7oYZXxweO8oddLv75kR1f4xHXuxLs/BW87kKHN5 VzmJya9jNMM6LyLNRJf6qyKTWR04icuPb0HFZ3U9angVGn5RJxB/BRYQBazNAEWhAZ0E1tCs0pP Re6s/hHq+hhCwI7+biYbyrcWpUua4acxmHr3kmGTK2eDce+nuAxdMn4Dc+cjGaVMRSGvN+jo2RS 7PBYmhOxMQ3Lzyi7uYPDSgPbR0nr++h/l1wkw73AAAykhhK08f9YdCpfiQkYGpj61VyWV+Rlbv6 VF5fmmBh6ewo8Zi4GU/fZ17ZPFioJbGS+Whzma7ULIrLdIJ3h1DsVqxcQoibwrDbHUd+ElulGoX RXxZJGmtG+HMH+ig8vWO7ulL7xJqE/rVpGAFc0zmWo4vOE+6wTjFuJJxyWw2mDN4QFc2uZPmciz iruF51RqBBmIwnqrJQAlwRasYXGTHagSckahlfGbdG33NMLXgpNHSnVAb4oSUezxa4nIwR+wLub 7t8WBpXXtSMLyGV X-Received: by 2002:a17:903:2283:b0:2ae:c5b2:6a41 with SMTP id d9443c01a7336-2aecac84adamr78848905ad.52.1773512958550; Sat, 14 Mar 2026 11:29:18 -0700 (PDT) Received: from localhost.localdomain ([122.168.66.151]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2aece62c581sm77673525ad.33.2026.03.14.11.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2026 11:29:17 -0700 (PDT) From: I Viswanath To: stfomichev@gmail.com, horms@kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, kuba@kernel.org, davem@davemloft.net, eperezma@redhat.com, xuanzhuo@linux.alibaba.com, jasowang@redhat.com, mst@redhat.com, przemyslaw.kitszel@intel.com, anthony.l.nguyen@intel.com, jacob.e.keller@intel.com, ronak.doshi@broadcom.com, pcnet32@frontier.com Cc: bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, virtualization@lists.linux.dev, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, I Viswanath Subject: [PATCH net-next v9 4/7] e1000: Implement ndo_set_rx_mode_async callback Date: Sat, 14 Mar 2026 23:58:06 +0530 Message-ID: <20260314182809.362808-5-viswanathiyyappan@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260314182809.362808-1-viswanathiyyappan@gmail.com> References: <20260314182809.362808-1-viswanathiyyappan@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Implement the ndo_set_rx_mode_async callback and update the driver to use the snapshot/commit model for RX mode update. Signed-off-by: I Viswanath Reviewed-by: Aleksandr Loktionov --- Call paths involving netif_set_rx_mode in e1000 netif_set_rx_mode |-- __e1000_shutdown (lock added) | `-- e1000_configure |-- e1000_open (ndo_open, takes lock) | `-- e1000_up |-- e1000_reinit_locked | |-- e1000_set_features (ndo_set_features, takes lock) | |-- e1000_reset_task (ethtool callback, takes lock) | |-- e1000_mii_ioctl | | `-- e1000_ioctl (ndo_do_ioctl, takes lock) | `-- e1000_nway_reset (ethtool callback, takes lock) | |-- e1000_change_mtu (ndo_change_mtu, takes lock) |-- e1000_resume (lock added) |-- e1000_io_resume (lock added) | |-- e1000_set_link_ksettings (ethtool callback, takes lock) |-- e1000_set_pauseparam (ethtool callback, takes lock) `-- e1000_set_ringparam (ethtool callback, takes lock) drivers/net/ethernet/intel/e1000/e1000_main.c | 77 ++++++++++++++----- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/et= hernet/intel/e1000/e1000_main.c index 9b09eb144b81..ec25b41c63b7 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -99,6 +99,7 @@ static void e1000_clean_tx_ring(struct e1000_adapter *ada= pter, static void e1000_clean_rx_ring(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring); static void e1000_set_rx_mode(struct net_device *netdev); +static void e1000_set_rx_mode_async(struct net_device *netdev); static void e1000_update_phy_info_task(struct work_struct *work); static void e1000_watchdog(struct work_struct *work); static void e1000_82547_tx_fifo_stall_task(struct work_struct *work); @@ -359,7 +360,7 @@ static void e1000_configure(struct e1000_adapter *adapt= er) struct net_device *netdev =3D adapter->netdev; int i; =20 - e1000_set_rx_mode(netdev); + netif_set_rx_mode(netdev); =20 e1000_restore_vlan(adapter); e1000_init_manageability(adapter); @@ -823,6 +824,7 @@ static const struct net_device_ops e1000_netdev_ops =3D= { .ndo_stop =3D e1000_close, .ndo_start_xmit =3D e1000_xmit_frame, .ndo_set_rx_mode =3D e1000_set_rx_mode, + .ndo_set_rx_mode_async =3D e1000_set_rx_mode_async, .ndo_set_mac_address =3D e1000_set_mac, .ndo_tx_timeout =3D e1000_tx_timeout, .ndo_change_mtu =3D e1000_change_mtu, @@ -2223,23 +2225,44 @@ static int e1000_set_mac(struct net_device *netdev,= void *p) } =20 /** - * e1000_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode s= et + * e1000_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode + * config. * @netdev: network interface device structure * * The set_rx_mode entry point is called whenever the unicast or multicast * address lists or the network interface flags are updated. This routine = is - * responsible for configuring the hardware for proper unicast, multicast, - * promiscuous mode, and all-multi behavior. + * responsible for preparing the rx mode config and scheduling the rx_mode + * work which invokes the set_rx_mode_async callback. **/ static void e1000_set_rx_mode(struct net_device *netdev) +{ + bool allmulti =3D !!(netdev->flags & IFF_ALLMULTI); + bool promisc =3D !!(netdev->flags & IFF_PROMISC); + + netif_set_rx_mode_flag(netdev, NETIF_RX_MODE_UC_SKIP, promisc); + + netif_set_rx_mode_cfg(netdev, NETIF_RX_MODE_CFG_ALLMULTI, allmulti); + netif_set_rx_mode_cfg(netdev, NETIF_RX_MODE_CFG_PROMISC, promisc); +} + +/** + * e1000_set_rx_mode_async - Secondary Unicast, Multicast and Promiscuous = mode + * confirm. + * @netdev: network interface device structure + * + * The set_rx_mode_async callback is responsible for actually updating the + * hardware. This routine is responsible for configuring the hardware for + * proper unicast, multicast, promiscuous mode, and all-multi behavior. + **/ +static void e1000_set_rx_mode_async(struct net_device *netdev) { struct e1000_adapter *adapter =3D netdev_priv(netdev); struct e1000_hw *hw =3D &adapter->hw; - struct netdev_hw_addr *ha; bool use_uc =3D false; + char *ha_addr; u32 rctl; u32 hash_value; - int i, rar_entries =3D E1000_RAR_ENTRIES; + int i, rar_entries =3D E1000_RAR_ENTRIES, ni; int mta_reg_count =3D E1000_NUM_MTA_REGISTERS; u32 *mcarray =3D kcalloc(mta_reg_count, sizeof(u32), GFP_ATOMIC); =20 @@ -2250,11 +2273,11 @@ static void e1000_set_rx_mode(struct net_device *ne= tdev) =20 rctl =3D er32(RCTL); =20 - if (netdev->flags & IFF_PROMISC) { + if (netif_get_rx_mode_cfg(netdev, NETIF_RX_MODE_CFG_PROMISC)) { rctl |=3D (E1000_RCTL_UPE | E1000_RCTL_MPE); rctl &=3D ~E1000_RCTL_VFE; } else { - if (netdev->flags & IFF_ALLMULTI) + if (netif_get_rx_mode_cfg(netdev, NETIF_RX_MODE_CFG_ALLMULTI)) rctl |=3D E1000_RCTL_MPE; else rctl &=3D ~E1000_RCTL_MPE; @@ -2263,9 +2286,9 @@ static void e1000_set_rx_mode(struct net_device *netd= ev) rctl |=3D E1000_RCTL_VFE; } =20 - if (netdev_uc_count(netdev) > rar_entries - 1) { + if (netif_rx_mode_uc_count(netdev) > rar_entries - 1) { rctl |=3D E1000_RCTL_UPE; - } else if (!(netdev->flags & IFF_PROMISC)) { + } else if (!netif_get_rx_mode_cfg(netdev, NETIF_RX_MODE_CFG_PROMISC)) { rctl &=3D ~E1000_RCTL_UPE; use_uc =3D true; } @@ -2286,23 +2309,23 @@ static void e1000_set_rx_mode(struct net_device *ne= tdev) */ i =3D 1; if (use_uc) - netdev_for_each_uc_addr(ha, netdev) { + netif_rx_mode_for_each_uc_addr(ha_addr, netdev, ni) { if (i =3D=3D rar_entries) break; - e1000_rar_set(hw, ha->addr, i++); + e1000_rar_set(hw, ha_addr, i++); } =20 - netdev_for_each_mc_addr(ha, netdev) { + netif_rx_mode_for_each_mc_addr(ha_addr, netdev, ni) { if (i =3D=3D rar_entries) { /* load any remaining addresses into the hash table */ u32 hash_reg, hash_bit, mta; - hash_value =3D e1000_hash_mc_addr(hw, ha->addr); + hash_value =3D e1000_hash_mc_addr(hw, ha_addr); hash_reg =3D (hash_value >> 5) & 0x7F; hash_bit =3D hash_value & 0x1F; mta =3D (1 << hash_bit); mcarray[hash_reg] |=3D mta; } else { - e1000_rar_set(hw, ha->addr, i++); + e1000_rar_set(hw, ha_addr, i++); } } =20 @@ -5092,7 +5115,10 @@ static int __e1000_shutdown(struct pci_dev *pdev, bo= ol *enable_wake) =20 if (wufc) { e1000_setup_rctl(adapter); - e1000_set_rx_mode(netdev); + + rtnl_lock(); + netif_set_rx_mode(netdev); + rtnl_unlock(); =20 rctl =3D er32(RCTL); =20 @@ -5150,11 +5176,13 @@ static int e1000_suspend(struct device *dev) { int retval; struct pci_dev *pdev =3D to_pci_dev(dev); + struct net_device *netdev =3D pci_get_drvdata(pdev); bool wake; =20 retval =3D __e1000_shutdown(pdev, &wake); device_set_wakeup_enable(dev, wake); =20 + netif_disable_async_ops(netdev); return retval; } =20 @@ -5166,6 +5194,8 @@ static int e1000_resume(struct device *dev) struct e1000_hw *hw =3D &adapter->hw; u32 err; =20 + netif_enable_async_ops(netdev); + if (adapter->need_ioport) err =3D pci_enable_device(pdev); else @@ -5195,8 +5225,11 @@ static int e1000_resume(struct device *dev) =20 e1000_init_manageability(adapter); =20 - if (netif_running(netdev)) + if (netif_running(netdev)) { + rtnl_lock(); e1000_up(adapter); + rtnl_unlock(); + } =20 netif_device_attach(netdev); =20 @@ -5205,6 +5238,7 @@ static int e1000_resume(struct device *dev) =20 static void e1000_shutdown(struct pci_dev *pdev) { + struct net_device *netdev =3D pci_get_drvdata(pdev); bool wake; =20 __e1000_shutdown(pdev, &wake); @@ -5213,6 +5247,8 @@ static void e1000_shutdown(struct pci_dev *pdev) pci_wake_from_d3(pdev, wake); pci_set_power_state(pdev, PCI_D3hot); } + + netif_disable_async_ops(netdev); } =20 #ifdef CONFIG_NET_POLL_CONTROLLER @@ -5312,11 +5348,16 @@ static void e1000_io_resume(struct pci_dev *pdev) { struct net_device *netdev =3D pci_get_drvdata(pdev); struct e1000_adapter *adapter =3D netdev_priv(netdev); + int rc; =20 e1000_init_manageability(adapter); =20 if (netif_running(netdev)) { - if (e1000_up(adapter)) { + rtnl_lock(); + rc =3D e1000_up(adapter); + rtnl_unlock(); + + if (rc) { pr_info("can't bring device back up after reset\n"); return; } --=20 2.47.3