From: Zijie Pan <zijie.pan@6wind.com>
To: dev@dpdk.org
Cc: beilei.xing@intel.com, qi.z.zhang@intel.com,
Laurent Hardy <laurent.hardy@6wind.com>
Subject: [dpdk-dev] [PATCH] net/i40e: add a specific API to control the LLDP agent
Date: Fri, 18 May 2018 12:14:07 +0200 [thread overview]
Message-ID: <1526638447-31246-1-git-send-email-zijie.pan@6wind.com> (raw)
Add a new API rte_pmd_i40e_set_lldp_cmd to control LLDP agent for i40e.
It supports the following i40e debug lldp commands:
- start/stop of the LLDP agent.
- get local/remote of the LLDP MIB (Management Information Base).
Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
Signed-off-by: Zijie Pan <zijie.pan@6wind.com>
---
drivers/net/i40e/i40e_ethdev.h | 19 +++++++++
drivers/net/i40e/rte_pmd_i40e.c | 64 +++++++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e.h | 22 ++++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 8 +++-
4 files changed, 112 insertions(+), 1 deletion(-)
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 55c8875..459b3ff 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -267,6 +267,25 @@ enum i40e_flxpld_layer_idx {
struct i40e_adapter;
/**
+ * LLDP command type
+ */
+enum i40_lldp_cmd_type {
+ I40E_LLDP_CMD_START = 0,
+ I40E_LLDP_CMD_STOP,
+ I40E_LLDP_CMD_GET_LOCAL,
+ I40E_LLDP_CMD_GET_REMOTE,
+ I40E_LLDP_CMD_UNKNOWN,
+};
+
+/**
+ * LLDP command structure
+ */
+struct i40e_lldp_cmd {
+ const char *name;
+ enum i40_lldp_cmd_type cmd;
+};
+
+/**
* MAC filter structure
*/
struct i40e_mac_filter_info {
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index 7aa1a75..307c597 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -12,6 +12,14 @@
#include "i40e_rxtx.h"
#include "rte_pmd_i40e.h"
+static const struct i40e_lldp_cmd lldp_cmds_table[] = {
+ {"start", I40E_LLDP_CMD_START},
+ {"stop", I40E_LLDP_CMD_STOP},
+ {"get local", I40E_LLDP_CMD_GET_LOCAL},
+ {"get remote", I40E_LLDP_CMD_GET_REMOTE},
+ {"", I40E_LLDP_CMD_UNKNOWN},
+};
+
int
rte_pmd_i40e_ping_vfs(uint16_t port, uint16_t vf)
{
@@ -3192,3 +3200,59 @@ int rte_pmd_i40e_flow_add_del_packet_template(
I40E_WRITE_FLUSH(hw);
return 0;
}
+
+int __rte_experimental
+rte_pmd_i40e_set_lldp_cmd(uint16_t port, const char *cmd, void *lldpmib)
+{
+ struct rte_eth_dev *dev;
+ struct i40e_hw *hw;
+ uint8_t br_type;
+ int i, ret;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+
+ if (!is_i40e_supported(dev))
+ return -ENOTSUP;
+
+ hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ for (i = 0; i < I40E_LLDP_CMD_UNKNOWN; i++) {
+ if (!strcmp(cmd, lldp_cmds_table[i].name))
+ break;
+ }
+
+ if (lldp_cmds_table[i].cmd == I40E_LLDP_CMD_UNKNOWN) {
+ PMD_DRV_LOG(ERR, "Unknown LLDP command\n");
+ return -EINVAL;
+ }
+
+ switch (lldp_cmds_table[i].cmd) {
+ case I40E_LLDP_CMD_START:
+ ret = i40e_aq_start_lldp(hw, NULL);
+ break;
+ case I40E_LLDP_CMD_STOP:
+ ret = i40e_aq_stop_lldp(hw, true, NULL);
+ break;
+ case I40E_LLDP_CMD_GET_LOCAL:
+ ret = i40e_aq_get_lldp_mib(hw, 0,
+ I40E_AQ_LLDP_MIB_LOCAL,
+ lldpmib, I40E_LLDPDU_SIZE,
+ NULL, NULL, NULL);
+ break;
+ case I40E_LLDP_CMD_GET_REMOTE:
+ br_type = I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE;
+ ret = i40e_aq_get_lldp_mib(hw, br_type,
+ I40E_AQ_LLDP_MIB_REMOTE,
+ lldpmib, I40E_LLDPDU_SIZE,
+ NULL, NULL, NULL);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "Unknown LLDP command\n");
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index be4a602..59b2eee 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -1061,4 +1061,26 @@ int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
return 0;
}
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Process the LLDP commands, including "lldp start", "lldp stop",
+ * "lldp get local" and "lldp get remote".
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param cmd
+ * The LLDP command.
+ * @param lldpmib
+ * The pointer to return the LLDP MIB.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if *cmd* invalid.
+ * - (-ENOTSUP) not supported by firmware.
+ */
+int __rte_experimental
+rte_pmd_i40e_set_lldp_cmd(uint16_t port, const char *cmd, void *lldpmib);
+
#endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index cccd576..1ffa02a 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -64,4 +64,10 @@ DPDK_18.02 {
rte_pmd_i40e_inset_get;
rte_pmd_i40e_inset_set;
-} DPDK_17.11;
\ No newline at end of file
+} DPDK_17.11;
+
+EXPERIMENTAL {
+ global:
+
+ rte_pmd_i40e_set_lldp_cmd;
+};
--
1.7.10.4
next reply other threads:[~2018-05-18 10:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-18 10:14 Zijie Pan [this message]
2018-05-18 10:27 ` Thomas Monjalon
2018-05-21 3:35 ` Zijie Pan
2018-05-21 8:39 ` Thomas Monjalon
2018-05-21 8:58 ` Laurent Hardy
2018-05-21 10:10 ` Thomas Monjalon
2018-05-21 13:11 ` Zhang, Qi Z
2018-05-22 9:47 ` Laurent Hardy
2018-05-22 13:00 ` Zhang, Qi Z
2018-05-24 1:32 ` [dpdk-dev] [PATCH v2] " Zijie Pan
2018-05-29 5:54 ` Zhang, Helin
2018-06-14 15:58 ` Ferruh Yigit
2018-05-24 1:45 [dpdk-dev] [PATCH] " Zijie Pan
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=1526638447-31246-1-git-send-email-zijie.pan@6wind.com \
--to=zijie.pan@6wind.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=laurent.hardy@6wind.com \
--cc=qi.z.zhang@intel.com \
/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).