From 1371f4df16bc58a6dc01776af9c89bb39c0bc796 Mon Sep 17 00:00:00 2001 From: Or Ami Date: Thu, 3 Mar 2016 15:27:35 +0100 Subject: [PATCH] mlx5: check port is configured as ethernet device If the port link layer is not Ethernet, notify the user. Signed-off-by: Or Ami --- doc/guides/rel_notes/release_16_04.rst | 5 +++++ drivers/net/mlx5/mlx5.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst index 41207c18de..0f6fd4cdb7 100644 --- a/doc/guides/rel_notes/release_16_04.rst +++ b/doc/guides/rel_notes/release_16_04.rst @@ -278,6 +278,11 @@ Drivers A crash could occur when failing to allocate private device context. +* **mlx5: Added port type check.** + + Done to prevent port initialization on non-Ethernet link layers and + to report an error. + * **aesni_mb: Fixed wrong return value when creating a device.** cryptodev_aesni_mb_init() was returning the device id of the device created, diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 41dcbbf697..ae2576f655 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -348,6 +348,13 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) ERROR("port query failed: %s", strerror(err)); goto port_error; } + + if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { + ERROR("port %d is not configured in Ethernet mode", + port); + goto port_error; + } + if (port_attr.state != IBV_PORT_ACTIVE) DEBUG("port %d is not active: \"%s\" (%d)", port, ibv_port_state_str(port_attr.state), -- 2.20.1