71 #define DEFAULT_UNIT 0
72 #define DEFAULT_VLAN 1
73 #define MAX_DIGITS_IN_CHOICE 5
76 "Syntax: example_vxlan \n\r"
78 "Paramaters: None. \n\r"
80 "Usage Guidelines: None. \n\r";
87 #define VXLAN_UDP_DEST_PORT 4789
96 static int do_vxlan_global_setting(
int unit)
131 static int do_vxlan_access_port_settings(
int unit,
opennsl_port_t a_port)
158 static int do_vxlan_net_port_settings(
int unit,
opennsl_port_t n_port)
198 vpn_info.
vnid = vnid;
206 printf(
"create_vxlan_vpn: failed to create VXLAN VPN rv %d\n", rv);
248 printf(
"create_vxlan_acc_vp: failed to create vxlan port rv %d\n", rv);
293 printf(
"create_vxlan_net_vp: failed to create vxlan port rv %d\n", rv);
315 opennsl_mac_t bc_mac_mask = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
320 l2_station.
vlan = vid;
327 printf(
"add_to_l2_station: failed to create l2 entry rv %d\n", rv);
355 printf(
"add_to_l2_table: failed to create l2 entry rv %d\n", rv);
392 static int create_l3_interface(
int unit,
opennsl_mac_t local_mac,
int vid,
407 printf(
"create_l3_interface: failed to create L3 intf rv %d\n", rv);
435 l3_egress.
intf = l3_if;
437 l3_egress.
vlan = vid;
438 l3_egress.
port = gport;
443 printf(
"create_egr_obj: failed to create L3 egress object rv %d\n", rv);
464 int dp,
int sp,
int ttl,
int *tid)
480 printf(
"tunnel_initiator_setup: failed to create VXLAN tunnel initiator rv %d\n", rv);
516 tnl_term.
vlan = net_vid;
523 printf(
"tunnel_terminator_setup: failed to create VXLAN tunnel terminator rv %d\n", rv);
547 int vnid_1 = 0x12345, vnid_2 = 0x53535;
551 int rsvd_network_vpn = 0x7001;
552 int rsvd_network_vpn_vnid = 0xeeee;
556 opennsl_mac_t acc_dummy_mac = {0x00, 0x00, 0x01, 0x00, 0x00, 0x01};
563 int acc_vxlan_port_1;
571 int acc_vxlan_port_2;
586 opennsl_mac_t net_local_mac = {0x00, 0x00, 0x00, 0x00, 0x22, 0x22};
587 opennsl_mac_t net_remote_mac = {0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
590 int tunnel_init_id, tunnel_term_id;
593 opennsl_mac_t dlf_mac = {0x01, 0x00, 0x5e, 0x00, 0x00, 0x0A};
598 int tunnel_mc_init_id, tunnel_mc_term_id;
601 opennsl_mac_t payload_sa_1 = {0x00, 0x00, 0x00, 0x00, 0x11, 0xaa};
602 opennsl_mac_t payload_da_1 = {0x00, 0x00, 0x00, 0x00, 0x11, 0xbb};
605 opennsl_mac_t payload_sa_2 = {0x00, 0x00, 0x00, 0x00, 0x22, 0xaa};
606 opennsl_mac_t payload_da_2 = {0x00, 0x00, 0x00, 0x00, 0x22, 0xbb};
610 do_vxlan_global_setting(unit);
613 do_vxlan_access_port_settings(unit, acc_port_1);
614 do_vxlan_access_port_settings(unit, acc_port_2);
617 do_vxlan_net_port_settings(unit, net_port);
628 create_vxlan_vpn(unit, vpn_id_1, vnid_1, bc_group_1, bc_group_1, bc_group_1);
629 create_vxlan_vpn(unit, vpn_id_2, vnid_2, bc_group_2, bc_group_2, bc_group_2);
632 create_vxlan_vpn(unit, rsvd_network_vpn, rsvd_network_vpn_vnid, bc_group_2,
633 bc_group_2, bc_group_2);
641 create_l3_interface(unit, acc_dummy_mac, acc_vid_1, &acc_intf_id_1);
642 create_egr_obj(unit, 0, acc_intf_id_1, acc_dummy_mac,
643 acc_gport_1, acc_vid_1, &acc_egr_obj_1);
647 acc_egr_obj_1, acc_vid_1, &acc_vxlan_port_1);
655 create_l3_interface(unit, acc_dummy_mac, acc_vid_2, &acc_intf_id_2);
656 create_egr_obj(unit, 0, acc_intf_id_2, acc_dummy_mac,
657 acc_gport_2, acc_vid_2, &acc_egr_obj_2);
661 acc_egr_obj_2, acc_vid_2, &acc_vxlan_port_2);
669 create_l3_interface(unit, net_local_mac, net_vid, &net_intf_id);
670 create_egr_obj(unit, 0, net_intf_id, net_remote_mac, net_gport,
671 net_vid, &net_egr_obj);
674 tunnel_initiator_setup(unit, tnl_local_ip, tnl_remote_ip, udp_dp, udp_sp, ttl, &tunnel_init_id);
675 tunnel_terminator_setup(unit, tnl_remote_ip, tnl_local_ip, -1, tunnel_init_id, &tunnel_term_id);
679 tunnel_init_id, tunnel_term_id, &net_vxlan_port);
682 add_to_l2_station(unit, net_local_mac, net_vid);
689 create_egr_obj(unit,
OPENNSL_L3_IPMC, net_intf_id, dlf_mac, net_gport, net_vid, &egr_obj_mc);
692 tunnel_initiator_setup(unit, tnl_local_ip, tnl_mc_dip, udp_dp, udp_sp, ttl, &tunnel_mc_init_id);
693 tunnel_terminator_setup(unit, tnl_remote_ip, tnl_mc_dip, net_vid,
694 tunnel_mc_init_id, &tunnel_mc_term_id);
699 tunnel_mc_init_id, tunnel_mc_term_id, &vxlan_port_mc);
702 add_to_l2_station(unit, dlf_mac, net_vid);
748 int main(
int argc,
char *argv[])
754 int aport_1, aport_2, nport;
756 if(strcmp(argv[0],
"gdb") == 0)
761 if((argc != (index + 1)) || ((argc > (index + 1)) && (strcmp(argv[index + 1],
"--help") == 0))) {
767 printf(
"Initializing the switch device.\r\n");
771 printf(
"\r\nFailed to initialize the switch device. Error %s\r\n",
779 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
783 printf(
"1. Enter Access port 1\n");
788 printf(
"Invalid port number entered. Please re-enter.\n");
794 printf(
"2. Enter Access port 2\n");
799 printf(
"Invalid port number entered. Please re-enter.\n");
805 printf(
"3. Enter Network port\n");
810 printf(
"Invalid port number entered. Please re-enter.\n");
819 printf(
"\r\nVxLAN configuration is done successfully\n");
822 printf(
"\r\nUser menu: Select one of the following options\r\n");
823 #ifdef INCLUDE_DIAG_SHELL
824 printf(
"9. Launch diagnostic shell\n");
826 printf(
"0. Quit the application\n");
830 printf(
"Invalid option entered. Please re-enter.\n");
835 #ifdef INCLUDE_DIAG_SHELL
838 opennsl_driver_shell();
845 printf(
"Exiting the application.\n");