162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Management Module Support for MPT (Message Passing Technology) based
362306a36Sopenharmony_ci * controllers
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
662306a36Sopenharmony_ci * Copyright (C) 2012-2014  LSI Corporation
762306a36Sopenharmony_ci * Copyright (C) 2013-2014 Avago Technologies
862306a36Sopenharmony_ci *  (mailto: MPT-FusionLinux.pdl@avagotech.com)
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or
1162306a36Sopenharmony_ci * modify it under the terms of the GNU General Public License
1262306a36Sopenharmony_ci * as published by the Free Software Foundation; either version 2
1362306a36Sopenharmony_ci * of the License, or (at your option) any later version.
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful,
1662306a36Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
1762306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1862306a36Sopenharmony_ci * GNU General Public License for more details.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * NO WARRANTY
2162306a36Sopenharmony_ci * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
2262306a36Sopenharmony_ci * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
2362306a36Sopenharmony_ci * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
2462306a36Sopenharmony_ci * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
2562306a36Sopenharmony_ci * solely responsible for determining the appropriateness of using and
2662306a36Sopenharmony_ci * distributing the Program and assumes all risks associated with its
2762306a36Sopenharmony_ci * exercise of rights under this Agreement, including but not limited to
2862306a36Sopenharmony_ci * the risks and costs of program errors, damage to or loss of data,
2962306a36Sopenharmony_ci * programs or equipment, and unavailability or interruption of operations.
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci * DISCLAIMER OF LIABILITY
3262306a36Sopenharmony_ci * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
3362306a36Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3462306a36Sopenharmony_ci * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
3562306a36Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
3662306a36Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
3762306a36Sopenharmony_ci * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
3862306a36Sopenharmony_ci * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
4162306a36Sopenharmony_ci * along with this program; if not, write to the Free Software
4262306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
4362306a36Sopenharmony_ci * USA.
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#ifndef MPT3SAS_CTL_H_INCLUDED
4762306a36Sopenharmony_ci#define MPT3SAS_CTL_H_INCLUDED
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#ifdef __KERNEL__
5062306a36Sopenharmony_ci#include <linux/miscdevice.h>
5162306a36Sopenharmony_ci#endif
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#include "mpt3sas_base.h"
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#ifndef MPT2SAS_MINOR
5662306a36Sopenharmony_ci#define MPT2SAS_MINOR		(MPT_MINOR + 1)
5762306a36Sopenharmony_ci#endif
5862306a36Sopenharmony_ci#ifndef MPT3SAS_MINOR
5962306a36Sopenharmony_ci#define MPT3SAS_MINOR		(MPT_MINOR + 2)
6062306a36Sopenharmony_ci#endif
6162306a36Sopenharmony_ci#define MPT2SAS_DEV_NAME	"mpt2ctl"
6262306a36Sopenharmony_ci#define MPT3SAS_DEV_NAME	"mpt3ctl"
6362306a36Sopenharmony_ci#define MPT3_MAGIC_NUMBER	'L'
6462306a36Sopenharmony_ci#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci/**
6762306a36Sopenharmony_ci * IOCTL opcodes
6862306a36Sopenharmony_ci */
6962306a36Sopenharmony_ci#define MPT3IOCINFO	_IOWR(MPT3_MAGIC_NUMBER, 17, \
7062306a36Sopenharmony_ci	struct mpt3_ioctl_iocinfo)
7162306a36Sopenharmony_ci#define MPT3COMMAND	_IOWR(MPT3_MAGIC_NUMBER, 20, \
7262306a36Sopenharmony_ci	struct mpt3_ioctl_command)
7362306a36Sopenharmony_ci#ifdef CONFIG_COMPAT
7462306a36Sopenharmony_ci#define MPT3COMMAND32	_IOWR(MPT3_MAGIC_NUMBER, 20, \
7562306a36Sopenharmony_ci	struct mpt3_ioctl_command32)
7662306a36Sopenharmony_ci#endif
7762306a36Sopenharmony_ci#define MPT3EVENTQUERY	_IOWR(MPT3_MAGIC_NUMBER, 21, \
7862306a36Sopenharmony_ci	struct mpt3_ioctl_eventquery)
7962306a36Sopenharmony_ci#define MPT3EVENTENABLE	_IOWR(MPT3_MAGIC_NUMBER, 22, \
8062306a36Sopenharmony_ci	struct mpt3_ioctl_eventenable)
8162306a36Sopenharmony_ci#define MPT3EVENTREPORT	_IOWR(MPT3_MAGIC_NUMBER, 23, \
8262306a36Sopenharmony_ci	struct mpt3_ioctl_eventreport)
8362306a36Sopenharmony_ci#define MPT3HARDRESET	_IOWR(MPT3_MAGIC_NUMBER, 24, \
8462306a36Sopenharmony_ci	struct mpt3_ioctl_diag_reset)
8562306a36Sopenharmony_ci#define MPT3BTDHMAPPING	_IOWR(MPT3_MAGIC_NUMBER, 31, \
8662306a36Sopenharmony_ci	struct mpt3_ioctl_btdh_mapping)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* diag buffer support */
8962306a36Sopenharmony_ci#define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
9062306a36Sopenharmony_ci	struct mpt3_diag_register)
9162306a36Sopenharmony_ci#define MPT3DIAGRELEASE	_IOWR(MPT3_MAGIC_NUMBER, 27, \
9262306a36Sopenharmony_ci	struct mpt3_diag_release)
9362306a36Sopenharmony_ci#define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
9462306a36Sopenharmony_ci	struct mpt3_diag_unregister)
9562306a36Sopenharmony_ci#define MPT3DIAGQUERY	_IOWR(MPT3_MAGIC_NUMBER, 29, \
9662306a36Sopenharmony_ci	struct mpt3_diag_query)
9762306a36Sopenharmony_ci#define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
9862306a36Sopenharmony_ci	struct mpt3_diag_read_buffer)
9962306a36Sopenharmony_ci#define MPT3ADDNLDIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 32, \
10062306a36Sopenharmony_ci	struct mpt3_addnl_diag_query)
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci/* Trace Buffer default UniqueId */
10362306a36Sopenharmony_ci#define MPT2DIAGBUFFUNIQUEID (0x07075900)
10462306a36Sopenharmony_ci#define MPT3DIAGBUFFUNIQUEID (0x4252434D)
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* UID not found */
10762306a36Sopenharmony_ci#define MPT3_DIAG_UID_NOT_FOUND (0xFF)
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/**
11162306a36Sopenharmony_ci * struct mpt3_ioctl_header - main header structure
11262306a36Sopenharmony_ci * @ioc_number -  IOC unit number
11362306a36Sopenharmony_ci * @port_number - IOC port number
11462306a36Sopenharmony_ci * @max_data_size - maximum number bytes to transfer on read
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_cistruct mpt3_ioctl_header {
11762306a36Sopenharmony_ci	uint32_t ioc_number;
11862306a36Sopenharmony_ci	uint32_t port_number;
11962306a36Sopenharmony_ci	uint32_t max_data_size;
12062306a36Sopenharmony_ci};
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci/**
12362306a36Sopenharmony_ci * struct mpt3_ioctl_diag_reset - diagnostic reset
12462306a36Sopenharmony_ci * @hdr - generic header
12562306a36Sopenharmony_ci */
12662306a36Sopenharmony_cistruct mpt3_ioctl_diag_reset {
12762306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
12862306a36Sopenharmony_ci};
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci/**
13262306a36Sopenharmony_ci * struct mpt3_ioctl_pci_info - pci device info
13362306a36Sopenharmony_ci * @device - pci device id
13462306a36Sopenharmony_ci * @function - pci function id
13562306a36Sopenharmony_ci * @bus - pci bus id
13662306a36Sopenharmony_ci * @segment_id - pci segment id
13762306a36Sopenharmony_ci */
13862306a36Sopenharmony_cistruct mpt3_ioctl_pci_info {
13962306a36Sopenharmony_ci	union {
14062306a36Sopenharmony_ci		struct {
14162306a36Sopenharmony_ci			uint32_t device:5;
14262306a36Sopenharmony_ci			uint32_t function:3;
14362306a36Sopenharmony_ci			uint32_t bus:24;
14462306a36Sopenharmony_ci		} bits;
14562306a36Sopenharmony_ci		uint32_t  word;
14662306a36Sopenharmony_ci	} u;
14762306a36Sopenharmony_ci	uint32_t segment_id;
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#define MPT2_IOCTL_INTERFACE_SCSI	(0x00)
15262306a36Sopenharmony_ci#define MPT2_IOCTL_INTERFACE_FC		(0x01)
15362306a36Sopenharmony_ci#define MPT2_IOCTL_INTERFACE_FC_IP	(0x02)
15462306a36Sopenharmony_ci#define MPT2_IOCTL_INTERFACE_SAS	(0x03)
15562306a36Sopenharmony_ci#define MPT2_IOCTL_INTERFACE_SAS2	(0x04)
15662306a36Sopenharmony_ci#define MPT2_IOCTL_INTERFACE_SAS2_SSS6200	(0x05)
15762306a36Sopenharmony_ci#define MPT3_IOCTL_INTERFACE_SAS3	(0x06)
15862306a36Sopenharmony_ci#define MPT3_IOCTL_INTERFACE_SAS35	(0x07)
15962306a36Sopenharmony_ci#define MPT2_IOCTL_VERSION_LENGTH	(32)
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci/**
16262306a36Sopenharmony_ci * struct mpt3_ioctl_iocinfo - generic controller info
16362306a36Sopenharmony_ci * @hdr - generic header
16462306a36Sopenharmony_ci * @adapter_type - type of adapter (spi, fc, sas)
16562306a36Sopenharmony_ci * @port_number - port number
16662306a36Sopenharmony_ci * @pci_id - PCI Id
16762306a36Sopenharmony_ci * @hw_rev - hardware revision
16862306a36Sopenharmony_ci * @sub_system_device - PCI subsystem Device ID
16962306a36Sopenharmony_ci * @sub_system_vendor - PCI subsystem Vendor ID
17062306a36Sopenharmony_ci * @rsvd0 - reserved
17162306a36Sopenharmony_ci * @firmware_version - firmware version
17262306a36Sopenharmony_ci * @bios_version - BIOS version
17362306a36Sopenharmony_ci * @driver_version - driver version - 32 ASCII characters
17462306a36Sopenharmony_ci * @rsvd1 - reserved
17562306a36Sopenharmony_ci * @scsi_id - scsi id of adapter 0
17662306a36Sopenharmony_ci * @rsvd2 - reserved
17762306a36Sopenharmony_ci * @pci_information - pci info (2nd revision)
17862306a36Sopenharmony_ci */
17962306a36Sopenharmony_cistruct mpt3_ioctl_iocinfo {
18062306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
18162306a36Sopenharmony_ci	uint32_t adapter_type;
18262306a36Sopenharmony_ci	uint32_t port_number;
18362306a36Sopenharmony_ci	uint32_t pci_id;
18462306a36Sopenharmony_ci	uint32_t hw_rev;
18562306a36Sopenharmony_ci	uint32_t subsystem_device;
18662306a36Sopenharmony_ci	uint32_t subsystem_vendor;
18762306a36Sopenharmony_ci	uint32_t rsvd0;
18862306a36Sopenharmony_ci	uint32_t firmware_version;
18962306a36Sopenharmony_ci	uint32_t bios_version;
19062306a36Sopenharmony_ci	uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
19162306a36Sopenharmony_ci	uint8_t rsvd1;
19262306a36Sopenharmony_ci	uint8_t scsi_id;
19362306a36Sopenharmony_ci	uint16_t rsvd2;
19462306a36Sopenharmony_ci	struct mpt3_ioctl_pci_info pci_information;
19562306a36Sopenharmony_ci};
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/* number of event log entries */
19962306a36Sopenharmony_ci#define MPT3SAS_CTL_EVENT_LOG_SIZE (200)
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci/**
20262306a36Sopenharmony_ci * struct mpt3_ioctl_eventquery - query event count and type
20362306a36Sopenharmony_ci * @hdr - generic header
20462306a36Sopenharmony_ci * @event_entries - number of events returned by get_event_report
20562306a36Sopenharmony_ci * @rsvd - reserved
20662306a36Sopenharmony_ci * @event_types - type of events currently being captured
20762306a36Sopenharmony_ci */
20862306a36Sopenharmony_cistruct mpt3_ioctl_eventquery {
20962306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
21062306a36Sopenharmony_ci	uint16_t event_entries;
21162306a36Sopenharmony_ci	uint16_t rsvd;
21262306a36Sopenharmony_ci	uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
21362306a36Sopenharmony_ci};
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci/**
21662306a36Sopenharmony_ci * struct mpt3_ioctl_eventenable - enable/disable event capturing
21762306a36Sopenharmony_ci * @hdr - generic header
21862306a36Sopenharmony_ci * @event_types - toggle off/on type of events to be captured
21962306a36Sopenharmony_ci */
22062306a36Sopenharmony_cistruct mpt3_ioctl_eventenable {
22162306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
22262306a36Sopenharmony_ci	uint32_t event_types[4];
22362306a36Sopenharmony_ci};
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci#define MPT3_EVENT_DATA_SIZE (192)
22662306a36Sopenharmony_ci/**
22762306a36Sopenharmony_ci * struct MPT3_IOCTL_EVENTS -
22862306a36Sopenharmony_ci * @event - the event that was reported
22962306a36Sopenharmony_ci * @context - unique value for each event assigned by driver
23062306a36Sopenharmony_ci * @data - event data returned in fw reply message
23162306a36Sopenharmony_ci */
23262306a36Sopenharmony_cistruct MPT3_IOCTL_EVENTS {
23362306a36Sopenharmony_ci	uint32_t event;
23462306a36Sopenharmony_ci	uint32_t context;
23562306a36Sopenharmony_ci	uint8_t data[MPT3_EVENT_DATA_SIZE];
23662306a36Sopenharmony_ci};
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci/**
23962306a36Sopenharmony_ci * struct mpt3_ioctl_eventreport - returing event log
24062306a36Sopenharmony_ci * @hdr - generic header
24162306a36Sopenharmony_ci * @event_data - (see struct MPT3_IOCTL_EVENTS)
24262306a36Sopenharmony_ci */
24362306a36Sopenharmony_cistruct mpt3_ioctl_eventreport {
24462306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
24562306a36Sopenharmony_ci	struct MPT3_IOCTL_EVENTS event_data[1];
24662306a36Sopenharmony_ci};
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci/**
24962306a36Sopenharmony_ci * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
25062306a36Sopenharmony_ci * @hdr - generic header
25162306a36Sopenharmony_ci * @timeout - command timeout in seconds. (if zero then use driver default
25262306a36Sopenharmony_ci *  value).
25362306a36Sopenharmony_ci * @reply_frame_buf_ptr - reply location
25462306a36Sopenharmony_ci * @data_in_buf_ptr - destination for read
25562306a36Sopenharmony_ci * @data_out_buf_ptr - data source for write
25662306a36Sopenharmony_ci * @sense_data_ptr - sense data location
25762306a36Sopenharmony_ci * @max_reply_bytes - maximum number of reply bytes to be sent to app.
25862306a36Sopenharmony_ci * @data_in_size - number bytes for data transfer in (read)
25962306a36Sopenharmony_ci * @data_out_size - number bytes for data transfer out (write)
26062306a36Sopenharmony_ci * @max_sense_bytes - maximum number of bytes for auto sense buffers
26162306a36Sopenharmony_ci * @data_sge_offset - offset in words from the start of the request message to
26262306a36Sopenharmony_ci * the first SGL
26362306a36Sopenharmony_ci * @mf[1];
26462306a36Sopenharmony_ci */
26562306a36Sopenharmony_cistruct mpt3_ioctl_command {
26662306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
26762306a36Sopenharmony_ci	uint32_t timeout;
26862306a36Sopenharmony_ci	void __user *reply_frame_buf_ptr;
26962306a36Sopenharmony_ci	void __user *data_in_buf_ptr;
27062306a36Sopenharmony_ci	void __user *data_out_buf_ptr;
27162306a36Sopenharmony_ci	void __user *sense_data_ptr;
27262306a36Sopenharmony_ci	uint32_t max_reply_bytes;
27362306a36Sopenharmony_ci	uint32_t data_in_size;
27462306a36Sopenharmony_ci	uint32_t data_out_size;
27562306a36Sopenharmony_ci	uint32_t max_sense_bytes;
27662306a36Sopenharmony_ci	uint32_t data_sge_offset;
27762306a36Sopenharmony_ci	uint8_t mf[1];
27862306a36Sopenharmony_ci};
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#ifdef CONFIG_COMPAT
28162306a36Sopenharmony_cistruct mpt3_ioctl_command32 {
28262306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
28362306a36Sopenharmony_ci	uint32_t timeout;
28462306a36Sopenharmony_ci	uint32_t reply_frame_buf_ptr;
28562306a36Sopenharmony_ci	uint32_t data_in_buf_ptr;
28662306a36Sopenharmony_ci	uint32_t data_out_buf_ptr;
28762306a36Sopenharmony_ci	uint32_t sense_data_ptr;
28862306a36Sopenharmony_ci	uint32_t max_reply_bytes;
28962306a36Sopenharmony_ci	uint32_t data_in_size;
29062306a36Sopenharmony_ci	uint32_t data_out_size;
29162306a36Sopenharmony_ci	uint32_t max_sense_bytes;
29262306a36Sopenharmony_ci	uint32_t data_sge_offset;
29362306a36Sopenharmony_ci	uint8_t mf[1];
29462306a36Sopenharmony_ci};
29562306a36Sopenharmony_ci#endif
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci/**
29862306a36Sopenharmony_ci * struct mpt3_ioctl_btdh_mapping - mapping info
29962306a36Sopenharmony_ci * @hdr - generic header
30062306a36Sopenharmony_ci * @id - target device identification number
30162306a36Sopenharmony_ci * @bus - SCSI bus number that the target device exists on
30262306a36Sopenharmony_ci * @handle - device handle for the target device
30362306a36Sopenharmony_ci * @rsvd - reserved
30462306a36Sopenharmony_ci *
30562306a36Sopenharmony_ci * To obtain a bus/id the application sets
30662306a36Sopenharmony_ci * handle to valid handle, and bus/id to 0xFFFF.
30762306a36Sopenharmony_ci *
30862306a36Sopenharmony_ci * To obtain the device handle the application sets
30962306a36Sopenharmony_ci * bus/id valid value, and the handle to 0xFFFF.
31062306a36Sopenharmony_ci */
31162306a36Sopenharmony_cistruct mpt3_ioctl_btdh_mapping {
31262306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
31362306a36Sopenharmony_ci	uint32_t id;
31462306a36Sopenharmony_ci	uint32_t bus;
31562306a36Sopenharmony_ci	uint16_t handle;
31662306a36Sopenharmony_ci	uint16_t rsvd;
31762306a36Sopenharmony_ci};
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci/* application flags for mpt3_diag_register, mpt3_diag_query */
32262306a36Sopenharmony_ci#define MPT3_APP_FLAGS_APP_OWNED	(0x0001)
32362306a36Sopenharmony_ci#define MPT3_APP_FLAGS_BUFFER_VALID	(0x0002)
32462306a36Sopenharmony_ci#define MPT3_APP_FLAGS_FW_BUFFER_ACCESS	(0x0004)
32562306a36Sopenharmony_ci#define MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC (0x0008)
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci/* flags for mpt3_diag_read_buffer */
32862306a36Sopenharmony_ci#define MPT3_FLAGS_REREGISTER		(0x0001)
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci#define MPT3_PRODUCT_SPECIFIC_DWORDS		23
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci/**
33362306a36Sopenharmony_ci * struct mpt3_diag_register - application register with driver
33462306a36Sopenharmony_ci * @hdr - generic header
33562306a36Sopenharmony_ci * @reserved -
33662306a36Sopenharmony_ci * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
33762306a36Sopenharmony_ci * @application_flags - misc flags
33862306a36Sopenharmony_ci * @diagnostic_flags - specifies flags affecting command processing
33962306a36Sopenharmony_ci * @product_specific - product specific information
34062306a36Sopenharmony_ci * @requested_buffer_size - buffers size in bytes
34162306a36Sopenharmony_ci * @unique_id - tag specified by application that is used to signal ownership
34262306a36Sopenharmony_ci *  of the buffer.
34362306a36Sopenharmony_ci *
34462306a36Sopenharmony_ci * This will allow the driver to setup any required buffers that will be
34562306a36Sopenharmony_ci * needed by firmware to communicate with the driver.
34662306a36Sopenharmony_ci */
34762306a36Sopenharmony_cistruct mpt3_diag_register {
34862306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
34962306a36Sopenharmony_ci	uint8_t reserved;
35062306a36Sopenharmony_ci	uint8_t buffer_type;
35162306a36Sopenharmony_ci	uint16_t application_flags;
35262306a36Sopenharmony_ci	uint32_t diagnostic_flags;
35362306a36Sopenharmony_ci	uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
35462306a36Sopenharmony_ci	uint32_t requested_buffer_size;
35562306a36Sopenharmony_ci	uint32_t unique_id;
35662306a36Sopenharmony_ci};
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci/**
35962306a36Sopenharmony_ci * struct mpt3_diag_unregister - application unregister with driver
36062306a36Sopenharmony_ci * @hdr - generic header
36162306a36Sopenharmony_ci * @unique_id - tag uniquely identifies the buffer to be unregistered
36262306a36Sopenharmony_ci *
36362306a36Sopenharmony_ci * This will allow the driver to cleanup any memory allocated for diag
36462306a36Sopenharmony_ci * messages and to free up any resources.
36562306a36Sopenharmony_ci */
36662306a36Sopenharmony_cistruct mpt3_diag_unregister {
36762306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
36862306a36Sopenharmony_ci	uint32_t unique_id;
36962306a36Sopenharmony_ci};
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci/**
37262306a36Sopenharmony_ci * struct mpt3_diag_query - query relevant info associated with diag buffers
37362306a36Sopenharmony_ci * @hdr - generic header
37462306a36Sopenharmony_ci * @reserved -
37562306a36Sopenharmony_ci * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
37662306a36Sopenharmony_ci * @application_flags - misc flags
37762306a36Sopenharmony_ci * @diagnostic_flags - specifies flags affecting command processing
37862306a36Sopenharmony_ci * @product_specific - product specific information
37962306a36Sopenharmony_ci * @total_buffer_size - diag buffer size in bytes
38062306a36Sopenharmony_ci * @driver_added_buffer_size - size of extra space appended to end of buffer
38162306a36Sopenharmony_ci * @unique_id - unique id associated with this buffer.
38262306a36Sopenharmony_ci *
38362306a36Sopenharmony_ci * The application will send only buffer_type and unique_id.  Driver will
38462306a36Sopenharmony_ci * inspect unique_id first, if valid, fill in all the info.  If unique_id is
38562306a36Sopenharmony_ci * 0x00, the driver will return info specified by Buffer Type.
38662306a36Sopenharmony_ci */
38762306a36Sopenharmony_cistruct mpt3_diag_query {
38862306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
38962306a36Sopenharmony_ci	uint8_t reserved;
39062306a36Sopenharmony_ci	uint8_t buffer_type;
39162306a36Sopenharmony_ci	uint16_t application_flags;
39262306a36Sopenharmony_ci	uint32_t diagnostic_flags;
39362306a36Sopenharmony_ci	uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
39462306a36Sopenharmony_ci	uint32_t total_buffer_size;
39562306a36Sopenharmony_ci	uint32_t driver_added_buffer_size;
39662306a36Sopenharmony_ci	uint32_t unique_id;
39762306a36Sopenharmony_ci};
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ci/**
40062306a36Sopenharmony_ci * struct mpt3_diag_release -  request to send Diag Release Message to firmware
40162306a36Sopenharmony_ci * @hdr - generic header
40262306a36Sopenharmony_ci * @unique_id - tag uniquely identifies the buffer to be released
40362306a36Sopenharmony_ci *
40462306a36Sopenharmony_ci * This allows ownership of the specified buffer to returned to the driver,
40562306a36Sopenharmony_ci * allowing an application to read the buffer without fear that firmware is
40662306a36Sopenharmony_ci * overwriting information in the buffer.
40762306a36Sopenharmony_ci */
40862306a36Sopenharmony_cistruct mpt3_diag_release {
40962306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
41062306a36Sopenharmony_ci	uint32_t unique_id;
41162306a36Sopenharmony_ci};
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ci/**
41462306a36Sopenharmony_ci * struct mpt3_diag_read_buffer - request for copy of the diag buffer
41562306a36Sopenharmony_ci * @hdr - generic header
41662306a36Sopenharmony_ci * @status -
41762306a36Sopenharmony_ci * @reserved -
41862306a36Sopenharmony_ci * @flags - misc flags
41962306a36Sopenharmony_ci * @starting_offset - starting offset within drivers buffer where to start
42062306a36Sopenharmony_ci *  reading data at into the specified application buffer
42162306a36Sopenharmony_ci * @bytes_to_read - number of bytes to copy from the drivers buffer into the
42262306a36Sopenharmony_ci *  application buffer starting at starting_offset.
42362306a36Sopenharmony_ci * @unique_id - unique id associated with this buffer.
42462306a36Sopenharmony_ci * @diagnostic_data - data payload
42562306a36Sopenharmony_ci */
42662306a36Sopenharmony_cistruct mpt3_diag_read_buffer {
42762306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
42862306a36Sopenharmony_ci	uint8_t status;
42962306a36Sopenharmony_ci	uint8_t reserved;
43062306a36Sopenharmony_ci	uint16_t flags;
43162306a36Sopenharmony_ci	uint32_t starting_offset;
43262306a36Sopenharmony_ci	uint32_t bytes_to_read;
43362306a36Sopenharmony_ci	uint32_t unique_id;
43462306a36Sopenharmony_ci	uint32_t diagnostic_data[1];
43562306a36Sopenharmony_ci};
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci/**
43862306a36Sopenharmony_ci * struct mpt3_addnl_diag_query - diagnostic buffer release reason
43962306a36Sopenharmony_ci * @hdr - generic header
44062306a36Sopenharmony_ci * @unique_id - unique id associated with this buffer.
44162306a36Sopenharmony_ci * @rel_query - release query.
44262306a36Sopenharmony_ci * @reserved2
44362306a36Sopenharmony_ci */
44462306a36Sopenharmony_cistruct mpt3_addnl_diag_query {
44562306a36Sopenharmony_ci	struct mpt3_ioctl_header hdr;
44662306a36Sopenharmony_ci	uint32_t unique_id;
44762306a36Sopenharmony_ci	struct htb_rel_query rel_query;
44862306a36Sopenharmony_ci	uint32_t reserved2[2];
44962306a36Sopenharmony_ci};
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci#endif /* MPT3SAS_CTL_H_INCLUDED */
452