diff mbox

[ovs-dev,2/2] tests/dpdk/ring_client: extend range of supported dpdkr ports

Message ID D2F2524F.168FC%diproiettod@vmware.com
State Accepted
Headers show

Commit Message

Daniele Di Proietto Feb. 24, 2016, 2:19 a.m. UTC
Thanks! I applied the following incremental
(minor style fixes) and push this to master




On 23/02/2016 14:06, "dev on behalf of Mauricio Vasquez B"
<dev-bounces@openvswitch.org on behalf of
mauricio.vasquezbernal@studenti.polito.it> wrote:

>Current implementation of the ring_client test only supports until the
>dpdkr255 port, this patch extends it to support the full range of possible
>dpdkr ports.
>
>Signed-off-by: Mauricio Vasquez B
><mauricio.vasquezbernal@studenti.polito.it>
>---
>v3:
>use str_to_uint
> tests/dpdk/ring_client.c | 46
>+++++++++++++++-------------------------------
> 1 file changed, 15 insertions(+), 31 deletions(-)
>
>diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c
>index aeaeaca..089657a 100644
>--- a/tests/dpdk/ring_client.c
>+++ b/tests/dpdk/ring_client.c
>@@ -42,6 +42,8 @@
> #include <rte_ip.h>
> #include <rte_byteorder.h>
> 
>+#include "util.h"
>+
> /* Number of packets to attempt to read from queue. */
> #define PKT_READ_SIZE  ((uint16_t)32)
> 
>@@ -51,25 +53,21 @@
> 
> #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
> 
>-#define BASE_10 10
>-
> /* Our client id number - tells us which rx queue to read, and tx
>  * queue to write to.
>  */
>-static uint8_t client_id = 0;
>+static unsigned int client_id;
> 
> /*
>  * Given the rx queue name template above, get the queue name.
>  */
> static inline const char *
>-get_rx_queue_name(unsigned id)
>+get_rx_queue_name(unsigned int id)
> {
>-    /* Buffer for return value. Size calculated by %u being replaced
>-     * by maximum 3 digits (plus an extra byte for safety).
>-     */
>-    static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2];
>+    /* Buffer for return value. */
>+    static char buffer[RTE_RING_NAMESIZE];
> 
>-    snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_RXQ_NAME, id);
>+    snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id);
>     return buffer;
> }
> 
>@@ -77,14 +75,12 @@ get_rx_queue_name(unsigned id)
>  * Given the tx queue name template above, get the queue name.
>  */
> static inline const char *
>-get_tx_queue_name(unsigned id)
>+get_tx_queue_name(unsigned int id)
> {
>-    /* Buffer for return value. Size calculated by %u being replaced
>-     * by maximum 3 digits (plus an extra byte for safety).
>-     */
>-    static char buffer[sizeof(MP_CLIENT_TXQ_NAME) + 2];
>+    /* Buffer for return value. */
>+    static char buffer[RTE_RING_NAMESIZE];
> 
>-    snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_TXQ_NAME, id);
>+    snprintf(buffer, sizeof(buffer), MP_CLIENT_TXQ_NAME, id);
>     return buffer;
> }
> 
>@@ -98,27 +94,15 @@ usage(const char *progname)
> }
> 
> /*
>- * Convert the client id number from a string to an int.
>+ * Convert the client id number from a string to an usigned int.
>  */
> static int
> parse_client_num(const char *client)
> {
>-    char *end = NULL;
>-    unsigned long temp = 0;
>-
>-    if (client == NULL || *client == '\0') {
>+    if(str_to_uint(client, 10, &client_id))
>+        return 0;
>+     else
>         return -1;
>-    }
>-
>-    temp = strtoul(client, &end, BASE_10);
>-    /* If valid string argument is provided, terminating '/0' character
>-     * is stored in 'end'. */
>-    if (end == NULL || *end != '\0') {
>-        return -1;
>-    }
>-
>-    client_id = (uint8_t)temp;
>-    return 0;
> }
> 
> /*
>-- 
>1.9.1
>
>_______________________________________________
>dev mailing list
>dev@openvswitch.org
>http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c
index 089657a..8a43c64 100644
--- a/tests/dpdk/ring_client.c
+++ b/tests/dpdk/ring_client.c
@@ -99,10 +99,11 @@  usage(const char *progname)
 static int
 parse_client_num(const char *client)
 {
-    if(str_to_uint(client, 10, &client_id))
+    if (str_to_uint(client, 10, &client_id)) {
         return 0;
-     else
+    } else {
         return -1;
+    }
 }
 
 /*