at commit c03c1a14
| 1 | /* Broadcom NetXtreme-C/E network driver. |
| 2 | * |
| 3 | * Copyright (c) 2014-2016 Broadcom Corporation |
| 4 | * Copyright (c) 2016-2018 Broadcom Limited |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #ifndef BNXT_H |
| 12 | #define BNXT_H |
| 13 | |
| 14 | #include <net/tso.h> |
| 15 | |
| 16 | #define DRV_MODULE_NAME "bnxt_en" |
| 17 | |
| 18 | /* DO NOT CHANGE DRV_VER_* defines |
| 19 | * FIXME: Delete them |
| 20 | */ |
| 21 | #define DRV_VER_MAJ 1 |
| 22 | #define DRV_VER_MIN 10 |
| 23 | #define DRV_VER_UPD 3 |
| 24 | |
| 25 | #include <linux/ethtool.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/rhashtable.h> |
| 28 | #include <linux/crash_dump.h> |
| 29 | #include <net/devlink.h> |
| 30 | #include <net/dst_metadata.h> |
| 31 | #include <net/xdp.h> |
| 32 | #include <linux/dim.h> |
| 33 | #include <linux/io-64-nonatomic-lo-hi.h> |
| 34 | #include <linux/bnxt/ulp.h> |
| 35 | #ifdef CONFIG_TEE_BNXT_FW |
| 36 | #include <linux/firmware/broadcom/tee_bnxt_fw.h> |
| 37 | #endif |
| 38 | |
| 39 | #define BNXT_MIN_RX_HDR_BUF 256 |
| 40 | #define BNXT_MAX_RX_HDR_BUF 1024 |
| 41 | |
| 42 | extern struct list_head bnxt_block_cb_list; |
| 43 | |
| 44 | struct page_pool; |
| 45 | |
| 46 | struct tx_bd { |
| 47 | __le32 tx_bd_len_flags_type; |
| 48 | #define TX_BD_TYPE (0x3f << 0) |
| 49 | #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0) |
| 50 | #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0) |
| 51 | #define TX_BD_FLAGS_PACKET_END (1 << 6) |
| 52 | #define TX_BD_FLAGS_NO_CMPL (1 << 7) |
| 53 | #define TX_BD_FLAGS_BD_CNT (0x1f << 8) |
| 54 | #define TX_BD_FLAGS_BD_CNT_SHIFT 8 |
| 55 | #define TX_BD_FLAGS_LHINT (3 << 13) |
| 56 | #define TX_BD_FLAGS_LHINT_SHIFT 13 |
| 57 | #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13) |
| 58 | #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13) |
| 59 | #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13) |
| 60 | #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13) |
| 61 | #define TX_BD_FLAGS_COAL_NOW (1 << 15) |
| 62 | #define TX_BD_LEN (0xffff << 16) |
| 63 | #define TX_BD_LEN_SHIFT 16 |
| 64 | |
| 65 | u32 tx_bd_opaque; |
| 66 | __le64 tx_bd_haddr; |
| 67 | } __packed; |
| 68 | |
| 69 | #define TX_OPAQUE_IDX_MASK 0x0000ffff |
| 70 | #define TX_OPAQUE_BDS_MASK 0x00ff0000 |
| 71 | #define TX_OPAQUE_BDS_SHIFT 16 |
| 72 | #define TX_OPAQUE_RING_MASK 0xff000000 |
| 73 | #define TX_OPAQUE_RING_SHIFT 24 |
| 74 | |
| 75 | #define SET_TX_OPAQUE(bp, txr, idx, bds) \ |
| 76 | (((txr)->tx_napi_idx << TX_OPAQUE_RING_SHIFT) | \ |
| 77 | ((bds) << TX_OPAQUE_BDS_SHIFT) | ((idx) & (bp)->tx_ring_mask)) |
| 78 | |
| 79 | #define TX_OPAQUE_IDX(opq) ((opq) & TX_OPAQUE_IDX_MASK) |
| 80 | #define TX_OPAQUE_RING(opq) (((opq) & TX_OPAQUE_RING_MASK) >> \ |
| 81 | TX_OPAQUE_RING_SHIFT) |
| 82 | #define TX_OPAQUE_BDS(opq) (((opq) & TX_OPAQUE_BDS_MASK) >> \ |
| 83 | TX_OPAQUE_BDS_SHIFT) |
| 84 | #define TX_OPAQUE_PROD(bp, opq) ((TX_OPAQUE_IDX(opq) + TX_OPAQUE_BDS(opq)) &\ |
| 85 | (bp)->tx_ring_mask) |
| 86 | |
| 87 | #define TX_BD_CNT(n) (((n) << TX_BD_FLAGS_BD_CNT_SHIFT) & TX_BD_FLAGS_BD_CNT) |
| 88 | |
| 89 | #define TX_MAX_BD_CNT 32 |
| 90 | |
| 91 | #define TX_MAX_FRAGS (TX_MAX_BD_CNT - 2) |
| 92 | |
| 93 | struct tx_bd_ext { |
| 94 | __le32 tx_bd_hsize_lflags; |
| 95 | #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0) |
| 96 | #define TX_BD_FLAGS_IP_CKSUM (1 << 1) |
| 97 | #define TX_BD_FLAGS_NO_CRC (1 << 2) |
| 98 | #define TX_BD_FLAGS_STAMP (1 << 3) |
| 99 | #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4) |
| 100 | #define TX_BD_FLAGS_LSO (1 << 5) |
| 101 | #define TX_BD_FLAGS_IPID_FMT (1 << 6) |
| 102 | #define TX_BD_FLAGS_T_IPID (1 << 7) |
| 103 | #define TX_BD_HSIZE (0xff << 16) |
| 104 | #define TX_BD_HSIZE_SHIFT 16 |
| 105 | |
| 106 | __le32 tx_bd_mss; |
| 107 | __le32 tx_bd_cfa_action; |
| 108 | #define TX_BD_CFA_ACTION (0xffff << 16) |
| 109 | #define TX_BD_CFA_ACTION_SHIFT 16 |
| 110 | |
| 111 | __le32 tx_bd_cfa_meta; |
| 112 | #define TX_BD_CFA_META_MASK 0xfffffff |
| 113 | #define TX_BD_CFA_META_VID_MASK 0xfff |
| 114 | #define TX_BD_CFA_META_PRI_MASK (0xf << 12) |
| 115 | #define TX_BD_CFA_META_PRI_SHIFT 12 |
| 116 | #define TX_BD_CFA_META_TPID_MASK (3 << 16) |
| 117 | #define TX_BD_CFA_META_TPID_SHIFT 16 |
| 118 | #define TX_BD_CFA_META_KEY (0xf << 28) |
| 119 | #define TX_BD_CFA_META_KEY_SHIFT 28 |
| 120 | #define TX_BD_CFA_META_KEY_VLAN (1 << 28) |
| 121 | }; |
| 122 | |
| 123 | #define BNXT_TX_PTP_IS_SET(lflags) ((lflags) & cpu_to_le32(TX_BD_FLAGS_STAMP)) |
| 124 | |
| 125 | struct rx_bd { |
| 126 | __le32 rx_bd_len_flags_type; |
| 127 | #define RX_BD_TYPE (0x3f << 0) |
| 128 | #define RX_BD_TYPE_RX_PACKET_BD 0x4 |
| 129 | #define RX_BD_TYPE_RX_BUFFER_BD 0x5 |
| 130 | #define RX_BD_TYPE_RX_AGG_BD 0x6 |
| 131 | #define RX_BD_TYPE_16B_BD_SIZE (0 << 4) |
| 132 | #define RX_BD_TYPE_32B_BD_SIZE (1 << 4) |
| 133 | #define RX_BD_TYPE_48B_BD_SIZE (2 << 4) |
| 134 | #define RX_BD_TYPE_64B_BD_SIZE (3 << 4) |
| 135 | #define RX_BD_FLAGS_SOP (1 << 6) |
| 136 | #define RX_BD_FLAGS_AGG_EOP (1 << 6) |
| 137 | #define RX_BD_FLAGS_EOP (1 << 7) |
| 138 | #define RX_BD_FLAGS_BUFFERS (3 << 8) |
| 139 | #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8) |
| 140 | #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8) |
| 141 | #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8) |
| 142 | #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8) |
| 143 | #define RX_BD_LEN (0xffff << 16) |
| 144 | #define RX_BD_LEN_SHIFT 16 |
| 145 | |
| 146 | u32 rx_bd_opaque; |
| 147 | __le64 rx_bd_haddr; |
| 148 | }; |
| 149 | |
| 150 | struct tx_cmp { |
| 151 | __le32 tx_cmp_flags_type; |
| 152 | #define CMP_TYPE (0x3f << 0) |
| 153 | #define CMP_TYPE_TX_L2_CMP 0 |
| 154 | #define CMP_TYPE_TX_L2_COAL_CMP 2 |
| 155 | #define CMP_TYPE_TX_L2_PKT_TS_CMP 4 |
| 156 | #define CMP_TYPE_RX_L2_CMP 17 |
| 157 | #define CMP_TYPE_RX_AGG_CMP 18 |
| 158 | #define CMP_TYPE_RX_L2_TPA_START_CMP 19 |
| 159 | #define CMP_TYPE_RX_L2_TPA_END_CMP 21 |
| 160 | #define CMP_TYPE_RX_TPA_AGG_CMP 22 |
| 161 | #define CMP_TYPE_RX_L2_V3_CMP 23 |
| 162 | #define CMP_TYPE_RX_L2_TPA_START_V3_CMP 25 |
| 163 | #define CMP_TYPE_STATUS_CMP 32 |
| 164 | #define CMP_TYPE_REMOTE_DRIVER_REQ 34 |
| 165 | #define CMP_TYPE_REMOTE_DRIVER_RESP 36 |
| 166 | #define CMP_TYPE_ERROR_STATUS 48 |
| 167 | #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL |
| 168 | #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL |
| 169 | #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL |
| 170 | #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL |
| 171 | #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL |
| 172 | |
| 173 | #define TX_CMP_FLAGS_ERROR (1 << 6) |
| 174 | #define TX_CMP_FLAGS_PUSH (1 << 7) |
| 175 | |
| 176 | u32 tx_cmp_opaque; |
| 177 | __le32 tx_cmp_errors_v; |
| 178 | #define TX_CMP_V (1 << 0) |
| 179 | #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1) |
| 180 | #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0 |
| 181 | #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2 |
| 182 | #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4 |
| 183 | #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5 |
| 184 | #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4) |
| 185 | #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5) |
| 186 | #define TX_CMP_ERRORS_DMA_ERROR (1 << 6) |
| 187 | #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7) |
| 188 | |
| 189 | __le32 sq_cons_idx; |
| 190 | #define TX_CMP_SQ_CONS_IDX_MASK 0x00ffffff |
| 191 | }; |
| 192 | |
| 193 | #define TX_CMP_SQ_CONS_IDX(txcmp) \ |
| 194 | (le32_to_cpu((txcmp)->sq_cons_idx) & TX_CMP_SQ_CONS_IDX_MASK) |
| 195 | |
| 196 | struct tx_ts_cmp { |
| 197 | __le32 tx_ts_cmp_flags_type; |
| 198 | #define TX_TS_CMP_FLAGS_ERROR (1 << 6) |
| 199 | #define TX_TS_CMP_FLAGS_TS_TYPE (1 << 7) |
| 200 | #define TX_TS_CMP_FLAGS_TS_TYPE_PM (0 << 7) |
| 201 | #define TX_TS_CMP_FLAGS_TS_TYPE_PA (1 << 7) |
| 202 | #define TX_TS_CMP_FLAGS_TS_FALLBACK (1 << 8) |
| 203 | #define TX_TS_CMP_TS_SUB_NS (0xf << 12) |
| 204 | #define TX_TS_CMP_TS_NS_MID (0xffff << 16) |
| 205 | #define TX_TS_CMP_TS_NS_MID_SFT 16 |
| 206 | u32 tx_ts_cmp_opaque; |
| 207 | __le32 tx_ts_cmp_errors_v; |
| 208 | #define TX_TS_CMP_V (1 << 0) |
| 209 | #define TX_TS_CMP_TS_INVALID_ERR (1 << 10) |
| 210 | __le32 tx_ts_cmp_ts_ns_lo; |
| 211 | }; |
| 212 | |
| 213 | #define BNXT_GET_TX_TS_48B_NS(tscmp) \ |
| 214 | (le32_to_cpu((tscmp)->tx_ts_cmp_ts_ns_lo) | \ |
| 215 | ((u64)(le32_to_cpu((tscmp)->tx_ts_cmp_flags_type) & \ |
| 216 | TX_TS_CMP_TS_NS_MID) << TX_TS_CMP_TS_NS_MID_SFT)) |
| 217 | |
| 218 | #define BNXT_TX_TS_ERR(tscmp) \ |
| 219 | (((tscmp)->tx_ts_cmp_flags_type & cpu_to_le32(TX_TS_CMP_FLAGS_ERROR)) &&\ |
| 220 | ((tscmp)->tx_ts_cmp_errors_v & cpu_to_le32(TX_TS_CMP_TS_INVALID_ERR))) |
| 221 | |
| 222 | struct rx_cmp { |
| 223 | __le32 rx_cmp_len_flags_type; |
| 224 | #define RX_CMP_CMP_TYPE (0x3f << 0) |
| 225 | #define RX_CMP_FLAGS_ERROR (1 << 6) |
| 226 | #define RX_CMP_FLAGS_PLACEMENT (7 << 7) |
| 227 | #define RX_CMP_FLAGS_RSS_VALID (1 << 10) |
| 228 | #define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11) |
| 229 | #define RX_CMP_FLAGS_ITYPES_SHIFT 12 |
| 230 | #define RX_CMP_FLAGS_ITYPES_MASK 0xf000 |
| 231 | #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12) |
| 232 | #define RX_CMP_FLAGS_ITYPE_IP (1 << 12) |
| 233 | #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12) |
| 234 | #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12) |
| 235 | #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12) |
| 236 | #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12) |
| 237 | #define RX_CMP_FLAGS_ITYPE_ICMP (7 << 12) |
| 238 | #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12) |
| 239 | #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12) |
| 240 | #define RX_CMP_LEN (0xffff << 16) |
| 241 | #define RX_CMP_LEN_SHIFT 16 |
| 242 | |
| 243 | u32 rx_cmp_opaque; |
| 244 | __le32 rx_cmp_misc_v1; |
| 245 | #define RX_CMP_V1 (1 << 0) |
| 246 | #define RX_CMP_AGG_BUFS (0x1f << 1) |
| 247 | #define RX_CMP_AGG_BUFS_SHIFT 1 |
| 248 | #define RX_CMP_RSS_HASH_TYPE (0x7f << 9) |
| 249 | #define RX_CMP_RSS_HASH_TYPE_SHIFT 9 |
| 250 | #define RX_CMP_V3_RSS_EXT_OP_LEGACY (0xf << 12) |
| 251 | #define RX_CMP_V3_RSS_EXT_OP_LEGACY_SHIFT 12 |
| 252 | #define RX_CMP_V3_RSS_EXT_OP_NEW (0xf << 8) |
| 253 | #define RX_CMP_V3_RSS_EXT_OP_NEW_SHIFT 8 |
| 254 | #define RX_CMP_PAYLOAD_OFFSET (0xff << 16) |
| 255 | #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16 |
| 256 | #define RX_CMP_SUB_NS_TS (0xf << 16) |
| 257 | #define RX_CMP_SUB_NS_TS_SHIFT 16 |
| 258 | #define RX_CMP_METADATA1 (0xf << 28) |
| 259 | #define RX_CMP_METADATA1_SHIFT 28 |
| 260 | #define RX_CMP_METADATA1_TPID_SEL (0x7 << 28) |
| 261 | #define RX_CMP_METADATA1_TPID_8021Q (0x1 << 28) |
| 262 | #define RX_CMP_METADATA1_TPID_8021AD (0x0 << 28) |
| 263 | #define RX_CMP_METADATA1_VALID (0x8 << 28) |
| 264 | |
| 265 | __le32 rx_cmp_rss_hash; |
| 266 | }; |
| 267 | |
| 268 | #define BNXT_PTP_RX_TS_VALID(flags) \ |
| 269 | (((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS) |
| 270 | |
| 271 | #define BNXT_ALL_RX_TS_VALID(flags) \ |
| 272 | !((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT) |
| 273 | |
| 274 | #define RX_CMP_HASH_VALID(rxcmp) \ |
| 275 | ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID)) |
| 276 | |
| 277 | #define RSS_PROFILE_ID_MASK 0x1f |
| 278 | |
| 279 | #define RX_CMP_HASH_TYPE(rxcmp) \ |
| 280 | (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\ |
| 281 | RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) |
| 282 | |
| 283 | #define RX_CMP_ITYPES(rxcmp) \ |
| 284 | (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_FLAGS_ITYPES_MASK) |
| 285 | |
| 286 | #define RX_CMP_V3_HASH_TYPE_LEGACY(rxcmp) \ |
| 287 | ((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_V3_RSS_EXT_OP_LEGACY) >>\ |
| 288 | RX_CMP_V3_RSS_EXT_OP_LEGACY_SHIFT) |
| 289 | |
| 290 | #define RX_CMP_V3_HASH_TYPE_NEW(rxcmp) \ |
| 291 | ((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_V3_RSS_EXT_OP_NEW) >>\ |
| 292 | RX_CMP_V3_RSS_EXT_OP_NEW_SHIFT) |
| 293 | |
| 294 | #define RX_CMP_V3_HASH_TYPE(bp, rxcmp) \ |
| 295 | (((bp)->rss_cap & BNXT_RSS_CAP_RSS_TCAM) ? \ |
| 296 | RX_CMP_V3_HASH_TYPE_NEW(rxcmp) : \ |
| 297 | RX_CMP_V3_HASH_TYPE_LEGACY(rxcmp)) |
| 298 | |
| 299 | #define EXT_OP_INNER_4 0x0 |
| 300 | #define EXT_OP_OUTER_4 0x2 |
| 301 | #define EXT_OP_INNFL_3 0x8 |
| 302 | #define EXT_OP_OUTFL_3 0xa |
| 303 | |
| 304 | #define RX_CMP_VLAN_VALID(rxcmp) \ |
| 305 | ((rxcmp)->rx_cmp_misc_v1 & cpu_to_le32(RX_CMP_METADATA1_VALID)) |
| 306 | |
| 307 | #define RX_CMP_VLAN_TPID_SEL(rxcmp) \ |
| 308 | (le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_METADATA1_TPID_SEL) |
| 309 | |
| 310 | struct rx_cmp_ext { |
| 311 | __le32 rx_cmp_flags2; |
| 312 | #define RX_CMP_FLAGS2_IP_CS_CALC 0x1 |
| 313 | #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1) |
| 314 | #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2) |
| 315 | #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) |
| 316 | #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) |
| 317 | #define RX_CMP_FLAGS2_IP_TYPE (0x1 << 8) |
| 318 | __le32 rx_cmp_meta_data; |
| 319 | #define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff |
| 320 | #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff |
| 321 | #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000 |
| 322 | #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16 |
| 323 | __le32 rx_cmp_cfa_code_errors_v2; |
| 324 | #define RX_CMP_V (1 << 0) |
| 325 | #define RX_CMPL_ERRORS_MASK (0x7fff << 1) |
| 326 | #define RX_CMPL_ERRORS_SFT 1 |
| 327 | #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1) |
| 328 | #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) |
| 329 | #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1) |
| 330 | #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1) |
| 331 | #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) |
| 332 | #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4) |
| 333 | #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5) |
| 334 | #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6) |
| 335 | #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7) |
| 336 | #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8) |
| 337 | #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9) |
| 338 | #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9) |
| 339 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9) |
| 340 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9) |
| 341 | #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9) |
| 342 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9) |
| 343 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9) |
| 344 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9) |
| 345 | #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12) |
| 346 | #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12) |
| 347 | #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12) |
| 348 | #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12) |
| 349 | #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12) |
| 350 | #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12) |
| 351 | #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12) |
| 352 | #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12) |
| 353 | #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12) |
| 354 | #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12) |
| 355 | |
| 356 | #define RX_CMPL_CFA_CODE_MASK (0xffff << 16) |
| 357 | #define RX_CMPL_CFA_CODE_SFT 16 |
| 358 | #define RX_CMPL_METADATA0_TCI_MASK (0xffff << 16) |
| 359 | #define RX_CMPL_METADATA0_VID_MASK (0x0fff << 16) |
| 360 | #define RX_CMPL_METADATA0_SFT 16 |
| 361 | |
| 362 | __le32 rx_cmp_timestamp; |
| 363 | }; |
| 364 | |
| 365 | #define RX_CMP_L2_ERRORS \ |
| 366 | cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR) |
| 367 | |
| 368 | #define RX_CMP_L4_CS_BITS \ |
| 369 | (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC)) |
| 370 | |
| 371 | #define RX_CMP_L4_CS_ERR_BITS \ |
| 372 | (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR)) |
| 373 | |
| 374 | #define RX_CMP_L4_CS_OK(rxcmp1) \ |
| 375 | (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \ |
| 376 | !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS)) |
| 377 | |
| 378 | #define RX_CMP_ENCAP(rxcmp1) \ |
| 379 | ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \ |
| 380 | RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3) |
| 381 | |
| 382 | #define RX_CMP_CFA_CODE(rxcmpl1) \ |
| 383 | ((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) & \ |
| 384 | RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT) |
| 385 | |
| 386 | #define RX_CMP_METADATA0_TCI(rxcmp1) \ |
| 387 | ((le32_to_cpu((rxcmp1)->rx_cmp_cfa_code_errors_v2) & \ |
| 388 | RX_CMPL_METADATA0_TCI_MASK) >> RX_CMPL_METADATA0_SFT) |
| 389 | |
| 390 | struct rx_agg_cmp { |
| 391 | __le32 rx_agg_cmp_len_flags_type; |
| 392 | #define RX_AGG_CMP_TYPE (0x3f << 0) |
| 393 | #define RX_AGG_CMP_LEN (0xffff << 16) |
| 394 | #define RX_AGG_CMP_LEN_SHIFT 16 |
| 395 | u32 rx_agg_cmp_opaque; |
| 396 | __le32 rx_agg_cmp_v; |
| 397 | #define RX_AGG_CMP_V (1 << 0) |
| 398 | #define RX_AGG_CMP_AGG_ID (0x0fff << 16) |
| 399 | #define RX_AGG_CMP_AGG_ID_SHIFT 16 |
| 400 | __le32 rx_agg_cmp_unused; |
| 401 | }; |
| 402 | |
| 403 | #define TPA_AGG_AGG_ID(rx_agg) \ |
| 404 | ((le32_to_cpu((rx_agg)->rx_agg_cmp_v) & \ |
| 405 | RX_AGG_CMP_AGG_ID) >> RX_AGG_CMP_AGG_ID_SHIFT) |
| 406 | |
| 407 | struct rx_tpa_start_cmp { |
| 408 | __le32 rx_tpa_start_cmp_len_flags_type; |
| 409 | #define RX_TPA_START_CMP_TYPE (0x3f << 0) |
| 410 | #define RX_TPA_START_CMP_FLAGS (0x3ff << 6) |
| 411 | #define RX_TPA_START_CMP_FLAGS_SHIFT 6 |
| 412 | #define RX_TPA_START_CMP_FLAGS_ERROR (0x1 << 6) |
| 413 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7) |
| 414 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7 |
| 415 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7) |
| 416 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7) |
| 417 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7) |
| 418 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7) |
| 419 | #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10) |
| 420 | #define RX_TPA_START_CMP_FLAGS_TIMESTAMP (0x1 << 11) |
| 421 | #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12) |
| 422 | #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12 |
| 423 | #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12) |
| 424 | #define RX_TPA_START_CMP_LEN (0xffff << 16) |
| 425 | #define RX_TPA_START_CMP_LEN_SHIFT 16 |
| 426 | |
| 427 | u32 rx_tpa_start_cmp_opaque; |
| 428 | __le32 rx_tpa_start_cmp_misc_v1; |
| 429 | #define RX_TPA_START_CMP_V1 (0x1 << 0) |
| 430 | #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9) |
| 431 | #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9 |
| 432 | #define RX_TPA_START_CMP_V3_RSS_HASH_TYPE (0x1ff << 7) |
| 433 | #define RX_TPA_START_CMP_V3_RSS_HASH_TYPE_SHIFT 7 |
| 434 | #define RX_TPA_START_CMP_AGG_ID (0x7f << 25) |
| 435 | #define RX_TPA_START_CMP_AGG_ID_SHIFT 25 |
| 436 | #define RX_TPA_START_CMP_AGG_ID_P5 (0x0fff << 16) |
| 437 | #define RX_TPA_START_CMP_AGG_ID_SHIFT_P5 16 |
| 438 | #define RX_TPA_START_CMP_METADATA1 (0xf << 28) |
| 439 | #define RX_TPA_START_CMP_METADATA1_SHIFT 28 |
| 440 | #define RX_TPA_START_METADATA1_TPID_SEL (0x7 << 28) |
| 441 | #define RX_TPA_START_METADATA1_TPID_8021Q (0x1 << 28) |
| 442 | #define RX_TPA_START_METADATA1_TPID_8021AD (0x0 << 28) |
| 443 | #define RX_TPA_START_METADATA1_VALID (0x8 << 28) |
| 444 | |
| 445 | __le32 rx_tpa_start_cmp_rss_hash; |
| 446 | }; |
| 447 | |
| 448 | #define TPA_START_HASH_VALID(rx_tpa_start) \ |
| 449 | ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \ |
| 450 | cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID)) |
| 451 | |
| 452 | #define TPA_START_HASH_TYPE(rx_tpa_start) \ |
| 453 | (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 454 | RX_TPA_START_CMP_RSS_HASH_TYPE) >> \ |
| 455 | RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) |
| 456 | |
| 457 | #define TPA_START_V3_HASH_TYPE(rx_tpa_start) \ |
| 458 | (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 459 | RX_TPA_START_CMP_V3_RSS_HASH_TYPE) >> \ |
| 460 | RX_TPA_START_CMP_V3_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) |
| 461 | |
| 462 | #define TPA_START_AGG_ID(rx_tpa_start) \ |
| 463 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 464 | RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT) |
| 465 | |
| 466 | #define TPA_START_AGG_ID_P5(rx_tpa_start) \ |
| 467 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 468 | RX_TPA_START_CMP_AGG_ID_P5) >> RX_TPA_START_CMP_AGG_ID_SHIFT_P5) |
| 469 | |
| 470 | #define TPA_START_ERROR(rx_tpa_start) \ |
| 471 | ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \ |
| 472 | cpu_to_le32(RX_TPA_START_CMP_FLAGS_ERROR)) |
| 473 | |
| 474 | #define TPA_START_VLAN_VALID(rx_tpa_start) \ |
| 475 | ((rx_tpa_start)->rx_tpa_start_cmp_misc_v1 & \ |
| 476 | cpu_to_le32(RX_TPA_START_METADATA1_VALID)) |
| 477 | |
| 478 | #define TPA_START_VLAN_TPID_SEL(rx_tpa_start) \ |
| 479 | (le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 480 | RX_TPA_START_METADATA1_TPID_SEL) |
| 481 | |
| 482 | struct rx_tpa_start_cmp_ext { |
| 483 | __le32 rx_tpa_start_cmp_flags2; |
| 484 | #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0) |
| 485 | #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1) |
| 486 | #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2) |
| 487 | #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) |
| 488 | #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8) |
| 489 | #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_VALID (0x1 << 9) |
| 490 | #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT (0x3 << 10) |
| 491 | #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT_SHIFT 10 |
| 492 | #define RX_TPA_START_CMP_V3_FLAGS2_T_IP_TYPE (0x1 << 10) |
| 493 | #define RX_TPA_START_CMP_V3_FLAGS2_AGG_GRO (0x1 << 11) |
| 494 | #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL (0xffff << 16) |
| 495 | #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_SHIFT 16 |
| 496 | |
| 497 | __le32 rx_tpa_start_cmp_metadata; |
| 498 | __le32 rx_tpa_start_cmp_cfa_code_v2; |
| 499 | #define RX_TPA_START_CMP_V2 (0x1 << 0) |
| 500 | #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK (0x7 << 1) |
| 501 | #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT 1 |
| 502 | #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) |
| 503 | #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) |
| 504 | #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1) |
| 505 | #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16) |
| 506 | #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16 |
| 507 | #define RX_TPA_START_CMP_METADATA0_TCI_MASK (0xffff << 16) |
| 508 | #define RX_TPA_START_CMP_METADATA0_VID_MASK (0x0fff << 16) |
| 509 | #define RX_TPA_START_CMP_METADATA0_SFT 16 |
| 510 | __le32 rx_tpa_start_cmp_hdr_info; |
| 511 | }; |
| 512 | |
| 513 | #define TPA_START_CFA_CODE(rx_tpa_start) \ |
| 514 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ |
| 515 | RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT) |
| 516 | |
| 517 | #define TPA_START_IS_IPV6(rx_tpa_start) \ |
| 518 | (!!((rx_tpa_start)->rx_tpa_start_cmp_flags2 & \ |
| 519 | cpu_to_le32(RX_TPA_START_CMP_FLAGS2_IP_TYPE))) |
| 520 | |
| 521 | #define TPA_START_ERROR_CODE(rx_tpa_start) \ |
| 522 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ |
| 523 | RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK) >> \ |
| 524 | RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT) |
| 525 | |
| 526 | #define TPA_START_METADATA0_TCI(rx_tpa_start) \ |
| 527 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ |
| 528 | RX_TPA_START_CMP_METADATA0_TCI_MASK) >> \ |
| 529 | RX_TPA_START_CMP_METADATA0_SFT) |
| 530 | |
| 531 | struct rx_tpa_end_cmp { |
| 532 | __le32 rx_tpa_end_cmp_len_flags_type; |
| 533 | #define RX_TPA_END_CMP_TYPE (0x3f << 0) |
| 534 | #define RX_TPA_END_CMP_FLAGS (0x3ff << 6) |
| 535 | #define RX_TPA_END_CMP_FLAGS_SHIFT 6 |
| 536 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7) |
| 537 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7 |
| 538 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7) |
| 539 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7) |
| 540 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7) |
| 541 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7) |
| 542 | #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10) |
| 543 | #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12) |
| 544 | #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12 |
| 545 | #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12) |
| 546 | #define RX_TPA_END_CMP_LEN (0xffff << 16) |
| 547 | #define RX_TPA_END_CMP_LEN_SHIFT 16 |
| 548 | |
| 549 | u32 rx_tpa_end_cmp_opaque; |
| 550 | __le32 rx_tpa_end_cmp_misc_v1; |
| 551 | #define RX_TPA_END_CMP_V1 (0x1 << 0) |
| 552 | #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1) |
| 553 | #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1 |
| 554 | #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8) |
| 555 | #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8 |
| 556 | #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16) |
| 557 | #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16 |
| 558 | #define RX_TPA_END_CMP_AGG_ID (0x7f << 25) |
| 559 | #define RX_TPA_END_CMP_AGG_ID_SHIFT 25 |
| 560 | #define RX_TPA_END_CMP_AGG_ID_P5 (0x0fff << 16) |
| 561 | #define RX_TPA_END_CMP_AGG_ID_SHIFT_P5 16 |
| 562 | |
| 563 | __le32 rx_tpa_end_cmp_tsdelta; |
| 564 | #define RX_TPA_END_GRO_TS (0x1 << 31) |
| 565 | }; |
| 566 | |
| 567 | #define TPA_END_AGG_ID(rx_tpa_end) \ |
| 568 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 569 | RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT) |
| 570 | |
| 571 | #define TPA_END_AGG_ID_P5(rx_tpa_end) \ |
| 572 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 573 | RX_TPA_END_CMP_AGG_ID_P5) >> RX_TPA_END_CMP_AGG_ID_SHIFT_P5) |
| 574 | |
| 575 | #define TPA_END_PAYLOAD_OFF(rx_tpa_end) \ |
| 576 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 577 | RX_TPA_END_CMP_PAYLOAD_OFFSET) >> RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT) |
| 578 | |
| 579 | #define TPA_END_AGG_BUFS(rx_tpa_end) \ |
| 580 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 581 | RX_TPA_END_CMP_AGG_BUFS) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT) |
| 582 | |
| 583 | #define TPA_END_TPA_SEGS(rx_tpa_end) \ |
| 584 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 585 | RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT) |
| 586 | |
| 587 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \ |
| 588 | cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \ |
| 589 | RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS) |
| 590 | |
| 591 | #define TPA_END_GRO(rx_tpa_end) \ |
| 592 | ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \ |
| 593 | RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO) |
| 594 | |
| 595 | #define TPA_END_GRO_TS(rx_tpa_end) \ |
| 596 | (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \ |
| 597 | cpu_to_le32(RX_TPA_END_GRO_TS))) |
| 598 | |
| 599 | struct rx_tpa_end_cmp_ext { |
| 600 | __le32 rx_tpa_end_cmp_dup_acks; |
| 601 | #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0) |
| 602 | #define RX_TPA_END_CMP_PAYLOAD_OFFSET_P5 (0xff << 16) |
| 603 | #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5 16 |
| 604 | #define RX_TPA_END_CMP_AGG_BUFS_P5 (0xff << 24) |
| 605 | #define RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5 24 |
| 606 | |
| 607 | __le32 rx_tpa_end_cmp_seg_len; |
| 608 | #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0) |
| 609 | |
| 610 | __le32 rx_tpa_end_cmp_errors_v2; |
| 611 | #define RX_TPA_END_CMP_V2 (0x1 << 0) |
| 612 | #define RX_TPA_END_CMP_ERRORS (0x3 << 1) |
| 613 | #define RX_TPA_END_CMP_ERRORS_P5 (0x7 << 1) |
| 614 | #define RX_TPA_END_CMPL_ERRORS_SHIFT 1 |
| 615 | #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) |
| 616 | #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1) |
| 617 | #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) |
| 618 | #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_RSV_ERROR (0x4 << 1) |
| 619 | #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1) |
| 620 | |
| 621 | u32 rx_tpa_end_cmp_start_opaque; |
| 622 | }; |
| 623 | |
| 624 | #define TPA_END_ERRORS(rx_tpa_end_ext) \ |
| 625 | ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \ |
| 626 | cpu_to_le32(RX_TPA_END_CMP_ERRORS)) |
| 627 | |
| 628 | #define TPA_END_PAYLOAD_OFF_P5(rx_tpa_end_ext) \ |
| 629 | ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \ |
| 630 | RX_TPA_END_CMP_PAYLOAD_OFFSET_P5) >> \ |
| 631 | RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5) |
| 632 | |
| 633 | #define TPA_END_AGG_BUFS_P5(rx_tpa_end_ext) \ |
| 634 | ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \ |
| 635 | RX_TPA_END_CMP_AGG_BUFS_P5) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5) |
| 636 | |
| 637 | #define EVENT_DATA1_RESET_NOTIFY_FATAL(data1) \ |
| 638 | (((data1) & \ |
| 639 | ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\ |
| 640 | ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL) |
| 641 | |
| 642 | #define EVENT_DATA1_RESET_NOTIFY_FW_ACTIVATION(data1) \ |
| 643 | (((data1) & \ |
| 644 | ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\ |
| 645 | ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_ACTIVATION) |
| 646 | |
| 647 | #define EVENT_DATA2_RESET_NOTIFY_FW_STATUS_CODE(data2) \ |
| 648 | ((data2) & \ |
| 649 | ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_MASK) |
| 650 | |
| 651 | #define EVENT_DATA1_RECOVERY_MASTER_FUNC(data1) \ |
| 652 | !!((data1) & \ |
| 653 | ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC) |
| 654 | |
| 655 | #define EVENT_DATA1_RECOVERY_ENABLED(data1) \ |
| 656 | !!((data1) & \ |
| 657 | ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED) |
| 658 | |
| 659 | #define BNXT_EVENT_ERROR_REPORT_TYPE(data1) \ |
| 660 | (((data1) & \ |
| 661 | ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_MASK) >>\ |
| 662 | ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_SFT) |
| 663 | |
| 664 | #define BNXT_EVENT_INVALID_SIGNAL_DATA(data2) \ |
| 665 | (((data2) & \ |
| 666 | ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_MASK) >>\ |
| 667 | ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_SFT) |
| 668 | |
| 669 | struct nqe_cn { |
| 670 | __le16 type; |
| 671 | #define NQ_CN_TYPE_MASK 0x3fUL |
| 672 | #define NQ_CN_TYPE_SFT 0 |
| 673 | #define NQ_CN_TYPE_CQ_NOTIFICATION 0x30UL |
| 674 | #define NQ_CN_TYPE_LAST NQ_CN_TYPE_CQ_NOTIFICATION |
| 675 | #define NQ_CN_TOGGLE_MASK 0xc0UL |
| 676 | #define NQ_CN_TOGGLE_SFT 6 |
| 677 | __le16 reserved16; |
| 678 | __le32 cq_handle_low; |
| 679 | __le32 v; |
| 680 | #define NQ_CN_V 0x1UL |
| 681 | __le32 cq_handle_high; |
| 682 | }; |
| 683 | |
| 684 | #define BNXT_NQ_HDL_IDX_MASK 0x00ffffff |
| 685 | #define BNXT_NQ_HDL_TYPE_MASK 0xff000000 |
| 686 | #define BNXT_NQ_HDL_TYPE_SHIFT 24 |
| 687 | #define BNXT_NQ_HDL_TYPE_RX 0x00 |
| 688 | #define BNXT_NQ_HDL_TYPE_TX 0x01 |
| 689 | |
| 690 | #define BNXT_NQ_HDL_IDX(hdl) ((hdl) & BNXT_NQ_HDL_IDX_MASK) |
| 691 | #define BNXT_NQ_HDL_TYPE(hdl) (((hdl) & BNXT_NQ_HDL_TYPE_MASK) >> \ |
| 692 | BNXT_NQ_HDL_TYPE_SHIFT) |
| 693 | |
| 694 | #define BNXT_SET_NQ_HDL(cpr) \ |
| 695 | (((cpr)->cp_ring_type << BNXT_NQ_HDL_TYPE_SHIFT) | (cpr)->cp_idx) |
| 696 | |
| 697 | #define NQE_CN_TYPE(type) ((type) & NQ_CN_TYPE_MASK) |
| 698 | #define NQE_CN_TOGGLE(type) (((type) & NQ_CN_TOGGLE_MASK) >> \ |
| 699 | NQ_CN_TOGGLE_SFT) |
| 700 | |
| 701 | #define DB_IDX_MASK 0xffffff |
| 702 | #define DB_IDX_VALID (0x1 << 26) |
| 703 | #define DB_IRQ_DIS (0x1 << 27) |
| 704 | #define DB_KEY_TX (0x0 << 28) |
| 705 | #define DB_KEY_RX (0x1 << 28) |
| 706 | #define DB_KEY_CP (0x2 << 28) |
| 707 | #define DB_KEY_ST (0x3 << 28) |
| 708 | #define DB_KEY_TX_PUSH (0x4 << 28) |
| 709 | #define DB_LONG_TX_PUSH (0x2 << 24) |
| 710 | |
| 711 | #define BNXT_MIN_ROCE_CP_RINGS 2 |
| 712 | #define BNXT_MIN_ROCE_STAT_CTXS 1 |
| 713 | |
| 714 | /* 64-bit doorbell */ |
| 715 | #define DBR_INDEX_MASK 0x0000000000ffffffULL |
| 716 | #define DBR_EPOCH_MASK 0x01000000UL |
| 717 | #define DBR_EPOCH_SFT 24 |
| 718 | #define DBR_TOGGLE_MASK 0x06000000UL |
| 719 | #define DBR_TOGGLE_SFT 25 |
| 720 | #define DBR_XID_MASK 0x000fffff00000000ULL |
| 721 | #define DBR_XID_SFT 32 |
| 722 | #define DBR_PATH_L2 (0x1ULL << 56) |
| 723 | #define DBR_VALID (0x1ULL << 58) |
| 724 | #define DBR_TYPE_SQ (0x0ULL << 60) |
| 725 | #define DBR_TYPE_RQ (0x1ULL << 60) |
| 726 | #define DBR_TYPE_SRQ (0x2ULL << 60) |
| 727 | #define DBR_TYPE_SRQ_ARM (0x3ULL << 60) |
| 728 | #define DBR_TYPE_CQ (0x4ULL << 60) |
| 729 | #define DBR_TYPE_CQ_ARMSE (0x5ULL << 60) |
| 730 | #define DBR_TYPE_CQ_ARMALL (0x6ULL << 60) |
| 731 | #define DBR_TYPE_CQ_ARMENA (0x7ULL << 60) |
| 732 | #define DBR_TYPE_SRQ_ARMENA (0x8ULL << 60) |
| 733 | #define DBR_TYPE_CQ_CUTOFF_ACK (0x9ULL << 60) |
| 734 | #define DBR_TYPE_NQ (0xaULL << 60) |
| 735 | #define DBR_TYPE_NQ_ARM (0xbULL << 60) |
| 736 | #define DBR_TYPE_NQ_MASK (0xeULL << 60) |
| 737 | #define DBR_TYPE_NULL (0xfULL << 60) |
| 738 | |
| 739 | #define DB_PF_OFFSET_P5 0x10000 |
| 740 | #define DB_VF_OFFSET_P5 0x4000 |
| 741 | |
| 742 | #define INVALID_HW_RING_ID ((u16)-1) |
| 743 | |
| 744 | /* The hardware supports certain page sizes. Use the supported page sizes |
| 745 | * to allocate the rings. |
| 746 | */ |
| 747 | #if (PAGE_SHIFT < 12) |
| 748 | #define BNXT_PAGE_SHIFT 12 |
| 749 | #elif (PAGE_SHIFT <= 13) |
| 750 | #define BNXT_PAGE_SHIFT PAGE_SHIFT |
| 751 | #elif (PAGE_SHIFT < 16) |
| 752 | #define BNXT_PAGE_SHIFT 13 |
| 753 | #else |
| 754 | #define BNXT_PAGE_SHIFT 16 |
| 755 | #endif |
| 756 | |
| 757 | #define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT) |
| 758 | |
| 759 | /* The RXBD length is 16-bit so we can only support page sizes < 64K */ |
| 760 | #if (PAGE_SHIFT > 15) |
| 761 | #define BNXT_RX_PAGE_SHIFT 15 |
| 762 | #else |
| 763 | #define BNXT_RX_PAGE_SHIFT PAGE_SHIFT |
| 764 | #endif |
| 765 | |
| 766 | #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) |
| 767 | #define BNXT_MAX_RX_PAGE_SIZE BIT(15) |
| 768 | |
| 769 | #define BNXT_MAX_MTU 9500 |
| 770 | |
| 771 | /* First RX buffer page in XDP multi-buf mode |
| 772 | * |
| 773 | * +-------------------------------------------------------------------------+ |
| 774 | * | XDP_PACKET_HEADROOM | bp->rx_buf_use_size | skb_shared_info| |
| 775 | * | (bp->rx_dma_offset) | | | |
| 776 | * +-------------------------------------------------------------------------+ |
| 777 | */ |
| 778 | #define BNXT_MAX_PAGE_MODE_MTU_SBUF \ |
| 779 | ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ |
| 780 | XDP_PACKET_HEADROOM) |
| 781 | #define BNXT_MAX_PAGE_MODE_MTU \ |
| 782 | (BNXT_MAX_PAGE_MODE_MTU_SBUF - \ |
| 783 | SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info))) |
| 784 | |
| 785 | #define BNXT_MIN_PKT_SIZE 52 |
| 786 | |
| 787 | #define BNXT_DEFAULT_RX_RING_SIZE 511 |
| 788 | #define BNXT_DEFAULT_TX_RING_SIZE 511 |
| 789 | |
| 790 | #define MAX_TPA 64 |
| 791 | #define MAX_TPA_P5 256 |
| 792 | #define MAX_TPA_SEGS_P5 0x3f |
| 793 | |
| 794 | #if (BNXT_PAGE_SHIFT == 16) |
| 795 | #define MAX_RX_PAGES_AGG_ENA 1 |
| 796 | #define MAX_RX_PAGES 4 |
| 797 | #define MAX_RX_AGG_PAGES 4 |
| 798 | #define MAX_TX_PAGES 1 |
| 799 | #define MAX_CP_PAGES 16 |
| 800 | #else |
| 801 | #define MAX_RX_PAGES_AGG_ENA 8 |
| 802 | #define MAX_RX_PAGES 32 |
| 803 | #define MAX_RX_AGG_PAGES 32 |
| 804 | #define MAX_TX_PAGES 8 |
| 805 | #define MAX_CP_PAGES 128 |
| 806 | #endif |
| 807 | |
| 808 | #define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd)) |
| 809 | #define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd)) |
| 810 | #define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp)) |
| 811 | |
| 812 | #define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT) |
| 813 | #define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT) |
| 814 | |
| 815 | #define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT) |
| 816 | |
| 817 | #define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT) |
| 818 | #define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT) |
| 819 | |
| 820 | #define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT) |
| 821 | |
| 822 | #define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1) |
| 823 | #define BNXT_MAX_RX_DESC_CNT_JUM_ENA (RX_DESC_CNT * MAX_RX_PAGES_AGG_ENA - 1) |
| 824 | #define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1) |
| 825 | #define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1) |
| 826 | |
| 827 | /* Minimum TX BDs for a TX packet with MAX_SKB_FRAGS + 1. We need one extra |
| 828 | * BD because the first TX BD is always a long BD. |
| 829 | */ |
| 830 | #define BNXT_MIN_TX_DESC_CNT (MAX_SKB_FRAGS + 2) |
| 831 | |
| 832 | #define RX_RING(bp, x) (((x) & (bp)->rx_ring_mask) >> (BNXT_PAGE_SHIFT - 4)) |
| 833 | #define RX_AGG_RING(bp, x) (((x) & (bp)->rx_agg_ring_mask) >> \ |
| 834 | (BNXT_PAGE_SHIFT - 4)) |
| 835 | #define RX_IDX(x) ((x) & (RX_DESC_CNT - 1)) |
| 836 | |
| 837 | #define TX_RING(bp, x) (((x) & (bp)->tx_ring_mask) >> (BNXT_PAGE_SHIFT - 4)) |
| 838 | #define TX_IDX(x) ((x) & (TX_DESC_CNT - 1)) |
| 839 | |
| 840 | #define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) |
| 841 | #define CP_IDX(x) ((x) & (CP_DESC_CNT - 1)) |
| 842 | |
| 843 | #define TX_CMP_VALID(txcmp, raw_cons) \ |
| 844 | (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \ |
| 845 | !((raw_cons) & bp->cp_bit)) |
| 846 | |
| 847 | #define RX_CMP_VALID(rxcmp1, raw_cons) \ |
| 848 | (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\ |
| 849 | !((raw_cons) & bp->cp_bit)) |
| 850 | |
| 851 | #define RX_AGG_CMP_VALID(agg, raw_cons) \ |
| 852 | (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \ |
| 853 | !((raw_cons) & bp->cp_bit)) |
| 854 | |
| 855 | #define NQ_CMP_VALID(nqcmp, raw_cons) \ |
| 856 | (!!((nqcmp)->v & cpu_to_le32(NQ_CN_V)) == !((raw_cons) & bp->cp_bit)) |
| 857 | |
| 858 | #define TX_CMP_TYPE(txcmp) \ |
| 859 | (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE) |
| 860 | |
| 861 | #define RX_CMP_TYPE(rxcmp) \ |
| 862 | (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE) |
| 863 | |
| 864 | #define RING_RX(bp, idx) ((idx) & (bp)->rx_ring_mask) |
| 865 | #define NEXT_RX(idx) ((idx) + 1) |
| 866 | |
| 867 | #define RING_RX_AGG(bp, idx) ((idx) & (bp)->rx_agg_ring_mask) |
| 868 | #define NEXT_RX_AGG(idx) ((idx) + 1) |
| 869 | |
| 870 | #define RING_TX(bp, idx) ((idx) & (bp)->tx_ring_mask) |
| 871 | #define NEXT_TX(idx) ((idx) + 1) |
| 872 | |
| 873 | #define ADV_RAW_CMP(idx, n) ((idx) + (n)) |
| 874 | #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1) |
| 875 | #define RING_CMP(idx) ((idx) & bp->cp_ring_mask) |
| 876 | #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1)) |
| 877 | |
| 878 | #define DFLT_HWRM_CMD_TIMEOUT 500 |
| 879 | |
| 880 | #define BNXT_RX_EVENT 1 |
| 881 | #define BNXT_AGG_EVENT 2 |
| 882 | #define BNXT_TX_EVENT 4 |
| 883 | #define BNXT_REDIRECT_EVENT 8 |
| 884 | #define BNXT_TX_CMP_EVENT 0x10 |
| 885 | |
| 886 | struct bnxt_sw_tx_bd { |
| 887 | union { |
| 888 | struct sk_buff *skb; |
| 889 | struct xdp_frame *xdpf; |
| 890 | }; |
| 891 | DEFINE_DMA_UNMAP_ADDR(mapping); |
| 892 | DEFINE_DMA_UNMAP_LEN(len); |
| 893 | struct page *page; |
| 894 | u8 is_ts_pkt; |
| 895 | u8 is_push; |
| 896 | u8 is_sw_gso; |
| 897 | u8 action; |
| 898 | unsigned short nr_frags; |
| 899 | union { |
| 900 | u16 rx_prod; |
| 901 | u16 txts_prod; |
| 902 | }; |
| 903 | struct tso_dma_map_completion_state sw_gso_cstate; |
| 904 | }; |
| 905 | |
| 906 | #define BNXT_SW_GSO_MID 1 |
| 907 | #define BNXT_SW_GSO_LAST 2 |
| 908 | |
| 909 | struct bnxt_sw_rx_bd { |
| 910 | void *data; |
| 911 | u8 *data_ptr; |
| 912 | dma_addr_t mapping; |
| 913 | unsigned int offset; |
| 914 | }; |
| 915 | |
| 916 | struct bnxt_sw_rx_agg_bd { |
| 917 | netmem_ref netmem; |
| 918 | unsigned int offset; |
| 919 | dma_addr_t mapping; |
| 920 | }; |
| 921 | |
| 922 | struct bnxt_ring_mem_info { |
| 923 | int nr_pages; |
| 924 | int page_size; |
| 925 | u16 flags; |
| 926 | #define BNXT_RMEM_VALID_PTE_FLAG 1 |
| 927 | #define BNXT_RMEM_RING_PTE_FLAG 2 |
| 928 | #define BNXT_RMEM_USE_FULL_PAGE_FLAG 4 |
| 929 | |
| 930 | u16 depth; |
| 931 | struct bnxt_ctx_mem_type *ctx_mem; |
| 932 | |
| 933 | void **pg_arr; |
| 934 | dma_addr_t *dma_arr; |
| 935 | |
| 936 | __le64 *pg_tbl; |
| 937 | dma_addr_t pg_tbl_map; |
| 938 | |
| 939 | int vmem_size; |
| 940 | void **vmem; |
| 941 | }; |
| 942 | |
| 943 | struct bnxt_ring_struct { |
| 944 | struct bnxt_ring_mem_info ring_mem; |
| 945 | |
| 946 | u16 fw_ring_id; /* Ring id filled by Chimp FW */ |
| 947 | union { |
| 948 | u16 grp_idx; |
| 949 | u16 map_idx; /* Used by cmpl rings */ |
| 950 | }; |
| 951 | u32 handle; |
| 952 | u8 queue_id; |
| 953 | }; |
| 954 | |
| 955 | struct tx_push_bd { |
| 956 | __le32 doorbell; |
| 957 | __le32 tx_bd_len_flags_type; |
| 958 | u32 tx_bd_opaque; |
| 959 | struct tx_bd_ext txbd2; |
| 960 | }; |
| 961 | |
| 962 | struct tx_push_buffer { |
| 963 | struct tx_push_bd push_bd; |
| 964 | u32 data[25]; |
| 965 | }; |
| 966 | |
| 967 | struct bnxt_db_info { |
| 968 | void __iomem *doorbell; |
| 969 | union { |
| 970 | u64 db_key64; |
| 971 | u32 db_key32; |
| 972 | }; |
| 973 | u32 db_ring_mask; |
| 974 | u32 db_epoch_mask; |
| 975 | u8 db_epoch_shift; |
| 976 | }; |
| 977 | |
| 978 | #define DB_EPOCH(db, idx) (((idx) & (db)->db_epoch_mask) << \ |
| 979 | ((db)->db_epoch_shift)) |
| 980 | |
| 981 | #define DB_TOGGLE(tgl) ((tgl) << DBR_TOGGLE_SFT) |
| 982 | |
| 983 | #define DB_RING_IDX(db, idx) (((idx) & (db)->db_ring_mask) | \ |
| 984 | DB_EPOCH(db, idx)) |
| 985 | |
| 986 | struct bnxt_tx_ring_info { |
| 987 | struct bnxt_napi *bnapi; |
| 988 | struct bnxt_cp_ring_info *tx_cpr; |
| 989 | u16 tx_prod; |
| 990 | u16 tx_cons; |
| 991 | u16 tx_hw_cons; |
| 992 | u16 txq_index; |
| 993 | u8 tx_napi_idx; |
| 994 | u8 kick_pending; |
| 995 | struct tx_bd *kick_txbd0; |
| 996 | struct bnxt_db_info tx_db; |
| 997 | |
| 998 | struct tx_bd *tx_desc_ring[MAX_TX_PAGES]; |
| 999 | struct bnxt_sw_tx_bd *tx_buf_ring; |
| 1000 | |
| 1001 | dma_addr_t tx_desc_mapping[MAX_TX_PAGES]; |
| 1002 | |
| 1003 | struct tx_push_buffer *tx_push; |
| 1004 | dma_addr_t tx_push_mapping; |
| 1005 | __le64 data_mapping; |
| 1006 | |
| 1007 | void *tx_inline_buf; |
| 1008 | dma_addr_t tx_inline_dma; |
| 1009 | unsigned int tx_inline_size; |
| 1010 | u16 tx_inline_prod; |
| 1011 | u16 tx_inline_cons; |
| 1012 | |
| 1013 | #define BNXT_DEV_STATE_CLOSING 0x1 |
| 1014 | u32 dev_state; |
| 1015 | |
| 1016 | struct bnxt_ring_struct tx_ring_struct; |
| 1017 | /* Synchronize simultaneous xdp_xmit on same ring */ |
| 1018 | spinlock_t xdp_tx_lock; |
| 1019 | }; |
| 1020 | |
| 1021 | #define BNXT_LEGACY_COAL_CMPL_PARAMS \ |
| 1022 | (RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MIN | \ |
| 1023 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MAX | \ |
| 1024 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_TIMER_RESET | \ |
| 1025 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_RING_IDLE | \ |
| 1026 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR | \ |
| 1027 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR_DURING_INT | \ |
| 1028 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR | \ |
| 1029 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR_DURING_INT | \ |
| 1030 | RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_AGGR_INT) |
| 1031 | |
| 1032 | #define BNXT_COAL_CMPL_ENABLES \ |
| 1033 | (RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR | \ |
| 1034 | RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_CMPL_AGGR_DMA_TMR | \ |
| 1035 | RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MAX | \ |
| 1036 | RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_AGGR_INT) |
| 1037 | |
| 1038 | #define BNXT_COAL_CMPL_MIN_TMR_ENABLE \ |
| 1039 | RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MIN |
| 1040 | |
| 1041 | #define BNXT_COAL_CMPL_AGGR_TMR_DURING_INT_ENABLE \ |
| 1042 | RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR_DURING_INT |
| 1043 | |
| 1044 | struct bnxt_coal_cap { |
| 1045 | u32 cmpl_params; |
| 1046 | u32 nq_params; |
| 1047 | u16 num_cmpl_dma_aggr_max; |
| 1048 | u16 num_cmpl_dma_aggr_during_int_max; |
| 1049 | u16 cmpl_aggr_dma_tmr_max; |
| 1050 | u16 cmpl_aggr_dma_tmr_during_int_max; |
| 1051 | u16 int_lat_tmr_min_max; |
| 1052 | u16 int_lat_tmr_max_max; |
| 1053 | u16 num_cmpl_aggr_int_max; |
| 1054 | u16 timer_units; |
| 1055 | }; |
| 1056 | |
| 1057 | struct bnxt_coal { |
| 1058 | u16 coal_ticks; |
| 1059 | u16 coal_ticks_irq; |
| 1060 | u16 coal_bufs; |
| 1061 | u16 coal_bufs_irq; |
| 1062 | /* RING_IDLE enabled when coal ticks < idle_thresh */ |
| 1063 | u16 idle_thresh; |
| 1064 | u8 bufs_per_record; |
| 1065 | u8 budget; |
| 1066 | u16 flags; |
| 1067 | }; |
| 1068 | |
| 1069 | struct bnxt_tpa_info { |
| 1070 | void *data; |
| 1071 | u8 *data_ptr; |
| 1072 | dma_addr_t mapping; |
| 1073 | u16 len; |
| 1074 | unsigned short gso_type; |
| 1075 | u32 flags2; |
| 1076 | u32 metadata; |
| 1077 | enum pkt_hash_types hash_type; |
| 1078 | u32 rss_hash; |
| 1079 | u32 hdr_info; |
| 1080 | |
| 1081 | #define BNXT_TPA_L4_SIZE(hdr_info) \ |
| 1082 | (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32) |
| 1083 | |
| 1084 | #define BNXT_TPA_INNER_L3_OFF(hdr_info) \ |
| 1085 | (((hdr_info) >> 18) & 0x1ff) |
| 1086 | |
| 1087 | #define BNXT_TPA_INNER_L2_OFF(hdr_info) \ |
| 1088 | (((hdr_info) >> 9) & 0x1ff) |
| 1089 | |
| 1090 | #define BNXT_TPA_OUTER_L3_OFF(hdr_info) \ |
| 1091 | ((hdr_info) & 0x1ff) |
| 1092 | |
| 1093 | u16 cfa_code; /* cfa_code in TPA start compl */ |
| 1094 | u8 agg_count; |
| 1095 | u8 vlan_valid:1; |
| 1096 | u8 cfa_code_valid:1; |
| 1097 | struct rx_agg_cmp *agg_arr; |
| 1098 | }; |
| 1099 | |
| 1100 | struct bnxt_tpa_idx_map { |
| 1101 | u16 agg_id_tbl[1024]; |
| 1102 | DECLARE_BITMAP(agg_idx_bmap, MAX_TPA_P5); |
| 1103 | }; |
| 1104 | |
| 1105 | struct bnxt_rx_ring_info { |
| 1106 | struct bnxt_napi *bnapi; |
| 1107 | struct bnxt_cp_ring_info *rx_cpr; |
| 1108 | u16 rx_prod; |
| 1109 | u16 rx_agg_prod; |
| 1110 | u16 rx_sw_agg_prod; |
| 1111 | u16 rx_next_cons; |
| 1112 | struct bnxt_db_info rx_db; |
| 1113 | struct bnxt_db_info rx_agg_db; |
| 1114 | |
| 1115 | struct bpf_prog *xdp_prog; |
| 1116 | |
| 1117 | struct rx_bd *rx_desc_ring[MAX_RX_PAGES]; |
| 1118 | struct bnxt_sw_rx_bd *rx_buf_ring; |
| 1119 | |
| 1120 | struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES]; |
| 1121 | struct bnxt_sw_rx_agg_bd *rx_agg_ring; |
| 1122 | |
| 1123 | unsigned long *rx_agg_bmap; |
| 1124 | u16 rx_agg_bmap_size; |
| 1125 | u32 rx_page_size; |
| 1126 | bool need_head_pool; |
| 1127 | |
| 1128 | dma_addr_t rx_desc_mapping[MAX_RX_PAGES]; |
| 1129 | dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES]; |
| 1130 | |
| 1131 | struct bnxt_tpa_info *rx_tpa; |
| 1132 | struct bnxt_tpa_idx_map *rx_tpa_idx_map; |
| 1133 | |
| 1134 | struct bnxt_ring_struct rx_ring_struct; |
| 1135 | struct bnxt_ring_struct rx_agg_ring_struct; |
| 1136 | struct xdp_rxq_info xdp_rxq; |
| 1137 | struct page_pool *page_pool; |
| 1138 | struct page_pool *head_pool; |
| 1139 | }; |
| 1140 | |
| 1141 | struct bnxt_rx_sw_stats { |
| 1142 | u64 rx_l4_csum_errors; |
| 1143 | u64 rx_resets; |
| 1144 | u64 rx_buf_errors; |
| 1145 | /* end of ethtool -S stats */ |
| 1146 | u64 rx_oom_discards; |
| 1147 | u64 rx_netpoll_discards; |
| 1148 | u64 rx_hw_gro_packets; |
| 1149 | u64 rx_hw_gro_wire_packets; |
| 1150 | }; |
| 1151 | |
| 1152 | struct bnxt_tx_sw_stats { |
| 1153 | u64 tx_resets; |
| 1154 | }; |
| 1155 | |
| 1156 | struct bnxt_cmn_sw_stats { |
| 1157 | u64 missed_irqs; |
| 1158 | }; |
| 1159 | |
| 1160 | struct bnxt_sw_stats { |
| 1161 | struct bnxt_rx_sw_stats rx; |
| 1162 | struct bnxt_tx_sw_stats tx; |
| 1163 | struct bnxt_cmn_sw_stats cmn; |
| 1164 | }; |
| 1165 | |
| 1166 | struct bnxt_total_ring_drv_stats { |
| 1167 | u64 rx_total_l4_csum_errors; |
| 1168 | u64 rx_total_resets; |
| 1169 | u64 rx_total_buf_errors; |
| 1170 | u64 rx_total_oom_discards; |
| 1171 | u64 rx_total_netpoll_discards; |
| 1172 | u64 rx_total_ring_discards; |
| 1173 | u64 tx_total_resets; |
| 1174 | u64 tx_total_ring_discards; |
| 1175 | u64 total_missed_irqs; |
| 1176 | /* end of ethtool -S stats */ |
| 1177 | u64 rx_total_hw_gro_packets; |
| 1178 | u64 rx_total_hw_gro_wire_packets; |
| 1179 | }; |
| 1180 | |
| 1181 | struct bnxt_stats_mem { |
| 1182 | u64 *sw_stats; |
| 1183 | u64 *hw_masks; |
| 1184 | void *hw_stats; |
| 1185 | dma_addr_t hw_stats_map; |
| 1186 | int len; |
| 1187 | }; |
| 1188 | |
| 1189 | struct bnxt_cp_ring_info { |
| 1190 | struct bnxt_napi *bnapi; |
| 1191 | u32 cp_raw_cons; |
| 1192 | struct bnxt_db_info cp_db; |
| 1193 | |
| 1194 | u8 had_work_done:1; |
| 1195 | u8 has_more_work:1; |
| 1196 | u8 had_nqe_notify:1; |
| 1197 | u8 toggle; |
| 1198 | |
| 1199 | u8 cp_ring_type; |
| 1200 | u8 cp_idx; |
| 1201 | |
| 1202 | u32 last_cp_raw_cons; |
| 1203 | |
| 1204 | struct bnxt_coal rx_ring_coal; |
| 1205 | u64 rx_packets; |
| 1206 | u64 rx_bytes; |
| 1207 | u64 event_ctr; |
| 1208 | |
| 1209 | struct dim dim; |
| 1210 | |
| 1211 | union { |
| 1212 | struct tx_cmp **cp_desc_ring; |
| 1213 | struct nqe_cn **nq_desc_ring; |
| 1214 | }; |
| 1215 | |
| 1216 | dma_addr_t *cp_desc_mapping; |
| 1217 | |
| 1218 | struct bnxt_stats_mem stats; |
| 1219 | u32 hw_stats_ctx_id; |
| 1220 | |
| 1221 | struct bnxt_sw_stats *sw_stats; |
| 1222 | |
| 1223 | struct bnxt_ring_struct cp_ring_struct; |
| 1224 | |
| 1225 | int cp_ring_count; |
| 1226 | struct bnxt_cp_ring_info *cp_ring_arr; |
| 1227 | }; |
| 1228 | |
| 1229 | #define BNXT_MAX_QUEUE 8 |
| 1230 | #define BNXT_MAX_TXR_PER_NAPI BNXT_MAX_QUEUE |
| 1231 | |
| 1232 | #define bnxt_for_each_napi_tx(iter, bnapi, txr) \ |
| 1233 | for (iter = 0, txr = (bnapi)->tx_ring[0]; txr; \ |
| 1234 | txr = (iter < BNXT_MAX_TXR_PER_NAPI - 1) ? \ |
| 1235 | (bnapi)->tx_ring[++iter] : NULL) |
| 1236 | |
| 1237 | struct bnxt_napi { |
| 1238 | struct napi_struct napi; |
| 1239 | struct bnxt *bp; |
| 1240 | |
| 1241 | int index; |
| 1242 | struct bnxt_cp_ring_info cp_ring; |
| 1243 | struct bnxt_rx_ring_info *rx_ring; |
| 1244 | struct bnxt_tx_ring_info *tx_ring[BNXT_MAX_TXR_PER_NAPI]; |
| 1245 | |
| 1246 | void (*tx_int)(struct bnxt *, struct bnxt_napi *, |
| 1247 | int budget); |
| 1248 | u8 events; |
| 1249 | u8 tx_fault:1; |
| 1250 | |
| 1251 | u32 flags; |
| 1252 | #define BNXT_NAPI_FLAG_XDP 0x1 |
| 1253 | |
| 1254 | bool in_reset; |
| 1255 | }; |
| 1256 | |
| 1257 | /* "TxRx", 2 hypens, plus maximum integer */ |
| 1258 | #define BNXT_IRQ_NAME_EXTRA 17 |
| 1259 | |
| 1260 | struct bnxt_irq { |
| 1261 | irq_handler_t handler; |
| 1262 | unsigned int vector; |
| 1263 | u8 requested:1; |
| 1264 | char name[IFNAMSIZ + BNXT_IRQ_NAME_EXTRA]; |
| 1265 | |
| 1266 | struct bnxt *bp; |
| 1267 | int msix_nr; |
| 1268 | int ring_nr; |
| 1269 | u16 tag; |
| 1270 | u16 new_tag; |
| 1271 | struct irq_affinity_notify affinity_notify; |
| 1272 | }; |
| 1273 | |
| 1274 | #define HWRM_RING_ALLOC_TX 0x1 |
| 1275 | #define HWRM_RING_ALLOC_RX 0x2 |
| 1276 | #define HWRM_RING_ALLOC_AGG 0x4 |
| 1277 | #define HWRM_RING_ALLOC_CMPL 0x8 |
| 1278 | #define HWRM_RING_ALLOC_NQ 0x10 |
| 1279 | |
| 1280 | #define INVALID_STATS_CTX_ID -1 |
| 1281 | |
| 1282 | struct bnxt_ring_grp_info { |
| 1283 | u16 fw_stats_ctx; |
| 1284 | u16 fw_grp_id; |
| 1285 | u16 rx_fw_ring_id; |
| 1286 | u16 agg_fw_ring_id; |
| 1287 | u16 cp_fw_ring_id; |
| 1288 | }; |
| 1289 | |
| 1290 | #define BNXT_VNIC_DEFAULT 0 |
| 1291 | #define BNXT_VNIC_NTUPLE 1 |
| 1292 | |
| 1293 | struct bnxt_vnic_info { |
| 1294 | u16 fw_vnic_id; /* returned by Chimp during alloc */ |
| 1295 | #define BNXT_MAX_CTX_PER_VNIC 8 |
| 1296 | u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC]; |
| 1297 | u16 fw_l2_ctx_id; |
| 1298 | u16 mru; |
| 1299 | #define BNXT_MAX_UC_ADDRS 4 |
| 1300 | struct bnxt_l2_filter *l2_filters[BNXT_MAX_UC_ADDRS]; |
| 1301 | /* index 0 always dev_addr */ |
| 1302 | u16 uc_filter_count; |
| 1303 | u8 *uc_list; |
| 1304 | |
| 1305 | u16 *fw_grp_ids; |
| 1306 | dma_addr_t rss_table_dma_addr; |
| 1307 | __le16 *rss_table; |
| 1308 | dma_addr_t rss_hash_key_dma_addr; |
| 1309 | u64 *rss_hash_key; |
| 1310 | int rss_table_size; |
| 1311 | #define BNXT_RSS_TABLE_ENTRIES_P5 64 |
| 1312 | #define BNXT_RSS_TABLE_SIZE_P5 (BNXT_RSS_TABLE_ENTRIES_P5 * 4) |
| 1313 | #define BNXT_RSS_TABLE_MAX_TBL_P5 8 |
| 1314 | #define BNXT_MAX_RSS_TABLE_SIZE_P5 \ |
| 1315 | (BNXT_RSS_TABLE_SIZE_P5 * BNXT_RSS_TABLE_MAX_TBL_P5) |
| 1316 | #define BNXT_MAX_RSS_TABLE_ENTRIES_P5 \ |
| 1317 | (BNXT_RSS_TABLE_ENTRIES_P5 * BNXT_RSS_TABLE_MAX_TBL_P5) |
| 1318 | |
| 1319 | u32 rx_mask; |
| 1320 | |
| 1321 | u8 *mc_list; |
| 1322 | int mc_list_size; |
| 1323 | int mc_list_count; |
| 1324 | dma_addr_t mc_list_mapping; |
| 1325 | #define BNXT_MAX_MC_ADDRS 16 |
| 1326 | |
| 1327 | u32 flags; |
| 1328 | #define BNXT_VNIC_RSS_FLAG 1 |
| 1329 | #define BNXT_VNIC_RFS_FLAG 2 |
| 1330 | #define BNXT_VNIC_MCAST_FLAG 4 |
| 1331 | #define BNXT_VNIC_UCAST_FLAG 8 |
| 1332 | #define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10 |
| 1333 | #define BNXT_VNIC_NTUPLE_FLAG 0x20 |
| 1334 | #define BNXT_VNIC_RSSCTX_FLAG 0x40 |
| 1335 | struct ethtool_rxfh_context *rss_ctx; |
| 1336 | u32 vnic_id; |
| 1337 | u16 default_rx_ring; |
| 1338 | }; |
| 1339 | |
| 1340 | struct bnxt_rss_ctx { |
| 1341 | struct bnxt_vnic_info vnic; |
| 1342 | u8 index; |
| 1343 | }; |
| 1344 | |
| 1345 | #define BNXT_MAX_ETH_RSS_CTX 32 |
| 1346 | #define BNXT_VNIC_ID_INVALID 0xffffffff |
| 1347 | |
| 1348 | struct bnxt_hw_rings { |
| 1349 | int tx; |
| 1350 | int rx; |
| 1351 | int grp; |
| 1352 | int cp; |
| 1353 | int cp_p5; |
| 1354 | int stat; |
| 1355 | int vnic; |
| 1356 | int rss_ctx; |
| 1357 | }; |
| 1358 | |
| 1359 | struct bnxt_hw_resc { |
| 1360 | u16 min_rsscos_ctxs; |
| 1361 | u16 max_rsscos_ctxs; |
| 1362 | u16 resv_rsscos_ctxs; |
| 1363 | u16 min_cp_rings; |
| 1364 | u16 max_cp_rings; |
| 1365 | u16 resv_cp_rings; |
| 1366 | u16 min_tx_rings; |
| 1367 | u16 max_tx_rings; |
| 1368 | u16 resv_tx_rings; |
| 1369 | u16 max_tx_sch_inputs; |
| 1370 | u16 min_rx_rings; |
| 1371 | u16 max_rx_rings; |
| 1372 | u16 resv_rx_rings; |
| 1373 | u16 min_hw_ring_grps; |
| 1374 | u16 max_hw_ring_grps; |
| 1375 | u16 resv_hw_ring_grps; |
| 1376 | u16 min_l2_ctxs; |
| 1377 | u16 max_l2_ctxs; |
| 1378 | u16 min_vnics; |
| 1379 | u16 max_vnics; |
| 1380 | u16 resv_vnics; |
| 1381 | u16 min_stat_ctxs; |
| 1382 | u16 max_stat_ctxs; |
| 1383 | u16 resv_stat_ctxs; |
| 1384 | u16 max_nqs; |
| 1385 | u16 max_irqs; |
| 1386 | u16 resv_irqs; |
| 1387 | u32 max_encap_records; |
| 1388 | u32 max_decap_records; |
| 1389 | u32 max_tx_em_flows; |
| 1390 | u32 max_tx_wm_flows; |
| 1391 | u32 max_rx_em_flows; |
| 1392 | u32 max_rx_wm_flows; |
| 1393 | }; |
| 1394 | |
| 1395 | #define BNXT_LARGE_RSS_TO_VNIC_RATIO 7 |
| 1396 | |
| 1397 | #if defined(CONFIG_BNXT_SRIOV) |
| 1398 | struct bnxt_vf_info { |
| 1399 | u16 fw_fid; |
| 1400 | u8 mac_addr[ETH_ALEN]; /* PF assigned MAC Address */ |
| 1401 | u8 vf_mac_addr[ETH_ALEN]; /* VF assigned MAC address, only |
| 1402 | * stored by PF. |
| 1403 | */ |
| 1404 | u16 vlan; |
| 1405 | u16 func_qcfg_flags; |
| 1406 | u32 flags; |
| 1407 | #define BNXT_VF_SPOOFCHK 0x2 |
| 1408 | #define BNXT_VF_LINK_FORCED 0x4 |
| 1409 | #define BNXT_VF_LINK_UP 0x8 |
| 1410 | #define BNXT_VF_TRUST 0x10 |
| 1411 | u32 min_tx_rate; |
| 1412 | u32 max_tx_rate; |
| 1413 | void *hwrm_cmd_req_addr; |
| 1414 | dma_addr_t hwrm_cmd_req_dma_addr; |
| 1415 | }; |
| 1416 | #endif |
| 1417 | |
| 1418 | struct bnxt_pf_info { |
| 1419 | #define BNXT_FIRST_PF_FID 1 |
| 1420 | #define BNXT_FIRST_VF_FID 128 |
| 1421 | u16 fw_fid; |
| 1422 | u16 port_id; |
| 1423 | u8 mac_addr[ETH_ALEN]; |
| 1424 | u32 first_vf_id; |
| 1425 | u16 active_vfs; |
| 1426 | u16 registered_vfs; |
| 1427 | u16 max_vfs; |
| 1428 | unsigned long *vf_event_bmap; |
| 1429 | u16 hwrm_cmd_req_pages; |
| 1430 | u8 vf_resv_strategy; |
| 1431 | #define BNXT_VF_RESV_STRATEGY_MAXIMAL 0 |
| 1432 | #define BNXT_VF_RESV_STRATEGY_MINIMAL 1 |
| 1433 | #define BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC 2 |
| 1434 | void *hwrm_cmd_req_addr[4]; |
| 1435 | dma_addr_t hwrm_cmd_req_dma_addr[4]; |
| 1436 | struct bnxt_vf_info *vf; |
| 1437 | }; |
| 1438 | |
| 1439 | struct bnxt_filter_base { |
| 1440 | struct hlist_node hash; |
| 1441 | struct list_head list; |
| 1442 | __le64 filter_id; |
| 1443 | u8 type; |
| 1444 | #define BNXT_FLTR_TYPE_NTUPLE 1 |
| 1445 | #define BNXT_FLTR_TYPE_L2 2 |
| 1446 | u8 flags; |
| 1447 | #define BNXT_ACT_DROP 1 |
| 1448 | #define BNXT_ACT_RING_DST 2 |
| 1449 | #define BNXT_ACT_FUNC_DST 4 |
| 1450 | #define BNXT_ACT_NO_AGING 8 |
| 1451 | #define BNXT_ACT_RSS_CTX 0x10 |
| 1452 | u16 sw_id; |
| 1453 | u16 rxq; |
| 1454 | u16 fw_vnic_id; |
| 1455 | u16 vf_idx; |
| 1456 | unsigned long state; |
| 1457 | #define BNXT_FLTR_VALID 0 |
| 1458 | #define BNXT_FLTR_INSERTED 1 |
| 1459 | #define BNXT_FLTR_FW_DELETED 2 |
| 1460 | |
| 1461 | struct rcu_head rcu; |
| 1462 | }; |
| 1463 | |
| 1464 | struct bnxt_flow_masks { |
| 1465 | struct flow_dissector_key_ports ports; |
| 1466 | struct flow_dissector_key_addrs addrs; |
| 1467 | }; |
| 1468 | |
| 1469 | extern const struct bnxt_flow_masks BNXT_FLOW_MASK_NONE; |
| 1470 | extern const struct bnxt_flow_masks BNXT_FLOW_IPV6_MASK_ALL; |
| 1471 | extern const struct bnxt_flow_masks BNXT_FLOW_IPV4_MASK_ALL; |
| 1472 | |
| 1473 | struct bnxt_ntuple_filter { |
| 1474 | /* base filter must be the first member */ |
| 1475 | struct bnxt_filter_base base; |
| 1476 | struct flow_keys fkeys; |
| 1477 | struct bnxt_flow_masks fmasks; |
| 1478 | struct bnxt_l2_filter *l2_fltr; |
| 1479 | u32 flow_id; |
| 1480 | }; |
| 1481 | |
| 1482 | struct bnxt_l2_key { |
| 1483 | union { |
| 1484 | struct { |
| 1485 | u8 dst_mac_addr[ETH_ALEN]; |
| 1486 | u16 vlan; |
| 1487 | }; |
| 1488 | u32 filter_key; |
| 1489 | }; |
| 1490 | }; |
| 1491 | |
| 1492 | struct bnxt_ipv4_tuple { |
| 1493 | struct flow_dissector_key_ipv4_addrs v4addrs; |
| 1494 | struct flow_dissector_key_ports ports; |
| 1495 | }; |
| 1496 | |
| 1497 | struct bnxt_ipv6_tuple { |
| 1498 | struct flow_dissector_key_ipv6_addrs v6addrs; |
| 1499 | struct flow_dissector_key_ports ports; |
| 1500 | }; |
| 1501 | |
| 1502 | #define BNXT_L2_KEY_SIZE (sizeof(struct bnxt_l2_key) / 4) |
| 1503 | |
| 1504 | struct bnxt_l2_filter { |
| 1505 | /* base filter must be the first member */ |
| 1506 | struct bnxt_filter_base base; |
| 1507 | struct bnxt_l2_key l2_key; |
| 1508 | atomic_t refcnt; |
| 1509 | }; |
| 1510 | |
| 1511 | /* Compat version of hwrm_port_phy_qcfg_output capped at 96 bytes. The |
| 1512 | * first 95 bytes are identical to hwrm_port_phy_qcfg_output in bnxt_hsi.h. |
| 1513 | * The last valid byte in the compat version is different. |
| 1514 | */ |
| 1515 | struct hwrm_port_phy_qcfg_output_compat { |
| 1516 | __le16 error_code; |
| 1517 | __le16 req_type; |
| 1518 | __le16 seq_id; |
| 1519 | __le16 resp_len; |
| 1520 | u8 link; |
| 1521 | u8 active_fec_signal_mode; |
| 1522 | __le16 link_speed; |
| 1523 | u8 duplex_cfg; |
| 1524 | u8 pause; |
| 1525 | __le16 support_speeds; |
| 1526 | __le16 force_link_speed; |
| 1527 | u8 auto_mode; |
| 1528 | u8 auto_pause; |
| 1529 | __le16 auto_link_speed; |
| 1530 | __le16 auto_link_speed_mask; |
| 1531 | u8 wirespeed; |
| 1532 | u8 lpbk; |
| 1533 | u8 force_pause; |
| 1534 | u8 module_status; |
| 1535 | __le32 preemphasis; |
| 1536 | u8 phy_maj; |
| 1537 | u8 phy_min; |
| 1538 | u8 phy_bld; |
| 1539 | u8 phy_type; |
| 1540 | u8 media_type; |
| 1541 | u8 xcvr_pkg_type; |
| 1542 | u8 eee_config_phy_addr; |
| 1543 | u8 parallel_detect; |
| 1544 | __le16 link_partner_adv_speeds; |
| 1545 | u8 link_partner_adv_auto_mode; |
| 1546 | u8 link_partner_adv_pause; |
| 1547 | __le16 adv_eee_link_speed_mask; |
| 1548 | __le16 link_partner_adv_eee_link_speed_mask; |
| 1549 | __le32 xcvr_identifier_type_tx_lpi_timer; |
| 1550 | __le16 fec_cfg; |
| 1551 | u8 duplex_state; |
| 1552 | u8 option_flags; |
| 1553 | char phy_vendor_name[16]; |
| 1554 | char phy_vendor_partnumber[16]; |
| 1555 | __le16 support_pam4_speeds; |
| 1556 | __le16 force_pam4_link_speed; |
| 1557 | __le16 auto_pam4_link_speed_mask; |
| 1558 | u8 link_partner_pam4_adv_speeds; |
| 1559 | u8 valid; |
| 1560 | }; |
| 1561 | |
| 1562 | struct bnxt_link_info { |
| 1563 | u8 phy_type; |
| 1564 | u8 media_type; |
| 1565 | u8 transceiver; |
| 1566 | u8 phy_addr; |
| 1567 | u8 phy_link_status; |
| 1568 | #define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK |
| 1569 | #define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL |
| 1570 | #define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK |
| 1571 | u8 wire_speed; |
| 1572 | u8 phy_state; |
| 1573 | #define BNXT_PHY_STATE_ENABLED 0 |
| 1574 | #define BNXT_PHY_STATE_DISABLED 1 |
| 1575 | |
| 1576 | u8 link_state; |
| 1577 | #define BNXT_LINK_STATE_UNKNOWN 0 |
| 1578 | #define BNXT_LINK_STATE_DOWN 1 |
| 1579 | #define BNXT_LINK_STATE_UP 2 |
| 1580 | #define BNXT_LINK_IS_UP(bp) ((bp)->link_info.link_state == BNXT_LINK_STATE_UP) |
| 1581 | u8 link_down_reason; |
| 1582 | u8 active_lanes; |
| 1583 | u8 duplex; |
| 1584 | #define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF |
| 1585 | #define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL |
| 1586 | u8 pause; |
| 1587 | #define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX |
| 1588 | #define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX |
| 1589 | #define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \ |
| 1590 | PORT_PHY_QCFG_RESP_PAUSE_TX) |
| 1591 | u8 lp_pause; |
| 1592 | u8 auto_pause_setting; |
| 1593 | u8 force_pause_setting; |
| 1594 | u8 duplex_setting; |
| 1595 | u8 auto_mode; |
| 1596 | #define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \ |
| 1597 | (mode) <= BNXT_LINK_AUTO_MSK) |
| 1598 | #define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE |
| 1599 | #define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS |
| 1600 | #define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED |
| 1601 | #define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW |
| 1602 | #define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK |
| 1603 | #define PHY_VER_LEN 3 |
| 1604 | u8 phy_ver[PHY_VER_LEN]; |
| 1605 | u16 link_speed; |
| 1606 | #define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB |
| 1607 | #define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB |
| 1608 | #define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB |
| 1609 | #define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB |
| 1610 | #define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB |
| 1611 | #define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB |
| 1612 | #define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB |
| 1613 | #define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB |
| 1614 | #define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB |
| 1615 | #define BNXT_LINK_SPEED_100GB PORT_PHY_QCFG_RESP_LINK_SPEED_100GB |
| 1616 | #define BNXT_LINK_SPEED_200GB PORT_PHY_QCFG_RESP_LINK_SPEED_200GB |
| 1617 | #define BNXT_LINK_SPEED_400GB PORT_PHY_QCFG_RESP_LINK_SPEED_400GB |
| 1618 | u16 support_speeds; |
| 1619 | u16 support_pam4_speeds; |
| 1620 | u16 support_speeds2; |
| 1621 | |
| 1622 | u16 auto_link_speeds; /* fw adv setting */ |
| 1623 | #define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB |
| 1624 | #define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB |
| 1625 | #define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB |
| 1626 | #define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB |
| 1627 | #define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB |
| 1628 | #define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB |
| 1629 | #define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB |
| 1630 | #define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB |
| 1631 | #define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB |
| 1632 | #define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB |
| 1633 | u16 auto_pam4_link_speeds; |
| 1634 | #define BNXT_LINK_PAM4_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_50G |
| 1635 | #define BNXT_LINK_PAM4_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_100G |
| 1636 | #define BNXT_LINK_PAM4_SPEED_MSK_200GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_200G |
| 1637 | u16 auto_link_speeds2; |
| 1638 | #define BNXT_LINK_SPEEDS2_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_1GB |
| 1639 | #define BNXT_LINK_SPEEDS2_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_10GB |
| 1640 | #define BNXT_LINK_SPEEDS2_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_25GB |
| 1641 | #define BNXT_LINK_SPEEDS2_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_40GB |
| 1642 | #define BNXT_LINK_SPEEDS2_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_50GB |
| 1643 | #define BNXT_LINK_SPEEDS2_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB |
| 1644 | #define BNXT_LINK_SPEEDS2_MSK_50GB_PAM4 \ |
| 1645 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_50GB_PAM4_56 |
| 1646 | #define BNXT_LINK_SPEEDS2_MSK_100GB_PAM4 \ |
| 1647 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB_PAM4_56 |
| 1648 | #define BNXT_LINK_SPEEDS2_MSK_200GB_PAM4 \ |
| 1649 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_200GB_PAM4_56 |
| 1650 | #define BNXT_LINK_SPEEDS2_MSK_400GB_PAM4 \ |
| 1651 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_400GB_PAM4_56 |
| 1652 | #define BNXT_LINK_SPEEDS2_MSK_100GB_PAM4_112 \ |
| 1653 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB_PAM4_112 |
| 1654 | #define BNXT_LINK_SPEEDS2_MSK_200GB_PAM4_112 \ |
| 1655 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_200GB_PAM4_112 |
| 1656 | #define BNXT_LINK_SPEEDS2_MSK_400GB_PAM4_112 \ |
| 1657 | PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_400GB_PAM4_112 |
| 1658 | |
| 1659 | u16 support_auto_speeds; |
| 1660 | u16 support_pam4_auto_speeds; |
| 1661 | u16 support_auto_speeds2; |
| 1662 | |
| 1663 | u16 lp_auto_link_speeds; |
| 1664 | u16 lp_auto_pam4_link_speeds; |
| 1665 | u16 force_link_speed; |
| 1666 | u16 force_pam4_link_speed; |
| 1667 | u16 force_link_speed2; |
| 1668 | #define BNXT_LINK_SPEED_50GB_PAM4 \ |
| 1669 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_50GB_PAM4_56 |
| 1670 | #define BNXT_LINK_SPEED_100GB_PAM4 \ |
| 1671 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_56 |
| 1672 | #define BNXT_LINK_SPEED_200GB_PAM4 \ |
| 1673 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_56 |
| 1674 | #define BNXT_LINK_SPEED_400GB_PAM4 \ |
| 1675 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_56 |
| 1676 | #define BNXT_LINK_SPEED_100GB_PAM4_112 \ |
| 1677 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_112 |
| 1678 | #define BNXT_LINK_SPEED_200GB_PAM4_112 \ |
| 1679 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_112 |
| 1680 | #define BNXT_LINK_SPEED_400GB_PAM4_112 \ |
| 1681 | PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_112 |
| 1682 | |
| 1683 | u32 preemphasis; |
| 1684 | u8 module_status; |
| 1685 | u8 active_fec_sig_mode; |
| 1686 | u16 fec_cfg; |
| 1687 | #define BNXT_FEC_NONE PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED |
| 1688 | #define BNXT_FEC_AUTONEG_CAP PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_SUPPORTED |
| 1689 | #define BNXT_FEC_AUTONEG PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED |
| 1690 | #define BNXT_FEC_ENC_BASE_R_CAP \ |
| 1691 | PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_SUPPORTED |
| 1692 | #define BNXT_FEC_ENC_BASE_R PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED |
| 1693 | #define BNXT_FEC_ENC_RS_CAP \ |
| 1694 | PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_SUPPORTED |
| 1695 | #define BNXT_FEC_ENC_LLRS_CAP \ |
| 1696 | (PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_SUPPORTED | \ |
| 1697 | PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_SUPPORTED) |
| 1698 | #define BNXT_FEC_ENC_RS \ |
| 1699 | (PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED | \ |
| 1700 | PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_1XN_ENABLED | \ |
| 1701 | PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_IEEE_ENABLED) |
| 1702 | #define BNXT_FEC_ENC_LLRS \ |
| 1703 | (PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_ENABLED | \ |
| 1704 | PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_ENABLED) |
| 1705 | |
| 1706 | /* copy of requested setting from ethtool cmd */ |
| 1707 | u8 autoneg; |
| 1708 | #define BNXT_AUTONEG_SPEED 1 |
| 1709 | #define BNXT_AUTONEG_FLOW_CTRL 2 |
| 1710 | u8 req_signal_mode; |
| 1711 | #define BNXT_SIG_MODE_NRZ PORT_PHY_QCFG_RESP_SIGNAL_MODE_NRZ |
| 1712 | #define BNXT_SIG_MODE_PAM4 PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4 |
| 1713 | #define BNXT_SIG_MODE_PAM4_112 PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4_112 |
| 1714 | #define BNXT_SIG_MODE_MAX (PORT_PHY_QCFG_RESP_SIGNAL_MODE_LAST + 1) |
| 1715 | u8 req_duplex; |
| 1716 | u8 req_flow_ctrl; |
| 1717 | u16 req_link_speed; |
| 1718 | u16 advertising; /* user adv setting */ |
| 1719 | u16 advertising_pam4; |
| 1720 | bool force_link_chng; |
| 1721 | |
| 1722 | bool phy_retry; |
| 1723 | unsigned long phy_retry_expires; |
| 1724 | |
| 1725 | /* a copy of phy_qcfg output used to report link |
| 1726 | * info to VF |
| 1727 | */ |
| 1728 | struct hwrm_port_phy_qcfg_output phy_qcfg_resp; |
| 1729 | }; |
| 1730 | |
| 1731 | #define BNXT_FEC_RS544_ON \ |
| 1732 | (PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_ENABLE | \ |
| 1733 | PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_ENABLE) |
| 1734 | |
| 1735 | #define BNXT_FEC_RS544_OFF \ |
| 1736 | (PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_DISABLE | \ |
| 1737 | PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_DISABLE) |
| 1738 | |
| 1739 | #define BNXT_FEC_RS272_ON \ |
| 1740 | (PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_ENABLE | \ |
| 1741 | PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_ENABLE) |
| 1742 | |
| 1743 | #define BNXT_FEC_RS272_OFF \ |
| 1744 | (PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_DISABLE | \ |
| 1745 | PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_DISABLE) |
| 1746 | |
| 1747 | #define BNXT_PAM4_SUPPORTED(link_info) \ |
| 1748 | ((link_info)->support_pam4_speeds) |
| 1749 | |
| 1750 | #define BNXT_FEC_RS_ON(link_info) \ |
| 1751 | (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE | \ |
| 1752 | PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ |
| 1753 | (BNXT_PAM4_SUPPORTED(link_info) ? \ |
| 1754 | (BNXT_FEC_RS544_ON | BNXT_FEC_RS272_OFF) : 0)) |
| 1755 | |
| 1756 | #define BNXT_FEC_LLRS_ON \ |
| 1757 | (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE | \ |
| 1758 | PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ |
| 1759 | BNXT_FEC_RS272_ON | BNXT_FEC_RS544_OFF) |
| 1760 | |
| 1761 | #define BNXT_FEC_RS_OFF(link_info) \ |
| 1762 | (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_DISABLE | \ |
| 1763 | (BNXT_PAM4_SUPPORTED(link_info) ? \ |
| 1764 | (BNXT_FEC_RS544_OFF | BNXT_FEC_RS272_OFF) : 0)) |
| 1765 | |
| 1766 | #define BNXT_FEC_BASE_R_ON(link_info) \ |
| 1767 | (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_ENABLE | \ |
| 1768 | BNXT_FEC_RS_OFF(link_info)) |
| 1769 | |
| 1770 | #define BNXT_FEC_ALL_OFF(link_info) \ |
| 1771 | (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ |
| 1772 | BNXT_FEC_RS_OFF(link_info)) |
| 1773 | |
| 1774 | struct bnxt_queue_info { |
| 1775 | u8 queue_id; |
| 1776 | u8 queue_profile; |
| 1777 | }; |
| 1778 | |
| 1779 | #define BNXT_MAX_LED 4 |
| 1780 | |
| 1781 | struct bnxt_led_info { |
| 1782 | u8 led_id; |
| 1783 | u8 led_type; |
| 1784 | u8 led_group_id; |
| 1785 | u8 unused; |
| 1786 | __le16 led_state_caps; |
| 1787 | #define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \ |
| 1788 | cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED)) |
| 1789 | |
| 1790 | __le16 led_color_caps; |
| 1791 | }; |
| 1792 | |
| 1793 | #define BNXT_MAX_TEST 8 |
| 1794 | |
| 1795 | struct bnxt_test_info { |
| 1796 | u8 offline_mask; |
| 1797 | u16 timeout; |
| 1798 | char string[BNXT_MAX_TEST][ETH_GSTRING_LEN]; |
| 1799 | }; |
| 1800 | |
| 1801 | #define CHIMP_REG_VIEW_ADDR \ |
| 1802 | ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) ? 0x80000000 : 0xb1000000) |
| 1803 | |
| 1804 | #define BNXT_GRCPF_REG_CHIMP_COMM 0x0 |
| 1805 | #define BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER 0x100 |
| 1806 | #define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400 |
| 1807 | |
| 1808 | #define BNXT_GRC_REG_STATUS_P5 0x520 |
| 1809 | |
| 1810 | #define BNXT_GRCPF_REG_KONG_COMM 0xA00 |
| 1811 | #define BNXT_GRCPF_REG_KONG_COMM_TRIGGER 0xB00 |
| 1812 | |
| 1813 | #define BNXT_GRC_REG_CHIP_NUM 0x48 |
| 1814 | #define BNXT_GRC_REG_BASE 0x260000 |
| 1815 | |
| 1816 | #define BNXT_TS_REG_TIMESYNC_TS0_LOWER 0x640180c |
| 1817 | #define BNXT_TS_REG_TIMESYNC_TS0_UPPER 0x6401810 |
| 1818 | |
| 1819 | #define BNXT_GRC_BASE_MASK 0xfffff000 |
| 1820 | #define BNXT_GRC_OFFSET_MASK 0x00000ffc |
| 1821 | |
| 1822 | struct bnxt_tc_flow_stats { |
| 1823 | u64 packets; |
| 1824 | u64 bytes; |
| 1825 | }; |
| 1826 | |
| 1827 | #ifdef CONFIG_BNXT_FLOWER_OFFLOAD |
| 1828 | struct bnxt_flower_indr_block_cb_priv { |
| 1829 | struct net_device *tunnel_netdev; |
| 1830 | struct bnxt *bp; |
| 1831 | struct list_head list; |
| 1832 | }; |
| 1833 | #endif |
| 1834 | |
| 1835 | struct bnxt_tc_info { |
| 1836 | bool enabled; |
| 1837 | |
| 1838 | /* hash table to store TC offloaded flows */ |
| 1839 | struct rhashtable flow_table; |
| 1840 | struct rhashtable_params flow_ht_params; |
| 1841 | |
| 1842 | /* hash table to store L2 keys of TC flows */ |
| 1843 | struct rhashtable l2_table; |
| 1844 | struct rhashtable_params l2_ht_params; |
| 1845 | /* hash table to store L2 keys for TC tunnel decap */ |
| 1846 | struct rhashtable decap_l2_table; |
| 1847 | struct rhashtable_params decap_l2_ht_params; |
| 1848 | /* hash table to store tunnel decap entries */ |
| 1849 | struct rhashtable decap_table; |
| 1850 | struct rhashtable_params decap_ht_params; |
| 1851 | /* hash table to store tunnel encap entries */ |
| 1852 | struct rhashtable encap_table; |
| 1853 | struct rhashtable_params encap_ht_params; |
| 1854 | |
| 1855 | /* lock to atomically add/del an l2 node when a flow is |
| 1856 | * added or deleted. |
| 1857 | */ |
| 1858 | struct mutex lock; |
| 1859 | |
| 1860 | /* Fields used for batching stats query */ |
| 1861 | struct rhashtable_iter iter; |
| 1862 | #define BNXT_FLOW_STATS_BATCH_MAX 10 |
| 1863 | struct bnxt_tc_stats_batch { |
| 1864 | void *flow_node; |
| 1865 | struct bnxt_tc_flow_stats hw_stats; |
| 1866 | } stats_batch[BNXT_FLOW_STATS_BATCH_MAX]; |
| 1867 | |
| 1868 | /* Stat counter mask (width) */ |
| 1869 | u64 bytes_mask; |
| 1870 | u64 packets_mask; |
| 1871 | }; |
| 1872 | |
| 1873 | struct bnxt_vf_rep_stats { |
| 1874 | u64 packets; |
| 1875 | u64 bytes; |
| 1876 | u64 dropped; |
| 1877 | }; |
| 1878 | |
| 1879 | struct bnxt_vf_rep { |
| 1880 | struct bnxt *bp; |
| 1881 | struct net_device *dev; |
| 1882 | struct metadata_dst *dst; |
| 1883 | u16 vf_idx; |
| 1884 | u16 tx_cfa_action; |
| 1885 | u16 rx_cfa_code; |
| 1886 | |
| 1887 | struct bnxt_vf_rep_stats rx_stats; |
| 1888 | struct bnxt_vf_rep_stats tx_stats; |
| 1889 | }; |
| 1890 | |
| 1891 | #define PTU_PTE_VALID 0x1UL |
| 1892 | #define PTU_PTE_LAST 0x2UL |
| 1893 | #define PTU_PTE_NEXT_TO_LAST 0x4UL |
| 1894 | |
| 1895 | #define MAX_CTX_PAGES (BNXT_PAGE_SIZE / 8) |
| 1896 | #define MAX_CTX_TOTAL_PAGES (MAX_CTX_PAGES * MAX_CTX_PAGES) |
| 1897 | #define MAX_CTX_BYTES ((size_t)MAX_CTX_TOTAL_PAGES * BNXT_PAGE_SIZE) |
| 1898 | #define MAX_CTX_BYTES_MASK (MAX_CTX_BYTES - 1) |
| 1899 | |
| 1900 | struct bnxt_ctx_pg_info { |
| 1901 | u32 entries; |
| 1902 | u32 nr_pages; |
| 1903 | void *ctx_pg_arr[MAX_CTX_PAGES]; |
| 1904 | dma_addr_t ctx_dma_arr[MAX_CTX_PAGES]; |
| 1905 | struct bnxt_ring_mem_info ring_mem; |
| 1906 | struct bnxt_ctx_pg_info **ctx_pg_tbl; |
| 1907 | }; |
| 1908 | |
| 1909 | #define BNXT_MAX_TQM_SP_RINGS 1 |
| 1910 | #define BNXT_MAX_TQM_FP_RINGS 8 |
| 1911 | #define BNXT_MAX_TQM_RINGS \ |
| 1912 | (BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_RINGS) |
| 1913 | |
| 1914 | #define BNXT_BACKING_STORE_CFG_LEGACY_LEN 256 |
| 1915 | |
| 1916 | #define BNXT_SET_CTX_PAGE_ATTR(attr) \ |
| 1917 | do { \ |
| 1918 | if (BNXT_PAGE_SIZE == 0x2000) \ |
| 1919 | attr = FUNC_BACKING_STORE_CFG_REQ_SRQ_PG_SIZE_PG_8K; \ |
| 1920 | else if (BNXT_PAGE_SIZE == 0x10000) \ |
| 1921 | attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_64K; \ |
| 1922 | else \ |
| 1923 | attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_4K; \ |
| 1924 | } while (0) |
| 1925 | |
| 1926 | struct bnxt_ctx_mem_type { |
| 1927 | u16 type; |
| 1928 | u16 entry_size; |
| 1929 | u32 flags; |
| 1930 | #define BNXT_CTX_MEM_TYPE_VALID FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_TYPE_VALID |
| 1931 | #define BNXT_CTX_MEM_FW_TRACE \ |
| 1932 | FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_FW_DBG_TRACE |
| 1933 | #define BNXT_CTX_MEM_FW_BIN_TRACE \ |
| 1934 | FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_FW_BIN_DBG_TRACE |
| 1935 | #define BNXT_CTX_MEM_PERSIST \ |
| 1936 | FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_NEXT_BS_OFFSET |
| 1937 | |
| 1938 | u32 instance_bmap; |
| 1939 | u8 init_value; |
| 1940 | u8 entry_multiple; |
| 1941 | u16 init_offset; |
| 1942 | #define BNXT_CTX_INIT_INVALID_OFFSET 0xffff |
| 1943 | u32 max_entries; |
| 1944 | u32 min_entries; |
| 1945 | u8 last:1; |
| 1946 | u8 mem_valid:1; |
| 1947 | u8 split_entry_cnt; |
| 1948 | #define BNXT_MAX_SPLIT_ENTRY 4 |
| 1949 | union { |
| 1950 | struct { |
| 1951 | u32 qp_l2_entries; |
| 1952 | u32 qp_qp1_entries; |
| 1953 | u32 qp_fast_qpmd_entries; |
| 1954 | }; |
| 1955 | u32 srq_l2_entries; |
| 1956 | u32 cq_l2_entries; |
| 1957 | u32 vnic_entries; |
| 1958 | struct { |
| 1959 | u32 mrav_av_entries; |
| 1960 | u32 mrav_num_entries_units; |
| 1961 | }; |
| 1962 | u32 split[BNXT_MAX_SPLIT_ENTRY]; |
| 1963 | }; |
| 1964 | struct bnxt_ctx_pg_info *pg_info; |
| 1965 | }; |
| 1966 | |
| 1967 | #define BNXT_CTX_MRAV_AV_SPLIT_ENTRY 0 |
| 1968 | |
| 1969 | #define BNXT_CTX_QP FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_QP |
| 1970 | #define BNXT_CTX_SRQ FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRQ |
| 1971 | #define BNXT_CTX_CQ FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CQ |
| 1972 | #define BNXT_CTX_VNIC FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_VNIC |
| 1973 | #define BNXT_CTX_STAT FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_STAT |
| 1974 | #define BNXT_CTX_STQM FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SP_TQM_RING |
| 1975 | #define BNXT_CTX_FTQM FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_FP_TQM_RING |
| 1976 | #define BNXT_CTX_MRAV FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_MRAV |
| 1977 | #define BNXT_CTX_TIM FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_TIM |
| 1978 | #define BNXT_CTX_TCK FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_TX_CK |
| 1979 | #define BNXT_CTX_RCK FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RX_CK |
| 1980 | #define BNXT_CTX_MTQM FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_MP_TQM_RING |
| 1981 | #define BNXT_CTX_SQDBS FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SQ_DB_SHADOW |
| 1982 | #define BNXT_CTX_RQDBS FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RQ_DB_SHADOW |
| 1983 | #define BNXT_CTX_SRQDBS FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRQ_DB_SHADOW |
| 1984 | #define BNXT_CTX_CQDBS FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CQ_DB_SHADOW |
| 1985 | #define BNXT_CTX_TBLSC FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_TBL_SCOPE |
| 1986 | #define BNXT_CTX_XPAR FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_XID_PARTITION |
| 1987 | #define BNXT_CTX_SRT FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRT_TRACE |
| 1988 | #define BNXT_CTX_SRT2 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRT2_TRACE |
| 1989 | #define BNXT_CTX_CRT FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CRT_TRACE |
| 1990 | #define BNXT_CTX_CRT2 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CRT2_TRACE |
| 1991 | #define BNXT_CTX_RIGP0 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RIGP0_TRACE |
| 1992 | #define BNXT_CTX_L2HWRM FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_L2_HWRM_TRACE |
| 1993 | #define BNXT_CTX_REHWRM FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_ROCE_HWRM_TRACE |
| 1994 | #define BNXT_CTX_CA0 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA0_TRACE |
| 1995 | #define BNXT_CTX_CA1 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA1_TRACE |
| 1996 | #define BNXT_CTX_CA2 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA2_TRACE |
| 1997 | #define BNXT_CTX_RIGP1 FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RIGP1_TRACE |
| 1998 | #define BNXT_CTX_KONG FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_AFM_KONG_HWRM_TRACE |
| 1999 | #define BNXT_CTX_QPC FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_ERR_QPC_TRACE |
| 2000 | |
| 2001 | #define BNXT_CTX_MAX (BNXT_CTX_TIM + 1) |
| 2002 | #define BNXT_CTX_L2_MAX (BNXT_CTX_FTQM + 1) |
| 2003 | #define BNXT_CTX_V2_MAX (BNXT_CTX_QPC + 1) |
| 2004 | #define BNXT_CTX_INV ((u16)-1) |
| 2005 | |
| 2006 | struct bnxt_ctx_mem_info { |
| 2007 | u8 tqm_fp_rings_count; |
| 2008 | |
| 2009 | u32 flags; |
| 2010 | #define BNXT_CTX_FLAG_INITED 0x01 |
| 2011 | struct bnxt_ctx_mem_type ctx_arr[BNXT_CTX_V2_MAX]; |
| 2012 | }; |
| 2013 | |
| 2014 | enum bnxt_health_severity { |
| 2015 | SEVERITY_NORMAL = 0, |
| 2016 | SEVERITY_WARNING, |
| 2017 | SEVERITY_RECOVERABLE, |
| 2018 | SEVERITY_FATAL, |
| 2019 | }; |
| 2020 | |
| 2021 | enum bnxt_health_remedy { |
| 2022 | REMEDY_DEVLINK_RECOVER, |
| 2023 | REMEDY_POWER_CYCLE_DEVICE, |
| 2024 | REMEDY_POWER_CYCLE_HOST, |
| 2025 | REMEDY_FW_UPDATE, |
| 2026 | REMEDY_HW_REPLACE, |
| 2027 | }; |
| 2028 | |
| 2029 | struct bnxt_fw_health { |
| 2030 | u32 flags; |
| 2031 | u32 polling_dsecs; |
| 2032 | u32 master_func_wait_dsecs; |
| 2033 | u32 normal_func_wait_dsecs; |
| 2034 | u32 post_reset_wait_dsecs; |
| 2035 | u32 post_reset_max_wait_dsecs; |
| 2036 | u32 regs[4]; |
| 2037 | u32 mapped_regs[4]; |
| 2038 | #define BNXT_FW_HEALTH_REG 0 |
| 2039 | #define BNXT_FW_HEARTBEAT_REG 1 |
| 2040 | #define BNXT_FW_RESET_CNT_REG 2 |
| 2041 | #define BNXT_FW_RESET_INPROG_REG 3 |
| 2042 | u32 fw_reset_inprog_reg_mask; |
| 2043 | u32 last_fw_heartbeat; |
| 2044 | u32 last_fw_reset_cnt; |
| 2045 | u8 enabled:1; |
| 2046 | u8 primary:1; |
| 2047 | u8 status_reliable:1; |
| 2048 | u8 resets_reliable:1; |
| 2049 | u8 tmr_multiplier; |
| 2050 | u8 tmr_counter; |
| 2051 | u8 fw_reset_seq_cnt; |
| 2052 | u32 fw_reset_seq_regs[16]; |
| 2053 | u32 fw_reset_seq_vals[16]; |
| 2054 | u32 fw_reset_seq_delay_msec[16]; |
| 2055 | u32 echo_req_data1; |
| 2056 | u32 echo_req_data2; |
| 2057 | struct devlink_health_reporter *fw_reporter; |
| 2058 | /* Protects severity and remedy */ |
| 2059 | struct mutex lock; |
| 2060 | enum bnxt_health_severity severity; |
| 2061 | enum bnxt_health_remedy remedy; |
| 2062 | u32 arrests; |
| 2063 | u32 discoveries; |
| 2064 | u32 survivals; |
| 2065 | u32 fatalities; |
| 2066 | u32 diagnoses; |
| 2067 | }; |
| 2068 | |
| 2069 | #define BNXT_FW_HEALTH_REG_TYPE_MASK 3 |
| 2070 | #define BNXT_FW_HEALTH_REG_TYPE_CFG 0 |
| 2071 | #define BNXT_FW_HEALTH_REG_TYPE_GRC 1 |
| 2072 | #define BNXT_FW_HEALTH_REG_TYPE_BAR0 2 |
| 2073 | #define BNXT_FW_HEALTH_REG_TYPE_BAR1 3 |
| 2074 | |
| 2075 | #define BNXT_FW_HEALTH_REG_TYPE(reg) ((reg) & BNXT_FW_HEALTH_REG_TYPE_MASK) |
| 2076 | #define BNXT_FW_HEALTH_REG_OFF(reg) ((reg) & ~BNXT_FW_HEALTH_REG_TYPE_MASK) |
| 2077 | |
| 2078 | #define BNXT_FW_HEALTH_WIN_BASE 0x3000 |
| 2079 | #define BNXT_FW_HEALTH_WIN_MAP_OFF 8 |
| 2080 | |
| 2081 | #define BNXT_FW_HEALTH_WIN_OFF(reg) (BNXT_FW_HEALTH_WIN_BASE + \ |
| 2082 | ((reg) & BNXT_GRC_OFFSET_MASK)) |
| 2083 | |
| 2084 | #define BNXT_FW_STATUS_HEALTH_MSK 0xffff |
| 2085 | #define BNXT_FW_STATUS_HEALTHY 0x8000 |
| 2086 | #define BNXT_FW_STATUS_SHUTDOWN 0x100000 |
| 2087 | #define BNXT_FW_STATUS_RECOVERING 0x400000 |
| 2088 | |
| 2089 | #define BNXT_FW_IS_HEALTHY(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) ==\ |
| 2090 | BNXT_FW_STATUS_HEALTHY) |
| 2091 | |
| 2092 | #define BNXT_FW_IS_BOOTING(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) < \ |
| 2093 | BNXT_FW_STATUS_HEALTHY) |
| 2094 | |
| 2095 | #define BNXT_FW_IS_ERR(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) > \ |
| 2096 | BNXT_FW_STATUS_HEALTHY) |
| 2097 | |
| 2098 | #define BNXT_FW_IS_RECOVERING(sts) (BNXT_FW_IS_ERR(sts) && \ |
| 2099 | ((sts) & BNXT_FW_STATUS_RECOVERING)) |
| 2100 | |
| 2101 | #define BNXT_FW_RETRY 5 |
| 2102 | #define BNXT_FW_IF_RETRY 10 |
| 2103 | #define BNXT_FW_SLOT_RESET_RETRY 4 |
| 2104 | |
| 2105 | enum board_idx { |
| 2106 | BCM57301, |
| 2107 | BCM57302, |
| 2108 | BCM57304, |
| 2109 | BCM57417_NPAR, |
| 2110 | BCM58700, |
| 2111 | BCM57311, |
| 2112 | BCM57312, |
| 2113 | BCM57402, |
| 2114 | BCM57404, |
| 2115 | BCM57406, |
| 2116 | BCM57402_NPAR, |
| 2117 | BCM57407, |
| 2118 | BCM57412, |
| 2119 | BCM57414, |
| 2120 | BCM57416, |
| 2121 | BCM57417, |
| 2122 | BCM57412_NPAR, |
| 2123 | BCM57314, |
| 2124 | BCM57417_SFP, |
| 2125 | BCM57416_SFP, |
| 2126 | BCM57404_NPAR, |
| 2127 | BCM57406_NPAR, |
| 2128 | BCM57407_SFP, |
| 2129 | BCM57407_NPAR, |
| 2130 | BCM57414_NPAR, |
| 2131 | BCM57416_NPAR, |
| 2132 | BCM57452, |
| 2133 | BCM57454, |
| 2134 | BCM5745x_NPAR, |
| 2135 | BCM57508, |
| 2136 | BCM57504, |
| 2137 | BCM57502, |
| 2138 | BCM57508_NPAR, |
| 2139 | BCM57504_NPAR, |
| 2140 | BCM57502_NPAR, |
| 2141 | BCM57608, |
| 2142 | BCM57604, |
| 2143 | BCM57602, |
| 2144 | BCM57601, |
| 2145 | BCM58802, |
| 2146 | BCM58804, |
| 2147 | BCM58808, |
| 2148 | NETXTREME_E_VF, |
| 2149 | NETXTREME_C_VF, |
| 2150 | NETXTREME_S_VF, |
| 2151 | NETXTREME_C_VF_HV, |
| 2152 | NETXTREME_E_VF_HV, |
| 2153 | NETXTREME_E_P5_VF, |
| 2154 | NETXTREME_E_P5_VF_HV, |
| 2155 | NETXTREME_E_P7_VF, |
| 2156 | NETXTREME_E_P7_VF_HV, |
| 2157 | }; |
| 2158 | |
| 2159 | #define BNXT_TRACE_BUF_MAGIC_BYTE ((u8)0xbc) |
| 2160 | #define BNXT_TRACE_MAX (DBG_LOG_BUFFER_FLUSH_REQ_TYPE_ERR_QPC_TRACE + 1) |
| 2161 | |
| 2162 | struct bnxt_bs_trace_info { |
| 2163 | u8 *magic_byte; |
| 2164 | u32 last_offset; |
| 2165 | u8 wrapped:1; |
| 2166 | u16 ctx_type; |
| 2167 | u16 trace_type; |
| 2168 | }; |
| 2169 | |
| 2170 | static inline void bnxt_bs_trace_check_wrap(struct bnxt_bs_trace_info *bs_trace, |
| 2171 | u32 offset) |
| 2172 | { |
| 2173 | if (!bs_trace->wrapped && bs_trace->magic_byte && |
| 2174 | *bs_trace->magic_byte != BNXT_TRACE_BUF_MAGIC_BYTE) |
| 2175 | bs_trace->wrapped = 1; |
| 2176 | bs_trace->last_offset = offset; |
| 2177 | } |
| 2178 | |
| 2179 | struct bnxt { |
| 2180 | void __iomem *bar0; |
| 2181 | void __iomem *bar1; |
| 2182 | void __iomem *bar2; |
| 2183 | |
| 2184 | u32 reg_base; |
| 2185 | u16 chip_num; |
| 2186 | #define CHIP_NUM_57301 0x16c8 |
| 2187 | #define CHIP_NUM_57302 0x16c9 |
| 2188 | #define CHIP_NUM_57304 0x16ca |
| 2189 | #define CHIP_NUM_58700 0x16cd |
| 2190 | #define CHIP_NUM_57402 0x16d0 |
| 2191 | #define CHIP_NUM_57404 0x16d1 |
| 2192 | #define CHIP_NUM_57406 0x16d2 |
| 2193 | #define CHIP_NUM_57407 0x16d5 |
| 2194 | |
| 2195 | #define CHIP_NUM_57311 0x16ce |
| 2196 | #define CHIP_NUM_57312 0x16cf |
| 2197 | #define CHIP_NUM_57314 0x16df |
| 2198 | #define CHIP_NUM_57317 0x16e0 |
| 2199 | #define CHIP_NUM_57412 0x16d6 |
| 2200 | #define CHIP_NUM_57414 0x16d7 |
| 2201 | #define CHIP_NUM_57416 0x16d8 |
| 2202 | #define CHIP_NUM_57417 0x16d9 |
| 2203 | #define CHIP_NUM_57412L 0x16da |
| 2204 | #define CHIP_NUM_57414L 0x16db |
| 2205 | |
| 2206 | #define CHIP_NUM_5745X 0xd730 |
| 2207 | #define CHIP_NUM_57452 0xc452 |
| 2208 | #define CHIP_NUM_57454 0xc454 |
| 2209 | |
| 2210 | #define CHIP_NUM_57508 0x1750 |
| 2211 | #define CHIP_NUM_57504 0x1751 |
| 2212 | #define CHIP_NUM_57502 0x1752 |
| 2213 | |
| 2214 | #define CHIP_NUM_57608 0x1760 |
| 2215 | |
| 2216 | #define CHIP_NUM_58802 0xd802 |
| 2217 | #define CHIP_NUM_58804 0xd804 |
| 2218 | #define CHIP_NUM_58808 0xd808 |
| 2219 | |
| 2220 | u8 chip_rev; |
| 2221 | |
| 2222 | #define BNXT_CHIP_NUM_5730X(chip_num) \ |
| 2223 | ((chip_num) >= CHIP_NUM_57301 && \ |
| 2224 | (chip_num) <= CHIP_NUM_57304) |
| 2225 | |
| 2226 | #define BNXT_CHIP_NUM_5740X(chip_num) \ |
| 2227 | (((chip_num) >= CHIP_NUM_57402 && \ |
| 2228 | (chip_num) <= CHIP_NUM_57406) || \ |
| 2229 | (chip_num) == CHIP_NUM_57407) |
| 2230 | |
| 2231 | #define BNXT_CHIP_NUM_5731X(chip_num) \ |
| 2232 | ((chip_num) == CHIP_NUM_57311 || \ |
| 2233 | (chip_num) == CHIP_NUM_57312 || \ |
| 2234 | (chip_num) == CHIP_NUM_57314 || \ |
| 2235 | (chip_num) == CHIP_NUM_57317) |
| 2236 | |
| 2237 | #define BNXT_CHIP_NUM_5741X(chip_num) \ |
| 2238 | ((chip_num) >= CHIP_NUM_57412 && \ |
| 2239 | (chip_num) <= CHIP_NUM_57414L) |
| 2240 | |
| 2241 | #define BNXT_CHIP_NUM_58700(chip_num) \ |
| 2242 | ((chip_num) == CHIP_NUM_58700) |
| 2243 | |
| 2244 | #define BNXT_CHIP_NUM_5745X(chip_num) \ |
| 2245 | ((chip_num) == CHIP_NUM_5745X || \ |
| 2246 | (chip_num) == CHIP_NUM_57452 || \ |
| 2247 | (chip_num) == CHIP_NUM_57454) |
| 2248 | |
| 2249 | |
| 2250 | #define BNXT_CHIP_NUM_57X0X(chip_num) \ |
| 2251 | (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num)) |
| 2252 | |
| 2253 | #define BNXT_CHIP_NUM_57X1X(chip_num) \ |
| 2254 | (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num)) |
| 2255 | |
| 2256 | #define BNXT_CHIP_NUM_588XX(chip_num) \ |
| 2257 | ((chip_num) == CHIP_NUM_58802 || \ |
| 2258 | (chip_num) == CHIP_NUM_58804 || \ |
| 2259 | (chip_num) == CHIP_NUM_58808) |
| 2260 | |
| 2261 | #define BNXT_VPD_FLD_LEN 32 |
| 2262 | char board_partno[BNXT_VPD_FLD_LEN]; |
| 2263 | char board_serialno[BNXT_VPD_FLD_LEN]; |
| 2264 | |
| 2265 | struct net_device *dev; |
| 2266 | struct pci_dev *pdev; |
| 2267 | |
| 2268 | atomic_t intr_sem; |
| 2269 | |
| 2270 | u32 flags; |
| 2271 | #define BNXT_FLAG_CHIP_P5_PLUS 0x1 |
| 2272 | #define BNXT_FLAG_VF 0x2 |
| 2273 | #define BNXT_FLAG_LRO 0x4 |
| 2274 | #ifdef CONFIG_INET |
| 2275 | #define BNXT_FLAG_GRO 0x8 |
| 2276 | #else |
| 2277 | /* Cannot support hardware GRO if CONFIG_INET is not set */ |
| 2278 | #define BNXT_FLAG_GRO 0x0 |
| 2279 | #endif |
| 2280 | #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO) |
| 2281 | #define BNXT_FLAG_JUMBO 0x10 |
| 2282 | #define BNXT_FLAG_STRIP_VLAN 0x20 |
| 2283 | #define BNXT_FLAG_RFS 0x100 |
| 2284 | #define BNXT_FLAG_SHARED_RINGS 0x200 |
| 2285 | #define BNXT_FLAG_PORT_STATS 0x400 |
| 2286 | #define BNXT_FLAG_WOL_CAP 0x4000 |
| 2287 | #define BNXT_FLAG_ROCEV1_CAP 0x8000 |
| 2288 | #define BNXT_FLAG_ROCEV2_CAP 0x10000 |
| 2289 | #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \ |
| 2290 | BNXT_FLAG_ROCEV2_CAP) |
| 2291 | #define BNXT_FLAG_NO_AGG_RINGS 0x20000 |
| 2292 | #define BNXT_FLAG_RX_PAGE_MODE 0x40000 |
| 2293 | #define BNXT_FLAG_CHIP_P7 0x80000 |
| 2294 | #define BNXT_FLAG_MULTI_HOST 0x100000 |
| 2295 | #define BNXT_FLAG_DSN_VALID 0x200000 |
| 2296 | #define BNXT_FLAG_DOUBLE_DB 0x400000 |
| 2297 | #define BNXT_FLAG_UDP_GSO_CAP 0x800000 |
| 2298 | #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000 |
| 2299 | #define BNXT_FLAG_DIM 0x2000000 |
| 2300 | #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000 |
| 2301 | #define BNXT_FLAG_TX_COAL_CMPL 0x8000000 |
| 2302 | #define BNXT_FLAG_PORT_STATS_EXT 0x10000000 |
| 2303 | #define BNXT_FLAG_HDS 0x20000000 |
| 2304 | #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ |
| 2305 | BNXT_FLAG_LRO | BNXT_FLAG_HDS) |
| 2306 | |
| 2307 | #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ |
| 2308 | BNXT_FLAG_RFS | \ |
| 2309 | BNXT_FLAG_STRIP_VLAN) |
| 2310 | |
| 2311 | #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF)) |
| 2312 | #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF) |
| 2313 | #ifdef CONFIG_BNXT_SRIOV |
| 2314 | #define BNXT_VF_IS_TRUSTED(bp) ((bp)->vf.flags & BNXT_VF_TRUST) |
| 2315 | #else |
| 2316 | #define BNXT_VF_IS_TRUSTED(bp) 0 |
| 2317 | #endif |
| 2318 | #define BNXT_NPAR(bp) ((bp)->port_partition_type) |
| 2319 | #define BNXT_MH(bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST) |
| 2320 | #define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp)) |
| 2321 | #define BNXT_SH_PORT_CFG_OK(bp) (BNXT_PF(bp) && \ |
| 2322 | ((bp)->phy_flags & BNXT_PHY_FL_SHARED_PORT_CFG)) |
| 2323 | #define BNXT_PHY_CFG_ABLE(bp) ((BNXT_SINGLE_PF(bp) || \ |
| 2324 | BNXT_SH_PORT_CFG_OK(bp)) && \ |
| 2325 | (bp)->link_info.phy_state == BNXT_PHY_STATE_ENABLED) |
| 2326 | #define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0) |
| 2327 | #define BNXT_RX_PAGE_MODE(bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE) |
| 2328 | #define BNXT_SUPPORTS_TPA(bp) (!BNXT_CHIP_TYPE_NITRO_A0(bp) && \ |
| 2329 | (!((bp)->flags & BNXT_FLAG_CHIP_P5_PLUS) ||\ |
| 2330 | (bp)->max_tpa_v2) && !is_kdump_kernel()) |
| 2331 | #define BNXT_RX_JUMBO_MODE(bp) ((bp)->flags & BNXT_FLAG_JUMBO) |
| 2332 | |
| 2333 | #define BNXT_CHIP_P7(bp) \ |
| 2334 | ((bp)->chip_num == CHIP_NUM_57608) |
| 2335 | |
| 2336 | #define BNXT_CHIP_P5(bp) \ |
| 2337 | ((bp)->chip_num == CHIP_NUM_57508 || \ |
| 2338 | (bp)->chip_num == CHIP_NUM_57504 || \ |
| 2339 | (bp)->chip_num == CHIP_NUM_57502) |
| 2340 | |
| 2341 | /* Chip class phase 5 */ |
| 2342 | #define BNXT_CHIP_P5_PLUS(bp) \ |
| 2343 | (BNXT_CHIP_P5(bp) || BNXT_CHIP_P7(bp)) |
| 2344 | |
| 2345 | /* Chip class phase 4.x */ |
| 2346 | #define BNXT_CHIP_P4(bp) \ |
| 2347 | (BNXT_CHIP_NUM_57X1X((bp)->chip_num) || \ |
| 2348 | BNXT_CHIP_NUM_5745X((bp)->chip_num) || \ |
| 2349 | BNXT_CHIP_NUM_588XX((bp)->chip_num) || \ |
| 2350 | (BNXT_CHIP_NUM_58700((bp)->chip_num) && \ |
| 2351 | !BNXT_CHIP_TYPE_NITRO_A0(bp))) |
| 2352 | |
| 2353 | /* Chip class phase 3.x */ |
| 2354 | #define BNXT_CHIP_P3(bp) \ |
| 2355 | (BNXT_CHIP_NUM_57X0X((bp)->chip_num) || \ |
| 2356 | BNXT_CHIP_TYPE_NITRO_A0(bp)) |
| 2357 | |
| 2358 | #define BNXT_CHIP_P4_PLUS(bp) \ |
| 2359 | (BNXT_CHIP_P4(bp) || BNXT_CHIP_P5_PLUS(bp)) |
| 2360 | |
| 2361 | #define BNXT_CHIP_P5_AND_MINUS(bp) \ |
| 2362 | (BNXT_CHIP_P3(bp) || BNXT_CHIP_P4(bp) || BNXT_CHIP_P5(bp)) |
| 2363 | |
| 2364 | struct bnxt_aux_priv *aux_priv[__BNXT_AUXDEV_MAX]; |
| 2365 | struct bnxt_en_dev *edev[__BNXT_AUXDEV_MAX]; |
| 2366 | |
| 2367 | struct bnxt_napi **bnapi; |
| 2368 | |
| 2369 | struct bnxt_rx_ring_info *rx_ring; |
| 2370 | struct bnxt_tx_ring_info *tx_ring; |
| 2371 | u16 *tx_ring_map; |
| 2372 | |
| 2373 | struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int, |
| 2374 | struct sk_buff *); |
| 2375 | |
| 2376 | struct sk_buff * (*rx_skb_func)(struct bnxt *, |
| 2377 | struct bnxt_rx_ring_info *, |
| 2378 | u16, void *, u8 *, dma_addr_t, |
| 2379 | unsigned int); |
| 2380 | |
| 2381 | u16 max_tpa_v2; |
| 2382 | u16 max_tpa; |
| 2383 | u16 max_tpa_roundup_size; |
| 2384 | u32 rx_buf_size; |
| 2385 | u32 rx_buf_use_size; /* useable size */ |
| 2386 | u16 rx_offset; |
| 2387 | u16 rx_dma_offset; |
| 2388 | enum dma_data_direction rx_dir; |
| 2389 | u32 rx_ring_size; |
| 2390 | u32 rx_agg_ring_size; |
| 2391 | u32 rx_copybreak; |
| 2392 | u32 rx_ring_mask; |
| 2393 | u32 rx_agg_ring_mask; |
| 2394 | int rx_nr_pages; |
| 2395 | int rx_agg_nr_pages; |
| 2396 | int rx_nr_rings; |
| 2397 | int rsscos_nr_ctxs; |
| 2398 | |
| 2399 | u32 tx_ring_size; |
| 2400 | u32 tx_ring_mask; |
| 2401 | int tx_nr_pages; |
| 2402 | int tx_nr_rings; |
| 2403 | int tx_nr_rings_per_tc; |
| 2404 | int tx_nr_rings_xdp; |
| 2405 | |
| 2406 | int tx_wake_thresh; |
| 2407 | int tx_push_thresh; |
| 2408 | int tx_push_size; |
| 2409 | |
| 2410 | u32 cp_ring_size; |
| 2411 | u32 cp_ring_mask; |
| 2412 | u32 cp_bit; |
| 2413 | int cp_nr_pages; |
| 2414 | int cp_nr_rings; |
| 2415 | |
| 2416 | /* grp_info indexed by completion ring index */ |
| 2417 | struct bnxt_ring_grp_info *grp_info; |
| 2418 | struct bnxt_vnic_info *vnic_info; |
| 2419 | u32 num_rss_ctx; |
| 2420 | int nr_vnics; |
| 2421 | u32 *rss_indir_tbl; |
| 2422 | u16 rss_indir_tbl_entries; |
| 2423 | u32 rss_hash_cfg; |
| 2424 | u32 rss_hash_delta; |
| 2425 | u32 rss_cap; |
| 2426 | #define BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA BIT(0) |
| 2427 | #define BNXT_RSS_CAP_UDP_RSS_CAP BIT(1) |
| 2428 | #define BNXT_RSS_CAP_NEW_RSS_CAP BIT(2) |
| 2429 | #define BNXT_RSS_CAP_RSS_TCAM BIT(3) |
| 2430 | #define BNXT_RSS_CAP_AH_V4_RSS_CAP BIT(4) |
| 2431 | #define BNXT_RSS_CAP_AH_V6_RSS_CAP BIT(5) |
| 2432 | #define BNXT_RSS_CAP_ESP_V4_RSS_CAP BIT(6) |
| 2433 | #define BNXT_RSS_CAP_ESP_V6_RSS_CAP BIT(7) |
| 2434 | #define BNXT_RSS_CAP_MULTI_RSS_CTX BIT(8) |
| 2435 | #define BNXT_RSS_CAP_IPV6_FLOW_LABEL_RSS_CAP BIT(9) |
| 2436 | #define BNXT_RSS_CAP_LARGE_RSS_CTX BIT(10) |
| 2437 | |
| 2438 | u8 rss_hash_key[HW_HASH_KEY_SIZE]; |
| 2439 | u8 rss_hash_key_valid:1; |
| 2440 | u8 rss_hash_key_updated:1; |
| 2441 | |
| 2442 | u16 max_mtu; |
| 2443 | u16 tso_max_segs; |
| 2444 | u8 max_tc; |
| 2445 | u8 max_lltc; /* lossless TCs */ |
| 2446 | struct bnxt_queue_info q_info[BNXT_MAX_QUEUE]; |
| 2447 | u8 tc_to_qidx[BNXT_MAX_QUEUE]; |
| 2448 | u8 q_ids[BNXT_MAX_QUEUE]; |
| 2449 | u8 max_q; |
| 2450 | u8 cos0_cos1_shared; |
| 2451 | u8 num_tc; |
| 2452 | |
| 2453 | u16 max_pfcwd_tmo_ms; |
| 2454 | |
| 2455 | u8 tph_mode; |
| 2456 | |
| 2457 | unsigned int current_interval; |
| 2458 | #define BNXT_TIMER_INTERVAL HZ |
| 2459 | |
| 2460 | struct timer_list timer; |
| 2461 | |
| 2462 | unsigned long state; |
| 2463 | #define BNXT_STATE_OPEN 0 |
| 2464 | #define BNXT_STATE_IN_SP_TASK 1 |
| 2465 | #define BNXT_STATE_READ_STATS 2 |
| 2466 | #define BNXT_STATE_FW_RESET_DET 3 |
| 2467 | #define BNXT_STATE_IN_FW_RESET 4 |
| 2468 | #define BNXT_STATE_ABORT_ERR 5 |
| 2469 | #define BNXT_STATE_FW_FATAL_COND 6 |
| 2470 | #define BNXT_STATE_DRV_REGISTERED 7 |
| 2471 | #define BNXT_STATE_NAPI_DISABLED 9 |
| 2472 | #define BNXT_STATE_FW_ACTIVATE 11 |
| 2473 | #define BNXT_STATE_RECOVER 12 |
| 2474 | #define BNXT_STATE_FW_NON_FATAL_COND 13 |
| 2475 | #define BNXT_STATE_FW_ACTIVATE_RESET 14 |
| 2476 | #define BNXT_STATE_HALF_OPEN 15 /* For offline ethtool tests */ |
| 2477 | |
| 2478 | #define BNXT_NO_FW_ACCESS(bp) \ |
| 2479 | (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \ |
| 2480 | pci_channel_offline((bp)->pdev)) |
| 2481 | |
| 2482 | struct bnxt_irq *irq_tbl; |
| 2483 | /* IRQ affinity, indexed by completion ring. Kept across IRQ |
| 2484 | * reallocation, the MSI-X vector index is not stable. |
| 2485 | */ |
| 2486 | cpumask_var_t *ring_cpu_mask; |
| 2487 | /* Rings for which the mask above was configured from the outside, |
| 2488 | * rather than being our own default placement. |
| 2489 | */ |
| 2490 | unsigned long *ring_affinity_set; |
| 2491 | int max_irqs; |
| 2492 | int total_irqs; |
| 2493 | int ulp_num_msix_want; |
| 2494 | u8 mac_addr[ETH_ALEN]; |
| 2495 | |
| 2496 | #ifdef CONFIG_BNXT_DCB |
| 2497 | struct ieee_pfc *ieee_pfc; |
| 2498 | struct ieee_ets *ieee_ets; |
| 2499 | u8 dcbx_cap; |
| 2500 | u8 default_pri; |
| 2501 | u8 max_dscp_value; |
| 2502 | #endif /* CONFIG_BNXT_DCB */ |
| 2503 | |
| 2504 | u32 msg_enable; |
| 2505 | |
| 2506 | u64 fw_cap; |
| 2507 | #define BNXT_FW_CAP_SHORT_CMD BIT_ULL(0) |
| 2508 | #define BNXT_FW_CAP_LLDP_AGENT BIT_ULL(1) |
| 2509 | #define BNXT_FW_CAP_DCBX_AGENT BIT_ULL(2) |
| 2510 | #define BNXT_FW_CAP_NEW_RM BIT_ULL(3) |
| 2511 | #define BNXT_FW_CAP_IF_CHANGE BIT_ULL(4) |
| 2512 | #define BNXT_FW_CAP_ENABLE_RDMA_SRIOV BIT_ULL(5) |
| 2513 | #define BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED BIT_ULL(6) |
| 2514 | #define BNXT_FW_CAP_KONG_MB_CHNL BIT_ULL(7) |
| 2515 | #define BNXT_FW_CAP_ROCE_VF_DYN_ALLOC_SUPPORT BIT_ULL(8) |
| 2516 | #define BNXT_FW_CAP_LINK_ADMIN BIT_ULL(9) |
| 2517 | #define BNXT_FW_CAP_OVS_64BIT_HANDLE BIT_ULL(10) |
| 2518 | #define BNXT_FW_CAP_TRUSTED_VF BIT_ULL(11) |
| 2519 | #define BNXT_FW_CAP_ERROR_RECOVERY BIT_ULL(13) |
| 2520 | #define BNXT_FW_CAP_PKG_VER BIT_ULL(14) |
| 2521 | #define BNXT_FW_CAP_CFA_ADV_FLOW BIT_ULL(15) |
| 2522 | #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2 BIT_ULL(16) |
| 2523 | #define BNXT_FW_CAP_PCIE_STATS_SUPPORTED BIT_ULL(17) |
| 2524 | #define BNXT_FW_CAP_EXT_STATS_SUPPORTED BIT_ULL(18) |
| 2525 | #define BNXT_FW_CAP_TX_TS_CMP BIT_ULL(19) |
| 2526 | #define BNXT_FW_CAP_ERR_RECOVER_RELOAD BIT_ULL(20) |
| 2527 | #define BNXT_FW_CAP_HOT_RESET BIT_ULL(21) |
| 2528 | #define BNXT_FW_CAP_PTP_RTC BIT_ULL(22) |
| 2529 | #define BNXT_FW_CAP_RX_ALL_PKT_TS BIT_ULL(23) |
| 2530 | #define BNXT_FW_CAP_VLAN_RX_STRIP BIT_ULL(24) |
| 2531 | #define BNXT_FW_CAP_VLAN_TX_INSERT BIT_ULL(25) |
| 2532 | #define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED BIT_ULL(26) |
| 2533 | #define BNXT_FW_CAP_LIVEPATCH BIT_ULL(27) |
| 2534 | #define BNXT_FW_CAP_PTP_PPS BIT_ULL(28) |
| 2535 | #define BNXT_FW_CAP_HOT_RESET_IF BIT_ULL(29) |
| 2536 | #define BNXT_FW_CAP_RING_MONITOR BIT_ULL(30) |
| 2537 | #define BNXT_FW_CAP_DBG_QCAPS BIT_ULL(31) |
| 2538 | #define BNXT_FW_CAP_PTP BIT_ULL(32) |
| 2539 | #define BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED BIT_ULL(33) |
| 2540 | #define BNXT_FW_CAP_DFLT_VLAN_TPID_PCP BIT_ULL(34) |
| 2541 | #define BNXT_FW_CAP_PRE_RESV_VNICS BIT_ULL(35) |
| 2542 | #define BNXT_FW_CAP_BACKING_STORE_V2 BIT_ULL(36) |
| 2543 | #define BNXT_FW_CAP_VNIC_TUNNEL_TPA BIT_ULL(37) |
| 2544 | #define BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO BIT_ULL(38) |
| 2545 | #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3 BIT_ULL(39) |
| 2546 | #define BNXT_FW_CAP_VNIC_RE_FLUSH BIT_ULL(40) |
| 2547 | #define BNXT_FW_CAP_SW_MAX_RESOURCE_LIMITS BIT_ULL(41) |
| 2548 | #define BNXT_FW_CAP_NPAR_1_2 BIT_ULL(42) |
| 2549 | #define BNXT_FW_CAP_MIRROR_ON_ROCE BIT_ULL(43) |
| 2550 | #define BNXT_FW_CAP_PTP_PTM BIT_ULL(44) |
| 2551 | |
| 2552 | u32 fw_dbg_cap; |
| 2553 | |
| 2554 | #define BNXT_NEW_RM(bp) ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM) |
| 2555 | #define BNXT_PTP_USE_RTC(bp) (!BNXT_MH(bp) && \ |
| 2556 | ((bp)->fw_cap & BNXT_FW_CAP_PTP_RTC)) |
| 2557 | #define BNXT_SUPPORTS_NTUPLE_VNIC(bp) \ |
| 2558 | (BNXT_PF(bp) && ((bp)->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3)) |
| 2559 | |
| 2560 | #define BNXT_SUPPORTS_MULTI_RSS_CTX(bp) \ |
| 2561 | (BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) && \ |
| 2562 | ((bp)->rss_cap & BNXT_RSS_CAP_MULTI_RSS_CTX)) |
| 2563 | #define BNXT_ROCE_VF_DYN_ALLOC_CAP(bp) \ |
| 2564 | ((bp)->fw_cap & BNXT_FW_CAP_ROCE_VF_DYN_ALLOC_SUPPORT) |
| 2565 | #define BNXT_SUPPORTS_QUEUE_API(bp) \ |
| 2566 | (BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) && \ |
| 2567 | ((bp)->fw_cap & BNXT_FW_CAP_VNIC_RE_FLUSH)) |
| 2568 | #define BNXT_RDMA_SRIOV_EN(bp) \ |
| 2569 | ((bp)->fw_cap & BNXT_FW_CAP_ENABLE_RDMA_SRIOV) |
| 2570 | #define BNXT_ROCE_VF_RESC_CAP(bp) \ |
| 2571 | ((bp)->fw_cap & BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED) |
| 2572 | #define BNXT_SW_RES_LMT(bp) \ |
| 2573 | ((bp)->fw_cap & BNXT_FW_CAP_SW_MAX_RESOURCE_LIMITS) |
| 2574 | #define BNXT_MIRROR_ON_ROCE_CAP(bp) \ |
| 2575 | ((bp)->fw_cap & BNXT_FW_CAP_MIRROR_ON_ROCE) |
| 2576 | |
| 2577 | u32 hwrm_spec_code; |
| 2578 | u16 hwrm_cmd_seq; |
| 2579 | u16 hwrm_cmd_kong_seq; |
| 2580 | struct dma_pool *hwrm_dma_pool; |
| 2581 | struct hlist_head hwrm_pending_list; |
| 2582 | |
| 2583 | struct rtnl_link_stats64 net_stats_prev; |
| 2584 | struct bnxt_stats_mem port_stats; |
| 2585 | struct bnxt_stats_mem rx_port_stats_ext; |
| 2586 | struct bnxt_stats_mem tx_port_stats_ext; |
| 2587 | u16 fw_rx_stats_ext_size; |
| 2588 | u16 fw_tx_stats_ext_size; |
| 2589 | u16 hw_ring_stats_size; |
| 2590 | u16 pcie_stat_len; |
| 2591 | u8 pri2cos_idx[8]; |
| 2592 | u8 pri2cos_valid; |
| 2593 | |
| 2594 | struct bnxt_total_ring_drv_stats ring_drv_stats_prev; |
| 2595 | |
| 2596 | u16 hwrm_max_req_len; |
| 2597 | u16 hwrm_max_ext_req_len; |
| 2598 | unsigned int hwrm_cmd_timeout; |
| 2599 | unsigned int hwrm_cmd_max_timeout; |
| 2600 | struct mutex hwrm_cmd_lock; /* serialize hwrm messages */ |
| 2601 | struct hwrm_ver_get_output ver_resp; |
| 2602 | #define FW_VER_STR_LEN 32 |
| 2603 | #define BC_HWRM_STR_LEN 21 |
| 2604 | #define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN) |
| 2605 | char fw_ver_str[FW_VER_STR_LEN]; |
| 2606 | char hwrm_ver_supp[FW_VER_STR_LEN]; |
| 2607 | char nvm_cfg_ver[FW_VER_STR_LEN]; |
| 2608 | u64 fw_ver_code; |
| 2609 | #define BNXT_FW_VER_CODE(maj, min, bld, rsv) \ |
| 2610 | ((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv)) |
| 2611 | #define BNXT_FW_MAJ(bp) ((bp)->fw_ver_code >> 48) |
| 2612 | #define BNXT_FW_BLD(bp) (((bp)->fw_ver_code >> 16) & 0xffff) |
| 2613 | |
| 2614 | u16 vxlan_fw_dst_port_id; |
| 2615 | u16 nge_fw_dst_port_id; |
| 2616 | u16 vxlan_gpe_fw_dst_port_id; |
| 2617 | __be16 vxlan_port; |
| 2618 | __be16 nge_port; |
| 2619 | __be16 vxlan_gpe_port; |
| 2620 | u8 port_partition_type; |
| 2621 | u8 port_count; |
| 2622 | u16 br_mode; |
| 2623 | |
| 2624 | struct bnxt_coal_cap coal_cap; |
| 2625 | struct bnxt_coal rx_coal; |
| 2626 | struct bnxt_coal tx_coal; |
| 2627 | |
| 2628 | u32 stats_coal_ticks; |
| 2629 | #define BNXT_DEF_STATS_COAL_TICKS 1000000 |
| 2630 | #define BNXT_MIN_STATS_COAL_TICKS 250000 |
| 2631 | #define BNXT_MAX_STATS_COAL_TICKS 1000000 |
| 2632 | |
| 2633 | /* Protects stats_updated_jiffies and writes to sw_stats */ |
| 2634 | spinlock_t stats_lock; |
| 2635 | unsigned long stats_updated_jiffies; |
| 2636 | |
| 2637 | struct work_struct sp_task; |
| 2638 | unsigned long sp_event; |
| 2639 | #define BNXT_RX_NTP_FLTR_SP_EVENT 1 |
| 2640 | #define BNXT_LINK_CHNG_SP_EVENT 2 |
| 2641 | #define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3 |
| 2642 | #define BNXT_RESET_TASK_SP_EVENT 6 |
| 2643 | #define BNXT_RST_RING_SP_EVENT 7 |
| 2644 | #define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8 |
| 2645 | #define BNXT_PERIODIC_STATS_SP_EVENT 9 |
| 2646 | #define BNXT_HWRM_PORT_MODULE_SP_EVENT 10 |
| 2647 | #define BNXT_RESET_TASK_SILENT_SP_EVENT 11 |
| 2648 | #define BNXT_LINK_SPEED_CHNG_SP_EVENT 14 |
| 2649 | #define BNXT_FLOW_STATS_SP_EVENT 15 |
| 2650 | #define BNXT_UPDATE_PHY_SP_EVENT 16 |
| 2651 | #define BNXT_RING_COAL_NOW_SP_EVENT 17 |
| 2652 | #define BNXT_FW_RESET_NOTIFY_SP_EVENT 18 |
| 2653 | #define BNXT_FW_EXCEPTION_SP_EVENT 19 |
| 2654 | #define BNXT_TPH_UPDATE_SP_EVENT 20 |
| 2655 | #define BNXT_LINK_CFG_CHANGE_SP_EVENT 21 |
| 2656 | #define BNXT_THERMAL_THRESHOLD_SP_EVENT 22 |
| 2657 | #define BNXT_FW_ECHO_REQUEST_SP_EVENT 23 |
| 2658 | #define BNXT_RESTART_ULP_SP_EVENT 24 |
| 2659 | |
| 2660 | struct delayed_work fw_reset_task; |
| 2661 | int fw_reset_state; |
| 2662 | #define BNXT_FW_RESET_STATE_POLL_VF 1 |
| 2663 | #define BNXT_FW_RESET_STATE_RESET_FW 2 |
| 2664 | #define BNXT_FW_RESET_STATE_ENABLE_DEV 3 |
| 2665 | #define BNXT_FW_RESET_STATE_POLL_FW 4 |
| 2666 | #define BNXT_FW_RESET_STATE_OPENING 5 |
| 2667 | #define BNXT_FW_RESET_STATE_POLL_FW_DOWN 6 |
| 2668 | #define BNXT_FW_RESET_STATE_ABORT 7 |
| 2669 | |
| 2670 | u16 fw_reset_min_dsecs; |
| 2671 | #define BNXT_DFLT_FW_RST_MIN_DSECS 20 |
| 2672 | u16 fw_reset_max_dsecs; |
| 2673 | #define BNXT_DFLT_FW_RST_MAX_DSECS 60 |
| 2674 | unsigned long fw_reset_timestamp; |
| 2675 | |
| 2676 | struct bnxt_fw_health *fw_health; |
| 2677 | |
| 2678 | struct bnxt_hw_resc hw_resc; |
| 2679 | struct bnxt_pf_info pf; |
| 2680 | struct bnxt_ctx_mem_info *ctx; |
| 2681 | #ifdef CONFIG_BNXT_SRIOV |
| 2682 | int nr_vfs; |
| 2683 | struct bnxt_vf_info vf; |
| 2684 | wait_queue_head_t sriov_cfg_wait; |
| 2685 | bool sriov_cfg; |
| 2686 | #define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000) |
| 2687 | #endif |
| 2688 | |
| 2689 | #if BITS_PER_LONG == 32 |
| 2690 | /* ensure atomic 64-bit doorbell writes on 32-bit systems. */ |
| 2691 | spinlock_t db_lock; |
| 2692 | #endif |
| 2693 | int db_offset; /* db_offset within db_size */ |
| 2694 | int db_size; |
| 2695 | |
| 2696 | #define BNXT_NTP_FLTR_MAX_FLTR 4096 |
| 2697 | #define BNXT_MAX_FLTR (BNXT_NTP_FLTR_MAX_FLTR + BNXT_L2_FLTR_MAX_FLTR) |
| 2698 | #define BNXT_NTP_FLTR_HASH_SIZE 512 |
| 2699 | #define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1) |
| 2700 | struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE]; |
| 2701 | spinlock_t ntp_fltr_lock; /* for hash table add, del */ |
| 2702 | |
| 2703 | unsigned long *ntp_fltr_bmap; |
| 2704 | int ntp_fltr_count; |
| 2705 | int max_fltr; |
| 2706 | |
| 2707 | #define BNXT_L2_FLTR_MAX_FLTR 1024 |
| 2708 | #define BNXT_L2_FLTR_HASH_SIZE 32 |
| 2709 | #define BNXT_L2_FLTR_HASH_MASK (BNXT_L2_FLTR_HASH_SIZE - 1) |
| 2710 | struct hlist_head l2_fltr_hash_tbl[BNXT_L2_FLTR_HASH_SIZE]; |
| 2711 | |
| 2712 | u32 hash_seed; |
| 2713 | u64 toeplitz_prefix; |
| 2714 | |
| 2715 | struct list_head usr_fltr_list; |
| 2716 | |
| 2717 | /* To protect link related settings during link changes and |
| 2718 | * ethtool settings changes. |
| 2719 | */ |
| 2720 | struct mutex link_lock; |
| 2721 | struct bnxt_link_info link_info; |
| 2722 | struct ethtool_keee eee; |
| 2723 | u32 lpi_tmr_lo; |
| 2724 | u32 lpi_tmr_hi; |
| 2725 | |
| 2726 | /* copied from flags and flags2 in hwrm_port_phy_qcaps_output */ |
| 2727 | u32 phy_flags; |
| 2728 | #define BNXT_PHY_FL_EEE_CAP PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED |
| 2729 | #define BNXT_PHY_FL_EXT_LPBK PORT_PHY_QCAPS_RESP_FLAGS_EXTERNAL_LPBK_SUPPORTED |
| 2730 | #define BNXT_PHY_FL_AN_PHY_LPBK PORT_PHY_QCAPS_RESP_FLAGS_AUTONEG_LPBK_SUPPORTED |
| 2731 | #define BNXT_PHY_FL_SHARED_PORT_CFG PORT_PHY_QCAPS_RESP_FLAGS_SHARED_PHY_CFG_SUPPORTED |
| 2732 | #define BNXT_PHY_FL_PORT_STATS_NO_RESET PORT_PHY_QCAPS_RESP_FLAGS_CUMULATIVE_COUNTERS_ON_RESET |
| 2733 | #define BNXT_PHY_FL_NO_PHY_LPBK PORT_PHY_QCAPS_RESP_FLAGS_LOCAL_LPBK_NOT_SUPPORTED |
| 2734 | #define BNXT_PHY_FL_FW_MANAGED_LKDN PORT_PHY_QCAPS_RESP_FLAGS_FW_MANAGED_LINK_DOWN |
| 2735 | #define BNXT_PHY_FL_NO_FCS PORT_PHY_QCAPS_RESP_FLAGS_NO_FCS |
| 2736 | #define BNXT_PHY_FL_NO_PAUSE (PORT_PHY_QCAPS_RESP_FLAGS2_PAUSE_UNSUPPORTED << 8) |
| 2737 | #define BNXT_PHY_FL_NO_PFC (PORT_PHY_QCAPS_RESP_FLAGS2_PFC_UNSUPPORTED << 8) |
| 2738 | #define BNXT_PHY_FL_BANK_SEL (PORT_PHY_QCAPS_RESP_FLAGS2_BANK_ADDR_SUPPORTED << 8) |
| 2739 | #define BNXT_PHY_FL_SPEEDS2 (PORT_PHY_QCAPS_RESP_FLAGS2_SPEEDS2_SUPPORTED << 8) |
| 2740 | #define BNXT_PHY_FL_FDRSTATS (PORT_PHY_QCAPS_RESP_FLAGS2_FDRSTAT_CMD_SUPPORTED << 8) |
| 2741 | |
| 2742 | /* copied from flags in hwrm_port_mac_qcaps_output */ |
| 2743 | u8 mac_flags; |
| 2744 | #define BNXT_MAC_FL_NO_MAC_LPBK \ |
| 2745 | PORT_MAC_QCAPS_RESP_FLAGS_LOCAL_LPBK_NOT_SUPPORTED |
| 2746 | |
| 2747 | u8 num_tests; |
| 2748 | struct bnxt_test_info *test_info; |
| 2749 | |
| 2750 | u8 wol_filter_id; |
| 2751 | u8 wol; |
| 2752 | |
| 2753 | u8 num_leds; |
| 2754 | struct bnxt_led_info leds[BNXT_MAX_LED]; |
| 2755 | u16 dump_flag; |
| 2756 | #define BNXT_DUMP_LIVE 0 |
| 2757 | #define BNXT_DUMP_CRASH 1 |
| 2758 | #define BNXT_DUMP_DRIVER 2 |
| 2759 | #define BNXT_DUMP_LIVE_WITH_CTX_L1_CACHE 3 |
| 2760 | |
| 2761 | struct bpf_prog *xdp_prog; |
| 2762 | |
| 2763 | struct bnxt_ptp_cfg *ptp_cfg; |
| 2764 | u8 ptp_all_rx_tstamp; |
| 2765 | |
| 2766 | /* devlink interface and vf-rep structs */ |
| 2767 | struct devlink *dl; |
| 2768 | struct devlink_port dl_port; |
| 2769 | enum devlink_eswitch_mode eswitch_mode; |
| 2770 | struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */ |
| 2771 | u16 *cfa_code_map; /* cfa_code -> vf_idx map */ |
| 2772 | u8 dsn[8]; |
| 2773 | struct bnxt_tc_info *tc_info; |
| 2774 | struct list_head tc_indr_block_list; |
| 2775 | struct dentry *debugfs_pdev; |
| 2776 | #ifdef CONFIG_BNXT_HWMON |
| 2777 | struct device *hwmon_dev; |
| 2778 | u8 warn_thresh_temp; |
| 2779 | u8 crit_thresh_temp; |
| 2780 | u8 fatal_thresh_temp; |
| 2781 | u8 shutdown_thresh_temp; |
| 2782 | #endif |
| 2783 | u32 thermal_threshold_type; |
| 2784 | enum board_idx board_idx; |
| 2785 | |
| 2786 | struct bnxt_ctx_pg_info *fw_crash_mem; |
| 2787 | u32 fw_crash_len; |
| 2788 | struct bnxt_bs_trace_info bs_trace[BNXT_TRACE_MAX]; |
| 2789 | int auxdev_id; |
| 2790 | /* synchronize validity checks of available aux devices */ |
| 2791 | struct mutex auxdev_lock; |
| 2792 | u8 auxdev_state[__BNXT_AUXDEV_MAX]; |
| 2793 | #define BNXT_ADEV_STATE_NONE 0 |
| 2794 | #define BNXT_ADEV_STATE_INIT 1 |
| 2795 | #define BNXT_ADEV_STATE_ADD 2 |
| 2796 | }; |
| 2797 | |
| 2798 | #define BNXT_NUM_RX_RING_STATS 8 |
| 2799 | #define BNXT_NUM_TX_RING_STATS 8 |
| 2800 | #define BNXT_NUM_TPA_RING_STATS 4 |
| 2801 | #define BNXT_NUM_TPA_RING_STATS_P5 5 |
| 2802 | #define BNXT_NUM_TPA_RING_STATS_P7 6 |
| 2803 | |
| 2804 | #define BNXT_RING_STATS_SIZE_P5 \ |
| 2805 | ((BNXT_NUM_RX_RING_STATS + BNXT_NUM_TX_RING_STATS + \ |
| 2806 | BNXT_NUM_TPA_RING_STATS_P5) * 8) |
| 2807 | |
| 2808 | #define BNXT_RING_STATS_SIZE_P7 \ |
| 2809 | ((BNXT_NUM_RX_RING_STATS + BNXT_NUM_TX_RING_STATS + \ |
| 2810 | BNXT_NUM_TPA_RING_STATS_P7) * 8) |
| 2811 | |
| 2812 | #define BNXT_GET_RING_STATS64(sw, counter) \ |
| 2813 | (*((sw) + offsetof(struct ctx_hw_stats, counter) / 8)) |
| 2814 | |
| 2815 | #define BNXT_GET_RX_PORT_STATS64(sw, counter) \ |
| 2816 | (*((sw) + offsetof(struct rx_port_stats, counter) / 8)) |
| 2817 | |
| 2818 | #define BNXT_GET_TX_PORT_STATS64(sw, counter) \ |
| 2819 | (*((sw) + offsetof(struct tx_port_stats, counter) / 8)) |
| 2820 | |
| 2821 | #define BNXT_PORT_STATS_SIZE \ |
| 2822 | (sizeof(struct rx_port_stats) + sizeof(struct tx_port_stats) + 1024) |
| 2823 | |
| 2824 | #define BNXT_TX_PORT_STATS_BYTE_OFFSET \ |
| 2825 | (sizeof(struct rx_port_stats) + 512) |
| 2826 | |
| 2827 | #define BNXT_RX_STATS_OFFSET(counter) \ |
| 2828 | (offsetof(struct rx_port_stats, counter) / 8) |
| 2829 | |
| 2830 | #define BNXT_TX_STATS_OFFSET(counter) \ |
| 2831 | ((offsetof(struct tx_port_stats, counter) + \ |
| 2832 | BNXT_TX_PORT_STATS_BYTE_OFFSET) / 8) |
| 2833 | |
| 2834 | #define BNXT_RX_STATS_EXT_OFFSET(counter) \ |
| 2835 | (offsetof(struct rx_port_stats_ext, counter) / 8) |
| 2836 | |
| 2837 | #define BNXT_RX_STATS_EXT_NUM_LEGACY \ |
| 2838 | BNXT_RX_STATS_EXT_OFFSET(rx_fec_corrected_blocks) |
| 2839 | |
| 2840 | #define BNXT_TX_STATS_EXT_OFFSET(counter) \ |
| 2841 | (offsetof(struct tx_port_stats_ext, counter) / 8) |
| 2842 | |
| 2843 | #define BNXT_HW_FEATURE_VLAN_ALL_RX \ |
| 2844 | (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX) |
| 2845 | #define BNXT_HW_FEATURE_VLAN_ALL_TX \ |
| 2846 | (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX) |
| 2847 | |
| 2848 | #define I2C_DEV_ADDR_A0 0xa0 |
| 2849 | #define I2C_DEV_ADDR_A2 0xa2 |
| 2850 | #define SFF_DIAG_SUPPORT_OFFSET 0x5c |
| 2851 | #define SFF_MODULE_ID_SFP 0x3 |
| 2852 | #define SFF_MODULE_ID_QSFP 0xc |
| 2853 | #define SFF_MODULE_ID_QSFP_PLUS 0xd |
| 2854 | #define SFF_MODULE_ID_QSFP28 0x11 |
| 2855 | #define BNXT_MAX_PHY_I2C_RESP_SIZE 64 |
| 2856 | |
| 2857 | #define BNXT_HDS_THRESHOLD_MAX 1023 |
| 2858 | |
| 2859 | static inline u32 bnxt_tx_avail(struct bnxt *bp, |
| 2860 | const struct bnxt_tx_ring_info *txr) |
| 2861 | { |
| 2862 | u32 used = READ_ONCE(txr->tx_prod) - READ_ONCE(txr->tx_cons); |
| 2863 | |
| 2864 | return bp->tx_ring_size - (used & bp->tx_ring_mask); |
| 2865 | } |
| 2866 | |
| 2867 | static inline struct tx_bd_ext * |
| 2868 | bnxt_init_ext_bd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, |
| 2869 | u16 prod, __le32 lflags, u32 vlan_tag_flags, |
| 2870 | u32 cfa_action) |
| 2871 | { |
| 2872 | struct tx_bd_ext *txbd1; |
| 2873 | |
| 2874 | txbd1 = (struct tx_bd_ext *) |
| 2875 | &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; |
| 2876 | txbd1->tx_bd_hsize_lflags = lflags; |
| 2877 | txbd1->tx_bd_mss = 0; |
| 2878 | txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); |
| 2879 | txbd1->tx_bd_cfa_action = |
| 2880 | cpu_to_le32(cfa_action << TX_BD_CFA_ACTION_SHIFT); |
| 2881 | |
| 2882 | return txbd1; |
| 2883 | } |
| 2884 | |
| 2885 | static inline void bnxt_writeq(struct bnxt *bp, u64 val, |
| 2886 | volatile void __iomem *addr) |
| 2887 | { |
| 2888 | #if BITS_PER_LONG == 32 |
| 2889 | spin_lock(&bp->db_lock); |
| 2890 | lo_hi_writeq(val, addr); |
| 2891 | spin_unlock(&bp->db_lock); |
| 2892 | #else |
| 2893 | writeq(val, addr); |
| 2894 | #endif |
| 2895 | } |
| 2896 | |
| 2897 | static inline void bnxt_writeq_relaxed(struct bnxt *bp, u64 val, |
| 2898 | volatile void __iomem *addr) |
| 2899 | { |
| 2900 | #if BITS_PER_LONG == 32 |
| 2901 | spin_lock(&bp->db_lock); |
| 2902 | lo_hi_writeq_relaxed(val, addr); |
| 2903 | spin_unlock(&bp->db_lock); |
| 2904 | #else |
| 2905 | writeq_relaxed(val, addr); |
| 2906 | #endif |
| 2907 | } |
| 2908 | |
| 2909 | /* For TX and RX ring doorbells with no ordering guarantee*/ |
| 2910 | static inline void bnxt_db_write_relaxed(struct bnxt *bp, |
| 2911 | struct bnxt_db_info *db, u32 idx) |
| 2912 | { |
| 2913 | if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { |
| 2914 | bnxt_writeq_relaxed(bp, db->db_key64 | DB_RING_IDX(db, idx), |
| 2915 | db->doorbell); |
| 2916 | } else { |
| 2917 | u32 db_val = db->db_key32 | DB_RING_IDX(db, idx); |
| 2918 | |
| 2919 | writel_relaxed(db_val, db->doorbell); |
| 2920 | if (bp->flags & BNXT_FLAG_DOUBLE_DB) |
| 2921 | writel_relaxed(db_val, db->doorbell); |
| 2922 | } |
| 2923 | } |
| 2924 | |
| 2925 | /* For TX and RX ring doorbells */ |
| 2926 | static inline void bnxt_db_write(struct bnxt *bp, struct bnxt_db_info *db, |
| 2927 | u32 idx) |
| 2928 | { |
| 2929 | if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { |
| 2930 | bnxt_writeq(bp, db->db_key64 | DB_RING_IDX(db, idx), |
| 2931 | db->doorbell); |
| 2932 | } else { |
| 2933 | u32 db_val = db->db_key32 | DB_RING_IDX(db, idx); |
| 2934 | |
| 2935 | writel(db_val, db->doorbell); |
| 2936 | if (bp->flags & BNXT_FLAG_DOUBLE_DB) |
| 2937 | writel(db_val, db->doorbell); |
| 2938 | } |
| 2939 | } |
| 2940 | |
| 2941 | /* Must hold rtnl_lock */ |
| 2942 | static inline bool bnxt_sriov_cfg(struct bnxt *bp) |
| 2943 | { |
| 2944 | #if defined(CONFIG_BNXT_SRIOV) |
| 2945 | return BNXT_PF(bp) && (bp->pf.active_vfs || bp->sriov_cfg); |
| 2946 | #else |
| 2947 | return false; |
| 2948 | #endif |
| 2949 | } |
| 2950 | |
| 2951 | static inline enum pkt_hash_types bnxt_rss_ext_op(struct bnxt *bp, |
| 2952 | const struct rx_cmp *rxcmp) |
| 2953 | { |
| 2954 | u8 ext_op; |
| 2955 | |
| 2956 | ext_op = RX_CMP_V3_HASH_TYPE(bp, rxcmp); |
| 2957 | switch (ext_op) { |
| 2958 | case EXT_OP_INNER_4: |
| 2959 | case EXT_OP_OUTER_4: |
| 2960 | case EXT_OP_INNFL_3: |
| 2961 | case EXT_OP_OUTFL_3: |
| 2962 | return PKT_HASH_TYPE_L4; |
| 2963 | default: |
| 2964 | return PKT_HASH_TYPE_L3; |
| 2965 | } |
| 2966 | } |
| 2967 | |
| 2968 | extern const u16 bnxt_bstore_to_trace[]; |
| 2969 | extern const u16 bnxt_lhint_arr[]; |
| 2970 | |
| 2971 | int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, |
| 2972 | u16 prod, gfp_t gfp); |
| 2973 | void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data); |
| 2974 | u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx); |
| 2975 | bool bnxt_bs_trace_avail(struct bnxt *bp, u16 type); |
| 2976 | void bnxt_set_tpa_flags(struct bnxt *bp); |
| 2977 | void bnxt_set_ring_params(struct bnxt *); |
| 2978 | void bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); |
| 2979 | void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); |
| 2980 | void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); |
| 2981 | int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, |
| 2982 | int bmap_size, bool async_only); |
| 2983 | int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp); |
| 2984 | void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr); |
| 2985 | struct bnxt_l2_filter *bnxt_alloc_new_l2_filter(struct bnxt *bp, |
| 2986 | struct bnxt_l2_key *key, |
| 2987 | u16 flags); |
| 2988 | int bnxt_hwrm_l2_filter_free(struct bnxt *bp, struct bnxt_l2_filter *fltr); |
| 2989 | int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr); |
| 2990 | int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, |
| 2991 | struct bnxt_ntuple_filter *fltr); |
| 2992 | int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, |
| 2993 | struct bnxt_ntuple_filter *fltr); |
| 2994 | int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic, |
| 2995 | u32 tpa_flags); |
| 2996 | void bnxt_fill_ipv6_mask(__be32 mask[4]); |
| 2997 | void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, |
| 2998 | struct ethtool_rxfh_context *rss_ctx); |
| 2999 | int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings); |
| 3000 | int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); |
| 3001 | int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic, |
| 3002 | unsigned int start_rx_ring_idx, |
| 3003 | unsigned int nr_rings); |
| 3004 | int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings); |
| 3005 | int bnxt_nq_rings_in_use(struct bnxt *bp); |
| 3006 | int bnxt_hwrm_set_coal(struct bnxt *); |
| 3007 | size_t bnxt_copy_ctx_mem(struct bnxt *bp, struct bnxt_ctx_mem_type *ctxm, |
| 3008 | void *buf, size_t offset); |
| 3009 | void bnxt_free_ctx_mem(struct bnxt *bp, bool force); |
| 3010 | int bnxt_num_tx_to_cp(struct bnxt *bp, int tx); |
| 3011 | unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp); |
| 3012 | unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp); |
| 3013 | unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); |
| 3014 | unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp); |
| 3015 | int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init); |
| 3016 | void bnxt_tx_disable(struct bnxt *bp); |
| 3017 | void bnxt_tx_enable(struct bnxt *bp); |
| 3018 | u16 bnxt_xmit_get_cfa_action(struct sk_buff *skb); |
| 3019 | void bnxt_sched_reset_txr(struct bnxt *bp, struct bnxt_tx_ring_info *txr, |
| 3020 | u16 curr); |
| 3021 | void bnxt_report_link(struct bnxt *bp); |
| 3022 | int bnxt_update_link(struct bnxt *bp, bool chng_link_state); |
| 3023 | int bnxt_hwrm_set_pause(struct bnxt *); |
| 3024 | int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool); |
| 3025 | void bnxt_clear_reservations(struct bnxt *bp, bool fw_reset); |
| 3026 | int bnxt_cancel_reservations(struct bnxt *bp, bool fw_reset); |
| 3027 | int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp); |
| 3028 | int bnxt_hwrm_free_wol_fltr(struct bnxt *bp); |
| 3029 | int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all); |
| 3030 | int bnxt_hwrm_func_qcaps(struct bnxt *bp); |
| 3031 | int bnxt_hwrm_fw_set_time(struct bnxt *); |
| 3032 | int bnxt_hwrm_vnic_update(struct bnxt *bp, struct bnxt_vnic_info *vnic, |
| 3033 | u8 valid); |
| 3034 | int bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic); |
| 3035 | int __bnxt_setup_vnic_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic); |
| 3036 | void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, |
| 3037 | bool all); |
| 3038 | int bnxt_open_nic(struct bnxt *, bool, bool); |
| 3039 | int bnxt_half_open_nic(struct bnxt *bp); |
| 3040 | void bnxt_half_close_nic(struct bnxt *bp); |
| 3041 | void bnxt_reenable_sriov(struct bnxt *bp); |
| 3042 | void bnxt_close_nic(struct bnxt *, bool, bool); |
| 3043 | void bnxt_get_ring_drv_stats(struct bnxt *bp, |
| 3044 | struct bnxt_total_ring_drv_stats *stats); |
| 3045 | void bnxt_sync_ring_stats(struct bnxt *bp); |
| 3046 | bool bnxt_rfs_capable(struct bnxt *bp, bool new_rss_ctx); |
| 3047 | int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, |
| 3048 | u32 *reg_buf); |
| 3049 | void bnxt_fw_exception(struct bnxt *bp); |
| 3050 | void bnxt_fw_reset(struct bnxt *bp); |
| 3051 | int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, |
| 3052 | int tx_xdp); |
| 3053 | int bnxt_fw_init_one(struct bnxt *bp); |
| 3054 | bool bnxt_hwrm_reset_permitted(struct bnxt *bp); |
| 3055 | void bnxt_set_cp_rings(struct bnxt *bp, bool sh); |
| 3056 | int bnxt_setup_mq_tc(struct net_device *dev, u8 tc); |
| 3057 | struct bnxt_ntuple_filter *bnxt_lookup_ntp_filter_from_idx(struct bnxt *bp, |
| 3058 | struct bnxt_ntuple_filter *fltr, u32 idx); |
| 3059 | u32 bnxt_get_ntp_filter_idx(struct bnxt *bp, struct flow_keys *fkeys, |
| 3060 | const struct sk_buff *skb); |
| 3061 | int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr, |
| 3062 | u32 idx); |
| 3063 | void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr); |
| 3064 | int bnxt_get_max_rings(struct bnxt *, int *, int *, bool); |
| 3065 | int bnxt_restore_pf_fw_resources(struct bnxt *bp); |
| 3066 | int bnxt_get_port_parent_id(struct net_device *dev, |
| 3067 | struct netdev_phys_item_id *ppid); |
| 3068 | void bnxt_dim_work(struct work_struct *work); |
| 3069 | int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi); |
| 3070 | void bnxt_print_device_info(struct bnxt *bp); |
| 3071 | #endif |