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