ice_dcb.h 5.7 KB

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