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 7EE47A0C43; Sat, 23 Oct 2021 01:33:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E739041102; Sat, 23 Oct 2021 01:33:51 +0200 (CEST) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mails.dpdk.org (Postfix) with ESMTP id A70AF410F0 for ; Sat, 23 Oct 2021 01:33:50 +0200 (CEST) Received: by mail-lf1-f46.google.com with SMTP id t9so444710lfd.1 for ; Fri, 22 Oct 2021 16:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nhWH8sMWwIkC+rGhDbYG0OiSJay8K+QWHHdkv3MxELM=; b=N4KUzTO7T0BVNTvA2Hmlqtc8rtvvocN5p/lVM7SCCjp367bahpY/S4PTN1pUeVdcwr 0tpTW+WUwo+SaXQNNTpcdYvxTlSq7B4Lyw+aJ7eXo2TSMxfDVBiUSRlcz9HNsfl2rLn1 H9fU3i+TSXK3m/G/dJRdWf4ZEF/vwsQYRrvj1QBwHQdWQqEMi9vEIFoU+sCxEdk1Aw1u Cnh0Wm0loi5dSRDucVv+2mOoLTF1XQp7Or4zhxmYmX5wSdXfzFs7VWoPMFg3buMlmqun akMTgTqkQwUaQqpTQuCWPKxp9aMkuM/nmbuCbxwLJS5urDyQFVrUUyBfYiziiLqaqm+7 PkQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nhWH8sMWwIkC+rGhDbYG0OiSJay8K+QWHHdkv3MxELM=; b=Fi/wuXPTgGCyHoppp0e1cDi/+6VpT1IybMcJtDFg2fPUjeLAdmhWzkJA0A3CRB86Ws as4Fee9yYqh/Vwoiuu8ZWjLlbheJhsJuGHcpXPD9D/N4+kmO6H3Rqz2ItWTFshAcuUeO 4pTLG2UFQvVBLc6jUuIwI0dfmm1pzw0DdVcNqAWrz2P3T2pqnlVQDZEjWGoLNVY8j7d/ 2RZ7m54k0ubACr5Wzt4GfoRBdoVtOqm5c5zZ3ajVf5tPc1G/qY7CpsZSatOS/kl25jQa Fa0qzN0GTyxuTZdXmrkmrJ7jPX+sfp4wndP6PxrH512M3aYZk8OfsDjI0FopL8l5wngL bJ7A== X-Gm-Message-State: AOAM531Jilqsdo3tx5OUIJJTAyrczRbz1j3tPa+MKGL+LULXgFBdlcte qYe5kaEmdmAdmsqbqQKjwm8= X-Google-Smtp-Source: ABdhPJzlOTrfOPqEXu/QC21CE4Exd+2fsAMEMOUI9Xkc+LUo2ar/C//tqiZ2KVJc89MlMUUMD8pQkw== X-Received: by 2002:ac2:5691:: with SMTP id 17mr2587605lfr.382.1634945630263; Fri, 22 Oct 2021 16:33:50 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id i7sm857017lfe.91.2021.10.22.16.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 16:33:49 -0700 (PDT) Date: Sat, 23 Oct 2021 02:33:49 +0300 From: Dmitry Kozlyuk To: Harman Kalra Cc: , Bruce Richardson , , , Message-ID: <20211023023349.6515943a@sovereign> In-Reply-To: <20211022204934.132186-3-hkalra@marvell.com> References: <20210826145726.102081-1-hkalra@marvell.com> <20211022204934.132186-1-hkalra@marvell.com> <20211022204934.132186-3-hkalra@marvell.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v5 2/6] eal/interrupts: avoid direct access to interrupt handle 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 Sender: "dev" 2021-10-23 02:19 (UTC+0530), Harman Kalra: > Making changes to the interrupt framework to use interrupt handle > APIs to get/set any field. > > Signed-off-by: Harman Kalra > --- > lib/eal/freebsd/eal_interrupts.c | 112 ++++++++---- > lib/eal/linux/eal_interrupts.c | 303 +++++++++++++++++++------------ > 2 files changed, 268 insertions(+), 147 deletions(-) > > diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c > [...] > + /* src->interrupt instance memory allocated > + * depends on from where intr_handle memory > + * is allocated. > + */ > + is_rte_memory = > + !!(rte_intr_instance_alloc_flag_get( > + intr_handle) & RTE_INTR_INSTANCE_F_SHARED); > + if (is_rte_memory == 0) > + src->intr_handle = > + rte_intr_instance_alloc( > + RTE_INTR_INSTANCE_F_UNSHARED); > + else if (is_rte_memory == 1) > + src->intr_handle = > + rte_intr_instance_alloc( > + RTE_INTR_INSTANCE_F_SHARED); > + else > + RTE_LOG(ERR, EAL, "Failed to get mem allocator\n"); Why not just get the flags and use them as-is to allocate a new instance? If you care to use only these flags even if there are others, a mask can be used. > + > + if (src->intr_handle == NULL) { > + RTE_LOG(ERR, EAL, "Can not create intr instance\n"); > + free(callback); > + ret = -ENOMEM; > + goto fail; > + } else { > + rte_intr_instance_copy(src->intr_handle, > + intr_handle); > + TAILQ_INIT(&src->callbacks); > + TAILQ_INSERT_TAIL(&intr_sources, src, > + next); > + } > } > } > [...] > diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c > [...] > @@ -522,12 +547,35 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle, > free(callback); > ret = -ENOMEM; > } else { > - src->intr_handle = *intr_handle; > - TAILQ_INIT(&src->callbacks); > - TAILQ_INSERT_TAIL(&(src->callbacks), callback, next); > - TAILQ_INSERT_TAIL(&intr_sources, src, next); > - wake_thread = 1; > - ret = 0; > + /* src->interrupt instance memory allocated depends on > + * from where intr_handle memory is allocated. > + */ > + is_rte_memory = > + !!(rte_intr_instance_alloc_flag_get(intr_handle) & > + RTE_INTR_INSTANCE_F_SHARED); > + if (is_rte_memory == 0) > + src->intr_handle = rte_intr_instance_alloc( > + RTE_INTR_INSTANCE_F_UNSHARED); > + else if (is_rte_memory == 1) > + src->intr_handle = rte_intr_instance_alloc( > + RTE_INTR_INSTANCE_F_SHARED); > + else > + RTE_LOG(ERR, EAL, "Failed to get mem allocator\n"); Likewise. > + > + if (src->intr_handle == NULL) { > + RTE_LOG(ERR, EAL, "Can not create intr instance\n"); > + free(callback); > + ret = -ENOMEM; > + } else { > + rte_intr_instance_copy(src->intr_handle, > + intr_handle); > + TAILQ_INIT(&src->callbacks); > + TAILQ_INSERT_TAIL(&(src->callbacks), callback, > + next); > + TAILQ_INSERT_TAIL(&intr_sources, src, next); > + wake_thread = 1; > + ret = 0; > + } > } > } > [...] > + if (intr_handle && rte_intr_type_get(intr_handle) == > + RTE_INTR_HANDLE_VDEV) > return 0; Nit: you have removed `intr_handle` condition everywhere except here.