1 /****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2010 Solarflare Communications Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
13 #include <linux/types.h>
16 * enum efx_filter_type - type of hardware filter
17 * @EFX_FILTER_TCP_FULL: Matching TCP/IPv4 4-tuple
18 * @EFX_FILTER_TCP_WILD: Matching TCP/IPv4 destination (host, port)
19 * @EFX_FILTER_UDP_FULL: Matching UDP/IPv4 4-tuple
20 * @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port)
21 * @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID
22 * @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address
23 * @EFX_FILTER_UC_DEF: Matching all otherwise unmatched unicast
24 * @EFX_FILTER_MC_DEF: Matching all otherwise unmatched multicast
25 * @EFX_FILTER_UNSPEC: Match type is unspecified
27 * Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types.
29 enum efx_filter_type
{
30 EFX_FILTER_TCP_FULL
= 0,
34 EFX_FILTER_MAC_FULL
= 4,
36 EFX_FILTER_UC_DEF
= 8,
38 EFX_FILTER_TYPE_COUNT
, /* number of specific types */
39 EFX_FILTER_UNSPEC
= 0xf,
43 * enum efx_filter_priority - priority of a hardware filter specification
44 * @EFX_FILTER_PRI_HINT: Performance hint
45 * @EFX_FILTER_PRI_MANUAL: Manually configured filter
46 * @EFX_FILTER_PRI_REQUIRED: Required for correct behaviour (user-level
47 * networking and SR-IOV)
49 enum efx_filter_priority
{
50 EFX_FILTER_PRI_HINT
= 0,
51 EFX_FILTER_PRI_MANUAL
,
52 EFX_FILTER_PRI_REQUIRED
,
56 * enum efx_filter_flags - flags for hardware filter specifications
57 * @EFX_FILTER_FLAG_RX_RSS: Use RSS to spread across multiple queues.
58 * By default, matching packets will be delivered only to the
59 * specified queue. If this flag is set, they will be delivered
60 * to a range of queues offset from the specified queue number
61 * according to the indirection table.
62 * @EFX_FILTER_FLAG_RX_SCATTER: Enable DMA scatter on the receiving
64 * @EFX_FILTER_FLAG_RX: Filter is for RX
65 * @EFX_FILTER_FLAG_TX: Filter is for TX
67 enum efx_filter_flags
{
68 EFX_FILTER_FLAG_RX_RSS
= 0x01,
69 EFX_FILTER_FLAG_RX_SCATTER
= 0x02,
70 EFX_FILTER_FLAG_RX
= 0x08,
71 EFX_FILTER_FLAG_TX
= 0x10,
75 * struct efx_filter_spec - specification for a hardware filter
76 * @type: Type of match to be performed, from &enum efx_filter_type
77 * @priority: Priority of the filter, from &enum efx_filter_priority
78 * @flags: Miscellaneous flags, from &enum efx_filter_flags
79 * @dmaq_id: Source/target queue index
80 * @data: Match data (type-dependent)
82 * Use the efx_filter_set_*() functions to initialise the @type and
85 * The @priority field is used by software to determine whether a new
86 * filter may replace an old one. The hardware priority of a filter
87 * depends on the filter type.
89 struct efx_filter_spec
{
97 static inline void efx_filter_init_rx(struct efx_filter_spec
*spec
,
98 enum efx_filter_priority priority
,
99 enum efx_filter_flags flags
,
102 spec
->type
= EFX_FILTER_UNSPEC
;
103 spec
->priority
= priority
;
104 spec
->flags
= EFX_FILTER_FLAG_RX
| flags
;
105 spec
->dmaq_id
= rxq_id
;
108 static inline void efx_filter_init_tx(struct efx_filter_spec
*spec
,
111 spec
->type
= EFX_FILTER_UNSPEC
;
112 spec
->priority
= EFX_FILTER_PRI_REQUIRED
;
113 spec
->flags
= EFX_FILTER_FLAG_TX
;
114 spec
->dmaq_id
= txq_id
;
117 extern int efx_filter_set_ipv4_local(struct efx_filter_spec
*spec
, u8 proto
,
118 __be32 host
, __be16 port
);
119 extern int efx_filter_get_ipv4_local(const struct efx_filter_spec
*spec
,
120 u8
*proto
, __be32
*host
, __be16
*port
);
121 extern int efx_filter_set_ipv4_full(struct efx_filter_spec
*spec
, u8 proto
,
122 __be32 host
, __be16 port
,
123 __be32 rhost
, __be16 rport
);
124 extern int efx_filter_get_ipv4_full(const struct efx_filter_spec
*spec
,
125 u8
*proto
, __be32
*host
, __be16
*port
,
126 __be32
*rhost
, __be16
*rport
);
127 extern int efx_filter_set_eth_local(struct efx_filter_spec
*spec
,
128 u16 vid
, const u8
*addr
);
129 extern int efx_filter_get_eth_local(const struct efx_filter_spec
*spec
,
131 extern int efx_filter_set_uc_def(struct efx_filter_spec
*spec
);
132 extern int efx_filter_set_mc_def(struct efx_filter_spec
*spec
);
134 EFX_FILTER_VID_UNSPEC
= 0xffff,
137 #endif /* EFX_FILTER_H */