Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/17364/?format=api
https://patches.dpdk.org/api/patches/17364/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1480679625-4157-4-git-send-email-beilei.xing@intel.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": "<1480679625-4157-4-git-send-email-beilei.xing@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1480679625-4157-4-git-send-email-beilei.xing@intel.com", "date": "2016-12-02T11:53:24", "name": "[dpdk-dev,03/24] net/i40e: store flow director filter", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "d21942d842e47de104e1808d2dedc590f16cf742", "submitter": { "id": 410, "url": "https://patches.dpdk.org/api/people/410/?format=api", "name": "Xing, Beilei", "email": "beilei.xing@intel.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/1480679625-4157-4-git-send-email-beilei.xing@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/17364/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/17364/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 A4754F980;\n\tFri, 2 Dec 2016 05:13:54 +0100 (CET)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id B8D0858CB\n\tfor <dev@dpdk.org>; Fri, 2 Dec 2016 05:13:00 +0100 (CET)", "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby fmsmga103.fm.intel.com with ESMTP; 01 Dec 2016 20:13:00 -0800", "from dpdk9.sh.intel.com ([10.239.129.141])\n\tby orsmga003.jf.intel.com with ESMTP; 01 Dec 2016 20:12:59 -0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.33,284,1477983600\"; d=\"scan'208\";a=\"907853445\"", "From": "Beilei Xing <beilei.xing@intel.com>", "To": "jingjing.wu@intel.com,\n\thelin.zhang@intel.com", "Cc": "dev@dpdk.org,\n\twenzhuo.lu@intel.com", "Date": "Fri, 2 Dec 2016 06:53:24 -0500", "Message-Id": "<1480679625-4157-4-git-send-email-beilei.xing@intel.com>", "X-Mailer": "git-send-email 2.5.5", "In-Reply-To": "<1480679625-4157-1-git-send-email-beilei.xing@intel.com>", "References": "<1480679625-4157-1-git-send-email-beilei.xing@intel.com>", "Subject": "[dpdk-dev] [PATCH 03/24] net/i40e: 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": "Add support for storing flow director filter in SW.\n\nSigned-off-by: Beilei Xing <beilei.xing@intel.com>\n---\n drivers/net/i40e/i40e_ethdev.c | 48 +++++++++++++++++++++\n drivers/net/i40e/i40e_ethdev.h | 12 ++++++\n drivers/net/i40e/i40e_fdir.c | 95 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 155 insertions(+)", "diff": "diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c\nindex b20a851..c38536f 100644\n--- a/drivers/net/i40e/i40e_ethdev.c\n+++ b/drivers/net/i40e/i40e_ethdev.c\n@@ -962,6 +962,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)\n \tuint8_t aq_fail = 0;\n \tstruct i40e_ethertype_info *ethertype_info = &pf->ethertype;\n \tstruct i40e_tunnel_info *tunnel_info = &pf->tunnel;\n+\tstruct i40e_fdir_info *fdir_info = &pf->fdir;\n \n \tPMD_INIT_FUNC_TRACE();\n \n@@ -981,6 +982,14 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)\n \t\t.hash_func = rte_hash_crc,\n \t};\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 = I40E_MAX_FDIR_FILTER_NUM,\n+\t\t.key_len = sizeof(struct rte_eth_fdir_input),\n+\t\t.hash_func = rte_hash_crc,\n+\t};\n+\n \tdev->dev_ops = &i40e_eth_dev_ops;\n \tdev->rx_pkt_burst = i40e_recv_pkts;\n \tdev->tx_pkt_burst = i40e_xmit_pkts;\n@@ -1262,8 +1271,33 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)\n \t\tgoto err_tunnel_hash_map_alloc;\n \t}\n \n+\t/* Initialize flow director filter rule list and hash */\n+\tTAILQ_INIT(&fdir_info->fdir_list);\n+\tsnprintf(fdir_hash_name, RTE_HASH_NAMESIZE,\n+\t\t \"fdir_%s\", dev->data->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\tret = -EINVAL;\n+\t\tgoto err_fdir_hash_table_create;\n+\t}\n+\tfdir_info->hash_map = rte_zmalloc(\"i40e_fdir_hash_map\",\n+\t\t\t\t\t sizeof(struct i40e_fdir_filter *) *\n+\t\t\t\t\t I40E_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+\n \treturn 0;\n \n+err_fdir_hash_map_alloc:\n+\trte_hash_free(fdir_info->hash_table);\n+err_fdir_hash_table_create:\n+\trte_free(tunnel_info->hash_map);\n err_tunnel_hash_map_alloc:\n \trte_hash_free(tunnel_info->hash_table);\n err_tunnel_hash_table_create:\n@@ -1300,10 +1334,12 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)\n \tstruct i40e_filter_control_settings settings;\n \tstruct i40e_ethertype_filter *p_ethertype;\n \tstruct i40e_tunnel_filter *p_tunnel;\n+\tstruct i40e_fdir_filter *p_fdir;\n \tint ret;\n \tuint8_t aq_fail = 0;\n \tstruct i40e_ethertype_info *ethertype_info;\n \tstruct i40e_tunnel_info *tunnel_info;\n+\tstruct i40e_fdir_info *fdir_info;\n \n \tPMD_INIT_FUNC_TRACE();\n \n@@ -1315,6 +1351,7 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)\n \tpci_dev = dev->pci_dev;\n \tethertype_info = &pf->ethertype;\n \ttunnel_info = &pf->tunnel;\n+\tfdir_info = &pf->fdir;\n \n \tif (hw->adapter_stopped == 0)\n \t\ti40e_dev_close(dev);\n@@ -1342,6 +1379,17 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)\n \t\trte_free(p_tunnel);\n \t}\n \n+\t/* Remove all flow director rules and hash */\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+\twhile ((p_fdir = TAILQ_FIRST(&fdir_info->fdir_list))) {\n+\t\tTAILQ_REMOVE(&fdir_info->fdir_list, p_fdir, rules);\n+\t\trte_free(p_fdir);\n+\t}\n+\n \tdev->dev_ops = NULL;\n \tdev->rx_pkt_burst = NULL;\n \tdev->tx_pkt_burst = NULL;\ndiff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h\nindex 5f9cddd..b6eed6a 100644\n--- a/drivers/net/i40e/i40e_ethdev.h\n+++ b/drivers/net/i40e/i40e_ethdev.h\n@@ -377,6 +377,14 @@ struct i40e_fdir_flex_mask {\n };\n \n #define I40E_FILTER_PCTYPE_MAX 64\n+#define I40E_MAX_FDIR_FILTER_NUM (1024 * 8)\n+\n+struct i40e_fdir_filter {\n+\tTAILQ_ENTRY(i40e_fdir_filter) rules;\n+\tstruct rte_eth_fdir_filter fdir;\n+};\n+\n+TAILQ_HEAD(i40e_fdir_filter_list, i40e_fdir_filter);\n /*\n * A structure used to define fields of a FDIR related info.\n */\n@@ -395,6 +403,10 @@ struct i40e_fdir_info {\n \t */\n \tstruct i40e_fdir_flex_pit flex_set[I40E_MAX_FLXPLD_LAYER * I40E_MAX_FLXPLD_FIED];\n \tstruct i40e_fdir_flex_mask flex_mask[I40E_FILTER_PCTYPE_MAX];\n+\n+\tstruct i40e_fdir_filter_list fdir_list;\n+\tstruct i40e_fdir_filter **hash_map;\n+\tstruct rte_hash *hash_table;\n };\n \n #define I40E_MAX_ETHERTYPE_FILTER_NUM 768\ndiff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c\nindex 335bf15..1913fe1 100644\n--- a/drivers/net/i40e/i40e_fdir.c\n+++ b/drivers/net/i40e/i40e_fdir.c\n@@ -121,6 +121,16 @@ static int i40e_fdir_filter_programming(struct i40e_pf *pf,\n \t\t\tbool add);\n static int i40e_fdir_flush(struct rte_eth_dev *dev);\n \n+static int i40e_fdir_filter_convert(const struct rte_eth_fdir_filter *input,\n+\t\t\t struct i40e_fdir_filter *filter);\n+static struct i40e_fdir_filter *\n+i40e_sw_fdir_filter_lookup(struct i40e_fdir_info *fdir_info,\n+\t\t\tconst struct rte_eth_fdir_input *input);\n+static int i40e_sw_fdir_filter_insert(struct i40e_pf *pf,\n+\t\t\t\t struct i40e_fdir_filter *filter);\n+static int i40e_sw_fdir_filter_del(struct i40e_pf *pf,\n+\t\t\t\tstruct i40e_fdir_filter *filter);\n+\n static int\n i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq)\n {\n@@ -1017,6 +1027,66 @@ i40e_check_fdir_programming_status(struct i40e_rx_queue *rxq)\n \treturn ret;\n }\n \n+static int\n+i40e_fdir_filter_convert(const struct rte_eth_fdir_filter *input,\n+\t\t\t struct i40e_fdir_filter *filter)\n+{\n+\trte_memcpy(&filter->fdir, input, sizeof(struct rte_eth_fdir_filter));\n+\treturn 0;\n+}\n+\n+static struct i40e_fdir_filter *\n+i40e_sw_fdir_filter_lookup(struct i40e_fdir_info *fdir_info,\n+\t\t\tconst struct rte_eth_fdir_input *input)\n+{\n+\tint ret = 0;\n+\n+\tret = rte_hash_lookup(fdir_info->hash_table, (const void *)input);\n+\tif (ret < 0)\n+\t\treturn NULL;\n+\n+\treturn fdir_info->hash_map[ret];\n+}\n+\n+static int\n+i40e_sw_fdir_filter_insert(struct i40e_pf *pf, struct i40e_fdir_filter *filter)\n+{\n+\tstruct i40e_fdir_info *fdir_info = &pf->fdir;\n+\tint ret = 0;\n+\n+\tret = rte_hash_add_key(fdir_info->hash_table,\n+\t\t\t &filter->fdir.input);\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+\tfdir_info->hash_map[ret] = filter;\n+\n+\tTAILQ_INSERT_TAIL(&fdir_info->fdir_list, filter, rules);\n+\n+\treturn 0;\n+}\n+\n+static int\n+i40e_sw_fdir_filter_del(struct i40e_pf *pf, struct i40e_fdir_filter *filter)\n+{\n+\tstruct i40e_fdir_info *fdir_info = &pf->fdir;\n+\tint ret = 0;\n+\n+\tret = rte_hash_del_key(fdir_info->hash_table,\n+\t\t\t &filter->fdir.input);\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+\tfdir_info->hash_map[ret] = NULL;\n+\n+\tTAILQ_REMOVE(&fdir_info->fdir_list, filter, rules);\n+\trte_free(filter);\n+\n+\treturn 0;\n+}\n+\n /*\n * i40e_add_del_fdir_filter - add or remove a flow director filter.\n * @pf: board private structure\n@@ -1032,6 +1102,8 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,\n \tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n \tunsigned char *pkt = (unsigned char *)pf->fdir.prg_pkt;\n \tenum i40e_filter_pctype pctype;\n+\tstruct i40e_fdir_info *fdir_info = &pf->fdir;\n+\tstruct i40e_fdir_filter *fdir_filter, *node;\n \tint ret = 0;\n \n \tif (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {\n@@ -1054,6 +1126,21 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,\n \t\treturn -EINVAL;\n \t}\n \n+\tfdir_filter = rte_zmalloc(\"fdir_filter\", sizeof(*fdir_filter), 0);\n+\ti40e_fdir_filter_convert(filter, fdir_filter);\n+\tnode = i40e_sw_fdir_filter_lookup(fdir_info, &fdir_filter->fdir.input);\n+\tif (add && node) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"Conflict with existing flow director rules!\");\n+\t\trte_free(fdir_filter);\n+\t\treturn -EINVAL;\n+\t} else if (!add && !node) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t \"There's no corresponding flow firector filter!\");\n+\t\trte_free(fdir_filter);\n+\t\treturn -EINVAL;\n+\t}\n+\n \tmemset(pkt, 0, I40E_FDIR_PKT_LEN);\n \n \tret = i40e_fdir_construct_pkt(pf, &filter->input, pkt);\n@@ -1077,6 +1164,14 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,\n \t\t\t pctype);\n \t\treturn ret;\n \t}\n+\n+\tif (add)\n+\t\tret = i40e_sw_fdir_filter_insert(pf, fdir_filter);\n+\telse {\n+\t\tret = i40e_sw_fdir_filter_del(pf, node);\n+\t\trte_free(fdir_filter);\n+\t}\n+\n \treturn ret;\n }\n \n", "prefixes": [ "dpdk-dev", "03/24" ] }{ "id": 17364, "url": "