Skip to content

Commit 580745e

Browse files
haiyangzrtg-canonical
authored andcommitted
net: mana: Add support for vlan tagging
BugLink: https://bugs.launchpad.net/bugs/2023695 To support vlan, use MANA_LONG_PKT_FMT if vlan tag is present in TX skb. Then extract the vlan tag from the skb struct, and save it to tx_oob for the NIC to transmit. For vlan tags on the payload, they are accepted by the NIC too. For RX, extract the vlan tag from CQE and put it into skb. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net> (backported from commit b803d1f linux-next) [rtg - context adjustments due to missing XDP features] Signed-off-by: Tim Gardner <tim.gardner@canonical.com> Acked-by: Andrei Gherzan <andrei.gherzan@canonical.com> Acked-by: Roxana Nicolescu <roxana.nicolescu@canonical.com> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
1 parent f83250a commit 580745e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/net/ethernet/microsoft/mana/mana_en.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ int mana_start_xmit(struct sk_buff *skb, struct net_device *ndev)
164164
pkg.tx_oob.s_oob.short_vp_offset = txq->vp_offset;
165165
}
166166

167+
if (skb_vlan_tag_present(skb)) {
168+
pkt_fmt = MANA_LONG_PKT_FMT;
169+
pkg.tx_oob.l_oob.inject_vlan_pri_tag = 1;
170+
pkg.tx_oob.l_oob.pcp = skb_vlan_tag_get_prio(skb);
171+
pkg.tx_oob.l_oob.dei = skb_vlan_tag_get_cfi(skb);
172+
pkg.tx_oob.l_oob.vlan_id = skb_vlan_tag_get_id(skb);
173+
}
174+
167175
pkg.tx_oob.s_oob.pkt_fmt = pkt_fmt;
168176

169177
if (pkt_fmt == MANA_SHORT_PKT_FMT)
@@ -1356,6 +1364,12 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe,
13561364
skb_set_hash(skb, hash_value, PKT_HASH_TYPE_L3);
13571365
}
13581366

1367+
if (cqe->rx_vlantag_present) {
1368+
u16 vlan_tci = cqe->rx_vlan_id;
1369+
1370+
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
1371+
}
1372+
13591373
u64_stats_update_begin(&rx_stats->syncp);
13601374
rx_stats->packets++;
13611375
rx_stats->bytes += pkt_len;
@@ -2338,8 +2352,9 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
23382352
ndev->hw_features |= NETIF_F_RXCSUM;
23392353
ndev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
23402354
ndev->hw_features |= NETIF_F_RXHASH;
2341-
ndev->features = ndev->hw_features;
2342-
ndev->vlan_features = 0;
2355+
ndev->features = ndev->hw_features | NETIF_F_HW_VLAN_CTAG_TX |
2356+
NETIF_F_HW_VLAN_CTAG_RX;
2357+
ndev->vlan_features = ndev->features;
23432358

23442359
err = register_netdev(ndev);
23452360
if (err) {

0 commit comments

Comments
 (0)