From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C802459AC; Mon, 16 Sep 2024 11:54:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 321214025F; Mon, 16 Sep 2024 11:54:40 +0200 (CEST) Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by mails.dpdk.org (Postfix) with ESMTP id 1258B40041 for ; Mon, 16 Sep 2024 11:54:37 +0200 (CEST) Received: from mail.cstnet.cn (unknown [60.29.3.194]) by APP-01 (Coremail) with SMTP id qwCowADX3R1YAOhmsVQcBA--.998S2; Mon, 16 Sep 2024 17:54:33 +0800 (CST) From: Jie Liu To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Jie Liu Subject: [PATCH v2] net/sxe: add net driver sxe again Date: Mon, 16 Sep 2024 17:54:26 +0800 Message-ID: <20240916095426.1206-1-liujie5@linkdatatechnology.com> X-Mailer: git-send-email 2.45.2.windows.1 In-Reply-To: <20240910034123.1043-1-liujie5@linkdatatechnology.com> References: <20240910034123.1043-1-liujie5@linkdatatechnology.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: qwCowADX3R1YAOhmsVQcBA--.998S2 X-Coremail-Antispam: 1UD129KBjvAXoWfKr4fZr17KrWxurykuw1kAFb_yoW8uFyfJo WxAr43JFW3ZF17CF97Jr1xWF43ZFWkK345Aa13Cwsava13GrZ8AF18Xry3AFnxX3W8JF48 AF18Cw4DZF4I9a1kn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UjIYCTnIWjp_UUUY07AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xva j40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2 x7M28EF7xvwVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWU JVW8JwA2z4x0Y4vEx4A2jsIE14v26r1j6r4UM28EF7xvwVC2z280aVCY1x0267AKxVWUJV W8JwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GFWl 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUIhFcUUUUU= X-Originating-IP: [60.29.3.194] X-CM-SenderInfo: xolxyxrhv6zxpqngt3pdwhux5qro0w31of0z/ X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Delete non essential files and modify code style issues. Signed-off-by: Jie Liu --- drivers/net/sxe/include/readme.txt | 0 drivers/net/sxe/include/sxe_version.h | 31 ---- drivers/net/sxe/pf/sxe.h | 3 - drivers/net/sxe/pf/sxe_filter.c | 33 +++-- drivers/net/sxe/pf/sxe_filter.h | 3 - drivers/net/sxe/pf/sxe_macsec.c | 6 +- drivers/net/sxe/pf/sxe_vf.c | 12 +- drivers/net/sxe/sxe_testpmd.c | 201 ++++++++++++++++++++++++++ drivers/net/sxe/vf/sxevf_ethdev.c | 4 +- drivers/net/sxe/vf/sxevf_filter.c | 25 ++-- drivers/net/sxe/vf/sxevf_filter.h | 3 - 11 files changed, 257 insertions(+), 64 deletions(-) delete mode 100644 drivers/net/sxe/include/readme.txt delete mode 100644 drivers/net/sxe/include/sxe_version.h create mode 100644 drivers/net/sxe/sxe_testpmd.c diff --git a/drivers/net/sxe/include/readme.txt b/drivers/net/sxe/include/readme.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/drivers/net/sxe/include/sxe_version.h b/drivers/net/sxe/include/sxe_version.h deleted file mode 100644 index 6b5e4caef1..0000000000 --- a/drivers/net/sxe/include/sxe_version.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (C), 2022, Linkdata Technology Co., Ltd. - */ -#ifndef __SXE_VER_H__ -#define __SXE_VER_H__ - -#define SXE_VERSION "0.0.0.0" -#define SXE_COMMIT_ID "51935d6" -#define SXE_BRANCH "feature/sagitta-1.3.0-P3-dpdk_patch_rwy" -#define SXE_BUILD_TIME "2024-09-05 21:49:55" - - -#define SXE_DRV_NAME "sxe" -#define SXEVF_DRV_NAME "sxevf" -#define SXE_DRV_LICENSE "GPL v2" -#define SXE_DRV_AUTHOR "sxe" -#define SXEVF_DRV_AUTHOR "sxevf" -#define SXE_DRV_DESCRIPTION "sxe driver" -#define SXEVF_DRV_DESCRIPTION "sxevf driver" - - -#define SXE_FW_NAME "soc" -#define SXE_FW_ARCH "arm32" - -#ifndef PS3_CFG_RELEASE -#define PS3_SXE_FW_BUILD_MODE "debug" -#else -#define PS3_SXE_FW_BUILD_MODE "release" -#endif - -#endif diff --git a/drivers/net/sxe/pf/sxe.h b/drivers/net/sxe/pf/sxe.h index 4d7e03adee..3abdf0d7e5 100644 --- a/drivers/net/sxe/pf/sxe.h +++ b/drivers/net/sxe/pf/sxe.h @@ -35,9 +35,6 @@ struct sxe_vlan_context; #define SXE_DEV_ID_ASIC 0x10a1 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ADDR(x) ((u8 *)(x))[0], ((u8 *)(x))[1], \ - ((u8 *)(x))[2], ((u8 *)(x))[3], \ - ((u8 *)(x))[4], ((u8 *)(x))[5] #ifdef RTE_PMD_PACKET_PREFETCH #define rte_packet_prefetch(p) rte_prefetch1(p) diff --git a/drivers/net/sxe/pf/sxe_filter.c b/drivers/net/sxe/pf/sxe_filter.c index 1d1d78b516..889b97f809 100644 --- a/drivers/net/sxe/pf/sxe_filter.c +++ b/drivers/net/sxe/pf/sxe_filter.c @@ -72,15 +72,18 @@ static void sxe_default_mac_addr_get(struct sxe_adapter *adapter) { s32 ret; struct rte_ether_addr mac_addr = { {0} }; + u8 *addr; ret = sxe_get_mac_addr_from_fw(adapter, mac_addr.addr_bytes); + addr = mac_addr.addr_bytes; if (ret || !rte_is_valid_assigned_ether_addr(&mac_addr)) { LOG_DEBUG("invalid default mac addr:"MAC_FMT" result:%d\n", - MAC_ADDR(mac_addr.addr_bytes), ret); + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], ret); return; } - LOG_DEBUG("default mac addr = "MAC_FMT"\n", MAC_ADDR(mac_addr.addr_bytes)); + LOG_DEBUG("default mac addr = "MAC_FMT"\n", addr[0], addr[1], addr[2], + addr[3], addr[4], addr[5]); rte_ether_addr_copy(&mac_addr, &adapter->mac_filter_ctxt.def_mac_addr); rte_ether_addr_copy(&mac_addr, &adapter->mac_filter_ctxt.fc_mac_addr); @@ -317,6 +320,7 @@ s32 sxe_mac_addr_add(struct rte_eth_dev *dev, struct sxe_adapter *adapter = dev->data->dev_private; struct sxe_hw *hw = &adapter->hw; s32 ret; + u8 *addr; u8 rar_idx = sxe_sw_uc_entry_add(adapter, index, mac_addr->addr_bytes); #if defined SXE_DPDK_L4_FEATURES && defined SXE_DPDK_SRIOV @@ -326,17 +330,20 @@ s32 sxe_mac_addr_add(struct rte_eth_dev *dev, ret = sxe_hw_uc_addr_add(hw, rar_idx, mac_addr->addr_bytes, sxe_vf_num_get(dev)); #endif + addr = mac_addr->addr_bytes; if (ret) { LOG_ERROR("rar_idx:%u pool:%u mac_addr:"MAC_FMT "add fail.(err:%d)", rar_idx, pool, - MAC_ADDR(mac_addr->addr_bytes), ret); + addr[0], addr[1], addr[2], addr[3], + addr[4], addr[5], ret); goto l_out; } PMD_LOG_INFO(DRV, "rar_idx:%u pool:%u mac_addr:"MAC_FMT" add done", rar_idx, pool, - MAC_ADDR(mac_addr->addr_bytes)); + addr[0], addr[1], addr[2], + addr[3], addr[4], addr[5]); l_out: return ret; @@ -348,6 +355,7 @@ void sxe_mac_addr_remove(struct rte_eth_dev *dev, u32 index) struct sxe_hw *hw = &adapter->hw; s32 ret; u8 rar_idx = sxe_sw_uc_entry_del(adapter, index); + u8 *mac_addr; ret = sxe_hw_uc_addr_del(hw, rar_idx); if (ret) { @@ -356,9 +364,11 @@ void sxe_mac_addr_remove(struct rte_eth_dev *dev, u32 index) return; } + mac_addr = dev->data->mac_addrs[rar_idx].addr_bytes; PMD_LOG_INFO(DRV, "rar_idx:%u mac_addr:"MAC_FMT" remove done", rar_idx, - MAC_ADDR(&dev->data->mac_addrs[rar_idx])); + mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5]); } @@ -376,6 +386,7 @@ s32 sxe_mac_addr_set(struct rte_eth_dev *dev, { u8 pool_idx; struct sxe_adapter *adapter = dev->data->dev_private; + u8 *addr = mac_addr->addr_bytes; sxe_mac_addr_remove(dev, 0); @@ -393,8 +404,8 @@ s32 sxe_mac_addr_set(struct rte_eth_dev *dev, sxe_fc_mac_addr_set(adapter); PMD_LOG_INFO(DRV, "pool:%u mac_addr:"MAC_FMT" set to be cur mac addr done", - pool_idx, - MAC_ADDR(mac_addr)); + pool_idx, addr[0], addr[1], addr[2], + addr[3],addr[4], addr[5]); return 0; } @@ -414,7 +425,8 @@ static void sxe_hash_mac_addr_parse(u8 *mac_addr, u16 *reg_idx, *bit_idx = extracted & SXE_MAC_ADDR_BIT_MASK; PMD_LOG_DEBUG(DRV, "mac_addr:"MAC_FMT" hash reg_idx:%u bit_idx:%u", - MAC_ADDR(mac_addr), *reg_idx, *bit_idx); + mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], + mac_addr[4], mac_addr[5], *reg_idx, *bit_idx); } @@ -428,6 +440,7 @@ s32 sxe_uc_hash_table_set(struct rte_eth_dev *dev, struct sxe_mac_filter_context *mac_filter = &adapter->mac_filter_ctxt; u32 value; s32 ret = 0; + u8 *addr; sxe_hash_mac_addr_parse(mac_addr->addr_bytes, ®_idx, &bit_idx); @@ -448,9 +461,11 @@ s32 sxe_uc_hash_table_set(struct rte_eth_dev *dev, sxe_hw_uta_hash_table_set(hw, reg_idx, value); + addr = mac_addr->addr_bytes; PMD_LOG_INFO(DRV, "mac_addr:"MAC_FMT" uta reg_idx:%u bit_idx:%u" " %s done, uta_used_count:%u", - MAC_ADDR(mac_addr->addr_bytes), + addr[0], addr[1], addr[2], + addr[3], addr[4], addr[5], reg_idx, bit_idx, on ? "set" : "clear", mac_filter->uta_used_count); diff --git a/drivers/net/sxe/pf/sxe_filter.h b/drivers/net/sxe/pf/sxe_filter.h index f7d147e492..2e5e2f9e2f 100644 --- a/drivers/net/sxe/pf/sxe_filter.h +++ b/drivers/net/sxe/pf/sxe_filter.h @@ -19,9 +19,6 @@ struct sxe_adapter; #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ADDR(x) ((u8 *)(x))[0], ((u8 *)(x))[1], \ - ((u8 *)(x))[2], ((u8 *)(x))[3], \ - ((u8 *)(x))[4], ((u8 *)(x))[5] #define BYTE_BIT_NUM 8 diff --git a/drivers/net/sxe/pf/sxe_macsec.c b/drivers/net/sxe/pf/sxe_macsec.c index 4a49405a95..1d08e13dca 100644 --- a/drivers/net/sxe/pf/sxe_macsec.c +++ b/drivers/net/sxe/pf/sxe_macsec.c @@ -155,7 +155,8 @@ s32 rte_pmd_sxe_macsec_txsc_configure(u16 port, u8 *mac) sxe_hw_macsec_txsc_set(&adapter->hw, (*(u32 *)mac_addr), (*(u32 *)&mac_addr[4])); PMD_LOG_INFO(DRV, "tx sc mac_addr:"MAC_FMT" configure done", - MAC_ADDR(mac_addr)); + mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], + mac_addr[4], mac_addr[5]); l_out: return ret; } @@ -182,7 +183,8 @@ s32 rte_pmd_sxe_macsec_rxsc_configure(u16 port, u8 *mac, u16 pi) sxe_hw_macsec_rxsc_set(&adapter->hw, (*(u32 *)mac_addr), (*(u32 *)&mac_addr[4]), pi); PMD_LOG_INFO(DRV, "rx sc mac_addr:"MAC_FMT" pi:%u configure done", - MAC_ADDR(mac_addr), pi); + mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], + mac_addr[4], mac_addr[5], pi); l_out: return ret; } diff --git a/drivers/net/sxe/pf/sxe_vf.c b/drivers/net/sxe/pf/sxe_vf.c index 4b8813e6de..87d8219f63 100644 --- a/drivers/net/sxe/pf/sxe_vf.c +++ b/drivers/net/sxe/pf/sxe_vf.c @@ -386,6 +386,7 @@ static s32 sxe_vf_dev_mac_addr_set_handler(struct rte_eth_dev *dev, u32 *msgbuf, struct sxe_vf_info *vf_info = adapter->vt_ctxt.vf_info; u32 rar_idx = sxe_sw_uc_entry_vf_add(adapter, vf, mac_msg.uc_addr, false); s32 ret = -SXE_ERR_PARAM; + u8 *mac_addr = mac_msg.uc_addr; if (rte_is_valid_assigned_ether_addr( (struct rte_ether_addr *)mac_msg.uc_addr)) { @@ -393,7 +394,8 @@ static s32 sxe_vf_dev_mac_addr_set_handler(struct rte_eth_dev *dev, u32 *msgbuf, ret = sxe_hw_uc_addr_add(&adapter->hw, rar_idx, mac_msg.uc_addr, vf); if (ret) { LOG_ERROR_BDF("vf:%u mac addr:"MAC_FMT" set fail.(err:%d)", - vf, MAC_ADDR(mac_msg.uc_addr), ret); + vf, mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5], ret); } } @@ -780,13 +782,15 @@ static s32 sxe_vf_uc_addr_sync_handler(struct rte_eth_dev *dev, struct sxe_uc_sync_msg *uc_msg = (struct sxe_uc_sync_msg *)msgbuf; s32 ret = 0; u8 rar_idx; + u8 *mac_addr = (u8 *)uc_msg->addr; if (uc_msg->index) { if (!rte_is_valid_assigned_ether_addr( (struct rte_ether_addr *)uc_msg->addr)) { ret = -SXE_ERR_PARAM; LOG_ERROR_BDF("vf:%u mac addr:"MAC_FMT" invalid.(err:%d).", - vf, MAC_ADDR(uc_msg->addr), ret); + vf, mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5], ret); goto l_out; } @@ -873,7 +877,9 @@ static void sxe_vf_reset_msg_handle(struct rte_eth_dev *dev, u8 vf_idx) LOG_INFO_BDF("vf_idx:%d reset msg:0x%x handle done.send mac addr:"MAC_FMT " mc type:%d to vf.", vf_idx, reply.msg_type, - MAC_ADDR(mac_addr), SXE_MC_FILTER_TYPE0); + mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5], + SXE_MC_FILTER_TYPE0); } diff --git a/drivers/net/sxe/sxe_testpmd.c b/drivers/net/sxe/sxe_testpmd.c new file mode 100644 index 0000000000..a1381a2039 --- /dev/null +++ b/drivers/net/sxe/sxe_testpmd.c @@ -0,0 +1,201 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C), 2022, Linkdata Technology Co., Ltd. + */ +#ifdef DPDK_22_11_3 + +#include +#include "sxe_ethdev.h" +#include "rte_pmd_sxe.h" + +#include +#include +#include + +#include "testpmd.h" + +static int +vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, uint8_t *tc_num, char *str) +{ + uint32_t size; + const char *p, *p0 = str; + char s[256]; + char *end; + char *str_fld[16]; + uint16_t i; + int ret; + + p = strchr(p0, '('); + if (p == NULL) { + fprintf(stderr, "The bandwidth-list should be '(bw1, bw2, ...)'\n"); + return -1; + } + p++; + p0 = strchr(p, ')'); + if (p0 == NULL) { + fprintf(stderr, "The bandwidth-list should be '(bw1, bw2, ...)'\n"); + return -1; + } + size = p0 - p; + if (size >= sizeof(s)) { + fprintf(stderr, "The string size exceeds the internal buffer size\n"); + return -1; + } + snprintf(s, sizeof(s), "%.*s", size, p); + ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); + if (ret <= 0) { + fprintf(stderr, "Failed to get the bandwidth list.\n"); + return -1; + } + *tc_num = ret; + for (i = 0; i < ret; i++) + bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); + + return 0; +} + +struct cmd_vf_tc_bw_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t tc; + cmdline_fixed_string_t tx; + cmdline_fixed_string_t min_bw; + portid_t port_id; + cmdline_fixed_string_t bw_list; +}; + +static cmdline_parse_token_string_t cmd_vf_tc_bw_set = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + set, "set"); +static cmdline_parse_token_string_t cmd_vf_tc_bw_tc = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + tc, "tc"); +static cmdline_parse_token_string_t cmd_vf_tc_bw_tx = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + tx, "tx"); +static cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + min_bw, "min-bandwidth"); +static cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_vf_tc_bw_result, + port_id, RTE_UINT16); +static cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + bw_list, NULL); + +static void +cmd_tc_min_bw_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_vf_tc_bw_result *res = parsed_result; + struct rte_port *port; + uint8_t tc_num; + uint8_t bw[16]; + int ret = -ENOTSUP; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + port = &ports[res->port_id]; + if (port->port_status != RTE_PORT_STOPPED) { + fprintf(stderr, "Please stop port %d first\n", res->port_id); + return; + } + + ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); + if (ret) + return; + + ret = rte_pmd_sxe_tc_bw_set(res->port_id, tc_num, bw); + + switch (ret) { + case 0: + break; + case -EINVAL: + fprintf(stderr, "invalid bandwidth\n"); + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", res->port_id); + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented\n"); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +static cmdline_parse_inst_t cmd_tc_min_bw = { + .f = cmd_tc_min_bw_parsed, + .data = NULL, + .help_str = "set tc tx min-bandwidth ", + .tokens = { + (void *)&cmd_vf_tc_bw_set, + (void *)&cmd_vf_tc_bw_tc, + (void *)&cmd_vf_tc_bw_tx, + (void *)&cmd_vf_tc_bw_min_bw, + (void *)&cmd_vf_tc_bw_port_id, + (void *)&cmd_vf_tc_bw_bw_list, + NULL, + }, +}; + +struct led_ctrl_result { + cmdline_fixed_string_t port; + uint16_t port_id; + cmdline_fixed_string_t led; + cmdline_fixed_string_t action; +}; + +cmdline_parse_token_string_t cmd_led_ctrl_port = + TOKEN_STRING_INITIALIZER(struct led_ctrl_result, port, "port"); +cmdline_parse_token_num_t cmd_led_ctrl_port_id = + TOKEN_NUM_INITIALIZER(struct led_ctrl_result, port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_led_ctrl_led = + TOKEN_STRING_INITIALIZER(struct led_ctrl_result, led, "led"); +cmdline_parse_token_string_t cmd_led_ctrl_action = + TOKEN_STRING_INITIALIZER(struct led_ctrl_result, action, "on#off"); + +static void cmd_led_ctrl_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct led_ctrl_result *res = parsed_result; + + if (strcmp(res->action, "on") == 0) { + rte_eth_led_on(res->port_id); + } else { + rte_eth_led_off(res->port_id); + } + +} + +cmdline_parse_inst_t cmd_led_ctrl = { + .f = cmd_led_ctrl_parsed, + .data = NULL, + .help_str = "port led on|off", + .tokens = { + (void *)&cmd_led_ctrl_port, + (void *)&cmd_led_ctrl_port_id, + (void *)&cmd_led_ctrl_led, + (void *)&cmd_led_ctrl_action, + NULL, + }, +}; + +static struct testpmd_driver_commands sxe_cmds = { + .commands = { + { + &cmd_tc_min_bw, + "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" + " Set all TCs' min bandwidth(%%) for all PF and VFs.\n", + }, + { + &cmd_led_ctrl, + "port led on|off\n" + " Set led on or off.\n", + }, + { NULL, NULL }, + }, +}; +TESTPMD_ADD_DRIVER_COMMANDS(sxe_cmds) + +#endif diff --git a/drivers/net/sxe/vf/sxevf_ethdev.c b/drivers/net/sxe/vf/sxevf_ethdev.c index dd39798520..79560b0bc7 100644 --- a/drivers/net/sxe/vf/sxevf_ethdev.c +++ b/drivers/net/sxe/vf/sxevf_ethdev.c @@ -159,6 +159,7 @@ static s32 sxevf_hw_dev_reset(struct sxevf_hw *hw) s32 ret; struct sxevf_rst_msg msg = {}; struct sxevf_adapter *adapter = hw->adapter; + u8 *mac_addr = adapter->mac_filter_ctxt.def_mac_addr.addr_bytes; adapter->stop = true; @@ -207,7 +208,8 @@ static s32 sxevf_hw_dev_reset(struct sxevf_hw *hw) LOG_INFO_BDF("vf get mc filter type:%d default mac addr:"MAC_FMT" from pf.\n", adapter->mac_filter_ctxt.mc_filter_type, - MAC_ADDR(&adapter->mac_filter_ctxt.def_mac_addr)); + mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5]); l_out: return ret; diff --git a/drivers/net/sxe/vf/sxevf_filter.c b/drivers/net/sxe/vf/sxevf_filter.c index 18257ba43e..232e5be5fd 100644 --- a/drivers/net/sxe/vf/sxevf_filter.c +++ b/drivers/net/sxe/vf/sxevf_filter.c @@ -65,6 +65,7 @@ s32 sxevf_mac_addr_init(struct rte_eth_dev *eth_dev) struct sxevf_hw *hw = &adapter->hw; struct sxevf_mac_filter_context *mac_filter = &adapter->mac_filter_ctxt; s32 ret = 0; + u8 *mac_addr; eth_dev->data->mac_addrs = rte_zmalloc("sxe", RTE_ETHER_ADDR_LEN * SXEVF_HW_UC_ENTRY_NUM_MAX, 0); @@ -82,8 +83,10 @@ s32 sxevf_mac_addr_init(struct rte_eth_dev *eth_dev) LOG_ERROR_BDF("vf uc mac addr set fail.(err:%d)", ret); goto l_free; } + mac_addr = mac_filter->def_mac_addr.addr_bytes; LOG_INFO_BDF("generate random mac_addr:"MAC_FMT, - MAC_ADDR(mac_filter->def_mac_addr.addr_bytes)); + mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], + mac_addr[4], mac_addr[5]); } rte_ether_addr_copy(&mac_filter->def_mac_addr, ð_dev->data->mac_addrs[0]); @@ -368,15 +371,16 @@ s32 sxevf_default_mac_addr_set(struct rte_eth_dev *dev, s32 ret; struct sxevf_adapter *adapter = dev->data->dev_private; struct sxevf_hw *hw = &adapter->hw; + u8 *addr = mac_addr->addr_bytes; ret = sxevf_mac_addr_set(hw, mac_addr->addr_bytes); if (ret) { LOG_ERROR_BDF("modify default mac addr to "MAC_FMT" fail.(err:%d)", - MAC_ADDR(mac_addr->addr_bytes), ret); + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], ret); } LOG_INFO_BDF("modify default mac addr to "MAC_FMT" success.", - MAC_ADDR(mac_addr->addr_bytes)); + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); return ret; } @@ -389,25 +393,26 @@ s32 sxevf_mac_addr_add(struct rte_eth_dev *dev, struct sxevf_adapter *adapter = dev->data->dev_private; struct sxevf_hw *hw = &adapter->hw; struct sxevf_mac_filter_context *mac_ctxt = &adapter->mac_filter_ctxt; + u8 *addr = mac_addr->addr_bytes; if (memcmp(mac_ctxt->def_mac_addr.addr_bytes, mac_addr->addr_bytes, sizeof(*mac_addr)) == 0) { ret = -EINVAL; LOG_ERROR_BDF("mac_addr:"MAC_FMT" eaqual to defalut mac addr" " skip mac addr add.(err:%d)", - MAC_ADDR(mac_addr->addr_bytes), ret); + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], ret); goto l_out; } ret = sxevf_uc_addr_add(hw, 2, mac_addr->addr_bytes); if (ret) { LOG_ERROR_BDF("mac_addr:"MAC_FMT" add fail.(err:%d)", - MAC_ADDR(mac_addr->addr_bytes), ret); + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], ret); goto l_out; } LOG_INFO_BDF("mac_addr:"MAC_FMT" add success.", - MAC_ADDR(mac_addr->addr_bytes)); + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); l_out: return ret; @@ -419,6 +424,7 @@ void sxevf_mac_addr_remove(struct rte_eth_dev *dev, u32 index) struct sxevf_hw *hw = &adapter->hw; struct sxevf_mac_filter_context *mac_ctxt = &adapter->mac_filter_ctxt; struct rte_ether_addr *mac_addr; + u8 *addr; u8 i; sxevf_uc_addr_add(hw, 0, NULL); @@ -432,9 +438,9 @@ void sxevf_mac_addr_remove(struct rte_eth_dev *dev, u32 index) } sxevf_uc_addr_add(hw, 2, mac_addr->addr_bytes); } - + addr = dev->data->mac_addrs[index].addr_bytes; LOG_INFO_BDF("index:%u mac addr"MAC_FMT" remove success.", - index, MAC_ADDR(dev->data->mac_addrs[index].addr_bytes)); + index, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); } static u16 sxevf_hash_mac_addr_parse(u8 *mac_addr) @@ -445,7 +451,8 @@ static u16 sxevf_hash_mac_addr_parse(u8 *mac_addr) extracted &= SXEVF_MAC_ADDR_EXTRACT_MASK; PMD_LOG_DEBUG(DRV, "mac_addr:"MAC_FMT" parse result:0x%x", - MAC_ADDR(mac_addr), extracted); + mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], + mac_addr[4], mac_addr[5], extracted); return extracted; } diff --git a/drivers/net/sxe/vf/sxevf_filter.h b/drivers/net/sxe/vf/sxevf_filter.h index e94be98ec5..e85f0f86e7 100644 --- a/drivers/net/sxe/vf/sxevf_filter.h +++ b/drivers/net/sxe/vf/sxevf_filter.h @@ -23,9 +23,6 @@ #define SXEVF_VLAN_ID_BIT_MASK (0x1F) #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ADDR(x) ((u8 *)(x))[0], ((u8 *)(x))[1], \ - ((u8 *)(x))[2], ((u8 *)(x))[3], \ - ((u8 *)(x))[4], ((u8 *)(x))[5] #define SXEVF_VLAN_STRIP_BITMAP_SIZE \ (SXEVF_HW_TXRX_RING_NUM_MAX / (sizeof(u32) * BYTE_BIT_NUM)) -- 2.45.2.windows.1