net/mlx5: introduce send scheduling devargs
[dpdk.git] / drivers / net / mlx5 / linux / mlx5_os.c
index 7978873..14af468 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "mlx5_defs.h"
 #include "mlx5.h"
+#include "mlx5_common_os.h"
 #include "mlx5_utils.h"
 #include "mlx5_rxtx.h"
 #include "mlx5_autoconf.h"
 #define MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP (1 << 4)
 #endif
 
-/**
- * Get device name. Given an ibv_device pointer - return a
- * pointer to the corresponding device name.
- *
- * @param[in] dev
- *   Pointer to ibv device.
- *
- * @return
- *   Pointer to device name if dev is valid, NULL otherwise.
- */
-const char *
-mlx5_os_get_dev_device_name(void *dev)
-{
-       if (!dev)
-               return NULL;
-       return ((struct ibv_device *)dev)->name;
-}
-
-/**
- * Get ibv device name. Given an ibv_context pointer - return a
- * pointer to the corresponding device name.
- *
- * @param[in] ctx
- *   Pointer to ibv context.
- *
- * @return
- *   Pointer to device name if ctx is valid, NULL otherwise.
- */
-const char *
-mlx5_os_get_ctx_device_name(void *ctx)
-{
-       if (!ctx)
-               return NULL;
-       return ((struct ibv_context *)ctx)->device->name;
-}
-
-/**
- * Get ibv device path name. Given an ibv_context pointer - return a
- * pointer to the corresponding device path name.
- *
- * @param[in] ctx
- *   Pointer to ibv context.
- *
- * @return
- *   Pointer to device path name if ctx is valid, NULL otherwise.
- */
-const char *
-mlx5_os_get_ctx_device_path(void *ctx)
-{
-       if (!ctx)
-               return NULL;
-
-       return ((struct ibv_context *)ctx)->device->ibdev_path;
-}
-
-/**
- * Get umem id. Given a pointer to umem object of type
- * 'struct mlx5dv_devx_umem *' - return its id.
- *
- * @param[in] umem
- *   Pointer to umem object.
- *
- * @return
- *   The umem id if umem is valid, 0 otherwise.
- */
-uint32_t
-mlx5_os_get_umem_id(void *umem)
-{
-       if (!umem)
-               return 0;
-       return ((struct mlx5dv_devx_umem *)umem)->umem_id;
-}
-
 /**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
@@ -949,6 +877,69 @@ err_secondary:
                                        priv->mtr_color_reg);
                        }
                }
+#endif
+       }
+       if (config.tx_pp) {
+               DRV_LOG(DEBUG, "Timestamp counter frequency %u kHz",
+                       config.hca_attr.dev_freq_khz);
+               DRV_LOG(DEBUG, "Packet pacing is %ssupported",
+                       config.hca_attr.qos.packet_pacing ? "" : "not ");
+               DRV_LOG(DEBUG, "Cross channel ops are %ssupported",
+                       config.hca_attr.cross_channel ? "" : "not ");
+               DRV_LOG(DEBUG, "WQE index ignore is %ssupported",
+                       config.hca_attr.wqe_index_ignore ? "" : "not ");
+               DRV_LOG(DEBUG, "Non-wire SQ feature is %ssupported",
+                       config.hca_attr.non_wire_sq ? "" : "not ");
+               DRV_LOG(DEBUG, "Static WQE SQ feature is %ssupported (%d)",
+                       config.hca_attr.log_max_static_sq_wq ? "" : "not ",
+                       config.hca_attr.log_max_static_sq_wq);
+               DRV_LOG(DEBUG, "WQE rate PP mode is %ssupported",
+                       config.hca_attr.qos.wqe_rate_pp ? "" : "not ");
+               if (!config.devx) {
+                       DRV_LOG(ERR, "DevX is required for packet pacing");
+                       err = ENODEV;
+                       goto error;
+               }
+               if (!config.hca_attr.qos.packet_pacing) {
+                       DRV_LOG(ERR, "Packet pacing is not supported");
+                       err = ENODEV;
+                       goto error;
+               }
+               if (!config.hca_attr.cross_channel) {
+                       DRV_LOG(ERR, "Cross channel operations are"
+                                    " required for packet pacing");
+                       err = ENODEV;
+                       goto error;
+               }
+               if (!config.hca_attr.wqe_index_ignore) {
+                       DRV_LOG(ERR, "WQE index ignore feature is"
+                                    " required for packet pacing");
+                       err = ENODEV;
+                       goto error;
+               }
+               if (!config.hca_attr.non_wire_sq) {
+                       DRV_LOG(ERR, "Non-wire SQ feature is"
+                                    " required for packet pacing");
+                       err = ENODEV;
+                       goto error;
+               }
+               if (!config.hca_attr.log_max_static_sq_wq) {
+                       DRV_LOG(ERR, "Static WQE SQ feature is"
+                                    " required for packet pacing");
+                       err = ENODEV;
+                       goto error;
+               }
+               if (!config.hca_attr.qos.wqe_rate_pp) {
+                       DRV_LOG(ERR, "WQE rate mode is required"
+                                    " for packet pacing");
+                       err = ENODEV;
+                       goto error;
+               }
+#ifndef HAVE_MLX5DV_DEVX_UAR_OFFSET
+               DRV_LOG(ERR, "DevX does not provide UAR offset,"
+                            " can't create queues for packet pacing");
+               err = ENODEV;
+               goto error;
 #endif
        }
        if (config.mprq.enabled && mprq) {
@@ -1060,14 +1051,13 @@ err_secondary:
        TAILQ_INIT(&priv->flow_meters);
        TAILQ_INIT(&priv->flow_meter_profiles);
        /* Hint libmlx5 to use PMD allocator for data plane resources */
-       struct mlx5dv_ctx_allocators alctr = {
-               .alloc = &mlx5_alloc_verbs_buf,
-               .free = &mlx5_free_verbs_buf,
-               .data = priv,
-       };
        mlx5_glue->dv_set_context_attr(sh->ctx,
-                                      MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
-                                      (void *)((uintptr_t)&alctr));
+                       MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
+                       (void *)((uintptr_t)&(struct mlx5dv_ctx_allocators){
+                               .alloc = &mlx5_alloc_verbs_buf,
+                               .free = &mlx5_free_verbs_buf,
+                               .data = priv,
+                       }));
        /* Bring Ethernet device up. */
        DRV_LOG(DEBUG, "port %u forcing Ethernet interface up",
                eth_dev->data->port_id);
@@ -1563,6 +1553,8 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                                        if (list[ns].info.port_name == bd)
                                                ns++;
                                        break;
+                               case MLX5_PHYS_PORT_NAME_TYPE_PFHPF:
+                                       /* Fallthrough */
                                case MLX5_PHYS_PORT_NAME_TYPE_PFVF:
                                        if (list[ns].info.pf_num == bd)
                                                ns++;