Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 1 | /********************************************************************** |
| 2 | * Author: Cavium, Inc. |
| 3 | * |
| 4 | * Contact: support@cavium.com |
| 5 | * Please include "LiquidIO" in the subject. |
| 6 | * |
| 7 | * Copyright (c) 2003-2015 Cavium, Inc. |
| 8 | * |
| 9 | * This file is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License, Version 2, as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * This file is distributed in the hope that it will be useful, but |
| 14 | * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty |
| 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or |
| 16 | * NONINFRINGEMENT. See the GNU General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * This file may also be available under a different license from Cavium. |
| 20 | * Contact Cavium, Inc. for more information |
| 21 | **********************************************************************/ |
| 22 | |
| 23 | /*! \file liquidio_common.h |
| 24 | * \brief Common: Structures and macros used in PCI-NIC package by core and |
| 25 | * host driver. |
| 26 | */ |
| 27 | |
| 28 | #ifndef __LIQUIDIO_COMMON_H__ |
| 29 | #define __LIQUIDIO_COMMON_H__ |
| 30 | |
| 31 | #include "octeon_config.h" |
| 32 | |
Raghu Vatsavayi | d3d7e6c | 2016-06-21 22:53:07 -0700 | [diff] [blame] | 33 | #define LIQUIDIO_BASE_VERSION "1.4" |
| 34 | #define LIQUIDIO_MICRO_VERSION ".1" |
| 35 | #define LIQUIDIO_PACKAGE "" |
| 36 | #define LIQUIDIO_VERSION "1.4.1" |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 37 | #define CONTROL_IQ 0 |
| 38 | /** Tag types used by Octeon cores in its work. */ |
| 39 | enum octeon_tag_type { |
| 40 | ORDERED_TAG = 0, |
| 41 | ATOMIC_TAG = 1, |
| 42 | NULL_TAG = 2, |
| 43 | NULL_NULL_TAG = 3 |
| 44 | }; |
| 45 | |
| 46 | /* pre-defined host->NIC tag values */ |
| 47 | #define LIO_CONTROL (0x11111110) |
| 48 | #define LIO_DATA(i) (0x11111111 + (i)) |
| 49 | |
| 50 | /* Opcodes used by host driver/apps to perform operations on the core. |
| 51 | * These are used to identify the major subsystem that the operation |
| 52 | * is for. |
| 53 | */ |
| 54 | #define OPCODE_CORE 0 /* used for generic core operations */ |
| 55 | #define OPCODE_NIC 1 /* used for NIC operations */ |
| 56 | #define OPCODE_LAST OPCODE_NIC |
| 57 | |
| 58 | /* Subcodes are used by host driver/apps to identify the sub-operation |
| 59 | * for the core. They only need to by unique for a given subsystem. |
| 60 | */ |
| 61 | #define OPCODE_SUBCODE(op, sub) (((op & 0x0f) << 8) | ((sub) & 0x7f)) |
| 62 | |
| 63 | /** OPCODE_CORE subcodes. For future use. */ |
| 64 | |
| 65 | /** OPCODE_NIC subcodes */ |
| 66 | |
| 67 | /* This subcode is sent by core PCI driver to indicate cores are ready. */ |
| 68 | #define OPCODE_NIC_CORE_DRV_ACTIVE 0x01 |
| 69 | #define OPCODE_NIC_NW_DATA 0x02 /* network packet data */ |
| 70 | #define OPCODE_NIC_CMD 0x03 |
| 71 | #define OPCODE_NIC_INFO 0x04 |
| 72 | #define OPCODE_NIC_PORT_STATS 0x05 |
| 73 | #define OPCODE_NIC_MDIO45 0x06 |
| 74 | #define OPCODE_NIC_TIMESTAMP 0x07 |
| 75 | #define OPCODE_NIC_INTRMOD_CFG 0x08 |
| 76 | #define OPCODE_NIC_IF_CFG 0x09 |
| 77 | |
| 78 | #define CORE_DRV_TEST_SCATTER_OP 0xFFF5 |
| 79 | |
| 80 | #define OPCODE_SLOW_PATH(rh) \ |
| 81 | (OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode) != \ |
| 82 | OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA)) |
| 83 | |
| 84 | /* Application codes advertised by the core driver initialization packet. */ |
| 85 | #define CVM_DRV_APP_START 0x0 |
| 86 | #define CVM_DRV_NO_APP 0 |
| 87 | #define CVM_DRV_APP_COUNT 0x2 |
| 88 | #define CVM_DRV_BASE_APP (CVM_DRV_APP_START + 0x0) |
| 89 | #define CVM_DRV_NIC_APP (CVM_DRV_APP_START + 0x1) |
| 90 | #define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2) |
| 91 | #define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1) |
| 92 | |
| 93 | /* Macro to increment index. |
| 94 | * Index is incremented by count; if the sum exceeds |
| 95 | * max, index is wrapped-around to the start. |
| 96 | */ |
| 97 | #define INCR_INDEX(index, count, max) \ |
| 98 | do { \ |
| 99 | if (((index) + (count)) >= (max)) \ |
| 100 | index = ((index) + (count)) - (max); \ |
| 101 | else \ |
| 102 | index += (count); \ |
| 103 | } while (0) |
| 104 | |
| 105 | #define INCR_INDEX_BY1(index, max) \ |
| 106 | do { \ |
| 107 | if ((++(index)) == (max)) \ |
| 108 | index = 0; \ |
| 109 | } while (0) |
| 110 | |
| 111 | #define DECR_INDEX(index, count, max) \ |
| 112 | do { \ |
| 113 | if ((count) > (index)) \ |
| 114 | index = ((max) - ((count - index))); \ |
| 115 | else \ |
| 116 | index -= count; \ |
| 117 | } while (0) |
| 118 | |
| 119 | #define OCT_BOARD_NAME 32 |
| 120 | #define OCT_SERIAL_LEN 64 |
| 121 | |
| 122 | /* Structure used by core driver to send indication that the Octeon |
| 123 | * application is ready. |
| 124 | */ |
| 125 | struct octeon_core_setup { |
| 126 | u64 corefreq; |
| 127 | |
| 128 | char boardname[OCT_BOARD_NAME]; |
| 129 | |
| 130 | char board_serial_number[OCT_SERIAL_LEN]; |
| 131 | |
| 132 | u64 board_rev_major; |
| 133 | |
| 134 | u64 board_rev_minor; |
| 135 | |
| 136 | }; |
| 137 | |
| 138 | /*--------------------------- SCATTER GATHER ENTRY -----------------------*/ |
| 139 | |
| 140 | /* The Scatter-Gather List Entry. The scatter or gather component used with |
| 141 | * a Octeon input instruction has this format. |
| 142 | */ |
| 143 | struct octeon_sg_entry { |
| 144 | /** The first 64 bit gives the size of data in each dptr.*/ |
| 145 | union { |
| 146 | u16 size[4]; |
| 147 | u64 size64; |
| 148 | } u; |
| 149 | |
| 150 | /** The 4 dptr pointers for this entry. */ |
| 151 | u64 ptr[4]; |
| 152 | |
| 153 | }; |
| 154 | |
| 155 | #define OCT_SG_ENTRY_SIZE (sizeof(struct octeon_sg_entry)) |
| 156 | |
| 157 | /* \brief Add size to gather list |
| 158 | * @param sg_entry scatter/gather entry |
| 159 | * @param size size to add |
| 160 | * @param pos position to add it. |
| 161 | */ |
| 162 | static inline void add_sg_size(struct octeon_sg_entry *sg_entry, |
| 163 | u16 size, |
| 164 | u32 pos) |
| 165 | { |
| 166 | #ifdef __BIG_ENDIAN_BITFIELD |
| 167 | sg_entry->u.size[pos] = size; |
| 168 | #else |
| 169 | sg_entry->u.size[3 - pos] = size; |
| 170 | #endif |
| 171 | } |
| 172 | |
| 173 | /*------------------------- End Scatter/Gather ---------------------------*/ |
| 174 | |
| 175 | #define OCTNET_FRM_PTP_HEADER_SIZE 8 |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 176 | |
Raghu Vatsavayi | a5b3788 | 2016-06-14 16:54:48 -0700 | [diff] [blame] | 177 | #define OCTNET_FRM_HEADER_SIZE 22 /* VLAN + Ethernet */ |
| 178 | |
| 179 | #define OCTNET_MIN_FRM_SIZE 64 |
| 180 | |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 181 | #define OCTNET_MAX_FRM_SIZE (16000 + OCTNET_FRM_HEADER_SIZE) |
| 182 | |
| 183 | #define OCTNET_DEFAULT_FRM_SIZE (1500 + OCTNET_FRM_HEADER_SIZE) |
| 184 | |
| 185 | /** NIC Commands are sent using this Octeon Input Queue */ |
| 186 | #define OCTNET_CMD_Q 0 |
| 187 | |
| 188 | /* NIC Command types */ |
| 189 | #define OCTNET_CMD_CHANGE_MTU 0x1 |
| 190 | #define OCTNET_CMD_CHANGE_MACADDR 0x2 |
| 191 | #define OCTNET_CMD_CHANGE_DEVFLAGS 0x3 |
| 192 | #define OCTNET_CMD_RX_CTL 0x4 |
| 193 | |
| 194 | #define OCTNET_CMD_SET_MULTI_LIST 0x5 |
| 195 | #define OCTNET_CMD_CLEAR_STATS 0x6 |
| 196 | |
| 197 | /* command for setting the speed, duplex & autoneg */ |
| 198 | #define OCTNET_CMD_SET_SETTINGS 0x7 |
| 199 | #define OCTNET_CMD_SET_FLOW_CTL 0x8 |
| 200 | |
| 201 | #define OCTNET_CMD_MDIO_READ_WRITE 0x9 |
| 202 | #define OCTNET_CMD_GPIO_ACCESS 0xA |
| 203 | #define OCTNET_CMD_LRO_ENABLE 0xB |
| 204 | #define OCTNET_CMD_LRO_DISABLE 0xC |
| 205 | #define OCTNET_CMD_SET_RSS 0xD |
| 206 | #define OCTNET_CMD_WRITE_SA 0xE |
| 207 | #define OCTNET_CMD_DELETE_SA 0xF |
| 208 | #define OCTNET_CMD_UPDATE_SA 0x12 |
| 209 | |
| 210 | #define OCTNET_CMD_TNL_RX_CSUM_CTL 0x10 |
| 211 | #define OCTNET_CMD_TNL_TX_CSUM_CTL 0x11 |
| 212 | #define OCTNET_CMD_IPSECV2_AH_ESP_CTL 0x13 |
| 213 | #define OCTNET_CMD_VERBOSE_ENABLE 0x14 |
| 214 | #define OCTNET_CMD_VERBOSE_DISABLE 0x15 |
| 215 | |
Raghu Vatsavayi | 63245f2 | 2016-06-21 22:53:05 -0700 | [diff] [blame] | 216 | #define OCTNET_CMD_ENABLE_VLAN_FILTER 0x16 |
| 217 | #define OCTNET_CMD_ADD_VLAN_FILTER 0x17 |
| 218 | #define OCTNET_CMD_DEL_VLAN_FILTER 0x18 |
| 219 | |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 220 | /* RX(packets coming from wire) Checksum verification flags */ |
| 221 | /* TCP/UDP csum */ |
| 222 | #define CNNIC_L4SUM_VERIFIED 0x1 |
| 223 | #define CNNIC_IPSUM_VERIFIED 0x2 |
| 224 | #define CNNIC_TUN_CSUM_VERIFIED 0x4 |
| 225 | #define CNNIC_CSUM_VERIFIED (CNNIC_IPSUM_VERIFIED | CNNIC_L4SUM_VERIFIED) |
| 226 | |
| 227 | /*LROIPV4 and LROIPV6 Flags*/ |
| 228 | #define OCTNIC_LROIPV4 0x1 |
| 229 | #define OCTNIC_LROIPV6 0x2 |
| 230 | |
| 231 | /* Interface flags communicated between host driver and core app. */ |
| 232 | enum octnet_ifflags { |
| 233 | OCTNET_IFFLAG_PROMISC = 0x01, |
| 234 | OCTNET_IFFLAG_ALLMULTI = 0x02, |
| 235 | OCTNET_IFFLAG_MULTICAST = 0x04, |
| 236 | OCTNET_IFFLAG_BROADCAST = 0x08, |
| 237 | OCTNET_IFFLAG_UNICAST = 0x10 |
| 238 | }; |
| 239 | |
| 240 | /* wqe |
| 241 | * --------------- 0 |
| 242 | * | wqe word0-3 | |
| 243 | * --------------- 32 |
| 244 | * | PCI IH | |
| 245 | * --------------- 40 |
| 246 | * | RPTR | |
| 247 | * --------------- 48 |
| 248 | * | PCI IRH | |
| 249 | * --------------- 56 |
| 250 | * | OCT_NET_CMD | |
| 251 | * --------------- 64 |
| 252 | * | Addtl 8-BData | |
| 253 | * | | |
| 254 | * --------------- |
| 255 | */ |
| 256 | |
| 257 | union octnet_cmd { |
| 258 | u64 u64; |
| 259 | |
| 260 | struct { |
| 261 | #ifdef __BIG_ENDIAN_BITFIELD |
| 262 | u64 cmd:5; |
| 263 | |
| 264 | u64 more:6; /* How many udd words follow the command */ |
| 265 | |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 266 | u64 reserved:29; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 267 | |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 268 | u64 param1:16; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 269 | |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 270 | u64 param2:8; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 271 | |
| 272 | #else |
| 273 | |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 274 | u64 param2:8; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 275 | |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 276 | u64 param1:16; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 277 | |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 278 | u64 reserved:29; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 279 | |
| 280 | u64 more:6; |
| 281 | |
| 282 | u64 cmd:5; |
| 283 | |
| 284 | #endif |
| 285 | } s; |
| 286 | |
| 287 | }; |
| 288 | |
| 289 | #define OCTNET_CMD_SIZE (sizeof(union octnet_cmd)) |
| 290 | |
Raghu Vatsavayi | 6a885b6 | 2016-06-14 16:54:51 -0700 | [diff] [blame] | 291 | /* Instruction Header (DPI - CN23xx) - for OCTEON-III models */ |
| 292 | struct octeon_instr_ih3 { |
| 293 | #ifdef __BIG_ENDIAN_BITFIELD |
| 294 | |
| 295 | /** Reserved3 */ |
| 296 | u64 reserved3:1; |
| 297 | |
| 298 | /** Gather indicator 1=gather*/ |
| 299 | u64 gather:1; |
| 300 | |
| 301 | /** Data length OR no. of entries in gather list */ |
| 302 | u64 dlengsz:14; |
| 303 | |
| 304 | /** Front Data size */ |
| 305 | u64 fsz:6; |
| 306 | |
| 307 | /** Reserved2 */ |
| 308 | u64 reserved2:4; |
| 309 | |
| 310 | /** PKI port kind - PKIND */ |
| 311 | u64 pkind:6; |
| 312 | |
| 313 | /** Reserved1 */ |
| 314 | u64 reserved1:32; |
| 315 | |
| 316 | #else |
| 317 | /** Reserved1 */ |
| 318 | u64 reserved1:32; |
| 319 | |
| 320 | /** PKI port kind - PKIND */ |
| 321 | u64 pkind:6; |
| 322 | |
| 323 | /** Reserved2 */ |
| 324 | u64 reserved2:4; |
| 325 | |
| 326 | /** Front Data size */ |
| 327 | u64 fsz:6; |
| 328 | |
| 329 | /** Data length OR no. of entries in gather list */ |
| 330 | u64 dlengsz:14; |
| 331 | |
| 332 | /** Gather indicator 1=gather*/ |
| 333 | u64 gather:1; |
| 334 | |
| 335 | /** Reserved3 */ |
| 336 | u64 reserved3:1; |
| 337 | |
| 338 | #endif |
| 339 | }; |
| 340 | |
| 341 | /* Optional PKI Instruction Header(PKI IH) - for OCTEON CN23XX models */ |
| 342 | /** BIG ENDIAN format. */ |
| 343 | struct octeon_instr_pki_ih3 { |
| 344 | #ifdef __BIG_ENDIAN_BITFIELD |
| 345 | |
| 346 | /** Wider bit */ |
| 347 | u64 w:1; |
| 348 | |
| 349 | /** Raw mode indicator 1 = RAW */ |
| 350 | u64 raw:1; |
| 351 | |
| 352 | /** Use Tag */ |
| 353 | u64 utag:1; |
| 354 | |
| 355 | /** Use QPG */ |
| 356 | u64 uqpg:1; |
| 357 | |
| 358 | /** Reserved2 */ |
| 359 | u64 reserved2:1; |
| 360 | |
| 361 | /** Parse Mode */ |
| 362 | u64 pm:3; |
| 363 | |
| 364 | /** Skip Length */ |
| 365 | u64 sl:8; |
| 366 | |
| 367 | /** Use Tag Type */ |
| 368 | u64 utt:1; |
| 369 | |
| 370 | /** Tag type */ |
| 371 | u64 tagtype:2; |
| 372 | |
| 373 | /** Reserved1 */ |
| 374 | u64 reserved1:2; |
| 375 | |
| 376 | /** QPG Value */ |
| 377 | u64 qpg:11; |
| 378 | |
| 379 | /** Tag Value */ |
| 380 | u64 tag:32; |
| 381 | |
| 382 | #else |
| 383 | |
| 384 | /** Tag Value */ |
| 385 | u64 tag:32; |
| 386 | |
| 387 | /** QPG Value */ |
| 388 | u64 qpg:11; |
| 389 | |
| 390 | /** Reserved1 */ |
| 391 | u64 reserved1:2; |
| 392 | |
| 393 | /** Tag type */ |
| 394 | u64 tagtype:2; |
| 395 | |
| 396 | /** Use Tag Type */ |
| 397 | u64 utt:1; |
| 398 | |
| 399 | /** Skip Length */ |
| 400 | u64 sl:8; |
| 401 | |
| 402 | /** Parse Mode */ |
| 403 | u64 pm:3; |
| 404 | |
| 405 | /** Reserved2 */ |
| 406 | u64 reserved2:1; |
| 407 | |
| 408 | /** Use QPG */ |
| 409 | u64 uqpg:1; |
| 410 | |
| 411 | /** Use Tag */ |
| 412 | u64 utag:1; |
| 413 | |
| 414 | /** Raw mode indicator 1 = RAW */ |
| 415 | u64 raw:1; |
| 416 | |
| 417 | /** Wider bit */ |
| 418 | u64 w:1; |
| 419 | #endif |
| 420 | |
| 421 | }; |
| 422 | |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 423 | /** Instruction Header */ |
Raghu Vatsavayi | 6a885b6 | 2016-06-14 16:54:51 -0700 | [diff] [blame] | 424 | struct octeon_instr_ih2 { |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 425 | #ifdef __BIG_ENDIAN_BITFIELD |
| 426 | /** Raw mode indicator 1 = RAW */ |
| 427 | u64 raw:1; |
| 428 | |
| 429 | /** Gather indicator 1=gather*/ |
| 430 | u64 gather:1; |
| 431 | |
| 432 | /** Data length OR no. of entries in gather list */ |
| 433 | u64 dlengsz:14; |
| 434 | |
| 435 | /** Front Data size */ |
| 436 | u64 fsz:6; |
| 437 | |
| 438 | /** Packet Order / Work Unit selection (1 of 8)*/ |
| 439 | u64 qos:3; |
| 440 | |
| 441 | /** Core group selection (1 of 16) */ |
| 442 | u64 grp:4; |
| 443 | |
| 444 | /** Short Raw Packet Indicator 1=short raw pkt */ |
| 445 | u64 rs:1; |
| 446 | |
| 447 | /** Tag type */ |
| 448 | u64 tagtype:2; |
| 449 | |
| 450 | /** Tag Value */ |
| 451 | u64 tag:32; |
| 452 | #else |
| 453 | /** Tag Value */ |
| 454 | u64 tag:32; |
| 455 | |
| 456 | /** Tag type */ |
| 457 | u64 tagtype:2; |
| 458 | |
| 459 | /** Short Raw Packet Indicator 1=short raw pkt */ |
| 460 | u64 rs:1; |
| 461 | |
| 462 | /** Core group selection (1 of 16) */ |
| 463 | u64 grp:4; |
| 464 | |
| 465 | /** Packet Order / Work Unit selection (1 of 8)*/ |
| 466 | u64 qos:3; |
| 467 | |
| 468 | /** Front Data size */ |
| 469 | u64 fsz:6; |
| 470 | |
| 471 | /** Data length OR no. of entries in gather list */ |
| 472 | u64 dlengsz:14; |
| 473 | |
| 474 | /** Gather indicator 1=gather*/ |
| 475 | u64 gather:1; |
| 476 | |
| 477 | /** Raw mode indicator 1 = RAW */ |
| 478 | u64 raw:1; |
| 479 | #endif |
| 480 | }; |
| 481 | |
| 482 | /** Input Request Header */ |
| 483 | struct octeon_instr_irh { |
| 484 | #ifdef __BIG_ENDIAN_BITFIELD |
| 485 | u64 opcode:4; |
| 486 | u64 rflag:1; |
| 487 | u64 subcode:7; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 488 | u64 vlan:12; |
| 489 | u64 priority:3; |
| 490 | u64 reserved:5; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 491 | u64 ossp:32; /* opcode/subcode specific parameters */ |
| 492 | #else |
| 493 | u64 ossp:32; /* opcode/subcode specific parameters */ |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 494 | u64 reserved:5; |
| 495 | u64 priority:3; |
| 496 | u64 vlan:12; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 497 | u64 subcode:7; |
| 498 | u64 rflag:1; |
| 499 | u64 opcode:4; |
| 500 | #endif |
| 501 | }; |
| 502 | |
| 503 | /** Return Data Parameters */ |
| 504 | struct octeon_instr_rdp { |
| 505 | #ifdef __BIG_ENDIAN_BITFIELD |
| 506 | u64 reserved:49; |
| 507 | u64 pcie_port:3; |
| 508 | u64 rlen:12; |
| 509 | #else |
| 510 | u64 rlen:12; |
| 511 | u64 pcie_port:3; |
| 512 | u64 reserved:49; |
| 513 | #endif |
| 514 | }; |
| 515 | |
| 516 | /** Receive Header */ |
| 517 | union octeon_rh { |
| 518 | #ifdef __BIG_ENDIAN_BITFIELD |
| 519 | u64 u64; |
| 520 | struct { |
| 521 | u64 opcode:4; |
| 522 | u64 subcode:8; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 523 | u64 len:3; /** additional 64-bit words */ |
| 524 | u64 reserved:17; |
| 525 | u64 ossp:32; /** opcode/subcode specific parameters */ |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 526 | } r; |
| 527 | struct { |
| 528 | u64 opcode:4; |
| 529 | u64 subcode:8; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 530 | u64 len:3; /** additional 64-bit words */ |
| 531 | u64 extra:28; |
| 532 | u64 vlan:12; |
| 533 | u64 priority:3; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 534 | u64 csum_verified:3; /** checksum verified. */ |
| 535 | u64 has_hwtstamp:1; /** Has hardware timestamp. 1 = yes. */ |
| 536 | } r_dh; |
| 537 | struct { |
| 538 | u64 opcode:4; |
| 539 | u64 subcode:8; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 540 | u64 len:3; /** additional 64-bit words */ |
| 541 | u64 reserved:11; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 542 | u64 num_gmx_ports:8; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 543 | u64 max_nic_ports:10; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 544 | u64 app_cap_flags:4; |
| 545 | u64 app_mode:16; |
| 546 | } r_core_drv_init; |
| 547 | struct { |
| 548 | u64 opcode:4; |
| 549 | u64 subcode:8; |
| 550 | u64 len:3; /** additional 64-bit words */ |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 551 | u64 reserved:8; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 552 | u64 extra:25; |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 553 | u64 gmxport:16; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 554 | } r_nic_info; |
| 555 | #else |
| 556 | u64 u64; |
| 557 | struct { |
| 558 | u64 ossp:32; /** opcode/subcode specific parameters */ |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 559 | u64 reserved:17; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 560 | u64 len:3; /** additional 64-bit words */ |
| 561 | u64 subcode:8; |
| 562 | u64 opcode:4; |
| 563 | } r; |
| 564 | struct { |
| 565 | u64 has_hwtstamp:1; /** 1 = has hwtstamp */ |
| 566 | u64 csum_verified:3; /** checksum verified. */ |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 567 | u64 priority:3; |
| 568 | u64 vlan:12; |
| 569 | u64 extra:28; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 570 | u64 len:3; /** additional 64-bit words */ |
| 571 | u64 subcode:8; |
| 572 | u64 opcode:4; |
| 573 | } r_dh; |
| 574 | struct { |
| 575 | u64 app_mode:16; |
| 576 | u64 app_cap_flags:4; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 577 | u64 max_nic_ports:10; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 578 | u64 num_gmx_ports:8; |
Raghu Vatsavayi | 0da0b77 | 2016-06-21 22:53:04 -0700 | [diff] [blame] | 579 | u64 reserved:11; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 580 | u64 len:3; /** additional 64-bit words */ |
| 581 | u64 subcode:8; |
| 582 | u64 opcode:4; |
| 583 | } r_core_drv_init; |
| 584 | struct { |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 585 | u64 gmxport:16; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 586 | u64 extra:25; |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 587 | u64 reserved:8; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 588 | u64 len:3; /** additional 64-bit words */ |
| 589 | u64 subcode:8; |
| 590 | u64 opcode:4; |
| 591 | } r_nic_info; |
| 592 | #endif |
| 593 | }; |
| 594 | |
| 595 | #define OCT_RH_SIZE (sizeof(union octeon_rh)) |
| 596 | |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 597 | union octnic_packet_params { |
| 598 | u32 u32; |
| 599 | struct { |
| 600 | #ifdef __BIG_ENDIAN_BITFIELD |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 601 | u32 reserved:24; |
Raghu Vatsavayi | 7275ebf | 2016-06-14 16:54:49 -0700 | [diff] [blame] | 602 | u32 ip_csum:1; /* Perform IP header checksum(s) */ |
| 603 | /* Perform Outer transport header checksum */ |
| 604 | u32 transport_csum:1; |
| 605 | /* Find tunnel, and perform transport csum. */ |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 606 | u32 tnl_csum:1; |
Raghu Vatsavayi | 7275ebf | 2016-06-14 16:54:49 -0700 | [diff] [blame] | 607 | u32 tsflag:1; /* Timestamp this packet */ |
| 608 | u32 ipsec_ops:4; /* IPsec operation */ |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 609 | #else |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 610 | u32 ipsec_ops:4; |
Raghu Vatsavayi | 7275ebf | 2016-06-14 16:54:49 -0700 | [diff] [blame] | 611 | u32 tsflag:1; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 612 | u32 tnl_csum:1; |
Raghu Vatsavayi | 7275ebf | 2016-06-14 16:54:49 -0700 | [diff] [blame] | 613 | u32 transport_csum:1; |
| 614 | u32 ip_csum:1; |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 615 | u32 reserved:24; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 616 | #endif |
| 617 | } s; |
| 618 | }; |
| 619 | |
| 620 | /** Status of a RGMII Link on Octeon as seen by core driver. */ |
| 621 | union oct_link_status { |
| 622 | u64 u64; |
| 623 | |
| 624 | struct { |
| 625 | #ifdef __BIG_ENDIAN_BITFIELD |
| 626 | u64 duplex:8; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 627 | u64 mtu:16; |
| 628 | u64 speed:16; |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 629 | u64 link_up:1; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 630 | u64 autoneg:1; |
| 631 | u64 interface:4; |
| 632 | u64 pause:1; |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 633 | u64 reserved:17; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 634 | #else |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 635 | u64 reserved:17; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 636 | u64 pause:1; |
| 637 | u64 interface:4; |
| 638 | u64 autoneg:1; |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 639 | u64 link_up:1; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 640 | u64 speed:16; |
| 641 | u64 mtu:16; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 642 | u64 duplex:8; |
| 643 | #endif |
| 644 | } s; |
| 645 | }; |
| 646 | |
Raghu Vatsavayi | 26236fa | 2016-06-14 16:54:44 -0700 | [diff] [blame] | 647 | /** The txpciq info passed to host from the firmware */ |
| 648 | |
| 649 | union oct_txpciq { |
| 650 | u64 u64; |
| 651 | |
| 652 | struct { |
| 653 | #ifdef __BIG_ENDIAN_BITFIELD |
| 654 | u64 q_no:8; |
| 655 | u64 port:8; |
| 656 | u64 pkind:6; |
| 657 | u64 use_qpg:1; |
| 658 | u64 qpg:11; |
| 659 | u64 reserved:30; |
| 660 | #else |
| 661 | u64 reserved:30; |
| 662 | u64 qpg:11; |
| 663 | u64 use_qpg:1; |
| 664 | u64 pkind:6; |
| 665 | u64 port:8; |
| 666 | u64 q_no:8; |
| 667 | #endif |
| 668 | } s; |
| 669 | }; |
| 670 | |
| 671 | /** The rxpciq info passed to host from the firmware */ |
| 672 | |
| 673 | union oct_rxpciq { |
| 674 | u64 u64; |
| 675 | |
| 676 | struct { |
| 677 | #ifdef __BIG_ENDIAN_BITFIELD |
| 678 | u64 q_no:8; |
| 679 | u64 reserved:56; |
| 680 | #else |
| 681 | u64 reserved:56; |
| 682 | u64 q_no:8; |
| 683 | #endif |
| 684 | } s; |
| 685 | }; |
| 686 | |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 687 | /** Information for a OCTEON ethernet interface shared between core & host. */ |
| 688 | struct oct_link_info { |
| 689 | union oct_link_status link; |
| 690 | u64 hw_addr; |
| 691 | |
| 692 | #ifdef __BIG_ENDIAN_BITFIELD |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 693 | u64 gmxport:16; |
| 694 | u64 rsvd:32; |
| 695 | u64 num_txpciq:8; |
| 696 | u64 num_rxpciq:8; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 697 | #else |
Raghu Vatsavayi | 0cece6c | 2016-06-14 16:54:50 -0700 | [diff] [blame] | 698 | u64 num_rxpciq:8; |
| 699 | u64 num_txpciq:8; |
| 700 | u64 rsvd:32; |
| 701 | u64 gmxport:16; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 702 | #endif |
| 703 | |
Raghu Vatsavayi | 26236fa | 2016-06-14 16:54:44 -0700 | [diff] [blame] | 704 | union oct_txpciq txpciq[MAX_IOQS_PER_NICIF]; |
| 705 | union oct_rxpciq rxpciq[MAX_IOQS_PER_NICIF]; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 706 | }; |
| 707 | |
| 708 | #define OCT_LINK_INFO_SIZE (sizeof(struct oct_link_info)) |
| 709 | |
| 710 | struct liquidio_if_cfg_info { |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 711 | u64 iqmask; /** mask for IQs enabled for the port */ |
| 712 | u64 oqmask; /** mask for OQs enabled for the port */ |
| 713 | struct oct_link_info linfo; /** initial link information */ |
Raghu Vatsavayi | d3d7e6c | 2016-06-21 22:53:07 -0700 | [diff] [blame] | 714 | char liquidio_firmware_version[32]; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 715 | }; |
| 716 | |
| 717 | /** Stats for each NIC port in RX direction. */ |
| 718 | struct nic_rx_stats { |
| 719 | /* link-level stats */ |
| 720 | u64 total_rcvd; |
| 721 | u64 bytes_rcvd; |
| 722 | u64 total_bcst; |
| 723 | u64 total_mcst; |
| 724 | u64 runts; |
| 725 | u64 ctl_rcvd; |
| 726 | u64 fifo_err; /* Accounts for over/under-run of buffers */ |
| 727 | u64 dmac_drop; |
| 728 | u64 fcs_err; |
| 729 | u64 jabber_err; |
| 730 | u64 l2_err; |
| 731 | u64 frame_err; |
| 732 | |
| 733 | /* firmware stats */ |
| 734 | u64 fw_total_rcvd; |
| 735 | u64 fw_total_fwd; |
| 736 | u64 fw_err_pko; |
| 737 | u64 fw_err_link; |
| 738 | u64 fw_err_drop; |
| 739 | u64 fw_lro_pkts; /* Number of packets that are LROed */ |
| 740 | u64 fw_lro_octs; /* Number of octets that are LROed */ |
| 741 | u64 fw_total_lro; /* Number of LRO packets formed */ |
| 742 | u64 fw_lro_aborts; /* Number of times lRO of packet aborted */ |
| 743 | /* intrmod: packet forward rate */ |
| 744 | u64 fwd_rate; |
| 745 | }; |
| 746 | |
| 747 | /** Stats for each NIC port in RX direction. */ |
| 748 | struct nic_tx_stats { |
| 749 | /* link-level stats */ |
| 750 | u64 total_pkts_sent; |
| 751 | u64 total_bytes_sent; |
| 752 | u64 mcast_pkts_sent; |
| 753 | u64 bcast_pkts_sent; |
| 754 | u64 ctl_sent; |
| 755 | u64 one_collision_sent; /* Packets sent after one collision*/ |
| 756 | u64 multi_collision_sent; /* Packets sent after multiple collision*/ |
| 757 | u64 max_collision_fail; /* Packets not sent due to max collisions */ |
| 758 | u64 max_deferral_fail; /* Packets not sent due to max deferrals */ |
| 759 | u64 fifo_err; /* Accounts for over/under-run of buffers */ |
| 760 | u64 runts; |
| 761 | u64 total_collisions; /* Total number of collisions detected */ |
| 762 | |
| 763 | /* firmware stats */ |
| 764 | u64 fw_total_sent; |
| 765 | u64 fw_total_fwd; |
| 766 | u64 fw_err_pko; |
| 767 | u64 fw_err_link; |
| 768 | u64 fw_err_drop; |
| 769 | }; |
| 770 | |
| 771 | struct oct_link_stats { |
| 772 | struct nic_rx_stats fromwire; |
| 773 | struct nic_tx_stats fromhost; |
| 774 | |
| 775 | }; |
| 776 | |
| 777 | #define LIO68XX_LED_CTRL_ADDR 0x3501 |
| 778 | #define LIO68XX_LED_CTRL_CFGON 0x1f |
| 779 | #define LIO68XX_LED_CTRL_CFGOFF 0x100 |
| 780 | #define LIO68XX_LED_BEACON_ADDR 0x3508 |
| 781 | #define LIO68XX_LED_BEACON_CFGON 0x47fd |
| 782 | #define LIO68XX_LED_BEACON_CFGOFF 0x11fc |
| 783 | #define VITESSE_PHY_GPIO_DRIVEON 0x1 |
| 784 | #define VITESSE_PHY_GPIO_CFG 0x8 |
| 785 | #define VITESSE_PHY_GPIO_DRIVEOFF 0x4 |
| 786 | #define VITESSE_PHY_GPIO_HIGH 0x2 |
| 787 | #define VITESSE_PHY_GPIO_LOW 0x3 |
| 788 | |
| 789 | struct oct_mdio_cmd { |
| 790 | u64 op; |
| 791 | u64 mdio_addr; |
| 792 | u64 value1; |
| 793 | u64 value2; |
| 794 | u64 value3; |
| 795 | }; |
| 796 | |
| 797 | #define OCT_LINK_STATS_SIZE (sizeof(struct oct_link_stats)) |
| 798 | |
Raghu Vatsavayi | 78e6a9b | 2016-06-21 22:53:10 -0700 | [diff] [blame^] | 799 | /* intrmod: max. packet rate threshold */ |
| 800 | #define LIO_INTRMOD_MAXPKT_RATETHR 196608 |
| 801 | /* intrmod: min. packet rate threshold */ |
| 802 | #define LIO_INTRMOD_MINPKT_RATETHR 9216 |
| 803 | /* intrmod: max. packets to trigger interrupt */ |
| 804 | #define LIO_INTRMOD_RXMAXCNT_TRIGGER 384 |
| 805 | /* intrmod: min. packets to trigger interrupt */ |
| 806 | #define LIO_INTRMOD_RXMINCNT_TRIGGER 1 |
| 807 | /* intrmod: max. time to trigger interrupt */ |
| 808 | #define LIO_INTRMOD_RXMAXTMR_TRIGGER 128 |
| 809 | /* 66xx:intrmod: min. time to trigger interrupt |
| 810 | * (value of 1 is optimum for TCP_RR) |
| 811 | */ |
| 812 | #define LIO_INTRMOD_RXMINTMR_TRIGGER 1 |
| 813 | |
| 814 | /* intrmod: max. packets to trigger interrupt */ |
| 815 | #define LIO_INTRMOD_TXMAXCNT_TRIGGER 64 |
| 816 | /* intrmod: min. packets to trigger interrupt */ |
| 817 | #define LIO_INTRMOD_TXMINCNT_TRIGGER 0 |
| 818 | |
| 819 | /* intrmod: poll interval in seconds */ |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 820 | #define LIO_INTRMOD_CHECK_INTERVAL 1 |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 821 | |
| 822 | struct oct_intrmod_cfg { |
Raghu Vatsavayi | 78e6a9b | 2016-06-21 22:53:10 -0700 | [diff] [blame^] | 823 | u64 rx_enable; |
| 824 | u64 tx_enable; |
| 825 | u64 check_intrvl; |
| 826 | u64 maxpkt_ratethr; |
| 827 | u64 minpkt_ratethr; |
| 828 | u64 rx_maxcnt_trigger; |
| 829 | u64 rx_mincnt_trigger; |
| 830 | u64 rx_maxtmr_trigger; |
| 831 | u64 rx_mintmr_trigger; |
| 832 | u64 tx_mincnt_trigger; |
| 833 | u64 tx_maxcnt_trigger; |
| 834 | u64 rx_frames; |
| 835 | u64 tx_frames; |
| 836 | u64 rx_usecs; |
Raghu Vatsavayi | f21fb3e | 2015-06-09 18:15:23 -0700 | [diff] [blame] | 837 | }; |
| 838 | |
| 839 | #define BASE_QUEUE_NOT_REQUESTED 65535 |
| 840 | |
| 841 | union oct_nic_if_cfg { |
| 842 | u64 u64; |
| 843 | struct { |
| 844 | #ifdef __BIG_ENDIAN_BITFIELD |
| 845 | u64 base_queue:16; |
| 846 | u64 num_iqueues:16; |
| 847 | u64 num_oqueues:16; |
| 848 | u64 gmx_port_id:8; |
| 849 | u64 reserved:8; |
| 850 | #else |
| 851 | u64 reserved:8; |
| 852 | u64 gmx_port_id:8; |
| 853 | u64 num_oqueues:16; |
| 854 | u64 num_iqueues:16; |
| 855 | u64 base_queue:16; |
| 856 | #endif |
| 857 | } s; |
| 858 | }; |
| 859 | |
| 860 | #endif |