get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 128320,
    "url": "http://patches.dpdk.org/api/patches/128320/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230607130245.8048-32-ivan.malov@arknetworks.am/",
    "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": "<20230607130245.8048-32-ivan.malov@arknetworks.am>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230607130245.8048-32-ivan.malov@arknetworks.am",
    "date": "2023-06-07T13:02:42",
    "name": "[v4,31/34] common/sfc_efx/base: rework MAE counter provisioning helpers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "fab9891d64340c6ac0fa3cc969fd39be742f172a",
    "submitter": {
        "id": 2962,
        "url": "http://patches.dpdk.org/api/people/2962/?format=api",
        "name": "Ivan Malov",
        "email": "ivan.malov@arknetworks.am"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230607130245.8048-32-ivan.malov@arknetworks.am/mbox/",
    "series": [
        {
            "id": 28390,
            "url": "http://patches.dpdk.org/api/series/28390/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28390",
            "date": "2023-06-07T13:02:11",
            "name": "net/sfc: support HW conntrack assistance",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/28390/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/128320/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/128320/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 2822842C4D;\n\tWed,  7 Jun 2023 15:07:29 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 50D8A43010;\n\tWed,  7 Jun 2023 15:03:28 +0200 (CEST)",
            "from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80])\n by mails.dpdk.org (Postfix) with ESMTP id 7CAD042D8E\n for <dev@dpdk.org>; Wed,  7 Jun 2023 15:03:04 +0200 (CEST)",
            "from localhost.localdomain (unknown [78.109.69.83])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by agw.arknetworks.am (Postfix) with ESMTPSA id F100CE12C4;\n Wed,  7 Jun 2023 17:03:03 +0400 (+04)"
        ],
        "From": "Ivan Malov <ivan.malov@arknetworks.am>",
        "To": "dev@dpdk.org",
        "Cc": "Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Ferruh Yigit <ferruh.yigit@amd.com>, Andy Moreton <amoreton@xilinx.com>",
        "Subject": "[PATCH v4 31/34] common/sfc_efx/base: rework MAE counter provisioning\n helpers",
        "Date": "Wed,  7 Jun 2023 17:02:42 +0400",
        "Message-Id": "<20230607130245.8048-32-ivan.malov@arknetworks.am>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20230607130245.8048-1-ivan.malov@arknetworks.am>",
        "References": "<20230601195538.8265-1-ivan.malov@arknetworks.am>\n <20230607130245.8048-1-ivan.malov@arknetworks.am>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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"
    },
    "content": "Doing so is required to disambiguate counters of different\ntypes supported by the match-action engine (MAE) on EF100.\n\nCurrently, the code only supports action rule counters,\nbut MAE may also support conntrack assistance counters.\nAdd type-aware allocate and free MCDI handlers and\nextend reporting of counter limits accordingly.\n\nSigned-off-by: Ivan Malov <ivan.malov@arknetworks.am>\nReviewed-by: Andy Moreton <amoreton@xilinx.com>\n---\n drivers/common/sfc_efx/base/efx.h      |  39 +++++++-\n drivers/common/sfc_efx/base/efx_impl.h |   2 +-\n drivers/common/sfc_efx/base/efx_mae.c  | 120 ++++++++++++++++++++-----\n drivers/common/sfc_efx/version.map     |   2 +\n 4 files changed, 140 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h\nindex a296d34f29..5a2e05134a 100644\n--- a/drivers/common/sfc_efx/base/efx.h\n+++ b/drivers/common/sfc_efx/base/efx.h\n@@ -4191,7 +4191,10 @@ typedef struct efx_mae_limits_s {\n \tuint32_t\t\t\teml_max_n_outer_prios;\n \tuint32_t\t\t\teml_encap_types_supported;\n \tuint32_t\t\t\teml_encap_header_size_limit;\n-\tuint32_t\t\t\teml_max_n_counters;\n+\tunion {\n+\t\tuint32_t\t\teml_max_n_counters;\n+\t\tuint32_t\t\teml_max_n_action_counters;\n+\t};\n } efx_mae_limits_t;\n \n LIBEFX_API\n@@ -4780,6 +4783,14 @@ efx_mae_action_set_fill_in_eh_id(\n \t__in\t\t\t\tefx_mae_actions_t *spec,\n \t__in\t\t\t\tconst efx_mae_eh_id_t *eh_idp);\n \n+/*\n+ * Counter types that may be supported by the match-action engine.\n+ * Each counter type maintains its own counter ID namespace in FW.\n+ */\n+typedef enum efx_counter_type_e {\n+\tEFX_COUNTER_TYPE_ACTION = 0,\n+} efx_counter_type_t;\n+\n typedef struct efx_counter_s {\n \tuint32_t id;\n } efx_counter_t;\n@@ -4809,6 +4820,8 @@ efx_mae_action_set_alloc(\n \t__out\t\t\t\tefx_mae_aset_id_t *aset_idp);\n \n /*\n+ * Allocates MAE counter(s) of type EFX_COUNTER_TYPE_ACTION.\n+ *\n  * Generation count has two purposes:\n  *\n  * 1) Distinguish between counter packets that belong to freed counter\n@@ -4832,6 +4845,20 @@ efx_mae_counters_alloc(\n \t__out_ecount(n_counters)\tefx_counter_t *countersp,\n \t__out_opt\t\t\tuint32_t *gen_countp);\n \n+/*\n+ * Allocates MAE counter(s) of the specified type. Other\n+ * than that, behaves like efx_mae_counters_alloc().\n+ */\n+LIBEFX_API\n+extern\t__checkReturn\t\t\tefx_rc_t\n+efx_mae_counters_alloc_type(\n+\t__in\t\t\t\tefx_nic_t *enp,\n+\t__in\t\t\t\tefx_counter_type_t type,\n+\t__in\t\t\t\tuint32_t n_counters,\n+\t__out\t\t\t\tuint32_t *n_allocatedp,\n+\t__out_ecount(n_counters)\tefx_counter_t *countersp,\n+\t__out_opt\t\t\tuint32_t *gen_countp);\n+\n LIBEFX_API\n extern\t__checkReturn\t\t\tefx_rc_t\n efx_mae_counters_free(\n@@ -4841,6 +4868,16 @@ efx_mae_counters_free(\n \t__in_ecount(n_counters)\t\tconst efx_counter_t *countersp,\n \t__out_opt\t\t\tuint32_t *gen_countp);\n \n+LIBEFX_API\n+extern\t__checkReturn\t\t\tefx_rc_t\n+efx_mae_counters_free_type(\n+\t__in\t\t\t\tefx_nic_t *enp,\n+\t__in\t\t\t\tefx_counter_type_t type,\n+\t__in\t\t\t\tuint32_t n_counters,\n+\t__out\t\t\t\tuint32_t *n_freedp,\n+\t__in_ecount(n_counters)\t\tconst efx_counter_t *countersp,\n+\t__out_opt\t\t\tuint32_t *gen_countp);\n+\n /* When set, include counters with a value of zero */\n #define\tEFX_MAE_COUNTERS_STREAM_IN_ZERO_SQUASH_DISABLE\t(1U << 0)\n \ndiff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h\nindex e978ad0de8..f6b472c160 100644\n--- a/drivers/common/sfc_efx/base/efx_impl.h\n+++ b/drivers/common/sfc_efx/base/efx_impl.h\n@@ -841,7 +841,7 @@ typedef struct efx_mae_s {\n \t/** Outer rule match field capabilities. */\n \tefx_mae_field_cap_t\t\t*em_outer_rule_field_caps;\n \tsize_t\t\t\t\tem_outer_rule_field_caps_size;\n-\tuint32_t\t\t\tem_max_ncounters;\n+\tuint32_t\t\t\tem_max_n_action_counters;\n } efx_mae_t;\n \n #endif /* EFSYS_OPT_MAE */\ndiff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c\nindex aaea38c933..4078146741 100644\n--- a/drivers/common/sfc_efx/base/efx_mae.c\n+++ b/drivers/common/sfc_efx/base/efx_mae.c\n@@ -67,8 +67,8 @@ efx_mae_get_capabilities(\n \tmaep->em_max_nfields =\n \t    MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_MATCH_FIELD_COUNT);\n \n-\tmaep->em_max_ncounters =\n-\t    MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_COUNTERS);\n+\tmaep->em_max_n_action_counters =\n+\t    MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_AR_COUNTERS);\n \n \treturn (0);\n \n@@ -374,7 +374,7 @@ efx_mae_get_limits(\n \temlp->eml_encap_types_supported = maep->em_encap_types_supported;\n \temlp->eml_encap_header_size_limit =\n \t    MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_MAXNUM_MCDI2;\n-\temlp->eml_max_n_counters = maep->em_max_ncounters;\n+\temlp->eml_max_n_action_counters = maep->em_max_n_action_counters;\n \n \treturn (0);\n \n@@ -3256,55 +3256,70 @@ efx_mae_action_set_fill_in_counter_id(\n }\n \n \t__checkReturn\t\t\tefx_rc_t\n-efx_mae_counters_alloc(\n+efx_mae_counters_alloc_type(\n \t__in\t\t\t\tefx_nic_t *enp,\n+\t__in\t\t\t\tefx_counter_type_t type,\n \t__in\t\t\t\tuint32_t n_counters,\n \t__out\t\t\t\tuint32_t *n_allocatedp,\n \t__out_ecount(n_counters)\tefx_counter_t *countersp,\n \t__out_opt\t\t\tuint32_t *gen_countp)\n {\n \tEFX_MCDI_DECLARE_BUF(payload,\n-\t    MC_CMD_MAE_COUNTER_ALLOC_IN_LEN,\n+\t    MC_CMD_MAE_COUNTER_ALLOC_V2_IN_LEN,\n \t    MC_CMD_MAE_COUNTER_ALLOC_OUT_LENMAX_MCDI2);\n \tefx_mae_t *maep = enp->en_maep;\n+\tuint32_t max_n_counters;\n \tuint32_t n_allocated;\n \tefx_mcdi_req_t req;\n \tunsigned int i;\n \tefx_rc_t rc;\n \n-\tif (n_counters > maep->em_max_ncounters ||\n+\tEFX_STATIC_ASSERT(EFX_COUNTER_TYPE_ACTION == MAE_COUNTER_TYPE_AR);\n+\n+\tswitch (type) {\n+\tcase EFX_COUNTER_TYPE_ACTION:\n+\t\tmax_n_counters = maep->em_max_n_action_counters;\n+\t\tbreak;\n+\tdefault:\n+\t\trc = EINVAL;\n+\t\tgoto fail1;\n+\t}\n+\n+\tif (n_counters > max_n_counters ||\n \t    n_counters < MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_MINNUM ||\n \t    n_counters > MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_MAXNUM_MCDI2) {\n \t\trc = EINVAL;\n-\t\tgoto fail1;\n+\t\tgoto fail2;\n \t}\n \n \treq.emr_cmd = MC_CMD_MAE_COUNTER_ALLOC;\n \treq.emr_in_buf = payload;\n-\treq.emr_in_length = MC_CMD_MAE_COUNTER_ALLOC_IN_LEN;\n+\treq.emr_in_length = MC_CMD_MAE_COUNTER_ALLOC_V2_IN_LEN;\n \treq.emr_out_buf = payload;\n \treq.emr_out_length = MC_CMD_MAE_COUNTER_ALLOC_OUT_LEN(n_counters);\n \n \tMCDI_IN_SET_DWORD(req, MAE_COUNTER_ALLOC_IN_REQUESTED_COUNT,\n \t    n_counters);\n \n+\tMCDI_IN_SET_DWORD(req, MAE_COUNTER_ALLOC_V2_IN_COUNTER_TYPE, type);\n+\n \tefx_mcdi_execute(enp, &req);\n \n \tif (req.emr_rc != 0) {\n \t\trc = req.emr_rc;\n-\t\tgoto fail2;\n+\t\tgoto fail3;\n \t}\n \n \tif (req.emr_out_length_used < MC_CMD_MAE_COUNTER_ALLOC_OUT_LENMIN) {\n \t\trc = EMSGSIZE;\n-\t\tgoto fail3;\n+\t\tgoto fail4;\n \t}\n \n \tn_allocated = MCDI_OUT_DWORD(req,\n \t    MAE_COUNTER_ALLOC_OUT_COUNTER_ID_COUNT);\n \tif (n_allocated < MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_MINNUM) {\n \t\trc = EFAULT;\n-\t\tgoto fail4;\n+\t\tgoto fail5;\n \t}\n \n \tfor (i = 0; i < n_allocated; i++) {\n@@ -3321,6 +3336,8 @@ efx_mae_counters_alloc(\n \n \treturn (0);\n \n+fail5:\n+\tEFSYS_PROBE(fail5);\n fail4:\n \tEFSYS_PROBE(fail4);\n fail3:\n@@ -3334,33 +3351,67 @@ efx_mae_counters_alloc(\n }\n \n \t__checkReturn\t\t\tefx_rc_t\n-efx_mae_counters_free(\n+efx_mae_counters_alloc(\n \t__in\t\t\t\tefx_nic_t *enp,\n \t__in\t\t\t\tuint32_t n_counters,\n+\t__out\t\t\t\tuint32_t *n_allocatedp,\n+\t__out_ecount(n_counters)\tefx_counter_t *countersp,\n+\t__out_opt\t\t\tuint32_t *gen_countp)\n+{\n+\tefx_rc_t rc;\n+\n+\trc = efx_mae_counters_alloc_type(enp, EFX_COUNTER_TYPE_ACTION,\n+\t\t\t\t\t n_counters, n_allocatedp,\n+\t\t\t\t\t countersp, gen_countp);\n+\tif (rc != 0)\n+\t\tgoto fail1;\n+\n+\treturn (0);\n+\n+fail1:\n+\tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n+\treturn (rc);\n+}\n+\n+\t__checkReturn\t\t\tefx_rc_t\n+efx_mae_counters_free_type(\n+\t__in\t\t\t\tefx_nic_t *enp,\n+\t__in\t\t\t\tefx_counter_type_t type,\n+\t__in\t\t\t\tuint32_t n_counters,\n \t__out\t\t\t\tuint32_t *n_freedp,\n \t__in_ecount(n_counters)\t\tconst efx_counter_t *countersp,\n \t__out_opt\t\t\tuint32_t *gen_countp)\n {\n \tEFX_MCDI_DECLARE_BUF(payload,\n-\t    MC_CMD_MAE_COUNTER_FREE_IN_LENMAX_MCDI2,\n+\t    MC_CMD_MAE_COUNTER_FREE_V2_IN_LEN,\n \t    MC_CMD_MAE_COUNTER_FREE_OUT_LENMAX_MCDI2);\n \tefx_mae_t *maep = enp->en_maep;\n+\tuint32_t max_n_counters;\n \tefx_mcdi_req_t req;\n \tuint32_t n_freed;\n \tunsigned int i;\n \tefx_rc_t rc;\n \n-\tif (n_counters > maep->em_max_ncounters ||\n-\t    n_counters < MC_CMD_MAE_COUNTER_FREE_IN_FREE_COUNTER_ID_MINNUM ||\n-\t    n_counters >\n-\t    MC_CMD_MAE_COUNTER_FREE_IN_FREE_COUNTER_ID_MAXNUM_MCDI2) {\n+\tswitch (type) {\n+\tcase EFX_COUNTER_TYPE_ACTION:\n+\t\tmax_n_counters = maep->em_max_n_action_counters;\n+\t\tbreak;\n+\tdefault:\n \t\trc = EINVAL;\n \t\tgoto fail1;\n \t}\n \n+\tif (n_counters > max_n_counters ||\n+\t    n_counters < MC_CMD_MAE_COUNTER_FREE_V2_IN_FREE_COUNTER_ID_MINNUM ||\n+\t    n_counters >\n+\t    MC_CMD_MAE_COUNTER_FREE_V2_IN_FREE_COUNTER_ID_MAXNUM_MCDI2) {\n+\t\trc = EINVAL;\n+\t\tgoto fail2;\n+\t}\n+\n \treq.emr_cmd = MC_CMD_MAE_COUNTER_FREE;\n \treq.emr_in_buf = payload;\n-\treq.emr_in_length = MC_CMD_MAE_COUNTER_FREE_IN_LEN(n_counters);\n+\treq.emr_in_length = MC_CMD_MAE_COUNTER_FREE_V2_IN_LEN;\n \treq.emr_out_buf = payload;\n \treq.emr_out_length = MC_CMD_MAE_COUNTER_FREE_OUT_LEN(n_counters);\n \n@@ -3371,23 +3422,25 @@ efx_mae_counters_free(\n \tMCDI_IN_SET_DWORD(req, MAE_COUNTER_FREE_IN_COUNTER_ID_COUNT,\n \t\t\t  n_counters);\n \n+\tMCDI_IN_SET_DWORD(req, MAE_COUNTER_FREE_V2_IN_COUNTER_TYPE, type);\n+\n \tefx_mcdi_execute(enp, &req);\n \n \tif (req.emr_rc != 0) {\n \t\trc = req.emr_rc;\n-\t\tgoto fail2;\n+\t\tgoto fail3;\n \t}\n \n \tif (req.emr_out_length_used < MC_CMD_MAE_COUNTER_FREE_OUT_LENMIN) {\n \t\trc = EMSGSIZE;\n-\t\tgoto fail3;\n+\t\tgoto fail4;\n \t}\n \n \tn_freed = MCDI_OUT_DWORD(req, MAE_COUNTER_FREE_OUT_COUNTER_ID_COUNT);\n \n \tif (n_freed < MC_CMD_MAE_COUNTER_FREE_OUT_FREED_COUNTER_ID_MINNUM) {\n \t\trc = EFAULT;\n-\t\tgoto fail4;\n+\t\tgoto fail5;\n \t}\n \n \tif (gen_countp != NULL) {\n@@ -3399,6 +3452,8 @@ efx_mae_counters_free(\n \n \treturn (0);\n \n+fail5:\n+\tEFSYS_PROBE(fail5);\n fail4:\n \tEFSYS_PROBE(fail4);\n fail3:\n@@ -3411,6 +3466,29 @@ efx_mae_counters_free(\n \treturn (rc);\n }\n \n+\t__checkReturn\t\t\tefx_rc_t\n+efx_mae_counters_free(\n+\t__in\t\t\t\tefx_nic_t *enp,\n+\t__in\t\t\t\tuint32_t n_counters,\n+\t__out\t\t\t\tuint32_t *n_freedp,\n+\t__in_ecount(n_counters)\t\tconst efx_counter_t *countersp,\n+\t__out_opt\t\t\tuint32_t *gen_countp)\n+{\n+\tefx_rc_t rc;\n+\n+\trc = efx_mae_counters_free_type(enp, EFX_COUNTER_TYPE_ACTION,\n+\t\t\t\t\tn_counters, n_freedp,\n+\t\t\t\t\tcountersp, gen_countp);\n+\tif (rc != 0)\n+\t\tgoto fail1;\n+\n+\treturn (0);\n+\n+fail1:\n+\tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n+\treturn (rc);\n+}\n+\n \t__checkReturn\t\t\tefx_rc_t\n efx_mae_counters_stream_start(\n \t__in\t\t\t\tefx_nic_t *enp,\ndiff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map\nindex 1ff760a024..e550b64be6 100644\n--- a/drivers/common/sfc_efx/version.map\n+++ b/drivers/common/sfc_efx/version.map\n@@ -113,7 +113,9 @@ INTERNAL {\n \tefx_mae_action_set_spec_init;\n \tefx_mae_action_set_specs_equal;\n \tefx_mae_counters_alloc;\n+\tefx_mae_counters_alloc_type;\n \tefx_mae_counters_free;\n+\tefx_mae_counters_free_type;\n \tefx_mae_counters_stream_give_credits;\n \tefx_mae_counters_stream_start;\n \tefx_mae_counters_stream_stop;\n",
    "prefixes": [
        "v4",
        "31/34"
    ]
}