ixgbe_model.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. int (*val)(struct ixgbe_fdir_filter *input,
  33. union ixgbe_atr_input *mask,
  34. u32 val, u32 m);
  35. unsigned int type;
  36. };
  37. struct ixgbe_jump_table {
  38. struct ixgbe_mat_field *mat;
  39. struct ixgbe_fdir_filter *input;
  40. union ixgbe_atr_input *mask;
  41. u32 link_hdl;
  42. unsigned long child_loc_map[32];
  43. };
  44. #define IXGBE_MAX_HW_ENTRIES 2045
  45. static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
  46. union ixgbe_atr_input *mask,
  47. u32 val, u32 m)
  48. {
  49. input->filter.formatted.src_ip[0] = val;
  50. mask->formatted.src_ip[0] = m;
  51. return 0;
  52. }
  53. static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
  54. union ixgbe_atr_input *mask,
  55. u32 val, u32 m)
  56. {
  57. input->filter.formatted.dst_ip[0] = val;
  58. mask->formatted.dst_ip[0] = m;
  59. return 0;
  60. }
  61. static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
  62. { .off = 12, .val = ixgbe_mat_prgm_sip,
  63. .type = IXGBE_ATR_FLOW_TYPE_IPV4},
  64. { .off = 16, .val = ixgbe_mat_prgm_dip,
  65. .type = IXGBE_ATR_FLOW_TYPE_IPV4},
  66. { .val = NULL } /* terminal node */
  67. };
  68. static inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input,
  69. union ixgbe_atr_input *mask,
  70. u32 val, u32 m)
  71. {
  72. input->filter.formatted.src_port = val & 0xffff;
  73. mask->formatted.src_port = m & 0xffff;
  74. input->filter.formatted.dst_port = val >> 16;
  75. mask->formatted.dst_port = m >> 16;
  76. return 0;
  77. };
  78. static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
  79. {.off = 0, .val = ixgbe_mat_prgm_ports,
  80. .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
  81. { .val = NULL } /* terminal node */
  82. };
  83. static struct ixgbe_mat_field ixgbe_udp_fields[] = {
  84. {.off = 0, .val = ixgbe_mat_prgm_ports,
  85. .type = IXGBE_ATR_FLOW_TYPE_UDPV4},
  86. { .val = NULL } /* terminal node */
  87. };
  88. struct ixgbe_nexthdr {
  89. /* offset, shift, and mask of position to next header */
  90. unsigned int o;
  91. u32 s;
  92. u32 m;
  93. /* match criteria to make this jump*/
  94. unsigned int off;
  95. u32 val;
  96. u32 mask;
  97. /* location of jump to make */
  98. struct ixgbe_mat_field *jump;
  99. };
  100. static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
  101. { .o = 0, .s = 6, .m = 0xf,
  102. .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
  103. { .o = 0, .s = 6, .m = 0xf,
  104. .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields},
  105. { .jump = NULL } /* terminal node */
  106. };
  107. #endif /* _IXGBE_MODEL_H_ */