xref: /freebsd/sys/dev/bnxt/bnxt_en/bnxt_dcb.h (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
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 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
44 	union { \
45 		struct { MEMBERS } ATTRS; \
46 		struct TAG { MEMBERS } ATTRS NAME; \
47 	}
48 #define struct_group_attr(NAME, ATTRS, MEMBERS...) \
49 	__struct_group(/* no tag */, NAME, ATTRS, MEMBERS)
50 
51 struct bnxt_cos2bw_cfg {
52 	uint8_t			pad[3];
53 	struct_group_attr(cfg, __packed,
54 		uint8_t			queue_id;
55 		uint32_t		min_bw;
56 		uint32_t		max_bw;
57 #define BW_VALUE_UNIT_PERCENT1_100		(0x1UL << 29)
58 		uint8_t			tsa;
59 		uint8_t			pri_lvl;
60 		uint8_t			bw_weight;
61 	);
62 	uint8_t			unused;
63 };
64 
65 struct bnxt_dscp2pri_entry {
66 	uint8_t	dscp;
67 	uint8_t	mask;
68 	uint8_t	pri;
69 };
70 
71 struct bnxt_ieee_ets {
72 	uint8_t    willing;
73 	uint8_t    ets_cap;
74 	uint8_t    cbs;
75 	uint8_t    tc_tx_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
76 	uint8_t    tc_rx_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
77 	uint8_t    tc_tsa[BNXT_IEEE_8021QAZ_MAX_TCS];
78 	uint8_t    prio_tc[BNXT_IEEE_8021QAZ_MAX_TCS];
79 	uint8_t    tc_reco_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
80 	uint8_t    tc_reco_tsa[BNXT_IEEE_8021QAZ_MAX_TCS];
81 	uint8_t    reco_prio_tc[BNXT_IEEE_8021QAZ_MAX_TCS];
82 } __attribute__ ((__packed__));
83 
84 struct bnxt_ieee_pfc {
85 	uint8_t    pfc_cap;
86 	uint8_t    pfc_en;
87 	uint8_t    mbc;
88 	uint16_t   delay;
89 	uint64_t   requests[BNXT_IEEE_8021QAZ_MAX_TCS];
90 	uint64_t   indications[BNXT_IEEE_8021QAZ_MAX_TCS];
91 } __attribute__ ((__packed__));
92 
93 struct bnxt_dcb_app {
94 	uint8_t    selector;
95 	uint8_t    priority;
96 	uint16_t   protocol;
97 } __attribute__ ((__packed__));
98 
99 struct bnxt_eee {
100 	uint32_t   cmd;
101 	uint32_t   supported;
102 	uint32_t   advertised;
103 	uint32_t   lp_advertised;
104 	uint32_t   eee_active;
105 	uint32_t   eee_enabled;
106 	uint32_t   tx_lpi_enabled;
107 	uint32_t   tx_lpi_timer;
108 	uint32_t   reserved[2];
109 } __attribute__ ((__packed__));
110 
111 #define BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE	1
112 #define BNXT_IEEE_8021QAZ_APP_SEL_STREAM	2
113 #define BNXT_IEEE_8021QAZ_APP_SEL_DGRAM		3
114 #define BNXT_IEEE_8021QAZ_APP_SEL_ANY		4
115 #define BNXT_IEEE_8021QAZ_APP_SEL_DSCP       	5
116 #define ETH_P_ROCE 				0x8915
117 #define ROCE_V2_UDP_DPORT 			4791
118 
119 #define BNXT_LLQ(q_profile)	\
120 	((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE ||	\
121 	 (q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_NIC)
122 #define BNXT_CNPQ(q_profile)	\
123 	((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP)
124 
125 #define HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL	0x0300
126 
127 #endif
128