1 /** @file 2 The shared head file for iSCSI driver. 3 4 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #ifndef _ISCSI_IMPL_H_ 16 #define _ISCSI_IMPL_H_ 17 18 #include <Uefi.h> 19 20 #include <IndustryStandard/Dhcp.h> 21 22 #include <Protocol/ComponentName.h> 23 #include <Protocol/ComponentName2.h> 24 #include <Protocol/DriverBinding.h> 25 #include <Protocol/DevicePath.h> 26 #include <Protocol/HiiConfigAccess.h> 27 28 #include <Protocol/Ip6.h> 29 #include <Protocol/Dhcp4.h> 30 #include <Protocol/Dhcp6.h> 31 #include <Protocol/Tcp4.h> 32 #include <Protocol/Tcp6.h> 33 34 #include <Protocol/AuthenticationInfo.h> 35 #include <Protocol/IScsiInitiatorName.h> 36 #include <Protocol/ScsiPassThruExt.h> 37 #include <Protocol/AdapterInformation.h> 38 39 #include <Library/HiiLib.h> 40 #include <Library/UefiHiiServicesLib.h> 41 #include <Library/DevicePathLib.h> 42 #include <Library/DebugLib.h> 43 #include <Library/BaseLib.h> 44 #include <Library/BaseMemoryLib.h> 45 #include <Library/MemoryAllocationLib.h> 46 #include <Library/PrintLib.h> 47 #include <Library/UefiBootServicesTableLib.h> 48 #include <Library/UefiRuntimeServicesTableLib.h> 49 #include <Library/UefiLib.h> 50 #include <Library/DpcLib.h> 51 #include <Library/NetLib.h> 52 #include <Library/TcpIoLib.h> 53 #include <Library/BaseCryptLib.h> 54 55 #include <Guid/MdeModuleHii.h> 56 #include <Guid/EventGroup.h> 57 #include <Guid/Acpi.h> 58 59 #include "IScsiConfigNVDataStruc.h" 60 #include "IScsiDriver.h" 61 #include "IScsiProto.h" 62 #include "IScsiCHAP.h" 63 #include "IScsiDhcp.h" 64 #include "IScsiDhcp6.h" 65 #include "IScsiIbft.h" 66 #include "IScsiMisc.h" 67 #include "IScsiConfig.h" 68 69 #define ISCSI_AUTH_INITIAL 0 70 71 #define ISCSI_SESSION_SIGNATURE SIGNATURE_32 ('I', 'S', 'S', 'N') 72 /// 73 /// 10 seconds 74 /// 75 #define ISCSI_GET_MAPPING_TIMEOUT 100000000U 76 /// 77 /// 3 seconds 78 /// 79 #define ISCSI_WAIT_IPSEC_TIMEOUT 30000000U 80 81 struct _ISCSI_SESSION { 82 UINT32 Signature; 83 84 ISCSI_DRIVER_DATA *Private; 85 ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData; 86 87 UINT8 AuthType; 88 union { 89 ISCSI_CHAP_AUTH_DATA CHAP; 90 } AuthData; 91 92 UINT8 State; 93 94 UINT8 Isid[6]; 95 UINT16 Tsih; 96 97 UINT32 CmdSN; 98 UINT32 ExpCmdSN; 99 UINT32 MaxCmdSN; 100 101 UINT32 InitiatorTaskTag; 102 UINT16 NextCid; 103 104 LIST_ENTRY Conns; 105 UINT32 NumConns; 106 107 LIST_ENTRY TcbList; 108 109 // 110 // Session-wide parameters 111 // 112 UINT16 TargetPortalGroupTag; 113 UINT32 MaxConnections; 114 BOOLEAN InitialR2T; 115 BOOLEAN ImmediateData; 116 UINT32 MaxBurstLength; 117 UINT32 FirstBurstLength; 118 UINT32 DefaultTime2Wait; 119 UINT32 DefaultTime2Retain; 120 UINT16 MaxOutstandingR2T; 121 BOOLEAN DataPDUInOrder; 122 BOOLEAN DataSequenceInOrder; 123 UINT8 ErrorRecoveryLevel; 124 }; 125 126 #define ISCSI_CONNECTION_SIGNATURE SIGNATURE_32 ('I', 'S', 'C', 'N') 127 128 struct _ISCSI_CONNECTION { 129 UINT32 Signature; 130 LIST_ENTRY Link; 131 132 EFI_EVENT TimeoutEvent; 133 134 ISCSI_SESSION *Session; 135 136 UINT8 State; 137 UINT8 CurrentStage; 138 UINT8 NextStage; 139 140 UINT8 AuthStep; 141 142 BOOLEAN PartialReqSent; 143 BOOLEAN PartialRspRcvd; 144 145 BOOLEAN TransitInitiated; 146 BOOLEAN ParamNegotiated; 147 148 UINT16 Cid; 149 UINT32 ExpStatSN; 150 151 // 152 // Queues... 153 // 154 NET_BUF_QUEUE RspQue; 155 156 BOOLEAN Ipv6Flag; 157 TCP_IO TcpIo; 158 159 // 160 // Connection-only parameters. 161 // 162 UINT32 MaxRecvDataSegmentLength; 163 ISCSI_DIGEST_TYPE HeaderDigest; 164 ISCSI_DIGEST_TYPE DataDigest; 165 }; 166 167 #define ISCSI_DRIVER_DATA_SIGNATURE SIGNATURE_32 ('I', 'S', 'D', 'A') 168 169 #define ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU(PassThru) \ 170 CR ( \ 171 PassThru, \ 172 ISCSI_DRIVER_DATA, \ 173 IScsiExtScsiPassThru, \ 174 ISCSI_DRIVER_DATA_SIGNATURE \ 175 ) 176 177 #define ISCSI_DRIVER_DATA_FROM_IDENTIFIER(Identifier) \ 178 CR ( \ 179 Identifier, \ 180 ISCSI_DRIVER_DATA, \ 181 IScsiIdentifier, \ 182 ISCSI_DRIVER_DATA_SIGNATURE \ 183 ) 184 185 struct _ISCSI_DRIVER_DATA { 186 UINT32 Signature; 187 EFI_HANDLE Image; 188 EFI_HANDLE Controller; 189 ISCSI_PRIVATE_PROTOCOL IScsiIdentifier; 190 191 EFI_EVENT ExitBootServiceEvent; 192 193 EFI_EXT_SCSI_PASS_THRU_PROTOCOL IScsiExtScsiPassThru; 194 EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode; 195 EFI_HANDLE ExtScsiPassThruHandle; 196 EFI_DEVICE_PATH_PROTOCOL *DevicePath; 197 EFI_HANDLE ChildHandle; 198 ISCSI_SESSION *Session; 199 }; 200 201 #endif 202