summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
diff options
context:
space:
mode:
authorEli Britstein2018-12-09 08:17:18 +0100
committerSaeed Mahameed2018-12-20 14:06:03 +0100
commitaa331450b81f071bc8d7b68d5baab1b78f93598a (patch)
tree47f04d281bed96df634318723bc0ae70c4b06ef3 /drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
parentnet/mlx5e: Re-order route and encap header memory allocation (diff)
downloadkernel-qcow2-linux-aa331450b81f071bc8d7b68d5baab1b78f93598a.tar.gz
kernel-qcow2-linux-aa331450b81f071bc8d7b68d5baab1b78f93598a.tar.xz
kernel-qcow2-linux-aa331450b81f071bc8d7b68d5baab1b78f93598a.zip
net/mlx5e: Support VLAN encap ETH header generation
Support generation of native or tagged Ethernet header for encap header, depending on provided net device. Signed-off-by: Eli Britstein <elibr@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c15
1 files 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,