ixgbe_model.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*******************************************************************************
  2. *
  3. * Intel 10 Gigabit PCI Express Linux drive
  4. * Copyright(c) 2016 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #ifndef _IXGBE_MODEL_H_
  27. #define _IXGBE_MODEL_H_
  28. #include "ixgbe.h"
  29. #include "ixgbe_type.h"
  30. struct ixgbe_mat_field {
  31. unsigned int off;
  32. unsigned int mask;
  33. int (*val)(struct ixgbe_fdir_filter *input,
  34. union ixgbe_atr_input *mask,
  35. u32 val, u32 m);
  36. unsigned int type;
  37. };
  38. static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
  39. union ixgbe_atr_input *mask,
  40. u32 val, u32 m)
  41. {
  42. input->filter.formatted.src_ip[0] = val;
  43. mask->formatted.src_ip[0] = m;
  44. return 0;
  45. }
  46. static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
  47. union ixgbe_atr_input *mask,
  48. u32 val, u32 m)
  49. {
  50. input->filter.formatted.dst_ip[0] = val;
  51. mask->formatted.dst_ip[0] = m;
  52. return 0;
  53. }
  54. static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
  55. { .off = 12, .mask = -1, .val = ixgbe_mat_prgm_sip,
  56. .type = IXGBE_ATR_FLOW_TYPE_IPV4},
  57. { .off = 16, .mask = -1, .val = ixgbe_mat_prgm_dip,
  58. .type = IXGBE_ATR_FLOW_TYPE_IPV4},
  59. { .val = NULL } /* terminal node */
  60. };
  61. static inline int ixgbe_mat_prgm_sport(struct ixgbe_fdir_filter *input,
  62. union ixgbe_atr_input *mask,
  63. u32 val, u32 m)
  64. {
  65. input->filter.formatted.src_port = val & 0xffff;
  66. mask->formatted.src_port = m & 0xffff;
  67. return 0;
  68. };
  69. static inline int ixgbe_mat_prgm_dport(struct ixgbe_fdir_filter *input,
  70. union ixgbe_atr_input *mask,
  71. u32 val, u32 m)
  72. {
  73. input->filter.formatted.dst_port = val & 0xffff;
  74. mask->formatted.dst_port = m & 0xffff;
  75. return 0;
  76. };
  77. static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
  78. {.off = 0, .mask = 0xffff, .val = ixgbe_mat_prgm_sport,
  79. .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
  80. {.off = 2, .mask = 0xffff, .val = ixgbe_mat_prgm_dport,
  81. .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
  82. { .val = NULL } /* terminal node */
  83. };
  84. struct ixgbe_nexthdr {
  85. /* offset, shift, and mask of position to next header */
  86. unsigned int o;
  87. u32 s;
  88. u32 m;
  89. /* match criteria to make this jump*/
  90. unsigned int off;
  91. u32 val;
  92. u32 mask;
  93. /* location of jump to make */
  94. struct ixgbe_mat_field *jump;
  95. };
  96. static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
  97. { .o = 0, .s = 6, .m = 0xf,
  98. .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
  99. { .jump = NULL } /* terminal node */
  100. };
  101. #endif /* _IXGBE_MODEL_H_ */