From 71adf25dbfb3a60731bd922342cc0f171714db81 Mon Sep 17 00:00:00 2001 From: Gregory Etelson Date: Wed, 2 Mar 2022 13:06:42 +0200 Subject: [PATCH] net/mlx5: fix flex item availability 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: db25cadc0887 ("net/mlx5: add flex item operations") Cc: stable@dpdk.org Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- drivers/common/mlx5/linux/mlx5_common_os.h | 1 + drivers/net/mlx5/mlx5_flow.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index a85f3b5f3c..27f1192205 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 15a4a8cd98..ffcaef0baa 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -10630,10 +10630,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, -- 2.20.1