From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) by dpdk.org (Postfix) with ESMTP id 68F821B1B8 for ; Fri, 29 Sep 2017 10:28:26 +0200 (CEST) Received: by mail-pf0-f175.google.com with SMTP id l188so397817pfc.6 for ; Fri, 29 Sep 2017 01:28:26 -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=m6X32h5awYFuJHum5+MUuCiIXEpdIYqemV9LpXu5eTA=; b=fIcrs7HrJ4SfoWLn4F1TmyFVJ6UPBeAkznpvmu/0HKVatZk5YzMNXfn6t3xBGA0pkL Ype0HyjHG8ggwV51xEbi6Eu2JQx43GKCNd2Fej4TgHqmiiK5v1tl0dyKWjKYl33RkISW DFQvA2WkO71RnFlgtt9z4F3Ox4HjH+CZlU5PYWHyV8JHzXD+N+7JUBI5blcfF2q77t7a bYOnL2Ac6hAAdjESjwwybprdHmaOOfF/4mOUYGmWe30nrHRi92tjRV4kdTIeA8XKngVG i8xtw9mVBGRqj6/q/Jkm/Fg2v1ixX1gfcRwFjlCVgk4y5m1M87DlPNGcXMN9/Gh/78H5 gZOw== 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=m6X32h5awYFuJHum5+MUuCiIXEpdIYqemV9LpXu5eTA=; b=Z/NhTyEjHurAwWMGshp9V4DbUBb2Z7NNJAvuIqeOrxFv25F1oKoLgCX3buutE3AJI1 PmkZli2uk4JteFeP20h59AaWgyAJW8GYRyVf41c107EOQNHw35G5cPxNKihDivaV6TI/ E+2F5DE5bJx05CkaW45CaextBoYFREJeI8ekKG1Ul7iWER/HCzDxeUxJIOs6X8jd+K9G pZ9gtzm/01Ga1lVhXdXRqgDEjI27iW46JwC2TTWBGjfdrvdRu+wfK/JBcXqSjQ6G794A Cfvt0yjhTLmETNb7UmsnXfckr5k9wjPZuR/7UZIrU0VyvIhGPzOZlJ934+QIPyomORj0 KPlw== X-Gm-Message-State: AHPjjUgnpmt9Syiti3BMxq+mSIQFsx1Dap/jzegkU/g2dznlWfLxPimo 3quUlyEXEoduKXIQHJ5m653Lag== X-Google-Smtp-Source: AOwi7QBvOX4LhHQKSt56uwCmmfn+fmO74SZv172/ASVYuIKhd6gHJ8BwrmoiD6EXJXMROMO/7k+Ymg== X-Received: by 10.84.218.71 with SMTP id f7mr6165947plm.145.1506673705710; Fri, 29 Sep 2017 01:28:25 -0700 (PDT) Received: from yliu-home ([45.63.61.64]) by smtp.gmail.com with ESMTPSA id x8sm6259702pff.104.2017.09.29.01.28.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 01:28:24 -0700 (PDT) Date: Fri, 29 Sep 2017 16:28:17 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, bruce.richardson@intel.com, konstantin.ananyev@intel.com, pablo.de.lara.guarch@intel.com, thomas@monjalon.net, maxime.coquelin@redhat.com, mtetsuyah@gmail.com, ferruh.yigit@intel.com Message-ID: <20170929082817.GN2251@yliu-home> References: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com> <1506606959-76230-1-git-send-email-jianfeng.tan@intel.com> <1506606959-76230-13-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1506606959-76230-13-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [dpdk-dev] [PATCH v2 12/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: Fri, 29 Sep 2017 08:28:26 -0000 On Thu, Sep 28, 2017 at 01:55:59PM +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) { > + RTE_LOG(ERR, PMD, "Failed to get mem table\n"); > + return 0; > + } > + for (i = 0; i < mem->nregions; ++i) > + fds[i] = mem->regions[i].fd; > + > + len = sizeof(struct rte_vhost_mem_region) * mem->nregions; > + params = malloc(sizeof(*params) + len); > + if (params == NULL) { > + RTE_LOG(ERR, PMD, "Failed to allocate memory\n"); > + return -1; > + } > + > + params->type = VHOST_MSG_TYPE_REGIONS; > + params->vid = vid; > + memcpy(params->regions, mem->regions, len); > + > + if (rte_eal_mp_sendmsg("vhost pmd", params, sizeof(*params) + len, To me, it's not a good idea to identify an object by a string. The common practice is to use a handler, which could either be a struct or a nubmer. > + fds, mem->nregions) < 0) { > + RTE_LOG(ERR, PMD, "Failed to share mem table\n"); > + free(params); > + return -1; > + } > + > + /* share callfd and kickfd */ > + params->type = VHOST_MSG_TYPE_SET_FDS; > + vring_num = rte_vhost_get_vring_num(vid); > + for (i = 0; i < vring_num; i++) { > + if (rte_vhost_get_vhost_vring(vid, i, &vring) < 0) { If you save the fds here, you don't have to get it every time when there is a new secondary process attached. Then as I have suggested firstly, you don't have to introduce callfd_pri in the vhost lib. --yliu