> -----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 <stuart.has...@linaro.org > > <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 <matias....@nokia.com > > <mailto:matias....@nokia.com>> > > > > For both patches > > > > Reviewed-and-Tested-by: Stuart Haslam <stuart.has...@linaro.org > > <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) | > > > (0xffff & 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:<ifname> */ > > > 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.
V3 with the aforesaid comment is already sent. -Matias > > > > + sleep(1); > > > + if (err == 0) > > > + return 0; > > > + } > > > + ODP_ERR("%s didn't come up\n", pktio_entry->s.name > > <http://s.name>); > > > > > > error: > > > netmap_close(pktio_entry); > > > -- > > > 1.9.1 > > > > > _______________________________________________ > > lng-odp mailing list > > lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> > > https://lists.linaro.org/mailman/listinfo/lng-odp > > > > > > > > > > -- > > Mike Holmes > > Technical Manager - Linaro Networking Group > > Linaro.org <http://www.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 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp