#include <linux/ethtool.h>
#include <linux/sockios.h>
+/* Verbs header. */
+/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-pedantic"
+#endif
+#include <infiniband/verbs.h>
+#ifdef PEDANTIC
+#pragma GCC diagnostic error "-pedantic"
+#endif
+
/* DPDK headers don't like -pedantic. */
#ifdef PEDANTIC
#pragma GCC diagnostic ignored "-pedantic"
#pragma GCC diagnostic error "-pedantic"
#endif
-/* Verbs header. */
-/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-pedantic"
-#endif
-
-#include <infiniband/verbs.h>
-
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-pedantic"
-#endif
-
/* Generated configuration header. */
#include "mlx4_autoconf.h"
list = ibv_get_device_list(&i);
if (list == NULL) {
assert(errno);
+ if (errno == ENOSYS) {
+ WARN("cannot list devices, is ib_uverbs loaded?");
+ return 0;
+ }
return -errno;
}
assert(i >= 0);
break;
}
if (attr_ctx == NULL) {
- if (err == 0)
- err = ENODEV;
ibv_free_device_list(list);
+ switch (err) {
+ case 0:
+ WARN("cannot access device, is mlx4_ib loaded?");
+ return 0;
+ case EINVAL:
+ WARN("cannot use device, are drivers up to date?");
+ return 0;
+ }
assert(err > 0);
return -err;
}
DEBUG("port %u MTU is %u", priv->port, priv->mtu);
/* from rte_ethdev.c */
-#if RTE_VERSION >= RTE_VERSION_NUM(1, 7, 0, 0)
{
char name[RTE_ETH_NAME_MAX_LEN];
snprintf(name, sizeof(name), "%s port %u",
ibv_get_device_name(ibv_dev), port);
- eth_dev = rte_eth_dev_allocate(name);
+ eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
}
-#else
- eth_dev = rte_eth_dev_allocate();
-#endif
if (eth_dev == NULL) {
ERROR("can not allocate rte ethdev");
err = ENOMEM;
eth_dev->pci_dev = pci_dev;
eth_dev->driver = &mlx4_driver;
eth_dev->data->rx_mbuf_alloc_failed = 0;
-#if RTE_VERSION >= RTE_VERSION_NUM(1, 7, 0, 0)
eth_dev->data->mtu = ETHER_MTU;
-#else
- eth_dev->data->max_frame_size = ETHER_MAX_LEN;
-#endif
priv->dev = eth_dev;
eth_dev->dev_ops = &mlx4_dev_ops;