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 E9C9BA0C45; Wed, 20 Oct 2021 09:11:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88AEB40150; Wed, 20 Oct 2021 09:11:07 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 19C7B40142 for ; Wed, 20 Oct 2021 09:11:06 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HZ1qp2T9zzbhFH; Wed, 20 Oct 2021 15:06:30 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Wed, 20 Oct 2021 15:10:58 +0800 Received: from [127.0.0.1] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Wed, 20 Oct 2021 15:10:58 +0800 To: Kevin Laatz , CC: , , , References: <20210827172048.558704-1-kevin.laatz@intel.com> <20211019141041.1890983-1-kevin.laatz@intel.com> <20211019141041.1890983-5-kevin.laatz@intel.com> From: fengchengwen Message-ID: Date: Wed, 20 Oct 2021 15:10:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20211019141041.1890983-5-kevin.laatz@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v10 04/16] dma/idxd: create dmadev instances on bus probe 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" On 2021/10/19 22:10, Kevin Laatz wrote: > When a suitable device is found during the bus scan/probe, create a dmadev > instance for each HW queue. Internal structures required for device > creation are also added. > [snip] > static void * > idxd_bus_mmap_wq(struct rte_dsa_device *dev) > { > @@ -206,6 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev) > return -1; > idxd.max_batch_size = ret; > idxd.qid = dev->addr.wq_id; > + idxd.u.bus.dsa_id = dev->addr.device_id; > idxd.sva_support = 1; > > idxd.portal = idxd_bus_mmap_wq(dev); > @@ -214,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev) > return -ENOENT; > } > > + ret = idxd_dmadev_create(dev->wq_name, &dev->device, &idxd, &idxd_bus_ops); > + if (ret) { > + IDXD_PMD_ERR("Failed to create rawdev %s", dev->wq_name); rawdev -> dmadev > + return ret; > + } > + > return 0; > } > > diff --git a/drivers/dma/idxd/idxd_common.c b/drivers/dma/idxd/idxd_common.c > index e00ddbe5ef..5abff34292 100644 > --- a/drivers/dma/idxd/idxd_common.c > +++ b/drivers/dma/idxd/idxd_common.c > @@ -2,10 +2,71 @@ > * Copyright 2021 Intel Corporation > */ > > +#include > +#include > #include > > #include "idxd_internal.h" > > +#define IDXD_PMD_NAME_STR "dmadev_idxd" > + > +int > +idxd_dmadev_create(const char *name, struct rte_device *dev, > + const struct idxd_dmadev *base_idxd, > + const struct rte_dma_dev_ops *ops) > +{ > + struct idxd_dmadev *idxd = NULL; > + struct rte_dma_dev *dmadev = NULL; > + int ret = 0; > + > + if (!name) { > + IDXD_PMD_ERR("Invalid name of the device!"); > + ret = -EINVAL; > + goto cleanup; > + } > + > + /* Allocate device structure */ > + dmadev = rte_dma_pmd_allocate(name, dev->numa_node, sizeof(struct idxd_dmadev)); > + if (dmadev == NULL) { > + IDXD_PMD_ERR("Unable to allocate raw device"); raw -> dma Better check the 'raw' keyword in the patch set. > + ret = -ENOMEM; > + goto cleanup; > + } > + dmadev->dev_ops = ops; > + dmadev->device = dev; > + > + idxd = dmadev->data->dev_private; > + *idxd = *base_idxd; /* copy over the main fields already passed in */ > + idxd->dmadev = dmadev; > + > + /* allocate batch index ring and completion ring. > + * The +1 is because we can never fully use > + * the ring, otherwise read == write means both full and empty. > + */ > + idxd->batch_comp_ring = rte_zmalloc(NULL, (sizeof(idxd->batch_idx_ring[0]) + > + sizeof(idxd->batch_comp_ring[0])) * (idxd->max_batches + 1), > + sizeof(idxd->batch_comp_ring[0])); infer the batch_comp_ring will access by hardware, maybe better use rte_zmalloc_socket() because rte_zmalloc will use rte_socket_id() and it may at diff socket when call. > + if (idxd->batch_comp_ring == NULL) { > + IDXD_PMD_ERR("Unable to reserve memory for batch data\n"); > + ret = -ENOMEM; > [snip]