From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wj0-f172.google.com (mail-wj0-f172.google.com [209.85.210.172]) by dpdk.org (Postfix) with ESMTP id 26075F931 for ; Wed, 4 Jan 2017 18:34:42 +0100 (CET) Received: by mail-wj0-f172.google.com with SMTP id tq7so237768615wjb.0 for ; Wed, 04 Jan 2017 09:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=zbb2QM79aRr67oMy43wWOxgFVQyEXIxlnCEjlfiytAc=; b=QuI8GAg+Q7b9opfMxdD1V4FPOqSSjNL7AguSqUqd++a4qLofqVQQT5WqVT8ppdAjIf RR6MLzYRsssseNvQqGzGFABlZs7FTibS91HV8sWQ3pYdpMfkzZMCiXLrOZMlfc8+960t FA4OMGZ2JoQ8/xqYJPVBh04UQm9l5NlBR13du58rjMXIg2VenFXdvp3i2QTK2MKaI9zE QxFdix/Uf3CyJT3Bm18e117GdRpMk+ozOqbVTkUDPAq/MtiSLUgxKWc3Ek3HiNhn/wN1 M4re/PmO1t0wIqoVrJmRPb/qLDh5+x/I0tk2zoa2Q3mQG/cfQteJFGqAkpMWJlr5JSgx uXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=zbb2QM79aRr67oMy43wWOxgFVQyEXIxlnCEjlfiytAc=; b=FvLyQvg449JD5oFX2m0lKafAQ2koUhCldHHLLQPpjh0Q2w2ue/V7uLXx7pRc/rteTq OCkZWEg7BQ2JXyxPeUjvUuFDFthqIEDVyhH1EccrHNWhuCXCiURB30MmeBveZ3fPDnTX srkXWEZiUAa7ZUjVTYYCK9cUmlGWqvpSBRjU9pguzHJJ6uU12Vvs1liQwg0iD01g1wK6 F78fqDKs2Ff5F6ccbHUNcmpwfHkgLtL1ODjJKZYzyzOJEzNmN2qstpZeDbWz0UQ1eEYM uPUCe3t84Je7Qp6bXk+krqQJhaGr0LSsucjBLaKClCRHLvaGfUkIoga7ZstUApNRnFLL dfIw== X-Gm-Message-State: AIkVDXJV6ds5ppWWhWitn/ecdTZ0AYjfSoiz7l6l0jx5YXH8B4H3st52FSu/8jhrdMZtzvBE X-Received: by 10.194.57.206 with SMTP id k14mr20603306wjq.30.1483551281835; Wed, 04 Jan 2017 09:34:41 -0800 (PST) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id ua15sm99517713wjb.1.2017.01.04.09.34.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jan 2017 09:34:41 -0800 (PST) From: Thomas Monjalon To: Yuanhan Liu Cc: dev@dpdk.org, Bruce Richardson , Ferruh Yigit , "Gonzalez Monroy, Sergio" Date: Wed, 04 Jan 2017 18:34:40 +0100 Message-ID: <1506472.SIAYXrUjSr@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <1482922962-21036-2-git-send-email-yuanhan.liu@linux.intel.com> References: <1482391123-8149-1-git-send-email-yuanhan.liu@linux.intel.com> <1482922962-21036-1-git-send-email-yuanhan.liu@linux.intel.com> <1482922962-21036-2-git-send-email-yuanhan.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v2 1/6] ethdev: fix port data mismatched in multiple process model 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, 04 Jan 2017 17:34:42 -0000 +Cc Sergio (maintainer of the secondary process thing) 2016-12-28 19:02, Yuanhan Liu: > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -201,9 +201,6 @@ rte_eth_dev_allocate(const char *name) > return NULL; > } > > - if (rte_eth_dev_data == NULL) > - rte_eth_dev_data_alloc(); > - It is dangerous to move this to rte_eth_dev_pci_probe. Please keep it here and duplicate it in eth_dev_attach. [...] > +/* > + * Attach to a port already registered by the primary process, which > + * makes sure that the same device would both have the same port id > + * in the primary and secondary process. > + */ > +static struct rte_eth_dev * > +eth_dev_attach(const char *name) Maybe that the word "secondary" could help to differentiate of the function rte_eth_dev_attach(). > +{ > + uint8_t i; > + struct rte_eth_dev *eth_dev; > + > + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { > + if (strcmp(rte_eth_dev_data[i].name, name) == 0) > + break; > + } > + if (i == RTE_MAX_ETHPORTS) { > + RTE_PMD_DEBUG_TRACE( > + "device %s is not driven by the primary process\n", > + name); > + return NULL; > + } > + > + RTE_ASSERT(eth_dev->data->port_id == i); > + > + eth_dev = &rte_eth_devices[i]; > + eth_dev->data = &rte_eth_dev_data[i]; > + eth_dev->attached = DEV_ATTACHED; > + nb_ports++; I am a bit nervous when I see these lines duplicated from rte_eth_dev_allocate. Not sure whether it deserves a common function or not. [...] > @@ -246,9 +275,26 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, > - eth_dev = rte_eth_dev_allocate(ethdev_name); > - if (eth_dev == NULL) > - return -ENOMEM; > + if (rte_eth_dev_data == NULL) > + rte_eth_dev_data_alloc(); > + > + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > + eth_dev = rte_eth_dev_allocate(ethdev_name); > + if (eth_dev == NULL) > + return -ENOMEM; > + } else { > + /* > + * if we failed to attach a device, it means that > + * device is skipped, due to some errors. Take > + * virtio-net device as example, it could be the > + * device is managed by virtio-net kernel driver. > + * For such case, we return a positive value, to > + * let EAL skip it as well. > + */ This comment (a bit too long) should be placed between "if" and "return". > + eth_dev = eth_dev_attach(ethdev_name); > + if (eth_dev == NULL) > + return 1; > + }