From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C8EBA04B5; Tue, 27 Oct 2020 23:15:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 75AA82DCC; Tue, 27 Oct 2020 23:14:08 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id D5EF42BFF for ; Tue, 27 Oct 2020 23:14:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603836841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gn3sgw9pFEoppITidZbG/bxoXDuvHQxH/vJU2HQkX40=; b=PRRByptgGsSGiAakEsKyv2ApthKeCgSWtKp5e43jsWg/pCzroZyFNE6c7GXNTOjIPk4KTt c9IcbHffP+F0uWb9g6X/3Px5REmrUtbe9+hLD8IYx54xRHEEApybt9m0D6Zo6MgDrpsuSc EOOuzO/awPC6tLjBbflyztQJBtQVfEo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-94kv8W1ONMSP7nP8Qz80bQ-1; Tue, 27 Oct 2020 18:13:59 -0400 X-MC-Unique: 94kv8W1ONMSP7nP8Qz80bQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59DA2809DDA; Tue, 27 Oct 2020 22:13:58 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id E827D5C1BB; Tue, 27 Oct 2020 22:13:55 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Reshma Pattan , Ray Kinsella , Neil Horman Date: Tue, 27 Oct 2020 23:13:39 +0100 Message-Id: <20201027221343.28551-5-david.marchand@redhat.com> In-Reply-To: <20201027221343.28551-1-david.marchand@redhat.com> References: <20201027221343.28551-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH 4/8] reorder: switch sequence number to dynamic mbuf field X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The reorder library used sequence numbers stored in the deprecated field seqn. It is moved to a dynamic mbuf field in order to allow removal of seqn. Signed-off-by: David Marchand --- app/test/test_reorder.c | 8 ++++---- examples/packet_ordering/main.c | 2 +- lib/librte_reorder/rte_reorder.c | 23 ++++++++++++++++++++--- lib/librte_reorder/rte_reorder.h | 21 +++++++++++++++++++++ lib/librte_reorder/version.map | 6 ++++++ 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 58fa9c71b5..1c4226da65 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -149,7 +149,7 @@ test_reorder_insert(void) for (i = 0; i < num_bufs; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); - bufs[i]->seqn = i; + *rte_reorder_seqn(bufs[i]) = i; } /* This should fill up order buffer: @@ -183,7 +183,7 @@ test_reorder_insert(void) bufs[4] = NULL; /* early packet from current sequence window - full ready buffer */ - bufs[5]->seqn = 2 * size; + *rte_reorder_seqn(bufs[5]) = 2 * size; ret = rte_reorder_insert(b, bufs[5]); if (!((ret == -1) && (rte_errno == ENOSPC))) { printf("%s:%d: No error inserting early packet with full ready buffer\n", @@ -194,7 +194,7 @@ test_reorder_insert(void) bufs[5] = NULL; /* late packet */ - bufs[6]->seqn = 3 * size; + *rte_reorder_seqn(bufs[6]) = 3 * size; ret = rte_reorder_insert(b, bufs[6]); if (!((ret == -1) && (rte_errno == ERANGE))) { printf("%s:%d: No error inserting late packet with seqn:" @@ -250,7 +250,7 @@ test_reorder_drain(void) for (i = 0; i < num_bufs; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); - bufs[i]->seqn = i; + *rte_reorder_seqn(bufs[i]) = i; } /* Insert packet with seqn 1: diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index a79d77a321..4bea1982d5 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -451,7 +451,7 @@ rx_thread(struct rte_ring *ring_out) /* mark sequence number */ for (i = 0; i < nb_rx_pkts; ) - pkts[i++]->seqn = seqn++; + *rte_reorder_seqn(pkts[i++]) = seqn++; /* enqueue to rx_to_workers ring */ ret = rte_ring_enqueue_burst(ring_out, diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c index 3c9f0e2d08..9445853b79 100644 --- a/lib/librte_reorder/rte_reorder.c +++ b/lib/librte_reorder/rte_reorder.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,9 @@ EAL_REGISTER_TAILQ(rte_reorder_tailq) /* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_REORDER RTE_LOGTYPE_USER1 +#define RTE_REORDER_SEQN_DYNFIELD_NAME "rte_reorder_seqn_dynfield" +int rte_reorder_seqn_dynfield_offset = -1; + /* A generic circular buffer */ struct cir_buffer { unsigned int size; /**< Number of entries that can be stored */ @@ -103,6 +107,11 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) struct rte_reorder_list *reorder_list; const unsigned int bufsize = sizeof(struct rte_reorder_buffer) + (2 * size * sizeof(struct rte_mbuf *)); + static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = { + .name = RTE_REORDER_SEQN_DYNFIELD_NAME, + .size = sizeof(rte_reorder_seqn_t), + .align = __alignof__(rte_reorder_seqn_t), + }; reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list); @@ -120,6 +129,14 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) return NULL; } + rte_reorder_seqn_dynfield_offset = + rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); + if (rte_reorder_seqn_dynfield_offset < 0) { + RTE_LOG(ERR, REORDER, "Failed to register mbuf field for reorder sequence number\n"); + rte_errno = ENOMEM; + return NULL; + } + rte_mcfg_tailq_write_lock(); /* guarantee there's no existing */ @@ -310,7 +327,7 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf) order_buf = &b->order_buf; if (!b->is_initialized) { - b->min_seqn = mbuf->seqn; + b->min_seqn = *rte_reorder_seqn(mbuf); b->is_initialized = 1; } @@ -322,7 +339,7 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf) * mbuf_seqn = 0x0010 * offset = 0x0010 - 0xFFFD = 0x13 */ - offset = mbuf->seqn - b->min_seqn; + offset = *rte_reorder_seqn(mbuf) - b->min_seqn; /* * action to take depends on offset. @@ -352,7 +369,7 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf) rte_errno = ENOSPC; return -1; } - offset = mbuf->seqn - b->min_seqn; + offset = *rte_reorder_seqn(mbuf) - b->min_seqn; position = (order_buf->head + offset) & order_buf->mask; order_buf->entries[position] = mbuf; } else { diff --git a/lib/librte_reorder/rte_reorder.h b/lib/librte_reorder/rte_reorder.h index 6d39710088..ce6cd598e9 100644 --- a/lib/librte_reorder/rte_reorder.h +++ b/lib/librte_reorder/rte_reorder.h @@ -16,6 +16,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -23,6 +24,26 @@ extern "C" { struct rte_reorder_buffer; +typedef uint32_t rte_reorder_seqn_t; +extern int rte_reorder_seqn_dynfield_offset; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Read reorder sequence number from mbuf. + * + * @param mbuf Structure to read from. + * @return pointer to reorder sequence number. + */ +__rte_experimental +static inline rte_reorder_seqn_t * +rte_reorder_seqn(const struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, rte_reorder_seqn_dynfield_offset, + rte_reorder_seqn_t *); +} + /** * Create a new reorder buffer instance * diff --git a/lib/librte_reorder/version.map b/lib/librte_reorder/version.map index 8c0220d324..d902a7fa12 100644 --- a/lib/librte_reorder/version.map +++ b/lib/librte_reorder/version.map @@ -11,3 +11,9 @@ DPDK_21 { local: *; }; + +EXPERIMENTAL { + global: + + rte_reorder_seqn_dynfield_offset; +}; -- 2.23.0