From patchwork Tue Sep 19 09:40:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Kuramshin X-Patchwork-Id: 28939 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D071FF94; Tue, 19 Sep 2017 11:40:55 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 1E9DA23B for ; Tue, 19 Sep 2017 11:40:54 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20170919094053euoutp0270957f3ac06777e0d34020ad229a7b6c~luedYXs0a0414504145euoutp02B; Tue, 19 Sep 2017 09:40:53 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170919094053eucas1p110f4b91936bfce248d84337657428847~luecybhkQ1785917859eucas1p1C; Tue, 19 Sep 2017 09:40:53 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 94.4C.12907.426E0C95; Tue, 19 Sep 2017 10:40:52 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37~luecEej4H0421004210eucas1p1Z; Tue, 19 Sep 2017 09:40:52 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-72-59c0e6247b8e Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CE.1F.20118.426E0C95; Tue, 19 Sep 2017 10:40:52 +0100 (BST) Received: from localhost.localdomain ([106.109.129.68]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OWI00MSJTJZOQ90@eusync1.samsung.com>; Tue, 19 Sep 2017 10:40:52 +0100 (BST) From: Vladimir Kuramshin To: tomasz.kantecki@intel.com, bruce.richardson@intel.com Cc: dev@dpdk.org, Vladimir Kuramshin Date: Tue, 19 Sep 2017 12:40:44 +0300 Message-id: <20170919094044.15553-1-v.kuramshin@samsung.com> X-Mailer: git-send-email 2.14.1 In-reply-to: <20170919081731.23970-1-v.kuramshin@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRmVeSWpSXmKPExsWy7djP87oqzw5EGhx6amRxY5W9xbtP25ks pq3+zW5x+uZmdgcWj18LlrJ6LN7zksmjb8sqxgDmKC6blNSczLLUIn27BK6M2+93MxXMsq44 sVKjgXGrXhcjB4eEgIlE72KWLkZOIFNM4sK99WxdjFwcQgJLGSVW7VzGDOF8ZpT48+0PC0zD 8pO8EPFljBJ/b1xhgXD+M0rcmLiSGWQUm4CRxKqN+9lAbBEBS4k1jy8xgdjMAnYStx/OA6sR FvCSWP58ByOIzSKgKvHs0m2wGl4BG4lVR/5DnSQvce7BbbB6TgFbiUtLWtkg4m9ZJZatjoM4 yEXi71p5iLCwxKvjW9ghbBmJy5O7wW6TEOhmlDjbOocVwpnCKLFn2ROoBfYSp25ehTqOT2LS tunMEEN5JTrahCBKPCT+bvoFNdRRYu6hr2C2kMAERolj50MnMEovYGRYxSiSWlqcm55abKRX nJhbXJqXrpecn7uJERhxp/8d/7iD8f0Jq0OMAhyMSjy8Atf2RwqxJpYVV+YeYpTgYFYS4T20 6ECkEG9KYmVValF+fFFpTmrxIUZpDhYlcV7bqLZIIYH0xJLU7NTUgtQimCwTB6dUA+ONhutX Pq6YrrlAPLH7HqfdvuYPizZv8ZjTvFnmkPSjSSsrLyhFiIosrD3tLedp1rHx1DPFF743OAUe ueisn+upKbWm45VR6jT14pkqP4UYHixbWnLwwyftBx0HLi9z56qWiEowNI3UjPLlq/nqtWdy qOwOPlfJjmlSxorTfn3J/13IOnWu1UwlluKMREMt5qLiRADyCSIztAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xy7oqzw5EGpy4L2hxY5W9xbtP25ks pq3+zW5x+uZmdgcWj18LlrJ6LN7zksmjb8sqxgDmKC6blNSczLLUIn27BK6M2+93MxXMsq44 sVKjgXGrXhcjB4eEgInE8pO8XYycQKaYxIV769m6GLk4hASWMEr8XdHGBOE0MkkcOr6JHaSK TcBIYtXG/WwgtoiApcSax5eYQGxmATuJ2w/nMYPYwgJeEsuf72AEsVkEVCWeXboNVsMrYCOx 6sh/Foht8hLnHtwGq+cUsJW4tKQVbKYQUM3jO53sExh5FzAyrGIUSS0tzk3PLTbSK07MLS7N S9dLzs/dxAgMj23Hfm4B2vEu+BCjAAejEg+vwLX9kUKsiWXFlbmHGCU4mJVEeA8tOhApxJuS WFmVWpQfX1Sak1p8iFGag0VJnLd3z+pIIYH0xJLU7NTUgtQimCwTB6dUA6OoYefije9/nlXa f84j60Tj26/5C4o6NkZbPMx9Lxh22GTdPOY3rItvcT9cUb15glnhU+n7ixU+TLkXumz9s+QT OdG1nzK9PCv2JMeeXqh3b1e/ZOwj35zqY0Z/cua9vHBzuqCGtPB/yUMfNqzrmmv4Njrp6UYm m6bbm8Vl11ZIn9uVynJjOXehEktxRqKhFnNRcSIADzihbgsCAAA= X-CMS-MailID: 20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Vladimir_Kuramshin=1BSRR-Virtualization_Lab=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG0V4cGVydCBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Vladimir_Kuramshin=1BSRR-Virtualization_Lab=1B?= =?utf-8?q?Samsung_Electronics=1BExpert_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BCISHQ=1BC10GD01GD010154?= CMS-TYPE: 201P X-CMS-RootMailID: 20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37 X-RootMTR: 20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37 References: <20170919081731.23970-1-v.kuramshin@samsung.com> Subject: [dpdk-dev] [PATCH v4] examples/l2fwd-cat: fix build according to API changes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Current version is compatible with PQOS version 1.3 but not compatible with higher versions. This change makes l2fwd-cat example compatible with versions since 1.4 Signed-off-by: Vladimir Kuramshin Acked-by: Bruce Richardson --- Version 4 changes: Fixed version number - 103 instead of 10300 Version 3 changes: Keep both API versions under #if .. #else .. #endif macro examples/l2fwd-cat/Makefile | 5 +-- examples/l2fwd-cat/cat.c | 85 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 14 deletions(-) diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile index ae921ade6..a7fe6d68e 100644 --- a/examples/l2fwd-cat/Makefile +++ b/examples/l2fwd-cat/Makefile @@ -40,9 +40,6 @@ endif # Default target, can be overridden by command line or environment RTE_TARGET ?= x86_64-native-linuxapp-gcc -# Location of PQoS library and includes, -PQOS_LIBRARY_PATH = $(PQOS_INSTALL_PATH)/libpqos.a - include $(RTE_SDK)/mk/rte.vars.mk # binary name @@ -65,6 +62,6 @@ CFLAGS += -I$(PQOS_INSTALL_PATH)/../include CFLAGS_cat.o := -D_GNU_SOURCE LDLIBS += -L$(PQOS_INSTALL_PATH) -LDLIBS += $(PQOS_LIBRARY_PATH) +LDLIBS += -lpqos include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c index 6133bf5bb..689dcb11f 100644 --- a/examples/l2fwd-cat/cat.c +++ b/examples/l2fwd-cat/cat.c @@ -53,7 +53,11 @@ static const struct pqos_cap *m_cap; static const struct pqos_cpuinfo *m_cpu; static const struct pqos_capability *m_cap_l3ca; +#if PQOS_VERSION <= 103 static unsigned m_sockets[PQOS_MAX_SOCKETS]; +#else +static unsigned int *m_sockets; +#endif static unsigned m_sock_count; static struct cat_config m_config[PQOS_MAX_CORES]; static unsigned m_config_count; @@ -271,16 +275,16 @@ parse_l3ca(const char *l3ca) /* scan the separator '@', ','(next) or '\0'(finish) */ l3ca += strcspn(l3ca, "@,"); - if (*l3ca == '@') { - /* explicit assign cpu_set */ - offset = parse_set(l3ca + 1, &cpuset); - if (offset < 0 || CPU_COUNT(&cpuset) == 0) - goto err; + if (*l3ca != '@') + goto err; - end = l3ca + 1 + offset; - } else + /* explicit assign cpu_set */ + offset = parse_set(l3ca + 1, &cpuset); + if (offset < 0 || CPU_COUNT(&cpuset) == 0) goto err; + end = l3ca + 1 + offset; + if (*end != ',' && *end != '\0') goto err; @@ -353,9 +357,6 @@ parse_l3ca(const char *l3ca) idx++; } while (*end != '\0' && idx < PQOS_MAX_CORES); - if (m_config_count == 0) - goto err; - return 0; err: @@ -408,7 +409,11 @@ check_cpus(void) goto exit; } +#if PQOS_VERSION <= 103 ret = pqos_l3ca_assoc_get(cpu_id, &cos_id); +#else + ret = pqos_alloc_assoc_get(cpu_id, &cos_id); +#endif if (ret != PQOS_RETVAL_OK) { printf("PQOS: Failed to read COS " "associated to cpu %u.\n", @@ -512,7 +517,11 @@ check_and_select_classes(unsigned cos_id_map[][PQOS_MAX_SOCKETS]) for (j = 0; j < m_cpu->num_cores; j++) { cpu_id = m_cpu->cores[j].lcore; +#if PQOS_VERSION <= 103 ret = pqos_l3ca_assoc_get(cpu_id, &cos_id); +#else + ret = pqos_alloc_assoc_get(cpu_id, &cos_id); +#endif if (ret != PQOS_RETVAL_OK) { printf("PQOS: Failed to read COS associated to " "cpu %u on phy_pkg %u.\n", cpu_id, phy_pkg_id); @@ -598,10 +607,19 @@ configure_cat(unsigned cos_id_map[][PQOS_MAX_SOCKETS]) l3ca.cdp = m_config[i].cdp; if (m_config[i].cdp == 1) { +#if PQOS_VERSION <= 103 l3ca.code_mask = m_config[i].code_mask; l3ca.data_mask = m_config[i].data_mask; +#else + l3ca.u.s.code_mask = m_config[i].code_mask; + l3ca.u.s.data_mask = m_config[i].data_mask; +#endif } else +#if PQOS_VERSION <= 103 l3ca.ways_mask = m_config[i].mask; +#else + l3ca.u.ways_mask = m_config[i].mask; +#endif for (j = 0; j < m_sock_count; j++) { phy_pkg_id = m_sockets[j]; @@ -637,7 +655,11 @@ configure_cat(unsigned cos_id_map[][PQOS_MAX_SOCKETS]) cos_id = cos_id_map[i][phy_pkg_id]; +#if PQOS_VERSION <= 103 ret = pqos_l3ca_assoc_set(cpu_id, cos_id); +#else + ret = pqos_alloc_assoc_set(cpu_id, cos_id); +#endif if (ret != PQOS_RETVAL_OK) { printf("PQOS: Failed to associate COS %u to " "cpu %u\n", cos_id, cpu_id); @@ -754,24 +776,43 @@ print_cat_config(void) if (tab[n].cdp == 1) { printf("PQOS: COS: %u, cMASK: 0x%llx, " "dMASK: 0x%llx\n", tab[n].class_id, +#if PQOS_VERSION <= 103 (unsigned long long)tab[n].code_mask, (unsigned long long)tab[n].data_mask); +#else + (unsigned long long)tab[n].u.s.code_mask, + (unsigned long long)tab[n].u.s.data_mask); +#endif } else { printf("PQOS: COS: %u, MASK: 0x%llx\n", tab[n].class_id, +#if PQOS_VERSION <= 103 (unsigned long long)tab[n].ways_mask); +#else + (unsigned long long)tab[n].u.ways_mask); +#endif } } } for (i = 0; i < m_sock_count; i++) { +#if PQOS_VERSION <= 103 unsigned lcores[PQOS_MAX_SOCKET_CORES] = {0}; +#else + unsigned int *lcores = NULL; +#endif unsigned lcount = 0; unsigned n = 0; +#if PQOS_VERSION <= 103 ret = pqos_cpu_get_cores(m_cpu, m_sockets[i], PQOS_MAX_SOCKET_CORES, &lcount, &lcores[0]); if (ret != PQOS_RETVAL_OK) { +#else + lcores = pqos_cpu_get_cores(m_cpu, m_sockets[i], + &lcount); + if (lcores == NULL || lcount == 0) { +#endif printf("PQOS: Error retrieving core information!\n"); return; } @@ -780,13 +821,21 @@ print_cat_config(void) for (n = 0; n < lcount; n++) { unsigned class_id = 0; +#if PQOS_VERSION <= 103 ret = pqos_l3ca_assoc_get(lcores[n], &class_id); +#else + ret = pqos_alloc_assoc_get(lcores[n], &class_id); +#endif if (ret == PQOS_RETVAL_OK) printf("PQOS: CPU: %u, COS: %u\n", lcores[n], class_id); else printf("PQOS: CPU: %u, ERROR\n", lcores[n]); } + +#if PQOS_VERSION > 103 + free(lcores); +#endif } } @@ -849,7 +898,12 @@ cat_fini(void) m_cap = NULL; m_cpu = NULL; m_cap_l3ca = NULL; +#if PQOS_VERSION <= 103 memset(m_sockets, 0, sizeof(m_sockets)); +#else + if (m_sockets != NULL) + free(m_sockets); +#endif m_sock_count = 0; memset(m_config, 0, sizeof(m_config)); m_config_count = 0; @@ -875,7 +929,11 @@ cat_exit(void) if (CPU_ISSET(cpu_id, &m_config[i].cpumask) == 0) continue; +#if PQOS_VERSION <= 103 ret = pqos_l3ca_assoc_set(cpu_id, 0); +#else + ret = pqos_alloc_assoc_set(cpu_id, 0); +#endif if (ret != PQOS_RETVAL_OK) { printf("PQOS: Failed to associate COS 0 to " "cpu %u\n", cpu_id); @@ -927,7 +985,9 @@ cat_init(int argc, char **argv) /* PQoS Initialization - Check and initialize CAT capability */ cfg.fd_log = STDOUT_FILENO; cfg.verbose = 0; +#if PQOS_VERSION <= 103 cfg.cdp_cfg = PQOS_REQUIRE_CDP_ANY; +#endif ret = pqos_init(&cfg); if (ret != PQOS_RETVAL_OK) { printf("PQOS: Error initializing PQoS library!\n"); @@ -953,9 +1013,14 @@ cat_init(int argc, char **argv) } /* Get CPU socket information */ +#if PQOS_VERSION <= 103 ret = pqos_cpu_get_sockets(m_cpu, PQOS_MAX_SOCKETS, &m_sock_count, m_sockets); if (ret != PQOS_RETVAL_OK) { +#else + m_sockets = pqos_cpu_get_sockets(m_cpu, &m_sock_count); + if (m_sockets == NULL) { +#endif printf("PQOS: Error retrieving CPU socket information!\n"); ret = -EFAULT; goto err;