1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020
8 #include "txgbe_type.h"
11 /* DCB credit calculation defines */
12 #define TXGBE_DCB_CREDIT_QUANTUM 64
13 #define TXGBE_DCB_MAX_CREDIT_REFILL 200 /* 200 * 64B = 12800B */
14 #define TXGBE_DCB_MAX_TSO_SIZE (32 * 1024) /* Max TSO pkt size in DCB*/
15 #define TXGBE_DCB_MAX_CREDIT (2 * TXGBE_DCB_MAX_CREDIT_REFILL)
17 /* 513 for 32KB TSO packet */
18 #define TXGBE_DCB_MIN_TSO_CREDIT \
19 ((TXGBE_DCB_MAX_TSO_SIZE / TXGBE_DCB_CREDIT_QUANTUM) + 1)
21 #define TXGBE_DCB_TX_CONFIG 0
22 #define TXGBE_DCB_RX_CONFIG 1
24 struct txgbe_dcb_support {
25 u32 capabilities; /* DCB capabilities */
27 /* Each bit represents a number of TCs configurable in the hw.
28 * If 8 traffic classes can be configured, the value is 0x80.
31 u8 pfc_traffic_classes;
35 txgbe_dcb_tsa_ets = 0,
36 txgbe_dcb_tsa_group_strict_cee,
40 /* Traffic class bandwidth allocation per direction */
41 struct txgbe_dcb_tc_path {
42 u8 bwg_id; /* Bandwidth Group (BWG) ID */
43 u8 bwg_percent; /* % of BWG's bandwidth */
44 u8 link_percent; /* % of link bandwidth */
45 u8 up_to_tc_bitmap; /* User Priority to Traffic Class mapping */
46 u16 data_credits_refill; /* Credit refill amount in 64B granularity */
47 u16 data_credits_max; /* Max credits for a configured packet buffer
50 enum txgbe_dcb_tsa tsa; /* Link or Group Strict Priority */
54 txgbe_dcb_pfc_disabled = 0,
55 txgbe_dcb_pfc_enabled,
56 txgbe_dcb_pfc_enabled_txonly,
57 txgbe_dcb_pfc_enabled_rxonly
60 /* Traffic class configuration */
61 struct txgbe_dcb_tc_config {
62 struct txgbe_dcb_tc_path path[2]; /* One each for Tx/Rx */
63 enum txgbe_dcb_pfc pfc; /* Class based flow control setting */
65 u16 desc_credits_max; /* For Tx Descriptor arbitration */
66 u8 tc; /* Traffic class (TC) */
70 /* PBA[0-7] each use 64KB FIFO */
71 txgbe_dcb_pba_equal = PBA_STRATEGY_EQUAL,
72 /* PBA[0-3] each use 80KB, PBA[4-7] each use 48KB */
73 txgbe_dcb_pba_80_48 = PBA_STRATEGY_WEIGHTED
76 struct txgbe_dcb_num_tcs {
81 struct txgbe_dcb_config {
82 struct txgbe_dcb_tc_config tc_config[TXGBE_DCB_TC_MAX];
83 struct txgbe_dcb_support support;
84 struct txgbe_dcb_num_tcs num_tcs;
85 u8 bw_percentage[TXGBE_DCB_BWG_MAX][2]; /* One each for Tx/Rx */
87 bool round_robin_enable;
89 enum txgbe_dcb_pba rx_pba_cfg;
91 u32 link_speed; /* For bandwidth allocation validation purpose */
95 int txgbe_dcb_pfc_enable(struct txgbe_hw *hw, u8 tc_num);
97 /* DCB credits calculation */
98 s32 txgbe_dcb_calculate_tc_credits_cee(struct txgbe_hw *hw,
99 struct txgbe_dcb_config *dcb_config,
100 u32 max_frame_size, u8 direction);
103 s32 txgbe_dcb_config_pfc(struct txgbe_hw *hw, u8 pfc_en, u8 *map);
105 /* DCB unpack routines */
106 void txgbe_dcb_unpack_pfc_cee(struct txgbe_dcb_config *cfg,
107 u8 *map, u8 *pfc_up);
108 void txgbe_dcb_unpack_refill_cee(struct txgbe_dcb_config *cfg, int direction,
110 void txgbe_dcb_unpack_max_cee(struct txgbe_dcb_config *cfg, u16 *max);
111 void txgbe_dcb_unpack_bwgid_cee(struct txgbe_dcb_config *cfg, int direction,
113 void txgbe_dcb_unpack_tsa_cee(struct txgbe_dcb_config *cfg, int direction,
115 void txgbe_dcb_unpack_map_cee(struct txgbe_dcb_config *cfg, int direction,
117 u8 txgbe_dcb_get_tc_from_up(struct txgbe_dcb_config *cfg, int direction, u8 up);
119 #include "txgbe_dcb_hw.h"
121 #endif /* _TXGBE_DCB_H_ */