OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 452... Line 452...
452 state->vlan_enabled = val->value.i; 452 state->vlan_enabled = val->value.i;
Line 453... Line 453...
453   453  
454 return 0; 454 return 0;
Line 455... Line -...
455 } -  
456   -  
457 static int mvsw61xx_get_mirror_rx_enable(struct switch_dev *dev, -  
458 const struct switch_attr *attr, struct switch_val *val) -  
459 { -  
460 struct mvsw61xx_state *state = get_state(dev); -  
461   -  
462 val->value.i = state->mirror_rx; -  
463   -  
464 return 0; -  
465 } -  
466   -  
467 static int mvsw61xx_set_mirror_rx_enable(struct switch_dev *dev, -  
468 const struct switch_attr *attr, struct switch_val *val) -  
469 { -  
470 struct mvsw61xx_state *state = get_state(dev); -  
471   -  
472 state->mirror_rx = val->value.i; -  
473   -  
474 return 0; -  
475 } -  
476   -  
477 static int mvsw61xx_get_mirror_tx_enable(struct switch_dev *dev, -  
478 const struct switch_attr *attr, struct switch_val *val) -  
479 { -  
480 struct mvsw61xx_state *state = get_state(dev); -  
481   -  
482 val->value.i = state->mirror_tx; -  
483   -  
484 return 0; -  
485 } -  
486   -  
487 static int mvsw61xx_set_mirror_tx_enable(struct switch_dev *dev, -  
488 const struct switch_attr *attr, struct switch_val *val) -  
489 { -  
490 struct mvsw61xx_state *state = get_state(dev); -  
491   -  
492 state->mirror_tx = val->value.i; -  
493   -  
494 return 0; -  
495 } -  
496   -  
497 static int mvsw61xx_get_mirror_monitor_port(struct switch_dev *dev, -  
498 const struct switch_attr *attr, struct switch_val *val) -  
499 { -  
500 struct mvsw61xx_state *state = get_state(dev); -  
501   -  
502 val->value.i = state->monitor_port; -  
503   -  
504 return 0; -  
505 } -  
506   -  
507 static int mvsw61xx_set_mirror_monitor_port(struct switch_dev *dev, -  
508 const struct switch_attr *attr, struct switch_val *val) -  
509 { -  
510 struct mvsw61xx_state *state = get_state(dev); -  
511   -  
512 state->monitor_port = val->value.i; -  
513   -  
514 return 0; -  
515 } -  
516   -  
517 static int mvsw61xx_get_mirror_source_port(struct switch_dev *dev, -  
518 const struct switch_attr *attr, struct switch_val *val) -  
519 { -  
520 struct mvsw61xx_state *state = get_state(dev); -  
521   -  
522 val->value.i = state->source_port; -  
523   -  
524 return 0; -  
525 } -  
526   -  
527 static int mvsw61xx_set_mirror_source_port(struct switch_dev *dev, -  
528 const struct switch_attr *attr, struct switch_val *val) -  
529 { -  
530 struct mvsw61xx_state *state = get_state(dev); -  
531   -  
532 state->source_port = val->value.i; -  
533   -  
534 return 0; -  
535 } 455 }
536   456  
537 static int mvsw61xx_vtu_program(struct switch_dev *dev) 457 static int mvsw61xx_vtu_program(struct switch_dev *dev)
538 { 458 {
539 struct mvsw61xx_state *state = get_state(dev); 459 struct mvsw61xx_state *state = get_state(dev);
Line 682... Line 602...
682 sw16(dev, MV_PORTREG(CONTROL2, i), reg); 602 sw16(dev, MV_PORTREG(CONTROL2, i), reg);
683 } 603 }
Line 684... Line 604...
684   604  
Line 685... Line -...
685 mvsw61xx_vtu_program(dev); -  
686   -  
687 /* port mirroring */ -  
688 /* reset all mirror registers */ -  
689 for (i = 0; i < dev->ports; i++) { -  
690 reg = sr16(dev, MV_PORTREG(CONTROL2, i)); -  
691 reg &= ~(MV_MIRROR_RX_SRC_MASK | MV_MIRROR_TX_SRC_MASK); -  
692 sw16(dev, MV_PORTREG(CONTROL2, i), reg); -  
693 } -  
694 reg = sr16(dev, MV_GLOBALREG(MONITOR_CTRL)); -  
695 reg |= MV_MIRROR_RX_DEST_MASK | MV_MIRROR_TX_DEST_MASK; -  
696 sw16(dev, MV_GLOBALREG(MONITOR_CTRL), reg); -  
697   -  
698 /* now enable mirroring if necessary */ -  
699 if (state->mirror_rx) { -  
700 /* set ingress monitor source */ -  
701 reg = sr16(dev, MV_PORTREG(CONTROL2, state->source_port)) & ~MV_MIRROR_RX_SRC_MASK; -  
702 reg |= state->mirror_rx << MV_MIRROR_RX_SRC_SHIFT; -  
703 sw16(dev, MV_PORTREG(CONTROL2, state->source_port), reg); -  
704 /* set ingress monitor destination */ -  
705 reg = sr16(dev, MV_GLOBALREG(MONITOR_CTRL)) & ~MV_MIRROR_RX_DEST_MASK; -  
706 reg |= state->monitor_port << MV_MIRROR_RX_DEST_SHIFT; -  
707 sw16(dev, MV_GLOBALREG(MONITOR_CTRL), reg); -  
708 } -  
709   -  
710 if (state->mirror_tx) { -  
711 /* set egress monitor source */ -  
712 reg = sr16(dev, MV_PORTREG(CONTROL2, state->source_port)) & ~MV_MIRROR_TX_SRC_MASK; -  
713 reg |= state->mirror_tx << MV_MIRROR_TX_SRC_SHIFT; -  
714 sw16(dev, MV_PORTREG(CONTROL2, state->source_port), reg); -  
715 /* set egress monitor destination */ -  
716 reg = sr16(dev, MV_GLOBALREG(MONITOR_CTRL)) & ~MV_MIRROR_TX_DEST_MASK; -  
717 reg |= state->monitor_port << MV_MIRROR_TX_DEST_SHIFT; -  
718 sw16(dev, MV_GLOBALREG(MONITOR_CTRL), reg); -  
719 } 605 mvsw61xx_vtu_program(dev);
720   606  
Line 721... Line 607...
721 return 0; 607 return 0;
722 } 608 }
Line 805... Line 691...
805 state->vlans[i].port_sstate = 0; 691 state->vlans[i].port_sstate = 0;
806 } 692 }
Line 807... Line 693...
807   693  
Line 808... Line -...
808 state->vlan_enabled = 0; -  
809   -  
810 state->mirror_rx = false; -  
811 state->mirror_tx = false; -  
812 state->source_port = 0; -  
813 state->monitor_port = 0; 694 state->vlan_enabled = 0;
Line 814... Line 695...
814   695  
815 mvsw61xx_update_state(dev); 696 mvsw61xx_update_state(dev);
816   697  
Line 828... Line 709...
828 { 709 {
829 return _mvsw61xx_reset(dev, false); 710 return _mvsw61xx_reset(dev, false);
830 } 711 }
Line 831... Line 712...
831   712  
-   713 enum {
-   714 MVSW61XX_ENABLE_VLAN,
-   715 };
-   716  
832 enum { 717 enum {
833 MVSW61XX_VLAN_PORT_BASED, 718 MVSW61XX_VLAN_PORT_BASED,
834 MVSW61XX_VLAN_ID, 719 MVSW61XX_VLAN_ID,
Line 835... Line 720...
835 }; 720 };
836   721  
837 enum { 722 enum {
838 MVSW61XX_PORT_MASK, 723 MVSW61XX_PORT_MASK,
Line 839... Line 724...
839 MVSW61XX_PORT_QMODE, 724 MVSW61XX_PORT_QMODE,
840 }; 725 };
-   726  
841   727 static const struct switch_attr mvsw61xx_global[] = {
842 static const struct switch_attr mvsw61xx_global[] = { 728 [MVSW61XX_ENABLE_VLAN] = {
843 { 729 .id = MVSW61XX_ENABLE_VLAN,
844 .type = SWITCH_TYPE_INT, 730 .type = SWITCH_TYPE_INT,
845 .name = "enable_vlan", 731 .name = "enable_vlan",
846 .description = "Enable 802.1q VLAN support", 732 .description = "Enable 802.1q VLAN support",
847 .get = mvsw61xx_get_enable_vlan, -  
848 .set = mvsw61xx_set_enable_vlan, -  
849 }, -  
850 { -  
851 .type = SWITCH_TYPE_INT, -  
852 .name = "enable_mirror_rx", -  
853 .description = "Enable mirroring of RX packets", -  
854 .set = mvsw61xx_set_mirror_rx_enable, -  
855 .get = mvsw61xx_get_mirror_rx_enable, -  
856 .max = 1 -  
857 }, -  
858 { -  
859 .type = SWITCH_TYPE_INT, -  
860 .name = "enable_mirror_tx", -  
861 .description = "Enable mirroring of TX packets", -  
862 .set = mvsw61xx_set_mirror_tx_enable, -  
863 .get = mvsw61xx_get_mirror_tx_enable, -  
864 .max = 1 -  
865 }, -  
866 { -  
867 .type = SWITCH_TYPE_INT, -  
868 .name = "mirror_monitor_port", -  
869 .description = "Mirror monitor port", -  
870 .set = mvsw61xx_set_mirror_monitor_port, -  
871 .get = mvsw61xx_get_mirror_monitor_port, -  
872 .max = MV_PORTS - 1 -  
873 }, -  
874 { -  
875 .type = SWITCH_TYPE_INT, -  
876 .name = "mirror_source_port", -  
877 .description = "Mirror source port", -  
878 .set = mvsw61xx_set_mirror_source_port, -  
879 .get = mvsw61xx_get_mirror_source_port, 733 .get = mvsw61xx_get_enable_vlan,
Line 880... Line 734...
880 .max = MV_PORTS - 1 734 .set = mvsw61xx_set_enable_vlan,
881 }, 735 },
882 }; 736 };