get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 491,
    "url": "https://patches.dpdk.org/api/patches/491/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1411628369-29532-5-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-5-git-send-email-jingjing.wu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1411628369-29532-5-git-send-email-jingjing.wu@intel.com",
    "date": "2014-09-25T06:59:29",
    "name": "[dpdk-dev,4/4] app/test-pmd: add commands for control packet filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9603b1fae4e4a3e76184437cae058e431b46c4c7",
    "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-5-git-send-email-jingjing.wu@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/491/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/491/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 987B6B38C;\n\tThu, 25 Sep 2014 08:54:15 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 6F4C4AF7F\n\tfor <dev@dpdk.org>; Thu, 25 Sep 2014 08:54:14 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga101.fm.intel.com with ESMTP; 25 Sep 2014 00:00:13 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby FMSMGA003.fm.intel.com with ESMTP; 24 Sep 2014 23:54:14 -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 s8P70BIs030197;\n\tThu, 25 Sep 2014 15:00:11 +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 s8P708h7029875; Thu, 25 Sep 2014 15:00:11 +0800",
            "(from wujingji@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8P708KA029871; \n\tThu, 25 Sep 2014 15:00:08 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"4.97,862,1389772800\"; d=\"scan'208\";a=\"391341480\"",
        "From": "Jingjing Wu <jingjing.wu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 25 Sep 2014 14:59:29 +0800",
        "Message-Id": "<1411628369-29532-5-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 4/4] app/test-pmd: add commands for control\n\tpacket filter",
        "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": "Add command to test control packet filter\n - add/delete control packet filter\n\nSigned-off-by: Jingjing Wu <jingjing.wu@intel.com>\n---\n app/test-pmd/cmdline.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 149 insertions(+)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 225f669..1354230 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -660,6 +660,12 @@ static void cmd_help_long_parsed(void *parsed_result,\n \n \t\t\t\"get_flex_filter (port_id) index (idx)\\n\"\n \t\t\t\"    get info of a flex filter.\\n\\n\"\n+\n+\t\t\t\"ctrl_pkt_filter (port_id) (add|del)\"\n+\t\t\t\"mac_addr (mac_address) ethertype (ether_type)\"\n+\t\t\t\"(none|options) queue (queue_id)\\n\"\n+\t\t\t\"    Add/Del a control packet filter.\\n\\n\"\n+\n \t\t);\n \t}\n }\n@@ -7411,6 +7417,148 @@ cmdline_parse_inst_t cmd_get_flex_filter = {\n \t},\n };\n \n+/* *** Filters Control *** */\n+\n+static inline int\n+parse_ctrl_pkt_filter_options(const char *q_arg,\n+\t\t\t     uint16_t *flags)\n+{\n+#define MAX_NUM_OPTIONS 3\n+\tchar s[256];\n+\tchar *str_fld[MAX_NUM_OPTIONS];\n+\tint i;\n+\tint num_options = -1;\n+\tunsigned size;\n+\n+\t*flags = 0;\n+\tif (!strcmp(q_arg, \"none\"))\n+\t\treturn 0;\n+\n+\tsize = strnlen(q_arg, sizeof(s));\n+\tsnprintf(s, sizeof(s), \"%.*s\", size, q_arg);\n+\tnum_options = rte_strsplit(s, sizeof(s), str_fld, MAX_NUM_OPTIONS, '-');\n+\t/* multi-options are combined by - */\n+\tif (num_options < 0 || num_options > MAX_NUM_OPTIONS)\n+\t\treturn -1;\n+\tfor (i = 0; i < num_options; i++) {\n+\t\tif (!strcmp(str_fld[i], \"tx\"))\n+\t\t\t*flags |= RTE_CONTROL_PACKET_FLAGS_TX;\n+\t\tif (!strcmp(str_fld[i], \"mac_ignr\"))\n+\t\t\t*flags |= RTE_CONTROL_PACKET_FLAGS_IGNORE_MAC;\n+\t\tif (!strcmp(str_fld[i], \"drop\"))\n+\t\t\t*flags |= RTE_CONTROL_PACKET_FLAGS_DROP;\n+\t}\n+\treturn num_options;\n+}\n+\n+struct cmd_ctrl_pkt_filter_result {\n+\tcmdline_fixed_string_t filter;\n+\tuint8_t port_id;\n+\tcmdline_fixed_string_t ops;\n+\tcmdline_fixed_string_t mac_addr;\n+\tstruct ether_addr mac_addr_value;\n+\tcmdline_fixed_string_t ethertype;\n+\tuint16_t ethertype_value;\n+\tcmdline_fixed_string_t options;\n+\tcmdline_fixed_string_t queue;\n+\tuint16_t  queue_id;\n+};\n+\n+cmdline_parse_token_string_t cmd_ctrl_pkt_filter_filter =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t filter, \"ctrl_pkt_filter\");\n+cmdline_parse_token_num_t cmd_ctrl_pkt_filter_port_id =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t      port_id, UINT8);\n+cmdline_parse_token_string_t cmd_ctrl_pkt_filter_ops =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t ops, \"add#del\");\n+cmdline_parse_token_string_t cmd_ctrl_pkt_filter_mac_addr =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t mac_addr, \"mac_addr\");\n+cmdline_parse_token_etheraddr_t cmd_ctrl_pkt_filter_mac_addr_value =\n+\tTOKEN_ETHERADDR_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t     mac_addr_value);\n+cmdline_parse_token_string_t cmd_ctrl_pkt_filter_ethertype =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t ethertype, \"ethertype\");\n+cmdline_parse_token_num_t cmd_ctrl_pkt_filter_ethertype_value =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t      ethertype_value, UINT16);\n+cmdline_parse_token_string_t cmd_ctrl_pkt_filter_options =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t options, NULL);\n+cmdline_parse_token_string_t cmd_ctrl_pkt_filter_queue =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t\t queue, \"queue\");\n+cmdline_parse_token_num_t cmd_ctrl_pkt_filter_queue_id =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_ctrl_pkt_filter_result,\n+\t\t\t      queue_id, UINT16);\n+\n+static void\n+cmd_ctrl_pkt_filter_parsed(void *parsed_result,\n+\t\t\t  __attribute__((unused)) struct cmdline *cl,\n+\t\t\t  __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_ctrl_pkt_filter_result *res = parsed_result;\n+\tstruct rte_ctrl_pkt_filter filter;\n+\tint ret = 0;\n+\n+\tret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_CTRL_PKT);\n+\tif (ret < 0) {\n+\t\tprintf(\"control packet filter is not supported on port %u. \\n\",\n+\t\t\tres->port_id);\n+\t\treturn;\n+\t}\n+\n+\tmemset(&filter, 0, sizeof(filter));\n+\n+\t(void)rte_memcpy(&filter.mac_addr, &res->mac_addr_value,\n+\t\tsizeof(struct ether_addr));\n+\tfilter.ether_type = res->ethertype_value;\n+\n+\tret = parse_ctrl_pkt_filter_options(res->options, &filter.flags);\n+\tif (ret < 0) {\n+\t\tprintf(\"options input is invalid. \\n\");\n+\t\treturn;\n+\t}\n+\tif (!(filter.flags & RTE_CONTROL_PACKET_FLAGS_DROP)) {\n+\t\tfilter.flags |= RTE_CONTROL_PACKET_FLAGS_TO_QUEUE;\n+\t\tfilter.queue = res->queue_id;\n+\t}\n+\tif (!strcmp(res->ops, \"add\"))\n+\t\tret = rte_eth_dev_filter_ctrl(res->port_id,\n+\t\t\t\tRTE_ETH_FILTER_CTRL_PKT,\n+\t\t\t\tRTE_ETH_FILTER_OP_ADD,\n+\t\t\t\t&filter);\n+\telse\n+\t\tret = rte_eth_dev_filter_ctrl(res->port_id,\n+\t\t\t\tRTE_ETH_FILTER_CTRL_PKT,\n+\t\t\t\tRTE_ETH_FILTER_OP_DELETE,\n+\t\t\t\t&filter);\n+\tif (ret < 0)\n+\t\tprintf(\"control packet filter programming error: (%s)\\n\", strerror(-ret));\n+}\n+\n+cmdline_parse_inst_t cmd_ctrl_pkt_filter = {\n+\t.f = cmd_ctrl_pkt_filter_parsed,\n+\t.data = NULL,\n+\t.help_str = \"add or delete a control packet filter entry\",\n+\t.tokens = {\n+\t\t(void *)&cmd_ctrl_pkt_filter_filter,\n+\t\t(void *)&cmd_ctrl_pkt_filter_port_id,\n+\t\t(void *)&cmd_ctrl_pkt_filter_ops,\n+\t\t(void *)&cmd_ctrl_pkt_filter_mac_addr,\n+\t\t(void *)&cmd_ctrl_pkt_filter_mac_addr_value,\n+\t\t(void *)&cmd_ctrl_pkt_filter_ethertype,\n+\t\t(void *)&cmd_ctrl_pkt_filter_ethertype_value,\n+\t\t(void *)&cmd_ctrl_pkt_filter_options,\n+\t\t(void *)&cmd_ctrl_pkt_filter_queue,\n+\t\t(void *)&cmd_ctrl_pkt_filter_queue_id,\n+\t\tNULL,\n+\t},\n+};\n+\n /* ******************************************************************************** */\n \n /* list of instructions */\n@@ -7537,6 +7685,7 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_add_flex_filter,\n \t(cmdline_parse_inst_t *)&cmd_remove_flex_filter,\n \t(cmdline_parse_inst_t *)&cmd_get_flex_filter,\n+\t(cmdline_parse_inst_t *)&cmd_ctrl_pkt_filter,\n \tNULL,\n };\n \n",
    "prefixes": [
        "dpdk-dev",
        "4/4"
    ]
}