diff --git a/Kconfig b/Kconfig index 6b0081492c4f40f7a81c7605958bb987d6756622..1afa3f364c6b4f3550299fcd5009b22c35452242 100644 --- a/Kconfig +++ b/Kconfig @@ -862,4 +862,24 @@ config FAN_HYSTERESIS_PWM_VAL endmenu endmenu +menu "RTU HP mask" + +config RTU_HP_MASK_ENABLE + bool "Set custom High Priority mask in RTU" + default n + help + Set the mask which priorities are considered High Priority (this + only concerns the traffic which is fast-forwarded). + + +config RTU_HP_MASK_VAL + string "HP mask" + default 0 + depends on RTU_HP_MASK_ENABLE + help + Mask with priorities (eg. 0x9 => priority 4 and 0 are considered HP) + + +endmenu + source Kconfig_vlans.in diff --git a/doc/wrs-developer-manual.in b/doc/wrs-developer-manual.in index 6f209c47c3158ab05ed0ccb29bcd84529e3064fb..0b273a1cddb6f8ec961a1aee6511df1e198e797f 100644 --- a/doc/wrs-developer-manual.in +++ b/doc/wrs-developer-manual.in @@ -1652,6 +1652,11 @@ the processes (excluding the @sc{rt} subsystem). used to pass a number of parameters to @i{rtud} and make it perform actions. +@item rtud::hp_mask + + Called by @i{rtu_stat} when setting which priorities are considered + High Priority (this only concerns the traffic which is fast-forwarded). + @end table @c -------------------------------------------------------------------------- diff --git a/doc/wrs-user-manual.in b/doc/wrs-user-manual.in index 0dd4279e1dcd645181f47238a29ad2735ba40999..ecdbcf985c34f9e47509d47ae5ff62311d0a9f09 100644 --- a/doc/wrs-user-manual.in +++ b/doc/wrs-user-manual.in @@ -834,6 +834,15 @@ value is changed by the web interface, proper action is taken. below @t{CONFIG_FAN_HYSTERESIS_T_DISABLE}. These options are intended to be used during development to reduce noise generated by switch. +@item CONFIG_RTU_HP_MASK_ENABLE +@itemx CONFIG_RTU_HP_MASK_VAL + + Set the mask which VLAN priorities are considered High Priority (this + only concerns the traffic which is fast-forwarded). + To enable the apply of the custom mask set + @t{CONFIG_RTU_HP_MASK_ENABLE}. + @t{CONFIG_RTU_HP_MASK_VAL} contains the mask to be used. + @end table @c ========================================================================== diff --git a/userspace/rootfs_override/var/www/port2vlan.php b/userspace/rootfs_override/var/www/port2vlan.php index 277d97fc5bc1267b96f937d151c264980cfd20b8..ea34e2721dcaa1150e8d35257f9a3de4b2e558ed 100644 --- a/userspace/rootfs_override/var/www/port2vlan.php +++ b/userspace/rootfs_override/var/www/port2vlan.php @@ -53,7 +53,7 @@ echo '<form method=POST>'; for($i = 0; $i < 18; $i++){ - $single_line = explode(" ",$vlans_assignment[$i+1]); //info per endpoint line + $single_line = explode(" ",$vlans_assignment[$i+2]); //info per endpoint line echo '<tr>'; echo '<th><center><b>'.($single_line[0]).'</b></center></th>'; diff --git a/userspace/rootfs_override/var/www/vlan.php b/userspace/rootfs_override/var/www/vlan.php index 646f58e28a4538a6b2cd60bfc509c77664a0887f..6486e3072806116bbc599f790686faabb93db184 100644 --- a/userspace/rootfs_override/var/www/vlan.php +++ b/userspace/rootfs_override/var/www/vlan.php @@ -96,7 +96,7 @@ foreach($vlans as $line){ $counter++; - if($counter>=2 && !empty($line)){ + if($counter>=3 && !empty($line)){ $line = explode(" ", $line); echo '<tr align=center><td>'.($line[0]).'</td><td>'.$line[1]." (".$line[2].')</td><td>'.($line[4]).'</td><td bgcolor="'.$vlancolor[$line[5]%10].'">VLAN '.$line[5].'</td><td>'.$line[6].'</td></td></tr>'; diff --git a/userspace/tools/wrs_vlans.c b/userspace/tools/wrs_vlans.c index 48a4f9826433224c03d39408471dcd6afcff3e1e..c900036a5444c1938b7c912fe35d79e4edf3205c 100644 --- a/userspace/tools/wrs_vlans.c +++ b/userspace/tools/wrs_vlans.c @@ -60,6 +60,7 @@ static struct option ropts[] = { {"rprio", 1, NULL, OPT_RTU_PRIO}, {"del", 0, NULL, OPT_RTU_DEL}, {"file", 1, NULL, OPT_FILE_READ}, + {"hpmask", 1, NULL, OPT_RTU_HP_MASK}, {0,}}; /*******************/ static struct vlan_sets dot_config_vlan_sets[] = { @@ -76,6 +77,7 @@ static void set_p_qmode(int ep, int arg_mode); static void set_p_vid(int ep, char *arg_vid); static void set_p_prio(int ep, char *arg_prio); static void set_p_umask(int ep, int arg_umask); +static void set_hp_mask(char *mask_str); static int check_rtu(char *name, char *arg_val, int min, int max); static int print_help(char *prgname); static void print_config_rtu(struct s_port_vlans *vlans); @@ -87,6 +89,7 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio, static void free_rtu_vlans(struct rtu_vlans_t *ptr); static void list_rtu_vlans(void); static void list_p_vlans(void); +static void print_hp_mask(void); static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid, int fid); static int config_rtud(void); @@ -276,6 +279,7 @@ int main(int argc, char *argv[]) case OPT_P_LIST: /* list endpoint stuff */ + print_hp_mask(); list_p_vlans(); break; @@ -315,7 +319,9 @@ int main(int argc, char *argv[]) case OPT_RTU_DEL: set_rtu_vlan(-1, -1, -1, 0, -1, 1, 0); break; - + case OPT_RTU_HP_MASK: + set_hp_mask(optarg); + break; /****************************************************/ /* Other settings */ case OPT_CLEAR: @@ -408,6 +414,30 @@ static void set_p_umask(int ep, int arg_umask) vlans[ep].valid_mask |= VALID_UNTAG; } +static void set_hp_mask(char *mask_str) +{ + int hp_mask; + int val; + int ret; + + hp_mask = strtol(mask_str, NULL, 0); + + if (hp_mask >= (1 << 8)) { + pr_error("Wrong HP mask %s\n", mask_str); + exit(1); + } + + ret = minipc_call(rtud_ch, MINIPC_TIMEOUT, + &rtud_export_hp_mask, &val, + RTU_SET_HP_MASK, hp_mask); + ret = (ret < 0) ? ret : val; + if (ret < 0) { + pr_error("failed to set HP mask 0x%x (%s), ret %d\n", + hp_mask, mask_str, ret); + exit(1); + } + +} static int check_rtu(char *name, char *arg_val, int min, int max) { int val; @@ -422,7 +452,7 @@ static int check_rtu(char *name, char *arg_val, int min, int max) static int print_help(char *prgname) { - fprintf(stderr, "Use: %s [-v] [-q]" + fprintf(stderr, "Use: %s [-v] [-q] [--hpmask <mask>]" "[--port <port number 1..18> <port options> " "--port <port number> <port options> ...] " "[--rvid <vid> --rfid <fid> --rmask <mask> --rdrop " @@ -448,6 +478,9 @@ static int print_help(char *prgname) "\t --rdrop <1/0> drop/don't drop frames on VLAN\n" "\t --rprio <prio> force priority for VLAN (-1 cancels priority override)\n" "Other options:\n" + "\t --hpmask <mask> Set the mask which priorities are considered\n" + "\t High Priority (this only concerns the traffic which\n" + "\t is fast-forwarded)\n" "\t --clear clears RTUd VLAN table\n" "\t --list prints the content of RTUd VLAN table\n" "\t -f|--file <file> reads configuration from the provided dot-config file\n" @@ -674,6 +707,21 @@ static void list_p_vlans(void) return; } +static void print_hp_mask(void) +{ + int hp_mask; + int ret; + ret = minipc_call(rtud_ch, MINIPC_TIMEOUT, &rtud_export_hp_mask, + &hp_mask, RTU_GET_HP_MASK, NULL); + if (ret < 0) { + pr_error("failed to read HP mask, ret %d\n", ret); + exit(1); + } + printf("#-----------------------------------------------\n"); + printf("# HP mask: 0x%02x\n", hp_mask); + printf("#-----------------------------------------------\n"); +} + static int clear_all(void) { uint32_t r; @@ -832,9 +880,27 @@ static int read_dot_config(char *dot_config_file) return -1; } + ret = libwr_cfg_get("RTU_HP_MASK_ENABLE"); + if (ret && !strcmp(ret, "y")) { + if (wrs_msg_level >= LOG_DEBUG) + printf("Setting HP mask\n"); + + ret = libwr_cfg_get("RTU_HP_MASK_VAL"); + if (ret) { + if (wrs_msg_level >= LOG_DEBUG) + printf("Set RTU_HP_MASK_VAL %s\n", ret); + set_hp_mask(ret); + } else { + pr_error("Unable to get RTU_HP_MASK_VAL\n"); + exit(1); + } + } + + + /* read VLANs related configuration */ ret = libwr_cfg_get("VLANS_ENABLE"); if (!ret || strcmp(ret, "y")) { - if (debug > 1) + if (wrs_msg_level >= LOG_DEBUG) printf("VLANS not enabled\n"); return -2; } diff --git a/userspace/tools/wrs_vlans.h b/userspace/tools/wrs_vlans.h index 4bdea867b7a87f930124afd698b619d7445cd406..f6453a3b824e2d50a48e88a5e582f708aeb89679 100644 --- a/userspace/tools/wrs_vlans.h +++ b/userspace/tools/wrs_vlans.h @@ -41,7 +41,6 @@ #define PORT_MASK(x) (1<<(x)) -#define NOPTS 15 #define OPT_HELP 'h' #define OPT_CLEAR 3 #define OPT_LIST 4 @@ -57,6 +56,7 @@ #define OPT_RTU_DROP 23 #define OPT_RTU_PRIO 24 #define OPT_RTU_DEL 25 +#define OPT_RTU_HP_MASK 30 #define OPT_FILE_READ 'f' #define PORT_PRIO_MIN 0 diff --git a/userspace/wrsw_rtud/rtud_exports.c b/userspace/wrsw_rtud/rtud_exports.c index 22abe28488a6f3633ae471b27933f44095e6f7ed..cd8161c0df2fba73ea4e1f54e1aa60383591846d 100644 --- a/userspace/wrsw_rtud/rtud_exports.c +++ b/userspace/wrsw_rtud/rtud_exports.c @@ -37,6 +37,7 @@ #include "rtu.h" #include "rtu_fd.h" #include "rtu_drv.h" +#include "rtu_ext_drv.h" #include "rtud_exports.h" #include <libwr/mac.h> @@ -278,6 +279,39 @@ int rtudexp_unrec(const struct minipc_pd *pd, uint32_t * args, void *ret) return *p_ret; } +int rtudexp_hp_mask(const struct minipc_pd *pd, uint32_t * args, void *ret) +{ + int oper; + uint32_t hp_mask; + int *p_ret = (int *)ret; /* force pointed to int type */ + + oper = (int)args[0]; + hp_mask = (int)args[1]; + + *p_ret = 0; + pr_debug("Request for HP mask\n"); + switch (oper) { + case RTU_SET_HP_MASK: + if (hp_mask >= (1 << 8)) { + *p_ret = -1; + pr_error("Wrong HP mask 0x%x\n", hp_mask); + break; + } + rtux_set_hp_prio_mask(hp_mask); + pr_debug("Setting HP mask 0x%x\n", hp_mask); + break; + case RTU_GET_HP_MASK: + *p_ret = rtux_get_hp_prio_mask(); + pr_debug("Got HP mask 0x%x\n", *p_ret); + break; + default: + pr_error("Wrong operation for HP mask %d\n", oper); + *p_ret = -1; + return *p_ret; + } + return *p_ret; +} + int rtudexp_vlan_entry(const struct minipc_pd *pd, uint32_t * args, void *ret) { int vid, fid, mask, drop, prio, has_prio, prio_override; @@ -314,6 +348,7 @@ int rtud_init_exports() MINIPC_EXP_FUNC(rtud_export_learning_process, rtudexp_learning_process); MINIPC_EXP_FUNC(rtud_export_unrec, rtudexp_unrec); MINIPC_EXP_FUNC(rtud_export_vlan_entry, rtudexp_vlan_entry); + MINIPC_EXP_FUNC(rtud_export_hp_mask, rtudexp_hp_mask); return 0; } diff --git a/userspace/wrsw_rtud/rtud_exports.h b/userspace/wrsw_rtud/rtud_exports.h index dd6bcb5d8f4a418623e3fd1b1d02fe701c4f1534..06e767a1d0c61008ec9380df2a8cfb93d86ec059 100644 --- a/userspace/wrsw_rtud/rtud_exports.h +++ b/userspace/wrsw_rtud/rtud_exports.h @@ -41,6 +41,9 @@ #define RTU_SET_UNREC 1 #define RTU_GET_UNREC 2 +#define RTU_SET_HP_MASK 1 +#define RTU_GET_HP_MASK 2 + /* Export of a function to set remove entry in rtu */ struct minipc_pd rtud_export_clear_entries = { .name = "clear_entries", @@ -118,4 +121,15 @@ struct minipc_pd rtud_export_vlan_entry = { }, }; +/* Export of a function to add vlan entry in rtu */ +struct minipc_pd rtud_export_hp_mask = { + .name = "hp_mask", + .retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), + .args = { + MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), /* operation */ + MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), /* HP mask */ + MINIPC_ARG_END, + }, +}; + #endif