• Jon Cooper's avatar
    sfc: fix filter_id misinterpretation in edge case · 0ccb998b
    Jon Cooper authored
    On EF10, hardware filter IDs are 13 bits, but in some places we store
     32-bit "full filter IDs" in which higher order bits encode the filter
     match-priority.  This could cause a filter to have a full filter ID of
     0xffff, which is also the value EFX_EF10_FILTER_ID_INVALID which we use
     in 16-bit "short" filter IDs (without match-priority bits).  This would
     occur if the hardware filter ID was 0x1fff and the match-priority was 7.
    Unfortunately, some code that checks for EFX_EF10_FILTER_ID_INVALID can
     be called on full filter IDs, and will WARN_ON if this ever happens.
    So, since we have plenty of spare bits in the full filter ID, this patch
     shifts the priority bits left one bit when constructing the full filter
     IDs, ensuring that the 0x2000 bit of a full filter ID will always be 0
     and thus no full filter ID can ever equal EFX_EF10_FILTER_ID_INVALID.
    
    This patch also replaces open-coded full<->short filter ID conversions
     with calls to functions, thus keeping the definition of the full filter
     ID format in one place.
    Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    0ccb998b
ef10.c 193 KB