From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by dpdk.org (Postfix) with ESMTP id 29FB48E8A for ; Tue, 24 Nov 2015 03:48:07 +0100 (CET) Received: by pabfh17 with SMTP id fh17so5536173pab.0 for ; Mon, 23 Nov 2015 18:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=UHyoVhI0mYzV+weg23R8beJ87gssiXvb6pMXLyw1fJs=; b=ICqCGYWl8rolK5OrCMeueSMjPHr8S9ukZs/tGV5d1NPk1JtckqfHi10c5JjJZgXWXE DF73VO0MAftjagwooOZaHQysDp7NYmpSju7803ziLXWK7re8Kp84X8BzD7pX85EFdMZ/ NsU+8aTnYJRb3+LP67jXG6ijSCvFaIKMnt9Z32Yw5She1JxaUHE3ImoacL2A5oJztL82 z8S9cRKwHNt/8Qq0F/53PHkuhW6PRMBY2HgbNvP5PoV19k0iGnlFwmOhT5NEte+5DbCy 7ZFl6ZUcn/+tuLwT6/pTtCZqURU5Omi+vCB9+hNcsu7i1YBcVpN1R2H+kopyjScUIw1L 2Gow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=UHyoVhI0mYzV+weg23R8beJ87gssiXvb6pMXLyw1fJs=; b=P9n5M/Mo5TOvuJMSYN+5zNajQogKo+a8cA2arCZjvWxzIqiRCi65mBRWeB571sf4OY /067Lpk+UX03d9diufkdYL5QRmjk9p8iDsKNgRGj5BaBfSc7zW/N8HDO82+DC+dKO+Uk 0b/eQJAYMMbk8C3bs4BJptoVV70sloW54XCSP6eEZ9WSazMtHmKClE7oYDSHQrqey5kv Eoe9NppfbX2S63Ezc/qHejtsJllrNE2aeUo3HnWz+f4Q47g0ud2Z4gmqakiYHojQ7nDu 4Uwy1g4SOv+xX18RGSBOl4uSaUZ4CU7A6kzJCeMUX9xPAdRzvG7P5pblDTWD+aBmBIzt xYOw== X-Gm-Message-State: ALoCoQnye6AyJ8Tp+0fvxtZrMgTp4VqA3Gs5DUMN9IiJPRy5kNYvMU4VBy0XJZ9ssuNQGAmyh0c/ X-Received: by 10.68.106.100 with SMTP id gt4mr39879722pbb.33.1448333286206; Mon, 23 Nov 2015 18:48:06 -0800 (PST) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by smtp.googlemail.com with ESMTPSA id hs4sm4633975pbb.58.2015.11.23.18.48.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Nov 2015 18:48:05 -0800 (PST) To: Yuanhan Liu References: <1447046221-20811-3-git-send-email-mukawa@igel.co.jp> <1447392031-24970-1-git-send-email-mukawa@igel.co.jp> <1447392031-24970-3-git-send-email-mukawa@igel.co.jp> <20151120114304.GB2325@yliu-dev.sh.intel.com> From: Tetsuya Mukawa X-Enigmail-Draft-Status: N1110 Message-ID: <5653CFE4.8010405@igel.co.jp> Date: Tue, 24 Nov 2015 11:48:04 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151120114304.GB2325@yliu-dev.sh.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, ann.zhuangyanying@huawei.com Subject: Re: [dpdk-dev] [PATCH v4 2/2] vhost: Add VHOST PMD 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: Tue, 24 Nov 2015 02:48:07 -0000 On 2015/11/20 20:43, Yuanhan Liu wrote: > On Fri, Nov 13, 2015 at 02:20:31PM +0900, Tetsuya Mukawa wrote: > .... >> +static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER; >> + >> +static rte_atomic16_t nb_started_ports; >> +pthread_t session_th; > static? Hi Yuanhan, I appreciate your carefully reviewing. I will fix issues you commented, and submit it again. I added below 2 comments. Could you please check it? >> + >> +static uint16_t >> +eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) >> +{ >> + struct vhost_queue *r = q; >> + uint16_t i, nb_tx = 0; >> + >> + if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0)) >> + return 0; >> + >> + rte_atomic32_set(&r->while_queuing, 1); >> + >> + if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0)) >> + goto out; >> + >> + /* Enqueue packets to guest RX queue */ >> + nb_tx = rte_vhost_enqueue_burst(r->device, >> + r->virtqueue_id, bufs, nb_bufs); >> + >> + r->tx_pkts += nb_tx; >> + r->err_pkts += nb_bufs - nb_tx; >> + >> + for (i = 0; likely(i < nb_tx); i++) >> + rte_pktmbuf_free(bufs[i]); > We should free upto nb_bufs here, but not nb_tx, right? I guess we don't need to free all packet buffers. Could you please check l2fwd_send_burst() in l2fwd example? It seems DPDK application frees packet buffers that failed to send. >> +static struct rte_driver pmd_vhost_drv = { >> + .name = "eth_vhost", >> + .type = PMD_VDEV, >> + .init = rte_pmd_vhost_devinit, >> + .uninit = rte_pmd_vhost_devuninit, >> +}; >> + >> +struct >> +virtio_net *rte_eth_vhost_portid2vdev(uint16_t port_id) > struct virtio_net * > rte_eth_vhost_portid2vdev() > > BTW, why making a speical eth API for virtio? This doesn't make too much > sense to me. This is a kind of helper function. I assume that DPDK applications want to know relation between port_id and virtio device structure. But, in "new" callback handler that DPDK application registers, application can receive virtio device structure, but it doesn't tell which port is. To know it, probably here are steps that DPDK application needs to do. 1. Store interface name that is specified when vhost pmd is invoked. (For example, store information like /tmp/socket0 is for port0, and /tmp/socket1 is for port1) 2. Compare above interface name and dev->ifname that is stored in virtio device structure, then DPDK application can know which port is. If DPDK application uses Port Hotplug, I guess above steps are easy. But if they don't, interface name will be specified in "--vdev" EAL command line option. So probably it's not so easy to handle interface name in DPDK application. This is why I added the function. Thanks, Tetsuya