From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Bruce Richardson <bruce.richardson@intel.com>,
Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH v9 18/20] ctrl_if: process ethtool messages
Date: Fri, 30 Jun 2017 17:51:38 +0100 [thread overview]
Message-ID: <20170630165140.59594-19-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20170630165140.59594-1-ferruh.yigit@intel.com>
Process ethtool messages and rend response back to kernel.
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/librte_ctrl_if/rte_ctrl_process.c | 223 ++++++++++++++++++++++++++++++++++
lib/librte_ctrl_if/rte_ctrl_process.h | 4 +
lib/librte_ctrl_if/rte_nl.c | 4 +
3 files changed, 231 insertions(+)
diff --git a/lib/librte_ctrl_if/rte_ctrl_process.c b/lib/librte_ctrl_if/rte_ctrl_process.c
index cfb243f64..55fd54351 100644
--- a/lib/librte_ctrl_if/rte_ctrl_process.c
+++ b/lib/librte_ctrl_if/rte_ctrl_process.c
@@ -38,8 +38,231 @@
#include <rte_version.h>
#include <rte_ethdev.h>
+#include <rte_ethtool.h>
#include "rte_ctrl_process.h"
+#define ETHTOOL_GEEPROM_LEN 99
+#define ETHTOOL_GREGS_LEN 98
+#define ETHTOOL_GSSET_COUNT 97
+
+static int
+get_settings(uint8_t port_id __rte_unused, void *data, size_t *data_len)
+{
+ struct ethtool_cmd *ecmd = data;
+
+ /* No PMD equivalent, added to make get pauseparam work */
+ memset(ecmd, 0, sizeof(struct ethtool_cmd));
+
+ *data_len = sizeof(struct ethtool_cmd);
+ return 0;
+}
+
+static int
+get_drvinfo(uint8_t port_id, void *data, size_t *data_len)
+{
+ struct ethtool_drvinfo *info = data;
+ int ret;
+
+ ret = rte_ethtool_get_drvinfo(port_id, info);
+ if (ret < 0)
+ return ret;
+
+ *data_len = sizeof(struct ethtool_drvinfo);
+
+ return 0;
+}
+
+static int
+get_reg_len(uint8_t port_id, void *data, size_t *data_len)
+{
+ int reg_length = 0;
+
+ reg_length = rte_ethtool_get_regs_len(port_id);
+ if (reg_length < 0)
+ return reg_length;
+
+ *(int *)data = reg_length;
+ *data_len = sizeof(int);
+
+ return 0;
+}
+
+static int
+get_reg_len_internal(uint8_t port_id, size_t *reg_length)
+{
+ size_t reg_length_out_len;
+
+ return get_reg_len(port_id, reg_length, ®_length_out_len);
+}
+
+static int
+get_reg(uint8_t port_id, void *in_data, void *out_data, size_t *out_data_len)
+{
+ size_t reg_length;
+ struct ethtool_regs *ethtool_regs = in_data;
+ int ret;
+
+ ret = get_reg_len_internal(port_id, ®_length);
+ /* not enough space in out data buffer */
+ if (ret < 0 || reg_length > ethtool_regs->len)
+ return -1;
+
+ ret = rte_ethtool_get_regs(port_id, ethtool_regs, out_data);
+ if (ret < 0)
+ return ret;
+
+ *out_data_len = reg_length;
+
+ return 0;
+}
+
+static int
+get_link(uint8_t port_id, void *data, size_t *data_len)
+{
+ int ret;
+
+ ret = rte_ethtool_get_link(port_id);
+
+ *(int *)data = ret;
+ *data_len = sizeof(size_t);
+
+ return 0;
+}
+
+static int
+get_eeprom_length(uint8_t port_id, void *data, size_t *data_len)
+{
+ int eeprom_length = 0;
+
+ eeprom_length = rte_ethtool_get_eeprom_len(port_id);
+ if (eeprom_length < 0)
+ return eeprom_length;
+
+ *(int *)data = eeprom_length;
+ *data_len = sizeof(int);
+
+ return 0;
+}
+
+static int
+get_eeprom(uint8_t port_id, void *in_data, void *out_data,
+ size_t *out_data_len)
+{
+ struct ethtool_eeprom *eeprom = in_data;
+ int ret;
+
+ ret = rte_ethtool_get_eeprom(port_id, eeprom, out_data);
+ if (ret < 0)
+ return ret;
+
+ *out_data_len = eeprom->len;
+
+ return 0;
+}
+
+static int
+set_eeprom(uint8_t port_id, void *in_data)
+{
+ struct ethtool_eeprom *eeprom = in_data;
+ int ret;
+
+ ret = rte_ethtool_set_eeprom(port_id, eeprom, eeprom->data);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
+static int
+get_ringparam(uint8_t port_id, void *data, size_t *data_len)
+{
+ struct ethtool_ringparam *ringparam = data;
+ int ret;
+
+ ret = rte_ethtool_get_ringparam(port_id, ringparam);
+ if (ret < 0)
+ return ret;
+
+ *data_len = sizeof(struct ethtool_ringparam);
+
+ return 0;
+}
+
+static int
+set_ringparam(uint8_t port_id, void *data)
+{
+ struct ethtool_ringparam *ringparam = data;
+ int ret;
+
+ ret = rte_ethtool_set_ringparam(port_id, ringparam);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
+static int
+get_pauseparam(uint8_t port_id, void *data, size_t *data_len)
+{
+ struct ethtool_pauseparam *pauseparam = data;
+ int ret;
+
+ ret = rte_ethtool_get_pauseparam(port_id, pauseparam);
+ if (ret < 0)
+ return ret;
+
+ *data_len = sizeof(struct ethtool_pauseparam);
+
+ return 0;
+}
+
+static int
+set_pauseparam(uint8_t port_id, void *data)
+{
+ struct ethtool_pauseparam *pauseparam = data;
+
+ return rte_ethtool_set_pauseparam(port_id, pauseparam);
+}
+
+int
+rte_eth_dev_ethtool_process(uint32_t cmd_id, uint8_t port_id, void *in_data,
+ void *out_data, size_t *out_data_len)
+{
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -ENODEV;
+
+ switch (cmd_id) {
+ case ETHTOOL_GSET:
+ return get_settings(port_id, out_data, out_data_len);
+ case ETHTOOL_GDRVINFO:
+ return get_drvinfo(port_id, out_data, out_data_len);
+ case ETHTOOL_GREGS_LEN:
+ return get_reg_len(port_id, out_data, out_data_len);
+ case ETHTOOL_GREGS:
+ return get_reg(port_id, in_data, out_data, out_data_len);
+ case ETHTOOL_GLINK:
+ return get_link(port_id, out_data, out_data_len);
+ case ETHTOOL_GEEPROM_LEN:
+ return get_eeprom_length(port_id, out_data, out_data_len);
+ case ETHTOOL_GEEPROM:
+ return get_eeprom(port_id, in_data, out_data, out_data_len);
+ case ETHTOOL_SEEPROM:
+ return set_eeprom(port_id, in_data);
+ case ETHTOOL_GRINGPARAM:
+ return get_ringparam(port_id, out_data, out_data_len);
+ case ETHTOOL_SRINGPARAM:
+ return set_ringparam(port_id, in_data);
+ case ETHTOOL_GPAUSEPARAM:
+ return get_pauseparam(port_id, out_data, out_data_len);
+ case ETHTOOL_SPAUSEPARAM:
+ return set_pauseparam(port_id, in_data);
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
static int
set_mtu(uint8_t port_id, void *in_data)
{
diff --git a/lib/librte_ctrl_if/rte_ctrl_process.h b/lib/librte_ctrl_if/rte_ctrl_process.h
index f67c60107..caa4f15f3 100644
--- a/lib/librte_ctrl_if/rte_ctrl_process.h
+++ b/lib/librte_ctrl_if/rte_ctrl_process.h
@@ -38,8 +38,12 @@
extern "C" {
#endif
+#include <linux/ethtool.h>
+
#include <exec-env/rte_unci_common.h>
+int rte_eth_dev_ethtool_process(uint32_t cmd_id, uint8_t port_id, void *in_data,
+ void *out_data, size_t *out_data_len);
int rte_eth_dev_control_process(uint32_t cmd_id, uint8_t port_id, void *in_data,
void *out_data, size_t *out_data_len);
diff --git a/lib/librte_ctrl_if/rte_nl.c b/lib/librte_ctrl_if/rte_nl.c
index 920d123a9..d00a242d2 100644
--- a/lib/librte_ctrl_if/rte_nl.c
+++ b/lib/librte_ctrl_if/rte_nl.c
@@ -123,6 +123,10 @@ process_msg(struct unci_nl_msg *msg)
msg->err = rte_eth_dev_control_process(msg->cmd_id,
msg->port_id, msg->input_buffer,
msg->output_buffer, &msg->output_buffer_len);
+ } else {
+ msg->err = rte_eth_dev_ethtool_process(msg->cmd_id,
+ msg->port_id, msg->input_buffer,
+ msg->output_buffer, &msg->output_buffer_len);
}
if (msg->err)
--
2.13.0
next prev parent reply other threads:[~2017-06-30 16:52 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 16:52 [dpdk-dev] [RFC] Kernel Control Path (KCP) Ferruh Yigit
2017-05-28 16:55 ` Wiles, Keith
2017-05-29 9:26 ` Bruce Richardson
2017-05-29 17:29 ` Wiles, Keith
2017-06-16 15:54 ` Ferruh Yigit
2017-06-20 12:33 ` Ferruh Yigit
2017-05-30 10:55 ` Thomas Monjalon
2017-06-13 17:21 ` Ferruh Yigit
2017-06-13 18:00 ` Jay Rolette
2017-06-13 18:04 ` Dumitrescu, Cristian
2017-06-13 18:18 ` Wiles, Keith
2017-06-15 12:07 ` Alex Rosenbaum
2017-06-16 15:27 ` Ferruh Yigit
2017-06-16 16:48 ` Stephen Hemminger
2017-06-13 18:17 ` Wiles, Keith
2017-06-21 11:06 ` [dpdk-dev] [PATCH v8 0/4] Userspace Network Control Interface (UNCI) Ferruh Yigit
2017-06-21 11:06 ` [dpdk-dev] [PATCH v8 1/4] ethtool: move from sample folder to lib folder Ferruh Yigit
2017-06-26 11:02 ` Bruce Richardson
2017-06-21 11:06 ` [dpdk-dev] [PATCH v8 2/4] unci: add kernel control path kernel module Ferruh Yigit
2017-06-21 15:23 ` Stephen Hemminger
2017-06-30 17:02 ` Ferruh Yigit
2017-06-21 11:06 ` [dpdk-dev] [PATCH v8 3/4] rte_ctrl_if: add control interface library Ferruh Yigit
2017-06-26 11:09 ` Bruce Richardson
2017-06-26 11:30 ` Bruce Richardson
2017-06-21 11:06 ` [dpdk-dev] [PATCH v8 4/4] ethdev: add control interface support Ferruh Yigit
2017-06-21 15:24 ` Stephen Hemminger
2017-06-30 17:06 ` Ferruh Yigit
2017-06-26 11:39 ` [dpdk-dev] [PATCH v8 0/4] Userspace Network Control Interface (UNCI) Bruce Richardson
2017-06-29 16:13 ` Ferruh Yigit
2017-06-30 16:56 ` Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 00/20] " Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 01/20] ethtool: add library skeleton Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 02/20] ethtool: move from sample folder into lib folder Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 03/20] ethtool: remove PMD specific API call Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 04/20] ethtool: update header doxygen syntax Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 05/20] ethtool: enable library Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 06/20] doc: add ethtool library documentation Ferruh Yigit
2017-07-02 20:18 ` Mcnamara, John
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 07/20] doc: update ethtool sample app doc Ferruh Yigit
2017-07-02 20:17 ` Mcnamara, John
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 08/20] unci: add module skeleton Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 09/20] unci: add rtnl newlink Ferruh Yigit
2017-06-30 17:27 ` Stephen Hemminger
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 10/20] unci: init netlink Ferruh Yigit
2017-06-30 17:28 ` Stephen Hemminger
2017-06-30 17:29 ` Stephen Hemminger
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 11/20] unci: add netlink exec Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 12/20] unci: add netdevice ops Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 13/20] unci: add ethtool support Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 14/20] ctrl_if: add library skeleton Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 15/20] ctrl_if: add create destroy interface APIs Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 16/20] ctrl_if: initialize netlink interface Ferruh Yigit
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 17/20] ctrl_if: process control messages Ferruh Yigit
2017-06-30 16:51 ` Ferruh Yigit [this message]
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 19/20] doc: add control interface library documentation Ferruh Yigit
2017-07-02 20:16 ` Mcnamara, John
2017-06-30 16:51 ` [dpdk-dev] [PATCH v9 20/20] ethdev: add control interface support Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 00/20] Userspace Network Control Interface (UNCI) Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 01/20] ethtool: add library skeleton Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 02/20] ethtool: move from sample folder into lib folder Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 03/20] ethtool: remove PMD specific API call Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 04/20] ethtool: update header doxygen syntax Ferruh Yigit
2017-07-06 9:18 ` Burakov, Anatoly
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 05/20] ethtool: enable library Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 06/20] doc: add ethtool library documentation Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 07/20] doc: update ethtool sample app doc Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 08/20] unci: add module skeleton Ferruh Yigit
2017-07-06 9:25 ` Burakov, Anatoly
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 09/20] unci: add rtnl newlink Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 10/20] unci: init netlink Ferruh Yigit
2017-07-06 9:32 ` Burakov, Anatoly
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 11/20] unci: add netlink exec Ferruh Yigit
2017-07-05 19:07 ` Stephen Hemminger
2017-07-06 10:45 ` Ferruh Yigit
2017-07-07 0:25 ` Stephen Hemminger
2017-07-05 19:15 ` Stephen Hemminger
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 12/20] unci: add netdevice ops Ferruh Yigit
2017-07-05 19:12 ` Stephen Hemminger
2017-07-05 19:12 ` Stephen Hemminger
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 13/20] unci: add ethtool support Ferruh Yigit
2017-07-05 19:07 ` Stephen Hemminger
2017-07-05 19:08 ` Stephen Hemminger
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 14/20] ctrl_if: add library skeleton Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 15/20] ctrl_if: add create destroy interface APIs Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 16/20] ctrl_if: initialize generic netlink interface Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 17/20] ctrl_if: process control messages Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 18/20] ctrl_if: process ethtool messages Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 19/20] doc: add control interface library documentation Ferruh Yigit
2017-07-04 16:13 ` [dpdk-dev] [PATCH v10 20/20] ethdev: add control interface support Ferruh Yigit
2017-07-08 6:28 ` Yuanhan Liu
2017-07-20 14:55 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170630165140.59594-19-ferruh.yigit@intel.com \
--to=ferruh.yigit@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).