DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/l2fwd-cat: fix build according to API changes
       [not found] <CGME20170829095235eucas1p1c53a2ad6ba980aad25d51dfb6c6b8dd7@eucas1p1.samsung.com>
@ 2017-08-29  9:51 ` Vladimir Kuramshin
       [not found]   ` <CGME20170907114552eucas1p182c484310d70f1d52f64b9ea7fb96ed6@eucas1p1.samsung.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Kuramshin @ 2017-08-29  9:51 UTC (permalink / raw)
  To: tomasz.kantecki; +Cc: dev, Vladimir Kuramshin

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 <v.kuramshin@samsung.com>
---
 examples/l2fwd-cat/Makefile |  5 +---
 examples/l2fwd-cat/cat.c    | 60 ++++++++++++++++++++++-----------------------
 2 files changed, 30 insertions(+), 35 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..4a0a22319 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -53,7 +53,7 @@
 static const struct pqos_cap *m_cap;
 static const struct pqos_cpuinfo *m_cpu;
 static const struct pqos_capability *m_cap_l3ca;
-static unsigned m_sockets[PQOS_MAX_SOCKETS];
+static unsigned *m_sockets;
 static unsigned m_sock_count;
 static struct cat_config m_config[PQOS_MAX_CORES];
 static unsigned m_config_count;
@@ -271,16 +271,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 +353,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 +405,7 @@ check_cpus(void)
 					goto exit;
 				}
 
-				ret = pqos_l3ca_assoc_get(cpu_id, &cos_id);
+				ret = pqos_alloc_assoc_get(cpu_id, &cos_id);
 				if (ret != PQOS_RETVAL_OK) {
 					printf("PQOS: Failed to read COS "
 						"associated to cpu %u.\n",
@@ -512,7 +509,7 @@ 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;
 
-		ret = pqos_l3ca_assoc_get(cpu_id, &cos_id);
+		ret = pqos_alloc_assoc_get(cpu_id, &cos_id);
 		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 +595,10 @@ configure_cat(unsigned cos_id_map[][PQOS_MAX_SOCKETS])
 
 		l3ca.cdp = m_config[i].cdp;
 		if (m_config[i].cdp == 1) {
-			l3ca.code_mask = m_config[i].code_mask;
-			l3ca.data_mask = m_config[i].data_mask;
+			l3ca.u.s.code_mask = m_config[i].code_mask;
+			l3ca.u.s.data_mask = m_config[i].data_mask;
 		} else
-			l3ca.ways_mask = m_config[i].mask;
+			l3ca.u.ways_mask = m_config[i].mask;
 
 		for (j = 0; j < m_sock_count; j++) {
 			phy_pkg_id = m_sockets[j];
@@ -637,7 +634,7 @@ configure_cat(unsigned cos_id_map[][PQOS_MAX_SOCKETS])
 
 			cos_id = cos_id_map[i][phy_pkg_id];
 
-			ret = pqos_l3ca_assoc_set(cpu_id, cos_id);
+			ret = pqos_alloc_assoc_set(cpu_id, cos_id);
 			if (ret != PQOS_RETVAL_OK) {
 				printf("PQOS: Failed to associate COS %u to "
 					"cpu %u\n", cos_id, cpu_id);
@@ -754,24 +751,24 @@ print_cat_config(void)
 			if (tab[n].cdp == 1) {
 				printf("PQOS: COS: %u, cMASK: 0x%llx, "
 					"dMASK: 0x%llx\n", tab[n].class_id,
-					(unsigned long long)tab[n].code_mask,
-					(unsigned long long)tab[n].data_mask);
+					(unsigned long long)tab[n].u.s.code_mask,
+					(unsigned long long)tab[n].u.s.data_mask);
 			} else {
 				printf("PQOS: COS: %u, MASK: 0x%llx\n",
 					tab[n].class_id,
-					(unsigned long long)tab[n].ways_mask);
+					(unsigned long long)tab[n].u.ways_mask);
 			}
 		}
 	}
 
 	for (i = 0; i < m_sock_count; i++) {
-		unsigned lcores[PQOS_MAX_SOCKET_CORES] = {0};
+		unsigned *lcores = NULL;
 		unsigned lcount = 0;
 		unsigned n = 0;
 
-		ret = pqos_cpu_get_cores(m_cpu, m_sockets[i],
-				PQOS_MAX_SOCKET_CORES, &lcount, &lcores[0]);
-		if (ret != PQOS_RETVAL_OK) {
+		lcores = pqos_cpu_get_cores(m_cpu, m_sockets[i],
+				&lcount);
+		if (lcores == NULL || lcount == 0) {
 			printf("PQOS: Error retrieving core information!\n");
 			return;
 		}
@@ -780,13 +777,15 @@ print_cat_config(void)
 		for (n = 0; n < lcount; n++) {
 			unsigned class_id = 0;
 
-			ret = pqos_l3ca_assoc_get(lcores[n], &class_id);
+			ret = pqos_alloc_assoc_get(lcores[n], &class_id);
 			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]);
 		}
+
+		free(lcores);
 	}
 
 }
@@ -849,7 +848,8 @@ cat_fini(void)
 	m_cap = NULL;
 	m_cpu = NULL;
 	m_cap_l3ca = NULL;
-	memset(m_sockets, 0, sizeof(m_sockets));
+	if (m_sockets != NULL)
+		free(m_sockets);
 	m_sock_count = 0;
 	memset(m_config, 0, sizeof(m_config));
 	m_config_count = 0;
@@ -875,7 +875,7 @@ cat_exit(void)
 			if (CPU_ISSET(cpu_id, &m_config[i].cpumask) == 0)
 				continue;
 
-			ret = pqos_l3ca_assoc_set(cpu_id, 0);
+			ret = pqos_alloc_assoc_set(cpu_id, 0);
 			if (ret != PQOS_RETVAL_OK) {
 				printf("PQOS: Failed to associate COS 0 to "
 					"cpu %u\n", cpu_id);
@@ -927,7 +927,6 @@ cat_init(int argc, char **argv)
 	/* PQoS Initialization - Check and initialize CAT capability */
 	cfg.fd_log = STDOUT_FILENO;
 	cfg.verbose = 0;
-	cfg.cdp_cfg = PQOS_REQUIRE_CDP_ANY;
 	ret = pqos_init(&cfg);
 	if (ret != PQOS_RETVAL_OK) {
 		printf("PQOS: Error initializing PQoS library!\n");
@@ -953,9 +952,8 @@ cat_init(int argc, char **argv)
 	}
 
 	/* Get CPU socket information */
-	ret = pqos_cpu_get_sockets(m_cpu, PQOS_MAX_SOCKETS, &m_sock_count,
-		m_sockets);
-	if (ret != PQOS_RETVAL_OK) {
+	m_sockets = pqos_cpu_get_sockets(m_cpu, &m_sock_count);
+	if (m_sockets == NULL) {
 		printf("PQOS: Error retrieving CPU socket information!\n");
 		ret = -EFAULT;
 		goto err;
-- 
2.14.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v2] examples/l2fwd-cat: fix build according to API changes
       [not found]   ` <CGME20170907114552eucas1p182c484310d70f1d52f64b9ea7fb96ed6@eucas1p1.samsung.com>
@ 2017-09-07 11:45     ` Vladimir Kuramshin
  2017-09-18 14:49       ` Bruce Richardson
       [not found]       ` <CGME20170919081803eucas1p255aac78e316693ea52c85e31bbfcc81b@eucas1p2.samsung.com>
  0 siblings, 2 replies; 11+ messages in thread
From: Vladimir Kuramshin @ 2017-09-07 11:45 UTC (permalink / raw)
  To: tomasz.kantecki; +Cc: dev, Vladimir Kuramshin

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 <v.kuramshin@samsung.com>
---
Version 2 changes: fixed checkpatch warnings
"Prefer 'unsigned int *' to bare use of 'unsigned *'"

 examples/l2fwd-cat/Makefile |  5 +---
 examples/l2fwd-cat/cat.c    | 60 ++++++++++++++++++++++-----------------------
 2 files changed, 30 insertions(+), 35 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..6b464bffa 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -53,7 +53,7 @@
 static const struct pqos_cap *m_cap;
 static const struct pqos_cpuinfo *m_cpu;
 static const struct pqos_capability *m_cap_l3ca;
-static unsigned m_sockets[PQOS_MAX_SOCKETS];
+static unsigned int *m_sockets;
 static unsigned m_sock_count;
 static struct cat_config m_config[PQOS_MAX_CORES];
 static unsigned m_config_count;
@@ -271,16 +271,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 +353,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 +405,7 @@ check_cpus(void)
 					goto exit;
 				}
 
-				ret = pqos_l3ca_assoc_get(cpu_id, &cos_id);
+				ret = pqos_alloc_assoc_get(cpu_id, &cos_id);
 				if (ret != PQOS_RETVAL_OK) {
 					printf("PQOS: Failed to read COS "
 						"associated to cpu %u.\n",
@@ -512,7 +509,7 @@ 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;
 
-		ret = pqos_l3ca_assoc_get(cpu_id, &cos_id);
+		ret = pqos_alloc_assoc_get(cpu_id, &cos_id);
 		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 +595,10 @@ configure_cat(unsigned cos_id_map[][PQOS_MAX_SOCKETS])
 
 		l3ca.cdp = m_config[i].cdp;
 		if (m_config[i].cdp == 1) {
-			l3ca.code_mask = m_config[i].code_mask;
-			l3ca.data_mask = m_config[i].data_mask;
+			l3ca.u.s.code_mask = m_config[i].code_mask;
+			l3ca.u.s.data_mask = m_config[i].data_mask;
 		} else
-			l3ca.ways_mask = m_config[i].mask;
+			l3ca.u.ways_mask = m_config[i].mask;
 
 		for (j = 0; j < m_sock_count; j++) {
 			phy_pkg_id = m_sockets[j];
@@ -637,7 +634,7 @@ configure_cat(unsigned cos_id_map[][PQOS_MAX_SOCKETS])
 
 			cos_id = cos_id_map[i][phy_pkg_id];
 
-			ret = pqos_l3ca_assoc_set(cpu_id, cos_id);
+			ret = pqos_alloc_assoc_set(cpu_id, cos_id);
 			if (ret != PQOS_RETVAL_OK) {
 				printf("PQOS: Failed to associate COS %u to "
 					"cpu %u\n", cos_id, cpu_id);
@@ -754,24 +751,24 @@ print_cat_config(void)
 			if (tab[n].cdp == 1) {
 				printf("PQOS: COS: %u, cMASK: 0x%llx, "
 					"dMASK: 0x%llx\n", tab[n].class_id,
-					(unsigned long long)tab[n].code_mask,
-					(unsigned long long)tab[n].data_mask);
+					(unsigned long long)tab[n].u.s.code_mask,
+					(unsigned long long)tab[n].u.s.data_mask);
 			} else {
 				printf("PQOS: COS: %u, MASK: 0x%llx\n",
 					tab[n].class_id,
-					(unsigned long long)tab[n].ways_mask);
+					(unsigned long long)tab[n].u.ways_mask);
 			}
 		}
 	}
 
 	for (i = 0; i < m_sock_count; i++) {
-		unsigned lcores[PQOS_MAX_SOCKET_CORES] = {0};
+		unsigned int *lcores = NULL;
 		unsigned lcount = 0;
 		unsigned n = 0;
 
-		ret = pqos_cpu_get_cores(m_cpu, m_sockets[i],
-				PQOS_MAX_SOCKET_CORES, &lcount, &lcores[0]);
-		if (ret != PQOS_RETVAL_OK) {
+		lcores = pqos_cpu_get_cores(m_cpu, m_sockets[i],
+				&lcount);
+		if (lcores == NULL || lcount == 0) {
 			printf("PQOS: Error retrieving core information!\n");
 			return;
 		}
@@ -780,13 +777,15 @@ print_cat_config(void)
 		for (n = 0; n < lcount; n++) {
 			unsigned class_id = 0;
 
-			ret = pqos_l3ca_assoc_get(lcores[n], &class_id);
+			ret = pqos_alloc_assoc_get(lcores[n], &class_id);
 			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]);
 		}
+
+		free(lcores);
 	}
 
 }
@@ -849,7 +848,8 @@ cat_fini(void)
 	m_cap = NULL;
 	m_cpu = NULL;
 	m_cap_l3ca = NULL;
-	memset(m_sockets, 0, sizeof(m_sockets));
+	if (m_sockets != NULL)
+		free(m_sockets);
 	m_sock_count = 0;
 	memset(m_config, 0, sizeof(m_config));
 	m_config_count = 0;
@@ -875,7 +875,7 @@ cat_exit(void)
 			if (CPU_ISSET(cpu_id, &m_config[i].cpumask) == 0)
 				continue;
 
-			ret = pqos_l3ca_assoc_set(cpu_id, 0);
+			ret = pqos_alloc_assoc_set(cpu_id, 0);
 			if (ret != PQOS_RETVAL_OK) {
 				printf("PQOS: Failed to associate COS 0 to "
 					"cpu %u\n", cpu_id);
@@ -927,7 +927,6 @@ cat_init(int argc, char **argv)
 	/* PQoS Initialization - Check and initialize CAT capability */
 	cfg.fd_log = STDOUT_FILENO;
 	cfg.verbose = 0;
-	cfg.cdp_cfg = PQOS_REQUIRE_CDP_ANY;
 	ret = pqos_init(&cfg);
 	if (ret != PQOS_RETVAL_OK) {
 		printf("PQOS: Error initializing PQoS library!\n");
@@ -953,9 +952,8 @@ cat_init(int argc, char **argv)
 	}
 
 	/* Get CPU socket information */
-	ret = pqos_cpu_get_sockets(m_cpu, PQOS_MAX_SOCKETS, &m_sock_count,
-		m_sockets);
-	if (ret != PQOS_RETVAL_OK) {
+	m_sockets = pqos_cpu_get_sockets(m_cpu, &m_sock_count);
+	if (m_sockets == NULL) {
 		printf("PQOS: Error retrieving CPU socket information!\n");
 		ret = -EFAULT;
 		goto err;
-- 
2.14.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/l2fwd-cat: fix build according to API changes
  2017-09-07 11:45     ` [dpdk-dev] [PATCH v2] " Vladimir Kuramshin
@ 2017-09-18 14:49       ` Bruce Richardson
  2017-09-18 16:07         ` Vladimir Kuramshin
       [not found]       ` <CGME20170919081803eucas1p255aac78e316693ea52c85e31bbfcc81b@eucas1p2.samsung.com>
  1 sibling, 1 reply; 11+ messages in thread
From: Bruce Richardson @ 2017-09-18 14:49 UTC (permalink / raw)
  To: Vladimir Kuramshin; +Cc: tomasz.kantecki, dev

On Thu, Sep 07, 2017 at 02:45:27PM +0300, Vladimir Kuramshin wrote:
> 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 <v.kuramshin@samsung.com>
> ---
> Version 2 changes: fixed checkpatch warnings
> "Prefer 'unsigned int *' to bare use of 'unsigned *'"
> 

I can confirm this at least allows the code to compile with the latest
versions of the pqos library, which is currently broken.

One enhancement might be to put into our code a check for PQOS_VERSION
from pqos.h (which is, interestingly enough, currently at 1.1), to flag
when we have an unsupported version - right now one that is too old.

Otherwise, this is a good fix to have.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/l2fwd-cat: fix build according to API changes
  2017-09-18 14:49       ` Bruce Richardson
@ 2017-09-18 16:07         ` Vladimir Kuramshin
  2017-09-18 16:18           ` Bruce Richardson
  0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Kuramshin @ 2017-09-18 16:07 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: tomasz.kantecki, dev

I agree with you but the problem is that in this case I should also 
change Makefile in order to add version checking there also but I don't 
know how to write correct condition in Makefile that checks if it's 
higher or lower version, e.g. if PQOS_VERSION > 1.3 then ... else ...

If there was some spec file I'd add such checking there but I have 
Makefile only.


Regards,
Vladimir Kuramshin

On 18.09.2017 17:49, Bruce Richardson wrote:
> On Thu, Sep 07, 2017 at 02:45:27PM +0300, Vladimir Kuramshin wrote:
>> 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 <v.kuramshin@samsung.com>
>> ---
>> Version 2 changes: fixed checkpatch warnings
>> "Prefer 'unsigned int *' to bare use of 'unsigned *'"
>>
> I can confirm this at least allows the code to compile with the latest
> versions of the pqos library, which is currently broken.
>
> One enhancement might be to put into our code a check for PQOS_VERSION
> from pqos.h (which is, interestingly enough, currently at 1.1), to flag
> when we have an unsupported version - right now one that is too old.
>
> Otherwise, this is a good fix to have.
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/l2fwd-cat: fix build according to API changes
  2017-09-18 16:07         ` Vladimir Kuramshin
@ 2017-09-18 16:18           ` Bruce Richardson
  0 siblings, 0 replies; 11+ messages in thread
From: Bruce Richardson @ 2017-09-18 16:18 UTC (permalink / raw)
  To: Vladimir Kuramshin; +Cc: tomasz.kantecki, dev

On Mon, Sep 18, 2017 at 07:07:18PM +0300, Vladimir Kuramshin wrote:
> I agree with you but the problem is that in this case I should also change
> Makefile in order to add version checking there also but I don't know how to
> write correct condition in Makefile that checks if it's higher or lower
> version, e.g. if PQOS_VERSION > 1.3 then ... else ...
> 
> If there was some spec file I'd add such checking there but I have Makefile
> only.
> 
> 
> Regards,
> Vladimir Kuramshin
> 
Yes, good point. However, if at least the check was in the C file, if
the build fails, the user can be given a clear message as to why it
fails.
That can be another patch for another day, however.

/Bruce

> On 18.09.2017 17:49, Bruce Richardson wrote:
> > On Thu, Sep 07, 2017 at 02:45:27PM +0300, Vladimir Kuramshin wrote:
> > > 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 <v.kuramshin@samsung.com>
> > > ---
> > > Version 2 changes: fixed checkpatch warnings
> > > "Prefer 'unsigned int *' to bare use of 'unsigned *'"
> > > 
> > I can confirm this at least allows the code to compile with the latest
> > versions of the pqos library, which is currently broken.
> > 
> > One enhancement might be to put into our code a check for PQOS_VERSION
> > from pqos.h (which is, interestingly enough, currently at 1.1), to flag
> > when we have an unsupported version - right now one that is too old.
> > 
> > Otherwise, this is a good fix to have.
> > 
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v3] examples/l2fwd-cat: fix build according to API changes
       [not found]       ` <CGME20170919081803eucas1p255aac78e316693ea52c85e31bbfcc81b@eucas1p2.samsung.com>
@ 2017-09-19  8:17         ` Vladimir Kuramshin
  2017-09-19  8:56           ` Bruce Richardson
       [not found]           ` <CGME20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37@eucas1p1.samsung.com>
  0 siblings, 2 replies; 11+ messages in thread
From: Vladimir Kuramshin @ 2017-09-19  8:17 UTC (permalink / raw)
  To: tomasz.kantecki, bruce.richardson; +Cc: dev, Vladimir Kuramshin

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 <v.kuramshin@samsung.com>
---
 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..9330b2d26 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 <= 10300
 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 <= 10300
 				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 <= 10300
 		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 <= 10300
 			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 <= 10300
 			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 <= 10300
 			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 <= 10300
 					(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 <= 10300
 					(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 <= 10300
 		unsigned lcores[PQOS_MAX_SOCKET_CORES] = {0};
+#else
+		unsigned int *lcores = NULL;
+#endif
 		unsigned lcount = 0;
 		unsigned n = 0;
 
+#if PQOS_VERSION <= 10300
 		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 <= 10300
 			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 > 10300
+		free(lcores);
+#endif
 	}
 
 }
@@ -849,7 +898,12 @@ cat_fini(void)
 	m_cap = NULL;
 	m_cpu = NULL;
 	m_cap_l3ca = NULL;
+#if PQOS_VERSION <= 10300
 	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 <= 10300
 			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 <= 10300
 	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 <= 10300
 	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;
-- 
2.14.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v3] examples/l2fwd-cat: fix build according to API changes
  2017-09-19  8:17         ` [dpdk-dev] [PATCH v3] " Vladimir Kuramshin
@ 2017-09-19  8:56           ` Bruce Richardson
  2017-09-19  9:23             ` Vladimir Kuramshin
       [not found]           ` <CGME20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37@eucas1p1.samsung.com>
  1 sibling, 1 reply; 11+ messages in thread
From: Bruce Richardson @ 2017-09-19  8:56 UTC (permalink / raw)
  To: Vladimir Kuramshin; +Cc: tomasz.kantecki, dev

On Tue, Sep 19, 2017 at 11:17:31AM +0300, Vladimir Kuramshin wrote:
> 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 <v.kuramshin@samsung.com>
> ---
>  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..9330b2d26 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 <= 10300
>  static unsigned m_sockets[PQOS_MAX_SOCKETS];
> +#else
> +static unsigned int *m_sockets;
> +#endif

Does this check work right? The version number in git right now seems to
be just 10100, which would use the "old" path here, despite being latest
code? https://github.com/01org/intel-cmt-cat/blob/master/lib/pqos.h

I will try and follow up with the maintainers of the pqos files, and see
how the version numbers in pqos.h are meant to work.

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v3] examples/l2fwd-cat: fix build according to API changes
  2017-09-19  8:56           ` Bruce Richardson
@ 2017-09-19  9:23             ` Vladimir Kuramshin
  0 siblings, 0 replies; 11+ messages in thread
From: Vladimir Kuramshin @ 2017-09-19  9:23 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: tomasz.kantecki, dev

On 19.09.2017 11:56, Bruce Richardson wrote:
> On Tue, Sep 19, 2017 at 11:17:31AM +0300, Vladimir Kuramshin wrote:
>> 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 <v.kuramshin@samsung.com>
>> ---
>>   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..9330b2d26 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 <= 10300
>>   static unsigned m_sockets[PQOS_MAX_SOCKETS];
>> +#else
>> +static unsigned int *m_sockets;
>> +#endif
> Does this check work right? The version number in git right now seems to
> be just 10100, which would use the "old" path here, despite being latest
> code? https://github.com/01org/intel-cmt-cat/blob/master/lib/pqos.h
>
> I will try and follow up with the maintainers of the pqos files, and see
> how the version numbers in pqos.h are meant to work.
>
> Regards,
> /Bruce
>
Sorry, added redundant zeros. The correct version number should be 103. 
But there is one pitfall in this commit 
6a6d9ef0cae67efe63a394f09fa587b6fc8b1046 but for other case 103 will work.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v4] examples/l2fwd-cat: fix build according to API changes
       [not found]           ` <CGME20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37@eucas1p1.samsung.com>
@ 2017-09-19  9:40             ` Vladimir Kuramshin
  2017-09-19 10:47               ` Bruce Richardson
  0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Kuramshin @ 2017-09-19  9:40 UTC (permalink / raw)
  To: tomasz.kantecki, bruce.richardson; +Cc: dev, Vladimir Kuramshin

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 <v.kuramshin@samsung.com>
---
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;
-- 
2.14.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v4] examples/l2fwd-cat: fix build according to API changes
  2017-09-19  9:40             ` [dpdk-dev] [PATCH v4] " Vladimir Kuramshin
@ 2017-09-19 10:47               ` Bruce Richardson
  2017-10-13 22:28                 ` Thomas Monjalon
  0 siblings, 1 reply; 11+ messages in thread
From: Bruce Richardson @ 2017-09-19 10:47 UTC (permalink / raw)
  To: Vladimir Kuramshin; +Cc: tomasz.kantecki, dev

On Tue, Sep 19, 2017 at 12:40:44PM +0300, Vladimir Kuramshin wrote:
> 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 <v.kuramshin@samsung.com>
> ---
> 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(-)
> 

Confirmed this builds fine with latest version of library from git.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v4] examples/l2fwd-cat: fix build according to API changes
  2017-09-19 10:47               ` Bruce Richardson
@ 2017-10-13 22:28                 ` Thomas Monjalon
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Monjalon @ 2017-10-13 22:28 UTC (permalink / raw)
  To: Vladimir Kuramshin; +Cc: dev, Bruce Richardson, tomasz.kantecki

19/09/2017 12:47, Bruce Richardson:
> On Tue, Sep 19, 2017 at 12:40:44PM +0300, Vladimir Kuramshin wrote:
> > 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 <v.kuramshin@samsung.com>
> > ---
> > 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(-)
> > 
> 
> Confirmed this builds fine with latest version of library from git.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-10-13 22:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170829095235eucas1p1c53a2ad6ba980aad25d51dfb6c6b8dd7@eucas1p1.samsung.com>
2017-08-29  9:51 ` [dpdk-dev] [PATCH] examples/l2fwd-cat: fix build according to API changes Vladimir Kuramshin
     [not found]   ` <CGME20170907114552eucas1p182c484310d70f1d52f64b9ea7fb96ed6@eucas1p1.samsung.com>
2017-09-07 11:45     ` [dpdk-dev] [PATCH v2] " Vladimir Kuramshin
2017-09-18 14:49       ` Bruce Richardson
2017-09-18 16:07         ` Vladimir Kuramshin
2017-09-18 16:18           ` Bruce Richardson
     [not found]       ` <CGME20170919081803eucas1p255aac78e316693ea52c85e31bbfcc81b@eucas1p2.samsung.com>
2017-09-19  8:17         ` [dpdk-dev] [PATCH v3] " Vladimir Kuramshin
2017-09-19  8:56           ` Bruce Richardson
2017-09-19  9:23             ` Vladimir Kuramshin
     [not found]           ` <CGME20170919094052eucas1p12138437b5d1f66086b82c98cd1464e37@eucas1p1.samsung.com>
2017-09-19  9:40             ` [dpdk-dev] [PATCH v4] " Vladimir Kuramshin
2017-09-19 10:47               ` Bruce Richardson
2017-10-13 22:28                 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).