summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/IScsiDxe/IScsiImpl.h
blob: 1d1a170c0e049e5771fe4fd3b1a111e631272557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/** @file
  The shared head file for iSCSI driver.

Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef _ISCSI_IMPL_H_
#define _ISCSI_IMPL_H_

#include <Uefi.h>

#include <IndustryStandard/Dhcp.h>

#include <Protocol/ComponentName.h>
#include <Protocol/ComponentName2.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/DevicePath.h>
#include <Protocol/HiiConfigAccess.h>

#include <Protocol/Ip6.h>
#include <Protocol/Dhcp4.h>
#include <Protocol/Dhcp6.h>
#include <Protocol/Dns4.h>
#include <Protocol/Dns6.h>
#include <Protocol/Tcp4.h>
#include <Protocol/Tcp6.h>
#include <Protocol/Ip4Config2.h>
#include <Protocol/Ip6Config.h>

#include <Protocol/AuthenticationInfo.h>
#include <Protocol/IScsiInitiatorName.h>
#include <Protocol/ScsiPassThruExt.h>
#include <Protocol/AdapterInformation.h>
#include <Protocol/NetworkInterfaceIdentifier.h>

#include <Library/BaseCryptLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/HiiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/NetLib.h>
#include <Library/PrintLib.h>
#include <Library/SafeIntLib.h>
#include <Library/TcpIoLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiHiiServicesLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

#include <Guid/MdeModuleHii.h>
#include <Guid/EventGroup.h>
#include <Guid/Acpi.h>

#include "IScsiConfigNVDataStruc.h"
#include "IScsiDriver.h"
#include "IScsiProto.h"
#include "IScsiCHAP.h"
#include "IScsiDhcp.h"
#include "IScsiDhcp6.h"

#include "IScsiIbft.h"
#include "IScsiMisc.h"
#include "IScsiDns.h"
#include "IScsiConfig.h"

#define ISCSI_AUTH_INITIAL  0

#define ISCSI_SESSION_SIGNATURE  SIGNATURE_32 ('I', 'S', 'S', 'N')
///
/// 10 seconds
///
#define ISCSI_GET_MAPPING_TIMEOUT  100000000U
///
/// 3 seconds
///
#define ISCSI_WAIT_IPSEC_TIMEOUT  30000000U

struct _ISCSI_SESSION {
  UINT32                         Signature;

  ISCSI_DRIVER_DATA              *Private;
  ISCSI_ATTEMPT_CONFIG_NVDATA    *ConfigData;

  UINT8                          AuthType;
  union {
    ISCSI_CHAP_AUTH_DATA    CHAP;
  } AuthData;

  UINT8                          State;

  UINT8                          Isid[6];
  UINT16                         Tsih;

  UINT32                         CmdSN;
  UINT32                         ExpCmdSN;
  UINT32                         MaxCmdSN;

  UINT32                         InitiatorTaskTag;
  UINT16                         NextCid;

  LIST_ENTRY                     Conns;
  UINT32                         NumConns;

  LIST_ENTRY                     TcbList;

  //
  // Session-wide parameters
  //
  UINT16                         TargetPortalGroupTag;
  UINT32                         MaxConnections;
  BOOLEAN                        InitialR2T;
  BOOLEAN                        ImmediateData;
  UINT32                         MaxBurstLength;
  UINT32                         FirstBurstLength;
  UINT32                         DefaultTime2Wait;
  UINT32                         DefaultTime2Retain;
  UINT16                         MaxOutstandingR2T;
  BOOLEAN                        DataPDUInOrder;
  BOOLEAN                        DataSequenceInOrder;
  UINT8                          ErrorRecoveryLevel;
};

#define ISCSI_CONNECTION_SIGNATURE  SIGNATURE_32 ('I', 'S', 'C', 'N')

struct _ISCSI_CONNECTION {
  UINT32               Signature;
  LIST_ENTRY           Link;

  EFI_EVENT            TimeoutEvent;

  ISCSI_SESSION        *Session;

  UINT8                State;
  UINT8                CurrentStage;
  UINT8                NextStage;

  UINT8                AuthStep;

  BOOLEAN              PartialReqSent;
  BOOLEAN              PartialRspRcvd;

  BOOLEAN              TransitInitiated;
  BOOLEAN              ParamNegotiated;

  UINT16               Cid;
  UINT32               ExpStatSN;

  //
  // Queues...
  //
  NET_BUF_QUEUE        RspQue;

  BOOLEAN              Ipv6Flag;
  TCP_IO               TcpIo;

  //
  // Connection-only parameters.
  //
  UINT32               MaxRecvDataSegmentLength;
  ISCSI_DIGEST_TYPE    HeaderDigest;
  ISCSI_DIGEST_TYPE    DataDigest;
};

#define ISCSI_DRIVER_DATA_SIGNATURE  SIGNATURE_32 ('I', 'S', 'D', 'A')

#define ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU(PassThru) \
  CR ( \
  PassThru, \
  ISCSI_DRIVER_DATA, \
  IScsiExtScsiPassThru, \
  ISCSI_DRIVER_DATA_SIGNATURE \
  )

#define ISCSI_DRIVER_DATA_FROM_IDENTIFIER(Identifier) \
  CR ( \
  Identifier, \
  ISCSI_DRIVER_DATA, \
  IScsiIdentifier, \
  ISCSI_DRIVER_DATA_SIGNATURE \
  )

struct _ISCSI_DRIVER_DATA {
  UINT32                             Signature;
  EFI_HANDLE                         Image;
  EFI_HANDLE                         Controller;
  ISCSI_PRIVATE_PROTOCOL             IScsiIdentifier;

  EFI_EVENT                          ExitBootServiceEvent;

  EFI_EXT_SCSI_PASS_THRU_PROTOCOL    IScsiExtScsiPassThru;
  EFI_EXT_SCSI_PASS_THRU_MODE        ExtScsiPassThruMode;
  EFI_HANDLE                         ExtScsiPassThruHandle;
  EFI_DEVICE_PATH_PROTOCOL           *DevicePath;
  EFI_HANDLE                         ChildHandle;
  ISCSI_SESSION                      *Session;
};

#endif