openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

wlan.c (34503B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * WLAN CLI commands
      8  */
      9 
     10 #include <shared/bsl.h>
     11 
     12 #include <appl/diag/system.h>
     13 #include <appl/diag/parse.h>
     14 #include <shared/bsl.h>
     15 #include <soc/debug.h>
     16 #if defined(BCM_TRIUMPH2_SUPPORT)
     17 #include <soc/triumph2.h>
     18 #endif /* BCM_TRIUMPH2_SUPPORT */
     19 
     20 #include <bcm/error.h>
     21 #include <bcm/debug.h>
     22 #include <bcm/l3.h>
     23 #include <bcm/wlan.h>
     24 #include <bcm/l2.h>
     25 #include <bcm_int/esw/l3.h>
     26 #include <bcm_int/esw/port.h>
     27 
     28 #ifdef INCLUDE_L3
     29 #if defined(BCM_TRIUMPH2_SUPPORT)
     30 
     31 #define ENV_WLAN_TYPE_ID "wlan_port_id"
     32 #define ENV_MCAST_TYPE_ID "mcast_type_id"
     33 
     34 
     35 enum _wlan_tr2_cmd_t {
     36     WLAN_INIT = 1,
     37     WLAN_DETACH,
     38     WLAN_PORT_ADD,
     39     WLAN_PORT_DEL,
     40     WLAN_PORT_DEL_ALL,
     41     WLAN_PORT_GET,
     42     WLAN_PORT_GET_ALL,
     43     WLAN_CLIENT_ADD,
     44     WLAN_CLIENT_DEL,
     45     WLAN_CLIENT_DEL_ALL,
     46     WLAN_CLIENT_GET,
     47     WLAN_CLIENT_GET_ALL,
     48     WLAN_TUNNEL_INIT_CREATE,
     49     WLAN_TUNNEL_INIT_DESTROY,
     50     WLAN_TUNNEL_INIT_GET,
     51     WLAN_MCAST_GROUP_CREATE,
     52     WLAN_MCAST_GROUP_DEL,
     53     WLAN_MCAST_GROUP_PORT_ADD,
     54     WLAN_MCAST_GROUP_PORT_DEL,
     55     WLAN_MCAST_GROUP_ADDR,
     56     WLAN_OPTIONS
     57 };
     58 
     59 #define BCM_WLAN_PORT                   1
     60 #define BCM_WLAN_CLIENT                 2
     61 #define BCM_WLAN_TUNNEL                 3
     62 #define MAX_FLAG_LENGTH                35 
     63 
     64 #define WLAN_ROE(op, arg)     \
     65     do {               \
     66         int __rv__;    \
     67         __rv__ = op arg;    \
     68         if (BCM_FAILURE(__rv__)) { \
     69             cli_out("WLAN_CLI: Error: " #op " failed, %s\n", \
     70                     bcm_errmsg(__rv__)); \
     71             return CMD_FAIL; \
     72         } \
     73     } while(0)
     74 #define WLAN_CMD(_s)                         \
     75     if ((cmd = ARG_CUR(a)) == NULL) {        \
     76         ARG_PREV(a);  \
     77         cli_out("WLAN_CLI: Error: Missing arg after %s\n", ARG_CUR(a)); \
     78         return CMD_USAGE;                    \
     79     } else if(sal_strcasecmp(cmd, _s) == 0)
     80 
     81 #define PT_ADD(_pt, _id, _typ, _arg) \
     82     parse_table_add(&_pt, (_id), PQ_DFL | (_typ), \
     83                     (void *)(_arg), (void*)(_arg), 0)
     84 
     85 #define PT_INIT(_u, _pt) parse_table_init(_u, &_pt); \
     86 
     87 #define PT_DONE(_pt) parse_arg_eq_done(&pt);
     88 
     89 #define PT_PARSE(_a, _pt) \
     90     do {     \
     91         if (parse_arg_eq(_a, &_pt) < 0) { \
     92             cli_out("WLAN_CLI: Error: Invalid option or expression: %s\n", \
     93                     ARG_CUR(_a)); \
     94             PT_DONE(_pt); \
     95             return CMD_USAGE; \
     96         } \
     97     } while(0)
     98 
     99 typedef struct _bcm_tr2_wlan_flag_s {
    100     char      *name;
    101     uint32     val; 
    102 } _bcm_tr2_wlan_flag_t;
    103 
    104 STATIC _bcm_tr2_wlan_flag_t wlan_port_flags[] = {
    105     {"RePLace", BCM_WLAN_PORT_REPLACE},
    106     {"WithID", BCM_WLAN_PORT_WITH_ID},
    107     {"DRop", BCM_WLAN_PORT_DROP},
    108     {"Network", BCM_WLAN_PORT_NETWORK},
    109     {"BSSid", BCM_WLAN_PORT_BSSID},
    110     {"BSSidRadioId",  BCM_WLAN_PORT_BSSID_RADIO},
    111     {"MatchTunnel", BCM_WLAN_PORT_MATCH_TUNNEL},
    112     {"EgressClientMultiCast",  BCM_WLAN_PORT_EGRESS_CLIENT_MULTICAST},
    113     {"EgressBSSid", BCM_WLAN_PORT_EGRESS_BSSID},
    114     {"EgressTunnelRemote", BCM_WLAN_PORT_EGRESS_TUNNEL_REMOTE},
    115     {NULL, 0}
    116 };
    117 
    118 STATIC _bcm_tr2_wlan_flag_t wlan_client_flags[] = {
    119     {"RePLace", BCM_WLAN_CLIENT_REPLACE},
    120     {"RoamedIn", BCM_WLAN_CLIENT_ROAMED_IN},
    121     {"RoamedOut", BCM_WLAN_CLIENT_ROAMED_OUT},
    122     {"Authorized", BCM_WLAN_CLIENT_AUTHORIZED},
    123     {"Captive", BCM_WLAN_CLIENT_CAPTIVE},
    124     {NULL, 0}
    125 };
    126 
    127 STATIC _bcm_tr2_wlan_flag_t wlan_tunnel_flags[] = {
    128     {"RePLace", BCM_TUNNEL_REPLACE},
    129     {"WithID", BCM_TUNNEL_INIT_WLAN_TUNNEL_WITH_ID},
    130     {"VlanTagged", BCM_TUNNEL_INIT_WLAN_VLAN_TAGGED},
    131     {"MTU", BCM_TUNNEL_INIT_WLAN_MTU},
    132     {"IDRandom", BCM_TUNNEL_INIT_IP4_ID_SET_RANDOM},
    133     {"IDFixed",  BCM_TUNNEL_INIT_IP4_ID_SET_FIXED},
    134     {"DF", BCM_TUNNEL_INIT_SET_DF},
    135     {"UseInnerDF",  BCM_TUNNEL_INIT_USE_INNER_DF},
    136     {NULL, 0}
    137 };
    138 
    139 int    _bcm_tr2_wlan_cli_port_add(int unit, args_t * a);
    140 int    _bcm_tr2_wlan_cli_port_del(int unit, args_t * a);
    141 int    _bcm_tr2_wlan_cli_port_del_all(int unit, args_t * a);
    142 int    _bcm_tr2_wlan_cli_port_get(int unit, args_t * a);
    143 int    _bcm_tr2_wlan_cli_port_get_all(int unit, args_t * a);
    144 int    _bcm_tr2_wlan_cli_port_print(int unit, bcm_wlan_port_t *wport, 
    145                                         void *user_data);
    146 int    _bcm_tr2_wlan_cli_client_add(int unit, args_t * a);
    147 int    _bcm_tr2_wlan_cli_client_del(int unit, args_t * a);
    148 int    _bcm_tr2_wlan_cli_client_del_all(int unit, args_t * a);
    149 int    _bcm_tr2_wlan_cli_client_get(int unit, args_t * a);
    150 int    _bcm_tr2_wlan_cli_client_get_all(int unit, args_t * a);
    151 int    _bcm_tr2_wlan_cli_client_print(int unit, bcm_wlan_client_t *client, 
    152                                       void *user_data);
    153 int    _bcm_tr2_wlan_tunnel_init_create(int unit, args_t *a);
    154 int    _bcm_tr2_wlan_tunnel_init_destroy(int unit, args_t *a);
    155 int    _bcm_tr2_wlan_tunnel_init_show(int unit, args_t *a);
    156 void   _bcm_tr2_wlan_tunnel_init_print(int unit, bcm_tunnel_initiator_t *info);
    157 int    _bcm_tr2_wlan_cli_mcast_group_create(int unit, args_t * a);
    158 int    _bcm_tr2_wlan_cli_mcast_group_del(int unit, args_t * a);
    159 int    _bcm_tr2_wlan_cli_mcast_group_port_add_del(int unit, args_t * a);
    160 int    _bcm_tr2_wlan_cli_mcast_group_addr(int unit, args_t * a);
    161 int    _bcm_tr2_wlan_cli_print_options(int unit, args_t * a);
    162 int    _bcm_tr2_wlan_cli_action(int unit, args_t * a);
    163 int    _bcm_tr2_wlan_cli_parse_flags(char *elo_s, int type);
    164 
    165 
    166 char       if_tr2_wlan_usage[] = "Only for XGS4 devices.\n\t"
    167 #ifdef COMPILER_STRING_CONST_LIMIT
    168     "  wlan <option> [args...]\n"
    169 #else
    170     "  wlan init\n\t"
    171     "        - Init WLAN software system.\n\t"
    172     "  wlan detach\n\t"
    173     "        - Detach WLAN software system.\n\t"
    174     "  wlan port add Port=<Wlan_port> PhysPort=<port>\n\t"
    175     "                FLaGs=<flags> IntfCLass=<class>\n\t"
    176     "                BSSid<bssid> RadioID=<radio_id>\n\t"
    177     "                MatchTunnel=<tunnel_id> EgressTunnel=<tunnel_id>\n\t"
    178     "                EgressClientMultiCast=<client_mc_bitmap>\n\t"
    179     "        - Add a WLAN port.\n\t"
    180     "  wlan port delete Port=<wlan_port_id>\n\t"
    181     "        - Delete a WLAN port.\n\t"
    182     "  wlan port clear\n\t"
    183     "        - Delete all WLAN ports.\n\t"
    184     "  wlan port get Port=<wlan_port_id>\n\t"
    185     "        - Display a WLAN port information.\n\t"
    186     "  wlan port show\n\t"
    187     "        - Traverse all WLAN ports.\n\t"
    188     "  wlan client add FLaGs=<flags> WlanPort=<Wlan_port_id>\n\t"
    189     "                MAC=<client_mac_addr> HomeAgent=<home_agent_gport> \n\t"
    190     "                WTP=<access_point_gport>\n\t"
    191     "        - Add a WLAN client.\n\t"
    192     "  wlan client delete MAC=<client_mac>\n\t"
    193     "        - Delete a WLAN client.\n\t"
    194     "  wlan client clear\n\t"
    195     "        - Delete all WLAN clients.\n\t"
    196     "  wlan client get MAC=<client_mac>\n\t"
    197     "        - Display a WLAN client information.\n\t"
    198     "  wlan client show\n\t"
    199     "        - Traverse all WLAN clients.\n\t"
    200     "  wlan mcast group create [l2|wlan] McastGroup=<mcast_group>\n\t"
    201     "        - Create a multicast group.\n\t"
    202     "  wlan mcast group delete McastGroup=<mcast_group>\n\t"
    203     "        - Delete a multicast group.\n\t"
    204     "  wlan mcast group port add McastGroup=<mcast_type_id>\n\t"
    205     "                            WlanPort=<wlan_port_id>\n\t"
    206     "        - Add WLAN port to multicast group.\n\t"
    207     "  wlan mcast group port delete  McastGroup=<mcast_type_id>\n\t"
    208     "                                WlanPort=<wlan_port_id>\n\t"
    209     "        - Delete WLAN port from multicast group\n\t"
    210     "  wlan mcast group addr McastGroup=<mcast_type_id>\n\t"
    211     "                        Mac=<mcast mac> VLAN=<vlan_id>\n\t"
    212     "        - Add multicast group Mac address.\n\t"
    213     "  wlan tunnel initiator create FLaGs=<flags> TYpe=<type> TTL=<ttl>\n\t"
    214     "                               DstMac=<mac> DIP=<ip> SIP=<ip>\n\t"
    215     "                               DIP6=<ip6> SIP6=<ip6> DSCPSel=<num>\n\t"
    216     "                               DSCPV=<val> DFSEL4=<num> DFSEL6=<num>\n\t"
    217     "                               DSCPMap=<mapID> TunnelID=<tid>\n\t"
    218     "                               L4DstPort=<port> L4SrcPort<port>\n\t"
    219     "                               SrcMac=<mac> MTU=<mtu> VID=<vid>\n\t"
    220     "                               TPID=<tpid> PktPri=<pri> PktCfi=<cfi>\n\t"
    221     "                               Ipv4ID=<val>\n\t"
    222     "        - Create a WLAN (CAPWAP) tunnel initiator.\n\t"
    223     "  wlan tunnel initiator destroy TunnelID=<tid>\n\t"
    224     "        - Destroy a WLAN (CAPWAP) tunnel initiator.\n\t"
    225     "  wlan tunnel initiator get TunnelID=<tid>\n\t"
    226     "        - Get a WLAN (CAPWAP) tunnel initiator.\n\t"
    227     "  wlan options Type=[PORT|CLIENT|TUNNEL]\n\t"
    228     "        - List various options/flags used in wlan commands.\n\t" "\n"
    229 #endif
    230           ;
    231 
    232 cmd_result_t
    233 if_tr2_wlan(int unit, args_t * a)
    234 {
    235     int        action = 0;
    236     cmd_result_t cmd_rv = CMD_OK;
    237 
    238     if (!sh_check_attached(ARG_CMD(a), unit)) {
    239         return CMD_FAIL;
    240     }
    241 
    242     if (ARG_CUR(a) == NULL) {
    243         return CMD_USAGE;
    244     }
    245 
    246     action = _bcm_tr2_wlan_cli_action(unit, a);
    247 
    248     switch (action) {
    249         case WLAN_INIT:
    250             WLAN_ROE(bcm_wlan_init, (unit));
    251             break;
    252         case WLAN_DETACH:
    253             WLAN_ROE(bcm_wlan_detach, (unit));
    254             break;
    255         case WLAN_PORT_ADD:
    256             cmd_rv = _bcm_tr2_wlan_cli_port_add(unit, a);
    257             break;
    258         case WLAN_PORT_DEL:
    259             cmd_rv = _bcm_tr2_wlan_cli_port_del(unit, a);
    260             break;
    261         case WLAN_PORT_DEL_ALL:
    262             cmd_rv = _bcm_tr2_wlan_cli_port_del_all(unit, a);
    263             break;
    264         case WLAN_PORT_GET:
    265             cmd_rv = _bcm_tr2_wlan_cli_port_get(unit, a);
    266             break;
    267         case WLAN_PORT_GET_ALL:
    268             cmd_rv = _bcm_tr2_wlan_cli_port_get_all(unit, a);
    269             break;
    270         case WLAN_CLIENT_ADD:
    271             cmd_rv = _bcm_tr2_wlan_cli_client_add(unit, a);
    272             break;
    273         case WLAN_CLIENT_DEL:
    274             cmd_rv = _bcm_tr2_wlan_cli_client_del(unit, a);
    275             break;
    276         case WLAN_CLIENT_DEL_ALL:
    277             cmd_rv = _bcm_tr2_wlan_cli_client_del_all(unit, a);
    278             break;
    279         case WLAN_CLIENT_GET:
    280             cmd_rv = _bcm_tr2_wlan_cli_client_get(unit, a);
    281             break;
    282         case WLAN_CLIENT_GET_ALL:
    283             cmd_rv = _bcm_tr2_wlan_cli_client_get_all(unit, a);
    284             break;
    285         case WLAN_TUNNEL_INIT_CREATE:
    286             cmd_rv = _bcm_tr2_wlan_tunnel_init_create(unit, a);
    287             break;
    288         case WLAN_TUNNEL_INIT_DESTROY:
    289             cmd_rv = _bcm_tr2_wlan_tunnel_init_destroy(unit, a);
    290             break;
    291         case WLAN_TUNNEL_INIT_GET:
    292             cmd_rv = _bcm_tr2_wlan_tunnel_init_show(unit, a);
    293             break;
    294         case WLAN_MCAST_GROUP_CREATE:
    295             cmd_rv = _bcm_tr2_wlan_cli_mcast_group_create(unit, a);
    296             break;
    297         case WLAN_MCAST_GROUP_DEL:
    298             cmd_rv = _bcm_tr2_wlan_cli_mcast_group_del(unit, a);
    299             break;
    300         case WLAN_MCAST_GROUP_PORT_ADD:
    301         case WLAN_MCAST_GROUP_PORT_DEL:
    302             cmd_rv = _bcm_tr2_wlan_cli_mcast_group_port_add_del(unit, a);
    303             break;
    304         case WLAN_MCAST_GROUP_ADDR:
    305             cmd_rv = _bcm_tr2_wlan_cli_mcast_group_addr(unit, a);
    306             break;
    307         case WLAN_OPTIONS:
    308             cmd_rv = _bcm_tr2_wlan_cli_print_options(unit, a);
    309             break;
    310         default:
    311             cli_out("Error:Unknown WLAN command %d\n", action);
    312             return CMD_USAGE;
    313     }
    314 
    315     ARG_DISCARD(a);
    316     return cmd_rv;
    317 }
    318 
    319 int
    320 _bcm_tr2_wlan_cli_port_add(int unit, args_t * a)
    321 {
    322     parse_table_t pt;
    323     bcm_port_t port = -1;
    324     bcm_port_t phys_port = -1;
    325     int        icl = 0;
    326     int        rid = 0;
    327     char      *ifl_s = 0;
    328     uint32     ifl = 0;
    329     int        wcmc = 0;
    330     bcm_wlan_port_t wport;
    331     bcm_mac_t  bssid;
    332     bcm_gport_t mtunnel = BCM_GPORT_INVALID;
    333     bcm_gport_t etunnel = BCM_GPORT_INVALID;
    334     bcm_gport_t gp = BCM_GPORT_INVALID; 
    335    
    336     sal_memset(bssid, 0, sizeof(bcm_mac_t));
    337     ARG_NEXT(a);
    338     PT_INIT(unit, pt);
    339     PT_ADD(pt, "FLaGs", PQ_STRING, &ifl_s);
    340     PT_ADD(pt, "Port", PQ_PORT, &port);
    341     PT_ADD(pt, "PhysPort", PQ_INT, &phys_port);
    342     PT_ADD(pt, "IntfCLass", PQ_INT, &icl);
    343     PT_ADD(pt, "BSSid", PQ_MAC, bssid);
    344     PT_ADD(pt, "RadioID", PQ_INT, &rid);
    345     PT_ADD(pt, "MatchTunnel", PQ_INT, &mtunnel);
    346     PT_ADD(pt, "EgressTunnel", PQ_INT, &etunnel);
    347     PT_ADD(pt, "EgressClientMultiCast", PQ_INT, &wcmc);
    348 
    349     PT_PARSE(a, pt);
    350 
    351     if (ifl_s) {
    352         ifl = _bcm_tr2_wlan_cli_parse_flags(ifl_s, BCM_WLAN_PORT);
    353     }
    354     LOG_INFO(BSL_LS_APPL_TESTS,
    355              (BSL_META_U(unit,
    356                          "Adding port %d FLaGs=%s PhysPort=%d icl=%d\n"
    357                          "BSSid=%02x:%02x:%02x:%02x:%02x:%02x\n"
    358                          "RadioID=%d MatchTunnel=%x EgressTunnel=%x\n"
    359                          "EgressClientMultiCast=%04x\n"),
    360               port, ifl_s, phys_port, icl, bssid[0], bssid[1], bssid[2],
    361               bssid[3], bssid[4], bssid[5], rid, mtunnel, etunnel, wcmc));
    362 
    363     PT_DONE(pt);
    364     bcm_wlan_port_t_init(&wport);
    365     if (ifl & (BCM_WLAN_PORT_REPLACE | BCM_WLAN_PORT_WITH_ID)) {
    366         BCM_GPORT_WLAN_PORT_ID_SET(wport.wlan_port_id, port);
    367         LOG_INFO(BSL_LS_APPL_TESTS,
    368                  (BSL_META_U(unit,
    369                              "wlan port=%08x\n"), port));
    370     }
    371     WLAN_ROE(bcm_port_gport_get, (unit, phys_port, &gp));
    372     wport.port = gp;
    373     LOG_INFO(BSL_LS_APPL_TESTS,
    374              (BSL_META_U(unit,
    375                          "gport_get gp=%08x\n"), gp));
    376     wport.flags = ifl;
    377     wport.if_class = icl;
    378     memcpy(wport.bssid, bssid, sizeof(sal_mac_addr_t));
    379     wport.radio = rid;
    380     wport.match_tunnel = mtunnel;
    381     wport.egress_tunnel = etunnel;
    382     wport.client_multicast = wcmc;
    383 
    384     WLAN_ROE(bcm_wlan_port_add, (unit, &wport));
    385     var_set_integer(ENV_WLAN_TYPE_ID, wport.wlan_port_id, TRUE, FALSE);
    386     cli_out("env var added : $wlan_port_id=0x%08x\n", wport.wlan_port_id);
    387 
    388     return CMD_OK;
    389 }
    390 
    391 int
    392 _bcm_tr2_wlan_cli_port_del(int unit, args_t * a)
    393 {
    394     parse_table_t pt;
    395     bcm_gport_t gp = BCM_GPORT_INVALID;
    396     ARG_NEXT(a);
    397 
    398     PT_INIT(unit, pt);
    399     PT_ADD(pt, "Port", PQ_PORT, &gp);
    400     PT_PARSE(a, pt);
    401     PT_DONE(pt);
    402     WLAN_ROE(bcm_wlan_port_delete, (unit, gp));
    403 
    404     return CMD_OK;
    405 }
    406 
    407 int
    408 _bcm_tr2_wlan_cli_port_del_all(int unit, args_t * a)
    409 {
    410     ARG_NEXT(a);
    411     WLAN_ROE(bcm_wlan_port_delete_all, (unit));
    412     return CMD_OK;
    413 }
    414 
    415 int
    416 _bcm_tr2_wlan_cli_port_get(int unit, args_t * a)
    417 {
    418     parse_table_t pt;
    419     bcm_gport_t gp = BCM_GPORT_INVALID;
    420     bcm_wlan_port_t wport;
    421     ARG_NEXT(a);
    422 
    423     bcm_wlan_port_t_init(&wport);
    424     PT_INIT(unit, pt);
    425     PT_ADD(pt, "Port", PQ_PORT, &gp);
    426     PT_PARSE(a, pt);
    427     PT_DONE(pt);
    428     WLAN_ROE(bcm_wlan_port_get, (unit, gp, &wport));
    429     WLAN_ROE(_bcm_tr2_wlan_cli_port_print, (unit, &wport, NULL));
    430 
    431     return CMD_OK;
    432 }
    433 
    434 int
    435 _bcm_tr2_wlan_cli_port_get_all(int unit, args_t * a)
    436 {
    437     ARG_NEXT(a);
    438     WLAN_ROE(bcm_wlan_port_traverse,(unit, _bcm_tr2_wlan_cli_port_print, NULL));
    439     return CMD_OK;
    440 }
    441 
    442 int
    443 _bcm_tr2_wlan_cli_client_add(int unit, args_t * a)
    444 {
    445     parse_table_t pt;
    446     bcm_mac_t  mac;
    447     bcm_wlan_client_t client;
    448     bcm_gport_t ha = BCM_GPORT_INVALID;
    449     bcm_gport_t wtp = BCM_GPORT_INVALID;
    450     bcm_gport_t wlan_port = BCM_GPORT_INVALID; 
    451     char      *cfl_s = 0;
    452     uint32     cfl = 0;   
    453 
    454     sal_memset(mac, 0, sizeof(bcm_mac_t));
    455     ARG_NEXT(a);
    456     PT_INIT(unit, pt);
    457     PT_ADD(pt, "FLaGs", PQ_STRING, &cfl_s);
    458     PT_ADD(pt, "WlanPort", PQ_INT, &wlan_port);
    459     PT_ADD(pt, "MAC", PQ_MAC, mac);
    460     PT_ADD(pt, "HomeAgent", PQ_INT, &ha);
    461     PT_ADD(pt, "WTP", PQ_INT, &wtp);
    462 
    463     PT_PARSE(a, pt);
    464 
    465     if (cfl_s) {
    466         cfl = _bcm_tr2_wlan_cli_parse_flags(cfl_s, BCM_WLAN_CLIENT);
    467     }
    468     LOG_INFO(BSL_LS_APPL_TESTS,
    469              (BSL_META_U(unit,
    470                          "Adding client FLaGs=%s WlanPort=%d\n"
    471                          "MAC=%02x:%02x:%02x:%02x:%02x:%02x\n"
    472                          "HomeAgent=%x WTP=%x\n"),
    473               cfl_s, wlan_port, mac[0], mac[1], mac[2],
    474               mac[3], mac[4], mac[5], ha, wtp));
    475 
    476     bcm_wlan_client_t_init(&client);
    477     client.flags = cfl;
    478     memcpy(client.mac, mac, sizeof(sal_mac_addr_t));
    479     client.home_agent = ha;
    480     client.wtp = wtp;
    481 
    482     PT_DONE(pt);
    483     WLAN_ROE(bcm_wlan_client_add, (unit, &client));
    484 
    485     return CMD_OK;
    486 }
    487 
    488 int
    489 _bcm_tr2_wlan_cli_client_del(int unit, args_t * a)
    490 {
    491     parse_table_t pt;
    492     bcm_mac_t mac;
    493     bcm_wlan_client_t client;
    494     ARG_NEXT(a);
    495 
    496     bcm_wlan_client_t_init(&client);
    497     sal_memset(mac, 0, sizeof(bcm_mac_t));
    498     PT_INIT(unit, pt);
    499     PT_ADD(pt, "MAC", PQ_MAC, mac);
    500     PT_PARSE(a, pt);
    501     PT_DONE(pt);
    502     WLAN_ROE(bcm_wlan_client_delete, (unit, mac));
    503 
    504     return CMD_OK;
    505 }
    506 
    507 int
    508 _bcm_tr2_wlan_cli_client_del_all(int unit, args_t * a)
    509 {
    510     ARG_NEXT(a);
    511     WLAN_ROE(bcm_wlan_client_delete_all, (unit));
    512     return CMD_OK;
    513 }
    514 
    515 int
    516 _bcm_tr2_wlan_cli_client_get(int unit, args_t * a)
    517 {
    518     parse_table_t pt;
    519     bcm_mac_t mac;
    520     bcm_wlan_client_t client;
    521     ARG_NEXT(a);
    522 
    523     bcm_wlan_client_t_init(&client);
    524     sal_memset(mac, 0, sizeof(bcm_mac_t));
    525     PT_INIT(unit, pt);
    526     PT_ADD(pt, "MAC", PQ_MAC, mac);
    527     PT_PARSE(a, pt);
    528     PT_DONE(pt);
    529     WLAN_ROE(bcm_wlan_client_get, (unit, mac, &client));
    530     WLAN_ROE(_bcm_tr2_wlan_cli_client_print, (unit, &client, NULL));
    531 
    532     return CMD_OK;
    533 }
    534 
    535 int
    536 _bcm_tr2_wlan_cli_client_get_all(int unit, args_t * a)
    537 {
    538     ARG_NEXT(a);
    539     WLAN_ROE(bcm_wlan_client_traverse, (unit, _bcm_tr2_wlan_cli_client_print, 
    540                                         NULL));
    541     return CMD_OK;
    542 }
    543 
    544 int
    545 _bcm_tr2_wlan_tunnel_init_create(int unit, args_t *a) 
    546 {
    547     bcm_tunnel_initiator_t tunnel_init;
    548     bcm_tunnel_type_t type = 0;
    549     parse_table_t     pt;     
    550     bcm_ip6_t         sip6_addr;
    551     bcm_ip6_t         ip6_addr;
    552     bcm_mac_t         dst_mac, src_mac;
    553     bcm_ip_t          sip_addr = 0;
    554     bcm_ip_t          ip_addr = 0;
    555     int               ip4_df_sel = 0;
    556     int               ip6_df_sel = 0;
    557     int               dscp_val = 0;
    558     int               dscp_sel = 0;
    559     int               dscp_map = 0;
    560     int               ttl = 0;
    561     int               rv;
    562     int               tid;
    563     uint32            tfl = 0;
    564     char              *tfl_s = 0;
    565     int               tpid = 0x8100;
    566     int               vid = BCM_VLAN_INVALID;
    567     int               mtu = 0;
    568     int               src_port = 0;
    569     int               dst_port = 0;
    570     int               pkt_pri = 0;
    571     int               pkt_cfi = 0;
    572     int               ip4_id = 0;
    573 
    574     /* Stack variables initialization. */
    575     sal_memset(sip6_addr, 0, sizeof(bcm_ip6_t));
    576     sal_memset(ip6_addr, 0, sizeof(bcm_ip6_t));
    577     sal_memset(dst_mac, 0, sizeof(bcm_mac_t));
    578     sal_memset(src_mac, 0, sizeof(bcm_mac_t));
    579 
    580     ARG_NEXT(a);
    581     PT_INIT(unit, pt);
    582     PT_ADD(pt, "FLaGs", PQ_STRING, &tfl_s);
    583     PT_ADD(pt, "TYpe", PQ_INT, &type);
    584     PT_ADD(pt, "TTL",  PQ_INT, &ttl);
    585     PT_ADD(pt, "DstMac",  PQ_MAC, dst_mac);
    586     PT_ADD(pt, "DIP",  PQ_IP, &ip_addr);
    587     PT_ADD(pt, "SIP",  PQ_IP, &sip_addr);
    588     PT_ADD(pt, "DIP6", PQ_IP6, &ip6_addr);
    589     PT_ADD(pt, "SIP6", PQ_IP6, &sip6_addr);
    590     PT_ADD(pt, "DSCPSel", PQ_INT, &dscp_sel);
    591     PT_ADD(pt, "DSCPV", PQ_INT, &dscp_val);
    592     PT_ADD(pt, "DFSEL4", PQ_INT, &ip4_df_sel);
    593     PT_ADD(pt, "DFSEL6", PQ_BOOL, &ip6_df_sel);
    594     PT_ADD(pt, "DSCPMap", PQ_INT, &dscp_map);
    595     PT_ADD(pt, "TunnelID", PQ_INT, &tid);
    596     PT_ADD(pt, "L4DstPort", PQ_INT, &dst_port);
    597     PT_ADD(pt, "L4SrcPort", PQ_INT, &src_port);
    598     PT_ADD(pt, "SrcMac",  PQ_MAC, src_mac);
    599     PT_ADD(pt, "MTU", PQ_INT, &mtu);
    600     PT_ADD(pt, "VID", PQ_INT, &vid);
    601     PT_ADD(pt, "TPID", PQ_INT, &tpid);
    602     PT_ADD(pt, "PktPri", PQ_INT, &pkt_pri);
    603     PT_ADD(pt, "PktCfi", PQ_INT, &pkt_cfi);
    604     PT_ADD(pt, "Ipv4ID", PQ_INT, &ip4_id);
    605 
    606     PT_PARSE(a, pt);
    607 
    608     if (tfl_s) {
    609         tfl = _bcm_tr2_wlan_cli_parse_flags(tfl_s, BCM_WLAN_TUNNEL);
    610     }
    611     PT_DONE(pt);
    612 
    613     /* Initialize data structures. */
    614     bcm_tunnel_initiator_t_init(&tunnel_init);
    615 
    616     /* Fill tunnel info. */
    617     tunnel_init.flags = tfl;
    618     tunnel_init.type = type;
    619     tunnel_init.ttl = ttl;
    620 
    621     sal_memcpy(tunnel_init.dmac, dst_mac, sizeof(dst_mac));
    622     sal_memcpy(tunnel_init.smac, src_mac, sizeof(src_mac));
    623 
    624     if (ip4_df_sel) { 
    625         tunnel_init.flags |= (ip4_df_sel > 1) ?
    626             BCM_TUNNEL_INIT_USE_INNER_DF : BCM_TUNNEL_INIT_IPV4_SET_DF;
    627     }
    628     if (ip6_df_sel) { 
    629         tunnel_init.flags |= BCM_TUNNEL_INIT_IPV6_SET_DF;
    630     }
    631 
    632     sal_memcpy(tunnel_init.dip6, ip6_addr, sizeof(bcm_ip6_t));
    633     sal_memcpy(tunnel_init.sip6, sip6_addr, sizeof(bcm_ip6_t));
    634     tunnel_init.dip = ip_addr;
    635     tunnel_init.sip = sip_addr;
    636     tunnel_init.dscp_sel = dscp_sel;
    637     tunnel_init.dscp = dscp_val;
    638     tunnel_init.dscp_map = dscp_map;
    639     if (tfl & BCM_TUNNEL_INIT_WLAN_MTU) {
    640         tunnel_init.mtu = mtu;
    641     }
    642     tunnel_init.vlan = vid;
    643     tunnel_init.tpid = tpid;
    644     tunnel_init.pkt_pri = pkt_pri;
    645     tunnel_init.pkt_cfi = pkt_cfi;
    646     tunnel_init.ip4_id = ip4_id;
    647 
    648     if ((rv = bcm_wlan_tunnel_initiator_create(unit, &tunnel_init)) < 0) {
    649         cli_out("ERROR %s: creating tunnel initiator %s\n",
    650                 ARG_CMD(a), bcm_errmsg(rv));
    651         return CMD_FAIL;
    652     }
    653     return CMD_OK;
    654 }
    655 
    656 int
    657 _bcm_tr2_wlan_tunnel_init_destroy(int unit, args_t *a) 
    658 {
    659     bcm_gport_t            tunnel_id = BCM_GPORT_INVALID;
    660     parse_table_t          pt;     
    661     int                    rv;
    662 
    663     PT_INIT(unit, pt);
    664     PT_ADD(pt, "TunnelID", PQ_INT, &tunnel_id);
    665 
    666     PT_PARSE(a, pt);
    667     PT_DONE(pt);
    668 
    669     if ((rv = bcm_wlan_tunnel_initiator_destroy(unit, tunnel_id)) < 0) {
    670         cli_out("ERROR %s: destroying tunnel initiator for %d %s\n",
    671                 ARG_CMD(a), tunnel_id, bcm_errmsg(rv));
    672         return CMD_FAIL;
    673     }
    674     return CMD_OK;
    675 }
    676 
    677 int
    678 _bcm_tr2_wlan_tunnel_init_show(int unit, args_t *a) 
    679 {
    680     bcm_tunnel_initiator_t tunnel_init;
    681     parse_table_t          pt;     
    682     bcm_gport_t            tunnel_id = BCM_GPORT_INVALID;
    683     int                    rv;
    684 
    685     PT_INIT(unit, pt);
    686     PT_ADD(pt, "TunnelID", PQ_INT, &tunnel_id);
    687 
    688     PT_PARSE(a, pt);
    689     PT_DONE(pt);
    690 
    691     bcm_tunnel_initiator_t_init(&tunnel_init);
    692     tunnel_init.tunnel_id = tunnel_id;
    693 
    694     if ((rv = bcm_wlan_tunnel_initiator_get(unit, &tunnel_init)) < 0) {
    695         cli_out("ERROR %s: getting tunnel initiator for %d %s\n",
    696                 ARG_CMD(a), tunnel_id, bcm_errmsg(rv));
    697         return CMD_FAIL;
    698     }
    699 
    700     _bcm_tr2_wlan_tunnel_init_print(unit, &tunnel_init);
    701     return CMD_OK;
    702 }
    703 
    704 void
    705 _bcm_tr2_wlan_tunnel_init_print(int unit, bcm_tunnel_initiator_t *info)
    706 {
    707     char ip_str[IP6ADDR_STR_LEN + 3];
    708     char if_mac_str[SAL_MACADDR_STR_LEN];
    709 
    710     cli_out("Tunnel initiator:\n");
    711     cli_out("\tUnit        = %d\n", unit);
    712     cli_out("\tTunnel ID   = %d\n", info->tunnel_id);
    713     cli_out("\tTUNNEL_TYPE = %d\n", info->type);
    714     cli_out("\tTTL         = %d\n", info->ttl);
    715     format_macaddr(if_mac_str, info->smac);
    716     cli_out("\tSRC MAC_ADDR    = %-18s\n", if_mac_str);
    717     format_macaddr(if_mac_str, info->dmac);
    718     cli_out("\tDST MAC_ADDR    = %-18s\n", if_mac_str);
    719     if (_BCM_TUNNEL_OUTER_HEADER_IPV6(info->type)) { 
    720         format_ip6addr(ip_str, info->dip6);
    721         cli_out("\tDIP         = 0x%-s\n", ip_str);
    722         format_ip6addr(ip_str, info->sip6);
    723         cli_out("\tSIP         = 0x%-s\n", ip_str);
    724     } else { 
    725         cli_out("\tDIP         = 0x%08x\n", info->dip);
    726         cli_out("\tSIP         = 0x%08x\n", info->sip);
    727         if (info->flags & BCM_TUNNEL_INIT_USE_INNER_DF) {
    728             cli_out("\tCopy DF from inner header.\n");
    729         } else if (info->flags & BCM_TUNNEL_INIT_IPV4_SET_DF) {
    730             cli_out("\tForce DF to 1 for ipv4 payload.\n");
    731         }
    732         if (info->flags & BCM_TUNNEL_INIT_IPV6_SET_DF) {
    733             cli_out("\tForce DF to 1 for ipv6 payload.\n");
    734         }
    735     }
    736     cli_out("\tDSCP_SEL    = 0x%x\n", info->dscp_sel);
    737     cli_out("\tDSCP        = 0x%x\n", info->dscp);
    738     cli_out("\tDSCP_MAP    = 0x%x\n", info->dscp_map);
    739     return;
    740 }
    741 
    742 int
    743 _bcm_tr2_wlan_cli_mcast_group_create(int unit, args_t * a)
    744 {
    745     int        flags = -1;
    746     int        mcast_group = BCM_VLAN_INVALID;
    747     char      *cmd;
    748     parse_table_t pt;
    749 
    750     ARG_NEXT(a);                /* wlan,l2 etc. */
    751     WLAN_CMD("l2") {
    752         flags = BCM_MULTICAST_TYPE_L2;
    753     }
    754     WLAN_CMD("wlan") {
    755         flags = BCM_MULTICAST_TYPE_WLAN;
    756     }
    757     ARG_NEXT(a);
    758     PT_INIT(unit, pt);
    759     PT_ADD(pt, "McastGroup", PQ_INT, &mcast_group);
    760     PT_PARSE(a, pt);
    761     LOG_INFO(BSL_LS_APPL_TESTS,
    762              (BSL_META_U(unit,
    763                          "mcast group %d\n"), mcast_group));
    764     flags |= BCM_MULTICAST_WITH_ID;
    765     PT_DONE(pt);
    766     WLAN_ROE(bcm_multicast_create, (unit, flags, &mcast_group));
    767     var_set_integer(ENV_MCAST_TYPE_ID, mcast_group, TRUE, FALSE);
    768     cli_out("env var added : $mcast_type_id=0x%08x\n", mcast_group);
    769 
    770     return CMD_OK;
    771 }
    772 
    773 int
    774 _bcm_tr2_wlan_cli_mcast_group_del(int unit, args_t * a)
    775 {
    776     int        mcast_group = BCM_VLAN_INVALID;
    777     parse_table_t pt;
    778 
    779     ARG_NEXT(a);
    780     PT_INIT(unit, pt);
    781     PT_ADD(pt, "McastGroup", PQ_INT, &mcast_group);
    782     PT_PARSE(a, pt);
    783     PT_DONE(pt);
    784     WLAN_ROE(bcm_multicast_destroy, (unit, mcast_group));
    785     LOG_INFO(BSL_LS_APPL_TESTS,
    786              (BSL_META_U(unit,
    787                          "mcast group %d destroyed\n"), mcast_group));
    788 
    789     return CMD_OK;
    790 }
    791 
    792 int
    793 _bcm_tr2_wlan_cli_mcast_group_port_add_del(int unit, args_t * a)
    794 {
    795     int        add = 0;
    796     int        mcast_group = BCM_VLAN_INVALID;
    797     bcm_module_t modid;
    798     bcm_port_t port;
    799     bcm_trunk_t trunk_id;
    800     int        id;
    801     bcm_gport_t gp = BCM_GPORT_INVALID;
    802     bcm_gport_t wlan_port;
    803     bcm_if_t   encap_id;
    804     parse_table_t pt;
    805     char      *cmd;
    806 
    807     ARG_NEXT(a);
    808     WLAN_CMD("add") {
    809         add = 1;
    810     }
    811     WLAN_CMD("delete") {
    812         add = 0;
    813     }
    814     ARG_NEXT(a);
    815     PT_INIT(unit, pt);
    816     PT_ADD(pt, "McastGroup", PQ_INT, &mcast_group);
    817     PT_ADD(pt, "WlanPort", PQ_INT, &wlan_port);
    818     PT_PARSE(a, pt);
    819     PT_DONE(pt);
    820     WLAN_ROE(_bcm_esw_gport_resolve,
    821              (unit, wlan_port, &modid, &port, &trunk_id, &id));
    822     WLAN_ROE(bcm_port_gport_get, (unit, port, &gp));
    823     WLAN_ROE(bcm_multicast_wlan_encap_get,
    824              (unit, mcast_group, gp, wlan_port, &encap_id));
    825     LOG_INFO(BSL_LS_APPL_TESTS,
    826              (BSL_META_U(unit,
    827                          "WLAN_CLI: wlan mcast group port %s wlan"
    828                          "group 0x%x gport 0x%0x wlan_port 0x%08xnh %d\n"),
    829               add ? "add" : "delete", mcast_group, gp, wlan_port,
    830               encap_id));
    831     if (add) {
    832         WLAN_ROE(bcm_multicast_egress_add,
    833                  (unit, mcast_group, gp, encap_id));
    834     } else {
    835         WLAN_ROE(bcm_multicast_egress_delete,
    836                  (unit, mcast_group, gp, encap_id));
    837     }
    838 
    839     return CMD_OK;
    840 }
    841 
    842 int
    843 _bcm_tr2_wlan_cli_mcast_group_addr(int unit, args_t * a)
    844 {
    845     int        mcast_group = BCM_VLAN_INVALID;
    846     int        vlan;
    847     bcm_mac_t  mac;
    848     bcm_l2_addr_t l2_addr;
    849     parse_table_t pt;
    850 
    851     ARG_NEXT(a);
    852     PT_INIT(unit, pt);
    853     PT_ADD(pt, "McastGroup", PQ_INT, &mcast_group);
    854     PT_ADD(pt, "Mac", PQ_MAC, mac);
    855     PT_ADD(pt, "VLAN", PQ_INT, &vlan);
    856     PT_PARSE(a, pt);
    857 
    858     bcm_l2_addr_t_init(&l2_addr, mac, vlan);
    859     l2_addr.flags = BCM_L2_STATIC | BCM_L2_MCAST;
    860     l2_addr.l2mc_group = mcast_group;
    861     PT_DONE(pt);
    862     WLAN_ROE(bcm_l2_addr_add, (unit, &l2_addr));
    863     LOG_INFO(BSL_LS_APPL_TESTS,
    864              (BSL_META_U(unit,
    865                          "mcast l2 addr add=%02x:%02x:%02x:%02x:%02x:%02x \n"),
    866               mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
    867     cli_out("WLAN_CLI: mc_group 0x%08x vlan 0x%08x\n", mcast_group, vlan);
    868     PT_DONE(pt);
    869 
    870     return CMD_OK;
    871 }
    872 
    873 int        
    874 _bcm_tr2_wlan_cli_print_options(int unit, args_t * a)
    875 {
    876     int i;
    877     char     *type_s = 0;
    878     parse_table_t pt;
    879     _bcm_tr2_wlan_flag_t *flags = 0;
    880 
    881     ARG_NEXT(a);
    882     PT_INIT(unit, pt);
    883     PT_ADD(pt, "Type", PQ_STRING, &type_s);
    884     PT_PARSE(a, pt);
    885 
    886     if (parse_cmp("CLIENT", type_s, '\0')) {
    887         flags = wlan_client_flags;
    888     } else if (parse_cmp(type_s, "PORT", '\0')) {
    889         flags = wlan_port_flags;
    890     } else if (parse_cmp(type_s, "TUNNEL", '\0')) {
    891         flags = wlan_tunnel_flags;
    892     }
    893     PT_DONE(pt);
    894 
    895     if (flags) {
    896         for (i = 0; flags[i].name != NULL; i++) {
    897             cli_out("\t%-25s  0x%08x\n", flags[i].name, flags[i].val);
    898         }
    899     } else {
    900         cli_out("Port Flags:\n\t");
    901         for (i = 0; wlan_port_flags[i].name != NULL; i++) {
    902             cli_out("%-35s  0x%08x\n\t", wlan_port_flags[i].name, 
    903                     wlan_port_flags[i].val);
    904         }
    905         cli_out("\nClient Flags:\n\t");
    906         for (i = 0; wlan_client_flags[i].name != NULL; i++) {
    907             cli_out("%-35s  0x%08x\n\t", wlan_client_flags[i].name, 
    908                     wlan_client_flags[i].val);
    909         }
    910         cli_out("\nTunnel Initiator Flags:\n\t");
    911         for (i = 0; wlan_tunnel_flags[i].name != NULL; i++) {
    912             cli_out("%-35s  0x%08x\n\t", wlan_tunnel_flags[i].name, 
    913                     wlan_tunnel_flags[i].val);
    914         }
    915         cli_out("\n");
    916     }
    917 
    918     return CMD_OK;
    919 }
    920 
    921 int
    922 _bcm_tr2_wlan_cli_action(int unit, args_t * a)
    923 {
    924     char      *cmd;
    925     int        action = -1;
    926 
    927     WLAN_CMD("init") {
    928         action = WLAN_INIT;
    929     }
    930 
    931     WLAN_CMD("detach") {
    932         action = WLAN_DETACH;
    933     }
    934 
    935     WLAN_CMD("options") {
    936         action = WLAN_OPTIONS;
    937     }
    938 
    939     WLAN_CMD("port") {
    940         ARG_NEXT(a);
    941         WLAN_CMD("add") {
    942             action = WLAN_PORT_ADD;
    943         }
    944         WLAN_CMD("delete") {
    945             action = WLAN_PORT_DEL;
    946         }
    947         WLAN_CMD("clear") {
    948             action = WLAN_PORT_DEL_ALL;
    949         }
    950         WLAN_CMD("get") {
    951             action = WLAN_PORT_GET;
    952         }
    953         WLAN_CMD("show") {
    954             action = WLAN_PORT_GET_ALL;
    955         }
    956     }
    957 
    958     WLAN_CMD("client") {
    959         ARG_NEXT(a);
    960         WLAN_CMD("add") {
    961             action = WLAN_CLIENT_ADD;
    962         }
    963         WLAN_CMD("delete") {
    964             action = WLAN_CLIENT_DEL;
    965         }
    966         WLAN_CMD("clear") {
    967             action = WLAN_CLIENT_DEL_ALL;
    968         }
    969         WLAN_CMD("get") {
    970             action = WLAN_CLIENT_GET;
    971         }
    972         WLAN_CMD("show") {
    973             action = WLAN_CLIENT_GET_ALL;
    974         }
    975     }
    976 
    977     WLAN_CMD("tunnel") {
    978         ARG_NEXT(a);
    979         WLAN_CMD("initiator") {
    980             ARG_NEXT(a);
    981             WLAN_CMD("create") {
    982                 action = WLAN_TUNNEL_INIT_CREATE;
    983             }
    984             WLAN_CMD("destroy") {
    985                 action = WLAN_TUNNEL_INIT_DESTROY;
    986             }
    987             WLAN_CMD("get") {
    988                 action = WLAN_TUNNEL_INIT_GET;
    989             }
    990         }
    991     }
    992 
    993     WLAN_CMD("mcast") {
    994         ARG_NEXT(a);
    995         WLAN_CMD("group") {
    996             ARG_NEXT(a);
    997             WLAN_CMD("create") {
    998                 action = WLAN_MCAST_GROUP_CREATE;
    999             }
   1000             WLAN_CMD("delete") {
   1001                 action = WLAN_MCAST_GROUP_DEL;
   1002             }
   1003             WLAN_CMD("port") {
   1004                 action = WLAN_MCAST_GROUP_PORT_ADD;
   1005             }
   1006             WLAN_CMD("addr") {
   1007                 action = WLAN_MCAST_GROUP_ADDR;
   1008             }
   1009         }
   1010     }
   1011 
   1012     return action;
   1013 }
   1014 
   1015 int
   1016 _bcm_tr2_wlan_cli_parse_flags(char *input_s, int type)
   1017 {
   1018     int cnt;
   1019     int len;
   1020     char *p;
   1021     char f_name[MAX_FLAG_LENGTH];
   1022     _bcm_tr2_wlan_flag_t *flags;
   1023     uint32 result = 0;
   1024     int done = 0;
   1025     int found = 0;
   1026 
   1027     if (isint(input_s)) {
   1028         result = parse_integer(input_s);
   1029         return result;
   1030     }
   1031 
   1032     switch (type) {
   1033         case BCM_WLAN_PORT:
   1034             flags = wlan_port_flags;
   1035             break;
   1036         case BCM_WLAN_CLIENT:
   1037             flags = wlan_client_flags;
   1038             break;
   1039         case BCM_WLAN_TUNNEL:
   1040             flags = wlan_tunnel_flags;
   1041             break;
   1042         default:
   1043             flags = 0;
   1044     } /* switch (type) */
   1045 
   1046     if(!flags) {
   1047         cli_out("WLAN CLI: Error: Discarded unrecognized Flags\n\t %s\n", 
   1048                 input_s);
   1049         return 0;
   1050     }
   1051 
   1052     while (!done) {
   1053         p = (char*)strcaseindex(input_s,",");
   1054         sal_memset(f_name, 0, MAX_FLAG_LENGTH); 
   1055         if (p) {
   1056             sal_strncpy(f_name, input_s, p-input_s);
   1057             input_s = p + 1;
   1058         } else {
   1059             len = (sal_strlen(input_s) >= MAX_FLAG_LENGTH) ? 
   1060                    (MAX_FLAG_LENGTH - 1) : sal_strlen(input_s);
   1061             sal_strncpy(f_name, input_s, len);
   1062             done = 1;
   1063         }
   1064         found = 0;
   1065         for (cnt = 0; flags[cnt].name ; cnt++) {
   1066             if (parse_cmp(flags[cnt].name, f_name, '\0')) {
   1067                 result |= flags[cnt].val;
   1068                 found = 1;
   1069             }
   1070         }
   1071         if (!found) {
   1072             cli_out("WLAN_CLI: flag %s not recognized, discarded\n", f_name);
   1073         }
   1074     }
   1075     return result;
   1076 
   1077 }
   1078 
   1079 int
   1080 _bcm_tr2_wlan_cli_port_print(int unit, bcm_wlan_port_t *wport, void *user_data)
   1081 {
   1082     cli_out("\n WLAN Port ID: %x", wport->wlan_port_id);
   1083     cli_out("\n Port: %x", wport->port);
   1084     cli_out("\n Interface Class: %d", wport->if_class);
   1085     cli_out("\n BSSID: %02x:%02x:%02x:%02x:%02x:%02x", wport->bssid[0], 
   1086             wport->bssid[1], wport->bssid[2], wport->bssid[3], wport->bssid[4], 
   1087             wport->bssid[5]);
   1088     cli_out("\n Radio ID: %d", wport->radio);
   1089     cli_out("\n Match Tunnel: %x", wport->match_tunnel);
   1090     cli_out("\n Egress Tunnel: %x", wport->egress_tunnel);
   1091     cli_out("\n Client Multicast Bitmap: %x", wport->client_multicast);
   1092     cli_out("\n Encap ID: %d", wport->encap_id);
   1093 
   1094     return BCM_E_NONE;
   1095 }
   1096 
   1097 int
   1098 _bcm_tr2_wlan_cli_client_print(int unit, bcm_wlan_client_t *client, 
   1099                                void *user_data)
   1100 {
   1101     cli_out("\n WLAN Port ID: %x", client->wlan_port_id);
   1102     cli_out("\n Client MAC: %02x:%02x:%02x:%02x:%02x:%02x", client->mac[0], 
   1103             client->mac[1], client->mac[2], client->mac[3], client->mac[4], 
   1104             client->mac[5]);
   1105     cli_out("\n Home Agent Port ID: %x", client->home_agent);
   1106     cli_out("\n Access Point Port ID: %x", client->wtp);
   1107 
   1108     return BCM_E_NONE;
   1109 }
   1110 
   1111 #endif /* BCM_TRIUMPH2_SUPPORT */
   1112 #endif /* INCLUDE_L3 */