diff options
| author | Arun Ramadoss <arun.ramadoss@microchip.com> | 2023-01-20 10:51:35 +0530 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2023-01-23 22:12:35 -0800 |
| commit | 71d7920fb2d1d6cdaa6db58426783be02c9cb7bb (patch) | |
| tree | 8443658cd4f29cf001d0cd936855b662f449f8f8 /drivers/net/dsa/microchip/lan937x_reg.h | |
| parent | e30f33a5f5c74f278feaa57517d851874dfc640f (diff) | |
| download | linux-71d7920fb2d1d6cdaa6db58426783be02c9cb7bb.tar.gz linux-71d7920fb2d1d6cdaa6db58426783be02c9cb7bb.tar.bz2 linux-71d7920fb2d1d6cdaa6db58426783be02c9cb7bb.zip | |
net: dsa: microchip: add support for credit based shaper
KSZ9477, KSZ9567, KSZ9563, KSZ8563 and LAN937x supports Credit based
shaper. To differentiate the chip supporting cbs, tc_cbs_supported
flag is introduced in ksz_chip_data.
And KSZ series has 16bit Credit increment registers whereas LAN937x has
24bit register. The value to be programmed in the credit increment is
determined using the successive multiplication method to convert decimal
fraction to hexadecimal fraction.
For example: if idleslope is 10000 and sendslope is -90000, then
bandwidth is 10000 - (-90000) = 100000.
The 10% bandwidth of 100Mbps means 10/100 = 0.1(decimal). This value has
to be converted to hexa.
1) 0.1 * 16 = 1.6 --> fraction 0.6 Carry = 1 (MSB)
2) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9
3) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9
4) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9
5) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9
6) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9 (LSB)
Now 0.1(decimal) becomes 0.199999(Hex).
If it is LAN937x, 24 bit value will be programmed to Credit Inc
register, 0x199999. For others 16 bit value will be prgrammed, 0x1999.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/dsa/microchip/lan937x_reg.h')
| -rw-r--r-- | drivers/net/dsa/microchip/lan937x_reg.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/dsa/microchip/lan937x_reg.h b/drivers/net/dsa/microchip/lan937x_reg.h index 5bc16a4c4441..45b606b6429f 100644 --- a/drivers/net/dsa/microchip/lan937x_reg.h +++ b/drivers/net/dsa/microchip/lan937x_reg.h @@ -185,6 +185,9 @@ #define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL +/* 9 - Shaping */ +#define REG_PORT_MTI_CREDIT_INCREMENT 0x091C + /* The port number as per the datasheet */ #define RGMII_2_PORT_NUM 5 #define RGMII_1_PORT_NUM 6 |
