18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _IXGBE_MODEL_H_ 58c2ecf20Sopenharmony_ci#define _IXGBE_MODEL_H_ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include "ixgbe.h" 88c2ecf20Sopenharmony_ci#include "ixgbe_type.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistruct ixgbe_mat_field { 118c2ecf20Sopenharmony_ci unsigned int off; 128c2ecf20Sopenharmony_ci int (*val)(struct ixgbe_fdir_filter *input, 138c2ecf20Sopenharmony_ci union ixgbe_atr_input *mask, 148c2ecf20Sopenharmony_ci u32 val, u32 m); 158c2ecf20Sopenharmony_ci unsigned int type; 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct ixgbe_jump_table { 198c2ecf20Sopenharmony_ci struct ixgbe_mat_field *mat; 208c2ecf20Sopenharmony_ci struct ixgbe_fdir_filter *input; 218c2ecf20Sopenharmony_ci union ixgbe_atr_input *mask; 228c2ecf20Sopenharmony_ci u32 link_hdl; 238c2ecf20Sopenharmony_ci unsigned long child_loc_map[32]; 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define IXGBE_MAX_HW_ENTRIES 2045 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input, 298c2ecf20Sopenharmony_ci union ixgbe_atr_input *mask, 308c2ecf20Sopenharmony_ci u32 val, u32 m) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci input->filter.formatted.src_ip[0] = (__force __be32)val; 338c2ecf20Sopenharmony_ci mask->formatted.src_ip[0] = (__force __be32)m; 348c2ecf20Sopenharmony_ci return 0; 358c2ecf20Sopenharmony_ci} 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input, 388c2ecf20Sopenharmony_ci union ixgbe_atr_input *mask, 398c2ecf20Sopenharmony_ci u32 val, u32 m) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci input->filter.formatted.dst_ip[0] = (__force __be32)val; 428c2ecf20Sopenharmony_ci mask->formatted.dst_ip[0] = (__force __be32)m; 438c2ecf20Sopenharmony_ci return 0; 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic struct ixgbe_mat_field ixgbe_ipv4_fields[] = { 478c2ecf20Sopenharmony_ci { .off = 12, .val = ixgbe_mat_prgm_sip, 488c2ecf20Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_IPV4}, 498c2ecf20Sopenharmony_ci { .off = 16, .val = ixgbe_mat_prgm_dip, 508c2ecf20Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_IPV4}, 518c2ecf20Sopenharmony_ci { .val = NULL } /* terminal node */ 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input, 558c2ecf20Sopenharmony_ci union ixgbe_atr_input *mask, 568c2ecf20Sopenharmony_ci u32 val, u32 m) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci input->filter.formatted.src_port = (__force __be16)(val & 0xffff); 598c2ecf20Sopenharmony_ci mask->formatted.src_port = (__force __be16)(m & 0xffff); 608c2ecf20Sopenharmony_ci input->filter.formatted.dst_port = (__force __be16)(val >> 16); 618c2ecf20Sopenharmony_ci mask->formatted.dst_port = (__force __be16)(m >> 16); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return 0; 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic struct ixgbe_mat_field ixgbe_tcp_fields[] = { 678c2ecf20Sopenharmony_ci {.off = 0, .val = ixgbe_mat_prgm_ports, 688c2ecf20Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_TCPV4}, 698c2ecf20Sopenharmony_ci { .val = NULL } /* terminal node */ 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistatic struct ixgbe_mat_field ixgbe_udp_fields[] = { 738c2ecf20Sopenharmony_ci {.off = 0, .val = ixgbe_mat_prgm_ports, 748c2ecf20Sopenharmony_ci .type = IXGBE_ATR_FLOW_TYPE_UDPV4}, 758c2ecf20Sopenharmony_ci { .val = NULL } /* terminal node */ 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct ixgbe_nexthdr { 798c2ecf20Sopenharmony_ci /* offset, shift, and mask of position to next header */ 808c2ecf20Sopenharmony_ci unsigned int o; 818c2ecf20Sopenharmony_ci u32 s; 828c2ecf20Sopenharmony_ci u32 m; 838c2ecf20Sopenharmony_ci /* match criteria to make this jump*/ 848c2ecf20Sopenharmony_ci unsigned int off; 858c2ecf20Sopenharmony_ci u32 val; 868c2ecf20Sopenharmony_ci u32 mask; 878c2ecf20Sopenharmony_ci /* location of jump to make */ 888c2ecf20Sopenharmony_ci struct ixgbe_mat_field *jump; 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = { 928c2ecf20Sopenharmony_ci { .o = 0, .s = 6, .m = 0xf, 938c2ecf20Sopenharmony_ci .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields}, 948c2ecf20Sopenharmony_ci { .o = 0, .s = 6, .m = 0xf, 958c2ecf20Sopenharmony_ci .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields}, 968c2ecf20Sopenharmony_ci { .jump = NULL } /* terminal node */ 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci#endif /* _IXGBE_MODEL_H_ */ 99