mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 12:14:10 +08:00
Merge branch 'am65-cpsw-rx-dscp-prio-map'
Roger Quadros says: ==================== net: ethernet: ti: am65-cpsw: enable DSCP to priority map for RX Configure default DSCP to User Priority mapping registers as per: https://datatracker.ietf.org/doc/html/rfc8325#section-4.3 and https://datatracker.ietf.org/doc/html/rfc8622#section-11 Also update Priority to Thread maping to be compliant with IEEE802.1Q-2014. Priority Code Point (PCP) 2 is higher priority than PCP 0 (Best Effort). PCP 1 (Background) is lower priority than PCP 0 (Best Effort). --- Changes in v4: - Updated default DSCP to User Priority mapping as per https://datatracker.ietf.org/doc/html/rfc8325#section-4.3 and https://datatracker.ietf.org/doc/html/rfc8622#section-11 - Link to v3: https://lore.kernel.org/r/20241109-am65-cpsw-multi-rx-dscp-v3-0-1cfb76928490@kernel.org Changes in v3: - Added Reviewed-by tag to patch 1 - Added macros for DSCP PRI field size and DSCP PRI per register - Drop unnecessary readl() in am65_cpsw_port_set_dscp_map() - Link to v2: https://lore.kernel.org/r/20241107-am65-cpsw-multi-rx-dscp-v2-0-9e9cd1920035@kernel.org Changes in v2: - Updated references to more recent standard IEEE802.1Q-2014. - Dropped reference to web link which might change in the future. - Typo fix in commit log. - Link to v1: https://lore.kernel.org/r/20241105-am65-cpsw-multi-rx-dscp-v1-0-38db85333c88@kernel.org ==================== Signed-off-by: Roger Quadros <rogerq@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
d7ef9eeef0
@ -71,6 +71,8 @@
|
||||
#define AM65_CPSW_PORT_REG_RX_PRI_MAP 0x020
|
||||
#define AM65_CPSW_PORT_REG_RX_MAXLEN 0x024
|
||||
|
||||
#define AM65_CPSW_PORTN_REG_CTL 0x004
|
||||
#define AM65_CPSW_PORTN_REG_DSCP_MAP 0x120
|
||||
#define AM65_CPSW_PORTN_REG_SA_L 0x308
|
||||
#define AM65_CPSW_PORTN_REG_SA_H 0x30c
|
||||
#define AM65_CPSW_PORTN_REG_TS_CTL 0x310
|
||||
@ -94,6 +96,10 @@
|
||||
/* AM65_CPSW_PORT_REG_PRI_CTL */
|
||||
#define AM65_CPSW_PORT_REG_PRI_CTL_RX_PTYPE_RROBIN BIT(8)
|
||||
|
||||
/* AM65_CPSW_PN_REG_CTL */
|
||||
#define AM65_CPSW_PN_REG_CTL_DSCP_IPV4_EN BIT(1)
|
||||
#define AM65_CPSW_PN_REG_CTL_DSCP_IPV6_EN BIT(2)
|
||||
|
||||
/* AM65_CPSW_PN_TS_CTL register fields */
|
||||
#define AM65_CPSW_PN_TS_CTL_TX_ANX_F_EN BIT(4)
|
||||
#define AM65_CPSW_PN_TS_CTL_TX_VLAN_LT1_EN BIT(5)
|
||||
@ -176,6 +182,99 @@ static void am65_cpsw_port_set_sl_mac(struct am65_cpsw_port *slave,
|
||||
writel(mac_lo, slave->port_base + AM65_CPSW_PORTN_REG_SA_L);
|
||||
}
|
||||
|
||||
#define AM65_CPSW_DSCP_MAX GENMASK(5, 0)
|
||||
#define AM65_CPSW_PRI_MAX GENMASK(2, 0)
|
||||
#define AM65_CPSW_DSCP_PRI_PER_REG 8
|
||||
#define AM65_CPSW_DSCP_PRI_SIZE 4 /* in bits */
|
||||
static int am65_cpsw_port_set_dscp_map(struct am65_cpsw_port *slave, u8 dscp, u8 pri)
|
||||
{
|
||||
int reg_ofs;
|
||||
int bit_ofs;
|
||||
u32 val;
|
||||
|
||||
if (dscp > AM65_CPSW_DSCP_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
if (pri > AM65_CPSW_PRI_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
/* 32-bit register offset to this dscp */
|
||||
reg_ofs = (dscp / AM65_CPSW_DSCP_PRI_PER_REG) * 4;
|
||||
/* bit field offset to this dscp */
|
||||
bit_ofs = AM65_CPSW_DSCP_PRI_SIZE * (dscp % AM65_CPSW_DSCP_PRI_PER_REG);
|
||||
|
||||
val = readl(slave->port_base + AM65_CPSW_PORTN_REG_DSCP_MAP + reg_ofs);
|
||||
val &= ~(AM65_CPSW_PRI_MAX << bit_ofs); /* clear */
|
||||
val |= pri << bit_ofs; /* set */
|
||||
writel(val, slave->port_base + AM65_CPSW_PORTN_REG_DSCP_MAP + reg_ofs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void am65_cpsw_port_enable_dscp_map(struct am65_cpsw_port *slave)
|
||||
{
|
||||
int dscp, pri;
|
||||
u32 val;
|
||||
|
||||
/* Default DSCP to User Priority mapping as per:
|
||||
* https://datatracker.ietf.org/doc/html/rfc8325#section-4.3
|
||||
* and
|
||||
* https://datatracker.ietf.org/doc/html/rfc8622#section-11
|
||||
*/
|
||||
for (dscp = 0; dscp <= AM65_CPSW_DSCP_MAX; dscp++) {
|
||||
switch (dscp) {
|
||||
case 56: /* CS7 */
|
||||
case 48: /* CS6 */
|
||||
pri = 7;
|
||||
break;
|
||||
case 46: /* EF */
|
||||
case 44: /* VA */
|
||||
pri = 6;
|
||||
break;
|
||||
case 40: /* CS5 */
|
||||
pri = 5;
|
||||
break;
|
||||
case 34: /* AF41 */
|
||||
case 36: /* AF42 */
|
||||
case 38: /* AF43 */
|
||||
case 32: /* CS4 */
|
||||
case 26: /* AF31 */
|
||||
case 28: /* AF32 */
|
||||
case 30: /* AF33 */
|
||||
case 24: /* CS3 */
|
||||
pri = 4;
|
||||
break;
|
||||
case 18: /* AF21 */
|
||||
case 20: /* AF22 */
|
||||
case 22: /* AF23 */
|
||||
pri = 3;
|
||||
break;
|
||||
case 16: /* CS2 */
|
||||
case 10: /* AF11 */
|
||||
case 12: /* AF12 */
|
||||
case 14: /* AF13 */
|
||||
case 0: /* DF */
|
||||
pri = 0;
|
||||
break;
|
||||
case 8: /* CS1 */
|
||||
case 1: /* LE */
|
||||
pri = 1;
|
||||
break;
|
||||
default:
|
||||
pri = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
am65_cpsw_port_set_dscp_map(slave, dscp, pri);
|
||||
}
|
||||
|
||||
/* enable port IPV4 and IPV6 DSCP for this port */
|
||||
val = readl(slave->port_base + AM65_CPSW_PORTN_REG_CTL);
|
||||
val |= AM65_CPSW_PN_REG_CTL_DSCP_IPV4_EN |
|
||||
AM65_CPSW_PN_REG_CTL_DSCP_IPV6_EN;
|
||||
writel(val, slave->port_base + AM65_CPSW_PORTN_REG_CTL);
|
||||
}
|
||||
|
||||
static void am65_cpsw_sl_ctl_reset(struct am65_cpsw_port *port)
|
||||
{
|
||||
cpsw_sl_reset(port->slave.mac_sl, 100);
|
||||
@ -916,6 +1015,7 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
|
||||
common->usage_count++;
|
||||
|
||||
am65_cpsw_port_set_sl_mac(port, ndev->dev_addr);
|
||||
am65_cpsw_port_enable_dscp_map(port);
|
||||
|
||||
if (common->is_emac_mode)
|
||||
am65_cpsw_init_port_emac_ale(port);
|
||||
|
@ -1704,26 +1704,34 @@ static void cpsw_ale_policer_reset(struct cpsw_ale *ale)
|
||||
void cpsw_ale_classifier_setup_default(struct cpsw_ale *ale, int num_rx_ch)
|
||||
{
|
||||
int pri, idx;
|
||||
/* IEEE802.1D-2004, Standard for Local and metropolitan area networks
|
||||
* Table G-2 - Traffic type acronyms
|
||||
* Table G-3 - Defining traffic types
|
||||
* User priority values 1 and 2 effectively communicate a lower
|
||||
* priority than 0. In the below table 0 is assigned to higher priority
|
||||
* thread than 1 and 2 wherever possible.
|
||||
* The below table maps which thread the user priority needs to be
|
||||
|
||||
/* Reference:
|
||||
* IEEE802.1Q-2014, Standard for Local and metropolitan area networks
|
||||
* Table I-2 - Traffic type acronyms
|
||||
* Table I-3 - Defining traffic types
|
||||
* Section I.4 Traffic types and priority values, states:
|
||||
* "0 is thus used both for default priority and for Best Effort, and
|
||||
* Background is associated with a priority value of 1. This means
|
||||
* that the value 1 effectively communicates a lower priority than 0."
|
||||
*
|
||||
* In the table below, Priority Code Point (PCP) 0 is assigned
|
||||
* to a higher priority thread than PCP 1 wherever possible.
|
||||
* The table maps which thread the PCP traffic needs to be
|
||||
* sent to for a given number of threads (RX channels). Upper threads
|
||||
* have higher priority.
|
||||
* e.g. if number of threads is 8 then user priority 0 will map to
|
||||
* pri_thread_map[8-1][0] i.e. thread 2
|
||||
* pri_thread_map[8-1][0] i.e. thread 1
|
||||
*/
|
||||
int pri_thread_map[8][8] = { { 0, 0, 0, 0, 0, 0, 0, 0, },
|
||||
|
||||
int pri_thread_map[8][8] = { /* BK,BE,EE,CA,VI,VO,IC,NC */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, },
|
||||
{ 0, 0, 0, 0, 1, 1, 1, 1, },
|
||||
{ 0, 0, 0, 0, 1, 1, 2, 2, },
|
||||
{ 1, 0, 0, 1, 2, 2, 3, 3, },
|
||||
{ 1, 0, 0, 1, 2, 3, 4, 4, },
|
||||
{ 1, 0, 0, 2, 3, 4, 5, 5, },
|
||||
{ 1, 0, 0, 2, 3, 4, 5, 6, },
|
||||
{ 2, 0, 1, 3, 4, 5, 6, 7, } };
|
||||
{ 0, 0, 1, 1, 2, 2, 3, 3, },
|
||||
{ 0, 0, 1, 1, 2, 2, 3, 4, },
|
||||
{ 1, 0, 2, 2, 3, 3, 4, 5, },
|
||||
{ 1, 0, 2, 3, 4, 4, 5, 6, },
|
||||
{ 1, 0, 2, 3, 4, 5, 6, 7 } };
|
||||
|
||||
cpsw_ale_policer_reset(ale);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user