Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: microchip: sparx5: Adding initial VCAP API support

This provides the initial VCAP API framework and Sparx5 specific VCAP
implementation.

When the Sparx5 Switchdev driver is initialized it will also initialize its
VCAP module, and this hooks up the concrete Sparx5 VCAP model to the VCAP
API, so that the VCAP API knows what VCAP instances are available.

Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Steen Hegelund and committed by
David S. Miller
8beef08f abc21095

+699 -2
+1
MAINTAINERS
··· 2439 2439 S: Supported 2440 2440 T: git git://github.com/microchip-ung/linux-upstream.git 2441 2441 F: arch/arm64/boot/dts/microchip/ 2442 + F: drivers/net/ethernet/microchip/vcap/ 2442 2443 F: drivers/pinctrl/pinctrl-microchip-sgpio.c 2443 2444 N: sparx5 2444 2445
+1
drivers/net/ethernet/microchip/Kconfig
··· 57 57 58 58 source "drivers/net/ethernet/microchip/lan966x/Kconfig" 59 59 source "drivers/net/ethernet/microchip/sparx5/Kconfig" 60 + source "drivers/net/ethernet/microchip/vcap/Kconfig" 60 61 61 62 endif # NET_VENDOR_MICROCHIP
+1
drivers/net/ethernet/microchip/sparx5/Kconfig
··· 9 9 select PHYLINK 10 10 select PHY_SPARX5_SERDES 11 11 select RESET_CONTROLLER 12 + select VCAP 12 13 help 13 14 This driver supports the Sparx5 network switch device.
+6 -2
drivers/net/ethernet/microchip/sparx5/Makefile
··· 5 5 6 6 obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o 7 7 8 - sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ 8 + sparx5-switch-y := sparx5_main.o sparx5_packet.o \ 9 9 sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o \ 10 10 sparx5_switchdev.o sparx5_calendar.o sparx5_ethtool.o sparx5_fdma.o \ 11 - sparx5_ptp.o sparx5_pgid.o sparx5_tc.o sparx5_qos.o 11 + sparx5_ptp.o sparx5_pgid.o sparx5_tc.o sparx5_qos.o \ 12 + sparx5_vcap_impl.o 13 + 14 + # Provide include files 15 + ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
+9
drivers/net/ethernet/microchip/sparx5/sparx5_main.c
··· 672 672 673 673 sparx5_board_init(sparx5); 674 674 err = sparx5_register_notifier_blocks(sparx5); 675 + if (err) 676 + return err; 677 + 678 + err = sparx5_vcap_init(sparx5); 679 + if (err) { 680 + sparx5_unregister_notifier_blocks(sparx5); 681 + return err; 682 + } 675 683 676 684 /* Start Frame DMA with fallback to register based INJ/XTR */ 677 685 err = -ENXIO; ··· 914 906 sparx5_ptp_deinit(sparx5); 915 907 sparx5_fdma_stop(sparx5); 916 908 sparx5_cleanup_ports(sparx5); 909 + sparx5_vcap_destroy(sparx5); 917 910 /* Unregister netdevs */ 918 911 sparx5_unregister_notifier_blocks(sparx5); 919 912
+6
drivers/net/ethernet/microchip/sparx5/sparx5_main.h
··· 288 288 struct mutex ptp_lock; /* lock for ptp interface state */ 289 289 u16 ptp_skbs; 290 290 int ptp_irq; 291 + /* VCAP */ 292 + struct vcap_control *vcap_ctrl; 291 293 /* PGID allocation map */ 292 294 u8 pgid_map[PGID_TABLE_SIZE]; 293 295 }; ··· 383 381 void sparx5_ptp_txtstamp_release(struct sparx5_port *port, 384 382 struct sk_buff *skb); 385 383 irqreturn_t sparx5_ptp_irq_handler(int irq, void *args); 384 + 385 + /* sparx5_vcap_impl.c */ 386 + int sparx5_vcap_init(struct sparx5 *sparx5); 387 + void sparx5_vcap_destroy(struct sparx5 *sparx5); 386 388 387 389 /* sparx5_pgid.c */ 388 390 enum sparx5_pgid_type {
+41
drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* Microchip Sparx5 Switch driver VCAP implementation 3 + * 4 + * Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries. 5 + * 6 + * The Sparx5 Chip Register Model can be browsed at this location: 7 + * https://github.com/microchip-ung/sparx-5_reginfo 8 + */ 9 + 10 + #include <linux/types.h> 11 + #include <linux/list.h> 12 + 13 + #include "vcap_api.h" 14 + #include "sparx5_main_regs.h" 15 + #include "sparx5_main.h" 16 + 17 + /* Allocate a vcap control and vcap instances and configure the system */ 18 + int sparx5_vcap_init(struct sparx5 *sparx5) 19 + { 20 + struct vcap_control *ctrl; 21 + 22 + /* Create a VCAP control instance that owns the platform specific VCAP 23 + * model with VCAP instances and information about keysets, keys, 24 + * actionsets and actions 25 + */ 26 + ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 27 + if (!ctrl) 28 + return -ENOMEM; 29 + 30 + sparx5->vcap_ctrl = ctrl; 31 + 32 + return 0; 33 + } 34 + 35 + void sparx5_vcap_destroy(struct sparx5 *sparx5) 36 + { 37 + if (!sparx5->vcap_ctrl) 38 + return; 39 + 40 + kfree(sparx5->vcap_ctrl); 41 + }
+39
drivers/net/ethernet/microchip/vcap/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + # 3 + # Microchip VCAP API configuration 4 + # 5 + 6 + if NET_VENDOR_MICROCHIP 7 + 8 + config VCAP 9 + bool "VCAP (Versatile Content-Aware Processor) library" 10 + help 11 + Provides the basic VCAP functionality for multiple Microchip switchcores 12 + 13 + A VCAP is essentially a TCAM with rules consisting of 14 + 15 + - Programmable key fields 16 + - Programmable action fields 17 + - A counter (which may be only one bit wide) 18 + 19 + Besides this each VCAP has: 20 + 21 + - A number of lookups 22 + - A keyset configuration per port per lookup 23 + 24 + The VCAP implementation provides switchcore independent handling of rules 25 + and supports: 26 + 27 + - Creating and deleting rules 28 + - Updating and getting rules 29 + 30 + The platform specific configuration as well as the platform specific model 31 + of the VCAP instances are attached to the VCAP API and a client can then 32 + access rules via the API in a platform independent way, with the 33 + limitations that each VCAP has in terms of its supported keys and actions. 34 + 35 + Different switchcores will have different VCAP instances with different 36 + characteristics. Look in the datasheet for the VCAP specifications for the 37 + specific switchcore. 38 + 39 + endif # NET_VENDOR_MICROCHIP
+326
drivers/net/ethernet/microchip/vcap/vcap_ag_api.h
··· 1 + /* SPDX-License-Identifier: BSD-3-Clause */ 2 + /* Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries. 3 + * Microchip VCAP API 4 + */ 5 + 6 + /* This file is autogenerated by cml-utils 2022-10-13 10:04:41 +0200. 7 + * Commit ID: fd7cafd175899f0672c73afb3a30fc872500ae86 8 + */ 9 + 10 + #ifndef __VCAP_AG_API__ 11 + #define __VCAP_AG_API__ 12 + 13 + enum vcap_type { 14 + VCAP_TYPE_IS2, 15 + VCAP_TYPE_MAX 16 + }; 17 + 18 + /* Keyfieldset names with origin information */ 19 + enum vcap_keyfield_set { 20 + VCAP_KFS_NO_VALUE, /* initial value */ 21 + VCAP_KFS_ARP, /* sparx5 is2 X6 */ 22 + VCAP_KFS_IP4_OTHER, /* sparx5 is2 X6 */ 23 + VCAP_KFS_IP4_TCP_UDP, /* sparx5 is2 X6 */ 24 + VCAP_KFS_IP6_STD, /* sparx5 is2 X6 */ 25 + VCAP_KFS_IP_7TUPLE, /* sparx5 is2 X12 */ 26 + VCAP_KFS_MAC_ETYPE, /* sparx5 is2 X6 */ 27 + }; 28 + 29 + /* List of keyfields with description 30 + * 31 + * Keys ending in _IS are booleans derived from frame data 32 + * Keys ending in _CLS are classified frame data 33 + * 34 + * VCAP_KF_8021Q_DEI_CLS: W1, sparx5: is2 35 + * Classified DEI 36 + * VCAP_KF_8021Q_PCP_CLS: W3, sparx5: is2 37 + * Classified PCP 38 + * VCAP_KF_8021Q_VID_CLS: W13, sparx5: is2 39 + * Classified VID 40 + * VCAP_KF_8021Q_VLAN_TAGGED_IS: W1, sparx5: is2 41 + * Sparx5: Set if frame was received with a VLAN tag, LAN966x: Set if frame has 42 + * one or more Q-tags. Independent of port VLAN awareness 43 + * VCAP_KF_ARP_ADDR_SPACE_OK_IS: W1, sparx5: is2 44 + * Set if hardware address is Ethernet 45 + * VCAP_KF_ARP_LEN_OK_IS: W1, sparx5: is2 46 + * Set if hardware address length = 6 (Ethernet) and IP address length = 4 (IP). 47 + * VCAP_KF_ARP_OPCODE: W2, sparx5: is2 48 + * ARP opcode 49 + * VCAP_KF_ARP_OPCODE_UNKNOWN_IS: W1, sparx5: is2 50 + * Set if not one of the codes defined in VCAP_KF_ARP_OPCODE 51 + * VCAP_KF_ARP_PROTO_SPACE_OK_IS: W1, sparx5: is2 52 + * Set if protocol address space is 0x0800 53 + * VCAP_KF_ARP_SENDER_MATCH_IS: W1, sparx5: is2 54 + * Sender Hardware Address = SMAC (ARP) 55 + * VCAP_KF_ARP_TGT_MATCH_IS: W1, sparx5: is2 56 + * Target Hardware Address = SMAC (RARP) 57 + * VCAP_KF_ETYPE: W16, sparx5: is2 58 + * Ethernet type 59 + * VCAP_KF_ETYPE_LEN_IS: W1, sparx5: is2 60 + * Set if frame has EtherType >= 0x600 61 + * VCAP_KF_IF_IGR_PORT_MASK: sparx5 is2 W32, sparx5 is2 W65 62 + * Ingress port mask, one bit per port/erleg 63 + * VCAP_KF_IF_IGR_PORT_MASK_L3: W1, sparx5: is2 64 + * If set, IF_IGR_PORT_MASK, IF_IGR_PORT_MASK_RNG, and IF_IGR_PORT_MASK_SEL are 65 + * used to specify L3 interfaces 66 + * VCAP_KF_IF_IGR_PORT_MASK_RNG: W4, sparx5: is2 67 + * Range selector for IF_IGR_PORT_MASK. Specifies which group of 32 ports are 68 + * available in IF_IGR_PORT_MASK 69 + * VCAP_KF_IF_IGR_PORT_MASK_SEL: W2, sparx5: is2 70 + * Mode selector for IF_IGR_PORT_MASK, applicable when IF_IGR_PORT_MASK_L3 == 0. 71 + * Mapping: 0: DEFAULT 1: LOOPBACK 2: MASQUERADE 3: CPU_VD 72 + * VCAP_KF_IP4_IS: W1, sparx5: is2 73 + * Set if frame has EtherType = 0x800 and IP version = 4 74 + * VCAP_KF_ISDX_CLS: W12, sparx5: is2 75 + * Classified ISDX 76 + * VCAP_KF_ISDX_GT0_IS: W1, sparx5: is2 77 + * Set if classified ISDX > 0 78 + * VCAP_KF_L2_BC_IS: W1, sparx5: is2 79 + * Set if frame’s destination MAC address is the broadcast address 80 + * (FF-FF-FF-FF-FF-FF). 81 + * VCAP_KF_L2_DMAC: W48, sparx5: is2 82 + * Destination MAC address 83 + * VCAP_KF_L2_FWD_IS: W1, sparx5: is2 84 + * Set if the frame is allowed to be forwarded to front ports 85 + * VCAP_KF_L2_MC_IS: W1, sparx5: is2 86 + * Set if frame’s destination MAC address is a multicast address (bit 40 = 1). 87 + * VCAP_KF_L2_PAYLOAD_ETYPE: W64, sparx5: is2 88 + * Byte 0-7 of L2 payload after Type/Len field and overloading for OAM 89 + * VCAP_KF_L2_SMAC: W48, sparx5: is2 90 + * Source MAC address 91 + * VCAP_KF_L3_DIP_EQ_SIP_IS: W1, sparx5: is2 92 + * Set if Src IP matches Dst IP address 93 + * VCAP_KF_L3_DST_IS: W1, sparx5: is2 94 + * Set if lookup is done for egress router leg 95 + * VCAP_KF_L3_FRAGMENT_TYPE: W2, sparx5: is2 96 + * L3 Fragmentation type (none, initial, suspicious, valid follow up) 97 + * VCAP_KF_L3_FRAG_INVLD_L4_LEN: W1, sparx5: is2 98 + * Set if frame's L4 length is less than ANA_CL:COMMON:CLM_FRAGMENT_CFG.L4_MIN_L 99 + * EN 100 + * VCAP_KF_L3_IP4_DIP: W32, sparx5: is2 101 + * Destination IPv4 Address 102 + * VCAP_KF_L3_IP4_SIP: W32, sparx5: is2 103 + * Source IPv4 Address 104 + * VCAP_KF_L3_IP6_DIP: W128, sparx5: is2 105 + * Sparx5: Full IPv6 DIP, LAN966x: Either Full IPv6 DIP or a subset depending on 106 + * frame type 107 + * VCAP_KF_L3_IP6_SIP: W128, sparx5: is2 108 + * Sparx5: Full IPv6 SIP, LAN966x: Either Full IPv6 SIP or a subset depending on 109 + * frame type 110 + * VCAP_KF_L3_IP_PROTO: W8, sparx5: is2 111 + * IPv4 frames: IP protocol. IPv6 frames: Next header, same as for IPV4 112 + * VCAP_KF_L3_OPTIONS_IS: W1, sparx5: is2 113 + * Set if IPv4 frame contains options (IP len > 5) 114 + * VCAP_KF_L3_PAYLOAD: sparx5 is2 W96, sparx5 is2 W40 115 + * Sparx5: Payload bytes after IP header. IPv4: IPv4 options are not parsed so 116 + * payload is always taken 20 bytes after the start of the IPv4 header, LAN966x: 117 + * Bytes 0-6 after IP header 118 + * VCAP_KF_L3_RT_IS: W1, sparx5: is2 119 + * Set if frame has hit a router leg 120 + * VCAP_KF_L3_TOS: W8, sparx5: is2 121 + * Sparx5: Frame's IPv4/IPv6 DSCP and ECN fields, LAN966x: IP TOS field 122 + * VCAP_KF_L3_TTL_GT0: W1, sparx5: is2 123 + * Set if IPv4 TTL / IPv6 hop limit is greater than 0 124 + * VCAP_KF_L4_ACK: W1, sparx5: is2 125 + * Sparx5 and LAN966x: TCP flag ACK, LAN966x only: PTP over UDP: flagField bit 2 126 + * (unicastFlag) 127 + * VCAP_KF_L4_DPORT: W16, sparx5: is2 128 + * Sparx5: TCP/UDP destination port. Overloading for IP_7TUPLE: Non-TCP/UDP IP 129 + * frames: L4_DPORT = L3_IP_PROTO, LAN966x: TCP/UDP destination port 130 + * VCAP_KF_L4_FIN: W1, sparx5: is2 131 + * TCP flag FIN, LAN966x: TCP flag FIN, and for PTP over UDP: messageType bit 1 132 + * VCAP_KF_L4_PAYLOAD: W64, sparx5: is2 133 + * Payload bytes after TCP/UDP header Overloading for IP_7TUPLE: Non TCP/UDP 134 + * frames: Payload bytes 0–7 after IP header. IPv4 options are not parsed so 135 + * payload is always taken 20 bytes after the start of the IPv4 header for non 136 + * TCP/UDP IPv4 frames 137 + * VCAP_KF_L4_PSH: W1, sparx5: is2 138 + * Sparx5: TCP flag PSH, LAN966x: TCP: TCP flag PSH. PTP over UDP: flagField bit 139 + * 1 (twoStepFlag) 140 + * VCAP_KF_L4_RNG: W16, sparx5: is2 141 + * Range checker bitmask (one for each range checker). Input into range checkers 142 + * is taken from classified results (VID, DSCP) and frame (SPORT, DPORT, ETYPE, 143 + * outer VID, inner VID) 144 + * VCAP_KF_L4_RST: W1, sparx5: is2 145 + * Sparx5: TCP flag RST , LAN966x: TCP: TCP flag RST. PTP over UDP: messageType 146 + * bit 3 147 + * VCAP_KF_L4_SEQUENCE_EQ0_IS: W1, sparx5: is2 148 + * Set if TCP sequence number is 0, LAN966x: Overlayed with PTP over UDP: 149 + * messageType bit 0 150 + * VCAP_KF_L4_SPORT: W16, sparx5: is2 151 + * TCP/UDP source port 152 + * VCAP_KF_L4_SPORT_EQ_DPORT_IS: W1, sparx5: is2 153 + * Set if UDP or TCP source port equals UDP or TCP destination port 154 + * VCAP_KF_L4_SYN: W1, sparx5: is2 155 + * Sparx5: TCP flag SYN, LAN966x: TCP: TCP flag SYN. PTP over UDP: messageType 156 + * bit 2 157 + * VCAP_KF_L4_URG: W1, sparx5: is2 158 + * Sparx5: TCP flag URG, LAN966x: TCP: TCP flag URG. PTP over UDP: flagField bit 159 + * 7 (reserved) 160 + * VCAP_KF_LOOKUP_FIRST_IS: W1, sparx5: is2 161 + * Selects between entries relevant for first and second lookup. Set for first 162 + * lookup, cleared for second lookup. 163 + * VCAP_KF_LOOKUP_PAG: W8, sparx5: is2 164 + * Classified Policy Association Group: chains rules from IS1/CLM to IS2 165 + * VCAP_KF_OAM_CCM_CNTS_EQ0: W1, sparx5: is2 166 + * Dual-ended loss measurement counters in CCM frames are all zero 167 + * VCAP_KF_OAM_Y1731_IS: W1, sparx5: is2 168 + * Set if frame’s EtherType = 0x8902 169 + * VCAP_KF_TCP_IS: W1, sparx5: is2 170 + * Set if frame is IPv4 TCP frame (IP protocol = 6) or IPv6 TCP frames (Next 171 + * header = 6) 172 + * VCAP_KF_TCP_UDP_IS: W1, sparx5: is2 173 + * Set if frame is IPv4/IPv6 TCP or UDP frame (IP protocol/next header equals 6 174 + * or 17) 175 + * VCAP_KF_TYPE: sparx5 is2 W4, sparx5 is2 W2 176 + * Keyset type id - set by the API 177 + */ 178 + 179 + /* Keyfield names */ 180 + enum vcap_key_field { 181 + VCAP_KF_NO_VALUE, /* initial value */ 182 + VCAP_KF_8021Q_DEI_CLS, 183 + VCAP_KF_8021Q_PCP_CLS, 184 + VCAP_KF_8021Q_VID_CLS, 185 + VCAP_KF_8021Q_VLAN_TAGGED_IS, 186 + VCAP_KF_ARP_ADDR_SPACE_OK_IS, 187 + VCAP_KF_ARP_LEN_OK_IS, 188 + VCAP_KF_ARP_OPCODE, 189 + VCAP_KF_ARP_OPCODE_UNKNOWN_IS, 190 + VCAP_KF_ARP_PROTO_SPACE_OK_IS, 191 + VCAP_KF_ARP_SENDER_MATCH_IS, 192 + VCAP_KF_ARP_TGT_MATCH_IS, 193 + VCAP_KF_ETYPE, 194 + VCAP_KF_ETYPE_LEN_IS, 195 + VCAP_KF_IF_IGR_PORT_MASK, 196 + VCAP_KF_IF_IGR_PORT_MASK_L3, 197 + VCAP_KF_IF_IGR_PORT_MASK_RNG, 198 + VCAP_KF_IF_IGR_PORT_MASK_SEL, 199 + VCAP_KF_IP4_IS, 200 + VCAP_KF_ISDX_CLS, 201 + VCAP_KF_ISDX_GT0_IS, 202 + VCAP_KF_L2_BC_IS, 203 + VCAP_KF_L2_DMAC, 204 + VCAP_KF_L2_FWD_IS, 205 + VCAP_KF_L2_MC_IS, 206 + VCAP_KF_L2_PAYLOAD_ETYPE, 207 + VCAP_KF_L2_SMAC, 208 + VCAP_KF_L3_DIP_EQ_SIP_IS, 209 + VCAP_KF_L3_DST_IS, 210 + VCAP_KF_L3_FRAGMENT_TYPE, 211 + VCAP_KF_L3_FRAG_INVLD_L4_LEN, 212 + VCAP_KF_L3_IP4_DIP, 213 + VCAP_KF_L3_IP4_SIP, 214 + VCAP_KF_L3_IP6_DIP, 215 + VCAP_KF_L3_IP6_SIP, 216 + VCAP_KF_L3_IP_PROTO, 217 + VCAP_KF_L3_OPTIONS_IS, 218 + VCAP_KF_L3_PAYLOAD, 219 + VCAP_KF_L3_RT_IS, 220 + VCAP_KF_L3_TOS, 221 + VCAP_KF_L3_TTL_GT0, 222 + VCAP_KF_L4_ACK, 223 + VCAP_KF_L4_DPORT, 224 + VCAP_KF_L4_FIN, 225 + VCAP_KF_L4_PAYLOAD, 226 + VCAP_KF_L4_PSH, 227 + VCAP_KF_L4_RNG, 228 + VCAP_KF_L4_RST, 229 + VCAP_KF_L4_SEQUENCE_EQ0_IS, 230 + VCAP_KF_L4_SPORT, 231 + VCAP_KF_L4_SPORT_EQ_DPORT_IS, 232 + VCAP_KF_L4_SYN, 233 + VCAP_KF_L4_URG, 234 + VCAP_KF_LOOKUP_FIRST_IS, 235 + VCAP_KF_LOOKUP_PAG, 236 + VCAP_KF_OAM_CCM_CNTS_EQ0, 237 + VCAP_KF_OAM_Y1731_IS, 238 + VCAP_KF_TCP_IS, 239 + VCAP_KF_TCP_UDP_IS, 240 + VCAP_KF_TYPE, 241 + }; 242 + 243 + /* Actionset names with origin information */ 244 + enum vcap_actionfield_set { 245 + VCAP_AFS_NO_VALUE, /* initial value */ 246 + VCAP_AFS_BASE_TYPE, /* sparx5 is2 X3 */ 247 + }; 248 + 249 + /* List of actionfields with description 250 + * 251 + * VCAP_AF_CNT_ID: W12, sparx5: is2 252 + * Counter ID, used per lookup to index the 4K frame counters (ANA_ACL:CNT_TBL). 253 + * Multiple VCAP IS2 entries can use the same counter. 254 + * VCAP_AF_CPU_COPY_ENA: W1, sparx5: is2 255 + * Setting this bit to 1 causes all frames that hit this action to be copied to 256 + * the CPU extraction queue specified in CPU_QUEUE_NUM. 257 + * VCAP_AF_CPU_QUEUE_NUM: W3, sparx5: is2 258 + * CPU queue number. Used when CPU_COPY_ENA is set. 259 + * VCAP_AF_HIT_ME_ONCE: W1, sparx5: is2 260 + * Setting this bit to 1 causes the first frame that hits this action where the 261 + * HIT_CNT counter is zero to be copied to the CPU extraction queue specified in 262 + * CPU_QUEUE_NUM. The HIT_CNT counter is then incremented and any frames that 263 + * hit this action later are not copied to the CPU. To re-enable the HIT_ME_ONCE 264 + * functionality, the HIT_CNT counter must be cleared. 265 + * VCAP_AF_IGNORE_PIPELINE_CTRL: W1, sparx5: is2 266 + * Ignore ingress pipeline control. This enforces the use of the VCAP IS2 action 267 + * even when the pipeline control has terminated the frame before VCAP IS2. 268 + * VCAP_AF_INTR_ENA: W1, sparx5: is2 269 + * If set, an interrupt is triggered when this rule is hit 270 + * VCAP_AF_LRN_DIS: W1, sparx5: is2 271 + * Setting this bit to 1 disables learning of frames hitting this action. 272 + * VCAP_AF_MASK_MODE: W3, sparx5: is2 273 + * Controls the PORT_MASK use. Sparx5: 0: OR_DSTMASK, 1: AND_VLANMASK, 2: 274 + * REPLACE_PGID, 3: REPLACE_ALL, 4: REDIR_PGID, 5: OR_PGID_MASK, 6: VSTAX, 7: 275 + * Not applicable. LAN966X: 0: No action, 1: Permit/deny (AND), 2: Policy 276 + * forwarding (DMAC lookup), 3: Redirect. The CPU port is untouched by 277 + * MASK_MODE. 278 + * VCAP_AF_MATCH_ID: W16, sparx5: is2 279 + * Logical ID for the entry. The MATCH_ID is extracted together with the frame 280 + * if the frame is forwarded to the CPU (CPU_COPY_ENA). The result is placed in 281 + * IFH.CL_RSLT. 282 + * VCAP_AF_MATCH_ID_MASK: W16, sparx5: is2 283 + * Mask used by MATCH_ID. 284 + * VCAP_AF_MIRROR_PROBE: W2, sparx5: is2 285 + * Mirroring performed according to configuration of a mirror probe. 0: No 286 + * mirroring. 1: Mirror probe 0. 2: Mirror probe 1. 3: Mirror probe 2 287 + * VCAP_AF_PIPELINE_FORCE_ENA: W1, sparx5: is2 288 + * If set, use PIPELINE_PT unconditionally and set PIPELINE_ACT = NONE if 289 + * PIPELINE_PT == NONE. Overrules previous settings of pipeline point. 290 + * VCAP_AF_PIPELINE_PT: W5, sparx5: is2 291 + * Pipeline point used if PIPELINE_FORCE_ENA is set 292 + * VCAP_AF_POLICE_ENA: W1, sparx5: is2 293 + * Setting this bit to 1 causes frames that hit this action to be policed by the 294 + * ACL policer specified in POLICE_IDX. Only applies to the first lookup. 295 + * VCAP_AF_POLICE_IDX: W6, sparx5: is2 296 + * Selects VCAP policer used when policing frames (POLICE_ENA) 297 + * VCAP_AF_PORT_MASK: W68, sparx5: is2 298 + * Port mask applied to the forwarding decision based on MASK_MODE. 299 + * VCAP_AF_RT_DIS: W1, sparx5: is2 300 + * If set, routing is disallowed. Only applies when IS_INNER_ACL is 0. See also 301 + * IGR_ACL_ENA, EGR_ACL_ENA, and RLEG_STAT_IDX. 302 + */ 303 + 304 + /* Actionfield names */ 305 + enum vcap_action_field { 306 + VCAP_AF_NO_VALUE, /* initial value */ 307 + VCAP_AF_CNT_ID, 308 + VCAP_AF_CPU_COPY_ENA, 309 + VCAP_AF_CPU_QUEUE_NUM, 310 + VCAP_AF_HIT_ME_ONCE, 311 + VCAP_AF_IGNORE_PIPELINE_CTRL, 312 + VCAP_AF_INTR_ENA, 313 + VCAP_AF_LRN_DIS, 314 + VCAP_AF_MASK_MODE, 315 + VCAP_AF_MATCH_ID, 316 + VCAP_AF_MATCH_ID_MASK, 317 + VCAP_AF_MIRROR_PROBE, 318 + VCAP_AF_PIPELINE_FORCE_ENA, 319 + VCAP_AF_PIPELINE_PT, 320 + VCAP_AF_POLICE_ENA, 321 + VCAP_AF_POLICE_IDX, 322 + VCAP_AF_PORT_MASK, 323 + VCAP_AF_RT_DIS, 324 + }; 325 + 326 + #endif /* __VCAP_AG_API__ */
+269
drivers/net/ethernet/microchip/vcap/vcap_api.h
··· 1 + /* SPDX-License-Identifier: BSD-3-Clause */ 2 + /* Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries. 3 + * Microchip VCAP API 4 + */ 5 + 6 + #ifndef __VCAP_API__ 7 + #define __VCAP_API__ 8 + 9 + #include <linux/types.h> 10 + #include <linux/list.h> 11 + #include <linux/netdevice.h> 12 + 13 + /* Use the generated API model */ 14 + #include "vcap_ag_api.h" 15 + 16 + #define VCAP_CID_LOOKUP_SIZE 100000 /* Chains in a lookup */ 17 + #define VCAP_CID_INGRESS_L0 1000000 /* Ingress Stage 1 Lookup 0 */ 18 + #define VCAP_CID_INGRESS_L1 1100000 /* Ingress Stage 1 Lookup 1 */ 19 + #define VCAP_CID_INGRESS_L2 1200000 /* Ingress Stage 1 Lookup 2 */ 20 + #define VCAP_CID_INGRESS_L3 1300000 /* Ingress Stage 1 Lookup 3 */ 21 + #define VCAP_CID_INGRESS_L4 1400000 /* Ingress Stage 1 Lookup 4 */ 22 + #define VCAP_CID_INGRESS_L5 1500000 /* Ingress Stage 1 Lookup 5 */ 23 + 24 + #define VCAP_CID_PREROUTING_IPV6 3000000 /* Prerouting Stage */ 25 + #define VCAP_CID_PREROUTING 6000000 /* Prerouting Stage */ 26 + 27 + #define VCAP_CID_INGRESS_STAGE2_L0 8000000 /* Ingress Stage 2 Lookup 0 */ 28 + #define VCAP_CID_INGRESS_STAGE2_L1 8100000 /* Ingress Stage 2 Lookup 1 */ 29 + #define VCAP_CID_INGRESS_STAGE2_L2 8200000 /* Ingress Stage 2 Lookup 2 */ 30 + #define VCAP_CID_INGRESS_STAGE2_L3 8300000 /* Ingress Stage 2 Lookup 3 */ 31 + 32 + #define VCAP_CID_EGRESS_L0 10000000 /* Egress Lookup 0 */ 33 + #define VCAP_CID_EGRESS_L1 10100000 /* Egress Lookup 1 */ 34 + 35 + #define VCAP_CID_EGRESS_STAGE2_L0 20000000 /* Egress Stage 2 Lookup 0 */ 36 + #define VCAP_CID_EGRESS_STAGE2_L1 20100000 /* Egress Stage 2 Lookup 1 */ 37 + 38 + /* Known users of the VCAP API */ 39 + enum vcap_user { 40 + VCAP_USER_PTP, 41 + VCAP_USER_MRP, 42 + VCAP_USER_CFM, 43 + VCAP_USER_VLAN, 44 + VCAP_USER_QOS, 45 + VCAP_USER_VCAP_UTIL, 46 + VCAP_USER_TC, 47 + VCAP_USER_TC_EXTRA, 48 + 49 + /* add new users above here */ 50 + 51 + /* used to define VCAP_USER_MAX below */ 52 + __VCAP_USER_AFTER_LAST, 53 + VCAP_USER_MAX = __VCAP_USER_AFTER_LAST - 1, 54 + }; 55 + 56 + /* VCAP information used for displaying data */ 57 + struct vcap_statistics { 58 + char *name; 59 + int count; 60 + const char * const *keyfield_set_names; 61 + const char * const *actionfield_set_names; 62 + const char * const *keyfield_names; 63 + const char * const *actionfield_names; 64 + }; 65 + 66 + /* VCAP key/action field type, position and width */ 67 + struct vcap_field { 68 + u16 type; 69 + u16 width; 70 + u16 offset; 71 + }; 72 + 73 + /* VCAP keyset or actionset type and width */ 74 + struct vcap_set { 75 + u8 type_id; 76 + u8 sw_per_item; 77 + u8 sw_cnt; 78 + }; 79 + 80 + /* VCAP typegroup position and bitvalue */ 81 + struct vcap_typegroup { 82 + u16 offset; 83 + u16 width; 84 + u16 value; 85 + }; 86 + 87 + /* VCAP model data */ 88 + struct vcap_info { 89 + char *name; /* user-friendly name */ 90 + u16 rows; /* number of row in instance */ 91 + u16 sw_count; /* maximum subwords used per rule */ 92 + u16 sw_width; /* bits per subword in a keyset */ 93 + u16 sticky_width; /* sticky bits per rule */ 94 + u16 act_width; /* bits per subword in an actionset */ 95 + u16 default_cnt; /* number of default rules */ 96 + u16 require_cnt_dis; /* not used */ 97 + u16 version; /* vcap rtl version */ 98 + const struct vcap_set *keyfield_set; /* keysets */ 99 + int keyfield_set_size; /* number of keysets */ 100 + const struct vcap_set *actionfield_set; /* actionsets */ 101 + int actionfield_set_size; /* number of actionsets */ 102 + /* map of keys per keyset */ 103 + const struct vcap_field **keyfield_set_map; 104 + /* number of entries in the above map */ 105 + int *keyfield_set_map_size; 106 + /* map of actions per actionset */ 107 + const struct vcap_field **actionfield_set_map; 108 + /* number of entries in the above map */ 109 + int *actionfield_set_map_size; 110 + /* map of keyset typegroups per subword size */ 111 + const struct vcap_typegroup **keyfield_set_typegroups; 112 + /* map of actionset typegroups per subword size */ 113 + const struct vcap_typegroup **actionfield_set_typegroups; 114 + }; 115 + 116 + enum vcap_field_type { 117 + VCAP_FIELD_BIT, 118 + VCAP_FIELD_U32, 119 + VCAP_FIELD_U48, 120 + VCAP_FIELD_U56, 121 + VCAP_FIELD_U64, 122 + VCAP_FIELD_U72, 123 + VCAP_FIELD_U112, 124 + VCAP_FIELD_U128, 125 + }; 126 + 127 + /* VCAP rule data towards the VCAP cache */ 128 + struct vcap_cache_data { 129 + u32 *keystream; 130 + u32 *maskstream; 131 + u32 *actionstream; 132 + u32 counter; 133 + bool sticky; 134 + }; 135 + 136 + /* Selects which part of the rule must be updated */ 137 + enum vcap_selection { 138 + VCAP_SEL_ENTRY = 0x01, 139 + VCAP_SEL_ACTION = 0x02, 140 + VCAP_SEL_COUNTER = 0x04, 141 + VCAP_SEL_ALL = 0xff, 142 + }; 143 + 144 + /* Commands towards the VCAP cache */ 145 + enum vcap_command { 146 + VCAP_CMD_WRITE = 0, 147 + VCAP_CMD_READ = 1, 148 + VCAP_CMD_MOVE_DOWN = 2, 149 + VCAP_CMD_MOVE_UP = 3, 150 + VCAP_CMD_INITIALIZE = 4, 151 + }; 152 + 153 + enum vcap_rule_error { 154 + VCAP_ERR_NONE = 0, /* No known error */ 155 + VCAP_ERR_NO_ADMIN, /* No admin instance */ 156 + VCAP_ERR_NO_NETDEV, /* No netdev instance */ 157 + VCAP_ERR_NO_KEYSET_MATCH, /* No keyset matched the rule keys */ 158 + VCAP_ERR_NO_ACTIONSET_MATCH, /* No actionset matched the rule actions */ 159 + VCAP_ERR_NO_PORT_KEYSET_MATCH, /* No port keyset matched the rule keys */ 160 + }; 161 + 162 + /* Administration of each VCAP instance */ 163 + struct vcap_admin { 164 + struct list_head list; /* for insertion in vcap_control */ 165 + struct list_head rules; /* list of rules */ 166 + enum vcap_type vtype; /* type of vcap */ 167 + int vinst; /* instance number within the same type */ 168 + int first_cid; /* first chain id in this vcap */ 169 + int last_cid; /* last chain id in this vcap */ 170 + int tgt_inst; /* hardware instance number */ 171 + int lookups; /* number of lookups in this vcap type */ 172 + int lookups_per_instance; /* number of lookups in this instance */ 173 + int last_valid_addr; /* top of address range to be used */ 174 + int first_valid_addr; /* bottom of address range to be used */ 175 + int last_used_addr; /* address of lowest added rule */ 176 + bool w32be; /* vcap uses "32bit-word big-endian" encoding */ 177 + struct vcap_cache_data cache; /* encoded rule data */ 178 + }; 179 + 180 + /* Client supplied VCAP rule data */ 181 + struct vcap_rule { 182 + int vcap_chain_id; /* chain used for this rule */ 183 + enum vcap_user user; /* rule owner */ 184 + u16 priority; 185 + u32 id; /* vcap rule id, must be unique, 0 will auto-generate a value */ 186 + u64 cookie; /* used by the client to identify the rule */ 187 + struct list_head keyfields; /* list of vcap_client_keyfield */ 188 + struct list_head actionfields; /* list of vcap_client_actionfield */ 189 + enum vcap_keyfield_set keyset; /* keyset used: may be derived from fields */ 190 + enum vcap_actionfield_set actionset; /* actionset used: may be derived from fields */ 191 + enum vcap_rule_error exterr; /* extended error - used by TC */ 192 + u64 client; /* space for client defined data */ 193 + }; 194 + 195 + /* List of keysets */ 196 + struct vcap_keyset_list { 197 + int max; /* size of the keyset list */ 198 + int cnt; /* count of keysets actually in the list */ 199 + enum vcap_keyfield_set *keysets; /* the list of keysets */ 200 + }; 201 + 202 + /* Client supplied VCAP callback operations */ 203 + struct vcap_operations { 204 + /* validate port keyset operation */ 205 + enum vcap_keyfield_set (*validate_keyset) 206 + (struct net_device *ndev, 207 + struct vcap_admin *admin, 208 + struct vcap_rule *rule, 209 + struct vcap_keyset_list *kslist, 210 + u16 l3_proto); 211 + /* add default rule fields for the selected keyset operations */ 212 + void (*add_default_fields) 213 + (struct net_device *ndev, 214 + struct vcap_admin *admin, 215 + struct vcap_rule *rule); 216 + /* cache operations */ 217 + void (*cache_erase) 218 + (struct vcap_admin *admin); 219 + void (*cache_write) 220 + (struct net_device *ndev, 221 + struct vcap_admin *admin, 222 + enum vcap_selection sel, 223 + u32 idx, u32 count); 224 + void (*cache_read) 225 + (struct net_device *ndev, 226 + struct vcap_admin *admin, 227 + enum vcap_selection sel, 228 + u32 idx, 229 + u32 count); 230 + /* block operations */ 231 + void (*init) 232 + (struct net_device *ndev, 233 + struct vcap_admin *admin, 234 + u32 addr, 235 + u32 count); 236 + void (*update) 237 + (struct net_device *ndev, 238 + struct vcap_admin *admin, 239 + enum vcap_command cmd, 240 + enum vcap_selection sel, 241 + u32 addr); 242 + void (*move) 243 + (struct net_device *ndev, 244 + struct vcap_admin *admin, 245 + u32 addr, 246 + int offset, 247 + int count); 248 + /* informational */ 249 + int (*port_info) 250 + (struct net_device *ndev, 251 + enum vcap_type vtype, 252 + int (*pf)(void *out, int arg, const char *fmt, ...), 253 + void *out, 254 + int arg); 255 + }; 256 + 257 + /* VCAP API Client control interface */ 258 + struct vcap_control { 259 + u32 rule_id; /* last used rule id (unique across VCAP instances) */ 260 + struct vcap_operations *ops; /* client supplied operations */ 261 + const struct vcap_info *vcaps; /* client supplied vcap models */ 262 + const struct vcap_statistics *stats; /* client supplied vcap stats */ 263 + struct list_head list; /* list of vcap instances */ 264 + }; 265 + 266 + /* Set client control interface on the API */ 267 + int vcap_api_set_client(struct vcap_control *vctrl); 268 + 269 + #endif /* __VCAP_API__ */