Currently 'p' and 'b' and used for packets, so use a convention that struct dp_packet is 'p' and struct dp_packet_batch is 'b'.
Some comments needed new formatting to not pass the 80 column. Some variables were using 'p' or 'b' were renamed as well. There should be no functional change with this patch. Signed-off-by: Flavio Leitner <f...@sysclose.org> --- lib/dp-packet.c | 342 ++++++++++++++++---------------- lib/dp-packet.h | 506 ++++++++++++++++++++++++------------------------ 2 files changed, 424 insertions(+), 424 deletions(-) diff --git a/lib/dp-packet.c b/lib/dp-packet.c index 72f6d09ac..b4ee8c33c 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -25,58 +25,58 @@ #include "util.h" static void -dp_packet_init__(struct dp_packet *b, size_t allocated, enum dp_packet_source source) -{ - dp_packet_set_allocated(b, allocated); - b->source = source; - dp_packet_reset_offsets(b); - pkt_metadata_init(&b->md, 0); - dp_packet_reset_cutlen(b); - dp_packet_reset_offload(b); +dp_packet_init__(struct dp_packet *p, size_t allocated, enum dp_packet_source source) +{ + dp_packet_set_allocated(p, allocated); + p->source = source; + dp_packet_reset_offsets(p); + pkt_metadata_init(&p->md, 0); + dp_packet_reset_cutlen(p); + dp_packet_reset_offload(p); /* Initialize implementation-specific fields of dp_packet. */ - dp_packet_init_specific(b); + dp_packet_init_specific(p); /* By default assume the packet type to be Ethernet. */ - b->packet_type = htonl(PT_ETH); + p->packet_type = htonl(PT_ETH); } static void -dp_packet_use__(struct dp_packet *b, void *base, size_t allocated, +dp_packet_use__(struct dp_packet *p, void *base, size_t allocated, enum dp_packet_source source) { - dp_packet_set_base(b, base); - dp_packet_set_data(b, base); - dp_packet_set_size(b, 0); + dp_packet_set_base(p, base); + dp_packet_set_data(p, base); + dp_packet_set_size(p, 0); - dp_packet_init__(b, allocated, source); + dp_packet_init__(p, allocated, source); } -/* Initializes 'b' as an empty dp_packet that contains the 'allocated' bytes of +/* Initializes 'p' as an empty dp_packet that contains the 'allocated' bytes of * memory starting at 'base'. 'base' should be the first byte of a region - * obtained from malloc(). It will be freed (with free()) if 'b' is resized or + * obtained from malloc(). It will be freed (with free()) if 'p' is resized or * freed. */ void -dp_packet_use(struct dp_packet *b, void *base, size_t allocated) +dp_packet_use(struct dp_packet *p, void *base, size_t allocated) { - dp_packet_use__(b, base, allocated, DPBUF_MALLOC); + dp_packet_use__(p, base, allocated, DPBUF_MALLOC); } #if HAVE_AF_XDP -/* Initialize 'b' as an empty dp_packet that contains +/* Initialize 'p' as an empty dp_packet that contains * memory starting at AF_XDP umem base. */ void -dp_packet_use_afxdp(struct dp_packet *b, void *data, size_t allocated, +dp_packet_use_afxdp(struct dp_packet *p, void *data, size_t allocated, size_t headroom) { - dp_packet_set_base(b, (char *)data - headroom); - dp_packet_set_data(b, data); - dp_packet_set_size(b, 0); + dp_packet_set_base(p, (char *)data - headroom); + dp_packet_set_data(p, data); + dp_packet_set_size(p, 0); - dp_packet_init__(b, allocated, DPBUF_AFXDP); + dp_packet_init__(p, allocated, DPBUF_AFXDP); } #endif -/* Initializes 'b' as an empty dp_packet that contains the 'allocated' bytes of +/* Initializes 'p' as an empty dp_packet that contains the 'allocated' bytes of * memory starting at 'base'. 'base' should point to a buffer on the stack. * (Nothing actually relies on 'base' being allocated on the stack. It could * be static or malloc()'d memory. But stack space is the most common use @@ -91,12 +91,12 @@ dp_packet_use_afxdp(struct dp_packet *b, void *data, size_t allocated, * on an dp_packet initialized by this function, so that if it expanded into the * heap, that memory is freed. */ void -dp_packet_use_stub(struct dp_packet *b, void *base, size_t allocated) +dp_packet_use_stub(struct dp_packet *p, void *base, size_t allocated) { - dp_packet_use__(b, base, allocated, DPBUF_STUB); + dp_packet_use__(p, base, allocated, DPBUF_STUB); } -/* Initializes 'b' as an dp_packet whose data starts at 'data' and continues for +/* Initializes 'p' as an dp_packet whose data starts at 'data' and continues for * 'size' bytes. This is appropriate for an dp_packet that will be used to * inspect existing data, without moving it around or reallocating it, and * generally without modifying it at all. @@ -104,43 +104,43 @@ dp_packet_use_stub(struct dp_packet *b, void *base, size_t allocated) * An dp_packet operation that requires reallocating data will assert-fail if this * function was used to initialize it. */ void -dp_packet_use_const(struct dp_packet *b, const void *data, size_t size) +dp_packet_use_const(struct dp_packet *p, const void *data, size_t size) { - dp_packet_use__(b, CONST_CAST(void *, data), size, DPBUF_STACK); - dp_packet_set_size(b, size); + dp_packet_use__(p, CONST_CAST(void *, data), size, DPBUF_STACK); + dp_packet_set_size(p, size); } -/* Initializes 'b' as a DPDK dp-packet, which must have been allocated from a +/* Initializes 'p' as a DPDK dp-packet, which must have been allocated from a * DPDK memory pool. */ void -dp_packet_init_dpdk(struct dp_packet *b) +dp_packet_init_dpdk(struct dp_packet *p) { - b->source = DPBUF_DPDK; + p->source = DPBUF_DPDK; } -/* Initializes 'b' as an empty dp_packet with an initial capacity of 'size' +/* Initializes 'p' as an empty dp_packet with an initial capacity of 'size' * bytes. */ void -dp_packet_init(struct dp_packet *b, size_t size) +dp_packet_init(struct dp_packet *p, size_t size) { - dp_packet_use(b, size ? xmalloc(size) : NULL, size); + dp_packet_use(p, size ? xmalloc(size) : NULL, size); } -/* Frees memory that 'b' points to. */ +/* Frees memory that 'p' points to. */ void -dp_packet_uninit(struct dp_packet *b) +dp_packet_uninit(struct dp_packet *p) { - if (b) { - if (b->source == DPBUF_MALLOC) { - free(dp_packet_base(b)); - } else if (b->source == DPBUF_DPDK) { + if (p) { + if (p->source == DPBUF_MALLOC) { + free(dp_packet_base(p)); + } else if (p->source == DPBUF_DPDK) { #ifdef DPDK_NETDEV /* If this dp_packet was allocated by DPDK it must have been * created as a dp_packet */ - free_dpdk_buf((struct dp_packet*) b); + free_dpdk_buf((struct dp_packet*) p); #endif - } else if (b->source == DPBUF_AFXDP) { - free_afxdp_buf(b); + } else if (p->source == DPBUF_AFXDP) { + free_afxdp_buf(p); } } } @@ -150,9 +150,9 @@ dp_packet_uninit(struct dp_packet *b) struct dp_packet * dp_packet_new(size_t size) { - struct dp_packet *b = xmalloc(sizeof *b); - dp_packet_init(b, size); - return b; + struct dp_packet *p = xmalloc(sizeof *p); + dp_packet_init(p, size); + return p; } /* Creates and returns a new dp_packet with an initial capacity of 'size + @@ -160,45 +160,45 @@ dp_packet_new(size_t size) struct dp_packet * dp_packet_new_with_headroom(size_t size, size_t headroom) { - struct dp_packet *b = dp_packet_new(size + headroom); - dp_packet_reserve(b, headroom); - return b; + struct dp_packet *p = dp_packet_new(size + headroom); + dp_packet_reserve(p, headroom); + return p; } /* Creates and returns a new dp_packet that initially contains a copy of the * 'dp_packet_size(buffer)' bytes of data starting at 'buffer->data' with no headroom or * tailroom. */ struct dp_packet * -dp_packet_clone(const struct dp_packet *buffer) +dp_packet_clone(const struct dp_packet *p) { - return dp_packet_clone_with_headroom(buffer, 0); + return dp_packet_clone_with_headroom(p, 0); } -/* Creates and returns a new dp_packet whose data are copied from 'buffer'. +/* Creates and returns a new dp_packet whose data are copied from packet 'p'. * The returned dp_packet will additionally have 'headroom' bytes of * headroom. */ struct dp_packet * -dp_packet_clone_with_headroom(const struct dp_packet *buffer, size_t headroom) +dp_packet_clone_with_headroom(const struct dp_packet *p, size_t headroom) { struct dp_packet *new_buffer; uint32_t mark; - new_buffer = dp_packet_clone_data_with_headroom(dp_packet_data(buffer), - dp_packet_size(buffer), - headroom); + new_buffer = dp_packet_clone_data_with_headroom(dp_packet_data(p), + dp_packet_size(p), + headroom); /* Copy the following fields into the returned buffer: l2_pad_size, * l2_5_ofs, l3_ofs, l4_ofs, cutlen, packet_type and md. */ - memcpy(&new_buffer->l2_pad_size, &buffer->l2_pad_size, + memcpy(&new_buffer->l2_pad_size, &p->l2_pad_size, sizeof(struct dp_packet) - offsetof(struct dp_packet, l2_pad_size)); - *dp_packet_ol_flags_ptr(new_buffer) = *dp_packet_ol_flags_ptr(buffer); + *dp_packet_ol_flags_ptr(new_buffer) = *dp_packet_ol_flags_ptr(p); *dp_packet_ol_flags_ptr(new_buffer) &= DP_PACKET_OL_SUPPORTED_MASK; - if (dp_packet_rss_valid(buffer)) { - dp_packet_set_rss_hash(new_buffer, dp_packet_get_rss_hash(buffer)); + if (dp_packet_rss_valid(p)) { + dp_packet_set_rss_hash(new_buffer, dp_packet_get_rss_hash(p)); } - if (dp_packet_has_flow_mark(buffer, &mark)) { + if (dp_packet_has_flow_mark(p, &mark)) { dp_packet_set_flow_mark(new_buffer, mark); } @@ -219,47 +219,47 @@ dp_packet_clone_data(const void *data, size_t size) struct dp_packet * dp_packet_clone_data_with_headroom(const void *data, size_t size, size_t headroom) { - struct dp_packet *b = dp_packet_new_with_headroom(size, headroom); - dp_packet_put(b, data, size); - return b; + struct dp_packet *p = dp_packet_new_with_headroom(size, headroom); + dp_packet_put(p, data, size); + return p; } static void -dp_packet_copy__(struct dp_packet *b, uint8_t *new_base, +dp_packet_copy__(struct dp_packet *p, uint8_t *new_base, size_t new_headroom, size_t new_tailroom) { - const uint8_t *old_base = dp_packet_base(b); - size_t old_headroom = dp_packet_headroom(b); - size_t old_tailroom = dp_packet_tailroom(b); + const uint8_t *old_base = dp_packet_base(p); + size_t old_headroom = dp_packet_headroom(p); + size_t old_tailroom = dp_packet_tailroom(p); size_t copy_headroom = MIN(old_headroom, new_headroom); size_t copy_tailroom = MIN(old_tailroom, new_tailroom); memcpy(&new_base[new_headroom - copy_headroom], &old_base[old_headroom - copy_headroom], - copy_headroom + dp_packet_size(b) + copy_tailroom); + copy_headroom + dp_packet_size(p) + copy_tailroom); } -/* Reallocates 'b' so that it has exactly 'new_headroom' and 'new_tailroom' +/* Reallocates 'p' so that it has exactly 'new_headroom' and 'new_tailroom' * bytes of headroom and tailroom, respectively. */ void -dp_packet_resize(struct dp_packet *b, size_t new_headroom, size_t new_tailroom) +dp_packet_resize(struct dp_packet *p, size_t new_headroom, size_t new_tailroom) { void *new_base, *new_data; size_t new_allocated; - new_allocated = new_headroom + dp_packet_size(b) + new_tailroom; + new_allocated = new_headroom + dp_packet_size(p) + new_tailroom; - switch (b->source) { + switch (p->source) { case DPBUF_DPDK: OVS_NOT_REACHED(); case DPBUF_MALLOC: - if (new_headroom == dp_packet_headroom(b)) { - new_base = xrealloc(dp_packet_base(b), new_allocated); + if (new_headroom == dp_packet_headroom(p)) { + new_base = xrealloc(dp_packet_base(p), new_allocated); } else { new_base = xmalloc(new_allocated); - dp_packet_copy__(b, new_base, new_headroom, new_tailroom); - free(dp_packet_base(b)); + dp_packet_copy__(p, new_base, new_headroom, new_tailroom); + free(dp_packet_base(p)); } break; @@ -270,108 +270,108 @@ dp_packet_resize(struct dp_packet *b, size_t new_headroom, size_t new_tailroom) OVS_NOT_REACHED(); case DPBUF_STUB: - b->source = DPBUF_MALLOC; + p->source = DPBUF_MALLOC; new_base = xmalloc(new_allocated); - dp_packet_copy__(b, new_base, new_headroom, new_tailroom); + dp_packet_copy__(p, new_base, new_headroom, new_tailroom); break; default: OVS_NOT_REACHED(); } - dp_packet_set_allocated(b, new_allocated); - dp_packet_set_base(b, new_base); + dp_packet_set_allocated(p, new_allocated); + dp_packet_set_base(p, new_base); new_data = (char *) new_base + new_headroom; - if (dp_packet_data(b) != new_data) { - dp_packet_set_data(b, new_data); + if (dp_packet_data(p) != new_data) { + dp_packet_set_data(p, new_data); } } -/* Ensures that 'b' has room for at least 'size' bytes at its tail end, +/* Ensures that 'p' has room for at least 'size' bytes at its tail end, * reallocating and copying its data if necessary. Its headroom, if any, is * preserved. */ void -dp_packet_prealloc_tailroom(struct dp_packet *b, size_t size) +dp_packet_prealloc_tailroom(struct dp_packet *p, size_t size) { - if (size > dp_packet_tailroom(b)) { - dp_packet_resize(b, dp_packet_headroom(b), MAX(size, 64)); + if (size > dp_packet_tailroom(p)) { + dp_packet_resize(p, dp_packet_headroom(p), MAX(size, 64)); } } -/* Ensures that 'b' has room for at least 'size' bytes at its head, +/* Ensures that 'p' has room for at least 'size' bytes at its head, * reallocating and copying its data if necessary. Its tailroom, if any, is * preserved. */ void -dp_packet_prealloc_headroom(struct dp_packet *b, size_t size) +dp_packet_prealloc_headroom(struct dp_packet *p, size_t size) { - if (size > dp_packet_headroom(b)) { - dp_packet_resize(b, MAX(size, 64), dp_packet_tailroom(b)); + if (size > dp_packet_headroom(p)) { + dp_packet_resize(p, MAX(size, 64), dp_packet_tailroom(p)); } } -/* Shifts all of the data within the allocated space in 'b' by 'delta' bytes. +/* Shifts all of the data within the allocated space in 'p' by 'delta' bytes. * For example, a 'delta' of 1 would cause each byte of data to move one byte * forward (from address 'p' to 'p+1'), and a 'delta' of -1 would cause each * byte to move one byte backward (from 'p' to 'p-1'). */ void -dp_packet_shift(struct dp_packet *b, int delta) +dp_packet_shift(struct dp_packet *p, int delta) { - ovs_assert(delta > 0 ? delta <= dp_packet_tailroom(b) - : delta < 0 ? -delta <= dp_packet_headroom(b) + ovs_assert(delta > 0 ? delta <= dp_packet_tailroom(p) + : delta < 0 ? -delta <= dp_packet_headroom(p) : true); if (delta != 0) { - char *dst = (char *) dp_packet_data(b) + delta; - memmove(dst, dp_packet_data(b), dp_packet_size(b)); - dp_packet_set_data(b, dst); + char *dst = (char *) dp_packet_data(p) + delta; + memmove(dst, dp_packet_data(p), dp_packet_size(p)); + dp_packet_set_data(p, dst); } } -/* Appends 'size' bytes of data to the tail end of 'b', reallocating and +/* Appends 'size' bytes of data to the tail end of 'p', reallocating and * copying its data if necessary. Returns a pointer to the first byte of the * new data, which is left uninitialized. */ void * -dp_packet_put_uninit(struct dp_packet *b, size_t size) +dp_packet_put_uninit(struct dp_packet *p, size_t size) { - void *p; - dp_packet_prealloc_tailroom(b, size); - p = dp_packet_tail(b); - dp_packet_set_size(b, dp_packet_size(b) + size); - return p; + void *tail; + dp_packet_prealloc_tailroom(p, size); + tail = dp_packet_tail(p); + dp_packet_set_size(p, dp_packet_size(p) + size); + return tail; } -/* Appends 'size' zeroed bytes to the tail end of 'b'. Data in 'b' is +/* Appends 'size' zeroed bytes to the tail end of 'p'. Data in 'p' is * reallocated and copied if necessary. Returns a pointer to the first byte of * the data's location in the dp_packet. */ void * -dp_packet_put_zeros(struct dp_packet *b, size_t size) +dp_packet_put_zeros(struct dp_packet *p, size_t size) { - void *dst = dp_packet_put_uninit(b, size); + void *dst = dp_packet_put_uninit(p, size); memset(dst, 0, size); return dst; } -/* Appends the 'size' bytes of data in 'p' to the tail end of 'b'. Data in 'b' - * is reallocated and copied if necessary. Returns a pointer to the first - * byte of the data's location in the dp_packet. */ +/* Appends the 'size' bytes of data in 'data' to the tail end of 'p'. + * Data in 'data' is reallocated and copied if necessary. Returns + * a pointer to the first byte of the data's location in the dp_packet. */ void * -dp_packet_put(struct dp_packet *b, const void *p, size_t size) +dp_packet_put(struct dp_packet *p, const void *data, size_t size) { - void *dst = dp_packet_put_uninit(b, size); - memcpy(dst, p, size); + void *dst = dp_packet_put_uninit(p, size); + memcpy(dst, data, size); return dst; } /* Parses as many pairs of hex digits as possible (possibly separated by - * spaces) from the beginning of 's', appending bytes for their values to 'b'. + * spaces) from the beginning of 's', appending bytes for their values to 'p'. * Returns the first character of 's' that is not the first of a pair of hex - * digits. If 'n' is nonnull, stores the number of bytes added to 'b' in + * digits. If 'n' is nonnull, stores the number of bytes added to 'p' in * '*n'. */ char * -dp_packet_put_hex(struct dp_packet *b, const char *s, size_t *n) +dp_packet_put_hex(struct dp_packet *p, const char *s, size_t *n) { - size_t initial_size = dp_packet_size(b); + size_t initial_size = dp_packet_size(p); for (;;) { uint8_t byte; bool ok; @@ -380,12 +380,12 @@ dp_packet_put_hex(struct dp_packet *b, const char *s, size_t *n) byte = hexits_value(s, 2, &ok); if (!ok) { if (n) { - *n = dp_packet_size(b) - initial_size; + *n = dp_packet_size(p) - initial_size; } return CONST_CAST(char *, s); } - dp_packet_put(b, &byte, 1); + dp_packet_put(p, &byte, 1); s += 2; } } @@ -393,80 +393,80 @@ dp_packet_put_hex(struct dp_packet *b, const char *s, size_t *n) /* Reserves 'size' bytes of headroom so that they can be later allocated with * dp_packet_push_uninit() without reallocating the dp_packet. */ void -dp_packet_reserve(struct dp_packet *b, size_t size) +dp_packet_reserve(struct dp_packet *p, size_t size) { - ovs_assert(!dp_packet_size(b)); - dp_packet_prealloc_tailroom(b, size); - dp_packet_set_data(b, (char*)dp_packet_data(b) + size); + ovs_assert(!dp_packet_size(p)); + dp_packet_prealloc_tailroom(p, size); + dp_packet_set_data(p, (char*)dp_packet_data(p) + size); } /* Reserves 'headroom' bytes at the head and 'tailroom' at the end so that * they can be later allocated with dp_packet_push_uninit() or * dp_packet_put_uninit() without reallocating the dp_packet. */ void -dp_packet_reserve_with_tailroom(struct dp_packet *b, size_t headroom, +dp_packet_reserve_with_tailroom(struct dp_packet *p, size_t headroom, size_t tailroom) { - ovs_assert(!dp_packet_size(b)); - dp_packet_prealloc_tailroom(b, headroom + tailroom); - dp_packet_set_data(b, (char*)dp_packet_data(b) + headroom); + ovs_assert(!dp_packet_size(p)); + dp_packet_prealloc_tailroom(p, headroom + tailroom); + dp_packet_set_data(p, (char*)dp_packet_data(p) + headroom); } -/* Prefixes 'size' bytes to the head end of 'b', reallocating and copying its +/* Prefixes 'size' bytes to the head end of 'p', reallocating and copying its * data if necessary. Returns a pointer to the first byte of the data's * location in the dp_packet. The new data is left uninitialized. */ void * -dp_packet_push_uninit(struct dp_packet *b, size_t size) +dp_packet_push_uninit(struct dp_packet *p, size_t size) { - dp_packet_prealloc_headroom(b, size); - dp_packet_set_data(b, (char*)dp_packet_data(b) - size); - dp_packet_set_size(b, dp_packet_size(b) + size); - return dp_packet_data(b); + dp_packet_prealloc_headroom(p, size); + dp_packet_set_data(p, (char*)dp_packet_data(p) - size); + dp_packet_set_size(p, dp_packet_size(p) + size); + return dp_packet_data(p); } -/* Prefixes 'size' zeroed bytes to the head end of 'b', reallocating and +/* Prefixes 'size' zeroed bytes to the head end of 'p', reallocating and * copying its data if necessary. Returns a pointer to the first byte of the * data's location in the dp_packet. */ void * -dp_packet_push_zeros(struct dp_packet *b, size_t size) +dp_packet_push_zeros(struct dp_packet *p, size_t size) { - void *dst = dp_packet_push_uninit(b, size); + void *dst = dp_packet_push_uninit(p, size); memset(dst, 0, size); return dst; } -/* Copies the 'size' bytes starting at 'p' to the head end of 'b', reallocating - * and copying its data if necessary. Returns a pointer to the first byte of - * the data's location in the dp_packet. */ +/* Copies the 'size' bytes starting at 'data' to the head end of 'p', + * reallocating and copying its data if necessary. Returns a pointer + * to the first byte of the data's location in the dp_packet. */ void * -dp_packet_push(struct dp_packet *b, const void *p, size_t size) +dp_packet_push(struct dp_packet *p, const void *data, size_t size) { - void *dst = dp_packet_push_uninit(b, size); - memcpy(dst, p, size); + void *dst = dp_packet_push_uninit(p, size); + memcpy(dst, data, size); return dst; } -/* Returns the data in 'b' as a block of malloc()'d memory and frees the buffer - * within 'b'. (If 'b' itself was dynamically allocated, e.g. with +/* Returns the data in 'p' as a block of malloc()'d memory and frees the buffer + * within 'p'. (If 'p' itself was dynamically allocated, e.g. with * dp_packet_new(), then it should still be freed with, e.g., dp_packet_delete().) */ void * -dp_packet_steal_data(struct dp_packet *b) +dp_packet_steal_data(struct dp_packet *p) { - void *p; - ovs_assert(b->source != DPBUF_DPDK); - ovs_assert(b->source != DPBUF_AFXDP); + void *data; + ovs_assert(p->source != DPBUF_DPDK); + ovs_assert(p->source != DPBUF_AFXDP); - if (b->source == DPBUF_MALLOC && dp_packet_data(b) == dp_packet_base(b)) { - p = dp_packet_data(b); + if (p->source == DPBUF_MALLOC && dp_packet_data(p) == dp_packet_base(p)) { + data = dp_packet_data(p); } else { - p = xmemdup(dp_packet_data(b), dp_packet_size(b)); - if (b->source == DPBUF_MALLOC) { - free(dp_packet_base(b)); + data = xmemdup(dp_packet_data(p), dp_packet_size(p)); + if (p->source == DPBUF_MALLOC) { + free(dp_packet_base(p)); } } - dp_packet_set_base(b, NULL); - dp_packet_set_data(b, NULL); - return p; + dp_packet_set_base(p, NULL); + dp_packet_set_data(p, NULL); + return data; } static inline void @@ -481,28 +481,28 @@ dp_packet_adjust_layer_offset(uint16_t *offset, int increment) * pointer and the layer offsets. The caller is responsible for * modifying the contents. */ void * -dp_packet_resize_l2_5(struct dp_packet *b, int increment) +dp_packet_resize_l2_5(struct dp_packet *p, int increment) { if (increment >= 0) { - dp_packet_push_uninit(b, increment); + dp_packet_push_uninit(p, increment); } else { - dp_packet_pull(b, -increment); + dp_packet_pull(p, -increment); } /* Adjust layer offsets after l2_5. */ - dp_packet_adjust_layer_offset(&b->l3_ofs, increment); - dp_packet_adjust_layer_offset(&b->l4_ofs, increment); + dp_packet_adjust_layer_offset(&p->l3_ofs, increment); + dp_packet_adjust_layer_offset(&p->l4_ofs, increment); - return dp_packet_data(b); + return dp_packet_data(p); } /* Adjust the size of the l2 portion of the dp_packet, updating the l2 * pointer and the layer offsets. The caller is responsible for * modifying the contents. */ void * -dp_packet_resize_l2(struct dp_packet *b, int increment) +dp_packet_resize_l2(struct dp_packet *p, int increment) { - dp_packet_resize_l2_5(b, increment); - dp_packet_adjust_layer_offset(&b->l2_5_ofs, increment); - return dp_packet_data(b); + dp_packet_resize_l2_5(p, increment); + dp_packet_adjust_layer_offset(&p->l2_5_ofs, increment); + return dp_packet_data(p); } diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 82eae87b6..8b06e457b 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -196,7 +196,7 @@ struct dp_packet *dp_packet_clone_with_headroom(const struct dp_packet *, struct dp_packet *dp_packet_clone_data(const void *, size_t); struct dp_packet *dp_packet_clone_data_with_headroom(const void *, size_t, size_t headroom); -void dp_packet_resize(struct dp_packet *b, size_t new_headroom, +void dp_packet_resize(struct dp_packet *p, size_t new_headroom, size_t new_tailroom); static inline void dp_packet_delete(struct dp_packet *); static inline void dp_packet_swap(struct dp_packet *, struct dp_packet *); @@ -235,25 +235,25 @@ static inline bool dp_packet_equal(const struct dp_packet *, const struct dp_packet *); -/* Frees memory that 'b' points to, as well as 'b' itself. */ +/* Frees memory that 'p' points to, as well as 'p' itself. */ static inline void -dp_packet_delete(struct dp_packet *b) +dp_packet_delete(struct dp_packet *p) { - if (b) { - if (b->source == DPBUF_DPDK) { + if (p) { + if (p->source == DPBUF_DPDK) { /* If this dp_packet was allocated by DPDK it must have been * created as a dp_packet */ - free_dpdk_buf((struct dp_packet*) b); + free_dpdk_buf((struct dp_packet*) p); return; } - if (b->source == DPBUF_AFXDP) { - free_afxdp_buf(b); + if (p->source == DPBUF_AFXDP) { + free_afxdp_buf(p); return; } - dp_packet_uninit(b); - free(b); + dp_packet_uninit(p); + free(p); } } @@ -269,207 +269,207 @@ dp_packet_swap(struct dp_packet *a, struct dp_packet *b) *b = c; } -/* If 'b' contains at least 'offset + size' bytes of data, returns a pointer to +/* If 'p' contains at least 'offset + size' bytes of data, returns a pointer to * byte 'offset'. Otherwise, returns a null pointer. */ static inline void * -dp_packet_at(const struct dp_packet *b, size_t offset, size_t size) +dp_packet_at(const struct dp_packet *p, size_t offset, size_t size) { - return offset + size <= dp_packet_size(b) - ? (char *) dp_packet_data(b) + offset + return offset + size <= dp_packet_size(p) + ? (char *) dp_packet_data(p) + offset : NULL; } -/* Returns a pointer to byte 'offset' in 'b', which must contain at least +/* Returns a pointer to byte 'offset' in 'p', which must contain at least * 'offset + size' bytes of data. */ static inline void * -dp_packet_at_assert(const struct dp_packet *b, size_t offset, size_t size) +dp_packet_at_assert(const struct dp_packet *p, size_t offset, size_t size) { - ovs_assert(offset + size <= dp_packet_size(b)); - return ((char *) dp_packet_data(b)) + offset; + ovs_assert(offset + size <= dp_packet_size(p)); + return ((char *) dp_packet_data(p)) + offset; } -/* Returns a pointer to byte following the last byte of data in use in 'b'. */ +/* Returns a pointer to byte following the last byte of data in use in 'p'. */ static inline void * -dp_packet_tail(const struct dp_packet *b) +dp_packet_tail(const struct dp_packet *p) { - return (char *) dp_packet_data(b) + dp_packet_size(b); + return (char *) dp_packet_data(p) + dp_packet_size(p); } /* Returns a pointer to byte following the last byte allocated for use (but - * not necessarily in use) in 'b'. */ + * not necessarily in use) in 'p'. */ static inline void * -dp_packet_end(const struct dp_packet *b) +dp_packet_end(const struct dp_packet *p) { - return (char *) dp_packet_base(b) + dp_packet_get_allocated(b); + return (char *) dp_packet_base(p) + dp_packet_get_allocated(p); } -/* Returns the number of bytes of headroom in 'b', that is, the number of bytes - * of unused space in dp_packet 'b' before the data that is in use. (Most +/* Returns the number of bytes of headroom in 'p', that is, the number of bytes + * of unused space in dp_packet 'p' before the data that is in use. (Most * commonly, the data in a dp_packet is at its beginning, and thus the * dp_packet's headroom is 0.) */ static inline size_t -dp_packet_headroom(const struct dp_packet *b) +dp_packet_headroom(const struct dp_packet *p) { - return (char *) dp_packet_data(b) - (char *) dp_packet_base(b); + return (char *) dp_packet_data(p) - (char *) dp_packet_base(p); } /* Returns the number of bytes that may be appended to the tail end of - * dp_packet 'b' before the dp_packet must be reallocated. */ + * dp_packet 'p' before the dp_packet must be reallocated. */ static inline size_t -dp_packet_tailroom(const struct dp_packet *b) +dp_packet_tailroom(const struct dp_packet *p) { - return (char *) dp_packet_end(b) - (char *) dp_packet_tail(b); + return (char *) dp_packet_end(p) - (char *) dp_packet_tail(p); } -/* Clears any data from 'b'. */ +/* Clears any data from 'p'. */ static inline void -dp_packet_clear(struct dp_packet *b) +dp_packet_clear(struct dp_packet *p) { - dp_packet_set_data(b, dp_packet_base(b)); - dp_packet_set_size(b, 0); + dp_packet_set_data(p, dp_packet_base(p)); + dp_packet_set_size(p, 0); } -/* Removes 'size' bytes from the head end of 'b', which must contain at least +/* Removes 'size' bytes from the head end of 'p', which must contain at least * 'size' bytes of data. Returns the first byte of data removed. */ static inline void * -dp_packet_pull(struct dp_packet *b, size_t size) +dp_packet_pull(struct dp_packet *p, size_t size) { - void *data = dp_packet_data(b); - ovs_assert(dp_packet_size(b) - dp_packet_l2_pad_size(b) >= size); - dp_packet_set_data(b, (char *) dp_packet_data(b) + size); - dp_packet_set_size(b, dp_packet_size(b) - size); + void *data = dp_packet_data(p); + ovs_assert(dp_packet_size(p) - dp_packet_l2_pad_size(p) >= size); + dp_packet_set_data(p, (char *) dp_packet_data(p) + size); + dp_packet_set_size(p, dp_packet_size(p) - size); return data; } -/* If 'b' has at least 'size' bytes of data, removes that many bytes from the - * head end of 'b' and returns the first byte removed. Otherwise, returns a - * null pointer without modifying 'b'. */ +/* If 'p' has at least 'size' bytes of data, removes that many bytes from the + * head end of 'p' and returns the first byte removed. Otherwise, returns a + * null pointer without modifying 'p'. */ static inline void * -dp_packet_try_pull(struct dp_packet *b, size_t size) +dp_packet_try_pull(struct dp_packet *p, size_t size) { - return dp_packet_size(b) - dp_packet_l2_pad_size(b) >= size - ? dp_packet_pull(b, size) : NULL; + return dp_packet_size(p) - dp_packet_l2_pad_size(p) >= size + ? dp_packet_pull(p, size) : NULL; } static inline bool -dp_packet_equal(const struct dp_packet *a, const struct dp_packet *b) +dp_packet_equal(const struct dp_packet *p1, const struct dp_packet *p2) { - return dp_packet_size(a) == dp_packet_size(b) && - !memcmp(dp_packet_data(a), dp_packet_data(b), dp_packet_size(a)); + return dp_packet_size(p1) == dp_packet_size(p2) && + !memcmp(dp_packet_data(p1), dp_packet_data(p2), dp_packet_size(p1)); } static inline bool -dp_packet_is_eth(const struct dp_packet *b) +dp_packet_is_eth(const struct dp_packet *p) { - return b->packet_type == htonl(PT_ETH); + return p->packet_type == htonl(PT_ETH); } /* Get the start of the Ethernet frame. 'l3_ofs' marks the end of the l2 * headers, so return NULL if it is not set. */ static inline void * -dp_packet_eth(const struct dp_packet *b) +dp_packet_eth(const struct dp_packet *p) { - return (dp_packet_is_eth(b) && b->l3_ofs != UINT16_MAX) - ? dp_packet_data(b) : NULL; + return (dp_packet_is_eth(p) && p->l3_ofs != UINT16_MAX) + ? dp_packet_data(p) : NULL; } /* Resets all layer offsets. 'l3' offset must be set before 'l2' can be * retrieved. */ static inline void -dp_packet_reset_offsets(struct dp_packet *b) +dp_packet_reset_offsets(struct dp_packet *p) { - b->l2_pad_size = 0; - b->l2_5_ofs = UINT16_MAX; - b->l3_ofs = UINT16_MAX; - b->l4_ofs = UINT16_MAX; + p->l2_pad_size = 0; + p->l2_5_ofs = UINT16_MAX; + p->l3_ofs = UINT16_MAX; + p->l4_ofs = UINT16_MAX; } static inline uint16_t -dp_packet_l2_pad_size(const struct dp_packet *b) +dp_packet_l2_pad_size(const struct dp_packet *p) { - return b->l2_pad_size; + return p->l2_pad_size; } static inline void -dp_packet_set_l2_pad_size(struct dp_packet *b, uint16_t pad_size) +dp_packet_set_l2_pad_size(struct dp_packet *p, uint16_t pad_size) { - ovs_assert(pad_size <= dp_packet_size(b)); - b->l2_pad_size = pad_size; + ovs_assert(pad_size <= dp_packet_size(p)); + p->l2_pad_size = pad_size; } static inline void * -dp_packet_l2_5(const struct dp_packet *b) +dp_packet_l2_5(const struct dp_packet *p) { - return b->l2_5_ofs != UINT16_MAX - ? (char *) dp_packet_data(b) + b->l2_5_ofs + return p->l2_5_ofs != UINT16_MAX + ? (char *) dp_packet_data(p) + p->l2_5_ofs : NULL; } static inline void -dp_packet_set_l2_5(struct dp_packet *b, void *l2_5) +dp_packet_set_l2_5(struct dp_packet *p, void *l2_5) { - b->l2_5_ofs = l2_5 - ? (char *) l2_5 - (char *) dp_packet_data(b) + p->l2_5_ofs = l2_5 + ? (char *) l2_5 - (char *) dp_packet_data(p) : UINT16_MAX; } static inline void * -dp_packet_l3(const struct dp_packet *b) +dp_packet_l3(const struct dp_packet *p) { - return b->l3_ofs != UINT16_MAX - ? (char *) dp_packet_data(b) + b->l3_ofs + return p->l3_ofs != UINT16_MAX + ? (char *) dp_packet_data(p) + p->l3_ofs : NULL; } static inline void -dp_packet_set_l3(struct dp_packet *b, void *l3) +dp_packet_set_l3(struct dp_packet *p, void *l3) { - b->l3_ofs = l3 ? (char *) l3 - (char *) dp_packet_data(b) : UINT16_MAX; + p->l3_ofs = l3 ? (char *) l3 - (char *) dp_packet_data(p) : UINT16_MAX; } static inline void * -dp_packet_l4(const struct dp_packet *b) +dp_packet_l4(const struct dp_packet *p) { - return b->l4_ofs != UINT16_MAX - ? (char *) dp_packet_data(b) + b->l4_ofs + return p->l4_ofs != UINT16_MAX + ? (char *) dp_packet_data(p) + p->l4_ofs : NULL; } static inline void -dp_packet_set_l4(struct dp_packet *b, void *l4) +dp_packet_set_l4(struct dp_packet *p, void *l4) { - b->l4_ofs = l4 ? (char *) l4 - (char *) dp_packet_data(b) : UINT16_MAX; + p->l4_ofs = l4 ? (char *) l4 - (char *) dp_packet_data(p) : UINT16_MAX; } /* Returns the size of the packet from the beginning of the L3 header to the * end of the L3 payload. Hence L2 padding is not included. */ static inline size_t -dp_packet_l3_size(const struct dp_packet *b) +dp_packet_l3_size(const struct dp_packet *p) { - return OVS_LIKELY(b->l3_ofs != UINT16_MAX) - ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l3(b) - - dp_packet_l2_pad_size(b) + return OVS_LIKELY(p->l3_ofs != UINT16_MAX) + ? (const char *)dp_packet_tail(p) - (const char *)dp_packet_l3(p) + - dp_packet_l2_pad_size(p) : 0; } /* Returns the size of the packet from the beginning of the L4 header to the * end of the L4 payload. Hence L2 padding is not included. */ static inline size_t -dp_packet_l4_size(const struct dp_packet *b) +dp_packet_l4_size(const struct dp_packet *p) { - return OVS_LIKELY(b->l4_ofs != UINT16_MAX) - ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l4(b) - - dp_packet_l2_pad_size(b) + return OVS_LIKELY(p->l4_ofs != UINT16_MAX) + ? (const char *)dp_packet_tail(p) - (const char *)dp_packet_l4(p) + - dp_packet_l2_pad_size(p) : 0; } static inline const void * -dp_packet_get_tcp_payload(const struct dp_packet *b) +dp_packet_get_tcp_payload(const struct dp_packet *p) { - size_t l4_size = dp_packet_l4_size(b); + size_t l4_size = dp_packet_l4_size(p); if (OVS_LIKELY(l4_size >= TCP_HEADER_LEN)) { - struct tcp_header *tcp = dp_packet_l4(b); + struct tcp_header *tcp = dp_packet_l4(p); int tcp_len = TCP_OFFSET(tcp->tcp_ctl) * 4; if (OVS_LIKELY(tcp_len >= TCP_HEADER_LEN && tcp_len <= l4_size)) { @@ -480,11 +480,11 @@ dp_packet_get_tcp_payload(const struct dp_packet *b) } static inline uint32_t -dp_packet_get_tcp_payload_length(const struct dp_packet *pkt) +dp_packet_get_tcp_payload_length(const struct dp_packet *p) { - const char *tcp_payload = dp_packet_get_tcp_payload(pkt); + const char *tcp_payload = dp_packet_get_tcp_payload(p); if (tcp_payload) { - return ((char *) dp_packet_tail(pkt) - dp_packet_l2_pad_size(pkt) + return ((char *) dp_packet_tail(p) - dp_packet_l2_pad_size(p) - tcp_payload); } else { return 0; @@ -492,69 +492,69 @@ dp_packet_get_tcp_payload_length(const struct dp_packet *pkt) } static inline const void * -dp_packet_get_udp_payload(const struct dp_packet *b) +dp_packet_get_udp_payload(const struct dp_packet *p) { - return OVS_LIKELY(dp_packet_l4_size(b) >= UDP_HEADER_LEN) - ? (const char *)dp_packet_l4(b) + UDP_HEADER_LEN : NULL; + return OVS_LIKELY(dp_packet_l4_size(p) >= UDP_HEADER_LEN) + ? (const char *)dp_packet_l4(p) + UDP_HEADER_LEN : NULL; } static inline const void * -dp_packet_get_sctp_payload(const struct dp_packet *b) +dp_packet_get_sctp_payload(const struct dp_packet *p) { - return OVS_LIKELY(dp_packet_l4_size(b) >= SCTP_HEADER_LEN) - ? (const char *)dp_packet_l4(b) + SCTP_HEADER_LEN : NULL; + return OVS_LIKELY(dp_packet_l4_size(p) >= SCTP_HEADER_LEN) + ? (const char *)dp_packet_l4(p) + SCTP_HEADER_LEN : NULL; } static inline const void * -dp_packet_get_icmp_payload(const struct dp_packet *b) +dp_packet_get_icmp_payload(const struct dp_packet *p) { - return OVS_LIKELY(dp_packet_l4_size(b) >= ICMP_HEADER_LEN) - ? (const char *)dp_packet_l4(b) + ICMP_HEADER_LEN : NULL; + return OVS_LIKELY(dp_packet_l4_size(p) >= ICMP_HEADER_LEN) + ? (const char *)dp_packet_l4(p) + ICMP_HEADER_LEN : NULL; } static inline const void * -dp_packet_get_nd_payload(const struct dp_packet *b) +dp_packet_get_nd_payload(const struct dp_packet *p) { - return OVS_LIKELY(dp_packet_l4_size(b) >= ND_MSG_LEN) - ? (const char *)dp_packet_l4(b) + ND_MSG_LEN : NULL; + return OVS_LIKELY(dp_packet_l4_size(p) >= ND_MSG_LEN) + ? (const char *)dp_packet_l4(p) + ND_MSG_LEN : NULL; } #ifdef DPDK_NETDEV static inline uint64_t * -dp_packet_ol_flags_ptr(const struct dp_packet *b) +dp_packet_ol_flags_ptr(const struct dp_packet *p) { - return CONST_CAST(uint64_t *, &b->mbuf.ol_flags); + return CONST_CAST(uint64_t *, &p->mbuf.ol_flags); } static inline uint32_t * -dp_packet_rss_ptr(const struct dp_packet *b) +dp_packet_rss_ptr(const struct dp_packet *p) { - return CONST_CAST(uint32_t *, &b->mbuf.hash.rss); + return CONST_CAST(uint32_t *, &p->mbuf.hash.rss); } static inline uint32_t * -dp_packet_flow_mark_ptr(const struct dp_packet *b) +dp_packet_flow_mark_ptr(const struct dp_packet *p) { - return CONST_CAST(uint32_t *, &b->mbuf.hash.fdir.hi); + return CONST_CAST(uint32_t *, &p->mbuf.hash.fdir.hi); } #else static inline uint32_t * -dp_packet_ol_flags_ptr(const struct dp_packet *b) +dp_packet_ol_flags_ptr(const struct dp_packet *p) { - return CONST_CAST(uint32_t *, &b->ol_flags); + return CONST_CAST(uint32_t *, &p->ol_flags); } static inline uint32_t * -dp_packet_rss_ptr(const struct dp_packet *b) +dp_packet_rss_ptr(const struct dp_packet *p) { - return CONST_CAST(uint32_t *, &b->rss_hash); + return CONST_CAST(uint32_t *, &p->rss_hash); } static inline uint32_t * -dp_packet_flow_mark_ptr(const struct dp_packet *b) +dp_packet_flow_mark_ptr(const struct dp_packet *p) { - return CONST_CAST(uint32_t *, &b->flow_mark); + return CONST_CAST(uint32_t *, &p->flow_mark); } #endif @@ -572,25 +572,25 @@ dp_packet_init_specific(struct dp_packet *p) } static inline void * -dp_packet_base(const struct dp_packet *b) +dp_packet_base(const struct dp_packet *p) { - return b->mbuf.buf_addr; + return p->mbuf.buf_addr; } static inline void -dp_packet_set_base(struct dp_packet *b, void *d) +dp_packet_set_base(struct dp_packet *p, void *d) { - b->mbuf.buf_addr = d; + p->mbuf.buf_addr = d; } static inline uint32_t -dp_packet_size(const struct dp_packet *b) +dp_packet_size(const struct dp_packet *p) { - return b->mbuf.pkt_len; + return p->mbuf.pkt_len; } static inline void -dp_packet_set_size(struct dp_packet *b, uint32_t v) +dp_packet_set_size(struct dp_packet *p, uint32_t v) { /* netdev-dpdk does not currently support segmentation; consequently, for * all intents and purposes, 'data_len' (16 bit) and 'pkt_len' (32 bit) may @@ -600,33 +600,33 @@ dp_packet_set_size(struct dp_packet *b, uint32_t v) * (and thus 'v') will always be <= UINT16_MAX; this means that there is no * loss of accuracy in assigning 'v' to 'data_len'. */ - b->mbuf.data_len = (uint16_t)v; /* Current seg length. */ - b->mbuf.pkt_len = v; /* Total length of all segments linked to + p->mbuf.data_len = (uint16_t)v; /* Current seg length. */ + p->mbuf.pkt_len = v; /* Total length of all segments linked to * this segment. */ } static inline uint16_t -__packet_data(const struct dp_packet *b) +__packet_data(const struct dp_packet *p) { - return b->mbuf.data_off; + return p->mbuf.data_off; } static inline void -__packet_set_data(struct dp_packet *b, uint16_t v) +__packet_set_data(struct dp_packet *p, uint16_t v) { - b->mbuf.data_off = v; + p->mbuf.data_off = v; } static inline uint16_t -dp_packet_get_allocated(const struct dp_packet *b) +dp_packet_get_allocated(const struct dp_packet *p) { - return b->mbuf.buf_len; + return p->mbuf.buf_len; } static inline void -dp_packet_set_allocated(struct dp_packet *b, uint16_t s) +dp_packet_set_allocated(struct dp_packet *p, uint16_t s) { - b->mbuf.buf_len = s; + p->mbuf.buf_len = s; } #else /* DPDK_NETDEV */ @@ -638,112 +638,112 @@ dp_packet_init_specific(struct dp_packet *p OVS_UNUSED) } static inline void * -dp_packet_base(const struct dp_packet *b) +dp_packet_base(const struct dp_packet *p) { - return b->base_; + return p->base_; } static inline void -dp_packet_set_base(struct dp_packet *b, void *d) +dp_packet_set_base(struct dp_packet *p, void *d) { - b->base_ = d; + p->base_ = d; } static inline uint32_t -dp_packet_size(const struct dp_packet *b) +dp_packet_size(const struct dp_packet *p) { - return b->size_; + return p->size_; } static inline void -dp_packet_set_size(struct dp_packet *b, uint32_t v) +dp_packet_set_size(struct dp_packet *p, uint32_t v) { - b->size_ = v; + p->size_ = v; } static inline uint16_t -__packet_data(const struct dp_packet *b) +__packet_data(const struct dp_packet *p) { - return b->data_ofs; + return p->data_ofs; } static inline void -__packet_set_data(struct dp_packet *b, uint16_t v) +__packet_set_data(struct dp_packet *p, uint16_t v) { - b->data_ofs = v; + p->data_ofs = v; } static inline uint16_t -dp_packet_get_allocated(const struct dp_packet *b) +dp_packet_get_allocated(const struct dp_packet *p) { - return b->allocated_; + return p->allocated_; } static inline void -dp_packet_set_allocated(struct dp_packet *b, uint16_t s) +dp_packet_set_allocated(struct dp_packet *p, uint16_t s) { - b->allocated_ = s; + p->allocated_ = s; } #endif /* DPDK_NETDEV */ static inline void -dp_packet_reset_cutlen(struct dp_packet *b) +dp_packet_reset_cutlen(struct dp_packet *p) { - b->cutlen = 0; + p->cutlen = 0; } static inline uint32_t -dp_packet_set_cutlen(struct dp_packet *b, uint32_t max_len) +dp_packet_set_cutlen(struct dp_packet *p, uint32_t max_len) { if (max_len < ETH_HEADER_LEN) { max_len = ETH_HEADER_LEN; } - if (max_len >= dp_packet_size(b)) { - b->cutlen = 0; + if (max_len >= dp_packet_size(p)) { + p->cutlen = 0; } else { - b->cutlen = dp_packet_size(b) - max_len; + p->cutlen = dp_packet_size(p) - max_len; } - return b->cutlen; + return p->cutlen; } static inline uint32_t -dp_packet_get_cutlen(const struct dp_packet *b) +dp_packet_get_cutlen(const struct dp_packet *p) { /* Always in valid range if user uses dp_packet_set_cutlen. */ - return b->cutlen; + return p->cutlen; } static inline uint32_t -dp_packet_get_send_len(const struct dp_packet *b) +dp_packet_get_send_len(const struct dp_packet *p) { - return dp_packet_size(b) - dp_packet_get_cutlen(b); + return dp_packet_size(p) - dp_packet_get_cutlen(p); } static inline void * -dp_packet_data(const struct dp_packet *b) +dp_packet_data(const struct dp_packet *p) { - return __packet_data(b) != UINT16_MAX - ? (char *) dp_packet_base(b) + __packet_data(b) : NULL; + return __packet_data(p) != UINT16_MAX + ? (char *) dp_packet_base(p) + __packet_data(p) : NULL; } static inline void -dp_packet_set_data(struct dp_packet *b, void *data) +dp_packet_set_data(struct dp_packet *p, void *data) { if (data) { - __packet_set_data(b, (char *) data - (char *) dp_packet_base(b)); + __packet_set_data(p, (char *) data - (char *) dp_packet_base(p)); } else { - __packet_set_data(b, UINT16_MAX); + __packet_set_data(p, UINT16_MAX); } } static inline void -dp_packet_reset_packet(struct dp_packet *b, int off) +dp_packet_reset_packet(struct dp_packet *p, int off) { - dp_packet_set_size(b, dp_packet_size(b) - off); - dp_packet_set_data(b, ((unsigned char *) dp_packet_data(b) + off)); - dp_packet_reset_offsets(b); + dp_packet_set_size(p, dp_packet_size(p) - off); + dp_packet_set_data(p, ((unsigned char *) dp_packet_data(p) + off)); + dp_packet_reset_offsets(p); } enum { NETDEV_MAX_BURST = 32 }; /* Maximum number packets in a batch. */ @@ -755,69 +755,69 @@ struct dp_packet_batch { }; static inline void -dp_packet_batch_init(struct dp_packet_batch *batch) +dp_packet_batch_init(struct dp_packet_batch *b) { - batch->count = 0; - batch->trunc = false; + b->count = 0; + b->trunc = false; } static inline void -dp_packet_batch_add__(struct dp_packet_batch *batch, +dp_packet_batch_add__(struct dp_packet_batch *b, struct dp_packet *packet, size_t limit) { - if (batch->count < limit) { - batch->packets[batch->count++] = packet; + if (b->count < limit) { + b->packets[b->count++] = packet; } else { dp_packet_delete(packet); } } -/* When the batch is full, 'packet' will be dropped and freed. */ +/* When the batch 'b' is full, packet 'p' will be dropped and freed. */ static inline void -dp_packet_batch_add(struct dp_packet_batch *batch, struct dp_packet *packet) +dp_packet_batch_add(struct dp_packet_batch *b, struct dp_packet *p) { - dp_packet_batch_add__(batch, packet, NETDEV_MAX_BURST); + dp_packet_batch_add__(b, p, NETDEV_MAX_BURST); } static inline size_t -dp_packet_batch_size(const struct dp_packet_batch *batch) +dp_packet_batch_size(const struct dp_packet_batch *b) { - return batch->count; + return b->count; } -/* Clear 'batch' for refill. Use dp_packet_batch_refill() to add - * packets back into the 'batch'. */ +/* Clear batch 'b' for refill. Use dp_packet_batch_refill() to add + * packets back into the batch 'b'. */ static inline void -dp_packet_batch_refill_init(struct dp_packet_batch *batch) +dp_packet_batch_refill_init(struct dp_packet_batch *b) { - batch->count = 0; + b->count = 0; }; static inline void -dp_packet_batch_refill(struct dp_packet_batch *batch, +dp_packet_batch_refill(struct dp_packet_batch *b, struct dp_packet *packet, size_t idx) { - dp_packet_batch_add__(batch, packet, MIN(NETDEV_MAX_BURST, idx + 1)); + dp_packet_batch_add__(b, packet, MIN(NETDEV_MAX_BURST, idx + 1)); } static inline void -dp_packet_batch_init_packet(struct dp_packet_batch *batch, struct dp_packet *p) +dp_packet_batch_init_packet(struct dp_packet_batch *b, struct dp_packet *p) { - dp_packet_batch_init(batch); - batch->count = 1; - batch->packets[0] = p; + dp_packet_batch_init(b); + b->count = 1; + b->packets[0] = p; } static inline bool -dp_packet_batch_is_empty(const struct dp_packet_batch *batch) +dp_packet_batch_is_empty(const struct dp_packet_batch *b) { - return !dp_packet_batch_size(batch); + return !dp_packet_batch_size(b); } static inline bool -dp_packet_batch_is_full(const struct dp_packet_batch *batch) +dp_packet_batch_is_full(const struct dp_packet_batch *b) { - return dp_packet_batch_size(batch) == NETDEV_MAX_BURST; + return dp_packet_batch_size(b) == NETDEV_MAX_BURST; } #define DP_PACKET_BATCH_FOR_EACH(IDX, PACKET, BATCH) \ @@ -861,53 +861,53 @@ dp_packet_batch_clone(struct dp_packet_batch *dst, } static inline void -dp_packet_delete_batch(struct dp_packet_batch *batch, bool should_steal) +dp_packet_delete_batch(struct dp_packet_batch *b, bool should_steal) { if (should_steal) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, b) { dp_packet_delete(packet); } - dp_packet_batch_init(batch); + dp_packet_batch_init(b); } } static inline void -dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch) +dp_packet_batch_init_packet_fields(struct dp_packet_batch *b) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, b) { dp_packet_reset_cutlen(packet); packet->packet_type = htonl(PT_ETH); } } static inline void -dp_packet_batch_apply_cutlen(struct dp_packet_batch *batch) +dp_packet_batch_apply_cutlen(struct dp_packet_batch *b) { - if (batch->trunc) { + if (b->trunc) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, b) { dp_packet_set_size(packet, dp_packet_get_send_len(packet)); dp_packet_reset_cutlen(packet); } - batch->trunc = false; + b->trunc = false; } } static inline void -dp_packet_batch_reset_cutlen(struct dp_packet_batch *batch) +dp_packet_batch_reset_cutlen(struct dp_packet_batch *b) { - if (batch->trunc) { + if (b->trunc) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, b) { dp_packet_reset_cutlen(packet); } - batch->trunc = false; + b->trunc = false; } } @@ -958,101 +958,101 @@ dp_packet_set_flow_mark(struct dp_packet *p, uint32_t mark) /* Returns the L4 cksum offload bitmask. */ static inline uint64_t -dp_packet_ol_l4_mask(const struct dp_packet *b) +dp_packet_ol_l4_mask(const struct dp_packet *p) { - return *dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK; + return *dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK; } -/* Return true if the packet 'b' requested L4 checksum offload. */ +/* Return true if the packet 'p' requested L4 checksum offload. */ static inline bool -dp_packet_ol_tx_l4_csum(const struct dp_packet *b) +dp_packet_ol_tx_l4_csum(const struct dp_packet *p) { - return !!dp_packet_ol_l4_mask(b); + return !!dp_packet_ol_l4_mask(p); } -/* Returns 'true' if packet 'b' is marked for TCP segmentation offloading. */ +/* Returns 'true' if packet 'p' is marked for TCP segmentation offloading. */ static inline bool -dp_packet_ol_is_tso(const struct dp_packet *b) +dp_packet_ol_is_tso(const struct dp_packet *p) { - return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_TCP_SEG); + return !!(*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_TCP_SEG); } -/* Returns 'true' if packet 'b' is marked for IPv4 checksum offloading. */ +/* Returns 'true' if packet 'p' is marked for IPv4 checksum offloading. */ static inline bool -dp_packet_ol_is_ipv4(const struct dp_packet *b) +dp_packet_ol_is_ipv4(const struct dp_packet *p) { - return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_IPV4); + return !!(*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_IPV4); } -/* Returns 'true' if packet 'b' is marked for TCP checksum offloading. */ +/* Returns 'true' if packet 'p' is marked for TCP checksum offloading. */ static inline bool -dp_packet_ol_l4_is_tcp(const struct dp_packet *b) +dp_packet_ol_l4_is_tcp(const struct dp_packet *p) { - return (*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK) == + return (*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK) == DP_PACKET_OL_TX_TCP_CSUM; } -/* Returns 'true' if packet 'b' is marked for UDP checksum offloading. */ +/* Returns 'true' if packet 'p' is marked for UDP checksum offloading. */ static inline bool -dp_packet_ol_l4_is_udp(struct dp_packet *b) +dp_packet_ol_l4_is_udp(struct dp_packet *p) { - return (*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK) == + return (*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK) == DP_PACKET_OL_TX_UDP_CSUM; } -/* Returns 'true' if packet 'b' is marked for SCTP checksum offloading. */ +/* Returns 'true' if packet 'p' is marked for SCTP checksum offloading. */ static inline bool -dp_packet_ol_l4_is_sctp(struct dp_packet *b) +dp_packet_ol_l4_is_sctp(struct dp_packet *p) { - return (*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_L4_MASK) == + return (*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK) == DP_PACKET_OL_TX_SCTP_CSUM; } -/* Mark packet 'b' for IPv4 checksum offloading. */ +/* Mark packet 'p' for IPv4 checksum offloading. */ static inline void -dp_packet_ol_set_tx_ipv4(struct dp_packet *b) +dp_packet_ol_set_tx_ipv4(struct dp_packet *p) { - *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_IPV4; + *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_IPV4; } -/* Mark packet 'b' for IPv6 checksum offloading. */ +/* Mark packet 'p' for IPv6 checksum offloading. */ static inline void -dp_packet_ol_set_tx_ipv6(struct dp_packet *b) +dp_packet_ol_set_tx_ipv6(struct dp_packet *p) { - *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_IPV6; + *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_IPV6; } -/* Mark packet 'b' for TCP checksum offloading. It implies that either - * the packet 'b' is marked for IPv4 or IPv6 checksum offloading. */ +/* Mark packet 'p' for TCP checksum offloading. It implies that either + * the packet 'p' is marked for IPv4 or IPv6 checksum offloading. */ static inline void -dp_packet_ol_set_csum_tcp(struct dp_packet *b) +dp_packet_ol_set_csum_tcp(struct dp_packet *p) { - *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_TCP_CSUM; + *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_TCP_CSUM; } -/* Mark packet 'b' for UDP checksum offloading. It implies that either - * the packet 'b' is marked for IPv4 or IPv6 checksum offloading. */ +/* Mark packet 'p' for UDP checksum offloading. It implies that either + * the packet 'p' is marked for IPv4 or IPv6 checksum offloading. */ static inline void -dp_packet_ol_set_csum_udp(struct dp_packet *b) +dp_packet_ol_set_csum_udp(struct dp_packet *p) { - *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_UDP_CSUM; + *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_UDP_CSUM; } -/* Mark packet 'b' for SCTP checksum offloading. It implies that either - * the packet 'b' is marked for IPv4 or IPv6 checksum offloading. */ +/* Mark packet 'p' for SCTP checksum offloading. It implies that either + * the packet 'p' is marked for IPv4 or IPv6 checksum offloading. */ static inline void -dp_packet_ol_set_csum_sctp(struct dp_packet *b) +dp_packet_ol_set_csum_sctp(struct dp_packet *p) { - *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_SCTP_CSUM; + *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_SCTP_CSUM; } -/* Mark packet 'b' for TCP segmentation offloading. It implies that - * either the packet 'b' is marked for IPv4 or IPv6 checksum offloading +/* Mark packet 'p' for TCP segmentation offloading. It implies that + * either the packet 'p' is marked for IPv4 or IPv6 checksum offloading * and also for TCP checksum offloading. */ static inline void -dp_packet_ol_set_tcp_seg(struct dp_packet *b) +dp_packet_ol_set_tcp_seg(struct dp_packet *p) { - *dp_packet_ol_flags_ptr(b) |= DP_PACKET_OL_TX_TCP_SEG; + *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_TCP_SEG; } static inline bool -- 2.31.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev