diff mbox series

[net-next,1/5] net: hns3: add support config dscp map to tc

Message ID 20220905081539.62131-2-huangguangbin2@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: hns3: updates for -next | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Guangbin Huang Sept. 5, 2022, 8:15 a.m. UTC
This patch add support config dscp map to tc by implementing ieee_setapp
and ieee_delapp of struct dcbnl_rtnl_ops. Driver will convert mapping
relationship from dscp-prio to dscp-tc.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  10 ++
 .../net/ethernet/hisilicon/hns3/hns3_dcbnl.c  |  28 +++++
 .../hisilicon/hns3/hns3pf/hclge_dcb.c         | 107 ++++++++++++++++++
 .../hisilicon/hns3/hns3pf/hclge_dcb.h         |   3 +
 .../hisilicon/hns3/hns3pf/hclge_main.c        |   1 +
 .../hisilicon/hns3/hns3pf/hclge_main.h        |   4 +
 .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.c |  50 +++++++-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.h |   5 +
 8 files changed, 207 insertions(+), 1 deletion(-)

Comments

kernel test robot Sept. 6, 2022, 1:35 a.m. UTC | #1
Hi Guangbin,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Guangbin-Huang/net-hns3-updates-for-next/20220905-162120
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 9837ec955b46b62d1dd2d00311461a950c50a791
config: arm64-defconfig
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/85cb1339e830bfa3a749b6ffdbdfbf40aa5b3077
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Guangbin-Huang/net-hns3-updates-for-next/20220905-162120
        git checkout 85cb1339e830bfa3a749b6ffdbdfbf40aa5b3077
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> aarch64-linux-ld: drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.o:(.rodata+0x860): undefined reference to `hclge_get_dscp_prio'
Paolo Abeni Sept. 6, 2022, 1:12 p.m. UTC | #2
On Mon, 2022-09-05 at 16:15 +0800, Guangbin Huang wrote:
> This patch add support config dscp map to tc by implementing ieee_setapp
> and ieee_delapp of struct dcbnl_rtnl_ops. Driver will convert mapping
> relationship from dscp-prio to dscp-tc.
> 
> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  10 ++
>  .../net/ethernet/hisilicon/hns3/hns3_dcbnl.c  |  28 +++++
>  .../hisilicon/hns3/hns3pf/hclge_dcb.c         | 107 ++++++++++++++++++
>  .../hisilicon/hns3/hns3pf/hclge_dcb.h         |   3 +
>  .../hisilicon/hns3/hns3pf/hclge_main.c        |   1 +
>  .../hisilicon/hns3/hns3pf/hclge_main.h        |   4 +
>  .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.c |  50 +++++++-
>  .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.h |   5 +
>  8 files changed, 207 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> index 795df7111119..33b5ac47f342 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> @@ -310,6 +310,11 @@ enum hnae3_dbg_cmd {
>  	HNAE3_DBG_CMD_UNKNOWN,
>  };
>  
> +enum hnae3_tc_map_mode {
> +	HNAE3_TC_MAP_MODE_PRIO,
> +	HNAE3_TC_MAP_MODE_DSCP,
> +};
> +
>  struct hnae3_vector_info {
>  	u8 __iomem *io_addr;
>  	int vector;
> @@ -739,6 +744,8 @@ struct hnae3_ae_ops {
>  	int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
>  				       u32 *status_code);
>  	void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
> +	int (*get_dscp_prio)(struct hnae3_handle *handle, u8 dscp,
> +			     u8 *tc_map_mode, u8 *priority);
>  };
>  
>  struct hnae3_dcb_ops {
> @@ -747,6 +754,8 @@ struct hnae3_dcb_ops {
>  	int (*ieee_setets)(struct hnae3_handle *, struct ieee_ets *);
>  	int (*ieee_getpfc)(struct hnae3_handle *, struct ieee_pfc *);
>  	int (*ieee_setpfc)(struct hnae3_handle *, struct ieee_pfc *);
> +	int (*ieee_setapp)(struct hnae3_handle *h, struct dcb_app *app);
> +	int (*ieee_delapp)(struct hnae3_handle *h, struct dcb_app *app);
>  
>  	/* DCBX configuration */
>  	u8   (*getdcbx)(struct hnae3_handle *);
> @@ -786,6 +795,7 @@ struct hnae3_knic_private_info {
>  	u32 tx_spare_buf_size;
>  
>  	struct hnae3_tc_info tc_info;
> +	u8 tc_map_mode;
>  
>  	u16 num_tqps;		  /* total number of TQPs in this handle */
>  	struct hnae3_queue **tqp;  /* array base of all TQPs in this instance */
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
> index d2ec4c573bf8..3b6dbf158b98 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
> @@ -56,6 +56,32 @@ static int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
>  	return -EOPNOTSUPP;
>  }
>  
> +static int hns3_dcbnl_ieee_setapp(struct net_device *ndev, struct dcb_app *app)
> +{
> +	struct hnae3_handle *h = hns3_get_handle(ndev);
> +
> +	if (hns3_nic_resetting(ndev))
> +		return -EBUSY;
> +
> +	if (h->kinfo.dcb_ops->ieee_setapp)
> +		return h->kinfo.dcb_ops->ieee_setapp(h, app);
> +
> +	return -EOPNOTSUPP;
> +}
> +
> +static int hns3_dcbnl_ieee_delapp(struct net_device *ndev, struct dcb_app *app)
> +{
> +	struct hnae3_handle *h = hns3_get_handle(ndev);
> +
> +	if (hns3_nic_resetting(ndev))
> +		return -EBUSY;
> +
> +	if (h->kinfo.dcb_ops->ieee_setapp)
> +		return h->kinfo.dcb_ops->ieee_delapp(h, app);
> +
> +	return -EOPNOTSUPP;
> +}
> +
>  /* DCBX configuration */
>  static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
>  {
> @@ -83,6 +109,8 @@ static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
>  	.ieee_setets	= hns3_dcbnl_ieee_setets,
>  	.ieee_getpfc	= hns3_dcbnl_ieee_getpfc,
>  	.ieee_setpfc	= hns3_dcbnl_ieee_setpfc,
> +	.ieee_setapp    = hns3_dcbnl_ieee_setapp,
> +	.ieee_delapp    = hns3_dcbnl_ieee_delapp,
>  	.getdcbx	= hns3_dcbnl_getdcbx,
>  	.setdcbx	= hns3_dcbnl_setdcbx,
>  };
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
> index 69b8673436ca..7fcacc76e749 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
> @@ -359,6 +359,111 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
>  	return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
>  }
>  
> +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 ret;
> +
> +	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
> +	    app->protocol >= HCLGE_MAX_DSCP ||
> +	    app->priority >= HNAE3_MAX_USER_PRIO)
> +		return -EINVAL;
> +
> +	dev_info(&hdev->pdev->dev, "setapp dscp=%u priority=%u\n",
> +		 app->protocol, app->priority);
> +
> +	if (app->priority == hdev->tm_info.dscp_prio[app->protocol])
> +		return 0;
> +
> +	ret = dcb_ieee_setapp(netdev, app);
> +	if (ret)
> +		return ret;
> +
> +	old_app.selector = IEEE_8021QAZ_APP_SEL_DSCP;
> +	old_app.protocol = app->protocol;
> +	old_app.priority = hdev->tm_info.dscp_prio[app->protocol];
> +
> +	hdev->tm_info.dscp_prio[app->protocol] = app->priority;
> +	ret = hclge_dscp_to_tc_map(hdev);
> +	if (ret) {
> +		dev_err(&hdev->pdev->dev,
> +			"failed to set dscp to tc map, ret = %d\n", ret);
> +		hdev->tm_info.dscp_prio[app->protocol] = old_app.priority;
> +		(void)dcb_ieee_delapp(netdev, app);
> +		return ret;
> +	}
> +
> +	vport->nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_DSCP;
> +	if (old_app.priority == HCLGE_PRIO_ID_INVALID)
> +		hdev->tm_info.dscp_app_cnt++;
> +	else
> +		ret = dcb_ieee_delapp(netdev, &old_app);
> +
> +	return ret;
> +}
> +
> +static int hclge_ieee_delapp(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;
> +	int ret;
> +
> +	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
> +	    app->protocol >= HCLGE_MAX_DSCP ||
> +	    app->priority >= HNAE3_MAX_USER_PRIO ||
> +	    app->priority != hdev->tm_info.dscp_prio[app->protocol])
> +		return -EINVAL;
> +
> +	dev_info(&hdev->pdev->dev, "delapp dscp=%u priority=%u\n",
> +		 app->protocol, app->priority);
> +
> +	ret = dcb_ieee_delapp(netdev, app);
> +	if (ret)
> +		return ret;
> +
> +	hdev->tm_info.dscp_prio[app->protocol] = HCLGE_PRIO_ID_INVALID;
> +	ret = hclge_dscp_to_tc_map(hdev);
> +	if (ret) {
> +		dev_err(&hdev->pdev->dev,
> +			"failed to del dscp to tc map, ret = %d\n", ret);
> +		hdev->tm_info.dscp_prio[app->protocol] = app->priority;
> +		(void)dcb_ieee_setapp(netdev, app);
> +		return ret;
> +	}
> +
> +	if (hdev->tm_info.dscp_app_cnt)
> +		hdev->tm_info.dscp_app_cnt--;
> +
> +	if (!hdev->tm_info.dscp_app_cnt) {
> +		vport->nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_PRIO;
> +		ret = hclge_up_to_tc_map(hdev);
> +	}
> +
> +	return ret;
> +}
> +
> +int hclge_get_dscp_prio(struct hnae3_handle *h, u8 dscp, u8 *tc_mode,
> +			u8 *priority)
> +{
> +	struct hclge_vport *vport = hclge_get_vport(h);
> +	struct hclge_dev *hdev = vport->back;
> +
> +	if (dscp >= HCLGE_MAX_DSCP)
> +		return -EINVAL;
> +
> +	if (tc_mode)
> +		*tc_mode = vport->nic.kinfo.tc_map_mode;
> +	if (priority)
> +		*priority = hdev->tm_info.dscp_prio[dscp] == HCLGE_PRIO_ID_INVALID ? 0 :
> +			    hdev->tm_info.dscp_prio[dscp];
> +
> +	return 0;
> +}
> +
>  /* DCBX configuration */
>  static u8 hclge_getdcbx(struct hnae3_handle *h)
>  {
> @@ -543,6 +648,8 @@ static const struct hnae3_dcb_ops hns3_dcb_ops = {
>  	.ieee_setets	= hclge_ieee_setets,
>  	.ieee_getpfc	= hclge_ieee_getpfc,
>  	.ieee_setpfc	= hclge_ieee_setpfc,
> +	.ieee_setapp    = hclge_ieee_setapp,
> +	.ieee_delapp    = hclge_ieee_delapp,
>  	.getdcbx	= hclge_getdcbx,
>  	.setdcbx	= hclge_setdcbx,
>  	.setup_tc	= hclge_setup_tc,
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
> index b04702e65689..17a5460e7ea9 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
> @@ -12,4 +12,7 @@ void hclge_dcb_ops_set(struct hclge_dev *hdev);
>  static inline void hclge_dcb_ops_set(struct hclge_dev *hdev) {}
>  #endif
>  
> +int hclge_get_dscp_prio(struct hnae3_handle *h, u8 dscp, u8 *tc_mode,
> +			u8 *priority);
> +
>  #endif /* __HCLGE_DCB_H__ */
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index fcdc978379ff..f43c7d392d1a 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -12907,6 +12907,7 @@ static const struct hnae3_ae_ops hclge_ops = {
>  	.get_ts_info = hclge_ptp_get_ts_info,
>  	.get_link_diagnosis_info = hclge_get_link_diagnosis_info,
>  	.clean_vf_config = hclge_clean_vport_config,
> +	.get_dscp_prio = hclge_get_dscp_prio,

This brings in an implicit dependency on CONFIG_HNS3_DCB, causing the
build error reported by the intel bot.

Please, address the above, thanks!

Paolo
Guangbin Huang Sept. 6, 2022, 1:50 p.m. UTC | #3
On 2022/9/6 21:12, Paolo Abeni wrote:
> On Mon, 2022-09-05 at 16:15 +0800, Guangbin Huang wrote:
>> This patch add support config dscp map to tc by implementing ieee_setapp
>> and ieee_delapp of struct dcbnl_rtnl_ops. Driver will convert mapping
>> relationship from dscp-prio to dscp-tc.
>>
>> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
>> ---
>>   drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  10 ++
>>   .../net/ethernet/hisilicon/hns3/hns3_dcbnl.c  |  28 +++++
>>   .../hisilicon/hns3/hns3pf/hclge_dcb.c         | 107 ++++++++++++++++++
>>   .../hisilicon/hns3/hns3pf/hclge_dcb.h         |   3 +
>>   .../hisilicon/hns3/hns3pf/hclge_main.c        |   1 +
>>   .../hisilicon/hns3/hns3pf/hclge_main.h        |   4 +
>>   .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.c |  50 +++++++-
>>   .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.h |   5 +
>>   8 files changed, 207 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
>> index 795df7111119..33b5ac47f342 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
>> @@ -310,6 +310,11 @@ enum hnae3_dbg_cmd {
>>   	HNAE3_DBG_CMD_UNKNOWN,
>>   };
>>   
>> +enum hnae3_tc_map_mode {
>> +	HNAE3_TC_MAP_MODE_PRIO,
>> +	HNAE3_TC_MAP_MODE_DSCP,
>> +};
>> +
>>   struct hnae3_vector_info {
>>   	u8 __iomem *io_addr;
>>   	int vector;
>> @@ -739,6 +744,8 @@ struct hnae3_ae_ops {
>>   	int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
>>   				       u32 *status_code);
>>   	void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
>> +	int (*get_dscp_prio)(struct hnae3_handle *handle, u8 dscp,
>> +			     u8 *tc_map_mode, u8 *priority);
>>   };
>>   
>>   struct hnae3_dcb_ops {
>> @@ -747,6 +754,8 @@ struct hnae3_dcb_ops {
>>   	int (*ieee_setets)(struct hnae3_handle *, struct ieee_ets *);
>>   	int (*ieee_getpfc)(struct hnae3_handle *, struct ieee_pfc *);
>>   	int (*ieee_setpfc)(struct hnae3_handle *, struct ieee_pfc *);
>> +	int (*ieee_setapp)(struct hnae3_handle *h, struct dcb_app *app);
>> +	int (*ieee_delapp)(struct hnae3_handle *h, struct dcb_app *app);
>>   
>>   	/* DCBX configuration */
>>   	u8   (*getdcbx)(struct hnae3_handle *);
>> @@ -786,6 +795,7 @@ struct hnae3_knic_private_info {
>>   	u32 tx_spare_buf_size;
>>   
>>   	struct hnae3_tc_info tc_info;
>> +	u8 tc_map_mode;
>>   
>>   	u16 num_tqps;		  /* total number of TQPs in this handle */
>>   	struct hnae3_queue **tqp;  /* array base of all TQPs in this instance */
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
>> index d2ec4c573bf8..3b6dbf158b98 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
>> @@ -56,6 +56,32 @@ static int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
>>   	return -EOPNOTSUPP;
>>   }
>>   
>> +static int hns3_dcbnl_ieee_setapp(struct net_device *ndev, struct dcb_app *app)
>> +{
>> +	struct hnae3_handle *h = hns3_get_handle(ndev);
>> +
>> +	if (hns3_nic_resetting(ndev))
>> +		return -EBUSY;
>> +
>> +	if (h->kinfo.dcb_ops->ieee_setapp)
>> +		return h->kinfo.dcb_ops->ieee_setapp(h, app);
>> +
>> +	return -EOPNOTSUPP;
>> +}
>> +
>> +static int hns3_dcbnl_ieee_delapp(struct net_device *ndev, struct dcb_app *app)
>> +{
>> +	struct hnae3_handle *h = hns3_get_handle(ndev);
>> +
>> +	if (hns3_nic_resetting(ndev))
>> +		return -EBUSY;
>> +
>> +	if (h->kinfo.dcb_ops->ieee_setapp)
>> +		return h->kinfo.dcb_ops->ieee_delapp(h, app);
>> +
>> +	return -EOPNOTSUPP;
>> +}
>> +
>>   /* DCBX configuration */
>>   static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
>>   {
>> @@ -83,6 +109,8 @@ static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
>>   	.ieee_setets	= hns3_dcbnl_ieee_setets,
>>   	.ieee_getpfc	= hns3_dcbnl_ieee_getpfc,
>>   	.ieee_setpfc	= hns3_dcbnl_ieee_setpfc,
>> +	.ieee_setapp    = hns3_dcbnl_ieee_setapp,
>> +	.ieee_delapp    = hns3_dcbnl_ieee_delapp,
>>   	.getdcbx	= hns3_dcbnl_getdcbx,
>>   	.setdcbx	= hns3_dcbnl_setdcbx,
>>   };
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
>> index 69b8673436ca..7fcacc76e749 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
>> @@ -359,6 +359,111 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
>>   	return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
>>   }
>>   
>> +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 ret;
>> +
>> +	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
>> +	    app->protocol >= HCLGE_MAX_DSCP ||
>> +	    app->priority >= HNAE3_MAX_USER_PRIO)
>> +		return -EINVAL;
>> +
>> +	dev_info(&hdev->pdev->dev, "setapp dscp=%u priority=%u\n",
>> +		 app->protocol, app->priority);
>> +
>> +	if (app->priority == hdev->tm_info.dscp_prio[app->protocol])
>> +		return 0;
>> +
>> +	ret = dcb_ieee_setapp(netdev, app);
>> +	if (ret)
>> +		return ret;
>> +
>> +	old_app.selector = IEEE_8021QAZ_APP_SEL_DSCP;
>> +	old_app.protocol = app->protocol;
>> +	old_app.priority = hdev->tm_info.dscp_prio[app->protocol];
>> +
>> +	hdev->tm_info.dscp_prio[app->protocol] = app->priority;
>> +	ret = hclge_dscp_to_tc_map(hdev);
>> +	if (ret) {
>> +		dev_err(&hdev->pdev->dev,
>> +			"failed to set dscp to tc map, ret = %d\n", ret);
>> +		hdev->tm_info.dscp_prio[app->protocol] = old_app.priority;
>> +		(void)dcb_ieee_delapp(netdev, app);
>> +		return ret;
>> +	}
>> +
>> +	vport->nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_DSCP;
>> +	if (old_app.priority == HCLGE_PRIO_ID_INVALID)
>> +		hdev->tm_info.dscp_app_cnt++;
>> +	else
>> +		ret = dcb_ieee_delapp(netdev, &old_app);
>> +
>> +	return ret;
>> +}
>> +
>> +static int hclge_ieee_delapp(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;
>> +	int ret;
>> +
>> +	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
>> +	    app->protocol >= HCLGE_MAX_DSCP ||
>> +	    app->priority >= HNAE3_MAX_USER_PRIO ||
>> +	    app->priority != hdev->tm_info.dscp_prio[app->protocol])
>> +		return -EINVAL;
>> +
>> +	dev_info(&hdev->pdev->dev, "delapp dscp=%u priority=%u\n",
>> +		 app->protocol, app->priority);
>> +
>> +	ret = dcb_ieee_delapp(netdev, app);
>> +	if (ret)
>> +		return ret;
>> +
>> +	hdev->tm_info.dscp_prio[app->protocol] = HCLGE_PRIO_ID_INVALID;
>> +	ret = hclge_dscp_to_tc_map(hdev);
>> +	if (ret) {
>> +		dev_err(&hdev->pdev->dev,
>> +			"failed to del dscp to tc map, ret = %d\n", ret);
>> +		hdev->tm_info.dscp_prio[app->protocol] = app->priority;
>> +		(void)dcb_ieee_setapp(netdev, app);
>> +		return ret;
>> +	}
>> +
>> +	if (hdev->tm_info.dscp_app_cnt)
>> +		hdev->tm_info.dscp_app_cnt--;
>> +
>> +	if (!hdev->tm_info.dscp_app_cnt) {
>> +		vport->nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_PRIO;
>> +		ret = hclge_up_to_tc_map(hdev);
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +int hclge_get_dscp_prio(struct hnae3_handle *h, u8 dscp, u8 *tc_mode,
>> +			u8 *priority)
>> +{
>> +	struct hclge_vport *vport = hclge_get_vport(h);
>> +	struct hclge_dev *hdev = vport->back;
>> +
>> +	if (dscp >= HCLGE_MAX_DSCP)
>> +		return -EINVAL;
>> +
>> +	if (tc_mode)
>> +		*tc_mode = vport->nic.kinfo.tc_map_mode;
>> +	if (priority)
>> +		*priority = hdev->tm_info.dscp_prio[dscp] == HCLGE_PRIO_ID_INVALID ? 0 :
>> +			    hdev->tm_info.dscp_prio[dscp];
>> +
>> +	return 0;
>> +}
>> +
>>   /* DCBX configuration */
>>   static u8 hclge_getdcbx(struct hnae3_handle *h)
>>   {
>> @@ -543,6 +648,8 @@ static const struct hnae3_dcb_ops hns3_dcb_ops = {
>>   	.ieee_setets	= hclge_ieee_setets,
>>   	.ieee_getpfc	= hclge_ieee_getpfc,
>>   	.ieee_setpfc	= hclge_ieee_setpfc,
>> +	.ieee_setapp    = hclge_ieee_setapp,
>> +	.ieee_delapp    = hclge_ieee_delapp,
>>   	.getdcbx	= hclge_getdcbx,
>>   	.setdcbx	= hclge_setdcbx,
>>   	.setup_tc	= hclge_setup_tc,
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
>> index b04702e65689..17a5460e7ea9 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
>> @@ -12,4 +12,7 @@ void hclge_dcb_ops_set(struct hclge_dev *hdev);
>>   static inline void hclge_dcb_ops_set(struct hclge_dev *hdev) {}
>>   #endif
>>   
>> +int hclge_get_dscp_prio(struct hnae3_handle *h, u8 dscp, u8 *tc_mode,
>> +			u8 *priority);
>> +
>>   #endif /* __HCLGE_DCB_H__ */
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
>> index fcdc978379ff..f43c7d392d1a 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
>> @@ -12907,6 +12907,7 @@ static const struct hnae3_ae_ops hclge_ops = {
>>   	.get_ts_info = hclge_ptp_get_ts_info,
>>   	.get_link_diagnosis_info = hclge_get_link_diagnosis_info,
>>   	.clean_vf_config = hclge_clean_vport_config,
>> +	.get_dscp_prio = hclge_get_dscp_prio,
> 
> This brings in an implicit dependency on CONFIG_HNS3_DCB, causing the
> build error reported by the intel bot.
> 
> Please, address the above, thanks!
> 
> Paolo
> 
> .
> 
Ok, I have modified in V2.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 795df7111119..33b5ac47f342 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -310,6 +310,11 @@  enum hnae3_dbg_cmd {
 	HNAE3_DBG_CMD_UNKNOWN,
 };
 
+enum hnae3_tc_map_mode {
+	HNAE3_TC_MAP_MODE_PRIO,
+	HNAE3_TC_MAP_MODE_DSCP,
+};
+
 struct hnae3_vector_info {
 	u8 __iomem *io_addr;
 	int vector;
@@ -739,6 +744,8 @@  struct hnae3_ae_ops {
 	int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
 				       u32 *status_code);
 	void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
+	int (*get_dscp_prio)(struct hnae3_handle *handle, u8 dscp,
+			     u8 *tc_map_mode, u8 *priority);
 };
 
 struct hnae3_dcb_ops {
@@ -747,6 +754,8 @@  struct hnae3_dcb_ops {
 	int (*ieee_setets)(struct hnae3_handle *, struct ieee_ets *);
 	int (*ieee_getpfc)(struct hnae3_handle *, struct ieee_pfc *);
 	int (*ieee_setpfc)(struct hnae3_handle *, struct ieee_pfc *);
+	int (*ieee_setapp)(struct hnae3_handle *h, struct dcb_app *app);
+	int (*ieee_delapp)(struct hnae3_handle *h, struct dcb_app *app);
 
 	/* DCBX configuration */
 	u8   (*getdcbx)(struct hnae3_handle *);
@@ -786,6 +795,7 @@  struct hnae3_knic_private_info {
 	u32 tx_spare_buf_size;
 
 	struct hnae3_tc_info tc_info;
+	u8 tc_map_mode;
 
 	u16 num_tqps;		  /* total number of TQPs in this handle */
 	struct hnae3_queue **tqp;  /* array base of all TQPs in this instance */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
index d2ec4c573bf8..3b6dbf158b98 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
@@ -56,6 +56,32 @@  static int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
 	return -EOPNOTSUPP;
 }
 
+static int hns3_dcbnl_ieee_setapp(struct net_device *ndev, struct dcb_app *app)
+{
+	struct hnae3_handle *h = hns3_get_handle(ndev);
+
+	if (hns3_nic_resetting(ndev))
+		return -EBUSY;
+
+	if (h->kinfo.dcb_ops->ieee_setapp)
+		return h->kinfo.dcb_ops->ieee_setapp(h, app);
+
+	return -EOPNOTSUPP;
+}
+
+static int hns3_dcbnl_ieee_delapp(struct net_device *ndev, struct dcb_app *app)
+{
+	struct hnae3_handle *h = hns3_get_handle(ndev);
+
+	if (hns3_nic_resetting(ndev))
+		return -EBUSY;
+
+	if (h->kinfo.dcb_ops->ieee_setapp)
+		return h->kinfo.dcb_ops->ieee_delapp(h, app);
+
+	return -EOPNOTSUPP;
+}
+
 /* DCBX configuration */
 static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
 {
@@ -83,6 +109,8 @@  static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
 	.ieee_setets	= hns3_dcbnl_ieee_setets,
 	.ieee_getpfc	= hns3_dcbnl_ieee_getpfc,
 	.ieee_setpfc	= hns3_dcbnl_ieee_setpfc,
+	.ieee_setapp    = hns3_dcbnl_ieee_setapp,
+	.ieee_delapp    = hns3_dcbnl_ieee_delapp,
 	.getdcbx	= hns3_dcbnl_getdcbx,
 	.setdcbx	= hns3_dcbnl_setdcbx,
 };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
index 69b8673436ca..7fcacc76e749 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
@@ -359,6 +359,111 @@  static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
 	return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
 }
 
+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 ret;
+
+	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
+	    app->protocol >= HCLGE_MAX_DSCP ||
+	    app->priority >= HNAE3_MAX_USER_PRIO)
+		return -EINVAL;
+
+	dev_info(&hdev->pdev->dev, "setapp dscp=%u priority=%u\n",
+		 app->protocol, app->priority);
+
+	if (app->priority == hdev->tm_info.dscp_prio[app->protocol])
+		return 0;
+
+	ret = dcb_ieee_setapp(netdev, app);
+	if (ret)
+		return ret;
+
+	old_app.selector = IEEE_8021QAZ_APP_SEL_DSCP;
+	old_app.protocol = app->protocol;
+	old_app.priority = hdev->tm_info.dscp_prio[app->protocol];
+
+	hdev->tm_info.dscp_prio[app->protocol] = app->priority;
+	ret = hclge_dscp_to_tc_map(hdev);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"failed to set dscp to tc map, ret = %d\n", ret);
+		hdev->tm_info.dscp_prio[app->protocol] = old_app.priority;
+		(void)dcb_ieee_delapp(netdev, app);
+		return ret;
+	}
+
+	vport->nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_DSCP;
+	if (old_app.priority == HCLGE_PRIO_ID_INVALID)
+		hdev->tm_info.dscp_app_cnt++;
+	else
+		ret = dcb_ieee_delapp(netdev, &old_app);
+
+	return ret;
+}
+
+static int hclge_ieee_delapp(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;
+	int ret;
+
+	if (app->selector != IEEE_8021QAZ_APP_SEL_DSCP ||
+	    app->protocol >= HCLGE_MAX_DSCP ||
+	    app->priority >= HNAE3_MAX_USER_PRIO ||
+	    app->priority != hdev->tm_info.dscp_prio[app->protocol])
+		return -EINVAL;
+
+	dev_info(&hdev->pdev->dev, "delapp dscp=%u priority=%u\n",
+		 app->protocol, app->priority);
+
+	ret = dcb_ieee_delapp(netdev, app);
+	if (ret)
+		return ret;
+
+	hdev->tm_info.dscp_prio[app->protocol] = HCLGE_PRIO_ID_INVALID;
+	ret = hclge_dscp_to_tc_map(hdev);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"failed to del dscp to tc map, ret = %d\n", ret);
+		hdev->tm_info.dscp_prio[app->protocol] = app->priority;
+		(void)dcb_ieee_setapp(netdev, app);
+		return ret;
+	}
+
+	if (hdev->tm_info.dscp_app_cnt)
+		hdev->tm_info.dscp_app_cnt--;
+
+	if (!hdev->tm_info.dscp_app_cnt) {
+		vport->nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_PRIO;
+		ret = hclge_up_to_tc_map(hdev);
+	}
+
+	return ret;
+}
+
+int hclge_get_dscp_prio(struct hnae3_handle *h, u8 dscp, u8 *tc_mode,
+			u8 *priority)
+{
+	struct hclge_vport *vport = hclge_get_vport(h);
+	struct hclge_dev *hdev = vport->back;
+
+	if (dscp >= HCLGE_MAX_DSCP)
+		return -EINVAL;
+
+	if (tc_mode)
+		*tc_mode = vport->nic.kinfo.tc_map_mode;
+	if (priority)
+		*priority = hdev->tm_info.dscp_prio[dscp] == HCLGE_PRIO_ID_INVALID ? 0 :
+			    hdev->tm_info.dscp_prio[dscp];
+
+	return 0;
+}
+
 /* DCBX configuration */
 static u8 hclge_getdcbx(struct hnae3_handle *h)
 {
@@ -543,6 +648,8 @@  static const struct hnae3_dcb_ops hns3_dcb_ops = {
 	.ieee_setets	= hclge_ieee_setets,
 	.ieee_getpfc	= hclge_ieee_getpfc,
 	.ieee_setpfc	= hclge_ieee_setpfc,
+	.ieee_setapp    = hclge_ieee_setapp,
+	.ieee_delapp    = hclge_ieee_delapp,
 	.getdcbx	= hclge_getdcbx,
 	.setdcbx	= hclge_setdcbx,
 	.setup_tc	= hclge_setup_tc,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
index b04702e65689..17a5460e7ea9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
@@ -12,4 +12,7 @@  void hclge_dcb_ops_set(struct hclge_dev *hdev);
 static inline void hclge_dcb_ops_set(struct hclge_dev *hdev) {}
 #endif
 
+int hclge_get_dscp_prio(struct hnae3_handle *h, u8 dscp, u8 *tc_mode,
+			u8 *priority);
+
 #endif /* __HCLGE_DCB_H__ */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index fcdc978379ff..f43c7d392d1a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -12907,6 +12907,7 @@  static const struct hnae3_ae_ops hclge_ops = {
 	.get_ts_info = hclge_ptp_get_ts_info,
 	.get_link_diagnosis_info = hclge_get_link_diagnosis_info,
 	.clean_vf_config = hclge_clean_vport_config,
+	.get_dscp_prio = hclge_get_dscp_prio,
 };
 
 static struct hnae3_ae_algo ae_algo = {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 18caddd541f8..8498cd8d36f9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -349,11 +349,15 @@  struct hclge_cfg {
 	u16 umv_space;
 };
 
+#define HCLGE_MAX_DSCP			64
+#define HCLGE_PRIO_ID_INVALID		0xff
 struct hclge_tm_info {
 	u8 num_tc;
 	u8 num_pg;      /* It must be 1 if vNET-Base schd */
+	u8 dscp_app_cnt;
 	u8 pg_dwrr[HCLGE_PG_NUM];
 	u8 prio_tc[HNAE3_MAX_USER_PRIO];
+	u8 dscp_prio[HCLGE_MAX_DSCP];
 	struct hclge_pg_info pg_info[HCLGE_PG_NUM];
 	struct hclge_tc_info tc_info[HNAE3_MAX_TC];
 	enum hclge_fc_mode fc_mode;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index 2f33b036a47a..7630d1f01e04 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -248,7 +248,7 @@  static int hclge_fill_pri_array(struct hclge_dev *hdev, u8 *pri, u8 pri_id)
 	return 0;
 }
 
-static int hclge_up_to_tc_map(struct hclge_dev *hdev)
+int hclge_up_to_tc_map(struct hclge_dev *hdev)
 {
 	struct hclge_desc desc;
 	u8 *pri = (u8 *)desc.data;
@@ -266,6 +266,47 @@  static int hclge_up_to_tc_map(struct hclge_dev *hdev)
 	return hclge_cmd_send(&hdev->hw, &desc, 1);
 }
 
+static void hclge_dscp_to_prio_map_init(struct hclge_dev *hdev)
+{
+	u8 i;
+
+	hdev->vport[0].nic.kinfo.tc_map_mode = HNAE3_TC_MAP_MODE_PRIO;
+	hdev->tm_info.dscp_app_cnt = 0;
+	for (i = 0; i < HCLGE_MAX_DSCP; i++)
+		hdev->tm_info.dscp_prio[i] = HCLGE_PRIO_ID_INVALID;
+}
+
+int hclge_dscp_to_tc_map(struct hclge_dev *hdev)
+{
+	struct hclge_desc desc[HCLGE_DSCP_MAP_TC_BD_NUM];
+	u8 *req0 = (u8 *)desc[0].data;
+	u8 *req1 = (u8 *)desc[1].data;
+	u8 pri_id, tc_id, i, j;
+
+	hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_QOS_MAP, false);
+	desc[0].flag |= cpu_to_le16(HCLGE_COMM_CMD_FLAG_NEXT);
+	hclge_cmd_setup_basic_desc(&desc[1], HCLGE_OPC_QOS_MAP, false);
+
+	/* The low 32 dscp setting use bd0, high 32 dscp setting use bd1 */
+	for (i = 0; i < HCLGE_MAX_DSCP / HCLGE_DSCP_MAP_TC_BD_NUM; i++) {
+		pri_id = hdev->tm_info.dscp_prio[i];
+		pri_id = pri_id == HCLGE_PRIO_ID_INVALID ? 0 : pri_id;
+		tc_id = hdev->tm_info.prio_tc[pri_id];
+		/* Each dscp setting has 4 bits, so each byte saves two dscp
+		 * setting
+		 */
+		req0[i >> 1] |= tc_id << HCLGE_DSCP_TC_SHIFT(i);
+
+		j = i + HCLGE_MAX_DSCP / HCLGE_DSCP_MAP_TC_BD_NUM;
+		pri_id = hdev->tm_info.dscp_prio[j];
+		pri_id = pri_id == HCLGE_PRIO_ID_INVALID ? 0 : pri_id;
+		tc_id = hdev->tm_info.prio_tc[pri_id];
+		req1[i >> 1] |= tc_id << HCLGE_DSCP_TC_SHIFT(i);
+	}
+
+	return hclge_cmd_send(&hdev->hw, desc, HCLGE_DSCP_MAP_TC_BD_NUM);
+}
+
 static int hclge_tm_pg_to_pri_map_cfg(struct hclge_dev *hdev,
 				      u8 pg_id, u8 pri_bit_map)
 {
@@ -1275,6 +1316,12 @@  static int hclge_tm_map_cfg(struct hclge_dev *hdev)
 	if (ret)
 		return ret;
 
+	if (hdev->vport[0].nic.kinfo.tc_map_mode == HNAE3_TC_MAP_MODE_DSCP) {
+		ret = hclge_dscp_to_tc_map(hdev);
+		if (ret)
+			return ret;
+	}
+
 	ret = hclge_tm_pg_to_pri_map(hdev);
 	if (ret)
 		return ret;
@@ -1646,6 +1693,7 @@  int hclge_tm_schd_init(struct hclge_dev *hdev)
 		return -EINVAL;
 
 	hclge_tm_schd_info_init(hdev);
+	hclge_dscp_to_prio_map_init(hdev);
 
 	return hclge_tm_init_hw(hdev, true);
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
index d943943912f7..68f28a98e380 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
@@ -30,6 +30,9 @@  enum hclge_opcode_type;
 #define HCLGE_TM_PF_MAX_PRI_NUM		8
 #define HCLGE_TM_PF_MAX_QSET_NUM	8
 
+#define HCLGE_DSCP_MAP_TC_BD_NUM	2
+#define HCLGE_DSCP_TC_SHIFT(n)		(((n) & 1) * 4)
+
 struct hclge_pg_to_pri_link_cmd {
 	u8 pg_id;
 	u8 rsvd1[3];
@@ -262,4 +265,6 @@  int hclge_tm_get_pg_shaper(struct hclge_dev *hdev, u8 pg_id,
 			   struct hclge_tm_shaper_para *para);
 int hclge_tm_get_port_shaper(struct hclge_dev *hdev,
 			     struct hclge_tm_shaper_para *para);
+int hclge_up_to_tc_map(struct hclge_dev *hdev);
+int hclge_dscp_to_tc_map(struct hclge_dev *hdev);
 #endif