[09/10] net/virtio: add ctrl vq helper for split ring
Checks
Commit Message
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(-)
Comments
On Tue, Mar 19, 2019 at 02:43:11PM +0800, Tiwei Bie wrote:
>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(-)
>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
On 3/19/19 7:43 AM, Tiwei Bie wrote:
> 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(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
@@ -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;
}