#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/hashtable.h>
#include <linux/crc32.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/if_vlan.h>
#include <linux/if_bridge.h>
#include <net/neighbour.h>
#include <net/switchdev.h>
#include <net/ip_fib.h>
#include <net/nexthop.h>
#include <net/arp.h>
#include "rocker.h"
#include "rocker_tlv.h"
struct ofdpa_flow_tbl_key { … };
struct ofdpa_flow_tbl_entry { … };
struct ofdpa_group_tbl_entry { … };
struct ofdpa_fdb_tbl_entry { … };
struct ofdpa_internal_vlan_tbl_entry { … };
struct ofdpa_neigh_tbl_entry { … };
enum { … };
#define OFDPA_INTERNAL_VLAN_ID_BASE …
#define OFDPA_N_INTERNAL_VLANS …
#define OFDPA_VLAN_BITMAP_LEN …
#define OFDPA_INTERNAL_VLAN_BITMAP_LEN …
#define OFDPA_UNTAGGED_VID …
struct ofdpa { … };
struct ofdpa_port { … };
static const u8 zero_mac[ETH_ALEN] = …;
static const u8 ff_mac[ETH_ALEN] = …;
static const u8 ll_mac[ETH_ALEN] = …;
static const u8 ll_mask[ETH_ALEN] = …;
static const u8 mcast_mac[ETH_ALEN] = …;
static const u8 ipv4_mcast[ETH_ALEN] = …;
static const u8 ipv4_mask[ETH_ALEN] = …;
static const u8 ipv6_mcast[ETH_ALEN] = …;
static const u8 ipv6_mask[ETH_ALEN] = …;
enum { … };
static bool ofdpa_vlan_id_is_internal(__be16 vlan_id)
{ … }
static __be16 ofdpa_port_vid_to_vlan(const struct ofdpa_port *ofdpa_port,
u16 vid, bool *pop_vlan)
{ … }
static u16 ofdpa_port_vlan_to_vid(const struct ofdpa_port *ofdpa_port,
__be16 vlan_id)
{ … }
static bool ofdpa_port_is_slave(const struct ofdpa_port *ofdpa_port,
const char *kind)
{ … }
static bool ofdpa_port_is_bridged(const struct ofdpa_port *ofdpa_port)
{ … }
static bool ofdpa_port_is_ovsed(const struct ofdpa_port *ofdpa_port)
{ … }
#define OFDPA_OP_FLAG_REMOVE …
#define OFDPA_OP_FLAG_NOWAIT …
#define OFDPA_OP_FLAG_LEARNED …
#define OFDPA_OP_FLAG_REFRESH …
static bool ofdpa_flags_nowait(int flags)
{ … }
static int
ofdpa_cmd_flow_tbl_add_ig_port(struct rocker_desc_info *desc_info,
const struct ofdpa_flow_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_flow_tbl_add_vlan(struct rocker_desc_info *desc_info,
const struct ofdpa_flow_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_flow_tbl_add_term_mac(struct rocker_desc_info *desc_info,
const struct ofdpa_flow_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_flow_tbl_add_ucast_routing(struct rocker_desc_info *desc_info,
const struct ofdpa_flow_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_flow_tbl_add_bridge(struct rocker_desc_info *desc_info,
const struct ofdpa_flow_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_flow_tbl_add_acl(struct rocker_desc_info *desc_info,
const struct ofdpa_flow_tbl_entry *entry)
{ … }
static int ofdpa_cmd_flow_tbl_add(const struct rocker_port *rocker_port,
struct rocker_desc_info *desc_info,
void *priv)
{ … }
static int ofdpa_cmd_flow_tbl_del(const struct rocker_port *rocker_port,
struct rocker_desc_info *desc_info,
void *priv)
{ … }
static int
ofdpa_cmd_group_tbl_add_l2_interface(struct rocker_desc_info *desc_info,
struct ofdpa_group_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_group_tbl_add_l2_rewrite(struct rocker_desc_info *desc_info,
const struct ofdpa_group_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_group_tbl_add_group_ids(struct rocker_desc_info *desc_info,
const struct ofdpa_group_tbl_entry *entry)
{ … }
static int
ofdpa_cmd_group_tbl_add_l3_unicast(struct rocker_desc_info *desc_info,
const struct ofdpa_group_tbl_entry *entry)
{ … }
static int ofdpa_cmd_group_tbl_add(const struct rocker_port *rocker_port,
struct rocker_desc_info *desc_info,
void *priv)
{ … }
static int ofdpa_cmd_group_tbl_del(const struct rocker_port *rocker_port,
struct rocker_desc_info *desc_info,
void *priv)
{ … }
static struct ofdpa_flow_tbl_entry *
ofdpa_flow_tbl_find(const struct ofdpa *ofdpa,
const struct ofdpa_flow_tbl_entry *match)
{ … }
static int ofdpa_flow_tbl_add(struct ofdpa_port *ofdpa_port,
int flags, struct ofdpa_flow_tbl_entry *match)
{ … }
static int ofdpa_flow_tbl_del(struct ofdpa_port *ofdpa_port,
int flags, struct ofdpa_flow_tbl_entry *match)
{ … }
static int ofdpa_flow_tbl_do(struct ofdpa_port *ofdpa_port, int flags,
struct ofdpa_flow_tbl_entry *entry)
{ … }
static int ofdpa_flow_tbl_ig_port(struct ofdpa_port *ofdpa_port, int flags,
u32 in_pport, u32 in_pport_mask,
enum rocker_of_dpa_table_id goto_tbl)
{ … }
static int ofdpa_flow_tbl_vlan(struct ofdpa_port *ofdpa_port,
int flags,
u32 in_pport, __be16 vlan_id,
__be16 vlan_id_mask,
enum rocker_of_dpa_table_id goto_tbl,
bool untagged, __be16 new_vlan_id)
{ … }
static int ofdpa_flow_tbl_term_mac(struct ofdpa_port *ofdpa_port,
u32 in_pport, u32 in_pport_mask,
__be16 eth_type, const u8 *eth_dst,
const u8 *eth_dst_mask, __be16 vlan_id,
__be16 vlan_id_mask, bool copy_to_cpu,
int flags)
{ … }
static int ofdpa_flow_tbl_bridge(struct ofdpa_port *ofdpa_port,
int flags, const u8 *eth_dst,
const u8 *eth_dst_mask, __be16 vlan_id,
u32 tunnel_id,
enum rocker_of_dpa_table_id goto_tbl,
u32 group_id, bool copy_to_cpu)
{ … }
static int ofdpa_flow_tbl_ucast4_routing(struct ofdpa_port *ofdpa_port,
__be16 eth_type, __be32 dst,
__be32 dst_mask, u32 priority,
enum rocker_of_dpa_table_id goto_tbl,
u32 group_id, struct fib_info *fi,
int flags)
{ … }
static int ofdpa_flow_tbl_acl(struct ofdpa_port *ofdpa_port, int flags,
u32 in_pport, u32 in_pport_mask,
const u8 *eth_src, const u8 *eth_src_mask,
const u8 *eth_dst, const u8 *eth_dst_mask,
__be16 eth_type, __be16 vlan_id,
__be16 vlan_id_mask, u8 ip_proto,
u8 ip_proto_mask, u8 ip_tos, u8 ip_tos_mask,
u32 group_id)
{ … }
static struct ofdpa_group_tbl_entry *
ofdpa_group_tbl_find(const struct ofdpa *ofdpa,
const struct ofdpa_group_tbl_entry *match)
{ … }
static void ofdpa_group_tbl_entry_free(struct ofdpa_group_tbl_entry *entry)
{ … }
static int ofdpa_group_tbl_add(struct ofdpa_port *ofdpa_port, int flags,
struct ofdpa_group_tbl_entry *match)
{ … }
static int ofdpa_group_tbl_del(struct ofdpa_port *ofdpa_port, int flags,
struct ofdpa_group_tbl_entry *match)
{ … }
static int ofdpa_group_tbl_do(struct ofdpa_port *ofdpa_port, int flags,
struct ofdpa_group_tbl_entry *entry)
{ … }
static int ofdpa_group_l2_interface(struct ofdpa_port *ofdpa_port,
int flags, __be16 vlan_id,
u32 out_pport, int pop_vlan)
{ … }
static int ofdpa_group_l2_fan_out(struct ofdpa_port *ofdpa_port,
int flags, u8 group_count,
const u32 *group_ids, u32 group_id)
{ … }
static int ofdpa_group_l2_flood(struct ofdpa_port *ofdpa_port,
int flags, __be16 vlan_id,
u8 group_count, const u32 *group_ids,
u32 group_id)
{ … }
static int ofdpa_group_l3_unicast(struct ofdpa_port *ofdpa_port, int flags,
u32 index, const u8 *src_mac, const u8 *dst_mac,
__be16 vlan_id, bool ttl_check, u32 pport)
{ … }
static struct ofdpa_neigh_tbl_entry *
ofdpa_neigh_tbl_find(const struct ofdpa *ofdpa, __be32 ip_addr)
{ … }
static void ofdpa_neigh_add(struct ofdpa *ofdpa,
struct ofdpa_neigh_tbl_entry *entry)
{ … }
static void ofdpa_neigh_del(struct ofdpa_neigh_tbl_entry *entry)
{ … }
static void ofdpa_neigh_update(struct ofdpa_neigh_tbl_entry *entry,
const u8 *eth_dst, bool ttl_check)
{ … }
static int ofdpa_port_ipv4_neigh(struct ofdpa_port *ofdpa_port,
int flags, __be32 ip_addr, const u8 *eth_dst)
{ … }
static int ofdpa_port_ipv4_resolve(struct ofdpa_port *ofdpa_port,
__be32 ip_addr)
{ … }
static int ofdpa_port_ipv4_nh(struct ofdpa_port *ofdpa_port,
int flags, __be32 ip_addr, u32 *index)
{ … }
static struct ofdpa_port *ofdpa_port_get(const struct ofdpa *ofdpa,
int port_index)
{ … }
static int ofdpa_port_vlan_flood_group(struct ofdpa_port *ofdpa_port,
int flags, __be16 vlan_id)
{ … }
static int ofdpa_port_vlan_l2_groups(struct ofdpa_port *ofdpa_port, int flags,
__be16 vlan_id, bool pop_vlan)
{ … }
static struct ofdpa_ctrl { … } ofdpa_ctrls[] = …;
static int ofdpa_port_ctrl_vlan_acl(struct ofdpa_port *ofdpa_port, int flags,
const struct ofdpa_ctrl *ctrl, __be16 vlan_id)
{ … }
static int ofdpa_port_ctrl_vlan_bridge(struct ofdpa_port *ofdpa_port,
int flags, const struct ofdpa_ctrl *ctrl,
__be16 vlan_id)
{ … }
static int ofdpa_port_ctrl_vlan_term(struct ofdpa_port *ofdpa_port, int flags,
const struct ofdpa_ctrl *ctrl, __be16 vlan_id)
{ … }
static int ofdpa_port_ctrl_vlan(struct ofdpa_port *ofdpa_port, int flags,
const struct ofdpa_ctrl *ctrl, __be16 vlan_id)
{ … }
static int ofdpa_port_ctrl_vlan_add(struct ofdpa_port *ofdpa_port, int flags,
__be16 vlan_id)
{ … }
static int ofdpa_port_ctrl(struct ofdpa_port *ofdpa_port, int flags,
const struct ofdpa_ctrl *ctrl)
{ … }
static int ofdpa_port_vlan(struct ofdpa_port *ofdpa_port, int flags,
u16 vid)
{ … }
static int ofdpa_port_ig_tbl(struct ofdpa_port *ofdpa_port, int flags)
{ … }
struct ofdpa_fdb_learn_work { … };
static void ofdpa_port_fdb_learn_work(struct work_struct *work)
{ … }
static int ofdpa_port_fdb_learn(struct ofdpa_port *ofdpa_port,
int flags, const u8 *addr, __be16 vlan_id)
{ … }
static struct ofdpa_fdb_tbl_entry *
ofdpa_fdb_tbl_find(const struct ofdpa *ofdpa,
const struct ofdpa_fdb_tbl_entry *match)
{ … }
static int ofdpa_port_fdb(struct ofdpa_port *ofdpa_port,
const unsigned char *addr,
__be16 vlan_id, int flags)
{ … }
static int ofdpa_port_fdb_flush(struct ofdpa_port *ofdpa_port, int flags)
{ … }
static void ofdpa_fdb_cleanup(struct timer_list *t)
{ … }
static int ofdpa_port_router_mac(struct ofdpa_port *ofdpa_port,
int flags, __be16 vlan_id)
{ … }
static int ofdpa_port_fwding(struct ofdpa_port *ofdpa_port, int flags)
{ … }
static int ofdpa_port_stp_update(struct ofdpa_port *ofdpa_port,
int flags, u8 state)
{ … }
static int ofdpa_port_fwd_enable(struct ofdpa_port *ofdpa_port, int flags)
{ … }
static int ofdpa_port_fwd_disable(struct ofdpa_port *ofdpa_port, int flags)
{ … }
static int ofdpa_port_vlan_add(struct ofdpa_port *ofdpa_port,
u16 vid, u16 flags)
{ … }
static int ofdpa_port_vlan_del(struct ofdpa_port *ofdpa_port,
u16 vid, u16 flags)
{ … }
static struct ofdpa_internal_vlan_tbl_entry *
ofdpa_internal_vlan_tbl_find(const struct ofdpa *ofdpa, int ifindex)
{ … }
static __be16 ofdpa_port_internal_vlan_id_get(struct ofdpa_port *ofdpa_port,
int ifindex)
{ … }
static int ofdpa_port_fib_ipv4(struct ofdpa_port *ofdpa_port, __be32 dst,
int dst_len, struct fib_info *fi, u32 tb_id,
int flags)
{ … }
static void
ofdpa_port_internal_vlan_id_put(const struct ofdpa_port *ofdpa_port,
int ifindex)
{ … }
static int ofdpa_init(struct rocker *rocker)
{ … }
static void ofdpa_fini(struct rocker *rocker)
{ … }
static int ofdpa_port_pre_init(struct rocker_port *rocker_port)
{ … }
static int ofdpa_port_init(struct rocker_port *rocker_port)
{ … }
static void ofdpa_port_fini(struct rocker_port *rocker_port)
{ … }
static int ofdpa_port_open(struct rocker_port *rocker_port)
{ … }
static void ofdpa_port_stop(struct rocker_port *rocker_port)
{ … }
static int ofdpa_port_attr_stp_state_set(struct rocker_port *rocker_port,
u8 state)
{ … }
static int ofdpa_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
unsigned long brport_flags)
{ … }
static int
ofdpa_port_attr_bridge_flags_support_get(const struct rocker_port *
rocker_port,
unsigned long *
p_brport_flags_support)
{ … }
static int
ofdpa_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
u32 ageing_time)
{ … }
static int ofdpa_port_obj_vlan_add(struct rocker_port *rocker_port,
const struct switchdev_obj_port_vlan *vlan)
{ … }
static int ofdpa_port_obj_vlan_del(struct rocker_port *rocker_port,
const struct switchdev_obj_port_vlan *vlan)
{ … }
static int ofdpa_port_obj_fdb_add(struct rocker_port *rocker_port,
u16 vid, const unsigned char *addr)
{ … }
static int ofdpa_port_obj_fdb_del(struct rocker_port *rocker_port,
u16 vid, const unsigned char *addr)
{ … }
static int ofdpa_port_bridge_join(struct ofdpa_port *ofdpa_port,
struct net_device *bridge,
struct netlink_ext_ack *extack)
{ … }
static int ofdpa_port_bridge_leave(struct ofdpa_port *ofdpa_port)
{ … }
static int ofdpa_port_ovs_changed(struct ofdpa_port *ofdpa_port,
struct net_device *master)
{ … }
static int ofdpa_port_master_linked(struct rocker_port *rocker_port,
struct net_device *master,
struct netlink_ext_ack *extack)
{ … }
static int ofdpa_port_master_unlinked(struct rocker_port *rocker_port,
struct net_device *master)
{ … }
static int ofdpa_port_neigh_update(struct rocker_port *rocker_port,
struct neighbour *n)
{ … }
static int ofdpa_port_neigh_destroy(struct rocker_port *rocker_port,
struct neighbour *n)
{ … }
static int ofdpa_port_ev_mac_vlan_seen(struct rocker_port *rocker_port,
const unsigned char *addr,
__be16 vlan_id)
{ … }
static struct ofdpa_port *ofdpa_port_dev_lower_find(struct net_device *dev,
struct rocker *rocker)
{ … }
static int ofdpa_fib4_add(struct rocker *rocker,
const struct fib_entry_notifier_info *fen_info)
{ … }
static int ofdpa_fib4_del(struct rocker *rocker,
const struct fib_entry_notifier_info *fen_info)
{ … }
static void ofdpa_fib4_abort(struct rocker *rocker)
{ … }
struct rocker_world_ops rocker_ofdpa_ops = …;