linux/drivers/scsi/megaraid/megaraid_ioctl.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *
 *			Linux MegaRAID device driver
 *
 * Copyright (c) 2003-2004  LSI Logic Corporation.
 *
 * FILE		: megaraid_ioctl.h
 *
 * Definitions to interface with user level applications
 */

#ifndef _MEGARAID_IOCTL_H_
#define _MEGARAID_IOCTL_H_

#include <linux/types.h>
#include <linux/semaphore.h>
#include <linux/timer.h>

#include "mbox_defs.h"

/*
 * console messages debug levels
 */
#define CL_ANN
#define CL_DLEVEL1
#define CL_DLEVEL2
#define CL_DLEVEL3

/**
 * con_log() - console log routine
 * @level		: indicates the severity of the message.
 * @fmt			: format string
 *
 * con_log displays the error messages on the console based on the current
 * debug level. Also it attaches the appropriate kernel severity level with
 * the message.
 */
#define con_log(level, fmt)

/*
 * Definitions & Declarations needed to use common management module
 */

#define MEGAIOC_MAGIC
#define MEGAIOCCMD

#define MEGAIOC_QNADAP
#define MEGAIOC_QDRVRVER
#define MEGAIOC_QADAPINFO

#define USCSICMD
#define UIOC_RD
#define UIOC_WR

#define MBOX_CMD
#define GET_DRIVER_VER
#define GET_N_ADAP
#define GET_ADAP_INFO
#define GET_CAP
#define GET_STATS
#define GET_IOCTL_VERSION

#define EXT_IOCTL_SIGN_SZ
#define EXT_IOCTL_SIGN

#define MBOX_LEGACY
#define MBOX_HPE

#define APPTYPE_MIMD
#define APPTYPE_UIOC

#define IOCTL_ISSUE
#define IOCTL_ABORT

#define DRVRTYPE_MBOX
#define DRVRTYPE_HPE

#define MKADAP(adapno)
#define GETADAP(mkadap)

#define MAX_DMA_POOLS


/**
 * struct uioc_t - the common ioctl packet structure
 *
 * @signature	: Must be "$$_EXTD_IOCTL_$$"
 * @mb_type	: Type of the mail box (MB_LEGACY or MB_HPE)
 * @app_type	: Type of the issuing application (existing or new)
 * @opcode	: Opcode of the command
 * @adapno	: Adapter number
 * @cmdbuf	: Pointer to buffer - can point to mbox or plain data buffer
 * @xferlen	: xferlen for DCMD and non mailbox commands
 * @data_dir	: Direction of the data transfer
 * @status	: Status from the driver
 * @reserved	: reserved bytes for future expansion
 *
 * @user_data	: user data transfer address is saved in this
 * @user_data_len: length of the data buffer sent by user app
 * @user_pthru	: user passthru address is saves in this (null if DCMD)
 * @pthru32	: kernel address passthru (allocated per kioc)
 * @pthru32_h	: physicall address of @pthru32
 * @list	: for kioc free pool list maintenance
 * @done	: call back routine for llds to call when kioc is completed
 * @buf_vaddr	: dma pool buffer attached to kioc for data transfer
 * @buf_paddr	: physical address of the dma pool buffer
 * @pool_index	: index of the dma pool that @buf_vaddr is taken from
 * @free_buf	: indicates if buffer needs to be freed after kioc completes
 *
 * Note		: All LSI drivers understand only this packet. Any other
 *		: format sent by applications would be converted to this.
 */
uioc_t;

/* For on-stack uioc timers. */
struct uioc_timeout {};

/**
 * struct mraid_hba_info - information about the controller
 *
 * @pci_vendor_id		: PCI vendor id
 * @pci_device_id		: PCI device id
 * @subsystem_vendor_id		: PCI subsystem vendor id
 * @subsystem_device_id		: PCI subsystem device id
 * @baseport			: base port of hba memory
 * @pci_bus			: PCI bus
 * @pci_dev_fn			: PCI device/function values
 * @irq				: interrupt vector for the device
 *
 * Extended information of 256 bytes about the controller. Align on the single
 * byte boundary so that 32-bit applications can be run on 64-bit platform
 * drivers withoug re-compilation.
 * NOTE: reduce the number of reserved bytes whenever new field are added, so
 * that total size of the structure remains 256 bytes.
 */
mraid_hba_info_t;


/**
 * mcontroller	: adapter info structure for old mimd_t apps
 *
 * @base	: base address
 * @irq		: irq number
 * @numldrv	: number of logical drives
 * @pcibus	: pci bus
 * @pcidev	: pci device
 * @pcifun	: pci function
 * @pciid	: pci id
 * @pcivendor	: vendor id
 * @pcislot	: slot number
 * @uid		: unique id
 */
mcontroller_t;


/**
 * mm_dmapool_t	: Represents one dma pool with just one buffer
 *
 * @vaddr	: Virtual address
 * @paddr	: DMA physicall address
 * @bufsize	: In KB - 4 = 4k, 8 = 8k etc.
 * @handle	: Handle to the dma pool
 * @lock	: lock to synchronize access to the pool
 * @in_use	: If pool already in use, attach new block
 */
mm_dmapool_t;


/**
 * mraid_mmadp_t: Structure that drivers pass during (un)registration
 *
 * @unique_id		: Any unique id (usually PCI bus+dev+fn)
 * @drvr_type		: megaraid or hpe (DRVRTYPE_MBOX or DRVRTYPE_HPE)
 * @drv_data		: Driver specific; not touched by the common module
 * @timeout		: timeout for issued kiocs
 * @max_kioc		: Maximum ioctl packets acceptable by the lld
 * @pdev		: pci dev; used for allocating dma'ble memory
 * @issue_uioc		: Driver supplied routine to issue uioc_t commands
 *			: issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
 * @quiescent		: flag to indicate if ioctl can be issued to this adp
 * @list		: attach with the global list of adapters
 * @kioc_list		: block of mem for @max_kioc number of kiocs
 * @kioc_pool		: pool of free kiocs
 * @kioc_pool_lock	: protection for free pool
 * @kioc_semaphore	: so as not to exceed @max_kioc parallel ioctls
 * @mbox_list		: block of mem for @max_kioc number of mboxes
 * @pthru_dma_pool	: DMA pool to allocate passthru packets
 * @dma_pool_list	: array of dma pools
 */

mraid_mmadp_t;

int mraid_mm_register_adp(mraid_mmadp_t *);
int mraid_mm_unregister_adp(uint32_t);
uint32_t mraid_mm_adapter_app_handle(uint32_t);

#endif /* _MEGARAID_IOCTL_H_ */