Commit b4e04c2d authored by Jian Shen's avatar Jian Shen Committed by Hao Chen
Browse files

net: hns3: add support for vf get dscp configuration from pf

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


CVE: NA

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

The vf supports two modes DSCP and priority. After configures DSCP
parameters in the pf, the pf synchronizes the DSCP parameters to the vf.
When multiple TCs are configured for a vf, vf can use the dscp parameter
of the pf to select a queue for data flows. The query and configuration
interfaces on the vf side are not provided. The vf supports dscp only
when the vf supports multi-TCs.

Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
parent 518ea89e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ enum HCLGE_MBX_OPCODE {
	HCLGE_MBX_SET_QB = 0x28,        /* (VF -> PF) set queue bonding */
	HCLGE_MBX_PUSH_QB_STATE,        /* (PF -> VF) push qb state */
	HCLGE_MBX_SET_TC = 0x30,        /* (VF -> PF) set tc */
	HCLGE_MBX_EVENT_NOTIFY,  /* (PF -> VF) event notify */

	HCLGE_MBX_SET_MGUID = 0x50,	/* (VF -> PF) set mc guid */
	HCLGE_UNIC_MBX_SET_IP,		/* (VF -> PF) set ip addr */
@@ -103,6 +104,10 @@ enum hclge_mbx_qb_cfg_subcode {
	HCLGE_MBX_QB_GET_STATE		/* query whether qb enabled */
};

enum hclge_mbx_event_notify_type {
	HCLGE_MBX_DSCP_CHANGE = 0,
};

#define HCLGE_MBX_MAX_MSG_SIZE	14
#define HCLGE_MBX_MAX_RESP_DATA_SIZE	8U
#define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM	4
+1 −0
Original line number Diff line number Diff line
@@ -921,6 +921,7 @@ struct hnae3_tc_info {

#define HNAE3_MAX_DSCP			64
#define HNAE3_PRIO_ID_INVALID		0xff
#define HNAE3_PRIO_ID_MAP_INVALID	0xf
struct hnae3_knic_private_info {
	struct net_device *netdev; /* Set by KNIC client when init instance */
	u16 rss_size;		   /* Allocated RSS queues */
+3 −0
Original line number Diff line number Diff line
@@ -268,6 +268,9 @@ enum hclge_opcode_type {
	HCLGE_OPC_IMP_STATS_INFO		= 0x7013,
	HCLGE_OPC_IMP_COMPAT_CFG		= 0x701A,

	/* dscp pri map command */
	HCLGE_OPC_DSCP_PRI_MAP		= 0x7039,

	/* SFP command */
	HCLGE_OPC_GET_SFP_EEPROM	= 0x7100,
	HCLGE_OPC_GET_SFP_EXIST		= 0x7101,
+33 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include "hclge_main.h"
#include "hclge_dcb.h"
#include "hclge_tm.h"
#include "hclge_mbx.h"
#include "hnae3.h"

#define BW_PERCENT	100
@@ -441,12 +442,34 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
	return last_bad_ret;
}

static void hclge_notify_dscp_change(struct hclge_dev *hdev)
{
	struct hclge_vport *vport;
	int ret;
	int i;

	if (!hnae3_ae_dev_vf_multi_tcs_supported(hdev))
		return;

	for (i = 0; i < pci_num_vf(hdev->pdev); i++) {
		vport = &hdev->vport[i + HCLGE_VF_VPORT_START_NUM];

		if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state))
			continue;

		ret = hclge_mbx_event_notify(vport, BIT(HCLGE_MBX_DSCP_CHANGE));
		if (ret)
			break;
	}
}

static int hclge_ieee_setapp(struct hnae3_handle *h, struct dcb_app *app)
{
	struct hclge_vport *vport = hclge_get_vport(h);
	struct net_device *netdev = h->kinfo.netdev;
	struct hclge_dev *hdev = vport->back;
	struct dcb_app old_app;
	int ret1;
	int ret;

	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
@@ -484,6 +507,11 @@ static int hclge_ieee_setapp(struct hnae3_handle *h, struct dcb_app *app)
	else
		ret = dcb_ieee_delapp(netdev, &old_app);

	ret1 = hclge_dscp_to_pri_map(hdev);
	if (ret1)
		return ret1;
	hclge_notify_dscp_change(hdev);

	return ret;
}

@@ -525,6 +553,11 @@ static int hclge_ieee_delapp(struct hnae3_handle *h, struct dcb_app *app)
		ret = hclge_up_to_tc_map(hdev);
	}

	ret = hclge_dscp_to_pri_map(hdev);
	if (ret)
		return ret;
	hclge_notify_dscp_change(hdev);

	return ret;
}

+1 −0
Original line number Diff line number Diff line
@@ -1230,4 +1230,5 @@ void hclge_get_media_type(struct hnae3_handle *handle, u8 *media_type,
			  u8 *module_type);
int hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable);
int hclge_query_scc_version(struct hclge_dev *hdev, u32 *scc_version);
int hclge_mbx_event_notify(struct hclge_vport *vport, u64 event_bits);
#endif
Loading