OpenNSL API Guide and Reference Manual
gport.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * (C) Copyright Broadcom Corporation 2013-2017
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  **********************************************************************
18  * File: gport.h
19  * Details: This file defines gport (generic port) parameters.
20  *
21  * Its contents are not used directly by applications;
22  * it is used only by header files of parent APIs which
23  * need to define error codes.
24  *********************************************************************/
25 
26 #ifndef _SHR_GPORT_H
27 #define _SHR_GPORT_H
28 
29 /*
30  * Defines:
31  * _SHR_GPORT_*
32  * Purpose:
33  * GPORT (Generic port) definitions. GPORT can be used to specify
34  * a {module, port} pair, trunk, and other port types.
35  */
36 
37 #define _SHR_GPORT_NONE (0)
38 #define _SHR_GPORT_INVALID (-1)
39 
40 #define _SHR_GPORT_TYPE_LOCAL 1 /* Port on local unit */
41 #define _SHR_GPORT_TYPE_MODPORT 2 /* Module ID and port */
42 #define _SHR_GPORT_TYPE_TRUNK 3 /* Trunk ID */
43 #define _SHR_GPORT_TYPE_BLACK_HOLE 4 /* Black hole destination */
44 #define _SHR_GPORT_TYPE_LOCAL_CPU 5 /* CPU destination */
45 #define _SHR_GPORT_TYPE_UCAST_QUEUE_GROUP 9 /* Queue Group */
46 #define _SHR_GPORT_TYPE_MCAST 11 /* Multicast Set */
47 #define _SHR_GPORT_TYPE_MCAST_QUEUE_GROUP 12 /* Multicast Queue Group */
48 #define _SHR_GPORT_TYPE_SCHEDULER 13 /* Scheduler */
49 #define _SHR_GPORT_TYPE_MIRROR 15 /* Mirror destination. */
50 #define _SHR_GPORT_TYPE_TUNNEL 19 /* Tunnel ID */
51 #define _SHR_GPORT_TYPE_CHILD 20 /* Child port */
52 #define _SHR_GPORT_TYPE_EGRESS_GROUP 21 /* Egress group port */
53 #define _SHR_GPORT_TYPE_EGRESS_CHILD 22 /* Egress child port */
54 #define _SHR_GPORT_TYPE_EGRESS_MODPORT 23 /* Egress Mod and port */
55 #define _SHR_GPORT_TYPE_UCAST_SUBSCRIBER_QUEUE_GROUP 24 /* Local Queue Group */
56 #define _SHR_GPORT_TYPE_MCAST_SUBSCRIBER_QUEUE_GROUP 25 /* Local Multicast Queue Group */
57 #define _SHR_GPORT_TYPE_SYSTEM_PORT 27 /* DPP System-Port */
58 #define _SHR_GPORT_TYPE_COSQ 30 /* cosq gport */
59 #define _SHR_GPORT_TYPE_PROFILE 40
60 #define _SHR_GPORT_TYPE_DESTMOD_QUEUE_GROUP 41 /* DMVOQ gport */
61 
62 /* definitions for cosq core handling */
63 #define _SHR_COSQ_GPORT_COMMON_QUEUE_BITS 18
64 #define _SHR_COSQ_GPORT_COMMON_QUEUE_MASK ((1 << _SHR_COSQ_GPORT_COMMON_QUEUE_BITS) - 1)
65 #define _SHR_COSQ_GPORT_COMMON_CORE_BITS 3
66 #define _SHR_COSQ_GPORT_COMMON_CORE_SHIFT _SHR_COSQ_GPORT_COMMON_QUEUE_BITS
67 #define _SHR_COSQ_GPORT_COMMON_CORE_MASK ((1 << _SHR_COSQ_GPORT_COMMON_CORE_BITS) - 1)
68 #define _SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE _SHR_COSQ_GPORT_COMMON_CORE_MASK
69 /*
70  * Note that only the bits under _SHR_COSQ_GPORT_CORE_MASK are considred
71  * See, e.g. _SHR_COSQ_GPORT_CORE_GET
72  */
73 #define _SHR_CORE_ALL -17
74 #define _SHR_CORE_FIELD2ID(field) ((field) != _SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE ? field : _SHR_CORE_ALL)
75 #define _SHR_CORE_ID2FIELD(id) ((id) != _SHR_CORE_ALL ? id : _SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE)
76 
77 #define _SHR_GPORT_TYPE_SHIFT 26
78 #define _SHR_GPORT_TYPE_MASK 0x3f
79 #define _SHR_GPORT_MODID_SHIFT 11
80 #define _SHR_GPORT_MODID_MASK 0x7fff
81 #define _SHR_GPORT_PORT_SHIFT 0
82 #define _SHR_GPORT_PORT_MASK 0x7ff
83 #define _SHR_GPORT_TRUNK_SHIFT 0
84 #define _SHR_GPORT_TRUNK_MASK 0x3ffffff
85 #define _SHR_GPORT_UCAST_QUEUE_GROUP_SHIFT 0
86 #define _SHR_GPORT_UCAST_QUEUE_GROUP_MASK 0x3ffffff
87 #define _SHR_GPORT_UCAST_QUEUE_GROUP_QID_SHIFT 0
88 #define _SHR_GPORT_UCAST_QUEUE_GROUP_QID_MASK 0x3fff
89 #define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_SHIFT 14
90 #define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK 0xfff
91 #define _SHR_GPORT_MCAST_QUEUE_GROUP_QID_SHIFT 0
92 #define _SHR_GPORT_MCAST_QUEUE_GROUP_QID_MASK 0x3fff
93 #define _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_SHIFT 14
94 #define _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_MASK 0xfff
95 #define _SHR_GPORT_SCHEDULER_SHIFT 0
96 #define _SHR_GPORT_SCHEDULER_MASK 0x7fffff
97 #define _SHR_GPORT_SCHEDULER_CORE_SHIFT 23
98 #define _SHR_GPORT_SCHEDULER_CORE_MASK _SHR_COSQ_GPORT_COMMON_CORE_MASK
99 #define _SHR_GPORT_SCHEDULER_NODE_SHIFT 0
100 #define _SHR_GPORT_SCHEDULER_NODE_MASK 0xfffff
101 #define _SHR_GPORT_MIRROR_SHIFT 0
102 #define _SHR_GPORT_MIRROR_MASK 0xffff
103 #define _SHR_GPORT_TUNNEL_SHIFT 0
104 #define _SHR_GPORT_TUNNEL_MASK 0x3ffffff
105 #define _SHR_GPORT_SYSTEM_PORT_SHIFT 0
106 #define _SHR_GPORT_SYSTEM_PORT_MASK 0xffffff
107 
108 #define _SHR_GPORT_TYPE_TRAP ((_SHR_GPORT_TYPE_LOCAL_CPU << 1) | 1) /* This will mark the CPU type, and
109  the 1st bit in the value to indicate trap */
110 #define _SHR_GPORT_TYPE_TRAP_SHIFT (_SHR_GPORT_TYPE_SHIFT-1) /* 25 */
111 #define _SHR_GPORT_TYPE_TRAP_MASK (_SHR_GPORT_TYPE_MASK<<1|1) /* 0x4f */
112 #define _SHR_GPORT_TRAP_ID_SHIFT 0
113 #define _SHR_GPORT_TRAP_ID_MASK 0xfff
114 #define _SHR_GPORT_TRAP_STRENGTH_SHIFT 12
115 #define _SHR_GPORT_TRAP_STRENGTH_MASK 0xf
116 #define _SHR_GPORT_TRAP_SNOOP_STRENGTH_SHIFT 16
117 #define _SHR_GPORT_TRAP_SNOOP_STRENGTH_MASK 0xf
119 #define _SHR_GPORT_LOCAL_TYPE_COMMON (0)
120 #define _SHR_GPORT_LOCAL_TYPE_FABRIC (1)
121 #define _SHR_GPORT_LOCAL_TYPE_SHIFT (21)
122 #define _SHR_GPORT_LOCAL_TYPE_MASK (0x1f)
124 #define _SHR_GPORT_IS_LOCAL(_gport) \
125  (((((_gport) >> _SHR_GPORT_TYPE_SHIFT) & _SHR_GPORT_TYPE_MASK) == \
126  _SHR_GPORT_TYPE_LOCAL) && \
127  ((((_gport) >> _SHR_GPORT_LOCAL_TYPE_SHIFT) & _SHR_GPORT_LOCAL_TYPE_MASK) == \
128  _SHR_GPORT_LOCAL_TYPE_COMMON))
130 #define _SHR_GPORT_LOCAL_SET(_gport, _port)\
131  ((_gport) = (_SHR_GPORT_TYPE_LOCAL << _SHR_GPORT_TYPE_SHIFT) |\
132  (_SHR_GPORT_LOCAL_TYPE_COMMON << _SHR_GPORT_LOCAL_TYPE_SHIFT)|\
133  (((_port) & _SHR_GPORT_PORT_MASK) << _SHR_GPORT_PORT_SHIFT))
135 #define _SHR_GPORT_LOCAL_GET(_gport) \
136  (((_gport) >> _SHR_GPORT_PORT_SHIFT) & _SHR_GPORT_PORT_MASK)
138 #define _SHR_GPORT_IS_MODPORT(_gport) \
139  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_MODPORT)
141 #define _SHR_GPORT_MODPORT_SET(_gport, _module, _port) \
142  ((_gport) = (_SHR_GPORT_TYPE_MODPORT << _SHR_GPORT_TYPE_SHIFT) | \
143  (((_module) & _SHR_GPORT_MODID_MASK) << _SHR_GPORT_MODID_SHIFT) | \
144  (((_port) & _SHR_GPORT_PORT_MASK) << _SHR_GPORT_PORT_SHIFT))
146 #define _SHR_GPORT_MODPORT_MODID_GET(_gport) \
147  (((_gport) >> _SHR_GPORT_MODID_SHIFT) & _SHR_GPORT_MODID_MASK)
149 #define _SHR_GPORT_MODPORT_PORT_GET(_gport) \
150  (((_gport) >> _SHR_GPORT_PORT_SHIFT) & _SHR_GPORT_PORT_MASK)
152 #define _SHR_GPORT_IS_TRUNK(_gport) \
153  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_TRUNK)
155 #define _SHR_GPORT_TRUNK_SET(_gport, _trunk_id) \
156  ((_gport) = (_SHR_GPORT_TYPE_TRUNK << _SHR_GPORT_TYPE_SHIFT) | \
157  (((_trunk_id) & _SHR_GPORT_TRUNK_MASK) << _SHR_GPORT_TRUNK_SHIFT))
159 #define _SHR_GPORT_TRUNK_GET(_gport) \
160  (((_gport) >> _SHR_GPORT_TRUNK_SHIFT) & _SHR_GPORT_TRUNK_MASK)
162 #define _SHR_GPORT_IS_SCHEDULER(_gport) \
163  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_SCHEDULER)
165 #define _SHR_GPORT_SCHEDULER_SET(_gport, _id) \
166  _SHR_GPORT_SCHEDULER_CORE_SET(_gport, _id, _SHR_CORE_ALL)
168 #define _SHR_GPORT_SCHEDULER_GET(_gport) \
169  (((_gport) >> _SHR_GPORT_SCHEDULER_SHIFT) & _SHR_GPORT_SCHEDULER_MASK)
171 #define _SHR_GPORT_SCHEDULER_CORE_GET(_gport) \
172  _SHR_CORE_FIELD2ID((((_gport) >> _SHR_GPORT_SCHEDULER_CORE_SHIFT) & _SHR_GPORT_SCHEDULER_CORE_MASK))
174 #define _SHR_GPORT_SCHEDULER_CORE_SET(_gport, _scheduler_id, _core_id) \
175  ((_gport) = (_SHR_GPORT_TYPE_SCHEDULER << _SHR_GPORT_TYPE_SHIFT) | \
176  (((_scheduler_id) & _SHR_GPORT_SCHEDULER_MASK) << _SHR_GPORT_SCHEDULER_SHIFT) | \
177  (((_SHR_CORE_ID2FIELD(_core_id)) & _SHR_GPORT_SCHEDULER_CORE_MASK) << _SHR_GPORT_SCHEDULER_CORE_SHIFT))
179 #define _SHR_GPORT_SCHEDULER_NODE_SET(_gport, _level, _node) \
180  ((_gport) = (_SHR_GPORT_TYPE_SCHEDULER << _SHR_GPORT_TYPE_SHIFT) | \
181  (((_level) & _SHR_GPORT_SCHEDULER_LEVEL_MASK) << _SHR_GPORT_SCHEDULER_LEVEL_SHIFT) | \
182  (((_node) & _SHR_GPORT_SCHEDULER_NODE_MASK) << _SHR_GPORT_SCHEDULER_NODE_SHIFT))
184 #define _SHR_GPORT_SCHEDULER_NODE_GET(_gport) \
185  (((_gport) >> _SHR_GPORT_SCHEDULER_NODE_SHIFT) & _SHR_GPORT_SCHEDULER_NODE_MASK)
187 #define _SHR_GPORT_BLACK_HOLE \
188  (_SHR_GPORT_TYPE_BLACK_HOLE << _SHR_GPORT_TYPE_SHIFT)
190 #define _SHR_GPORT_IS_BLACK_HOLE(_gport) ((_gport) == _SHR_GPORT_BLACK_HOLE)
192 #define _SHR_GPORT_LOCAL_CPU \
193  (_SHR_GPORT_TYPE_LOCAL_CPU << _SHR_GPORT_TYPE_SHIFT)
195 #define _SHR_GPORT_IS_UCAST_QUEUE_GROUP(_gport) \
196  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_UCAST_QUEUE_GROUP)
198 #define _SHR_GPORT_UCAST_QUEUE_GROUP_SET(_gport, _qid) \
199  _SHR_GPORT_UCAST_QUEUE_GROUP_SYSQID_SET(_gport, \
200  _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK, \
201  _qid)
203 #define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSQID_SET(_gport, _sysport_id, _qid) \
204  ((_gport) = (_SHR_GPORT_TYPE_UCAST_QUEUE_GROUP << _SHR_GPORT_TYPE_SHIFT) | \
205  (((_sysport_id) & _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK) << _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_SHIFT) | \
206  (((_qid) & _SHR_GPORT_UCAST_QUEUE_GROUP_QID_MASK) << _SHR_GPORT_UCAST_QUEUE_GROUP_QID_SHIFT))
208 #define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_GET(_gport) \
209  (((_gport) >> _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_SHIFT) & _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK)
211 #define _SHR_GPORT_UCAST_QUEUE_GROUP_QID_GET(_gport) \
212  (((_gport) >> _SHR_GPORT_UCAST_QUEUE_GROUP_QID_SHIFT) & _SHR_GPORT_UCAST_QUEUE_GROUP_QID_MASK)
214 #define _SHR_GPORT_IS_MCAST_QUEUE_GROUP(_gport) \
215  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_MCAST_QUEUE_GROUP)
217 #define _SHR_GPORT_MCAST_QUEUE_GROUP_SET(_gport, _qid) \
218  _SHR_GPORT_MCAST_QUEUE_GROUP_SYSQID_SET(_gport, \
219  _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_MASK, \
220  _qid)
222 #define _SHR_GPORT_MCAST_QUEUE_GROUP_GET(_gport) \
223  _SHR_GPORT_MCAST_QUEUE_GROUP_QID_GET(_gport)
225 #define _SHR_GPORT_MCAST_QUEUE_GROUP_SYSQID_SET(_gport, _sysport_id, _qid) \
226  ((_gport) = (_SHR_GPORT_TYPE_MCAST_QUEUE_GROUP << _SHR_GPORT_TYPE_SHIFT) | \
227  (((_sysport_id) & _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_MASK) << _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_SHIFT) | \
228  (((_qid) & _SHR_GPORT_MCAST_QUEUE_GROUP_QID_MASK) << _SHR_GPORT_MCAST_QUEUE_GROUP_QID_SHIFT))
230 #define _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_GET(_gport) \
231  (((_gport) >> _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_SHIFT) & _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_MASK)
233 #define _SHR_GPORT_MCAST_QUEUE_GROUP_QID_GET(_gport) \
234  (((_gport) >> _SHR_GPORT_MCAST_QUEUE_GROUP_QID_SHIFT) & _SHR_GPORT_MCAST_QUEUE_GROUP_QID_MASK)
235 
236 /* for multicast queue gports representing queue ID + core ID */
237 #define _SHR_GPORT_MCAST_QUEUE_GROUP_QUEUE_SET(_gport, _qid) \
238  ((_gport) = (_SHR_GPORT_TYPE_MCAST_QUEUE_GROUP << _SHR_GPORT_TYPE_SHIFT) | \
239  (_SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE << _SHR_COSQ_GPORT_COMMON_CORE_SHIFT) | \
240  (((_qid) & _SHR_COSQ_GPORT_COMMON_QUEUE_MASK) << _SHR_GPORT_MCAST_QUEUE_GROUP_QID_SHIFT))
242 #define _SHR_GPORT_MCAST_QUEUE_GROUP_CORE_QUEUE_SET(_gport, _core, _qid) \
243  ((_gport) = (_SHR_GPORT_TYPE_MCAST_QUEUE_GROUP << _SHR_GPORT_TYPE_SHIFT) | \
244  (_SHR_CORE_ID2FIELD(_core) << _SHR_COSQ_GPORT_COMMON_CORE_SHIFT) | \
245  (((_qid) & _SHR_COSQ_GPORT_COMMON_QUEUE_MASK) << _SHR_GPORT_MCAST_QUEUE_GROUP_QID_SHIFT))
247 #define _SHR_GPORT_MCAST_QUEUE_GROUP_QUEUE_GET(_gport) \
248  (_SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_GET(_gport) == _SHR_GPORT_MCAST_QUEUE_GROUP_SYSPORTID_MASK ? \
249  _SHR_GPORT_MCAST_QUEUE_GROUP_QID_GET(_gport) : \
250  (((_gport) >> _SHR_GPORT_MCAST_QUEUE_GROUP_QID_SHIFT) & _SHR_COSQ_GPORT_COMMON_QUEUE_MASK))
252 #define _SHR_GPORT_MCAST_QUEUE_GROUP_CORE_GET(_gport) \
253  _SHR_CORE_FIELD2ID(((_gport) >> _SHR_COSQ_GPORT_COMMON_CORE_SHIFT) & _SHR_COSQ_GPORT_COMMON_CORE_MASK)
255 #define _SHR_GPORT_IS_MIRROR(_gport) \
256  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_MIRROR)
258 #define _SHR_GPORT_MIRROR_SET(_gport, _value) \
259  ((_gport) = (_SHR_GPORT_TYPE_MIRROR << _SHR_GPORT_TYPE_SHIFT) | \
260  (((_value) & _SHR_GPORT_MIRROR_MASK) << _SHR_GPORT_MIRROR_SHIFT))
262 #define _SHR_GPORT_MIRROR_GET(_gport) \
263  (((_gport) >> _SHR_GPORT_MIRROR_SHIFT) & _SHR_GPORT_MIRROR_MASK)
265 #define _SHR_GPORT_IS_TUNNEL(_gport) \
266  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_TUNNEL)
268 #define _SHR_GPORT_TUNNEL_ID_SET(_gport, _tunnel_id) \
269  ((_gport) = (_SHR_GPORT_TYPE_TUNNEL << _SHR_GPORT_TYPE_SHIFT) | \
270  (((_tunnel_id) & _SHR_GPORT_TUNNEL_MASK) << _SHR_GPORT_TUNNEL_SHIFT))
272 #define _SHR_GPORT_TUNNEL_ID_GET(_gport) \
273  (((_gport) >> _SHR_GPORT_TUNNEL_SHIFT) & _SHR_GPORT_TUNNEL_MASK)
275 #define _SHR_GPORT_IS_SYSTEM_PORT(_gport) \
276  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_SYSTEM_PORT)
277 #define _SHR_GPORT_SYSTEM_PORT_ID_GET(_gport) \
278  (((_gport) >> _SHR_GPORT_SYSTEM_PORT_SHIFT) & _SHR_GPORT_SYSTEM_PORT_MASK)
279 #define _SHR_GPORT_SYSTEM_PORT_ID_SET(_gport, _id) \
280  ((_gport) = (_SHR_GPORT_TYPE_SYSTEM_PORT << _SHR_GPORT_TYPE_SHIFT) | \
281  (((_id) & _SHR_GPORT_SYSTEM_PORT_MASK) << _SHR_GPORT_SYSTEM_PORT_SHIFT))
283 #define _SHR_GPORT_IS_COSQ(_gport) \
284  (((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_COSQ)
286 #define _SHR_GPORT_TRAP_SET(_gport, _trap_id, _trap_strength, _snoop_strength) \
287  ((_gport) = (_SHR_GPORT_TYPE_TRAP << _SHR_GPORT_TYPE_TRAP_SHIFT) | \
288  (((_trap_id) & _SHR_GPORT_TRAP_ID_MASK) << _SHR_GPORT_TRAP_ID_SHIFT) | \
289  (((_trap_strength) & _SHR_GPORT_TRAP_STRENGTH_MASK) << _SHR_GPORT_TRAP_STRENGTH_SHIFT) | \
290  (((_snoop_strength) & _SHR_GPORT_TRAP_SNOOP_STRENGTH_MASK) << _SHR_GPORT_TRAP_SNOOP_STRENGTH_SHIFT) )
292 #define _SHR_GPORT_TRAP_GET_ID(_gport) \
293  (((_gport) >> _SHR_GPORT_TRAP_ID_SHIFT) & _SHR_GPORT_TRAP_ID_MASK)
295 #define _SHR_GPORT_TRAP_GET_STRENGTH(_gport) \
296  (((_gport) >> _SHR_GPORT_TRAP_STRENGTH_SHIFT & _SHR_GPORT_TRAP_STRENGTH_MASK))
298 #define _SHR_GPORT_TRAP_GET_SNOOP_STRENGTH(_gport) \
299  (((_gport) >> _SHR_GPORT_TRAP_SNOOP_STRENGTH_SHIFT & _SHR_GPORT_TRAP_SNOOP_STRENGTH_MASK))
301 #define _SHR_GPORT_IS_TRAP(_gport) \
302  (((_gport) >> _SHR_GPORT_TYPE_TRAP_SHIFT) == _SHR_GPORT_TYPE_TRAP)
304 #define _SHR_FIELD_CTR_PROC_MASK_LEGACY ((1 << 2) - 1) /*2 bits for counter engines in Arad */
305 #define _SHR_FIELD_CTR_PROC_SHIFT_LEGACY 29 /* minimum 20 for the Statistic-Report Counter in Arad */
306 #define _SHR_FIELD_CTR_SET_MASK_LEGACY ((1 << _SHR_FIELD_CTR_PROC_SHIFT_LEGACY) - 1)
307 #define _SHR_FIELD_CTR_SET_SHIFT_LEGACY 0
309 #define _SHR_FIELD_STAT_ID_PROC_LEGACY_GET(_stat_id) \
310  (((_stat_id) >> _SHR_FIELD_CTR_PROC_SHIFT_LEGACY) & _SHR_FIELD_CTR_PROC_MASK_LEGACY)
312 #define _SHR_FIELD_STAT_ID_CNTR_LEGACY_GET(_stat_id) \
313  (((_stat_id) >> _SHR_FIELD_CTR_SET_SHIFT_LEGACY) & _SHR_FIELD_CTR_SET_MASK_LEGACY)
315 #define _SHR_FIELD_STAT_ID_LEGACY_SET(_proc, _ctr) \
316  ((((_proc) & _SHR_FIELD_CTR_PROC_MASK_LEGACY) << _SHR_FIELD_CTR_PROC_SHIFT_LEGACY)\
317  | (((_ctr) & _SHR_FIELD_CTR_SET_MASK_LEGACY) << _SHR_FIELD_CTR_SET_SHIFT_LEGACY))
319 #define _SHR_FIELD_STAT_ID_IS_LEGACY(_stat_id) (!((_stat_id >> 31) & 0x1))
320 #define _SHR_FIELD_STAT_ID_LEGACY (0x1 << 31)
321 
322 /* minimum 20 for the Statistic-Report Counter in Arad */
323 #define _SHR_FIELD_CTR_PROC_MASK ((1 << 4) - 1) /*4 bits for counter engines in Arad */
325 #define _SHR_FIELD_CTR_PROC_SHIFT 27 /* minimum 20 for the Statistic-Report Counter in Jericho */
326 #define _SHR_FIELD_CTR_SET_MASK ((1 << _SHR_FIELD_CTR_PROC_SHIFT) - 1)
327 #define _SHR_FIELD_CTR_SET_SHIFT 0
329 #define _SHR_FIELD_CTR_PROC_SHIFT_GET(_stat_id) (_SHR_FIELD_STAT_ID_IS_LEGACY(_stat_id) ? _SHR_FIELD_CTR_PROC_SHIFT_LEGACY : _SHR_FIELD_CTR_PROC_SHIFT)
330 #define _SHR_FIELD_STAT_ID_PROC_NEW_GET(_stat_id) \
331  (((_stat_id) >> _SHR_FIELD_CTR_PROC_SHIFT) & _SHR_FIELD_CTR_PROC_MASK)
333 #define _SHR_FIELD_STAT_ID_CNTR_NEW_GET(_stat_id) \
334  (((_stat_id) >> _SHR_FIELD_CTR_SET_SHIFT) & _SHR_FIELD_CTR_SET_MASK)
336 #define _SHR_FIELD_STAT_ID_NEW_SET(_proc, _ctr) \
337  (_SHR_FIELD_STAT_ID_LEGACY | \
338  (((_proc) & _SHR_FIELD_CTR_PROC_MASK) << _SHR_FIELD_CTR_PROC_SHIFT)|\
339  (((_ctr) & _SHR_FIELD_CTR_SET_MASK) << _SHR_FIELD_CTR_SET_SHIFT))
341 #define _SHR_FIELD_STAT_ID_PROCESSOR_GET(_stat_id) \
342  (_SHR_FIELD_STAT_ID_IS_LEGACY(_stat_id) ? \
343  _SHR_FIELD_STAT_ID_PROC_LEGACY_GET(_stat_id) : \
344  _SHR_FIELD_STAT_ID_PROC_NEW_GET(_stat_id))
346 #define _SHR_FIELD_STAT_ID_COUNTER_GET(_stat_id) \
347  (_SHR_FIELD_STAT_ID_IS_LEGACY(_stat_id) ? \
348  _SHR_FIELD_STAT_ID_CNTR_LEGACY_GET(_stat_id) : \
349  _SHR_FIELD_STAT_ID_CNTR_NEW_GET(_stat_id))
351 #define _SHR_FIELD_STAT_ID_SET(_stat_id, _proc, _ctr) \
352  (_stat_id = _SHR_FIELD_STAT_ID_NEW_SET(_proc, _ctr))
353 
354 #endif /* !_SHR_GPORT_H */