linux/drivers/net/ethernet/meta/fbnic/fbnic_rpc.h

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) Meta Platforms, Inc. and affiliates. */

#ifndef _FBNIC_RPC_H_
#define _FBNIC_RPC_H_

#include <uapi/linux/in6.h>
#include <linux/bitfield.h>

/*  The TCAM state definitions follow an expected ordering.
 *  They start out disabled, then move through the following states:
 *  Disabled  0	-> Add	      2
 *  Add	      2	-> Valid      1
 *
 *  Valid     1	-> Add/Update 2
 *  Add	      2	-> Valid      1
 *
 *  Valid     1	-> Delete     3
 *  Delete    3	-> Disabled   0
 */
enum {};

/* 32 MAC Destination Address TCAM Entries
 * 4 registers DA[1:0], DA[3:2], DA[5:4], Validate
 */
#define FBNIC_RPC_TCAM_MACDA_WORD_LEN
#define FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES

#define FBNIC_RPC_TCAM_ACT_WORD_LEN
#define FBNIC_RPC_TCAM_ACT_NUM_ENTRIES

struct fbnic_mac_addr {};

struct fbnic_act_tcam {};

enum {};

/* Reserve the first 2 entries for the use by the BMC so that we can
 * avoid allowing rules to get in the way of BMC unicast traffic.
 */
#define FBNIC_RPC_ACT_TBL_BMC_OFFSET
#define FBNIC_RPC_ACT_TBL_BMC_ALL_MULTI_OFFSET

/* We reserve the last 14 entries for RSS rules on the host. The BMC
 * unicast rule will need to be populated above these and is expected to
 * use MACDA TCAM entry 23 to store the BMC MAC address.
 */
#define FBNIC_RPC_ACT_TBL_RSS_OFFSET

/* Flags used to identify the owner for this MAC filter. Note that any
 * flags set for Broadcast thru Promisc indicate that the rule belongs
 * to the RSS filters for the host.
 */
enum {};

#define FBNIC_MAC_ADDR_T_HOST_LEN

#define FBNIC_RPC_TCAM_ACT0_IPSRC_IDX
#define FBNIC_RPC_TCAM_ACT0_IPSRC_VALID
#define FBNIC_RPC_TCAM_ACT0_IPDST_IDX
#define FBNIC_RPC_TCAM_ACT0_IPDST_VALID
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPSRC_IDX
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPSRC_VALID
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPDST_IDX
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPDST_VALID

#define FBNIC_RPC_TCAM_ACT1_L2_MACDA_IDX
#define FBNIC_RPC_TCAM_ACT1_L2_MACDA_VALID
#define FBNIC_RPC_TCAM_ACT1_IP_IS_V6
#define FBNIC_RPC_TCAM_ACT1_IP_VALID
#define FBNIC_RPC_TCAM_ACT1_OUTER_IP_VALID
#define FBNIC_RPC_TCAM_ACT1_L4_IS_UDP
#define FBNIC_RPC_TCAM_ACT1_L4_VALID

/* TCAM 0 - 3 reserved for BMC MAC addresses */
#define FBNIC_RPC_TCAM_MACDA_BMC_ADDR_IDX
/* TCAM 4 reserved for broadcast MAC address */
#define FBNIC_RPC_TCAM_MACDA_BROADCAST_IDX
/* TCAMs 5 - 30 will be used for multicast and unicast addresses. The
 * boundary between the two can be variable it is currently set to 24
 * on which the unicast addresses start. The general idea is that we will
 * always go top-down with unicast, and bottom-up with multicast so that
 * there should be free-space in the middle between the two.
 *
 * The entry at MADCA_DEFAULT_BOUNDARY is a special case as it can be used
 * for the ALL MULTI address if the list is full, or the BMC has requested
 * it.
 */
#define FBNIC_RPC_TCAM_MACDA_MULTICAST_IDX
#define FBNIC_RPC_TCAM_MACDA_DEFAULT_BOUNDARY
#define FBNIC_RPC_TCAM_MACDA_HOST_ADDR_IDX
/* Reserved for use to record Multicast promisc, or Promiscuous */
#define FBNIC_RPC_TCAM_MACDA_PROMISC_IDX

enum {};

struct fbnic_dev;
struct fbnic_net;

void fbnic_bmc_rpc_init(struct fbnic_dev *fbd);
void fbnic_bmc_rpc_all_multi_config(struct fbnic_dev *fbd, bool enable_host);

void fbnic_reset_indir_tbl(struct fbnic_net *fbn);
void fbnic_rss_key_fill(u32 *buffer);
void fbnic_rss_init_en_mask(struct fbnic_net *fbn);
void fbnic_rss_disable_hw(struct fbnic_dev *fbd);
void fbnic_rss_reinit_hw(struct fbnic_dev *fbd, struct fbnic_net *fbn);
void fbnic_rss_reinit(struct fbnic_dev *fbd, struct fbnic_net *fbn);

int __fbnic_xc_unsync(struct fbnic_mac_addr *mac_addr, unsigned int tcam_idx);
struct fbnic_mac_addr *__fbnic_uc_sync(struct fbnic_dev *fbd,
				       const unsigned char *addr);
struct fbnic_mac_addr *__fbnic_mc_sync(struct fbnic_dev *fbd,
				       const unsigned char *addr);
void fbnic_sift_macda(struct fbnic_dev *fbd);
void fbnic_write_macda(struct fbnic_dev *fbd);

static inline int __fbnic_uc_unsync(struct fbnic_mac_addr *mac_addr)
{}

static inline int __fbnic_mc_unsync(struct fbnic_mac_addr *mac_addr)
{}

void fbnic_clear_rules(struct fbnic_dev *fbd);
void fbnic_write_rules(struct fbnic_dev *fbd);
#endif /* _FBNIC_RPC_H_ */