From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 3E5D72946 for ; Fri, 6 Jan 2017 14:12:50 +0100 (CET) Received: by mail-wm0-f46.google.com with SMTP id k184so28727229wme.1 for ; Fri, 06 Jan 2017 05:12:50 -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=YuVWbMqasuVPrBRoVTAEViQRBJYaU3NJCkQa8bsmeWI=; b=M7fbibW5TI+h/PjI5zPyEP1W6SAByTlDYlVWlIUC/tc+dh5gRMLacaZuF7mr1NmzAj 86OyL0sTJLHSvCRZN98Ckmw855fSXXAmNpVxu95qn1WGTOXAJDzKKTCw9AOF/ovwGw7v 1ZPE08mV0p+f/2zhRm23chBvyIJaytuQYJI2czAjIAJhpVkijQ748CpJ4m0Je0dDsh87 /qI7ateiZmnLnojaiVI5tVYsCBWVBPks8Xs15zjuqGfU24ctTz5uKQfE5oOZbV+TH5Pc iQED2s8ebB4O0zzChmJV5o46orPi8UMs6/+4Tl7+nDFjjL/n+e3AFABJEzdPJ3vv/v5n UwzA== 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=YuVWbMqasuVPrBRoVTAEViQRBJYaU3NJCkQa8bsmeWI=; b=GPlVzI/0JoFH+JNckZLSxCTYQ5/XVE5txfTTxmQD1C8wCalXTnIbF+/tOKf6j2NIwP 4+NI4FJMAjd/tu0bWmx4J2aJA3+R3N2oepfBHKT42ovRUT+L6pPvB+vYLVvbU9q/fZvp Ib+FiX7RzLeQgQMkVoQjRrIrLl0oVBzvs73Mu3a6h9bPfJJUy+OtYBYhqEFJiEeLlQAd ruKd/begHVpqtgeiOwtzMtFHLfytN3QEWFoop24TS2n5g84wjWdOkAiz5cMf1LoY+QgN zkD1RNyaA6Mu44WIK3lWCvG5F2DdMqTq7y1odN2HirnS4zvGhfFSg4vPEvNu9QYTU1Ik IWwg== X-Gm-Message-State: AIkVDXL/PiNZlCdkfBIdYRVt64emvsYmk3klMjmDfQdUgkg1VhNGQdvN0dzkZnF0EXskju1P X-Received: by 10.223.150.240 with SMTP id u103mr969558wrb.9.1483708369968; Fri, 06 Jan 2017 05:12:49 -0800 (PST) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id jd9sm92840803wjb.9.2017.01.06.05.12.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jan 2017 05:12:49 -0800 (PST) From: Thomas Monjalon To: Yuanhan Liu , Bruce Richardson Cc: dev@dpdk.org, Ferruh Yigit Date: Fri, 06 Jan 2017 14:12:48 +0100 Message-ID: <16135200.seSVc815in@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <1483697780-12088-2-git-send-email-yuanhan.liu@linux.intel.com> References: <1482922962-21036-1-git-send-email-yuanhan.liu@linux.intel.com> <1483697780-12088-1-git-send-email-yuanhan.liu@linux.intel.com> <1483697780-12088-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 v3 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: Fri, 06 Jan 2017 13:12:50 -0000 2017-01-06 18:16, Yuanhan Liu: > +static void > +eth_dev_init(struct rte_eth_dev *eth_dev, uint8_t port_id, const char *name) > +{ > + eth_dev->data = &rte_eth_dev_data[port_id]; > + eth_dev->attached = DEV_ATTACHED; > + eth_dev_last_created_port = port_id; > + nb_ports++; > + > + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > + snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), > + "%s", name); > + eth_dev->data->port_id = port_id; > + } Why not keeping eth_dev->data filling in rte_eth_dev_allocate? > +} > + > struct rte_eth_dev * > rte_eth_dev_allocate(const char *name) > { > @@ -211,12 +226,41 @@ struct rte_eth_dev * > } > > eth_dev = &rte_eth_devices[port_id]; Why not moving this line in eth_dev_init? > - eth_dev->data = &rte_eth_dev_data[port_id]; > - snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name); > - eth_dev->data->port_id = port_id; > - eth_dev->attached = DEV_ATTACHED; > - eth_dev_last_created_port = port_id; > - nb_ports++; > + eth_dev_init(eth_dev, port_id, name); > + > + return eth_dev; > +} [...] > +/* > + * Attach to a port already registered by the primary process, which > + * makes sure that the same device would have the same port id both > + * in the primary and secondary process. > + */ > +static struct rte_eth_dev * > +eth_dev_attach_secondary(const char *name) OK, good description [...] > - eth_dev = rte_eth_dev_allocate(ethdev_name); > - if (eth_dev == NULL) > - return -ENOMEM; > + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > + eth_dev = rte_eth_dev_allocate(ethdev_name); > + if (eth_dev == NULL) > + return -ENOMEM; You could merge here the rest of primary init below. > + } else { > + eth_dev = eth_dev_attach_secondary(ethdev_name); > + if (eth_dev == NULL) { > + /* > + * if we failed to attach a device, it means > + * the device is skipped, due to some errors. > + * Take virtio-net device as example, it could > + * due to the device is managed by virtio-net > + * kernel driver. For such case, we return a > + * positive value, to let EAL skip it as well. > + */ I'm not sure we need an example here. Is the virtio case special? nit: "it could due" looks to be a typo > + return 1; > + } > + } > > if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > eth_dev->data->dev_private = rte_zmalloc("ethdev private structure",