xref: /freebsd/sys/dev/bnxt/bnxt_en/bnxt_dcb.h (revision 152e6197615570e7a2f5f1c6c2ed00ecee9dd10c)
1 /*-
2  * Broadcom NetXtreme-C/E network driver.
3  *
4  * Copyright (c) 2024 Broadcom, All Rights Reserved.
5  * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _BNXT_DCB_H
30 #define _BNXT_DCB_H
31 
32 #define BNXT_IEEE_8021QAZ_MAX_TCS		8
33 #define BNXT_IEEE_8021QAZ_TSA_STRICT		0
34 #define BNXT_IEEE_8021QAZ_TSA_ETS		2
35 #define BNXT_IEEE_8021QAZ_TSA_VENDOR		255
36 
37 #define BNXT_DCB_CAP_DCBX_HOST			0x01
38 #define BNXT_DCB_CAP_DCBX_LLD_MANAGED		0x02
39 #define BNXT_DCB_CAP_DCBX_VER_CEE		0x04
40 #define BNXT_DCB_CAP_DCBX_VER_IEEE		0x08
41 #define BNXT_DCB_CAP_DCBX_STATIC		0x10
42 
43 #ifndef	__struct_group
44 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
45 	union { \
46 		struct { MEMBERS } ATTRS; \
47 		struct TAG { MEMBERS } ATTRS NAME; \
48 	}
49 #endif
50 #ifndef	struct_group_attr
51 #define struct_group_attr(NAME, ATTRS, MEMBERS...) \
52 	__struct_group(/* no tag */, NAME, ATTRS, MEMBERS)
53 #endif
54 
55 struct bnxt_cos2bw_cfg {
56 	uint8_t			pad[3];
57 	struct_group_attr(cfg, __packed,
58 		uint8_t			queue_id;
59 		uint32_t		min_bw;
60 		uint32_t		max_bw;
61 #define BW_VALUE_UNIT_PERCENT1_100		(0x1UL << 29)
62 		uint8_t			tsa;
63 		uint8_t			pri_lvl;
64 		uint8_t			bw_weight;
65 	);
66 	uint8_t			unused;
67 };
68 
69 struct bnxt_dscp2pri_entry {
70 	uint8_t	dscp;
71 	uint8_t	mask;
72 	uint8_t	pri;
73 };
74 
75 struct bnxt_ieee_ets {
76 	uint8_t    willing;
77 	uint8_t    ets_cap;
78 	uint8_t    cbs;
79 	uint8_t    tc_tx_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
80 	uint8_t    tc_rx_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
81 	uint8_t    tc_tsa[BNXT_IEEE_8021QAZ_MAX_TCS];
82 	uint8_t    prio_tc[BNXT_IEEE_8021QAZ_MAX_TCS];
83 	uint8_t    tc_reco_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
84 	uint8_t    tc_reco_tsa[BNXT_IEEE_8021QAZ_MAX_TCS];
85 	uint8_t    reco_prio_tc[BNXT_IEEE_8021QAZ_MAX_TCS];
86 } __attribute__ ((__packed__));
87 
88 struct bnxt_ieee_pfc {
89 	uint8_t    pfc_cap;
90 	uint8_t    pfc_en;
91 	uint8_t    mbc;
92 	uint16_t   delay;
93 	uint64_t   requests[BNXT_IEEE_8021QAZ_MAX_TCS];
94 	uint64_t   indications[BNXT_IEEE_8021QAZ_MAX_TCS];
95 } __attribute__ ((__packed__));
96 
97 struct bnxt_dcb_app {
98 	uint8_t    selector;
99 	uint8_t    priority;
100 	uint16_t   protocol;
101 } __attribute__ ((__packed__));
102 
103 struct bnxt_eee {
104 	uint32_t   cmd;
105 	uint32_t   supported;
106 	uint32_t   advertised;
107 	uint32_t   lp_advertised;
108 	uint32_t   eee_active;
109 	uint32_t   eee_enabled;
110 	uint32_t   tx_lpi_enabled;
111 	uint32_t   tx_lpi_timer;
112 	uint32_t   reserved[2];
113 } __attribute__ ((__packed__));
114 
115 #define BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE	1
116 #define BNXT_IEEE_8021QAZ_APP_SEL_STREAM	2
117 #define BNXT_IEEE_8021QAZ_APP_SEL_DGRAM		3
118 #define BNXT_IEEE_8021QAZ_APP_SEL_ANY		4
119 #define BNXT_IEEE_8021QAZ_APP_SEL_DSCP       	5
120 #define ETH_P_ROCE 				0x8915
121 #define ROCE_V2_UDP_DPORT 			4791
122 
123 #define BNXT_LLQ(q_profile)	\
124 	((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE ||	\
125 	 (q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_NIC)
126 #define BNXT_CNPQ(q_profile)	\
127 	((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP)
128 
129 #define HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL	0x0300
130 
131 #endif
132