--- zzzz-none-000/linux-5.15.111/net/bridge/br_private.h 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/net/bridge/br_private.h 2024-02-07 10:23:29.000000000 +0000 @@ -6,6 +6,11 @@ * Lennert Buytenhek */ +/* + Includes MaxLinear's changes dated: 2021, 2022, 2023. + Changed portions - Copyright 2021-2023 MaxLinear, Inc. +*/ + #ifndef _BR_PRIVATE_H #define _BR_PRIVATE_H @@ -15,9 +20,16 @@ #include #include #include +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +#include +#endif #include #include #include +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +#include "../openvswitch/datapath.h" +#include "../openvswitch/vport.h" +#endif #define BR_HASH_BITS 8 #define BR_HASH_SIZE (1 << BR_HASH_BITS) @@ -54,6 +66,11 @@ #define BR_FDB_NOTIFY_SETTABLE_BITS (FDB_NOTIFY_BIT | FDB_NOTIFY_INACTIVE_BIT) +#ifdef CONFIG_TI_PACKET_PROCESSOR +#define TI_PP_FDB_INACTIVE 0x0 +#define TI_PP_FDB_ACTIVE 0x1 +#endif /* CONFIG_TI_PACKET_PROCESSOR */ + typedef struct bridge_id bridge_id; typedef struct mac_addr mac_addr; typedef __u16 port_id; @@ -267,7 +284,10 @@ /* write-heavy members should not affect lookups */ unsigned long updated ____cacheline_aligned_in_smp; unsigned long used; - +#ifdef CONFIG_TI_PACKET_PROCESSOR + int ti_pp_session_handle; + int ti_pp_fdb_status; +#endif /* CONFIG_TI_PACKET_PROCESSOR */ struct rcu_head rcu; }; @@ -342,6 +362,65 @@ struct net_bridge_mcast_gc mcast_gc; struct rcu_head rcu; }; +#ifdef CONFIG_LTQ_MCAST_SNOOPING + +typedef enum { + IPV4 = 0, + IPV6, +} ptype_t; + +struct ipaddr { + ptype_t type; + union { + struct in_addr ip4; + struct in6_addr ip6; + } addr; +}; + +typedef struct ipaddr ipaddr_t; + +enum igmp_ver { + IGMPV1 = 1, + IGMPV2, + IGMPV3, +}; + +enum mld_ver { + MLDV1 = 1, + MLDV2, +}; + +/* Set router port ioctl request */ +struct router_port { + ptype_t type; + u32 if_index; /* interface index */ + u32 expires; /* expiry time */ +}; + +/* Multicast group record ioctl request */ +struct br_grp_rec { + u32 if_index; /* interface index */ + ipaddr_t gaddr; /* Group address */ + u32 filter_mode; /* Filter mode */ + u32 compat; /* Compatibility mode */ + u32 nsrc; /* number of sources */ + ipaddr_t slist[0]; /* source list */ +}; + +struct net_bridge_mg_entry +{ + struct hlist_node hlist; + ipaddr_t gaddr; /* Group ipaddr */ + u8 filter_mode; /* 0 = EX, 1 = IN */ + u8 compat_mode; /* 1 = v1, 2 = v2, 3 = v3 */ + struct net_bridge_port *port; + struct rcu_head rcu; + u32 saddr_cnt; + ipaddr_t saddr[0]; /* Array of src ipaddr */ +}; + +#endif /* CONFIG_LTQ_MCAST_SNOOPING */ + struct net_bridge_port { struct net_bridge *br; @@ -376,6 +455,17 @@ struct net_bridge_mcast_port multicast_ctx; +#ifdef CONFIG_LTQ_MCAST_SNOOPING + u32 mghash_secret; + u32 mghash_secret6; + spinlock_t mghash_lock; + struct hlist_head mghash[BR_HASH_SIZE]; + u8 igmp_router_port; + struct timer_list igmp_router_timer; + u8 mld_router_port; + struct timer_list mld_router_timer; +#endif /* CONFIG_LTQ_MCAST_SNOOPING */ + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING struct bridge_mcast_stats __percpu *mcast_stats; @@ -412,7 +502,14 @@ static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev) { +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT + if (netif_is_ovs_port(dev)) + return ovs_port_get_rcu ? ovs_port_get_rcu(dev) : NULL; + return netif_is_bridge_port(dev) ? + rcu_dereference(dev->rx_handler_data) : NULL; +#else return rcu_dereference(dev->rx_handler_data); +#endif } static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev) @@ -446,6 +543,16 @@ BROPT_MCAST_VLAN_SNOOPING_ENABLED, }; +#ifdef CONFIG_TI_L2_SELECTIVE_PACKET_HANDLING +struct l2_sph +{ + int (*packet_handler)(struct sk_buff *skb); + int priority; + struct l2_sph *prev; + struct l2_sph *next; +}; +#endif /* CONFIG_TI_L2_SELECTIVE_PACKET_HANDLING */ + struct net_bridge { spinlock_t lock; spinlock_t hash_lock; @@ -466,6 +573,20 @@ struct rtable fake_rtable; struct rt6_info fake_rt6_info; }; + /* These non-standard parameters allow disabling the bridge-netfilter hooks + even if those hooks are enabled globally. This is to support special bridge + configurations which NEED to bypass the bridge-netfilter hooks, for example + to avoid fragmented packets being reassembled and re-fragmented, and to + avoid negative performance impact from unecessarily calling those hooks */ + bool nf_disable_iptables; + bool nf_disable_ip6tables; + bool nf_disable_arptables; +#endif +#ifdef CONFIG_AVM_BRIDGE_FLOOD_RATELIMITER + atomic_t avm_flood_credits; + int avm_flood_credits_max; + int avm_flood_credits_recov_rate; + struct timer_list avm_flood_rl_timer; #endif u16 group_fwd_mask; u16 group_fwd_mask_required; @@ -535,6 +656,15 @@ #if IS_ENABLED(CONFIG_BRIDGE_CFM) struct hlist_head mep_list; #endif +#ifdef CONFIG_TI_L2_SELECTIVE_PACKET_HANDLING + struct l2_sph *selective_packet_handler; +#endif /* CONFIG_TI_L2_SELECTIVE_PACKET_HANDLING */ +#ifdef CONFIG_INTEL_L2VPN_L2CP_FORWARD + int (*l2vpn_packet_handler)(struct sk_buff *skb, int *l2vpnRelate); +#endif +#ifdef CONFIG_LTQ_MCAST_SNOOPING + bool this_br_snooping_enabled; +#endif /* CONFIG_LTQ_MCAST_SNOOPING */ }; struct br_input_skb_cb { @@ -912,6 +1042,22 @@ br_mdb_ip_get(struct net_bridge *br, struct br_ip *dst); struct net_bridge_mdb_entry * br_multicast_new_group(struct net_bridge *br, struct br_ip *group); + +int br_multicast_add_group(struct net_bridge_mcast *brmctx, + struct net_bridge_mcast_port *pmctx, + struct br_ip *group, + const unsigned char *src, + u8 filter_mode, + bool igmpv2_mldv1); +void br_multicast_leave_group(struct net_bridge_mcast *brmctx, + struct net_bridge_mcast_port *pmctx, + struct br_ip *group, + struct bridge_mcast_other_query *other_query, + struct bridge_mcast_own_query *own_query, + const unsigned char *src); + + +void br_multicast_free_pg(struct rcu_head *head); struct net_bridge_port_group * br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group, struct net_bridge_port_group __rcu *next, @@ -1798,6 +1944,21 @@ #define br_netfilter_rtable_init(x) #endif +/* br_bcast_rl.c */ +#ifdef CONFIG_AVM_BRIDGE_FLOOD_RATELIMITER +int br_flood_rl_init(void); +void br_flood_rl_fini(void); +void br_flood_rl_setup(struct net_bridge *br); +int br_flood_rl_set_credits(struct net_bridge *br, unsigned long v, + struct netlink_ext_ack *extack); +unsigned int br_flood_rl(struct net_bridge *br, struct sk_buff *skb, struct net_device *src_dev); +#else +#define br_flood_rl_init() (0) +#define br_flood_rl_fini() do { } while (0) +#define br_flood_rl_setup(br) do { } while (0) +#define br_flood_rl(br, skb, dev) (1) +#endif + /* br_stp.c */ void br_set_state(struct net_bridge_port *p, unsigned int state); struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no); @@ -1948,6 +2109,20 @@ bool *changed, struct netlink_ext_ack *extack); +#ifdef CONFIG_LTQ_MCAST_SNOOPING +/* br_mcast_snooping.c */ +void br_mcast_port_init(struct net_bridge_port *port); +void br_mcast_port_cleanup(struct net_bridge_port *port); +int br_mg_del_record(struct net_bridge_port *port, ipaddr_t *gaddr); +int br_mg_add_entry(struct net_bridge_port *port, ipaddr_t *gaddr, u8 filter, u8 compat, u32 saddr_cnt, ipaddr_t *saddr); +int br_selective_flood(struct net_bridge_port *p, struct sk_buff *skb); + +extern int bridge_igmp_snooping; +extern int bridge_mld_snooping; +void br_mcast_snoop_init(void); +void br_mcast_snoop_deinit(void); +#endif + #ifdef CONFIG_SYSFS /* br_sysfs_if.c */ extern const struct sysfs_ops brport_sysfs_ops;