summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/CMakeLists.txt
diff options
context:
space:
mode:
authorFan Zhang <roy.fan.zhang@intel.com>2021-05-25 15:50:30 +0100
committerDamjan Marion <dmarion@me.com>2021-05-26 21:06:34 +0000
commit3f3da0d27dcf83808f2691205b891a42ac2b4679 (patch)
treed53c6d086d82c0bd8da377bbfa29a0461b69aede /src/plugins/dpdk/CMakeLists.txt
parent57e0af924b8b48cf39b1020bf11f10e3c227f22c (diff)
dpdk: fix missing symbol
Type: fix This patch fixes the missing symbol of dpdk_plugin.so when creating symmetric key. The solution is to add dependency of libssl to dpdk cryptodev and disable cryptodev engine when libssl is not presented. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> Change-Id: I30aa6e3e3af1faefa82883bad613e1d82235a2ec
Diffstat (limited to 'src/plugins/dpdk/CMakeLists.txt')
-rw-r--r--src/plugins/dpdk/CMakeLists.txt19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/dpdk/CMakeLists.txt b/src/plugins/dpdk/CMakeLists.txt
index 386515e8eef..5de75e76289 100644
--- a/src/plugins/dpdk/CMakeLists.txt
+++ b/src/plugins/dpdk/CMakeLists.txt
@@ -117,9 +117,15 @@ endif()
# DPDK plugin
##############################################################################
-if (${DPDK_VERSION} VERSION_GREATER_EQUAL "20.8.0")
- set(DPDK_CRYPTODEV_RAW_SOURCE cryptodev/cryptodev_raw_data_path.c)
-endif ()
+if(OPENSSL_FOUND)
+ include_directories(${OPENSSL_INCLUDE_DIR})
+
+ set(DPDK_CRYPTODEV_OP_SOURCE cryptodev/cryptodev_op_data_path.c)
+ set(DPDK_CRYPTODEV_SOURCE cryptodev/cryptodev.c)
+ if (${DPDK_VERSION} VERSION_GREATER_EQUAL "20.8.0")
+ set(DPDK_CRYPTODEV_RAW_SOURCE cryptodev/cryptodev_raw_data_path.c)
+ endif()
+endif()
add_vpp_plugin(dpdk
SOURCES
@@ -133,8 +139,8 @@ add_vpp_plugin(dpdk
device/format.c
device/init.c
device/node.c
- cryptodev/cryptodev_op_data_path.c
- cryptodev/cryptodev.c
+ ${DPDK_CRYPTODEV_OP_SOURCE}
+ ${DPDK_CRYPTODEV_SOURCE}
${DPDK_CRYPTODEV_RAW_SOURCE}
MULTIARCH_SOURCES
@@ -151,6 +157,9 @@ add_vpp_plugin(dpdk
LINK_LIBRARIES
${DPDK_LINK_LIBRARIES}
+ LINK_LIBRARIES
+ ${OPENSSL_LIBRARIES}
+
COMPONENT
vpp-plugin-dpdk
)
f='#n228'>228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
/* SPDX-License-Identifier: Apache-2.0
 * Copyright(c) 2021 Cisco Systems, Inc.
 */

#include <vppinfra/format.h>
#include <vppinfra/vector/test/test.h>
#include <vppinfra/vector/compress.h>

__test_funct_fn u32
clib_compress_u64_wrapper (u64 *dst, u64 *src, u64 *mask, u32 n_elts)
{
  return clib_compress_u64 (dst, src, mask, n_elts);
}

__test_funct_fn u32
clib_compress_u32_wrapper (u32 *dst, u32 *src, u64 *mask, u32 n_elts)
{
  return clib_compress_u32 (dst, src, mask, n_elts);
}

__test_funct_fn u32
clib_compress_u16_wrapper (u16 *dst, u16 *src, u64 *mask, u32 n_elts)
{
  return clib_compress_u16 (dst, src, mask, n_elts);
}

__test_funct_fn u32
clib_compress_u8_wrapper (u8 *dst, u8 *src, u64 *mask, u32 n_elts)
{
  return clib_compress_u8 (dst, src, mask, n_elts);
}

typedef struct
{
  u64 mask[10];
  u32 n_elts;
} compress_test_t;

static compress_test_t tests[] = {
  { .mask = { 1 }, .n_elts = 1 },
  { .mask = { 2 }, .n_elts = 2 },
  { .mask = { 3 }, .n_elts = 2 },
  { .mask = { 0, 1 }, .n_elts = 66 },
  { .mask = { 0, 2 }, .n_elts = 69 },
  { .mask = { 0, 3 }, .n_elts = 66 },
  { .mask = { ~0ULL, ~0ULL, ~0ULL, ~0ULL }, .n_elts = 62 },
  { .mask = { ~0ULL, ~0ULL, ~0ULL, ~0ULL }, .n_elts = 255 },
  { .mask = { ~0ULL, 1, 1, ~0ULL }, .n_elts = 256 },
};

static clib_error_t *
test_clib_compress_u64 (clib_error_t *err)
{
  u64 src[513];
  u64 dst[513];
  u32 i, j;

  for (i = 0; i < ARRAY_LEN (src); i++)
    src[i] = i;

  for (i = 0; i < ARRAY_LEN (tests); i++)
    {
      compress_test_t *t = tests + i;
      u64 *dp = dst;
      u32 r;

      for (j = 0; j < ARRAY_LEN (dst); j++)
	dst[j] = 0xa5a5a5a5a5a5a5a5;

      r = clib_compress_u64_wrapper (dst, src, t->mask, t->n_elts);

      for (j = 0; j < t->n_elts; j++)
	{
	  if ((t->mask[j >> 6] & (1ULL << (j & 0x3f))) == 0)
	    continue;
	  if (dp[0] != src[j])
	    return clib_error_return (err,
				      "wrong data in testcase %u at "
				      "(dst[%u] = 0x%lx, src[%u] = 0x%lx)",
				      i, dp - dst, dp[0], j, src[j]);
	  dp++;
	}

      if (dst[dp - dst + 1] != 0xa5a5a5a5a5a5a5a5)
	return clib_error_return (err, "buffer overrun in testcase %u", i);

      if (dp - dst != r)
	return clib_error_return (err, "wrong number of elts in testcase %u",
				  i);
    }

  return err;

  return err;
}

static clib_error_t *
test_clib_compress_u32 (clib_error_t *err)
{
  u32 src[513];
  u32 dst[513];
  u32 i, j;

  for (i = 0; i < ARRAY_LEN (src); i++)
    src[i] = i;

  for (i = 0; i < ARRAY_LEN (tests); i++)
    {
      compress_test_t *t = tests + i;
      u32 *dp = dst;
      u32 r;

      for (j = 0; j < ARRAY_LEN (dst); j++)
	dst[j] = 0xa5a5a5a5;

      r = clib_compress_u32_wrapper (dst, src, t->mask, t->n_elts);

      for (j = 0; j < t->n_elts; j++)
	{
	  if ((t->mask[j >> 6] & (1ULL << (j & 0x3f))) == 0)
	    continue;

	  if (dp[0] != src[j])
	    return clib_error_return (err,
				      "wrong data in testcase %u at "
				      "(dst[%u] = 0x%x, src[%u] = 0x%x)",
				      i, dp - dst, dp[0], j, src[j]);
	  dp++;
	}

      if (dst[dp - dst + 1] != 0xa5a5a5a5)
	return clib_error_return (err, "buffer overrun in testcase %u", i);

      if (dp - dst != r)
	return clib_error_return (err, "wrong number of elts in testcase %u",
				  i);
    }

  return err;
}

static clib_error_t *
test_clib_compress_u16 (clib_error_t *err)
{
  u16 src[513];
  u16 dst[513];
  u32 i, j;

  for (i = 0; i < ARRAY_LEN (src); i++)
    src[i] = i;

  for (i = 0; i < ARRAY_LEN (tests); i++)
    {
      compress_test_t *t = tests + i;
      u16 *dp = dst;
      u32 r;

      for (j = 0; j < ARRAY_LEN (dst); j++)
	dst[j] = 0xa5a5;

      r = clib_compress_u16_wrapper (dst, src, t->mask, t->n_elts);

      for (j = 0; j < t->n_elts; j++)
	{
	  if ((t->mask[j >> 6] & (1ULL << (j & 0x3f))) == 0)
	    continue;
	  if (dp[0] != src[j])
	    return clib_error_return (err,
				      "wrong data in testcase %u at "
				      "(dst[%u] = 0x%x, src[%u] = 0x%x)",
				      i, dp - dst, dp[0], j, src[j]);
	  dp++;
	}

      if (dst[dp - dst + 1] != 0xa5a5)
	return clib_error_return (err, "buffer overrun in testcase %u", i);

      if (dp - dst != r)
	return clib_error_return (err, "wrong number of elts in testcase %u",
				  i);
    }

  return err;
}

static clib_error_t *
test_clib_compress_u8 (clib_error_t *err)
{
  u8 src[513];
  u8 dst[513];
  u32 i, j;

  for (i = 0; i < ARRAY_LEN (src); i++)
    src[i] = i;

  for (i = 0; i < ARRAY_LEN (tests); i++)
    {
      compress_test_t *t = tests + i;
      u8 *dp = dst;
      u32 r;

      for (j = 0; j < ARRAY_LEN (dst); j++)
	dst[j] = 0xa5;

      r = clib_compress_u8_wrapper (dst, src, t->mask, t->n_elts);

      for (j = 0; j < t->n_elts; j++)
	{
	  if ((t->mask[j >> 6] & (1ULL << (j & 0x3f))) == 0)
	    continue;
	  if (dp[0] != src[j])
	    return clib_error_return (err,
				      "wrong data in testcase %u at "
				      "(dst[%u] = 0x%x, src[%u] = 0x%x)",
				      i, dp - dst, dp[0], j, src[j]);
	  dp++;
	}

      if (dst[dp - dst + 1] != 0xa5)
	return clib_error_return (err, "buffer overrun in testcase %u", i);

      if (dp - dst != r)
	return clib_error_return (err, "wrong number of elts in testcase %u",
				  i);
    }

  return err;
}

REGISTER_TEST (clib_compress_u64) = {
  .name = "clib_compress_u64",
  .fn = test_clib_compress_u64,
};

REGISTER_TEST (clib_compress_u32) = {
  .name = "clib_compress_u32",
  .fn = test_clib_compress_u32,
};

REGISTER_TEST (clib_compress_u16) = {
  .name = "clib_compress_u16",
  .fn = test_clib_compress_u16,
};

REGISTER_TEST (clib_compress_u8) = {
  .name = "clib_compress_u8",
  .fn = test_clib_compress_u8,
};