mlxsw: Configure egress VID for unicast FDB entries
authorAmit Cohen <amcohen@nvidia.com>
Mon, 4 Jul 2022 06:11:27 +0000 (09:11 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Jul 2022 08:56:57 +0000 (09:56 +0100)
Using unified bridge model, firmware no longer configures the egress VID
"under the hood" and moves this responsibility to software.

For layer 2, this means that software needs to determine the egress VID
for both unicast (i.e., FDB) and multicast (i.e., MDB and flooding) flows.

Unicast FDB records and unicast LAG FDB records have new fields - "set_vid"
and "vid", set them. For records which point to router port, do not set
these fields.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/reg.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

index 022b216..b0b5806 100644 (file)
@@ -380,7 +380,7 @@ static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
 
 static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
                                         enum mlxsw_reg_sfd_rec_policy policy,
-                                        const char *mac, u16 fid_vid,
+                                        const char *mac, u16 fid_vid, u16 vid,
                                         enum mlxsw_reg_sfd_rec_action action,
                                         u16 local_port)
 {
@@ -389,6 +389,8 @@ static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
        mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
        mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
        mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
+       mlxsw_reg_sfd_uc_set_vid_set(payload, rec_index, vid ? true : false);
+       mlxsw_reg_sfd_uc_vid_set(payload, rec_index, vid);
        mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
 }
 
@@ -454,6 +456,7 @@ mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
        mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
        mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
        mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
+       mlxsw_reg_sfd_uc_lag_set_vid_set(payload, rec_index, true);
        mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
        mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
 }
index 7cabe6e..fd8f9be 100644 (file)
@@ -1681,7 +1681,8 @@ static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp,
 }
 
 static int __mlxsw_sp_port_fdb_uc_op(struct mlxsw_sp *mlxsw_sp, u16 local_port,
-                                    const char *mac, u16 fid, bool adding,
+                                    const char *mac, u16 fid, u16 vid,
+                                    bool adding,
                                     enum mlxsw_reg_sfd_rec_action action,
                                     enum mlxsw_reg_sfd_rec_policy policy)
 {
@@ -1694,7 +1695,8 @@ static int __mlxsw_sp_port_fdb_uc_op(struct mlxsw_sp *mlxsw_sp, u16 local_port,
                return -ENOMEM;
 
        mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0);
-       mlxsw_reg_sfd_uc_pack(sfd_pl, 0, policy, mac, fid, action, local_port);
+       mlxsw_reg_sfd_uc_pack(sfd_pl, 0, policy, mac, fid, vid, action,
+                             local_port);
        num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl);
        err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl);
        if (err)
@@ -1709,18 +1711,18 @@ out:
 }
 
 static int mlxsw_sp_port_fdb_uc_op(struct mlxsw_sp *mlxsw_sp, u16 local_port,
-                                  const char *mac, u16 fid, bool adding,
-                                  bool dynamic)
+                                  const char *mac, u16 fid, u16 vid,
+                                  bool adding, bool dynamic)
 {
-       return __mlxsw_sp_port_fdb_uc_op(mlxsw_sp, local_port, mac, fid, adding,
-                                        MLXSW_REG_SFD_REC_ACTION_NOP,
+       return __mlxsw_sp_port_fdb_uc_op(mlxsw_sp, local_port, mac, fid, vid,
+                                        adding, MLXSW_REG_SFD_REC_ACTION_NOP,
                                         mlxsw_sp_sfd_rec_policy(dynamic));
 }
 
 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
                        bool adding)
 {
-       return __mlxsw_sp_port_fdb_uc_op(mlxsw_sp, 0, mac, fid, adding,
+       return __mlxsw_sp_port_fdb_uc_op(mlxsw_sp, 0, mac, fid, 0, adding,
                                         MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER,
                                         MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY);
 }
@@ -1782,7 +1784,7 @@ mlxsw_sp_port_fdb_set(struct mlxsw_sp_port *mlxsw_sp_port,
        if (!bridge_port->lagged)
                return mlxsw_sp_port_fdb_uc_op(mlxsw_sp,
                                               bridge_port->system_port,
-                                              fdb_info->addr, fid_index,
+                                              fdb_info->addr, fid_index, vid,
                                               adding, false);
        else
                return mlxsw_sp_port_fdb_uc_lag_op(mlxsw_sp,
@@ -2906,10 +2908,9 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
        struct mlxsw_sp_bridge_device *bridge_device;
        struct mlxsw_sp_bridge_port *bridge_port;
        struct mlxsw_sp_port *mlxsw_sp_port;
+       u16 local_port, vid, fid, evid = 0;
        enum switchdev_notifier_type type;
        char mac[ETH_ALEN];
-       u16 local_port;
-       u16 vid, fid;
        bool do_notification = true;
        int err;
 
@@ -2940,9 +2941,10 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
 
        bridge_device = bridge_port->bridge_device;
        vid = bridge_device->vlan_enabled ? mlxsw_sp_port_vlan->vid : 0;
+       evid = mlxsw_sp_port_vlan->vid;
 
 do_fdb_op:
-       err = mlxsw_sp_port_fdb_uc_op(mlxsw_sp, local_port, mac, fid,
+       err = mlxsw_sp_port_fdb_uc_op(mlxsw_sp, local_port, mac, fid, evid,
                                      adding, true);
        if (err) {
                dev_err_ratelimited(mlxsw_sp->bus_info->dev, "Failed to set FDB entry\n");