diff options
author | lpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-09 19:16:44 +0000 |
---|---|---|
committer | lpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-09 19:16:44 +0000 |
commit | 3bdf9aae5f7f4c5f47fc8f807ae4409dfe3bdd58 (patch) | |
tree | 39701f4ccf22d6842122baa1a27d92ff8040375f /StdLib/EfiSocketLib/Socket.c | |
parent | 5709e4e290f80aaf5ed6f1c7a9e3654a14e4ceb9 (diff) | |
download | edk2-3bdf9aae5f7f4c5f47fc8f807ae4409dfe3bdd58.tar.gz edk2-3bdf9aae5f7f4c5f47fc8f807ae4409dfe3bdd58.tar.bz2 edk2-3bdf9aae5f7f4c5f47fc8f807ae4409dfe3bdd58.zip |
Merged socket development branch:
* Fixed bug report (Duane Voth: Python sockets test application not working) by starting the receive operations when a connection is established!
* Increased performance by extending the idle loop into the network stack with the Poll call.
* Added support for TCPv6 (SOCK_STREAM) and UDPv6 (SOCK_DGRAM).
* Added support for getaddrinfo and getnameinfo calls.
* Moved application PCD values into AppPkg
Signed-off-by: lpleahy
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13002 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/EfiSocketLib/Socket.c')
-rw-r--r-- | StdLib/EfiSocketLib/Socket.c | 103 |
1 files changed, 98 insertions, 5 deletions
diff --git a/StdLib/EfiSocketLib/Socket.c b/StdLib/EfiSocketLib/Socket.c index 9c2d2f6844..1805fa629c 100644 --- a/StdLib/EfiSocketLib/Socket.c +++ b/StdLib/EfiSocketLib/Socket.c @@ -481,6 +481,14 @@ CONST ESL_SOCKET_BINDING cEslSocketBinding[] = { 4, // RX buffers
4, // TX buffers
4 }, // TX Oob buffers
+ { L"Tcp6",
+ &gEfiTcp6ServiceBindingProtocolGuid,
+ &gEfiTcp6ProtocolGuid,
+ &mEslTcp6ServiceGuid,
+ OFFSET_OF ( ESL_LAYER, pTcp6List ),
+ 4, // RX buffers
+ 4, // TX buffers
+ 4 }, // TX Oob buffers
{ L"Udp4",
&gEfiUdp4ServiceBindingProtocolGuid,
&gEfiUdp4ProtocolGuid,
@@ -488,6 +496,14 @@ CONST ESL_SOCKET_BINDING cEslSocketBinding[] = { OFFSET_OF ( ESL_LAYER, pUdp4List ),
4, // RX buffers
4, // TX buffers
+ 0 }, // TX Oob buffers
+ { L"Udp6",
+ &gEfiUdp6ServiceBindingProtocolGuid,
+ &gEfiUdp6ProtocolGuid,
+ &mEslUdp6ServiceGuid,
+ OFFSET_OF ( ESL_LAYER, pUdp6List ),
+ 4, // RX buffers
+ 4, // TX buffers
0 } // TX Oob buffers
};
@@ -516,11 +532,11 @@ CONST int cEslAfInetApiSize = DIM ( cEslAfInetApi ); **/
CONST ESL_PROTOCOL_API * cEslAfInet6Api[] = {
NULL, // 0
- NULL, // SOCK_STREAM
- NULL, // SOCK_DGRAM
+ &cEslTcp6Api, // SOCK_STREAM
+ &cEslUdp6Api, // SOCK_DGRAM
NULL, // SOCK_RAW
NULL, // SOCK_RDM
- NULL // SOCK_SEQPACKET
+ &cEslTcp6Api // SOCK_SEQPACKET
};
/**
@@ -603,6 +619,7 @@ EslSocket ( // Validate the domain value
//
if (( AF_INET != domain )
+ && ( AF_INET6 != domain )
&& ( AF_LOCAL != domain )) {
DEBUG (( DEBUG_ERROR | DEBUG_SOCKET,
"ERROR - Invalid domain value\r\n" ));
@@ -1789,6 +1806,11 @@ EslSocketConnect ( if ( EFI_NOT_READY != Status ) {
if ( !EFI_ERROR ( Status )) {
pSocket->State = SOCKET_STATE_CONNECTED;
+
+ //
+ // Start the receive operations
+ //
+ EslSocketRxStart ( pSocket->pPortList );
}
else {
pSocket->State = SOCKET_STATE_BOUND;
@@ -1980,7 +2002,8 @@ EslSocketGetLocalAddress ( //
// Verify the socket state
//
- if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
+ if (( SOCKET_STATE_CONNECTED == pSocket->State )
+ || ( SOCKET_STATE_LISTENING == pSocket->State )) {
//
// Verify the API
//
@@ -3096,7 +3119,7 @@ EslSocketPacketAllocate ( LengthInBytes,
(VOID **)&pPacket );
if ( !EFI_ERROR ( Status )) {
- DEBUG (( DebugFlags | DEBUG_POOL | DEBUG_INIT,
+ DEBUG (( DebugFlags | DEBUG_POOL,
"0x%08x: Allocate pPacket, %d bytes\r\n",
pPacket,
LengthInBytes ));
@@ -3210,6 +3233,7 @@ EslSocketPoll ( short DetectedEvents;
ESL_SOCKET * pSocket;
EFI_STATUS Status;
+ EFI_TPL TplPrevious;
short ValidEvents;
DEBUG (( DEBUG_POLL, "Entering SocketPoll\r\n" ));
@@ -3248,6 +3272,22 @@ EslSocketPoll ( }
else {
//
+ // Synchronize with the socket layer
+ //
+ RAISE_TPL ( TplPrevious, TPL_SOCKETS );
+
+ //
+ // Increase the network performance by extending the
+ // polling (idle) loop down into the LAN driver
+ //
+ EslSocketRxPoll ( pSocket );
+
+ //
+ // Release the socket layer synchronization
+ //
+ RESTORE_TPL ( TplPrevious );
+
+ //
// Check for pending connections
//
if ( 0 != pSocket->FifoDepth ) {
@@ -4367,6 +4407,11 @@ EslSocketReceive ( //
if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
//
+ // Poll the network to increase performance
+ //
+ EslSocketRxPoll ( pSocket );
+
+ //
// Locate the port
//
pPort = pSocket->pPortList;
@@ -4848,6 +4893,49 @@ EslSocketRxComplete ( /**
+ Poll a socket for pending receive activity.
+
+ This routine is called at elivated TPL and extends the idle
+ loop which polls a socket down into the LAN driver layer to
+ determine if there is any receive activity.
+
+ The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit
+ routines call this routine when there is nothing to do.
+
+ @param [in] pSocket Address of an ::EFI_SOCKET structure.
+
+ **/
+VOID
+EslSocketRxPoll (
+ IN ESL_SOCKET * pSocket
+ )
+{
+ ESL_PORT * pPort;
+
+ DEBUG (( DEBUG_POLL, "Entering EslSocketRxPoll\r\n" ));
+
+ //
+ // Increase the network performance by extending the
+ // polling (idle) loop down into the LAN driver
+ //
+ pPort = pSocket->pPortList;
+ while ( NULL != pPort ) {
+ //
+ // Poll the LAN adapter
+ //
+ pPort->pfnRxPoll ( pPort->pProtocol.v );
+
+ //
+ // Locate the next LAN adapter
+ //
+ pPort = pPort->pLinkSocket;
+ }
+
+ DEBUG (( DEBUG_POLL, "Exiting EslSocketRxPoll\r\n" ));
+}
+
+
+/**
Start a receive operation
This routine posts a receive buffer to the network adapter.
@@ -5292,6 +5380,11 @@ EslSocketTransmit ( RAISE_TPL ( TplPrevious, TPL_SOCKETS );
//
+ // Poll the network to increase performance
+ //
+ EslSocketRxPoll ( pSocket );
+
+ //
// Attempt to buffer the packet for transmission
//
Status = pSocket->pApi->pfnTransmit ( pSocket,
|