Skip to content

Commit f0bbfc3

Browse files
XinIZengherbertx
authored andcommitted
crypto: qat - implement interface for live migration
Add logic to implement the interface for live migration defined in qat/qat_mig_dev.h. This is specific for QAT GEN4 Virtual Functions (VFs). This introduces a migration data manager which is used to handle the device state during migration. The manager ensures that the device state is stored in a format that can be restored in the destination node. The VF state is organized into a hierarchical structure that includes a preamble, a general state section, a MISC bar section and an ETR bar section. The latter contains the state of the 4 ring pairs contained on a VF. Here is a graphical representation of the state: preamble | general state section | leaf state | MISC bar state section| leaf state | ETR bar state section | bank0 state section | leaf state | bank1 state section | leaf state | bank2 state section | leaf state | bank3 state section | leaf state In addition to the implementation of the qat_migdev_ops interface and the state manager framework, add a mutex in pfvf to avoid pf2vf messages during migration. Signed-off-by: Xin Zeng <[email protected]> Reviewed-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 0fce55e commit f0bbfc3

File tree

9 files changed

+1445
-1
lines changed

9 files changed

+1445
-1
lines changed

drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <adf_gen4_ras.h>
1818
#include <adf_gen4_timer.h>
1919
#include <adf_gen4_tl.h>
20+
#include <adf_gen4_vf_mig.h>
2021
#include "adf_420xx_hw_data.h"
2122
#include "icp_qat_hw.h"
2223

@@ -488,6 +489,7 @@ void adf_init_hw_data_420xx(struct adf_hw_device_data *hw_data, u32 dev_id)
488489
adf_gen4_init_dc_ops(&hw_data->dc_ops);
489490
adf_gen4_init_ras_ops(&hw_data->ras_ops);
490491
adf_gen4_init_tl_data(&hw_data->tl_data);
492+
adf_gen4_init_vf_mig_ops(&hw_data->vfmig_ops);
491493
adf_init_rl_data(&hw_data->rl_data);
492494
}
493495

drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "adf_gen4_ras.h"
1818
#include <adf_gen4_timer.h>
1919
#include <adf_gen4_tl.h>
20+
#include <adf_gen4_vf_mig.h>
2021
#include "adf_4xxx_hw_data.h"
2122
#include "icp_qat_hw.h"
2223

@@ -472,6 +473,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id)
472473
adf_gen4_init_dc_ops(&hw_data->dc_ops);
473474
adf_gen4_init_ras_ops(&hw_data->ras_ops);
474475
adf_gen4_init_tl_data(&hw_data->tl_data);
476+
adf_gen4_init_vf_mig_ops(&hw_data->vfmig_ops);
475477
adf_init_rl_data(&hw_data->rl_data);
476478
}
477479

drivers/crypto/intel/qat/qat_common/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ intel_qat-objs := adf_cfg.o \
2020
adf_gen4_config.o \
2121
adf_gen4_hw_csr_data.o \
2222
adf_gen4_hw_data.o \
23+
adf_gen4_vf_mig.o \
2324
adf_gen4_pm.o \
2425
adf_gen2_dc.o \
2526
adf_gen4_dc.o \
2627
adf_gen4_ras.o \
2728
adf_gen4_timer.o \
2829
adf_clock.o \
30+
adf_mstate_mgr.o \
2931
qat_crypto.o \
3032
qat_compression.o \
3133
qat_comp_algs.o \

drivers/crypto/intel/qat/qat_common/adf_accel_devices.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,17 @@ struct adf_fw_loader_data {
412412
struct adf_accel_vf_info {
413413
struct adf_accel_dev *accel_dev;
414414
struct mutex pf2vf_lock; /* protect CSR access for PF2VF messages */
415+
struct mutex pfvf_mig_lock; /* protects PFVF state for migration */
415416
struct ratelimit_state vf2pf_ratelimit;
416417
u32 vf_nr;
417418
bool init;
418419
bool restarting;
419420
u8 vf_compat_ver;
421+
/*
422+
* Private area used for device migration.
423+
* Memory allocation and free is managed by migration driver.
424+
*/
425+
void *mig_priv;
420426
};
421427

422428
struct adf_dc_data {

drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#define ADF_RP_INT_SRC_SEL_F_RISE_MASK BIT(2)
8787
#define ADF_RP_INT_SRC_SEL_F_FALL_MASK GENMASK(2, 0)
8888
#define ADF_RP_INT_SRC_SEL_RANGE_WIDTH 4
89+
#define ADF_COALESCED_POLL_TIMEOUT_US (1 * USEC_PER_SEC)
8990
#define ADF_COALESCED_POLL_DELAY_US 1000
9091
#define ADF_WQM_CSR_RPINTSOU(bank) (0x200000 + ((bank) << 12))
9192
#define ADF_WQM_CSR_RP_IDX_RX 1
@@ -120,6 +121,15 @@
120121
/* PF2VM communication channel */
121122
#define ADF_GEN4_PF2VM_OFFSET(i) (0x40B010 + (i) * 0x20)
122123
#define ADF_GEN4_VM2PF_OFFSET(i) (0x40B014 + (i) * 0x20)
124+
#define ADF_GEN4_VINTMSKPF2VM_OFFSET(i) (0x40B00C + (i) * 0x20)
125+
#define ADF_GEN4_VINTSOUPF2VM_OFFSET(i) (0x40B008 + (i) * 0x20)
126+
#define ADF_GEN4_VINTMSK_OFFSET(i) (0x40B004 + (i) * 0x20)
127+
#define ADF_GEN4_VINTSOU_OFFSET(i) (0x40B000 + (i) * 0x20)
128+
129+
struct adf_gen4_vfmig {
130+
struct adf_mstate_mgr *mstate_mgr;
131+
bool bank_stopped[ADF_GEN4_NUM_BANKS_PER_VF];
132+
};
123133

124134
void adf_gen4_set_ssm_wdtimer(struct adf_accel_dev *accel_dev);
125135

0 commit comments

Comments
 (0)