mirror of https://github.com/hak5/openwrt.git
ramips: mt7530: remove redundant global attrs for port mirroring
Global attributes enable_mirror_tx/enable_mirror_rx depend on runtime value of another global attribute mirror_source_port which just resides in the memory The same functionality can be achieved by directly setting port attribute of the same names. E.g. the following two groups of commands achieve the same thing swconfig dev switch0 set mirror_source_port 3 swconfig dev switch0 set enable_mirror_tx 1 swconfig dev switch0 set mirror_source_port 4 swconfig dev switch0 set enable_mirror_tx 1 swconfig dev switch0 port 3 set enable_mirror_tx 1 swconfig dev switch0 port 4 set enable_mirror_tx 1 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>master
parent
0493d57e04
commit
2408f2f08f
|
@ -208,7 +208,6 @@ struct mt7530_priv {
|
|||
struct mii_bus *bus;
|
||||
struct switch_dev swdev;
|
||||
|
||||
u8 mirror_src_port;
|
||||
u8 mirror_dest_port;
|
||||
bool global_vlan_enable;
|
||||
struct mt7530_vlan_entry vlan_entries[MT7530_NUM_VLANS];
|
||||
|
@ -519,50 +518,6 @@ mt7530_get_vid(struct switch_dev *dev, const struct switch_attr *attr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_get_mirror_rx_enable(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
{
|
||||
struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
|
||||
|
||||
val->value.i = priv->port_entries[priv->mirror_src_port].mirror_rx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_set_mirror_rx_enable(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
{
|
||||
struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
|
||||
|
||||
priv->port_entries[priv->mirror_src_port].mirror_rx = val->value.i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_get_mirror_tx_enable(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
{
|
||||
struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
|
||||
|
||||
val->value.i = priv->port_entries[priv->mirror_src_port].mirror_tx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_set_mirror_tx_enable(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
{
|
||||
struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
|
||||
|
||||
priv->port_entries[priv->mirror_src_port].mirror_tx = val->value.i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_get_mirror_monitor_port(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
|
@ -585,28 +540,6 @@ mt7530_set_mirror_monitor_port(struct switch_dev *dev, const struct switch_attr
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_get_mirror_source_port(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
{
|
||||
struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
|
||||
|
||||
val->value.i = priv->mirror_src_port;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_set_mirror_source_port(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
{
|
||||
struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
|
||||
|
||||
priv->mirror_src_port = val->value.i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_get_port_mirror_rx(struct switch_dev *dev, const struct switch_attr *attr,
|
||||
struct switch_val *val)
|
||||
|
@ -1002,20 +935,6 @@ static const struct switch_attr mt7530_global[] = {
|
|||
.description = "Get MIB counters for switch",
|
||||
.get = mt7530_sw_get_mib,
|
||||
.set = NULL,
|
||||
}, {
|
||||
.type = SWITCH_TYPE_INT,
|
||||
.name = "enable_mirror_rx",
|
||||
.description = "Enable mirroring of RX packets",
|
||||
.set = mt7530_set_mirror_rx_enable,
|
||||
.get = mt7530_get_mirror_rx_enable,
|
||||
.max = 1
|
||||
}, {
|
||||
.type = SWITCH_TYPE_INT,
|
||||
.name = "enable_mirror_tx",
|
||||
.description = "Enable mirroring of TX packets",
|
||||
.set = mt7530_set_mirror_tx_enable,
|
||||
.get = mt7530_get_mirror_tx_enable,
|
||||
.max = 1
|
||||
}, {
|
||||
.type = SWITCH_TYPE_INT,
|
||||
.name = "mirror_monitor_port",
|
||||
|
@ -1023,13 +942,6 @@ static const struct switch_attr mt7530_global[] = {
|
|||
.set = mt7530_set_mirror_monitor_port,
|
||||
.get = mt7530_get_mirror_monitor_port,
|
||||
.max = MT7530_NUM_PORTS - 1
|
||||
}, {
|
||||
.type = SWITCH_TYPE_INT,
|
||||
.name = "mirror_source_port",
|
||||
.description = "Mirror source port",
|
||||
.set = mt7530_set_mirror_source_port,
|
||||
.get = mt7530_get_mirror_source_port,
|
||||
.max = MT7530_NUM_PORTS - 1
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue