]> git.baikalelectronics.ru Git - kernel.git/commit
net: hns3: modify mac statistics update process for compatibility
authorGuangbin Huang <huangguangbin2@huawei.com>
Sun, 24 Oct 2021 09:41:09 +0000 (17:41 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Oct 2021 13:00:59 +0000 (14:00 +0100)
commit81c91a5da174147ec60b484dcdf0e17333db93d9
treea9bfae1dc2cc812055b994fa2aee12aa5b6f3fb1
parente5ade26ec4a9d44c98ede6a56f76376fe2571fae
net: hns3: modify mac statistics update process for compatibility

After querying mac statistics from firmware, driver copies data from
descriptors to struct mac_stats of hdev, and the number of copied data
is just according to the register number queried from firmware. There is
a problem that if the register number queried from firmware is larger
than data number of struct mac_stats, it will cause a copy overflow.

So if the firmware adds more mac statistics in later version, it is not
compatible with driver of old version.

To fix this problem, the number of copied data needs to be used the
minimum value between the register number queried from firmware and
data number of struct mac_stats.

The first descriptor has three data and there is one reserved, to
optimize the copy process, add this reserverd data to struct mac_stats.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h