// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2015 - 2021 Intel Corporation */ #include <linux/bitfield.h> #include <linux/completion.h> #include <linux/minmax.h> #include <linux/types.h> #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_pfvf_msg.h" #include "adf_pfvf_utils.h" #include "adf_pfvf_vf_msg.h" #include "adf_pfvf_vf_proto.h" #define ADF_PFVF_MSG_COLLISION_DETECT_DELAY … #define ADF_PFVF_MSG_ACK_DELAY … #define ADF_PFVF_MSG_ACK_MAX_RETRY … /* How often to retry if there is no response */ #define ADF_PFVF_MSG_RESP_RETRIES … #define ADF_PFVF_MSG_RESP_TIMEOUT … /** * adf_send_vf2pf_msg() - send VF to PF message * @accel_dev: Pointer to acceleration device * @msg: Message to send * * This function allows the VF to send a message to the PF. * * Return: 0 on success, error code otherwise. */ int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, struct pfvf_message msg) { … } /** * 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 struct pfvf_message 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, struct pfvf_message msg, struct pfvf_message *resp) { … } static int adf_vf2pf_blkmsg_data_req(struct adf_accel_dev *accel_dev, bool crc, u8 *type, u8 *data) { … } static int adf_vf2pf_blkmsg_get_byte(struct adf_accel_dev *accel_dev, u8 type, u8 index, u8 *data) { … } static int adf_vf2pf_blkmsg_get_crc(struct adf_accel_dev *accel_dev, u8 type, u8 bytes, u8 *crc) { … } /** * adf_send_vf2pf_blkmsg_req() - retrieve block message * @accel_dev: Pointer to acceleration VF device. * @type: The block message type, see adf_pfvf_msg.h for allowed values * @buffer: input buffer where to place the received data * @buffer_len: buffer length as input, the amount of written bytes on output * * Request a message of type 'type' over the block message transport. * This function will send the required amount block message requests and * return the overall content back to the caller through the provided buffer. * The buffer should be large enough to contain the requested message type, * otherwise the response will be truncated. * * Return: 0 on success, error code otherwise. */ int adf_send_vf2pf_blkmsg_req(struct adf_accel_dev *accel_dev, u8 type, u8 *buffer, unsigned int *buffer_len) { … } static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, struct pfvf_message msg) { … } bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev) { … } /** * adf_enable_vf2pf_comms() - Function enables communication from vf to pf * * @accel_dev: Pointer to acceleration device virtual function. * * Return: 0 on success, error code otherwise. */ int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev) { … } EXPORT_SYMBOL_GPL(…);