get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 18676,
    "url": "http://patches.dpdk.org/api/patches/18676/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1483027473-89042-4-git-send-email-beilei.xing@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": "<1483027473-89042-4-git-send-email-beilei.xing@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1483027473-89042-4-git-send-email-beilei.xing@intel.com",
    "date": "2016-12-29T16:04:19",
    "name": "[dpdk-dev,v3,03/17] net/i40e: store flow director filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ed3d3572f99a2126b87004d3d45212db7b81bc28",
    "submitter": {
        "id": 410,
        "url": "http://patches.dpdk.org/api/people/410/?format=api",
        "name": "Xing, Beilei",
        "email": "beilei.xing@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/1483027473-89042-4-git-send-email-beilei.xing@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/18676/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/18676/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 B9118591E;\n\tThu, 29 Dec 2016 17:05:39 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 34FA05599\n\tfor <dev@dpdk.org>; Thu, 29 Dec 2016 17:05:27 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP; 29 Dec 2016 08:05:26 -0800",
            "from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31])\n\tby fmsmga002.fm.intel.com with ESMTP; 29 Dec 2016 08:05:13 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.33,427,1477983600\"; d=\"scan'208\";\n\ta=\"1105684975\"",
        "From": "Beilei Xing <beilei.xing@intel.com>",
        "To": "jingjing.wu@intel.com,\n\thelin.zhang@intel.com",
        "Cc": "dev@dpdk.org",
        "Date": "Fri, 30 Dec 2016 00:04:19 +0800",
        "Message-Id": "<1483027473-89042-4-git-send-email-beilei.xing@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "In-Reply-To": "<1483027473-89042-1-git-send-email-beilei.xing@intel.com>",
        "References": "<1482819984-14120-1-git-send-email-beilei.xing@intel.com>\n\t<1483027473-89042-1-git-send-email-beilei.xing@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 03/17] 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": "Currently there's no flow director filter stored in SW. This\npatch stores flow director filters in SW with cuckoo hash,\nalso adds protection if a flow director filter has been added.\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 |  14 ++++++\n drivers/net/i40e/i40e_fdir.c   | 105 +++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 167 insertions(+)",
    "diff": "diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c\nindex 2bdb4d6..fb7d794 100644\n--- a/drivers/net/i40e/i40e_ethdev.c\n+++ b/drivers/net/i40e/i40e_ethdev.c\n@@ -953,6 +953,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)\n \tuint8_t aq_fail = 0;\n \tstruct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;\n \tstruct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;\n+\tstruct i40e_fdir_info *fdir_info = &pf->fdir;\n \n \tPMD_INIT_FUNC_TRACE();\n \n@@ -972,6 +973,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@@ -1253,8 +1262,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_rule->hash_map);\n err_tunnel_hash_map_alloc:\n \trte_hash_free(tunnel_rule->hash_table);\n err_tunnel_hash_table_create:\n@@ -1291,10 +1325,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_rule *ethertype_rule;\n \tstruct i40e_tunnel_rule *tunnel_rule;\n+\tstruct i40e_fdir_info *fdir_info;\n \n \tPMD_INIT_FUNC_TRACE();\n \n@@ -1306,6 +1342,7 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)\n \tpci_dev = dev->pci_dev;\n \tethertype_rule = &pf->ethertype;\n \ttunnel_rule = &pf->tunnel;\n+\tfdir_info = &pf->fdir;\n \n \tif (hw->adapter_stopped == 0)\n \t\ti40e_dev_close(dev);\n@@ -1333,6 +1370,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 83f3594..b79fbd6 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 /* Ethertype filter number HW supports */\n@@ -674,6 +686,8 @@ i40e_sw_ethertype_filter_lookup(struct i40e_ethertype_rule *ethertype_rule,\n \t\t\tconst struct i40e_ethertype_filter_input *input);\n int i40e_sw_ethertype_filter_del(struct i40e_pf *pf,\n \t\t\t\t struct i40e_ethertype_filter_input *input);\n+int i40e_sw_fdir_filter_del(struct i40e_pf *pf,\n+\t\t\t    struct rte_eth_fdir_input *input);\n struct i40e_tunnel_filter *\n i40e_sw_tunnel_filter_lookup(struct i40e_tunnel_rule *tunnel_rule,\n \t\t\t     const struct i40e_tunnel_filter_input *input);\ndiff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c\nindex 335bf15..4a29b37 100644\n--- a/drivers/net/i40e/i40e_fdir.c\n+++ b/drivers/net/i40e/i40e_fdir.c\n@@ -121,6 +121,14 @@ 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+\n static int\n i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq)\n {\n@@ -1017,6 +1025,74 @@ 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+/* Check if there exists the flow director 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+{\n+\tint ret;\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+/* Add a flow director filter into the SW list */\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;\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+\t\treturn ret;\n+\t}\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+/* Delete a flow director filter from the SW list */\n+int\n+i40e_sw_fdir_filter_del(struct i40e_pf *pf, struct rte_eth_fdir_input *input)\n+{\n+\tstruct i40e_fdir_info *fdir_info = &pf->fdir;\n+\tstruct i40e_fdir_filter *filter;\n+\tint ret;\n+\n+\tret = rte_hash_del_key(fdir_info->hash_table, 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+\t\treturn ret;\n+\t}\n+\tfilter = fdir_info->hash_map[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 +1108,9 @@ 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+\tstruct i40e_fdir_filter check_filter; /* Check if the filter exists */\n \tint ret = 0;\n \n \tif (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {\n@@ -1054,6 +1133,22 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,\n \t\treturn -EINVAL;\n \t}\n \n+\t/* Check if there is the filter in SW list */\n+\tmemset(&check_filter, 0, sizeof(check_filter));\n+\ti40e_fdir_filter_convert(filter, &check_filter);\n+\tnode = i40e_sw_fdir_filter_lookup(fdir_info, &check_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\treturn -EINVAL;\n+\t}\n+\n+\tif (!add && !node) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t    \"There's no corresponding flow firector 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 +1172,16 @@ 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\tfdir_filter = rte_zmalloc(\"fdir_filter\",\n+\t\t\t\t\t  sizeof(*fdir_filter), 0);\n+\t\trte_memcpy(fdir_filter, &check_filter, sizeof(check_filter));\n+\t\tret = i40e_sw_fdir_filter_insert(pf, fdir_filter);\n+\t} else {\n+\t\tret = i40e_sw_fdir_filter_del(pf, &node->fdir.input);\n+\t}\n+\n \treturn ret;\n }\n \n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "03/17"
    ]
}