From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 965A545B00; Thu, 10 Oct 2024 10:31:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 778F64065A; Thu, 10 Oct 2024 10:31:04 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 780994065D for ; Thu, 10 Oct 2024 10:31:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728549062; 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=RGDPolikfXt2Se17+JlJF2CPnxYtihqTuJPT8p+Qz8o=; b=XBcPrnlZulOuU/CojsnuN+HZeXlhqXccnTJw33erbV37b+OJ1nn+vZYX2xQcB7UR24xYT3 Xf6MIK+lcI8f0UaabTE+SWSwLlymib7sR61JRtdI603YER7AqkcYOEWZJZ+m+MPrCna8tO huWCbENMw2TnUkTiS0agAHQkJtrw1cU= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-jDJ5LpcVMbe5bY4E1Y5xzQ-1; Thu, 10 Oct 2024 04:30:53 -0400 X-MC-Unique: jDJ5LpcVMbe5bY4E1Y5xzQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97BF419560A2; Thu, 10 Oct 2024 08:30:52 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.68]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4114B19560AE; Thu, 10 Oct 2024 08:30:50 +0000 (UTC) From: David Marchand 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 Message-ID: <20241010083022.3437380-5-david.marchand@redhat.com> In-Reply-To: <20241010083022.3437380-1-david.marchand@redhat.com> References: <20240809201440.590464-1-mattias.ronnblom@ericsson.com> <20241010083022.3437380-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Mattias Rönnblom Switch from using an open-coded, single-word bitset to using 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 Acked-by: Tyler Retzlaff --- 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 +#include #include #include @@ -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