• Ido Schimmel's avatar
    mlxsw: spectrum: Fix incorrect parsing depth after reload · 35c35692
    Ido Schimmel authored
    Spectrum ASICs have a configurable limit on how deep into the packet
    they parse. By default, the limit is 96 bytes.
    
    There are several cases where this parsing depth is not enough and there
    is a need to increase it. For example, timestamping of PTP packets and a
    FIB multipath hash policy that requires hashing on inner fields. The
    driver therefore maintains a reference count that reflects the number of
    consumers that require an increased parsing depth.
    
    During reload_down() the parsing depth reference count does not
    necessarily drop to zero, but the parsing depth itself is restored to
    the default during reload_up() when the firmware is reset. It is
    therefore possible to end up in situations where the driver thinks that
    the parsing depth was increased (reference count is non-zero), when it
    is not.
    
    Fix by making sure that all the consumers that increase the parsing
    depth reference count also decrease it during reload_down().
    Specifically, make sure that when the routing code is de-initialized it
    drops the reference count if it was increased because of a FIB multipath
    hash policy that requires hashing on inner fields.
    
    Add a warning if the reference count is not zero after the driver was
    de-initialized and explicitly reset it to zero during initialization for
    good measures.
    
    Fixes: 2d91f080 ("mlxsw: spectrum: Add infrastructure for parsing configuration")
    Reported-by: default avatarMaksym Yaremchuk <maksymy@nvidia.com>
    Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
    Link: https://lore.kernel.org/r/9c35e1b3e6c1d8f319a2449d14e2b86373f3b3ba.1678727526.git.petrm@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    35c35692
spectrum_router.c 287 KB