18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
38c2ecf20Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify
68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
78c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
108c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
118c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
128c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
138c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
158c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
168c2ecf20Sopenharmony_ci * SOFTWARE.
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#ifndef _FCPIO_H_
198c2ecf20Sopenharmony_ci#define _FCPIO_H_
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include <linux/if_ether.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/*
248c2ecf20Sopenharmony_ci * This header file includes all of the data structures used for
258c2ecf20Sopenharmony_ci * communication by the host driver to the fcp firmware.
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/*
298c2ecf20Sopenharmony_ci * Exchange and sequence id space allocated to the host driver
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci#define FCPIO_HOST_EXCH_RANGE_START         0x1000
328c2ecf20Sopenharmony_ci#define FCPIO_HOST_EXCH_RANGE_END           0x1fff
338c2ecf20Sopenharmony_ci#define FCPIO_HOST_SEQ_ID_RANGE_START       0x80
348c2ecf20Sopenharmony_ci#define FCPIO_HOST_SEQ_ID_RANGE_END         0xff
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/*
378c2ecf20Sopenharmony_ci * Command entry type
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_cienum fcpio_type {
408c2ecf20Sopenharmony_ci	/*
418c2ecf20Sopenharmony_ci	 * Initiator request types
428c2ecf20Sopenharmony_ci	 */
438c2ecf20Sopenharmony_ci	FCPIO_ICMND_16 = 0x1,
448c2ecf20Sopenharmony_ci	FCPIO_ICMND_32,
458c2ecf20Sopenharmony_ci	FCPIO_ICMND_CMPL,
468c2ecf20Sopenharmony_ci	FCPIO_ITMF,
478c2ecf20Sopenharmony_ci	FCPIO_ITMF_CMPL,
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	/*
508c2ecf20Sopenharmony_ci	 * Target request types
518c2ecf20Sopenharmony_ci	 */
528c2ecf20Sopenharmony_ci	FCPIO_TCMND_16 = 0x11,
538c2ecf20Sopenharmony_ci	FCPIO_TCMND_32,
548c2ecf20Sopenharmony_ci	FCPIO_TDATA,
558c2ecf20Sopenharmony_ci	FCPIO_TXRDY,
568c2ecf20Sopenharmony_ci	FCPIO_TRSP,
578c2ecf20Sopenharmony_ci	FCPIO_TDRSP_CMPL,
588c2ecf20Sopenharmony_ci	FCPIO_TTMF,
598c2ecf20Sopenharmony_ci	FCPIO_TTMF_ACK,
608c2ecf20Sopenharmony_ci	FCPIO_TABORT,
618c2ecf20Sopenharmony_ci	FCPIO_TABORT_CMPL,
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	/*
648c2ecf20Sopenharmony_ci	 * Misc request types
658c2ecf20Sopenharmony_ci	 */
668c2ecf20Sopenharmony_ci	FCPIO_ACK = 0x20,
678c2ecf20Sopenharmony_ci	FCPIO_RESET,
688c2ecf20Sopenharmony_ci	FCPIO_RESET_CMPL,
698c2ecf20Sopenharmony_ci	FCPIO_FLOGI_REG,
708c2ecf20Sopenharmony_ci	FCPIO_FLOGI_REG_CMPL,
718c2ecf20Sopenharmony_ci	FCPIO_ECHO,
728c2ecf20Sopenharmony_ci	FCPIO_ECHO_CMPL,
738c2ecf20Sopenharmony_ci	FCPIO_LUNMAP_CHNG,
748c2ecf20Sopenharmony_ci	FCPIO_LUNMAP_REQ,
758c2ecf20Sopenharmony_ci	FCPIO_LUNMAP_REQ_CMPL,
768c2ecf20Sopenharmony_ci	FCPIO_FLOGI_FIP_REG,
778c2ecf20Sopenharmony_ci	FCPIO_FLOGI_FIP_REG_CMPL,
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci/*
818c2ecf20Sopenharmony_ci * Header status codes from the firmware
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_cienum fcpio_status {
848c2ecf20Sopenharmony_ci	FCPIO_SUCCESS = 0,              /* request was successful */
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	/*
878c2ecf20Sopenharmony_ci	 * If a request to the firmware is rejected, the original request
888c2ecf20Sopenharmony_ci	 * header will be returned with the status set to one of the following:
898c2ecf20Sopenharmony_ci	 */
908c2ecf20Sopenharmony_ci	FCPIO_INVALID_HEADER,    /* header contains invalid data */
918c2ecf20Sopenharmony_ci	FCPIO_OUT_OF_RESOURCE,   /* out of resources to complete request */
928c2ecf20Sopenharmony_ci	FCPIO_INVALID_PARAM,     /* some parameter in request is invalid */
938c2ecf20Sopenharmony_ci	FCPIO_REQ_NOT_SUPPORTED, /* request type is not supported */
948c2ecf20Sopenharmony_ci	FCPIO_IO_NOT_FOUND,      /* requested I/O was not found */
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	/*
978c2ecf20Sopenharmony_ci	 * Once a request is processed, the firmware will usually return
988c2ecf20Sopenharmony_ci	 * a cmpl message type.  In cases where errors occurred,
998c2ecf20Sopenharmony_ci	 * the header status field would be filled in with one of the following:
1008c2ecf20Sopenharmony_ci	 */
1018c2ecf20Sopenharmony_ci	FCPIO_ABORTED = 0x41,     /* request was aborted */
1028c2ecf20Sopenharmony_ci	FCPIO_TIMEOUT,            /* request was timed out */
1038c2ecf20Sopenharmony_ci	FCPIO_SGL_INVALID,        /* request was aborted due to sgl error */
1048c2ecf20Sopenharmony_ci	FCPIO_MSS_INVALID,        /* request was aborted due to mss error */
1058c2ecf20Sopenharmony_ci	FCPIO_DATA_CNT_MISMATCH,  /* recv/sent more/less data than exp. */
1068c2ecf20Sopenharmony_ci	FCPIO_FW_ERR,             /* request was terminated due to fw error */
1078c2ecf20Sopenharmony_ci	FCPIO_ITMF_REJECTED,      /* itmf req was rejected by remote node */
1088c2ecf20Sopenharmony_ci	FCPIO_ITMF_FAILED,        /* itmf req was failed by remote node */
1098c2ecf20Sopenharmony_ci	FCPIO_ITMF_INCORRECT_LUN, /* itmf req targeted incorrect LUN */
1108c2ecf20Sopenharmony_ci	FCPIO_CMND_REJECTED,      /* request was invalid and rejected */
1118c2ecf20Sopenharmony_ci	FCPIO_NO_PATH_AVAIL,      /* no paths to the lun was available */
1128c2ecf20Sopenharmony_ci	FCPIO_PATH_FAILED,        /* i/o sent to current path failed */
1138c2ecf20Sopenharmony_ci	FCPIO_LUNMAP_CHNG_PEND,   /* i/o rejected due to lunmap change */
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/*
1178c2ecf20Sopenharmony_ci * The header command tag.  All host requests will use the "tag" field
1188c2ecf20Sopenharmony_ci * to mark commands with a unique tag.  When the firmware responds to
1198c2ecf20Sopenharmony_ci * a host request, it will copy the tag field into the response.
1208c2ecf20Sopenharmony_ci *
1218c2ecf20Sopenharmony_ci * The only firmware requests that will use the rx_id/ox_id fields instead
1228c2ecf20Sopenharmony_ci * of the tag field will be the target command and target task management
1238c2ecf20Sopenharmony_ci * requests.  These two requests do not have corresponding host requests
1248c2ecf20Sopenharmony_ci * since they come directly from the FC initiator on the network.
1258c2ecf20Sopenharmony_ci */
1268c2ecf20Sopenharmony_cistruct fcpio_tag {
1278c2ecf20Sopenharmony_ci	union {
1288c2ecf20Sopenharmony_ci		u32 req_id;
1298c2ecf20Sopenharmony_ci		struct {
1308c2ecf20Sopenharmony_ci			u16 rx_id;
1318c2ecf20Sopenharmony_ci			u16 ox_id;
1328c2ecf20Sopenharmony_ci		} ex_id;
1338c2ecf20Sopenharmony_ci	} u;
1348c2ecf20Sopenharmony_ci};
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_cistatic inline void
1378c2ecf20Sopenharmony_cifcpio_tag_id_enc(struct fcpio_tag *tag, u32 id)
1388c2ecf20Sopenharmony_ci{
1398c2ecf20Sopenharmony_ci	tag->u.req_id = id;
1408c2ecf20Sopenharmony_ci}
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistatic inline void
1438c2ecf20Sopenharmony_cifcpio_tag_id_dec(struct fcpio_tag *tag, u32 *id)
1448c2ecf20Sopenharmony_ci{
1458c2ecf20Sopenharmony_ci	*id = tag->u.req_id;
1468c2ecf20Sopenharmony_ci}
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic inline void
1498c2ecf20Sopenharmony_cifcpio_tag_exid_enc(struct fcpio_tag *tag, u16 ox_id, u16 rx_id)
1508c2ecf20Sopenharmony_ci{
1518c2ecf20Sopenharmony_ci	tag->u.ex_id.rx_id = rx_id;
1528c2ecf20Sopenharmony_ci	tag->u.ex_id.ox_id = ox_id;
1538c2ecf20Sopenharmony_ci}
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_cistatic inline void
1568c2ecf20Sopenharmony_cifcpio_tag_exid_dec(struct fcpio_tag *tag, u16 *ox_id, u16 *rx_id)
1578c2ecf20Sopenharmony_ci{
1588c2ecf20Sopenharmony_ci	*rx_id = tag->u.ex_id.rx_id;
1598c2ecf20Sopenharmony_ci	*ox_id = tag->u.ex_id.ox_id;
1608c2ecf20Sopenharmony_ci}
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci/*
1638c2ecf20Sopenharmony_ci * The header for an fcpio request, whether from the firmware or from the
1648c2ecf20Sopenharmony_ci * host driver
1658c2ecf20Sopenharmony_ci */
1668c2ecf20Sopenharmony_cistruct fcpio_header {
1678c2ecf20Sopenharmony_ci	u8            type;           /* enum fcpio_type */
1688c2ecf20Sopenharmony_ci	u8            status;         /* header status entry */
1698c2ecf20Sopenharmony_ci	u16           _resvd;         /* reserved */
1708c2ecf20Sopenharmony_ci	struct fcpio_tag    tag;      /* header tag */
1718c2ecf20Sopenharmony_ci};
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_cistatic inline void
1748c2ecf20Sopenharmony_cifcpio_header_enc(struct fcpio_header *hdr,
1758c2ecf20Sopenharmony_ci		 u8 type, u8 status,
1768c2ecf20Sopenharmony_ci		 struct fcpio_tag tag)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	hdr->type = type;
1798c2ecf20Sopenharmony_ci	hdr->status = status;
1808c2ecf20Sopenharmony_ci	hdr->_resvd = 0;
1818c2ecf20Sopenharmony_ci	hdr->tag = tag;
1828c2ecf20Sopenharmony_ci}
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistatic inline void
1858c2ecf20Sopenharmony_cifcpio_header_dec(struct fcpio_header *hdr,
1868c2ecf20Sopenharmony_ci		 u8 *type, u8 *status,
1878c2ecf20Sopenharmony_ci		 struct fcpio_tag *tag)
1888c2ecf20Sopenharmony_ci{
1898c2ecf20Sopenharmony_ci	*type = hdr->type;
1908c2ecf20Sopenharmony_ci	*status = hdr->status;
1918c2ecf20Sopenharmony_ci	*tag = hdr->tag;
1928c2ecf20Sopenharmony_ci}
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci#define CDB_16      16
1958c2ecf20Sopenharmony_ci#define CDB_32      32
1968c2ecf20Sopenharmony_ci#define LUN_ADDRESS 8
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/*
1998c2ecf20Sopenharmony_ci * fcpio_icmnd_16: host -> firmware request
2008c2ecf20Sopenharmony_ci *
2018c2ecf20Sopenharmony_ci * used for sending out an initiator SCSI 16-byte command
2028c2ecf20Sopenharmony_ci */
2038c2ecf20Sopenharmony_cistruct fcpio_icmnd_16 {
2048c2ecf20Sopenharmony_ci	u32	  lunmap_id;		/* index into lunmap table */
2058c2ecf20Sopenharmony_ci	u8	  special_req_flags;	/* special exchange request flags */
2068c2ecf20Sopenharmony_ci	u8	  _resvd0[3];	        /* reserved */
2078c2ecf20Sopenharmony_ci	u32	  sgl_cnt;		/* scatter-gather list count */
2088c2ecf20Sopenharmony_ci	u32	  sense_len;		/* sense buffer length */
2098c2ecf20Sopenharmony_ci	u64	  sgl_addr;		/* scatter-gather list addr */
2108c2ecf20Sopenharmony_ci	u64	  sense_addr;		/* sense buffer address */
2118c2ecf20Sopenharmony_ci	u8	  crn;			/* SCSI Command Reference No. */
2128c2ecf20Sopenharmony_ci	u8	  pri_ta;		/* SCSI Priority and Task attribute */
2138c2ecf20Sopenharmony_ci	u8	  _resvd1;		/* reserved: should be 0 */
2148c2ecf20Sopenharmony_ci	u8	  flags;		/* command flags */
2158c2ecf20Sopenharmony_ci	u8	  scsi_cdb[CDB_16];	/* SCSI Cmnd Descriptor Block */
2168c2ecf20Sopenharmony_ci	u32	  data_len;		/* length of data expected */
2178c2ecf20Sopenharmony_ci	u8	  lun[LUN_ADDRESS];	/* FC vNIC only: LUN address */
2188c2ecf20Sopenharmony_ci	u8	  _resvd2;		/* reserved */
2198c2ecf20Sopenharmony_ci	u8	  d_id[3];		/* FC vNIC only: Target D_ID */
2208c2ecf20Sopenharmony_ci	u16	  mss;			/* FC vNIC only: max burst */
2218c2ecf20Sopenharmony_ci	u16	  _resvd3;		/* reserved */
2228c2ecf20Sopenharmony_ci	u32	  r_a_tov;		/* FC vNIC only: Res. Alloc Timeout */
2238c2ecf20Sopenharmony_ci	u32	  e_d_tov;	        /* FC vNIC only: Err Detect Timeout */
2248c2ecf20Sopenharmony_ci};
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci/*
2278c2ecf20Sopenharmony_ci * Special request flags
2288c2ecf20Sopenharmony_ci */
2298c2ecf20Sopenharmony_ci#define FCPIO_ICMND_SRFLAG_RETRY 0x01   /* Enable Retry handling on exchange */
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/*
2328c2ecf20Sopenharmony_ci * Priority/Task Attribute settings
2338c2ecf20Sopenharmony_ci */
2348c2ecf20Sopenharmony_ci#define FCPIO_ICMND_PTA_SIMPLE      0   /* simple task attribute */
2358c2ecf20Sopenharmony_ci#define FCPIO_ICMND_PTA_HEADQ       1   /* head of queue task attribute */
2368c2ecf20Sopenharmony_ci#define FCPIO_ICMND_PTA_ORDERED     2   /* ordered task attribute */
2378c2ecf20Sopenharmony_ci#define FCPIO_ICMND_PTA_ACA         4   /* auto contingent allegiance */
2388c2ecf20Sopenharmony_ci#define FCPIO_ICMND_PRI_SHIFT       3   /* priority field starts in bit 3 */
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci/*
2418c2ecf20Sopenharmony_ci * Command flags
2428c2ecf20Sopenharmony_ci */
2438c2ecf20Sopenharmony_ci#define FCPIO_ICMND_RDDATA      0x02    /* read data */
2448c2ecf20Sopenharmony_ci#define FCPIO_ICMND_WRDATA      0x01    /* write data */
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci/*
2478c2ecf20Sopenharmony_ci * fcpio_icmnd_32: host -> firmware request
2488c2ecf20Sopenharmony_ci *
2498c2ecf20Sopenharmony_ci * used for sending out an initiator SCSI 32-byte command
2508c2ecf20Sopenharmony_ci */
2518c2ecf20Sopenharmony_cistruct fcpio_icmnd_32 {
2528c2ecf20Sopenharmony_ci	u32   lunmap_id;              /* index into lunmap table */
2538c2ecf20Sopenharmony_ci	u8    special_req_flags;      /* special exchange request flags */
2548c2ecf20Sopenharmony_ci	u8    _resvd0[3];             /* reserved */
2558c2ecf20Sopenharmony_ci	u32   sgl_cnt;                /* scatter-gather list count */
2568c2ecf20Sopenharmony_ci	u32   sense_len;              /* sense buffer length */
2578c2ecf20Sopenharmony_ci	u64   sgl_addr;               /* scatter-gather list addr */
2588c2ecf20Sopenharmony_ci	u64   sense_addr;             /* sense buffer address */
2598c2ecf20Sopenharmony_ci	u8    crn;                    /* SCSI Command Reference No. */
2608c2ecf20Sopenharmony_ci	u8    pri_ta;                 /* SCSI Priority and Task attribute */
2618c2ecf20Sopenharmony_ci	u8    _resvd1;                /* reserved: should be 0 */
2628c2ecf20Sopenharmony_ci	u8    flags;                  /* command flags */
2638c2ecf20Sopenharmony_ci	u8    scsi_cdb[CDB_32];       /* SCSI Cmnd Descriptor Block */
2648c2ecf20Sopenharmony_ci	u32   data_len;               /* length of data expected */
2658c2ecf20Sopenharmony_ci	u8    lun[LUN_ADDRESS];       /* FC vNIC only: LUN address */
2668c2ecf20Sopenharmony_ci	u8    _resvd2;                /* reserved */
2678c2ecf20Sopenharmony_ci	u8    d_id[3];		      /* FC vNIC only: Target D_ID */
2688c2ecf20Sopenharmony_ci	u16   mss;                    /* FC vNIC only: max burst */
2698c2ecf20Sopenharmony_ci	u16   _resvd3;                /* reserved */
2708c2ecf20Sopenharmony_ci	u32   r_a_tov;                /* FC vNIC only: Res. Alloc Timeout */
2718c2ecf20Sopenharmony_ci	u32   e_d_tov;                /* FC vNIC only: Error Detect Timeout */
2728c2ecf20Sopenharmony_ci};
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci/*
2758c2ecf20Sopenharmony_ci * fcpio_itmf: host -> firmware request
2768c2ecf20Sopenharmony_ci *
2778c2ecf20Sopenharmony_ci * used for requesting the firmware to abort a request and/or send out
2788c2ecf20Sopenharmony_ci * a task management function
2798c2ecf20Sopenharmony_ci *
2808c2ecf20Sopenharmony_ci * The t_tag field is only needed when the request type is ABT_TASK.
2818c2ecf20Sopenharmony_ci */
2828c2ecf20Sopenharmony_cistruct fcpio_itmf {
2838c2ecf20Sopenharmony_ci	u32   lunmap_id;              /* index into lunmap table */
2848c2ecf20Sopenharmony_ci	u32   tm_req;                 /* SCSI Task Management request */
2858c2ecf20Sopenharmony_ci	u32   t_tag;                  /* header tag of fcpio to be aborted */
2868c2ecf20Sopenharmony_ci	u32   _resvd;                 /* _reserved */
2878c2ecf20Sopenharmony_ci	u8    lun[LUN_ADDRESS];       /* FC vNIC only: LUN address */
2888c2ecf20Sopenharmony_ci	u8    _resvd1;                /* reserved */
2898c2ecf20Sopenharmony_ci	u8    d_id[3];		      /* FC vNIC only: Target D_ID */
2908c2ecf20Sopenharmony_ci	u32   r_a_tov;                /* FC vNIC only: R_A_TOV in msec */
2918c2ecf20Sopenharmony_ci	u32   e_d_tov;                /* FC vNIC only: E_D_TOV in msec */
2928c2ecf20Sopenharmony_ci};
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci/*
2958c2ecf20Sopenharmony_ci * Task Management request
2968c2ecf20Sopenharmony_ci */
2978c2ecf20Sopenharmony_cienum fcpio_itmf_tm_req_type {
2988c2ecf20Sopenharmony_ci	FCPIO_ITMF_ABT_TASK_TERM = 0x01,    /* abort task and terminate */
2998c2ecf20Sopenharmony_ci	FCPIO_ITMF_ABT_TASK,                /* abort task and issue abts */
3008c2ecf20Sopenharmony_ci	FCPIO_ITMF_ABT_TASK_SET,            /* abort task set */
3018c2ecf20Sopenharmony_ci	FCPIO_ITMF_CLR_TASK_SET,            /* clear task set */
3028c2ecf20Sopenharmony_ci	FCPIO_ITMF_LUN_RESET,               /* logical unit reset task mgmt */
3038c2ecf20Sopenharmony_ci	FCPIO_ITMF_CLR_ACA,                 /* Clear ACA condition */
3048c2ecf20Sopenharmony_ci};
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci/*
3078c2ecf20Sopenharmony_ci * fcpio_tdata: host -> firmware request
3088c2ecf20Sopenharmony_ci *
3098c2ecf20Sopenharmony_ci * used for requesting the firmware to send out a read data transfer for a
3108c2ecf20Sopenharmony_ci * target command
3118c2ecf20Sopenharmony_ci */
3128c2ecf20Sopenharmony_cistruct fcpio_tdata {
3138c2ecf20Sopenharmony_ci	u16   rx_id;                  /* FC rx_id of target command */
3148c2ecf20Sopenharmony_ci	u16   flags;                  /* command flags */
3158c2ecf20Sopenharmony_ci	u32   rel_offset;             /* data sequence relative offset */
3168c2ecf20Sopenharmony_ci	u32   sgl_cnt;                /* scatter-gather list count */
3178c2ecf20Sopenharmony_ci	u32   data_len;               /* length of data expected to send */
3188c2ecf20Sopenharmony_ci	u64   sgl_addr;               /* scatter-gather list address */
3198c2ecf20Sopenharmony_ci};
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci/*
3228c2ecf20Sopenharmony_ci * Command flags
3238c2ecf20Sopenharmony_ci */
3248c2ecf20Sopenharmony_ci#define FCPIO_TDATA_SCSI_RSP    0x01    /* send a scsi resp. after last frame */
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci/*
3278c2ecf20Sopenharmony_ci * fcpio_txrdy: host -> firmware request
3288c2ecf20Sopenharmony_ci *
3298c2ecf20Sopenharmony_ci * used for requesting the firmware to send out a write data transfer for a
3308c2ecf20Sopenharmony_ci * target command
3318c2ecf20Sopenharmony_ci */
3328c2ecf20Sopenharmony_cistruct fcpio_txrdy {
3338c2ecf20Sopenharmony_ci	u16   rx_id;                  /* FC rx_id of target command */
3348c2ecf20Sopenharmony_ci	u16   _resvd0;                /* reserved */
3358c2ecf20Sopenharmony_ci	u32   rel_offset;             /* data sequence relative offset */
3368c2ecf20Sopenharmony_ci	u32   sgl_cnt;                /* scatter-gather list count */
3378c2ecf20Sopenharmony_ci	u32   data_len;               /* length of data expected to send */
3388c2ecf20Sopenharmony_ci	u64   sgl_addr;               /* scatter-gather list address */
3398c2ecf20Sopenharmony_ci};
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci/*
3428c2ecf20Sopenharmony_ci * fcpio_trsp: host -> firmware request
3438c2ecf20Sopenharmony_ci *
3448c2ecf20Sopenharmony_ci * used for requesting the firmware to send out a response for a target
3458c2ecf20Sopenharmony_ci * command
3468c2ecf20Sopenharmony_ci */
3478c2ecf20Sopenharmony_cistruct fcpio_trsp {
3488c2ecf20Sopenharmony_ci	u16   rx_id;                  /* FC rx_id of target command */
3498c2ecf20Sopenharmony_ci	u16   _resvd0;                /* reserved */
3508c2ecf20Sopenharmony_ci	u32   sense_len;              /* sense data buffer length */
3518c2ecf20Sopenharmony_ci	u64   sense_addr;             /* sense data buffer address */
3528c2ecf20Sopenharmony_ci	u16   _resvd1;                /* reserved */
3538c2ecf20Sopenharmony_ci	u8    flags;                  /* response request flags */
3548c2ecf20Sopenharmony_ci	u8    scsi_status;            /* SCSI status */
3558c2ecf20Sopenharmony_ci	u32   residual;               /* SCSI data residual value of I/O */
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci/*
3598c2ecf20Sopenharmony_ci * resposnse request flags
3608c2ecf20Sopenharmony_ci */
3618c2ecf20Sopenharmony_ci#define FCPIO_TRSP_RESID_UNDER  0x08   /* residual is valid and is underflow */
3628c2ecf20Sopenharmony_ci#define FCPIO_TRSP_RESID_OVER   0x04   /* residual is valid and is overflow */
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci/*
3658c2ecf20Sopenharmony_ci * fcpio_ttmf_ack: host -> firmware response
3668c2ecf20Sopenharmony_ci *
3678c2ecf20Sopenharmony_ci * used by the host to indicate to the firmware it has received and processed
3688c2ecf20Sopenharmony_ci * the target tmf request
3698c2ecf20Sopenharmony_ci */
3708c2ecf20Sopenharmony_cistruct fcpio_ttmf_ack {
3718c2ecf20Sopenharmony_ci	u16   rx_id;                  /* FC rx_id of target command */
3728c2ecf20Sopenharmony_ci	u16   _resvd0;                /* reserved */
3738c2ecf20Sopenharmony_ci	u32   tmf_status;             /* SCSI task management status */
3748c2ecf20Sopenharmony_ci};
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci/*
3778c2ecf20Sopenharmony_ci * fcpio_tabort: host -> firmware request
3788c2ecf20Sopenharmony_ci *
3798c2ecf20Sopenharmony_ci * used by the host to request the firmware to abort a target request that was
3808c2ecf20Sopenharmony_ci * received by the firmware
3818c2ecf20Sopenharmony_ci */
3828c2ecf20Sopenharmony_cistruct fcpio_tabort {
3838c2ecf20Sopenharmony_ci	u16   rx_id;                  /* rx_id of the target request */
3848c2ecf20Sopenharmony_ci};
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci/*
3878c2ecf20Sopenharmony_ci * fcpio_reset: host -> firmware request
3888c2ecf20Sopenharmony_ci *
3898c2ecf20Sopenharmony_ci * used by the host to signal a reset of the driver to the firmware
3908c2ecf20Sopenharmony_ci * and to request firmware to clean up all outstanding I/O
3918c2ecf20Sopenharmony_ci */
3928c2ecf20Sopenharmony_cistruct fcpio_reset {
3938c2ecf20Sopenharmony_ci	u32   _resvd;
3948c2ecf20Sopenharmony_ci};
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cienum fcpio_flogi_reg_format_type {
3978c2ecf20Sopenharmony_ci	FCPIO_FLOGI_REG_DEF_DEST = 0,    /* Use the oui | s_id mac format */
3988c2ecf20Sopenharmony_ci	FCPIO_FLOGI_REG_GW_DEST,         /* Use the fixed gateway mac */
3998c2ecf20Sopenharmony_ci};
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci/*
4028c2ecf20Sopenharmony_ci * fcpio_flogi_reg: host -> firmware request
4038c2ecf20Sopenharmony_ci *
4048c2ecf20Sopenharmony_ci * fc vnic only
4058c2ecf20Sopenharmony_ci * used by the host to notify the firmware of the lif's s_id
4068c2ecf20Sopenharmony_ci * and destination mac address format
4078c2ecf20Sopenharmony_ci */
4088c2ecf20Sopenharmony_cistruct fcpio_flogi_reg {
4098c2ecf20Sopenharmony_ci	u8 format;
4108c2ecf20Sopenharmony_ci	u8 s_id[3];			/* FC vNIC only: Source S_ID */
4118c2ecf20Sopenharmony_ci	u8 gateway_mac[ETH_ALEN];	/* Destination gateway mac */
4128c2ecf20Sopenharmony_ci	u16 _resvd;
4138c2ecf20Sopenharmony_ci	u32 r_a_tov;			/* R_A_TOV in msec */
4148c2ecf20Sopenharmony_ci	u32 e_d_tov;			/* E_D_TOV in msec */
4158c2ecf20Sopenharmony_ci};
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci/*
4188c2ecf20Sopenharmony_ci * fcpio_echo: host -> firmware request
4198c2ecf20Sopenharmony_ci *
4208c2ecf20Sopenharmony_ci * sends a heartbeat echo request to the firmware
4218c2ecf20Sopenharmony_ci */
4228c2ecf20Sopenharmony_cistruct fcpio_echo {
4238c2ecf20Sopenharmony_ci	u32 _resvd;
4248c2ecf20Sopenharmony_ci};
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci/*
4278c2ecf20Sopenharmony_ci * fcpio_lunmap_req: host -> firmware request
4288c2ecf20Sopenharmony_ci *
4298c2ecf20Sopenharmony_ci * scsi vnic only
4308c2ecf20Sopenharmony_ci * sends a request to retrieve the lunmap table for scsi vnics
4318c2ecf20Sopenharmony_ci */
4328c2ecf20Sopenharmony_cistruct fcpio_lunmap_req {
4338c2ecf20Sopenharmony_ci	u64 addr;                     /* address of the buffer */
4348c2ecf20Sopenharmony_ci	u32 len;                      /* len of the buffer */
4358c2ecf20Sopenharmony_ci};
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci/*
4388c2ecf20Sopenharmony_ci * fcpio_flogi_fip_reg: host -> firmware request
4398c2ecf20Sopenharmony_ci *
4408c2ecf20Sopenharmony_ci * fc vnic only
4418c2ecf20Sopenharmony_ci * used by the host to notify the firmware of the lif's s_id
4428c2ecf20Sopenharmony_ci * and destination mac address format
4438c2ecf20Sopenharmony_ci */
4448c2ecf20Sopenharmony_cistruct fcpio_flogi_fip_reg {
4458c2ecf20Sopenharmony_ci	u8    _resvd0;
4468c2ecf20Sopenharmony_ci	u8     s_id[3];               /* FC vNIC only: Source S_ID */
4478c2ecf20Sopenharmony_ci	u8     fcf_mac[ETH_ALEN];     /* FCF Target destination mac */
4488c2ecf20Sopenharmony_ci	u16   _resvd1;
4498c2ecf20Sopenharmony_ci	u32   r_a_tov;                /* R_A_TOV in msec */
4508c2ecf20Sopenharmony_ci	u32   e_d_tov;                /* E_D_TOV in msec */
4518c2ecf20Sopenharmony_ci	u8    ha_mac[ETH_ALEN];       /* Host adapter source mac */
4528c2ecf20Sopenharmony_ci	u16   _resvd2;
4538c2ecf20Sopenharmony_ci};
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci/*
4568c2ecf20Sopenharmony_ci * Basic structure for all fcpio structures that are sent from the host to the
4578c2ecf20Sopenharmony_ci * firmware.  They are 128 bytes per structure.
4588c2ecf20Sopenharmony_ci */
4598c2ecf20Sopenharmony_ci#define FCPIO_HOST_REQ_LEN      128     /* expected length of host requests */
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_cistruct fcpio_host_req {
4628c2ecf20Sopenharmony_ci	struct fcpio_header hdr;
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci	union {
4658c2ecf20Sopenharmony_ci		/*
4668c2ecf20Sopenharmony_ci		 * Defines space needed for request
4678c2ecf20Sopenharmony_ci		 */
4688c2ecf20Sopenharmony_ci		u8 buf[FCPIO_HOST_REQ_LEN - sizeof(struct fcpio_header)];
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci		/*
4718c2ecf20Sopenharmony_ci		 * Initiator host requests
4728c2ecf20Sopenharmony_ci		 */
4738c2ecf20Sopenharmony_ci		struct fcpio_icmnd_16               icmnd_16;
4748c2ecf20Sopenharmony_ci		struct fcpio_icmnd_32               icmnd_32;
4758c2ecf20Sopenharmony_ci		struct fcpio_itmf                   itmf;
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci		/*
4788c2ecf20Sopenharmony_ci		 * Target host requests
4798c2ecf20Sopenharmony_ci		 */
4808c2ecf20Sopenharmony_ci		struct fcpio_tdata                  tdata;
4818c2ecf20Sopenharmony_ci		struct fcpio_txrdy                  txrdy;
4828c2ecf20Sopenharmony_ci		struct fcpio_trsp                   trsp;
4838c2ecf20Sopenharmony_ci		struct fcpio_ttmf_ack               ttmf_ack;
4848c2ecf20Sopenharmony_ci		struct fcpio_tabort                 tabort;
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci		/*
4878c2ecf20Sopenharmony_ci		 * Misc requests
4888c2ecf20Sopenharmony_ci		 */
4898c2ecf20Sopenharmony_ci		struct fcpio_reset                  reset;
4908c2ecf20Sopenharmony_ci		struct fcpio_flogi_reg              flogi_reg;
4918c2ecf20Sopenharmony_ci		struct fcpio_echo                   echo;
4928c2ecf20Sopenharmony_ci		struct fcpio_lunmap_req             lunmap_req;
4938c2ecf20Sopenharmony_ci		struct fcpio_flogi_fip_reg          flogi_fip_reg;
4948c2ecf20Sopenharmony_ci	} u;
4958c2ecf20Sopenharmony_ci};
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci/*
4988c2ecf20Sopenharmony_ci * fcpio_icmnd_cmpl: firmware -> host response
4998c2ecf20Sopenharmony_ci *
5008c2ecf20Sopenharmony_ci * used for sending the host a response to an initiator command
5018c2ecf20Sopenharmony_ci */
5028c2ecf20Sopenharmony_cistruct fcpio_icmnd_cmpl {
5038c2ecf20Sopenharmony_ci	u8    _resvd0[6];             /* reserved */
5048c2ecf20Sopenharmony_ci	u8    flags;                  /* response flags */
5058c2ecf20Sopenharmony_ci	u8    scsi_status;            /* SCSI status */
5068c2ecf20Sopenharmony_ci	u32   residual;               /* SCSI data residual length */
5078c2ecf20Sopenharmony_ci	u32   sense_len;              /* SCSI sense length */
5088c2ecf20Sopenharmony_ci};
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci/*
5118c2ecf20Sopenharmony_ci * response flags
5128c2ecf20Sopenharmony_ci */
5138c2ecf20Sopenharmony_ci#define FCPIO_ICMND_CMPL_RESID_UNDER    0x08    /* resid under and valid */
5148c2ecf20Sopenharmony_ci#define FCPIO_ICMND_CMPL_RESID_OVER     0x04    /* resid over and valid */
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci/*
5178c2ecf20Sopenharmony_ci * fcpio_itmf_cmpl: firmware -> host response
5188c2ecf20Sopenharmony_ci *
5198c2ecf20Sopenharmony_ci * used for sending the host a response for a itmf request
5208c2ecf20Sopenharmony_ci */
5218c2ecf20Sopenharmony_cistruct fcpio_itmf_cmpl {
5228c2ecf20Sopenharmony_ci	u32    _resvd;                /* reserved */
5238c2ecf20Sopenharmony_ci};
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci/*
5268c2ecf20Sopenharmony_ci * fcpio_tcmnd_16: firmware -> host request
5278c2ecf20Sopenharmony_ci *
5288c2ecf20Sopenharmony_ci * used by the firmware to notify the host of an incoming target SCSI 16-Byte
5298c2ecf20Sopenharmony_ci * request
5308c2ecf20Sopenharmony_ci */
5318c2ecf20Sopenharmony_cistruct fcpio_tcmnd_16 {
5328c2ecf20Sopenharmony_ci	u8    lun[LUN_ADDRESS];       /* FC vNIC only: LUN address */
5338c2ecf20Sopenharmony_ci	u8    crn;                    /* SCSI Command Reference No. */
5348c2ecf20Sopenharmony_ci	u8    pri_ta;                 /* SCSI Priority and Task attribute */
5358c2ecf20Sopenharmony_ci	u8    _resvd2;                /* reserved: should be 0 */
5368c2ecf20Sopenharmony_ci	u8    flags;                  /* command flags */
5378c2ecf20Sopenharmony_ci	u8    scsi_cdb[CDB_16];       /* SCSI Cmnd Descriptor Block */
5388c2ecf20Sopenharmony_ci	u32   data_len;               /* length of data expected */
5398c2ecf20Sopenharmony_ci	u8    _resvd1;                /* reserved */
5408c2ecf20Sopenharmony_ci	u8    s_id[3];		      /* FC vNIC only: Source S_ID */
5418c2ecf20Sopenharmony_ci};
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci/*
5448c2ecf20Sopenharmony_ci * Priority/Task Attribute settings
5458c2ecf20Sopenharmony_ci */
5468c2ecf20Sopenharmony_ci#define FCPIO_TCMND_PTA_SIMPLE      0   /* simple task attribute */
5478c2ecf20Sopenharmony_ci#define FCPIO_TCMND_PTA_HEADQ       1   /* head of queue task attribute */
5488c2ecf20Sopenharmony_ci#define FCPIO_TCMND_PTA_ORDERED     2   /* ordered task attribute */
5498c2ecf20Sopenharmony_ci#define FCPIO_TCMND_PTA_ACA         4   /* auto contingent allegiance */
5508c2ecf20Sopenharmony_ci#define FCPIO_TCMND_PRI_SHIFT       3   /* priority field starts in bit 3 */
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_ci/*
5538c2ecf20Sopenharmony_ci * Command flags
5548c2ecf20Sopenharmony_ci */
5558c2ecf20Sopenharmony_ci#define FCPIO_TCMND_RDDATA      0x02    /* read data */
5568c2ecf20Sopenharmony_ci#define FCPIO_TCMND_WRDATA      0x01    /* write data */
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci/*
5598c2ecf20Sopenharmony_ci * fcpio_tcmnd_32: firmware -> host request
5608c2ecf20Sopenharmony_ci *
5618c2ecf20Sopenharmony_ci * used by the firmware to notify the host of an incoming target SCSI 32-Byte
5628c2ecf20Sopenharmony_ci * request
5638c2ecf20Sopenharmony_ci */
5648c2ecf20Sopenharmony_cistruct fcpio_tcmnd_32 {
5658c2ecf20Sopenharmony_ci	u8    lun[LUN_ADDRESS];       /* FC vNIC only: LUN address */
5668c2ecf20Sopenharmony_ci	u8    crn;                    /* SCSI Command Reference No. */
5678c2ecf20Sopenharmony_ci	u8    pri_ta;                 /* SCSI Priority and Task attribute */
5688c2ecf20Sopenharmony_ci	u8    _resvd2;                /* reserved: should be 0 */
5698c2ecf20Sopenharmony_ci	u8    flags;                  /* command flags */
5708c2ecf20Sopenharmony_ci	u8    scsi_cdb[CDB_32];       /* SCSI Cmnd Descriptor Block */
5718c2ecf20Sopenharmony_ci	u32   data_len;               /* length of data expected */
5728c2ecf20Sopenharmony_ci	u8    _resvd0;                /* reserved */
5738c2ecf20Sopenharmony_ci	u8    s_id[3];		      /* FC vNIC only: Source S_ID */
5748c2ecf20Sopenharmony_ci};
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci/*
5778c2ecf20Sopenharmony_ci * fcpio_tdrsp_cmpl: firmware -> host response
5788c2ecf20Sopenharmony_ci *
5798c2ecf20Sopenharmony_ci * used by the firmware to notify the host of a response to a host target
5808c2ecf20Sopenharmony_ci * command
5818c2ecf20Sopenharmony_ci */
5828c2ecf20Sopenharmony_cistruct fcpio_tdrsp_cmpl {
5838c2ecf20Sopenharmony_ci	u16   rx_id;                  /* rx_id of the target request */
5848c2ecf20Sopenharmony_ci	u16   _resvd0;                /* reserved */
5858c2ecf20Sopenharmony_ci};
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci/*
5888c2ecf20Sopenharmony_ci * fcpio_ttmf: firmware -> host request
5898c2ecf20Sopenharmony_ci *
5908c2ecf20Sopenharmony_ci * used by the firmware to notify the host of an incoming task management
5918c2ecf20Sopenharmony_ci * function request
5928c2ecf20Sopenharmony_ci */
5938c2ecf20Sopenharmony_cistruct fcpio_ttmf {
5948c2ecf20Sopenharmony_ci	u8    _resvd0;                /* reserved */
5958c2ecf20Sopenharmony_ci	u8    s_id[3];		      /* FC vNIC only: Source S_ID */
5968c2ecf20Sopenharmony_ci	u8    lun[LUN_ADDRESS];       /* FC vNIC only: LUN address */
5978c2ecf20Sopenharmony_ci	u8    crn;                    /* SCSI Command Reference No. */
5988c2ecf20Sopenharmony_ci	u8    _resvd2[3];             /* reserved */
5998c2ecf20Sopenharmony_ci	u32   tmf_type;               /* task management request type */
6008c2ecf20Sopenharmony_ci};
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci/*
6038c2ecf20Sopenharmony_ci * Task Management request
6048c2ecf20Sopenharmony_ci */
6058c2ecf20Sopenharmony_ci#define FCPIO_TTMF_CLR_ACA      0x40    /* Clear ACA condition */
6068c2ecf20Sopenharmony_ci#define FCPIO_TTMF_LUN_RESET    0x10    /* logical unit reset task mgmt */
6078c2ecf20Sopenharmony_ci#define FCPIO_TTMF_CLR_TASK_SET 0x04    /* clear task set */
6088c2ecf20Sopenharmony_ci#define FCPIO_TTMF_ABT_TASK_SET 0x02    /* abort task set */
6098c2ecf20Sopenharmony_ci#define FCPIO_TTMF_ABT_TASK     0x01    /* abort task */
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ci/*
6128c2ecf20Sopenharmony_ci * fcpio_tabort_cmpl: firmware -> host response
6138c2ecf20Sopenharmony_ci *
6148c2ecf20Sopenharmony_ci * used by the firmware to respond to a host's tabort request
6158c2ecf20Sopenharmony_ci */
6168c2ecf20Sopenharmony_cistruct fcpio_tabort_cmpl {
6178c2ecf20Sopenharmony_ci	u16   rx_id;                  /* rx_id of the target request */
6188c2ecf20Sopenharmony_ci	u16   _resvd0;                /* reserved */
6198c2ecf20Sopenharmony_ci};
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci/*
6228c2ecf20Sopenharmony_ci * fcpio_ack: firmware -> host response
6238c2ecf20Sopenharmony_ci *
6248c2ecf20Sopenharmony_ci * used by firmware to notify the host of the last work request received
6258c2ecf20Sopenharmony_ci */
6268c2ecf20Sopenharmony_cistruct fcpio_ack {
6278c2ecf20Sopenharmony_ci	u16  request_out;             /* last host entry received */
6288c2ecf20Sopenharmony_ci	u16  _resvd;
6298c2ecf20Sopenharmony_ci};
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci/*
6328c2ecf20Sopenharmony_ci * fcpio_reset_cmpl: firmware -> host response
6338c2ecf20Sopenharmony_ci *
6348c2ecf20Sopenharmony_ci * use by firmware to respond to the host's reset request
6358c2ecf20Sopenharmony_ci */
6368c2ecf20Sopenharmony_cistruct fcpio_reset_cmpl {
6378c2ecf20Sopenharmony_ci	u16   vnic_id;
6388c2ecf20Sopenharmony_ci};
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci/*
6418c2ecf20Sopenharmony_ci * fcpio_flogi_reg_cmpl: firmware -> host response
6428c2ecf20Sopenharmony_ci *
6438c2ecf20Sopenharmony_ci * fc vnic only
6448c2ecf20Sopenharmony_ci * response to the fcpio_flogi_reg request
6458c2ecf20Sopenharmony_ci */
6468c2ecf20Sopenharmony_cistruct fcpio_flogi_reg_cmpl {
6478c2ecf20Sopenharmony_ci	u32 _resvd;
6488c2ecf20Sopenharmony_ci};
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci/*
6518c2ecf20Sopenharmony_ci * fcpio_echo_cmpl: firmware -> host response
6528c2ecf20Sopenharmony_ci *
6538c2ecf20Sopenharmony_ci * response to the fcpio_echo request
6548c2ecf20Sopenharmony_ci */
6558c2ecf20Sopenharmony_cistruct fcpio_echo_cmpl {
6568c2ecf20Sopenharmony_ci	u32 _resvd;
6578c2ecf20Sopenharmony_ci};
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_ci/*
6608c2ecf20Sopenharmony_ci * fcpio_lunmap_chng: firmware -> host notification
6618c2ecf20Sopenharmony_ci *
6628c2ecf20Sopenharmony_ci * scsi vnic only
6638c2ecf20Sopenharmony_ci * notifies the host that the lunmap tables have changed
6648c2ecf20Sopenharmony_ci */
6658c2ecf20Sopenharmony_cistruct fcpio_lunmap_chng {
6668c2ecf20Sopenharmony_ci	u32 _resvd;
6678c2ecf20Sopenharmony_ci};
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci/*
6708c2ecf20Sopenharmony_ci * fcpio_lunmap_req_cmpl: firmware -> host response
6718c2ecf20Sopenharmony_ci *
6728c2ecf20Sopenharmony_ci * scsi vnic only
6738c2ecf20Sopenharmony_ci * response for lunmap table request from the host
6748c2ecf20Sopenharmony_ci */
6758c2ecf20Sopenharmony_cistruct fcpio_lunmap_req_cmpl {
6768c2ecf20Sopenharmony_ci	u32 _resvd;
6778c2ecf20Sopenharmony_ci};
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci/*
6808c2ecf20Sopenharmony_ci * Basic structure for all fcpio structures that are sent from the firmware to
6818c2ecf20Sopenharmony_ci * the host.  They are 64 bytes per structure.
6828c2ecf20Sopenharmony_ci */
6838c2ecf20Sopenharmony_ci#define FCPIO_FW_REQ_LEN        64      /* expected length of fw requests */
6848c2ecf20Sopenharmony_cistruct fcpio_fw_req {
6858c2ecf20Sopenharmony_ci	struct fcpio_header hdr;
6868c2ecf20Sopenharmony_ci
6878c2ecf20Sopenharmony_ci	union {
6888c2ecf20Sopenharmony_ci		/*
6898c2ecf20Sopenharmony_ci		 * Defines space needed for request
6908c2ecf20Sopenharmony_ci		 */
6918c2ecf20Sopenharmony_ci		u8 buf[FCPIO_FW_REQ_LEN - sizeof(struct fcpio_header)];
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci		/*
6948c2ecf20Sopenharmony_ci		 * Initiator firmware responses
6958c2ecf20Sopenharmony_ci		 */
6968c2ecf20Sopenharmony_ci		struct fcpio_icmnd_cmpl         icmnd_cmpl;
6978c2ecf20Sopenharmony_ci		struct fcpio_itmf_cmpl          itmf_cmpl;
6988c2ecf20Sopenharmony_ci
6998c2ecf20Sopenharmony_ci		/*
7008c2ecf20Sopenharmony_ci		 * Target firmware new requests
7018c2ecf20Sopenharmony_ci		 */
7028c2ecf20Sopenharmony_ci		struct fcpio_tcmnd_16           tcmnd_16;
7038c2ecf20Sopenharmony_ci		struct fcpio_tcmnd_32           tcmnd_32;
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci		/*
7068c2ecf20Sopenharmony_ci		 * Target firmware responses
7078c2ecf20Sopenharmony_ci		 */
7088c2ecf20Sopenharmony_ci		struct fcpio_tdrsp_cmpl         tdrsp_cmpl;
7098c2ecf20Sopenharmony_ci		struct fcpio_ttmf               ttmf;
7108c2ecf20Sopenharmony_ci		struct fcpio_tabort_cmpl        tabort_cmpl;
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_ci		/*
7138c2ecf20Sopenharmony_ci		 * Firmware response to work received
7148c2ecf20Sopenharmony_ci		 */
7158c2ecf20Sopenharmony_ci		struct fcpio_ack                ack;
7168c2ecf20Sopenharmony_ci
7178c2ecf20Sopenharmony_ci		/*
7188c2ecf20Sopenharmony_ci		 * Misc requests
7198c2ecf20Sopenharmony_ci		 */
7208c2ecf20Sopenharmony_ci		struct fcpio_reset_cmpl         reset_cmpl;
7218c2ecf20Sopenharmony_ci		struct fcpio_flogi_reg_cmpl     flogi_reg_cmpl;
7228c2ecf20Sopenharmony_ci		struct fcpio_echo_cmpl          echo_cmpl;
7238c2ecf20Sopenharmony_ci		struct fcpio_lunmap_chng        lunmap_chng;
7248c2ecf20Sopenharmony_ci		struct fcpio_lunmap_req_cmpl    lunmap_req_cmpl;
7258c2ecf20Sopenharmony_ci	} u;
7268c2ecf20Sopenharmony_ci};
7278c2ecf20Sopenharmony_ci
7288c2ecf20Sopenharmony_ci/*
7298c2ecf20Sopenharmony_ci * Access routines to encode and decode the color bit, which is the most
7308c2ecf20Sopenharmony_ci * significant bit of the MSB of the structure
7318c2ecf20Sopenharmony_ci */
7328c2ecf20Sopenharmony_cistatic inline void fcpio_color_enc(struct fcpio_fw_req *fw_req, u8 color)
7338c2ecf20Sopenharmony_ci{
7348c2ecf20Sopenharmony_ci	u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1;
7358c2ecf20Sopenharmony_ci
7368c2ecf20Sopenharmony_ci	if (color)
7378c2ecf20Sopenharmony_ci		*c |= 0x80;
7388c2ecf20Sopenharmony_ci	else
7398c2ecf20Sopenharmony_ci		*c &= ~0x80;
7408c2ecf20Sopenharmony_ci}
7418c2ecf20Sopenharmony_ci
7428c2ecf20Sopenharmony_cistatic inline void fcpio_color_dec(struct fcpio_fw_req *fw_req, u8 *color)
7438c2ecf20Sopenharmony_ci{
7448c2ecf20Sopenharmony_ci	u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1;
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci	*color = *c >> 7;
7478c2ecf20Sopenharmony_ci
7488c2ecf20Sopenharmony_ci	/*
7498c2ecf20Sopenharmony_ci	 * Make sure color bit is read from desc *before* other fields
7508c2ecf20Sopenharmony_ci	 * are read from desc.  Hardware guarantees color bit is last
7518c2ecf20Sopenharmony_ci	 * bit (byte) written.  Adding the rmb() prevents the compiler
7528c2ecf20Sopenharmony_ci	 * and/or CPU from reordering the reads which would potentially
7538c2ecf20Sopenharmony_ci	 * result in reading stale values.
7548c2ecf20Sopenharmony_ci	 */
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci	rmb();
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_ci}
7598c2ecf20Sopenharmony_ci
7608c2ecf20Sopenharmony_ci/*
7618c2ecf20Sopenharmony_ci * Lunmap table entry for scsi vnics
7628c2ecf20Sopenharmony_ci */
7638c2ecf20Sopenharmony_ci#define FCPIO_LUNMAP_TABLE_SIZE     256
7648c2ecf20Sopenharmony_ci#define FCPIO_FLAGS_LUNMAP_VALID    0x80
7658c2ecf20Sopenharmony_ci#define FCPIO_FLAGS_BOOT            0x01
7668c2ecf20Sopenharmony_cistruct fcpio_lunmap_entry {
7678c2ecf20Sopenharmony_ci	u8    bus;
7688c2ecf20Sopenharmony_ci	u8    target;
7698c2ecf20Sopenharmony_ci	u8    lun;
7708c2ecf20Sopenharmony_ci	u8    path_cnt;
7718c2ecf20Sopenharmony_ci	u16   flags;
7728c2ecf20Sopenharmony_ci	u16   update_cnt;
7738c2ecf20Sopenharmony_ci};
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_cistruct fcpio_lunmap_tbl {
7768c2ecf20Sopenharmony_ci	u32                   update_cnt;
7778c2ecf20Sopenharmony_ci	struct fcpio_lunmap_entry   lunmaps[FCPIO_LUNMAP_TABLE_SIZE];
7788c2ecf20Sopenharmony_ci};
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_ci#endif /* _FCPIO_H_ */
781