1809f0800SChristian Ehrhardt/*-
2809f0800SChristian Ehrhardt *   BSD LICENSE
3809f0800SChristian Ehrhardt *
4809f0800SChristian Ehrhardt *   Copyright(c) Broadcom Limited.
5809f0800SChristian Ehrhardt *   All rights reserved.
6809f0800SChristian Ehrhardt *
7809f0800SChristian Ehrhardt *   Redistribution and use in source and binary forms, with or without
8809f0800SChristian Ehrhardt *   modification, are permitted provided that the following conditions
9809f0800SChristian Ehrhardt *   are met:
10809f0800SChristian Ehrhardt *
11809f0800SChristian Ehrhardt *     * Redistributions of source code must retain the above copyright
12809f0800SChristian Ehrhardt *       notice, this list of conditions and the following disclaimer.
13809f0800SChristian Ehrhardt *     * Redistributions in binary form must reproduce the above copyright
14809f0800SChristian Ehrhardt *       notice, this list of conditions and the following disclaimer in
15809f0800SChristian Ehrhardt *       the documentation and/or other materials provided with the
16809f0800SChristian Ehrhardt *       distribution.
17809f0800SChristian Ehrhardt *     * Neither the name of Broadcom Corporation nor the names of its
18809f0800SChristian Ehrhardt *       contributors may be used to endorse or promote products derived
19809f0800SChristian Ehrhardt *       from this software without specific prior written permission.
20809f0800SChristian Ehrhardt *
21809f0800SChristian Ehrhardt *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22809f0800SChristian Ehrhardt *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23809f0800SChristian Ehrhardt *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24809f0800SChristian Ehrhardt *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25809f0800SChristian Ehrhardt *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26809f0800SChristian Ehrhardt *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27809f0800SChristian Ehrhardt *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28809f0800SChristian Ehrhardt *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29809f0800SChristian Ehrhardt *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30809f0800SChristian Ehrhardt *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31809f0800SChristian Ehrhardt *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32809f0800SChristian Ehrhardt */
33809f0800SChristian Ehrhardt
34809f0800SChristian Ehrhardt#ifndef _HSI_STRUCT_DEF_EXTERNAL_H_
35809f0800SChristian Ehrhardt#define _HSI_STRUCT_DEF_EXTERNAL_H_
36809f0800SChristian Ehrhardt
37809f0800SChristian Ehrhardt/*
38809f0800SChristian Ehrhardt * per-context HW statistics -- chip view
39809f0800SChristian Ehrhardt */
40809f0800SChristian Ehrhardt
41809f0800SChristian Ehrhardtstruct ctx_hw_stats64 {
42809f0800SChristian Ehrhardt	uint64_t rx_ucast_pkts;
43809f0800SChristian Ehrhardt	uint64_t rx_mcast_pkts;
44809f0800SChristian Ehrhardt	uint64_t rx_bcast_pkts;
45809f0800SChristian Ehrhardt	uint64_t rx_drop_pkts;
463d9b7210SChristian Ehrhardt	uint64_t rx_discard_pkts;
47809f0800SChristian Ehrhardt	uint64_t rx_ucast_bytes;
48809f0800SChristian Ehrhardt	uint64_t rx_mcast_bytes;
49809f0800SChristian Ehrhardt	uint64_t rx_bcast_bytes;
50809f0800SChristian Ehrhardt
51809f0800SChristian Ehrhardt	uint64_t tx_ucast_pkts;
52809f0800SChristian Ehrhardt	uint64_t tx_mcast_pkts;
53809f0800SChristian Ehrhardt	uint64_t tx_bcast_pkts;
54809f0800SChristian Ehrhardt	uint64_t tx_drop_pkts;
553d9b7210SChristian Ehrhardt	uint64_t tx_discard_pkts;
56809f0800SChristian Ehrhardt	uint64_t tx_ucast_bytes;
57809f0800SChristian Ehrhardt	uint64_t tx_mcast_bytes;
58809f0800SChristian Ehrhardt	uint64_t tx_bcast_bytes;
59809f0800SChristian Ehrhardt
60809f0800SChristian Ehrhardt	uint64_t tpa_pkts;
61809f0800SChristian Ehrhardt	uint64_t tpa_bytes;
62809f0800SChristian Ehrhardt	uint64_t tpa_events;
63809f0800SChristian Ehrhardt	uint64_t tpa_aborts;
643d9b7210SChristian Ehrhardt} __attribute__((packed));
65809f0800SChristian Ehrhardt
663d9b7210SChristian Ehrhardt/* HW Resource Manager Specification 1.5.1 */
67809f0800SChristian Ehrhardt#define HWRM_VERSION_MAJOR	1
683d9b7210SChristian Ehrhardt#define HWRM_VERSION_MINOR	5
693d9b7210SChristian Ehrhardt#define HWRM_VERSION_UPDATE	1
703d9b7210SChristian Ehrhardt
713d9b7210SChristian Ehrhardt#define HWRM_VERSION_STR	"1.5.1"
72809f0800SChristian Ehrhardt
73809f0800SChristian Ehrhardt/*
74809f0800SChristian Ehrhardt * Following is the signature for HWRM message field that indicates not
75809f0800SChristian Ehrhardt * applicable (All F's). Need to cast it the size of the field if needed.
76809f0800SChristian Ehrhardt */
77809f0800SChristian Ehrhardt#define HWRM_NA_SIGNATURE        ((uint32_t)(-1))
78809f0800SChristian Ehrhardt#define HWRM_MAX_REQ_LEN	(128)  /* hwrm_func_buf_rgtr */
79809f0800SChristian Ehrhardt#define HWRM_MAX_RESP_LEN	(176)  /* hwrm_func_qstats */
80809f0800SChristian Ehrhardt#define HW_HASH_INDEX_SIZE      0x80    /* 7 bit indirection table index. */
81809f0800SChristian Ehrhardt#define HW_HASH_KEY_SIZE        40
82809f0800SChristian Ehrhardt#define HWRM_RESP_VALID_KEY	1 /* valid key for HWRM response */
83809f0800SChristian Ehrhardt
84809f0800SChristian Ehrhardt/*
85809f0800SChristian Ehrhardt * Request types
86809f0800SChristian Ehrhardt */
87809f0800SChristian Ehrhardt#define HWRM_VER_GET			(UINT32_C(0x0))
88809f0800SChristian Ehrhardt#define HWRM_FUNC_RESET			(UINT32_C(0x11))
89809f0800SChristian Ehrhardt#define HWRM_FUNC_QCAPS			(UINT32_C(0x15))
903d9b7210SChristian Ehrhardt#define HWRM_FUNC_QCFG			(UINT32_C(0x16))
91809f0800SChristian Ehrhardt#define HWRM_FUNC_DRV_UNRGTR		(UINT32_C(0x1a))
92809f0800SChristian Ehrhardt#define HWRM_FUNC_DRV_RGTR		(UINT32_C(0x1d))
93809f0800SChristian Ehrhardt#define HWRM_PORT_PHY_CFG		(UINT32_C(0x20))
94809f0800SChristian Ehrhardt#define HWRM_PORT_PHY_QCFG		(UINT32_C(0x27))
95809f0800SChristian Ehrhardt#define HWRM_QUEUE_QPORTCFG		(UINT32_C(0x30))
96809f0800SChristian Ehrhardt#define HWRM_VNIC_ALLOC			(UINT32_C(0x40))
97809f0800SChristian Ehrhardt#define HWRM_VNIC_FREE			(UINT32_C(0x41))
98809f0800SChristian Ehrhardt#define HWRM_VNIC_CFG			(UINT32_C(0x42))
99809f0800SChristian Ehrhardt#define HWRM_VNIC_RSS_CFG		(UINT32_C(0x46))
100809f0800SChristian Ehrhardt#define HWRM_RING_ALLOC			(UINT32_C(0x50))
101809f0800SChristian Ehrhardt#define HWRM_RING_FREE			(UINT32_C(0x51))
102809f0800SChristian Ehrhardt#define HWRM_RING_GRP_ALLOC		(UINT32_C(0x60))
103809f0800SChristian Ehrhardt#define HWRM_RING_GRP_FREE		(UINT32_C(0x61))
104809f0800SChristian Ehrhardt#define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC	(UINT32_C(0x70))
105809f0800SChristian Ehrhardt#define HWRM_VNIC_RSS_COS_LB_CTX_FREE	(UINT32_C(0x71))
106809f0800SChristian Ehrhardt#define HWRM_CFA_L2_FILTER_ALLOC	(UINT32_C(0x90))
107809f0800SChristian Ehrhardt#define HWRM_CFA_L2_FILTER_FREE		(UINT32_C(0x91))
108809f0800SChristian Ehrhardt#define HWRM_CFA_L2_FILTER_CFG		(UINT32_C(0x92))
109809f0800SChristian Ehrhardt#define HWRM_CFA_L2_SET_RX_MASK		(UINT32_C(0x93))
110809f0800SChristian Ehrhardt#define HWRM_STAT_CTX_ALLOC		(UINT32_C(0xb0))
111809f0800SChristian Ehrhardt#define HWRM_STAT_CTX_FREE		(UINT32_C(0xb1))
112809f0800SChristian Ehrhardt#define HWRM_STAT_CTX_CLR_STATS		(UINT32_C(0xb3))
113809f0800SChristian Ehrhardt#define HWRM_EXEC_FWD_RESP		(UINT32_C(0xd0))
114809f0800SChristian Ehrhardt
115809f0800SChristian Ehrhardt/* Return Codes */
116809f0800SChristian Ehrhardt#define HWRM_ERR_CODE_INVALID_PARAMS                      (UINT32_C(0x2))
117809f0800SChristian Ehrhardt#define HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED              (UINT32_C(0x3))
118809f0800SChristian Ehrhardt
119809f0800SChristian Ehrhardt/* Short TX BD (16 bytes) */
120809f0800SChristian Ehrhardtstruct tx_bd_short {
1213d9b7210SChristian Ehrhardt	uint16_t flags_type;
122809f0800SChristian Ehrhardt	/*
1233d9b7210SChristian Ehrhardt	 * All bits in this field must be valid on the first BD of a
1243d9b7210SChristian Ehrhardt	 * packet. Only the packet_end bit must be valid for the
1253d9b7210SChristian Ehrhardt	 * remaining BDs of a packet.
126809f0800SChristian Ehrhardt	 */
127809f0800SChristian Ehrhardt	/* This value identifies the type of buffer descriptor. */
1283d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_TYPE_MASK	UINT32_C(0x3f)
1293d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_TYPE_SFT	0
130809f0800SChristian Ehrhardt	/*
1313d9b7210SChristian Ehrhardt	 * Indicates that this BD is 16B long and is
1323d9b7210SChristian Ehrhardt	 * used for normal L2 packet transmission.
133809f0800SChristian Ehrhardt	 */
1343d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_TYPE_TX_BD_SHORT	UINT32_C(0x0)
135809f0800SChristian Ehrhardt	/*
1363d9b7210SChristian Ehrhardt	 * If set to 1, the packet ends with the data in the buffer
1373d9b7210SChristian Ehrhardt	 * pointed to by this descriptor. This flag must be valid on
1383d9b7210SChristian Ehrhardt	 * every BD.
139809f0800SChristian Ehrhardt	 */
1403d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_PACKET_END	UINT32_C(0x40)
141809f0800SChristian Ehrhardt	/*
1423d9b7210SChristian Ehrhardt	 * If set to 1, the device will not generate a completion for
1433d9b7210SChristian Ehrhardt	 * this transmit packet unless there is an error in it's
1443d9b7210SChristian Ehrhardt	 * processing. If this bit is set to 0, then the packet will be
1453d9b7210SChristian Ehrhardt	 * completed normally. This bit must be valid only on the first
1463d9b7210SChristian Ehrhardt	 * BD of a packet.
1473d9b7210SChristian Ehrhardt	 */
1483d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_NO_CMPL	UINT32_C(0x80)
1493d9b7210SChristian Ehrhardt	/*
1503d9b7210SChristian Ehrhardt	 * This value indicates how many 16B BD locations are consumed
1513d9b7210SChristian Ehrhardt	 * in the ring by this packet. A value of 1 indicates that this
1523d9b7210SChristian Ehrhardt	 * BD is the only BD (and that the it is a short BD). A value of
1533d9b7210SChristian Ehrhardt	 * 3 indicates either 3 short BDs or 1 long BD and one short BD
1543d9b7210SChristian Ehrhardt	 * in the packet. A value of 0 indicates that there are 32 BD
1553d9b7210SChristian Ehrhardt	 * locations in the packet (the maximum). This field is valid
1563d9b7210SChristian Ehrhardt	 * only on the first BD of a packet.
1573d9b7210SChristian Ehrhardt	 */
1583d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_BD_CNT_MASK	UINT32_C(0x1f00)
1593d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_BD_CNT_SFT	8
1603d9b7210SChristian Ehrhardt	/*
1613d9b7210SChristian Ehrhardt	 * This value is a hint for the length of the entire packet. It
1623d9b7210SChristian Ehrhardt	 * is used by the chip to optimize internal processing. The
1633d9b7210SChristian Ehrhardt	 * packet will be dropped if the hint is too short. This field
1643d9b7210SChristian Ehrhardt	 * is valid only on the first BD of a packet.
1653d9b7210SChristian Ehrhardt	 */
1663d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_MASK	UINT32_C(0x6000)
1673d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_SFT	13
1683d9b7210SChristian Ehrhardt	/* indicates packet length < 512B */
1693d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_LT512	(UINT32_C(0x0) << 13)
1703d9b7210SChristian Ehrhardt	/* indicates 512 <= packet length < 1KB */
1713d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_LT1K	(UINT32_C(0x1) << 13)
1723d9b7210SChristian Ehrhardt	/* indicates 1KB <= packet length < 2KB */
1733d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_LT2K	(UINT32_C(0x2) << 13)
1743d9b7210SChristian Ehrhardt	/* indicates packet length >= 2KB */
1753d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_GTE2K	(UINT32_C(0x3) << 13)
1763d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_LHINT_LAST	TX_BD_SHORT_FLAGS_LHINT_GTE2K
1773d9b7210SChristian Ehrhardt	/*
1783d9b7210SChristian Ehrhardt	 * If set to 1, the device immediately updates the Send Consumer
1793d9b7210SChristian Ehrhardt	 * Index after the buffer associated with this descriptor has
1803d9b7210SChristian Ehrhardt	 * been transferred via DMA to NIC memory from host memory. An
1813d9b7210SChristian Ehrhardt	 * interrupt may or may not be generated according to the state
1823d9b7210SChristian Ehrhardt	 * of the interrupt avoidance mechanisms. If this bit is set to
1833d9b7210SChristian Ehrhardt	 * 0, then the Consumer Index is only updated as soon as one of
1843d9b7210SChristian Ehrhardt	 * the host interrupt coalescing conditions has been met. This
1853d9b7210SChristian Ehrhardt	 * bit must be valid on the first BD of a packet.
186809f0800SChristian Ehrhardt	 */
1873d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_COAL_NOW	UINT32_C(0x8000)
1883d9b7210SChristian Ehrhardt	/*
1893d9b7210SChristian Ehrhardt	 * All bits in this field must be valid on the first BD of a
1903d9b7210SChristian Ehrhardt	 * packet. Only the packet_end bit must be valid for the
1913d9b7210SChristian Ehrhardt	 * remaining BDs of a packet.
1923d9b7210SChristian Ehrhardt	 */
1933d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_MASK	UINT32_C(0xffc0)
1943d9b7210SChristian Ehrhardt	#define TX_BD_SHORT_FLAGS_SFT	6
195809f0800SChristian Ehrhardt	uint16_t len;
196809f0800SChristian Ehrhardt	/*
1973d9b7210SChristian Ehrhardt	 * This is the length of the host physical buffer this BD
1983d9b7210SChristian Ehrhardt	 * describes in bytes. This field must be valid on all BDs of a
1993d9b7210SChristian Ehrhardt	 * packet.
200809f0800SChristian Ehrhardt	 */
201809f0800SChristian Ehrhardt	uint32_t opaque;
202809f0800SChristian Ehrhardt	/*
2033d9b7210SChristian Ehrhardt	 * The opaque data field is pass through to the completion and
2043d9b7210SChristian Ehrhardt	 * can be used for any data that the driver wants to associate
2053d9b7210SChristian Ehrhardt	 * with the transmit BD. This field must be valid on the first
2063d9b7210SChristian Ehrhardt	 * BD of a packet.
207809f0800SChristian Ehrhardt	 */
208809f0800SChristian Ehrhardt	uint64_t addr;
2093d9b7210SChristian Ehrhardt	/*
2103d9b7210SChristian Ehrhardt	 * This is the host physical address for the portion of the
2113d9b7210SChristian Ehrhardt	 * packet described by this TX BD. This value must be valid on
2123d9b7210SChristian Ehrhardt	 * all BDs of a packet.
2133d9b7210SChristian Ehrhardt	 */
214809f0800SChristian Ehrhardt} __attribute__((packed));
215809f0800SChristian Ehrhardt
216809f0800SChristian Ehrhardt/* Long TX BD (32 bytes split to 2 16-byte struct) */
217809f0800SChristian Ehrhardtstruct tx_bd_long {
2183d9b7210SChristian Ehrhardt	uint16_t flags_type;
219809f0800SChristian Ehrhardt	/*
2203d9b7210SChristian Ehrhardt	 * All bits in this field must be valid on the first BD of a
2213d9b7210SChristian Ehrhardt	 * packet. Only the packet_end bit must be valid for the
2223d9b7210SChristian Ehrhardt	 * remaining BDs of a packet.
223809f0800SChristian Ehrhardt	 */
224809f0800SChristian Ehrhardt	/* This value identifies the type of buffer descriptor. */
2253d9b7210SChristian Ehrhardt	#define TX_BD_LONG_TYPE_MASK	UINT32_C(0x3f)
2263d9b7210SChristian Ehrhardt	#define TX_BD_LONG_TYPE_SFT	0
227809f0800SChristian Ehrhardt	/*
2283d9b7210SChristian Ehrhardt	 * Indicates that this BD is 32B long and is
2293d9b7210SChristian Ehrhardt	 * used for normal L2 packet transmission.
230809f0800SChristian Ehrhardt	 */
2313d9b7210SChristian Ehrhardt	#define TX_BD_LONG_TYPE_TX_BD_LONG	UINT32_C(0x10)
232809f0800SChristian Ehrhardt	/*
2333d9b7210SChristian Ehrhardt	 * If set to 1, the packet ends with the data in the buffer
2343d9b7210SChristian Ehrhardt	 * pointed to by this descriptor. This flag must be valid on
2353d9b7210SChristian Ehrhardt	 * every BD.
236809f0800SChristian Ehrhardt	 */
2373d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_PACKET_END	UINT32_C(0x40)
2383d9b7210SChristian Ehrhardt	/*
2393d9b7210SChristian Ehrhardt	 * If set to 1, the device will not generate a completion for
2403d9b7210SChristian Ehrhardt	 * this transmit packet unless there is an error in it's
2413d9b7210SChristian Ehrhardt	 * processing. If this bit is set to 0, then the packet will be
2423d9b7210SChristian Ehrhardt	 * completed normally. This bit must be valid only on the first
2433d9b7210SChristian Ehrhardt	 * BD of a packet.
2443d9b7210SChristian Ehrhardt	 */
2453d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_NO_CMPL	UINT32_C(0x80)
2463d9b7210SChristian Ehrhardt	/*
2473d9b7210SChristian Ehrhardt	 * This value indicates how many 16B BD locations are consumed
2483d9b7210SChristian Ehrhardt	 * in the ring by this packet. A value of 1 indicates that this
2493d9b7210SChristian Ehrhardt	 * BD is the only BD (and that the it is a short BD). A value of
2503d9b7210SChristian Ehrhardt	 * 3 indicates either 3 short BDs or 1 long BD and one short BD
2513d9b7210SChristian Ehrhardt	 * in the packet. A value of 0 indicates that there are 32 BD
2523d9b7210SChristian Ehrhardt	 * locations in the packet (the maximum). This field is valid
2533d9b7210SChristian Ehrhardt	 * only on the first BD of a packet.
2543d9b7210SChristian Ehrhardt	 */
2553d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_BD_CNT_MASK	UINT32_C(0x1f00)
2563d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_BD_CNT_SFT	8
2573d9b7210SChristian Ehrhardt	/*
2583d9b7210SChristian Ehrhardt	 * This value is a hint for the length of the entire packet. It
2593d9b7210SChristian Ehrhardt	 * is used by the chip to optimize internal processing. The
2603d9b7210SChristian Ehrhardt	 * packet will be dropped if the hint is too short. This field
2613d9b7210SChristian Ehrhardt	 * is valid only on the first BD of a packet.
2623d9b7210SChristian Ehrhardt	 */
2633d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_MASK	UINT32_C(0x6000)
2643d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_SFT	13
2653d9b7210SChristian Ehrhardt	/* indicates packet length < 512B */
2663d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_LT512	(UINT32_C(0x0) << 13)
2673d9b7210SChristian Ehrhardt	/* indicates 512 <= packet length < 1KB */
2683d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_LT1K	(UINT32_C(0x1) << 13)
2693d9b7210SChristian Ehrhardt	/* indicates 1KB <= packet length < 2KB */
2703d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_LT2K	(UINT32_C(0x2) << 13)
2713d9b7210SChristian Ehrhardt	/* indicates packet length >= 2KB */
2723d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_GTE2K	(UINT32_C(0x3) << 13)
2733d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_LHINT_LAST	TX_BD_LONG_FLAGS_LHINT_GTE2K
2743d9b7210SChristian Ehrhardt	/*
2753d9b7210SChristian Ehrhardt	 * If set to 1, the device immediately updates the Send Consumer
2763d9b7210SChristian Ehrhardt	 * Index after the buffer associated with this descriptor has
2773d9b7210SChristian Ehrhardt	 * been transferred via DMA to NIC memory from host memory. An
2783d9b7210SChristian Ehrhardt	 * interrupt may or may not be generated according to the state
2793d9b7210SChristian Ehrhardt	 * of the interrupt avoidance mechanisms. If this bit is set to
2803d9b7210SChristian Ehrhardt	 * 0, then the Consumer Index is only updated as soon as one of
2813d9b7210SChristian Ehrhardt	 * the host interrupt coalescing conditions has been met. This
2823d9b7210SChristian Ehrhardt	 * bit must be valid on the first BD of a packet.
2833d9b7210SChristian Ehrhardt	 */
2843d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_COAL_NOW	UINT32_C(0x8000)
285809f0800SChristian Ehrhardt	/*
2863d9b7210SChristian Ehrhardt	 * All bits in this field must be valid on the first BD of a
2873d9b7210SChristian Ehrhardt	 * packet. Only the packet_end bit must be valid for the
2883d9b7210SChristian Ehrhardt	 * remaining BDs of a packet.
289809f0800SChristian Ehrhardt	 */
2903d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_MASK	UINT32_C(0xffc0)
2913d9b7210SChristian Ehrhardt	#define TX_BD_LONG_FLAGS_SFT	6
292809f0800SChristian Ehrhardt	uint16_t len;
293809f0800SChristian Ehrhardt	/*
2943d9b7210SChristian Ehrhardt	 * This is the length of the host physical buffer this BD
2953d9b7210SChristian Ehrhardt	 * describes in bytes. This field must be valid on all BDs of a
2963d9b7210SChristian Ehrhardt	 * packet.
297809f0800SChristian Ehrhardt	 */
298809f0800SChristian Ehrhardt	uint32_t opaque;
299809f0800SChristian Ehrhardt	/*
3003d9b7210SChristian Ehrhardt	 * The opaque data field is pass through to the completion and
3013d9b7210SChristian Ehrhardt	 * can be used for any data that the driver wants to associate
3023d9b7210SChristian Ehrhardt	 * with the transmit BD. This field must be valid on the first
3033d9b7210SChristian Ehrhardt	 * BD of a packet.
304809f0800SChristian Ehrhardt	 */
305809f0800SChristian Ehrhardt	uint64_t addr;
3063d9b7210SChristian Ehrhardt	/*
3073d9b7210SChristian Ehrhardt	 * This is the host physical address for the portion of the
3083d9b7210SChristian Ehrhardt	 * packet described by this TX BD. This value must be valid on
3093d9b7210SChristian Ehrhardt	 * all BDs of a packet.
3103d9b7210SChristian Ehrhardt	 */
311809f0800SChristian Ehrhardt} __attribute__((packed));
312809f0800SChristian Ehrhardt
313809f0800SChristian Ehrhardt/* last 16 bytes of Long TX BD */
314809f0800SChristian Ehrhardtstruct tx_bd_long_hi {
3153d9b7210SChristian Ehrhardt	uint16_t lflags;
316809f0800SChristian Ehrhardt	/*
3173d9b7210SChristian Ehrhardt	 * All bits in this field must be valid on the first BD of a
3183d9b7210SChristian Ehrhardt	 * packet. Their value on other BDs of the packet will be
3193d9b7210SChristian Ehrhardt	 * ignored.
320809f0800SChristian Ehrhardt	 */
321809f0800SChristian Ehrhardt	/*
3223d9b7210SChristian Ehrhardt	 * If set to 1, the controller replaces the TCP/UPD checksum
3233d9b7210SChristian Ehrhardt	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
3243d9b7210SChristian Ehrhardt	 * checksum field of the encapsulated TCP/UDP packets with the
3253d9b7210SChristian Ehrhardt	 * hardware calculated TCP/UDP checksum for the packet
3263d9b7210SChristian Ehrhardt	 * associated with this descriptor. The flag is ignored if the
3273d9b7210SChristian Ehrhardt	 * LSO flag is set. This bit must be valid on the first BD of a
3283d9b7210SChristian Ehrhardt	 * packet.
329809f0800SChristian Ehrhardt	 */
330809f0800SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
331809f0800SChristian Ehrhardt	/*
3323d9b7210SChristian Ehrhardt	 * If set to 1, the controller replaces the IP checksum of the
3333d9b7210SChristian Ehrhardt	 * normal packets, or the inner IP checksum of the encapsulated
3343d9b7210SChristian Ehrhardt	 * packets with the hardware calculated IP checksum for the
3353d9b7210SChristian Ehrhardt	 * packet associated with this descriptor. This bit must be
3363d9b7210SChristian Ehrhardt	 * valid on the first BD of a packet.
3373d9b7210SChristian Ehrhardt	 */
3383d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
3393d9b7210SChristian Ehrhardt	/*
3403d9b7210SChristian Ehrhardt	 * If set to 1, the controller will not append an Ethernet CRC
3413d9b7210SChristian Ehrhardt	 * to the end of the frame. This bit must be valid on the first
3423d9b7210SChristian Ehrhardt	 * BD of a packet. Packet must be 64B or longer when this flag
3433d9b7210SChristian Ehrhardt	 * is set. It is not useful to use this bit with any form of TX
3443d9b7210SChristian Ehrhardt	 * offload such as CSO or LSO. The intent is that the packet
3453d9b7210SChristian Ehrhardt	 * from the host already has a valid Ethernet CRC on the packet.
3463d9b7210SChristian Ehrhardt	 */
3473d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_NOCRC	UINT32_C(0x4)
3483d9b7210SChristian Ehrhardt	/*
3493d9b7210SChristian Ehrhardt	 * If set to 1, the device will record the time at which the
3503d9b7210SChristian Ehrhardt	 * packet was actually transmitted at the TX MAC. This bit must
3513d9b7210SChristian Ehrhardt	 * be valid on the first BD of a packet.
3523d9b7210SChristian Ehrhardt	 */
3533d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_STAMP	UINT32_C(0x8)
3543d9b7210SChristian Ehrhardt	/*
3553d9b7210SChristian Ehrhardt	 * If set to 1, The controller replaces the tunnel IP checksum
3563d9b7210SChristian Ehrhardt	 * field with hardware calculated IP checksum for the IP header
3573d9b7210SChristian Ehrhardt	 * of the packet associated with this descriptor. For outer UDP
3583d9b7210SChristian Ehrhardt	 * checksum, global outer UDP checksum TE_NIC register needs to
3593d9b7210SChristian Ehrhardt	 * be enabled. If the global outer UDP checksum TE_NIC register
3603d9b7210SChristian Ehrhardt	 * bit is set, outer UDP checksum will be calculated for the
3613d9b7210SChristian Ehrhardt	 * following cases: 1. Packets with tcp_udp_chksum flag set to
3623d9b7210SChristian Ehrhardt	 * offload checksum for inner packet AND the inner packet is
3633d9b7210SChristian Ehrhardt	 * TCP/UDP. If the inner packet is ICMP for example (non-
3643d9b7210SChristian Ehrhardt	 * TCP/UDP), even if the tcp_udp_chksum is set, the outer UDP
3653d9b7210SChristian Ehrhardt	 * checksum will not be calculated. 2. Packets with lso flag set
3663d9b7210SChristian Ehrhardt	 * which implies inner TCP checksum calculation as part of LSO
3673d9b7210SChristian Ehrhardt	 * operation.
3683d9b7210SChristian Ehrhardt	 */
3693d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
3703d9b7210SChristian Ehrhardt	/*
3713d9b7210SChristian Ehrhardt	 * If set to 1, the device will treat this packet with LSO(Large
3723d9b7210SChristian Ehrhardt	 * Send Offload) processing for both normal or encapsulated
3733d9b7210SChristian Ehrhardt	 * packets, which is a form of TCP segmentation. When this bit
3743d9b7210SChristian Ehrhardt	 * is 1, the hdr_size and mss fields must be valid. The driver
3753d9b7210SChristian Ehrhardt	 * doesn't need to set t_ip_chksum, ip_chksum, and
3763d9b7210SChristian Ehrhardt	 * tcp_udp_chksum flags since the controller will replace the
3773d9b7210SChristian Ehrhardt	 * appropriate checksum fields for segmented packets. When this
3783d9b7210SChristian Ehrhardt	 * bit is 1, the hdr_size and mss fields must be valid.
3793d9b7210SChristian Ehrhardt	 */
3803d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_LSO	UINT32_C(0x20)
3813d9b7210SChristian Ehrhardt	/*
3823d9b7210SChristian Ehrhardt	 * If set to zero when LSO is '1', then the IPID will be treated
3833d9b7210SChristian Ehrhardt	 * as a 16b number and will be wrapped if it exceeds a value of
3843d9b7210SChristian Ehrhardt	 * 0xffff. If set to one when LSO is '1', then the IPID will be
3853d9b7210SChristian Ehrhardt	 * treated as a 15b number and will be wrapped if it exceeds a
3863d9b7210SChristian Ehrhardt	 * value 0f 0x7fff.
3873d9b7210SChristian Ehrhardt	 */
3883d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_IPID_FMT	UINT32_C(0x40)
3893d9b7210SChristian Ehrhardt	/*
3903d9b7210SChristian Ehrhardt	 * If set to zero when LSO is '1', then the IPID of the tunnel
3913d9b7210SChristian Ehrhardt	 * IP header will not be modified during LSO operations. If set
3923d9b7210SChristian Ehrhardt	 * to one when LSO is '1', then the IPID of the tunnel IP header
3933d9b7210SChristian Ehrhardt	 * will be incremented for each subsequent segment of an LSO
3943d9b7210SChristian Ehrhardt	 * operation. The flag is ignored if the LSO packet is a normal
3953d9b7210SChristian Ehrhardt	 * (non-tunneled) TCP packet.
3963d9b7210SChristian Ehrhardt	 */
3973d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_T_IPID	UINT32_C(0x80)
3983d9b7210SChristian Ehrhardt	/*
3993d9b7210SChristian Ehrhardt	 * If set to '1', then the RoCE ICRC will be appended to the
4003d9b7210SChristian Ehrhardt	 * packet. Packet must be a valid RoCE format packet.
4013d9b7210SChristian Ehrhardt	 */
4023d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_ROCE_CRC	UINT32_C(0x100)
4033d9b7210SChristian Ehrhardt	/*
4043d9b7210SChristian Ehrhardt	 * If set to '1', then the FCoE CRC will be appended to the
4053d9b7210SChristian Ehrhardt	 * packet. Packet must be a valid FCoE format packet.
4063d9b7210SChristian Ehrhardt	 */
4073d9b7210SChristian Ehrhardt	#define TX_BD_LONG_LFLAGS_FCOE_CRC	UINT32_C(0x200)
408809f0800SChristian Ehrhardt	uint16_t hdr_size;
409809f0800SChristian Ehrhardt	/*
4103d9b7210SChristian Ehrhardt	 * When LSO is '1', this field must contain the offset of the
4113d9b7210SChristian Ehrhardt	 * TCP payload from the beginning of the packet in as 16b words.
4123d9b7210SChristian Ehrhardt	 * In case of encapsulated/tunneling packet, this field contains
4133d9b7210SChristian Ehrhardt	 * the offset of the inner TCP payload from beginning of the
4143d9b7210SChristian Ehrhardt	 * packet as 16-bit words. This value must be valid on the first
415809f0800SChristian Ehrhardt	 * BD of a packet.
416809f0800SChristian Ehrhardt	 */
4173d9b7210SChristian Ehrhardt	#define TX_BD_LONG_HDR_SIZE_MASK	UINT32_C(0x1ff)
4183d9b7210SChristian Ehrhardt	#define TX_BD_LONG_HDR_SIZE_SFT	0
419809f0800SChristian Ehrhardt	uint32_t mss;
420809f0800SChristian Ehrhardt	/*
4213d9b7210SChristian Ehrhardt	 * This is the MSS value that will be used to do the LSO
4223d9b7210SChristian Ehrhardt	 * processing. The value is the length in bytes of the TCP
4233d9b7210SChristian Ehrhardt	 * payload for each segment generated by the LSO operation. This
4243d9b7210SChristian Ehrhardt	 * value must be valid on the first BD of a packet.
425809f0800SChristian Ehrhardt	 */
4263d9b7210SChristian Ehrhardt	#define TX_BD_LONG_MSS_MASK	UINT32_C(0x7fff)
4273d9b7210SChristian Ehrhardt	#define TX_BD_LONG_MSS_SFT	0
4283d9b7210SChristian Ehrhardt	uint16_t unused_2;
429809f0800SChristian Ehrhardt	uint16_t cfa_action;
430809f0800SChristian Ehrhardt	/*
4313d9b7210SChristian Ehrhardt	 * This value selects a CFA action to perform on the packet. Set
4323d9b7210SChristian Ehrhardt	 * this value to zero if no CFA action is desired. This value
4333d9b7210SChristian Ehrhardt	 * must be valid on the first BD of a packet.
4343d9b7210SChristian Ehrhardt	 */
4353d9b7210SChristian Ehrhardt	uint32_t cfa_meta;
4363d9b7210SChristian Ehrhardt	/*
4373d9b7210SChristian Ehrhardt	 * This value is action meta-data that defines CFA edit
4383d9b7210SChristian Ehrhardt	 * operations that are done in addition to any action editing.
439809f0800SChristian Ehrhardt	 */
440809f0800SChristian Ehrhardt	/* When key=1, This is the VLAN tag VID value. */
441809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
442809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_VID_SFT	0
443809f0800SChristian Ehrhardt	/* When key=1, This is the VLAN tag DE value. */
4443d9b7210SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_DE	UINT32_C(0x1000)
445809f0800SChristian Ehrhardt	/* When key=1, This is the VLAN tag PRI value. */
446809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
447809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_PRI_SFT	13
448809f0800SChristian Ehrhardt	/* When key=1, This is the VLAN tag TPID select value. */
449809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
450809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_SFT	16
4513d9b7210SChristian Ehrhardt	/* 0x88a8 */
452809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_TPID88A8	(UINT32_C(0x0) << 16)
4533d9b7210SChristian Ehrhardt	/* 0x8100 */
454809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_TPID8100	(UINT32_C(0x1) << 16)
4553d9b7210SChristian Ehrhardt	/* 0x9100 */
456809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_TPID9100	(UINT32_C(0x2) << 16)
4573d9b7210SChristian Ehrhardt	/* 0x9200 */
458809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_TPID9200	(UINT32_C(0x3) << 16)
4593d9b7210SChristian Ehrhardt	/* 0x9300 */
460809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_TPID9300	(UINT32_C(0x4) << 16)
4613d9b7210SChristian Ehrhardt	/* Value programmed in CFA VLANTPID register. */
462809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_TPIDCFG	(UINT32_C(0x5) << 16)
4633d9b7210SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_TPID_LAST	\
4643d9b7210SChristian Ehrhardt		TX_BD_LONG_CFA_META_VLAN_TPID_TPIDCFG
465809f0800SChristian Ehrhardt	/* When key=1, This is the VLAN tag TPID select value. */
466809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_RESERVED_MASK	UINT32_C(0xff80000)
467809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_VLAN_RESERVED_SFT	19
468809f0800SChristian Ehrhardt	/*
4693d9b7210SChristian Ehrhardt	 * This field identifies the type of edit to be performed on the
4703d9b7210SChristian Ehrhardt	 * packet. This value must be valid on the first BD of a packet.
4713d9b7210SChristian Ehrhardt	 */
4723d9b7210SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
4733d9b7210SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_KEY_SFT	28
4743d9b7210SChristian Ehrhardt	/* No editing */
4753d9b7210SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_KEY_NONE	(UINT32_C(0x0) << 28)
4763d9b7210SChristian Ehrhardt	/*
4773d9b7210SChristian Ehrhardt	 * - meta[17:16] - TPID select value (0 =
4783d9b7210SChristian Ehrhardt	 * 0x8100). - meta[15:12] - PRI/DE value. -
4793d9b7210SChristian Ehrhardt	 * meta[11:0] - VID value.
4803d9b7210SChristian Ehrhardt	 */
481809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
482809f0800SChristian Ehrhardt	#define TX_BD_LONG_CFA_META_KEY_LAST	TX_BD_LONG_CFA_META_KEY_VLAN_TAG
483809f0800SChristian Ehrhardt} __attribute__((packed));
484809f0800SChristian Ehrhardt
485809f0800SChristian Ehrhardt/* RX Producer Packet BD (16 bytes) */
486809f0800SChristian Ehrhardtstruct rx_prod_pkt_bd {
4873d9b7210SChristian Ehrhardt	uint16_t flags_type;
488809f0800SChristian Ehrhardt	/* This value identifies the type of buffer descriptor. */
4893d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_TYPE_MASK	UINT32_C(0x3f)
4903d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_TYPE_SFT	0
4913d9b7210SChristian Ehrhardt	/*
4923d9b7210SChristian Ehrhardt	 * Indicates that this BD is 16B long and is an
4933d9b7210SChristian Ehrhardt	 * RX Producer (ie. empty) buffer descriptor.
4943d9b7210SChristian Ehrhardt	 */
4953d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_TYPE_RX_PROD_PKT	UINT32_C(0x4)
496809f0800SChristian Ehrhardt	/*
4973d9b7210SChristian Ehrhardt	 * If set to 1, the packet will be placed at the address plus
4983d9b7210SChristian Ehrhardt	 * 2B. The 2 Bytes of padding will be written as zero.
499809f0800SChristian Ehrhardt	 */
500809f0800SChristian Ehrhardt	/*
5013d9b7210SChristian Ehrhardt	 * This is intended to be used when the host buffer is cache-
5023d9b7210SChristian Ehrhardt	 * line aligned to produce packets that are easy to parse in
5033d9b7210SChristian Ehrhardt	 * host memory while still allowing writes to be cache line
5043d9b7210SChristian Ehrhardt	 * aligned.
505809f0800SChristian Ehrhardt	 */
5063d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_FLAGS_SOP_PAD	UINT32_C(0x40)
507809f0800SChristian Ehrhardt	/*
5083d9b7210SChristian Ehrhardt	 * If set to 1, the packet write will be padded out to the
5093d9b7210SChristian Ehrhardt	 * nearest cache-line with zero value padding.
510809f0800SChristian Ehrhardt	 */
511809f0800SChristian Ehrhardt	/*
5123d9b7210SChristian Ehrhardt	 * If receive buffers start/end on cache-line boundaries, this
5133d9b7210SChristian Ehrhardt	 * feature will ensure that all data writes on the PCI bus
5143d9b7210SChristian Ehrhardt	 * start/end on cache line boundaries.
515809f0800SChristian Ehrhardt	 */
5163d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_FLAGS_EOP_PAD	UINT32_C(0x80)
517809f0800SChristian Ehrhardt	/*
5183d9b7210SChristian Ehrhardt	 * This value is the number of additional buffers in the ring
5193d9b7210SChristian Ehrhardt	 * that describe the buffer space to be consumed for the this
5203d9b7210SChristian Ehrhardt	 * packet. If the value is zero, then the packet must fit within
5213d9b7210SChristian Ehrhardt	 * the space described by this BD. If this value is 1 or more,
5223d9b7210SChristian Ehrhardt	 * it indicates how many additional "buffer" BDs are in the ring
5233d9b7210SChristian Ehrhardt	 * immediately following this BD to be used for the same network
5243d9b7210SChristian Ehrhardt	 * packet. Even if the packet to be placed does not need all the
5253d9b7210SChristian Ehrhardt	 * additional buffers, they will be consumed anyway.
526809f0800SChristian Ehrhardt	 */
527809f0800SChristian Ehrhardt	#define RX_PROD_PKT_BD_FLAGS_BUFFERS_MASK	UINT32_C(0x300)
528809f0800SChristian Ehrhardt	#define RX_PROD_PKT_BD_FLAGS_BUFFERS_SFT	8
5293d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_FLAGS_MASK	UINT32_C(0xffc0)
5303d9b7210SChristian Ehrhardt	#define RX_PROD_PKT_BD_FLAGS_SFT	6
5313d9b7210SChristian Ehrhardt	uint16_t len;
532809f0800SChristian Ehrhardt	/*
5333d9b7210SChristian Ehrhardt	 * This is the length in Bytes of the host physical buffer where
5343d9b7210SChristian Ehrhardt	 * data for the packet may be placed in host memory.
535809f0800SChristian Ehrhardt	 */
536809f0800SChristian Ehrhardt	/*
5373d9b7210SChristian Ehrhardt	 * While this is a Byte resolution value, it is often
5383d9b7210SChristian Ehrhardt	 * advantageous to ensure that the buffers provided end on a
5393d9b7210SChristian Ehrhardt	 * host cache line.
540809f0800SChristian Ehrhardt	 */
5413d9b7210SChristian Ehrhardt	uint32_t opaque;
542809f0800SChristian Ehrhardt	/*
5433d9b7210SChristian Ehrhardt	 * The opaque data field is pass through to the completion and
5443d9b7210SChristian Ehrhardt	 * can be used for any data that the driver wants to associate
5453d9b7210SChristian Ehrhardt	 * with this receive buffer set.
546809f0800SChristian Ehrhardt	 */
5473d9b7210SChristian Ehrhardt	uint64_t addr;
548809f0800SChristian Ehrhardt	/*
5493d9b7210SChristian Ehrhardt	 * This is the host physical address where data for the packet
5503d9b7210SChristian Ehrhardt	 * may by placed in host memory.
551809f0800SChristian Ehrhardt	 */
552809f0800SChristian Ehrhardt	/*
5533d9b7210SChristian Ehrhardt	 * While this is a Byte resolution value, it is often
5543d9b7210SChristian Ehrhardt	 * advantageous to ensure that the buffers provide start on a
5553d9b7210SChristian Ehrhardt	 * host cache line.
556809f0800SChristian Ehrhardt	 */
557809f0800SChristian Ehrhardt} __attribute__((packed));
558809f0800SChristian Ehrhardt
559809f0800SChristian Ehrhardt/* Completion Ring Structures */
560809f0800SChristian Ehrhardt/* Note: This structure is used by the HWRM to communicate HWRM Error. */
561809f0800SChristian Ehrhardt/* Base Completion Record (16 bytes) */
562809f0800SChristian Ehrhardtstruct cmpl_base {
5633d9b7210SChristian Ehrhardt	uint16_t type;
564809f0800SChristian Ehrhardt	/* unused is 10 b */
565809f0800SChristian Ehrhardt	/*
5663d9b7210SChristian Ehrhardt	 * This field indicates the exact type of the completion. By
5673d9b7210SChristian Ehrhardt	 * convention, the LSB identifies the length of the record in
5683d9b7210SChristian Ehrhardt	 * 16B units. Even values indicate 16B records. Odd values
5693d9b7210SChristian Ehrhardt	 * indicate 32B records.
5703d9b7210SChristian Ehrhardt	 */
5713d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_MASK	UINT32_C(0x3f)
5723d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_SFT	0
5733d9b7210SChristian Ehrhardt	/* TX L2 completion: Completion of TX packet. Length = 16B */
5743d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_TX_L2	UINT32_C(0x0)
5753d9b7210SChristian Ehrhardt	/*
5763d9b7210SChristian Ehrhardt	 * RX L2 completion: Completion of and L2 RX
5773d9b7210SChristian Ehrhardt	 * packet. Length = 32B
5783d9b7210SChristian Ehrhardt	 */
5793d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_RX_L2	UINT32_C(0x11)
5803d9b7210SChristian Ehrhardt	/*
5813d9b7210SChristian Ehrhardt	 * RX Aggregation Buffer completion : Completion
5823d9b7210SChristian Ehrhardt	 * of an L2 aggregation buffer in support of
5833d9b7210SChristian Ehrhardt	 * TPA, HDS, or Jumbo packet completion. Length
5843d9b7210SChristian Ehrhardt	 * = 16B
5853d9b7210SChristian Ehrhardt	 */
5863d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_RX_AGG	UINT32_C(0x12)
5873d9b7210SChristian Ehrhardt	/*
5883d9b7210SChristian Ehrhardt	 * RX L2 TPA Start Completion: Completion at the
5893d9b7210SChristian Ehrhardt	 * beginning of a TPA operation. Length = 32B
5903d9b7210SChristian Ehrhardt	 */
5913d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_RX_TPA_START	UINT32_C(0x13)
5923d9b7210SChristian Ehrhardt	/*
5933d9b7210SChristian Ehrhardt	 * RX L2 TPA End Completion: Completion at the
5943d9b7210SChristian Ehrhardt	 * end of a TPA operation. Length = 32B
5953d9b7210SChristian Ehrhardt	 */
5963d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_RX_TPA_END	UINT32_C(0x15)
5973d9b7210SChristian Ehrhardt	/*
5983d9b7210SChristian Ehrhardt	 * Statistics Ejection Completion: Completion of
5993d9b7210SChristian Ehrhardt	 * statistics data ejection buffer. Length = 16B
6003d9b7210SChristian Ehrhardt	 */
6013d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_STAT_EJECT	UINT32_C(0x1a)
6023d9b7210SChristian Ehrhardt	/* HWRM Command Completion: Completion of an HWRM command. */
6033d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_HWRM_DONE	UINT32_C(0x20)
6043d9b7210SChristian Ehrhardt	/* Forwarded HWRM Request */
6053d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_HWRM_FWD_REQ	UINT32_C(0x22)
6063d9b7210SChristian Ehrhardt	/* Forwarded HWRM Response */
6073d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_HWRM_FWD_RESP	UINT32_C(0x24)
6083d9b7210SChristian Ehrhardt	/* HWRM Asynchronous Event Information */
6093d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT	UINT32_C(0x2e)
6103d9b7210SChristian Ehrhardt	/* CQ Notification */
6113d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_CQ_NOTIFICATION	UINT32_C(0x30)
6123d9b7210SChristian Ehrhardt	/* SRQ Threshold Event */
6133d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_SRQ_EVENT	UINT32_C(0x32)
6143d9b7210SChristian Ehrhardt	/* DBQ Threshold Event */
6153d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_DBQ_EVENT	UINT32_C(0x34)
6163d9b7210SChristian Ehrhardt	/* QP Async Notification */
6173d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_QP_EVENT	UINT32_C(0x38)
6183d9b7210SChristian Ehrhardt	/* Function Async Notification */
6193d9b7210SChristian Ehrhardt	#define CMPL_BASE_TYPE_FUNC_EVENT	UINT32_C(0x3a)
6203d9b7210SChristian Ehrhardt	/* unused is 10 b */
621809f0800SChristian Ehrhardt	uint16_t info1;
6223d9b7210SChristian Ehrhardt	/* info1 is 16 b */
623809f0800SChristian Ehrhardt	uint32_t info2;
6243d9b7210SChristian Ehrhardt	/* info2 is 32 b */
6253d9b7210SChristian Ehrhardt	uint32_t info3_v;
6263d9b7210SChristian Ehrhardt	/* info3 is 31 b */
627809f0800SChristian Ehrhardt	/*
6283d9b7210SChristian Ehrhardt	 * This value is written by the NIC such that it will be
6293d9b7210SChristian Ehrhardt	 * different for each pass through the completion queue. The
6303d9b7210SChristian Ehrhardt	 * even passes will write 1. The odd passes will write 0.
631809f0800SChristian Ehrhardt	 */
6323d9b7210SChristian Ehrhardt	#define CMPL_BASE_V	UINT32_C(0x1)
633809f0800SChristian Ehrhardt	/* info3 is 31 b */
6343d9b7210SChristian Ehrhardt	#define CMPL_BASE_INFO3_MASK	UINT32_C(0xfffffffe)
6353d9b7210SChristian Ehrhardt	#define CMPL_BASE_INFO3_SFT	1
636809f0800SChristian Ehrhardt	uint32_t info4;
6373d9b7210SChristian Ehrhardt	/* info4 is 32 b */
638809f0800SChristian Ehrhardt} __attribute__((packed));
639809f0800SChristian Ehrhardt
640809f0800SChristian Ehrhardt/* TX Completion Record (16 bytes) */
641809f0800SChristian Ehrhardtstruct tx_cmpl {
6423d9b7210SChristian Ehrhardt	uint16_t flags_type;
643809f0800SChristian Ehrhardt	/*
6443d9b7210SChristian Ehrhardt	 * This field indicates the exact type of the completion. By
6453d9b7210SChristian Ehrhardt	 * convention, the LSB identifies the length of the record in
6463d9b7210SChristian Ehrhardt	 * 16B units. Even values indicate 16B records. Odd values
6473d9b7210SChristian Ehrhardt	 * indicate 32B records.
648809f0800SChristian Ehrhardt	 */
6493d9b7210SChristian Ehrhardt	#define TX_CMPL_TYPE_MASK	UINT32_C(0x3f)
6503d9b7210SChristian Ehrhardt	#define TX_CMPL_TYPE_SFT	0
6513d9b7210SChristian Ehrhardt	/* TX L2 completion: Completion of TX packet. Length = 16B */
6523d9b7210SChristian Ehrhardt	#define TX_CMPL_TYPE_TX_L2	UINT32_C(0x0)
653809f0800SChristian Ehrhardt	/*
6543d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates a packet that has an error
6553d9b7210SChristian Ehrhardt	 * of some type. Type of error is indicated in error_flags.
656809f0800SChristian Ehrhardt	 */
6573d9b7210SChristian Ehrhardt	#define TX_CMPL_FLAGS_ERROR	UINT32_C(0x40)
658809f0800SChristian Ehrhardt	/*
6593d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates that the packet completed
6603d9b7210SChristian Ehrhardt	 * was transmitted using the push acceleration data provided by
6613d9b7210SChristian Ehrhardt	 * the driver. When this bit is '0', it indicates that the
6623d9b7210SChristian Ehrhardt	 * packet had not push acceleration data written or was executed
6633d9b7210SChristian Ehrhardt	 * as a normal packet even though push data was provided.
664809f0800SChristian Ehrhardt	 */
6653d9b7210SChristian Ehrhardt	#define TX_CMPL_FLAGS_PUSH	UINT32_C(0x80)
6663d9b7210SChristian Ehrhardt	#define TX_CMPL_FLAGS_MASK	UINT32_C(0xffc0)
6673d9b7210SChristian Ehrhardt	#define TX_CMPL_FLAGS_SFT	6
668809f0800SChristian Ehrhardt	uint16_t unused_0;
6693d9b7210SChristian Ehrhardt	/* unused1 is 16 b */
6703d9b7210SChristian Ehrhardt	uint32_t opaque;
671809f0800SChristian Ehrhardt	/*
6723d9b7210SChristian Ehrhardt	 * This is a copy of the opaque field from the first TX BD of
6733d9b7210SChristian Ehrhardt	 * this transmitted packet.
674809f0800SChristian Ehrhardt	 */
6753d9b7210SChristian Ehrhardt	uint16_t errors_v;
676809f0800SChristian Ehrhardt	/*
6773d9b7210SChristian Ehrhardt	 * This value is written by the NIC such that it will be
6783d9b7210SChristian Ehrhardt	 * different for each pass through the completion queue. The
6793d9b7210SChristian Ehrhardt	 * even passes will write 1. The odd passes will write 0.
680809f0800SChristian Ehrhardt	 */
6813d9b7210SChristian Ehrhardt	#define TX_CMPL_V	UINT32_C(0x1)
682809f0800SChristian Ehrhardt	/*
6833d9b7210SChristian Ehrhardt	 * This error indicates that there was some sort of problem with
6843d9b7210SChristian Ehrhardt	 * the BDs for the packet.
685809f0800SChristian Ehrhardt	 */
686809f0800SChristian Ehrhardt	#define TX_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
6873d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_BUFFER_ERROR_SFT	1
6883d9b7210SChristian Ehrhardt	/* No error */
689809f0800SChristian Ehrhardt	#define TX_CMPL_ERRORS_BUFFER_ERROR_NO_ERROR	(UINT32_C(0x0) << 1)
6903d9b7210SChristian Ehrhardt	/* Bad Format: BDs were not formatted correctly. */
691809f0800SChristian Ehrhardt	#define TX_CMPL_ERRORS_BUFFER_ERROR_BAD_FMT	(UINT32_C(0x2) << 1)
6923d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_BUFFER_ERROR_LAST	\
6933d9b7210SChristian Ehrhardt		TX_CMPL_ERRORS_BUFFER_ERROR_BAD_FMT
694809f0800SChristian Ehrhardt	/*
6953d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates that the length of the
6963d9b7210SChristian Ehrhardt	 * packet was zero. No packet was transmitted.
697809f0800SChristian Ehrhardt	 */
6983d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_ZERO_LENGTH_PKT	UINT32_C(0x10)
699809f0800SChristian Ehrhardt	/*
7003d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates that the packet was longer
7013d9b7210SChristian Ehrhardt	 * than the programmed limit in TDI. No packet was transmitted.
702809f0800SChristian Ehrhardt	 */
703809f0800SChristian Ehrhardt	#define TX_CMPL_ERRORS_EXCESSIVE_BD_LENGTH	UINT32_C(0x20)
704809f0800SChristian Ehrhardt	/*
7053d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates that one or more of the
7063d9b7210SChristian Ehrhardt	 * BDs associated with this packet generated a PCI error. This
7073d9b7210SChristian Ehrhardt	 * probably means the address was not valid.
708809f0800SChristian Ehrhardt	 */
7093d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_DMA_ERROR	UINT32_C(0x40)
710809f0800SChristian Ehrhardt	/*
7113d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates that the packet was longer
7123d9b7210SChristian Ehrhardt	 * than indicated by the hint. No packet was transmitted.
713809f0800SChristian Ehrhardt	 */
7143d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_HINT_TOO_SHORT	UINT32_C(0x80)
715809f0800SChristian Ehrhardt	/*
7163d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates that the packet was
7173d9b7210SChristian Ehrhardt	 * dropped due to Poison TLP error on one or more of the TLPs in
7183d9b7210SChristian Ehrhardt	 * the PXP completion.
719809f0800SChristian Ehrhardt	 */
7203d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_POISON_TLP_ERROR	UINT32_C(0x100)
7213d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_MASK	UINT32_C(0xfffe)
7223d9b7210SChristian Ehrhardt	#define TX_CMPL_ERRORS_SFT	1
723809f0800SChristian Ehrhardt	uint16_t unused_1;
7243d9b7210SChristian Ehrhardt	/* unused2 is 16 b */
725809f0800SChristian Ehrhardt	uint32_t unused_2;
7263d9b7210SChristian Ehrhardt	/* unused3 is 32 b */
7273d9b7210SChristian Ehrhardt} __attribute__((packed));
728809f0800SChristian Ehrhardt
729809f0800SChristian Ehrhardt/* RX Packet Completion Record (32 bytes split to 2 16-byte struct) */
730809f0800SChristian Ehrhardtstruct rx_pkt_cmpl {
7313d9b7210SChristian Ehrhardt	uint16_t flags_type;
7323d9b7210SChristian Ehrhardt	/*
7333d9b7210SChristian Ehrhardt	 * This field indicates the exact type of the completion. By
7343d9b7210SChristian Ehrhardt	 * convention, the LSB identifies the length of the record in
7353d9b7210SChristian Ehrhardt	 * 16B units. Even values indicate 16B records. Odd values
7363d9b7210SChristian Ehrhardt	 * indicate 32B records.
7373d9b7210SChristian Ehrhardt	 */
7383d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_TYPE_MASK	UINT32_C(0x3f)
7393d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_TYPE_SFT	0
740809f0800SChristian Ehrhardt	/*
7413d9b7210SChristian Ehrhardt	 * RX L2 completion: Completion of and L2 RX
7423d9b7210SChristian Ehrhardt	 * packet. Length = 32B
743809f0800SChristian Ehrhardt	 */
7443d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_TYPE_RX_L2	UINT32_C(0x11)
745809f0800SChristian Ehrhardt	/*
7463d9b7210SChristian Ehrhardt	 * When this bit is '1', it indicates a packet that has an error
7473d9b7210SChristian Ehrhardt	 * of some type. Type of error is indicated in error_flags.
748809f0800SChristian Ehrhardt	 */
7493d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ERROR	UINT32_C(0x40)
750809f0800SChristian Ehrhardt	/* This field indicates how the packet was placed in the buffer. */
751809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_PLACEMENT_MASK	UINT32_C(0x380)
7523d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_PLACEMENT_SFT	7
7533d9b7210SChristian Ehrhardt	/* Normal: Packet was placed using normal algorithm. */
754809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_PLACEMENT_NORMAL	(UINT32_C(0x0) << 7)
7553d9b7210SChristian Ehrhardt	/* Jumbo: Packet was placed using jumbo algorithm. */
756809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_PLACEMENT_JUMBO	(UINT32_C(0x1) << 7)
7573d9b7210SChristian Ehrhardt	/*
7583d9b7210SChristian Ehrhardt	 * Header/Data Separation: Packet was placed
7593d9b7210SChristian Ehrhardt	 * using Header/Data separation algorithm. The
7603d9b7210SChristian Ehrhardt	 * separation location is indicated by the itype
7613d9b7210SChristian Ehrhardt	 * field.
7623d9b7210SChristian Ehrhardt	 */
7633d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_PLACEMENT_HDS	(UINT32_C(0x2) << 7)
7643d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_PLACEMENT_LAST	RX_PKT_CMPL_FLAGS_PLACEMENT_HDS
765809f0800SChristian Ehrhardt	/* This bit is '1' if the RSS field in this completion is valid. */
7663d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_RSS_VALID	UINT32_C(0x400)
7673d9b7210SChristian Ehrhardt	/* unused is 1 b */
768809f0800SChristian Ehrhardt	/*
7693d9b7210SChristian Ehrhardt	 * This value indicates what the inner packet determined for the
7703d9b7210SChristian Ehrhardt	 * packet was.
771809f0800SChristian Ehrhardt	 */
7723d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_MASK	UINT32_C(0xf000)
7733d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_SFT	12
7743d9b7210SChristian Ehrhardt	/* Not Known: Indicates that the packet type was not known. */
775809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 12)
776809f0800SChristian Ehrhardt	/*
7773d9b7210SChristian Ehrhardt	 * IP Packet: Indicates that the packet was an
7783d9b7210SChristian Ehrhardt	 * IP packet, but further classification was not
7793d9b7210SChristian Ehrhardt	 * possible.
7803d9b7210SChristian Ehrhardt	 */
7813d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_IP	(UINT32_C(0x1) << 12)
7823d9b7210SChristian Ehrhardt	/*
7833d9b7210SChristian Ehrhardt	 * TCP Packet: Indicates that the packet was IP
7843d9b7210SChristian Ehrhardt	 * and TCP. This indicates that the
7853d9b7210SChristian Ehrhardt	 * payload_offset field is valid.
7863d9b7210SChristian Ehrhardt	 */
7873d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_TCP	(UINT32_C(0x2) << 12)
7883d9b7210SChristian Ehrhardt	/*
7893d9b7210SChristian Ehrhardt	 * UDP Packet: Indicates that the packet was IP
7903d9b7210SChristian Ehrhardt	 * and UDP. This indicates that the
7913d9b7210SChristian Ehrhardt	 * payload_offset field is valid.
7923d9b7210SChristian Ehrhardt	 */
7933d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_UDP	(UINT32_C(0x3) << 12)
7943d9b7210SChristian Ehrhardt	/*
7953d9b7210SChristian Ehrhardt	 * FCoE Packet: Indicates that the packet was
7963d9b7210SChristian Ehrhardt	 * recognized as a FCoE. This also indicates
7973d9b7210SChristian Ehrhardt	 * that the payload_offset field is valid.
798809f0800SChristian Ehrhardt	 */
7993d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_FCOE	(UINT32_C(0x4) << 12)
8003d9b7210SChristian Ehrhardt	/*
8013d9b7210SChristian Ehrhardt	 * RoCE Packet: Indicates that the packet was
8023d9b7210SChristian Ehrhardt	 * recognized as a RoCE. This also indicates
8033d9b7210SChristian Ehrhardt	 * that the payload_offset field is valid.
8043d9b7210SChristian Ehrhardt	 */
8053d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_ROCE	(UINT32_C(0x5) << 12)
8063d9b7210SChristian Ehrhardt	/*
8073d9b7210SChristian Ehrhardt	 * ICMP Packet: Indicates that the packet was
8083d9b7210SChristian Ehrhardt	 * recognized as ICMP. This indicates that the
8093d9b7210SChristian Ehrhardt	 * payload_offset field is valid.
8103d9b7210SChristian Ehrhardt	 */
8113d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_ICMP	(UINT32_C(0x7) << 12)
8123d9b7210SChristian Ehrhardt	/*
8133d9b7210SChristian Ehrhardt	 * PtP packet wo/timestamp: Indicates that the
8143d9b7210SChristian Ehrhardt	 * packet was recognized as a PtP packet.
8153d9b7210SChristian Ehrhardt	 */
8163d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP	(UINT32_C(0x8) << 12)
8173d9b7210SChristian Ehrhardt	/*
8183d9b7210SChristian Ehrhardt	 * PtP packet w/timestamp: Indicates that the
8193d9b7210SChristian Ehrhardt	 * packet was recognized as a PtP packet and
8203d9b7210SChristian Ehrhardt	 * that a timestamp was taken for the packet.
8213d9b7210SChristian Ehrhardt	 */
8223d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 12)
8233d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_ITYPE_LAST	RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP
8243d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_MASK	UINT32_C(0xffc0)
8253d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS_SFT	6
826809f0800SChristian Ehrhardt	uint16_t len;
827809f0800SChristian Ehrhardt	/*
8283d9b7210SChristian Ehrhardt	 * This is the length of the data for the packet stored in the
8293d9b7210SChristian Ehrhardt	 * buffer(s) identified by the opaque value. This includes the
8303d9b7210SChristian Ehrhardt	 * packet BD and any associated buffer BDs. This does not
8313d9b7210SChristian Ehrhardt	 * include the the length of any data places in aggregation BDs.
832809f0800SChristian Ehrhardt	 */
833809f0800SChristian Ehrhardt	uint32_t opaque;
834809f0800SChristian Ehrhardt	/*
8353d9b7210SChristian Ehrhardt	 * This is a copy of the opaque field from the RX BD this
8363d9b7210SChristian Ehrhardt	 * completion corresponds to.
837809f0800SChristian Ehrhardt	 */
8383d9b7210SChristian Ehrhardt	uint8_t agg_bufs_v1;
8393d9b7210SChristian Ehrhardt	/* unused1 is 2 b */
840809f0800SChristian Ehrhardt	/*
8413d9b7210SChristian Ehrhardt	 * This value is written by the NIC such that it will be
8423d9b7210SChristian Ehrhardt	 * different for each pass through the completion queue. The
8433d9b7210SChristian Ehrhardt	 * even passes will write 1. The odd passes will write 0.
844809f0800SChristian Ehrhardt	 */
8453d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_V1	UINT32_C(0x1)
846809f0800SChristian Ehrhardt	/*
8473d9b7210SChristian Ehrhardt	 * This value is the number of aggregation buffers that follow
8483d9b7210SChristian Ehrhardt	 * this entry in the completion ring that are a part of this
8493d9b7210SChristian Ehrhardt	 * packet. If the value is zero, then the packet is completely
8503d9b7210SChristian Ehrhardt	 * contained in the buffer space provided for the packet in the
8513d9b7210SChristian Ehrhardt	 * RX ring.
852809f0800SChristian Ehrhardt	 */
8533d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_AGG_BUFS_MASK	UINT32_C(0x3e)
8543d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_AGG_BUFS_SFT	1
8553d9b7210SChristian Ehrhardt	/* unused1 is 2 b */
856809f0800SChristian Ehrhardt	uint8_t rss_hash_type;
857809f0800SChristian Ehrhardt	/*
8583d9b7210SChristian Ehrhardt	 * This is the RSS hash type for the packet. The value is packed
8593d9b7210SChristian Ehrhardt	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}
8603d9b7210SChristian Ehrhardt	 * . The value of tuple_extrac_op provides the information about
8613d9b7210SChristian Ehrhardt	 * what fields the hash was computed on. * 0: The RSS hash was
8623d9b7210SChristian Ehrhardt	 * computed over source IP address, destination IP address,
8633d9b7210SChristian Ehrhardt	 * source port, and destination port of inner IP and TCP or UDP
8643d9b7210SChristian Ehrhardt	 * headers. Note: For non-tunneled packets, the packet headers
8653d9b7210SChristian Ehrhardt	 * are considered inner packet headers for the RSS hash
8663d9b7210SChristian Ehrhardt	 * computation purpose. * 1: The RSS hash was computed over
8673d9b7210SChristian Ehrhardt	 * source IP address and destination IP address of inner IP
8683d9b7210SChristian Ehrhardt	 * header. Note: For non-tunneled packets, the packet headers
8693d9b7210SChristian Ehrhardt	 * are considered inner packet headers for the RSS hash
8703d9b7210SChristian Ehrhardt	 * computation purpose. * 2: The RSS hash was computed over
8713d9b7210SChristian Ehrhardt	 * source IP address, destination IP address, source port, and
8723d9b7210SChristian Ehrhardt	 * destination port of IP and TCP or UDP headers of outer tunnel
8733d9b7210SChristian Ehrhardt	 * headers. Note: For non-tunneled packets, this value is not
8743d9b7210SChristian Ehrhardt	 * applicable. * 3: The RSS hash was computed over source IP
8753d9b7210SChristian Ehrhardt	 * address and destination IP address of IP header of outer
8763d9b7210SChristian Ehrhardt	 * tunnel headers. Note: For non-tunneled packets, this value is
8773d9b7210SChristian Ehrhardt	 * not applicable. Note that 4-tuples values listed above are
8783d9b7210SChristian Ehrhardt	 * applicable for layer 4 protocols supported and enabled for
8793d9b7210SChristian Ehrhardt	 * RSS in the hardware, HWRM firmware, and drivers. For example,
8803d9b7210SChristian Ehrhardt	 * if RSS hash is supported and enabled for TCP traffic only,
8813d9b7210SChristian Ehrhardt	 * then the values of tuple_extract_op corresponding to 4-tuples
8823d9b7210SChristian Ehrhardt	 * are only valid for TCP traffic.
883809f0800SChristian Ehrhardt	 */
884809f0800SChristian Ehrhardt	uint8_t payload_offset;
885809f0800SChristian Ehrhardt	/*
8863d9b7210SChristian Ehrhardt	 * This value indicates the offset in bytes from the beginning
8873d9b7210SChristian Ehrhardt	 * of the packet where the inner payload starts. This value is
8883d9b7210SChristian Ehrhardt	 * valid for TCP, UDP, FCoE, and RoCE packets. A value of zero
8893d9b7210SChristian Ehrhardt	 * indicates that header is 256B into the packet.
890809f0800SChristian Ehrhardt	 */
8913d9b7210SChristian Ehrhardt	uint8_t unused_1;
8923d9b7210SChristian Ehrhardt	/* unused2 is 8 b */
893809f0800SChristian Ehrhardt	uint32_t rss_hash;
8943d9b7210SChristian Ehrhardt	/*
8953d9b7210SChristian Ehrhardt	 * This value is the RSS hash value calculated for the packet
8963d9b7210SChristian Ehrhardt	 * based on the mode bits and key value in the VNIC.
8973d9b7210SChristian Ehrhardt	 */
898809f0800SChristian Ehrhardt} __attribute__((packed));
899809f0800SChristian Ehrhardt
900809f0800SChristian Ehrhardt/* last 16 bytes of RX Packet Completion Record */
901809f0800SChristian Ehrhardtstruct rx_pkt_cmpl_hi {
9023d9b7210SChristian Ehrhardt	uint32_t flags2;
903809f0800SChristian Ehrhardt	/*
9043d9b7210SChristian Ehrhardt	 * This indicates that the ip checksum was calculated for the
9053d9b7210SChristian Ehrhardt	 * inner packet and that the ip_cs_error field indicates if
9063d9b7210SChristian Ehrhardt	 * there was an error.
907809f0800SChristian Ehrhardt	 */
9083d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_IP_CS_CALC	UINT32_C(0x1)
909809f0800SChristian Ehrhardt	/*
9103d9b7210SChristian Ehrhardt	 * This indicates that the TCP, UDP or ICMP checksum was
9113d9b7210SChristian Ehrhardt	 * calculated for the inner packet and that the l4_cs_error
9123d9b7210SChristian Ehrhardt	 * field indicates if there was an error.
913809f0800SChristian Ehrhardt	 */
9143d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_L4_CS_CALC	UINT32_C(0x2)
915809f0800SChristian Ehrhardt	/*
9163d9b7210SChristian Ehrhardt	 * This indicates that the ip checksum was calculated for the
9173d9b7210SChristian Ehrhardt	 * tunnel header and that the t_ip_cs_error field indicates if
9183d9b7210SChristian Ehrhardt	 * there was an error.
919809f0800SChristian Ehrhardt	 */
9203d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC	UINT32_C(0x4)
921809f0800SChristian Ehrhardt	/*
9223d9b7210SChristian Ehrhardt	 * This indicates that the UDP checksum was calculated for the
9233d9b7210SChristian Ehrhardt	 * tunnel packet and that the t_l4_cs_error field indicates if
9243d9b7210SChristian Ehrhardt	 * there was an error.
925809f0800SChristian Ehrhardt	 */
9263d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_T_L4_CS_CALC	UINT32_C(0x8)
927809f0800SChristian Ehrhardt	/* This value indicates what format the metadata field is. */
928809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
929809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_META_FORMAT_SFT	4
9303d9b7210SChristian Ehrhardt	/* No metadata informtaion. Value is zero. */
931809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_META_FORMAT_NONE	(UINT32_C(0x0) << 4)
9323d9b7210SChristian Ehrhardt	/*
9333d9b7210SChristian Ehrhardt	 * The metadata field contains the VLAN tag and
9343d9b7210SChristian Ehrhardt	 * TPID value. - metadata[11:0] contains the
9353d9b7210SChristian Ehrhardt	 * vlan VID value. - metadata[12] contains the
9363d9b7210SChristian Ehrhardt	 * vlan DE value. - metadata[15:13] contains the
9373d9b7210SChristian Ehrhardt	 * vlan PRI value. - metadata[31:16] contains
9383d9b7210SChristian Ehrhardt	 * the vlan TPID value.
9393d9b7210SChristian Ehrhardt	 */
940809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN	(UINT32_C(0x1) << 4)
9413d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_META_FORMAT_LAST	\
9423d9b7210SChristian Ehrhardt		RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN
943809f0800SChristian Ehrhardt	/*
9443d9b7210SChristian Ehrhardt	 * This field indicates the IP type for the inner-most IP
9453d9b7210SChristian Ehrhardt	 * header. A value of '0' indicates IPv4. A value of '1'
9463d9b7210SChristian Ehrhardt	 * indicates IPv6. This value is only valid if itype indicates a
9473d9b7210SChristian Ehrhardt	 * packet with an IP header.
948809f0800SChristian Ehrhardt	 */
9493d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_FLAGS2_IP_TYPE	UINT32_C(0x100)
9503d9b7210SChristian Ehrhardt	uint32_t metadata;
951809f0800SChristian Ehrhardt	/*
9523d9b7210SChristian Ehrhardt	 * This is data from the CFA block as indicated by the
9533d9b7210SChristian Ehrhardt	 * meta_format field.
954809f0800SChristian Ehrhardt	 */
955809f0800SChristian Ehrhardt	/* When meta_format=1, this value is the VLAN VID. */
9563d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_VID_MASK	UINT32_C(0xfff)
9573d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_VID_SFT	0
958809f0800SChristian Ehrhardt	/* When meta_format=1, this value is the VLAN DE. */
9593d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_DE	UINT32_C(0x1000)
960809f0800SChristian Ehrhardt	/* When meta_format=1, this value is the VLAN PRI. */
9613d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_PRI_MASK	UINT32_C(0xe000)
9623d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_PRI_SFT	13
963809f0800SChristian Ehrhardt	/* When meta_format=1, this value is the VLAN TPID. */
9643d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_TPID_MASK	UINT32_C(0xffff0000)
9653d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_METADATA_TPID_SFT	16
9663d9b7210SChristian Ehrhardt	uint16_t errors_v2;
967809f0800SChristian Ehrhardt	/*
9683d9b7210SChristian Ehrhardt	 * This value is written by the NIC such that it will be
9693d9b7210SChristian Ehrhardt	 * different for each pass through the completion queue. The
9703d9b7210SChristian Ehrhardt	 * even passes will write 1. The odd passes will write 0.
971809f0800SChristian Ehrhardt	 */
9723d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_V2	UINT32_C(0x1)
973809f0800SChristian Ehrhardt	/*
9743d9b7210SChristian Ehrhardt	 * This error indicates that there was some sort of problem with
9753d9b7210SChristian Ehrhardt	 * the BDs for the packet that was found after part of the
9763d9b7210SChristian Ehrhardt	 * packet was already placed. The packet should be treated as
9773d9b7210SChristian Ehrhardt	 * invalid.
978809f0800SChristian Ehrhardt	 */
979809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
980809f0800SChristian Ehrhardt	#define RX_PKT_CMPL_ERRORS_BUFFER_ERROR_SFT	1
9813d9b7210SChristian Ehrhardt	/* No buffer error */
9823d9b7210SChristian Ehrhardt	#define RX_PKT_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
9833d9b7210SChristian Ehrhardt	/*
9843d9b7210SChristian Ehrhardt	 * Did Not Fit: Packet did not fit into packet
9853d9b7210SChristian Ehrhardt	 * buffer provided. For regular placement, this
9863d9b7210SChristian Ehrhardt	 * means the packet did not fit in the buffer
9873d9b7210SChristian Ehrhardt	 * provided. For HDS and jumbo placement, this
9883d9b7210SChristian Ehrhardt	 * means that the packet could not be placed
989