All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] User-space Ethtool
@ 2015-05-29 13:15 Liang-Min Larry Wang
  2015-05-29 13:15 ` [PATCH 1/2] ethdev: add api to set default mac address Liang-Min Larry Wang
  2015-05-29 13:15 ` [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs Liang-Min Larry Wang
  0 siblings, 2 replies; 9+ messages in thread
From: Liang-Min Larry Wang @ 2015-05-29 13:15 UTC (permalink / raw)
  To: dev; +Cc: aharton, bruce.richardson, Liang-Min Larry Wang

This implementation is designed to provide a familar interface for applications that rely on kernel-space driver to support ethtool_op and net_device_op for device management. The initial implementation focuses on ops that can be implemented through existing netdev APIs. More ops will be supported in latter release.


Liang-Min Larry Wang (2):
  ethdev: add api to set default mac address
  ethtool: add new library to provide ethtool-alike APIs

 MAINTAINERS                                |   4 +
 config/common_linuxapp                     |   5 +
 lib/Makefile                               |   1 +
 lib/librte_ether/rte_ethdev.c              |  26 +++
 lib/librte_ether/rte_ethdev.h              |  14 ++
 lib/librte_ether/rte_ether_version.map     |   1 +
 lib/librte_ethtool/Makefile                |  56 +++++++
 lib/librte_ethtool/rte_ethtool.c           | 155 +++++++++++++++++
 lib/librte_ethtool/rte_ethtool.h           | 257 +++++++++++++++++++++++++++++
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk                              |   1 +
 11 files changed, 538 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

-- 
2.1.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ethdev: add api to set default mac address
  2015-05-29 13:15 [PATCH 0/2] User-space Ethtool Liang-Min Larry Wang
@ 2015-05-29 13:15 ` Liang-Min Larry Wang
  2015-05-29 15:20   ` Stephen Hemminger
  2015-05-29 13:15 ` [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs Liang-Min Larry Wang
  1 sibling, 1 reply; 9+ messages in thread
From: Liang-Min Larry Wang @ 2015-05-29 13:15 UTC (permalink / raw)
  To: dev; +Cc: aharton, bruce.richardson, Liang-Min Larry Wang

add a new api: rte_eth_dev_default_mac_addr_set to
support changing default mac address of a NIC

Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 26 ++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 14 ++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 3 files changed, 41 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 024fe8b..850b83c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2752,6 +2752,32 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
 }
 
 int
+rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
+{
+	struct rte_eth_dev *dev;
+	const int index = 0;
+	const uint32_t pool = 0;
+
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return -ENODEV;
+	}
+
+	dev = &rte_eth_devices[port_id];
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
+
+	/* Update NIC default MAC address*/
+	(*dev->dev_ops->mac_addr_remove)(dev, index);
+	(*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
+
+	/* Update default address in NIC data structure */
+	ether_addr_copy(addr, &dev->data->mac_addrs[index]);
+
+	return 0;
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
 				uint16_t rx_mode, uint8_t on)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..5f07e0d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2982,6 +2982,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);
 
 /**
+ * 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
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a2d25a6..2dbbaa7 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -102,6 +102,7 @@ DPDK_2.0 {
 	rte_eth_tx_queue_setup;
 	rte_eth_xstats_get;
 	rte_eth_xstats_reset;
+	rte_eth_dev_default_mac_addr_set;
 
 	local: *;
 };
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs
  2015-05-29 13:15 [PATCH 0/2] User-space Ethtool Liang-Min Larry Wang
  2015-05-29 13:15 ` [PATCH 1/2] ethdev: add api to set default mac address Liang-Min Larry Wang
@ 2015-05-29 13:15 ` Liang-Min Larry Wang
  2015-05-29 15:22   ` Stephen Hemminger
  1 sibling, 1 reply; 9+ messages in thread
From: Liang-Min Larry Wang @ 2015-05-29 13:15 UTC (permalink / raw)
  To: dev; +Cc: aharton, bruce.richardson, Liang-Min Larry Wang

adding a new library based upon ethdev APIs to provide API's that bear
the same functionality as ethtool_ops (linux/ethtool.h) and net_device_ops
(linux/netdevice.h).

Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
---
 MAINTAINERS                                |   4 +
 config/common_linuxapp                     |   5 +
 lib/Makefile                               |   1 +
 lib/librte_ethtool/Makefile                |  56 +++++++
 lib/librte_ethtool/rte_ethtool.c           | 155 +++++++++++++++++
 lib/librte_ethtool/rte_ethtool.h           | 257 +++++++++++++++++++++++++++++
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk                              |   1 +
 8 files changed, 497 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 9362c19..b8b481f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -186,6 +186,10 @@ M: Thomas Monjalon <thomas.monjalon@6wind.com>
 F: lib/librte_ether/
 F: scripts/test-null.sh
 
+Ethtool API
+M: Liang-Min Larry Wang <liang-min.wang@intel.com>
+F: lib/librte_ethtool/
+
 
 Drivers
 -------
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..f5759fd 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -129,6 +129,11 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
 CONFIG_RTE_LIBRTE_KVARGS=y
 
 #
+# Compile user-space ethtool library
+#
+CONFIG_RTE_LIBRTE_ETHTOOL=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/lib/Makefile b/lib/Makefile
index 5f480f9..a6c7375 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer
 DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
 DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
+DIRS-$(CONFIG_RTE_LIBRTE_ETHTOOL) += librte_ethtool
 DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
diff --git a/lib/librte_ethtool/Makefile b/lib/librte_ethtool/Makefile
new file mode 100644
index 0000000..1d981f6
--- /dev/null
+++ b/lib/librte_ethtool/Makefile
@@ -0,0 +1,56 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-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 COPYRIGHT
+#   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.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ethtool.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_ethtool_version.map
+
+LIBABIVER := 1
+
+SRCS-y += rte_ethtool.c
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_ethtool.h
+
+# this lib depends upon:
+DEPDIRS-y += lib/librte_ether
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_ethtool/rte_ethtool.c b/lib/librte_ethtool/rte_ethtool.c
new file mode 100644
index 0000000..2ccf06f
--- /dev/null
+++ b/lib/librte_ethtool/rte_ethtool.c
@@ -0,0 +1,155 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-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 COPYRIGHT
+ *   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.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <rte_version.h>
+#include <rte_ethdev.h>
+#include "rte_ethtool.h"
+
+int
+rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
+{
+	struct rte_eth_dev_info dev_info;
+
+	memset(&dev_info, 0, sizeof(dev_info));
+	rte_eth_dev_info_get(port_id, &dev_info);
+
+	snprintf(drvinfo->driver, sizeof(drvinfo->driver), "%s",
+		dev_info.driver_name);
+	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
+		rte_version());
+	snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
+		"%04x:%02x:%02x.%x",
+		dev_info.pci_dev->addr.domain, dev_info.pci_dev->addr.bus,
+		dev_info.pci_dev->addr.devid, dev_info.pci_dev->addr.function);
+
+	drvinfo->n_stats = sizeof(struct rte_eth_stats) / sizeof(uint64_t);
+	drvinfo->testinfo_len = 0;
+
+	return 0;
+}
+
+int
+rte_ethtool_get_link(uint8_t port_id)
+{
+	struct rte_eth_link link;
+
+	rte_eth_link_get(port_id, &link);
+	return link.link_status;
+}
+
+int
+rte_ethtool_net_open(uint8_t port_id)
+{
+	rte_eth_dev_stop(port_id);
+
+	return rte_eth_dev_start(port_id);
+}
+
+int
+rte_ethtool_net_stop(uint8_t port_id)
+{
+	rte_eth_dev_stop(port_id);
+
+	return 0;
+}
+
+int
+rte_ethtool_net_get_mac_addr(uint8_t port_id, struct ether_addr *addr)
+{
+	rte_eth_macaddr_get(port_id, addr);
+
+	return 0;
+}
+
+int
+rte_ethtool_net_set_mac_addr(uint8_t port_id, struct ether_addr *addr)
+{
+	return rte_eth_dev_default_mac_addr_set(port_id, addr);
+}
+
+int
+rte_ethtool_net_validate_addr(uint8_t port_id __rte_unused,
+	struct ether_addr *addr)
+{
+	return is_valid_assigned_ether_addr(addr);
+}
+
+int
+rte_ethtool_net_set_config(uint8_t port_id, void *config __rte_unused)
+{
+	struct rte_eth_link link;
+
+	memset(&link, 0, sizeof(link));
+	rte_eth_link_get(port_id, &link);
+	if (link.link_status == 1)
+		return -EINVAL;
+	return 0;
+}
+
+int
+rte_ethtool_net_change_mtu(uint8_t port_id, int mtu)
+{
+	return rte_eth_dev_set_mtu(port_id, (uint16_t)mtu);
+}
+
+int
+rte_ethtool_net_get_stats64(uint8_t port_id, struct rte_eth_stats *stats)
+{
+	return rte_eth_stats_get(port_id, stats);
+}
+
+int
+rte_ethtool_net_vlan_rx_add_vid(uint8_t port_id, uint16_t vid)
+{
+	return rte_eth_dev_vlan_filter(port_id, vid, 1);
+}
+
+int
+rte_ethtool_net_vlan_rx_kill_vid(uint8_t port_id, uint16_t vid)
+{
+	return rte_eth_dev_vlan_filter(port_id, vid, 0);
+}
+
+int
+rte_ethtool_net_set_rx_mode(uint8_t port_id __rte_unused)
+{
+	/*
+	 * The set_rx_mode op is part of pmd driver start operation, and
+	 * the ethdev api maintains software configuration parameters and under-
+	 * line hardware states consistent, so no operation is needed for
+	 * rte_ethtool_net_set_rx_mode().
+	 */
+	return 0;
+}
diff --git a/lib/librte_ethtool/rte_ethtool.h b/lib/librte_ethtool/rte_ethtool.h
new file mode 100644
index 0000000..0488e8e
--- /dev/null
+++ b/lib/librte_ethtool/rte_ethtool.h
@@ -0,0 +1,257 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-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 COPYRIGHT
+ *   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_ETHTOOL_H_
+#define _RTE_ETHTOOL_H_
+
+/*
+ * This new interface is designed to provide a user-space shim layer for
+ * Ethtool and Netdevice op API.
+ *
+ * rte_ethtool_get_driver:          ethtool_ops::get_driverinfo
+ * rte_ethtool_get_link:            ethtool_ops::get_link
+ *
+ * rte_ethtool_net_open:            net_device_ops::ndo_open
+ * rte_ethtool_net_stop:            net_device_ops::ndo_stop
+ * rte_ethtool_net_set_mac_addr:    net_device_ops::ndo_set_mac_address
+ * rte_ethtool_net_validate_addr:   net_device_ops::ndo_validate_addr
+ * rte_ethtool_net_set_config:      net_device_ops::ndo_set_config
+ * rte_ethtool_net_change_mtu:      net_device_ops::rte_net_change_mtu
+ * rte_ethtool_net_get_stats64:     net_device_ops::ndo_get_stats64
+ * rte_ethtool_net_vlan_rx_add_vid  net_device_ops::ndo_vlan_rx_add_vid
+ * rte_ethtool_net_vlan_rx_kill_vid net_device_ops::ndo_vlan_rx_kill_vid
+ * rte_ethtool_net_set_rx_mode      net_device_ops::ndo_set_rx_mode
+ *
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+#include <linux/ethtool.h>
+
+/**
+ * Retrieve the Ethernet device driver information according to attributes described by
+ * ethtool data structure, ethtool_drvinfo
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param drvinfo
+ *   A pointer to get driver 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_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo);
+
+/**
+ * Retrieve the Ethernet device link status
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @return
+ *   - (1) if link up.
+ *   - (0) if link down.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_get_link(uint8_t port_id);
+
+/**
+ * Start the Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_open(uint8_t port_id);
+
+/**
+ * Stop the Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_stop(uint8_t port_id);
+
+/**
+ * Get the Ethernet device MAC address.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param addr
+ *	 MAC address of the Ethernet device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_get_mac_addr(uint8_t port_id, struct ether_addr *addr);
+
+/**
+ * Setting the Ethernet device MAC address.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param addr
+ *	 The new MAC addr.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_set_mac_addr(uint8_t port_id, struct ether_addr *addr);
+
+/**
+ * Validate if the provided MAC address is valid unicast address
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param addr
+ *	 A pointer to a buffer (6-byte, 48bit) for the target MAC address
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_validate_addr(uint8_t port_id, struct ether_addr *addr);
+
+/**
+ * Setting the Ethernet device configuration.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param config
+ *	 A opintr to a configuration parameter.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_set_config(uint8_t port_id, void *config);
+
+/**
+ * Setting the Ethernet device maximum Tx unit.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param mtu
+ *	 New MTU
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_change_mtu(uint8_t port_id, int mtu);
+
+/**
+ * Retrieve the Ethernet device traffic statistics
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param stats
+ *	 A pointer to struct rte_eth_stats for statistics parameters
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_get_stats64(uint8_t port_id, struct rte_eth_stats *stats);
+
+/**
+ * Update the Ethernet device VLAN filter with new vid
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param vid
+ *	 A new VLAN id
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_vlan_rx_add_vid(uint8_t port_id, uint16_t vid);
+
+/**
+ * Remove VLAN id from Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param vid
+ *	 A new VLAN id
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_vlan_rx_kill_vid(uint8_t port_id, uint16_t vid);
+
+/**
+ * Setting the Ethernet device rx mode.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - others depends on the specific operations implementation.
+ */
+int rte_ethtool_net_set_rx_mode(uint8_t port_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_ETHTOOL_H_ */
diff --git a/lib/librte_ethtool/rte_ethtool_version.map b/lib/librte_ethtool/rte_ethtool_version.map
new file mode 100644
index 0000000..82fc0d3
--- /dev/null
+++ b/lib/librte_ethtool/rte_ethtool_version.map
@@ -0,0 +1,18 @@
+DPDK_2.0 {
+	global:
+
+	rte_ethtool_net_open;
+	rte_ethtool_net_stop;
+	rte_ethtool_net_get_mac_addr;
+	rte_ethtool_net_get_mac_addr;
+	rte_ethtool_net_validate_addr;
+	rte_ethtool_net_set_config;
+	rte_ethtool_net_change_mtu;
+	rte_ethtool_net_get_stats64;
+	rte_ethtool_net_vlan_rx_add_vid;
+	rte_ethtool_net_vlan_rx_kill_vid;
+	rte_ethtool_get_drvinfo;
+	rte_ethtool_get_link;
+
+	local: *;
+};
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 1a2043a..86867a6 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -105,6 +105,7 @@ ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KVARGS)         += -lrte_kvargs
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF)           += -lrte_mbuf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
+_LDLIBS-$(CONFIG_RTE_LIBRTE_ETHTOOL)        += -lrte_ethtool
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ETHER)          += -lethdev
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MALLOC)         += -lrte_malloc
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ethdev: add api to set default mac address
  2015-05-29 13:15 ` [PATCH 1/2] ethdev: add api to set default mac address Liang-Min Larry Wang
@ 2015-05-29 15:20   ` Stephen Hemminger
  2015-05-29 18:21     ` Wang, Liang-min
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2015-05-29 15:20 UTC (permalink / raw)
  To: Liang-Min Larry Wang; +Cc: dev, aharton, bruce.richardson

On Fri, 29 May 2015 09:15:08 -0400
Liang-Min Larry Wang <liang-min.wang@intel.com> wrote:

>  }
>  
>  int
> +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
> +{
> +	struct rte_eth_dev *dev;
> +	const int index = 0;
> +	const uint32_t pool = 0;
> +
> +	if (!rte_eth_dev_is_valid_port(port_id)) {
> +		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
> +		return -ENODEV;
> +	}
> +
> +	dev = &rte_eth_devices[port_id];
> +	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
> +	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
> +
> +	/* Update NIC default MAC address*/
> +	(*dev->dev_ops->mac_addr_remove)(dev, index);
> +	(*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
> +
> +	/* Update default address in NIC data structure */
> +	ether_addr_copy(addr, &dev->data->mac_addrs[index]);
> +
> +	return 0;
> +}
> +

No. this won't work. for some devices.

Please use mac_addr_set hook added in recent DPDK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs
  2015-05-29 13:15 ` [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs Liang-Min Larry Wang
@ 2015-05-29 15:22   ` Stephen Hemminger
  2015-05-29 18:17     ` Wang, Liang-min
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2015-05-29 15:22 UTC (permalink / raw)
  To: Liang-Min Larry Wang; +Cc: dev, aharton, bruce.richardson

On Fri, 29 May 2015 09:15:09 -0400
Liang-Min Larry Wang <liang-min.wang@intel.com> wrote:

> +	drvinfo->n_stats = sizeof(struct rte_eth_stats) / sizeof(uint64_t);
> +	drvinfo->testinfo_len = 0;


Providing a hook to access more functionality is good and compatiablity
with old API's is helpful.  Too bad ethtool is kind of a clunky old
inflexible, and easily broken with changes. But that is not your fault.

Duplicating eth_stats in ethtool is not helpful.
This is actively discouraged for Linux device drivers.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs
  2015-05-29 15:22   ` Stephen Hemminger
@ 2015-05-29 18:17     ` Wang, Liang-min
  0 siblings, 0 replies; 9+ messages in thread
From: Wang, Liang-min @ 2015-05-29 18:17 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, bruce.richardson


>On Fri, 29 May 2015 09:15:09 -0400
>Liang-Min Larry Wang <liang-min.wang@intel.com> wrote:
>
>> +	drvinfo->n_stats = sizeof(struct rte_eth_stats) / sizeof(uint64_t);
> >+	drvinfo->testinfo_len = 0;
>
>
>Providing a hook to access more functionality is good and compatiablity with old API's is helpful.  Too bad ethtool is kind of a clunky old inflexible, and easily broken with changes. But >that is not your fault.
>
>Duplicating eth_stats in ethtool is not helpful.
>This is actively discouraged for Linux device drivers.

(I have a typo of David's email, and I corrected it in this email)
This new library is designed to support ethtool alike interface, some of the implementation will be just a placeholder. The rte_ethtool_net_get_stats64 is designed as a place holder to support net_device_ops::ndo_get_stats64. For the legacy support, it is required to provide # of statistic parameters are supported, so caller can allocate right size of buffer to get statistic from device driver.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ethdev: add api to set default mac address
  2015-05-29 15:20   ` Stephen Hemminger
@ 2015-05-29 18:21     ` Wang, Liang-min
  0 siblings, 0 replies; 9+ messages in thread
From: Wang, Liang-min @ 2015-05-29 18:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, bruce.richardson


>On Fri, 29 May 2015 09:15:08 -0400
>Liang-Min Larry Wang <liang-min.wang@intel.com> wrote:
>
>>  }
> > 
>>  int
>> +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr 
>> +*addr) {
>> +	struct rte_eth_dev *dev;
>> +	const int index = 0;
>> +	const uint32_t pool = 0;
>> +
>> +	if (!rte_eth_dev_is_valid_port(port_id)) {
>> +		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>> +		return -ENODEV;
>> +	}
>> +
>> +	dev = &rte_eth_devices[port_id];
>> +	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
>> +	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
>> +
>> +	/* Update NIC default MAC address*/
>> +	(*dev->dev_ops->mac_addr_remove)(dev, index);
>> +	(*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
>> +
>> +	/* Update default address in NIC data structure */
>> +	ether_addr_copy(addr, &dev->data->mac_addrs[index]);
>> +
>> +	return 0;
>> +}
>> +
>
>No. this won't work. for some devices.
>
>Please use mac_addr_set hook added in recent DPDK

I tested over ixgbe and igb, and both work. As for your concern, it's legit. I will take your suggestion and make modification.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 0/2] User-space Ethtool
@ 2015-05-30  0:37 Liang-Min Larry Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Liang-Min Larry Wang @ 2015-05-30  0:37 UTC (permalink / raw)
  To: dev; +Cc: Liang-Min Larry Wang

This implementation is designed to provide a familar interface for applications that rely on kernel-space driver to support ethtool_op and net_device_op for device management. The initial implementation focuses on ops that can be implemented through existing netdev APIs. More ops will be supported in latter release.
ethtool: adding new ethtool api support

v3 change:
- Fix a build issue
v2 change:
- Implement rte_eth_dev_default_mac_addr_set through dev_ops::mac_addr_set so it would support NIC devices other than ixgbe and igb

Liang-Min Larry Wang (2):
  ethdev: add api to set default mac address
  ethtool: add new library to provide ethtool-alike APIs

 MAINTAINERS                                |   4 +
 config/common_linuxapp                     |   5 +
 lib/Makefile                               |   1 +
 lib/librte_ether/rte_ethdev.c              |  18 ++
 lib/librte_ether/rte_ethdev.h              |  14 ++
 lib/librte_ether/rte_ether_version.map     |   1 +
 lib/librte_ethtool/Makefile                |  56 +++++++
 lib/librte_ethtool/rte_ethtool.c           | 155 +++++++++++++++++
 lib/librte_ethtool/rte_ethtool.h           | 257 +++++++++++++++++++++++++++++
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk                              |   1 +
 11 files changed, 530 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

-- 
2.1.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 0/2] User-space Ethtool
@ 2015-05-29 19:26 Liang-Min Larry Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Liang-Min Larry Wang @ 2015-05-29 19:26 UTC (permalink / raw)
  To: dev; +Cc: Liang-Min Larry Wang

This implementation is designed to provide a familar interface for applications that rely on kernel-space driver to support ethtool_op and net_device_op for device management. The initial implementation focuses on ops that can be implemented through existing netdev APIs. More ops will be supported in latter release.
ethtool: adding new ethtool api support

v2 change:
- Implement rte_eth_dev_default_mac_addr_set through dev_ops::mac_addr_set so it would support NIC devices other than ixgbe and igb

Liang-Min Larry Wang (2):
  ethdev: add api to set default mac address
  ethtool: add new library to provide ethtool-alike APIs

 MAINTAINERS                                |   4 +
 config/common_linuxapp                     |   5 +
 lib/Makefile                               |   1 +
 lib/librte_ether/rte_ethdev.c              |  16 ++
 lib/librte_ether/rte_ethdev.h              |  14 ++
 lib/librte_ether/rte_ether_version.map     |   1 +
 lib/librte_ethtool/Makefile                |  56 +++++++
 lib/librte_ethtool/rte_ethtool.c           | 155 +++++++++++++++++
 lib/librte_ethtool/rte_ethtool.h           | 257 +++++++++++++++++++++++++++++
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk                              |   1 +
 11 files changed, 528 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

-- 
2.1.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-05-30  0:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-29 13:15 [PATCH 0/2] User-space Ethtool Liang-Min Larry Wang
2015-05-29 13:15 ` [PATCH 1/2] ethdev: add api to set default mac address Liang-Min Larry Wang
2015-05-29 15:20   ` Stephen Hemminger
2015-05-29 18:21     ` Wang, Liang-min
2015-05-29 13:15 ` [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs Liang-Min Larry Wang
2015-05-29 15:22   ` Stephen Hemminger
2015-05-29 18:17     ` Wang, Liang-min
2015-05-29 19:26 [PATCH 0/2] User-space Ethtool Liang-Min Larry Wang
2015-05-30  0:37 Liang-Min Larry Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.