[3/4] net/hns3: adjust printing MAC addresses in log
diff mbox series

Message ID 1605871656-51819-4-git-send-email-oulijun@huawei.com
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series
  • hns3 fixes
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

oulijun Nov. 20, 2020, 11:27 a.m. UTC
Here the printing of MAC addresses is adjusted. After the
modification, only some bytes of the MAC address are
displayed.

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    | 53 +++++++++++++++++++++++----------------
 drivers/net/hns3/hns3_ethdev.h    |  2 ++
 drivers/net/hns3/hns3_ethdev_vf.c | 32 +++++++++++------------
 3 files changed, 49 insertions(+), 38 deletions(-)

Comments

Ferruh Yigit Nov. 20, 2020, 2:25 p.m. UTC | #1
On 11/20/2020 11:27 AM, Lijun Ou wrote:
> Here the printing of MAC addresses is adjusted. After the
> modification, only some bytes of the MAC address are
> displayed.
> 

Why logging only some bytes of the MAC address?

> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
> Signed-off-by: Lijun Ou <oulijun@huawei.com>
> ---
>   drivers/net/hns3/hns3_ethdev.c    | 53 +++++++++++++++++++++++----------------
>   drivers/net/hns3/hns3_ethdev.h    |  2 ++
>   drivers/net/hns3/hns3_ethdev_vf.c | 32 +++++++++++------------
>   3 files changed, 49 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
> index 2011378..d6d3f03 100644
> --- a/drivers/net/hns3/hns3_ethdev.c
> +++ b/drivers/net/hns3/hns3_ethdev.c
> @@ -102,6 +102,15 @@ static int hns3_remove_mc_addr(struct hns3_hw *hw,
>   static int hns3_restore_fec(struct hns3_hw *hw);
>   static int hns3_query_dev_fec_info(struct rte_eth_dev *dev);
>   
> +void hns3_ether_format_addr(char *buf, uint16_t size,
> +			    const struct rte_ether_addr *ether_addr)
> +{
> +	snprintf(buf, size, "%02X:**:**:**:%02X:%02X",
> +		ether_addr->addr_bytes[0],
> +		ether_addr->addr_bytes[4],
> +		ether_addr->addr_bytes[5]);
> +}
> +
>   static void
>   hns3_pf_disable_irq0(struct hns3_hw *hw)
>   {
> @@ -1449,7 +1458,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
>   
>   	/* 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,
> +		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
>   				      mac_addr);

Is all these interim variable only to log the mac address? If so why not use 
macros insted, something like:

#define FMT "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]

hns3_err(fw, "Add unicast mac addr err! addr(" FMT ") invalid", MAC(mac_addr));
oulijun Dec. 7, 2020, 2:52 p.m. UTC | #2
在 2020/11/20 22:25, Ferruh Yigit 写道:
> On 11/20/2020 11:27 AM, Lijun Ou wrote:
>> Here the printing of MAC addresses is adjusted. After the
>> modification, only some bytes of the MAC address are
>> displayed.
>>
> 
> Why logging only some bytes of the MAC address?
I understand that the entire MAC address information can be obtained by 
printing part of the value, instead of printing all the MAC addresses.
> 
>> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>> ---
>>   drivers/net/hns3/hns3_ethdev.c    | 53 
>> +++++++++++++++++++++++----------------
>>   drivers/net/hns3/hns3_ethdev.h    |  2 ++
>>   drivers/net/hns3/hns3_ethdev_vf.c | 32 +++++++++++------------
>>   3 files changed, 49 insertions(+), 38 deletions(-)
>>
>> diff --git a/drivers/net/hns3/hns3_ethdev.c 
>> b/drivers/net/hns3/hns3_ethdev.c
>> index 2011378..d6d3f03 100644
>> --- a/drivers/net/hns3/hns3_ethdev.c
>> +++ b/drivers/net/hns3/hns3_ethdev.c
>> @@ -102,6 +102,15 @@ static int hns3_remove_mc_addr(struct hns3_hw *hw,
>>   static int hns3_restore_fec(struct hns3_hw *hw);
>>   static int hns3_query_dev_fec_info(struct rte_eth_dev *dev);
>> +void hns3_ether_format_addr(char *buf, uint16_t size,
>> +                const struct rte_ether_addr *ether_addr)
>> +{
>> +    snprintf(buf, size, "%02X:**:**:**:%02X:%02X",
>> +        ether_addr->addr_bytes[0],
>> +        ether_addr->addr_bytes[4],
>> +        ether_addr->addr_bytes[5]);
>> +}
>> +
>>   static void
>>   hns3_pf_disable_irq0(struct hns3_hw *hw)
>>   {
>> @@ -1449,7 +1458,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, 
>> struct rte_ether_addr *mac_addr)
>>       /* 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,
>> +        hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
>>                         mac_addr);
> 
> Is all these interim variable only to log the mac address? If so why not 
> use macros insted, something like:
> 
> #define FMT "%02x:%02x:%02x:%02x:%02x:%02x"
> #define MAC(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
> 
> hns3_err(fw, "Add unicast mac addr err! addr(" FMT ") invalid", 
> MAC(mac_addr));
Looks like a good suggestion. I need to discuss it with the author. 
Maybe it will be fixed in the new version.
> 
> .
>
oulijun Dec. 10, 2020, 11:54 a.m. UTC | #3
在 2020/12/7 22:52, oulijun 写道:
> 
> 
> 在 2020/11/20 22:25, Ferruh Yigit 写道:
>> On 11/20/2020 11:27 AM, Lijun Ou wrote:
>>> Here the printing of MAC addresses is adjusted. After the
>>> modification, only some bytes of the MAC address are
>>> displayed.
>>>
>>
>> Why logging only some bytes of the MAC address?
> I understand that the entire MAC address information can be obtained by 
> printing part of the value, instead of printing all the MAC addresses.
>>
>>> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
>>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>>> ---
>>>   drivers/net/hns3/hns3_ethdev.c    | 53 
>>> +++++++++++++++++++++++----------------
>>>   drivers/net/hns3/hns3_ethdev.h    |  2 ++
>>>   drivers/net/hns3/hns3_ethdev_vf.c | 32 +++++++++++------------
>>>   3 files changed, 49 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/drivers/net/hns3/hns3_ethdev.c 
>>> b/drivers/net/hns3/hns3_ethdev.c
>>> index 2011378..d6d3f03 100644
>>> --- a/drivers/net/hns3/hns3_ethdev.c
>>> +++ b/drivers/net/hns3/hns3_ethdev.c
>>> @@ -102,6 +102,15 @@ static int hns3_remove_mc_addr(struct hns3_hw *hw,
>>>   static int hns3_restore_fec(struct hns3_hw *hw);
>>>   static int hns3_query_dev_fec_info(struct rte_eth_dev *dev);
>>> +void hns3_ether_format_addr(char *buf, uint16_t size,
>>> +                const struct rte_ether_addr *ether_addr)
>>> +{
>>> +    snprintf(buf, size, "%02X:**:**:**:%02X:%02X",
>>> +        ether_addr->addr_bytes[0],
>>> +        ether_addr->addr_bytes[4],
>>> +        ether_addr->addr_bytes[5]);
>>> +}
>>> +
>>>   static void
>>>   hns3_pf_disable_irq0(struct hns3_hw *hw)
>>>   {
>>> @@ -1449,7 +1458,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, 
>>> struct rte_ether_addr *mac_addr)
>>>       /* 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,
>>> +        hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
>>>                         mac_addr);
>>
>> Is all these interim variable only to log the mac address? If so why 
>> not use macros insted, something like:
>>
>> #define FMT "%02x:%02x:%02x:%02x:%02x:%02x"
>> #define MAC(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
>>
>> hns3_err(fw, "Add unicast mac addr err! addr(" FMT ") invalid", 
>> MAC(mac_addr));
> Looks like a good suggestion. I need to discuss it with the author. 
> Maybe it will be fixed in the new version.
Hi,Ferruh Yigit
   We think that the effect is the same. In addition, an error occurs 
when you use the scheme provided by you. The definition of hns3_err 
needs to be modified.

Thanks
Lijun Ou
>>
>> .
>>

Patch
diff mbox series

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 2011378..d6d3f03 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -102,6 +102,15 @@  static int hns3_remove_mc_addr(struct hns3_hw *hw,
 static int hns3_restore_fec(struct hns3_hw *hw);
 static int hns3_query_dev_fec_info(struct rte_eth_dev *dev);
 
+void hns3_ether_format_addr(char *buf, uint16_t size,
+			    const struct rte_ether_addr *ether_addr)
+{
+	snprintf(buf, size, "%02X:**:**:**:%02X:%02X",
+		ether_addr->addr_bytes[0],
+		ether_addr->addr_bytes[4],
+		ether_addr->addr_bytes[5]);
+}
+
 static void
 hns3_pf_disable_irq0(struct hns3_hw *hw)
 {
@@ -1449,7 +1458,7 @@  hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	/* 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,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "Add unicast mac addr err! addr(%s) invalid",
 			 mac_str);
@@ -1489,7 +1498,7 @@  hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 		return -ENOSPC;
 	}
 
-	rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr);
+	hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr);
 
 	/* check if we just hit the duplicate */
 	if (ret == 0) {
@@ -1515,7 +1524,7 @@  hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 		addr = &hw->mc_addrs[i];
 		/* Check if there are duplicate addresses */
 		if (rte_is_same_ether_addr(addr, mac_addr)) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw, "failed to add mc mac addr, same addrs"
 				 "(%s) is added by the set_mc_mac_addr_list "
@@ -1526,7 +1535,7 @@  hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	ret = hns3_add_mc_addr(hw, mac_addr);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add mc mac addr(%s), ret = %d",
 			 mac_str, ret);
@@ -1542,7 +1551,7 @@  hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	ret = hns3_remove_mc_addr(hw, mac_addr);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to remove mc mac addr(%s), ret = %d",
 			 mac_str, ret);
@@ -1576,7 +1585,7 @@  hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
 
 	if (ret) {
 		rte_spinlock_unlock(&hw->lock);
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str,
 			 ret);
@@ -1599,7 +1608,7 @@  hns3_remove_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	/* 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,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "remove unicast mac addr err! addr(%s) invalid",
 			 mac_str);
@@ -1635,7 +1644,7 @@  hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx)
 		ret = hns3_remove_uc_addr_common(hw, mac_addr);
 	rte_spinlock_unlock(&hw->lock);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to remove mac addr(%s), ret = %d", mac_str,
 			 ret);
@@ -1666,7 +1675,7 @@  hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	if (default_addr_setted) {
 		ret = hns3_remove_uc_addr_common(hw, oaddr);
 		if (ret) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      oaddr);
 			hns3_warn(hw, "Remove old uc mac address(%s) fail: %d",
 				  mac_str, ret);
@@ -1677,7 +1686,7 @@  hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 
 	ret = hns3_add_uc_addr_common(hw, mac_addr);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "Failed to set mac addr(%s): %d", mac_str, ret);
 		goto err_add_uc_addr;
@@ -1699,7 +1708,7 @@  hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 err_pause_addr_cfg:
 	ret_val = hns3_remove_uc_addr_common(hw, mac_addr);
 	if (ret_val) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_warn(hw,
 			  "Failed to roll back to del setted mac addr(%s): %d",
@@ -1710,7 +1719,7 @@  hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	if (rm_succes) {
 		ret_val = hns3_add_uc_addr_common(hw, oaddr);
 		if (ret_val) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      oaddr);
 			hns3_warn(hw,
 				  "Failed to restore old uc mac addr(%s): %d",
@@ -1746,7 +1755,7 @@  hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del)
 
 		if (ret) {
 			err = ret;
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw, "failed to %s mac addr(%s) index:%d "
 				 "ret = %d.", del ? "remove" : "restore",
@@ -1795,7 +1804,7 @@  hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	/* Check if mac addr is valid */
 	if (!rte_is_multicast_ether_addr(mac_addr)) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add mc mac addr, addr(%s) invalid",
 			 mac_str);
@@ -1823,7 +1832,7 @@  hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 	if (ret) {
 		if (ret == -ENOSPC)
 			hns3_err(hw, "mc mac vlan table is full");
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret);
 	}
@@ -1842,7 +1851,7 @@  hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	/* Check if mac addr is valid */
 	if (!rte_is_multicast_ether_addr(mac_addr)) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "Failed to rm mc mac addr, addr(%s) invalid",
 			 mac_str);
@@ -1870,7 +1879,7 @@  hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 	}
 
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "Failed to rm mc mac addr(%s): %d", mac_str, ret);
 	}
@@ -1899,7 +1908,7 @@  hns3_set_mc_addr_chk_param(struct hns3_hw *hw,
 	for (i = 0; i < nb_mc_addr; i++) {
 		addr = &mc_addr_set[i];
 		if (!rte_is_multicast_ether_addr(addr)) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw,
 				 "failed to set mc mac addr, addr(%s) invalid.",
@@ -1910,7 +1919,7 @@  hns3_set_mc_addr_chk_param(struct hns3_hw *hw,
 		/* Check if there are duplicate addresses */
 		for (j = i + 1; j < nb_mc_addr; j++) {
 			if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) {
-				rte_ether_format_addr(mac_str,
+				hns3_ether_format_addr(mac_str,
 						      RTE_ETHER_ADDR_FMT_SIZE,
 						      addr);
 				hns3_err(hw, "failed to set mc mac addr, "
@@ -1927,7 +1936,7 @@  hns3_set_mc_addr_chk_param(struct hns3_hw *hw,
 		for (j = 0; j < HNS3_UC_MACADDR_NUM; j++) {
 			if (rte_is_same_ether_addr(addr,
 						   &hw->data->mac_addrs[j])) {
-				rte_ether_format_addr(mac_str,
+				hns3_ether_format_addr(mac_str,
 						      RTE_ETHER_ADDR_FMT_SIZE,
 						      addr);
 				hns3_err(hw, "failed to set mc mac addr, "
@@ -2101,7 +2110,7 @@  hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del)
 			ret = hns3_add_mc_addr(hw, addr);
 		if (ret) {
 			err = ret;
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_dbg(hw, "%s mc mac addr: %s failed for pf: ret = %d",
 				 del ? "Remove" : "Restore", mac_str, ret);
@@ -6160,7 +6169,7 @@  hns3_dev_init(struct rte_eth_dev *eth_dev)
 	eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr;
 	if (!rte_is_valid_assigned_ether_addr(eth_addr)) {
 		rte_eth_random_addr(hw->mac.mac_addr);
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				(struct rte_ether_addr *)hw->mac.mac_addr);
 		hns3_warn(hw, "default mac_addr from firmware is an invalid "
 			  "unicast address, using random MAC address %s",
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 4c40df1..31f78a1 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -935,6 +935,8 @@  int hns3_dev_filter_ctrl(struct rte_eth_dev *dev,
 bool hns3_is_reset_pending(struct hns3_adapter *hns);
 bool hns3vf_is_reset_pending(struct hns3_adapter *hns);
 void hns3_update_link_status(struct hns3_hw *hw);
+void hns3_ether_format_addr(char *buf, uint16_t size,
+			const struct rte_ether_addr *ether_addr);
 
 static inline bool
 is_reset_pending(struct hns3_adapter *hns)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 0366b9d..f09cabc 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -170,7 +170,7 @@  hns3vf_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 				HNS3_MBX_MAC_VLAN_UC_ADD, mac_addr->addr_bytes,
 				RTE_ETHER_ADDR_LEN, false, NULL, 0);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add uc mac addr(%s), ret = %d",
 			 mac_str, ret);
@@ -190,7 +190,7 @@  hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 				mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN,
 				false, NULL, 0);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add uc mac addr(%s), ret = %d",
 			 mac_str, ret);
@@ -210,7 +210,7 @@  hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 		addr = &hw->mc_addrs[i];
 		/* Check if there are duplicate addresses */
 		if (rte_is_same_ether_addr(addr, mac_addr)) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw, "failed to add mc mac addr, same addrs"
 				 "(%s) is added by the set_mc_mac_addr_list "
@@ -221,7 +221,7 @@  hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 
 	ret = hns3vf_add_mc_mac_addr(hw, mac_addr);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add mc mac addr(%s), ret = %d",
 			 mac_str, ret);
@@ -256,7 +256,7 @@  hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
 
 	rte_spinlock_unlock(&hw->lock);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str,
 			 ret);
@@ -283,7 +283,7 @@  hns3vf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx)
 
 	rte_spinlock_unlock(&hw->lock);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "failed to remove mac addr(%s), ret = %d",
 			 mac_str, ret);
@@ -324,12 +324,12 @@  hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,
 		 * -EPREM to VF driver through mailbox.
 		 */
 		if (ret == -EPERM) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      old_addr);
 			hns3_warn(hw, "Has permanet mac addr(%s) for vf",
 				  mac_str);
 		} else {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      mac_addr);
 			hns3_err(hw, "Failed to set mac addr(%s) for vf: %d",
 				 mac_str, ret);
@@ -366,7 +366,7 @@  hns3vf_configure_mac_addr(struct hns3_adapter *hns, bool del)
 
 		if (ret) {
 			err = ret;
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw, "failed to %s mac addr(%s) index:%d "
 				 "ret = %d.", del ? "remove" : "restore",
@@ -388,7 +388,7 @@  hns3vf_add_mc_mac_addr(struct hns3_hw *hw,
 				mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false,
 				NULL, 0);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "Failed to add mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
@@ -409,7 +409,7 @@  hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,
 				mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false,
 				NULL, 0);
 	if (ret) {
-		rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 				      mac_addr);
 		hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
@@ -439,7 +439,7 @@  hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw,
 	for (i = 0; i < nb_mc_addr; i++) {
 		addr = &mc_addr_set[i];
 		if (!rte_is_multicast_ether_addr(addr)) {
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw,
 				 "failed to set mc mac addr, addr(%s) invalid.",
@@ -450,7 +450,7 @@  hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw,
 		/* Check if there are duplicate addresses */
 		for (j = i + 1; j < nb_mc_addr; j++) {
 			if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) {
-				rte_ether_format_addr(mac_str,
+				hns3_ether_format_addr(mac_str,
 						      RTE_ETHER_ADDR_FMT_SIZE,
 						      addr);
 				hns3_err(hw, "failed to set mc mac addr, "
@@ -467,7 +467,7 @@  hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw,
 		for (j = 0; j < HNS3_VF_UC_MACADDR_NUM; j++) {
 			if (rte_is_same_ether_addr(addr,
 						   &hw->data->mac_addrs[j])) {
-				rte_ether_format_addr(mac_str,
+				hns3_ether_format_addr(mac_str,
 						      RTE_ETHER_ADDR_FMT_SIZE,
 						      addr);
 				hns3_err(hw, "failed to set mc mac addr, "
@@ -550,7 +550,7 @@  hns3vf_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del)
 			ret = hns3vf_add_mc_mac_addr(hw, addr);
 		if (ret) {
 			err = ret;
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      addr);
 			hns3_err(hw, "Failed to %s mc mac addr: %s for vf: %d",
 				 del ? "Remove" : "Restore", mac_str, ret);
@@ -2468,7 +2468,7 @@  hns3vf_check_default_mac_change(struct hns3_hw *hw)
 		ret = rte_is_same_ether_addr(&hw->data->mac_addrs[0], hw_mac);
 		if (!ret) {
 			rte_ether_addr_copy(hw_mac, &hw->data->mac_addrs[0]);
-			rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
 					      &hw->data->mac_addrs[0]);
 			hns3_warn(hw, "Default MAC address has been changed to:"
 				  " %s by the host PF kernel ethdev driver",