get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 21248,
    "url": "https://patches.dpdk.org/api/patches/21248/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1488533497-27682-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": "<1488533497-27682-4-git-send-email-beilei.xing@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1488533497-27682-4-git-send-email-beilei.xing@intel.com",
    "date": "2017-03-03T09:31:36",
    "name": "[dpdk-dev,3/4] net/i40e: support tunnel filter to VF",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "acc17e69bf99820354ddda6732f0bcb71c606f91",
    "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/1488533497-27682-4-git-send-email-beilei.xing@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/21248/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/21248/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 DF2CBD4E0;\n\tFri,  3 Mar 2017 10:33:11 +0100 (CET)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id E1BC12952\n\tfor <dev@dpdk.org>; Fri,  3 Mar 2017 10:32:53 +0100 (CET)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t03 Mar 2017 01:32:53 -0800",
            "from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31])\n\tby fmsmga006.fm.intel.com with ESMTP; 03 Mar 2017 01:32:51 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.35,236,1484035200\"; d=\"scan'208\";a=\"72335765\"",
        "From": "Beilei Xing <beilei.xing@intel.com>",
        "To": "jingjing.wu@intel.com",
        "Cc": "helin.zhang@intel.com, dev@dpdk.org,\n\tBernard Iremonger <bernard.iremonger@intel.com>,\n\tYong Liu <yong.liu@intel.com>",
        "Date": "Fri,  3 Mar 2017 17:31:36 +0800",
        "Message-Id": "<1488533497-27682-4-git-send-email-beilei.xing@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "In-Reply-To": "<1488533497-27682-1-git-send-email-beilei.xing@intel.com>",
        "References": "<1488533497-27682-1-git-send-email-beilei.xing@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 3/4] net/i40e: support tunnel filter to VF",
        "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": "This patch is to support tunnel filter to VF.\n\nSigned-off-by: Bernard Iremonger <bernard.iremonger@intel.com>\nSigned-off-by: Yong Liu <yong.liu@intel.com>\nSigned-off-by: Beilei Xing <beilei.xing@intel.com>\n---\n drivers/net/i40e/i40e_ethdev.c | 145 +++++++++++++++++++++++++++++++++++++++++\n drivers/net/i40e/i40e_ethdev.h |  32 +++++++++\n drivers/net/i40e/i40e_flow.c   |  50 +++++++++-----\n 3 files changed, 212 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c\nindex 8de68b5..43afd5b 100644\n--- a/drivers/net/i40e/i40e_ethdev.c\n+++ b/drivers/net/i40e/i40e_ethdev.c\n@@ -6922,6 +6922,151 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,\n \treturn ret;\n }\n \n+int\n+i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,\n+\t\t      struct i40e_tunnel_filter_conf *tunnel_filter,\n+\t\t      uint8_t add)\n+{\n+\tuint16_t ip_type;\n+\tuint32_t ipv4_addr;\n+\tuint8_t i, tun_type = 0;\n+\t/* internal variable to convert ipv6 byte order */\n+\tuint32_t convert_ipv6[4];\n+\tint val, ret = 0;\n+\tstruct i40e_pf_vf *vf = NULL;\n+\tstruct i40e_hw *hw = I40E_PF_TO_HW(pf);\n+\tstruct i40e_vsi *vsi;\n+\tstruct i40e_aqc_add_remove_cloud_filters_element_big_data  *cld_filter;\n+\tstruct i40e_aqc_add_remove_cloud_filters_element_big_data  *pfilter;\n+\tstruct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;\n+\tstruct i40e_tunnel_filter *tunnel, *node;\n+\tstruct i40e_tunnel_filter check_filter; /* Check if filter exists */\n+\tbool big_buffer = 0;\n+\n+\tcld_filter = rte_zmalloc(\"tunnel_filter\",\n+\tsizeof(struct i40e_aqc_add_remove_cloud_filters_element_big_data),\n+\t0);\n+\n+\tif (cld_filter == NULL) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to alloc memory.\");\n+\t\treturn -EINVAL;\n+\t}\n+\tpfilter = cld_filter;\n+\n+\tether_addr_copy(&tunnel_filter->outer_mac,\n+\t\t\t(struct ether_addr *)&pfilter->element.outer_mac);\n+\tether_addr_copy(&tunnel_filter->inner_mac,\n+\t\t\t(struct ether_addr *)&pfilter->element.inner_mac);\n+\n+\tpfilter->element.inner_vlan =\n+\t\trte_cpu_to_le_16(tunnel_filter->inner_vlan);\n+\tif (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {\n+\t\tip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;\n+\t\tipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);\n+\t\trte_memcpy(&pfilter->element.ipaddr.v4.data,\n+\t\t\t\t&rte_cpu_to_le_32(ipv4_addr),\n+\t\t\t\tsizeof(pfilter->element.ipaddr.v4.data));\n+\t} else {\n+\t\tip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;\n+\t\tfor (i = 0; i < 4; i++) {\n+\t\t\tconvert_ipv6[i] =\n+\t\t\trte_cpu_to_le_32(rte_be_to_cpu_32(\n+\t\t\t\t\t tunnel_filter->ip_addr.ipv6_addr[i]));\n+\t\t}\n+\t\trte_memcpy(&pfilter->element.ipaddr.v6.data,\n+\t\t\t   &convert_ipv6,\n+\t\t\t   sizeof(pfilter->element.ipaddr.v6.data));\n+\t}\n+\n+\t/* check tunneled type */\n+\tswitch (tunnel_filter->tunnel_type) {\n+\tcase RTE_TUNNEL_TYPE_VXLAN:\n+\t\ttun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;\n+\t\tbreak;\n+\tcase RTE_TUNNEL_TYPE_NVGRE:\n+\t\ttun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;\n+\t\tbreak;\n+\tcase RTE_TUNNEL_TYPE_IP_IN_GRE:\n+\t\ttun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;\n+\t\tbreak;\n+\tdefault:\n+\t\t/* Other tunnel types is not supported. */\n+\t\tPMD_DRV_LOG(ERR, \"tunnel type is not supported.\");\n+\t\trte_free(cld_filter);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tval = i40e_dev_get_filter_type(tunnel_filter->filter_type,\n+\t\t\t\t       &pfilter->element.flags);\n+\tif (val < 0) {\n+\t\trte_free(cld_filter);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tpfilter->element.flags |= rte_cpu_to_le_16(\n+\t\tI40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |\n+\t\tip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));\n+\tpfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);\n+\tpfilter->element.queue_number =\n+\t\trte_cpu_to_le_16(tunnel_filter->queue_id);\n+\n+\tif (!tunnel_filter->is_to_vf)\n+\t\tvsi = pf->main_vsi;\n+\telse {\n+\t\tif (tunnel_filter->vf_id >= pf->vf_num) {\n+\t\t\tPMD_DRV_LOG(ERR, \"Invalid argument.\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tvf = &pf->vfs[tunnel_filter->vf_id];\n+\t\tvsi = vf->vsi;\n+\t}\n+\n+\t/* Check if there is the filter in SW list */\n+\tmemset(&check_filter, 0, sizeof(check_filter));\n+\ti40e_tunnel_filter_convert(cld_filter, &check_filter);\n+\tnode = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);\n+\tif (add && node) {\n+\t\tPMD_DRV_LOG(ERR, \"Conflict with existing tunnel rules!\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!add && !node) {\n+\t\tPMD_DRV_LOG(ERR, \"There's no corresponding tunnel filter!\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (add) {\n+\t\tif (big_buffer)\n+\t\t\tret = i40e_aq_add_cloud_filters_big_buffer(hw,\n+\t\t\t\t\t\t   vsi->seid, cld_filter, 1);\n+\t\telse\n+\t\t\tret = i40e_aq_add_cloud_filters(hw,\n+\t\t\t\t\tvsi->seid, &cld_filter->element, 1);\n+\t\tif (ret < 0) {\n+\t\t\tPMD_DRV_LOG(ERR, \"Failed to add a tunnel filter.\");\n+\t\t\treturn ret;\n+\t\t}\n+\t\ttunnel = rte_zmalloc(\"tunnel_filter\", sizeof(*tunnel), 0);\n+\t\trte_memcpy(tunnel, &check_filter, sizeof(check_filter));\n+\t\tret = i40e_sw_tunnel_filter_insert(pf, tunnel);\n+\t} else {\n+\t\tif (big_buffer)\n+\t\t\tret = i40e_aq_remove_cloud_filters_big_buffer(\n+\t\t\t\thw, vsi->seid, cld_filter, 1);\n+\t\telse\n+\t\t\tret = i40e_aq_remove_cloud_filters(hw, vsi->seid,\n+\t\t\t\t\t   &cld_filter->element, 1);\n+\t\tif (ret < 0) {\n+\t\t\tPMD_DRV_LOG(ERR, \"Failed to delete a tunnel filter.\");\n+\t\t\treturn ret;\n+\t\t}\n+\t\tret = i40e_sw_tunnel_filter_del(pf, &node->input);\n+\t}\n+\n+\trte_free(cld_filter);\n+\treturn ret;\n+}\n+\n static int\n i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)\n {\ndiff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h\nindex adf26f4..3c8a420 100644\n--- a/drivers/net/i40e/i40e_ethdev.h\n+++ b/drivers/net/i40e/i40e_ethdev.h\n@@ -513,6 +513,7 @@ struct i40e_tunnel_filter_input {\n \tuint16_t flags;          /* Filter type flag */\n \tuint32_t tenant_id;      /* Tenant id to match */\n \tuint16_t general_fields[32];  /* Big buffer */\n+\tuint16_t vf_id;         /* VF id for tunnel filtering. */\n };\n \n struct i40e_tunnel_filter {\n@@ -529,6 +530,33 @@ struct i40e_tunnel_rule {\n \tstruct rte_hash *hash_table;\n };\n \n+/**\n+ * Tunneling Packet filter configuration.\n+ */\n+struct i40e_tunnel_filter_conf {\n+\tstruct ether_addr outer_mac;    /**< Outer MAC address to match. */\n+\tstruct ether_addr inner_mac;    /**< Inner MAC address to match. */\n+\tuint16_t inner_vlan;            /**< Inner VLAN to match. */\n+\tuint32_t outer_vlan;            /**< Outer VLAN to match */\n+\tenum rte_tunnel_iptype ip_type; /**< IP address type. */\n+\t/**\n+\t * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP\n+\t * is set in filter_type, or inner destination IP address to match\n+\t * if ETH_TUNNEL_FILTER_IIP is set in filter_type.\n+\t */\n+\tunion {\n+\t\tuint32_t ipv4_addr;     /**< IPv4 address in big endian. */\n+\t\tuint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */\n+\t} ip_addr;\n+\t/** Flags from ETH_TUNNEL_FILTER_XX - see above. */\n+\tuint16_t filter_type;\n+\tenum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */\n+\tuint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */\n+\tuint16_t queue_id;      /**< Queue assigned to if match. */\n+\tuint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */\n+\tuint16_t vf_id;         /**< VF id for tunnel filter insertion. */\n+};\n+\n #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64\n #define I40E_MAX_MIRROR_RULES           64\n /*\n@@ -717,6 +745,7 @@ union i40e_filter_t {\n \tstruct rte_eth_ethertype_filter ethertype_filter;\n \tstruct rte_eth_fdir_filter fdir_filter;\n \tstruct rte_eth_tunnel_filter_conf tunnel_filter;\n+\tstruct i40e_tunnel_filter_conf consistent_tunnel_filter;\n };\n \n typedef int (*parse_filter_t)(struct rte_eth_dev *dev,\n@@ -899,6 +928,9 @@ int i40e_add_del_fdir_filter(struct rte_eth_dev *dev,\n int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,\n \t\t\t       struct rte_eth_tunnel_filter_conf *tunnel_filter,\n \t\t\t       uint8_t add);\n+int i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,\n+\t\t\t\t  struct i40e_tunnel_filter_conf *tunnel_filter,\n+\t\t\t\t  uint8_t add);\n int i40e_fdir_flush(struct rte_eth_dev *dev);\n \n enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(struct i40e_hw *hw,\ndiff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c\nindex 62f5842..03c7026 100644\n--- a/drivers/net/i40e/i40e_flow.c\n+++ b/drivers/net/i40e/i40e_flow.c\n@@ -93,7 +93,7 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,\n static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,\n \t\t\t\t const struct rte_flow_action *actions,\n \t\t\t\t struct rte_flow_error *error,\n-\t\t\t\t struct rte_eth_tunnel_filter_conf *filter);\n+\t\t\t\t struct i40e_tunnel_filter_conf *filter);\n static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,\n \t\t\t\tstruct rte_flow_error *error);\n static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,\n@@ -1127,34 +1127,54 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,\n }\n \n /* Parse to get the action info of a tunnle filter\n- * Tunnel action only supports QUEUE.\n+ * Tunnel action only supports PF, VF and QUEUE.\n  */\n static int\n i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,\n \t\t\t      const struct rte_flow_action *actions,\n \t\t\t      struct rte_flow_error *error,\n-\t\t\t      struct rte_eth_tunnel_filter_conf *filter)\n+\t\t\t      struct i40e_tunnel_filter_conf *filter)\n {\n \tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n \tconst struct rte_flow_action *act;\n \tconst struct rte_flow_action_queue *act_q;\n+\tconst struct rte_flow_action_vf *act_vf;\n \tuint32_t index = 0;\n \n-\t/* Check if the first non-void action is QUEUE. */\n+\t/* Check if the first non-void action is PF or VF. */\n \tNEXT_ITEM_OF_ACTION(act, actions, index);\n-\tif (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {\n+\tif (act->type != RTE_FLOW_ACTION_TYPE_PF &&\n+\t    act->type != RTE_FLOW_ACTION_TYPE_VF) {\n \t\trte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,\n \t\t\t\t   act, \"Not supported action.\");\n \t\treturn -rte_errno;\n \t}\n \n-\tact_q = (const struct rte_flow_action_queue *)act->conf;\n-\tfilter->queue_id = act_q->index;\n-\tif (filter->queue_id >= pf->dev_data->nb_rx_queues) {\n-\t\trte_flow_error_set(error, EINVAL,\n+\tif (act->type == RTE_FLOW_ACTION_TYPE_VF) {\n+\t\tact_vf = (const struct rte_flow_action_vf *)act->conf;\n+\t\tfilter->vf_id = act_vf->id;\n+\t\tfilter->is_to_vf = 1;\n+\t\tif (filter->vf_id >= pf->vf_num) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t   act, \"Invalid VF ID for tunnel filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t}\n+\n+\t/* Check if the next non-void item is QUEUE */\n+\tindex++;\n+\tNEXT_ITEM_OF_ACTION(act, actions, index);\n+\tif (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {\n+\t\tact_q = (const struct rte_flow_action_queue *)act->conf;\n+\t\tfilter->queue_id = act_q->index;\n+\t\tif (!filter->is_to_vf)\n+\t\t\tif (filter->queue_id >= pf->dev_data->nb_rx_queues) {\n+\t\t\t\trte_flow_error_set(error, EINVAL,\n \t\t\t\t   RTE_FLOW_ERROR_TYPE_ACTION,\n \t\t\t\t   act, \"Invalid queue ID for tunnel filter\");\n-\t\treturn -rte_errno;\n+\t\t\t\treturn -rte_errno;\n+\t\t\t}\n \t}\n \n \t/* Check if the next non-void item is END */\n@@ -1204,7 +1224,7 @@ static int\n i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,\n \t\t\t      const struct rte_flow_item *pattern,\n \t\t\t      struct rte_flow_error *error,\n-\t\t\t      struct rte_eth_tunnel_filter_conf *filter)\n+\t\t\t      struct i40e_tunnel_filter_conf *filter)\n {\n \tconst struct rte_flow_item *item = pattern;\n \tconst struct rte_flow_item_eth *eth_spec;\n@@ -1473,8 +1493,8 @@ i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,\n \t\t\t     struct rte_flow_error *error,\n \t\t\t     union i40e_filter_t *filter)\n {\n-\tstruct rte_eth_tunnel_filter_conf *tunnel_filter =\n-\t\t&filter->tunnel_filter;\n+\tstruct i40e_tunnel_filter_conf *tunnel_filter =\n+\t\t&filter->consistent_tunnel_filter;\n \tint ret;\n \n \tret = i40e_flow_parse_vxlan_pattern(dev, pattern,\n@@ -1605,8 +1625,8 @@ i40e_flow_create(struct rte_eth_dev *dev,\n \t\t\t\t\ti40e_fdir_filter_list);\n \t\tbreak;\n \tcase RTE_ETH_FILTER_TUNNEL:\n-\t\tret = i40e_dev_tunnel_filter_set(pf,\n-\t\t\t\t\t &cons_filter.tunnel_filter, 1);\n+\t\tret = i40e_dev_consistent_tunnel_filter_set(pf,\n+\t\t\t    &cons_filter.consistent_tunnel_filter, 1);\n \t\tif (ret)\n \t\t\tgoto free_flow;\n \t\tflow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,\n",
    "prefixes": [
        "dpdk-dev",
        "3/4"
    ]
}