From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 95078ADDB for ; Mon, 23 Feb 2015 12:06:40 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 23 Feb 2015 03:05:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,630,1418112000"; d="scan'208";a="531374534" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by orsmga003.jf.intel.com with ESMTP; 23 Feb 2015 02:56:27 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.218]) by IRSMSX153.ger.corp.intel.com ([169.254.9.234]) with mapi id 14.03.0195.001; Mon, 23 Feb 2015 11:01:54 +0000 From: "Iremonger, Bernard" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [PATCH v11 08/13] ethdev: Add functions that will be used by port hotplug functions Thread-Index: AQHQTycGXLrs6bSSiES9nYKnm59F75z+EQVA Date: Mon, 23 Feb 2015 11:01:53 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C2049EBD15@IRSMSX108.ger.corp.intel.com> References: <1424414390-18509-6-git-send-email-mukawa@igel.co.jp> <1424668171-8695-1-git-send-email-mukawa@igel.co.jp> <1424668171-8695-9-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1424668171-8695-9-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 v11 08/13] ethdev: Add functions that will be used by port hotplug functions 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, 23 Feb 2015 11:06:41 -0000 > -----Original Message----- > From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp] > Sent: Monday, February 23, 2015 5:09 AM > To: dev@dpdk.org > Cc: Qiu, Michael; Iremonger, Bernard; maxime.leroy@6wind.com; Tetsuya Muk= awa > Subject: [PATCH v11 08/13] ethdev: Add functions that will be used by por= t hotplug functions >=20 > The patch adds following functions. >=20 > - rte_eth_dev_save() > The function is used for saving current rte_eth_dev structures. > - rte_eth_dev_get_changed_port() > The function receives the rte_eth_dev structures, then compare > these with current values to know which port is actually > attached or detached. > - rte_eth_dev_get_addr_by_port() > The function returns a pci address of an ethdev specified by port > identifier. > - rte_eth_dev_get_port_by_addr() > The function returns a port identifier of an ethdev specified by > pci address. > - rte_eth_dev_get_name_by_port() > The function returns a unique identifier name of an ethdev > specified by port identifier. > - Add rte_eth_dev_is_detachable() > The function returns whether a PMD supports detach function. >=20 > Also, the patch changes scope of rte_eth_dev_allocated() to global. > This function will be called by virtual PMDs to support port hotplug. > So change scope of the function to global. >=20 > v10: > - Change order of version.map. > (Thanks to Thomas Monjalon) > v9: > - rte_eth_dev_check_detachable() is replaced by > rte_eth_dev_is_detachable(). > - strncpy() is replaced by strcpy(). > (Thanks to Thomas Monjalon) > - Add missing symbol in version map. > (Thanks to Nail Horman) > v8: > - Add size parameter to rte_eth_dev_save(). > - Add missing symbol in version map. > (Thanks to Qiu, Michael and Iremonger, Bernard) > v7: > - Add pt_driver checking to rte_eth_dev_check_detachable(). > (Thanks to Qiu, Michael) > v5: > - Fix return value of below functions. > rte_eth_dev_get_changed_port(). > rte_eth_dev_get_port_by_addr(). > v4: > - Add parameter checking. > v3: > - Fix if-condition bug while comparing pci addresses. > - Add error checking codes. > Reported-by: Mark Enright >=20 > Signed-off-by: Tetsuya Mukawa > --- > lib/librte_ether/rte_ethdev.c | 103 +++++++++++++++++++++++++++= +++++- > lib/librte_ether/rte_ethdev.h | 83 ++++++++++++++++++++++++++ > lib/librte_ether/rte_ether_version.map | 7 +++ > 3 files changed, 192 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c index 3d148e2..7067620 > 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -201,7 +201,7 @@ rte_eth_dev_data_alloc(void) > RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data)); } >=20 > -static struct rte_eth_dev * > +struct rte_eth_dev * > rte_eth_dev_allocated(const char *name) { > unsigned i; > @@ -426,6 +426,107 @@ rte_eth_dev_count(void) > return (nb_ports); > } >=20 > +int > +rte_eth_dev_save(struct rte_eth_dev *devs, size_t size) { > + if ((devs =3D=3D NULL) || > + (size !=3D sizeof(struct rte_eth_dev) * RTE_MAX_ETHPORTS)) > + return -EINVAL; > + > + /* save current rte_eth_devices */ > + memcpy(devs, rte_eth_devices, size); > + return 0; > +} > + > +int > +rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t > +*port_id) { > + if ((devs =3D=3D NULL) || (port_id =3D=3D NULL)) > + return -EINVAL; > + > + /* check which port was attached or detached */ > + for (*port_id =3D 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs++)= { > + if (rte_eth_devices[*port_id].attached ^ devs->attached) > + return 0; > + } > + return -ENODEV; > +} > + > +int > +rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr > +*addr) { > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -EINVAL; > + } > + > + if (addr =3D=3D NULL) { > + PMD_DEBUG_TRACE("Null pointer is specified\n"); > + return -EINVAL; > + } > + > + *addr =3D rte_eth_devices[port_id].pci_dev->addr; > + return 0; > +} > + > +int > +rte_eth_dev_get_port_by_addr(struct rte_pci_addr *addr, uint8_t > +*port_id) { > + struct rte_pci_addr *tmp; > + > + if ((addr =3D=3D NULL) || (port_id =3D=3D NULL)) { > + PMD_DEBUG_TRACE("Null pointer is specified\n"); > + return -EINVAL; > + } > + > + for (*port_id =3D 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++) { > + if (!rte_eth_devices[*port_id].attached) > + continue; > + if (!rte_eth_devices[*port_id].pci_dev) > + continue; > + tmp =3D &rte_eth_devices[*port_id].pci_dev->addr; > + if (rte_eal_compare_pci_addr(tmp, addr) =3D=3D 0) > + return 0; > + } > + return -ENODEV; > +} > + > +int > +rte_eth_dev_get_name_by_port(uint8_t port_id, char *name) { > + char *tmp; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -EINVAL; > + } > + > + if (name =3D=3D NULL) { > + PMD_DEBUG_TRACE("Null pointer is specified\n"); > + return -EINVAL; > + } > + > + /* shouldn't check 'rte_eth_devices[i].data', > + * because it might be overwritten by VDEV PMD */ > + tmp =3D rte_eth_dev_data[port_id].name; > + strcpy(name, tmp); > + return 0; > +} > + > +int > +rte_eth_dev_is_detachable(uint8_t port_id) { > + uint32_t drv_flags; > + > + if (port_id >=3D RTE_MAX_ETHPORTS) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -EINVAL; > + } > + > + drv_flags =3D rte_eth_devices[port_id].driver->pci_drv.drv_flags; > + return !(drv_flags & RTE_PCI_DRV_DETACHABLE); } > + > static int > rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)= { diff --git > a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 6cb= a06d..d4cfafb 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -1476,6 +1476,89 @@ extern struct rte_eth_dev rte_eth_devices[]; exte= rn uint8_t > rte_eth_dev_count(void); >=20 > /** > + * Function for internal use by port hotplug functions. > + * Copies current ethdev structures to the specified pointer. > + * > + * @param devs The pointer to the ethdev structures > + * @param size The size of ethdev structures > + * @return > + * - 0 on success, negative on error > + */ > +extern int rte_eth_dev_save(struct rte_eth_dev *devs, size_t size); > + > +/** > + * Function for internal use by port hotplug functions. > + * Compare the specified ethdev structures with currents. Then > + * if there is a port which status is changed, fill the specified > +pointer > + * with the port id of that port. > + * @param devs The pointer to the ethdev structures > + * @param port_id The pointer to the port id > + * @return > + * - 0 on success, negative on error > + */ > +extern int rte_eth_dev_get_changed_port( > + struct rte_eth_dev *devs, uint8_t *port_id); > + > +/** > + * Function for internal use by port hotplug functions. > + * Returns a pci address of a ethdev specified by port identifier. > + * @param port_id > + * The port identifier of the Ethernet device > + * @param addr > + * The pointer to the pci address > + * @return > + * - 0 on success, negative on error > + */ > +extern int rte_eth_dev_get_addr_by_port( > + uint8_t port_id, struct rte_pci_addr *addr); > + > +/** > + * Function for internal use by port hotplug functions. > + * Returns a port identifier of a ethdev specified by pci address. > + * @param addr > + * The pointer to the pci address of the Ethernet device. > + * @param port_id > + * The pointer to the port identifier > + * @return > + * - 0 on success, negative on error > + */ > +extern int rte_eth_dev_get_port_by_addr( > + struct rte_pci_addr *addr, uint8_t *port_id); > + > +/** > + * Function for internal use by port hotplug functions. > + * Returns a unique identifier name of a ethdev specified by port identi= fier. > + * @param port_id > + * The port identifier. > + * @param name > + * The pointer to the Unique identifier name for each Ethernet device > + * @return > + * - 0 on success, negative on error > + */ > +extern int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name); > + > +/** > + * Function for internal use by port hotplug functions. > + * Check whether or not, a PMD that is handling the ethdev specified by > +port > + * identifier can support detach function. > + * @param port_id > + * The port identifier > + * @return > + * - 0 on supporting detach function, negative on not supporting > + */ > +extern int rte_eth_dev_is_detachable(uint8_t port_id); > + > +/** > + * Function for internal use by port hotplug functions. > + * Returns a ethdev slot specified by the unique identifier name. > + * @param name > + * The pointer to the Unique identifier name for each Ethernet device > + * @return > + * - The pointer to the ethdev slot, on success. NULL on error > + */ > +extern struct rte_eth_dev *rte_eth_dev_allocated(const char *name); > + > +/** > * Function for internal use by dummy drivers primarily, e.g. ring-based > * driver. > * Allocates a new ethdev slot for an ethernet device and returns the po= inter diff --git > a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_ver= sion.map > index f66fd2d..099c769 100644 > --- a/lib/librte_ether/rte_ether_version.map > +++ b/lib/librte_ether/rte_ether_version.map > @@ -6,6 +6,7 @@ DPDK_2.0 { > rte_eth_allmulticast_enable; > rte_eth_allmulticast_get; > rte_eth_dev_allocate; > + rte_eth_dev_allocated; > rte_eth_dev_bypass_event_show; > rte_eth_dev_bypass_event_store; > rte_eth_dev_bypass_init; > @@ -32,9 +33,14 @@ DPDK_2.0 { > rte_eth_dev_filter_supported; > rte_eth_dev_flow_ctrl_get; > rte_eth_dev_flow_ctrl_set; > + rte_eth_dev_get_addr_by_port; > + rte_eth_dev_get_changed_port; Hi Tetsuya, rte_eth_dev_get_device_type; needs to be added to rte_ether_version map to solve linking issue. Regards, Bernard. > rte_eth_dev_get_mtu; > + rte_eth_dev_get_name_by_port; > + rte_eth_dev_get_port_by_addr; > rte_eth_dev_get_vlan_offload; > rte_eth_dev_info_get; > + rte_eth_dev_is_detachable; > rte_eth_dev_mac_addr_add; > rte_eth_dev_mac_addr_remove; > rte_eth_dev_priority_flow_ctrl_set; > @@ -44,6 +50,7 @@ DPDK_2.0 { > rte_eth_dev_rss_reta_update; > rte_eth_dev_rx_queue_start; > rte_eth_dev_rx_queue_stop; > + rte_eth_dev_save; > rte_eth_dev_set_link_down; > rte_eth_dev_set_link_up; > rte_eth_dev_set_mtu; > -- > 1.9.1