Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 1999 - 2018 Intel Corporation. */
0003 
0004 #ifndef _IXGBE_MODEL_H_
0005 #define _IXGBE_MODEL_H_
0006 
0007 #include "ixgbe.h"
0008 #include "ixgbe_type.h"
0009 
0010 struct ixgbe_mat_field {
0011     unsigned int off;
0012     int (*val)(struct ixgbe_fdir_filter *input,
0013            union ixgbe_atr_input *mask,
0014            u32 val, u32 m);
0015     unsigned int type;
0016 };
0017 
0018 struct ixgbe_jump_table {
0019     struct ixgbe_mat_field *mat;
0020     struct ixgbe_fdir_filter *input;
0021     union ixgbe_atr_input *mask;
0022     u32 link_hdl;
0023     unsigned long child_loc_map[32];
0024 };
0025 
0026 #define IXGBE_MAX_HW_ENTRIES 2045
0027 
0028 static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
0029                      union ixgbe_atr_input *mask,
0030                      u32 val, u32 m)
0031 {
0032     input->filter.formatted.src_ip[0] = (__force __be32)val;
0033     mask->formatted.src_ip[0] = (__force __be32)m;
0034     return 0;
0035 }
0036 
0037 static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
0038                      union ixgbe_atr_input *mask,
0039                      u32 val, u32 m)
0040 {
0041     input->filter.formatted.dst_ip[0] = (__force __be32)val;
0042     mask->formatted.dst_ip[0] = (__force __be32)m;
0043     return 0;
0044 }
0045 
0046 static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
0047     { .off = 12, .val = ixgbe_mat_prgm_sip,
0048       .type = IXGBE_ATR_FLOW_TYPE_IPV4},
0049     { .off = 16, .val = ixgbe_mat_prgm_dip,
0050       .type = IXGBE_ATR_FLOW_TYPE_IPV4},
0051     { .val = NULL } /* terminal node */
0052 };
0053 
0054 static inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input,
0055                        union ixgbe_atr_input *mask,
0056                        u32 val, u32 m)
0057 {
0058     input->filter.formatted.src_port = (__force __be16)(val & 0xffff);
0059     mask->formatted.src_port = (__force __be16)(m & 0xffff);
0060     input->filter.formatted.dst_port = (__force __be16)(val >> 16);
0061     mask->formatted.dst_port = (__force __be16)(m >> 16);
0062 
0063     return 0;
0064 };
0065 
0066 static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
0067     {.off = 0, .val = ixgbe_mat_prgm_ports,
0068      .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
0069     { .val = NULL } /* terminal node */
0070 };
0071 
0072 static struct ixgbe_mat_field ixgbe_udp_fields[] = {
0073     {.off = 0, .val = ixgbe_mat_prgm_ports,
0074      .type = IXGBE_ATR_FLOW_TYPE_UDPV4},
0075     { .val = NULL } /* terminal node */
0076 };
0077 
0078 struct ixgbe_nexthdr {
0079     /* offset, shift, and mask of position to next header */
0080     unsigned int o;
0081     u32 s;
0082     u32 m;
0083     /* match criteria to make this jump*/
0084     unsigned int off;
0085     u32 val;
0086     u32 mask;
0087     /* location of jump to make */
0088     struct ixgbe_mat_field *jump;
0089 };
0090 
0091 static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
0092     { .o = 0, .s = 6, .m = 0xf,
0093       .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
0094     { .o = 0, .s = 6, .m = 0xf,
0095       .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields},
0096     { .jump = NULL } /* terminal node */
0097 };
0098 #endif /* _IXGBE_MODEL_H_ */