Show a patch.

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

{
    "id": 195,
    "url": "https://patches.dpdk.org/api/patches/195/?format=api",
    "web_url": "https://patches.dpdk.org/patch/195/",
    "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"
    },
    "msgid": "<1408695969-9774-6-git-send-email-helin.zhang@intel.com>",
    "date": "2014-08-22T08:26:09",
    "name": "[dpdk-dev,5/5] app/testpmd: rework of updating/querying redirection table",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7a49910c3e828d13ef6815bdddd45cf9f914f798",
    "submitter": {
        "id": 14,
        "url": "https://patches.dpdk.org/api/people/14/?format=api",
        "name": "Helin Zhang",
        "email": "helin.zhang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/195/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/195/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/195/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Received": [
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id DDE9EB37D\n\tfor <dev@dpdk.org>; Fri, 22 Aug 2014 10:22:47 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga102.fm.intel.com with ESMTP; 22 Aug 2014 01:26:28 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 22 Aug 2014 01:26:27 -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 s7M8QP9G017813;\n\tFri, 22 Aug 2014 16:26:25 +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 s7M8QLnX009919; Fri, 22 Aug 2014 16:26:23 +0800",
            "(from hzhan75@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7M8QL1Z009915; \n\tFri, 22 Aug 2014 16:26:21 +0800"
        ],
        "References": "<1408695969-9774-1-git-send-email-helin.zhang@intel.com>",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<1408695969-9774-6-git-send-email-helin.zhang@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.04,378,1406617200\"; d=\"scan'208\";a=\"580304319\"",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Precedence": "list",
        "From": "Helin Zhang <helin.zhang@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "X-List-Received-Date": "Fri, 22 Aug 2014 08:22:48 -0000",
        "Return-Path": "<hzhan75@shecgisg004.sh.intel.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": "<1408695969-9774-1-git-send-email-helin.zhang@intel.com>",
        "To": "dev@dpdk.org",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "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>",
        "Date": "Fri, 22 Aug 2014 16:26:09 +0800",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Subject": "[dpdk-dev] [PATCH 5/5] app/testpmd: rework of updating/querying\n\tredirection table"
    },
    "content": "As multiple sizes (64, 128, 512) of redirection table have\nbeen supported, the commands of updating/querying redirection\ntable entries have been reworked. In addition, the\nredirection table size can be queried by the existing\ncommand of 'show port info <>'.\n\nSigned-off-by: Helin Zhang <helin.zhang@intel.com>\nReviewed-by: Jijiang Liu <jijiang.liu@intel.com>\nReviewed-by: Cunming Liang <cunming.liang@intel.com>\nReviewed-by: Jingjing Wu <jingjing.wu@intel.com>\n---\n app/test-pmd/cmdline.c | 159 ++++++++++++++++++++++++++++++++++++-------------\n app/test-pmd/config.c  |  37 ++++++------\n app/test-pmd/testpmd.h |   4 +-\n 3 files changed, 137 insertions(+), 63 deletions(-)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 345be11..5ad501e 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -59,6 +59,7 @@\n #include <rte_cycles.h>\n #include <rte_memory.h>\n #include <rte_memzone.h>\n+#include <rte_malloc.h>\n #include <rte_launch.h>\n #include <rte_tailq.h>\n #include <rte_eal.h>\n@@ -186,6 +187,11 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"show port (info|stats|fdir|stat_qmap) (port_id|all)\\n\"\n \t\t\t\"    Display information for port_id, or all.\\n\\n\"\n \n+\t\t\t\"show port X rss reta (size) (mask0,mask1,...)\\n\"\n+\t\t\t\"    Display the rss redirection table entry indicated\"\n+\t\t\t\" by masks or port X. size is used to indicate the\"\n+\t\t\t\" hardware supported reta size\\n\\n\"\n+\n \t\t\t\"show port rss-hash [key]\\n\"\n \t\t\t\"    Display the RSS hash functions and RSS hash key\"\n \t\t\t\" of port X\\n\\n\"\n@@ -1436,11 +1442,13 @@ struct cmd_config_rss_reta {\n };\n \n static int\n-parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)\n+parse_reta_config(const char *str,\n+\t\t  struct rte_eth_rss_reta_entry64 *reta_conf,\n+\t\t  uint16_t nb_entries)\n {\n \tint i;\n \tunsigned size;\n-\tuint8_t hash_index;\n+\tuint16_t hash_index, idx, shift;\n \tuint8_t nb_queue;\n \tchar s[256];\n \tconst char *p, *p0 = str;\n@@ -1475,17 +1483,15 @@ parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)\n \t\thash_index = (uint8_t)int_fld[FLD_HASH_INDEX];\n \t\tnb_queue = (uint8_t)int_fld[FLD_QUEUE];\n \n-\t\tif (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {\n+\t\tif (hash_index >= nb_entries) {\n \t\t\tprintf(\"Invalid RETA hash index=%d\",hash_index);\n \t\t\treturn -1;\n \t\t}\n \n-\t\tif (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)\n-\t\t\treta_conf->mask_lo |= (1ULL << hash_index);\n-\t\telse\n-\t\t\treta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));\n-\n-\t\treta_conf->reta[hash_index] = nb_queue;\n+\t\tidx = hash_index / RTE_BIT_WIDTH_64;\n+\t\tshift = hash_index % RTE_BIT_WIDTH_64;\n+\t\treta_conf[idx].mask |= (1ULL << shift);\n+\t\treta_conf[idx].reta[shift] = nb_queue;\n \t}\n \n \treturn 0;\n@@ -1493,22 +1499,42 @@ parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)\n \n static void\n cmd_set_rss_reta_parsed(void *parsed_result,\n-\t\t\t\t__attribute__((unused)) struct cmdline *cl,\n-\t\t\t\t__attribute__((unused)) void *data)\n+\t\t\t__attribute__((unused)) struct cmdline *cl,\n+\t\t\t__attribute__((unused)) void *data)\n {\n \tint ret;\n-\tstruct rte_eth_rss_reta reta_conf;\n+\tstruct rte_eth_dev_info dev_info;\n+\tstruct rte_eth_rss_reta_entry64 reta_conf[8];\n \tstruct cmd_config_rss_reta *res = parsed_result;\n \n-\tmemset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));\n+\tmemset(&dev_info, 0, sizeof(dev_info));\n+\trte_eth_dev_info_get(res->port_id, &dev_info);\n+\tif (dev_info.reta_size == 0) {\n+\t\tprintf(\"Redirection table size is 0 which is \"\n+\t\t\t\t\t\"invalid for RSS\\n\");\n+\t\treturn;\n+\t} else\n+\t\tprintf(\"The reta size of port %d is %u\\n\",\n+\t\t\tres->port_id, dev_info.reta_size);\n+\tif (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {\n+\t\tprintf(\"Currently do not support more than %u entries of \"\n+\t\t\t\"redirection table\\n\", ETH_RSS_RETA_SIZE_512);\n+\t\treturn;\n+\t}\n+\n+\tmemset(reta_conf, 0, sizeof(reta_conf));\n \tif (!strcmp(res->list_name, \"reta\")) {\n-\t\tif (parse_reta_config(res->list_of_items, &reta_conf)) {\n-\t\t\tprintf(\"Invalid RSS Redirection Table config entered\\n\");\n+\t\tif (parse_reta_config(res->list_of_items, reta_conf,\n+\t\t\t\t\t\tdev_info.reta_size)) {\n+\t\t\tprintf(\"Invalid RSS Redirection Table \"\n+\t\t\t\t\t\"config entered\\n\");\n \t\t\treturn;\n \t\t}\n-\t\tret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);\n+\t\tret = rte_eth_dev_rss_reta_update(res->port_id,\n+\t\t\t\treta_conf, dev_info.reta_size);\n \t\tif (ret != 0)\n-\t\t\tprintf(\"Bad redirection table parameter, return code = %d \\n\",ret);\n+\t\t\tprintf(\"Bad redirection table parameter, \"\n+\t\t\t\t\t\"return code = %d \\n\", ret);\n \t}\n }\n \n@@ -1547,56 +1573,103 @@ struct cmd_showport_reta {\n \tuint8_t port_id;\n \tcmdline_fixed_string_t rss;\n \tcmdline_fixed_string_t reta;\n-\tuint64_t mask_lo;\n-\tuint64_t mask_hi;\n+\tuint16_t size;\n+\tcmdline_fixed_string_t list_of_items;\n };\n \n-static void cmd_showport_reta_parsed(void *parsed_result,\n-\t\t\t\t__attribute__((unused)) struct cmdline *cl,\n-\t\t\t\t__attribute__((unused)) void *data)\n+static int\n+showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,\n+\t\t\t   uint16_t nb_entries,\n+\t\t\t   char *str)\n {\n-\tstruct cmd_showport_reta *res = parsed_result;\n-\tstruct rte_eth_rss_reta reta_conf;\n+\tuint32_t size;\n+\tconst char *p, *p0 = str;\n+\tchar s[256];\n+\tchar *end;\n+\tchar *str_fld[8];\n+\tuint16_t i, num = nb_entries / RTE_BIT_WIDTH_64;\n+\tint ret;\n \n-\tif ((res->mask_lo == 0) && (res->mask_hi == 0)) {\n-\t\tprintf(\"Invalid RSS Redirection Table config entered\\n\");\n-\t\treturn;\n+\tp = strchr(p0, '(');\n+\tif (p == NULL)\n+\t\treturn -1;\n+\tp++;\n+\tp0 = strchr(p, ')');\n+\tif (p0 == NULL)\n+\t\treturn -1;\n+\tsize = p0 - p;\n+\tif (size >= sizeof(s)) {\n+\t\tprintf(\"The string size exceeds the internal buffer size\\n\");\n+\t\treturn -1;\n+\t}\n+\tsnprintf(s, sizeof(s), \"%.*s\", size, p);\n+\tret = rte_strsplit(s, sizeof(s), str_fld, num, ',');\n+\tif (ret <= 0 || ret != num) {\n+\t\tprintf(\"The bits of masks do not match the number of \"\n+\t\t\t\t\t\"reta entries: %u\\n\", num);\n+\t\treturn -1;\n \t}\n+\tfor (i = 0; i < ret; i++)\n+\t\tconf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);\n \n-\treta_conf.mask_lo = res->mask_lo;\n-\treta_conf.mask_hi = res->mask_hi;\n+\treturn 0;\n+}\n \n-\tport_rss_reta_info(res->port_id,&reta_conf);\n+static void\n+cmd_showport_reta_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_showport_reta *res = parsed_result;\n+\tstruct rte_eth_rss_reta_entry64 reta_conf[8];\n+\tstruct rte_eth_dev_info dev_info;\n+\n+\tmemset(&dev_info, 0, sizeof(dev_info));\n+\trte_eth_dev_info_get(res->port_id, &dev_info);\n+\tif (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||\n+\t\t\t\tres->size > ETH_RSS_RETA_SIZE_512) {\n+\t\tprintf(\"Invalid redirection table size: %u\\n\", res->size);\n+\t\treturn;\n+\t}\n+\n+\tmemset(reta_conf, 0, sizeof(reta_conf));\n+\tif (showport_parse_reta_config(reta_conf, res->size,\n+\t\t\t\tres->list_of_items) < 0) {\n+\t\tprintf(\"Invalid string: %s for reta masks\\n\",\n+\t\t\t\t\tres->list_of_items);\n+\t\treturn;\n+\t}\n+\tport_rss_reta_info(res->port_id, reta_conf, res->size);\n }\n \n cmdline_parse_token_string_t cmd_showport_reta_show =\n-        TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, \"show\");\n+\tTOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, \"show\");\n cmdline_parse_token_string_t cmd_showport_reta_port =\n-        TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, \"port\");\n+\tTOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, \"port\");\n cmdline_parse_token_num_t cmd_showport_reta_port_id =\n-        TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);\n+\tTOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);\n cmdline_parse_token_string_t cmd_showport_reta_rss =\n-        TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, \"rss\");\n+\tTOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, \"rss\");\n cmdline_parse_token_string_t cmd_showport_reta_reta =\n-        TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, \"reta\");\n-cmdline_parse_token_num_t cmd_showport_reta_mask_lo =\n-        TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);\n-cmdline_parse_token_num_t cmd_showport_reta_mask_hi =\n-\tTOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);\n+\tTOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, \"reta\");\n+cmdline_parse_token_num_t cmd_showport_reta_size =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);\n+cmdline_parse_token_string_t cmd_showport_reta_list_of_items =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_showport_reta,\n+\t\t\t\t\tlist_of_items, NULL);\n \n cmdline_parse_inst_t cmd_showport_reta = {\n \t.f = cmd_showport_reta_parsed,\n \t.data = NULL,\n-\t.help_str = \"show port X rss reta mask_lo mask_hi (X = port number)\\n\\\n-\t\t\t(mask_lo and mask_hi is UINT64)\",\n+\t.help_str = \"show port X rss reta (size) (mask0,mask1,...)\",\n \t.tokens = {\n \t\t(void *)&cmd_showport_reta_show,\n \t\t(void *)&cmd_showport_reta_port,\n \t\t(void *)&cmd_showport_reta_port_id,\n \t\t(void *)&cmd_showport_reta_rss,\n \t\t(void *)&cmd_showport_reta_reta,\n-\t\t(void *)&cmd_showport_reta_mask_lo,\n-\t\t(void *)&cmd_showport_reta_mask_hi,\n+\t\t(void *)&cmd_showport_reta_size,\n+\t\t(void *)&cmd_showport_reta_list_of_items,\n \t\tNULL,\n \t},\n };\ndiff --git a/app/test-pmd/config.c b/app/test-pmd/config.c\nindex c72f6ee..e56320e 100644\n--- a/app/test-pmd/config.c\n+++ b/app/test-pmd/config.c\n@@ -254,6 +254,7 @@ port_infos_display(portid_t port_id)\n \tstruct rte_port *port;\n \tstruct ether_addr mac_addr;\n \tstruct rte_eth_link link;\n+\tstruct rte_eth_dev_info dev_info;\n \tint vlan_offload;\n \tstruct rte_mempool * mp;\n \tstatic const char *info_border = \"*********************\";\n@@ -309,6 +310,11 @@ port_infos_display(portid_t port_id)\n \t\telse\n \t\t\tprintf(\"  qinq(extend) off \\n\");\n \t}\n+\n+\tmemset(&dev_info, 0, sizeof(dev_info));\n+\trte_eth_dev_info_get(port_id, &dev_info);\n+\tif (dev_info.reta_size > 0)\n+\t\tprintf(\"Redirection table size: %u\\n\", dev_info.reta_size);\n }\n \n static int\n@@ -728,36 +734,29 @@ rxtx_config_display(void)\n }\n \n void\n-port_rss_reta_info(portid_t port_id,struct rte_eth_rss_reta *reta_conf)\n+port_rss_reta_info(portid_t port_id,\n+\t\t   struct rte_eth_rss_reta_entry64 *reta_conf,\n+\t\t   uint16_t nb_entries)\n {\n-\tuint8_t i,j;\n+\tuint16_t i, idx, shift;\n \tint ret;\n \n \tif (port_id_is_invalid(port_id))\n \t\treturn;\n \n-\tret = rte_eth_dev_rss_reta_query(port_id, reta_conf);\n+\tret = rte_eth_dev_rss_reta_query(port_id, reta_conf, nb_entries);\n \tif (ret != 0) {\n \t\tprintf(\"Failed to get RSS RETA info, return code = %d\\n\", ret);\n \t\treturn;\n \t}\n \n-\tif (reta_conf->mask_lo != 0) {\n-\t\tfor (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {\n-\t\t\tif (reta_conf->mask_lo & (uint64_t)(1ULL << i))\n-\t\t\t\tprintf(\"RSS RETA configuration: hash index=%d,\"\n-\t\t\t\t\t\"queue=%d\\n\",i,reta_conf->reta[i]);\n-\t\t}\n-\t}\n-\n-\tif (reta_conf->mask_hi != 0) {\n-\t\tfor (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {\n-\t\t\tif(reta_conf->mask_hi & (uint64_t)(1ULL << i)) {\n-\t\t\t\tj = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);\n-\t\t\t\tprintf(\"RSS RETA configuration: hash index=%d,\"\n-\t\t\t\t\t\"queue=%d\\n\",j,reta_conf->reta[j]);\n-\t\t\t}\n-\t\t}\n+\tfor (i = 0; i < nb_entries; i++) {\n+\t\tidx = i / RTE_BIT_WIDTH_64;\n+\t\tshift = i % RTE_BIT_WIDTH_64;\n+\t\tif (!(reta_conf[idx].mask & (1ULL << shift)))\n+\t\t\tcontinue;\n+\t\tprintf(\"RSS RETA configuration: hash index=%u, queue=%u\\n\",\n+\t\t\t\t\ti, reta_conf[idx].reta[shift]);\n \t}\n }\n \ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex ac86bfe..9c033e3 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -530,7 +530,9 @@ void fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id,\n \t\t\t\tstruct rte_fdir_filter *fdir_filter);\n void fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks);\n \n-void port_rss_reta_info(portid_t port_id, struct rte_eth_rss_reta *reta_conf);\n+void port_rss_reta_info(portid_t port_id,\n+\t\t\tstruct rte_eth_rss_reta_entry64 *reta_conf,\n+\t\t\tuint16_t nb_entries);\n \n void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);\n void set_vf_rx_vlan(portid_t port_id, uint16_t vlan_id,\n",
    "prefixes": [
        "dpdk-dev",
        "5/5"
    ]
}