Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/75997/?format=api
http://patches.dpdk.org/api/patches/75997/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200826151445.51500-3-cristian.dumitrescu@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20200826151445.51500-3-cristian.dumitrescu@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200826151445.51500-3-cristian.dumitrescu@intel.com", "date": "2020-08-26T15:14:07", "name": "[02/40] pipeline: add input port", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "74ac3ff506c0c3ee8f784386e334b582b97b8154", "submitter": { "id": 19, "url": "http://patches.dpdk.org/api/people/19/?format=api", "name": "Cristian Dumitrescu", "email": "cristian.dumitrescu@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200826151445.51500-3-cristian.dumitrescu@intel.com/mbox/", "series": [ { "id": 11806, "url": "http://patches.dpdk.org/api/series/11806/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=11806", "date": "2020-08-26T15:14:05", "name": "Pipeline alignment with the P4 language", "version": 1, "mbox": "http://patches.dpdk.org/series/11806/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/75997/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/75997/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 69CCBA04B4;\n\tWed, 26 Aug 2020 17:15:24 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 355B71BECC;\n\tWed, 26 Aug 2020 17:15:08 +0200 (CEST)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by dpdk.org (Postfix) with ESMTP id ED528A3\n for <dev@dpdk.org>; Wed, 26 Aug 2020 17:15:02 +0200 (CEST)", "from orsmga004.jf.intel.com ([10.7.209.38])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 26 Aug 2020 08:14:49 -0700", "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com) ([10.237.223.107])\n by orsmga004.jf.intel.com with ESMTP; 26 Aug 2020 08:14:48 -0700" ], "IronPort-SDR": [ "\n o3cn974pRHGdu1PdcGMEqIEujRweD/KBXE4hFABRvqlX3tBgS4HBGNzOLTcEYSyzRitq7s3m3T\n 8NHR3tLQvNBA==", "\n c+xUf4Y8yPlvIc25ohZcCktWkaHCdB0rWY0rzKh379BflD9sj7tkvG4Gbk8BNh5RhzX5ChZ8tn\n zsPhidH31RtQ==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6000,8403,9725\"; a=\"153879480\"", "E=Sophos;i=\"5.76,356,1592895600\"; d=\"scan'208\";a=\"153879480\"", "E=Sophos;i=\"5.76,356,1592895600\"; d=\"scan'208\";a=\"444081258\"" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>", "To": "dev@dpdk.org", "Date": "Wed, 26 Aug 2020 16:14:07 +0100", "Message-Id": "<20200826151445.51500-3-cristian.dumitrescu@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20200826151445.51500-1-cristian.dumitrescu@intel.com>", "References": "<20200826151445.51500-1-cristian.dumitrescu@intel.com>", "Subject": "[dpdk-dev] [PATCH 02/40] pipeline: add input port", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Add input ports to the pipeline. Each port instantiates a port type\nthat defines the port operations, e.g. ethdev port, PCAP port, etc.\nThe RX interface is single packet, with packet batching internally\nfor performance.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_pipeline_version.map | 2 +\n lib/librte_pipeline/rte_swx_pipeline.c | 209 +++++++++++++++++++\n lib/librte_pipeline/rte_swx_pipeline.h | 54 +++++\n lib/librte_port/Makefile | 1 +\n lib/librte_port/meson.build | 3 +-\n lib/librte_port/rte_swx_port.h | 118 +++++++++++\n 6 files changed, 386 insertions(+), 1 deletion(-)\n create mode 100644 lib/librte_port/rte_swx_port.h", "diff": "diff --git a/lib/librte_pipeline/rte_pipeline_version.map b/lib/librte_pipeline/rte_pipeline_version.map\nindex 39593f1ee..a9ebd3b1f 100644\n--- a/lib/librte_pipeline/rte_pipeline_version.map\n+++ b/lib/librte_pipeline/rte_pipeline_version.map\n@@ -56,6 +56,8 @@ EXPERIMENTAL {\n \trte_table_action_ttl_read;\n \trte_table_action_crypto_sym_session_get;\n \trte_swx_pipeline_config;\n+\trte_swx_pipeline_port_in_type_register;\n+\trte_swx_pipeline_port_in_config;\n \trte_swx_pipeline_build;\n \trte_swx_pipeline_free;\n };\ndiff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c\nindex 2319d4570..5b1559209 100644\n--- a/lib/librte_pipeline/rte_swx_pipeline.c\n+++ b/lib/librte_pipeline/rte_swx_pipeline.c\n@@ -5,6 +5,7 @@\n #include <string.h>\n #include <stdio.h>\n #include <errno.h>\n+#include <sys/queue.h>\n \n #include <rte_common.h>\n \n@@ -19,14 +20,206 @@ do { \\\n #define CHECK_NAME(name, err_code) \\\n \tCHECK((name) && (name)[0], err_code)\n \n+/*\n+ * Input port.\n+ */\n+struct port_in_type {\n+\tTAILQ_ENTRY(port_in_type) node;\n+\tchar name[RTE_SWX_NAME_SIZE];\n+\tstruct rte_swx_port_in_ops ops;\n+};\n+\n+TAILQ_HEAD(port_in_type_tailq, port_in_type);\n+\n+struct port_in {\n+\tTAILQ_ENTRY(port_in) node;\n+\tstruct port_in_type *type;\n+\tvoid *obj;\n+\tuint32_t id;\n+};\n+\n+TAILQ_HEAD(port_in_tailq, port_in);\n+\n+struct port_in_runtime {\n+\trte_swx_port_in_pkt_rx_t pkt_rx;\n+\tvoid *obj;\n+};\n+\n /*\n * Pipeline.\n */\n struct rte_swx_pipeline {\n+\tstruct port_in_type_tailq port_in_types;\n+\tstruct port_in_tailq ports_in;\n+\n+\tstruct port_in_runtime *in;\n+\n+\tuint32_t n_ports_in;\n \tint build_done;\n \tint numa_node;\n };\n \n+/*\n+ * Input port.\n+ */\n+static struct port_in_type *\n+port_in_type_find(struct rte_swx_pipeline *p, const char *name)\n+{\n+\tstruct port_in_type *elem;\n+\n+\tif (!name)\n+\t\treturn NULL;\n+\n+\tTAILQ_FOREACH(elem, &p->port_in_types, node)\n+\t\tif (strcmp(elem->name, name) == 0)\n+\t\t\treturn elem;\n+\n+\treturn NULL;\n+}\n+\n+int\n+rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,\n+\t\t\t\t const char *name,\n+\t\t\t\t struct rte_swx_port_in_ops *ops)\n+{\n+\tstruct port_in_type *elem;\n+\n+\tCHECK(p, EINVAL);\n+\tCHECK_NAME(name, EINVAL);\n+\tCHECK(ops, EINVAL);\n+\tCHECK(ops->create, EINVAL);\n+\tCHECK(ops->free, EINVAL);\n+\tCHECK(ops->pkt_rx, EINVAL);\n+\tCHECK(ops->stats_read, EINVAL);\n+\n+\tCHECK(!port_in_type_find(p, name), EEXIST);\n+\n+\t/* Node allocation. */\n+\telem = calloc(1, sizeof(struct port_in_type));\n+\tCHECK(elem, ENOMEM);\n+\n+\t/* Node initialization. */\n+\tstrcpy(elem->name, name);\n+\tmemcpy(&elem->ops, ops, sizeof(*ops));\n+\n+\t/* Node add to tailq. */\n+\tTAILQ_INSERT_TAIL(&p->port_in_types, elem, node);\n+\n+\treturn 0;\n+}\n+\n+static struct port_in *\n+port_in_find(struct rte_swx_pipeline *p, uint32_t port_id)\n+{\n+\tstruct port_in *port;\n+\n+\tTAILQ_FOREACH(port, &p->ports_in, node)\n+\t\tif (port->id == port_id)\n+\t\t\treturn port;\n+\n+\treturn NULL;\n+}\n+\n+int\n+rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,\n+\t\t\t\tuint32_t port_id,\n+\t\t\t\tconst char *port_type_name,\n+\t\t\t\tvoid *args)\n+{\n+\tstruct port_in_type *type = NULL;\n+\tstruct port_in *port = NULL;\n+\tvoid *obj = NULL;\n+\n+\tCHECK(p, EINVAL);\n+\n+\tCHECK(!port_in_find(p, port_id), EINVAL);\n+\n+\tCHECK_NAME(port_type_name, EINVAL);\n+\ttype = port_in_type_find(p, port_type_name);\n+\tCHECK(type, EINVAL);\n+\n+\tobj = type->ops.create(args);\n+\tCHECK(obj, ENODEV);\n+\n+\t/* Node allocation. */\n+\tport = calloc(1, sizeof(struct port_in));\n+\tCHECK(port, ENOMEM);\n+\n+\t/* Node initialization. */\n+\tport->type = type;\n+\tport->obj = obj;\n+\tport->id = port_id;\n+\n+\t/* Node add to tailq. */\n+\tTAILQ_INSERT_TAIL(&p->ports_in, port, node);\n+\tif (p->n_ports_in < port_id + 1)\n+\t\tp->n_ports_in = port_id + 1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+port_in_build(struct rte_swx_pipeline *p)\n+{\n+\tstruct port_in *port;\n+\tuint32_t i;\n+\n+\tCHECK(p->n_ports_in, EINVAL);\n+\tCHECK(rte_is_power_of_2(p->n_ports_in), EINVAL);\n+\n+\tfor (i = 0; i < p->n_ports_in; i++)\n+\t\tCHECK(port_in_find(p, i), EINVAL);\n+\n+\tp->in = calloc(p->n_ports_in, sizeof(struct port_in_runtime));\n+\tCHECK(p->in, ENOMEM);\n+\n+\tTAILQ_FOREACH(port, &p->ports_in, node) {\n+\t\tstruct port_in_runtime *in = &p->in[port->id];\n+\n+\t\tin->pkt_rx = port->type->ops.pkt_rx;\n+\t\tin->obj = port->obj;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+port_in_build_free(struct rte_swx_pipeline *p)\n+{\n+\tfree(p->in);\n+\tp->in = NULL;\n+}\n+\n+static void\n+port_in_free(struct rte_swx_pipeline *p)\n+{\n+\tport_in_build_free(p);\n+\n+\t/* Input ports. */\n+\tfor ( ; ; ) {\n+\t\tstruct port_in *port;\n+\n+\t\tport = TAILQ_FIRST(&p->ports_in);\n+\t\tif (!port)\n+\t\t\tbreak;\n+\n+\t\tTAILQ_REMOVE(&p->ports_in, port, node);\n+\t\tport->type->ops.free(port->obj);\n+\t\tfree(port);\n+\t}\n+\n+\t/* Input port types. */\n+\tfor ( ; ; ) {\n+\t\tstruct port_in_type *elem;\n+\n+\t\telem = TAILQ_FIRST(&p->port_in_types);\n+\t\tif (!elem)\n+\t\t\tbreak;\n+\n+\t\tTAILQ_REMOVE(&p->port_in_types, elem, node);\n+\t\tfree(elem);\n+\t}\n+}\n \n /*\n * Pipeline.\n@@ -44,6 +237,9 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)\n \tCHECK(pipeline, ENOMEM);\n \n \t/* Initialization. */\n+\tTAILQ_INIT(&pipeline->port_in_types);\n+\tTAILQ_INIT(&pipeline->ports_in);\n+\n \tpipeline->numa_node = numa_node;\n \n \t*p = pipeline;\n@@ -56,15 +252,28 @@ rte_swx_pipeline_free(struct rte_swx_pipeline *p)\n \tif (!p)\n \t\treturn;\n \n+\tport_in_free(p);\n+\n \tfree(p);\n }\n \n int\n rte_swx_pipeline_build(struct rte_swx_pipeline *p)\n {\n+\tint status;\n+\n \tCHECK(p, EINVAL);\n \tCHECK(p->build_done == 0, EEXIST);\n \n+\tstatus = port_in_build(p);\n+\tif (status)\n+\t\tgoto error;\n+\n \tp->build_done = 1;\n \treturn 0;\n+\n+error:\n+\tport_in_build_free(p);\n+\n+\treturn status;\n }\ndiff --git a/lib/librte_pipeline/rte_swx_pipeline.h b/lib/librte_pipeline/rte_swx_pipeline.h\nindex ded26a4e4..3dbe7ce0b 100644\n--- a/lib/librte_pipeline/rte_swx_pipeline.h\n+++ b/lib/librte_pipeline/rte_swx_pipeline.h\n@@ -18,6 +18,12 @@ extern \"C\" {\n \n #include <rte_compat.h>\n \n+#include \"rte_swx_port.h\"\n+\n+/** Name size. */\n+#ifndef RTE_SWX_NAME_SIZE\n+#define RTE_SWX_NAME_SIZE 64\n+#endif\n /*\n * Pipeline setup and operation\n */\n@@ -43,6 +49,54 @@ int\n rte_swx_pipeline_config(struct rte_swx_pipeline **p,\n \t\t\tint numa_node);\n \n+/*\n+ * Pipeline input ports\n+ */\n+\n+/**\n+ * Pipeline input port type register\n+ *\n+ * @param[in] p\n+ * Pipeline handle.\n+ * @param[in] name\n+ * Input port type name.\n+ * @param[in] ops\n+ * Input port type operations.\n+ * @return\n+ * 0 on success or the following error codes otherwise:\n+ * -EINVAL: Invalid argument;\n+ * -ENOMEM: Not enough space/cannot allocate memory;\n+ * -EEXIST: Input port type with this name already exists.\n+ */\n+__rte_experimental\n+int\n+rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p,\n+\t\t\t\t const char *name,\n+\t\t\t\t struct rte_swx_port_in_ops *ops);\n+\n+/**\n+ * Pipeline input port configure\n+ *\n+ * @param[in] p\n+ * Pipeline handle.\n+ * @param[in] port_id\n+ * Input port ID.\n+ * @param[in] port_type_name\n+ * Existing input port type name.\n+ * @param[in] args\n+ * Input port creation arguments.\n+ * @return\n+ * 0 on success or the following error codes otherwise:\n+ * -EINVAL: Invalid argument;\n+ * -ENOMEM: Not enough space/cannot allocate memory;\n+ * -ENODEV: Input port object creation error.\n+ */\n+__rte_experimental\n+int\n+rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p,\n+\t\t\t\tuint32_t port_id,\n+\t\t\t\tconst char *port_type_name,\n+\t\t\t\tvoid *args);\n /**\n * Pipeline build\n *\ndiff --git a/lib/librte_port/Makefile b/lib/librte_port/Makefile\nindex 57d2aedbc..4221618b3 100644\n--- a/lib/librte_port/Makefile\n+++ b/lib/librte_port/Makefile\n@@ -55,5 +55,6 @@ endif\n SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_source_sink.h\n SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_sym_crypto.h\n SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_eventdev.h\n+SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_swx_port.h\n \n include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_port/meson.build b/lib/librte_port/meson.build\nindex 0d5ede44a..5b5fbf6c4 100644\n--- a/lib/librte_port/meson.build\n+++ b/lib/librte_port/meson.build\n@@ -21,7 +21,8 @@ headers = files(\n \t'rte_port_sched.h',\n \t'rte_port_source_sink.h',\n \t'rte_port_sym_crypto.h',\n-\t'rte_port_eventdev.h')\n+\t'rte_port_eventdev.h',\n+\t'rte_swx_port.h',)\n deps += ['ethdev', 'sched', 'ip_frag', 'cryptodev', 'eventdev']\n \n if dpdk_conf.has('RTE_PORT_PCAP')\ndiff --git a/lib/librte_port/rte_swx_port.h b/lib/librte_port/rte_swx_port.h\nnew file mode 100644\nindex 000000000..a6f80de9a\n--- /dev/null\n+++ b/lib/librte_port/rte_swx_port.h\n@@ -0,0 +1,118 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Intel Corporation\n+ */\n+#ifndef __INCLUDE_RTE_SWX_PORT_H__\n+#define __INCLUDE_RTE_SWX_PORT_H__\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * @file\n+ * RTE SWX Port\n+ *\n+ * Packet I/O port interface.\n+ */\n+\n+#include <stdint.h>\n+\n+/** Packet. */\n+struct rte_swx_pkt {\n+\t/** Opaque packet handle. */\n+\tvoid *handle;\n+\n+\t/** Buffer where the packet is stored. */\n+\tuint8_t *pkt;\n+\n+\t/** Packet buffer offset of the first packet byte. */\n+\tuint32_t offset;\n+\n+\t/** Packet length in bytes. */\n+\tuint32_t length;\n+};\n+\n+/*\n+ * Input port\n+ */\n+\n+/**\n+ * Input port create\n+ *\n+ * @param[in] args\n+ * Arguments for input port creation. Format specific to each port type.\n+ * @return\n+ * Handle to input port instance on success, NULL on error.\n+ */\n+typedef void *\n+(*rte_swx_port_in_create_t)(void *args);\n+\n+/**\n+ * Input port free\n+ *\n+ * @param[in] args\n+ * Input port handle.\n+ */\n+typedef void\n+(*rte_swx_port_in_free_t)(void *port);\n+\n+/**\n+ * Input port packet receive\n+ *\n+ * @param[in] port\n+ * Input port handle.\n+ * @param[out] pkt\n+ * Received packet. Only valid when the function returns 1. Must point to\n+ * valid memory.\n+ * @return\n+ * 0 when no packet was received, 1 when a packet was received. No other\n+ * return values are allowed.\n+ */\n+typedef int\n+(*rte_swx_port_in_pkt_rx_t)(void *port,\n+\t\t\t struct rte_swx_pkt *pkt);\n+\n+/** Input port statistics counters. */\n+struct rte_swx_port_in_stats {\n+\t/** Number of packets. */\n+\tuint64_t n_pkts;\n+\n+\t/** Number of bytes. */\n+\tuint64_t n_bytes;\n+\n+\t/** Number of empty polls. */\n+\tuint64_t n_empty;\n+};\n+\n+/**\n+ * Input port statistics counters read\n+ *\n+ * @param[in] port\n+ * Input port handle.\n+ * @param[out] stats\n+ * Input port statistics counters. Must point to valid memory.\n+ */\n+typedef void\n+(*rte_swx_port_in_stats_read_t)(void *port,\n+\t\t\t\tstruct rte_swx_port_in_stats *stats);\n+\n+/** Input port operations. */\n+struct rte_swx_port_in_ops {\n+\t/** Create. Must be non-NULL. */\n+\trte_swx_port_in_create_t create;\n+\n+\t/** Free. Must be non-NULL. */\n+\trte_swx_port_in_free_t free;\n+\n+\t/** Packet reception. Must be non-NULL. */\n+\trte_swx_port_in_pkt_rx_t pkt_rx;\n+\n+\t/** Statistics counters read. Must be non-NULL. */\n+\trte_swx_port_in_stats_read_t stats_read;\n+};\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif\n", "prefixes": [ "02/40" ] }{ "id": 75997, "url": "