From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by dpdk.org (Postfix) with ESMTP id 3A1BA5A15 for ; Wed, 21 Jan 2015 07:33:24 +0100 (CET) Received: by mail-pd0-f181.google.com with SMTP id g10so14855637pdj.12 for ; Tue, 20 Jan 2015 22:33:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=bFSiieAIkm79IGXfdlfVXqDdV3BsfLgONdJWpN/uq+A=; b=ZBVv/KbOjzqzEoWQ3rEBGIS67vytCODhcYnlJQSQygn9H4hYWDc6z17uUgoj4KdyMm GMlcB/j9t9uLM4TDJOFjn44wfs/cpD37BelNOe4QgjDy9b5PDtOnBEXeM/kmv/gY/+ud WAx4fv7qxtzvE4+0ersSroyNDWIOvqRnpX+HhZtPbTt0UbKuAOnbtQqNl9yPGg20sog8 6XjNhwrpPJEreZ2m+lYND4ZvhcRavQKeNv8qJD+CqHiyxJSDpzUqWzekp+WQKe5XgiXm mFkAiU1XEzYX9P5RQTR0ziPpO9k9JLWSsq5iI7vPNbwFKXu39c1MuIOF/O/eViX+rUv5 nDOg== X-Gm-Message-State: ALoCoQld4eP3wPw6JKcSxjz+zUCPgGP3egtudW+cac2OTaIZIEW83PBvdicOKJzJ/nlCQP22s3So X-Received: by 10.70.43.8 with SMTP id s8mr11715444pdl.114.1421822002363; Tue, 20 Jan 2015 22:33:22 -0800 (PST) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id fa10sm1868944pdb.55.2015.01.20.22.33.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jan 2015 22:33:21 -0800 (PST) Message-ID: <54BF482F.6010409@igel.co.jp> Date: Wed, 21 Jan 2015 15:33:19 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "Qiu, Michael" References: <1418106629-22227-2-git-send-email-mukawa@igel.co.j> <1421664027-17971-1-git-send-email-mukawa@igel.co.jp> <1421664027-17971-8-git-send-email-mukawa@igel.co.jp> <533710CFB86FA344BFBF2D6802E60286CB7F7B@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286CB7F7B@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v4 07/11] eal/pci: Add a function to remove the entry of devargs list 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: Wed, 21 Jan 2015 06:33:25 -0000 Hi Michael, On 2015/01/21 11:55, Qiu, Michael wrote: > On 1/19/2015 6:42 PM, Tetsuya Mukawa wrote: >> The function removes the specified devargs entry from devargs_list. >> Also the patch adds sanity checking to rte_eal_devargs_add(). >> >> v4: >> - Fix sanity check code >> >> Signed-off-by: Tetsuya Mukawa >> --- >> lib/librte_eal/common/eal_common_devargs.c | 57 ++++++++++++++++++++= +++++++++ >> lib/librte_eal/common/include/rte_devargs.h | 18 +++++++++ >> 2 files changed, 75 insertions(+) >> >> diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_e= al/common/eal_common_devargs.c >> index 4c7d11a..a360a85 100644 >> --- a/lib/librte_eal/common/eal_common_devargs.c >> +++ b/lib/librte_eal/common/eal_common_devargs.c >> @@ -44,6 +44,35 @@ >> struct rte_devargs_list devargs_list =3D >> TAILQ_HEAD_INITIALIZER(devargs_list); >> =20 >> + >> +/* find a entry specified by pci address or device name */ >> +static struct rte_devargs * >> +rte_eal_devargs_find(enum rte_devtype devtype, void *args) >> +{ >> + struct rte_devargs *devargs; >> + >> + if (args =3D=3D NULL) >> + return NULL; >> + >> + TAILQ_FOREACH(devargs, &devargs_list, next) { >> + switch (devtype) { >> + case RTE_DEVTYPE_WHITELISTED_PCI: >> + case RTE_DEVTYPE_BLACKLISTED_PCI: >> + if (eal_compare_pci_addr(&devargs->pci.addr, args) =3D=3D 0) >> + goto found; >> + break; >> + case RTE_DEVTYPE_VIRTUAL: >> + if (memcmp(&devargs->virtual.drv_name, args, >> + strlen((char *)args)) =3D=3D 0) >> + goto found; >> + break; >> + } >> + } >> + return NULL; >> +found: >> + return devargs; >> +} >> + >> /* store a whitelist parameter for later parsing */ >> int >> rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str= ) >> @@ -87,6 +116,12 @@ rte_eal_devargs_add(enum rte_devtype devtype, cons= t char *devargs_str) >> free(devargs); >> return -1; >> } >> + /* make sure there is no same entry */ >> + if (rte_eal_devargs_find(devtype, &devargs->pci.addr)) { >> + RTE_LOG(ERR, EAL, >> + "device already registered: <%s>\n", buf); >> + return -1; >> + } >> break; >> case RTE_DEVTYPE_VIRTUAL: >> /* save driver name */ >> @@ -98,6 +133,12 @@ rte_eal_devargs_add(enum rte_devtype devtype, cons= t char *devargs_str) >> free(devargs); >> return -1; >> } >> + /* make sure there is no same entry */ >> + if (rte_eal_devargs_find(devtype, &devargs->virtual.drv_name)) { >> + RTE_LOG(ERR, EAL, >> + "device already registered: <%s>\n", buf); >> + return -1; >> + } >> break; >> } >> =20 >> @@ -105,6 +146,22 @@ rte_eal_devargs_add(enum rte_devtype devtype, con= st char *devargs_str) >> return 0; >> } >> =20 >> +/* remove it from the devargs_list */ >> +void >> +rte_eal_devargs_remove(enum rte_devtype devtype, void *args) >> +{ >> + struct rte_devargs *devargs; >> + >> + if (args =3D=3D NULL) >> + return; >> + >> + devargs =3D rte_eal_devargs_find(devtype, args); >> + if (devargs =3D=3D NULL) > If devargs =3D=3D NULL, means not found, does it reasonable to ignore?= Some > error happens I think, at least you should print out some logs. I appreciate your comment. I agree with you. At least error message should be displayed. I will change function definition to return a error code and fix caller of the function. Also I will add error message. Thanks, Tetsuya > Thanks, > Michael >> + return; >> + >> + TAILQ_REMOVE(&devargs_list, devargs, next); >> +} >> + >> /* count the number of devices of a specified type */ >> unsigned int >> rte_eal_devargs_type_count(enum rte_devtype devtype) >> diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_= eal/common/include/rte_devargs.h >> index 9f9c98f..1066efd 100644 >> --- a/lib/librte_eal/common/include/rte_devargs.h >> +++ b/lib/librte_eal/common/include/rte_devargs.h >> @@ -123,6 +123,24 @@ extern struct rte_devargs_list devargs_list; >> int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs= _str); >> =20 >> /** >> + * Remove a device from the user device list >> + * >> + * For PCI devices, the format of arguments string is "PCI_ADDR". It = shouldn't >> + * involves parameters for the device. Example: "08:00.1". >> + * >> + * For virtual devices, the format of arguments string is "DRIVER_NAM= E*". It >> + * shouldn't involves parameters for the device. Example: "eth_ring".= The >> + * validity of the driver name is not checked by this function, it is= done >> + * when closing the drivers. >> + * >> + * @param devtype >> + * The type of the device. >> + * @param name >> + * The name of the device. >> + */ >> +void rte_eal_devargs_remove(enum rte_devtype devtype, void *args); >> + >> +/** >> * Count the number of user devices of a specified type >> * >> * @param devtype