get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 67844,
    "url": "http://patches.dpdk.org/api/patches/67844/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200405085613.1336841-24-jerinj@marvell.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": "<20200405085613.1336841-24-jerinj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200405085613.1336841-24-jerinj@marvell.com",
    "date": "2020-04-05T08:56:07",
    "name": "[v4,23/29] node: add ipv4 rewrite and lookup ctrl API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e3df27de091eab9336aa85e53cf64851f47a8f68",
    "submitter": {
        "id": 1188,
        "url": "http://patches.dpdk.org/api/people/1188/?format=api",
        "name": "Jerin Jacob Kollanukkaran",
        "email": "jerinj@marvell.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/20200405085613.1336841-24-jerinj@marvell.com/mbox/",
    "series": [
        {
            "id": 9203,
            "url": "http://patches.dpdk.org/api/series/9203/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=9203",
            "date": "2020-04-05T08:55:44",
            "name": "graph: introduce graph subsystem",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/9203/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/67844/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/67844/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 DBDA3A0577;\n\tSun,  5 Apr 2020 11:01:17 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 340201BF9A;\n\tSun,  5 Apr 2020 10:57:46 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id BA2BF1BF9A\n for <dev@dpdk.org>; Sun,  5 Apr 2020 10:57:44 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n 0358fkWI019155; Sun, 5 Apr 2020 01:57:43 -0700",
            "from sc-exch01.marvell.com ([199.233.58.181])\n by mx0b-0016f401.pphosted.com with ESMTP id 306srm29wg-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Sun, 05 Apr 2020 01:57:43 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Sun, 5 Apr 2020 01:57:40 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Sun, 5 Apr 2020 01:57:40 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Sun, 5 Apr 2020 01:57:40 -0700",
            "from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14])\n by maili.marvell.com (Postfix) with ESMTP id 4D75C3F703F;\n Sun,  5 Apr 2020 01:57:37 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0818;\n bh=7UJVlBXlVU3jQtHIac8Ht6W1qqZKBxE+cXtn+NXzjEE=;\n b=fuIwHwwB5U3UXEGMyUJAMmDvCm808aVaLD9i5a1N6OiPSycqVmn4lWY+8spQX6hWcb3B\n HDf+v/ZNNeh/zYctgQQXQKf1Mclxb9SzetiU4HDuADrV+rYkasGdUNHfGHkIrPLKNRKt\n 2+cqbZTcv3tVoJ8lovUhDs0+/O33NwDYS17ooQe+iPpt/3GD2o6mMQ4fNOGiIjpGKp+G\n DGxfh084SW7AKx7N+CUTHTdYQ3tChEiNavWnM5dTYTMk1LoRUo5bnR5D6KAXVjSR3woN\n dunuAjNKySqIW4g0gSWesbjoToh7NXnO+i9dN2FJGf5/fEzymD+FM7IKSpILYUOR18eS 6Q==",
        "From": "<jerinj@marvell.com>",
        "To": "Nithin Dabilpuram <ndabilpuram@marvell.com>, Pavan Nikhilesh\n <pbhagavatula@marvell.com>",
        "CC": "<dev@dpdk.org>, <thomas@monjalon.net>, <david.marchand@redhat.com>,\n <mdr@ashroe.eu>, <mattias.ronnblom@ericsson.com>,\n <kirankumark@marvell.com>, <xiao.w.wang@intel.com>",
        "Date": "Sun, 5 Apr 2020 14:26:07 +0530",
        "Message-ID": "<20200405085613.1336841-24-jerinj@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200405085613.1336841-1-jerinj@marvell.com>",
        "References": "<20200331192945.2466880-1-jerinj@marvell.com>\n <20200405085613.1336841-1-jerinj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676\n definitions=2020-04-04_19:2020-04-03,\n 2020-04-04 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v4 23/29] node: add ipv4 rewrite and lookup ctrl\n\tAPI",
        "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": "From: Nithin Dabilpuram <ndabilpuram@marvell.com>\n\nAdd ip4_rewrite and ip4_lookup ctrl API. ip4_lookup ctrl\nAPI is used to add route entries for LPM lookup with\nresult data containing next hop id and next proto.\nip4_rewrite ctrl API is used to add rewrite data for\nevery next hop.\n\nSigned-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>\nSigned-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>\nSigned-off-by: Kiran Kumar K <kirankumark@marvell.com>\n---\n lib/librte_node/ethdev_ctrl.c        | 18 ++++++-\n lib/librte_node/ip4_lookup.c         | 80 ++++++++++++++++++++++++++++\n lib/librte_node/ip4_rewrite.c        | 56 +++++++++++++++++++\n lib/librte_node/ip4_rewrite_priv.h   | 22 ++++++++\n lib/librte_node/rte_node_ip4_api.h   | 44 +++++++++++++++\n lib/librte_node/rte_node_version.map |  2 +\n 6 files changed, 221 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/librte_node/ethdev_ctrl.c b/lib/librte_node/ethdev_ctrl.c\nindex b2ac5e2c4..845d92987 100644\n--- a/lib/librte_node/ethdev_ctrl.c\n+++ b/lib/librte_node/ethdev_ctrl.c\n@@ -11,6 +11,7 @@\n \n #include \"ethdev_rx_priv.h\"\n #include \"ethdev_tx_priv.h\"\n+#include \"ip4_rewrite_priv.h\"\n #include \"node_private.h\"\n \n static struct ethdev_ctrl {\n@@ -21,14 +22,17 @@ int\n rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs,\n \t\t    uint16_t nb_graphs)\n {\n+\tstruct rte_node_register *ip4_rewrite_node;\n \tstruct ethdev_tx_node_main *tx_node_data;\n \tuint16_t tx_q_used, rx_q_used, port_id;\n \tstruct rte_node_register *tx_node;\n \tchar name[RTE_NODE_NAMESIZE];\n+\tconst char *next_nodes = name;\n \tstruct rte_mempool *mp;\n+\tint i, j, rc;\n \tuint32_t id;\n-\tint i, j;\n \n+\tip4_rewrite_node = ip4_rewrite_node_get();\n \ttx_node_data = ethdev_tx_node_data_get();\n \ttx_node = ethdev_tx_node_get();\n \tfor (i = 0; i < nb_confs; i++) {\n@@ -93,6 +97,18 @@ rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs,\n \n \t\tnode_dbg(\"ethdev\", \"Tx node %s-%s: is at %u\", tx_node->name,\n \t\t\t name, id);\n+\n+\t\t/* Prepare the actual name of the cloned node */\n+\t\tsnprintf(name, sizeof(name), \"ethdev_tx-%u\", port_id);\n+\n+\t\t/* Add this tx port node as next to ip4_rewrite_node */\n+\t\trte_node_edge_update(ip4_rewrite_node->id, RTE_EDGE_ID_INVALID,\n+\t\t\t\t     &next_nodes, 1);\n+\t\t/* Assuming edge id is the last one alloc'ed */\n+\t\trc = ip4_rewrite_set_next(\n+\t\t\tport_id, rte_node_edge_count(ip4_rewrite_node->id) - 1);\n+\t\tif (rc < 0)\n+\t\t\treturn rc;\n \t}\n \n \tctrl.nb_graphs = nb_graphs;\ndiff --git a/lib/librte_node/ip4_lookup.c b/lib/librte_node/ip4_lookup.c\nindex 3a38f5ad8..d10d17879 100644\n--- a/lib/librte_node/ip4_lookup.c\n+++ b/lib/librte_node/ip4_lookup.c\n@@ -28,6 +28,8 @@ struct ip4_lookup_node_main {\n \tstruct rte_lpm *lpm_tbl[RTE_MAX_NUMA_NODES];\n };\n \n+static struct ip4_lookup_node_main ip4_lookup_nm;\n+\n #if defined(RTE_MACHINE_CPUFLAG_NEON)\n #include \"ip4_lookup_neon.h\"\n #elif defined(RTE_ARCH_X86)\n@@ -109,12 +111,90 @@ ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node,\n \n #endif\n \n+int\n+rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,\n+\t\t       enum rte_node_ip4_lookup_next next_node)\n+{\n+\tchar abuf[INET6_ADDRSTRLEN];\n+\tstruct in_addr in;\n+\tuint8_t socket;\n+\tuint32_t val;\n+\tint ret;\n+\n+\tin.s_addr = htonl(ip);\n+\tinet_ntop(AF_INET, &in, abuf, sizeof(abuf));\n+\t/* Embedded next node id in next hop */\n+\tval = (next_node << 16) | next_hop;\n+\tnode_dbg(\"ip4_lookup\", \"LPM: Adding route %s / %d nh (0x%x)\", abuf,\n+\t\t depth, val);\n+\n+\tfor (socket = 0; socket < RTE_MAX_NUMA_NODES; socket++) {\n+\t\tif (!ip4_lookup_nm.lpm_tbl[socket])\n+\t\t\tcontinue;\n+\n+\t\tret = rte_lpm_add(ip4_lookup_nm.lpm_tbl[socket], ip, depth,\n+\t\t\t\t  val);\n+\n+\t\tif (ret < 0) {\n+\t\t\tnode_err(\"ip4_lookup\",\n+\t\t\t\t \"Unable to add entry %s / %d nh (%x) to LPM table on sock %d, rc=%d\\n\",\n+\t\t\t\t abuf, depth, val, socket, ret);\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+setup_lpm(struct ip4_lookup_node_main *nm, int socket)\n+{\n+\tstruct rte_lpm_config config_ipv4;\n+\tchar s[RTE_LPM_NAMESIZE];\n+\n+\t/* One LPM table per socket */\n+\tif (nm->lpm_tbl[socket])\n+\t\treturn 0;\n+\n+\t/* create the LPM table */\n+\tconfig_ipv4.max_rules = IPV4_L3FWD_LPM_MAX_RULES;\n+\tconfig_ipv4.number_tbl8s = IPV4_L3FWD_LPM_NUMBER_TBL8S;\n+\tconfig_ipv4.flags = 0;\n+\tsnprintf(s, sizeof(s), \"IPV4_L3FWD_LPM_%d\", socket);\n+\tnm->lpm_tbl[socket] = rte_lpm_create(s, socket, &config_ipv4);\n+\tif (nm->lpm_tbl[socket] == NULL)\n+\t\treturn -rte_errno;\n+\n+\treturn 0;\n+}\n+\n static int\n ip4_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)\n {\n+\tstruct rte_lpm **lpm_p = (struct rte_lpm **)&node->ctx;\n+\tuint16_t socket, lcore_id;\n+\tstatic uint8_t init_once;\n+\tint rc;\n+\n \tRTE_SET_USED(graph);\n \tRTE_SET_USED(node);\n \n+\tif (!init_once) {\n+\t\t/* Setup LPM tables for all sockets */\n+\t\tRTE_LCORE_FOREACH(lcore_id)\n+\t\t{\n+\t\t\tsocket = rte_lcore_to_socket_id(lcore_id);\n+\t\t\trc = setup_lpm(&ip4_lookup_nm, socket);\n+\t\t\tif (rc) {\n+\t\t\t\tnode_err(\"ip4_lookup\",\n+\t\t\t\t\t \"Failed to setup lpm tbl for sock %u, rc=%d\",\n+\t\t\t\t\t socket, rc);\n+\t\t\t\treturn rc;\n+\t\t\t}\n+\t\t}\n+\t\tinit_once = 1;\n+\t}\n+\t*lpm_p = ip4_lookup_nm.lpm_tbl[graph->socket];\n \tnode_dbg(\"ip4_lookup\", \"Initialized ip4_lookup node\");\n \n \treturn 0;\ndiff --git a/lib/librte_node/ip4_rewrite.c b/lib/librte_node/ip4_rewrite.c\nindex ef49ccea0..5663f1eb1 100644\n--- a/lib/librte_node/ip4_rewrite.c\n+++ b/lib/librte_node/ip4_rewrite.c\n@@ -256,6 +256,56 @@ ip4_rewrite_node_init(const struct rte_graph *graph, struct rte_node *node)\n \treturn 0;\n }\n \n+int\n+ip4_rewrite_set_next(uint16_t port_id, uint16_t next_index)\n+{\n+\tif (ip4_rewrite_nm == NULL) {\n+\t\tip4_rewrite_nm = rte_zmalloc(\n+\t\t\t\"ip4_rewrite\", sizeof(struct ip4_rewrite_node_main),\n+\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (ip4_rewrite_nm == NULL)\n+\t\t\treturn -ENOMEM;\n+\t}\n+\tip4_rewrite_nm->next_index[port_id] = next_index;\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_node_ip4_rewrite_add(uint16_t next_hop, uint8_t *rewrite_data,\n+\t\t\t uint8_t rewrite_len, uint16_t dst_port)\n+{\n+\tstruct ip4_rewrite_nh_header *nh;\n+\n+\tif (next_hop >= RTE_GRAPH_IP4_REWRITE_MAX_NH)\n+\t\treturn -EINVAL;\n+\n+\tif (rewrite_len > RTE_GRAPH_IP4_REWRITE_MAX_LEN)\n+\t\treturn -EINVAL;\n+\n+\tif (ip4_rewrite_nm == NULL) {\n+\t\tip4_rewrite_nm = rte_zmalloc(\n+\t\t\t\"ip4_rewrite\", sizeof(struct ip4_rewrite_node_main),\n+\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (ip4_rewrite_nm == NULL)\n+\t\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Check if dst port doesn't exist as edge */\n+\tif (!ip4_rewrite_nm->next_index[dst_port])\n+\t\treturn -EINVAL;\n+\n+\t/* Update next hop */\n+\tnh = &ip4_rewrite_nm->nh[next_hop];\n+\n+\tmemcpy(nh->rewrite_data, rewrite_data, rewrite_len);\n+\tnh->tx_node = ip4_rewrite_nm->next_index[dst_port];\n+\tnh->rewrite_len = rewrite_len;\n+\tnh->enabled = true;\n+\n+\treturn 0;\n+}\n+\n static struct rte_node_register ip4_rewrite_node = {\n \t.process = ip4_rewrite_node_process,\n \t.name = \"ip4_rewrite\",\n@@ -267,4 +317,10 @@ static struct rte_node_register ip4_rewrite_node = {\n \t.init = ip4_rewrite_node_init,\n };\n \n+struct rte_node_register *\n+ip4_rewrite_node_get(void)\n+{\n+\treturn &ip4_rewrite_node;\n+}\n+\n RTE_NODE_REGISTER(ip4_rewrite_node);\ndiff --git a/lib/librte_node/ip4_rewrite_priv.h b/lib/librte_node/ip4_rewrite_priv.h\nindex 420996a03..80f0abdc9 100644\n--- a/lib/librte_node/ip4_rewrite_priv.h\n+++ b/lib/librte_node/ip4_rewrite_priv.h\n@@ -48,6 +48,28 @@ struct ip4_rewrite_node_main {\n \t/**< Next index of each configured port. */\n };\n \n+/**\n+ * @internal\n+ *\n+ * Get the ipv4 rewrite node.\n+ *\n+ * @retrun\n+ *   Pointer to the ipv4 rewrite node.\n+ */\n+struct rte_node_register *ip4_rewrite_node_get(void);\n+\n+/**\n+ * @internal\n+ *\n+ * Set the Edge index of a given port_id.\n+ *\n+ * @param port_id\n+ *   Ethernet port identifier.\n+ * @param next_index\n+ *   Edge index of the Given Tx node.\n+ */\n+int ip4_rewrite_set_next(uint16_t port_id, uint16_t next_index);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_node/rte_node_ip4_api.h b/lib/librte_node/rte_node_ip4_api.h\nindex 37c12bf82..394cac097 100644\n--- a/lib/librte_node/rte_node_ip4_api.h\n+++ b/lib/librte_node/rte_node_ip4_api.h\n@@ -36,6 +36,50 @@ enum rte_node_ip4_lookup_next {\n \t/**< Number of next nodes of lookup node. */\n };\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Add ipv4 route to lookup table.\n+ *\n+ * @param ip\n+ *   IP address of route to be added.\n+ * @param depth\n+ *   Depth of the rule to be added.\n+ * @param next_hop\n+ *   Next hop id of the rule result to be added.\n+ * @param next_node\n+ *   Next node to redirect traffic to.\n+ *\n+ * @return\n+ *   0 on success, negative otherwise.\n+ */\n+__rte_experimental\n+int rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,\n+\t\t\t   enum rte_node_ip4_lookup_next next_node);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Add a next hop's rewrite data.\n+ *\n+ * @param next_hop\n+ *   Next hop id to add rewrite data to.\n+ * @param rewrite_data\n+ *   Rewrite data.\n+ * @param rewrite_len\n+ *   Length of rewrite data.\n+ * @param dst_port\n+ *   Destination port to redirect traffic to.\n+ *\n+ * @return\n+ *   0 on success, negative otherwise.\n+ */\n+__rte_experimental\n+int rte_node_ip4_rewrite_add(uint16_t next_hop, uint8_t *rewrite_data,\n+\t\t\t     uint8_t rewrite_len, uint16_t dst_port);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_node/rte_node_version.map b/lib/librte_node/rte_node_version.map\nindex c6c71bd02..a799b0d38 100644\n--- a/lib/librte_node/rte_node_version.map\n+++ b/lib/librte_node/rte_node_version.map\n@@ -2,6 +2,8 @@ EXPERIMENTAL {\n \tglobal:\n \n \trte_node_eth_config;\n+\trte_node_ip4_route_add;\n+\trte_node_ip4_rewrite_add;\n \trte_node_logtype;\n \tlocal: *;\n };\n",
    "prefixes": [
        "v4",
        "23/29"
    ]
}