ixgbe_dcb.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 1999 - 2018 Intel Corporation. */
  3. #ifndef _DCB_CONFIG_H_
  4. #define _DCB_CONFIG_H_
  5. #include <linux/dcbnl.h>
  6. #include "ixgbe_type.h"
  7. /* DCB data structures */
  8. #define IXGBE_MAX_PACKET_BUFFERS 8
  9. #define MAX_USER_PRIORITY 8
  10. #define MAX_BW_GROUP 8
  11. #define BW_PERCENT 100
  12. #define DCB_TX_CONFIG 0
  13. #define DCB_RX_CONFIG 1
  14. /* DCB error Codes */
  15. #define DCB_SUCCESS 0
  16. #define DCB_ERR_CONFIG -1
  17. #define DCB_ERR_PARAM -2
  18. /* Transmit and receive Errors */
  19. /* Error in bandwidth group allocation */
  20. #define DCB_ERR_BW_GROUP -3
  21. /* Error in traffic class bandwidth allocation */
  22. #define DCB_ERR_TC_BW -4
  23. /* Traffic class has both link strict and group strict enabled */
  24. #define DCB_ERR_LS_GS -5
  25. /* Link strict traffic class has non zero bandwidth */
  26. #define DCB_ERR_LS_BW_NONZERO -6
  27. /* Link strict bandwidth group has non zero bandwidth */
  28. #define DCB_ERR_LS_BWG_NONZERO -7
  29. /* Traffic class has zero bandwidth */
  30. #define DCB_ERR_TC_BW_ZERO -8
  31. #define DCB_NOT_IMPLEMENTED 0x7FFFFFFF
  32. struct dcb_pfc_tc_debug {
  33. u8 tc;
  34. u8 pause_status;
  35. u64 pause_quanta;
  36. };
  37. enum strict_prio_type {
  38. prio_none = 0,
  39. prio_group,
  40. prio_link
  41. };
  42. /* DCB capability definitions */
  43. #define IXGBE_DCB_PG_SUPPORT 0x00000001
  44. #define IXGBE_DCB_PFC_SUPPORT 0x00000002
  45. #define IXGBE_DCB_BCN_SUPPORT 0x00000004
  46. #define IXGBE_DCB_UP2TC_SUPPORT 0x00000008
  47. #define IXGBE_DCB_GSP_SUPPORT 0x00000010
  48. #define IXGBE_DCB_8_TC_SUPPORT 0x80
  49. struct dcb_support {
  50. /* DCB capabilities */
  51. u32 capabilities;
  52. /* Each bit represents a number of TCs configurable in the hw.
  53. * If 8 traffic classes can be configured, the value is 0x80.
  54. */
  55. u8 traffic_classes;
  56. u8 pfc_traffic_classes;
  57. };
  58. /* Traffic class bandwidth allocation per direction */
  59. struct tc_bw_alloc {
  60. u8 bwg_id; /* Bandwidth Group (BWG) ID */
  61. u8 bwg_percent; /* % of BWG's bandwidth */
  62. u8 link_percent; /* % of link bandwidth */
  63. u8 up_to_tc_bitmap; /* User Priority to Traffic Class mapping */
  64. u16 data_credits_refill; /* Credit refill amount in 64B granularity */
  65. u16 data_credits_max; /* Max credits for a configured packet buffer
  66. * in 64B granularity.*/
  67. enum strict_prio_type prio_type; /* Link or Group Strict Priority */
  68. };
  69. enum dcb_pfc_type {
  70. pfc_disabled = 0,
  71. pfc_enabled_full,
  72. pfc_enabled_tx,
  73. pfc_enabled_rx
  74. };
  75. /* Traffic class configuration */
  76. struct tc_configuration {
  77. struct tc_bw_alloc path[2]; /* One each for Tx/Rx */
  78. enum dcb_pfc_type dcb_pfc; /* Class based flow control setting */
  79. u16 desc_credits_max; /* For Tx Descriptor arbitration */
  80. u8 tc; /* Traffic class (TC) */
  81. };
  82. struct dcb_num_tcs {
  83. u8 pg_tcs;
  84. u8 pfc_tcs;
  85. };
  86. struct ixgbe_dcb_config {
  87. struct dcb_support support;
  88. struct dcb_num_tcs num_tcs;
  89. struct tc_configuration tc_config[MAX_TRAFFIC_CLASS];
  90. u8 bw_percentage[2][MAX_BW_GROUP]; /* One each for Tx/Rx */
  91. bool pfc_mode_enable;
  92. u32 dcb_cfg_version; /* Not used...OS-specific? */
  93. u32 link_speed; /* For bandwidth allocation validation purpose */
  94. };
  95. /* DCB driver APIs */
  96. void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en);
  97. void ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *, int, u16 *);
  98. void ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *, u16 *);
  99. void ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *, int, u8 *);
  100. void ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *, int, u8 *);
  101. void ixgbe_dcb_unpack_map(struct ixgbe_dcb_config *, int, u8 *);
  102. u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *, int, u8);
  103. /* DCB credits calculation */
  104. s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *,
  105. struct ixgbe_dcb_config *, int, u8);
  106. /* DCB hw initialization */
  107. s32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max);
  108. s32 ixgbe_dcb_hw_ets_config(struct ixgbe_hw *hw, u16 *refill, u16 *max,
  109. u8 *bwg_id, u8 *prio_type, u8 *tc_prio);
  110. s32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en, u8 *tc_prio);
  111. s32 ixgbe_dcb_hw_config(struct ixgbe_hw *, struct ixgbe_dcb_config *);
  112. void ixgbe_dcb_read_rtrup2tc(struct ixgbe_hw *hw, u8 *map);
  113. /* DCB definitions for credit calculation */
  114. #define DCB_CREDIT_QUANTUM 64 /* DCB Quantum */
  115. #define MAX_CREDIT_REFILL 511 /* 0x1FF * 64B = 32704B */
  116. #define DCB_MAX_TSO_SIZE (32*1024) /* MAX TSO packet size supported in DCB mode */
  117. #define MINIMUM_CREDIT_FOR_TSO (DCB_MAX_TSO_SIZE/64 + 1) /* 513 for 32KB TSO packet */
  118. #define MAX_CREDIT 4095 /* Maximum credit supported: 256KB * 1204 / 64B */
  119. #endif /* _DCB_CONFIG_H */