get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 66535,
    "url": "http://patches.dpdk.org/api/patches/66535/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/4c50f2a293a7dbb175584d9f98413aa31ca2f6ec.1583906144.git.kaara.satwik@chelsio.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": "<4c50f2a293a7dbb175584d9f98413aa31ca2f6ec.1583906144.git.kaara.satwik@chelsio.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/4c50f2a293a7dbb175584d9f98413aa31ca2f6ec.1583906144.git.kaara.satwik@chelsio.com",
    "date": "2020-03-11T09:05:48",
    "name": "[6/9] net/cxgbe: add Source MAC Table (SMT) support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "ffadcd7448a52d1694f2da0bbe3f22aa41a28dc2",
    "submitter": {
        "id": 241,
        "url": "http://patches.dpdk.org/api/people/241/?format=api",
        "name": "Rahul Lakkireddy",
        "email": "rahul.lakkireddy@chelsio.com"
    },
    "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/4c50f2a293a7dbb175584d9f98413aa31ca2f6ec.1583906144.git.kaara.satwik@chelsio.com/mbox/",
    "series": [
        {
            "id": 8880,
            "url": "http://patches.dpdk.org/api/series/8880/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8880",
            "date": "2020-03-11T09:05:42",
            "name": "net/cxgbe: updates for rte_flow support",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8880/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/66535/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/66535/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 A3C89A0567;\n\tWed, 11 Mar 2020 10:17:44 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id C82F51C06A;\n\tWed, 11 Mar 2020 10:16:56 +0100 (CET)",
            "from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8])\n by dpdk.org (Postfix) with ESMTP id 85A6E1C02C\n for <dev@dpdk.org>; Wed, 11 Mar 2020 10:16:55 +0100 (CET)",
            "from localhost (scalar.blr.asicdesigners.com [10.193.185.94])\n by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 02B9Gr2Q014339;\n Wed, 11 Mar 2020 02:16:54 -0700"
        ],
        "From": "Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>",
        "To": "dev@dpdk.org",
        "Cc": "nirranjan@chelsio.com, kaara.satwik@chelsio.com",
        "Date": "Wed, 11 Mar 2020 14:35:48 +0530",
        "Message-Id": "\n <4c50f2a293a7dbb175584d9f98413aa31ca2f6ec.1583906144.git.kaara.satwik@chelsio.com>",
        "X-Mailer": "git-send-email 2.5.3",
        "In-Reply-To": [
            "<cover.1583906144.git.kaara.satwik@chelsio.com>",
            "<cover.1583906144.git.kaara.satwik@chelsio.com>"
        ],
        "References": [
            "<cover.1583906144.git.kaara.satwik@chelsio.com>",
            "<cover.1583906144.git.kaara.satwik@chelsio.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH 6/9] net/cxgbe: add Source MAC Table (SMT) support",
        "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: Karra Satwik <kaara.satwik@chelsio.com>\n\nSource MAC Table (SMT) is used for storing Source MAC\naddresses to be written in packets transmitted on the\nwire. Hence, the SMT table can be used for overwriting\nSource MAC addresses in packets, hitting corresponding\nfilter rules inserted by the rte_flow API.\n\nQuery firmware for SMT start and size information available\nto the underlying PF. Allocate and maintain the corresponding\ndriver's copy of the hardware SMT table, with appropriate\nrefcount mechanism. If SMT information is not available, then\nuse the entire hardware SMT table.\n\nSigned-off-by: Karra Satwik <kaara.satwik@chelsio.com>\nSigned-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>\n---\n drivers/net/cxgbe/Makefile              |  1 +\n drivers/net/cxgbe/base/adapter.h        |  1 +\n drivers/net/cxgbe/base/t4fw_interface.h |  2 ++\n drivers/net/cxgbe/cxgbe_main.c          | 41 ++++++++++++++++++++++-\n drivers/net/cxgbe/meson.build           |  1 +\n drivers/net/cxgbe/smt.c                 | 43 +++++++++++++++++++++++++\n drivers/net/cxgbe/smt.h                 | 39 ++++++++++++++++++++++\n 7 files changed, 127 insertions(+), 1 deletion(-)\n create mode 100644 drivers/net/cxgbe/smt.c\n create mode 100644 drivers/net/cxgbe/smt.h",
    "diff": "diff --git a/drivers/net/cxgbe/Makefile b/drivers/net/cxgbe/Makefile\nindex 79c6e1d1f..53b2bb56d 100644\n--- a/drivers/net/cxgbe/Makefile\n+++ b/drivers/net/cxgbe/Makefile\n@@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += t4_hw.c\n SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += clip_tbl.c\n SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += mps_tcam.c\n SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += l2t.c\n+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += smt.c\n SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += t4vf_hw.c\n \n include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h\nindex c6b8036fd..ae318ccf5 100644\n--- a/drivers/net/cxgbe/base/adapter.h\n+++ b/drivers/net/cxgbe/base/adapter.h\n@@ -342,6 +342,7 @@ struct adapter {\n \tunsigned int l2t_end;     /* Layer 2 table end */\n \tstruct clip_tbl *clipt;   /* CLIP table */\n \tstruct l2t_data *l2t;     /* Layer 2 table */\n+\tstruct smt_data *smt;     /* Source mac table */\n \tstruct mpstcam_table *mpstcam;\n \n \tstruct tid_info tids;     /* Info used to access TID related tables */\ndiff --git a/drivers/net/cxgbe/base/t4fw_interface.h b/drivers/net/cxgbe/base/t4fw_interface.h\nindex 39e02077f..3684c8006 100644\n--- a/drivers/net/cxgbe/base/t4fw_interface.h\n+++ b/drivers/net/cxgbe/base/t4fw_interface.h\n@@ -695,6 +695,8 @@ enum fw_params_param_pfvf {\n \tFW_PARAMS_PARAM_PFVF_CPLFW4MSG_ENCAP = 0x31,\n \tFW_PARAMS_PARAM_PFVF_PORT_CAPS32 = 0x3A,\n \tFW_PARAMS_PARAM_PFVF_MAX_PKTS_PER_ETH_TX_PKTS_WR = 0x3D,\n+\tFW_PARAMS_PARAM_PFVF_GET_SMT_START = 0x3E,\n+\tFW_PARAMS_PARAM_PFVF_GET_SMT_SIZE = 0x3F,\n };\n \n /*\ndiff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c\nindex a286d8557..1ab6f8fba 100644\n--- a/drivers/net/cxgbe/cxgbe_main.c\n+++ b/drivers/net/cxgbe/cxgbe_main.c\n@@ -40,6 +40,7 @@\n #include \"cxgbe_pfvf.h\"\n #include \"clip_tbl.h\"\n #include \"l2t.h\"\n+#include \"smt.h\"\n #include \"mps_tcam.h\"\n \n /**\n@@ -1735,6 +1736,7 @@ void cxgbe_close(struct adapter *adapter)\n \t\tt4_cleanup_mpstcam(adapter);\n \t\tt4_cleanup_clip_tbl(adapter);\n \t\tt4_cleanup_l2t(adapter);\n+\t\tt4_cleanup_smt(adapter);\n \t\tif (is_pf4(adapter))\n \t\t\tt4_intr_disable(adapter);\n \t\tt4_sge_tx_monitor_stop(adapter);\n@@ -1753,13 +1755,45 @@ void cxgbe_close(struct adapter *adapter)\n \t\tt4_fw_bye(adapter, adapter->mbox);\n }\n \n+static void adap_smt_index(struct adapter *adapter, u32 *smt_start_idx,\n+\t\t\t   u32 *smt_size)\n+{\n+\tu32 params[2], smt_val[2];\n+\tint ret;\n+\n+\tparams[0] = CXGBE_FW_PARAM_PFVF(GET_SMT_START);\n+\tparams[1] = CXGBE_FW_PARAM_PFVF(GET_SMT_SIZE);\n+\n+\tret = t4_query_params(adapter, adapter->mbox, adapter->pf, 0,\n+\t\t\t      2, params, smt_val);\n+\n+\t/* if FW doesn't recognize this command then set it to default setting\n+\t * which is start index as 0 and size as 256.\n+\t */\n+\tif (ret < 0) {\n+\t\t*smt_start_idx = 0;\n+\t\t*smt_size = SMT_SIZE;\n+\t} else {\n+\t\t*smt_start_idx = smt_val[0];\n+\t\t/* smt size can be zero, if nsmt is not yet configured in\n+\t\t * the config file or set as zero, then configure all the\n+\t\t * remaining entries to this PF itself.\n+\t\t */\n+\t\tif (!smt_val[1])\n+\t\t\t*smt_size = SMT_SIZE - *smt_start_idx;\n+\t\telse\n+\t\t\t*smt_size = smt_val[1];\n+\t}\n+}\n+\n int cxgbe_probe(struct adapter *adapter)\n {\n+\tu32 smt_start_idx, smt_size;\n \tstruct port_info *pi;\n-\tint chip;\n \tint func, i;\n \tint err = 0;\n \tu32 whoami;\n+\tint chip;\n \n \twhoami = t4_read_reg(adapter, A_PL_WHOAMI);\n \tchip = t4_get_chip_type(adapter,\n@@ -1904,6 +1938,11 @@ int cxgbe_probe(struct adapter *adapter)\n \t\tdev_warn(adapter, \"could not allocate CLIP. Continuing\\n\");\n \t}\n \n+\tadap_smt_index(adapter, &smt_start_idx, &smt_size);\n+\tadapter->smt = t4_init_smt(smt_start_idx, smt_size);\n+\tif (!adapter->smt)\n+\t\tdev_warn(adapter, \"could not allocate SMT, continuing\\n\");\n+\n \tadapter->l2t = t4_init_l2t(adapter->l2t_start, adapter->l2t_end);\n \tif (!adapter->l2t) {\n \t\t/* We tolerate a lack of L2T, giving up some functionality */\ndiff --git a/drivers/net/cxgbe/meson.build b/drivers/net/cxgbe/meson.build\nindex c51af26e9..3992aba44 100644\n--- a/drivers/net/cxgbe/meson.build\n+++ b/drivers/net/cxgbe/meson.build\n@@ -11,6 +11,7 @@ sources = files('cxgbe_ethdev.c',\n \t'clip_tbl.c',\n \t'mps_tcam.c',\n \t'l2t.c',\n+\t'smt.c',\n \t'base/t4_hw.c',\n \t'base/t4vf_hw.c')\n includes += include_directories('base')\ndiff --git a/drivers/net/cxgbe/smt.c b/drivers/net/cxgbe/smt.c\nnew file mode 100644\nindex 000000000..cf40c8a8a\n--- /dev/null\n+++ b/drivers/net/cxgbe/smt.c\n@@ -0,0 +1,43 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Chelsio Communications.\n+ * All rights reserved.\n+ */\n+\n+#include \"base/common.h\"\n+#include \"smt.h\"\n+\n+/**\n+ * Initialize Source MAC Table\n+ */\n+struct smt_data *t4_init_smt(u32 smt_start_idx, u32 smt_size)\n+{\n+\tstruct smt_data *s;\n+\tu32 i;\n+\n+\ts = t4_alloc_mem(sizeof(*s) + smt_size * sizeof(struct smt_entry));\n+\tif (!s)\n+\t\treturn NULL;\n+\n+\ts->smt_start = smt_start_idx;\n+\ts->smt_size = smt_size;\n+\tt4_os_rwlock_init(&s->lock);\n+\n+\tfor (i = 0; i < s->smt_size; ++i) {\n+\t\ts->smtab[i].idx = i;\n+\t\ts->smtab[i].hw_idx = smt_start_idx + i;\n+\t\ts->smtab[i].state = SMT_STATE_UNUSED;\n+\t\tmemset(&s->smtab[i].src_mac, 0, RTE_ETHER_ADDR_LEN);\n+\t\tt4_os_lock_init(&s->smtab[i].lock);\n+\t\trte_atomic32_set(&s->smtab[i].refcnt, 0);\n+\t}\n+\treturn s;\n+}\n+\n+/**\n+ * Cleanup Source MAC Table\n+ */\n+void t4_cleanup_smt(struct adapter *adap)\n+{\n+\tif (adap->smt)\n+\t\tt4_os_free(adap->smt);\n+}\ndiff --git a/drivers/net/cxgbe/smt.h b/drivers/net/cxgbe/smt.h\nnew file mode 100644\nindex 000000000..aa4afcce2\n--- /dev/null\n+++ b/drivers/net/cxgbe/smt.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Chelsio Communications.\n+ * All rights reserved.\n+ */\n+#ifndef __CXGBE_SMT_H_\n+#define __CXGBE_SMT_H_\n+\n+enum {\n+\tSMT_STATE_SWITCHING,\n+\tSMT_STATE_UNUSED,\n+\tSMT_STATE_ERROR\n+};\n+\n+enum {\n+\tSMT_SIZE = 256\n+};\n+\n+struct smt_entry {\n+\tu16 state;\n+\tu16 idx;\n+\tu16 pfvf;\n+\tu16 hw_idx;\n+\tu8 src_mac[RTE_ETHER_ADDR_LEN];\n+\trte_atomic32_t refcnt;\n+\trte_spinlock_t lock;\n+};\n+\n+struct smt_data {\n+\tunsigned int smt_size;\n+\tunsigned int smt_start;\n+\trte_rwlock_t lock;\n+\tstruct smt_entry smtab[0];\n+};\n+\n+struct smt_data *t4_init_smt(u32 smt_start_idx, u32 smt_size);\n+void t4_cleanup_smt(struct adapter *adap);\n+\n+#endif  /* __CXGBE_SMT_H_ */\n+\n",
    "prefixes": [
        "6/9"
    ]
}