ixgbe_model.h 3.5 KB

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