From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id DAE4D1B1FC for ; Thu, 5 Oct 2017 15:04:32 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id y44so4510650wry.2 for ; Thu, 05 Oct 2017 06:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=gwR5FuccRRjDhY9JZ36wmhKd10vMctqZ8PPNZrcyevs=; b=kudQvr68aDbh0jF+odf0hEq+tf9k/klQGyvgp/5XGa2qXM+B4oHJ+AGV4hxF+/ztQk b6cE3pYBvi8cCADia2TaT02pVZDzvJqWiFkpfVquo4TMgGhXRuQCzCg4O9agGxw6s0gG tQlrxTq2AnfbRS12dL7OoEKBIi4rv8Jr5DTpskiEt0TBQH12hzZWY0O0j9k+6A5as+fb +Wrl/jukioGcd58rBWXnVYLD8pVmvSZ2Y0xn8/jQoU1/TL0tjXGKYzkjkQ6SDsGE+YSh zsTvUnMeGnUVxiuSdRo7ZSrsP5ud1aBpw1DyvA/T2Ep+NojWoOID3ImQqZul4skBIlAe i1xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=gwR5FuccRRjDhY9JZ36wmhKd10vMctqZ8PPNZrcyevs=; b=kdaUBj7FHdyHH+4qyV/xiIhmxm4jQOKgANiqzxv0fETIqMxOupErcG0mQPryYQOesj AePENsEzbP8w6XvIl3Wf0wV1I5YDP5KX6b50SbmDa+QnrCKomRX4E+Mebr6AUZs+Guyp z1nwXnxj1HM4fozi7aVX4lIW/vuiL507AQ6jB5Jwys8BhAeXw4ydxJnzdjgmMEgsA6bH +8WqNkBNpXRpi2gBA2IE/PYTG2ZWxBXJkOptqyf9m1g9AXHpvYah/BDZLplxG2mPSETP juQGUx2OrINPQ41Oqd9nGfdP+Q9M7Kt4qok+71IMEfAJXvHp6knZ+HPqRcK24iPFlGvO q3Nw== X-Gm-Message-State: AHPjjUgMqEBlmi1TlJIzRTxYV3+F1vHsM3IsG1QOMs8wEHUUutzrCWJG TRK6KnmZmWQjN8HGmzyT2bihjjyBwkKALRAduOo= X-Google-Smtp-Source: AOwi7QDBtIxHWNzLFxM/DZ2tnRXWwurZYmBq4brwqsSLQTllWm+uUgLu9phg04HEaKmMGvVK8vzmP5t5Js85VHtQI7s= X-Received: by 10.223.139.200 with SMTP id w8mr26742004wra.172.1507208672322; Thu, 05 Oct 2017 06:04:32 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.140.196 with HTTP; Thu, 5 Oct 2017 06:04:31 -0700 (PDT) In-Reply-To: <1506606959-76230-9-git-send-email-jianfeng.tan@intel.com> References: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com> <1506606959-76230-1-git-send-email-jianfeng.tan@intel.com> <1506606959-76230-9-git-send-email-jianfeng.tan@intel.com> From: Jan Blunck Date: Thu, 5 Oct 2017 15:04:31 +0200 X-Google-Sender-Auth: bijsgXIA1mBtjHFumc09jkUwQiQ Message-ID: To: Jianfeng Tan Cc: dev , Bruce Richardson , "Ananyev, Konstantin" , "De Lara Guarch, Pablo" , Thomas Monjalon , yliu@fridaylinux.org, Maxime Coquelin , Tetsuya Mukawa , Ferruh Yigit Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v2 08/12] bus/vdev: scan and probe vdev in secondary processes 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, 05 Oct 2017 13:04:33 -0000 On Thu, Sep 28, 2017 at 3:55 PM, Jianfeng Tan wrote: > Base on primary/secondary communication channel, we add vdev action > to scan virtual devices in secondary processes. > This doesn't need to be in vdev. You application could just hotplug the drivers with exactly the same parameters as the primary process. The driver need to be aware of the primary/secondary process split though. > Signed-off-by: Jianfeng Tan > --- > drivers/bus/vdev/vdev.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 100 insertions(+), 4 deletions(-) > > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c > index e0ba0da..1d1690f 100644 > --- a/drivers/bus/vdev/vdev.c > +++ b/drivers/bus/vdev/vdev.c > @@ -104,7 +104,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) > > name = rte_vdev_device_name(dev); > > - VDEV_LOG(DEBUG, "Search driver %s to probe device %s\n", name, > + VDEV_LOG(DEBUG, "Search driver %s to probe device %s", name, > rte_vdev_device_name(dev)); > > if (vdev_parse(name, &driver)) > @@ -190,7 +190,7 @@ rte_vdev_init(const char *name, const char *args) > ret = vdev_probe_all_drivers(dev); > if (ret) { > if (ret > 0) > - VDEV_LOG(ERR, "no driver found for %s\n", name); > + VDEV_LOG(ERR, "no driver found for %s", name); > goto fail; > } > > @@ -213,7 +213,7 @@ vdev_remove_driver(struct rte_vdev_device *dev) > const struct rte_vdev_driver *driver; > > if (!dev->device.driver) { > - VDEV_LOG(DEBUG, "no driver attach to device %s\n", name); > + VDEV_LOG(DEBUG, "no driver attach to device %s", name); > return 1; > } > > @@ -252,12 +252,105 @@ rte_vdev_uninit(const char *name) > return 0; > } > > +struct vdev_action_params { > +#define VDEV_SCAN_REQUEST 1 > +#define VDEV_SCAN_RESPONSE 2 > + int type; > + char name[32]; > +}; > + > +static int vdev_plug(struct rte_device *dev); > + > +static int > +vdev_action(const void *params, int len, > + int fds[] __rte_unused, > + int fds_num __rte_unused) > +{ > + struct rte_vdev_device *dev; > + struct rte_devargs *devargs; > + struct vdev_action_params ou_params; > + const struct vdev_action_params *in_params = params; > + > + switch (in_params->type) { > + case VDEV_SCAN_REQUEST: > + ou_params.type = VDEV_SCAN_RESPONSE; > + TAILQ_FOREACH(dev, &vdev_device_list, next) { > + VDEV_LOG(INFO, "push vdev, %s", dev->device.name); > + strncpy(ou_params.name, dev->device.name, 32); > + rte_eal_mp_sendmsg("vdev", &ou_params, > + len, NULL, 0); > + } > + break; > + case VDEV_SCAN_RESPONSE: > + VDEV_LOG(INFO, "get vdev, %s", in_params->name); > + > + if (strlen(in_params->name) == 0) { > + VDEV_LOG(ERR, "invalid name was passed"); > + break; > + } > + > + dev = find_vdev(in_params->name); > + if (dev) { > + VDEV_LOG(ERR, "vdev already exists: %s", in_params->name); > + break; > + } > + > + devargs = alloc_devargs(in_params->name, NULL); > + if (!devargs) { > + VDEV_LOG(ERR, "failed to allocate memory"); > + break; > + } > + > + dev = calloc(1, sizeof(*dev)); > + if (!dev) { > + VDEV_LOG(ERR, "failed to allocate memory"); > + free(devargs); > + break; > + } > + > + dev->device.devargs = devargs; > + dev->device.numa_node = 0; /* to be corrected in probe() */ > + dev->device.name = devargs->name; > + > + TAILQ_INSERT_TAIL(&devargs_list, devargs, next); > + TAILQ_INSERT_TAIL(&vdev_device_list, dev, next); > + > + if (vdev_plug(&dev->device) < 0) { > + VDEV_LOG(ERR, "failed to plug device %s", in_params->name); > + free(devargs); > + free(dev); > + } else > + VDEV_LOG(INFO, "plug in device: %s", in_params->name); > + > + break; > + default: > + VDEV_LOG(ERR, "vdev cannot recognize this message"); > + } > + > + return 0; > +} > + > static int > vdev_scan(void) > { > struct rte_vdev_device *dev; > struct rte_devargs *devargs; > > + if (rte_eal_mp_action_register("vdev", vdev_action) < 0) { > + VDEV_LOG(ERR, "vdev fails to add action"); > + return -1; > + } > + > + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { > + struct vdev_action_params params; > + > + params.type = VDEV_SCAN_REQUEST; > + rte_eal_mp_sendmsg("vdev", ¶ms, > + sizeof(params), NULL, 0); > + > + return 0; > + } > + > /* for virtual devices we scan the devargs_list populated via cmdline */ > TAILQ_FOREACH(devargs, &devargs_list, next) { > > @@ -287,6 +380,9 @@ vdev_probe(void) > { > struct rte_vdev_device *dev; > > + if (rte_eal_process_type() == RTE_PROC_SECONDARY) > + return 0; > + > /* call the init function for each virtual device */ > TAILQ_FOREACH(dev, &vdev_device_list, next) { > > @@ -294,7 +390,7 @@ vdev_probe(void) > continue; > > if (vdev_probe_all_drivers(dev)) { > - VDEV_LOG(ERR, "failed to initialize %s device\n", > + VDEV_LOG(ERR, "failed to initialize %s device", > rte_vdev_device_name(dev)); > return -1; > } > -- > 2.7.4 >