filter.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #ifndef EFX_FILTER_H
  10. #define EFX_FILTER_H
  11. #include <linux/types.h>
  12. /**
  13. * enum efx_filter_type - type of hardware filter
  14. * @EFX_FILTER_TCP_FULL: Matching TCP/IPv4 4-tuple
  15. * @EFX_FILTER_TCP_WILD: Matching TCP/IPv4 destination (host, port)
  16. * @EFX_FILTER_UDP_FULL: Matching UDP/IPv4 4-tuple
  17. * @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port)
  18. * @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID
  19. * @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address
  20. * @EFX_FILTER_UNSPEC: Match type is unspecified
  21. *
  22. * Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types.
  23. */
  24. enum efx_filter_type {
  25. EFX_FILTER_TCP_FULL = 0,
  26. EFX_FILTER_TCP_WILD,
  27. EFX_FILTER_UDP_FULL,
  28. EFX_FILTER_UDP_WILD,
  29. EFX_FILTER_MAC_FULL = 4,
  30. EFX_FILTER_MAC_WILD,
  31. EFX_FILTER_TYPE_COUNT, /* number of specific types */
  32. EFX_FILTER_UNSPEC = 0xf,
  33. };
  34. /**
  35. * enum efx_filter_priority - priority of a hardware filter specification
  36. * @EFX_FILTER_PRI_HINT: Performance hint
  37. * @EFX_FILTER_PRI_MANUAL: Manually configured filter
  38. * @EFX_FILTER_PRI_REQUIRED: Required for correct behaviour
  39. */
  40. enum efx_filter_priority {
  41. EFX_FILTER_PRI_HINT = 0,
  42. EFX_FILTER_PRI_MANUAL,
  43. EFX_FILTER_PRI_REQUIRED,
  44. };
  45. /**
  46. * enum efx_filter_flags - flags for hardware filter specifications
  47. * @EFX_FILTER_FLAG_RX_RSS: Use RSS to spread across multiple queues.
  48. * By default, matching packets will be delivered only to the
  49. * specified queue. If this flag is set, they will be delivered
  50. * to a range of queues offset from the specified queue number
  51. * according to the indirection table.
  52. * @EFX_FILTER_FLAG_RX_SCATTER: Enable DMA scatter on the receiving
  53. * queue.
  54. * @EFX_FILTER_FLAG_RX_OVERRIDE_IP: Enables a MAC filter to override
  55. * any IP filter that matches the same packet. By default, IP
  56. * filters take precedence.
  57. * @EFX_FILTER_FLAG_RX: Filter is for RX
  58. */
  59. enum efx_filter_flags {
  60. EFX_FILTER_FLAG_RX_RSS = 0x01,
  61. EFX_FILTER_FLAG_RX_SCATTER = 0x02,
  62. EFX_FILTER_FLAG_RX_OVERRIDE_IP = 0x04,
  63. EFX_FILTER_FLAG_RX = 0x08,
  64. };
  65. /**
  66. * struct efx_filter_spec - specification for a hardware filter
  67. * @type: Type of match to be performed, from &enum efx_filter_type
  68. * @priority: Priority of the filter, from &enum efx_filter_priority
  69. * @flags: Miscellaneous flags, from &enum efx_filter_flags
  70. * @dmaq_id: Source/target queue index
  71. * @data: Match data (type-dependent)
  72. *
  73. * Use the efx_filter_set_*() functions to initialise the @type and
  74. * @data fields.
  75. */
  76. struct efx_filter_spec {
  77. u8 type:4;
  78. u8 priority:4;
  79. u8 flags;
  80. u16 dmaq_id;
  81. u32 data[3];
  82. };
  83. static inline void efx_filter_init_rx(struct efx_filter_spec *spec,
  84. enum efx_filter_priority priority,
  85. enum efx_filter_flags flags,
  86. unsigned rxq_id)
  87. {
  88. spec->type = EFX_FILTER_UNSPEC;
  89. spec->priority = priority;
  90. spec->flags = EFX_FILTER_FLAG_RX | flags;
  91. spec->dmaq_id = rxq_id;
  92. }
  93. extern int efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto,
  94. __be32 host, __be16 port);
  95. extern int efx_filter_set_ipv4_full(struct efx_filter_spec *spec, u8 proto,
  96. __be32 host, __be16 port,
  97. __be32 rhost, __be16 rport);
  98. extern int efx_filter_set_eth_local(struct efx_filter_spec *spec,
  99. u16 vid, const u8 *addr);
  100. enum {
  101. EFX_FILTER_VID_UNSPEC = 0xffff,
  102. };
  103. #endif /* EFX_FILTER_H */