Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1 | /* Broadcom NetXtreme-C/E network driver. |
| 2 | * |
Michael Chan | 11f15ed | 2016-04-05 14:08:55 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2016 Broadcom Corporation |
Michael Chan | bac9a7e | 2017-02-12 19:18:10 -0500 | [diff] [blame] | 4 | * Copyright (c) 2016-2017 Broadcom Limited |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 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 | #define DRV_MODULE_NAME "bnxt_en" |
Michael Chan | acb2005 | 2017-07-24 12:34:20 -0400 | [diff] [blame] | 15 | #define DRV_MODULE_VERSION "1.8.0" |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 16 | |
Michael Chan | c193554 | 2015-12-27 18:19:28 -0500 | [diff] [blame] | 17 | #define DRV_VER_MAJ 1 |
Michael Chan | acb2005 | 2017-07-24 12:34:20 -0400 | [diff] [blame] | 18 | #define DRV_VER_MIN 8 |
Michael Chan | c193554 | 2015-12-27 18:19:28 -0500 | [diff] [blame] | 19 | #define DRV_VER_UPD 0 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 20 | |
Florian Westphal | 282ccf6 | 2017-03-29 17:17:31 +0200 | [diff] [blame] | 21 | #include <linux/interrupt.h> |
Sathya Perla | 2ae7408 | 2017-08-28 13:40:33 -0400 | [diff] [blame] | 22 | #include <linux/rhashtable.h> |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 23 | #include <net/devlink.h> |
Sathya Perla | ee5c7fb | 2017-07-24 12:34:28 -0400 | [diff] [blame] | 24 | #include <net/dst_metadata.h> |
Sathya Perla | c124a62 | 2017-07-24 12:34:29 -0400 | [diff] [blame] | 25 | #include <net/switchdev.h> |
Florian Westphal | 282ccf6 | 2017-03-29 17:17:31 +0200 | [diff] [blame] | 26 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 27 | struct tx_bd { |
| 28 | __le32 tx_bd_len_flags_type; |
| 29 | #define TX_BD_TYPE (0x3f << 0) |
| 30 | #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0) |
| 31 | #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0) |
| 32 | #define TX_BD_FLAGS_PACKET_END (1 << 6) |
| 33 | #define TX_BD_FLAGS_NO_CMPL (1 << 7) |
| 34 | #define TX_BD_FLAGS_BD_CNT (0x1f << 8) |
| 35 | #define TX_BD_FLAGS_BD_CNT_SHIFT 8 |
| 36 | #define TX_BD_FLAGS_LHINT (3 << 13) |
| 37 | #define TX_BD_FLAGS_LHINT_SHIFT 13 |
| 38 | #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13) |
| 39 | #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13) |
| 40 | #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13) |
| 41 | #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13) |
| 42 | #define TX_BD_FLAGS_COAL_NOW (1 << 15) |
| 43 | #define TX_BD_LEN (0xffff << 16) |
| 44 | #define TX_BD_LEN_SHIFT 16 |
| 45 | |
| 46 | u32 tx_bd_opaque; |
| 47 | __le64 tx_bd_haddr; |
| 48 | } __packed; |
| 49 | |
| 50 | struct tx_bd_ext { |
| 51 | __le32 tx_bd_hsize_lflags; |
| 52 | #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0) |
| 53 | #define TX_BD_FLAGS_IP_CKSUM (1 << 1) |
| 54 | #define TX_BD_FLAGS_NO_CRC (1 << 2) |
| 55 | #define TX_BD_FLAGS_STAMP (1 << 3) |
| 56 | #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4) |
| 57 | #define TX_BD_FLAGS_LSO (1 << 5) |
| 58 | #define TX_BD_FLAGS_IPID_FMT (1 << 6) |
| 59 | #define TX_BD_FLAGS_T_IPID (1 << 7) |
| 60 | #define TX_BD_HSIZE (0xff << 16) |
| 61 | #define TX_BD_HSIZE_SHIFT 16 |
| 62 | |
| 63 | __le32 tx_bd_mss; |
| 64 | __le32 tx_bd_cfa_action; |
| 65 | #define TX_BD_CFA_ACTION (0xffff << 16) |
| 66 | #define TX_BD_CFA_ACTION_SHIFT 16 |
| 67 | |
| 68 | __le32 tx_bd_cfa_meta; |
| 69 | #define TX_BD_CFA_META_MASK 0xfffffff |
| 70 | #define TX_BD_CFA_META_VID_MASK 0xfff |
| 71 | #define TX_BD_CFA_META_PRI_MASK (0xf << 12) |
| 72 | #define TX_BD_CFA_META_PRI_SHIFT 12 |
| 73 | #define TX_BD_CFA_META_TPID_MASK (3 << 16) |
| 74 | #define TX_BD_CFA_META_TPID_SHIFT 16 |
| 75 | #define TX_BD_CFA_META_KEY (0xf << 28) |
| 76 | #define TX_BD_CFA_META_KEY_SHIFT 28 |
| 77 | #define TX_BD_CFA_META_KEY_VLAN (1 << 28) |
| 78 | }; |
| 79 | |
| 80 | struct rx_bd { |
| 81 | __le32 rx_bd_len_flags_type; |
| 82 | #define RX_BD_TYPE (0x3f << 0) |
| 83 | #define RX_BD_TYPE_RX_PACKET_BD 0x4 |
| 84 | #define RX_BD_TYPE_RX_BUFFER_BD 0x5 |
| 85 | #define RX_BD_TYPE_RX_AGG_BD 0x6 |
| 86 | #define RX_BD_TYPE_16B_BD_SIZE (0 << 4) |
| 87 | #define RX_BD_TYPE_32B_BD_SIZE (1 << 4) |
| 88 | #define RX_BD_TYPE_48B_BD_SIZE (2 << 4) |
| 89 | #define RX_BD_TYPE_64B_BD_SIZE (3 << 4) |
| 90 | #define RX_BD_FLAGS_SOP (1 << 6) |
| 91 | #define RX_BD_FLAGS_EOP (1 << 7) |
| 92 | #define RX_BD_FLAGS_BUFFERS (3 << 8) |
| 93 | #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8) |
| 94 | #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8) |
| 95 | #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8) |
| 96 | #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8) |
| 97 | #define RX_BD_LEN (0xffff << 16) |
| 98 | #define RX_BD_LEN_SHIFT 16 |
| 99 | |
| 100 | u32 rx_bd_opaque; |
| 101 | __le64 rx_bd_haddr; |
| 102 | }; |
| 103 | |
| 104 | struct tx_cmp { |
| 105 | __le32 tx_cmp_flags_type; |
| 106 | #define CMP_TYPE (0x3f << 0) |
| 107 | #define CMP_TYPE_TX_L2_CMP 0 |
| 108 | #define CMP_TYPE_RX_L2_CMP 17 |
| 109 | #define CMP_TYPE_RX_AGG_CMP 18 |
| 110 | #define CMP_TYPE_RX_L2_TPA_START_CMP 19 |
| 111 | #define CMP_TYPE_RX_L2_TPA_END_CMP 21 |
| 112 | #define CMP_TYPE_STATUS_CMP 32 |
| 113 | #define CMP_TYPE_REMOTE_DRIVER_REQ 34 |
| 114 | #define CMP_TYPE_REMOTE_DRIVER_RESP 36 |
| 115 | #define CMP_TYPE_ERROR_STATUS 48 |
Michael Chan | 441cabb | 2016-09-19 03:58:02 -0400 | [diff] [blame] | 116 | #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL |
| 117 | #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL |
| 118 | #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL |
| 119 | #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL |
| 120 | #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 121 | |
| 122 | #define TX_CMP_FLAGS_ERROR (1 << 6) |
| 123 | #define TX_CMP_FLAGS_PUSH (1 << 7) |
| 124 | |
| 125 | u32 tx_cmp_opaque; |
| 126 | __le32 tx_cmp_errors_v; |
| 127 | #define TX_CMP_V (1 << 0) |
| 128 | #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1) |
| 129 | #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0 |
| 130 | #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2 |
| 131 | #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4 |
| 132 | #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5 |
| 133 | #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4) |
| 134 | #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5) |
| 135 | #define TX_CMP_ERRORS_DMA_ERROR (1 << 6) |
| 136 | #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7) |
| 137 | |
| 138 | __le32 tx_cmp_unsed_3; |
| 139 | }; |
| 140 | |
| 141 | struct rx_cmp { |
| 142 | __le32 rx_cmp_len_flags_type; |
| 143 | #define RX_CMP_CMP_TYPE (0x3f << 0) |
| 144 | #define RX_CMP_FLAGS_ERROR (1 << 6) |
| 145 | #define RX_CMP_FLAGS_PLACEMENT (7 << 7) |
| 146 | #define RX_CMP_FLAGS_RSS_VALID (1 << 10) |
| 147 | #define RX_CMP_FLAGS_UNUSED (1 << 11) |
| 148 | #define RX_CMP_FLAGS_ITYPES_SHIFT 12 |
| 149 | #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12) |
| 150 | #define RX_CMP_FLAGS_ITYPE_IP (1 << 12) |
| 151 | #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12) |
| 152 | #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12) |
| 153 | #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12) |
| 154 | #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12) |
| 155 | #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12) |
| 156 | #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12) |
| 157 | #define RX_CMP_LEN (0xffff << 16) |
| 158 | #define RX_CMP_LEN_SHIFT 16 |
| 159 | |
| 160 | u32 rx_cmp_opaque; |
| 161 | __le32 rx_cmp_misc_v1; |
| 162 | #define RX_CMP_V1 (1 << 0) |
| 163 | #define RX_CMP_AGG_BUFS (0x1f << 1) |
| 164 | #define RX_CMP_AGG_BUFS_SHIFT 1 |
| 165 | #define RX_CMP_RSS_HASH_TYPE (0x7f << 9) |
| 166 | #define RX_CMP_RSS_HASH_TYPE_SHIFT 9 |
| 167 | #define RX_CMP_PAYLOAD_OFFSET (0xff << 16) |
| 168 | #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16 |
| 169 | |
| 170 | __le32 rx_cmp_rss_hash; |
| 171 | }; |
| 172 | |
| 173 | #define RX_CMP_HASH_VALID(rxcmp) \ |
| 174 | ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID)) |
| 175 | |
Michael Chan | 614388c | 2015-11-05 16:25:48 -0500 | [diff] [blame] | 176 | #define RSS_PROFILE_ID_MASK 0x1f |
| 177 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 178 | #define RX_CMP_HASH_TYPE(rxcmp) \ |
Michael Chan | 614388c | 2015-11-05 16:25:48 -0500 | [diff] [blame] | 179 | (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\ |
| 180 | RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 181 | |
| 182 | struct rx_cmp_ext { |
| 183 | __le32 rx_cmp_flags2; |
| 184 | #define RX_CMP_FLAGS2_IP_CS_CALC 0x1 |
| 185 | #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1) |
| 186 | #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2) |
| 187 | #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) |
| 188 | #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) |
| 189 | __le32 rx_cmp_meta_data; |
| 190 | #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff |
| 191 | #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000 |
| 192 | #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16 |
| 193 | __le32 rx_cmp_cfa_code_errors_v2; |
| 194 | #define RX_CMP_V (1 << 0) |
| 195 | #define RX_CMPL_ERRORS_MASK (0x7fff << 1) |
| 196 | #define RX_CMPL_ERRORS_SFT 1 |
| 197 | #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1) |
| 198 | #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) |
| 199 | #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1) |
| 200 | #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1) |
| 201 | #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) |
| 202 | #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4) |
| 203 | #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5) |
| 204 | #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6) |
| 205 | #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7) |
| 206 | #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8) |
| 207 | #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9) |
| 208 | #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9) |
| 209 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9) |
| 210 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9) |
| 211 | #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9) |
| 212 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9) |
| 213 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9) |
| 214 | #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9) |
| 215 | #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12) |
| 216 | #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12) |
| 217 | #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12) |
| 218 | #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12) |
| 219 | #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12) |
| 220 | #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12) |
| 221 | #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12) |
| 222 | #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12) |
| 223 | #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12) |
| 224 | #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12) |
| 225 | |
| 226 | #define RX_CMPL_CFA_CODE_MASK (0xffff << 16) |
| 227 | #define RX_CMPL_CFA_CODE_SFT 16 |
| 228 | |
| 229 | __le32 rx_cmp_unused3; |
| 230 | }; |
| 231 | |
| 232 | #define RX_CMP_L2_ERRORS \ |
| 233 | cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR) |
| 234 | |
| 235 | #define RX_CMP_L4_CS_BITS \ |
| 236 | (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC)) |
| 237 | |
| 238 | #define RX_CMP_L4_CS_ERR_BITS \ |
| 239 | (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR)) |
| 240 | |
| 241 | #define RX_CMP_L4_CS_OK(rxcmp1) \ |
| 242 | (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \ |
| 243 | !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS)) |
| 244 | |
| 245 | #define RX_CMP_ENCAP(rxcmp1) \ |
| 246 | ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \ |
| 247 | RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3) |
| 248 | |
Sathya Perla | ee5c7fb | 2017-07-24 12:34:28 -0400 | [diff] [blame] | 249 | #define RX_CMP_CFA_CODE(rxcmpl1) \ |
| 250 | ((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) & \ |
| 251 | RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT) |
| 252 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 253 | struct rx_agg_cmp { |
| 254 | __le32 rx_agg_cmp_len_flags_type; |
| 255 | #define RX_AGG_CMP_TYPE (0x3f << 0) |
| 256 | #define RX_AGG_CMP_LEN (0xffff << 16) |
| 257 | #define RX_AGG_CMP_LEN_SHIFT 16 |
| 258 | u32 rx_agg_cmp_opaque; |
| 259 | __le32 rx_agg_cmp_v; |
| 260 | #define RX_AGG_CMP_V (1 << 0) |
| 261 | __le32 rx_agg_cmp_unused; |
| 262 | }; |
| 263 | |
| 264 | struct rx_tpa_start_cmp { |
| 265 | __le32 rx_tpa_start_cmp_len_flags_type; |
| 266 | #define RX_TPA_START_CMP_TYPE (0x3f << 0) |
| 267 | #define RX_TPA_START_CMP_FLAGS (0x3ff << 6) |
| 268 | #define RX_TPA_START_CMP_FLAGS_SHIFT 6 |
| 269 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7) |
| 270 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7 |
| 271 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7) |
| 272 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7) |
| 273 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7) |
| 274 | #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7) |
| 275 | #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10) |
| 276 | #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12) |
| 277 | #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12 |
| 278 | #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12) |
| 279 | #define RX_TPA_START_CMP_LEN (0xffff << 16) |
| 280 | #define RX_TPA_START_CMP_LEN_SHIFT 16 |
| 281 | |
| 282 | u32 rx_tpa_start_cmp_opaque; |
| 283 | __le32 rx_tpa_start_cmp_misc_v1; |
| 284 | #define RX_TPA_START_CMP_V1 (0x1 << 0) |
| 285 | #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9) |
| 286 | #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9 |
| 287 | #define RX_TPA_START_CMP_AGG_ID (0x7f << 25) |
| 288 | #define RX_TPA_START_CMP_AGG_ID_SHIFT 25 |
| 289 | |
| 290 | __le32 rx_tpa_start_cmp_rss_hash; |
| 291 | }; |
| 292 | |
| 293 | #define TPA_START_HASH_VALID(rx_tpa_start) \ |
| 294 | ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \ |
| 295 | cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID)) |
| 296 | |
| 297 | #define TPA_START_HASH_TYPE(rx_tpa_start) \ |
Michael Chan | 614388c | 2015-11-05 16:25:48 -0500 | [diff] [blame] | 298 | (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 299 | RX_TPA_START_CMP_RSS_HASH_TYPE) >> \ |
| 300 | RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 301 | |
| 302 | #define TPA_START_AGG_ID(rx_tpa_start) \ |
| 303 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ |
| 304 | RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT) |
| 305 | |
| 306 | struct rx_tpa_start_cmp_ext { |
| 307 | __le32 rx_tpa_start_cmp_flags2; |
| 308 | #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0) |
| 309 | #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1) |
| 310 | #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2) |
| 311 | #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) |
Michael Chan | 94758f8 | 2016-06-13 02:25:35 -0400 | [diff] [blame] | 312 | #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 313 | |
| 314 | __le32 rx_tpa_start_cmp_metadata; |
| 315 | __le32 rx_tpa_start_cmp_cfa_code_v2; |
| 316 | #define RX_TPA_START_CMP_V2 (0x1 << 0) |
| 317 | #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16) |
| 318 | #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16 |
Michael Chan | 94758f8 | 2016-06-13 02:25:35 -0400 | [diff] [blame] | 319 | __le32 rx_tpa_start_cmp_hdr_info; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 320 | }; |
| 321 | |
Sathya Perla | ee5c7fb | 2017-07-24 12:34:28 -0400 | [diff] [blame] | 322 | #define TPA_START_CFA_CODE(rx_tpa_start) \ |
| 323 | ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ |
| 324 | RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT) |
| 325 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 326 | struct rx_tpa_end_cmp { |
| 327 | __le32 rx_tpa_end_cmp_len_flags_type; |
| 328 | #define RX_TPA_END_CMP_TYPE (0x3f << 0) |
| 329 | #define RX_TPA_END_CMP_FLAGS (0x3ff << 6) |
| 330 | #define RX_TPA_END_CMP_FLAGS_SHIFT 6 |
| 331 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7) |
| 332 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7 |
| 333 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7) |
| 334 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7) |
| 335 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7) |
| 336 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7) |
| 337 | #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10) |
| 338 | #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12) |
| 339 | #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12 |
| 340 | #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12) |
| 341 | #define RX_TPA_END_CMP_LEN (0xffff << 16) |
| 342 | #define RX_TPA_END_CMP_LEN_SHIFT 16 |
| 343 | |
| 344 | u32 rx_tpa_end_cmp_opaque; |
| 345 | __le32 rx_tpa_end_cmp_misc_v1; |
| 346 | #define RX_TPA_END_CMP_V1 (0x1 << 0) |
| 347 | #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1) |
| 348 | #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1 |
| 349 | #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8) |
| 350 | #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8 |
| 351 | #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16) |
| 352 | #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16 |
| 353 | #define RX_TPA_END_CMP_AGG_ID (0x7f << 25) |
| 354 | #define RX_TPA_END_CMP_AGG_ID_SHIFT 25 |
| 355 | |
| 356 | __le32 rx_tpa_end_cmp_tsdelta; |
| 357 | #define RX_TPA_END_GRO_TS (0x1 << 31) |
| 358 | }; |
| 359 | |
| 360 | #define TPA_END_AGG_ID(rx_tpa_end) \ |
| 361 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 362 | RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT) |
| 363 | |
| 364 | #define TPA_END_TPA_SEGS(rx_tpa_end) \ |
| 365 | ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ |
| 366 | RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT) |
| 367 | |
| 368 | #define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \ |
| 369 | cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \ |
| 370 | RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS) |
| 371 | |
| 372 | #define TPA_END_GRO(rx_tpa_end) \ |
| 373 | ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \ |
| 374 | RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO) |
| 375 | |
| 376 | #define TPA_END_GRO_TS(rx_tpa_end) \ |
Michael Chan | a58a3e6 | 2016-07-01 18:46:20 -0400 | [diff] [blame] | 377 | (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \ |
| 378 | cpu_to_le32(RX_TPA_END_GRO_TS))) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 379 | |
| 380 | struct rx_tpa_end_cmp_ext { |
| 381 | __le32 rx_tpa_end_cmp_dup_acks; |
| 382 | #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0) |
| 383 | |
| 384 | __le32 rx_tpa_end_cmp_seg_len; |
| 385 | #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0) |
| 386 | |
| 387 | __le32 rx_tpa_end_cmp_errors_v2; |
| 388 | #define RX_TPA_END_CMP_V2 (0x1 << 0) |
Michael Chan | 69c149e | 2017-06-23 14:01:00 -0400 | [diff] [blame] | 389 | #define RX_TPA_END_CMP_ERRORS (0x3 << 1) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 390 | #define RX_TPA_END_CMPL_ERRORS_SHIFT 1 |
| 391 | |
| 392 | u32 rx_tpa_end_cmp_start_opaque; |
| 393 | }; |
| 394 | |
Michael Chan | 69c149e | 2017-06-23 14:01:00 -0400 | [diff] [blame] | 395 | #define TPA_END_ERRORS(rx_tpa_end_ext) \ |
| 396 | ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \ |
| 397 | cpu_to_le32(RX_TPA_END_CMP_ERRORS)) |
| 398 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 399 | #define DB_IDX_MASK 0xffffff |
| 400 | #define DB_IDX_VALID (0x1 << 26) |
| 401 | #define DB_IRQ_DIS (0x1 << 27) |
| 402 | #define DB_KEY_TX (0x0 << 28) |
| 403 | #define DB_KEY_RX (0x1 << 28) |
| 404 | #define DB_KEY_CP (0x2 << 28) |
| 405 | #define DB_KEY_ST (0x3 << 28) |
| 406 | #define DB_KEY_TX_PUSH (0x4 << 28) |
| 407 | #define DB_LONG_TX_PUSH (0x2 << 24) |
| 408 | |
Michael Chan | e4060d3 | 2016-12-07 00:26:19 -0500 | [diff] [blame] | 409 | #define BNXT_MIN_ROCE_CP_RINGS 2 |
| 410 | #define BNXT_MIN_ROCE_STAT_CTXS 1 |
| 411 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 412 | #define INVALID_HW_RING_ID ((u16)-1) |
| 413 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 414 | /* The hardware supports certain page sizes. Use the supported page sizes |
| 415 | * to allocate the rings. |
| 416 | */ |
| 417 | #if (PAGE_SHIFT < 12) |
| 418 | #define BNXT_PAGE_SHIFT 12 |
| 419 | #elif (PAGE_SHIFT <= 13) |
| 420 | #define BNXT_PAGE_SHIFT PAGE_SHIFT |
| 421 | #elif (PAGE_SHIFT < 16) |
| 422 | #define BNXT_PAGE_SHIFT 13 |
| 423 | #else |
| 424 | #define BNXT_PAGE_SHIFT 16 |
| 425 | #endif |
| 426 | |
| 427 | #define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT) |
| 428 | |
Michael Chan | 2839f28 | 2016-04-25 02:30:50 -0400 | [diff] [blame] | 429 | /* The RXBD length is 16-bit so we can only support page sizes < 64K */ |
| 430 | #if (PAGE_SHIFT > 15) |
| 431 | #define BNXT_RX_PAGE_SHIFT 15 |
| 432 | #else |
| 433 | #define BNXT_RX_PAGE_SHIFT PAGE_SHIFT |
| 434 | #endif |
| 435 | |
| 436 | #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) |
| 437 | |
Michael Chan | c61fb99 | 2017-02-06 16:55:36 -0500 | [diff] [blame] | 438 | #define BNXT_MAX_MTU 9500 |
| 439 | #define BNXT_MAX_PAGE_MODE_MTU \ |
Michael Chan | c6d30e8 | 2017-02-06 16:55:42 -0500 | [diff] [blame] | 440 | ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ |
| 441 | XDP_PACKET_HEADROOM) |
Michael Chan | c61fb99 | 2017-02-06 16:55:36 -0500 | [diff] [blame] | 442 | |
Michael Chan | 4ffcd58 | 2016-09-19 03:58:07 -0400 | [diff] [blame] | 443 | #define BNXT_MIN_PKT_SIZE 52 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 444 | |
Michael Chan | 51dd55b | 2016-02-10 17:33:50 -0500 | [diff] [blame] | 445 | #define BNXT_DEFAULT_RX_RING_SIZE 511 |
| 446 | #define BNXT_DEFAULT_TX_RING_SIZE 511 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 447 | |
| 448 | #define MAX_TPA 64 |
| 449 | |
Michael Chan | d0a42d6 | 2016-05-15 03:04:46 -0400 | [diff] [blame] | 450 | #if (BNXT_PAGE_SHIFT == 16) |
| 451 | #define MAX_RX_PAGES 1 |
| 452 | #define MAX_RX_AGG_PAGES 4 |
| 453 | #define MAX_TX_PAGES 1 |
| 454 | #define MAX_CP_PAGES 8 |
| 455 | #else |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 456 | #define MAX_RX_PAGES 8 |
| 457 | #define MAX_RX_AGG_PAGES 32 |
| 458 | #define MAX_TX_PAGES 8 |
| 459 | #define MAX_CP_PAGES 64 |
Michael Chan | d0a42d6 | 2016-05-15 03:04:46 -0400 | [diff] [blame] | 460 | #endif |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 461 | |
| 462 | #define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd)) |
| 463 | #define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd)) |
| 464 | #define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp)) |
| 465 | |
| 466 | #define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT) |
| 467 | #define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT) |
| 468 | |
| 469 | #define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT) |
| 470 | |
| 471 | #define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT) |
| 472 | #define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT) |
| 473 | |
| 474 | #define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT) |
| 475 | |
| 476 | #define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1) |
| 477 | #define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1) |
| 478 | #define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1) |
| 479 | |
| 480 | #define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) |
| 481 | #define RX_IDX(x) ((x) & (RX_DESC_CNT - 1)) |
| 482 | |
| 483 | #define TX_RING(x) (((x) & ~(TX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) |
| 484 | #define TX_IDX(x) ((x) & (TX_DESC_CNT - 1)) |
| 485 | |
| 486 | #define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) |
| 487 | #define CP_IDX(x) ((x) & (CP_DESC_CNT - 1)) |
| 488 | |
| 489 | #define TX_CMP_VALID(txcmp, raw_cons) \ |
| 490 | (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \ |
| 491 | !((raw_cons) & bp->cp_bit)) |
| 492 | |
| 493 | #define RX_CMP_VALID(rxcmp1, raw_cons) \ |
| 494 | (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\ |
| 495 | !((raw_cons) & bp->cp_bit)) |
| 496 | |
| 497 | #define RX_AGG_CMP_VALID(agg, raw_cons) \ |
| 498 | (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \ |
| 499 | !((raw_cons) & bp->cp_bit)) |
| 500 | |
| 501 | #define TX_CMP_TYPE(txcmp) \ |
| 502 | (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE) |
| 503 | |
| 504 | #define RX_CMP_TYPE(rxcmp) \ |
| 505 | (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE) |
| 506 | |
| 507 | #define NEXT_RX(idx) (((idx) + 1) & bp->rx_ring_mask) |
| 508 | |
| 509 | #define NEXT_RX_AGG(idx) (((idx) + 1) & bp->rx_agg_ring_mask) |
| 510 | |
| 511 | #define NEXT_TX(idx) (((idx) + 1) & bp->tx_ring_mask) |
| 512 | |
| 513 | #define ADV_RAW_CMP(idx, n) ((idx) + (n)) |
| 514 | #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1) |
| 515 | #define RING_CMP(idx) ((idx) & bp->cp_ring_mask) |
| 516 | #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1)) |
| 517 | |
Michael Chan | e6ef269 | 2016-03-28 19:46:05 -0400 | [diff] [blame] | 518 | #define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len) |
Deepak Khungar | e605db8 | 2017-05-29 19:06:04 -0400 | [diff] [blame] | 519 | #define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input) |
Michael Chan | ff4fe81 | 2016-02-26 04:00:04 -0500 | [diff] [blame] | 520 | #define DFLT_HWRM_CMD_TIMEOUT 500 |
| 521 | #define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 522 | #define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4) |
| 523 | #define HWRM_RESP_ERR_CODE_MASK 0xffff |
Michael Chan | a8643e1 | 2016-02-26 04:00:05 -0500 | [diff] [blame] | 524 | #define HWRM_RESP_LEN_OFFSET 4 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 525 | #define HWRM_RESP_LEN_MASK 0xffff0000 |
| 526 | #define HWRM_RESP_LEN_SFT 16 |
| 527 | #define HWRM_RESP_VALID_MASK 0xff000000 |
Michael Chan | a8643e1 | 2016-02-26 04:00:05 -0500 | [diff] [blame] | 528 | #define HWRM_SEQ_ID_INVALID -1 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 529 | #define BNXT_HWRM_REQ_MAX_SIZE 128 |
| 530 | #define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \ |
| 531 | BNXT_HWRM_REQ_MAX_SIZE) |
| 532 | |
Michael Chan | 4e5dbbda | 2017-02-06 16:55:37 -0500 | [diff] [blame] | 533 | #define BNXT_RX_EVENT 1 |
| 534 | #define BNXT_AGG_EVENT 2 |
Michael Chan | 3841340 | 2017-02-06 16:55:43 -0500 | [diff] [blame] | 535 | #define BNXT_TX_EVENT 4 |
Michael Chan | 4e5dbbda | 2017-02-06 16:55:37 -0500 | [diff] [blame] | 536 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 537 | struct bnxt_sw_tx_bd { |
| 538 | struct sk_buff *skb; |
| 539 | DEFINE_DMA_UNMAP_ADDR(mapping); |
| 540 | u8 is_gso; |
| 541 | u8 is_push; |
Michael Chan | 3841340 | 2017-02-06 16:55:43 -0500 | [diff] [blame] | 542 | union { |
| 543 | unsigned short nr_frags; |
| 544 | u16 rx_prod; |
| 545 | }; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 546 | }; |
| 547 | |
| 548 | struct bnxt_sw_rx_bd { |
Michael Chan | 6bb1947 | 2017-02-06 16:55:32 -0500 | [diff] [blame] | 549 | void *data; |
| 550 | u8 *data_ptr; |
Michael Chan | 11cd119 | 2017-02-06 16:55:33 -0500 | [diff] [blame] | 551 | dma_addr_t mapping; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 552 | }; |
| 553 | |
| 554 | struct bnxt_sw_rx_agg_bd { |
| 555 | struct page *page; |
Michael Chan | 89d0a06 | 2016-04-25 02:30:51 -0400 | [diff] [blame] | 556 | unsigned int offset; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 557 | dma_addr_t mapping; |
| 558 | }; |
| 559 | |
| 560 | struct bnxt_ring_struct { |
| 561 | int nr_pages; |
| 562 | int page_size; |
| 563 | void **pg_arr; |
| 564 | dma_addr_t *dma_arr; |
| 565 | |
| 566 | __le64 *pg_tbl; |
| 567 | dma_addr_t pg_tbl_map; |
| 568 | |
| 569 | int vmem_size; |
| 570 | void **vmem; |
| 571 | |
| 572 | u16 fw_ring_id; /* Ring id filled by Chimp FW */ |
| 573 | u8 queue_id; |
| 574 | }; |
| 575 | |
| 576 | struct tx_push_bd { |
| 577 | __le32 doorbell; |
Michael Chan | 4419dbe | 2016-02-10 17:33:49 -0500 | [diff] [blame] | 578 | __le32 tx_bd_len_flags_type; |
| 579 | u32 tx_bd_opaque; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 580 | struct tx_bd_ext txbd2; |
| 581 | }; |
| 582 | |
Michael Chan | 4419dbe | 2016-02-10 17:33:49 -0500 | [diff] [blame] | 583 | struct tx_push_buffer { |
| 584 | struct tx_push_bd push_bd; |
| 585 | u32 data[25]; |
| 586 | }; |
| 587 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 588 | struct bnxt_tx_ring_info { |
Michael Chan | b6ab4b0 | 2016-01-02 23:44:59 -0500 | [diff] [blame] | 589 | struct bnxt_napi *bnapi; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 590 | u16 tx_prod; |
| 591 | u16 tx_cons; |
Michael Chan | a960dec | 2017-02-06 16:55:39 -0500 | [diff] [blame] | 592 | u16 txq_index; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 593 | void __iomem *tx_doorbell; |
| 594 | |
| 595 | struct tx_bd *tx_desc_ring[MAX_TX_PAGES]; |
| 596 | struct bnxt_sw_tx_bd *tx_buf_ring; |
| 597 | |
| 598 | dma_addr_t tx_desc_mapping[MAX_TX_PAGES]; |
| 599 | |
Michael Chan | 4419dbe | 2016-02-10 17:33:49 -0500 | [diff] [blame] | 600 | struct tx_push_buffer *tx_push; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 601 | dma_addr_t tx_push_mapping; |
Michael Chan | 4419dbe | 2016-02-10 17:33:49 -0500 | [diff] [blame] | 602 | __le64 data_mapping; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 603 | |
| 604 | #define BNXT_DEV_STATE_CLOSING 0x1 |
| 605 | u32 dev_state; |
| 606 | |
| 607 | struct bnxt_ring_struct tx_ring_struct; |
| 608 | }; |
| 609 | |
| 610 | struct bnxt_tpa_info { |
Michael Chan | 6bb1947 | 2017-02-06 16:55:32 -0500 | [diff] [blame] | 611 | void *data; |
| 612 | u8 *data_ptr; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 613 | dma_addr_t mapping; |
| 614 | u16 len; |
| 615 | unsigned short gso_type; |
| 616 | u32 flags2; |
| 617 | u32 metadata; |
| 618 | enum pkt_hash_types hash_type; |
| 619 | u32 rss_hash; |
Michael Chan | 94758f8 | 2016-06-13 02:25:35 -0400 | [diff] [blame] | 620 | u32 hdr_info; |
| 621 | |
| 622 | #define BNXT_TPA_L4_SIZE(hdr_info) \ |
| 623 | (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32) |
| 624 | |
| 625 | #define BNXT_TPA_INNER_L3_OFF(hdr_info) \ |
| 626 | (((hdr_info) >> 18) & 0x1ff) |
| 627 | |
| 628 | #define BNXT_TPA_INNER_L2_OFF(hdr_info) \ |
| 629 | (((hdr_info) >> 9) & 0x1ff) |
| 630 | |
| 631 | #define BNXT_TPA_OUTER_L3_OFF(hdr_info) \ |
| 632 | ((hdr_info) & 0x1ff) |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 633 | |
| 634 | u16 cfa_code; /* cfa_code in TPA start compl */ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 635 | }; |
| 636 | |
| 637 | struct bnxt_rx_ring_info { |
Michael Chan | b6ab4b0 | 2016-01-02 23:44:59 -0500 | [diff] [blame] | 638 | struct bnxt_napi *bnapi; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 639 | u16 rx_prod; |
| 640 | u16 rx_agg_prod; |
| 641 | u16 rx_sw_agg_prod; |
Michael Chan | 376a5b8 | 2016-05-10 19:17:59 -0400 | [diff] [blame] | 642 | u16 rx_next_cons; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 643 | void __iomem *rx_doorbell; |
| 644 | void __iomem *rx_agg_doorbell; |
| 645 | |
Michael Chan | c6d30e8 | 2017-02-06 16:55:42 -0500 | [diff] [blame] | 646 | struct bpf_prog *xdp_prog; |
| 647 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 648 | struct rx_bd *rx_desc_ring[MAX_RX_PAGES]; |
| 649 | struct bnxt_sw_rx_bd *rx_buf_ring; |
| 650 | |
| 651 | struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES]; |
| 652 | struct bnxt_sw_rx_agg_bd *rx_agg_ring; |
| 653 | |
| 654 | unsigned long *rx_agg_bmap; |
| 655 | u16 rx_agg_bmap_size; |
| 656 | |
Michael Chan | 89d0a06 | 2016-04-25 02:30:51 -0400 | [diff] [blame] | 657 | struct page *rx_page; |
| 658 | unsigned int rx_page_offset; |
| 659 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 660 | dma_addr_t rx_desc_mapping[MAX_RX_PAGES]; |
| 661 | dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES]; |
| 662 | |
| 663 | struct bnxt_tpa_info *rx_tpa; |
| 664 | |
| 665 | struct bnxt_ring_struct rx_ring_struct; |
| 666 | struct bnxt_ring_struct rx_agg_ring_struct; |
| 667 | }; |
| 668 | |
| 669 | struct bnxt_cp_ring_info { |
| 670 | u32 cp_raw_cons; |
| 671 | void __iomem *cp_doorbell; |
| 672 | |
| 673 | struct tx_cmp *cp_desc_ring[MAX_CP_PAGES]; |
| 674 | |
| 675 | dma_addr_t cp_desc_mapping[MAX_CP_PAGES]; |
| 676 | |
| 677 | struct ctx_hw_stats *hw_stats; |
| 678 | dma_addr_t hw_stats_map; |
| 679 | u32 hw_stats_ctx_id; |
| 680 | u64 rx_l4_csum_errors; |
| 681 | |
| 682 | struct bnxt_ring_struct cp_ring_struct; |
| 683 | }; |
| 684 | |
| 685 | struct bnxt_napi { |
| 686 | struct napi_struct napi; |
| 687 | struct bnxt *bp; |
| 688 | |
| 689 | int index; |
| 690 | struct bnxt_cp_ring_info cp_ring; |
Michael Chan | b6ab4b0 | 2016-01-02 23:44:59 -0500 | [diff] [blame] | 691 | struct bnxt_rx_ring_info *rx_ring; |
| 692 | struct bnxt_tx_ring_info *tx_ring; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 693 | |
Michael Chan | fa3e93e | 2017-02-06 16:55:41 -0500 | [diff] [blame] | 694 | void (*tx_int)(struct bnxt *, struct bnxt_napi *, |
| 695 | int); |
| 696 | u32 flags; |
| 697 | #define BNXT_NAPI_FLAG_XDP 0x1 |
| 698 | |
Michael Chan | fa7e281 | 2016-05-10 19:18:00 -0400 | [diff] [blame] | 699 | bool in_reset; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 700 | }; |
| 701 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 702 | struct bnxt_irq { |
| 703 | irq_handler_t handler; |
| 704 | unsigned int vector; |
Vasundhara Volam | 56f0fd8 | 2017-08-28 13:40:27 -0400 | [diff] [blame] | 705 | u8 requested:1; |
| 706 | u8 have_cpumask:1; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 707 | char name[IFNAMSIZ + 2]; |
Vasundhara Volam | 56f0fd8 | 2017-08-28 13:40:27 -0400 | [diff] [blame] | 708 | cpumask_var_t cpu_mask; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 709 | }; |
| 710 | |
| 711 | #define HWRM_RING_ALLOC_TX 0x1 |
| 712 | #define HWRM_RING_ALLOC_RX 0x2 |
| 713 | #define HWRM_RING_ALLOC_AGG 0x4 |
| 714 | #define HWRM_RING_ALLOC_CMPL 0x8 |
| 715 | |
| 716 | #define INVALID_STATS_CTX_ID -1 |
| 717 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 718 | struct bnxt_ring_grp_info { |
| 719 | u16 fw_stats_ctx; |
| 720 | u16 fw_grp_id; |
| 721 | u16 rx_fw_ring_id; |
| 722 | u16 agg_fw_ring_id; |
| 723 | u16 cp_fw_ring_id; |
| 724 | }; |
| 725 | |
| 726 | struct bnxt_vnic_info { |
| 727 | u16 fw_vnic_id; /* returned by Chimp during alloc */ |
Prashant Sreedharan | 94ce9ca | 2016-07-18 07:15:21 -0400 | [diff] [blame] | 728 | #define BNXT_MAX_CTX_PER_VNIC 2 |
| 729 | u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC]; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 730 | u16 fw_l2_ctx_id; |
| 731 | #define BNXT_MAX_UC_ADDRS 4 |
| 732 | __le64 fw_l2_filter_id[BNXT_MAX_UC_ADDRS]; |
| 733 | /* index 0 always dev_addr */ |
| 734 | u16 uc_filter_count; |
| 735 | u8 *uc_list; |
| 736 | |
| 737 | u16 *fw_grp_ids; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 738 | dma_addr_t rss_table_dma_addr; |
| 739 | __le16 *rss_table; |
| 740 | dma_addr_t rss_hash_key_dma_addr; |
| 741 | u64 *rss_hash_key; |
| 742 | u32 rx_mask; |
| 743 | |
| 744 | u8 *mc_list; |
| 745 | int mc_list_size; |
| 746 | int mc_list_count; |
| 747 | dma_addr_t mc_list_mapping; |
| 748 | #define BNXT_MAX_MC_ADDRS 16 |
| 749 | |
| 750 | u32 flags; |
| 751 | #define BNXT_VNIC_RSS_FLAG 1 |
| 752 | #define BNXT_VNIC_RFS_FLAG 2 |
| 753 | #define BNXT_VNIC_MCAST_FLAG 4 |
| 754 | #define BNXT_VNIC_UCAST_FLAG 8 |
Michael Chan | ae10ae7 | 2016-12-29 12:13:38 -0500 | [diff] [blame] | 755 | #define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 756 | }; |
| 757 | |
| 758 | #if defined(CONFIG_BNXT_SRIOV) |
| 759 | struct bnxt_vf_info { |
| 760 | u16 fw_fid; |
| 761 | u8 mac_addr[ETH_ALEN]; |
| 762 | u16 max_rsscos_ctxs; |
| 763 | u16 max_cp_rings; |
| 764 | u16 max_tx_rings; |
| 765 | u16 max_rx_rings; |
Michael Chan | b72d4a6 | 2015-12-27 18:19:27 -0500 | [diff] [blame] | 766 | u16 max_hw_ring_grps; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 767 | u16 max_l2_ctxs; |
| 768 | u16 max_irqs; |
| 769 | u16 max_vnics; |
| 770 | u16 max_stat_ctxs; |
| 771 | u16 vlan; |
| 772 | u32 flags; |
| 773 | #define BNXT_VF_QOS 0x1 |
| 774 | #define BNXT_VF_SPOOFCHK 0x2 |
| 775 | #define BNXT_VF_LINK_FORCED 0x4 |
| 776 | #define BNXT_VF_LINK_UP 0x8 |
| 777 | u32 func_flags; /* func cfg flags */ |
| 778 | u32 min_tx_rate; |
| 779 | u32 max_tx_rate; |
| 780 | void *hwrm_cmd_req_addr; |
| 781 | dma_addr_t hwrm_cmd_req_dma_addr; |
| 782 | }; |
Michael Chan | 379a80a | 2015-10-23 15:06:19 -0400 | [diff] [blame] | 783 | #endif |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 784 | |
| 785 | struct bnxt_pf_info { |
| 786 | #define BNXT_FIRST_PF_FID 1 |
| 787 | #define BNXT_FIRST_VF_FID 128 |
Michael Chan | a58a3e6 | 2016-07-01 18:46:20 -0400 | [diff] [blame] | 788 | u16 fw_fid; |
| 789 | u16 port_id; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 790 | u8 mac_addr[ETH_ALEN]; |
| 791 | u16 max_rsscos_ctxs; |
| 792 | u16 max_cp_rings; |
| 793 | u16 max_tx_rings; /* HW assigned max tx rings for this PF */ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 794 | u16 max_rx_rings; /* HW assigned max rx rings for this PF */ |
Michael Chan | b72d4a6 | 2015-12-27 18:19:27 -0500 | [diff] [blame] | 795 | u16 max_hw_ring_grps; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 796 | u16 max_irqs; |
| 797 | u16 max_l2_ctxs; |
| 798 | u16 max_vnics; |
| 799 | u16 max_stat_ctxs; |
| 800 | u32 first_vf_id; |
| 801 | u16 active_vfs; |
| 802 | u16 max_vfs; |
| 803 | u32 max_encap_records; |
| 804 | u32 max_decap_records; |
| 805 | u32 max_tx_em_flows; |
| 806 | u32 max_tx_wm_flows; |
| 807 | u32 max_rx_em_flows; |
| 808 | u32 max_rx_wm_flows; |
| 809 | unsigned long *vf_event_bmap; |
| 810 | u16 hwrm_cmd_req_pages; |
| 811 | void *hwrm_cmd_req_addr[4]; |
| 812 | dma_addr_t hwrm_cmd_req_dma_addr[4]; |
| 813 | struct bnxt_vf_info *vf; |
| 814 | }; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 815 | |
| 816 | struct bnxt_ntuple_filter { |
| 817 | struct hlist_node hash; |
Michael Chan | a54c4d7 | 2016-07-25 12:33:35 -0400 | [diff] [blame] | 818 | u8 dst_mac_addr[ETH_ALEN]; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 819 | u8 src_mac_addr[ETH_ALEN]; |
| 820 | struct flow_keys fkeys; |
| 821 | __le64 filter_id; |
| 822 | u16 sw_id; |
Michael Chan | a54c4d7 | 2016-07-25 12:33:35 -0400 | [diff] [blame] | 823 | u8 l2_fltr_idx; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 824 | u16 rxq; |
| 825 | u32 flow_id; |
| 826 | unsigned long state; |
| 827 | #define BNXT_FLTR_VALID 0 |
| 828 | #define BNXT_FLTR_UPDATE 1 |
| 829 | }; |
| 830 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 831 | struct bnxt_link_info { |
Michael Chan | 03efbec | 2016-04-11 04:11:11 -0400 | [diff] [blame] | 832 | u8 phy_type; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 833 | u8 media_type; |
| 834 | u8 transceiver; |
| 835 | u8 phy_addr; |
| 836 | u8 phy_link_status; |
| 837 | #define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK |
| 838 | #define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL |
| 839 | #define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK |
| 840 | u8 wire_speed; |
| 841 | u8 loop_back; |
| 842 | u8 link_up; |
| 843 | u8 duplex; |
Michael Chan | acb2005 | 2017-07-24 12:34:20 -0400 | [diff] [blame] | 844 | #define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF |
| 845 | #define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 846 | u8 pause; |
| 847 | #define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX |
| 848 | #define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX |
| 849 | #define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \ |
| 850 | PORT_PHY_QCFG_RESP_PAUSE_TX) |
Michael Chan | 3277360 | 2016-03-07 15:38:42 -0500 | [diff] [blame] | 851 | u8 lp_pause; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 852 | u8 auto_pause_setting; |
| 853 | u8 force_pause_setting; |
| 854 | u8 duplex_setting; |
| 855 | u8 auto_mode; |
| 856 | #define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \ |
| 857 | (mode) <= BNXT_LINK_AUTO_MSK) |
| 858 | #define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE |
| 859 | #define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS |
| 860 | #define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED |
| 861 | #define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW |
Michael Chan | 11f15ed | 2016-04-05 14:08:55 -0400 | [diff] [blame] | 862 | #define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 863 | #define PHY_VER_LEN 3 |
| 864 | u8 phy_ver[PHY_VER_LEN]; |
| 865 | u16 link_speed; |
| 866 | #define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB |
| 867 | #define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB |
| 868 | #define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB |
| 869 | #define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB |
| 870 | #define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB |
| 871 | #define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB |
| 872 | #define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB |
| 873 | #define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB |
| 874 | #define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB |
Deepak Khungar | 38a21b3 | 2017-04-21 20:11:24 -0400 | [diff] [blame] | 875 | #define BNXT_LINK_SPEED_100GB PORT_PHY_QCFG_RESP_LINK_SPEED_100GB |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 876 | u16 support_speeds; |
Michael Chan | 68515a1 | 2016-12-29 12:13:34 -0500 | [diff] [blame] | 877 | u16 auto_link_speeds; /* fw adv setting */ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 878 | #define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB |
| 879 | #define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB |
| 880 | #define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB |
| 881 | #define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB |
| 882 | #define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB |
| 883 | #define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB |
| 884 | #define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB |
| 885 | #define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB |
| 886 | #define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB |
Deepak Khungar | 38a21b3 | 2017-04-21 20:11:24 -0400 | [diff] [blame] | 887 | #define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB |
Michael Chan | 93ed811 | 2016-06-13 02:25:37 -0400 | [diff] [blame] | 888 | u16 support_auto_speeds; |
Michael Chan | 3277360 | 2016-03-07 15:38:42 -0500 | [diff] [blame] | 889 | u16 lp_auto_link_speeds; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 890 | u16 force_link_speed; |
| 891 | u32 preemphasis; |
Ajit Khaparde | 42ee18f | 2016-05-15 03:04:44 -0400 | [diff] [blame] | 892 | u8 module_status; |
Michael Chan | e70c752 | 2017-02-12 19:18:16 -0500 | [diff] [blame] | 893 | u16 fec_cfg; |
| 894 | #define BNXT_FEC_AUTONEG PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED |
| 895 | #define BNXT_FEC_ENC_BASE_R PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED |
| 896 | #define BNXT_FEC_ENC_RS PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 897 | |
| 898 | /* copy of requested setting from ethtool cmd */ |
| 899 | u8 autoneg; |
| 900 | #define BNXT_AUTONEG_SPEED 1 |
| 901 | #define BNXT_AUTONEG_FLOW_CTRL 2 |
| 902 | u8 req_duplex; |
| 903 | u8 req_flow_ctrl; |
| 904 | u16 req_link_speed; |
Michael Chan | 68515a1 | 2016-12-29 12:13:34 -0500 | [diff] [blame] | 905 | u16 advertising; /* user adv setting */ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 906 | bool force_link_chng; |
Michael Chan | 4bb13ab | 2016-04-05 14:09:01 -0400 | [diff] [blame] | 907 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 908 | /* a copy of phy_qcfg output used to report link |
| 909 | * info to VF |
| 910 | */ |
| 911 | struct hwrm_port_phy_qcfg_output phy_qcfg_resp; |
| 912 | }; |
| 913 | |
| 914 | #define BNXT_MAX_QUEUE 8 |
| 915 | |
| 916 | struct bnxt_queue_info { |
| 917 | u8 queue_id; |
| 918 | u8 queue_profile; |
| 919 | }; |
| 920 | |
Michael Chan | 5ad2cbe | 2017-01-13 01:32:03 -0500 | [diff] [blame] | 921 | #define BNXT_MAX_LED 4 |
| 922 | |
| 923 | struct bnxt_led_info { |
| 924 | u8 led_id; |
| 925 | u8 led_type; |
| 926 | u8 led_group_id; |
| 927 | u8 unused; |
| 928 | __le16 led_state_caps; |
| 929 | #define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \ |
| 930 | cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED)) |
| 931 | |
| 932 | __le16 led_color_caps; |
| 933 | }; |
| 934 | |
Michael Chan | eb51365 | 2017-04-04 18:14:12 -0400 | [diff] [blame] | 935 | #define BNXT_MAX_TEST 8 |
| 936 | |
| 937 | struct bnxt_test_info { |
| 938 | u8 offline_mask; |
| 939 | u16 timeout; |
| 940 | char string[BNXT_MAX_TEST][ETH_GSTRING_LEN]; |
| 941 | }; |
| 942 | |
Jeffrey Huang | 1180949 | 2015-11-05 16:25:49 -0500 | [diff] [blame] | 943 | #define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400 |
| 944 | #define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014 |
| 945 | #define BNXT_CAG_REG_BASE 0x300000 |
| 946 | |
Michael Chan | 18775aa | 2017-10-26 11:51:27 -0400 | [diff] [blame] | 947 | struct bnxt_coal { |
| 948 | u16 coal_ticks; |
| 949 | u16 coal_ticks_irq; |
| 950 | u16 coal_bufs; |
| 951 | u16 coal_bufs_irq; |
| 952 | /* RING_IDLE enabled when coal ticks < idle_thresh */ |
| 953 | u16 idle_thresh; |
| 954 | u8 bufs_per_record; |
| 955 | u8 budget; |
| 956 | }; |
| 957 | |
Sathya Perla | 5a84acb | 2017-10-26 11:51:31 -0400 | [diff] [blame^] | 958 | struct bnxt_tc_flow_stats { |
| 959 | u64 packets; |
| 960 | u64 bytes; |
| 961 | }; |
| 962 | |
Sathya Perla | 2ae7408 | 2017-08-28 13:40:33 -0400 | [diff] [blame] | 963 | struct bnxt_tc_info { |
| 964 | bool enabled; |
| 965 | |
| 966 | /* hash table to store TC offloaded flows */ |
| 967 | struct rhashtable flow_table; |
| 968 | struct rhashtable_params flow_ht_params; |
| 969 | |
| 970 | /* hash table to store L2 keys of TC flows */ |
| 971 | struct rhashtable l2_table; |
| 972 | struct rhashtable_params l2_ht_params; |
Sathya Perla | 8c95f77 | 2017-10-26 11:51:29 -0400 | [diff] [blame] | 973 | /* hash table to store L2 keys for TC tunnel decap */ |
| 974 | struct rhashtable decap_l2_table; |
| 975 | struct rhashtable_params decap_l2_ht_params; |
| 976 | /* hash table to store tunnel decap entries */ |
| 977 | struct rhashtable decap_table; |
| 978 | struct rhashtable_params decap_ht_params; |
| 979 | /* hash table to store tunnel encap entries */ |
| 980 | struct rhashtable encap_table; |
| 981 | struct rhashtable_params encap_ht_params; |
Sathya Perla | 2ae7408 | 2017-08-28 13:40:33 -0400 | [diff] [blame] | 982 | |
| 983 | /* lock to atomically add/del an l2 node when a flow is |
| 984 | * added or deleted. |
| 985 | */ |
| 986 | struct mutex lock; |
| 987 | |
Sathya Perla | 5a84acb | 2017-10-26 11:51:31 -0400 | [diff] [blame^] | 988 | /* Fields used for batching stats query */ |
| 989 | struct rhashtable_iter iter; |
| 990 | #define BNXT_FLOW_STATS_BATCH_MAX 10 |
| 991 | struct bnxt_tc_stats_batch { |
| 992 | void *flow_node; |
| 993 | struct bnxt_tc_flow_stats hw_stats; |
| 994 | } stats_batch[BNXT_FLOW_STATS_BATCH_MAX]; |
| 995 | |
Sathya Perla | 2ae7408 | 2017-08-28 13:40:33 -0400 | [diff] [blame] | 996 | /* Stat counter mask (width) */ |
| 997 | u64 bytes_mask; |
| 998 | u64 packets_mask; |
| 999 | }; |
| 1000 | |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 1001 | struct bnxt_vf_rep_stats { |
| 1002 | u64 packets; |
| 1003 | u64 bytes; |
| 1004 | u64 dropped; |
| 1005 | }; |
| 1006 | |
| 1007 | struct bnxt_vf_rep { |
| 1008 | struct bnxt *bp; |
| 1009 | struct net_device *dev; |
Sathya Perla | ee5c7fb | 2017-07-24 12:34:28 -0400 | [diff] [blame] | 1010 | struct metadata_dst *dst; |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 1011 | u16 vf_idx; |
| 1012 | u16 tx_cfa_action; |
| 1013 | u16 rx_cfa_code; |
| 1014 | |
| 1015 | struct bnxt_vf_rep_stats rx_stats; |
| 1016 | struct bnxt_vf_rep_stats tx_stats; |
| 1017 | }; |
| 1018 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1019 | struct bnxt { |
| 1020 | void __iomem *bar0; |
| 1021 | void __iomem *bar1; |
| 1022 | void __iomem *bar2; |
| 1023 | |
| 1024 | u32 reg_base; |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1025 | u16 chip_num; |
| 1026 | #define CHIP_NUM_57301 0x16c8 |
| 1027 | #define CHIP_NUM_57302 0x16c9 |
| 1028 | #define CHIP_NUM_57304 0x16ca |
Prashant Sreedharan | 3e8060f | 2016-07-18 07:15:20 -0400 | [diff] [blame] | 1029 | #define CHIP_NUM_58700 0x16cd |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1030 | #define CHIP_NUM_57402 0x16d0 |
| 1031 | #define CHIP_NUM_57404 0x16d1 |
| 1032 | #define CHIP_NUM_57406 0x16d2 |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1033 | #define CHIP_NUM_57407 0x16d5 |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1034 | |
| 1035 | #define CHIP_NUM_57311 0x16ce |
| 1036 | #define CHIP_NUM_57312 0x16cf |
| 1037 | #define CHIP_NUM_57314 0x16df |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1038 | #define CHIP_NUM_57317 0x16e0 |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1039 | #define CHIP_NUM_57412 0x16d6 |
| 1040 | #define CHIP_NUM_57414 0x16d7 |
| 1041 | #define CHIP_NUM_57416 0x16d8 |
| 1042 | #define CHIP_NUM_57417 0x16d9 |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1043 | #define CHIP_NUM_57412L 0x16da |
| 1044 | #define CHIP_NUM_57414L 0x16db |
| 1045 | |
| 1046 | #define CHIP_NUM_5745X 0xd730 |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1047 | |
Ray Jui | 4a58139 | 2017-08-28 13:40:28 -0400 | [diff] [blame] | 1048 | #define CHIP_NUM_58802 0xd802 |
Ray Jui | 8ed693b | 2017-10-26 11:51:20 -0400 | [diff] [blame] | 1049 | #define CHIP_NUM_58804 0xd804 |
Ray Jui | 4a58139 | 2017-08-28 13:40:28 -0400 | [diff] [blame] | 1050 | #define CHIP_NUM_58808 0xd808 |
| 1051 | |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1052 | #define BNXT_CHIP_NUM_5730X(chip_num) \ |
| 1053 | ((chip_num) >= CHIP_NUM_57301 && \ |
| 1054 | (chip_num) <= CHIP_NUM_57304) |
| 1055 | |
| 1056 | #define BNXT_CHIP_NUM_5740X(chip_num) \ |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1057 | (((chip_num) >= CHIP_NUM_57402 && \ |
| 1058 | (chip_num) <= CHIP_NUM_57406) || \ |
| 1059 | (chip_num) == CHIP_NUM_57407) |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1060 | |
| 1061 | #define BNXT_CHIP_NUM_5731X(chip_num) \ |
| 1062 | ((chip_num) == CHIP_NUM_57311 || \ |
| 1063 | (chip_num) == CHIP_NUM_57312 || \ |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1064 | (chip_num) == CHIP_NUM_57314 || \ |
| 1065 | (chip_num) == CHIP_NUM_57317) |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1066 | |
| 1067 | #define BNXT_CHIP_NUM_5741X(chip_num) \ |
| 1068 | ((chip_num) >= CHIP_NUM_57412 && \ |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1069 | (chip_num) <= CHIP_NUM_57414L) |
| 1070 | |
| 1071 | #define BNXT_CHIP_NUM_58700(chip_num) \ |
| 1072 | ((chip_num) == CHIP_NUM_58700) |
| 1073 | |
| 1074 | #define BNXT_CHIP_NUM_5745X(chip_num) \ |
| 1075 | ((chip_num) == CHIP_NUM_5745X) |
Michael Chan | 659c805 | 2016-06-13 02:25:33 -0400 | [diff] [blame] | 1076 | |
| 1077 | #define BNXT_CHIP_NUM_57X0X(chip_num) \ |
| 1078 | (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num)) |
| 1079 | |
| 1080 | #define BNXT_CHIP_NUM_57X1X(chip_num) \ |
| 1081 | (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num)) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1082 | |
Ray Jui | 4a58139 | 2017-08-28 13:40:28 -0400 | [diff] [blame] | 1083 | #define BNXT_CHIP_NUM_588XX(chip_num) \ |
| 1084 | ((chip_num) == CHIP_NUM_58802 || \ |
Ray Jui | 8ed693b | 2017-10-26 11:51:20 -0400 | [diff] [blame] | 1085 | (chip_num) == CHIP_NUM_58804 || \ |
Ray Jui | 4a58139 | 2017-08-28 13:40:28 -0400 | [diff] [blame] | 1086 | (chip_num) == CHIP_NUM_58808) |
| 1087 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1088 | struct net_device *dev; |
| 1089 | struct pci_dev *pdev; |
| 1090 | |
| 1091 | atomic_t intr_sem; |
| 1092 | |
| 1093 | u32 flags; |
| 1094 | #define BNXT_FLAG_DCB_ENABLED 0x1 |
| 1095 | #define BNXT_FLAG_VF 0x2 |
| 1096 | #define BNXT_FLAG_LRO 0x4 |
Michael Chan | d1611c3 | 2015-10-25 22:27:57 -0400 | [diff] [blame] | 1097 | #ifdef CONFIG_INET |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1098 | #define BNXT_FLAG_GRO 0x8 |
Michael Chan | d1611c3 | 2015-10-25 22:27:57 -0400 | [diff] [blame] | 1099 | #else |
| 1100 | /* Cannot support hardware GRO if CONFIG_INET is not set */ |
| 1101 | #define BNXT_FLAG_GRO 0x0 |
| 1102 | #endif |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1103 | #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO) |
| 1104 | #define BNXT_FLAG_JUMBO 0x10 |
| 1105 | #define BNXT_FLAG_STRIP_VLAN 0x20 |
| 1106 | #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ |
| 1107 | BNXT_FLAG_LRO) |
| 1108 | #define BNXT_FLAG_USING_MSIX 0x40 |
| 1109 | #define BNXT_FLAG_MSIX_CAP 0x80 |
| 1110 | #define BNXT_FLAG_RFS 0x100 |
Michael Chan | 6e6c5a5 | 2016-01-02 23:45:02 -0500 | [diff] [blame] | 1111 | #define BNXT_FLAG_SHARED_RINGS 0x200 |
Michael Chan | 3bdf56c | 2016-03-07 15:38:45 -0500 | [diff] [blame] | 1112 | #define BNXT_FLAG_PORT_STATS 0x400 |
Michael Chan | 87da7f7 | 2016-11-16 21:13:09 -0500 | [diff] [blame] | 1113 | #define BNXT_FLAG_UDP_RSS_CAP 0x800 |
Michael Chan | 170ce01 | 2016-04-05 14:08:57 -0400 | [diff] [blame] | 1114 | #define BNXT_FLAG_EEE_CAP 0x1000 |
Michael Chan | 8fdefd6 | 2016-12-29 12:13:36 -0500 | [diff] [blame] | 1115 | #define BNXT_FLAG_NEW_RSS_CAP 0x2000 |
Michael Chan | c1ef146 | 2017-04-04 18:14:07 -0400 | [diff] [blame] | 1116 | #define BNXT_FLAG_WOL_CAP 0x4000 |
Michael Chan | e4060d3 | 2016-12-07 00:26:19 -0500 | [diff] [blame] | 1117 | #define BNXT_FLAG_ROCEV1_CAP 0x8000 |
| 1118 | #define BNXT_FLAG_ROCEV2_CAP 0x10000 |
| 1119 | #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \ |
| 1120 | BNXT_FLAG_ROCEV2_CAP) |
Michael Chan | bdbd1eb | 2016-12-29 12:13:43 -0500 | [diff] [blame] | 1121 | #define BNXT_FLAG_NO_AGG_RINGS 0x20000 |
Michael Chan | c61fb99 | 2017-02-06 16:55:36 -0500 | [diff] [blame] | 1122 | #define BNXT_FLAG_RX_PAGE_MODE 0x40000 |
Michael Chan | bc39f88 | 2017-03-08 18:44:34 -0500 | [diff] [blame] | 1123 | #define BNXT_FLAG_FW_LLDP_AGENT 0x80000 |
Deepak Khungar | 9e54e32 | 2017-04-21 20:11:26 -0400 | [diff] [blame] | 1124 | #define BNXT_FLAG_MULTI_HOST 0x100000 |
Deepak Khungar | e605db8 | 2017-05-29 19:06:04 -0400 | [diff] [blame] | 1125 | #define BNXT_FLAG_SHORT_CMD 0x200000 |
Michael Chan | 434c975 | 2017-05-29 19:06:08 -0400 | [diff] [blame] | 1126 | #define BNXT_FLAG_DOUBLE_DB 0x400000 |
Michael Chan | 9315edc | 2017-07-24 12:34:25 -0400 | [diff] [blame] | 1127 | #define BNXT_FLAG_FW_DCBX_AGENT 0x800000 |
Prashant Sreedharan | 3e8060f | 2016-07-18 07:15:20 -0400 | [diff] [blame] | 1128 | #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000 |
Michael Chan | 6e6c5a5 | 2016-01-02 23:45:02 -0500 | [diff] [blame] | 1129 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1130 | #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ |
| 1131 | BNXT_FLAG_RFS | \ |
| 1132 | BNXT_FLAG_STRIP_VLAN) |
| 1133 | |
| 1134 | #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF)) |
| 1135 | #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF) |
Satish Baddipadige | 567b2ab | 2016-06-13 02:25:31 -0400 | [diff] [blame] | 1136 | #define BNXT_NPAR(bp) ((bp)->port_partition_type) |
Deepak Khungar | 9e54e32 | 2017-04-21 20:11:26 -0400 | [diff] [blame] | 1137 | #define BNXT_MH(bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST) |
| 1138 | #define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp)) |
Prashant Sreedharan | 3e8060f | 2016-07-18 07:15:20 -0400 | [diff] [blame] | 1139 | #define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0) |
Michael Chan | c61fb99 | 2017-02-06 16:55:36 -0500 | [diff] [blame] | 1140 | #define BNXT_RX_PAGE_MODE(bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1141 | |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1142 | /* Chip class phase 4 and later */ |
| 1143 | #define BNXT_CHIP_P4_PLUS(bp) \ |
| 1144 | (BNXT_CHIP_NUM_57X1X((bp)->chip_num) || \ |
| 1145 | BNXT_CHIP_NUM_5745X((bp)->chip_num) || \ |
Ray Jui | 4a58139 | 2017-08-28 13:40:28 -0400 | [diff] [blame] | 1146 | BNXT_CHIP_NUM_588XX((bp)->chip_num) || \ |
Michael Chan | 3284f9e | 2017-05-29 19:06:07 -0400 | [diff] [blame] | 1147 | (BNXT_CHIP_NUM_58700((bp)->chip_num) && \ |
| 1148 | !BNXT_CHIP_TYPE_NITRO_A0(bp))) |
| 1149 | |
Michael Chan | a588e45 | 2016-12-07 00:26:21 -0500 | [diff] [blame] | 1150 | struct bnxt_en_dev *edev; |
| 1151 | struct bnxt_en_dev * (*ulp_probe)(struct net_device *); |
| 1152 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1153 | struct bnxt_napi **bnapi; |
| 1154 | |
Michael Chan | b6ab4b0 | 2016-01-02 23:44:59 -0500 | [diff] [blame] | 1155 | struct bnxt_rx_ring_info *rx_ring; |
| 1156 | struct bnxt_tx_ring_info *tx_ring; |
Michael Chan | a960dec | 2017-02-06 16:55:39 -0500 | [diff] [blame] | 1157 | u16 *tx_ring_map; |
Michael Chan | b6ab4b0 | 2016-01-02 23:44:59 -0500 | [diff] [blame] | 1158 | |
Michael Chan | 309369c | 2016-06-13 02:25:34 -0400 | [diff] [blame] | 1159 | struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int, |
| 1160 | struct sk_buff *); |
| 1161 | |
Michael Chan | 6bb1947 | 2017-02-06 16:55:32 -0500 | [diff] [blame] | 1162 | struct sk_buff * (*rx_skb_func)(struct bnxt *, |
| 1163 | struct bnxt_rx_ring_info *, |
| 1164 | u16, void *, u8 *, dma_addr_t, |
| 1165 | unsigned int); |
| 1166 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1167 | u32 rx_buf_size; |
| 1168 | u32 rx_buf_use_size; /* useable size */ |
Michael Chan | b3dba77 | 2017-02-06 16:55:35 -0500 | [diff] [blame] | 1169 | u16 rx_offset; |
| 1170 | u16 rx_dma_offset; |
Michael Chan | 745fc05 | 2017-02-06 16:55:34 -0500 | [diff] [blame] | 1171 | enum dma_data_direction rx_dir; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1172 | u32 rx_ring_size; |
| 1173 | u32 rx_agg_ring_size; |
| 1174 | u32 rx_copy_thresh; |
| 1175 | u32 rx_ring_mask; |
| 1176 | u32 rx_agg_ring_mask; |
| 1177 | int rx_nr_pages; |
| 1178 | int rx_agg_nr_pages; |
| 1179 | int rx_nr_rings; |
| 1180 | int rsscos_nr_ctxs; |
| 1181 | |
| 1182 | u32 tx_ring_size; |
| 1183 | u32 tx_ring_mask; |
| 1184 | int tx_nr_pages; |
| 1185 | int tx_nr_rings; |
| 1186 | int tx_nr_rings_per_tc; |
Michael Chan | 5f44924 | 2017-02-06 16:55:40 -0500 | [diff] [blame] | 1187 | int tx_nr_rings_xdp; |
Michael Chan | 98fdbe7 | 2017-08-28 13:40:26 -0400 | [diff] [blame] | 1188 | int tx_reserved_rings; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1189 | |
| 1190 | int tx_wake_thresh; |
| 1191 | int tx_push_thresh; |
| 1192 | int tx_push_size; |
| 1193 | |
| 1194 | u32 cp_ring_size; |
| 1195 | u32 cp_ring_mask; |
| 1196 | u32 cp_bit; |
| 1197 | int cp_nr_pages; |
| 1198 | int cp_nr_rings; |
| 1199 | |
| 1200 | int num_stat_ctxs; |
Michael Chan | b81a90d | 2016-01-02 23:45:01 -0500 | [diff] [blame] | 1201 | |
| 1202 | /* grp_info indexed by completion ring index */ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1203 | struct bnxt_ring_grp_info *grp_info; |
| 1204 | struct bnxt_vnic_info *vnic_info; |
| 1205 | int nr_vnics; |
Michael Chan | 87da7f7 | 2016-11-16 21:13:09 -0500 | [diff] [blame] | 1206 | u32 rss_hash_cfg; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1207 | |
Michael Chan | 7eb9bb3 | 2017-10-26 11:51:25 -0400 | [diff] [blame] | 1208 | u16 max_mtu; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1209 | u8 max_tc; |
Michael Chan | 87c374d | 2016-12-02 21:17:16 -0500 | [diff] [blame] | 1210 | u8 max_lltc; /* lossless TCs */ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1211 | struct bnxt_queue_info q_info[BNXT_MAX_QUEUE]; |
| 1212 | |
| 1213 | unsigned int current_interval; |
Michael Chan | 3bdf56c | 2016-03-07 15:38:45 -0500 | [diff] [blame] | 1214 | #define BNXT_TIMER_INTERVAL HZ |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1215 | |
| 1216 | struct timer_list timer; |
| 1217 | |
Michael Chan | caefe52 | 2015-12-09 19:35:42 -0500 | [diff] [blame] | 1218 | unsigned long state; |
| 1219 | #define BNXT_STATE_OPEN 0 |
Michael Chan | 4cebdce | 2015-12-09 19:35:43 -0500 | [diff] [blame] | 1220 | #define BNXT_STATE_IN_SP_TASK 1 |
Michael Chan | f9b76eb | 2017-07-11 13:05:34 -0400 | [diff] [blame] | 1221 | #define BNXT_STATE_READ_STATS 2 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1222 | |
| 1223 | struct bnxt_irq *irq_tbl; |
Michael Chan | 7809592 | 2016-12-07 00:26:16 -0500 | [diff] [blame] | 1224 | int total_irqs; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1225 | u8 mac_addr[ETH_ALEN]; |
| 1226 | |
Michael Chan | 7df4ae9 | 2016-12-02 21:17:17 -0500 | [diff] [blame] | 1227 | #ifdef CONFIG_BNXT_DCB |
| 1228 | struct ieee_pfc *ieee_pfc; |
| 1229 | struct ieee_ets *ieee_ets; |
| 1230 | u8 dcbx_cap; |
| 1231 | u8 default_pri; |
| 1232 | #endif /* CONFIG_BNXT_DCB */ |
| 1233 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1234 | u32 msg_enable; |
| 1235 | |
Michael Chan | 11f15ed | 2016-04-05 14:08:55 -0400 | [diff] [blame] | 1236 | u32 hwrm_spec_code; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1237 | u16 hwrm_cmd_seq; |
| 1238 | u32 hwrm_intr_seq_id; |
Deepak Khungar | e605db8 | 2017-05-29 19:06:04 -0400 | [diff] [blame] | 1239 | void *hwrm_short_cmd_req_addr; |
| 1240 | dma_addr_t hwrm_short_cmd_req_dma_addr; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1241 | void *hwrm_cmd_resp_addr; |
| 1242 | dma_addr_t hwrm_cmd_resp_dma_addr; |
| 1243 | void *hwrm_dbg_resp_addr; |
| 1244 | dma_addr_t hwrm_dbg_resp_dma_addr; |
| 1245 | #define HWRM_DBG_REG_BUF_SIZE 128 |
Michael Chan | 3bdf56c | 2016-03-07 15:38:45 -0500 | [diff] [blame] | 1246 | |
| 1247 | struct rx_port_stats *hw_rx_port_stats; |
| 1248 | struct tx_port_stats *hw_tx_port_stats; |
| 1249 | dma_addr_t hw_rx_port_stats_map; |
| 1250 | dma_addr_t hw_tx_port_stats_map; |
| 1251 | int hw_port_stats_size; |
| 1252 | |
Michael Chan | e6ef269 | 2016-03-28 19:46:05 -0400 | [diff] [blame] | 1253 | u16 hwrm_max_req_len; |
Michael Chan | ff4fe81 | 2016-02-26 04:00:04 -0500 | [diff] [blame] | 1254 | int hwrm_cmd_timeout; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1255 | struct mutex hwrm_cmd_lock; /* serialize hwrm messages */ |
| 1256 | struct hwrm_ver_get_output ver_resp; |
| 1257 | #define FW_VER_STR_LEN 32 |
| 1258 | #define BC_HWRM_STR_LEN 21 |
| 1259 | #define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN) |
| 1260 | char fw_ver_str[FW_VER_STR_LEN]; |
| 1261 | __be16 vxlan_port; |
| 1262 | u8 vxlan_port_cnt; |
| 1263 | __le16 vxlan_fw_dst_port_id; |
Alexander Duyck | 7cdd5fc | 2016-06-16 12:21:36 -0700 | [diff] [blame] | 1264 | __be16 nge_port; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1265 | u8 nge_port_cnt; |
| 1266 | __le16 nge_fw_dst_port_id; |
Satish Baddipadige | 567b2ab | 2016-06-13 02:25:31 -0400 | [diff] [blame] | 1267 | u8 port_partition_type; |
Michael Chan | d5430d3 | 2017-08-28 13:40:31 -0400 | [diff] [blame] | 1268 | u8 port_count; |
Michael Chan | 32e8239c | 2017-07-24 12:34:21 -0400 | [diff] [blame] | 1269 | u16 br_mode; |
Michael Chan | dfc9c94 | 2016-02-26 04:00:03 -0500 | [diff] [blame] | 1270 | |
Michael Chan | 18775aa | 2017-10-26 11:51:27 -0400 | [diff] [blame] | 1271 | struct bnxt_coal rx_coal; |
| 1272 | struct bnxt_coal tx_coal; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1273 | |
| 1274 | #define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2) |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1275 | |
Michael Chan | 51f3078 | 2016-07-01 18:46:29 -0400 | [diff] [blame] | 1276 | u32 stats_coal_ticks; |
| 1277 | #define BNXT_DEF_STATS_COAL_TICKS 1000000 |
| 1278 | #define BNXT_MIN_STATS_COAL_TICKS 250000 |
| 1279 | #define BNXT_MAX_STATS_COAL_TICKS 1000000 |
| 1280 | |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1281 | struct work_struct sp_task; |
| 1282 | unsigned long sp_event; |
| 1283 | #define BNXT_RX_MASK_SP_EVENT 0 |
| 1284 | #define BNXT_RX_NTP_FLTR_SP_EVENT 1 |
| 1285 | #define BNXT_LINK_CHNG_SP_EVENT 2 |
Jeffrey Huang | c5d7774 | 2015-11-05 16:25:47 -0500 | [diff] [blame] | 1286 | #define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3 |
| 1287 | #define BNXT_VXLAN_ADD_PORT_SP_EVENT 4 |
| 1288 | #define BNXT_VXLAN_DEL_PORT_SP_EVENT 5 |
| 1289 | #define BNXT_RESET_TASK_SP_EVENT 6 |
| 1290 | #define BNXT_RST_RING_SP_EVENT 7 |
Jeffrey Huang | 1924136 | 2016-02-26 04:00:00 -0500 | [diff] [blame] | 1291 | #define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8 |
Michael Chan | 3bdf56c | 2016-03-07 15:38:45 -0500 | [diff] [blame] | 1292 | #define BNXT_PERIODIC_STATS_SP_EVENT 9 |
Michael Chan | 4bb13ab | 2016-04-05 14:09:01 -0400 | [diff] [blame] | 1293 | #define BNXT_HWRM_PORT_MODULE_SP_EVENT 10 |
Michael Chan | fc0f192 | 2016-06-13 02:25:30 -0400 | [diff] [blame] | 1294 | #define BNXT_RESET_TASK_SILENT_SP_EVENT 11 |
Alexander Duyck | 7cdd5fc | 2016-06-16 12:21:36 -0700 | [diff] [blame] | 1295 | #define BNXT_GENEVE_ADD_PORT_SP_EVENT 12 |
| 1296 | #define BNXT_GENEVE_DEL_PORT_SP_EVENT 13 |
Michael Chan | 286ef9d | 2016-11-16 21:13:08 -0500 | [diff] [blame] | 1297 | #define BNXT_LINK_SPEED_CHNG_SP_EVENT 14 |
Sathya Perla | 5a84acb | 2017-10-26 11:51:31 -0400 | [diff] [blame^] | 1298 | #define BNXT_FLOW_STATS_SP_EVENT 15 |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1299 | |
Michael Chan | 379a80a | 2015-10-23 15:06:19 -0400 | [diff] [blame] | 1300 | struct bnxt_pf_info pf; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1301 | #ifdef CONFIG_BNXT_SRIOV |
| 1302 | int nr_vfs; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1303 | struct bnxt_vf_info vf; |
| 1304 | wait_queue_head_t sriov_cfg_wait; |
| 1305 | bool sriov_cfg; |
| 1306 | #define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000) |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 1307 | |
| 1308 | /* lock to protect VF-rep creation/cleanup via |
| 1309 | * multiple paths such as ->sriov_configure() and |
| 1310 | * devlink ->eswitch_mode_set() |
| 1311 | */ |
| 1312 | struct mutex sriov_lock; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1313 | #endif |
| 1314 | |
| 1315 | #define BNXT_NTP_FLTR_MAX_FLTR 4096 |
| 1316 | #define BNXT_NTP_FLTR_HASH_SIZE 512 |
| 1317 | #define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1) |
| 1318 | struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE]; |
| 1319 | spinlock_t ntp_fltr_lock; /* for hash table add, del */ |
| 1320 | |
| 1321 | unsigned long *ntp_fltr_bmap; |
| 1322 | int ntp_fltr_count; |
| 1323 | |
Michael Chan | e2dc9b6 | 2017-10-13 21:09:30 -0400 | [diff] [blame] | 1324 | /* To protect link related settings during link changes and |
| 1325 | * ethtool settings changes. |
| 1326 | */ |
| 1327 | struct mutex link_lock; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1328 | struct bnxt_link_info link_info; |
Michael Chan | 170ce01 | 2016-04-05 14:08:57 -0400 | [diff] [blame] | 1329 | struct ethtool_eee eee; |
| 1330 | u32 lpi_tmr_lo; |
| 1331 | u32 lpi_tmr_hi; |
Michael Chan | 5ad2cbe | 2017-01-13 01:32:03 -0500 | [diff] [blame] | 1332 | |
Michael Chan | eb51365 | 2017-04-04 18:14:12 -0400 | [diff] [blame] | 1333 | u8 num_tests; |
| 1334 | struct bnxt_test_info *test_info; |
| 1335 | |
Michael Chan | c1ef146 | 2017-04-04 18:14:07 -0400 | [diff] [blame] | 1336 | u8 wol_filter_id; |
| 1337 | u8 wol; |
| 1338 | |
Michael Chan | 5ad2cbe | 2017-01-13 01:32:03 -0500 | [diff] [blame] | 1339 | u8 num_leds; |
| 1340 | struct bnxt_led_info leds[BNXT_MAX_LED]; |
Michael Chan | c6d30e8 | 2017-02-06 16:55:42 -0500 | [diff] [blame] | 1341 | |
| 1342 | struct bpf_prog *xdp_prog; |
Sathya Perla | 4ab0c6a | 2017-07-24 12:34:27 -0400 | [diff] [blame] | 1343 | |
| 1344 | /* devlink interface and vf-rep structs */ |
| 1345 | struct devlink *dl; |
| 1346 | enum devlink_eswitch_mode eswitch_mode; |
| 1347 | struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */ |
| 1348 | u16 *cfa_code_map; /* cfa_code -> vf_idx map */ |
Sathya Perla | 2ae7408 | 2017-08-28 13:40:33 -0400 | [diff] [blame] | 1349 | struct bnxt_tc_info tc_info; |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1350 | }; |
| 1351 | |
Michael Chan | c77192f | 2016-12-02 21:17:18 -0500 | [diff] [blame] | 1352 | #define BNXT_RX_STATS_OFFSET(counter) \ |
| 1353 | (offsetof(struct rx_port_stats, counter) / 8) |
| 1354 | |
| 1355 | #define BNXT_TX_STATS_OFFSET(counter) \ |
| 1356 | ((offsetof(struct tx_port_stats, counter) + \ |
| 1357 | sizeof(struct rx_port_stats) + 512) / 8) |
| 1358 | |
Ajit Khaparde | 42ee18f | 2016-05-15 03:04:44 -0400 | [diff] [blame] | 1359 | #define I2C_DEV_ADDR_A0 0xa0 |
| 1360 | #define I2C_DEV_ADDR_A2 0xa2 |
| 1361 | #define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e |
| 1362 | #define SFP_EEPROM_SFF_8472_COMP_SIZE 1 |
| 1363 | #define SFF_MODULE_ID_SFP 0x3 |
| 1364 | #define SFF_MODULE_ID_QSFP 0xc |
| 1365 | #define SFF_MODULE_ID_QSFP_PLUS 0xd |
| 1366 | #define SFF_MODULE_ID_QSFP28 0x11 |
| 1367 | #define BNXT_MAX_PHY_I2C_RESP_SIZE 64 |
| 1368 | |
Michael Chan | 3841340 | 2017-02-06 16:55:43 -0500 | [diff] [blame] | 1369 | static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr) |
| 1370 | { |
| 1371 | /* Tell compiler to fetch tx indices from memory. */ |
| 1372 | barrier(); |
| 1373 | |
| 1374 | return bp->tx_ring_size - |
| 1375 | ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask); |
| 1376 | } |
| 1377 | |
Michael Chan | 434c975 | 2017-05-29 19:06:08 -0400 | [diff] [blame] | 1378 | /* For TX and RX ring doorbells */ |
| 1379 | static inline void bnxt_db_write(struct bnxt *bp, void __iomem *db, u32 val) |
| 1380 | { |
| 1381 | writel(val, db); |
| 1382 | if (bp->flags & BNXT_FLAG_DOUBLE_DB) |
| 1383 | writel(val, db); |
| 1384 | } |
| 1385 | |
Michael Chan | 3841340 | 2017-02-06 16:55:43 -0500 | [diff] [blame] | 1386 | extern const u16 bnxt_lhint_arr[]; |
| 1387 | |
| 1388 | int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, |
| 1389 | u16 prod, gfp_t gfp); |
Michael Chan | c6d30e8 | 2017-02-06 16:55:42 -0500 | [diff] [blame] | 1390 | void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data); |
| 1391 | void bnxt_set_tpa_flags(struct bnxt *bp); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1392 | void bnxt_set_ring_params(struct bnxt *); |
Michael Chan | c61fb99 | 2017-02-06 16:55:36 -0500 | [diff] [blame] | 1393 | int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1394 | void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16); |
| 1395 | int _hwrm_send_message(struct bnxt *, void *, u32, int); |
Michael Chan | cc72f3b | 2017-10-13 21:09:33 -0400 | [diff] [blame] | 1396 | int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1397 | int hwrm_send_message(struct bnxt *, void *, u32, int); |
Michael Chan | 90e20921 | 2016-02-26 04:00:08 -0500 | [diff] [blame] | 1398 | int hwrm_send_message_silent(struct bnxt *, void *, u32, int); |
Michael Chan | a1653b1 | 2016-12-07 00:26:20 -0500 | [diff] [blame] | 1399 | int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap, |
| 1400 | int bmap_size); |
Michael Chan | a588e45 | 2016-12-07 00:26:21 -0500 | [diff] [blame] | 1401 | int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id); |
Michael Chan | 391be5c | 2016-12-29 12:13:41 -0500 | [diff] [blame] | 1402 | int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1403 | int bnxt_hwrm_set_coal(struct bnxt *); |
Michael Chan | e4060d3 | 2016-12-07 00:26:19 -0500 | [diff] [blame] | 1404 | unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp); |
Michael Chan | a588e45 | 2016-12-07 00:26:21 -0500 | [diff] [blame] | 1405 | void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max); |
Michael Chan | e4060d3 | 2016-12-07 00:26:19 -0500 | [diff] [blame] | 1406 | unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); |
Michael Chan | a588e45 | 2016-12-07 00:26:21 -0500 | [diff] [blame] | 1407 | void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max); |
Michael Chan | 33c2657 | 2016-12-07 00:26:15 -0500 | [diff] [blame] | 1408 | void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max); |
Michael Chan | 7df4ae9 | 2016-12-02 21:17:17 -0500 | [diff] [blame] | 1409 | void bnxt_tx_disable(struct bnxt *bp); |
| 1410 | void bnxt_tx_enable(struct bnxt *bp); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1411 | int bnxt_hwrm_set_pause(struct bnxt *); |
Michael Chan | 939f7f0 | 2016-04-05 14:08:58 -0400 | [diff] [blame] | 1412 | int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool); |
Michael Chan | 5282db6 | 2017-04-04 18:14:10 -0400 | [diff] [blame] | 1413 | int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp); |
| 1414 | int bnxt_hwrm_free_wol_fltr(struct bnxt *bp); |
Rob Swindell | 5ac67d8 | 2016-09-19 03:58:03 -0400 | [diff] [blame] | 1415 | int bnxt_hwrm_fw_set_time(struct bnxt *); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1416 | int bnxt_open_nic(struct bnxt *, bool, bool); |
Michael Chan | f7dc1ea | 2017-04-04 18:14:13 -0400 | [diff] [blame] | 1417 | int bnxt_half_open_nic(struct bnxt *bp); |
| 1418 | void bnxt_half_close_nic(struct bnxt *bp); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1419 | int bnxt_close_nic(struct bnxt *, bool, bool); |
Michael Chan | 98fdbe7 | 2017-08-28 13:40:26 -0400 | [diff] [blame] | 1420 | int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, |
| 1421 | int tx_xdp); |
Michael Chan | c5e3deb | 2016-12-02 21:17:15 -0500 | [diff] [blame] | 1422 | int bnxt_setup_mq_tc(struct net_device *dev, u8 tc); |
Michael Chan | 6e6c5a5 | 2016-01-02 23:45:02 -0500 | [diff] [blame] | 1423 | int bnxt_get_max_rings(struct bnxt *, int *, int *, bool); |
Michael Chan | 7b08f66 | 2016-12-07 00:26:18 -0500 | [diff] [blame] | 1424 | void bnxt_restore_pf_fw_resources(struct bnxt *bp); |
Sathya Perla | c124a62 | 2017-07-24 12:34:29 -0400 | [diff] [blame] | 1425 | int bnxt_port_attr_get(struct bnxt *bp, struct switchdev_attr *attr); |
Michael Chan | c0c050c | 2015-10-22 16:01:17 -0400 | [diff] [blame] | 1426 | #endif |