get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 98298,
    "url": "https://patches.dpdk.org/api/patches/98298/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210908083758.312055-17-jiawenwu@trustnetic.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20210908083758.312055-17-jiawenwu@trustnetic.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210908083758.312055-17-jiawenwu@trustnetic.com",
    "date": "2021-09-08T08:37:42",
    "name": "[16/32] net/ngbe: support VLAN filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "6354340b6251b4cc7ecbc4949ceffb26b9b5b240",
    "submitter": {
        "id": 1932,
        "url": "https://patches.dpdk.org/api/people/1932/?format=api",
        "name": "Jiawen Wu",
        "email": "jiawenwu@trustnetic.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210908083758.312055-17-jiawenwu@trustnetic.com/mbox/",
    "series": [
        {
            "id": 18760,
            "url": "https://patches.dpdk.org/api/series/18760/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=18760",
            "date": "2021-09-08T08:37:26",
            "name": "net/ngbe: add many features",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/18760/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/98298/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/98298/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 BA982A0C56;\n\tWed,  8 Sep 2021 10:38:17 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7EAEC411E1;\n\tWed,  8 Sep 2021 10:37:00 +0200 (CEST)",
            "from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166])\n by mails.dpdk.org (Postfix) with ESMTP id 3E822411DC\n for <dev@dpdk.org>; Wed,  8 Sep 2021 10:36:56 +0200 (CEST)",
            "from wxdbg.localdomain.com (unknown [183.129.236.74])\n by esmtp6.qq.com (ESMTP) with\n id ; Wed, 08 Sep 2021 16:36:49 +0800 (CST)"
        ],
        "X-QQ-mid": "bizesmtp47t1631090210thv83uoe",
        "X-QQ-SSF": "01400000002000E0G000B00A0000000",
        "X-QQ-FEAT": "r/cTxDoDoiGYKx6n32Xd3z36w0VmcjwGOG5SO2NuExKmVO1HIIzo32GDwyqsi\n 3pO0QdyRkfC6XfEAN09wgosBAqrNhWaDnlqg/fn2RfJVcIerHXoD8afmdRtK+1Y+552YbYU\n DWnSLOpp/9Y0ND2Fov2xVqEAxuV3RkaeBm2Jo7SVb/2O+togsUh7xoItrzYAshr4bKf2vVn\n TttJCPNrNttvqdLBUutfgBtvJzIw9eUwY8Yp6lnI8/Vs8ARHKXlod7ur/+Xxvk6NYSeU68I\n J+XDNsrIp/VgHkEdaU6YhjtEHGe7LoT5jc7I0DLk/ywd8TuOMLAMYbA9q6Qnts5J33G0Kgq\n 4xDUsYli2bhM0qUdAyPsSKHB4JL4tYf5fAdED/L",
        "X-QQ-GoodBg": "2",
        "From": "Jiawen Wu <jiawenwu@trustnetic.com>",
        "To": "dev@dpdk.org",
        "Cc": "Jiawen Wu <jiawenwu@trustnetic.com>",
        "Date": "Wed,  8 Sep 2021 16:37:42 +0800",
        "Message-Id": "<20210908083758.312055-17-jiawenwu@trustnetic.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20210908083758.312055-1-jiawenwu@trustnetic.com>",
        "References": "<20210908083758.312055-1-jiawenwu@trustnetic.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-QQ-SENDSIZE": "520",
        "Feedback-ID": "bizesmtp:trustnetic.com:qybgforeign:qybgforeign7",
        "X-QQ-Bgrelay": "1",
        "Subject": "[dpdk-dev] [PATCH 16/32] net/ngbe: support VLAN filter",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Support to filter of a VLAN tag identifier.\n\nSigned-off-by: Jiawen Wu <jiawenwu@trustnetic.com>\n---\n doc/guides/nics/features/ngbe.ini  |   1 +\n doc/guides/nics/ngbe.rst           |   2 +-\n drivers/net/ngbe/base/ngbe_dummy.h |   5 ++\n drivers/net/ngbe/base/ngbe_hw.c    |  29 +++++++\n drivers/net/ngbe/base/ngbe_hw.h    |   2 +\n drivers/net/ngbe/base/ngbe_type.h  |   3 +\n drivers/net/ngbe/ngbe_ethdev.c     | 128 +++++++++++++++++++++++++++++\n 7 files changed, 169 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini\nindex 4b22dc683a..265edba361 100644\n--- a/doc/guides/nics/features/ngbe.ini\n+++ b/doc/guides/nics/features/ngbe.ini\n@@ -17,6 +17,7 @@ Promiscuous mode     = Y\n Allmulticast mode    = Y\n Unicast MAC filter   = Y\n Multicast MAC filter = Y\n+VLAN filter          = Y\n CRC offload          = P\n VLAN offload         = P\n QinQ offload         = P\ndiff --git a/doc/guides/nics/ngbe.rst b/doc/guides/nics/ngbe.rst\nindex 4d01c27064..3683862fd1 100644\n--- a/doc/guides/nics/ngbe.rst\n+++ b/doc/guides/nics/ngbe.rst\n@@ -11,7 +11,7 @@ for Wangxun 1 Gigabit Ethernet NICs.\n Features\n --------\n \n-- MAC filtering\n+- MAC/VLAN filtering\n - Packet type information\n - Checksum offload\n - VLAN/QinQ stripping and inserting\ndiff --git a/drivers/net/ngbe/base/ngbe_dummy.h b/drivers/net/ngbe/base/ngbe_dummy.h\nindex fe2d53f312..7814fd6226 100644\n--- a/drivers/net/ngbe/base/ngbe_dummy.h\n+++ b/drivers/net/ngbe/base/ngbe_dummy.h\n@@ -132,6 +132,10 @@ static inline s32 ngbe_mac_update_mc_addr_list_dummy(struct ngbe_hw *TUP0,\n {\n \treturn NGBE_ERR_OPS_DUMMY;\n }\n+static inline s32 ngbe_mac_clear_vfta_dummy(struct ngbe_hw *TUP0)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n static inline s32 ngbe_mac_init_thermal_ssth_dummy(struct ngbe_hw *TUP0)\n {\n \treturn NGBE_ERR_OPS_DUMMY;\n@@ -209,6 +213,7 @@ static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw)\n \thw->mac.clear_vmdq = ngbe_mac_clear_vmdq_dummy;\n \thw->mac.init_rx_addrs = ngbe_mac_init_rx_addrs_dummy;\n \thw->mac.update_mc_addr_list = ngbe_mac_update_mc_addr_list_dummy;\n+\thw->mac.clear_vfta = ngbe_mac_clear_vfta_dummy;\n \thw->mac.init_thermal_sensor_thresh = ngbe_mac_init_thermal_ssth_dummy;\n \thw->mac.check_overtemp = ngbe_mac_check_overtemp_dummy;\n \thw->phy.identify = ngbe_phy_identify_dummy;\ndiff --git a/drivers/net/ngbe/base/ngbe_hw.c b/drivers/net/ngbe/base/ngbe_hw.c\nindex 897baf179d..ce0867575a 100644\n--- a/drivers/net/ngbe/base/ngbe_hw.c\n+++ b/drivers/net/ngbe/base/ngbe_hw.c\n@@ -19,6 +19,9 @@ s32 ngbe_start_hw(struct ngbe_hw *hw)\n {\n \tDEBUGFUNC(\"ngbe_start_hw\");\n \n+\t/* Clear the VLAN filter table */\n+\thw->mac.clear_vfta(hw);\n+\n \t/* Clear statistics registers */\n \thw->mac.clear_hw_cntrs(hw);\n \n@@ -910,6 +913,30 @@ s32 ngbe_init_uta_tables(struct ngbe_hw *hw)\n \treturn 0;\n }\n \n+/**\n+ *  ngbe_clear_vfta - Clear VLAN filter table\n+ *  @hw: pointer to hardware structure\n+ *\n+ *  Clears the VLAN filer table, and the VMDq index associated with the filter\n+ **/\n+s32 ngbe_clear_vfta(struct ngbe_hw *hw)\n+{\n+\tu32 offset;\n+\n+\tDEBUGFUNC(\"ngbe_clear_vfta\");\n+\n+\tfor (offset = 0; offset < hw->mac.vft_size; offset++)\n+\t\twr32(hw, NGBE_VLANTBL(offset), 0);\n+\n+\tfor (offset = 0; offset < NGBE_NUM_POOL; offset++) {\n+\t\twr32(hw, NGBE_PSRVLANIDX, offset);\n+\t\twr32(hw, NGBE_PSRVLAN, 0);\n+\t\twr32(hw, NGBE_PSRVLANPLM(0), 0);\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n  *  ngbe_check_mac_link_em - Determine link and speed status\n  *  @hw: pointer to hardware structure\n@@ -1238,6 +1265,7 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw)\n \tmac->update_mc_addr_list = ngbe_update_mc_addr_list;\n \tmac->set_vmdq = ngbe_set_vmdq;\n \tmac->clear_vmdq = ngbe_clear_vmdq;\n+\tmac->clear_vfta = ngbe_clear_vfta;\n \n \t/* Link */\n \tmac->get_link_capabilities = ngbe_get_link_capabilities_em;\n@@ -1254,6 +1282,7 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw)\n \trom->validate_checksum = ngbe_validate_eeprom_checksum_em;\n \n \tmac->mcft_size\t\t= NGBE_EM_MC_TBL_SIZE;\n+\tmac->vft_size\t\t= NGBE_EM_VFT_TBL_SIZE;\n \tmac->num_rar_entries\t= NGBE_EM_RAR_ENTRIES;\n \tmac->max_rx_queues\t= NGBE_EM_MAX_RX_QUEUES;\n \tmac->max_tx_queues\t= NGBE_EM_MAX_TX_QUEUES;\ndiff --git a/drivers/net/ngbe/base/ngbe_hw.h b/drivers/net/ngbe/base/ngbe_hw.h\nindex f06baa4395..a27bd3e650 100644\n--- a/drivers/net/ngbe/base/ngbe_hw.h\n+++ b/drivers/net/ngbe/base/ngbe_hw.h\n@@ -12,6 +12,7 @@\n #define NGBE_EM_MAX_RX_QUEUES 8\n #define NGBE_EM_RAR_ENTRIES   32\n #define NGBE_EM_MC_TBL_SIZE   32\n+#define NGBE_EM_VFT_TBL_SIZE  128\n \n s32 ngbe_init_hw(struct ngbe_hw *hw);\n s32 ngbe_start_hw(struct ngbe_hw *hw);\n@@ -48,6 +49,7 @@ void ngbe_release_swfw_sync(struct ngbe_hw *hw, u32 mask);\n s32 ngbe_set_vmdq(struct ngbe_hw *hw, u32 rar, u32 vmdq);\n s32 ngbe_clear_vmdq(struct ngbe_hw *hw, u32 rar, u32 vmdq);\n s32 ngbe_init_uta_tables(struct ngbe_hw *hw);\n+s32 ngbe_clear_vfta(struct ngbe_hw *hw);\n \n s32 ngbe_init_thermal_sensor_thresh(struct ngbe_hw *hw);\n s32 ngbe_mac_check_overtemp(struct ngbe_hw *hw);\ndiff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h\nindex 3e62dde707..5a88d38e84 100644\n--- a/drivers/net/ngbe/base/ngbe_type.h\n+++ b/drivers/net/ngbe/base/ngbe_type.h\n@@ -10,6 +10,7 @@\n \n #define NGBE_FRAME_SIZE_MAX       (9728) /* Maximum frame size, +FCS */\n #define NGBE_FRAME_SIZE_DFT       (1522) /* Default frame size, +FCS */\n+#define NGBE_NUM_POOL             (32)\n #define NGBE_MAX_QP               (8)\n #define NGBE_MAX_UTA              128\n \n@@ -252,6 +253,7 @@ struct ngbe_mac_info {\n \ts32 (*update_mc_addr_list)(struct ngbe_hw *hw, u8 *mc_addr_list,\n \t\t\t\t      u32 mc_addr_count,\n \t\t\t\t      ngbe_mc_addr_itr func, bool clear);\n+\ts32 (*clear_vfta)(struct ngbe_hw *hw);\n \n \t/* Manageability interface */\n \ts32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);\n@@ -264,6 +266,7 @@ struct ngbe_mac_info {\n \tu32 mta_shadow[NGBE_MAX_MTA];\n \ts32 mc_filter_type;\n \tu32 mcft_size;\n+\tu32 vft_size;\n \tu32 num_rar_entries;\n \tu32 max_tx_queues;\n \tu32 max_rx_queues;\ndiff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c\nindex d076ba8036..acc018c811 100644\n--- a/drivers/net/ngbe/ngbe_ethdev.c\n+++ b/drivers/net/ngbe/ngbe_ethdev.c\n@@ -492,6 +492,131 @@ static struct rte_pci_driver rte_ngbe_pmd = {\n \t.remove = eth_ngbe_pci_remove,\n };\n \n+static int\n+ngbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(dev);\n+\tstruct ngbe_vfta *shadow_vfta = NGBE_DEV_VFTA(dev);\n+\tuint32_t vfta;\n+\tuint32_t vid_idx;\n+\tuint32_t vid_bit;\n+\n+\tvid_idx = (uint32_t)((vlan_id >> 5) & 0x7F);\n+\tvid_bit = (uint32_t)(1 << (vlan_id & 0x1F));\n+\tvfta = rd32(hw, NGBE_VLANTBL(vid_idx));\n+\tif (on)\n+\t\tvfta |= vid_bit;\n+\telse\n+\t\tvfta &= ~vid_bit;\n+\twr32(hw, NGBE_VLANTBL(vid_idx), vfta);\n+\n+\t/* update local VFTA copy */\n+\tshadow_vfta->vfta[vid_idx] = vfta;\n+\n+\treturn 0;\n+}\n+\n+static void\n+ngbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(dev);\n+\tstruct ngbe_rx_queue *rxq;\n+\tbool restart;\n+\tuint32_t rxcfg, rxbal, rxbah;\n+\n+\tif (on)\n+\t\tngbe_vlan_hw_strip_enable(dev, queue);\n+\telse\n+\t\tngbe_vlan_hw_strip_disable(dev, queue);\n+\n+\trxq = dev->data->rx_queues[queue];\n+\trxbal = rd32(hw, NGBE_RXBAL(rxq->reg_idx));\n+\trxbah = rd32(hw, NGBE_RXBAH(rxq->reg_idx));\n+\trxcfg = rd32(hw, NGBE_RXCFG(rxq->reg_idx));\n+\tif (rxq->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) {\n+\t\trestart = (rxcfg & NGBE_RXCFG_ENA) &&\n+\t\t\t!(rxcfg & NGBE_RXCFG_VLAN);\n+\t\trxcfg |= NGBE_RXCFG_VLAN;\n+\t} else {\n+\t\trestart = (rxcfg & NGBE_RXCFG_ENA) &&\n+\t\t\t(rxcfg & NGBE_RXCFG_VLAN);\n+\t\trxcfg &= ~NGBE_RXCFG_VLAN;\n+\t}\n+\trxcfg &= ~NGBE_RXCFG_ENA;\n+\n+\tif (restart) {\n+\t\t/* set vlan strip for ring */\n+\t\tngbe_dev_rx_queue_stop(dev, queue);\n+\t\twr32(hw, NGBE_RXBAL(rxq->reg_idx), rxbal);\n+\t\twr32(hw, NGBE_RXBAH(rxq->reg_idx), rxbah);\n+\t\twr32(hw, NGBE_RXCFG(rxq->reg_idx), rxcfg);\n+\t\tngbe_dev_rx_queue_start(dev, queue);\n+\t}\n+}\n+\n+static int\n+ngbe_vlan_tpid_set(struct rte_eth_dev *dev,\n+\t\t    enum rte_vlan_type vlan_type,\n+\t\t    uint16_t tpid)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(dev);\n+\tint ret = 0;\n+\tuint32_t portctrl, vlan_ext, qinq;\n+\n+\tportctrl = rd32(hw, NGBE_PORTCTL);\n+\n+\tvlan_ext = (portctrl & NGBE_PORTCTL_VLANEXT);\n+\tqinq = vlan_ext && (portctrl & NGBE_PORTCTL_QINQ);\n+\tswitch (vlan_type) {\n+\tcase ETH_VLAN_TYPE_INNER:\n+\t\tif (vlan_ext) {\n+\t\t\twr32m(hw, NGBE_VLANCTL,\n+\t\t\t\tNGBE_VLANCTL_TPID_MASK,\n+\t\t\t\tNGBE_VLANCTL_TPID(tpid));\n+\t\t\twr32m(hw, NGBE_DMATXCTRL,\n+\t\t\t\tNGBE_DMATXCTRL_TPID_MASK,\n+\t\t\t\tNGBE_DMATXCTRL_TPID(tpid));\n+\t\t} else {\n+\t\t\tret = -ENOTSUP;\n+\t\t\tPMD_DRV_LOG(ERR,\n+\t\t\t\t\"Inner type is not supported by single VLAN\");\n+\t\t}\n+\n+\t\tif (qinq) {\n+\t\t\twr32m(hw, NGBE_TAGTPID(0),\n+\t\t\t\tNGBE_TAGTPID_LSB_MASK,\n+\t\t\t\tNGBE_TAGTPID_LSB(tpid));\n+\t\t}\n+\t\tbreak;\n+\tcase ETH_VLAN_TYPE_OUTER:\n+\t\tif (vlan_ext) {\n+\t\t\t/* Only the high 16-bits is valid */\n+\t\t\twr32m(hw, NGBE_EXTAG,\n+\t\t\t\tNGBE_EXTAG_VLAN_MASK,\n+\t\t\t\tNGBE_EXTAG_VLAN(tpid));\n+\t\t} else {\n+\t\t\twr32m(hw, NGBE_VLANCTL,\n+\t\t\t\tNGBE_VLANCTL_TPID_MASK,\n+\t\t\t\tNGBE_VLANCTL_TPID(tpid));\n+\t\t\twr32m(hw, NGBE_DMATXCTRL,\n+\t\t\t\tNGBE_DMATXCTRL_TPID_MASK,\n+\t\t\t\tNGBE_DMATXCTRL_TPID(tpid));\n+\t\t}\n+\n+\t\tif (qinq) {\n+\t\t\twr32m(hw, NGBE_TAGTPID(0),\n+\t\t\t\tNGBE_TAGTPID_MSB_MASK,\n+\t\t\t\tNGBE_TAGTPID_MSB(tpid));\n+\t\t}\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"Unsupported VLAN type %d\", vlan_type);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn ret;\n+}\n+\n void\n ngbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)\n {\n@@ -2411,7 +2536,10 @@ static const struct eth_dev_ops ngbe_eth_dev_ops = {\n \t.queue_stats_mapping_set    = ngbe_dev_queue_stats_mapping_set,\n \t.fw_version_get             = ngbe_fw_version_get,\n \t.mtu_set                    = ngbe_dev_mtu_set,\n+\t.vlan_filter_set            = ngbe_vlan_filter_set,\n+\t.vlan_tpid_set              = ngbe_vlan_tpid_set,\n \t.vlan_offload_set           = ngbe_vlan_offload_set,\n+\t.vlan_strip_queue_set       = ngbe_vlan_strip_queue_set,\n \t.rx_queue_start\t            = ngbe_dev_rx_queue_start,\n \t.rx_queue_stop              = ngbe_dev_rx_queue_stop,\n \t.tx_queue_start\t            = ngbe_dev_tx_queue_start,\n",
    "prefixes": [
        "16/32"
    ]
}