Skip to contentSkip to conversation

net/enic: remove 'extern' in .h file function declarations

PATCH Superseded John Daley 6 participants 44 messages Feb 24, 2018 – Mar 14, 2018

Subsystems (2)
lore
Share & tools
lore

John Daley

author
#0 lore raw

PATCH 1/1 net/enic: remove 'extern' in .h file function declarations

---
 drivers/net/enic/enic.h | 80 ++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 40 deletions(-)
drivers/net/enic/enic.h +40 -40
index c083985ee..e88af6bc9 100644
@@ -220,54 +220,54 @@ enic_ring_incr(uint32_t n_descriptors, uint32_t idx)
 	return idx;
 }
 
-extern void enic_fdir_stats_get(struct enic *enic,
-	struct rte_eth_fdir_stats *stats);
-extern int enic_fdir_add_fltr(struct enic *enic,
-	struct rte_eth_fdir_filter *params);
-extern int enic_fdir_del_fltr(struct enic *enic,
-	struct rte_eth_fdir_filter *params);
-extern void enic_free_wq(void *txq);
-extern int enic_alloc_intr_resources(struct enic *enic);
-extern int enic_setup_finish(struct enic *enic);
-extern int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
-	unsigned int socket_id, uint16_t nb_desc);
-extern void enic_start_wq(struct enic *enic, uint16_t queue_idx);
-extern int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
-extern void enic_start_rq(struct enic *enic, uint16_t queue_idx);
-extern int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
-extern void enic_free_rq(void *rxq);
-extern int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
-	unsigned int socket_id, struct rte_mempool *mp,
-	uint16_t nb_desc, uint16_t free_thresh);
-extern int enic_set_rss_nic_cfg(struct enic *enic);
-extern int enic_set_vnic_res(struct enic *enic);
-extern int enic_enable(struct enic *enic);
-extern int enic_disable(struct enic *enic);
-extern void enic_remove(struct enic *enic);
-extern int enic_get_link_status(struct enic *enic);
-extern int enic_dev_stats_get(struct enic *enic,
-	struct rte_eth_stats *r_stats);
-extern void enic_dev_stats_clear(struct enic *enic);
-extern void enic_add_packet_filter(struct enic *enic);
+void enic_fdir_stats_get(struct enic *enic,
+			 struct rte_eth_fdir_stats *stats);
+int enic_fdir_add_fltr(struct enic *enic,
+		       struct rte_eth_fdir_filter *params);
+int enic_fdir_del_fltr(struct enic *enic,
+		       struct rte_eth_fdir_filter *params);
+void enic_free_wq(void *txq);
+int enic_alloc_intr_resources(struct enic *enic);
+int enic_setup_finish(struct enic *enic);
+int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
+		  unsigned int socket_id, uint16_t nb_desc);
+void enic_start_wq(struct enic *enic, uint16_t queue_idx);
+int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
+void enic_start_rq(struct enic *enic, uint16_t queue_idx);
+int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
+void enic_free_rq(void *rxq);
+int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
+		  unsigned int socket_id, struct rte_mempool *mp,
+		  uint16_t nb_desc, uint16_t free_thresh);
+int enic_set_rss_nic_cfg(struct enic *enic);
+int enic_set_vnic_res(struct enic *enic);
+int enic_enable(struct enic *enic);
+int enic_disable(struct enic *enic);
+void enic_remove(struct enic *enic);
+int enic_get_link_status(struct enic *enic);
+int enic_dev_stats_get(struct enic *enic,
+		       struct rte_eth_stats *r_stats);
+void enic_dev_stats_clear(struct enic *enic);
+void enic_add_packet_filter(struct enic *enic);
 int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr);
 void enic_del_mac_address(struct enic *enic, int mac_index);
-extern unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
-extern void enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
-			  struct rte_mbuf *tx_pkt, unsigned short len,
-			  uint8_t sop, uint8_t eop, uint8_t cq_entry,
-			  uint16_t ol_flags, uint16_t vlan_tag);
-
-extern void enic_post_wq_index(struct vnic_wq *wq);
-extern int enic_probe(struct enic *enic);
-extern int enic_clsf_init(struct enic *enic);
-extern void enic_clsf_destroy(struct enic *enic);
+unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
+void enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
+		   struct rte_mbuf *tx_pkt, unsigned short len,
+		   uint8_t sop, uint8_t eop, uint8_t cq_entry,
+		   uint16_t ol_flags, uint16_t vlan_tag);
+
+void enic_post_wq_index(struct vnic_wq *wq);
+int enic_probe(struct enic *enic);
+int enic_clsf_init(struct enic *enic);
+void enic_clsf_destroy(struct enic *enic);
 uint16_t enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			uint16_t nb_pkts);
 uint16_t enic_dummy_recv_pkts(void *rx_queue,
 			      struct rte_mbuf **rx_pkts,
 			      uint16_t nb_pkts);
 uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
-			       uint16_t nb_pkts);
+			uint16_t nb_pkts);
 uint16_t enic_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
 int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
Signature · 1 line
2.12.0
author
#1 lore raw

PATCH 1/1 net/enic: allocate stats DMA buffer upfront during probe

From: Hyong Youb Kim <[email protected]>

The driver provides a DMA buffer to the firmware when it requests port stats. The NIC then fills that buffer with latest stats. Currently, the driver allocates the DMA buffer the first time it requests stats and saves it for later use. This can lead to crashes when primary/secondary processes are involved. For example, the following sequence crashes the secondary process.

1. Start a primary app that does not call rte_eth_stats_get()
2. dpdk-procinfo -- --stats

dpdk-procinfo crashes while trying to allocate the stats DMA buffer because the alloc function pointer (vdev.alloc_consistent) is valid only in the primary process, not in the secondary process.

Overwriting the alloc function pointer in the secondary process is not an option, as it will simply make the pointer invalid in the primary process. Instead, allocate the DMA buffer during probe so that only the primary process does both allocate and free. This allows the secondary process to dump stats as well.

Fixes 9913fbb91df0 ("enic/base: common code")
---
 drivers/net/enic/base/vnic_dev.c | 24 ++++++++++++++----------
 drivers/net/enic/base/vnic_dev.h |  1 +
 drivers/net/enic/enic_main.c     |  9 +++++++++
 3 files changed, 24 insertions(+), 10 deletions(-)
drivers/net/enic/base/vnic_dev.c +14 -10
index 05b595eb8..1f8d222fc 100644
@@ -587,17 +587,9 @@ int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats)
 {
 	u64 a0, a1;
 	int wait = 1000;
-	static u32 instance;
-	char name[NAME_MAX];
 
-	if (!vdev->stats) {
-		snprintf((char *)name, sizeof(name),
-			"vnic_stats-%u", instance++);
-		vdev->stats = vdev->alloc_consistent(vdev->priv,
-			sizeof(struct vnic_stats), &vdev->stats_pa, (u8 *)name);
-		if (!vdev->stats)
-			return -ENOMEM;
-	}
+	if (!vdev->stats)
+		return -ENOMEM;
 
 	*stats = vdev->stats;
 	a0 = vdev->stats_pa;
@@ -922,6 +914,18 @@ u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev)
 	return vdev->intr_coal_timer_info.max_usec;
 }
 
+int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev)
+{
+	char name[NAME_MAX];
+	static u32 instance;
+
+	snprintf((char *)name, sizeof(name), "vnic_stats-%u", instance++);
+	vdev->stats = vdev->alloc_consistent(vdev->priv,
+					     sizeof(struct vnic_stats),
+					     &vdev->stats_pa, (u8 *)name);
+	return vdev->stats == NULL ? -ENOMEM : 0;
+}
+
 void vnic_dev_unregister(struct vnic_dev *vdev)
 {
 	if (vdev) {
drivers/net/enic/base/vnic_dev.h +1 -0
index 8c0992063..7e5736b4d 100644
@@ -165,6 +165,7 @@ struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
 	void *priv, struct rte_pci_device *pdev, struct vnic_dev_bar *bar,
 	unsigned int num_bars);
 struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev);
+int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev);
 int vnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
 int vnic_dev_get_size(void);
 int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op);
drivers/net/enic/enic_main.c +9 -0
index d4f478b5e..bd4447f01 100644
@@ -1478,6 +1478,15 @@ int enic_probe(struct enic *enic)
 		enic_alloc_consistent,
 		enic_free_consistent);
 
+	/*
+	 * Allocate the consistent memory for stats upfront so both primary and
+	 * secondary processes can dump stats.
+	 */
+	err = vnic_dev_alloc_stats_mem(enic->vdev);
+	if (err) {
+		dev_err(enic, "Failed to allocate cmd memory, aborting\n");
+		goto err_out_unregister;
+	}
 	/* Issue device open to get device in known state */
 	err = enic_dev_open(enic);
 	if (err) {
Signature · 1 line
2.12.0
author
#2 lore raw

PATCH 1/1 net/enic: allow the user to change RSS settings

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Currently, when more than 1 receive queues are configured, the driver always enables RSS with the driver's own default hash type, key, and RETA. The user is unable to change any of the RSS settings. Address this by implementing the ethdev RSS API as follows.

Correctly report the RETA size, key size, and supported hash types through rte_eth_dev_info.

During dev_configure(), initialize RSS according to the device's mq_mode and rss_conf. Start with the default RETA, and use the default key unless a custom key is provided.

Add the RETA and rss_conf query/set handlers to let the user change RSS settings after the initial configuration. The hardware is able to change hash type, key, and RETA individually. So, the handlers change only the affected settings.

Refactor/rename several functions in order to make their intentions clear. For example, remove all traces of RSS from enicpmd_vlan_offload_set() as it is confusing.

---
 doc/guides/nics/features/enic.ini |   2 +
 drivers/net/enic/enic.h           |  20 +++-
 drivers/net/enic/enic_ethdev.c    | 117 ++++++++++++++++++++++-
 drivers/net/enic/enic_main.c      | 192 ++++++++++++++++++++++++++++----------
 drivers/net/enic/enic_res.c       |  20 ++++
 drivers/net/enic/enic_res.h       |   6 ++
 6 files changed, 301 insertions(+), 56 deletions(-)
doc/guides/nics/features/enic.ini +2 -0
index 498341f07..e79d7277d 100644
@@ -15,6 +15,8 @@ Promiscuous mode     = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
 RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
 SR-IOV               = Y
 VLAN filter          = Y
 CRC offload          = Y
drivers/net/enic/enic.h +19 -1
index e88af6bc9..d29939c94 100644
@@ -146,6 +146,20 @@ struct enic {
 
 	LIST_HEAD(enic_flows, rte_flow) flows;
 	rte_spinlock_t flows_lock;
+
+	/* RSS */
+	uint16_t reta_size;
+	uint8_t hash_key_size;
+	uint64_t flow_type_rss_offloads; /* 0 indicates RSS not supported */
+	/*
+	 * Keep a copy of current RSS config for queries, as we cannot retrieve
+	 * it from the NIC.
+	 */
+	uint8_t rss_hash_type; /* NIC_CFG_RSS_HASH_TYPE flags */
+	uint8_t rss_enable;
+	uint64_t rss_hf; /* ETH_RSS flags */
+	union vnic_rss_key rss_key;
+	union vnic_rss_cpu rss_cpu;
 };
 
 /* Get the CQ index from a Start of Packet(SOP) RQ index */
@@ -239,8 +253,12 @@ void enic_free_rq(void *rxq);
 int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
 		  unsigned int socket_id, struct rte_mempool *mp,
 		  uint16_t nb_desc, uint16_t free_thresh);
-int enic_set_rss_nic_cfg(struct enic *enic);
 int enic_set_vnic_res(struct enic *enic);
+int enic_init_rss_nic_cfg(struct enic *enic);
+int enic_set_rss_conf(struct enic *enic,
+		      struct rte_eth_rss_conf *rss_conf);
+int enic_set_rss_reta(struct enic *enic, union vnic_rss_cpu *rss_cpu);
+int enic_set_vlan_strip(struct enic *enic);
 int enic_enable(struct enic *enic);
 int enic_disable(struct enic *enic);
 void enic_remove(struct enic *enic);
drivers/net/enic/enic_ethdev.c +112 -5

153 lines not on this page · raw message

drivers/net/enic/enic_main.c +142 -50

262 lines not on this page · raw message

drivers/net/enic/enic_res.c +20 -0
index c99d61837..d8f7892c3 100644
@@ -128,6 +128,26 @@ int enic_get_vnic_config(struct enic *enic)
 		c->intr_timer_usec,
 		c->loop_tag);
 
+	/* RSS settings from vNIC */
+	enic->reta_size = ENIC_RSS_RETA_SIZE;
+	enic->hash_key_size = ENIC_RSS_HASH_KEY_SIZE;
+	enic->flow_type_rss_offloads = 0;
+	if (ENIC_SETTING(enic, RSSHASH_IPV4))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV4;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV4))
+		enic->flow_type_rss_offloads |= ETH_RSS_NONFRAG_IPV4_TCP;
+	if (ENIC_SETTING(enic, RSSHASH_IPV6))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV6))
+		enic->flow_type_rss_offloads |= ETH_RSS_NONFRAG_IPV6_TCP;
+	if (ENIC_SETTING(enic, RSSHASH_IPV6_EX))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6_EX;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV6_EX))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6_TCP_EX;
+	/* Zero offloads if RSS is not enabled */
+	if (!ENIC_SETTING(enic, RSS))
+		enic->flow_type_rss_offloads = 0;
+
 	return 0;
 }
 
drivers/net/enic/enic_res.h +6 -0
index cf3a6fde8..e68f1307b 100644
@@ -31,6 +31,12 @@
 #define ENIC_DEFAULT_RX_FREE_THRESH	32
 #define ENIC_TX_XMIT_MAX		64
 
+#define ENIC_RSS_DEFAULT_CPU    0
+#define ENIC_RSS_BASE_CPU       0
+#define ENIC_RSS_HASH_BITS      7
+#define ENIC_RSS_RETA_SIZE      (1 << ENIC_RSS_HASH_BITS)
+#define ENIC_RSS_HASH_KEY_SIZE  40
+
 #define ENIC_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0)
 
 
Signature · 1 line
2.12.0
author
#3 lore raw

PATCH 1/1 net/enic: heed the requested max Rx packet size

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Currently, enic completely ignores the requested max Rx packet size (rxmode.max_rx_pkt_len). The desired behavior is that the NIC hardware drops packets larger than the requested size, even though they are still smaller than MTU.

Cisco VIC does not have such a feature. But, we can accomplish a similar (not same) effect by reducing the size of posted receive buffers. Packets larger than the posted size get truncated, and the receive handler drops them. This is also how the kernel enic driver enforces the Rx side MTU.

This workaround works only when scatter mode is *not* used. When scatter is used, there is currently no way to support rxmode.max_rx_pkt_len, as the NIC always receives packets up to MTU.

For posterity, add a copious amount of comments regarding the hardware's drop/receive behavior with respect to max/current MTU.

---
 doc/guides/nics/enic.rst       |  1 +
 drivers/net/enic/enic.h        |  7 ++++++
 drivers/net/enic/enic_ethdev.c |  9 +++++++-
 drivers/net/enic/enic_main.c   | 49 ++++++++++++++++++++++++++++++++++++------
 4 files changed, 58 insertions(+), 8 deletions(-)
doc/guides/nics/enic.rst +1 -0
index 4dffce1a6..0e655e9e3 100644
@@ -371,6 +371,7 @@ Known bugs and unsupported features in this release
 - Setting of extended VLAN
 - UDP RSS hashing
 - MTU update only works if Scattered Rx mode is disabled
+- Maximum receive packet length is ignored if Scattered Rx mode is used
 
 Prerequisites
 -------------
drivers/net/enic/enic.h +7 -0
index d29939c94..1b3813a58 100644
@@ -162,6 +162,13 @@ struct enic {
 	union vnic_rss_cpu rss_cpu;
 };
 
+/* Compute ethdev's max packet size from MTU */
+static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu)
+{
+	/* ethdev max size includes eth and crc whereas NIC MTU does not */
+	return mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+}
+
 /* Get the CQ index from a Start of Packet(SOP) RQ index */
 static inline unsigned int enic_sop_rq_idx_to_cq_idx(unsigned int sop_idx)
 {
drivers/net/enic/enic_ethdev.c +8 -1
index cbab7029b..bdbaf4cdf 100644
@@ -470,7 +470,14 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	device_info->max_rx_queues = enic->conf_rq_count / 2;
 	device_info->max_tx_queues = enic->conf_wq_count;
 	device_info->min_rx_bufsize = ENIC_MIN_MTU;
-	device_info->max_rx_pktlen = enic->max_mtu + ETHER_HDR_LEN + 4;
+	/* "Max" mtu is not a typo. HW receives packet sizes up to the
+	 * max mtu regardless of the current mtu (vNIC's mtu). vNIC mtu is
+	 * a hint to the driver to size receive buffers accordingly so that
+	 * larger-than-vnic-mtu packets get truncated.. For DPDK, we let
+	 * the user decide the buffer size via rxmode.max_rx_pkt_len, basically
+	 * ignoring vNIC mtu.
+	 */
+	device_info->max_rx_pktlen = enic_mtu_to_max_rx_pktlen(enic->max_mtu);
 	device_info->max_mac_addrs = ENIC_MAX_MAC_ADDR;
 	device_info->rx_offload_capa =
 		DEV_RX_OFFLOAD_VLAN_STRIP |
drivers/net/enic/enic_main.c +42 -7

98 lines not on this page · raw message

Signature · 1 line
2.12.0
author
#4 lore raw

PATCH 1/1 net/enic: remove the VLAN filter handler

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

VIC does not support VLAN filtering at the moment. The firmware does accept the filter add/del commands and returns success. But, they are no-ops. To avoid confusion, remove the filter set handler so the app sees an error instead of silent failure.

Also during the device configure time, enicpmd_vlan_offload_set would not print a warning message about unsupported VLAN filtering, because the caller specifies only ETH_VLAN_STRIP_MASK. This is wrong, as we should attempt to apply all requested offloads at the configure time. So, pass all VLAN offload masks, which triggers a warning message about VLAN filtering, if requested.

Finally, enicpmd_vlan_offload_set should check both mask and rxmode.offloads, not just mask.

---
 drivers/net/enic/enic_ethdev.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/net/enic/enic_ethdev.c +14 -20
index bdbaf4cdf..e5523e311 100644
@@ -318,40 +318,29 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	return enicpmd_dev_setup_intr(enic);
 }
 
-static int enicpmd_vlan_filter_set(struct rte_eth_dev *eth_dev,
-	uint16_t vlan_id, int on)
-{
-	struct enic *enic = pmd_priv(eth_dev);
-	int err;
-
-	ENICPMD_FUNC_TRACE();
-	if (on)
-		err = enic_add_vlan(enic, vlan_id);
-	else
-		err = enic_del_vlan(enic, vlan_id);
-	return err;
-}
-
 static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 {
 	struct enic *enic = pmd_priv(eth_dev);
+	uint64_t offloads;
 
 	ENICPMD_FUNC_TRACE();
 
+	offloads = eth_dev->data->dev_conf.rxmode.offloads;
 	if (mask & ETH_VLAN_STRIP_MASK) {
-		if (eth_dev->data->dev_conf.rxmode.offloads &
-		    DEV_RX_OFFLOAD_VLAN_STRIP)
+		if (offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
 			enic->ig_vlan_strip_en = 1;
 		else
 			enic->ig_vlan_strip_en = 0;
 	}
 
-	if (mask & ETH_VLAN_FILTER_MASK) {
+	if ((mask & ETH_VLAN_FILTER_MASK) &&
+	    (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) {
 		dev_warning(enic,
 			"Configuration of VLAN filter is not supported\n");
 	}
 
-	if (mask & ETH_VLAN_EXTEND_MASK) {
+	if ((mask & ETH_VLAN_EXTEND_MASK) &&
+	    (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) {
 		dev_warning(enic,
 			"Configuration of extended VLAN is not supported\n");
 	}
@@ -362,6 +351,7 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
 {
 	int ret;
+	int mask;
 	struct enic *enic = pmd_priv(eth_dev);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -376,7 +366,11 @@ static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
 
 	enic->hw_ip_checksum = !!(eth_dev->data->dev_conf.rxmode.offloads &
 				  DEV_RX_OFFLOAD_CHECKSUM);
-	ret = enicpmd_vlan_offload_set(eth_dev, ETH_VLAN_STRIP_MASK);
+	/* All vlan offload masks to apply the current settings */
+	mask = ETH_VLAN_STRIP_MASK |
+		ETH_VLAN_FILTER_MASK |
+		ETH_VLAN_EXTEND_MASK;
+	ret = enicpmd_vlan_offload_set(eth_dev, mask);
 	if (ret) {
 		dev_err(enic, "Failed to configure VLAN offloads\n");
 		return ret;
@@ -710,7 +704,7 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_infos_get        = enicpmd_dev_info_get,
 	.dev_supported_ptypes_get = enicpmd_dev_supported_ptypes_get,
 	.mtu_set              = enicpmd_mtu_set,
-	.vlan_filter_set      = enicpmd_vlan_filter_set,
+	.vlan_filter_set      = NULL,
 	.vlan_tpid_set        = NULL,
 	.vlan_offload_set     = enicpmd_vlan_offload_set,
 	.vlan_strip_queue_set = NULL,
Signature · 1 line
2.12.0
author
#5 lore raw

PATCH 1/1 net/enic: add Rx/Tx queue configuration getters

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/enic_ethdev.c | 76 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 65 insertions(+), 11 deletions(-)
drivers/net/enic/enic_ethdev.c +65 -11
index e5523e311..6dd72729e 100644
@@ -39,6 +39,19 @@ static const struct rte_pci_id pci_id_enic_map[] = {
 	{.vendor_id = 0, /* sentinel */},
 };
 
+#define ENIC_TX_OFFLOAD_CAPA (			\
+		DEV_TX_OFFLOAD_VLAN_INSERT |	\
+		DEV_TX_OFFLOAD_IPV4_CKSUM  |	\
+		DEV_TX_OFFLOAD_UDP_CKSUM   |	\
+		DEV_TX_OFFLOAD_TCP_CKSUM   |	\
+		DEV_TX_OFFLOAD_TCP_TSO)
+
+#define ENIC_RX_OFFLOAD_CAPA (			\
+		DEV_RX_OFFLOAD_VLAN_STRIP |	\
+		DEV_RX_OFFLOAD_IPV4_CKSUM |	\
+		DEV_RX_OFFLOAD_UDP_CKSUM  |	\
+		DEV_RX_OFFLOAD_TCP_CKSUM)
+
 RTE_INIT(enicpmd_init_log);
 static void
 enicpmd_init_log(void)
@@ -473,17 +486,8 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	 */
 	device_info->max_rx_pktlen = enic_mtu_to_max_rx_pktlen(enic->max_mtu);
 	device_info->max_mac_addrs = ENIC_MAX_MAC_ADDR;
-	device_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_VLAN_STRIP |
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM  |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-	device_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_VLAN_INSERT |
-		DEV_TX_OFFLOAD_IPV4_CKSUM  |
-		DEV_TX_OFFLOAD_UDP_CKSUM   |
-		DEV_TX_OFFLOAD_TCP_CKSUM   |
-		DEV_TX_OFFLOAD_TCP_TSO;
+	device_info->rx_offload_capa = ENIC_RX_OFFLOAD_CAPA;
+	device_info->tx_offload_capa = ENIC_TX_OFFLOAD_CAPA;
 	device_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = ENIC_DEFAULT_RX_FREE_THRESH
 	};
@@ -686,6 +690,54 @@ static int enicpmd_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void enicpmd_dev_rxq_info_get(struct rte_eth_dev *dev,
+				     uint16_t rx_queue_id,
+				     struct rte_eth_rxq_info *qinfo)
+{
+	struct enic *enic = pmd_priv(dev);
+	struct vnic_rq *rq_sop;
+	struct vnic_rq *rq_data;
+	struct rte_eth_rxconf *conf;
+	uint16_t sop_queue_idx;
+	uint16_t data_queue_idx;
+
+	ENICPMD_FUNC_TRACE();
+	sop_queue_idx = enic_rte_rq_idx_to_sop_idx(rx_queue_id);
+	data_queue_idx = enic_rte_rq_idx_to_data_idx(rx_queue_id);
+	rq_sop = &enic->rq[sop_queue_idx];
+	rq_data = &enic->rq[data_queue_idx]; /* valid if data_queue_enable */
+	qinfo->mp = rq_sop->mp;
+	qinfo->scattered_rx = rq_sop->data_queue_enable;
+	qinfo->nb_desc = rq_sop->ring.desc_count;
+	if (qinfo->scattered_rx)
+		qinfo->nb_desc += rq_data->ring.desc_count;
+	conf = &qinfo->conf;
+	memset(conf, 0, sizeof(*conf));
+	conf->rx_free_thresh = rq_sop->rx_free_thresh;
+	conf->rx_drop_en = 1;
+	/*
+	 * Except VLAN stripping (port setting), all the checksum offloads
+	 * are always enabled.
+	 */
+	conf->offloads = ENIC_RX_OFFLOAD_CAPA;
+	if (!enic->ig_vlan_strip_en)
+		conf->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
+	/* rx_thresh and other fields are not applicable for enic */
+}
+
+static void enicpmd_dev_txq_info_get(struct rte_eth_dev *dev,
+				     __rte_unused uint16_t tx_queue_id,
+				     struct rte_eth_txq_info *qinfo)
+{
+	struct enic *enic = pmd_priv(dev);
+
+	ENICPMD_FUNC_TRACE();
+	qinfo->nb_desc = enic->config.wq_desc_count;
+	memset(&qinfo->conf, 0, sizeof(qinfo->conf));
+	qinfo->conf.offloads = ENIC_TX_OFFLOAD_CAPA; /* not configurable */
+	/* tx_thresh, and all the other fields are not applicable for enic */
+}
+
 static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_configure        = enicpmd_dev_configure,
 	.dev_start            = enicpmd_dev_start,
@@ -718,6 +770,8 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.rx_descriptor_done   = NULL,
 	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
 	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.rxq_info_get         = enicpmd_dev_rxq_info_get,
+	.txq_info_get         = enicpmd_dev_txq_info_get,
 	.dev_led_on           = NULL,
 	.dev_led_off          = NULL,
 	.flow_ctrl_get        = NULL,
Signature · 1 line
2.12.0
author
#6 lore raw

PATCH 1/1 net/enic: support Rx queue interrupts

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Enable rx queue interrupts if the app requests them, and vNIC has enough interrupt resources. Use interrupt vector 0 for link status and errors. Use vector 1 for rx queue 0, vector 2 for rx queue 1, and so on. So, with n rx queues, vNIC needs to have at n + 1 interrupts.

For VIC, enabling and disabling rx queue interrupts are simply mask/unmask operations. VIC's credit based interrupt moderation is not used, as the app wants to explicitly control when to enable/disable interrupts.

This version requires MSI-X (vfio-pci). Sharing one interrupt for link status and rx queues is possible, but is rather complex and has no user demands.

---
 doc/guides/nics/enic.rst          |   7 ++-
 doc/guides/nics/features/enic.ini |   1 +
 drivers/net/enic/enic.h           |  15 ++++-
 drivers/net/enic/enic_ethdev.c    |  22 +++++++
 drivers/net/enic/enic_main.c      | 123 ++++++++++++++++++++++++++++++++------
 drivers/net/enic/enic_res.c       |   3 +-
 6 files changed, 149 insertions(+), 22 deletions(-)
doc/guides/nics/enic.rst +6 -1
index 0e655e9e3..7e19cf88a 100644
@@ -114,11 +114,16 @@ Configuration information
 
   - **Interrupts**
 
-    Only one interrupt per vNIC interface should be configured in the UCS
+    At least one interrupt per vNIC interface should be configured in the UCS
     manager regardless of the number receive/transmit queues. The ENIC PMD
     uses this interrupt to get information about link status and errors
     in the fast path.
 
+    In addition to the interrupt for link status and errors, when using Rx queue
+    interrupts, increase the number of configured interrupts so that there is at
+    least one interrupt for each Rx queue. For example, if the app uses 3 Rx
+    queues and wants to use per-queue interrupts, configure 4 (3 + 1) interrupts.
+
 .. _enic-flow-director:
 
 Flow director support
doc/guides/nics/features/enic.ini +1 -0
index e79d7277d..ea171a45b 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Link status event    = Y
+Rx interrupt         = Y
 Queue start/stop     = Y
 MTU update           = Y
 Jumbo frame          = Y
drivers/net/enic/enic.h +12 -3
index 1b3813a58..adccc8ac5 100644
@@ -49,6 +49,15 @@
 
 #define ENICPMD_FDIR_MAX           64
 
+/*
+ * Interrupt 0: LSC and errors
+ * Interrupt 1: rx queue 0
+ * Interrupt 2: rx queue 1
+ * ...
+ */
+#define ENICPMD_LSC_INTR_OFFSET 0
+#define ENICPMD_RXQ_INTR_OFFSET 1
+
 struct enic_fdir_node {
 	struct rte_eth_fdir_filter filter;
 	u16 fltr_id;
@@ -126,9 +135,9 @@ struct enic {
 	struct vnic_cq *cq;
 	unsigned int cq_count; /* equals rq_count + wq_count */
 
-	/* interrupt resource */
-	struct vnic_intr intr;
-	unsigned int intr_count;
+	/* interrupt vectors (len = conf_intr_count) */
+	struct vnic_intr *intr;
+	unsigned int intr_count; /* equals enabled interrupts (lsc + rxqs) */
 
 	/* software counters */
 	struct enic_soft_stats soft_stats;
drivers/net/enic/enic_ethdev.c +22 -0
index 6dd72729e..2a289b6a4 100644
@@ -738,6 +738,26 @@ static void enicpmd_dev_txq_info_get(struct rte_eth_dev *dev,
 	/* tx_thresh, and all the other fields are not applicable for enic */
 }
 
+static int enicpmd_dev_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
+					    uint16_t rx_queue_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	vnic_intr_unmask(&enic->intr[rx_queue_id + ENICPMD_RXQ_INTR_OFFSET]);
+	return 0;
+}
+
+static int enicpmd_dev_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
+					     uint16_t rx_queue_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	vnic_intr_mask(&enic->intr[rx_queue_id + ENICPMD_RXQ_INTR_OFFSET]);
+	return 0;
+}
+
 static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_configure        = enicpmd_dev_configure,
 	.dev_start            = enicpmd_dev_start,
@@ -770,6 +790,8 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.rx_descriptor_done   = NULL,
 	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
 	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.rx_queue_intr_enable = enicpmd_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable = enicpmd_dev_rx_queue_intr_disable,
 	.rxq_info_get         = enicpmd_dev_rxq_info_get,
 	.txq_info_get         = enicpmd_dev_txq_info_get,
 	.dev_led_on           = NULL,
drivers/net/enic/enic_main.c +106 -17

236 lines not on this page · raw message

drivers/net/enic/enic_res.c +2 -1
index d8f7892c3..e7ad6767e 100644
@@ -222,7 +222,8 @@ void enic_free_vnic_resources(struct enic *enic)
 			vnic_rq_free(&enic->rq[i]);
 	for (i = 0; i < enic->cq_count; i++)
 		vnic_cq_free(&enic->cq[i]);
-	vnic_intr_free(&enic->intr);
+	for (i = 0; i < enic->intr_count; i++)
+		vnic_intr_free(&enic->intr[i]);
 }
 
 void enic_get_res_counts(struct enic *enic)
Signature · 1 line
2.12.0
author
#7 lore raw

PATCH 1/1 doc: describe Rx bytes counter behavior for enic

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 doc/guides/nics/enic.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
doc/guides/nics/enic.rst +8 -0
index 7e19cf88a..0bc55936a 100644
@@ -310,6 +310,14 @@ Limitations
     were added. Since there currently is no grouping or priority support,
     'catch-all' filters should be added last.
 
+- **Statistics**
+
+  - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
+  - When the NIC drops a packet because the Rx queue has no free buffers,
+    ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
+    VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
+    is enabled.
+
 How to build the suite
 ----------------------
 
Signature · 1 line
2.12.0
author
#8 lore raw

PATCH 1/1 net/enic: use memcpy to avoid strict aliasing warnings

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/enic_clsf.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/net/enic/enic_clsf.c +8 -13
index 3ef1d0832..9d95201ec 100644
@@ -111,7 +111,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 	     struct rte_eth_fdir_masks *masks)
 {
 	struct filter_generic_1 *gp = &fltr->u.generic_1;
-	int i;
 
 	fltr->type = FILTER_DPDK_1;
 	memset(gp, 0, sizeof(*gp));
@@ -273,18 +272,14 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 			ipv6_mask.proto = masks->ipv6_mask.proto;
 			ipv6_val.proto = input->flow.ipv6_flow.proto;
 		}
-		for (i = 0; i < 4; i++) {
-			*(uint32_t *)&ipv6_mask.src_addr[i * 4] =
-					masks->ipv6_mask.src_ip[i];
-			*(uint32_t *)&ipv6_val.src_addr[i * 4] =
-					input->flow.ipv6_flow.src_ip[i];
-		}
-		for (i = 0; i < 4; i++) {
-			*(uint32_t *)&ipv6_mask.dst_addr[i * 4] =
-					masks->ipv6_mask.src_ip[i];
-			*(uint32_t *)&ipv6_val.dst_addr[i * 4] =
-					input->flow.ipv6_flow.dst_ip[i];
-		}
+		memcpy(ipv6_mask.src_addr, masks->ipv6_mask.src_ip,
+		       sizeof(ipv6_mask.src_addr));
+		memcpy(ipv6_val.src_addr, input->flow.ipv6_flow.src_ip,
+		       sizeof(ipv6_val.src_addr));
+		memcpy(ipv6_mask.dst_addr, masks->ipv6_mask.dst_ip,
+		       sizeof(ipv6_mask.dst_addr));
+		memcpy(ipv6_val.dst_addr, input->flow.ipv6_flow.dst_ip,
+		       sizeof(ipv6_val.dst_addr));
 		if (input->flow.ipv6_flow.tc) {
 			ipv6_mask.vtc_flow = masks->ipv6_mask.tc << 12;
 			ipv6_val.vtc_flow = input->flow.ipv6_flow.tc << 12;
Signature · 1 line
2.12.0
author
#9 lore raw

PATCH 1/1 net/enic: support for meson

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---

Note: check-git-log.sh seems to fail when files in drivers/net are included even if they are commited independently with the "drivers/net:" prefix. Commiting both files at once. Please ignore check-git-log.sh failure or suggest a petter prefix.

 drivers/net/enic/meson.build | 19 +++++++++++++++++++
 drivers/net/meson.build      |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/enic/meson.build
drivers/net/enic/meson.build new file +19 -0
new file mode 100644
index 000000000..bfd4e2373
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cisco Systems, Inc.
+
+sources = files(
+	'base/vnic_cq.c',
+	'base/vnic_dev.c',
+	'base/vnic_intr.c',
+	'base/vnic_rq.c',
+	'base/vnic_rss.c',
+	'base/vnic_wq.c',
+	'enic_clsf.c',
+	'enic_ethdev.c',
+	'enic_flow.c',
+	'enic_main.c',
+	'enic_res.c',
+	'enic_rxtx.c',
+	)
+deps += ['hash']
+includes += include_directories('base')
drivers/net/meson.build +1 -1
index 704cbe3c8..f535baa13 100644
@@ -2,7 +2,7 @@
 # Copyright(c) 2017 Intel Corporation
 
 drivers = ['af_packet', 'bonding',
-	'e1000', 'fm10k', 'i40e', 'ixgbe',
+	'e1000', 'enic', 'fm10k', 'i40e', 'ixgbe',
 	'null', 'octeontx', 'pcap', 'ring',
 	'sfc', 'thunderx']
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
Signature · 1 line
2.12.0
author
#10 lore raw

v2 cover enic patchset

v2: rebase, submit as patchset instead of individual patches so they apply correctly.

Hyong Youb Kim (9):
net/enic: allow the user to change RSS settings net/enic: heed the requested max Rx packet size net/enic: remove the VLAN filter handler net/enic: add Rx/Tx queue configuration getters net/enic: allocate stats DMA buffer upfront during probe net/enic: support Rx queue interrupts
doc: describe Rx bytes counter behavior for enic net/enic: use memcpy to avoid strict aliasing warnings net/enic: support for meson

John Daley (1):
net/enic: remove 'extern' in .h file function declarations

 doc/guides/nics/enic.rst          |  16 +-
 doc/guides/nics/features/enic.ini |   3 +
 drivers/net/enic/base/vnic_dev.c  |  24 ++-
 drivers/net/enic/base/vnic_dev.h  |   1 +
 drivers/net/enic/enic.h           | 120 +++++++-----
 drivers/net/enic/enic_clsf.c      |  21 +--
 drivers/net/enic/enic_ethdev.c    | 258 ++++++++++++++++++++++----
 drivers/net/enic/enic_main.c      | 373 ++++++++++++++++++++++++++++++--------
 drivers/net/enic/enic_res.c       |  23 ++-
 drivers/net/enic/enic_res.h       |   6 +
 drivers/net/enic/meson.build      |  19 ++
 drivers/net/meson.build           |   2 +-
 12 files changed, 686 insertions(+), 180 deletions(-)
 create mode 100644 drivers/net/enic/meson.build
Signature · 1 line
2.16.2
author
#11 lore raw

PATCH v2 1/10 net/enic: remove 'extern' in .h file function declarations

---
 drivers/net/enic/enic.h | 80 ++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 40 deletions(-)
drivers/net/enic/enic.h +40 -40
index c083985ee..e88af6bc9 100644
@@ -220,54 +220,54 @@ enic_ring_incr(uint32_t n_descriptors, uint32_t idx)
 	return idx;
 }
 
-extern void enic_fdir_stats_get(struct enic *enic,
-	struct rte_eth_fdir_stats *stats);
-extern int enic_fdir_add_fltr(struct enic *enic,
-	struct rte_eth_fdir_filter *params);
-extern int enic_fdir_del_fltr(struct enic *enic,
-	struct rte_eth_fdir_filter *params);
-extern void enic_free_wq(void *txq);
-extern int enic_alloc_intr_resources(struct enic *enic);
-extern int enic_setup_finish(struct enic *enic);
-extern int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
-	unsigned int socket_id, uint16_t nb_desc);
-extern void enic_start_wq(struct enic *enic, uint16_t queue_idx);
-extern int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
-extern void enic_start_rq(struct enic *enic, uint16_t queue_idx);
-extern int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
-extern void enic_free_rq(void *rxq);
-extern int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
-	unsigned int socket_id, struct rte_mempool *mp,
-	uint16_t nb_desc, uint16_t free_thresh);
-extern int enic_set_rss_nic_cfg(struct enic *enic);
-extern int enic_set_vnic_res(struct enic *enic);
-extern int enic_enable(struct enic *enic);
-extern int enic_disable(struct enic *enic);
-extern void enic_remove(struct enic *enic);
-extern int enic_get_link_status(struct enic *enic);
-extern int enic_dev_stats_get(struct enic *enic,
-	struct rte_eth_stats *r_stats);
-extern void enic_dev_stats_clear(struct enic *enic);
-extern void enic_add_packet_filter(struct enic *enic);
+void enic_fdir_stats_get(struct enic *enic,
+			 struct rte_eth_fdir_stats *stats);
+int enic_fdir_add_fltr(struct enic *enic,
+		       struct rte_eth_fdir_filter *params);
+int enic_fdir_del_fltr(struct enic *enic,
+		       struct rte_eth_fdir_filter *params);
+void enic_free_wq(void *txq);
+int enic_alloc_intr_resources(struct enic *enic);
+int enic_setup_finish(struct enic *enic);
+int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
+		  unsigned int socket_id, uint16_t nb_desc);
+void enic_start_wq(struct enic *enic, uint16_t queue_idx);
+int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
+void enic_start_rq(struct enic *enic, uint16_t queue_idx);
+int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
+void enic_free_rq(void *rxq);
+int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
+		  unsigned int socket_id, struct rte_mempool *mp,
+		  uint16_t nb_desc, uint16_t free_thresh);
+int enic_set_rss_nic_cfg(struct enic *enic);
+int enic_set_vnic_res(struct enic *enic);
+int enic_enable(struct enic *enic);
+int enic_disable(struct enic *enic);
+void enic_remove(struct enic *enic);
+int enic_get_link_status(struct enic *enic);
+int enic_dev_stats_get(struct enic *enic,
+		       struct rte_eth_stats *r_stats);
+void enic_dev_stats_clear(struct enic *enic);
+void enic_add_packet_filter(struct enic *enic);
 int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr);
 void enic_del_mac_address(struct enic *enic, int mac_index);
-extern unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
-extern void enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
-			  struct rte_mbuf *tx_pkt, unsigned short len,
-			  uint8_t sop, uint8_t eop, uint8_t cq_entry,
-			  uint16_t ol_flags, uint16_t vlan_tag);
-
-extern void enic_post_wq_index(struct vnic_wq *wq);
-extern int enic_probe(struct enic *enic);
-extern int enic_clsf_init(struct enic *enic);
-extern void enic_clsf_destroy(struct enic *enic);
+unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
+void enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
+		   struct rte_mbuf *tx_pkt, unsigned short len,
+		   uint8_t sop, uint8_t eop, uint8_t cq_entry,
+		   uint16_t ol_flags, uint16_t vlan_tag);
+
+void enic_post_wq_index(struct vnic_wq *wq);
+int enic_probe(struct enic *enic);
+int enic_clsf_init(struct enic *enic);
+void enic_clsf_destroy(struct enic *enic);
 uint16_t enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			uint16_t nb_pkts);
 uint16_t enic_dummy_recv_pkts(void *rx_queue,
 			      struct rte_mbuf **rx_pkts,
 			      uint16_t nb_pkts);
 uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
-			       uint16_t nb_pkts);
+			uint16_t nb_pkts);
 uint16_t enic_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
 int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
Signature · 1 line
2.16.2
author
#12 lore raw

v3 cover enic PMD patchset

V2: rebase, submit as patchset instead of individual patches so they apply correctly.
V3: try again submitting patches one at a time so they are applied in order (tester seems to be applying patches in order received instead of looking at patch ID).

Hyong Youb Kim (9):
net/enic: allow the user to change RSS settings net/enic: heed the requested max Rx packet size net/enic: remove the VLAN filter handler net/enic: add Rx/Tx queue configuration getters net/enic: allocate stats DMA buffer upfront during probe net/enic: support Rx queue interrupts
doc: describe Rx bytes counter behavior for enic net/enic: use memcpy to avoid strict aliasing warnings net/enic: support for meson

John Daley (1):
net/enic: remove 'extern' in .h file function declarations

 doc/guides/nics/enic.rst          |  16 +-
 doc/guides/nics/features/enic.ini |   3 +
 drivers/net/enic/base/vnic_dev.c  |  24 ++-
 drivers/net/enic/base/vnic_dev.h  |   1 +
 drivers/net/enic/enic.h           | 120 +++++++-----
 drivers/net/enic/enic_clsf.c      |  21 +--
 drivers/net/enic/enic_ethdev.c    | 258 ++++++++++++++++++++++----
 drivers/net/enic/enic_main.c      | 373 ++++++++++++++++++++++++++++++--------
 drivers/net/enic/enic_res.c       |  23 ++-
 drivers/net/enic/enic_res.h       |   6 +
 drivers/net/enic/meson.build      |  19 ++
 drivers/net/meson.build           |   2 +-
 12 files changed, 686 insertions(+), 180 deletions(-)
 create mode 100644 drivers/net/enic/meson.build
Signature · 1 line
2.16.2
author
#13 lore raw

PATCH v3 1/10 net/enic: remove 'extern' in .h file function declarations

---
 drivers/net/enic/enic.h | 80 ++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 40 deletions(-)
drivers/net/enic/enic.h +40 -40
index c083985ee..e88af6bc9 100644
@@ -220,54 +220,54 @@ enic_ring_incr(uint32_t n_descriptors, uint32_t idx)
 	return idx;
 }
 
-extern void enic_fdir_stats_get(struct enic *enic,
-	struct rte_eth_fdir_stats *stats);
-extern int enic_fdir_add_fltr(struct enic *enic,
-	struct rte_eth_fdir_filter *params);
-extern int enic_fdir_del_fltr(struct enic *enic,
-	struct rte_eth_fdir_filter *params);
-extern void enic_free_wq(void *txq);
-extern int enic_alloc_intr_resources(struct enic *enic);
-extern int enic_setup_finish(struct enic *enic);
-extern int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
-	unsigned int socket_id, uint16_t nb_desc);
-extern void enic_start_wq(struct enic *enic, uint16_t queue_idx);
-extern int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
-extern void enic_start_rq(struct enic *enic, uint16_t queue_idx);
-extern int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
-extern void enic_free_rq(void *rxq);
-extern int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
-	unsigned int socket_id, struct rte_mempool *mp,
-	uint16_t nb_desc, uint16_t free_thresh);
-extern int enic_set_rss_nic_cfg(struct enic *enic);
-extern int enic_set_vnic_res(struct enic *enic);
-extern int enic_enable(struct enic *enic);
-extern int enic_disable(struct enic *enic);
-extern void enic_remove(struct enic *enic);
-extern int enic_get_link_status(struct enic *enic);
-extern int enic_dev_stats_get(struct enic *enic,
-	struct rte_eth_stats *r_stats);
-extern void enic_dev_stats_clear(struct enic *enic);
-extern void enic_add_packet_filter(struct enic *enic);
+void enic_fdir_stats_get(struct enic *enic,
+			 struct rte_eth_fdir_stats *stats);
+int enic_fdir_add_fltr(struct enic *enic,
+		       struct rte_eth_fdir_filter *params);
+int enic_fdir_del_fltr(struct enic *enic,
+		       struct rte_eth_fdir_filter *params);
+void enic_free_wq(void *txq);
+int enic_alloc_intr_resources(struct enic *enic);
+int enic_setup_finish(struct enic *enic);
+int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
+		  unsigned int socket_id, uint16_t nb_desc);
+void enic_start_wq(struct enic *enic, uint16_t queue_idx);
+int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
+void enic_start_rq(struct enic *enic, uint16_t queue_idx);
+int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
+void enic_free_rq(void *rxq);
+int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
+		  unsigned int socket_id, struct rte_mempool *mp,
+		  uint16_t nb_desc, uint16_t free_thresh);
+int enic_set_rss_nic_cfg(struct enic *enic);
+int enic_set_vnic_res(struct enic *enic);
+int enic_enable(struct enic *enic);
+int enic_disable(struct enic *enic);
+void enic_remove(struct enic *enic);
+int enic_get_link_status(struct enic *enic);
+int enic_dev_stats_get(struct enic *enic,
+		       struct rte_eth_stats *r_stats);
+void enic_dev_stats_clear(struct enic *enic);
+void enic_add_packet_filter(struct enic *enic);
 int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr);
 void enic_del_mac_address(struct enic *enic, int mac_index);
-extern unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
-extern void enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
-			  struct rte_mbuf *tx_pkt, unsigned short len,
-			  uint8_t sop, uint8_t eop, uint8_t cq_entry,
-			  uint16_t ol_flags, uint16_t vlan_tag);
-
-extern void enic_post_wq_index(struct vnic_wq *wq);
-extern int enic_probe(struct enic *enic);
-extern int enic_clsf_init(struct enic *enic);
-extern void enic_clsf_destroy(struct enic *enic);
+unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq);
+void enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
+		   struct rte_mbuf *tx_pkt, unsigned short len,
+		   uint8_t sop, uint8_t eop, uint8_t cq_entry,
+		   uint16_t ol_flags, uint16_t vlan_tag);
+
+void enic_post_wq_index(struct vnic_wq *wq);
+int enic_probe(struct enic *enic);
+int enic_clsf_init(struct enic *enic);
+void enic_clsf_destroy(struct enic *enic);
 uint16_t enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			uint16_t nb_pkts);
 uint16_t enic_dummy_recv_pkts(void *rx_queue,
 			      struct rte_mbuf **rx_pkts,
 			      uint16_t nb_pkts);
 uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
-			       uint16_t nb_pkts);
+			uint16_t nb_pkts);
 uint16_t enic_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
 int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
Signature · 1 line
2.16.2
author
#14 lore raw

PATCH v3 2/10 net/enic: allow the user to change RSS settings

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Currently, when more than 1 receive queues are configured, the driver always enables RSS with the driver's own default hash type, key, and RETA. The user is unable to change any of the RSS settings. Address this by implementing the ethdev RSS API as follows.

Correctly report the RETA size, key size, and supported hash types through rte_eth_dev_info.

During dev_configure(), initialize RSS according to the device's mq_mode and rss_conf. Start with the default RETA, and use the default key unless a custom key is provided.

Add the RETA and rss_conf query/set handlers to let the user change RSS settings after the initial configuration. The hardware is able to change hash type, key, and RETA individually. So, the handlers change only the affected settings.

Refactor/rename several functions in order to make their intentions clear. For example, remove all traces of RSS from enicpmd_vlan_offload_set() as it is confusing.

---
 doc/guides/nics/features/enic.ini |   2 +
 drivers/net/enic/enic.h           |  20 +++-
 drivers/net/enic/enic_ethdev.c    | 117 ++++++++++++++++++++++-
 drivers/net/enic/enic_main.c      | 192 ++++++++++++++++++++++++++++----------
 drivers/net/enic/enic_res.c       |  20 ++++
 drivers/net/enic/enic_res.h       |   6 ++
 6 files changed, 301 insertions(+), 56 deletions(-)
doc/guides/nics/features/enic.ini +2 -0
index 498341f07..e79d7277d 100644
@@ -15,6 +15,8 @@ Promiscuous mode     = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
 RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
 SR-IOV               = Y
 VLAN filter          = Y
 CRC offload          = Y
drivers/net/enic/enic.h +19 -1
index e88af6bc9..d29939c94 100644
@@ -146,6 +146,20 @@ struct enic {
 
 	LIST_HEAD(enic_flows, rte_flow) flows;
 	rte_spinlock_t flows_lock;
+
+	/* RSS */
+	uint16_t reta_size;
+	uint8_t hash_key_size;
+	uint64_t flow_type_rss_offloads; /* 0 indicates RSS not supported */
+	/*
+	 * Keep a copy of current RSS config for queries, as we cannot retrieve
+	 * it from the NIC.
+	 */
+	uint8_t rss_hash_type; /* NIC_CFG_RSS_HASH_TYPE flags */
+	uint8_t rss_enable;
+	uint64_t rss_hf; /* ETH_RSS flags */
+	union vnic_rss_key rss_key;
+	union vnic_rss_cpu rss_cpu;
 };
 
 /* Get the CQ index from a Start of Packet(SOP) RQ index */
@@ -239,8 +253,12 @@ void enic_free_rq(void *rxq);
 int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
 		  unsigned int socket_id, struct rte_mempool *mp,
 		  uint16_t nb_desc, uint16_t free_thresh);
-int enic_set_rss_nic_cfg(struct enic *enic);
 int enic_set_vnic_res(struct enic *enic);
+int enic_init_rss_nic_cfg(struct enic *enic);
+int enic_set_rss_conf(struct enic *enic,
+		      struct rte_eth_rss_conf *rss_conf);
+int enic_set_rss_reta(struct enic *enic, union vnic_rss_cpu *rss_cpu);
+int enic_set_vlan_strip(struct enic *enic);
 int enic_enable(struct enic *enic);
 int enic_disable(struct enic *enic);
 void enic_remove(struct enic *enic);
drivers/net/enic/enic_ethdev.c +112 -5

153 lines not on this page · raw message

drivers/net/enic/enic_main.c +142 -50

262 lines not on this page · raw message

drivers/net/enic/enic_res.c +20 -0
index c99d61837..d8f7892c3 100644
@@ -128,6 +128,26 @@ int enic_get_vnic_config(struct enic *enic)
 		c->intr_timer_usec,
 		c->loop_tag);
 
+	/* RSS settings from vNIC */
+	enic->reta_size = ENIC_RSS_RETA_SIZE;
+	enic->hash_key_size = ENIC_RSS_HASH_KEY_SIZE;
+	enic->flow_type_rss_offloads = 0;
+	if (ENIC_SETTING(enic, RSSHASH_IPV4))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV4;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV4))
+		enic->flow_type_rss_offloads |= ETH_RSS_NONFRAG_IPV4_TCP;
+	if (ENIC_SETTING(enic, RSSHASH_IPV6))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV6))
+		enic->flow_type_rss_offloads |= ETH_RSS_NONFRAG_IPV6_TCP;
+	if (ENIC_SETTING(enic, RSSHASH_IPV6_EX))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6_EX;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV6_EX))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6_TCP_EX;
+	/* Zero offloads if RSS is not enabled */
+	if (!ENIC_SETTING(enic, RSS))
+		enic->flow_type_rss_offloads = 0;
+
 	return 0;
 }
 
drivers/net/enic/enic_res.h +6 -0
index cf3a6fde8..e68f1307b 100644
@@ -31,6 +31,12 @@
 #define ENIC_DEFAULT_RX_FREE_THRESH	32
 #define ENIC_TX_XMIT_MAX		64
 
+#define ENIC_RSS_DEFAULT_CPU    0
+#define ENIC_RSS_BASE_CPU       0
+#define ENIC_RSS_HASH_BITS      7
+#define ENIC_RSS_RETA_SIZE      (1 << ENIC_RSS_HASH_BITS)
+#define ENIC_RSS_HASH_KEY_SIZE  40
+
 #define ENIC_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0)
 
 
Signature · 1 line
2.16.2
#15 lore raw

Re: [PATCH v3 02/10] net/enic: allow the user to change RSS settings

Quoted 25 lines · John Daley

From: Hyong Youb Kim <[email protected]>

Currently, when more than 1 receive queues are configured, the driver always enables RSS with the driver's own default hash type, key, and RETA. The user is unable to change any of the RSS settings. Address this by implementing the ethdev RSS API as follows.

Correctly report the RETA size, key size, and supported hash types through rte_eth_dev_info.

During dev_configure(), initialize RSS according to the device's mq_mode and rss_conf. Start with the default RETA, and use the default key unless a custom key is provided.

Add the RETA and rss_conf query/set handlers to let the user change RSS settings after the initial configuration. The hardware is able to change hash type, key, and RETA individually. So, the handlers change only the affected settings.

Refactor/rename several functions in order to make their intentions clear. For example, remove all traces of RSS from enicpmd_vlan_offload_set() as it is confusing.

<...>

Quoted 12 lines
drivers/net/enic/enic_main.c +1 -4
@@ -889,44 +889,42 @@ static int enic_dev_open(struct enic *enic)
 	return err;
 }
 
-static int enic_set_rsskey(struct enic *enic)
+static int enic_set_rsskey(struct enic *enic, uint8_t *user_key)
 {
 	dma_addr_t rss_key_buf_pa;
 	union vnic_rss_key *rss_key_buf_va = NULL;
-	static union vnic_rss_key rss_key = {
-		.key = {
-			[0] = {.b = {85, 67, 83, 97, 119, 101, 115, 111, 109, 101}},

drivers/net/enic/enic_main.c static int enic_dev_open(struct enic *enic) · line 899

Quoted 10 lines
drivers/net/enic/enic_main.c +2 -6
-			[1] = {.b = {80, 65, 76, 79, 117, 110, 105, 113, 117, 101}},
-			[2] = {.b = {76, 73, 78, 85, 88, 114, 111, 99, 107, 115}},
-			[3] = {.b = {69, 78, 73, 67, 105, 115, 99, 111, 111, 108}},
-		}
-	};
-	int err;
+	int err, i;
 	u8 name[NAME_MAX];
 
+	RTE_ASSERT(use_key != NULL);

there is a typo, "use_key" should be "user_key" which is causing a build error. If RTE_ASSERT used in the code, should test enabling CONFIG_RTE_ENABLE_ASSERT option too.

author
#16 lore raw

PATCH v3 3/10 net/enic: heed the requested max Rx packet size

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Currently, enic completely ignores the requested max Rx packet size (rxmode.max_rx_pkt_len). The desired behavior is that the NIC hardware drops packets larger than the requested size, even though they are still smaller than MTU.

Cisco VIC does not have such a feature. But, we can accomplish a similar (not same) effect by reducing the size of posted receive buffers. Packets larger than the posted size get truncated, and the receive handler drops them. This is also how the kernel enic driver enforces the Rx side MTU.

This workaround works only when scatter mode is *not* used. When scatter is used, there is currently no way to support rxmode.max_rx_pkt_len, as the NIC always receives packets up to MTU.

For posterity, add a copious amount of comments regarding the hardware's drop/receive behavior with respect to max/current MTU.

---
 doc/guides/nics/enic.rst       |  1 +
 drivers/net/enic/enic.h        |  7 ++++++
 drivers/net/enic/enic_ethdev.c |  9 +++++++-
 drivers/net/enic/enic_main.c   | 49 ++++++++++++++++++++++++++++++++++++------
 4 files changed, 58 insertions(+), 8 deletions(-)
doc/guides/nics/enic.rst +1 -0
index 4dffce1a6..0e655e9e3 100644
@@ -371,6 +371,7 @@ Known bugs and unsupported features in this release
 - Setting of extended VLAN
 - UDP RSS hashing
 - MTU update only works if Scattered Rx mode is disabled
+- Maximum receive packet length is ignored if Scattered Rx mode is used
 
 Prerequisites
 -------------
drivers/net/enic/enic.h +7 -0
index d29939c94..1b3813a58 100644
@@ -162,6 +162,13 @@ struct enic {
 	union vnic_rss_cpu rss_cpu;
 };
 
+/* Compute ethdev's max packet size from MTU */
+static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu)
+{
+	/* ethdev max size includes eth and crc whereas NIC MTU does not */
+	return mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+}
+
 /* Get the CQ index from a Start of Packet(SOP) RQ index */
 static inline unsigned int enic_sop_rq_idx_to_cq_idx(unsigned int sop_idx)
 {
drivers/net/enic/enic_ethdev.c +8 -1
index cbab7029b..bdbaf4cdf 100644
@@ -470,7 +470,14 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	device_info->max_rx_queues = enic->conf_rq_count / 2;
 	device_info->max_tx_queues = enic->conf_wq_count;
 	device_info->min_rx_bufsize = ENIC_MIN_MTU;
-	device_info->max_rx_pktlen = enic->max_mtu + ETHER_HDR_LEN + 4;
+	/* "Max" mtu is not a typo. HW receives packet sizes up to the
+	 * max mtu regardless of the current mtu (vNIC's mtu). vNIC mtu is
+	 * a hint to the driver to size receive buffers accordingly so that
+	 * larger-than-vnic-mtu packets get truncated.. For DPDK, we let
+	 * the user decide the buffer size via rxmode.max_rx_pkt_len, basically
+	 * ignoring vNIC mtu.
+	 */
+	device_info->max_rx_pktlen = enic_mtu_to_max_rx_pktlen(enic->max_mtu);
 	device_info->max_mac_addrs = ENIC_MAX_MAC_ADDR;
 	device_info->rx_offload_capa =
 		DEV_RX_OFFLOAD_VLAN_STRIP |
drivers/net/enic/enic_main.c +42 -7

98 lines not on this page · raw message

Signature · 1 line
2.16.2
#17 lore raw

Re: [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Quoted 6 lines · John Daley

From: Hyong Youb Kim <[email protected]>

Currently, enic completely ignores the requested max Rx packet size (rxmode.max_rx_pkt_len). The desired behavior is that the NIC hardware drops packets larger than the requested size, even though they are still smaller than MTU.

Your description looks reasonable but is there reason of two levels of limits, max_rx_pkt_len and MTU, why not just use MTU. There is already a mail thread to clarify max_rx_pkt_len [1].

Is this work based on an application that uses max_rx_pkt_len and to make PMD compatible with that application? If so we can continue with patch, but if the patch is to implement DPDK properly I suggest postponing this until max_rx_pkt_len clarified.

[1]
https://dpdk.org/ml/archives/dev/2018-March/092178.html

Quoted 16 lines

Cisco VIC does not have such a feature. But, we can accomplish a similar (not same) effect by reducing the size of posted receive buffers. Packets larger than the posted size get truncated, and the receive handler drops them. This is also how the kernel enic driver enforces the Rx side MTU.

This workaround works only when scatter mode is *not* used. When scatter is used, there is currently no way to support rxmode.max_rx_pkt_len, as the NIC always receives packets up to MTU.

For posterity, add a copious amount of comments regarding the hardware's drop/receive behavior with respect to max/current MTU.

<...>

#18 lore raw

Re: [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Hi everyone,

Quoted 19 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Friday, March 9, 2018 3:04 PM
To: John Daley <[email protected]>
Cc: [email protected]; Hyong Youb Kim <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Quoted 6 lines · John Daley

From: Hyong Youb Kim <[email protected]>

Currently, enic completely ignores the requested max Rx packet size (rxmode.max_rx_pkt_len). The desired behavior is that the NIC hardware drops packets larger than the requested size, even though they are still smaller than MTU.

Your description looks reasonable but is there reason of two levels of limits, max_rx_pkt_len and MTU, why not just use MTU. There is already a mail thread to clarify max_rx_pkt_len [1].

Quoted 7 lines

Is this work based on an application that uses max_rx_pkt_len and to make PMD compatible with that application? If so we can continue with patch, but if the patch is to implement DPDK properly I suggest postponing this until max_rx_pkt_len clarified.

[1]
https://dpdk.org/ml/archives/dev/2018-March/092178.html

I think there are quite a lot apps these days that might rely on setting MTU via rxmode.max_rx_pkt_len.
I think we need to support them till we (ever) deprecate rxmode.max_rx_pkt_len. Konstantin

Quoted 19 lines
Quoted 17 lines

Cisco VIC does not have such a feature. But, we can accomplish a similar (not same) effect by reducing the size of posted receive buffers. Packets larger than the posted size get truncated, and the receive handler drops them. This is also how the kernel enic driver enforces the Rx side MTU.

This workaround works only when scatter mode is *not* used. When scatter is used, there is currently no way to support rxmode.max_rx_pkt_len, as the NIC always receives packets up to MTU.

For posterity, add a copious amount of comments regarding the hardware's drop/receive behavior with respect to max/current MTU.

<...>

#19 lore raw

Re: [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Quoted 27 lines · Konstantin

Hi everyone,

Quoted 24 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Friday, March 9, 2018 3:04 PM
To: John Daley <[email protected]>
Cc: [email protected]; Hyong Youb Kim <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Quoted 6 lines · John Daley

From: Hyong Youb Kim <[email protected]>

Currently, enic completely ignores the requested max Rx packet size (rxmode.max_rx_pkt_len). The desired behavior is that the NIC hardware drops packets larger than the requested size, even though they are still smaller than MTU.

Your description looks reasonable but is there reason of two levels of limits, max_rx_pkt_len and MTU, why not just use MTU. There is already a mail thread to clarify max_rx_pkt_len [1].

Is this work based on an application that uses max_rx_pkt_len and to make PMD compatible with that application? If so we can continue with patch, but if the patch is to implement DPDK properly I suggest postponing this until max_rx_pkt_len clarified.

Quoted 6 lines
Quoted 2 lines

[1]
https://dpdk.org/ml/archives/dev/2018-March/092178.html

I think there are quite a lot apps these days that might rely on setting MTU via rxmode.max_rx_pkt_len.
I think we need to support them till we (ever) deprecate rxmode.max_rx_pkt_len.

Right. I was trying to save effort in case something changes related max_rx_pkt_len, but since it is not clear yet, will continue with this patch.

Quoted 22 lines

Konstantin

Quoted 19 lines
Quoted 17 lines

Cisco VIC does not have such a feature. But, we can accomplish a similar (not same) effect by reducing the size of posted receive buffers. Packets larger than the posted size get truncated, and the receive handler drops them. This is also how the kernel enic driver enforces the Rx side MTU.

This workaround works only when scatter mode is *not* used. When scatter is used, there is currently no way to support rxmode.max_rx_pkt_len, as the NIC always receives packets up to MTU.

For posterity, add a copious amount of comments regarding the hardware's drop/receive behavior with respect to max/current MTU.

<...>

#20 lore raw

Re: [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Quoted 1 line · Ferruh Yigit

On 3/9/2018 3:51 PM, Ananyev, Konstantin wrote:

[...]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Is this work based on an application that uses max_rx_pkt_len and to make PMD compatible with that application? If so we can continue with patch, but if the patch is to implement DPDK properly I suggest postponing this until max_rx_pkt_len clarified.

[1]
https://dpdk.org/ml/archives/dev/2018-March/092178.html

Quoted 9 lines
Quoted 3 lines

I think there are quite a lot apps these days that might rely on setting MTU via rxmode.max_rx_pkt_len.
I think we need to support them till we (ever) deprecate rxmode.max_rx_pkt_len.

Right. I was trying to save effort in case something changes related max_rx_pkt_len, but since it is not clear yet, will continue with this patch.

Quoted 2 lines

Konstantin

testpmd has a command to change max_rx_pkt_len, a few DTS test cases rely on this feature to see if packets of certain sizes get dropped, and so on. We worked on this patch to support these cases.

I prefer using only MTU, to follow the convention of most (all?) OSes. Though, this feature (max_rx_pkt_len) seems to come straight from an Intel 82599 feature. In its datasheet, see "8.2.3.22.13 Max Frame Size -- MAXFRS". Like to understand use cases for that, if anyone can share.

-Hyong

#21 lore raw

Re: [PATCH v3 03/10] net/enic: heed the requested max Rx packet size

Quoted 25 lines · Hyong Youb Kim
Quoted 1 line · Ferruh Yigit

On 3/9/2018 3:51 PM, Ananyev, Konstantin wrote:

[...]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Is this work based on an application that uses max_rx_pkt_len and to make PMD compatible with that application? If so we can continue with patch, but if the patch is to implement DPDK properly I suggest postponing this until max_rx_pkt_len clarified.

[1]
https://dpdk.org/ml/archives/dev/2018-March/092178.html

Quoted 9 lines
Quoted 3 lines

I think there are quite a lot apps these days that might rely on setting MTU via rxmode.max_rx_pkt_len.
I think we need to support them till we (ever) deprecate rxmode.max_rx_pkt_len.

Right. I was trying to save effort in case something changes related max_rx_pkt_len, but since it is not clear yet, will continue with this patch.

Quoted 2 lines

Konstantin

testpmd has a command to change max_rx_pkt_len, a few DTS test cases rely on this feature to see if packets of certain sizes get dropped, and so on. We worked on this patch to support these cases.

Quoted 5 lines

I prefer using only MTU, to follow the convention of most (all?) OSes. Though, this feature (max_rx_pkt_len) seems to come straight from an Intel 82599 feature. In its datasheet, see "8.2.3.22.13 Max Frame Size -- MAXFRS". Like to understand use cases for that, if anyone can share.

ixgbe driver updates MAXFRS register in ixgbe_dev_mtu_set(), so mtu seems can replace max_rx_pkt_len.

MAXFRS is for rx only, from datasheet description of it:
"This value has no effect on transmit frames; it is the responsibility of software to limit the size of transmit frames"

This may be the reason a new variable has been created for rx_frames, to differentiate it from mtu. Not sure if max rx and tx size can be different values for ixgbe.

Quoted 3 lines

-Hyong

author
#22 lore raw

PATCH v3 4/10 net/enic: remove the VLAN filter handler

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

VIC does not support VLAN filtering at the moment. The firmware does accept the filter add/del commands and returns success. But, they are no-ops. To avoid confusion, remove the filter set handler so the app sees an error instead of silent failure.

Also during the device configure time, enicpmd_vlan_offload_set would not print a warning message about unsupported VLAN filtering, because the caller specifies only ETH_VLAN_STRIP_MASK. This is wrong, as we should attempt to apply all requested offloads at the configure time. So, pass all VLAN offload masks, which triggers a warning message about VLAN filtering, if requested.

Finally, enicpmd_vlan_offload_set should check both mask and rxmode.offloads, not just mask.

---
 drivers/net/enic/enic_ethdev.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/net/enic/enic_ethdev.c +14 -20
index bdbaf4cdf..e5523e311 100644
@@ -318,40 +318,29 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	return enicpmd_dev_setup_intr(enic);
 }
 
-static int enicpmd_vlan_filter_set(struct rte_eth_dev *eth_dev,
-	uint16_t vlan_id, int on)
-{
-	struct enic *enic = pmd_priv(eth_dev);
-	int err;
-
-	ENICPMD_FUNC_TRACE();
-	if (on)
-		err = enic_add_vlan(enic, vlan_id);
-	else
-		err = enic_del_vlan(enic, vlan_id);
-	return err;
-}
-
 static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 {
 	struct enic *enic = pmd_priv(eth_dev);
+	uint64_t offloads;
 
 	ENICPMD_FUNC_TRACE();
 
+	offloads = eth_dev->data->dev_conf.rxmode.offloads;
 	if (mask & ETH_VLAN_STRIP_MASK) {
-		if (eth_dev->data->dev_conf.rxmode.offloads &
-		    DEV_RX_OFFLOAD_VLAN_STRIP)
+		if (offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
 			enic->ig_vlan_strip_en = 1;
 		else
 			enic->ig_vlan_strip_en = 0;
 	}
 
-	if (mask & ETH_VLAN_FILTER_MASK) {
+	if ((mask & ETH_VLAN_FILTER_MASK) &&
+	    (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) {
 		dev_warning(enic,
 			"Configuration of VLAN filter is not supported\n");
 	}
 
-	if (mask & ETH_VLAN_EXTEND_MASK) {
+	if ((mask & ETH_VLAN_EXTEND_MASK) &&
+	    (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) {
 		dev_warning(enic,
 			"Configuration of extended VLAN is not supported\n");
 	}
@@ -362,6 +351,7 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
 {
 	int ret;
+	int mask;
 	struct enic *enic = pmd_priv(eth_dev);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -376,7 +366,11 @@ static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
 
 	enic->hw_ip_checksum = !!(eth_dev->data->dev_conf.rxmode.offloads &
 				  DEV_RX_OFFLOAD_CHECKSUM);
-	ret = enicpmd_vlan_offload_set(eth_dev, ETH_VLAN_STRIP_MASK);
+	/* All vlan offload masks to apply the current settings */
+	mask = ETH_VLAN_STRIP_MASK |
+		ETH_VLAN_FILTER_MASK |
+		ETH_VLAN_EXTEND_MASK;
+	ret = enicpmd_vlan_offload_set(eth_dev, mask);
 	if (ret) {
 		dev_err(enic, "Failed to configure VLAN offloads\n");
 		return ret;
@@ -710,7 +704,7 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_infos_get        = enicpmd_dev_info_get,
 	.dev_supported_ptypes_get = enicpmd_dev_supported_ptypes_get,
 	.mtu_set              = enicpmd_mtu_set,
-	.vlan_filter_set      = enicpmd_vlan_filter_set,
+	.vlan_filter_set      = NULL,
 	.vlan_tpid_set        = NULL,
 	.vlan_offload_set     = enicpmd_vlan_offload_set,
 	.vlan_strip_queue_set = NULL,
Signature · 1 line
2.16.2
author
#23 lore raw

PATCH v3 5/10 net/enic: add Rx/Tx queue configuration getters

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/enic_ethdev.c | 76 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 65 insertions(+), 11 deletions(-)
drivers/net/enic/enic_ethdev.c +65 -11
index e5523e311..6dd72729e 100644
@@ -39,6 +39,19 @@ static const struct rte_pci_id pci_id_enic_map[] = {
 	{.vendor_id = 0, /* sentinel */},
 };
 
+#define ENIC_TX_OFFLOAD_CAPA (			\
+		DEV_TX_OFFLOAD_VLAN_INSERT |	\
+		DEV_TX_OFFLOAD_IPV4_CKSUM  |	\
+		DEV_TX_OFFLOAD_UDP_CKSUM   |	\
+		DEV_TX_OFFLOAD_TCP_CKSUM   |	\
+		DEV_TX_OFFLOAD_TCP_TSO)
+
+#define ENIC_RX_OFFLOAD_CAPA (			\
+		DEV_RX_OFFLOAD_VLAN_STRIP |	\
+		DEV_RX_OFFLOAD_IPV4_CKSUM |	\
+		DEV_RX_OFFLOAD_UDP_CKSUM  |	\
+		DEV_RX_OFFLOAD_TCP_CKSUM)
+
 RTE_INIT(enicpmd_init_log);
 static void
 enicpmd_init_log(void)
@@ -473,17 +486,8 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	 */
 	device_info->max_rx_pktlen = enic_mtu_to_max_rx_pktlen(enic->max_mtu);
 	device_info->max_mac_addrs = ENIC_MAX_MAC_ADDR;
-	device_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_VLAN_STRIP |
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM  |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-	device_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_VLAN_INSERT |
-		DEV_TX_OFFLOAD_IPV4_CKSUM  |
-		DEV_TX_OFFLOAD_UDP_CKSUM   |
-		DEV_TX_OFFLOAD_TCP_CKSUM   |
-		DEV_TX_OFFLOAD_TCP_TSO;
+	device_info->rx_offload_capa = ENIC_RX_OFFLOAD_CAPA;
+	device_info->tx_offload_capa = ENIC_TX_OFFLOAD_CAPA;
 	device_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = ENIC_DEFAULT_RX_FREE_THRESH
 	};
@@ -686,6 +690,54 @@ static int enicpmd_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void enicpmd_dev_rxq_info_get(struct rte_eth_dev *dev,
+				     uint16_t rx_queue_id,
+				     struct rte_eth_rxq_info *qinfo)
+{
+	struct enic *enic = pmd_priv(dev);
+	struct vnic_rq *rq_sop;
+	struct vnic_rq *rq_data;
+	struct rte_eth_rxconf *conf;
+	uint16_t sop_queue_idx;
+	uint16_t data_queue_idx;
+
+	ENICPMD_FUNC_TRACE();
+	sop_queue_idx = enic_rte_rq_idx_to_sop_idx(rx_queue_id);
+	data_queue_idx = enic_rte_rq_idx_to_data_idx(rx_queue_id);
+	rq_sop = &enic->rq[sop_queue_idx];
+	rq_data = &enic->rq[data_queue_idx]; /* valid if data_queue_enable */
+	qinfo->mp = rq_sop->mp;
+	qinfo->scattered_rx = rq_sop->data_queue_enable;
+	qinfo->nb_desc = rq_sop->ring.desc_count;
+	if (qinfo->scattered_rx)
+		qinfo->nb_desc += rq_data->ring.desc_count;
+	conf = &qinfo->conf;
+	memset(conf, 0, sizeof(*conf));
+	conf->rx_free_thresh = rq_sop->rx_free_thresh;
+	conf->rx_drop_en = 1;
+	/*
+	 * Except VLAN stripping (port setting), all the checksum offloads
+	 * are always enabled.
+	 */
+	conf->offloads = ENIC_RX_OFFLOAD_CAPA;
+	if (!enic->ig_vlan_strip_en)
+		conf->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
+	/* rx_thresh and other fields are not applicable for enic */
+}
+
+static void enicpmd_dev_txq_info_get(struct rte_eth_dev *dev,
+				     __rte_unused uint16_t tx_queue_id,
+				     struct rte_eth_txq_info *qinfo)
+{
+	struct enic *enic = pmd_priv(dev);
+
+	ENICPMD_FUNC_TRACE();
+	qinfo->nb_desc = enic->config.wq_desc_count;
+	memset(&qinfo->conf, 0, sizeof(qinfo->conf));
+	qinfo->conf.offloads = ENIC_TX_OFFLOAD_CAPA; /* not configurable */
+	/* tx_thresh, and all the other fields are not applicable for enic */
+}
+
 static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_configure        = enicpmd_dev_configure,
 	.dev_start            = enicpmd_dev_start,
@@ -718,6 +770,8 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.rx_descriptor_done   = NULL,
 	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
 	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.rxq_info_get         = enicpmd_dev_rxq_info_get,
+	.txq_info_get         = enicpmd_dev_txq_info_get,
 	.dev_led_on           = NULL,
 	.dev_led_off          = NULL,
 	.flow_ctrl_get        = NULL,
Signature · 1 line
2.16.2
author
#24 lore raw

PATCH v3 6/10 net/enic: allocate stats DMA buffer upfront during probe

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

The driver provides a DMA buffer to the firmware when it requests port stats. The NIC then fills that buffer with latest stats. Currently, the driver allocates the DMA buffer the first time it requests stats and saves it for later use. This can lead to crashes when primary/secondary processes are involved. For example, the following sequence crashes the secondary process.

1. Start a primary app that does not call rte_eth_stats_get()
2. dpdk-procinfo -- --stats

dpdk-procinfo crashes while trying to allocate the stats DMA buffer because the alloc function pointer (vdev.alloc_consistent) is valid only in the primary process, not in the secondary process.

Overwriting the alloc function pointer in the secondary process is not an option, as it will simply make the pointer invalid in the primary process. Instead, allocate the DMA buffer during probe so that only the primary process does both allocate and free. This allows the secondary process to dump stats as well.

Fixes 9913fbb91df0 ("enic/base: common code")
---
 drivers/net/enic/base/vnic_dev.c | 24 ++++++++++++++----------
 drivers/net/enic/base/vnic_dev.h |  1 +
 drivers/net/enic/enic_main.c     |  9 +++++++++
 3 files changed, 24 insertions(+), 10 deletions(-)
drivers/net/enic/base/vnic_dev.c +14 -10
index 05b595eb8..1f8d222fc 100644
@@ -587,17 +587,9 @@ int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats)
 {
 	u64 a0, a1;
 	int wait = 1000;
-	static u32 instance;
-	char name[NAME_MAX];
 
-	if (!vdev->stats) {
-		snprintf((char *)name, sizeof(name),
-			"vnic_stats-%u", instance++);
-		vdev->stats = vdev->alloc_consistent(vdev->priv,
-			sizeof(struct vnic_stats), &vdev->stats_pa, (u8 *)name);
-		if (!vdev->stats)
-			return -ENOMEM;
-	}
+	if (!vdev->stats)
+		return -ENOMEM;
 
 	*stats = vdev->stats;
 	a0 = vdev->stats_pa;
@@ -922,6 +914,18 @@ u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev)
 	return vdev->intr_coal_timer_info.max_usec;
 }
 
+int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev)
+{
+	char name[NAME_MAX];
+	static u32 instance;
+
+	snprintf((char *)name, sizeof(name), "vnic_stats-%u", instance++);
+	vdev->stats = vdev->alloc_consistent(vdev->priv,
+					     sizeof(struct vnic_stats),
+					     &vdev->stats_pa, (u8 *)name);
+	return vdev->stats == NULL ? -ENOMEM : 0;
+}
+
 void vnic_dev_unregister(struct vnic_dev *vdev)
 {
 	if (vdev) {
drivers/net/enic/base/vnic_dev.h +1 -0
index 8c0992063..7e5736b4d 100644
@@ -165,6 +165,7 @@ struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
 	void *priv, struct rte_pci_device *pdev, struct vnic_dev_bar *bar,
 	unsigned int num_bars);
 struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev);
+int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev);
 int vnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
 int vnic_dev_get_size(void);
 int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op);
drivers/net/enic/enic_main.c +9 -0
index d4f478b5e..bd4447f01 100644
@@ -1478,6 +1478,15 @@ int enic_probe(struct enic *enic)
 		enic_alloc_consistent,
 		enic_free_consistent);
 
+	/*
+	 * Allocate the consistent memory for stats upfront so both primary and
+	 * secondary processes can dump stats.
+	 */
+	err = vnic_dev_alloc_stats_mem(enic->vdev);
+	if (err) {
+		dev_err(enic, "Failed to allocate cmd memory, aborting\n");
+		goto err_out_unregister;
+	}
 	/* Issue device open to get device in known state */
 	err = enic_dev_open(enic);
 	if (err) {
Signature · 1 line
2.16.2
author
#25 lore raw

PATCH v3 7/10 net/enic: support Rx queue interrupts

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Enable rx queue interrupts if the app requests them, and vNIC has enough interrupt resources. Use interrupt vector 0 for link status and errors. Use vector 1 for rx queue 0, vector 2 for rx queue 1, and so on. So, with n rx queues, vNIC needs to have at n + 1 interrupts.

For VIC, enabling and disabling rx queue interrupts are simply mask/unmask operations. VIC's credit based interrupt moderation is not used, as the app wants to explicitly control when to enable/disable interrupts.

This version requires MSI-X (vfio-pci). Sharing one interrupt for link status and rx queues is possible, but is rather complex and has no user demands.

---
 doc/guides/nics/enic.rst          |   7 ++-
 doc/guides/nics/features/enic.ini |   1 +
 drivers/net/enic/enic.h           |  15 ++++-
 drivers/net/enic/enic_ethdev.c    |  22 +++++++
 drivers/net/enic/enic_main.c      | 123 ++++++++++++++++++++++++++++++++------
 drivers/net/enic/enic_res.c       |   3 +-
 6 files changed, 149 insertions(+), 22 deletions(-)
doc/guides/nics/enic.rst +6 -1
index 0e655e9e3..7e19cf88a 100644
@@ -114,11 +114,16 @@ Configuration information
 
   - **Interrupts**
 
-    Only one interrupt per vNIC interface should be configured in the UCS
+    At least one interrupt per vNIC interface should be configured in the UCS
     manager regardless of the number receive/transmit queues. The ENIC PMD
     uses this interrupt to get information about link status and errors
     in the fast path.
 
+    In addition to the interrupt for link status and errors, when using Rx queue
+    interrupts, increase the number of configured interrupts so that there is at
+    least one interrupt for each Rx queue. For example, if the app uses 3 Rx
+    queues and wants to use per-queue interrupts, configure 4 (3 + 1) interrupts.
+
 .. _enic-flow-director:
 
 Flow director support
doc/guides/nics/features/enic.ini +1 -0
index e79d7277d..ea171a45b 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Link status event    = Y
+Rx interrupt         = Y
 Queue start/stop     = Y
 MTU update           = Y
 Jumbo frame          = Y
drivers/net/enic/enic.h +12 -3
index 1b3813a58..adccc8ac5 100644
@@ -49,6 +49,15 @@
 
 #define ENICPMD_FDIR_MAX           64
 
+/*
+ * Interrupt 0: LSC and errors
+ * Interrupt 1: rx queue 0
+ * Interrupt 2: rx queue 1
+ * ...
+ */
+#define ENICPMD_LSC_INTR_OFFSET 0
+#define ENICPMD_RXQ_INTR_OFFSET 1
+
 struct enic_fdir_node {
 	struct rte_eth_fdir_filter filter;
 	u16 fltr_id;
@@ -126,9 +135,9 @@ struct enic {
 	struct vnic_cq *cq;
 	unsigned int cq_count; /* equals rq_count + wq_count */
 
-	/* interrupt resource */
-	struct vnic_intr intr;
-	unsigned int intr_count;
+	/* interrupt vectors (len = conf_intr_count) */
+	struct vnic_intr *intr;
+	unsigned int intr_count; /* equals enabled interrupts (lsc + rxqs) */
 
 	/* software counters */
 	struct enic_soft_stats soft_stats;
drivers/net/enic/enic_ethdev.c +22 -0
index 6dd72729e..2a289b6a4 100644
@@ -738,6 +738,26 @@ static void enicpmd_dev_txq_info_get(struct rte_eth_dev *dev,
 	/* tx_thresh, and all the other fields are not applicable for enic */
 }
 
+static int enicpmd_dev_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
+					    uint16_t rx_queue_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	vnic_intr_unmask(&enic->intr[rx_queue_id + ENICPMD_RXQ_INTR_OFFSET]);
+	return 0;
+}
+
+static int enicpmd_dev_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
+					     uint16_t rx_queue_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	vnic_intr_mask(&enic->intr[rx_queue_id + ENICPMD_RXQ_INTR_OFFSET]);
+	return 0;
+}
+
 static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_configure        = enicpmd_dev_configure,
 	.dev_start            = enicpmd_dev_start,
@@ -770,6 +790,8 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.rx_descriptor_done   = NULL,
 	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
 	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.rx_queue_intr_enable = enicpmd_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable = enicpmd_dev_rx_queue_intr_disable,
 	.rxq_info_get         = enicpmd_dev_rxq_info_get,
 	.txq_info_get         = enicpmd_dev_txq_info_get,
 	.dev_led_on           = NULL,
drivers/net/enic/enic_main.c +106 -17

236 lines not on this page · raw message

drivers/net/enic/enic_res.c +2 -1
index d8f7892c3..e7ad6767e 100644
@@ -222,7 +222,8 @@ void enic_free_vnic_resources(struct enic *enic)
 			vnic_rq_free(&enic->rq[i]);
 	for (i = 0; i < enic->cq_count; i++)
 		vnic_cq_free(&enic->cq[i]);
-	vnic_intr_free(&enic->intr);
+	for (i = 0; i < enic->intr_count; i++)
+		vnic_intr_free(&enic->intr[i]);
 }
 
 void enic_get_res_counts(struct enic *enic)
Signature · 1 line
2.16.2
author
#26 lore raw

PATCH v3 8/10 doc: describe Rx bytes counter behavior for enic

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 doc/guides/nics/enic.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
doc/guides/nics/enic.rst +8 -0
index 7e19cf88a..0bc55936a 100644
@@ -310,6 +310,14 @@ Limitations
     were added. Since there currently is no grouping or priority support,
     'catch-all' filters should be added last.
 
+- **Statistics**
+
+  - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
+  - When the NIC drops a packet because the Rx queue has no free buffers,
+    ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
+    VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
+    is enabled.
+
 How to build the suite
 ----------------------
 
Signature · 1 line
2.16.2
#27 lore raw

Re: [PATCH v3 08/10] doc: describe Rx bytes counter behavior for enic

doc/guides/nics/enic.rst Limitations · line 319

Quoted 9 lines · On Wed, 7 Mar 2018 18:47:00 -0800 John Daley <[email protected]> wrote:

'catch-all' filters should be added last.

+- **Statistics**

doc/guides/nics/enic.rst +6 -0
+
+  - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
+  - When the NIC drops a packet because the Rx queue has no free buffers,
+    ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
+    VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
+    is enabled.

All drivers must provide consistent statistics! That means do NOT include CRC in the rx byte counts. Yes, several drivers in DPDK are already broken for this.

Otherwise there are cases like packets being forwarded from HW NIC to virtio and the counts differ and customers think data is lots.

#28 lore raw

Re: [PATCH v3 08/10] doc: describe Rx bytes counter behavior for enic

Quoted 13 lines · Stephen Hemminger

doc/guides/nics/enic.rst Limitations · line 319

Quoted 9 lines · On Wed, 7 Mar 2018 18:47:00 -0800 John Daley <[email protected]> wrote:

'catch-all' filters should be added last.

+- **Statistics**

doc/guides/nics/enic.rst +6 -0
+
+  - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
+  - When the NIC drops a packet because the Rx queue has no free buffers,
+    ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
+    VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
+    is enabled.
Quoted 6 lines

All drivers must provide consistent statistics! That means do NOT include CRC in the rx byte counts. Yes, several drivers in DPDK are already broken for this.

Otherwise there are cases like packets being forwarded from HW NIC to virtio and the counts differ and customers think data is lots.

Thanks for sharing this specific use case issue.

We are aware that our current counters are non-standard. Newer 100G hardware models have fixed the problem (i.e. no CRC bytes, no incrementing of bytes when no buffers). We plan to update the doc again when we add these newer models to the supported hardware list.

As for older models, we will see if we can fix up stats in software..

-Hyong

#29 lore raw

Re: [PATCH v3 08/10] doc: describe Rx bytes counter behavior for enic

Quoted 23 lines · On Fri, 9 Mar 2018 09:52:54 +0900 Hyong Youb Kim <[email protected]> wrote:
Quoted 13 lines · Stephen Hemminger

doc/guides/nics/enic.rst Limitations · line 319

Quoted 9 lines · On Wed, 7 Mar 2018 18:47:00 -0800 John Daley <[email protected]> wrote:

'catch-all' filters should be added last.

+- **Statistics**

doc/guides/nics/enic.rst +6 -0
+
+  - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
+  - When the NIC drops a packet because the Rx queue has no free buffers,
+    ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
+    VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
+    is enabled.  
Quoted 6 lines

All drivers must provide consistent statistics! That means do NOT include CRC in the rx byte counts. Yes, several drivers in DPDK are already broken for this.

Otherwise there are cases like packets being forwarded from HW NIC to virtio and the counts differ and customers think data is lots.

Thanks for sharing this specific use case issue.

Quoted 8 lines

We are aware that our current counters are non-standard. Newer 100G hardware models have fixed the problem (i.e. no CRC bytes, no incrementing of bytes when no buffers). We plan to update the doc again when we add these newer models to the supported hardware list.

As for older models, we will see if we can fix up stats in software..

-Hyong

Don't worry some of the Intel drivers are buggy last I checked. Also make sure that when forwarding that bytes transmitted == bytes received. There were some drivers adding CRC on the receive but no on transmit.

It maybe true that you want to count CRC if the CRC stripping flag is not set.

author
#30 lore raw

PATCH v3 9/10 net/enic: use memcpy to avoid strict aliasing warnings

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/enic_clsf.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/net/enic/enic_clsf.c +8 -13
index 3ef1d0832..9d95201ec 100644
@@ -111,7 +111,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 	     struct rte_eth_fdir_masks *masks)
 {
 	struct filter_generic_1 *gp = &fltr->u.generic_1;
-	int i;
 
 	fltr->type = FILTER_DPDK_1;
 	memset(gp, 0, sizeof(*gp));
@@ -273,18 +272,14 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 			ipv6_mask.proto = masks->ipv6_mask.proto;
 			ipv6_val.proto = input->flow.ipv6_flow.proto;
 		}
-		for (i = 0; i < 4; i++) {
-			*(uint32_t *)&ipv6_mask.src_addr[i * 4] =
-					masks->ipv6_mask.src_ip[i];
-			*(uint32_t *)&ipv6_val.src_addr[i * 4] =
-					input->flow.ipv6_flow.src_ip[i];
-		}
-		for (i = 0; i < 4; i++) {
-			*(uint32_t *)&ipv6_mask.dst_addr[i * 4] =
-					masks->ipv6_mask.src_ip[i];
-			*(uint32_t *)&ipv6_val.dst_addr[i * 4] =
-					input->flow.ipv6_flow.dst_ip[i];
-		}
+		memcpy(ipv6_mask.src_addr, masks->ipv6_mask.src_ip,
+		       sizeof(ipv6_mask.src_addr));
+		memcpy(ipv6_val.src_addr, input->flow.ipv6_flow.src_ip,
+		       sizeof(ipv6_val.src_addr));
+		memcpy(ipv6_mask.dst_addr, masks->ipv6_mask.dst_ip,
+		       sizeof(ipv6_mask.dst_addr));
+		memcpy(ipv6_val.dst_addr, input->flow.ipv6_flow.dst_ip,
+		       sizeof(ipv6_val.dst_addr));
 		if (input->flow.ipv6_flow.tc) {
 			ipv6_mask.vtc_flow = masks->ipv6_mask.tc << 12;
 			ipv6_val.vtc_flow = input->flow.ipv6_flow.tc << 12;
Signature · 1 line
2.16.2
author
#31 lore raw

PATCH v3 10/10 net/enic: support for meson

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/meson.build | 19 +++++++++++++++++++
 drivers/net/meson.build      |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/enic/meson.build
drivers/net/enic/meson.build new file +19 -0
new file mode 100644
index 000000000..bfd4e2373
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cisco Systems, Inc.
+
+sources = files(
+	'base/vnic_cq.c',
+	'base/vnic_dev.c',
+	'base/vnic_intr.c',
+	'base/vnic_rq.c',
+	'base/vnic_rss.c',
+	'base/vnic_wq.c',
+	'enic_clsf.c',
+	'enic_ethdev.c',
+	'enic_flow.c',
+	'enic_main.c',
+	'enic_res.c',
+	'enic_rxtx.c',
+	)
+deps += ['hash']
+includes += include_directories('base')
drivers/net/meson.build +1 -1
index 704cbe3c8..f535baa13 100644
@@ -2,7 +2,7 @@
 # Copyright(c) 2017 Intel Corporation
 
 drivers = ['af_packet', 'bonding',
-	'e1000', 'fm10k', 'i40e', 'ixgbe',
+	'e1000', 'enic', 'fm10k', 'i40e', 'ixgbe',
 	'null', 'octeontx', 'pcap', 'ring',
 	'sfc', 'thunderx']
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
Signature · 1 line
2.16.2
Acked-by on v3 10/10
#32 lore raw

Re: [PATCH v3 10/10] net/enic: support for meson

Quoted 10 lines · John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/meson.build | 19 +++++++++++++++++++
 drivers/net/meson.build      |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/enic/meson.build

Patch LGTM

#33 lore raw

Re: [PATCH v3 00/10] enic PMD patchset

In reply to John Daley
Quoted 17 lines · John Daley

V2: rebase, submit as patchset instead of individual patches so they apply correctly.
V3: try again submitting patches one at a time so they are applied in order (tester seems to be applying patches in order received instead of looking at patch ID).

Hyong Youb Kim (9):
net/enic: allow the user to change RSS settings net/enic: heed the requested max Rx packet size net/enic: remove the VLAN filter handler net/enic: add Rx/Tx queue configuration getters net/enic: allocate stats DMA buffer upfront during probe net/enic: support Rx queue interrupts
doc: describe Rx bytes counter behavior for enic net/enic: use memcpy to avoid strict aliasing warnings net/enic: support for meson

Quoted 2 lines

John Daley (1):
net/enic: remove 'extern' in .h file function declarations

Series applied to dpdk-next-net/master, thanks.

(typo in 2/10 fixed while applying)

#34 lore raw

Re: [PATCH v3 00/10] enic PMD patchset

On Fri, Mar 09, 2018 at 04:00:55PM +0000, Ferruh Yigit wrote:
[...]

Quoted 3 lines

Series applied to dpdk-next-net/master, thanks.

(typo in 2/10 fixed while applying)

Thanks a lot for fixing that. Adding "build with assert enabled" to our checklist..

-Hyong

author
#35 lore raw

PATCH v2 2/10 net/enic: allow the user to change RSS settings

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Currently, when more than 1 receive queues are configured, the driver always enables RSS with the driver's own default hash type, key, and RETA. The user is unable to change any of the RSS settings. Address this by implementing the ethdev RSS API as follows.

Correctly report the RETA size, key size, and supported hash types through rte_eth_dev_info.

During dev_configure(), initialize RSS according to the device's mq_mode and rss_conf. Start with the default RETA, and use the default key unless a custom key is provided.

Add the RETA and rss_conf query/set handlers to let the user change RSS settings after the initial configuration. The hardware is able to change hash type, key, and RETA individually. So, the handlers change only the affected settings.

Refactor/rename several functions in order to make their intentions clear. For example, remove all traces of RSS from enicpmd_vlan_offload_set() as it is confusing.

---
 doc/guides/nics/features/enic.ini |   2 +
 drivers/net/enic/enic.h           |  20 +++-
 drivers/net/enic/enic_ethdev.c    | 117 ++++++++++++++++++++++-
 drivers/net/enic/enic_main.c      | 192 ++++++++++++++++++++++++++++----------
 drivers/net/enic/enic_res.c       |  20 ++++
 drivers/net/enic/enic_res.h       |   6 ++
 6 files changed, 301 insertions(+), 56 deletions(-)
doc/guides/nics/features/enic.ini +2 -0
index 498341f07..e79d7277d 100644
@@ -15,6 +15,8 @@ Promiscuous mode     = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
 RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
 SR-IOV               = Y
 VLAN filter          = Y
 CRC offload          = Y
drivers/net/enic/enic.h +19 -1
index e88af6bc9..d29939c94 100644
@@ -146,6 +146,20 @@ struct enic {
 
 	LIST_HEAD(enic_flows, rte_flow) flows;
 	rte_spinlock_t flows_lock;
+
+	/* RSS */
+	uint16_t reta_size;
+	uint8_t hash_key_size;
+	uint64_t flow_type_rss_offloads; /* 0 indicates RSS not supported */
+	/*
+	 * Keep a copy of current RSS config for queries, as we cannot retrieve
+	 * it from the NIC.
+	 */
+	uint8_t rss_hash_type; /* NIC_CFG_RSS_HASH_TYPE flags */
+	uint8_t rss_enable;
+	uint64_t rss_hf; /* ETH_RSS flags */
+	union vnic_rss_key rss_key;
+	union vnic_rss_cpu rss_cpu;
 };
 
 /* Get the CQ index from a Start of Packet(SOP) RQ index */
@@ -239,8 +253,12 @@ void enic_free_rq(void *rxq);
 int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
 		  unsigned int socket_id, struct rte_mempool *mp,
 		  uint16_t nb_desc, uint16_t free_thresh);
-int enic_set_rss_nic_cfg(struct enic *enic);
 int enic_set_vnic_res(struct enic *enic);
+int enic_init_rss_nic_cfg(struct enic *enic);
+int enic_set_rss_conf(struct enic *enic,
+		      struct rte_eth_rss_conf *rss_conf);
+int enic_set_rss_reta(struct enic *enic, union vnic_rss_cpu *rss_cpu);
+int enic_set_vlan_strip(struct enic *enic);
 int enic_enable(struct enic *enic);
 int enic_disable(struct enic *enic);
 void enic_remove(struct enic *enic);
drivers/net/enic/enic_ethdev.c +112 -5

153 lines not on this page · raw message

drivers/net/enic/enic_main.c +142 -50

262 lines not on this page · raw message

drivers/net/enic/enic_res.c +20 -0
index c99d61837..d8f7892c3 100644
@@ -128,6 +128,26 @@ int enic_get_vnic_config(struct enic *enic)
 		c->intr_timer_usec,
 		c->loop_tag);
 
+	/* RSS settings from vNIC */
+	enic->reta_size = ENIC_RSS_RETA_SIZE;
+	enic->hash_key_size = ENIC_RSS_HASH_KEY_SIZE;
+	enic->flow_type_rss_offloads = 0;
+	if (ENIC_SETTING(enic, RSSHASH_IPV4))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV4;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV4))
+		enic->flow_type_rss_offloads |= ETH_RSS_NONFRAG_IPV4_TCP;
+	if (ENIC_SETTING(enic, RSSHASH_IPV6))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV6))
+		enic->flow_type_rss_offloads |= ETH_RSS_NONFRAG_IPV6_TCP;
+	if (ENIC_SETTING(enic, RSSHASH_IPV6_EX))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6_EX;
+	if (ENIC_SETTING(enic, RSSHASH_TCPIPV6_EX))
+		enic->flow_type_rss_offloads |= ETH_RSS_IPV6_TCP_EX;
+	/* Zero offloads if RSS is not enabled */
+	if (!ENIC_SETTING(enic, RSS))
+		enic->flow_type_rss_offloads = 0;
+
 	return 0;
 }
 
drivers/net/enic/enic_res.h +6 -0
index cf3a6fde8..e68f1307b 100644
@@ -31,6 +31,12 @@
 #define ENIC_DEFAULT_RX_FREE_THRESH	32
 #define ENIC_TX_XMIT_MAX		64
 
+#define ENIC_RSS_DEFAULT_CPU    0
+#define ENIC_RSS_BASE_CPU       0
+#define ENIC_RSS_HASH_BITS      7
+#define ENIC_RSS_RETA_SIZE      (1 << ENIC_RSS_HASH_BITS)
+#define ENIC_RSS_HASH_KEY_SIZE  40
+
 #define ENIC_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0)
 
 
Signature · 1 line
2.16.2
author
#36 lore raw

PATCH v2 3/10 net/enic: heed the requested max Rx packet size

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Currently, enic completely ignores the requested max Rx packet size (rxmode.max_rx_pkt_len). The desired behavior is that the NIC hardware drops packets larger than the requested size, even though they are still smaller than MTU.

Cisco VIC does not have such a feature. But, we can accomplish a similar (not same) effect by reducing the size of posted receive buffers. Packets larger than the posted size get truncated, and the receive handler drops them. This is also how the kernel enic driver enforces the Rx side MTU.

This workaround works only when scatter mode is *not* used. When scatter is used, there is currently no way to support rxmode.max_rx_pkt_len, as the NIC always receives packets up to MTU.

For posterity, add a copious amount of comments regarding the hardware's drop/receive behavior with respect to max/current MTU.

---
 doc/guides/nics/enic.rst       |  1 +
 drivers/net/enic/enic.h        |  7 ++++++
 drivers/net/enic/enic_ethdev.c |  9 +++++++-
 drivers/net/enic/enic_main.c   | 49 ++++++++++++++++++++++++++++++++++++------
 4 files changed, 58 insertions(+), 8 deletions(-)
doc/guides/nics/enic.rst +1 -0
index 4dffce1a6..0e655e9e3 100644
@@ -371,6 +371,7 @@ Known bugs and unsupported features in this release
 - Setting of extended VLAN
 - UDP RSS hashing
 - MTU update only works if Scattered Rx mode is disabled
+- Maximum receive packet length is ignored if Scattered Rx mode is used
 
 Prerequisites
 -------------
drivers/net/enic/enic.h +7 -0
index d29939c94..1b3813a58 100644
@@ -162,6 +162,13 @@ struct enic {
 	union vnic_rss_cpu rss_cpu;
 };
 
+/* Compute ethdev's max packet size from MTU */
+static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu)
+{
+	/* ethdev max size includes eth and crc whereas NIC MTU does not */
+	return mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+}
+
 /* Get the CQ index from a Start of Packet(SOP) RQ index */
 static inline unsigned int enic_sop_rq_idx_to_cq_idx(unsigned int sop_idx)
 {
drivers/net/enic/enic_ethdev.c +8 -1
index cbab7029b..bdbaf4cdf 100644
@@ -470,7 +470,14 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	device_info->max_rx_queues = enic->conf_rq_count / 2;
 	device_info->max_tx_queues = enic->conf_wq_count;
 	device_info->min_rx_bufsize = ENIC_MIN_MTU;
-	device_info->max_rx_pktlen = enic->max_mtu + ETHER_HDR_LEN + 4;
+	/* "Max" mtu is not a typo. HW receives packet sizes up to the
+	 * max mtu regardless of the current mtu (vNIC's mtu). vNIC mtu is
+	 * a hint to the driver to size receive buffers accordingly so that
+	 * larger-than-vnic-mtu packets get truncated.. For DPDK, we let
+	 * the user decide the buffer size via rxmode.max_rx_pkt_len, basically
+	 * ignoring vNIC mtu.
+	 */
+	device_info->max_rx_pktlen = enic_mtu_to_max_rx_pktlen(enic->max_mtu);
 	device_info->max_mac_addrs = ENIC_MAX_MAC_ADDR;
 	device_info->rx_offload_capa =
 		DEV_RX_OFFLOAD_VLAN_STRIP |
drivers/net/enic/enic_main.c +42 -7

98 lines not on this page · raw message

Signature · 1 line
2.16.2
author
#37 lore raw

PATCH v2 4/10 net/enic: remove the VLAN filter handler

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

VIC does not support VLAN filtering at the moment. The firmware does accept the filter add/del commands and returns success. But, they are no-ops. To avoid confusion, remove the filter set handler so the app sees an error instead of silent failure.

Also during the device configure time, enicpmd_vlan_offload_set would not print a warning message about unsupported VLAN filtering, because the caller specifies only ETH_VLAN_STRIP_MASK. This is wrong, as we should attempt to apply all requested offloads at the configure time. So, pass all VLAN offload masks, which triggers a warning message about VLAN filtering, if requested.

Finally, enicpmd_vlan_offload_set should check both mask and rxmode.offloads, not just mask.

---
 drivers/net/enic/enic_ethdev.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/net/enic/enic_ethdev.c +14 -20
index bdbaf4cdf..e5523e311 100644
@@ -318,40 +318,29 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 	return enicpmd_dev_setup_intr(enic);
 }
 
-static int enicpmd_vlan_filter_set(struct rte_eth_dev *eth_dev,
-	uint16_t vlan_id, int on)
-{
-	struct enic *enic = pmd_priv(eth_dev);
-	int err;
-
-	ENICPMD_FUNC_TRACE();
-	if (on)
-		err = enic_add_vlan(enic, vlan_id);
-	else
-		err = enic_del_vlan(enic, vlan_id);
-	return err;
-}
-
 static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 {
 	struct enic *enic = pmd_priv(eth_dev);
+	uint64_t offloads;
 
 	ENICPMD_FUNC_TRACE();
 
+	offloads = eth_dev->data->dev_conf.rxmode.offloads;
 	if (mask & ETH_VLAN_STRIP_MASK) {
-		if (eth_dev->data->dev_conf.rxmode.offloads &
-		    DEV_RX_OFFLOAD_VLAN_STRIP)
+		if (offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
 			enic->ig_vlan_strip_en = 1;
 		else
 			enic->ig_vlan_strip_en = 0;
 	}
 
-	if (mask & ETH_VLAN_FILTER_MASK) {
+	if ((mask & ETH_VLAN_FILTER_MASK) &&
+	    (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) {
 		dev_warning(enic,
 			"Configuration of VLAN filter is not supported\n");
 	}
 
-	if (mask & ETH_VLAN_EXTEND_MASK) {
+	if ((mask & ETH_VLAN_EXTEND_MASK) &&
+	    (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) {
 		dev_warning(enic,
 			"Configuration of extended VLAN is not supported\n");
 	}
@@ -362,6 +351,7 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
 {
 	int ret;
+	int mask;
 	struct enic *enic = pmd_priv(eth_dev);
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -376,7 +366,11 @@ static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
 
 	enic->hw_ip_checksum = !!(eth_dev->data->dev_conf.rxmode.offloads &
 				  DEV_RX_OFFLOAD_CHECKSUM);
-	ret = enicpmd_vlan_offload_set(eth_dev, ETH_VLAN_STRIP_MASK);
+	/* All vlan offload masks to apply the current settings */
+	mask = ETH_VLAN_STRIP_MASK |
+		ETH_VLAN_FILTER_MASK |
+		ETH_VLAN_EXTEND_MASK;
+	ret = enicpmd_vlan_offload_set(eth_dev, mask);
 	if (ret) {
 		dev_err(enic, "Failed to configure VLAN offloads\n");
 		return ret;
@@ -710,7 +704,7 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_infos_get        = enicpmd_dev_info_get,
 	.dev_supported_ptypes_get = enicpmd_dev_supported_ptypes_get,
 	.mtu_set              = enicpmd_mtu_set,
-	.vlan_filter_set      = enicpmd_vlan_filter_set,
+	.vlan_filter_set      = NULL,
 	.vlan_tpid_set        = NULL,
 	.vlan_offload_set     = enicpmd_vlan_offload_set,
 	.vlan_strip_queue_set = NULL,
Signature · 1 line
2.16.2
author
#38 lore raw

PATCH v2 5/10 net/enic: add Rx/Tx queue configuration getters

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/enic_ethdev.c | 76 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 65 insertions(+), 11 deletions(-)
drivers/net/enic/enic_ethdev.c +65 -11
index e5523e311..6dd72729e 100644
@@ -39,6 +39,19 @@ static const struct rte_pci_id pci_id_enic_map[] = {
 	{.vendor_id = 0, /* sentinel */},
 };
 
+#define ENIC_TX_OFFLOAD_CAPA (			\
+		DEV_TX_OFFLOAD_VLAN_INSERT |	\
+		DEV_TX_OFFLOAD_IPV4_CKSUM  |	\
+		DEV_TX_OFFLOAD_UDP_CKSUM   |	\
+		DEV_TX_OFFLOAD_TCP_CKSUM   |	\
+		DEV_TX_OFFLOAD_TCP_TSO)
+
+#define ENIC_RX_OFFLOAD_CAPA (			\
+		DEV_RX_OFFLOAD_VLAN_STRIP |	\
+		DEV_RX_OFFLOAD_IPV4_CKSUM |	\
+		DEV_RX_OFFLOAD_UDP_CKSUM  |	\
+		DEV_RX_OFFLOAD_TCP_CKSUM)
+
 RTE_INIT(enicpmd_init_log);
 static void
 enicpmd_init_log(void)
@@ -473,17 +486,8 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	 */
 	device_info->max_rx_pktlen = enic_mtu_to_max_rx_pktlen(enic->max_mtu);
 	device_info->max_mac_addrs = ENIC_MAX_MAC_ADDR;
-	device_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_VLAN_STRIP |
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM  |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-	device_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_VLAN_INSERT |
-		DEV_TX_OFFLOAD_IPV4_CKSUM  |
-		DEV_TX_OFFLOAD_UDP_CKSUM   |
-		DEV_TX_OFFLOAD_TCP_CKSUM   |
-		DEV_TX_OFFLOAD_TCP_TSO;
+	device_info->rx_offload_capa = ENIC_RX_OFFLOAD_CAPA;
+	device_info->tx_offload_capa = ENIC_TX_OFFLOAD_CAPA;
 	device_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = ENIC_DEFAULT_RX_FREE_THRESH
 	};
@@ -686,6 +690,54 @@ static int enicpmd_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void enicpmd_dev_rxq_info_get(struct rte_eth_dev *dev,
+				     uint16_t rx_queue_id,
+				     struct rte_eth_rxq_info *qinfo)
+{
+	struct enic *enic = pmd_priv(dev);
+	struct vnic_rq *rq_sop;
+	struct vnic_rq *rq_data;
+	struct rte_eth_rxconf *conf;
+	uint16_t sop_queue_idx;
+	uint16_t data_queue_idx;
+
+	ENICPMD_FUNC_TRACE();
+	sop_queue_idx = enic_rte_rq_idx_to_sop_idx(rx_queue_id);
+	data_queue_idx = enic_rte_rq_idx_to_data_idx(rx_queue_id);
+	rq_sop = &enic->rq[sop_queue_idx];
+	rq_data = &enic->rq[data_queue_idx]; /* valid if data_queue_enable */
+	qinfo->mp = rq_sop->mp;
+	qinfo->scattered_rx = rq_sop->data_queue_enable;
+	qinfo->nb_desc = rq_sop->ring.desc_count;
+	if (qinfo->scattered_rx)
+		qinfo->nb_desc += rq_data->ring.desc_count;
+	conf = &qinfo->conf;
+	memset(conf, 0, sizeof(*conf));
+	conf->rx_free_thresh = rq_sop->rx_free_thresh;
+	conf->rx_drop_en = 1;
+	/*
+	 * Except VLAN stripping (port setting), all the checksum offloads
+	 * are always enabled.
+	 */
+	conf->offloads = ENIC_RX_OFFLOAD_CAPA;
+	if (!enic->ig_vlan_strip_en)
+		conf->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
+	/* rx_thresh and other fields are not applicable for enic */
+}
+
+static void enicpmd_dev_txq_info_get(struct rte_eth_dev *dev,
+				     __rte_unused uint16_t tx_queue_id,
+				     struct rte_eth_txq_info *qinfo)
+{
+	struct enic *enic = pmd_priv(dev);
+
+	ENICPMD_FUNC_TRACE();
+	qinfo->nb_desc = enic->config.wq_desc_count;
+	memset(&qinfo->conf, 0, sizeof(qinfo->conf));
+	qinfo->conf.offloads = ENIC_TX_OFFLOAD_CAPA; /* not configurable */
+	/* tx_thresh, and all the other fields are not applicable for enic */
+}
+
 static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_configure        = enicpmd_dev_configure,
 	.dev_start            = enicpmd_dev_start,
@@ -718,6 +770,8 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.rx_descriptor_done   = NULL,
 	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
 	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.rxq_info_get         = enicpmd_dev_rxq_info_get,
+	.txq_info_get         = enicpmd_dev_txq_info_get,
 	.dev_led_on           = NULL,
 	.dev_led_off          = NULL,
 	.flow_ctrl_get        = NULL,
Signature · 1 line
2.16.2
author
#39 lore raw

PATCH v2 6/10 net/enic: allocate stats DMA buffer upfront during probe

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

The driver provides a DMA buffer to the firmware when it requests port stats. The NIC then fills that buffer with latest stats. Currently, the driver allocates the DMA buffer the first time it requests stats and saves it for later use. This can lead to crashes when primary/secondary processes are involved. For example, the following sequence crashes the secondary process.

1. Start a primary app that does not call rte_eth_stats_get()
2. dpdk-procinfo -- --stats

dpdk-procinfo crashes while trying to allocate the stats DMA buffer because the alloc function pointer (vdev.alloc_consistent) is valid only in the primary process, not in the secondary process.

Overwriting the alloc function pointer in the secondary process is not an option, as it will simply make the pointer invalid in the primary process. Instead, allocate the DMA buffer during probe so that only the primary process does both allocate and free. This allows the secondary process to dump stats as well.

Fixes 9913fbb91df0 ("enic/base: common code")
---
 drivers/net/enic/base/vnic_dev.c | 24 ++++++++++++++----------
 drivers/net/enic/base/vnic_dev.h |  1 +
 drivers/net/enic/enic_main.c     |  9 +++++++++
 3 files changed, 24 insertions(+), 10 deletions(-)
drivers/net/enic/base/vnic_dev.c +14 -10
index 05b595eb8..1f8d222fc 100644
@@ -587,17 +587,9 @@ int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats)
 {
 	u64 a0, a1;
 	int wait = 1000;
-	static u32 instance;
-	char name[NAME_MAX];
 
-	if (!vdev->stats) {
-		snprintf((char *)name, sizeof(name),
-			"vnic_stats-%u", instance++);
-		vdev->stats = vdev->alloc_consistent(vdev->priv,
-			sizeof(struct vnic_stats), &vdev->stats_pa, (u8 *)name);
-		if (!vdev->stats)
-			return -ENOMEM;
-	}
+	if (!vdev->stats)
+		return -ENOMEM;
 
 	*stats = vdev->stats;
 	a0 = vdev->stats_pa;
@@ -922,6 +914,18 @@ u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev)
 	return vdev->intr_coal_timer_info.max_usec;
 }
 
+int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev)
+{
+	char name[NAME_MAX];
+	static u32 instance;
+
+	snprintf((char *)name, sizeof(name), "vnic_stats-%u", instance++);
+	vdev->stats = vdev->alloc_consistent(vdev->priv,
+					     sizeof(struct vnic_stats),
+					     &vdev->stats_pa, (u8 *)name);
+	return vdev->stats == NULL ? -ENOMEM : 0;
+}
+
 void vnic_dev_unregister(struct vnic_dev *vdev)
 {
 	if (vdev) {
drivers/net/enic/base/vnic_dev.h +1 -0
index 8c0992063..7e5736b4d 100644
@@ -165,6 +165,7 @@ struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
 	void *priv, struct rte_pci_device *pdev, struct vnic_dev_bar *bar,
 	unsigned int num_bars);
 struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev);
+int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev);
 int vnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
 int vnic_dev_get_size(void);
 int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op);
drivers/net/enic/enic_main.c +9 -0
index d4f478b5e..bd4447f01 100644
@@ -1478,6 +1478,15 @@ int enic_probe(struct enic *enic)
 		enic_alloc_consistent,
 		enic_free_consistent);
 
+	/*
+	 * Allocate the consistent memory for stats upfront so both primary and
+	 * secondary processes can dump stats.
+	 */
+	err = vnic_dev_alloc_stats_mem(enic->vdev);
+	if (err) {
+		dev_err(enic, "Failed to allocate cmd memory, aborting\n");
+		goto err_out_unregister;
+	}
 	/* Issue device open to get device in known state */
 	err = enic_dev_open(enic);
 	if (err) {
Signature · 1 line
2.16.2
author
#40 lore raw

PATCH v2 7/10 net/enic: support Rx queue interrupts

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

Enable rx queue interrupts if the app requests them, and vNIC has enough interrupt resources. Use interrupt vector 0 for link status and errors. Use vector 1 for rx queue 0, vector 2 for rx queue 1, and so on. So, with n rx queues, vNIC needs to have at n + 1 interrupts.

For VIC, enabling and disabling rx queue interrupts are simply mask/unmask operations. VIC's credit based interrupt moderation is not used, as the app wants to explicitly control when to enable/disable interrupts.

This version requires MSI-X (vfio-pci). Sharing one interrupt for link status and rx queues is possible, but is rather complex and has no user demands.

---
 doc/guides/nics/enic.rst          |   7 ++-
 doc/guides/nics/features/enic.ini |   1 +
 drivers/net/enic/enic.h           |  15 ++++-
 drivers/net/enic/enic_ethdev.c    |  22 +++++++
 drivers/net/enic/enic_main.c      | 123 ++++++++++++++++++++++++++++++++------
 drivers/net/enic/enic_res.c       |   3 +-
 6 files changed, 149 insertions(+), 22 deletions(-)
doc/guides/nics/enic.rst +6 -1
index 0e655e9e3..7e19cf88a 100644
@@ -114,11 +114,16 @@ Configuration information
 
   - **Interrupts**
 
-    Only one interrupt per vNIC interface should be configured in the UCS
+    At least one interrupt per vNIC interface should be configured in the UCS
     manager regardless of the number receive/transmit queues. The ENIC PMD
     uses this interrupt to get information about link status and errors
     in the fast path.
 
+    In addition to the interrupt for link status and errors, when using Rx queue
+    interrupts, increase the number of configured interrupts so that there is at
+    least one interrupt for each Rx queue. For example, if the app uses 3 Rx
+    queues and wants to use per-queue interrupts, configure 4 (3 + 1) interrupts.
+
 .. _enic-flow-director:
 
 Flow director support
doc/guides/nics/features/enic.ini +1 -0
index e79d7277d..ea171a45b 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Link status event    = Y
+Rx interrupt         = Y
 Queue start/stop     = Y
 MTU update           = Y
 Jumbo frame          = Y
drivers/net/enic/enic.h +12 -3
index 1b3813a58..adccc8ac5 100644
@@ -49,6 +49,15 @@
 
 #define ENICPMD_FDIR_MAX           64
 
+/*
+ * Interrupt 0: LSC and errors
+ * Interrupt 1: rx queue 0
+ * Interrupt 2: rx queue 1
+ * ...
+ */
+#define ENICPMD_LSC_INTR_OFFSET 0
+#define ENICPMD_RXQ_INTR_OFFSET 1
+
 struct enic_fdir_node {
 	struct rte_eth_fdir_filter filter;
 	u16 fltr_id;
@@ -126,9 +135,9 @@ struct enic {
 	struct vnic_cq *cq;
 	unsigned int cq_count; /* equals rq_count + wq_count */
 
-	/* interrupt resource */
-	struct vnic_intr intr;
-	unsigned int intr_count;
+	/* interrupt vectors (len = conf_intr_count) */
+	struct vnic_intr *intr;
+	unsigned int intr_count; /* equals enabled interrupts (lsc + rxqs) */
 
 	/* software counters */
 	struct enic_soft_stats soft_stats;
drivers/net/enic/enic_ethdev.c +22 -0
index 6dd72729e..2a289b6a4 100644
@@ -738,6 +738,26 @@ static void enicpmd_dev_txq_info_get(struct rte_eth_dev *dev,
 	/* tx_thresh, and all the other fields are not applicable for enic */
 }
 
+static int enicpmd_dev_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
+					    uint16_t rx_queue_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	vnic_intr_unmask(&enic->intr[rx_queue_id + ENICPMD_RXQ_INTR_OFFSET]);
+	return 0;
+}
+
+static int enicpmd_dev_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
+					     uint16_t rx_queue_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	vnic_intr_mask(&enic->intr[rx_queue_id + ENICPMD_RXQ_INTR_OFFSET]);
+	return 0;
+}
+
 static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.dev_configure        = enicpmd_dev_configure,
 	.dev_start            = enicpmd_dev_start,
@@ -770,6 +790,8 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
 	.rx_descriptor_done   = NULL,
 	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
 	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.rx_queue_intr_enable = enicpmd_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable = enicpmd_dev_rx_queue_intr_disable,
 	.rxq_info_get         = enicpmd_dev_rxq_info_get,
 	.txq_info_get         = enicpmd_dev_txq_info_get,
 	.dev_led_on           = NULL,
drivers/net/enic/enic_main.c +106 -17

236 lines not on this page · raw message

drivers/net/enic/enic_res.c +2 -1
index d8f7892c3..e7ad6767e 100644
@@ -222,7 +222,8 @@ void enic_free_vnic_resources(struct enic *enic)
 			vnic_rq_free(&enic->rq[i]);
 	for (i = 0; i < enic->cq_count; i++)
 		vnic_cq_free(&enic->cq[i]);
-	vnic_intr_free(&enic->intr);
+	for (i = 0; i < enic->intr_count; i++)
+		vnic_intr_free(&enic->intr[i]);
 }
 
 void enic_get_res_counts(struct enic *enic)
Signature · 1 line
2.16.2
author
#41 lore raw

PATCH v2 8/10 doc: describe Rx bytes counter behavior for enic

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 doc/guides/nics/enic.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
doc/guides/nics/enic.rst +8 -0
index 7e19cf88a..0bc55936a 100644
@@ -310,6 +310,14 @@ Limitations
     were added. Since there currently is no grouping or priority support,
     'catch-all' filters should be added last.
 
+- **Statistics**
+
+  - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
+  - When the NIC drops a packet because the Rx queue has no free buffers,
+    ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
+    VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
+    is enabled.
+
 How to build the suite
 ----------------------
 
Signature · 1 line
2.16.2
author
#42 lore raw

PATCH v2 9/10 net/enic: use memcpy to avoid strict aliasing warnings

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---
 drivers/net/enic/enic_clsf.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/net/enic/enic_clsf.c +8 -13
index 3ef1d0832..9d95201ec 100644
@@ -111,7 +111,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 	     struct rte_eth_fdir_masks *masks)
 {
 	struct filter_generic_1 *gp = &fltr->u.generic_1;
-	int i;
 
 	fltr->type = FILTER_DPDK_1;
 	memset(gp, 0, sizeof(*gp));
@@ -273,18 +272,14 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 			ipv6_mask.proto = masks->ipv6_mask.proto;
 			ipv6_val.proto = input->flow.ipv6_flow.proto;
 		}
-		for (i = 0; i < 4; i++) {
-			*(uint32_t *)&ipv6_mask.src_addr[i * 4] =
-					masks->ipv6_mask.src_ip[i];
-			*(uint32_t *)&ipv6_val.src_addr[i * 4] =
-					input->flow.ipv6_flow.src_ip[i];
-		}
-		for (i = 0; i < 4; i++) {
-			*(uint32_t *)&ipv6_mask.dst_addr[i * 4] =
-					masks->ipv6_mask.src_ip[i];
-			*(uint32_t *)&ipv6_val.dst_addr[i * 4] =
-					input->flow.ipv6_flow.dst_ip[i];
-		}
+		memcpy(ipv6_mask.src_addr, masks->ipv6_mask.src_ip,
+		       sizeof(ipv6_mask.src_addr));
+		memcpy(ipv6_val.src_addr, input->flow.ipv6_flow.src_ip,
+		       sizeof(ipv6_val.src_addr));
+		memcpy(ipv6_mask.dst_addr, masks->ipv6_mask.dst_ip,
+		       sizeof(ipv6_mask.dst_addr));
+		memcpy(ipv6_val.dst_addr, input->flow.ipv6_flow.dst_ip,
+		       sizeof(ipv6_val.dst_addr));
 		if (input->flow.ipv6_flow.tc) {
 			ipv6_mask.vtc_flow = masks->ipv6_mask.tc << 12;
 			ipv6_val.vtc_flow = input->flow.ipv6_flow.tc << 12;
Signature · 1 line
2.16.2
author
#43 lore raw

PATCH v2 10/10 net/enic: support for meson

In reply to John Daley

From: Hyong Youb Kim <[email protected]>

---

 drivers/net/enic/meson.build | 19 +++++++++++++++++++
 drivers/net/meson.build      |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/enic/meson.build
drivers/net/enic/meson.build new file +19 -0
new file mode 100644
index 000000000..bfd4e2373
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cisco Systems, Inc.
+
+sources = files(
+	'base/vnic_cq.c',
+	'base/vnic_dev.c',
+	'base/vnic_intr.c',
+	'base/vnic_rq.c',
+	'base/vnic_rss.c',
+	'base/vnic_wq.c',
+	'enic_clsf.c',
+	'enic_ethdev.c',
+	'enic_flow.c',
+	'enic_main.c',
+	'enic_res.c',
+	'enic_rxtx.c',
+	)
+deps += ['hash']
+includes += include_directories('base')
drivers/net/meson.build +1 -1
index 704cbe3c8..f535baa13 100644
@@ -2,7 +2,7 @@
 # Copyright(c) 2017 Intel Corporation
 
 drivers = ['af_packet', 'bonding',
-	'e1000', 'fm10k', 'i40e', 'ixgbe',
+	'e1000', 'enic', 'fm10k', 'i40e', 'ixgbe',
 	'null', 'octeontx', 'pcap', 'ring',
 	'sfc', 'thunderx']
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
Signature · 1 line
2.16.2