Neale Ranns | e403113 | 2020-10-26 13:00:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #ifndef __IP_FLOW_HASH_H__ |
| 17 | #define __IP_FLOW_HASH_H__ |
| 18 | |
Neale Ranns | 3d5f08a | 2021-01-22 16:12:38 +0000 | [diff] [blame] | 19 | #include <vnet/ip/ip_types.h> |
| 20 | |
Ahmed Abdelsalam | f2984bb | 2020-11-20 18:56:09 +0000 | [diff] [blame] | 21 | /** Default: 5-tuple + flowlabel without the "reverse" bit */ |
| 22 | #define IP_FLOW_HASH_DEFAULT (0x9F) |
Neale Ranns | e403113 | 2020-10-26 13:00:06 +0000 | [diff] [blame] | 23 | |
Ahmed Abdelsalam | f2984bb | 2020-11-20 18:56:09 +0000 | [diff] [blame] | 24 | #define foreach_flow_hash_bit_v1 \ |
| 25 | _ (src, IP_FLOW_HASH_SRC_ADDR) \ |
| 26 | _ (dst, IP_FLOW_HASH_DST_ADDR) \ |
| 27 | _ (sport, IP_FLOW_HASH_SRC_PORT) \ |
| 28 | _ (dport, IP_FLOW_HASH_DST_PORT) \ |
| 29 | _ (proto, IP_FLOW_HASH_PROTO) \ |
| 30 | _ (reverse, IP_FLOW_HASH_REVERSE_SRC_DST) \ |
| 31 | _ (symmetric, IP_FLOW_HASH_SYMMETRIC) |
Neale Ranns | e403113 | 2020-10-26 13:00:06 +0000 | [diff] [blame] | 32 | |
Ahmed Abdelsalam | f2984bb | 2020-11-20 18:56:09 +0000 | [diff] [blame] | 33 | #define foreach_flow_hash_bit \ |
| 34 | _ (src, 0, IP_FLOW_HASH_SRC_ADDR) \ |
| 35 | _ (dst, 1, IP_FLOW_HASH_DST_ADDR) \ |
| 36 | _ (sport, 2, IP_FLOW_HASH_SRC_PORT) \ |
| 37 | _ (dport, 3, IP_FLOW_HASH_DST_PORT) \ |
| 38 | _ (proto, 4, IP_FLOW_HASH_PROTO) \ |
| 39 | _ (reverse, 5, IP_FLOW_HASH_REVERSE_SRC_DST) \ |
| 40 | _ (symmetric, 6, IP_FLOW_HASH_SYMMETRIC) \ |
Takeru Hayasaka | b23c6f4 | 2023-01-17 04:45:58 +0900 | [diff] [blame] | 41 | _ (flowlabel, 7, IP_FLOW_HASH_FL) \ |
| 42 | _ (gtpv1teid, 8, IP_FLOW_HASH_GTPV1_TEID) |
| 43 | |
| 44 | typedef struct |
| 45 | { |
| 46 | u8 ver_flags; |
| 47 | u8 type; |
| 48 | u16 length; |
| 49 | u32 teid; |
| 50 | } __attribute__ ((packed)) gtpv1u_header_t; |
| 51 | #define GTPV1_PORT_BE 0x6808 |
Neale Ranns | e403113 | 2020-10-26 13:00:06 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * A flow hash configuration is a mask of the flow hash options |
| 55 | */ |
Ahmed Abdelsalam | f2984bb | 2020-11-20 18:56:09 +0000 | [diff] [blame] | 56 | typedef enum flow_hash_config_t_ |
| 57 | { |
| 58 | #define _(a, b, c) c = (1 << b), |
| 59 | foreach_flow_hash_bit |
| 60 | #undef _ |
| 61 | } flow_hash_config_t; |
Neale Ranns | e403113 | 2020-10-26 13:00:06 +0000 | [diff] [blame] | 62 | |
Neale Ranns | 3d5f08a | 2021-01-22 16:12:38 +0000 | [diff] [blame] | 63 | /* Router ID mixed into the flow hash to prevent network polarisation */ |
| 64 | extern u32 ip_flow_hash_router_id; |
| 65 | |
| 66 | int ip_flow_hash_set (ip_address_family_t af, u32 table_id, |
| 67 | flow_hash_config_t flow_hash_config); |
| 68 | void ip_flow_hash_router_id_set (u32 router_id); |
| 69 | |
Neale Ranns | e403113 | 2020-10-26 13:00:06 +0000 | [diff] [blame] | 70 | #endif /* __IP_TYPES_H__ */ |
| 71 | |
| 72 | /* |
| 73 | * fd.io coding-style-patch-verification: ON |
| 74 | * |
| 75 | * Local Variables: |
| 76 | * eval: (c-set-style "gnu") |
| 77 | * End: |
| 78 | */ |