xref: /openbmc/linux/drivers/scsi/lpfc/lpfc_scsi.h (revision 1775c208)
1dea3101eS /*******************************************************************
2dea3101eS  * This file is part of the Emulex Linux Device Driver for         *
3c44ce173SJames.Smart@Emulex.Com  * Fibre Channel Host Bus Adapters.                                *
4*1775c208SJames Smart  * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
53e21d1cbSJames Smart  * “Broadcom” refers to Broadcom Inc and/or its subsidiaries.  *
651f4ca3cSJames Smart  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
7c44ce173SJames.Smart@Emulex.Com  * EMULEX and SLI are trademarks of Emulex.                        *
8d080abe0SJames Smart  * www.broadcom.com                                                *
9dea3101eS  *                                                                 *
10dea3101eS  * This program is free software; you can redistribute it and/or   *
11c44ce173SJames.Smart@Emulex.Com  * modify it under the terms of version 2 of the GNU General       *
12c44ce173SJames.Smart@Emulex.Com  * Public License as published by the Free Software Foundation.    *
13c44ce173SJames.Smart@Emulex.Com  * This program is distributed in the hope that it will be useful. *
14c44ce173SJames.Smart@Emulex.Com  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
15c44ce173SJames.Smart@Emulex.Com  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
16c44ce173SJames.Smart@Emulex.Com  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
17c44ce173SJames.Smart@Emulex.Com  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18c44ce173SJames.Smart@Emulex.Com  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
19c44ce173SJames.Smart@Emulex.Com  * more details, a copy of which can be found in the file COPYING  *
20c44ce173SJames.Smart@Emulex.Com  * included with this package.                                     *
21dea3101eS  *******************************************************************/
22dea3101eS 
2344456d37SOlaf Hering #include <asm/byteorder.h>
2444456d37SOlaf Hering 
25dea3101eS struct lpfc_hba;
26df9e1b59SJames Smart #define LPFC_FCP_CDB_LEN 16
27dea3101eS 
28dea3101eS #define list_remove_head(list, entry, type, member)		\
29286fc8f8SJames Bottomley 	do {							\
30286fc8f8SJames Bottomley 	entry = NULL;						\
31dea3101eS 	if (!list_empty(list)) {				\
32dea3101eS 		entry = list_entry((list)->next, type, member);	\
33dea3101eS 		list_del_init(&entry->member);			\
34286fc8f8SJames Bottomley 	}							\
35286fc8f8SJames Bottomley 	} while(0)
36dea3101eS 
37dea3101eS #define list_get_first(list, type, member)			\
38dea3101eS 	(list_empty(list)) ? NULL :				\
39dea3101eS 	list_entry((list)->next, type, member)
40dea3101eS 
41dea3101eS /* per-port data that is allocated in the FC transport for us */
42dea3101eS struct lpfc_rport_data {
43dea3101eS 	struct lpfc_nodelist *pnode;	/* Pointer to the node structure. */
44dea3101eS };
45dea3101eS 
461ba981fdSJames Smart struct lpfc_device_id {
471ba981fdSJames Smart 	struct lpfc_name vport_wwpn;
481ba981fdSJames Smart 	struct lpfc_name target_wwpn;
491ba981fdSJames Smart 	uint64_t lun;
501ba981fdSJames Smart };
511ba981fdSJames Smart 
521ba981fdSJames Smart struct lpfc_device_data {
531ba981fdSJames Smart 	struct list_head listentry;
541ba981fdSJames Smart 	struct lpfc_rport_data *rport_data;
551ba981fdSJames Smart 	struct lpfc_device_id device_id;
56c92c841cSJames Smart 	uint8_t priority;
571ba981fdSJames Smart 	bool oas_enabled;
581ba981fdSJames Smart 	bool available;
591ba981fdSJames Smart };
601ba981fdSJames Smart 
61dea3101eS struct fcp_rsp {
62dea3101eS 	uint32_t rspRsvd1;	/* FC Word 0, byte 0:3 */
63dea3101eS 	uint32_t rspRsvd2;	/* FC Word 1, byte 0:3 */
64dea3101eS 
65dea3101eS 	uint8_t rspStatus0;	/* FCP_STATUS byte 0 (reserved) */
66dea3101eS 	uint8_t rspStatus1;	/* FCP_STATUS byte 1 (reserved) */
67dea3101eS 	uint8_t rspStatus2;	/* FCP_STATUS byte 2 field validity */
68dea3101eS #define RSP_LEN_VALID  0x01	/* bit 0 */
69dea3101eS #define SNS_LEN_VALID  0x02	/* bit 1 */
70dea3101eS #define RESID_OVER     0x04	/* bit 2 */
71dea3101eS #define RESID_UNDER    0x08	/* bit 3 */
72dea3101eS 	uint8_t rspStatus3;	/* FCP_STATUS byte 3 SCSI status byte */
73dea3101eS 
74dea3101eS 	uint32_t rspResId;	/* Residual xfer if residual count field set in
75dea3101eS 				   fcpStatus2 */
76dea3101eS 	/* Received in Big Endian format */
77dea3101eS 	uint32_t rspSnsLen;	/* Length of sense data in fcpSnsInfo */
78dea3101eS 	/* Received in Big Endian format */
79dea3101eS 	uint32_t rspRspLen;	/* Length of FCP response data in fcpRspInfo */
80dea3101eS 	/* Received in Big Endian format */
81dea3101eS 
82dea3101eS 	uint8_t rspInfo0;	/* FCP_RSP_INFO byte 0 (reserved) */
83dea3101eS 	uint8_t rspInfo1;	/* FCP_RSP_INFO byte 1 (reserved) */
84dea3101eS 	uint8_t rspInfo2;	/* FCP_RSP_INFO byte 2 (reserved) */
85dea3101eS 	uint8_t rspInfo3;	/* FCP_RSP_INFO RSP_CODE byte 3 */
86dea3101eS 
87dea3101eS #define RSP_NO_FAILURE       0x00
88dea3101eS #define RSP_DATA_BURST_ERR   0x01
89dea3101eS #define RSP_CMD_FIELD_ERR    0x02
90dea3101eS #define RSP_RO_MISMATCH_ERR  0x03
91dea3101eS #define RSP_TM_NOT_SUPPORTED 0x04	/* Task mgmt function not supported */
92dea3101eS #define RSP_TM_NOT_COMPLETED 0x05	/* Task mgmt function not performed */
9353151bbbSJames Smart #define RSP_TM_INVALID_LU    0x09	/* Task mgmt function to invalid LU */
94dea3101eS 
95dea3101eS 	uint32_t rspInfoRsvd;	/* FCP_RSP_INFO bytes 4-7 (reserved) */
96dea3101eS 
97dea3101eS 	uint8_t rspSnsInfo[128];
98dea3101eS #define SNS_ILLEGAL_REQ 0x05	/* sense key is byte 3 ([2]) */
99dea3101eS #define SNSCOD_BADCMD 0x20	/* sense code is byte 13 ([12]) */
100dea3101eS };
101dea3101eS 
102dea3101eS struct fcp_cmnd {
10391886523SJames.Smart@Emulex.Com 	struct scsi_lun  fcp_lun;
104dea3101eS 
105dea3101eS 	uint8_t fcpCntl0;	/* FCP_CNTL byte 0 (reserved) */
106dea3101eS 	uint8_t fcpCntl1;	/* FCP_CNTL byte 1 task codes */
107dea3101eS #define  SIMPLE_Q        0x00
108dea3101eS #define  HEAD_OF_Q       0x01
109dea3101eS #define  ORDERED_Q       0x02
110dea3101eS #define  ACA_Q           0x04
111dea3101eS #define  UNTAGGED        0x05
112dea3101eS 	uint8_t fcpCntl2;	/* FCP_CTL byte 2 task management codes */
113dea3101eS #define  FCP_ABORT_TASK_SET  0x02	/* Bit 1 */
114dea3101eS #define  FCP_CLEAR_TASK_SET  0x04	/* bit 2 */
115dea3101eS #define  FCP_BUS_RESET       0x08	/* bit 3 */
116dea3101eS #define  FCP_LUN_RESET       0x10	/* bit 4 */
117dea3101eS #define  FCP_TARGET_RESET    0x20	/* bit 5 */
118dea3101eS #define  FCP_CLEAR_ACA       0x40	/* bit 6 */
119dea3101eS #define  FCP_TERMINATE_TASK  0x80	/* bit 7 */
120dea3101eS 	uint8_t fcpCntl3;
121dea3101eS #define  WRITE_DATA      0x01	/* Bit 0 */
122dea3101eS #define  READ_DATA       0x02	/* Bit 1 */
123dea3101eS 
124df9e1b59SJames Smart 	uint8_t fcpCdb[LPFC_FCP_CDB_LEN]; /* SRB cdb field is copied here */
125dea3101eS 	uint32_t fcpDl;		/* Total transfer length */
126dea3101eS 
127dea3101eS };
128dea3101eS 
129dea3101eS #define LPFC_SCSI_DMA_EXT_SIZE	264
130dea3101eS #define LPFC_BPL_SIZE		1024
131dea3101eS #define MDAC_DIRECT_CMD		0x22
1321ba981fdSJames Smart 
1331ba981fdSJames Smart #define FIND_FIRST_OAS_LUN	0
1341ba981fdSJames Smart #define NO_MORE_OAS_LUN		-1
1351ba981fdSJames Smart #define NOT_OAS_ENABLED_LUN	NO_MORE_OAS_LUN
1368b0dff14SJames Smart 
1371dc5ec24SJames Smart #ifndef FC_PORTSPEED_128GBIT
1381dc5ec24SJames Smart #define FC_PORTSPEED_128GBIT	0x2000
1391dc5ec24SJames Smart #endif
1401dc5ec24SJames Smart 
141bfc47785SJames Smart #ifndef FC_PORTSPEED_256GBIT
142bfc47785SJames Smart #define FC_PORTSPEED_256GBIT	0x4000
143bfc47785SJames Smart #endif
144bfc47785SJames Smart 
145895427bdSJames Smart #define TXRDY_PAYLOAD_LEN	12
146895427bdSJames Smart 
1474c47efc1SJames Smart /* For sysfs/debugfs tmp string max len */
1484c47efc1SJames Smart #define LPFC_MAX_SCSI_INFO_TMP_LEN	79
1494c47efc1SJames Smart 
150