blob: 66291652dda8fc51baf8b342208a03684f83826f [file] [log] [blame]
developer69bcd592024-03-25 14:26:39 +08001/* FILE NAME: air_vlan.c
2 * PURPOSE:
3 * Define the VLAN function in AIR SDK.
4 * NOTES:
5 */
6
7/* INCLUDE FILE DECLARATIONS
8 */
9#include "air.h"
10
11/* NAMING CONSTANT DECLARATIONS
12 */
13
14/* MACRO FUNCTION DECLARATIONS
15 */
16
17/* DATA TYPE DECLARATIONS
18 */
19
20/* GLOBAL VARIABLE DECLARATIONS
21 */
22
23/* LOCAL SUBPROGRAM DECLARATIONS
24 */
25
26/* STATIC VARIABLE DECLARATIONS
27 */
28
29/* EXPORTED SUBPROGRAM BODIES
30 */
31
32/* LOCAL SUBPROGRAM BODIES
33*/
34void
35_air_vlan_readEntry(
36 const UI32_T unit,
37 const UI16_T vid,
38 AIR_VLAN_ENTRY_T* vlan_entry)
39{
40 UI32_T val = 0;
41 val = (0x80000000 + vid); //r_vid_cmd
42 aml_writeReg(unit, VTCR, val);
43
44 for (;;)
45 {
46 aml_readReg(unit, VTCR, &val);
47 if ((val & 0x80000000) == 0)
48 break;
49 AIR_UDELAY(10);
50 }
51
52 aml_readReg(unit, VLNRDATA0, &(vlan_entry->vlan_table.vlan_table0));
53 aml_readReg(unit, VLNRDATA1, &(vlan_entry->vlan_table.vlan_table1));
54}
55
56void
57_air_vlan_writeEntry(
58 const UI32_T unit,
59 const UI16_T vid,
60 AIR_VLAN_ENTRY_T* vlan_entry)
61{
62 UI32_T val = 0;
63
64 aml_writeReg(unit, VLNWDATA0, vlan_entry->vlan_table.vlan_table0);
65 aml_writeReg(unit, VLNWDATA1, vlan_entry->vlan_table.vlan_table1);
66 aml_writeReg(unit, VLNWDATA2, 0);
67 aml_writeReg(unit, VLNWDATA3, 0);
68 aml_writeReg(unit, VLNWDATA4, 0);
69
70 val = (0x80001000 + vid); //w_vid_cmd
71 aml_writeReg(unit, VTCR, val);
72
73 for (;;)
74 {
75 aml_readReg(unit, VTCR, &val);
76 if ((val & 0x80000000) == 0)
77 break;
78 AIR_UDELAY(10);
79 }
80}
81
82void
83_air_untagged_vlan_readEntry(
84 const UI32_T unit,
85 const UI16_T vid,
86 AIR_VLAN_ENTRY_ATTR_T* vlan_entry)
87{
88 UI32_T val = 0;
89 val = (0x80000000 + vid); //r_vid_cmd
90 aml_writeReg(unit, VTCR, val);
91
92 for (;;)
93 {
94 aml_readReg(unit, VTCR, &val);
95 if ((val & 0x80000000) == 0)
96 break;
97 AIR_UDELAY(10);
98 }
99
100 aml_readReg(unit, VLNRDATA0, &(vlan_entry->vlan_table.vlan_table0));
101 aml_readReg(unit, VLNRDATA1, &(vlan_entry->vlan_table.vlan_table1));
102 aml_readReg(unit, VLNRDATA2, &(vlan_entry->vlan_table.vlan_table2));
103 aml_readReg(unit, VLNRDATA3, &(vlan_entry->vlan_table.vlan_table3));
104 aml_readReg(unit, VLNRDATA4, &(vlan_entry->vlan_table.vlan_table4));
105}
106
107void
108_air_untagged_vlan_writeEntry(
109 const UI32_T unit,
110 const UI16_T vid,
111 AIR_VLAN_ENTRY_ATTR_T* vlan_entry)
112{
113 UI32_T val = 0;
114
115 aml_writeReg(unit, VLNWDATA0, vlan_entry->vlan_table.vlan_table0);
116 aml_writeReg(unit, VLNWDATA1, vlan_entry->vlan_table.vlan_table1);
117 aml_writeReg(unit, VLNWDATA2, vlan_entry->vlan_table.vlan_table2);
118 aml_writeReg(unit, VLNWDATA3, vlan_entry->vlan_table.vlan_table3);
119 aml_writeReg(unit, VLNWDATA4, vlan_entry->vlan_table.vlan_table4);
120
121 val = (0x80001000 + vid); //w_vid_cmd
122 aml_writeReg(unit, VTCR, val);
123
124 for (;;)
125 {
126 aml_readReg(unit, VTCR, &val);
127 if ((val & 0x80000000) == 0)
128 break;
129 AIR_UDELAY(10);
130 }
131}
132
133/* FUNCTION NAME: air_vlan_create
134 * PURPOSE:
135 * Create the vlan in the specified device.
136 * INPUT:
137 * unit -- unit id
138 * vid -- vlan id
139 * p_attr -- vlan attr
140 * OUTPUT:
141 * None
142 * RETURN:
143 * AIR_E_OK -- Successfully read the data.
144 * AIR_E_OTHERS -- Vlan creation failed.
145 * AIR_E_BAD_PARAMETER -- Invalid parameter.
146 * NOTES:
147 * none
148 */
149AIR_ERROR_NO_T
150air_vlan_create(
151 const UI32_T unit,
152 const UI16_T vid,
153 AIR_VLAN_ENTRY_ATTR_T *p_attr)
154{
155 AIR_VLAN_ENTRY_T vlan_entry = {0};
156
157 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
158
159 _air_vlan_readEntry(unit, vid, &vlan_entry);
160 if (vlan_entry.valid)
161 return AIR_E_ENTRY_EXISTS;
162
163 if (NULL != p_attr)
164 {
165 p_attr->valid = 1;
166 _air_untagged_vlan_writeEntry(unit, vid, p_attr);
167 }
168 else
169 {
170 memset(&vlan_entry, 0, sizeof(vlan_entry));
171 vlan_entry.valid = 1;
172 _air_untagged_vlan_writeEntry(unit, vid, &vlan_entry);
173 }
174
175 return AIR_E_OK;
176}
177
178/* FUNCTION NAME: air_vlan_destroy
179 * PURPOSE:
180 * Destroy the vlan in the specified device.
181 * INPUT:
182 * unit -- unit id
183 * vid -- vlan id
184 * OUTPUT:
185 * None
186 * RETURN:
187 * AIR_E_OK -- Successfully read the data.
188 * AIR_E_OTHERS -- Vlan destroy failed.
189 * NOTES:
190 * none
191 */
192AIR_ERROR_NO_T
193air_vlan_destroy(
194 const UI32_T unit,
195 const UI16_T vid)
196{
197 AIR_VLAN_ENTRY_T vlan_entry = {0};
198
199 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
200
201 _air_vlan_writeEntry(unit, vid, &vlan_entry);
202
203 return AIR_E_OK;
204}
205
206/* FUNCTION NAME: air_vlan_destroyAll
207 * PURPOSE:
208 * Destroy the vlan in the specified device.
209 * INPUT:
210 * unit -- unit id
211 * vid -- vlan id
212 * OUTPUT:
213 * None
214 * RETURN:
215 * AIR_E_OK -- Successfully read the data.
216 * AIR_E_OTHERS -- Vlan destroy failed.
217 * NOTES:
218 * none
219 */
220AIR_ERROR_NO_T
221air_vlan_destroyAll(
222 const UI32_T unit,
223 const UI32_T keep_and_restore_default_vlan)
224{
225 UI16_T vid = 0;
226
227 for (vid = AIR_VLAN_ID_MIN; vid <= AIR_VLAN_ID_MAX; vid++)
228 {
229 if (keep_and_restore_default_vlan)
230 {
231 air_vlan_reset(unit, vid);
232 }
233 else
234 {
235 air_vlan_destroy(unit, vid);
236 }
237 }
238
239 return AIR_E_OK;
240}
241
242/* FUNCTION NAME: air_vlan_reset
243 * PURPOSE:
244 * Destroy the vlan in the specified device.
245 * INPUT:
246 * unit -- unit id
247 * vid -- vlan id
248 * OUTPUT:
249 * None
250 * RETURN:
251 * AIR_E_OK -- Successfully reset the data.
252 * AIR_E_OTHERS -- Vlan reset failed.
253 * NOTES:
254 * none
255 */
256AIR_ERROR_NO_T
257air_vlan_reset(
258 const UI32_T unit,
259 const UI16_T vid)
260{
261 AIR_VLAN_ENTRY_T vlan_entry = {0};
262
263 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
264
265 vlan_entry.vlan_entry_format.port_mem = AIR_ALL_PORT_BITMAP;
266 vlan_entry.valid = TRUE;
267
268 _air_vlan_writeEntry(unit, vid, &vlan_entry);
269
270 return AIR_E_OK;
271}
272
273/* FUNCTION NAME: air_vlan_setFid
274 * PURPOSE:
275 * Set the filter id of the vlan to the specified device.
276 * INPUT:
277 * unit -- unit id
278 * vid -- vlan id
279 * fid -- filter id
280 * OUTPUT:
281 * None
282 * RETURN:
283 * AIR_E_OK -- Successfully read the data.
284 * AIR_E_OTHERS -- Operation failed.
285 * AIR_E_BAD_PARAMETER -- Invalid parameter.
286 * NOTES:
287 * none
288 */
289AIR_ERROR_NO_T
290air_vlan_setFid(
291 const UI32_T unit,
292 const UI16_T vid,
293 const UI8_T fid)
294{
295 AIR_VLAN_ENTRY_T vlan_entry = {0};
296
297 /* VID check */
298 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
299 AIR_PARAM_CHK((fid > AIR_FILTER_ID_MAX), AIR_E_BAD_PARAMETER);
300
301 _air_vlan_readEntry(unit, vid, &vlan_entry);
302 if (!vlan_entry.valid)
303 return AIR_E_ENTRY_NOT_FOUND;
304
305 vlan_entry.vlan_entry_format.fid = fid;
306 _air_vlan_writeEntry(unit, vid, &vlan_entry);
307
308 return AIR_E_OK;
309}
310
311/* FUNCTION NAME: air_vlan_getFid
312 * PURPOSE:
313 * Get the filter id of the vlan from the specified device.
314 * INPUT:
315 * unit -- unit id
316 * vid -- vlan id to be created
317 * OUTPUT:
318 * ptr_fid -- filter id
319 * RETURN:
320 * AIR_E_OK -- Successfully read the data.
321 * AIR_E_OTHERS -- Operation failed.
322 * AIR_E_BAD_PARAMETER -- Invalid parameter.
323 * NOTES:
324 * none
325 */
326AIR_ERROR_NO_T
327air_vlan_getFid(
328 const UI32_T unit,
329 const UI16_T vid,
330 UI8_T *ptr_fid)
331{
332 AIR_VLAN_ENTRY_T vlan_entry = {0};
333
334 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
335 AIR_CHECK_PTR(ptr_fid);
336
337 _air_vlan_readEntry(unit, vid, &vlan_entry);
338 if (!vlan_entry.valid)
339 return AIR_E_ENTRY_NOT_FOUND;
340
341 *ptr_fid = vlan_entry.vlan_entry_format.fid;
342
343 return AIR_E_OK;
344}
345
346/* FUNCTION NAME: air_vlan_addMemberPort
347 * PURPOSE:
348 * Add one vlan member to the specified device.
349 * INPUT:
350 * unit -- unit id
351 * vid -- vlan id
352 * port -- port id
353 * OUTPUT:
354 * None
355 * RETURN:
356 * AIR_E_OK -- Successfully read the data.
357 * AIR_E_OTHERS -- Operation failed.
358 * AIR_E_BAD_PARAMETER -- Invalid parameter.
359 * NOTES:
360 * none
361 */
362AIR_ERROR_NO_T
363air_vlan_addMemberPort(
364 const UI32_T unit,
365 const UI16_T vid,
366 const UI32_T port)
367{
368 AIR_VLAN_ENTRY_T vlan_entry = {0};
369
370 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
371 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
372
373 _air_vlan_readEntry(unit, vid, &vlan_entry);
374 if (!vlan_entry.valid)
375 return AIR_E_ENTRY_NOT_FOUND;
376
377 vlan_entry.vlan_entry_format.port_mem |= 1 << port;
378 _air_vlan_writeEntry(unit, vid, &vlan_entry);
379
380 return AIR_E_OK;
381}
382
383/* FUNCTION NAME: air_vlan_delMemberPort
384 * PURPOSE:
385 * Delete one vlan member from the specified device.
386 * INPUT:
387 * unit -- unit id
388 * vid -- vlan id
389 * port -- port id
390 * OUTPUT:
391 * None
392 * RETURN:
393 * AIR_E_OK -- Successfully read the data.
394 * AIR_E_OTHERS -- Operation failed.
395 * AIR_E_BAD_PARAMETER -- Invalid parameter.
396 * NOTES:
397 * none
398 */
399AIR_ERROR_NO_T
400air_vlan_delMemberPort(
401 const UI32_T unit,
402 const UI16_T vid,
403 const UI32_T port)
404{
405 AIR_VLAN_ENTRY_T vlan_entry = {0};
406
407 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
408 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
409
410 _air_vlan_readEntry(unit, vid, &vlan_entry);
411 if (!vlan_entry.valid)
412 return AIR_E_ENTRY_NOT_FOUND;
413
414 vlan_entry.vlan_entry_format.port_mem &= ~(1 << port);
415 _air_vlan_writeEntry(unit, vid, &vlan_entry);
416
417 return AIR_E_OK;
418}
419
420/* FUNCTION NAME: air_vlan_setMemberPort
421 * PURPOSE:
422 * Replace the vlan members in the specified device.
423 * INPUT:
424 * unit -- unit id
425 * vid -- vlan id
426 * port_bitmap -- member port bitmap
427 * OUTPUT:
428 * None
429 * RETURN:
430 * AIR_E_OK -- Successfully read the data.
431 * AIR_E_OTHERS -- Operation failed.
432 * AIR_E_BAD_PARAMETER -- Invalid parameter.
433 * NOTES:
434 * none
435 */
436AIR_ERROR_NO_T
437air_vlan_setMemberPort(
438 const UI32_T unit,
439 const UI16_T vid,
440 const UI32_T port_bitmap)
441{
442 AIR_VLAN_ENTRY_T vlan_entry = {0};
443
444 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
445 AIR_PARAM_CHK((port_bitmap & (~AIR_ALL_PORT_BITMAP)), AIR_E_BAD_PARAMETER);
446
447 _air_vlan_readEntry(unit, vid, &vlan_entry);
448 if (!vlan_entry.valid)
449 return AIR_E_ENTRY_NOT_FOUND;
450
451 vlan_entry.vlan_entry_format.port_mem = port_bitmap;
452 _air_vlan_writeEntry(unit, vid, &vlan_entry);
453
454 return AIR_E_OK;
455}
456
457/* FUNCTION NAME: air_vlan_getMemberPort
458 * PURPOSE:
459 * Get the vlan members from the specified device.
460 * INPUT:
461 * unit -- unit id
462 * vid -- vlan id
463 * OUTPUT:
464 * port_bitmap -- member port bitmap
465 * RETURN:
466 * AIR_E_OK -- Successfully read the data.
467 * AIR_E_OTHERS -- Operation failed.
468 * AIR_E_BAD_PARAMETER -- Invalid parameter.
469 * NOTES:
470 * none
471 */
472AIR_ERROR_NO_T
473air_vlan_getMemberPort(
474 const UI32_T unit,
475 const UI16_T vid,
476 UI32_T *ptr_port_bitmap)
477{
478 AIR_VLAN_ENTRY_T vlan_entry = {0};
479
480 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
481 AIR_CHECK_PTR(ptr_port_bitmap);
482
483 _air_vlan_readEntry(unit, vid, &vlan_entry);
484 if (!vlan_entry.valid)
485 return AIR_E_ENTRY_NOT_FOUND;
486
487 *ptr_port_bitmap = vlan_entry.vlan_entry_format.port_mem;
488
489 return AIR_E_OK;
490}
491
492/* FUNCTION NAME: air_vlan_setIVL
493 * PURPOSE:
494 * Set L2 lookup mode IVL/SVL for L2 traffic.
495 * INPUT:
496 * unit -- unit id
497 * vid -- vlan id
498 * enable -- enable IVL
499 * OUTPUT:
500 * None
501 * RETURN:
502 * AIR_E_OK -- Successfully read the data.
503 * AIR_E_OTHERS -- Operation failed.
504 * AIR_E_BAD_PARAMETER -- Invalid parameter.
505 * NOTES:
506 * none
507 */
508AIR_ERROR_NO_T
509air_vlan_setIVL(
510 const UI32_T unit,
511 const UI16_T vid,
512 const BOOL_T enable)
513{
514 AIR_VLAN_ENTRY_T vlan_entry = {0};
515
516 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
517
518 _air_vlan_readEntry(unit, vid, &vlan_entry);
519 if (!vlan_entry.valid)
520 return AIR_E_ENTRY_NOT_FOUND;
521
522 vlan_entry.vlan_entry_format.ivl = enable ? 1 : 0;
523 _air_vlan_writeEntry(unit, vid, &vlan_entry);
524
525 return AIR_E_OK;
526}
527
528/* FUNCTION NAME: air_vlan_getIVL
529 * PURPOSE:
530 * Get L2 lookup mode IVL/SVL for L2 traffic.
531 * INPUT:
532 * unit -- unit id
533 * vid -- vlan id
534 * OUTPUT:
535 * ptr_enable -- enable IVL
536 * RETURN:
537 * AIR_E_OK -- Successfully read the data.
538 * AIR_E_OTHERS -- Operation failed.
539 * AIR_E_BAD_PARAMETER -- Invalid parameter.
540 * NOTES:
541 * none
542 */
543AIR_ERROR_NO_T
544air_vlan_getIVL(
545 const UI32_T unit,
546 const UI16_T vid,
547 BOOL_T *ptr_enable)
548{
549 AIR_VLAN_ENTRY_T vlan_entry = {0};
550
551 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
552 AIR_CHECK_PTR(ptr_enable);
553
554 _air_vlan_readEntry(unit, vid, &vlan_entry);
555 if (!vlan_entry.valid)
556 return AIR_E_ENTRY_NOT_FOUND;
557
558 *ptr_enable = vlan_entry.vlan_entry_format.ivl;
559
560 return AIR_E_OK;
561}
562
563/* FUNCTION NAME: air_vlan_setPortAcceptFrameType
564 * PURPOSE:
565 * Set vlan accept frame type of the port from the specified device.
566 * INPUT:
567 * unit -- unit id
568 * port -- port id
569 * type -- accept frame type
570 * OUTPUT:
571 * None
572 * RETURN:
573 * AIR_E_OK -- Successfully read the data.
574 * AIR_E_OTHERS -- Operation failed.
575 * AIR_E_BAD_PARAMETER -- Invalid parameter.
576 * NOTES:
577 * none
578 */
579AIR_ERROR_NO_T
580air_vlan_setPortAcceptFrameType(
581 const UI32_T unit,
582 const UI32_T port,
583 const AIR_VLAN_ACCEPT_FRAME_TYPE_T type)
584{
585 AIR_ERROR_NO_T rc = AIR_E_OK;
586 UI32_T val = 0;
587
588 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
589 AIR_PARAM_CHK((type >= AIR_VLAN_ACCEPT_FRAME_TYPE_LAST), AIR_E_BAD_PARAMETER);
590
591 aml_readReg(unit, PVC(port), &val);
592 val &= ~PVC_ACC_FRM_MASK;
593 val |= (type & PVC_ACC_FRM_RELMASK) << PVC_ACC_FRM_OFFT;
594 aml_writeReg(unit, PVC(port), val);
595
596 return rc;
597}
598
599/* FUNCTION NAME: air_vlan_getPortAcceptFrameType
600 * PURPOSE:
601 * Get vlan accept frame type of the port from the specified device.
602 * INPUT:
603 * unit -- unit id
604 * port -- port id
605 * OUTPUT:
606 * ptr_type -- accept frame type
607 * RETURN:
608 * AIR_E_OK -- Successfully read the data.
609 * AIR_E_OTHERS -- Operation failed.
610 * AIR_E_BAD_PARAMETER -- Invalid parameter.
611 * NOTES:
612 * none
613 */
614AIR_ERROR_NO_T
615air_vlan_getPortAcceptFrameType(
616 const UI32_T unit,
617 const UI32_T port,
618 AIR_VLAN_ACCEPT_FRAME_TYPE_T *ptr_type)
619{
620 AIR_ERROR_NO_T rc = AIR_E_OK;
621 UI32_T val = 0;
622
623 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
624 AIR_CHECK_PTR(ptr_type);
625
626 aml_readReg(unit, PVC(port), &val);
627 *ptr_type = (val >> PVC_ACC_FRM_OFFT) & PVC_ACC_FRM_RELMASK;
628
629 return rc;
630}
631
632/* FUNCTION NAME: air_vlan_setPortLeakyVlanEnable
633 * PURPOSE:
634 * Set leaky vlan enable of the port from the specified device.
635 * INPUT:
636 * unit -- unit id
637 * port -- port id
638 * pkt_type -- packet type
639 * enable -- enable leaky
640 * OUTPUT:
641 * None
642 * RETURN:
643 * AIR_E_OK -- Successfully read the data.
644 * AIR_E_OTHERS -- Operation failed.
645 * AIR_E_BAD_PARAMETER -- Invalid parameter.
646 * NOTES:
647 * none
648 */
649AIR_ERROR_NO_T
650air_vlan_setPortLeakyVlanEnable(
651 const UI32_T unit,
652 const UI32_T port,
653 AIR_LEAKY_PKT_TYPE_T pkt_type,
654 const BOOL_T enable)
655{
656 AIR_ERROR_NO_T rc = AIR_E_OK;
657 UI32_T val = 0;
658
659 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
660 AIR_PARAM_CHK((pkt_type >= AIR_LEAKY_PKT_TYPE_LAST), AIR_E_BAD_PARAMETER);
661
662 aml_readReg(unit, PVC(port), &val);
663
664 if (pkt_type == AIR_LEAKY_PKT_TYPE_UNICAST)
665 {
666 if (enable)
667 {
668 val |= PVC_UC_LKYV_EN_MASK;
669 }
670 else
671 {
672 val &= ~PVC_UC_LKYV_EN_MASK;
673 }
674 }
675 else if (pkt_type == AIR_LEAKY_PKT_TYPE_MULTICAST)
676 {
677 if (enable)
678 {
679 val |= PVC_MC_LKYV_EN_MASK;
680 }
681 else
682 {
683 val &= ~PVC_MC_LKYV_EN_MASK;
684 }
685 }
686 else
687 {
688 if (enable)
689 {
690 val |= PVC_BC_LKYV_EN_MASK;
691 }
692 else
693 {
694 val &= ~PVC_BC_LKYV_EN_MASK;
695 }
696 }
697
698 aml_writeReg(unit, PVC(port), val);
699
700 return rc;
701}
702
703/* FUNCTION NAME: air_vlan_getPortLeakyVlanEnable
704 * PURPOSE:
705 * Get leaky vlan enable of the port from the specified device.
706 * INPUT:
707 * unit -- unit id
708 * port -- port id
709 * pkt_type -- packet type
710 * OUTPUT:
711 * ptr_enable -- enable leaky
712 * RETURN:
713 * AIR_E_OK -- Successfully read the data.
714 * AIR_E_OTHERS -- Operation failed.
715 * AIR_E_BAD_PARAMETER -- Invalid parameter.
716 * NOTES:
717 * none
718 */
719AIR_ERROR_NO_T
720air_vlan_getPortLeakyVlanEnable(
721 const UI32_T unit,
722 const UI32_T port,
723 AIR_LEAKY_PKT_TYPE_T pkt_type,
724 BOOL_T *ptr_enable)
725{
726 AIR_ERROR_NO_T rc = AIR_E_OK;
727 UI32_T val = 0;
728
729 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
730 AIR_PARAM_CHK((pkt_type >= AIR_LEAKY_PKT_TYPE_LAST), AIR_E_BAD_PARAMETER);
731 AIR_CHECK_PTR(ptr_enable);
732
733 aml_readReg(unit, PVC(port), &val);
734
735 if (pkt_type == AIR_LEAKY_PKT_TYPE_UNICAST)
736 {
737 *ptr_enable = val & PVC_UC_LKYV_EN_MASK ? TRUE : FALSE;
738 }
739 else if (pkt_type == AIR_LEAKY_PKT_TYPE_MULTICAST)
740 {
741 *ptr_enable = val & PVC_MC_LKYV_EN_MASK ? TRUE : FALSE;
742 }
743 else
744 {
745 *ptr_enable = val & PVC_BC_LKYV_EN_MASK ? TRUE : FALSE;
746 }
747
748 return rc;
749}
750
751/* FUNCTION NAME: air_vlan_setPortAttr
752 * PURPOSE:
753 * Set vlan port attribute from the specified device.
754 * INPUT:
755 * unit -- unit id
756 * port -- port id
757 * attr -- vlan port attr
758 * OUTPUT:
759 * None
760 * RETURN:
761 * AIR_E_OK -- Successfully read the data.
762 * AIR_E_OTHERS -- Operation failed.
763 * AIR_E_BAD_PARAMETER -- Invalid parameter.
764 * NOTES:
765 * none
766 */
767AIR_ERROR_NO_T
768air_vlan_setPortAttr(
769 const UI32_T unit,
770 const UI32_T port,
771 const AIR_VLAN_PORT_ATTR_T attr)
772{
773 AIR_ERROR_NO_T rc = AIR_E_OK;
774 UI32_T val = 0;
775
776 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
777 AIR_PARAM_CHK((attr >= AIR_VLAN_PORT_ATTR_LAST), AIR_E_BAD_PARAMETER);
778
779 aml_readReg(unit, PVC(port), &val);
780 val &= ~PVC_VLAN_ATTR_MASK;
781 val |= (attr & PVC_VLAN_ATTR_RELMASK) << PVC_VLAN_ATTR_OFFT;
782 aml_writeReg(unit, PVC(port), val);
783
784 return rc;
785}
786
787/* FUNCTION NAME: air_vlan_getPortAttr
788 * PURPOSE:
789 * Get vlan port attribute from the specified device.
790 * INPUT:
791 * unit -- unit id
792 * port -- port id
793 * OUTPUT:
794 * ptr_attr -- vlan port attr
795 * RETURN:
796 * AIR_E_OK -- Successfully read the data.
797 * AIR_E_OTHERS -- Operation failed.
798 * AIR_E_BAD_PARAMETER -- Invalid parameter.
799 * NOTES:
800 * none
801 */
802AIR_ERROR_NO_T
803air_vlan_getPortAttr(
804 const UI32_T unit,
805 const UI32_T port,
806 AIR_VLAN_PORT_ATTR_T *ptr_attr)
807{
808 AIR_ERROR_NO_T rc = AIR_E_OK;
809 UI32_T val = 0;
810
811 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
812 AIR_CHECK_PTR(ptr_attr);
813
814 aml_readReg(unit, PVC(port), &val);
815 *ptr_attr = (val >> PVC_VLAN_ATTR_OFFT) & PVC_VLAN_ATTR_RELMASK;
816
817 return rc;
818}
819
820/* FUNCTION NAME: air_vlan_setIgrPortTagAttr
821 * PURPOSE:
822 * Set vlan incoming port egress tag attribute from the specified device.
823 * INPUT:
824 * unit -- unit id
825 * port -- port id
826 * attr -- egress tag attr
827 * OUTPUT:
828 * None
829 * RETURN:
830 * AIR_E_OK -- Successfully read the data.
831 * AIR_E_OTHERS -- Operation failed.
832 * AIR_E_BAD_PARAMETER -- Invalid parameter.
833 * NOTES:
834 * none
835 */
836AIR_ERROR_NO_T
837air_vlan_setIgrPortTagAttr(
838 const UI32_T unit,
839 const UI32_T port,
840 const AIR_IGR_PORT_EG_TAG_ATTR_T attr)
841{
842 UI32_T val = 0;
843
844 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
845 AIR_PARAM_CHK((attr >= AIR_IGR_PORT_EG_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
846
847 aml_readReg(unit, PVC(port), &val);
848 val &= ~PVC_EG_TAG_MASK;
849 val |= (attr & PVC_EG_TAG_RELMASK) << PVC_EG_TAG_OFFT;
850 aml_writeReg(unit, PVC(port), val);
851
852 return AIR_E_OK;
853}
854
855/* FUNCTION NAME: air_vlan_getIgrPortTagAttr
856 * PURPOSE:
857 * Get vlan incoming port egress tag attribute from the specified device.
858 * INPUT:
859 * unit -- unit id
860 * port -- port id
861 * OUTPUT:
862 * ptr_attr -- egress tag attr
863 * RETURN:
864 * AIR_E_OK -- Successfully read the data.
865 * AIR_E_OTHERS -- Operation failed.
866 * AIR_E_BAD_PARAMETER -- Invalid parameter.
867 * NOTES:
868 * none
869 */
870AIR_ERROR_NO_T
871air_vlan_getIgrPortTagAttr(
872 const UI32_T unit,
873 const UI32_T port,
874 AIR_IGR_PORT_EG_TAG_ATTR_T *ptr_attr)
875{
876 UI32_T val = 0;
877
878 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
879 AIR_CHECK_PTR(ptr_attr);
880
881 aml_readReg(unit, PVC(port), &val);
882 *ptr_attr = (val >> PVC_EG_TAG_OFFT) & PVC_EG_TAG_RELMASK;
883
884 return AIR_E_OK;
885}
886
887/* FUNCTION NAME: air_vlan_setPortEgsTagAttr
888 * PURPOSE:
889 * Set vlan port egress tag attribute from the specified device.
890 * INPUT:
891 * unit -- unit id
892 * port -- port id
893 * attr -- egress tag attr
894 * OUTPUT:
895 * None
896 * RETURN:
897 * AIR_E_OK -- Successfully read the data.
898 * AIR_E_OTHERS -- Operation failed.
899 * AIR_E_BAD_PARAMETER -- Invalid parameter.
900 * NOTES:
901 * none
902 */
903AIR_ERROR_NO_T
904air_vlan_setPortEgsTagAttr(
905 const UI32_T unit,
906 const UI32_T port,
907 const AIR_PORT_EGS_TAG_ATTR_T attr)
908{
909 UI32_T val = 0;
910
911 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
912 AIR_PARAM_CHK((attr >= AIR_PORT_EGS_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
913
914 aml_readReg(unit, PCR(port), &val);
915 val &= ~PCR_EG_TAG_MASK;
916 val |= (attr & PCR_EG_TAG_RELMASK) << PCR_EG_TAG_OFFT;
917 aml_writeReg(unit, PCR(port), val);
918
919 return AIR_E_OK;
920}
921
922/* FUNCTION NAME: air_vlan_getPortEgsTagAttr
923 * PURPOSE:
924 * Get vlan port egress tag attribute from the specified device.
925 * INPUT:
926 * unit -- unit id
927 * port -- port id
928 * OUTPUT:
929 * ptr_attr -- egress tag attr
930 * RETURN:
931 * AIR_E_OK -- Successfully read the data.
932 * AIR_E_OTHERS -- Operation failed.
933 * AIR_E_BAD_PARAMETER -- Invalid parameter.
934 * NOTES:
935 * none
936 */
937AIR_ERROR_NO_T
938air_vlan_getPortEgsTagAttr(
939 const UI32_T unit,
940 const UI32_T port,
941 AIR_PORT_EGS_TAG_ATTR_T *ptr_attr)
942{
943 UI32_T val = 0;
944
945 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
946 AIR_CHECK_PTR(ptr_attr);
947
948 aml_readReg(unit, PCR(port), &val);
949 *ptr_attr = (val >> PCR_EG_TAG_OFFT) & PCR_EG_TAG_RELMASK;
950
951 return AIR_E_OK;
952}
953
954/* FUNCTION NAME: air_vlan_setPortOuterTPID
955 * PURPOSE:
956 * Set stack tag TPID of the port from the specified device.
957 * INPUT:
958 * unit -- unit id
959 * port -- port id
960 * tpid -- TPID
961 * OUTPUT:
962 * None
963 * RETURN:
964 * AIR_E_OK -- Successfully read the data.
965 * AIR_E_OTHERS -- Operation failed.
966 * AIR_E_BAD_PARAMETER -- Invalid parameter.
967 * NOTES:
968 * none
969 */
970AIR_ERROR_NO_T
971air_vlan_setPortOuterTPID(
972 const UI32_T unit,
973 const UI32_T port,
974 const UI16_T tpid)
975{
976 UI32_T val = 0;
977
978 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
979
980 aml_readReg(unit, PVC(port), &val);
981 val &= ~PVC_STAG_VPID_MASK;
982 val |= (tpid & PVC_STAG_VPID_RELMASK) << PVC_STAG_VPID_OFFT;
983 aml_writeReg(unit, PVC(port), val);
984
985 return AIR_E_OK;
986}
987
988/* FUNCTION NAME: air_vlan_getPortOuterTPID
989 * PURPOSE:
990 * Get stack tag TPID of the port from the specified device.
991 * INPUT:
992 * unit -- unit id
993 * port -- port id
994 * OUTPUT:
995 * ptr_tpid -- TPID
996 * RETURN:
997 * AIR_E_OK -- Successfully read the data.
998 * AIR_E_OTHERS -- Operation failed.
999 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1000 * NOTES:
1001 * none
1002 */
1003AIR_ERROR_NO_T
1004air_vlan_getPortOuterTPID(
1005 const UI32_T unit,
1006 const UI32_T port,
1007 UI16_T *ptr_tpid)
1008{
1009 UI32_T val = 0;
1010
1011 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
1012 AIR_CHECK_PTR(ptr_tpid);
1013
1014 aml_readReg(unit, PVC(port), &val);
1015 *ptr_tpid = (val >> PVC_STAG_VPID_OFFT) & PVC_STAG_VPID_RELMASK;
1016
1017 return AIR_E_OK;
1018}
1019
1020/* FUNCTION NAME: air_vlan_setPortPVID
1021 * PURPOSE:
1022 * Set PVID of the port from the specified device.
1023 * INPUT:
1024 * unit -- unit id
1025 * port -- port id
1026 * pvid -- native vlan id
1027 * OUTPUT:
1028 * None
1029 * RETURN:
1030 * AIR_E_OK -- Successfully read the data.
1031 * AIR_E_OTHERS -- Operation failed.
1032 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1033 * NOTES:
1034 * none
1035 */
1036AIR_ERROR_NO_T
1037air_vlan_setPortPVID(
1038 const UI32_T unit,
1039 const UI32_T port,
1040 const UI16_T pvid)
1041{
1042 UI32_T val = 0;
1043
1044 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
1045 AIR_PARAM_CHK((pvid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1046
1047 aml_readReg(unit, PVID(port), &val);
1048 val &= ~PVID_PCVID_MASK;
1049 val |= (pvid & PVID_PCVID_RELMASK) << PVID_PCVID_OFFT;
1050 aml_writeReg(unit, PVID(port), val);
1051
1052 return AIR_E_OK;
1053}
1054
1055/* FUNCTION NAME: air_vlan_getPortPVID
1056 * PURPOSE:
1057 * Get PVID of the port from the specified device.
1058 * INPUT:
1059 * unit -- unit id
1060 * port -- port id
1061 * OUTPUT:
1062 * ptr_pvid -- native vlan id
1063 * RETURN:
1064 * AIR_E_OK -- Successfully read the data.
1065 * AIR_E_OTHERS -- Operation failed.
1066 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1067 * NOTES:
1068 * none
1069 */
1070AIR_ERROR_NO_T
1071air_vlan_getPortPVID(
1072 const UI32_T unit,
1073 const UI32_T port,
1074 UI16_T *ptr_pvid)
1075{
1076 UI32_T val = 0;
1077
1078 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
1079 AIR_CHECK_PTR(ptr_pvid);
1080
1081 aml_readReg(unit, PVID(port), &val);
1082 *ptr_pvid = (val >> PVID_PCVID_OFFT) & PVID_PCVID_RELMASK;
1083
1084 return AIR_E_OK;
1085}
1086
1087/* FUNCTION NAME: air_vlan_setServiceTag
1088 * PURPOSE:
1089 * Set Vlan service tag.
1090 * INPUT:
1091 * unit -- unit id
1092 * vid -- vlan id
1093 * stag -- service stag
1094 * OUTPUT:
1095 * None
1096 * RETURN:
1097 * AIR_E_OK -- Successfully read the data.
1098 * AIR_E_OTHERS -- Operation failed.
1099 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1100 * NOTES:
1101 * none
1102 */
1103AIR_ERROR_NO_T
1104air_vlan_setServiceTag(
1105 const UI32_T unit,
1106 const UI16_T vid,
1107 const UI16_T stag)
1108{
1109 AIR_VLAN_ENTRY_T vlan_entry = {0};
1110
1111 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1112 AIR_PARAM_CHK((stag > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1113
1114 _air_vlan_readEntry(unit, vid, &vlan_entry);
1115 if (!vlan_entry.valid)
1116 return AIR_E_ENTRY_NOT_FOUND;
1117
1118 vlan_entry.vlan_entry_format.stag = stag;
1119 _air_vlan_writeEntry(unit, vid, &vlan_entry);
1120
1121 return AIR_E_OK;
1122}
1123
1124/* FUNCTION NAME: air_vlan_getServiceTag
1125 * PURPOSE:
1126 * Get Vlan service tag.
1127 * INPUT:
1128 * unit -- unit id
1129 * vid -- vlan id
1130 * OUTPUT:
1131 * ptr_stag -- service stag
1132 * RETURN:
1133 * AIR_E_OK -- Successfully read the data.
1134 * AIR_E_OTHERS -- Operation failed.
1135 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1136 * NOTES:
1137 * none
1138 */
1139AIR_ERROR_NO_T
1140air_vlan_getServiceTag(
1141 const UI32_T unit,
1142 const UI16_T vid,
1143 UI16_T *ptr_stag)
1144{
1145 AIR_VLAN_ENTRY_T vlan_entry = {0};
1146
1147 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1148 AIR_CHECK_PTR(ptr_stag);
1149
1150 _air_vlan_readEntry(unit, vid, &vlan_entry);
1151 if (!vlan_entry.valid)
1152 return AIR_E_ENTRY_NOT_FOUND;
1153
1154 *ptr_stag = vlan_entry.vlan_entry_format.stag;
1155
1156 return AIR_E_OK;
1157}
1158
1159/* FUNCTION NAME: air_vlan_setEgsTagCtlEnable
1160 * PURPOSE:
1161 * Set per vlan egress tag control.
1162 * INPUT:
1163 * unit -- unit id
1164 * vid -- vlan id
1165 * enable -- enable vlan egress tag control
1166 * OUTPUT:
1167 * None
1168 * RETURN:
1169 * AIR_E_OK -- Successfully read the data.
1170 * AIR_E_OTHERS -- Operation failed.
1171 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1172 * NOTES:
1173 * none
1174 */
1175AIR_ERROR_NO_T
1176air_vlan_setEgsTagCtlEnable(
1177 const UI32_T unit,
1178 const UI16_T vid,
1179 const BOOL_T enable)
1180{
1181 AIR_VLAN_ENTRY_T vlan_entry = {0};
1182
1183 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1184
1185 _air_vlan_readEntry(unit, vid, &vlan_entry);
1186 if (!vlan_entry.valid)
1187 return AIR_E_ENTRY_NOT_FOUND;
1188
1189 vlan_entry.vlan_entry_format.eg_ctrl_en = enable ? 1 : 0;
1190 _air_vlan_writeEntry(unit, vid, &vlan_entry);
1191
1192 return AIR_E_OK;
1193}
1194
1195/* FUNCTION NAME: air_vlan_getEgsTagCtlEnable
1196 * PURPOSE:
1197 * Get per vlan egress tag control.
1198 * INPUT:
1199 * unit -- unit id
1200 * vid -- vlan id
1201 * OUTPUT:
1202 * ptr_enable -- enable vlan egress tag control
1203 * RETURN:
1204 * AIR_E_OK -- Successfully read the data.
1205 * AIR_E_OTHERS -- Operation failed.
1206 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1207 * NOTES:
1208 * none
1209 */
1210AIR_ERROR_NO_T
1211air_vlan_getEgsTagCtlEnable(
1212 const UI32_T unit,
1213 const UI16_T vid,
1214 BOOL_T *ptr_enable)
1215{
1216 AIR_VLAN_ENTRY_T vlan_entry = {0};
1217
1218 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1219 AIR_CHECK_PTR(ptr_enable);
1220
1221 _air_vlan_readEntry(unit, vid, &vlan_entry);
1222 if (!vlan_entry.valid)
1223 return AIR_E_ENTRY_NOT_FOUND;
1224
1225 *ptr_enable = vlan_entry.vlan_entry_format.eg_ctrl_en;
1226
1227 return AIR_E_OK;
1228}
1229
1230/* FUNCTION NAME: air_vlan_setEgsTagConsistent
1231 * PURPOSE:
1232 * Set per vlan egress tag consistent.
1233 * INPUT:
1234 * unit -- unit id
1235 * vid -- vlan id
1236 * enable -- enable vlan egress tag consistent
1237 * OUTPUT:
1238 * None
1239 * RETURN:
1240 * AIR_E_OK -- Successfully read the data.
1241 * AIR_E_OTHERS -- Operation failed.
1242 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1243 * NOTES:
1244 * none
1245 */
1246AIR_ERROR_NO_T
1247air_vlan_setEgsTagConsistent(
1248 const UI32_T unit,
1249 const UI16_T vid,
1250 const BOOL_T enable)
1251{
1252 AIR_VLAN_ENTRY_T vlan_entry = {0};
1253
1254 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1255
1256 _air_vlan_readEntry(unit, vid, &vlan_entry);
1257 if (!vlan_entry.valid)
1258 return AIR_E_ENTRY_NOT_FOUND;
1259
1260 vlan_entry.vlan_entry_format.eg_con = enable;
1261 _air_vlan_writeEntry(unit, vid, &vlan_entry);
1262
1263 return AIR_E_OK;
1264}
1265
1266/* FUNCTION NAME: air_vlan_getEgsTagConsistent
1267 * PURPOSE:
1268 * Get per vlan egress tag consistent.
1269 * INPUT:
1270 * unit -- unit id
1271 * vid -- vlan id
1272 * OUTPUT:
1273 * ptr_enable -- enable vlan egress tag consistent
1274 * RETURN:
1275 * AIR_E_OK -- Successfully read the data.
1276 * AIR_E_OTHERS -- Operation failed.
1277 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1278 * NOTES:
1279 * none
1280 */
1281AIR_ERROR_NO_T
1282air_vlan_getEgsTagConsistent(
1283 const UI32_T unit,
1284 const UI16_T vid,
1285 BOOL_T *ptr_enable)
1286{
1287 AIR_VLAN_ENTRY_T vlan_entry = {0};
1288
1289 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1290 AIR_CHECK_PTR(ptr_enable);
1291
1292 _air_vlan_readEntry(unit, vid, &vlan_entry);
1293 if (!vlan_entry.valid)
1294 return AIR_E_ENTRY_NOT_FOUND;
1295
1296 *ptr_enable = vlan_entry.vlan_entry_format.eg_con;
1297
1298 return AIR_E_OK;
1299}
1300
1301/* FUNCTION NAME: air_vlan_setPortBasedStag
1302 * PURPOSE:
1303 * Set vlan port based stag enable.
1304 * INPUT:
1305 * unit -- unit id
1306 * vid -- vlan id
1307 * enable -- vlan port based stag enable
1308 * OUTPUT:
1309 * None
1310 * RETURN:
1311 * AIR_E_OK -- Successfully read the data.
1312 * AIR_E_OTHERS -- Operation failed.
1313 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1314 * NOTES:
1315 * none
1316 */
1317AIR_ERROR_NO_T
1318air_vlan_setPortBasedStag(
1319 const UI32_T unit,
1320 const UI16_T vid,
1321 const BOOL_T enable)
1322{
1323 AIR_VLAN_ENTRY_T vlan_entry = {0};
1324
1325 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1326
1327 _air_vlan_readEntry(unit, vid, &vlan_entry);
1328 if (!vlan_entry.valid)
1329 return AIR_E_ENTRY_NOT_FOUND;
1330
1331 vlan_entry.vlan_entry_format.port_stag = enable;
1332 _air_vlan_writeEntry(unit, vid, &vlan_entry);
1333
1334 return AIR_E_OK;
1335}
1336
1337/* FUNCTION NAME: air_vlan_getPortBasedStag
1338 * PURPOSE:
1339 * Get vlan port based stag enable.
1340 * INPUT:
1341 * unit -- unit id
1342 * vid -- vlan id
1343 * OUTPUT:
1344 * ptr_enable -- vlan port based stag enable
1345 * RETURN:
1346 * AIR_E_OK -- Successfully read the data.
1347 * AIR_E_OTHERS -- Operation failed.
1348 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1349 * NOTES:
1350 * none
1351 */
1352AIR_ERROR_NO_T
1353air_vlan_getPortBasedStag(
1354 const UI32_T unit,
1355 const UI16_T vid,
1356 BOOL_T *ptr_enable)
1357{
1358 AIR_VLAN_ENTRY_T vlan_entry = {0};
1359
1360 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1361 AIR_CHECK_PTR(ptr_enable);
1362
1363 _air_vlan_readEntry(unit, vid, &vlan_entry);
1364 if (!vlan_entry.valid)
1365 return AIR_E_ENTRY_NOT_FOUND;
1366
1367 *ptr_enable = vlan_entry.vlan_entry_format.port_stag;
1368
1369 return AIR_E_OK;
1370}
1371
1372/* FUNCTION NAME: air_vlan_setPortEgsTagCtl
1373 * PURPOSE:
1374 * Set vlan port egress tag control.
1375 * INPUT:
1376 * unit -- unit id
1377 * vid -- vlan id
1378 * port -- port id
1379 * tag_ctl -- egress tag control
1380 * OUTPUT:
1381 * None
1382 * RETURN:
1383 * AIR_E_OK -- Successfully read the data.
1384 * AIR_E_OTHERS -- Operation failed.
1385 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1386 * NOTES:
1387 * none
1388 */
1389AIR_ERROR_NO_T
1390air_vlan_setPortEgsTagCtl(
1391 const UI32_T unit,
1392 const UI16_T vid,
1393 const UI32_T port,
1394 const AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T tag_ctl)
1395{
1396 AIR_VLAN_ENTRY_T vlan_entry = {0};
1397
1398 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1399 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
1400 AIR_PARAM_CHK((tag_ctl >= AIR_PORT_EGS_TAG_ATTR_LAST), AIR_E_BAD_PARAMETER);
1401
1402 _air_vlan_readEntry(unit, vid, &vlan_entry);
1403 if (!vlan_entry.valid)
1404 return AIR_E_ENTRY_NOT_FOUND;
1405
1406 vlan_entry.vlan_entry_format.eg_ctrl &= ~(0x3 << (port * 2));
1407 vlan_entry.vlan_entry_format.eg_ctrl |= (tag_ctl & 0x3) << (port * 2);
1408 _air_vlan_writeEntry(unit, vid, &vlan_entry);
1409
1410 return AIR_E_OK;
1411}
1412
1413/* FUNCTION NAME: air_vlan_getPortEgsTagCtl
1414 * PURPOSE:
1415 * Get vlan port egress tag control.
1416 * INPUT:
1417 * unit -- unit id
1418 * vid -- vlan id
1419 * OUTPUT:
1420 * ptr_tag_ctl -- egress tag control
1421 * RETURN:
1422 * AIR_E_OK -- Successfully read the data.
1423 * AIR_E_OTHERS -- Operation failed.
1424 * AIR_E_BAD_PARAMETER -- Invalid parameter.
1425 * NOTES:
1426 * none
1427 */
1428AIR_ERROR_NO_T
1429air_vlan_getPortEgsTagCtl(
1430 const UI32_T unit,
1431 const UI16_T vid,
1432 const UI32_T port,
1433 AIR_VLAN_PORT_EGS_TAG_CTL_TYPE_T *ptr_tag_ctl)
1434{
1435 AIR_VLAN_ENTRY_T vlan_entry = {0};
1436
1437 AIR_PARAM_CHK((vid > AIR_VLAN_ID_MAX), AIR_E_BAD_PARAMETER);
1438 AIR_PARAM_CHK((port >= AIR_MAX_NUM_OF_PORTS), AIR_E_BAD_PARAMETER);
1439 AIR_CHECK_PTR(ptr_tag_ctl);
1440
1441 _air_vlan_readEntry(unit, vid, &vlan_entry);
1442 if (!vlan_entry.valid)
1443 return AIR_E_ENTRY_NOT_FOUND;
1444
1445 *ptr_tag_ctl = (vlan_entry.vlan_entry_format.eg_ctrl >> (port * 2)) & 0x3;
1446
1447 return AIR_E_OK;
1448}