blob: 28c7e366495fe87e6ce3a7799c427fd6bc8bafb2 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/******************************************************************************
2 *
3 * <:copyright-BRCM:2016:DUAL/GPL:standard
4 *
5 * Copyright (c) 2016 Broadcom
6 * All Rights Reserved
7 *
8 * Unless you and Broadcom execute a separate written software license
9 * agreement governing use of this software, this software is licensed
10 * to you under the terms of the GNU General Public License version 2
11 * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
12 * with the following added to such license:
13 *
14 * As a special exception, the copyright holders of this software give
15 * you permission to link this software with independent modules, and
16 * to copy and distribute the resulting executable under terms of your
17 * choice, provided that you also meet, for each linked independent
18 * module, the terms and conditions of the license of that module.
19 * An independent module is a module which is not derived from this
20 * software. The special exception does not apply to any modifications
21 * of the software.
22 *
23 * Not withstanding the above, under no circumstances may you combine
24 * this software in any way with any other Broadcom software provided
25 * under a license other than the GPL, without Broadcom's express prior
26 * written consent.
27 *
28 * :>
29 *
30 *****************************************************************************/
31
32/**
33 * @file bal_dpp_qos.h
34 * @brief BAL Switch Util QoS configuration API
35 *
36 * This include file contains the data structures and API for
37 * configuring and managing Quality of Service (QoS) for services on
38 * DPP (DUNE Packet Processor).
39 *
40 *
41 */
42
43/*@{*/
44
45#ifndef _BAL_DPP_QOS_H_
46#define _BAL_DPP_QOS_H_
47
48/* --- project includes --- */
49
50#include "flow_fsm.h"
51
52/* --- local static constants ---*/
53
54/**
55 * @brief Value representing 10G in units of kbps
56 */
57#define BAL_BCM_QOS_10G_kbps 10000000
58
59/**
60 * @brief Value representing 2G (Turbo Mode) in units of kbps
61 */
62#define BAL_BCM_QOS_2G_kbps 2000000
63
64/**
65 * @brief Value representing 1G in units of kbps
66 */
67#define BAL_BCM_QOS_1G_kbps 1000000
68
69/**
70 * @brief Scheduler weight for 10G port scheduler
71 */
72#define BAL_BCM_SCHED_WEIGHT_10G 10
73
74/**
75 * @brief Scheduler weight for 1G port scheduler when Turbo Mode is enabled
76 */
77#define BAL_BCM_SCHED_WEIGHT_2G 2
78
79/**
80 * @brief Scheduler weight for 1G port scheduler (when Turbo Mode is disabled)
81 */
82#define BAL_BCM_SCHED_WEIGHT_1G 1
83
84/**
85 * @brief Scheduler weight used for MIN Rate schedulers
86 */
87#define BAL_BCM_SCHED_WEIGHT_MIN_RATE 1
88
89/**
90 * @brief Scheduler weight used for MAX Rate schedulers
91 */
92#define BAL_BCM_SCHED_WEIGHT_MAX_RATE 1
93
94/**
95 * @brief Number of PON port schedulers
96 */
97#define BAL_BCM_QOS_NUM_PON_PORTS 16
98
99/**
100 * @brief PON port Max value as defined in config.bcm
101 */
102#define BAL_BCM_MAX_PON_NUM 16
103
104/**
105 * @brief Number of queues per PON Link (LLID)
106 */
107#define BAL_BCM_QOS_QUEUES_PER_LLID 4
108
109/**
110 * @brief Default CoS level for untagged frames for 10G queues
111 */
112#define BAL_BCM_QOS_UNTAGGED_DEFAULT_COS_10G 0
113
114/**
115 * @brief Default CoS level for untagged frames for 1G queues
116 */
117#define BAL_BCM_QOS_UNTAGGED_DEFAULT_COS_1G 4
118
119/**
120 * @brief Size of ICT and Shared Vlan tag overhead (in bytes)
121 */
122#define BAL_BCM_QOS_SINGLE_VLAN_TAG_HDR_SIZE 4
123
124/**
125 * @brief Base value for VOQ IDs assigned to the 1G channel
126 *
127 * All VOQ IDs configured on the 1G channel are configured with an
128 * ID value of 0x4000 (16384) and larger.
129 */
130#define BAL_BCM_QOS_VOQ_ID_1G_BASE 0x4000
131
132/**
133 * @brief WFQ maximum value for a weight
134 */
135#define BAL_BCM_SCHED_WFQ_MAX_WEIGHT 4096
136
137/**
138 * @brief Number of WFQ scheduling priority levels
139 */
140#define BAL_BCM_SCHED_WFQ_PRI_NUM 8
141
142/**
143 * @brief Default rate for PON port shaper in kbps (12.5Gbps)
144 */
145#define BAL_BCM_QOS_DEFAULT_PORT_RATE 12500000
146
147/**
148 * @brief Default rate for 10G PON channel shaper in kbps (10.25Gbps)
149 *
150 * The extra 0.25 Gbps allows for some overhead (flow control frames, etc.)
151 */
152#define BAL_BCM_QOS_DEFAULT_10G_CHAN_RATE 10250000
153
154/**
155 * @brief Default rate for 1G PON channel shaper in kbps (2.25Gbps)
156 *
157 * This is set to 2G to allow for Turbo Mode configurations.
158 *
159 * The extra 0.25 Gbps allows for some overhead (flow control frames, etc.)
160 */
161#define BAL_BCM_QOS_DEFAULT_1G_CHAN_RATE 2250000
162
163/**
164 * @brief Credit adjustment to account for scheduler overhead (percentage)
165 *
166 * The adjustment is five percent based on the recommendation from the
167 * Dune team.
168 */
169#define BAL_BCM_QOS_CREDIT_RATE_ADJ 0.05
170
171/**
172 * @brief Shaper adjustment to account for scheduler overhead (percentage)
173 *
174 * The adjustment is one percent based on the recommendation from the
175 * Dune team.
176 */
177#define BAL_BCM_QOS_SHAPER_RATE_ADJ 0.01
178
179/**
180 * @brief Default maximum bust size for PON port shaper in bytes (0 = disabled)
181 */
182#define BAL_BCM_QOS_DEFAULT_MAX_BURST 0
183
184/**
185 * @brief PFC flow control priority value for the 10G channel
186 */
187#define BAL_BCM_QOS_10G_CHAN_PFC 0
188
189/**
190 * @brief PFC flow control priority value for the 1G channel
191 */
192#define BAL_BCM_QOS_1G_CHAN_PFC 1
193
194/**
195 * @brief First logical PON port number
196 */
197#define BAL_PON_PORT_START 0
198
199/**
200 * @brief Last logical PON port number
201 */
202#define BAL_PON_PORT_END 7
203
204/**
205 * @brief The total number of PON ports
206 */
207#define NUM_PON_PORTS (BAL_PON_PORT_END - BAL_PON_PORT_START + 1)
208
209/**
210 * @brief Default DPP header size used by scheduler and rate
211 * calculations.
212 */
213#define DEFAULT_QOS_DPP_PKT_HDR_SIZE 19 /* bytes */
214
215/**
216 * @brief Size of the Dune PP header used to report the Flow ID (for
217 * QoS) in packets trapped to the CPU.
218 */
219#define BAL_BCM_DPP_FLOWID_HDR_SIZE 5
220
221/**
222 * @brief Size of ICT and Shared Vlan tag overhead (in bytes)
223 */
224#define BAL_BCM_QOS_SINGLE_VLAN_TAG_HDR_SIZE 4
225
226
227/**
228 * @brief Default VOQ Identifier Base Value for 10G flows
229 *
230 * 10G VOQ/Flow IDs can range from 3000..16383. This means the blocks
231 * will be allocated in groups of four as follows.
232 *
233 * blk 1 = 3000, 3001, 3002, 3003
234 * blk 2 = 3004, 3005, 3006, 3007
235 * ...
236 * blk last = 16380, 16381, 16382, 16383
237 *
238 * This means that the last ID used to allocate a 10G VOQ group will
239 * be 16380.
240 *
241 * VOQ/flow IDs start at 3000 because the SDK assigns ID values
242 * between 0..2000+ to port queues.
243 */
244#define DEFAULT_QOS_VOQ_BASE_10G 3000
245
246/**
247 * @brief Default VOQ Identifier Maximum Value for 10G flows
248 *
249 * The last available value for 10G flows is 16384 - 4.
250 */
251#define DEFAULT_QOS_VOQ_MAX_10G 16380
252
253/**
254 * @brief Default VOQ Identifier Base Value for 1G flows
255 *
256 * 1G VOQ/Flow IDs can range from 16384..32767. This means the blocks
257 * will be allocated in groups of four as follows.
258 *
259 * blk 1 = 16384, 16385, 16386, 16387
260 * blk 2 = 16388, 16389, 16390, 16392
261 * ...
262 * blk last = 32764, 32765, 32766, 32767
263 *
264 * This means that the last ID used to allocate a 1G VOQ group will be
265 * 32764.
266 */
267#define DEFAULT_QOS_VOQ_BASE_1G 16384
268
269/**
270 * @brief Default VOQ Identifier Maximum Value for 1G flows
271 *
272 * The last available value for 1G flows is 32768 - 4.
273 */
274#define DEFAULT_QOS_VOQ_MAX_1G 32764
275
276/**
277 * @brief Get the PP port number for the specified PON port and
278 * channel (10G vs. 1G)
279 */
280#define BAL_BCM_GET_PP_PORT(pon, chan) ((pon) + (NUM_PON_PORTS * (chan)))
281
282/**
283 * @brief PON channel (a.k.a speed, 10G vs. 1G)
284 *
285 * The 1G PON channel value is also used to represent 2G Turbo Mode
286 * when enabled.
287 */
288typedef enum bal_sw_dpp_qos_sched_pon_chan
289{
290 BAL_BCM_SCHED_PON_CHAN_10G = 0, /**< 10G PON channel */
291 BAL_BCM_SCHED_PON_CHAN_1G = 1, /**< 1G PON channel */
292 BAL_BCM_SCHED_PON_CHAN_NUM
293} bal_sw_dpp_qos_sched_pon_chan;
294
295/**
296 * @brief SLA Type (MIN vs. MAX)
297 */
298typedef enum bal_sw_dpp_qos_sched_sla_type
299{
300 BAL_BCM_SCHED_SLA_MIN_RATE = 0, /**< MIN Rate */
301 BAL_BCM_SCHED_SLA_MAX_RATE = 1, /**< MAX Rate */
302 BAL_BCM_SCHED_SLA_TYPE_NUM
303} bal_sw_dpp_qos_sched_sla_type;
304
305/**
306 * @brief Scheduling Type
307 */
308typedef enum bal_sw_dpp_qos_sched_type
309{
310 BAL_BCM_SCHED_TYPE_SP = 0, /**< Strict priority scheduling */
311 BAL_BCM_SCHED_TYPE_WFQ = 1, /**< Weighted Fair Queuing */
312 BAL_BCM_SCHED_TYPE_NUM
313} bal_sw_dpp_qos_sched_type;
314
315/**
316 * @brief SLA scheduler configuration
317 */
318typedef struct bal_sw_dpp_qos_sched_sla
319{
320 bcm_gport_t scheduler_gport; /**< Scheduler object gport*/
321 bcm_gport_t parent_gport; /**< Parent scheduler gport */
322 uint32_t rate; /**< Rate (or bandwidth) in Kbps */
323 uint32_t burst; /**< Max burst in Kbits */
324 uint8_t traffic_priority; /**< Traffic priority */
325} bal_sw_dpp_qos_sched_sla;
326
327/**
328 * @brief QoS configuration for a PON Link (LLID)
329 */
330typedef struct bal_sw_dpp_llid_qos
331{
332 bal_sw_dpp_qos_sched_pon_chan pon_chan; /**< PON Channel (or speed) the link is connected to */
333 bal_sw_dpp_qos_sched_sla min; /**< MIN Rate configuration */
334 bal_sw_dpp_qos_sched_sla max; /**< MAX Rate configuration */
335 bcm_gport_t voq_connector_gport; /**< VOQ Connector gport */
336 bcm_gport_t voq_gport; /**< VOQ gport */
337 int voq_flow_id; /**< VOQ Flow ID */
338 int voq_id; /**< VOQ ID */
339} bal_sw_dpp_llid_qos;
340
341/**
342 * @brief QoS configuration for a channelized PON port
343 */
344typedef struct bal_sw_dpp_port_qos_cfg
345{
346 bcm_gport_t mod_gport; /**< MOD port for a channelized PON interface */
347 bal_sw_dpp_qos_sched_type sched_type; /**< Scheduling type used on the PON channel (SP vs. WFQ) */
348 bcm_gport_t pon_chan_scheduler; /**< PON channel scheduler */
349 bcm_gport_t sp_scheduler; /**< Strict Priority scheduler for MAX rates (EIRs) */
350 bcm_gport_t wfq_scheduler[BAL_BCM_SCHED_WFQ_PRI_NUM]; /**< WFQ+FQ schedulers for MAX rates (EIRs) */
351 int32_t pon_chan_weight_cfg[BAL_BCM_SCHED_WFQ_PRI_NUM]; /**< Weight configuration for WFQ scheduler */
352} bal_sw_dpp_port_qos_cfg;
353
354/**
355 * @brief Flow/VOQ ID Pool Entry
356 */
357typedef struct bal_sw_dpp_qos_flowid_pool_entry
358{
359 uint32_t flow_id; /**< Flow/VOQ ID value */
360 TAILQ_ENTRY(bal_sw_dpp_qos_flowid_pool_entry) entry; /**< Link into the pool table */
361} bal_sw_dpp_qos_flowid_pool_entry;
362
363/**
364 * @brief Flow/VOQ ID resource pool
365 */
366typedef struct bal_sw_dpp_qos_flowid_pool
367{
368 uint32_t next_flow_id_value; /**< Next flow ID to be allocated */
369 uint32_t max_value; /**< Maximum value for the flow IDs in this pool */
370 TAILQ_HEAD(bal_sw_dpp_qos_flowid_pool_free_head, bal_sw_dpp_qos_flowid_pool_entry) free_table; /**< Flow/VOQ ID free pool */
371} bal_sw_dpp_qos_flowid_pool;
372
373/**
374 * @brief DML BCM APP QoS configuration context definition
375 */
376typedef struct bal_sw_qos_cfg
377{
378 int32_t mod_id; /**< Module ID for this ARAD device */
379 int32_t qos_port_map_id; /**< QoS Port Map Identifier */
380 bal_sw_dpp_port_qos_cfg pon[BAL_BCM_QOS_NUM_PON_PORTS][BAL_BCM_SCHED_PON_CHAN_NUM]; /**< DS QoS configuration for channelized PON ports */
381 bal_sw_dpp_qos_flowid_pool flow_id_pool_10g; /**< Flow/VOQ ID resource pool for 10G flows */
382 bal_sw_dpp_qos_flowid_pool flow_id_pool_1g; /**< Flow/VOQ ID resource pool for 1G flows */
383 int num_channels_per_pon;
384} bal_sw_qos_cfg;
385
386/**
387 * @brief WFQ scheduling configuration
388 *
389 * This structure is used to configure weight values per scheduler
390 * level (i.e., DOCSIS Traffic Priority). The range of weight values
391 * is 0:4K, where values 1:4K are used for WFQ scheduling and a value
392 * of '0' is used for strict priority.
393 */
394typedef struct bal_sw_dpp_qos_wfq_cfg
395{
396 uint32_t weights[BAL_BCM_SCHED_WFQ_PRI_NUM];
397} bal_sw_dpp_qos_wfq_cfg;
398
399extern bal_sw_qos_cfg *gp_bal_bcm_qos_cfg;
400
401/**
402 * @brief Max Number of NNI ports
403 */
404#define BAL_BCM_QOS_NUM_NNI_PORTS 16
405
406/**
407 * @brief Service Configuration Entry Type
408 *
409 * The type of service configuration that the DmlBcmServiceCfgT entry
410 * represents.
411 */
412typedef enum bal_sw_service_type
413{
414 BAL_BCM_SVC_TYPE_NONE, /**< None/uninitialized */
415 BAL_BCM_SVC_TYPE_ICT, /**< Intra-chassis Tagged */
416 BAL_BCM_SVC_TYPE_IP, /**< IP(HSD) */
417 BAL_BCM_SVC_TYPE_PB, /**< MEF Provider Bridging (VLAN tagged) */
418 BAL_BCM_SVC_TYPE_SHVLAN,/**< Shared VLAN */
419 BAL_BCM_SVC_TYPE_LAST /**< Number of bal_sw_service_type_t values */
420} bal_sw_service_type;
421
422/* --- forward declarations --- */
423
424typedef struct bal_sw_dpp_qos_service_cfg
425{
426 uint32_t bal_flow_id;
427 bcm_port_t pon_port; /* logical port number from bal flow config */
428 uint32_t num_nni_gport;
429 bcm_gport_t nni_gport[BAL_BCM_QOS_NUM_NNI_PORTS];
430 uint32_t tunnel_id;
431 bal_sw_dpp_llid_qos ds_qos;
432 bal_sw_service_type service_type;
433} bal_sw_dpp_qos_service_cfg;
434
435
436/* --- function prototypes --- */
437
438bcmos_errno bal_sw_dpp_qos_init(int unit, bal_swapp_port_map_indx pon_mode);
439void bal_sw_dpp_qos_cleanup(int unit);
440bcmos_errno bal_sw_dpp_port_qos_init(int unit, bcm_port_t pon_port, bal_sw_dpp_qos_sched_pon_chan pon_chan);
441void bal_sw_dpp_port_qos_cleanup(int unit, bcm_port_t pon_port, bal_sw_dpp_qos_sched_pon_chan pon_chan);
442bcmos_errno bal_sw_dpp_qos_set_port_bandwidth(int unit, bcm_port_t pon_port, uint32_t bandwidth, uint32_t max_burst);
443bcmos_errno bal_sw_dpp_qos_set_portchan_bandwidth(int unit, bcm_port_t pon_port, bal_sw_dpp_qos_sched_pon_chan pon_chan,
444 uint32_t bandwidth, uint32_t max_burst);
445bcmos_errno bal_sw_dpp_qos_set_ponchan_wfq_cfg(int unit, bcm_port_t pon_port,
446 bal_sw_dpp_qos_sched_pon_chan pon_chan, bal_sw_dpp_qos_wfq_cfg *p_wfq_cfg);
447bcmos_errno bal_sw_dpp_qos_set_llid_bandwidth(int unit, bal_sw_dpp_qos_service_cfg *p_service_cfg,
448 bal_sw_dpp_qos_sched_sla_type sla_type, uint32_t bandwidth, uint32_t max_burst);
449bcmos_errno bal_sw_dpp_llid_qos_config(int unit, bal_sw_dpp_qos_service_cfg *p_service_cfg_entry);
450bcmos_errno bal_sw_dpp_llid_set_qos_port_map(int unit, bal_sw_dpp_qos_service_cfg *p_service_cfg_entry);
451void bal_sw_dpp_llid_qos_cleanup(int unit, bal_sw_dpp_qos_service_cfg *p_service_cfg_entry);
452void bal_sw_dpp_qos_clear_voq_stats(int unit, bcm_gport_t gport);
453void bal_sw_dpp_print_all_port_qos(int unit);
454void bal_sw_dpp_qos_print_flowid_pool(int unit);
455
456#endif /* #ifndef _BAL_DPP_QOS_H_ */
457
458/*@}*/