1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2019, Intel Corporation. */
3
4#ifndef _ICE_DCB_H_
5#define _ICE_DCB_H_
6
7#include "ice_type.h"
8#include <scsi/iscsi_proto.h>
9
10#define ICE_DCBX_STATUS_NOT_STARTED 0
11#define ICE_DCBX_STATUS_IN_PROGRESS 1
12#define ICE_DCBX_STATUS_DONE 2
13#define ICE_DCBX_STATUS_DIS 7
14
15#define ICE_TLV_TYPE_END 0
16#define ICE_TLV_TYPE_ORG 127
17
18#define ICE_IEEE_8021QAZ_OUI 0x0080C2
19#define ICE_IEEE_SUBTYPE_ETS_CFG 9
20#define ICE_IEEE_SUBTYPE_ETS_REC 10
21#define ICE_IEEE_SUBTYPE_PFC_CFG 11
22#define ICE_IEEE_SUBTYPE_APP_PRI 12
23
24#define ICE_CEE_DCBX_OUI 0x001B21
25#define ICE_CEE_DCBX_TYPE 2
26
27#define ICE_DSCP_OUI 0xFFFFFF
28#define ICE_DSCP_SUBTYPE_DSCP2UP 0x41
29#define ICE_DSCP_SUBTYPE_ENFORCE 0x42
30#define ICE_DSCP_SUBTYPE_TCBW 0x43
31#define ICE_DSCP_SUBTYPE_PFC 0x44
32#define ICE_DSCP_IPV6_OFFSET 80
33
34#define ICE_CEE_SUBTYPE_PG_CFG 2
35#define ICE_CEE_SUBTYPE_PFC_CFG 3
36#define ICE_CEE_SUBTYPE_APP_PRI 4
37#define ICE_CEE_MAX_FEAT_TYPE 3
38/* Defines for LLDP TLV header */
39#define ICE_LLDP_TLV_LEN_S 0
40#define ICE_LLDP_TLV_LEN_M (0x01FF << ICE_LLDP_TLV_LEN_S)
41#define ICE_LLDP_TLV_TYPE_S 9
42#define ICE_LLDP_TLV_TYPE_M (0x7F << ICE_LLDP_TLV_TYPE_S)
43#define ICE_LLDP_TLV_SUBTYPE_S 0
44#define ICE_LLDP_TLV_SUBTYPE_M (0xFF << ICE_LLDP_TLV_SUBTYPE_S)
45#define ICE_LLDP_TLV_OUI_S 8
46#define ICE_LLDP_TLV_OUI_M (0xFFFFFFUL << ICE_LLDP_TLV_OUI_S)
47
48/* Defines for IEEE ETS TLV */
49#define ICE_IEEE_ETS_MAXTC_S 0
50#define ICE_IEEE_ETS_MAXTC_M (0x7 << ICE_IEEE_ETS_MAXTC_S)
51#define ICE_IEEE_ETS_CBS_S 6
52#define ICE_IEEE_ETS_CBS_M BIT(ICE_IEEE_ETS_CBS_S)
53#define ICE_IEEE_ETS_WILLING_S 7
54#define ICE_IEEE_ETS_WILLING_M BIT(ICE_IEEE_ETS_WILLING_S)
55#define ICE_IEEE_ETS_PRIO_0_S 0
56#define ICE_IEEE_ETS_PRIO_0_M (0x7 << ICE_IEEE_ETS_PRIO_0_S)
57#define ICE_IEEE_ETS_PRIO_1_S 4
58#define ICE_IEEE_ETS_PRIO_1_M (0x7 << ICE_IEEE_ETS_PRIO_1_S)
59#define ICE_CEE_PGID_PRIO_0_S 0
60#define ICE_CEE_PGID_PRIO_0_M (0xF << ICE_CEE_PGID_PRIO_0_S)
61#define ICE_CEE_PGID_PRIO_1_S 4
62#define ICE_CEE_PGID_PRIO_1_M (0xF << ICE_CEE_PGID_PRIO_1_S)
63#define ICE_CEE_PGID_STRICT 15
64
65/* Defines for IEEE TSA types */
66#define ICE_IEEE_TSA_STRICT 0
67#define ICE_IEEE_TSA_ETS 2
68
69/* Defines for IEEE PFC TLV */
70#define ICE_IEEE_PFC_CAP_S 0
71#define ICE_IEEE_PFC_CAP_M (0xF << ICE_IEEE_PFC_CAP_S)
72#define ICE_IEEE_PFC_MBC_S 6
73#define ICE_IEEE_PFC_MBC_M BIT(ICE_IEEE_PFC_MBC_S)
74#define ICE_IEEE_PFC_WILLING_S 7
75#define ICE_IEEE_PFC_WILLING_M BIT(ICE_IEEE_PFC_WILLING_S)
76
77/* Defines for IEEE APP TLV */
78#define ICE_IEEE_APP_SEL_S 0
79#define ICE_IEEE_APP_SEL_M (0x7 << ICE_IEEE_APP_SEL_S)
80#define ICE_IEEE_APP_PRIO_S 5
81#define ICE_IEEE_APP_PRIO_M (0x7 << ICE_IEEE_APP_PRIO_S)
82
83/* TLV definitions for preparing MIB */
84#define ICE_IEEE_TLV_ID_ETS_CFG 3
85#define ICE_IEEE_TLV_ID_ETS_REC 4
86#define ICE_IEEE_TLV_ID_PFC_CFG 5
87#define ICE_IEEE_TLV_ID_APP_PRI 6
88#define ICE_TLV_ID_END_OF_LLDPPDU 7
89#define ICE_TLV_ID_START ICE_IEEE_TLV_ID_ETS_CFG
90#define ICE_TLV_ID_DSCP_UP 3
91#define ICE_TLV_ID_DSCP_ENF 4
92#define ICE_TLV_ID_DSCP_TC_BW 5
93#define ICE_TLV_ID_DSCP_TO_PFC 6
94
95#define ICE_IEEE_ETS_TLV_LEN 25
96#define ICE_IEEE_PFC_TLV_LEN 6
97#define ICE_IEEE_APP_TLV_LEN 11
98
99#define ICE_DSCP_UP_TLV_LEN 148
100#define ICE_DSCP_ENF_TLV_LEN 132
101#define ICE_DSCP_TC_BW_TLV_LEN 25
102#define ICE_DSCP_PFC_TLV_LEN 6
103
104/* IEEE 802.1AB LLDP Organization specific TLV */
105struct ice_lldp_org_tlv {
106 __be16 typelen;
107 __be32 ouisubtype;
108 u8 tlvinfo[];
109} __packed;
110
111struct ice_cee_tlv_hdr {
112 __be16 typelen;
113 u8 operver;
114 u8 maxver;
115};
116
117struct ice_cee_ctrl_tlv {
118 struct ice_cee_tlv_hdr hdr;
119 __be32 seqno;
120 __be32 ackno;
121};
122
123struct ice_cee_feat_tlv {
124 struct ice_cee_tlv_hdr hdr;
125 u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */
126#define ICE_CEE_FEAT_TLV_ENA_M 0x80
127#define ICE_CEE_FEAT_TLV_WILLING_M 0x40
128#define ICE_CEE_FEAT_TLV_ERR_M 0x20
129 u8 subtype;
130 u8 tlvinfo[];
131};
132
133struct ice_cee_app_prio {
134 __be16 protocol;
135 u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */
136#define ICE_CEE_APP_SELECTOR_M 0x03
137 __be16 lower_oui;
138 u8 prio_map;
139} __packed;
140
141int ice_aq_set_pfc_mode(struct ice_hw *hw, u8 pfc_mode, struct ice_sq_cd *cd);
142int
143ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
144 struct ice_dcbx_cfg *dcbcfg);
145int ice_get_dcb_cfg(struct ice_port_info *pi);
146int ice_set_dcb_cfg(struct ice_port_info *pi);
147void ice_get_dcb_cfg_from_mib_change(struct ice_port_info *pi,
148 struct ice_rq_event_info *event);
149int ice_init_dcb(struct ice_hw *hw, bool enable_mib_change);
150int
151ice_query_port_ets(struct ice_port_info *pi,
152 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
153 struct ice_sq_cd *cmd_details);
154#ifdef CONFIG_DCB
155int
156ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
157 struct ice_sq_cd *cd);
158int ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd);
159int
160ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
161 bool *dcbx_agent_status, struct ice_sq_cd *cd);
162int ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib);
163#else /* CONFIG_DCB */
164static inline int
165ice_aq_stop_lldp(struct ice_hw __always_unused *hw,
166 bool __always_unused shutdown_lldp_agent,
167 bool __always_unused persist,
168 struct ice_sq_cd __always_unused *cd)
169{
170 return 0;
171}
172
173static inline int
174ice_aq_start_lldp(struct ice_hw __always_unused *hw,
175 bool __always_unused persist,
176 struct ice_sq_cd __always_unused *cd)
177{
178 return 0;
179}
180
181static inline int
182ice_aq_start_stop_dcbx(struct ice_hw __always_unused *hw,
183 bool __always_unused start_dcbx_agent,
184 bool *dcbx_agent_status,
185 struct ice_sq_cd __always_unused *cd)
186{
187 *dcbx_agent_status = false;
188
189 return 0;
190}
191
192static inline int
193ice_cfg_lldp_mib_change(struct ice_hw __always_unused *hw,
194 bool __always_unused ena_mib)
195{
196 return 0;
197}
198
199#endif /* CONFIG_DCB */
200#endif /* _ICE_DCB_H_ */
201

source code of linux/drivers/net/ethernet/intel/ice/ice_dcb.h