get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/76977/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 76977,
    "url": "http://patches.dpdk.org/api/patches/76977/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200909002247.864844-2-patrick.fu@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": "<20200909002247.864844-2-patrick.fu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200909002247.864844-2-patrick.fu@intel.com",
    "date": "2020-09-09T00:22:45",
    "name": "[v1,1/3] lib/mirror: introduce traffic mirror API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3c172f5bf7392f2719da194502a51b865ddab35c",
    "submitter": {
        "id": 1781,
        "url": "http://patches.dpdk.org/api/people/1781/?format=api",
        "name": "Patrick Fu",
        "email": "patrick.fu@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/20200909002247.864844-2-patrick.fu@intel.com/mbox/",
    "series": [
        {
            "id": 12036,
            "url": "http://patches.dpdk.org/api/series/12036/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12036",
            "date": "2020-09-09T00:22:44",
            "name": "lib: introduce traffic mirroring lib",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12036/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/76977/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/76977/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 6598CA04B1;\n\tWed,  9 Sep 2020 02:28:34 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 22E791BF8A;\n\tWed,  9 Sep 2020 02:28:31 +0200 (CEST)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n by dpdk.org (Postfix) with ESMTP id B400E1BEE1\n for <dev@dpdk.org>; Wed,  9 Sep 2020 02:28:28 +0200 (CEST)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 08 Sep 2020 17:28:27 -0700",
            "from npg-dpdk-patrickfu-casc2.sh.intel.com ([10.67.119.92])\n by fmsmga008.fm.intel.com with ESMTP; 08 Sep 2020 17:28:23 -0700"
        ],
        "IronPort-SDR": [
            "\n wVOK2nWt+fpPbjLVTQil7GdJ67O7zJe+jRPaNtbGCdVv8J38U5ZNajzM/Qp/4D+rGzWVIY6oae\n o3nskyH/fHUw==",
            "\n pK/cBdiKSOscJV+RxpKLIBTdP2ecudC+I3f8qrSfSXtbbIU7NEU8O4q3m5MZQYfxvIyPtiZFMN\n TZ3LQlGv9png=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9738\"; a=\"222453007\"",
            "E=Sophos;i=\"5.76,407,1592895600\"; d=\"scan'208\";a=\"222453007\"",
            "E=Sophos;i=\"5.76,407,1592895600\"; d=\"scan'208\";a=\"286051334\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Patrick Fu <patrick.fu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net, ferruh.yigit@intel.com, maxime.coquelin@redhat.com,\n bruce.richardson@intel.com, mm6021@att.com, zhihong.wang@intel.com,\n liang-min.wang@intel.com, konstantin.ananyev@intel.com,\n timothy.miskell@intel.com, cunming.liang@intel.com, patrick.fu@intel.com",
        "Date": "Wed,  9 Sep 2020 08:22:45 +0800",
        "Message-Id": "<20200909002247.864844-2-patrick.fu@intel.com>",
        "X-Mailer": "git-send-email 2.18.4",
        "In-Reply-To": "<20200909002247.864844-1-patrick.fu@intel.com>",
        "References": "<20200909002247.864844-1-patrick.fu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 1/3] lib/mirror: introduce traffic mirror API",
        "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": "Network Test Access Point (TAP) is the network monitoring service\ncommonly adotpted in SDN-based network infrastructures. When VMs are\ninter-connected over virtual switches, TAP requires vSwitch to mirror\nout network traffics from specific workload VM ports to the TAP\ndevice/VM ports.\n\nThis patch introduce 2 a new APIs to support high-throughput packet\nmirroring:\n - rte_mirror_register()\n - rte_mirror_unregister()\nApplications use the new API to setup the source traffic port and\nthe mirror traffic port. Packets flowing over the registered\nsource ports will be transmited to the mirror port when registration\nsucceeds.\n\nSigned-off-by: Liang-min Wang <liang-min.wang@intel.com>\nSigned-off-by: Patrick Fu <patrick.fu@intel.com>\nSigned-off-by: Timothy Miskell <timothy.miskell@intel.com>\n---\n config/common_base                       |   5 +\n lib/Makefile                             |   2 +\n lib/librte_mirror/Makefile               |  20 ++\n lib/librte_mirror/meson.build            |   6 +\n lib/librte_mirror/rte_mirror.c           | 297 +++++++++++++++++++++++\n lib/librte_mirror/rte_mirror.h           | 111 +++++++++\n lib/librte_mirror/rte_mirror_version.map |   7 +\n lib/meson.build                          |   2 +-\n 8 files changed, 449 insertions(+), 1 deletion(-)\n create mode 100644 lib/librte_mirror/Makefile\n create mode 100644 lib/librte_mirror/meson.build\n create mode 100644 lib/librte_mirror/rte_mirror.c\n create mode 100644 lib/librte_mirror/rte_mirror.h\n create mode 100644 lib/librte_mirror/rte_mirror_version.map",
    "diff": "diff --git a/config/common_base b/config/common_base\nindex fbf0ee70c..60217cc93 100644\n--- a/config/common_base\n+++ b/config/common_base\n@@ -1110,6 +1110,11 @@ CONFIG_RTE_LIBRTE_GRAPH_STATS=y\n #\n CONFIG_RTE_LIBRTE_NODE=y\n \n+#\n+# Compile librte_mirror\n+#\n+CONFIG_RTE_LIBRTE_MIRROR=y\n+\n #\n # Compile the test application\n #\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 8f5b68a2d..24175dd98 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -112,6 +112,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder\n DEPDIRS-librte_reorder := librte_eal librte_mempool librte_mbuf\n DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump\n DEPDIRS-librte_pdump := librte_eal librte_mempool librte_mbuf librte_ethdev\n+DIRS-$(CONFIG_RTE_LIBRTE_MIRROR) += librte_mirror\n+DEPDIRS-librte_mirror := librte_eal librte_mempool librte_mbuf librte_ethdev\n DIRS-$(CONFIG_RTE_LIBRTE_GSO) += librte_gso\n DEPDIRS-librte_gso := librte_eal librte_mbuf librte_ethdev librte_net\n DEPDIRS-librte_gso += librte_mempool\ndiff --git a/lib/librte_mirror/Makefile b/lib/librte_mirror/Makefile\nnew file mode 100644\nindex 000000000..3ca1db734\n--- /dev/null\n+++ b/lib/librte_mirror/Makefile\n@@ -0,0 +1,20 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2020- Intel Corporation\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+# library name\n+LIB = librte_mirror.a\n+\n+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3\n+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ethdev\n+\n+EXPORT_MAP := rte_mirror_version.map\n+\n+# all source are stored in SRCS-y\n+SRCS-$(CONFIG_RTE_LIBRTE_MIRROR) := rte_mirror.c\n+\n+# install this header file\n+SYMLINK-$(CONFIG_RTE_LIBRTE_MIRROR)-include := rte_mirror.h\n+\n+include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_mirror/meson.build b/lib/librte_mirror/meson.build\nnew file mode 100644\nindex 000000000..2d0ba0ed2\n--- /dev/null\n+++ b/lib/librte_mirror/meson.build\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2020 Intel Corporation\n+\n+sources = files('rte_mirror.c')\n+headers = files('rte_mirror.h')\n+deps += ['ethdev']\ndiff --git a/lib/librte_mirror/rte_mirror.c b/lib/librte_mirror/rte_mirror.c\nnew file mode 100644\nindex 000000000..f2a85976a\n--- /dev/null\n+++ b/lib/librte_mirror/rte_mirror.c\n@@ -0,0 +1,297 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020- Intel Corporation\n+ */\n+\n+#include <rte_memcpy.h>\n+#include <rte_mbuf.h>\n+#include <rte_ethdev.h>\n+#include <rte_log.h>\n+#include <rte_errno.h>\n+\n+#include \"rte_mirror.h\"\n+\n+/* Macro for printing using RTE_LOG */\n+extern int mirror_logtype;\n+#define MIRROR_LOG(level, fmt, args...)\t\t\t\t\\\n+\trte_log(RTE_LOG_ ## level, mirror_logtype, \"%s(): \" fmt,\t\\\n+\t\t__func__, ## args)\n+\n+#define MAC_ADDR_MAP           0x0000FFFFFFFFFFFFULL\n+#define VLAN_INSERT_FLAG       (PKT_TX_VLAN_PKT)\n+#define is_mac_addr_match(a, b) (((a^b)&MAC_ADDR_MAP) == 0)\n+#define INIT_MIRROR_DB_SIZE    8\n+#define INVALID_PORT_ID        0xFFFF\n+#define SRC_MAC_OFFSET         6\n+#define DST_MAC_OFFSET         0\n+\n+static int mirror_port_db_size;\n+static int mirror_port_used;\n+static struct rte_mirror_offload_port *mirror_port_db;\n+\n+static int\n+rte_mirror_param_copy(struct rte_mirror_param *dst,\n+\tstruct rte_mirror_param *src)\n+{\n+\tvoid *extra_data;\n+\n+\tmemcpy(dst, src, sizeof(struct rte_mirror_param));\n+\n+\tif (src->extra_data_size) {\n+\t\textra_data = malloc(src->extra_data_size);\n+\t\tif (!extra_data) {\n+\t\t\tMIRROR_LOG(ERR, \"Out of memory !!!\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tmemcpy(extra_data, src->extra_data, src->extra_data_size);\n+\n+\t\tdst->extra_data = extra_data;\n+\t} else\n+\t\tdst->extra_data = NULL;\n+\treturn 0;\n+}\n+\n+static struct rte_mirror_offload_port*\n+mirror_data_find(uint16_t port_id)\n+{\n+\tint i;\n+\n+\tif (mirror_port_db == NULL)\n+\t\treturn NULL;\n+\tfor (i = 0; i < mirror_port_db_size; i++) {\n+\t\tif (port_id == mirror_port_db[i].port_id)\n+\t\t\treturn &mirror_port_db[i];\n+\t}\n+\treturn NULL;\n+}\n+\n+static void\n+mirror_db_init(struct rte_mirror_offload_port *db, int size)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < size; i++) {\n+\t\tmemset(&db[i], 0, sizeof(struct rte_mirror_offload_port));\n+\t\tdb[i].port_id = INVALID_PORT_ID;\n+\t}\n+}\n+\n+/* Double the db size when it runs out of space */\n+static int\n+mirror_db_resize(void)\n+{\n+\tint new_size = 2*mirror_port_db_size;\n+\tstruct rte_mirror_offload_port *new_db = malloc(\n+\t\tsizeof(struct rte_mirror_offload_port)*new_size);\n+\n+\tif (new_db == NULL) {\n+\t\tMIRROR_LOG(ERR, \"Out of memory!!!\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tmemcpy(new_db, mirror_port_db, sizeof(struct rte_mirror_offload_port)\n+\t\t*mirror_port_db_size);\n+\tmirror_db_init(&new_db[mirror_port_db_size], mirror_port_db_size);\n+\tmirror_port_db_size = new_size;\n+\tmirror_port_db = new_db;\n+\n+\treturn 0;\n+}\n+\n+/* release db when used count drop to 0 */\n+static void\n+mirror_data_remove(uint16_t port_id, int tx)\n+{\n+\tstruct rte_mirror_offload_port *target = mirror_data_find(port_id);\n+\n+\tif (!target)\n+\t\tMIRROR_LOG(ERR, \"Attempt to remove unsaved port, \"\n+\t\t\t\"%d, %s callback\\n\", port_id, tx?\"tx\" : \"rx\");\n+\n+\tif (tx)\n+\t\tmemset(&target->tx, 0, sizeof(struct rte_mirror_param));\n+\telse\n+\t\tmemset(&target->rx, 0, sizeof(struct rte_mirror_param));\n+\n+\tif ((target->rx.mirror_cb == NULL) &&\n+\t\t(target->tx.mirror_cb == NULL)) {\n+\t\ttarget->port_id = INVALID_PORT_ID;\n+\t\tmirror_port_used--;\n+\t\tif (mirror_port_used == 0) {\n+\t\t\tfree(mirror_port_db);\n+\t\t\tmirror_port_db = NULL;\n+\t\t\tmirror_port_db_size = 0;\n+\t\t}\n+\t}\n+}\n+\n+static struct rte_mirror_offload_port*\n+mirror_data_add(uint16_t port_id, int tx,\n+\t\tstruct rte_mirror_param *new_param)\n+{\n+\tstruct rte_mirror_offload_port *target = NULL;\n+\tstruct rte_mirror_param *param;\n+\tint i;\n+\n+\tif (!mirror_port_db) {\n+\t\tmirror_port_db_size = INIT_MIRROR_DB_SIZE;\n+\t\tmirror_port_db = malloc(sizeof(struct rte_mirror_offload_port)*\n+\t\t\tmirror_port_db_size);\n+\t\tif (!mirror_port_db) {\n+\t\t\tMIRROR_LOG(ERR, \"Out of memory!!!\\n\");\n+\t\t\treturn NULL;\n+\t\t}\n+\t\tmirror_db_init(mirror_port_db, mirror_port_db_size);\n+\t}\n+\ttarget = mirror_data_find(port_id);\n+\tif (target) {\n+\t\tif (tx) {\n+\t\t\tif (target->tx.mirror_cb) {\n+\t\t\t\tMIRROR_LOG(ERR, \"Attempt to add ingress mirror \"\n+\t\t\t\t\t\"offloading on port, %d, \"\n+\t\t\t\t\t\"while one is outstanding\\n\", port_id);\n+\t\t\t\treturn target;\n+\t\t\t}\n+\n+\t\t\tif (rte_mirror_param_copy(&target->tx, new_param))\n+\t\t\t\treturn NULL;\n+\n+\t\t} else {\n+\t\t\tif (target->rx.mirror_cb) {\n+\t\t\t\tMIRROR_LOG(ERR, \"Attempt to add egress mirror \"\n+\t\t\t\t\t\"offloading on port, %d, \"\n+\t\t\t\t\t\"while one is outstanding\\n\", port_id);\n+\t\t\t\treturn target;\n+\t\t\t}\n+\n+\t\t\tif (rte_mirror_param_copy(&target->rx, new_param))\n+\t\t\t\treturn NULL;\n+\t\t}\n+\t} else {\n+\t\t/* find an unused spot on db */\n+\t\tfor (i = 0; i < mirror_port_db_size; i++) {\n+\t\t\tif (mirror_port_db[i].port_id == INVALID_PORT_ID)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (i == mirror_port_db_size) {\n+\t\t\tif (mirror_db_resize())\n+\t\t\t\treturn NULL;\n+\t\t}\n+\n+\t\tparam = tx ? &mirror_port_db[i].tx : &mirror_port_db[i].rx;\n+\t\tif (rte_mirror_param_copy(param, new_param))\n+\t\t\treturn NULL;\n+\n+\t\ttarget = &mirror_port_db[i];\n+\t\ttarget->port_id = port_id;\n+\t\tmirror_port_used++;\n+\t}\n+\treturn target;\n+}\n+\n+static inline void\n+mirror_pkt_update(struct rte_mbuf *pkt, uint16_t dst_vlan_id)\n+{\n+\tpkt->ol_flags |= VLAN_INSERT_FLAG;\n+\tpkt->vlan_tci = dst_vlan_id;\n+\trte_mbuf_refcnt_update(pkt, 1);\n+}\n+\n+int\n+rte_mirror_offload_register(uint16_t src_port,\n+\t\tstruct rte_mirror_param *param, int tx_cb)\n+{\n+\tint i;\n+\tstruct rte_mirror_offload_port *port_info;\n+\tstruct rte_mirror_param *data;\n+\trte_rx_callback_fn rx_fn = NULL;\n+\trte_tx_callback_fn tx_fn = NULL;\n+\n+\n+\tport_info = mirror_data_add(src_port, tx_cb, param);\n+\tif (!port_info)\n+\t\treturn -EINVAL;\n+\n+\tdata = tx_cb ? &port_info->tx : &port_info->rx;\n+\tdata->pkt_buf = NULL;\n+\tdata->mirror_cb = malloc(sizeof(struct rte_eth_rxtx_callbac *) *\n+\t\t\tdata->n_src_queue);\n+\tif (!data->mirror_cb) {\n+\t\tMIRROR_LOG(ERR, \"Out of memory !!!\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tswitch (data->mirror_type) {\n+\tdefault:\n+\t\tMIRROR_LOG(ERR, \"Un-supported mirror offloading type!!!\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tif (data->mirror_type != rte_mirror_type_port) {\n+\t\tdata->pkt_buf = malloc(sizeof(struct rte_mbuf *) *\n+\t\t\t\tdata->max_burst_size * data->n_src_queue);\n+\t\tif (!data->pkt_buf) {\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"Out of memory !!!\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (!tx_cb) {\n+\t\tfor (i = 0; i < data->n_src_queue; i++) {\n+\t\t\tdata->mirror_cb[i] = rte_eth_add_rx_callback(src_port,\n+\t\t\t\ti, rx_fn, data);\n+\t\t}\n+\t} else {\n+\t\tfor (i = 0; i < data->n_src_queue; i++) {\n+\t\t\tdata->mirror_cb[i] = rte_eth_add_tx_callback(src_port,\n+\t\t\t\ti, tx_fn, data);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_mirror_offload_unregister(uint16_t src_port, int tx_cb)\n+{\n+\t/* release both cb and pkt_buf */\n+\tint i;\n+\tstruct rte_mirror_offload_port *port_info;\n+\tstruct rte_mirror_param *data;\n+\n+\tport_info = mirror_data_find(src_port);\n+\tif (port_info == NULL) {\n+\t\tMIRROR_LOG(ERR, \"Source port %d is not on outstanding \"\n+\t\t\t\"port mirror db\\n\", src_port);\n+\t\treturn -1;\n+\t}\n+\tdata = tx_cb ? &port_info->tx : &port_info->rx;\n+\n+\tfor (i = 0; i < data->n_src_queue; i++) {\n+\t\tif (data->mirror_cb[i]) {\n+\t\t\tif (tx_cb)\n+\t\t\t\trte_eth_remove_tx_callback(src_port,\n+\t\t\t\t\t\ti, data->mirror_cb[i]);\n+\t\t\telse\n+\t\t\t\trte_eth_remove_rx_callback(src_port,\n+\t\t\t\t\t\ti, data->mirror_cb[i]);\n+\t\t}\n+\t\tdata->mirror_cb[i] = 0;\n+\t}\n+\tfree(data->mirror_cb);\n+\n+\tif (data->pkt_buf) {\n+\t\tfree(data->pkt_buf);\n+\t\tdata->pkt_buf = NULL;\n+\t}\n+\n+\tif (data->extra_data) {\n+\t\tfree(data->extra_data);\n+\t\tdata->extra_data = NULL;\n+\t\tdata->extra_data_size = 0;\n+\t}\n+\n+\tmirror_data_remove(src_port, tx_cb);\n+\treturn 0;\n+}\n+\n+RTE_LOG_REGISTER(mirror_logtype, lib.mirror, NOTICE);\ndiff --git a/lib/librte_mirror/rte_mirror.h b/lib/librte_mirror/rte_mirror.h\nnew file mode 100644\nindex 000000000..71f3e1ea1\n--- /dev/null\n+++ b/lib/librte_mirror/rte_mirror.h\n@@ -0,0 +1,111 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020- Intel Corporation\n+ */\n+\n+#ifndef _RTE_MIRROR_H_\n+#define _RTE_MIRROR_H_\n+\n+/**\n+ * @file\n+ * RTE mirror\n+ *\n+ * packet mirror offloading library to provide packet mirroring support on dpdk.\n+ */\n+\n+#include <stdint.h>\n+#include <rte_ethdev_core.h>\n+#include <rte_mbuf_core.h>\n+#include <rte_spinlock.h>\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * Function type used for mirrored packet header scan.\n+ *\n+ * The callback function is called on each mirrored packet\n+ * to determinate if mirror condition is match.\n+ *\n+ * @param pkt\n+ *   Pointer to one packet data.\n+ * @param user_param\n+ *   The arbitrary user parameter passed in by the application when the callback\n+ *   was originally configured.\n+ * @return\n+ *   One if the condition matches, else 0.\n+ */\n+typedef int (*rte_mirror_scan_fn)(struct rte_mbuf *pkt, void *user_param);\n+\n+typedef enum {\n+\trte_mirror_type_port = 0,\t/* port mirror */\n+\trte_mirror_type_flow_mac,\t/* mac based flow mirror */\n+\trte_mirror_type_flow_custom,\t/* custom flow mirror */\n+\trte_mirror_type_invalid = 0xFF,\t/* invalid mirror_type */\n+} rte_mirror_type;\n+\n+struct rte_mirror_param {\n+\tuint16_t dst_port_id;\n+\tuint16_t dst_vlan_id;\n+\trte_spinlock_t *locks;\n+\tint n_src_queue;\n+\tint n_dst_queue;\n+\tstruct rte_mbuf **pkt_buf;\n+\tconst struct rte_eth_rxtx_callback **mirror_cb;\n+\tunsigned int max_burst_size;\n+\trte_mirror_scan_fn custom_scan;\n+\trte_mirror_type mirror_type;\n+\tunsigned int extra_data_size;\n+\tvoid *extra_data; /* extra mirror parameter */\n+};\n+\n+struct rte_mirror_offload_port {\n+\tuint16_t port_id;\n+\tstruct rte_mirror_param rx;\n+\tstruct rte_mirror_param tx;\n+};\n+\n+/**\n+ * Add a port mirroring via port offloading\n+ *\n+ * This function adds traffic (ingress or egress) mirroring from\n+ * the specified port\n+ *\n+ * @param src_port\n+ *   The source port where port traffic is to be captured and sent to\n+ *   the offload port.\n+ * @param param\n+ *   The port mirror offloading parameters\n+ * @param tx_cb\n+ *   1: register tx callback; 0: register rx callback\n+ * @return\n+ *   0 = success\n+ *   N > 0 any error encouter\n+ */\n+__rte_experimental\n+int rte_mirror_offload_register(uint16_t src_port,\n+\tstruct rte_mirror_param *param, int tx_cb);\n+\n+/**\n+ * Remove a port mirroring via port offloading\n+ *\n+ * This function removes traffic (ingress or egress) mirroring from\n+ * the specified port\n+ *\n+ * @param src_port\n+ *   The port-id of source port where port traffic is to be captured\n+ *   and sent to the offload port.\n+ * @param tx_cb\n+ *   1: tx callback; 0: rx callback\n+ * @return\n+ *   0 = success\n+ *   N > 0 any error encouter\n+ */\n+__rte_experimental\n+int rte_mirror_offload_unregister(uint16_t src_port, int tx_cb);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_PDUMP_H_ */\ndiff --git a/lib/librte_mirror/rte_mirror_version.map b/lib/librte_mirror/rte_mirror_version.map\nnew file mode 100644\nindex 000000000..e0a4d69d1\n--- /dev/null\n+++ b/lib/librte_mirror/rte_mirror_version.map\n@@ -0,0 +1,7 @@\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\trte_mirror_offload_register;\n+\trte_mirror_offload_unregister;\n+};\n+\ndiff --git a/lib/meson.build b/lib/meson.build\nindex 3852c0156..6674749dd 100644\n--- a/lib/meson.build\n+++ b/lib/meson.build\n@@ -24,7 +24,7 @@ libraries = [\n \t'distributor', 'efd', 'eventdev',\n \t'gro', 'gso', 'ip_frag', 'jobstats',\n \t'kni', 'latencystats', 'lpm', 'member',\n-\t'power', 'pdump', 'rawdev', 'regexdev',\n+\t'power', 'pdump', 'rawdev', 'regexdev', 'mirror',\n \t'rib', 'reorder', 'sched', 'security', 'stack', 'vhost',\n \t# ipsec lib depends on net, crypto and security\n \t'ipsec',\n",
    "prefixes": [
        "v1",
        "1/3"
    ]
}