[dpdk-dev] [RFC PATCH 1/4 v2] Adding the common device files for multiple device support
On 13/04/15 21:44, Keith Wiles wrote: > Add the eal_common_device.c and rte_common_device.h and include the > build support changes. > > Signed-off-by: Keith Wiles > --- > lib/librte_eal/bsdapp/eal/Makefile| 1 + > lib/librte_eal/common/Makefile| 1 + > lib/librte_eal/common/eal_common_device.c | 185 ++ > lib/librte_eal/common/include/rte_common_device.h | 674 > ++ > lib/librte_eal/common/include/rte_log.h | 1 + > lib/librte_eal/linuxapp/eal/Makefile | 1 + > lib/librte_kni/rte_kni.c | 4 +- > 7 files changed, 865 insertions(+), 2 deletions(-) > create mode 100644 lib/librte_eal/common/eal_common_device.c > create mode 100644 lib/librte_eal/common/include/rte_common_device.h > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile > b/lib/librte_eal/bsdapp/eal/Makefile > index 2357cfa..7bb2689 100644 > --- a/lib/librte_eal/bsdapp/eal/Makefile > +++ b/lib/librte_eal/bsdapp/eal/Makefile > @@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c > SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c > +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_device.c > > CFLAGS_eal.o := -D_GNU_SOURCE > #CFLAGS_eal_thread.o := -D_GNU_SOURCE > diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile > index 3ea3bbf..c4bf805 100644 > --- a/lib/librte_eal/common/Makefile > +++ b/lib/librte_eal/common/Makefile > @@ -40,6 +40,7 @@ INC += rte_string_fns.h rte_version.h > INC += rte_eal_memconfig.h rte_malloc_heap.h > INC += rte_hexdump.h rte_devargs.h rte_dev.h > INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h > +INC += rte_common_device.h > > ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y) > INC += rte_warnings.h > diff --git a/lib/librte_eal/common/eal_common_device.c > b/lib/librte_eal/common/eal_common_device.c > new file mode 100644 > index 000..a9ef925 > --- /dev/null > +++ b/lib/librte_eal/common/eal_common_device.c > @@ -0,0 +1,185 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > + * Copyright(c) 2014 6WIND S.A. > + * 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 > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "rte_common_device.h" > + > +void * > +rte_dev_add_callback(struct rte_dev_rxtx_callback ** cbp, > + void * fn, void *user_param) > +{ > + struct rte_dev_rxtx_callback *cb; > + > + cb = rte_zmalloc(NULL, sizeof(*cb), 0); > + > + if (cb == NULL) { > + rte_errno = ENOMEM; > + return NULL; > + } > + > + cb->fn.vp = fn; > + cb->param = user_param; > + cb->next = *cbp; > + *cbp = cb; > + return cb; > +} > + > +int > +rte_dev_remove_callback(struct rte_dev_rxtx_callback ** cbp, > + struct rte_dev_rxtx_callback *user_cb) > +{ > + struct rte_dev_rxtx_callback *cb = *cbp; > + struct rte_dev_rxtx_callback *prev_cb; > + > + /* Reset head pointer and remove user cb if first in the list. */ > + if
[dpdk-dev] [RFC PATCH 1/4 v2] Adding the common device files for multiple device support
Hi Marc On 5/4/15, 6:13 AM, "Marc Sune" wrote: > > >On 13/04/15 21:44, Keith Wiles wrote: >> Add the eal_common_device.c and rte_common_device.h and include the >> build support changes. >> >> Signed-off-by: Keith Wiles >> --- >> lib/librte_eal/bsdapp/eal/Makefile| 1 + >> lib/librte_eal/common/Makefile| 1 + >> lib/librte_eal/common/eal_common_device.c | 185 ++ >> lib/librte_eal/common/include/rte_common_device.h | 674 >>++ >> lib/librte_eal/common/include/rte_log.h | 1 + >> lib/librte_eal/linuxapp/eal/Makefile | 1 + >> lib/librte_kni/rte_kni.c | 4 +- >> 7 files changed, 865 insertions(+), 2 deletions(-) >> create mode 100644 lib/librte_eal/common/eal_common_device.c >> create mode 100644 lib/librte_eal/common/include/rte_common_device.h >> >> diff --git a/lib/librte_eal/bsdapp/eal/Makefile >>b/lib/librte_eal/bsdapp/eal/Makefile >> index 2357cfa..7bb2689 100644 >> --- a/lib/librte_eal/bsdapp/eal/Makefile >> +++ b/lib/librte_eal/bsdapp/eal/Makefile >> @@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += >>eal_common_devargs.c >> SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c >> SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c >> SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c >> +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_device.c >> >> CFLAGS_eal.o := -D_GNU_SOURCE >> #CFLAGS_eal_thread.o := -D_GNU_SOURCE >> diff --git a/lib/librte_eal/common/Makefile >>b/lib/librte_eal/common/Makefile >> index 3ea3bbf..c4bf805 100644 >> --- a/lib/librte_eal/common/Makefile >> +++ b/lib/librte_eal/common/Makefile >> @@ -40,6 +40,7 @@ INC += rte_string_fns.h rte_version.h >> INC += rte_eal_memconfig.h rte_malloc_heap.h >> INC += rte_hexdump.h rte_devargs.h rte_dev.h >> INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h >> +INC += rte_common_device.h >> >> ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y) >> INC += rte_warnings.h >> diff --git a/lib/librte_eal/common/eal_common_device.c >>b/lib/librte_eal/common/eal_common_device.c >> new file mode 100644 >> index 000..a9ef925 >> --- /dev/null >> +++ b/lib/librte_eal/common/eal_common_device.c >> @@ -0,0 +1,185 @@ >> +/*- >> + * BSD LICENSE >> + * >> + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. >> + * Copyright(c) 2014 6WIND S.A. >> + * 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 >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "rte_common_device.h" >> + >> +void * >> +rte_dev_add_callback(struct rte_dev_rxtx_callback ** cbp, >> +void * fn, void *user_param) >> +{ >> +struct rte_dev_rxtx_callback *cb; >> + >> +cb = rte_zmalloc(NULL, sizeof(*cb), 0); >> + >> +if (cb == NULL) { >> +rte_errno = ENOMEM; >> +return NULL; >> +} >> + >> +cb->fn.vp = fn; >> +cb->param = user_param; >> +cb->next = *cbp; >> +*cbp = cb; >> +return cb; >> +} >> + >> +int >> +rte_dev_remove_callback(struct rte_dev_rxtx_callback ** cbp, >> +struct rte_dev_rxtx_callback *user_cb) >> +{
[dpdk-dev] [RFC PATCH 1/4 v2] Adding the common device files for multiple device support
Add the eal_common_device.c and rte_common_device.h and include the build support changes. Signed-off-by: Keith Wiles --- lib/librte_eal/bsdapp/eal/Makefile| 1 + lib/librte_eal/common/Makefile| 1 + lib/librte_eal/common/eal_common_device.c | 185 ++ lib/librte_eal/common/include/rte_common_device.h | 674 ++ lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_kni/rte_kni.c | 4 +- 7 files changed, 865 insertions(+), 2 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_device.c create mode 100644 lib/librte_eal/common/include/rte_common_device.h diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 2357cfa..7bb2689 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_device.c CFLAGS_eal.o := -D_GNU_SOURCE #CFLAGS_eal_thread.o := -D_GNU_SOURCE diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index 3ea3bbf..c4bf805 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -40,6 +40,7 @@ INC += rte_string_fns.h rte_version.h INC += rte_eal_memconfig.h rte_malloc_heap.h INC += rte_hexdump.h rte_devargs.h rte_dev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h +INC += rte_common_device.h ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y) INC += rte_warnings.h diff --git a/lib/librte_eal/common/eal_common_device.c b/lib/librte_eal/common/eal_common_device.c new file mode 100644 index 000..a9ef925 --- /dev/null +++ b/lib/librte_eal/common/eal_common_device.c @@ -0,0 +1,185 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2014 6WIND S.A. + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "rte_common_device.h" + +void * +rte_dev_add_callback(struct rte_dev_rxtx_callback ** cbp, + void * fn, void *user_param) +{ + struct rte_dev_rxtx_callback *cb; + + cb = rte_zmalloc(NULL, sizeof(*cb), 0); + + if (cb == NULL) { + rte_errno = ENOMEM; + return NULL; + } + + cb->fn.vp = fn; + cb->param = user_param; + cb->next = *cbp; + *cbp = cb; + return cb; +} + +int +rte_dev_remove_callback(struct rte_dev_rxtx_callback ** cbp, + struct rte_dev_rxtx_callback *user_cb) +{ + struct rte_dev_rxtx_callback *cb = *cbp; + struct rte_dev_rxtx_callback *prev_cb; + + /* Reset head pointer and remove user cb if first in the list. */ + if (cb == user_cb) { + *cbp = user_cb->next; + return 0; + } + + /* Remove the user cb from the callback list. */ + do { + prev_cb = cb; + cb = cb->next; + + if (cb == user_cb) { +