get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 77852,
    "url": "http://patches.dpdk.org/api/patches/77852/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200916042851.32914-24-ajit.khaparde@broadcom.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": "<20200916042851.32914-24-ajit.khaparde@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200916042851.32914-24-ajit.khaparde@broadcom.com",
    "date": "2020-09-16T04:28:49",
    "name": "[v2,23/25] net/bnxt: add locks in flow database",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "ad48b9f975ac42b0c8ffe24314ee3ea197492483",
    "submitter": {
        "id": 501,
        "url": "http://patches.dpdk.org/api/people/501/?format=api",
        "name": "Ajit Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "delegate": {
        "id": 1766,
        "url": "http://patches.dpdk.org/api/users/1766/?format=api",
        "username": "ajitkhaparde",
        "first_name": "Ajit",
        "last_name": "Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200916042851.32914-24-ajit.khaparde@broadcom.com/mbox/",
    "series": [
        {
            "id": 12255,
            "url": "http://patches.dpdk.org/api/series/12255/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12255",
            "date": "2020-09-16T04:28:26",
            "name": "patchset for bnxt",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/12255/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/77852/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/77852/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 856BAA04C7;\n\tWed, 16 Sep 2020 06:32:53 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id A16211C211;\n\tWed, 16 Sep 2020 06:29:46 +0200 (CEST)",
            "from mail-pj1-f97.google.com (mail-pj1-f97.google.com\n [209.85.216.97]) by dpdk.org (Postfix) with ESMTP id B0E801C1C0\n for <dev@dpdk.org>; Wed, 16 Sep 2020 06:29:20 +0200 (CEST)",
            "by mail-pj1-f97.google.com with SMTP id mm21so901671pjb.4\n for <dev@dpdk.org>; Tue, 15 Sep 2020 21:29:20 -0700 (PDT)",
            "from localhost.localdomain ([192.19.223.252])\n by smtp-relay.gmail.com with ESMTPS id hk6sm132636pjb.6.2020.09.15.21.29.19\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Tue, 15 Sep 2020 21:29:19 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com;\n s=google;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=f+VFC4P9mS+kh4wGoMD3x+yp6KVYD/pWwuNsBZ2VPrI=;\n b=dlM4dG1fb/8+N2kD2jvrLH7dg/U+g3fQmpDlC6kGbjOEVy794Ug7SrkFnDg2C83hEU\n ElF9pe3gSdFhO3+ycclK4hPX4l9Owi2x31elUQOogLvZV9UMhCBn5ahkgXh3sUdGGPwA\n D4Bc6R+PYRR9F9tCsTQp1y0ccea2y4+WPc7hg=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=f+VFC4P9mS+kh4wGoMD3x+yp6KVYD/pWwuNsBZ2VPrI=;\n b=LR/2jRP3FWLVfJopOBJbLEZYR55QHo9foKwkpfXynwWkvnkKKe/uRHr0Lt4mxROKiz\n b8UieRSj8N6BYum6BdUKgDh4YdzgWFsLvV10cET1LHAqagTNlbT0iRp4a4aH9IPaPCcK\n D+MAj0PcCwAie+MNoGLBKDDfZwzfxexrCeCRdx7B2/1jOekJ46z0sFLFjMnEVRTElOzM\n 7xdZn0i4Xngmdp6uc+6kf/On5bAm4mhvabHCGtaYHjz2JtyLzBS+c8NW/MCRoOm9P6Hx\n Gx24Y/SAt26OSLnBY/iM9UEjz8Lj7h080PiZIVZzO9J/vt6/oRA4LGoREHJavGl17Ngw\n z7fw==",
        "X-Gm-Message-State": "AOAM530SHsCPCegItxNrxBEl0GI97aDYZ5OnA9RGLzcJ8VXfGVHsY1sn\n z6ZENC9AFlHnBcmWpoUfcft0agdZvAFr3eNLA0ujUYFEiOHie5Dj4SssTwhIUk3+qsw9T9R+UZX\n TUCCnuc9FFuhcQD2uKY4oh3UdkoX8F0H23DkR/NF9HhXxpNnpH2Xcw/kC5pP66AtJ0VMM224LSB\n 2/9A==",
        "X-Google-Smtp-Source": "\n ABdhPJxfueUYW1FuHp6JWRBapE7vT04V7irLEAzqyl15eu2pB6EVWRgXsQBr9+F7Jt7P9/crxaC58r+JMX1u",
        "X-Received": "by 2002:a17:90a:65c5:: with SMTP id\n i5mr233962pjs.112.1600230559830;\n Tue, 15 Sep 2020 21:29:19 -0700 (PDT)",
        "X-Relaying-Domain": "broadcom.com",
        "From": "Ajit Khaparde <ajit.khaparde@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "Kishore Padmanabha <kishore.padmanabha@broadcom.com>,\n Mike Baucom <michael.baucom@broadcom.com>,\n Shahaji Bhosle <sbhosle@broadcom.com>",
        "Date": "Tue, 15 Sep 2020 21:28:49 -0700",
        "Message-Id": "<20200916042851.32914-24-ajit.khaparde@broadcom.com>",
        "X-Mailer": "git-send-email 2.21.1 (Apple Git-122.3)",
        "In-Reply-To": "<20200916042851.32914-1-ajit.khaparde@broadcom.com>",
        "References": "<20200911015603.88359-1-ajit.khaparde@broadcom.com>\n <20200916042851.32914-1-ajit.khaparde@broadcom.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v2 23/25] net/bnxt: add locks in flow database",
        "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: Kishore Padmanabha <kishore.padmanabha@broadcom.com>\n\nAdded support for mutex protection for the flow database to prevent\nsimultaneous access to flow database and protect flow creation and\ndeletion.\n\nSigned-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>\nReviewed-by: Mike Baucom <michael.baucom@broadcom.com>\nReviewed-by: Shahaji Bhosle <sbhosle@broadcom.com>\nReviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\n---\n drivers/net/bnxt/tf_ulp/bnxt_ulp.c    | 33 +++++++++++++++++++++++++++\n drivers/net/bnxt/tf_ulp/bnxt_ulp.h    |  7 ++++++\n drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 13 ++++++++++-\n drivers/net/bnxt/tf_ulp/ulp_mapper.c  | 20 +++++++++++++++-\n 4 files changed, 71 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\nindex 364853a6e..e8927f629 100644\n--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n@@ -727,6 +727,9 @@ bnxt_ulp_deinit(struct bnxt *bp,\n \t\t\t\t\t TF_TUNNEL_ENCAP_NAT,\n \t\t\t\t\t BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0);\n \n+\t/* free the flow db lock */\n+\tpthread_mutex_destroy(&bp->ulp_ctx->cfg_data->flow_db_lock);\n+\n \t/* Delete the ulp context and tf session and free the ulp context */\n \tulp_ctx_deinit(bp, session);\n \tBNXT_TF_DBG(DEBUG, \"ulp ctx has been deinitialized\\n\");\n@@ -750,6 +753,12 @@ bnxt_ulp_init(struct bnxt *bp,\n \t\tgoto jump_to_error;\n \t}\n \n+\trc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Unable to initialize flow db lock\\n\");\n+\t\tgoto jump_to_error;\n+\t}\n+\n \t/* Initialize ulp dparms with values devargs passed */\n \trc = ulp_dparms_init(bp, bp->ulp_ctx);\n \tif (rc) {\n@@ -1235,3 +1244,27 @@ bnxt_ulp_cntxt_ptr2_ulp_vfr_info_get(struct bnxt_ulp_context *ulp_ctx,\n \n \treturn &ulp_ctx->cfg_data->vfr_rule_info[port_id];\n }\n+\n+/* Function to acquire the flow database lock from the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context\t*ulp_ctx)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data)\n+\t\treturn -1;\n+\n+\tif (pthread_mutex_lock(&ulp_ctx->cfg_data->flow_db_lock)) {\n+\t\tBNXT_TF_DBG(ERR, \"unable to acquire fdb lock\\n\");\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+/* Function to release the flow database lock from the ulp context. */\n+void\n+bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context\t*ulp_ctx)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data)\n+\t\treturn;\n+\n+\tpthread_mutex_unlock(&ulp_ctx->cfg_data->flow_db_lock);\n+}\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\nindex ed978734a..36405ae1e 100644\n--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\n@@ -47,6 +47,7 @@ struct bnxt_ulp_data {\n \tuint32_t\t\t\tdev_id; /* Hardware device id */\n \tuint32_t\t\t\tref_cnt;\n \tstruct bnxt_ulp_flow_db\t\t*flow_db;\n+\tpthread_mutex_t\t\t\tflow_db_lock;\n \tvoid\t\t\t\t*mapper_data;\n \tstruct bnxt_ulp_port_db\t\t*port_db;\n \tstruct bnxt_ulp_fc_info\t\t*fc_info;\n@@ -196,4 +197,10 @@ struct bnxt_ulp_vfr_rule_info*\n bnxt_ulp_cntxt_ptr2_ulp_vfr_info_get(struct bnxt_ulp_context *ulp_ctx,\n \t\t\t\t     uint32_t port_id);\n \n+int32_t\n+bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context\t*ulp_ctx);\n+\n+void\n+bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context\t*ulp_ctx);\n+\n #endif /* _BNXT_ULP_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c\nindex cbdf5df68..9a2d3758d 100644\n--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c\n+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c\n@@ -793,10 +793,17 @@ int32_t\tulp_flow_db_flush_flows(struct bnxt_ulp_context *ulp_ctx,\n \t\tBNXT_TF_DBG(ERR, \"Flow database not found\\n\");\n \t\treturn -EINVAL;\n \t}\n+\tif (bnxt_ulp_cntxt_acquire_fdb_lock(ulp_ctx)) {\n+\t\tBNXT_TF_DBG(ERR, \"Flow db lock acquire failed\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \tflow_tbl = &flow_db->flow_tbl[idx];\n \twhile (!ulp_flow_db_next_entry_get(flow_tbl, &fid))\n \t\tulp_mapper_resources_free(ulp_ctx, fid, idx);\n \n+\tbnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);\n+\n \treturn 0;\n }\n \n@@ -826,13 +833,17 @@ ulp_flow_db_function_flow_flush(struct bnxt_ulp_context *ulp_ctx,\n \t\tBNXT_TF_DBG(ERR, \"Flow database not found\\n\");\n \t\treturn -EINVAL;\n \t}\n+\tif (bnxt_ulp_cntxt_acquire_fdb_lock(ulp_ctx)) {\n+\t\tBNXT_TF_DBG(ERR, \"Flow db lock acquire failed\\n\");\n+\t\treturn -EINVAL;\n+\t}\n \tflow_tbl = &flow_db->flow_tbl[BNXT_ULP_REGULAR_FLOW_TABLE];\n \twhile (!ulp_flow_db_next_entry_get(flow_tbl, &flow_id)) {\n \t\tif (flow_db->func_id_tbl[flow_id] == func_id)\n \t\t\tulp_mapper_resources_free(ulp_ctx, flow_id,\n \t\t\t\t\t\t  BNXT_ULP_REGULAR_FLOW_TABLE);\n \t}\n-\n+\tbnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);\n \treturn 0;\n }\n \ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c\nindex 732141166..85ae3b5c4 100644\n--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c\n+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c\n@@ -2668,12 +2668,21 @@ int32_t\n ulp_mapper_flow_destroy(struct bnxt_ulp_context\t*ulp_ctx, uint32_t fid,\n \t\t\tenum bnxt_ulp_flow_db_tables flow_tbl_type)\n {\n+\tint32_t rc;\n+\n \tif (!ulp_ctx) {\n \t\tBNXT_TF_DBG(ERR, \"Invalid parms, unable to free flow\\n\");\n \t\treturn -EINVAL;\n \t}\n+\tif (bnxt_ulp_cntxt_acquire_fdb_lock(ulp_ctx)) {\n+\t\tBNXT_TF_DBG(ERR, \"Flow db lock acquire failed\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trc = ulp_mapper_resources_free(ulp_ctx, fid, flow_tbl_type);\n+\tbnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);\n+\treturn rc;\n \n-\treturn ulp_mapper_resources_free(ulp_ctx, fid, flow_tbl_type);\n }\n \n /* Function to handle the default global templates that are allocated during\n@@ -2838,6 +2847,12 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,\n \t\treturn -EINVAL;\n \t}\n \n+\t/* Protect flow creation */\n+\tif (bnxt_ulp_cntxt_acquire_fdb_lock(ulp_ctx)) {\n+\t\tBNXT_TF_DBG(ERR, \"Flow db lock acquire failed\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Allocate a Flow ID for attaching all resources for the flow to.\n \t * Once allocated, all errors have to walk the list of resources and\n \t * free each of them.\n@@ -2848,6 +2863,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,\n \t\t\t\t   &parms.fid);\n \tif (rc) {\n \t\tBNXT_TF_DBG(ERR, \"Unable to allocate flow table entry\\n\");\n+\t\tbnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);\n \t\treturn rc;\n \t}\n \n@@ -2871,10 +2887,12 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,\n \t}\n \n \t*flowid = parms.fid;\n+\tbnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);\n \n \treturn rc;\n \n flow_error:\n+\tbnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);\n \t/* Free all resources that were allocated during flow creation */\n \ttrc = ulp_mapper_flow_destroy(ulp_ctx, parms.fid,\n \t\t\t\t      BNXT_ULP_REGULAR_FLOW_TABLE);\n",
    "prefixes": [
        "v2",
        "23/25"
    ]
}