> -----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'. > + * 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). > + > +#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