• Arun Ramadoss's avatar
    net: dsa: microchip: add support for credit based shaper · 71d7920f
    Arun Ramadoss authored
    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: default avatarArun Ramadoss <arun.ramadoss@microchip.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    71d7920f
ksz_common.c 88.4 KB