get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 52763,
    "url": "http://patches.dpdk.org/api/patches/52763/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1555276357-4892-8-git-send-email-orika@mellanox.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": "<1555276357-4892-8-git-send-email-orika@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1555276357-4892-8-git-send-email-orika@mellanox.com",
    "date": "2019-04-14T21:12:35",
    "name": "[7/9] net/mlx5: add port ID action to Direct Verbs",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "90c344c8c9178952dcf12560a615cb2c862e2af3",
    "submitter": {
        "id": 795,
        "url": "http://patches.dpdk.org/api/people/795/?format=api",
        "name": "Ori Kam",
        "email": "orika@mellanox.com"
    },
    "delegate": {
        "id": 6624,
        "url": "http://patches.dpdk.org/api/users/6624/?format=api",
        "username": "shahafs",
        "first_name": "Shahaf",
        "last_name": "Shuler",
        "email": "shahafs@mellanox.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1555276357-4892-8-git-send-email-orika@mellanox.com/mbox/",
    "series": [
        {
            "id": 4308,
            "url": "http://patches.dpdk.org/api/series/4308/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4308",
            "date": "2019-04-14T21:12:28",
            "name": "net/mlx5: add Direct Verbs E-Switch support",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/4308/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/52763/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/52763/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 2EE4F58C6;\n\tSun, 14 Apr 2019 23:13:15 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n\tby dpdk.org (Postfix) with ESMTP id DB89E5B36\n\tfor <dev@dpdk.org>; Sun, 14 Apr 2019 23:13:08 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n\torika@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 15 Apr 2019 00:13:02 +0300",
            "from pegasus03.mtr.labs.mlnx (pegasus03.mtr.labs.mlnx\n\t[10.210.16.124])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x3ELD10r027116;\n\tMon, 15 Apr 2019 00:13:02 +0300"
        ],
        "From": "Ori Kam <orika@mellanox.com>",
        "To": "yskoh@mellanox.com, shahafs@mellanox.com, matan@mellanox.com,\n\tviacheslavo@mellanox.com, motih@mellanox.com",
        "Cc": "dev@dpdk.org, orika@mellanox.com",
        "Date": "Sun, 14 Apr 2019 21:12:35 +0000",
        "Message-Id": "<1555276357-4892-8-git-send-email-orika@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1555276357-4892-1-git-send-email-orika@mellanox.com>",
        "References": "<1555276357-4892-1-git-send-email-orika@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH 7/9] net/mlx5: add port ID action to Direct Verbs",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This commits adds the port ID action to DV steering.\n\nSigned-off-by: Ori Kam <orika@mellanox.com>\n---\n drivers/net/mlx5/mlx5.h         |   2 +\n drivers/net/mlx5/mlx5_flow.h    |  12 ++++\n drivers/net/mlx5/mlx5_flow_dv.c | 149 ++++++++++++++++++++++++++++++++++++++++\n drivers/net/mlx5/mlx5_glue.c    |  14 ++++\n drivers/net/mlx5/mlx5_glue.h    |   1 +\n 5 files changed, 178 insertions(+)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 8d63575..016984d 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -281,6 +281,8 @@ struct mlx5_ibv_shared {\n \tLIST_HEAD(modify_cmd, mlx5_flow_dv_modify_hdr_resource) modify_cmds;\n \tLIST_HEAD(tag, mlx5_flow_dv_tag_resource) tags;\n \tLIST_HEAD(jump, mlx5_flow_dv_jump_tbl_resource) jump_tbl;\n+\tLIST_HEAD(port_id_action_list, mlx5_flow_dv_port_id_action_resource)\n+\t\tport_id_action_list; /* List of port ID actions. */\n \t/* Shared interrupt handler section. */\n \tpthread_mutex_t intr_mutex; /* Interrupt config mutex. */\n \tuint32_t intr_cnt; /* Interrupt handler reference counter. */\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 9d72024..c419e6b 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -267,6 +267,16 @@ struct mlx5_flow_dv_jump_tbl_resource {\n \tstruct mlx5_flow_tbl_resource *tbl; /**< The target table. */\n };\n \n+/* Port ID resource structure. */\n+struct mlx5_flow_dv_port_id_action_resource {\n+\tLIST_ENTRY(mlx5_flow_dv_port_id_action_resource) next;\n+\t/* Pointer to next element. */\n+\trte_atomic32_t refcnt; /**< Reference counter. */\n+\tvoid *action;\n+\t/**< Verbs tag action object. */\n+\tuint32_t port_id; /**< Port ID value. */\n+};\n+\n /*\n  * Max number of actions per DV flow.\n  * See CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED\n@@ -289,6 +299,8 @@ struct mlx5_flow_dv {\n \tstruct ibv_flow *flow; /**< Installed flow. */\n \tstruct mlx5_flow_dv_jump_tbl_resource *jump;\n \t/**< Pointer to the jump action resource. */\n+\tstruct mlx5_flow_dv_port_id_action_resource *port_id_action;\n+\t/**< Pointer to port ID action resource. */\n #ifdef HAVE_IBV_FLOW_DV_SUPPORT\n \tvoid *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];\n \t/**< Action list. */\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex b4ca9ca..f4b7f06 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -1058,6 +1058,70 @@ struct field_modify_info modify_tcp[] = {\n }\n \n /**\n+ * Find existing table port ID resource or create and register a new one.\n+ *\n+ * @param dev[in, out]\n+ *   Pointer to rte_eth_dev structure.\n+ * @param[in, out] resource\n+ *   Pointer to port ID action resource.\n+ * @parm[in, out] dev_flow\n+ *   Pointer to the dev_flow.\n+ * @param[out] error\n+ *   pointer to error structure.\n+ *\n+ * @return\n+ *   0 on success otherwise -errno and errno is set.\n+ */\n+static int\n+flow_dv_port_id_action_resource_register\n+\t\t\t(struct rte_eth_dev *dev,\n+\t\t\t struct mlx5_flow_dv_port_id_action_resource *resource,\n+\t\t\t struct mlx5_flow *dev_flow,\n+\t\t\t struct rte_flow_error *error)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_ibv_shared *sh = priv->sh;\n+\tstruct mlx5_flow_dv_port_id_action_resource *cache_resource;\n+\n+\t/* Lookup a matching resource from cache. */\n+\tLIST_FOREACH(cache_resource, &sh->port_id_action_list, next) {\n+\t\tif (resource->port_id == cache_resource->port_id) {\n+\t\t\tDRV_LOG(DEBUG, \"port id action resource resource %p: \"\n+\t\t\t\t\"refcnt %d++\",\n+\t\t\t\t(void *)cache_resource,\n+\t\t\t\trte_atomic32_read(&cache_resource->refcnt));\n+\t\t\trte_atomic32_inc(&cache_resource->refcnt);\n+\t\t\tdev_flow->dv.port_id_action = cache_resource;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\t/* Register new port id action resource. */\n+\tcache_resource = rte_calloc(__func__, 1, sizeof(*cache_resource), 0);\n+\tif (!cache_resource)\n+\t\treturn rte_flow_error_set(error, ENOMEM,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\t  \"cannot allocate resource memory\");\n+\t*cache_resource = *resource;\n+\tcache_resource->action =\n+\t\tmlx5_glue->dr_create_flow_action_dest_vport(priv->sh->fdb_ns,\n+\t\t\t\t\t\t\t    resource->port_id);\n+\tif (!cache_resource->action) {\n+\t\trte_free(cache_resource);\n+\t\treturn rte_flow_error_set(error, ENOMEM,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t  NULL, \"cannot create action\");\n+\t}\n+\trte_atomic32_init(&cache_resource->refcnt);\n+\trte_atomic32_inc(&cache_resource->refcnt);\n+\tLIST_INSERT_HEAD(&sh->port_id_action_list, cache_resource, next);\n+\tdev_flow->dv.port_id_action = cache_resource;\n+\tDRV_LOG(DEBUG, \"new port id action resource %p: refcnt %d++\",\n+\t\t(void *)cache_resource,\n+\t\trte_atomic32_read(&cache_resource->refcnt));\n+\treturn 0;\n+}\n+\n+/**\n  * Get the size of specific rte_flow_item_type\n  *\n  * @param[in] item_type\n@@ -3467,6 +3531,44 @@ struct field_modify_info modify_tcp[] = {\n }\n \n /**\n+ * Translate port ID action to vport.\n+ *\n+ * @param[in] dev\n+ *   Pointer to rte_eth_dev structure.\n+ * @param[in] action\n+ *   Pointer to the port ID action.\n+ * @param[out] dst_port_id\n+ *   The target port ID.\n+ * @param[out] error\n+ *   Pointer to the error structure.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+flow_dv_translate_action_port_id(struct rte_eth_dev *dev,\n+\t\t\t\t const struct rte_flow_action *action,\n+\t\t\t\t uint32_t *dst_port_id,\n+\t\t\t\t struct rte_flow_error *error)\n+{\n+\tuint32_t port;\n+\tuint16_t port_id;\n+\tint ret;\n+\tconst struct rte_flow_action_port_id *conf =\n+\t\t\t(const struct rte_flow_action_port_id *)action->conf;\n+\n+\tport = conf->original ? dev->data->port_id : conf->id;\n+\tret = mlx5_port_to_eswitch_info(port, NULL, &port_id);\n+\tif (ret)\n+\t\treturn rte_flow_error_set(error, -ret,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t\t  NULL,\n+\t\t\t\t\t  \"No eswitch info was found for port\");\n+\t*dst_port_id = port_id;\n+\treturn 0;\n+}\n+\n+/**\n  * Fill the flow with DV spec.\n  *\n  * @param[in] dev\n@@ -3524,10 +3626,24 @@ struct field_modify_info modify_tcp[] = {\n \t\tconst struct rte_flow_action_jump *jump_data;\n \t\tstruct mlx5_flow_dv_jump_tbl_resource jump_tbl_resource;\n \t\tstruct mlx5_flow_tbl_resource *tbl;\n+\t\tuint32_t port_id = 0;\n+\t\tstruct mlx5_flow_dv_port_id_action_resource port_id_resource;\n \n \t\tswitch (actions->type) {\n \t\tcase RTE_FLOW_ACTION_TYPE_VOID:\n \t\t\tbreak;\n+\t\tcase RTE_FLOW_ACTION_TYPE_PORT_ID:\n+\t\t\tif (flow_dv_translate_action_port_id(dev, action,\n+\t\t\t\t\t\t\t     &port_id, error))\n+\t\t\t\treturn -rte_errno;\n+\t\t\tport_id_resource.port_id = port_id;\n+\t\t\tif (flow_dv_port_id_action_resource_register\n+\t\t\t    (dev, &port_id_resource, dev_flow, error))\n+\t\t\t\treturn -rte_errno;\n+\t\t\tdev_flow->dv.actions[actions_n++] =\n+\t\t\t\tdev_flow->dv.port_id_action->action;\n+\t\t\taction_flags |= MLX5_FLOW_ACTION_PORT_ID;\n+\t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_FLAG:\n \t\t\ttag_resource.tag =\n \t\t\t\tmlx5_flow_mark_set(MLX5_FLOW_MARK_DEFAULT);\n@@ -4131,6 +4247,37 @@ struct field_modify_info modify_tcp[] = {\n }\n \n /**\n+ * Release port ID action resource.\n+ *\n+ * @param flow\n+ *   Pointer to mlx5_flow.\n+ *\n+ * @return\n+ *   1 while a reference on it exists, 0 when freed.\n+ */\n+static int\n+flow_dv_port_id_action_resource_release(struct mlx5_flow *flow)\n+{\n+\tstruct mlx5_flow_dv_port_id_action_resource *cache_resource =\n+\t\tflow->dv.port_id_action;\n+\n+\tassert(cache_resource->action);\n+\tDRV_LOG(DEBUG, \"port ID action resource %p: refcnt %d--\",\n+\t\t(void *)cache_resource,\n+\t\trte_atomic32_read(&cache_resource->refcnt));\n+\tif (rte_atomic32_dec_and_test(&cache_resource->refcnt)) {\n+\t\tclaim_zero(mlx5_glue->destroy_flow_action\n+\t\t\t\t(cache_resource->action));\n+\t\tLIST_REMOVE(cache_resource, next);\n+\t\trte_free(cache_resource);\n+\t\tDRV_LOG(DEBUG, \"port id action resource %p: removed\",\n+\t\t\t(void *)cache_resource);\n+\t\treturn 0;\n+\t}\n+\treturn 1;\n+}\n+\n+/**\n  * Remove the flow from the NIC but keeps it in memory.\n  *\n  * @param[in] dev\n@@ -4197,6 +4344,8 @@ struct field_modify_info modify_tcp[] = {\n \t\t\tflow_dv_modify_hdr_resource_release(dev_flow);\n \t\tif (dev_flow->dv.jump)\n \t\t\tflow_dv_jump_tbl_resource_release(dev_flow);\n+\t\tif (dev_flow->dv.port_id_action)\n+\t\t\tflow_dv_port_id_action_resource_release(dev_flow);\n \t\trte_free(dev_flow);\n \t}\n }\ndiff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c\nindex a508faa..117190f 100644\n--- a/drivers/net/mlx5/mlx5_glue.c\n+++ b/drivers/net/mlx5/mlx5_glue.c\n@@ -382,6 +382,18 @@\n }\n \n static void *\n+mlx5_glue_dr_create_flow_action_dest_vport(void *ns, uint32_t vport)\n+{\n+#ifdef HAVE_MLX5DV_DR_ESWITCH\n+\treturn mlx5dv_dr_create_action_dest_vport(ns, vport);\n+#else\n+\t(void)ns;\n+\t(void)vport;\n+\treturn NULL;\n+#endif\n+}\n+\n+static void *\n mlx5_glue_dr_create_flow_tbl(void *ns, uint32_t level)\n {\n #ifdef HAVE_MLX5DV_DR\n@@ -847,6 +859,8 @@\n \t.cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,\n \t.dr_create_flow_action_dest_flow_tbl =\n \t\tmlx5_glue_dr_create_flow_action_dest_flow_tbl,\n+\t.dr_create_flow_action_dest_vport =\n+\t\tmlx5_glue_dr_create_flow_action_dest_vport,\n \t.dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,\n \t.dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,\n \t.dr_create_ns = mlx5_glue_dr_create_ns,\ndiff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h\nindex 058e9b1..26f5cb3 100644\n--- a/drivers/net/mlx5/mlx5_glue.h\n+++ b/drivers/net/mlx5/mlx5_glue.h\n@@ -146,6 +146,7 @@ struct mlx5_glue {\n \tconst char *(*port_state_str)(enum ibv_port_state port_state);\n \tstruct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);\n \tvoid *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);\n+\tvoid *(*dr_create_flow_action_dest_vport)(void *ns, uint32_t vport);\n \tvoid *(*dr_create_flow_tbl)(void *ns, uint32_t level);\n \tint (*dr_destroy_flow_tbl)(void *tbl);\n \tvoid *(*dr_create_ns)(struct ibv_context *ctx,\n",
    "prefixes": [
        "7/9"
    ]
}