Commit 35494b0d authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'there-are-some-bugfix-for-the-hns3-ethernet-driver'

Jijie Shao says:

====================
There are some bugfix for the HNS3 ethernet driver
====================

Link: https://lore.kernel.org/r/20230906072018.3020671-1-shaojijie@huawei.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 08c6d8ba 60326634
...@@ -814,6 +814,7 @@ struct hnae3_tc_info { ...@@ -814,6 +814,7 @@ struct hnae3_tc_info {
u8 max_tc; /* Total number of TCs */ u8 max_tc; /* Total number of TCs */
u8 num_tc; /* Total number of enabled TCs */ u8 num_tc; /* Total number of enabled TCs */
bool mqprio_active; bool mqprio_active;
bool dcb_ets_active;
}; };
#define HNAE3_MAX_DSCP 64 #define HNAE3_MAX_DSCP 64
......
...@@ -1045,6 +1045,7 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos) ...@@ -1045,6 +1045,7 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
struct hnae3_dev_specs *dev_specs = &ae_dev->dev_specs; struct hnae3_dev_specs *dev_specs = &ae_dev->dev_specs;
struct hnae3_knic_private_info *kinfo = &h->kinfo; struct hnae3_knic_private_info *kinfo = &h->kinfo;
struct net_device *dev = kinfo->netdev;
*pos += scnprintf(buf + *pos, len - *pos, "dev_spec:\n"); *pos += scnprintf(buf + *pos, len - *pos, "dev_spec:\n");
*pos += scnprintf(buf + *pos, len - *pos, "MAC entry num: %u\n", *pos += scnprintf(buf + *pos, len - *pos, "MAC entry num: %u\n",
...@@ -1087,6 +1088,9 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos) ...@@ -1087,6 +1088,9 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
dev_specs->mc_mac_size); dev_specs->mc_mac_size);
*pos += scnprintf(buf + *pos, len - *pos, "MAC statistics number: %u\n", *pos += scnprintf(buf + *pos, len - *pos, "MAC statistics number: %u\n",
dev_specs->mac_stats_num); dev_specs->mac_stats_num);
*pos += scnprintf(buf + *pos, len - *pos,
"TX timeout threshold: %d seconds\n",
dev->watchdog_timeo / HZ);
} }
static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len) static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
...@@ -1411,9 +1415,9 @@ int hns3_dbg_init(struct hnae3_handle *handle) ...@@ -1411,9 +1415,9 @@ int hns3_dbg_init(struct hnae3_handle *handle)
return 0; return 0;
out: out:
mutex_destroy(&handle->dbgfs_lock);
debugfs_remove_recursive(handle->hnae3_dbgfs); debugfs_remove_recursive(handle->hnae3_dbgfs);
handle->hnae3_dbgfs = NULL; handle->hnae3_dbgfs = NULL;
mutex_destroy(&handle->dbgfs_lock);
return ret; return ret;
} }
...@@ -1421,6 +1425,9 @@ void hns3_dbg_uninit(struct hnae3_handle *handle) ...@@ -1421,6 +1425,9 @@ void hns3_dbg_uninit(struct hnae3_handle *handle)
{ {
u32 i; u32 i;
debugfs_remove_recursive(handle->hnae3_dbgfs);
handle->hnae3_dbgfs = NULL;
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++)
if (handle->dbgfs_buf[i]) { if (handle->dbgfs_buf[i]) {
kvfree(handle->dbgfs_buf[i]); kvfree(handle->dbgfs_buf[i]);
...@@ -1428,8 +1435,6 @@ void hns3_dbg_uninit(struct hnae3_handle *handle) ...@@ -1428,8 +1435,6 @@ void hns3_dbg_uninit(struct hnae3_handle *handle)
} }
mutex_destroy(&handle->dbgfs_lock); mutex_destroy(&handle->dbgfs_lock);
debugfs_remove_recursive(handle->hnae3_dbgfs);
handle->hnae3_dbgfs = NULL;
} }
void hns3_dbg_register_debugfs(const char *debugfs_dir_name) void hns3_dbg_register_debugfs(const char *debugfs_dir_name)
......
...@@ -2103,8 +2103,12 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num, ...@@ -2103,8 +2103,12 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
*/ */
if (test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state) && num && if (test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state) && num &&
!ring->pending_buf && num <= HNS3_MAX_PUSH_BD_NUM && doorbell) { !ring->pending_buf && num <= HNS3_MAX_PUSH_BD_NUM && doorbell) {
/* This smp_store_release() pairs with smp_load_aquire() in
* hns3_nic_reclaim_desc(). Ensure that the BD valid bit
* is updated.
*/
smp_store_release(&ring->last_to_use, ring->next_to_use);
hns3_tx_push_bd(ring, num); hns3_tx_push_bd(ring, num);
WRITE_ONCE(ring->last_to_use, ring->next_to_use);
return; return;
} }
...@@ -2115,6 +2119,11 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num, ...@@ -2115,6 +2119,11 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
return; return;
} }
/* This smp_store_release() pairs with smp_load_aquire() in
* hns3_nic_reclaim_desc(). Ensure that the BD valid bit is updated.
*/
smp_store_release(&ring->last_to_use, ring->next_to_use);
if (ring->tqp->mem_base) if (ring->tqp->mem_base)
hns3_tx_mem_doorbell(ring); hns3_tx_mem_doorbell(ring);
else else
...@@ -2122,7 +2131,6 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num, ...@@ -2122,7 +2131,6 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG); ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG);
ring->pending_buf = 0; ring->pending_buf = 0;
WRITE_ONCE(ring->last_to_use, ring->next_to_use);
} }
static void hns3_tsyn(struct net_device *netdev, struct sk_buff *skb, static void hns3_tsyn(struct net_device *netdev, struct sk_buff *skb,
...@@ -3308,8 +3316,6 @@ static void hns3_set_default_feature(struct net_device *netdev) ...@@ -3308,8 +3316,6 @@ static void hns3_set_default_feature(struct net_device *netdev)
netdev->priv_flags |= IFF_UNICAST_FLT; netdev->priv_flags |= IFF_UNICAST_FLT;
netdev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
...@@ -3563,9 +3569,8 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i) ...@@ -3563,9 +3569,8 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring, static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
int *bytes, int *pkts, int budget) int *bytes, int *pkts, int budget)
{ {
/* pair with ring->last_to_use update in hns3_tx_doorbell(), /* This smp_load_acquire() pairs with smp_store_release() in
* smp_store_release() is not used in hns3_tx_doorbell() because * hns3_tx_doorbell().
* the doorbell operation already have the needed barrier operation.
*/ */
int ltu = smp_load_acquire(&ring->last_to_use); int ltu = smp_load_acquire(&ring->last_to_use);
int ntc = ring->next_to_clean; int ntc = ring->next_to_clean;
......
...@@ -773,7 +773,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -773,7 +773,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
hns3_get_ksettings(h, cmd); hns3_get_ksettings(h, cmd);
break; break;
case HNAE3_MEDIA_TYPE_FIBER: case HNAE3_MEDIA_TYPE_FIBER:
if (module_type == HNAE3_MODULE_TYPE_CR) if (module_type == HNAE3_MODULE_TYPE_UNKNOWN)
cmd->base.port = PORT_OTHER;
else if (module_type == HNAE3_MODULE_TYPE_CR)
cmd->base.port = PORT_DA; cmd->base.port = PORT_DA;
else else
cmd->base.port = PORT_FIBRE; cmd->base.port = PORT_FIBRE;
......
...@@ -259,7 +259,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) ...@@ -259,7 +259,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
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) h->kinfo.tc_info.mqprio_active)
return -EINVAL; return -EINVAL;
ret = hclge_ets_validate(hdev, ets, &num_tc, &map_changed); ret = hclge_ets_validate(hdev, ets, &num_tc, &map_changed);
...@@ -275,10 +275,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) ...@@ -275,10 +275,7 @@ 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) h->kinfo.tc_info.dcb_ets_active = 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)
...@@ -487,7 +484,7 @@ static u8 hclge_getdcbx(struct hnae3_handle *h) ...@@ -487,7 +484,7 @@ static u8 hclge_getdcbx(struct hnae3_handle *h)
struct hclge_vport *vport = hclge_get_vport(h); struct hclge_vport *vport = hclge_get_vport(h);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
if (hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE) if (h->kinfo.tc_info.mqprio_active)
return 0; return 0;
return hdev->dcbx_cap; return hdev->dcbx_cap;
...@@ -611,7 +608,8 @@ static int hclge_setup_tc(struct hnae3_handle *h, ...@@ -611,7 +608,8 @@ static int hclge_setup_tc(struct hnae3_handle *h,
if (!test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state)) if (!test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state))
return -EBUSY; return -EBUSY;
if (hdev->flag & HCLGE_FLAG_DCB_ENABLE) kinfo = &vport->nic.kinfo;
if (kinfo->tc_info.dcb_ets_active)
return -EINVAL; return -EINVAL;
ret = hclge_mqprio_qopt_check(hdev, mqprio_qopt); ret = hclge_mqprio_qopt_check(hdev, mqprio_qopt);
...@@ -625,7 +623,6 @@ static int hclge_setup_tc(struct hnae3_handle *h, ...@@ -625,7 +623,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
if (ret) if (ret)
return ret; return ret;
kinfo = &vport->nic.kinfo;
memcpy(&old_tc_info, &kinfo->tc_info, sizeof(old_tc_info)); memcpy(&old_tc_info, &kinfo->tc_info, sizeof(old_tc_info));
hclge_sync_mqprio_qopt(&kinfo->tc_info, mqprio_qopt); hclge_sync_mqprio_qopt(&kinfo->tc_info, mqprio_qopt);
kinfo->tc_info.mqprio_active = tc > 0; kinfo->tc_info.mqprio_active = tc > 0;
...@@ -634,13 +631,6 @@ static int hclge_setup_tc(struct hnae3_handle *h, ...@@ -634,13 +631,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
if (ret) if (ret)
goto err_out; goto err_out;
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
if (tc > 1)
hdev->flag |= HCLGE_FLAG_MQPRIO_ENABLE;
else
hdev->flag &= ~HCLGE_FLAG_MQPRIO_ENABLE;
return hclge_notify_init_up(hdev); return hclge_notify_init_up(hdev);
err_out: err_out:
......
...@@ -1519,7 +1519,7 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x, ...@@ -1519,7 +1519,7 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
struct hclge_desc desc[3]; struct hclge_desc desc[3];
int pos = 0; int pos = 0;
int ret, i; int ret, i;
u32 *req; __le32 *req;
hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_FD_TCAM_OP, true); hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_FD_TCAM_OP, true);
desc[0].flag |= cpu_to_le16(HCLGE_COMM_CMD_FLAG_NEXT); desc[0].flag |= cpu_to_le16(HCLGE_COMM_CMD_FLAG_NEXT);
...@@ -1544,22 +1544,22 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x, ...@@ -1544,22 +1544,22 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
tcam_msg.loc); tcam_msg.loc);
/* tcam_data0 ~ tcam_data1 */ /* tcam_data0 ~ tcam_data1 */
req = (u32 *)req1->tcam_data; req = (__le32 *)req1->tcam_data;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos, pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
"%08x\n", *req++); "%08x\n", le32_to_cpu(*req++));
/* tcam_data2 ~ tcam_data7 */ /* tcam_data2 ~ tcam_data7 */
req = (u32 *)req2->tcam_data; req = (__le32 *)req2->tcam_data;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos, pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
"%08x\n", *req++); "%08x\n", le32_to_cpu(*req++));
/* tcam_data8 ~ tcam_data12 */ /* tcam_data8 ~ tcam_data12 */
req = (u32 *)req3->tcam_data; req = (__le32 *)req3->tcam_data;
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos, pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
"%08x\n", *req++); "%08x\n", le32_to_cpu(*req++));
return ret; return ret;
} }
......
...@@ -11026,6 +11026,7 @@ static void hclge_get_mdix_mode(struct hnae3_handle *handle, ...@@ -11026,6 +11026,7 @@ static void hclge_get_mdix_mode(struct hnae3_handle *handle,
static void hclge_info_show(struct hclge_dev *hdev) static void hclge_info_show(struct hclge_dev *hdev)
{ {
struct hnae3_handle *handle = &hdev->vport->nic;
struct device *dev = &hdev->pdev->dev; struct device *dev = &hdev->pdev->dev;
dev_info(dev, "PF info begin:\n"); dev_info(dev, "PF info begin:\n");
...@@ -11042,9 +11043,9 @@ static void hclge_info_show(struct hclge_dev *hdev) ...@@ -11042,9 +11043,9 @@ static void hclge_info_show(struct hclge_dev *hdev)
dev_info(dev, "This is %s PF\n", dev_info(dev, "This is %s PF\n",
hdev->flag & HCLGE_FLAG_MAIN ? "main" : "not main"); hdev->flag & HCLGE_FLAG_MAIN ? "main" : "not main");
dev_info(dev, "DCB %s\n", dev_info(dev, "DCB %s\n",
hdev->flag & HCLGE_FLAG_DCB_ENABLE ? "enable" : "disable"); handle->kinfo.tc_info.dcb_ets_active ? "enable" : "disable");
dev_info(dev, "MQPRIO %s\n", dev_info(dev, "MQPRIO %s\n",
hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE ? "enable" : "disable"); handle->kinfo.tc_info.mqprio_active ? "enable" : "disable");
dev_info(dev, "Default tx spare buffer size: %u\n", dev_info(dev, "Default tx spare buffer size: %u\n",
hdev->tx_spare_buf_size); hdev->tx_spare_buf_size);
......
...@@ -919,8 +919,6 @@ struct hclge_dev { ...@@ -919,8 +919,6 @@ struct hclge_dev {
#define HCLGE_FLAG_MAIN BIT(0) #define HCLGE_FLAG_MAIN BIT(0)
#define HCLGE_FLAG_DCB_CAPABLE BIT(1) #define HCLGE_FLAG_DCB_CAPABLE BIT(1)
#define HCLGE_FLAG_DCB_ENABLE BIT(2)
#define HCLGE_FLAG_MQPRIO_ENABLE BIT(3)
u32 flag; u32 flag;
u32 pkt_buf_size; /* Total pf buf size for tx/rx */ u32 pkt_buf_size; /* Total pf buf size for tx/rx */
......
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