|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [UNIKRAFT PATCH 2/4] lib/uknetdev: netbuf: Metadata at the end of an allocation
Thanks for the work Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> On 10/30/20 2:41 PM, Simon Kuenzer wrote: Place the netbuf metadata (`struct netbuf`) at the end of an allocation. This enables forwarding possible alignments of an underlying allocation to the buffer area of a netbuf. The metadata will no longer cause an offset of the buffer start address (`m->buf`). Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> --- lib/uknetdev/include/uk/netbuf.h | 29 +++++----- lib/uknetdev/netbuf.c | 97 ++++++++++++-------------------- 2 files changed, 50 insertions(+), 76 deletions(-) diff --git a/lib/uknetdev/include/uk/netbuf.h b/lib/uknetdev/include/uk/netbuf.h index f21d082b..ea803ae8 100644 --- a/lib/uknetdev/include/uk/netbuf.h +++ b/lib/uknetdev/include/uk/netbuf.h @@ -57,18 +57,6 @@ typedef void (*uk_netbuf_dtor_t)(struct uk_netbuf *); * The structure can be chained to describe a packet with multiple scattered * buffers. * - * NETBUF - * +----------------------+ - * | struct uk_netbuf | - * | | - * +----------------------+ - * - * PRIVATE META DATA - * *priv -> +----------------------+ - * | private meta | - * | data area | - * +----------------------+ - * * PACKET BUFFER * *buf -> +----------------------+ \ * | HEAD ROOM | | @@ -82,6 +70,17 @@ typedef void (*uk_netbuf_dtor_t)(struct uk_netbuf *); * | TAIL ROOM | | * *buf + buflen -> +----------------------+ / * + * NETBUF + * +----------------------+ + * | struct uk_netbuf | + * | | + * +----------------------+ + * + * PRIVATE META DATA + * *priv -> +----------------------+ + * | private meta | + * | data area | + * +----------------------+ * * The private data area is intended for glue code that wants to embed stack- * specific data to the netbuf (e.g., `struct pbuf` for lwIP). This avoids @@ -237,7 +236,8 @@ struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,/*** Allocate and initialize netbuf with data buffer area. - * m->len is initialized with 0. + * m->len is initialized with 0. Metadata (struct uknetbuf, priv) + * is placed at the end of the according allocation. * @param a * Allocator to be used for allocating `struct uk_netbuf` and the * corresponding buffer area (single allocation). @@ -268,7 +268,8 @@ struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,/*** Initialize netbuf with data buffer on a user given allocated memory area - * m->len is initialized with 0. + * m->len is initialized with 0. Metadata (struct uknetbuf, priv) + * is placed at the end of the given allocation. * @param mem * Reference to user provided memory region * @param buflen diff --git a/lib/uknetdev/netbuf.c b/lib/uknetdev/netbuf.c index 5156e808..c5cf662e 100644 --- a/lib/uknetdev/netbuf.c +++ b/lib/uknetdev/netbuf.c @@ -37,7 +37,10 @@/* Used to align netbuf's priv and data areas to `long long` data type */#define NETBUF_ADDR_ALIGNMENT (sizeof(long long)) -#define NETBUF_ADDR_ALIGN_UP(x) ALIGN_UP((x), NETBUF_ADDR_ALIGNMENT) +#define NETBUF_ADDR_ALIGN_UP(x) ALIGN_UP((__uptr) (x), \ + NETBUF_ADDR_ALIGNMENT) +#define NETBUF_ADDR_ALIGN_DOWN(x) ALIGN_DOWN((__uptr) (x), \ + NETBUF_ADDR_ALIGNMENT)void uk_netbuf_init_indir(struct uk_netbuf *m,
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |