From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by dpdk.org (Postfix) with ESMTP id 485D216E for ; Mon, 25 Dec 2017 19:06:36 +0100 (CET) Received: by mail-pl0-f65.google.com with SMTP id g2so16882811pli.8 for ; Mon, 25 Dec 2017 10:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TcznKFDyycVw7uDAI8kj/jym883rOJgR3EhBL4qet6M=; b=vj8h+NpzNXKXKgPTRc5Q43yT8YWcdhepQqvY56ZmNLPVuBHg2c9Rt89CZZ6KrLckkB wUanzS5w8M9plrAW+KgpQazUa7ZDK/K7EfUhq8vvDUg0B6ZpjcqFTJg7wLzrZVrCe5Ns qzAFUtWO45CGyy+DwDRtMGHu/c+e+IWQjHRMwBSVL1bq5MatGQUsAri8NQ79EwRZiNVv rPXq7aqTiGXtdffgA6/xb31Z/WOWAiWU+SAUP/KgYPZSkDo/tnHhLn+e4CHeBYnt12VH vysYQvec1dgJkXuRBGH92mP1b/lr3PpJTnOF/z6RQQf2nezCSQiLyhMZkA2p06N8aN1A qo6w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=TcznKFDyycVw7uDAI8kj/jym883rOJgR3EhBL4qet6M=; b=FzYhLdVj95X5Ab9MYtynEYpQ/I8XM5BxBbndRSem6+J2/KVgBmBATZbLQKpZxBdztp 6SiEGr84sak8w8LYeWHIKDVt56g+aBZaPdiPjcx6GlBmDjP+lCZvYemqtjxUmP2hQH0p B8jZ4W4p5m8oeYj2aIuAWwgMxhyuPsSGsg0it6QA7E8SOC9RaSXrMfRHFSyRKbMl3U7Y 8dYpDpa+G8OLtgI02GFQlMoCEBxyoMqZB+nWo6u6utWGizcgOzNEBsVu3CBQyKeyh5dY gURcEm1bYM0kGcdlWv6zwyqtiZ/GOMikgr8eYoOTVITDuHfQjEdGG2sglrw8rp5JSWtf KWuw== X-Gm-Message-State: AKGB3mLV98Aakhfws9s8Gk181KR+cmdBHhdlGqOXAAWYV3gXyYP+2tzl mExV/SEW96nodFoalM2BgoeTBQ== X-Google-Smtp-Source: ACJfBosoookU83tArqJ8l5VKs7hStAo6GT57Yvf2O0Kh2jggfHonC8O5FfJ4lERmIqNQZNFzOIJKDg== X-Received: by 10.84.130.37 with SMTP id 34mr23388044plc.379.1514225195349; Mon, 25 Dec 2017 10:06:35 -0800 (PST) Received: from xeon-e3 (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id 77sm56853564pfh.43.2017.12.25.10.06.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Dec 2017 10:06:35 -0800 (PST) Date: Mon, 25 Dec 2017 10:06:32 -0800 From: Stephen Hemminger To: Jeff Guo Cc: bruce.richardson@intel.com, ferruh.yigit@intel.com, gaetan.rivet@6wind.com, thomas@monjalon.net, konstantin.ananyev@intel.com, jblunck@infradead.org, shreyansh.jain@nxp.com, jingjing.wu@intel.com, dev@dpdk.org, helin.zhang@intel.com Message-ID: <20171225100632.055c3fc8@xeon-e3> In-Reply-To: <1509567405-27439-2-git-send-email-jia.guo@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> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Mon, 25 Dec 2017 18:06:36 -0000 On Thu, 2 Nov 2017 04:16:44 +0800 Jeff Guo wrote: > +int > +rte_dev_bind_driver(const char *dev_name, const char *drv_type) { Bracket left after declaration. > + snprintf(drv_override_path, sizeof(drv_override_path), > + "/sys/bus/pci/devices/%s/driver_override", dev_name); > + > + /* specify the driver for a device by writing to driver_override */ > + drv_override_fd = open(drv_override_path, O_WRONLY); > + if (drv_override_fd < 0) { > + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", > + drv_override_path, strerror(errno)); > + goto err; > + } You should not have dev functions that assume PCI. Please split into common and bus specific code. > +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 = 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) { > + for (; i < RTE_EAL_UEVENT_MSG_LEN; i++) { > + if (*buf) > + break; > + buf++; > + } > + if (!strncmp(buf, "libudev", 7)) { > + buf += 7; > + i += 7; > + event->group = UEV_MONITOR_UDEV; > + } > + if (!strncmp(buf, "ACTION=", 7)) { > + buf += 7; > + i += 7; > + snprintf(action, sizeof(action), "%s", buf); Why snprintf rather than strncpy? > + } else if (!strncmp(buf, "DEVPATH=", 8)) { > + buf += 8; > + i += 8; > + snprintf(dev_path, sizeof(dev_path), "%s", buf); > + } else if (!strncmp(buf, "SUBSYSTEM=", 10)) { > + buf += 10; > + i += 10; > + snprintf(subsystem, sizeof(subsystem), "%s", buf); > + } else if (!strncmp(buf, "PCI_SLOT_NAME=", 14)) { > + buf += 14; > + i += 14; > + snprintf(pci_slot_name, sizeof(subsystem), "%s", buf); > + } > + for (; i < RTE_EAL_UEVENT_MSG_LEN; i++) { > + if (*buf == '\0') > + break; > + buf++; > + } > + } > + > + if (!strncmp(subsystem, "pci", 3)) > + event->subsystem = UEV_SUBSYSTEM_PCI; > + if (!strncmp(action, "add", 3)) > + event->type = RTE_EAL_DEV_EVENT_ADD; > + if (!strncmp(action, "remove", 6)) > + event->type = RTE_EAL_DEV_EVENT_REMOVE; > + event->devname = pci_slot_name; Why do you need to first capture the strings, then set state variables? Instead why not update event->xxx directly?