40 #ifndef included_ip_packet_h 41 #define included_ip_packet_h 49 #define ip_protocol(n,s) IP_PROTOCOL_##s = n, 57 #define ip_port(s,n) IP_PORT_##s = n, 70 #define foreach_ip_builtin_multicast_group \ 71 _ (1, all_hosts_on_subnet) \ 72 _ (2, all_routers_on_subnet) \ 74 _ (5, ospf_all_routers) \ 75 _ (6, ospf_designated_routers) \ 83 #define _(n,f) IP_MULTICAST_GROUP_##f = n, 92 #define foreach_ip_dscp \ 117 #define _(n,f) IP_DSCP_##f = n, 129 #define IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT 2 130 #define IP_PACKET_TC_FIELD_ECN_MASK 0x03 135 #define foreach_ip_ecn \ 143 #define _(n,f) IP_ECN_##f = n, 158 #ifdef CLIB_HAVE_VEC256 166 sum = (n_left & 1) ? ((
u8 *)
data)[n_left - 1] << 8 : 0;
171 #ifdef CLIB_HAVE_VEC256 174 v1 = u16x16_load_unaligned (data);
175 v2 = u16x16_load_unaligned (data + 32);
177 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN 181 sum8 += u32x8_from_u16x8 (u16x16_extract_lo (v1));
182 sum8 += u32x8_from_u16x8 (u16x16_extract_hi (v1));
183 sum8 += u32x8_from_u16x8 (u16x16_extract_lo (v2));
184 sum8 += u32x8_from_u16x8 (u16x16_extract_hi (v2));
191 v1 = u16x16_load_unaligned (data);
192 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN 195 sum8 += u32x8_from_u16x8 (u16x16_extract_lo (v1));
196 sum8 += u32x8_from_u16x8 (u16x16_extract_hi (v1));
203 v1 = u16x16_load_unaligned (data);
204 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN 208 sum8 += u32x8_from_u16x8 (u16x16_extract_lo (v1));
209 sum8 += u32x8_from_u16x8 (u16x16_extract_hi (v1));
213 sum4 = u32x8_extract_lo (sum8) + u32x8_extract_hi (sum8);
214 sum += sum4[0] + sum4[1];
220 sum += clib_net_to_host_u16 (*((
u16 *) data + 0));
221 sum += clib_net_to_host_u16 (*((
u16 *) data + 1));
222 sum += clib_net_to_host_u16 (*((
u16 *) data + 2));
223 sum += clib_net_to_host_u16 (*((
u16 *) data + 3));
224 sum += clib_net_to_host_u16 (*((
u16 *) data + 4));
225 sum += clib_net_to_host_u16 (*((
u16 *) data + 5));
226 sum += clib_net_to_host_u16 (*((
u16 *) data + 6));
227 sum += clib_net_to_host_u16 (*((
u16 *) data + 7));
233 sum += clib_net_to_host_u16 (*(
u16 *) data);
239 sum = (sum & 0xffff) + (sum >> 16);
240 sum = (sum & 0xffff) + (sum >> 16);
266 ASSERT ((t - c == 0) || (t - c == ~0));
280 u32 field_byte_offset,
u32 field_n_bytes)
284 if ((field_n_bytes % 2)
295 #define ip_csum_update(sum,old,new,type,field) \ 296 ip_csum_update_inline ((sum), (old), (new), \ 297 STRUCT_OFFSET_OF (type, field), \ 298 STRUCT_SIZE_OF (type, field)) 306 c = (c & 0xffff) + (c >> 16);
309 c = (c & 0xffff) + (c >> 16);
310 c = (c & 0xffff) + (c >> 16);
unformat_function_t unformat_ip_dscp
#define CLIB_ARCH_IS_LITTLE_ENDIAN
u8 * format_ip_dscp(u8 *s, va_list *va)
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
static_always_inline u16x16 u16x16_mask_last(u16x16 v, u8 n_last)
static u16 ip_csum_and_memcpy_fold(ip_csum_t sum, void *dst)
#define static_always_inline
STATIC_ASSERT_SIZEOF(ip_ecn_t, 1)
static ip_csum_t ip_csum_update_inline(ip_csum_t sum, ip_csum_t old, ip_csum_t new, u32 field_byte_offset, u32 field_n_bytes)
enum ip_protocol ip_protocol_t
static_always_inline u16x16 u16x16_byte_swap(u16x16 v)
static_always_inline u16 ip_csum(void *data, u16 n_left)
static_always_inline u32x8 u32x8_hadd(u32x8 v1, u32x8 v2)
enum ip_dscp_t_ ip_dscp_t
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
#define foreach_ip_ecn
The set of RFC defined DSCP values.
ip_csum_t(* vnet_incremental_checksum_fp)(ip_csum_t, void *, uword)
#define foreach_ip_builtin_multicast_group
u8 * format_ip_ecn(u8 *s, va_list *va)
#define foreach_ip_dscp
The set of RFC defined DSCP values.
_mm256_packus_epi16 u16x16
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static u16 ip_csum_fold(ip_csum_t c)
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)