diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2012-08-24 15:12:20 -0400 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2012-10-01 20:58:42 -0400 |
commit | 6ac7ef1487a040483d89a95045efc5185a71268f (patch) | |
tree | 4543fbc8a4ac5f7c823337f15642898e2f5ac881 /drivers/net/ethernet/sfc | |
parent | 9e0f9a10576a7769869ce1f76f5b336da20667a6 (diff) |
sfc: Fix the reported priorities of different filter types
Each RX filter table contains filters with two different levels of
specificity: TCP/IPv4 and UDP/IPv4 filters match the local address and
port and optionally the remote address and port; Ethernet filters
match the local address and optionally the VID. The more specific
filters always override less specific filters within the same table,
and should be numbered accordingly.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc')
-rw-r--r-- | drivers/net/ethernet/sfc/filter.c | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/drivers/net/ethernet/sfc/filter.c b/drivers/net/ethernet/sfc/filter.c index e89bad78312e..8af42cd1feda 100644 --- a/drivers/net/ethernet/sfc/filter.c +++ b/drivers/net/ethernet/sfc/filter.c | |||
@@ -557,26 +557,62 @@ static int efx_filter_search(struct efx_filter_table *table, | |||
557 | } | 557 | } |
558 | 558 | ||
559 | /* | 559 | /* |
560 | * Construct/deconstruct external filter IDs. These must be ordered | 560 | * Construct/deconstruct external filter IDs. At least the RX filter |
561 | * by matching priority, for RX NFC semantics. | 561 | * IDs must be ordered by matching priority, for RX NFC semantics. |
562 | * | ||
563 | * Deconstruction needs to be robust against invalid IDs so that | ||
564 | * efx_filter_remove_id_safe() and efx_filter_get_filter_safe() can | ||
565 | * accept user-provided IDs. | ||
562 | */ | 566 | */ |
563 | 567 | ||
568 | #define EFX_FILTER_MATCH_PRI_COUNT 5 | ||
569 | |||
570 | static const u8 efx_filter_type_match_pri[EFX_FILTER_TYPE_COUNT] = { | ||
571 | [EFX_FILTER_TCP_FULL] = 0, | ||
572 | [EFX_FILTER_UDP_FULL] = 0, | ||
573 | [EFX_FILTER_TCP_WILD] = 1, | ||
574 | [EFX_FILTER_UDP_WILD] = 1, | ||
575 | [EFX_FILTER_MAC_FULL] = 2, | ||
576 | [EFX_FILTER_MAC_WILD] = 3, | ||
577 | [EFX_FILTER_UC_DEF] = 4, | ||
578 | [EFX_FILTER_MC_DEF] = 4, | ||
579 | }; | ||
580 | |||
581 | static const enum efx_filter_table_id efx_filter_range_table[] = { | ||
582 | EFX_FILTER_TABLE_RX_IP, /* RX match pri 0 */ | ||
583 | EFX_FILTER_TABLE_RX_IP, | ||
584 | EFX_FILTER_TABLE_RX_MAC, | ||
585 | EFX_FILTER_TABLE_RX_MAC, | ||
586 | EFX_FILTER_TABLE_RX_DEF, /* RX match pri 4 */ | ||
587 | EFX_FILTER_TABLE_COUNT, /* TX match pri 0; invalid */ | ||
588 | EFX_FILTER_TABLE_COUNT, /* invalid */ | ||
589 | EFX_FILTER_TABLE_TX_MAC, | ||
590 | EFX_FILTER_TABLE_TX_MAC, /* TX match pri 3 */ | ||
591 | }; | ||
592 | |||
564 | #define EFX_FILTER_INDEX_WIDTH 13 | 593 | #define EFX_FILTER_INDEX_WIDTH 13 |
565 | #define EFX_FILTER_INDEX_MASK ((1 << EFX_FILTER_INDEX_WIDTH) - 1) | 594 | #define EFX_FILTER_INDEX_MASK ((1 << EFX_FILTER_INDEX_WIDTH) - 1) |
566 | 595 | ||
567 | static inline u32 efx_filter_make_id(enum efx_filter_table_id table_id, | 596 | static inline u32 |
568 | unsigned int index, u8 flags) | 597 | efx_filter_make_id(const struct efx_filter_spec *spec, unsigned int index) |
569 | { | 598 | { |
570 | unsigned int match_pri = table_id; | 599 | unsigned int range; |
600 | |||
601 | range = efx_filter_type_match_pri[spec->type]; | ||
602 | if (!(spec->flags & EFX_FILTER_FLAG_RX)) | ||
603 | range += EFX_FILTER_MATCH_PRI_COUNT; | ||
571 | 604 | ||
572 | return match_pri << EFX_FILTER_INDEX_WIDTH | index; | 605 | return range << EFX_FILTER_INDEX_WIDTH | index; |
573 | } | 606 | } |
574 | 607 | ||
575 | static inline enum efx_filter_table_id efx_filter_id_table_id(u32 id) | 608 | static inline enum efx_filter_table_id efx_filter_id_table_id(u32 id) |
576 | { | 609 | { |
577 | unsigned int match_pri = id >> EFX_FILTER_INDEX_WIDTH; | 610 | unsigned int range = id >> EFX_FILTER_INDEX_WIDTH; |
578 | 611 | ||
579 | return match_pri; | 612 | if (range < ARRAY_SIZE(efx_filter_range_table)) |
613 | return efx_filter_range_table[range]; | ||
614 | else | ||
615 | return EFX_FILTER_TABLE_COUNT; /* invalid */ | ||
580 | } | 616 | } |
581 | 617 | ||
582 | static inline unsigned int efx_filter_id_index(u32 id) | 618 | static inline unsigned int efx_filter_id_index(u32 id) |
@@ -586,9 +622,9 @@ static inline unsigned int efx_filter_id_index(u32 id) | |||
586 | 622 | ||
587 | static inline u8 efx_filter_id_flags(u32 id) | 623 | static inline u8 efx_filter_id_flags(u32 id) |
588 | { | 624 | { |
589 | unsigned int match_pri = id >> EFX_FILTER_INDEX_WIDTH; | 625 | unsigned int range = id >> EFX_FILTER_INDEX_WIDTH; |
590 | 626 | ||
591 | if (match_pri <= EFX_FILTER_TABLE_RX_DEF) | 627 | if (range < EFX_FILTER_MATCH_PRI_COUNT) |
592 | return EFX_FILTER_FLAG_RX; | 628 | return EFX_FILTER_FLAG_RX; |
593 | else | 629 | else |
594 | return EFX_FILTER_FLAG_TX; | 630 | return EFX_FILTER_FLAG_TX; |
@@ -597,13 +633,15 @@ static inline u8 efx_filter_id_flags(u32 id) | |||
597 | u32 efx_filter_get_rx_id_limit(struct efx_nic *efx) | 633 | u32 efx_filter_get_rx_id_limit(struct efx_nic *efx) |
598 | { | 634 | { |
599 | struct efx_filter_state *state = efx->filter_state; | 635 | struct efx_filter_state *state = efx->filter_state; |
600 | unsigned int table_id = EFX_FILTER_TABLE_RX_DEF; | 636 | unsigned int range = EFX_FILTER_MATCH_PRI_COUNT - 1; |
637 | enum efx_filter_table_id table_id; | ||
601 | 638 | ||
602 | do { | 639 | do { |
640 | table_id = efx_filter_range_table[range]; | ||
603 | if (state->table[table_id].size != 0) | 641 | if (state->table[table_id].size != 0) |
604 | return (table_id << EFX_FILTER_INDEX_WIDTH) + | 642 | return range << EFX_FILTER_INDEX_WIDTH | |
605 | state->table[table_id].size; | 643 | state->table[table_id].size; |
606 | } while (table_id--); | 644 | } while (range--); |
607 | 645 | ||
608 | return 0; | 646 | return 0; |
609 | } | 647 | } |
@@ -681,7 +719,7 @@ s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, | |||
681 | netif_vdbg(efx, hw, efx->net_dev, | 719 | netif_vdbg(efx, hw, efx->net_dev, |
682 | "%s: filter type %d index %d rxq %u set", | 720 | "%s: filter type %d index %d rxq %u set", |
683 | __func__, spec->type, filter_idx, spec->dmaq_id); | 721 | __func__, spec->type, filter_idx, spec->dmaq_id); |
684 | rc = efx_filter_make_id(table->id, filter_idx, spec->flags); | 722 | rc = efx_filter_make_id(spec, filter_idx); |
685 | 723 | ||
686 | out: | 724 | out: |
687 | spin_unlock_bh(&state->lock); | 725 | spin_unlock_bh(&state->lock); |
@@ -888,8 +926,7 @@ s32 efx_filter_get_rx_ids(struct efx_nic *efx, | |||
888 | goto out; | 926 | goto out; |
889 | } | 927 | } |
890 | buf[count++] = efx_filter_make_id( | 928 | buf[count++] = efx_filter_make_id( |
891 | table_id, filter_idx, | 929 | &table->spec[filter_idx], filter_idx); |
892 | table->spec[filter_idx].flags); | ||
893 | } | 930 | } |
894 | } | 931 | } |
895 | } | 932 | } |