Commit d8f1cb18 authored by Jiantao Xiao's avatar Jiantao Xiao
Browse files

net: hns3: support set pfc pause trans time

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6W94W


CVE: NA

----------------------------------------------------------------------

The patch provides a customized interface to modify the pause trans time
and retains the configured parameters.

Signed-off-by: default avatarshaojijie <shaojijie@huawei.com>
Signed-off-by: default avatarJiantao Xiao <xiaojiantao1@h-partners.com>
parent 67daa90c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ enum hnae3_ext_opcode {
	HNAE3_EXT_OPC_DISABLE_LANE,
	HNAE3_EXT_OPC_GET_LANE_STATUS,
	HNAE3_EXT_OPC_DISABLE_CLOCK,
	HNAE3_EXT_OPC_SET_PFC_TIME,
};

struct hnae3_pfc_storm_para {
+7 −0
Original line number Diff line number Diff line
@@ -432,3 +432,10 @@ int nic_disable_clock(struct net_device *ndev)
				  NULL, 0);
}
EXPORT_SYMBOL(nic_disable_clock);

int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time)
{
	return nic_invoke_pri_ops(ndev, HNAE3_EXT_OPC_SET_PFC_TIME,
				  &time, sizeof(time));
}
EXPORT_SYMBOL(nic_set_pfc_time_cfg);
+1 −0
Original line number Diff line number Diff line
@@ -41,4 +41,5 @@ int nic_set_sfp_state(struct net_device *ndev, bool en);
int nic_disable_net_lane(struct net_device *ndev);
int nic_get_net_lane_status(struct net_device *ndev, u32 *status);
int nic_disable_clock(struct net_device *ndev);
int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time);
#endif
+36 −0
Original line number Diff line number Diff line
@@ -545,6 +545,42 @@ static int hclge_disable_nic_clock(struct hclge_dev *hdev, void *data,
	return ret;
}

static int hclge_set_pause_trans_time(struct hclge_dev *hdev, void *data,
				      size_t length)
{
	struct hclge_cfg_pause_param_cmd *pause_param;
	struct hclge_desc desc;
	u16 pause_trans_time;
	int ret;

	if (length != sizeof(u16))
		return -EINVAL;

	pause_param = (struct hclge_cfg_pause_param_cmd *)desc.data;
	ret = hclge_get_info_from_cmd(hdev, &desc, 1, HCLGE_OPC_CFG_MAC_PARA);
	if (ret) {
		dev_err(&hdev->pdev->dev,
			"failed to get pause cfg info, ret = %d\n", ret);
		return ret;
	}

	pause_trans_time = *(u16 *)data;
	if (pause_trans_time == le16_to_cpu(pause_param->pause_trans_time))
		return 0;

	ret = hclge_pause_param_cfg(hdev, pause_param->mac_addr,
				    pause_param->pause_trans_gap,
				    pause_trans_time);
	if (ret) {
		dev_err(&hdev->pdev->dev,
			"failed to set pause trans time, ret = %d\n", ret);
		return ret;
	}

	hdev->tm_info.pause_time = pause_trans_time;
	return 0;
}

static void hclge_ext_resotre_config(struct hclge_dev *hdev)
{
	if (hdev->reset_type != HNAE3_IMP_RESET &&
+1 −0
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ struct hclge_tm_info {
	enum hclge_fc_mode fc_mode;
	u8 hw_pfc_map; /* Allow for packet drop or not on this TC */
	u8 pfc_en;	/* PFC enabled or not for user priority */
	u16 pause_time;
};

/* max number of mac statistics on each version */
Loading