43 _ip_incremental_checksum (
ip_csum_t sum,
void *_data,
uword n_bytes)
58 if (n_bytes >= sizeof (t) \ 59 && sizeof (t) < sizeof (ip_csum_t) \ 60 && (data % (2 * sizeof (t))) != 0) \ 62 sum0 += * uword_to_pointer (data, t *); \ 64 n_bytes -= sizeof (t); \ 79 while (n_bytes >= 2 *
sizeof (d[0]))
84 n_bytes -= 2 *
sizeof (d[0]);
92 if (n_bytes >= sizeof (t) && sizeof (t) <= sizeof (ip_csum_t)) \ 94 sum0 = ip_csum_with_carry (sum0, * uword_to_pointer (data, t *)); \ 96 n_bytes -= sizeof (t); \ 124 #define IP_INCREMENTAL_CHECKSUM_CLONE_TEMPLATE(arch, fn) 125 #define IP_INCREMENTAL_CHECKSUM_MULTIARCH_CLONE(fn) 127 #define IP_INCREMENTAL_CHECKSUM_CLONE_TEMPLATE(arch, fn, tgt) \ 129 __attribute__ ((flatten)) \ 130 __attribute__ ((target (tgt))) \ 132 fn ## _ ## arch (ip_csum_t sum, \ 135 { return fn (sum, _data, n_bytes); } 137 #define IP_INCREMENTAL_CHECKSUM_MULTIARCH_CLONE(fn) \ 138 foreach_march_variant(IP_INCREMENTAL_CHECKSUM_CLONE_TEMPLATE,fn) 158 static const char test_pkt[] = {
159 0x45, 0x00, 0x00, 0x3c, 0x5d, 0x6f, 0x40, 0x00,
160 0x40, 0x06, 0x3f, 0x6b, 0x0a, 0x76, 0x72, 0x44,
161 0x0a, 0x56, 0x16, 0xd2,
175 for (offset = 0; offset < 8; offset++)
177 memcpy (align_test + offset, test_pkt,
ARRAY_LEN (test_pkt));
192 .path =
"test ip checksum",
193 .short_help =
"test ip checksum",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static clib_error_t * test_ip_checksum_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip_csum_t(* vnet_incremental_checksum_fp)(ip_csum_t, void *, uword)
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
#define VLIB_INIT_FUNCTION(x)
static clib_error_t * ip_checksum_init(vlib_main_t *vm)
#define VLIB_CLI_COMMAND(x,...)
#define uword_to_pointer(u, type)
CLIB_MULTIARCH_SELECT_FN(_ip_incremental_checksum, static inline)
static uword pointer_to_uword(const void *p)
struct clib_bihash_value offset
template key/value backing page structure
#define IP_INCREMENTAL_CHECKSUM_MULTIARCH_CLONE(fn)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static u16 ip4_header_checksum(ip4_header_t *i)