]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fbnic: Move promisc_sync out of netdev code and into RPC path
authorAlexander Duyck <alexanderduyck@fb.com>
Tue, 26 Aug 2025 19:44:47 +0000 (12:44 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 28 Aug 2025 12:51:07 +0000 (14:51 +0200)
In order for us to support the BMC possibly connecting, disconnecting, and
then reconnecting we need to be able to support entities outside of just
the NIC setting up promiscuous mode as the BMC can use a multicast
promiscuous setup.

To support that we should move the promisc_sync code out of the netdev and
into the RPC section of the driver so that it is reachable from more paths.

Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/175623748769.2246365.2130394904175851458.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
drivers/net/ethernet/meta/fbnic/fbnic_rpc.c
drivers/net/ethernet/meta/fbnic/fbnic_rpc.h

index 98602bc3b39fde60973d8d81a3c28a019ea2e864..24c256ac03302cdd7c9a7547b6f96334d5ef2798 100644 (file)
@@ -220,49 +220,8 @@ void __fbnic_set_rx_mode(struct net_device *netdev)
        uc_promisc |= !!(netdev->flags & IFF_PROMISC);
        mc_promisc |= !!(netdev->flags & IFF_ALLMULTI) || uc_promisc;
 
-       /* Populate last TCAM entry with promiscuous entry and 0/1 bit mask */
-       mac_addr = &fbd->mac_addr[FBNIC_RPC_TCAM_MACDA_PROMISC_IDX];
-       if (uc_promisc) {
-               if (!is_zero_ether_addr(mac_addr->value.addr8) ||
-                   mac_addr->state != FBNIC_TCAM_S_VALID) {
-                       eth_zero_addr(mac_addr->value.addr8);
-                       eth_broadcast_addr(mac_addr->mask.addr8);
-                       clear_bit(FBNIC_MAC_ADDR_T_ALLMULTI,
-                                 mac_addr->act_tcam);
-                       set_bit(FBNIC_MAC_ADDR_T_PROMISC,
-                               mac_addr->act_tcam);
-                       mac_addr->state = FBNIC_TCAM_S_ADD;
-               }
-       } else if (mc_promisc &&
-                  (!fbnic_bmc_present(fbd) || !fbd->fw_cap.all_multi)) {
-               /* We have to add a special handler for multicast as the
-                * BMC may have an all-multi rule already in place. As such
-                * adding a rule ourselves won't do any good so we will have
-                * to modify the rules for the ALL MULTI below if the BMC
-                * already has the rule in place.
-                */
-               if (!is_multicast_ether_addr(mac_addr->value.addr8) ||
-                   mac_addr->state != FBNIC_TCAM_S_VALID) {
-                       eth_zero_addr(mac_addr->value.addr8);
-                       eth_broadcast_addr(mac_addr->mask.addr8);
-                       mac_addr->value.addr8[0] ^= 1;
-                       mac_addr->mask.addr8[0] ^= 1;
-                       set_bit(FBNIC_MAC_ADDR_T_ALLMULTI,
-                               mac_addr->act_tcam);
-                       clear_bit(FBNIC_MAC_ADDR_T_PROMISC,
-                                 mac_addr->act_tcam);
-                       mac_addr->state = FBNIC_TCAM_S_ADD;
-               }
-       } else if (mac_addr->state == FBNIC_TCAM_S_VALID) {
-               if (test_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam)) {
-                       clear_bit(FBNIC_MAC_ADDR_T_ALLMULTI,
-                                 mac_addr->act_tcam);
-                       clear_bit(FBNIC_MAC_ADDR_T_PROMISC,
-                                 mac_addr->act_tcam);
-               } else {
-                       mac_addr->state = FBNIC_TCAM_S_DELETE;
-               }
-       }
+       /* Update the promiscuous rules */
+       fbnic_promisc_sync(fbd, uc_promisc, mc_promisc);
 
        /* Add rules for BMC all multicast if it is enabled */
        fbnic_bmc_rpc_all_multi_config(fbd, mc_promisc);
index a4dc1024c0c2d50ba43e535b06542aeb87c9879d..d5badaced6c3a62ea469014dc89e0ba47a96b587 100644 (file)
@@ -454,6 +454,50 @@ int __fbnic_xc_unsync(struct fbnic_mac_addr *mac_addr, unsigned int tcam_idx)
        return 0;
 }
 
+void fbnic_promisc_sync(struct fbnic_dev *fbd,
+                       bool uc_promisc, bool mc_promisc)
+{
+       struct fbnic_mac_addr *mac_addr;
+
+       /* Populate last TCAM entry with promiscuous entry and 0/1 bit mask */
+       mac_addr = &fbd->mac_addr[FBNIC_RPC_TCAM_MACDA_PROMISC_IDX];
+       if (uc_promisc) {
+               if (!is_zero_ether_addr(mac_addr->value.addr8) ||
+                   mac_addr->state != FBNIC_TCAM_S_VALID) {
+                       eth_zero_addr(mac_addr->value.addr8);
+                       eth_broadcast_addr(mac_addr->mask.addr8);
+                       clear_bit(FBNIC_MAC_ADDR_T_ALLMULTI,
+                                 mac_addr->act_tcam);
+                       set_bit(FBNIC_MAC_ADDR_T_PROMISC,
+                               mac_addr->act_tcam);
+                       mac_addr->state = FBNIC_TCAM_S_ADD;
+               }
+       } else if (mc_promisc &&
+                  (!fbnic_bmc_present(fbd) || !fbd->fw_cap.all_multi)) {
+               /* We have to add a special handler for multicast as the
+                * BMC may have an all-multi rule already in place. As such
+                * adding a rule ourselves won't do any good so we will have
+                * to modify the rules for the ALL MULTI below if the BMC
+                * already has the rule in place.
+                */
+               if (!is_multicast_ether_addr(mac_addr->value.addr8) ||
+                   mac_addr->state != FBNIC_TCAM_S_VALID) {
+                       eth_zero_addr(mac_addr->value.addr8);
+                       eth_broadcast_addr(mac_addr->mask.addr8);
+                       mac_addr->value.addr8[0] ^= 1;
+                       mac_addr->mask.addr8[0] ^= 1;
+                       set_bit(FBNIC_MAC_ADDR_T_ALLMULTI,
+                               mac_addr->act_tcam);
+                       clear_bit(FBNIC_MAC_ADDR_T_PROMISC,
+                                 mac_addr->act_tcam);
+                       mac_addr->state = FBNIC_TCAM_S_ADD;
+               }
+       } else if (mac_addr->state == FBNIC_TCAM_S_VALID) {
+               __fbnic_xc_unsync(mac_addr, FBNIC_MAC_ADDR_T_ALLMULTI);
+               __fbnic_xc_unsync(mac_addr, FBNIC_MAC_ADDR_T_PROMISC);
+       }
+}
+
 void fbnic_sift_macda(struct fbnic_dev *fbd)
 {
        int dest, src;
index 6892414195c3e6dddcd3a27385d444e8760fb075..d9db7781a49b5104ffde6edadb17fe2570ead2ae 100644 (file)
@@ -201,6 +201,9 @@ struct fbnic_mac_addr *__fbnic_mc_sync(struct fbnic_dev *fbd,
 void fbnic_sift_macda(struct fbnic_dev *fbd);
 void fbnic_write_macda(struct fbnic_dev *fbd);
 
+void fbnic_promisc_sync(struct fbnic_dev *fbd,
+                       bool uc_promisc, bool mc_promisc);
+
 struct fbnic_ip_addr *__fbnic_ip4_sync(struct fbnic_dev *fbd,
                                       struct fbnic_ip_addr *ip_addr,
                                       const struct in_addr *addr,