get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 127882,
    "url": "http://patches.dpdk.org/api/patches/127882/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230601195538.8265-10-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": "<20230601195538.8265-10-ivan.malov@arknetworks.am>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230601195538.8265-10-ivan.malov@arknetworks.am",
    "date": "2023-06-01T19:55:13",
    "name": "[09/34] net/sfc: add functions to manipulate MCDI table fields",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d44be495a845515aa13ff3d0ef1bbea9e297d180",
    "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/20230601195538.8265-10-ivan.malov@arknetworks.am/mbox/",
    "series": [
        {
            "id": 28307,
            "url": "http://patches.dpdk.org/api/series/28307/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28307",
            "date": "2023-06-01T19:55:04",
            "name": "net/sfc: support HW conntrack assistance",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/28307/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/127882/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/127882/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 CB7BC42C07;\n\tThu,  1 Jun 2023 21:56:49 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5582C42D62;\n\tThu,  1 Jun 2023 21:55:52 +0200 (CEST)",
            "from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80])\n by mails.dpdk.org (Postfix) with ESMTP id 049DE42D33\n for <dev@dpdk.org>; Thu,  1 Jun 2023 21:55:46 +0200 (CEST)",
            "from localhost.localdomain (unknown [78.109.69.146])\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 79228E121D;\n Thu,  1 Jun 2023 23:55:45 +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>,\n Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>,\n Andy Moreton <amoreton@xilinx.com>",
        "Subject": "[PATCH 09/34] net/sfc: add functions to manipulate MCDI table fields",
        "Date": "Thu,  1 Jun 2023 23:55:13 +0400",
        "Message-Id": "<20230601195538.8265-10-ivan.malov@arknetworks.am>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20230601195538.8265-1-ivan.malov@arknetworks.am>",
        "References": "<20230601195538.8265-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": "From: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>\n\nImplemented functions that help to fill user data for\nmanipulation with HW tables in the required format.\n\nSigned-off-by: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>\nReviewed-by: Ivan Malov <ivan.malov@arknetworks.am>\nReviewed-by: Andy Moreton <amoreton@xilinx.com>\n---\n drivers/net/sfc/meson.build |   1 +\n drivers/net/sfc/sfc_tbls.c  | 140 ++++++++++++++++++++++++++++++++++++\n drivers/net/sfc/sfc_tbls.h  | 135 ++++++++++++++++++++++++++++++++++\n 3 files changed, 276 insertions(+)\n create mode 100644 drivers/net/sfc/sfc_tbls.c",
    "diff": "diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build\nindex c2d8430810..39c7f24764 100644\n--- a/drivers/net/sfc/meson.build\n+++ b/drivers/net/sfc/meson.build\n@@ -87,6 +87,7 @@ sources = files(\n         'sfc_tso.c',\n         'sfc_filter.c',\n         'sfc_switch.c',\n+        'sfc_tbls.c',\n         'sfc_mae.c',\n         'sfc_mae_counter.c',\n         'sfc_flow.c',\ndiff --git a/drivers/net/sfc/sfc_tbls.c b/drivers/net/sfc/sfc_tbls.c\nnew file mode 100644\nindex 0000000000..db54fc0d40\n--- /dev/null\n+++ b/drivers/net/sfc/sfc_tbls.c\n@@ -0,0 +1,140 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ *\n+ * Copyright (c) 2023 Advanced Micro Devices, Inc.\n+ */\n+\n+#include \"sfc_tbls.h\"\n+#include \"sfc_debug.h\"\n+\n+#include <rte_ip.h>\n+\n+/* Number of bits in uint32_t type */\n+#define SFC_TBLS_U32_BITS (sizeof(uint32_t) * CHAR_BIT)\n+\n+static uint32_t\n+sfc_tbls_field_update(uint32_t in, uint16_t lbn, uint16_t width, uint32_t value)\n+{\n+\tuint32_t mask;\n+\n+\tif (width == SFC_TBLS_U32_BITS)\n+\t\treturn value;\n+\n+\tmask = RTE_LEN2MASK(width, uint32_t);\n+\tvalue &= mask;\n+\n+\tif (lbn != 0) {\n+\t\tmask <<= lbn;\n+\t\tvalue <<= lbn;\n+\t}\n+\n+\treturn (in & (~mask)) | value;\n+}\n+\n+void\n+sfc_tbls_field_set_u32(uint32_t data[], __rte_unused unsigned int data_size,\n+\t\t       uint16_t lbn, uint16_t width, uint32_t value)\n+{\n+\tuint32_t data_offset = 0;\n+\n+\tif (lbn >= SFC_TBLS_U32_BITS) {\n+\t\tdata_offset = lbn / SFC_TBLS_U32_BITS;\n+\n+\t\tSFC_ASSERT(data_offset < data_size);\n+\n+\t\tdata += data_offset;\n+\t\tlbn %= SFC_TBLS_U32_BITS;\n+\t}\n+\n+\tif (lbn + width <= SFC_TBLS_U32_BITS) {\n+\t\t*data = sfc_tbls_field_update(*data, lbn, width, value);\n+\t} else {\n+\t\t*data = sfc_tbls_field_update(*data, lbn,\n+\t\t\t\t\t      SFC_TBLS_U32_BITS - lbn, value);\n+\t\tvalue >>= SFC_TBLS_U32_BITS - lbn;\n+\n+\t\tdata_offset++;\n+\t\tSFC_ASSERT(data_offset < data_size);\n+\n+\t\tdata++;\n+\t\t*data = sfc_tbls_field_update(*data, 0,\n+\t\t\t\t\t      width + lbn - SFC_TBLS_U32_BITS,\n+\t\t\t\t\t      value);\n+\t}\n+}\n+\n+void\n+sfc_tbls_field_set_u16(uint32_t data[], unsigned int data_size, uint16_t lbn,\n+\t\t       uint16_t width, uint16_t value)\n+{\n+\tsfc_tbls_field_set_u32(data, data_size, lbn, width, value);\n+}\n+\n+void\n+sfc_tbls_field_set_u8(uint32_t data[], unsigned int data_size, uint16_t lbn,\n+\t\t      uint16_t width, uint8_t value)\n+{\n+\tsfc_tbls_field_set_u32(data, data_size, lbn, width, value);\n+}\n+\n+void\n+sfc_tbls_field_set_ip(uint32_t data[], unsigned int data_size, uint16_t lbn,\n+\t\t      __rte_unused uint16_t width, const uint32_t *ip)\n+{\n+\tunsigned int i;\n+\tsize_t ipv6_addr_len = RTE_SIZEOF_FIELD(struct rte_ipv6_hdr, src_addr);\n+\n+\tSFC_ASSERT(width == ipv6_addr_len * CHAR_BIT);\n+\n+\tfor (i = 0; i < ipv6_addr_len / sizeof(*ip); i++) {\n+\t\tsfc_tbls_field_set_u32(data, data_size, lbn,\n+\t\t\t\t       SFC_TBLS_U32_BITS, ip[i]);\n+\t\tlbn += SFC_TBLS_U32_BITS;\n+\t}\n+}\n+\n+void\n+sfc_tbls_field_set_u64(uint32_t data[], __rte_unused unsigned int data_size,\n+\t\t       uint16_t lbn, uint16_t width, uint64_t value)\n+{\n+\tuint32_t data_offset = 0;\n+\n+\tif (lbn >= SFC_TBLS_U32_BITS) {\n+\t\tdata_offset = lbn / SFC_TBLS_U32_BITS;\n+\n+\t\tSFC_ASSERT(data_offset < data_size);\n+\n+\t\tdata += data_offset;\n+\t\tlbn %= SFC_TBLS_U32_BITS;\n+\t}\n+\n+\t*data = sfc_tbls_field_update(*data, lbn, SFC_TBLS_U32_BITS - lbn, value);\n+\tvalue >>= SFC_TBLS_U32_BITS - lbn;\n+\twidth -= SFC_TBLS_U32_BITS - lbn;\n+\n+\tdata_offset++;\n+\tSFC_ASSERT(data_offset < data_size);\n+\n+\tdata++;\n+\n+\tif (width > SFC_TBLS_U32_BITS) {\n+\t\t*data = sfc_tbls_field_update(*data, 0, SFC_TBLS_U32_BITS, value);\n+\t\tvalue >>= SFC_TBLS_U32_BITS;\n+\t\twidth -= SFC_TBLS_U32_BITS;\n+\n+\t\tdata_offset++;\n+\t\tSFC_ASSERT(data_offset < data_size);\n+\n+\t\tdata++;\n+\t}\n+\n+\t*data = sfc_tbls_field_update(*data, 0, width, value);\n+}\n+\n+void\n+sfc_tbls_field_set_bit(uint32_t data[], unsigned int data_size, uint16_t lbn,\n+\t\t       uint16_t width, bool value)\n+{\n+\tSFC_ASSERT(width == 1);\n+\n+\tsfc_tbls_field_set_u32(data, data_size, lbn, width, value ? 1 : 0);\n+}\ndiff --git a/drivers/net/sfc/sfc_tbls.h b/drivers/net/sfc/sfc_tbls.h\nindex 2a5c87b82c..7b6bb5b341 100644\n--- a/drivers/net/sfc/sfc_tbls.h\n+++ b/drivers/net/sfc/sfc_tbls.h\n@@ -63,6 +63,141 @@ sfc_tbls_bcam_entry_delete(efx_nic_t *enp, efx_table_id_t table_id, uint16_t key\n \t\t\t\t      data, data_size);\n }\n \n+/**\n+ * All manipulations with HW tables entries require forming\n+ * a key and response.\n+ * The key and response fields follow, consecutively, each\n+ * packed as follows:\n+ *  - the key/response is logically treated as a single wide N-bit value;\n+ *  - fields have been placed in these logical values per the \"lbn\" and \"width\"\n+ *    information from the table field descriptors;\n+ *  - the wide N-bit value is padded at the MSB end up to a 32-bit boundary;\n+ *  - the values are put into the table op request with bits[31:0] of the wide\n+ *    value in the first 32-bit word, bits[63:32] in the second 32-bit word, etc.\n+ *\n+ * Below is an API that helps to form  MCDI insertion/deletion request.\n+ * Workflow:\n+ * 1) Allocate an array of EFX_TABLE_ENTRY_LENGTH_MAX bytes.\n+ * 2) Read a descriptor of the table that you want to use.\n+ * 3) Fill the array using sfc_tbls_field_set_* functions to form a key.\n+ *    Each field of the key has LBN and width. This information can be\n+ *    found in a field's descriptor.\n+ * 4) Use sfc_tbls_next_req_fields() to get a pointer where the response\n+ *    must start. It's required as the key and response need to be\n+ *    zero-padded at the MSB end to multiples of 32 bits.\n+ * 5) Fill the response the same way.\n+ * 6) Use sfc_tbls_next_req_fields() to get the end of the data request.\n+ *    It will help you to get the real size of the data request.\n+ */\n+\n+/**\n+ * Get a pointer to the beginning of the next 32-bit wide fields\n+ * that go after a given width.\n+ * It should be used to get a pointer to the response's start and the end\n+ * of the data for an MCDI request.\n+ *\n+ * @param data\t\tPointer to the data to make an offset from\n+ * @param width\t\tWidth of fields to offset\n+ *\n+ * @note @p width is expected to be a key's or response's size.\n+ *\n+ * @return Pointer to the beginning of the next field.\n+ */\n+static inline uint32_t *\n+sfc_tbls_next_req_fields(uint32_t *data, uint16_t width) {\n+\treturn data + EFX_DIV_ROUND_UP(width, sizeof(*data) * CHAR_BIT);\n+}\n+\n+/**\n+ * Insert value into a field in the @p data buffer starting at\n+ * bit offset @p lbn and containing @p width bits.\n+ *\n+ * @param data\t\tData buffer\n+ * @param data_size\tSize of the data buffer\n+ * @param lbn\t\tOffset\n+ * @param width\t\tWidth of @p value in bits\n+ * @param value\t\tuint32_t value to insert\n+ *\n+ * @note @p width and @p lbn must to be obtained from the field's descriptor.\n+ */\n+void sfc_tbls_field_set_u32(uint32_t data[], unsigned int data_size,\n+\t\t\t    uint16_t lbn, uint16_t width, uint32_t value);\n+\n+/**\n+ * Insert value into a field in the @p data buffer starting at\n+ * bit offset @p lbn and containing @p width bits.\n+ *\n+ * @param data\t\tData buffer\n+ * @param data_size\tSize of the data buffer\n+ * @param lbn\t\tOffset\n+ * @param width\t\tWidth of @p value in bits\n+ * @param value\t\tuint16_t value to insert\n+ *\n+ * @note @p width and @p lbn must to be obtained from the field's descriptor.\n+ */\n+void sfc_tbls_field_set_u16(uint32_t data[], unsigned int data_size,\n+\t\t\t    uint16_t lbn, uint16_t width, uint16_t value);\n+\n+/**\n+ * Insert value into a field in the @p data buffer starting at\n+ * bit offset @p lbn and containing @p width bits.\n+ *\n+ * @param data\t\tData buffer\n+ * @param data_size\tSize of the data buffer\n+ * @param lbn\t\tOffset\n+ * @param width\t\tWidth of @p value in bits\n+ * @param value\t\tuint8_t value to insert\n+ *\n+ * @note @p width and @p lbn must to be obtained from the field's descriptor.\n+ */\n+void sfc_tbls_field_set_u8(uint32_t data[], unsigned int data_size,\n+\t\t\t   uint16_t lbn, uint16_t width, uint8_t value);\n+\n+/**\n+ * Insert IP address into a field in the @p data buffer starting at\n+ * bit offset @p lbn and containing @p width bits.\n+ *\n+ * @param data\t\tData buffer\n+ * @param data_size\tSize of the data buffer\n+ * @param lbn\t\tOffset\n+ * @param width\t\tWidth of @p value in bits\n+ * @param ip\t\tIP address to insert\n+ *\n+ * @note @p width and @p lbn must to be obtained from the field's descriptor.\n+ */\n+void sfc_tbls_field_set_ip(uint32_t data[], unsigned int data_size,\n+\t\t\t   uint16_t lbn, uint16_t width, const uint32_t *ip);\n+\n+/**\n+ * Insert value into a field in the data buffer starting at\n+ * bit offset @p lbn and containing @p width bits.\n+ *\n+ * @param data\t\tData buffer\n+ * @param data_size\tSize of the data buffer\n+ * @param lbn\t\tOffset\n+ * @param width\t\tWidth of @p value in bits\n+ * @param value\t\tuint64_t value to insert\n+ *\n+ * @note @p width and @p lbn must to be obtained from the field's descriptor.\n+ */\n+void sfc_tbls_field_set_u64(uint32_t data[], unsigned int data_size,\n+\t\t\t    uint16_t lbn, uint16_t width, uint64_t value);\n+\n+/**\n+ * Insert value into a field in the @p data buffer starting at\n+ * bit offset @p lbn and containing @p width bits.\n+ *\n+ * @param data\t\tData buffer\n+ * @param data_size\tSize of the data buffer\n+ * @param lbn\t\tOffset\n+ * @param width\t\tWidth of @p value in bits\n+ * @param value\t\tBit value to insert\n+ *\n+ * @note @p width and @p lbn must to be obtained from the field's descriptor.\n+ */\n+void sfc_tbls_field_set_bit(uint32_t data[], unsigned int data_size,\n+\t\t\t    uint16_t lbn, uint16_t width, bool value);\n+\n #ifdef __cplusplus\n }\n #endif\n",
    "prefixes": [
        "09/34"
    ]
}