• Ido Schimmel's avatar
    mlxsw: spectrum_matchall: Add support for egress sampling · 54d0e963
    Ido Schimmel authored
    Allow user space to install a matchall classifier with sample action on
    egress. This is only supported on Spectrum-2 onwards, so Spectrum-1 will
    continue to return an error.
    
    Programming the hardware to sample on egress is identical to ingress
    sampling with the sole change of using a different sampling trigger.
    
    Upon receiving a sampled packet, the sampling trigger (ingress vs.
    egress) will be encoded in the mirroring reason in the Completion Queue
    Element (CQE). The mirroring reason is used to lookup the sampling
    parameters (e.g., psample group) which are passed to the psample module.
    
    Note that locally generated packets that are sampled are simply
    consumed. This is done for several reasons.
    
    First, such packets do not have an ingress netdev given that their Rx
    local port is the CPU port. This breaks several basic assumptions.
    
    Second, sampling using the same interface (tc), but with flower
    classifier will not result in locally generated packets being sampled
    given that such packets are not subject to the policy engine.
    
    Third, realistically, this is not a big deal given that the vast
    majority of the packets being transmitted through the port are not
    locally generated packets.
    
    Fourth, if such packets do need to be sampled, they can be sampled with
    a 'skip_hw' filter and reported to the same sampling group as the data
    path packets. The software sampling rate can also be adjusted to fit the
    rate of the locally generated packets which is much lower than the rate
    of the data path traffic.
    Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    54d0e963
spectrum_matchall.c 14 KB