net/mlx5: Query device memory capabilities
authorAriel Levkovich <lariel@mellanox.com>
Thu, 5 Apr 2018 15:53:26 +0000 (18:53 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 5 Apr 2018 19:04:48 +0000 (13:04 -0600)
This patch adds querying of device memory capabilities by the mlx5_core
driver during initialization.

Device memory capabilities is a new capability type and structure
which contains the necessary data that is needed for future device
memory allocation.

The presence of this new capabilities struct is indicated in the
general capabilities struct which is queried first by the driver.
If the presence bit is set, the driver will also query the new
capabilities struct and save it in the device context.

Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/fw.c
include/linux/mlx5/device.h
include/linux/mlx5/mlx5_ifc.h

index 9d11e92fb54192c59c3b77e8ea9e308c8d3ec31d..17ec55874714a8e2575a72ac1cafdb96fd6d54b1 100644 (file)
@@ -192,6 +192,12 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
        if (MLX5_CAP_GEN(dev, qcam_reg))
                mlx5_get_qcam_reg(dev);
 
+       if (MLX5_CAP_GEN(dev, device_memory)) {
+               err = mlx5_core_get_caps(dev, MLX5_CAP_DEV_MEM);
+               if (err)
+                       return err;
+       }
+
        return 0;
 }
 
index 413df3c11a46380cf811b474ee8225ea006d1822..2651691c05fb2faa57ba3a37780ab659c2f8ce5e 100644 (file)
@@ -1013,6 +1013,9 @@ enum mlx5_cap_type {
        MLX5_CAP_RESERVED,
        MLX5_CAP_VECTOR_CALC,
        MLX5_CAP_QOS,
+       MLX5_CAP_DEBUG,
+       MLX5_CAP_RESERVED_14,
+       MLX5_CAP_DEV_MEM,
        /* NUM OF CAP Types */
        MLX5_CAP_NUM
 };
@@ -1161,6 +1164,12 @@ enum mlx5_qcam_feature_groups {
 #define MLX5_CAP64_FPGA(mdev, cap) \
        MLX5_GET64(fpga_cap, (mdev)->caps.fpga, cap)
 
+#define MLX5_CAP_DEV_MEM(mdev, cap)\
+       MLX5_GET(device_mem_cap, mdev->caps.hca_cur[MLX5_CAP_DEV_MEM], cap)
+
+#define MLX5_CAP64_DEV_MEM(mdev, cap)\
+       MLX5_GET64(device_mem_cap, mdev->caps.hca_cur[MLX5_CAP_DEV_MEM], cap)
+
 enum {
        MLX5_CMD_STAT_OK                        = 0x0,
        MLX5_CMD_STAT_INT_ERR                   = 0x1,
index 64963fd2cd9bf4db453e829c80bb8b0d5b03cb74..13c3bf25753b6613055efc3ab7d5bcb5f0a85e8e 100644 (file)
@@ -658,6 +658,24 @@ struct mlx5_ifc_roce_cap_bits {
        u8         reserved_at_100[0x700];
 };
 
+struct mlx5_ifc_device_mem_cap_bits {
+       u8         memic[0x1];
+       u8         reserved_at_1[0x1f];
+
+       u8         reserved_at_20[0xb];
+       u8         log_min_memic_alloc_size[0x5];
+       u8         reserved_at_30[0x8];
+       u8         log_max_memic_addr_alignment[0x8];
+
+       u8         memic_bar_start_addr[0x40];
+
+       u8         memic_bar_size[0x20];
+
+       u8         max_memic_size[0x20];
+
+       u8         reserved_at_c0[0x740];
+};
+
 enum {
        MLX5_ATOMIC_CAPS_ATOMIC_SIZE_QP_1_BYTE     = 0x0,
        MLX5_ATOMIC_CAPS_ATOMIC_SIZE_QP_2_BYTES    = 0x2,
@@ -872,7 +890,7 @@ struct mlx5_ifc_cmd_hca_cap_bits {
        u8         ets[0x1];
        u8         nic_flow_table[0x1];
        u8         eswitch_flow_table[0x1];
-       u8         early_vf_enable[0x1];
+       u8         device_memory[0x1];
        u8         mcam_reg[0x1];
        u8         pcam_reg[0x1];
        u8         local_ca_ack_delay[0x5];