1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB OR BSD-3-Clause */
2 /* Copyright (c) 2017-2020 Pensando Systems, Inc. All rights reserved. */
7 #define IONIC_DEV_INFO_SIGNATURE 0x44455649 /* 'DEVI' */
8 #define IONIC_DEV_INFO_VERSION 1
9 #define IONIC_IFNAMSIZ 16
12 * enum ionic_cmd_opcode - Device commands
14 enum ionic_cmd_opcode {
18 IONIC_CMD_IDENTIFY = 1,
21 IONIC_CMD_GETATTR = 4,
22 IONIC_CMD_SETATTR = 5,
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,
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,
38 IONIC_CMD_RX_MODE_SET = 30,
39 IONIC_CMD_RX_FILTER_ADD = 31,
40 IONIC_CMD_RX_FILTER_DEL = 32,
43 IONIC_CMD_Q_IDENTIFY = 39,
44 IONIC_CMD_Q_INIT = 40,
45 IONIC_CMD_Q_CONTROL = 41,
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,
54 IONIC_CMD_VF_GETATTR = 60,
55 IONIC_CMD_VF_SETATTR = 61,
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,
65 /* Firmware commands */
66 IONIC_CMD_FW_DOWNLOAD = 254,
67 IONIC_CMD_FW_CONTROL = 255,
71 * enum ionic_status_code - Device command return codes
73 enum ionic_status_code {
74 IONIC_RC_SUCCESS = 0, /* Success */
75 IONIC_RC_EVERSION = 1, /* Incorrect version for request */
76 IONIC_RC_EOPCODE = 2, /* Invalid cmd opcode */
77 IONIC_RC_EIO = 3, /* I/O error */
78 IONIC_RC_EPERM = 4, /* Permission denied */
79 IONIC_RC_EQID = 5, /* Bad qid */
80 IONIC_RC_EQTYPE = 6, /* Bad qtype */
81 IONIC_RC_ENOENT = 7, /* No such element */
82 IONIC_RC_EINTR = 8, /* operation interrupted */
83 IONIC_RC_EAGAIN = 9, /* Try again */
84 IONIC_RC_ENOMEM = 10, /* Out of memory */
85 IONIC_RC_EFAULT = 11, /* Bad address */
86 IONIC_RC_EBUSY = 12, /* Device or resource busy */
87 IONIC_RC_EEXIST = 13, /* object already exists */
88 IONIC_RC_EINVAL = 14, /* Invalid argument */
89 IONIC_RC_ENOSPC = 15, /* No space left or alloc failure */
90 IONIC_RC_ERANGE = 16, /* Parameter out of range */
91 IONIC_RC_BAD_ADDR = 17, /* Descriptor contains a bad ptr */
92 IONIC_RC_DEV_CMD = 18, /* Device cmd attempted on AdminQ */
93 IONIC_RC_ENOSUPP = 19, /* Operation not supported */
94 IONIC_RC_ERROR = 29, /* Generic error */
95 IONIC_RC_ERDMA = 30, /* Generic RDMA error */
96 IONIC_RC_EVFID = 31, /* VF ID does not exist */
99 enum ionic_notifyq_opcode {
100 IONIC_EVENT_LINK_CHANGE = 1,
101 IONIC_EVENT_RESET = 2,
102 IONIC_EVENT_HEARTBEAT = 3,
104 IONIC_EVENT_XCVR = 5,
108 * struct ionic_admin_cmd - General admin command format
109 * @opcode: Opcode for the command
110 * @lif_index: LIF index
111 * @cmd_data: Opcode-specific command bytes
113 struct ionic_admin_cmd {
121 * struct ionic_admin_comp - General admin command completion format
122 * @status: Status of the command (enum ionic_status_code)
123 * @comp_index: Index in the descriptor ring for which this is the completion
124 * @cmd_data: Command-specific bytes
125 * @color: Color bit (Always 0 for commands issued to the
126 * Device Cmd Registers)
128 struct ionic_admin_comp {
134 #define IONIC_COMP_COLOR_MASK 0x80
137 static inline u8 color_match(u8 color, u8 done_color)
139 return (!!(color & IONIC_COMP_COLOR_MASK)) == done_color;
143 * struct ionic_nop_cmd - NOP command
146 struct ionic_nop_cmd {
152 * struct ionic_nop_comp - NOP command completion
153 * @status: Status of the command (enum ionic_status_code)
155 struct ionic_nop_comp {
161 * struct ionic_dev_init_cmd - Device init command
165 struct ionic_dev_init_cmd {
172 * struct ionic_dev_init_comp - Device init command completion
173 * @status: Status of the command (enum ionic_status_code)
175 struct ionic_dev_init_comp {
181 * struct ionic_dev_reset_cmd - Device reset command
184 struct ionic_dev_reset_cmd {
190 * struct ionic_dev_reset_comp - Reset command completion
191 * @status: Status of the command (enum ionic_status_code)
193 struct ionic_dev_reset_comp {
198 #define IONIC_IDENTITY_VERSION_1 1
201 * struct ionic_dev_identify_cmd - Driver/device identify command
203 * @ver: Highest version of identify supported by driver
205 struct ionic_dev_identify_cmd {
212 * struct ionic_dev_identify_comp - Driver/device identify command completion
213 * @status: Status of the command (enum ionic_status_code)
214 * @ver: Version of identify returned by device
216 struct ionic_dev_identify_comp {
223 IONIC_OS_TYPE_LINUX = 1,
224 IONIC_OS_TYPE_WIN = 2,
225 IONIC_OS_TYPE_DPDK = 3,
226 IONIC_OS_TYPE_FREEBSD = 4,
227 IONIC_OS_TYPE_IPXE = 5,
228 IONIC_OS_TYPE_ESXI = 6,
232 * union ionic_drv_identity - driver identity information
233 * @os_type: OS type (see enum ionic_os_type)
234 * @os_dist: OS distribution, numeric format
235 * @os_dist_str: OS distribution, string format
236 * @kernel_ver: Kernel version, numeric format
237 * @kernel_ver_str: Kernel version, string format
238 * @driver_ver_str: Driver version, string format
240 union ionic_drv_identity {
244 char os_dist_str[128];
246 char kernel_ver_str[32];
247 char driver_ver_str[32];
253 * union ionic_dev_identity - device identity information
254 * @version: Version of device identify
255 * @type: Identify type (0 for now)
256 * @nports: Number of ports provisioned
257 * @nlifs: Number of LIFs provisioned
258 * @nintrs: Number of interrupts provisioned
259 * @ndbpgs_per_lif: Number of doorbell pages per LIF
260 * @intr_coal_mult: Interrupt coalescing multiplication factor
261 * Scale user-supplied interrupt coalescing
262 * value in usecs to device units using:
263 * device units = usecs * mult / div
264 * @intr_coal_div: Interrupt coalescing division factor
265 * Scale user-supplied interrupt coalescing
266 * value in usecs to device units using:
267 * device units = usecs * mult / div
268 * @eq_count: Number of shared event queues
270 union ionic_dev_identity {
279 __le32 ndbpgs_per_lif;
280 __le32 intr_coal_mult;
281 __le32 intr_coal_div;
287 enum ionic_lif_type {
288 IONIC_LIF_TYPE_CLASSIC = 0,
289 IONIC_LIF_TYPE_MACVLAN = 1,
290 IONIC_LIF_TYPE_NETQUEUE = 2,
294 * struct ionic_lif_identify_cmd - LIF identify command
296 * @type: LIF type (enum ionic_lif_type)
297 * @ver: Version of identify returned by device
299 struct ionic_lif_identify_cmd {
307 * struct ionic_lif_identify_comp - LIF identify command completion
308 * @status: Status of the command (enum ionic_status_code)
309 * @ver: Version of identify returned by device
311 struct ionic_lif_identify_comp {
318 * enum ionic_lif_capability - LIF capabilities
319 * @IONIC_LIF_CAP_ETH: LIF supports Ethernet
320 * @IONIC_LIF_CAP_RDMA: LIF support RDMA
322 enum ionic_lif_capability {
323 IONIC_LIF_CAP_ETH = BIT(0),
324 IONIC_LIF_CAP_RDMA = BIT(1),
328 * enum ionic_logical_qtype - Logical Queue Types
329 * @IONIC_QTYPE_ADMINQ: Administrative Queue
330 * @IONIC_QTYPE_NOTIFYQ: Notify Queue
331 * @IONIC_QTYPE_RXQ: Receive Queue
332 * @IONIC_QTYPE_TXQ: Transmit Queue
333 * @IONIC_QTYPE_EQ: Event Queue
334 * @IONIC_QTYPE_MAX: Max queue type supported
336 enum ionic_logical_qtype {
337 IONIC_QTYPE_ADMINQ = 0,
338 IONIC_QTYPE_NOTIFYQ = 1,
342 IONIC_QTYPE_MAX = 16,
346 * struct ionic_lif_logical_qtype - Descriptor of logical to HW queue type
347 * @qtype: Hardware Queue Type
348 * @qid_count: Number of Queue IDs of the logical type
349 * @qid_base: Minimum Queue ID of the logical type
351 struct ionic_lif_logical_qtype {
359 * enum ionic_lif_state - LIF state
360 * @IONIC_LIF_DISABLE: LIF disabled
361 * @IONIC_LIF_ENABLE: LIF enabled
362 * @IONIC_LIF_QUIESCE: LIF Quiesced
364 enum ionic_lif_state {
365 IONIC_LIF_QUIESCE = 0,
366 IONIC_LIF_ENABLE = 1,
367 IONIC_LIF_DISABLE = 2,
371 * union ionic_lif_config - LIF configuration
372 * @state: LIF state (enum ionic_lif_state)
375 * @mac: Station MAC address
376 * @vlan: Default Vlan ID
377 * @features: Features (enum ionic_eth_hw_features)
378 * @queue_count: Queue counts per queue-type
380 union ionic_lif_config {
384 char name[IONIC_IFNAMSIZ];
389 __le32 queue_count[IONIC_QTYPE_MAX];
395 * struct ionic_lif_identity - LIF identity information (type-specific)
397 * @capabilities: LIF capabilities
399 * @eth: Ethernet identify structure
400 * @version: Ethernet identify structure version
401 * @max_ucast_filters: Number of perfect unicast addresses supported
402 * @max_mcast_filters: Number of perfect multicast addresses supported
403 * @min_frame_size: Minimum size of frames to be sent
404 * @max_frame_size: Maximum size of frames to be sent
405 * @config: LIF config struct with features, mtu, mac, q counts
407 * @rdma: RDMA identify structure
408 * @version: RDMA version of opcodes and queue descriptors
409 * @qp_opcodes: Number of RDMA queue pair opcodes supported
410 * @admin_opcodes: Number of RDMA admin opcodes supported
411 * @npts_per_lif: Page table size per LIF
412 * @nmrs_per_lif: Number of memory regions per LIF
413 * @nahs_per_lif: Number of address handles per LIF
414 * @max_stride: Max work request stride
415 * @cl_stride: Cache line stride
416 * @pte_stride: Page table entry stride
417 * @rrq_stride: Remote RQ work request stride
418 * @rsq_stride: Remote SQ work request stride
419 * @dcqcn_profiles: Number of DCQCN profiles
420 * @aq_qtype: RDMA Admin Qtype
421 * @sq_qtype: RDMA Send Qtype
422 * @rq_qtype: RDMA Receive Qtype
423 * @cq_qtype: RDMA Completion Qtype
424 * @eq_qtype: RDMA Event Qtype
426 union ionic_lif_identity {
433 __le32 max_ucast_filters;
434 __le32 max_mcast_filters;
435 __le16 rss_ind_tbl_sz;
436 __le32 min_frame_size;
437 __le32 max_frame_size;
439 union ionic_lif_config config;
456 u8 rsvd_dimensions[10];
457 struct ionic_lif_logical_qtype aq_qtype;
458 struct ionic_lif_logical_qtype sq_qtype;
459 struct ionic_lif_logical_qtype rq_qtype;
460 struct ionic_lif_logical_qtype cq_qtype;
461 struct ionic_lif_logical_qtype eq_qtype;
468 * struct ionic_lif_init_cmd - LIF init command
470 * @type: LIF type (enum ionic_lif_type)
472 * @info_pa: Destination address for LIF info (struct ionic_lif_info)
474 struct ionic_lif_init_cmd {
484 * struct ionic_lif_init_comp - LIF init command completion
485 * @status: Status of the command (enum ionic_status_code)
486 * @hw_index: Hardware index of the initialized LIF
488 struct ionic_lif_init_comp {
496 * struct ionic_q_identify_cmd - queue identify command
498 * @lif_type: LIF type (enum ionic_lif_type)
499 * @type: Logical queue type (enum ionic_logical_qtype)
500 * @ver: Highest queue type version that the driver supports
502 struct ionic_q_identify_cmd {
512 * struct ionic_q_identify_comp - queue identify command completion
513 * @status: Status of the command (enum ionic_status_code)
514 * @comp_index: Index in the descriptor ring for which this is the completion
515 * @ver: Queue type version that can be used with FW
517 struct ionic_q_identify_comp {
526 * union ionic_q_identity - queue identity information
527 * @version: Queue type version that can be used with FW
528 * @supported: Bitfield of queue versions, first bit = ver 0
529 * @features: Queue features
530 * @desc_sz: Descriptor size
531 * @comp_sz: Completion descriptor size
532 * @sg_desc_sz: Scatter/Gather descriptor size
533 * @max_sg_elems: Maximum number of Scatter/Gather elements
534 * @sg_desc_stride: Number of Scatter/Gather elements per descriptor
536 union ionic_q_identity {
541 #define IONIC_QIDENT_F_CQ 0x01 /* queue has completion ring */
542 #define IONIC_QIDENT_F_SG 0x02 /* queue has scatter/gather ring */
543 #define IONIC_QIDENT_F_EQ 0x04 /* queue can use event queue */
544 #define IONIC_QIDENT_F_CMB 0x08 /* queue is in cmb bar */
550 __le16 sg_desc_stride;
556 * struct ionic_q_init_cmd - Queue init command
558 * @type: Logical queue type
559 * @ver: Queue type version
560 * @lif_index: LIF index
561 * @index: (LIF, qtype) relative admin queue index
562 * @intr_index: Interrupt control register index, or Event queue index
565 * IRQ: Interrupt requested on completion
566 * ENA: Enable the queue. If ENA=0 the queue is initialized
567 * but remains disabled, to be later enabled with the
568 * Queue Enable command. If ENA=1, then queue is
569 * initialized and then enabled.
570 * SG: Enable Scatter-Gather on the queue.
571 * in number of descs. The actual ring size is
572 * (1 << ring_size). For example, to
573 * select a ring size of 64 descriptors write
574 * ring_size = 6. The minimum ring_size value is 2
575 * for a ring size of 4 descriptors. The maximum
576 * ring_size value is 16 for a ring size of 64k
577 * descriptors. Values of ring_size <2 and >16 are
579 * EQ: Enable the Event Queue
580 * @cos: Class of service for this queue
581 * @ring_size: Queue ring size, encoded as a log2(size)
582 * @ring_base: Queue ring base address
583 * @cq_ring_base: Completion queue ring base address
584 * @sg_ring_base: Scatter/Gather ring base address
586 struct ionic_q_init_cmd {
597 #define IONIC_QINIT_F_IRQ 0x01 /* Request interrupt on completion */
598 #define IONIC_QINIT_F_ENA 0x02 /* Enable the queue */
599 #define IONIC_QINIT_F_SG 0x04 /* Enable scatter/gather on the queue */
600 #define IONIC_QINIT_F_EQ 0x08 /* Enable event queue */
601 #define IONIC_QINIT_F_CMB 0x10 /* Enable cmb-based queue */
602 #define IONIC_QINIT_F_DEBUG 0x80 /* Enable queue debugging */
612 * struct ionic_q_init_comp - Queue init command completion
613 * @status: Status of the command (enum ionic_status_code)
614 * @comp_index: Index in the descriptor ring for which this is the completion
615 * @hw_index: Hardware Queue ID
616 * @hw_type: Hardware Queue type
619 struct ionic_q_init_comp {
629 /* the device's internal addressing uses up to 52 bits */
630 #define IONIC_ADDR_LEN 52
631 #define IONIC_ADDR_MASK (BIT_ULL(IONIC_ADDR_LEN) - 1)
633 enum ionic_txq_desc_opcode {
634 IONIC_TXQ_DESC_OPCODE_CSUM_NONE = 0,
635 IONIC_TXQ_DESC_OPCODE_CSUM_PARTIAL = 1,
636 IONIC_TXQ_DESC_OPCODE_CSUM_HW = 2,
637 IONIC_TXQ_DESC_OPCODE_TSO = 3,
641 * struct ionic_txq_desc - Ethernet Tx queue descriptor format
642 * @cmd: Tx operation, see IONIC_TXQ_DESC_OPCODE_*:
644 * IONIC_TXQ_DESC_OPCODE_CSUM_NONE:
645 * Non-offload send. No segmentation,
646 * fragmentation or checksum calc/insertion is
647 * performed by device; packet is prepared
648 * to send by software stack and requires
649 * no further manipulation from device.
651 * IONIC_TXQ_DESC_OPCODE_CSUM_PARTIAL:
652 * Offload 16-bit L4 checksum
653 * calculation/insertion. The device will
654 * calculate the L4 checksum value and
655 * insert the result in the packet's L4
656 * header checksum field. The L4 checksum
657 * is calculated starting at @csum_start bytes
658 * into the packet to the end of the packet.
659 * The checksum insertion position is given
660 * in @csum_offset, which is the offset from
661 * @csum_start to the checksum field in the L4
662 * header. This feature is only applicable to
663 * protocols such as TCP, UDP and ICMP where a
664 * standard (i.e. the 'IP-style' checksum)
665 * one's complement 16-bit checksum is used,
666 * using an IP pseudo-header to seed the
667 * calculation. Software will preload the L4
668 * checksum field with the IP pseudo-header
671 * For tunnel encapsulation, @csum_start and
672 * @csum_offset refer to the inner L4
673 * header. Supported tunnels encapsulations
674 * are: IPIP, GRE, and UDP. If the @encap
675 * is clear, no further processing by the
676 * device is required; software will
677 * calculate the outer header checksums. If
678 * the @encap is set, the device will
679 * offload the outer header checksums using
680 * LCO (local checksum offload) (see
681 * Documentation/networking/checksum-offloads.rst
684 * IONIC_TXQ_DESC_OPCODE_CSUM_HW:
685 * Offload 16-bit checksum computation to hardware.
686 * If @csum_l3 is set then the packet's L3 checksum is
687 * updated. Similarly, if @csum_l4 is set the the L4
688 * checksum is updated. If @encap is set then encap header
689 * checksums are also updated.
691 * IONIC_TXQ_DESC_OPCODE_TSO:
692 * Device performs TCP segmentation offload
693 * (TSO). @hdr_len is the number of bytes
694 * to the end of TCP header (the offset to
695 * the TCP payload). @mss is the desired
696 * MSS, the TCP payload length for each
697 * segment. The device will calculate/
698 * insert IP (IPv4 only) and TCP checksums
699 * for each segment. In the first data
700 * buffer containing the header template,
701 * the driver will set IPv4 checksum to 0
702 * and preload TCP checksum with the IP
703 * pseudo header calculated with IP length = 0.
705 * Supported tunnel encapsulations are IPIP,
706 * layer-3 GRE, and UDP. @hdr_len includes
707 * both outer and inner headers. The driver
708 * will set IPv4 checksum to zero and
709 * preload TCP checksum with IP pseudo
710 * header on the inner header.
712 * TCP ECN offload is supported. The device
713 * will set CWR flag in the first segment if
714 * CWR is set in the template header, and
715 * clear CWR in remaining segments.
718 * Insert an L2 VLAN header using @vlan_tci
720 * Calculate encap header checksum
722 * Compute L3 header checksum
724 * Compute L4 header checksum
729 * @num_sg_elems: Number of scatter-gather elements in SG
731 * @addr: First data buffer's DMA address
732 * (Subsequent data buffers are on txq_sg_desc)
733 * @len: First data buffer's length, in bytes
734 * @vlan_tci: VLAN tag to insert in the packet (if requested
735 * by @V-bit). Includes .1p and .1q tags
736 * @hdr_len: Length of packet headers, including
737 * encapsulating outer header, if applicable
738 * Valid for opcodes IONIC_TXQ_DESC_OPCODE_CALC_CSUM and
739 * IONIC_TXQ_DESC_OPCODE_TSO. Should be set to zero for
740 * all other modes. For
741 * IONIC_TXQ_DESC_OPCODE_CALC_CSUM, @hdr_len is length
742 * of headers up to inner-most L4 header. For
743 * IONIC_TXQ_DESC_OPCODE_TSO, @hdr_len is up to
744 * inner-most L4 payload, so inclusive of
745 * inner-most L4 header.
746 * @mss: Desired MSS value for TSO; only applicable for
747 * IONIC_TXQ_DESC_OPCODE_TSO
748 * @csum_start: Offset from packet to first byte checked in L4 checksum
749 * @csum_offset: Offset from csum_start to L4 checksum field
751 struct ionic_txq_desc {
753 #define IONIC_TXQ_DESC_OPCODE_MASK 0xf
754 #define IONIC_TXQ_DESC_OPCODE_SHIFT 4
755 #define IONIC_TXQ_DESC_FLAGS_MASK 0xf
756 #define IONIC_TXQ_DESC_FLAGS_SHIFT 0
757 #define IONIC_TXQ_DESC_NSGE_MASK 0xf
758 #define IONIC_TXQ_DESC_NSGE_SHIFT 8
759 #define IONIC_TXQ_DESC_ADDR_MASK (BIT_ULL(IONIC_ADDR_LEN) - 1)
760 #define IONIC_TXQ_DESC_ADDR_SHIFT 12
763 #define IONIC_TXQ_DESC_FLAG_VLAN 0x1
764 #define IONIC_TXQ_DESC_FLAG_ENCAP 0x2
766 /* flags for csum_hw opcode */
767 #define IONIC_TXQ_DESC_FLAG_CSUM_L3 0x4
768 #define IONIC_TXQ_DESC_FLAG_CSUM_L4 0x8
770 /* flags for tso opcode */
771 #define IONIC_TXQ_DESC_FLAG_TSO_SOT 0x4
772 #define IONIC_TXQ_DESC_FLAG_TSO_EOT 0x8
791 static inline u64 encode_txq_desc_cmd(u8 opcode, u8 flags,
796 cmd = (opcode & IONIC_TXQ_DESC_OPCODE_MASK) <<
797 IONIC_TXQ_DESC_OPCODE_SHIFT;
798 cmd |= (flags & IONIC_TXQ_DESC_FLAGS_MASK) <<
799 IONIC_TXQ_DESC_FLAGS_SHIFT;
800 cmd |= (nsge & IONIC_TXQ_DESC_NSGE_MASK) <<
801 IONIC_TXQ_DESC_NSGE_SHIFT;
802 cmd |= (addr & IONIC_TXQ_DESC_ADDR_MASK) <<
803 IONIC_TXQ_DESC_ADDR_SHIFT;
809 decode_txq_desc_cmd(u64 cmd, u8 *opcode, u8 *flags,
812 *opcode = (cmd >> IONIC_TXQ_DESC_OPCODE_SHIFT) &
813 IONIC_TXQ_DESC_OPCODE_MASK;
814 *flags = (cmd >> IONIC_TXQ_DESC_FLAGS_SHIFT) &
815 IONIC_TXQ_DESC_FLAGS_MASK;
816 *nsge = (cmd >> IONIC_TXQ_DESC_NSGE_SHIFT) &
817 IONIC_TXQ_DESC_NSGE_MASK;
818 *addr = (cmd >> IONIC_TXQ_DESC_ADDR_SHIFT) &
819 IONIC_TXQ_DESC_ADDR_MASK;
823 * struct ionic_txq_sg_elem - Transmit scatter-gather (SG) descriptor element
824 * @addr: DMA address of SG element data buffer
825 * @len: Length of SG element data buffer, in bytes
827 struct ionic_txq_sg_elem {
834 * struct ionic_txq_sg_desc - Transmit scatter-gather (SG) list
835 * @elems: Scatter-gather elements
837 struct ionic_txq_sg_desc {
838 #define IONIC_TX_MAX_SG_ELEMS 8
839 #define IONIC_TX_SG_DESC_STRIDE 8
840 struct ionic_txq_sg_elem elems[IONIC_TX_MAX_SG_ELEMS];
843 struct ionic_txq_sg_desc_v1 {
844 #define IONIC_TX_MAX_SG_ELEMS_V1 15
845 #define IONIC_TX_SG_DESC_STRIDE_V1 16
846 struct ionic_txq_sg_elem elems[IONIC_TX_SG_DESC_STRIDE_V1];
850 * struct ionic_txq_comp - Ethernet transmit queue completion descriptor
851 * @status: Status of the command (enum ionic_status_code)
852 * @comp_index: Index in the descriptor ring for which this is the completion
855 struct ionic_txq_comp {
863 enum ionic_rxq_desc_opcode {
864 IONIC_RXQ_DESC_OPCODE_SIMPLE = 0,
865 IONIC_RXQ_DESC_OPCODE_SG = 1,
869 * struct ionic_rxq_desc - Ethernet Rx queue descriptor format
870 * @opcode: Rx operation, see IONIC_RXQ_DESC_OPCODE_*:
872 * IONIC_RXQ_DESC_OPCODE_SIMPLE:
873 * Receive full packet into data buffer
874 * starting at @addr. Results of
875 * receive, including actual bytes received,
876 * are recorded in Rx completion descriptor.
878 * @len: Data buffer's length, in bytes
879 * @addr: Data buffer's DMA address
881 struct ionic_rxq_desc {
889 * struct ionic_rxq_sg_elem - Receive scatter-gather (SG) descriptor element
890 * @addr: DMA address of SG element data buffer
891 * @len: Length of SG element data buffer, in bytes
893 struct ionic_rxq_sg_elem {
900 * struct ionic_rxq_sg_desc - Receive scatter-gather (SG) list
901 * @elems: Scatter-gather elements
903 struct ionic_rxq_sg_desc {
904 #define IONIC_RX_MAX_SG_ELEMS 8
905 #define IONIC_RX_SG_DESC_STRIDE 8
906 struct ionic_rxq_sg_elem elems[IONIC_RX_SG_DESC_STRIDE];
910 * struct ionic_rxq_comp - Ethernet receive queue completion descriptor
911 * @status: Status of the command (enum ionic_status_code)
912 * @num_sg_elems: Number of SG elements used by this descriptor
913 * @comp_index: Index in the descriptor ring for which this is the completion
914 * @rss_hash: 32-bit RSS hash
915 * @csum: 16-bit sum of the packet's L2 payload
916 * If the packet's L2 payload is odd length, an extra
917 * zero-value byte is included in the @csum calculation but
918 * not included in @len.
919 * @vlan_tci: VLAN tag stripped from the packet. Valid if @VLAN is
920 * set. Includes .1p and .1q tags.
921 * @len: Received packet length, in bytes. Excludes FCS.
922 * @csum_calc L2 payload checksum is computed or not
923 * @csum_flags: See IONIC_RXQ_COMP_CSUM_F_*:
925 * IONIC_RXQ_COMP_CSUM_F_TCP_OK:
926 * The TCP checksum calculated by the device
927 * matched the checksum in the receive packet's
930 * IONIC_RXQ_COMP_CSUM_F_TCP_BAD:
931 * The TCP checksum calculated by the device did
932 * not match the checksum in the receive packet's
935 * IONIC_RXQ_COMP_CSUM_F_UDP_OK:
936 * The UDP checksum calculated by the device
937 * matched the checksum in the receive packet's
940 * IONIC_RXQ_COMP_CSUM_F_UDP_BAD:
941 * The UDP checksum calculated by the device did
942 * not match the checksum in the receive packet's
945 * IONIC_RXQ_COMP_CSUM_F_IP_OK:
946 * The IPv4 checksum calculated by the device
947 * matched the checksum in the receive packet's
948 * first IPv4 header. If the receive packet
949 * contains both a tunnel IPv4 header and a
950 * transport IPv4 header, the device validates the
951 * checksum for the both IPv4 headers.
953 * IONIC_RXQ_COMP_CSUM_F_IP_BAD:
954 * The IPv4 checksum calculated by the device did
955 * not match the checksum in the receive packet's
956 * first IPv4 header. If the receive packet
957 * contains both a tunnel IPv4 header and a
958 * transport IPv4 header, the device validates the
959 * checksum for both IP headers.
961 * IONIC_RXQ_COMP_CSUM_F_VLAN:
962 * The VLAN header was stripped and placed in @vlan_tci.
964 * IONIC_RXQ_COMP_CSUM_F_CALC:
965 * The checksum was calculated by the device.
967 * @pkt_type_color: Packet type and color bit; see IONIC_RXQ_COMP_PKT_TYPE_MASK
969 struct ionic_rxq_comp {
978 #define IONIC_RXQ_COMP_CSUM_F_TCP_OK 0x01
979 #define IONIC_RXQ_COMP_CSUM_F_TCP_BAD 0x02
980 #define IONIC_RXQ_COMP_CSUM_F_UDP_OK 0x04
981 #define IONIC_RXQ_COMP_CSUM_F_UDP_BAD 0x08
982 #define IONIC_RXQ_COMP_CSUM_F_IP_OK 0x10
983 #define IONIC_RXQ_COMP_CSUM_F_IP_BAD 0x20
984 #define IONIC_RXQ_COMP_CSUM_F_VLAN 0x40
985 #define IONIC_RXQ_COMP_CSUM_F_CALC 0x80
987 #define IONIC_RXQ_COMP_PKT_TYPE_MASK 0x7f
990 enum ionic_pkt_type {
991 IONIC_PKT_TYPE_NON_IP = 0x00,
992 IONIC_PKT_TYPE_IPV4 = 0x01,
993 IONIC_PKT_TYPE_IPV4_TCP = 0x03,
994 IONIC_PKT_TYPE_IPV4_UDP = 0x05,
995 IONIC_PKT_TYPE_IPV6 = 0x08,
996 IONIC_PKT_TYPE_IPV6_TCP = 0x18,
997 IONIC_PKT_TYPE_IPV6_UDP = 0x28,
998 /* below types are only used if encap offloads are enabled on lif */
999 IONIC_PKT_TYPE_ENCAP_NON_IP = 0x40,
1000 IONIC_PKT_TYPE_ENCAP_IPV4 = 0x41,
1001 IONIC_PKT_TYPE_ENCAP_IPV4_TCP = 0x43,
1002 IONIC_PKT_TYPE_ENCAP_IPV4_UDP = 0x45,
1003 IONIC_PKT_TYPE_ENCAP_IPV6 = 0x48,
1004 IONIC_PKT_TYPE_ENCAP_IPV6_TCP = 0x58,
1005 IONIC_PKT_TYPE_ENCAP_IPV6_UDP = 0x68,
1008 enum ionic_eth_hw_features {
1009 IONIC_ETH_HW_VLAN_TX_TAG = BIT(0),
1010 IONIC_ETH_HW_VLAN_RX_STRIP = BIT(1),
1011 IONIC_ETH_HW_VLAN_RX_FILTER = BIT(2),
1012 IONIC_ETH_HW_RX_HASH = BIT(3),
1013 IONIC_ETH_HW_RX_CSUM = BIT(4),
1014 IONIC_ETH_HW_TX_SG = BIT(5),
1015 IONIC_ETH_HW_RX_SG = BIT(6),
1016 IONIC_ETH_HW_TX_CSUM = BIT(7),
1017 IONIC_ETH_HW_TSO = BIT(8),
1018 IONIC_ETH_HW_TSO_IPV6 = BIT(9),
1019 IONIC_ETH_HW_TSO_ECN = BIT(10),
1020 IONIC_ETH_HW_TSO_GRE = BIT(11),
1021 IONIC_ETH_HW_TSO_GRE_CSUM = BIT(12),
1022 IONIC_ETH_HW_TSO_IPXIP4 = BIT(13),
1023 IONIC_ETH_HW_TSO_IPXIP6 = BIT(14),
1024 IONIC_ETH_HW_TSO_UDP = BIT(15),
1025 IONIC_ETH_HW_TSO_UDP_CSUM = BIT(16),
1026 IONIC_ETH_HW_RX_CSUM_GENEVE = BIT(17),
1027 IONIC_ETH_HW_TX_CSUM_GENEVE = BIT(18),
1028 IONIC_ETH_HW_TSO_GENEVE = BIT(19)
1032 * struct ionic_q_control_cmd - Queue control command
1035 * @lif_index: LIF index
1036 * @index: Queue index
1037 * @oper: Operation (enum ionic_q_control_oper)
1039 struct ionic_q_control_cmd {
1048 typedef struct ionic_admin_comp ionic_q_control_comp;
1050 enum ionic_q_control_oper {
1051 IONIC_Q_DISABLE = 0,
1053 IONIC_Q_HANG_RESET = 2,
1057 * enum ionic_phy_type - Physical connection type
1058 * @IONIC_PHY_TYPE_NONE: No PHY installed
1059 * @IONIC_PHY_TYPE_COPPER: Copper PHY
1060 * @IONIC_PHY_TYPE_FIBER: Fiber PHY
1062 enum ionic_phy_type {
1063 IONIC_PHY_TYPE_NONE = 0,
1064 IONIC_PHY_TYPE_COPPER = 1,
1065 IONIC_PHY_TYPE_FIBER = 2,
1069 * enum ionic_xcvr_state - Transceiver status
1070 * @IONIC_XCVR_STATE_REMOVED: Transceiver removed
1071 * @IONIC_XCVR_STATE_INSERTED: Transceiver inserted
1072 * @IONIC_XCVR_STATE_PENDING: Transceiver pending
1073 * @IONIC_XCVR_STATE_SPROM_READ: Transceiver data read
1074 * @IONIC_XCVR_STATE_SPROM_READ_ERR: Transceiver data read error
1076 enum ionic_xcvr_state {
1077 IONIC_XCVR_STATE_REMOVED = 0,
1078 IONIC_XCVR_STATE_INSERTED = 1,
1079 IONIC_XCVR_STATE_PENDING = 2,
1080 IONIC_XCVR_STATE_SPROM_READ = 3,
1081 IONIC_XCVR_STATE_SPROM_READ_ERR = 4,
1085 * enum ionic_xcvr_pid - Supported link modes
1087 enum ionic_xcvr_pid {
1088 IONIC_XCVR_PID_UNKNOWN = 0,
1091 IONIC_XCVR_PID_QSFP_100G_CR4 = 1,
1092 IONIC_XCVR_PID_QSFP_40GBASE_CR4 = 2,
1093 IONIC_XCVR_PID_SFP_25GBASE_CR_S = 3,
1094 IONIC_XCVR_PID_SFP_25GBASE_CR_L = 4,
1095 IONIC_XCVR_PID_SFP_25GBASE_CR_N = 5,
1098 IONIC_XCVR_PID_QSFP_100G_AOC = 50,
1099 IONIC_XCVR_PID_QSFP_100G_ACC = 51,
1100 IONIC_XCVR_PID_QSFP_100G_SR4 = 52,
1101 IONIC_XCVR_PID_QSFP_100G_LR4 = 53,
1102 IONIC_XCVR_PID_QSFP_100G_ER4 = 54,
1103 IONIC_XCVR_PID_QSFP_40GBASE_ER4 = 55,
1104 IONIC_XCVR_PID_QSFP_40GBASE_SR4 = 56,
1105 IONIC_XCVR_PID_QSFP_40GBASE_LR4 = 57,
1106 IONIC_XCVR_PID_QSFP_40GBASE_AOC = 58,
1107 IONIC_XCVR_PID_SFP_25GBASE_SR = 59,
1108 IONIC_XCVR_PID_SFP_25GBASE_LR = 60,
1109 IONIC_XCVR_PID_SFP_25GBASE_ER = 61,
1110 IONIC_XCVR_PID_SFP_25GBASE_AOC = 62,
1111 IONIC_XCVR_PID_SFP_10GBASE_SR = 63,
1112 IONIC_XCVR_PID_SFP_10GBASE_LR = 64,
1113 IONIC_XCVR_PID_SFP_10GBASE_LRM = 65,
1114 IONIC_XCVR_PID_SFP_10GBASE_ER = 66,
1115 IONIC_XCVR_PID_SFP_10GBASE_AOC = 67,
1116 IONIC_XCVR_PID_SFP_10GBASE_CU = 68,
1117 IONIC_XCVR_PID_QSFP_100G_CWDM4 = 69,
1118 IONIC_XCVR_PID_QSFP_100G_PSM4 = 70,
1119 IONIC_XCVR_PID_SFP_25GBASE_ACC = 71,
1123 * enum ionic_port_admin_state - Port config state
1124 * @IONIC_PORT_ADMIN_STATE_NONE: Port admin state not configured
1125 * @IONIC_PORT_ADMIN_STATE_DOWN: Port admin disabled
1126 * @IONIC_PORT_ADMIN_STATE_UP: Port admin enabled
1128 enum ionic_port_admin_state {
1129 IONIC_PORT_ADMIN_STATE_NONE = 0,
1130 IONIC_PORT_ADMIN_STATE_DOWN = 1,
1131 IONIC_PORT_ADMIN_STATE_UP = 2,
1135 * enum ionic_port_oper_status - Port operational status
1136 * @IONIC_PORT_OPER_STATUS_NONE: Port disabled
1137 * @IONIC_PORT_OPER_STATUS_UP: Port link status up
1138 * @IONIC_PORT_OPER_STATUS_DOWN: Port link status down
1140 enum ionic_port_oper_status {
1141 IONIC_PORT_OPER_STATUS_NONE = 0,
1142 IONIC_PORT_OPER_STATUS_UP = 1,
1143 IONIC_PORT_OPER_STATUS_DOWN = 2,
1147 * enum ionic_port_fec_type - Ethernet Forward error correction (FEC) modes
1148 * @IONIC_PORT_FEC_TYPE_NONE: FEC Disabled
1149 * @IONIC_PORT_FEC_TYPE_FC: FireCode FEC
1150 * @IONIC_PORT_FEC_TYPE_RS: ReedSolomon FEC
1152 enum ionic_port_fec_type {
1153 IONIC_PORT_FEC_TYPE_NONE = 0,
1154 IONIC_PORT_FEC_TYPE_FC = 1,
1155 IONIC_PORT_FEC_TYPE_RS = 2,
1159 * enum ionic_port_pause_type - Ethernet pause (flow control) modes
1160 * @IONIC_PORT_PAUSE_TYPE_NONE: Disable Pause
1161 * @IONIC_PORT_PAUSE_TYPE_LINK: Link level pause
1162 * @IONIC_PORT_PAUSE_TYPE_PFC: Priority-Flow Control
1164 enum ionic_port_pause_type {
1165 IONIC_PORT_PAUSE_TYPE_NONE = 0,
1166 IONIC_PORT_PAUSE_TYPE_LINK = 1,
1167 IONIC_PORT_PAUSE_TYPE_PFC = 2,
1171 * enum ionic_port_loopback_mode - Loopback modes
1172 * @IONIC_PORT_LOOPBACK_MODE_NONE: Disable loopback
1173 * @IONIC_PORT_LOOPBACK_MODE_MAC: MAC loopback
1174 * @IONIC_PORT_LOOPBACK_MODE_PHY: PHY/SerDes loopback
1176 enum ionic_port_loopback_mode {
1177 IONIC_PORT_LOOPBACK_MODE_NONE = 0,
1178 IONIC_PORT_LOOPBACK_MODE_MAC = 1,
1179 IONIC_PORT_LOOPBACK_MODE_PHY = 2,
1183 * struct ionic_xcvr_status - Transceiver Status information
1184 * @state: Transceiver status (enum ionic_xcvr_state)
1185 * @phy: Physical connection type (enum ionic_phy_type)
1186 * @pid: Transceiver link mode (enum ionic_xcvr_pid)
1187 * @sprom: Transceiver sprom contents
1189 struct ionic_xcvr_status {
1197 * union ionic_port_config - Port configuration
1198 * @speed: port speed (in Mbps)
1200 * @state: port admin state (enum ionic_port_admin_state)
1201 * @an_enable: autoneg enable
1202 * @fec_type: fec type (enum ionic_port_fec_type)
1203 * @pause_type: pause type (enum ionic_port_pause_type)
1204 * @loopback_mode: loopback mode (enum ionic_port_loopback_mode)
1206 union ionic_port_config {
1208 #define IONIC_SPEED_100G 100000 /* 100G in Mbps */
1209 #define IONIC_SPEED_50G 50000 /* 50G in Mbps */
1210 #define IONIC_SPEED_40G 40000 /* 40G in Mbps */
1211 #define IONIC_SPEED_25G 25000 /* 25G in Mbps */
1212 #define IONIC_SPEED_10G 10000 /* 10G in Mbps */
1213 #define IONIC_SPEED_1G 1000 /* 1G in Mbps */
1219 #define IONIC_PAUSE_TYPE_MASK 0x0f
1220 #define IONIC_PAUSE_FLAGS_MASK 0xf0
1221 #define IONIC_PAUSE_F_TX 0x10
1222 #define IONIC_PAUSE_F_RX 0x20
1230 * struct ionic_port_status - Port Status information
1231 * @status: link status (enum ionic_port_oper_status)
1233 * @speed: link speed (in Mbps)
1234 * @link_down_count: number of times link went from up to down
1235 * @fec_type: fec type (enum ionic_port_fec_type)
1236 * @xcvr: transceiver status
1238 struct ionic_port_status {
1242 __le16 link_down_count;
1245 struct ionic_xcvr_status xcvr;
1249 * struct ionic_port_identify_cmd - Port identify command
1251 * @index: port index
1252 * @ver: Highest version of identify supported by driver
1254 struct ionic_port_identify_cmd {
1262 * struct ionic_port_identify_comp - Port identify command completion
1263 * @status: Status of the command (enum ionic_status_code)
1264 * @ver: Version of identify returned by device
1266 struct ionic_port_identify_comp {
1273 * struct ionic_port_init_cmd - Port initialization command
1275 * @index: port index
1276 * @info_pa: destination address for port info (struct ionic_port_info)
1278 struct ionic_port_init_cmd {
1287 * struct ionic_port_init_comp - Port initialization command completion
1288 * @status: Status of the command (enum ionic_status_code)
1290 struct ionic_port_init_comp {
1296 * struct ionic_port_reset_cmd - Port reset command
1298 * @index: port index
1300 struct ionic_port_reset_cmd {
1307 * struct ionic_port_reset_comp - Port reset command completion
1308 * @status: Status of the command (enum ionic_status_code)
1310 struct ionic_port_reset_comp {
1316 * enum ionic_stats_ctl_cmd - List of commands for stats control
1317 * @IONIC_STATS_CTL_RESET: Reset statistics
1319 enum ionic_stats_ctl_cmd {
1320 IONIC_STATS_CTL_RESET = 0,
1324 * enum ionic_port_attr - List of device attributes
1325 * @IONIC_PORT_ATTR_STATE: Port state attribute
1326 * @IONIC_PORT_ATTR_SPEED: Port speed attribute
1327 * @IONIC_PORT_ATTR_MTU: Port MTU attribute
1328 * @IONIC_PORT_ATTR_AUTONEG: Port autonegotiation attribute
1329 * @IONIC_PORT_ATTR_FEC: Port FEC attribute
1330 * @IONIC_PORT_ATTR_PAUSE: Port pause attribute
1331 * @IONIC_PORT_ATTR_LOOPBACK: Port loopback attribute
1332 * @IONIC_PORT_ATTR_STATS_CTRL: Port statistics control attribute
1334 enum ionic_port_attr {
1335 IONIC_PORT_ATTR_STATE = 0,
1336 IONIC_PORT_ATTR_SPEED = 1,
1337 IONIC_PORT_ATTR_MTU = 2,
1338 IONIC_PORT_ATTR_AUTONEG = 3,
1339 IONIC_PORT_ATTR_FEC = 4,
1340 IONIC_PORT_ATTR_PAUSE = 5,
1341 IONIC_PORT_ATTR_LOOPBACK = 6,
1342 IONIC_PORT_ATTR_STATS_CTRL = 7,
1346 * struct ionic_port_setattr_cmd - Set port attributes on the NIC
1348 * @index: Port index
1349 * @attr: Attribute type (enum ionic_port_attr)
1350 * @state: Port state
1351 * @speed: Port speed
1353 * @an_enable: Port autonegotiation setting
1354 * @fec_type: Port FEC type setting
1355 * @pause_type: Port pause type setting
1356 * @loopback_mode: Port loopback mode
1357 * @stats_ctl: Port stats setting
1359 struct ionic_port_setattr_cmd {
1378 * struct ionic_port_setattr_comp - Port set attr command completion
1379 * @status: Status of the command (enum ionic_status_code)
1382 struct ionic_port_setattr_comp {
1389 * struct ionic_port_getattr_cmd - Get port attributes from the NIC
1391 * @index: port index
1392 * @attr: Attribute type (enum ionic_port_attr)
1394 struct ionic_port_getattr_cmd {
1402 * struct ionic_port_getattr_comp - Port get attr command completion
1403 * @status: Status of the command (enum ionic_status_code)
1404 * @state: Port state
1405 * @speed: Port speed
1407 * @an_enable: Port autonegotiation setting
1408 * @fec_type: Port FEC type setting
1409 * @pause_type: Port pause type setting
1410 * @loopback_mode: Port loopback mode
1413 struct ionic_port_getattr_comp {
1430 * struct ionic_lif_status - LIF status register
1431 * @eid: most recent NotifyQ event id
1432 * @port_num: port the LIF is connected to
1433 * @link_status: port status (enum ionic_port_oper_status)
1434 * @link_speed: speed of link in Mbps
1435 * @link_down_count: number of times link went from up to down
1437 struct ionic_lif_status {
1442 __le32 link_speed; /* units of 1Mbps: eg 10000 = 10Gbps */
1443 __le16 link_down_count;
1448 * struct ionic_lif_reset_cmd - LIF reset command
1452 struct ionic_lif_reset_cmd {
1459 typedef struct ionic_admin_comp ionic_lif_reset_comp;
1461 enum ionic_dev_state {
1462 IONIC_DEV_DISABLE = 0,
1463 IONIC_DEV_ENABLE = 1,
1464 IONIC_DEV_HANG_RESET = 2,
1468 * enum ionic_dev_attr - List of device attributes
1469 * @IONIC_DEV_ATTR_STATE: Device state attribute
1470 * @IONIC_DEV_ATTR_NAME: Device name attribute
1471 * @IONIC_DEV_ATTR_FEATURES: Device feature attributes
1473 enum ionic_dev_attr {
1474 IONIC_DEV_ATTR_STATE = 0,
1475 IONIC_DEV_ATTR_NAME = 1,
1476 IONIC_DEV_ATTR_FEATURES = 2,
1480 * struct ionic_dev_setattr_cmd - Set Device attributes on the NIC
1482 * @attr: Attribute type (enum ionic_dev_attr)
1483 * @state: Device state (enum ionic_dev_state)
1484 * @name: The bus info, e.g. PCI slot-device-function, 0 terminated
1485 * @features: Device features
1487 struct ionic_dev_setattr_cmd {
1493 char name[IONIC_IFNAMSIZ];
1500 * struct ionic_dev_setattr_comp - Device set attr command completion
1501 * @status: Status of the command (enum ionic_status_code)
1502 * @features: Device features
1505 struct ionic_dev_setattr_comp {
1516 * struct ionic_dev_getattr_cmd - Get Device attributes from the NIC
1518 * @attr: Attribute type (enum ionic_dev_attr)
1520 struct ionic_dev_getattr_cmd {
1527 * struct ionic_dev_setattr_comp - Device set attr command completion
1528 * @status: Status of the command (enum ionic_status_code)
1529 * @features: Device features
1532 struct ionic_dev_getattr_comp {
1545 #define IONIC_RSS_HASH_KEY_SIZE 40
1547 enum ionic_rss_hash_types {
1548 IONIC_RSS_TYPE_IPV4 = BIT(0),
1549 IONIC_RSS_TYPE_IPV4_TCP = BIT(1),
1550 IONIC_RSS_TYPE_IPV4_UDP = BIT(2),
1551 IONIC_RSS_TYPE_IPV6 = BIT(3),
1552 IONIC_RSS_TYPE_IPV6_TCP = BIT(4),
1553 IONIC_RSS_TYPE_IPV6_UDP = BIT(5),
1557 * enum ionic_lif_attr - List of LIF attributes
1558 * @IONIC_LIF_ATTR_STATE: LIF state attribute
1559 * @IONIC_LIF_ATTR_NAME: LIF name attribute
1560 * @IONIC_LIF_ATTR_MTU: LIF MTU attribute
1561 * @IONIC_LIF_ATTR_MAC: LIF MAC attribute
1562 * @IONIC_LIF_ATTR_FEATURES: LIF features attribute
1563 * @IONIC_LIF_ATTR_RSS: LIF RSS attribute
1564 * @IONIC_LIF_ATTR_STATS_CTRL: LIF statistics control attribute
1566 enum ionic_lif_attr {
1567 IONIC_LIF_ATTR_STATE = 0,
1568 IONIC_LIF_ATTR_NAME = 1,
1569 IONIC_LIF_ATTR_MTU = 2,
1570 IONIC_LIF_ATTR_MAC = 3,
1571 IONIC_LIF_ATTR_FEATURES = 4,
1572 IONIC_LIF_ATTR_RSS = 5,
1573 IONIC_LIF_ATTR_STATS_CTRL = 6,
1577 * struct ionic_lif_setattr_cmd - Set LIF attributes on the NIC
1579 * @attr: Attribute type (enum ionic_lif_attr)
1581 * @state: LIF state (enum ionic_lif_state)
1582 * @name: The netdev name string, 0 terminated
1585 * @features: Features (enum ionic_eth_hw_features)
1586 * @rss: RSS properties
1587 * @types: The hash types to enable (see rss_hash_types)
1588 * @key: The hash secret key
1589 * @addr: Address for the indirection table shared memory
1590 * @stats_ctl: stats control commands (enum ionic_stats_ctl_cmd)
1592 struct ionic_lif_setattr_cmd {
1598 char name[IONIC_IFNAMSIZ];
1604 u8 key[IONIC_RSS_HASH_KEY_SIZE];
1614 * struct ionic_lif_setattr_comp - LIF set attr command completion
1615 * @status: Status of the command (enum ionic_status_code)
1616 * @comp_index: Index in the descriptor ring for which this is the completion
1617 * @features: features (enum ionic_eth_hw_features)
1620 struct ionic_lif_setattr_comp {
1632 * struct ionic_lif_getattr_cmd - Get LIF attributes from the NIC
1634 * @attr: Attribute type (enum ionic_lif_attr)
1637 struct ionic_lif_getattr_cmd {
1645 * struct ionic_lif_getattr_comp - LIF get attr command completion
1646 * @status: Status of the command (enum ionic_status_code)
1647 * @comp_index: Index in the descriptor ring for which this is the completion
1648 * @state: LIF state (enum ionic_lif_state)
1649 * @name: The netdev name string, 0 terminated
1652 * @features: Features (enum ionic_eth_hw_features)
1655 struct ionic_lif_getattr_comp {
1669 enum ionic_rx_mode {
1670 IONIC_RX_MODE_F_UNICAST = BIT(0),
1671 IONIC_RX_MODE_F_MULTICAST = BIT(1),
1672 IONIC_RX_MODE_F_BROADCAST = BIT(2),
1673 IONIC_RX_MODE_F_PROMISC = BIT(3),
1674 IONIC_RX_MODE_F_ALLMULTI = BIT(4),
1675 IONIC_RX_MODE_F_RDMA_SNIFFER = BIT(5),
1679 * struct ionic_rx_mode_set_cmd - Set LIF's Rx mode command
1681 * @lif_index: LIF index
1682 * @rx_mode: Rx mode flags:
1683 * IONIC_RX_MODE_F_UNICAST: Accept known unicast packets
1684 * IONIC_RX_MODE_F_MULTICAST: Accept known multicast packets
1685 * IONIC_RX_MODE_F_BROADCAST: Accept broadcast packets
1686 * IONIC_RX_MODE_F_PROMISC: Accept any packets
1687 * IONIC_RX_MODE_F_ALLMULTI: Accept any multicast packets
1688 * IONIC_RX_MODE_F_RDMA_SNIFFER: Sniff RDMA packets
1690 struct ionic_rx_mode_set_cmd {
1698 typedef struct ionic_admin_comp ionic_rx_mode_set_comp;
1700 enum ionic_rx_filter_match_type {
1701 IONIC_RX_FILTER_MATCH_VLAN = 0,
1702 IONIC_RX_FILTER_MATCH_MAC,
1703 IONIC_RX_FILTER_MATCH_MAC_VLAN,
1707 * struct ionic_rx_filter_add_cmd - Add LIF Rx filter command
1709 * @qtype: Queue type
1710 * @lif_index: LIF index
1712 * @match: Rx filter match type (see IONIC_RX_FILTER_MATCH_xxx)
1713 * @vlan: VLAN filter
1716 * @addr: MAC address (network-byte order)
1717 * @mac_vlan: MACVLAN filter
1719 * @addr: MAC address (network-byte order)
1721 struct ionic_rx_filter_add_cmd {
1743 * struct ionic_rx_filter_add_comp - Add LIF Rx filter command completion
1744 * @status: Status of the command (enum ionic_status_code)
1745 * @comp_index: Index in the descriptor ring for which this is the completion
1746 * @filter_id: Filter ID
1749 struct ionic_rx_filter_add_comp {
1759 * struct ionic_rx_filter_del_cmd - Delete LIF Rx filter command
1761 * @lif_index: LIF index
1762 * @filter_id: Filter ID
1764 struct ionic_rx_filter_del_cmd {
1772 typedef struct ionic_admin_comp ionic_rx_filter_del_comp;
1774 enum ionic_vf_attr {
1775 IONIC_VF_ATTR_SPOOFCHK = 1,
1776 IONIC_VF_ATTR_TRUST = 2,
1777 IONIC_VF_ATTR_MAC = 3,
1778 IONIC_VF_ATTR_LINKSTATE = 4,
1779 IONIC_VF_ATTR_VLAN = 5,
1780 IONIC_VF_ATTR_RATE = 6,
1781 IONIC_VF_ATTR_STATSADDR = 7,
1785 * enum ionic_vf_link_status - Virtual Function link status
1786 * @IONIC_VF_LINK_STATUS_AUTO: Use link state of the uplink
1787 * @IONIC_VF_LINK_STATUS_UP: Link always up
1788 * @IONIC_VF_LINK_STATUS_DOWN: Link always down
1790 enum ionic_vf_link_status {
1791 IONIC_VF_LINK_STATUS_AUTO = 0,
1792 IONIC_VF_LINK_STATUS_UP = 1,
1793 IONIC_VF_LINK_STATUS_DOWN = 2,
1797 * struct ionic_vf_setattr_cmd - Set VF attributes on the NIC
1799 * @attr: Attribute type (enum ionic_vf_attr)
1800 * @vf_index: VF index
1801 * @macaddr: mac address
1803 * @maxrate: max Tx rate in Mbps
1804 * @spoofchk: enable address spoof checking
1805 * @trust: enable VF trust
1806 * @linkstate: set link up or down
1807 * @stats_pa: set DMA address for VF stats
1809 struct ionic_vf_setattr_cmd {
1825 struct ionic_vf_setattr_comp {
1835 * struct ionic_vf_getattr_cmd - Get VF attributes from the NIC
1837 * @attr: Attribute type (enum ionic_vf_attr)
1838 * @vf_index: VF index
1840 struct ionic_vf_getattr_cmd {
1847 struct ionic_vf_getattr_comp {
1865 * struct ionic_qos_identify_cmd - QoS identify command
1867 * @ver: Highest version of identify supported by driver
1870 struct ionic_qos_identify_cmd {
1877 * struct ionic_qos_identify_comp - QoS identify command completion
1878 * @status: Status of the command (enum ionic_status_code)
1879 * @ver: Version of identify returned by device
1881 struct ionic_qos_identify_comp {
1887 #define IONIC_QOS_TC_MAX 8
1888 #define IONIC_QOS_ALL_TC 0xFF
1889 /* Capri max supported, should be renamed. */
1890 #define IONIC_QOS_CLASS_MAX 7
1891 #define IONIC_QOS_PCP_MAX 8
1892 #define IONIC_QOS_CLASS_NAME_SZ 32
1893 #define IONIC_QOS_DSCP_MAX 64
1894 #define IONIC_QOS_ALL_PCP 0xFF
1895 #define IONIC_DSCP_BLOCK_SIZE 8
1898 * enum ionic_qos_class
1900 enum ionic_qos_class {
1901 IONIC_QOS_CLASS_DEFAULT = 0,
1902 IONIC_QOS_CLASS_USER_DEFINED_1 = 1,
1903 IONIC_QOS_CLASS_USER_DEFINED_2 = 2,
1904 IONIC_QOS_CLASS_USER_DEFINED_3 = 3,
1905 IONIC_QOS_CLASS_USER_DEFINED_4 = 4,
1906 IONIC_QOS_CLASS_USER_DEFINED_5 = 5,
1907 IONIC_QOS_CLASS_USER_DEFINED_6 = 6,
1911 * enum ionic_qos_class_type - Traffic classification criteria
1912 * @IONIC_QOS_CLASS_TYPE_NONE: No QoS
1913 * @IONIC_QOS_CLASS_TYPE_PCP: Dot1Q PCP
1914 * @IONIC_QOS_CLASS_TYPE_DSCP: IP DSCP
1916 enum ionic_qos_class_type {
1917 IONIC_QOS_CLASS_TYPE_NONE = 0,
1918 IONIC_QOS_CLASS_TYPE_PCP = 1,
1919 IONIC_QOS_CLASS_TYPE_DSCP = 2,
1923 * enum ionic_qos_sched_type - QoS class scheduling type
1924 * @IONIC_QOS_SCHED_TYPE_STRICT: Strict priority
1925 * @IONIC_QOS_SCHED_TYPE_DWRR: Deficit weighted round-robin
1927 enum ionic_qos_sched_type {
1928 IONIC_QOS_SCHED_TYPE_STRICT = 0,
1929 IONIC_QOS_SCHED_TYPE_DWRR = 1,
1933 * union ionic_qos_config - QoS configuration structure
1934 * @flags: Configuration flags
1935 * IONIC_QOS_CONFIG_F_ENABLE enable
1936 * IONIC_QOS_CONFIG_F_NO_DROP drop/nodrop
1937 * IONIC_QOS_CONFIG_F_RW_DOT1Q_PCP enable dot1q pcp rewrite
1938 * IONIC_QOS_CONFIG_F_RW_IP_DSCP enable ip dscp rewrite
1939 * IONIC_QOS_CONFIG_F_NON_DISRUPTIVE Non-disruptive TC update
1940 * @sched_type: QoS class scheduling type (enum ionic_qos_sched_type)
1941 * @class_type: QoS class type (enum ionic_qos_class_type)
1942 * @pause_type: QoS pause type (enum ionic_qos_pause_type)
1943 * @name: QoS class name
1944 * @mtu: MTU of the class
1945 * @pfc_cos: Priority-Flow Control class of service
1946 * @dwrr_weight: QoS class scheduling weight
1947 * @strict_rlmt: Rate limit for strict priority scheduling
1948 * @rw_dot1q_pcp: Rewrite dot1q pcp to value (valid iff F_RW_DOT1Q_PCP)
1949 * @rw_ip_dscp: Rewrite ip dscp to value (valid iff F_RW_IP_DSCP)
1950 * @dot1q_pcp: Dot1q pcp value
1951 * @ndscp: Number of valid dscp values in the ip_dscp field
1952 * @ip_dscp: IP dscp values
1954 union ionic_qos_config {
1956 #define IONIC_QOS_CONFIG_F_ENABLE BIT(0)
1957 #define IONIC_QOS_CONFIG_F_NO_DROP BIT(1)
1958 /* Used to rewrite PCP or DSCP value. */
1959 #define IONIC_QOS_CONFIG_F_RW_DOT1Q_PCP BIT(2)
1960 #define IONIC_QOS_CONFIG_F_RW_IP_DSCP BIT(3)
1961 /* Non-disruptive TC update */
1962 #define IONIC_QOS_CONFIG_F_NON_DISRUPTIVE BIT(4)
1967 char name[IONIC_QOS_CLASS_NAME_SZ];
1977 /* Used to rewrite PCP or DSCP value. */
1982 /* classification */
1987 u8 ip_dscp[IONIC_QOS_DSCP_MAX];
1995 * union ionic_qos_identity - QoS identity structure
1996 * @version: Version of the identify structure
1997 * @type: QoS system type
1998 * @nclasses: Number of usable QoS classes
1999 * @config: Current configuration of classes
2001 union ionic_qos_identity {
2006 union ionic_qos_config config[IONIC_QOS_CLASS_MAX];
2012 * struct ionic_qos_init_cmd - QoS config init command
2014 * @group: QoS class id
2015 * @info_pa: destination address for qos info
2017 struct ionic_qos_init_cmd {
2025 typedef struct ionic_admin_comp ionic_qos_init_comp;
2028 * struct ionic_qos_reset_cmd - QoS config reset command
2030 * @group: QoS class id
2032 struct ionic_qos_reset_cmd {
2039 * struct ionic_qos_clear_port_stats_cmd - Qos config reset command
2042 struct ionic_qos_clear_stats_cmd {
2048 typedef struct ionic_admin_comp ionic_qos_reset_comp;
2051 * struct ionic_fw_download_cmd - Firmware download command
2053 * @addr: dma address of the firmware buffer
2054 * @offset: offset of the firmware buffer within the full image
2055 * @length: number of valid bytes in the firmware buffer
2057 struct ionic_fw_download_cmd {
2065 typedef struct ionic_admin_comp ionic_fw_download_comp;
2068 * enum ionic_fw_control_oper - FW control operations
2069 * @IONIC_FW_RESET: Reset firmware
2070 * @IONIC_FW_INSTALL: Install firmware
2071 * @IONIC_FW_ACTIVATE: Acticate firmware
2073 enum ionic_fw_control_oper {
2075 IONIC_FW_INSTALL = 1,
2076 IONIC_FW_ACTIVATE = 2,
2080 * struct ionic_fw_control_cmd - Firmware control command
2082 * @oper: firmware control operation (enum ionic_fw_control_oper)
2083 * @slot: slot to activate
2085 struct ionic_fw_control_cmd {
2094 * struct ionic_fw_control_comp - Firmware control copletion
2095 * @status: Status of the command (enum ionic_status_code)
2096 * @comp_index: Index in the descriptor ring for which this is the completion
2097 * @slot: Slot where the firmware was installed
2100 struct ionic_fw_control_comp {
2109 /******************************************************************
2110 ******************* RDMA Commands ********************************
2111 ******************************************************************/
2114 * struct ionic_rdma_reset_cmd - Reset RDMA LIF cmd
2116 * @lif_index: LIF index
2118 * There is no RDMA specific dev command completion struct. Completion uses
2119 * the common struct ionic_admin_comp. Only the status is indicated.
2120 * Nonzero status means the LIF does not support RDMA.
2122 struct ionic_rdma_reset_cmd {
2130 * struct ionic_rdma_queue_cmd - Create RDMA Queue command
2131 * @opcode: opcode, 52, 53
2132 * @lif_index: LIF index
2133 * @qid_ver: (qid | (RDMA version << 24))
2134 * @cid: intr, eq_id, or cq_id
2135 * @dbid: doorbell page id
2136 * @depth_log2: log base two of queue depth
2137 * @stride_log2: log base two of queue stride
2138 * @dma_addr: address of the queue memory
2140 * The same command struct is used to create an RDMA event queue, completion
2141 * queue, or RDMA admin queue. The cid is an interrupt number for an event
2142 * queue, an event queue id for a completion queue, or a completion queue id
2143 * for an RDMA admin queue.
2145 * The queue created via a dev command must be contiguous in dma space.
2147 * The dev commands are intended only to be used during driver initialization,
2148 * to create queues supporting the RDMA admin queue. Other queues, and other
2149 * types of RDMA resources like memory regions, will be created and registered
2150 * via the RDMA admin queue, and will support a more complete interface
2151 * providing scatter gather lists for larger, scattered queue buffers and
2152 * memory registration.
2154 * There is no RDMA specific dev command completion struct. Completion uses
2155 * the common struct ionic_admin_comp. Only the status is indicated.
2157 struct ionic_rdma_queue_cmd {
2170 /******************************************************************
2171 ******************* Notify Events ********************************
2172 ******************************************************************/
2175 * struct ionic_notifyq_event - Generic event reporting structure
2176 * @eid: event number
2177 * @ecode: event code
2178 * @data: unspecified data about the event
2180 * This is the generic event report struct from which the other
2181 * actual events will be formed.
2183 struct ionic_notifyq_event {
2190 * struct ionic_link_change_event - Link change event notification
2191 * @eid: event number
2192 * @ecode: event code = IONIC_EVENT_LINK_CHANGE
2193 * @link_status: link up/down, with error bits (enum ionic_port_status)
2194 * @link_speed: speed of the network link
2196 * Sent when the network link state changes between UP and DOWN
2198 struct ionic_link_change_event {
2202 __le32 link_speed; /* units of 1Mbps: e.g. 10000 = 10Gbps */
2207 * struct ionic_reset_event - Reset event notification
2208 * @eid: event number
2209 * @ecode: event code = IONIC_EVENT_RESET
2210 * @reset_code: reset type
2211 * @state: 0=pending, 1=complete, 2=error
2213 * Sent when the NIC or some subsystem is going to be or
2216 struct ionic_reset_event {
2225 * struct ionic_heartbeat_event - Sent periodically by NIC to indicate health
2226 * @eid: event number
2227 * @ecode: event code = IONIC_EVENT_HEARTBEAT
2229 struct ionic_heartbeat_event {
2236 * struct ionic_log_event - Sent to notify the driver of an internal error
2237 * @eid: event number
2238 * @ecode: event code = IONIC_EVENT_LOG
2241 struct ionic_log_event {
2248 * struct ionic_xcvr_event - Transceiver change event
2249 * @eid: event number
2250 * @ecode: event code = IONIC_EVENT_XCVR
2252 struct ionic_xcvr_event {
2259 * struct ionic_port_stats - Port statistics structure
2261 struct ionic_port_stats {
2262 __le64 frames_rx_ok;
2263 __le64 frames_rx_all;
2264 __le64 frames_rx_bad_fcs;
2265 __le64 frames_rx_bad_all;
2266 __le64 octets_rx_ok;
2267 __le64 octets_rx_all;
2268 __le64 frames_rx_unicast;
2269 __le64 frames_rx_multicast;
2270 __le64 frames_rx_broadcast;
2271 __le64 frames_rx_pause;
2272 __le64 frames_rx_bad_length;
2273 __le64 frames_rx_undersized;
2274 __le64 frames_rx_oversized;
2275 __le64 frames_rx_fragments;
2276 __le64 frames_rx_jabber;
2277 __le64 frames_rx_pripause;
2278 __le64 frames_rx_stomped_crc;
2279 __le64 frames_rx_too_long;
2280 __le64 frames_rx_vlan_good;
2281 __le64 frames_rx_dropped;
2282 __le64 frames_rx_less_than_64b;
2283 __le64 frames_rx_64b;
2284 __le64 frames_rx_65b_127b;
2285 __le64 frames_rx_128b_255b;
2286 __le64 frames_rx_256b_511b;
2287 __le64 frames_rx_512b_1023b;
2288 __le64 frames_rx_1024b_1518b;
2289 __le64 frames_rx_1519b_2047b;
2290 __le64 frames_rx_2048b_4095b;
2291 __le64 frames_rx_4096b_8191b;
2292 __le64 frames_rx_8192b_9215b;
2293 __le64 frames_rx_other;
2294 __le64 frames_tx_ok;
2295 __le64 frames_tx_all;
2296 __le64 frames_tx_bad;
2297 __le64 octets_tx_ok;
2298 __le64 octets_tx_total;
2299 __le64 frames_tx_unicast;
2300 __le64 frames_tx_multicast;
2301 __le64 frames_tx_broadcast;
2302 __le64 frames_tx_pause;
2303 __le64 frames_tx_pripause;
2304 __le64 frames_tx_vlan;
2305 __le64 frames_tx_less_than_64b;
2306 __le64 frames_tx_64b;
2307 __le64 frames_tx_65b_127b;
2308 __le64 frames_tx_128b_255b;
2309 __le64 frames_tx_256b_511b;
2310 __le64 frames_tx_512b_1023b;
2311 __le64 frames_tx_1024b_1518b;
2312 __le64 frames_tx_1519b_2047b;
2313 __le64 frames_tx_2048b_4095b;
2314 __le64 frames_tx_4096b_8191b;
2315 __le64 frames_tx_8192b_9215b;
2316 __le64 frames_tx_other;
2317 __le64 frames_tx_pri_0;
2318 __le64 frames_tx_pri_1;
2319 __le64 frames_tx_pri_2;
2320 __le64 frames_tx_pri_3;
2321 __le64 frames_tx_pri_4;
2322 __le64 frames_tx_pri_5;
2323 __le64 frames_tx_pri_6;
2324 __le64 frames_tx_pri_7;
2325 __le64 frames_rx_pri_0;
2326 __le64 frames_rx_pri_1;
2327 __le64 frames_rx_pri_2;
2328 __le64 frames_rx_pri_3;
2329 __le64 frames_rx_pri_4;
2330 __le64 frames_rx_pri_5;
2331 __le64 frames_rx_pri_6;
2332 __le64 frames_rx_pri_7;
2333 __le64 tx_pripause_0_1us_count;
2334 __le64 tx_pripause_1_1us_count;
2335 __le64 tx_pripause_2_1us_count;
2336 __le64 tx_pripause_3_1us_count;
2337 __le64 tx_pripause_4_1us_count;
2338 __le64 tx_pripause_5_1us_count;
2339 __le64 tx_pripause_6_1us_count;
2340 __le64 tx_pripause_7_1us_count;
2341 __le64 rx_pripause_0_1us_count;
2342 __le64 rx_pripause_1_1us_count;
2343 __le64 rx_pripause_2_1us_count;
2344 __le64 rx_pripause_3_1us_count;
2345 __le64 rx_pripause_4_1us_count;
2346 __le64 rx_pripause_5_1us_count;
2347 __le64 rx_pripause_6_1us_count;
2348 __le64 rx_pripause_7_1us_count;
2349 __le64 rx_pause_1us_count;
2350 __le64 frames_tx_truncated;
2353 struct ionic_mgmt_port_stats {
2354 __le64 frames_rx_ok;
2355 __le64 frames_rx_all;
2356 __le64 frames_rx_bad_fcs;
2357 __le64 frames_rx_bad_all;
2358 __le64 octets_rx_ok;
2359 __le64 octets_rx_all;
2360 __le64 frames_rx_unicast;
2361 __le64 frames_rx_multicast;
2362 __le64 frames_rx_broadcast;
2363 __le64 frames_rx_pause;
2364 __le64 frames_rx_bad_length;
2365 __le64 frames_rx_undersized;
2366 __le64 frames_rx_oversized;
2367 __le64 frames_rx_fragments;
2368 __le64 frames_rx_jabber;
2369 __le64 frames_rx_64b;
2370 __le64 frames_rx_65b_127b;
2371 __le64 frames_rx_128b_255b;
2372 __le64 frames_rx_256b_511b;
2373 __le64 frames_rx_512b_1023b;
2374 __le64 frames_rx_1024b_1518b;
2375 __le64 frames_rx_gt_1518b;
2376 __le64 frames_rx_fifo_full;
2377 __le64 frames_tx_ok;
2378 __le64 frames_tx_all;
2379 __le64 frames_tx_bad;
2380 __le64 octets_tx_ok;
2381 __le64 octets_tx_total;
2382 __le64 frames_tx_unicast;
2383 __le64 frames_tx_multicast;
2384 __le64 frames_tx_broadcast;
2385 __le64 frames_tx_pause;
2388 enum ionic_pb_buffer_drop_stats {
2389 IONIC_BUFFER_INTRINSIC_DROP = 0,
2390 IONIC_BUFFER_DISCARDED,
2391 IONIC_BUFFER_ADMITTED,
2392 IONIC_BUFFER_OUT_OF_CELLS_DROP,
2393 IONIC_BUFFER_OUT_OF_CELLS_DROP_2,
2394 IONIC_BUFFER_OUT_OF_CREDIT_DROP,
2395 IONIC_BUFFER_TRUNCATION_DROP,
2396 IONIC_BUFFER_PORT_DISABLED_DROP,
2397 IONIC_BUFFER_COPY_TO_CPU_TAIL_DROP,
2398 IONIC_BUFFER_SPAN_TAIL_DROP,
2399 IONIC_BUFFER_MIN_SIZE_VIOLATION_DROP,
2400 IONIC_BUFFER_ENQUEUE_ERROR_DROP,
2401 IONIC_BUFFER_INVALID_PORT_DROP,
2402 IONIC_BUFFER_INVALID_OUTPUT_QUEUE_DROP,
2403 IONIC_BUFFER_DROP_MAX,
2406 enum ionic_oflow_drop_stats {
2407 IONIC_OFLOW_OCCUPANCY_DROP,
2408 IONIC_OFLOW_EMERGENCY_STOP_DROP,
2409 IONIC_OFLOW_WRITE_BUFFER_ACK_FILL_UP_DROP,
2410 IONIC_OFLOW_WRITE_BUFFER_ACK_FULL_DROP,
2411 IONIC_OFLOW_WRITE_BUFFER_FULL_DROP,
2412 IONIC_OFLOW_CONTROL_FIFO_FULL_DROP,
2413 IONIC_OFLOW_DROP_MAX,
2417 * struct port_pb_stats - packet buffers system stats
2418 * uses ionic_pb_buffer_drop_stats for drop_counts[]
2420 struct ionic_port_pb_stats {
2421 __le64 sop_count_in;
2422 __le64 eop_count_in;
2423 __le64 sop_count_out;
2424 __le64 eop_count_out;
2425 __le64 drop_counts[IONIC_BUFFER_DROP_MAX];
2426 __le64 input_queue_buffer_occupancy[IONIC_QOS_TC_MAX];
2427 __le64 input_queue_port_monitor[IONIC_QOS_TC_MAX];
2428 __le64 output_queue_port_monitor[IONIC_QOS_TC_MAX];
2429 __le64 oflow_drop_counts[IONIC_OFLOW_DROP_MAX];
2430 __le64 input_queue_good_pkts_in[IONIC_QOS_TC_MAX];
2431 __le64 input_queue_good_pkts_out[IONIC_QOS_TC_MAX];
2432 __le64 input_queue_err_pkts_in[IONIC_QOS_TC_MAX];
2433 __le64 input_queue_fifo_depth[IONIC_QOS_TC_MAX];
2434 __le64 input_queue_max_fifo_depth[IONIC_QOS_TC_MAX];
2435 __le64 input_queue_peak_occupancy[IONIC_QOS_TC_MAX];
2436 __le64 output_queue_buffer_occupancy[IONIC_QOS_TC_MAX];
2440 * enum ionic_port_type - Port types
2441 * @IONIC_ETH_UNKNOWN: Port type not configured
2442 * @IONIC_ETH_HOST: Port carries ethernet traffic (inband)
2443 * @IONIC_ETH_HOST_MGMT: Port carries mgmt traffic (out-of-band)
2444 * @IONIC_ETH_MNIC_OOB_MGMT:
2445 * @IONIC_ETH_MNIC_INTERNAL_MGMT:
2446 * @IONIC_ETH_MNIC_INBAND_MGMT:
2447 * @IONIC_ETH_MNIC_CPU:
2448 * @IONIC_ETH_MNIC_LEARN:
2449 * @IONIC_ETH_MNIC_CONTROL:
2451 enum ionic_port_type {
2454 IONIC_ETH_HOST_MGMT,
2455 IONIC_ETH_MNIC_OOB_MGMT,
2456 IONIC_ETH_MNIC_INTERNAL_MGMT,
2457 IONIC_ETH_MNIC_INBAND_MGMT,
2459 IONIC_ETH_MNIC_LEARN,
2460 IONIC_ETH_MNIC_CONTROL,
2464 * struct ionic_port_identity - port identity structure
2465 * @version: identity structure version
2466 * @type: type of port (enum ionic_port_type)
2467 * @num_lanes: number of lanes for the port
2468 * @autoneg: autoneg supported
2469 * @min_frame_size: minimum frame size supported
2470 * @max_frame_size: maximum frame size supported
2471 * @fec_type: supported fec types
2472 * @pause_type: supported pause types
2473 * @loopback_mode: supported loopback mode
2474 * @speeds: supported speeds
2475 * @config: current port configuration
2477 union ionic_port_identity {
2483 __le32 min_frame_size;
2484 __le32 max_frame_size;
2487 u8 loopback_mode[2];
2490 union ionic_port_config config;
2496 * struct ionic_port_info - port info structure
2497 * @config: Port configuration data
2498 * @status: Port status data
2499 * @stats: Port statistics data
2500 * @mgmt_stats: Port management statistics data
2501 * @port_pb_drop_stats: uplink pb drop stats
2503 struct ionic_port_info {
2504 union ionic_port_config config;
2505 struct ionic_port_status status;
2507 struct ionic_port_stats stats;
2508 struct ionic_mgmt_port_stats mgmt_stats;
2510 /* room for pb_stats to start at 2k offset */
2512 struct ionic_port_pb_stats pb_stats;
2516 * struct ionic_lif_stats - LIF statistics structure
2518 struct ionic_lif_stats {
2520 __le64 rx_ucast_bytes;
2521 __le64 rx_ucast_packets;
2522 __le64 rx_mcast_bytes;
2523 __le64 rx_mcast_packets;
2524 __le64 rx_bcast_bytes;
2525 __le64 rx_bcast_packets;
2529 __le64 rx_ucast_drop_bytes;
2530 __le64 rx_ucast_drop_packets;
2531 __le64 rx_mcast_drop_bytes;
2532 __le64 rx_mcast_drop_packets;
2533 __le64 rx_bcast_drop_bytes;
2534 __le64 rx_bcast_drop_packets;
2535 __le64 rx_dma_error;
2538 __le64 tx_ucast_bytes;
2539 __le64 tx_ucast_packets;
2540 __le64 tx_mcast_bytes;
2541 __le64 tx_mcast_packets;
2542 __le64 tx_bcast_bytes;
2543 __le64 tx_bcast_packets;
2547 __le64 tx_ucast_drop_bytes;
2548 __le64 tx_ucast_drop_packets;
2549 __le64 tx_mcast_drop_bytes;
2550 __le64 tx_mcast_drop_packets;
2551 __le64 tx_bcast_drop_bytes;
2552 __le64 tx_bcast_drop_packets;
2553 __le64 tx_dma_error;
2555 /* Rx Queue/Ring drops */
2556 __le64 rx_queue_disabled;
2557 __le64 rx_queue_empty;
2558 __le64 rx_queue_error;
2559 __le64 rx_desc_fetch_error;
2560 __le64 rx_desc_data_error;
2564 /* Tx Queue/Ring drops */
2565 __le64 tx_queue_disabled;
2566 __le64 tx_queue_error;
2567 __le64 tx_desc_fetch_error;
2568 __le64 tx_desc_data_error;
2569 __le64 tx_queue_empty;
2575 __le64 tx_rdma_ucast_bytes;
2576 __le64 tx_rdma_ucast_packets;
2577 __le64 tx_rdma_mcast_bytes;
2578 __le64 tx_rdma_mcast_packets;
2579 __le64 tx_rdma_cnp_packets;
2585 __le64 rx_rdma_ucast_bytes;
2586 __le64 rx_rdma_ucast_packets;
2587 __le64 rx_rdma_mcast_bytes;
2588 __le64 rx_rdma_mcast_packets;
2589 __le64 rx_rdma_cnp_packets;
2590 __le64 rx_rdma_ecn_packets;
2630 /* RDMA/ROCE REQ Error/Debugs (768 - 895) */
2631 __le64 rdma_req_rx_pkt_seq_err;
2632 __le64 rdma_req_rx_rnr_retry_err;
2633 __le64 rdma_req_rx_remote_access_err;
2634 __le64 rdma_req_rx_remote_inv_req_err;
2635 __le64 rdma_req_rx_remote_oper_err;
2636 __le64 rdma_req_rx_implied_nak_seq_err;
2637 __le64 rdma_req_rx_cqe_err;
2638 __le64 rdma_req_rx_cqe_flush_err;
2640 __le64 rdma_req_rx_dup_responses;
2641 __le64 rdma_req_rx_invalid_packets;
2642 __le64 rdma_req_tx_local_access_err;
2643 __le64 rdma_req_tx_local_oper_err;
2644 __le64 rdma_req_tx_memory_mgmt_err;
2649 /* RDMA/ROCE RESP Error/Debugs (896 - 1023) */
2650 __le64 rdma_resp_rx_dup_requests;
2651 __le64 rdma_resp_rx_out_of_buffer;
2652 __le64 rdma_resp_rx_out_of_seq_pkts;
2653 __le64 rdma_resp_rx_cqe_err;
2654 __le64 rdma_resp_rx_cqe_flush_err;
2655 __le64 rdma_resp_rx_local_len_err;
2656 __le64 rdma_resp_rx_inv_request_err;
2657 __le64 rdma_resp_rx_local_qp_oper_err;
2659 __le64 rdma_resp_rx_out_of_atomic_resource;
2660 __le64 rdma_resp_tx_pkt_seq_err;
2661 __le64 rdma_resp_tx_remote_inv_req_err;
2662 __le64 rdma_resp_tx_remote_access_err;
2663 __le64 rdma_resp_tx_remote_oper_err;
2664 __le64 rdma_resp_tx_rnr_retry_err;
2670 * struct ionic_lif_info - LIF info structure
2671 * @config: LIF configuration structure
2672 * @status: LIF status structure
2673 * @stats: LIF statistics structure
2675 struct ionic_lif_info {
2676 union ionic_lif_config config;
2677 struct ionic_lif_status status;
2678 struct ionic_lif_stats stats;
2681 union ionic_dev_cmd {
2683 struct ionic_admin_cmd cmd;
2684 struct ionic_nop_cmd nop;
2686 struct ionic_dev_identify_cmd identify;
2687 struct ionic_dev_init_cmd init;
2688 struct ionic_dev_reset_cmd reset;
2689 struct ionic_dev_getattr_cmd getattr;
2690 struct ionic_dev_setattr_cmd setattr;
2692 struct ionic_port_identify_cmd port_identify;
2693 struct ionic_port_init_cmd port_init;
2694 struct ionic_port_reset_cmd port_reset;
2695 struct ionic_port_getattr_cmd port_getattr;
2696 struct ionic_port_setattr_cmd port_setattr;
2698 struct ionic_vf_setattr_cmd vf_setattr;
2699 struct ionic_vf_getattr_cmd vf_getattr;
2701 struct ionic_lif_identify_cmd lif_identify;
2702 struct ionic_lif_init_cmd lif_init;
2703 struct ionic_lif_reset_cmd lif_reset;
2705 struct ionic_qos_identify_cmd qos_identify;
2706 struct ionic_qos_init_cmd qos_init;
2707 struct ionic_qos_reset_cmd qos_reset;
2708 struct ionic_qos_clear_stats_cmd qos_clear_stats;
2710 struct ionic_q_identify_cmd q_identify;
2711 struct ionic_q_init_cmd q_init;
2712 struct ionic_q_control_cmd q_control;
2715 union ionic_dev_cmd_comp {
2718 struct ionic_admin_comp comp;
2719 struct ionic_nop_comp nop;
2721 struct ionic_dev_identify_comp identify;
2722 struct ionic_dev_init_comp init;
2723 struct ionic_dev_reset_comp reset;
2724 struct ionic_dev_getattr_comp getattr;
2725 struct ionic_dev_setattr_comp setattr;
2727 struct ionic_port_identify_comp port_identify;
2728 struct ionic_port_init_comp port_init;
2729 struct ionic_port_reset_comp port_reset;
2730 struct ionic_port_getattr_comp port_getattr;
2731 struct ionic_port_setattr_comp port_setattr;
2733 struct ionic_vf_setattr_comp vf_setattr;
2734 struct ionic_vf_getattr_comp vf_getattr;
2736 struct ionic_lif_identify_comp lif_identify;
2737 struct ionic_lif_init_comp lif_init;
2738 ionic_lif_reset_comp lif_reset;
2740 struct ionic_qos_identify_comp qos_identify;
2741 ionic_qos_init_comp qos_init;
2742 ionic_qos_reset_comp qos_reset;
2744 struct ionic_q_identify_comp q_identify;
2745 struct ionic_q_init_comp q_init;
2749 * union ionic_dev_info_regs - Device info register format (read-only)
2750 * @signature: Signature value of 0x44455649 ('DEVI')
2751 * @version: Current version of info
2752 * @asic_type: Asic type
2753 * @asic_rev: Asic revision
2754 * @fw_status: Firmware status
2755 * @fw_heartbeat: Firmware heartbeat counter
2756 * @serial_num: Serial number
2757 * @fw_version: Firmware version
2759 union ionic_dev_info_regs {
2760 #define IONIC_DEVINFO_FWVERS_BUFLEN 32
2761 #define IONIC_DEVINFO_SERIAL_BUFLEN 32
2767 #define IONIC_FW_STS_F_RUNNING 0x1
2770 char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];
2771 char serial_num[IONIC_DEVINFO_SERIAL_BUFLEN];
2777 * union ionic_dev_cmd_regs - Device command register format (read-write)
2778 * @doorbell: Device Cmd Doorbell, write-only
2779 * Write a 1 to signal device to process cmd,
2780 * poll done for completion.
2781 * @done: Done indicator, bit 0 == 1 when command is complete
2782 * @cmd: Opcode-specific command bytes
2783 * @comp: Opcode-specific response bytes
2784 * @data: Opcode-specific side-data
2786 union ionic_dev_cmd_regs {
2790 union ionic_dev_cmd cmd;
2791 union ionic_dev_cmd_comp comp;
2799 * union ionic_dev_regs - Device register format for bar 0 page 0
2800 * @info: Device info registers
2801 * @devcmd: Device command registers
2803 union ionic_dev_regs {
2805 union ionic_dev_info_regs info;
2806 union ionic_dev_cmd_regs devcmd;
2811 union ionic_adminq_cmd {
2812 struct ionic_admin_cmd cmd;
2813 struct ionic_nop_cmd nop;
2814 struct ionic_q_identify_cmd q_identify;
2815 struct ionic_q_init_cmd q_init;
2816 struct ionic_q_control_cmd q_control;
2817 struct ionic_lif_setattr_cmd lif_setattr;
2818 struct ionic_lif_getattr_cmd lif_getattr;
2819 struct ionic_rx_mode_set_cmd rx_mode_set;
2820 struct ionic_rx_filter_add_cmd rx_filter_add;
2821 struct ionic_rx_filter_del_cmd rx_filter_del;
2822 struct ionic_rdma_reset_cmd rdma_reset;
2823 struct ionic_rdma_queue_cmd rdma_queue;
2824 struct ionic_fw_download_cmd fw_download;
2825 struct ionic_fw_control_cmd fw_control;
2828 union ionic_adminq_comp {
2829 struct ionic_admin_comp comp;
2830 struct ionic_nop_comp nop;
2831 struct ionic_q_identify_comp q_identify;
2832 struct ionic_q_init_comp q_init;
2833 struct ionic_lif_setattr_comp lif_setattr;
2834 struct ionic_lif_getattr_comp lif_getattr;
2835 struct ionic_rx_filter_add_comp rx_filter_add;
2836 struct ionic_fw_control_comp fw_control;
2839 #define IONIC_BARS_MAX 6
2840 #define IONIC_PCI_BAR_DBELL 1
2843 #define IONIC_BAR0_SIZE 0x8000
2845 #define IONIC_BAR0_DEV_INFO_REGS_OFFSET 0x0000
2846 #define IONIC_BAR0_DEV_CMD_REGS_OFFSET 0x0800
2847 #define IONIC_BAR0_DEV_CMD_DATA_REGS_OFFSET 0x0c00
2848 #define IONIC_BAR0_INTR_STATUS_OFFSET 0x1000
2849 #define IONIC_BAR0_INTR_CTRL_OFFSET 0x2000
2850 #define IONIC_DEV_CMD_DONE 0x00000001
2852 #define IONIC_ASIC_TYPE_CAPRI 0
2855 * struct ionic_doorbell - Doorbell register layout
2856 * @p_index: Producer index
2857 * @ring: Selects the specific ring of the queue to update
2858 * Type-specific meaning:
2859 * ring=0: Default producer/consumer queue
2860 * ring=1: (CQ, EQ) Re-Arm queue. RDMA CQs
2861 * send events to EQs when armed. EQs send
2862 * interrupts when armed.
2863 * @qid_lo: Queue destination for the producer index and flags (low bits)
2864 * @qid_hi: Queue destination for the producer index and flags (high bits)
2866 struct ionic_doorbell {
2875 * struct ionic_intr_ctrl - Interrupt control register
2876 * @coalescing_init: Coalescing timer initial value, in
2877 * device units. Use @identity->intr_coal_mult
2878 * and @identity->intr_coal_div to convert from
2879 * usecs to device units:
2881 * coal_init = coal_usecs * coal_mutl / coal_div
2883 * When an interrupt is sent the interrupt
2884 * coalescing timer current value
2885 * (@coalescing_curr) is initialized with this
2886 * value and begins counting down. No more
2887 * interrupts are sent until the coalescing
2888 * timer reaches 0. When @coalescing_init=0
2889 * interrupt coalescing is effectively disabled
2890 * and every interrupt assert results in an
2891 * interrupt. Reset value: 0
2892 * @mask: Interrupt mask. When @mask=1 the interrupt
2893 * resource will not send an interrupt. When
2894 * @mask=0 the interrupt resource will send an
2895 * interrupt if an interrupt event is pending
2896 * or on the next interrupt assertion event.
2898 * @int_credits: Interrupt credits. This register indicates
2899 * how many interrupt events the hardware has
2900 * sent. When written by software this
2901 * register atomically decrements @int_credits
2902 * by the value written. When @int_credits
2903 * becomes 0 then the "pending interrupt" bit
2904 * in the Interrupt Status register is cleared
2905 * by the hardware and any pending but unsent
2906 * interrupts are cleared.
2907 * !!!IMPORTANT!!! This is a signed register.
2908 * @flags: Interrupt control flags
2909 * @unmask -- When this bit is written with a 1
2910 * the interrupt resource will set mask=0.
2911 * @coal_timer_reset -- When this
2912 * bit is written with a 1 the
2913 * @coalescing_curr will be reloaded with
2914 * @coalescing_init to reset the coalescing
2916 * @mask_on_assert: Automatically mask on assertion. When
2917 * @mask_on_assert=1 the interrupt resource
2918 * will set @mask=1 whenever an interrupt is
2919 * sent. When using interrupts in Legacy
2920 * Interrupt mode the driver must select
2921 * @mask_on_assert=0 for proper interrupt
2923 * @coalescing_curr: Coalescing timer current value, in
2924 * microseconds. When this value reaches 0
2925 * the interrupt resource is again eligible to
2926 * send an interrupt. If an interrupt event
2927 * is already pending when @coalescing_curr
2928 * reaches 0 the pending interrupt will be
2929 * sent, otherwise an interrupt will be sent
2930 * on the next interrupt assertion event.
2932 struct ionic_intr_ctrl {
2939 #define INTR_F_UNMASK 0x0001
2940 #define INTR_F_TIMER_RESET 0x0002
2948 #define IONIC_INTR_CTRL_REGS_MAX 2048
2949 #define IONIC_INTR_CTRL_COAL_MAX 0x3F
2951 #define intr_to_coal(intr_ctrl) \
2952 ((void __iomem *)&(intr_ctrl)->coalescing_init)
2953 #define intr_to_mask(intr_ctrl) \
2954 ((void __iomem *)&(intr_ctrl)->mask)
2955 #define intr_to_credits(intr_ctrl) \
2956 ((void __iomem *)&(intr_ctrl)->int_credits)
2957 #define intr_to_mask_on_assert(intr_ctrl)\
2958 ((void __iomem *)&(intr_ctrl)->mask_on_assert)
2960 struct ionic_intr_status {
2964 struct ionic_notifyq_cmd {
2965 __le32 data; /* Not used but needed for qcq structure */
2968 union ionic_notifyq_comp {
2969 struct ionic_notifyq_event event;
2970 struct ionic_link_change_event link_change;
2971 struct ionic_reset_event reset;
2972 struct ionic_heartbeat_event heartbeat;
2973 struct ionic_log_event log;
2977 * struct ionic_eq_comp - Event queue completion descriptor
2979 * @code: Event code, see enum ionic_eq_comp_code
2980 * @lif_index: To which LIF the event pertains
2981 * @qid: To which queue id the event pertains
2982 * @gen_color: Event queue wrap counter, init 1, incr each wrap
2984 struct ionic_eq_comp {
2992 enum ionic_eq_comp_code {
2993 IONIC_EQ_COMP_CODE_NONE = 0,
2994 IONIC_EQ_COMP_CODE_RX_COMP = 1,
2995 IONIC_EQ_COMP_CODE_TX_COMP = 2,
2999 struct ionic_identity {
3000 union ionic_drv_identity drv;
3001 union ionic_dev_identity dev;
3002 union ionic_lif_identity lif;
3003 union ionic_port_identity port;
3004 union ionic_qos_identity qos;
3005 union ionic_q_identity txq;
3008 #endif /* _IONIC_IF_H_ */