linux/drivers/misc/bcm-vk/bcm_vk_msg.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright 2018-2020 Broadcom.
 */

#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/hash.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/sizes.h>
#include <linux/spinlock.h>
#include <linux/timer.h>

#include "bcm_vk.h"
#include "bcm_vk_msg.h"
#include "bcm_vk_sg.h"

/* functions to manipulate the transport id in msg block */
#define BCM_VK_MSG_Q_SHIFT
#define BCM_VK_MSG_Q_MASK
#define BCM_VK_MSG_ID_MASK

#define BCM_VK_DMA_DRAIN_MAX_MS

/* number x q_size will be the max number of msg processed per loop */
#define BCM_VK_MSG_PROC_MAX_LOOP

/* module parameter */
static bool hb_mon =;
module_param(hb_mon, bool, 0444);
MODULE_PARM_DESC();
static int batch_log =;
module_param(batch_log, int, 0444);
MODULE_PARM_DESC();

static bool hb_mon_is_on(void)
{}

static u32 get_q_num(const struct vk_msg_blk *msg)
{}

static void set_q_num(struct vk_msg_blk *msg, u32 q_num)
{}

static u32 get_msg_id(const struct vk_msg_blk *msg)
{}

static void set_msg_id(struct vk_msg_blk *msg, u32 val)
{}

static u32 msgq_inc(const struct bcm_vk_sync_qinfo *qinfo, u32 idx, u32 inc)
{}

static
struct vk_msg_blk __iomem *msgq_blk_addr(const struct bcm_vk_sync_qinfo *qinfo,
					 u32 idx)
{}

static u32 msgq_occupied(const struct bcm_vk_msgq __iomem *msgq,
			 const struct bcm_vk_sync_qinfo *qinfo)
{}

static
u32 msgq_avail_space(const struct bcm_vk_msgq __iomem *msgq,
		     const struct bcm_vk_sync_qinfo *qinfo)
{}

/* number of retries when enqueue message fails before returning EAGAIN */
#define BCM_VK_H2VK_ENQ_RETRY
#define BCM_VK_H2VK_ENQ_RETRY_DELAY_MS

bool bcm_vk_drv_access_ok(struct bcm_vk *vk)
{}

void bcm_vk_set_host_alert(struct bcm_vk *vk, u32 bit_mask)
{}

/*
 * Heartbeat related defines
 * The heartbeat from host is a last resort.  If stuck condition happens
 * on the card, firmware is supposed to detect it.  Therefore, the heartbeat
 * values used will be more relaxed on the driver, which need to be bigger
 * than the watchdog timeout on the card.  The watchdog timeout on the card
 * is 20s, with a jitter of 2s => 22s.  We use a value of 27s here.
 */
#define BCM_VK_HB_TIMER_S
#define BCM_VK_HB_TIMER_VALUE
#define BCM_VK_HB_LOST_MAX

static void bcm_vk_hb_poll(struct work_struct *work)
{}

void bcm_vk_hb_init(struct bcm_vk *vk)
{}

void bcm_vk_hb_deinit(struct bcm_vk *vk)
{}

static void bcm_vk_msgid_bitmap_clear(struct bcm_vk *vk,
				      unsigned int start,
				      unsigned int nbits)
{}

/*
 * allocate a ctx per file struct
 */
static struct bcm_vk_ctx *bcm_vk_get_ctx(struct bcm_vk *vk, const pid_t pid)
{}

static u16 bcm_vk_get_msg_id(struct bcm_vk *vk)
{}

static int bcm_vk_free_ctx(struct bcm_vk *vk, struct bcm_vk_ctx *ctx)
{}

static void bcm_vk_free_wkent(struct device *dev, struct bcm_vk_wkent *entry)
{}

static void bcm_vk_drain_all_pend(struct device *dev,
				  struct bcm_vk_msg_chan *chan,
				  struct bcm_vk_ctx *ctx)
{}

void bcm_vk_drain_msg_on_reset(struct bcm_vk *vk)
{}

/*
 * Function to sync up the messages queue info that is provided by BAR1
 */
int bcm_vk_sync_msgq(struct bcm_vk *vk, bool force_sync)
{}

static int bcm_vk_msg_chan_init(struct bcm_vk_msg_chan *chan)
{}

static void bcm_vk_append_pendq(struct bcm_vk_msg_chan *chan, u16 q_num,
				struct bcm_vk_wkent *entry)
{}

static u32 bcm_vk_append_ib_sgl(struct bcm_vk *vk,
				struct bcm_vk_wkent *entry,
				struct _vk_data *data,
				unsigned int num_planes)
{}

void bcm_to_v_q_doorbell(struct bcm_vk *vk, u32 q_num, u32 db_val)
{}

static int bcm_to_v_msg_enqueue(struct bcm_vk *vk, struct bcm_vk_wkent *entry)
{}

int bcm_vk_send_shutdown_msg(struct bcm_vk *vk, u32 shut_type,
			     const pid_t pid, const u32 q_num)
{}

static int bcm_vk_handle_last_sess(struct bcm_vk *vk, const pid_t pid,
				   const u32 q_num)
{}

static struct bcm_vk_wkent *bcm_vk_dequeue_pending(struct bcm_vk *vk,
						   struct bcm_vk_msg_chan *chan,
						   u16 q_num,
						   u16 msg_id)
{}

s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
{}

/*
 * init routine for all required data structures
 */
static int bcm_vk_data_init(struct bcm_vk *vk)
{}

irqreturn_t bcm_vk_msgq_irqhandler(int irq, void *dev_id)
{}

int bcm_vk_open(struct inode *inode, struct file *p_file)
{}

ssize_t bcm_vk_read(struct file *p_file,
		    char __user *buf,
		    size_t count,
		    loff_t *f_pos)
{}

ssize_t bcm_vk_write(struct file *p_file,
		     const char __user *buf,
		     size_t count,
		     loff_t *f_pos)
{}

__poll_t bcm_vk_poll(struct file *p_file, struct poll_table_struct *wait)
{}

int bcm_vk_release(struct inode *inode, struct file *p_file)
{}

int bcm_vk_msg_init(struct bcm_vk *vk)
{}

void bcm_vk_msg_remove(struct bcm_vk *vk)
{}