From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 501742BE1 for ; Thu, 24 May 2018 03:33:12 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id m129-v6so594481wmb.3 for ; Wed, 23 May 2018 18:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=md9hFhPXm70aaAXO61wdjXyZLbYh6tGSN38JWaqjzO4=; b=M0ZJQ+CyauK+zAGoPZAN0dUo2/aTfsPojtsCnlGe8l1xmUArw00o5LhoyeBqOjcF45 HhqRvoFWXtFN5a7+UbrOXQYAyebC02dMV8E+FxwEjJvwxJc7JDRfYrl3KdE3UINeOOrr X80McoeUhDFRzzlXAu0aK1OKQmHaBfHg3RXsAWy1c374bkHnhtRP7ZKjskOhaX2+Zqkf QEv0Q+G1cjL60u9wFB/xRc7lLOWgK07xS1oGmiaqyRBfi1st2bP4liY7SbOBT3CcXlRN a2qudzyWN7uW6nNPUUWNKKaJvQ8BXBokMKai9u3CDuGNdTv+QW/Xihqjx7E2RNYs/oO2 OZtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=md9hFhPXm70aaAXO61wdjXyZLbYh6tGSN38JWaqjzO4=; b=OyB+/0tZqh0Rciml48/qRnGcP5a9WFAgp3SgaqW+LzFTP+5phBxwidSKK+6Venr2rT +dvclN5/a5qqjZQ44RiTqVInh38V8wO8+ZB+uzhZSJ5kj1QG79sUEf49xa3MiErq7xxz 7K/B9U8riQ/U5FRaYU4xcJVn1BN4sO1DZpTtxDaXsYC21BCz4VZseNdJaenJKRDaUNpL 3LPCk6QfMTmNrOwENCSuQAHLUsSlqqXoeveUS1pij9Xbl9YXR4TEo8/jYuUeqx4PI2kQ k/K0b/H80VF+WIiOSHLIJnKu6TP88cGJLg+FJfynRwZHEOLneX0rjTr4gkruiWDRQxPJ NymQ== X-Gm-Message-State: ALKqPwdQlckJN4dcv6fBbNVU5d6YhgKhENQGS8zTwuJmwsQIZNWqI8U7 /5xnbhCEW02tLuCbeC68r6/rtBq4 X-Google-Smtp-Source: AB8JxZoxFhomwGZWIo7SUIdAzvyNbb60/6qMoGDfkKJgTBj9OU+xXQX4e9iLB5GYUzNbcp4dRPsvNQ== X-Received: by 2002:a1c:170f:: with SMTP id 15-v6mr5730661wmx.90.1527125591615; Wed, 23 May 2018 18:33:11 -0700 (PDT) Received: from cougar.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id m134-v6sm4231607wmg.4.2018.05.23.18.33.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 18:33:11 -0700 (PDT) From: Zijie Pan To: dev@dpdk.org Cc: beilei.xing@intel.com, qi.z.zhang@intel.com, thomas@monjalon.net, Laurent Hardy Date: Thu, 24 May 2018 03:32:30 +0200 Message-Id: <1527125550-8425-1-git-send-email-zijie.pan@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1526638447-31246-1-git-send-email-zijie.pan@6wind.com> References: <1526638447-31246-1-git-send-email-zijie.pan@6wind.com> Subject: [dpdk-dev] [PATCH v2] net/i40e: add a specific API to control the LLDP agent X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2018 01:33:12 -0000 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 Signed-off-by: Zijie Pan Acked-by: Qi Zhang --- drivers/net/i40e/i40e_ethdev.h | 19 ++++++++ drivers/net/i40e/rte_pmd_i40e.c | 69 +++++++++++++++++++++++++++++ drivers/net/i40e/rte_pmd_i40e.h | 22 +++++++++ drivers/net/i40e/rte_pmd_i40e_version.map | 8 +++- 4 files changed, 117 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..612eb6d 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,64 @@ int rte_pmd_i40e_flow_add_del_packet_template( I40E_WRITE_FLUSH(hw); return 0; } + +/** + * LLDP is enabled by default. Disabling LLDP when using NVM 4.53 or 5.x can + * result in the device firmware not configuring the Receive Packet Buffer + * according to the link mode and flow control settings. + */ +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