LCOV - code coverage report
Current view: top level - drivers/common/mlx5/linux - mlx5_glue.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 2 268 0.7 %
Date: 2025-05-01 17:49:45 Functions: 1 120 0.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 30 3.3 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2018 6WIND S.A.
       3                 :            :  * Copyright 2018 Mellanox Technologies, Ltd
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <errno.h>
       7                 :            : #include <stdalign.h>
       8                 :            : #include <stddef.h>
       9                 :            : #include <stdint.h>
      10                 :            : #include <stdlib.h>
      11                 :            : /*
      12                 :            :  * Not needed by this file; included to work around the lack of off_t
      13                 :            :  * definition for mlx5dv.h with unpatched rdma-core versions.
      14                 :            :  */
      15                 :            : #include <sys/types.h>
      16                 :            : 
      17                 :            : #include "mlx5_glue.h"
      18                 :            : 
      19                 :            : #include <eal_export.h>
      20                 :            : 
      21                 :            : static int
      22                 :        252 : mlx5_glue_fork_init(void)
      23                 :            : {
      24                 :            : #ifdef HAVE_IBV_FORK_UNNEEDED
      25         [ -  + ]:        252 :         if (ibv_is_fork_initialized() == IBV_FORK_UNNEEDED)
      26                 :            :                 return 0; /* ibv_fork_init() not needed */
      27                 :            : #endif
      28                 :          0 :         return ibv_fork_init();
      29                 :            : }
      30                 :            : 
      31                 :            : static struct ibv_pd *
      32                 :          0 : mlx5_glue_alloc_pd(struct ibv_context *context)
      33                 :            : {
      34                 :          0 :         return ibv_alloc_pd(context);
      35                 :            : }
      36                 :            : 
      37                 :            : static int
      38                 :          0 : mlx5_glue_dealloc_pd(struct ibv_pd *pd)
      39                 :            : {
      40                 :          0 :         return ibv_dealloc_pd(pd);
      41                 :            : }
      42                 :            : 
      43                 :            : static struct ibv_pd *
      44                 :          0 : mlx5_glue_import_pd(struct ibv_context *context, uint32_t pd_handle)
      45                 :            : {
      46                 :            : #ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
      47                 :          0 :         return ibv_import_pd(context, pd_handle);
      48                 :            : #else
      49                 :            :         (void)context;
      50                 :            :         (void)pd_handle;
      51                 :            :         errno = ENOTSUP;
      52                 :            :         return NULL;
      53                 :            : #endif
      54                 :            : }
      55                 :            : 
      56                 :            : static int
      57                 :          0 : mlx5_glue_unimport_pd(struct ibv_pd *pd)
      58                 :            : {
      59                 :            : #ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
      60                 :          0 :         ibv_unimport_pd(pd);
      61                 :          0 :         return 0;
      62                 :            : #else
      63                 :            :         (void)pd;
      64                 :            :         errno = ENOTSUP;
      65                 :            :         return -errno;
      66                 :            : #endif
      67                 :            : }
      68                 :            : 
      69                 :            : static struct ibv_device **
      70                 :          0 : mlx5_glue_get_device_list(int *num_devices)
      71                 :            : {
      72                 :          0 :         return ibv_get_device_list(num_devices);
      73                 :            : }
      74                 :            : 
      75                 :            : static void
      76                 :          0 : mlx5_glue_free_device_list(struct ibv_device **list)
      77                 :            : {
      78                 :          0 :         ibv_free_device_list(list);
      79                 :          0 : }
      80                 :            : 
      81                 :            : static struct ibv_context *
      82                 :          0 : mlx5_glue_open_device(struct ibv_device *device)
      83                 :            : {
      84                 :          0 :         return ibv_open_device(device);
      85                 :            : }
      86                 :            : 
      87                 :            : static struct ibv_context *
      88                 :          0 : mlx5_glue_import_device(int cmd_fd)
      89                 :            : {
      90                 :            : #ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
      91                 :          0 :         return ibv_import_device(cmd_fd);
      92                 :            : #else
      93                 :            :         (void)cmd_fd;
      94                 :            :         errno = ENOTSUP;
      95                 :            :         return NULL;
      96                 :            : #endif
      97                 :            : }
      98                 :            : 
      99                 :            : static int
     100                 :          0 : mlx5_glue_close_device(struct ibv_context *context)
     101                 :            : {
     102                 :          0 :         return ibv_close_device(context);
     103                 :            : }
     104                 :            : 
     105                 :            : static int
     106                 :          0 : mlx5_glue_query_device(struct ibv_context *context,
     107                 :            :                        struct ibv_device_attr *device_attr)
     108                 :            : {
     109                 :          0 :         return ibv_query_device(context, device_attr);
     110                 :            : }
     111                 :            : 
     112                 :            : static int
     113                 :          0 : mlx5_glue_query_device_ex(struct ibv_context *context,
     114                 :            :                           const struct ibv_query_device_ex_input *input,
     115                 :            :                           struct ibv_device_attr_ex *attr)
     116                 :            : {
     117                 :          0 :         return ibv_query_device_ex(context, input, attr);
     118                 :            : }
     119                 :            : 
     120                 :            : static const char *
     121                 :          0 : mlx5_glue_get_device_name(struct ibv_device *device)
     122                 :            : {
     123                 :          0 :         return ibv_get_device_name(device);
     124                 :            : }
     125                 :            : 
     126                 :            : static int
     127         [ #  # ]:          0 : mlx5_glue_query_rt_values_ex(struct ibv_context *context,
     128                 :            :                           struct ibv_values_ex *values)
     129                 :            : {
     130                 :          0 :         return ibv_query_rt_values_ex(context, values);
     131                 :            : }
     132                 :            : 
     133                 :            : static int
     134                 :          0 : mlx5_glue_query_port(struct ibv_context *context, uint8_t port_num,
     135                 :            :                      struct ibv_port_attr *port_attr)
     136                 :            : {
     137                 :          0 :         return ibv_query_port(context, port_num, port_attr);
     138                 :            : }
     139                 :            : 
     140                 :            : static struct ibv_comp_channel *
     141                 :          0 : mlx5_glue_create_comp_channel(struct ibv_context *context)
     142                 :            : {
     143                 :          0 :         return ibv_create_comp_channel(context);
     144                 :            : }
     145                 :            : 
     146                 :            : static int
     147                 :          0 : mlx5_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
     148                 :            : {
     149                 :          0 :         return ibv_destroy_comp_channel(channel);
     150                 :            : }
     151                 :            : 
     152                 :            : static struct ibv_cq *
     153                 :          0 : mlx5_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
     154                 :            :                     struct ibv_comp_channel *channel, int comp_vector)
     155                 :            : {
     156                 :          0 :         return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
     157                 :            : }
     158                 :            : 
     159                 :            : static int
     160                 :          0 : mlx5_glue_destroy_cq(struct ibv_cq *cq)
     161                 :            : {
     162                 :          0 :         return ibv_destroy_cq(cq);
     163                 :            : }
     164                 :            : 
     165                 :            : static int
     166                 :          0 : mlx5_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
     167                 :            :                        void **cq_context)
     168                 :            : {
     169                 :          0 :         return ibv_get_cq_event(channel, cq, cq_context);
     170                 :            : }
     171                 :            : 
     172                 :            : static void
     173                 :          0 : mlx5_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
     174                 :            : {
     175                 :          0 :         ibv_ack_cq_events(cq, nevents);
     176                 :          0 : }
     177                 :            : 
     178                 :            : static struct ibv_rwq_ind_table *
     179                 :          0 : mlx5_glue_create_rwq_ind_table(struct ibv_context *context,
     180                 :            :                                struct ibv_rwq_ind_table_init_attr *init_attr)
     181                 :            : {
     182                 :          0 :         return ibv_create_rwq_ind_table(context, init_attr);
     183                 :            : }
     184                 :            : 
     185                 :            : static int
     186         [ #  # ]:          0 : mlx5_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
     187                 :            : {
     188                 :          0 :         return ibv_destroy_rwq_ind_table(rwq_ind_table);
     189                 :            : }
     190                 :            : 
     191                 :            : static struct ibv_wq *
     192                 :          0 : mlx5_glue_create_wq(struct ibv_context *context,
     193                 :            :                     struct ibv_wq_init_attr *wq_init_attr)
     194                 :            : {
     195                 :          0 :         return ibv_create_wq(context, wq_init_attr);
     196                 :            : }
     197                 :            : 
     198                 :            : static int
     199         [ #  # ]:          0 : mlx5_glue_destroy_wq(struct ibv_wq *wq)
     200                 :            : {
     201                 :          0 :         return ibv_destroy_wq(wq);
     202                 :            : }
     203                 :            : static int
     204         [ #  # ]:          0 : mlx5_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
     205                 :            : {
     206                 :          0 :         return ibv_modify_wq(wq, wq_attr);
     207                 :            : }
     208                 :            : 
     209                 :            : static struct ibv_flow *
     210                 :          0 : mlx5_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
     211                 :            : {
     212                 :          0 :         return ibv_create_flow(qp, flow);
     213                 :            : }
     214                 :            : 
     215                 :            : static int
     216         [ #  # ]:          0 : mlx5_glue_destroy_flow(struct ibv_flow *flow_id)
     217                 :            : {
     218                 :          0 :         return ibv_destroy_flow(flow_id);
     219                 :            : }
     220                 :            : 
     221                 :            : static int
     222                 :          0 : mlx5_glue_destroy_flow_action(void *action)
     223                 :            : {
     224                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     225                 :            : #ifdef HAVE_MLX5DV_DR
     226                 :          0 :         return mlx5dv_dr_action_destroy(action);
     227                 :            : #else
     228                 :            :         struct mlx5dv_flow_action_attr *attr = action;
     229                 :            :         int res = 0;
     230                 :            :         switch (attr->type) {
     231                 :            :         case MLX5DV_FLOW_ACTION_TAG:
     232                 :            :                 break;
     233                 :            :         default:
     234                 :            :                 res = ibv_destroy_flow_action(attr->action);
     235                 :            :                 break;
     236                 :            :         }
     237                 :            :         free(action);
     238                 :            :         return res;
     239                 :            : #endif
     240                 :            : #else
     241                 :            :         (void)action;
     242                 :            :         return -ENOTSUP;
     243                 :            : #endif
     244                 :            : }
     245                 :            : 
     246                 :            : static struct ibv_qp *
     247                 :          0 : mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
     248                 :            : {
     249                 :          0 :         return ibv_create_qp(pd, qp_init_attr);
     250                 :            : }
     251                 :            : 
     252                 :            : static struct ibv_qp *
     253                 :          0 : mlx5_glue_create_qp_ex(struct ibv_context *context,
     254                 :            :                        struct ibv_qp_init_attr_ex *qp_init_attr_ex)
     255                 :            : {
     256                 :          0 :         return ibv_create_qp_ex(context, qp_init_attr_ex);
     257                 :            : }
     258                 :            : 
     259                 :            : static int
     260                 :          0 : mlx5_glue_destroy_qp(struct ibv_qp *qp)
     261                 :            : {
     262                 :          0 :         return ibv_destroy_qp(qp);
     263                 :            : }
     264                 :            : 
     265                 :            : static int
     266                 :          0 : mlx5_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
     267                 :            : {
     268                 :          0 :         return ibv_modify_qp(qp, attr, attr_mask);
     269                 :            : }
     270                 :            : 
     271                 :            : static struct ibv_mr *
     272                 :          0 : mlx5_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
     273                 :            : {
     274         [ #  # ]:          0 :         return ibv_reg_mr(pd, addr, length, access);
     275                 :            : }
     276                 :            : 
     277                 :            : static struct ibv_mr *
     278                 :          0 : mlx5_glue_reg_mr_iova(struct ibv_pd *pd, void *addr, size_t length,
     279                 :            :                       uint64_t iova, int access)
     280                 :            : {
     281                 :            : #ifdef HAVE_MLX5_IBV_REG_MR_IOVA
     282         [ #  # ]:          0 :                 return ibv_reg_mr_iova(pd, addr, length, iova, access);
     283                 :            : #else
     284                 :            :         (void)pd;
     285                 :            :         (void)addr;
     286                 :            :         (void)length;
     287                 :            :         (void)iova;
     288                 :            :         (void)access;
     289                 :            :         errno = ENOTSUP;
     290                 :            :         return NULL;
     291                 :            : #endif
     292                 :            : }
     293                 :            : 
     294                 :            : static struct ibv_mr *
     295                 :          0 : mlx5_glue_alloc_null_mr(struct ibv_pd *pd)
     296                 :            : {
     297                 :            : #ifdef HAVE_IBV_DEVX_OBJ
     298                 :          0 :         return ibv_alloc_null_mr(pd);
     299                 :            : #else
     300                 :            :         (void)pd;
     301                 :            :         errno = ENOTSUP;
     302                 :            :         return NULL;
     303                 :            : #endif
     304                 :            : }
     305                 :            : 
     306                 :            : static int
     307                 :          0 : mlx5_glue_dereg_mr(struct ibv_mr *mr)
     308                 :            : {
     309                 :          0 :         return ibv_dereg_mr(mr);
     310                 :            : }
     311                 :            : 
     312                 :            : static struct ibv_counter_set *
     313                 :          0 : mlx5_glue_create_counter_set(struct ibv_context *context,
     314                 :            :                              struct ibv_counter_set_init_attr *init_attr)
     315                 :            : {
     316                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
     317                 :            :         (void)context;
     318                 :            :         (void)init_attr;
     319                 :          0 :         return NULL;
     320                 :            : #else
     321                 :            :         return ibv_create_counter_set(context, init_attr);
     322                 :            : #endif
     323                 :            : }
     324                 :            : 
     325                 :            : static int
     326                 :          0 : mlx5_glue_destroy_counter_set(struct ibv_counter_set *cs)
     327                 :            : {
     328                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
     329                 :            :         (void)cs;
     330                 :          0 :         return -ENOTSUP;
     331                 :            : #else
     332                 :            :         return ibv_destroy_counter_set(cs);
     333                 :            : #endif
     334                 :            : }
     335                 :            : 
     336                 :            : static int
     337                 :          0 : mlx5_glue_describe_counter_set(struct ibv_context *context,
     338                 :            :                                uint16_t counter_set_id,
     339                 :            :                                struct ibv_counter_set_description *cs_desc)
     340                 :            : {
     341                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
     342                 :            :         (void)context;
     343                 :            :         (void)counter_set_id;
     344                 :            :         (void)cs_desc;
     345                 :          0 :         return -ENOTSUP;
     346                 :            : #else
     347                 :            :         return ibv_describe_counter_set(context, counter_set_id, cs_desc);
     348                 :            : #endif
     349                 :            : }
     350                 :            : 
     351                 :            : static int
     352                 :          0 : mlx5_glue_query_counter_set(struct ibv_query_counter_set_attr *query_attr,
     353                 :            :                             struct ibv_counter_set_data *cs_data)
     354                 :            : {
     355                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
     356                 :            :         (void)query_attr;
     357                 :            :         (void)cs_data;
     358                 :          0 :         return -ENOTSUP;
     359                 :            : #else
     360                 :            :         return ibv_query_counter_set(query_attr, cs_data);
     361                 :            : #endif
     362                 :            : }
     363                 :            : 
     364                 :            : static struct ibv_counters *
     365                 :          0 : mlx5_glue_create_counters(struct ibv_context *context,
     366                 :            :                           struct ibv_counters_init_attr *init_attr)
     367                 :            : {
     368                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
     369                 :            :         (void)context;
     370                 :            :         (void)init_attr;
     371                 :            :         errno = ENOTSUP;
     372                 :            :         return NULL;
     373                 :            : #else
     374                 :          0 :         return ibv_create_counters(context, init_attr);
     375                 :            : #endif
     376                 :            : }
     377                 :            : 
     378                 :            : static int
     379         [ #  # ]:          0 : mlx5_glue_destroy_counters(struct ibv_counters *counters)
     380                 :            : {
     381                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
     382                 :            :         (void)counters;
     383                 :            :         return -ENOTSUP;
     384                 :            : #else
     385                 :          0 :         return ibv_destroy_counters(counters);
     386                 :            : #endif
     387                 :            : }
     388                 :            : 
     389                 :            : static int
     390         [ #  # ]:          0 : mlx5_glue_attach_counters(struct ibv_counters *counters,
     391                 :            :                           struct ibv_counter_attach_attr *attr,
     392                 :            :                           struct ibv_flow *flow)
     393                 :            : {
     394                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
     395                 :            :         (void)counters;
     396                 :            :         (void)attr;
     397                 :            :         (void)flow;
     398                 :            :         return -ENOTSUP;
     399                 :            : #else
     400                 :          0 :         return ibv_attach_counters_point_flow(counters, attr, flow);
     401                 :            : #endif
     402                 :            : }
     403                 :            : 
     404                 :            : static int
     405         [ #  # ]:          0 : mlx5_glue_query_counters(struct ibv_counters *counters,
     406                 :            :                          uint64_t *counters_value,
     407                 :            :                          uint32_t ncounters,
     408                 :            :                          uint32_t flags)
     409                 :            : {
     410                 :            : #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
     411                 :            :         (void)counters;
     412                 :            :         (void)counters_value;
     413                 :            :         (void)ncounters;
     414                 :            :         (void)flags;
     415                 :            :         return -ENOTSUP;
     416                 :            : #else
     417                 :          0 :         return ibv_read_counters(counters, counters_value, ncounters, flags);
     418                 :            : #endif
     419                 :            : }
     420                 :            : 
     421                 :            : static void
     422                 :          0 : mlx5_glue_ack_async_event(struct ibv_async_event *event)
     423                 :            : {
     424                 :          0 :         ibv_ack_async_event(event);
     425                 :          0 : }
     426                 :            : 
     427                 :            : static int
     428                 :          0 : mlx5_glue_get_async_event(struct ibv_context *context,
     429                 :            :                           struct ibv_async_event *event)
     430                 :            : {
     431                 :          0 :         return ibv_get_async_event(context, event);
     432                 :            : }
     433                 :            : 
     434                 :            : static const char *
     435                 :          0 : mlx5_glue_port_state_str(enum ibv_port_state port_state)
     436                 :            : {
     437                 :          0 :         return ibv_port_state_str(port_state);
     438                 :            : }
     439                 :            : 
     440                 :            : static struct ibv_cq *
     441                 :          0 : mlx5_glue_cq_ex_to_cq(struct ibv_cq_ex *cq)
     442                 :            : {
     443                 :          0 :         return ibv_cq_ex_to_cq(cq);
     444                 :            : }
     445                 :            : 
     446                 :            : static void *
     447                 :          0 : mlx5_glue_dr_create_flow_action_dest_flow_tbl(void *tbl)
     448                 :            : {
     449                 :            : #ifdef HAVE_MLX5DV_DR
     450                 :          0 :         return mlx5dv_dr_action_create_dest_table(tbl);
     451                 :            : #else
     452                 :            :         (void)tbl;
     453                 :            :         errno = ENOTSUP;
     454                 :            :         return NULL;
     455                 :            : #endif
     456                 :            : }
     457                 :            : 
     458                 :            : static void *
     459                 :          0 : mlx5_glue_dr_create_flow_action_dest_port(void *domain, uint32_t port)
     460                 :            : {
     461                 :            : #ifdef HAVE_MLX5DV_DR_CREATE_DEST_IB_PORT
     462                 :          0 :         return mlx5dv_dr_action_create_dest_ib_port(domain, port);
     463                 :            : #else
     464                 :            : #ifdef HAVE_MLX5DV_DR_ESWITCH
     465                 :            :         return mlx5dv_dr_action_create_dest_vport(domain, port);
     466                 :            : #else
     467                 :            :         (void)domain;
     468                 :            :         (void)port;
     469                 :            :         errno = ENOTSUP;
     470                 :            :         return NULL;
     471                 :            : #endif
     472                 :            : #endif
     473                 :            : }
     474                 :            : 
     475                 :            : static void *
     476                 :          0 : mlx5_glue_dr_create_flow_action_drop(void)
     477                 :            : {
     478                 :            : #ifdef HAVE_MLX5DV_DR_ESWITCH
     479                 :          0 :         return mlx5dv_dr_action_create_drop();
     480                 :            : #else
     481                 :            :         errno = ENOTSUP;
     482                 :            :         return NULL;
     483                 :            : #endif
     484                 :            : }
     485                 :            : 
     486                 :            : static void *
     487                 :          0 : mlx5_glue_dr_create_flow_action_push_vlan(struct mlx5dv_dr_domain *domain,
     488                 :            :                                           rte_be32_t vlan_tag)
     489                 :            : {
     490                 :            : #ifdef HAVE_MLX5DV_DR_VLAN
     491                 :          0 :         return mlx5dv_dr_action_create_push_vlan(domain, vlan_tag);
     492                 :            : #else
     493                 :            :         (void)domain;
     494                 :            :         (void)vlan_tag;
     495                 :            :         errno = ENOTSUP;
     496                 :            :         return NULL;
     497                 :            : #endif
     498                 :            : }
     499                 :            : 
     500                 :            : static void *
     501                 :          0 : mlx5_glue_dr_create_flow_action_pop_vlan(void)
     502                 :            : {
     503                 :            : #ifdef HAVE_MLX5DV_DR_VLAN
     504                 :          0 :         return mlx5dv_dr_action_create_pop_vlan();
     505                 :            : #else
     506                 :            :         errno = ENOTSUP;
     507                 :            :         return NULL;
     508                 :            : #endif
     509                 :            : }
     510                 :            : 
     511                 :            : static void *
     512                 :          0 : mlx5_glue_dr_create_flow_tbl(void *domain, uint32_t level)
     513                 :            : {
     514                 :            : #ifdef HAVE_MLX5DV_DR
     515                 :          0 :         return mlx5dv_dr_table_create(domain, level);
     516                 :            : #else
     517                 :            :         (void)domain;
     518                 :            :         (void)level;
     519                 :            :         errno = ENOTSUP;
     520                 :            :         return NULL;
     521                 :            : #endif
     522                 :            : }
     523                 :            : 
     524                 :            : static int
     525                 :          0 : mlx5_glue_dr_destroy_flow_tbl(void *tbl)
     526                 :            : {
     527                 :            : #ifdef HAVE_MLX5DV_DR
     528                 :          0 :         return mlx5dv_dr_table_destroy(tbl);
     529                 :            : #else
     530                 :            :         (void)tbl;
     531                 :            :         errno = ENOTSUP;
     532                 :            :         return errno;
     533                 :            : #endif
     534                 :            : }
     535                 :            : 
     536                 :            : static void *
     537                 :          0 : mlx5_glue_dr_create_domain(struct ibv_context *ctx,
     538                 :            :                            enum  mlx5dv_dr_domain_type domain)
     539                 :            : {
     540                 :            : #ifdef HAVE_MLX5DV_DR
     541                 :          0 :         return mlx5dv_dr_domain_create(ctx, domain);
     542                 :            : #else
     543                 :            :         (void)ctx;
     544                 :            :         (void)domain;
     545                 :            :         errno = ENOTSUP;
     546                 :            :         return NULL;
     547                 :            : #endif
     548                 :            : }
     549                 :            : 
     550                 :            : static int
     551                 :          0 : mlx5_glue_dr_destroy_domain(void *domain)
     552                 :            : {
     553                 :            : #ifdef HAVE_MLX5DV_DR
     554                 :          0 :         return mlx5dv_dr_domain_destroy(domain);
     555                 :            : #else
     556                 :            :         (void)domain;
     557                 :            :         errno = ENOTSUP;
     558                 :            :         return errno;
     559                 :            : #endif
     560                 :            : }
     561                 :            : 
     562                 :            : static int
     563                 :          0 : mlx5_glue_dr_sync_domain(void *domain, uint32_t flags)
     564                 :            : {
     565                 :            : #ifdef HAVE_MLX5DV_DR
     566                 :          0 :         return mlx5dv_dr_domain_sync(domain, flags);
     567                 :            : #else
     568                 :            :         (void)domain;
     569                 :            :         (void)flags;
     570                 :            :         errno = ENOTSUP;
     571                 :            :         return errno;
     572                 :            : #endif
     573                 :            : }
     574                 :            : 
     575                 :            : static struct ibv_cq_ex *
     576                 :          0 : mlx5_glue_dv_create_cq(struct ibv_context *context,
     577                 :            :                        struct ibv_cq_init_attr_ex *cq_attr,
     578                 :            :                        struct mlx5dv_cq_init_attr *mlx5_cq_attr)
     579                 :            : {
     580                 :          0 :         return mlx5dv_create_cq(context, cq_attr, mlx5_cq_attr);
     581                 :            : }
     582                 :            : 
     583                 :            : static struct ibv_wq *
     584                 :          0 : mlx5_glue_dv_create_wq(struct ibv_context *context,
     585                 :            :                        struct ibv_wq_init_attr *wq_attr,
     586                 :            :                        struct mlx5dv_wq_init_attr *mlx5_wq_attr)
     587                 :            : {
     588                 :            : #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
     589                 :            :         (void)context;
     590                 :            :         (void)wq_attr;
     591                 :            :         (void)mlx5_wq_attr;
     592                 :            :         errno = ENOTSUP;
     593                 :            :         return NULL;
     594                 :            : #else
     595                 :          0 :         return mlx5dv_create_wq(context, wq_attr, mlx5_wq_attr);
     596                 :            : #endif
     597                 :            : }
     598                 :            : 
     599                 :            : static int
     600                 :          0 : mlx5_glue_dv_query_device(struct ibv_context *ctx,
     601                 :            :                           struct mlx5dv_context *attrs_out)
     602                 :            : {
     603                 :          0 :         return mlx5dv_query_device(ctx, attrs_out);
     604                 :            : }
     605                 :            : 
     606                 :            : static int
     607                 :          0 : mlx5_glue_dv_set_context_attr(struct ibv_context *ibv_ctx,
     608                 :            :                               enum mlx5dv_set_ctx_attr_type type, void *attr)
     609                 :            : {
     610                 :          0 :         return mlx5dv_set_context_attr(ibv_ctx, type, attr);
     611                 :            : }
     612                 :            : 
     613                 :            : static int
     614                 :          0 : mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
     615                 :            : {
     616                 :          0 :         return mlx5dv_init_obj(obj, obj_type);
     617                 :            : }
     618                 :            : 
     619                 :            : static struct ibv_qp *
     620                 :          0 : mlx5_glue_dv_create_qp(struct ibv_context *context,
     621                 :            :                        struct ibv_qp_init_attr_ex *qp_init_attr_ex,
     622                 :            :                        struct mlx5dv_qp_init_attr *dv_qp_init_attr)
     623                 :            : {
     624                 :            : #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
     625                 :          0 :         return mlx5dv_create_qp(context, qp_init_attr_ex, dv_qp_init_attr);
     626                 :            : #else
     627                 :            :         (void)context;
     628                 :            :         (void)qp_init_attr_ex;
     629                 :            :         (void)dv_qp_init_attr;
     630                 :            :         errno = ENOTSUP;
     631                 :            :         return NULL;
     632                 :            : #endif
     633                 :            : }
     634                 :            : 
     635                 :            : static void *
     636                 :          0 : __mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
     637                 :            :                 struct mlx5dv_flow_matcher_attr *matcher_attr)
     638                 :            : {
     639                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     640                 :          0 :         return mlx5dv_create_flow_matcher(context, matcher_attr);
     641                 :            : #else
     642                 :            :         (void)context;
     643                 :            :         (void)matcher_attr;
     644                 :            :         errno = ENOTSUP;
     645                 :            :         return NULL;
     646                 :            : #endif
     647                 :            : }
     648                 :            : 
     649                 :            : static void *
     650                 :          0 : mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
     651                 :            :                                  struct mlx5dv_flow_matcher_attr *matcher_attr,
     652                 :            :                                  void *tbl)
     653                 :            : {
     654                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     655                 :            : #ifdef HAVE_MLX5DV_DR
     656                 :            :         (void)context;
     657                 :          0 :         return mlx5dv_dr_matcher_create(tbl, matcher_attr->priority,
     658                 :          0 :                                         matcher_attr->match_criteria_enable,
     659                 :            :                                         matcher_attr->match_mask);
     660                 :            : #else
     661                 :            :         (void)tbl;
     662                 :            :         return __mlx5_glue_dv_create_flow_matcher(context, matcher_attr);
     663                 :            : #endif
     664                 :            : #else
     665                 :            :         (void)context;
     666                 :            :         (void)matcher_attr;
     667                 :            :         (void)tbl;
     668                 :            :         errno = ENOTSUP;
     669                 :            :         return NULL;
     670                 :            : #endif
     671                 :            : }
     672                 :            : 
     673                 :            : static void *
     674                 :          0 : __mlx5_glue_dv_create_flow(void *matcher,
     675                 :            :                            void *match_value,
     676                 :            :                            size_t num_actions,
     677                 :            :                            void *actions)
     678                 :            : {
     679                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     680                 :          0 :         return mlx5dv_create_flow(matcher,
     681                 :            :                                   match_value,
     682                 :            :                                   num_actions,
     683                 :            :                                   (struct mlx5dv_flow_action_attr *)actions);
     684                 :            : #else
     685                 :            :         (void)matcher;
     686                 :            :         (void)match_value;
     687                 :            :         (void)num_actions;
     688                 :            :         (void)actions;
     689                 :            :         return NULL;
     690                 :            : #endif
     691                 :            : }
     692                 :            : 
     693                 :            : static void *
     694                 :          0 : mlx5_glue_dv_create_flow(void *matcher,
     695                 :            :                          void *match_value,
     696                 :            :                          size_t num_actions,
     697                 :            :                          void *actions[])
     698                 :            : {
     699                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     700                 :            : #ifdef HAVE_MLX5DV_DR
     701                 :          0 :         return mlx5dv_dr_rule_create(matcher, match_value, num_actions,
     702                 :            :                                      (struct mlx5dv_dr_action **)actions);
     703                 :            : #else
     704                 :            :         size_t i;
     705                 :            :         struct mlx5dv_flow_action_attr actions_attr[8];
     706                 :            : 
     707                 :            :         if (num_actions > 8)
     708                 :            :                 return NULL;
     709                 :            :         for (i = 0; i < num_actions; i++)
     710                 :            :                 actions_attr[i] =
     711                 :            :                         *((struct mlx5dv_flow_action_attr *)(actions[i]));
     712                 :            :         return __mlx5_glue_dv_create_flow(matcher, match_value,
     713                 :            :                                           num_actions, actions_attr);
     714                 :            : #endif
     715                 :            : #else
     716                 :            :         (void)matcher;
     717                 :            :         (void)match_value;
     718                 :            :         (void)num_actions;
     719                 :            :         (void)actions;
     720                 :            :         return NULL;
     721                 :            : #endif
     722                 :            : }
     723                 :            : 
     724                 :            : static void *
     725                 :          0 : mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
     726                 :            : {
     727                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     728                 :            : #ifdef HAVE_MLX5DV_DR
     729                 :          0 :         return mlx5dv_dr_action_create_flow_counter(counter_obj, offset);
     730                 :            : #else
     731                 :            :         struct mlx5dv_flow_action_attr *action;
     732                 :            : 
     733                 :            :         (void)offset;
     734                 :            :         action = malloc(sizeof(*action));
     735                 :            :         if (!action)
     736                 :            :                 return NULL;
     737                 :            :         action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
     738                 :            :         action->obj = counter_obj;
     739                 :            :         return action;
     740                 :            : #endif
     741                 :            : #else
     742                 :            :         (void)counter_obj;
     743                 :            :         (void)offset;
     744                 :            :         errno = ENOTSUP;
     745                 :            :         return NULL;
     746                 :            : #endif
     747                 :            : }
     748                 :            : 
     749                 :            : static void *
     750                 :          0 : mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
     751                 :            : {
     752                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     753                 :            : #ifdef HAVE_MLX5DV_DR
     754                 :          0 :         return mlx5dv_dr_action_create_dest_ibv_qp(qp);
     755                 :            : #else
     756                 :            :         struct mlx5dv_flow_action_attr *action;
     757                 :            : 
     758                 :            :         action = malloc(sizeof(*action));
     759                 :            :         if (!action)
     760                 :            :                 return NULL;
     761                 :            :         action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
     762                 :            :         action->obj = qp;
     763                 :            :         return action;
     764                 :            : #endif
     765                 :            : #else
     766                 :            :         (void)qp;
     767                 :            :         errno = ENOTSUP;
     768                 :            :         return NULL;
     769                 :            : #endif
     770                 :            : }
     771                 :            : 
     772                 :            : static void *
     773                 :          0 : mlx5_glue_dv_create_flow_action_dest_devx_tir(void *tir)
     774                 :            : {
     775                 :            : #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR
     776                 :          0 :         return mlx5dv_dr_action_create_dest_devx_tir(tir);
     777                 :            : #else
     778                 :            :         (void)tir;
     779                 :            :         errno = ENOTSUP;
     780                 :            :         return NULL;
     781                 :            : #endif
     782                 :            : }
     783                 :            : 
     784                 :            : static void *
     785                 :          0 : __mlx5_glue_dv_create_flow_action_modify_header
     786                 :            :                                         (struct ibv_context *ctx,
     787                 :            :                                          size_t actions_sz,
     788                 :            :                                          uint64_t actions[],
     789                 :            :                                          enum mlx5dv_flow_table_type ft_type)
     790                 :            : {
     791                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     792                 :          0 :         return mlx5dv_create_flow_action_modify_header
     793                 :            :                 (ctx, actions_sz, actions, ft_type);
     794                 :            : #else
     795                 :            :         (void)ctx;
     796                 :            :         (void)ft_type;
     797                 :            :         (void)actions_sz;
     798                 :            :         (void)actions;
     799                 :            :         errno = ENOTSUP;
     800                 :            :         return NULL;
     801                 :            : #endif
     802                 :            : }
     803                 :            : 
     804                 :            : static void *
     805                 :          0 : mlx5_glue_dv_create_flow_action_modify_header
     806                 :            :                                         (struct ibv_context *ctx,
     807                 :            :                                          enum mlx5dv_flow_table_type ft_type,
     808                 :            :                                          void *domain, uint64_t flags,
     809                 :            :                                          size_t actions_sz,
     810                 :            :                                          uint64_t actions[])
     811                 :            : {
     812                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     813                 :            : #ifdef HAVE_MLX5DV_DR
     814                 :            :         (void)ctx;
     815                 :            :         (void)ft_type;
     816                 :          0 :         return mlx5dv_dr_action_create_modify_header(domain, flags, actions_sz,
     817                 :            :                                                      (__be64 *)actions);
     818                 :            : #else
     819                 :            :         struct mlx5dv_flow_action_attr *action;
     820                 :            : 
     821                 :            :         (void)domain;
     822                 :            :         (void)flags;
     823                 :            :         action = malloc(sizeof(*action));
     824                 :            :         if (!action)
     825                 :            :                 return NULL;
     826                 :            :         action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
     827                 :            :         action->action = __mlx5_glue_dv_create_flow_action_modify_header
     828                 :            :                 (ctx, actions_sz, actions, ft_type);
     829                 :            :         return action;
     830                 :            : #endif
     831                 :            : #else
     832                 :            :         (void)ctx;
     833                 :            :         (void)ft_type;
     834                 :            :         (void)domain;
     835                 :            :         (void)flags;
     836                 :            :         (void)actions_sz;
     837                 :            :         (void)actions;
     838                 :            :         errno = ENOTSUP;
     839                 :            :         return NULL;
     840                 :            : #endif
     841                 :            : }
     842                 :            : 
     843                 :            : static void *
     844                 :          0 : __mlx5_glue_dv_create_flow_action_packet_reformat
     845                 :            :                 (struct ibv_context *ctx,
     846                 :            :                  size_t data_sz, void *data,
     847                 :            :                  enum mlx5dv_flow_action_packet_reformat_type reformat_type,
     848                 :            :                  enum mlx5dv_flow_table_type ft_type)
     849                 :            : {
     850                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     851                 :          0 :         return mlx5dv_create_flow_action_packet_reformat
     852                 :            :                 (ctx, data_sz, data, reformat_type, ft_type);
     853                 :            : #else
     854                 :            :         (void)ctx;
     855                 :            :         (void)reformat_type;
     856                 :            :         (void)ft_type;
     857                 :            :         (void)data_sz;
     858                 :            :         (void)data;
     859                 :            :         errno = ENOTSUP;
     860                 :            :         return NULL;
     861                 :            : #endif
     862                 :            : }
     863                 :            : 
     864                 :            : static void *
     865                 :          0 : mlx5_glue_dv_create_flow_action_packet_reformat
     866                 :            :                 (struct ibv_context *ctx,
     867                 :            :                  enum mlx5dv_flow_action_packet_reformat_type reformat_type,
     868                 :            :                  enum mlx5dv_flow_table_type ft_type,
     869                 :            :                  struct mlx5dv_dr_domain *domain,
     870                 :            :                  uint32_t flags, size_t data_sz, void *data)
     871                 :            : {
     872                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     873                 :            : #ifdef HAVE_MLX5DV_DR
     874                 :            :         (void)ctx;
     875                 :            :         (void)ft_type;
     876                 :          0 :         return mlx5dv_dr_action_create_packet_reformat(domain, flags,
     877                 :            :                                                        reformat_type, data_sz,
     878                 :            :                                                        data);
     879                 :            : #else
     880                 :            :         (void)domain;
     881                 :            :         (void)flags;
     882                 :            :         struct mlx5dv_flow_action_attr *action;
     883                 :            : 
     884                 :            :         action = malloc(sizeof(*action));
     885                 :            :         if (!action)
     886                 :            :                 return NULL;
     887                 :            :         action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
     888                 :            :         action->action = __mlx5_glue_dv_create_flow_action_packet_reformat
     889                 :            :                 (ctx, data_sz, data, reformat_type, ft_type);
     890                 :            :         return action;
     891                 :            : #endif
     892                 :            : #else
     893                 :            :         (void)ctx;
     894                 :            :         (void)reformat_type;
     895                 :            :         (void)ft_type;
     896                 :            :         (void)domain;
     897                 :            :         (void)flags;
     898                 :            :         (void)data_sz;
     899                 :            :         (void)data;
     900                 :            :         errno = ENOTSUP;
     901                 :            :         return NULL;
     902                 :            : #endif
     903                 :            : }
     904                 :            : 
     905                 :            : static void *
     906                 :          0 : mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
     907                 :            : {
     908                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
     909                 :            : #ifdef HAVE_MLX5DV_DR
     910                 :          0 :         return mlx5dv_dr_action_create_tag(tag);
     911                 :            : #else /* HAVE_MLX5DV_DR */
     912                 :            :         struct mlx5dv_flow_action_attr *action;
     913                 :            : 
     914                 :            :         action = malloc(sizeof(*action));
     915                 :            :         if (!action)
     916                 :            :                 return NULL;
     917                 :            :         action->type = MLX5DV_FLOW_ACTION_TAG;
     918                 :            :         action->tag_value = tag;
     919                 :            :         return action;
     920                 :            : #endif /* HAVE_MLX5DV_DR */
     921                 :            : #else /* HAVE_IBV_FLOW_DV_SUPPORT */
     922                 :            :         (void)tag;
     923                 :            :         errno = ENOTSUP;
     924                 :            :         return NULL;
     925                 :            : #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
     926                 :            : }
     927                 :            : 
     928                 :            : static void *
     929                 :          0 : mlx5_glue_dv_create_flow_action_meter(struct mlx5dv_dr_flow_meter_attr *attr)
     930                 :            : {
     931                 :            : #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
     932                 :          0 :         return mlx5dv_dr_action_create_flow_meter(attr);
     933                 :            : #else
     934                 :            :         (void)attr;
     935                 :            :         errno = ENOTSUP;
     936                 :            :         return NULL;
     937                 :            : #endif
     938                 :            : }
     939                 :            : 
     940                 :            : static int
     941                 :          0 : mlx5_glue_dv_modify_flow_action_meter(void *action,
     942                 :            :                                       struct mlx5dv_dr_flow_meter_attr *attr,
     943                 :            :                                       uint64_t modify_bits)
     944                 :            : {
     945                 :            : #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
     946                 :          0 :         return mlx5dv_dr_action_modify_flow_meter(action, attr, modify_bits);
     947                 :            : #else
     948                 :            :         (void)action;
     949                 :            :         (void)attr;
     950                 :            :         (void)modify_bits;
     951                 :            :         errno = ENOTSUP;
     952                 :            :         return errno;
     953                 :            : #endif
     954                 :            : }
     955                 :            : 
     956                 :            : static void *
     957                 :          0 : mlx5_glue_dv_create_flow_action_aso(struct mlx5dv_dr_domain *domain,
     958                 :            :                                     void *aso_obj,
     959                 :            :                                     uint32_t offset,
     960                 :            :                                     uint32_t flags,
     961                 :            :                                     uint8_t return_reg_c)
     962                 :            : {
     963                 :            : #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_ASO)
     964                 :          0 :         return mlx5dv_dr_action_create_aso(domain, aso_obj, offset,
     965                 :            :                                            flags, return_reg_c);
     966                 :            : #else
     967                 :            :         (void)domain;
     968                 :            :         (void)aso_obj;
     969                 :            :         (void)offset;
     970                 :            :         (void)flags;
     971                 :            :         (void)return_reg_c;
     972                 :            :         errno = ENOTSUP;
     973                 :            :         return NULL;
     974                 :            : #endif
     975                 :            : }
     976                 :            : 
     977                 :            : static void *
     978                 :          0 : mlx5_glue_dr_create_flow_action_default_miss(void)
     979                 :            : {
     980                 :            : #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS)
     981                 :          0 :         return mlx5dv_dr_action_create_default_miss();
     982                 :            : #else
     983                 :            :         errno = ENOTSUP;
     984                 :            :         return NULL;
     985                 :            : #endif
     986                 :            : }
     987                 :            : 
     988                 :            : static int
     989                 :          0 : mlx5_glue_dv_destroy_flow(void *flow_id)
     990                 :            : {
     991                 :            : #ifdef HAVE_MLX5DV_DR
     992                 :          0 :         return mlx5dv_dr_rule_destroy(flow_id);
     993                 :            : #else
     994                 :            :         return ibv_destroy_flow(flow_id);
     995                 :            : #endif
     996                 :            : }
     997                 :            : 
     998                 :            : static int
     999                 :          0 : __mlx5_glue_dv_destroy_flow_matcher(void *matcher)
    1000                 :            : {
    1001                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
    1002                 :          0 :         return mlx5dv_destroy_flow_matcher(matcher);
    1003                 :            : #else
    1004                 :            :         (void)matcher;
    1005                 :            :         errno = ENOTSUP;
    1006                 :            :         return errno;
    1007                 :            : #endif
    1008                 :            : }
    1009                 :            : 
    1010                 :            : static int
    1011                 :          0 : mlx5_glue_dv_destroy_flow_matcher(void *matcher)
    1012                 :            : {
    1013                 :            : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
    1014                 :            : #ifdef HAVE_MLX5DV_DR
    1015                 :          0 :         return mlx5dv_dr_matcher_destroy(matcher);
    1016                 :            : #else
    1017                 :            :         return __mlx5_glue_dv_destroy_flow_matcher(matcher);
    1018                 :            : #endif
    1019                 :            : #else
    1020                 :            :         (void)matcher;
    1021                 :            :         errno = ENOTSUP;
    1022                 :            :         return errno;
    1023                 :            : #endif
    1024                 :            : }
    1025                 :            : 
    1026                 :            : static struct ibv_context *
    1027                 :          0 : mlx5_glue_dv_open_device(struct ibv_device *device)
    1028                 :            : {
    1029                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1030                 :          0 :         return mlx5dv_open_device(device,
    1031                 :          0 :                                   &(struct mlx5dv_context_attr){
    1032                 :            :                                         .flags = MLX5DV_CONTEXT_FLAGS_DEVX,
    1033                 :            :                                   });
    1034                 :            : #else
    1035                 :            :         (void)device;
    1036                 :            :         errno = ENOTSUP;
    1037                 :            :         return NULL;
    1038                 :            : #endif
    1039                 :            : }
    1040                 :            : 
    1041                 :            : static struct mlx5dv_devx_obj *
    1042                 :          0 : mlx5_glue_devx_obj_create(struct ibv_context *ctx,
    1043                 :            :                           const void *in, size_t inlen,
    1044                 :            :                           void *out, size_t outlen)
    1045                 :            : {
    1046                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1047                 :          0 :         return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
    1048                 :            : #else
    1049                 :            :         (void)ctx;
    1050                 :            :         (void)in;
    1051                 :            :         (void)inlen;
    1052                 :            :         (void)out;
    1053                 :            :         (void)outlen;
    1054                 :            :         errno = ENOTSUP;
    1055                 :            :         return NULL;
    1056                 :            : #endif
    1057                 :            : }
    1058                 :            : 
    1059                 :            : static int
    1060                 :          0 : mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
    1061                 :            : {
    1062                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1063                 :          0 :         return mlx5dv_devx_obj_destroy(obj);
    1064                 :            : #else
    1065                 :            :         (void)obj;
    1066                 :            :         return -ENOTSUP;
    1067                 :            : #endif
    1068                 :            : }
    1069                 :            : 
    1070                 :            : static int
    1071                 :          0 : mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
    1072                 :            :                          const void *in, size_t inlen,
    1073                 :            :                          void *out, size_t outlen)
    1074                 :            : {
    1075                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1076                 :          0 :         return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
    1077                 :            : #else
    1078                 :            :         (void)obj;
    1079                 :            :         (void)in;
    1080                 :            :         (void)inlen;
    1081                 :            :         (void)out;
    1082                 :            :         (void)outlen;
    1083                 :            :         return -ENOTSUP;
    1084                 :            : #endif
    1085                 :            : }
    1086                 :            : 
    1087                 :            : static int
    1088                 :          0 : mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
    1089                 :            :                           const void *in, size_t inlen,
    1090                 :            :                           void *out, size_t outlen)
    1091                 :            : {
    1092                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1093                 :          0 :         return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
    1094                 :            : #else
    1095                 :            :         (void)obj;
    1096                 :            :         (void)in;
    1097                 :            :         (void)inlen;
    1098                 :            :         (void)out;
    1099                 :            :         (void)outlen;
    1100                 :            :         return -ENOTSUP;
    1101                 :            : #endif
    1102                 :            : }
    1103                 :            : 
    1104                 :            : static int
    1105                 :          0 : mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
    1106                 :            :                            const void *in, size_t inlen,
    1107                 :            :                            void *out, size_t outlen)
    1108                 :            : {
    1109                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1110                 :          0 :         return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
    1111                 :            : #else
    1112                 :            :         (void)ctx;
    1113                 :            :         (void)in;
    1114                 :            :         (void)inlen;
    1115                 :            :         (void)out;
    1116                 :            :         (void)outlen;
    1117                 :            :         return -ENOTSUP;
    1118                 :            : #endif
    1119                 :            : }
    1120                 :            : 
    1121                 :            : static struct mlx5dv_devx_cmd_comp *
    1122                 :          0 : mlx5_glue_devx_create_cmd_comp(struct ibv_context *ctx)
    1123                 :            : {
    1124                 :            : #ifdef HAVE_IBV_DEVX_ASYNC
    1125                 :          0 :         return mlx5dv_devx_create_cmd_comp(ctx);
    1126                 :            : #else
    1127                 :            :         (void)ctx;
    1128                 :            :         errno = -ENOTSUP;
    1129                 :            :         return NULL;
    1130                 :            : #endif
    1131                 :            : }
    1132                 :            : 
    1133                 :            : static void
    1134                 :          0 : mlx5_glue_devx_destroy_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp)
    1135                 :            : {
    1136                 :            : #ifdef HAVE_IBV_DEVX_ASYNC
    1137                 :          0 :         mlx5dv_devx_destroy_cmd_comp(cmd_comp);
    1138                 :            : #else
    1139                 :            :         (void)cmd_comp;
    1140                 :            :         errno = -ENOTSUP;
    1141                 :            : #endif
    1142                 :          0 : }
    1143                 :            : 
    1144                 :            : static int
    1145                 :          0 : mlx5_glue_devx_obj_query_async(struct mlx5dv_devx_obj *obj, const void *in,
    1146                 :            :                                size_t inlen, size_t outlen, uint64_t wr_id,
    1147                 :            :                                struct mlx5dv_devx_cmd_comp *cmd_comp)
    1148                 :            : {
    1149                 :            : #ifdef HAVE_IBV_DEVX_ASYNC
    1150                 :          0 :         return mlx5dv_devx_obj_query_async(obj, in, inlen, outlen, wr_id,
    1151                 :            :                                            cmd_comp);
    1152                 :            : #else
    1153                 :            :         (void)obj;
    1154                 :            :         (void)in;
    1155                 :            :         (void)inlen;
    1156                 :            :         (void)outlen;
    1157                 :            :         (void)wr_id;
    1158                 :            :         (void)cmd_comp;
    1159                 :            :         return -ENOTSUP;
    1160                 :            : #endif
    1161                 :            : }
    1162                 :            : 
    1163                 :            : static int
    1164                 :          0 : mlx5_glue_devx_get_async_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp,
    1165                 :            :                                   struct mlx5dv_devx_async_cmd_hdr *cmd_resp,
    1166                 :            :                                   size_t cmd_resp_len)
    1167                 :            : {
    1168                 :            : #ifdef HAVE_IBV_DEVX_ASYNC
    1169                 :          0 :         return mlx5dv_devx_get_async_cmd_comp(cmd_comp, cmd_resp,
    1170                 :            :                                               cmd_resp_len);
    1171                 :            : #else
    1172                 :            :         (void)cmd_comp;
    1173                 :            :         (void)cmd_resp;
    1174                 :            :         (void)cmd_resp_len;
    1175                 :            :         return -ENOTSUP;
    1176                 :            : #endif
    1177                 :            : }
    1178                 :            : 
    1179                 :            : static struct mlx5dv_devx_umem *
    1180                 :          0 : mlx5_glue_devx_umem_reg(struct ibv_context *context, void *addr, size_t size,
    1181                 :            :                         uint32_t access)
    1182                 :            : {
    1183                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1184                 :          0 :         return mlx5dv_devx_umem_reg(context, addr, size, access);
    1185                 :            : #else
    1186                 :            :         (void)context;
    1187                 :            :         (void)addr;
    1188                 :            :         (void)size;
    1189                 :            :         (void)access;
    1190                 :            :         errno = -ENOTSUP;
    1191                 :            :         return NULL;
    1192                 :            : #endif
    1193                 :            : }
    1194                 :            : 
    1195                 :            : static int
    1196                 :          0 : mlx5_glue_devx_umem_dereg(struct mlx5dv_devx_umem *dv_devx_umem)
    1197                 :            : {
    1198                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1199                 :          0 :         return mlx5dv_devx_umem_dereg(dv_devx_umem);
    1200                 :            : #else
    1201                 :            :         (void)dv_devx_umem;
    1202                 :            :         return -ENOTSUP;
    1203                 :            : #endif
    1204                 :            : }
    1205                 :            : 
    1206                 :            : static int
    1207                 :          0 : mlx5_glue_devx_qp_query(struct ibv_qp *qp,
    1208                 :            :                         const void *in, size_t inlen,
    1209                 :            :                         void *out, size_t outlen)
    1210                 :            : {
    1211                 :            : #ifdef HAVE_IBV_DEVX_QP
    1212                 :          0 :         return mlx5dv_devx_qp_query(qp, in, inlen, out, outlen);
    1213                 :            : #else
    1214                 :            :         (void)qp;
    1215                 :            :         (void)in;
    1216                 :            :         (void)inlen;
    1217                 :            :         (void)out;
    1218                 :            :         (void)outlen;
    1219                 :            :         errno = ENOTSUP;
    1220                 :            :         return errno;
    1221                 :            : #endif
    1222                 :            : }
    1223                 :            : 
    1224                 :            : static int
    1225                 :          0 : mlx5_glue_devx_wq_query(struct ibv_wq *wq, const void *in, size_t inlen,
    1226                 :            :                         void *out, size_t outlen)
    1227                 :            : {
    1228                 :            : #ifdef HAVE_IBV_DEVX_QP
    1229                 :          0 :         return mlx5dv_devx_wq_query(wq, in, inlen, out, outlen);
    1230                 :            : #else
    1231                 :            :         (void)wq;
    1232                 :            :         (void)in;
    1233                 :            :         (void)inlen;
    1234                 :            :         (void)out;
    1235                 :            :         (void)outlen;
    1236                 :            :         errno = ENOTSUP;
    1237                 :            :         return errno;
    1238                 :            : #endif
    1239                 :            : }
    1240                 :            : 
    1241                 :            : static int
    1242                 :          0 : mlx5_glue_devx_port_query(struct ibv_context *ctx,
    1243                 :            :                           uint32_t port_num,
    1244                 :            :                           struct mlx5_port_info *info)
    1245                 :            : {
    1246                 :            :         int err = 0;
    1247                 :            : 
    1248                 :          0 :         info->query_flags = 0;
    1249                 :            : #ifdef HAVE_MLX5DV_DR_DEVX_PORT_V35
    1250                 :            :         /* The DevX port query API is implemented (rdma-core v35 and above). */
    1251                 :            :         struct mlx5_ib_uapi_query_port devx_port;
    1252                 :            : 
    1253                 :            :         memset(&devx_port, 0, sizeof(devx_port));
    1254                 :            :         err = mlx5dv_query_port(ctx, port_num, &devx_port);
    1255         [ #  # ]:          0 :         if (err)
    1256                 :            :                 return err;
    1257         [ #  # ]:          0 :         if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT_REG_C0) {
    1258                 :          0 :                 info->vport_meta_tag = devx_port.reg_c0.value;
    1259                 :          0 :                 info->vport_meta_mask = devx_port.reg_c0.mask;
    1260                 :          0 :                 info->query_flags |= MLX5_PORT_QUERY_REG_C0;
    1261                 :            :         }
    1262         [ #  # ]:          0 :         if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT) {
    1263                 :          0 :                 info->vport_id = devx_port.vport;
    1264                 :          0 :                 info->query_flags |= MLX5_PORT_QUERY_VPORT;
    1265                 :            :         }
    1266         [ #  # ]:          0 :         if (devx_port.flags & MLX5DV_QUERY_PORT_ESW_OWNER_VHCA_ID) {
    1267                 :          0 :                 info->esw_owner_vhca_id = devx_port.esw_owner_vhca_id;
    1268                 :          0 :                 info->query_flags |= MLX5_PORT_QUERY_ESW_OWNER_VHCA_ID;
    1269                 :            :         }
    1270                 :            : #else
    1271                 :            : #ifdef HAVE_MLX5DV_DR_DEVX_PORT
    1272                 :            :         /* The legacy DevX port query API is implemented (prior v35). */
    1273                 :            :         struct mlx5dv_devx_port devx_port = {
    1274                 :            :                 .comp_mask = MLX5DV_DEVX_PORT_VPORT |
    1275                 :            :                              MLX5DV_DEVX_PORT_MATCH_REG_C_0 |
    1276                 :            :                              MLX5DV_DEVX_PORT_VPORT_VHCA_ID |
    1277                 :            :                              MLX5DV_DEVX_PORT_ESW_OWNER_VHCA_ID
    1278                 :            :         };
    1279                 :            : 
    1280                 :            :         err = mlx5dv_query_devx_port(ctx, port_num, &devx_port);
    1281                 :            :         if (err)
    1282                 :            :                 return err;
    1283                 :            :         if (devx_port.comp_mask & MLX5DV_DEVX_PORT_MATCH_REG_C_0) {
    1284                 :            :                 info->vport_meta_tag = devx_port.reg_c_0.value;
    1285                 :            :                 info->vport_meta_mask = devx_port.reg_c_0.mask;
    1286                 :            :                 info->query_flags |= MLX5_PORT_QUERY_REG_C0;
    1287                 :            :         }
    1288                 :            :         if (devx_port.comp_mask & MLX5DV_DEVX_PORT_VPORT) {
    1289                 :            :                 info->vport_id = devx_port.vport_num;
    1290                 :            :                 info->query_flags |= MLX5_PORT_QUERY_VPORT;
    1291                 :            :         }
    1292                 :            : #else
    1293                 :            :         RTE_SET_USED(ctx);
    1294                 :            :         RTE_SET_USED(port_num);
    1295                 :            : #endif /* HAVE_MLX5DV_DR_DEVX_PORT */
    1296                 :            : #endif /* HAVE_MLX5DV_DR_DEVX_PORT_V35 */
    1297                 :            :         return err;
    1298                 :            : }
    1299                 :            : 
    1300                 :            : static int
    1301                 :          0 : mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
    1302                 :            : {
    1303                 :            : #ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
    1304                 :          0 :         return mlx5dv_dump_dr_rule(file, rule);
    1305                 :            : #else
    1306                 :            :         RTE_SET_USED(file);
    1307                 :            :         RTE_SET_USED(rule);
    1308                 :            :         return -ENOTSUP;
    1309                 :            : #endif
    1310                 :            : }
    1311                 :            : 
    1312                 :            : static int
    1313                 :          0 : mlx5_glue_dr_dump_domain(FILE *file, void *domain)
    1314                 :            : {
    1315                 :            : #ifdef HAVE_MLX5_DR_FLOW_DUMP
    1316                 :          0 :         return mlx5dv_dump_dr_domain(file, domain);
    1317                 :            : #else
    1318                 :            :         RTE_SET_USED(file);
    1319                 :            :         RTE_SET_USED(domain);
    1320                 :            :         return -ENOTSUP;
    1321                 :            : #endif
    1322                 :            : }
    1323                 :            : 
    1324                 :            : static void *
    1325                 :          0 : mlx5_glue_dr_create_flow_action_sampler
    1326                 :            :                         (struct mlx5dv_dr_flow_sampler_attr *attr)
    1327                 :            : {
    1328                 :            : #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
    1329                 :          0 :         return mlx5dv_dr_action_create_flow_sampler(attr);
    1330                 :            : #else
    1331                 :            :         (void)attr;
    1332                 :            :         errno = ENOTSUP;
    1333                 :            :         return NULL;
    1334                 :            : #endif
    1335                 :            : }
    1336                 :            : 
    1337                 :            : static void *
    1338                 :          0 : mlx5_glue_dr_action_create_dest_array
    1339                 :            :                         (void *domain,
    1340                 :            :                          size_t num_dest,
    1341                 :            :                          struct mlx5dv_dr_action_dest_attr *dests[])
    1342                 :            : {
    1343                 :            : #ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
    1344                 :          0 :         return mlx5dv_dr_action_create_dest_array
    1345                 :            :                                 (domain,
    1346                 :            :                                 num_dest,
    1347                 :            :                                 dests);
    1348                 :            : #else
    1349                 :            :         (void)domain;
    1350                 :            :         (void)num_dest;
    1351                 :            :         (void)dests;
    1352                 :            :         errno = ENOTSUP;
    1353                 :            :         return NULL;
    1354                 :            : #endif
    1355                 :            : }
    1356                 :            : 
    1357                 :            : static int
    1358                 :          0 : mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
    1359                 :            :                          uint32_t *eqn)
    1360                 :            : {
    1361                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1362                 :          0 :         return mlx5dv_devx_query_eqn(ctx, cpus, eqn);
    1363                 :            : #else
    1364                 :            :         (void)ctx;
    1365                 :            :         (void)cpus;
    1366                 :            :         (void)eqn;
    1367                 :            :         return -ENOTSUP;
    1368                 :            : #endif
    1369                 :            : }
    1370                 :            : 
    1371                 :            : static struct mlx5dv_devx_event_channel *
    1372                 :          0 : mlx5_glue_devx_create_event_channel(struct ibv_context *ctx, int flags)
    1373                 :            : {
    1374                 :            : #ifdef HAVE_IBV_DEVX_EVENT
    1375                 :          0 :         return mlx5dv_devx_create_event_channel(ctx, flags);
    1376                 :            : #else
    1377                 :            :         (void)ctx;
    1378                 :            :         (void)flags;
    1379                 :            :         errno = ENOTSUP;
    1380                 :            :         return NULL;
    1381                 :            : #endif
    1382                 :            : }
    1383                 :            : 
    1384                 :            : static void
    1385                 :          0 : mlx5_glue_devx_destroy_event_channel(struct mlx5dv_devx_event_channel *eventc)
    1386                 :            : {
    1387                 :            : #ifdef HAVE_IBV_DEVX_EVENT
    1388                 :          0 :         mlx5dv_devx_destroy_event_channel(eventc);
    1389                 :            : #else
    1390                 :            :         (void)eventc;
    1391                 :            : #endif
    1392                 :          0 : }
    1393                 :            : 
    1394                 :            : static int
    1395                 :          0 : mlx5_glue_devx_subscribe_devx_event(struct mlx5dv_devx_event_channel *eventc,
    1396                 :            :                                     struct mlx5dv_devx_obj *obj,
    1397                 :            :                                     uint16_t events_sz, uint16_t events_num[],
    1398                 :            :                                     uint64_t cookie)
    1399                 :            : {
    1400                 :            : #ifdef HAVE_IBV_DEVX_EVENT
    1401                 :          0 :         return mlx5dv_devx_subscribe_devx_event(eventc, obj, events_sz,
    1402                 :            :                                                 events_num, cookie);
    1403                 :            : #else
    1404                 :            :         (void)eventc;
    1405                 :            :         (void)obj;
    1406                 :            :         (void)events_sz;
    1407                 :            :         (void)events_num;
    1408                 :            :         (void)cookie;
    1409                 :            :         return -ENOTSUP;
    1410                 :            : #endif
    1411                 :            : }
    1412                 :            : 
    1413                 :            : static int
    1414                 :          0 : mlx5_glue_devx_subscribe_devx_event_fd(struct mlx5dv_devx_event_channel *eventc,
    1415                 :            :                                        int fd, struct mlx5dv_devx_obj *obj,
    1416                 :            :                                        uint16_t event_num)
    1417                 :            : {
    1418                 :            : #ifdef HAVE_IBV_DEVX_EVENT
    1419                 :          0 :         return mlx5dv_devx_subscribe_devx_event_fd(eventc, fd, obj, event_num);
    1420                 :            : #else
    1421                 :            :         (void)eventc;
    1422                 :            :         (void)fd;
    1423                 :            :         (void)obj;
    1424                 :            :         (void)event_num;
    1425                 :            :         return -ENOTSUP;
    1426                 :            : #endif
    1427                 :            : }
    1428                 :            : 
    1429                 :            : static ssize_t
    1430                 :          0 : mlx5_glue_devx_get_event(struct mlx5dv_devx_event_channel *eventc,
    1431                 :            :                          struct mlx5dv_devx_async_event_hdr *event_data,
    1432                 :            :                          size_t event_resp_len)
    1433                 :            : {
    1434                 :            : #ifdef HAVE_IBV_DEVX_EVENT
    1435                 :          0 :         return mlx5dv_devx_get_event(eventc, event_data, event_resp_len);
    1436                 :            : #else
    1437                 :            :         (void)eventc;
    1438                 :            :         (void)event_data;
    1439                 :            :         (void)event_resp_len;
    1440                 :            :         errno = ENOTSUP;
    1441                 :            :         return -1;
    1442                 :            : #endif
    1443                 :            : }
    1444                 :            : 
    1445                 :            : static struct mlx5dv_devx_uar *
    1446                 :          0 : mlx5_glue_devx_alloc_uar(struct ibv_context *context, uint32_t flags)
    1447                 :            : {
    1448                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1449                 :          0 :         return mlx5dv_devx_alloc_uar(context, flags);
    1450                 :            : #else
    1451                 :            :         (void)context;
    1452                 :            :         (void)flags;
    1453                 :            :         errno = ENOTSUP;
    1454                 :            :         return NULL;
    1455                 :            : #endif
    1456                 :            : }
    1457                 :            : 
    1458                 :            : static void
    1459                 :          0 : mlx5_glue_devx_free_uar(struct mlx5dv_devx_uar *devx_uar)
    1460                 :            : {
    1461                 :            : #ifdef HAVE_IBV_DEVX_OBJ
    1462                 :          0 :         mlx5dv_devx_free_uar(devx_uar);
    1463                 :            : #else
    1464                 :            :         (void)devx_uar;
    1465                 :            : #endif
    1466                 :          0 : }
    1467                 :            : 
    1468                 :            : static struct mlx5dv_var *
    1469                 :          0 : mlx5_glue_dv_alloc_var(struct ibv_context *context, uint32_t flags)
    1470                 :            : {
    1471                 :            : #ifdef HAVE_IBV_VAR
    1472                 :          0 :         return mlx5dv_alloc_var(context, flags);
    1473                 :            : #else
    1474                 :            :         (void)context;
    1475                 :            :         (void)flags;
    1476                 :            :         errno = ENOTSUP;
    1477                 :            :         return NULL;
    1478                 :            : #endif
    1479                 :            : }
    1480                 :            : 
    1481                 :            : static void
    1482                 :          0 : mlx5_glue_dv_free_var(struct mlx5dv_var *var)
    1483                 :            : {
    1484                 :            : #ifdef HAVE_IBV_VAR
    1485                 :          0 :         mlx5dv_free_var(var);
    1486                 :            : #else
    1487                 :            :         (void)var;
    1488                 :            :         errno = ENOTSUP;
    1489                 :            : #endif
    1490                 :          0 : }
    1491                 :            : 
    1492                 :            : static void
    1493                 :          0 : mlx5_glue_dr_reclaim_domain_memory(void *domain, uint32_t enable)
    1494                 :            : {
    1495                 :            : #ifdef HAVE_MLX5DV_DR_MEM_RECLAIM
    1496                 :          0 :         mlx5dv_dr_domain_set_reclaim_device_memory(domain, enable);
    1497                 :            : #else
    1498                 :            :         (void)(enable);
    1499                 :            :         (void)(domain);
    1500                 :            : #endif
    1501                 :          0 : }
    1502                 :            : 
    1503                 :            : static struct mlx5dv_pp *
    1504                 :          0 : mlx5_glue_dv_alloc_pp(struct ibv_context *context,
    1505                 :            :                       size_t pp_context_sz,
    1506                 :            :                       const void *pp_context,
    1507                 :            :                       uint32_t flags)
    1508                 :            : {
    1509                 :            : #ifdef HAVE_MLX5DV_PP_ALLOC
    1510                 :          0 :         return mlx5dv_pp_alloc(context, pp_context_sz, pp_context, flags);
    1511                 :            : #else
    1512                 :            :         RTE_SET_USED(context);
    1513                 :            :         RTE_SET_USED(pp_context_sz);
    1514                 :            :         RTE_SET_USED(pp_context);
    1515                 :            :         RTE_SET_USED(flags);
    1516                 :            :         errno = ENOTSUP;
    1517                 :            :         return NULL;
    1518                 :            : #endif
    1519                 :            : }
    1520                 :            : 
    1521                 :            : static void
    1522                 :          0 : mlx5_glue_dr_allow_duplicate_rules(void *domain, uint32_t allow)
    1523                 :            : {
    1524                 :            : #ifdef HAVE_MLX5_DR_ALLOW_DUPLICATE
    1525                 :          0 :         mlx5dv_dr_domain_allow_duplicate_rules(domain, allow);
    1526                 :            : #else
    1527                 :            :         (void)(allow);
    1528                 :            :         (void)(domain);
    1529                 :            : #endif
    1530                 :          0 : }
    1531                 :            : 
    1532                 :            : static void
    1533                 :          0 : mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
    1534                 :            : {
    1535                 :            : #ifdef HAVE_MLX5DV_PP_ALLOC
    1536                 :          0 :         mlx5dv_pp_free(pp);
    1537                 :            : #else
    1538                 :            :         RTE_SET_USED(pp);
    1539                 :            : #endif
    1540                 :          0 : }
    1541                 :            : 
    1542                 :            : static void *
    1543                 :          0 : mlx5_glue_dr_create_flow_action_send_to_kernel(void *tbl, uint16_t priority)
    1544                 :            : {
    1545                 :            : #ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
    1546                 :            :         struct mlx5dv_dr_table *table = (struct mlx5dv_dr_table *)tbl;
    1547                 :            : 
    1548                 :            :         return mlx5dv_dr_action_create_dest_root_table(table, priority);
    1549                 :            : #else
    1550                 :            :         RTE_SET_USED(tbl);
    1551                 :            :         RTE_SET_USED(priority);
    1552                 :          0 :         errno = ENOTSUP;
    1553                 :          0 :         return NULL;
    1554                 :            : #endif
    1555                 :            : }
    1556                 :            : 
    1557                 :            : static struct mlx5dv_steering_anchor *
    1558                 :          0 : mlx5_glue_dv_create_steering_anchor(struct ibv_context *context,
    1559                 :            :                                     struct mlx5dv_steering_anchor_attr *attr)
    1560                 :            : {
    1561                 :            : #ifdef HAVE_MLX5DV_CREATE_STEERING_ANCHOR
    1562                 :            :         return mlx5dv_create_steering_anchor(context, attr);
    1563                 :            : #else
    1564                 :            :         (void)context;
    1565                 :            :         (void)attr;
    1566                 :          0 :         errno = ENOTSUP;
    1567                 :          0 :         return NULL;
    1568                 :            : #endif
    1569                 :            : }
    1570                 :            : 
    1571                 :            : static int
    1572                 :          0 : mlx5_glue_dv_destroy_steering_anchor(struct mlx5dv_steering_anchor *sa)
    1573                 :            : {
    1574                 :            : #ifdef HAVE_MLX5DV_CREATE_STEERING_ANCHOR
    1575                 :            :         return mlx5dv_destroy_steering_anchor(sa);
    1576                 :            : #else
    1577                 :            :         (void)sa;
    1578                 :          0 :         errno = ENOTSUP;
    1579                 :          0 :         return -ENOTSUP;
    1580                 :            : #endif
    1581                 :            : }
    1582                 :            : 
    1583                 :            : RTE_EXPORT_INTERNAL_SYMBOL(mlx5_glue)
    1584                 :            : alignas(RTE_CACHE_LINE_SIZE)
    1585                 :            : const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
    1586                 :            :         .version = MLX5_GLUE_VERSION,
    1587                 :            :         .fork_init = mlx5_glue_fork_init,
    1588                 :            :         .alloc_pd = mlx5_glue_alloc_pd,
    1589                 :            :         .dealloc_pd = mlx5_glue_dealloc_pd,
    1590                 :            :         .import_pd = mlx5_glue_import_pd,
    1591                 :            :         .unimport_pd = mlx5_glue_unimport_pd,
    1592                 :            :         .get_device_list = mlx5_glue_get_device_list,
    1593                 :            :         .free_device_list = mlx5_glue_free_device_list,
    1594                 :            :         .open_device = mlx5_glue_open_device,
    1595                 :            :         .import_device = mlx5_glue_import_device,
    1596                 :            :         .close_device = mlx5_glue_close_device,
    1597                 :            :         .query_device = mlx5_glue_query_device,
    1598                 :            :         .query_device_ex = mlx5_glue_query_device_ex,
    1599                 :            :         .get_device_name = mlx5_glue_get_device_name,
    1600                 :            :         .query_rt_values_ex = mlx5_glue_query_rt_values_ex,
    1601                 :            :         .query_port = mlx5_glue_query_port,
    1602                 :            :         .create_comp_channel = mlx5_glue_create_comp_channel,
    1603                 :            :         .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
    1604                 :            :         .create_cq = mlx5_glue_create_cq,
    1605                 :            :         .destroy_cq = mlx5_glue_destroy_cq,
    1606                 :            :         .get_cq_event = mlx5_glue_get_cq_event,
    1607                 :            :         .ack_cq_events = mlx5_glue_ack_cq_events,
    1608                 :            :         .create_rwq_ind_table = mlx5_glue_create_rwq_ind_table,
    1609                 :            :         .destroy_rwq_ind_table = mlx5_glue_destroy_rwq_ind_table,
    1610                 :            :         .create_wq = mlx5_glue_create_wq,
    1611                 :            :         .destroy_wq = mlx5_glue_destroy_wq,
    1612                 :            :         .modify_wq = mlx5_glue_modify_wq,
    1613                 :            :         .create_flow = mlx5_glue_create_flow,
    1614                 :            :         .destroy_flow = mlx5_glue_destroy_flow,
    1615                 :            :         .destroy_flow_action = mlx5_glue_destroy_flow_action,
    1616                 :            :         .create_qp = mlx5_glue_create_qp,
    1617                 :            :         .create_qp_ex = mlx5_glue_create_qp_ex,
    1618                 :            :         .destroy_qp = mlx5_glue_destroy_qp,
    1619                 :            :         .modify_qp = mlx5_glue_modify_qp,
    1620                 :            :         .reg_mr = mlx5_glue_reg_mr,
    1621                 :            :         .reg_mr_iova = mlx5_glue_reg_mr_iova,
    1622                 :            :         .alloc_null_mr = mlx5_glue_alloc_null_mr,
    1623                 :            :         .dereg_mr = mlx5_glue_dereg_mr,
    1624                 :            :         .create_counter_set = mlx5_glue_create_counter_set,
    1625                 :            :         .destroy_counter_set = mlx5_glue_destroy_counter_set,
    1626                 :            :         .describe_counter_set = mlx5_glue_describe_counter_set,
    1627                 :            :         .query_counter_set = mlx5_glue_query_counter_set,
    1628                 :            :         .create_counters = mlx5_glue_create_counters,
    1629                 :            :         .destroy_counters = mlx5_glue_destroy_counters,
    1630                 :            :         .attach_counters = mlx5_glue_attach_counters,
    1631                 :            :         .query_counters = mlx5_glue_query_counters,
    1632                 :            :         .ack_async_event = mlx5_glue_ack_async_event,
    1633                 :            :         .get_async_event = mlx5_glue_get_async_event,
    1634                 :            :         .port_state_str = mlx5_glue_port_state_str,
    1635                 :            :         .cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,
    1636                 :            :         .dr_create_flow_action_dest_flow_tbl =
    1637                 :            :                 mlx5_glue_dr_create_flow_action_dest_flow_tbl,
    1638                 :            :         .dr_create_flow_action_dest_port =
    1639                 :            :                 mlx5_glue_dr_create_flow_action_dest_port,
    1640                 :            :         .dr_create_flow_action_drop =
    1641                 :            :                 mlx5_glue_dr_create_flow_action_drop,
    1642                 :            :         .dr_create_flow_action_push_vlan =
    1643                 :            :                 mlx5_glue_dr_create_flow_action_push_vlan,
    1644                 :            :         .dr_create_flow_action_pop_vlan =
    1645                 :            :                 mlx5_glue_dr_create_flow_action_pop_vlan,
    1646                 :            :         .dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
    1647                 :            :         .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
    1648                 :            :         .dr_create_domain = mlx5_glue_dr_create_domain,
    1649                 :            :         .dr_destroy_domain = mlx5_glue_dr_destroy_domain,
    1650                 :            :         .dr_sync_domain = mlx5_glue_dr_sync_domain,
    1651                 :            :         .dv_create_cq = mlx5_glue_dv_create_cq,
    1652                 :            :         .dv_create_wq = mlx5_glue_dv_create_wq,
    1653                 :            :         .dv_query_device = mlx5_glue_dv_query_device,
    1654                 :            :         .dv_set_context_attr = mlx5_glue_dv_set_context_attr,
    1655                 :            :         .dv_init_obj = mlx5_glue_dv_init_obj,
    1656                 :            :         .dv_create_qp = mlx5_glue_dv_create_qp,
    1657                 :            :         .dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
    1658                 :            :         .dv_create_flow_matcher_root = __mlx5_glue_dv_create_flow_matcher,
    1659                 :            :         .dv_create_flow = mlx5_glue_dv_create_flow,
    1660                 :            :         .dv_create_flow_root = __mlx5_glue_dv_create_flow,
    1661                 :            :         .dv_create_flow_action_counter =
    1662                 :            :                 mlx5_glue_dv_create_flow_action_counter,
    1663                 :            :         .dv_create_flow_action_dest_ibv_qp =
    1664                 :            :                 mlx5_glue_dv_create_flow_action_dest_ibv_qp,
    1665                 :            :         .dv_create_flow_action_dest_devx_tir =
    1666                 :            :                 mlx5_glue_dv_create_flow_action_dest_devx_tir,
    1667                 :            :         .dv_create_flow_action_modify_header =
    1668                 :            :                 mlx5_glue_dv_create_flow_action_modify_header,
    1669                 :            :         .dv_create_flow_action_modify_header_root =
    1670                 :            :                 __mlx5_glue_dv_create_flow_action_modify_header,
    1671                 :            :         .dv_create_flow_action_packet_reformat =
    1672                 :            :                 mlx5_glue_dv_create_flow_action_packet_reformat,
    1673                 :            :         .dv_create_flow_action_packet_reformat_root =
    1674                 :            :                 __mlx5_glue_dv_create_flow_action_packet_reformat,
    1675                 :            :         .dv_create_flow_action_tag =  mlx5_glue_dv_create_flow_action_tag,
    1676                 :            :         .dv_create_flow_action_meter = mlx5_glue_dv_create_flow_action_meter,
    1677                 :            :         .dv_modify_flow_action_meter = mlx5_glue_dv_modify_flow_action_meter,
    1678                 :            :         .dv_create_flow_action_aso = mlx5_glue_dv_create_flow_action_aso,
    1679                 :            :         .dr_create_flow_action_default_miss =
    1680                 :            :                 mlx5_glue_dr_create_flow_action_default_miss,
    1681                 :            :         .dv_destroy_flow = mlx5_glue_dv_destroy_flow,
    1682                 :            :         .dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
    1683                 :            :         .dv_destroy_flow_matcher_root = __mlx5_glue_dv_destroy_flow_matcher,
    1684                 :            :         .dv_open_device = mlx5_glue_dv_open_device,
    1685                 :            :         .devx_obj_create = mlx5_glue_devx_obj_create,
    1686                 :            :         .devx_obj_destroy = mlx5_glue_devx_obj_destroy,
    1687                 :            :         .devx_obj_query = mlx5_glue_devx_obj_query,
    1688                 :            :         .devx_obj_modify = mlx5_glue_devx_obj_modify,
    1689                 :            :         .devx_general_cmd = mlx5_glue_devx_general_cmd,
    1690                 :            :         .devx_create_cmd_comp = mlx5_glue_devx_create_cmd_comp,
    1691                 :            :         .devx_destroy_cmd_comp = mlx5_glue_devx_destroy_cmd_comp,
    1692                 :            :         .devx_obj_query_async = mlx5_glue_devx_obj_query_async,
    1693                 :            :         .devx_get_async_cmd_comp = mlx5_glue_devx_get_async_cmd_comp,
    1694                 :            :         .devx_umem_reg = mlx5_glue_devx_umem_reg,
    1695                 :            :         .devx_umem_dereg = mlx5_glue_devx_umem_dereg,
    1696                 :            :         .devx_qp_query = mlx5_glue_devx_qp_query,
    1697                 :            :         .devx_wq_query = mlx5_glue_devx_wq_query,
    1698                 :            :         .devx_port_query = mlx5_glue_devx_port_query,
    1699                 :            :         .dr_dump_domain = mlx5_glue_dr_dump_domain,
    1700                 :            :         .dr_dump_rule = mlx5_glue_dr_dump_single_rule,
    1701                 :            :         .dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
    1702                 :            :         .dr_create_flow_action_sampler =
    1703                 :            :                 mlx5_glue_dr_create_flow_action_sampler,
    1704                 :            :         .dr_create_flow_action_dest_array =
    1705                 :            :                 mlx5_glue_dr_action_create_dest_array,
    1706                 :            :         .dr_allow_duplicate_rules = mlx5_glue_dr_allow_duplicate_rules,
    1707                 :            :         .devx_query_eqn = mlx5_glue_devx_query_eqn,
    1708                 :            :         .devx_create_event_channel = mlx5_glue_devx_create_event_channel,
    1709                 :            :         .devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
    1710                 :            :         .devx_subscribe_devx_event = mlx5_glue_devx_subscribe_devx_event,
    1711                 :            :         .devx_subscribe_devx_event_fd = mlx5_glue_devx_subscribe_devx_event_fd,
    1712                 :            :         .devx_get_event = mlx5_glue_devx_get_event,
    1713                 :            :         .devx_alloc_uar = mlx5_glue_devx_alloc_uar,
    1714                 :            :         .devx_free_uar = mlx5_glue_devx_free_uar,
    1715                 :            :         .dv_alloc_var = mlx5_glue_dv_alloc_var,
    1716                 :            :         .dv_free_var = mlx5_glue_dv_free_var,
    1717                 :            :         .dv_alloc_pp = mlx5_glue_dv_alloc_pp,
    1718                 :            :         .dv_free_pp = mlx5_glue_dv_free_pp,
    1719                 :            :         .dr_create_flow_action_send_to_kernel =
    1720                 :            :                 mlx5_glue_dr_create_flow_action_send_to_kernel,
    1721                 :            :         .create_steering_anchor = mlx5_glue_dv_create_steering_anchor,
    1722                 :            :         .destroy_steering_anchor = mlx5_glue_dv_destroy_steering_anchor,
    1723                 :            : };

Generated by: LCOV version 1.14