1 /* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) OR BSD-2-Clause */ 2 /* Copyright (c) 2017-2020 Pensando Systems, Inc. All rights reserved. */ 3 4 #ifndef _IONIC_IF_H_ 5 #define _IONIC_IF_H_ 6 7 #define IONIC_DEV_INFO_SIGNATURE 0x44455649 /* 'DEVI' */ 8 #define IONIC_DEV_INFO_VERSION 1 9 #define IONIC_IFNAMSIZ 16 10 11 /** 12 * enum ionic_cmd_opcode - Device commands 13 */ 14 enum ionic_cmd_opcode { 15 IONIC_CMD_NOP = 0, 16 17 /* Device commands */ 18 IONIC_CMD_IDENTIFY = 1, 19 IONIC_CMD_INIT = 2, 20 IONIC_CMD_RESET = 3, 21 IONIC_CMD_GETATTR = 4, 22 IONIC_CMD_SETATTR = 5, 23 24 /* Port commands */ 25 IONIC_CMD_PORT_IDENTIFY = 10, 26 IONIC_CMD_PORT_INIT = 11, 27 IONIC_CMD_PORT_RESET = 12, 28 IONIC_CMD_PORT_GETATTR = 13, 29 IONIC_CMD_PORT_SETATTR = 14, 30 31 /* LIF commands */ 32 IONIC_CMD_LIF_IDENTIFY = 20, 33 IONIC_CMD_LIF_INIT = 21, 34 IONIC_CMD_LIF_RESET = 22, 35 IONIC_CMD_LIF_GETATTR = 23, 36 IONIC_CMD_LIF_SETATTR = 24, 37 38 IONIC_CMD_RX_MODE_SET = 30, 39 IONIC_CMD_RX_FILTER_ADD = 31, 40 IONIC_CMD_RX_FILTER_DEL = 32, 41 42 /* Queue commands */ 43 IONIC_CMD_Q_IDENTIFY = 39, 44 IONIC_CMD_Q_INIT = 40, 45 IONIC_CMD_Q_CONTROL = 41, 46 47 /* RDMA commands */ 48 IONIC_CMD_RDMA_RESET_LIF = 50, 49 IONIC_CMD_RDMA_CREATE_EQ = 51, 50 IONIC_CMD_RDMA_CREATE_CQ = 52, 51 IONIC_CMD_RDMA_CREATE_ADMINQ = 53, 52 53 /* SR/IOV commands */ 54 IONIC_CMD_VF_GETATTR = 60, 55 IONIC_CMD_VF_SETATTR = 61, 56 57 /* QoS commands */ 58 IONIC_CMD_QOS_CLASS_IDENTIFY = 240, 59 IONIC_CMD_QOS_CLASS_INIT = 241, 60 IONIC_CMD_QOS_CLASS_RESET = 242, 61 IONIC_CMD_QOS_CLASS_UPDATE = 243, 62 IONIC_CMD_QOS_CLEAR_STATS = 244, 63 IONIC_CMD_QOS_RESET = 245, 64 65 /* Firmware commands */ 66 IONIC_CMD_FW_DOWNLOAD = 252, 67 IONIC_CMD_FW_CONTROL = 253, 68 IONIC_CMD_FW_DOWNLOAD_V1 = 254, 69 IONIC_CMD_FW_CONTROL_V1 = 255, 70 }; 71 72 /** 73 * enum ionic_status_code - Device command return codes 74 */ 75 enum ionic_status_code { 76 IONIC_RC_SUCCESS = 0, /* Success */ 77 IONIC_RC_EVERSION = 1, /* Incorrect version for request */ 78 IONIC_RC_EOPCODE = 2, /* Invalid cmd opcode */ 79 IONIC_RC_EIO = 3, /* I/O error */ 80 IONIC_RC_EPERM = 4, /* Permission denied */ 81 IONIC_RC_EQID = 5, /* Bad qid */ 82 IONIC_RC_EQTYPE = 6, /* Bad qtype */ 83 IONIC_RC_ENOENT = 7, /* No such element */ 84 IONIC_RC_EINTR = 8, /* operation interrupted */ 85 IONIC_RC_EAGAIN = 9, /* Try again */ 86 IONIC_RC_ENOMEM = 10, /* Out of memory */ 87 IONIC_RC_EFAULT = 11, /* Bad address */ 88 IONIC_RC_EBUSY = 12, /* Device or resource busy */ 89 IONIC_RC_EEXIST = 13, /* object already exists */ 90 IONIC_RC_EINVAL = 14, /* Invalid argument */ 91 IONIC_RC_ENOSPC = 15, /* No space left or alloc failure */ 92 IONIC_RC_ERANGE = 16, /* Parameter out of range */ 93 IONIC_RC_BAD_ADDR = 17, /* Descriptor contains a bad ptr */ 94 IONIC_RC_DEV_CMD = 18, /* Device cmd attempted on AdminQ */ 95 IONIC_RC_ENOSUPP = 19, /* Operation not supported */ 96 IONIC_RC_ERROR = 29, /* Generic error */ 97 IONIC_RC_ERDMA = 30, /* Generic RDMA error */ 98 IONIC_RC_EVFID = 31, /* VF ID does not exist */ 99 IONIC_RC_EBAD_FW = 32, /* FW file is invalid or corrupted */ 100 }; 101 102 enum ionic_notifyq_opcode { 103 IONIC_EVENT_LINK_CHANGE = 1, 104 IONIC_EVENT_RESET = 2, 105 IONIC_EVENT_HEARTBEAT = 3, 106 IONIC_EVENT_LOG = 4, 107 IONIC_EVENT_XCVR = 5, 108 }; 109 110 /** 111 * struct ionic_admin_cmd - General admin command format 112 * @opcode: Opcode for the command 113 * @lif_index: LIF index 114 * @cmd_data: Opcode-specific command bytes 115 */ 116 struct ionic_admin_cmd { 117 u8 opcode; 118 u8 rsvd; 119 __le16 lif_index; 120 u8 cmd_data[60]; 121 }; 122 123 /** 124 * struct ionic_admin_comp - General admin command completion format 125 * @status: Status of the command (enum ionic_status_code) 126 * @comp_index: Index in the descriptor ring for which this is the completion 127 * @cmd_data: Command-specific bytes 128 * @color: Color bit (Always 0 for commands issued to the 129 * Device Cmd Registers) 130 */ 131 struct ionic_admin_comp { 132 u8 status; 133 u8 rsvd; 134 __le16 comp_index; 135 u8 cmd_data[11]; 136 u8 color; 137 #define IONIC_COMP_COLOR_MASK 0x80 138 }; 139 140 static inline u8 color_match(u8 color, u8 done_color) 141 { 142 return (!!(color & IONIC_COMP_COLOR_MASK)) == done_color; 143 } 144 145 /** 146 * struct ionic_nop_cmd - NOP command 147 * @opcode: opcode 148 */ 149 struct ionic_nop_cmd { 150 u8 opcode; 151 u8 rsvd[63]; 152 }; 153 154 /** 155 * struct ionic_nop_comp - NOP command completion 156 * @status: Status of the command (enum ionic_status_code) 157 */ 158 struct ionic_nop_comp { 159 u8 status; 160 u8 rsvd[15]; 161 }; 162 163 /** 164 * struct ionic_dev_init_cmd - Device init command 165 * @opcode: opcode 166 * @type: Device type 167 */ 168 struct ionic_dev_init_cmd { 169 u8 opcode; 170 u8 type; 171 u8 rsvd[62]; 172 }; 173 174 /** 175 * struct ionic_dev_init_comp - Device init command completion 176 * @status: Status of the command (enum ionic_status_code) 177 */ 178 struct ionic_dev_init_comp { 179 u8 status; 180 u8 rsvd[15]; 181 }; 182 183 /** 184 * struct ionic_dev_reset_cmd - Device reset command 185 * @opcode: opcode 186 */ 187 struct ionic_dev_reset_cmd { 188 u8 opcode; 189 u8 rsvd[63]; 190 }; 191 192 /** 193 * struct ionic_dev_reset_comp - Reset command completion 194 * @status: Status of the command (enum ionic_status_code) 195 */ 196 struct ionic_dev_reset_comp { 197 u8 status; 198 u8 rsvd[15]; 199 }; 200 201 #define IONIC_IDENTITY_VERSION_1 1 202 203 /** 204 * struct ionic_dev_identify_cmd - Driver/device identify command 205 * @opcode: opcode 206 * @ver: Highest version of identify supported by driver 207 */ 208 struct ionic_dev_identify_cmd { 209 u8 opcode; 210 u8 ver; 211 u8 rsvd[62]; 212 }; 213 214 /** 215 * struct ionic_dev_identify_comp - Driver/device identify command completion 216 * @status: Status of the command (enum ionic_status_code) 217 * @ver: Version of identify returned by device 218 */ 219 struct ionic_dev_identify_comp { 220 u8 status; 221 u8 ver; 222 u8 rsvd[14]; 223 }; 224 225 enum ionic_os_type { 226 IONIC_OS_TYPE_LINUX = 1, 227 IONIC_OS_TYPE_WIN = 2, 228 IONIC_OS_TYPE_DPDK = 3, 229 IONIC_OS_TYPE_FREEBSD = 4, 230 IONIC_OS_TYPE_IPXE = 5, 231 IONIC_OS_TYPE_ESXI = 6, 232 }; 233 234 /** 235 * union ionic_drv_identity - driver identity information 236 * @os_type: OS type (see enum ionic_os_type) 237 * @os_dist: OS distribution, numeric format 238 * @os_dist_str: OS distribution, string format 239 * @kernel_ver: Kernel version, numeric format 240 * @kernel_ver_str: Kernel version, string format 241 * @driver_ver_str: Driver version, string format 242 */ 243 union ionic_drv_identity { 244 struct { 245 __le32 os_type; 246 __le32 os_dist; 247 char os_dist_str[128]; 248 __le32 kernel_ver; 249 char kernel_ver_str[32]; 250 char driver_ver_str[32]; 251 }; 252 __le32 words[478]; 253 }; 254 255 /** 256 * union ionic_dev_identity - device identity information 257 * @version: Version of device identify 258 * @type: Identify type (0 for now) 259 * @nports: Number of ports provisioned 260 * @nlifs: Number of LIFs provisioned 261 * @nintrs: Number of interrupts provisioned 262 * @ndbpgs_per_lif: Number of doorbell pages per LIF 263 * @intr_coal_mult: Interrupt coalescing multiplication factor 264 * Scale user-supplied interrupt coalescing 265 * value in usecs to device units using: 266 * device units = usecs * mult / div 267 * @intr_coal_div: Interrupt coalescing division factor 268 * Scale user-supplied interrupt coalescing 269 * value in usecs to device units using: 270 * device units = usecs * mult / div 271 * @eq_count: Number of shared event queues 272 */ 273 union ionic_dev_identity { 274 struct { 275 u8 version; 276 u8 type; 277 u8 rsvd[2]; 278 u8 nports; 279 u8 rsvd2[3]; 280 __le32 nlifs; 281 __le32 nintrs; 282 __le32 ndbpgs_per_lif; 283 __le32 intr_coal_mult; 284 __le32 intr_coal_div; 285 __le32 eq_count; 286 }; 287 __le32 words[478]; 288 }; 289 290 enum ionic_lif_type { 291 IONIC_LIF_TYPE_CLASSIC = 0, 292 IONIC_LIF_TYPE_MACVLAN = 1, 293 IONIC_LIF_TYPE_NETQUEUE = 2, 294 }; 295 296 /** 297 * struct ionic_lif_identify_cmd - LIF identify command 298 * @opcode: opcode 299 * @type: LIF type (enum ionic_lif_type) 300 * @ver: Version of identify returned by device 301 */ 302 struct ionic_lif_identify_cmd { 303 u8 opcode; 304 u8 type; 305 u8 ver; 306 u8 rsvd[61]; 307 }; 308 309 /** 310 * struct ionic_lif_identify_comp - LIF identify command completion 311 * @status: Status of the command (enum ionic_status_code) 312 * @ver: Version of identify returned by device 313 */ 314 struct ionic_lif_identify_comp { 315 u8 status; 316 u8 ver; 317 u8 rsvd2[14]; 318 }; 319 320 /** 321 * enum ionic_lif_capability - LIF capabilities 322 * @IONIC_LIF_CAP_ETH: LIF supports Ethernet 323 * @IONIC_LIF_CAP_RDMA: LIF supports RDMA 324 */ 325 enum ionic_lif_capability { 326 IONIC_LIF_CAP_ETH = BIT(0), 327 IONIC_LIF_CAP_RDMA = BIT(1), 328 }; 329 330 /** 331 * enum ionic_logical_qtype - Logical Queue Types 332 * @IONIC_QTYPE_ADMINQ: Administrative Queue 333 * @IONIC_QTYPE_NOTIFYQ: Notify Queue 334 * @IONIC_QTYPE_RXQ: Receive Queue 335 * @IONIC_QTYPE_TXQ: Transmit Queue 336 * @IONIC_QTYPE_EQ: Event Queue 337 * @IONIC_QTYPE_MAX: Max queue type supported 338 */ 339 enum ionic_logical_qtype { 340 IONIC_QTYPE_ADMINQ = 0, 341 IONIC_QTYPE_NOTIFYQ = 1, 342 IONIC_QTYPE_RXQ = 2, 343 IONIC_QTYPE_TXQ = 3, 344 IONIC_QTYPE_EQ = 4, 345 IONIC_QTYPE_MAX = 16, 346 }; 347 348 /** 349 * struct ionic_lif_logical_qtype - Descriptor of logical to HW queue type 350 * @qtype: Hardware Queue Type 351 * @qid_count: Number of Queue IDs of the logical type 352 * @qid_base: Minimum Queue ID of the logical type 353 */ 354 struct ionic_lif_logical_qtype { 355 u8 qtype; 356 u8 rsvd[3]; 357 __le32 qid_count; 358 __le32 qid_base; 359 }; 360 361 /** 362 * enum ionic_lif_state - LIF state 363 * @IONIC_LIF_DISABLE: LIF disabled 364 * @IONIC_LIF_ENABLE: LIF enabled 365 * @IONIC_LIF_QUIESCE: LIF Quiesced 366 */ 367 enum ionic_lif_state { 368 IONIC_LIF_QUIESCE = 0, 369 IONIC_LIF_ENABLE = 1, 370 IONIC_LIF_DISABLE = 2, 371 }; 372 373 /** 374 * union ionic_lif_config - LIF configuration 375 * @state: LIF state (enum ionic_lif_state) 376 * @name: LIF name 377 * @mtu: MTU 378 * @mac: Station MAC address 379 * @vlan: Default Vlan ID 380 * @features: Features (enum ionic_eth_hw_features) 381 * @queue_count: Queue counts per queue-type 382 */ 383 union ionic_lif_config { 384 struct { 385 u8 state; 386 u8 rsvd[3]; 387 char name[IONIC_IFNAMSIZ]; 388 __le32 mtu; 389 u8 mac[6]; 390 __le16 vlan; 391 __le64 features; 392 __le32 queue_count[IONIC_QTYPE_MAX]; 393 } __packed; 394 __le32 words[64]; 395 }; 396 397 /** 398 * struct ionic_lif_identity - LIF identity information (type-specific) 399 * 400 * @capabilities: LIF capabilities 401 * 402 * @eth: Ethernet identify structure 403 * @version: Ethernet identify structure version 404 * @max_ucast_filters: Number of perfect unicast addresses supported 405 * @max_mcast_filters: Number of perfect multicast addresses supported 406 * @min_frame_size: Minimum size of frames to be sent 407 * @max_frame_size: Maximum size of frames to be sent 408 * @config: LIF config struct with features, mtu, mac, q counts 409 * 410 * @rdma: RDMA identify structure 411 * @version: RDMA version of opcodes and queue descriptors 412 * @qp_opcodes: Number of RDMA queue pair opcodes supported 413 * @admin_opcodes: Number of RDMA admin opcodes supported 414 * @npts_per_lif: Page table size per LIF 415 * @nmrs_per_lif: Number of memory regions per LIF 416 * @nahs_per_lif: Number of address handles per LIF 417 * @max_stride: Max work request stride 418 * @cl_stride: Cache line stride 419 * @pte_stride: Page table entry stride 420 * @rrq_stride: Remote RQ work request stride 421 * @rsq_stride: Remote SQ work request stride 422 * @dcqcn_profiles: Number of DCQCN profiles 423 * @aq_qtype: RDMA Admin Qtype 424 * @sq_qtype: RDMA Send Qtype 425 * @rq_qtype: RDMA Receive Qtype 426 * @cq_qtype: RDMA Completion Qtype 427 * @eq_qtype: RDMA Event Qtype 428 */ 429 union ionic_lif_identity { 430 struct { 431 __le64 capabilities; 432 433 struct { 434 u8 version; 435 u8 rsvd[3]; 436 __le32 max_ucast_filters; 437 __le32 max_mcast_filters; 438 __le16 rss_ind_tbl_sz; 439 __le32 min_frame_size; 440 __le32 max_frame_size; 441 u8 rsvd2[106]; 442 union ionic_lif_config config; 443 } __packed eth; 444 445 struct { 446 u8 version; 447 u8 qp_opcodes; 448 u8 admin_opcodes; 449 u8 rsvd; 450 __le32 npts_per_lif; 451 __le32 nmrs_per_lif; 452 __le32 nahs_per_lif; 453 u8 max_stride; 454 u8 cl_stride; 455 u8 pte_stride; 456 u8 rrq_stride; 457 u8 rsq_stride; 458 u8 dcqcn_profiles; 459 u8 rsvd_dimensions[10]; 460 struct ionic_lif_logical_qtype aq_qtype; 461 struct ionic_lif_logical_qtype sq_qtype; 462 struct ionic_lif_logical_qtype rq_qtype; 463 struct ionic_lif_logical_qtype cq_qtype; 464 struct ionic_lif_logical_qtype eq_qtype; 465 } __packed rdma; 466 } __packed; 467 __le32 words[478]; 468 }; 469 470 /** 471 * struct ionic_lif_init_cmd - LIF init command 472 * @opcode: Opcode 473 * @type: LIF type (enum ionic_lif_type) 474 * @index: LIF index 475 * @info_pa: Destination address for LIF info (struct ionic_lif_info) 476 */ 477 struct ionic_lif_init_cmd { 478 u8 opcode; 479 u8 type; 480 __le16 index; 481 __le32 rsvd; 482 __le64 info_pa; 483 u8 rsvd2[48]; 484 }; 485 486 /** 487 * struct ionic_lif_init_comp - LIF init command completion 488 * @status: Status of the command (enum ionic_status_code) 489 * @hw_index: Hardware index of the initialized LIF 490 */ 491 struct ionic_lif_init_comp { 492 u8 status; 493 u8 rsvd; 494 __le16 hw_index; 495 u8 rsvd2[12]; 496 }; 497 498 /** 499 * struct ionic_q_identify_cmd - queue identify command 500 * @opcode: opcode 501 * @lif_type: LIF type (enum ionic_lif_type) 502 * @type: Logical queue type (enum ionic_logical_qtype) 503 * @ver: Highest queue type version that the driver supports 504 */ 505 struct ionic_q_identify_cmd { 506 u8 opcode; 507 u8 rsvd; 508 __le16 lif_type; 509 u8 type; 510 u8 ver; 511 u8 rsvd2[58]; 512 }; 513 514 /** 515 * struct ionic_q_identify_comp - queue identify command completion 516 * @status: Status of the command (enum ionic_status_code) 517 * @comp_index: Index in the descriptor ring for which this is the completion 518 * @ver: Queue type version that can be used with FW 519 */ 520 struct ionic_q_identify_comp { 521 u8 status; 522 u8 rsvd; 523 __le16 comp_index; 524 u8 ver; 525 u8 rsvd2[11]; 526 }; 527 528 /** 529 * union ionic_q_identity - queue identity information 530 * @version: Queue type version that can be used with FW 531 * @supported: Bitfield of queue versions, first bit = ver 0 532 * @features: Queue features 533 * @desc_sz: Descriptor size 534 * @comp_sz: Completion descriptor size 535 * @sg_desc_sz: Scatter/Gather descriptor size 536 * @max_sg_elems: Maximum number of Scatter/Gather elements 537 * @sg_desc_stride: Number of Scatter/Gather elements per descriptor 538 */ 539 union ionic_q_identity { 540 struct { 541 u8 version; 542 u8 supported; 543 u8 rsvd[6]; 544 #define IONIC_QIDENT_F_CQ 0x01 /* queue has completion ring */ 545 #define IONIC_QIDENT_F_SG 0x02 /* queue has scatter/gather ring */ 546 #define IONIC_QIDENT_F_EQ 0x04 /* queue can use event queue */ 547 #define IONIC_QIDENT_F_CMB 0x08 /* queue is in cmb bar */ 548 __le64 features; 549 __le16 desc_sz; 550 __le16 comp_sz; 551 __le16 sg_desc_sz; 552 __le16 max_sg_elems; 553 __le16 sg_desc_stride; 554 }; 555 __le32 words[478]; 556 }; 557 558 /** 559 * struct ionic_q_init_cmd - Queue init command 560 * @opcode: opcode 561 * @type: Logical queue type 562 * @ver: Queue type version 563 * @lif_index: LIF index 564 * @index: (LIF, qtype) relative admin queue index 565 * @intr_index: Interrupt control register index, or Event queue index 566 * @pid: Process ID 567 * @flags: 568 * IRQ: Interrupt requested on completion 569 * ENA: Enable the queue. If ENA=0 the queue is initialized 570 * but remains disabled, to be later enabled with the 571 * Queue Enable command. If ENA=1, then queue is 572 * initialized and then enabled. 573 * SG: Enable Scatter-Gather on the queue. 574 * in number of descs. The actual ring size is 575 * (1 << ring_size). For example, to 576 * select a ring size of 64 descriptors write 577 * ring_size = 6. The minimum ring_size value is 2 578 * for a ring size of 4 descriptors. The maximum 579 * ring_size value is 16 for a ring size of 64k 580 * descriptors. Values of ring_size <2 and >16 are 581 * reserved. 582 * EQ: Enable the Event Queue 583 * @cos: Class of service for this queue 584 * @ring_size: Queue ring size, encoded as a log2(size) 585 * @ring_base: Queue ring base address 586 * @cq_ring_base: Completion queue ring base address 587 * @sg_ring_base: Scatter/Gather ring base address 588 */ 589 struct ionic_q_init_cmd { 590 u8 opcode; 591 u8 rsvd; 592 __le16 lif_index; 593 u8 type; 594 u8 ver; 595 u8 rsvd1[2]; 596 __le32 index; 597 __le16 pid; 598 __le16 intr_index; 599 __le16 flags; 600 #define IONIC_QINIT_F_IRQ 0x01 /* Request interrupt on completion */ 601 #define IONIC_QINIT_F_ENA 0x02 /* Enable the queue */ 602 #define IONIC_QINIT_F_SG 0x04 /* Enable scatter/gather on the queue */ 603 #define IONIC_QINIT_F_EQ 0x08 /* Enable event queue */ 604 #define IONIC_QINIT_F_CMB 0x10 /* Enable cmb-based queue */ 605 #define IONIC_QINIT_F_DEBUG 0x80 /* Enable queue debugging */ 606 u8 cos; 607 u8 ring_size; 608 __le64 ring_base; 609 __le64 cq_ring_base; 610 __le64 sg_ring_base; 611 u8 rsvd2[20]; 612 } __packed; 613 614 /** 615 * struct ionic_q_init_comp - Queue init command completion 616 * @status: Status of the command (enum ionic_status_code) 617 * @comp_index: Index in the descriptor ring for which this is the completion 618 * @hw_index: Hardware Queue ID 619 * @hw_type: Hardware Queue type 620 * @color: Color 621 */ 622 struct ionic_q_init_comp { 623 u8 status; 624 u8 rsvd; 625 __le16 comp_index; 626 __le32 hw_index; 627 u8 hw_type; 628 u8 rsvd2[6]; 629 u8 color; 630 }; 631 632 /* the device's internal addressing uses up to 52 bits */ 633 #define IONIC_ADDR_LEN 52 634 #define IONIC_ADDR_MASK (BIT_ULL(IONIC_ADDR_LEN) - 1) 635 636 enum ionic_txq_desc_opcode { 637 IONIC_TXQ_DESC_OPCODE_CSUM_NONE = 0, 638 IONIC_TXQ_DESC_OPCODE_CSUM_PARTIAL = 1, 639 IONIC_TXQ_DESC_OPCODE_CSUM_HW = 2, 640 IONIC_TXQ_DESC_OPCODE_TSO = 3, 641 }; 642 643 /** 644 * struct ionic_txq_desc - Ethernet Tx queue descriptor format 645 * @cmd: Tx operation, see IONIC_TXQ_DESC_OPCODE_*: 646 * 647 * IONIC_TXQ_DESC_OPCODE_CSUM_NONE: 648 * Non-offload send. No segmentation, 649 * fragmentation or checksum calc/insertion is 650 * performed by device; packet is prepared 651 * to send by software stack and requires 652 * no further manipulation from device. 653 * 654 * IONIC_TXQ_DESC_OPCODE_CSUM_PARTIAL: 655 * Offload 16-bit L4 checksum 656 * calculation/insertion. The device will 657 * calculate the L4 checksum value and 658 * insert the result in the packet's L4 659 * header checksum field. The L4 checksum 660 * is calculated starting at @csum_start bytes 661 * into the packet to the end of the packet. 662 * The checksum insertion position is given 663 * in @csum_offset, which is the offset from 664 * @csum_start to the checksum field in the L4 665 * header. This feature is only applicable to 666 * protocols such as TCP, UDP and ICMP where a 667 * standard (i.e. the 'IP-style' checksum) 668 * one's complement 16-bit checksum is used, 669 * using an IP pseudo-header to seed the 670 * calculation. Software will preload the L4 671 * checksum field with the IP pseudo-header 672 * checksum. 673 * 674 * For tunnel encapsulation, @csum_start and 675 * @csum_offset refer to the inner L4 676 * header. Supported tunnels encapsulations 677 * are: IPIP, GRE, and UDP. If the @encap 678 * is clear, no further processing by the 679 * device is required; software will 680 * calculate the outer header checksums. If 681 * the @encap is set, the device will 682 * offload the outer header checksums using 683 * LCO (local checksum offload) (see 684 * Documentation/networking/checksum-offloads.rst 685 * for more info). 686 * 687 * IONIC_TXQ_DESC_OPCODE_CSUM_HW: 688 * Offload 16-bit checksum computation to hardware. 689 * If @csum_l3 is set then the packet's L3 checksum is 690 * updated. Similarly, if @csum_l4 is set the the L4 691 * checksum is updated. If @encap is set then encap header 692 * checksums are also updated. 693 * 694 * IONIC_TXQ_DESC_OPCODE_TSO: 695 * Device performs TCP segmentation offload 696 * (TSO). @hdr_len is the number of bytes 697 * to the end of TCP header (the offset to 698 * the TCP payload). @mss is the desired 699 * MSS, the TCP payload length for each 700 * segment. The device will calculate/ 701 * insert IP (IPv4 only) and TCP checksums 702 * for each segment. In the first data 703 * buffer containing the header template, 704 * the driver will set IPv4 checksum to 0 705 * and preload TCP checksum with the IP 706 * pseudo header calculated with IP length = 0. 707 * 708 * Supported tunnel encapsulations are IPIP, 709 * layer-3 GRE, and UDP. @hdr_len includes 710 * both outer and inner headers. The driver 711 * will set IPv4 checksum to zero and 712 * preload TCP checksum with IP pseudo 713 * header on the inner header. 714 * 715 * TCP ECN offload is supported. The device 716 * will set CWR flag in the first segment if 717 * CWR is set in the template header, and 718 * clear CWR in remaining segments. 719 * @flags: 720 * vlan: 721 * Insert an L2 VLAN header using @vlan_tci 722 * encap: 723 * Calculate encap header checksum 724 * csum_l3: 725 * Compute L3 header checksum 726 * csum_l4: 727 * Compute L4 header checksum 728 * tso_sot: 729 * TSO start 730 * tso_eot: 731 * TSO end 732 * @num_sg_elems: Number of scatter-gather elements in SG 733 * descriptor 734 * @addr: First data buffer's DMA address 735 * (Subsequent data buffers are on txq_sg_desc) 736 * @len: First data buffer's length, in bytes 737 * @vlan_tci: VLAN tag to insert in the packet (if requested 738 * by @V-bit). Includes .1p and .1q tags 739 * @hdr_len: Length of packet headers, including 740 * encapsulating outer header, if applicable 741 * Valid for opcodes IONIC_TXQ_DESC_OPCODE_CALC_CSUM and 742 * IONIC_TXQ_DESC_OPCODE_TSO. Should be set to zero for 743 * all other modes. For 744 * IONIC_TXQ_DESC_OPCODE_CALC_CSUM, @hdr_len is length 745 * of headers up to inner-most L4 header. For 746 * IONIC_TXQ_DESC_OPCODE_TSO, @hdr_len is up to 747 * inner-most L4 payload, so inclusive of 748 * inner-most L4 header. 749 * @mss: Desired MSS value for TSO; only applicable for 750 * IONIC_TXQ_DESC_OPCODE_TSO 751 * @csum_start: Offset from packet to first byte checked in L4 checksum 752 * @csum_offset: Offset from csum_start to L4 checksum field 753 */ 754 struct ionic_txq_desc { 755 __le64 cmd; 756 #define IONIC_TXQ_DESC_OPCODE_MASK 0xf 757 #define IONIC_TXQ_DESC_OPCODE_SHIFT 4 758 #define IONIC_TXQ_DESC_FLAGS_MASK 0xf 759 #define IONIC_TXQ_DESC_FLAGS_SHIFT 0 760 #define IONIC_TXQ_DESC_NSGE_MASK 0xf 761 #define IONIC_TXQ_DESC_NSGE_SHIFT 8 762 #define IONIC_TXQ_DESC_ADDR_MASK (BIT_ULL(IONIC_ADDR_LEN) - 1) 763 #define IONIC_TXQ_DESC_ADDR_SHIFT 12 764 765 /* common flags */ 766 #define IONIC_TXQ_DESC_FLAG_VLAN 0x1 767 #define IONIC_TXQ_DESC_FLAG_ENCAP 0x2 768 769 /* flags for csum_hw opcode */ 770 #define IONIC_TXQ_DESC_FLAG_CSUM_L3 0x4 771 #define IONIC_TXQ_DESC_FLAG_CSUM_L4 0x8 772 773 /* flags for tso opcode */ 774 #define IONIC_TXQ_DESC_FLAG_TSO_SOT 0x4 775 #define IONIC_TXQ_DESC_FLAG_TSO_EOT 0x8 776 777 __le16 len; 778 union { 779 __le16 vlan_tci; 780 __le16 hword0; 781 }; 782 union { 783 __le16 csum_start; 784 __le16 hdr_len; 785 __le16 hword1; 786 }; 787 union { 788 __le16 csum_offset; 789 __le16 mss; 790 __le16 hword2; 791 }; 792 }; 793 794 static inline u64 encode_txq_desc_cmd(u8 opcode, u8 flags, 795 u8 nsge, u64 addr) 796 { 797 u64 cmd; 798 799 cmd = (opcode & IONIC_TXQ_DESC_OPCODE_MASK) << IONIC_TXQ_DESC_OPCODE_SHIFT; 800 cmd |= (flags & IONIC_TXQ_DESC_FLAGS_MASK) << IONIC_TXQ_DESC_FLAGS_SHIFT; 801 cmd |= (nsge & IONIC_TXQ_DESC_NSGE_MASK) << IONIC_TXQ_DESC_NSGE_SHIFT; 802 cmd |= (addr & IONIC_TXQ_DESC_ADDR_MASK) << IONIC_TXQ_DESC_ADDR_SHIFT; 803 804 return cmd; 805 }; 806 807 static inline void decode_txq_desc_cmd(u64 cmd, u8 *opcode, u8 *flags, 808 u8 *nsge, u64 *addr) 809 { 810 *opcode = (cmd >> IONIC_TXQ_DESC_OPCODE_SHIFT) & IONIC_TXQ_DESC_OPCODE_MASK; 811 *flags = (cmd >> IONIC_TXQ_DESC_FLAGS_SHIFT) & IONIC_TXQ_DESC_FLAGS_MASK; 812 *nsge = (cmd >> IONIC_TXQ_DESC_NSGE_SHIFT) & IONIC_TXQ_DESC_NSGE_MASK; 813 *addr = (cmd >> IONIC_TXQ_DESC_ADDR_SHIFT) & IONIC_TXQ_DESC_ADDR_MASK; 814 }; 815 816 /** 817 * struct ionic_txq_sg_elem - Transmit scatter-gather (SG) descriptor element 818 * @addr: DMA address of SG element data buffer 819 * @len: Length of SG element data buffer, in bytes 820 */ 821 struct ionic_txq_sg_elem { 822 __le64 addr; 823 __le16 len; 824 __le16 rsvd[3]; 825 }; 826 827 /** 828 * struct ionic_txq_sg_desc - Transmit scatter-gather (SG) list 829 * @elems: Scatter-gather elements 830 */ 831 struct ionic_txq_sg_desc { 832 #define IONIC_TX_MAX_SG_ELEMS 8 833 #define IONIC_TX_SG_DESC_STRIDE 8 834 struct ionic_txq_sg_elem elems[IONIC_TX_MAX_SG_ELEMS]; 835 }; 836 837 struct ionic_txq_sg_desc_v1 { 838 #define IONIC_TX_MAX_SG_ELEMS_V1 15 839 #define IONIC_TX_SG_DESC_STRIDE_V1 16 840 struct ionic_txq_sg_elem elems[IONIC_TX_SG_DESC_STRIDE_V1]; 841 }; 842 843 /** 844 * struct ionic_txq_comp - Ethernet transmit queue completion descriptor 845 * @status: Status of the command (enum ionic_status_code) 846 * @comp_index: Index in the descriptor ring for which this is the completion 847 * @color: Color bit 848 */ 849 struct ionic_txq_comp { 850 u8 status; 851 u8 rsvd; 852 __le16 comp_index; 853 u8 rsvd2[11]; 854 u8 color; 855 }; 856 857 enum ionic_rxq_desc_opcode { 858 IONIC_RXQ_DESC_OPCODE_SIMPLE = 0, 859 IONIC_RXQ_DESC_OPCODE_SG = 1, 860 }; 861 862 /** 863 * struct ionic_rxq_desc - Ethernet Rx queue descriptor format 864 * @opcode: Rx operation, see IONIC_RXQ_DESC_OPCODE_*: 865 * 866 * IONIC_RXQ_DESC_OPCODE_SIMPLE: 867 * Receive full packet into data buffer 868 * starting at @addr. Results of 869 * receive, including actual bytes received, 870 * are recorded in Rx completion descriptor. 871 * 872 * @len: Data buffer's length, in bytes 873 * @addr: Data buffer's DMA address 874 */ 875 struct ionic_rxq_desc { 876 u8 opcode; 877 u8 rsvd[5]; 878 __le16 len; 879 __le64 addr; 880 }; 881 882 /** 883 * struct ionic_rxq_sg_elem - Receive scatter-gather (SG) descriptor element 884 * @addr: DMA address of SG element data buffer 885 * @len: Length of SG element data buffer, in bytes 886 */ 887 struct ionic_rxq_sg_elem { 888 __le64 addr; 889 __le16 len; 890 __le16 rsvd[3]; 891 }; 892 893 /** 894 * struct ionic_rxq_sg_desc - Receive scatter-gather (SG) list 895 * @elems: Scatter-gather elements 896 */ 897 struct ionic_rxq_sg_desc { 898 #define IONIC_RX_MAX_SG_ELEMS 8 899 #define IONIC_RX_SG_DESC_STRIDE 8 900 struct ionic_rxq_sg_elem elems[IONIC_RX_SG_DESC_STRIDE]; 901 }; 902 903 /** 904 * struct ionic_rxq_comp - Ethernet receive queue completion descriptor 905 * @status: Status of the command (enum ionic_status_code) 906 * @num_sg_elems: Number of SG elements used by this descriptor 907 * @comp_index: Index in the descriptor ring for which this is the completion 908 * @rss_hash: 32-bit RSS hash 909 * @csum: 16-bit sum of the packet's L2 payload 910 * If the packet's L2 payload is odd length, an extra 911 * zero-value byte is included in the @csum calculation but 912 * not included in @len. 913 * @vlan_tci: VLAN tag stripped from the packet. Valid if @VLAN is 914 * set. Includes .1p and .1q tags. 915 * @len: Received packet length, in bytes. Excludes FCS. 916 * @csum_calc L2 payload checksum is computed or not 917 * @csum_flags: See IONIC_RXQ_COMP_CSUM_F_*: 918 * 919 * IONIC_RXQ_COMP_CSUM_F_TCP_OK: 920 * The TCP checksum calculated by the device 921 * matched the checksum in the receive packet's 922 * TCP header. 923 * 924 * IONIC_RXQ_COMP_CSUM_F_TCP_BAD: 925 * The TCP checksum calculated by the device did 926 * not match the checksum in the receive packet's 927 * TCP header. 928 * 929 * IONIC_RXQ_COMP_CSUM_F_UDP_OK: 930 * The UDP checksum calculated by the device 931 * matched the checksum in the receive packet's 932 * UDP header 933 * 934 * IONIC_RXQ_COMP_CSUM_F_UDP_BAD: 935 * The UDP checksum calculated by the device did 936 * not match the checksum in the receive packet's 937 * UDP header. 938 * 939 * IONIC_RXQ_COMP_CSUM_F_IP_OK: 940 * The IPv4 checksum calculated by the device 941 * matched the checksum in the receive packet's 942 * first IPv4 header. If the receive packet 943 * contains both a tunnel IPv4 header and a 944 * transport IPv4 header, the device validates the 945 * checksum for the both IPv4 headers. 946 * 947 * IONIC_RXQ_COMP_CSUM_F_IP_BAD: 948 * The IPv4 checksum calculated by the device did 949 * not match the checksum in the receive packet's 950 * first IPv4 header. If the receive packet 951 * contains both a tunnel IPv4 header and a 952 * transport IPv4 header, the device validates the 953 * checksum for both IP headers. 954 * 955 * IONIC_RXQ_COMP_CSUM_F_VLAN: 956 * The VLAN header was stripped and placed in @vlan_tci. 957 * 958 * IONIC_RXQ_COMP_CSUM_F_CALC: 959 * The checksum was calculated by the device. 960 * 961 * @pkt_type_color: Packet type and color bit; see IONIC_RXQ_COMP_PKT_TYPE_MASK 962 */ 963 struct ionic_rxq_comp { 964 u8 status; 965 u8 num_sg_elems; 966 __le16 comp_index; 967 __le32 rss_hash; 968 __le16 csum; 969 __le16 vlan_tci; 970 __le16 len; 971 u8 csum_flags; 972 #define IONIC_RXQ_COMP_CSUM_F_TCP_OK 0x01 973 #define IONIC_RXQ_COMP_CSUM_F_TCP_BAD 0x02 974 #define IONIC_RXQ_COMP_CSUM_F_UDP_OK 0x04 975 #define IONIC_RXQ_COMP_CSUM_F_UDP_BAD 0x08 976 #define IONIC_RXQ_COMP_CSUM_F_IP_OK 0x10 977 #define IONIC_RXQ_COMP_CSUM_F_IP_BAD 0x20 978 #define IONIC_RXQ_COMP_CSUM_F_VLAN 0x40 979 #define IONIC_RXQ_COMP_CSUM_F_CALC 0x80 980 u8 pkt_type_color; 981 #define IONIC_RXQ_COMP_PKT_TYPE_MASK 0x7f 982 }; 983 984 enum ionic_pkt_type { 985 IONIC_PKT_TYPE_NON_IP = 0x00, 986 IONIC_PKT_TYPE_IPV4 = 0x01, 987 IONIC_PKT_TYPE_IPV4_TCP = 0x03, 988 IONIC_PKT_TYPE_IPV4_UDP = 0x05, 989 IONIC_PKT_TYPE_IPV6 = 0x08, 990 IONIC_PKT_TYPE_IPV6_TCP = 0x18, 991 IONIC_PKT_TYPE_IPV6_UDP = 0x28, 992 /* below types are only used if encap offloads are enabled on lif */ 993 IONIC_PKT_TYPE_ENCAP_NON_IP = 0x40, 994 IONIC_PKT_TYPE_ENCAP_IPV4 = 0x41, 995 IONIC_PKT_TYPE_ENCAP_IPV4_TCP = 0x43, 996 IONIC_PKT_TYPE_ENCAP_IPV4_UDP = 0x45, 997 IONIC_PKT_TYPE_ENCAP_IPV6 = 0x48, 998 IONIC_PKT_TYPE_ENCAP_IPV6_TCP = 0x58, 999 IONIC_PKT_TYPE_ENCAP_IPV6_UDP = 0x68, 1000 }; 1001 1002 enum ionic_eth_hw_features { 1003 IONIC_ETH_HW_VLAN_TX_TAG = BIT(0), 1004 IONIC_ETH_HW_VLAN_RX_STRIP = BIT(1), 1005 IONIC_ETH_HW_VLAN_RX_FILTER = BIT(2), 1006 IONIC_ETH_HW_RX_HASH = BIT(3), 1007 IONIC_ETH_HW_RX_CSUM = BIT(4), 1008 IONIC_ETH_HW_TX_SG = BIT(5), 1009 IONIC_ETH_HW_RX_SG = BIT(6), 1010 IONIC_ETH_HW_TX_CSUM = BIT(7), 1011 IONIC_ETH_HW_TSO = BIT(8), 1012 IONIC_ETH_HW_TSO_IPV6 = BIT(9), 1013 IONIC_ETH_HW_TSO_ECN = BIT(10), 1014 IONIC_ETH_HW_TSO_GRE = BIT(11), 1015 IONIC_ETH_HW_TSO_GRE_CSUM = BIT(12), 1016 IONIC_ETH_HW_TSO_IPXIP4 = BIT(13), 1017 IONIC_ETH_HW_TSO_IPXIP6 = BIT(14), 1018 IONIC_ETH_HW_TSO_UDP = BIT(15), 1019 IONIC_ETH_HW_TSO_UDP_CSUM = BIT(16), 1020 IONIC_ETH_HW_RX_CSUM_GENEVE = BIT(17), 1021 IONIC_ETH_HW_TX_CSUM_GENEVE = BIT(18), 1022 IONIC_ETH_HW_TSO_GENEVE = BIT(19) 1023 }; 1024 1025 /** 1026 * struct ionic_q_control_cmd - Queue control command 1027 * @opcode: opcode 1028 * @type: Queue type 1029 * @lif_index: LIF index 1030 * @index: Queue index 1031 * @oper: Operation (enum ionic_q_control_oper) 1032 */ 1033 struct ionic_q_control_cmd { 1034 u8 opcode; 1035 u8 type; 1036 __le16 lif_index; 1037 __le32 index; 1038 u8 oper; 1039 u8 rsvd[55]; 1040 }; 1041 1042 typedef struct ionic_admin_comp ionic_q_control_comp; 1043 1044 enum q_control_oper { 1045 IONIC_Q_DISABLE = 0, 1046 IONIC_Q_ENABLE = 1, 1047 IONIC_Q_HANG_RESET = 2, 1048 }; 1049 1050 /** 1051 * enum ionic_phy_type - Physical connection type 1052 * @IONIC_PHY_TYPE_NONE: No PHY installed 1053 * @IONIC_PHY_TYPE_COPPER: Copper PHY 1054 * @IONIC_PHY_TYPE_FIBER: Fiber PHY 1055 */ 1056 enum ionic_phy_type { 1057 IONIC_PHY_TYPE_NONE = 0, 1058 IONIC_PHY_TYPE_COPPER = 1, 1059 IONIC_PHY_TYPE_FIBER = 2, 1060 }; 1061 1062 /** 1063 * enum ionic_xcvr_state - Transceiver status 1064 * @IONIC_XCVR_STATE_REMOVED: Transceiver removed 1065 * @IONIC_XCVR_STATE_INSERTED: Transceiver inserted 1066 * @IONIC_XCVR_STATE_PENDING: Transceiver pending 1067 * @IONIC_XCVR_STATE_SPROM_READ: Transceiver data read 1068 * @IONIC_XCVR_STATE_SPROM_READ_ERR: Transceiver data read error 1069 */ 1070 enum ionic_xcvr_state { 1071 IONIC_XCVR_STATE_REMOVED = 0, 1072 IONIC_XCVR_STATE_INSERTED = 1, 1073 IONIC_XCVR_STATE_PENDING = 2, 1074 IONIC_XCVR_STATE_SPROM_READ = 3, 1075 IONIC_XCVR_STATE_SPROM_READ_ERR = 4, 1076 }; 1077 1078 /** 1079 * enum ionic_xcvr_pid - Supported link modes 1080 */ 1081 enum ionic_xcvr_pid { 1082 IONIC_XCVR_PID_UNKNOWN = 0, 1083 1084 /* CU */ 1085 IONIC_XCVR_PID_QSFP_100G_CR4 = 1, 1086 IONIC_XCVR_PID_QSFP_40GBASE_CR4 = 2, 1087 IONIC_XCVR_PID_SFP_25GBASE_CR_S = 3, 1088 IONIC_XCVR_PID_SFP_25GBASE_CR_L = 4, 1089 IONIC_XCVR_PID_SFP_25GBASE_CR_N = 5, 1090 1091 /* Fiber */ 1092 IONIC_XCVR_PID_QSFP_100G_AOC = 50, 1093 IONIC_XCVR_PID_QSFP_100G_ACC = 51, 1094 IONIC_XCVR_PID_QSFP_100G_SR4 = 52, 1095 IONIC_XCVR_PID_QSFP_100G_LR4 = 53, 1096 IONIC_XCVR_PID_QSFP_100G_ER4 = 54, 1097 IONIC_XCVR_PID_QSFP_40GBASE_ER4 = 55, 1098 IONIC_XCVR_PID_QSFP_40GBASE_SR4 = 56, 1099 IONIC_XCVR_PID_QSFP_40GBASE_LR4 = 57, 1100 IONIC_XCVR_PID_QSFP_40GBASE_AOC = 58, 1101 IONIC_XCVR_PID_SFP_25GBASE_SR = 59, 1102 IONIC_XCVR_PID_SFP_25GBASE_LR = 60, 1103 IONIC_XCVR_PID_SFP_25GBASE_ER = 61, 1104 IONIC_XCVR_PID_SFP_25GBASE_AOC = 62, 1105 IONIC_XCVR_PID_SFP_10GBASE_SR = 63, 1106 IONIC_XCVR_PID_SFP_10GBASE_LR = 64, 1107 IONIC_XCVR_PID_SFP_10GBASE_LRM = 65, 1108 IONIC_XCVR_PID_SFP_10GBASE_ER = 66, 1109 IONIC_XCVR_PID_SFP_10GBASE_AOC = 67, 1110 IONIC_XCVR_PID_SFP_10GBASE_CU = 68, 1111 IONIC_XCVR_PID_QSFP_100G_CWDM4 = 69, 1112 IONIC_XCVR_PID_QSFP_100G_PSM4 = 70, 1113 IONIC_XCVR_PID_SFP_25GBASE_ACC = 71, 1114 IONIC_XCVR_PID_SFP_10GBASE_T = 72, 1115 IONIC_XCVR_PID_SFP_1000BASE_T = 73, 1116 }; 1117 1118 /** 1119 * enum ionic_port_type - Port types 1120 * @IONIC_PORT_TYPE_NONE: Port type not configured 1121 * @IONIC_PORT_TYPE_ETH: Port carries ethernet traffic (inband) 1122 * @IONIC_PORT_TYPE_MGMT: Port carries mgmt traffic (out-of-band) 1123 */ 1124 enum ionic_port_type { 1125 IONIC_PORT_TYPE_NONE = 0, 1126 IONIC_PORT_TYPE_ETH = 1, 1127 IONIC_PORT_TYPE_MGMT = 2, 1128 }; 1129 1130 /** 1131 * enum ionic_port_admin_state - Port config state 1132 * @IONIC_PORT_ADMIN_STATE_NONE: Port admin state not configured 1133 * @IONIC_PORT_ADMIN_STATE_DOWN: Port admin disabled 1134 * @IONIC_PORT_ADMIN_STATE_UP: Port admin enabled 1135 */ 1136 enum ionic_port_admin_state { 1137 IONIC_PORT_ADMIN_STATE_NONE = 0, 1138 IONIC_PORT_ADMIN_STATE_DOWN = 1, 1139 IONIC_PORT_ADMIN_STATE_UP = 2, 1140 }; 1141 1142 /** 1143 * enum ionic_port_oper_status - Port operational status 1144 * @IONIC_PORT_OPER_STATUS_NONE: Port disabled 1145 * @IONIC_PORT_OPER_STATUS_UP: Port link status up 1146 * @IONIC_PORT_OPER_STATUS_DOWN: Port link status down 1147 */ 1148 enum ionic_port_oper_status { 1149 IONIC_PORT_OPER_STATUS_NONE = 0, 1150 IONIC_PORT_OPER_STATUS_UP = 1, 1151 IONIC_PORT_OPER_STATUS_DOWN = 2, 1152 }; 1153 1154 /** 1155 * enum ionic_port_fec_type - Ethernet Forward error correction (FEC) modes 1156 * @IONIC_PORT_FEC_TYPE_NONE: FEC Disabled 1157 * @IONIC_PORT_FEC_TYPE_FC: FireCode FEC 1158 * @IONIC_PORT_FEC_TYPE_RS: ReedSolomon FEC 1159 */ 1160 enum ionic_port_fec_type { 1161 IONIC_PORT_FEC_TYPE_NONE = 0, 1162 IONIC_PORT_FEC_TYPE_FC = 1, 1163 IONIC_PORT_FEC_TYPE_RS = 2, 1164 }; 1165 1166 /** 1167 * enum ionic_port_pause_type - Ethernet pause (flow control) modes 1168 * @IONIC_PORT_PAUSE_TYPE_NONE: Disable Pause 1169 * @IONIC_PORT_PAUSE_TYPE_LINK: Link level pause 1170 * @IONIC_PORT_PAUSE_TYPE_PFC: Priority-Flow Control 1171 */ 1172 enum ionic_port_pause_type { 1173 IONIC_PORT_PAUSE_TYPE_NONE = 0, 1174 IONIC_PORT_PAUSE_TYPE_LINK = 1, 1175 IONIC_PORT_PAUSE_TYPE_PFC = 2, 1176 }; 1177 1178 /** 1179 * enum ionic_port_loopback_mode - Loopback modes 1180 * @IONIC_PORT_LOOPBACK_MODE_NONE: Disable loopback 1181 * @IONIC_PORT_LOOPBACK_MODE_MAC: MAC loopback 1182 * @IONIC_PORT_LOOPBACK_MODE_PHY: PHY/SerDes loopback 1183 */ 1184 enum ionic_port_loopback_mode { 1185 IONIC_PORT_LOOPBACK_MODE_NONE = 0, 1186 IONIC_PORT_LOOPBACK_MODE_MAC = 1, 1187 IONIC_PORT_LOOPBACK_MODE_PHY = 2, 1188 }; 1189 1190 /** 1191 * struct ionic_xcvr_status - Transceiver Status information 1192 * @state: Transceiver status (enum ionic_xcvr_state) 1193 * @phy: Physical connection type (enum ionic_phy_type) 1194 * @pid: Transceiver link mode (enum ionic_xcvr_pid) 1195 * @sprom: Transceiver sprom contents 1196 */ 1197 struct ionic_xcvr_status { 1198 u8 state; 1199 u8 phy; 1200 __le16 pid; 1201 u8 sprom[256]; 1202 }; 1203 1204 /** 1205 * union ionic_port_config - Port configuration 1206 * @speed: port speed (in Mbps) 1207 * @mtu: mtu 1208 * @state: port admin state (enum ionic_port_admin_state) 1209 * @an_enable: autoneg enable 1210 * @fec_type: fec type (enum ionic_port_fec_type) 1211 * @pause_type: pause type (enum ionic_port_pause_type) 1212 * @loopback_mode: loopback mode (enum ionic_port_loopback_mode) 1213 */ 1214 union ionic_port_config { 1215 struct { 1216 #define IONIC_SPEED_100G 100000 /* 100G in Mbps */ 1217 #define IONIC_SPEED_50G 50000 /* 50G in Mbps */ 1218 #define IONIC_SPEED_40G 40000 /* 40G in Mbps */ 1219 #define IONIC_SPEED_25G 25000 /* 25G in Mbps */ 1220 #define IONIC_SPEED_10G 10000 /* 10G in Mbps */ 1221 #define IONIC_SPEED_1G 1000 /* 1G in Mbps */ 1222 __le32 speed; 1223 __le32 mtu; 1224 u8 state; 1225 u8 an_enable; 1226 u8 fec_type; 1227 #define IONIC_PAUSE_TYPE_MASK 0x0f 1228 #define IONIC_PAUSE_FLAGS_MASK 0xf0 1229 #define IONIC_PAUSE_F_TX 0x10 1230 #define IONIC_PAUSE_F_RX 0x20 1231 u8 pause_type; 1232 u8 loopback_mode; 1233 }; 1234 __le32 words[64]; 1235 }; 1236 1237 /** 1238 * struct ionic_port_status - Port Status information 1239 * @status: link status (enum ionic_port_oper_status) 1240 * @id: port id 1241 * @speed: link speed (in Mbps) 1242 * @link_down_count: number of times link went from from up to down 1243 * @fec_type: fec type (enum ionic_port_fec_type) 1244 * @xcvr: tranceiver status 1245 */ 1246 struct ionic_port_status { 1247 __le32 id; 1248 __le32 speed; 1249 u8 status; 1250 __le16 link_down_count; 1251 u8 fec_type; 1252 u8 rsvd[48]; 1253 struct ionic_xcvr_status xcvr; 1254 } __packed; 1255 1256 /** 1257 * struct ionic_port_identify_cmd - Port identify command 1258 * @opcode: opcode 1259 * @index: port index 1260 * @ver: Highest version of identify supported by driver 1261 */ 1262 struct ionic_port_identify_cmd { 1263 u8 opcode; 1264 u8 index; 1265 u8 ver; 1266 u8 rsvd[61]; 1267 }; 1268 1269 /** 1270 * struct ionic_port_identify_comp - Port identify command completion 1271 * @status: Status of the command (enum ionic_status_code) 1272 * @ver: Version of identify returned by device 1273 */ 1274 struct ionic_port_identify_comp { 1275 u8 status; 1276 u8 ver; 1277 u8 rsvd[14]; 1278 }; 1279 1280 /** 1281 * struct ionic_port_init_cmd - Port initialization command 1282 * @opcode: opcode 1283 * @index: port index 1284 * @info_pa: destination address for port info (struct ionic_port_info) 1285 */ 1286 struct ionic_port_init_cmd { 1287 u8 opcode; 1288 u8 index; 1289 u8 rsvd[6]; 1290 __le64 info_pa; 1291 u8 rsvd2[48]; 1292 }; 1293 1294 /** 1295 * struct ionic_port_init_comp - Port initialization command completion 1296 * @status: Status of the command (enum ionic_status_code) 1297 */ 1298 struct ionic_port_init_comp { 1299 u8 status; 1300 u8 rsvd[15]; 1301 }; 1302 1303 /** 1304 * struct ionic_port_reset_cmd - Port reset command 1305 * @opcode: opcode 1306 * @index: port index 1307 */ 1308 struct ionic_port_reset_cmd { 1309 u8 opcode; 1310 u8 index; 1311 u8 rsvd[62]; 1312 }; 1313 1314 /** 1315 * struct ionic_port_reset_comp - Port reset command completion 1316 * @status: Status of the command (enum ionic_status_code) 1317 */ 1318 struct ionic_port_reset_comp { 1319 u8 status; 1320 u8 rsvd[15]; 1321 }; 1322 1323 /** 1324 * enum ionic_stats_ctl_cmd - List of commands for stats control 1325 * @IONIC_STATS_CTL_RESET: Reset statistics 1326 */ 1327 enum ionic_stats_ctl_cmd { 1328 IONIC_STATS_CTL_RESET = 0, 1329 }; 1330 1331 /** 1332 * enum ionic_port_attr - List of device attributes 1333 * @IONIC_PORT_ATTR_STATE: Port state attribute 1334 * @IONIC_PORT_ATTR_SPEED: Port speed attribute 1335 * @IONIC_PORT_ATTR_MTU: Port MTU attribute 1336 * @IONIC_PORT_ATTR_AUTONEG: Port autonegotiation attribute 1337 * @IONIC_PORT_ATTR_FEC: Port FEC attribute 1338 * @IONIC_PORT_ATTR_PAUSE: Port pause attribute 1339 * @IONIC_PORT_ATTR_LOOPBACK: Port loopback attribute 1340 * @IONIC_PORT_ATTR_STATS_CTRL: Port statistics control attribute 1341 */ 1342 enum ionic_port_attr { 1343 IONIC_PORT_ATTR_STATE = 0, 1344 IONIC_PORT_ATTR_SPEED = 1, 1345 IONIC_PORT_ATTR_MTU = 2, 1346 IONIC_PORT_ATTR_AUTONEG = 3, 1347 IONIC_PORT_ATTR_FEC = 4, 1348 IONIC_PORT_ATTR_PAUSE = 5, 1349 IONIC_PORT_ATTR_LOOPBACK = 6, 1350 IONIC_PORT_ATTR_STATS_CTRL = 7, 1351 }; 1352 1353 /** 1354 * struct ionic_port_setattr_cmd - Set port attributes on the NIC 1355 * @opcode: Opcode 1356 * @index: Port index 1357 * @attr: Attribute type (enum ionic_port_attr) 1358 * @state: Port state 1359 * @speed: Port speed 1360 * @mtu: Port MTU 1361 * @an_enable: Port autonegotiation setting 1362 * @fec_type: Port FEC type setting 1363 * @pause_type: Port pause type setting 1364 * @loopback_mode: Port loopback mode 1365 * @stats_ctl: Port stats setting 1366 */ 1367 struct ionic_port_setattr_cmd { 1368 u8 opcode; 1369 u8 index; 1370 u8 attr; 1371 u8 rsvd; 1372 union { 1373 u8 state; 1374 __le32 speed; 1375 __le32 mtu; 1376 u8 an_enable; 1377 u8 fec_type; 1378 u8 pause_type; 1379 u8 loopback_mode; 1380 u8 stats_ctl; 1381 u8 rsvd2[60]; 1382 }; 1383 }; 1384 1385 /** 1386 * struct ionic_port_setattr_comp - Port set attr command completion 1387 * @status: Status of the command (enum ionic_status_code) 1388 * @color: Color bit 1389 */ 1390 struct ionic_port_setattr_comp { 1391 u8 status; 1392 u8 rsvd[14]; 1393 u8 color; 1394 }; 1395 1396 /** 1397 * struct ionic_port_getattr_cmd - Get port attributes from the NIC 1398 * @opcode: Opcode 1399 * @index: port index 1400 * @attr: Attribute type (enum ionic_port_attr) 1401 */ 1402 struct ionic_port_getattr_cmd { 1403 u8 opcode; 1404 u8 index; 1405 u8 attr; 1406 u8 rsvd[61]; 1407 }; 1408 1409 /** 1410 * struct ionic_port_getattr_comp - Port get attr command completion 1411 * @status: Status of the command (enum ionic_status_code) 1412 * @state: Port state 1413 * @speed: Port speed 1414 * @mtu: Port MTU 1415 * @an_enable: Port autonegotiation setting 1416 * @fec_type: Port FEC type setting 1417 * @pause_type: Port pause type setting 1418 * @loopback_mode: Port loopback mode 1419 * @color: Color bit 1420 */ 1421 struct ionic_port_getattr_comp { 1422 u8 status; 1423 u8 rsvd[3]; 1424 union { 1425 u8 state; 1426 __le32 speed; 1427 __le32 mtu; 1428 u8 an_enable; 1429 u8 fec_type; 1430 u8 pause_type; 1431 u8 loopback_mode; 1432 u8 rsvd2[11]; 1433 } __packed; 1434 u8 color; 1435 }; 1436 1437 /** 1438 * struct ionic_lif_status - LIF status register 1439 * @eid: most recent NotifyQ event id 1440 * @port_num: port the LIF is connected to 1441 * @link_status: port status (enum ionic_port_oper_status) 1442 * @link_speed: speed of link in Mbps 1443 * @link_down_count: number of times link went from up to down 1444 */ 1445 struct ionic_lif_status { 1446 __le64 eid; 1447 u8 port_num; 1448 u8 rsvd; 1449 __le16 link_status; 1450 __le32 link_speed; /* units of 1Mbps: eg 10000 = 10Gbps */ 1451 __le16 link_down_count; 1452 u8 rsvd2[46]; 1453 }; 1454 1455 /** 1456 * struct ionic_lif_reset_cmd - LIF reset command 1457 * @opcode: opcode 1458 * @index: LIF index 1459 */ 1460 struct ionic_lif_reset_cmd { 1461 u8 opcode; 1462 u8 rsvd; 1463 __le16 index; 1464 __le32 rsvd2[15]; 1465 }; 1466 1467 typedef struct ionic_admin_comp ionic_lif_reset_comp; 1468 1469 enum ionic_dev_state { 1470 IONIC_DEV_DISABLE = 0, 1471 IONIC_DEV_ENABLE = 1, 1472 IONIC_DEV_HANG_RESET = 2, 1473 }; 1474 1475 /** 1476 * enum ionic_dev_attr - List of device attributes 1477 * @IONIC_DEV_ATTR_STATE: Device state attribute 1478 * @IONIC_DEV_ATTR_NAME: Device name attribute 1479 * @IONIC_DEV_ATTR_FEATURES: Device feature attributes 1480 */ 1481 enum ionic_dev_attr { 1482 IONIC_DEV_ATTR_STATE = 0, 1483 IONIC_DEV_ATTR_NAME = 1, 1484 IONIC_DEV_ATTR_FEATURES = 2, 1485 }; 1486 1487 /** 1488 * struct ionic_dev_setattr_cmd - Set Device attributes on the NIC 1489 * @opcode: Opcode 1490 * @attr: Attribute type (enum ionic_dev_attr) 1491 * @state: Device state (enum ionic_dev_state) 1492 * @name: The bus info, e.g. PCI slot-device-function, 0 terminated 1493 * @features: Device features 1494 */ 1495 struct ionic_dev_setattr_cmd { 1496 u8 opcode; 1497 u8 attr; 1498 __le16 rsvd; 1499 union { 1500 u8 state; 1501 char name[IONIC_IFNAMSIZ]; 1502 __le64 features; 1503 u8 rsvd2[60]; 1504 } __packed; 1505 }; 1506 1507 /** 1508 * struct ionic_dev_setattr_comp - Device set attr command completion 1509 * @status: Status of the command (enum ionic_status_code) 1510 * @features: Device features 1511 * @color: Color bit 1512 */ 1513 struct ionic_dev_setattr_comp { 1514 u8 status; 1515 u8 rsvd[3]; 1516 union { 1517 __le64 features; 1518 u8 rsvd2[11]; 1519 } __packed; 1520 u8 color; 1521 }; 1522 1523 /** 1524 * struct ionic_dev_getattr_cmd - Get Device attributes from the NIC 1525 * @opcode: opcode 1526 * @attr: Attribute type (enum ionic_dev_attr) 1527 */ 1528 struct ionic_dev_getattr_cmd { 1529 u8 opcode; 1530 u8 attr; 1531 u8 rsvd[62]; 1532 }; 1533 1534 /** 1535 * struct ionic_dev_setattr_comp - Device set attr command completion 1536 * @status: Status of the command (enum ionic_status_code) 1537 * @features: Device features 1538 * @color: Color bit 1539 */ 1540 struct ionic_dev_getattr_comp { 1541 u8 status; 1542 u8 rsvd[3]; 1543 union { 1544 __le64 features; 1545 u8 rsvd2[11]; 1546 } __packed; 1547 u8 color; 1548 }; 1549 1550 /** 1551 * RSS parameters 1552 */ 1553 #define IONIC_RSS_HASH_KEY_SIZE 40 1554 1555 enum ionic_rss_hash_types { 1556 IONIC_RSS_TYPE_IPV4 = BIT(0), 1557 IONIC_RSS_TYPE_IPV4_TCP = BIT(1), 1558 IONIC_RSS_TYPE_IPV4_UDP = BIT(2), 1559 IONIC_RSS_TYPE_IPV6 = BIT(3), 1560 IONIC_RSS_TYPE_IPV6_TCP = BIT(4), 1561 IONIC_RSS_TYPE_IPV6_UDP = BIT(5), 1562 }; 1563 1564 /** 1565 * enum ionic_lif_attr - List of LIF attributes 1566 * @IONIC_LIF_ATTR_STATE: LIF state attribute 1567 * @IONIC_LIF_ATTR_NAME: LIF name attribute 1568 * @IONIC_LIF_ATTR_MTU: LIF MTU attribute 1569 * @IONIC_LIF_ATTR_MAC: LIF MAC attribute 1570 * @IONIC_LIF_ATTR_FEATURES: LIF features attribute 1571 * @IONIC_LIF_ATTR_RSS: LIF RSS attribute 1572 * @IONIC_LIF_ATTR_STATS_CTRL: LIF statistics control attribute 1573 */ 1574 enum ionic_lif_attr { 1575 IONIC_LIF_ATTR_STATE = 0, 1576 IONIC_LIF_ATTR_NAME = 1, 1577 IONIC_LIF_ATTR_MTU = 2, 1578 IONIC_LIF_ATTR_MAC = 3, 1579 IONIC_LIF_ATTR_FEATURES = 4, 1580 IONIC_LIF_ATTR_RSS = 5, 1581 IONIC_LIF_ATTR_STATS_CTRL = 6, 1582 }; 1583 1584 /** 1585 * struct ionic_lif_setattr_cmd - Set LIF attributes on the NIC 1586 * @opcode: Opcode 1587 * @attr: Attribute type (enum ionic_lif_attr) 1588 * @index: LIF index 1589 * @state: LIF state (enum ionic_lif_state) 1590 * @name: The netdev name string, 0 terminated 1591 * @mtu: Mtu 1592 * @mac: Station mac 1593 * @features: Features (enum ionic_eth_hw_features) 1594 * @rss: RSS properties 1595 * @types: The hash types to enable (see rss_hash_types) 1596 * @key: The hash secret key 1597 * @addr: Address for the indirection table shared memory 1598 * @stats_ctl: stats control commands (enum ionic_stats_ctl_cmd) 1599 */ 1600 struct ionic_lif_setattr_cmd { 1601 u8 opcode; 1602 u8 attr; 1603 __le16 index; 1604 union { 1605 u8 state; 1606 char name[IONIC_IFNAMSIZ]; 1607 __le32 mtu; 1608 u8 mac[6]; 1609 __le64 features; 1610 struct { 1611 __le16 types; 1612 u8 key[IONIC_RSS_HASH_KEY_SIZE]; 1613 u8 rsvd[6]; 1614 __le64 addr; 1615 } rss; 1616 u8 stats_ctl; 1617 u8 rsvd[60]; 1618 } __packed; 1619 }; 1620 1621 /** 1622 * struct ionic_lif_setattr_comp - LIF set attr command completion 1623 * @status: Status of the command (enum ionic_status_code) 1624 * @comp_index: Index in the descriptor ring for which this is the completion 1625 * @features: features (enum ionic_eth_hw_features) 1626 * @color: Color bit 1627 */ 1628 struct ionic_lif_setattr_comp { 1629 u8 status; 1630 u8 rsvd; 1631 __le16 comp_index; 1632 union { 1633 __le64 features; 1634 u8 rsvd2[11]; 1635 } __packed; 1636 u8 color; 1637 }; 1638 1639 /** 1640 * struct ionic_lif_getattr_cmd - Get LIF attributes from the NIC 1641 * @opcode: Opcode 1642 * @attr: Attribute type (enum ionic_lif_attr) 1643 * @index: LIF index 1644 */ 1645 struct ionic_lif_getattr_cmd { 1646 u8 opcode; 1647 u8 attr; 1648 __le16 index; 1649 u8 rsvd[60]; 1650 }; 1651 1652 /** 1653 * struct ionic_lif_getattr_comp - LIF get attr command completion 1654 * @status: Status of the command (enum ionic_status_code) 1655 * @comp_index: Index in the descriptor ring for which this is the completion 1656 * @state: LIF state (enum ionic_lif_state) 1657 * @name: The netdev name string, 0 terminated 1658 * @mtu: Mtu 1659 * @mac: Station mac 1660 * @features: Features (enum ionic_eth_hw_features) 1661 * @color: Color bit 1662 */ 1663 struct ionic_lif_getattr_comp { 1664 u8 status; 1665 u8 rsvd; 1666 __le16 comp_index; 1667 union { 1668 u8 state; 1669 __le32 mtu; 1670 u8 mac[6]; 1671 __le64 features; 1672 u8 rsvd2[11]; 1673 } __packed; 1674 u8 color; 1675 }; 1676 1677 enum ionic_rx_mode { 1678 IONIC_RX_MODE_F_UNICAST = BIT(0), 1679 IONIC_RX_MODE_F_MULTICAST = BIT(1), 1680 IONIC_RX_MODE_F_BROADCAST = BIT(2), 1681 IONIC_RX_MODE_F_PROMISC = BIT(3), 1682 IONIC_RX_MODE_F_ALLMULTI = BIT(4), 1683 IONIC_RX_MODE_F_RDMA_SNIFFER = BIT(5), 1684 }; 1685 1686 /** 1687 * struct ionic_rx_mode_set_cmd - Set LIF's Rx mode command 1688 * @opcode: opcode 1689 * @lif_index: LIF index 1690 * @rx_mode: Rx mode flags: 1691 * IONIC_RX_MODE_F_UNICAST: Accept known unicast packets 1692 * IONIC_RX_MODE_F_MULTICAST: Accept known multicast packets 1693 * IONIC_RX_MODE_F_BROADCAST: Accept broadcast packets 1694 * IONIC_RX_MODE_F_PROMISC: Accept any packets 1695 * IONIC_RX_MODE_F_ALLMULTI: Accept any multicast packets 1696 * IONIC_RX_MODE_F_RDMA_SNIFFER: Sniff RDMA packets 1697 */ 1698 struct ionic_rx_mode_set_cmd { 1699 u8 opcode; 1700 u8 rsvd; 1701 __le16 lif_index; 1702 __le16 rx_mode; 1703 __le16 rsvd2[29]; 1704 }; 1705 1706 typedef struct ionic_admin_comp ionic_rx_mode_set_comp; 1707 1708 enum ionic_rx_filter_match_type { 1709 IONIC_RX_FILTER_MATCH_VLAN = 0, 1710 IONIC_RX_FILTER_MATCH_MAC, 1711 IONIC_RX_FILTER_MATCH_MAC_VLAN, 1712 }; 1713 1714 /** 1715 * struct ionic_rx_filter_add_cmd - Add LIF Rx filter command 1716 * @opcode: opcode 1717 * @qtype: Queue type 1718 * @lif_index: LIF index 1719 * @qid: Queue ID 1720 * @match: Rx filter match type (see IONIC_RX_FILTER_MATCH_xxx) 1721 * @vlan: VLAN filter 1722 * @vlan: VLAN ID 1723 * @mac: MAC filter 1724 * @addr: MAC address (network-byte order) 1725 * @mac_vlan: MACVLAN filter 1726 * @vlan: VLAN ID 1727 * @addr: MAC address (network-byte order) 1728 */ 1729 struct ionic_rx_filter_add_cmd { 1730 u8 opcode; 1731 u8 qtype; 1732 __le16 lif_index; 1733 __le32 qid; 1734 __le16 match; 1735 union { 1736 struct { 1737 __le16 vlan; 1738 } vlan; 1739 struct { 1740 u8 addr[6]; 1741 } mac; 1742 struct { 1743 __le16 vlan; 1744 u8 addr[6]; 1745 } mac_vlan; 1746 u8 rsvd[54]; 1747 }; 1748 }; 1749 1750 /** 1751 * struct ionic_rx_filter_add_comp - Add LIF Rx filter command completion 1752 * @status: Status of the command (enum ionic_status_code) 1753 * @comp_index: Index in the descriptor ring for which this is the completion 1754 * @filter_id: Filter ID 1755 * @color: Color bit 1756 */ 1757 struct ionic_rx_filter_add_comp { 1758 u8 status; 1759 u8 rsvd; 1760 __le16 comp_index; 1761 __le32 filter_id; 1762 u8 rsvd2[7]; 1763 u8 color; 1764 }; 1765 1766 /** 1767 * struct ionic_rx_filter_del_cmd - Delete LIF Rx filter command 1768 * @opcode: opcode 1769 * @lif_index: LIF index 1770 * @filter_id: Filter ID 1771 */ 1772 struct ionic_rx_filter_del_cmd { 1773 u8 opcode; 1774 u8 rsvd; 1775 __le16 lif_index; 1776 __le32 filter_id; 1777 u8 rsvd2[56]; 1778 }; 1779 1780 typedef struct ionic_admin_comp ionic_rx_filter_del_comp; 1781 1782 enum ionic_vf_attr { 1783 IONIC_VF_ATTR_SPOOFCHK = 1, 1784 IONIC_VF_ATTR_TRUST = 2, 1785 IONIC_VF_ATTR_MAC = 3, 1786 IONIC_VF_ATTR_LINKSTATE = 4, 1787 IONIC_VF_ATTR_VLAN = 5, 1788 IONIC_VF_ATTR_RATE = 6, 1789 IONIC_VF_ATTR_STATSADDR = 7, 1790 }; 1791 1792 /** 1793 * enum ionic_vf_link_status - Virtual Function link status 1794 * @IONIC_VF_LINK_STATUS_AUTO: Use link state of the uplink 1795 * @IONIC_VF_LINK_STATUS_UP: Link always up 1796 * @IONIC_VF_LINK_STATUS_DOWN: Link always down 1797 */ 1798 enum ionic_vf_link_status { 1799 IONIC_VF_LINK_STATUS_AUTO = 0, 1800 IONIC_VF_LINK_STATUS_UP = 1, 1801 IONIC_VF_LINK_STATUS_DOWN = 2, 1802 }; 1803 1804 /** 1805 * struct ionic_vf_setattr_cmd - Set VF attributes on the NIC 1806 * @opcode: Opcode 1807 * @attr: Attribute type (enum ionic_vf_attr) 1808 * @vf_index: VF index 1809 * @macaddr: mac address 1810 * @vlanid: vlan ID 1811 * @maxrate: max Tx rate in Mbps 1812 * @spoofchk: enable address spoof checking 1813 * @trust: enable VF trust 1814 * @linkstate: set link up or down 1815 * @stats_pa: set DMA address for VF stats 1816 */ 1817 struct ionic_vf_setattr_cmd { 1818 u8 opcode; 1819 u8 attr; 1820 __le16 vf_index; 1821 union { 1822 u8 macaddr[6]; 1823 __le16 vlanid; 1824 __le32 maxrate; 1825 u8 spoofchk; 1826 u8 trust; 1827 u8 linkstate; 1828 __le64 stats_pa; 1829 u8 pad[60]; 1830 } __packed; 1831 }; 1832 1833 struct ionic_vf_setattr_comp { 1834 u8 status; 1835 u8 attr; 1836 __le16 vf_index; 1837 __le16 comp_index; 1838 u8 rsvd[9]; 1839 u8 color; 1840 }; 1841 1842 /** 1843 * struct ionic_vf_getattr_cmd - Get VF attributes from the NIC 1844 * @opcode: Opcode 1845 * @attr: Attribute type (enum ionic_vf_attr) 1846 * @vf_index: VF index 1847 */ 1848 struct ionic_vf_getattr_cmd { 1849 u8 opcode; 1850 u8 attr; 1851 __le16 vf_index; 1852 u8 rsvd[60]; 1853 }; 1854 1855 struct ionic_vf_getattr_comp { 1856 u8 status; 1857 u8 attr; 1858 __le16 vf_index; 1859 union { 1860 u8 macaddr[6]; 1861 __le16 vlanid; 1862 __le32 maxrate; 1863 u8 spoofchk; 1864 u8 trust; 1865 u8 linkstate; 1866 __le64 stats_pa; 1867 u8 pad[11]; 1868 } __packed; 1869 u8 color; 1870 }; 1871 1872 /** 1873 * struct ionic_qos_identify_cmd - QoS identify command 1874 * @opcode: opcode 1875 * @ver: Highest version of identify supported by driver 1876 * 1877 */ 1878 struct ionic_qos_identify_cmd { 1879 u8 opcode; 1880 u8 ver; 1881 u8 rsvd[62]; 1882 }; 1883 1884 /** 1885 * struct ionic_qos_identify_comp - QoS identify command completion 1886 * @status: Status of the command (enum ionic_status_code) 1887 * @ver: Version of identify returned by device 1888 */ 1889 struct ionic_qos_identify_comp { 1890 u8 status; 1891 u8 ver; 1892 u8 rsvd[14]; 1893 }; 1894 1895 #define IONIC_QOS_TC_MAX 8 1896 #define IONIC_QOS_ALL_TC 0xFF 1897 /* Capri max supported, should be renamed. */ 1898 #define IONIC_QOS_CLASS_MAX 7 1899 #define IONIC_QOS_PCP_MAX 8 1900 #define IONIC_QOS_CLASS_NAME_SZ 32 1901 #define IONIC_QOS_DSCP_MAX 64 1902 #define IONIC_QOS_ALL_PCP 0xFF 1903 #define IONIC_DSCP_BLOCK_SIZE 8 1904 1905 /** 1906 * enum ionic_qos_class 1907 */ 1908 enum ionic_qos_class { 1909 IONIC_QOS_CLASS_DEFAULT = 0, 1910 IONIC_QOS_CLASS_USER_DEFINED_1 = 1, 1911 IONIC_QOS_CLASS_USER_DEFINED_2 = 2, 1912 IONIC_QOS_CLASS_USER_DEFINED_3 = 3, 1913 IONIC_QOS_CLASS_USER_DEFINED_4 = 4, 1914 IONIC_QOS_CLASS_USER_DEFINED_5 = 5, 1915 IONIC_QOS_CLASS_USER_DEFINED_6 = 6, 1916 }; 1917 1918 /** 1919 * enum ionic_qos_class_type - Traffic classification criteria 1920 * @IONIC_QOS_CLASS_TYPE_NONE: No QoS 1921 * @IONIC_QOS_CLASS_TYPE_PCP: Dot1Q PCP 1922 * @IONIC_QOS_CLASS_TYPE_DSCP: IP DSCP 1923 */ 1924 enum ionic_qos_class_type { 1925 IONIC_QOS_CLASS_TYPE_NONE = 0, 1926 IONIC_QOS_CLASS_TYPE_PCP = 1, 1927 IONIC_QOS_CLASS_TYPE_DSCP = 2, 1928 }; 1929 1930 /** 1931 * enum ionic_qos_sched_type - QoS class scheduling type 1932 * @IONIC_QOS_SCHED_TYPE_STRICT: Strict priority 1933 * @IONIC_QOS_SCHED_TYPE_DWRR: Deficit weighted round-robin 1934 */ 1935 enum ionic_qos_sched_type { 1936 IONIC_QOS_SCHED_TYPE_STRICT = 0, 1937 IONIC_QOS_SCHED_TYPE_DWRR = 1, 1938 }; 1939 1940 /** 1941 * union ionic_qos_config - QoS configuration structure 1942 * @flags: Configuration flags 1943 * IONIC_QOS_CONFIG_F_ENABLE enable 1944 * IONIC_QOS_CONFIG_F_NO_DROP drop/nodrop 1945 * IONIC_QOS_CONFIG_F_RW_DOT1Q_PCP enable dot1q pcp rewrite 1946 * IONIC_QOS_CONFIG_F_RW_IP_DSCP enable ip dscp rewrite 1947 * IONIC_QOS_CONFIG_F_NON_DISRUPTIVE Non-disruptive TC update 1948 * @sched_type: QoS class scheduling type (enum ionic_qos_sched_type) 1949 * @class_type: QoS class type (enum ionic_qos_class_type) 1950 * @pause_type: QoS pause type (enum ionic_qos_pause_type) 1951 * @name: QoS class name 1952 * @mtu: MTU of the class 1953 * @pfc_cos: Priority-Flow Control class of service 1954 * @dwrr_weight: QoS class scheduling weight 1955 * @strict_rlmt: Rate limit for strict priority scheduling 1956 * @rw_dot1q_pcp: Rewrite dot1q pcp to value (valid iff F_RW_DOT1Q_PCP) 1957 * @rw_ip_dscp: Rewrite ip dscp to value (valid iff F_RW_IP_DSCP) 1958 * @dot1q_pcp: Dot1q pcp value 1959 * @ndscp: Number of valid dscp values in the ip_dscp field 1960 * @ip_dscp: IP dscp values 1961 */ 1962 union ionic_qos_config { 1963 struct { 1964 #define IONIC_QOS_CONFIG_F_ENABLE BIT(0) 1965 #define IONIC_QOS_CONFIG_F_NO_DROP BIT(1) 1966 /* Used to rewrite PCP or DSCP value. */ 1967 #define IONIC_QOS_CONFIG_F_RW_DOT1Q_PCP BIT(2) 1968 #define IONIC_QOS_CONFIG_F_RW_IP_DSCP BIT(3) 1969 /* Non-disruptive TC update */ 1970 #define IONIC_QOS_CONFIG_F_NON_DISRUPTIVE BIT(4) 1971 u8 flags; 1972 u8 sched_type; 1973 u8 class_type; 1974 u8 pause_type; 1975 char name[IONIC_QOS_CLASS_NAME_SZ]; 1976 __le32 mtu; 1977 /* flow control */ 1978 u8 pfc_cos; 1979 /* scheduler */ 1980 union { 1981 u8 dwrr_weight; 1982 __le64 strict_rlmt; 1983 }; 1984 /* marking */ 1985 /* Used to rewrite PCP or DSCP value. */ 1986 union { 1987 u8 rw_dot1q_pcp; 1988 u8 rw_ip_dscp; 1989 }; 1990 /* classification */ 1991 union { 1992 u8 dot1q_pcp; 1993 struct { 1994 u8 ndscp; 1995 u8 ip_dscp[IONIC_QOS_DSCP_MAX]; 1996 }; 1997 }; 1998 }; 1999 __le32 words[64]; 2000 }; 2001 2002 /** 2003 * union ionic_qos_identity - QoS identity structure 2004 * @version: Version of the identify structure 2005 * @type: QoS system type 2006 * @nclasses: Number of usable QoS classes 2007 * @config: Current configuration of classes 2008 */ 2009 union ionic_qos_identity { 2010 struct { 2011 u8 version; 2012 u8 type; 2013 u8 rsvd[62]; 2014 union ionic_qos_config config[IONIC_QOS_CLASS_MAX]; 2015 }; 2016 __le32 words[478]; 2017 }; 2018 2019 /** 2020 * struct ionic_qos_init_cmd - QoS config init command 2021 * @opcode: Opcode 2022 * @group: QoS class id 2023 * @info_pa: destination address for qos info 2024 */ 2025 struct ionic_qos_init_cmd { 2026 u8 opcode; 2027 u8 group; 2028 u8 rsvd[6]; 2029 __le64 info_pa; 2030 u8 rsvd1[48]; 2031 }; 2032 2033 typedef struct ionic_admin_comp ionic_qos_init_comp; 2034 2035 /** 2036 * struct ionic_qos_reset_cmd - QoS config reset command 2037 * @opcode: Opcode 2038 * @group: QoS class id 2039 */ 2040 struct ionic_qos_reset_cmd { 2041 u8 opcode; 2042 u8 group; 2043 u8 rsvd[62]; 2044 }; 2045 2046 /** 2047 * struct ionic_qos_clear_port_stats_cmd - Qos config reset command 2048 * @opcode: Opcode 2049 */ 2050 struct ionic_qos_clear_stats_cmd { 2051 u8 opcode; 2052 u8 group_bitmap; 2053 u8 rsvd[62]; 2054 }; 2055 2056 typedef struct ionic_admin_comp ionic_qos_reset_comp; 2057 2058 /** 2059 * struct ionic_fw_download_cmd - Firmware download command 2060 * @opcode: opcode 2061 * @addr: dma address of the firmware buffer 2062 * @offset: offset of the firmware buffer within the full image 2063 * @length: number of valid bytes in the firmware buffer 2064 */ 2065 struct ionic_fw_download_cmd { 2066 u8 opcode; 2067 u8 rsvd[3]; 2068 __le32 offset; 2069 __le64 addr; 2070 __le32 length; 2071 }; 2072 2073 typedef struct ionic_admin_comp ionic_fw_download_comp; 2074 2075 /** 2076 * enum ionic_fw_control_oper - FW control operations 2077 * @IONIC_FW_RESET: Reset firmware 2078 * @IONIC_FW_INSTALL: Install firmware 2079 * @IONIC_FW_ACTIVATE: Activate firmware 2080 * @IONIC_FW_INSTALL_ASYNC: Install firmware asynchronously 2081 * @IONIC_FW_INSTALL_STATUS: Firmware installation status 2082 * @IONIC_FW_ACTIVATE_ASYNC: Activate firmware asynchronously 2083 * @IONIC_FW_ACTIVATE_STATUS: Firmware activate status 2084 */ 2085 enum ionic_fw_control_oper { 2086 IONIC_FW_RESET = 0, 2087 IONIC_FW_INSTALL = 1, 2088 IONIC_FW_ACTIVATE = 2, 2089 IONIC_FW_INSTALL_ASYNC = 3, 2090 IONIC_FW_INSTALL_STATUS = 4, 2091 IONIC_FW_ACTIVATE_ASYNC = 5, 2092 IONIC_FW_ACTIVATE_STATUS = 6, 2093 IONIC_FW_UPDATE_CLEANUP = 7, 2094 }; 2095 2096 /** 2097 * struct ionic_fw_control_cmd - Firmware control command 2098 * @opcode: opcode 2099 * @oper: firmware control operation (enum ionic_fw_control_oper) 2100 * @slot: slot to activate 2101 */ 2102 struct ionic_fw_control_cmd { 2103 u8 opcode; 2104 u8 rsvd[3]; 2105 u8 oper; 2106 u8 slot; 2107 u8 rsvd1[58]; 2108 }; 2109 2110 /** 2111 * struct ionic_fw_control_comp - Firmware control copletion 2112 * @status: Status of the command (enum ionic_status_code) 2113 * @comp_index: Index in the descriptor ring for which this is the completion 2114 * @slot: Slot where the firmware was installed 2115 * @color: Color bit 2116 */ 2117 struct ionic_fw_control_comp { 2118 u8 status; 2119 u8 rsvd; 2120 __le16 comp_index; 2121 u8 slot; 2122 u8 rsvd1[10]; 2123 u8 color; 2124 }; 2125 2126 /****************************************************************** 2127 ******************* RDMA Commands ******************************** 2128 ******************************************************************/ 2129 2130 /** 2131 * struct ionic_rdma_reset_cmd - Reset RDMA LIF cmd 2132 * @opcode: opcode 2133 * @lif_index: LIF index 2134 * 2135 * There is no RDMA specific dev command completion struct. Completion uses 2136 * the common struct ionic_admin_comp. Only the status is indicated. 2137 * Nonzero status means the LIF does not support RDMA. 2138 **/ 2139 struct ionic_rdma_reset_cmd { 2140 u8 opcode; 2141 u8 rsvd; 2142 __le16 lif_index; 2143 u8 rsvd2[60]; 2144 }; 2145 2146 /** 2147 * struct ionic_rdma_queue_cmd - Create RDMA Queue command 2148 * @opcode: opcode, 52, 53 2149 * @lif_index: LIF index 2150 * @qid_ver: (qid | (RDMA version << 24)) 2151 * @cid: intr, eq_id, or cq_id 2152 * @dbid: doorbell page id 2153 * @depth_log2: log base two of queue depth 2154 * @stride_log2: log base two of queue stride 2155 * @dma_addr: address of the queue memory 2156 * 2157 * The same command struct is used to create an RDMA event queue, completion 2158 * queue, or RDMA admin queue. The cid is an interrupt number for an event 2159 * queue, an event queue id for a completion queue, or a completion queue id 2160 * for an RDMA admin queue. 2161 * 2162 * The queue created via a dev command must be contiguous in dma space. 2163 * 2164 * The dev commands are intended only to be used during driver initialization, 2165 * to create queues supporting the RDMA admin queue. Other queues, and other 2166 * types of RDMA resources like memory regions, will be created and registered 2167 * via the RDMA admin queue, and will support a more complete interface 2168 * providing scatter gather lists for larger, scattered queue buffers and 2169 * memory registration. 2170 * 2171 * There is no RDMA specific dev command completion struct. Completion uses 2172 * the common struct ionic_admin_comp. Only the status is indicated. 2173 **/ 2174 struct ionic_rdma_queue_cmd { 2175 u8 opcode; 2176 u8 rsvd; 2177 __le16 lif_index; 2178 __le32 qid_ver; 2179 __le32 cid; 2180 __le16 dbid; 2181 u8 depth_log2; 2182 u8 stride_log2; 2183 __le64 dma_addr; 2184 u8 rsvd2[40]; 2185 }; 2186 2187 /****************************************************************** 2188 ******************* Notify Events ******************************** 2189 ******************************************************************/ 2190 2191 /** 2192 * struct ionic_notifyq_event - Generic event reporting structure 2193 * @eid: event number 2194 * @ecode: event code 2195 * @data: unspecified data about the event 2196 * 2197 * This is the generic event report struct from which the other 2198 * actual events will be formed. 2199 */ 2200 struct ionic_notifyq_event { 2201 __le64 eid; 2202 __le16 ecode; 2203 u8 data[54]; 2204 }; 2205 2206 /** 2207 * struct ionic_link_change_event - Link change event notification 2208 * @eid: event number 2209 * @ecode: event code = IONIC_EVENT_LINK_CHANGE 2210 * @link_status: link up/down, with error bits (enum ionic_port_status) 2211 * @link_speed: speed of the network link 2212 * 2213 * Sent when the network link state changes between UP and DOWN 2214 */ 2215 struct ionic_link_change_event { 2216 __le64 eid; 2217 __le16 ecode; 2218 __le16 link_status; 2219 __le32 link_speed; /* units of 1Mbps: e.g. 10000 = 10Gbps */ 2220 u8 rsvd[48]; 2221 }; 2222 2223 /** 2224 * struct ionic_reset_event - Reset event notification 2225 * @eid: event number 2226 * @ecode: event code = IONIC_EVENT_RESET 2227 * @reset_code: reset type 2228 * @state: 0=pending, 1=complete, 2=error 2229 * 2230 * Sent when the NIC or some subsystem is going to be or 2231 * has been reset. 2232 */ 2233 struct ionic_reset_event { 2234 __le64 eid; 2235 __le16 ecode; 2236 u8 reset_code; 2237 u8 state; 2238 u8 rsvd[52]; 2239 }; 2240 2241 /** 2242 * struct ionic_heartbeat_event - Sent periodically by NIC to indicate health 2243 * @eid: event number 2244 * @ecode: event code = IONIC_EVENT_HEARTBEAT 2245 */ 2246 struct ionic_heartbeat_event { 2247 __le64 eid; 2248 __le16 ecode; 2249 u8 rsvd[54]; 2250 }; 2251 2252 /** 2253 * struct ionic_log_event - Sent to notify the driver of an internal error 2254 * @eid: event number 2255 * @ecode: event code = IONIC_EVENT_LOG 2256 * @data: log data 2257 */ 2258 struct ionic_log_event { 2259 __le64 eid; 2260 __le16 ecode; 2261 u8 data[54]; 2262 }; 2263 2264 /** 2265 * struct ionic_xcvr_event - Transceiver change event 2266 * @eid: event number 2267 * @ecode: event code = IONIC_EVENT_XCVR 2268 */ 2269 struct ionic_xcvr_event { 2270 __le64 eid; 2271 __le16 ecode; 2272 u8 rsvd[54]; 2273 }; 2274 2275 /** 2276 * struct ionic_port_stats - Port statistics structure 2277 */ 2278 struct ionic_port_stats { 2279 __le64 frames_rx_ok; 2280 __le64 frames_rx_all; 2281 __le64 frames_rx_bad_fcs; 2282 __le64 frames_rx_bad_all; 2283 __le64 octets_rx_ok; 2284 __le64 octets_rx_all; 2285 __le64 frames_rx_unicast; 2286 __le64 frames_rx_multicast; 2287 __le64 frames_rx_broadcast; 2288 __le64 frames_rx_pause; 2289 __le64 frames_rx_bad_length; 2290 __le64 frames_rx_undersized; 2291 __le64 frames_rx_oversized; 2292 __le64 frames_rx_fragments; 2293 __le64 frames_rx_jabber; 2294 __le64 frames_rx_pripause; 2295 __le64 frames_rx_stomped_crc; 2296 __le64 frames_rx_too_long; 2297 __le64 frames_rx_vlan_good; 2298 __le64 frames_rx_dropped; 2299 __le64 frames_rx_less_than_64b; 2300 __le64 frames_rx_64b; 2301 __le64 frames_rx_65b_127b; 2302 __le64 frames_rx_128b_255b; 2303 __le64 frames_rx_256b_511b; 2304 __le64 frames_rx_512b_1023b; 2305 __le64 frames_rx_1024b_1518b; 2306 __le64 frames_rx_1519b_2047b; 2307 __le64 frames_rx_2048b_4095b; 2308 __le64 frames_rx_4096b_8191b; 2309 __le64 frames_rx_8192b_9215b; 2310 __le64 frames_rx_other; 2311 __le64 frames_tx_ok; 2312 __le64 frames_tx_all; 2313 __le64 frames_tx_bad; 2314 __le64 octets_tx_ok; 2315 __le64 octets_tx_total; 2316 __le64 frames_tx_unicast; 2317 __le64 frames_tx_multicast; 2318 __le64 frames_tx_broadcast; 2319 __le64 frames_tx_pause; 2320 __le64 frames_tx_pripause; 2321 __le64 frames_tx_vlan; 2322 __le64 frames_tx_less_than_64b; 2323 __le64 frames_tx_64b; 2324 __le64 frames_tx_65b_127b; 2325 __le64 frames_tx_128b_255b; 2326 __le64 frames_tx_256b_511b; 2327 __le64 frames_tx_512b_1023b; 2328 __le64 frames_tx_1024b_1518b; 2329 __le64 frames_tx_1519b_2047b; 2330 __le64 frames_tx_2048b_4095b; 2331 __le64 frames_tx_4096b_8191b; 2332 __le64 frames_tx_8192b_9215b; 2333 __le64 frames_tx_other; 2334 __le64 frames_tx_pri_0; 2335 __le64 frames_tx_pri_1; 2336 __le64 frames_tx_pri_2; 2337 __le64 frames_tx_pri_3; 2338 __le64 frames_tx_pri_4; 2339 __le64 frames_tx_pri_5; 2340 __le64 frames_tx_pri_6; 2341 __le64 frames_tx_pri_7; 2342 __le64 frames_rx_pri_0; 2343 __le64 frames_rx_pri_1; 2344 __le64 frames_rx_pri_2; 2345 __le64 frames_rx_pri_3; 2346 __le64 frames_rx_pri_4; 2347 __le64 frames_rx_pri_5; 2348 __le64 frames_rx_pri_6; 2349 __le64 frames_rx_pri_7; 2350 __le64 tx_pripause_0_1us_count; 2351 __le64 tx_pripause_1_1us_count; 2352 __le64 tx_pripause_2_1us_count; 2353 __le64 tx_pripause_3_1us_count; 2354 __le64 tx_pripause_4_1us_count; 2355 __le64 tx_pripause_5_1us_count; 2356 __le64 tx_pripause_6_1us_count; 2357 __le64 tx_pripause_7_1us_count; 2358 __le64 rx_pripause_0_1us_count; 2359 __le64 rx_pripause_1_1us_count; 2360 __le64 rx_pripause_2_1us_count; 2361 __le64 rx_pripause_3_1us_count; 2362 __le64 rx_pripause_4_1us_count; 2363 __le64 rx_pripause_5_1us_count; 2364 __le64 rx_pripause_6_1us_count; 2365 __le64 rx_pripause_7_1us_count; 2366 __le64 rx_pause_1us_count; 2367 __le64 frames_tx_truncated; 2368 }; 2369 2370 struct ionic_mgmt_port_stats { 2371 __le64 frames_rx_ok; 2372 __le64 frames_rx_all; 2373 __le64 frames_rx_bad_fcs; 2374 __le64 frames_rx_bad_all; 2375 __le64 octets_rx_ok; 2376 __le64 octets_rx_all; 2377 __le64 frames_rx_unicast; 2378 __le64 frames_rx_multicast; 2379 __le64 frames_rx_broadcast; 2380 __le64 frames_rx_pause; 2381 __le64 frames_rx_bad_length; 2382 __le64 frames_rx_undersized; 2383 __le64 frames_rx_oversized; 2384 __le64 frames_rx_fragments; 2385 __le64 frames_rx_jabber; 2386 __le64 frames_rx_64b; 2387 __le64 frames_rx_65b_127b; 2388 __le64 frames_rx_128b_255b; 2389 __le64 frames_rx_256b_511b; 2390 __le64 frames_rx_512b_1023b; 2391 __le64 frames_rx_1024b_1518b; 2392 __le64 frames_rx_gt_1518b; 2393 __le64 frames_rx_fifo_full; 2394 __le64 frames_tx_ok; 2395 __le64 frames_tx_all; 2396 __le64 frames_tx_bad; 2397 __le64 octets_tx_ok; 2398 __le64 octets_tx_total; 2399 __le64 frames_tx_unicast; 2400 __le64 frames_tx_multicast; 2401 __le64 frames_tx_broadcast; 2402 __le64 frames_tx_pause; 2403 }; 2404 2405 enum ionic_pb_buffer_drop_stats { 2406 IONIC_BUFFER_INTRINSIC_DROP = 0, 2407 IONIC_BUFFER_DISCARDED, 2408 IONIC_BUFFER_ADMITTED, 2409 IONIC_BUFFER_OUT_OF_CELLS_DROP, 2410 IONIC_BUFFER_OUT_OF_CELLS_DROP_2, 2411 IONIC_BUFFER_OUT_OF_CREDIT_DROP, 2412 IONIC_BUFFER_TRUNCATION_DROP, 2413 IONIC_BUFFER_PORT_DISABLED_DROP, 2414 IONIC_BUFFER_COPY_TO_CPU_TAIL_DROP, 2415 IONIC_BUFFER_SPAN_TAIL_DROP, 2416 IONIC_BUFFER_MIN_SIZE_VIOLATION_DROP, 2417 IONIC_BUFFER_ENQUEUE_ERROR_DROP, 2418 IONIC_BUFFER_INVALID_PORT_DROP, 2419 IONIC_BUFFER_INVALID_OUTPUT_QUEUE_DROP, 2420 IONIC_BUFFER_DROP_MAX, 2421 }; 2422 2423 enum ionic_oflow_drop_stats { 2424 IONIC_OFLOW_OCCUPANCY_DROP, 2425 IONIC_OFLOW_EMERGENCY_STOP_DROP, 2426 IONIC_OFLOW_WRITE_BUFFER_ACK_FILL_UP_DROP, 2427 IONIC_OFLOW_WRITE_BUFFER_ACK_FULL_DROP, 2428 IONIC_OFLOW_WRITE_BUFFER_FULL_DROP, 2429 IONIC_OFLOW_CONTROL_FIFO_FULL_DROP, 2430 IONIC_OFLOW_DROP_MAX, 2431 }; 2432 2433 /** 2434 * struct port_pb_stats - packet buffers system stats 2435 * uses ionic_pb_buffer_drop_stats for drop_counts[] 2436 */ 2437 struct ionic_port_pb_stats { 2438 __le64 sop_count_in; 2439 __le64 eop_count_in; 2440 __le64 sop_count_out; 2441 __le64 eop_count_out; 2442 __le64 drop_counts[IONIC_BUFFER_DROP_MAX]; 2443 __le64 input_queue_buffer_occupancy[IONIC_QOS_TC_MAX]; 2444 __le64 input_queue_port_monitor[IONIC_QOS_TC_MAX]; 2445 __le64 output_queue_port_monitor[IONIC_QOS_TC_MAX]; 2446 __le64 oflow_drop_counts[IONIC_OFLOW_DROP_MAX]; 2447 __le64 input_queue_good_pkts_in[IONIC_QOS_TC_MAX]; 2448 __le64 input_queue_good_pkts_out[IONIC_QOS_TC_MAX]; 2449 __le64 input_queue_err_pkts_in[IONIC_QOS_TC_MAX]; 2450 __le64 input_queue_fifo_depth[IONIC_QOS_TC_MAX]; 2451 __le64 input_queue_max_fifo_depth[IONIC_QOS_TC_MAX]; 2452 __le64 input_queue_peak_occupancy[IONIC_QOS_TC_MAX]; 2453 __le64 output_queue_buffer_occupancy[IONIC_QOS_TC_MAX]; 2454 }; 2455 2456 /** 2457 * struct ionic_port_identity - port identity structure 2458 * @version: identity structure version 2459 * @type: type of port (enum ionic_port_type) 2460 * @num_lanes: number of lanes for the port 2461 * @autoneg: autoneg supported 2462 * @min_frame_size: minimum frame size supported 2463 * @max_frame_size: maximum frame size supported 2464 * @fec_type: supported fec types 2465 * @pause_type: supported pause types 2466 * @loopback_mode: supported loopback mode 2467 * @speeds: supported speeds 2468 * @config: current port configuration 2469 */ 2470 union ionic_port_identity { 2471 struct { 2472 u8 version; 2473 u8 type; 2474 u8 num_lanes; 2475 u8 autoneg; 2476 __le32 min_frame_size; 2477 __le32 max_frame_size; 2478 u8 fec_type[4]; 2479 u8 pause_type[2]; 2480 u8 loopback_mode[2]; 2481 __le32 speeds[16]; 2482 u8 rsvd2[44]; 2483 union ionic_port_config config; 2484 }; 2485 __le32 words[478]; 2486 }; 2487 2488 /** 2489 * struct ionic_port_info - port info structure 2490 * @config: Port configuration data 2491 * @status: Port status data 2492 * @stats: Port statistics data 2493 * @mgmt_stats: Port management statistics data 2494 * @port_pb_drop_stats: uplink pb drop stats 2495 */ 2496 struct ionic_port_info { 2497 union ionic_port_config config; 2498 struct ionic_port_status status; 2499 union { 2500 struct ionic_port_stats stats; 2501 struct ionic_mgmt_port_stats mgmt_stats; 2502 }; 2503 /* room for pb_stats to start at 2k offset */ 2504 u8 rsvd[760]; 2505 struct ionic_port_pb_stats pb_stats; 2506 }; 2507 2508 /** 2509 * struct ionic_lif_stats - LIF statistics structure 2510 */ 2511 struct ionic_lif_stats { 2512 /* RX */ 2513 __le64 rx_ucast_bytes; 2514 __le64 rx_ucast_packets; 2515 __le64 rx_mcast_bytes; 2516 __le64 rx_mcast_packets; 2517 __le64 rx_bcast_bytes; 2518 __le64 rx_bcast_packets; 2519 __le64 rsvd0; 2520 __le64 rsvd1; 2521 /* RX drops */ 2522 __le64 rx_ucast_drop_bytes; 2523 __le64 rx_ucast_drop_packets; 2524 __le64 rx_mcast_drop_bytes; 2525 __le64 rx_mcast_drop_packets; 2526 __le64 rx_bcast_drop_bytes; 2527 __le64 rx_bcast_drop_packets; 2528 __le64 rx_dma_error; 2529 __le64 rsvd2; 2530 /* TX */ 2531 __le64 tx_ucast_bytes; 2532 __le64 tx_ucast_packets; 2533 __le64 tx_mcast_bytes; 2534 __le64 tx_mcast_packets; 2535 __le64 tx_bcast_bytes; 2536 __le64 tx_bcast_packets; 2537 __le64 rsvd3; 2538 __le64 rsvd4; 2539 /* TX drops */ 2540 __le64 tx_ucast_drop_bytes; 2541 __le64 tx_ucast_drop_packets; 2542 __le64 tx_mcast_drop_bytes; 2543 __le64 tx_mcast_drop_packets; 2544 __le64 tx_bcast_drop_bytes; 2545 __le64 tx_bcast_drop_packets; 2546 __le64 tx_dma_error; 2547 __le64 rsvd5; 2548 /* Rx Queue/Ring drops */ 2549 __le64 rx_queue_disabled; 2550 __le64 rx_queue_empty; 2551 __le64 rx_queue_error; 2552 __le64 rx_desc_fetch_error; 2553 __le64 rx_desc_data_error; 2554 __le64 rsvd6; 2555 __le64 rsvd7; 2556 __le64 rsvd8; 2557 /* Tx Queue/Ring drops */ 2558 __le64 tx_queue_disabled; 2559 __le64 tx_queue_error; 2560 __le64 tx_desc_fetch_error; 2561 __le64 tx_desc_data_error; 2562 __le64 tx_queue_empty; 2563 __le64 rsvd10; 2564 __le64 rsvd11; 2565 __le64 rsvd12; 2566 2567 /* RDMA/ROCE TX */ 2568 __le64 tx_rdma_ucast_bytes; 2569 __le64 tx_rdma_ucast_packets; 2570 __le64 tx_rdma_mcast_bytes; 2571 __le64 tx_rdma_mcast_packets; 2572 __le64 tx_rdma_cnp_packets; 2573 __le64 rsvd13; 2574 __le64 rsvd14; 2575 __le64 rsvd15; 2576 2577 /* RDMA/ROCE RX */ 2578 __le64 rx_rdma_ucast_bytes; 2579 __le64 rx_rdma_ucast_packets; 2580 __le64 rx_rdma_mcast_bytes; 2581 __le64 rx_rdma_mcast_packets; 2582 __le64 rx_rdma_cnp_packets; 2583 __le64 rx_rdma_ecn_packets; 2584 __le64 rsvd16; 2585 __le64 rsvd17; 2586 2587 __le64 rsvd18; 2588 __le64 rsvd19; 2589 __le64 rsvd20; 2590 __le64 rsvd21; 2591 __le64 rsvd22; 2592 __le64 rsvd23; 2593 __le64 rsvd24; 2594 __le64 rsvd25; 2595 2596 __le64 rsvd26; 2597 __le64 rsvd27; 2598 __le64 rsvd28; 2599 __le64 rsvd29; 2600 __le64 rsvd30; 2601 __le64 rsvd31; 2602 __le64 rsvd32; 2603 __le64 rsvd33; 2604 2605 __le64 rsvd34; 2606 __le64 rsvd35; 2607 __le64 rsvd36; 2608 __le64 rsvd37; 2609 __le64 rsvd38; 2610 __le64 rsvd39; 2611 __le64 rsvd40; 2612 __le64 rsvd41; 2613 2614 __le64 rsvd42; 2615 __le64 rsvd43; 2616 __le64 rsvd44; 2617 __le64 rsvd45; 2618 __le64 rsvd46; 2619 __le64 rsvd47; 2620 __le64 rsvd48; 2621 __le64 rsvd49; 2622 2623 /* RDMA/ROCE REQ Error/Debugs (768 - 895) */ 2624 __le64 rdma_req_rx_pkt_seq_err; 2625 __le64 rdma_req_rx_rnr_retry_err; 2626 __le64 rdma_req_rx_remote_access_err; 2627 __le64 rdma_req_rx_remote_inv_req_err; 2628 __le64 rdma_req_rx_remote_oper_err; 2629 __le64 rdma_req_rx_implied_nak_seq_err; 2630 __le64 rdma_req_rx_cqe_err; 2631 __le64 rdma_req_rx_cqe_flush_err; 2632 2633 __le64 rdma_req_rx_dup_responses; 2634 __le64 rdma_req_rx_invalid_packets; 2635 __le64 rdma_req_tx_local_access_err; 2636 __le64 rdma_req_tx_local_oper_err; 2637 __le64 rdma_req_tx_memory_mgmt_err; 2638 __le64 rsvd52; 2639 __le64 rsvd53; 2640 __le64 rsvd54; 2641 2642 /* RDMA/ROCE RESP Error/Debugs (896 - 1023) */ 2643 __le64 rdma_resp_rx_dup_requests; 2644 __le64 rdma_resp_rx_out_of_buffer; 2645 __le64 rdma_resp_rx_out_of_seq_pkts; 2646 __le64 rdma_resp_rx_cqe_err; 2647 __le64 rdma_resp_rx_cqe_flush_err; 2648 __le64 rdma_resp_rx_local_len_err; 2649 __le64 rdma_resp_rx_inv_request_err; 2650 __le64 rdma_resp_rx_local_qp_oper_err; 2651 2652 __le64 rdma_resp_rx_out_of_atomic_resource; 2653 __le64 rdma_resp_tx_pkt_seq_err; 2654 __le64 rdma_resp_tx_remote_inv_req_err; 2655 __le64 rdma_resp_tx_remote_access_err; 2656 __le64 rdma_resp_tx_remote_oper_err; 2657 __le64 rdma_resp_tx_rnr_retry_err; 2658 __le64 rsvd57; 2659 __le64 rsvd58; 2660 }; 2661 2662 /** 2663 * struct ionic_lif_info - LIF info structure 2664 * @config: LIF configuration structure 2665 * @status: LIF status structure 2666 * @stats: LIF statistics structure 2667 */ 2668 struct ionic_lif_info { 2669 union ionic_lif_config config; 2670 struct ionic_lif_status status; 2671 struct ionic_lif_stats stats; 2672 }; 2673 2674 union ionic_dev_cmd { 2675 u32 words[16]; 2676 struct ionic_admin_cmd cmd; 2677 struct ionic_nop_cmd nop; 2678 2679 struct ionic_dev_identify_cmd identify; 2680 struct ionic_dev_init_cmd init; 2681 struct ionic_dev_reset_cmd reset; 2682 struct ionic_dev_getattr_cmd getattr; 2683 struct ionic_dev_setattr_cmd setattr; 2684 2685 struct ionic_port_identify_cmd port_identify; 2686 struct ionic_port_init_cmd port_init; 2687 struct ionic_port_reset_cmd port_reset; 2688 struct ionic_port_getattr_cmd port_getattr; 2689 struct ionic_port_setattr_cmd port_setattr; 2690 2691 struct ionic_vf_setattr_cmd vf_setattr; 2692 struct ionic_vf_getattr_cmd vf_getattr; 2693 2694 struct ionic_lif_identify_cmd lif_identify; 2695 struct ionic_lif_init_cmd lif_init; 2696 struct ionic_lif_reset_cmd lif_reset; 2697 2698 struct ionic_qos_identify_cmd qos_identify; 2699 struct ionic_qos_init_cmd qos_init; 2700 struct ionic_qos_reset_cmd qos_reset; 2701 struct ionic_qos_clear_stats_cmd qos_clear_stats; 2702 2703 struct ionic_q_identify_cmd q_identify; 2704 struct ionic_q_init_cmd q_init; 2705 struct ionic_q_control_cmd q_control; 2706 2707 struct ionic_fw_download_cmd fw_download; 2708 struct ionic_fw_control_cmd fw_control; 2709 }; 2710 2711 union ionic_dev_cmd_comp { 2712 u32 words[4]; 2713 u8 status; 2714 struct ionic_admin_comp comp; 2715 struct ionic_nop_comp nop; 2716 2717 struct ionic_dev_identify_comp identify; 2718 struct ionic_dev_init_comp init; 2719 struct ionic_dev_reset_comp reset; 2720 struct ionic_dev_getattr_comp getattr; 2721 struct ionic_dev_setattr_comp setattr; 2722 2723 struct ionic_port_identify_comp port_identify; 2724 struct ionic_port_init_comp port_init; 2725 struct ionic_port_reset_comp port_reset; 2726 struct ionic_port_getattr_comp port_getattr; 2727 struct ionic_port_setattr_comp port_setattr; 2728 2729 struct ionic_vf_setattr_comp vf_setattr; 2730 struct ionic_vf_getattr_comp vf_getattr; 2731 2732 struct ionic_lif_identify_comp lif_identify; 2733 struct ionic_lif_init_comp lif_init; 2734 ionic_lif_reset_comp lif_reset; 2735 2736 struct ionic_qos_identify_comp qos_identify; 2737 ionic_qos_init_comp qos_init; 2738 ionic_qos_reset_comp qos_reset; 2739 2740 struct ionic_q_identify_comp q_identify; 2741 struct ionic_q_init_comp q_init; 2742 2743 ionic_fw_download_comp fw_download; 2744 struct ionic_fw_control_comp fw_control; 2745 }; 2746 2747 /** 2748 * union ionic_dev_info_regs - Device info register format (read-only) 2749 * @signature: Signature value of 0x44455649 ('DEVI') 2750 * @version: Current version of info 2751 * @asic_type: Asic type 2752 * @asic_rev: Asic revision 2753 * @fw_status: Firmware status 2754 * @fw_heartbeat: Firmware heartbeat counter 2755 * @serial_num: Serial number 2756 * @fw_version: Firmware version 2757 */ 2758 union ionic_dev_info_regs { 2759 #define IONIC_DEVINFO_FWVERS_BUFLEN 32 2760 #define IONIC_DEVINFO_SERIAL_BUFLEN 32 2761 struct { 2762 u32 signature; 2763 u8 version; 2764 u8 asic_type; 2765 u8 asic_rev; 2766 #define IONIC_FW_STS_F_RUNNING 0x1 2767 u8 fw_status; 2768 u32 fw_heartbeat; 2769 char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN]; 2770 char serial_num[IONIC_DEVINFO_SERIAL_BUFLEN]; 2771 }; 2772 u32 words[512]; 2773 }; 2774 2775 /** 2776 * union ionic_dev_cmd_regs - Device command register format (read-write) 2777 * @doorbell: Device Cmd Doorbell, write-only 2778 * Write a 1 to signal device to process cmd, 2779 * poll done for completion. 2780 * @done: Done indicator, bit 0 == 1 when command is complete 2781 * @cmd: Opcode-specific command bytes 2782 * @comp: Opcode-specific response bytes 2783 * @data: Opcode-specific side-data 2784 */ 2785 union ionic_dev_cmd_regs { 2786 struct { 2787 u32 doorbell; 2788 u32 done; 2789 union ionic_dev_cmd cmd; 2790 union ionic_dev_cmd_comp comp; 2791 u8 rsvd[48]; 2792 u32 data[478]; 2793 } __packed; 2794 u32 words[512]; 2795 }; 2796 2797 /** 2798 * union ionic_dev_regs - Device register format for bar 0 page 0 2799 * @info: Device info registers 2800 * @devcmd: Device command registers 2801 */ 2802 union ionic_dev_regs { 2803 struct { 2804 union ionic_dev_info_regs info; 2805 union ionic_dev_cmd_regs devcmd; 2806 } __packed; 2807 __le32 words[1024]; 2808 }; 2809 2810 union ionic_adminq_cmd { 2811 struct ionic_admin_cmd cmd; 2812 struct ionic_nop_cmd nop; 2813 struct ionic_q_identify_cmd q_identify; 2814 struct ionic_q_init_cmd q_init; 2815 struct ionic_q_control_cmd q_control; 2816 struct ionic_lif_setattr_cmd lif_setattr; 2817 struct ionic_lif_getattr_cmd lif_getattr; 2818 struct ionic_rx_mode_set_cmd rx_mode_set; 2819 struct ionic_rx_filter_add_cmd rx_filter_add; 2820 struct ionic_rx_filter_del_cmd rx_filter_del; 2821 struct ionic_rdma_reset_cmd rdma_reset; 2822 struct ionic_rdma_queue_cmd rdma_queue; 2823 struct ionic_fw_download_cmd fw_download; 2824 struct ionic_fw_control_cmd fw_control; 2825 }; 2826 2827 union ionic_adminq_comp { 2828 struct ionic_admin_comp comp; 2829 struct ionic_nop_comp nop; 2830 struct ionic_q_identify_comp q_identify; 2831 struct ionic_q_init_comp q_init; 2832 struct ionic_lif_setattr_comp lif_setattr; 2833 struct ionic_lif_getattr_comp lif_getattr; 2834 struct ionic_rx_filter_add_comp rx_filter_add; 2835 struct ionic_fw_control_comp fw_control; 2836 }; 2837 2838 #define IONIC_BARS_MAX 6 2839 #define IONIC_PCI_BAR_DBELL 1 2840 2841 /* BAR0 */ 2842 #define IONIC_BAR0_SIZE 0x8000 2843 2844 #define IONIC_BAR0_DEV_INFO_REGS_OFFSET 0x0000 2845 #define IONIC_BAR0_DEV_CMD_REGS_OFFSET 0x0800 2846 #define IONIC_BAR0_DEV_CMD_DATA_REGS_OFFSET 0x0c00 2847 #define IONIC_BAR0_INTR_STATUS_OFFSET 0x1000 2848 #define IONIC_BAR0_INTR_CTRL_OFFSET 0x2000 2849 #define IONIC_DEV_CMD_DONE 0x00000001 2850 2851 #define IONIC_ASIC_TYPE_CAPRI 0 2852 2853 /** 2854 * struct ionic_doorbell - Doorbell register layout 2855 * @p_index: Producer index 2856 * @ring: Selects the specific ring of the queue to update 2857 * Type-specific meaning: 2858 * ring=0: Default producer/consumer queue 2859 * ring=1: (CQ, EQ) Re-Arm queue. RDMA CQs 2860 * send events to EQs when armed. EQs send 2861 * interrupts when armed. 2862 * @qid_lo: Queue destination for the producer index and flags (low bits) 2863 * @qid_hi: Queue destination for the producer index and flags (high bits) 2864 */ 2865 struct ionic_doorbell { 2866 __le16 p_index; 2867 u8 ring; 2868 u8 qid_lo; 2869 __le16 qid_hi; 2870 u16 rsvd2; 2871 }; 2872 2873 struct ionic_intr_status { 2874 u32 status[2]; 2875 }; 2876 2877 struct ionic_notifyq_cmd { 2878 __le32 data; /* Not used but needed for qcq structure */ 2879 }; 2880 2881 union ionic_notifyq_comp { 2882 struct ionic_notifyq_event event; 2883 struct ionic_link_change_event link_change; 2884 struct ionic_reset_event reset; 2885 struct ionic_heartbeat_event heartbeat; 2886 struct ionic_log_event log; 2887 }; 2888 2889 /* Deprecate */ 2890 struct ionic_identity { 2891 union ionic_drv_identity drv; 2892 union ionic_dev_identity dev; 2893 union ionic_lif_identity lif; 2894 union ionic_port_identity port; 2895 union ionic_qos_identity qos; 2896 union ionic_q_identity txq; 2897 }; 2898 2899 #endif /* _IONIC_IF_H_ */ 2900