aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2010-12-07 14:02:27 -0500
committerBen Hutchings <bhutchings@solarflare.com>2010-12-07 14:02:50 -0500
commit8891681af928f1da795cd4bd59043e5e0fadd6c8 (patch)
tree11a1d55774d82ffd2694ce68cea103b8416323ba
parentac33ac610dc613b2b1c938f8b61eef651ab72563 (diff)
sfc: Remove filter table IDs from filter functions
The separation between filter tables is largely an internal detail and it may be removed in future hardware. To prepare for that: - Merge table ID with filter index to make an opaque filter ID - Wrap efx_filter_table_clear() with a function that clears filters from both RX tables, which is all that the current caller requires Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r--drivers/net/sfc/efx.h5
-rw-r--r--drivers/net/sfc/ethtool.c8
-rw-r--r--drivers/net/sfc/filter.c40
-rw-r--r--drivers/net/sfc/filter.h6
4 files changed, 34 insertions, 25 deletions
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
index 10a1bf40da96..003fdb35b4bb 100644
--- a/drivers/net/sfc/efx.h
+++ b/drivers/net/sfc/efx.h
@@ -74,9 +74,8 @@ extern int efx_filter_insert_filter(struct efx_nic *efx,
74 bool replace); 74 bool replace);
75extern int efx_filter_remove_filter(struct efx_nic *efx, 75extern int efx_filter_remove_filter(struct efx_nic *efx,
76 struct efx_filter_spec *spec); 76 struct efx_filter_spec *spec);
77extern void efx_filter_table_clear(struct efx_nic *efx, 77extern void efx_filter_clear_rx(struct efx_nic *efx,
78 enum efx_filter_table_id table_id, 78 enum efx_filter_priority priority);
79 enum efx_filter_priority priority);
80 79
81/* Channels */ 80/* Channels */
82extern void efx_process_channel_now(struct efx_channel *channel); 81extern void efx_process_channel_now(struct efx_channel *channel);
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index d51a6b1f4766..0f46c1a3171e 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -558,12 +558,8 @@ static int efx_ethtool_set_flags(struct net_device *net_dev, u32 data)
558 if (rc) 558 if (rc)
559 return rc; 559 return rc;
560 560
561 if (!(data & ETH_FLAG_NTUPLE)) { 561 if (!(data & ETH_FLAG_NTUPLE))
562 efx_filter_table_clear(efx, EFX_FILTER_TABLE_RX_IP, 562 efx_filter_clear_rx(efx, EFX_FILTER_PRI_MANUAL);
563 EFX_FILTER_PRI_MANUAL);
564 efx_filter_table_clear(efx, EFX_FILTER_TABLE_RX_MAC,
565 EFX_FILTER_PRI_MANUAL);
566 }
567 563
568 return 0; 564 return 0;
569} 565}
diff --git a/drivers/net/sfc/filter.c b/drivers/net/sfc/filter.c
index 44500b54fd5f..e96e6e852f16 100644
--- a/drivers/net/sfc/filter.c
+++ b/drivers/net/sfc/filter.c
@@ -26,6 +26,12 @@
26 */ 26 */
27#define FILTER_CTL_SRCH_MAX 200 27#define FILTER_CTL_SRCH_MAX 200
28 28
29enum efx_filter_table_id {
30 EFX_FILTER_TABLE_RX_IP = 0,
31 EFX_FILTER_TABLE_RX_MAC,
32 EFX_FILTER_TABLE_COUNT,
33};
34
29struct efx_filter_table { 35struct efx_filter_table {
30 u32 offset; /* address of table relative to BAR */ 36 u32 offset; /* address of table relative to BAR */
31 unsigned size; /* number of entries */ 37 unsigned size; /* number of entries */
@@ -206,6 +212,14 @@ found:
206 return filter_idx; 212 return filter_idx;
207} 213}
208 214
215/* Construct/deconstruct external filter IDs */
216
217static inline int
218efx_filter_make_id(enum efx_filter_table_id table_id, unsigned index)
219{
220 return table_id << 16 | index;
221}
222
209/** 223/**
210 * efx_filter_insert_filter - add or replace a filter 224 * efx_filter_insert_filter - add or replace a filter
211 * @efx: NIC in which to insert the filter 225 * @efx: NIC in which to insert the filter
@@ -213,7 +227,7 @@ found:
213 * @replace: Flag for whether the specified filter may replace a filter 227 * @replace: Flag for whether the specified filter may replace a filter
214 * with an identical match expression and equal or lower priority 228 * with an identical match expression and equal or lower priority
215 * 229 *
216 * On success, return the filter index within its table. 230 * On success, return the filter ID.
217 * On failure, return a negative error code. 231 * On failure, return a negative error code.
218 */ 232 */
219int efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, 233int efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec,
@@ -273,6 +287,7 @@ int efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec,
273 netif_vdbg(efx, hw, efx->net_dev, 287 netif_vdbg(efx, hw, efx->net_dev,
274 "%s: filter type %d index %d rxq %u set", 288 "%s: filter type %d index %d rxq %u set",
275 __func__, spec->type, filter_idx, spec->dmaq_id); 289 __func__, spec->type, filter_idx, spec->dmaq_id);
290 rc = efx_filter_make_id(table_id, filter_idx);
276 291
277out: 292out:
278 spin_unlock_bh(&state->lock); 293 spin_unlock_bh(&state->lock);
@@ -340,15 +355,9 @@ out:
340 return rc; 355 return rc;
341} 356}
342 357
343/** 358static void efx_filter_table_clear(struct efx_nic *efx,
344 * efx_filter_table_clear - remove filters from a table by priority 359 enum efx_filter_table_id table_id,
345 * @efx: NIC from which to remove the filters 360 enum efx_filter_priority priority)
346 * @table_id: Table from which to remove the filters
347 * @priority: Maximum priority to remove
348 */
349void efx_filter_table_clear(struct efx_nic *efx,
350 enum efx_filter_table_id table_id,
351 enum efx_filter_priority priority)
352{ 361{
353 struct efx_filter_state *state = efx->filter_state; 362 struct efx_filter_state *state = efx->filter_state;
354 struct efx_filter_table *table = &state->table[table_id]; 363 struct efx_filter_table *table = &state->table[table_id];
@@ -365,6 +374,17 @@ void efx_filter_table_clear(struct efx_nic *efx,
365 spin_unlock_bh(&state->lock); 374 spin_unlock_bh(&state->lock);
366} 375}
367 376
377/**
378 * efx_filter_clear_rx - remove RX filters by priority
379 * @efx: NIC from which to remove the filters
380 * @priority: Maximum priority to remove
381 */
382void efx_filter_clear_rx(struct efx_nic *efx, enum efx_filter_priority priority)
383{
384 efx_filter_table_clear(efx, EFX_FILTER_TABLE_RX_IP, priority);
385 efx_filter_table_clear(efx, EFX_FILTER_TABLE_RX_MAC, priority);
386}
387
368/* Restore filter stater after reset */ 388/* Restore filter stater after reset */
369void efx_restore_filters(struct efx_nic *efx) 389void efx_restore_filters(struct efx_nic *efx)
370{ 390{
diff --git a/drivers/net/sfc/filter.h b/drivers/net/sfc/filter.h
index a53319ded79c..d11e4aa78133 100644
--- a/drivers/net/sfc/filter.h
+++ b/drivers/net/sfc/filter.h
@@ -12,12 +12,6 @@
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14 14
15enum efx_filter_table_id {
16 EFX_FILTER_TABLE_RX_IP = 0,
17 EFX_FILTER_TABLE_RX_MAC,
18 EFX_FILTER_TABLE_COUNT,
19};
20
21/** 15/**
22 * enum efx_filter_type - type of hardware filter 16 * enum efx_filter_type - type of hardware filter
23 * @EFX_FILTER_RX_TCP_FULL: RX, matching TCP/IPv4 4-tuple 17 * @EFX_FILTER_RX_TCP_FULL: RX, matching TCP/IPv4 4-tuple