etherswitch: Add a new striptagingress port flag

Felix switch found in LS1028A supports stripping VLAN tag on
ingress, instead of egress. The striptag flag excepts the latter
behaviour.
Add a new flag to support the feature.

Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30922
This commit is contained in:
Kornel Duleba 2021-06-23 13:13:05 +02:00 committed by Marcin Wojtas
parent 428a32edba
commit f5b29d0f35
3 changed files with 19 additions and 10 deletions

View file

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 28, 2019
.Dd June 23, 2021
.Dt ETHERSWITCHCFG 8
.Os
.Sh NAME
@ -139,6 +139,10 @@ Disable the add VLAN tag option.
Strip the VLAN tags from the packets sent by the port.
.It Fl striptag
Disable the strip VLAN tag option.
.It Cm striptagingress
Strip the VLAN tags from the packets received by the port.
.It Fl striptagingress
Disable the strip VLAN tag on ingress option.
.It Cm firstlock
This options makes the switch port lock on the first MAC address it sees.
After that, usually you need to reset the switch to learn different

View file

@ -223,6 +223,8 @@ set_port_flag(struct cfg *cfg, int argc, char *argv[])
f = ETHERSWITCH_PORT_DOUBLE_TAG;
else if (strcasecmp(flag, "ingress") == 0)
f = ETHERSWITCH_PORT_INGRESS;
else if (strcasecmp(flag, "striptagingress") == 0)
f = ETHERSWITCH_PORT_STRIPTAGINGRESS;
}
bzero(&p, sizeof(p));
p.es_port = cfg->unit;
@ -869,6 +871,8 @@ static struct cmds cmds[] = {
{ MODE_PORT, "-ingress", 0, set_port_flag },
{ MODE_PORT, "striptag", 0, set_port_flag },
{ MODE_PORT, "-striptag", 0, set_port_flag },
{ MODE_PORT, "striptagingress", 0, set_port_flag },
{ MODE_PORT, "-striptagingress", 0, set_port_flag },
{ MODE_PORT, "doubletag", 0, set_port_flag },
{ MODE_PORT, "-doubletag", 0, set_port_flag },
{ MODE_PORT, "firstlock", 0, set_port_flag },

View file

@ -57,17 +57,18 @@ struct etherswitch_conf {
};
typedef struct etherswitch_conf etherswitch_conf_t;
#define ETHERSWITCH_PORT_CPU (1 << 0)
#define ETHERSWITCH_PORT_STRIPTAG (1 << 1)
#define ETHERSWITCH_PORT_ADDTAG (1 << 2)
#define ETHERSWITCH_PORT_FIRSTLOCK (1 << 3)
#define ETHERSWITCH_PORT_DROPUNTAGGED (1 << 4)
#define ETHERSWITCH_PORT_DOUBLE_TAG (1 << 5)
#define ETHERSWITCH_PORT_INGRESS (1 << 6)
#define ETHERSWITCH_PORT_DROPTAGGED (1 << 7)
#define ETHERSWITCH_PORT_CPU (1 << 0)
#define ETHERSWITCH_PORT_STRIPTAG (1 << 1)
#define ETHERSWITCH_PORT_ADDTAG (1 << 2)
#define ETHERSWITCH_PORT_FIRSTLOCK (1 << 3)
#define ETHERSWITCH_PORT_DROPUNTAGGED (1 << 4)
#define ETHERSWITCH_PORT_DOUBLE_TAG (1 << 5)
#define ETHERSWITCH_PORT_INGRESS (1 << 6)
#define ETHERSWITCH_PORT_DROPTAGGED (1 << 7)
#define ETHERSWITCH_PORT_STRIPTAGINGRESS (1 << 8)
#define ETHERSWITCH_PORT_FLAGS_BITS \
"\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS" \
"\10DROPTAGGED"
"\10DROPTAGGED\11STRIPTAGINGRESS"
#define ETHERSWITCH_PORT_MAX_LEDS 3