dpdk/drivers/net/mlx4/mlx4_glue.c
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright 2018 6WIND S.A.
   3 * Copyright 2018 Mellanox Technologies, Ltd
   4 */
   5
   6#include <stddef.h>
   7#include <stdint.h>
   8
   9/* Verbs headers do not support -pedantic. */
  10#ifdef PEDANTIC
  11#pragma GCC diagnostic ignored "-Wpedantic"
  12#endif
  13#include <infiniband/mlx4dv.h>
  14#include <infiniband/verbs.h>
  15#ifdef PEDANTIC
  16#pragma GCC diagnostic error "-Wpedantic"
  17#endif
  18
  19#include "mlx4_glue.h"
  20
  21static int
  22mlx4_glue_fork_init(void)
  23{
  24        return ibv_fork_init();
  25}
  26
  27static int
  28mlx4_glue_get_async_event(struct ibv_context *context,
  29                          struct ibv_async_event *event)
  30{
  31        return ibv_get_async_event(context, event);
  32}
  33
  34static void
  35mlx4_glue_ack_async_event(struct ibv_async_event *event)
  36{
  37        ibv_ack_async_event(event);
  38}
  39
  40static struct ibv_pd *
  41mlx4_glue_alloc_pd(struct ibv_context *context)
  42{
  43        return ibv_alloc_pd(context);
  44}
  45
  46static int
  47mlx4_glue_dealloc_pd(struct ibv_pd *pd)
  48{
  49        return ibv_dealloc_pd(pd);
  50}
  51
  52static struct ibv_device **
  53mlx4_glue_get_device_list(int *num_devices)
  54{
  55        return ibv_get_device_list(num_devices);
  56}
  57
  58static void
  59mlx4_glue_free_device_list(struct ibv_device **list)
  60{
  61        ibv_free_device_list(list);
  62}
  63
  64static struct ibv_context *
  65mlx4_glue_open_device(struct ibv_device *device)
  66{
  67        return ibv_open_device(device);
  68}
  69
  70static int
  71mlx4_glue_close_device(struct ibv_context *context)
  72{
  73        return ibv_close_device(context);
  74}
  75
  76static const char *
  77mlx4_glue_get_device_name(struct ibv_device *device)
  78{
  79        return ibv_get_device_name(device);
  80}
  81
  82static int
  83mlx4_glue_query_device(struct ibv_context *context,
  84                       struct ibv_device_attr *device_attr)
  85{
  86        return ibv_query_device(context, device_attr);
  87}
  88
  89static int
  90mlx4_glue_query_device_ex(struct ibv_context *context,
  91                          const struct ibv_query_device_ex_input *input,
  92                          struct ibv_device_attr_ex *attr)
  93{
  94        return ibv_query_device_ex(context, input, attr);
  95}
  96
  97static int
  98mlx4_glue_query_port(struct ibv_context *context, uint8_t port_num,
  99                     struct ibv_port_attr *port_attr)
 100{
 101        return ibv_query_port(context, port_num, port_attr);
 102}
 103
 104static const char *
 105mlx4_glue_port_state_str(enum ibv_port_state port_state)
 106{
 107        return ibv_port_state_str(port_state);
 108}
 109
 110static struct ibv_comp_channel *
 111mlx4_glue_create_comp_channel(struct ibv_context *context)
 112{
 113        return ibv_create_comp_channel(context);
 114}
 115
 116static int
 117mlx4_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
 118{
 119        return ibv_destroy_comp_channel(channel);
 120}
 121
 122static struct ibv_cq *
 123mlx4_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
 124                    struct ibv_comp_channel *channel, int comp_vector)
 125{
 126        return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
 127}
 128
 129static int
 130mlx4_glue_destroy_cq(struct ibv_cq *cq)
 131{
 132        return ibv_destroy_cq(cq);
 133}
 134
 135static int
 136mlx4_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
 137                       void **cq_context)
 138{
 139        return ibv_get_cq_event(channel, cq, cq_context);
 140}
 141
 142static void
 143mlx4_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
 144{
 145        ibv_ack_cq_events(cq, nevents);
 146}
 147
 148static struct ibv_flow *
 149mlx4_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
 150{
 151        return ibv_create_flow(qp, flow);
 152}
 153
 154static int
 155mlx4_glue_destroy_flow(struct ibv_flow *flow_id)
 156{
 157        return ibv_destroy_flow(flow_id);
 158}
 159
 160static struct ibv_qp *
 161mlx4_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
 162{
 163        return ibv_create_qp(pd, qp_init_attr);
 164}
 165
 166static struct ibv_qp *
 167mlx4_glue_create_qp_ex(struct ibv_context *context,
 168                       struct ibv_qp_init_attr_ex *qp_init_attr_ex)
 169{
 170        return ibv_create_qp_ex(context, qp_init_attr_ex);
 171}
 172
 173static int
 174mlx4_glue_destroy_qp(struct ibv_qp *qp)
 175{
 176        return ibv_destroy_qp(qp);
 177}
 178
 179static int
 180mlx4_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
 181{
 182        return ibv_modify_qp(qp, attr, attr_mask);
 183}
 184
 185static struct ibv_mr *
 186mlx4_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
 187{
 188        return ibv_reg_mr(pd, addr, length, access);
 189}
 190
 191static int
 192mlx4_glue_dereg_mr(struct ibv_mr *mr)
 193{
 194        return ibv_dereg_mr(mr);
 195}
 196
 197static struct ibv_rwq_ind_table *
 198mlx4_glue_create_rwq_ind_table(struct ibv_context *context,
 199                               struct ibv_rwq_ind_table_init_attr *init_attr)
 200{
 201        return ibv_create_rwq_ind_table(context, init_attr);
 202}
 203
 204static int
 205mlx4_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
 206{
 207        return ibv_destroy_rwq_ind_table(rwq_ind_table);
 208}
 209
 210static struct ibv_wq *
 211mlx4_glue_create_wq(struct ibv_context *context,
 212                    struct ibv_wq_init_attr *wq_init_attr)
 213{
 214        return ibv_create_wq(context, wq_init_attr);
 215}
 216
 217static int
 218mlx4_glue_destroy_wq(struct ibv_wq *wq)
 219{
 220        return ibv_destroy_wq(wq);
 221}
 222static int
 223mlx4_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
 224{
 225        return ibv_modify_wq(wq, wq_attr);
 226}
 227
 228static int
 229mlx4_glue_dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
 230{
 231        return mlx4dv_init_obj(obj, obj_type);
 232}
 233
 234static int
 235mlx4_glue_dv_set_context_attr(struct ibv_context *context,
 236                              enum mlx4dv_set_ctx_attr_type attr_type,
 237                              void *attr)
 238{
 239        return mlx4dv_set_context_attr(context, attr_type, attr);
 240}
 241
 242const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){
 243        .version = MLX4_GLUE_VERSION,
 244        .fork_init = mlx4_glue_fork_init,
 245        .get_async_event = mlx4_glue_get_async_event,
 246        .ack_async_event = mlx4_glue_ack_async_event,
 247        .alloc_pd = mlx4_glue_alloc_pd,
 248        .dealloc_pd = mlx4_glue_dealloc_pd,
 249        .get_device_list = mlx4_glue_get_device_list,
 250        .free_device_list = mlx4_glue_free_device_list,
 251        .open_device = mlx4_glue_open_device,
 252        .close_device = mlx4_glue_close_device,
 253        .get_device_name = mlx4_glue_get_device_name,
 254        .query_device = mlx4_glue_query_device,
 255        .query_device_ex = mlx4_glue_query_device_ex,
 256        .query_port = mlx4_glue_query_port,
 257        .port_state_str = mlx4_glue_port_state_str,
 258        .create_comp_channel = mlx4_glue_create_comp_channel,
 259        .destroy_comp_channel = mlx4_glue_destroy_comp_channel,
 260        .create_cq = mlx4_glue_create_cq,
 261        .destroy_cq = mlx4_glue_destroy_cq,
 262        .get_cq_event = mlx4_glue_get_cq_event,
 263        .ack_cq_events = mlx4_glue_ack_cq_events,
 264        .create_flow = mlx4_glue_create_flow,
 265        .destroy_flow = mlx4_glue_destroy_flow,
 266        .create_qp = mlx4_glue_create_qp,
 267        .create_qp_ex = mlx4_glue_create_qp_ex,
 268        .destroy_qp = mlx4_glue_destroy_qp,
 269        .modify_qp = mlx4_glue_modify_qp,
 270        .reg_mr = mlx4_glue_reg_mr,
 271        .dereg_mr = mlx4_glue_dereg_mr,
 272        .create_rwq_ind_table = mlx4_glue_create_rwq_ind_table,
 273        .destroy_rwq_ind_table = mlx4_glue_destroy_rwq_ind_table,
 274        .create_wq = mlx4_glue_create_wq,
 275        .destroy_wq = mlx4_glue_destroy_wq,
 276        .modify_wq = mlx4_glue_modify_wq,
 277        .dv_init_obj = mlx4_glue_dv_init_obj,
 278        .dv_set_context_attr = mlx4_glue_dv_set_context_attr,
 279};
 280