From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 12A5358E8 for ; Mon, 9 Feb 2015 16:03:07 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 09 Feb 2015 06:59:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,544,1418112000"; d="scan'208";a="675145618" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by fmsmga002.fm.intel.com with ESMTP; 09 Feb 2015 07:03:04 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.64]) by IRSMSX151.ger.corp.intel.com ([169.254.4.84]) with mapi id 14.03.0195.001; Mon, 9 Feb 2015 15:03:04 +0000 From: "Iremonger, Bernard" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [PATCH v7 11/14] ethdev: Add one dev_type parameter to rte_eth_dev_allocate Thread-Index: AQHQRELdpZHaNWH2qEySXVZIYeXQoJzoaSww Date: Mon, 9 Feb 2015 15:03:03 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C2049DF0D5@IRSMSX108.ger.corp.intel.com> References: <1422763322-13742-4-git-send-email-mukawa@igel.co.jp> <1423470639-15744-1-git-send-email-mukawa@igel.co.jp> <1423470639-15744-12-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1423470639-15744-12-git-send-email-mukawa@igel.co.jp> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v7 11/14] ethdev: Add one dev_type parameter to rte_eth_dev_allocate 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: Mon, 09 Feb 2015 15:03:08 -0000 > -----Original Message----- > From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp] > Sent: Monday, February 9, 2015 8:31 AM > To: dev@dpdk.org > Cc: Iremonger, Bernard; Qiu, Michael; Tetsuya Mukawa > Subject: [PATCH v7 11/14] ethdev: Add one dev_type parameter to rte_eth_d= ev_allocate >=20 > This new parameter is needed to keep device type like physical or virtual= . > Port detaching processes are different between physical and virtual. > This parameter lets detaching function know a device type of the port. >=20 > v4: > - Fix comments of rte_eth_dev_type. >=20 > Signed-off-by: Tetsuya Mukawa > --- > app/test/virtual_pmd.c | 2 +- > lib/librte_ether/rte_ethdev.c | 14 ++++++++++++-- > lib/librte_ether/rte_ethdev.h | 25 ++++++++++++++++++++++= ++- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 2 +- > lib/librte_pmd_bond/rte_eth_bond_api.c | 2 +- > lib/librte_pmd_pcap/rte_eth_pcap.c | 2 +- > lib/librte_pmd_ring/rte_eth_ring.c | 2 +- > lib/librte_pmd_xenvirt/rte_eth_xenvirt.c | 2 +- > 8 files changed, 42 insertions(+), 9 deletions(-) >=20 > diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index 9fac95= d..8d3a5ff 100644 > --- a/app/test/virtual_pmd.c > +++ b/app/test/virtual_pmd.c > @@ -556,7 +556,7 @@ virtual_ethdev_create(const char *name, struct ether_= addr *mac_addr, > goto err; >=20 > /* reserve an ethdev entry */ > - eth_dev =3D rte_eth_dev_allocate(name); > + eth_dev =3D rte_eth_dev_allocate(name, RTE_ETH_DEV_PHYSICAL); > if (eth_dev =3D=3D NULL) > goto err; >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c index 14a040a..704185d > 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -232,7 +232,7 @@ rte_eth_dev_allocate_new_port(void) > } >=20 > struct rte_eth_dev * > -rte_eth_dev_allocate(const char *name) > +rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type) > { > uint8_t port_id; > struct rte_eth_dev *eth_dev; > @@ -256,6 +256,7 @@ rte_eth_dev_allocate(const char *name) > snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name); > eth_dev->data->port_id =3D port_id; > eth_dev->attached =3D DEV_CONNECTED; > + eth_dev->dev_type =3D type; > nb_ports++; > return eth_dev; > } > @@ -267,6 +268,7 @@ rte_eth_dev_free(struct rte_eth_dev *eth_dev) > return -EINVAL; >=20 > eth_dev->attached =3D 0; > + eth_dev->dev_type =3D RTE_ETH_DEV_UNKNOWN; > nb_ports--; > return 0; > } > @@ -287,7 +289,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv, > snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d", > pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); >=20 > - eth_dev =3D rte_eth_dev_allocate(ethdev_name); > + eth_dev =3D rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PHYSICAL); > if (eth_dev =3D=3D NULL) > return -ENOMEM; >=20 > @@ -426,6 +428,14 @@ rte_eth_dev_count(void) > return (nb_ports); > } >=20 > +enum rte_eth_dev_type > +rte_eth_dev_get_device_type(uint8_t port_id) { > + if (rte_eth_dev_validate_port(port_id, NONE_TRACE) =3D=3D DEV_INVALID) Hi Tetsuya, NO_TRACE would be better than NON_TRACE. > + return -1; > + return rte_eth_devices[port_id].dev_type; > +} > + > void > rte_eth_dev_save(struct rte_eth_dev *devs) { diff --git a/lib/librte_et= her/rte_ethdev.h > b/lib/librte_ether/rte_ethdev.h index 9919968..00a6218 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -1522,6 +1522,17 @@ struct eth_dev_ops { }; >=20 > /** > + * The eth device type > + */ > +enum rte_eth_dev_type { > + RTE_ETH_DEV_UNKNOWN, /**< unknown device type */ > + RTE_ETH_DEV_PHYSICAL, > + /**< Physical function and Virtual function devices of NIC */ > + RTE_ETH_DEV_VIRTUAL, /**< non hardware device */ > + RTE_ETH_DEV_MAX /**< max value of this enum */ > +}; > + > +/** > * @internal > * The generic data structure associated with each ethernet device. > * > @@ -1540,6 +1551,7 @@ struct rte_eth_dev { > struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */ > struct rte_eth_dev_cb_list callbacks; /**< User application callbacks *= / > uint8_t attached; /**< Flag indicating the port is attached */ > + enum rte_eth_dev_type dev_type; /**< Flag indicating the device type > +*/ > }; >=20 > struct rte_eth_dev_sriov { > @@ -1617,6 +1629,15 @@ extern uint8_t rte_eth_dev_count(void); >=20 > /** > * Function for internal use by port hotplug functions. > + * Get the device type to know whether the device is physical or virtual= . > + * @param port_id The pointer to the port id > + * @return > + * - Device type. > + */ > +extern enum rte_eth_dev_type rte_eth_dev_get_device_type(uint8_t > +port_id); > + > +/** > + * Function for internal use by port hotplug functions. > * Copies current ethdev structures to the specified pointer. > * > * @param devs The pointer to the ethdev structures > @@ -1702,10 +1723,12 @@ extern struct rte_eth_dev *rte_eth_dev_allocated(= const char *name); > * to that slot for the driver to use. > * > * @param name Unique identifier name for each Ethernet device > + * @param type Device type of this Ethernet device > * @return > * - Slot in the rte_dev_devices array for a new device; > */ > -struct rte_eth_dev *rte_eth_dev_allocate(const char *name); > +struct rte_eth_dev *rte_eth_dev_allocate(const char *name, > + enum rte_eth_dev_type type); >=20 > /** > * Function for internal use by dummy drivers primarily, e.g. ring-based= diff --git > a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet= /rte_eth_af_packet.c > index 1ffe1cd..80e9bdf 100644 > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > @@ -649,7 +649,7 @@ rte_pmd_init_internals(const char *name, > } >=20 > /* reserve an ethdev entry */ > - *eth_dev =3D rte_eth_dev_allocate(name); > + *eth_dev =3D rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL); > if (*eth_dev =3D=3D NULL) > goto error; >=20 > diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond= /rte_eth_bond_api.c > index 4ab3267..7a6a5f7 100644 > --- a/lib/librte_pmd_bond/rte_eth_bond_api.c > +++ b/lib/librte_pmd_bond/rte_eth_bond_api.c > @@ -235,7 +235,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, u= int8_t socket_id) > } >=20 > /* reserve an ethdev entry */ > - eth_dev =3D rte_eth_dev_allocate(name); > + eth_dev =3D rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL); > if (eth_dev =3D=3D NULL) { > RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev"); > goto err; > diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte= _eth_pcap.c > index d299288..af7fae8 100644 > --- a/lib/librte_pmd_pcap/rte_eth_pcap.c > +++ b/lib/librte_pmd_pcap/rte_eth_pcap.c > @@ -709,7 +709,7 @@ rte_pmd_init_internals(const char *name, const unsign= ed nb_rx_queues, > goto error; >=20 > /* reserve an ethdev entry */ > - *eth_dev =3D rte_eth_dev_allocate(name); > + *eth_dev =3D rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL); > if (*eth_dev =3D=3D NULL) > goto error; >=20 > diff --git a/lib/librte_pmd_ring/rte_eth_ring.c b/lib/librte_pmd_ring/rte= _eth_ring.c > index d5b1686..c837fcd 100644 > --- a/lib/librte_pmd_ring/rte_eth_ring.c > +++ b/lib/librte_pmd_ring/rte_eth_ring.c > @@ -255,7 +255,7 @@ rte_eth_from_rings(const char *name, struct rte_ring = *const rx_queues[], > goto error; >=20 > /* reserve an ethdev entry */ > - eth_dev =3D rte_eth_dev_allocate(name); > + eth_dev =3D rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL); > if (eth_dev =3D=3D NULL) > goto error; >=20 > diff --git a/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c b/lib/librte_pmd_xe= nvirt/rte_eth_xenvirt.c > index 04e30c9..bc403d6 100644 > --- a/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c > +++ b/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c > @@ -648,7 +648,7 @@ eth_dev_xenvirt_create(const char *name, const char *= params, > goto err; >=20 > /* reserve an ethdev entry */ > - eth_dev =3D rte_eth_dev_allocate(name); > + eth_dev =3D rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL); > if (eth_dev =3D=3D NULL) > goto err; >=20 > -- > 1.9.1 Regards, Bernard.