From 6533e2408e4a20ec7ffe54960e1955f00eba3c68 Mon Sep 17 00:00:00 2001 From: hselasky Date: Wed, 8 May 2019 10:39:53 +0000 Subject: [PATCH] Query and cache PCAM, MCAM registers on initialization in mlx5core. On load_one, we now cache our capabilities registers internally, similar to QUERY_HCA_CAP. Capabilities can later be queried using macros introduced in this patch. Linux commit: 71862561f3a62015a11de16d1c306481e8415c08 Submitted by: slavash@ MFC after: 3 days Sponsored by: Mellanox Technologies --- sys/dev/mlx5/device.h | 6 ++++++ sys/dev/mlx5/driver.h | 2 ++ sys/dev/mlx5/mlx5_core/mlx5_fw.c | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/sys/dev/mlx5/device.h b/sys/dev/mlx5/device.h index 0b26a1b7727a..f3d325139c91 100644 --- a/sys/dev/mlx5/device.h +++ b/sys/dev/mlx5/device.h @@ -1050,6 +1050,12 @@ enum mlx5_mcam_feature_groups { MLX5_GET(qos_cap,\ mdev->hca_caps_max[MLX5_CAP_QOS], cap) +#define MLX5_CAP_PCAM_FEATURE(mdev, fld) \ + MLX5_GET(pcam_reg, (mdev)->caps.pcam, feature_cap_mask.enhanced_features.fld) + +#define MLX5_CAP_MCAM_FEATURE(mdev, fld) \ + MLX5_GET(mcam_reg, (mdev)->caps.mcam, mng_feature_cap_mask.enhanced_features.fld) + #define MLX5_CAP_QCAM_REG(mdev, fld) \ MLX5_GET(qcam_reg, (mdev)->caps.qcam, qos_access_reg_cap_mask.reg_cap.fld) diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h index 917349bc7075..017b52a80a5b 100644 --- a/sys/dev/mlx5/driver.h +++ b/sys/dev/mlx5/driver.h @@ -699,6 +699,8 @@ struct mlx5_core_dev { u32 hca_caps_cur[MLX5_CAP_NUM][MLX5_UN_SZ_DW(hca_cap_union)]; u32 hca_caps_max[MLX5_CAP_NUM][MLX5_UN_SZ_DW(hca_cap_union)]; struct { + u32 pcam[MLX5_ST_SZ_DW(pcam_reg)]; + u32 mcam[MLX5_ST_SZ_DW(mcam_reg)]; u32 qcam[MLX5_ST_SZ_DW(qcam_reg)]; u32 fpga[MLX5_ST_SZ_DW(fpga_cap)]; } caps; diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fw.c b/sys/dev/mlx5/mlx5_core/mlx5_fw.c index 31962cad8212..94597b6d421e 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fw.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fw.c @@ -117,6 +117,20 @@ static int mlx5_get_qcam_reg(struct mlx5_core_dev *dev) MLX5_QCAM_REGS_FIRST_128); } +static int mlx5_get_pcam_reg(struct mlx5_core_dev *dev) +{ + return mlx5_query_pcam_reg(dev, dev->caps.pcam, + MLX5_PCAM_FEATURE_ENHANCED_FEATURES, + MLX5_PCAM_REGS_5000_TO_507F); +} + +static int mlx5_get_mcam_reg(struct mlx5_core_dev *dev) +{ + return mlx5_query_mcam_reg(dev, dev->caps.mcam, + MLX5_MCAM_FEATURE_ENHANCED_FEATURES, + MLX5_MCAM_REGS_FIRST_128); +} + int mlx5_query_hca_caps(struct mlx5_core_dev *dev) { int err;