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 66A34426CE; Fri, 6 Oct 2023 10:47:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 210D8402F1; Fri, 6 Oct 2023 10:47:14 +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 F1EE7402A8 for ; Fri, 6 Oct 2023 10:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696582032; 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=IETZ0aMwhKn6bQprbzOAAOZ5to6BWfOs8CbqrIIaC6o=; b=eZjPmKFrK+G9/tNyI825+PcsE3gaYGPq7Zo7pdLyBPtniCfuue5OI9OcsNeipiMwWqGNrJ R6J2Z/gv72yx+iQig+isiz/GiylFLhbQqU/brgxcU42H35D+hJyLWOhQkNVAWtX///qhcI hSSXymnffQxpYLl/C35yBftI4ee07Xw= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-nLIqjT_1MCKtpeSkRi9jkw-1; Fri, 06 Oct 2023 04:47:11 -0400 X-MC-Unique: nLIqjT_1MCKtpeSkRi9jkw-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c135cf1316so18992311fa.1 for ; Fri, 06 Oct 2023 01:47:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696582029; x=1697186829; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IETZ0aMwhKn6bQprbzOAAOZ5to6BWfOs8CbqrIIaC6o=; b=dsOQWqxQvn+uhrNm6tTU5oCNiROfkhjnUHnBxwElzt24kqsNINSEaODW7EJpGPldlz wAuhc+PJmTgQNxBxtpohiR5ov42pgeMMwCX8jKjlliR1zkT2CPPPo8uf5QsU2wkSERfx 4vmMkDoLotPlA0vwRNYqipQFdXTWCfCO7tET4xEtllSH06TVSbCYBrCkxZZ8ZkcvTSLq uvEv6JQSWocqxxQ+LNptKlKUmAdcoSRaQBHOnUoOhM1mCjIjw5g9bPOC+ALvbEv8FCHV iqhUqARorPsQUCWozYRskEU8o73XJB22SGXCd9lmK4KRdmLfVZLusbRjDWBncnhs/S6C gj1A== X-Gm-Message-State: AOJu0Yx+QSy8Nu1nVLgFxLpns2FN2Bpc0OU2VykbHXmLlEmf+5HawPuT B5rfUTaHMdgKMN4ZxvjWqNlxufboIPKb5WGxcTKDTm7160N69wFH6LX2XELoby0pRLoF2gZVidV 0bf316vF2q9p3v4dHDv4= X-Received: by 2002:a2e:2413:0:b0:2c0:ff6:984f with SMTP id k19-20020a2e2413000000b002c00ff6984fmr6077756ljk.49.1696582029511; Fri, 06 Oct 2023 01:47:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAChkCxAyVIUUeZrbA1pCwY255fM2nY6r8uH8AJkkmpk9UEUhIHTJqRq2AQgkXRRD5UXnMtKvymfZi8e08nTk= X-Received: by 2002:a2e:2413:0:b0:2c0:ff6:984f with SMTP id k19-20020a2e2413000000b002c00ff6984fmr6077734ljk.49.1696582029175; Fri, 06 Oct 2023 01:47:09 -0700 (PDT) MIME-Version: 1.0 References: <20230922073825.351453-2-mattias.ronnblom@ericsson.com> <20230928073056.359356-1-mattias.ronnblom@ericsson.com> <20230928073056.359356-2-mattias.ronnblom@ericsson.com> <0c8eaf05-8dc7-4462-a893-2b7019d24fae@lysator.liu.se> In-Reply-To: <0c8eaf05-8dc7-4462-a893-2b7019d24fae@lysator.liu.se> From: David Marchand Date: Fri, 6 Oct 2023 10:46:57 +0200 Message-ID: Subject: Re: [PATCH v5 1/3] lib: introduce dispatcher library To: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= Cc: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= , dev@dpdk.org, Jerin Jacob , techboard@dpdk.org, harry.van.haaren@intel.com, Peter Nilsson , Heng Wang , Naga Harish K S V , Pavan Nikhilesh , Gujjar Abhinandan S , Erik Gabriel Carrillo , Shijith Thotton , Hemant Agrawal , Sachin Saxena , Liang Ma , Peter Mccarthy , Zhirun Yan X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Hello Mattias, On Thu, Oct 5, 2023 at 12:09=E2=80=AFPM Mattias R=C3=B6nnblom wrote: > >> + > >> +deps +=3D ['eventdev'] > >> diff --git a/lib/dispatcher/rte_dispatcher.c b/lib/dispatcher/rte_disp= atcher.c > >> new file mode 100644 > >> index 0000000000..0e69db2b9b > >> --- /dev/null > >> +++ b/lib/dispatcher/rte_dispatcher.c > >> @@ -0,0 +1,708 @@ > >> +/* SPDX-License-Identifier: BSD-3-Clause > >> + * Copyright(c) 2023 Ericsson AB > >> + */ > >> + > >> +#include > >> +#include > >> + > >> +#include > >> +#include > >> +#include > >> +#include > >> +#include > >> + > >> +#include "eventdev_pmd.h" > >> + > >> +#include > >> + > >> +#define EVD_MAX_PORTS_PER_LCORE 4 > >> +#define EVD_MAX_HANDLERS 32 > >> +#define EVD_MAX_FINALIZERS 16 > >> +#define EVD_AVG_PRIO_INTERVAL 2000 > >> +#define EVD_SERVICE_NAME "dispatcher" > >> + > >> +struct rte_dispatcher_lcore_port { > >> + uint8_t port_id; > >> + uint16_t batch_size; > >> + uint64_t timeout; > >> +}; > >> + > >> +struct rte_dispatcher_handler { > >> + int id; > >> + rte_dispatcher_match_t match_fun; > >> + void *match_data; > >> + rte_dispatcher_process_t process_fun; > >> + void *process_data; > >> +}; > >> + > >> +struct rte_dispatcher_finalizer { > >> + int id; > >> + rte_dispatcher_finalize_t finalize_fun; > >> + void *finalize_data; > >> +}; > >> + > >> +struct rte_dispatcher_lcore { > >> + uint8_t num_ports; > >> + uint16_t num_handlers; > >> + int32_t prio_count; > >> + struct rte_dispatcher_lcore_port ports[EVD_MAX_PORTS_PER_LCORE= ]; > >> + struct rte_dispatcher_handler handlers[EVD_MAX_HANDLERS]; > >> + struct rte_dispatcher_stats stats; > >> +} __rte_cache_aligned; > >> + > >> +struct rte_dispatcher { > >> + uint8_t event_dev_id; > >> + int socket_id; > >> + uint32_t service_id; > >> + struct rte_dispatcher_lcore lcores[RTE_MAX_LCORE]; > >> + uint16_t num_finalizers; > >> + struct rte_dispatcher_finalizer finalizers[EVD_MAX_FINALIZERS]= ; > >> +}; > >> + > >> +static int > >> +evd_lookup_handler_idx(struct rte_dispatcher_lcore *lcore, > >> + const struct rte_event *event) > > > > Wrt DPDK coding tyle, indent is a single tab. > > Adding an extra tab is recommended when continuing control statements > > like if()/for()/.. > > > > Sure, but I don't understand why you mention this. I wanted to remind the DPDK coding style which I try to more closely enforce for new code. indent is off in this file (especially for function prototypes with multiple tabs used). > > > On the other hand, max accepted length for a line is 100 columns. > > > > Wdyt of a single line for this specific case? > > > Are you asking why the evd_lookup_handler_idx() function prototype is > not a single line? > > It would make it long, that's why. Even if 100 wide lines are allowed, > it doesn't means the author is forced to use such long lines? I find it more readable. If you want to stick to 80 columns, please comply with a single tab for ind= ent. [snip] > >> +static int > >> +evd_set_service_runstate(struct rte_dispatcher *dispatcher, int state= ) > >> +{ > >> + int rc; > >> + > >> + rc =3D rte_service_component_runstate_set(dispatcher->service_= id, > >> + state); > >> + > >> + if (rc !=3D 0) { > >> + RTE_EDEV_LOG_ERR("Unexpected error %d occurred while s= etting " > >> + "service component run state to %d\n"= , rc, > >> + state); > >> + RTE_ASSERT(0); > > > > Why not propagating the error to callers? > > > > > > The root cause would be a programming error, hence an assertion is more > appropriate way to deal with the situation. Without building RTE_ENABLE_ASSERT (disabled by default), the code later in this function will still be executed. [snip] > >> +typedef void > >> +(*rte_dispatcher_finalize_t)(uint8_t event_dev_id, uint8_t event_port= _id, > >> + void *cb_data); > >> + > >> +/** > >> + * Dispatcher statistics > >> + */ > >> +struct rte_dispatcher_stats { > >> + uint64_t poll_count; > >> + /**< Number of event dequeue calls made toward the event devic= e. */ > > > > We had a number of issues with doxygen post annotations. > > Prefer the prefixed ones. > > > > OK. More readable, too. I just used the postfix syntax since it seemed > the only one used in DPDK. Historically yes, but we started cleaning headers for readability (like in ethdev) and after catching a few errors with postfix comments. --=20 David Marchand