#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/if_vlan.h>
#include <net/flow_dissector.h>
#include <net/pkt_cls.h>
#include <net/tc_act/tc_gact.h>
#include <net/tc_act/tc_skbedit.h>
#include <net/tc_act/tc_mirred.h>
#include <net/tc_act/tc_vlan.h>
#include <net/tc_act/tc_pedit.h>
#include <net/tc_act/tc_tunnel_key.h>
#include <net/vxlan.h>
#include "bnxt_hsi.h"
#include "bnxt.h"
#include "bnxt_hwrm.h"
#include "bnxt_sriov.h"
#include "bnxt_tc.h"
#include "bnxt_vfr.h"
#define BNXT_FID_INVALID …
#define VLAN_TCI(vid, prio) …
#define is_vlan_pcp_wildcarded(vlan_tci_mask) …
#define is_vlan_pcp_exactmatch(vlan_tci_mask) …
#define is_vlan_pcp_zero(vlan_tci) …
#define is_vid_exactmatch(vlan_tci_mask) …
static bool is_wildcard(void *mask, int len);
static bool is_exactmatch(void *mask, int len);
static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct net_device *dev)
{ … }
static int bnxt_tc_parse_redir(struct bnxt *bp,
struct bnxt_tc_actions *actions,
const struct flow_action_entry *act)
{ … }
static int bnxt_tc_parse_vlan(struct bnxt *bp,
struct bnxt_tc_actions *actions,
const struct flow_action_entry *act)
{ … }
static int bnxt_tc_parse_tunnel_set(struct bnxt *bp,
struct bnxt_tc_actions *actions,
const struct flow_action_entry *act)
{ … }
static void bnxt_set_l2_key_mask(u32 part_key, u32 part_mask,
u8 *actual_key, u8 *actual_mask)
{ … }
static int
bnxt_fill_l2_rewrite_fields(struct bnxt_tc_actions *actions,
u16 *eth_addr, u16 *eth_addr_mask)
{ … }
static int
bnxt_tc_parse_pedit(struct bnxt *bp, struct bnxt_tc_actions *actions,
struct flow_action_entry *act, int act_idx, u8 *eth_addr,
u8 *eth_addr_mask)
{ … }
static int bnxt_tc_parse_actions(struct bnxt *bp,
struct bnxt_tc_actions *actions,
struct flow_action *flow_action,
struct netlink_ext_ack *extack)
{ … }
static int bnxt_tc_parse_flow(struct bnxt *bp,
struct flow_cls_offload *tc_flow_cmd,
struct bnxt_tc_flow *flow)
{ … }
static int bnxt_hwrm_cfa_flow_free(struct bnxt *bp,
struct bnxt_tc_flow_node *flow_node)
{ … }
static int ipv6_mask_len(struct in6_addr *mask)
{ … }
static bool is_wildcard(void *mask, int len)
{ … }
static bool is_exactmatch(void *mask, int len)
{ … }
static bool is_vlan_tci_allowed(__be16 vlan_tci_mask,
__be16 vlan_tci)
{ … }
static bool bits_set(void *key, int len)
{ … }
static int bnxt_hwrm_cfa_flow_alloc(struct bnxt *bp, struct bnxt_tc_flow *flow,
__le16 ref_flow_handle,
__le32 tunnel_handle,
struct bnxt_tc_flow_node *flow_node)
{ … }
static int hwrm_cfa_decap_filter_alloc(struct bnxt *bp,
struct bnxt_tc_flow *flow,
struct bnxt_tc_l2_key *l2_info,
__le32 ref_decap_handle,
__le32 *decap_filter_handle)
{ … }
static int hwrm_cfa_decap_filter_free(struct bnxt *bp,
__le32 decap_filter_handle)
{ … }
static int hwrm_cfa_encap_record_alloc(struct bnxt *bp,
struct ip_tunnel_key *encap_key,
struct bnxt_tc_l2_key *l2_info,
__le32 *encap_record_handle)
{ … }
static int hwrm_cfa_encap_record_free(struct bnxt *bp,
__le32 encap_record_handle)
{ … }
static int bnxt_tc_put_l2_node(struct bnxt *bp,
struct bnxt_tc_flow_node *flow_node)
{ … }
static struct bnxt_tc_l2_node *
bnxt_tc_get_l2_node(struct bnxt *bp, struct rhashtable *l2_table,
struct rhashtable_params ht_params,
struct bnxt_tc_l2_key *l2_key)
{ … }
static int
bnxt_tc_get_ref_flow_handle(struct bnxt *bp, struct bnxt_tc_flow *flow,
struct bnxt_tc_flow_node *flow_node,
__le16 *ref_flow_handle)
{ … }
static bool bnxt_tc_can_offload(struct bnxt *bp, struct bnxt_tc_flow *flow)
{ … }
static int bnxt_tc_put_tunnel_node(struct bnxt *bp,
struct rhashtable *tunnel_table,
struct rhashtable_params *ht_params,
struct bnxt_tc_tunnel_node *tunnel_node)
{ … }
static struct bnxt_tc_tunnel_node *
bnxt_tc_get_tunnel_node(struct bnxt *bp, struct rhashtable *tunnel_table,
struct rhashtable_params *ht_params,
struct ip_tunnel_key *tun_key)
{ … }
static int bnxt_tc_get_ref_decap_handle(struct bnxt *bp,
struct bnxt_tc_flow *flow,
struct bnxt_tc_l2_key *l2_key,
struct bnxt_tc_flow_node *flow_node,
__le32 *ref_decap_handle)
{ … }
static void bnxt_tc_put_decap_l2_node(struct bnxt *bp,
struct bnxt_tc_flow_node *flow_node)
{ … }
static void bnxt_tc_put_decap_handle(struct bnxt *bp,
struct bnxt_tc_flow_node *flow_node)
{ … }
static int bnxt_tc_resolve_tunnel_hdrs(struct bnxt *bp,
struct ip_tunnel_key *tun_key,
struct bnxt_tc_l2_key *l2_info)
{ … }
static int bnxt_tc_get_decap_handle(struct bnxt *bp, struct bnxt_tc_flow *flow,
struct bnxt_tc_flow_node *flow_node,
__le32 *decap_filter_handle)
{ … }
static void bnxt_tc_put_encap_handle(struct bnxt *bp,
struct bnxt_tc_tunnel_node *encap_node)
{ … }
static int bnxt_tc_get_encap_handle(struct bnxt *bp, struct bnxt_tc_flow *flow,
struct bnxt_tc_flow_node *flow_node,
__le32 *encap_handle)
{ … }
static void bnxt_tc_put_tunnel_handle(struct bnxt *bp,
struct bnxt_tc_flow *flow,
struct bnxt_tc_flow_node *flow_node)
{ … }
static int bnxt_tc_get_tunnel_handle(struct bnxt *bp,
struct bnxt_tc_flow *flow,
struct bnxt_tc_flow_node *flow_node,
__le32 *tunnel_handle)
{ … }
static int __bnxt_tc_del_flow(struct bnxt *bp,
struct bnxt_tc_flow_node *flow_node)
{ … }
static void bnxt_tc_set_flow_dir(struct bnxt *bp, struct bnxt_tc_flow *flow,
u16 src_fid)
{ … }
static void bnxt_tc_set_src_fid(struct bnxt *bp, struct bnxt_tc_flow *flow,
u16 src_fid)
{ … }
static int bnxt_tc_add_flow(struct bnxt *bp, u16 src_fid,
struct flow_cls_offload *tc_flow_cmd)
{ … }
static int bnxt_tc_del_flow(struct bnxt *bp,
struct flow_cls_offload *tc_flow_cmd)
{ … }
static int bnxt_tc_get_flow_stats(struct bnxt *bp,
struct flow_cls_offload *tc_flow_cmd)
{ … }
static void bnxt_fill_cfa_stats_req(struct bnxt *bp,
struct bnxt_tc_flow_node *flow_node,
__le16 *flow_handle, __le32 *flow_id)
{ … }
static int
bnxt_hwrm_cfa_flow_stats_get(struct bnxt *bp, int num_flows,
struct bnxt_tc_stats_batch stats_batch[])
{ … }
static void accumulate_val(u64 *accum, u64 val, u64 mask)
{ … }
static void bnxt_flow_stats_accum(struct bnxt_tc_info *tc_info,
struct bnxt_tc_flow_stats *acc_stats,
struct bnxt_tc_flow_stats *hw_stats)
{ … }
static int
bnxt_tc_flow_stats_batch_update(struct bnxt *bp, int num_flows,
struct bnxt_tc_stats_batch stats_batch[])
{ … }
static int
bnxt_tc_flow_stats_batch_prep(struct bnxt *bp,
struct bnxt_tc_stats_batch stats_batch[],
int *num_flows)
{ … }
void bnxt_tc_flow_stats_work(struct bnxt *bp)
{ … }
int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
struct flow_cls_offload *cls_flower)
{ … }
static int bnxt_tc_setup_indr_block_cb(enum tc_setup_type type,
void *type_data, void *cb_priv)
{ … }
static struct bnxt_flower_indr_block_cb_priv *
bnxt_tc_indr_block_cb_lookup(struct bnxt *bp, struct net_device *netdev)
{ … }
static void bnxt_tc_setup_indr_rel(void *cb_priv)
{ … }
static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct Qdisc *sch, struct bnxt *bp,
struct flow_block_offload *f, void *data,
void (*cleanup)(struct flow_block_cb *block_cb))
{ … }
static bool bnxt_is_netdev_indr_offload(struct net_device *netdev)
{ … }
static int bnxt_tc_setup_indr_cb(struct net_device *netdev, struct Qdisc *sch, void *cb_priv,
enum tc_setup_type type, void *type_data,
void *data,
void (*cleanup)(struct flow_block_cb *block_cb))
{ … }
static const struct rhashtable_params bnxt_tc_flow_ht_params = …;
static const struct rhashtable_params bnxt_tc_l2_ht_params = …;
static const struct rhashtable_params bnxt_tc_decap_l2_ht_params = …;
static const struct rhashtable_params bnxt_tc_tunnel_ht_params = …;
#define mask(width) …
int bnxt_init_tc(struct bnxt *bp)
{ … }
void bnxt_shutdown_tc(struct bnxt *bp)
{ … }