From patchwork Sat May 2 00:02:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 186048 Delivered-To: patch@linaro.org Received: by 2002:a50:3a95:0:0:0:0:0 with SMTP id v21csp791774ecc; Fri, 1 May 2020 17:03:40 -0700 (PDT) X-Google-Smtp-Source: APiQypLSmFus9As7IiToIFQMfIzObtRuoBvhYPjMRUQqjuyQJww8jEUvs8FKTZspS7+z6kZLQyMs X-Received: by 2002:a17:906:a2d3:: with SMTP id by19mr5707536ejb.370.1588377820327; Fri, 01 May 2020 17:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588377820; cv=none; d=google.com; s=arc-20160816; b=vVt1lwVlD/nchfROOon+dEViVAzvyCBavi3QVTf39528UGD++OrBWfMAHtUkLGAS9k nY8AH+MQuaStMM9mH0A53R5ZfYR+u2wawPayI1vbPN8d1Lz/16CSnLvv1u8Del0Dhu8U oPbWEt3BLnudQwYI7ixBOAssO8BbflhN3+x4tG7BTmccYolQD5/RN7QcVYHl1QwO5oeH Ydn1l8ZBudAP6O3E5JH1sUc6wFlAIplRF7kQQbDhTCsHPY5y/bBBykEBTpk3NVDQWWZ2 ArCZv5QFPi765oF70+RrNCkE1O1REvfLPVE1Zl75Q1Gxvty7Uk9U3ZBe2lNczCeSYFmk bxPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=Rj956vN1yF638hwj2zc6Yi/2qgnLZ+Tet/mT5Nq/8A4=; b=Y3QsAFsGUCEcxIaqJ3muyeJ2pGVpRXTDEiqrjzwUMqdcfKYjVJgacXpxZGbMy1PU8y DrxaTOt4ovhqNNHkZjAF9GkM6eoL+y/CCkcuKEkAXC90237uHZf/oEZYj+zHHeAeG/TA NWFye5lMPSaquJd7jEn2DfsWHJrfhZGEfzs9aVd1s1wkPI6qxT01u5P2gysW0uN8VA5b v649IGHTQ9nrOyh01WtP/LslP2HB+rHD2Bj/z+2pONjiRRZ3ulFFZaTkN4OLHawUu4cg CVzGSAtdL8qjnNwNwlc7XcyCj9IBldEpjWLwIGeREMupFUE1pC83dFG57xrnk0pzczCW YxLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id eb6si2971420edb.271.2020.05.01.17.03.40; Fri, 01 May 2020 17:03:40 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 55DC91D9F9; Sat, 2 May 2020 02:03:09 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 4C8E61D99E for ; Sat, 2 May 2020 02:03:05 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D4AB711B3; Fri, 1 May 2020 17:03:04 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.14.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CB4803F305; Fri, 1 May 2020 17:03:04 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, phil.yang@arm.com, harry.van.haaren@intel.com Cc: thomas@monjalon.net, david.marchand@redhat.com, konstantin.ananyev@intel.com, jerinj@marvell.com, hemant.agrawal@nxp.com, gage.eads@intel.com, bruce.richardson@intel.com, honnappa.nagarahalli@arm.com, nd@arm.com Date: Fri, 1 May 2020 19:02:43 -0500 Message-Id: <20200502000245.11071-5-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200502000245.11071-1-honnappa.nagarahalli@arm.com> References: <1587659482-27133-1-git-send-email-phil.yang@arm.com> <20200502000245.11071-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v3 4/6] service: remove redundant code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Phil Yang The service id validation is duplicated, remove the redundant code in the calling functions. Signed-off-by: Phil Yang Reviewed-by: Honnappa Nagarahalli --- lib/librte_eal/common/rte_service.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) -- 2.17.1 Acked-by: Harry van Haaren diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index ed2070267..9c1a1d5cd 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -541,24 +541,12 @@ rte_service_start_with_defaults(void) } static int32_t -service_update(struct rte_service_spec *service, uint32_t lcore, +service_update(uint32_t sid, uint32_t lcore, uint32_t *set, uint32_t *enabled) { - uint32_t i; - int32_t sid = -1; - - for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) { - if ((struct rte_service_spec *)&rte_services[i] == service && - service_valid(i)) { - sid = i; - break; - } - } - - if (sid == -1 || lcore >= RTE_MAX_LCORE) - return -EINVAL; - - if (!lcore_states[lcore].is_service_core) + /* validate ID, or return error value */ + if (sid >= RTE_SERVICE_NUM_MAX || !service_valid(sid) || + lcore >= RTE_MAX_LCORE || !lcore_states[lcore].is_service_core) return -EINVAL; uint64_t sid_mask = UINT64_C(1) << sid; @@ -587,19 +575,15 @@ service_update(struct rte_service_spec *service, uint32_t lcore, int32_t rte_service_map_lcore_set(uint32_t id, uint32_t lcore, uint32_t enabled) { - struct rte_service_spec_impl *s; - SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); uint32_t on = enabled > 0; - return service_update(&s->spec, lcore, &on, 0); + return service_update(id, lcore, &on, 0); } int32_t rte_service_map_lcore_get(uint32_t id, uint32_t lcore) { - struct rte_service_spec_impl *s; - SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); uint32_t enabled; - int ret = service_update(&s->spec, lcore, 0, &enabled); + int ret = service_update(id, lcore, 0, &enabled); if (ret == 0) return enabled; return ret;