[dpdk-dev,RFC,v4,3/4] eventtimer: add default software implementation stub

Message ID 1511890808-6072-4-git-send-email-erik.g.carrillo@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues

Commit Message

Carrillo, Erik G Nov. 28, 2017, 5:40 p.m. UTC
  If an eventdev PMD does not wish to provide event timer adapter ops
definitions, the library will fall back to a default software
implementation whose entry points are added by this commit.

Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
---
 lib/librte_eventdev/Makefile                  |   1 +
 lib/librte_eventdev/rte_event_timer_adapter.c |  14 +++
 lib/librte_eventdev/sw_event_timer_adapter.c  | 123 ++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 lib/librte_eventdev/sw_event_timer_adapter.c
  

Comments

Pavan Nikhilesh Nov. 29, 2017, 10:34 a.m. UTC | #1
On Tue, Nov 28, 2017 at 11:40:07AM -0600, Erik Gabriel Carrillo wrote:
> If an eventdev PMD does not wish to provide event timer adapter ops
> definitions, the library will fall back to a default software
> implementation whose entry points are added by this commit.
>

I do agree with having sw driver in lib/librte_eventdev as it doesn't fit
anywhere else, but it seems out of place maybe it would be better to merged
it with rte_event_timer_adapter_driver.h or in rte_event_timer_adapter.c as
done by eth_rx_adapter.

Thoughts?
-Pavan

> Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> ---
>  lib/librte_eventdev/Makefile                  |   1 +
>  lib/librte_eventdev/rte_event_timer_adapter.c |  14 +++
>  lib/librte_eventdev/sw_event_timer_adapter.c  | 123 ++++++++++++++++++++++++++
>  3 files changed, 138 insertions(+)
>  create mode 100644 lib/librte_eventdev/sw_event_timer_adapter.c
  
Carrillo, Erik G Nov. 30, 2017, 11:56 p.m. UTC | #2
Hi Pavan,

Response in-line:

> -----Original Message-----
> From: Pavan Nikhilesh Bhagavatula
> [mailto:pbhagavatula@caviumnetworks.com]
> Sent: Wednesday, November 29, 2017 4:35 AM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: dev@dpdk.org; nipun.gupta@nxp.com; hemant.agrawal@nxp.com; Rao,
> Nikhil <nikhil.rao@intel.com>; jerin.jacobkollanukkaran@cavium.com
> Subject: Re: [RFC PATCH v4 3/4] eventtimer: add default software
> implementation stub
> 
> On Tue, Nov 28, 2017 at 11:40:07AM -0600, Erik Gabriel Carrillo wrote:
> > If an eventdev PMD does not wish to provide event timer adapter ops
> > definitions, the library will fall back to a default software
> > implementation whose entry points are added by this commit.
> >
> 
> I do agree with having sw driver in lib/librte_eventdev as it doesn't fit
> anywhere else, but it seems out of place maybe it would be better to
> merged it with rte_event_timer_adapter_driver.h or in
> rte_event_timer_adapter.c as done by eth_rx_adapter.
> 
> Thoughts?

I had also considered merging the SW driver with rte_event_timer_adapter.c but then thought it would be cleaner to separate it into its own module.  

But I'll make the change so that it's more like the eth rx adapter, and if the file gets too messy when we flesh out the SW driver, we can break it back out.

Thanks,
Gabriel

> -Pavan
> 
> > Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> > ---
> >  lib/librte_eventdev/Makefile                  |   1 +
> >  lib/librte_eventdev/rte_event_timer_adapter.c |  14 +++
> > lib/librte_eventdev/sw_event_timer_adapter.c  | 123
> > ++++++++++++++++++++++++++
> >  3 files changed, 138 insertions(+)
> >  create mode 100644 lib/librte_eventdev/sw_event_timer_adapter.c
  
Pavan Nikhilesh Dec. 1, 2017, 5:15 a.m. UTC | #3
On Thu, Nov 30, 2017 at 11:56:20PM +0000, Carrillo, Erik G wrote:
> Hi Pavan,
>
> Response in-line:
>
> > -----Original Message-----
> > From: Pavan Nikhilesh Bhagavatula
> > [mailto:pbhagavatula@caviumnetworks.com]
> > Sent: Wednesday, November 29, 2017 4:35 AM
> > To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> > Cc: dev@dpdk.org; nipun.gupta@nxp.com; hemant.agrawal@nxp.com; Rao,
> > Nikhil <nikhil.rao@intel.com>; jerin.jacobkollanukkaran@cavium.com
> > Subject: Re: [RFC PATCH v4 3/4] eventtimer: add default software
> > implementation stub
> >
> > On Tue, Nov 28, 2017 at 11:40:07AM -0600, Erik Gabriel Carrillo wrote:
> > > If an eventdev PMD does not wish to provide event timer adapter ops
> > > definitions, the library will fall back to a default software
> > > implementation whose entry points are added by this commit.
> > >
> >
> > I do agree with having sw driver in lib/librte_eventdev as it doesn't fit
> > anywhere else, but it seems out of place maybe it would be better to
> > merged it with rte_event_timer_adapter_driver.h or in
> > rte_event_timer_adapter.c as done by eth_rx_adapter.
> >
> > Thoughts?
>
> I had also considered merging the SW driver with rte_event_timer_adapter.c but then thought it would be cleaner to separate it into its own module.
>
> But I'll make the change so that it's more like the eth rx adapter, and if the file gets too messy when we flesh out the SW driver, we can break it back out.
>
Sounds good to me.

Cheers,
Pavan

> Thanks,
> Gabriel
>
> > -Pavan
> >
> > > Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> > > ---
> > >  lib/librte_eventdev/Makefile                  |   1 +
> > >  lib/librte_eventdev/rte_event_timer_adapter.c |  14 +++
> > > lib/librte_eventdev/sw_event_timer_adapter.c  | 123
> > > ++++++++++++++++++++++++++
> > >  3 files changed, 138 insertions(+)
> > >  create mode 100644 lib/librte_eventdev/sw_event_timer_adapter.c
  

Patch

diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile
index ad1a5db..d5c7cc7 100644
--- a/lib/librte_eventdev/Makefile
+++ b/lib/librte_eventdev/Makefile
@@ -46,6 +46,7 @@  SRCS-y += rte_eventdev.c
 SRCS-y += rte_event_ring.c
 SRCS-y += rte_event_eth_rx_adapter.c
 SRCS-y += rte_event_timer_adapter.c
+SRCS-y += sw_event_timer_adapter.c
 
 # export include files
 SYMLINK-y-include += rte_eventdev.h
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 7708e2b..09dcf0f 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -48,6 +48,8 @@ 
 
 static struct rte_event_timer_adapter adapters[MAX_EVENT_TIMER_ADAPTERS];
 
+extern const struct rte_event_timer_adapter_ops sw_event_adapter_timer_ops;
+
 static inline int
 adapter_valid(const struct rte_event_timer_adapter *adapter)
 {
@@ -207,6 +209,12 @@  rte_event_timer_adapter_create_ext(
 		}
 	}
 
+	/* If eventdev PMD did not provide ops, use default software
+	 * implementation.
+	 */
+	if (adapter->ops == NULL)
+		adapter->ops = &sw_event_adapter_timer_ops;
+
 	/* Allow driver to do some setup */
 	FUNC_PTR_OR_NULL_RET_WITH_ERRNO(adapter->ops->init, -ENOTSUP);
 	ret = adapter->ops->init(adapter);
@@ -313,6 +321,12 @@  rte_event_timer_adapter_lookup(uint16_t adapter_id)
 		return NULL;
 	}
 
+	/* If eventdev PMD did not provide ops, use default software
+	 * implementation.
+	 */
+	if (adapter->ops == NULL)
+		adapter->ops = &sw_event_adapter_timer_ops;
+
 	/* Set fast-path function pointers */
 	adapter->arm_burst = adapter->ops->arm_burst;
 	adapter->arm_tmo_tick_burst = adapter->ops->arm_tmo_tick_burst;
diff --git a/lib/librte_eventdev/sw_event_timer_adapter.c b/lib/librte_eventdev/sw_event_timer_adapter.c
new file mode 100644
index 0000000..43fdad2
--- /dev/null
+++ b/lib/librte_eventdev/sw_event_timer_adapter.c
@@ -0,0 +1,123 @@ 
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "rte_event_timer_adapter.h"
+#include "rte_event_timer_adapter_driver.h"
+
+static int
+sw_event_timer_adapter_init(struct rte_event_timer_adapter *adapter)
+{
+	RTE_SET_USED(adapter);
+
+	return 0;
+}
+
+static int
+sw_event_timer_adapter_uninit(struct rte_event_timer_adapter *adapter)
+{
+	RTE_SET_USED(adapter);
+
+	return 0;
+}
+
+static int
+sw_event_timer_adapter_start(const struct rte_event_timer_adapter *adapter)
+{
+	RTE_SET_USED(adapter);
+
+	return 0;
+}
+
+static int
+sw_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter)
+{
+	RTE_SET_USED(adapter);
+
+	return 0;
+}
+
+static void
+sw_event_timer_adapter_get_info(const struct rte_event_timer_adapter *adapter,
+			struct rte_event_timer_adapter_info *adapter_info)
+{
+	RTE_SET_USED(adapter);
+	RTE_SET_USED(adapter_info);
+}
+
+static int
+sw_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
+			 struct rte_event_timer **evtims,
+			 uint16_t nb_evtims)
+{
+	RTE_SET_USED(adapter);
+	RTE_SET_USED(evtims);
+	RTE_SET_USED(nb_evtims);
+
+	return 0;
+}
+
+static int
+sw_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
+			    struct rte_event_timer **evtims,
+			    uint16_t nb_evtims)
+{
+	RTE_SET_USED(adapter);
+	RTE_SET_USED(evtims);
+	RTE_SET_USED(nb_evtims);
+
+	return 0;
+}
+
+static int
+sw_event_timer_arm_tmo_tick_burst(const struct rte_event_timer_adapter *adapter,
+				  struct rte_event_timer **tims,
+				  uint64_t timeout_tick,
+				  uint16_t nb_tims)
+{
+	RTE_SET_USED(adapter);
+	RTE_SET_USED(tims);
+	RTE_SET_USED(timeout_tick);
+	RTE_SET_USED(nb_tims);
+
+	return 0;
+}
+
+const struct rte_event_timer_adapter_ops sw_event_adapter_timer_ops = {
+	.init = sw_event_timer_adapter_init,
+	.uninit = sw_event_timer_adapter_uninit,
+	.start = sw_event_timer_adapter_start,
+	.stop = sw_event_timer_adapter_stop,
+	.get_info = sw_event_timer_adapter_get_info,
+	.arm_burst = sw_event_timer_arm_burst,
+	.arm_tmo_tick_burst = sw_event_timer_arm_tmo_tick_burst,
+	.cancel_burst = sw_event_timer_cancel_burst,
+};