linux/drivers/accel/qaic/qaic_control.c

// SPDX-License-Identifier: GPL-2.0-only

/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. */

#include <asm/byteorder.h>
#include <linux/completion.h>
#include <linux/crc32.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/mhi.h>
#include <linux/mm.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/overflow.h>
#include <linux/pci.h>
#include <linux/scatterlist.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/workqueue.h>
#include <linux/wait.h>
#include <drm/drm_device.h>
#include <drm/drm_file.h>
#include <uapi/drm/qaic_accel.h>

#include "qaic.h"

#define MANAGE_MAGIC_NUMBER
#define QAIC_DBC_Q_GAP
#define QAIC_DBC_Q_BUF_ALIGN
#define QAIC_MANAGE_EXT_MSG_LENGTH
#define QAIC_WRAPPER_MAX_SIZE
#define QAIC_MHI_RETRY_WAIT_MS
#define QAIC_MHI_RETRY_MAX

static unsigned int control_resp_timeout_s =; /* 60 sec default */
module_param(control_resp_timeout_s, uint, 0600);
MODULE_PARM_DESC();

struct manage_msg {};

/*
 * wire encoding structures for the manage protocol.
 * All fields are little endian on the wire
 */
struct wire_msg_hdr {} __packed;

struct wire_msg {} __packed;

struct wire_trans_hdr {} __packed;

/* Each message sent from driver to device are organized in a list of wrapper_msg */
struct wrapper_msg {};

struct wrapper_list {};

struct wire_trans_passthrough {} __packed;

struct wire_addr_size_pair {} __packed;

struct wire_trans_dma_xfer {} __packed;

/* Initiated by device to continue the DMA xfer of a large piece of data */
struct wire_trans_dma_xfer_cont {} __packed;

struct wire_trans_activate_to_dev {} __packed;

struct wire_trans_activate_from_dev {} __packed;

struct wire_trans_deactivate_from_dev {} __packed;

struct wire_trans_terminate_to_dev {} __packed;

struct wire_trans_terminate_from_dev {} __packed;

struct wire_trans_status_to_dev {} __packed;

struct wire_trans_status_from_dev {} __packed;

struct wire_trans_validate_part_to_dev {} __packed;

struct wire_trans_validate_part_from_dev {} __packed;

struct xfer_queue_elem {};

struct dma_xfer {};

struct ioctl_resources {};

struct resp_work {};

/*
 * Since we're working with little endian messages, its useful to be able to
 * increment without filling a whole line with conversions back and forth just
 * to add one(1) to a message count.
 */
static __le32 incr_le32(__le32 val)
{}

static u32 gen_crc(void *msg)
{}

static u32 gen_crc_stub(void *msg)
{}

static bool valid_crc(void *msg)
{}

static bool valid_crc_stub(void *msg)
{}

static void free_wrapper(struct kref *ref)
{}

static void save_dbc_buf(struct qaic_device *qdev, struct ioctl_resources *resources,
			 struct qaic_user *usr)
{}

static void free_dbc_buf(struct qaic_device *qdev, struct ioctl_resources *resources)
{}

static void free_dma_xfers(struct qaic_device *qdev, struct ioctl_resources *resources)
{}

static struct wrapper_msg *add_wrapper(struct wrapper_list *wrappers, u32 size)
{}

static int encode_passthrough(struct qaic_device *qdev, void *trans, struct wrapper_list *wrappers,
			      u32 *user_len)
{}

/* returns error code for failure, 0 if enough pages alloc'd, 1 if dma_cont is needed */
static int find_and_map_user_pages(struct qaic_device *qdev,
				   struct qaic_manage_trans_dma_xfer *in_trans,
				   struct ioctl_resources *resources, struct dma_xfer *xfer)
{}

/* returns error code for failure, 0 if everything was encoded, 1 if dma_cont is needed */
static int encode_addr_size_pairs(struct dma_xfer *xfer, struct wrapper_list *wrappers,
				  struct ioctl_resources *resources, u32 msg_hdr_len, u32 *size,
				  struct wire_trans_dma_xfer **out_trans)
{}

static void cleanup_xfer(struct qaic_device *qdev, struct dma_xfer *xfer)
{}

static int encode_dma(struct qaic_device *qdev, void *trans, struct wrapper_list *wrappers,
		      u32 *user_len, struct ioctl_resources *resources, struct qaic_user *usr)
{}

static int encode_activate(struct qaic_device *qdev, void *trans, struct wrapper_list *wrappers,
			   u32 *user_len, struct ioctl_resources *resources)
{}

static int encode_deactivate(struct qaic_device *qdev, void *trans,
			     u32 *user_len, struct qaic_user *usr)
{}

static int encode_status(struct qaic_device *qdev, void *trans, struct wrapper_list *wrappers,
			 u32 *user_len)
{}

static int encode_message(struct qaic_device *qdev, struct manage_msg *user_msg,
			  struct wrapper_list *wrappers, struct ioctl_resources *resources,
			  struct qaic_user *usr)
{}

static int decode_passthrough(struct qaic_device *qdev, void *trans, struct manage_msg *user_msg,
			      u32 *msg_len)
{}

static int decode_activate(struct qaic_device *qdev, void *trans, struct manage_msg *user_msg,
			   u32 *msg_len, struct ioctl_resources *resources, struct qaic_user *usr)
{}

static int decode_deactivate(struct qaic_device *qdev, void *trans, u32 *msg_len,
			     struct qaic_user *usr)
{}

static int decode_status(struct qaic_device *qdev, void *trans, struct manage_msg *user_msg,
			 u32 *user_len, struct wire_msg *msg)
{}

static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg,
			  struct wire_msg *msg, struct ioctl_resources *resources,
			  struct qaic_user *usr)
{}

static void *msg_xfer(struct qaic_device *qdev, struct wrapper_list *wrappers, u32 seq_num,
		      bool ignore_signal)
{}

/* Add a transaction to abort the outstanding DMA continuation */
static int abort_dma_cont(struct qaic_device *qdev, struct wrapper_list *wrappers, u32 dma_chunk_id)
{}

static struct wrapper_list *alloc_wrapper_list(void)
{}

static int qaic_manage_msg_xfer(struct qaic_device *qdev, struct qaic_user *usr,
				struct manage_msg *user_msg, struct ioctl_resources *resources,
				struct wire_msg **rsp)
{}

static int qaic_manage(struct qaic_device *qdev, struct qaic_user *usr, struct manage_msg *user_msg)
{}

int qaic_manage_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
{}

int get_cntl_version(struct qaic_device *qdev, struct qaic_user *usr, u16 *major, u16 *minor)
{}

static void resp_worker(struct work_struct *work)
{}

static void free_wrapper_from_list(struct wrapper_list *wrappers, struct wrapper_msg *wrapper)
{}

void qaic_mhi_ul_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
{}

void qaic_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
{}

int qaic_control_open(struct qaic_device *qdev)
{}

void qaic_control_close(struct qaic_device *qdev)
{}

void qaic_release_usr(struct qaic_device *qdev, struct qaic_user *usr)
{}

void wake_all_cntl(struct qaic_device *qdev)
{}