Commit d75f6132 authored by Maciej Lipinski's avatar Maciej Lipinski Committed by Alessandro Rubini

[rtud/tool] Added all parameters to rtu_stat vlan adding and cleaned the code

parent dfe39cf4
......@@ -65,12 +65,14 @@ int rtudexp_add_entry(const char *eha, int port, int mode)
return (ret<0)?ret:val;
}
int rtudexp_vlan_entry(int vid, int fid, const char *ch_mask, int drop)
int rtudexp_vlan_entry(int vid, int fid, const char *ch_mask, int drop, int prio, int has_prio,
int prio_override)
{
int val, ret;
int mask;
sscanf(ch_mask,"%x", &mask);
ret = minipc_call(rtud_ch, MINIPC_TIMEOUT, &rtud_export_vlan_entry,&val,vid,fid,mask,drop);
ret = minipc_call(rtud_ch, MINIPC_TIMEOUT, &rtud_export_vlan_entry,&val,vid,fid,mask,
drop,prio,has_prio,prio_override);
return (ret<0)?ret:val;
}
......@@ -164,9 +166,12 @@ void show_help(char *prgname)
fprintf(stderr,""
" help: Show this message\n"
" list: List the routing table (same as empty command)\n"
" remove <ifnum> [<force>]: Remove all dynamic entries for one interface\n"
" add <mac (XX:XX:XX:XX:XX)> <ifnum> [<mode>]: Add entry for a specific MAC address\n"
" vlan <vid> <fid> <hex mask> [<drop>]: Add VLAN entry with vid, fid, mask and drop flag\n");
" remove <ifnum> [<force>]: Remove all dynamic entries for one interface\n"
" add <mac (XX:XX:XX:XX:XX)> <ifnum> [<mode>]: Add entry for a specific \n"
" MAC address (mode={1=dynamic,0=static}\n"
" vlan <vid> <fid> <hex mask> [<drop>, <prio>, <has_prio>, <prio_override>]: \n"
" Add VLAN entry with vid, fid, mask and drop flag (Write mask=0x0 \n"
" and drop=1 to remove the VLAN)\n");
exit(1);
}
......@@ -211,7 +216,9 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[1], "vlan")==0)
{
if((argc > 3 ) && (rtudexp_vlan_entry(atoi(argv[2]),atoi(argv[3]),argv[4],atoidef(argv[5],0))==0)) isok=1;
if((argc > 3 ) && (rtudexp_vlan_entry(atoi(argv[2]),atoi(argv[3]),argv[4],
atoidef(argv[5],0),atoidef(argv[6],0),atoidef(argv[7],0),
atoidef(argv[8],0))==0)) isok=1;
else printf("Could not %s entry for %s\n",argv[2],argv[3]);
exit(1);
}
......@@ -267,9 +274,8 @@ int main(int argc, char **argv)
else printf(" %1d ",vd_list[i].prio);
if(vd_list[i].prio_override == 0) printf(" NO ");
else printf(" YES ");
else printf(" YES ");
printf("\n");
}
printf("\n");
printf("\n");
}
......@@ -635,12 +635,12 @@ void rtu_fd_create_vlan_entry(int vid, uint32_t port_mask, uint8_t fid, uint8_t
/**
* \brief Creates or updates a filtering entry in the VLAN table.
* @param vid VLAN ID
* @return entry of VLAN table at given VID-address
* @return entry of VLAN table at given VID-address
*/
struct rtu_fd_vlan_table_entry *rtu_vlan_entry_get(int vid)
struct vlan_table_entry *rtu_vlan_entry_get(int vid)
{
// First entry reserved for untagged packets.
if(vid > NUM_VLANS) return NULL;
if(vid > NUM_VLANS) return NULL;
return &vlan_tab[vid];
}
......@@ -70,7 +70,7 @@ struct filtering_entry *rtu_fd_lookup_htab_entry(int index);
void rtu_fd_create_vlan_entry(int vid, uint32_t port_mask, uint8_t fid, uint8_t prio,
int has_prio,int prio_override, int drop);
struct rtu_fd_vlan_table_entry *rtu_vlan_entry_get(int vid);
struct vlan_table_entry *rtu_vlan_entry_get(int vid);
#endif /*__WHITERABBIT_RTU_FD_H*/
......@@ -100,7 +100,7 @@ int rtudexp_get_vd_list(const struct minipc_pd *pd,
struct vlan_table_entry *ent = rtu_vlan_entry_get(current);
if(!ent) break;
if(ent->drop == 0)
if(ent->drop == 0 || ent->port_mask != 0x0)
{
list->list[i].vid = current;
list->list[i].port_mask = ent->port_mask;
......@@ -173,15 +173,18 @@ int rtudexp_add_entry(const struct minipc_pd *pd,
int rtudexp_vlan_entry(const struct minipc_pd *pd,
uint32_t *args, void *ret)
{
int vid, fid, mask, drop;
int vid, fid, mask, drop, prio, has_prio, prio_override;
int *p_ret=(int*)ret; //force pointed to int type
*p_ret = 0;
vid = (int)args[0];
fid = (int)args[1];
mask= (int)args[2];
drop= (int)args[3];
rtu_fd_create_vlan_entry(vid, (uint32_t)mask, (uint8_t)fid, 0 /*prio*/, 0 /*has_prio*/,0 /*prio_override*/, drop /*drop */);
vid = (int)args[0];
fid = (int)args[1];
mask= (int)args[2];
drop= (int)args[3];
prio= (int)args[4];
has_prio= (int)args[5];
prio_override= (int)args[6];
rtu_fd_create_vlan_entry(vid, (uint32_t)mask, (uint8_t)fid, (uint8_t)prio, has_prio,prio_override, drop);
return *p_ret;
}
......
......@@ -122,10 +122,13 @@ struct minipc_pd rtud_export_vlan_entry = {
.name = "vlan_entry",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT,int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 0: vid
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 1: fid
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 2: mask
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 3: drop
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 4: prio
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 5: has_prio
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), // 6: prio_override
MINIPC_ARG_END,
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment