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 77A6FA0C45; Wed, 22 Sep 2021 04:40:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E5914003F; Wed, 22 Sep 2021 04:40:31 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 3F3534003C for ; Wed, 22 Sep 2021 04:40:29 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4HDjDQ0fykz1DHB2; Wed, 22 Sep 2021 10:39:18 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 22 Sep 2021 10:40:26 +0800 Received: from [10.40.190.165] (10.40.190.165) 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.8; Wed, 22 Sep 2021 10:40:26 +0800 To: Kevin Laatz , CC: , , References: <20210827172048.558704-1-kevin.laatz@intel.com> <20210917152437.3270330-1-kevin.laatz@intel.com> <20210917152437.3270330-9-kevin.laatz@intel.com> From: fengchengwen Message-ID: <13453bcc-945e-140d-3cd3-15d1d6582b9d@huawei.com> Date: Wed, 22 Sep 2021 10:40:25 +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: <20210917152437.3270330-9-kevin.laatz@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.190.165] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v5 08/16] dma/idxd: add start and stop functions for pci devices 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/9/17 23:24, Kevin Laatz wrote: > Add device start/stop functions for DSA devices bound to vfio. For devices > bound to the IDXD kernel driver, these are not required since the IDXD > kernel driver takes care of this. > > Signed-off-by: Bruce Richardson > Signed-off-by: Kevin Laatz > Reviewed-by: Conor Walsh > --- > doc/guides/dmadevs/idxd.rst | 3 +++ > drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 55 insertions(+) > > diff --git a/doc/guides/dmadevs/idxd.rst b/doc/guides/dmadevs/idxd.rst > index abfa5be9ea..a603c5dd22 100644 > --- a/doc/guides/dmadevs/idxd.rst > +++ b/doc/guides/dmadevs/idxd.rst > @@ -150,3 +150,6 @@ The following code shows how the device is configured in > :start-after: Setup of the dmadev device. 8< > :end-before: >8 End of setup of the dmadev device. > :dedent: 1 > + > +Once configured, the device can then be made ready for use by calling the > +``rte_dma_start()`` API. > diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c > index 0216ab80d9..cfb64ce220 100644 > --- a/drivers/dma/idxd/idxd_pci.c > +++ b/drivers/dma/idxd/idxd_pci.c > @@ -59,11 +59,63 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) > return ((state >> WQ_STATE_SHIFT) & WQ_STATE_MASK) == 0x1; > } > > +static int > +idxd_pci_dev_stop(struct rte_dma_dev *dev) > +{ > + struct idxd_dmadev *idxd = dev->dev_private; > + uint8_t err_code; > + > + if (!idxd_is_wq_enabled(idxd)) { > + IDXD_PMD_ERR("Work queue %d already disabled", idxd->qid); > + return -EALREADY; > + } > + > + err_code = idxd_pci_dev_command(idxd, idxd_disable_wq); > + if (err_code || idxd_is_wq_enabled(idxd)) { > + IDXD_PMD_ERR("Failed disabling work queue %d, error code: %#x", > + idxd->qid, err_code); > + return -err_code; The err_code may zero. > + } > + IDXD_PMD_DEBUG("Work queue %d disabled OK", idxd->qid); > + > + return 0; > +} > + > +static int > +idxd_pci_dev_start(struct rte_dma_dev *dev) > +{ > + struct idxd_dmadev *idxd = dev->dev_private; > + uint8_t err_code; > + > + if (idxd_is_wq_enabled(idxd)) { > + IDXD_PMD_WARN("WQ %d already enabled", idxd->qid); > + return 0; > + } > + > + if (idxd->desc_ring == NULL) { > + IDXD_PMD_ERR("WQ %d has not been fully configured", idxd->qid); > + return -EINVAL; > + } > + > + err_code = idxd_pci_dev_command(idxd, idxd_enable_wq); > + if (err_code || !idxd_is_wq_enabled(idxd)) { > + IDXD_PMD_ERR("Failed enabling work queue %d, error code: %#x", > + idxd->qid, err_code); > + return err_code == 0 ? -1 : err_code; The rte_dma_start specified that a negative number is returned for failure. Suggestions return err_code == 0 ? -1 : -err_code; > + } > + > + IDXD_PMD_DEBUG("Work queue %d enabled OK", idxd->qid); > + > + return 0; > +} > + > static const struct rte_dma_dev_ops idxd_pci_ops = { > .dev_dump = idxd_dump, > .dev_configure = idxd_configure, > .vchan_setup = idxd_vchan_setup, > .dev_info_get = idxd_info_get, > + .dev_start = idxd_pci_dev_start, > + .dev_stop = idxd_pci_dev_stop, > }; > > /* each portal uses 4 x 4k pages */ >