get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 79777,
    "url": "http://patches.dpdk.org/api/patches/79777/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1601984948-313027-24-git-send-email-suanmingm@nvidia.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": "<1601984948-313027-24-git-send-email-suanmingm@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1601984948-313027-24-git-send-email-suanmingm@nvidia.com",
    "date": "2020-10-06T11:49:06",
    "name": "[23/25] net/mlx5: make meter action thread safe",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ac3ff906721653a79e91b4f7fac47e6deec192b8",
    "submitter": {
        "id": 1887,
        "url": "http://patches.dpdk.org/api/people/1887/?format=api",
        "name": "Suanming Mou",
        "email": "suanmingm@nvidia.com"
    },
    "delegate": {
        "id": 3268,
        "url": "http://patches.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1601984948-313027-24-git-send-email-suanmingm@nvidia.com/mbox/",
    "series": [
        {
            "id": 12718,
            "url": "http://patches.dpdk.org/api/series/12718/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12718",
            "date": "2020-10-06T11:48:45",
            "name": "net/mlx5: support multiple-thread flow operations",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12718/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/79777/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/79777/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 6B7DDA04BB;\n\tTue,  6 Oct 2020 13:58:04 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 3B3BB1BC29;\n\tTue,  6 Oct 2020 13:50:02 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 662261BC29\n for <dev@dpdk.org>; Tue,  6 Oct 2020 13:50:00 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n suanmingm@nvidia.com) with SMTP; 6 Oct 2020 14:49:54 +0300",
            "from nvidia.com (mtbc-r640-04.mtbc.labs.mlnx [10.75.70.9])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 096BnC0h028553;\n Tue, 6 Oct 2020 14:49:52 +0300"
        ],
        "From": "Suanming Mou <suanmingm@nvidia.com>",
        "To": "viacheslavo@nvidia.com, matan@nvidia.com",
        "Cc": "rasland@nvidia.com, dev@dpdk.org",
        "Date": "Tue,  6 Oct 2020 19:49:06 +0800",
        "Message-Id": "<1601984948-313027-24-git-send-email-suanmingm@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>",
        "References": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>",
        "Subject": "[dpdk-dev] [PATCH 23/25] net/mlx5: make meter action thread safe",
        "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": "This commits add the spinlock for the meter action to make it be thread\nsafe. Atomic reference count is not engough as the meter action should\nbe created synchronized with reference count increase. With only atomic\nreference count, even the count is increased, the action may still not\nbe created.\n\nSigned-off-by: Suanming Mou <suanmingm@nvidia.com>\n---\n drivers/net/mlx5/mlx5_flow.h       |  2 ++\n drivers/net/mlx5/mlx5_flow_meter.c | 72 ++++++++++++++++++++------------------\n 2 files changed, 39 insertions(+), 35 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 2e060e6..e6890a4 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -748,6 +748,8 @@ struct mlx5_flow_meter {\n \tstruct mlx5_flow_meter_profile *profile;\n \t/**< Meter profile parameters. */\n \n+\trte_spinlock_t sl; /**< Meter action spinlock. */\n+\n \t/** Policer actions (per meter output color). */\n \tenum rte_mtr_policer_action action[RTE_COLORS];\n \ndiff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c\nindex b36bc7b..cba8389 100644\n--- a/drivers/net/mlx5/mlx5_flow_meter.c\n+++ b/drivers/net/mlx5/mlx5_flow_meter.c\n@@ -679,6 +679,7 @@\n \tfm->shared = !!shared;\n \tfm->policer_stats.stats_mask = params->stats_mask;\n \tfm->profile->ref_cnt++;\n+\trte_spinlock_init(&fm->sl);\n \treturn 0;\n error:\n \tmlx5_flow_destroy_policer_rules(dev, fm, &attr);\n@@ -1167,49 +1168,49 @@ struct mlx5_flow_meter *\n \t\t       struct rte_flow_error *error)\n {\n \tstruct mlx5_flow_meter *fm;\n+\tint ret = 0;\n \n \tfm = mlx5_flow_meter_find(priv, meter_id);\n \tif (fm == NULL) {\n \t\trte_flow_error_set(error, ENOENT,\n \t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n \t\t\t\t   \"Meter object id not valid\");\n-\t\tgoto error;\n-\t}\n-\tif (!fm->shared && fm->ref_cnt) {\n-\t\tDRV_LOG(ERR, \"Cannot share a non-shared meter.\");\n-\t\trte_flow_error_set(error, EINVAL,\n-\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n-\t\t\t\t  \"Meter can't be shared\");\n-\t\tgoto error;\n+\t\treturn fm;\n \t}\n-\tif (!fm->ref_cnt++) {\n-\t\tMLX5_ASSERT(!fm->mfts->meter_action);\n+\trte_spinlock_lock(&fm->sl);\n+\tif (fm->mfts->meter_action) {\n+\t\tif (fm->shared &&\n+\t\t    attr->transfer == fm->transfer &&\n+\t\t    attr->ingress == fm->ingress &&\n+\t\t    attr->egress == fm->egress)\n+\t\t\tfm->ref_cnt++;\n+\t\telse\n+\t\t\tret = -1;\n+\t} else {\n \t\tfm->ingress = attr->ingress;\n \t\tfm->egress = attr->egress;\n \t\tfm->transfer = attr->transfer;\n+\t\t fm->ref_cnt = 1;\n \t\t/* This also creates the meter object. */\n \t\tfm->mfts->meter_action = mlx5_flow_meter_action_create(priv,\n \t\t\t\t\t\t\t\t       fm);\n-\t\tif (!fm->mfts->meter_action)\n-\t\t\tgoto error_detach;\n-\t} else {\n-\t\tMLX5_ASSERT(fm->mfts->meter_action);\n-\t\tif (attr->transfer != fm->transfer ||\n-\t\t    attr->ingress != fm->ingress ||\n-\t\t    attr->egress != fm->egress) {\n-\t\t\tDRV_LOG(ERR, \"meter I/O attributes do not \"\n-\t\t\t\t\"match flow I/O attributes.\");\n-\t\t\tgoto error_detach;\n+\t\tif (!fm->mfts->meter_action) {\n+\t\t\tfm->ref_cnt = 0;\n+\t\t\tfm->ingress = 0;\n+\t\t\tfm->egress = 0;\n+\t\t\tfm->transfer = 0;\n+\t\t\tret = -1;\n+\t\t\tDRV_LOG(ERR, \"meter action create failed.\");\n \t\t}\n \t}\n-\treturn fm;\n-error_detach:\n-\tmlx5_flow_meter_detach(fm);\n-\trte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n-\t\t\t  fm->mfts->meter_action ? \"Meter attr not match\" :\n-\t\t\t  \"Meter action create failed\");\n-error:\n-\treturn NULL;\n+\trte_spinlock_unlock(&fm->sl);\n+\tif (ret)\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t   fm->mfts->meter_action ?\n+\t\t\t\t   \"Meter attr not match\" :\n+\t\t\t\t   \"Meter action create failed\");\n+\treturn ret ? NULL : fm;\n }\n \n /**\n@@ -1222,15 +1223,16 @@ struct mlx5_flow_meter *\n mlx5_flow_meter_detach(struct mlx5_flow_meter *fm)\n {\n #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER\n+\trte_spinlock_lock(&fm->sl);\n \tMLX5_ASSERT(fm->ref_cnt);\n-\tif (--fm->ref_cnt)\n-\t\treturn;\n-\tif (fm->mfts->meter_action)\n+\tif (--fm->ref_cnt == 0) {\n \t\tmlx5_glue->destroy_flow_action(fm->mfts->meter_action);\n-\tfm->mfts->meter_action = NULL;\n-\tfm->ingress = 0;\n-\tfm->egress = 0;\n-\tfm->transfer = 0;\n+\t\tfm->mfts->meter_action = NULL;\n+\t\tfm->ingress = 0;\n+\t\tfm->egress = 0;\n+\t\tfm->transfer = 0;\n+\t}\n+\trte_spinlock_unlock(&fm->sl);\n #else\n \t(void)fm;\n #endif\n",
    "prefixes": [
        "23/25"
    ]
}