Skip to contentSkip to conversation

crypto: qat - enable three-service mode for QAT GEN5

PATCH In review Ahsan Atta 2 participants 4 messages Oct 30 – Nov 12

Subsystems (2)
lore
Share & tools
lore

Ahsan Atta

author
#0 lore raw

v2 cover crypto: qat - enable three-service mode for QAT GEN5

QAT GEN5 devices (qat_420xx) have enough accelerator engines to run three services concurrently, but the driver currently only allows a maximum of two to be configured at a time, matching the GEN4 limit.

This series lifts that restriction so that symmetric crypto, asymmetric crypto and compression can be enabled together on GEN5, as is already possible on GEN6 (qat_6xxx).

In summary:
Patch #1: Define the firmware object layout, ring-to-service mapping and thread-to-arbiter mapping required for the sym;asym;dc configuration on GEN5, and register the new service combination in adf_cfg_services so that it can be selected through the cfg_services sysfs attribute.

Patch #2: Update the cfg_services ABI documentation to state that GEN5 devices (qat_420xx) support a maximum of three combined services, alongside the existing GEN6 entry. Documentation only, no functional change.

There is an existing issue opened by Sashiko regarding the AE count when different services are configured on the device. That shall be addressed in later commits if applicable.

Changes in v2:
- Dropped the per-service AE accounting for rate limiting in three-service mode; it now uses the same AE count as the other GEN4/GEN5 configurations. This also resolves the stale-count issue reported by Sashiko.
- Renamed ADF_GEN4_SYM_ASYM_DC_RING_TO_SRV_MAP to ADF_420XX_SYM_ASYM_DC_RING_TO_SRV_MAP.

Bairavi Alagappan (2):
crypto: qat - enable three-service mode for QAT GEN5 devices
Documentation: qat: document three-service mode for QAT GEN5 devices

 Documentation/ABI/testing/sysfs-driver-qat    |  4 +-
 .../intel/qat/qat_420xx/adf_420xx_hw_data.c   | 59 ++++++++++++++++++-
 .../intel/qat/qat_420xx/adf_420xx_hw_data.h   |  6 ++
 .../intel/qat/qat_common/adf_cfg_services.c   |  3 +
 .../intel/qat/qat_common/adf_cfg_services.h   |  1 +
 5 files changed, 69 insertions(+), 4 deletions(-)

base-commit: 9c5d66e1ea78912b8a43ce16a1c14db1357e0ae0

Signature · 1 line
2.50.1
author
#1 lore raw

PATCH v2 1/2 crypto: qat - enable three-service mode for QAT GEN5 devices

From: Bairavi Alagappan <[email protected]>

QAT GEN5 devices have enough accelerator engines to support three concurrent services. However, the qat_420xx module does not currently allow configuring symmetric crypto, asymmetric crypto, and compression services together.

Add support for enabling these three services concurrently on QAT GEN5 devices.

Define the corresponding firmware object layout, ring-to-service mapping, and thread-to-arbiter mapping required for three-service mode.

---
 .../intel/qat/qat_420xx/adf_420xx_hw_data.c   | 59 ++++++++++++++++++-
 .../intel/qat/qat_420xx/adf_420xx_hw_data.h   |  6 ++
 .../intel/qat/qat_common/adf_cfg_services.c   |  3 +
 .../intel/qat/qat_common/adf_cfg_services.h   |  1 +
 4 files changed, 67 insertions(+), 2 deletions(-)
drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c +57 -2
index d6f1f626cf5a..23684868b4e3 100644
@@ -89,6 +89,14 @@ static const struct adf_fw_config adf_fw_dcc_config[] = {
 	{ADF_AE_GROUP_4, ADF_FW_ADMIN_OBJ},
 };
 
+static const struct adf_fw_config adf_fw_asym_sym_dc_config[] = {
+	{ADF_AE_GROUP_3, ADF_FW_DC_OBJ},
+	{ADF_AE_GROUP_2, ADF_FW_DC_OBJ},
+	{ADF_AE_GROUP_1, ADF_FW_SYM_OBJ},
+	{ADF_AE_GROUP_0, ADF_FW_ASYM_OBJ},
+	{ADF_AE_GROUP_4, ADF_FW_ADMIN_OBJ},
+};
+
 
 static struct adf_hw_device_class adf_420xx_class = {
 	.name = ADF_420XX_DEVICE_NAME,
@@ -135,6 +143,8 @@ static u32 uof_get_num_objs(struct adf_accel_dev *accel_dev)
 		return ARRAY_SIZE(adf_fw_asym_dc_config);
 	case SVC_SYM_DC:
 		return ARRAY_SIZE(adf_fw_sym_dc_config);
+	case SVC_SYM_ASYM_DC:
+		return ARRAY_SIZE(adf_fw_asym_sym_dc_config);
 	default:
 		return 0;
 	}
@@ -157,6 +167,8 @@ static const struct adf_fw_config *get_fw_config(struct adf_accel_dev *accel_dev
 		return adf_fw_asym_dc_config;
 	case SVC_SYM_DC:
 		return adf_fw_sym_dc_config;
+	case SVC_SYM_ASYM_DC:
+		return adf_fw_asym_sym_dc_config;
 	default:
 		return NULL;
 	}
@@ -288,13 +300,26 @@ static u32 get_accel_cap(struct adf_accel_dev *accel_dev)
 		return capabilities_asym | capabilities_dc;
 	case SVC_SYM_DC:
 		return capabilities_sym | capabilities_dc;
+	case SVC_SYM_ASYM_DC:
+		return capabilities_sym | capabilities_asym | capabilities_dc;
 	default:
 		return 0;
 	}
 }
 
+static const u32 thrd_to_arb_map_asym_sym_dc[ADF_420XX_MAX_ACCELENGINES] = {
+	0x00000011, 0x00000011, 0x00000011, 0x00000011,
+	0x00002222, 0x00002222, 0x00002222, 0x00002222,
+	0x000000cc, 0x000000cc, 0x000000cc, 0x000000cc,
+	0x000000cc, 0x000000cc, 0x000000cc, 0x000000cc,
+	0x0
+};
+
 static const u32 *adf_get_arbiter_mapping(struct adf_accel_dev *accel_dev)
 {
+	if (adf_get_service_enabled(accel_dev) == SVC_SYM_ASYM_DC)
+		return thrd_to_arb_map_asym_sym_dc;
+
 	if (adf_gen4_init_thd2arb_map(accel_dev))
 		dev_warn(&GET_DEV(accel_dev),
 			 "Failed to generate thread to arbiter mapping");
@@ -425,6 +450,36 @@ static void adf_gen4_set_err_mask(struct adf_dev_err_mask *dev_err_mask)
 	dev_err_mask->ssmfeatren_mask = ADF_420XX_SSMFEATREN_MASK;
 }
 
+static u16 adf_420xx_get_ring_to_svc_map(struct adf_accel_dev *accel_dev)
+{
+	if (adf_get_service_enabled(accel_dev) == SVC_SYM_ASYM_DC)
+		return ADF_420XX_SYM_ASYM_DC_RING_TO_SRV_MAP;
+
+	return adf_gen4_get_ring_to_svc_map(accel_dev);
+}
+
+static bool adf_420xx_services_supported(unsigned long mask)
+{
+	int num_svc;
+
+	if (mask >= BIT(SVC_COUNT))
+		return false;
+
+	if (test_bit(SVC_DECOMP, &mask))
+		return false;
+
+	num_svc = hweight_long(mask);
+	switch (num_svc) {
+	case ADF_ONE_SERVICE:
+		return true;
+	case ADF_TWO_SERVICES:
+	case ADF_THREE_SERVICES:
+		return !test_bit(SVC_DCC, &mask);
+	default:
+		return false;
+	}
+}
+
 void adf_init_hw_data_420xx(struct adf_hw_device_data *hw_data, u32 dev_id)
 {
 	hw_data->dev_class = &adf_420xx_class;
@@ -472,7 +527,7 @@ void adf_init_hw_data_420xx(struct adf_hw_device_data *hw_data, u32 dev_id)
 	hw_data->get_ena_thd_mask = get_ena_thd_mask;
 	hw_data->set_msix_rttable = adf_gen4_set_msix_default_rttable;
 	hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer;
-	hw_data->get_ring_to_svc_map = adf_gen4_get_ring_to_svc_map;
+	hw_data->get_ring_to_svc_map = adf_420xx_get_ring_to_svc_map;
 	hw_data->disable_iov = adf_disable_sriov;
 	hw_data->ring_pair_reset = adf_gen4_ring_pair_reset;
 	hw_data->bank_state_save = adf_bank_state_save;
@@ -485,7 +540,7 @@ void adf_init_hw_data_420xx(struct adf_hw_device_data *hw_data, u32 dev_id)
 	hw_data->get_hb_clock = adf_gen4_get_heartbeat_clock;
 	hw_data->num_hb_ctrs = ADF_NUM_HB_CNT_PER_AE;
 	hw_data->clock_frequency = ADF_420XX_AE_FREQ;
-	hw_data->services_supported = adf_gen4_services_supported;
+	hw_data->services_supported = adf_420xx_services_supported;
 	hw_data->get_svc_slice_cnt = adf_gen4_get_svc_slice_cnt;
 	hw_data->accel_capabilities_ext_mask = ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S;
 
drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.h +6 -0
index 99abbfc14820..1fdaed3dd952 100644
@@ -17,6 +17,12 @@
 #define ADF_420XX_PARITYERRORMASK_PKE_MASK	(0xFFF)
 #define ADF_420XX_PARITYERRORMASK_WAT_WCP_MASK	(0x3FF03FF)
 
+#define ADF_420XX_SYM_ASYM_DC_RING_TO_SRV_MAP \
+	(ASYM << ADF_CFG_SERV_RING_PAIR_0_SHIFT | \
+	  SYM << ADF_CFG_SERV_RING_PAIR_1_SHIFT | \
+	 COMP << ADF_CFG_SERV_RING_PAIR_2_SHIFT | \
+	 COMP << ADF_CFG_SERV_RING_PAIR_3_SHIFT)
+
 /*
  * SSMFEATREN bit mask
  * BIT(4) - enables parity detection on CPP
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c +3 -0
index f7237c7ef2b1..ef245c2e80c1 100644
@@ -148,6 +148,9 @@ int adf_get_service_enabled(struct adf_accel_dev *accel_dev)
 	if (ret)
 		return ret;
 
+	if (test_bit(SVC_SYM, &mask) && test_bit(SVC_ASYM, &mask) && test_bit(SVC_DC, &mask))
+		return SVC_SYM_ASYM_DC;
+
 	if (test_bit(SVC_SYM, &mask) && test_bit(SVC_ASYM, &mask))
 		return SVC_SYM_ASYM;
 
drivers/crypto/intel/qat/qat_common/adf_cfg_services.h +1 -0
index 89be2f2c7233..d8b45645d2a9 100644
@@ -24,6 +24,7 @@ enum adf_composed_services {
 	SVC_SYM_ASYM = SVC_COUNT,
 	SVC_SYM_DC,
 	SVC_ASYM_DC,
+	SVC_SYM_ASYM_DC,
 };
 
 enum {
Signature · 1 line
2.50.1
author
#2 lore raw

PATCH v2 2/2 Documentation: qat: document three-service mode for QAT GEN5 devices

In reply to Ahsan Atta

From: Bairavi Alagappan <[email protected]>

Update the cfg_services sysfs attribute documentation to describe support for concurrent symmetric crypto, asymmetric crypto, and compression services on QAT GEN5 devices.

---
 Documentation/ABI/testing/sysfs-driver-qat | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-driver-qat +2 -2
index b0561b9fc4eb..48e17de3e0fd 100644
@@ -41,8 +41,8 @@ Description:	(RW) Reports the current configuration of the QAT device.
 
 		Service combinations are permitted for all services except dcc.
 		On QAT GEN4 devices (qat_4xxx driver) a maximum of two services can be
-		combined and on QAT GEN6 devices (qat_6xxx driver ) a maximum of three
-		services can be combined.
+		combined. On QAT GEN5 devices (qat_420xx driver) and GEN6 devices
+		(qat_6xxx driver) a maximum of three services can be combined.
 		The order of services is not significant. For instance, sym;asym is
 		functionally equivalent to asym;sym.
 
Signature · 1 line
2.50.1
maintainer
#3 lore raw
In reply to Ahsan Atta
Quoted 44 lines · Ahsan Atta

QAT GEN5 devices (qat_420xx) have enough accelerator engines to run three services concurrently, but the driver currently only allows a maximum of two to be configured at a time, matching the GEN4 limit.

This series lifts that restriction so that symmetric crypto, asymmetric crypto and compression can be enabled together on GEN5, as is already possible on GEN6 (qat_6xxx).

In summary:
Patch #1: Define the firmware object layout, ring-to-service mapping and thread-to-arbiter mapping required for the sym;asym;dc configuration on GEN5, and register the new service combination in adf_cfg_services so that it can be selected through the cfg_services sysfs attribute.

Patch #2: Update the cfg_services ABI documentation to state that GEN5 devices (qat_420xx) support a maximum of three combined services, alongside the existing GEN6 entry. Documentation only, no functional change.

There is an existing issue opened by Sashiko regarding the AE count when different services are configured on the device. That shall be addressed in later commits if applicable.

Changes in v2:
- Dropped the per-service AE accounting for rate limiting in three-service mode; it now uses the same AE count as the other GEN4/GEN5 configurations. This also resolves the stale-count issue reported by Sashiko.
- Renamed ADF_GEN4_SYM_ASYM_DC_RING_TO_SRV_MAP to ADF_420XX_SYM_ASYM_DC_RING_TO_SRV_MAP.

Bairavi Alagappan (2):
crypto: qat - enable three-service mode for QAT GEN5 devices
Documentation: qat: document three-service mode for QAT GEN5 devices

 Documentation/ABI/testing/sysfs-driver-qat    |  4 +-
 .../intel/qat/qat_420xx/adf_420xx_hw_data.c   | 59 ++++++++++++++++++-
 .../intel/qat/qat_420xx/adf_420xx_hw_data.h   |  6 ++
 .../intel/qat/qat_common/adf_cfg_services.c   |  3 +
 .../intel/qat/qat_common/adf_cfg_services.h   |  1 +
 5 files changed, 69 insertions(+), 4 deletions(-)
Quoted 3 lines

base-commit: 9c5d66e1ea78912b8a43ce16a1c14db1357e0ae0

Signature · 1 line
2.50.1

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt