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