crypto: qat - relocate PFVF PF related logic
authorMarco Chiappero <marco.chiappero@intel.com>
Wed, 17 Nov 2021 14:30:44 +0000 (14:30 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Nov 2021 05:20:46 +0000 (16:20 +1100)
Move device specific PFVF logic related to the PF to the newly created
adf_gen2_pfvf.c.
This refactory is done to isolate the GEN2 PFVF code into its own file
in preparation for the introduction of support for PFVF for GEN4
devices.

In addition the PFVF PF logic for dh895xcc has been isolated to
adf_dh895xcc_hw_data.c.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c
drivers/crypto/qat/qat_common/Makefile
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c [new file with mode: 0644]
drivers/crypto/qat/qat_common/adf_gen2_pfvf.h [new file with mode: 0644]
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h

index 1fa690219d9250d13cd58de4def91ff716f4481d..0bc528004f79d9c0c77af0c312d2b1050be1c446 100644 (file)
@@ -4,6 +4,7 @@
 #include <adf_common_drv.h>
 #include <adf_pf2vf_msg.h>
 #include <adf_gen2_hw_data.h>
+#include <adf_gen2_pfvf.h>
 #include "adf_c3xxx_hw_data.h"
 #include "icp_qat_hw.h"
 
index 0613db0776896ab10c4409e33ecad753dfd785ce..9303f2dbcaf9eb89ac400ad287cb329621c7264a 100644 (file)
@@ -4,6 +4,7 @@
 #include <adf_common_drv.h>
 #include <adf_pf2vf_msg.h>
 #include <adf_gen2_hw_data.h>
+#include <adf_gen2_pfvf.h>
 #include "adf_c62x_hw_data.h"
 #include "icp_qat_hw.h"
 
index 9c57abdf56b78db795e087e9bb0cf61718782932..3874e427d1f7e17042b4c661bf0c342e8b48af56 100644 (file)
@@ -16,7 +16,8 @@ intel_qat-objs := adf_cfg.o \
        qat_algs.o \
        qat_asym_algs.o \
        qat_uclo.o \
-       qat_hal.o
+       qat_hal.o \
+       adf_gen2_pfvf.o
 
 intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o
 intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o \
index 262bdc05dab4eda99282891f5db29aaa73502319..3b48fdaaff6d5c392d371ffeba82935d9ca7109c 100644 (file)
@@ -4,54 +4,6 @@
 #include "icp_qat_hw.h"
 #include <linux/pci.h>
 
-#define ADF_GEN2_PF2VF_OFFSET(i)       (0x3A000 + 0x280 + ((i) * 0x04))
-
-u32 adf_gen2_get_pf2vf_offset(u32 i)
-{
-       return ADF_GEN2_PF2VF_OFFSET(i);
-}
-EXPORT_SYMBOL_GPL(adf_gen2_get_pf2vf_offset);
-
-u32 adf_gen2_get_vf2pf_sources(void __iomem *pmisc_addr)
-{
-       u32 errsou3, errmsk3, vf_int_mask;
-
-       /* Get the interrupt sources triggered by VFs */
-       errsou3 = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRSOU3);
-       vf_int_mask = ADF_GEN2_ERR_REG_VF2PF(errsou3);
-
-       /* To avoid adding duplicate entries to work queue, clear
-        * vf_int_mask_sets bits that are already masked in ERRMSK register.
-        */
-       errmsk3 = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3);
-       vf_int_mask &= ~ADF_GEN2_ERR_REG_VF2PF(errmsk3);
-
-       return vf_int_mask;
-}
-EXPORT_SYMBOL_GPL(adf_gen2_get_vf2pf_sources);
-
-void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
-{
-       /* Enable VF2PF Messaging Ints - VFs 0 through 15 per vf_mask[15:0] */
-       if (vf_mask & 0xFFFF) {
-               u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
-                         & ~ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
-               ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
-       }
-}
-EXPORT_SYMBOL_GPL(adf_gen2_enable_vf2pf_interrupts);
-
-void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
-{
-       /* Disable VF2PF interrupts for VFs 0 through 15 per vf_mask[15:0] */
-       if (vf_mask & 0xFFFF) {
-               u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
-                         | ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
-               ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
-       }
-}
-EXPORT_SYMBOL_GPL(adf_gen2_disable_vf2pf_interrupts);
-
 u32 adf_gen2_get_num_accels(struct adf_hw_device_data *self)
 {
        if (!self || !self->accel_mask)
index c169d704097de8dfef9e23ee487f90057df91b43..448c97f740e7c24baaba95ae8a1f63e03c64f6c2 100644 (file)
@@ -136,19 +136,6 @@ do { \
 #define ADF_GEN2_CERRSSMSH(i)          ((i) * 0x4000 + 0x10)
 #define ADF_GEN2_ERRSSMSH_EN           BIT(3)
 
- /* VF2PF interrupts */
-#define ADF_GEN2_ERRSOU3 (0x3A000 + 0x0C)
-#define ADF_GEN2_ERRSOU5 (0x3A000 + 0xD8)
-#define ADF_GEN2_ERRMSK3 (0x3A000 + 0x1C)
-#define ADF_GEN2_ERRMSK5 (0x3A000 + 0xDC)
-#define ADF_GEN2_ERR_REG_VF2PF(vf_src) (((vf_src) & 0x01FFFE00) >> 9)
-#define ADF_GEN2_ERR_MSK_VF2PF(vf_mask)        (((vf_mask) & 0xFFFF) << 9)
-
-u32 adf_gen2_get_pf2vf_offset(u32 i);
-u32 adf_gen2_get_vf2pf_sources(void __iomem *pmisc_bar);
-void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask);
-void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask);
-
 u32 adf_gen2_get_num_accels(struct adf_hw_device_data *self);
 u32 adf_gen2_get_num_aes(struct adf_hw_device_data *self);
 void adf_gen2_enable_error_correction(struct adf_accel_dev *accel_dev);
diff --git a/drivers/crypto/qat/qat_common/adf_gen2_pfvf.c b/drivers/crypto/qat/qat_common/adf_gen2_pfvf.c
new file mode 100644 (file)
index 0000000..d4d7941
--- /dev/null
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
+/* Copyright(c) 2021 Intel Corporation */
+#include <linux/types.h>
+#include "adf_accel_devices.h"
+#include "adf_gen2_pfvf.h"
+
+ /* VF2PF interrupts */
+#define ADF_GEN2_ERR_REG_VF2PF(vf_src) (((vf_src) & 0x01FFFE00) >> 9)
+#define ADF_GEN2_ERR_MSK_VF2PF(vf_mask)        (((vf_mask) & 0xFFFF) << 9)
+
+#define ADF_GEN2_PF2VF_OFFSET(i)       (0x3A000 + 0x280 + ((i) * 0x04))
+
+u32 adf_gen2_get_pf2vf_offset(u32 i)
+{
+       return ADF_GEN2_PF2VF_OFFSET(i);
+}
+EXPORT_SYMBOL_GPL(adf_gen2_get_pf2vf_offset);
+
+u32 adf_gen2_get_vf2pf_sources(void __iomem *pmisc_addr)
+{
+       u32 errsou3, errmsk3, vf_int_mask;
+
+       /* Get the interrupt sources triggered by VFs */
+       errsou3 = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRSOU3);
+       vf_int_mask = ADF_GEN2_ERR_REG_VF2PF(errsou3);
+
+       /* To avoid adding duplicate entries to work queue, clear
+        * vf_int_mask_sets bits that are already masked in ERRMSK register.
+        */
+       errmsk3 = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3);
+       vf_int_mask &= ~ADF_GEN2_ERR_REG_VF2PF(errmsk3);
+
+       return vf_int_mask;
+}
+EXPORT_SYMBOL_GPL(adf_gen2_get_vf2pf_sources);
+
+void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
+{
+       /* Enable VF2PF Messaging Ints - VFs 0 through 15 per vf_mask[15:0] */
+       if (vf_mask & 0xFFFF) {
+               u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
+                         & ~ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
+               ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
+       }
+}
+EXPORT_SYMBOL_GPL(adf_gen2_enable_vf2pf_interrupts);
+
+void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
+{
+       /* Disable VF2PF interrupts for VFs 0 through 15 per vf_mask[15:0] */
+       if (vf_mask & 0xFFFF) {
+               u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
+                         | ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
+               ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
+       }
+}
+EXPORT_SYMBOL_GPL(adf_gen2_disable_vf2pf_interrupts);
diff --git a/drivers/crypto/qat/qat_common/adf_gen2_pfvf.h b/drivers/crypto/qat/qat_common/adf_gen2_pfvf.h
new file mode 100644 (file)
index 0000000..0987e25
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */
+/* Copyright(c) 2021 Intel Corporation */
+#ifndef ADF_GEN2_PFVF_H
+#define ADF_GEN2_PFVF_H
+
+#include <linux/types.h>
+#include "adf_accel_devices.h"
+
+#define ADF_GEN2_ERRSOU3 (0x3A000 + 0x0C)
+#define ADF_GEN2_ERRSOU5 (0x3A000 + 0xD8)
+#define ADF_GEN2_ERRMSK3 (0x3A000 + 0x1C)
+#define ADF_GEN2_ERRMSK5 (0x3A000 + 0xDC)
+
+u32 adf_gen2_get_pf2vf_offset(u32 i);
+u32 adf_gen2_get_vf2pf_sources(void __iomem *pmisc_bar);
+void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask);
+void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask);
+
+#endif /* ADF_GEN2_PFVF_H */
index 8e2e1554dcf6a2ef3014bf1bb366d09e237d5257..e134385b76a8c39e6190d79e59e1c1778b32b9a2 100644 (file)
@@ -4,6 +4,7 @@
 #include <adf_pf2vf_msg.h>
 #include <adf_common_drv.h>
 #include <adf_gen2_hw_data.h>
+#include <adf_gen2_pfvf.h>
 #include "adf_dh895xcc_hw_data.h"
 #include "icp_qat_hw.h"
 
@@ -114,14 +115,19 @@ static void adf_enable_ints(struct adf_accel_dev *accel_dev)
 
 static u32 get_vf2pf_sources(void __iomem *pmisc_bar)
 {
-       u32 errsou5, errmsk5, vf_int_mask;
+       u32 errsou3, errmsk3, errsou5, errmsk5, vf_int_mask;
 
-       vf_int_mask = adf_gen2_get_vf2pf_sources(pmisc_bar);
+       /* Get the interrupt sources triggered by VFs */
+       errsou3 = ADF_CSR_RD(pmisc_bar, ADF_GEN2_ERRSOU3);
+       vf_int_mask = ADF_DH895XCC_ERR_REG_VF2PF_L(errsou3);
 
-       /* Get the interrupt sources triggered by VFs, but to avoid duplicates
-        * in the work queue, clear vf_int_mask_sets bits that are already
-        * masked in ERRMSK register.
+       /* To avoid adding duplicate entries to work queue, clear
+        * vf_int_mask_sets bits that are already masked in ERRMSK register.
         */
+       errmsk3 = ADF_CSR_RD(pmisc_bar, ADF_GEN2_ERRMSK3);
+       vf_int_mask &= ~ADF_DH895XCC_ERR_REG_VF2PF_L(errmsk3);
+
+       /* Do the same for ERRSOU5 */
        errsou5 = ADF_CSR_RD(pmisc_bar, ADF_GEN2_ERRSOU5);
        errmsk5 = ADF_CSR_RD(pmisc_bar, ADF_GEN2_ERRMSK5);
        vf_int_mask |= ADF_DH895XCC_ERR_REG_VF2PF_U(errsou5);
@@ -133,7 +139,11 @@ static u32 get_vf2pf_sources(void __iomem *pmisc_bar)
 static void enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
 {
        /* Enable VF2PF Messaging Ints - VFs 0 through 15 per vf_mask[15:0] */
-       adf_gen2_enable_vf2pf_interrupts(pmisc_addr, vf_mask);
+       if (vf_mask & 0xFFFF) {
+               u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
+                         & ~ADF_DH895XCC_ERR_MSK_VF2PF_L(vf_mask);
+               ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
+       }
 
        /* Enable VF2PF Messaging Ints - VFs 16 through 31 per vf_mask[31:16] */
        if (vf_mask >> 16) {
@@ -147,7 +157,11 @@ static void enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
 static void disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
 {
        /* Disable VF2PF interrupts for VFs 0 through 15 per vf_mask[15:0] */
-       adf_gen2_disable_vf2pf_interrupts(pmisc_addr, vf_mask);
+       if (vf_mask & 0xFFFF) {
+               u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
+                         | ADF_DH895XCC_ERR_MSK_VF2PF_L(vf_mask);
+               ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
+       }
 
        /* Disable VF2PF interrupts for VFs 16 through 31 per vf_mask[31:16] */
        if (vf_mask >> 16) {
index 0af34dd8708ac3f4e1c580ed8f7f8c766333149c..aa17272a1507b26bdb9c55eaf59b6ce4aaf5f50f 100644 (file)
@@ -25,6 +25,8 @@
 #define ADF_DH895XCC_SMIA1_MASK 0x1
 
 /* Masks for VF2PF interrupts */
+#define ADF_DH895XCC_ERR_REG_VF2PF_L(vf_src)   (((vf_src) & 0x01FFFE00) >> 9)
+#define ADF_DH895XCC_ERR_MSK_VF2PF_L(vf_mask)  (((vf_mask) & 0xFFFF) << 9)
 #define ADF_DH895XCC_ERR_REG_VF2PF_U(vf_src)   (((vf_src) & 0x0000FFFF) << 16)
 #define ADF_DH895XCC_ERR_MSK_VF2PF_U(vf_mask)  ((vf_mask) >> 16)