DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: mattias.ronnblom@ericsson.com, mb@smartsharesystems.com,
	stephen@networkplumber.org, harry.van.haaren@intel.com,
	roretzla@linux.microsoft.com
Subject: [PATCH v2 4/4] event/dsw: add support for larger port count
Date: Thu, 10 Oct 2024 10:30:22 +0200	[thread overview]
Message-ID: <20241010083022.3437380-5-david.marchand@redhat.com> (raw)
In-Reply-To: <20241010083022.3437380-1-david.marchand@redhat.com>

From: Mattias Rönnblom <mattias.ronnblom@ericsson.com>

Switch from using an open-coded, single-word bitset to using
<rte_bitset.h> to represent which event ports are linked to a
particular event queue.

Besides the cleaner code, this also allow the user to extend the
maximum port count beyond 64, by means of changing an "event_dev.h"

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/event/dsw/dsw_evdev.c | 19 +++++++------------
 drivers/event/dsw/dsw_evdev.h |  3 ++-
 drivers/event/dsw/dsw_event.c |  7 ++++---
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c
index 8a1a2db8ac..bf95cb39cd 100644
--- a/drivers/event/dsw/dsw_evdev.c
+++ b/drivers/event/dsw/dsw_evdev.c
@@ -123,6 +123,7 @@ dsw_queue_setup(struct rte_eventdev *dev, uint8_t queue_id,
 		queue->schedule_type = conf->schedule_type;
 	}
 
+	rte_bitset_init(queue->serving_ports, DSW_MAX_PORTS);
 	queue->num_serving_ports = 0;
 
 	return 0;
@@ -149,20 +150,16 @@ dsw_queue_release(struct rte_eventdev *dev __rte_unused,
 static void
 queue_add_port(struct dsw_queue *queue, uint16_t port_id)
 {
-	uint64_t port_mask = UINT64_C(1) << port_id;
-
-	queue->serving_ports |=	port_mask;
+	rte_bitset_set(queue->serving_ports, port_id);
 	queue->num_serving_ports++;
 }
 
 static bool
 queue_remove_port(struct dsw_queue *queue, uint16_t port_id)
 {
-	uint64_t port_mask = UINT64_C(1) << port_id;
-
-	if (queue->serving_ports & port_mask) {
+	if (rte_bitset_test(queue->serving_ports, port_id)) {
 		queue->num_serving_ports--;
-		queue->serving_ports ^= port_mask;
+		rte_bitset_clear(queue->serving_ports, port_id);
 		return true;
 	}
 
@@ -263,14 +260,12 @@ initial_flow_to_port_assignment(struct dsw_evdev *dsw)
 		struct dsw_queue *queue = &dsw->queues[queue_id];
 		uint16_t flow_hash;
 		for (flow_hash = 0; flow_hash < DSW_MAX_FLOWS; flow_hash++) {
-			uint8_t skip =
-				rte_rand_max(queue->num_serving_ports);
+			uint8_t skip = rte_rand_max(queue->num_serving_ports);
 			uint8_t port_id;
 
 			for (port_id = 0;; port_id++) {
-				uint64_t port_mask = UINT64_C(1) << port_id;
-
-				if (queue->serving_ports & port_mask) {
+				if (rte_bitset_test(queue->serving_ports,
+						    port_id)) {
 					if (skip == 0)
 						break;
 					skip--;
diff --git a/drivers/event/dsw/dsw_evdev.h b/drivers/event/dsw/dsw_evdev.h
index 3f29e53929..e05cee0e6a 100644
--- a/drivers/event/dsw/dsw_evdev.h
+++ b/drivers/event/dsw/dsw_evdev.h
@@ -7,6 +7,7 @@
 
 #include <eventdev_pmd.h>
 
+#include <rte_bitset.h>
 #include <rte_event_ring.h>
 #include <rte_eventdev.h>
 
@@ -237,7 +238,7 @@ struct __rte_cache_aligned dsw_port {
 
 struct dsw_queue {
 	uint8_t schedule_type;
-	uint64_t serving_ports;
+	RTE_BITSET_DECLARE(serving_ports, DSW_MAX_PORTS);
 	uint16_t num_serving_ports;
 
 	alignas(RTE_CACHE_LINE_SIZE) uint8_t flow_to_port_map[DSW_MAX_FLOWS];
diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 67e630ffcb..6eeeb6da93 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -457,9 +457,8 @@ static bool
 dsw_is_serving_port(struct dsw_evdev *dsw, uint8_t port_id, uint8_t queue_id)
 {
 	struct dsw_queue *queue = &dsw->queues[queue_id];
-	uint64_t port_mask = UINT64_C(1) << port_id;
 
-	return queue->serving_ports & port_mask;
+	return rte_bitset_test(queue->serving_ports, port_id);
 }
 
 static bool
@@ -583,7 +582,9 @@ dsw_schedule(struct dsw_evdev *dsw, uint8_t queue_id, uint16_t flow_hash)
 		/* A single-link queue, or atomic/ordered/parallel but
 		 * with just a single serving port.
 		 */
-		port_id = rte_bsf64(queue->serving_ports);
+		port_id = (uint8_t)rte_bitset_find_first_set(
+			queue->serving_ports, DSW_MAX_PORTS
+		);
 
 	DSW_LOG_DP_LINE(DEBUG, "Event with queue_id %d flow_hash %d is scheduled "
 		   "to port %d.", queue_id, flow_hash, port_id);
-- 
2.46.2


  parent reply	other threads:[~2024-10-10  8:31 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 13:13 [RFC v3] eal: add bitset type Mattias Rönnblom
2024-01-31 16:02 ` Stephen Hemminger
2024-01-31 16:28   ` Mattias Rönnblom
2024-01-31 16:06 ` Stephen Hemminger
2024-01-31 18:45   ` Mattias Rönnblom
2024-02-01  8:04     ` Morten Brørup
2024-02-02 10:19       ` Mattias Rönnblom
2024-02-02 12:42         ` Morten Brørup
2024-02-16 10:23 ` [RFC v4 1/4] " Mattias Rönnblom
2024-02-16 10:23   ` [RFC v4 2/4] eal: add bitset test suite Mattias Rönnblom
2024-02-16 10:23   ` [RFC v4 3/4] service: use multi-word bitset to represent service flags Mattias Rönnblom
2024-02-16 10:23   ` [RFC v4 4/4] event/dsw: optimize serving port logic Mattias Rönnblom
2024-05-05  7:33   ` [RFC v5 1/6] eal: add bitset type Mattias Rönnblom
2024-05-05  7:33     ` [RFC v5 2/6] eal: add bitset test suite Mattias Rönnblom
2024-05-05  7:33     ` [RFC v5 3/6] eal: add atomic bitset functions Mattias Rönnblom
2024-05-05  7:33     ` [RFC v5 4/6] eal: add unit tests for atomic bitset operations Mattias Rönnblom
2024-05-05  7:33     ` [RFC v5 5/6] service: use multi-word bitset to represent service flags Mattias Rönnblom
2024-05-05  7:33     ` [RFC v5 6/6] event/dsw: optimize serving port logic Mattias Rönnblom
2024-08-09 20:14     ` [PATCH 1/6] eal: add bitset type Mattias Rönnblom
2024-08-09 20:14       ` [PATCH 2/6] eal: add bitset test suite Mattias Rönnblom
2024-09-12  4:51         ` Tyler Retzlaff
2024-08-09 20:14       ` [PATCH 3/6] eal: add atomic bitset functions Mattias Rönnblom
2024-09-12  4:51         ` Tyler Retzlaff
2024-08-09 20:14       ` [PATCH 4/6] eal: add unit tests for atomic bitset operations Mattias Rönnblom
2024-09-12  4:52         ` Tyler Retzlaff
2024-10-09 20:29           ` Morten Brørup
2024-08-09 20:14       ` [PATCH 5/6] service: use multi-word bitset to represent service flags Mattias Rönnblom
2024-09-12  4:52         ` Tyler Retzlaff
2024-08-09 20:14       ` [PATCH 6/6] event/dsw: add support for larger port count Mattias Rönnblom
2024-09-12  4:53         ` Tyler Retzlaff
2024-08-20 17:09       ` [PATCH 1/6] eal: add bitset type Mattias Rönnblom
2024-09-02 13:55       ` Morten Brørup
2024-09-02 14:46         ` Mattias Rönnblom
2024-09-02 14:49         ` Mattias Rönnblom
2024-09-12  4:51       ` Tyler Retzlaff
2024-09-17  9:36       ` [PATCH v7 0/6] Improve EAL bit operations API Mattias Rönnblom
2024-09-17  9:36         ` [PATCH v7 1/6] dpdk: do not force C linkage on include file dependencies Mattias Rönnblom
2024-09-17 10:48           ` [PATCH v8 0/6] Improve EAL bit operations API Mattias Rönnblom
2024-09-17 10:48             ` [PATCH v8 1/6] dpdk: do not force C linkage on include file dependencies Mattias Rönnblom
2024-09-18  9:04               ` [PATCH v9 0/6] Improve EAL bit operations API Mattias Rönnblom
2024-09-18  9:04                 ` [PATCH v9 1/6] dpdk: do not force C linkage on include file dependencies Mattias Rönnblom
2024-09-19 19:31                   ` [PATCH v10 0/7] Improve EAL bit operations API Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 1/7] buildtools/chkincs: relax C linkage requirement Mattias Rönnblom
2024-09-20  6:24                       ` [PATCH v11 0/7] Improve EAL bit operations API Mattias Rönnblom
2024-09-20  6:24                         ` [PATCH v11 1/7] buildtools/chkincs: relax C linkage requirement Mattias Rönnblom
2024-09-20 10:47                           ` [PATCH v12 0/7] Improve EAL bit operations API Mattias Rönnblom
2024-09-20 10:47                             ` [PATCH v12 1/7] buildtools/chkincs: relax C linkage requirement Mattias Rönnblom
2024-10-03 16:47                               ` Robin Jarry
2024-10-04  7:31                                 ` Mattias Rönnblom
2024-10-04  8:05                                   ` Robin Jarry
2024-10-04  8:40                                     ` Mattias Rönnblom
2024-10-04 11:51                                       ` Robin Jarry
2024-10-04 12:19                                         ` Thomas Monjalon
2024-10-06  8:55                                         ` Mattias Rönnblom
2024-10-06  9:47                                           ` Mattias Rönnblom
2024-10-06 12:25                                             ` Robin Jarry
2024-10-06 13:09                                               ` Robin Jarry
2024-10-06 14:17                                               ` Mattias Rönnblom
2024-10-06 15:58                                                 ` Robin Jarry
2024-10-10 10:24                                                   ` Mattias Rönnblom
2024-10-10 10:39                                                     ` Bruce Richardson
2024-09-20 10:47                             ` [PATCH v12 2/7] dpdk: use C linkage only where appropriate Mattias Rönnblom
2024-09-20 10:47                             ` [PATCH v12 3/7] eal: extend bit manipulation functionality Mattias Rönnblom
2024-09-20 10:47                             ` [PATCH v12 4/7] eal: add unit tests for bit operations Mattias Rönnblom
2024-09-20 10:47                             ` [PATCH v12 5/7] eal: add atomic " Mattias Rönnblom
2024-09-20 10:47                             ` [PATCH v12 6/7] eal: add unit tests for atomic bit access functions Mattias Rönnblom
2024-10-10 10:45                               ` David Marchand
2024-10-10 11:55                                 ` Mattias Rönnblom
2024-10-10 12:14                                   ` David Marchand
2024-10-10 12:35                                     ` Mattias Rönnblom
2024-10-10 13:07                                       ` Thomas Monjalon
2024-10-11  8:35                                   ` David Marchand
2024-10-11 15:06                                 ` Morten Brørup
2024-10-11 15:11                                   ` David Marchand
2024-10-11 15:15                                     ` Morten Brørup
2024-10-11 15:18                                       ` David Marchand
2024-09-20 10:47                             ` [PATCH v12 7/7] eal: extend bitops to handle volatile pointers Mattias Rönnblom
2024-10-09 20:18                             ` [PATCH v12 0/7] Improve EAL bit operations API David Marchand
2024-09-20  6:24                         ` [PATCH v11 2/7] dpdk: use C linkage only where appropriate Mattias Rönnblom
2024-09-20  6:24                         ` [PATCH v11 3/7] eal: extend bit manipulation functionality Mattias Rönnblom
2024-09-20  6:24                         ` [PATCH v11 4/7] eal: add unit tests for bit operations Mattias Rönnblom
2024-09-20  6:24                         ` [PATCH v11 5/7] eal: add atomic " Mattias Rönnblom
2024-09-20  6:24                         ` [PATCH v11 6/7] eal: add unit tests for atomic bit access functions Mattias Rönnblom
2024-09-20  6:24                         ` [PATCH v11 7/7] eal: extend bitops to handle volatile pointers Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 2/7] dpdk: use C linkage only where appropriate Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 3/7] eal: extend bit manipulation functionality Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 4/7] eal: add unit tests for bit operations Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 5/7] eal: add atomic " Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 6/7] eal: add unit tests for atomic bit access functions Mattias Rönnblom
2024-09-19 19:31                     ` [PATCH v10 7/7] eal: extend bitops to handle volatile pointers Mattias Rönnblom
2024-09-18  9:04                 ` [PATCH v9 2/6] eal: extend bit manipulation functionality Mattias Rönnblom
2024-09-18  9:04                 ` [PATCH v9 3/6] eal: add unit tests for bit operations Mattias Rönnblom
2024-09-18  9:04                 ` [PATCH v9 4/6] eal: add atomic " Mattias Rönnblom
2024-09-18  9:04                 ` [PATCH v9 5/6] eal: add unit tests for atomic bit access functions Mattias Rönnblom
2024-09-18  9:04                 ` [PATCH v9 6/6] eal: extend bitops to handle volatile pointers Mattias Rönnblom
2024-09-17 10:48             ` [PATCH v8 2/6] eal: extend bit manipulation functionality Mattias Rönnblom
2024-09-17 10:48             ` [PATCH v8 3/6] eal: add unit tests for bit operations Mattias Rönnblom
2024-09-17 10:48             ` [PATCH v8 4/6] eal: add atomic " Mattias Rönnblom
2024-09-17 10:48             ` [PATCH v8 5/6] eal: add unit tests for atomic bit access functions Mattias Rönnblom
2024-09-17 10:48             ` [PATCH v8 6/6] eal: extend bitops to handle volatile pointers Mattias Rönnblom
2024-09-17  9:36         ` [PATCH v7 2/6] eal: extend bit manipulation functionality Mattias Rönnblom
2024-09-17  9:36         ` [PATCH v7 3/6] eal: add unit tests for bit operations Mattias Rönnblom
2024-09-17  9:36         ` [PATCH v7 4/6] eal: add atomic " Mattias Rönnblom
2024-09-17  9:36         ` [PATCH v7 5/6] eal: add unit tests for atomic bit access functions Mattias Rönnblom
2024-09-17  9:36         ` [PATCH v7 6/6] eal: extend bitops to handle volatile pointers Mattias Rönnblom
2024-10-10  8:30       ` [PATCH v2 0/4] Add bitset type David Marchand
2024-10-10  8:30         ` [PATCH v2 1/4] eal: add " David Marchand
2024-10-11  9:35           ` Mattias Rönnblom
2024-10-16 11:30           ` David Marchand
2024-10-16 13:37             ` Mattias Rönnblom
2024-10-10  8:30         ` [PATCH v2 2/4] bitset: add atomic functions David Marchand
2024-10-10  8:30         ` [PATCH v2 3/4] service: use multi-word bitset to represent service flags David Marchand
2024-10-10  8:30         ` David Marchand [this message]
2024-10-14 15:08         ` [PATCH v2 0/4] Add bitset type David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241010083022.3437380-5-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=mb@smartsharesystems.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).