162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Driver for Broadcom MPI3 Storage Controllers
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2017-2022 Broadcom Inc.
662306a36Sopenharmony_ci *  (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef SCSI_BSG_MPI3MR_H_INCLUDED
1162306a36Sopenharmony_ci#define SCSI_BSG_MPI3MR_H_INCLUDED
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <linux/types.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/* Definitions for BSG commands */
1662306a36Sopenharmony_ci#define MPI3MR_IOCTL_VERSION			0x06
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define MPI3MR_APP_DEFAULT_TIMEOUT		(60) /*seconds*/
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define MPI3MR_BSG_ADPTYPE_UNKNOWN		0
2162306a36Sopenharmony_ci#define MPI3MR_BSG_ADPTYPE_AVGFAMILY		1
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define MPI3MR_BSG_ADPSTATE_UNKNOWN		0
2462306a36Sopenharmony_ci#define MPI3MR_BSG_ADPSTATE_OPERATIONAL		1
2562306a36Sopenharmony_ci#define MPI3MR_BSG_ADPSTATE_FAULT		2
2662306a36Sopenharmony_ci#define MPI3MR_BSG_ADPSTATE_IN_RESET		3
2762306a36Sopenharmony_ci#define MPI3MR_BSG_ADPSTATE_UNRECOVERABLE	4
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#define MPI3MR_BSG_ADPRESET_UNKNOWN		0
3062306a36Sopenharmony_ci#define MPI3MR_BSG_ADPRESET_SOFT		1
3162306a36Sopenharmony_ci#define MPI3MR_BSG_ADPRESET_DIAG_FAULT		2
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define MPI3MR_BSG_LOGDATA_MAX_ENTRIES		400
3462306a36Sopenharmony_ci#define MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ	4
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_UNKNOWN		0
3762306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_ADPINFO		1
3862306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_ADPRESET		2
3962306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO	4
4062306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_GETCHGCNT		5
4162306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE	6
4262306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_PELENABLE		7
4362306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_GETLOGDATA		8
4462306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_QUERY_HDB		9
4562306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_REPOST_HDB		10
4662306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_UPLOAD_HDB		11
4762306a36Sopenharmony_ci#define MPI3MR_DRVBSG_OPCODE_REFRESH_HDB_TRIGGERS	12
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_UNKNOWN		0
5162306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD		1
5262306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP	2
5362306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_DATA_IN		3
5462306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_DATA_OUT		4
5562306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_MPI_REPLY		5
5662306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_ERR_RESPONSE		6
5762306a36Sopenharmony_ci#define MPI3MR_BSG_BUFTYPE_MPI_REQUEST		0xFE
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_UNKNOWN	0
6062306a36Sopenharmony_ci#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS	1
6162306a36Sopenharmony_ci#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS	2
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define MPI3MR_HDB_BUFTYPE_UNKNOWN		0
6462306a36Sopenharmony_ci#define MPI3MR_HDB_BUFTYPE_TRACE		1
6562306a36Sopenharmony_ci#define MPI3MR_HDB_BUFTYPE_FIRMWARE		2
6662306a36Sopenharmony_ci#define MPI3MR_HDB_BUFTYPE_RESERVED		3
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#define MPI3MR_HDB_BUFSTATUS_UNKNOWN		0
6962306a36Sopenharmony_ci#define MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED	1
7062306a36Sopenharmony_ci#define MPI3MR_HDB_BUFSTATUS_POSTED_UNPAUSED	2
7162306a36Sopenharmony_ci#define MPI3MR_HDB_BUFSTATUS_POSTED_PAUSED	3
7262306a36Sopenharmony_ci#define MPI3MR_HDB_BUFSTATUS_RELEASED		4
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN		0
7562306a36Sopenharmony_ci#define MPI3MR_HDB_TRIGGER_TYPE_DIAGFAULT	1
7662306a36Sopenharmony_ci#define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT		2
7762306a36Sopenharmony_ci#define MPI3MR_HDB_TRIGGER_TYPE_MASTER		3
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* Supported BSG commands */
8162306a36Sopenharmony_cienum command {
8262306a36Sopenharmony_ci	MPI3MR_DRV_CMD = 1,
8362306a36Sopenharmony_ci	MPI3MR_MPT_CMD = 2,
8462306a36Sopenharmony_ci};
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci/**
8762306a36Sopenharmony_ci * struct mpi3_driver_info_layout - Information about driver
8862306a36Sopenharmony_ci *
8962306a36Sopenharmony_ci * @information_length: Length of this structure in bytes
9062306a36Sopenharmony_ci * @driver_signature: Driver Vendor name
9162306a36Sopenharmony_ci * @os_name: Operating System Name
9262306a36Sopenharmony_ci * @driver_name: Driver name
9362306a36Sopenharmony_ci * @driver_version: Driver version
9462306a36Sopenharmony_ci * @driver_release_date: Driver release date
9562306a36Sopenharmony_ci * @driver_capabilities: Driver capabilities
9662306a36Sopenharmony_ci */
9762306a36Sopenharmony_cistruct mpi3_driver_info_layout {
9862306a36Sopenharmony_ci	__le32	information_length;
9962306a36Sopenharmony_ci	__u8	driver_signature[12];
10062306a36Sopenharmony_ci	__u8	os_name[16];
10162306a36Sopenharmony_ci	__u8	os_version[12];
10262306a36Sopenharmony_ci	__u8	driver_name[20];
10362306a36Sopenharmony_ci	__u8	driver_version[32];
10462306a36Sopenharmony_ci	__u8	driver_release_date[20];
10562306a36Sopenharmony_ci	__le32	driver_capabilities;
10662306a36Sopenharmony_ci};
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci/**
10962306a36Sopenharmony_ci * struct mpi3mr_bsg_in_adpinfo - Adapter information request
11062306a36Sopenharmony_ci * data returned by the driver.
11162306a36Sopenharmony_ci *
11262306a36Sopenharmony_ci * @adp_type: Adapter type
11362306a36Sopenharmony_ci * @rsvd1: Reserved
11462306a36Sopenharmony_ci * @pci_dev_id: PCI device ID of the adapter
11562306a36Sopenharmony_ci * @pci_dev_hw_rev: PCI revision of the adapter
11662306a36Sopenharmony_ci * @pci_subsys_dev_id: PCI subsystem device ID of the adapter
11762306a36Sopenharmony_ci * @pci_subsys_ven_id: PCI subsystem vendor ID of the adapter
11862306a36Sopenharmony_ci * @pci_dev: PCI device
11962306a36Sopenharmony_ci * @pci_func: PCI function
12062306a36Sopenharmony_ci * @pci_bus: PCI bus
12162306a36Sopenharmony_ci * @rsvd2: Reserved
12262306a36Sopenharmony_ci * @pci_seg_id: PCI segment ID
12362306a36Sopenharmony_ci * @app_intfc_ver: version of the application interface definition
12462306a36Sopenharmony_ci * @rsvd3: Reserved
12562306a36Sopenharmony_ci * @rsvd4: Reserved
12662306a36Sopenharmony_ci * @rsvd5: Reserved
12762306a36Sopenharmony_ci * @driver_info: Driver Information (Version/Name)
12862306a36Sopenharmony_ci */
12962306a36Sopenharmony_cistruct mpi3mr_bsg_in_adpinfo {
13062306a36Sopenharmony_ci	__u32	adp_type;
13162306a36Sopenharmony_ci	__u32	rsvd1;
13262306a36Sopenharmony_ci	__u32	pci_dev_id;
13362306a36Sopenharmony_ci	__u32	pci_dev_hw_rev;
13462306a36Sopenharmony_ci	__u32	pci_subsys_dev_id;
13562306a36Sopenharmony_ci	__u32	pci_subsys_ven_id;
13662306a36Sopenharmony_ci	__u32	pci_dev:5;
13762306a36Sopenharmony_ci	__u32	pci_func:3;
13862306a36Sopenharmony_ci	__u32	pci_bus:8;
13962306a36Sopenharmony_ci	__u16	rsvd2;
14062306a36Sopenharmony_ci	__u32	pci_seg_id;
14162306a36Sopenharmony_ci	__u32	app_intfc_ver;
14262306a36Sopenharmony_ci	__u8	adp_state;
14362306a36Sopenharmony_ci	__u8	rsvd3;
14462306a36Sopenharmony_ci	__u16	rsvd4;
14562306a36Sopenharmony_ci	__u32	rsvd5[2];
14662306a36Sopenharmony_ci	struct mpi3_driver_info_layout driver_info;
14762306a36Sopenharmony_ci};
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci/**
15062306a36Sopenharmony_ci * struct mpi3mr_bsg_adp_reset - Adapter reset request
15162306a36Sopenharmony_ci * payload data to the driver.
15262306a36Sopenharmony_ci *
15362306a36Sopenharmony_ci * @reset_type: Reset type
15462306a36Sopenharmony_ci * @rsvd1: Reserved
15562306a36Sopenharmony_ci * @rsvd2: Reserved
15662306a36Sopenharmony_ci */
15762306a36Sopenharmony_cistruct mpi3mr_bsg_adp_reset {
15862306a36Sopenharmony_ci	__u8	reset_type;
15962306a36Sopenharmony_ci	__u8	rsvd1;
16062306a36Sopenharmony_ci	__u16	rsvd2;
16162306a36Sopenharmony_ci};
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/**
16462306a36Sopenharmony_ci * struct mpi3mr_change_count - Topology change count
16562306a36Sopenharmony_ci * returned by the driver.
16662306a36Sopenharmony_ci *
16762306a36Sopenharmony_ci * @change_count: Topology change count
16862306a36Sopenharmony_ci * @rsvd: Reserved
16962306a36Sopenharmony_ci */
17062306a36Sopenharmony_cistruct mpi3mr_change_count {
17162306a36Sopenharmony_ci	__u16	change_count;
17262306a36Sopenharmony_ci	__u16	rsvd;
17362306a36Sopenharmony_ci};
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci/**
17662306a36Sopenharmony_ci * struct mpi3mr_device_map_info - Target device mapping
17762306a36Sopenharmony_ci * information
17862306a36Sopenharmony_ci *
17962306a36Sopenharmony_ci * @handle: Firmware device handle
18062306a36Sopenharmony_ci * @perst_id: Persistent ID assigned by the firmware
18162306a36Sopenharmony_ci * @target_id: Target ID assigned by the driver
18262306a36Sopenharmony_ci * @bus_id: Bus ID assigned by the driver
18362306a36Sopenharmony_ci * @rsvd1: Reserved
18462306a36Sopenharmony_ci * @rsvd2: Reserved
18562306a36Sopenharmony_ci */
18662306a36Sopenharmony_cistruct mpi3mr_device_map_info {
18762306a36Sopenharmony_ci	__u16	handle;
18862306a36Sopenharmony_ci	__u16	perst_id;
18962306a36Sopenharmony_ci	__u32	target_id;
19062306a36Sopenharmony_ci	__u8	bus_id;
19162306a36Sopenharmony_ci	__u8	rsvd1;
19262306a36Sopenharmony_ci	__u16	rsvd2;
19362306a36Sopenharmony_ci};
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/**
19662306a36Sopenharmony_ci * struct mpi3mr_all_tgt_info - Target device mapping
19762306a36Sopenharmony_ci * information returned by the driver
19862306a36Sopenharmony_ci *
19962306a36Sopenharmony_ci * @num_devices: The number of devices in driver's inventory
20062306a36Sopenharmony_ci * @rsvd1: Reserved
20162306a36Sopenharmony_ci * @rsvd2: Reserved
20262306a36Sopenharmony_ci * @dmi: Variable length array of mapping information of targets
20362306a36Sopenharmony_ci */
20462306a36Sopenharmony_cistruct mpi3mr_all_tgt_info {
20562306a36Sopenharmony_ci	__u16	num_devices;
20662306a36Sopenharmony_ci	__u16	rsvd1;
20762306a36Sopenharmony_ci	__u32	rsvd2;
20862306a36Sopenharmony_ci	struct mpi3mr_device_map_info dmi[1];
20962306a36Sopenharmony_ci};
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci/**
21262306a36Sopenharmony_ci * struct mpi3mr_logdata_enable - Number of log data
21362306a36Sopenharmony_ci * entries saved by the driver returned as payload data for
21462306a36Sopenharmony_ci * enable logdata BSG request by the driver.
21562306a36Sopenharmony_ci *
21662306a36Sopenharmony_ci * @max_entries: Number of log data entries cached by the driver
21762306a36Sopenharmony_ci * @rsvd: Reserved
21862306a36Sopenharmony_ci */
21962306a36Sopenharmony_cistruct mpi3mr_logdata_enable {
22062306a36Sopenharmony_ci	__u16	max_entries;
22162306a36Sopenharmony_ci	__u16	rsvd;
22262306a36Sopenharmony_ci};
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci/**
22562306a36Sopenharmony_ci * struct mpi3mr_bsg_out_pel_enable - PEL enable request payload
22662306a36Sopenharmony_ci * data to the driver.
22762306a36Sopenharmony_ci *
22862306a36Sopenharmony_ci * @pel_locale: PEL locale to the firmware
22962306a36Sopenharmony_ci * @pel_class: PEL class to the firmware
23062306a36Sopenharmony_ci * @rsvd: Reserved
23162306a36Sopenharmony_ci */
23262306a36Sopenharmony_cistruct mpi3mr_bsg_out_pel_enable {
23362306a36Sopenharmony_ci	__u16	pel_locale;
23462306a36Sopenharmony_ci	__u8	pel_class;
23562306a36Sopenharmony_ci	__u8	rsvd;
23662306a36Sopenharmony_ci};
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci/**
23962306a36Sopenharmony_ci * struct mpi3mr_logdata_entry - Log data entry cached by the
24062306a36Sopenharmony_ci * driver.
24162306a36Sopenharmony_ci *
24262306a36Sopenharmony_ci * @valid_entry: Is the entry valid
24362306a36Sopenharmony_ci * @rsvd1: Reserved
24462306a36Sopenharmony_ci * @rsvd2: Reserved
24562306a36Sopenharmony_ci * @data: Variable length Log entry data
24662306a36Sopenharmony_ci */
24762306a36Sopenharmony_cistruct mpi3mr_logdata_entry {
24862306a36Sopenharmony_ci	__u8	valid_entry;
24962306a36Sopenharmony_ci	__u8	rsvd1;
25062306a36Sopenharmony_ci	__u16	rsvd2;
25162306a36Sopenharmony_ci	__u8	data[1]; /* Variable length Array */
25262306a36Sopenharmony_ci};
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/**
25562306a36Sopenharmony_ci * struct mpi3mr_bsg_in_log_data - Log data entries saved by
25662306a36Sopenharmony_ci * the driver returned as payload data for Get logdata request
25762306a36Sopenharmony_ci * by the driver.
25862306a36Sopenharmony_ci *
25962306a36Sopenharmony_ci * @entry: Variable length Log data entry array
26062306a36Sopenharmony_ci */
26162306a36Sopenharmony_cistruct mpi3mr_bsg_in_log_data {
26262306a36Sopenharmony_ci	struct mpi3mr_logdata_entry entry[1];
26362306a36Sopenharmony_ci};
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci/**
26662306a36Sopenharmony_ci * struct mpi3mr_hdb_entry - host diag buffer entry.
26762306a36Sopenharmony_ci *
26862306a36Sopenharmony_ci * @buf_type: Buffer type
26962306a36Sopenharmony_ci * @status: Buffer status
27062306a36Sopenharmony_ci * @trigger_type: Trigger type
27162306a36Sopenharmony_ci * @rsvd1: Reserved
27262306a36Sopenharmony_ci * @size: Buffer size
27362306a36Sopenharmony_ci * @rsvd2: Reserved
27462306a36Sopenharmony_ci * @trigger_data: Trigger specific data
27562306a36Sopenharmony_ci * @rsvd3: Reserved
27662306a36Sopenharmony_ci * @rsvd4: Reserved
27762306a36Sopenharmony_ci */
27862306a36Sopenharmony_cistruct mpi3mr_hdb_entry {
27962306a36Sopenharmony_ci	__u8	buf_type;
28062306a36Sopenharmony_ci	__u8	status;
28162306a36Sopenharmony_ci	__u8	trigger_type;
28262306a36Sopenharmony_ci	__u8	rsvd1;
28362306a36Sopenharmony_ci	__u16	size;
28462306a36Sopenharmony_ci	__u16	rsvd2;
28562306a36Sopenharmony_ci	__u64	trigger_data;
28662306a36Sopenharmony_ci	__u32	rsvd3;
28762306a36Sopenharmony_ci	__u32	rsvd4;
28862306a36Sopenharmony_ci};
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci/**
29262306a36Sopenharmony_ci * struct mpi3mr_bsg_in_hdb_status - This structure contains
29362306a36Sopenharmony_ci * return data for the BSG request to retrieve the number of host
29462306a36Sopenharmony_ci * diagnostic buffers supported by the driver and their current
29562306a36Sopenharmony_ci * status and additional status specific data if any in forms of
29662306a36Sopenharmony_ci * multiple hdb entries.
29762306a36Sopenharmony_ci *
29862306a36Sopenharmony_ci * @num_hdb_types: Number of host diag buffer types supported
29962306a36Sopenharmony_ci * @rsvd1: Reserved
30062306a36Sopenharmony_ci * @rsvd2: Reserved
30162306a36Sopenharmony_ci * @rsvd3: Reserved
30262306a36Sopenharmony_ci * @entry: Variable length Diag buffer status entry array
30362306a36Sopenharmony_ci */
30462306a36Sopenharmony_cistruct mpi3mr_bsg_in_hdb_status {
30562306a36Sopenharmony_ci	__u8	num_hdb_types;
30662306a36Sopenharmony_ci	__u8	rsvd1;
30762306a36Sopenharmony_ci	__u16	rsvd2;
30862306a36Sopenharmony_ci	__u32	rsvd3;
30962306a36Sopenharmony_ci	struct mpi3mr_hdb_entry entry[1];
31062306a36Sopenharmony_ci};
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci/**
31362306a36Sopenharmony_ci * struct mpi3mr_bsg_out_repost_hdb - Repost host diagnostic
31462306a36Sopenharmony_ci * buffer request payload data to the driver.
31562306a36Sopenharmony_ci *
31662306a36Sopenharmony_ci * @buf_type: Buffer type
31762306a36Sopenharmony_ci * @rsvd1: Reserved
31862306a36Sopenharmony_ci * @rsvd2: Reserved
31962306a36Sopenharmony_ci */
32062306a36Sopenharmony_cistruct mpi3mr_bsg_out_repost_hdb {
32162306a36Sopenharmony_ci	__u8	buf_type;
32262306a36Sopenharmony_ci	__u8	rsvd1;
32362306a36Sopenharmony_ci	__u16	rsvd2;
32462306a36Sopenharmony_ci};
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci/**
32762306a36Sopenharmony_ci * struct mpi3mr_bsg_out_upload_hdb - Upload host diagnostic
32862306a36Sopenharmony_ci * buffer request payload data to the driver.
32962306a36Sopenharmony_ci *
33062306a36Sopenharmony_ci * @buf_type: Buffer type
33162306a36Sopenharmony_ci * @rsvd1: Reserved
33262306a36Sopenharmony_ci * @rsvd2: Reserved
33362306a36Sopenharmony_ci * @start_offset: Start offset of the buffer from where to copy
33462306a36Sopenharmony_ci * @length: Length of the buffer to copy
33562306a36Sopenharmony_ci */
33662306a36Sopenharmony_cistruct mpi3mr_bsg_out_upload_hdb {
33762306a36Sopenharmony_ci	__u8	buf_type;
33862306a36Sopenharmony_ci	__u8	rsvd1;
33962306a36Sopenharmony_ci	__u16	rsvd2;
34062306a36Sopenharmony_ci	__u32	start_offset;
34162306a36Sopenharmony_ci	__u32	length;
34262306a36Sopenharmony_ci};
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci/**
34562306a36Sopenharmony_ci * struct mpi3mr_bsg_out_refresh_hdb_triggers - Refresh host
34662306a36Sopenharmony_ci * diagnostic buffer triggers request payload data to the driver.
34762306a36Sopenharmony_ci *
34862306a36Sopenharmony_ci * @page_type: Page type
34962306a36Sopenharmony_ci * @rsvd1: Reserved
35062306a36Sopenharmony_ci * @rsvd2: Reserved
35162306a36Sopenharmony_ci */
35262306a36Sopenharmony_cistruct mpi3mr_bsg_out_refresh_hdb_triggers {
35362306a36Sopenharmony_ci	__u8	page_type;
35462306a36Sopenharmony_ci	__u8	rsvd1;
35562306a36Sopenharmony_ci	__u16	rsvd2;
35662306a36Sopenharmony_ci};
35762306a36Sopenharmony_ci/**
35862306a36Sopenharmony_ci * struct mpi3mr_bsg_drv_cmd -  Generic bsg data
35962306a36Sopenharmony_ci * structure for all driver specific requests.
36062306a36Sopenharmony_ci *
36162306a36Sopenharmony_ci * @mrioc_id: Controller ID
36262306a36Sopenharmony_ci * @opcode: Driver specific opcode
36362306a36Sopenharmony_ci * @rsvd1: Reserved
36462306a36Sopenharmony_ci * @rsvd2: Reserved
36562306a36Sopenharmony_ci */
36662306a36Sopenharmony_cistruct mpi3mr_bsg_drv_cmd {
36762306a36Sopenharmony_ci	__u8	mrioc_id;
36862306a36Sopenharmony_ci	__u8	opcode;
36962306a36Sopenharmony_ci	__u16	rsvd1;
37062306a36Sopenharmony_ci	__u32	rsvd2[4];
37162306a36Sopenharmony_ci};
37262306a36Sopenharmony_ci/**
37362306a36Sopenharmony_ci * struct mpi3mr_bsg_in_reply_buf - MPI reply buffer returned
37462306a36Sopenharmony_ci * for MPI Passthrough request .
37562306a36Sopenharmony_ci *
37662306a36Sopenharmony_ci * @mpi_reply_type: Type of MPI reply
37762306a36Sopenharmony_ci * @rsvd1: Reserved
37862306a36Sopenharmony_ci * @rsvd2: Reserved
37962306a36Sopenharmony_ci * @reply_buf: Variable Length buffer based on mpirep type
38062306a36Sopenharmony_ci */
38162306a36Sopenharmony_cistruct mpi3mr_bsg_in_reply_buf {
38262306a36Sopenharmony_ci	__u8	mpi_reply_type;
38362306a36Sopenharmony_ci	__u8	rsvd1;
38462306a36Sopenharmony_ci	__u16	rsvd2;
38562306a36Sopenharmony_ci	__u8	reply_buf[1];
38662306a36Sopenharmony_ci};
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci/**
38962306a36Sopenharmony_ci * struct mpi3mr_buf_entry - User buffer descriptor for MPI
39062306a36Sopenharmony_ci * Passthrough requests.
39162306a36Sopenharmony_ci *
39262306a36Sopenharmony_ci * @buf_type: Buffer type
39362306a36Sopenharmony_ci * @rsvd1: Reserved
39462306a36Sopenharmony_ci * @rsvd2: Reserved
39562306a36Sopenharmony_ci * @buf_len: Buffer length
39662306a36Sopenharmony_ci */
39762306a36Sopenharmony_cistruct mpi3mr_buf_entry {
39862306a36Sopenharmony_ci	__u8	buf_type;
39962306a36Sopenharmony_ci	__u8	rsvd1;
40062306a36Sopenharmony_ci	__u16	rsvd2;
40162306a36Sopenharmony_ci	__u32	buf_len;
40262306a36Sopenharmony_ci};
40362306a36Sopenharmony_ci/**
40462306a36Sopenharmony_ci * struct mpi3mr_bsg_buf_entry_list - list of user buffer
40562306a36Sopenharmony_ci * descriptor for MPI Passthrough requests.
40662306a36Sopenharmony_ci *
40762306a36Sopenharmony_ci * @num_of_entries: Number of buffer descriptors
40862306a36Sopenharmony_ci * @rsvd1: Reserved
40962306a36Sopenharmony_ci * @rsvd2: Reserved
41062306a36Sopenharmony_ci * @rsvd3: Reserved
41162306a36Sopenharmony_ci * @buf_entry: Variable length array of buffer descriptors
41262306a36Sopenharmony_ci */
41362306a36Sopenharmony_cistruct mpi3mr_buf_entry_list {
41462306a36Sopenharmony_ci	__u8	num_of_entries;
41562306a36Sopenharmony_ci	__u8	rsvd1;
41662306a36Sopenharmony_ci	__u16	rsvd2;
41762306a36Sopenharmony_ci	__u32	rsvd3;
41862306a36Sopenharmony_ci	struct mpi3mr_buf_entry buf_entry[1];
41962306a36Sopenharmony_ci};
42062306a36Sopenharmony_ci/**
42162306a36Sopenharmony_ci * struct mpi3mr_bsg_mptcmd -  Generic bsg data
42262306a36Sopenharmony_ci * structure for all MPI Passthrough requests .
42362306a36Sopenharmony_ci *
42462306a36Sopenharmony_ci * @mrioc_id: Controller ID
42562306a36Sopenharmony_ci * @rsvd1: Reserved
42662306a36Sopenharmony_ci * @timeout: MPI request timeout
42762306a36Sopenharmony_ci * @buf_entry_list: Buffer descriptor list
42862306a36Sopenharmony_ci */
42962306a36Sopenharmony_cistruct mpi3mr_bsg_mptcmd {
43062306a36Sopenharmony_ci	__u8	mrioc_id;
43162306a36Sopenharmony_ci	__u8	rsvd1;
43262306a36Sopenharmony_ci	__u16	timeout;
43362306a36Sopenharmony_ci	__u32	rsvd2;
43462306a36Sopenharmony_ci	struct mpi3mr_buf_entry_list buf_entry_list;
43562306a36Sopenharmony_ci};
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci/**
43862306a36Sopenharmony_ci * struct mpi3mr_bsg_packet -  Generic bsg data
43962306a36Sopenharmony_ci * structure for all supported requests .
44062306a36Sopenharmony_ci *
44162306a36Sopenharmony_ci * @cmd_type: represents drvrcmd or mptcmd
44262306a36Sopenharmony_ci * @rsvd1: Reserved
44362306a36Sopenharmony_ci * @rsvd2: Reserved
44462306a36Sopenharmony_ci * @drvrcmd: driver request structure
44562306a36Sopenharmony_ci * @mptcmd: mpt request structure
44662306a36Sopenharmony_ci */
44762306a36Sopenharmony_cistruct mpi3mr_bsg_packet {
44862306a36Sopenharmony_ci	__u8	cmd_type;
44962306a36Sopenharmony_ci	__u8	rsvd1;
45062306a36Sopenharmony_ci	__u16	rsvd2;
45162306a36Sopenharmony_ci	__u32	rsvd3;
45262306a36Sopenharmony_ci	union {
45362306a36Sopenharmony_ci		struct mpi3mr_bsg_drv_cmd drvrcmd;
45462306a36Sopenharmony_ci		struct mpi3mr_bsg_mptcmd mptcmd;
45562306a36Sopenharmony_ci	} cmd;
45662306a36Sopenharmony_ci};
45762306a36Sopenharmony_ci
45862306a36Sopenharmony_cistruct mpi3_nvme_encapsulated_request {
45962306a36Sopenharmony_ci	__le16	host_tag;
46062306a36Sopenharmony_ci	__u8	ioc_use_only02;
46162306a36Sopenharmony_ci	__u8	function;
46262306a36Sopenharmony_ci	__le16	ioc_use_only04;
46362306a36Sopenharmony_ci	__u8	ioc_use_only06;
46462306a36Sopenharmony_ci	__u8	msg_flags;
46562306a36Sopenharmony_ci	__le16	change_count;
46662306a36Sopenharmony_ci	__le16	dev_handle;
46762306a36Sopenharmony_ci	__le16	encapsulated_command_length;
46862306a36Sopenharmony_ci	__le16	flags;
46962306a36Sopenharmony_ci	__le32	data_length;
47062306a36Sopenharmony_ci	__le32  reserved14[3];
47162306a36Sopenharmony_ci	__le32	command[];
47262306a36Sopenharmony_ci};
47362306a36Sopenharmony_ci
47462306a36Sopenharmony_cistruct mpi3_nvme_encapsulated_error_reply {
47562306a36Sopenharmony_ci	__le16	host_tag;
47662306a36Sopenharmony_ci	__u8	ioc_use_only02;
47762306a36Sopenharmony_ci	__u8	function;
47862306a36Sopenharmony_ci	__le16	ioc_use_only04;
47962306a36Sopenharmony_ci	__u8	ioc_use_only06;
48062306a36Sopenharmony_ci	__u8	msg_flags;
48162306a36Sopenharmony_ci	__le16	ioc_use_only08;
48262306a36Sopenharmony_ci	__le16	ioc_status;
48362306a36Sopenharmony_ci	__le32	ioc_log_info;
48462306a36Sopenharmony_ci	__le32	nvme_completion_entry[4];
48562306a36Sopenharmony_ci};
48662306a36Sopenharmony_ci
48762306a36Sopenharmony_ci#define	MPI3MR_NVME_PRP_SIZE		8 /* PRP size */
48862306a36Sopenharmony_ci#define	MPI3MR_NVME_CMD_PRP1_OFFSET	24 /* PRP1 offset in NVMe cmd */
48962306a36Sopenharmony_ci#define	MPI3MR_NVME_CMD_PRP2_OFFSET	32 /* PRP2 offset in NVMe cmd */
49062306a36Sopenharmony_ci#define	MPI3MR_NVME_CMD_SGL_OFFSET	24 /* SGL offset in NVMe cmd */
49162306a36Sopenharmony_ci#define MPI3MR_NVME_DATA_FORMAT_PRP	0
49262306a36Sopenharmony_ci#define MPI3MR_NVME_DATA_FORMAT_SGL1	1
49362306a36Sopenharmony_ci#define MPI3MR_NVME_DATA_FORMAT_SGL2	2
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_ci/* MPI3: task management related definitions */
49662306a36Sopenharmony_cistruct mpi3_scsi_task_mgmt_request {
49762306a36Sopenharmony_ci	__le16	host_tag;
49862306a36Sopenharmony_ci	__u8	ioc_use_only02;
49962306a36Sopenharmony_ci	__u8	function;
50062306a36Sopenharmony_ci	__le16	ioc_use_only04;
50162306a36Sopenharmony_ci	__u8	ioc_use_only06;
50262306a36Sopenharmony_ci	__u8    msg_flags;
50362306a36Sopenharmony_ci	__le16	change_count;
50462306a36Sopenharmony_ci	__le16	dev_handle;
50562306a36Sopenharmony_ci	__le16	task_host_tag;
50662306a36Sopenharmony_ci	__u8	task_type;
50762306a36Sopenharmony_ci	__u8	reserved0f;
50862306a36Sopenharmony_ci	__le16	task_request_queue_id;
50962306a36Sopenharmony_ci	__le16	reserved12;
51062306a36Sopenharmony_ci	__le32	reserved14;
51162306a36Sopenharmony_ci	__u8	lun[8];
51262306a36Sopenharmony_ci};
51362306a36Sopenharmony_ci
51462306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU      (0x08)
51562306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK               (0x01)
51662306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET           (0x02)
51762306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET             (0x03)
51862306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET       (0x05)
51962306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET           (0x06)
52062306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK               (0x07)
52162306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA                (0x08)
52262306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET           (0x09)
52362306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT        (0x0a)
52462306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET          (0x0b)
52562306a36Sopenharmony_cistruct mpi3_scsi_task_mgmt_reply {
52662306a36Sopenharmony_ci	__le16	host_tag;
52762306a36Sopenharmony_ci	__u8	ioc_use_only02;
52862306a36Sopenharmony_ci	__u8	function;
52962306a36Sopenharmony_ci	__le16  ioc_use_only04;
53062306a36Sopenharmony_ci	__u8	ioc_use_only06;
53162306a36Sopenharmony_ci	__u8	msg_flags;
53262306a36Sopenharmony_ci	__le16	ioc_use_only08;
53362306a36Sopenharmony_ci	__le16	ioc_status;
53462306a36Sopenharmony_ci	__le32	ioc_log_info;
53562306a36Sopenharmony_ci	__le32	termination_count;
53662306a36Sopenharmony_ci	__le32	response_data;
53762306a36Sopenharmony_ci	__le32	reserved18;
53862306a36Sopenharmony_ci};
53962306a36Sopenharmony_ci
54062306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE                (0x00)
54162306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME              (0x02)
54262306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED  (0x04)
54362306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED                  (0x05)
54462306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED               (0x08)
54562306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN             (0x09)
54662306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG          (0x0a)
54762306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC           (0x80)
54862306a36Sopenharmony_ci#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED             (0x81)
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci/* MPI3: PEL related definitions */
55162306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT   (0x0200)
55262306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT       (0x0100)
55362306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_PCIE                      (0x0080)
55462306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION             (0x0040)
55562306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_CONTROLER                 (0x0020)
55662306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_SAS                       (0x0010)
55762306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_EPACK                     (0x0008)
55862306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE                 (0x0004)
55962306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_PD                        (0x0002)
56062306a36Sopenharmony_ci#define MPI3_PEL_LOCALE_FLAGS_VD                        (0x0001)
56162306a36Sopenharmony_ci#define MPI3_PEL_CLASS_DEBUG                            (0x00)
56262306a36Sopenharmony_ci#define MPI3_PEL_CLASS_PROGRESS                         (0x01)
56362306a36Sopenharmony_ci#define MPI3_PEL_CLASS_INFORMATIONAL                    (0x02)
56462306a36Sopenharmony_ci#define MPI3_PEL_CLASS_WARNING                          (0x03)
56562306a36Sopenharmony_ci#define MPI3_PEL_CLASS_CRITICAL                         (0x04)
56662306a36Sopenharmony_ci#define MPI3_PEL_CLASS_FATAL                            (0x05)
56762306a36Sopenharmony_ci#define MPI3_PEL_CLASS_FAULT                            (0x06)
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_ci/* MPI3: Function definitions */
57062306a36Sopenharmony_ci#define MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH              (0x0a)
57162306a36Sopenharmony_ci#define MPI3_BSG_FUNCTION_SCSI_IO                       (0x20)
57262306a36Sopenharmony_ci#define MPI3_BSG_FUNCTION_SCSI_TASK_MGMT                (0x21)
57362306a36Sopenharmony_ci#define MPI3_BSG_FUNCTION_SMP_PASSTHROUGH               (0x22)
57462306a36Sopenharmony_ci#define MPI3_BSG_FUNCTION_NVME_ENCAPSULATED             (0x24)
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_ci#endif
577