get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 490,
    "url": "https://patches.dpdk.org/api/patches/490/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1411628369-29532-4-git-send-email-jingjing.wu@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": "<1411628369-29532-4-git-send-email-jingjing.wu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1411628369-29532-4-git-send-email-jingjing.wu@intel.com",
    "date": "2014-09-25T06:59:28",
    "name": "[dpdk-dev,3/4] i40e: ctrl_pkt filter implementation in i40e pmd driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8ab1a91ea05bf258698215fab6dff310de88119d",
    "submitter": {
        "id": 47,
        "url": "https://patches.dpdk.org/api/people/47/?format=api",
        "name": "Jingjing Wu",
        "email": "jingjing.wu@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1411628369-29532-4-git-send-email-jingjing.wu@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/490/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/490/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 DD307AFCA;\n\tThu, 25 Sep 2014 08:54:02 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id E4030ADC4\n\tfor <dev@dpdk.org>; Thu, 25 Sep 2014 08:54:00 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga102.fm.intel.com with ESMTP; 25 Sep 2014 00:00:16 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 25 Sep 2014 00:00:06 -0700",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id s8P704QL030160;\n\tThu, 25 Sep 2014 15:00:04 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid s8P702D8029792; Thu, 25 Sep 2014 15:00:04 +0800",
            "(from wujingji@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8P701kI029761; \n\tThu, 25 Sep 2014 15:00:01 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.04,595,1406617200\"; d=\"scan'208\";a=\"596576566\"",
        "From": "Jingjing Wu <jingjing.wu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 25 Sep 2014 14:59:28 +0800",
        "Message-Id": "<1411628369-29532-4-git-send-email-jingjing.wu@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1411628369-29532-1-git-send-email-jingjing.wu@intel.com>",
        "References": "<1411628369-29532-1-git-send-email-jingjing.wu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 3/4] i40e: ctrl_pkt filter implementation in i40e\n\tpmd driver",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <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": "Implement control packet filter, support add and delete operations.\nIt can assign packets to specific queue or vsi by filtering with mac address and ethertype or only\n ethertype on both rx and tx directions.\n\nSigned-off-by: Jingjing Wu <jingjing.wu@intel.com>\n---\n lib/librte_pmd_i40e/i40e_ethdev.c | 161 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 161 insertions(+)",
    "diff": "diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c\nindex a00d6ca..ab662ff 100644\n--- a/lib/librte_pmd_i40e/i40e_ethdev.c\n+++ b/lib/librte_pmd_i40e/i40e_ethdev.c\n@@ -205,6 +205,15 @@ static int i40e_dev_rss_hash_update(struct rte_eth_dev *dev,\n \t\t\t\t    struct rte_eth_rss_conf *rss_conf);\n static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,\n \t\t\t\t      struct rte_eth_rss_conf *rss_conf);\n+static int i40e_ctrl_pkt_filter_set(struct i40e_pf *pf,\n+\t\t\tstruct rte_ctrl_pkt_filter *cp_filter,\n+\t\t\tbool add);\n+static int i40e_ctrl_pkt_filter_handle(struct i40e_pf *pf,\n+\t\t\t\tenum rte_filter_op filter_op,\n+\t\t\t\tvoid *arg);\n+static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,\n+\t\t\t\tenum rte_filter_type filter_type,\n+\t\t\t\tenum rte_filter_op filter_op, void *arg);\n \n /* Default hash key buffer for RSS */\n static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];\n@@ -256,6 +265,7 @@ static struct eth_dev_ops i40e_eth_dev_ops = {\n \t.reta_query                   = i40e_dev_rss_reta_query,\n \t.rss_hash_update              = i40e_dev_rss_hash_update,\n \t.rss_hash_conf_get            = i40e_dev_rss_hash_conf_get,\n+\t.filter_ctrl                  = i40e_dev_filter_ctrl,\n };\n \n static struct eth_driver rte_i40e_pmd = {\n@@ -4131,3 +4141,154 @@ i40e_pf_config_mq_rx(struct i40e_pf *pf)\n \n \treturn 0;\n }\n+\n+/* Look up vsi by vsi_id */\n+static struct i40e_vsi *\n+i40e_vsi_lookup_by_id(struct i40e_vsi *uplink_vsi, uint16_t id)\n+{\n+\tstruct i40e_vsi *vsi = NULL;\n+\tstruct i40e_vsi_list *vsi_list;\n+\n+\tif (uplink_vsi == NULL)\n+\t\treturn NULL;\n+\n+\tif (uplink_vsi->vsi_id == id)\n+\t\treturn vsi;\n+\n+\t/* if VSI has child to attach*/\n+\tif (uplink_vsi->veb) {\n+\t\tTAILQ_FOREACH(vsi_list, &uplink_vsi->veb->head, list) {\n+\t\t\tvsi = i40e_vsi_lookup_by_id(vsi_list->vsi, id);\n+\t\t\tif (vsi)\n+\t\t\t\treturn vsi;\n+\t\t}\n+\t}\n+\treturn NULL;\n+}\n+\n+/*\n+ * Configure control packet filter, which can director packet by filtering\n+ * with mac address and ether_type or only ether_type\n+ */\n+static int\n+i40e_ctrl_pkt_filter_set(struct i40e_pf *pf,\n+\t\t\tstruct rte_ctrl_pkt_filter *cp_filter,\n+\t\t\tbool add)\n+{\n+\tstruct i40e_hw *hw = I40E_PF_TO_HW(pf);\n+\tstruct i40e_control_filter_stats stats;\n+\tstruct i40e_vsi *vsi = NULL;\n+\tuint16_t seid;\n+\tuint16_t flags = 0;\n+\tint ret;\n+\n+\tif (cp_filter->ether_type == ETHER_TYPE_IPv4 ||\n+\t\tcp_filter->ether_type == ETHER_TYPE_IPv6) {\n+\t\tPMD_DRV_LOG(ERR, \"unsupported ether_type(0x%04x) in\"\n+\t\t\t\" control packet filter.\", cp_filter->ether_type);\n+\t\treturn -EINVAL;\n+\t}\n+\tif (cp_filter->ether_type == ETHER_TYPE_VLAN)\n+\t\tPMD_DRV_LOG(WARNING, \"filter vlan ether_type in first tag is\"\n+\t\t\t\" not supported.\");\n+\n+\tif (cp_filter->dest_id == 0)\n+\t\t/* Use LAN VSI Id if not programmed by user */\n+\t\tvsi = pf->main_vsi;\n+\telse {\n+\t\tvsi = i40e_vsi_lookup_by_id(pf->main_vsi, cp_filter->dest_id);\n+\t\tif (vsi == NULL || vsi->type == I40E_VSI_FDIR) {\n+\t\t\tPMD_DRV_LOG(ERR, \"VSI arg is invalid\\n\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tseid = vsi->seid;\n+\tmemset(&stats, 0, sizeof(stats));\n+\n+\tif (cp_filter->flags & RTE_CONTROL_PACKET_FLAGS_TX)\n+\t\tflags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;\n+\tif (cp_filter->flags & RTE_CONTROL_PACKET_FLAGS_IGNORE_MAC)\n+\t\tflags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;\n+\tif (cp_filter->flags & RTE_CONTROL_PACKET_FLAGS_TO_QUEUE)\n+\t\tflags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;\n+\tif (cp_filter->flags & RTE_CONTROL_PACKET_FLAGS_DROP)\n+\t\tflags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;\n+\n+\tret = i40e_aq_add_rem_control_packet_filter(hw,\n+\t\t\tcp_filter->mac_addr.addr_bytes,\n+\t\t\tcp_filter->ether_type, flags,\n+\t\t\tseid, cp_filter->queue, add, &stats, NULL);\n+\n+\tPMD_DRV_LOG(INFO, \"add/rem control packet filter, return %d,\"\n+\t\t\t \" mac_etype_used = %u, etype_used = %u,\"\n+\t\t\t \" mac_etype_free = %u, etype_free = %u\\n\",\n+\t\t\t ret, stats.mac_etype_used, stats.etype_used,\n+\t\t\t stats.mac_etype_free, stats.etype_free);\n+\tif (ret < 0)\n+\t\treturn -ENOSYS;\n+\treturn 0;\n+}\n+\n+/*\n+ * Handle operations for control packte filter type.\n+ */\n+static int\n+i40e_ctrl_pkt_filter_handle(struct i40e_pf *pf,\n+\t\t\t\tenum rte_filter_op filter_op,\n+\t\t\t\tvoid *arg)\n+{\n+\tint ret = 0;\n+\n+\tif (arg == NULL && filter_op != RTE_ETH_FILTER_OP_NONE) {\n+\t\tPMD_DRV_LOG(ERR, \"arg shouldn't be NULL for operation %u\\n\",\n+\t\t\t    filter_op);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tswitch (filter_op) {\n+\tcase RTE_ETH_FILTER_OP_NONE:\n+\t\tret = 0;\n+\t\tbreak;\n+\tcase RTE_ETH_FILTER_OP_ADD:\n+\t\tret = i40e_ctrl_pkt_filter_set(pf,\n+\t\t\t(struct rte_ctrl_pkt_filter *)arg,\n+\t\t\tTRUE);\n+\t\tbreak;\n+\tcase RTE_ETH_FILTER_OP_DELETE:\n+\t\tret = i40e_ctrl_pkt_filter_set(pf,\n+\t\t\t(struct rte_ctrl_pkt_filter *)arg,\n+\t\t\tFALSE);\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"unsupported operation %u\\n\", filter_op);\n+\t\tret = -ENOSYS;\n+\t\tbreak;\n+\t}\n+\treturn ret;\n+}\n+\n+/*\n+ * Take operations to assigned filter type on NIC.\n+ */\n+static int\n+i40e_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type,\n+\t\t     enum rte_filter_op filter_op, void *arg)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tint ret = I40E_SUCCESS;\n+\n+\tif (dev == NULL)\n+\t\treturn -EINVAL;\n+\n+\tswitch (filter_type) {\n+\tcase RTE_ETH_FILTER_CTRL_PKT:\n+\t\tret = i40e_ctrl_pkt_filter_handle(pf, filter_op, arg);\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"unsupported filter type %u.\", filter_type);\n+\t\tret = -EINVAL;\n+\t\tbreak;\n+\t}\n+\treturn ret;\n+}\n",
    "prefixes": [
        "dpdk-dev",
        "3/4"
    ]
}