From: Saeed Mahameed Subject: [net-next V2 10/13] net/mlx5e: Support VLAN encap ETH header generation Date: Thu, 20 Dec 2018 10:04:37 -0800 Message-ID: <20181220180440.14047-11-saeedm@mellanox.com> References: <20181220180440.14047-1-saeedm@mellanox.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, Eli Britstein , Saeed Mahameed To: "David S. Miller" Return-path: Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:52157 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388459AbeLTSFZ (ORCPT ); Thu, 20 Dec 2018 13:05:25 -0500 In-Reply-To: <20181220180440.14047-1-saeedm@mellanox.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Eli Britstein Support generation of native or tagged Ethernet header for encap header, depending on provided net device. Signed-off-by: Eli Britstein Reviewed-by: Roi Dayan Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c index bcf08f5abc2f..a6990744730a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c @@ -185,12 +185,23 @@ static char *gen_eth_tnl_hdr(char *buf, struct net_device *dev, u16 proto) { struct ethhdr *eth = (struct ethhdr *)buf; + char *ip; ether_addr_copy(eth->h_dest, e->h_dest); ether_addr_copy(eth->h_source, dev->dev_addr); - eth->h_proto = htons(proto); + if (is_vlan_dev(dev)) { + struct vlan_hdr *vlan = (struct vlan_hdr *) + ((char *)eth + ETH_HLEN); + ip = (char *)vlan + VLAN_HLEN; + eth->h_proto = vlan_dev_vlan_proto(dev); + vlan->h_vlan_TCI = htons(vlan_dev_vlan_id(dev)); + vlan->h_vlan_encapsulated_proto = htons(proto); + } else { + eth->h_proto = htons(proto); + ip = (char *)eth + ETH_HLEN; + } - return (char *)eth + ETH_HLEN; + return ip; } int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, -- 2.19.2