From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 0277C1B19E for ; Wed, 6 Dec 2017 10:21:49 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7236D20BBC; Wed, 6 Dec 2017 04:21:49 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 06 Dec 2017 04:21:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=wa/Dy8CxsmZnfkhaUVmJQPprZz y3yAk1cKOsnoZGlFU=; b=J2WD3jmBoeSpCIHaAyN5rE8CE2vYpukaLf/HQ1KGGf Im8SLrVNkqRRo/8ZnWUahxycY6+yr79eIDK+l8JwSkedv0vn200oZJDgf4cbnKMG UY0CAmAt9/5VY6mvMtiLyxYUTWsEgPehF/xfFjKAGyRqtcvomVPBytd3kZCpNA7A 8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=wa/Dy8 CxsmZnfkhaUVmJQPprZzy3yAk1cKOsnoZGlFU=; b=Hb5fVBIgx5cZxzHiIICFa2 9SH5uRN/+UsKUBHZh+L+1+hL4SYUX/ky4QponbEaujnw17unIH4JeRkIOUxfMedg smbDB1E+t9PR5xsk18UMUMrBUh1miGHzis7+04tkuCDXmCxXBr+weWa63Xl32Y5k TfcNDEPN/PI6bWiMnplNpZC20O4WFGZtI4OUqbj3Ylsv7MgPxdisRam3XU0WVAMg 7h0BppEKigAYvsk+WpyC+Yu7038KPz1lrMp/UdKnuCRbu/iSIBP0quUocvZnIg+B oUpAEYkg8pVrisO26nn+c1f5hUrPrPO20DuMfR8YwIdMDx4D9zOoj/dwfoJEPmbA == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 097822473E; Wed, 6 Dec 2017 04:21:49 -0500 (EST) From: Thomas Monjalon To: "Tan, Jianfeng" Cc: dev@dpdk.org Date: Wed, 06 Dec 2017 10:21:48 +0100 Message-ID: <3098333.2ghLid1hiy@xps> In-Reply-To: References: <20171201003642.19827-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] bus/vdev: add custom scan hook 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: Wed, 06 Dec 2017 09:21:50 -0000 06/12/2017 03:52, Tan, Jianfeng: > On 12/1/2017 8:36 AM, Thomas Monjalon wrote: > > +int > > +rte_vdev_add_custom_scan(rte_vdev_scan_callback callback, void *user_arg) > > +{ > > + struct vdev_custom_scan *custom_scan; > > + > > + rte_spinlock_lock(&vdev_custom_scan_lock); > > + > > + /* check if already registered */ > > + TAILQ_FOREACH(custom_scan, &vdev_custom_scans, next) { > > + if (custom_scan->callback == callback && > > + custom_scan->user_arg == user_arg) > > + break; > > + } > > + > > + if (custom_scan == NULL) { > > + custom_scan = malloc(sizeof(struct vdev_custom_scan)); > > + if (custom_scan != NULL) { > > + custom_scan->callback = callback; > > + custom_scan->user_arg = user_arg; > > + TAILQ_INSERT_TAIL(&vdev_custom_scans, custom_scan, next); > > + } > > + } > > + > > + rte_spinlock_unlock(&vdev_custom_scan_lock); > > + > > + return (custom_scan == NULL) ? -ENOMEM : 0; > > +} > > + > > +int > > +rte_vdev_remove_custom_scan(rte_vdev_scan_callback callback, void *user_arg) > > +{ > > + struct vdev_custom_scan *custom_scan, *tmp_scan; > > + > > + rte_spinlock_lock(&vdev_custom_scan_lock); > > + TAILQ_FOREACH_SAFE(custom_scan, &vdev_custom_scans, next, tmp_scan) { > > + if (custom_scan->callback != callback || > > + (custom_scan->user_arg != (void *)-1 && > > + custom_scan->user_arg != user_arg)) > > + continue; > > + TAILQ_REMOVE(&vdev_custom_scans, custom_scan, next); > > + free(custom_scan); > > + } > > + rte_spinlock_unlock(&vdev_custom_scan_lock); > > + > > + return 0; > > +} > > + > > static int > > vdev_parse(const char *name, void *addr) > > { > > @@ -260,6 +319,22 @@ vdev_scan(void) > > { > > struct rte_vdev_device *dev; > > struct rte_devargs *devargs; > > + struct vdev_custom_scan *custom_scan; > > + > > + /* call custom scan callbacks if any */ > > + rte_spinlock_lock(&vdev_custom_scan_lock); > > + TAILQ_FOREACH(custom_scan, &vdev_custom_scans, next) { > > + if (custom_scan->callback != NULL) > > + /* > > + * the callback should update devargs list > > + * by calling rte_eal_devargs_insert() with > > + * devargs.bus = rte_bus_find_by_name("vdev"); > > + * devargs.type = RTE_DEVTYPE_VIRTUAL; > > + * devargs.policy = RTE_DEV_WHITELISTED; > > + */ > > + custom_scan->callback(custom_scan->user_arg); > > + } > > + rte_spinlock_unlock(&vdev_custom_scan_lock); > > You mentioned that we want to call the hook in the scan(), but it's now > in parse()? No, it is in vdev_scan. Look carefully the patch, especially after @@.