From patchwork Mon Jan 18 20:35:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Boyer X-Patchwork-Id: 86828 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F2038A0A03; Mon, 18 Jan 2021 21:36:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2D80140E72; Mon, 18 Jan 2021 21:35:49 +0100 (CET) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 7525D140E6B for ; Mon, 18 Jan 2021 21:35:48 +0100 (CET) Received: by mail-pj1-f44.google.com with SMTP id l23so10619146pjg.1 for ; Mon, 18 Jan 2021 12:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=24BP+Q67kN0eDqxDt+Vaw15W8iDoxXsAhj9vupDR0os=; b=No08ayfaC/Dzq0KrUvynPlEojm1pGI0tZgE4akuL58N5lhexos8qWIKEVhFym7L9a4 iMsUrMmjoCNItHRe4+mMSiEqV2As+4P3+jVkNEUEEefcS7qtChhAtqdl7J/E2TYD44uw CRlOrUbu8PIC/Eex2rtQ7fozhowIMM3aZED0YKEG5bHSGTrboMP20o82UQAM9lpYlE3/ GLdUMqTB/k1Hwr4jrg/g4hHkV816sUhmLfjoqA7BfWaqKpuvU1zYrzGBCWo+bZAHKPeg yRuBR1bH28W0cqWnxIFXh/606ncS0PDEIuqBLo+6bDW6PTv0eAzbSdxwF16Ib5G15trG K1Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=24BP+Q67kN0eDqxDt+Vaw15W8iDoxXsAhj9vupDR0os=; b=EJJNrBkw/In8pAMGKqUbjFeeKC0NBkg2gSH/xvyo4ryz6wU6ITvNkl8aridE15z5NZ pPE4XjNUHOf2DFyxxVlqP9ykpKZKLopXUKhBqW8Hzro4W22QS3o23NGSPhjxi10u+hP7 AMYWCweUk4fk2xcyprBAyHmIcm2yloY5/dmsGwEBShV6ee0esHzc8Kkj+bJy7QTxoTiY ZYSes1btPk0RkGaF5/kJOmp8SopJZXpcRIuDQlGIwR0OmIgl4ggLk1b5yPdpID/OQvfW tWnaU94V+zgSpZuwnpKvwdF0EeStxS0tPbHNb1JUl0wPQCcnNKANiRgPDdqG1aSYE2Xf Q/XA== X-Gm-Message-State: AOAM533RONevHNXvjTKfy3Ppr5CNVbugG7GryJxkL5QoNWryq+mdcss9 G7I+t9cxgQJJNAQseVbOhutk+z7AjObh/g== X-Google-Smtp-Source: ABdhPJzj49OrvZYUWhyrs/TYS4t5yLn5kZ4fZENhCgjtCYLgAIqJsmybFRmbg518Ux3ZR9YY/Z2ENg== X-Received: by 2002:a17:90a:12c4:: with SMTP id b4mr1126827pjg.98.1611002147507; Mon, 18 Jan 2021 12:35:47 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id g201sm795160pfb.81.2021.01.18.12.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 12:35:47 -0800 (PST) From: Andrew Boyer To: dev@dpdk.org Cc: Alfredo Cardigliano , Andrew Boyer Date: Mon, 18 Jan 2021 12:35:03 -0800 Message-Id: <20210118203508.1332-9-aboyer@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210118203508.1332-1-aboyer@pensando.io> References: <20210118203508.1332-1-aboyer@pensando.io> Subject: [dpdk-dev] [PATCH 08/13] net/ionic: inline queue space function 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" This is a hot-path function. Remove ionic_q_has_space() while here. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_dev.c | 21 +-------------------- drivers/net/ionic/ionic_dev.h | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c index fcb3df482a..e847741632 100644 --- a/drivers/net/ionic/ionic_dev.c +++ b/drivers/net/ionic/ionic_dev.c @@ -474,25 +474,6 @@ ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb, ionic_q_flush(q); } -uint32_t -ionic_q_space_avail(struct ionic_queue *q) -{ - uint32_t avail = q->tail_idx; - - if (q->head_idx >= avail) - avail += q->num_descs - q->head_idx - 1; - else - avail -= q->head_idx + 1; - - return avail; -} - -bool -ionic_q_has_space(struct ionic_queue *q, uint32_t want) -{ - return ionic_q_space_avail(q) >= want; -} - void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index, uint32_t stop_index, void *service_cb_arg) @@ -561,7 +542,7 @@ ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx) rte_spinlock_lock(&lif->adminq_lock); - if (!ionic_q_has_space(adminq, 1)) { + if (ionic_q_space_avail(adminq) < 1) { err = -ENOSPC; goto err_out; } diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h index 55a56434fd..8847d6cad4 100644 --- a/drivers/net/ionic/ionic_dev.h +++ b/drivers/net/ionic/ionic_dev.h @@ -256,11 +256,22 @@ void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa); void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa); void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb, void *cb_arg); -uint32_t ionic_q_space_avail(struct ionic_queue *q); -bool ionic_q_has_space(struct ionic_queue *q, uint32_t want); void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index, uint32_t stop_index, void *service_cb_arg); +static inline uint32_t +ionic_q_space_avail(struct ionic_queue *q) +{ + uint32_t avail = q->tail_idx; + + if (q->head_idx >= avail) + avail += q->num_descs - q->head_idx - 1; + else + avail -= q->head_idx + 1; + + return avail; +} + static inline void ionic_q_flush(struct ionic_queue *q) {