FILE
fbnic_rpc.h
File preview with syntax highlighting.
linux-6.19.14/drivers/net/ethernet/meta/fbnic/fbnic_rpc.h
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright (c) Meta Platforms, Inc. and affiliates. */ 3 4#ifndef _FBNIC_RPC_H_ 5#define _FBNIC_RPC_H_ 6 7#include <uapi/linux/in6.h> 8#include <linux/bitfield.h> 9 10struct in_addr; 11 12/* The TCAM state definitions follow an expected ordering. 13 * They start out disabled, then move through the following states: 14 * Disabled 0 -> Add 2 15 * Add 2 -> Valid 1 16 * 17 * Valid 1 -> Add/Update 2 18 * Add 2 -> Valid 1 19 * 20 * Valid 1 -> Delete 3 21 * Delete 3 -> Disabled 0 22 */ 23enum { 24 FBNIC_TCAM_S_DISABLED = 0, 25 FBNIC_TCAM_S_VALID = 1, 26 FBNIC_TCAM_S_ADD = 2, 27 FBNIC_TCAM_S_UPDATE = FBNIC_TCAM_S_ADD, 28 FBNIC_TCAM_S_DELETE = 3, 29}; 30 31/* 32 MAC Destination Address TCAM Entries 32 * 4 registers DA[1:0], DA[3:2], DA[5:4], Validate 33 */ 34#define FBNIC_RPC_TCAM_MACDA_WORD_LEN 3 35#define FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES 32 36 37/* 8 IPSRC and IPDST TCAM Entries each 38 * 8 registers, Validate each 39 */ 40#define FBNIC_RPC_TCAM_IP_ADDR_WORD_LEN 8 41#define FBNIC_RPC_TCAM_IP_ADDR_NUM_ENTRIES 8 42 43#define FBNIC_RPC_TCAM_ACT_WORD_LEN 11 44#define FBNIC_RPC_TCAM_ACT_NUM_ENTRIES 64 45 46#define FBNIC_TCE_TCAM_WORD_LEN 3 47#define FBNIC_TCE_TCAM_NUM_ENTRIES 8 48 49struct fbnic_mac_addr { 50 union { 51 unsigned char addr8[ETH_ALEN]; 52 __be16 addr16[FBNIC_RPC_TCAM_MACDA_WORD_LEN]; 53 } mask, value; 54 unsigned char state; 55 DECLARE_BITMAP(act_tcam, FBNIC_RPC_TCAM_ACT_NUM_ENTRIES); 56}; 57 58struct fbnic_ip_addr { 59 struct in6_addr mask, value; 60 unsigned char version; 61 unsigned char state; 62 DECLARE_BITMAP(act_tcam, FBNIC_RPC_TCAM_ACT_NUM_ENTRIES); 63}; 64 65struct fbnic_act_tcam { 66 struct { 67 u16 tcam[FBNIC_RPC_TCAM_ACT_WORD_LEN]; 68 } mask, value; 69 unsigned char state; 70 u16 rss_en_mask; 71 u32 dest; 72}; 73 74enum { 75 FBNIC_RSS_EN_HOST_UDP6, 76 FBNIC_RSS_EN_HOST_UDP4, 77 FBNIC_RSS_EN_HOST_TCP6, 78 FBNIC_RSS_EN_HOST_TCP4, 79 FBNIC_RSS_EN_HOST_IP6, 80 FBNIC_RSS_EN_HOST_IP4, 81 FBNIC_RSS_EN_HOST_ETHER, 82 FBNIC_RSS_EN_XCAST_UDP6, 83#define FBNIC_RSS_EN_NUM_UNICAST FBNIC_RSS_EN_XCAST_UDP6 84 FBNIC_RSS_EN_XCAST_UDP4, 85 FBNIC_RSS_EN_XCAST_TCP6, 86 FBNIC_RSS_EN_XCAST_TCP4, 87 FBNIC_RSS_EN_XCAST_IP6, 88 FBNIC_RSS_EN_XCAST_IP4, 89 FBNIC_RSS_EN_XCAST_ETHER, 90 FBNIC_RSS_EN_NUM_ENTRIES 91}; 92 93/* Reserve the first 2 entries for the use by the BMC so that we can 94 * avoid allowing rules to get in the way of BMC unicast traffic. 95 */ 96#define FBNIC_RPC_ACT_TBL_BMC_OFFSET 0 97#define FBNIC_RPC_ACT_TBL_BMC_ALL_MULTI_OFFSET 1 98 99/* This should leave us with 48 total entries in the TCAM that can be used 100 * for NFC after also deducting the 14 needed for RSS table programming. 101 */ 102#define FBNIC_RPC_ACT_TBL_NFC_OFFSET 2 103 104/* We reserve the last 14 entries for RSS rules on the host. The BMC 105 * unicast rule will need to be populated above these and is expected to 106 * use MACDA TCAM entry 23 to store the BMC MAC address. 107 */ 108#define FBNIC_RPC_ACT_TBL_RSS_OFFSET \ 109 (FBNIC_RPC_ACT_TBL_NUM_ENTRIES - FBNIC_RSS_EN_NUM_ENTRIES) 110 111#define FBNIC_RPC_ACT_TBL_NFC_ENTRIES \ 112 (FBNIC_RPC_ACT_TBL_RSS_OFFSET - FBNIC_RPC_ACT_TBL_NFC_OFFSET) 113 114/* Flags used to identify the owner for this MAC filter. Note that any 115 * flags set for Broadcast thru Promisc indicate that the rule belongs 116 * to the RSS filters for the host. 117 */ 118enum { 119 FBNIC_MAC_ADDR_T_BMC = 0, 120 FBNIC_MAC_ADDR_T_BROADCAST = FBNIC_RPC_ACT_TBL_RSS_OFFSET, 121#define FBNIC_MAC_ADDR_T_HOST_START FBNIC_MAC_ADDR_T_BROADCAST 122 FBNIC_MAC_ADDR_T_MULTICAST, 123 FBNIC_MAC_ADDR_T_UNICAST, 124 FBNIC_MAC_ADDR_T_ALLMULTI, /* BROADCAST ... MULTICAST*/ 125 FBNIC_MAC_ADDR_T_PROMISC, /* BROADCAST ... UNICAST */ 126 FBNIC_MAC_ADDR_T_HOST_LAST 127}; 128 129#define FBNIC_MAC_ADDR_T_HOST_LEN \ 130 (FBNIC_MAC_ADDR_T_HOST_LAST - FBNIC_MAC_ADDR_T_HOST_START) 131 132#define FBNIC_RPC_TCAM_ACT0_IPSRC_IDX CSR_GENMASK(2, 0) 133#define FBNIC_RPC_TCAM_ACT0_IPSRC_VALID CSR_BIT(3) 134#define FBNIC_RPC_TCAM_ACT0_IPDST_IDX CSR_GENMASK(6, 4) 135#define FBNIC_RPC_TCAM_ACT0_IPDST_VALID CSR_BIT(7) 136#define FBNIC_RPC_TCAM_ACT0_OUTER_IPSRC_IDX CSR_GENMASK(10, 8) 137#define FBNIC_RPC_TCAM_ACT0_OUTER_IPSRC_VALID CSR_BIT(11) 138#define FBNIC_RPC_TCAM_ACT0_OUTER_IPDST_IDX CSR_GENMASK(14, 12) 139#define FBNIC_RPC_TCAM_ACT0_OUTER_IPDST_VALID CSR_BIT(15) 140 141#define FBNIC_RPC_TCAM_ACT1_L2_MACDA_IDX CSR_GENMASK(9, 5) 142#define FBNIC_RPC_TCAM_ACT1_L2_MACDA_VALID CSR_BIT(10) 143#define FBNIC_RPC_TCAM_ACT1_IP_IS_V6 CSR_BIT(11) 144#define FBNIC_RPC_TCAM_ACT1_IP_VALID CSR_BIT(12) 145#define FBNIC_RPC_TCAM_ACT1_OUTER_IP_VALID CSR_BIT(13) 146#define FBNIC_RPC_TCAM_ACT1_L4_IS_UDP CSR_BIT(14) 147#define FBNIC_RPC_TCAM_ACT1_L4_VALID CSR_BIT(15) 148 149/* TCAM 0 - 3 reserved for BMC MAC addresses */ 150#define FBNIC_RPC_TCAM_MACDA_BMC_ADDR_IDX 0 151/* TCAM 4 reserved for broadcast MAC address */ 152#define FBNIC_RPC_TCAM_MACDA_BROADCAST_IDX 4 153/* TCAMs 5 - 30 will be used for multicast and unicast addresses. The 154 * boundary between the two can be variable it is currently set to 24 155 * on which the unicast addresses start. The general idea is that we will 156 * always go top-down with unicast, and bottom-up with multicast so that 157 * there should be free-space in the middle between the two. 158 * 159 * The entry at MADCA_DEFAULT_BOUNDARY is a special case as it can be used 160 * for the ALL MULTI address if the list is full, or the BMC has requested 161 * it. 162 */ 163#define FBNIC_RPC_TCAM_MACDA_MULTICAST_IDX 5 164#define FBNIC_RPC_TCAM_MACDA_DEFAULT_BOUNDARY 24 165#define FBNIC_RPC_TCAM_MACDA_HOST_ADDR_IDX 30 166/* Reserved for use to record Multicast promisc, or Promiscuous */ 167#define FBNIC_RPC_TCAM_MACDA_PROMISC_IDX 31 168 169enum { 170 FBNIC_UDP6_HASH_OPT, 171 FBNIC_UDP4_HASH_OPT, 172 FBNIC_TCP6_HASH_OPT, 173 FBNIC_TCP4_HASH_OPT, 174#define FBNIC_L4_HASH_OPT FBNIC_TCP4_HASH_OPT 175 FBNIC_IPV6_HASH_OPT, 176 FBNIC_IPV4_HASH_OPT, 177#define FBNIC_IP_HASH_OPT FBNIC_IPV4_HASH_OPT 178 FBNIC_ETHER_HASH_OPT, 179 FBNIC_NUM_HASH_OPT, 180}; 181 182struct fbnic_dev; 183struct fbnic_net; 184 185void fbnic_bmc_rpc_init(struct fbnic_dev *fbd); 186void fbnic_bmc_rpc_all_multi_config(struct fbnic_dev *fbd, bool enable_host); 187void fbnic_bmc_rpc_check(struct fbnic_dev *fbd); 188 189void fbnic_reset_indir_tbl(struct fbnic_net *fbn); 190void fbnic_rss_key_fill(u32 *buffer); 191void fbnic_rss_init_en_mask(struct fbnic_net *fbn); 192void fbnic_rss_disable_hw(struct fbnic_dev *fbd); 193void fbnic_rss_reinit_hw(struct fbnic_dev *fbd, struct fbnic_net *fbn); 194void fbnic_rss_reinit(struct fbnic_dev *fbd, struct fbnic_net *fbn); 195u16 fbnic_flow_hash_2_rss_en_mask(struct fbnic_net *fbn, int flow_type); 196 197int __fbnic_xc_unsync(struct fbnic_mac_addr *mac_addr, unsigned int tcam_idx); 198struct fbnic_mac_addr *__fbnic_uc_sync(struct fbnic_dev *fbd, 199 const unsigned char *addr); 200struct fbnic_mac_addr *__fbnic_mc_sync(struct fbnic_dev *fbd, 201 const unsigned char *addr); 202void fbnic_sift_macda(struct fbnic_dev *fbd); 203void fbnic_write_macda(struct fbnic_dev *fbd); 204 205void fbnic_promisc_sync(struct fbnic_dev *fbd, 206 bool uc_promisc, bool mc_promisc); 207 208struct fbnic_ip_addr *__fbnic_ip4_sync(struct fbnic_dev *fbd, 209 struct fbnic_ip_addr *ip_addr, 210 const struct in_addr *addr, 211 const struct in_addr *mask); 212struct fbnic_ip_addr *__fbnic_ip6_sync(struct fbnic_dev *fbd, 213 struct fbnic_ip_addr *ip_addr, 214 const struct in6_addr *addr, 215 const struct in6_addr *mask); 216int __fbnic_ip_unsync(struct fbnic_ip_addr *ip_addr, unsigned int tcam_idx); 217void fbnic_write_ip_addr(struct fbnic_dev *fbd); 218 219static inline int __fbnic_uc_unsync(struct fbnic_mac_addr *mac_addr) 220{ 221 return __fbnic_xc_unsync(mac_addr, FBNIC_MAC_ADDR_T_UNICAST); 222} 223 224static inline int __fbnic_mc_unsync(struct fbnic_mac_addr *mac_addr) 225{ 226 return __fbnic_xc_unsync(mac_addr, FBNIC_MAC_ADDR_T_MULTICAST); 227} 228 229void fbnic_clear_rules(struct fbnic_dev *fbd); 230void fbnic_write_rules(struct fbnic_dev *fbd); 231void fbnic_write_tce_tcam(struct fbnic_dev *fbd); 232#endif /* _FBNIC_RPC_H_ */
~/
Read-only file preview.