Commit e2a24edb authored by Adam Wujek's avatar Adam Wujek 💬

userspace/tools: rename network interfaces from wrX to wriX+1 in wrs_vlans

rename parameters:
ep to port
emode to pmode
evid to pvid
eprio to pprio
eumask to pumask
elist to plist

Additionally update wrs-user-manual
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 3cc1e803
...@@ -1306,7 +1306,7 @@ configuration is divided into two parts: ...@@ -1306,7 +1306,7 @@ configuration is divided into two parts:
@table @code @table @code
@item wrs_vlans --ep <port number or range> [options] @item wrs_vlans --port <port number or range> [options]
Per-port Endpoint VLAN configuration. Used to set VID and priority for ingress Per-port Endpoint VLAN configuration. Used to set VID and priority for ingress
frames tagging, egress untagging and port mode to: frames tagging, egress untagging and port mode to:
...@@ -1332,19 +1332,19 @@ order to have a full VLAN setup on a WR Switch. ...@@ -1332,19 +1332,19 @@ order to have a full VLAN setup on a WR Switch.
For per-port configuration, multiple ways of specifying ports are supported: For per-port configuration, multiple ways of specifying ports are supported:
@table @code @table @code
@item wrs_vlans --ep 1 [options] @item wrs_vlans --port 1 [options]
Selected configuration will be applied only to port 1. Selected configuration will be applied only to port 1.
@item wrs_vlans --ep 1,3,4 [options] @item wrs_vlans --port 1,3,4 [options]
Selected configuration will be applied to ports 1,3 and 4. Selected configuration will be applied to ports 1,3 and 4.
@item wrs_vlans --ep 5-8 [options] @item wrs_vlans --port 5-8 [options]
Selected configuration will be applied to port range 5 to 8. Selected configuration will be applied to port range 5 to 8.
@item wrs_vlans --ep 5-8,15 [options] @item wrs_vlans --port 5-8,15 [options]
Selected configuration will be applied to port range 5 to 8 and port 15. Selected configuration will be applied to port range 5 to 8 and port 15.
...@@ -1353,16 +1353,16 @@ For per-port configuration, multiple ways of specifying ports are supported: ...@@ -1353,16 +1353,16 @@ For per-port configuration, multiple ways of specifying ports are supported:
To configure each Endpoint the following options may be used: To configure each Endpoint the following options may be used:
@table @code @table @code
@item --emode <mode No.> @item --pmode <mode No.>
Sets qmode for a port (0 - ACCESS, 1 - TRUNK, 2 - disabled, 3 - unqualified) Sets qmode for a port (0 - ACCESS, 1 - TRUNK, 2 - disabled, 3 - unqualified)
@item --evid <vid> @item --pvid <vid>
Sets VLAN id for tagging ingress frames. Sets VLAN id for tagging ingress frames.
@item --eprio <priority> @item --pprio <priority>
Sets priority for tagging ingress frames. Sets priority for tagging ingress frames.
@item --eumask <hex mask> @item --pumask <hex mask>
Sets mask for egress untagging. By default, if you configure ingress tagging, Sets mask for egress untagging. By default, if you configure ingress tagging,
all VIDs are untagged on egress. all VIDs are untagged on egress.
...@@ -1404,9 +1404,9 @@ VLAN configuration of the switch: ...@@ -1404,9 +1404,9 @@ VLAN configuration of the switch:
@table @code @table @code
@item wrs_vlans --elist @item wrs_vlans --plist
Current Endpoints VLAN configuration Current Port VLAN configuration
@item wrs_vlans --list @item wrs_vlans --list
...@@ -1418,12 +1418,12 @@ VLAN configuration of the switch: ...@@ -1418,12 +1418,12 @@ VLAN configuration of the switch:
@i{wrs_vlans} tool can be called multiple times to make a set of per-port and @i{wrs_vlans} tool can be called multiple times to make a set of per-port and
per-VLAN configurations. However, it is also possible to configure multiple per-VLAN configurations. However, it is also possible to configure multiple
ports/VLANs in one go. For example to configure ports 0,1,2,5 to VLAN 5 and ports/VLANs in one go. For example to configure ports 1,2,3,6 to VLAN 5 and
ports 3,4 to VLAN 6 with tagging ingress frames one could call @i{wrs_vlans} ports 4,5 to VLAN 6 with tagging ingress frames one could call @i{wrs_vlans}
with these parameters: with these parameters:
@example @example
wrs_vlans --ep 0-2,5 --emode 0 --evid 5 --ep 3,4 --emode 0 --evid 6 \ wrs_vlans --port 1-3,6 --pmode 0 --pvid 5 --port 4,5 --pmode 0 --pvid 6 \
--rvid 5 --rmask 0x27 --rvid 6 --rmask 0x18 --rvid 5 --rmask 0x27 --rvid 6 --rmask 0x18
@end example @end example
......
...@@ -48,12 +48,12 @@ static struct option ropts[] = { ...@@ -48,12 +48,12 @@ static struct option ropts[] = {
{"debug", 0, &debug, 1}, {"debug", 0, &debug, 1},
{"clear", 0, NULL, OPT_CLEAR}, {"clear", 0, NULL, OPT_CLEAR},
{"list", 0, NULL, OPT_LIST}, {"list", 0, NULL, OPT_LIST},
{"ep", 1, NULL, OPT_EP_PORT}, {"port", 1, NULL, OPT_P_PORT},
{"emode", 1, NULL, OPT_EP_QMODE}, {"pmode", 1, NULL, OPT_P_QMODE},
{"evid", 1, NULL, OPT_EP_VID}, {"pvid", 1, NULL, OPT_P_VID},
{"eprio", 1, NULL, OPT_EP_PRIO}, {"pprio", 1, NULL, OPT_P_PRIO},
{"eumask", 1, NULL, OPT_EP_UMASK}, {"pumask", 1, NULL, OPT_P_UMASK},
{"elist", 0, NULL, OPT_EP_LIST}, {"plist", 0, NULL, OPT_P_LIST},
{"rvid", 1, NULL, OPT_RTU_VID}, {"rvid", 1, NULL, OPT_RTU_VID},
{"rfid", 1, NULL, OPT_RTU_FID}, {"rfid", 1, NULL, OPT_RTU_FID},
{"rmask", 1, NULL, OPT_RTU_PMASK}, {"rmask", 1, NULL, OPT_RTU_PMASK},
...@@ -75,7 +75,7 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio, ...@@ -75,7 +75,7 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio,
int del, int flags); int del, int flags);
static void free_rtu_vlans(struct rtu_vlans_t *ptr); static void free_rtu_vlans(struct rtu_vlans_t *ptr);
static void list_rtu_vlans(void); static void list_rtu_vlans(void);
static void list_ep_vlans(void); static void list_p_vlans(void);
static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid, static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid,
int fid); int fid);
static int config_rtud(void); static int config_rtud(void);
...@@ -113,6 +113,10 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -113,6 +113,10 @@ static int parse_mask(char *arg, unsigned long *pmask)
default: default:
return -1; return -1;
} }
/* parameter --port should be from the range 1..18,
* but internally we use 0..17 */
p1--;
p2--;
if ((p1 > p2) || (p1 < 0) || (p2 >= NPORTS)) if ((p1 > p2) || (p1 < 0) || (p2 >= NPORTS))
return -1; return -1;
for (; p1 <= p2; p1++) { for (; p1 <= p2; p1++) {
...@@ -123,9 +127,9 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -123,9 +127,9 @@ static int parse_mask(char *arg, unsigned long *pmask)
if (!debug) if (!debug)
return 0; return 0;
fprintf(stderr, "%s: working on ports:", prgname); printf("%s: working on ports:\n", prgname);
iterate_ports(p1, *pmask) iterate_ports(p1, *pmask)
printf(" %i", p1); printf(" %i", p1 + 1);
printf("\n"); printf("\n");
return 0; return 0;
} }
...@@ -133,7 +137,7 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -133,7 +137,7 @@ static int parse_mask(char *arg, unsigned long *pmask)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int c, i, arg; int c, i, arg;
unsigned long conf_pmask = 0; //current '--ep' port mask unsigned long conf_pmask = 0; /* current '--port' port mask */
struct rtu_shmem_header *rtu_hdr; struct rtu_shmem_header *rtu_hdr;
int n_wait = 0; int n_wait = 0;
int ret; int ret;
...@@ -208,19 +212,18 @@ int main(int argc, char *argv[]) ...@@ -208,19 +212,18 @@ int main(int argc, char *argv[])
/*parse parameters*/ /*parse parameters*/
while( (c = getopt_long(argc, argv, "h", ropts, NULL)) != -1) { while( (c = getopt_long(argc, argv, "h", ropts, NULL)) != -1) {
switch(c) { switch(c) {
case OPT_EP_PORT: case OPT_P_PORT:
//port number /* port number */
conf_pmask = 0; conf_pmask = 0;
if (parse_mask(optarg, &conf_pmask) < 0) { if (parse_mask(optarg, &conf_pmask) < 0) {
fprintf(stderr, "%s: wrong port mask " fprintf(stderr, "%s: wrong port mask "
"\"%s\"\n", prgname, optarg); "\"%s\"\n", prgname, optarg);
exit(1); exit(1);
} }
break; break;
case OPT_EP_QMODE:
//qmode for port case OPT_P_QMODE:
/* qmode for port */
arg = atoi(optarg); arg = atoi(optarg);
if (arg < 0 || arg > 3) { if (arg < 0 || arg > 3) {
fprintf(stderr, "%s: invalid qmode %i (\"%s\")\n", fprintf(stderr, "%s: invalid qmode %i (\"%s\")\n",
...@@ -235,22 +238,25 @@ int main(int argc, char *argv[]) ...@@ -235,22 +238,25 @@ int main(int argc, char *argv[])
vlans[i].untag_mask = (arg == 0); vlans[i].untag_mask = (arg == 0);
} }
break; break;
case OPT_EP_PRIO:
//priority value for port, forces fix_prio=1 case OPT_P_PRIO:
/* priority value for port, forces fix_prio=1 */
iterate_ports(i, conf_pmask) { iterate_ports(i, conf_pmask) {
vlans[i].prio_val = atoi(optarg); vlans[i].prio_val = atoi(optarg);
vlans[i].fix_prio = 1; vlans[i].fix_prio = 1;
vlans[i].valid_mask |= VALID_PRIO; vlans[i].valid_mask |= VALID_PRIO;
} }
break; break;
case OPT_EP_VID:
//VID for port case OPT_P_VID:
/* VID for port */
iterate_ports(i, conf_pmask) { iterate_ports(i, conf_pmask) {
vlans[i].vid = atoi(optarg); vlans[i].vid = atoi(optarg);
vlans[i].valid_mask |= VALID_VID; vlans[i].valid_mask |= VALID_VID;
} }
break; break;
case OPT_EP_UMASK:
case OPT_P_UMASK:
//untag mask -- currently 0 or 1. Overrides default set in QMODE above //untag mask -- currently 0 or 1. Overrides default set in QMODE above
arg = atoi(optarg); arg = atoi(optarg);
if (arg < 0 || arg > 1) { if (arg < 0 || arg > 1) {
...@@ -263,9 +269,10 @@ int main(int argc, char *argv[]) ...@@ -263,9 +269,10 @@ int main(int argc, char *argv[])
vlans[i].valid_mask |= VALID_UNTAG; vlans[i].valid_mask |= VALID_UNTAG;
} }
break; break;
case OPT_EP_LIST:
// list endpoint stuff case OPT_P_LIST:
list_ep_vlans(); /* list endpoint stuff */
list_p_vlans();
break; break;
/****************************************************/ /****************************************************/
...@@ -322,28 +329,29 @@ int main(int argc, char *argv[]) ...@@ -322,28 +329,29 @@ int main(int argc, char *argv[])
static int print_help(char *prgname) static int print_help(char *prgname)
{ {
fprintf(stderr, "Use: %s [--ep <port number> <EP options> --ep <port number> " fprintf(stderr, "Use: %s [--port <port number 1..18> <port options> "
"<EP options> ...] [--rvid <vid> --rfid <fid> --rmask <mask> --rdrop " "--port <port number> <port options> ...] "
"[--rvid <vid> --rfid <fid> --rmask <mask> --rdrop "
"--rprio <prio> --rvid <vid>...] [--debug]\n", prgname); "--rprio <prio> --rvid <vid>...] [--debug]\n", prgname);
fprintf(stderr, fprintf(stderr,
"Endpoint options:\n" "Port options:\n"
"\t --emode <mode No.> sets qmode for a port, possible values:\n" "\t --pmode <mode No.> sets qmode for a port, possible values:\n"
"\t \t 0: ACCESS - tags untagged frames, drops tagged frames not belinging to configured VLAN\n" "\t \t 0: ACCESS - tags untagged frames, drops tagged frames not belinging to configured VLAN\n"
"\t \t 1: TRUNK - passes only tagged frames, drops all untagged frames\n" "\t \t 1: TRUNK - passes only tagged frames, drops all untagged frames\n"
"\t \t 2: VLANs disabled - passess all frames as is\n" "\t \t 2: VLANs disabled - passess all frames as is\n"
"\t \t 3: Unqualified port - passess all frames regardless VLAN config\n" "\t \t 3: Unqualified port - passess all frames regardless VLAN config\n"
"\t --eprio <priority> sets priority for retagging\n" "\t --pprio <priority> sets priority for retagging\n"
"\t --evid <vid> sets VLAN Id for port\n" "\t --pvid <vid> sets VLAN Id for port\n"
"\t --eumask <hex mask> sets untag mask for port\n" "\t --pumask <hex mask> sets untag mask for port\n"
"\t --elist lists current EP configuration\n" "\t --plist lists current ports configuration\n"
"RTU options:\n" "RTU options:\n"
"\t --rvid <vid> configure VLAN <vid> in rtud\n" "\t --rvid <vid> configure VLAN <vid> in rtud\n"
"\t --del delete selected VLAN from rtud\n" "\t --del delete selected VLAN from rtud\n"
"\t --rfid <fid> assign <fid> to configured VLAN\n" "\t --rfid <fid> assign <fid> to configured VLAN\n"
"\t --rmask <hex mask> ports belonging to configured VLAN\n" "\t --rmask <hex mask> ports belonging to configured VLAN\n"
"\t --rdrop <1/0> drop/don't drop frames on VLAN\n" "\t --rdrop <1/0> drop/don't drop frames on VLAN\n"
"\t --rprio <prio> force priority for VLAN (-1 cancels priority override\n" "\t --rprio <prio> force priority for VLAN (-1 cancels priority override)\n"
"Other options:\n" "Other options:\n"
"\t --clear clears RTUd VLAN table\n" "\t --clear clears RTUd VLAN table\n"
"\t --list prints the content of RTUd VLAN table\n" "\t --list prints the content of RTUd VLAN table\n"
...@@ -359,10 +367,17 @@ static void print_config(struct s_port_vlans *vlans) ...@@ -359,10 +367,17 @@ static void print_config(struct s_port_vlans *vlans)
for_each_port(i) { for_each_port(i) {
printf("port: %d, qmode: %d, qmode_valid: %d, fix_prio: %d, prio_val: %d, " printf("port: %d, qmode: %d, qmode_valid: %d, fix_prio: %d, prio_val: %d, "
"prio_valid: %d, vid: %d, vid_valid: %d, untag_mask: 0x%X, untag_valid: %d\n", "prio_valid: %d, vid: %d, vid_valid: %d, untag_mask: 0x%X, untag_valid: %d\n",
i, vlans[i].qmode, ((vlans[i].valid_mask & VALID_QMODE) != 0), vlans[i].fix_prio, i + 1,
vlans[i].prio_val, ((vlans[i].valid_mask & VALID_PRIO) != 0),vlans[i].vid, vlans[i].qmode,
((vlans[i].valid_mask & VALID_VID) != 0), vlans[i].untag_mask, ((vlans[i].valid_mask & VALID_QMODE) != 0),
((vlans[i].valid_mask & VALID_UNTAG) != 0) ); vlans[i].fix_prio,
vlans[i].prio_val,
((vlans[i].valid_mask & VALID_PRIO) != 0),
vlans[i].vid,
((vlans[i].valid_mask & VALID_VID) != 0),
vlans[i].untag_mask,
((vlans[i].valid_mask & VALID_UNTAG) != 0)
);
} }
} }
...@@ -501,19 +516,19 @@ static void list_rtu_vlans(void) ...@@ -501,19 +516,19 @@ static void list_rtu_vlans(void)
} }
static void list_ep_vlans(void) static void list_p_vlans(void)
{ {
uint32_t v, r; uint32_t v, r;
int ep; int ep;
static char *names[] = {"ACCESS", "TRUNK", "disabled", "unqualified"}; static char *names[] = {"ACCESS", "TRUNK", "disabled", "unqualified"};
printf("# QMODE FIX_PRIO PRIO PVID MAC\n"); printf("# QMODE FIX_PRIO PRIO PVID MAC\n");
printf("#---------------------------------------------\n"); printf("#-----------------------------------------------\n");
for (ep = 0; ep < NPORTS; ep++) { for (ep = 0; ep < NPORTS; ep++) {
r = offsetof(struct EP_WB, VCR0); r = offsetof(struct EP_WB, VCR0);
v = ep_read(ep, r); v = ep_read(ep, r);
printf(" %2i %i %6.6s %i %i %4i %04x%08x\n", printf("wri%-2i %i %6.6s %i %i %4i %04x%08x\n",
ep, v & 3, names[v & 3], ep + 1, v & 3, names[v & 3],
v & EP_VCR0_FIX_PRIO ? 1 : 0, v & EP_VCR0_FIX_PRIO ? 1 : 0,
EP_VCR0_PRIO_VAL_R(v), EP_VCR0_PRIO_VAL_R(v),
EP_VCR0_PVID_R(v), EP_VCR0_PVID_R(v),
......
...@@ -46,12 +46,12 @@ ...@@ -46,12 +46,12 @@
#define OPT_DEBUG 'd' #define OPT_DEBUG 'd'
#define OPT_CLEAR 3 #define OPT_CLEAR 3
#define OPT_LIST 4 #define OPT_LIST 4
#define OPT_EP_PORT 10 #define OPT_P_PORT 10
#define OPT_EP_QMODE 11 #define OPT_P_QMODE 11
#define OPT_EP_VID 12 #define OPT_P_VID 12
#define OPT_EP_PRIO 13 #define OPT_P_PRIO 13
#define OPT_EP_UMASK 14 #define OPT_P_UMASK 14
#define OPT_EP_LIST 15 #define OPT_P_LIST 15
#define OPT_RTU_VID 20 #define OPT_RTU_VID 20
#define OPT_RTU_FID 21 #define OPT_RTU_FID 21
#define OPT_RTU_PMASK 22 #define OPT_RTU_PMASK 22
......
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