mlxsw: spectrum: Use per-FID struct for the VLAN-aware bridge
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlxsw / spectrum.h
index e2c022d..d6cf6de 100644 (file)
@@ -87,11 +87,11 @@ struct mlxsw_sp_upper {
        unsigned int ref_count;
 };
 
-struct mlxsw_sp_vfid {
+struct mlxsw_sp_fid {
        struct list_head list;
-       u16 nr_vports;
-       u16 vfid;       /* Starting at 0 */
-       struct net_device *br_dev;
+       unsigned int ref_count;
+       struct net_device *dev;
+       u16 fid;
        u16 vid;
 };
 
@@ -155,17 +155,17 @@ struct mlxsw_sp_sb {
 struct mlxsw_sp {
        struct {
                struct list_head list;
-               unsigned long mapped[BITS_TO_LONGS(MLXSW_SP_VFID_PORT_MAX)];
+               DECLARE_BITMAP(mapped, MLXSW_SP_VFID_PORT_MAX);
        } port_vfids;
        struct {
                struct list_head list;
-               unsigned long mapped[BITS_TO_LONGS(MLXSW_SP_VFID_BR_MAX)];
+               DECLARE_BITMAP(mapped, MLXSW_SP_VFID_BR_MAX);
        } br_vfids;
        struct {
                struct list_head list;
-               unsigned long mapped[BITS_TO_LONGS(MLXSW_SP_MID_MAX)];
+               DECLARE_BITMAP(mapped, MLXSW_SP_MID_MAX);
        } br_mids;
-       unsigned long active_fids[BITS_TO_LONGS(VLAN_N_VID)];
+       struct list_head fids;  /* VLAN-aware bridge FIDs */
        struct mlxsw_sp_port **ports;
        struct mlxsw_core *core;
        const struct mlxsw_bus_info *bus_info;
@@ -217,7 +217,7 @@ struct mlxsw_sp_port {
        u16 lag_id;
        struct {
                struct list_head list;
-               struct mlxsw_sp_vfid *vfid;
+               struct mlxsw_sp_fid *f;
                u16 vid;
        } vport;
        struct {
@@ -229,6 +229,11 @@ struct mlxsw_sp_port {
                struct ieee_maxrate *maxrate;
                struct ieee_pfc *pfc;
        } dcb;
+       struct {
+               u8 module;
+               u8 width;
+               u8 lane;
+       } mapping;
        /* 802.1Q bridge VLANs */
        unsigned long *active_vlans;
        unsigned long *untagged_vlans;
@@ -257,13 +262,13 @@ mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
 static inline bool
 mlxsw_sp_port_is_vport(const struct mlxsw_sp_port *mlxsw_sp_port)
 {
-       return mlxsw_sp_port->vport.vfid;
+       return mlxsw_sp_port->vport.f;
 }
 
 static inline struct net_device *
 mlxsw_sp_vport_br_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
 {
-       return mlxsw_sp_vport->vport.vfid->br_dev;
+       return mlxsw_sp_vport->vport.f->dev;
 }
 
 static inline u16
@@ -273,9 +278,9 @@ mlxsw_sp_vport_vid_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
 }
 
 static inline u16
-mlxsw_sp_vport_vfid_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
+mlxsw_sp_vport_fid_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
 {
-       return mlxsw_sp_vport->vport.vfid->vfid;
+       return mlxsw_sp_vport->vport.f->fid;
 }
 
 static inline struct mlxsw_sp_port *
@@ -293,14 +298,14 @@ mlxsw_sp_port_vport_find(const struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
 }
 
 static inline struct mlxsw_sp_port *
-mlxsw_sp_port_vport_find_by_vfid(const struct mlxsw_sp_port *mlxsw_sp_port,
-                                u16 vfid)
+mlxsw_sp_port_vport_find_by_fid(const struct mlxsw_sp_port *mlxsw_sp_port,
+                               u16 fid)
 {
        struct mlxsw_sp_port *mlxsw_sp_vport;
 
        list_for_each_entry(mlxsw_sp_vport, &mlxsw_sp_port->vports_list,
                            vport.list) {
-               if (mlxsw_sp_vport_vfid_get(mlxsw_sp_vport) == vfid)
+               if (mlxsw_sp_vport_fid_get(mlxsw_sp_vport) == fid)
                        return mlxsw_sp_vport;
        }
 
@@ -361,8 +366,8 @@ int mlxsw_sp_port_add_vid(struct net_device *dev, __be16 __always_unused proto,
                          u16 vid);
 int mlxsw_sp_port_kill_vid(struct net_device *dev,
                           __be16 __always_unused proto, u16 vid);
-int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 vfid,
-                            bool set, bool only_uc);
+int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 fid,
+                            bool set);
 void mlxsw_sp_port_active_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port);
 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,