Commit c4d63c71 authored by David S. Miller's avatar David S. Miller

Merge branch 'hns3-fixes'

Huazhong Tan says:

====================
Bugfix for the HNS3 driver

This patch series include bugfix for the HNS3 ethernet
controller driver.

Change log:
V4->V5:
	Fixes comments from Joe Perches & Sergei Shtylyov
V3->V4:
	Fixes comments from Sergei Shtylyov
V2->V3:
	Fixes comments from Sergei Shtylyov
V1->V2:
	Fixes the compilation break reported by kbuild test robot
	http://patchwork.ozlabs.org/patch/989818/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d48051c5 29118ab9
...@@ -316,7 +316,7 @@ struct hnae3_ae_ops { ...@@ -316,7 +316,7 @@ struct hnae3_ae_ops {
int (*set_loopback)(struct hnae3_handle *handle, int (*set_loopback)(struct hnae3_handle *handle,
enum hnae3_loop loop_mode, bool en); enum hnae3_loop loop_mode, bool en);
void (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc, int (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc,
bool en_mc_pmc); bool en_mc_pmc);
int (*set_mtu)(struct hnae3_handle *handle, int new_mtu); int (*set_mtu)(struct hnae3_handle *handle, int new_mtu);
...@@ -391,7 +391,7 @@ struct hnae3_ae_ops { ...@@ -391,7 +391,7 @@ struct hnae3_ae_ops {
int vector_num, int vector_num,
struct hnae3_ring_chain_node *vr_chain); struct hnae3_ring_chain_node *vr_chain);
void (*reset_queue)(struct hnae3_handle *handle, u16 queue_id); int (*reset_queue)(struct hnae3_handle *handle, u16 queue_id);
u32 (*get_fw_version)(struct hnae3_handle *handle); u32 (*get_fw_version)(struct hnae3_handle *handle);
void (*get_mdix_mode)(struct hnae3_handle *handle, void (*get_mdix_mode)(struct hnae3_handle *handle,
u8 *tp_mdix_ctrl, u8 *tp_mdix); u8 *tp_mdix_ctrl, u8 *tp_mdix);
......
...@@ -509,16 +509,18 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev) ...@@ -509,16 +509,18 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)
h->netdev_flags = new_flags; h->netdev_flags = new_flags;
} }
void hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags) int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle; struct hnae3_handle *h = priv->ae_handle;
if (h->ae_algo->ops->set_promisc_mode) { if (h->ae_algo->ops->set_promisc_mode) {
h->ae_algo->ops->set_promisc_mode(h, return h->ae_algo->ops->set_promisc_mode(h,
promisc_flags & HNAE3_UPE, promisc_flags & HNAE3_UPE,
promisc_flags & HNAE3_MPE); promisc_flags & HNAE3_MPE);
} }
return 0;
} }
void hns3_enable_vlan_filter(struct net_device *netdev, bool enable) void hns3_enable_vlan_filter(struct net_device *netdev, bool enable)
...@@ -1494,18 +1496,22 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev, ...@@ -1494,18 +1496,22 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev,
return ret; return ret;
} }
static void hns3_restore_vlan(struct net_device *netdev) static int hns3_restore_vlan(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
int ret = 0;
u16 vid; u16 vid;
int ret;
for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) { for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
ret = hns3_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid); ret = hns3_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid);
if (ret) if (ret) {
netdev_warn(netdev, "Restore vlan: %d filter, ret:%d\n", netdev_err(netdev, "Restore vlan: %d filter, ret:%d\n",
vid, ret); vid, ret);
return ret;
}
} }
return ret;
} }
static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
...@@ -2727,7 +2733,7 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector, ...@@ -2727,7 +2733,7 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
chain = devm_kzalloc(&pdev->dev, sizeof(*chain), chain = devm_kzalloc(&pdev->dev, sizeof(*chain),
GFP_KERNEL); GFP_KERNEL);
if (!chain) if (!chain)
return -ENOMEM; goto err_free_chain;
cur_chain->next = chain; cur_chain->next = chain;
chain->tqp_index = tx_ring->tqp->tqp_index; chain->tqp_index = tx_ring->tqp->tqp_index;
...@@ -2757,7 +2763,7 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector, ...@@ -2757,7 +2763,7 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
while (rx_ring) { while (rx_ring) {
chain = devm_kzalloc(&pdev->dev, sizeof(*chain), GFP_KERNEL); chain = devm_kzalloc(&pdev->dev, sizeof(*chain), GFP_KERNEL);
if (!chain) if (!chain)
return -ENOMEM; goto err_free_chain;
cur_chain->next = chain; cur_chain->next = chain;
chain->tqp_index = rx_ring->tqp->tqp_index; chain->tqp_index = rx_ring->tqp->tqp_index;
...@@ -2772,6 +2778,16 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector, ...@@ -2772,6 +2778,16 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
} }
return 0; return 0;
err_free_chain:
cur_chain = head->next;
while (cur_chain) {
chain = cur_chain->next;
devm_kfree(&pdev->dev, chain);
cur_chain = chain;
}
return -ENOMEM;
} }
static void hns3_free_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector, static void hns3_free_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
...@@ -2821,7 +2837,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) ...@@ -2821,7 +2837,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
struct hnae3_handle *h = priv->ae_handle; struct hnae3_handle *h = priv->ae_handle;
struct hns3_enet_tqp_vector *tqp_vector; struct hns3_enet_tqp_vector *tqp_vector;
int ret = 0; int ret = 0;
u16 i; int i;
hns3_nic_set_cpumask(priv); hns3_nic_set_cpumask(priv);
...@@ -2868,13 +2884,19 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) ...@@ -2868,13 +2884,19 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain); hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain);
if (ret) if (ret)
return ret; goto map_ring_fail;
netif_napi_add(priv->netdev, &tqp_vector->napi, netif_napi_add(priv->netdev, &tqp_vector->napi,
hns3_nic_common_poll, NAPI_POLL_WEIGHT); hns3_nic_common_poll, NAPI_POLL_WEIGHT);
} }
return 0; return 0;
map_ring_fail:
while (i--)
netif_napi_del(&priv->tqp_vector[i].napi);
return ret;
} }
static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
...@@ -3031,8 +3053,10 @@ static int hns3_queue_to_ring(struct hnae3_queue *tqp, ...@@ -3031,8 +3053,10 @@ static int hns3_queue_to_ring(struct hnae3_queue *tqp,
return ret; return ret;
ret = hns3_ring_get_cfg(tqp, priv, HNAE3_RING_TYPE_RX); ret = hns3_ring_get_cfg(tqp, priv, HNAE3_RING_TYPE_RX);
if (ret) if (ret) {
devm_kfree(priv->dev, priv->ring_data[tqp->tqp_index].ring);
return ret; return ret;
}
return 0; return 0;
} }
...@@ -3059,6 +3083,12 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) ...@@ -3059,6 +3083,12 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv)
return 0; return 0;
err: err:
while (i--) {
devm_kfree(priv->dev, priv->ring_data[i].ring);
devm_kfree(priv->dev,
priv->ring_data[i + h->kinfo.num_tqps].ring);
}
devm_kfree(&pdev->dev, priv->ring_data); devm_kfree(&pdev->dev, priv->ring_data);
return ret; return ret;
} }
...@@ -3226,9 +3256,6 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv) ...@@ -3226,9 +3256,6 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv)
int i; int i;
for (i = 0; i < h->kinfo.num_tqps; i++) { for (i = 0; i < h->kinfo.num_tqps; i++) {
if (h->ae_algo->ops->reset_queue)
h->ae_algo->ops->reset_queue(h, i);
hns3_fini_ring(priv->ring_data[i].ring); hns3_fini_ring(priv->ring_data[i].ring);
hns3_fini_ring(priv->ring_data[i + h->kinfo.num_tqps].ring); hns3_fini_ring(priv->ring_data[i + h->kinfo.num_tqps].ring);
} }
...@@ -3236,11 +3263,12 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv) ...@@ -3236,11 +3263,12 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv)
} }
/* Set mac addr if it is configured. or leave it to the AE driver */ /* Set mac addr if it is configured. or leave it to the AE driver */
static void hns3_init_mac_addr(struct net_device *netdev, bool init) static int hns3_init_mac_addr(struct net_device *netdev, bool init)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle; struct hnae3_handle *h = priv->ae_handle;
u8 mac_addr_temp[ETH_ALEN]; u8 mac_addr_temp[ETH_ALEN];
int ret = 0;
if (h->ae_algo->ops->get_mac_addr && init) { if (h->ae_algo->ops->get_mac_addr && init) {
h->ae_algo->ops->get_mac_addr(h, mac_addr_temp); h->ae_algo->ops->get_mac_addr(h, mac_addr_temp);
...@@ -3255,8 +3283,9 @@ static void hns3_init_mac_addr(struct net_device *netdev, bool init) ...@@ -3255,8 +3283,9 @@ static void hns3_init_mac_addr(struct net_device *netdev, bool init)
} }
if (h->ae_algo->ops->set_mac_addr) if (h->ae_algo->ops->set_mac_addr)
h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr, true); ret = h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr, true);
return ret;
} }
static int hns3_restore_fd_rules(struct net_device *netdev) static int hns3_restore_fd_rules(struct net_device *netdev)
...@@ -3469,20 +3498,29 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) ...@@ -3469,20 +3498,29 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
return ret; return ret;
} }
static void hns3_recover_hw_addr(struct net_device *ndev) static int hns3_recover_hw_addr(struct net_device *ndev)
{ {
struct netdev_hw_addr_list *list; struct netdev_hw_addr_list *list;
struct netdev_hw_addr *ha, *tmp; struct netdev_hw_addr *ha, *tmp;
int ret = 0;
/* go through and sync uc_addr entries to the device */ /* go through and sync uc_addr entries to the device */
list = &ndev->uc; list = &ndev->uc;
list_for_each_entry_safe(ha, tmp, &list->list, list) list_for_each_entry_safe(ha, tmp, &list->list, list) {
hns3_nic_uc_sync(ndev, ha->addr); ret = hns3_nic_uc_sync(ndev, ha->addr);
if (ret)
return ret;
}
/* go through and sync mc_addr entries to the device */ /* go through and sync mc_addr entries to the device */
list = &ndev->mc; list = &ndev->mc;
list_for_each_entry_safe(ha, tmp, &list->list, list) list_for_each_entry_safe(ha, tmp, &list->list, list) {
hns3_nic_mc_sync(ndev, ha->addr); ret = hns3_nic_mc_sync(ndev, ha->addr);
if (ret)
return ret;
}
return ret;
} }
static void hns3_remove_hw_addr(struct net_device *netdev) static void hns3_remove_hw_addr(struct net_device *netdev)
...@@ -3609,7 +3647,10 @@ int hns3_nic_reset_all_ring(struct hnae3_handle *h) ...@@ -3609,7 +3647,10 @@ int hns3_nic_reset_all_ring(struct hnae3_handle *h)
int ret; int ret;
for (i = 0; i < h->kinfo.num_tqps; i++) { for (i = 0; i < h->kinfo.num_tqps; i++) {
h->ae_algo->ops->reset_queue(h, i); ret = h->ae_algo->ops->reset_queue(h, i);
if (ret)
return ret;
hns3_init_ring_hw(priv->ring_data[i].ring); hns3_init_ring_hw(priv->ring_data[i].ring);
/* We need to clear tx ring here because self test will /* We need to clear tx ring here because self test will
...@@ -3701,18 +3742,30 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) ...@@ -3701,18 +3742,30 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
bool vlan_filter_enable; bool vlan_filter_enable;
int ret; int ret;
hns3_init_mac_addr(netdev, false); ret = hns3_init_mac_addr(netdev, false);
hns3_recover_hw_addr(netdev); if (ret)
hns3_update_promisc_mode(netdev, handle->netdev_flags); return ret;
ret = hns3_recover_hw_addr(netdev);
if (ret)
return ret;
ret = hns3_update_promisc_mode(netdev, handle->netdev_flags);
if (ret)
return ret;
vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true; vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true;
hns3_enable_vlan_filter(netdev, vlan_filter_enable); hns3_enable_vlan_filter(netdev, vlan_filter_enable);
/* Hardware table is only clear when pf resets */ /* Hardware table is only clear when pf resets */
if (!(handle->flags & HNAE3_SUPPORT_VF)) if (!(handle->flags & HNAE3_SUPPORT_VF)) {
hns3_restore_vlan(netdev); ret = hns3_restore_vlan(netdev);
return ret;
}
hns3_restore_fd_rules(netdev); ret = hns3_restore_fd_rules(netdev);
if (ret)
return ret;
/* Carrier off reporting is important to ethtool even BEFORE open */ /* Carrier off reporting is important to ethtool even BEFORE open */
netif_carrier_off(netdev); netif_carrier_off(netdev);
......
...@@ -640,7 +640,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector, ...@@ -640,7 +640,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
u32 rl_value); u32 rl_value);
void hns3_enable_vlan_filter(struct net_device *netdev, bool enable); void hns3_enable_vlan_filter(struct net_device *netdev, bool enable);
void hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags); int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags);
#ifdef CONFIG_HNS3_DCB #ifdef CONFIG_HNS3_DCB
void hns3_dcbnl_setup(struct hnae3_handle *handle); void hns3_dcbnl_setup(struct hnae3_handle *handle);
......
...@@ -24,15 +24,15 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring) ...@@ -24,15 +24,15 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring)
return ring->desc_num - used - 1; return ring->desc_num - used - 1;
} }
static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int h) static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int head)
{ {
int u = ring->next_to_use; int ntu = ring->next_to_use;
int c = ring->next_to_clean; int ntc = ring->next_to_clean;
if (unlikely(h >= ring->desc_num)) if (ntu > ntc)
return 0; return head >= ntc && head <= ntu;
return u > c ? (h > c && h <= u) : (h > c || h <= u); return head >= ntc || head <= ntu;
} }
static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring) static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring)
...@@ -304,6 +304,10 @@ int hclge_cmd_queue_init(struct hclge_dev *hdev) ...@@ -304,6 +304,10 @@ int hclge_cmd_queue_init(struct hclge_dev *hdev)
{ {
int ret; int ret;
/* Setup the lock for command queue */
spin_lock_init(&hdev->hw.cmq.csq.lock);
spin_lock_init(&hdev->hw.cmq.crq.lock);
/* Setup the queue entries for use cmd queue */ /* Setup the queue entries for use cmd queue */
hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;
hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;
...@@ -337,18 +341,20 @@ int hclge_cmd_init(struct hclge_dev *hdev) ...@@ -337,18 +341,20 @@ int hclge_cmd_init(struct hclge_dev *hdev)
u32 version; u32 version;
int ret; int ret;
spin_lock_bh(&hdev->hw.cmq.csq.lock);
spin_lock_bh(&hdev->hw.cmq.crq.lock);
hdev->hw.cmq.csq.next_to_clean = 0; hdev->hw.cmq.csq.next_to_clean = 0;
hdev->hw.cmq.csq.next_to_use = 0; hdev->hw.cmq.csq.next_to_use = 0;
hdev->hw.cmq.crq.next_to_clean = 0; hdev->hw.cmq.crq.next_to_clean = 0;
hdev->hw.cmq.crq.next_to_use = 0; hdev->hw.cmq.crq.next_to_use = 0;
/* Setup the lock for command queue */
spin_lock_init(&hdev->hw.cmq.csq.lock);
spin_lock_init(&hdev->hw.cmq.crq.lock);
hclge_cmd_init_regs(&hdev->hw); hclge_cmd_init_regs(&hdev->hw);
clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
spin_unlock_bh(&hdev->hw.cmq.crq.lock);
spin_unlock_bh(&hdev->hw.cmq.csq.lock);
ret = hclge_cmd_query_firmware_version(&hdev->hw, &version); ret = hclge_cmd_query_firmware_version(&hdev->hw, &version);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
......
...@@ -2236,7 +2236,7 @@ static irqreturn_t hclge_misc_irq_handle(int irq, void *data) ...@@ -2236,7 +2236,7 @@ static irqreturn_t hclge_misc_irq_handle(int irq, void *data)
} }
/* clear the source of interrupt if it is not cause by reset */ /* clear the source of interrupt if it is not cause by reset */
if (event_cause != HCLGE_VECTOR0_EVENT_RST) { if (event_cause == HCLGE_VECTOR0_EVENT_MBX) {
hclge_clear_event_cause(hdev, event_cause, clearval); hclge_clear_event_cause(hdev, event_cause, clearval);
hclge_enable_vector(&hdev->misc_vector, true); hclge_enable_vector(&hdev->misc_vector, true);
} }
...@@ -2470,14 +2470,17 @@ static void hclge_reset(struct hclge_dev *hdev) ...@@ -2470,14 +2470,17 @@ static void hclge_reset(struct hclge_dev *hdev)
handle = &hdev->vport[0].nic; handle = &hdev->vport[0].nic;
rtnl_lock(); rtnl_lock();
hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
rtnl_unlock();
if (!hclge_reset_wait(hdev)) { if (!hclge_reset_wait(hdev)) {
rtnl_lock();
hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT); hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
hclge_reset_ae_dev(hdev->ae_dev); hclge_reset_ae_dev(hdev->ae_dev);
hclge_notify_client(hdev, HNAE3_INIT_CLIENT); hclge_notify_client(hdev, HNAE3_INIT_CLIENT);
hclge_clear_reset_cause(hdev); hclge_clear_reset_cause(hdev);
} else { } else {
rtnl_lock();
/* schedule again to check pending resets later */ /* schedule again to check pending resets later */
set_bit(hdev->reset_type, &hdev->reset_pending); set_bit(hdev->reset_type, &hdev->reset_pending);
hclge_reset_task_schedule(hdev); hclge_reset_task_schedule(hdev);
...@@ -3314,7 +3317,7 @@ void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc, ...@@ -3314,7 +3317,7 @@ void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc,
param->vf_id = vport_id; param->vf_id = vport_id;
} }
static void hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc, static int hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc,
bool en_mc_pmc) bool en_mc_pmc)
{ {
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
...@@ -3323,7 +3326,7 @@ static void hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc, ...@@ -3323,7 +3326,7 @@ static void hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc,
hclge_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, true, hclge_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, true,
vport->vport_id); vport->vport_id);
hclge_cmd_set_promisc_mode(hdev, &param); return hclge_cmd_set_promisc_mode(hdev, &param);
} }
static int hclge_get_fd_mode(struct hclge_dev *hdev, u8 *fd_mode) static int hclge_get_fd_mode(struct hclge_dev *hdev, u8 *fd_mode)
...@@ -6107,31 +6110,28 @@ static u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, ...@@ -6107,31 +6110,28 @@ static u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle,
return tqp->index; return tqp->index;
} }
void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id) int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
{ {
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
int reset_try_times = 0; int reset_try_times = 0;
int reset_status; int reset_status;
u16 queue_gid; u16 queue_gid;
int ret; int ret = 0;
if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
return;
queue_gid = hclge_covert_handle_qid_global(handle, queue_id); queue_gid = hclge_covert_handle_qid_global(handle, queue_id);
ret = hclge_tqp_enable(hdev, queue_id, 0, false); ret = hclge_tqp_enable(hdev, queue_id, 0, false);
if (ret) { if (ret) {
dev_warn(&hdev->pdev->dev, "Disable tqp fail, ret = %d\n", ret); dev_err(&hdev->pdev->dev, "Disable tqp fail, ret = %d\n", ret);
return; return ret;
} }
ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true); ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true);
if (ret) { if (ret) {
dev_warn(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"Send reset tqp cmd fail, ret = %d\n", ret); "Send reset tqp cmd fail, ret = %d\n", ret);
return; return ret;
} }
reset_try_times = 0; reset_try_times = 0;
...@@ -6144,16 +6144,16 @@ void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id) ...@@ -6144,16 +6144,16 @@ void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
} }
if (reset_try_times >= HCLGE_TQP_RESET_TRY_TIMES) { if (reset_try_times >= HCLGE_TQP_RESET_TRY_TIMES) {
dev_warn(&hdev->pdev->dev, "Reset TQP fail\n"); dev_err(&hdev->pdev->dev, "Reset TQP fail\n");
return; return ret;
} }
ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, false); ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, false);
if (ret) { if (ret)
dev_warn(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"Deassert the soft reset fail, ret = %d\n", ret); "Deassert the soft reset fail, ret = %d\n", ret);
return;
} return ret;
} }
void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id) void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id)
......
...@@ -778,7 +778,7 @@ int hclge_rss_init_hw(struct hclge_dev *hdev); ...@@ -778,7 +778,7 @@ int hclge_rss_init_hw(struct hclge_dev *hdev);
void hclge_rss_indir_init_cfg(struct hclge_dev *hdev); void hclge_rss_indir_init_cfg(struct hclge_dev *hdev);
void hclge_mbx_handler(struct hclge_dev *hdev); void hclge_mbx_handler(struct hclge_dev *hdev);
void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id); int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id);
void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id); void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id);
int hclge_cfg_flowctrl(struct hclge_dev *hdev); int hclge_cfg_flowctrl(struct hclge_dev *hdev);
int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id); int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);
......
...@@ -400,6 +400,12 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -400,6 +400,12 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
/* handle all the mailbox requests in the queue */ /* handle all the mailbox requests in the queue */
while (!hclge_cmd_crq_empty(&hdev->hw)) { while (!hclge_cmd_crq_empty(&hdev->hw)) {
if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) {
dev_warn(&hdev->pdev->dev,
"command queue needs re-initializing\n");
return;
}
desc = &crq->desc[crq->next_to_use]; desc = &crq->desc[crq->next_to_use];
req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data; req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data;
......
...@@ -52,7 +52,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum, ...@@ -52,7 +52,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum,
struct hclge_desc desc; struct hclge_desc desc;
int ret; int ret;
if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state))
return 0; return 0;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false);
...@@ -90,7 +90,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum) ...@@ -90,7 +90,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum)
struct hclge_desc desc; struct hclge_desc desc;
int ret; int ret;
if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state))
return 0; return 0;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true);
......
...@@ -925,12 +925,12 @@ static int hclgevf_cmd_set_promisc_mode(struct hclgevf_dev *hdev, ...@@ -925,12 +925,12 @@ static int hclgevf_cmd_set_promisc_mode(struct hclgevf_dev *hdev,
return status; return status;
} }
static void hclgevf_set_promisc_mode(struct hnae3_handle *handle, static int hclgevf_set_promisc_mode(struct hnae3_handle *handle,
bool en_uc_pmc, bool en_mc_pmc) bool en_uc_pmc, bool en_mc_pmc)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
hclgevf_cmd_set_promisc_mode(hdev, en_uc_pmc, en_mc_pmc); return hclgevf_cmd_set_promisc_mode(hdev, en_uc_pmc, en_mc_pmc);
} }
static int hclgevf_tqp_enable(struct hclgevf_dev *hdev, int tqp_id, static int hclgevf_tqp_enable(struct hclgevf_dev *hdev, int tqp_id,
...@@ -1080,7 +1080,7 @@ static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) ...@@ -1080,7 +1080,7 @@ static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
1, false, NULL, 0); 1, false, NULL, 0);
} }
static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id) static int hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 msg_data[2]; u8 msg_data[2];
...@@ -1091,9 +1091,9 @@ static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id) ...@@ -1091,9 +1091,9 @@ static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
/* disable vf queue before send queue reset msg to PF */ /* disable vf queue before send queue reset msg to PF */
ret = hclgevf_tqp_enable(hdev, queue_id, 0, false); ret = hclgevf_tqp_enable(hdev, queue_id, 0, false);
if (ret) if (ret)
return; return ret;
hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data, return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data,
2, true, NULL, 0); 2, true, NULL, 0);
} }
...@@ -1170,6 +1170,8 @@ static int hclgevf_reset(struct hclgevf_dev *hdev) ...@@ -1170,6 +1170,8 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
/* bring down the nic to stop any ongoing TX/RX */ /* bring down the nic to stop any ongoing TX/RX */
hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
rtnl_unlock();
/* check if VF could successfully fetch the hardware reset completion /* check if VF could successfully fetch the hardware reset completion
* status from the hardware * status from the hardware
*/ */
...@@ -1181,12 +1183,15 @@ static int hclgevf_reset(struct hclgevf_dev *hdev) ...@@ -1181,12 +1183,15 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
ret); ret);
dev_warn(&hdev->pdev->dev, "VF reset failed, disabling VF!\n"); dev_warn(&hdev->pdev->dev, "VF reset failed, disabling VF!\n");
rtnl_lock();
hclgevf_notify_client(hdev, HNAE3_UNINIT_CLIENT); hclgevf_notify_client(hdev, HNAE3_UNINIT_CLIENT);
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
} }
rtnl_lock();
/* now, re-initialize the nic client and ae device*/ /* now, re-initialize the nic client and ae device*/
ret = hclgevf_reset_stack(hdev); ret = hclgevf_reset_stack(hdev);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment