Merge branch 'net-hns3-add-some-bugfixes-and-cleanups'
Huazhong Tan says: ==================== net: hns3: add some bugfixes and cleanups This patch-set includes bugfixes and cleanups for the HNS3 ethernet controller driver. [patch 01/07] fixes an error when setting VLAN offload. [patch 02/07] fixes an double free issue when setting ringparam. [patch 03/07] fixes a mis-assignment of hdev->reset_level. [patch 04/07] adds a checking for client's validity. [patch 05/07] simplifies bool variable's assignment. [patch 06/07] disables loopback when initializing. [patch 07/07] makes internal function to static. Change log: V1->V2: fixes comment from Sergei Shtylyov. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
7250a9d21e
|
@ -138,12 +138,28 @@ EXPORT_SYMBOL(hnae3_register_client);
|
|||
|
||||
void hnae3_unregister_client(struct hnae3_client *client)
|
||||
{
|
||||
struct hnae3_client *client_tmp;
|
||||
struct hnae3_ae_dev *ae_dev;
|
||||
bool existed = false;
|
||||
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
mutex_lock(&hnae3_common_lock);
|
||||
|
||||
list_for_each_entry(client_tmp, &hnae3_client_list, node) {
|
||||
if (client_tmp->type == client->type) {
|
||||
existed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!existed) {
|
||||
mutex_unlock(&hnae3_common_lock);
|
||||
pr_err("client %s does not exist!\n", client->name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* un-initialize the client on every matched port */
|
||||
list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) {
|
||||
hnae3_uninit_client_instance(client, ae_dev);
|
||||
|
|
|
@ -908,9 +908,11 @@ static struct hns3_enet_ring *hns3_backup_ringparam(struct hns3_nic_priv *priv)
|
|||
if (!tmp_rings)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < handle->kinfo.num_tqps * 2; i++)
|
||||
for (i = 0; i < handle->kinfo.num_tqps * 2; i++) {
|
||||
memcpy(&tmp_rings[i], priv->ring_data[i].ring,
|
||||
sizeof(struct hns3_enet_ring));
|
||||
tmp_rings[i].skb = NULL;
|
||||
}
|
||||
|
||||
return tmp_rings;
|
||||
}
|
||||
|
|
|
@ -949,7 +949,7 @@ static void hclge_dbg_dump_rst_info(struct hclge_dev *hdev)
|
|||
hdev->rst_stats.reset_cnt);
|
||||
}
|
||||
|
||||
void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev)
|
||||
static void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev)
|
||||
{
|
||||
struct hclge_desc *desc_src, *desc_tmp;
|
||||
struct hclge_get_m7_bd_cmd *req;
|
||||
|
|
|
@ -66,6 +66,7 @@ static void hclge_rfs_filter_expire(struct hclge_dev *hdev);
|
|||
static void hclge_clear_arfs_rules(struct hnae3_handle *handle);
|
||||
static enum hnae3_reset_type hclge_get_reset_level(struct hnae3_ae_dev *ae_dev,
|
||||
unsigned long *addr);
|
||||
static int hclge_set_default_loopback(struct hclge_dev *hdev);
|
||||
|
||||
static struct hnae3_ae_algo ae_algo;
|
||||
|
||||
|
@ -2599,6 +2600,10 @@ static int hclge_mac_init(struct hclge_dev *hdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = hclge_set_default_loopback(hdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = hclge_buffer_alloc(hdev);
|
||||
if (ret)
|
||||
dev_err(&hdev->pdev->dev,
|
||||
|
@ -3619,6 +3624,7 @@ static int hclge_reset_stack(struct hclge_dev *hdev)
|
|||
static void hclge_reset(struct hclge_dev *hdev)
|
||||
{
|
||||
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
|
||||
enum hnae3_reset_type reset_level;
|
||||
int ret;
|
||||
|
||||
/* Initialize ae_dev reset status as well, in case enet layer wants to
|
||||
|
@ -3697,10 +3703,10 @@ static void hclge_reset(struct hclge_dev *hdev)
|
|||
* it should be handled as soon as possible. since some errors
|
||||
* need this kind of reset to fix.
|
||||
*/
|
||||
hdev->reset_level = hclge_get_reset_level(ae_dev,
|
||||
&hdev->default_reset_request);
|
||||
if (hdev->reset_level != HNAE3_NONE_RESET)
|
||||
set_bit(hdev->reset_level, &hdev->reset_request);
|
||||
reset_level = hclge_get_reset_level(ae_dev,
|
||||
&hdev->default_reset_request);
|
||||
if (reset_level != HNAE3_NONE_RESET)
|
||||
set_bit(reset_level, &hdev->reset_request);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -6173,7 +6179,7 @@ static void hclge_enable_fd(struct hnae3_handle *handle, bool enable)
|
|||
bool clear;
|
||||
|
||||
hdev->fd_en = enable;
|
||||
clear = hdev->fd_active_type == HCLGE_FD_ARFS_ACTIVE ? true : false;
|
||||
clear = hdev->fd_active_type == HCLGE_FD_ARFS_ACTIVE;
|
||||
if (!enable)
|
||||
hclge_del_all_fd_entries(handle, clear);
|
||||
else
|
||||
|
@ -6330,7 +6336,7 @@ static int hclge_set_app_loopback(struct hclge_dev *hdev, bool en)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en,
|
||||
static int hclge_cfg_serdes_loopback(struct hclge_dev *hdev, bool en,
|
||||
enum hnae3_loop loop_mode)
|
||||
{
|
||||
#define HCLGE_SERDES_RETRY_MS 10
|
||||
|
@ -6391,6 +6397,17 @@ static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en,
|
|||
dev_err(&hdev->pdev->dev, "serdes loopback set failed in fw\n");
|
||||
return -EIO;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en,
|
||||
enum hnae3_loop loop_mode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = hclge_cfg_serdes_loopback(hdev, en, loop_mode);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
hclge_cfg_mac_mode(hdev, en);
|
||||
|
||||
|
@ -6534,6 +6551,22 @@ static int hclge_set_loopback(struct hnae3_handle *handle,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int hclge_set_default_loopback(struct hclge_dev *hdev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = hclge_set_app_loopback(hdev, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = hclge_cfg_serdes_loopback(hdev, false, HNAE3_LOOP_SERIAL_SERDES);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return hclge_cfg_serdes_loopback(hdev, false,
|
||||
HNAE3_LOOP_PARALLEL_SERDES);
|
||||
}
|
||||
|
||||
static void hclge_reset_tqp_stats(struct hnae3_handle *handle)
|
||||
{
|
||||
struct hclge_vport *vport = hclge_get_vport(handle);
|
||||
|
@ -7691,6 +7724,7 @@ static int hclge_set_vlan_tx_offload_cfg(struct hclge_vport *vport)
|
|||
struct hclge_vport_vtag_tx_cfg_cmd *req;
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
struct hclge_desc desc;
|
||||
u16 bmap_index;
|
||||
int status;
|
||||
|
||||
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_PORT_TX_CFG, false);
|
||||
|
@ -7713,8 +7747,10 @@ static int hclge_set_vlan_tx_offload_cfg(struct hclge_vport *vport)
|
|||
hnae3_set_bit(req->vport_vlan_cfg, HCLGE_CFG_NIC_ROCE_SEL_B, 0);
|
||||
|
||||
req->vf_offset = vport->vport_id / HCLGE_VF_NUM_PER_CMD;
|
||||
req->vf_bitmap[req->vf_offset] =
|
||||
1 << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
|
||||
bmap_index = vport->vport_id % HCLGE_VF_NUM_PER_CMD /
|
||||
HCLGE_VF_NUM_PER_BYTE;
|
||||
req->vf_bitmap[bmap_index] =
|
||||
1U << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
|
||||
|
||||
status = hclge_cmd_send(&hdev->hw, &desc, 1);
|
||||
if (status)
|
||||
|
@ -7731,6 +7767,7 @@ static int hclge_set_vlan_rx_offload_cfg(struct hclge_vport *vport)
|
|||
struct hclge_vport_vtag_rx_cfg_cmd *req;
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
struct hclge_desc desc;
|
||||
u16 bmap_index;
|
||||
int status;
|
||||
|
||||
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_PORT_RX_CFG, false);
|
||||
|
@ -7746,8 +7783,10 @@ static int hclge_set_vlan_rx_offload_cfg(struct hclge_vport *vport)
|
|||
vcfg->vlan2_vlan_prionly ? 1 : 0);
|
||||
|
||||
req->vf_offset = vport->vport_id / HCLGE_VF_NUM_PER_CMD;
|
||||
req->vf_bitmap[req->vf_offset] =
|
||||
1 << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
|
||||
bmap_index = vport->vport_id % HCLGE_VF_NUM_PER_CMD /
|
||||
HCLGE_VF_NUM_PER_BYTE;
|
||||
req->vf_bitmap[bmap_index] =
|
||||
1U << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
|
||||
|
||||
status = hclge_cmd_send(&hdev->hw, &desc, 1);
|
||||
if (status)
|
||||
|
|
Loading…
Reference in New Issue