• Vladimir Oltean's avatar
    net: mscc: ocelot: configure watermarks using devlink-sb · f59fd9ca
    Vladimir Oltean authored
    Using devlink-sb, we can configure 12/16 (the important 75%) of the
    switch's controlling watermarks for congestion drops, and we can monitor
    50% of the watermark occupancies (we can monitor the reservation
    watermarks, but not the sharing watermarks, which are exposed as pool
    sizes).
    
    The following definitions can be made:
    
    SB_BUF=0 # The devlink-sb for frame buffers
    SB_REF=1 # The devlink-sb for frame references
    POOL_ING=0 # The pool for ingress traffic. Both devlink-sb instances
               # have one of these.
    POOL_EGR=1 # The pool for egress traffic. Both devlink-sb instances
               # have one of these.
    
    Editing the hardware watermarks is done in the following way:
    BUF_xxxx_I is accessed when sb=$SB_BUF and pool=$POOL_ING
    REF_xxxx_I is accessed when sb=$SB_REF and pool=$POOL_ING
    BUF_xxxx_E is accessed when sb=$SB_BUF and pool=$POOL_EGR
    REF_xxxx_E is accessed when sb=$SB_REF and pool=$POOL_EGR
    
    Configuring the sharing watermarks for COL_SHR(dp=0) is done implicitly
    by modifying the corresponding pool size. By default, the pool size has
    maximum size, so this can be skipped.
    
    devlink sb pool set pci/0000:00:00.5 sb $SB_BUF pool $POOL_ING \
    	size 129840 thtype static
    
    Since by default there is no buffer reservation, the above command has
    maxed out BUF_COL_SHR_I(dp=0).
    
    Configuring the per-port reservation watermark (P_RSRV) is done in the
    following way:
    
    devlink sb port pool set pci/0000:00:00.5/0 sb $SB_BUF \
    	pool $POOL_ING th 1000
    
    The above command sets BUF_P_RSRV_I(port 0) to 1000 bytes. After this
    command, the sharing watermarks are internally reconfigured with 1000
    bytes less, i.e. from 129840 bytes to 128840 bytes.
    
    Configuring the per-port-tc reservation watermarks (Q_RSRV) is done in
    the following way:
    
    for tc in {0..7}; do
    	devlink sb tc bind set pci/0000:00:00.5/0 sb 0 tc $tc \
    		type ingress pool $POOL_ING \
    		th 3000
    done
    
    The above command sets BUF_Q_RSRV_I(port 0, tc 0..7) to 3000 bytes.
    The sharing watermarks are again reconfigured with 24000 bytes less.
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    f59fd9ca
ocelot.h 24 KB