crypto: qat - PFVF refactoring
v2 cover crypto: qat - PFVF refactoring
This set includes fixes to the PFVF logic but also refactoring in preparation for updates to the protocol and support for QAT GEN4 devices.
The main changes introduced by this set are:
* A fix for a bug introduced in the previous PFVF set related to an undetected timeout;
* The refactoring and rework of the PFVF message handling logic which includes changes to the ACK behaviour;
* The introduction of adf_pfvf_gen2.c which includes logic common to QAT GEN 2 devices;
* The introduction of the pfvf_ops structure to isolate PFVF related code inside the adf_hw_device_data structure and facilitate the introduction of PFVF for QAT GEN4;
* The reorganization of the PFVF code structure so that message logic is separated from low level communication primitives and the protocol.
Changes from v1:
- Fixed compilation error with CONFIG_PCI_IOV=n, reported by kernel test robot <[email protected]>
Giovanni Cabiddu (6):
crypto: qat - fix undetected PFVF timeout in ACK loop
crypto: qat - move vf2pf interrupt helpers
crypto: qat - change PFVF ACK behaviour
crypto: qat - re-enable interrupts for legacy PFVF messages
crypto: qat - relocate PFVF disabled function
crypto: qat - abstract PFVF receive logic
Marco Chiappero (18):
crypto: qat - refactor PF top half for PFVF
crypto: qat - move VF message handler to adf_vf2pf_msg.c
crypto: qat - move interrupt code out of the PFVF handler
crypto: qat - split PFVF message decoding from handling
crypto: qat - handle retries due to collisions in adf_iov_putmsg()
crypto: qat - relocate PFVF PF related logic
crypto: qat - relocate PFVF VF related logic
crypto: qat - add pfvf_ops
crypto: qat - differentiate between pf2vf and vf2pf offset
crypto: qat - abstract PFVF send function
crypto: qat - reorganize PFVF code
crypto: qat - reorganize PFVF protocol definitions
crypto: qat - use enums for PFVF protocol codes
crypto: qat - pass the PF2VF responses back to the callers
crypto: qat - refactor pfvf version request messages
crypto: qat - do not rely on min version
crypto: qat - fix VF IDs in PFVF log messages
crypto: qat - improve logging of PFVF messages
.../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 11 +-
.../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 11 +-
.../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 14 +-
.../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.h | 1 -
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 2 +-
.../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 11 +-
.../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 14 +-
.../qat/qat_c62xvf/adf_c62xvf_hw_data.h | 1 -
drivers/crypto/qat/qat_c62xvf/adf_drv.c | 2 +-
drivers/crypto/qat/qat_common/Makefile | 6 +-
.../crypto/qat/qat_common/adf_accel_devices.h | 25 +-
.../crypto/qat/qat_common/adf_common_drv.h | 30 +-
.../crypto/qat/qat_common/adf_gen2_hw_data.c | 48 --
.../crypto/qat/qat_common/adf_gen2_hw_data.h | 13 -
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 222 ++++++++++
drivers/crypto/qat/qat_common/adf_gen2_pfvf.h | 29 ++
.../crypto/qat/qat_common/adf_gen4_hw_data.c | 7 +
drivers/crypto/qat/qat_common/adf_init.c | 2 +-
drivers/crypto/qat/qat_common/adf_isr.c | 123 ++++--
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 416 ------------------
.../{adf_pf2vf_msg.h => adf_pfvf_msg.h} | 68 +--
.../crypto/qat/qat_common/adf_pfvf_pf_msg.c | 21 +
.../crypto/qat/qat_common/adf_pfvf_pf_msg.h | 10 +
.../crypto/qat/qat_common/adf_pfvf_pf_proto.c | 145 ++++++
.../crypto/qat/qat_common/adf_pfvf_pf_proto.h | 13 +
.../crypto/qat/qat_common/adf_pfvf_vf_msg.c | 97 ++++
.../crypto/qat/qat_common/adf_pfvf_vf_msg.h | 21 +
.../crypto/qat/qat_common/adf_pfvf_vf_proto.c | 134 ++++++
.../crypto/qat/qat_common/adf_pfvf_vf_proto.h | 14 +
drivers/crypto/qat/qat_common/adf_sriov.c | 20 +-
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 48 --
drivers/crypto/qat/qat_common/adf_vf_isr.c | 92 ++--
.../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 41 +-
.../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 2 +
.../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 14 +-
.../qat_dh895xccvf/adf_dh895xccvf_hw_data.h | 1 -
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 2 +-
37 files changed, 953 insertions(+), 778 deletions(-)
create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c
create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_pfvf.h
delete mode 100644 drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
rename drivers/crypto/qat/qat_common/{adf_pf2vf_msg.h => adf_pfvf_msg.h} (81%)
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.h
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.h
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.h
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.h
delete mode 100644 drivers/crypto/qat/qat_common/adf_vf2pf_msg.cSignature · 1 line
2.33.1
PATCH v2 1/24 crypto: qat - fix undetected PFVF timeout in ACK loop
If the remote function did not ACK the reception of a message, the function __adf_iov_putmsg() could detect it as a collision.
This was due to the fact that the collision and the timeout checks after the ACK loop were in the wrong order. The timeout must be checked at the end of the loop, so fix by swapping the order of the two checks.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +6 -6
@@ -107,6 +107,12 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) val =ADF_CSR_RD (pmisc_bar_addr, pf2vf_offset); }while ((val & int_bit) && (count++ <ADF_PFVF_MSG_ACK_MAX_RETRY )); +if (val & int_bit) { +dev_dbg (&GET_DEV (accel_dev),"ACK not received from remote\n" ); + val &= ~int_bit; + ret = -EIO ; + } +if (val != msg) {dev_dbg (&GET_DEV (accel_dev),"Collision - PFVF CSR overwritten by remote function\n" );
@@ -114,12 +120,6 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) goto out; } -if (val & int_bit) { -dev_dbg (&GET_DEV (accel_dev),"ACK not received from remote\n" ); - val &= ~int_bit; - ret = -EIO ; - } -/* Finished with the PFVF CSR; relinquish it and leave msg in CSR */ ADF_CSR_WR (pmisc_bar_addr, pf2vf_offset, val & ~local_in_use_mask); out:
Signature · 1 line
2.33.1
PATCH v2 2/24 crypto: qat - refactor PF top half for PFVF
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Move logic associated to handling VF2PF interrupt to its own function. This will simplify the handling of multiple interrupt sources in the function adf_msix_isr_ae() in the future.
--- drivers/crypto/qat/qat_common/adf_isr.c | 84 +++++++++++++------------ 1 file changed, 44 insertions(+), 40 deletions(-)
drivers/crypto/qat/qat_common/adf_isr.c +44 -40
@@ -54,52 +54,56 @@ static irqreturn_t adf_msix_isr_bundle(int irq, void *bank_ptr)return IRQ_HANDLED ; } +#ifdef CONFIG_PCI_IOV +static bool adf_handle_vf2pf_int (struct adf_accel_dev *accel_dev) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +int bar_id = hw_data->get_misc_bar_id (hw_data); +struct adf_bar *pmisc = &GET_BARS (accel_dev)[bar_id]; +void __iomem *pmisc_addr = pmisc->virt_addr; +bool irq_handled = false; +unsigned long vf_mask; + +/* Get the interrupt sources triggered by VFs */ + vf_mask = hw_data->get_vf2pf_sources (pmisc_addr); + +if (vf_mask) { +struct adf_accel_vf_info *vf_info; +int i; + +/* Disable VF2PF interrupts for VFs with pending ints */ +adf_disable_vf2pf_interrupts_irq (accel_dev, vf_mask); + +/* +* Handle VF2PF interrupt unless the VF is malicious and +* is attempting to flood the host OS with VF2PF interrupts. +*/ +for_each_set_bit (i, &vf_mask,ADF_MAX_NUM_VFS ) { + vf_info = accel_dev->pf.vf_info + i; + +if (!__ratelimit (&vf_info->vf2pf_ratelimit)) { +dev_info (&GET_DEV (accel_dev), +"Too many ints from VF%d\n" , + vf_info->vf_nr +1 ); +continue ; + } + +adf_schedule_vf2pf_handler (vf_info); + irq_handled = true; + } + } +return irq_handled; +} +#endif /* CONFIG_PCI_IOV */ +static irqreturn_t adf_msix_isr_ae (int irq,void *dev_ptr) {struct adf_accel_dev *accel_dev = dev_ptr;#ifdef CONFIG_PCI_IOV /* If SR-IOV is enabled (vf_info is non-NULL), check for VF->PF ints */ -if (accel_dev->pf.vf_info) { -struct adf_hw_device_data *hw_data = accel_dev->hw_device; -struct adf_bar *pmisc = - &GET_BARS (accel_dev)[hw_data->get_misc_bar_id (hw_data)]; -void __iomem *pmisc_addr = pmisc->virt_addr; -unsigned long vf_mask; - -/* Get the interrupt sources triggered by VFs */ - vf_mask = hw_data->get_vf2pf_sources (pmisc_addr); - -if (vf_mask) { -struct adf_accel_vf_info *vf_info; -bool irq_handled = false; -int i; - -/* Disable VF2PF interrupts for VFs with pending ints */ -adf_disable_vf2pf_interrupts_irq (accel_dev, vf_mask); - -/* -* Handle VF2PF interrupt unless the VF is malicious and -* is attempting to flood the host OS with VF2PF interrupts. -*/ -for_each_set_bit (i, &vf_mask,ADF_MAX_NUM_VFS ) { - vf_info = accel_dev->pf.vf_info + i; - -if (!__ratelimit (&vf_info->vf2pf_ratelimit)) { -dev_info (&GET_DEV (accel_dev), -"Too many ints from VF%d\n" , - vf_info->vf_nr +1 ); -continue ; - } - -adf_schedule_vf2pf_handler (vf_info); - irq_handled = true; - } - -if (irq_handled) -return IRQ_HANDLED ; - } - } +if (accel_dev->pf.vf_info &&adf_handle_vf2pf_int (accel_dev)) +return IRQ_HANDLED ;#endif /* CONFIG_PCI_IOV */ dev_dbg(&GET_DEV(accel_dev), "qat_dev%d spurious AE interrupt\n",
Signature · 1 line
2.33.1
PATCH v2 3/24 crypto: qat - move vf2pf interrupt helpers
In reply to Giovanni CabidduMove vf2pf interrupt enable and disable functions from adf_pf2vf_msg.c to adf_isr.c
This it to separate the interrupt related code from the PFVF protocol logic.
With this change, the function adf_disable_vf2pf_interrupts_irq() is only called from adf_isr.c and it has been marked as static.
--- .../crypto/qat/qat_common/adf_common_drv.h | 2 - drivers/crypto/qat/qat_common/adf_isr.c | 39 +++++++++++++++++++ drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 39 ------------------- 3 files changed, 39 insertions(+), 41 deletions(-)
drivers/crypto/qat/qat_common/adf_common_drv.h +0 -2
@@ -192,8 +192,6 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs);void adf_disable_sriov (struct adf_accel_dev *accel_dev);void adf_disable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask); -void adf_disable_vf2pf_interrupts_irq (struct adf_accel_dev *accel_dev, -u32 vf_mask);void adf_enable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask);int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_isr.c +39 -0
@@ -55,6 +55,45 @@ static irqreturn_t adf_msix_isr_bundle(int irq, void *bank_ptr) }#ifdef CONFIG_PCI_IOV +void adf_enable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +u32 misc_bar_id = hw_data->get_misc_bar_id (hw_data); +struct adf_bar *pmisc = &GET_BARS (accel_dev)[misc_bar_id]; +void __iomem *pmisc_addr = pmisc->virt_addr; +unsigned long flags; + +spin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags); + hw_data->enable_vf2pf_interrupts (pmisc_addr, vf_mask); +spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); +} + +void adf_disable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +u32 misc_bar_id = hw_data->get_misc_bar_id (hw_data); +struct adf_bar *pmisc = &GET_BARS (accel_dev)[misc_bar_id]; +void __iomem *pmisc_addr = pmisc->virt_addr; +unsigned long flags; + +spin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags); + hw_data->disable_vf2pf_interrupts (pmisc_addr, vf_mask); +spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); +} + +static void adf_disable_vf2pf_interrupts_irq (struct adf_accel_dev *accel_dev, +u32 vf_mask) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +u32 misc_bar_id = hw_data->get_misc_bar_id (hw_data); +struct adf_bar *pmisc = &GET_BARS (accel_dev)[misc_bar_id]; +void __iomem *pmisc_addr = pmisc->virt_addr; + +spin_lock (&accel_dev->pf.vf2pf_ints_lock); + hw_data->disable_vf2pf_interrupts (pmisc_addr, vf_mask); +spin_unlock (&accel_dev->pf.vf2pf_ints_lock); +} +static bool adf_handle_vf2pf_int (struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_data = accel_dev->hw_device;
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +0 -39
@@ -14,45 +14,6 @@ ADF_PFVF_MSG_ACK_MAX_RETRY + \ ADF_PFVF_MSG_COLLISION_DETECT_DELAY) -void adf_enable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask) -{ -struct adf_hw_device_data *hw_data = accel_dev->hw_device; -u32 misc_bar_id = hw_data->get_misc_bar_id (hw_data); -struct adf_bar *pmisc = &GET_BARS (accel_dev)[misc_bar_id]; -void __iomem *pmisc_addr = pmisc->virt_addr; -unsigned long flags; - -spin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags); - hw_data->enable_vf2pf_interrupts (pmisc_addr, vf_mask); -spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); -} - -void adf_disable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask) -{ -struct adf_hw_device_data *hw_data = accel_dev->hw_device; -u32 misc_bar_id = hw_data->get_misc_bar_id (hw_data); -struct adf_bar *pmisc = &GET_BARS (accel_dev)[misc_bar_id]; -void __iomem *pmisc_addr = pmisc->virt_addr; -unsigned long flags; - -spin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags); - hw_data->disable_vf2pf_interrupts (pmisc_addr, vf_mask); -spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); -} - -void adf_disable_vf2pf_interrupts_irq (struct adf_accel_dev *accel_dev, -u32 vf_mask) -{ -struct adf_hw_device_data *hw_data = accel_dev->hw_device; -u32 misc_bar_id = hw_data->get_misc_bar_id (hw_data); -struct adf_bar *pmisc = &GET_BARS (accel_dev)[misc_bar_id]; -void __iomem *pmisc_addr = pmisc->virt_addr; - -spin_lock (&accel_dev->pf.vf2pf_ints_lock); - hw_data->disable_vf2pf_interrupts (pmisc_addr, vf_mask); -spin_unlock (&accel_dev->pf.vf2pf_ints_lock); -} -static int __adf_iov_putmsg (struct adf_accel_dev *accel_dev,u32 msg,u8 vf_nr) {struct adf_accel_pci *pci_info = &accel_dev->accel_pci_dev;
Signature · 1 line
2.33.1
PATCH v2 4/24 crypto: qat - move VF message handler to adf_vf2pf_msg.c
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Move the reading and parsing of a PF2VF message from the bottom half function in adf_vf_isr.c, adf_pf2vf_bh_handler(), to the PFVF protocol file adf_vf2pf_msg.c, for better code organization.
The receive and handle logic has been moved to a new function called adf_recv_and_handle_pf2vf_msg() which returns a boolean indicating if interrupts need to be re-enabled or not.
A slight refactoring has been done to avoid calculating the PF2VF CSR offset twice and repeating the clearing of the PF2VFINT bit.
The "PF restarting" logic, now defined in the function adf_pf2vf_handle_pf_restaring(), has been kept in adf_vf_isr.c due to the dependencies with the adf_vf_stop_wq workqueue.
--- .../crypto/qat/qat_common/adf_common_drv.h | 2 + drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 59 ++++++++++++ drivers/crypto/qat/qat_common/adf_vf_isr.c | 91 +++++-------------- 3 files changed, 86 insertions(+), 66 deletions(-)
drivers/crypto/qat/qat_common/adf_common_drv.h +2 -0
@@ -194,6 +194,8 @@ void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask);void adf_enable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask); +bool adf_recv_and_handle_pf2vf_msg (struct adf_accel_dev *accel_dev); +int adf_pf2vf_handle_pf_restarting (struct adf_accel_dev *accel_dev);int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev);void adf_enable_pf2vf_interrupts (struct adf_accel_dev *accel_dev);void adf_disable_pf2vf_interrupts (struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c +59 -0
62 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_vf_isr.c +25 -66
103 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 5/24 crypto: qat - move interrupt code out of the PFVF handler
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Move the interrupt handling call from the PF specific protocol file, adf_pf2vf_msg.c, to adf_sriov.c to maintain the PFVF files focused on the protocol handling.
The function adf_vf2pf_req_hndl() has been renamed as adf_recv_and_handle_vf2pf_msg() to reflect its actual purpose and maintain consistency with the VF side. This function now returns a boolean indicating to the caller if interrupts need to be re-enabled or not.
--- drivers/crypto/qat/qat_common/adf_common_drv.h | 2 +- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 15 ++++++--------- drivers/crypto/qat/qat_common/adf_sriov.c | 10 +++++++++- 3 files changed, 16 insertions(+), 11 deletions(-)
drivers/crypto/qat/qat_common/adf_common_drv.h +1 -1
@@ -64,7 +64,6 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev);void adf_pf2vf_notify_restarting (struct adf_accel_dev *accel_dev);int adf_enable_vf2pf_comms (struct adf_accel_dev *accel_dev); -void adf_vf2pf_req_hndl (struct adf_accel_vf_info *vf_info);void adf_devmgr_update_class_index (struct adf_hw_device_data *hw_data);void adf_clean_vf_map (bool );
@@ -195,6 +194,7 @@ void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,void adf_enable_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 vf_mask);bool adf_recv_and_handle_pf2vf_msg (struct adf_accel_dev *accel_dev); +bool adf_recv_and_handle_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 vf_nr);int adf_pf2vf_handle_pf_restarting (struct adf_accel_dev *accel_dev);int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev);void adf_enable_pf2vf_interrupts (struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +6 -9
@@ -178,21 +178,21 @@ static int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg)return 0 ; } -void adf_vf2pf_req_hndl (struct adf_accel_vf_info *vf_info) +bool adf_recv_and_handle_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 vf_nr) { -struct adf_accel_dev *accel_dev = vf_info->accel_dev; +struct adf_accel_vf_info *vf_info = &accel_dev->pf.vf_info[vf_nr];struct adf_hw_device_data *hw_data = accel_dev->hw_device;int bar_id = hw_data->get_misc_bar_id (hw_data);struct adf_bar *pmisc = &GET_BARS (accel_dev)[bar_id];void __iomem *pmisc_addr = pmisc->virt_addr; -u32 msg, resp =0 , vf_nr = vf_info->vf_nr; +u32 msg, resp =0 ;/* Read message from the VF */ msg =ADF_CSR_RD (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr));if (!(msg &ADF_VF2PF_INT )) {dev_info (&GET_DEV (accel_dev),"Spurious VF2PF interrupt, msg %X. Ignored\n" , msg); - goto out; +return true; }/* To ACK, clear the VF2PFINT bit */
@@ -277,14 +277,11 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)if (resp &&adf_send_pf2vf_msg (accel_dev, vf_nr, resp))dev_err (&GET_DEV (accel_dev),"Failed to send response to VF\n" ); -out: -/* re-enable interrupt on PF from this VF */ -adf_enable_vf2pf_interrupts (accel_dev, (1 << vf_nr)); - -return ; +return true; err:dev_dbg (&GET_DEV (accel_dev),"Unknown message from VF%d (0x%x);\n" , vf_nr +1 , msg); +return false; }void adf_pf2vf_notify_restarting (struct adf_accel_dev *accel_dev)
drivers/crypto/qat/qat_common/adf_sriov.c +9 -1
@@ -19,8 +19,16 @@ static void adf_iov_send_resp(struct work_struct *work) {struct adf_pf2vf_resp *pf2vf_resp = container_of(work, struct adf_pf2vf_resp, pf2vf_resp_work); +struct adf_accel_vf_info *vf_info = pf2vf_resp->vf_info; +struct adf_accel_dev *accel_dev = vf_info->accel_dev; +u32 vf_nr = vf_info->vf_nr; +bool ret; + + ret =adf_recv_and_handle_vf2pf_msg (accel_dev, vf_nr); +if (ret) +/* re-enable interrupt on PF from this VF */ +adf_enable_vf2pf_interrupts (accel_dev,1 << vf_nr); -adf_vf2pf_req_hndl (pf2vf_resp->vf_info);kfree (pf2vf_resp); }
Signature · 1 line
2.33.1
PATCH v2 6/24 crypto: qat - change PFVF ACK behaviour
In reply to Giovanni CabidduChange the PFVF receipt flow on the VF side to read, ack and handle the message instead of read, handle and ack.
This is done for (1) consistency with the PF side, see the function adf_recv_and_handle_vf2pf_msg() in adf_pf2vf_msg.c, and (2) performance reasons, to avoid keeping the CSR busy while parsing the message.
In addition, do not ACK PFVF legacy messages, as this driver is not capable of handling PFVF legacy messages.
If a PFVF message with MSGORIGIN not set is received, do nothing.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 8 ++++---- drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +4 -4
@@ -195,14 +195,14 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)return true; } -/* To ACK, clear the VF2PFINT bit */ - msg &= ~ADF_VF2PF_INT ; -ADF_CSR_WR (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr), msg); -if (!(msg &ADF_VF2PF_MSGORIGIN_SYSTEM ))/* Ignore legacy non-system (non-kernel) VF2PF messages */ goto err; +/* To ACK, clear the VF2PFINT bit */ + msg &= ~ADF_VF2PF_INT ; +ADF_CSR_WR (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr), msg); +switch ((msg &ADF_VF2PF_MSGTYPE_MASK ) >>ADF_VF2PF_MSGTYPE_SHIFT ) {case ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ : {
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c +4 -3
@@ -69,6 +69,10 @@ bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev)/* Ignore legacy non-system (non-kernel) PF2VF messages */ goto err; +/* To ack, clear the PF2VFINT bit */ + msg &= ~ADF_PF2VF_INT ; +ADF_CSR_WR (pmisc_bar_addr, offset, msg); +switch ((msg &ADF_PF2VF_MSGTYPE_MASK ) >>ADF_PF2VF_MSGTYPE_SHIFT ) {case ADF_PF2VF_MSGTYPE_RESTARTING : dev_dbg(&GET_DEV(accel_dev),
@@ -93,9 +97,6 @@ bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev) goto err; } -/* To ack, clear the PF2VFINT bit */ - msg &= ~ADF_PF2VF_INT ; -ADF_CSR_WR (pmisc_bar_addr, offset, msg);return ret; err:
Signature · 1 line
2.33.1
PATCH v2 7/24 crypto: qat - re-enable interrupts for legacy PFVF messages
In reply to Giovanni CabidduIf a PFVF message with MSGORIGIN_SYSTEM not set is received, re-enable interrupts allowing the processing of new messages.
This is to simplify the refactoring of the recv function in a subsequent patch.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 2 +- drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +1 -1
@@ -197,7 +197,7 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)if (!(msg &ADF_VF2PF_MSGORIGIN_SYSTEM ))/* Ignore legacy non-system (non-kernel) VF2PF messages */ - goto err; +return true;/* To ACK, clear the VF2PFINT bit */ msg &= ~ADF_VF2PF_INT ;
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c +1 -1
@@ -67,7 +67,7 @@ bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev)if (!(msg &ADF_PF2VF_MSGORIGIN_SYSTEM ))/* Ignore legacy non-system (non-kernel) PF2VF messages */ - goto err; +return true;/* To ack, clear the PF2VFINT bit */ msg &= ~ADF_PF2VF_INT ;
Signature · 1 line
2.33.1
PATCH v2 8/24 crypto: qat - split PFVF message decoding from handling
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Refactor the receive and handle logic to separate the parsing and handling of the PFVF message from the initial retrieval and ACK.
This is to allow the intoduction of the recv function in a subsequent patch.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 68 ++++++++++++------- drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 62 ++++++++--------- 2 files changed, 71 insertions(+), 59 deletions(-)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +42 -26
@@ -178,30 +178,12 @@ static int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg)return 0 ; } -bool adf_recv_and_handle_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 vf_nr) +static int adf_handle_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 vf_nr, +u32 msg,u32 *response) {struct adf_accel_vf_info *vf_info = &accel_dev->pf.vf_info[vf_nr];struct adf_hw_device_data *hw_data = accel_dev->hw_device; -int bar_id = hw_data->get_misc_bar_id (hw_data); -struct adf_bar *pmisc = &GET_BARS (accel_dev)[bar_id]; -void __iomem *pmisc_addr = pmisc->virt_addr; -u32 msg, resp =0 ; - -/* Read message from the VF */ - msg =ADF_CSR_RD (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr)); -if (!(msg &ADF_VF2PF_INT )) { -dev_info (&GET_DEV (accel_dev), -"Spurious VF2PF interrupt, msg %X. Ignored\n" , msg); -return true; - } - -if (!(msg &ADF_VF2PF_MSGORIGIN_SYSTEM )) -/* Ignore legacy non-system (non-kernel) VF2PF messages */ -return true; - -/* To ACK, clear the VF2PFINT bit */ - msg &= ~ADF_VF2PF_INT ; -ADF_CSR_WR (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr), msg); +u32 resp =0 ;switch ((msg &ADF_VF2PF_MSGTYPE_MASK ) >>ADF_VF2PF_MSGTYPE_SHIFT ) {case ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ :
@@ -271,17 +253,51 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr) }break ;default : - goto err; +dev_dbg (&GET_DEV (accel_dev),"Unknown message from VF%d (0x%x)\n" , + vf_nr +1 , msg); +return -ENOMSG ; + } + + *response = resp; + +return 0 ; +} + +bool adf_recv_and_handle_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 vf_nr) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +int bar_id = hw_data->get_misc_bar_id (hw_data); +struct adf_bar *pmisc = &GET_BARS (accel_dev)[bar_id]; +void __iomem *pmisc_addr = pmisc->virt_addr; +u32 msg, resp =0 ; + +/* Read message from the VF */ + msg =ADF_CSR_RD (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr)); +if (!(msg &ADF_VF2PF_INT )) { +dev_info (&GET_DEV (accel_dev), +"Spurious VF2PF interrupt, msg %X. Ignored\n" , msg); +return true; + } + +/* Ignore legacy non-system (non-kernel) VF2PF messages */ +if (!(msg &ADF_VF2PF_MSGORIGIN_SYSTEM )) { +dev_dbg (&GET_DEV (accel_dev), +"Ignored non-system message from VF%d (0x%x);\n" , + vf_nr +1 , msg); +return true; } +/* To ACK, clear the VF2PFINT bit */ + msg &= ~ADF_VF2PF_INT ; +ADF_CSR_WR (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr), msg); + +if (adf_handle_vf2pf_msg (accel_dev, vf_nr, msg, &resp)) +return false; +if (resp &&adf_send_pf2vf_msg (accel_dev, vf_nr, resp))dev_err (&GET_DEV (accel_dev),"Failed to send response to VF\n" );return true; -err: -dev_dbg (&GET_DEV (accel_dev),"Unknown message from VF%d (0x%x);\n" , - vf_nr +1 , msg); -return false; }void adf_pf2vf_notify_restarting (struct adf_accel_dev *accel_dev)
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c +29 -33
78 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 9/24 crypto: qat - handle retries due to collisions in adf_iov_putmsg()
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Rework __adf_iov_putmsg() to handle retries due to collisions internally, removing the need for an external retry loop. The functions __adf_iov_putmsg() and adf_iov_putmsg() have been merged together maintaining the adf_iov_putmsg() name.
This will allow to use this function only for GEN2 devices, since collision are peculiar of this generation and therefore should be confined to the actual implementation of the transport/medium access.
Note that now adf_iov_putmsg() will retry to send a message only in case of collisions and will now fail if an ACK is not received from the remote function.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +19 -33
@@ -14,7 +14,7 @@ ADF_PFVF_MSG_ACK_MAX_RETRY + \ ADF_PFVF_MSG_COLLISION_DETECT_DELAY) -static int __adf_iov_putmsg (struct adf_accel_dev *accel_dev,u32 msg,u8 vf_nr) +static int adf_iov_putmsg (struct adf_accel_dev *accel_dev,u32 msg,u8 vf_nr) {struct adf_accel_pci *pci_info = &accel_dev->accel_pci_dev;struct adf_hw_device_data *hw_data = accel_dev->hw_device;
@@ -24,8 +24,9 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)u32 local_in_use_mask, local_in_use_pattern;u32 remote_in_use_mask, remote_in_use_pattern;struct mutex *lock;/* lock preventing concurrent acces of CSR */ +unsigned int retries =ADF_PFVF_MSG_MAX_RETRIES ;u32 int_bit; -int ret =0 ; +int ret;if (accel_dev->is_vf) { pf2vf_offset = hw_data->get_pf2vf_offset (0 );
@@ -45,20 +46,22 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) int_bit =ADF_PF2VF_INT ; } + msg &= ~local_in_use_mask; + msg |= local_in_use_pattern; +mutex_lock (lock); +start: + ret =0 ; +/* Check if the PFVF CSR is in use by remote function */ val =ADF_CSR_RD (pmisc_bar_addr, pf2vf_offset);if ((val & remote_in_use_mask) == remote_in_use_pattern) {dev_dbg (&GET_DEV (accel_dev),"PFVF CSR in use by remote function\n" ); - ret = -EBUSY ; - goto out; + goto retry; } - msg &= ~local_in_use_mask; - msg |= local_in_use_pattern; -/* Attempt to get ownership of the PFVF CSR */ ADF_CSR_WR (pmisc_bar_addr, pf2vf_offset, msg | int_bit);
@@ -77,8 +80,7 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)if (val != msg) {dev_dbg (&GET_DEV (accel_dev),"Collision - PFVF CSR overwritten by remote function\n" ); - ret = -EIO ; - goto out; + goto retry; }/* Finished with the PFVF CSR; relinquish it and leave msg in CSR */
@@ -86,31 +88,15 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) out:mutex_unlock (lock);return ret; -} -/** -* adf_iov_putmsg() - send PFVF message -* @accel_dev: Pointer to acceleration device. -* @msg: Message to send -* @vf_nr: VF number to which the message will be sent if on PF, ignored -* otherwise -* -* Function sends a message through the PFVF channel -* -* Return: 0 on success, error code otherwise. -*/ -static int adf_iov_putmsg (struct adf_accel_dev *accel_dev,u32 msg,u8 vf_nr) -{ -u32 count =0 ; -int ret; - -do { - ret =__adf_iov_putmsg (accel_dev, msg, vf_nr); -if (ret) -msleep (ADF_PFVF_MSG_RETRY_DELAY ); - }while (ret && (count++ <ADF_PFVF_MSG_MAX_RETRIES )); - -return ret; +retry: +if (--retries) { +msleep (ADF_PFVF_MSG_RETRY_DELAY ); + goto start; + }else { + ret = -EBUSY ; + goto out; + } }/**
Signature · 1 line
2.33.1
PATCH v2 10/24 crypto: qat - relocate PFVF PF related logic
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
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 the file adf_dh895xcc_hw_data.c.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 1 + drivers/crypto/qat/qat_common/Makefile | 3 +- .../crypto/qat/qat_common/adf_gen2_hw_data.c | 48 ---------------- .../crypto/qat/qat_common/adf_gen2_hw_data.h | 13 ----- drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 57 +++++++++++++++++++ drivers/crypto/qat/qat_common/adf_gen2_pfvf.h | 19 +++++++ .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 28 ++++++--- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 2 + 9 files changed, 103 insertions(+), 69 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_pfvf.h
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -0
@@ -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"
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -0
@@ -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"
drivers/crypto/qat/qat_common/Makefile +2 -1
@@ -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 \
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +0 -48
54 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +0 -13
@@ -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);
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c new file +57 -0
57 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen2_pfvf.h new file +19 -0
@@ -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 */
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +21 -7
@@ -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 ) {
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h +2 -0
@@ -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)
Signature · 1 line
2.33.1
PATCH v2 11/24 crypto: qat - relocate PFVF VF related logic
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Move device specific PFVF logic related to the VF 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.
--- drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 2 +- .../crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 8 ++------ .../crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.h | 1 - drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c | 2 +- .../crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c | 8 ++------ .../crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.h | 1 - drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 15 +++++++++++---- drivers/crypto/qat/qat_common/adf_gen2_pfvf.h | 3 ++- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 2 +- .../qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 8 ++------ .../qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.h | 1 - 11 files changed, 22 insertions(+), 29 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -1
@@ -136,7 +136,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; - hw_data->get_pf2vf_offset = adf_gen2_get_pf2vf_offset; + hw_data->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; hw_data->get_vf2pf_sources = adf_gen2_get_vf2pf_sources; hw_data->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts; hw_data->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts;
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +2 -6
@@ -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_c3xxxvf_hw_data.h" static struct adf_hw_device_class c3xxxiov_class = {
@@ -47,11 +48,6 @@ static enum dev_sku_info get_sku(struct adf_hw_device_data *self)return DEV_SKU_VF ; } -static u32 get_pf2vf_offset (u32 i) -{ -return ADF_C3XXXIOV_PF2VF_OFFSET ; -} -static int adf_vf_int_noop (struct adf_accel_dev *accel_dev) {return 0 ;
@@ -86,7 +82,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; - hw_data->get_pf2vf_offset = get_pf2vf_offset; + hw_data->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; hw_data->enable_pfvf_comms = adf_enable_vf2pf_comms;
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.h +0 -1
@@ -12,7 +12,6 @@#define ADF_C3XXXIOV_TX_RINGS_MASK 0xFF#define ADF_C3XXXIOV_ETR_BAR 0#define ADF_C3XXXIOV_ETR_MAX_BANKS 1 -#define ADF_C3XXXIOV_PF2VF_OFFSET 0x200void adf_init_hw_data_c3xxxiov (struct adf_hw_device_data *hw_data);void adf_clean_hw_data_c3xxxiov (struct adf_hw_device_data *hw_data);
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -1
@@ -138,7 +138,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; - hw_data->get_pf2vf_offset = adf_gen2_get_pf2vf_offset; + hw_data->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; hw_data->get_vf2pf_sources = adf_gen2_get_vf2pf_sources; hw_data->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts; hw_data->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts;
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +2 -6
@@ -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_c62xvf_hw_data.h" static struct adf_hw_device_class c62xiov_class = {
@@ -47,11 +48,6 @@ static enum dev_sku_info get_sku(struct adf_hw_device_data *self)return DEV_SKU_VF ; } -static u32 get_pf2vf_offset (u32 i) -{ -return ADF_C62XIOV_PF2VF_OFFSET ; -} -static int adf_vf_int_noop (struct adf_accel_dev *accel_dev) {return 0 ;
@@ -86,7 +82,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; - hw_data->get_pf2vf_offset = get_pf2vf_offset; + hw_data->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; hw_data->enable_pfvf_comms = adf_enable_vf2pf_comms;
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.h +0 -1
@@ -12,7 +12,6 @@#define ADF_C62XIOV_TX_RINGS_MASK 0xFF#define ADF_C62XIOV_ETR_BAR 0#define ADF_C62XIOV_ETR_MAX_BANKS 1 -#define ADF_C62XIOV_PF2VF_OFFSET 0x200void adf_init_hw_data_c62xiov (struct adf_hw_device_data *hw_data);void adf_clean_hw_data_c62xiov (struct adf_hw_device_data *hw_data);
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +11 -4
@@ -8,13 +8,20 @@#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)) +#define ADF_GEN2_PF_PF2VF_OFFSET (i) (0x3A000 + 0x280 + ((i) * 0x04)) +#define ADF_GEN2_VF_PF2VF_OFFSET 0x200 -u32 adf_gen2_get_pf2vf_offset (u32 i) +u32 adf_gen2_pf_get_pf2vf_offset (u32 i) { -return ADF_GEN2_PF2VF_OFFSET (i); +return ADF_GEN2_PF_PF2VF_OFFSET (i); } -EXPORT_SYMBOL_GPL (adf_gen2_get_pf2vf_offset); +EXPORT_SYMBOL_GPL (adf_gen2_pf_get_pf2vf_offset); + +u32 adf_gen2_vf_get_pf2vf_offset (u32 i) +{ +return ADF_GEN2_VF_PF2VF_OFFSET ; +} +EXPORT_SYMBOL_GPL (adf_gen2_vf_get_pf2vf_offset);u32 adf_gen2_get_vf2pf_sources (void __iomem *pmisc_addr) {
drivers/crypto/qat/qat_common/adf_gen2_pfvf.h +2 -1
@@ -11,7 +11,8 @@#define ADF_GEN2_ERRMSK3 (0x3A000 + 0x1C)#define ADF_GEN2_ERRMSK5 (0x3A000 + 0xDC) -u32 adf_gen2_get_pf2vf_offset (u32 i); +u32 adf_gen2_pf_get_pf2vf_offset (u32 i); +u32 adf_gen2_vf_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);
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -1
@@ -215,7 +215,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->get_arb_mapping = adf_get_arbiter_mapping; hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_sbr; - hw_data->get_pf2vf_offset = adf_gen2_get_pf2vf_offset; + hw_data->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; hw_data->get_vf2pf_sources = get_vf2pf_sources; hw_data->enable_vf2pf_interrupts = enable_vf2pf_interrupts; hw_data->disable_vf2pf_interrupts = disable_vf2pf_interrupts;
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +2 -6
@@ -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_dh895xccvf_hw_data.h" static struct adf_hw_device_class dh895xcciov_class = {
@@ -47,11 +48,6 @@ static enum dev_sku_info get_sku(struct adf_hw_device_data *self)return DEV_SKU_VF ; } -static u32 get_pf2vf_offset (u32 i) -{ -return ADF_DH895XCCIOV_PF2VF_OFFSET ; -} -static int adf_vf_int_noop (struct adf_accel_dev *accel_dev) {return 0 ;
@@ -86,7 +82,7 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; - hw_data->get_pf2vf_offset = get_pf2vf_offset; + hw_data->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; hw_data->enable_pfvf_comms = adf_enable_vf2pf_comms;
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.h +0 -1
@@ -12,7 +12,6 @@#define ADF_DH895XCCIOV_TX_RINGS_MASK 0xFF#define ADF_DH895XCCIOV_ETR_BAR 0#define ADF_DH895XCCIOV_ETR_MAX_BANKS 1 -#define ADF_DH895XCCIOV_PF2VF_OFFSET 0x200void adf_init_hw_data_dh895xcciov (struct adf_hw_device_data *hw_data);void adf_clean_hw_data_dh895xcciov (struct adf_hw_device_data *hw_data);
Signature · 1 line
2.33.1
PATCH v2 12/24 crypto: qat - relocate PFVF disabled function
In reply to Giovanni CabidduMove the function pfvf_comms_disabled() from the qat_4xxx module to intel_qat as it will be used by other components to keep the PFVF feature disabled.
--- drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 7 +------ drivers/crypto/qat/qat_common/adf_common_drv.h | 2 ++ drivers/crypto/qat/qat_common/adf_gen4_hw_data.c | 7 +++++++ 3 files changed, 10 insertions(+), 6 deletions(-)
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +1 -6
@@ -191,11 +191,6 @@ static int adf_init_device(struct adf_accel_dev *accel_dev)return ret; } -static int pfvf_comms_disabled (struct adf_accel_dev *accel_dev) -{ -return 0 ; -} -static u32 uof_get_num_objs (void ) {return ARRAY_SIZE (adf_4xxx_fw_config);
@@ -253,7 +248,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data) hw_data->uof_get_ae_mask = uof_get_ae_mask; hw_data->set_msix_rttable = set_msix_default_rttable; hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer; - hw_data->enable_pfvf_comms = pfvf_comms_disabled; + hw_data->enable_pfvf_comms = adf_pfvf_comms_disabled; hw_data->disable_iov = adf_disable_sriov; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ;
drivers/crypto/qat/qat_common/adf_common_drv.h +2 -0
@@ -129,6 +129,8 @@ void adf_isr_resource_free(struct adf_accel_dev *accel_dev);int adf_vf_isr_resource_alloc (struct adf_accel_dev *accel_dev);void adf_vf_isr_resource_free (struct adf_accel_dev *accel_dev); +int adf_pfvf_comms_disabled (struct adf_accel_dev *accel_dev); +int qat_hal_init (struct adf_accel_dev *accel_dev);void qat_hal_deinit (struct icp_qat_fw_loader_handle *handle);int qat_hal_start (struct icp_qat_fw_loader_handle *handle);
drivers/crypto/qat/qat_common/adf_gen4_hw_data.c +7 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2020 Intel Corporation */ #include "adf_accel_devices.h" +#include "adf_common_drv.h" #include "adf_gen4_hw_data.h" static u64 build_csr_ring_base_addr (dma_addr_t addr,u32 size)
@@ -139,3 +140,9 @@ void adf_gen4_set_ssm_wdtimer(struct adf_accel_dev *accel_dev)ADF_CSR_WR (pmisc_addr,ADF_SSMWDTPKEH_OFFSET , ssm_wdt_pke_high); }EXPORT_SYMBOL_GPL (adf_gen4_set_ssm_wdtimer); + +int adf_pfvf_comms_disabled (struct adf_accel_dev *accel_dev) +{ +return 0 ; +} +EXPORT_SYMBOL_GPL (adf_pfvf_comms_disabled);
Signature · 1 line
2.33.1
PATCH v2 13/24 crypto: qat - add pfvf_ops
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Add pfvf_ops structure to isolate PFVF related functions inside the adf_hw_device_data structure.
For GEN2, the structure is populated using one of the two helper functions, adf_gen2_init_pf_pfvf_ops() or adf_gen2_init_vf_pfvf_ops(), for the PF and VF driver respectively.
For the DH895XCC PF driver, the structure is populated using adf_gen2_init_pf_pfvf_ops() but some of the functions are then overwritten.
--- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 2 +- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 6 +--- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 3 +- .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 6 +--- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 3 +- drivers/crypto/qat/qat_common/Makefile | 6 ++-- .../crypto/qat/qat_common/adf_accel_devices.h | 17 ++++++---- drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 33 +++++++++++++------ drivers/crypto/qat/qat_common/adf_gen2_pfvf.h | 19 ++++++++--- drivers/crypto/qat/qat_common/adf_init.c | 2 +- drivers/crypto/qat/qat_common/adf_isr.c | 8 ++--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 8 ++--- drivers/crypto/qat/qat_common/adf_sriov.c | 6 ++-- drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 2 +- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 9 +++-- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 3 +- 16 files changed, 73 insertions(+), 60 deletions(-)
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +1 -1
@@ -248,7 +248,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data) hw_data->uof_get_ae_mask = uof_get_ae_mask; hw_data->set_msix_rttable = set_msix_default_rttable; hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer; - hw_data->enable_pfvf_comms = adf_pfvf_comms_disabled; + hw_data->pfvf_ops.enable_comms = adf_pfvf_comms_disabled; hw_data->disable_iov = adf_disable_sriov; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ;
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -5
@@ -136,14 +136,10 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; - hw_data->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; - hw_data->get_vf2pf_sources = adf_gen2_get_vf2pf_sources; - hw_data->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts; - hw_data->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts; - hw_data->enable_pfvf_comms = adf_enable_pf2vf_comms; hw_data->disable_iov = adf_disable_sriov; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; +adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +1 -2
@@ -82,13 +82,12 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; - hw_data->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; - hw_data->enable_pfvf_comms = adf_enable_vf2pf_comms; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data); +adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -5
@@ -138,14 +138,10 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; - hw_data->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; - hw_data->get_vf2pf_sources = adf_gen2_get_vf2pf_sources; - hw_data->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts; - hw_data->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts; - hw_data->enable_pfvf_comms = adf_enable_pf2vf_comms; hw_data->disable_iov = adf_disable_sriov; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; +adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +1 -2
@@ -82,13 +82,12 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; - hw_data->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; - hw_data->enable_pfvf_comms = adf_enable_vf2pf_comms; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data); +adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }
drivers/crypto/qat/qat_common/Makefile +3 -3
@@ -16,9 +16,9 @@ intel_qat-objs := adf_cfg.o \ qat_algs.o \ qat_asym_algs.o \ qat_uclo.o \ - qat_hal.o \ - adf_gen2_pfvf.o + qat_hal.o intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o \ - adf_vf2pf_msg.o adf_vf_isr.o + adf_vf2pf_msg.o adf_vf_isr.o \ + adf_gen2_pfvf.o
drivers/crypto/qat/qat_common/adf_accel_devices.h +10 -7
@@ -147,6 +147,14 @@ struct adf_accel_dev;struct adf_etr_data ;struct adf_etr_ring_data ; +struct adf_pfvf_ops { +int (*enable_comms)(struct adf_accel_dev *accel_dev); +u32 (*get_pf2vf_offset)(u32 i); +u32 (*get_vf2pf_sources)(void __iomem *pmisc_addr); +void (*enable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask); +void (*disable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask); +}; +struct adf_hw_device_data {struct adf_hw_device_class *dev_class;u32 (*get_accel_mask)(struct adf_hw_device_data *self);
@@ -157,7 +165,6 @@ struct adf_hw_device_data {u32 (*get_etr_bar_id)(struct adf_hw_device_data *self);u32 (*get_num_aes)(struct adf_hw_device_data *self);u32 (*get_num_accels)(struct adf_hw_device_data *self); -u32 (*get_pf2vf_offset)(u32 i);void (*get_arb_info)(struct arb_info *arb_csrs_info);void (*get_admin_info)(struct admin_info *admin_csrs_info);enum dev_sku_info (*get_sku)(struct adf_hw_device_data *self);
@@ -176,17 +183,12 @@ struct adf_hw_device_data { bool enable);void (*enable_ints)(struct adf_accel_dev *accel_dev);void (*set_ssm_wdtimer)(struct adf_accel_dev *accel_dev); -int (*enable_pfvf_comms)(struct adf_accel_dev *accel_dev); -u32 (*get_vf2pf_sources)(void__iomem *pmisc_addr); -void (*enable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr, -u32 vf_mask); -void (*disable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr, -u32 vf_mask);void (*reset_device)(struct adf_accel_dev *accel_dev);void (*set_msix_rttable)(struct adf_accel_dev *accel_dev);char *(*uof_get_name)(u32 obj_num);u32 (*uof_get_num_objs)(void);u32 (*uof_get_ae_mask)(u32 obj_num); +struct adf_pfvf_ops pfvf_ops;struct adf_hw_csr_ops csr_ops;const char *fw_name;const char *fw_mmp_name;
@@ -222,6 +224,7 @@ struct adf_hw_device_data { GET_HW_DATA(accel_dev)->num_rings_per_bank#define GET_MAX_ACCELENGINES (accel_dev) (GET_HW_DATA(accel_dev)->num_engines)#define GET_CSR_OPS (accel_dev) (&(accel_dev)->hw_device->csr_ops) +#define GET_PFVF_OPS (accel_dev) (&(accel_dev)->hw_device->pfvf_ops)#define accel_to_pci_dev (accel_ptr) accel_ptr->accel_pci_dev.pci_devstruct adf_admin_comms ;
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +23 -10
@@ -2,6 +2,7 @@/* Copyright(c) 2021 Intel Corporation */ #include <linux/types.h> #include "adf_accel_devices.h" +#include "adf_common_drv.h" #include "adf_gen2_pfvf.h" /* VF2PF interrupts */
@@ -11,19 +12,17 @@#define ADF_GEN2_PF_PF2VF_OFFSET (i) (0x3A000 + 0x280 + ((i) * 0x04))#define ADF_GEN2_VF_PF2VF_OFFSET 0x200 -u32 adf_gen2_pf_get_pf2vf_offset (u32 i) +static u32 adf_gen2_pf_get_pf2vf_offset (u32 i) {return ADF_GEN2_PF_PF2VF_OFFSET (i); } -EXPORT_SYMBOL_GPL (adf_gen2_pf_get_pf2vf_offset); -u32 adf_gen2_vf_get_pf2vf_offset (u32 i) +static u32 adf_gen2_vf_get_pf2vf_offset (u32 i) {return ADF_GEN2_VF_PF2VF_OFFSET ; } -EXPORT_SYMBOL_GPL (adf_gen2_vf_get_pf2vf_offset); -u32 adf_gen2_get_vf2pf_sources (void __iomem *pmisc_addr) +static u32 adf_gen2_get_vf2pf_sources (void __iomem *pmisc_addr) {u32 errsou3, errmsk3, vf_int_mask;
@@ -39,9 +38,8 @@ u32 adf_gen2_get_vf2pf_sources(void __iomem *pmisc_addr)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) +static 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 ) {
@@ -50,9 +48,8 @@ void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 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) +static 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 ) {
@@ -61,4 +58,20 @@ void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)ADF_CSR_WR (pmisc_addr,ADF_GEN2_ERRMSK3 , val); } } -EXPORT_SYMBOL_GPL (adf_gen2_disable_vf2pf_interrupts); + +void adf_gen2_init_pf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops) +{ + pfvf_ops->enable_comms = adf_enable_pf2vf_comms; + pfvf_ops->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; + pfvf_ops->get_vf2pf_sources = adf_gen2_get_vf2pf_sources; + pfvf_ops->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts; + pfvf_ops->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts; +} +EXPORT_SYMBOL_GPL (adf_gen2_init_pf_pfvf_ops); + +void adf_gen2_init_vf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops) +{ + pfvf_ops->enable_comms = adf_enable_vf2pf_comms; + pfvf_ops->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; +} +EXPORT_SYMBOL_GPL (adf_gen2_init_vf_pfvf_ops);
drivers/crypto/qat/qat_common/adf_gen2_pfvf.h +14 -5
@@ -11,10 +11,19 @@#define ADF_GEN2_ERRMSK3 (0x3A000 + 0x1C)#define ADF_GEN2_ERRMSK5 (0x3A000 + 0xDC) -u32 adf_gen2_pf_get_pf2vf_offset (u32 i); -u32 adf_gen2_vf_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); +#if defined(CONFIG_PCI_IOV ) +void adf_gen2_init_pf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops); +void adf_gen2_init_vf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops); +#else +static inline void adf_gen2_init_pf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops) +{ + pfvf_ops->enable_comms = adf_pfvf_comms_disabled; +} + +static inline void adf_gen2_init_vf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops) +{ + pfvf_ops->enable_comms = adf_pfvf_comms_disabled; +} +#endif #endif /* ADF_GEN2_PFVF_H */
drivers/crypto/qat/qat_common/adf_init.c +1 -1
@@ -117,7 +117,7 @@ int adf_dev_init(struct adf_accel_dev *accel_dev) hw_data->enable_ints (accel_dev); hw_data->enable_error_correction (accel_dev); - ret = hw_data->enable_pfvf_comms (accel_dev); + ret = hw_data->pfvf_ops.enable_comms (accel_dev);if (ret)return ret;
drivers/crypto/qat/qat_common/adf_isr.c +4 -4
@@ -64,7 +64,7 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)unsigned long flags;spin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags); - hw_data->enable_vf2pf_interrupts (pmisc_addr, vf_mask); + hw_data->pfvf_ops.enable_vf2pf_interrupts (pmisc_addr, vf_mask);spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); }
@@ -77,7 +77,7 @@ void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)unsigned long flags;spin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags); - hw_data->disable_vf2pf_interrupts (pmisc_addr, vf_mask); + hw_data->pfvf_ops.disable_vf2pf_interrupts (pmisc_addr, vf_mask);spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); }
@@ -90,7 +90,7 @@ static void adf_disable_vf2pf_interrupts_irq(struct adf_accel_dev *accel_dev,void __iomem *pmisc_addr = pmisc->virt_addr;spin_lock (&accel_dev->pf.vf2pf_ints_lock); - hw_data->disable_vf2pf_interrupts (pmisc_addr, vf_mask); + hw_data->pfvf_ops.disable_vf2pf_interrupts (pmisc_addr, vf_mask);spin_unlock (&accel_dev->pf.vf2pf_ints_lock); }
@@ -104,7 +104,7 @@ static bool adf_handle_vf2pf_int(struct adf_accel_dev *accel_dev)unsigned long vf_mask;/* Get the interrupt sources triggered by VFs */ - vf_mask = hw_data->get_vf2pf_sources (pmisc_addr); + vf_mask = hw_data->pfvf_ops.get_vf2pf_sources (pmisc_addr);if (vf_mask) {struct adf_accel_vf_info *vf_info;
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +4 -4
@@ -29,7 +29,7 @@ static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)int ret;if (accel_dev->is_vf) { - pf2vf_offset = hw_data->get_pf2vf_offset (0 ); + pf2vf_offset = hw_data->pfvf_ops.get_pf2vf_offset (0 ); lock = &accel_dev->vf.vf2pf_lock; local_in_use_mask =ADF_VF2PF_IN_USE_BY_VF_MASK ; local_in_use_pattern =ADF_VF2PF_IN_USE_BY_VF ;
@@ -37,7 +37,7 @@ static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) remote_in_use_pattern =ADF_PF2VF_IN_USE_BY_PF ; int_bit =ADF_VF2PF_INT ; }else { - pf2vf_offset = hw_data->get_pf2vf_offset (vf_nr); + pf2vf_offset = hw_data->pfvf_ops.get_pf2vf_offset (vf_nr); lock = &accel_dev->pf.vf_info[vf_nr].pf2vf_lock; local_in_use_mask =ADF_PF2VF_IN_USE_BY_PF_MASK ; local_in_use_pattern =ADF_PF2VF_IN_USE_BY_PF ;
@@ -258,7 +258,7 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)u32 msg, resp =0 ;/* Read message from the VF */ - msg =ADF_CSR_RD (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr)); + msg =ADF_CSR_RD (pmisc_addr, hw_data->pfvf_ops.get_pf2vf_offset (vf_nr));if (!(msg &ADF_VF2PF_INT )) {dev_info (&GET_DEV (accel_dev),"Spurious VF2PF interrupt, msg %X. Ignored\n" , msg);
@@ -275,7 +275,7 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)/* To ACK, clear the VF2PFINT bit */ msg &= ~ADF_VF2PF_INT ; -ADF_CSR_WR (pmisc_addr, hw_data->get_pf2vf_offset (vf_nr), msg); +ADF_CSR_WR (pmisc_addr, hw_data->pfvf_ops.get_pf2vf_offset (vf_nr), msg);if (adf_handle_vf2pf_msg (accel_dev, vf_nr, msg, &resp))return false;
drivers/crypto/qat/qat_common/adf_sriov.c +3 -3
@@ -70,7 +70,7 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev) hw_data->configure_iov_threads (accel_dev, true);/* Enable VF to PF interrupts for all VFs */ -if (hw_data->get_pf2vf_offset) +if (hw_data->pfvf_ops.get_pf2vf_offset)adf_enable_vf2pf_interrupts (accel_dev,BIT_ULL (totalvfs) -1 );/*
@@ -100,13 +100,13 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)if (!accel_dev->pf.vf_info)return ; -if (hw_data->get_pf2vf_offset) +if (hw_data->pfvf_ops.get_pf2vf_offset)adf_pf2vf_notify_restarting (accel_dev);pci_disable_sriov (accel_to_pci_dev (accel_dev));/* Disable VF to PF interrupts */ -if (hw_data->get_pf2vf_offset) +if (hw_data->pfvf_ops.get_pf2vf_offset)adf_disable_vf2pf_interrupts (accel_dev,GENMASK (31 ,0 ));/* Clear Valid bits in AE Thread to PCIe Function Mapping */
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c +1 -1
@@ -81,7 +81,7 @@ bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev)struct adf_bar *pmisc = &GET_BARS (accel_dev)[hw_data->get_misc_bar_id (hw_data)];void __iomem *pmisc_bar_addr = pmisc->virt_addr; -u32 offset = hw_data->get_pf2vf_offset (0 ); +u32 offset = hw_data->pfvf_ops.get_pf2vf_offset (0 );u32 msg;/* Read the message from PF */
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +4 -5
@@ -215,14 +215,13 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->get_arb_mapping = adf_get_arbiter_mapping; hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_sbr; - hw_data->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; - hw_data->get_vf2pf_sources = get_vf2pf_sources; - hw_data->enable_vf2pf_interrupts = enable_vf2pf_interrupts; - hw_data->disable_vf2pf_interrupts = disable_vf2pf_interrupts; - hw_data->enable_pfvf_comms = adf_enable_pf2vf_comms; hw_data->disable_iov = adf_disable_sriov; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; +adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops); + hw_data->pfvf_ops.get_vf2pf_sources = get_vf2pf_sources; + hw_data->pfvf_ops.enable_vf2pf_interrupts = enable_vf2pf_interrupts; + hw_data->pfvf_ops.disable_vf2pf_interrupts = disable_vf2pf_interrupts;adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +1 -2
@@ -82,13 +82,12 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; - hw_data->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; - hw_data->enable_pfvf_comms = adf_enable_vf2pf_comms; hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data); +adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }
Signature · 1 line
2.33.1
PATCH v2 14/24 crypto: qat - differentiate between pf2vf and vf2pf offset
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Add the function get_vf2pf_offset() to adf_pfvf_ops to differentiate the CSRs used for pf2vf and vf2pf.
Offsets may or may not be direction specific depending on QAT generation. Since in QAT GEN2 the CSR is not direction specific, i.e. there is a single mailbox register shared for pf2vf and vf2pf, both get_vf2pf_offset() and get_vf2pf_offset() will return the same offset.
This change is to make the direction explicit, so it is easier to understand and debug and also in preparation for the introduction of PFVF support in the qat_4xxx driver since QAT GEN4 devices have a separate CSR for pf2vf and vf2pf communications.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 10 ++++++---- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -150,6 +150,7 @@ struct adf_etr_ring_data;struct adf_pfvf_ops {int (*enable_comms)(struct adf_accel_dev *accel_dev);u32 (*get_pf2vf_offset)(u32 i); +u32 (*get_vf2pf_offset)(u32 i);u32 (*get_vf2pf_sources)(void __iomem *pmisc_addr);void (*enable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask);void (*disable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask);
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +6 -4
@@ -12,12 +12,12 @@#define ADF_GEN2_PF_PF2VF_OFFSET (i) (0x3A000 + 0x280 + ((i) * 0x04))#define ADF_GEN2_VF_PF2VF_OFFSET 0x200 -static u32 adf_gen2_pf_get_pf2vf_offset (u32 i) +static u32 adf_gen2_pf_get_pfvf_offset (u32 i) {return ADF_GEN2_PF_PF2VF_OFFSET (i); } -static u32 adf_gen2_vf_get_pf2vf_offset (u32 i) +static u32 adf_gen2_vf_get_pfvf_offset (u32 i) {return ADF_GEN2_VF_PF2VF_OFFSET ; }
@@ -62,7 +62,8 @@ static void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mvoid adf_gen2_init_pf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops) { pfvf_ops->enable_comms = adf_enable_pf2vf_comms; - pfvf_ops->get_pf2vf_offset = adf_gen2_pf_get_pf2vf_offset; + pfvf_ops->get_pf2vf_offset = adf_gen2_pf_get_pfvf_offset; + pfvf_ops->get_vf2pf_offset = adf_gen2_pf_get_pfvf_offset; pfvf_ops->get_vf2pf_sources = adf_gen2_get_vf2pf_sources; pfvf_ops->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts; pfvf_ops->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts;
@@ -72,6 +73,7 @@ EXPORT_SYMBOL_GPL(adf_gen2_init_pf_pfvf_ops);void adf_gen2_init_vf_pfvf_ops (struct adf_pfvf_ops *pfvf_ops) { pfvf_ops->enable_comms = adf_enable_vf2pf_comms; - pfvf_ops->get_pf2vf_offset = adf_gen2_vf_get_pf2vf_offset; + pfvf_ops->get_pf2vf_offset = adf_gen2_vf_get_pfvf_offset; + pfvf_ops->get_vf2pf_offset = adf_gen2_vf_get_pfvf_offset; }EXPORT_SYMBOL_GPL (adf_gen2_init_vf_pfvf_ops);
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +3 -3
@@ -29,7 +29,7 @@ static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)int ret;if (accel_dev->is_vf) { - pf2vf_offset = hw_data->pfvf_ops.get_pf2vf_offset (0 ); + pf2vf_offset = hw_data->pfvf_ops.get_vf2pf_offset (0 ); lock = &accel_dev->vf.vf2pf_lock; local_in_use_mask =ADF_VF2PF_IN_USE_BY_VF_MASK ; local_in_use_pattern =ADF_VF2PF_IN_USE_BY_VF ;
@@ -258,7 +258,7 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)u32 msg, resp =0 ;/* Read message from the VF */ - msg =ADF_CSR_RD (pmisc_addr, hw_data->pfvf_ops.get_pf2vf_offset (vf_nr)); + msg =ADF_CSR_RD (pmisc_addr, hw_data->pfvf_ops.get_vf2pf_offset (vf_nr));if (!(msg &ADF_VF2PF_INT )) {dev_info (&GET_DEV (accel_dev),"Spurious VF2PF interrupt, msg %X. Ignored\n" , msg);
@@ -275,7 +275,7 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)/* To ACK, clear the VF2PFINT bit */ msg &= ~ADF_VF2PF_INT ; -ADF_CSR_WR (pmisc_addr, hw_data->pfvf_ops.get_pf2vf_offset (vf_nr), msg); +ADF_CSR_WR (pmisc_addr, hw_data->pfvf_ops.get_vf2pf_offset (vf_nr), msg);if (adf_handle_vf2pf_msg (accel_dev, vf_nr, msg, &resp))return false;
Signature · 1 line
2.33.1
PATCH v2 15/24 crypto: qat - abstract PFVF send function
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Make the PFVF send function device specific.
This is in preparation for the introduction of PFVF support in the qat_4xxx driver since the send logic differs between QAT GEN2 and QAT GEN4 devices.
--- .../crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 96 +++++++++++++++++++ drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 92 +----------------- drivers/crypto/qat/qat_common/adf_pf2vf_msg.h | 3 +- 4 files changed, 101 insertions(+), 91 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -154,6 +154,7 @@ struct adf_pfvf_ops {u32 (*get_vf2pf_sources)(void__iomem *pmisc_addr);void (*enable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask);void (*disable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask); +int (*send_msg)(struct adf_accel_dev *accel_dev,u32 msg,u8 vf_nr); };struct adf_hw_device_data {
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +96 -0
128 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +2 -90
119 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_pf2vf_msg.h +2 -1
@@ -49,7 +49,8 @@* * When a PF or VF attempts to send a message in the lower or upper 16 bits, * respectively, the other 16 bits are written to first with a defined -* IN_USE_BY pattern as part of a collision control scheme (see adf_iov_putmsg). +* IN_USE_BY pattern as part of a collision control scheme (see function +* adf_gen2_pfvf_send() in adf_pf2vf_msg.c). */ #define ADF_PFVF_COMPAT_THIS_VERSION 0x1/* PF<->VF compat */
Signature · 1 line
2.33.1
PATCH v2 16/24 crypto: qat - abstract PFVF receive logic
In reply to Giovanni CabidduRefactor the PFVF receive logic so it is common between PF and VF and make it device specific.
This is in preparation for the introduction of PFVF support in the qat_4xxx driver since the receive logic differs between QAT GEN2 and QAT GEN4 devices.
--- .../crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 45 +++++++++++++++++++ drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 41 ++++++++--------- drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 38 +++++++--------- 4 files changed, 81 insertions(+), 44 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -155,6 +155,7 @@ struct adf_pfvf_ops {void (*enable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask);void (*disable_vf2pf_interrupts)(void __iomem *pmisc_bar_addr,u32 vf_mask);int (*send_msg)(struct adf_accel_dev *accel_dev,u32 msg,u8 vf_nr); +u32 (*recv_msg)(struct adf_accel_dev *accel_dev,u8 vf_nr); };struct adf_hw_device_data {
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +45 -0
62 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +18 -23
55 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c +17 -21
@@ -47,6 +47,19 @@ void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev) }EXPORT_SYMBOL_GPL (adf_vf2pf_notify_shutdown); +/** +* adf_recv_pf2vf_msg() - receive a PF to VF message +* @accel_dev: Pointer to acceleration device +* +* This function allows the VF to receive a message from the PF. +* +* Return: a valid message on success, zero otherwise. +*/ +static u32 adf_recv_pf2vf_msg (struct adf_accel_dev *accel_dev) +{ +return GET_PFVF_OPS (accel_dev)->recv_msg (accel_dev,0 ); +} +static bool adf_handle_pf2vf_msg (struct adf_accel_dev *accel_dev,u32 msg) {switch ((msg &ADF_PF2VF_MSGTYPE_MASK ) >>ADF_PF2VF_MSGTYPE_SHIFT ) {
@@ -77,28 +90,11 @@ static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg)bool adf_recv_and_handle_pf2vf_msg (struct adf_accel_dev *accel_dev) { -struct adf_hw_device_data *hw_data = accel_dev->hw_device; -struct adf_bar *pmisc = - &GET_BARS (accel_dev)[hw_data->get_misc_bar_id (hw_data)]; -void __iomem *pmisc_bar_addr = pmisc->virt_addr; -u32 offset = hw_data->pfvf_ops.get_pf2vf_offset (0 );u32 msg; -/* Read the message from PF */ - msg =ADF_CSR_RD (pmisc_bar_addr, offset); -if (!(msg &ADF_PF2VF_INT )) { -dev_info (&GET_DEV (accel_dev), -"Spurious PF2VF interrupt, msg %X. Ignored\n" , msg); -return true; - } - -if (!(msg &ADF_PF2VF_MSGORIGIN_SYSTEM )) -/* Ignore legacy non-system (non-kernel) PF2VF messages */ -return true; - -/* To ack, clear the PF2VFINT bit */ - msg &= ~ADF_PF2VF_INT ; -ADF_CSR_WR (pmisc_bar_addr, offset, msg); + msg =adf_recv_pf2vf_msg (accel_dev); +if (msg) +return adf_handle_pf2vf_msg (accel_dev, msg); -return adf_handle_pf2vf_msg (accel_dev, msg); +return true; }
Signature · 1 line
2.33.1
PATCH v2 17/24 crypto: qat - reorganize PFVF code
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Reorganize the structure of the PFVF code by moving the content of adf_pf2vf_msg.c and adf_vf2pf_msg.c.
The logic that handles high level messages has been moved to adf_pfvf_pf_msg.c and adf_pfvf_vf_msg.c.
The implementation of low level communication primitives and the protocol is now included in adf_pfvf_pf_proto.c and adf_pfvf_vf_proto.c.
In addition, the file adf_pf2vf_msg.h has been renamed in adf_pfvf_msg.h since it common to PF and VF and the copyright date for the touched files has been updated.
---
.../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 4 +-
.../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 4 +-
.../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 5 +-
.../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 4 +-
.../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 5 +-
drivers/crypto/qat/qat_common/Makefile | 5 +-
.../crypto/qat/qat_common/adf_common_drv.h | 22 +--
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 4 +-
.../{adf_pf2vf_msg.h => adf_pfvf_msg.h} | 8 +-
.../crypto/qat/qat_common/adf_pfvf_pf_msg.c | 21 +++
.../crypto/qat/qat_common/adf_pfvf_pf_msg.h | 10 ++
.../{adf_pf2vf_msg.c => adf_pfvf_pf_proto.c} | 137 +-----------------
.../crypto/qat/qat_common/adf_pfvf_pf_proto.h | 13 ++
.../crypto/qat/qat_common/adf_pfvf_vf_msg.c | 93 ++++++++++++
.../crypto/qat/qat_common/adf_pfvf_vf_msg.h | 21 +++
.../crypto/qat/qat_common/adf_pfvf_vf_proto.c | 133 +++++++++++++++++
.../crypto/qat/qat_common/adf_pfvf_vf_proto.h | 14 ++
drivers/crypto/qat/qat_common/adf_sriov.c | 4 +-
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 100 -------------
drivers/crypto/qat/qat_common/adf_vf_isr.c | 1 -
.../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 4 +-
.../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 5 +-
22 files changed, 341 insertions(+), 276 deletions(-)
rename drivers/crypto/qat/qat_common/{adf_pf2vf_msg.h => adf_pfvf_msg.h} (96%)
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.h
rename drivers/crypto/qat/qat_common/{adf_pf2vf_msg.c => adf_pfvf_pf_proto.c} (53%)
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.h
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.h
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c
create mode 100644 drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.h
delete mode 100644 drivers/crypto/qat/qat_common/adf_vf2pf_msg.cdrivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +2 -2
@@ -1,10 +1,10 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2020 Intel Corporation */ +/* Copyright(c) 2020 - 2021 Intel Corporation */ #include <linux/iopoll.h> #include <adf_accel_devices.h> #include <adf_common_drv.h> -#include <adf_pf2vf_msg.h> #include <adf_gen4_hw_data.h> +#include <adf_pfvf_msg.h> #include "adf_4xxx_hw_data.h" #include "icp_qat_hw.h"
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +2 -2
@@ -1,10 +1,10 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2014 - 2020 Intel Corporation */ +/* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> -#include <adf_pf2vf_msg.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> +#include <adf_pfvf_msg.h> #include "adf_c3xxx_hw_data.h" #include "icp_qat_hw.h"
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +3 -2
@@ -1,10 +1,11 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2015 - 2020 Intel Corporation */ +/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <adf_accel_devices.h> -#include <adf_pf2vf_msg.h> #include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> +#include <adf_pfvf_msg.h> +#include <adf_pfvf_vf_msg.h> #include "adf_c3xxxvf_hw_data.h" static struct adf_hw_device_class c3xxxiov_class = {
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +2 -2
@@ -1,10 +1,10 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2014 - 2020 Intel Corporation */ +/* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> -#include <adf_pf2vf_msg.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> +#include <adf_pfvf_msg.h> #include "adf_c62x_hw_data.h" #include "icp_qat_hw.h"
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +3 -2
@@ -1,10 +1,11 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2015 - 2020 Intel Corporation */ +/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <adf_accel_devices.h> -#include <adf_pf2vf_msg.h> #include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> +#include <adf_pfvf_msg.h> +#include <adf_pfvf_vf_msg.h> #include "adf_c62xvf_hw_data.h" static struct adf_hw_device_class c62xiov_class = {
drivers/crypto/qat/qat_common/Makefile +3 -2
@@ -19,6 +19,7 @@ intel_qat-objs := adf_cfg.o \ qat_hal.o intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o -intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o \ - adf_vf2pf_msg.o adf_vf_isr.o \ +intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_vf_isr.o \ + adf_pfvf_pf_msg.o adf_pfvf_pf_proto.o \ + adf_pfvf_vf_msg.o adf_pfvf_vf_proto.o \ adf_gen2_pfvf.o
drivers/crypto/qat/qat_common/adf_common_drv.h +1 -21
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ -/* Copyright(c) 2014 - 2020 Intel Corporation */ +/* Copyright(c) 2014 - 2021 Intel Corporation */ #ifndef ADF_DRV_H #define ADF_DRV_H
@@ -62,8 +62,6 @@ int adf_dev_start(struct adf_accel_dev *accel_dev);void adf_dev_stop (struct adf_accel_dev *accel_dev);void adf_dev_shutdown (struct adf_accel_dev *accel_dev); -void adf_pf2vf_notify_restarting (struct adf_accel_dev *accel_dev); -int adf_enable_vf2pf_comms (struct adf_accel_dev *accel_dev);void adf_devmgr_update_class_index (struct adf_hw_device_data *hw_data);void adf_clean_vf_map (bool );
@@ -198,13 +196,9 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,bool adf_recv_and_handle_pf2vf_msg (struct adf_accel_dev *accel_dev);bool adf_recv_and_handle_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 vf_nr);int adf_pf2vf_handle_pf_restarting (struct adf_accel_dev *accel_dev); -int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev);void adf_enable_pf2vf_interrupts (struct adf_accel_dev *accel_dev);void adf_disable_pf2vf_interrupts (struct adf_accel_dev *accel_dev);void adf_schedule_vf2pf_handler (struct adf_accel_vf_info *vf_info); -int adf_send_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 msg); -int adf_vf2pf_notify_init (struct adf_accel_dev *accel_dev); -void adf_vf2pf_notify_shutdown (struct adf_accel_dev *accel_dev);int adf_init_pf_wq (void );void adf_exit_pf_wq (void );int adf_init_vf_wq (void );
@@ -213,11 +207,6 @@ void adf_flush_vf_wq(struct adf_accel_dev *accel_dev);#else #define adf_sriov_configure NULL -static inline int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev) -{ -return 0 ; -} -static inline void adf_disable_sriov (struct adf_accel_dev *accel_dev) { }
@@ -230,15 +219,6 @@ static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) { } -static inline int adf_vf2pf_notify_init (struct adf_accel_dev *accel_dev) -{ -return 0 ; -} - -static inline void adf_vf2pf_notify_shutdown (struct adf_accel_dev *accel_dev) -{ -} -static inline int adf_init_pf_wq (void ) {return 0 ;
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +3 -1
@@ -6,7 +6,9 @@#include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_gen2_pfvf.h" -#include "adf_pf2vf_msg.h" +#include "adf_pfvf_msg.h" +#include "adf_pfvf_pf_proto.h" +#include "adf_pfvf_vf_proto.h" /* VF2PF interrupts */ #define ADF_GEN2_ERR_REG_VF2PF (vf_src) (((vf_src) & 0x01FFFE00) >> 9)
drivers/crypto/qat/qat_common/adf_pfvf_msg.h renamed from drivers/crypto/qat/qat_common/adf_pf2vf_msg.h +4 -4
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ -/* Copyright(c) 2015 - 2020 Intel Corporation */ -#ifndef ADF_PF2VF_MSG_H -#define ADF_PF2VF_MSG_H +/* Copyright(c) 2015 - 2021 Intel Corporation */ +#ifndef ADF_PFVF_MSG_H +#define ADF_PFVF_MSG_H /* * PF<->VF Messaging
@@ -91,4 +91,4 @@/* VF->PF Compatible Version Request */ #define ADF_VF2PF_COMPAT_VER_REQ_SHIFT 22 -#endif /* ADF_IOV_MSG_H */ +#endif /* ADF_PFVF_MSG_H */
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) +/* Copyright(c) 2015 - 2021 Intel Corporation */ +#include <linux/pci.h> +#include "adf_accel_devices.h" +#include "adf_pfvf_msg.h" +#include "adf_pfvf_pf_msg.h" +#include "adf_pfvf_pf_proto.h" + +void adf_pf2vf_notify_restarting (struct adf_accel_dev *accel_dev) +{ +struct adf_accel_vf_info *vf; +u32 msg = (ADF_PF2VF_MSGORIGIN_SYSTEM | + (ADF_PF2VF_MSGTYPE_RESTARTING <<ADF_PF2VF_MSGTYPE_SHIFT )); +int i, num_vfs =pci_num_vf (accel_to_pci_dev (accel_dev)); + +for (i =0 , vf = accel_dev->pf.vf_info; i < num_vfs; i++, vf++) { +if (vf->init &&adf_send_pf2vf_msg (accel_dev, i, msg)) +dev_err (&GET_DEV (accel_dev), +"Failed to send restarting msg to VF%d\n" , i); + } +}
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ +/* Copyright(c) 2021 Intel Corporation */ +#ifndef ADF_PFVF_PF_MSG_H +#define ADF_PFVF_PF_MSG_H + +#include "adf_accel_devices.h" + +void adf_pf2vf_notify_restarting (struct adf_accel_dev *accel_dev); + +#endif /* ADF_PFVF_PF_MSG_H */
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c renamed from drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +6 -131
165 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ +/* Copyright(c) 2021 Intel Corporation */ +#ifndef ADF_PFVF_PF_PROTO_H +#define ADF_PFVF_PF_PROTO_H + +#include <linux/types.h> +#include "adf_accel_devices.h" + +int adf_send_pf2vf_msg (struct adf_accel_dev *accel_dev,u8 vf_nr,u32 msg); + +int adf_enable_pf2vf_comms (struct adf_accel_dev *accel_dev); + +#endif /* ADF_PFVF_PF_PROTO_H */
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c new file +93 -0
93 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ +/* Copyright(c) 2021 Intel Corporation */ +#ifndef ADF_PFVF_VF_MSG_H +#define ADF_PFVF_VF_MSG_H + +#if defined(CONFIG_PCI_IOV ) +int adf_vf2pf_notify_init (struct adf_accel_dev *accel_dev); +void adf_vf2pf_notify_shutdown (struct adf_accel_dev *accel_dev); +int adf_vf2pf_request_version (struct adf_accel_dev *accel_dev); +#else +static inline int adf_vf2pf_notify_init (struct adf_accel_dev *accel_dev) +{ +return 0 ; +} + +static inline void adf_vf2pf_notify_shutdown (struct adf_accel_dev *accel_dev) +{ +} +#endif + +#endif /* ADF_PFVF_VF_MSG_H */
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c new file +133 -0
133 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ +/* Copyright(c) 2021 Intel Corporation */ +#ifndef ADF_PFVF_VF_PROTO_H +#define ADF_PFVF_VF_PROTO_H + +#include <linux/types.h> +#include "adf_accel_devices.h" + +int adf_send_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 msg); +int adf_send_vf2pf_req (struct adf_accel_dev *accel_dev,u32 msg); + +int adf_enable_vf2pf_comms (struct adf_accel_dev *accel_dev); + +#endif /* ADF_PFVF_VF_PROTO_H */
drivers/crypto/qat/qat_common/adf_sriov.c +2 -2
@@ -1,12 +1,12 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2015 - 2020 Intel Corporation */ +/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <linux/workqueue.h> #include <linux/pci.h> #include <linux/device.h> #include <linux/iommu.h> #include "adf_common_drv.h" #include "adf_cfg.h" -#include "adf_pf2vf_msg.h" +#include "adf_pfvf_pf_msg.h" static struct workqueue_struct *pf2vf_resp_wq;
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c deleted +0 -100
100 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_vf_isr.c +0 -1
@@ -15,7 +15,6 @@#include "adf_cfg_common.h" #include "adf_transport_access_macros.h" #include "adf_transport_internal.h" -#include "adf_pf2vf_msg.h" #define ADF_VINTSOU_OFFSET 0x204#define ADF_VINTMSK_OFFSET 0x208
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +2 -2
@@ -1,10 +1,10 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2014 - 2020 Intel Corporation */ +/* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> -#include <adf_pf2vf_msg.h> #include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> +#include <adf_pfvf_msg.h> #include "adf_dh895xcc_hw_data.h" #include "icp_qat_hw.h"
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +3 -2
@@ -1,10 +1,11 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) -/* Copyright(c) 2015 - 2020 Intel Corporation */ +/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <adf_accel_devices.h> -#include <adf_pf2vf_msg.h> #include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> +#include <adf_pfvf_msg.h> +#include <adf_pfvf_vf_msg.h> #include "adf_dh895xccvf_hw_data.h" static struct adf_hw_device_class dh895xcciov_class = {
Signature · 1 line
2.33.1
PATCH v2 18/24 crypto: qat - reorganize PFVF protocol definitions
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Organize PFVF protocol definitions by type rather than direction, by keeping related fields close.
Also, make sure the order is consistent for both PF and VF definitions.
--- drivers/crypto/qat/qat_common/adf_pfvf_msg.h | 36 +++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/crypto/qat/qat_common/adf_pfvf_msg.h +19 -17
@@ -53,34 +53,21 @@* adf_gen2_pfvf_send() in adf_pf2vf_msg.c). */ -#define ADF_PFVF_COMPAT_THIS_VERSION 0x1/* PF<->VF compat */ -/* PF->VF messages */ #define ADF_PF2VF_INT BIT(0)#define ADF_PF2VF_MSGORIGIN_SYSTEM BIT(1) +#define ADF_PF2VF_IN_USE_BY_PF 0x6AC20000 +#define ADF_PF2VF_IN_USE_BY_PF_MASK 0xFFFE0000#define ADF_PF2VF_MSGTYPE_MASK 0x0000003C#define ADF_PF2VF_MSGTYPE_SHIFT 2#define ADF_PF2VF_MSGTYPE_RESTARTING 0x01#define ADF_PF2VF_MSGTYPE_VERSION_RESP 0x02 -#define ADF_PF2VF_IN_USE_BY_PF 0x6AC20000 -#define ADF_PF2VF_IN_USE_BY_PF_MASK 0xFFFE0000 - -/* PF->VF Version Response */ -#define ADF_PF2VF_VERSION_RESP_VERS_MASK 0x00003FC0 -#define ADF_PF2VF_VERSION_RESP_VERS_SHIFT 6 -#define ADF_PF2VF_VERSION_RESP_RESULT_MASK 0x0000C000 -#define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT 14 -#define ADF_PF2VF_MINORVERSION_SHIFT 6 -#define ADF_PF2VF_MAJORVERSION_SHIFT 10 -#define ADF_PF2VF_VF_COMPATIBLE 1 -#define ADF_PF2VF_VF_INCOMPATIBLE 2 -#define ADF_PF2VF_VF_COMPAT_UNKNOWN 3/* VF->PF messages */ -#define ADF_VF2PF_IN_USE_BY_VF 0x00006AC2 -#define ADF_VF2PF_IN_USE_BY_VF_MASK 0x0000FFFE#define ADF_VF2PF_INT BIT(16)#define ADF_VF2PF_MSGORIGIN_SYSTEM BIT(17) +#define ADF_VF2PF_IN_USE_BY_VF 0x00006AC2 +#define ADF_VF2PF_IN_USE_BY_VF_MASK 0x0000FFFE#define ADF_VF2PF_MSGTYPE_MASK 0x003C0000#define ADF_VF2PF_MSGTYPE_SHIFT 18#define ADF_VF2PF_MSGTYPE_INIT 0x3
@@ -88,6 +75,21 @@#define ADF_VF2PF_MSGTYPE_VERSION_REQ 0x5#define ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ 0x6 +/* VF/PF compatibility version. */ +/* Reference to the current version */ +#define ADF_PFVF_COMPAT_THIS_VERSION 1/* PF<->VF compat */ + +/* PF->VF Version Response */ +#define ADF_PF2VF_MINORVERSION_SHIFT 6 +#define ADF_PF2VF_MAJORVERSION_SHIFT 10 +#define ADF_PF2VF_VERSION_RESP_VERS_MASK 0x00003FC0 +#define ADF_PF2VF_VERSION_RESP_VERS_SHIFT 6 +#define ADF_PF2VF_VERSION_RESP_RESULT_MASK 0x0000C000 +#define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT 14 +#define ADF_PF2VF_VF_COMPATIBLE 1 +#define ADF_PF2VF_VF_INCOMPATIBLE 2 +#define ADF_PF2VF_VF_COMPAT_UNKNOWN 3 +/* VF->PF Compatible Version Request */ #define ADF_VF2PF_COMPAT_VER_REQ_SHIFT 22
Signature · 1 line
2.33.1
PATCH v2 19/24 crypto: qat - use enums for PFVF protocol codes
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Replace PFVF constants with enumerations for valid protocol codes.
--- drivers/crypto/qat/qat_common/adf_pfvf_msg.h | 33 +++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/crypto/qat/qat_common/adf_pfvf_msg.h +22 -11
@@ -60,8 +60,11 @@#define ADF_PF2VF_IN_USE_BY_PF_MASK 0xFFFE0000#define ADF_PF2VF_MSGTYPE_MASK 0x0000003C#define ADF_PF2VF_MSGTYPE_SHIFT 2 -#define ADF_PF2VF_MSGTYPE_RESTARTING 0x01 -#define ADF_PF2VF_MSGTYPE_VERSION_RESP 0x02 + +enum pf2vf_msgtype { +ADF_PF2VF_MSGTYPE_RESTARTING =0x01 , +ADF_PF2VF_MSGTYPE_VERSION_RESP =0x02 , +};/* VF->PF messages */ #define ADF_VF2PF_INT BIT(16)
@@ -70,14 +73,19 @@#define ADF_VF2PF_IN_USE_BY_VF_MASK 0x0000FFFE#define ADF_VF2PF_MSGTYPE_MASK 0x003C0000#define ADF_VF2PF_MSGTYPE_SHIFT 18 -#define ADF_VF2PF_MSGTYPE_INIT 0x3 -#define ADF_VF2PF_MSGTYPE_SHUTDOWN 0x4 -#define ADF_VF2PF_MSGTYPE_VERSION_REQ 0x5 -#define ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ 0x6 + +enum vf2pf_msgtype { +ADF_VF2PF_MSGTYPE_INIT =0x03 , +ADF_VF2PF_MSGTYPE_SHUTDOWN =0x04 , +ADF_VF2PF_MSGTYPE_VERSION_REQ =0x05 , +ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ =0x06 , +};/* VF/PF compatibility version. */ -/* Reference to the current version */ -#define ADF_PFVF_COMPAT_THIS_VERSION 1/* PF<->VF compat */ +enum pfvf_compatibility_version { +/* Reference to the current version */ +ADF_PFVF_COMPAT_THIS_VERSION =0x01 , +};/* PF->VF Version Response */ #define ADF_PF2VF_MINORVERSION_SHIFT 6
@@ -86,9 +94,12 @@#define ADF_PF2VF_VERSION_RESP_VERS_SHIFT 6#define ADF_PF2VF_VERSION_RESP_RESULT_MASK 0x0000C000#define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT 14 -#define ADF_PF2VF_VF_COMPATIBLE 1 -#define ADF_PF2VF_VF_INCOMPATIBLE 2 -#define ADF_PF2VF_VF_COMPAT_UNKNOWN 3 + +enum pf2vf_compat_response { +ADF_PF2VF_VF_COMPATIBLE =0x01 , +ADF_PF2VF_VF_INCOMPATIBLE =0x02 , +ADF_PF2VF_VF_COMPAT_UNKNOWN =0x03 , +};/* VF->PF Compatible Version Request */ #define ADF_VF2PF_COMPAT_VER_REQ_SHIFT 22
Signature · 1 line
2.33.1
PATCH v2 20/24 crypto: qat - pass the PF2VF responses back to the callers
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Currently, any PF response to a VF request is fully parsed during the interrupt handling. This way the individual response values are stored into the accel_dev structure, preventing the caller to access and decode the full response message itself.
Change this behavior, by letting the API return back the entire message to the caller, in order to:
- keep correlated code together, that is, the (building of the)
request and the (decoding of the) response;
- avoid polluting the accel_dev data structure with unnecessary and at times temporary values; only the entire message is stored in a temporary buffer.
--- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 2 +- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 2 +- .../crypto/qat/qat_common/adf_accel_devices.h | 4 ++-- .../crypto/qat/qat_common/adf_pfvf_vf_msg.c | 23 +++++++++++------- .../crypto/qat/qat_common/adf_pfvf_vf_proto.c | 24 +++++++++---------- .../crypto/qat/qat_common/adf_pfvf_vf_proto.h | 2 +- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 2 +- 7 files changed, 33 insertions(+), 26 deletions(-)
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +1 -1
@@ -171,7 +171,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }pci_set_master (pdev);/* Completion for VF2PF request/response message exchange */ -init_completion (&accel_dev->vf.iov_msg_completion); +init_completion (&accel_dev->vf.msg_received); ret =qat_crypto_dev_config (accel_dev);if (ret)
drivers/crypto/qat/qat_c62xvf/adf_drv.c +1 -1
@@ -171,7 +171,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }pci_set_master (pdev);/* Completion for VF2PF request/response message exchange */ -init_completion (&accel_dev->vf.iov_msg_completion); +init_completion (&accel_dev->vf.msg_received); ret =qat_crypto_dev_config (accel_dev);if (ret)
drivers/crypto/qat/qat_common/adf_accel_devices.h +2 -2
@@ -271,8 +271,8 @@ struct adf_accel_dev {char irq_name[ADF_MAX_MSIX_VECTOR_NAME ];struct tasklet_struct pf2vf_bh_tasklet;struct mutex vf2pf_lock;/* protect CSR access */ -struct completion iov_msg_completion; -u8 compatible; +struct completion msg_received; +u32 response;/* temp field holding pf2vf response */ u8 pf_version; } vf; };
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c +15 -8
@@ -52,7 +52,10 @@ EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown);int adf_vf2pf_request_version (struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_data = accel_dev->hw_device; +u8 pf_version;u32 msg =0 ; +int compat; +u32 resp;int ret; msg =ADF_VF2PF_MSGORIGIN_SYSTEM ;
@@ -60,34 +63,38 @@ int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev) msg |=ADF_PFVF_COMPAT_THIS_VERSION <<ADF_VF2PF_COMPAT_VER_REQ_SHIFT ;BUILD_BUG_ON (ADF_PFVF_COMPAT_THIS_VERSION >255 ); - ret =adf_send_vf2pf_req (accel_dev, msg); + ret =adf_send_vf2pf_req (accel_dev, msg, &resp);if (ret) {dev_err (&GET_DEV (accel_dev),"Failed to send Compatibility Version Request.\n" );return ret; } + pf_version = (resp &ADF_PF2VF_VERSION_RESP_VERS_MASK ) + >>ADF_PF2VF_VERSION_RESP_VERS_SHIFT ; + compat = (resp &ADF_PF2VF_VERSION_RESP_RESULT_MASK ) + >>ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; +/* Response from PF received, check compatibility */ -switch (accel_dev->vf.compatible) { +switch (compat) {case ADF_PF2VF_VF_COMPATIBLE :break ;case ADF_PF2VF_VF_COMPAT_UNKNOWN :/* VF is newer than PF and decides whether it is compatible */ -if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver) { - accel_dev->vf.compatible =ADF_PF2VF_VF_COMPATIBLE ; +if (pf_version >= hw_data->min_iov_compat_ver)break ; - } fallthrough;case ADF_PF2VF_VF_INCOMPATIBLE :dev_err (&GET_DEV (accel_dev),"PF (vers %d) and VF (vers %d) are not compatible\n" , - accel_dev->vf.pf_version, -ADF_PFVF_COMPAT_THIS_VERSION ); + pf_version,ADF_PFVF_COMPAT_THIS_VERSION );return -EINVAL ;default :dev_err (&GET_DEV (accel_dev),"Invalid response from PF; assume not compatible\n" );return -EINVAL ; } -return ret; + + accel_dev->vf.pf_version = pf_version; +return 0 ; }
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c +12 -12
@@ -47,18 +47,19 @@ static u32 adf_recv_pf2vf_msg(struct adf_accel_dev *accel_dev)* adf_send_vf2pf_req() - send VF2PF request message * @accel_dev: Pointer to acceleration device. * @msg: Request message to send +* @resp: Returned PF response * * This function sends a message that requires a response from the VF to the PF * and waits for a reply. * * Return: 0 on success, error code otherwise. */ -int adf_send_vf2pf_req (struct adf_accel_dev *accel_dev,u32 msg) +int adf_send_vf2pf_req (struct adf_accel_dev *accel_dev,u32 msg,u32 *resp) {unsigned long timeout =msecs_to_jiffies (ADF_PFVF_MSG_RESP_TIMEOUT );int ret; -reinit_completion (&accel_dev->vf.iov_msg_completion); +reinit_completion (&accel_dev->vf.msg_received);/* Send request from VF to PF */ ret =adf_send_vf2pf_msg (accel_dev, msg);
@@ -69,13 +70,19 @@ int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg) }/* Wait for response */ -if (!wait_for_completion_timeout (&accel_dev->vf.iov_msg_completion, +if (!wait_for_completion_timeout (&accel_dev->vf.msg_received, timeout)) {dev_err (&GET_DEV (accel_dev),"PFVF request/response message timeout expired\n" );return -EIO ; } +if (likely (resp)) + *resp = accel_dev->vf.response; + +/* Once copied, set to an invalid value */ + accel_dev->vf.response =0 ; +return 0 ; }
@@ -89,15 +96,8 @@ static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg)adf_pf2vf_handle_pf_restarting (accel_dev);return false;case ADF_PF2VF_MSGTYPE_VERSION_RESP : -dev_dbg (&GET_DEV (accel_dev), -"Version resp received from PF 0x%x\n" , msg); - accel_dev->vf.pf_version = - (msg &ADF_PF2VF_VERSION_RESP_VERS_MASK ) >> -ADF_PF2VF_VERSION_RESP_VERS_SHIFT ; - accel_dev->vf.compatible = - (msg &ADF_PF2VF_VERSION_RESP_RESULT_MASK ) >> -ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; -complete (&accel_dev->vf.iov_msg_completion); + accel_dev->vf.response = msg; +complete (&accel_dev->vf.msg_received);return true;default : dev_err(&GET_DEV(accel_dev),
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.h +1 -1
@@ -7,7 +7,7 @@#include "adf_accel_devices.h" int adf_send_vf2pf_msg (struct adf_accel_dev *accel_dev,u32 msg); -int adf_send_vf2pf_req (struct adf_accel_dev *accel_dev,u32 msg); +int adf_send_vf2pf_req (struct adf_accel_dev *accel_dev,u32 msg,u32 *resp);int adf_enable_vf2pf_comms (struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +1 -1
@@ -171,7 +171,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }pci_set_master (pdev);/* Completion for VF2PF request/response message exchange */ -init_completion (&accel_dev->vf.iov_msg_completion); +init_completion (&accel_dev->vf.msg_received); ret =qat_crypto_dev_config (accel_dev);if (ret)
Signature · 1 line
2.33.1
PATCH v2 21/24 crypto: qat - refactor pfvf version request messages
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Refactor version handling logic for ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ and ADF_VF2PF_MSGTYPE_VERSION_REQ on the PF.
Response messages are now filled only after fully parsing the request, in a consisted way with the rest of the PFVF codebase.
This patch also fixes a harmless double setting for VERSION in the response for ADF_VF2PF_MSGTYPE_VERSION_REQ.
--- .../crypto/qat/qat_common/adf_pfvf_pf_proto.c | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-)
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c +20 -19
@@ -47,12 +47,7 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,case ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ : {u8 vf_compat_ver = msg >>ADF_VF2PF_COMPAT_VER_REQ_SHIFT ; - - resp = (ADF_PF2VF_MSGORIGIN_SYSTEM | - (ADF_PF2VF_MSGTYPE_VERSION_RESP << -ADF_PF2VF_MSGTYPE_SHIFT ) | - (ADF_PFVF_COMPAT_THIS_VERSION << -ADF_PF2VF_VERSION_RESP_VERS_SHIFT )); +u8 compat; dev_dbg(&GET_DEV(accel_dev), "Compatibility Version Request from VF%d vers=%u\n",
@@ -62,37 +57,43 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,dev_err (&GET_DEV (accel_dev),"VF (vers %d) incompatible with PF (vers %d)\n" , vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - resp |=ADF_PF2VF_VF_INCOMPATIBLE << -ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; + compat =ADF_PF2VF_VF_INCOMPATIBLE ; }else if (vf_compat_ver >ADF_PFVF_COMPAT_THIS_VERSION ) {dev_err (&GET_DEV (accel_dev),"VF (vers %d) compat with PF (vers %d) unkn.\n" , vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - resp |=ADF_PF2VF_VF_COMPAT_UNKNOWN << -ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; + compat =ADF_PF2VF_VF_COMPAT_UNKNOWN ; }else {dev_dbg (&GET_DEV (accel_dev),"VF (vers %d) compatible with PF (vers %d)\n" , vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - resp |=ADF_PF2VF_VF_COMPATIBLE << -ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; + compat =ADF_PF2VF_VF_COMPATIBLE ; } + + resp =ADF_PF2VF_MSGORIGIN_SYSTEM ; + resp |=ADF_PF2VF_MSGTYPE_VERSION_RESP <<ADF_PF2VF_MSGTYPE_SHIFT ; + resp |=ADF_PFVF_COMPAT_THIS_VERSION <<ADF_PF2VF_VERSION_RESP_VERS_SHIFT ; + resp |= compat <<ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; }break ;case ADF_VF2PF_MSGTYPE_VERSION_REQ : + { +u8 compat; +dev_dbg (&GET_DEV (accel_dev),"Legacy VersionRequest received from VF%d 0x%x\n" , vf_nr +1 , msg); - resp = (ADF_PF2VF_MSGORIGIN_SYSTEM | - (ADF_PF2VF_MSGTYPE_VERSION_RESP << -ADF_PF2VF_MSGTYPE_SHIFT ) | - (ADF_PFVF_COMPAT_THIS_VERSION << -ADF_PF2VF_VERSION_RESP_VERS_SHIFT )); - resp |=ADF_PF2VF_VF_COMPATIBLE << -ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; + +/* PF always newer than legacy VF */ + compat =ADF_PF2VF_VF_COMPATIBLE ; + + resp =ADF_PF2VF_MSGORIGIN_SYSTEM ; + resp |=ADF_PF2VF_MSGTYPE_VERSION_RESP <<ADF_PF2VF_MSGTYPE_SHIFT ;/* Set legacy major and minor version num */ resp |=1 <<ADF_PF2VF_MAJORVERSION_SHIFT |1 <<ADF_PF2VF_MINORVERSION_SHIFT ; + resp |= compat <<ADF_PF2VF_VERSION_RESP_RESULT_SHIFT ; + }break ;case ADF_VF2PF_MSGTYPE_INIT : {
Signature · 1 line
2.33.1
PATCH v2 22/24 crypto: qat - do not rely on min version
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Remove min_iov_compat_ver field as for now all versions are compatible.
Compatibility is determined by a series of rules and dynamic conditions such as specific configurations.
In any case the minimum version requirement for compatibility is an inadequate and obsolete approach which should be removed.
At this time compatibility can be assured across the currently available versions.
--- drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 2 -- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 2 -- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 2 -- drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c | 2 -- .../crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c | 2 -- .../crypto/qat/qat_common/adf_accel_devices.h | 1 - .../crypto/qat/qat_common/adf_pfvf_pf_proto.c | 18 ++++++------------ .../crypto/qat/qat_common/adf_pfvf_vf_msg.c | 7 ++----- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 2 -- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 2 -- 10 files changed, 8 insertions(+), 32 deletions(-)
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen4_hw_data.h> -#include <adf_pfvf_msg.h> #include "adf_4xxx_hw_data.h" #include "icp_qat_hw.h"
@@ -250,7 +249,6 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data) hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer; hw_data->pfvf_ops.enable_comms = adf_pfvf_comms_disabled; hw_data->disable_iov = adf_disable_sriov; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ;adf_gen4_init_hw_csr_ops (&hw_data->csr_ops); }
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> -#include <adf_pfvf_msg.h> #include "adf_c3xxx_hw_data.h" #include "icp_qat_hw.h"
@@ -137,7 +136,6 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; hw_data->disable_iov = adf_disable_sriov; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ;adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> -#include <adf_pfvf_msg.h> #include <adf_pfvf_vf_msg.h> #include "adf_c3xxxvf_hw_data.h"
@@ -85,7 +84,6 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) hw_data->get_misc_bar_id = get_misc_bar_id; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> -#include <adf_pfvf_msg.h> #include "adf_c62x_hw_data.h" #include "icp_qat_hw.h"
@@ -139,7 +138,6 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; hw_data->disable_iov = adf_disable_sriov; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ;adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> -#include <adf_pfvf_msg.h> #include <adf_pfvf_vf_msg.h> #include "adf_c62xvf_hw_data.h"
@@ -85,7 +84,6 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) hw_data->get_misc_bar_id = get_misc_bar_id; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);
drivers/crypto/qat/qat_common/adf_accel_devices.h +0 -1
@@ -209,7 +209,6 @@ struct adf_hw_device_data {u8 num_accel;u8 num_logical_accel;u8 num_engines; -u8 min_iov_compat_ver; };/* CSR write macro */
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c +6 -12
@@ -40,7 +40,6 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr, u32 msg, u32 *response) { struct adf_accel_vf_info *vf_info = &accel_dev->pf.vf_info[vf_nr]; -struct adf_hw_device_data *hw_data = accel_dev->hw_device;u32 resp =0 ;switch ((msg &ADF_VF2PF_MSGTYPE_MASK ) >>ADF_VF2PF_MSGTYPE_SHIFT ) {
@@ -53,21 +52,16 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,"Compatibility Version Request from VF%d vers=%u\n" , vf_nr + 1, vf_compat_ver); -if (vf_compat_ver < hw_data->min_iov_compat_ver) { -dev_err (&GET_DEV (accel_dev), -"VF (vers %d) incompatible with PF (vers %d)\n" , +if (vf_compat_ver <=ADF_PFVF_COMPAT_THIS_VERSION ) { + compat =ADF_PF2VF_VF_COMPATIBLE ; +dev_dbg (&GET_DEV (accel_dev), +"VF (vers %d) compatible with PF (vers %d)\n" , vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - compat =ADF_PF2VF_VF_INCOMPATIBLE ; - }else if (vf_compat_ver >ADF_PFVF_COMPAT_THIS_VERSION ) { + }else { + compat =ADF_PF2VF_VF_COMPAT_UNKNOWN ;dev_err (&GET_DEV (accel_dev),"VF (vers %d) compat with PF (vers %d) unkn.\n" , vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - compat =ADF_PF2VF_VF_COMPAT_UNKNOWN ; - }else { -dev_dbg (&GET_DEV (accel_dev), -"VF (vers %d) compatible with PF (vers %d)\n" , - vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - compat =ADF_PF2VF_VF_COMPATIBLE ; } resp =ADF_PF2VF_MSGORIGIN_SYSTEM ;
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c +2 -5
@@ -51,7 +51,6 @@ EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown);int adf_vf2pf_request_version (struct adf_accel_dev *accel_dev) { -struct adf_hw_device_data *hw_data = accel_dev->hw_device;u8 pf_version;u32 msg =0 ;int compat;
@@ -80,10 +79,8 @@ int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)case ADF_PF2VF_VF_COMPATIBLE :break ;case ADF_PF2VF_VF_COMPAT_UNKNOWN : -/* VF is newer than PF and decides whether it is compatible */ -if (pf_version >= hw_data->min_iov_compat_ver) -break ; - fallthrough; +/* VF is newer than PF - compatible for now */ +break ;case ADF_PF2VF_VF_INCOMPATIBLE : dev_err(&GET_DEV(accel_dev), "PF (vers %d) and VF (vers %d) are not compatible\n",
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> -#include <adf_pfvf_msg.h> #include "adf_dh895xcc_hw_data.h" #include "icp_qat_hw.h"
@@ -216,7 +215,6 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->enable_ints = adf_enable_ints; hw_data->reset_device = adf_reset_sbr; hw_data->disable_iov = adf_disable_sriov; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ;adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops); hw_data->pfvf_ops.get_vf2pf_sources = get_vf2pf_sources;
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +0 -2
@@ -4,7 +4,6 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> -#include <adf_pfvf_msg.h> #include <adf_pfvf_vf_msg.h> #include "adf_dh895xccvf_hw_data.h"
@@ -85,7 +84,6 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) hw_data->get_misc_bar_id = get_misc_bar_id; hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; - hw_data->min_iov_compat_ver =ADF_PFVF_COMPAT_THIS_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);
Signature · 1 line
2.33.1
PATCH v2 23/24 crypto: qat - fix VF IDs in PFVF log messages
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
PFVF debug messages use a mix of zero and one based VF IDs. Switch to zero based VF numbers in all log messages.
--- drivers/crypto/qat/qat_common/adf_isr.c | 2 +- drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/qat/qat_common/adf_isr.c +1 -1
@@ -123,7 +123,7 @@ static bool adf_handle_vf2pf_int(struct adf_accel_dev *accel_dev)if (!__ratelimit (&vf_info->vf2pf_ratelimit)) {dev_info (&GET_DEV (accel_dev),"Too many ints from VF%d\n" , - vf_info->vf_nr +1 ); + vf_info->vf_nr);continue ; }
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c +5 -5
@@ -50,7 +50,7 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,dev_dbg (&GET_DEV (accel_dev),"Compatibility Version Request from VF%d vers=%u\n" , - vf_nr +1 , vf_compat_ver); + vf_nr, vf_compat_ver);if (vf_compat_ver <=ADF_PFVF_COMPAT_THIS_VERSION ) { compat =ADF_PF2VF_VF_COMPATIBLE ;
@@ -76,7 +76,7 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,dev_dbg (&GET_DEV (accel_dev),"Legacy VersionRequest received from VF%d 0x%x\n" , - vf_nr +1 , msg); + vf_nr, msg);/* PF always newer than legacy VF */ compat =ADF_PF2VF_VF_COMPATIBLE ;
@@ -93,7 +93,7 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr, {dev_dbg (&GET_DEV (accel_dev),"Init message received from VF%d 0x%x\n" , - vf_nr +1 , msg); + vf_nr, msg); vf_info->init = true; }break ;
@@ -101,13 +101,13 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr, {dev_dbg (&GET_DEV (accel_dev),"Shutdown message received from VF%d 0x%x\n" , - vf_nr +1 , msg); + vf_nr, msg); vf_info->init = false; }break ;default :dev_dbg (&GET_DEV (accel_dev),"Unknown message from VF%d (0x%x)\n" , - vf_nr +1 , msg); + vf_nr, msg);return -ENOMSG ; }
Signature · 1 line
2.33.1
PATCH v2 24/24 crypto: qat - improve logging of PFVF messages
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Improve and simplify logging of PFVF messages.
--- drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 4 +-- .../crypto/qat/qat_common/adf_pfvf_pf_proto.c | 30 +++++++------------ .../crypto/qat/qat_common/adf_pfvf_vf_proto.c | 7 +++-- 3 files changed, 17 insertions(+), 24 deletions(-)
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +2 -2
@@ -180,14 +180,14 @@ static u32 adf_gen2_pfvf_recv(struct adf_accel_dev *accel_dev, u8 vf_nr) msg =ADF_CSR_RD (pmisc_addr, pfvf_offset);if (!(msg & int_bit)) {dev_info (&GET_DEV (accel_dev), -"Spurious PFVF interrupt, msg %X. Ignored\n" , msg); +"Spurious PFVF interrupt, msg 0x%.8x. Ignored\n" , msg);return 0 ; }/* Ignore legacy non-system (non-kernel) VF2PF messages */ if (!(msg & msg_origin)) {dev_dbg (&GET_DEV (accel_dev), -"Ignored non-system message (0x%x);\n" , msg); +"Ignored non-system message (0x%.8x);\n" , msg);return 0 ; }
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c +11 -19
@@ -49,20 +49,13 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,u8 compat;dev_dbg (&GET_DEV (accel_dev), -"Compatibility Version Request from VF%d vers=%u\n" , - vf_nr, vf_compat_ver); +"VersionRequest received from VF%d (vers %d) to PF (vers %d)\n" , + vf_nr, vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); -if (vf_compat_ver <=ADF_PFVF_COMPAT_THIS_VERSION ) { +if (vf_compat_ver <=ADF_PFVF_COMPAT_THIS_VERSION ) compat =ADF_PF2VF_VF_COMPATIBLE ; -dev_dbg (&GET_DEV (accel_dev), -"VF (vers %d) compatible with PF (vers %d)\n" , - vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - }else { +else compat =ADF_PF2VF_VF_COMPAT_UNKNOWN ; -dev_err (&GET_DEV (accel_dev), -"VF (vers %d) compat with PF (vers %d) unkn.\n" , - vf_compat_ver,ADF_PFVF_COMPAT_THIS_VERSION ); - } resp =ADF_PF2VF_MSGORIGIN_SYSTEM ; resp |=ADF_PF2VF_MSGTYPE_VERSION_RESP <<ADF_PF2VF_MSGTYPE_SHIFT ;
@@ -75,8 +68,8 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,u8 compat;dev_dbg (&GET_DEV (accel_dev), -"Legacy VersionRequest received from VF%d 0x%x\n" , - vf_nr, msg); +"Legacy VersionRequest received from VF%d to PF (vers 1.1)\n" , + vf_nr);/* PF always newer than legacy VF */ compat =ADF_PF2VF_VF_COMPATIBLE ;
@@ -92,21 +85,19 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,case ADF_VF2PF_MSGTYPE_INIT : {dev_dbg (&GET_DEV (accel_dev), -"Init message received from VF%d 0x%x\n" , - vf_nr, msg); +"Init message received from VF%d\n" , vf_nr); vf_info->init = true; }break ;case ADF_VF2PF_MSGTYPE_SHUTDOWN : {dev_dbg (&GET_DEV (accel_dev), -"Shutdown message received from VF%d 0x%x\n" , - vf_nr, msg); +"Shutdown message received from VF%d\n" , vf_nr); vf_info->init = false; }break ;default : -dev_dbg (&GET_DEV (accel_dev),"Unknown message from VF%d (0x%x)\n" , +dev_dbg (&GET_DEV (accel_dev),"Unknown message from VF%d (0x%.8x)\n" , vf_nr, msg);return -ENOMSG ; }
@@ -129,7 +120,8 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)return false;if (resp &&adf_send_pf2vf_msg (accel_dev, vf_nr, resp)) -dev_err (&GET_DEV (accel_dev),"Failed to send response to VF\n" ); +dev_err (&GET_DEV (accel_dev), +"Failed to send response to VF%d\n" , vf_nr);return true; }
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c +4 -3
@@ -90,18 +90,19 @@ static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg) {switch ((msg &ADF_PF2VF_MSGTYPE_MASK ) >>ADF_PF2VF_MSGTYPE_SHIFT ) {case ADF_PF2VF_MSGTYPE_RESTARTING : -dev_dbg (&GET_DEV (accel_dev), -"Restarting msg received from PF 0x%x\n" , msg); +dev_dbg (&GET_DEV (accel_dev),"Restarting message received from PF\n" );adf_pf2vf_handle_pf_restarting (accel_dev);return false;case ADF_PF2VF_MSGTYPE_VERSION_RESP : +dev_dbg (&GET_DEV (accel_dev), +"Response message received from PF (0x%.8x)\n" , msg); accel_dev->vf.response = msg;complete (&accel_dev->vf.msg_received);return true;default :dev_err (&GET_DEV (accel_dev), -"Unknown PF2VF message(0x%x)\n" , msg); +"Unknown PF2VF message (0x%.8x) from PF\n" , msg); }return false;
Signature · 1 line
2.33.1