Skip to contentSkip to conversation

minor fixes and cleanup

PATCH Superseded Bruce Richardson 4 participants 15 messages Feb 21, 2017 – Mar 8, 2017 Crypto API

lore
Share & tools
lore
#0 lore raw

cover minor fixes and cleanup

This patchset contains some minor fixes and improvements which I found in the context of preparing a new patchset for the rte_ring code. Having these merged separately reduces the number of patches in the ring set once I get it finished and so should make everyone's life easier.

Bruce Richardson (4):
app/pdump: fix duplicate macro definition
ring: add a function to return the ring size crypto/null: use ring size function examples/quota_watermark: correct code indentation

 app/pdump/main.c                          |   1 -
 drivers/crypto/null/null_crypto_pmd_ops.c |   2 +-
 examples/quota_watermark/qw/args.c        |  63 ++---
 examples/quota_watermark/qw/init.c        | 177 +++++++-------
 examples/quota_watermark/qw/main.c        | 377 ++++++++++++++++--------------
 examples/quota_watermark/qw/main.h        |   6 +-
 examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
 examples/quota_watermark/qwctl/qwctl.c    |  38 +--
 lib/librte_ring/rte_ring.h                |  14 ++
 9 files changed, 464 insertions(+), 422 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/4 app/pdump: fix duplicate macro definition

RTE_RING_SZ_MASK is redefined here with the original definition in rte_ring.h. Since rte_ring.h is already included, just remove the duplicate definition here.

Fixes caa7028276b8 ("app/pdump: add tool for packet capturing")
---
 app/pdump/main.c | 1 -
 1 file changed, 1 deletion(-)
app/pdump/main.c +0 -1
index f3ef181..b88090d 100644
@@ -92,7 +92,6 @@
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
 
-#define RTE_RING_SZ_MASK  (unsigned)(0x0fffffff) /**< Ring size mask */
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
 
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/4 ring: add a function to return the ring size

In reply to Bruce Richardson

Applications and other libraries should not be reading inside the rte_ring structure directly to get the ring size. Instead add a fn to allow it to be queried.

---
 lib/librte_ring/rte_ring.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
lib/librte_ring/rte_ring.h +14 -0
index e359aff..72ccca5 100644
@@ -1108,6 +1108,20 @@ rte_ring_free_count(const struct rte_ring *r)
 }
 
 /**
+ * Return the size of the ring.
+ *
+ * @param r
+ *   A pointer to the ring structure.
+ * @return
+ *   The number of elements which can be stored in the ring.
+ */
+static inline unsigned int
+rte_ring_get_size(const struct rte_ring *r)
+{
+	return r->prod.size;
+}
+
+/**
  * Dump the status of all rings on the console
  *
  * @param f
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/4 crypto/null: use ring size function

In reply to Bruce Richardson

Rather than reading the size directly from the ring structure, use the dedicated function for that purpose.

---
 drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/null/null_crypto_pmd_ops.c +1 -1
index 26ff631..4a24537 100644
@@ -193,7 +193,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
 
 	r = rte_ring_lookup(qp->name);
 	if (r) {
-		if (r->prod.size >= ring_size) {
+		if (rte_ring_get_size(r) >= ring_size) {
 			NULL_CRYPTO_LOG_INFO(
 				"Reusing existing ring %s for processed packets",
 				qp->name);
Signature · 1 line
2.9.3
#4 lore raw

PATCH 4/4 examples/quota_watermark: correct code indentation

In reply to Bruce Richardson

The code indentation in the example app files used spaces rather than tabs for indentation, and as such did not conform to DPDK conventions. This left those modifying the code in a bind - to fix things on a line by line basis so as to avoid checkpatch errors, or to keep things consistent within the file, and accept checkpatch errors.

Since these files have not had too many changes since the original import, there is little change history to lose by doing a complete reformatting of the code, so just update all indentation to standard. In the process, wrap long lines appropriately, avoiding splitting error messages.

---
 examples/quota_watermark/qw/args.c        |  63 ++---
 examples/quota_watermark/qw/init.c        | 177 +++++++-------
 examples/quota_watermark/qw/main.c        | 377 ++++++++++++++++--------------
 examples/quota_watermark/qw/main.h        |   6 +-
 examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
 examples/quota_watermark/qwctl/qwctl.c    |  38 +--
 6 files changed, 449 insertions(+), 420 deletions(-)
examples/quota_watermark/qw/args.c +33 -30
index 408b54d..6ba77bc 100644
@@ -47,9 +47,9 @@ unsigned int portmask = 0;
 static void
 usage(const char *prgname)
 {
-    fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
-                    "-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
-            prgname);
+	fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
+			"-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
+			prgname);
 }
 
 static unsigned long
@@ -61,44 +61,47 @@ parse_portmask(const char *portmask_str)
 static void
 check_core_count(void)
 {
-    if (rte_lcore_count() < 3)
-        rte_exit(EXIT_FAILURE, "At least 3 cores need to be passed in the coremask\n");
+	if (rte_lcore_count() < 3)
+		rte_exit(EXIT_FAILURE,
+				"At least 3 cores need to be passed in the coremask\n");
 }
 
 static void
 check_portmask_value(unsigned int portmask)
 {
-    unsigned int port_nb = 0;
+	unsigned int port_nb = 0;
 
-    port_nb = __builtin_popcount(portmask);
+	port_nb = __builtin_popcount(portmask);
 
-    if (port_nb == 0)
-        rte_exit(EXIT_FAILURE, "At least 2 ports need to be passed in the portmask\n");
+	if (port_nb == 0)
+		rte_exit(EXIT_FAILURE,
+				"At least 2 ports need to be passed in the portmask\n");
 
-    if (port_nb % 2 != 0)
-        rte_exit(EXIT_FAILURE, "An even number of ports is required in the portmask\n");
+	if (port_nb % 2 != 0)
+		rte_exit(EXIT_FAILURE,
+				"An even number of ports is required in the portmask\n");
 }
 
 int
 parse_qw_args(int argc, char **argv)
 {
-    int opt;
-
-    while ((opt = getopt(argc, argv, "h:p:")) != -1) {
-        switch (opt) {
-        case 'h':
-                usage(argv[0]);
-                break;
-        case 'p':
-                portmask = parse_portmask(optarg);
-                break;
-        default:
-                usage(argv[0]);
-        }
-    }
-
-    check_core_count();
-    check_portmask_value(portmask);
-
-    return 0;
+	int opt;
+
+	while ((opt = getopt(argc, argv, "h:p:")) != -1) {
+		switch (opt) {
+		case 'h':
+			usage(argv[0]);
+			break;
+		case 'p':
+			portmask = parse_portmask(optarg);
+			break;
+		default:
+			usage(argv[0]);
+		}
+	}
+
+	check_core_count();
+	check_portmask_value(portmask);
+
+	return 0;
 }
examples/quota_watermark/qw/init.c +90 -87

214 lines not on this page · raw message

examples/quota_watermark/qw/main.c +196 -181

488 lines not on this page · raw message

examples/quota_watermark/qw/main.h +3 -3
index 6b36489..545ba42 100644
@@ -37,8 +37,8 @@
 #include "../include/conf.h"
 
 enum ring_state {
-    RING_READY,
-    RING_OVERLOADED,
+	RING_READY,
+	RING_OVERLOADED,
 };
 
 extern int *quota;
@@ -53,7 +53,7 @@ extern struct rte_mempool *mbuf_pool;
 static inline int
 is_bit_set(int i, unsigned int mask)
 {
-    return (1 << i) & mask;
+	return (1 << i) & mask;
 }
 
 #endif /* _MAIN_H_ */
examples/quota_watermark/qwctl/commands.c +108 -100

269 lines not on this page · raw message

examples/quota_watermark/qwctl/qwctl.c +19 -19
index 29c501c..3a85cc3 100644
@@ -60,35 +60,35 @@ unsigned int *low_watermark;
 static void
 setup_shared_variables(void)
 {
-    const struct rte_memzone *qw_memzone;
+	const struct rte_memzone *qw_memzone;
 
-    qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
-    if (qw_memzone == NULL)
-        rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
+	qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
+	if (qw_memzone == NULL)
+		rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
 
-    quota = qw_memzone->addr;
-    low_watermark = (unsigned int *) qw_memzone->addr + 1;
+	quota = qw_memzone->addr;
+	low_watermark = (unsigned int *) qw_memzone->addr + 1;
 }
 
 int main(int argc, char **argv)
 {
-    int ret;
-    struct cmdline *cl;
+	int ret;
+	struct cmdline *cl;
 
-    rte_set_log_level(RTE_LOG_INFO);
+	rte_set_log_level(RTE_LOG_INFO);
 
-    ret = rte_eal_init(argc, argv);
-    if (ret < 0)
-        rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
+	ret = rte_eal_init(argc, argv);
+	if (ret < 0)
+		rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
 
-    setup_shared_variables();
+	setup_shared_variables();
 
-    cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
-    if (cl == NULL)
-        rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
+	cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
+	if (cl == NULL)
+		rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
 
-    cmdline_interact(cl);
-    cmdline_stdin_exit(cl);
+	cmdline_interact(cl);
+	cmdline_stdin_exit(cl);
 
-    return 0;
+	return 0;
 }
Signature · 1 line
2.9.3
#14 lore raw

PATCH v2 5/5 examples/quota_watermark: fix requirement for 2M pages

In reply to Bruce Richardson

The sample app was forcing the shared memory block for high/low watermarks to be placed in a memzone on 2M pages. This prevented it from running on systems with just 1G pages, so remove the flag forcing 2M pages.

Fixes 1d6c3ee3321a ("examples/quota_watermark: initial import")
---
 examples/quota_watermark/qw/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/quota_watermark/qw/init.c +1 -1
index e941ce8..95a9f94 100644
@@ -168,7 +168,7 @@ setup_shared_variables(void)
 	const struct rte_memzone *qw_memzone;
 
 	qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME,
-			2 * sizeof(int), rte_socket_id(), RTE_MEMZONE_2MB);
+			2 * sizeof(int), rte_socket_id(), 0);
 	if (qw_memzone == NULL)
 		rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
 
Signature · 1 line
2.9.3
#6 lore raw

v2 cover minor fixes and cleanup

In reply to Bruce Richardson

This patchset contains some minor fixes and improvements which I found in the context of preparing a new patchset for the rte_ring code. Having these merged separately reduces the number of patches in the ring set so should make everyone's life easier.

V2 Changes: new patch added with extra fix for quota_watermark example

Bruce Richardson (5):
app/pdump: fix duplicate macro definition
ring: add a function to return the ring size crypto/null: use ring size function examples/quota_watermark: correct code indentation examples/quota_watermark: fix requirement for 2M pages

 app/pdump/main.c                          |   1 -
 drivers/crypto/null/null_crypto_pmd_ops.c |   2 +-
 examples/quota_watermark/qw/args.c        |  63 ++---
 examples/quota_watermark/qw/init.c        | 177 +++++++-------
 examples/quota_watermark/qw/main.c        | 377 ++++++++++++++++--------------
 examples/quota_watermark/qw/main.h        |   6 +-
 examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
 examples/quota_watermark/qwctl/qwctl.c    |  38 +--
 lib/librte_ring/rte_ring.h                |  14 ++
 9 files changed, 464 insertions(+), 422 deletions(-)
Signature · 1 line
2.9.3
#5 lore raw

PATCH v2 1/5 app/pdump: fix duplicate macro definition

In reply to Bruce Richardson

RTE_RING_SZ_MASK is redefined here with the original definition in rte_ring.h. Since rte_ring.h is already included, just remove the duplicate definition here.

Fixes caa7028276b8 ("app/pdump: add tool for packet capturing")
---
 app/pdump/main.c | 1 -
 1 file changed, 1 deletion(-)
app/pdump/main.c +0 -1
index f3ef181..b88090d 100644
@@ -92,7 +92,6 @@
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
 
-#define RTE_RING_SZ_MASK  (unsigned)(0x0fffffff) /**< Ring size mask */
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
 
Signature · 1 line
2.9.3
#9 lore raw

PATCH v2 2/5 ring: add a function to return the ring size

In reply to Bruce Richardson

Applications and other libraries should not be reading inside the rte_ring structure directly to get the ring size. Instead add a fn to allow it to be queried.

---
 lib/librte_ring/rte_ring.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
lib/librte_ring/rte_ring.h +14 -0
index e359aff..72ccca5 100644
@@ -1108,6 +1108,20 @@ rte_ring_free_count(const struct rte_ring *r)
 }
 
 /**
+ * Return the size of the ring.
+ *
+ * @param r
+ *   A pointer to the ring structure.
+ * @return
+ *   The number of elements which can be stored in the ring.
+ */
+static inline unsigned int
+rte_ring_get_size(const struct rte_ring *r)
+{
+	return r->prod.size;
+}
+
+/**
  * Dump the status of all rings on the console
  *
  * @param f
Signature · 1 line
2.9.3
#11 lore raw

PATCH v2 3/5 crypto/null: use ring size function

In reply to Bruce Richardson

Rather than reading the size directly from the ring structure, use the dedicated function for that purpose.

---
 drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/null/null_crypto_pmd_ops.c +1 -1
index 26ff631..4a24537 100644
@@ -193,7 +193,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
 
 	r = rte_ring_lookup(qp->name);
 	if (r) {
-		if (r->prod.size >= ring_size) {
+		if (rte_ring_get_size(r) >= ring_size) {
 			NULL_CRYPTO_LOG_INFO(
 				"Reusing existing ring %s for processed packets",
 				qp->name);
Signature · 1 line
2.9.3
#13 lore raw

PATCH v2 4/5 examples/quota_watermark: correct code indentation

In reply to Bruce Richardson

The code indentation in the example app files used spaces rather than tabs for indentation, and as such did not conform to DPDK conventions. This left those modifying the code in a bind - to fix things on a line by line basis so as to avoid checkpatch errors, or to keep things consistent within the file, and accept checkpatch errors.

Since these files have not had too many changes since the original import, there is little change history to lose by doing a complete reformatting of the code, so just update all indentation to standard. In the process, wrap long lines appropriately, avoiding splitting error messages.

---
 examples/quota_watermark/qw/args.c        |  63 ++---
 examples/quota_watermark/qw/init.c        | 177 +++++++-------
 examples/quota_watermark/qw/main.c        | 377 ++++++++++++++++--------------
 examples/quota_watermark/qw/main.h        |   6 +-
 examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
 examples/quota_watermark/qwctl/qwctl.c    |  38 +--
 6 files changed, 449 insertions(+), 420 deletions(-)
examples/quota_watermark/qw/args.c +33 -30
index 408b54d..6ba77bc 100644
@@ -47,9 +47,9 @@ unsigned int portmask = 0;
 static void
 usage(const char *prgname)
 {
-    fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
-                    "-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
-            prgname);
+	fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
+			"-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
+			prgname);
 }
 
 static unsigned long
@@ -61,44 +61,47 @@ parse_portmask(const char *portmask_str)
 static void
 check_core_count(void)
 {
-    if (rte_lcore_count() < 3)
-        rte_exit(EXIT_FAILURE, "At least 3 cores need to be passed in the coremask\n");
+	if (rte_lcore_count() < 3)
+		rte_exit(EXIT_FAILURE,
+				"At least 3 cores need to be passed in the coremask\n");
 }
 
 static void
 check_portmask_value(unsigned int portmask)
 {
-    unsigned int port_nb = 0;
+	unsigned int port_nb = 0;
 
-    port_nb = __builtin_popcount(portmask);
+	port_nb = __builtin_popcount(portmask);
 
-    if (port_nb == 0)
-        rte_exit(EXIT_FAILURE, "At least 2 ports need to be passed in the portmask\n");
+	if (port_nb == 0)
+		rte_exit(EXIT_FAILURE,
+				"At least 2 ports need to be passed in the portmask\n");
 
-    if (port_nb % 2 != 0)
-        rte_exit(EXIT_FAILURE, "An even number of ports is required in the portmask\n");
+	if (port_nb % 2 != 0)
+		rte_exit(EXIT_FAILURE,
+				"An even number of ports is required in the portmask\n");
 }
 
 int
 parse_qw_args(int argc, char **argv)
 {
-    int opt;
-
-    while ((opt = getopt(argc, argv, "h:p:")) != -1) {
-        switch (opt) {
-        case 'h':
-                usage(argv[0]);
-                break;
-        case 'p':
-                portmask = parse_portmask(optarg);
-                break;
-        default:
-                usage(argv[0]);
-        }
-    }
-
-    check_core_count();
-    check_portmask_value(portmask);
-
-    return 0;
+	int opt;
+
+	while ((opt = getopt(argc, argv, "h:p:")) != -1) {
+		switch (opt) {
+		case 'h':
+			usage(argv[0]);
+			break;
+		case 'p':
+			portmask = parse_portmask(optarg);
+			break;
+		default:
+			usage(argv[0]);
+		}
+	}
+
+	check_core_count();
+	check_portmask_value(portmask);
+
+	return 0;
 }
examples/quota_watermark/qw/init.c +90 -87

214 lines not on this page · raw message

examples/quota_watermark/qw/main.c +196 -181

488 lines not on this page · raw message

examples/quota_watermark/qw/main.h +3 -3
index 6b36489..545ba42 100644
@@ -37,8 +37,8 @@
 #include "../include/conf.h"
 
 enum ring_state {
-    RING_READY,
-    RING_OVERLOADED,
+	RING_READY,
+	RING_OVERLOADED,
 };
 
 extern int *quota;
@@ -53,7 +53,7 @@ extern struct rte_mempool *mbuf_pool;
 static inline int
 is_bit_set(int i, unsigned int mask)
 {
-    return (1 << i) & mask;
+	return (1 << i) & mask;
 }
 
 #endif /* _MAIN_H_ */
examples/quota_watermark/qwctl/commands.c +108 -100

269 lines not on this page · raw message

examples/quota_watermark/qwctl/qwctl.c +19 -19
index 29c501c..3a85cc3 100644
@@ -60,35 +60,35 @@ unsigned int *low_watermark;
 static void
 setup_shared_variables(void)
 {
-    const struct rte_memzone *qw_memzone;
+	const struct rte_memzone *qw_memzone;
 
-    qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
-    if (qw_memzone == NULL)
-        rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
+	qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
+	if (qw_memzone == NULL)
+		rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
 
-    quota = qw_memzone->addr;
-    low_watermark = (unsigned int *) qw_memzone->addr + 1;
+	quota = qw_memzone->addr;
+	low_watermark = (unsigned int *) qw_memzone->addr + 1;
 }
 
 int main(int argc, char **argv)
 {
-    int ret;
-    struct cmdline *cl;
+	int ret;
+	struct cmdline *cl;
 
-    rte_set_log_level(RTE_LOG_INFO);
+	rte_set_log_level(RTE_LOG_INFO);
 
-    ret = rte_eal_init(argc, argv);
-    if (ret < 0)
-        rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
+	ret = rte_eal_init(argc, argv);
+	if (ret < 0)
+		rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
 
-    setup_shared_variables();
+	setup_shared_variables();
 
-    cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
-    if (cl == NULL)
-        rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
+	cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
+	if (cl == NULL)
+		rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
 
-    cmdline_interact(cl);
-    cmdline_stdin_exit(cl);
+	cmdline_interact(cl);
+	cmdline_stdin_exit(cl);
 
-    return 0;
+	return 0;
 }
Signature · 1 line
2.9.3
#7 lore raw
In reply to Bruce Richardson
Quoted 6 lines · Bruce Richardson

This patchset contains some minor fixes and improvements which I found in the context of preparing a new patchset for the rte_ring code. Having these merged separately reduces the number of patches in the ring set so should make everyone's life easier.

Quoted 9 lines

V2 Changes: new patch added with extra fix for quota_watermark example

Bruce Richardson (5):
app/pdump: fix duplicate macro definition
ring: add a function to return the ring size crypto/null: use ring size function examples/quota_watermark: correct code indentation examples/quota_watermark: fix requirement for 2M pages

Apologies for the threading errors in this email chain. I was unexpectedly using an old version of git for the send-email command. :-(

/Bruce

#8 lore raw
In reply to Bruce Richardson

2017-02-23 16:41, Bruce Richardson:

Quoted 6 lines

This patchset contains some minor fixes and improvements which I found in the context of preparing a new patchset for the rte_ring code. Having these merged separately reduces the number of patches in the ring set so should make everyone's life easier.

Quoted 8 lines

V2 Changes: new patch added with extra fix for quota_watermark example

Bruce Richardson (5):
app/pdump: fix duplicate macro definition
ring: add a function to return the ring size crypto/null: use ring size function examples/quota_watermark: correct code indentation examples/quota_watermark: fix requirement for 2M pages

Applied, thanks