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

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.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 08c6d8ba 60326634
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -814,6 +814,7 @@ struct hnae3_tc_info {
	u8 max_tc; /* Total number of TCs */
	u8 num_tc; /* Total number of enabled TCs */
	bool mqprio_active;
	bool dcb_ets_active;
};

#define HNAE3_MAX_DSCP			64
+8 −3
Original line number Diff line number Diff line
@@ -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_dev_specs *dev_specs = &ae_dev->dev_specs;
	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, "MAC entry num: %u\n",
@@ -1087,6 +1088,9 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
			  dev_specs->mc_mac_size);
	*pos += scnprintf(buf + *pos, len - *pos, "MAC statistics number: %u\n",
			  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)
@@ -1411,9 +1415,9 @@ int hns3_dbg_init(struct hnae3_handle *handle)
	return 0;

out:
	mutex_destroy(&handle->dbgfs_lock);
	debugfs_remove_recursive(handle->hnae3_dbgfs);
	handle->hnae3_dbgfs = NULL;
	mutex_destroy(&handle->dbgfs_lock);
	return ret;
}

@@ -1421,6 +1425,9 @@ void hns3_dbg_uninit(struct hnae3_handle *handle)
{
	u32 i;

	debugfs_remove_recursive(handle->hnae3_dbgfs);
	handle->hnae3_dbgfs = NULL;

	for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++)
		if (handle->dbgfs_buf[i]) {
			kvfree(handle->dbgfs_buf[i]);
@@ -1428,8 +1435,6 @@ void hns3_dbg_uninit(struct hnae3_handle *handle)
		}

	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)
+12 −7
Original line number Diff line number Diff line
@@ -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 &&
	    !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);
		WRITE_ONCE(ring->last_to_use, ring->next_to_use);
		return;
	}

@@ -2115,6 +2119,11 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
		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)
		hns3_tx_mem_doorbell(ring);
	else
@@ -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->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,
@@ -3308,8 +3316,6 @@ static void hns3_set_default_feature(struct net_device *netdev)

	netdev->priv_flags |= IFF_UNICAST_FLT;

	netdev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;

	netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
		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)
static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
				  int *bytes, int *pkts, int budget)
{
	/* pair with ring->last_to_use update in hns3_tx_doorbell(),
	 * smp_store_release() is not used in hns3_tx_doorbell() because
	 * the doorbell operation already have the needed barrier operation.
	/* This smp_load_acquire() pairs with smp_store_release() in
	 * hns3_tx_doorbell().
	 */
	int ltu = smp_load_acquire(&ring->last_to_use);
	int ntc = ring->next_to_clean;
+3 −1
Original line number Diff line number Diff line
@@ -773,7 +773,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
		hns3_get_ksettings(h, cmd);
		break;
	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;
		else
			cmd->base.port = PORT_FIBRE;
+5 −15
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
	int ret;

	if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) ||
	    hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
	    h->kinfo.tc_info.mqprio_active)
		return -EINVAL;

	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)
	}

	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;
	h->kinfo.tc_info.dcb_ets_active = num_tc > 1;

	ret = hclge_ieee_ets_to_tm_info(hdev, ets);
	if (ret)
@@ -487,7 +484,7 @@ static u8 hclge_getdcbx(struct hnae3_handle *h)
	struct hclge_vport *vport = hclge_get_vport(h);
	struct hclge_dev *hdev = vport->back;

	if (hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
	if (h->kinfo.tc_info.mqprio_active)
		return 0;

	return hdev->dcbx_cap;
@@ -611,7 +608,8 @@ static int hclge_setup_tc(struct hnae3_handle *h,
	if (!test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state))
		return -EBUSY;

	if (hdev->flag & HCLGE_FLAG_DCB_ENABLE)
	kinfo = &vport->nic.kinfo;
	if (kinfo->tc_info.dcb_ets_active)
		return -EINVAL;

	ret = hclge_mqprio_qopt_check(hdev, mqprio_qopt);
@@ -625,7 +623,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
	if (ret)
		return ret;

	kinfo = &vport->nic.kinfo;
	memcpy(&old_tc_info, &kinfo->tc_info, sizeof(old_tc_info));
	hclge_sync_mqprio_qopt(&kinfo->tc_info, mqprio_qopt);
	kinfo->tc_info.mqprio_active = tc > 0;
@@ -634,13 +631,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
	if (ret)
		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);

err_out:
Loading