Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - split PFVF message decoding from handling

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.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Marco Chiappero and committed by
Herbert Xu
bd59b769 04cf4787

+71 -59
+42 -26
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
··· 178 178 return 0; 179 179 } 180 180 181 - bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr) 181 + static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr, 182 + u32 msg, u32 *response) 182 183 { 183 184 struct adf_accel_vf_info *vf_info = &accel_dev->pf.vf_info[vf_nr]; 184 185 struct adf_hw_device_data *hw_data = accel_dev->hw_device; 185 - int bar_id = hw_data->get_misc_bar_id(hw_data); 186 - struct adf_bar *pmisc = &GET_BARS(accel_dev)[bar_id]; 187 - void __iomem *pmisc_addr = pmisc->virt_addr; 188 - u32 msg, resp = 0; 189 - 190 - /* Read message from the VF */ 191 - msg = ADF_CSR_RD(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr)); 192 - if (!(msg & ADF_VF2PF_INT)) { 193 - dev_info(&GET_DEV(accel_dev), 194 - "Spurious VF2PF interrupt, msg %X. Ignored\n", msg); 195 - return true; 196 - } 197 - 198 - if (!(msg & ADF_VF2PF_MSGORIGIN_SYSTEM)) 199 - /* Ignore legacy non-system (non-kernel) VF2PF messages */ 200 - return true; 201 - 202 - /* To ACK, clear the VF2PFINT bit */ 203 - msg &= ~ADF_VF2PF_INT; 204 - ADF_CSR_WR(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr), msg); 186 + u32 resp = 0; 205 187 206 188 switch ((msg & ADF_VF2PF_MSGTYPE_MASK) >> ADF_VF2PF_MSGTYPE_SHIFT) { 207 189 case ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ: ··· 253 271 } 254 272 break; 255 273 default: 256 - goto err; 274 + dev_dbg(&GET_DEV(accel_dev), "Unknown message from VF%d (0x%x)\n", 275 + vf_nr + 1, msg); 276 + return -ENOMSG; 257 277 } 278 + 279 + *response = resp; 280 + 281 + return 0; 282 + } 283 + 284 + bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr) 285 + { 286 + struct adf_hw_device_data *hw_data = accel_dev->hw_device; 287 + int bar_id = hw_data->get_misc_bar_id(hw_data); 288 + struct adf_bar *pmisc = &GET_BARS(accel_dev)[bar_id]; 289 + void __iomem *pmisc_addr = pmisc->virt_addr; 290 + u32 msg, resp = 0; 291 + 292 + /* Read message from the VF */ 293 + msg = ADF_CSR_RD(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr)); 294 + if (!(msg & ADF_VF2PF_INT)) { 295 + dev_info(&GET_DEV(accel_dev), 296 + "Spurious VF2PF interrupt, msg %X. Ignored\n", msg); 297 + return true; 298 + } 299 + 300 + /* Ignore legacy non-system (non-kernel) VF2PF messages */ 301 + if (!(msg & ADF_VF2PF_MSGORIGIN_SYSTEM)) { 302 + dev_dbg(&GET_DEV(accel_dev), 303 + "Ignored non-system message from VF%d (0x%x);\n", 304 + vf_nr + 1, msg); 305 + return true; 306 + } 307 + 308 + /* To ACK, clear the VF2PFINT bit */ 309 + msg &= ~ADF_VF2PF_INT; 310 + ADF_CSR_WR(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr), msg); 311 + 312 + if (adf_handle_vf2pf_msg(accel_dev, vf_nr, msg, &resp)) 313 + return false; 258 314 259 315 if (resp && adf_send_pf2vf_msg(accel_dev, vf_nr, resp)) 260 316 dev_err(&GET_DEV(accel_dev), "Failed to send response to VF\n"); 261 317 262 318 return true; 263 - err: 264 - dev_dbg(&GET_DEV(accel_dev), "Unknown message from VF%d (0x%x);\n", 265 - vf_nr + 1, msg); 266 - return false; 267 319 } 268 320 269 321 void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev)
+29 -33
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
··· 47 47 } 48 48 EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown); 49 49 50 + static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg) 51 + { 52 + switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) { 53 + case ADF_PF2VF_MSGTYPE_RESTARTING: 54 + dev_dbg(&GET_DEV(accel_dev), 55 + "Restarting msg received from PF 0x%x\n", msg); 56 + 57 + adf_pf2vf_handle_pf_restarting(accel_dev); 58 + return false; 59 + case ADF_PF2VF_MSGTYPE_VERSION_RESP: 60 + dev_dbg(&GET_DEV(accel_dev), 61 + "Version resp received from PF 0x%x\n", msg); 62 + accel_dev->vf.pf_version = 63 + (msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >> 64 + ADF_PF2VF_VERSION_RESP_VERS_SHIFT; 65 + accel_dev->vf.compatible = 66 + (msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >> 67 + ADF_PF2VF_VERSION_RESP_RESULT_SHIFT; 68 + complete(&accel_dev->vf.iov_msg_completion); 69 + return true; 70 + default: 71 + dev_err(&GET_DEV(accel_dev), 72 + "Unknown PF2VF message(0x%x)\n", msg); 73 + } 74 + 75 + return false; 76 + } 77 + 50 78 bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev) 51 79 { 52 80 struct adf_hw_device_data *hw_data = accel_dev->hw_device; ··· 82 54 &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)]; 83 55 void __iomem *pmisc_bar_addr = pmisc->virt_addr; 84 56 u32 offset = hw_data->get_pf2vf_offset(0); 85 - bool ret; 86 57 u32 msg; 87 58 88 59 /* Read the message from PF */ ··· 100 73 msg &= ~ADF_PF2VF_INT; 101 74 ADF_CSR_WR(pmisc_bar_addr, offset, msg); 102 75 103 - switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) { 104 - case ADF_PF2VF_MSGTYPE_RESTARTING: 105 - dev_dbg(&GET_DEV(accel_dev), 106 - "Restarting msg received from PF 0x%x\n", msg); 107 - 108 - adf_pf2vf_handle_pf_restarting(accel_dev); 109 - ret = false; 110 - break; 111 - case ADF_PF2VF_MSGTYPE_VERSION_RESP: 112 - dev_dbg(&GET_DEV(accel_dev), 113 - "Version resp received from PF 0x%x\n", msg); 114 - accel_dev->vf.pf_version = 115 - (msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >> 116 - ADF_PF2VF_VERSION_RESP_VERS_SHIFT; 117 - accel_dev->vf.compatible = 118 - (msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >> 119 - ADF_PF2VF_VERSION_RESP_RESULT_SHIFT; 120 - complete(&accel_dev->vf.iov_msg_completion); 121 - ret = true; 122 - break; 123 - default: 124 - goto err; 125 - } 126 - 127 - return ret; 128 - 129 - err: 130 - dev_err(&GET_DEV(accel_dev), 131 - "Unknown message from PF (0x%x); leaving PF2VF ints disabled\n", 132 - msg); 133 - 134 - return false; 76 + return adf_handle_pf2vf_msg(accel_dev, msg); 135 77 }