Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.37-rc5 189 lines 6.0 kB view raw
1/**************************************************************************** 2 * Driver for Solarflare Solarstorm network controllers and boards 3 * Copyright 2005-2010 Solarflare Communications Inc. 4 * 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. 8 */ 9 10#ifndef EFX_FILTER_H 11#define EFX_FILTER_H 12 13#include <linux/types.h> 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/** 22 * enum efx_filter_type - type of hardware filter 23 * @EFX_FILTER_RX_TCP_FULL: RX, matching TCP/IPv4 4-tuple 24 * @EFX_FILTER_RX_TCP_WILD: RX, matching TCP/IPv4 destination (host, port) 25 * @EFX_FILTER_RX_UDP_FULL: RX, matching UDP/IPv4 4-tuple 26 * @EFX_FILTER_RX_UDP_WILD: RX, matching UDP/IPv4 destination (host, port) 27 * @EFX_FILTER_RX_MAC_FULL: RX, matching Ethernet destination MAC address, VID 28 * @EFX_FILTER_RX_MAC_WILD: RX, matching Ethernet destination MAC address 29 * 30 * Falcon NICs only support the RX TCP/IPv4 and UDP/IPv4 filter types. 31 */ 32enum efx_filter_type { 33 EFX_FILTER_RX_TCP_FULL = 0, 34 EFX_FILTER_RX_TCP_WILD, 35 EFX_FILTER_RX_UDP_FULL, 36 EFX_FILTER_RX_UDP_WILD, 37 EFX_FILTER_RX_MAC_FULL = 4, 38 EFX_FILTER_RX_MAC_WILD, 39 EFX_FILTER_TYPE_COUNT, 40}; 41 42/** 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 47 */ 48enum efx_filter_priority { 49 EFX_FILTER_PRI_HINT = 0, 50 EFX_FILTER_PRI_MANUAL, 51 EFX_FILTER_PRI_REQUIRED, 52}; 53 54/** 55 * enum efx_filter_flags - flags for hardware filter specifications 56 * @EFX_FILTER_FLAG_RX_RSS: Use RSS to spread across multiple queues. 57 * By default, matching packets will be delivered only to the 58 * specified queue. If this flag is set, they will be delivered 59 * to a range of queues offset from the specified queue number 60 * according to the indirection table. 61 * @EFX_FILTER_FLAG_RX_SCATTER: Enable DMA scatter on the receiving 62 * queue. 63 * @EFX_FILTER_FLAG_RX_OVERRIDE_IP: Enables a MAC filter to override 64 * any IP filter that matches the same packet. By default, IP 65 * filters take precedence. 66 * 67 * Currently, no flags are defined for TX filters. 68 */ 69enum efx_filter_flags { 70 EFX_FILTER_FLAG_RX_RSS = 0x01, 71 EFX_FILTER_FLAG_RX_SCATTER = 0x02, 72 EFX_FILTER_FLAG_RX_OVERRIDE_IP = 0x04, 73}; 74 75/** 76 * struct efx_filter_spec - specification for a hardware filter 77 * @type: Type of match to be performed, from &enum efx_filter_type 78 * @priority: Priority of the filter, from &enum efx_filter_priority 79 * @flags: Miscellaneous flags, from &enum efx_filter_flags 80 * @dmaq_id: Source/target queue index 81 * @data: Match data (type-dependent) 82 * 83 * Use the efx_filter_set_*() functions to initialise the @type and 84 * @data fields. 85 */ 86struct efx_filter_spec { 87 u8 type:4; 88 u8 priority:4; 89 u8 flags; 90 u16 dmaq_id; 91 u32 data[3]; 92}; 93 94/** 95 * efx_filter_set_rx_tcp_full - specify RX filter with TCP/IPv4 full match 96 * @spec: Specification to initialise 97 * @shost: Source host address (host byte order) 98 * @sport: Source port (host byte order) 99 * @dhost: Destination host address (host byte order) 100 * @dport: Destination port (host byte order) 101 */ 102static inline void 103efx_filter_set_rx_tcp_full(struct efx_filter_spec *spec, 104 u32 shost, u16 sport, u32 dhost, u16 dport) 105{ 106 spec->type = EFX_FILTER_RX_TCP_FULL; 107 spec->data[0] = sport | shost << 16; 108 spec->data[1] = dport << 16 | shost >> 16; 109 spec->data[2] = dhost; 110} 111 112/** 113 * efx_filter_set_rx_tcp_wild - specify RX filter with TCP/IPv4 wildcard match 114 * @spec: Specification to initialise 115 * @dhost: Destination host address (host byte order) 116 * @dport: Destination port (host byte order) 117 */ 118static inline void 119efx_filter_set_rx_tcp_wild(struct efx_filter_spec *spec, u32 dhost, u16 dport) 120{ 121 spec->type = EFX_FILTER_RX_TCP_WILD; 122 spec->data[0] = 0; 123 spec->data[1] = dport << 16; 124 spec->data[2] = dhost; 125} 126 127/** 128 * efx_filter_set_rx_udp_full - specify RX filter with UDP/IPv4 full match 129 * @spec: Specification to initialise 130 * @shost: Source host address (host byte order) 131 * @sport: Source port (host byte order) 132 * @dhost: Destination host address (host byte order) 133 * @dport: Destination port (host byte order) 134 */ 135static inline void 136efx_filter_set_rx_udp_full(struct efx_filter_spec *spec, 137 u32 shost, u16 sport, u32 dhost, u16 dport) 138{ 139 spec->type = EFX_FILTER_RX_UDP_FULL; 140 spec->data[0] = sport | shost << 16; 141 spec->data[1] = dport << 16 | shost >> 16; 142 spec->data[2] = dhost; 143} 144 145/** 146 * efx_filter_set_rx_udp_wild - specify RX filter with UDP/IPv4 wildcard match 147 * @spec: Specification to initialise 148 * @dhost: Destination host address (host byte order) 149 * @dport: Destination port (host byte order) 150 */ 151static inline void 152efx_filter_set_rx_udp_wild(struct efx_filter_spec *spec, u32 dhost, u16 dport) 153{ 154 spec->type = EFX_FILTER_RX_UDP_WILD; 155 spec->data[0] = dport; 156 spec->data[1] = 0; 157 spec->data[2] = dhost; 158} 159 160/** 161 * efx_filter_set_rx_mac_full - specify RX filter with MAC full match 162 * @spec: Specification to initialise 163 * @vid: VLAN ID 164 * @addr: Destination MAC address 165 */ 166static inline void efx_filter_set_rx_mac_full(struct efx_filter_spec *spec, 167 u16 vid, const u8 *addr) 168{ 169 spec->type = EFX_FILTER_RX_MAC_FULL; 170 spec->data[0] = vid; 171 spec->data[1] = addr[2] << 24 | addr[3] << 16 | addr[4] << 8 | addr[5]; 172 spec->data[2] = addr[0] << 8 | addr[1]; 173} 174 175/** 176 * efx_filter_set_rx_mac_full - specify RX filter with MAC wildcard match 177 * @spec: Specification to initialise 178 * @addr: Destination MAC address 179 */ 180static inline void efx_filter_set_rx_mac_wild(struct efx_filter_spec *spec, 181 const u8 *addr) 182{ 183 spec->type = EFX_FILTER_RX_MAC_WILD; 184 spec->data[0] = 0; 185 spec->data[1] = addr[2] << 24 | addr[3] << 16 | addr[4] << 8 | addr[5]; 186 spec->data[2] = addr[0] << 8 | addr[1]; 187} 188 189#endif /* EFX_FILTER_H */