blob: 4d19176b03630700293a4a1425fbaa52beb24948 [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#ifndef _RSC_MGR_COMMON_H_
33#define _RSC_MGR_COMMON_H_
34
35#include <bcmolt_host_api.h>
36#include <bcm_dev_log.h>
37#include <bal_objs.h>
38#include <bcmolt_math.h>
39
40#define RSC_MGR_MIN_RANGE_SIZE 1
41#define RSC_MGR_MAX_RANGE_SIZE 8
42
43#define RSC_MGR_PON_TOPO_CONTEXT(pon_id) ((rsc_mgr_topo_pon_context *)bcm_topo_pon_get_context(pon_id, BCM_TOPO_PON_CONTEXT_ID_RSC_MGR))
44
45typedef enum rsc_mgr_obj_type
46{
47 RSC_MGR_OBJ_TYPE_INVALID = 0,
48 RSC_MGR_OBJ_TYPE_GEM_PORT_UNICAST,
49 RSC_MGR_OBJ_TYPE_GEM_PORT_MULTICAST,
50 RSC_MGR_OBJ_TYPE_GEM_PORT_BROADCAST,
51 RSC_MGR_OBJ_TYPE_ALLOC_ID,
52 RSC_MGR_OBJ_TYPE_TM_SCHED,
53} rsc_mgr_obj_type;
54
55#define RSC_MGR_OBJ_TYPE_STR(_type) \
56 ((_type) == RSC_MGR_OBJ_TYPE_GEM_PORT_UNICAST ? "gem_port_unicast":\
57 (_type) == RSC_MGR_OBJ_TYPE_GEM_PORT_MULTICAST ? "gem_port_multicast":\
58 (_type) == RSC_MGR_OBJ_TYPE_GEM_PORT_BROADCAST ? "gem_port_broadcast":\
59 (_type) == RSC_MGR_OBJ_TYPE_ALLOC_ID ? "alloc_id":\
60 (_type) == RSC_MGR_OBJ_TYPE_TM_SCHED ? "tm_sched":"invalid")
61
62
63typedef struct
64{
65 bcmos_bool is_initialized;
66} rsc_mgr_context_t;
67
68extern rsc_mgr_context_t rsc_mgr_context;
69
70/** @brief container for storing user data */
71typedef struct rsc_mgr_user_data_entry
72{
73 TAILQ_ENTRY(rsc_mgr_user_data_entry) next;
74 void *user_data;
75} rsc_mgr_user_data_entry;
76
77/** @brief linked list of flow entries sharing the same GEM port or Alloc Id */
78typedef TAILQ_HEAD(, rsc_mgr_user_data_entry) shared_obj_user_data_list;
79
80/* An object ID can be either alloc ID or GEM port. */
81typedef uint32_t rsc_mgr_obj_id;
82
83/* An element for an object linked list. */
84typedef struct rsc_mgr_obj
85{
86 TAILQ_ENTRY(rsc_mgr_obj) list;
87 struct rsc_mgr_obj *base_obj; /* The last object of a range points to the base object of the range. */
88 rsc_mgr_obj_id id;
89 uint32_t ref_count;
90 uint32_t range_size;
91 rsc_mgr_obj_type type;
92 shared_obj_user_data_list user_data_list; /* this stores a list of flows sharing the same gem or alloc id object */
93} rsc_mgr_obj;
94
95typedef TAILQ_HEAD(, rsc_mgr_obj) rsc_mgr_obj_list;
96
97typedef bcmos_bool (*rsc_mgr_is_valid_data_obj_id_cb_t)(bcmolt_pon_ni pon_id, rsc_mgr_obj_id id, rsc_mgr_obj_id min_data_obj_id);
98typedef rsc_mgr_obj_id (*rsc_mgr_get_last_data_obj_id_cb_t)(bcmolt_pon_ni pon_id, rsc_mgr_obj_id min_data_obj_id);
99
100typedef struct
101{
102 const char *obj_name;
103 rsc_mgr_is_valid_data_obj_id_cb_t is_valid_data_obj_id_cb;
104 rsc_mgr_get_last_data_obj_id_cb_t get_last_data_obj_id_cb;
105 rsc_mgr_obj_list free_objs;
106 rsc_mgr_obj_list allocated_objs;
107 rsc_mgr_obj *objs; /* Dynamically allocated */
108 uint32_t num_of_objs;
109 rsc_mgr_obj_id min_data_obj_id;
110} rsc_mgr_obj_rsc;
111
112typedef struct
113{
114 rsc_mgr_obj_rsc alloc_ids;
115 rsc_mgr_obj_rsc gems;
116 uint16_t num_of_alloc_ids;
117 uint16_t num_of_gem_ports;
118#ifndef MULTIPLE_MULTICAST_GEM_PORTS_PER_PON
119 uint16_t multicast_gem_port; /* For validation purposes (validate there is no more than a single multicast GEM port per PON). */
120#endif
121#ifndef MULTIPLE_BROADCAST_GEM_PORTS_PER_PON
122 uint16_t broadcast_gem_port; /* For validation purposes (validate there is no more than a single broadcast GEM port per PON). */
123#endif
124#ifdef ENABLE_LOG
125 dev_log_id log_id;
126 char log_id_name[MAX_DEV_LOG_ID_NAME];
127#endif
128} rsc_mgr_topo_pon_context;
129
130typedef struct
131{
132 rsc_mgr_obj_rsc tm_sched_auto_key_ids;
133 uint16_t num_of_tm_sched_auto_key_ids;
134#ifdef ENABLE_LOG
135 dev_log_id log_id;
136 char log_id_name[MAX_DEV_LOG_ID_NAME];
137#endif
138
139} rsc_mgr_tm_context;
140#ifdef ENABLE_LOG
141extern dev_log_id rsc_mgr_log_id;
142#endif
143
144bcmos_errno rsc_mgr_init_validate(void);
145
146#endif
147