1fe750c24SBenoît Ganne# Copyright (c) 2018 Cisco and/or its affiliates.
2fe750c24SBenoît Ganne# Licensed under the Apache License, Version 2.0 (the "License");
3fe750c24SBenoît Ganne# you may not use this file except in compliance with the License.
4fe750c24SBenoît Ganne# You may obtain a copy of the License at:
5fe750c24SBenoît Ganne#
6fe750c24SBenoît Ganne#     http://www.apache.org/licenses/LICENSE-2.0
7fe750c24SBenoît Ganne#
8fe750c24SBenoît Ganne# Unless required by applicable law or agreed to in writing, software
9fe750c24SBenoît Ganne# distributed under the License is distributed on an "AS IS" BASIS,
10fe750c24SBenoît Ganne# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11fe750c24SBenoît Ganne# See the License for the specific language governing permissions and
12fe750c24SBenoît Ganne# limitations under the License.
13fe750c24SBenoît Ganne
14fe750c24SBenoît Gannefind_path(IBVERBS_INCLUDE_DIR NAMES infiniband/verbs.h)
159fd24793SDamjan Marion
169fd24793SDamjan Marionif (NOT IBVERBS_INCLUDE_DIR)
179fd24793SDamjan Marion  message(WARNING "-- rdma headers not found - rdma plugin disabled")
189fd24793SDamjan Marion  return()
199fd24793SDamjan Marionendif()
209fd24793SDamjan Marion
219fd24793SDamjan Marionvpp_plugin_find_library(rdma IBVERBS_LIB libibverbs.a)
22c0bc26eaSBenoît Gannevpp_plugin_find_library(rdma RDMA_UTIL_LIB librdma_util.a)
239fd24793SDamjan Marionvpp_plugin_find_library(rdma MLX5_LIB libmlx5.a)
24fe750c24SBenoît Ganne
25c0bc26eaSBenoît Ganneif (NOT IBVERBS_LIB OR NOT RDMA_UTIL_LIB OR NOT MLX5_LIB)
269fd24793SDamjan Marion  message(WARNING "rdma plugin - ibverbs not found - rdma plugin disabled")
27fe750c24SBenoît Ganne  return()
28fe750c24SBenoît Ganneendif()
29fe750c24SBenoît Ganne
30386ebb6eSBenoît Gannestring_append(RDMA_LINK_FLAGS "-Wl,--whole-archive,${MLX5_LIB},--no-whole-archive")
31fe750c24SBenoît Ganne
32971c5be2SBenoît Ganneset(CMAKE_REQUIRED_FLAGS "-fPIC -shared -pthread -Wno-unused-command-line-argument ${RDMA_LINK_FLAGS} ${IBVERBS_LIB} ${RDMA_UTIL_LIB}")
33971c5be2SBenoît Ganneset(CMAKE_REQUIRED_INCLUDES "${IBVERBS_INCLUDE_DIR}")
34971c5be2SBenoît Ganneset(CMAKE_REQUIRED_LIBRARIES "c") # force linkage by including libc explicitely
35971c5be2SBenoît GanneCHECK_C_SOURCE_COMPILES("
36971c5be2SBenoît Ganne#include <infiniband/verbs.h>
37971c5be2SBenoît Ganneint main(void)
38971c5be2SBenoît Ganne{
39971c5be2SBenoît Ganne    return 0 != ibv_get_device_list(0);
40971c5be2SBenoît Ganne}" IBVERBS_COMPILES_CHECK)
41fe750c24SBenoît Ganne
42fe750c24SBenoît Ganneif (NOT IBVERBS_COMPILES_CHECK)
439fd24793SDamjan Marion  message(WARNING "rdma plugins - no working ibverbs found - rdma plugin disabled")
44fe750c24SBenoît Ganne  return()
45fe750c24SBenoît Ganneendif()
46fe750c24SBenoît Ganne
47fe750c24SBenoît Ganneinclude_directories(${IBVERBS_INCLUDE_DIR})
48fe750c24SBenoît Ganne
49fe750c24SBenoît Ganneadd_vpp_plugin(rdma
50fe750c24SBenoît Ganne  SOURCES
51812afe71SBenoît Ganne  api.c
52fe750c24SBenoît Ganne  cli.c
53fe750c24SBenoît Ganne  device.c
54fe750c24SBenoît Ganne  format.c
55fe750c24SBenoît Ganne  plugin.c
56812afe71SBenoît Ganne  unformat.c
57fe750c24SBenoît Ganne  input.c
58fe750c24SBenoît Ganne  output.c
59fe750c24SBenoît Ganne
60fe750c24SBenoît Ganne  MULTIARCH_SOURCES
61fe750c24SBenoît Ganne  input.c
62fe750c24SBenoît Ganne  output.c
63fe750c24SBenoît Ganne
64812afe71SBenoît Ganne  API_FILES
65812afe71SBenoît Ganne  rdma.api
66812afe71SBenoît Ganne
67812afe71SBenoît Ganne  API_TEST_SOURCES
68812afe71SBenoît Ganne  unformat.c
69812afe71SBenoît Ganne  test_api.c
70812afe71SBenoît Ganne
71fe750c24SBenoît Ganne  LINK_FLAGS
72fe750c24SBenoît Ganne  "${RDMA_LINK_FLAGS}"
73fe750c24SBenoît Ganne
74fe750c24SBenoît Ganne  LINK_LIBRARIES
75fe750c24SBenoît Ganne  ${IBVERBS_LIB}
76c0bc26eaSBenoît Ganne  ${RDMA_UTIL_LIB}
77fe750c24SBenoît Ganne)
78