get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 80694,
    "url": "http://patches.dpdk.org/api/patches/80694/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20201014084131.72035-9-simonx.lu@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": "<20201014084131.72035-9-simonx.lu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20201014084131.72035-9-simonx.lu@intel.com",
    "date": "2020-10-14T08:41:31",
    "name": "[v1,8/8] net/i40e: use generic flow command to re-realize mirror rule",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "57a6c7d3b1233091e7d8f0b5fa0854372477e396",
    "submitter": {
        "id": 2016,
        "url": "http://patches.dpdk.org/api/people/2016/?format=api",
        "name": "SimonX Lu",
        "email": "simonx.lu@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/20201014084131.72035-9-simonx.lu@intel.com/mbox/",
    "series": [
        {
            "id": 12943,
            "url": "http://patches.dpdk.org/api/series/12943/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12943",
            "date": "2020-10-14T08:41:23",
            "name": "use generic flow command to re-realize mirror rule",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12943/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/80694/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/80694/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 7B643A04B7;\n\tWed, 14 Oct 2020 10:45:56 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D56EE1DD42;\n\tWed, 14 Oct 2020 10:43:34 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by dpdk.org (Postfix) with ESMTP id A78D51DD36\n for <dev@dpdk.org>; Wed, 14 Oct 2020 10:43:32 +0200 (CEST)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 14 Oct 2020 01:43:32 -0700",
            "from intel-npg-odc-srv01.cd.intel.com ([10.240.178.136])\n by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 14 Oct 2020 01:43:29 -0700"
        ],
        "IronPort-SDR": [
            "\n G5OL/qqbNXIY8AOG7kY8b8qzyfnVuiDF/okFPWjNDi5LUM1pzBNL+Gae5yOoLaRncHz3CAyYMP\n AUia6YLmUyyg==",
            "\n B6VxOPdiElcQRhWpA7mecaBIb62LAiucV2qEuTVBSj+U9BQDNlYSUrv0vSdzQ4cweU5BtD6OMq\n Hem5XQ4WOJbQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9773\"; a=\"163432247\"",
            "E=Sophos;i=\"5.77,374,1596524400\"; d=\"scan'208\";a=\"163432247\"",
            "E=Sophos;i=\"5.77,374,1596524400\"; d=\"scan'208\";a=\"299864596\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "From": "SimonX Lu <simonx.lu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "jia.guo@intel.com, haiyue.wang@intel.com, qiming.yang@intel.com,\n beilei.xing@intel.com, orika@nvidia.com, Simon Lu <simonx.lu@intel.com>",
        "Date": "Wed, 14 Oct 2020 08:41:31 +0000",
        "Message-Id": "<20201014084131.72035-9-simonx.lu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20201014084131.72035-1-simonx.lu@intel.com>",
        "References": "<20201014084131.72035-1-simonx.lu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 8/8] net/i40e: use generic flow command to\n\tre-realize mirror rule",
        "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Simon Lu <simonx.lu@intel.com>\n\nfollow mirror rule to add new action called mirror in flow management,\nso we can use \"flow create * pattern * action mirror *\"  to replace\nold \"set port * mirror-rule *\" command now\n\nthe example of mirror rule command mapping to flow management command:\n(in below command, port 0 is PF and port 1-3 is VF):\n\n1) ingress: pf => pf\n   set port 0 mirror-rule 0 uplink-mirror dst-pool 4 on\n   or\n   flow create 0 ingress pattern pf / end actions mirror pf / end\n2) egress: pf => pf\n   set port 0 mirror-rule 0 downlink-mirror dst-pool 4 on\n   or\n   flow create 0 egress pattern pf / end actions mirror pf / end\n3) ingress: pf => vf 3\n   set port 0 mirror-rule 0 uplink-mirror dst-pool 3 on\n   or\n   flow create 0 ingress pattern pf / end actions mirror vf id 3 / end\n4) egress: pf => vf 3\n   set port 0 mirror-rule 0 downlink-mirror dst-pool 3 on\n   or\n   flow create 0 egress pattern pf / end actions mirror vf id 3 / end\n5) ingress: vf 0,1 => pf\n   set port 0 mirror-rule 0 pool-mirror-up 0x3 dst-pool 4 on\n   or\n   flow create 0 ingress pattern vf id is 0 / end \\\n                         actions mirror pf / end\n\n   flow create 0 ingress pattern vf id is 1 / end \\\n                         actions mirror pf / end\n   or\n   flow create 0 ingress pattern vf id last 1 / end \\\n                         actions mirror pf / end\n   or\n   flow create 0 ingress pattern vf id mask 0x3 / end \\\n                         actions mirror pf / end\n6) egress: vf 0,1 => pf\n   set port 0 mirror-rule 0 pool-mirror-down 0x3 dst-pool 4 on\n   or\n   flow create 0 egress pattern vf id is 0 / end actions mirror pf / end\n   flow create 0 egress pattern vf id is 1 / end actions mirror pf / end\n   or\n   flow create 0 egress pattern vf id last 1 / end actions mirror pf / end\n   or\n   flow create 0 egress pattern vf id mask 0x3 / end \\\n                        actions mirror pf / end\n7) ingress: vf 1,2 => vf 3\n   set port 0 mirror-rule 0 pool-mirror-up 0x6 dst-pool 3 on\n   or\n   flow create 0 ingress pattern vf id is 1 / end \\\n                         actions mirror vf id 3 / end\n\n   flow create 0 ingress pattern vf id is 2 / end \\\n                         actions mirror vf id 3 / end\n   or\n   flow create 0 ingress pattern vf id is 1 id last 2 / end \\\n                         actions mirror vf id 3 / end\n   or\n   flow create 0 ingress pattern vf id mask 0x6 / end \\\n                         actions mirror vf id 3 / end\n8) egress: vf 1,2 => vf 3\n   set port 0 mirror-rule 0 pool-mirror-down 0x6 dst-pool 3 on\n   or\n   flow create 0 egress pattern vf id is 1 / end \\\n                        actions mirror vf id 3 / end\n\n   flow create 0 egress pattern vf id is 2 / end \\\n                        actions mirror vf id 3 / end\n   or\n   flow create 0 egress pattern vf id is 1 id last 2 / end \\\n                        actions mirror vf id 3 / end\n   or\n   flow create 0 egress pattern vf id mask 0x6 / end \\\n                        actions mirror vf id 3 / end\n9) ingress: vlan 4,6 => vf 3\n   set port 0 mirror-rule 0 vlan-mirror 4,6 dst-pool 4 on\n   or\n   flow create 0 ingress pattern vlan vid is 4 / end \\\n                         actions mirror vf id 3 / end\n\n   flow create 0 ingress pattern vlan vid is 6 / end \\\n                         actions mirror vf id 3 end\n   or\n   flow create 0 ingress pattern vlan vid mask 0x28 / end \\\n                         actions mirror vf id 3 / end\n   or\n   flow create 0 ingress pattern vlan vid is 4 vid last 6 \\\n        vid mask 0x5 / end actions mirror vf id 3 / end\n\nSigned-off-by: Simon Lu <simonx.lu@intel.com>\n---\n drivers/net/i40e/i40e_flow.c | 153 +++++++++++++++++++++++++++++++++++\n 1 file changed, 153 insertions(+)",
    "diff": "diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c\nindex 578a68773..8164903a2 100644\n--- a/drivers/net/i40e/i40e_flow.c\n+++ b/drivers/net/i40e/i40e_flow.c\n@@ -116,6 +116,7 @@ static int i40e_flow_flush_fdir_filter(struct i40e_pf *pf);\n static int i40e_flow_flush_ethertype_filter(struct i40e_pf *pf);\n static int i40e_flow_flush_tunnel_filter(struct i40e_pf *pf);\n static int i40e_flow_flush_rss_filter(struct rte_eth_dev *dev);\n+static int i40e_flow_flush_mirror_filter(struct rte_eth_dev *dev);\n static int\n i40e_flow_parse_qinq_filter(struct rte_eth_dev *dev,\n \t\t\t      const struct rte_flow_attr *attr,\n@@ -5508,6 +5509,104 @@ i40e_parse_mirror_filter(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+static int\n+i40e_config_mirror_filter_set(struct rte_eth_dev *dev,\n+\t\t\t      struct i40e_mirror_rule_conf *conf)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tstruct i40e_mirror_filter *it;\n+\tstruct i40e_mirror_filter *mirror_filter;\n+\tuint16_t rule_id;\n+\tint ret;\n+\n+\tif (pf->main_vsi->veb == NULL || pf->vfs == NULL) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t\"mirror rule can not be configured without veb or vfs.\");\n+\t\treturn -ENOSYS;\n+\t}\n+\tif (pf->nb_mirror_rule > I40E_MAX_MIRROR_RULES) {\n+\t\tPMD_DRV_LOG(ERR, \"mirror table is full.\");\n+\t\treturn -ENOSPC;\n+\t}\n+\n+\tTAILQ_FOREACH(it, &pf->mirror_filter_list, next) {\n+\t\tif (it->conf.dst_vsi_seid == conf->dst_vsi_seid &&\n+\t\t    it->conf.rule_type == conf->rule_type &&\n+\t\t    it->conf.num_entries == conf->num_entries &&\n+\t\t    !memcmp(it->conf.entries, conf->entries,\n+\t\t\t    conf->num_entries * sizeof(conf->entries[0]))) {\n+\t\t\tPMD_DRV_LOG(ERR, \"mirror rule exists.\");\n+\t\t\treturn -EEXIST;\n+\t\t}\n+\t}\n+\n+\tmirror_filter = rte_zmalloc(\"i40e_mirror_filter\",\n+\t\t\t\t    sizeof(*mirror_filter), 0);\n+\tif (mirror_filter == NULL) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to alloc memory.\");\n+\t\treturn -ENOMEM;\n+\t}\n+\tmirror_filter->conf = *conf;\n+\n+\tret = i40e_aq_add_mirror_rule(hw,\n+\t\t\t\t      pf->main_vsi->veb->seid,\n+\t\t\t\t      mirror_filter->conf.dst_vsi_seid,\n+\t\t\t\t      mirror_filter->conf.rule_type,\n+\t\t\t\t      mirror_filter->conf.entries,\n+\t\t\t\t      mirror_filter->conf.num_entries,\n+\t\t\t\t      &rule_id);\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t\"failed to add mirror rule: ret = %d, aq_err = %d.\",\n+\t\t\tret, hw->aq.asq_last_status);\n+\t\trte_free(mirror_filter);\n+\t\treturn -ENOSYS;\n+\t}\n+\n+\tmirror_filter->conf.rule_id = rule_id;\n+\n+\tpf->nb_mirror_rule++;\n+\n+\tTAILQ_INSERT_TAIL(&pf->mirror_filter_list, mirror_filter, next);\n+\n+\treturn 0;\n+}\n+\n+static int\n+i40e_config_mirror_filter_del(struct rte_eth_dev *dev,\n+\t\t\t      struct i40e_mirror_rule_conf *conf)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tstruct i40e_mirror_filter *mirror_filter;\n+\tvoid *temp;\n+\tint ret;\n+\n+\tret = i40e_aq_del_mirror_rule(hw,\n+\t\t\t\t      pf->main_vsi->veb->seid,\n+\t\t\t\t      conf->rule_type,\n+\t\t\t\t      conf->entries,\n+\t\t\t\t      conf->num_entries,\n+\t\t\t\t      conf->rule_id);\n+\tif (ret < 0) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t    \"failed to remove mirror rule: ret = %d, aq_err = %d.\",\n+\t\t\t    ret, hw->aq.asq_last_status);\n+\t\treturn -ENOSYS;\n+\t}\n+\n+\tTAILQ_FOREACH_SAFE(mirror_filter, &pf->mirror_filter_list, next, temp) {\n+\t\tif (!memcmp(&mirror_filter->conf, conf,\n+\t\t\t    sizeof(struct i40e_mirror_rule_conf))) {\n+\t\t\tTAILQ_REMOVE(&pf->mirror_filter_list,\n+\t\t\t\t     mirror_filter, next);\n+\t\t\trte_free(mirror_filter);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n static int\n i40e_flow_validate(struct rte_eth_dev *dev,\n \t\t   const struct rte_flow_attr *attr,\n@@ -5553,6 +5652,12 @@ i40e_flow_validate(struct rte_eth_dev *dev,\n \t\treturn ret;\n \t}\n \n+\tif ((actions + i)->type == RTE_FLOW_ACTION_TYPE_MIRROR) {\n+\t\tret = i40e_parse_mirror_filter(dev, attr, pattern,\n+\t\t\t\t\t    actions, &cons_filter, error);\n+\t\treturn ret;\n+\t}\n+\n \ti = 0;\n \t/* Get the non-void item number of pattern */\n \twhile ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {\n@@ -5672,6 +5777,14 @@ i40e_flow_create(struct rte_eth_dev *dev,\n \t\tflow->rule = TAILQ_LAST(&pf->rss_config_list,\n \t\t\t\ti40e_rss_conf_list);\n \t\tbreak;\n+\tcase RTE_ETH_FILTER_MIRROR:\n+\t\tret = i40e_config_mirror_filter_set(dev,\n+\t\t\t\t\t\t    &cons_filter.mirror_conf);\n+\t\tif (ret)\n+\t\t\tgoto free_flow;\n+\t\tflow->rule = TAILQ_LAST(&pf->mirror_filter_list,\n+\t\t\t\t\ti40e_mirror_filter_list);\n+\t\tbreak;\n \tdefault:\n \t\tgoto free_flow;\n \t}\n@@ -5726,6 +5839,10 @@ i40e_flow_destroy(struct rte_eth_dev *dev,\n \t\tret = i40e_config_rss_filter_del(dev,\n \t\t\t&((struct i40e_rss_filter *)flow->rule)->rss_filter_info);\n \t\tbreak;\n+\tcase RTE_ETH_FILTER_MIRROR:\n+\t\tret = i40e_config_mirror_filter_del(dev,\n+\t\t\t&((struct i40e_mirror_filter *)flow->rule)->conf);\n+\t\tbreak;\n \tdefault:\n \t\tPMD_DRV_LOG(WARNING, \"Filter type (%d) not supported\",\n \t\t\t    filter_type);\n@@ -5880,6 +5997,14 @@ i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)\n \t\treturn -rte_errno;\n \t}\n \n+\tret = i40e_flow_flush_mirror_filter(dev);\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   \"Failed to flush mirror flows.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n \treturn ret;\n }\n \n@@ -6026,6 +6151,34 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev)\n \treturn ret;\n }\n \n+/* remove the mirror filter */\n+static int\n+i40e_flow_flush_mirror_filter(struct rte_eth_dev *dev)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct rte_flow *flow;\n+\tvoid *temp;\n+\tint32_t ret = -EINVAL;\n+\n+\t/* Delete mirror flows in flow list. */\n+\tTAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {\n+\t\tstruct i40e_mirror_filter *rule = flow->rule;\n+\n+\t\tif (flow->filter_type != RTE_ETH_FILTER_MIRROR)\n+\t\t\tcontinue;\n+\n+\t\tif (rule) {\n+\t\t\tret = i40e_config_mirror_filter_del(dev, &rule->conf);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n+\t\tTAILQ_REMOVE(&pf->flow_list, flow, node);\n+\t\trte_free(flow);\n+\t}\n+\n+\treturn ret;\n+}\n+\n static int\n i40e_flow_query(struct rte_eth_dev *dev __rte_unused,\n \t\tstruct rte_flow *flow,\n",
    "prefixes": [
        "v1",
        "8/8"
    ]
}