Skip to content

Commit d117909

Browse files
Govindarajulu Varadarajandavem330
authored andcommitted
enic: Add vxlan offload support for IPv6 pkts
New adaptors supports vxlan offload for inner IPv6 and outer IPv6 vxlan pkts. Fw sets BIT(0) & BIT(1) in a1 if hw supports ipv6 inner & outer pkt offload. Signed-off-by: Govindarajulu Varadarajan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a464a2 commit d117909

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

drivers/net/ethernet/cisco/enic/enic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ struct enic_rfs_flw_tbl {
140140
struct vxlan_offload {
141141
u16 vxlan_udp_port_number;
142142
u8 patch_level;
143+
u8 flags;
143144
};
144145

145146
/* Per-instance private data structure */

drivers/net/ethernet/cisco/enic/enic_main.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,16 @@ static void enic_udp_tunnel_add(struct net_device *netdev,
191191
goto error;
192192
}
193193

194-
if (ti->sa_family != AF_INET) {
195-
netdev_info(netdev, "vxlan: only IPv4 offload supported");
194+
switch (ti->sa_family) {
195+
case AF_INET6:
196+
if (!(enic->vxlan.flags & ENIC_VXLAN_OUTER_IPV6)) {
197+
netdev_info(netdev, "vxlan: only IPv4 offload supported");
198+
goto error;
199+
}
200+
/* Fall through */
201+
case AF_INET:
202+
break;
203+
default:
196204
goto error;
197205
}
198206

@@ -271,22 +279,37 @@ static netdev_features_t enic_features_check(struct sk_buff *skb,
271279
struct enic *enic = netdev_priv(dev);
272280
struct udphdr *udph;
273281
u16 port = 0;
274-
u16 proto;
282+
u8 proto;
275283

276284
if (!skb->encapsulation)
277285
return features;
278286

279287
features = vxlan_features_check(skb, features);
280288

281-
/* hardware only supports IPv4 vxlan tunnel */
282-
if (vlan_get_protocol(skb) != htons(ETH_P_IP))
289+
switch (vlan_get_protocol(skb)) {
290+
case htons(ETH_P_IPV6):
291+
if (!(enic->vxlan.flags & ENIC_VXLAN_OUTER_IPV6))
292+
goto out;
293+
proto = ipv6_hdr(skb)->nexthdr;
294+
break;
295+
case htons(ETH_P_IP):
296+
proto = ip_hdr(skb)->protocol;
297+
break;
298+
default:
283299
goto out;
300+
}
284301

285-
/* hardware does not support offload of ipv6 inner pkt */
286-
if (eth->h_proto != ntohs(ETH_P_IP))
302+
switch (eth->h_proto) {
303+
case ntohs(ETH_P_IPV6):
304+
if (!(enic->vxlan.flags & ENIC_VXLAN_INNER_IPV6))
305+
goto out;
306+
/* Fall through */
307+
case ntohs(ETH_P_IP):
308+
break;
309+
default:
287310
goto out;
311+
}
288312

289-
proto = ip_hdr(skb)->protocol;
290313

291314
if (proto == IPPROTO_UDP) {
292315
udph = udp_hdr(skb);
@@ -2914,9 +2937,11 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
29142937
netdev->hw_features |= NETIF_F_RXCSUM;
29152938
if (ENIC_SETTING(enic, VXLAN)) {
29162939
u64 patch_level;
2940+
u64 a1 = 0;
29172941

29182942
netdev->hw_enc_features |= NETIF_F_RXCSUM |
29192943
NETIF_F_TSO |
2944+
NETIF_F_TSO6 |
29202945
NETIF_F_TSO_ECN |
29212946
NETIF_F_GSO_UDP_TUNNEL |
29222947
NETIF_F_HW_CSUM |
@@ -2935,9 +2960,10 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
29352960
*/
29362961
err = vnic_dev_get_supported_feature_ver(enic->vdev,
29372962
VIC_FEATURE_VXLAN,
2938-
&patch_level);
2963+
&patch_level, &a1);
29392964
if (err)
29402965
patch_level = 0;
2966+
enic->vxlan.flags = (u8)a1;
29412967
/* mask bits that are supported by driver
29422968
*/
29432969
patch_level &= BIT_ULL(0) | BIT_ULL(2);

drivers/net/ethernet/cisco/enic/vnic_dev.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,14 +1269,13 @@ int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
12691269
}
12701270

12711271
int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
1272-
u64 *supported_versions)
1272+
u64 *supported_versions, u64 *a1)
12731273
{
12741274
u64 a0 = feature;
12751275
int wait = 1000;
1276-
u64 a1 = 0;
12771276
int ret;
12781277

1279-
ret = vnic_dev_cmd(vdev, CMD_GET_SUPP_FEATURE_VER, &a0, &a1, wait);
1278+
ret = vnic_dev_cmd(vdev, CMD_GET_SUPP_FEATURE_VER, &a0, a1, wait);
12801279
if (!ret)
12811280
*supported_versions = a0;
12821281

drivers/net/ethernet/cisco/enic/vnic_dev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ int vnic_dev_overlay_offload_ctrl(struct vnic_dev *vdev, u8 overlay, u8 config);
183183
int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
184184
u16 vxlan_udp_port_number);
185185
int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
186-
u64 *supported_versions);
186+
u64 *supported_versions, u64 *a1);
187187

188188
#endif /* _VNIC_DEV_H_ */

drivers/net/ethernet/cisco/enic/vnic_devcmd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ enum overlay_ofld_cmd {
697697

698698
#define OVERLAY_CFG_VXLAN_PORT_UPDATE 0
699699

700+
#define ENIC_VXLAN_INNER_IPV6 BIT(0)
701+
#define ENIC_VXLAN_OUTER_IPV6 BIT(1)
702+
700703
/* Use this enum to get the supported versions for each of these features
701704
* If you need to use the devcmd_get_supported_feature_version(), add
702705
* the new feature into this enum and install function handler in devcmd.c

0 commit comments

Comments
 (0)