Merge branch 'hns3-mac'
Guangbin Huang says: ==================== PF support get MAC address space assigned by firmware This series add support PF to get unicast/multicast MAC address space assigned by firmware for the HNS3 ethernet driver. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -95,6 +95,7 @@ enum HNAE3_DEV_CAP_BITS {
|
||||
HNAE3_DEV_SUPPORT_RXD_ADV_LAYOUT_B,
|
||||
HNAE3_DEV_SUPPORT_PORT_VLAN_BYPASS_B,
|
||||
HNAE3_DEV_SUPPORT_VLAN_FLTR_MDF_B,
|
||||
HNAE3_DEV_SUPPORT_MC_MAC_MNG_B,
|
||||
};
|
||||
|
||||
#define hnae3_dev_fd_supported(hdev) \
|
||||
@@ -151,6 +152,9 @@ enum HNAE3_DEV_CAP_BITS {
|
||||
#define hnae3_ae_dev_rxd_adv_layout_supported(ae_dev) \
|
||||
test_bit(HNAE3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, (ae_dev)->caps)
|
||||
|
||||
#define hnae3_ae_dev_mc_mac_mng_supported(ae_dev) \
|
||||
test_bit(HNAE3_DEV_SUPPORT_MC_MAC_MNG_B, (ae_dev)->caps)
|
||||
|
||||
enum HNAE3_PF_CAP_BITS {
|
||||
HNAE3_PF_SUPPORT_VLAN_FLTR_MDF_B = 0,
|
||||
};
|
||||
@@ -341,6 +345,8 @@ struct hnae3_dev_specs {
|
||||
u8 max_non_tso_bd_num; /* max BD number of one non-TSO packet */
|
||||
u16 max_frm_size;
|
||||
u16 max_qset_num;
|
||||
u16 umv_size;
|
||||
u16 mc_mac_size;
|
||||
};
|
||||
|
||||
struct hnae3_client_ops {
|
||||
|
||||
@@ -924,6 +924,10 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
|
||||
dev_specs->max_tm_rate);
|
||||
*pos += scnprintf(buf + *pos, len - *pos, "MAX QSET number: %u\n",
|
||||
dev_specs->max_qset_num);
|
||||
*pos += scnprintf(buf + *pos, len - *pos, "umv size: %u\n",
|
||||
dev_specs->umv_size);
|
||||
*pos += scnprintf(buf + *pos, len - *pos, "mc mac size: %u\n",
|
||||
dev_specs->mc_mac_size);
|
||||
}
|
||||
|
||||
static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
|
||||
|
||||
@@ -1188,7 +1188,10 @@ struct hclge_dev_specs_1_cmd {
|
||||
__le16 max_frm_size;
|
||||
__le16 max_qset_num;
|
||||
__le16 max_int_gl;
|
||||
u8 rsv1[18];
|
||||
u8 rsv0[2];
|
||||
__le16 umv_size;
|
||||
__le16 mc_mac_size;
|
||||
u8 rsv1[12];
|
||||
};
|
||||
|
||||
/* mac speed type defined in firmware command */
|
||||
|
||||
@@ -1968,6 +1968,9 @@ static int hclge_dbg_dump_umv_info(struct hclge_dev *hdev, char *buf, int len)
|
||||
}
|
||||
mutex_unlock(&hdev->vport_lock);
|
||||
|
||||
pos += scnprintf(buf + pos, len - pos, "used_mc_mac_num : %u\n",
|
||||
hdev->used_mc_mac_num);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1342,8 +1342,6 @@ static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc)
|
||||
cfg->umv_space = hnae3_get_field(__le32_to_cpu(req->param[1]),
|
||||
HCLGE_CFG_UMV_TBL_SPACE_M,
|
||||
HCLGE_CFG_UMV_TBL_SPACE_S);
|
||||
if (!cfg->umv_space)
|
||||
cfg->umv_space = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
|
||||
|
||||
cfg->pf_rss_size_max = hnae3_get_field(__le32_to_cpu(req->param[2]),
|
||||
HCLGE_CFG_PF_RSS_SIZE_M,
|
||||
@@ -1419,6 +1417,7 @@ static void hclge_set_default_dev_specs(struct hclge_dev *hdev)
|
||||
ae_dev->dev_specs.max_int_gl = HCLGE_DEF_MAX_INT_GL;
|
||||
ae_dev->dev_specs.max_frm_size = HCLGE_MAC_MAX_FRAME;
|
||||
ae_dev->dev_specs.max_qset_num = HCLGE_MAX_QSET_NUM;
|
||||
ae_dev->dev_specs.umv_size = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
|
||||
}
|
||||
|
||||
static void hclge_parse_dev_specs(struct hclge_dev *hdev,
|
||||
@@ -1440,6 +1439,8 @@ static void hclge_parse_dev_specs(struct hclge_dev *hdev,
|
||||
ae_dev->dev_specs.max_qset_num = le16_to_cpu(req1->max_qset_num);
|
||||
ae_dev->dev_specs.max_int_gl = le16_to_cpu(req1->max_int_gl);
|
||||
ae_dev->dev_specs.max_frm_size = le16_to_cpu(req1->max_frm_size);
|
||||
ae_dev->dev_specs.umv_size = le16_to_cpu(req1->umv_size);
|
||||
ae_dev->dev_specs.mc_mac_size = le16_to_cpu(req1->mc_mac_size);
|
||||
}
|
||||
|
||||
static void hclge_check_dev_specs(struct hclge_dev *hdev)
|
||||
@@ -1460,6 +1461,8 @@ static void hclge_check_dev_specs(struct hclge_dev *hdev)
|
||||
dev_specs->max_int_gl = HCLGE_DEF_MAX_INT_GL;
|
||||
if (!dev_specs->max_frm_size)
|
||||
dev_specs->max_frm_size = HCLGE_MAC_MAX_FRAME;
|
||||
if (!dev_specs->umv_size)
|
||||
dev_specs->umv_size = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
|
||||
}
|
||||
|
||||
static int hclge_query_dev_specs(struct hclge_dev *hdev)
|
||||
@@ -1548,7 +1551,10 @@ static int hclge_configure(struct hclge_dev *hdev)
|
||||
hdev->tm_info.num_pg = 1;
|
||||
hdev->tc_max = cfg.tc_num;
|
||||
hdev->tm_info.hw_pfc_map = 0;
|
||||
hdev->wanted_umv_size = cfg.umv_space;
|
||||
if (cfg.umv_space)
|
||||
hdev->wanted_umv_size = cfg.umv_space;
|
||||
else
|
||||
hdev->wanted_umv_size = hdev->ae_dev->dev_specs.umv_size;
|
||||
hdev->tx_spare_buf_size = cfg.tx_spare_buf_size;
|
||||
hdev->gro_en = true;
|
||||
if (cfg.vlan_fliter_cap == HCLGE_VLAN_FLTR_CAN_MDF)
|
||||
@@ -8475,6 +8481,9 @@ static int hclge_init_umv_space(struct hclge_dev *hdev)
|
||||
hdev->share_umv_size = hdev->priv_umv_size +
|
||||
hdev->max_umv_size % (hdev->num_alloc_vport + 1);
|
||||
|
||||
if (hdev->ae_dev->dev_specs.mc_mac_size)
|
||||
set_bit(HNAE3_DEV_SUPPORT_MC_MAC_MNG_B, hdev->ae_dev->caps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8492,6 +8501,8 @@ static void hclge_reset_umv_space(struct hclge_dev *hdev)
|
||||
hdev->share_umv_size = hdev->priv_umv_size +
|
||||
hdev->max_umv_size % (hdev->num_alloc_vport + 1);
|
||||
mutex_unlock(&hdev->vport_lock);
|
||||
|
||||
hdev->used_mc_mac_num = 0;
|
||||
}
|
||||
|
||||
static bool hclge_is_umv_space_full(struct hclge_vport *vport, bool need_lock)
|
||||
@@ -8753,6 +8764,7 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport,
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
struct hclge_mac_vlan_tbl_entry_cmd req;
|
||||
struct hclge_desc desc[3];
|
||||
bool is_new_addr = false;
|
||||
int status;
|
||||
|
||||
/* mac addr check */
|
||||
@@ -8766,6 +8778,13 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport,
|
||||
hclge_prepare_mac_addr(&req, addr, true);
|
||||
status = hclge_lookup_mac_vlan_tbl(vport, &req, desc, true);
|
||||
if (status) {
|
||||
if (hnae3_ae_dev_mc_mac_mng_supported(hdev->ae_dev) &&
|
||||
hdev->used_mc_mac_num >=
|
||||
hdev->ae_dev->dev_specs.mc_mac_size)
|
||||
goto err_no_space;
|
||||
|
||||
is_new_addr = true;
|
||||
|
||||
/* This mac addr do not exist, add new entry for it */
|
||||
memset(desc[0].data, 0, sizeof(desc[0].data));
|
||||
memset(desc[1].data, 0, sizeof(desc[0].data));
|
||||
@@ -8775,12 +8794,18 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport,
|
||||
if (status)
|
||||
return status;
|
||||
status = hclge_add_mac_vlan_tbl(vport, &req, desc);
|
||||
/* if already overflow, not to print each time */
|
||||
if (status == -ENOSPC &&
|
||||
!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE))
|
||||
dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n");
|
||||
if (status == -ENOSPC)
|
||||
goto err_no_space;
|
||||
else if (!status && is_new_addr)
|
||||
hdev->used_mc_mac_num++;
|
||||
|
||||
return status;
|
||||
|
||||
err_no_space:
|
||||
/* if already overflow, not to print each time */
|
||||
if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE))
|
||||
dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n");
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
static int hclge_rm_mc_addr(struct hnae3_handle *handle,
|
||||
@@ -8817,12 +8842,15 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport,
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (hclge_is_all_function_id_zero(desc))
|
||||
if (hclge_is_all_function_id_zero(desc)) {
|
||||
/* All the vfid is zero, so need to delete this entry */
|
||||
status = hclge_remove_mac_vlan_tbl(vport, &req);
|
||||
else
|
||||
if (!status)
|
||||
hdev->used_mc_mac_num--;
|
||||
} else {
|
||||
/* Not all the vfid is zero, update the vfid */
|
||||
status = hclge_add_mac_vlan_tbl(vport, &req, desc);
|
||||
}
|
||||
} else if (status == -ENOENT) {
|
||||
status = 0;
|
||||
}
|
||||
|
||||
@@ -938,6 +938,8 @@ struct hclge_dev {
|
||||
u16 priv_umv_size;
|
||||
/* unicast mac vlan space shared by PF and its VFs */
|
||||
u16 share_umv_size;
|
||||
/* multicast mac address number used by PF and its VFs */
|
||||
u16 used_mc_mac_num;
|
||||
|
||||
DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats,
|
||||
HCLGE_MAC_TNL_LOG_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user