162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _IXGBE_MODEL_H_ 562306a36Sopenharmony_ci#define _IXGBE_MODEL_H_ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include "ixgbe.h" 862306a36Sopenharmony_ci#include "ixgbe_type.h" 962306a36Sopenharmony_ci 1062306a36Sopenharmony_cistruct ixgbe_mat_field { 1162306a36Sopenharmony_ci unsigned int off; 1262306a36Sopenharmony_ci int (*val)(struct ixgbe_fdir_filter *input, 1362306a36Sopenharmony_ci union ixgbe_atr_input *mask, 1462306a36Sopenharmony_ci u32 val, u32 m); 1562306a36Sopenharmony_ci unsigned int type; 1662306a36Sopenharmony_ci}; 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_cistruct ixgbe_jump_table { 1962306a36Sopenharmony_ci struct ixgbe_mat_field *mat; 2062306a36Sopenharmony_ci struct ixgbe_fdir_filter *input; 2162306a36Sopenharmony_ci union ixgbe_atr_input *mask; 2262306a36Sopenharmony_ci u32 link_hdl; 2362306a36Sopenharmony_ci unsigned long child_loc_map[32]; 2462306a36Sopenharmony_ci}; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#define IXGBE_MAX_HW_ENTRIES 2045 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistatic inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input, 2962306a36Sopenharmony_ci union ixgbe_atr_input *mask, 3062306a36Sopenharmony_ci u32 val, u32 m) 3162306a36Sopenharmony_ci{ 3262306a36Sopenharmony_ci input->filter.formatted.src_ip[0] = (__force __be32)val; 3362306a36Sopenharmony_ci mask->formatted.src_ip[0] = (__force __be32)m; 3462306a36Sopenharmony_ci return 0; 3562306a36Sopenharmony_ci} 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistatic inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input, 3862306a36Sopenharmony_ci union ixgbe_atr_input *mask, 3962306a36Sopenharmony_ci u32 val, u32 m) 4062306a36Sopenharmony_ci{ 4162306a36Sopenharmony_ci input->filter.formatted.dst_ip[0] = (__force __be32)val; 4262306a36Sopenharmony_ci mask->formatted.dst_ip[0] = (__force __be32)m; 4362306a36Sopenharmony_ci return 0; 4462306a36Sopenharmony_ci} 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistatic struct ixgbe_mat_field ixgbe_ipv4_fields[] = { 4762306a36Sopenharmony_ci { .off = 12, .val = ixgbe_mat_prgm_sip, 4862306a36Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_IPV4}, 4962306a36Sopenharmony_ci { .off = 16, .val = ixgbe_mat_prgm_dip, 5062306a36Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_IPV4}, 5162306a36Sopenharmony_ci { .val = NULL } /* terminal node */ 5262306a36Sopenharmony_ci}; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistatic inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input, 5562306a36Sopenharmony_ci union ixgbe_atr_input *mask, 5662306a36Sopenharmony_ci u32 val, u32 m) 5762306a36Sopenharmony_ci{ 5862306a36Sopenharmony_ci input->filter.formatted.src_port = (__force __be16)(val & 0xffff); 5962306a36Sopenharmony_ci mask->formatted.src_port = (__force __be16)(m & 0xffff); 6062306a36Sopenharmony_ci input->filter.formatted.dst_port = (__force __be16)(val >> 16); 6162306a36Sopenharmony_ci mask->formatted.dst_port = (__force __be16)(m >> 16); 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci return 0; 6462306a36Sopenharmony_ci}; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_cistatic struct ixgbe_mat_field ixgbe_tcp_fields[] = { 6762306a36Sopenharmony_ci {.off = 0, .val = ixgbe_mat_prgm_ports, 6862306a36Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_TCPV4}, 6962306a36Sopenharmony_ci { .val = NULL } /* terminal node */ 7062306a36Sopenharmony_ci}; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistatic struct ixgbe_mat_field ixgbe_udp_fields[] = { 7362306a36Sopenharmony_ci {.off = 0, .val = ixgbe_mat_prgm_ports, 7462306a36Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_UDPV4}, 7562306a36Sopenharmony_ci { .val = NULL } /* terminal node */ 7662306a36Sopenharmony_ci}; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cistruct ixgbe_nexthdr { 7962306a36Sopenharmony_ci /* offset, shift, and mask of position to next header */ 8062306a36Sopenharmony_ci unsigned int o; 8162306a36Sopenharmony_ci u32 s; 8262306a36Sopenharmony_ci u32 m; 8362306a36Sopenharmony_ci /* match criteria to make this jump*/ 8462306a36Sopenharmony_ci unsigned int off; 8562306a36Sopenharmony_ci u32 val; 8662306a36Sopenharmony_ci u32 mask; 8762306a36Sopenharmony_ci /* location of jump to make */ 8862306a36Sopenharmony_ci struct ixgbe_mat_field *jump; 8962306a36Sopenharmony_ci}; 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_cistatic struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = { 9262306a36Sopenharmony_ci { .o = 0, .s = 6, .m = 0xf, 9362306a36Sopenharmony_ci .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields}, 9462306a36Sopenharmony_ci { .o = 0, .s = 6, .m = 0xf, 9562306a36Sopenharmony_ci .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields}, 9662306a36Sopenharmony_ci { .jump = NULL } /* terminal node */ 9762306a36Sopenharmony_ci}; 9862306a36Sopenharmony_ci#endif /* _IXGBE_MODEL_H_ */ 99