Commit 2474f280 authored by Adam Wujek's avatar Adam Wujek 💬

[Feature: 1366] userspace/wrsw_rtud: support setting HP mask

Add to Kconfig:
--RTU_HP_MASK_ENABLE
--RTU_HP_MASK_VAL

Update wrs_vlans:
--add parameter --hpmask
--read RTU_HP_MASK_* from dot-config
--print hpmask with plist

add a new minipc call rtud_export_hp_mask for HP mask

Update wrs-user-manual
Update wrs-developer-manual
Update webinterface
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 25a0699a
......@@ -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
......@@ -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 --------------------------------------------------------------------------
......
......@@ -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 ==========================================================================
......
......@@ -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>';
......
......@@ -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>';
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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
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