[v2,1/4] raw/common: add multi-function interface
Checks
Commit Message
The multi-function interface provides a flexible and extensible
way of combining one or more packet processing functions into a
single operation. The interface can be used by applications to
send the combined operations to a optimized software or hardware
accelerator via a raw device.
Signed-off-by: David Coyle <david.coyle@intel.com>
Signed-off-by: Mairtin o Loingsigh <mairtin.oloingsigh@intel.com>
---
In particular, looking for feedback on the meson script changes
that were required to build the drivers/raw/common/multi_fn
directory. Thank you.
config/common_base | 5 +
drivers/meson.build | 5 +
drivers/raw/Makefile | 1 +
drivers/raw/common/Makefile | 8 +
drivers/raw/common/meson.build | 7 +
drivers/raw/common/multi_fn/Makefile | 27 ++
drivers/raw/common/multi_fn/meson.build | 9 +
.../multi_fn/rte_common_multi_fn_version.map | 11 +
drivers/raw/common/multi_fn/rte_multi_fn.c | 166 +++++++++
drivers/raw/common/multi_fn/rte_multi_fn.h | 350 ++++++++++++++++++
.../raw/common/multi_fn/rte_multi_fn_driver.h | 55 +++
meson.build | 4 +
mk/rte.app.mk | 1 +
13 files changed, 649 insertions(+)
create mode 100644 drivers/raw/common/Makefile
create mode 100644 drivers/raw/common/meson.build
create mode 100644 drivers/raw/common/multi_fn/Makefile
create mode 100644 drivers/raw/common/multi_fn/meson.build
create mode 100644 drivers/raw/common/multi_fn/rte_common_multi_fn_version.map
create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn.c
create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn.h
create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn_driver.h
Comments
Hi David,
> -----Original Message-----
> From: Coyle, David <david.coyle@intel.com>
> Sent: Friday, April 3, 2020 5:37 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Ryan, Brendan <brendan.ryan@intel.com>;
> shreyansh.jain@nxp.com; hemant.agrawal@nxp.com; Coyle, David
> <david.coyle@intel.com>; O'loingsigh, Mairtin <mairtin.oloingsigh@intel.com>
> Subject: [PATCH v2 1/4] raw/common: add multi-function interface
>
> The multi-function interface provides a flexible and extensible way of combining
> one or more packet processing functions into a single operation. The interface
> can be used by applications to send the combined operations to a optimized
> software or hardware accelerator via a raw device.
>
> Signed-off-by: David Coyle <david.coyle@intel.com>
> Signed-off-by: Mairtin o Loingsigh <mairtin.oloingsigh@intel.com>
> ---
>
> In particular, looking for feedback on the meson script changes that were
> required to build the drivers/raw/common/multi_fn directory. Thank you.
>
> config/common_base | 5 +
> drivers/meson.build | 5 +
> drivers/raw/Makefile | 1 +
> drivers/raw/common/Makefile | 8 +
> drivers/raw/common/meson.build | 7 +
> drivers/raw/common/multi_fn/Makefile | 27 ++
> drivers/raw/common/multi_fn/meson.build | 9 +
> .../multi_fn/rte_common_multi_fn_version.map | 11 +
> drivers/raw/common/multi_fn/rte_multi_fn.c | 166 +++++++++
> drivers/raw/common/multi_fn/rte_multi_fn.h | 350 ++++++++++++++++++
> .../raw/common/multi_fn/rte_multi_fn_driver.h | 55 +++
> meson.build | 4 +
> mk/rte.app.mk | 1 +
> 13 files changed, 649 insertions(+)
> create mode 100644 drivers/raw/common/Makefile create mode 100644
> drivers/raw/common/meson.build create mode 100644
> drivers/raw/common/multi_fn/Makefile
> create mode 100644 drivers/raw/common/multi_fn/meson.build
> create mode 100644
> drivers/raw/common/multi_fn/rte_common_multi_fn_version.map
> create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn.c
> create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn.h
> create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn_driver.h
>
> diff --git a/config/common_base b/config/common_base index
> c31175f9d..4f004968b 100644
> --- a/config/common_base
> +++ b/config/common_base
> @@ -818,6 +818,11 @@
> CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV=y
> #
> CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV=y
>
> +#
> +# Compile multi-fn raw device interface #
> +CONFIG_RTE_LIBRTE_MULTI_FN_COMMON=n
This can be enabled by default, right? It doesn't have any external dependency.
...
> +++ b/drivers/raw/common/multi_fn/rte_common_multi_fn_version.map
> @@ -0,0 +1,11 @@
> +EXPERIMENTAL {
> + global:
> +
> + rte_multi_fn_session_create;
> + rte_multi_fn_session_destroy;
> + rte_multi_fn_op_pool_create;
> + rte_multi_fn_op_bulk_alloc;
> + rte_multi_fn_op_free;
This list should be sorted alphabetically.
> +
> + local: *;
> +};
> diff --git a/drivers/raw/common/multi_fn/rte_multi_fn.c
> b/drivers/raw/common/multi_fn/rte_multi_fn.c
> new file mode 100644
> index 000000000..4f8e7fd94
> --- /dev/null
> +++ b/drivers/raw/common/multi_fn/rte_multi_fn.c
> @@ -0,0 +1,166 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Intel Corporation.
> + */
> +
> +#include <ctype.h>
> +#include <stdio.h>
...
> +#include <rte_rawdev.h>
A bunch of these includes are not needed.
From what I could see, only <inttypes.h>, <rte_log.h>, <rte_common.h>,
<rte_rawdev.h> and <rte_mempool.h> are needed, apart from the two below.
> +
> +#include "rte_multi_fn_driver.h"
> +#include "rte_multi_fn.h"
...
> +++ b/drivers/raw/common/multi_fn/rte_multi_fn.h
> @@ -0,0 +1,350 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Intel Corporation.
> + */
> +
> +#ifndef _RTE_MULTI_FN_H_
> +#define _RTE_MULTI_FN_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include <rte_compat.h>
> +#include <rte_common.h>
> +#include <rte_mbuf.h>
> +#include <rte_memory.h>
> +#include <rte_mempool.h>
> +#include <rte_comp.h>
> +#include <rte_crypto.h>
> +#include <rte_rawdev.h>
Only <rte_comp.h> and <rte_crypto.h> are needed.
> +
...
> +__rte_experimental
> +static inline void
This is a public API, so I'd say this shouldn't be inline, right?
> +rte_multi_fn_op_free(struct rte_multi_fn_op *op) {
> + if (op != NULL && op->mempool != NULL)
> + rte_mempool_put(op->mempool, op);
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _RTE_MULTI_FN_H_ */
> diff --git a/drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> b/drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> new file mode 100644
> index 000000000..7e1e57fa3
> --- /dev/null
> +++ b/drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> @@ -0,0 +1,55 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Intel Corporation.
> + */
> +
> +#ifndef _RTE_MULTI_FN_DRIVER_H_
> +#define _RTE_MULTI_FN_DRIVER_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include <rte_compat.h>
> +#include <rte_common.h>
> +#include <rte_rawdev.h>
> +#include <rte_multi_fn.h>
> +
Only <rte_rawdev.h> and <rte_multi_fn.h> are needed.
Actually, since rte_multi_fn.h is in the same folder, you can use double quotes.
Hi David,
> -----Original Message-----
> From: Coyle, David <david.coyle@intel.com>
> Sent: Friday, April 3, 2020 5:37 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Ryan, Brendan <brendan.ryan@intel.com>;
> shreyansh.jain@nxp.com; hemant.agrawal@nxp.com; Coyle, David
> <david.coyle@intel.com>; O'loingsigh, Mairtin <mairtin.oloingsigh@intel.com>
> Subject: [PATCH v2 1/4] raw/common: add multi-function interface
>
> The multi-function interface provides a flexible and extensible way of combining
> one or more packet processing functions into a single operation. The interface
> can be used by applications to send the combined operations to a optimized
> software or hardware accelerator via a raw device.
>
> Signed-off-by: David Coyle <david.coyle@intel.com>
> Signed-off-by: Mairtin o Loingsigh <mairtin.oloingsigh@intel.com>
> ---
>
Forgot to say to update Release Notes document, which these changes.
Thanks!
Pablo
Hi Pablo
Thank you for reviewing and the comments - see below for resolutions.
The changes will be available in v3 shortly
David
> -----Original Message-----
> From: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Sent: Monday, April 6, 2020 5:09 PM
>
> Hi David,
>
> > -----Original Message-----
> > From: Coyle, David <david.coyle@intel.com>
> > Sent: Friday, April 3, 2020 5:37 PM
> >
> > The multi-function interface provides a flexible and extensible way of
> > combining one or more packet processing functions into a single
> > operation. The interface can be used by applications to send the
> > combined operations to a optimized software or hardware accelerator via a
> raw device.
> >
> > Signed-off-by: David Coyle <david.coyle@intel.com>
> > Signed-off-by: Mairtin o Loingsigh <mairtin.oloingsigh@intel.com>
> > ---
> >
> > In particular, looking for feedback on the meson script changes that
> > were required to build the drivers/raw/common/multi_fn directory. Thank
> you.
> >
> > config/common_base | 5 +
> > drivers/meson.build | 5 +
> > drivers/raw/Makefile | 1 +
> > drivers/raw/common/Makefile | 8 +
> > drivers/raw/common/meson.build | 7 +
> > drivers/raw/common/multi_fn/Makefile | 27 ++
> > drivers/raw/common/multi_fn/meson.build | 9 +
> > .../multi_fn/rte_common_multi_fn_version.map | 11 +
> > drivers/raw/common/multi_fn/rte_multi_fn.c | 166 +++++++++
> > drivers/raw/common/multi_fn/rte_multi_fn.h | 350
> ++++++++++++++++++
> > .../raw/common/multi_fn/rte_multi_fn_driver.h | 55 +++
> > meson.build | 4 +
> > mk/rte.app.mk | 1 +
> > 13 files changed, 649 insertions(+)
> > create mode 100644 drivers/raw/common/Makefile create mode 100644
> > drivers/raw/common/meson.build create mode 100644
> > drivers/raw/common/multi_fn/Makefile
> > create mode 100644 drivers/raw/common/multi_fn/meson.build
> > create mode 100644
> > drivers/raw/common/multi_fn/rte_common_multi_fn_version.map
> > create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn.c
> > create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn.h
> > create mode 100644 drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> >
> > diff --git a/config/common_base b/config/common_base index
> > c31175f9d..4f004968b 100644
> > --- a/config/common_base
> > +++ b/config/common_base
> > @@ -818,6 +818,11 @@
> > CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV=y
> > #
> > CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV=y
> >
> > +#
> > +# Compile multi-fn raw device interface #
> > +CONFIG_RTE_LIBRTE_MULTI_FN_COMMON=n
>
> This can be enabled by default, right? It doesn't have any external
> dependency.
[DC] That is true, so yes this is now enabled by default
>
> ...
>
> > +++
> b/drivers/raw/common/multi_fn/rte_common_multi_fn_version.map
> > @@ -0,0 +1,11 @@
> > +EXPERIMENTAL {
> > + global:
> > +
> > + rte_multi_fn_session_create;
> > + rte_multi_fn_session_destroy;
> > + rte_multi_fn_op_pool_create;
> > + rte_multi_fn_op_bulk_alloc;
> > + rte_multi_fn_op_free;
>
> This list should be sorted alphabetically.
[DC] Fixed
>
> > +
> > + local: *;
> > +};
> > diff --git a/drivers/raw/common/multi_fn/rte_multi_fn.c
> > b/drivers/raw/common/multi_fn/rte_multi_fn.c
> > new file mode 100644
> > index 000000000..4f8e7fd94
> > --- /dev/null
> > +++ b/drivers/raw/common/multi_fn/rte_multi_fn.c
> > @@ -0,0 +1,166 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2020 Intel Corporation.
> > + */
> > +
> > +#include <ctype.h>
> > +#include <stdio.h>
>
> ...
>
> > +#include <rte_rawdev.h>
>
> A bunch of these includes are not needed.
> From what I could see, only <inttypes.h>, <rte_log.h>, <rte_common.h>,
> <rte_rawdev.h> and <rte_mempool.h> are needed, apart from the two
> below.
[DC] Most of the includes weren't needed... these have been tidied up now
>
>
> > +
> > +#include "rte_multi_fn_driver.h"
> > +#include "rte_multi_fn.h"
>
> ...
>
> > +++ b/drivers/raw/common/multi_fn/rte_multi_fn.h
> > @@ -0,0 +1,350 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2020 Intel Corporation.
> > + */
> > +
> > +#ifndef _RTE_MULTI_FN_H_
> > +#define _RTE_MULTI_FN_H_
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#include <rte_compat.h>
> > +#include <rte_common.h>
> > +#include <rte_mbuf.h>
> > +#include <rte_memory.h>
> > +#include <rte_mempool.h>
> > +#include <rte_comp.h>
> > +#include <rte_crypto.h>
> > +#include <rte_rawdev.h>
>
> Only <rte_comp.h> and <rte_crypto.h> are needed.
[DC] Again includes have been tidied up... left common, mbuf, mempool and crypto as these are referenced directly in this file
rte_comp.h has been removed as he have removed compression completely from this patchset
>
> > +
>
> ...
>
> > +__rte_experimental
> > +static inline void
>
> This is a public API, so I'd say this shouldn't be inline, right?
[DC] Lots of example of public APIs being inline, so no issue here
>
> > +rte_multi_fn_op_free(struct rte_multi_fn_op *op) {
> > + if (op != NULL && op->mempool != NULL)
> > + rte_mempool_put(op->mempool, op);
> > +}
> > +
> > +#ifdef __cplusplus
> > +}
> > +#endif
> > +
> > +#endif /* _RTE_MULTI_FN_H_ */
> > diff --git a/drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> > b/drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> > new file mode 100644
> > index 000000000..7e1e57fa3
> > --- /dev/null
> > +++ b/drivers/raw/common/multi_fn/rte_multi_fn_driver.h
> > @@ -0,0 +1,55 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2020 Intel Corporation.
> > + */
> > +
> > +#ifndef _RTE_MULTI_FN_DRIVER_H_
> > +#define _RTE_MULTI_FN_DRIVER_H_
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#include <rte_compat.h>
> > +#include <rte_common.h>
> > +#include <rte_rawdev.h>
> > +#include <rte_multi_fn.h>
> > +
>
> Only <rte_rawdev.h> and <rte_multi_fn.h> are needed.
> Actually, since rte_multi_fn.h is in the same folder, you can use double
> quotes.
[DC] Includes tidied up, only rawdev and multi_fn (in quotes) left now
Hi Pablo
Thank you for reviewing and the comments - see below for resolutions.
The changes will be available in v3 shortly
David
> -----Original Message-----
> From: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Sent: Tuesday, April 7, 2020 7:56 PM
>
> Hi David,
>
> > -----Original Message-----
> > From: Coyle, David <david.coyle@intel.com>
> > Sent: Friday, April 3, 2020 5:37 PM
> >
> > The multi-function interface provides a flexible and extensible way of
> > combining one or more packet processing functions into a single
> > operation. The interface can be used by applications to send the
> > combined operations to a optimized software or hardware accelerator via a
> raw device.
> >
> > Signed-off-by: David Coyle <david.coyle@intel.com>
> > Signed-off-by: Mairtin o Loingsigh <mairtin.oloingsigh@intel.com>
> > ---
> >
>
> Forgot to say to update Release Notes document, which these changes.
[DC] Release notes have been updated
>
> Thanks!
> Pablo
>
@@ -818,6 +818,11 @@ CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV=y
#
CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV=y
+#
+# Compile multi-fn raw device interface
+#
+CONFIG_RTE_LIBRTE_MULTI_FN_COMMON=n
+
#
# Compile librte_ring
#
@@ -10,6 +10,7 @@ dpdk_driver_classes = ['common',
'bus',
'mempool', # depends on common and bus.
'net', # depends on common, bus, mempool
+ 'raw/common',
'raw', # depends on common, bus and net.
'crypto', # depends on common, bus and mempool (net in future).
'compress', # depends on common, bus, mempool.
@@ -212,5 +213,9 @@ foreach class:dpdk_driver_classes
endif # build
endforeach
+ if class.contains('/')
+ class_split = class.split('/')
+ class = '_'.join(class_split)
+ endif
set_variable(class + '_drivers', class_drivers)
endforeach
@@ -14,5 +14,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV) += ioat
DIRS-$(CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV) += ntb
DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += octeontx2_dma
DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += octeontx2_ep
+DIRS-y += common
include $(RTE_SDK)/mk/rte.subdir.mk
new file mode 100644
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+DIRS-$(CONFIG_RTE_LIBRTE_MULTI_FN_COMMON) += multi_fn
+
+include $(RTE_SDK)/mk/rte.subdir.mk
new file mode 100644
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation.
+
+drivers = ['multi_fn']
+std_deps = ['rawdev']
+config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
+driver_name_fmt = 'rte_common_@0@'
new file mode 100644
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_multi_fn.a
+
+# build flags
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
+# versioning export map
+EXPORT_MAP := rte_common_multi_fn_version.map
+
+# external library dependencies
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_mempool
+LDLIBS += -lrte_rawdev
+
+SRCS-y += rte_multi_fn.c
+
+SYMLINK-y-include += rte_multi_fn.h
+SYMLINK-y-include += rte_multi_fn_driver.h
+
+include $(RTE_SDK)/mk/rte.lib.mk
new file mode 100644
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation.
+
+sources = files('rte_multi_fn.c')
+
+deps = ['rawdev', 'cryptodev', 'compressdev']
+allow_experimental_apis = true
+
+install_headers('rte_multi_fn.h')
new file mode 100644
@@ -0,0 +1,11 @@
+EXPERIMENTAL {
+ global:
+
+ rte_multi_fn_session_create;
+ rte_multi_fn_session_destroy;
+ rte_multi_fn_op_pool_create;
+ rte_multi_fn_op_bulk_alloc;
+ rte_multi_fn_op_free;
+
+ local: *;
+};
new file mode 100644
@@ -0,0 +1,166 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation.
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/queue.h>
+
+#include <rte_string_fns.h>
+#include <rte_byteorder.h>
+#include <rte_log.h>
+#include <rte_debug.h>
+#include <rte_dev.h>
+#include <rte_memory.h>
+#include <rte_memcpy.h>
+#include <rte_memzone.h>
+#include <rte_eal.h>
+#include <rte_per_lcore.h>
+#include <rte_lcore.h>
+#include <rte_atomic.h>
+#include <rte_branch_prediction.h>
+#include <rte_common.h>
+#include <rte_malloc.h>
+#include <rte_errno.h>
+#include <rte_rawdev.h>
+
+#include "rte_multi_fn_driver.h"
+#include "rte_multi_fn.h"
+
+/* Dynamic log identifier */
+static int multi_fn_logtype;
+
+/* Logging Macros */
+#define MF_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, multi_fn_logtype, \
+ "%s() line %u: " fmt "\n", \
+ __func__, __LINE__, ##args)
+#define MF_DEBUG(fmt, args...) \
+ MF_LOG(DEBUG, fmt, ## args)
+#define MF_INFO(fmt, args...) \
+ MF_LOG(INFO, fmt, ## args)
+#define MF_ERR(fmt, args...) \
+ MF_LOG(ERR, fmt, ## args)
+#define MF_WARN(fmt, args...) \
+ MF_LOG(WARNING, fmt, ## args)
+
+static void
+multi_fn_op_init(struct rte_mempool *mempool,
+ __rte_unused void *opaque_arg,
+ void *op_data,
+ __rte_unused unsigned int i)
+{
+ struct rte_multi_fn_op *op = op_data;
+
+ memset(op_data, 0, mempool->elt_size);
+
+ op->overall_status = RTE_MULTI_FN_OP_STATUS_NOT_PROCESSED;
+ op->mempool = mempool;
+}
+
+struct rte_multi_fn_session *
+rte_multi_fn_session_create(uint16_t dev_id,
+ struct rte_multi_fn_xform *xform,
+ int socket_id)
+{
+ struct rte_rawdev *rawdev;
+ struct rte_rawdev_info info = {0};
+ struct rte_multi_fn_ops *mf_ops;
+
+ if (xform == NULL) {
+ MF_ERR("NULL xform for multi-function session create");
+ return NULL;
+ }
+
+ if (rte_rawdev_info_get(dev_id, &info) < 0) {
+ MF_ERR("Invalid dev_id=%d", dev_id);
+ return NULL;
+ }
+
+ rawdev = &rte_rawdevs[dev_id];
+
+ mf_ops = *((struct rte_multi_fn_ops **)(rawdev->dev_private));
+
+ RTE_FUNC_PTR_OR_ERR_RET(*mf_ops->session_create, NULL);
+ return (*mf_ops->session_create)(rawdev, xform, socket_id);
+}
+
+int
+rte_multi_fn_session_destroy(uint16_t dev_id, struct rte_multi_fn_session *sess)
+{
+ struct rte_rawdev *rawdev;
+ struct rte_rawdev_info info = {0};
+ struct rte_multi_fn_ops *mf_ops;
+
+ if (rte_rawdev_info_get(dev_id, &info) < 0) {
+ MF_ERR("Invalid dev_id=%d", dev_id);
+ return -EINVAL;
+ }
+
+ rawdev = &rte_rawdevs[dev_id];
+
+ mf_ops = *((struct rte_multi_fn_ops **)(rawdev->dev_private));
+
+ RTE_FUNC_PTR_OR_ERR_RET(*mf_ops->session_destroy, -ENOTSUP);
+ return (*mf_ops->session_destroy)(rawdev, sess);
+}
+
+struct rte_mempool *
+rte_multi_fn_op_pool_create(const char *name,
+ uint32_t nb_elts,
+ uint32_t cache_size,
+ uint16_t priv_size,
+ int socket_id)
+{
+ uint32_t elt_size = sizeof(struct rte_multi_fn_op) + priv_size;
+
+ /* Lookup mempool in case already allocated */
+ struct rte_mempool *mp = rte_mempool_lookup(name);
+
+ if (mp != NULL) {
+ if (mp->elt_size != elt_size ||
+ mp->cache_size < cache_size ||
+ mp->size < nb_elts) {
+ mp = NULL;
+ MF_ERR("Mempool %s already exists but with "
+ "incompatible parameters",
+ name);
+ return NULL;
+ }
+
+ return mp;
+ }
+
+ mp = rte_mempool_create(name,
+ nb_elts,
+ elt_size,
+ cache_size,
+ 0,
+ NULL,
+ NULL,
+ multi_fn_op_init,
+ NULL,
+ socket_id,
+ 0);
+
+ if (mp == NULL) {
+ MF_ERR("Failed to create mempool %s", name);
+ return NULL;
+ }
+
+ return mp;
+}
+
+RTE_INIT(rte_multi_fn_log_init)
+{
+ multi_fn_logtype = rte_log_register("pmd.raw.common.multi_fn");
+ if (multi_fn_logtype >= 0)
+ rte_log_set_level(multi_fn_logtype, RTE_LOG_INFO);
+}
new file mode 100644
@@ -0,0 +1,350 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation.
+ */
+
+#ifndef _RTE_MULTI_FN_H_
+#define _RTE_MULTI_FN_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_compat.h>
+#include <rte_common.h>
+#include <rte_mbuf.h>
+#include <rte_memory.h>
+#include <rte_mempool.h>
+#include <rte_comp.h>
+#include <rte_crypto.h>
+#include <rte_rawdev.h>
+
+/** Error Detection Algorithms */
+enum rte_multi_fn_err_detect_algorithm {
+ RTE_MULTI_FN_ERR_DETECT_CRC32_ETH,
+ /**< CRC32 Ethernet */
+ RTE_MULTI_FN_ERR_DETECT_BIP32
+ /**< BIP32 */
+};
+
+/** Error Detection Operation Types */
+enum rte_multi_fn_err_detect_operation {
+ RTE_MULTI_FN_ERR_DETECT_OP_VERIFY,
+ /**< Verify error detection result */
+ RTE_MULTI_FN_ERR_DETECT_OP_GENERATE
+ /**< Generate error detection result */
+};
+
+/** Error Detection Status */
+enum rte_multi_fn_err_detect_op_status {
+ RTE_MULTI_FN_ERR_DETECT_OP_STATUS_SUCCESS,
+ /**< Operation completed successfully */
+ RTE_MULTI_FN_ERR_DETECT_OP_STATUS_NOT_PROCESSED,
+ /**< Operation has not yet been processed by a device */
+ RTE_MULTI_FN_ERR_DETECT_OP_STATUS_VERIFY_FAILED,
+ /**< Verification failed */
+ RTE_MULTI_FN_ERR_DETECT_OP_STATUS_ERROR
+ /**< Error handling operation */
+};
+
+struct rte_multi_fn_err_detect_xform {
+ enum rte_multi_fn_err_detect_operation op;
+ /**< Error detection operation type */
+ enum rte_multi_fn_err_detect_algorithm algo;
+ /**< Error detection algorithm */
+};
+
+/** Error Detection Operation */
+struct rte_multi_fn_err_detect_op {
+ struct rte_mbuf *m_src; /**< Source mbuf */
+ enum rte_multi_fn_err_detect_op_status status;
+ /**< Operation status */
+
+ struct {
+ uint16_t offset;
+ /**<
+ * Starting point for error detection processing, specified
+ * as the number of bytes from start of the packet in the
+ * source mbuf
+ */
+ uint16_t length;
+ /**<
+ * The length, in bytes, of the source mbuf on which the error
+ * detection operation will be computed
+ */
+ } data; /**< Data offset and length for error detection */
+
+ struct {
+ uint8_t *data;
+ /**<
+ * This points to the location where the error detection
+ * result should be written (in the case of generation) or
+ * where the purported result exists (in the case of
+ * verification)
+ *
+ * The caller must ensure the required length of physically
+ * contiguous memory is available at this address
+ *
+ * For a CRC, this may point into the mbuf packet data. For
+ * an operation such as a BIP, this may point to a memory
+ * location after the op
+ *
+ * For generation, the result will overwrite any data at this
+ * location
+ */
+ rte_iova_t phys_addr;
+ /**< Physical address of output data */
+ } output; /**< Output location */
+};
+
+/**
+ * Multi-function transform types
+ */
+enum rte_multi_fn_xform_type {
+ RTE_MULTI_FN_XFORM_TYPE_UNDEFINED,
+ /**< Undefined transform type */
+ RTE_MULTI_FN_XFORM_TYPE_CRYPTO_SYM,
+ /**< Symmetric crypto transform type */
+ RTE_MULTI_FN_XFORM_TYPE_CRYPTO_ASYM,
+ /**< Asymmetric crypto transform type */
+ RTE_MULTI_FN_XFORM_TYPE_COMP,
+ /**< Compression transform type */
+ RTE_MULTI_FN_XFORM_TYPE_ERR_DETECT
+ /**< Error detection transform type */
+};
+
+/**
+ * Multi-function transform setup data
+ *
+ * This structure is used to specify the multi-function transforms required.
+ * Multiple transforms can be chained together to specify a chain of transforms
+ * such as symmetric crypto followed by error detection, or compression followed
+ * by symmetric crypto. Each transform structure holds a single transform, with
+ * the type field specifying which transform is contained within the union.
+ */
+struct rte_multi_fn_xform {
+ struct rte_multi_fn_xform *next;
+ /**<
+ * Next transform in the chain
+ * - the last transform in the chain MUST set this to NULL
+ */
+ enum rte_multi_fn_xform_type type;
+ /**< Transform type */
+
+ RTE_STD_C11
+ union {
+ struct rte_crypto_sym_xform crypto_sym;
+ /**< Symmetric crypto transform */
+ struct rte_crypto_asym_xform crypto_asym;
+ /**< Asymmetric crypto transform */
+ struct rte_comp_xform comp;
+ /**< Compression transform */
+ struct rte_multi_fn_err_detect_xform err_detect;
+ /**< Error detection transform */
+ };
+};
+
+/**
+ * Multi-function operation status
+ */
+enum rte_multi_fn_op_status {
+ RTE_MULTI_FN_OP_STATUS_SUCCESS,
+ /**< Operation completed successfully */
+ RTE_MULTI_FN_OP_STATUS_NOT_PROCESSED,
+ /**< Operation has not yet been processed by a device */
+ RTE_MULTI_FN_OP_STATUS_FAILURE,
+ /**< Operation completed with failure */
+ RTE_MULTI_FN_STATUS_INVALID_SESSION,
+ /**< Operation failed due to invalid session arguments */
+};
+
+/**
+ * Multi-function session
+ */
+struct rte_multi_fn_session;
+
+/**
+ * Operation data
+ */
+struct rte_multi_fn_op {
+ struct rte_multi_fn_op *next;
+ /**<
+ * Next operation in the chain
+ * - the last operation in the chain MUST set this to NULL
+ */
+ struct rte_multi_fn_session *sess;
+ /**< Handle for the associated multi fn session */
+
+ struct rte_mempool *mempool;
+ /**< Mempool from which the operation is allocated */
+
+ struct rte_mbuf *m_src; /**< Source mbuf */
+ struct rte_mbuf *m_dst; /**< Destination mbuf */
+
+ enum rte_multi_fn_op_status overall_status;
+ /**<
+ * Overall operation status
+ * - indicates if all the operations in the chain succeeded or if any
+ * one of them failed
+ */
+
+ uint8_t op_status;
+ /**<
+ * Individual operation status
+ * - indicates the status of the individual operation in the chain
+ */
+
+ RTE_STD_C11
+ union {
+ struct rte_crypto_sym_op crypto_sym;
+ /**< Symmetric crypto operation */
+ struct rte_crypto_asym_op crypto_asym;
+ /**< Asymmetric crypto operation */
+ struct rte_comp_op comp;
+ /**< Compression operation */
+ struct rte_multi_fn_err_detect_op err_detect;
+ /**< Error detection operation */
+ };
+};
+
+/**
+ * Device information structure
+ *
+ * This structure is returned from rte_rawdev_info_get() with information
+ * about the device
+ */
+struct rte_multi_fn_dev_info {
+ uint16_t max_nb_queues;
+ /**<
+ * Maximum number of queue pairs that can be configured on the
+ * device
+ */
+};
+
+/**
+ * Device configuration structure
+ *
+ * This structure should be passed to rte_rawdev_configure() to configure
+ * a device
+ */
+struct rte_multi_fn_dev_config {
+ uint16_t nb_queues; /**< Number of queue pairs to configure */
+ unsigned int socket_id; /**< Socket to allocate queues on */
+};
+
+/**
+ * Queue pair configuration structure
+ *
+ * This should be passed to rte_rawdev_queue_setup() to configure a queue pair
+ */
+struct rte_multi_fn_qp_config {
+ uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
+};
+
+/**
+ * Create multi-function session as specified by the transform chain
+ *
+ * @param dev_id The identifier of the device
+ * @param xform Pointer to the first element of the session transform
+ * chain
+ * @param socket_id Socket to allocate the session on
+ *
+ * @return
+ * - Pointer to session, if successful
+ * - NULL, on failure
+ */
+__rte_experimental
+struct rte_multi_fn_session *
+rte_multi_fn_session_create(uint16_t dev_id,
+ struct rte_multi_fn_xform *xform,
+ int socket_id);
+
+/**
+ * Free memory associated with a multi-function session
+ *
+ * @param dev_id The identifier of the device
+ * @param sess Multi-function session to be freed
+ *
+ * @return
+ * - 0, if successful
+ * - -EINVAL, if session is NULL
+ * - -EBUSY, if not all session data has been freed
+ */
+__rte_experimental
+int
+rte_multi_fn_session_destroy(uint16_t dev_id,
+ struct rte_multi_fn_session *sess);
+
+/**
+ * Creates a multi-function operation pool
+ *
+ * @param name Pool name
+ * @param nb_elts Number of elements in pool
+ * @param cache_size Number of elements to cache on lcore, see
+ * *rte_mempool_create* for further details about
+ * cache size
+ * @param priv_size Size of private data to allocate with each
+ * operation
+ * @param socket_id Socket to allocate memory on
+ *
+ * @return
+ * - Pointer to mempool, if successful
+ * - NULL, on failure
+ */
+__rte_experimental
+struct rte_mempool *
+rte_multi_fn_op_pool_create(const char *name,
+ uint32_t nb_elts,
+ uint32_t cache_size,
+ uint16_t priv_size,
+ int socket_id);
+
+/**
+ * Bulk allocate multi-function operations from a mempool with default
+ * parameters set
+ *
+ * @param mempool Multi-function operation mempool
+ * @param ops Array to place allocated multi-function operations
+ * @param nb_ops Number of multi-function operations to allocate
+ *
+ * @returns
+ * - nb_ops, if the number of operations requested were allocated
+ * - 0, if the requested number of ops are not available. None are allocated in
+ * this case
+ */
+__rte_experimental
+static inline unsigned
+rte_multi_fn_op_bulk_alloc(struct rte_mempool *mempool,
+ struct rte_multi_fn_op **ops,
+ uint16_t nb_ops)
+{
+ int i;
+
+ if (rte_mempool_get_bulk(mempool, (void **)ops, nb_ops) == 0) {
+ for (i = 0; i < nb_ops; i++)
+ ops[i]->overall_status =
+ RTE_MULTI_FN_OP_STATUS_NOT_PROCESSED;
+
+ return nb_ops;
+ }
+
+ return 0;
+}
+
+/**
+ * Free multi-function operation back to it's mempool
+ *
+ * @param op Multi-function operation
+ */
+__rte_experimental
+static inline void
+rte_multi_fn_op_free(struct rte_multi_fn_op *op)
+{
+ if (op != NULL && op->mempool != NULL)
+ rte_mempool_put(op->mempool, op);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_MULTI_FN_H_ */
new file mode 100644
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation.
+ */
+
+#ifndef _RTE_MULTI_FN_DRIVER_H_
+#define _RTE_MULTI_FN_DRIVER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_compat.h>
+#include <rte_common.h>
+#include <rte_rawdev.h>
+#include <rte_multi_fn.h>
+
+/**
+ * Multi-function session
+ */
+struct rte_multi_fn_session {
+ void *sess_private_data;
+};
+
+/**
+ * Session create function pointer type
+ */
+typedef struct rte_multi_fn_session *(*multi_fn_session_create_t)(
+ struct rte_rawdev *,
+ struct rte_multi_fn_xform *,
+ int);
+
+/**
+ * Session destroy function pointer type
+ */
+typedef int (*multi_fn_session_destroy_t)(struct rte_rawdev *,
+ struct rte_multi_fn_session *);
+
+/**
+ * Structure containing multi-function ops to create and destroy a session.
+ *
+ * This structure MUST be the first element of the device's private data
+ * structure pointed to by rte_rawdev->dev_private
+ */
+struct rte_multi_fn_ops {
+ multi_fn_session_create_t session_create;
+ /**< Create session function pointer */
+ multi_fn_session_destroy_t session_destroy;
+ /**< Destroy session function pointer */
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_MULTI_FN_DRIVER_H_ */
@@ -102,6 +102,10 @@ message(output_message + '\n')
output_message = '\n===============\nDrivers Enabled\n===============\n'
foreach class:dpdk_driver_classes
+ if class.contains('/')
+ class_split = class.split('/')
+ class = '_'.join(class_split)
+ endif
class_drivers = get_variable(class + '_drivers')
output_message += '\n' + class + ':\n\t'
output_count = 0
@@ -347,6 +347,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV) += -lrte_rawdev_ioat
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV) += -lrte_rawdev_ntb
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += -lrte_rawdev_octeontx2_dma
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += -lrte_rawdev_octeontx2_ep
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MULTI_FN_COMMON) += -lrte_multi_fn
endif # CONFIG_RTE_LIBRTE_RAWDEV
endif # !CONFIG_RTE_BUILD_SHARED_LIBS