Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2014, 2015 Netronome Systems, Inc. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #ifndef __NFP_NET_CTRL_H__ 7 : : #define __NFP_NET_CTRL_H__ 8 : : 9 : : #include <stdint.h> 10 : : 11 : : #include <ethdev_driver.h> 12 : : 13 : : #include <nfp_common_ctrl.h> 14 : : 15 : : /* 16 : : * Mac stats (0x0000 - 0x0200) 17 : : * All counters are 64bit. 18 : : */ 19 : : #define NFP_MAC_STATS_BASE 0x0000 20 : : #define NFP_MAC_STATS_SIZE 0x0200 21 : : 22 : : #define NFP_MAC_STATS_RX_IN_OCTS (NFP_MAC_STATS_BASE + 0x000) 23 : : #define NFP_MAC_STATS_RX_FRAME_TOO_LONG_ERRORS (NFP_MAC_STATS_BASE + 0x010) 24 : : #define NFP_MAC_STATS_RX_RANGE_LENGTH_ERRORS (NFP_MAC_STATS_BASE + 0x018) 25 : : #define NFP_MAC_STATS_RX_VLAN_RECEIVED_OK (NFP_MAC_STATS_BASE + 0x020) 26 : : #define NFP_MAC_STATS_RX_IN_ERRORS (NFP_MAC_STATS_BASE + 0x028) 27 : : #define NFP_MAC_STATS_RX_IN_BROADCAST_PKTS (NFP_MAC_STATS_BASE + 0x030) 28 : : #define NFP_MAC_STATS_RX_DROP_EVENTS (NFP_MAC_STATS_BASE + 0x038) 29 : : #define NFP_MAC_STATS_RX_ALIGNMENT_ERRORS (NFP_MAC_STATS_BASE + 0x040) 30 : : #define NFP_MAC_STATS_RX_PAUSE_MAC_CTRL_FRAMES (NFP_MAC_STATS_BASE + 0x048) 31 : : #define NFP_MAC_STATS_RX_FRAMES_RECEIVED_OK (NFP_MAC_STATS_BASE + 0x050) 32 : : #define NFP_MAC_STATS_RX_FRAME_CHECK_SEQ_ERRORS (NFP_MAC_STATS_BASE + 0x058) 33 : : #define NFP_MAC_STATS_RX_UNICAST_PKTS (NFP_MAC_STATS_BASE + 0x060) 34 : : #define NFP_MAC_STATS_RX_MULTICAST_PKTS (NFP_MAC_STATS_BASE + 0x068) 35 : : #define NFP_MAC_STATS_RX_PKTS (NFP_MAC_STATS_BASE + 0x070) 36 : : #define NFP_MAC_STATS_RX_UNDERSIZE_PKTS (NFP_MAC_STATS_BASE + 0x078) 37 : : #define NFP_MAC_STATS_RX_PKTS_64_OCTS (NFP_MAC_STATS_BASE + 0x080) 38 : : #define NFP_MAC_STATS_RX_PKTS_65_TO_127_OCTS (NFP_MAC_STATS_BASE + 0x088) 39 : : #define NFP_MAC_STATS_RX_PKTS_512_TO_1023_OCTS (NFP_MAC_STATS_BASE + 0x090) 40 : : #define NFP_MAC_STATS_RX_PKTS_1024_TO_1518_OCTS (NFP_MAC_STATS_BASE + 0x098) 41 : : #define NFP_MAC_STATS_RX_JABBERS (NFP_MAC_STATS_BASE + 0x0a0) 42 : : #define NFP_MAC_STATS_RX_FRAGMENTS (NFP_MAC_STATS_BASE + 0x0a8) 43 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS2 (NFP_MAC_STATS_BASE + 0x0b0) 44 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS3 (NFP_MAC_STATS_BASE + 0x0b8) 45 : : #define NFP_MAC_STATS_RX_PKTS_128_TO_255_OCTS (NFP_MAC_STATS_BASE + 0x0c0) 46 : : #define NFP_MAC_STATS_RX_PKTS_256_TO_511_OCTS (NFP_MAC_STATS_BASE + 0x0c8) 47 : : #define NFP_MAC_STATS_RX_PKTS_1519_TO_MAX_OCTS (NFP_MAC_STATS_BASE + 0x0d0) 48 : : #define NFP_MAC_STATS_RX_OVERSIZE_PKTS (NFP_MAC_STATS_BASE + 0x0d8) 49 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS0 (NFP_MAC_STATS_BASE + 0x0e0) 50 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS1 (NFP_MAC_STATS_BASE + 0x0e8) 51 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS4 (NFP_MAC_STATS_BASE + 0x0f0) 52 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS5 (NFP_MAC_STATS_BASE + 0x0f8) 53 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS6 (NFP_MAC_STATS_BASE + 0x100) 54 : : #define NFP_MAC_STATS_RX_PAUSE_FRAMES_CLASS7 (NFP_MAC_STATS_BASE + 0x108) 55 : : #define NFP_MAC_STATS_RX_MAC_CTRL_FRAMES_REC (NFP_MAC_STATS_BASE + 0x110) 56 : : #define NFP_MAC_STATS_RX_MAC_HEAD_DROP (NFP_MAC_STATS_BASE + 0x118) 57 : : #define NFP_MAC_STATS_TX_QUEUE_DROP (NFP_MAC_STATS_BASE + 0x138) 58 : : #define NFP_MAC_STATS_TX_OUT_OCTS (NFP_MAC_STATS_BASE + 0x140) 59 : : #define NFP_MAC_STATS_TX_VLAN_TRANSMITTED_OK (NFP_MAC_STATS_BASE + 0x150) 60 : : #define NFP_MAC_STATS_TX_OUT_ERRORS (NFP_MAC_STATS_BASE + 0x158) 61 : : #define NFP_MAC_STATS_TX_BROADCAST_PKTS (NFP_MAC_STATS_BASE + 0x160) 62 : : #define NFP_MAC_STATS_TX_PKTS_64_OCTS (NFP_MAC_STATS_BASE + 0x168) 63 : : #define NFP_MAC_STATS_TX_PKTS_256_TO_511_OCTS (NFP_MAC_STATS_BASE + 0x170) 64 : : #define NFP_MAC_STATS_TX_PKTS_512_TO_1023_OCTS (NFP_MAC_STATS_BASE + 0x178) 65 : : #define NFP_MAC_STATS_TX_PAUSE_MAC_CTRL_FRAMES (NFP_MAC_STATS_BASE + 0x180) 66 : : #define NFP_MAC_STATS_TX_FRAMES_TRANSMITTED_OK (NFP_MAC_STATS_BASE + 0x188) 67 : : #define NFP_MAC_STATS_TX_UNICAST_PKTS (NFP_MAC_STATS_BASE + 0x190) 68 : : #define NFP_MAC_STATS_TX_MULTICAST_PKTS (NFP_MAC_STATS_BASE + 0x198) 69 : : #define NFP_MAC_STATS_TX_PKTS_65_TO_127_OCTS (NFP_MAC_STATS_BASE + 0x1a0) 70 : : #define NFP_MAC_STATS_TX_PKTS_128_TO_255_OCTS (NFP_MAC_STATS_BASE + 0x1a8) 71 : : #define NFP_MAC_STATS_TX_PKTS_1024_TO_1518_OCTS (NFP_MAC_STATS_BASE + 0x1b0) 72 : : #define NFP_MAC_STATS_TX_PKTS_1519_TO_MAX_OCTS (NFP_MAC_STATS_BASE + 0x1b8) 73 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS0 (NFP_MAC_STATS_BASE + 0x1c0) 74 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS1 (NFP_MAC_STATS_BASE + 0x1c8) 75 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS4 (NFP_MAC_STATS_BASE + 0x1d0) 76 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS5 (NFP_MAC_STATS_BASE + 0x1d8) 77 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS2 (NFP_MAC_STATS_BASE + 0x1e0) 78 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS3 (NFP_MAC_STATS_BASE + 0x1e8) 79 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS6 (NFP_MAC_STATS_BASE + 0x1f0) 80 : : #define NFP_MAC_STATS_TX_PAUSE_FRAMES_CLASS7 (NFP_MAC_STATS_BASE + 0x1f8) 81 : : 82 : : /* 83 : : * General use mailbox area (0x1800 - 0x19ff) 84 : : * 4B used for update command and 4B return code followed by 85 : : * a max of 504B of variable length value. 86 : : */ 87 : : #define NFP_NET_CFG_MBOX_BASE 0x1800 88 : : #define NFP_NET_CFG_MBOX_VAL 0x1808 89 : : #define NFP_NET_CFG_MBOX_VAL_MAX_SZ 0x1F8 90 : : #define NFP_NET_CFG_MBOX_SIMPLE_CMD 0x0 91 : : #define NFP_NET_CFG_MBOX_SIMPLE_RET 0x4 92 : : #define NFP_NET_CFG_MBOX_SIMPLE_VAL 0x8 93 : : 94 : : #define NFP_NET_CFG_MBOX_CMD_IPSEC 3 95 : : #define NFP_NET_CFG_MBOX_CMD_FLOW_STEER 10 96 : : 97 : : /* 98 : : * TLV capabilities 99 : : * @NFP_NET_CFG_TLV_TYPE: Offset of type within the TLV 100 : : * @NFP_NET_CFG_TLV_TYPE_REQUIRED: Driver must be able to parse the TLV 101 : : * @NFP_NET_CFG_TLV_LENGTH: Offset of length within the TLV 102 : : * @NFP_NET_CFG_TLV_LENGTH_INC: TLV length increments 103 : : * @NFP_NET_CFG_TLV_VALUE: Offset of value with the TLV 104 : : * @NFP_NET_CFG_TLV_STATS_OFFSET: Length of TLV stats offset 105 : : * 106 : : * List of simple TLV structures, first one starts at @NFP_NET_CFG_TLV_BASE. 107 : : * Last structure must be of type @NFP_NET_CFG_TLV_TYPE_END. Presence of TLVs 108 : : * is indicated by @NFP_NET_CFG_TLV_BASE being non-zero. TLV structures may 109 : : * fill the entire remainder of the BAR or be shorter. FW must make sure TLVs 110 : : * don't conflict with other features which allocate space beyond 111 : : * @NFP_NET_CFG_TLV_BASE. @NFP_NET_CFG_TLV_TYPE_RESERVED should be used to wrap 112 : : * space used by such features. 113 : : * 114 : : * Note that the 4 byte TLV header is not counted in %NFP_NET_CFG_TLV_LENGTH. 115 : : */ 116 : : #define NFP_NET_CFG_TLV_TYPE 0x00 117 : : #define NFP_NET_CFG_TLV_TYPE_REQUIRED 0x8000 118 : : #define NFP_NET_CFG_TLV_LENGTH 0x02 119 : : #define NFP_NET_CFG_TLV_LENGTH_INC 4 120 : : #define NFP_NET_CFG_TLV_VALUE 0x04 121 : : #define NFP_NET_CFG_TLV_STATS_OFFSET 0x08 122 : : 123 : : #define NFP_NET_CFG_TLV_HEADER_REQUIRED 0x80000000 124 : : #define NFP_NET_CFG_TLV_HEADER_TYPE 0x7fff0000 125 : : #define NFP_NET_CFG_TLV_HEADER_LENGTH 0x0000ffff 126 : : 127 : : /* 128 : : * Capability TLV types 129 : : * 130 : : * @NFP_NET_CFG_TLV_TYPE_UNKNOWN: 131 : : * Special TLV type to catch bugs, should never be encountered. Drivers should 132 : : * treat encountering this type as error and refuse to probe. 133 : : * 134 : : * @NFP_NET_CFG_TLV_TYPE_RESERVED: 135 : : * Reserved space, may contain legacy fixed-offset fields, or be used for 136 : : * padding. The use of this type should be otherwise avoided. 137 : : * 138 : : * @NFP_NET_CFG_TLV_TYPE_END: 139 : : * Empty, end of TLV list. Must be the last TLV. Drivers will stop processing 140 : : * further TLVs when encountered. 141 : : * 142 : : * @NFP_NET_CFG_TLV_TYPE_ME_FREQ: 143 : : * Single word, ME frequency in MHz as used in calculation for 144 : : * @NFP_NET_CFG_RXR_IRQ_MOD and @NFP_NET_CFG_TXR_IRQ_MOD. 145 : : * 146 : : * @NFP_NET_CFG_TLV_TYPE_MBOX: 147 : : * Variable, mailbox area. Overwrites the default location which is 148 : : * @NFP_NET_CFG_MBOX_BASE and length @NFP_NET_CFG_MBOX_VAL_MAX_SZ. 149 : : * 150 : : * @NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL0: 151 : : * @NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL1: 152 : : * Variable, experimental IDs. IDs designated for internal development and 153 : : * experiments before a stable TLV ID has been allocated to a feature. Should 154 : : * never be present in production FW. 155 : : * 156 : : * @NFP_NET_CFG_TLV_TYPE_REPR_CAP: 157 : : * Single word, equivalent of %NFP_NET_CFG_CAP for representors, features which 158 : : * can be used on representors. 159 : : * 160 : : * @NFP_NET_CFG_TLV_TYPE_MBOX_CMSG_TYPES: 161 : : * Variable, bitmap of control message types supported by the mailbox handler. 162 : : * Bit 0 corresponds to message type 0, bit 1 to 1, etc. Control messages are 163 : : * encapsulated into simple TLVs, with an end TLV and written to the Mailbox. 164 : : * 165 : : * @NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS: 166 : : * 8 words, bitmaps of supported and enabled crypto operations. 167 : : * First 16B (4 words) contains a bitmap of supported crypto operations, 168 : : * and next 16B contain the enabled operations. 169 : : * This capability is obsoleted by ones with better sync methods. 170 : : * 171 : : * @NFP_NET_CFG_TLV_TYPE_VNIC_STATS: 172 : : * Variable, per-vNIC statistics, data should be 8B aligned (FW should insert 173 : : * zero-length RESERVED TLV to pad). 174 : : * TLV data has two sections. First is an array of statistics' IDs (2B each). 175 : : * Second 8B statistics themselves. Statistics are 8B aligned, meaning there 176 : : * may be a padding between sections. 177 : : * Number of statistics can be determined as floor(tlv.length / (2 + 8)). 178 : : * This TLV overwrites %NFP_NET_CFG_STATS_* values (statistics in this TLV 179 : : * duplicate the old ones, so driver should be careful not to unnecessarily 180 : : * render both). 181 : : * 182 : : * @NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS_RX_SCAN: 183 : : * Same as %NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS, but crypto TLS does stream scan 184 : : * RX sync, rather than kernel-assisted sync. 185 : : * 186 : : * @NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS_LENGTH: 187 : : * CRYPTO OPS TLV should be at least 32B. 188 : : */ 189 : : #define NFP_NET_CFG_TLV_TYPE_UNKNOWN 0 190 : : #define NFP_NET_CFG_TLV_TYPE_RESERVED 1 191 : : #define NFP_NET_CFG_TLV_TYPE_END 2 192 : : #define NFP_NET_CFG_TLV_TYPE_MBOX 4 193 : : #define NFP_NET_CFG_TLV_TYPE_MBOX_CMSG_TYPES 10 194 : : 195 : : int nfp_net_tlv_caps_parse(struct rte_eth_dev *dev); 196 : : 197 : : /** 198 : : * Get RSS flag based on firmware's capability 199 : : * 200 : : * @param hw_cap 201 : : * The firmware's capabilities 202 : : */ 203 : : static inline uint32_t 204 : : nfp_net_cfg_ctrl_rss(uint32_t hw_cap) 205 : : { 206 [ # # ]: 0 : if ((hw_cap & NFP_NET_CFG_CTRL_RSS2) != 0) 207 : 0 : return NFP_NET_CFG_CTRL_RSS2; 208 : : 209 : : return NFP_NET_CFG_CTRL_RSS; 210 : : } 211 : : 212 : : #endif /* __NFP_NET_CTRL_H__ */