[dpdk-dev] [dpdk-dev, 1/8] drivers/common/dpaa2: Run time assembler for Descriptor formation

Neil Horman nhorman at tuxdriver.com
Mon Dec 12 15:59:04 CET 2016


On Mon, Dec 05, 2016 at 06:25:33PM +0530, Akhil Goyal wrote:
> FLib is a library which helps in making the descriptors which
> is understood by NXP's SEC hardware.
> This patch provides header files for command words which can be used
> for descritptor formation.
> 
> Signed-off-by: Horia Geanta Neag <horia.geanta at nxp.com>
> Acked-by: Akhil Goyal <akhil.goyal at nxp.com>
> ---
>  drivers/common/dpaa2/flib/README                   |  43 +
>  drivers/common/dpaa2/flib/compat.h                 | 186 +++++
>  drivers/common/dpaa2/flib/rta.h                    | 918 +++++++++++++++++++++
>  .../common/dpaa2/flib/rta/fifo_load_store_cmd.h    | 308 +++++++
>  drivers/common/dpaa2/flib/rta/header_cmd.h         | 213 +++++
>  drivers/common/dpaa2/flib/rta/jump_cmd.h           | 172 ++++
>  drivers/common/dpaa2/flib/rta/key_cmd.h            | 187 +++++
>  drivers/common/dpaa2/flib/rta/load_cmd.h           | 301 +++++++
>  drivers/common/dpaa2/flib/rta/math_cmd.h           | 366 ++++++++
>  drivers/common/dpaa2/flib/rta/move_cmd.h           | 405 +++++++++
>  drivers/common/dpaa2/flib/rta/nfifo_cmd.h          | 161 ++++
>  drivers/common/dpaa2/flib/rta/operation_cmd.h      | 549 ++++++++++++
>  drivers/common/dpaa2/flib/rta/protocol_cmd.h       | 680 +++++++++++++++
>  drivers/common/dpaa2/flib/rta/sec_run_time_asm.h   | 767 +++++++++++++++++
>  drivers/common/dpaa2/flib/rta/seq_in_out_ptr_cmd.h | 172 ++++
>  drivers/common/dpaa2/flib/rta/signature_cmd.h      |  40 +
>  drivers/common/dpaa2/flib/rta/store_cmd.h          | 149 ++++
>  17 files changed, 5617 insertions(+)
>  create mode 100644 drivers/common/dpaa2/flib/README
>  create mode 100644 drivers/common/dpaa2/flib/compat.h
>  create mode 100644 drivers/common/dpaa2/flib/rta.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/fifo_load_store_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/header_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/jump_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/key_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/load_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/math_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/move_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/nfifo_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/operation_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/protocol_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/sec_run_time_asm.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/seq_in_out_ptr_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/signature_cmd.h
>  create mode 100644 drivers/common/dpaa2/flib/rta/store_cmd.h
> 
> diff --git a/drivers/common/dpaa2/flib/README b/drivers/common/dpaa2/flib/README
> new file mode 100644
> index 0000000..a8b3358
> --- /dev/null
> +++ b/drivers/common/dpaa2/flib/README
> @@ -0,0 +1,43 @@
> +Copyright 2008-2013 Freescale Semiconductor, Inc.
> +
> +Runtime Assembler provides an easy and flexible runtime method for writing
> +SEC descriptors.
> +
> +1. What's supported
> +===================
> +1.1 Initialization/verification code for descriptor buffer.
> +1.2 Configuration/verification code for SEC commands:
> +       FIFOLOAD and SEQFIFOLOAD;
> +       FIFOSTORE and SEQFIFOSTORE;
> +       SHARED HEADER and JOB HEADER;
> +       JUMP;
> +       KEY;
> +       LOAD and SEQLOAD;
> +       MATH;
> +       MOVE and MOVELEN;
> +       NFIFO - pseudo command (shortcut for writing FIFO entries using LOAD command);
> +       PKA OPERATION and ALGORITHM OPERATION;
> +       PROTOCOL;
> +       SEQ IN PTR and SEQ OUT PTR;
> +       SIGNATURE;
> +       STORE and SEQSTORE.
> +1.3 Support for referential code:
> +	patching routines for LOAD, MOVE, JUMP and HEADER commands.
> +	raw patching (i.e. patch any 4-byte word from descriptor)
> +1.4 Support for extended (32/36/40-bit) pointer size.
> +1.5 SEC Eras 1-6
> +	Below is a non-exhaustive list of platforms:
> +	Era 1 - P4080R1
> +	Era 2 - P4080R2
> +	Era 3 - P1010, P1023, P3041, P5020
> +	Era 4 - BSC9131, BSC9132, P4080R3
> +	Era 5 - P5040, B4860, T4240R1
> +	Era 6 - C290, T4240R2, T1040, T2080
> +
> +2. What's not supported
> +=======================
> +2.1 SEC Eras 7 and 8.
> +
> +3. Integration
> +==============
> +To integrate this tool into your project, rta.h file must be included.
> diff --git a/drivers/common/dpaa2/flib/compat.h b/drivers/common/dpaa2/flib/compat.h
> new file mode 100644
> index 0000000..bd946e1
> --- /dev/null
> +++ b/drivers/common/dpaa2/flib/compat.h
> @@ -0,0 +1,186 @@
> +/*
> + * Copyright 2013 Freescale Semiconductor, Inc.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+
> + */
> +
> +#ifndef __RTA_COMPAT_H__
> +#define __RTA_COMPAT_H__
> +
> +#include <stdint.h>
> +#include <errno.h>
> +
> +#ifdef __GLIBC__
> +#include <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <stdbool.h>
> +#include <byteswap.h>
> +
> +#ifndef __BYTE_ORDER__
> +#error "Undefined endianness"
> +#endif
> +
> +/* FSL's Embedded Warrior C Library; assume AIOP or MC environment */
> +#elif defined(__EWL__) && (defined(AIOP) || defined(MC))
> +#include "common/fsl_string.h"
> +#include "common/fsl_stdlib.h"
> +#include "common/fsl_stdio.h"
> +#if defined(AIOP)
> +#include "dplib/fsl_cdma.h"
> +#endif
> +#include "fsl_dbg.h"
> +#include "fsl_endian.h"
> +#if _EWL_C99
> +#include <stdbool.h>
> +#else
> +#if !__option(c99)
> +typedef unsigned char			_Bool;
> +#endif
> +#define bool				_Bool
> +#define true				1
> +#define false				0
> +#define __bool_true_false_are_defined	1
> +#endif /* _EWL_C99 */
> +#else
> +#error Environment not supported!
> +#endif
> +
> +#ifndef __always_inline
> +#define __always_inline inline __attribute__((always_inline))
> +#endif
> +
> +#ifndef __always_unused
> +#define __always_unused __attribute__((unused))
> +#endif
> +
> +#ifndef __maybe_unused
> +#define __maybe_unused __attribute__((unused))
> +#endif
> +
> +#if defined(__GLIBC__) && (defined(SUPPRESS_PRINTS) || \
> +			   (!defined(pr_debug) && !defined(RTA_DEBUG)))
> +#ifndef __printf
> +#define __printf(a, b)	__attribute__((format(printf, 1, 2)))
> +#endif
> +static inline __printf(1, 2) int no_printf(const char *fmt __always_unused, ...)
> +{
> +	return 0;
> +}
> +#endif
> +
> +#if defined(__GLIBC__) && !defined(pr_debug)
> +#if !defined(SUPPRESS_PRINTS) && defined(RTA_DEBUG)
> +#define pr_debug(fmt, ...)    printf(fmt, ##__VA_ARGS__)
> +#else
> +#define pr_debug(fmt, ...)    no_printf(fmt, ##__VA_ARGS__)
> +#endif
> +#endif /* pr_debug */
> +
> +#if defined(__GLIBC__) && !defined(pr_err)
> +#if !defined(SUPPRESS_PRINTS)
> +#define pr_err(fmt, ...)    printf(fmt, ##__VA_ARGS__)
> +#else
> +#define pr_err(fmt, ...)    no_printf(fmt, ##__VA_ARGS__)
> +#endif
> +#endif /* pr_err */
> +
> +#if defined(__GLIBC__) && !defined(pr_warning)
> +#if !defined(SUPPRESS_PRINTS)
> +#define pr_warning(fmt, ...)    printf(fmt, ##__VA_ARGS__)
> +#else
> +#define pr_warning(fmt, ...)    no_printf(fmt, ##__VA_ARGS__)
> +#endif
> +#endif /* pr_warning */
> +
> +#if defined(__GLIBC__) && !defined(pr_warn)
> +#define pr_warn	pr_warning
> +#endif /* pr_warn */
Seems like logging should be folded into the rte logging facility, not
controlled independently, and manipulated via redefinitions of printf

> +
> +/**
> + * ARRAY_SIZE - returns the number of elements in an array
> + * @x: array
> + */
> +#ifndef ARRAY_SIZE
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> +#endif
> +
> +#ifndef ALIGN
> +#define ALIGN(x, a) (((x) + ((__typeof__(x))(a) - 1)) & \
> +			~((__typeof__(x))(a) - 1))
> +#endif
> +
> +#ifndef BIT
> +#define BIT(nr)		(1UL << (nr))
> +#endif
> +
> +#ifndef upper_32_bits
> +/**
> + * upper_32_bits - return bits 32-63 of a number
> + * @n: the number we're accessing
> + */
> +#define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
> +#endif
> +
> +#ifndef lower_32_bits
> +/**
> + * lower_32_bits - return bits 0-31 of a number
> + * @n: the number we're accessing
> + */
> +#define lower_32_bits(n) ((uint32_t)(n))
> +#endif
> +
> +/* Use Linux naming convention */
> +#ifdef __GLIBC__
> +	#define swab16(x) bswap_16(x)
> +	#define swab32(x) bswap_32(x)
> +	#define swab64(x) bswap_64(x)
> +	/* Define cpu_to_be32 macro if not defined in the build environment */
> +	#if !defined(cpu_to_be32)
> +		#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> +			#define cpu_to_be32(x)	(x)
> +		#else
> +			#define cpu_to_be32(x)	swab32(x)
> +		#endif
> +	#endif
> +	/* Define cpu_to_le32 macro if not defined in the build environment */
> +	#if !defined(cpu_to_le32)
> +		#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> +			#define cpu_to_le32(x)	swab32(x)
> +		#else
> +			#define cpu_to_le32(x)	(x)
> +		#endif
Definately shouldn't be redefining your own byte swapping routines here.




More information about the dev mailing list