mlx5: manage all special flow types at once
[dpdk.git] / drivers / net / mlx5 / mlx5.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright 2015 6WIND S.A.
5  *   Copyright 2015 Mellanox.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of 6WIND S.A. nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <stddef.h>
35 #include <unistd.h>
36 #include <string.h>
37 #include <assert.h>
38 #include <stdint.h>
39 #include <stdlib.h>
40 #include <net/if.h>
41
42 /* Verbs header. */
43 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
44 #ifdef PEDANTIC
45 #pragma GCC diagnostic ignored "-pedantic"
46 #endif
47 #include <infiniband/verbs.h>
48 #ifdef PEDANTIC
49 #pragma GCC diagnostic error "-pedantic"
50 #endif
51
52 /* DPDK headers don't like -pedantic. */
53 #ifdef PEDANTIC
54 #pragma GCC diagnostic ignored "-pedantic"
55 #endif
56 #include <rte_malloc.h>
57 #include <rte_ethdev.h>
58 #include <rte_pci.h>
59 #include <rte_common.h>
60 #ifdef PEDANTIC
61 #pragma GCC diagnostic error "-pedantic"
62 #endif
63
64 #include "mlx5.h"
65 #include "mlx5_utils.h"
66 #include "mlx5_rxtx.h"
67 #include "mlx5_autoconf.h"
68 #include "mlx5_defs.h"
69
70 /**
71  * DPDK callback to close the device.
72  *
73  * Destroy all queues and objects, free memory.
74  *
75  * @param dev
76  *   Pointer to Ethernet device structure.
77  */
78 static void
79 mlx5_dev_close(struct rte_eth_dev *dev)
80 {
81         struct priv *priv = dev->data->dev_private;
82         void *tmp;
83         unsigned int i;
84
85         priv_lock(priv);
86         DEBUG("%p: closing device \"%s\"",
87               (void *)dev,
88               ((priv->ctx != NULL) ? priv->ctx->device->name : ""));
89         /* In case mlx5_dev_stop() has not been called. */
90         priv_dev_interrupt_handler_uninstall(priv, dev);
91         priv_special_flow_disable_all(priv);
92         priv_mac_addrs_disable(priv);
93         priv_destroy_hash_rxqs(priv);
94
95         /* Remove flow director elements. */
96         priv_fdir_disable(priv);
97         priv_fdir_delete_filters_list(priv);
98
99         /* Prevent crashes when queues are still in use. */
100         dev->rx_pkt_burst = removed_rx_burst;
101         dev->tx_pkt_burst = removed_tx_burst;
102         if (priv->rxqs != NULL) {
103                 /* XXX race condition if mlx5_rx_burst() is still running. */
104                 usleep(1000);
105                 for (i = 0; (i != priv->rxqs_n); ++i) {
106                         tmp = (*priv->rxqs)[i];
107                         if (tmp == NULL)
108                                 continue;
109                         (*priv->rxqs)[i] = NULL;
110                         rxq_cleanup(tmp);
111                         rte_free(tmp);
112                 }
113                 priv->rxqs_n = 0;
114                 priv->rxqs = NULL;
115         }
116         if (priv->txqs != NULL) {
117                 /* XXX race condition if mlx5_tx_burst() is still running. */
118                 usleep(1000);
119                 for (i = 0; (i != priv->txqs_n); ++i) {
120                         tmp = (*priv->txqs)[i];
121                         if (tmp == NULL)
122                                 continue;
123                         (*priv->txqs)[i] = NULL;
124                         txq_cleanup(tmp);
125                         rte_free(tmp);
126                 }
127                 priv->txqs_n = 0;
128                 priv->txqs = NULL;
129         }
130         if (priv->pd != NULL) {
131                 assert(priv->ctx != NULL);
132                 claim_zero(ibv_dealloc_pd(priv->pd));
133                 claim_zero(ibv_close_device(priv->ctx));
134         } else
135                 assert(priv->ctx == NULL);
136         if (priv->rss_conf != NULL) {
137                 for (i = 0; (i != hash_rxq_init_n); ++i)
138                         rte_free((*priv->rss_conf)[i]);
139                 rte_free(priv->rss_conf);
140         }
141         if (priv->reta_idx != NULL)
142                 rte_free(priv->reta_idx);
143         priv_unlock(priv);
144         memset(priv, 0, sizeof(*priv));
145 }
146
147 static const struct eth_dev_ops mlx5_dev_ops = {
148         .dev_configure = mlx5_dev_configure,
149         .dev_start = mlx5_dev_start,
150         .dev_stop = mlx5_dev_stop,
151         .dev_close = mlx5_dev_close,
152         .promiscuous_enable = mlx5_promiscuous_enable,
153         .promiscuous_disable = mlx5_promiscuous_disable,
154         .allmulticast_enable = mlx5_allmulticast_enable,
155         .allmulticast_disable = mlx5_allmulticast_disable,
156         .link_update = mlx5_link_update,
157         .stats_get = mlx5_stats_get,
158         .stats_reset = mlx5_stats_reset,
159         .dev_infos_get = mlx5_dev_infos_get,
160         .vlan_filter_set = mlx5_vlan_filter_set,
161         .rx_queue_setup = mlx5_rx_queue_setup,
162         .tx_queue_setup = mlx5_tx_queue_setup,
163         .rx_queue_release = mlx5_rx_queue_release,
164         .tx_queue_release = mlx5_tx_queue_release,
165         .flow_ctrl_get = mlx5_dev_get_flow_ctrl,
166         .flow_ctrl_set = mlx5_dev_set_flow_ctrl,
167         .mac_addr_remove = mlx5_mac_addr_remove,
168         .mac_addr_add = mlx5_mac_addr_add,
169         .mac_addr_set = mlx5_mac_addr_set,
170         .mtu_set = mlx5_dev_set_mtu,
171 #ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS
172         .vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
173         .vlan_offload_set = mlx5_vlan_offload_set,
174 #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */
175         .reta_update = mlx5_dev_rss_reta_update,
176         .reta_query = mlx5_dev_rss_reta_query,
177         .rss_hash_update = mlx5_rss_hash_update,
178         .rss_hash_conf_get = mlx5_rss_hash_conf_get,
179 #ifdef MLX5_FDIR_SUPPORT
180         .filter_ctrl = mlx5_dev_filter_ctrl,
181 #endif /* MLX5_FDIR_SUPPORT */
182 };
183
184 static struct {
185         struct rte_pci_addr pci_addr; /* associated PCI address */
186         uint32_t ports; /* physical ports bitfield. */
187 } mlx5_dev[32];
188
189 /**
190  * Get device index in mlx5_dev[] from PCI bus address.
191  *
192  * @param[in] pci_addr
193  *   PCI bus address to look for.
194  *
195  * @return
196  *   mlx5_dev[] index on success, -1 on failure.
197  */
198 static int
199 mlx5_dev_idx(struct rte_pci_addr *pci_addr)
200 {
201         unsigned int i;
202         int ret = -1;
203
204         assert(pci_addr != NULL);
205         for (i = 0; (i != RTE_DIM(mlx5_dev)); ++i) {
206                 if ((mlx5_dev[i].pci_addr.domain == pci_addr->domain) &&
207                     (mlx5_dev[i].pci_addr.bus == pci_addr->bus) &&
208                     (mlx5_dev[i].pci_addr.devid == pci_addr->devid) &&
209                     (mlx5_dev[i].pci_addr.function == pci_addr->function))
210                         return i;
211                 if ((mlx5_dev[i].ports == 0) && (ret == -1))
212                         ret = i;
213         }
214         return ret;
215 }
216
217 static struct eth_driver mlx5_driver;
218
219 /**
220  * DPDK callback to register a PCI device.
221  *
222  * This function creates an Ethernet device for each port of a given
223  * PCI device.
224  *
225  * @param[in] pci_drv
226  *   PCI driver structure (mlx5_driver).
227  * @param[in] pci_dev
228  *   PCI device information.
229  *
230  * @return
231  *   0 on success, negative errno value on failure.
232  */
233 static int
234 mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
235 {
236         struct ibv_device **list;
237         struct ibv_device *ibv_dev;
238         int err = 0;
239         struct ibv_context *attr_ctx = NULL;
240         struct ibv_device_attr device_attr;
241         unsigned int vf;
242         int idx;
243         int i;
244
245         (void)pci_drv;
246         assert(pci_drv == &mlx5_driver.pci_drv);
247         /* Get mlx5_dev[] index. */
248         idx = mlx5_dev_idx(&pci_dev->addr);
249         if (idx == -1) {
250                 ERROR("this driver cannot support any more adapters");
251                 return -ENOMEM;
252         }
253         DEBUG("using driver device index %d", idx);
254
255         /* Save PCI address. */
256         mlx5_dev[idx].pci_addr = pci_dev->addr;
257         list = ibv_get_device_list(&i);
258         if (list == NULL) {
259                 assert(errno);
260                 if (errno == ENOSYS) {
261                         WARN("cannot list devices, is ib_uverbs loaded?");
262                         return 0;
263                 }
264                 return -errno;
265         }
266         assert(i >= 0);
267         /*
268          * For each listed device, check related sysfs entry against
269          * the provided PCI ID.
270          */
271         while (i != 0) {
272                 struct rte_pci_addr pci_addr;
273
274                 --i;
275                 DEBUG("checking device \"%s\"", list[i]->name);
276                 if (mlx5_ibv_device_to_pci_addr(list[i], &pci_addr))
277                         continue;
278                 if ((pci_dev->addr.domain != pci_addr.domain) ||
279                     (pci_dev->addr.bus != pci_addr.bus) ||
280                     (pci_dev->addr.devid != pci_addr.devid) ||
281                     (pci_dev->addr.function != pci_addr.function))
282                         continue;
283                 vf = ((pci_dev->id.device_id ==
284                        PCI_DEVICE_ID_MELLANOX_CONNECTX4VF) ||
285                       (pci_dev->id.device_id ==
286                        PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF));
287                 INFO("PCI information matches, using device \"%s\" (VF: %s)",
288                      list[i]->name, (vf ? "true" : "false"));
289                 attr_ctx = ibv_open_device(list[i]);
290                 err = errno;
291                 break;
292         }
293         if (attr_ctx == NULL) {
294                 ibv_free_device_list(list);
295                 switch (err) {
296                 case 0:
297                         WARN("cannot access device, is mlx5_ib loaded?");
298                         return 0;
299                 case EINVAL:
300                         WARN("cannot use device, are drivers up to date?");
301                         return 0;
302                 }
303                 assert(err > 0);
304                 return -err;
305         }
306         ibv_dev = list[i];
307
308         DEBUG("device opened");
309         if (ibv_query_device(attr_ctx, &device_attr))
310                 goto error;
311         INFO("%u port(s) detected", device_attr.phys_port_cnt);
312
313         for (i = 0; i < device_attr.phys_port_cnt; i++) {
314                 uint32_t port = i + 1; /* ports are indexed from one */
315                 uint32_t test = (1 << i);
316                 struct ibv_context *ctx = NULL;
317                 struct ibv_port_attr port_attr;
318                 struct ibv_pd *pd = NULL;
319                 struct priv *priv = NULL;
320                 struct rte_eth_dev *eth_dev;
321 #ifdef HAVE_EXP_QUERY_DEVICE
322                 struct ibv_exp_device_attr exp_device_attr;
323 #endif /* HAVE_EXP_QUERY_DEVICE */
324                 struct ether_addr mac;
325
326 #ifdef HAVE_EXP_QUERY_DEVICE
327                 exp_device_attr.comp_mask =
328                         IBV_EXP_DEVICE_ATTR_EXP_CAP_FLAGS |
329                         IBV_EXP_DEVICE_ATTR_RX_HASH |
330 #ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS
331                         IBV_EXP_DEVICE_ATTR_VLAN_OFFLOADS |
332 #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */
333                         0;
334 #endif /* HAVE_EXP_QUERY_DEVICE */
335
336                 DEBUG("using port %u (%08" PRIx32 ")", port, test);
337
338                 ctx = ibv_open_device(ibv_dev);
339                 if (ctx == NULL)
340                         goto port_error;
341
342                 /* Check port status. */
343                 err = ibv_query_port(ctx, port, &port_attr);
344                 if (err) {
345                         ERROR("port query failed: %s", strerror(err));
346                         goto port_error;
347                 }
348
349                 if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
350                         ERROR("port %d is not configured in Ethernet mode",
351                               port);
352                         goto port_error;
353                 }
354
355                 if (port_attr.state != IBV_PORT_ACTIVE)
356                         DEBUG("port %d is not active: \"%s\" (%d)",
357                               port, ibv_port_state_str(port_attr.state),
358                               port_attr.state);
359
360                 /* Allocate protection domain. */
361                 pd = ibv_alloc_pd(ctx);
362                 if (pd == NULL) {
363                         ERROR("PD allocation failure");
364                         err = ENOMEM;
365                         goto port_error;
366                 }
367
368                 mlx5_dev[idx].ports |= test;
369
370                 /* from rte_ethdev.c */
371                 priv = rte_zmalloc("ethdev private structure",
372                                    sizeof(*priv),
373                                    RTE_CACHE_LINE_SIZE);
374                 if (priv == NULL) {
375                         ERROR("priv allocation failure");
376                         err = ENOMEM;
377                         goto port_error;
378                 }
379
380                 priv->ctx = ctx;
381                 priv->device_attr = device_attr;
382                 priv->port = port;
383                 priv->pd = pd;
384                 priv->mtu = ETHER_MTU;
385 #ifdef HAVE_EXP_QUERY_DEVICE
386                 if (ibv_exp_query_device(ctx, &exp_device_attr)) {
387                         ERROR("ibv_exp_query_device() failed");
388                         goto port_error;
389                 }
390
391                 priv->hw_csum =
392                         ((exp_device_attr.exp_device_cap_flags &
393                           IBV_EXP_DEVICE_RX_CSUM_TCP_UDP_PKT) &&
394                          (exp_device_attr.exp_device_cap_flags &
395                           IBV_EXP_DEVICE_RX_CSUM_IP_PKT));
396                 DEBUG("checksum offloading is %ssupported",
397                       (priv->hw_csum ? "" : "not "));
398
399                 priv->hw_csum_l2tun = !!(exp_device_attr.exp_device_cap_flags &
400                                          IBV_EXP_DEVICE_VXLAN_SUPPORT);
401                 DEBUG("L2 tunnel checksum offloads are %ssupported",
402                       (priv->hw_csum_l2tun ? "" : "not "));
403
404                 priv->ind_table_max_size = exp_device_attr.rx_hash_caps.max_rwq_indirection_table_size;
405                 /* Remove this check once DPDK supports larger/variable
406                  * indirection tables. */
407                 if (priv->ind_table_max_size > (unsigned int)RSS_INDIRECTION_TABLE_SIZE)
408                         priv->ind_table_max_size = RSS_INDIRECTION_TABLE_SIZE;
409                 DEBUG("maximum RX indirection table size is %u",
410                       priv->ind_table_max_size);
411 #ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS
412                 priv->hw_vlan_strip = !!(exp_device_attr.wq_vlan_offloads_cap &
413                                          IBV_EXP_RECEIVE_WQ_CVLAN_STRIP);
414 #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */
415                 DEBUG("VLAN stripping is %ssupported",
416                       (priv->hw_vlan_strip ? "" : "not "));
417
418 #else /* HAVE_EXP_QUERY_DEVICE */
419                 priv->ind_table_max_size = RSS_INDIRECTION_TABLE_SIZE;
420 #endif /* HAVE_EXP_QUERY_DEVICE */
421
422                 priv->vf = vf;
423                 /* Allocate and register default RSS hash keys. */
424                 priv->rss_conf = rte_calloc(__func__, hash_rxq_init_n,
425                                             sizeof((*priv->rss_conf)[0]), 0);
426                 if (priv->rss_conf == NULL) {
427                         err = ENOMEM;
428                         goto port_error;
429                 }
430                 err = rss_hash_rss_conf_new_key(priv,
431                                                 rss_hash_default_key,
432                                                 rss_hash_default_key_len,
433                                                 ETH_RSS_PROTO_MASK);
434                 if (err)
435                         goto port_error;
436                 /* Configure the first MAC address by default. */
437                 if (priv_get_mac(priv, &mac.addr_bytes)) {
438                         ERROR("cannot get MAC address, is mlx5_en loaded?"
439                               " (errno: %s)", strerror(errno));
440                         goto port_error;
441                 }
442                 INFO("port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
443                      priv->port,
444                      mac.addr_bytes[0], mac.addr_bytes[1],
445                      mac.addr_bytes[2], mac.addr_bytes[3],
446                      mac.addr_bytes[4], mac.addr_bytes[5]);
447                 /* Register MAC address. */
448                 claim_zero(priv_mac_addr_add(priv, 0,
449                                              (const uint8_t (*)[ETHER_ADDR_LEN])
450                                              mac.addr_bytes));
451                 /* Initialize FD filters list. */
452                 err = fdir_init_filters_list(priv);
453                 if (err)
454                         goto port_error;
455 #ifndef NDEBUG
456                 {
457                         char ifname[IF_NAMESIZE];
458
459                         if (priv_get_ifname(priv, &ifname) == 0)
460                                 DEBUG("port %u ifname is \"%s\"",
461                                       priv->port, ifname);
462                         else
463                                 DEBUG("port %u ifname is unknown", priv->port);
464                 }
465 #endif
466                 /* Get actual MTU if possible. */
467                 priv_get_mtu(priv, &priv->mtu);
468                 DEBUG("port %u MTU is %u", priv->port, priv->mtu);
469
470                 /* from rte_ethdev.c */
471                 {
472                         char name[RTE_ETH_NAME_MAX_LEN];
473
474                         snprintf(name, sizeof(name), "%s port %u",
475                                  ibv_get_device_name(ibv_dev), port);
476                         eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
477                 }
478                 if (eth_dev == NULL) {
479                         ERROR("can not allocate rte ethdev");
480                         err = ENOMEM;
481                         goto port_error;
482                 }
483
484                 eth_dev->data->dev_private = priv;
485                 eth_dev->pci_dev = pci_dev;
486
487                 rte_eth_copy_pci_info(eth_dev, pci_dev);
488
489                 eth_dev->driver = &mlx5_driver;
490                 eth_dev->data->rx_mbuf_alloc_failed = 0;
491                 eth_dev->data->mtu = ETHER_MTU;
492
493                 priv->dev = eth_dev;
494                 eth_dev->dev_ops = &mlx5_dev_ops;
495                 eth_dev->data->mac_addrs = priv->mac;
496                 TAILQ_INIT(&eth_dev->link_intr_cbs);
497
498                 /* Bring Ethernet device up. */
499                 DEBUG("forcing Ethernet interface up");
500                 priv_set_flags(priv, ~IFF_UP, IFF_UP);
501                 continue;
502
503 port_error:
504                 if (priv) {
505                         rte_free(priv->rss_conf);
506                         rte_free(priv);
507                 }
508                 if (pd)
509                         claim_zero(ibv_dealloc_pd(pd));
510                 if (ctx)
511                         claim_zero(ibv_close_device(ctx));
512                 break;
513         }
514
515         /*
516          * XXX if something went wrong in the loop above, there is a resource
517          * leak (ctx, pd, priv, dpdk ethdev) but we can do nothing about it as
518          * long as the dpdk does not provide a way to deallocate a ethdev and a
519          * way to enumerate the registered ethdevs to free the previous ones.
520          */
521
522         /* no port found, complain */
523         if (!mlx5_dev[idx].ports) {
524                 err = ENODEV;
525                 goto error;
526         }
527
528 error:
529         if (attr_ctx)
530                 claim_zero(ibv_close_device(attr_ctx));
531         if (list)
532                 ibv_free_device_list(list);
533         assert(err >= 0);
534         return -err;
535 }
536
537 static const struct rte_pci_id mlx5_pci_id_map[] = {
538         {
539                 .vendor_id = PCI_VENDOR_ID_MELLANOX,
540                 .device_id = PCI_DEVICE_ID_MELLANOX_CONNECTX4,
541                 .subsystem_vendor_id = PCI_ANY_ID,
542                 .subsystem_device_id = PCI_ANY_ID
543         },
544         {
545                 .vendor_id = PCI_VENDOR_ID_MELLANOX,
546                 .device_id = PCI_DEVICE_ID_MELLANOX_CONNECTX4VF,
547                 .subsystem_vendor_id = PCI_ANY_ID,
548                 .subsystem_device_id = PCI_ANY_ID
549         },
550         {
551                 .vendor_id = PCI_VENDOR_ID_MELLANOX,
552                 .device_id = PCI_DEVICE_ID_MELLANOX_CONNECTX4LX,
553                 .subsystem_vendor_id = PCI_ANY_ID,
554                 .subsystem_device_id = PCI_ANY_ID
555         },
556         {
557                 .vendor_id = PCI_VENDOR_ID_MELLANOX,
558                 .device_id = PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF,
559                 .subsystem_vendor_id = PCI_ANY_ID,
560                 .subsystem_device_id = PCI_ANY_ID
561         },
562         {
563                 .vendor_id = 0
564         }
565 };
566
567 static struct eth_driver mlx5_driver = {
568         .pci_drv = {
569                 .name = MLX5_DRIVER_NAME,
570                 .id_table = mlx5_pci_id_map,
571                 .devinit = mlx5_pci_devinit,
572                 .drv_flags = RTE_PCI_DRV_INTR_LSC,
573         },
574         .dev_private_size = sizeof(struct priv)
575 };
576
577 /**
578  * Driver initialization routine.
579  */
580 static int
581 rte_mlx5_pmd_init(const char *name, const char *args)
582 {
583         (void)name;
584         (void)args;
585         /*
586          * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
587          * huge pages. Calling ibv_fork_init() during init allows
588          * applications to use fork() safely for purposes other than
589          * using this PMD, which is not supported in forked processes.
590          */
591         setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
592         ibv_fork_init();
593         rte_eal_pci_register(&mlx5_driver.pci_drv);
594         return 0;
595 }
596
597 static struct rte_driver rte_mlx5_driver = {
598         .type = PMD_PDEV,
599         .name = MLX5_DRIVER_NAME,
600         .init = rte_mlx5_pmd_init,
601 };
602
603 PMD_REGISTER_DRIVER(rte_mlx5_driver)