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 2A7A5A00C2; Thu, 3 Feb 2022 09:24:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ACC0C4014F; Thu, 3 Feb 2022 09:24:20 +0100 (CET) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 5627140143 for ; Thu, 3 Feb 2022 09:24:19 +0100 (CET) Received: by mail-pg1-f169.google.com with SMTP id q132so1684871pgq.7 for ; Thu, 03 Feb 2022 00:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=J34MTgL+T2rkWtqd5qZO2JyskvWJqvLEQQPUyUyWvpw=; b=C+/+hN2HaE2xUU2PEcwJx06e3CbM/JNRzN8PAT/Zn5+mEiko25WISJogsD6H4LEOeI De40HgpcRk6PSp1Ot96uKkG83aVzpGStzklJYSgr0SdCB9IKsJL2hX3HNahYqQkDdnEE 838QCXz0Yppc2Bh7hZdjwzuDtyyES4tUBu7dyr+NcEQnrImKmCy8pPVSE9wVAULCX3um VBfVGRjrEWaIQTj4W23nGHIjAf+0ghCmiVK6XxIJw5NVYnbxLiA+kYr2x1fWMurFF0Cf BNOrvIsEHBvy/2U36LXtj4mcJr0KLUzxdlBX+6aKvWFzxhEmd6TmV/vUivUWAhfmiLxD +rJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=J34MTgL+T2rkWtqd5qZO2JyskvWJqvLEQQPUyUyWvpw=; b=qpKy4f0Q/k2Fzda5XnWRBvQCCfku54u+dqnYw9FKwi2OiXEL0cfzds+zCH/shWI8QM Bkc4nUImMbVUMAD1jHyJjDOvswm9+AWvxKIirzw/Uh4QNSKNsDRfvWOn1I5kqbhTBIxB POIz4GJGVeGWwRj7bX4WLMtioaOMSzWTqwfWTFLYKgW7pBIy9aIG70TK4akyvdDlLPmo g14tv8fZ7kfavcdYO+vX9WSkhxMmcjfsjVpRGsokoG3KMiq86qzLi6gQfzO8+aE/8ndc jDMglA1bx9DTgc0Idnq9QWfBHT5UTjh8L19j6q4nE5sec7WM2w5bqFv2r67XtHRqBawc DJVw== X-Gm-Message-State: AOAM532LyrDNbVhzGRTGOS71rJ0HfGV2WnE+tATjDz14o5ZDl3YYITJs BkjCKSURHVdKvcyQ0jmGWZrOps+bhHjJHQ== X-Google-Smtp-Source: ABdhPJzJ3D2u+RGT6XM7QEvIkVA8CCfZCN/bSDb8lbmw6UsxWSHAAHDtrejXoM7tMirv8J+P3gfQGg== X-Received: by 2002:a05:6a00:2129:: with SMTP id n9mr33782471pfj.71.1643876658148; Thu, 03 Feb 2022 00:24:18 -0800 (PST) Received: from kparameshwa-a01.vmware.com.com ([49.206.11.18]) by smtp.gmail.com with ESMTPSA id q11sm27671502pfk.149.2022.02.03.00.24.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Feb 2022 00:24:17 -0800 (PST) From: Kumara Parameshwaran To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kumara Parameshwaran Subject: [PATCH v1] drivers/net: use internal API to get eth dev from name Date: Thu, 3 Feb 2022 13:54:12 +0530 Message-Id: <20220203082412.79028-1-kumaraparamesh92@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 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: Kumara Parameshwaran Make changes in PMDs to use the new function where rte_eth_dev_get_port_by_name is used to get port_id to access rte_eth_devices Signed-off-by: Kumara Parameshwaran --- v1 * Replace rte_eth_get_get_port_by_name in PMDs with rte_eth_dev_get_by_name where port_id is used to retrieve rte_eth_dev data structure drivers/net/bonding/rte_eth_bond_api.c | 10 +++++----- drivers/net/ipn3ke/ipn3ke_ethdev.c | 9 +++------ drivers/net/memif/rte_eth_memif.c | 7 ++----- drivers/net/softnic/rte_eth_softnic_thread.c | 8 +++----- drivers/net/tap/rte_eth_tap.c | 7 ++----- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 8840d9e17b..b78867b125 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -151,8 +151,8 @@ int rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) { struct bond_dev_private *internals; + struct rte_eth_dev *bond_dev; char devargs[52]; - uint16_t port_id; int ret; if (name == NULL) { @@ -169,8 +169,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) if (ret) return ret; - ret = rte_eth_dev_get_port_by_name(name, &port_id); - RTE_ASSERT(!ret); + bond_dev = rte_eth_dev_get_by_name(name); + RTE_ASSERT(bond_dev); /* * To make bond_ethdev_configure() happy we need to free the @@ -178,11 +178,11 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) * * Also see comment in bond_ethdev_configure(). */ - internals = rte_eth_devices[port_id].data->dev_private; + internals = bond_dev->data->dev_private; rte_kvargs_free(internals->kvlist); internals->kvlist = NULL; - return port_id; + return bond_dev->data->port_id; } int diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c index 014e438dd5..550a8b0466 100644 --- a/drivers/net/ipn3ke/ipn3ke_ethdev.c +++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c @@ -469,7 +469,6 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev) struct ipn3ke_hw *hw; struct rte_eth_dev *i40e_eth; struct ifpga_rawdev *ifpga_dev; - uint16_t port_id; int i, j, retval; char *fvl_bdf; @@ -519,14 +518,12 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev) for (; j < 8; j++) { fvl_bdf = ifpga_dev->fvl_bdf[j]; - retval = rte_eth_dev_get_port_by_name(fvl_bdf, - &port_id); - if (retval) { + i40e_eth = rte_eth_dev_get_by_name(fvl_bdf); + if (!i40e_eth) { continue; } else { - i40e_eth = &rte_eth_devices[port_id]; rpst.i40e_pf_eth = i40e_eth; - rpst.i40e_pf_eth_port_id = port_id; + rpst.i40e_pf_eth_port_id = i40e_eth->data->port_id; j++; break; diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index d3459c5007..5700c6a2bf 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -88,17 +88,14 @@ memif_mp_send_region(const struct rte_mp_msg *msg, const void *peer) const struct mp_region_msg *msg_param = (const struct mp_region_msg *)msg->param; struct rte_mp_msg reply; struct mp_region_msg *reply_param = (struct mp_region_msg *)reply.param; - uint16_t port_id; - int ret; /* Get requested port */ - ret = rte_eth_dev_get_port_by_name(msg_param->port_name, &port_id); - if (ret) { + dev = rte_eth_dev_get_by_name(msg_param->port_name); + if (!dev) { MIF_LOG(ERR, "Failed to get port id for %s", msg_param->port_name); return -1; } - dev = &rte_eth_devices[port_id]; proc_private = dev->process_private; memset(&reply, 0, sizeof(reply)); diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index a8c26a5b23..4a9f2fa6a4 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -129,14 +129,12 @@ thread_sc_service_up(struct pmd_internals *softnic, uint32_t thread_id) struct softnic_thread *t = &softnic->thread[thread_id]; struct rte_eth_dev *dev; int status; - uint16_t port_id; /* service params */ - status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id); - if (status) - return status; + dev = rte_eth_dev_get_by_name(softnic->params.name); + if (!dev) + return -EINVAL; - dev = &rte_eth_devices[port_id]; snprintf(service_params.name, sizeof(service_params.name), "%s_%u", softnic->params.name, thread_id); diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 111037de65..bc3d56a311 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -2428,19 +2428,16 @@ tap_mp_sync_queues(const struct rte_mp_msg *request, const void *peer) (const struct ipc_queues *)request->param; struct ipc_queues *reply_param = (struct ipc_queues *)reply.param; - uint16_t port_id; int queue; - int ret; /* Get requested port */ TAP_LOG(DEBUG, "Received IPC request for %s", request_param->port_name); - ret = rte_eth_dev_get_port_by_name(request_param->port_name, &port_id); - if (ret) { + dev = rte_eth_dev_get_by_name(request_param->port_name); + if (!dev) { TAP_LOG(ERR, "Failed to get port id for %s", request_param->port_name); return -1; } - dev = &rte_eth_devices[port_id]; process_private = dev->process_private; /* Fill file descriptors for all queues */ -- 2.17.1