From patchwork Fri Mar 16 15:21:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 36161 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7EC9DAAA9; Fri, 16 Mar 2018 16:21:46 +0100 (CET) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 38043AA99 for ; Fri, 16 Mar 2018 16:21:44 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C47AC4036114; Fri, 16 Mar 2018 15:21:43 +0000 (UTC) Received: from localhost (dhcp-192-241.str.redhat.com [10.33.192.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B0EB202322B; Fri, 16 Mar 2018 15:21:43 +0000 (UTC) From: Jens Freimann To: dev@dpdk.org Cc: tiwei.bie@intel.com, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mst@redhat.com Date: Fri, 16 Mar 2018 16:21:09 +0100 Message-Id: <20180316152120.13199-7-jfreimann@redhat.com> In-Reply-To: <20180316152120.13199-1-jfreimann@redhat.com> References: <20180316152120.13199-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 16 Mar 2018 15:21:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 16 Mar 2018 15:21:43 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jfreimann@redhat.com' RCPT:'' Subject: [dpdk-dev] [PATCH 06/17] net/virtio-user: add option to use packed queues X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yuanhan Liu Add option to enable packed queue support for virtio-user devices. Signed-off-by: Yuanhan Liu --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 12 ++++++++++-- drivers/net/virtio/virtio_user/virtio_user_dev.h | 3 ++- drivers/net/virtio/virtio_user_ethdev.c | 15 ++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index f90fee9..5f2ff09 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -314,11 +314,13 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) 1ULL << VIRTIO_NET_F_GUEST_CSUM | \ 1ULL << VIRTIO_NET_F_GUEST_TSO4 | \ 1ULL << VIRTIO_NET_F_GUEST_TSO6 | \ - 1ULL << VIRTIO_F_VERSION_1) + 1ULL << VIRTIO_F_VERSION_1 | \ + 1ULL << VIRTIO_F_RING_PACKED) int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, - int cq, int queue_size, const char *mac, char **ifname) + int cq, int queue_size, const char *mac, char **ifname, + int version_1_1) { snprintf(dev->path, PATH_MAX, "%s", path); dev->max_queue_pairs = queues; @@ -347,6 +349,12 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) PMD_INIT_LOG(ERR, "get_features failed: %s", strerror(errno)); return -1; } + + if (version_1_1) + dev->device_features |= (1ull << VIRTIO_F_RING_PACKED); + else + dev->device_features &= ~(1ull << VIRTIO_F_RING_PACKED); + if (dev->mac_specified) dev->device_features |= (1ull << VIRTIO_NET_F_MAC); diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index 64467b4..ce1e103 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -42,7 +42,8 @@ struct virtio_user_dev { int virtio_user_start_device(struct virtio_user_dev *dev); int virtio_user_stop_device(struct virtio_user_dev *dev); int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, - int cq, int queue_size, const char *mac, char **ifname); + int cq, int queue_size, const char *mac, char **ifname, + int version_1_1); void virtio_user_dev_uninit(struct virtio_user_dev *dev); void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx); #endif diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 2636490..ee291b3 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -278,6 +278,8 @@ VIRTIO_USER_ARG_QUEUE_SIZE, #define VIRTIO_USER_ARG_INTERFACE_NAME "iface" VIRTIO_USER_ARG_INTERFACE_NAME, +#define VIRTIO_USER_ARG_VERSION_1_1 "version_1_1" + VIRTIO_USER_ARG_VERSION_1_1, NULL }; @@ -382,6 +384,7 @@ char *ifname = NULL; char *mac_addr = NULL; int ret = -1; + uint64_t version_1_1 = 0; kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_args); if (!kvlist) { @@ -456,6 +459,15 @@ cq = 1; } + if (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_VERSION_1_1) == 1) { + if (rte_kvargs_process(kvlist, VIRTIO_USER_ARG_VERSION_1_1, + &get_integer_arg, &version_1_1) < 0) { + PMD_INIT_LOG(ERR, "error to parse %s", + VIRTIO_USER_ARG_VERSION_1_1); + goto end; + } + } + if (queues > 1 && cq == 0) { PMD_INIT_LOG(ERR, "multi-q requires ctrl-q"); goto end; @@ -477,7 +489,8 @@ hw = eth_dev->data->dev_private; if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq, - queue_size, mac_addr, &ifname) < 0) { + queue_size, mac_addr, &ifname, + version_1_1) < 0) { PMD_INIT_LOG(ERR, "virtio_user_dev_init fails"); virtio_user_eth_dev_free(eth_dev); goto end;