From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CB7EDA0562; Sun, 29 Mar 2020 08:48:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD92D1C07F; Sun, 29 Mar 2020 08:47:46 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 733FA1C07F for ; Sun, 29 Mar 2020 08:47:45 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from orika@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Mar 2020 09:47:42 +0300 Received: from pegasus04.mtr.labs.mlnx. (pegasus04.mtr.labs.mlnx [10.210.16.126]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02T6lSO0004381; Sun, 29 Mar 2020 09:47:41 +0300 From: Ori Kam To: jerinj@marvell.com, xiang.w.wang@intel.com Cc: dev@dpdk.org, pbhagavatula@marvell.com, shahafs@mellanox.com, hemant.agrawal@nxp.com, opher@mellanox.com, alexr@mellanox.com, dovrat@marvell.com, pkapoor@marvell.com, nipun.gupta@nxp.com, bruce.richardson@intel.com, yang.a.hong@intel.com, harry.chang@intel.com, gu.jian1@zte.com.cn, shanjiangh@chinatelecom.cn, zhangy.yun@chinatelecom.cn, lixingfu@huachentel.com, wushuai@inspur.com, yuyingxia@yxlink.com, fanchenggang@sunyainfo.com, davidfgao@tencent.com, liuzhong1@chinaunicom.cn, zhaoyong11@huawei.com, oc@yunify.com, jim@netgate.com, hongjun.ni@intel.com, j.bromhead@titan-ic.com, deri@ntop.org, fc@napatech.com, arthur.su@lionic.com, thomas@monjalon.net, orika@mellanox.com Date: Sun, 29 Mar 2020 06:47:18 +0000 Message-Id: <1585464438-111285-5-git-send-email-orika@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1585464438-111285-1-git-send-email-orika@mellanox.com> References: <1585464438-111285-1-git-send-email-orika@mellanox.com> Subject: [dpdk-dev] [PATCH v1 4/4] regexdev: implement regex rte level functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" This commit implements all the RegEx public API. Signed-off-by: Ori Kam --- lib/librte_regexdev/rte_regexdev.c | 298 +++++++++++++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) diff --git a/lib/librte_regexdev/rte_regexdev.c b/lib/librte_regexdev/rte_regexdev.c index 4396bb5..72f18fb 100644 --- a/lib/librte_regexdev/rte_regexdev.c +++ b/lib/librte_regexdev/rte_regexdev.c @@ -76,3 +76,301 @@ { regex_devices[dev->dev_id] = NULL; } + +uint8_t +rte_regexdev_count(void) +{ + int i; + int count = 0; + + for (i = 0; i < RTE_MAX_REGEXDEV_DEVS; i++) { + if (regex_devices[i] != NULL) + count++; + } + return count; +} + +int +rte_regexdev_get_dev_id(const char *name) +{ + int i; + int id = -EINVAL; + + if (name == NULL) + return -EINVAL; + for (i = 0; i < RTE_MAX_REGEXDEV_DEVS; i++) { + if (regex_devices[i] != NULL) + if (strcmp(name, regex_devices[i]->dev_name)) { + id = regex_devices[i]->dev_id; + break; + } + } + return id; +} + +int +rte_regexdev_info_get(uint8_t dev_id, struct rte_regexdev_info *dev_info) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (dev_info == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_info_get == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_info_get + (regex_devices[dev_id], dev_info); +} + +int +rte_regexdev_configure(uint8_t dev_id, const struct rte_regexdev_config *cfg) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (cfg == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_configure == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_configure + (regex_devices[dev_id], cfg); +} + +int +rte_regexdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, + const struct rte_regexdev_qp_conf *qp_conf) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_qp_setup == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_qp_setup + (regex_devices[dev_id], queue_pair_id, qp_conf); +} + +int +rte_regexdev_start(uint8_t dev_id) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_start == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_start(regex_devices[dev_id]); +} + +void +rte_regexdev_stop(uint8_t dev_id) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return; + if (regex_devices[dev_id] == NULL) + return; + regex_devices[dev_id]->dev_ops->dev_stop(regex_devices[dev_id]); +} + +int +rte_regexdev_close(uint8_t dev_id) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_close == NULL) + return -ENOTSUP; + regex_devices[dev_id]->dev_ops->dev_close(regex_devices[dev_id]); + return 0; +} + +int +rte_regexdev_attr_get(uint8_t dev_id, enum rte_regexdev_attr_id attr_id, + void *attr_value) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_attr_get == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_attr_get + (regex_devices[dev_id], attr_id, attr_value); +} + +int +rte_regexdev_attr_set(uint8_t dev_id, enum rte_regexdev_attr_id attr_id, + const void *attr_value) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_attr_set == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_attr_set + (regex_devices[dev_id], attr_id, attr_value); +} + +int +rte_regexdev_rule_db_update(uint8_t dev_id, + const struct rte_regexdev_rule *rules, + uint32_t nb_rules) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_rule_db_update == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_rule_db_update + (regex_devices[dev_id], rules, nb_rules); +} + +int +rte_regexdev_rule_db_compile_activate(uint8_t dev_id) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_rule_db_compile_activate == + NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_rule_db_compile_activate + (regex_devices[dev_id]); +} + +int +rte_regexdev_rule_db_import(uint8_t dev_id, const char *rule_db, + uint32_t rule_db_len) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (rule_db == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_db_import == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_db_import + (regex_devices[dev_id], rule_db, rule_db_len); +} + +int +rte_regexdev_rule_db_export(uint8_t dev_id, char *rule_db) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_db_export == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_db_export + (regex_devices[dev_id], rule_db); +} + +int +rte_regexdev_xstats_names_get(uint8_t dev_id, + struct rte_regexdev_xstats_map *xstats_map) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (xstats_map == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_xstats_names_get == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_xstats_names_get + (regex_devices[dev_id], xstats_map); +} + +int +rte_regexdev_xstats_get(uint8_t dev_id, const uint16_t *ids, + uint64_t *values, uint16_t n) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_xstats_get == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_xstats_get + (regex_devices[dev_id], ids, values, n); +} + +int +rte_regexdev_xstats_by_name_get(uint8_t dev_id, const char *name, + uint16_t *id, uint64_t *value) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_xstats_by_name_get == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_xstats_by_name_get + (regex_devices[dev_id], name, id, value); +} + +int +rte_regexdev_xstats_reset(uint8_t dev_id, const uint16_t *ids, + uint16_t nb_ids) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_xstats_reset == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_xstats_reset + (regex_devices[dev_id], ids, nb_ids); +} + +int +rte_regexdev_selftest(uint8_t dev_id) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_selftest == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_selftest + (regex_devices[dev_id]); +} + +int +rte_regexdev_dump(uint8_t dev_id, FILE *f) +{ + if (dev_id >= RTE_MAX_REGEXDEV_DEVS) + return -EINVAL; + if (regex_devices[dev_id] == NULL) + return -EINVAL; + if (f == NULL) + return -EINVAL; + if (regex_devices[dev_id]->dev_ops->dev_dump == NULL) + return -ENOTSUP; + return regex_devices[dev_id]->dev_ops->dev_dump + (regex_devices[dev_id], f); +} + +uint16_t +rte_regexdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, + struct rte_regex_ops **ops, uint16_t nb_ops) +{ + return regex_devices[dev_id]->enqueue(regex_devices[dev_id], qp_id, + ops, nb_ops); +} + +uint16_t +rte_regexdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id, + struct rte_regex_ops **ops, uint16_t nb_ops) +{ + return regex_devices[dev_id]->dequeue(regex_devices[dev_id], qp_id, + ops, nb_ops); +} -- 1.8.3.1