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

crypto: qat - exchange ring-to-service mappings over PFVF

In addition to retrieving the device capabilities, a VF may also need to
retrieve the mapping of its ring pairs to crypto and or compression
services in order to work properly.

Make the VF receive the ring-to-service mappings from the PF by means of a
new REQ_RING_SVC_MAP Block Message and add the request and response
logic on VF and PF respectively. This change requires to bump the PFVF
protocol to version 4.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Fiona Trahe <fiona.trahe@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Marco Chiappero and committed by
Herbert Xu
e1b176af 73ef8f33

+63 -1
+14 -1
drivers/crypto/qat/qat_common/adf_pfvf_msg.h
··· 91 91 ADF_PFVF_COMPAT_CAPABILITIES = 0x02, 92 92 /* In-use pattern cleared by receiver */ 93 93 ADF_PFVF_COMPAT_FAST_ACK = 0x03, 94 + /* Ring to service mapping support for non-standard mappings */ 95 + ADF_PFVF_COMPAT_RING_TO_SVC_MAP = 0x04, 94 96 /* Reference to the latest version */ 95 - ADF_PFVF_COMPAT_THIS_VERSION = 0x03, 97 + ADF_PFVF_COMPAT_THIS_VERSION = 0x04, 96 98 }; 97 99 98 100 /* PF->VF Version Response */ ··· 141 139 */ 142 140 enum vf2pf_blkmsg_req_type { 143 141 ADF_VF2PF_BLKMSG_REQ_CAP_SUMMARY = 0x02, 142 + ADF_VF2PF_BLKMSG_REQ_RING_SVC_MAP = 0x03, 144 143 }; 145 144 146 145 #define ADF_VF2PF_SMALL_BLOCK_TYPE_MAX \ ··· 203 200 u32 ext_dc_caps; 204 201 u32 capabilities; 205 202 u32 frequency; 203 + } __packed; 204 + 205 + /* PF/VF Ring to service mapping values */ 206 + enum blkmsg_ring_to_svc_versions { 207 + ADF_PFVF_RING_TO_SVC_VERSION = 0x01, 208 + }; 209 + 210 + struct ring_to_svc_map_v1 { 211 + struct pfvf_blkmsg_header hdr; 212 + u16 map; 206 213 } __packed; 207 214 208 215 #endif /* ADF_PFVF_MSG_H */
+14
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.c
··· 36 36 37 37 return 0; 38 38 } 39 + 40 + int adf_pf_ring_to_svc_msg_provider(struct adf_accel_dev *accel_dev, 41 + u8 *buffer, u8 compat) 42 + { 43 + struct ring_to_svc_map_v1 rts_map_msg; 44 + 45 + rts_map_msg.map = accel_dev->hw_device->ring_to_svc_map; 46 + rts_map_msg.hdr.version = ADF_PFVF_RING_TO_SVC_VERSION; 47 + rts_map_msg.hdr.payload_size = ADF_PFVF_BLKMSG_PAYLOAD_SIZE(rts_map_msg); 48 + 49 + memcpy(buffer, &rts_map_msg, sizeof(rts_map_msg)); 50 + 51 + return 0; 52 + }
+2
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.h
··· 12 12 13 13 int adf_pf_capabilities_msg_provider(struct adf_accel_dev *accel_dev, 14 14 u8 *buffer, u8 comapt); 15 + int adf_pf_ring_to_svc_msg_provider(struct adf_accel_dev *accel_dev, 16 + u8 *buffer, u8 comapt); 15 17 16 18 #endif /* ADF_PFVF_PF_MSG_H */
+1
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
··· 16 16 NULL, /* no message type defined for value 0 */ 17 17 NULL, /* no message type defined for value 1 */ 18 18 adf_pf_capabilities_msg_provider, /* ADF_VF2PF_BLKMSG_REQ_CAP_SUMMARY */ 19 + adf_pf_ring_to_svc_msg_provider, /* ADF_VF2PF_BLKMSG_REQ_RING_SVC_MAP */ 19 20 }; 20 21 21 22 /**
+27
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
··· 138 138 139 139 return 0; 140 140 } 141 + 142 + int adf_vf2pf_get_ring_to_svc(struct adf_accel_dev *accel_dev) 143 + { 144 + struct ring_to_svc_map_v1 rts_map_msg = { { 0 }, }; 145 + unsigned int len = sizeof(rts_map_msg); 146 + 147 + if (accel_dev->vf.pf_compat_ver < ADF_PFVF_COMPAT_RING_TO_SVC_MAP) 148 + /* Use already set default mappings */ 149 + return 0; 150 + 151 + if (adf_send_vf2pf_blkmsg_req(accel_dev, ADF_VF2PF_BLKMSG_REQ_RING_SVC_MAP, 152 + (u8 *)&rts_map_msg, &len)) { 153 + dev_err(&GET_DEV(accel_dev), 154 + "QAT: Failed to get block message response\n"); 155 + return -EFAULT; 156 + } 157 + 158 + if (unlikely(len < sizeof(struct ring_to_svc_map_v1))) { 159 + dev_err(&GET_DEV(accel_dev), 160 + "RING_TO_SVC message truncated to %d bytes\n", len); 161 + return -EFAULT; 162 + } 163 + 164 + /* Only v1 at present */ 165 + accel_dev->hw_device->ring_to_svc_map = rts_map_msg.map; 166 + return 0; 167 + }
+1
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.h
··· 8 8 void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev); 9 9 int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev); 10 10 int adf_vf2pf_get_capabilities(struct adf_accel_dev *accel_dev); 11 + int adf_vf2pf_get_ring_to_svc(struct adf_accel_dev *accel_dev); 11 12 #else 12 13 static inline int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev) 13 14 {
+4
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c
··· 357 357 return ret; 358 358 359 359 ret = adf_vf2pf_get_capabilities(accel_dev); 360 + if (ret) 361 + return ret; 362 + 363 + ret = adf_vf2pf_get_ring_to_svc(accel_dev); 360 364 361 365 return ret; 362 366 }