From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 858767CDE for ; Thu, 21 Sep 2017 06:29:36 +0200 (CEST) Received: by mail-pf0-f178.google.com with SMTP id b70so2628665pfl.8 for ; Wed, 20 Sep 2017 21:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ULUkEcWHxazllZ41c4SR1ddL2RtlloEUoHHHhnvlyqI=; b=wrrGItR8dwPE/7mZ4/ViDHaKOzyMOTlQpwGBfqN3eBbpmm8Sq2MlmG5mlqcxcvIgEt c1743E+MggkULqANRPCazoUlc8FE9Anm8irxAOtpIf+rSJXpNXTaLvDc9nFo/5mHzHbl TfH2k+H7ijGzVjsCby58driUlYtdL599FE3fyG/V8IqpOz7CrtV3zGNaa4VRoaQ3TnVU RYFWQvU6brlhJ1GnIGhD9mwAvuUJpOmpEPqDxX0kOZCTrHLwkuMAgokal7EWff9qEgMw DsoV+rI/YXyX0EzH8Bur9FgYHJRKthFKO46lA/7ecI4Y6iIWccaZFlpJd7DjBNBh4+Aw imgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ULUkEcWHxazllZ41c4SR1ddL2RtlloEUoHHHhnvlyqI=; b=EdvustmLUHq1CRotTO0ph/ok3wzsQ+s1J5S2b7WdooKISvwgqrYXAlznW3HObaKGbw 8iUK3onibMjYdbkhdgenawdbDec8l0WMFI4/n8bpps/mo/VcGEZ7/JQlUaShn5M79rxM 8F6FOdgwjljiE5Eyv/0svD5iYIYVRV0KmVI61QtpBFTaThhKvFfObkIWxKgFlmuqA2Jd bqZa7PtBgTiDbx7am8y5C9lAi5D9awZ3BziMWdDqI68n2HN1LEoSVg6ZqIZZdFzbZftv R0wOsgLL0zJD6YymHWcJ+fgwn0kQEsst0Ga9L/e1FpQAdUtcxTzZzDC6nwfSBnUGNpDv N+CQ== X-Gm-Message-State: AHPjjUjia4JBEhYBJVC4clxEmfxSEwB5/Rb4D1fAnR55Ua3YC7wBm35s AoHHtN0JvAZK+uLxnRcZSfQhJ9gs+qQ= X-Google-Smtp-Source: AOwi7QChF6+ysn4iXVQDGCAkmZqESh1ybhDBhPGF+4yQAoREPpq/gGH8C6zcxhirQfZKmucwjEXPMQ== X-Received: by 10.98.242.3 with SMTP id m3mr4410749pfh.306.1505968175726; Wed, 20 Sep 2017 21:29:35 -0700 (PDT) Received: from yliu-home ([45.63.61.64]) by smtp.gmail.com with ESMTPSA id v8sm553572pgs.9.2017.09.20.21.29.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 21:29:34 -0700 (PDT) Date: Thu, 21 Sep 2017 12:29:28 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, maxime.coquelin@redhat.com, mtetsuyah@gmail.com Message-ID: <20170921042927.GB2251@yliu-home> References: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com> <1503654052-84730-12-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1503654052-84730-12-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [dpdk-dev] [PATCH 11/12] net/vhost: support to run in the secondary process 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: , X-List-Received-Date: Thu, 21 Sep 2017 04:29:37 -0000 On Fri, Aug 25, 2017 at 09:40:51AM +0000, Jianfeng Tan wrote: > static int > +share_device(int vid) > +{ > + uint32_t i, vring_num; > + int len; > + int fds[8]; > + struct rte_vhost_memory *mem; > + struct vhost_params *params; > + struct rte_vhost_vring vring; > + > + /* share mem table */ > + if (rte_vhost_get_mem_table(vid, &mem) < 0) { > + printf("Failed to get mem table\n"); No printf in DPDK lib and pmd, use RTE_LOG instead. [...] > +static int > +eth_dev_vhost_attach(struct rte_vdev_device *dev) > +{ > + struct rte_eth_dev *eth_dev = NULL; > + struct rte_eth_dev_data *data = NULL; > + > + RTE_LOG(INFO, PMD, "Attach vhost user port\n"); > + > + /* reserve an ethdev entry */ > + eth_dev = rte_eth_vdev_allocate(dev, sizeof(struct pmd_internal)); > + if (eth_dev == NULL) > + goto error; I'd suggest to "return -1" directly here, without introducing goto. > + > + eth_dev->dev_ops = &ops; > + > + /* finally assign rx and tx ops */ > + eth_dev->rx_pkt_burst = eth_vhost_rx; > + eth_dev->tx_pkt_burst = eth_vhost_tx; > + > + data = eth_dev->data; > + > + return data->port_id; > + > +error: > + return -1; > +} > + > static inline int > open_iface(const char *key __rte_unused, const char *value, void *extra_args) > { > @@ -1154,6 +1244,39 @@ open_int(const char *key __rte_unused, const char *value, void *extra_args) > } > > static int > +vhost_pmd_action(const char *params, int len __rte_unused, > + int fds[], int fds_num) > +{ > + int i; > + void *base_addr; > + const struct vhost_params *p = (const struct vhost_params *)params; The cast could be avoided if you define the action prototype with "const void *params". > + const struct rte_vhost_mem_region *regions; > + > + switch (p->type) { > + case VHOST_MSG_TYPE_REGIONS: > + regions = (const void *)p->regions; Unnecessary cast. > + for (i = 0; i < fds_num; ++i) { > + base_addr = mmap(regions[i].mmap_addr, > + regions[i].mmap_size, > + PROT_READ | PROT_WRITE, > + MAP_FIXED | MAP_SHARED, fds[i], 0); > + if (base_addr != regions[i].mmap_addr) { > + RTE_LOG(INFO, PMD, "mmap error"); The log level should be error, nothing will work if it happens. Also, the log message should be more informative. --yliu