ixgbe_dcb.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*******************************************************************************
  2. Intel 10 Gigabit PCI Express Linux driver
  3. Copyright(c) 1999 - 2011 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. #ifndef _DCB_CONFIG_H_
  22. #define _DCB_CONFIG_H_
  23. #include "ixgbe_type.h"
  24. /* DCB data structures */
  25. #define IXGBE_MAX_PACKET_BUFFERS 8
  26. #define MAX_USER_PRIORITY 8
  27. #define MAX_TRAFFIC_CLASS 8
  28. #define MAX_BW_GROUP 8
  29. #define BW_PERCENT 100
  30. #define DCB_TX_CONFIG 0
  31. #define DCB_RX_CONFIG 1
  32. /* DCB error Codes */
  33. #define DCB_SUCCESS 0
  34. #define DCB_ERR_CONFIG -1
  35. #define DCB_ERR_PARAM -2
  36. /* Transmit and receive Errors */
  37. /* Error in bandwidth group allocation */
  38. #define DCB_ERR_BW_GROUP -3
  39. /* Error in traffic class bandwidth allocation */
  40. #define DCB_ERR_TC_BW -4
  41. /* Traffic class has both link strict and group strict enabled */
  42. #define DCB_ERR_LS_GS -5
  43. /* Link strict traffic class has non zero bandwidth */
  44. #define DCB_ERR_LS_BW_NONZERO -6
  45. /* Link strict bandwidth group has non zero bandwidth */
  46. #define DCB_ERR_LS_BWG_NONZERO -7
  47. /* Traffic class has zero bandwidth */
  48. #define DCB_ERR_TC_BW_ZERO -8
  49. #define DCB_NOT_IMPLEMENTED 0x7FFFFFFF
  50. struct dcb_pfc_tc_debug {
  51. u8 tc;
  52. u8 pause_status;
  53. u64 pause_quanta;
  54. };
  55. enum strict_prio_type {
  56. prio_none = 0,
  57. prio_group,
  58. prio_link
  59. };
  60. /* DCB capability definitions */
  61. #define IXGBE_DCB_PG_SUPPORT 0x00000001
  62. #define IXGBE_DCB_PFC_SUPPORT 0x00000002
  63. #define IXGBE_DCB_BCN_SUPPORT 0x00000004
  64. #define IXGBE_DCB_UP2TC_SUPPORT 0x00000008
  65. #define IXGBE_DCB_GSP_SUPPORT 0x00000010
  66. #define IXGBE_DCB_8_TC_SUPPORT 0x80
  67. struct dcb_support {
  68. /* DCB capabilities */
  69. u32 capabilities;
  70. /* Each bit represents a number of TCs configurable in the hw.
  71. * If 8 traffic classes can be configured, the value is 0x80.
  72. */
  73. u8 traffic_classes;
  74. u8 pfc_traffic_classes;
  75. };
  76. /* Traffic class bandwidth allocation per direction */
  77. struct tc_bw_alloc {
  78. u8 bwg_id; /* Bandwidth Group (BWG) ID */
  79. u8 bwg_percent; /* % of BWG's bandwidth */
  80. u8 link_percent; /* % of link bandwidth */
  81. u8 up_to_tc_bitmap; /* User Priority to Traffic Class mapping */
  82. u16 data_credits_refill; /* Credit refill amount in 64B granularity */
  83. u16 data_credits_max; /* Max credits for a configured packet buffer
  84. * in 64B granularity.*/
  85. enum strict_prio_type prio_type; /* Link or Group Strict Priority */
  86. };
  87. enum dcb_pfc_type {
  88. pfc_disabled = 0,
  89. pfc_enabled_full,
  90. pfc_enabled_tx,
  91. pfc_enabled_rx
  92. };
  93. /* Traffic class configuration */
  94. struct tc_configuration {
  95. struct tc_bw_alloc path[2]; /* One each for Tx/Rx */
  96. enum dcb_pfc_type dcb_pfc; /* Class based flow control setting */
  97. u16 desc_credits_max; /* For Tx Descriptor arbitration */
  98. u8 tc; /* Traffic class (TC) */
  99. };
  100. enum dcb_rx_pba_cfg {
  101. pba_equal, /* PBA[0-7] each use 64KB FIFO */
  102. pba_80_48 /* PBA[0-3] each use 80KB, PBA[4-7] each use 48KB */
  103. };
  104. struct dcb_num_tcs {
  105. u8 pg_tcs;
  106. u8 pfc_tcs;
  107. };
  108. struct ixgbe_dcb_config {
  109. struct dcb_support support;
  110. struct dcb_num_tcs num_tcs;
  111. struct tc_configuration tc_config[MAX_TRAFFIC_CLASS];
  112. u8 bw_percentage[2][MAX_BW_GROUP]; /* One each for Tx/Rx */
  113. bool pfc_mode_enable;
  114. enum dcb_rx_pba_cfg rx_pba_cfg;
  115. u32 dcb_cfg_version; /* Not used...OS-specific? */
  116. u32 link_speed; /* For bandwidth allocation validation purpose */
  117. };
  118. /* DCB driver APIs */
  119. void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en);
  120. void ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *, int, u16 *);
  121. void ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *, u16 *);
  122. void ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *, int, u8 *);
  123. void ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *, int, u8 *);
  124. /* DCB credits calculation */
  125. s32 ixgbe_ieee_credits(__u8 *bw, __u16 *refill, __u16 *max, int max_frame);
  126. s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *,
  127. struct ixgbe_dcb_config *, int, u8);
  128. /* DCB hw initialization */
  129. s32 ixgbe_dcb_hw_ets_config(struct ixgbe_hw *hw, u16 *refill, u16 *max,
  130. u8 *bwg_id, u8 *prio_type, u8 *tc_prio);
  131. s32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en);
  132. s32 ixgbe_dcb_hw_config(struct ixgbe_hw *, struct ixgbe_dcb_config *);
  133. /* DCB definitions for credit calculation */
  134. #define DCB_CREDIT_QUANTUM 64 /* DCB Quantum */
  135. #define MAX_CREDIT_REFILL 511 /* 0x1FF * 64B = 32704B */
  136. #define DCB_MAX_TSO_SIZE (32*1024) /* MAX TSO packet size supported in DCB mode */
  137. #define MINIMUM_CREDIT_FOR_TSO (DCB_MAX_TSO_SIZE/64 + 1) /* 513 for 32KB TSO packet */
  138. #define MAX_CREDIT 4095 /* Maximum credit supported: 256KB * 1204 / 64B */
  139. #endif /* _DCB_CONFIG_H */