]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: refactor to detect operation by DevX
authorMichael Baum <michaelba@nvidia.com>
Mon, 14 Feb 2022 09:35:08 +0000 (11:35 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Mon, 21 Feb 2022 10:36:53 +0000 (11:36 +0100)
Add inline function indicating whether HW objects operations can be
created by DevX. It makes the code more readable.

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_ethdev.c
drivers/net/mlx5/mlx5_trigger.c

index 7ee76d54bd545c96f6785aec9cee52cb418e74c7..c1eda0089943b3c054e97e003235f39ca6e932a6 100644 (file)
@@ -370,8 +370,7 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)
        sh->dev_cap.txpp_en = 0;
 #endif
        /* Check for LRO support. */
-       if (sh->dev_cap.dest_tir && sh->dev_cap.dv_flow_en &&
-           hca_attr->lro_cap) {
+       if (mlx5_devx_obj_ops_en(sh) && hca_attr->lro_cap) {
                /* TBD check tunnel lro caps. */
                sh->dev_cap.lro_supported = 1;
                DRV_LOG(DEBUG, "Device supports LRO.");
@@ -1550,8 +1549,7 @@ err_secondary:
                if (mlx5_flex_item_port_init(eth_dev) < 0)
                        goto error;
        }
-       if (sh->cdev->config.devx && sh->config.dv_flow_en &&
-           sh->dev_cap.dest_tir) {
+       if (mlx5_devx_obj_ops_en(sh)) {
                priv->obj_ops = devx_obj_ops;
                mlx5_queue_counter_id_prepare(eth_dev);
                priv->obj_ops.lb_dummy_queue_create =
index 5ca48ef68fdea664939e98aad44b086c5a9ed0e9..46fa5131a78cb134e196a9d313de106bad7720cd 100644 (file)
@@ -1496,6 +1496,30 @@ enum dr_dump_rec_type {
        DR_DUMP_REC_TYPE_PMD_COUNTER = 4430,
 };
 
+/**
+ * Indicates whether HW objects operations can be created by DevX.
+ *
+ * This function is used for both:
+ *  Before creation - deciding whether to create HW objects operations by DevX.
+ *  After creation - indicator if HW objects operations were created by DevX.
+ *
+ * @param sh
+ *   Pointer to shared device context.
+ *
+ * @return
+ *   True if HW objects were created by DevX, False otherwise.
+ */
+static inline bool
+mlx5_devx_obj_ops_en(struct mlx5_dev_ctx_shared *sh)
+{
+       /*
+        * When advanced DR API is available and DV flow is supported and
+        * DevX is supported, HW objects operations are created by DevX.
+        */
+       return (sh->cdev->config.devx && sh->config.dv_flow_en &&
+               sh->dev_cap.dest_tir);
+}
+
 /* mlx5.c */
 
 int mlx5_getenv_int(const char *);
index 9e478db8df1891a57491083c93ad2f58c30db450..d637dee98d5a2714e9934b804145bbd2c284b704 100644 (file)
@@ -721,8 +721,7 @@ mlx5_hairpin_cap_get(struct rte_eth_dev *dev, struct rte_eth_hairpin_cap *cap)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
 
-       if (!priv->sh->cdev->config.devx || !priv->sh->dev_cap.dest_tir ||
-           !priv->sh->config.dv_flow_en) {
+       if (!mlx5_devx_obj_ops_en(priv->sh)) {
                rte_errno = ENOTSUP;
                return -rte_errno;
        }
index a67a6af72854a45bd0cb63e983546a91135c1d7d..74c3bc8a134d933486ac782638807387d80b40e0 100644 (file)
@@ -1104,8 +1104,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
                        dev->data->port_id, strerror(rte_errno));
                goto error;
        }
-       if ((priv->sh->cdev->config.devx && priv->sh->config.dv_flow_en &&
-            priv->sh->dev_cap.dest_tir) &&
+       if (mlx5_devx_obj_ops_en(priv->sh) &&
            priv->obj_ops.lb_dummy_queue_create) {
                ret = priv->obj_ops.lb_dummy_queue_create(dev);
                if (ret)