Skip to content

Commit 7a73c46

Browse files
intmcherbertx
authored andcommitted
crypto: qat - add VF and PF wrappers to common send function
The send function, adf_iov_putmsg(), is shared by both PF and VF. This commit provides two direction specific APIs, adf_send_pf2vf_msg() and adf_send_vf2pf_msg() which decouple the implementation, which can change and evolve over time, from the user. With this change, the adf_iov_putmsg() is now isolated inside the file adf_pf2vf_msg.c and has been marked as static. Signed-off-by: Marco Chiappero <[email protected]> Co-developed-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 71b5f2a commit 7a73c46

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

drivers/crypto/qat/qat_common/adf_common_drv.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ int adf_dev_start(struct adf_accel_dev *accel_dev);
6262
void adf_dev_stop(struct adf_accel_dev *accel_dev);
6363
void adf_dev_shutdown(struct adf_accel_dev *accel_dev);
6464

65-
int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr);
6665
void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev);
6766
int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev);
6867
void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info);
@@ -200,7 +199,7 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
200199
void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
201200
void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
202201
void adf_schedule_vf2pf_handler(struct adf_accel_vf_info *vf_info);
203-
202+
int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg);
204203
int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev);
205204
void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev);
206205
int adf_init_pf_wq(void);

drivers/crypto/qat/qat_common/adf_pf2vf_msg.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
138138
*
139139
* Return: 0 on success, error code otherwise.
140140
*/
141-
int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
141+
static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
142142
{
143143
u32 count = 0;
144144
int ret;
@@ -152,6 +152,35 @@ int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
152152
return ret;
153153
}
154154

155+
/**
156+
* adf_send_pf2vf_msg() - send PF to VF message
157+
* @accel_dev: Pointer to acceleration device
158+
* @vf_nr: VF number to which the message will be sent
159+
* @msg: Message to send
160+
*
161+
* This function allows the PF to send a message to a specific VF.
162+
*
163+
* Return: 0 on success, error code otherwise.
164+
*/
165+
static int adf_send_pf2vf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr, u32 msg)
166+
{
167+
return adf_iov_putmsg(accel_dev, msg, vf_nr);
168+
}
169+
170+
/**
171+
* adf_send_vf2pf_msg() - send VF to PF message
172+
* @accel_dev: Pointer to acceleration device
173+
* @msg: Message to send
174+
*
175+
* This function allows the VF to send a message to the PF.
176+
*
177+
* Return: 0 on success, error code otherwise.
178+
*/
179+
int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg)
180+
{
181+
return adf_iov_putmsg(accel_dev, msg, 0);
182+
}
183+
155184
void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
156185
{
157186
struct adf_accel_dev *accel_dev = vf_info->accel_dev;
@@ -248,7 +277,7 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
248277
goto err;
249278
}
250279

251-
if (resp && adf_iov_putmsg(accel_dev, resp, vf_nr))
280+
if (resp && adf_send_pf2vf_msg(accel_dev, vf_nr, resp))
252281
dev_err(&GET_DEV(accel_dev), "Failed to send response to VF\n");
253282

254283
out:
@@ -269,7 +298,7 @@ void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev)
269298
int i, num_vfs = pci_num_vf(accel_to_pci_dev(accel_dev));
270299

271300
for (i = 0, vf = accel_dev->pf.vf_info; i < num_vfs; i++, vf++) {
272-
if (vf->init && adf_iov_putmsg(accel_dev, msg, i))
301+
if (vf->init && adf_send_pf2vf_msg(accel_dev, i, msg))
273302
dev_err(&GET_DEV(accel_dev),
274303
"Failed to send restarting msg to VF%d\n", i);
275304
}
@@ -290,7 +319,7 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
290319
reinit_completion(&accel_dev->vf.iov_msg_completion);
291320

292321
/* Send request from VF to PF */
293-
ret = adf_iov_putmsg(accel_dev, msg, 0);
322+
ret = adf_send_vf2pf_msg(accel_dev, msg);
294323
if (ret) {
295324
dev_err(&GET_DEV(accel_dev),
296325
"Failed to send Compatibility Version Request.\n");

drivers/crypto/qat/qat_common/adf_vf2pf_msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
1717
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
1818
(ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
1919

20-
if (adf_iov_putmsg(accel_dev, msg, 0)) {
20+
if (adf_send_vf2pf_msg(accel_dev, msg)) {
2121
dev_err(&GET_DEV(accel_dev),
2222
"Failed to send Init event to PF\n");
2323
return -EFAULT;
@@ -41,7 +41,7 @@ void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
4141
(ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
4242

4343
if (test_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status))
44-
if (adf_iov_putmsg(accel_dev, msg, 0))
44+
if (adf_send_vf2pf_msg(accel_dev, msg))
4545
dev_err(&GET_DEV(accel_dev),
4646
"Failed to send Shutdown event to PF\n");
4747
}

0 commit comments

Comments
 (0)