get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 17461,
    "url": "http://patches.dpdk.org/api/patches/17461/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1480675394-59179-3-git-send-email-wei.zhao1@intel.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": "<1480675394-59179-3-git-send-email-wei.zhao1@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1480675394-59179-3-git-send-email-wei.zhao1@intel.com",
    "date": "2016-12-02T10:42:58",
    "name": "[dpdk-dev,02/18] net/ixgbe: store flow director filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "65830af690c6ac93bde316b63ef988a243839598",
    "submitter": {
        "id": 495,
        "url": "http://patches.dpdk.org/api/people/495/?format=api",
        "name": "Zhao1, Wei",
        "email": "wei.zhao1@intel.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/1480675394-59179-3-git-send-email-wei.zhao1@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/17461/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/17461/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 4236AF980;\n\tFri,  2 Dec 2016 11:47:08 +0100 (CET)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id A456F58DB\n\tfor <dev@dpdk.org>; Fri,  2 Dec 2016 11:46:48 +0100 (CET)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby orsmga103.jf.intel.com with ESMTP; 02 Dec 2016 02:46:47 -0800",
            "from dpdk1.bj.intel.com ([172.16.182.84])\n\tby orsmga001.jf.intel.com with ESMTP; 02 Dec 2016 02:46:46 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.33,729,1477983600\"; d=\"scan'208\";\n\ta=\"1067043765\"",
        "From": "Wei Zhao <wei.zhao1@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "wenzhuo.lu@intel.com,\n\twei zhao1 <wei.zhao1@intel.com>",
        "Date": "Fri,  2 Dec 2016 18:42:58 +0800",
        "Message-Id": "<1480675394-59179-3-git-send-email-wei.zhao1@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "In-Reply-To": "<1480675394-59179-1-git-send-email-wei.zhao1@intel.com>",
        "References": "<1480675394-59179-1-git-send-email-wei.zhao1@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 02/18] net/ixgbe: store flow director filter",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: wei zhao1 <wei.zhao1@intel.com>\n\nAdd support for storing flow director filter in SW.\n\nSigned-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>\nSigned-off-by: wei zhao1 <wei.zhao1@intel.com>\n---\n drivers/net/ixgbe/ixgbe_ethdev.c |  48 ++++++++++++++++++\n drivers/net/ixgbe/ixgbe_ethdev.h |  19 ++++++-\n drivers/net/ixgbe/ixgbe_fdir.c   | 105 ++++++++++++++++++++++++++++++++++++++-\n 3 files changed, 169 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c\nindex 7f10cca..f8e5fe1 100644\n--- a/drivers/net/ixgbe/ixgbe_ethdev.c\n+++ b/drivers/net/ixgbe/ixgbe_ethdev.c\n@@ -60,6 +60,7 @@\n #include <rte_malloc.h>\n #include <rte_random.h>\n #include <rte_dev.h>\n+#include <rte_hash_crc.h>\n \n #include \"ixgbe_logs.h\"\n #include \"base/ixgbe_api.h\"\n@@ -1094,10 +1095,22 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)\n \t\tIXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);\n \tstruct ixgbe_filter_info *filter_info =\n \t\tIXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);\n+\tstruct ixgbe_hw_fdir_info *fdir_info =\n+\t\tIXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);\n \tuint32_t ctrl_ext;\n \tuint16_t csum;\n \tint diag, i;\n \n+\tchar fdir_hash_name[RTE_HASH_NAMESIZE];\n+\tstruct rte_hash_parameters fdir_hash_params = {\n+\t\t.name = fdir_hash_name,\n+\t\t.entries = IXGBE_MAX_FDIR_FILTER_NUM,\n+\t\t.key_len = sizeof(union ixgbe_atr_input),\n+\t\t.hash_func = rte_hash_crc,\n+\t\t.hash_func_init_val = 0,\n+\t\t.socket_id = rte_socket_id(),\n+\t};\n+\n \tPMD_INIT_FUNC_TRACE();\n \n \teth_dev->dev_ops = &ixgbe_eth_dev_ops;\n@@ -1289,6 +1302,25 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)\n \n \t/* initialize SYN filter */\n \tfilter_info->syn_info = 0;\n+\t/* initialize flow director filter list & hash */\n+\tTAILQ_INIT(&fdir_info->fdir_list);\n+\tsnprintf(fdir_hash_name, RTE_HASH_NAMESIZE,\n+\t\t \"fdir_%s\", eth_dev->data->name);\n+\tfdir_info->hash_handle = rte_hash_create(&fdir_hash_params);\n+\tif (!fdir_info->hash_handle) {\n+\t\tPMD_INIT_LOG(ERR, \"Failed to create fdir hash table!\");\n+\t\treturn -EINVAL;\n+\t}\n+\tfdir_info->hash_map = rte_zmalloc(\"ixgbe\",\n+\t\t\t\t\t  sizeof(struct ixgbe_fdir_filter *) *\n+\t\t\t\t\t  IXGBE_MAX_FDIR_FILTER_NUM,\n+\t\t\t\t\t  0);\n+\tif (!fdir_info->hash_map) {\n+\t\tPMD_INIT_LOG(ERR,\n+\t\t\t     \"Failed to allocate memory for fdir hash map!\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n \treturn 0;\n }\n \n@@ -1297,6 +1329,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)\n {\n \tstruct rte_pci_device *pci_dev;\n \tstruct ixgbe_hw *hw;\n+\tstruct ixgbe_hw_fdir_info *fdir_info =\n+\t\tIXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);\n+\tstruct ixgbe_fdir_filter *fdir_filter;\n \n \tPMD_INIT_FUNC_TRACE();\n \n@@ -1330,6 +1365,19 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)\n \trte_free(eth_dev->data->hash_mac_addrs);\n \teth_dev->data->hash_mac_addrs = NULL;\n \n+\t/* remove all the fdir filters & hash */\n+\tif (fdir_info->hash_map)\n+\t\trte_free(fdir_info->hash_map);\n+\tif (fdir_info->hash_handle)\n+\t\trte_hash_free(fdir_info->hash_handle);\n+\n+\twhile ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {\n+\t\tTAILQ_REMOVE(&fdir_info->fdir_list,\n+\t\t\t     fdir_filter,\n+\t\t\t     entries);\n+\t\trte_free(fdir_filter);\n+\t}\n+\n \treturn 0;\n }\n \ndiff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h\nindex 827026c..8310220 100644\n--- a/drivers/net/ixgbe/ixgbe_ethdev.h\n+++ b/drivers/net/ixgbe/ixgbe_ethdev.h\n@@ -38,6 +38,7 @@\n #include \"base/ixgbe_dcb_82598.h\"\n #include \"ixgbe_bypass.h\"\n #include <rte_time.h>\n+#include <rte_hash.h>\n \n /* need update link, bit flag */\n #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)\n@@ -130,10 +131,11 @@\n #define IXGBE_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET\n #define IXGBE_RX_VEC_START              RTE_INTR_VEC_RXTX_OFFSET\n \n+#define IXGBE_MAX_FDIR_FILTER_NUM       (1024 * 32)\n+\n /*\n  * Information about the fdir mode.\n  */\n-\n struct ixgbe_hw_fdir_mask {\n \tuint16_t vlan_tci_mask;\n \tuint32_t src_ipv4_mask;\n@@ -148,6 +150,17 @@ struct ixgbe_hw_fdir_mask {\n \tuint8_t  tunnel_type_mask;\n };\n \n+struct ixgbe_fdir_filter {\n+\tTAILQ_ENTRY(ixgbe_fdir_filter) entries;\n+\tunion ixgbe_atr_input ixgbe_fdir; /* key of fdir filter*/\n+\tuint32_t fdirflags; /* drop or forward */\n+\tuint32_t fdirhash; /* hash value for fdir */\n+\tuint8_t queue; /* assigned rx queue */\n+};\n+\n+/* list of fdir filters */\n+TAILQ_HEAD(ixgbe_fdir_filter_list, ixgbe_fdir_filter);\n+\n struct ixgbe_hw_fdir_info {\n \tstruct ixgbe_hw_fdir_mask mask;\n \tuint8_t     flex_bytes_offset;\n@@ -159,6 +172,10 @@ struct ixgbe_hw_fdir_info {\n \tuint64_t    remove;\n \tuint64_t    f_add;\n \tuint64_t    f_remove;\n+\tstruct ixgbe_fdir_filter_list fdir_list; /* filter list*/\n+\t/* store the pointers of the filters, index is the hash value. */\n+\tstruct ixgbe_fdir_filter **hash_map;\n+\tstruct rte_hash *hash_handle; /* cuckoo hash handler */\n };\n \n /* structure for interrupt relative data */\ndiff --git a/drivers/net/ixgbe/ixgbe_fdir.c b/drivers/net/ixgbe/ixgbe_fdir.c\nindex 4b81ee3..bfcd294 100644\n--- a/drivers/net/ixgbe/ixgbe_fdir.c\n+++ b/drivers/net/ixgbe/ixgbe_fdir.c\n@@ -43,6 +43,7 @@\n #include <rte_pci.h>\n #include <rte_ether.h>\n #include <rte_ethdev.h>\n+#include <rte_malloc.h>\n \n #include \"ixgbe_logs.h\"\n #include \"base/ixgbe_api.h\"\n@@ -1075,6 +1076,65 @@ fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash)\n \n }\n \n+static inline struct ixgbe_fdir_filter *\n+ixgbe_fdir_filter_lookup(struct ixgbe_hw_fdir_info *fdir_info,\n+\t\t\t union ixgbe_atr_input *key)\n+{\n+\tint ret = 0;\n+\n+\tret = rte_hash_lookup(fdir_info->hash_handle, (const void *)key);\n+\tif (ret < 0)\n+\t\treturn NULL;\n+\n+\treturn fdir_info->hash_map[ret];\n+}\n+\n+static inline int\n+ixgbe_insert_fdir_filter(struct ixgbe_hw_fdir_info *fdir_info,\n+\t\t\t struct ixgbe_fdir_filter *fdir_filter)\n+{\n+\tint ret = 0;\n+\n+\tret = rte_hash_add_key(fdir_info->hash_handle,\n+\t\t\t       &fdir_filter->ixgbe_fdir);\n+\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t    \"Failed to insert fdir filter to hash table %d!\",\n+\t\t\t    ret);\n+\t\treturn ret;\n+\t}\n+\n+\tfdir_info->hash_map[ret] = fdir_filter;\n+\n+\tTAILQ_INSERT_TAIL(&fdir_info->fdir_list, fdir_filter, entries);\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+ixgbe_remove_fdir_filter(struct ixgbe_hw_fdir_info *fdir_info,\n+\t\t\t union ixgbe_atr_input *key)\n+{\n+\tint ret = 0;\n+\tstruct ixgbe_fdir_filter *fdir_filter;\n+\n+\tret = rte_hash_del_key(fdir_info->hash_handle, key);\n+\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"No such fdir filter to delete %d!\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\tfdir_filter = fdir_info->hash_map[ret];\n+\tfdir_info->hash_map[ret] = NULL;\n+\n+\tTAILQ_REMOVE(&fdir_info->fdir_list, fdir_filter, entries);\n+\trte_free(fdir_filter);\n+\n+\treturn 0;\n+}\n+\n /*\n  * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter.\n  * @dev: pointer to the structure rte_eth_dev\n@@ -1098,6 +1158,8 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,\n \tstruct ixgbe_hw_fdir_info *info =\n \t\tIXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);\n \tenum rte_fdir_mode fdir_mode = dev->data->dev_conf.fdir_conf.mode;\n+\tstruct ixgbe_fdir_filter *node;\n+\tbool add_node = FALSE;\n \n \tif (fdir_mode == RTE_FDIR_MODE_NONE)\n \t\treturn -ENOTSUP;\n@@ -1148,6 +1210,10 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,\n \t\t\t\t\t\t      dev->data->dev_conf.fdir_conf.pballoc);\n \n \tif (del) {\n+\t\terr = ixgbe_remove_fdir_filter(info, &input);\n+\t\tif (err < 0)\n+\t\t\treturn err;\n+\n \t\terr = fdir_erase_filter_82599(hw, fdirhash);\n \t\tif (err < 0)\n \t\t\tPMD_DRV_LOG(ERR, \"Fail to delete FDIR filter!\");\n@@ -1172,6 +1238,37 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,\n \telse\n \t\treturn -EINVAL;\n \n+\tnode = ixgbe_fdir_filter_lookup(info, &input);\n+\tif (node) {\n+\t\tif (update) {\n+\t\t\tnode->fdirflags = fdircmd_flags;\n+\t\t\tnode->fdirhash = fdirhash;\n+\t\t\tnode->queue = queue;\n+\t\t} else {\n+\t\t\tPMD_DRV_LOG(ERR, \"Conflict with existing fdir filter!\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else {\n+\t\tadd_node = TRUE;\n+\t\tnode = rte_zmalloc(\"ixgbe_fdir\",\n+\t\t\t\t   sizeof(struct ixgbe_fdir_filter),\n+\t\t\t\t   0);\n+\t\tif (!node)\n+\t\t\treturn -ENOMEM;\n+\t\t(void)rte_memcpy(&node->ixgbe_fdir,\n+\t\t\t\t &input,\n+\t\t\t\t sizeof(union ixgbe_atr_input));\n+\t\tnode->fdirflags = fdircmd_flags;\n+\t\tnode->fdirhash = fdirhash;\n+\t\tnode->queue = queue;\n+\n+\t\terr = ixgbe_insert_fdir_filter(info, node);\n+\t\tif (err < 0) {\n+\t\t\trte_free(node);\n+\t\t\treturn err;\n+\t\t}\n+\t}\n+\n \tif (is_perfect) {\n \t\terr = fdir_write_perfect_filter_82599(hw, &input, queue,\n \t\t\t\t\t\t      fdircmd_flags, fdirhash,\n@@ -1180,10 +1277,14 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,\n \t\terr = fdir_add_signature_filter_82599(hw, &input, queue,\n \t\t\t\t\t\t      fdircmd_flags, fdirhash);\n \t}\n-\tif (err < 0)\n+\tif (err < 0) {\n \t\tPMD_DRV_LOG(ERR, \"Fail to add FDIR filter!\");\n-\telse\n+\n+\t\tif (add_node)\n+\t\t\t(void)ixgbe_remove_fdir_filter(info, &input);\n+\t} else {\n \t\tPMD_DRV_LOG(DEBUG, \"Success to add FDIR filter\");\n+\t}\n \n \treturn err;\n }\n",
    "prefixes": [
        "dpdk-dev",
        "02/18"
    ]
}