diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2010-12-07 14:11:26 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2010-12-07 14:11:26 -0500 |
commit | c39d35ebffeea5996a6f8fd8430fae9acfb8aeaf (patch) | |
tree | af09ac5b15429b41d4b5c54fd63c1ac769d67b39 /drivers/net/sfc/filter.h | |
parent | 8891681af928f1da795cd4bd59043e5e0fadd6c8 (diff) |
sfc: Generalise filter spec initialisation
Move search_depth arrays into per-table state.
Define initialisation function efx_filter_init_rx() which sets
everything apart from the match fields.
Define efx_filter_set_{ipv4_local,ipv4_full,eth_local}() to set the
match fields. This allows some simplification of callers and later
support for additional protocols and more flexible matching using
multiple calls to these functions.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/sfc/filter.h')
-rw-r--r-- | drivers/net/sfc/filter.h | 143 |
1 files changed, 36 insertions, 107 deletions
diff --git a/drivers/net/sfc/filter.h b/drivers/net/sfc/filter.h index d11e4aa7813..872f2132a49 100644 --- a/drivers/net/sfc/filter.h +++ b/drivers/net/sfc/filter.h | |||
@@ -14,23 +14,25 @@ | |||
14 | 14 | ||
15 | /** | 15 | /** |
16 | * enum efx_filter_type - type of hardware filter | 16 | * enum efx_filter_type - type of hardware filter |
17 | * @EFX_FILTER_RX_TCP_FULL: RX, matching TCP/IPv4 4-tuple | 17 | * @EFX_FILTER_TCP_FULL: Matching TCP/IPv4 4-tuple |
18 | * @EFX_FILTER_RX_TCP_WILD: RX, matching TCP/IPv4 destination (host, port) | 18 | * @EFX_FILTER_TCP_WILD: Matching TCP/IPv4 destination (host, port) |
19 | * @EFX_FILTER_RX_UDP_FULL: RX, matching UDP/IPv4 4-tuple | 19 | * @EFX_FILTER_UDP_FULL: Matching UDP/IPv4 4-tuple |
20 | * @EFX_FILTER_RX_UDP_WILD: RX, matching UDP/IPv4 destination (host, port) | 20 | * @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port) |
21 | * @EFX_FILTER_RX_MAC_FULL: RX, matching Ethernet destination MAC address, VID | 21 | * @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID |
22 | * @EFX_FILTER_RX_MAC_WILD: RX, matching Ethernet destination MAC address | 22 | * @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address |
23 | * @EFX_FILTER_UNSPEC: Match type is unspecified | ||
23 | * | 24 | * |
24 | * Falcon NICs only support the RX TCP/IPv4 and UDP/IPv4 filter types. | 25 | * Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types. |
25 | */ | 26 | */ |
26 | enum efx_filter_type { | 27 | enum efx_filter_type { |
27 | EFX_FILTER_RX_TCP_FULL = 0, | 28 | EFX_FILTER_TCP_FULL = 0, |
28 | EFX_FILTER_RX_TCP_WILD, | 29 | EFX_FILTER_TCP_WILD, |
29 | EFX_FILTER_RX_UDP_FULL, | 30 | EFX_FILTER_UDP_FULL, |
30 | EFX_FILTER_RX_UDP_WILD, | 31 | EFX_FILTER_UDP_WILD, |
31 | EFX_FILTER_RX_MAC_FULL = 4, | 32 | EFX_FILTER_MAC_FULL = 4, |
32 | EFX_FILTER_RX_MAC_WILD, | 33 | EFX_FILTER_MAC_WILD, |
33 | EFX_FILTER_TYPE_COUNT, | 34 | EFX_FILTER_TYPE_COUNT, /* number of specific types */ |
35 | EFX_FILTER_UNSPEC = 0xf, | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | /** | 38 | /** |
@@ -57,13 +59,13 @@ enum efx_filter_priority { | |||
57 | * @EFX_FILTER_FLAG_RX_OVERRIDE_IP: Enables a MAC filter to override | 59 | * @EFX_FILTER_FLAG_RX_OVERRIDE_IP: Enables a MAC filter to override |
58 | * any IP filter that matches the same packet. By default, IP | 60 | * any IP filter that matches the same packet. By default, IP |
59 | * filters take precedence. | 61 | * filters take precedence. |
60 | * | 62 | * @EFX_FILTER_FLAG_RX: Filter is for RX |
61 | * Currently, no flags are defined for TX filters. | ||
62 | */ | 63 | */ |
63 | enum efx_filter_flags { | 64 | enum efx_filter_flags { |
64 | EFX_FILTER_FLAG_RX_RSS = 0x01, | 65 | EFX_FILTER_FLAG_RX_RSS = 0x01, |
65 | EFX_FILTER_FLAG_RX_SCATTER = 0x02, | 66 | EFX_FILTER_FLAG_RX_SCATTER = 0x02, |
66 | EFX_FILTER_FLAG_RX_OVERRIDE_IP = 0x04, | 67 | EFX_FILTER_FLAG_RX_OVERRIDE_IP = 0x04, |
68 | EFX_FILTER_FLAG_RX = 0x08, | ||
67 | }; | 69 | }; |
68 | 70 | ||
69 | /** | 71 | /** |
@@ -85,99 +87,26 @@ struct efx_filter_spec { | |||
85 | u32 data[3]; | 87 | u32 data[3]; |
86 | }; | 88 | }; |
87 | 89 | ||
88 | /** | 90 | static inline void efx_filter_init_rx(struct efx_filter_spec *spec, |
89 | * efx_filter_set_rx_tcp_full - specify RX filter with TCP/IPv4 full match | 91 | enum efx_filter_priority priority, |
90 | * @spec: Specification to initialise | 92 | enum efx_filter_flags flags, |
91 | * @shost: Source host address (host byte order) | 93 | unsigned rxq_id) |
92 | * @sport: Source port (host byte order) | ||
93 | * @dhost: Destination host address (host byte order) | ||
94 | * @dport: Destination port (host byte order) | ||
95 | */ | ||
96 | static inline void | ||
97 | efx_filter_set_rx_tcp_full(struct efx_filter_spec *spec, | ||
98 | u32 shost, u16 sport, u32 dhost, u16 dport) | ||
99 | { | ||
100 | spec->type = EFX_FILTER_RX_TCP_FULL; | ||
101 | spec->data[0] = sport | shost << 16; | ||
102 | spec->data[1] = dport << 16 | shost >> 16; | ||
103 | spec->data[2] = dhost; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * efx_filter_set_rx_tcp_wild - specify RX filter with TCP/IPv4 wildcard match | ||
108 | * @spec: Specification to initialise | ||
109 | * @dhost: Destination host address (host byte order) | ||
110 | * @dport: Destination port (host byte order) | ||
111 | */ | ||
112 | static inline void | ||
113 | efx_filter_set_rx_tcp_wild(struct efx_filter_spec *spec, u32 dhost, u16 dport) | ||
114 | { | ||
115 | spec->type = EFX_FILTER_RX_TCP_WILD; | ||
116 | spec->data[0] = 0; | ||
117 | spec->data[1] = dport << 16; | ||
118 | spec->data[2] = dhost; | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * efx_filter_set_rx_udp_full - specify RX filter with UDP/IPv4 full match | ||
123 | * @spec: Specification to initialise | ||
124 | * @shost: Source host address (host byte order) | ||
125 | * @sport: Source port (host byte order) | ||
126 | * @dhost: Destination host address (host byte order) | ||
127 | * @dport: Destination port (host byte order) | ||
128 | */ | ||
129 | static inline void | ||
130 | efx_filter_set_rx_udp_full(struct efx_filter_spec *spec, | ||
131 | u32 shost, u16 sport, u32 dhost, u16 dport) | ||
132 | { | ||
133 | spec->type = EFX_FILTER_RX_UDP_FULL; | ||
134 | spec->data[0] = sport | shost << 16; | ||
135 | spec->data[1] = dport << 16 | shost >> 16; | ||
136 | spec->data[2] = dhost; | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * efx_filter_set_rx_udp_wild - specify RX filter with UDP/IPv4 wildcard match | ||
141 | * @spec: Specification to initialise | ||
142 | * @dhost: Destination host address (host byte order) | ||
143 | * @dport: Destination port (host byte order) | ||
144 | */ | ||
145 | static inline void | ||
146 | efx_filter_set_rx_udp_wild(struct efx_filter_spec *spec, u32 dhost, u16 dport) | ||
147 | { | ||
148 | spec->type = EFX_FILTER_RX_UDP_WILD; | ||
149 | spec->data[0] = dport; | ||
150 | spec->data[1] = 0; | ||
151 | spec->data[2] = dhost; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * efx_filter_set_rx_mac_full - specify RX filter with MAC full match | ||
156 | * @spec: Specification to initialise | ||
157 | * @vid: VLAN ID | ||
158 | * @addr: Destination MAC address | ||
159 | */ | ||
160 | static inline void efx_filter_set_rx_mac_full(struct efx_filter_spec *spec, | ||
161 | u16 vid, const u8 *addr) | ||
162 | { | 94 | { |
163 | spec->type = EFX_FILTER_RX_MAC_FULL; | 95 | spec->type = EFX_FILTER_UNSPEC; |
164 | spec->data[0] = vid; | 96 | spec->priority = priority; |
165 | spec->data[1] = addr[2] << 24 | addr[3] << 16 | addr[4] << 8 | addr[5]; | 97 | spec->flags = EFX_FILTER_FLAG_RX | flags; |
166 | spec->data[2] = addr[0] << 8 | addr[1]; | 98 | spec->dmaq_id = rxq_id; |
167 | } | 99 | } |
168 | 100 | ||
169 | /** | 101 | extern int efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto, |
170 | * efx_filter_set_rx_mac_full - specify RX filter with MAC wildcard match | 102 | __be32 host, __be16 port); |
171 | * @spec: Specification to initialise | 103 | extern int efx_filter_set_ipv4_full(struct efx_filter_spec *spec, u8 proto, |
172 | * @addr: Destination MAC address | 104 | __be32 host, __be16 port, |
173 | */ | 105 | __be32 rhost, __be16 rport); |
174 | static inline void efx_filter_set_rx_mac_wild(struct efx_filter_spec *spec, | 106 | extern int efx_filter_set_eth_local(struct efx_filter_spec *spec, |
175 | const u8 *addr) | 107 | u16 vid, const u8 *addr); |
176 | { | 108 | enum { |
177 | spec->type = EFX_FILTER_RX_MAC_WILD; | 109 | EFX_FILTER_VID_UNSPEC = 0xffff, |
178 | spec->data[0] = 0; | 110 | }; |
179 | spec->data[1] = addr[2] << 24 | addr[3] << 16 | addr[4] << 8 | addr[5]; | ||
180 | spec->data[2] = addr[0] << 8 | addr[1]; | ||
181 | } | ||
182 | 111 | ||
183 | #endif /* EFX_FILTER_H */ | 112 | #endif /* EFX_FILTER_H */ |