On Thu, Dec 10, 2015 at 06:32:02PM +0300, Ilya Maximets wrote: > 'ODP_WAIT_FOR_NETWORK' environment variable may be used > to wait some time right after pktio_open(). > > Signed-off-by: Ilya Maximets <i.maxim...@samsung.com> > --- > > 'ODP_WAIT_FOR_NETWORK' also may be used to remove sleep(1) > from netmap pktio in the future, beacause IMO waiting > for external network is a work for application and not > for pktio itself.
I agree doing that sort of thing in the pktio itself is a bit nasty [1], but doing it in the application in this way also isn't ideal as it requires pktio specific knowledge (to know to set ODP_WAIT_FOR_NETWORK for tap pktios). Having an unconditional delay wouldn't be great either. The intention has been to have the applications check the link status, once the odp_pktio_link_status() API is available, but presumably that wouldn't help in this case because both links are up but not connected together. Another way around the issue would be to modify the test to have an initial "probe" period, so after opening the interfaces it sends probe packets to check if the interfaces are connected before actually starting the test, with a timeout after a couple of seconds if no packets make it through. This still wouldn't handle netmap's quirk though, as in that case after opening the interfaces both links do come up and the can pass traffic for a short time, then one of the links bounces briefly (at least when using an external loopback cable). Anyway, although I think we may still need some work here, I don't think it's worth holding up this series for, so I'm OK with this going in as it is. 1. https://lists.linaro.org/pipermail/lng-odp/2015-October/016320.html > > test/validation/pktio/pktio.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c > index 53633dd..28bfd30 100644 > --- a/test/validation/pktio/pktio.c > +++ b/test/validation/pktio/pktio.c > @@ -29,6 +29,11 @@ static const char *iface_name[MAX_NUM_IFACES]; > /** number of interfaces being used (1=loopback, 2=pair) */ > static int num_ifaces; > > +/** while testing real-world interfaces additional time may be > + needed for external network to enable link to pktio > + interface that just become up.*/ > +static bool wait_for_network; > + > /** local container for pktio attributes */ > typedef struct { > const char *name; > @@ -252,6 +257,17 @@ static int default_pool_create(void) > return 0; > } > > +static void spin_wait(uint64_t ns) > +{ > + odp_time_t start, now, diff; > + > + start = odp_time_local(); > + do { > + now = odp_time_local(); > + diff = odp_time_diff(now, start); > + } while (odp_time_to_ns(diff) < ns); > +} > + > static odp_pktio_t create_pktio(int iface_idx, odp_pktio_input_mode_t imode, > odp_pktio_output_mode_t omode) > { > @@ -271,6 +287,9 @@ static odp_pktio_t create_pktio(int iface_idx, > odp_pktio_input_mode_t imode, > CU_ASSERT(odp_pktio_to_u64(pktio) != > odp_pktio_to_u64(ODP_PKTIO_INVALID)); > > + if (wait_for_network) > + spin_wait(ODP_TIME_SEC_IN_NS / 4); > + > return pktio; > } > > @@ -1105,11 +1124,16 @@ static int create_pool(const char *iface, int num) > > static int pktio_suite_init(void) > { > + int i; > + > odp_atomic_init_u32(&ip_seq, 0); > + > + if (getenv("ODP_WAIT_FOR_NETWORK")) > + wait_for_network = true; > + > iface_name[0] = getenv("ODP_PKTIO_IF0"); > iface_name[1] = getenv("ODP_PKTIO_IF1"); > num_ifaces = 1; > - int i; > > if (!iface_name[0]) { > printf("No interfaces specified, using default \"loop\".\n"); > -- > 2.1.4 > _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp