From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 8CA681B395 for ; Wed, 8 Nov 2017 06:40:00 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2017 21:39:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,362,1505804400"; d="scan'208";a="2226952" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 07 Nov 2017 21:39:58 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 7 Nov 2017 21:39:56 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 7 Nov 2017 21:39:56 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Wed, 8 Nov 2017 13:39:54 +0800 From: "Guo, Jia" To: Stephen Hemminger CC: "Richardson, Bruce" , "Yigit, Ferruh" , "gaetan.rivet@6wind.com" , "thomas@monjalon.net" , "Ananyev, Konstantin" , "jblunck@infradead.org" , "shreyansh.jain@nxp.com" , "Wu, Jingjing" , "dev@dpdk.org" , "Zhang, Helin" Thread-Topic: [PATCH v6 1/2] eal: add uevent monitor for hot plug Thread-Index: AQHTUshOx1wCgXWqXEWsNzybPEseMqL/iL4AgAp5FLA= Date: Wed, 8 Nov 2017 05:39:54 +0000 Message-ID: <01BA8470C017D6468C8290E4B9C5E1E83B2A7073@shsmsx102.ccr.corp.intel.com> References: <1505880732-16539-3-git-send-email-jia.guo@intel.com> <1509567405-27439-1-git-send-email-jia.guo@intel.com> <1509567405-27439-2-git-send-email-jia.guo@intel.com> <20171101224144.7e0854bf@shemminger-XPS-13-9360> In-Reply-To: <20171101224144.7e0854bf@shemminger-XPS-13-9360> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjMwZTAwYTUtYmFjNy00OWM4LTg5N2MtYzI4YjBhZTZiYTNkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IldiK3h6aUJpeldGWlFIVzczZk5UVlVkSWVyWVVLNWFrZjM3Vm9jYjB3akU9In0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v6 1/2] eal: add uevent monitor for hot plug 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, 08 Nov 2017 05:40:01 -0000 Thanks Stephen for your eye on review, would collect other comment and refi= ne it better in next version. Best regards, Jeff Guo -----Original Message----- From: Stephen Hemminger [mailto:stephen@networkplumber.org]=20 Sent: Thursday, November 2, 2017 5:42 AM To: Guo, Jia Cc: Richardson, Bruce ; Yigit, Ferruh ; gaetan.rivet@6wind.com; thomas@monjalon.net; Ananyev, Kons= tantin ; jblunck@infradead.org; shreyansh.jai= n@nxp.com; Wu, Jingjing ; dev@dpdk.org; Zhang, Helin= Subject: Re: [PATCH v6 1/2] eal: add uevent monitor for hot plug On Thu, 2 Nov 2017 04:16:44 +0800 Jeff Guo wrote: > + > +static int > +dev_uev_parse(const char *buf, struct rte_eal_uevent *event) { > + char action[RTE_EAL_UEVENT_MSG_LEN]; > + char subsystem[RTE_EAL_UEVENT_MSG_LEN]; > + char dev_path[RTE_EAL_UEVENT_MSG_LEN]; > + char pci_slot_name[RTE_EAL_UEVENT_MSG_LEN]; > + int i =3D 0; > + > + memset(action, 0, RTE_EAL_UEVENT_MSG_LEN); > + memset(subsystem, 0, RTE_EAL_UEVENT_MSG_LEN); > + memset(dev_path, 0, RTE_EAL_UEVENT_MSG_LEN); > + memset(pci_slot_name, 0, RTE_EAL_UEVENT_MSG_LEN); > + > + while (i < RTE_EAL_UEVENT_MSG_LEN) { Might be simpler, safer, clearer to use rte_strsplit here. And then have a table of fields rather than open coding the parsing. > + for (; i < RTE_EAL_UEVENT_MSG_LEN; i++) { > + if (*buf) > + break; > + buf++; > + } > + if (!strncmp(buf, "libudev", 7)) { > + buf +=3D 7; > + i +=3D 7; > + event->group =3D UEV_MONITOR_UDEV; > + } > + if (!strncmp(buf, "ACTION=3D", 7)) { > + buf +=3D 7; > + i +=3D 7; > + snprintf(action, sizeof(action), "%s", buf); > + } else if (!strncmp(buf, "DEVPATH=3D", 8)) { > + buf +=3D 8; > + i +=3D 8; > + snprintf(dev_path, sizeof(dev_path), "%s", buf); > + } else if (!strncmp(buf, "SUBSYSTEM=3D", 10)) { > + buf +=3D 10; > + i +=3D 10; > + snprintf(subsystem, sizeof(subsystem), "%s", buf); > + } else if (!strncmp(buf, "PCI_SLOT_NAME=3D", 14)) { > + buf +=3D 14; > + i +=3D 14; > + snprintf(pci_slot_name, sizeof(subsystem), "%s", buf); > + } > + for (; i < RTE_EAL_UEVENT_MSG_LEN; i++) { > + if (*buf =3D=3D '\0') > + break; > + buf++; > + } > + } > + > + if (!strncmp(subsystem, "pci", 3)) > + event->subsystem =3D UEV_SUBSYSTEM_PCI; > + if (!strncmp(action, "add", 3)) > + event->type =3D RTE_EAL_DEV_EVENT_ADD; > + if (!strncmp(action, "remove", 6)) > + event->type =3D RTE_EAL_DEV_EVENT_REMOVE; > + event->devname =3D pci_slot_name; > + > + return 0; Function always returns 0, why is it not void?