diff options
author | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-26 09:29:46 +0000 |
---|---|---|
committer | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-26 09:29:46 +0000 |
commit | 501793fad4084c43828ba2f4e2d9355d29abe9f7 (patch) | |
tree | ac49b115a60da8a6d1fd0ae42eff53c29d113acb /MdeModulePkg/Universal | |
parent | 8f5e3a12a9dc5f5b782204ee655db6cb22e25ea5 (diff) | |
download | edk2-platforms-501793fad4084c43828ba2f4e2d9355d29abe9f7.tar.xz |
Adopt new IPv4/IPv6 device path for network modules.
Signed-off-by: tye
Reviewed-by: niruiyu
Adopt SasEx and new IPv6 device path for DevicePathDxe driver.
Signed-off-by: niruiyu
Reviewed-by: erictian
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12574 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
7 files changed, 212 insertions, 10 deletions
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c index bc9af70135..11f5c159df 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c @@ -1685,6 +1685,74 @@ DevPathFromTextSAS ( }
/**
+ Converts a text device path node to Serial Attached SCSI Ex device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextSasEx (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *AddressStr;
+ CHAR16 *LunStr;
+ CHAR16 *RTPStr;
+ CHAR16 *SASSATAStr;
+ CHAR16 *LocationStr;
+ CHAR16 *ConnectStr;
+ CHAR16 *DriveBayStr;
+ UINT16 Info;
+ SASEX_DEVICE_PATH *SasEx;
+
+ AddressStr = GetNextParamStr (&TextDeviceNode);
+ LunStr = GetNextParamStr (&TextDeviceNode);
+ RTPStr = GetNextParamStr (&TextDeviceNode);
+ SASSATAStr = GetNextParamStr (&TextDeviceNode);
+ LocationStr = GetNextParamStr (&TextDeviceNode);
+ ConnectStr = GetNextParamStr (&TextDeviceNode);
+ DriveBayStr = GetNextParamStr (&TextDeviceNode);
+ Info = 0x0000;
+ SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_SASEX_DP,
+ (UINT16) sizeof (SASEX_DEVICE_PATH)
+ );
+
+ Strtoi64 (AddressStr, (UINT64 *) &SasEx->SasAddress);
+ Strtoi64 (LunStr, (UINT64 *) &SasEx->Lun);
+ *(UINT64 *) &SasEx->SasAddress = SwapBytes64 (*(UINT64 *) &SasEx->SasAddress);
+ *(UINT64 *) &SasEx->Lun = SwapBytes64 (*(UINT64 *) &SasEx->Lun);
+ SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
+ if (StrCmp (SASSATAStr, L"NoTopology") != 0) {
+ if (StrCmp (DriveBayStr, L"0") == 0) {
+ Info |= 0x0001;
+ } else {
+ Info |= 0x0002;
+ Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));
+ }
+
+ if (StrCmp (SASSATAStr, L"SATA") == 0) {
+ Info |= 0x0010;
+ }
+
+ if (StrCmp (LocationStr, L"External") == 0) {
+ Info |= 0x0020;
+ }
+
+ if (StrCmp (ConnectStr, L"Expanded") == 0) {
+ Info |= 0x0040;
+ }
+ }
+
+ SasEx->DeviceTopology = Info;
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;
+}
+
+/**
Converts a text device path node to Debug Port device path structure.
@param TextDeviceNode The input Text device path node.
@@ -1843,12 +1911,16 @@ DevPathFromTextIPv6 ( CHAR16 *ProtocolStr;
CHAR16 *TypeStr;
CHAR16 *LocalIPStr;
+ CHAR16 *GatewayIPStr;
+ CHAR16 *PrefixLengthStr;
IPv6_DEVICE_PATH *IPv6;
RemoteIPStr = GetNextParamStr (&TextDeviceNode);
ProtocolStr = GetNextParamStr (&TextDeviceNode);
TypeStr = GetNextParamStr (&TextDeviceNode);
LocalIPStr = GetNextParamStr (&TextDeviceNode);
+ PrefixLengthStr = GetNextParamStr (&TextDeviceNode);
+ GatewayIPStr = GetNextParamStr (&TextDeviceNode);
IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_IPv6_DP,
@@ -1858,12 +1930,21 @@ DevPathFromTextIPv6 ( StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);
IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
if (StrCmp (TypeStr, L"Static") == 0) {
- IPv6->StaticIpAddress = TRUE;
+ IPv6->IpAddressOrigin = 0;
+ } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {
+ IPv6->IpAddressOrigin = 1;
} else {
- IPv6->StaticIpAddress = FALSE;
+ IPv6->IpAddressOrigin = 2;
}
StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);
+ if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {
+ StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);
+ IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);
+ } else {
+ ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));
+ IPv6->PrefixLength = 0;
+ }
IPv6->LocalPort = 0;
IPv6->RemotePort = 0;
@@ -2895,6 +2976,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] {L"VenUtf8", DevPathFromTextVenUtf8},
{L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},
{L"SAS", DevPathFromTextSAS},
+ {L"SasEx", DevPathFromTextSasEx},
{L"DebugPort", DevPathFromTextDebugPort},
{L"MAC", DevPathFromTextMAC},
{L"IPv4", DevPathFromTextIPv4},
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c index d7cff207fe..2cfd6730d2 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c @@ -654,6 +654,66 @@ DevPathToTextFibreEx ( }
/**
+ Converts a Sas Ex device path structure to its string representative.
+
+ @param Str The string representative of input device.
+ @param DevPath The input device path structure.
+ @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
+ of the display node is used, where applicable. If DisplayOnly
+ is FALSE, then the longer text representation of the display node
+ is used.
+ @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
+ representation for a device node can be used, where applicable.
+
+**/
+VOID
+DevPathToTextSasEx (
+ IN OUT POOL_PRINT *Str,
+ IN VOID *DevPath,
+ IN BOOLEAN DisplayOnly,
+ IN BOOLEAN AllowShortcuts
+ )
+{
+ SASEX_DEVICE_PATH *SasEx;
+ UINTN Index;
+
+ SasEx = DevPath;
+ CatPrint (Str, L"SasEx(0x");
+
+ for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {
+ CatPrint (Str, L"%02x", SasEx->SasAddress[Index]);
+ }
+ CatPrint (Str, L",0x");
+ for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {
+ CatPrint (Str, L"%02x", SasEx->Lun[Index]);
+ }
+ CatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort);
+
+ if ((SasEx->DeviceTopology & 0x0f) == 0) {
+ CatPrint (Str, L"NoTopology,0,0,0,");
+ } else if (((SasEx->DeviceTopology & 0x0f) == 1) || ((SasEx->DeviceTopology & 0x0f) == 2)) {
+ CatPrint (
+ Str,
+ L"%s,%s,%s,",
+ ((SasEx->DeviceTopology & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",
+ ((SasEx->DeviceTopology & (0x1 << 5)) != 0) ? L"External" : L"Internal",
+ ((SasEx->DeviceTopology & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"
+ );
+ if ((SasEx->DeviceTopology & 0x0f) == 1) {
+ CatPrint (Str, L"0,");
+ } else {
+ CatPrint (Str, L"0x%x,", (SasEx->DeviceTopology >> 8) & 0xff);
+ }
+ } else {
+ CatPrint (Str, L"0,0,0,0,");
+ }
+
+ CatPrint (Str, L")");
+ return ;
+
+}
+
+/**
Converts a 1394 device path structure to its string representative.
@param Str The string representative of input device.
@@ -1205,10 +1265,21 @@ DevPathToTextIPv6 ( IPDevPath->Protocol
);
+ switch (IPDevPath->IpAddressOrigin) {
+ case 0:
+ CatPrint (Str, L",Static");
+ break;
+ case 1:
+ CatPrint (Str, L",StatelessAutoConfigure");
+ break;
+ default:
+ CatPrint (Str, L",StatefulAutoConfigure");
+ break;
+ }
+
CatPrint (
Str,
- L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
- IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
+ L",%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
IPDevPath->LocalIpAddress.Addr[0],
IPDevPath->LocalIpAddress.Addr[1],
IPDevPath->LocalIpAddress.Addr[2],
@@ -1226,6 +1297,31 @@ DevPathToTextIPv6 ( IPDevPath->LocalIpAddress.Addr[14],
IPDevPath->LocalIpAddress.Addr[15]
);
+
+ if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {
+ CatPrint (
+ Str,
+ L",0x%x,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
+ IPDevPath->PrefixLength,
+ IPDevPath->GatewayIpAddress.Addr[0],
+ IPDevPath->GatewayIpAddress.Addr[1],
+ IPDevPath->GatewayIpAddress.Addr[2],
+ IPDevPath->GatewayIpAddress.Addr[3],
+ IPDevPath->GatewayIpAddress.Addr[4],
+ IPDevPath->GatewayIpAddress.Addr[5],
+ IPDevPath->GatewayIpAddress.Addr[6],
+ IPDevPath->GatewayIpAddress.Addr[7],
+ IPDevPath->GatewayIpAddress.Addr[8],
+ IPDevPath->GatewayIpAddress.Addr[9],
+ IPDevPath->GatewayIpAddress.Addr[10],
+ IPDevPath->GatewayIpAddress.Addr[11],
+ IPDevPath->GatewayIpAddress.Addr[12],
+ IPDevPath->GatewayIpAddress.Addr[13],
+ IPDevPath->GatewayIpAddress.Addr[14],
+ IPDevPath->GatewayIpAddress.Addr[15]
+ );
+ }
+ CatPrint (Str, L")");
}
/**
@@ -1790,6 +1886,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},
{MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},
{MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx},
+ {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx},
{MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},
{MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},
{MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h index 59d514fe18..f6a64e56da 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h @@ -41,9 +41,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
UINT8 CHAPType;
- CHAR8 CHAPName[ISCSI_CHAP_NAME_MAX_LEN];
+ CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
- CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];
+ CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
} ISCSI_CHAP_AUTH_CONFIG_NVDATA;
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h index 85ad3d173e..7c2e4e65fa 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h @@ -73,6 +73,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define ISCSI_CHAP_SECRET_STORAGE 17
#define ISCSI_CHAP_NAME_MAX_LEN 126
+#define ISCSI_CHAP_NAME_STORAGE 127
#define ISID_CONFIGURABLE_MIN_LEN 6
#define ISID_CONFIGURABLE_MAX_LEN 12
@@ -96,9 +97,9 @@ typedef struct { UINT8 TargetInfoFromDhcp;
UINT8 CHAPType;
- CHAR16 CHAPName[ISCSI_CHAP_NAME_MAX_LEN];
+ CHAR16 CHAPName[ISCSI_CHAP_NAME_STORAGE];
CHAR16 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
- CHAR16 ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];
+ CHAR16 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
CHAR16 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
CHAR16 IsId[ISID_CONFIGURABLE_STORAGE];
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index 840692b45d..5341e5a01e 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -757,7 +757,19 @@ IScsiGetTcpConnDevicePath ( ) {
DPathNode->Ipv4.LocalPort = 0;
- DPathNode->Ipv4.StaticIpAddress = (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp);
+ DPathNode->Ipv4.StaticIpAddress =
+ (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp);
+
+ IP4_COPY_ADDRESS (
+ &DPathNode->Ipv4.GatewayIpAddress,
+ &Session->ConfigData.NvData.Gateway
+ );
+
+ IP4_COPY_ADDRESS (
+ &DPathNode->Ipv4.SubnetMask,
+ &Session->ConfigData.NvData.SubnetMask
+ );
+
break;
}
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c index 3836053d93..331f9d8d22 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c @@ -693,6 +693,14 @@ IScsiProcessLoginRsp ( if ((Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION) && (Conn->CHAPStep == ISCSI_CHAP_INITIAL)) {
//
+ // If the Login Request is a leading Login Request, the target MUST use
+ // the value presented in CmdSN as the target value for ExpCmdSN.
+ //
+ if ((Session->State == SESSION_STATE_FREE) && (Session->CmdSN != LoginRsp->ExpCmdSN)) {
+ return EFI_PROTOCOL_ERROR;
+ }
+
+ //
// It's the initial Login Response, initialize the local ExpStatSN, MaxCmdSN
// and ExpCmdSN.
//
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c index 2ed3c254f3..b3591aa7df 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c @@ -1,7 +1,7 @@ /** @file
Misc support routines for tcp.
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1115,6 +1115,8 @@ TcpInstallDevicePath ( Tcb->UseDefaultAddr
);
+ IP4_COPY_ADDRESS (&Ip4DPathNode.SubnetMask, &Tcb->SubnetMask);
+
Sock->DevicePath = AppendDevicePathNode (
Sock->ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &Ip4DPathNode
|