From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 57B675955 for ; Tue, 3 May 2016 00:22:39 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 02 May 2016 15:22:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,569,1455004800"; d="scan'208";a="95911127" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by fmsmga004.fm.intel.com with ESMTP; 02 May 2016 15:22:16 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: huawei.xie@intel.com, Thomas Monjalon , Panu Matilainen , Tetsuya Mukawa , Traynor Kevin , Yuanhan Liu Date: Mon, 2 May 2016 15:25:19 -0700 Message-Id: <1462227927-22853-9-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1462227927-22853-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1462227927-22853-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH 08/16] vhost: query pmd internal by vid X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2016 22:22:39 -0000 Query internal by vid instead of "ifname", to avoid the dependency of virtio_net struct. Signed-off-by: Yuanhan Liu --- drivers/net/vhost/rte_eth_vhost.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 63538c1..290fd9e 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -86,6 +86,7 @@ struct vhost_queue { }; struct pmd_internal { + int vid; char *dev_name; char *iface_name; uint16_t max_queues; @@ -194,20 +195,17 @@ eth_dev_configure(struct rte_eth_dev *dev __rte_unused) } static inline struct internal_list * -find_internal_resource(char *ifname) +find_internal_resource(int vid) { int found = 0; struct internal_list *list; struct pmd_internal *internal; - if (ifname == NULL) - return NULL; - pthread_mutex_lock(&internal_list_lock); TAILQ_FOREACH(list, &internal_list, next) { internal = list->eth_dev->data->dev_private; - if (!strcmp(internal->iface_name, ifname)) { + if (internal->vid == vid) { found = 1; break; } @@ -238,14 +236,15 @@ new_device(struct virtio_net *dev) return -1; } - list = find_internal_resource(dev->ifname); + list = find_internal_resource(dev->vid); if (list == NULL) { - RTE_LOG(INFO, PMD, "Invalid device name\n"); + RTE_LOG(INFO, PMD, "Invalid vid %d\n", dev->vid); return -1; } eth_dev = list->eth_dev; internal = eth_dev->data->dev_private; + internal->vid = dev->vid; #ifdef RTE_LIBRTE_VHOST_NUMA ret = get_mempolicy(&newnode, NULL, 0, dev, @@ -371,9 +370,9 @@ vring_state_changed(struct virtio_net *dev, uint16_t vring, int enable) return -1; } - list = find_internal_resource(dev->ifname); + list = find_internal_resource(dev->vid); if (list == NULL) { - RTE_LOG(ERR, PMD, "Invalid interface name: %s\n", dev->ifname); + RTE_LOG(ERR, PMD, "Invalid vid %d\n", dev->vid); return -1; } @@ -884,7 +883,7 @@ rte_pmd_vhost_devuninit(const char *name) if (internal == NULL) return -ENODEV; - list = find_internal_resource(internal->iface_name); + list = find_internal_resource(internal->vid); if (list == NULL) return -ENODEV; -- 1.9.0