18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2019, Intel Corporation. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _ICE_DCB_H_
58c2ecf20Sopenharmony_ci#define _ICE_DCB_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include "ice_type.h"
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define ICE_DCBX_STATUS_NOT_STARTED	0
108c2ecf20Sopenharmony_ci#define ICE_DCBX_STATUS_IN_PROGRESS	1
118c2ecf20Sopenharmony_ci#define ICE_DCBX_STATUS_DONE		2
128c2ecf20Sopenharmony_ci#define ICE_DCBX_STATUS_DIS		7
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define ICE_TLV_TYPE_END		0
158c2ecf20Sopenharmony_ci#define ICE_TLV_TYPE_ORG		127
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define ICE_IEEE_8021QAZ_OUI		0x0080C2
188c2ecf20Sopenharmony_ci#define ICE_IEEE_SUBTYPE_ETS_CFG	9
198c2ecf20Sopenharmony_ci#define ICE_IEEE_SUBTYPE_ETS_REC	10
208c2ecf20Sopenharmony_ci#define ICE_IEEE_SUBTYPE_PFC_CFG	11
218c2ecf20Sopenharmony_ci#define ICE_IEEE_SUBTYPE_APP_PRI	12
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define ICE_CEE_DCBX_OUI		0x001B21
248c2ecf20Sopenharmony_ci#define ICE_CEE_DCBX_TYPE		2
258c2ecf20Sopenharmony_ci#define ICE_CEE_SUBTYPE_PG_CFG		2
268c2ecf20Sopenharmony_ci#define ICE_CEE_SUBTYPE_PFC_CFG		3
278c2ecf20Sopenharmony_ci#define ICE_CEE_SUBTYPE_APP_PRI		4
288c2ecf20Sopenharmony_ci#define ICE_CEE_MAX_FEAT_TYPE		3
298c2ecf20Sopenharmony_ci/* Defines for LLDP TLV header */
308c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_LEN_S		0
318c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_LEN_M		(0x01FF << ICE_LLDP_TLV_LEN_S)
328c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_TYPE_S		9
338c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_TYPE_M		(0x7F << ICE_LLDP_TLV_TYPE_S)
348c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_SUBTYPE_S		0
358c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_SUBTYPE_M		(0xFF << ICE_LLDP_TLV_SUBTYPE_S)
368c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_OUI_S		8
378c2ecf20Sopenharmony_ci#define ICE_LLDP_TLV_OUI_M		(0xFFFFFFUL << ICE_LLDP_TLV_OUI_S)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* Defines for IEEE ETS TLV */
408c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_MAXTC_S	0
418c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_MAXTC_M		(0x7 << ICE_IEEE_ETS_MAXTC_S)
428c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_CBS_S		6
438c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_CBS_M		BIT(ICE_IEEE_ETS_CBS_S)
448c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_WILLING_S		7
458c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_WILLING_M		BIT(ICE_IEEE_ETS_WILLING_S)
468c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_0_S		0
478c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_0_M		(0x7 << ICE_IEEE_ETS_PRIO_0_S)
488c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_1_S		4
498c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_PRIO_1_M		(0x7 << ICE_IEEE_ETS_PRIO_1_S)
508c2ecf20Sopenharmony_ci#define ICE_CEE_PGID_PRIO_0_S		0
518c2ecf20Sopenharmony_ci#define ICE_CEE_PGID_PRIO_0_M		(0xF << ICE_CEE_PGID_PRIO_0_S)
528c2ecf20Sopenharmony_ci#define ICE_CEE_PGID_PRIO_1_S		4
538c2ecf20Sopenharmony_ci#define ICE_CEE_PGID_PRIO_1_M		(0xF << ICE_CEE_PGID_PRIO_1_S)
548c2ecf20Sopenharmony_ci#define ICE_CEE_PGID_STRICT		15
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Defines for IEEE TSA types */
578c2ecf20Sopenharmony_ci#define ICE_IEEE_TSA_STRICT		0
588c2ecf20Sopenharmony_ci#define ICE_IEEE_TSA_ETS		2
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* Defines for IEEE PFC TLV */
618c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_CAP_S		0
628c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_CAP_M		(0xF << ICE_IEEE_PFC_CAP_S)
638c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_MBC_S		6
648c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_MBC_M		BIT(ICE_IEEE_PFC_MBC_S)
658c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_WILLING_S		7
668c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_WILLING_M		BIT(ICE_IEEE_PFC_WILLING_S)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* Defines for IEEE APP TLV */
698c2ecf20Sopenharmony_ci#define ICE_IEEE_APP_SEL_S		0
708c2ecf20Sopenharmony_ci#define ICE_IEEE_APP_SEL_M		(0x7 << ICE_IEEE_APP_SEL_S)
718c2ecf20Sopenharmony_ci#define ICE_IEEE_APP_PRIO_S		5
728c2ecf20Sopenharmony_ci#define ICE_IEEE_APP_PRIO_M		(0x7 << ICE_IEEE_APP_PRIO_S)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/* TLV definitions for preparing MIB */
758c2ecf20Sopenharmony_ci#define ICE_IEEE_TLV_ID_ETS_CFG		3
768c2ecf20Sopenharmony_ci#define ICE_IEEE_TLV_ID_ETS_REC		4
778c2ecf20Sopenharmony_ci#define ICE_IEEE_TLV_ID_PFC_CFG		5
788c2ecf20Sopenharmony_ci#define ICE_IEEE_TLV_ID_APP_PRI		6
798c2ecf20Sopenharmony_ci#define ICE_TLV_ID_END_OF_LLDPPDU	7
808c2ecf20Sopenharmony_ci#define ICE_TLV_ID_START		ICE_IEEE_TLV_ID_ETS_CFG
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#define ICE_IEEE_ETS_TLV_LEN		25
838c2ecf20Sopenharmony_ci#define ICE_IEEE_PFC_TLV_LEN		6
848c2ecf20Sopenharmony_ci#define ICE_IEEE_APP_TLV_LEN		11
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/* IEEE 802.1AB LLDP Organization specific TLV */
878c2ecf20Sopenharmony_cistruct ice_lldp_org_tlv {
888c2ecf20Sopenharmony_ci	__be16 typelen;
898c2ecf20Sopenharmony_ci	__be32 ouisubtype;
908c2ecf20Sopenharmony_ci	u8 tlvinfo[];
918c2ecf20Sopenharmony_ci} __packed;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistruct ice_cee_tlv_hdr {
948c2ecf20Sopenharmony_ci	__be16 typelen;
958c2ecf20Sopenharmony_ci	u8 operver;
968c2ecf20Sopenharmony_ci	u8 maxver;
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct ice_cee_ctrl_tlv {
1008c2ecf20Sopenharmony_ci	struct ice_cee_tlv_hdr hdr;
1018c2ecf20Sopenharmony_ci	__be32 seqno;
1028c2ecf20Sopenharmony_ci	__be32 ackno;
1038c2ecf20Sopenharmony_ci};
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cistruct ice_cee_feat_tlv {
1068c2ecf20Sopenharmony_ci	struct ice_cee_tlv_hdr hdr;
1078c2ecf20Sopenharmony_ci	u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */
1088c2ecf20Sopenharmony_ci#define ICE_CEE_FEAT_TLV_ENA_M		0x80
1098c2ecf20Sopenharmony_ci#define ICE_CEE_FEAT_TLV_WILLING_M	0x40
1108c2ecf20Sopenharmony_ci#define ICE_CEE_FEAT_TLV_ERR_M		0x20
1118c2ecf20Sopenharmony_ci	u8 subtype;
1128c2ecf20Sopenharmony_ci	u8 tlvinfo[];
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistruct ice_cee_app_prio {
1168c2ecf20Sopenharmony_ci	__be16 protocol;
1178c2ecf20Sopenharmony_ci	u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */
1188c2ecf20Sopenharmony_ci#define ICE_CEE_APP_SELECTOR_M	0x03
1198c2ecf20Sopenharmony_ci	__be16 lower_oui;
1208c2ecf20Sopenharmony_ci	u8 prio_map;
1218c2ecf20Sopenharmony_ci} __packed;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_cienum ice_status
1248c2ecf20Sopenharmony_ciice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
1258c2ecf20Sopenharmony_ci		   struct ice_dcbx_cfg *dcbcfg);
1268c2ecf20Sopenharmony_cienum ice_status ice_get_dcb_cfg(struct ice_port_info *pi);
1278c2ecf20Sopenharmony_cienum ice_status ice_set_dcb_cfg(struct ice_port_info *pi);
1288c2ecf20Sopenharmony_cienum ice_status ice_init_dcb(struct ice_hw *hw, bool enable_mib_change);
1298c2ecf20Sopenharmony_cienum ice_status
1308c2ecf20Sopenharmony_ciice_query_port_ets(struct ice_port_info *pi,
1318c2ecf20Sopenharmony_ci		   struct ice_aqc_port_ets_elem *buf, u16 buf_size,
1328c2ecf20Sopenharmony_ci		   struct ice_sq_cd *cmd_details);
1338c2ecf20Sopenharmony_ci#ifdef CONFIG_DCB
1348c2ecf20Sopenharmony_cienum ice_status
1358c2ecf20Sopenharmony_ciice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
1368c2ecf20Sopenharmony_ci		 struct ice_sq_cd *cd);
1378c2ecf20Sopenharmony_cienum ice_status
1388c2ecf20Sopenharmony_ciice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd);
1398c2ecf20Sopenharmony_cienum ice_status
1408c2ecf20Sopenharmony_ciice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
1418c2ecf20Sopenharmony_ci		       bool *dcbx_agent_status, struct ice_sq_cd *cd);
1428c2ecf20Sopenharmony_cienum ice_status ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib);
1438c2ecf20Sopenharmony_ci#else /* CONFIG_DCB */
1448c2ecf20Sopenharmony_cistatic inline enum ice_status
1458c2ecf20Sopenharmony_ciice_aq_stop_lldp(struct ice_hw __always_unused *hw,
1468c2ecf20Sopenharmony_ci		 bool __always_unused shutdown_lldp_agent,
1478c2ecf20Sopenharmony_ci		 bool __always_unused persist,
1488c2ecf20Sopenharmony_ci		 struct ice_sq_cd __always_unused *cd)
1498c2ecf20Sopenharmony_ci{
1508c2ecf20Sopenharmony_ci	return 0;
1518c2ecf20Sopenharmony_ci}
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistatic inline enum ice_status
1548c2ecf20Sopenharmony_ciice_aq_start_lldp(struct ice_hw __always_unused *hw,
1558c2ecf20Sopenharmony_ci		  bool __always_unused persist,
1568c2ecf20Sopenharmony_ci		  struct ice_sq_cd __always_unused *cd)
1578c2ecf20Sopenharmony_ci{
1588c2ecf20Sopenharmony_ci	return 0;
1598c2ecf20Sopenharmony_ci}
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic inline enum ice_status
1628c2ecf20Sopenharmony_ciice_aq_start_stop_dcbx(struct ice_hw __always_unused *hw,
1638c2ecf20Sopenharmony_ci		       bool __always_unused start_dcbx_agent,
1648c2ecf20Sopenharmony_ci		       bool *dcbx_agent_status,
1658c2ecf20Sopenharmony_ci		       struct ice_sq_cd __always_unused *cd)
1668c2ecf20Sopenharmony_ci{
1678c2ecf20Sopenharmony_ci	*dcbx_agent_status = false;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	return 0;
1708c2ecf20Sopenharmony_ci}
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_cistatic inline enum ice_status
1738c2ecf20Sopenharmony_ciice_cfg_lldp_mib_change(struct ice_hw __always_unused *hw,
1748c2ecf20Sopenharmony_ci			bool __always_unused ena_mib)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	return 0;
1778c2ecf20Sopenharmony_ci}
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci#endif /* CONFIG_DCB */
1808c2ecf20Sopenharmony_ci#endif /* _ICE_DCB_H_ */
181