Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/61454/?format=api
http://patches.dpdk.org/api/patches/61454/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20191018111602.26742-8-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": "<20191018111602.26742-8-yahui.cao@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20191018111602.26742-8-yahui.cao@intel.com", "date": "2019-10-18T11:16:00", "name": "[v7,7/9] net/ice: reject duplicate flow for FDIR", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "98010265f95f34aa969ce7aa10b26f0c2904b64e", "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/20191018111602.26742-8-yahui.cao@intel.com/mbox/", "series": [ { "id": 6926, "url": "http://patches.dpdk.org/api/series/6926/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=6926", "date": "2019-10-18T11:15:53", "name": "net/ice: add ice Flow Director driver", "version": 7, "mbox": "http://patches.dpdk.org/series/6926/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/61454/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/61454/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 035A01E88C;\n\tFri, 18 Oct 2019 05:34:04 +0200 (CEST)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 9FE521E874\n\tfor <dev@dpdk.org>; Fri, 18 Oct 2019 05:33:52 +0200 (CEST)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t17 Oct 2019 20:33:52 -0700", "from dpdk-yahui-skylake.sh.intel.com ([10.67.119.16])\n\tby FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2019 20:33:50 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.67,310,1566889200\"; d=\"scan'208\";a=\"202577942\"", "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, 18 Oct 2019 19:16:00 +0800", "Message-Id": "<20191018111602.26742-8-yahui.cao@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20191018111602.26742-1-yahui.cao@intel.com>", "References": "<20191017160454.14518-1-yahui.cao@intel.com>\n\t<20191018111602.26742-1-yahui.cao@intel.com>", "Subject": "[dpdk-dev] [PATCH v7 7/9] net/ice: reject duplicate flow 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 duplication lookup for existing flow director rule entry.\n\nSigned-off-by: Yahui Cao <yahui.cao@intel.com>\nAcked-by: Qi Zhang <qi.z.zhang@intel.com>\n---\n drivers/net/ice/Makefile | 2 +-\n drivers/net/ice/ice_ethdev.h | 17 +++\n drivers/net/ice/ice_fdir_filter.c | 185 ++++++++++++++++++++++++++++--\n 3 files changed, 196 insertions(+), 8 deletions(-)", "diff": "diff --git a/drivers/net/ice/Makefile b/drivers/net/ice/Makefile\nindex f7e185288..884fc4075 100644\n--- a/drivers/net/ice/Makefile\n+++ b/drivers/net/ice/Makefile\n@@ -13,7 +13,7 @@ CFLAGS += $(WERROR_FLAGS)\n CFLAGS += -DALLOW_EXPERIMENTAL_API\n \n LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs\n-LDLIBS += -lrte_bus_pci -lrte_mempool\n+LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash\n \n EXPORT_MAP := rte_pmd_ice_version.map\n \ndiff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h\nindex 5129b3b67..ab8b452e4 100644\n--- a/drivers/net/ice/ice_ethdev.h\n+++ b/drivers/net/ice/ice_ethdev.h\n@@ -256,6 +256,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 #define ICE_FDIR_COUNTER_DEFAULT_POOL_SIZE\t1\n #define ICE_FDIR_COUNTER_MAX_POOL_SIZE\t\t32\n #define ICE_FDIR_COUNTERS_PER_BLOCK\t\t256\n@@ -301,6 +315,9 @@ struct ice_fdir_info {\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 \tstruct ice_fdir_counter_pool_container counter;\n };\n \ndiff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c\nindex b327ead80..1b6101ec6 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@@ -272,6 +274,60 @@ ice_fdir_counter_free(__rte_unused struct ice_pf *pf,\n \t}\n }\n \n+static int\n+ice_fdir_init_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_fdir_release_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@@ -309,6 +365,12 @@ ice_fdir_setup(struct ice_pf *pf)\n \t}\n \tpf->fdir.fdir_vsi = vsi;\n \n+\terr = ice_fdir_init_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 \terr = ice_fdir_counter_init(pf);\n \tif (err) {\n \t\tPMD_DRV_LOG(ERR, \"Failed to init FDIR counter.\");\n@@ -470,6 +532,8 @@ ice_fdir_teardown(struct ice_pf *pf)\n \tif (err)\n \t\tPMD_DRV_LOG(ERR, \"Failed to release FDIR counter resource.\");\n \n+\tice_fdir_release_filter_list(pf);\n+\n \tice_tx_queue_release(pf->fdir.txq);\n \tpf->fdir.txq = NULL;\n \tice_rx_queue_release(pf->fdir.rxq);\n@@ -752,6 +816,74 @@ ice_fdir_add_del_filter(struct ice_pf *pf,\n \treturn ice_fdir_programming(pf, &desc);\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_fdir_create_filter(struct ice_adapter *ad,\n \t\t struct rte_flow *flow,\n@@ -760,11 +892,22 @@ ice_fdir_create_filter(struct ice_adapter *ad,\n {\n \tstruct ice_pf *pf = &ad->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;\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@@ -804,9 +947,18 @@ ice_fdir_create_filter(struct ice_adapter *ad,\n \t\tgoto free_counter;\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_cnt_update(pf, filter->input.flow_type, false, true);\n+\n \treturn 0;\n \n free_counter:\n@@ -816,7 +968,7 @@ ice_fdir_create_filter(struct ice_adapter *ad,\n \t}\n \n free_entry:\n-\trte_free(rule);\n+\trte_free(entry);\n \treturn -rte_errno;\n }\n \n@@ -826,7 +978,9 @@ ice_fdir_destroy_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@@ -836,6 +990,15 @@ ice_fdir_destroy_filter(struct ice_adapter *ad,\n \t\tfilter->counter = NULL;\n \t}\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_fdir_add_del_filter(pf, filter, false);\n \tif (ret) {\n \t\trte_flow_error_set(error, -ret,\n@@ -844,6 +1007,14 @@ ice_fdir_destroy_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 \tice_fdir_cnt_update(pf, filter->input.flow_type, false, false);\n \tflow->rule = NULL;\n \n", "prefixes": [ "v7", "7/9" ] }{ "id": 61454, "url": "