Skip to content

Commit

Permalink
sfc: Limit filter search depth further for performance hints (i.e. RFS)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
  • Loading branch information
Ben Hutchings committed Feb 16, 2011
1 parent 69a19ee commit d472605
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/net/sfc/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
*/
#define FILTER_CTL_SRCH_MAX 200

/* Don't try very hard to find space for performance hints, as this is
* counter-productive. */
#define FILTER_CTL_SRCH_HINT_MAX 5

enum efx_filter_table_id {
EFX_FILTER_TABLE_RX_IP = 0,
EFX_FILTER_TABLE_RX_MAC,
Expand Down Expand Up @@ -325,15 +329,16 @@ static int efx_filter_search(struct efx_filter_table *table,
struct efx_filter_spec *spec, u32 key,
bool for_insert, int *depth_required)
{
unsigned hash, incr, filter_idx, depth;
unsigned hash, incr, filter_idx, depth, depth_max;
struct efx_filter_spec *cmp;

hash = efx_filter_hash(key);
incr = efx_filter_increment(key);
depth_max = (spec->priority <= EFX_FILTER_PRI_HINT ?
FILTER_CTL_SRCH_HINT_MAX : FILTER_CTL_SRCH_MAX);

for (depth = 1, filter_idx = hash & (table->size - 1);
depth <= FILTER_CTL_SRCH_MAX &&
test_bit(filter_idx, table->used_bitmap);
depth <= depth_max && test_bit(filter_idx, table->used_bitmap);
++depth) {
cmp = &table->spec[filter_idx];
if (efx_filter_equal(spec, cmp))
Expand All @@ -342,7 +347,7 @@ static int efx_filter_search(struct efx_filter_table *table,
}
if (!for_insert)
return -ENOENT;
if (depth > FILTER_CTL_SRCH_MAX)
if (depth > depth_max)
return -EBUSY;
found:
*depth_required = depth;
Expand Down

0 comments on commit d472605

Please sign in to comment.