Back to home page

OSCL-LXR

 
 

    


0001 /*******************************************************************
0002  * This file is part of the Emulex Linux Device Driver for         *
0003  * Fibre Channel Host Bus Adapters.                                *
0004  * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *
0005  * “Broadcom” refers to Broadcom Inc and/or its subsidiaries.  *
0006  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
0007  * EMULEX and SLI are trademarks of Emulex.                        *
0008  * www.broadcom.com                                                *
0009  *                                                                 *
0010  * This program is free software; you can redistribute it and/or   *
0011  * modify it under the terms of version 2 of the GNU General       *
0012  * Public License as published by the Free Software Foundation.    *
0013  * This program is distributed in the hope that it will be useful. *
0014  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
0015  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
0016  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
0017  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
0018  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
0019  * more details, a copy of which can be found in the file COPYING  *
0020  * included with this package.                                     *
0021  *******************************************************************/
0022 
0023 #include <asm/byteorder.h>
0024 
0025 struct lpfc_hba;
0026 #define LPFC_FCP_CDB_LEN 16
0027 
0028 #define list_remove_head(list, entry, type, member)     \
0029     do {                            \
0030     entry = NULL;                       \
0031     if (!list_empty(list)) {                \
0032         entry = list_entry((list)->next, type, member); \
0033         list_del_init(&entry->member);          \
0034     }                           \
0035     } while(0)
0036 
0037 #define list_get_first(list, type, member)          \
0038     (list_empty(list)) ? NULL :             \
0039     list_entry((list)->next, type, member)
0040 
0041 /* per-port data that is allocated in the FC transport for us */
0042 struct lpfc_rport_data {
0043     struct lpfc_nodelist *pnode;    /* Pointer to the node structure. */
0044 };
0045 
0046 struct lpfc_device_id {
0047     struct lpfc_name vport_wwpn;
0048     struct lpfc_name target_wwpn;
0049     uint64_t lun;
0050 };
0051 
0052 struct lpfc_device_data {
0053     struct list_head listentry;
0054     struct lpfc_rport_data *rport_data;
0055     struct lpfc_device_id device_id;
0056     uint8_t priority;
0057     bool oas_enabled;
0058     bool available;
0059 };
0060 
0061 struct fcp_rsp {
0062     uint32_t rspRsvd1;  /* FC Word 0, byte 0:3 */
0063     uint32_t rspRsvd2;  /* FC Word 1, byte 0:3 */
0064 
0065     uint8_t rspStatus0; /* FCP_STATUS byte 0 (reserved) */
0066     uint8_t rspStatus1; /* FCP_STATUS byte 1 (reserved) */
0067     uint8_t rspStatus2; /* FCP_STATUS byte 2 field validity */
0068 #define RSP_LEN_VALID  0x01 /* bit 0 */
0069 #define SNS_LEN_VALID  0x02 /* bit 1 */
0070 #define RESID_OVER     0x04 /* bit 2 */
0071 #define RESID_UNDER    0x08 /* bit 3 */
0072     uint8_t rspStatus3; /* FCP_STATUS byte 3 SCSI status byte */
0073 
0074     uint32_t rspResId;  /* Residual xfer if residual count field set in
0075                    fcpStatus2 */
0076     /* Received in Big Endian format */
0077     uint32_t rspSnsLen; /* Length of sense data in fcpSnsInfo */
0078     /* Received in Big Endian format */
0079     uint32_t rspRspLen; /* Length of FCP response data in fcpRspInfo */
0080     /* Received in Big Endian format */
0081 
0082     uint8_t rspInfo0;   /* FCP_RSP_INFO byte 0 (reserved) */
0083     uint8_t rspInfo1;   /* FCP_RSP_INFO byte 1 (reserved) */
0084     uint8_t rspInfo2;   /* FCP_RSP_INFO byte 2 (reserved) */
0085     uint8_t rspInfo3;   /* FCP_RSP_INFO RSP_CODE byte 3 */
0086 
0087 #define RSP_NO_FAILURE       0x00
0088 #define RSP_DATA_BURST_ERR   0x01
0089 #define RSP_CMD_FIELD_ERR    0x02
0090 #define RSP_RO_MISMATCH_ERR  0x03
0091 #define RSP_TM_NOT_SUPPORTED 0x04   /* Task mgmt function not supported */
0092 #define RSP_TM_NOT_COMPLETED 0x05   /* Task mgmt function not performed */
0093 #define RSP_TM_INVALID_LU    0x09   /* Task mgmt function to invalid LU */
0094 
0095     uint32_t rspInfoRsvd;   /* FCP_RSP_INFO bytes 4-7 (reserved) */
0096 
0097     uint8_t rspSnsInfo[128];
0098 #define SNS_ILLEGAL_REQ 0x05    /* sense key is byte 3 ([2]) */
0099 #define SNSCOD_BADCMD 0x20  /* sense code is byte 13 ([12]) */
0100 };
0101 
0102 struct fcp_cmnd {
0103     struct scsi_lun  fcp_lun;
0104 
0105     uint8_t fcpCntl0;   /* FCP_CNTL byte 0 (reserved) */
0106     uint8_t fcpCntl1;   /* FCP_CNTL byte 1 task codes */
0107 #define  SIMPLE_Q        0x00
0108 #define  HEAD_OF_Q       0x01
0109 #define  ORDERED_Q       0x02
0110 #define  ACA_Q           0x04
0111 #define  UNTAGGED        0x05
0112     uint8_t fcpCntl2;   /* FCP_CTL byte 2 task management codes */
0113 #define  FCP_ABORT_TASK_SET  0x02   /* Bit 1 */
0114 #define  FCP_CLEAR_TASK_SET  0x04   /* bit 2 */
0115 #define  FCP_BUS_RESET       0x08   /* bit 3 */
0116 #define  FCP_LUN_RESET       0x10   /* bit 4 */
0117 #define  FCP_TARGET_RESET    0x20   /* bit 5 */
0118 #define  FCP_CLEAR_ACA       0x40   /* bit 6 */
0119 #define  FCP_TERMINATE_TASK  0x80   /* bit 7 */
0120     uint8_t fcpCntl3;
0121 #define  WRITE_DATA      0x01   /* Bit 0 */
0122 #define  READ_DATA       0x02   /* Bit 1 */
0123 
0124     uint8_t fcpCdb[LPFC_FCP_CDB_LEN]; /* SRB cdb field is copied here */
0125     uint32_t fcpDl;     /* Total transfer length */
0126 
0127 };
0128 
0129 struct lpfc_scsicmd_bkt {
0130     uint32_t cmd_count;
0131 };
0132 
0133 #define LPFC_SCSI_DMA_EXT_SIZE  264
0134 #define LPFC_BPL_SIZE       1024
0135 #define MDAC_DIRECT_CMD     0x22
0136 
0137 #define FIND_FIRST_OAS_LUN  0
0138 #define NO_MORE_OAS_LUN     -1
0139 #define NOT_OAS_ENABLED_LUN NO_MORE_OAS_LUN
0140 
0141 #ifndef FC_PORTSPEED_128GBIT
0142 #define FC_PORTSPEED_128GBIT    0x2000
0143 #endif
0144 
0145 #ifndef FC_PORTSPEED_256GBIT
0146 #define FC_PORTSPEED_256GBIT    0x4000
0147 #endif
0148 
0149 #define TXRDY_PAYLOAD_LEN   12
0150 
0151 /* For sysfs/debugfs tmp string max len */
0152 #define LPFC_MAX_SCSI_INFO_TMP_LEN  79
0153