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 09476A0C49; Tue, 20 Jul 2021 08:53:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BEBDB4068F; Tue, 20 Jul 2021 08:53:14 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 9D4BE4068B for ; Tue, 20 Jul 2021 08:53:12 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GTTmC70mBzYd3f; Tue, 20 Jul 2021 14:47:23 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 20 Jul 2021 14:53:09 +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.2176.2; Tue, 20 Jul 2021 14:53:09 +0800 To: Jerin Jacob CC: Thomas Monjalon , Ferruh Yigit , "Richardson, Bruce" , Jerin Jacob , Andrew Rybchenko , dpdk-dev , =?UTF-8?Q?Morten_Br=c3=b8rup?= , Nipun Gupta , Hemant Agrawal , "Maxime Coquelin" , Honnappa Nagarahalli , David Marchand , Satananda Burla , Prasun Kapoor , "Ananyev, Konstantin" References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <1626743685-43734-1-git-send-email-fengchengwen@huawei.com> From: fengchengwen Message-ID: Date: Tue, 20 Jul 2021 14:53:08 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.190.165] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v8] dmadev: introduce DMA device library 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" Thanks Jerin, comment inline On 2021/7/20 13:03, Jerin Jacob wrote: > On Tue, Jul 20, 2021 at 6:48 AM Chengwen Feng wrote: >> >> This patch introduce 'dmadevice' which is a generic type of DMA >> device. >> >> The APIs of dmadev library exposes some generic operations which can >> enable configuration and I/O with the DMA devices. >> >> Signed-off-by: Chengwen Feng [snip] >> +int >> +rte_dmadev_info_get(uint16_t dev_id, struct rte_dmadev_info *dev_info) >> +{ >> + const struct rte_dmadev *dev = &rte_dmadevices[dev_id]; >> + int ret; >> + >> + RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL); >> + if (dev_info == NULL) >> + return -EINVAL; >> + >> + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_info_get, -ENOTSUP); >> + memset(dev_info, 0, sizeof(struct rte_dmadev_info)); >> + ret = (*dev->dev_ops->dev_info_get)(dev, dev_info, >> + sizeof(struct rte_dmadev_info)); >> + if (ret != 0) >> + return ret; >> + >> + dev_info->device = dev->device; >> + dev_info->nb_vchans = dev->data->dev_conf.max_vchans; > > This will be updated after configure stage. Yes, the dev_info->nb_vchans hold the number of virtual DMA channel configured. Do you mean add one comment here ? > > >> + >> + return 0; >> +} >> + >> +int >> +rte_dmadev_configure(uint16_t dev_id, const struct rte_dmadev_conf *dev_conf) >> +{ >> + struct rte_dmadev *dev = &rte_dmadevices[dev_id]; >> + struct rte_dmadev_info info; >> + int ret; >> + >> + RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL); >> + if (dev_conf == NULL) >> + return -EINVAL; >> + >> + ret = rte_dmadev_info_get(dev_id, &info); >> + if (ret != 0) { >> + RTE_DMADEV_LOG(ERR, "Device %u get device info fail\n", dev_id); >> + return -EINVAL; >> + } >> + if (dev_conf->max_vchans == 0) { >> + RTE_DMADEV_LOG(ERR, >> + "Device %u configure zero vchans\n", dev_id); >> + return -EINVAL; >> + } >> + if (dev_conf->max_vchans > info.max_vchans) { >> + RTE_DMADEV_LOG(ERR, >> + "Device %u configure too many vchans\n", dev_id); >> + return -EINVAL; >> + } >> + if (dev_conf->enable_silent && >> + !(info.dev_capa & RTE_DMADEV_CAPA_SILENT)) { >> + RTE_DMADEV_LOG(ERR, "Device %u don't support silent\n", dev_id); >> + return -EINVAL; >> + } >> + >> + if (dev->data->dev_started != 0) { >> + RTE_DMADEV_LOG(ERR, >> + "Device %u must be stopped to allow configuration\n", >> + dev_id); >> + return -EBUSY; >> + } > > ethdev and other device class common code handles the reconfigure case. i.e > the application configures N vchan first and reconfigures to N - M > then free the resources > attached to M - N. Please do the same here. DMA is a simple device, I think it's OK to reconfigure at driver-level. PS: If we need support reconfigure at dmadev-level, dmadev should hold the vchan-configuration, and invoke driver's vchan_release to release resources. This may introduce more complexity. >> +int >> +rte_dmadev_dump(uint16_t dev_id, FILE *f) >> +{ >> + const struct rte_dmadev *dev = &rte_dmadevices[dev_id]; >> + struct rte_dmadev_info info; >> + int ret; >> + >> + RTE_DMADEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL); >> + if (f == NULL) >> + return -EINVAL; >> + >> + ret = rte_dmadev_info_get(dev_id, &info); >> + if (ret != 0) { >> + RTE_DMADEV_LOG(ERR, "Device %u get device info fail\n", dev_id); >> + return -EINVAL; >> + } >> + >> + fprintf(f, "DMA Dev %u, '%s' [%s]\n", >> + dev->data->dev_id, >> + dev->data->dev_name, >> + dev->data->dev_started ? "started" : "stopped"); >> + fprintf(f, " dev_capa: 0x%" PRIx64 "\n", info.dev_capa); >> + fprintf(f, " max_vchans_supported: %u\n", info.max_vchans); >> + fprintf(f, " max_vchans_configured: %u\n", info.nb_vchans); >> + fprintf(f, " silent_mode: %s\n", >> + dev->data->dev_conf.enable_silent ? "on" : "off"); > > Probably iterate over each vchan and dumping the at least direction > will be usefull. dmadev hasn't hold vchan-configuration, Need more discussion.