Skip to contentSkip to conversation

enic update

PATCH Applied Govindarajulu Varadarajan 2 participants 8 messages Mar 2, 2018 – Mar 4, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover enic update

This series adds support for IPv6 vxlan offload and UDP rss along with a bug fix in filling the rq ring.

Govindarajulu Varadarajan (6):
enic: Check inner ip proto for pseudo header csum
enic: Add vxlan offload support for IPv6 pkts
enic: Check if hw supports multi wq with vxlan offload
enic: set UDP rss flag
enic: enable rq before updating rq descriptors
enic: set IG desc cache flag in open

 drivers/net/ethernet/cisco/enic/enic.h         |  3 +-
 drivers/net/ethernet/cisco/enic/enic_ethtool.c | 36 ++++++++++++
 drivers/net/ethernet/cisco/enic/enic_main.c    | 81 +++++++++++++++++++++-----
 drivers/net/ethernet/cisco/enic/vnic_dev.c     | 22 ++++++-
 drivers/net/ethernet/cisco/enic/vnic_dev.h     |  3 +-
 drivers/net/ethernet/cisco/enic/vnic_devcmd.h  |  5 ++
 drivers/net/ethernet/cisco/enic/vnic_nic.h     |  1 +
 7 files changed, 131 insertions(+), 20 deletions(-)
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/6 enic: Check inner ip proto for pseudo header csum

To compute pseudo IP header csum, we need to check the inner header for encap pkt, not outer IP header.

Also add pseudo csum for IPv6 inner pkt.

---
 drivers/net/ethernet/cisco/enic/enic_main.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/ethernet/cisco/enic/enic_main.c +14 -1
index f202ba72a811..252285894968 100644
@@ -635,12 +635,25 @@ static int enic_queue_wq_skb_csum_l4(struct enic *enic, struct vnic_wq *wq,
 
 static void enic_preload_tcp_csum_encap(struct sk_buff *skb)
 {
-	if (skb->protocol == cpu_to_be16(ETH_P_IP)) {
+	const struct ethhdr *eth = (struct ethhdr *)skb_inner_mac_header(skb);
+
+	switch (eth->h_proto) {
+	case ntohs(ETH_P_IP):
 		inner_ip_hdr(skb)->check = 0;
 		inner_tcp_hdr(skb)->check =
 			~csum_tcpudp_magic(inner_ip_hdr(skb)->saddr,
 					   inner_ip_hdr(skb)->daddr, 0,
 					   IPPROTO_TCP, 0);
+		break;
+	case ntohs(ETH_P_IPV6):
+		inner_tcp_hdr(skb)->check =
+			~csum_ipv6_magic(&inner_ipv6_hdr(skb)->saddr,
+					 &inner_ipv6_hdr(skb)->daddr, 0,
+					 IPPROTO_TCP, 0);
+		break;
+	default:
+		WARN_ONCE(1, "Non ipv4/ipv6 inner pkt for encap offload");
+		break;
 	}
 }
 
Signature · 1 line
2.16.2
#2 lore raw

PATCH 2/6 enic: Add vxlan offload support for IPv6 pkts

In reply to Govindarajulu Varadarajan

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.

---
 drivers/net/ethernet/cisco/enic/enic.h        |  1 +
 drivers/net/ethernet/cisco/enic/enic_main.c   | 44 +++++++++++++++++++++------
 drivers/net/ethernet/cisco/enic/vnic_dev.c    |  5 ++-
 drivers/net/ethernet/cisco/enic/vnic_dev.h    |  2 +-
 drivers/net/ethernet/cisco/enic/vnic_devcmd.h |  3 ++
 5 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +1 -0
index 9b218f0e5a4c..83be9a5e8daa 100644
@@ -140,6 +140,7 @@ struct enic_rfs_flw_tbl {
 struct vxlan_offload {
 	u16 vxlan_udp_port_number;
 	u8 patch_level;
+	u8 flags;
 };
 
 /* Per-instance private data structure */
drivers/net/ethernet/cisco/enic/enic_main.c +35 -9

83 lines not on this page · raw message

drivers/net/ethernet/cisco/enic/vnic_dev.c +2 -3
index 39bad67422dd..b60fb6e3e775 100644
@@ -1269,14 +1269,13 @@ int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
 }
 
 int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
-				       u64 *supported_versions)
+				       u64 *supported_versions, u64 *a1)
 {
 	u64 a0 = feature;
 	int wait = 1000;
-	u64 a1 = 0;
 	int ret;
 
-	ret = vnic_dev_cmd(vdev, CMD_GET_SUPP_FEATURE_VER, &a0, &a1, wait);
+	ret = vnic_dev_cmd(vdev, CMD_GET_SUPP_FEATURE_VER, &a0, a1, wait);
 	if (!ret)
 		*supported_versions = a0;
 
drivers/net/ethernet/cisco/enic/vnic_dev.h +1 -1
index 9d43d6bb9907..db160f459852 100644
@@ -183,6 +183,6 @@ int vnic_dev_overlay_offload_ctrl(struct vnic_dev *vdev, u8 overlay, u8 config);
 int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
 				 u16 vxlan_udp_port_number);
 int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
-				       u64 *supported_versions);
+				       u64 *supported_versions, u64 *a1);
 
 #endif /* _VNIC_DEV_H_ */
drivers/net/ethernet/cisco/enic/vnic_devcmd.h +3 -0
index d83880b0d468..69529a3516cd 100644
@@ -697,6 +697,9 @@ enum overlay_ofld_cmd {
 
 #define OVERLAY_CFG_VXLAN_PORT_UPDATE	0
 
+#define ENIC_VXLAN_INNER_IPV6		BIT(0)
+#define ENIC_VXLAN_OUTER_IPV6		BIT(1)
+
 /* Use this enum to get the supported versions for each of these features
  * If you need to use the devcmd_get_supported_feature_version(), add
  * the new feature into this enum and install function handler in devcmd.c
Signature · 1 line
2.16.2
#3 lore raw

PATCH 3/6 enic: Check if hw supports multi wq with vxlan offload

In reply to Govindarajulu Varadarajan

Some adaptors do not support vxlan offload when multi wq is configured.

If hw supports multi wq, BIT(2) is set in a1.

---
 drivers/net/ethernet/cisco/enic/enic_main.c   | 5 +++++
 drivers/net/ethernet/cisco/enic/vnic_devcmd.h | 1 +
 2 files changed, 6 insertions(+)
drivers/net/ethernet/cisco/enic/enic_main.c +5 -0
index 848aac477cff..3280a05f9cf1 100644
@@ -212,6 +212,11 @@ static void enic_udp_tunnel_add(struct net_device *netdev,
 
 		goto error;
 	}
+	if ((vnic_dev_get_res_count(enic->vdev, RES_TYPE_WQ) != 1) &&
+	    !(enic->vxlan.flags & ENIC_VXLAN_MULTI_WQ)) {
+		netdev_info(netdev, "vxlan: vxlan offload with multi wq not supported on this adapter");
+		goto error;
+	}
 
 	err = vnic_dev_overlay_offload_cfg(enic->vdev,
 					   OVERLAY_CFG_VXLAN_PORT_UPDATE,
drivers/net/ethernet/cisco/enic/vnic_devcmd.h +1 -0
index 69529a3516cd..8fce9ef1c9bc 100644
@@ -699,6 +699,7 @@ enum overlay_ofld_cmd {
 
 #define ENIC_VXLAN_INNER_IPV6		BIT(0)
 #define ENIC_VXLAN_OUTER_IPV6		BIT(1)
+#define ENIC_VXLAN_MULTI_WQ		BIT(2)
 
 /* Use this enum to get the supported versions for each of these features
  * If you need to use the devcmd_get_supported_feature_version(), add
Signature · 1 line
2.16.2
#4 lore raw

PATCH 4/6 enic: set UDP rss flag

In reply to Govindarajulu Varadarajan

New hardware needs UDP flag set to enable UDP L4 rss hash. Add ethtool get option to display supported rss flow hash.

---
 drivers/net/ethernet/cisco/enic/enic_ethtool.c | 36 ++++++++++++++++++++++++++
 drivers/net/ethernet/cisco/enic/enic_main.c    |  4 ++-
 drivers/net/ethernet/cisco/enic/vnic_dev.c     | 17 ++++++++++++
 drivers/net/ethernet/cisco/enic/vnic_dev.h     |  1 +
 drivers/net/ethernet/cisco/enic/vnic_nic.h     |  1 +
 5 files changed, 58 insertions(+), 1 deletion(-)
drivers/net/ethernet/cisco/enic/enic_ethtool.c +36 -0
index efb9333c7cf8..869006c2002d 100644
@@ -474,6 +474,39 @@ static int enic_grxclsrule(struct enic *enic, struct ethtool_rxnfc *cmd)
 	return 0;
 }
 
+static int enic_get_rx_flow_hash(struct enic *enic, struct ethtool_rxnfc *cmd)
+{
+	cmd->data = 0;
+
+	switch (cmd->flow_type) {
+	case TCP_V6_FLOW:
+	case TCP_V4_FLOW:
+		cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
+		/* Fall through */
+	case UDP_V6_FLOW:
+	case UDP_V4_FLOW:
+		if (vnic_dev_capable_udp_rss(enic->vdev))
+			cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
+		/* Fall through */
+	case SCTP_V4_FLOW:
+	case AH_ESP_V4_FLOW:
+	case AH_V4_FLOW:
+	case ESP_V4_FLOW:
+	case SCTP_V6_FLOW:
+	case AH_ESP_V6_FLOW:
+	case AH_V6_FLOW:
+	case ESP_V6_FLOW:
+	case IPV4_FLOW:
+	case IPV6_FLOW:
+		cmd->data |= RXH_IP_SRC | RXH_IP_DST;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
 			  u32 *rule_locs)
 {
@@ -500,6 +533,9 @@ static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
 		ret = enic_grxclsrule(enic, cmd);
 		spin_unlock_bh(&enic->rfs_h.lock);
 		break;
+	case ETHTOOL_GRXFH:
+		ret = enic_get_rx_flow_hash(enic, cmd);
+		break;
 	default:
 		ret = -EOPNOTSUPP;
 		break;
drivers/net/ethernet/cisco/enic/enic_main.c +3 -1
index 3280a05f9cf1..5213bc01a6e9 100644
@@ -2316,7 +2316,7 @@ static int enic_set_rss_nic_cfg(struct enic *enic)
 {
 	struct device *dev = enic_get_dev(enic);
 	const u8 rss_default_cpu = 0;
-	const u8 rss_hash_type = NIC_CFG_RSS_HASH_TYPE_IPV4 |
+	u8 rss_hash_type = NIC_CFG_RSS_HASH_TYPE_IPV4 |
 		NIC_CFG_RSS_HASH_TYPE_TCP_IPV4 |
 		NIC_CFG_RSS_HASH_TYPE_IPV6 |
 		NIC_CFG_RSS_HASH_TYPE_TCP_IPV6;
@@ -2324,6 +2324,8 @@ static int enic_set_rss_nic_cfg(struct enic *enic)
 	const u8 rss_base_cpu = 0;
 	u8 rss_enable = ENIC_SETTING(enic, RSS) && (enic->rq_count > 1);
 
+	if (vnic_dev_capable_udp_rss(enic->vdev))
+		rss_hash_type |= NIC_CFG_RSS_HASH_TYPE_UDP;
 	if (rss_enable) {
 		if (!enic_set_rsskey(enic)) {
 			if (enic_set_rsscpu(enic, rss_hash_bits)) {
drivers/net/ethernet/cisco/enic/vnic_dev.c +17 -0
index b60fb6e3e775..a2b376055b2d 100644
@@ -1281,3 +1281,20 @@ int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
 
 	return ret;
 }
+
+bool vnic_dev_capable_udp_rss(struct vnic_dev *vdev)
+{
+	u64 a0 = CMD_NIC_CFG, a1 = 0;
+	u64 rss_hash_type;
+	int wait = 1000;
+	int err;
+
+	err = vnic_dev_cmd(vdev, CMD_CAPABILITY, &a0, &a1, wait);
+	if (err || !a0)
+		return 0;
+
+	rss_hash_type = (a1 >> NIC_CFG_RSS_HASH_TYPE_SHIFT) &
+			NIC_CFG_RSS_HASH_TYPE_MASK_FIELD;
+
+	return (rss_hash_type & NIC_CFG_RSS_HASH_TYPE_UDP);
+}
drivers/net/ethernet/cisco/enic/vnic_dev.h +1 -0
index db160f459852..59d4cc8fbb85 100644
@@ -184,5 +184,6 @@ int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
 				 u16 vxlan_udp_port_number);
 int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
 				       u64 *supported_versions, u64 *a1);
+bool vnic_dev_capable_udp_rss(struct vnic_dev *vdev);
 
 #endif /* _VNIC_DEV_H_ */
drivers/net/ethernet/cisco/enic/vnic_nic.h +1 -0
index 995a50dd4c99..5a93db0d7afc 100644
@@ -47,6 +47,7 @@
 #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6		(1 << 4)
 #define NIC_CFG_RSS_HASH_TYPE_IPV6_EX		(1 << 5)
 #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6_EX	(1 << 6)
+#define NIC_CFG_RSS_HASH_TYPE_UDP		(1 << 7)
 
 static inline void vnic_set_nic_cfg(u32 *nic_cfg,
 	u8 rss_default_cpu, u8 rss_hash_type,
Signature · 1 line
2.16.2
#5 lore raw

PATCH 5/6 enic: enable rq before updating rq descriptors

In reply to Govindarajulu Varadarajan

rq should be enabled before posting the buffers to rq desc. If not hw sees stale value and casuses DMAR errors.

---
 drivers/net/ethernet/cisco/enic/enic_main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +7 -3
index 5213bc01a6e9..243d5c5fd5e3 100644
@@ -1939,6 +1939,8 @@ static int enic_open(struct net_device *netdev)
 	}
 
 	for (i = 0; i < enic->rq_count; i++) {
+		/* enable rq before updating rq desc */
+		vnic_rq_enable(&enic->rq[i]);
 		vnic_rq_fill(&enic->rq[i], enic_rq_alloc_buf);
 		/* Need at least one buffer on ring to get going */
 		if (vnic_rq_desc_used(&enic->rq[i]) == 0) {
@@ -1950,8 +1952,6 @@ static int enic_open(struct net_device *netdev)
 
 	for (i = 0; i < enic->wq_count; i++)
 		vnic_wq_enable(&enic->wq[i]);
-	for (i = 0; i < enic->rq_count; i++)
-		vnic_rq_enable(&enic->rq[i]);
 
 	if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
 		enic_dev_add_station_addr(enic);
@@ -1977,8 +1977,12 @@ static int enic_open(struct net_device *netdev)
 	return 0;
 
 err_out_free_rq:
-	for (i = 0; i < enic->rq_count; i++)
+	for (i = 0; i < enic->rq_count; i++) {
+		err = vnic_rq_disable(&enic->rq[i]);
+		if (err)
+			return err;
 		vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
+	}
 	enic_dev_notify_unset(enic);
 err_out_free_intr:
 	enic_unset_affinity_hint(enic);
Signature · 1 line
2.16.2
#6 lore raw

PATCH 6/6 enic: set IG desc cache flag in open

In reply to Govindarajulu Varadarajan

New adapter needs CMD_OPENF_IG_DESCCACHE flag to be set. If this flag is not set, fw flushes the global IG desc cache. This flag is nop in older adapter.

Also increment driver version

---
 drivers/net/ethernet/cisco/enic/enic.h        | 2 +-
 drivers/net/ethernet/cisco/enic/enic_main.c   | 3 ++-
 drivers/net/ethernet/cisco/enic/vnic_devcmd.h | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +1 -1
index 83be9a5e8daa..0dd64acd2a3f 100644
@@ -33,7 +33,7 @@
 
 #define DRV_NAME		"enic"
 #define DRV_DESCRIPTION		"Cisco VIC Ethernet NIC Driver"
-#define DRV_VERSION		"2.3.0.45"
+#define DRV_VERSION		"2.3.0.53"
 #define DRV_COPYRIGHT		"Copyright 2008-2013 Cisco Systems, Inc"
 
 #define ENIC_BARS_MAX		6
drivers/net/ethernet/cisco/enic/enic_main.c +2 -1
index 243d5c5fd5e3..a25fb95492a0 100644
@@ -2196,9 +2196,10 @@ static int enic_dev_wait(struct vnic_dev *vdev,
 static int enic_dev_open(struct enic *enic)
 {
 	int err;
+	u32 flags = CMD_OPENF_IG_DESCCACHE;
 
 	err = enic_dev_wait(enic->vdev, vnic_dev_open,
-		vnic_dev_open_done, 0);
+		vnic_dev_open_done, flags);
 	if (err)
 		dev_err(enic_get_dev(enic), "vNIC device open failed, err %d\n",
 			err);
drivers/net/ethernet/cisco/enic/vnic_devcmd.h +1 -0
index 8fce9ef1c9bc..41de4ba622a1 100644
@@ -439,6 +439,7 @@ enum vnic_devcmd_cmd {
 
 /* flags for CMD_OPEN */
 #define CMD_OPENF_OPROM		0x1	/* open coming from option rom */
+#define CMD_OPENF_IG_DESCCACHE	0x2	/* Do not flush IG DESC cache */
 
 /* flags for CMD_INIT */
 #define CMD_INITF_DEFAULT_MAC	0x1	/* init with default mac addr */
Signature · 1 line
2.16.2