[dpdk-dev] [PATCH 3/4] net/hns3: adjust printing MAC addresses in log

oulijun oulijun at huawei.com
Mon Dec 7 15:52:32 CET 2020



在 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 at huawei.com>
>> Signed-off-by: Lijun Ou <oulijun at 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.
> 
> .
> 


More information about the dev mailing list