ixgbe_model.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 1999 - 2018 Intel Corporation. */
  3. #ifndef _IXGBE_MODEL_H_
  4. #define _IXGBE_MODEL_H_
  5. #include "ixgbe.h"
  6. #include "ixgbe_type.h"
  7. struct ixgbe_mat_field {
  8. unsigned int off;
  9. int (*val)(struct ixgbe_fdir_filter *input,
  10. union ixgbe_atr_input *mask,
  11. u32 val, u32 m);
  12. unsigned int type;
  13. };
  14. struct ixgbe_jump_table {
  15. struct ixgbe_mat_field *mat;
  16. struct ixgbe_fdir_filter *input;
  17. union ixgbe_atr_input *mask;
  18. u32 link_hdl;
  19. unsigned long child_loc_map[32];
  20. };
  21. #define IXGBE_MAX_HW_ENTRIES 2045
  22. static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
  23. union ixgbe_atr_input *mask,
  24. u32 val, u32 m)
  25. {
  26. input->filter.formatted.src_ip[0] = (__force __be32)val;
  27. mask->formatted.src_ip[0] = (__force __be32)m;
  28. return 0;
  29. }
  30. static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
  31. union ixgbe_atr_input *mask,
  32. u32 val, u32 m)
  33. {
  34. input->filter.formatted.dst_ip[0] = (__force __be32)val;
  35. mask->formatted.dst_ip[0] = (__force __be32)m;
  36. return 0;
  37. }
  38. static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
  39. { .off = 12, .val = ixgbe_mat_prgm_sip,
  40. .type = IXGBE_ATR_FLOW_TYPE_IPV4},
  41. { .off = 16, .val = ixgbe_mat_prgm_dip,
  42. .type = IXGBE_ATR_FLOW_TYPE_IPV4},
  43. { .val = NULL } /* terminal node */
  44. };
  45. static inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input,
  46. union ixgbe_atr_input *mask,
  47. u32 val, u32 m)
  48. {
  49. input->filter.formatted.src_port = (__force __be16)(val & 0xffff);
  50. mask->formatted.src_port = (__force __be16)(m & 0xffff);
  51. input->filter.formatted.dst_port = (__force __be16)(val >> 16);
  52. mask->formatted.dst_port = (__force __be16)(m >> 16);
  53. return 0;
  54. };
  55. static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
  56. {.off = 0, .val = ixgbe_mat_prgm_ports,
  57. .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
  58. { .val = NULL } /* terminal node */
  59. };
  60. static struct ixgbe_mat_field ixgbe_udp_fields[] = {
  61. {.off = 0, .val = ixgbe_mat_prgm_ports,
  62. .type = IXGBE_ATR_FLOW_TYPE_UDPV4},
  63. { .val = NULL } /* terminal node */
  64. };
  65. struct ixgbe_nexthdr {
  66. /* offset, shift, and mask of position to next header */
  67. unsigned int o;
  68. u32 s;
  69. u32 m;
  70. /* match criteria to make this jump*/
  71. unsigned int off;
  72. u32 val;
  73. u32 mask;
  74. /* location of jump to make */
  75. struct ixgbe_mat_field *jump;
  76. };
  77. static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
  78. { .o = 0, .s = 6, .m = 0xf,
  79. .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
  80. { .o = 0, .s = 6, .m = 0xf,
  81. .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields},
  82. { .jump = NULL } /* terminal node */
  83. };
  84. #endif /* _IXGBE_MODEL_H_ */