Skip to content

Commit e059436

Browse files
jpirkodavem330
authored andcommitted
mlxsw: reg: Add shared buffer configuration registers definitions
Add definitions of SBPR, SBCM, SBPM, SBMM and PBMC registers that are used to configure shared buffers. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b2e345f commit e059436

File tree

1 file changed

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

1 file changed

+349
-0
lines changed

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

Lines changed: 349 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,82 @@ static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port)
14181418
mlxsw_reg_ppcnt_prio_tc_set(payload, 0);
14191419
}
14201420

1421+
/* PBMC - Port Buffer Management Control Register
1422+
* ----------------------------------------------
1423+
* The PBMC register configures and retrieves the port packet buffer
1424+
* allocation for different Prios, and the Pause threshold management.
1425+
*/
1426+
#define MLXSW_REG_PBMC_ID 0x500C
1427+
#define MLXSW_REG_PBMC_LEN 0x68
1428+
1429+
static const struct mlxsw_reg_info mlxsw_reg_pbmc = {
1430+
.id = MLXSW_REG_PBMC_ID,
1431+
.len = MLXSW_REG_PBMC_LEN,
1432+
};
1433+
1434+
/* reg_pbmc_local_port
1435+
* Local port number.
1436+
* Access: Index
1437+
*/
1438+
MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
1439+
1440+
/* reg_pbmc_xoff_timer_value
1441+
* When device generates a pause frame, it uses this value as the pause
1442+
* timer (time for the peer port to pause in quota-512 bit time).
1443+
* Access: RW
1444+
*/
1445+
MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
1446+
1447+
/* reg_pbmc_xoff_refresh
1448+
* The time before a new pause frame should be sent to refresh the pause RW
1449+
* state. Using the same units as xoff_timer_value above (in quota-512 bit
1450+
* time).
1451+
* Access: RW
1452+
*/
1453+
MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
1454+
1455+
/* reg_pbmc_buf_lossy
1456+
* The field indicates if the buffer is lossy.
1457+
* 0 - Lossless
1458+
* 1 - Lossy
1459+
* Access: RW
1460+
*/
1461+
MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
1462+
1463+
/* reg_pbmc_buf_epsb
1464+
* Eligible for Port Shared buffer.
1465+
* If epsb is set, packets assigned to buffer are allowed to insert the port
1466+
* shared buffer.
1467+
* When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
1468+
* Access: RW
1469+
*/
1470+
MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
1471+
1472+
/* reg_pbmc_buf_size
1473+
* The part of the packet buffer array is allocated for the specific buffer.
1474+
* Units are represented in cells.
1475+
* Access: RW
1476+
*/
1477+
MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
1478+
1479+
static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
1480+
u16 xoff_timer_value, u16 xoff_refresh)
1481+
{
1482+
MLXSW_REG_ZERO(pbmc, payload);
1483+
mlxsw_reg_pbmc_local_port_set(payload, local_port);
1484+
mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
1485+
mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
1486+
}
1487+
1488+
static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
1489+
int buf_index,
1490+
u16 size)
1491+
{
1492+
mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
1493+
mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
1494+
mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
1495+
}
1496+
14211497
/* PSPA - Port Switch Partition Allocation
14221498
* ---------------------------------------
14231499
* Controls the association of a port with a switch partition and enables
@@ -1697,6 +1773,269 @@ static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id)
16971773
mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT);
16981774
}
16991775

1776+
/* SBPR - Shared Buffer Pools Register
1777+
* -----------------------------------
1778+
* The SBPR configures and retrieves the shared buffer pools and configuration.
1779+
*/
1780+
#define MLXSW_REG_SBPR_ID 0xB001
1781+
#define MLXSW_REG_SBPR_LEN 0x14
1782+
1783+
static const struct mlxsw_reg_info mlxsw_reg_sbpr = {
1784+
.id = MLXSW_REG_SBPR_ID,
1785+
.len = MLXSW_REG_SBPR_LEN,
1786+
};
1787+
1788+
enum mlxsw_reg_sbpr_dir {
1789+
MLXSW_REG_SBPR_DIR_INGRESS,
1790+
MLXSW_REG_SBPR_DIR_EGRESS,
1791+
};
1792+
1793+
/* reg_sbpr_dir
1794+
* Direction.
1795+
* Access: Index
1796+
*/
1797+
MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
1798+
1799+
/* reg_sbpr_pool
1800+
* Pool index.
1801+
* Access: Index
1802+
*/
1803+
MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
1804+
1805+
/* reg_sbpr_size
1806+
* Pool size in buffer cells.
1807+
* Access: RW
1808+
*/
1809+
MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
1810+
1811+
enum mlxsw_reg_sbpr_mode {
1812+
MLXSW_REG_SBPR_MODE_STATIC,
1813+
MLXSW_REG_SBPR_MODE_DYNAMIC,
1814+
};
1815+
1816+
/* reg_sbpr_mode
1817+
* Pool quota calculation mode.
1818+
* Access: RW
1819+
*/
1820+
MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
1821+
1822+
static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
1823+
enum mlxsw_reg_sbpr_dir dir,
1824+
enum mlxsw_reg_sbpr_mode mode, u32 size)
1825+
{
1826+
MLXSW_REG_ZERO(sbpr, payload);
1827+
mlxsw_reg_sbpr_pool_set(payload, pool);
1828+
mlxsw_reg_sbpr_dir_set(payload, dir);
1829+
mlxsw_reg_sbpr_mode_set(payload, mode);
1830+
mlxsw_reg_sbpr_size_set(payload, size);
1831+
}
1832+
1833+
/* SBCM - Shared Buffer Class Management Register
1834+
* ----------------------------------------------
1835+
* The SBCM register configures and retrieves the shared buffer allocation
1836+
* and configuration according to Port-PG, including the binding to pool
1837+
* and definition of the associated quota.
1838+
*/
1839+
#define MLXSW_REG_SBCM_ID 0xB002
1840+
#define MLXSW_REG_SBCM_LEN 0x28
1841+
1842+
static const struct mlxsw_reg_info mlxsw_reg_sbcm = {
1843+
.id = MLXSW_REG_SBCM_ID,
1844+
.len = MLXSW_REG_SBCM_LEN,
1845+
};
1846+
1847+
/* reg_sbcm_local_port
1848+
* Local port number.
1849+
* For Ingress: excludes CPU port and Router port
1850+
* For Egress: excludes IP Router
1851+
* Access: Index
1852+
*/
1853+
MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
1854+
1855+
/* reg_sbcm_pg_buff
1856+
* PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
1857+
* For PG buffer: range is 0..cap_max_pg_buffers - 1
1858+
* For traffic class: range is 0..cap_max_tclass - 1
1859+
* Note that when traffic class is in MC aware mode then the traffic
1860+
* classes which are MC aware cannot be configured.
1861+
* Access: Index
1862+
*/
1863+
MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
1864+
1865+
enum mlxsw_reg_sbcm_dir {
1866+
MLXSW_REG_SBCM_DIR_INGRESS,
1867+
MLXSW_REG_SBCM_DIR_EGRESS,
1868+
};
1869+
1870+
/* reg_sbcm_dir
1871+
* Direction.
1872+
* Access: Index
1873+
*/
1874+
MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
1875+
1876+
/* reg_sbcm_min_buff
1877+
* Minimum buffer size for the limiter, in cells.
1878+
* Access: RW
1879+
*/
1880+
MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
1881+
1882+
/* reg_sbcm_max_buff
1883+
* When the pool associated to the port-pg/tclass is configured to
1884+
* static, Maximum buffer size for the limiter configured in cells.
1885+
* When the pool associated to the port-pg/tclass is configured to
1886+
* dynamic, the max_buff holds the "alpha" parameter, supporting
1887+
* the following values:
1888+
* 0: 0
1889+
* i: (1/128)*2^(i-1), for i=1..14
1890+
* 0xFF: Infinity
1891+
* Access: RW
1892+
*/
1893+
MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
1894+
1895+
/* reg_sbcm_pool
1896+
* Association of the port-priority to a pool.
1897+
* Access: RW
1898+
*/
1899+
MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
1900+
1901+
static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
1902+
enum mlxsw_reg_sbcm_dir dir,
1903+
u32 min_buff, u32 max_buff, u8 pool)
1904+
{
1905+
MLXSW_REG_ZERO(sbcm, payload);
1906+
mlxsw_reg_sbcm_local_port_set(payload, local_port);
1907+
mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
1908+
mlxsw_reg_sbcm_dir_set(payload, dir);
1909+
mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
1910+
mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
1911+
mlxsw_reg_sbcm_pool_set(payload, pool);
1912+
}
1913+
1914+
/* SBPM - Shared Buffer Class Management Register
1915+
* ----------------------------------------------
1916+
* The SBPM register configures and retrieves the shared buffer allocation
1917+
* and configuration according to Port-Pool, including the definition
1918+
* of the associated quota.
1919+
*/
1920+
#define MLXSW_REG_SBPM_ID 0xB003
1921+
#define MLXSW_REG_SBPM_LEN 0x28
1922+
1923+
static const struct mlxsw_reg_info mlxsw_reg_sbpm = {
1924+
.id = MLXSW_REG_SBPM_ID,
1925+
.len = MLXSW_REG_SBPM_LEN,
1926+
};
1927+
1928+
/* reg_sbpm_local_port
1929+
* Local port number.
1930+
* For Ingress: excludes CPU port and Router port
1931+
* For Egress: excludes IP Router
1932+
* Access: Index
1933+
*/
1934+
MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
1935+
1936+
/* reg_sbpm_pool
1937+
* The pool associated to quota counting on the local_port.
1938+
* Access: Index
1939+
*/
1940+
MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
1941+
1942+
enum mlxsw_reg_sbpm_dir {
1943+
MLXSW_REG_SBPM_DIR_INGRESS,
1944+
MLXSW_REG_SBPM_DIR_EGRESS,
1945+
};
1946+
1947+
/* reg_sbpm_dir
1948+
* Direction.
1949+
* Access: Index
1950+
*/
1951+
MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
1952+
1953+
/* reg_sbpm_min_buff
1954+
* Minimum buffer size for the limiter, in cells.
1955+
* Access: RW
1956+
*/
1957+
MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
1958+
1959+
/* reg_sbpm_max_buff
1960+
* When the pool associated to the port-pg/tclass is configured to
1961+
* static, Maximum buffer size for the limiter configured in cells.
1962+
* When the pool associated to the port-pg/tclass is configured to
1963+
* dynamic, the max_buff holds the "alpha" parameter, supporting
1964+
* the following values:
1965+
* 0: 0
1966+
* i: (1/128)*2^(i-1), for i=1..14
1967+
* 0xFF: Infinity
1968+
* Access: RW
1969+
*/
1970+
MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
1971+
1972+
static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
1973+
enum mlxsw_reg_sbpm_dir dir,
1974+
u32 min_buff, u32 max_buff)
1975+
{
1976+
MLXSW_REG_ZERO(sbpm, payload);
1977+
mlxsw_reg_sbpm_local_port_set(payload, local_port);
1978+
mlxsw_reg_sbpm_pool_set(payload, pool);
1979+
mlxsw_reg_sbpm_dir_set(payload, dir);
1980+
mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
1981+
mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
1982+
}
1983+
1984+
/* SBMM - Shared Buffer Multicast Management Register
1985+
* --------------------------------------------------
1986+
* The SBMM register configures and retrieves the shared buffer allocation
1987+
* and configuration for MC packets according to Switch-Priority, including
1988+
* the binding to pool and definition of the associated quota.
1989+
*/
1990+
#define MLXSW_REG_SBMM_ID 0xB004
1991+
#define MLXSW_REG_SBMM_LEN 0x28
1992+
1993+
static const struct mlxsw_reg_info mlxsw_reg_sbmm = {
1994+
.id = MLXSW_REG_SBMM_ID,
1995+
.len = MLXSW_REG_SBMM_LEN,
1996+
};
1997+
1998+
/* reg_sbmm_prio
1999+
* Switch Priority.
2000+
* Access: Index
2001+
*/
2002+
MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
2003+
2004+
/* reg_sbmm_min_buff
2005+
* Minimum buffer size for the limiter, in cells.
2006+
* Access: RW
2007+
*/
2008+
MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
2009+
2010+
/* reg_sbmm_max_buff
2011+
* When the pool associated to the port-pg/tclass is configured to
2012+
* static, Maximum buffer size for the limiter configured in cells.
2013+
* When the pool associated to the port-pg/tclass is configured to
2014+
* dynamic, the max_buff holds the "alpha" parameter, supporting
2015+
* the following values:
2016+
* 0: 0
2017+
* i: (1/128)*2^(i-1), for i=1..14
2018+
* 0xFF: Infinity
2019+
* Access: RW
2020+
*/
2021+
MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
2022+
2023+
/* reg_sbmm_pool
2024+
* Association of the port-priority to a pool.
2025+
* Access: RW
2026+
*/
2027+
MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
2028+
2029+
static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
2030+
u32 max_buff, u8 pool)
2031+
{
2032+
MLXSW_REG_ZERO(sbmm, payload);
2033+
mlxsw_reg_sbmm_prio_set(payload, prio);
2034+
mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
2035+
mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
2036+
mlxsw_reg_sbmm_pool_set(payload, pool);
2037+
}
2038+
17002039
static inline const char *mlxsw_reg_id_str(u16 reg_id)
17012040
{
17022041
switch (reg_id) {
@@ -1734,12 +2073,22 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
17342073
return "PAOS";
17352074
case MLXSW_REG_PPCNT_ID:
17362075
return "PPCNT";
2076+
case MLXSW_REG_PBMC_ID:
2077+
return "PBMC";
17372078
case MLXSW_REG_PSPA_ID:
17382079
return "PSPA";
17392080
case MLXSW_REG_HTGT_ID:
17402081
return "HTGT";
17412082
case MLXSW_REG_HPKT_ID:
17422083
return "HPKT";
2084+
case MLXSW_REG_SBPR_ID:
2085+
return "SBPR";
2086+
case MLXSW_REG_SBCM_ID:
2087+
return "SBCM";
2088+
case MLXSW_REG_SBPM_ID:
2089+
return "SBPM";
2090+
case MLXSW_REG_SBMM_ID:
2091+
return "SBMM";
17432092
default:
17442093
return "*UNKNOWN*";
17452094
}

0 commit comments

Comments
 (0)