linux/drivers/net/ethernet/sfc/tc.h

/* SPDX-License-Identifier: GPL-2.0-only */
/****************************************************************************
 * Driver for Solarflare network controllers and boards
 * Copyright 2019 Solarflare Communications Inc.
 * Copyright 2020-2022 Xilinx Inc.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, incorporated herein by reference.
 */

#ifndef EFX_TC_H
#define EFX_TC_H
#include <net/flow_offload.h>
#include <linux/rhashtable.h>
#include "net_driver.h"
#include "tc_counters.h"

#define IS_ALL_ONES(v)

/**
 * struct efx_tc_mac_pedit_action - mac pedit action fields
 *
 * @h_addr:	mac address field of ethernet header
 * @linkage:	rhashtable reference
 * @ref:	reference count
 * @fw_id:	index of this entry in firmware MAC address table
 *
 * MAC address edits are indirected through a table in the hardware
 */
struct efx_tc_mac_pedit_action {};

static inline bool efx_ipv6_addr_all_ones(struct in6_addr *addr)
{}

struct efx_tc_encap_action; /* see tc_encap_actions.h */

/**
 * struct efx_tc_action_set - collection of tc action fields
 *
 * @vlan_push: the number of vlan headers to push
 * @vlan_pop: the number of vlan headers to pop
 * @decap: used to indicate a tunnel header decapsulation should take place
 * @do_nat: perform NAT/NPT with values returned by conntrack match
 * @do_ttl_dec: used to indicate IP TTL / Hop Limit should be decremented
 * @deliver: used to indicate a deliver action should take place
 * @vlan_tci: tci fields for vlan push actions
 * @vlan_proto: ethernet types for vlan push actions
 * @count: counter mapping
 * @encap_md: encap entry in tc_encap_ht table
 * @encap_user: linked list of encap users (encap_md->users)
 * @user: owning action-set-list. Only populated if @encap_md is; used by efx_tc_update_encap() fallback handling
 * @count_user: linked list of counter users (counter->users)
 * @dest_mport: destination mport
 * @src_mac: source mac entry in tc_mac_ht table
 * @dst_mac: destination mac entry in tc_mac_ht table
 * @fw_id: index of this entry in firmware actions table
 * @list: linked list of tc actions
 *
 */
struct efx_tc_action_set {};

struct efx_tc_match_fields {};

static inline bool efx_tc_match_is_encap(const struct efx_tc_match_fields *mask)
{}

/**
 * enum efx_tc_em_pseudo_type - &struct efx_tc_encap_match pseudo type
 *
 * These are used to classify "pseudo" encap matches, which don't refer
 * to an entry in hardware but rather indicate that a section of the
 * match space is in use by another Outer Rule.
 *
 * @EFX_TC_EM_DIRECT: real HW entry in Outer Rule table; not a pseudo.
 *	Hardware index in &struct efx_tc_encap_match.fw_id is valid.
 * @EFX_TC_EM_PSEUDO_MASK: registered by an encap match which includes a
 *	match on an optional field (currently ip_tos and/or udp_sport),
 *	to prevent an overlapping encap match _without_ optional fields.
 *	The pseudo encap match may be referenced again by an encap match
 *	with different values for these fields, but all masks must match the
 *	first (stored in our child_* fields).
 * @EFX_TC_EM_PSEUDO_OR: registered by an fLHS rule that fits in the OR
 *	table.  The &struct efx_tc_lhs_rule already holds the HW OR entry.
 *	Only one reference to this encap match may exist.
 */
enum efx_tc_em_pseudo_type {};

struct efx_tc_encap_match {};

struct efx_tc_recirc_id {};

struct efx_tc_match {};

struct efx_tc_action_set_list {};

struct efx_tc_lhs_action {};

struct efx_tc_flow_rule {};

struct efx_tc_lhs_rule {};

enum efx_tc_rule_prios {};

struct efx_tc_table_field_fmt {};

struct efx_tc_table_desc {};

struct efx_tc_table_ct {};

/**
 * struct efx_tc_state - control plane data for TC offload
 *
 * @caps: MAE capabilities reported by MCDI
 * @block_list: List of &struct efx_tc_block_binding
 * @mutex: Used to serialise operations on TC hashtables
 * @counter_ht: Hashtable of TC counters (FW IDs and counter values)
 * @counter_id_ht: Hashtable mapping TC counter cookies to counters
 * @encap_ht: Hashtable of TC encap actions
 * @mac_ht: Hashtable of MAC address entries (for pedits)
 * @encap_match_ht: Hashtable of TC encap matches
 * @match_action_ht: Hashtable of TC match-action rules
 * @lhs_rule_ht: Hashtable of TC left-hand (act ct & goto chain) rules
 * @ct_zone_ht: Hashtable of TC conntrack flowtable bindings
 * @ct_ht: Hashtable of TC conntrack flow entries
 * @neigh_ht: Hashtable of neighbour watches (&struct efx_neigh_binder)
 * @recirc_ht: Hashtable of recirculation ID mappings (&struct efx_tc_recirc_id)
 * @recirc_ida: Recirculation ID allocator
 * @meta_ct: MAE table layout for conntrack table
 * @reps_mport_id: MAE port allocated for representor RX
 * @reps_filter_uc: VNIC filter for representor unicast RX (promisc)
 * @reps_filter_mc: VNIC filter for representor multicast RX (allmulti)
 * @reps_mport_vport_id: vport_id for representor RX filters
 * @flush_counters: counters have been stopped, waiting for drain
 * @flush_gen: final generation count per type array as reported by
 *             MC_CMD_MAE_COUNTERS_STREAM_STOP
 * @seen_gen: most recent generation count per type as seen by efx_tc_rx()
 * @flush_wq: wait queue used by efx_mae_stop_counters() to wait for
 *	MAE counters RXQ to finish draining
 * @dflt: Match-action rules for default switching; at priority
 *	%EFX_TC_PRIO_DFLT.  Named by *ingress* port
 * @dflt.pf: rule for traffic ingressing from PF (egresses to wire)
 * @dflt.wire: rule for traffic ingressing from wire (egresses to PF)
 * @facts: Fallback action-set-lists for unready rules.  Named by *egress* port
 * @facts.pf: action-set-list for unready rules on PF netdev, hence applying to
 *	traffic from wire, and egressing to PF
 * @facts.reps: action-set-list for unready rules on representors, hence
 *	applying to traffic from representees, and egressing to the reps mport
 * @up: have TC datastructures been set up?
 */
struct efx_tc_state {};

struct efx_rep;

enum efx_encap_type efx_tc_indr_netdev_type(struct net_device *net_dev);
struct efx_rep *efx_tc_flower_lookup_efv(struct efx_nic *efx,
					 struct net_device *dev);
s64 efx_tc_flower_external_mport(struct efx_nic *efx, struct efx_rep *efv);
int efx_tc_configure_default_rule_rep(struct efx_rep *efv);
void efx_tc_deconfigure_default_rule(struct efx_nic *efx,
				     struct efx_tc_flow_rule *rule);
int efx_tc_flower(struct efx_nic *efx, struct net_device *net_dev,
		  struct flow_cls_offload *tc, struct efx_rep *efv);

int efx_tc_insert_rep_filters(struct efx_nic *efx);
void efx_tc_remove_rep_filters(struct efx_nic *efx);

int efx_init_tc(struct efx_nic *efx);
void efx_fini_tc(struct efx_nic *efx);

int efx_init_struct_tc(struct efx_nic *efx);
void efx_fini_struct_tc(struct efx_nic *efx);

#endif /* EFX_TC_H */