From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-5.cisco.com (alln-iport-5.cisco.com [173.37.142.92]) by dpdk.org (Postfix) with ESMTP id 52E311DB1 for ; Sun, 14 Jun 2015 01:25:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=16439; q=dns/txt; s=iport; t=1434237946; x=1435447546; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=5mS3sQDk+8kHT1OCToysHQH7HbJznohRKxX+qXUxWMI=; b=am6Z8MsatSvyfr5slOcSJSXUCbfxfwUn6lAT03MSjiEEw2mwKikgR5qY CKsCFvBqCI6EkdosX9J2l8gsMDjaCA1/xzc0SYxRRfD/9USMlW7vdXGW+ bCu8mcaRbRIUoo4X3OzwJV2g8kvpSvm+0ODGnyQRIpUDyjATH44x1BVoN A=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CRBAD2unxV/5tdJa1cgxCBMwa9dwmEJYM2AoEgOBQBAQEBAQEBgQqEIgEBAQQnEz8MBAIBCBEEAQELFAkHMhQJCAIEAQ0FCIgnyQcBAQEBAQEBAQEBAQEBAQEBAQEBAQEXi0SEGRQoMQcGgxGBFgWLewqHVgGJJYIdgTIUjk2HfCZjgSgcgVJvgQMJFyOBAQEBAQ X-IronPort-AV: E=Sophos;i="5.13,610,1427760000"; d="scan'208";a="159192380" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by alln-iport-5.cisco.com with ESMTP; 13 Jun 2015 23:25:39 +0000 Received: from xhc-rcd-x12.cisco.com (xhc-rcd-x12.cisco.com [173.37.183.86]) by rcdn-core-4.cisco.com (8.14.5/8.14.5) with ESMTP id t5DNPd9G032371 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Sat, 13 Jun 2015 23:25:39 GMT Received: from xmb-aln-x05.cisco.com ([169.254.11.78]) by xhc-rcd-x12.cisco.com ([173.37.183.86]) with mapi id 14.03.0195.001; Sat, 13 Jun 2015 18:25:39 -0500 From: "David Harton (dharton)" To: Liang-Min Larry Wang , "dev@dpdk.org" Thread-Topic: [PATCH v6 1/4] ethdev: add apis to support access device info Thread-Index: AQHQpVuUQ3DGOEbuB0mWZijVYyUjNp2rFU+g Date: Sat, 13 Jun 2015 23:25:39 +0000 Message-ID: References: <1432946276-9424-1-git-send-email-liang-min.wang@intel.com> <1434146585-14472-1-git-send-email-liang-min.wang@intel.com> <1434146585-14472-2-git-send-email-liang-min.wang@intel.com> In-Reply-To: <1434146585-14472-2-git-send-email-liang-min.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.82.209.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v6 1/4] ethdev: add apis to support access device info 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: Sat, 13 Jun 2015 23:25:47 -0000 > -----Original Message----- > From: Liang-Min Larry Wang [mailto:liang-min.wang@intel.com] > Sent: Friday, June 12, 2015 6:03 PM > To: dev@dpdk.org > Cc: Andrew Harvey (agh); David Harton (dharton); Roger Melton (rmelton); > Liang-Min Larry Wang > Subject: [PATCH v6 1/4] ethdev: add apis to support access device info >=20 > add new apis: > - rte_eth_dev_default_mac_addr_set > - rte_eth_dev_reg_length > - rte_eth_dev_reg_info > - rte_eth_dev_eeprom_length > - rte_eth_dev_get_eeprom > - rte_eth_dev_set_eeprom > - rte_eth_dev_get_ringparam >=20 > to enable reading device parameters (mac-addr, register, > eeprom, ring) based upon ethtool alike > data parameter specification. >=20 > Signed-off-by: Liang-Min Larry Wang > --- > lib/librte_ether/Makefile | 1 + > lib/librte_ether/rte_eth_dev_info.h | 67 +++++++++++++++ > lib/librte_ether/rte_ethdev.c | 134 > ++++++++++++++++++++++++++++++ > lib/librte_ether/rte_ethdev.h | 144 > +++++++++++++++++++++++++++++++++ > lib/librte_ether/rte_ether_version.map | 7 ++ > 5 files changed, 353 insertions(+) > create mode 100644 lib/librte_ether/rte_eth_dev_info.h >=20 > diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile > index c0e5768..05209e9 100644 > --- a/lib/librte_ether/Makefile > +++ b/lib/librte_ether/Makefile > @@ -51,6 +51,7 @@ SRCS-y +=3D rte_ethdev.c > SYMLINK-y-include +=3D rte_ether.h > SYMLINK-y-include +=3D rte_ethdev.h > SYMLINK-y-include +=3D rte_eth_ctrl.h > +SYMLINK-y-include +=3D rte_eth_dev_info.h >=20 > # this lib depends upon: > DEPDIRS-y +=3D lib/librte_eal lib/librte_mempool lib/librte_ring > lib/librte_mbuf > diff --git a/lib/librte_ether/rte_eth_dev_info.h > b/lib/librte_ether/rte_eth_dev_info.h > new file mode 100644 > index 0000000..1cf2c23 > --- /dev/null > +++ b/lib/librte_ether/rte_eth_dev_info.h > @@ -0,0 +1,67 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright(c) 2015 Intel Corporation. All rights reserved. > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * > + * * Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * * Redistributions in binary form must reproduce the above > copyright > + * notice, this list of conditions and the following disclaimer in > + * the documentation and/or other materials provided with the > + * distribution. > + * * Neither the name of Intel Corporation nor the names of its > + * contributors may be used to endorse or promote products derived > + * from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS > FOR > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGH= T > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON > ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE > USE > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE= . > + */ > + > +#ifndef _RTE_ETH_DEV_INFO_H_ > +#define _RTE_ETH_DEV_INFO_H_ > + > +/* > + * Placeholder for accessing device registers > + */ > +struct rte_dev_reg_info { > + void *buf; /**< Buffer for register */ > + uint32_t offset; /**< Offset for 1st register to fetch */ > + uint32_t leng; /**< Number of registers to fetch */ > + uint32_t version; /**< Device version */ > +}; > + > +/* > + * Placeholder for accessing device eeprom > + */ > +struct rte_dev_eeprom_info { > + void *buf; /**< Buffer for eeprom */ > + uint32_t offset; /**< Offset for 1st eeprom location to access */ > + uint32_t leng; /**< Length of eeprom region to access */ > + uint32_t magic; /**< Device ID */ > +}; > + > +/* > + * Placeholder for accessing device ring parameters > + */ > +struct rte_dev_ring_info { > + uint32_t rx_pending; /**< Number of outstanding Rx ring */ > + uint32_t tx_pending; /**< Number of outstanding Tx ring */ > + uint32_t rx_max_pending; /**< Maximum number of outstanding Rx ring > */ > + uint32_t tx_max_pending; /**< Maximum number of outstanding Tx ring > */ > +}; > + > +#endif /* _RTE_ETH_DEV_INFO_H_ */ > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c > index e13fde5..27c9215 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -2751,6 +2751,30 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struc= t > ether_addr *addr) > } >=20 > int > +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr > *addr) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -ENODEV; > + } > + > + if (!is_valid_assigned_ether_addr(addr)) > + return -EINVAL; > + > + dev =3D &rte_eth_devices[port_id]; > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); > + > + /* Update default address in NIC data structure */ > + ether_addr_copy(addr, &dev->data->mac_addrs[0]); > + > + (*dev->dev_ops->mac_addr_set)(dev, addr); > + > + return 0; > +} > + > +int > rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf, > uint16_t rx_mode, uint8_t on) > { > @@ -3644,3 +3668,113 @@ rte_eth_dev_set_mc_addr_list(uint8_t port_id, > FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP); > return dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr); > } > + > +int > +rte_eth_dev_reg_length(uint8_t port_id) > +{ > + struct rte_eth_dev *dev; > + > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } > + > + dev =3D &rte_eth_devices[port_id]; > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg_length, -ENOTSUP); > + return (*dev->dev_ops->get_reg_length)(dev); > +} > + > +int > +rte_eth_dev_reg_info(uint8_t port_id, struct rte_dev_reg_info *info) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -ENODEV; > + } > + > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } > + > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg, -ENOTSUP); > + return (*dev->dev_ops->get_reg)(dev, info); > +} > + > +int > +rte_eth_dev_eeprom_length(uint8_t port_id) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -ENODEV; > + } > + > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } > + > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom_length, -ENOTSUP); > + return (*dev->dev_ops->get_eeprom_length)(dev); > +} > + > +int > +rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info= ) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -ENODEV; > + } > + > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } > + > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP); > + return (*dev->dev_ops->get_eeprom)(dev, info); > +} > + > +int > +rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info= ) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -ENODEV; > + } > + > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } > + > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP); > + return (*dev->dev_ops->set_eeprom)(dev, info); > +} > + > +int > +rte_eth_dev_get_ringparam(uint8_t port_id, struct rte_dev_ring_info > *info) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > + return -ENODEV; > + } > + > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } > + > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_ringparam, -ENOTSUP); > + return (*dev->dev_ops->get_ringparam)(dev, info); > +} > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.= h > index 04c192d..c9e629d 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -182,6 +182,7 @@ extern "C" { > #include > #include "rte_ether.h" > #include "rte_eth_ctrl.h" > +#include "rte_eth_dev_info.h" >=20 > struct rte_mbuf; >=20 > @@ -1233,6 +1234,32 @@ typedef int (*eth_set_mc_addr_list_t)(struct > rte_eth_dev *dev, > uint32_t nb_mc_addr); > /**< @internal set the list of multicast addresses on an Ethernet device > */ >=20 > +typedef int (*eth_get_reg_length_t)(struct rte_eth_dev *dev); > +/**< @internal Retrieve device register count */ > + > +typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev, > + struct rte_dev_reg_info *info); > +/**< @internal Retrieve registers */ > + > +typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev); > +/**< @internal Retrieve eeprom size */ > + > +typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev, > + struct rte_dev_eeprom_info *info); > +/**< @internal Retrieve eeprom data */ > + > +typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev, > + struct rte_dev_eeprom_info *info); > +/**< @internal Program eeprom data */ > + > +typedef int (*eth_get_ringparam_t)(struct rte_eth_dev *dev, > + struct rte_dev_ring_info *info); > +/**< @internal Retrieve device ring descriptor */ > + > +typedef int (*eth_set_ringparam_t)(struct rte_eth_dev *dev, > + struct rte_dev_ring_info *info); > +/**< @internal Set device ring descriptor */ > + > #ifdef RTE_NIC_BYPASS >=20 > enum { > @@ -1372,6 +1399,21 @@ struct eth_dev_ops { > reta_update_t reta_update; > /** Query redirection table. */ > reta_query_t reta_query; > + > + eth_get_reg_length_t get_reg_length; > + /**< Get # of registers */ > + eth_get_reg_t get_reg; > + /**< Get registers */ > + eth_get_eeprom_length_t get_eeprom_length; > + /**< Get eeprom length */ > + eth_get_eeprom_t get_eeprom; > + /**< Get eeprom data */ > + eth_set_eeprom_t set_eeprom; > + /**< Set eeprom */ > + eth_get_ringparam_t get_ringparam; > + /**< Get descriptor ring parameters */ > + eth_set_ringparam_t set_ringparam; > + /**< Set descriptor ring parameters */ > /* bypass control */ > #ifdef RTE_NIC_BYPASS > bypass_init_t bypass_init; > @@ -2987,6 +3029,20 @@ int rte_eth_dev_mac_addr_add(uint8_t port, struct > ether_addr *mac_addr, > int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr > *mac_addr); >=20 > /** > + * Set the default MAC address. > + * > + * @param port > + * The port identifier of the Ethernet device. > + * @param mac_addr > + * New default MAC address. > + * @return > + * - (0) if successful, or *mac_addr* didn't exist. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port* invalid. > + */ > +int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr > *mac_addr); > + > +/** > * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet > device. > * > * @param port > @@ -3616,6 +3672,94 @@ int rte_eth_remove_rx_callback(uint8_t port_id, > uint16_t queue_id, > int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id, > struct rte_eth_rxtx_callback *user_cb); >=20 > +/** > + * Retrieve number of available registers for access > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @return > + * - (>=3D0) number of registers if successful. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port_id* invalid. > + * - others depends on the specific operations implementation. > + */ > +int rte_eth_dev_reg_length(uint8_t port_id); > + > +/** > + * Retrieve device registers and register attributes > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param info > + * The template includes buffer for register data and attribute to be > filled. > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port_id* invalid. > + * - others depends on the specific operations implementation. > + */ > +int rte_eth_dev_reg_info(uint8_t port_id, struct rte_dev_reg_info *info)= ; > + > +/** > + * Retrieve size of device EEPROM > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @return > + * - (>=3D0) EEPROM size if successful. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port_id* invalid. > + * - others depends on the specific operations implementation. > + */ > +int rte_eth_dev_eeprom_length(uint8_t port_id); > + > +/** > + * Retrieve EEPROM and EEPROM attribute > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param info > + * The template includes buffer for return EEPROM data and > + * EEPROM attributes to be filled. > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port_id* invalid. > + * - others depends on the specific operations implementation. > + */ > +int rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info > *info); > + > +/** > + * Program EEPROM with provided data > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param info > + * The template includes EEPROM data for programming and > + * EEPROM attributes to be filled > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port_id* invalid. > + * - others depends on the specific operations implementation. > + */ > +int rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info > *info); > + > +/** > + * Retrieve device descriptor ring information > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param info > + * The template includes device ring descriptor usage information. > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if hardware doesn't support. > + * - (-ENODEV) if *port_id* invalid. > + * - others depends on the specific operations implementation. > + */ > +int rte_eth_dev_get_ringparam(uint8_t port_id, struct rte_dev_ring_info > *info); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_ether/rte_ether_version.map > b/lib/librte_ether/rte_ether_version.map > index 012a82e..f75f3d1 100644 > --- a/lib/librte_ether/rte_ether_version.map > +++ b/lib/librte_ether/rte_ether_version.map > @@ -102,6 +102,13 @@ DPDK_2.0 { > rte_eth_tx_queue_setup; > rte_eth_xstats_get; > rte_eth_xstats_reset; > + rte_eth_dev_default_mac_addr_set; > + rte_eth_dev_reg_length; > + rte_eth_dev_reg_info; > + rte_eth_dev_eeprom_length; > + rte_eth_dev_get_eeprom; > + rte_eth_dev_set_eeprom; > + rte_eth_dev_get_ringparam; >=20 > local: *; > }; > -- > 2.1.4 Acked-by: David Harton (dharton)