bnx2x_dcb.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* bnx2x_dcb.h: QLogic Everest network driver.
  2. *
  3. * Copyright 2009-2013 Broadcom Corporation
  4. * Copyright 2014 QLogic Corporation
  5. * All rights reserved
  6. *
  7. * Unless you and QLogic execute a separate written software license
  8. * agreement governing use of this software, this software is licensed to you
  9. * under the terms of the GNU General Public License version 2, available
  10. * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
  11. *
  12. * Notwithstanding the above, under no circumstances may you combine this
  13. * software in any way with any other QLogic software provided under a
  14. * license other than the GPL, without QLogic's express prior written
  15. * consent.
  16. *
  17. * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
  18. * Written by: Dmitry Kravkov
  19. *
  20. */
  21. #ifndef BNX2X_DCB_H
  22. #define BNX2X_DCB_H
  23. #include "bnx2x_hsi.h"
  24. #define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */
  25. struct bnx2x_dcbx_app_params {
  26. u32 enabled;
  27. u32 traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
  28. };
  29. #define DCBX_COS_MAX_NUM_E2 DCBX_E2E3_MAX_NUM_COS
  30. /* bnx2x currently limits numbers of supported COSes to 3 to be extended to 6 */
  31. #define BNX2X_MAX_COS_SUPPORT 3
  32. #define DCBX_COS_MAX_NUM_E3B0 BNX2X_MAX_COS_SUPPORT
  33. #define DCBX_COS_MAX_NUM BNX2X_MAX_COS_SUPPORT
  34. struct bnx2x_dcbx_cos_params {
  35. u32 bw_tbl;
  36. u32 pri_bitmask;
  37. /*
  38. * strict priority: valid values are 0..5; 0 is highest priority.
  39. * There can't be two COSes with the same priority.
  40. */
  41. u8 strict;
  42. #define BNX2X_DCBX_STRICT_INVALID DCBX_COS_MAX_NUM
  43. #define BNX2X_DCBX_STRICT_COS_HIGHEST 0
  44. #define BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(sp) ((sp) + 1)
  45. u8 pauseable;
  46. };
  47. struct bnx2x_dcbx_pg_params {
  48. u32 enabled;
  49. u8 num_of_cos; /* valid COS entries */
  50. struct bnx2x_dcbx_cos_params cos_params[DCBX_COS_MAX_NUM];
  51. };
  52. struct bnx2x_dcbx_pfc_params {
  53. u32 enabled;
  54. u32 priority_non_pauseable_mask;
  55. };
  56. struct bnx2x_dcbx_port_params {
  57. struct bnx2x_dcbx_pfc_params pfc;
  58. struct bnx2x_dcbx_pg_params ets;
  59. struct bnx2x_dcbx_app_params app;
  60. };
  61. #define BNX2X_DCBX_CONFIG_INV_VALUE (0xFFFFFFFF)
  62. #define BNX2X_DCBX_OVERWRITE_SETTINGS_DISABLE 0
  63. #define BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE 1
  64. #define BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID (BNX2X_DCBX_CONFIG_INV_VALUE)
  65. #define BNX2X_IS_ETS_ENABLED(bp) ((bp)->dcb_state == BNX2X_DCB_STATE_ON &&\
  66. (bp)->dcbx_port_params.ets.enabled)
  67. struct bnx2x_config_lldp_params {
  68. u32 overwrite_settings;
  69. u32 msg_tx_hold;
  70. u32 msg_fast_tx;
  71. u32 tx_credit_max;
  72. u32 msg_tx_interval;
  73. u32 tx_fast;
  74. };
  75. struct bnx2x_admin_priority_app_table {
  76. u32 valid;
  77. u32 priority;
  78. #define INVALID_TRAFFIC_TYPE_PRIORITY (0xFFFFFFFF)
  79. u32 traffic_type;
  80. #define TRAFFIC_TYPE_ETH 0
  81. #define TRAFFIC_TYPE_PORT 1
  82. u32 app_id;
  83. };
  84. #define DCBX_CONFIG_MAX_APP_PROTOCOL 4
  85. struct bnx2x_config_dcbx_params {
  86. u32 overwrite_settings;
  87. u32 admin_dcbx_version;
  88. u32 admin_ets_enable;
  89. u32 admin_pfc_enable;
  90. u32 admin_tc_supported_tx_enable;
  91. u32 admin_ets_configuration_tx_enable;
  92. u32 admin_ets_recommendation_tx_enable;
  93. u32 admin_pfc_tx_enable;
  94. u32 admin_application_priority_tx_enable;
  95. u32 admin_ets_willing;
  96. u32 admin_ets_reco_valid;
  97. u32 admin_pfc_willing;
  98. u32 admin_app_priority_willing;
  99. u32 admin_configuration_bw_precentage[8];
  100. u32 admin_configuration_ets_pg[8];
  101. u32 admin_recommendation_bw_precentage[8];
  102. u32 admin_recommendation_ets_pg[8];
  103. u32 admin_pfc_bitmap;
  104. struct bnx2x_admin_priority_app_table
  105. admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL];
  106. u32 admin_default_priority;
  107. };
  108. #define GET_FLAGS(flags, bits) ((flags) & (bits))
  109. #define SET_FLAGS(flags, bits) ((flags) |= (bits))
  110. #define RESET_FLAGS(flags, bits) ((flags) &= ~(bits))
  111. enum {
  112. DCBX_READ_LOCAL_MIB,
  113. DCBX_READ_REMOTE_MIB
  114. };
  115. #define ETH_TYPE_FCOE (0x8906)
  116. #define TCP_PORT_ISCSI (0xCBC)
  117. #define PFC_VALUE_FRAME_SIZE (512)
  118. #define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed) \
  119. ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed))
  120. #define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD 130
  121. #define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD 170
  122. struct cos_entry_help_data {
  123. u32 pri_join_mask;
  124. u32 cos_bw;
  125. u8 strict;
  126. bool pausable;
  127. };
  128. struct cos_help_data {
  129. struct cos_entry_help_data data[DCBX_COS_MAX_NUM];
  130. u8 num_of_cos;
  131. };
  132. #define DCBX_ILLEGAL_PG (0xFF)
  133. #define DCBX_PFC_PRI_MASK (0xFF)
  134. #define DCBX_STRICT_PRIORITY (15)
  135. #define DCBX_INVALID_COS_BW (0xFFFFFFFF)
  136. #define DCBX_PFC_PRI_NON_PAUSE_MASK(bp) \
  137. ((bp)->dcbx_port_params.pfc.priority_non_pauseable_mask)
  138. #define DCBX_PFC_PRI_PAUSE_MASK(bp) \
  139. ((u8)~DCBX_PFC_PRI_NON_PAUSE_MASK(bp))
  140. #define DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri) \
  141. ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(bp)))
  142. #define DCBX_PFC_PRI_GET_NON_PAUSE(bp, pg_pri) \
  143. (DCBX_PFC_PRI_NON_PAUSE_MASK(bp) & (pg_pri))
  144. #define DCBX_IS_PFC_PRI_SOME_PAUSE(bp, pg_pri) \
  145. (0 != DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri))
  146. #define IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pg_pri) \
  147. (pg_pri == DCBX_PFC_PRI_GET_PAUSE((bp), (pg_pri)))
  148. #define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(bp, pg_pri)\
  149. ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((bp), (pg_pri)))
  150. #define IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pg_pri) \
  151. (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((bp), (pg_pri)) || \
  152. IS_DCBX_PFC_PRI_ONLY_PAUSE((bp), (pg_pri))))
  153. struct pg_entry_help_data {
  154. u8 num_of_dif_pri;
  155. u8 pg;
  156. u32 pg_priority;
  157. };
  158. struct pg_help_data {
  159. struct pg_entry_help_data data[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
  160. u8 num_of_pg;
  161. };
  162. /* forward DCB/PFC related declarations */
  163. struct bnx2x;
  164. void bnx2x_dcbx_update(struct work_struct *work);
  165. void bnx2x_dcbx_init_params(struct bnx2x *bp);
  166. void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled);
  167. enum {
  168. BNX2X_DCBX_STATE_NEG_RECEIVED = 0x1,
  169. BNX2X_DCBX_STATE_TX_PAUSED,
  170. BNX2X_DCBX_STATE_TX_RELEASED
  171. };
  172. void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state);
  173. void bnx2x_dcbx_pmf_update(struct bnx2x *bp);
  174. /* DCB netlink */
  175. #ifdef BCM_DCBNL
  176. extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops;
  177. int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall);
  178. #endif /* BCM_DCBNL */
  179. int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
  180. int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);
  181. #endif /* BNX2X_DCB_H */