From: Tiwei Bie <tiwei.bie@intel.com>
To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH 09/10] net/virtio: add ctrl vq helper for split ring
Date: Tue, 19 Mar 2019 14:43:11 +0800 [thread overview]
Message-ID: <20190319064312.13743-10-tiwei.bie@intel.com> (raw)
Message-ID: <20190319064311.UElKh4eX_xuRKwlvtGGroXYf6p_nOoSPfesP3JSqIX0@z> (raw)
In-Reply-To: <20190319064312.13743-1-tiwei.bie@intel.com>
Add a helper for sending commands in split ring to make the
code consistent with the corresponding code in packed ring.
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 76 +++++++++++++++++-------------
1 file changed, 43 insertions(+), 33 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 8aa250997..85b223451 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -237,44 +237,18 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,
return result;
}
-static int
-virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl,
- int *dlen, int pkt_num)
+static struct virtio_pmd_ctrl *
+virtio_send_command_split(struct virtnet_ctl *cvq,
+ struct virtio_pmd_ctrl *ctrl,
+ int *dlen, int pkt_num)
{
+ struct virtio_pmd_ctrl *result;
+ struct virtqueue *vq = cvq->vq;
uint32_t head, i;
int k, sum = 0;
- virtio_net_ctrl_ack status = ~0;
- struct virtio_pmd_ctrl *result;
- struct virtqueue *vq;
- ctrl->status = status;
-
- if (!cvq || !cvq->vq) {
- PMD_INIT_LOG(ERR, "Control queue is not supported.");
- return -1;
- }
-
- rte_spinlock_lock(&cvq->lock);
- vq = cvq->vq;
head = vq->vq_desc_head_idx;
- PMD_INIT_LOG(DEBUG, "vq->vq_desc_head_idx = %d, status = %d, "
- "vq->hw->cvq = %p vq = %p",
- vq->vq_desc_head_idx, status, vq->hw->cvq, vq);
-
- if (vq->vq_free_cnt < pkt_num + 2 || pkt_num < 1) {
- rte_spinlock_unlock(&cvq->lock);
- return -1;
- }
-
- memcpy(cvq->virtio_net_hdr_mz->addr, ctrl,
- sizeof(struct virtio_pmd_ctrl));
-
- if (vtpci_packed_queue(vq->hw)) {
- result = virtio_send_command_packed(cvq, ctrl, dlen, pkt_num);
- goto out_unlock;
- }
-
/*
* Format is enforced in qemu code:
* One TX packet for header;
@@ -346,8 +320,44 @@ virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl,
vq->vq_free_cnt, vq->vq_desc_head_idx);
result = cvq->virtio_net_hdr_mz->addr;
+ return result;
+}
+
+static int
+virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl,
+ int *dlen, int pkt_num)
+{
+ virtio_net_ctrl_ack status = ~0;
+ struct virtio_pmd_ctrl *result;
+ struct virtqueue *vq;
+
+ ctrl->status = status;
+
+ if (!cvq || !cvq->vq) {
+ PMD_INIT_LOG(ERR, "Control queue is not supported.");
+ return -1;
+ }
+
+ rte_spinlock_lock(&cvq->lock);
+ vq = cvq->vq;
+
+ PMD_INIT_LOG(DEBUG, "vq->vq_desc_head_idx = %d, status = %d, "
+ "vq->hw->cvq = %p vq = %p",
+ vq->vq_desc_head_idx, status, vq->hw->cvq, vq);
+
+ if (vq->vq_free_cnt < pkt_num + 2 || pkt_num < 1) {
+ rte_spinlock_unlock(&cvq->lock);
+ return -1;
+ }
+
+ memcpy(cvq->virtio_net_hdr_mz->addr, ctrl,
+ sizeof(struct virtio_pmd_ctrl));
+
+ if (vtpci_packed_queue(vq->hw))
+ result = virtio_send_command_packed(cvq, ctrl, dlen, pkt_num);
+ else
+ result = virtio_send_command_split(cvq, ctrl, dlen, pkt_num);
-out_unlock:
rte_spinlock_unlock(&cvq->lock);
return result->status;
}
--
2.17.1
next prev parent reply other threads:[~2019-03-19 6:45 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 6:43 [dpdk-dev] [PATCH 00/10] net/virtio: cleanups and fixes for packed/split ring Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 6:43 ` [dpdk-dev] [PATCH 01/10] net/virtio: fix typo in packed ring init Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 8:39 ` Jens Freimann
2019-03-19 8:39 ` Jens Freimann
2019-03-19 12:46 ` Maxime Coquelin
2019-03-19 12:46 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 02/10] net/virtio: fix interrupt helper for packed ring Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 12:48 ` Maxime Coquelin
2019-03-19 12:48 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 03/10] net/virtio: add missing barrier in interrupt enable Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 12:49 ` Maxime Coquelin
2019-03-19 12:49 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 04/10] net/virtio: optimize flags update for packed ring Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 8:54 ` Jens Freimann
2019-03-19 8:54 ` Jens Freimann
2019-03-19 9:37 ` Tiwei Bie
2019-03-19 9:37 ` Tiwei Bie
2019-03-19 10:11 ` Jens Freimann
2019-03-19 10:11 ` Jens Freimann
2019-03-19 12:50 ` Maxime Coquelin
2019-03-19 12:50 ` Maxime Coquelin
2019-03-19 12:58 ` Maxime Coquelin
2019-03-19 12:58 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 05/10] net/virtio: refactor virtqueue structure Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 9:44 ` Jens Freimann
2019-03-19 9:44 ` Jens Freimann
2019-03-19 10:09 ` Tiwei Bie
2019-03-19 10:09 ` Tiwei Bie
2019-03-19 13:28 ` Maxime Coquelin
2019-03-19 13:28 ` Maxime Coquelin
2019-03-19 13:47 ` Jens Freimann
2019-03-19 13:47 ` Jens Freimann
2019-03-19 13:50 ` Maxime Coquelin
2019-03-19 13:50 ` Maxime Coquelin
2019-03-19 14:59 ` Kevin Traynor
2019-03-19 14:59 ` Kevin Traynor
2019-03-20 4:40 ` Tiwei Bie
2019-03-20 4:40 ` Tiwei Bie
2019-03-20 17:50 ` Stephen Hemminger
2019-03-20 17:50 ` Stephen Hemminger
2019-03-21 14:18 ` Maxime Coquelin
2019-03-21 14:18 ` Maxime Coquelin
2019-03-20 4:35 ` Tiwei Bie
2019-03-20 4:35 ` Tiwei Bie
2019-03-19 13:28 ` Maxime Coquelin
2019-03-19 13:28 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 06/10] net/virtio: drop redundant suffix in packed ring structure Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 9:47 ` Jens Freimann
2019-03-19 9:47 ` Jens Freimann
2019-03-19 13:29 ` Maxime Coquelin
2019-03-19 13:29 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 07/10] net/virtio: drop unused field in Tx region structure Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 9:51 ` Jens Freimann
2019-03-19 9:51 ` Jens Freimann
2019-03-19 13:33 ` Maxime Coquelin
2019-03-19 13:33 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 08/10] net/virtio: add interrupt helper for split ring Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 9:53 ` Jens Freimann
2019-03-19 9:53 ` Jens Freimann
2019-03-19 13:34 ` Maxime Coquelin
2019-03-19 13:34 ` Maxime Coquelin
2019-03-19 6:43 ` Tiwei Bie [this message]
2019-03-19 6:43 ` [dpdk-dev] [PATCH 09/10] net/virtio: add ctrl vq " Tiwei Bie
2019-03-19 9:54 ` Jens Freimann
2019-03-19 9:54 ` Jens Freimann
2019-03-19 13:54 ` Maxime Coquelin
2019-03-19 13:54 ` Maxime Coquelin
2019-03-19 6:43 ` [dpdk-dev] [PATCH 10/10] net/virtio: improve batching in standard Rx path Tiwei Bie
2019-03-19 6:43 ` Tiwei Bie
2019-03-19 10:04 ` Jens Freimann
2019-03-19 10:04 ` Jens Freimann
2019-03-19 10:28 ` Tiwei Bie
2019-03-19 10:28 ` Tiwei Bie
2019-03-19 11:08 ` Maxime Coquelin
2019-03-19 11:08 ` Maxime Coquelin
2019-03-19 14:15 ` Maxime Coquelin
2019-03-19 14:15 ` Maxime Coquelin
2019-03-20 7:35 ` [dpdk-dev] [PATCH 00/10] net/virtio: cleanups and fixes for packed/split ring Maxime Coquelin
2019-03-20 7:35 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190319064312.13743-10-tiwei.bie@intel.com \
--to=tiwei.bie@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).