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

Mauricio Vásquez mauricio.vasquezbernal at studenti.polito.it
Mon Jan 25 18:52:34 UTC 2016


On 25 January 2016 at 10:42, Aaron Conole <aconole at redhat.com> wrote:

> Mauricio Vasquez B <mauricio.vasquezbernal at studenti.polito.it> writes:
>
> > Current implementation allows to support only until the dpdkr255 port,
> > this patch extends it to support the full range of possible dpdkr ports.
>
> I think this commit message is not correct. This patch just extends the
> test.
>
> I was talking about current implementation of this test.


> Also, it's not too big a deal, but you've changed from strtoul to
> strtol, any reason why?
>
>
I was trying to avoid negative port numbers, but I implemented it in a
wrong
way. New version is on the way!


> > Signed-off-by: Mauricio Vasquez B <
> mauricio.vasquezbernal at studenti.polito.it>
> > ---
> >  tests/dpdk/ring_client.c | 43
> ++++++++++++++++++++++++++-----------------
> >  1 file changed, 26 insertions(+), 17 deletions(-)
> >
> > diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c
> > index aeaeaca..9ccec4f 100644
> > --- a/tests/dpdk/ring_client.c
> > +++ b/tests/dpdk/ring_client.c
> > @@ -33,6 +33,9 @@
> >   */
> >
> >  #include <getopt.h>
> > +#include <stdlib.h>
> > +#include <errno.h>
> > +#include <limits.h>
> >
> >  #include <config.h>
> >  #include <rte_config.h>
> > @@ -56,20 +59,18 @@
> >  /* 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 +78,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,7 +97,7 @@ 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)
> > @@ -110,14 +109,24 @@ parse_client_num(const char *client)
> >          return -1;
> >      }
> >
> > -    temp = strtoul(client, &end, BASE_10);
> > +    errno = 0;
> > +    temp = strtol(client, &end, BASE_10);
> > +
> > +    if(errno != 0) {
> > +        return -1;
> > +    }
> > +
> >      /* If valid string argument is provided, terminating '/0' character
> >       * is stored in 'end'. */
> > -    if (end == NULL || *end != '\0') {
> > +    if(end == NULL || *end != '\0' || end == client) {
> > +        return -1;
> > +    }
> > +
> > +    if(temp > UINT_MAX) {
> >          return -1;
> >      }
> >
> > -    client_id = (uint8_t)temp;
> > +    client_id = (unsigned int)temp;
> >      return 0;
> >  }
>


Thank you!



More information about the dev mailing list