summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Semin <fancer.lancer@gmail.com>2025-04-21 22:40:24 +0300
committerSerge Semin <fancer.lancer@gmail.com>2026-08-13 20:35:10 +0300
commit090df3f59c6054fe486e443666e9d49a092bb6d6 (patch)
treeb7b70391a4e20fa7d5bb7ee711a8b1028c8d64b0
parent5276846cf534820b1956283d16157f010301438c (diff)
downloadlinux-090df3f59c6054fe486e443666e9d49a092bb6d6.tar.gz
linux-090df3f59c6054fe486e443666e9d49a092bb6d6.zip
net: stmmac: vlan: Add VLAN Tag core setter
DW MAC IP-cores can be equipped with the "SA, VLAN, and CRC Insertion on TX" feature. In case of VLAN Tag insertion the actual tag can be specified either via a dedicated setup register field or via a context DMA-descriptor. The last option is available on the DW QoS Ether and DW XGMAC IP-cores only, but not on the DW GMAC controllers. As a preparation before adding the VLAN Tag insertion support to the DW GMAC submodule let's add a callback method which would be responsible for initializing the Tx VLAN Tags of the device MAC. Note after this change if none of the VLAN Tx Tag setting up callbacks were successful the driver will try to push the tag inside the payload. Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/hwif.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c21
2 files changed, 18 insertions, 6 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 7e43630c6e87..a7f73b039fdf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -630,6 +630,7 @@ struct stmmac_est_ops {
struct stmmac_vlan_ops {
/* VLAN */
+ int (*set_vlan_tag)(struct mac_device_info *hw, u32 queue, u16 vid);
void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
int add_ctags, int add_stags);
void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc,
@@ -646,6 +647,8 @@ struct stmmac_vlan_ops {
struct mac_device_info *hw);
};
+#define stmmac_set_core_vlan_tag(__priv, __args...) \
+ stmmac_do_callback(__priv, vlan, set_vlan_tag, __args)
#define stmmac_update_vlan_hash(__priv, __args...) \
stmmac_do_void_callback(__priv, vlan, update_vlan_hash, __args)
#define stmmac_rx_hw_vlan(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b8bdaeab32b7..163ab3f0ad2b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4419,13 +4419,22 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
else
p = &tx_q->dma_tx[tx_q->cur_tx];
- if (stmmac_set_desc_vlan_tag(priv, p, tag, 0x0, 0x0))
- return false;
+ if (!stmmac_set_desc_vlan_tag(priv, p, tag, 0x0, 0x0)) {
+ stmmac_set_tx_owner(priv, p);
+ tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx,
+ priv->dma_conf.dma_tx_size);
+ tx_q->tci = tag;
+ return true;
+ } else if (!stmmac_set_core_vlan_tag(priv, priv->hw, tx_q->queue_index, tag)) {
+ tx_q->tci = tag;
+ return true;
+ }
- stmmac_set_tx_owner(priv, p);
- tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);
- tx_q->tci = tag;
- return true;
+ skb = __vlan_hwaccel_push_inside(skb);
+ if (IS_ERR(skb))
+ netdev_err(priv->dev, "failed to push VLAN inside, skipping\n");
+
+ return false;
}
/**