Add Broadcom / Netgear changes from RAXE 1.0.0.48
[project/bcm63xx/u-boot.git] / arch / arm / mach-bcmbca / xrdp / rdpa_types.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (c) 2013 Broadcom
4 */
5 /*
6 *
7 */
8
9
10 #ifndef _RDPA_TYPES_H_
11 #define _RDPA_TYPES_H_
12
13 #include <bdmf_data_types.h>
14
15 /** Traffic direction */
16 typedef enum {
17 rdpa_dir_ds, /* Downstream */
18 rdpa_dir_us /* Upstream */
19 } rdpa_traffic_dir;
20
21 /* Direction + index, Underlying structure for rdpa_dir_index aggregate */
22 typedef struct {
23 rdpa_traffic_dir dir; /* Traffic direction */
24 bdmf_index index; /* Index */
25 } rdpa_dir_index_t;
26
27 /* PPPoE header */
28 typedef struct {
29 uint32_t session; /* PPPoE session ID */
30 } rdpa_pppoe_t;
31
32 /* PBIT */
33 typedef uint8_t rdpa_pbit;
34
35 /* DSCP */
36 typedef uint8_t rdpa_dscp;
37
38 /* DSCP pbit dei */
39 typedef struct {
40 uint8_t pbit; /* pbit */
41 uint8_t dei; /* pbit */
42 } rdpa_pbit_dei_t;
43
44 /* Priority */
45 typedef uint8_t rdpa_prty;
46
47 /** TCONT index */
48 typedef uint8_t rdpa_tcont;
49
50 /* Dual Stack lite tunnel ID */
51 /* this enum is the only modification needed in order to add more than
52 * one tunnel */
53 typedef enum {
54 rdpa_ds_lite_tunnel_0,
55 rdpa_ds_lite_max_tunnel_id = rdpa_ds_lite_tunnel_0
56 } rdpa_ds_lite_tunnel_id;
57
58 /* GEM flow ID (internal index) */
59 typedef uint16_t rdpa_gem;
60
61 /* Ethernet/GEM flow ID */
62 typedef uint16_t rdpa_flow;
63
64 /* not used by xDSL WAN Mode. flows 1-15 are used by DSL WAN modes for 16
65 * channels in multiples upto 255.
66 * Any other values would collide with the DSL WAN flows.
67 * values 0x0, 0x10, 0x20... are unused. */
68 #define GBE_WAN_FLOW_ID 0
69
70
71 /* UNASSIGNED value */
72 #define RDPA_VALUE_UNASSIGNED ((unsigned)-1)
73 #define RDPA_VALUE_UNMATCHED RDPA_VALUE_UNASSIGNED
74
75 /* ANY value */
76 #define RDPA_VALUE_ANY ((unsigned)-2)
77
78 /* VID/PBIT/DEI */
79 #define RDPA_VID_UNTAGGED ((unsigned)-3)
80 #define RDPA_MAX_VID 4095
81 #define RDPA_MAX_PBIT 7
82 #define RDPA_MAX_DEI 1
83
84 /* Layer-4 PROTOCOL definitions */
85 #define RDPA_INVALID_PROTOCOL (0xFF)
86
87 /* TPID Detect.
88 * A set of TPID values, both pre- and user-defined,
89 * used to apply tagging classification rules on incoming
90 * traffic. Accordingly, every packet is classified as Single
91 * or Double tagged. */
92 typedef enum {
93 rdpa_tpid_detect_0x8100, /* Pre-Defined, 0x8100 */
94 rdpa_tpid_detect_0x88A8, /* Pre-Defined, 0x88A8 */
95 rdpa_tpid_detect_0x9100, /* Pre-Defined, 0x9100 */
96 rdpa_tpid_detect_0x9200, /* Pre-Defined, 0x9200 */
97
98 rdpa_tpid_detect_udef_1, /* User-Defined, #1 */
99 rdpa_tpid_detect_udef_2, /* User-Defined, #2 */
100
101 rdpa_tpid_detect__num_of
102 } rdpa_tpid_detect_t;
103
104
105 /* Forwarding action */
106 typedef enum {
107 rdpa_forward_action_none = 0, /* ACL */
108 rdpa_forward_action_forward = 1, /* Forward */
109 rdpa_forward_action_host = 2, /* Trap to the host */
110 rdpa_forward_action_drop = 4, /* Discard */
111 rdpa_forward_action_flood = 8, /* Flood, for DA lookup only */
112 /* Skip - used for generic filter for increment counter action only */
113 rdpa_forward_action_skip = 16
114 } rdpa_forward_action;
115
116 /** Filtering action */
117 typedef enum {
118 rdpa_filter_action_allow, /* Allow through */
119 rdpa_filter_action_deny /* Block packet */
120 } rdpa_filter_action;
121
122 /** QoS mapping method */
123 typedef enum {
124 rdpa_qos_method_flow, /**< Flow-based QoS mapping */
125 rdpa_qos_method_pbit /**< Pbit-based QoS mapping */
126 } rdpa_qos_method;
127
128 /** Allow frame types */
129 typedef enum
130 {
131 rdpa_port_allow_any, /**< Allow tagged and untagged frames */
132 rdpa_port_allow_tagged, /**< Allow tagged frames only */
133 rdpa_port_allow_untagged, /**< Allow untagged frames only */
134 } rdpa_port_frame_allow;
135
136 /** Forwarding mode */
137 typedef enum
138 {
139 rdpa_forwarding_mode_pkt, /**< Packet-based forwarding */
140 rdpa_forwarding_mode_flow, /**< Flow-based forwarding */
141 } rdpa_forwarding_mode;
142
143 /** DS Ethernet flow classification mode */
144 typedef enum
145 {
146 rdpa_classify_mode_pkt, /**< Packet-based classification */
147 rdpa_classify_mode_flow, /**< Flow-based classification */
148 } rdpa_classify_mode;
149
150 /** Discard priority */
151 typedef enum
152 {
153 rdpa_discard_prty_low, /**< Low priority for Ingress QoS: traffic dropped under high ingress congestion */
154 rdpa_discard_prty_high /**< High priority for Ingress QoS: traffic passed under high ingress congresion */
155 } rdpa_discard_prty;
156
157 /** Flow destination */
158 typedef enum
159 {
160 rdpa_flow_dest_none, /**< Not set */
161
162 rdpa_flow_dest_iptv, /**< IPTV */
163 rdpa_flow_dest_eth, /**< Flow */
164 rdpa_flow_dest_omci, /**< OMCI */
165
166 rdpa_flow_dest__num_of, /* Number of values in rdpa_flow_destination enum */
167 } rdpa_flow_destination;
168
169 /** WAN technology */
170 typedef enum
171 {
172 rdpa_wan_none, /**< Not configured */
173 rdpa_wan_gpon, /**< GPON */
174 rdpa_wan_xgpon, /**< XGPON */
175 rdpa_wan_epon, /**< EPON */
176 rdpa_wan_xepon, /**< XEPON */
177 rdpa_wan_gbe, /**< GbE */
178 rdpa_wan_dsl, /**< xDSL */
179 rdpa_wan_type__num_of
180 } rdpa_wan_type;
181
182 /** Link speed */
183 typedef enum
184 {
185 rdpa_speed_none, /**< Not configured */
186 rdpa_speed_100m, /**< Speed of 100 Mega */
187 rdpa_speed_1g, /**< Speed of 1 Giga */
188 rdpa_speed_2_5g, /**< Speed of 2.5 Giga */
189 rdpa_speed_5g, /**< Speed of 5 Giga */
190 rdpa_speed_10g, /**< Speed of 10 Giga */
191 } rdpa_speed_type;
192
193 /** Simple statistics */
194 typedef struct
195 {
196 uint32_t packets; /**< Packets */
197 uint32_t bytes; /**< Bytes */
198 } rdpa_stat_t;
199
200 /** Generic 1-way statistics */
201 typedef struct
202 {
203 rdpa_stat_t passed; /**< Passed statistics */
204 rdpa_stat_t discarded; /**< Discarded statistics */
205 } rdpa_stat_1way_t;
206
207 /** Tx+Rx statistics */
208 typedef struct
209 {
210 rdpa_stat_1way_t tx; /**< Transmit statistics */
211 rdpa_stat_1way_t rx; /**< Receive statistics */
212 } rdpa_stat_tx_rx_t;
213
214 /** Tx+Rx statistics for passed packets + bytes */
215 typedef struct
216 {
217 rdpa_stat_t tx; /**< Transmit statistics */
218 rdpa_stat_t rx; /**< Receive statistics */
219 } rdpa_stat_tx_rx_valid_t;
220
221 /** RDPA interface (port).
222 * The enum includes physical and virtual ports that
223 * can appear in bridging / routing rules as ingress or egress interface.
224 * The port list does not include VLAN-based virtual interfaces and tunnels.
225 * Aggregation ports, such as PCI and SWITCH, can be used in 2-level scheduling.
226 */
227 typedef enum
228 {
229 rdpa_if_first, /*< First interface */
230
231 /** WAN ports */
232 rdpa_if_wan0 = rdpa_if_first, /**< WAN0 port */
233 rdpa_if_wan1, /**< WAN1 port */
234 rdpa_if_wan2, /**< WAN2 port */
235 rdpa_if_wan_max = rdpa_if_wan2,
236 /** LAN ports */
237 rdpa_if_lan0, /**< LAN0 port */
238 rdpa_if_lan1, /**< LAN1 port */
239 rdpa_if_lan2, /**< LAN2 port */
240 rdpa_if_lan3, /**< LAN3 port */
241 rdpa_if_lan4, /**< LAN4 port */
242 rdpa_if_lan5, /**< LAN5 port */
243 rdpa_if_lan6, /**< LAN6 port */
244 rdpa_if_lan7, /**< LAN7 port */
245 #if defined(BCM_DSL_RDP) || defined(BCM_DSL_XRDP)
246 rdpa_if_lan_max = rdpa_if_lan7,
247 #else /* DSL Platforms */
248 rdpa_if_lan8, /**< LAN8 port */
249 rdpa_if_lan9, /**< LAN9 port */
250 rdpa_if_lan10, /**< LAN10 port */
251 rdpa_if_lan11, /**< LAN11 port */
252 rdpa_if_lan12, /**< LAN12 port */
253 rdpa_if_lan13, /**< LAN13 port */
254 rdpa_if_lan14, /**< LAN14 port */
255 rdpa_if_lan15, /**< LAN15 port */
256 rdpa_if_lan16, /**< LAN16 port */
257 rdpa_if_lan17, /**< LAN17 port */
258 rdpa_if_lan18, /**< LAN18 port */
259 rdpa_if_lan19, /**< LAN19 port */
260 rdpa_if_lan20, /**< LAN20 port */
261 rdpa_if_lan21, /**< LAN21 port */
262 #ifdef G9991
263 rdpa_if_lan22, /**< LAN22 port */
264 rdpa_if_lan23, /**< LAN23 port */
265 rdpa_if_lan24, /**< LAN24 port */
266 rdpa_if_lan25, /**< LAN25 port */
267 rdpa_if_lan26, /**< LAN26 port */
268 rdpa_if_lan27, /**< LAN27 port */
269 rdpa_if_lan28, /**< LAN28 port */
270 rdpa_if_lan29, /**< LAN29 port */
271 rdpa_if_lan_max = rdpa_if_lan29,
272 #else
273 rdpa_if_lan_max = rdpa_if_lan21,
274 #endif
275 #endif /* PON Platforms */
276 /** Special ports */
277 rdpa_if_lag0, /**< Physical emac0 port */
278 rdpa_if_lag1, /**< Physical emac1 port */
279 rdpa_if_lag2, /**< Physical emac2 port */
280 rdpa_if_lag3, /**< Physical emac3 port */
281 rdpa_if_lag4, /**< Physical emac4 port */
282 rdpa_if_lag_max = rdpa_if_lag4,
283
284 /** Switch aggregate port */
285 rdpa_if_switch, /**< LAN switch port */
286
287 #ifndef XRDP
288 /** CPU ports for WLAN usage (local termination) */
289 rdpa_if_wlan0,
290 rdpa_if_cpu_first = rdpa_if_wlan0,
291 rdpa_if_wlan1,
292 rdpa_if_wlan_last = rdpa_if_wlan1,
293 /** CPU (local termination) */
294 rdpa_if_cpu, /**< CPU port (local termination) */
295
296 rdpa_if_max_mcast_port = rdpa_if_cpu, /* only above ports could be part of mcast egress port mask */
297
298 /** Wi-Fi logical ports (SSIDs) */
299 rdpa_if_ssid0, /**< Wi-Fi: SSID0 */
300 rdpa_if_ssid1, /**< Wi-Fi: SSID1 */
301 rdpa_if_ssid2, /**< Wi-Fi: SSID2 */
302 rdpa_if_ssid3, /**< Wi-Fi: SSID3 */
303 rdpa_if_ssid4, /**< Wi-Fi: SSID4 */
304 rdpa_if_ssid5, /**< Wi-Fi: SSID5 */
305 rdpa_if_ssid6, /**< Wi-Fi: SSID6 */
306 rdpa_if_ssid7, /**< Wi-Fi: SSID7 */
307 rdpa_if_ssid8, /**< Wi-Fi: SSID8 */
308 rdpa_if_ssid9, /**< Wi-Fi: SSID9 */
309 rdpa_if_ssid10, /**< Wi-Fi: SSID10 */
310 rdpa_if_ssid11, /**< Wi-Fi: SSID11 */
311 rdpa_if_ssid12, /**< Wi-Fi: SSID12 */
312 rdpa_if_ssid13, /**< Wi-Fi: SSID13 */
313 rdpa_if_ssid14, /**< Wi-Fi: SSID14 */
314 rdpa_if_ssid15, /**< Wi-Fi: SSID15 */
315 rdpa_if_cpu_last = rdpa_if_ssid15,
316 #else
317 /** CPU ports (local termination) */
318 rdpa_if_cpu0, /**< CPU0 port (local termination) */
319 rdpa_if_cpu_first = rdpa_if_cpu0,
320 rdpa_if_cpu = rdpa_if_cpu0,
321 rdpa_if_max_mcast_port = rdpa_if_cpu, /* only above ports could be part of mcast egress port mask */
322 rdpa_if_cpu1, /**< CPU1 port (local termination) */
323 rdpa_if_cpu2, /**< CPU2 port (local termination) */
324 rdpa_if_cpu3, /**< CPU3 port (local termination) */
325 rdpa_if_wlan0, /**< CPU port (local termination) reserved for WLAN0 */
326 rdpa_if_wlan1, /**< CPU port (local termination) reserved for WLAN1 */
327 rdpa_if_wlan2, /**< CPU port (local termination) reserved for WLAN2 */
328 rdpa_if_wlan_last = rdpa_if_wlan2,
329 rdpa_if_cpu_last = rdpa_if_wlan2,
330 #endif
331
332 rdpa_if_bond0, /**< Virtual Port bonding interface 0 */
333 rdpa_if_bond1, /**< Virtual Port bonding interface 1 */
334 rdpa_if_bond2, /**< Virtual Port bonding interface 2 */
335 rdpa_if_bond_max = rdpa_if_bond2,
336 rdpa_if_any, /**< Any Port */
337
338
339 rdpa_if__number_of,
340
341 rdpa_if_none /**< No port */
342
343 } rdpa_if;
344
345 typedef enum
346 {
347 rdpa_wlan_ssid0,
348 rdpa_wlan_ssid1,
349 rdpa_wlan_ssid2,
350 rdpa_wlan_ssid3,
351 rdpa_wlan_ssid4,
352 rdpa_wlan_ssid5,
353 rdpa_wlan_ssid6,
354 rdpa_wlan_ssid7,
355 rdpa_wlan_ssid8,
356 rdpa_wlan_ssid9,
357 rdpa_wlan_ssid10,
358 rdpa_wlan_ssid11,
359 rdpa_wlan_ssid12,
360 rdpa_wlan_ssid13,
361 rdpa_wlan_ssid14,
362 rdpa_wlan_ssid15,
363 } rdpa_wlan_ssid;
364
365 /** EMAC id */
366 typedef enum
367 {
368 rdpa_emac0, /**< EMAC0 */
369 rdpa_emac1, /**< EMAC1 */
370 rdpa_emac2, /**< EMAC2 */
371 rdpa_emac3, /**< EMAC3 */
372 rdpa_emac4, /**< EMAC4 */
373 rdpa_emac5, /**< EMAC5 */
374 rdpa_emac6, /**< EMAC6 */
375 rdpa_emac7, /**< EMAC7 */
376 rdpa_emac__num_of, /* Max number of EMACs */
377 rdpa_emac_none, /**< Indicates virtual port */
378 } rdpa_emac;
379
380 /** EMAC mode */
381 typedef enum
382 {
383 rdpa_emac_mode_sgmii, /**< SGMII */
384 rdpa_emac_mode_hisgmii, /**< HISGMII */
385 rdpa_emac_mode_qsgmii, /**< QSGMII */
386 rdpa_emac_mode_ss_smii, /**< SS SMII */
387 rdpa_emac_mode_rgmii, /**< RGMII */
388 rdpa_emac_mode_mii, /**< MII */
389 rdpa_emac_mode_tmii, /**< TMII */
390
391 rdpa_emac_mode__num_of, /* Number of EMAC modes */
392 } rdpa_emac_mode;
393
394
395 /** EMAC rates */
396 typedef enum
397 {
398 rdpa_emac_rate_10m, /**< 10 Mbps */
399 rdpa_emac_rate_100m, /**< 100 Mbps */
400 rdpa_emac_rate_1g, /**< 1 Gbps */
401 rdpa_emac_rate_2_5g, /**< 2.5 Gbps */
402
403 rdpa_emac_rate__num_of, /* Number of rates */
404 } rdpa_emac_rate;
405
406 /** EMAC configuration */
407 typedef struct
408 {
409 char loopback; /**< 1 = line loopback */
410 rdpa_emac_rate rate; /**< EMAC rate */
411 char generate_crc; /**< 1 = generate CRC */
412 char full_duplex; /**< 1 = full duplex */
413 char pad_short; /**< 1 = pad short frames */
414 char allow_too_long;/**< 1 = allow long frames */
415 char check_length; /**< 1 = check frame length */
416 uint32_t preamble_length; /**< Preamble length */
417 uint32_t back2back_gap; /**< Back2Back inter-packet gap */
418 uint32_t non_back2back_gap; /**< Non Back2Back inter-packet gap */
419 uint32_t min_interframe_gap; /**< Min inter-frame gap */
420 char rx_flow_control;/**< 1 = enable RX flow control */
421 char tx_flow_control;/**< 1 = enable TX flow control */
422 } rdpa_emac_cfg_t;
423
424 /** RX RMON counters.
425 * Underlying type for emac_rx_stat aggregate type.
426 */
427 typedef struct
428 {
429 uint32_t byte; /**< Receive Byte Counter */
430 uint32_t packet; /**< Receive Packet Counter */
431 uint32_t frame_64; /**< Receive 64 Byte Frame Counter */
432 uint32_t frame_65_127; /**< Receive 65 to 127 Byte Frame Counter */
433 uint32_t frame_128_255; /**< Receive 128 to 255 Byte Frame Counter */
434 uint32_t frame_256_511; /**< Receive 256 to 511 Byte Frame Counter */
435 uint32_t frame_512_1023; /**< Receive 512 to 1023 Byte Frame Counter */
436 uint32_t frame_1024_1518; /**< Receive 1024 to 1518 Byte Frame Counter */
437 uint32_t frame_1519_mtu; /**< Receive 1519 to MTU Frame Counter */
438 uint32_t multicast_packet; /**< Receive Multicast Packet */
439 uint32_t broadcast_packet; /**< Receive Broadcast Packet */
440 uint32_t unicast_packet; /**< Receive Unicast Packet */
441 uint32_t alignment_error; /**< Receive Alignment error */
442 uint32_t frame_length_error;/**< Receive Frame Length Error Counter */
443 uint32_t code_error; /**< Receive Code Error Counter */
444 uint32_t carrier_sense_error;/**< Receive Carrier sense error */
445 uint32_t fcs_error; /**< Receive FCS Error Counter */
446 uint32_t control_frame; /**< Receive Control Frame Counter */
447 uint32_t pause_control_frame;/**< Receive Pause Control Frame */
448 uint32_t unknown_opcode; /**< Receive Unknown opcode */
449 uint32_t undersize_packet; /**< Receive Undersize Packet */
450 uint32_t oversize_packet; /**< Receive Oversize Packet */
451 uint32_t fragments; /**< Receive Fragments */
452 uint32_t jabber; /**< Receive Jabber counter */
453 uint32_t overflow; /**< Receive Overflow counter */
454 } rdpa_emac_rx_stat_t;
455
456 /** Tx RMON counters.
457 * Underlying type for emac_tx_stat aggregate type.
458 */
459 typedef struct
460 {
461 uint32_t byte; /**< Transmit Byte Counter */
462 uint32_t packet; /**< Transmit Packet Counter */
463 uint32_t frame_64; /**< Transmit 64 Byte Frame Counter */
464 uint32_t frame_65_127; /**< Transmit 65 to 127 Byte Frame Counter */
465 uint32_t frame_128_255; /**< Transmit 128 to 255 Byte Frame Counter */
466 uint32_t frame_256_511; /**< Transmit 256 to 511 Byte Frame Counter */
467 uint32_t frame_512_1023; /**< Transmit 512 to 1023 Byte Frame Counter */
468 uint32_t frame_1024_1518; /**< Transmit 1024 to 1518 Byte Frame Counter */
469 uint32_t frame_1519_mtu; /**< Transmit 1519 to MTU Frame Counter */
470 uint32_t fcs_error; /**< Transmit FCS Error */
471 uint32_t multicast_packet; /**< Transmit Multicast Packet */
472 uint32_t broadcast_packet; /**< Transmit Broadcast Packet */
473 uint32_t unicast_packet; /**< Transmit Unicast Packet */
474 uint32_t excessive_collision; /**< Transmit Excessive collision counter */
475 uint32_t late_collision; /**< Transmit Late collision counter */
476 uint32_t single_collision; /**< Transmit Single collision frame counter */
477 uint32_t multiple_collision;/**< Transmit Multiple collision frame counter */
478 uint32_t total_collision; /**< Transmit Total Collision Counter */
479 uint32_t pause_control_frame; /**< Transmit PAUSE Control Frame */
480 uint32_t deferral_packet; /**< Transmit Deferral Packet */
481 uint32_t excessive_deferral_packet; /**< Transmit Excessive Deferral Packet */
482 uint32_t jabber_frame; /**< Transmit Jabber Frame */
483 uint32_t control_frame; /**< Transmit Control Frame */
484 uint32_t oversize_frame; /**< Transmit Oversize Frame counter */
485 uint32_t undersize_frame; /**< Transmit Undersize Frame */
486 uint32_t fragments_frame; /**< Transmit Fragments Frame counter */
487 uint32_t error; /**< Transmission errors*/
488 uint32_t underrun; /**< Transmission underrun */
489 } rdpa_emac_tx_stat_t;
490
491 /** Emac statistics */
492 typedef struct
493 {
494 rdpa_emac_rx_stat_t rx; /**< Emac Receive Statistics */
495 rdpa_emac_tx_stat_t tx; /**< Emac Transmit Statistics */
496 } rdpa_emac_stat_t;
497
498 /** RDPA EMAC mask
499 * A combination of \ref rdpa_emac_id constants.
500 */
501 typedef unsigned int rdpa_emacs;
502
503 /** RDPA emac mask.
504 * \param[in] __emac EMAC
505 * \return EMAC - Mask representation
506 */
507 static inline rdpa_emacs rdpa_emac_id(rdpa_emac __emac)
508 {
509 return 1 << (__emac);
510 }
511
512 /** RDPA port mask
513 * A combination of \ref rdpa_if_id constants.
514 */
515 typedef uint64_t rdpa_ports __attribute__((aligned(8)));
516
517 /** RDPA interface (port) mask.
518 * Can be combined in rdpa_ports mask to specify multiple ports in the same operation.
519 * \param[in] __if Interface
520 * \return Interface - Mask representation
521 */
522 static inline rdpa_ports rdpa_if_id(rdpa_if __if)
523 {
524 return 1LL << (__if);
525 }
526
527 /** All WAN ports */
528 #define RDPA_PORT_ALL_WAN (rdpa_if_id(rdpa_if_wan0) | rdpa_if_id(rdpa_if_wan1) | rdpa_if_id(rdpa_if_wan2))
529
530 /** Check if interface is WAN interface
531 * \param[in] __if Interface
532 * \return 1 WAN, 0 otherwise
533 */
534 static inline int rdpa_if_is_wan(rdpa_if __if)
535 {
536 return (RDPA_PORT_ALL_WAN & rdpa_if_id(__if)) ? 1 : 0;
537 }
538
539 /** Map a given WAN type to the corresponding WAN interface per the platform support.
540 * \param[in] __wan WAN type
541 * \return Interface (rdpa_if_wan0/1/2) or rdpa_if_none if wan_type is not supported on the platform
542 */
543 static inline rdpa_if rdpa_wan_type_to_if(rdpa_wan_type __wan)
544 {
545 #if defined(CONFIG_BCM63146)
546 switch (__wan) {
547 case rdpa_wan_gbe :
548 return (rdpa_if_wan0);
549 case rdpa_wan_dsl :
550 return (rdpa_if_wan1);
551 default :
552 return (rdpa_if_none);
553 }
554 #else /* PON Platforms */
555 switch (__wan) {
556 case rdpa_wan_gpon :
557 case rdpa_wan_xgpon :
558 case rdpa_wan_epon :
559 case rdpa_wan_xepon :
560 return (rdpa_if_wan0);
561 case rdpa_wan_gbe :
562 #ifdef CONFIG_MULTI_WAN_SUPPORT
563 return (rdpa_if_wan1);
564 #else
565 return (rdpa_if_wan0);
566 #endif
567 default :
568 return (rdpa_if_none);
569 }
570 #endif /* PON Platforms */
571 }
572
573 /** All LAN MACs */
574 #ifndef XRDP
575 #define RDPA_PORT_ALL_LOOKUP_PORTS \
576 (rdpa_if_id(rdpa_if_wan0) | rdpa_if_id(rdpa_if_lan0) | rdpa_if_id(rdpa_if_lan1) | rdpa_if_id(rdpa_if_lan2) | \
577 rdpa_if_id(rdpa_if_lan3) | rdpa_if_id(rdpa_if_lan4))
578 #endif
579 /** All LAN MACs */
580 #ifdef G9991
581 #define RDPA_PORT_ALL_LAN_MACS \
582 (rdpa_if_id(rdpa_if_lan0) | rdpa_if_id(rdpa_if_lan1) | rdpa_if_id(rdpa_if_lan2) | \
583 rdpa_if_id(rdpa_if_lan3) | rdpa_if_id(rdpa_if_lan4) | rdpa_if_id(rdpa_if_lan5) | \
584 rdpa_if_id(rdpa_if_lan6) | rdpa_if_id(rdpa_if_lan7) | rdpa_if_id(rdpa_if_lan8) | \
585 rdpa_if_id(rdpa_if_lan9) | rdpa_if_id(rdpa_if_lan10) | rdpa_if_id(rdpa_if_lan11) | \
586 rdpa_if_id(rdpa_if_lan12) | rdpa_if_id(rdpa_if_lan13) | rdpa_if_id(rdpa_if_lan14) | \
587 rdpa_if_id(rdpa_if_lan15) | rdpa_if_id(rdpa_if_lan16) | rdpa_if_id(rdpa_if_lan17) | \
588 rdpa_if_id(rdpa_if_lan18) | rdpa_if_id(rdpa_if_lan19) | rdpa_if_id(rdpa_if_lan20) | \
589 rdpa_if_id(rdpa_if_lan21) | rdpa_if_id(rdpa_if_lan22) | rdpa_if_id(rdpa_if_lan23) | \
590 rdpa_if_id(rdpa_if_lan24) | rdpa_if_id(rdpa_if_lan25) | rdpa_if_id(rdpa_if_lan26) | \
591 rdpa_if_id(rdpa_if_lan27) | rdpa_if_id(rdpa_if_lan28) | rdpa_if_id(rdpa_if_lan29))
592 #elif defined(BCM_DSL_RDP) || defined(BCM_DSL_XRDP)
593 #define RDPA_PORT_ALL_LAN_MACS \
594 (rdpa_if_id(rdpa_if_lan0) | rdpa_if_id(rdpa_if_lan1) | rdpa_if_id(rdpa_if_lan2) | \
595 rdpa_if_id(rdpa_if_lan3) | rdpa_if_id(rdpa_if_lan4) | rdpa_if_id(rdpa_if_lan5) | \
596 rdpa_if_id(rdpa_if_lan6) | rdpa_if_id(rdpa_if_lan7))
597 #else
598 #define RDPA_PORT_ALL_LAN_MACS \
599 (rdpa_if_id(rdpa_if_lan0) | rdpa_if_id(rdpa_if_lan1) | rdpa_if_id(rdpa_if_lan2) | \
600 rdpa_if_id(rdpa_if_lan3) | rdpa_if_id(rdpa_if_lan4) | rdpa_if_id(rdpa_if_lan5) | \
601 rdpa_if_id(rdpa_if_lan6) | rdpa_if_id(rdpa_if_lan7) | rdpa_if_id(rdpa_if_lan8) | \
602 rdpa_if_id(rdpa_if_lan9) | rdpa_if_id(rdpa_if_lan10) | rdpa_if_id(rdpa_if_lan11) | \
603 rdpa_if_id(rdpa_if_lan12) | rdpa_if_id(rdpa_if_lan13) | rdpa_if_id(rdpa_if_lan14) | \
604 rdpa_if_id(rdpa_if_lan15) | rdpa_if_id(rdpa_if_lan16) | rdpa_if_id(rdpa_if_lan17) | \
605 rdpa_if_id(rdpa_if_lan18) | rdpa_if_id(rdpa_if_lan19) | rdpa_if_id(rdpa_if_lan20) | \
606 rdpa_if_id(rdpa_if_lan21))
607 #endif
608
609 /** All physical ports */
610 #define RDPA_PORT_LAG_AND_SWITCH_PORTS \
611 (rdpa_if_id(rdpa_if_lag0) | rdpa_if_id(rdpa_if_lag1) | rdpa_if_id(rdpa_if_lag2) | \
612 rdpa_if_id(rdpa_if_lag3) | rdpa_if_id(rdpa_if_lag4) | rdpa_if_id(rdpa_if_switch))
613
614 /** All EMACs */
615 #ifndef XRDP
616 #define RDPA_PORT_ALL_EMACS \
617 (rdpa_emac_id(rdpa_emac0) | rdpa_emac_id(rdpa_emac1) | rdpa_emac_id(rdpa_emac2) | \
618 rdpa_emac_id(rdpa_emac3) | rdpa_emac_id(rdpa_emac4) | rdpa_emac_id(rdpa_emac5))
619 #else
620 #define RDPA_PORT_ALL_EMACS \
621 (rdpa_emac_id(rdpa_emac0) | rdpa_emac_id(rdpa_emac1) | rdpa_emac_id(rdpa_emac2) | \
622 rdpa_emac_id(rdpa_emac3) | rdpa_emac_id(rdpa_emac4) | rdpa_emac_id(rdpa_emac5) |\
623 rdpa_emac_id(rdpa_emac6))
624 #endif
625
626 /** All LAN ports */
627 #define RDPA_PORT_ALL_LAN (RDPA_PORT_ALL_LAN_MACS)
628 /** All LAN ports and physical */
629 #define RDPA_PORT_ALL_LAN_AND_LAG (RDPA_PORT_ALL_LAN_MACS | RDPA_PORT_LAG_AND_SWITCH_PORTS)
630
631 /** Check if interface is LAN interface (LAN EMAC port or LAN switch port, not including Wi-Fi ports)
632 * \param[in] __if Interface
633 * \return 1 LAN (port or switch), 0 otherwise
634 */
635 static inline int rdpa_if_is_lan(rdpa_if __if)
636 {
637 return (RDPA_PORT_ALL_LAN & rdpa_if_id(__if)) ? 1 : 0;
638 }
639
640 /** Check if interface is LAN interface (LAN EMAC port, not including WiFi ports)
641 * \param[in] __if Interface
642 * \return 1 LAN , 0 otherwise
643 */
644 static inline int rdpa_if_is_lan_mac(rdpa_if __if)
645 {
646 return (RDPA_PORT_ALL_LAN_MACS & rdpa_if_id(__if)) ? 1 : 0;
647 }
648
649 /** Check if interface is LAN interface (LAN EMAC port or physical port)
650 * \param[in] __if Interface
651 * \return 1 LAN (port or phisical), 0 otherwise
652 */
653 static inline int rdpa_if_is_lan_lag_and_switch(rdpa_if __if)
654 {
655 return (RDPA_PORT_ALL_LAN_AND_LAG & rdpa_if_id(__if)) ? 1 : 0;
656 }
657
658
659 /** Check if interface is LAG interface (physical port)
660 * \param[in] __if Interface
661 * \return 1 LAN (port or phisical), 0 otherwise
662 */
663 static inline int rdpa_if_is_lag_and_switch(rdpa_if __if)
664 {
665 return (RDPA_PORT_LAG_AND_SWITCH_PORTS & rdpa_if_id(__if)) ? 1 : 0;
666 }
667
668 /** All WLAN ports */
669 #ifdef XRDP
670 #define RDPA_PORT_ALL_WLAN \
671 (rdpa_if_id(rdpa_if_wlan0) | rdpa_if_id(rdpa_if_wlan1) | rdpa_if_id(rdpa_if_wlan2))
672 #else
673 #define RDPA_PORT_ALL_WLAN \
674 (rdpa_if_id(rdpa_if_wlan0) | rdpa_if_id(rdpa_if_wlan1))
675 #endif
676
677 /** Check if interface is WLAN (PCI port)
678 * \param[in] __if Interface
679 * \return 1 if WLAN port, 0 otherwise
680 */
681 static inline int rdpa_if_is_wlan(rdpa_if __if)
682 {
683 return (RDPA_PORT_ALL_WLAN & rdpa_if_id(__if)) ? 1 : 0;
684 }
685
686 #if defined(CONFIG_BCM_PON_XRDP) || defined(BCM_DSL_XRDP)
687 #define WL_NUM_OF_SSID_PER_UNIT 16
688 #else
689 #define WL_NUM_OF_SSID_PER_UNIT 8
690 #endif /* CONFIG_BCM_PON */
691
692 /** All Bond ports */
693 #define RDPA_PORT_ALL_BOND \
694 (rdpa_if_id(rdpa_if_bond0) | rdpa_if_id(rdpa_if_bond1) | rdpa_if_id(rdpa_if_bond2))
695
696 /** Check if interface is Bonded
697 * \param[in] __if Interface
698 * \return 1 if Bond port, 0 otherwise
699 */
700 static inline int rdpa_if_is_bond(rdpa_if __if)
701 {
702 return (RDPA_PORT_ALL_BOND & rdpa_if_id(__if)) ? 1 : 0;
703 }
704
705
706 #ifndef XRDP
707 /** All WiFi virtual interfaces */
708 #define RDPA_PORT_ALL_SSIDS \
709 (rdpa_if_id(rdpa_if_ssid0) | rdpa_if_id(rdpa_if_ssid1) | rdpa_if_id(rdpa_if_ssid2) | rdpa_if_id(rdpa_if_ssid3) | \
710 rdpa_if_id(rdpa_if_ssid4) | rdpa_if_id(rdpa_if_ssid5) | rdpa_if_id(rdpa_if_ssid6) | rdpa_if_id(rdpa_if_ssid7) | \
711 rdpa_if_id(rdpa_if_ssid8) | rdpa_if_id(rdpa_if_ssid9) | rdpa_if_id(rdpa_if_ssid10) | rdpa_if_id(rdpa_if_ssid11) | \
712 rdpa_if_id(rdpa_if_ssid12) | rdpa_if_id(rdpa_if_ssid13) | rdpa_if_id(rdpa_if_ssid14) | rdpa_if_id(rdpa_if_ssid15))
713
714 /** Check if interface is Wi-Fi SSID
715 * \param[in] __if Interface
716 * \return 1 Wi-Fi SSID, 0 otherwise
717 */
718 static inline int rdpa_if_is_wifi(rdpa_if __if)
719 {
720 return (RDPA_PORT_ALL_SSIDS & rdpa_if_id(__if)) ? 1 : 0;
721 }
722 #else
723 static inline int rdpa_if_is_wifi(rdpa_if __if)
724 {
725 return rdpa_if_is_wlan(__if);
726 }
727 #endif
728
729 static inline int rdpa_if_is_cpu_port(rdpa_if __if)
730 {
731 return __if >= rdpa_if_cpu_first && __if <= rdpa_if_cpu_last;
732 }
733
734 /** Check if interface is either LAN interface (LAN EMAC port or LAN switch port) or Wi-Fi SSID
735 * \param[in] __if Interface
736 * \return 1 LAN interface or Wi-Fi SSID, 0 otherwise
737 */
738 static inline int rdpa_if_is_lan_or_wifi(rdpa_if __if)
739 {
740 return rdpa_if_is_lan(__if) || rdpa_if_is_wifi(__if);
741 }
742
743 /** Check if interface is either LAN interface (LAN EMAC port or LAN switch port) or WLAN (PCI port)
744 * \param[in] __if Interface
745 * \return 1 LAN interface or WLAN, 0 otherwise
746 */
747 static inline int rdpa_if_is_lan_or_cpu(rdpa_if __if)
748 {
749 return rdpa_if_is_lan(__if) || rdpa_if_is_cpu_port(__if);
750 }
751
752 /** Check if interface is CPU and not WLAN (PCI port)
753 * \param[in] __if Interface
754 * \return 1 if pure CPU, 0 otherwise
755 */
756 static inline int rdpa_if_is_cpu_not_wlan(rdpa_if __if)
757 {
758 return rdpa_if_is_cpu_port(__if) && (!rdpa_if_is_wlan(__if));
759 }
760
761
762 /** All MACs */
763 #define RDPA_PORT_ALL_MACS (RDPA_PORT_ALL_LAN_MACS | RDPA_PORT_ALL_WAN)
764
765 /** Check if port mask contains single port
766 * \param[in] ports Port Mask
767 * \return 1 if mask contains a single port , 0 otherwise
768 */
769 static inline int rdpa_port_is_single(rdpa_ports ports)
770 {
771 return (ports & (ports - 1)) == 0;
772 }
773
774 /** Check if port mask contains wan0 port
775 * \param[in] ports Port Mask
776 * \return 1 if mask contains a wan0 port , 0 otherwise
777 */
778 static inline int rdpa_ports_contains_wan0_if(rdpa_ports ports)
779 {
780 return ports & rdpa_if_id(rdpa_if_wan0); /* FIXME - MULTI-WAN XPON */
781 }
782
783 /** System operation mode */
784 typedef enum
785 {
786 rdpa_method_prv, /**< Used to configure system in Provision mode */
787 rdpa_method_fc, /**< Used to configure system in Flow Cache mode */
788 } rdpa_operation_mode;
789
790 /** IPTV entries lookup method */
791 typedef enum
792 {
793 iptv_lookup_method_mac, /**< Perform IPTV entry lookup by MAC address (L2) */
794 iptv_lookup_method_mac_vid, /**< Perform IPTV entry lookup by MAC address and VID (L2) */
795 iptv_lookup_method_group_ip, /**< Perform IPTV entry lookup by Multicast Group IP address (IGMPv2/MLDv1) */
796 iptv_lookup_method_group_ip_src_ip, /**< Perform IPTV entry lookup by Multicast Group IP and Source IP
797 addresses (IGMPv3/MLDv2). Source IP address is optional. */
798 iptv_lookup_method_group_ip_src_ip_vid /**< Perform IPTV entry lookup by Multicast Group IP and Source IP
799 addresses and VID. Source IP address is optional. */
800 } rdpa_iptv_lookup_method;
801
802 /** EPON mode */
803 typedef enum
804 {
805 rdpa_epon_none, /**< not EPON mode */
806 rdpa_epon_ctc, /**< CTC OAM mode */
807 rdpa_epon_cuc, /**< CUC OAM mode */
808 rdpa_epon_dpoe, /**< DPOE OAM mode */
809 rdpa_epon_bcm, /**< BCM OAM mode */
810 rdpa_epon_ctc_dyn, /**< CTC OAM dynamic mode */
811 rdpa_epon_cuc_dyn, /**< CUC OAM dynamic mode */
812 rdpa_epon_last,
813 } rdpa_epon_mode;
814
815 /** Packet offset type */
816 typedef enum
817 {
818 RDPA_OFFSET_L2, /**< Offset of L2 header */
819 RDPA_OFFSET_L3, /**< Offset of L3 header */
820 RDPA_OFFSET_L4, /**< Offset of L4 header */
821 } rdpa_offset_t;
822
823 /* BPM buffer size */
824 typedef enum
825 {
826 RDPA_BPM_BUFFER_2K = 2048,
827 RDPA_BPM_BUFFER_2_5K = 2560,
828 RDPA_BPM_BUFFER_4K = 4096,
829 RDPA_BPM_BUFFER_16K = 16384,
830 } rdpa_bpm_buffer_size_t;
831
832 /** WiFi Acceleration type */
833 typedef enum
834 {
835 RDPA_WL_ACCEL_NONE = 0, /**< Acceleration disabled */
836 RDPA_WL_ACCEL_WFD, /**< WFD Acceleration type */
837 RDPA_WL_ACCEL_DHD_OFFLOAD /**< DHD Offload Acceleration type */
838 } rdpa_wl_accel_t;
839
840 /** CPU ring type */
841 typedef enum {
842 rdpa_ring_data = 0, /**< Data ring */
843 rdpa_ring_recycle = 1, /**< Recycle ring */
844 rdpa_ring_feed = 2, /**< Feed ring */
845 rdpa_ring_cpu_tx = 3, /**< Cpu tx PD ring */
846 } rdpa_ring_type_t;
847
848 typedef enum {
849 rdpa_proto_filter_ipv4,
850 rdpa_proto_filter_ipv6,
851 rdpa_proto_filter_pppoe,
852 rdpa_proto_filter_non_ip,
853 rdpa_proto_filter_any,
854 rdpa_proto_filter_last = rdpa_proto_filter_any,
855 } rdpa_proto_filter_t;
856
857 /** Protocol Filters mask, defines allowed protocols */
858 typedef enum {
859 rdpa_proto_filter_ipv4_mask = (1 << rdpa_proto_filter_ipv4), /**< Allow IPv4 traffic */
860 rdpa_proto_filter_ipv6_mask = (1 << rdpa_proto_filter_ipv6), /**< Allow IPv6 traffic */
861 rdpa_proto_filter_pppoe_mask = (1 << rdpa_proto_filter_pppoe), /**< Allow PPPoE traffic */
862 rdpa_proto_filter_non_ip_mask = (1 << rdpa_proto_filter_non_ip), /**< Allow Non-IP traffic */
863 rdpa_proto_filter_any_mask = (1 << rdpa_proto_filter_any), /**< Allow any traffic */
864 } rdpa_proto_filter_fields;
865
866 typedef uint32_t rdpa_proto_filters_mask_t; /**< Mask of \ref rdpa_proto_filter_fields (enabled protocols) */
867
868 /** @} end of types Doxygen group */
869
870 typedef struct
871 {
872 int src;
873 int dest;
874 } int2int_map_t;
875
876 static inline int int2int_map(int2int_map_t *map, int src, int last)
877 {
878 for (; map->src != last && map->src != src; map++)
879 ;
880 return map->dest;
881 }
882
883 static inline int int2int_map_r(int2int_map_t *map, int src, int last)
884 {
885 for (; map->src != last && map->dest != src; map++)
886 ;
887 return map->src;
888 }
889
890 typedef enum
891 {
892 RDPA_FLOW_UNKNOWN,
893 RDPA_FLOW_TUPLE_L3,
894 RDPA_FLOW_TUPLE_L2,
895 RDPA_FLOW_MC,
896 } rdpa_flow_t;
897
898 #endif /* _RDPA_TYPES_H_ */
899