40 #ifndef included_ip_packet_h 41 #define included_ip_packet_h 48 #define ip_protocol(n,s) IP_PROTOCOL_##s = n, 56 #define ip_port(s,n) IP_PORT_##s = n, 69 #define foreach_ip_builtin_multicast_group \ 70 _ (1, all_hosts_on_subnet) \ 71 _ (2, all_routers_on_subnet) \ 73 _ (5, ospf_all_routers) \ 74 _ (6, ospf_designated_routers) \ 82 #define _(n,f) IP_MULTICAST_GROUP_##f = n, 93 #ifdef CLIB_HAVE_VEC256 101 sum = (n_left & 1) ? ((
u8 *) data)[n_left - 1] << 8 : 0;
106 #ifdef CLIB_HAVE_VEC256 109 v1 = u16x16_load_unaligned (data);
110 v2 = u16x16_load_unaligned (data + 32);
112 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN 116 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_lo (v1));
117 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_hi (v1));
118 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_lo (v2));
119 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_hi (v2));
126 v1 = u16x16_load_unaligned (data);
127 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN 131 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_lo (v1));
132 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_hi (v1));
139 v1 = u16x16_load_unaligned (data);
140 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN 144 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_lo (v1));
145 sum8 += u16x8_extend_to_u32x8 (u16x16_extract_hi (v1));
149 sum4 = u32x8_extract_lo (sum8) + u32x8_extract_hi (sum8);
150 sum = sum4[0] + sum4[1];
156 sum += clib_net_to_host_u16 (*((
u16 *) data + 0));
157 sum += clib_net_to_host_u16 (*((
u16 *) data + 1));
158 sum += clib_net_to_host_u16 (*((
u16 *) data + 2));
159 sum += clib_net_to_host_u16 (*((
u16 *) data + 3));
160 sum += clib_net_to_host_u16 (*((
u16 *) data + 4));
161 sum += clib_net_to_host_u16 (*((
u16 *) data + 5));
162 sum += clib_net_to_host_u16 (*((
u16 *) data + 6));
163 sum += clib_net_to_host_u16 (*((
u16 *) data + 7));
169 sum += clib_net_to_host_u16 (*(
u16 *) data);
175 sum = (sum & 0xffff) + (sum >> 16);
176 sum = (sum & 0xffff) + (sum >> 16);
186 ip_csum_t t = sum + x;
202 ASSERT ((t - c == 0) || (t - c == ~0));
216 u32 field_byte_offset,
u32 field_n_bytes)
220 if ((field_n_bytes % 2)
231 #define ip_csum_update(sum,old,new,type,field) \ 232 ip_csum_update_inline ((sum), (old), (new), \ 233 STRUCT_OFFSET_OF (type, field), \ 234 STRUCT_SIZE_OF (type, field)) 242 c = (c & 0xffff) + (c >> 16);
245 c = (c & 0xffff) + (c >> 16);
246 c = (c & 0xffff) + (c >> 16);
#define CLIB_ARCH_IS_LITTLE_ENDIAN
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
epu16_epi64 epu8_epi64 epu8_epi64 epi16_epi64 epi8_epi64 epi8_epi64 static_always_inline u16x16 u16x16_byte_swap(u16x16 v)
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 u16 ip_csum(void *data, u16 n_left)
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static_always_inline u32x8 u32x8_hadd(u32x8 v1, u32x8 v2)
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
ip_csum_t(* vnet_incremental_checksum_fp)(ip_csum_t, void *, uword)
#define foreach_ip_builtin_multicast_group
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)