From e579435fac1aea9bc75588907ade35ddab54a419 Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Tue, 17 Mar 2020 17:12:00 +0800 Subject: [PATCH] net/hns3: remove redundant check when setting MAC This patch removes unnecessary MAC address validity check operation in the .mac_addr_set ops implementation function named hns3_set_default_mac_addr and hns3vf_set_default_mac_addr, because it has been guaranteed that input parameter named mac_addr is valid address in the rte layer of DPDK framework. Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 13 ++++--------- drivers/net/hns3/hns3_ethdev_vf.c | 12 ++++-------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index ed79510f25..ebf8dc9b78 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -1487,15 +1487,10 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, bool rm_succes = false; int ret, ret_val; - /* check if mac addr is valid */ - if (!rte_is_valid_assigned_ether_addr(mac_addr)) { - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to set mac addr, addr(%s) invalid", - mac_str); - return -EINVAL; - } - + /* + * It has been guaranteed that input parameter named mac_addr is valid + * address in the rte layer of DPDK framework. + */ oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; default_addr_setted = hw->mac.default_addr_setted; if (default_addr_setted && !!rte_is_same_ether_addr(mac_addr, oaddr)) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 893eb0363c..febce865bd 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -192,14 +192,10 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; int ret; - if (!rte_is_valid_assigned_ether_addr(mac_addr)) { - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to set mac addr, addr(%s) invalid.", - mac_str); - return -EINVAL; - } - + /* + * It has been guaranteed that input parameter named mac_addr is valid + * address in the rte layer of DPDK framework. + */ old_addr = (struct rte_ether_addr *)hw->mac.mac_addr; rte_spinlock_lock(&hw->lock); memcpy(addr_bytes, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN); -- 2.20.1