git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/mlx5: rearrange creation of WQ and CQ object
[dpdk.git]
/
drivers
/
net
/
mlx4
/
mlx4.c
diff --git
a/drivers/net/mlx4/mlx4.c
b/drivers/net/mlx4/mlx4.c
index
931e4f4
..
71061a7
100644
(file)
--- a/
drivers/net/mlx4/mlx4.c
+++ b/
drivers/net/mlx4/mlx4.c
@@
-8,8
+8,6
@@
* mlx4 driver initialization.
*/
* mlx4 driver initialization.
*/
-#include <assert.h>
-#include <dlfcn.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
@@
-19,6
+17,9
@@
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
+#ifdef RTE_IBVERBS_LINK_DLOPEN
+#include <dlfcn.h>
+#endif
/* Verbs headers do not support -pedantic. */
#ifdef PEDANTIC
/* Verbs headers do not support -pedantic. */
#ifdef PEDANTIC
@@
-30,7
+31,6
@@
#endif
#include <rte_common.h>
#endif
#include <rte_common.h>
-#include <rte_config.h>
#include <rte_dev.h>
#include <rte_errno.h>
#include <rte_ethdev_driver.h>
#include <rte_dev.h>
#include <rte_errno.h>
#include <rte_ethdev_driver.h>
@@
-49,6
+49,10
@@
#include "mlx4_rxtx.h"
#include "mlx4_utils.h"
#include "mlx4_rxtx.h"
#include "mlx4_utils.h"
+#ifdef MLX4_GLUE
+const struct mlx4_glue *mlx4_glue;
+#endif
+
static const char *MZ_MLX4_PMD_SHARED_DATA = "mlx4_pmd_shared_data";
/* Shared memory between primary and secondary processes. */
static const char *MZ_MLX4_PMD_SHARED_DATA = "mlx4_pmd_shared_data";
/* Shared memory between primary and secondary processes. */
@@
-60,9
+64,6
@@
static rte_spinlock_t mlx4_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
/* Process local data for secondary processes. */
static struct mlx4_local_data mlx4_local_data;
/* Process local data for secondary processes. */
static struct mlx4_local_data mlx4_local_data;
-/** Driver-specific log messages type. */
-int mlx4_logtype;
-
/** Configuration structure for device arguments. */
struct mlx4_conf {
struct {
/** Configuration structure for device arguments. */
struct mlx4_conf {
struct {
@@
-162,7
+163,7
@@
mlx4_alloc_verbs_buf(size_t size, void *data)
socket = rxq->socket;
}
socket = rxq->socket;
}
-
assert
(data != NULL);
+
MLX4_ASSERT
(data != NULL);
ret = rte_malloc_socket(__func__, size, alignment, socket);
if (!ret && size)
rte_errno = ENOMEM;
ret = rte_malloc_socket(__func__, size, alignment, socket);
if (!ret && size)
rte_errno = ENOMEM;
@@
-180,7
+181,7
@@
mlx4_alloc_verbs_buf(size_t size, void *data)
static void
mlx4_free_verbs_buf(void *ptr, void *data __rte_unused)
{
static void
mlx4_free_verbs_buf(void *ptr, void *data __rte_unused)
{
-
assert
(data != NULL);
+
MLX4_ASSERT
(data != NULL);
rte_free(ptr);
}
#endif
rte_free(ptr);
}
#endif
@@
-248,6
+249,9
@@
mlx4_dev_configure(struct rte_eth_dev *dev)
struct rte_flow_error error;
int ret;
struct rte_flow_error error;
int ret;
+ if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+ dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
/* Prepare internal flow rules. */
ret = mlx4_flow_sync(priv, &error);
if (ret) {
/* Prepare internal flow rules. */
ret = mlx4_flow_sync(priv, &error);
if (ret) {
@@
-302,7
+306,7
@@
mlx4_dev_start(struct rte_eth_dev *dev)
(void *)dev, strerror(-ret));
goto err;
}
(void *)dev, strerror(-ret));
goto err;
}
-#if
ndef N
DEBUG
+#if
def RTE_LIBRTE_MLX4_
DEBUG
mlx4_mr_dump_dev(dev);
#endif
ret = mlx4_rxq_intr_enable(priv);
mlx4_mr_dump_dev(dev);
#endif
ret = mlx4_rxq_intr_enable(priv);
@@
-389,11
+393,11
@@
mlx4_dev_close(struct rte_eth_dev *dev)
mlx4_proc_priv_uninit(dev);
mlx4_mr_release(dev);
if (priv->pd != NULL) {
mlx4_proc_priv_uninit(dev);
mlx4_mr_release(dev);
if (priv->pd != NULL) {
-
assert
(priv->ctx != NULL);
+
MLX4_ASSERT
(priv->ctx != NULL);
claim_zero(mlx4_glue->dealloc_pd(priv->pd));
claim_zero(mlx4_glue->close_device(priv->ctx));
} else
claim_zero(mlx4_glue->dealloc_pd(priv->pd));
claim_zero(mlx4_glue->close_device(priv->ctx));
} else
-
assert
(priv->ctx == NULL);
+
MLX4_ASSERT
(priv->ctx == NULL);
mlx4_intr_uninstall(priv);
memset(priv, 0, sizeof(*priv));
}
mlx4_intr_uninstall(priv);
memset(priv, 0, sizeof(*priv));
}
@@
-485,7
+489,6
@@
mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
&pci_addr->bus,
&pci_addr->devid,
&pci_addr->function) == 4) {
&pci_addr->bus,
&pci_addr->devid,
&pci_addr->function) == 4) {
- ret = 0;
break;
}
}
break;
}
}
@@
-702,7
+705,7
@@
mlx4_init_once(void)
if (mlx4_init_shared_data())
return -rte_errno;
sd = mlx4_shared_data;
if (mlx4_init_shared_data())
return -rte_errno;
sd = mlx4_shared_data;
-
assert
(sd);
+
MLX4_ASSERT
(sd);
rte_spinlock_lock(&sd->lock);
switch (rte_eal_process_type()) {
case RTE_PROC_PRIMARY:
rte_spinlock_lock(&sd->lock);
switch (rte_eal_process_type()) {
case RTE_PROC_PRIMARY:
@@
-772,16
+775,16
@@
mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
strerror(rte_errno));
return -rte_errno;
}
strerror(rte_errno));
return -rte_errno;
}
-
assert
(pci_drv == &mlx4_driver);
+
MLX4_ASSERT
(pci_drv == &mlx4_driver);
list = mlx4_glue->get_device_list(&i);
if (list == NULL) {
rte_errno = errno;
list = mlx4_glue->get_device_list(&i);
if (list == NULL) {
rte_errno = errno;
-
assert
(rte_errno);
+
MLX4_ASSERT
(rte_errno);
if (rte_errno == ENOSYS)
ERROR("cannot list devices, is ib_uverbs loaded?");
return -rte_errno;
}
if (rte_errno == ENOSYS)
ERROR("cannot list devices, is ib_uverbs loaded?");
return -rte_errno;
}
-
assert
(i >= 0);
+
MLX4_ASSERT
(i >= 0);
/*
* For each listed device, check related sysfs entry against
* the provided PCI ID.
/*
* For each listed device, check related sysfs entry against
* the provided PCI ID.
@@
-818,7
+821,7
@@
mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
ERROR("cannot use device, are drivers up to date?");
return -rte_errno;
}
ERROR("cannot use device, are drivers up to date?");
return -rte_errno;
}
-
assert
(err > 0);
+
MLX4_ASSERT
(err > 0);
rte_errno = err;
return -rte_errno;
}
rte_errno = err;
return -rte_errno;
}
@@
-843,7
+846,7
@@
mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
err = ENODEV;
goto error;
}
err = ENODEV;
goto error;
}
-
assert
(device_attr.max_sge >= MLX4_MAX_SGE);
+
MLX4_ASSERT
(device_attr.max_sge >= MLX4_MAX_SGE);
for (i = 0; i < device_attr.phys_port_cnt; i++) {
uint32_t port = i + 1; /* ports are indexed from one */
struct ibv_context *ctx = NULL;
for (i = 0; i < device_attr.phys_port_cnt; i++) {
uint32_t port = i + 1; /* ports are indexed from one */
struct ibv_context *ctx = NULL;
@@
-1026,10
+1029,9
@@
mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
eth_dev->device = &pci_dev->device;
rte_eth_copy_pci_info(eth_dev, pci_dev);
/* Initialize local interrupt handle for current port. */
eth_dev->device = &pci_dev->device;
rte_eth_copy_pci_info(eth_dev, pci_dev);
/* Initialize local interrupt handle for current port. */
- priv->intr_handle = (struct rte_intr_handle){
- .fd = -1,
- .type = RTE_INTR_HANDLE_EXT,
- };
+ memset(&priv->intr_handle, 0, sizeof(struct rte_intr_handle));
+ priv->intr_handle.fd = -1;
+ priv->intr_handle.type = RTE_INTR_HANDLE_EXT;
/*
* Override ethdev interrupt handle pointer with private
* handle instead of that of the parent PCI device used by
/*
* Override ethdev interrupt handle pointer with private
* handle instead of that of the parent PCI device used by
@@
-1047,14
+1049,13
@@
mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
eth_dev->dev_ops = &mlx4_dev_ops;
#ifdef HAVE_IBV_MLX4_BUF_ALLOCATORS
/* Hint libmlx4 to use PMD allocator for data plane resources */
eth_dev->dev_ops = &mlx4_dev_ops;
#ifdef HAVE_IBV_MLX4_BUF_ALLOCATORS
/* Hint libmlx4 to use PMD allocator for data plane resources */
- struct mlx4dv_ctx_allocators alctr = {
- .alloc = &mlx4_alloc_verbs_buf,
- .free = &mlx4_free_verbs_buf,
- .data = priv,
- };
err = mlx4_glue->dv_set_context_attr
(ctx, MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS,
err = mlx4_glue->dv_set_context_attr
(ctx, MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS,
- (void *)((uintptr_t)&alctr));
+ (void *)((uintptr_t)&(struct mlx4dv_ctx_allocators){
+ .alloc = &mlx4_alloc_verbs_buf,
+ .free = &mlx4_free_verbs_buf,
+ .data = priv,
+ }));
if (err)
WARN("Verbs external allocator is not supported");
else
if (err)
WARN("Verbs external allocator is not supported");
else
@@
-1274,16
+1275,14
@@
glue_error:
#endif
#endif
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx4_logtype, pmd.net.mlx4, NOTICE)
+
/**
* Driver initialization routine.
*/
RTE_INIT(rte_mlx4_pmd_init)
{
/**
* Driver initialization routine.
*/
RTE_INIT(rte_mlx4_pmd_init)
{
- /* Initialize driver log type. */
- mlx4_logtype = rte_log_register("pmd.net.mlx4");
- if (mlx4_logtype >= 0)
- rte_log_set_level(mlx4_logtype, RTE_LOG_NOTICE);
-
/*
* MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
* want to get success errno value in case of calling them
/*
* MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
* want to get success errno value in case of calling them
@@
-1300,15
+1299,15
@@
RTE_INIT(rte_mlx4_pmd_init)
#ifdef RTE_IBVERBS_LINK_DLOPEN
if (mlx4_glue_init())
return;
#ifdef RTE_IBVERBS_LINK_DLOPEN
if (mlx4_glue_init())
return;
-
assert
(mlx4_glue);
+
MLX4_ASSERT
(mlx4_glue);
#endif
#endif
-#if
ndef N
DEBUG
+#if
def RTE_LIBRTE_MLX4_
DEBUG
/* Glue structure must not contain any NULL pointers. */
{
unsigned int i;
for (i = 0; i != sizeof(*mlx4_glue) / sizeof(void *); ++i)
/* Glue structure must not contain any NULL pointers. */
{
unsigned int i;
for (i = 0; i != sizeof(*mlx4_glue) / sizeof(void *); ++i)
-
assert
(((const void *const *)mlx4_glue)[i]);
+
MLX4_ASSERT
(((const void *const *)mlx4_glue)[i]);
}
#endif
if (strcmp(mlx4_glue->version, MLX4_GLUE_VERSION)) {
}
#endif
if (strcmp(mlx4_glue->version, MLX4_GLUE_VERSION)) {