• Ivan Khoronzhuk's avatar
    net: ethernet: ti: cpsw: add CBS Qdisc offload · 57d90148
    Ivan Khoronzhuk authored
    The cpsw has up to 4 FIFOs per port and upper 3 FIFOs can feed rate
    limited queue with shaping. In order to set and enable shaping for
    those 3 FIFOs queues the network device with CBS qdisc attached is
    needed. The CBS configuration is added for dual-emac/single port mode
    only, but potentially can be used in switch mode also, based on
    switchdev for instance.
    
    Despite the FIFO shapers can work w/o cpdma level shapers the base
    usage must be in combine with cpdma level shapers as described in TRM,
    that are set as maximum rates for interface queues with sysfs.
    
    One of the possible configuration with txq shapers and CBS shapers:
    
                          Configured with echo RATE >
                      /sys/class/net/eth0/queues/tx-0/tx_maxrate
                 /---------------------------------------------------
                /
               /            cpdma level shapers
            +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+
            | c7 | | c6 | | c5 | | c4 | | c3 | | c2 | | c1 | | c0 |
            \    / \    / \    / \    / \    / \    / \    / \    /
             \  /   \  /   \  /   \  /   \  /   \  /   \  /   \  /
              \/     \/     \/     \/     \/     \/     \/     \/
    +---------|------|------|------|-------------------------------------+
    |    +----+      |      |  +---+                                     |
    |    |      +----+      |  |                                         |
    |    v      v           v  v                                         |
    | +----+ +----+ +----+ +----+ p        p+----+ +----+ +----+ +----+  |
    | |    | |    | |    | |    | o        o|    | |    | |    | |    |  |
    | | f3 | | f2 | | f1 | | f0 | r  CPSW  r| f3 | | f2 | | f1 | | f0 |  |
    | |    | |    | |    | |    | t        t|    | |    | |    | |    |  |
    | \    / \    / \    / \    / 0        1\    / \    / \    / \    /  |
    |  \  X   \  /   \  /   \  /             \  /   \  /   \  /   \  /   |
    |   \/ \   \/     \/     \/               \/     \/     \/     \/    |
    +-------\------------------------------------------------------------+
             \
              \ FIFO shaper, set with CBS offload added in this patch,
               \ FIFO0 cannot be rate limited
                ------------------------------------------------------
    
    CBS shaper configuration is supposed to be used with root MQPRIO Qdisc
    offload allowing to add sk_prio->tc->txq maps that direct traffic to
    appropriate tx queue and maps L2 priority to FIFO shaper.
    
    The CBS shaper is intended to be used for AVB where L2 priority
    (pcp field) is used to differentiate class of traffic. So additionally
    vlan needs to be created with appropriate egress sk_prio->l2 prio map.
    
    If CBS has several tx queues assigned to it, the sum of their
    bandwidth has not overlap bandwidth set for CBS. It's recomended the
    CBS bandwidth to be a little bit more.
    
    The CBS shaper is configured with CBS qdisc offload interface using tc
    tool from iproute2 packet.
    
    For instance:
    
    $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
    map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
    
    $ tc -g class show dev eth0
    +---(100:ffe2) mqprio
    |    +---(100:3) mqprio
    |    +---(100:4) mqprio
    |    
    +---(100:ffe1) mqprio
    |    +---(100:2) mqprio
    |    
    +---(100:ffe0) mqprio
         +---(100:1) mqprio
    
    $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1440 \
    hicredit 60 sendslope -960000 idleslope 40000 offload 1
    
    $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \
    hicredit 62 sendslope -980000 idleslope 20000 offload 1
    
    The above code set CBS shapers for tc0 and tc1, for that txq0 and
    txq1 is used. Pay attention, the real set bandwidth can differ a bit
    due to discreteness of configuration parameters.
    
    Here parameters like locredit, hicredit and sendslope are ignored
    internally and are supposed to be set with assumption that maximum
    frame size for frame - 1500.
    
    It's supposed that interface speed is not changed while reconnection,
    not always is true, so inform user in case speed of interface was
    changed, as it can impact on dependent shapers configuration.
    
    For more examples see Documentation.
    Reviewed-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
    Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
    Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    57d90148
cpsw.c 95.9 KB