[dpdk-dev] [PATCH v7 06/21] eal/soc: introduce very essential SoC infra definitions

Jianbo Liu jianbo.liu at linaro.org
Thu Nov 10 05:09:03 CET 2016


On 28 October 2016 at 20:26, Shreyansh Jain <shreyansh.jain at nxp.com> wrote:
> From: Jan Viktorin <viktorin at rehivetech.com>
>
> Define initial structures and functions for the SoC infrastructure.
> This patch supports only a very minimal functions for now.
> More features will be added in the following commits.
>
> Includes rte_device/rte_driver inheritance of
> rte_soc_device/rte_soc_driver.
>
> Signed-off-by: Jan Viktorin <viktorin at rehivetech.com>
> Signed-off-by: Shreyansh Jain <shreyansh.jain at nxp.com>
> Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
> ---
>  app/test/Makefile                       |   1 +
>  app/test/test_soc.c                     |  90 +++++++++++++++++++++
>  lib/librte_eal/common/Makefile          |   2 +-
>  lib/librte_eal/common/eal_private.h     |   4 +
>  lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++
>  5 files changed, 234 insertions(+), 1 deletion(-)
>  create mode 100644 app/test/test_soc.c
>  create mode 100644 lib/librte_eal/common/include/rte_soc.h
>
...


> +/**
> + * Utility function to write a SoC device name, this device name can later be
> + * used to retrieve the corresponding rte_soc_addr using above functions.
> + *
> + * @param addr
> + *     The SoC address
> + * @param output
> + *     The output buffer string
> + * @param size
> + *     The output buffer size
> + * @return
> + *  0 on success, negative on error.
> + */
> +static inline void
> +rte_eal_soc_device_name(const struct rte_soc_addr *addr,
> +                       char *output, size_t size)
> +{
> +       int ret;
> +
> +       RTE_VERIFY(addr != NULL);
> +       RTE_VERIFY(size >= strlen(addr->name));

Is it better to use (size > strlen(addr->name)?

> +       ret = snprintf(output, size, "%s", addr->name);
> +       RTE_VERIFY(ret >= 0);
> +}
> +
> +static inline int
> +rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
> +                        const struct rte_soc_addr *a1)
> +{
> +       if (a0 == NULL || a1 == NULL)
> +               return -1;
> +
> +       RTE_VERIFY(a0->name != NULL);
> +       RTE_VERIFY(a1->name != NULL);
> +
> +       return strcmp(a0->name, a1->name);
> +}
> +
> +#endif
> --
> 2.7.4
>


More information about the dev mailing list