Skip to content

Commit

Permalink
net/mlx5: fix flex item availability
Browse files Browse the repository at this point in the history
[ upstream commit 71adf25 ]

Flex item availability is restricted to BlueField-2 and BlueField-3
PF ports.

The patch validates port type compliance before proceeding to
flex item creation.

Fixes: db25cad ("net/mlx5: add flex item operations")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  • Loading branch information
getelson-at-mellanox authored and kevintraynor committed Mar 10, 2022
1 parent 3bd5cf3 commit 48fe9ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/common/mlx5/linux/mlx5_common_os.h
Expand Up @@ -9,6 +9,7 @@
#include <malloc.h>

#include <rte_pci.h>
#include <rte_bus_pci.h>
#include <rte_debug.h>
#include <rte_atomic.h>
#include <rte_log.h>
Expand Down
17 changes: 17 additions & 0 deletions drivers/net/mlx5/mlx5_flow.c
Expand Up @@ -9853,10 +9853,27 @@ mlx5_flow_flex_item_create(struct rte_eth_dev *dev,
struct rte_flow_error *error)
{
static const char err_msg[] = "flex item creation unsupported";
struct mlx5_priv *priv = dev->data->dev_private;
struct rte_flow_attr attr = { .transfer = 0 };
const struct mlx5_flow_driver_ops *fops =
flow_get_drv_ops(flow_get_drv_type(dev, &attr));

if (!priv->pci_dev) {
rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
"create flex item on PF only");
return NULL;
}
switch (priv->pci_dev->id.device_id) {
case PCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF:
case PCI_DEVICE_ID_MELLANOX_CONNECTX7BF:
break;
default:
rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
"flex item available on BlueField ports only");
return NULL;
}
if (!fops->item_create) {
DRV_LOG(ERR, "port %u %s.", dev->data->port_id, err_msg);
rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
Expand Down

0 comments on commit 48fe9ef

Please sign in to comment.