> -----Original Message----- > From: EXT Maxim Uvarov [mailto:maxim.uva...@linaro.org] > Sent: Tuesday, December 29, 2015 12:56 PM > To: Elo, Matias (Nokia - FI/Espoo) <matias....@nokia.com>; lng- > o...@lists.linaro.org > Subject: Re: [lng-odp] [API-NEXT PATCHv2 2/4] helper: define > odph_pktio_wailt_linkup() helper to wait link up > > On 12/29/2015 11:06, Elo, Matias (Nokia - FI/Espoo) wrote: > >> -----Original Message----- > >> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of EXT > Maxim > >> Uvarov > >> Sent: Monday, December 28, 2015 6:40 PM > >> To: lng-odp@lists.linaro.org > >> Subject: [lng-odp] [API-NEXT PATCHv2 2/4] helper: define > >> odph_pktio_wailt_linkup() helper to wait link up > >> > >> Define pktio helper to wait link up after odp_pktio_start(). > >> > >> Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org> > >> --- > >> helper/Makefile.am | 1 + > >> helper/include/odp/helper/pktio.h | 65 > >> +++++++++++++++++++++++++++++++++++++++ > >> 2 files changed, 66 insertions(+) > >> create mode 100644 helper/include/odp/helper/pktio.h > >> > >> diff --git a/helper/Makefile.am b/helper/Makefile.am > >> index 1906ae2..c01f43a 100644 > >> --- a/helper/Makefile.am > >> +++ b/helper/Makefile.am > >> @@ -18,6 +18,7 @@ helperinclude_HEADERS = \ > >> $(srcdir)/include/odp/helper/strong_types.h\ > >> $(srcdir)/include/odp/helper/tcp.h\ > >> $(srcdir)/include/odp/helper/table.h\ > >> + $(srcdir)/include/odp/helper/pktio.h\ > >> $(srcdir)/include/odp/helper/udp.h > >> > >> noinst_HEADERS = \ > >> diff --git a/helper/include/odp/helper/pktio.h > >> b/helper/include/odp/helper/pktio.h > >> new file mode 100644 > >> index 0000000..18e6f94 > >> --- /dev/null > >> +++ b/helper/include/odp/helper/pktio.h > >> @@ -0,0 +1,65 @@ > >> +/* Copyright (c) 2015, Linaro Limited > >> + * All rights reserved. > >> + * > >> + * SPDX-License-Identifier: BSD-3-Clause > >> + */ > >> + > >> +/** > >> + * @file > >> + * > >> + * ODP pktio helper API > >> + * > >> + */ > >> + > >> +#ifndef ODPH_PKTIO_H_ > >> +#define ODPH_PKTIO_H_ > >> + > >> +#ifdef __cplusplus > >> +extern "C" { > >> +#endif > >> + > >> +#include <odp/time.h> > >> +#include <odp/packet_io.h> > >> + > >> +/** time to wait after odp_pktio_start() to bring link up. > >> + * It's is hardware dependent value, here we will have some common > > First letter in capital, remove double 'is'. > > Ok. > > > > >> + * value. > >> + */ > >> +#define _ODPH_PKTIO_LINK_UP_TIME (50 * ODP_TIME_MSEC_IN_NS) > >> + > >> +/** Number of odp_pktio_link_status() calls in time interval. */ > >> +#define _ODPH_PKTIO_LINK_TRIES 5 > >> + > >> +/** > >> + * Wait for pktio link up. > >> + * > >> + * After odp_pktio_link_start(pktio) some platforms need small delay > >> + * to bring up corresponding pktio link. > >> + * > >> + * @param pktio Packet IO handle. > >> + * > >> + * @retval 1 link is up > >> + * @retval 0 link is down > >> + * @retval <0 on failure > >> +*/ > >> +static inline int odph_pktio_wait_linkup(odp_pktio_t pktio) > >> +{ > >> + uint64_t wait_ns = _ODPH_PKTIO_LINK_UP_TIME / > >> _ODPH_PKTIO_LINK_TRIES; > >> + int i; > >> + int ret = -1; > >> + > >> + for (i = 0; i < _ODPH_PKTIO_LINK_TRIES; i++) { > >> + ret = odp_pktio_link_status(pktio); > >> + if (ret < 0 || ret == 1) > >> + return ret; > >> + /* link is down, call status again after delay */ > >> + odp_time_wait_ns(wait_ns); > >> + } > >> + return ret; > >> +} > > I was originally thinking simply adding the helper function to the pktio.c > validation test directly. However, this function could be useful in the pktio > API. In > this case the timeout value should be a function argument (e.g. uint64_t > nanosec) > > I think that each pktio should have it's own link up time. Maybe to > introduce uint64_tt nonosec odp_pktio_link_up_time() or > odp_pktio_conf_link_up_time(). Or odp_pktio_link_status_wait(pktio). I > will send RFC for that so we can discuss.
The link up time depends on the opposing end of the link, so there is no way of knowing how long it will take. Instead of that I would suggest adding a new pktio API call like: int odp_pktio_wait_linkup(odp_pktio_t pktio, uint64_t timeout_ns) > > I did not add it to pktio.c due all tests and examples need that link > wait (like generator, packet and etc.). So I added it to helper assuming > that 50 milliseconds is enough time to wait. That should allow to merge > odp_pktio_link_status() implementation and validation tests. And > wait function can be in separate patch. > > What do you think? As mentioned above I would add the new API call odp_pktio_wait_linkup() and use that in all the tests and examples. This could be done in a separate patch. For this patch set you could move odph_pktio_wait_linkup() functionality to pktio.c as a stopgap until the new API function is available. -Matias > > Maxim. > > >> + > >> +#ifdef __cplusplus > >> +} > >> +#endif > >> + > >> +#endif > >> -- > >> 1.9.1 > >> > >> _______________________________________________ > >> 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