[RFC net-next 1/2] net: dsa: allow taggers to customise netdev features

From: DENG Qingfang
Date: Wed Aug 25 2021 - 04:39:00 EST


Allow taggers to add netdev features, such as VLAN offload, to slave
devices, which will make it possible for taggers to handle VLAN tags
themselves.

Signed-off-by: DENG Qingfang <dqfext@xxxxxxxxx>
---
include/net/dsa.h | 2 ++
net/dsa/slave.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index f9a17145255a..f65442858f71 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -96,6 +96,8 @@ struct dsa_device_ops {
* its RX filter.
*/
bool promisc_on_master;
+ /* Additional features to be applied to the slave. */
+ netdev_features_t features;
};

/* This structure defines the control interfaces that are overlayed by the
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 662ff531d4e2..6d6f1aebf1ca 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1885,7 +1885,8 @@ void dsa_slave_setup_tagger(struct net_device *slave)

p->xmit = cpu_dp->tag_ops->xmit;

- slave->features = master->vlan_features | NETIF_F_HW_TC;
+ slave->features = master->vlan_features | cpu_dp->tag_ops->features |
+ NETIF_F_HW_TC;
slave->hw_features |= NETIF_F_HW_TC;
slave->features |= NETIF_F_LLTX;
if (slave->needed_tailroom)
--
2.25.1