--- zzzz-none-000/linux-5.15.111/net/openvswitch/datapath.h 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/net/openvswitch/datapath.h 2024-02-07 10:23:30.000000000 +0000 @@ -3,10 +3,21 @@ * Copyright (c) 2007-2014 Nicira, Inc. */ +/* + * Includes Inango Systems Ltd’s changes/modifications dated: 2021. + * Changed/modified portions - Copyright (c) 2021 , Inango Systems Ltd. + */ + +/* + Includes MaxLinear's changes dated: 2021, 2022, 2023 + Changed portions - Copyright 2021-2023 MaxLinear, Inc. +*/ + #ifndef DATAPATH_H #define DATAPATH_H 1 #include +#include #include #include #include @@ -15,6 +26,9 @@ #include #include "conntrack.h" +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +#include "dp_sysfs.h" +#endif #include "flow.h" #include "flow_table.h" #include "meter.h" @@ -50,6 +64,14 @@ struct u64_stats_sync syncp; }; +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +#ifdef OVS_DEBUG_LOG_ENABLE + #define OVS_LOG_DBG(format, ...) printk(KERN_INFO "OVS:%s:%d " format, __func__, __LINE__,##__VA_ARGS__ ) +#else + #define OVS_LOG_DBG(format, ...) +#endif +#endif + /** * struct dp_nlsk_pids - array of netlink portids of for a datapath. * This is used when OVS_DP_F_DISPATCH_UPCALL_PER_CPU @@ -69,6 +91,9 @@ * struct datapath - datapath for flow-based packet switching * @rcu: RCU callback head for deferred destruction. * @list_node: Element in global 'dps' list. +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT + * @ifobj: Represents /sys/class/net//brif. Protected by RTNL. +#endif * @table: flow table. * @ports: Hash table for ports. %OVSP_LOCAL port always exists. Protected by * ovs_mutex and RCU. @@ -85,6 +110,9 @@ struct rcu_head rcu; struct list_head list_node; +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT + struct kobject ifobj; +#endif /* Flow table. */ struct flow_table table; @@ -107,6 +135,20 @@ struct dp_nlsk_pids __rcu *upcall_portids; }; +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +/** + * struct br_pair_t used to save the bridge - interface pairs. + * @brname: bridge name + * @prname: port name + * @next: pointer for the next pair + */ + typedef struct br_pair_t { + char *brname; + char *prname; + struct br_pair_t* next; +} br_pair_t; +#endif + /** * struct ovs_skb_cb - OVS data in skb CB * @input_vport: The original vport packet came in on. This value is cached @@ -190,6 +232,11 @@ #define rcu_dereference_ovsl(p) \ rcu_dereference_check(p, lockdep_ovsl_is_held()) +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +/* Function to get the vport structure through its bridge name*/ +struct vport* get_vport_by_bridge(struct datapath *dp, const char *bridge); +#endif + static inline struct net *ovs_dp_get_net(const struct datapath *dp) { return read_pnet(&dp->net); @@ -255,6 +302,35 @@ DECLARE_STATIC_KEY_FALSE(tc_recirc_sharing_support); +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +extern int (*ovs_dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, void __user *data, int cmd);; +extern int (*ovs_dp_mac_addr_hook)(struct net_device *dev, void *p); +extern int (*ovs_dp_mtu_hook)(struct net_device *dev, int mtu); +extern int (*ovs_dp_add_del_port_hook)(struct net_device *br_dev, struct net_device *p_dev, int add); +extern int (*ovs_dp_br_changelink_hook)(struct vport *vport, struct nlattr *tb[], struct nlattr *data[]); +extern struct net_device *(*ovs_dp_br_get_netdev_hook)(void); +extern int (*ovs_dp_br_brc_add_bridge_netlink_hook)(struct net *net, struct net_device *dev); +extern void (*ovs_dp_br_brc_del_bridge_netlink_hook)(struct net *net, struct net_device *dev); +extern int (*ovs_dp_br_port_slave_changelink_hook)(struct vport *vport, struct net_device *br_dev, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *ack); +extern int (*ovs_dp_br_fill_info_hook)(struct vport *vport, struct sk_buff *skb, const struct net_device *br_dev); +extern int (*ovs_dp_br_fill_ifinfo_hook)(struct vport *vport, struct sk_buff *skb, const struct net_device *dev, u32 pid, u32 seq, int event, unsigned int flags); +extern int (*ovs_dp_br_port_fill_slave_info_hook)(struct vport *vport, struct sk_buff *skb, const struct net_device *br_dev, const struct net_device *dev); +extern int (*ovs_dp_br_setlink_hook)(struct vport *vport, struct net_device *dev, struct nlmsghdr *nlh, u16 flags); +extern int (*ovs_dp_br_bridge_setup)(struct vport *vport, int add); +extern int (*ovs_dp_br_bridge_port_setup)(struct vport *br_vport, struct vport *vport, int add); +extern struct rtnl_link_ops * (*ovs_dp_get_rtnl_link_ops_hook)(void); +extern int (*ovs_dp_sysfs_hook)(struct net_device *dev, unsigned long *ul_value, int cmd, int oper); +extern int (*ovs_dp_sysfs_string_hook)(struct net_device *dev, char *ustring, int cmd); +extern int (*ovs_get_fdb_entries)(struct net_device *dev, void *userbuf, unsigned long maxnum, unsigned long offset, bool is_user_buf); +extern void (*ovs_dp_dev_init)(struct vport *vport); +extern void (*ovs_dp_dev_open)(struct vport *vport); +extern void (*ovs_dp_dev_stop)(struct vport *vport); +extern int (*ovs_dp_dev_set_mtu_set_by_user)(struct net_device *dev, int is_set_by_user); +extern int (*ovs_dp_multicast_add_group)(struct vport *vport, struct br_ip *group, unsigned char *mac); +extern int (*ovs_dp_multicast_del_group)(struct vport *vport, struct br_ip *group, unsigned char *mac); +extern int (*brc_handle_event_hook)(struct net_device *dev, unsigned long event); +#endif + void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key); void ovs_dp_detach_port(struct vport *); int ovs_dp_upcall(struct datapath *, struct sk_buff *, @@ -268,13 +344,19 @@ u32 portid, u32 seq, u8 cmd); int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, - const struct sw_flow_actions *, struct sw_flow_key *); + const struct sw_flow_actions *, struct sw_flow *flow /*, struct sw_flow_key *, + const struct sw_flow_id *ufid*/); void ovs_dp_notify_wq(struct work_struct *work); int action_fifos_init(void); void action_fifos_exit(void); +#ifdef CONFIG_OPENVSWITCH_BRCOMPAT +uint32_t set_vport_flags(struct vport *vport, uint32_t flags); +uint32_t del_vport_flags(struct vport *vport, uint32_t flags); +#endif + /* 'KEY' must not have any bits set outside of the 'MASK' */ #define OVS_MASKED(OLD, KEY, MASK) ((KEY) | ((OLD) & ~(MASK))) #define OVS_SET_MASKED(OLD, KEY, MASK) ((OLD) = OVS_MASKED(OLD, KEY, MASK))