Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/58717/?format=api
http://patches.dpdk.org/api/patches/58717/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190906120058.108073-7-yahui.cao@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": "<20190906120058.108073-7-yahui.cao@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20190906120058.108073-7-yahui.cao@intel.com", "date": "2019-09-06T12:00:52", "name": "[06/12] net/ice: add hash table for FDIR", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "4849fbb89ecf9b0e1ef8abddd3792fc421361af5", "submitter": { "id": 1176, "url": "http://patches.dpdk.org/api/people/1176/?format=api", "name": "Cao, Yahui", "email": "yahui.cao@intel.com" }, "delegate": { "id": 31221, "url": "http://patches.dpdk.org/api/users/31221/?format=api", "username": "yexl", "first_name": "xiaolong", "last_name": "ye", "email": "xiaolong.ye@intel.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190906120058.108073-7-yahui.cao@intel.com/mbox/", "series": [ { "id": 6273, "url": "http://patches.dpdk.org/api/series/6273/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=6273", "date": "2019-09-06T12:00:46", "name": "net/ice: add ice Flow Director driver", "version": 1, "mbox": "http://patches.dpdk.org/series/6273/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/58717/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/58717/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E39621F119;\n\tFri, 6 Sep 2019 06:16:32 +0200 (CEST)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 2B1D21F0FA\n\tfor <dev@dpdk.org>; Fri, 6 Sep 2019 06:16:24 +0200 (CEST)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Sep 2019 21:16:23 -0700", "from dpdk-yahui-skylake.sh.intel.com ([10.67.119.16])\n\tby FMSMGA003.fm.intel.com with ESMTP; 05 Sep 2019 21:16:22 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.64,472,1559545200\"; d=\"scan'208\";a=\"190709720\"", "From": "Yahui Cao <yahui.cao@intel.com>", "To": "Qiming Yang <qiming.yang@intel.com>,\n\tWenzhuo Lu <wenzhuo.lu@intel.com>", "Cc": "dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>,\n\tXiaolong Ye <xiaolong.ye@intel.com>,\n\tBeilei Xing <beilei.xing@intel.com>, Yahui Cao <yahui.cao@intel.com>", "Date": "Fri, 6 Sep 2019 20:00:52 +0800", "Message-Id": "<20190906120058.108073-7-yahui.cao@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20190906120058.108073-1-yahui.cao@intel.com>", "References": "<20190906120058.108073-1-yahui.cao@intel.com>", "Subject": "[dpdk-dev] [dpdk-dev 06/12] net/ice: add hash table for FDIR", "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Enable quick lookup for existing flow director rule entry.\n\nSigned-off-by: Yahui Cao <yahui.cao@intel.com>\n---\n drivers/net/ice/ice_ethdev.h | 17 +++\n drivers/net/ice/ice_fdir_filter.c | 186 ++++++++++++++++++++++++++++--\n 2 files changed, 196 insertions(+), 7 deletions(-)", "diff": "diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h\nindex bb821bc41..30ab518cd 100644\n--- a/drivers/net/ice/ice_ethdev.h\n+++ b/drivers/net/ice/ice_ethdev.h\n@@ -254,6 +254,20 @@ struct ice_fdir_filter_conf {\n \tuint64_t input_set;\n };\n \n+#define ICE_MAX_FDIR_FILTER_NUM\t\t(1024 * 16)\n+\n+struct ice_fdir_fltr_pattern {\n+\tenum ice_fltr_ptype flow_type;\n+\n+\tunion {\n+\t\tstruct ice_fdir_v4 v4;\n+\t\tstruct ice_fdir_v6 v6;\n+\t} ip, mask;\n+\n+\tstruct ice_fdir_extra ext_data;\n+\tstruct ice_fdir_extra ext_mask;\n+};\n+\n /**\n * A structure used to define fields of a FDIR related info.\n */\n@@ -264,6 +278,9 @@ struct ice_fdir_info {\n \tvoid *prg_pkt; /* memory for fdir program packet */\n \tuint64_t dma_addr; /* physic address of packet memory*/\n \tstruct ice_fdir_filter_conf conf;\n+\n+\tstruct ice_fdir_filter_conf **hash_map;\n+\tstruct rte_hash *hash_table;\n };\n \n struct ice_pf {\ndiff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c\nindex 294678075..df4d0329c 100644\n--- a/drivers/net/ice/ice_fdir_filter.c\n+++ b/drivers/net/ice/ice_fdir_filter.c\n@@ -1,5 +1,7 @@\n #include <stdio.h>\n #include <rte_flow.h>\n+#include <rte_hash.h>\n+#include <rte_hash_crc.h>\n #include \"base/ice_fdir.h\"\n #include \"base/ice_flow.h\"\n #include \"base/ice_type.h\"\n@@ -69,6 +71,60 @@ ice_memzone_reserve(const char *name, uint32_t len, int socket_id)\n \n #define ICE_FDIR_MZ_NAME\t\"FDIR_MEMZONE\"\n \n+static int\n+ice_init_fdir_filter_list(struct ice_pf *pf)\n+{\n+\tstruct rte_eth_dev *dev = pf->adapter->eth_dev;\n+\tstruct ice_fdir_info *fdir_info = &pf->fdir;\n+\tchar fdir_hash_name[RTE_HASH_NAMESIZE];\n+\tint ret;\n+\n+\tstruct rte_hash_parameters fdir_hash_params = {\n+\t\t.name = fdir_hash_name,\n+\t\t.entries = ICE_MAX_FDIR_FILTER_NUM,\n+\t\t.key_len = sizeof(struct ice_fdir_fltr_pattern),\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+\t/* Initialize hash */\n+\tsnprintf(fdir_hash_name, RTE_HASH_NAMESIZE,\n+\t\t \"fdir_%s\", dev->device->name);\n+\tfdir_info->hash_table = rte_hash_create(&fdir_hash_params);\n+\tif (!fdir_info->hash_table) {\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(\"ice_fdir_hash_map\",\n+\t\t\t\t\t sizeof(*fdir_info->hash_map) *\n+\t\t\t\t\t ICE_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\tret = -ENOMEM;\n+\t\tgoto err_fdir_hash_map_alloc;\n+\t}\n+\treturn 0;\n+\n+err_fdir_hash_map_alloc:\n+\trte_hash_free(fdir_info->hash_table);\n+\n+\treturn ret;\n+}\n+\n+static void\n+ice_release_fdir_filter_list(struct ice_pf *pf)\n+{\n+\tstruct ice_fdir_info *fdir_info = &pf->fdir;\n+\n+\tif (fdir_info->hash_map)\n+\t\trte_free(fdir_info->hash_map);\n+\tif (fdir_info->hash_table)\n+\t\trte_hash_free(fdir_info->hash_table);\n+}\n+\n /*\n * ice_fdir_setup - reserve and initialize the Flow Director resources\n * @pf: board private structure\n@@ -106,6 +162,12 @@ ice_fdir_setup(struct ice_pf *pf)\n \t}\n \tpf->fdir.fdir_vsi = vsi;\n \n+\terr = ice_init_fdir_filter_list(pf);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to init FDIR filter list.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/*Fdir tx queue setup*/\n \terr = ice_fdir_setup_tx_resources(pf);\n \tif (err) {\n@@ -177,6 +239,8 @@ ice_fdir_teardown(struct ice_pf *pf)\n \tif (!vsi)\n \t\treturn;\n \n+\tice_release_fdir_filter_list(pf);\n+\n \terr = ice_fdir_tx_queue_stop(eth_dev, pf->fdir.txq->queue_id);\n \tif (err)\n \t\tPMD_DRV_LOG(ERR, \"Failed to stop TX queue.\");\n@@ -490,6 +554,74 @@ ice_add_del_fdir_filter(struct ice_pf *pf,\n \treturn 0;\n }\n \n+static void\n+ice_fdir_extract_fltr_key(struct ice_fdir_fltr_pattern *key,\n+\t\t\t struct ice_fdir_filter_conf *filter)\n+{\n+\tstruct ice_fdir_fltr *input = &filter->input;\n+\tmemset(key, 0, sizeof(*key));\n+\n+\tkey->flow_type = input->flow_type;\n+\trte_memcpy(&key->ip, &input->ip, sizeof(key->ip));\n+\trte_memcpy(&key->mask, &input->mask, sizeof(key->mask));\n+\trte_memcpy(&key->ext_data, &input->ext_data, sizeof(key->ext_data));\n+\trte_memcpy(&key->ext_mask, &input->ext_mask, sizeof(key->ext_mask));\n+}\n+\n+/* Check if there exists the flow director filter */\n+static struct ice_fdir_filter_conf *\n+ice_fdir_entry_lookup(struct ice_fdir_info *fdir_info,\n+\t\t\tconst struct ice_fdir_fltr_pattern *key)\n+{\n+\tint ret;\n+\n+\tret = rte_hash_lookup(fdir_info->hash_table, key);\n+\tif (ret < 0)\n+\t\treturn NULL;\n+\n+\treturn fdir_info->hash_map[ret];\n+}\n+\n+/* Add a flow director entry into the SW list */\n+static int\n+ice_fdir_entry_insert(struct ice_pf *pf,\n+\t\t struct ice_fdir_filter_conf *entry,\n+\t\t struct ice_fdir_fltr_pattern *key)\n+{\n+\tstruct ice_fdir_info *fdir_info = &pf->fdir;\n+\tint ret;\n+\n+\tret = rte_hash_add_key(fdir_info->hash_table, key);\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"Failed to insert fdir entry to hash table %d!\",\n+\t\t\t ret);\n+\t\treturn ret;\n+\t}\n+\tfdir_info->hash_map[ret] = entry;\n+\n+\treturn 0;\n+}\n+\n+/* Delete a flow director entry from the SW list */\n+static int\n+ice_fdir_entry_del(struct ice_pf *pf, struct ice_fdir_fltr_pattern *key)\n+{\n+\tstruct ice_fdir_info *fdir_info = &pf->fdir;\n+\tint ret;\n+\n+\tret = rte_hash_del_key(fdir_info->hash_table, key);\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"Failed to delete fdir filter to hash table %d!\",\n+\t\t\t ret);\n+\t\treturn ret;\n+\t}\n+\tfdir_info->hash_map[ret] = NULL;\n+\n+\treturn 0;\n+}\n+\n static int\n ice_create_fdir_filter(struct ice_adapter *ad,\n \t\t struct rte_flow *flow,\n@@ -499,11 +631,22 @@ ice_create_fdir_filter(struct ice_adapter *ad,\n \tstruct ice_pf *pf = &ad->pf;\n \tstruct ice_hw *hw = ICE_PF_TO_HW(pf);\n \tstruct ice_fdir_filter_conf *filter = meta;\n-\tstruct ice_fdir_filter_conf *rule;\n+\tstruct ice_fdir_info *fdir_info = &pf->fdir;\n+\tstruct ice_fdir_filter_conf *entry, *node;\n+\tstruct ice_fdir_fltr_pattern key;\n \tint ret = 0;\n \n-\trule = rte_zmalloc(\"fdir_entry\", sizeof(*rule), 0);\n-\tif (!rule) {\n+\tice_fdir_extract_fltr_key(&key, filter);\n+\tnode = ice_fdir_entry_lookup(fdir_info, &key);\n+\tif (node) {\n+\t\trte_flow_error_set(error, EEXIST,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n+\t\t\t\t \"Rule already exists!\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tentry = rte_zmalloc(\"fdir_entry\", sizeof(*entry), 0);\n+\tif (!entry) {\n \t\trte_flow_error_set(error, ENOMEM,\n \t\t\t\t RTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n \t\t\t\t \"Failed to allocate memory\");\n@@ -527,13 +670,22 @@ ice_create_fdir_filter(struct ice_adapter *ad,\n \t\tgoto free_entry;\n \t}\n \n-\trte_memcpy(rule, filter, sizeof(*rule));\n-\tflow->rule = rule;\n+\trte_memcpy(entry, filter, sizeof(*entry));\n+\tret = ice_fdir_entry_insert(pf, entry, &key);\n+\tif (ret) {\n+\t\trte_flow_error_set(error, -ret,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n+\t\t\t\t \"Insert entry to table failed.\");\n+\t\tgoto free_entry;\n+\t}\n+\n+\tflow->rule = entry;\n \tice_fdir_update_cntrs(hw, filter->input.flow_type, true);\n+\n \treturn 0;\n \n free_entry:\n-\trte_free(rule);\n+\trte_free(entry);\n \treturn -rte_errno;\n }\n \n@@ -543,11 +695,22 @@ ice_destroy_fdir_filter(struct ice_adapter *ad,\n \t\t\tstruct rte_flow_error *error)\n {\n \tstruct ice_pf *pf = &ad->pf;\n-\tstruct ice_fdir_filter_conf *filter;\n+\tstruct ice_fdir_info *fdir_info = &pf->fdir;\n+\tstruct ice_fdir_filter_conf *filter, *entry;\n+\tstruct ice_fdir_fltr_pattern key;\n \tint ret;\n \n \tfilter = (struct ice_fdir_filter_conf *)flow->rule;\n \n+\tice_fdir_extract_fltr_key(&key, filter);\n+\tentry = ice_fdir_entry_lookup(fdir_info, &key);\n+\tif (!entry) {\n+\t\trte_flow_error_set(error, ENOENT,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n+\t\t\t\t \"Can't find entry.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n \tret = ice_add_del_fdir_filter(pf, filter, false);\n \tif (ret) {\n \t\trte_flow_error_set(error, -ret,\n@@ -556,7 +719,16 @@ ice_destroy_fdir_filter(struct ice_adapter *ad,\n \t\treturn -rte_errno;\n \t}\n \n+\tret = ice_fdir_entry_del(pf, &key);\n+\tif (ret) {\n+\t\trte_flow_error_set(error, -ret,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n+\t\t\t\t \"Remove entry from table failed.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n \trte_free(filter);\n+\tflow->rule = NULL;\n \n \treturn 0;\n }\n", "prefixes": [ "06/12" ] }{ "id": 58717, "url": "