bnx2x_dcb.h 5.2 KB

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