Ping.
> -----Original Message----- > From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT Elo, > Matias (Nokia - FI/Espoo) > Sent: Monday, October 19, 2015 1:32 PM > To: EXT Stuart Haslam <stuart.has...@linaro.org>; Maxim Uvarov > <maxim.uva...@linaro.org> > Cc: lng-odp@lists.linaro.org > Subject: Re: [lng-odp] [PATCH 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 > Stuart > > Haslam > > Sent: Friday, October 16, 2015 8:43 PM > > To: Maxim Uvarov <maxim.uva...@linaro.org> > > Cc: lng-odp@lists.linaro.org > > Subject: Re: [lng-odp] [PATCH 1/2] linux-generic: netmap: wait for the > > interface > > to become active > > > > On Fri, Oct 16, 2015 at 06:59:42PM +0300, Maxim Uvarov wrote: > > > On 10/16/2015 15:45, 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> > > > >--- > > > > 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..0c9ad35 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); > > > >+ if (err == 0) > > > >+ return 0; > > > >+ sleep(1); > > > >+ } > > > >+ ODP_ERR("%s didn't come up\n", pktio_entry->s.name); > > > > > > before usage pktio you need to call odp_pktio_start(). Maybe it's > > > more reasonable on start() check that link is up? > > > > > > Maxim. > > > > > > > The issue is that the nm_open() call puts the interface into netmap > > mode, which makes it drop the link briefly (about 3 seconds in my case). > > > > I suppose it would be marginally better to check the link state before > > the nm_open() call and avoid waiting for it to come up if it wasn't up > > before. This way the error would only be reported if the link had > > unexpectedly failed to come back up, but you'd still be able to open an > > interface whose link was down. > > > > The current implementation is based on the assumption that the netmap_open() > call should not bring the interface up if it was down to begin with (e.g. set > down > using ifconfig). Currently, netmap_open() will always return an error in this > case. > > I'm implementing the start/stop calls next and in that patch I could enable > opening interfaces whose link is down. > > -Matias > > > -- > > Stuart. > > _______________________________________________ > > 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