Commit 251ffc07 authored by David S. Miller's avatar David S. Miller

Merge branch 'hns3-fixes'

Guangbin Huang says:

====================
net: hns3: add some fixes for -net

This series adds some fixes for the HNS3 ethernet driver.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 513e605d 0178839c
...@@ -752,7 +752,6 @@ struct hnae3_tc_info { ...@@ -752,7 +752,6 @@ struct hnae3_tc_info {
u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */ u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */
u16 tqp_count[HNAE3_MAX_TC]; u16 tqp_count[HNAE3_MAX_TC];
u16 tqp_offset[HNAE3_MAX_TC]; u16 tqp_offset[HNAE3_MAX_TC];
unsigned long tc_en; /* bitmap of TC enabled */
u8 num_tc; /* Total number of enabled TCs */ u8 num_tc; /* Total number of enabled TCs */
bool mqprio_active; bool mqprio_active;
}; };
......
...@@ -623,13 +623,9 @@ static int hns3_nic_set_real_num_queue(struct net_device *netdev) ...@@ -623,13 +623,9 @@ static int hns3_nic_set_real_num_queue(struct net_device *netdev)
return ret; return ret;
} }
for (i = 0; i < HNAE3_MAX_TC; i++) { for (i = 0; i < tc_info->num_tc; i++)
if (!test_bit(i, &tc_info->tc_en))
continue;
netdev_set_tc_queue(netdev, i, tc_info->tqp_count[i], netdev_set_tc_queue(netdev, i, tc_info->tqp_count[i],
tc_info->tqp_offset[i]); tc_info->tqp_offset[i]);
}
} }
ret = netif_set_real_num_tx_queues(netdev, queue_size); ret = netif_set_real_num_tx_queues(netdev, queue_size);
...@@ -779,6 +775,11 @@ static int hns3_nic_net_open(struct net_device *netdev) ...@@ -779,6 +775,11 @@ static int hns3_nic_net_open(struct net_device *netdev)
if (hns3_nic_resetting(netdev)) if (hns3_nic_resetting(netdev))
return -EBUSY; return -EBUSY;
if (!test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) {
netdev_warn(netdev, "net open repeatedly!\n");
return 0;
}
netif_carrier_off(netdev); netif_carrier_off(netdev);
ret = hns3_nic_set_real_num_queue(netdev); ret = hns3_nic_set_real_num_queue(netdev);
...@@ -4865,12 +4866,9 @@ static void hns3_init_tx_ring_tc(struct hns3_nic_priv *priv) ...@@ -4865,12 +4866,9 @@ static void hns3_init_tx_ring_tc(struct hns3_nic_priv *priv)
struct hnae3_tc_info *tc_info = &kinfo->tc_info; struct hnae3_tc_info *tc_info = &kinfo->tc_info;
int i; int i;
for (i = 0; i < HNAE3_MAX_TC; i++) { for (i = 0; i < tc_info->num_tc; i++) {
int j; int j;
if (!test_bit(i, &tc_info->tc_en))
continue;
for (j = 0; j < tc_info->tqp_count[i]; j++) { for (j = 0; j < tc_info->tqp_count[i]; j++) {
struct hnae3_queue *q; struct hnae3_queue *q;
......
...@@ -334,7 +334,8 @@ static void hns3_selftest_prepare(struct net_device *ndev, ...@@ -334,7 +334,8 @@ static void hns3_selftest_prepare(struct net_device *ndev,
#if IS_ENABLED(CONFIG_VLAN_8021Q) #if IS_ENABLED(CONFIG_VLAN_8021Q)
/* Disable the vlan filter for selftest does not support it */ /* Disable the vlan filter for selftest does not support it */
if (h->ae_algo->ops->enable_vlan_filter) if (h->ae_algo->ops->enable_vlan_filter &&
ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
h->ae_algo->ops->enable_vlan_filter(h, false); h->ae_algo->ops->enable_vlan_filter(h, false);
#endif #endif
...@@ -359,7 +360,8 @@ static void hns3_selftest_restore(struct net_device *ndev, bool if_running) ...@@ -359,7 +360,8 @@ static void hns3_selftest_restore(struct net_device *ndev, bool if_running)
h->ae_algo->ops->halt_autoneg(h, false); h->ae_algo->ops->halt_autoneg(h, false);
#if IS_ENABLED(CONFIG_VLAN_8021Q) #if IS_ENABLED(CONFIG_VLAN_8021Q)
if (h->ae_algo->ops->enable_vlan_filter) if (h->ae_algo->ops->enable_vlan_filter &&
ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
h->ae_algo->ops->enable_vlan_filter(h, true); h->ae_algo->ops->enable_vlan_filter(h, true);
#endif #endif
......
...@@ -467,7 +467,7 @@ int hclge_cmd_queue_init(struct hclge_dev *hdev) ...@@ -467,7 +467,7 @@ int hclge_cmd_queue_init(struct hclge_dev *hdev)
return ret; return ret;
} }
static int hclge_firmware_compat_config(struct hclge_dev *hdev) static int hclge_firmware_compat_config(struct hclge_dev *hdev, bool en)
{ {
struct hclge_firmware_compat_cmd *req; struct hclge_firmware_compat_cmd *req;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -475,13 +475,16 @@ static int hclge_firmware_compat_config(struct hclge_dev *hdev) ...@@ -475,13 +475,16 @@ static int hclge_firmware_compat_config(struct hclge_dev *hdev)
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_IMP_COMPAT_CFG, false); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_IMP_COMPAT_CFG, false);
req = (struct hclge_firmware_compat_cmd *)desc.data; if (en) {
req = (struct hclge_firmware_compat_cmd *)desc.data;
hnae3_set_bit(compat, HCLGE_LINK_EVENT_REPORT_EN_B, 1); hnae3_set_bit(compat, HCLGE_LINK_EVENT_REPORT_EN_B, 1);
hnae3_set_bit(compat, HCLGE_NCSI_ERROR_REPORT_EN_B, 1); hnae3_set_bit(compat, HCLGE_NCSI_ERROR_REPORT_EN_B, 1);
if (hnae3_dev_phy_imp_supported(hdev)) if (hnae3_dev_phy_imp_supported(hdev))
hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1); hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1);
req->compat = cpu_to_le32(compat);
req->compat = cpu_to_le32(compat);
}
return hclge_cmd_send(&hdev->hw, &desc, 1); return hclge_cmd_send(&hdev->hw, &desc, 1);
} }
...@@ -538,7 +541,7 @@ int hclge_cmd_init(struct hclge_dev *hdev) ...@@ -538,7 +541,7 @@ int hclge_cmd_init(struct hclge_dev *hdev)
/* ask the firmware to enable some features, driver can work without /* ask the firmware to enable some features, driver can work without
* it. * it.
*/ */
ret = hclge_firmware_compat_config(hdev); ret = hclge_firmware_compat_config(hdev, true);
if (ret) if (ret)
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"Firmware compatible features not enabled(%d).\n", "Firmware compatible features not enabled(%d).\n",
...@@ -568,6 +571,8 @@ static void hclge_cmd_uninit_regs(struct hclge_hw *hw) ...@@ -568,6 +571,8 @@ static void hclge_cmd_uninit_regs(struct hclge_hw *hw)
void hclge_cmd_uninit(struct hclge_dev *hdev) void hclge_cmd_uninit(struct hclge_dev *hdev)
{ {
hclge_firmware_compat_config(hdev, false);
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
/* wait to ensure that the firmware completes the possible left /* wait to ensure that the firmware completes the possible left
* over commands. * over commands.
......
...@@ -247,6 +247,10 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) ...@@ -247,6 +247,10 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
} }
hclge_tm_schd_info_update(hdev, num_tc); hclge_tm_schd_info_update(hdev, num_tc);
if (num_tc > 1)
hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
else
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
ret = hclge_ieee_ets_to_tm_info(hdev, ets); ret = hclge_ieee_ets_to_tm_info(hdev, ets);
if (ret) if (ret)
...@@ -306,8 +310,7 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc) ...@@ -306,8 +310,7 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
u8 i, j, pfc_map, *prio_tc; u8 i, j, pfc_map, *prio_tc;
int ret; int ret;
if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
return -EINVAL; return -EINVAL;
if (pfc->pfc_en == hdev->tm_info.pfc_en) if (pfc->pfc_en == hdev->tm_info.pfc_en)
...@@ -441,8 +444,6 @@ static int hclge_mqprio_qopt_check(struct hclge_dev *hdev, ...@@ -441,8 +444,6 @@ static int hclge_mqprio_qopt_check(struct hclge_dev *hdev,
static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info, static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info,
struct tc_mqprio_qopt_offload *mqprio_qopt) struct tc_mqprio_qopt_offload *mqprio_qopt)
{ {
int i;
memset(tc_info, 0, sizeof(*tc_info)); memset(tc_info, 0, sizeof(*tc_info));
tc_info->num_tc = mqprio_qopt->qopt.num_tc; tc_info->num_tc = mqprio_qopt->qopt.num_tc;
memcpy(tc_info->prio_tc, mqprio_qopt->qopt.prio_tc_map, memcpy(tc_info->prio_tc, mqprio_qopt->qopt.prio_tc_map,
...@@ -451,9 +452,6 @@ static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info, ...@@ -451,9 +452,6 @@ static void hclge_sync_mqprio_qopt(struct hnae3_tc_info *tc_info,
sizeof_field(struct hnae3_tc_info, tqp_count)); sizeof_field(struct hnae3_tc_info, tqp_count));
memcpy(tc_info->tqp_offset, mqprio_qopt->qopt.offset, memcpy(tc_info->tqp_offset, mqprio_qopt->qopt.offset,
sizeof_field(struct hnae3_tc_info, tqp_offset)); sizeof_field(struct hnae3_tc_info, tqp_offset));
for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
set_bit(tc_info->prio_tc[i], &tc_info->tc_en);
} }
static int hclge_config_tc(struct hclge_dev *hdev, static int hclge_config_tc(struct hclge_dev *hdev,
...@@ -519,12 +517,17 @@ static int hclge_setup_tc(struct hnae3_handle *h, ...@@ -519,12 +517,17 @@ static int hclge_setup_tc(struct hnae3_handle *h,
return hclge_notify_init_up(hdev); return hclge_notify_init_up(hdev);
err_out: err_out:
/* roll-back */ if (!tc) {
memcpy(&kinfo->tc_info, &old_tc_info, sizeof(old_tc_info)); dev_warn(&hdev->pdev->dev,
if (hclge_config_tc(hdev, &kinfo->tc_info)) "failed to destroy mqprio, will active after reset, ret = %d\n",
dev_err(&hdev->pdev->dev, ret);
"failed to roll back tc configuration\n"); } else {
/* roll-back */
memcpy(&kinfo->tc_info, &old_tc_info, sizeof(old_tc_info));
if (hclge_config_tc(hdev, &kinfo->tc_info))
dev_err(&hdev->pdev->dev,
"failed to roll back tc configuration\n");
}
hclge_notify_init_up(hdev); hclge_notify_init_up(hdev);
return ret; return ret;
......
...@@ -8708,15 +8708,8 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport, ...@@ -8708,15 +8708,8 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport,
} }
/* check if we just hit the duplicate */ /* check if we just hit the duplicate */
if (!ret) { if (!ret)
dev_warn(&hdev->pdev->dev, "VF %u mac(%pM) exists\n", return -EEXIST;
vport->vport_id, addr);
return 0;
}
dev_err(&hdev->pdev->dev,
"PF failed to add unicast entry(%pM) in the MAC table\n",
addr);
return ret; return ret;
} }
...@@ -8868,7 +8861,13 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport, ...@@ -8868,7 +8861,13 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport,
} else { } else {
set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE,
&vport->state); &vport->state);
break;
/* If one unicast mac address is existing in hardware,
* we need to try whether other unicast mac addresses
* are new addresses that can be added.
*/
if (ret != -EEXIST)
break;
} }
} }
} }
...@@ -12797,8 +12796,12 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev) ...@@ -12797,8 +12796,12 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev)
continue; continue;
if (vport->vf_info.trusted) { if (vport->vf_info.trusted) {
uc_en = vport->vf_info.request_uc_en > 0; uc_en = vport->vf_info.request_uc_en > 0 ||
mc_en = vport->vf_info.request_mc_en > 0; vport->overflow_promisc_flags &
HNAE3_OVERFLOW_UPE;
mc_en = vport->vf_info.request_mc_en > 0 ||
vport->overflow_promisc_flags &
HNAE3_OVERFLOW_MPE;
} }
bc_en = vport->vf_info.request_bc_en > 0; bc_en = vport->vf_info.request_bc_en > 0;
......
...@@ -687,12 +687,10 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport) ...@@ -687,12 +687,10 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport)
for (i = 0; i < HNAE3_MAX_TC; i++) { for (i = 0; i < HNAE3_MAX_TC; i++) {
if (hdev->hw_tc_map & BIT(i) && i < kinfo->tc_info.num_tc) { if (hdev->hw_tc_map & BIT(i) && i < kinfo->tc_info.num_tc) {
set_bit(i, &kinfo->tc_info.tc_en);
kinfo->tc_info.tqp_offset[i] = i * kinfo->rss_size; kinfo->tc_info.tqp_offset[i] = i * kinfo->rss_size;
kinfo->tc_info.tqp_count[i] = kinfo->rss_size; kinfo->tc_info.tqp_count[i] = kinfo->rss_size;
} else { } else {
/* Set to default queue if TC is disable */ /* Set to default queue if TC is disable */
clear_bit(i, &kinfo->tc_info.tc_en);
kinfo->tc_info.tqp_offset[i] = 0; kinfo->tc_info.tqp_offset[i] = 0;
kinfo->tc_info.tqp_count[i] = 1; kinfo->tc_info.tqp_count[i] = 1;
} }
...@@ -729,14 +727,6 @@ static void hclge_tm_tc_info_init(struct hclge_dev *hdev) ...@@ -729,14 +727,6 @@ static void hclge_tm_tc_info_init(struct hclge_dev *hdev)
for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
hdev->tm_info.prio_tc[i] = hdev->tm_info.prio_tc[i] =
(i >= hdev->tm_info.num_tc) ? 0 : i; (i >= hdev->tm_info.num_tc) ? 0 : i;
/* DCB is enabled if we have more than 1 TC or pfc_en is
* non-zero.
*/
if (hdev->tm_info.num_tc > 1 || hdev->tm_info.pfc_en)
hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
else
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
} }
static void hclge_tm_pg_info_init(struct hclge_dev *hdev) static void hclge_tm_pg_info_init(struct hclge_dev *hdev)
...@@ -767,10 +757,10 @@ static void hclge_tm_pg_info_init(struct hclge_dev *hdev) ...@@ -767,10 +757,10 @@ static void hclge_tm_pg_info_init(struct hclge_dev *hdev)
static void hclge_update_fc_mode_by_dcb_flag(struct hclge_dev *hdev) static void hclge_update_fc_mode_by_dcb_flag(struct hclge_dev *hdev)
{ {
if (!(hdev->flag & HCLGE_FLAG_DCB_ENABLE)) { if (hdev->tm_info.num_tc == 1 && !hdev->tm_info.pfc_en) {
if (hdev->fc_mode_last_time == HCLGE_FC_PFC) if (hdev->fc_mode_last_time == HCLGE_FC_PFC)
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"DCB is disable, but last mode is FC_PFC\n"); "Only 1 tc used, but last mode is FC_PFC\n");
hdev->tm_info.fc_mode = hdev->fc_mode_last_time; hdev->tm_info.fc_mode = hdev->fc_mode_last_time;
} else if (hdev->tm_info.fc_mode != HCLGE_FC_PFC) { } else if (hdev->tm_info.fc_mode != HCLGE_FC_PFC) {
...@@ -796,7 +786,7 @@ static void hclge_update_fc_mode(struct hclge_dev *hdev) ...@@ -796,7 +786,7 @@ static void hclge_update_fc_mode(struct hclge_dev *hdev)
} }
} }
static void hclge_pfc_info_init(struct hclge_dev *hdev) void hclge_tm_pfc_info_update(struct hclge_dev *hdev)
{ {
if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
hclge_update_fc_mode(hdev); hclge_update_fc_mode(hdev);
...@@ -812,7 +802,7 @@ static void hclge_tm_schd_info_init(struct hclge_dev *hdev) ...@@ -812,7 +802,7 @@ static void hclge_tm_schd_info_init(struct hclge_dev *hdev)
hclge_tm_vport_info_update(hdev); hclge_tm_vport_info_update(hdev);
hclge_pfc_info_init(hdev); hclge_tm_pfc_info_update(hdev);
} }
static int hclge_tm_pg_to_pri_map(struct hclge_dev *hdev) static int hclge_tm_pg_to_pri_map(struct hclge_dev *hdev)
...@@ -1558,19 +1548,6 @@ void hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc) ...@@ -1558,19 +1548,6 @@ void hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc)
hclge_tm_schd_info_init(hdev); hclge_tm_schd_info_init(hdev);
} }
void hclge_tm_pfc_info_update(struct hclge_dev *hdev)
{
/* DCB is enabled if we have more than 1 TC or pfc_en is
* non-zero.
*/
if (hdev->tm_info.num_tc > 1 || hdev->tm_info.pfc_en)
hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
else
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
hclge_pfc_info_init(hdev);
}
int hclge_tm_init_hw(struct hclge_dev *hdev, bool init) int hclge_tm_init_hw(struct hclge_dev *hdev, bool init)
{ {
int ret; int ret;
...@@ -1616,7 +1593,7 @@ int hclge_tm_vport_map_update(struct hclge_dev *hdev) ...@@ -1616,7 +1593,7 @@ int hclge_tm_vport_map_update(struct hclge_dev *hdev)
if (ret) if (ret)
return ret; return ret;
if (!(hdev->flag & HCLGE_FLAG_DCB_ENABLE)) if (hdev->tm_info.num_tc == 1 && !hdev->tm_info.pfc_en)
return 0; return 0;
return hclge_tm_bp_setup(hdev); return hclge_tm_bp_setup(hdev);
......
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