This patchset refactors the MAC table management, configure
the MAC address asynchronously, instead of synchronously.
Base on this change, it also refines the handle of promisc
mode and filter table entries restoring after reset.
Jian Shen (8):
net: hns3: refine for unicast MAC VLAN space management
net: hns3: remove unnecessary parameter 'is_alloc' in
hclge_set_umv_space()
net: hns3: replace num_req_vfs with num_alloc_vport in
hclge_reset_umv_space()
net: hns3: refactor the MAC address configure
net: hns3: add support for dumping UC and MC MAC list
net: hns3: refactor the promisc mode setting
net: hns3: use mutex vport_lock instead of mutex umv_lock
net: hns3: optimize the filter table entries handling when resetting
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 5 +
drivers/net/ethernet/hisilicon/hns3/hnae3.h | 8 +-
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 152 +---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 10 +-
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +-
.../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 51 ++
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 867 ++++++++++++++++-----
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 33 +-
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 70 +-
.../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 368 ++++++++-
.../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 26 +
12 files changed, 1166 insertions(+), 428 deletions(-)
--
2.7.4
From: Jian Shen <[email protected]>
Currently, the driver use mutex umv_lock to protect the variable
vport->share_umv_size. And there is already a mutex vport_lock
being defined in the driver, which is designed to protect the
resource of vport. So we can use vport_lock instead of umv_lock.
Furthermore, there is a time window for protect share_umv_size
between checking UMV space and doing MAC configuration in the
lin function hclge_add_uc_addr_common(). It should be extended.
This patch uses mutex vport_lock intead of spin lock umv_lock to
protect share_umv_size, and adjusts the mutex's range.
Signed-off-by: Jian Shen <[email protected]>
Signed-off-by: Huazhong Tan <[email protected]>
---
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 31 +++++++++++++---------
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 -
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 71ff0fa..177ef5e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -7250,7 +7250,6 @@ static int hclge_init_umv_space(struct hclge_dev *hdev)
"failed to alloc umv space, want %u, get %u\n",
hdev->wanted_umv_size, allocated_size);
- mutex_init(&hdev->umv_mutex);
hdev->max_umv_size = allocated_size;
hdev->priv_umv_size = hdev->max_umv_size / (hdev->num_alloc_vport + 1);
hdev->share_umv_size = hdev->priv_umv_size +
@@ -7269,21 +7268,25 @@ static void hclge_reset_umv_space(struct hclge_dev *hdev)
vport->used_umv_num = 0;
}
- mutex_lock(&hdev->umv_mutex);
+ mutex_lock(&hdev->vport_lock);
hdev->share_umv_size = hdev->priv_umv_size +
hdev->max_umv_size % (hdev->num_alloc_vport + 1);
- mutex_unlock(&hdev->umv_mutex);
+ mutex_unlock(&hdev->vport_lock);
}
-static bool hclge_is_umv_space_full(struct hclge_vport *vport)
+static bool hclge_is_umv_space_full(struct hclge_vport *vport, bool need_lock)
{
struct hclge_dev *hdev = vport->back;
bool is_full;
- mutex_lock(&hdev->umv_mutex);
+ if (need_lock)
+ mutex_lock(&hdev->vport_lock);
+
is_full = (vport->used_umv_num >= hdev->priv_umv_size &&
hdev->share_umv_size == 0);
- mutex_unlock(&hdev->umv_mutex);
+
+ if (need_lock)
+ mutex_unlock(&hdev->vport_lock);
return is_full;
}
@@ -7292,7 +7295,6 @@ static void hclge_update_umv_space(struct hclge_vport *vport, bool is_free)
{
struct hclge_dev *hdev = vport->back;
- mutex_lock(&hdev->umv_mutex);
if (is_free) {
if (vport->used_umv_num > hdev->priv_umv_size)
hdev->share_umv_size++;
@@ -7305,7 +7307,6 @@ static void hclge_update_umv_space(struct hclge_vport *vport, bool is_free)
hdev->share_umv_size--;
vport->used_umv_num++;
}
- mutex_unlock(&hdev->umv_mutex);
}
static struct hclge_mac_node *hclge_find_mac_node(struct list_head *list,
@@ -7446,12 +7447,15 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport,
*/
ret = hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false);
if (ret == -ENOENT) {
- if (!hclge_is_umv_space_full(vport)) {
+ mutex_lock(&hdev->vport_lock);
+ if (!hclge_is_umv_space_full(vport, false)) {
ret = hclge_add_mac_vlan_tbl(vport, &req, NULL);
if (!ret)
hclge_update_umv_space(vport, false);
+ mutex_unlock(&hdev->vport_lock);
return ret;
}
+ mutex_unlock(&hdev->vport_lock);
if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_UPE))
dev_err(&hdev->pdev->dev, "UC MAC table full(%u)\n",
@@ -7503,10 +7507,13 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport,
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0);
hclge_prepare_mac_addr(&req, addr, false);
ret = hclge_remove_mac_vlan_tbl(vport, &req);
- if (!ret)
+ if (!ret) {
+ mutex_lock(&hdev->vport_lock);
hclge_update_umv_space(vport, true);
- else if (ret == -ENOENT)
+ mutex_unlock(&hdev->vport_lock);
+ } else if (ret == -ENOENT) {
ret = 0;
+ }
return ret;
}
@@ -10163,7 +10170,7 @@ static int hclge_set_vf_spoofchk(struct hnae3_handle *handle, int vf,
dev_warn(&hdev->pdev->dev,
"vf %d vlan table is full, enable spoof check may cause its packet send fail\n",
vf);
- else if (enable && hclge_is_umv_space_full(vport))
+ else if (enable && hclge_is_umv_space_full(vport, true))
dev_warn(&hdev->pdev->dev,
"vf %d mac table is full, enable spoof check may cause its packet send fail\n",
vf);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 85180f4..8e69651 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -831,7 +831,6 @@ struct hclge_dev {
u16 priv_umv_size;
/* unicast mac vlan space shared by PF and its VFs */
u16 share_umv_size;
- struct mutex umv_mutex; /* protect share_umv_size */
DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats,
HCLGE_MAC_TNL_LOG_SIZE);
--
2.7.4
From: Jian Shen <[email protected]>
Like the calculation elsewhere, replaces num_req_vfs with
num_alloc_vport in hclge_reset_umv_space().
Signed-off-by: Jian Shen <[email protected]>
Signed-off-by: Huazhong Tan <[email protected]>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index fe6e60a..a268004 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -7254,7 +7254,7 @@ static void hclge_reset_umv_space(struct hclge_dev *hdev)
mutex_lock(&hdev->umv_mutex);
hdev->share_umv_size = hdev->priv_umv_size +
- hdev->max_umv_size % (hdev->num_req_vfs + 2);
+ hdev->max_umv_size % (hdev->num_alloc_vport + 1);
mutex_unlock(&hdev->umv_mutex);
}
--
2.7.4
On Fri, 24 Apr 2020 10:23:05 +0800 Huazhong Tan wrote:
> This patchset refactors the MAC table management, configure
> the MAC address asynchronously, instead of synchronously.
> Base on this change, it also refines the handle of promisc
> mode and filter table entries restoring after reset.
Looks like in patch 2 you could also remove the check if allocated_size
is NULL if there is only once caller ;) But that's a nit, series seems
okay:
Acked-by: Jakub Kicinski <[email protected]>
On 2020/4/25 7:23, Jakub Kicinski wrote:
> On Fri, 24 Apr 2020 10:23:05 +0800 Huazhong Tan wrote:
>> This patchset refactors the MAC table management, configure
>> the MAC address asynchronously, instead of synchronously.
>> Base on this change, it also refines the handle of promisc
>> mode and filter table entries restoring after reset.
>
> Looks like in patch 2 you could also remove the check if allocated_size
> is NULL if there is only once caller ;) But that's a nit, series seems
> okay:
>
> Acked-by: Jakub Kicinski <[email protected]>
>
Will send a V2 to remove it.
Thanks :)
> .
>
From: Huazhong Tan <[email protected]>
Date: Fri, 24 Apr 2020 10:23:05 +0800
> This patchset refactors the MAC table management, configure
> the MAC address asynchronously, instead of synchronously.
> Base on this change, it also refines the handle of promisc
> mode and filter table entries restoring after reset.
Series applied, thanks.