Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-27 Thread Elo, Matias (Nokia - FI/Espoo)
Ping. V2 was already reviewed and tested by Stuart. The only change in v3 was 
the added comment.

-Matias

> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Elo,
> Matias (Nokia - FI/Espoo)
> Sent: Monday, October 26, 2015 12:31 PM
> To: EXT Maxim Uvarov ; lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the
> interface to become active
> 
> 
> > -Original Message-
> > From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT
> Maxim
> > Uvarov
> > Sent: Monday, October 26, 2015 11:42 AM
> > To: lng-odp@lists.linaro.org
> > Subject: Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the
> > interface to become active
> >
> > On 10/22/2015 19:58, Mike Holmes wrote:
> > >
> > >
> > > On 22 October 2015 at 09:12, Stuart Haslam  > > <mailto:stuart.has...@linaro.org>> wrote:
> > >
> > > On Thu, Oct 22, 2015 at 02:40:45PM +0300, Matias Elo wrote:
> > > > Netmap interface takes a few seconds to become active after
> > > > setup. This caused several test applications to fail.
> > > > Check link status at the end of netmap_open() to fix this.
> > > >
> > > > Signed-off-by: Matias Elo  > > <mailto:matias@nokia.com>>
> > >
> > > For both patches
> > >
> > > Reviewed-and-Tested-by: Stuart Haslam  > > <mailto:stuart.has...@linaro.org>>
> > >
> > > > ---
> > > >
> > > > v2:
> > > >   - Rebased to master
> > > >   - The other end of a directly attached loopback cable may come
> > > up after a
> > > > small delay. Sleep once after link is detected to enable
> > > running validation
> > > > tests with directly attached loopback cable. (Stuart Haslam)
> > > >
> > > >  platform/linux-generic/pktio/netmap.c | 20 +---
> > > >  1 file changed, 17 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/platform/linux-generic/pktio/netmap.c
> > > b/platform/linux-generic/pktio/netmap.c
> > > > index ab4667e..0dfe511 100644
> > > > --- a/platform/linux-generic/pktio/netmap.c
> > > > +++ b/platform/linux-generic/pktio/netmap.c
> > > > @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;/** Used
> > > to store the mmap address;
> > > > filled in first time,
> > > used for
> > > >  subsequent calls to nm_open */
> > > >
> > > > +#define NM_OPEN_RETRIES 5
> > > >  #define NM_INJECT_RETRIES 10
> > > >
> > > >  struct dispatch_args {
> > > > @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t
> > > *pktio_entry, unsigned long cmd,
> > > >   pkt_nm->if_flags = (ifr.ifr_flags << 16) |
> > > >   (0x & ifr.ifr_flags);
> > > >   break;
> > > > + case SIOCETHTOOL:
> > > > + if (subcmd == ETHTOOL_GLINK)
> > > > + return !eval.data;
> > > > + break;
> > > >   default:
> > > >   break;
> > > >   }
> > > > @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t
> > > *pktio_entry)
> > > >  {
> > > >   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> > > >
> > > > - if (pkt_nm->desc != NULL)
> > > > + if (pkt_nm->desc != NULL) {
> > > >   nm_close(pkt_nm->desc);
> > > > -
> > > > + mmap_desc.mem = NULL;
> > > > + }
> > > >   if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
> > > >   __odp_errno = errno;
> > > >   ODP_ERR("close(sockfd): %s\n", strerror(errno));
> > > > @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id
> > > ODP_UNUSED, pktio_entry_t *pktio_entry,
> > > >   char ifname[IFNAMSIZ + 7]; /* netmap: */
> > > >   int err;
> > > >  

Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-26 Thread Elo, Matias (Nokia - FI/Espoo)

> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Maxim
> Uvarov
> Sent: Monday, October 26, 2015 11:42 AM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the
> interface to become active
> 
> On 10/22/2015 19:58, Mike Holmes wrote:
> >
> >
> > On 22 October 2015 at 09:12, Stuart Haslam  > <mailto:stuart.has...@linaro.org>> wrote:
> >
> > On Thu, Oct 22, 2015 at 02:40:45PM +0300, Matias Elo wrote:
> > > Netmap interface takes a few seconds to become active after
> > > setup. This caused several test applications to fail.
> > > Check link status at the end of netmap_open() to fix this.
> > >
> > > Signed-off-by: Matias Elo  > <mailto:matias@nokia.com>>
> >
> > For both patches
> >
> > Reviewed-and-Tested-by: Stuart Haslam  > <mailto:stuart.has...@linaro.org>>
> >
> > > ---
> > >
> > > v2:
> > >   - Rebased to master
> > >   - The other end of a directly attached loopback cable may come
> > up after a
> > > small delay. Sleep once after link is detected to enable
> > running validation
> > > tests with directly attached loopback cable. (Stuart Haslam)
> > >
> > >  platform/linux-generic/pktio/netmap.c | 20 +---
> > >  1 file changed, 17 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/platform/linux-generic/pktio/netmap.c
> > b/platform/linux-generic/pktio/netmap.c
> > > index ab4667e..0dfe511 100644
> > > --- a/platform/linux-generic/pktio/netmap.c
> > > +++ b/platform/linux-generic/pktio/netmap.c
> > > @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;/** Used
> > to store the mmap address;
> > > filled in first time,
> > used for
> > >  subsequent calls to nm_open */
> > >
> > > +#define NM_OPEN_RETRIES 5
> > >  #define NM_INJECT_RETRIES 10
> > >
> > >  struct dispatch_args {
> > > @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t
> > *pktio_entry, unsigned long cmd,
> > >   pkt_nm->if_flags = (ifr.ifr_flags << 16) |
> > >   (0x & ifr.ifr_flags);
> > >   break;
> > > + case SIOCETHTOOL:
> > > + if (subcmd == ETHTOOL_GLINK)
> > > + return !eval.data;
> > > + break;
> > >   default:
> > >   break;
> > >   }
> > > @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t
> > *pktio_entry)
> > >  {
> > >   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> > >
> > > - if (pkt_nm->desc != NULL)
> > > + if (pkt_nm->desc != NULL) {
> > >   nm_close(pkt_nm->desc);
> > > -
> > > + mmap_desc.mem = NULL;
> > > + }
> > >   if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
> > >   __odp_errno = errno;
> > >   ODP_ERR("close(sockfd): %s\n", strerror(errno));
> > > @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id
> > ODP_UNUSED, pktio_entry_t *pktio_entry,
> > >   char ifname[IFNAMSIZ + 7]; /* netmap: */
> > >   int err;
> > >   int sockfd;
> > > + int i;
> > >   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> > >
> > >   if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> > > @@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id
> > ODP_UNUSED, pktio_entry_t *pktio_entry,
> > >   if (err)
> > >   goto error;
> > >
> > > - return 0;
> > > + /* Wait for the link to come up */
> > > + for (i = 0; i < NM_OPEN_RETRIES; i++) {
> > > + err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL,
> > ETHTOOL_GLINK);
> >
> >
> > /*
> > When using direct attached loopback cable there may
> > be a small delay until the opposing end's netmap interface comes up.

Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-26 Thread Maxim Uvarov

On 10/22/2015 19:58, Mike Holmes wrote:



On 22 October 2015 at 09:12, Stuart Haslam > wrote:


On Thu, Oct 22, 2015 at 02:40:45PM +0300, Matias Elo wrote:
> Netmap interface takes a few seconds to become active after
> setup. This caused several test applications to fail.
> Check link status at the end of netmap_open() to fix this.
>
> Signed-off-by: Matias Elo mailto:matias@nokia.com>>

For both patches

Reviewed-and-Tested-by: Stuart Haslam mailto:stuart.has...@linaro.org>>

> ---
>
> v2:
>   - Rebased to master
>   - The other end of a directly attached loopback cable may come
up after a
> small delay. Sleep once after link is detected to enable
running validation
> tests with directly attached loopback cable. (Stuart Haslam)
>
>  platform/linux-generic/pktio/netmap.c | 20 +---
>  1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/platform/linux-generic/pktio/netmap.c
b/platform/linux-generic/pktio/netmap.c
> index ab4667e..0dfe511 100644
> --- a/platform/linux-generic/pktio/netmap.c
> +++ b/platform/linux-generic/pktio/netmap.c
> @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;/** Used
to store the mmap address;
> filled in first time,
used for
>  subsequent calls to nm_open */
>
> +#define NM_OPEN_RETRIES 5
>  #define NM_INJECT_RETRIES 10
>
>  struct dispatch_args {
> @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t
*pktio_entry, unsigned long cmd,
>   pkt_nm->if_flags = (ifr.ifr_flags << 16) |
>   (0x & ifr.ifr_flags);
>   break;
> + case SIOCETHTOOL:
> + if (subcmd == ETHTOOL_GLINK)
> + return !eval.data;
> + break;
>   default:
>   break;
>   }
> @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t
*pktio_entry)
>  {
>   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
>
> - if (pkt_nm->desc != NULL)
> + if (pkt_nm->desc != NULL) {
>   nm_close(pkt_nm->desc);
> -
> + mmap_desc.mem = NULL;
> + }
>   if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
>   __odp_errno = errno;
>   ODP_ERR("close(sockfd): %s\n", strerror(errno));
> @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id
ODP_UNUSED, pktio_entry_t *pktio_entry,
>   char ifname[IFNAMSIZ + 7]; /* netmap: */
>   int err;
>   int sockfd;
> + int i;
>   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
>
>   if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> @@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id
ODP_UNUSED, pktio_entry_t *pktio_entry,
>   if (err)
>   goto error;
>
> - return 0;
> + /* Wait for the link to come up */
> + for (i = 0; i < NM_OPEN_RETRIES; i++) {
> + err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL,
ETHTOOL_GLINK);


/*
When using direct attached loopback cable there may
be a small delay until the opposing end's netmap interface comes up. 
In this case without the additional

sleep pktio validation tests fail.
*/

agree, please add note here.

Maxim.


> + sleep(1);
> + if (err == 0)
> + return 0;
> + }
> + ODP_ERR("%s didn't come up\n", pktio_entry->s.name
);
>
>  error:
>   netmap_close(pktio_entry);
> --
> 1.9.1
>
___
lng-odp mailing list
lng-odp@lists.linaro.org 
https://lists.linaro.org/mailman/listinfo/lng-odp




--
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org ***│ *Open source software for ARM SoCs



___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-22 Thread Mike Holmes
On 22 October 2015 at 09:12, Stuart Haslam  wrote:

> On Thu, Oct 22, 2015 at 02:40:45PM +0300, Matias Elo wrote:
> > Netmap interface takes a few seconds to become active after
> > setup. This caused several test applications to fail.
> > Check link status at the end of netmap_open() to fix this.
> >
> > Signed-off-by: Matias Elo 
>
> For both patches
>
> Reviewed-and-Tested-by: Stuart Haslam 
>
> > ---
> >
> > v2:
> >   - Rebased to master
> >   - The other end of a directly attached loopback cable may come up
> after a
> > small delay. Sleep once after link is detected to enable running
> validation
> > tests with directly attached loopback cable. (Stuart Haslam)
> >
> >  platform/linux-generic/pktio/netmap.c | 20 +---
> >  1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/platform/linux-generic/pktio/netmap.c
> b/platform/linux-generic/pktio/netmap.c
> > index ab4667e..0dfe511 100644
> > --- a/platform/linux-generic/pktio/netmap.c
> > +++ b/platform/linux-generic/pktio/netmap.c
> > @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;/** Used to store
> the mmap address;
> > filled in first time, used for
> > subsequent calls to nm_open */
> >
> > +#define NM_OPEN_RETRIES 5
> >  #define NM_INJECT_RETRIES 10
> >
> >  struct dispatch_args {
> > @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t
> *pktio_entry, unsigned long cmd,
> >   pkt_nm->if_flags = (ifr.ifr_flags << 16) |
> >   (0x & ifr.ifr_flags);
> >   break;
> > + case SIOCETHTOOL:
> > + if (subcmd == ETHTOOL_GLINK)
> > + return !eval.data;
> > + break;
> >   default:
> >   break;
> >   }
> > @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
> >  {
> >   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> >
> > - if (pkt_nm->desc != NULL)
> > + if (pkt_nm->desc != NULL) {
> >   nm_close(pkt_nm->desc);
> > -
> > + mmap_desc.mem = NULL;
> > + }
> >   if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
> >   __odp_errno = errno;
> >   ODP_ERR("close(sockfd): %s\n", strerror(errno));
> > @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> >   char ifname[IFNAMSIZ + 7]; /* netmap: */
> >   int err;
> >   int sockfd;
> > + int i;
> >   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> >
> >   if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> > @@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> >   if (err)
> >   goto error;
> >
> > - return 0;
> > + /* Wait for the link to come up */
> > + for (i = 0; i < NM_OPEN_RETRIES; i++) {
> > + err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL,
> ETHTOOL_GLINK);
>

/*
When using direct attached loopback cable there may
be a small delay until the opposing end's netmap interface comes up. In
this case without the additional
sleep pktio validation tests fail.
*/


> > + sleep(1);
> > + if (err == 0)
> > + return 0;
> > + }
> > + ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
> >
> >  error:
> >   netmap_close(pktio_entry);
> > --
> > 1.9.1
> >
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>



-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org  *│ *Open source software for ARM SoCs
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-22 Thread Stuart Haslam
On Thu, Oct 22, 2015 at 02:40:45PM +0300, Matias Elo wrote:
> Netmap interface takes a few seconds to become active after
> setup. This caused several test applications to fail.
> Check link status at the end of netmap_open() to fix this.
> 
> Signed-off-by: Matias Elo 

For both patches

Reviewed-and-Tested-by: Stuart Haslam 

> ---
> 
> v2:
>   - Rebased to master
>   - The other end of a directly attached loopback cable may come up after a
> small delay. Sleep once after link is detected to enable running 
> validation
> tests with directly attached loopback cable. (Stuart Haslam)
> 
>  platform/linux-generic/pktio/netmap.c | 20 +---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/platform/linux-generic/pktio/netmap.c 
> b/platform/linux-generic/pktio/netmap.c
> index ab4667e..0dfe511 100644
> --- a/platform/linux-generic/pktio/netmap.c
> +++ b/platform/linux-generic/pktio/netmap.c
> @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;/** Used to store the 
> mmap address;
> filled in first time, used for
> subsequent calls to nm_open */
>  
> +#define NM_OPEN_RETRIES 5
>  #define NM_INJECT_RETRIES 10
>  
>  struct dispatch_args {
> @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry, 
> unsigned long cmd,
>   pkt_nm->if_flags = (ifr.ifr_flags << 16) |
>   (0x & ifr.ifr_flags);
>   break;
> + case SIOCETHTOOL:
> + if (subcmd == ETHTOOL_GLINK)
> + return !eval.data;
> + break;
>   default:
>   break;
>   }
> @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
>  {
>   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
>  
> - if (pkt_nm->desc != NULL)
> + if (pkt_nm->desc != NULL) {
>   nm_close(pkt_nm->desc);
> -
> + mmap_desc.mem = NULL;
> + }
>   if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
>   __odp_errno = errno;
>   ODP_ERR("close(sockfd): %s\n", strerror(errno));
> @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
> pktio_entry_t *pktio_entry,
>   char ifname[IFNAMSIZ + 7]; /* netmap: */
>   int err;
>   int sockfd;
> + int i;
>   pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
>  
>   if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> @@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
> pktio_entry_t *pktio_entry,
>   if (err)
>   goto error;
>  
> - return 0;
> + /* Wait for the link to come up */
> + for (i = 0; i < NM_OPEN_RETRIES; i++) {
> + err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL, ETHTOOL_GLINK);
> + sleep(1);
> + if (err == 0)
> + return 0;
> + }
> + ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
>  
>  error:
>   netmap_close(pktio_entry);
> -- 
> 1.9.1
> 
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-22 Thread Elo, Matias (Nokia - FI/Espoo)


> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Maxim
> Uvarov
> Sent: Thursday, October 22, 2015 2:49 PM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the
> interface to become active
> 
> On 10/22/2015 14:40, Matias Elo wrote:
> > Netmap interface takes a few seconds to become active after
> > setup. This caused several test applications to fail.
> > Check link status at the end of netmap_open() to fix this.
> >
> > Signed-off-by: Matias Elo 
> > ---
> >
> > v2:
> >- Rebased to master
> >- The other end of a directly attached loopback cable may come up after a
> >  small delay. Sleep once after link is detected to enable running 
> > validation
> >  tests with directly attached loopback cable. (Stuart Haslam)
> >
> >   platform/linux-generic/pktio/netmap.c | 20 +---
> >   1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-
> generic/pktio/netmap.c
> > index ab4667e..0dfe511 100644
> > --- a/platform/linux-generic/pktio/netmap.c
> > +++ b/platform/linux-generic/pktio/netmap.c
> > @@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;  /** Used to store
> the mmap address;
> >   filled in first time, used for
> >   subsequent calls to nm_open */
> >
> > +#define NM_OPEN_RETRIES 5
> >   #define NM_INJECT_RETRIES 10
> >
> >   struct dispatch_args {
> > @@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry,
> unsigned long cmd,
> > pkt_nm->if_flags = (ifr.ifr_flags << 16) |
> > (0x & ifr.ifr_flags);
> > break;
> > +   case SIOCETHTOOL:
> > +   if (subcmd == ETHTOOL_GLINK)
> > +   return !eval.data;
> > +   break;
> > default:
> > break;
> > }
> > @@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
> >   {
> > pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> >
> > -   if (pkt_nm->desc != NULL)
> > +   if (pkt_nm->desc != NULL) {
> > nm_close(pkt_nm->desc);
> > -
> > +   mmap_desc.mem = NULL;
> > +   }
> > if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
> > __odp_errno = errno;
> > ODP_ERR("close(sockfd): %s\n", strerror(errno));
> > @@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> > char ifname[IFNAMSIZ + 7]; /* netmap: */
> > int err;
> > int sockfd;
> > +   int i;
> > pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
> >
> > if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
> > @@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED,
> pktio_entry_t *pktio_entry,
> > if (err)
> > goto error;
> >
> > -   return 0;
> > +   /* Wait for the link to come up */
> > +   for (i = 0; i < NM_OPEN_RETRIES; i++) {
> > +   err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL,
> ETHTOOL_GLINK);
> > +   sleep(1);
> > +   if (err == 0)
> > +   return 0;
> 
> why sleep() is between err check with return?
> 

To sleep once after the link is detected to be up. When using direct attached 
loopback cable there may
be a small delay until the opposing end's netmap interface comes up. In this 
case without the additional
sleep pktio validation tests fail.

-Matias

> Maxim.
> > +   }
> > +   ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
> >
> >   error:
> > netmap_close(pktio_entry);
> 
> ___
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-22 Thread Maxim Uvarov

On 10/22/2015 14:40, Matias Elo wrote:

Netmap interface takes a few seconds to become active after
setup. This caused several test applications to fail.
Check link status at the end of netmap_open() to fix this.

Signed-off-by: Matias Elo 
---

v2:
   - Rebased to master
   - The other end of a directly attached loopback cable may come up after a
 small delay. Sleep once after link is detected to enable running validation
 tests with directly attached loopback cable. (Stuart Haslam)

  platform/linux-generic/pktio/netmap.c | 20 +---
  1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index ab4667e..0dfe511 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;  /** Used to store the 
mmap address;
  filled in first time, used for
  subsequent calls to nm_open */
  
+#define NM_OPEN_RETRIES 5

  #define NM_INJECT_RETRIES 10
  
  struct dispatch_args {

@@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry, 
unsigned long cmd,
pkt_nm->if_flags = (ifr.ifr_flags << 16) |
(0x & ifr.ifr_flags);
break;
+   case SIOCETHTOOL:
+   if (subcmd == ETHTOOL_GLINK)
+   return !eval.data;
+   break;
default:
break;
}
@@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
  {
pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
  
-	if (pkt_nm->desc != NULL)

+   if (pkt_nm->desc != NULL) {
nm_close(pkt_nm->desc);
-
+   mmap_desc.mem = NULL;
+   }
if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
__odp_errno = errno;
ODP_ERR("close(sockfd): %s\n", strerror(errno));
@@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
char ifname[IFNAMSIZ + 7]; /* netmap: */
int err;
int sockfd;
+   int i;
pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
  
  	if (getenv("ODP_PKTIO_DISABLE_NETMAP"))

@@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
if (err)
goto error;
  
-	return 0;

+   /* Wait for the link to come up */
+   for (i = 0; i < NM_OPEN_RETRIES; i++) {
+   err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL, ETHTOOL_GLINK);
+   sleep(1);
+   if (err == 0)
+   return 0;


why sleep() is between err check with return?

Maxim.

+   }
+   ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
  
  error:

netmap_close(pktio_entry);


___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCH v2 1/2] linux-generic: netmap: wait for the interface to become active

2015-10-22 Thread Matias Elo
Netmap interface takes a few seconds to become active after
setup. This caused several test applications to fail.
Check link status at the end of netmap_open() to fix this.

Signed-off-by: Matias Elo 
---

v2:
  - Rebased to master
  - The other end of a directly attached loopback cable may come up after a
small delay. Sleep once after link is detected to enable running validation
tests with directly attached loopback cable. (Stuart Haslam)

 platform/linux-generic/pktio/netmap.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index ab4667e..0dfe511 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -28,6 +28,7 @@ static struct nm_desc mmap_desc;  /** Used to store the 
mmap address;
  filled in first time, used for
  subsequent calls to nm_open */
 
+#define NM_OPEN_RETRIES 5
 #define NM_INJECT_RETRIES 10
 
 struct dispatch_args {
@@ -70,6 +71,10 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry, 
unsigned long cmd,
pkt_nm->if_flags = (ifr.ifr_flags << 16) |
(0x & ifr.ifr_flags);
break;
+   case SIOCETHTOOL:
+   if (subcmd == ETHTOOL_GLINK)
+   return !eval.data;
+   break;
default:
break;
}
@@ -84,9 +89,10 @@ static int netmap_close(pktio_entry_t *pktio_entry)
 {
pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
 
-   if (pkt_nm->desc != NULL)
+   if (pkt_nm->desc != NULL) {
nm_close(pkt_nm->desc);
-
+   mmap_desc.mem = NULL;
+   }
if (pkt_nm->sockfd != -1 && close(pkt_nm->sockfd) != 0) {
__odp_errno = errno;
ODP_ERR("close(sockfd): %s\n", strerror(errno));
@@ -101,6 +107,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
char ifname[IFNAMSIZ + 7]; /* netmap: */
int err;
int sockfd;
+   int i;
pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
 
if (getenv("ODP_PKTIO_DISABLE_NETMAP"))
@@ -155,7 +162,14 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
if (err)
goto error;
 
-   return 0;
+   /* Wait for the link to come up */
+   for (i = 0; i < NM_OPEN_RETRIES; i++) {
+   err = netmap_do_ioctl(pktio_entry, SIOCETHTOOL, ETHTOOL_GLINK);
+   sleep(1);
+   if (err == 0)
+   return 0;
+   }
+   ODP_ERR("%s didn't come up\n", pktio_entry->s.name);
 
 error:
netmap_close(pktio_entry);
-- 
1.9.1

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp