Skip to contentSkip to conversation

net/netvsc: patches

PATCH Superseded Stephen Hemminger 2 participants 27 messages Mar 16, 2020 – Apr 7, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/netvsc: patches

A couple of fixes for netvsc PMD.
The first is more serious than the second.

Stephen Hemminger (2):
net/netvsc: handle receive packets during multi-channel setup net/netvsc: avoid mixing buffered and direct packets

 drivers/net/netvsc/hn_ethdev.c |  1 +
 drivers/net/netvsc/hn_nvs.c    | 40 ++++++++++++++++++++++++++++++++--
 drivers/net/netvsc/hn_rxtx.c   | 15 ++++++-------
 drivers/net/netvsc/hn_var.h    |  1 +
 4 files changed, 47 insertions(+), 10 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 net/netvsc: handle receive packets during multi-channel setup

It is possible for a packet to arrive during the configuration process when setting up multiple queue mode. This would cause configure to fail; fix by just ignoring receive packets while waiting for control commands.

Add a spinlock to ensure that two control operations are not attempted at once.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_ethdev.c |  1 +
 drivers/net/netvsc/hn_nvs.c    | 40 ++++++++++++++++++++++++++++++++--
 drivers/net/netvsc/hn_var.h    |  1 +
 3 files changed, 40 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_ethdev.c +1 -0
index 564620748daf..01e69de6f3e2 100644
@@ -951,6 +951,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	hv->latency = HN_CHAN_LATENCY_NS;
 	hv->max_queues = 1;
 	rte_spinlock_init(&hv->vf_lock);
+	rte_spinlock_init(&hv->nvs_lock);
 	hv->vf_port = HN_INVALID_PORT;
 
 	err = hn_parse_args(eth_dev);
drivers/net/netvsc/hn_nvs.c +38 -2
index 6b518685ab6f..f56692f4d605 100644
@@ -54,7 +54,7 @@ static int hn_nvs_req_send(struct hn_data *hv,
 }
 
 static int
-hn_nvs_execute(struct hn_data *hv,
+__hn_nvs_execute(struct hn_data *hv,
 	       void *req, uint32_t reqlen,
 	       void *resp, uint32_t resplen,
 	       uint32_t type)
@@ -62,6 +62,7 @@ hn_nvs_execute(struct hn_data *hv,
 	struct vmbus_channel *chan = hn_primary_chan(hv);
 	char buffer[NVS_RESPSIZE_MAX];
 	const struct hn_nvs_hdr *hdr;
+	uint64_t xactid;
 	uint32_t len;
 	int ret;
 
@@ -77,7 +78,7 @@ hn_nvs_execute(struct hn_data *hv,
 
  retry:
 	len = sizeof(buffer);
-	ret = rte_vmbus_chan_recv(chan, buffer, &len, NULL);
+	ret = rte_vmbus_chan_recv(chan, buffer, &len, &xactid);
 	if (ret == -EAGAIN) {
 		rte_delay_us(HN_CHAN_INTERVAL_US);
 		goto retry;
@@ -88,7 +89,20 @@ hn_nvs_execute(struct hn_data *hv,
 		return ret;
 	}
 
+	if (len < sizeof(*hdr)) {
+		PMD_DRV_LOG(ERR, "response missing NVS header");
+		return -EINVAL;
+	}
+
 	hdr = (struct hn_nvs_hdr *)buffer;
+
+	/* Silently drop received packets while waiting for response */
+	if (hdr->type == NVS_TYPE_RNDIS) {
+		hn_nvs_ack_rxbuf(chan, xactid);
+		--hv->rxbuf_outstanding;
+		goto retry;
+	}
+
 	if (hdr->type != type) {
 		PMD_DRV_LOG(ERR, "unexpected NVS resp %#x, expect %#x",
 			    hdr->type, type);
@@ -108,6 +122,28 @@ hn_nvs_execute(struct hn_data *hv,
 	return 0;
 }
 
+
+/*
+ * Execute one control command and get the response.
+ * Only one command can be active on a channel at once
+ * Unlike BSD, DPDK does not have an interrupt context
+ * so the polling is required to wait for response.
+ */
+static int
+hn_nvs_execute(struct hn_data *hv,
+	       void *req, uint32_t reqlen,
+	       void *resp, uint32_t resplen,
+	       uint32_t type)
+{
+	int ret;
+
+	rte_spinlock_lock(&hv->nvs_lock);
+	ret = __hn_nvs_execute(hv, req, reqlen, resp, resplen, type);
+	rte_spinlock_unlock(&hv->nvs_lock);
+
+	return ret;
+}
+
 static int
 hn_nvs_doinit(struct hn_data *hv, uint32_t nvs_ver)
 {
drivers/net/netvsc/hn_var.h +1 -0
index 05bc492511ec..7434ff19bfa5 100644
@@ -97,6 +97,7 @@ struct hn_data {
 	struct rte_vmbus_device *vmbus;
 	struct hn_rx_queue *primary;
 	rte_spinlock_t  vf_lock;
+	rte_spinlock_t  nvs_lock;
 	uint16_t	port_id;
 	uint16_t	vf_port;
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 net/netvsc: avoid mixing buffered and direct packets

In reply to Stephen Hemminger

Putting buffered and direct packets together into one request is an unnecessary optimization. Better to split into two requests (buffered and direct).

---
 drivers/net/netvsc/hn_rxtx.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/netvsc/hn_rxtx.c +7 -8
index 7212780c156e..aad3d8c04c7f 100644
@@ -1362,15 +1362,14 @@ hn_xmit_pkts(void *ptxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		} else {
 			struct hn_txdesc *txd;
 
-			/* can send chimney data and large packet at once */
+			/* Send any outstanding packets in buffer */
 			txd = txq->agg_txd;
-			if (txd) {
-				hn_reset_txagg(txq);
-			} else {
-				txd = hn_new_txd(hv, txq);
-				if (unlikely(!txd))
-					break;
-			}
+			if (txd && hn_flush_txagg(txq, &need_sig))
+				goto fail;
+
+			txd = hn_new_txd(hv, txq);
+			if (unlikely(!txd))
+				break;
 
 			pkt = txd->rndis_pkt;
 			txd->m = m;
Signature · 1 line
2.20.1
#3 lore raw
In reply to Stephen Hemminger
Quoted 7 lines · Stephen Hemminger

A couple of fixes for netvsc PMD.
The first is more serious than the second.

Stephen Hemminger (2):
net/netvsc: handle receive packets during multi-channel setup net/netvsc: avoid mixing buffered and direct packets

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

#4 lore raw
Quoted 10 lines · On Wed, 18 Mar 2020 17:33:18 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 7 lines · Stephen Hemminger

A couple of fixes for netvsc PMD.
The first is more serious than the second.

Stephen Hemminger (2):
net/netvsc: handle receive packets during multi-channel setup net/netvsc: avoid mixing buffered and direct packets

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

Could you back it out. I have v2 to send today.

#5 lore raw
Quoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Wed, 18 Mar 2020 17:33:18 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 3 lines · Stephen Hemminger

A couple of fixes for netvsc PMD.
The first is more serious than the second.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Stephen Hemminger (2):
net/netvsc: handle receive packets during multi-channel setup net/netvsc: avoid mixing buffered and direct packets

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

Could you back it out. I have v2 to send today.

Done, dropped from next-net.

#6 lore raw

v2 cover net/netvsc patches

In reply to Stephen Hemminger

These are bug fixes for netvsc PMD mostly related to issues discovered by users of multi-queue.

v2 -- simplify the locking on multi-channel setup
add patches to handle single queue and tx descriptor pool

Stephen Hemminger (4):
net/netvsc: propogate descriptor limits from VF to netvsc net/netvsc: handle receive packets during multi-channel setup net/netvsc: split send buffers from transmit descriptors net/netvsc: don't enable RSS if only single receive queue

 drivers/net/netvsc/hn_ethdev.c |  22 ++-
 drivers/net/netvsc/hn_nvs.c    |  41 +++++-
 drivers/net/netvsc/hn_rxtx.c   | 258 ++++++++++++++++++++-------------
 drivers/net/netvsc/hn_var.h    |  10 +-
 drivers/net/netvsc/hn_vf.c     |  13 ++
 5 files changed, 231 insertions(+), 113 deletions(-)
Signature · 1 line
2.20.1
#7 lore raw

PATCH v2 1/4 net/netvsc: propogate descriptor limits from VF to netvsc

If application cares about descriptor limits, the netvsc device values should reflect those of the VF as well.

Fixes dc7680e8597c ("net/netvsc: support integrated VF")
---
 drivers/net/netvsc/hn_vf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/netvsc/hn_vf.c +13 -0
index 7a3734cadfa4..1261b2e2ef85 100644
@@ -167,6 +167,17 @@ hn_nvs_handle_vfassoc(struct rte_eth_dev *dev,
 		hn_vf_remove(hv);
 }
 
+static void
+hn_vf_merge_desc_lim(struct rte_eth_desc_lim *lim,
+		     const struct rte_eth_desc_lim *vf_lim)
+{
+	lim->nb_max = RTE_MIN(vf_lim->nb_max, lim->nb_max);
+	lim->nb_min = RTE_MAX(vf_lim->nb_min, lim->nb_min);
+	lim->nb_align = RTE_MAX(vf_lim->nb_align, lim->nb_align);
+	lim->nb_seg_max = RTE_MIN(vf_lim->nb_seg_max, lim->nb_seg_max);
+	lim->nb_mtu_seg_max = RTE_MIN(vf_lim->nb_seg_max, lim->nb_seg_max);
+}
+
 /*
  * Merge the info from the VF and synthetic path.
  * use the default config of the VF
@@ -196,11 +207,13 @@ static int hn_vf_info_merge(struct rte_eth_dev *vf_dev,
 				      info->max_tx_queues);
 	info->tx_offload_capa &= vf_info.tx_offload_capa;
 	info->tx_queue_offload_capa &= vf_info.tx_queue_offload_capa;
+	hn_vf_merge_desc_lim(&info->tx_desc_lim, &vf_info.tx_desc_lim);
 
 	info->min_rx_bufsize = RTE_MAX(vf_info.min_rx_bufsize,
 				       info->min_rx_bufsize);
 	info->max_rx_pktlen  = RTE_MAX(vf_info.max_rx_pktlen,
 				       info->max_rx_pktlen);
+	hn_vf_merge_desc_lim(&info->rx_desc_lim, &vf_info.rx_desc_lim);
 
 	return 0;
 }
Signature · 1 line
2.20.1
#8 lore raw

PATCH v2 2/4 net/netvsc: handle receive packets during multi-channel setup

In reply to Stephen Hemminger

It is possible for a packet to arrive during the configuration process when setting up multiple queue mode. This would cause configure to fail; fix by just ignoring receive packets while waiting for control commands.

Use the receive ring lock to avoid possible races between oddly behaved applications doing rx_burst and control operations concurrently.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_nvs.c | 41 +++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_nvs.c +39 -2
index 6b518685ab6f..477202b2a0b7 100644
@@ -54,7 +54,7 @@ static int hn_nvs_req_send(struct hn_data *hv,
 }
 
 static int
-hn_nvs_execute(struct hn_data *hv,
+__hn_nvs_execute(struct hn_data *hv,
 	       void *req, uint32_t reqlen,
 	       void *resp, uint32_t resplen,
 	       uint32_t type)
@@ -62,6 +62,7 @@ hn_nvs_execute(struct hn_data *hv,
 	struct vmbus_channel *chan = hn_primary_chan(hv);
 	char buffer[NVS_RESPSIZE_MAX];
 	const struct hn_nvs_hdr *hdr;
+	uint64_t xactid;
 	uint32_t len;
 	int ret;
 
@@ -77,7 +78,7 @@ hn_nvs_execute(struct hn_data *hv,
 
  retry:
 	len = sizeof(buffer);
-	ret = rte_vmbus_chan_recv(chan, buffer, &len, NULL);
+	ret = rte_vmbus_chan_recv(chan, buffer, &len, &xactid);
 	if (ret == -EAGAIN) {
 		rte_delay_us(HN_CHAN_INTERVAL_US);
 		goto retry;
@@ -88,7 +89,20 @@ hn_nvs_execute(struct hn_data *hv,
 		return ret;
 	}
 
+	if (len < sizeof(*hdr)) {
+		PMD_DRV_LOG(ERR, "response missing NVS header");
+		return -EINVAL;
+	}
+
 	hdr = (struct hn_nvs_hdr *)buffer;
+
+	/* Silently drop received packets while waiting for response */
+	if (hdr->type == NVS_TYPE_RNDIS) {
+		hn_nvs_ack_rxbuf(chan, xactid);
+		--hv->rxbuf_outstanding;
+		goto retry;
+	}
+
 	if (hdr->type != type) {
 		PMD_DRV_LOG(ERR, "unexpected NVS resp %#x, expect %#x",
 			    hdr->type, type);
@@ -108,6 +122,29 @@ hn_nvs_execute(struct hn_data *hv,
 	return 0;
 }
 
+
+/*
+ * Execute one control command and get the response.
+ * Only one command can be active on a channel at once
+ * Unlike BSD, DPDK does not have an interrupt context
+ * so the polling is required to wait for response.
+ */
+static int
+hn_nvs_execute(struct hn_data *hv,
+	       void *req, uint32_t reqlen,
+	       void *resp, uint32_t resplen,
+	       uint32_t type)
+{
+	struct hn_rx_queue *rxq = hv->primary;
+	int ret;
+
+	rte_spinlock_lock(&rxq->ring_lock);
+	ret = __hn_nvs_execute(hv, req, reqlen, resp, resplen, type);
+	rte_spinlock_unlock(&rxq->ring_lock);
+
+	return ret;
+}
+
 static int
 hn_nvs_doinit(struct hn_data *hv, uint32_t nvs_ver)
 {
Signature · 1 line
2.20.1
#9 lore raw

PATCH v2 3/4 net/netvsc: split send buffers from transmit descriptors

In reply to Stephen Hemminger

The VMBus has reserved transmit area (per device) and transmit descriptors (per queue). The previous code was always having a 1:1 mapping between send buffers and descriptors. This can lead to one queue starving another and also buffer bloat.

Change to working more like FreeBSD where there is a pool of transmit descriptors per queue. If send buffer is not available then no aggregation happens but the queue can still drain.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_ethdev.c |   9 +-
 drivers/net/netvsc/hn_rxtx.c   | 258 ++++++++++++++++++++-------------
 drivers/net/netvsc/hn_var.h    |  10 +-
 3 files changed, 171 insertions(+), 106 deletions(-)
drivers/net/netvsc/hn_ethdev.c +6 -3
index 564620748daf..ac6610838008 100644
@@ -257,6 +257,9 @@ static int hn_dev_info_get(struct rte_eth_dev *dev,
 	dev_info->max_rx_queues = hv->max_queues;
 	dev_info->max_tx_queues = hv->max_queues;
 
+	dev_info->tx_desc_lim.nb_min = 1;
+	dev_info->tx_desc_lim.nb_max = 4096;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
@@ -982,7 +985,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if  (err)
 		goto failed;
 
-	err = hn_tx_pool_init(eth_dev);
+	err = hn_chim_init(eth_dev);
 	if (err)
 		goto failed;
 
@@ -1018,7 +1021,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 failed:
 	PMD_INIT_LOG(NOTICE, "device init failed");
 
-	hn_tx_pool_uninit(eth_dev);
+	hn_chim_uninit(eth_dev);
 	hn_detach(hv);
 	return err;
 }
@@ -1042,7 +1045,7 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->rx_pkt_burst = NULL;
 
 	hn_detach(hv);
-	hn_tx_pool_uninit(eth_dev);
+	hn_chim_uninit(eth_dev);
 	rte_vmbus_chan_close(hv->primary->chan);
 	rte_free(hv->primary);
 	ret = rte_eth_dev_owner_delete(hv->owner.id);
drivers/net/netvsc/hn_rxtx.c +158 -100

408 lines not on this page · raw message

drivers/net/netvsc/hn_var.h +7 -3
index 05bc492511ec..bd8aeada76ee 100644
@@ -52,6 +52,8 @@ struct hn_tx_queue {
 	uint16_t	port_id;
 	uint16_t	queue_id;
 	uint32_t	free_thresh;
+	struct rte_mempool *txdesc_pool;
+	void 		*tx_rndis;
 
 	/* Applied packet transmission aggregation limits. */
 	uint32_t	agg_szmax;
@@ -115,8 +117,10 @@ struct hn_data {
 	uint16_t	num_queues;
 	uint64_t	rss_offloads;
 
+	rte_spinlock_t	chim_lock;
 	struct rte_mem_resource *chim_res;	/* UIO resource for Tx */
-	struct rte_mempool *tx_pool;		/* Tx descriptors */
+	struct rte_bitmap *chim_bmap;		/* Send buffer map */
+	void		*chim_bmem;
 	uint32_t	chim_szmax;		/* Max size per buffer */
 	uint32_t	chim_cnt;		/* Max packets per buffer */
 
@@ -157,8 +161,8 @@ uint16_t hn_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 uint16_t hn_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		      uint16_t nb_pkts);
 
-int	hn_tx_pool_init(struct rte_eth_dev *dev);
-void	hn_tx_pool_uninit(struct rte_eth_dev *dev);
+int	hn_chim_init(struct rte_eth_dev *dev);
+void	hn_chim_uninit(struct rte_eth_dev *dev);
 int	hn_dev_link_update(struct rte_eth_dev *dev, int wait);
 int	hn_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			      uint16_t nb_desc, unsigned int socket_id,
Signature · 1 line
2.20.1
#10 lore raw

PATCH v2 4/4 net/netvsc: don't enable RSS if only single receive queue

In reply to Stephen Hemminger

If application has multiple transmit queues but only a single receive queue, then do not enable RSS.

Fixes 8b945a7f7dcb ("drivers/net: update Rx RSS hash offload capabilities")
---
 drivers/net/netvsc/hn_ethdev.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/netvsc/hn_ethdev.c +8 -5
index ac6610838008..85f43996a623 100644
@@ -597,11 +597,14 @@ static int hn_dev_configure(struct rte_eth_dev *dev)
 			return err;
 		}
 
-		err = hn_rndis_conf_rss(hv, 0);
-		if (err) {
-			PMD_DRV_LOG(NOTICE,
-				    "initial RSS config failed");
-			return err;
+		if ((dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_RSS_HASH) &&
+		    dev->data->nb_rx_queues > 1) {
+			err = hn_rndis_conf_rss(hv, 0);
+			if (err) {
+				PMD_DRV_LOG(NOTICE,
+					    "initial RSS config failed");
+				return err;
+			}
 		}
 	}
 
Signature · 1 line
2.20.1
#11 lore raw

v3 cover net/netvsc patches

In reply to Stephen Hemminger

These are bug fixes for netvsc PMD mostly related to issues discovered by users of multi-queue.

v3 - fix checkpatch complaints
v2 - simplify the locking on multi-channel setup
add patches to handle single queue and tx descriptor pool

Stephen Hemminger (4):
net/netvsc: propagate descriptor limits from VF to netvsc net/netvsc: handle receive packets during multi-channel setup net/netvsc: split send buffers from transmit descriptors net/netvsc: don't enable RSS if only single receive queue

 drivers/net/netvsc/hn_ethdev.c |  22 ++-
 drivers/net/netvsc/hn_nvs.c    |  41 +++++-
 drivers/net/netvsc/hn_rxtx.c   | 261 ++++++++++++++++++++-------------
 drivers/net/netvsc/hn_var.h    |  10 +-
 drivers/net/netvsc/hn_vf.c     |  13 ++
 5 files changed, 234 insertions(+), 113 deletions(-)
Signature · 1 line
2.20.1
#12 lore raw

PATCH v3 1/4 net/netvsc: propagate descriptor limits from VF to netvsc

If application cares about descriptor limits, the netvsc device values should reflect those of the VF as well.

Fixes dc7680e8597c ("net/netvsc: support integrated VF")
---
 drivers/net/netvsc/hn_vf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/netvsc/hn_vf.c +13 -0
index 7a3734cadfa4..1261b2e2ef85 100644
@@ -167,6 +167,17 @@ hn_nvs_handle_vfassoc(struct rte_eth_dev *dev,
 		hn_vf_remove(hv);
 }
 
+static void
+hn_vf_merge_desc_lim(struct rte_eth_desc_lim *lim,
+		     const struct rte_eth_desc_lim *vf_lim)
+{
+	lim->nb_max = RTE_MIN(vf_lim->nb_max, lim->nb_max);
+	lim->nb_min = RTE_MAX(vf_lim->nb_min, lim->nb_min);
+	lim->nb_align = RTE_MAX(vf_lim->nb_align, lim->nb_align);
+	lim->nb_seg_max = RTE_MIN(vf_lim->nb_seg_max, lim->nb_seg_max);
+	lim->nb_mtu_seg_max = RTE_MIN(vf_lim->nb_seg_max, lim->nb_seg_max);
+}
+
 /*
  * Merge the info from the VF and synthetic path.
  * use the default config of the VF
@@ -196,11 +207,13 @@ static int hn_vf_info_merge(struct rte_eth_dev *vf_dev,
 				      info->max_tx_queues);
 	info->tx_offload_capa &= vf_info.tx_offload_capa;
 	info->tx_queue_offload_capa &= vf_info.tx_queue_offload_capa;
+	hn_vf_merge_desc_lim(&info->tx_desc_lim, &vf_info.tx_desc_lim);
 
 	info->min_rx_bufsize = RTE_MAX(vf_info.min_rx_bufsize,
 				       info->min_rx_bufsize);
 	info->max_rx_pktlen  = RTE_MAX(vf_info.max_rx_pktlen,
 				       info->max_rx_pktlen);
+	hn_vf_merge_desc_lim(&info->rx_desc_lim, &vf_info.rx_desc_lim);
 
 	return 0;
 }
Signature · 1 line
2.20.1
#13 lore raw

PATCH v3 2/4 net/netvsc: handle receive packets during multi-channel setup

In reply to Stephen Hemminger

It is possible for a packet to arrive during the configuration process when setting up multiple queue mode. This would cause configure to fail; fix by just ignoring receive packets while waiting for control commands.

Use the receive ring lock to avoid possible races between oddly behaved applications doing rx_burst and control operations concurrently.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_nvs.c | 41 +++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_nvs.c +39 -2
index 6b518685ab6f..477202b2a0b7 100644
@@ -54,7 +54,7 @@ static int hn_nvs_req_send(struct hn_data *hv,
 }
 
 static int
-hn_nvs_execute(struct hn_data *hv,
+__hn_nvs_execute(struct hn_data *hv,
 	       void *req, uint32_t reqlen,
 	       void *resp, uint32_t resplen,
 	       uint32_t type)
@@ -62,6 +62,7 @@ hn_nvs_execute(struct hn_data *hv,
 	struct vmbus_channel *chan = hn_primary_chan(hv);
 	char buffer[NVS_RESPSIZE_MAX];
 	const struct hn_nvs_hdr *hdr;
+	uint64_t xactid;
 	uint32_t len;
 	int ret;
 
@@ -77,7 +78,7 @@ hn_nvs_execute(struct hn_data *hv,
 
  retry:
 	len = sizeof(buffer);
-	ret = rte_vmbus_chan_recv(chan, buffer, &len, NULL);
+	ret = rte_vmbus_chan_recv(chan, buffer, &len, &xactid);
 	if (ret == -EAGAIN) {
 		rte_delay_us(HN_CHAN_INTERVAL_US);
 		goto retry;
@@ -88,7 +89,20 @@ hn_nvs_execute(struct hn_data *hv,
 		return ret;
 	}
 
+	if (len < sizeof(*hdr)) {
+		PMD_DRV_LOG(ERR, "response missing NVS header");
+		return -EINVAL;
+	}
+
 	hdr = (struct hn_nvs_hdr *)buffer;
+
+	/* Silently drop received packets while waiting for response */
+	if (hdr->type == NVS_TYPE_RNDIS) {
+		hn_nvs_ack_rxbuf(chan, xactid);
+		--hv->rxbuf_outstanding;
+		goto retry;
+	}
+
 	if (hdr->type != type) {
 		PMD_DRV_LOG(ERR, "unexpected NVS resp %#x, expect %#x",
 			    hdr->type, type);
@@ -108,6 +122,29 @@ hn_nvs_execute(struct hn_data *hv,
 	return 0;
 }
 
+
+/*
+ * Execute one control command and get the response.
+ * Only one command can be active on a channel at once
+ * Unlike BSD, DPDK does not have an interrupt context
+ * so the polling is required to wait for response.
+ */
+static int
+hn_nvs_execute(struct hn_data *hv,
+	       void *req, uint32_t reqlen,
+	       void *resp, uint32_t resplen,
+	       uint32_t type)
+{
+	struct hn_rx_queue *rxq = hv->primary;
+	int ret;
+
+	rte_spinlock_lock(&rxq->ring_lock);
+	ret = __hn_nvs_execute(hv, req, reqlen, resp, resplen, type);
+	rte_spinlock_unlock(&rxq->ring_lock);
+
+	return ret;
+}
+
 static int
 hn_nvs_doinit(struct hn_data *hv, uint32_t nvs_ver)
 {
Signature · 1 line
2.20.1
#14 lore raw

PATCH v3 3/4 net/netvsc: split send buffers from transmit descriptors

In reply to Stephen Hemminger

The VMBus has reserved transmit area (per device) and transmit descriptors (per queue). The previous code was always having a 1:1 mapping between send buffers and descriptors. This can lead to one queue starving another and also buffer bloat.

Change to working more like FreeBSD where there is a pool of transmit descriptors per queue. If send buffer is not available then no aggregation happens but the queue can still drain.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_ethdev.c |   9 +-
 drivers/net/netvsc/hn_rxtx.c   | 261 ++++++++++++++++++++-------------
 drivers/net/netvsc/hn_var.h    |  10 +-
 3 files changed, 174 insertions(+), 106 deletions(-)
drivers/net/netvsc/hn_ethdev.c +6 -3
index 564620748daf..ac6610838008 100644
@@ -257,6 +257,9 @@ static int hn_dev_info_get(struct rte_eth_dev *dev,
 	dev_info->max_rx_queues = hv->max_queues;
 	dev_info->max_tx_queues = hv->max_queues;
 
+	dev_info->tx_desc_lim.nb_min = 1;
+	dev_info->tx_desc_lim.nb_max = 4096;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
@@ -982,7 +985,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if  (err)
 		goto failed;
 
-	err = hn_tx_pool_init(eth_dev);
+	err = hn_chim_init(eth_dev);
 	if (err)
 		goto failed;
 
@@ -1018,7 +1021,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 failed:
 	PMD_INIT_LOG(NOTICE, "device init failed");
 
-	hn_tx_pool_uninit(eth_dev);
+	hn_chim_uninit(eth_dev);
 	hn_detach(hv);
 	return err;
 }
@@ -1042,7 +1045,7 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->rx_pkt_burst = NULL;
 
 	hn_detach(hv);
-	hn_tx_pool_uninit(eth_dev);
+	hn_chim_uninit(eth_dev);
 	rte_vmbus_chan_close(hv->primary->chan);
 	rte_free(hv->primary);
 	ret = rte_eth_dev_owner_delete(hv->owner.id);
drivers/net/netvsc/hn_rxtx.c +161 -100

411 lines not on this page · raw message

drivers/net/netvsc/hn_var.h +7 -3
index 05bc492511ec..822d737bd3cc 100644
@@ -52,6 +52,8 @@ struct hn_tx_queue {
 	uint16_t	port_id;
 	uint16_t	queue_id;
 	uint32_t	free_thresh;
+	struct rte_mempool *txdesc_pool;
+	void		*tx_rndis;
 
 	/* Applied packet transmission aggregation limits. */
 	uint32_t	agg_szmax;
@@ -115,8 +117,10 @@ struct hn_data {
 	uint16_t	num_queues;
 	uint64_t	rss_offloads;
 
+	rte_spinlock_t	chim_lock;
 	struct rte_mem_resource *chim_res;	/* UIO resource for Tx */
-	struct rte_mempool *tx_pool;		/* Tx descriptors */
+	struct rte_bitmap *chim_bmap;		/* Send buffer map */
+	void		*chim_bmem;
 	uint32_t	chim_szmax;		/* Max size per buffer */
 	uint32_t	chim_cnt;		/* Max packets per buffer */
 
@@ -157,8 +161,8 @@ uint16_t hn_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 uint16_t hn_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		      uint16_t nb_pkts);
 
-int	hn_tx_pool_init(struct rte_eth_dev *dev);
-void	hn_tx_pool_uninit(struct rte_eth_dev *dev);
+int	hn_chim_init(struct rte_eth_dev *dev);
+void	hn_chim_uninit(struct rte_eth_dev *dev);
 int	hn_dev_link_update(struct rte_eth_dev *dev, int wait);
 int	hn_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			      uint16_t nb_desc, unsigned int socket_id,
Signature · 1 line
2.20.1
#15 lore raw

PATCH v3 4/4 net/netvsc: don't enable RSS if only single receive queue

In reply to Stephen Hemminger

If application has multiple transmit queues but only a single receive queue, then do not enable RSS.

Fixes 8b945a7f7dcb ("drivers/net: update Rx RSS hash offload capabilities")
---
 drivers/net/netvsc/hn_ethdev.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/netvsc/hn_ethdev.c +8 -5
index ac6610838008..85f43996a623 100644
@@ -597,11 +597,14 @@ static int hn_dev_configure(struct rte_eth_dev *dev)
 			return err;
 		}
 
-		err = hn_rndis_conf_rss(hv, 0);
-		if (err) {
-			PMD_DRV_LOG(NOTICE,
-				    "initial RSS config failed");
-			return err;
+		if ((dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_RSS_HASH) &&
+		    dev->data->nb_rx_queues > 1) {
+			err = hn_rndis_conf_rss(hv, 0);
+			if (err) {
+				PMD_DRV_LOG(NOTICE,
+					    "initial RSS config failed");
+				return err;
+			}
 		}
 	}
 
Signature · 1 line
2.20.1
#16 lore raw

v4 cover net/netvsc: bug fixes

In reply to Stephen Hemminger

These are bug fixes for netvsc PMD mostly related to issues in the transmit ring discovered by users of multi-queue.

v4 - add more bug fixes
v3 - fix checkpatch complaints
v2 - simplify the locking on multi-channel setup

Stephen Hemminger (8):
net/netvsc: propagate descriptor limits from VF to netvsc net/netvsc: handle receive packets during multi-channel setup net/netvsc: split send buffers from transmit descriptors net/netvsc: fix invalid rte_free on dev_close net/netvsc: remove process event optimization net/netvsc: handle transmit completions based on burst size bus/vmbus: simplify args to need_signal
net/netvsc: avoid possible live lock

 drivers/bus/vmbus/vmbus_bufring.c |   8 +-
 drivers/net/netvsc/hn_ethdev.c    |  25 ++-
 drivers/net/netvsc/hn_nvs.c       |  41 ++++-
 drivers/net/netvsc/hn_rxtx.c      | 281 ++++++++++++++++++------------
 drivers/net/netvsc/hn_var.h       |  12 +-
 drivers/net/netvsc/hn_vf.c        |  13 ++
 6 files changed, 248 insertions(+), 132 deletions(-)
Signature · 1 line
2.20.1
#17 lore raw

PATCH v4 1/8 net/netvsc: propagate descriptor limits from VF to netvsc

If application cares about descriptor limits, the netvsc device values should reflect those of the VF as well.

Fixes dc7680e8597c ("net/netvsc: support integrated VF")
---
 drivers/net/netvsc/hn_vf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/netvsc/hn_vf.c +13 -0
index 7a3734cadfa4..1261b2e2ef85 100644
@@ -167,6 +167,17 @@ hn_nvs_handle_vfassoc(struct rte_eth_dev *dev,
 		hn_vf_remove(hv);
 }
 
+static void
+hn_vf_merge_desc_lim(struct rte_eth_desc_lim *lim,
+		     const struct rte_eth_desc_lim *vf_lim)
+{
+	lim->nb_max = RTE_MIN(vf_lim->nb_max, lim->nb_max);
+	lim->nb_min = RTE_MAX(vf_lim->nb_min, lim->nb_min);
+	lim->nb_align = RTE_MAX(vf_lim->nb_align, lim->nb_align);
+	lim->nb_seg_max = RTE_MIN(vf_lim->nb_seg_max, lim->nb_seg_max);
+	lim->nb_mtu_seg_max = RTE_MIN(vf_lim->nb_seg_max, lim->nb_seg_max);
+}
+
 /*
  * Merge the info from the VF and synthetic path.
  * use the default config of the VF
@@ -196,11 +207,13 @@ static int hn_vf_info_merge(struct rte_eth_dev *vf_dev,
 				      info->max_tx_queues);
 	info->tx_offload_capa &= vf_info.tx_offload_capa;
 	info->tx_queue_offload_capa &= vf_info.tx_queue_offload_capa;
+	hn_vf_merge_desc_lim(&info->tx_desc_lim, &vf_info.tx_desc_lim);
 
 	info->min_rx_bufsize = RTE_MAX(vf_info.min_rx_bufsize,
 				       info->min_rx_bufsize);
 	info->max_rx_pktlen  = RTE_MAX(vf_info.max_rx_pktlen,
 				       info->max_rx_pktlen);
+	hn_vf_merge_desc_lim(&info->rx_desc_lim, &vf_info.rx_desc_lim);
 
 	return 0;
 }
Signature · 1 line
2.20.1
#18 lore raw

PATCH v4 2/8 net/netvsc: handle receive packets during multi-channel setup

In reply to Stephen Hemminger

It is possible for a packet to arrive during the configuration process when setting up multiple queue mode. This would cause configure to fail; fix by just ignoring receive packets while waiting for control commands.

Use the receive ring lock to avoid possible races between oddly behaved applications doing rx_burst and control operations concurrently.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_nvs.c | 41 +++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_nvs.c +39 -2
index 6b518685ab6f..477202b2a0b7 100644
@@ -54,7 +54,7 @@ static int hn_nvs_req_send(struct hn_data *hv,
 }
 
 static int
-hn_nvs_execute(struct hn_data *hv,
+__hn_nvs_execute(struct hn_data *hv,
 	       void *req, uint32_t reqlen,
 	       void *resp, uint32_t resplen,
 	       uint32_t type)
@@ -62,6 +62,7 @@ hn_nvs_execute(struct hn_data *hv,
 	struct vmbus_channel *chan = hn_primary_chan(hv);
 	char buffer[NVS_RESPSIZE_MAX];
 	const struct hn_nvs_hdr *hdr;
+	uint64_t xactid;
 	uint32_t len;
 	int ret;
 
@@ -77,7 +78,7 @@ hn_nvs_execute(struct hn_data *hv,
 
  retry:
 	len = sizeof(buffer);
-	ret = rte_vmbus_chan_recv(chan, buffer, &len, NULL);
+	ret = rte_vmbus_chan_recv(chan, buffer, &len, &xactid);
 	if (ret == -EAGAIN) {
 		rte_delay_us(HN_CHAN_INTERVAL_US);
 		goto retry;
@@ -88,7 +89,20 @@ hn_nvs_execute(struct hn_data *hv,
 		return ret;
 	}
 
+	if (len < sizeof(*hdr)) {
+		PMD_DRV_LOG(ERR, "response missing NVS header");
+		return -EINVAL;
+	}
+
 	hdr = (struct hn_nvs_hdr *)buffer;
+
+	/* Silently drop received packets while waiting for response */
+	if (hdr->type == NVS_TYPE_RNDIS) {
+		hn_nvs_ack_rxbuf(chan, xactid);
+		--hv->rxbuf_outstanding;
+		goto retry;
+	}
+
 	if (hdr->type != type) {
 		PMD_DRV_LOG(ERR, "unexpected NVS resp %#x, expect %#x",
 			    hdr->type, type);
@@ -108,6 +122,29 @@ hn_nvs_execute(struct hn_data *hv,
 	return 0;
 }
 
+
+/*
+ * Execute one control command and get the response.
+ * Only one command can be active on a channel at once
+ * Unlike BSD, DPDK does not have an interrupt context
+ * so the polling is required to wait for response.
+ */
+static int
+hn_nvs_execute(struct hn_data *hv,
+	       void *req, uint32_t reqlen,
+	       void *resp, uint32_t resplen,
+	       uint32_t type)
+{
+	struct hn_rx_queue *rxq = hv->primary;
+	int ret;
+
+	rte_spinlock_lock(&rxq->ring_lock);
+	ret = __hn_nvs_execute(hv, req, reqlen, resp, resplen, type);
+	rte_spinlock_unlock(&rxq->ring_lock);
+
+	return ret;
+}
+
 static int
 hn_nvs_doinit(struct hn_data *hv, uint32_t nvs_ver)
 {
Signature · 1 line
2.20.1
#19 lore raw

PATCH v4 3/8 net/netvsc: split send buffers from transmit descriptors

In reply to Stephen Hemminger

The VMBus has reserved transmit area (per device) and transmit descriptors (per queue). The previous code was always having a 1:1 mapping between send buffers and descriptors. This can lead to one queue starving another and also buffer bloat.

Change to working more like FreeBSD where there is a pool of transmit descriptors per queue. If send buffer is not available then no aggregation happens but the queue can still drain.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_ethdev.c |   9 +-
 drivers/net/netvsc/hn_rxtx.c   | 271 ++++++++++++++++++++-------------
 drivers/net/netvsc/hn_var.h    |  10 +-
 3 files changed, 180 insertions(+), 110 deletions(-)
drivers/net/netvsc/hn_ethdev.c +6 -3
index 564620748daf..ac6610838008 100644
@@ -257,6 +257,9 @@ static int hn_dev_info_get(struct rte_eth_dev *dev,
 	dev_info->max_rx_queues = hv->max_queues;
 	dev_info->max_tx_queues = hv->max_queues;
 
+	dev_info->tx_desc_lim.nb_min = 1;
+	dev_info->tx_desc_lim.nb_max = 4096;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
@@ -982,7 +985,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if  (err)
 		goto failed;
 
-	err = hn_tx_pool_init(eth_dev);
+	err = hn_chim_init(eth_dev);
 	if (err)
 		goto failed;
 
@@ -1018,7 +1021,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 failed:
 	PMD_INIT_LOG(NOTICE, "device init failed");
 
-	hn_tx_pool_uninit(eth_dev);
+	hn_chim_uninit(eth_dev);
 	hn_detach(hv);
 	return err;
 }
@@ -1042,7 +1045,7 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->rx_pkt_burst = NULL;
 
 	hn_detach(hv);
-	hn_tx_pool_uninit(eth_dev);
+	hn_chim_uninit(eth_dev);
 	rte_vmbus_chan_close(hv->primary->chan);
 	rte_free(hv->primary);
 	ret = rte_eth_dev_owner_delete(hv->owner.id);
drivers/net/netvsc/hn_rxtx.c +167 -104

430 lines not on this page · raw message

drivers/net/netvsc/hn_var.h +7 -3
index 05bc492511ec..822d737bd3cc 100644
@@ -52,6 +52,8 @@ struct hn_tx_queue {
 	uint16_t	port_id;
 	uint16_t	queue_id;
 	uint32_t	free_thresh;
+	struct rte_mempool *txdesc_pool;
+	void		*tx_rndis;
 
 	/* Applied packet transmission aggregation limits. */
 	uint32_t	agg_szmax;
@@ -115,8 +117,10 @@ struct hn_data {
 	uint16_t	num_queues;
 	uint64_t	rss_offloads;
 
+	rte_spinlock_t	chim_lock;
 	struct rte_mem_resource *chim_res;	/* UIO resource for Tx */
-	struct rte_mempool *tx_pool;		/* Tx descriptors */
+	struct rte_bitmap *chim_bmap;		/* Send buffer map */
+	void		*chim_bmem;
 	uint32_t	chim_szmax;		/* Max size per buffer */
 	uint32_t	chim_cnt;		/* Max packets per buffer */
 
@@ -157,8 +161,8 @@ uint16_t hn_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 uint16_t hn_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		      uint16_t nb_pkts);
 
-int	hn_tx_pool_init(struct rte_eth_dev *dev);
-void	hn_tx_pool_uninit(struct rte_eth_dev *dev);
+int	hn_chim_init(struct rte_eth_dev *dev);
+void	hn_chim_uninit(struct rte_eth_dev *dev);
 int	hn_dev_link_update(struct rte_eth_dev *dev, int wait);
 int	hn_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			      uint16_t nb_desc, unsigned int socket_id,
Signature · 1 line
2.20.1
#20 lore raw

PATCH v4 4/8 net/netvsc: fix invalid rte_free on dev_close

In reply to Stephen Hemminger

The netvsc PMD was putting the mac address in private data but the core rte_ethdev doesn't allow that it. It has to be in rte_malloc'd memory or the a message will be printed on shutdown/close.
EAL: Invalid memory

Fixes f8279f47dd89 ("net/netvsc: fix crash in secondary process")
---
 drivers/net/netvsc/hn_ethdev.c | 16 ++++++++++------
 drivers/net/netvsc/hn_var.h    |  2 --
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/net/netvsc/hn_ethdev.c +10 -6
index ac6610838008..05f1a25a1abc 100644
@@ -134,8 +134,6 @@ eth_dev_vmbus_allocate(struct rte_vmbus_device *dev, size_t private_data_size)
 static void
 eth_dev_vmbus_release(struct rte_eth_dev *eth_dev)
 {
-	/* mac_addrs must not be freed alone because part of dev_private */
-	eth_dev->data->mac_addrs = NULL;
 	/* free ether device */
 	rte_eth_dev_release_port(eth_dev);
 
@@ -937,9 +935,6 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &hn_xmit_pkts;
 	eth_dev->rx_pkt_burst = &hn_recv_pkts;
 
-	/* Since Hyper-V only supports one MAC address, just use local data */
-	eth_dev->data->mac_addrs = &hv->mac_addr;
-
 	/*
 	 * for secondary processes, we don't initialize any further as primary
 	 * has already done this work.
@@ -947,6 +942,15 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	/* Since Hyper-V only supports one MAC address */
+	eth_dev->data->mac_addrs = rte_calloc("hv_mac", HN_MAX_MAC_ADDRS,
+					      sizeof(struct rte_ether_addr), 0);
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR,
+			     "Failed to allocate memory store MAC addresses");
+		return -ENOMEM;
+	}
+
 	hv->vmbus = vmbus;
 	hv->rxbuf_res = &vmbus->resource[HV_RECV_BUF_MAP];
 	hv->chim_res  = &vmbus->resource[HV_SEND_BUF_MAP];
@@ -989,7 +993,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if (err)
 		goto failed;
 
-	err = hn_rndis_get_eaddr(hv, hv->mac_addr.addr_bytes);
+	err = hn_rndis_get_eaddr(hv, eth_dev->data->mac_addrs->addr_bytes);
 	if (err)
 		goto failed;
 
drivers/net/netvsc/hn_var.h +0 -2
index 822d737bd3cc..b4c61717379f 100644
@@ -139,8 +139,6 @@ struct hn_data {
 	uint8_t		rss_key[40];
 	uint16_t	rss_ind[128];
 
-	struct rte_ether_addr mac_addr;
-
 	struct rte_eth_dev_owner owner;
 	struct rte_intr_handle vf_intr;
 
Signature · 1 line
2.20.1
#21 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v4 4/8] net/netvsc: fix invalid rte_free on dev_close

Quoted 3 lines · Stephen Hemminger

The netvsc PMD was putting the mac address in private data but the core rte_ethdev doesn't allow that it. It has to be in rte_malloc'd memory or the a message will be printed on shutdown/close.

It doesn't have to be rte_malloc'ed. Setting 'eth_dev->data->mac_addrs' to null in 'hn_dev_close()' should fix it.

But dynamically allocating it also works if that is what preferred.

Quoted 72 lines

EAL: Invalid memory

Fixes f8279f47dd89 ("net/netvsc: fix crash in secondary process")
---
 drivers/net/netvsc/hn_ethdev.c | 16 ++++++++++------
 drivers/net/netvsc/hn_var.h    |  2 --
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/net/netvsc/hn_ethdev.c +10 -6
index ac6610838008..05f1a25a1abc 100644
@@ -134,8 +134,6 @@ eth_dev_vmbus_allocate(struct rte_vmbus_device *dev, size_t private_data_size)
 static void
 eth_dev_vmbus_release(struct rte_eth_dev *eth_dev)
 {
-	/* mac_addrs must not be freed alone because part of dev_private */
-	eth_dev->data->mac_addrs = NULL;
 	/* free ether device */
 	rte_eth_dev_release_port(eth_dev);
 
@@ -937,9 +935,6 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &hn_xmit_pkts;
 	eth_dev->rx_pkt_burst = &hn_recv_pkts;
 
-	/* Since Hyper-V only supports one MAC address, just use local data */
-	eth_dev->data->mac_addrs = &hv->mac_addr;
-
 	/*
 	 * for secondary processes, we don't initialize any further as primary
 	 * has already done this work.
@@ -947,6 +942,15 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	/* Since Hyper-V only supports one MAC address */
+	eth_dev->data->mac_addrs = rte_calloc("hv_mac", HN_MAX_MAC_ADDRS,
+					      sizeof(struct rte_ether_addr), 0);
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR,
+			     "Failed to allocate memory store MAC addresses");
+		return -ENOMEM;
+	}
+
 	hv->vmbus = vmbus;
 	hv->rxbuf_res = &vmbus->resource[HV_RECV_BUF_MAP];
 	hv->chim_res  = &vmbus->resource[HV_SEND_BUF_MAP];
@@ -989,7 +993,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	if (err)
 		goto failed;
 
-	err = hn_rndis_get_eaddr(hv, hv->mac_addr.addr_bytes);
+	err = hn_rndis_get_eaddr(hv, eth_dev->data->mac_addrs->addr_bytes);
 	if (err)
 		goto failed;
 
drivers/net/netvsc/hn_var.h +0 -2
index 822d737bd3cc..b4c61717379f 100644
@@ -139,8 +139,6 @@ struct hn_data {
 	uint8_t		rss_key[40];
 	uint16_t	rss_ind[128];
 
-	struct rte_ether_addr mac_addr;
-
 	struct rte_eth_dev_owner owner;
 	struct rte_intr_handle vf_intr;
 
#22 lore raw

PATCH v4 5/8 net/netvsc: remove process event optimization

In reply to Stephen Hemminger

Remove unlocked check for data in receive ring. This check is not safe because of missing barriers etc.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_rxtx.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/net/netvsc/hn_rxtx.c +0 -4
index 32c03e3da0c7..e8df84604202 100644
@@ -969,10 +969,6 @@ uint32_t hn_process_events(struct hn_data *hv, uint16_t queue_id,
 
 	rxq = queue_id == 0 ? hv->primary : dev->data->rx_queues[queue_id];
 
-	/* If no pending data then nothing to do */
-	if (rte_vmbus_chan_rx_empty(rxq->chan))
-		return 0;
-
 	/*
 	 * Since channel is shared between Rx and TX queue need to have a lock
 	 * since DPDK does not force same CPU to be used for Rx/Tx.
Signature · 1 line
2.20.1
#23 lore raw

PATCH v4 6/8 net/netvsc: handle transmit completions based on burst size

In reply to Stephen Hemminger

If tx_free_thresh is quite low, it is possible that we need to cleanup based on burst size.

Fixes fc30efe3a22e ("net/netvsc: change Rx descriptor setup and sizing")
---
 drivers/net/netvsc/hn_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_rxtx.c +3 -2
index e8df84604202..cbdfcc628b75 100644
@@ -1375,7 +1375,7 @@ hn_xmit_pkts(void *ptxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct hn_data *hv = txq->hv;
 	struct rte_eth_dev *vf_dev;
 	bool need_sig = false;
-	uint16_t nb_tx;
+	uint16_t nb_tx, avail;
 	int ret;
 
 	if (unlikely(hv->closed))
@@ -1390,7 +1390,8 @@ hn_xmit_pkts(void *ptxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		return (*vf_dev->tx_pkt_burst)(sub_q, tx_pkts, nb_pkts);
 	}
 
-	if (rte_mempool_avail_count(txq->txdesc_pool) <= txq->free_thresh)
+	avail = rte_mempool_avail_count(txq->txdesc_pool);
+	if (nb_pkts > avail || avail <= txq->free_thresh)
 		hn_process_events(hv, txq->queue_id, 0);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
Signature · 1 line
2.20.1
#24 lore raw

PATCH v4 7/8 bus/vmbus: simplify args to need_signal

In reply to Stephen Hemminger

The transmit need signal function can avoid an unnecessary dereference by passing the right pointer. This also makes code better match FreeBSD driver.

---
 drivers/bus/vmbus/vmbus_bufring.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/bus/vmbus/vmbus_bufring.c +4 -4
index c88001605dbb..c4aa07b307ff 100644
@@ -54,10 +54,10 @@ void vmbus_br_setup(struct vmbus_br *br, void *buf, unsigned int blen)
  *   data have arrived.
  */
 static inline bool
-vmbus_txbr_need_signal(const struct vmbus_br *tbr, uint32_t old_windex)
+vmbus_txbr_need_signal(const struct vmbus_bufring *vbr, uint32_t old_windex)
 {
 	rte_smp_mb();
-	if (tbr->vbr->imask)
+	if (vbr->imask)
 		return false;
 
 	rte_smp_rmb();
@@ -66,7 +66,7 @@ vmbus_txbr_need_signal(const struct vmbus_br *tbr, uint32_t old_windex)
 	 * This is the only case we need to signal when the
 	 * ring transitions from being empty to non-empty.
 	 */
-	return old_windex == tbr->vbr->rindex;
+	return old_windex == vbr->rindex;
 }
 
 static inline uint32_t
@@ -163,7 +163,7 @@ vmbus_txbr_write(struct vmbus_br *tbr, const struct iovec iov[], int iovlen,
 		rte_pause();
 
 	/* If host had read all data before this, then need to signal */
-	*need_sig |= vmbus_txbr_need_signal(tbr, old_windex);
+	*need_sig |= vmbus_txbr_need_signal(vbr, old_windex);
 	return 0;
 }
 
Signature · 1 line
2.20.1
#25 lore raw

PATCH v4 8/8 net/netvsc: avoid possible live lock

In reply to Stephen Hemminger

Since the ring buffer with host is shared for both transmit completions and receive packets, it is possible that transmitter could get starved if receive ring gets full.

Better to process all outstanding events which frees up transmit buffer slots, even if means dropping some packets.

Fixes 7e6c82430702 ("net/netvsc: avoid over filling Rx descriptor ring")
---
 drivers/net/netvsc/hn_rxtx.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/netvsc/hn_rxtx.c +0 -3
index cbdfcc628b75..19f00a05285f 100644
@@ -1032,9 +1032,6 @@ uint32_t hn_process_events(struct hn_data *hv, uint16_t queue_id,
 
 		if (tx_limit && tx_done >= tx_limit)
 			break;
-
-		if (rxq->rx_ring && rte_ring_full(rxq->rx_ring))
-			break;
 	}
 
 	if (bytes_read > 0)
Signature · 1 line
2.20.1
#26 lore raw

Re: [dpdk-dev] [PATCH v4 0/8] net/netvsc: bug fixes

In reply to Stephen Hemminger
Quoted 7 lines · Stephen Hemminger

These are bug fixes for netvsc PMD mostly related to issues in the transmit ring discovered by users of multi-queue.

v4 - add more bug fixes
v3 - fix checkpatch complaints
v2 - simplify the locking on multi-channel setup

Quoted 9 lines

Stephen Hemminger (8):
net/netvsc: propagate descriptor limits from VF to netvsc net/netvsc: handle receive packets during multi-channel setup net/netvsc: split send buffers from transmit descriptors net/netvsc: fix invalid rte_free on dev_close net/netvsc: remove process event optimization net/netvsc: handle transmit completions based on burst size bus/vmbus: simplify args to need_signal
net/netvsc: avoid possible live lock

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