OSDN Git Service

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)
commit0bd7e894dffaa1fdbef9dcf68b5994a18ff32024
treea9bfae1dc2cc812055b994fa2aee12aa5b6f3fb1
parentc99fead7cb07979f5db38035ccb5f02ad2c7106a
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