diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2013-01-14 12:43:15 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-03-07 15:21:58 -0500 |
commit | 7de07a4deb8e7707892b952daa59eff67701f0c3 (patch) | |
tree | ccfa987cfc42c51d896e8a6571eaca4148c0966b /drivers/net/ethernet/sfc | |
parent | 97d48a10c670f87bba9e5b2241e32f2eccd3fef0 (diff) |
sfc: More sensible semantics for efx_filter_insert_filter() replace flag
The 'replace' flag to efx_filter_insert_filter() controls whether the
new filter may replace *any* filter, and is checked even before
priority comparison. But lower-priority filters should never
block insertion of higher-priority filters.
Change the priority checking so that lower-priority filters are
replaced regardless of the value of the flag, and rename the
flag to 'replace_equal'.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc')
-rw-r--r-- | drivers/net/ethernet/sfc/filter.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/net/ethernet/sfc/filter.c b/drivers/net/ethernet/sfc/filter.c index 8af42cd1feda..2fdd3a5f21c4 100644 --- a/drivers/net/ethernet/sfc/filter.c +++ b/drivers/net/ethernet/sfc/filter.c | |||
@@ -650,14 +650,22 @@ u32 efx_filter_get_rx_id_limit(struct efx_nic *efx) | |||
650 | * efx_filter_insert_filter - add or replace a filter | 650 | * efx_filter_insert_filter - add or replace a filter |
651 | * @efx: NIC in which to insert the filter | 651 | * @efx: NIC in which to insert the filter |
652 | * @spec: Specification for the filter | 652 | * @spec: Specification for the filter |
653 | * @replace: Flag for whether the specified filter may replace a filter | 653 | * @replace_equal: Flag for whether the specified filter may replace an |
654 | * with an identical match expression and equal or lower priority | 654 | * existing filter with equal priority |
655 | * | 655 | * |
656 | * On success, return the filter ID. | 656 | * On success, return the filter ID. |
657 | * On failure, return a negative error code. | 657 | * On failure, return a negative error code. |
658 | * | ||
659 | * If an existing filter has equal match values to the new filter | ||
660 | * spec, then the new filter might replace it, depending on the | ||
661 | * relative priorities. If the existing filter has lower priority, or | ||
662 | * if @replace_equal is set and it has equal priority, then it is | ||
663 | * replaced. Otherwise the function fails, returning -%EPERM if | ||
664 | * the existing filter has higher priority or -%EEXIST if it has | ||
665 | * equal priority. | ||
658 | */ | 666 | */ |
659 | s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, | 667 | s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, |
660 | bool replace) | 668 | bool replace_equal) |
661 | { | 669 | { |
662 | struct efx_filter_state *state = efx->filter_state; | 670 | struct efx_filter_state *state = efx->filter_state; |
663 | struct efx_filter_table *table = efx_filter_spec_table(state, spec); | 671 | struct efx_filter_table *table = efx_filter_spec_table(state, spec); |
@@ -687,7 +695,7 @@ s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, | |||
687 | 695 | ||
688 | if (test_bit(filter_idx, table->used_bitmap)) { | 696 | if (test_bit(filter_idx, table->used_bitmap)) { |
689 | /* Should we replace the existing filter? */ | 697 | /* Should we replace the existing filter? */ |
690 | if (!replace) { | 698 | if (spec->priority == saved_spec->priority && !replace_equal) { |
691 | rc = -EEXIST; | 699 | rc = -EEXIST; |
692 | goto out; | 700 | goto out; |
693 | } | 701 | } |