realtek-doc/sources/uboot-be550/drivers/net/rtl8372/qos.c
Markus Stockhausen 9b3bf98ee9 add BE550 sources
2025-10-14 01:59:03 -04:00

1110 lines
32 KiB
C
Executable file

/*
* Copyright (C) 2013 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision$
* $Date$
*
* Purpose : RTK switch high-level API for RTL8373
* Feature : Here is a list of all functions and variables in QoS module.
*
*/
#include <rtk_switch.h>
#include <rtk_error.h>
#include <qos.h>
#include <linux/string.h>
#include <dal/dal_mgmt.h>
/* Function Name:
* rtk_qos_init
* Description:
* Configure Qos default settings.
* Input:
* None
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QUEUE_NUM - Invalid queue number.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This API will initialize related Qos setting.
*/
rtk_api_ret_t rtk_qos_init(void)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_init)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_init();
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_priSel_set
* Description:
* Configure the priority order among different priority mechanism.
* Input:
* index - Priority decision table index (0~1)
* pPriDec - Priority assign for port, dscp, 802.1p, svlan, acl based priority decision.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_SEL_PRI_SOURCE - Invalid priority decision source parameter.
* Note:
* ASIC will follow user priority setting of mechanisms to select mapped queue priority for receiving frame.
* If two priority mechanisms are the same, the ASIC will chose the highest priority from mechanisms to
* assign queue priority to receiving frame.
* The priority sources are:
* - PRIDEC_PORT
* - PRIDEC_ACL
* - PRIDEC_DSCP
* - PRIDEC_1Q
* - PRIDEC_SVLAN
*/
rtk_api_ret_t rtk_qos_priSel_set(rtk_qos_priDecTbl_t index, rtk_priority_select_t *pPriDec)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_priSel_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_priSel_set(index, pPriDec);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_priSel_get
* Description:
* Get the priority order configuration among different priority mechanism.
* Input:
* index - Priority decision table index (0~1)
* Output:
* pPriDec - Priority assign for port, dscp, 802.1p, svlan, acl based priority decision .
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* Note:
* ASIC will follow user priority setting of mechanisms to select mapped queue priority for receiving frame.
* If two priority mechanisms are the same, the ASIC will chose the highest priority from mechanisms to
* assign queue priority to receiving frame.
* The priority sources are:
* - PRIDEC_PORT,
* - PRIDEC_ACL,
* - PRIDEC_DSCP,
* - PRIDEC_1Q,
* - PRIDEC_SVLAN,
*/
rtk_api_ret_t rtk_qos_priSel_get(rtk_qos_priDecTbl_t index, rtk_priority_select_t *pPriDec)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_priSel_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_priSel_get(index, pPriDec);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pPriRemap_set
* Description:
* Configure 1Q priorities mapping to internal absolute priority.
* Input:
* dot1p_pri - 802.1p priority value.
* int_pri - internal priority value.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_VLAN_PRIORITY - Invalid 1p priority.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* Priority of 802.1Q assignment for internal asic priority, and it is used for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_1pPriRemap_set(rtk_pri_t dot1p_pri, rtk_pri_t int_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pPriRemap_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pPriRemap_set(dot1p_pri, int_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pPriRemap_get
* Description:
* Get 1Q priorities mapping to internal absolute priority.
* Input:
* dot1p_pri - 802.1p priority value .
* Output:
* pInt_pri - internal priority value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_VLAN_PRIORITY - Invalid priority.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* Priority of 802.1Q assigment for internal asic priority, and it is uesed for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_1pPriRemap_get(rtk_pri_t dot1p_pri, rtk_pri_t *pInt_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pPriRemap_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pPriRemap_get(dot1p_pri, pInt_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscpPriRemap_set
* Description:
* Map dscp value to internal priority.
* Input:
* dscp - Dscp value of receiving frame
* int_pri - internal priority value .
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_QOS_DSCP_VALUE - Invalid DSCP value.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* The Differentiated Service Code Point is a selector for router's per-hop behaviors. As a selector, there is no implication that a numerically
* greater DSCP implies a better network service. As can be seen, the DSCP totally overlaps the old precedence field of TOS. So if values of
* DSCP are carefully chosen then backward compatibility can be achieved.
*/
rtk_api_ret_t rtk_qos_dscpPriRemap_set(rtk_dscp_t dscp, rtk_pri_t int_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscpPriRemap_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscpPriRemap_set(dscp, int_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscpPriRemap_get
* Description:
* Get dscp value to internal priority.
* Input:
* dscp - Dscp value of receiving frame
* Output:
* pInt_pri - internal priority value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_DSCP_VALUE - Invalid DSCP value.
* Note:
* The Differentiated Service Code Point is a selector for router's per-hop behaviors. As a selector, there is no implication that a numerically
* greater DSCP implies a better network service. As can be seen, the DSCP totally overlaps the old precedence field of TOS. So if values of
* DSCP are carefully chosen then backward compatibility can be achieved.
*/
rtk_api_ret_t rtk_qos_dscpPriRemap_get(rtk_dscp_t dscp, rtk_pri_t *pInt_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscpPriRemap_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscpPriRemap_get(dscp, pInt_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_RspanPriRemap_set
* Description:
* Configure RSPAN priorities mapping to internal absolute priority.
* Input:
* rspan_pri - rspan priority value.
* int_pri - internal priority value.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_VLAN_PRIORITY - Invalid 1p priority.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* Priority of RSPAN assignment for internal asic priority, and it is used for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_RspanPriRemap_set(rtk_pri_t rspan_pri, rtk_pri_t int_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_rspanpriRemap_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_rspanpriRemap_set(rspan_pri, int_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_RspanPriRemap_get
* Description:
* Get RSPAN priorities mapping to internal absolute priority.
* Input:
* rspan_pri - rspan priority value.
* Output:
* pInt_pri - internal priority value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_VLAN_PRIORITY - Invalid priority.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* Priority of RSPAN assigment for internal asic priority, and it is uesed for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_RspanPriRemap_get(rtk_pri_t rspan_pri, rtk_pri_t *pInt_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_rspanpriRemap_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_rspanpriRemap_get(rspan_pri, pInt_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_portPri_set
* Description:
* Configure priority usage to each port.
* Input:
* port - Port id.
* int_pri - internal priority value.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_QOS_SEL_PORT_PRI - Invalid port priority.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* The API can set priority of port assignments for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_portPri_set(rtk_port_t port, rtk_pri_t int_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_portPri_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_portPri_set(port, int_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_portPri_get
* Description:
* Get priority usage to each port.
* Input:
* port - Port id.
* Output:
* pInt_pri - internal priority value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* The API can get priority of port assignments for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_portPri_get(rtk_port_t port, rtk_pri_t *pInt_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_portPri_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_portPri_get(port, pInt_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_priMap_set
* Description:
* Set output queue number for each port.
* Input:
* port - Port ID.
* pPri2qid - Priority mapping to queue ID.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_QUEUE_NUM - Invalid queue number.
* RT_ERR_QUEUE_ID - Invalid queue id.
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* ASIC supports priority mapping to queue with different internal available queue IDs.
*/
rtk_api_ret_t rtk_qos_priMap_set(rtk_port_t port, rtk_qos_pri2queue_t *pPri2qid)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_priMap_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_priMap_set(port, pPri2qid);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* dal_rtl8371c_qos_priMap_get
* Description:
* Get priority to queue ID mapping table parameters.
* Input:
* port - Port ID.
* Output:
* pPri2qid - Priority mapping to queue ID.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_QUEUE_NUM - Invalid queue number.
* Note:
* The API can return the mapping queue id of the specified priority.
*/
rtk_api_ret_t rtk_qos_priMap_get(rtk_port_t port, rtk_qos_pri2queue_t *pPri2qid)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_priMap_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_priMap_get(port, pPri2qid);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_schedulingQueue_set
* Description:
* Set weight and type of queues in dedicated port.
* Input:
* port - Port id.
* pQweights - The array of weights for WRR/WFQ queue (0 for STRICT_PRIORITY queue).
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_QOS_QUEUE_WEIGHT - Invalid queue weight.
* Note:
* The API can set weight and type, strict priority or weight fair queue (WFQ) for
* dedicated port for using queues. If queue id is not included in queue usage,
* then its type and weight setting in dummy for setting. There are priorities
* as queue id in strict queues. It means strict queue id 5 carrying higher priority
* than strict queue id 4. The WFQ queue weight is from 1 to 127, and weight 0 is
* for strict priority queue type.
*/
rtk_api_ret_t rtk_qos_schedulingQueue_set(rtk_port_t port, rtk_qos_queue_weights_t *pQweights)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_schedulingQueue_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_schedulingQueue_set(port, pQweights);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_schedulingQueue_get
* Description:
* Get weight and type of queues in dedicated port.
* Input:
* port - Port id.
* Output:
* pQweights - The array of weights for WRR/WFQ queue (0 for STRICT_PRIORITY queue).
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_PORT_ID - Invalid port number.
* Note:
* The API can get weight and type, strict priority or weight fair queue (WFQ) for dedicated port for using queues.
* The WFQ queue weight is from 1 to 127, and weight 0 is for strict priority queue type.
*/
rtk_api_ret_t rtk_qos_schedulingQueue_get(rtk_port_t port, rtk_qos_queue_weights_t *pQweights)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_schedulingQueue_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_schedulingQueue_get(port, pQweights);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pRemarkEnable_set
* Description:
* Set 1p Remarking state
* Input:
* port - Port id.
* enable - State of per-port 1p Remarking
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_ENABLE - Invalid enable parameter.
* Note:
* The API can enable or disable 802.1p remarking ability for whole system.
* The status of 802.1p remark:
* - DISABLED
* - ENABLED
*/
rtk_api_ret_t rtk_qos_1pRemarkEnable_set(rtk_port_t port, rtk_enable_t enable)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pRemarkEnable_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pRemarkEnable_set(port, enable);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pRemarkEnable_get
* Description:
* Get 802.1p remarking ability.
* Input:
* port - Port id.
* Output:
* pEnable - Status of 802.1p remark.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* Note:
* The API can get 802.1p remarking ability.
* The status of 802.1p remark:
* - DISABLED
* - ENABLED
*/
rtk_api_ret_t rtk_qos_1pRemarkEnable_get(rtk_port_t port, rtk_enable_t *pEnable)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pRemarkEnable_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pRemarkEnable_get(port, pEnable);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pRemark_set
* Description:
* Set 802.1p remarking parameter.
* Input:
* int_pri - Internal priority value.
* dot1p_pri - 802.1p priority value.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_VLAN_PRIORITY - Invalid 1p priority.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* The API can set 802.1p parameters source priority and new priority.
*/
rtk_api_ret_t rtk_qos_1pRemark_set(rtk_pri_t int_pri, rtk_pri_t dot1p_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pRemark_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pRemark_set(int_pri, dot1p_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pRemark_get
* Description:
* Get 802.1p remarking parameter.
* Input:
* int_pri - Internal priority value.
* Output:
* pDot1p_pri - 802.1p priority value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* The API can get 802.1p remarking parameters. It would return new priority of ingress priority.
*/
rtk_api_ret_t rtk_qos_1pRemark_get(rtk_pri_t int_pri, rtk_pri_t *pDot1p_pri)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pRemark_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pRemark_get(int_pri, pDot1p_pri);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pRemarkSrcSel_set
* Description:
* Set remarking source of 802.1p remarking.
* Input:
* type - remarking source
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* The API can configure 802.1p remark functionality to map original 802.1p value or internal
* priority to TX DSCP value.
*/
rtk_api_ret_t rtk_qos_1pRemarkSrcSel_set(rtk_qos_1pRmkSrc_t type)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pRemarkSrcSel_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pRemarkSrcSel_set(type);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_1pRemarkSrcSel_get
* Description:
* Get remarking source of 802.1p remarking.
* Input:
* none
* Output:
* pType - remarking source
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
rtk_api_ret_t rtk_qos_1pRemarkSrcSel_get(rtk_qos_1pRmkSrc_t *pType)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_1pRemarkSrcSel_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_1pRemarkSrcSel_get(pType);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscpRemarkEnable_set
* Description:
* Set DSCP remarking ability.
* Input:
* port - Port id.
* enable - status of DSCP remark.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* RT_ERR_ENABLE - Invalid enable parameter.
* Note:
* The API can enable or disable DSCP remarking ability for whole system.
* The status of DSCP remark:
* - DISABLED
* - ENABLED
*/
rtk_api_ret_t rtk_qos_dscpRemarkEnable_set(rtk_port_t port, rtk_enable_t enable)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscpRemarkEnable_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscpRemarkEnable_set(port, enable);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscpRemarkEnable_get
* Description:
* Get DSCP remarking ability.
* Input:
* port - Port id.
* Output:
* pEnable - status of DSCP remarking.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* Note:
* The API can get DSCP remarking ability.
* The status of DSCP remark:
* - DISABLED
* - ENABLED
*/
rtk_api_ret_t rtk_qos_dscpRemarkEnable_get(rtk_port_t port, rtk_enable_t *pEnable)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscpRemarkEnable_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscpRemarkEnable_get(port, pEnable);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_intpri2dscp_Remark_set
* Description:
* Set DSCP remarking parameter.
* Input:
* int_pri - Internal priority value.
* dscp - remark DSCP value.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* RT_ERR_QOS_DSCP_VALUE - Invalid DSCP value.
* Note:
* The API can set internal priority to DSCP value.
*/
rtk_api_ret_t rtk_qos_intpri2dscp_Remark_set(rtk_pri_t int_pri, rtk_dscp_t dscp)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_intpri2dscpRemark_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_intpri2dscpRemark_set(int_pri, dscp);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_intpri2dscp_Remark_get
* Description:
* Get DSCP remarking parameter.
* Input:
* int_pri - Internal priority value.
* Output:
* pDscp - remark DSCP value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* The API can get DSCP parameters. It would return DSCP value for mapping priority.
*/
rtk_api_ret_t rtk_qos_intpri2dscp_Remark_get(rtk_pri_t int_pri, rtk_dscp_t *pDscp)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_intpri2dscpRemark_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_intpri2dscpRemark_get(int_pri, pDscp);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscp2dscp_Remark_set
* Description:
* Set original DSCP remarking parameter.
* Input:
* ori_dscp - original dscp value.
* RmkDscp - remark DSCP value.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* RT_ERR_QOS_DSCP_VALUE - Invalid DSCP value.
* Note:
* The API can set original DSCP value to dscp value.
*/
rtk_api_ret_t rtk_qos_dscp2dscp_Remark_set(rtk_pri_t ori_dscp, rtk_dscp_t RmkDscp)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscp2dscpRemark_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscp2dscpRemark_set(ori_dscp, RmkDscp);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscp2dscp_Remark_get
* Description:
* Get DSCP remarking parameter.
* Input:
* ori_dscp - original dscp value.
* Output:
* pRmkDscp - remark DSCP value.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_INT_PRIORITY - Invalid priority.
* Note:
* The API can get DSCP parameters. It would return DSCP value for mapping priority.
*/
rtk_api_ret_t rtk_qos_dscp2dscp_Remark_get(rtk_pri_t ori_dscp, rtk_dscp_t *pRmkDscp)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscp2dscpRemark_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscp2dscpRemark_get(ori_dscp, pRmkDscp);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscpRemarkSrcSel_set
* Description:
* Set remarking source of DSCP remarking.
* Input:
* type - remarking source
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* The API can configure DSCP remark functionality to map original DSCP value or internal
* priority to TX DSCP value.
*/
rtk_api_ret_t rtk_qos_dscpRemarkSrcSel_set(rtk_qos_dscpRmkSrc_t type)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscpRemarkSrcSel_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscpRemarkSrcSel_set(type);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_dscpRemarkSrcSel_get
* Description:
* Get remarking source of DSCP remarking.
* Input:
* none
* Output:
* pType - remarking source
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
rtk_api_ret_t rtk_qos_dscpRemarkSrcSel_get(rtk_qos_dscpRmkSrc_t *pType)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_dscpRemarkSrcSel_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_dscpRemarkSrcSel_get(pType);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_portPriSelIndex_set
* Description:
* Configure priority decision index to each port.
* Input:
* port - Port id.
* index - priority decision index.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* RT_ERR_ENTRY_INDEX - Invalid entry index.
* Note:
* The API can set priority of port assignments for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_portPriSelIndex_set(rtk_port_t port, rtk_qos_priDecTbl_t index)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_portPriSelIndex_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_portPriSelIndex_set(port, index);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_portPriSelIndex_get
* Description:
* Get priority decision index from each port.
* Input:
* port - Port id.
* Output:
* pIndex - priority decision index.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number.
* Note:
* The API can get priority of port assignments for queue usage and packet scheduling.
*/
rtk_api_ret_t rtk_qos_portPriSelIndex_get(rtk_port_t port, rtk_qos_priDecTbl_t *pIndex)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_portPriSelIndex_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_portPriSelIndex_get(port, pIndex);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_schedulingType_set
* Description:
* Configure type of scheduling.
* Input:
* port - port id
* queueType - Scheduling type.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_QOS_SCHE_TYPE - Invalid QoS scheduling type.
* Note:
* The API can set type of scheduling.
*/
rtk_api_ret_t rtk_qos_schedulingType_set(rtk_port_t port, rtk_qos_scheduling_type_t queueType)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_schedulingType_set)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_schedulingType_set(port, queueType);
RTK_API_UNLOCK();
return retVal;
}
/* Function Name:
* rtk_qos_schedulingType_get
* Description:
* Get type of scheduling.
* Input:
* port - port id
* Output:
* pIndex - priority decision index.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* The API can get type of scheduling.
*/
rtk_api_ret_t rtk_qos_schedulingType_get(rtk_port_t port, rtk_qos_scheduling_type_t *pQueueType)
{
rtk_api_ret_t retVal;
if (NULL == RT_MAPPER->qos_schedulingType_get)
return RT_ERR_DRIVER_NOT_FOUND;
RTK_API_LOCK();
retVal = RT_MAPPER->qos_schedulingType_get(port, pQueueType);
RTK_API_UNLOCK();
return retVal;
}