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 AB09FA0545; Tue, 20 Dec 2022 20:27:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5CFC42D30; Tue, 20 Dec 2022 20:27:00 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 8218240A7F for ; Tue, 20 Dec 2022 20:26:55 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BKHShun015480 for ; Tue, 20 Dec 2022 11:26:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=99aplHfMZ8leZuIjOnGnatyZ75mxy4/Hjr68DxQZcaM=; b=Z+AcKQZIWPu10Hd3qozl+wWpM1OMFVWqqXsqmolPbZNC2t+SmSQI3D2RkqoIjpYr62Rt RdrTbKWE0slWdrJHgll7ytB+dh3mne45A4U9ib8JwqHpC898hkUsyek1wtSLmhGwpPa2 CctFvCpXxKeQb5plDcCZlzk2hqN5dAnnqwZNIjBGsw9ldGT78LLC8JRAMO06QD1csy6N +3Em6EKkItCGUixBokObBBNoh1Cri7w4MfiPK4QbUOPli2UOKaTHl6vsHx0w35cypq44 i7fEaBt27ga2Z61yopGn4nOLAdalHMP0yML+rsT2l/oQ9kFwS6YPj79bcwM+t7C+IwLR zw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3mkapj2tpj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Dec 2022 11:26:54 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 20 Dec 2022 11:26:52 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Tue, 20 Dec 2022 11:26:52 -0800 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 1B97F3F706F; Tue, 20 Dec 2022 11:26:52 -0800 (PST) From: Srikanth Yalavarthi To: Srikanth Yalavarthi CC: , , , Subject: [PATCH v3 05/38] ml/cnxk: add support for configure and close Date: Tue, 20 Dec 2022 11:26:12 -0800 Message-ID: <20221220192645.14042-6-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220192645.14042-1-syalavarthi@marvell.com> References: <20221208201806.21893-1-syalavarthi@marvell.com> <20221220192645.14042-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: 5ly8BkPP4zcfaJ2Z7nv3UU_GSm1fdG37 X-Proofpoint-GUID: 5ly8BkPP4zcfaJ2Z7nv3UU_GSm1fdG37 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-20_06,2022-12-20_01,2022-06-22_01 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 Implemented driver functions to configure and close ML devices. Added skeleton code and support to reconfigure ML device. PCI device remove is enabled in device close. Signed-off-by: Srikanth Yalavarthi --- drivers/ml/cnxk/cn10k_ml_dev.c | 2 ++ drivers/ml/cnxk/cn10k_ml_dev.h | 21 ++++++++++++ drivers/ml/cnxk/cn10k_ml_ops.c | 60 ++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/drivers/ml/cnxk/cn10k_ml_dev.c b/drivers/ml/cnxk/cn10k_ml_dev.c index c2e93c9a1a..fd45226add 100644 --- a/drivers/ml/cnxk/cn10k_ml_dev.c +++ b/drivers/ml/cnxk/cn10k_ml_dev.c @@ -65,6 +65,8 @@ cn10k_ml_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_de dev->dequeue_burst = NULL; dev->op_error_get = NULL; + mldev->state = ML_CN10K_DEV_STATE_PROBED; + return 0; pmd_destroy: diff --git a/drivers/ml/cnxk/cn10k_ml_dev.h b/drivers/ml/cnxk/cn10k_ml_dev.h index 13d26373e4..e7fb5fc2e2 100644 --- a/drivers/ml/cnxk/cn10k_ml_dev.h +++ b/drivers/ml/cnxk/cn10k_ml_dev.h @@ -25,10 +25,31 @@ /* Maximum number of segments for IO data */ #define ML_CN10K_MAX_SEGMENTS 1 +/* ML command timeout in seconds */ +#define ML_CN10K_CMD_TIMEOUT 5 + +/* Device configuration state enum */ +enum cn10k_ml_dev_state { + /* Probed and not configured */ + ML_CN10K_DEV_STATE_PROBED = 0, + + /* Configured */ + ML_CN10K_DEV_STATE_CONFIGURED, + + /* Started */ + ML_CN10K_DEV_STATE_STARTED, + + /* Closed */ + ML_CN10K_DEV_STATE_CLOSED +}; + /* Device private data */ struct cn10k_ml_dev { /* Device ROC */ struct roc_ml roc; + + /* Configuration state */ + enum cn10k_ml_dev_state state; }; #endif /* _CN10K_ML_DEV_H_ */ diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c index bad5ad4713..32d38569a3 100644 --- a/drivers/ml/cnxk/cn10k_ml_ops.c +++ b/drivers/ml/cnxk/cn10k_ml_ops.c @@ -25,7 +25,67 @@ cn10k_ml_dev_info_get(struct rte_ml_dev *dev, struct rte_ml_dev_info *dev_info) return 0; } +static int +cn10k_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *conf) +{ + struct rte_ml_dev_info dev_info; + struct cn10k_ml_dev *mldev; + + if (dev == NULL || conf == NULL) + return -EINVAL; + + /* Get CN10K device handle */ + mldev = dev->data->dev_private; + + cn10k_ml_dev_info_get(dev, &dev_info); + if (conf->nb_models > dev_info.max_models) { + plt_err("Invalid device config, nb_models > %d\n", dev_info.max_models); + return -EINVAL; + } + + if (conf->nb_queue_pairs > dev_info.max_queue_pairs) { + plt_err("Invalid device config, nb_queue_pairs > %u\n", dev_info.max_queue_pairs); + return -EINVAL; + } + + if (mldev->state == ML_CN10K_DEV_STATE_PROBED) { + plt_ml_dbg("Configuring ML device, nb_queue_pairs = %u, nb_models = %u", + conf->nb_queue_pairs, conf->nb_models); + } else if (mldev->state == ML_CN10K_DEV_STATE_CONFIGURED) { + plt_ml_dbg("Re-configuring ML device, nb_queue_pairs = %u, nb_models = %u", + conf->nb_queue_pairs, conf->nb_models); + } else if (mldev->state == ML_CN10K_DEV_STATE_STARTED) { + plt_err("Device can't be reconfigured in started state\n"); + return -ENOTSUP; + } else if (mldev->state == ML_CN10K_DEV_STATE_CLOSED) { + plt_err("Device can't be reconfigured after close\n"); + return -ENOTSUP; + } + + mldev->state = ML_CN10K_DEV_STATE_CONFIGURED; + + return 0; +} + +static int +cn10k_ml_dev_close(struct rte_ml_dev *dev) +{ + struct cn10k_ml_dev *mldev; + + if (dev == NULL) + return -EINVAL; + + mldev = dev->data->dev_private; + + mldev->state = ML_CN10K_DEV_STATE_CLOSED; + + /* Remove PCI device */ + return rte_dev_remove(dev->device); +} + struct rte_ml_dev_ops cn10k_ml_ops = { /* Device control ops */ .dev_info_get = cn10k_ml_dev_info_get, + .dev_configure = cn10k_ml_dev_configure, + .dev_close = cn10k_ml_dev_close, }; -- 2.17.1