162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright (c) 2019, Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _ICE_DCB_H_
562306a36Sopenharmony_ci#define _ICE_DCB_H_
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include "ice_type.h"
862306a36Sopenharmony_ci#include <scsi/iscsi_proto.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define ICE_DCBX_STATUS_NOT_STARTED	0
1162306a36Sopenharmony_ci#define ICE_DCBX_STATUS_IN_PROGRESS	1
1262306a36Sopenharmony_ci#define ICE_DCBX_STATUS_DONE		2
1362306a36Sopenharmony_ci#define ICE_DCBX_STATUS_DIS		7
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define ICE_TLV_TYPE_END		0
1662306a36Sopenharmony_ci#define ICE_TLV_TYPE_ORG		127
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define ICE_IEEE_8021QAZ_OUI		0x0080C2
1962306a36Sopenharmony_ci#define ICE_IEEE_SUBTYPE_ETS_CFG	9
2062306a36Sopenharmony_ci#define ICE_IEEE_SUBTYPE_ETS_REC	10
2162306a36Sopenharmony_ci#define ICE_IEEE_SUBTYPE_PFC_CFG	11
2262306a36Sopenharmony_ci#define ICE_IEEE_SUBTYPE_APP_PRI	12
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define ICE_CEE_DCBX_OUI		0x001B21
2562306a36Sopenharmony_ci#define ICE_CEE_DCBX_TYPE		2
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define ICE_DSCP_OUI			0xFFFFFF
2862306a36Sopenharmony_ci#define ICE_DSCP_SUBTYPE_DSCP2UP	0x41
2962306a36Sopenharmony_ci#define ICE_DSCP_SUBTYPE_ENFORCE	0x42
3062306a36Sopenharmony_ci#define ICE_DSCP_SUBTYPE_TCBW		0x43
3162306a36Sopenharmony_ci#define ICE_DSCP_SUBTYPE_PFC		0x44
3262306a36Sopenharmony_ci#define ICE_DSCP_IPV6_OFFSET		80
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#define ICE_CEE_SUBTYPE_PG_CFG		2
3562306a36Sopenharmony_ci#define ICE_CEE_SUBTYPE_PFC_CFG		3
3662306a36Sopenharmony_ci#define ICE_CEE_SUBTYPE_APP_PRI		4
3762306a36Sopenharmony_ci#define ICE_CEE_MAX_FEAT_TYPE		3
3862306a36Sopenharmony_ci/* Defines for LLDP TLV header */
3962306a36Sopenharmony_ci#define ICE_LLDP_TLV_LEN_S		0
4062306a36Sopenharmony_ci#define ICE_LLDP_TLV_LEN_M		(0x01FF << ICE_LLDP_TLV_LEN_S)
4162306a36Sopenharmony_ci#define ICE_LLDP_TLV_TYPE_S		9
4262306a36Sopenharmony_ci#define ICE_LLDP_TLV_TYPE_M		(0x7F << ICE_LLDP_TLV_TYPE_S)
4362306a36Sopenharmony_ci#define ICE_LLDP_TLV_SUBTYPE_S		0
4462306a36Sopenharmony_ci#define ICE_LLDP_TLV_SUBTYPE_M		(0xFF << ICE_LLDP_TLV_SUBTYPE_S)
4562306a36Sopenharmony_ci#define ICE_LLDP_TLV_OUI_S		8
4662306a36Sopenharmony_ci#define ICE_LLDP_TLV_OUI_M		(0xFFFFFFUL << ICE_LLDP_TLV_OUI_S)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* Defines for IEEE ETS TLV */
4962306a36Sopenharmony_ci#define ICE_IEEE_ETS_MAXTC_S	0
5062306a36Sopenharmony_ci#define ICE_IEEE_ETS_MAXTC_M		(0x7 << ICE_IEEE_ETS_MAXTC_S)
5162306a36Sopenharmony_ci#define ICE_IEEE_ETS_CBS_S		6
5262306a36Sopenharmony_ci#define ICE_IEEE_ETS_CBS_M		BIT(ICE_IEEE_ETS_CBS_S)
5362306a36Sopenharmony_ci#define ICE_IEEE_ETS_WILLING_S		7
5462306a36Sopenharmony_ci#define ICE_IEEE_ETS_WILLING_M		BIT(ICE_IEEE_ETS_WILLING_S)
5562306a36Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_0_S		0
5662306a36Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_0_M		(0x7 << ICE_IEEE_ETS_PRIO_0_S)
5762306a36Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_1_S		4
5862306a36Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_1_M		(0x7 << ICE_IEEE_ETS_PRIO_1_S)
5962306a36Sopenharmony_ci#define ICE_CEE_PGID_PRIO_0_S		0
6062306a36Sopenharmony_ci#define ICE_CEE_PGID_PRIO_0_M		(0xF << ICE_CEE_PGID_PRIO_0_S)
6162306a36Sopenharmony_ci#define ICE_CEE_PGID_PRIO_1_S		4
6262306a36Sopenharmony_ci#define ICE_CEE_PGID_PRIO_1_M		(0xF << ICE_CEE_PGID_PRIO_1_S)
6362306a36Sopenharmony_ci#define ICE_CEE_PGID_STRICT		15
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/* Defines for IEEE TSA types */
6662306a36Sopenharmony_ci#define ICE_IEEE_TSA_STRICT		0
6762306a36Sopenharmony_ci#define ICE_IEEE_TSA_ETS		2
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci/* Defines for IEEE PFC TLV */
7062306a36Sopenharmony_ci#define ICE_IEEE_PFC_CAP_S		0
7162306a36Sopenharmony_ci#define ICE_IEEE_PFC_CAP_M		(0xF << ICE_IEEE_PFC_CAP_S)
7262306a36Sopenharmony_ci#define ICE_IEEE_PFC_MBC_S		6
7362306a36Sopenharmony_ci#define ICE_IEEE_PFC_MBC_M		BIT(ICE_IEEE_PFC_MBC_S)
7462306a36Sopenharmony_ci#define ICE_IEEE_PFC_WILLING_S		7
7562306a36Sopenharmony_ci#define ICE_IEEE_PFC_WILLING_M		BIT(ICE_IEEE_PFC_WILLING_S)
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* Defines for IEEE APP TLV */
7862306a36Sopenharmony_ci#define ICE_IEEE_APP_SEL_S		0
7962306a36Sopenharmony_ci#define ICE_IEEE_APP_SEL_M		(0x7 << ICE_IEEE_APP_SEL_S)
8062306a36Sopenharmony_ci#define ICE_IEEE_APP_PRIO_S		5
8162306a36Sopenharmony_ci#define ICE_IEEE_APP_PRIO_M		(0x7 << ICE_IEEE_APP_PRIO_S)
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* TLV definitions for preparing MIB */
8462306a36Sopenharmony_ci#define ICE_IEEE_TLV_ID_ETS_CFG		3
8562306a36Sopenharmony_ci#define ICE_IEEE_TLV_ID_ETS_REC		4
8662306a36Sopenharmony_ci#define ICE_IEEE_TLV_ID_PFC_CFG		5
8762306a36Sopenharmony_ci#define ICE_IEEE_TLV_ID_APP_PRI		6
8862306a36Sopenharmony_ci#define ICE_TLV_ID_END_OF_LLDPPDU	7
8962306a36Sopenharmony_ci#define ICE_TLV_ID_START		ICE_IEEE_TLV_ID_ETS_CFG
9062306a36Sopenharmony_ci#define ICE_TLV_ID_DSCP_UP		3
9162306a36Sopenharmony_ci#define ICE_TLV_ID_DSCP_ENF		4
9262306a36Sopenharmony_ci#define ICE_TLV_ID_DSCP_TC_BW		5
9362306a36Sopenharmony_ci#define ICE_TLV_ID_DSCP_TO_PFC		6
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define ICE_IEEE_ETS_TLV_LEN		25
9662306a36Sopenharmony_ci#define ICE_IEEE_PFC_TLV_LEN		6
9762306a36Sopenharmony_ci#define ICE_IEEE_APP_TLV_LEN		11
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define ICE_DSCP_UP_TLV_LEN		148
10062306a36Sopenharmony_ci#define ICE_DSCP_ENF_TLV_LEN		132
10162306a36Sopenharmony_ci#define ICE_DSCP_TC_BW_TLV_LEN		25
10262306a36Sopenharmony_ci#define ICE_DSCP_PFC_TLV_LEN		6
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/* IEEE 802.1AB LLDP Organization specific TLV */
10562306a36Sopenharmony_cistruct ice_lldp_org_tlv {
10662306a36Sopenharmony_ci	__be16 typelen;
10762306a36Sopenharmony_ci	__be32 ouisubtype;
10862306a36Sopenharmony_ci	u8 tlvinfo[];
10962306a36Sopenharmony_ci} __packed;
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_cistruct ice_cee_tlv_hdr {
11262306a36Sopenharmony_ci	__be16 typelen;
11362306a36Sopenharmony_ci	u8 operver;
11462306a36Sopenharmony_ci	u8 maxver;
11562306a36Sopenharmony_ci};
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_cistruct ice_cee_ctrl_tlv {
11862306a36Sopenharmony_ci	struct ice_cee_tlv_hdr hdr;
11962306a36Sopenharmony_ci	__be32 seqno;
12062306a36Sopenharmony_ci	__be32 ackno;
12162306a36Sopenharmony_ci};
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_cistruct ice_cee_feat_tlv {
12462306a36Sopenharmony_ci	struct ice_cee_tlv_hdr hdr;
12562306a36Sopenharmony_ci	u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */
12662306a36Sopenharmony_ci#define ICE_CEE_FEAT_TLV_ENA_M		0x80
12762306a36Sopenharmony_ci#define ICE_CEE_FEAT_TLV_WILLING_M	0x40
12862306a36Sopenharmony_ci#define ICE_CEE_FEAT_TLV_ERR_M		0x20
12962306a36Sopenharmony_ci	u8 subtype;
13062306a36Sopenharmony_ci	u8 tlvinfo[];
13162306a36Sopenharmony_ci};
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_cistruct ice_cee_app_prio {
13462306a36Sopenharmony_ci	__be16 protocol;
13562306a36Sopenharmony_ci	u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */
13662306a36Sopenharmony_ci#define ICE_CEE_APP_SELECTOR_M	0x03
13762306a36Sopenharmony_ci	__be16 lower_oui;
13862306a36Sopenharmony_ci	u8 prio_map;
13962306a36Sopenharmony_ci} __packed;
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ciint ice_aq_set_pfc_mode(struct ice_hw *hw, u8 pfc_mode, struct ice_sq_cd *cd);
14262306a36Sopenharmony_ciint
14362306a36Sopenharmony_ciice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
14462306a36Sopenharmony_ci		   struct ice_dcbx_cfg *dcbcfg);
14562306a36Sopenharmony_ciint ice_get_dcb_cfg(struct ice_port_info *pi);
14662306a36Sopenharmony_ciint ice_set_dcb_cfg(struct ice_port_info *pi);
14762306a36Sopenharmony_civoid ice_get_dcb_cfg_from_mib_change(struct ice_port_info *pi,
14862306a36Sopenharmony_ci				     struct ice_rq_event_info *event);
14962306a36Sopenharmony_ciint ice_init_dcb(struct ice_hw *hw, bool enable_mib_change);
15062306a36Sopenharmony_ciint
15162306a36Sopenharmony_ciice_query_port_ets(struct ice_port_info *pi,
15262306a36Sopenharmony_ci		   struct ice_aqc_port_ets_elem *buf, u16 buf_size,
15362306a36Sopenharmony_ci		   struct ice_sq_cd *cmd_details);
15462306a36Sopenharmony_ci#ifdef CONFIG_DCB
15562306a36Sopenharmony_ciint
15662306a36Sopenharmony_ciice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
15762306a36Sopenharmony_ci		 struct ice_sq_cd *cd);
15862306a36Sopenharmony_ciint ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd);
15962306a36Sopenharmony_ciint
16062306a36Sopenharmony_ciice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
16162306a36Sopenharmony_ci		       bool *dcbx_agent_status, struct ice_sq_cd *cd);
16262306a36Sopenharmony_ciint ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib);
16362306a36Sopenharmony_ci#else /* CONFIG_DCB */
16462306a36Sopenharmony_cistatic inline int
16562306a36Sopenharmony_ciice_aq_stop_lldp(struct ice_hw __always_unused *hw,
16662306a36Sopenharmony_ci		 bool __always_unused shutdown_lldp_agent,
16762306a36Sopenharmony_ci		 bool __always_unused persist,
16862306a36Sopenharmony_ci		 struct ice_sq_cd __always_unused *cd)
16962306a36Sopenharmony_ci{
17062306a36Sopenharmony_ci	return 0;
17162306a36Sopenharmony_ci}
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_cistatic inline int
17462306a36Sopenharmony_ciice_aq_start_lldp(struct ice_hw __always_unused *hw,
17562306a36Sopenharmony_ci		  bool __always_unused persist,
17662306a36Sopenharmony_ci		  struct ice_sq_cd __always_unused *cd)
17762306a36Sopenharmony_ci{
17862306a36Sopenharmony_ci	return 0;
17962306a36Sopenharmony_ci}
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_cistatic inline int
18262306a36Sopenharmony_ciice_aq_start_stop_dcbx(struct ice_hw __always_unused *hw,
18362306a36Sopenharmony_ci		       bool __always_unused start_dcbx_agent,
18462306a36Sopenharmony_ci		       bool *dcbx_agent_status,
18562306a36Sopenharmony_ci		       struct ice_sq_cd __always_unused *cd)
18662306a36Sopenharmony_ci{
18762306a36Sopenharmony_ci	*dcbx_agent_status = false;
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci	return 0;
19062306a36Sopenharmony_ci}
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_cistatic inline int
19362306a36Sopenharmony_ciice_cfg_lldp_mib_change(struct ice_hw __always_unused *hw,
19462306a36Sopenharmony_ci			bool __always_unused ena_mib)
19562306a36Sopenharmony_ci{
19662306a36Sopenharmony_ci	return 0;
19762306a36Sopenharmony_ci}
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci#endif /* CONFIG_DCB */
20062306a36Sopenharmony_ci#endif /* _ICE_DCB_H_ */
201