// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) Intel Corporation * Author: Shao Guohua */ #ifndef DATAPATH_SWDEV_H #define DATAPATH_SWDEV_H #include #include #include #include /*Switch related structures */ #include #define BRIDGE_ID_ENTRY_HASH_LENGTH 6 #define BR_ID_ENTRY_HASH_TABLE_SIZE BIT(BRIDGE_ID_ENTRY_HASH_LENGTH) #define ADD_BRENTRY BIT(0) #define DEL_BRENTRY BIT(1) #define BRIDGE_NO_ACTION BIT(2) #define LOGIC_DEV_REGISTER BIT(3) #define CPU_PORT_DISABLE BIT(4) #define DP_SWDEV_BRIDGE_ITEM 1 struct bridge_id_entry_item { struct net_device *dev; u16 fid; u32 flags; u32 bportid; /*Bridge port*/ u32 dp_port; /*DP port*/ u32 inst; u32 priv_flag; /* to store bp dev priv flags (like IFF_NO_QUEUE) */ struct switchdev_trans_item tritem; }; struct persist_bridge { struct list_head list; struct net_device *dev; struct list_head bp_list; /* The following values should be initialized with the desired * default state when calling dp_swdev_bridge_port_add_rcu() or * dp_swdev_bridge_add_rcu(). */ int avm_flood_ratelimit; }; #define DP_PORT_ISOLATED BIT(0) #define DP_PORT_HAIRPIN BIT(1) #define DP_PORT_MULTICAST_TO_UNICAST BIT(2) /* JZ-88765: Pretend hairpin is off for the Bridge. Together with * SW flooding this means we drop all hairpin packets and leave it to * the WLAN driver to implement hairpin flooding. This will be fixed * for MOVE21. */ #define DP_PORT_HAIRPIN_WLAN_WORKAROUND BIT(3) struct persist_bridge_port { struct list_head list; struct net_device *dev; /* The following values should be initialized with the desired * default state when calling dp_swdev_bridge_port_add_rcu(). */ u32 flags; }; struct br_info { struct hlist_node br_hlist; struct net_device *dev; /* bridge dev */ struct persist_bridge *persist; /* persistent bridge state */ u16 fid; u32 flag; u32 inst; u32 dp_port; struct list_head bp_list; bool br_vlan_en; /* VLAN Enabled for this bridge */ u32 num_vlan; /* Num of vlans supported in br */ u32 num_fid; /* Num of vlan aware fid in br */ struct list_head br_vlan_list; /* List pointing to the vlan entry */ struct rcu_head rcu_head; }; struct bridge_member_port { struct list_head list; u32 bportid; /* bridge port */ struct net_device *dev; /* bridge port dev for debug */ struct persist_bridge_port *persist; /* persistent bridge port state */ u32 dev_reg_flag; u16 bport[8]; u32 dev_priv_flag; /* to store bp dev priv flags (like IFF_NO_QUEUE) */ u32 dp_port; struct list_head bport_vlan_list; /* List pointing to the vlan entry */ }; struct vlist_entry { struct list_head list; struct vlan_entry *vlan_entry; /* Pointer to the VLAN Aware Entry */ }; struct vlan_entry { u16 fid; /* New FiD used for this bridge port */ u16 vlan_id; /* Vlan ID supported in this bridge port */ u32 ref_cnt; /* Reference count for this VLAN */ }; struct fdb_tbl { struct list_head fdb_list; struct net_device *port_dev; u8 addr[ETH_ALEN]; __be16 vid; }; extern struct list_head fdb_tbl_list; int dp_swdev_bridge_id_entry_init(void); struct br_info *dp_swdev_bridge_entry_lookup_rcu(struct net_device *dev); int dp_swdev_chk_bport_in_br(struct net_device *bp_dev, int bport, int inst); int dp_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags); int dp_ndo_bridge_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags); struct persist_bridge_port * dp_persist_bridge_port_add_rcu(struct net_device *br_dev, const struct persist_bridge *br_init, struct net_device *dev, const struct persist_bridge_port *port_init); int dp_persist_bridge_port_del_rcu(struct net_device *br_dev, struct net_device *dev); void dp_switchdev_exit(void); #endif /*DATAPATH_SWDEV_H*/