Skip to content

Commit ad53fa0

Browse files
Nogah Frankeldavem330
authored andcommitted
mlxsw: reg: Add cwtp & cwtpm registers
This patch adds 2 new registers: - Congestion WRED ECN TClass Profile Register [CWTP] - Congestion WRED ECN TClass and Pool Mapping Register [CWTPM] These registers would later be needed to offload RED-related functionality to the HW. Signed-off-by: Yuval Mintz <yuvalm@mellanox.com> Signed-off-by: Nogah Frankel <nogahf@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8521db4 commit ad53fa0

File tree

1 file changed

+187
-0
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+187
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,191 @@ static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
17581758
}
17591759
}
17601760

1761+
/* CWTP - Congetion WRED ECN TClass Profile
1762+
* ----------------------------------------
1763+
* Configures the profiles for queues of egress port and traffic class
1764+
*/
1765+
#define MLXSW_REG_CWTP_ID 0x2802
1766+
#define MLXSW_REG_CWTP_BASE_LEN 0x28
1767+
#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
1768+
#define MLXSW_REG_CWTP_LEN 0x40
1769+
1770+
MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
1771+
1772+
/* reg_cwtp_local_port
1773+
* Local port number
1774+
* Not supported for CPU port
1775+
* Access: Index
1776+
*/
1777+
MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
1778+
1779+
/* reg_cwtp_traffic_class
1780+
* Traffic Class to configure
1781+
* Access: Index
1782+
*/
1783+
MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
1784+
1785+
/* reg_cwtp_profile_min
1786+
* Minimum Average Queue Size of the profile in cells.
1787+
* Access: RW
1788+
*/
1789+
MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
1790+
0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
1791+
1792+
/* reg_cwtp_profile_percent
1793+
* Percentage of WRED and ECN marking for maximum Average Queue size
1794+
* Range is 0 to 100, units of integer percentage
1795+
* Access: RW
1796+
*/
1797+
MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
1798+
24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1799+
1800+
/* reg_cwtp_profile_max
1801+
* Maximum Average Queue size of the profile in cells
1802+
* Access: RW
1803+
*/
1804+
MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
1805+
0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1806+
1807+
#define MLXSW_REG_CWTP_MIN_VALUE 64
1808+
#define MLXSW_REG_CWTP_MAX_PROFILE 2
1809+
#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
1810+
1811+
static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
1812+
u8 traffic_class)
1813+
{
1814+
int i;
1815+
1816+
MLXSW_REG_ZERO(cwtp, payload);
1817+
mlxsw_reg_cwtp_local_port_set(payload, local_port);
1818+
mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
1819+
1820+
for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
1821+
mlxsw_reg_cwtp_profile_min_set(payload, i,
1822+
MLXSW_REG_CWTP_MIN_VALUE);
1823+
mlxsw_reg_cwtp_profile_max_set(payload, i,
1824+
MLXSW_REG_CWTP_MIN_VALUE);
1825+
}
1826+
}
1827+
1828+
#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
1829+
1830+
static inline void
1831+
mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
1832+
u32 probability)
1833+
{
1834+
u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
1835+
1836+
mlxsw_reg_cwtp_profile_min_set(payload, index, min);
1837+
mlxsw_reg_cwtp_profile_max_set(payload, index, max);
1838+
mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
1839+
}
1840+
1841+
/* CWTPM - Congestion WRED ECN TClass and Pool Mapping
1842+
* ---------------------------------------------------
1843+
* The CWTPM register maps each egress port and traffic class to profile num.
1844+
*/
1845+
#define MLXSW_REG_CWTPM_ID 0x2803
1846+
#define MLXSW_REG_CWTPM_LEN 0x44
1847+
1848+
MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
1849+
1850+
/* reg_cwtpm_local_port
1851+
* Local port number
1852+
* Not supported for CPU port
1853+
* Access: Index
1854+
*/
1855+
MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
1856+
1857+
/* reg_cwtpm_traffic_class
1858+
* Traffic Class to configure
1859+
* Access: Index
1860+
*/
1861+
MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
1862+
1863+
/* reg_cwtpm_ew
1864+
* Control enablement of WRED for traffic class:
1865+
* 0 - Disable
1866+
* 1 - Enable
1867+
* Access: RW
1868+
*/
1869+
MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
1870+
1871+
/* reg_cwtpm_ee
1872+
* Control enablement of ECN for traffic class:
1873+
* 0 - Disable
1874+
* 1 - Enable
1875+
* Access: RW
1876+
*/
1877+
MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
1878+
1879+
/* reg_cwtpm_tcp_g
1880+
* TCP Green Profile.
1881+
* Index of the profile within {port, traffic class} to use.
1882+
* 0 for disabling both WRED and ECN for this type of traffic.
1883+
* Access: RW
1884+
*/
1885+
MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
1886+
1887+
/* reg_cwtpm_tcp_y
1888+
* TCP Yellow Profile.
1889+
* Index of the profile within {port, traffic class} to use.
1890+
* 0 for disabling both WRED and ECN for this type of traffic.
1891+
* Access: RW
1892+
*/
1893+
MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
1894+
1895+
/* reg_cwtpm_tcp_r
1896+
* TCP Red Profile.
1897+
* Index of the profile within {port, traffic class} to use.
1898+
* 0 for disabling both WRED and ECN for this type of traffic.
1899+
* Access: RW
1900+
*/
1901+
MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
1902+
1903+
/* reg_cwtpm_ntcp_g
1904+
* Non-TCP Green Profile.
1905+
* Index of the profile within {port, traffic class} to use.
1906+
* 0 for disabling both WRED and ECN for this type of traffic.
1907+
* Access: RW
1908+
*/
1909+
MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
1910+
1911+
/* reg_cwtpm_ntcp_y
1912+
* Non-TCP Yellow Profile.
1913+
* Index of the profile within {port, traffic class} to use.
1914+
* 0 for disabling both WRED and ECN for this type of traffic.
1915+
* Access: RW
1916+
*/
1917+
MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
1918+
1919+
/* reg_cwtpm_ntcp_r
1920+
* Non-TCP Red Profile.
1921+
* Index of the profile within {port, traffic class} to use.
1922+
* 0 for disabling both WRED and ECN for this type of traffic.
1923+
* Access: RW
1924+
*/
1925+
MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
1926+
1927+
#define MLXSW_REG_CWTPM_RESET_PROFILE 0
1928+
1929+
static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
1930+
u8 traffic_class, u8 profile,
1931+
bool wred, bool ecn)
1932+
{
1933+
MLXSW_REG_ZERO(cwtpm, payload);
1934+
mlxsw_reg_cwtpm_local_port_set(payload, local_port);
1935+
mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
1936+
mlxsw_reg_cwtpm_ew_set(payload, wred);
1937+
mlxsw_reg_cwtpm_ee_set(payload, ecn);
1938+
mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
1939+
mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
1940+
mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
1941+
mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
1942+
mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
1943+
mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
1944+
}
1945+
17611946
/* PPBT - Policy-Engine Port Binding Table
17621947
* ---------------------------------------
17631948
* This register is used for configuration of the Port Binding Table.
@@ -7405,6 +7590,8 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
74057590
MLXSW_REG(svpe),
74067591
MLXSW_REG(sfmr),
74077592
MLXSW_REG(spvmlr),
7593+
MLXSW_REG(cwtp),
7594+
MLXSW_REG(cwtpm),
74087595
MLXSW_REG(ppbt),
74097596
MLXSW_REG(pacl),
74107597
MLXSW_REG(pagt),

0 commit comments

Comments
 (0)