2011-09-14 07:50:12 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Stefan Lankes, Chair for Operating Systems,
|
|
|
|
* RWTH Aachen University
|
2011-09-03 13:29:33 -07:00
|
|
|
*
|
2011-09-14 07:50:12 -07:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-09-03 13:29:33 -07:00
|
|
|
*
|
2011-09-14 07:50:12 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-09-03 13:29:33 -07:00
|
|
|
*
|
2011-09-14 07:50:12 -07:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2011-08-10 08:02:30 +02:00
|
|
|
*
|
2011-09-14 07:50:12 -07:00
|
|
|
* This file is part of MetalSVM.
|
2011-08-10 08:02:30 +02:00
|
|
|
*/
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
#include <metalsvm/stddef.h>
|
|
|
|
#include <metalsvm/stdio.h>
|
|
|
|
#include <metalsvm/time.h>
|
|
|
|
#include <metalsvm/tasks.h>
|
|
|
|
#include <metalsvm/syscall.h>
|
|
|
|
#include <metalsvm/errno.h>
|
2011-08-10 08:02:30 +02:00
|
|
|
|
2012-07-16 21:55:42 +02:00
|
|
|
#include "tests.h"
|
|
|
|
|
2011-10-03 03:52:50 -07:00
|
|
|
#ifdef CONFIG_ROCKCREEK
|
|
|
|
#include <asm/RCCE.h>
|
|
|
|
#include <asm/RCCE_lib.h>
|
|
|
|
#include <asm/SCC_API.h>
|
|
|
|
#endif
|
|
|
|
|
2012-09-10 09:58:47 +02:00
|
|
|
#define USE_SOCKET_BYPASSING 0
|
2011-10-19 04:47:19 -07:00
|
|
|
|
2011-09-16 20:49:13 +02:00
|
|
|
/*
|
2011-10-03 03:52:50 -07:00
|
|
|
* This implements a netio server and client (only TCP version).
|
2011-09-16 20:49:13 +02:00
|
|
|
* The client sends a command word (4 bytes) then a data length word (4 bytes).
|
|
|
|
* If the command is "receive", the server is to consume "data length" bytes into
|
|
|
|
* a circular buffer until the first byte is non-zero, then it is to consume
|
|
|
|
* another command/data pair.
|
|
|
|
* If the command is "send", the server is to send "data length" bytes from a circular
|
|
|
|
* buffer with the first byte being zero, until "some time" (6 seconds in the
|
|
|
|
* current netio131.zip download) has passed and then send one final buffer with
|
|
|
|
* the first byte being non-zero. Then it is to consume another command/data pair.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* See http://www.nwlab.net/art/netio/netio.html to get the netio tool */
|
|
|
|
|
2012-09-17 14:51:10 +02:00
|
|
|
#if (defined(START_NETIO) || defined(START_CHIEFTEST)) && defined(CONFIG_LWIP)
|
2011-10-24 16:23:25 +02:00
|
|
|
#ifdef CONFIG_ROCKCREEK
|
2011-10-19 04:47:19 -07:00
|
|
|
#if USE_SOCKET_BYPASSING // for socket bypassing
|
|
|
|
#include <lwip/opt.h>
|
|
|
|
#undef LWIP_COMPAT_SOCKETS
|
|
|
|
#endif
|
2011-10-24 16:23:25 +02:00
|
|
|
#endif
|
2011-10-19 04:47:19 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
#include <lwip/sockets.h>
|
2011-10-13 15:21:45 -07:00
|
|
|
#include <lwip/err.h>
|
2011-10-19 04:47:19 -07:00
|
|
|
#include <lwip/stats.h>
|
|
|
|
|
2011-10-24 16:23:25 +02:00
|
|
|
#ifdef CONFIG_ROCKCREEK
|
2011-10-19 04:47:19 -07:00
|
|
|
#if USE_SOCKET_BYPASSING // for socket bypassing
|
|
|
|
#include <net/mmnif.h>
|
|
|
|
#undef AF_INET
|
|
|
|
#define AF_INET AF_MMNIF_NET
|
|
|
|
#endif
|
2011-10-24 16:23:25 +02:00
|
|
|
#endif
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t cmd;
|
|
|
|
uint32_t data;
|
|
|
|
} CONTROL;
|
|
|
|
|
|
|
|
#define CMD_QUIT 0
|
|
|
|
#define CMD_C2S 1
|
|
|
|
#define CMD_S2C 2
|
|
|
|
#define CMD_RES 3
|
|
|
|
|
|
|
|
#define CTLSIZE sizeof(CONTROL)
|
2011-10-19 04:47:19 -07:00
|
|
|
#define DEFAULTPORT 0x494F
|
2011-09-14 07:50:12 -07:00
|
|
|
#define TMAXSIZE 65536
|
|
|
|
|
2011-10-20 06:44:53 -07:00
|
|
|
static int tSizes[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767};
|
2011-10-03 03:52:50 -07:00
|
|
|
static size_t ntSizes = sizeof(tSizes) / sizeof(int);
|
2011-09-14 07:50:12 -07:00
|
|
|
static int nPort = DEFAULTPORT;
|
|
|
|
static const int sobufsize = 131072;
|
|
|
|
static struct in_addr addr_local;
|
2011-10-03 03:52:50 -07:00
|
|
|
static struct in_addr addr_server;
|
2011-09-14 07:50:12 -07:00
|
|
|
|
|
|
|
static int send_data(int socket, void *buffer, size_t size, int flags)
|
|
|
|
{
|
2012-02-28 13:20:46 +01:00
|
|
|
ssize_t rc = send(socket, buffer, size, flags);
|
2011-08-10 08:02:30 +02:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
if (rc < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("send failed: %d\n", errno);
|
2011-09-14 07:50:12 -07:00
|
|
|
return -1;
|
|
|
|
}
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
if (rc != size)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
2011-09-03 13:29:33 -07:00
|
|
|
}
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
static int recv_data(int socket, void *buffer, size_t size, int flags)
|
2011-09-03 13:29:33 -07:00
|
|
|
{
|
2012-02-28 13:20:46 +01:00
|
|
|
ssize_t rc = recv(socket, buffer, size, flags);
|
2011-08-10 08:02:30 +02:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
if (rc < 0) {
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("recv failed: %d\n", errno);
|
2011-09-14 07:50:12 -07:00
|
|
|
return -1;
|
|
|
|
}
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
if (rc != size)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
2011-09-03 13:29:33 -07:00
|
|
|
}
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
static char *InitBuffer(size_t nSize)
|
2011-09-03 13:29:33 -07:00
|
|
|
{
|
2011-09-14 07:50:12 -07:00
|
|
|
char *cBuffer = kmalloc(nSize);
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
memset(cBuffer, 0xFF, nSize);
|
|
|
|
cBuffer[0] = 0;
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
return cBuffer;
|
2011-08-10 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
static char *PacketSize(int nSize)
|
2011-08-10 08:02:30 +02:00
|
|
|
{
|
2011-09-14 07:50:12 -07:00
|
|
|
static char szBuffer[64];
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
if ((nSize % 1024) == 0 || (nSize % 1024) == 1023)
|
|
|
|
ksprintf(szBuffer, "%2dk", (nSize + 512) / 1024);
|
|
|
|
else
|
|
|
|
ksprintf(szBuffer, "%d", nSize);
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
return szBuffer;
|
2011-08-10 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
static int TCPServer(void* arg)
|
2011-08-10 08:02:30 +02:00
|
|
|
{
|
2011-09-14 07:50:12 -07:00
|
|
|
char *cBuffer;
|
|
|
|
CONTROL ctl;
|
|
|
|
uint64_t nData;
|
|
|
|
struct sockaddr_in sa_server, sa_client;
|
|
|
|
int server, client;
|
|
|
|
socklen_t length;
|
|
|
|
struct timeval tv;
|
|
|
|
fd_set fds;
|
|
|
|
int rc;
|
|
|
|
int nByte;
|
|
|
|
int err;
|
|
|
|
uint64_t start, end;
|
|
|
|
uint32_t freq = get_cpu_frequency(); /* in MHz */
|
|
|
|
|
|
|
|
if ((cBuffer = InitBuffer(TMAXSIZE)) == NULL) {
|
|
|
|
kprintf("Netio: Not enough memory\n");
|
2011-10-03 03:52:50 -07:00
|
|
|
return -1;
|
2011-09-14 07:50:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((server = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
|
|
|
|
kprintf("socket failed: %d\n", server);
|
|
|
|
kfree(cBuffer, TMAXSIZE);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
setsockopt(server, SOL_SOCKET, SO_RCVBUF, (char *) &sobufsize, sizeof(sobufsize));
|
|
|
|
setsockopt(server, SOL_SOCKET, SO_SNDBUF, (char *) &sobufsize, sizeof(sobufsize));
|
|
|
|
|
2011-10-19 04:47:19 -07:00
|
|
|
memset((char *) &sa_server, 0x00, sizeof(sa_server));
|
2011-09-14 07:50:12 -07:00
|
|
|
sa_server.sin_family = AF_INET;
|
|
|
|
sa_server.sin_port = htons(nPort);
|
|
|
|
sa_server.sin_addr = addr_local;
|
|
|
|
|
|
|
|
if ((err = bind(server, (struct sockaddr *) &sa_server, sizeof(sa_server))) < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("bind failed: %d\n", errno);
|
2011-09-15 03:18:38 -07:00
|
|
|
closesocket(server);
|
2011-09-14 07:50:12 -07:00
|
|
|
kfree(cBuffer, TMAXSIZE);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((err = listen(server, 2)) != 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("listen failed: %d\n", errno);
|
2011-09-15 03:18:38 -07:00
|
|
|
closesocket(server);
|
2011-09-14 07:50:12 -07:00
|
|
|
kfree(cBuffer, TMAXSIZE);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
kprintf("TCP server listening.\n");
|
|
|
|
|
2011-10-20 06:44:53 -07:00
|
|
|
#if !USE_SOCKET_BYPASSING
|
2011-09-14 07:50:12 -07:00
|
|
|
FD_ZERO(&fds);
|
|
|
|
FD_SET(server, &fds);
|
|
|
|
tv.tv_sec = 3600;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
|
|
|
|
if ((rc = select(FD_SETSIZE, &fds, 0, 0, &tv)) < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("select failed: %d\n", errno);
|
2011-09-14 07:50:12 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == 0 || FD_ISSET(server, &fds) == 0)
|
|
|
|
continue;
|
2011-10-19 04:47:19 -07:00
|
|
|
#endif
|
2011-09-14 07:50:12 -07:00
|
|
|
length = sizeof(sa_client);
|
2011-10-19 04:47:19 -07:00
|
|
|
#if USE_SOCKET_BYPASSING
|
|
|
|
// TODO: Bug, not compatible with BSD sockets
|
|
|
|
memcpy(&sa_client, &sa_server, length);
|
|
|
|
#endif
|
|
|
|
if ((client = accept(server, (struct sockaddr *) &sa_client, &length)) < 0) {
|
|
|
|
kprintf("accept faild: %d\n", errno);
|
2011-09-14 07:50:12 -07:00
|
|
|
continue;
|
2011-10-19 04:47:19 -07:00
|
|
|
}
|
2011-09-14 07:50:12 -07:00
|
|
|
|
|
|
|
setsockopt(client, SOL_SOCKET, SO_RCVBUF, (char *) &sobufsize, sizeof(sobufsize));
|
|
|
|
setsockopt(client, SOL_SOCKET, SO_SNDBUF, (char *) &sobufsize, sizeof(sobufsize));
|
|
|
|
|
|
|
|
kprintf("TCP connection established ... ");
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (recv_data(client, (void *) &ctl, CTLSIZE, 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
ctl.cmd = ntohl(ctl.cmd);
|
|
|
|
ctl.data = ntohl(ctl.data);
|
|
|
|
|
|
|
|
if (ctl.cmd == CMD_C2S)
|
|
|
|
{
|
|
|
|
start = rdtsc();
|
|
|
|
|
2011-09-20 16:37:12 +02:00
|
|
|
kprintf("\nReceiving from client, packet size %s ... \n", PacketSize(ctl.data));
|
2011-09-14 07:50:12 -07:00
|
|
|
cBuffer[0] = 0;
|
|
|
|
nData = 0;
|
2011-10-19 04:47:19 -07:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
do {
|
|
|
|
for (nByte = 0; nByte < ctl.data; )
|
|
|
|
{
|
|
|
|
rc = recv(client, cBuffer + nByte, ctl.data - nByte, 0);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("recv failed: %d\n", errno);
|
2011-09-14 07:50:12 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc > 0)
|
|
|
|
nByte += rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nData += ctl.data;
|
|
|
|
} while (cBuffer[0] == 0 && rc > 0);
|
|
|
|
|
|
|
|
end = rdtsc();
|
|
|
|
kprintf("Time to receive %llu bytes: %llu nsec (ticks %llu)\n", nData, ((end-start)*1000ULL)/freq, end-start);
|
|
|
|
} else if (ctl.cmd == CMD_S2C) {
|
|
|
|
start = rdtsc();
|
|
|
|
|
2011-09-20 16:37:12 +02:00
|
|
|
kprintf("\nSending to client, packet size %s ... \n", PacketSize(ctl.data));
|
2011-09-14 07:50:12 -07:00
|
|
|
cBuffer[0] = 0;
|
|
|
|
nData = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
//GenerateRandomData(cBuffer, ctl.data);
|
|
|
|
|
|
|
|
for (nByte = 0; nByte < ctl.data; )
|
|
|
|
{
|
|
|
|
rc = send(client, cBuffer + nByte, ctl.data - nByte, 0);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("send failed: %d\n", errno);
|
2011-09-14 07:50:12 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc > 0)
|
|
|
|
nByte += rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nData += ctl.data;
|
2011-09-15 03:18:38 -07:00
|
|
|
end = rdtsc();
|
|
|
|
} while((end-start)/freq < 6000000ULL /* = 6s */);
|
2011-09-14 07:50:12 -07:00
|
|
|
|
|
|
|
cBuffer[0] = 1;
|
|
|
|
|
|
|
|
if (send_data(client, cBuffer, ctl.data, 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
end = rdtsc();
|
|
|
|
kprintf("Time to send %llu bytes: %llu nsec (ticks %llu)\n", nData, ((end-start)*1000ULL)/freq, end-start);
|
|
|
|
} else /* quit */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
kprintf("\nDone.\n");
|
|
|
|
|
2011-09-15 03:18:38 -07:00
|
|
|
closesocket(client);
|
2011-09-14 07:50:12 -07:00
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-15 03:18:38 -07:00
|
|
|
closesocket(server);
|
2011-09-14 07:50:12 -07:00
|
|
|
kfree(cBuffer, TMAXSIZE);
|
2011-08-10 08:02:30 +02:00
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
return 0;
|
2011-08-10 08:02:30 +02:00
|
|
|
}
|
2011-09-03 13:29:33 -07:00
|
|
|
|
2011-10-03 03:52:50 -07:00
|
|
|
int TCP_Bench(void)
|
|
|
|
{
|
|
|
|
char *cBuffer;
|
|
|
|
CONTROL ctl;
|
2011-10-04 00:00:32 -07:00
|
|
|
uint64_t nData;
|
2011-10-03 03:52:50 -07:00
|
|
|
int i;
|
|
|
|
struct sockaddr_in sa_server;
|
|
|
|
int server;
|
|
|
|
int rc, err;
|
|
|
|
int nByte;
|
|
|
|
uint64_t start, end;
|
|
|
|
uint32_t freq = get_cpu_frequency(); /* in MHz */
|
|
|
|
|
|
|
|
if ((cBuffer = InitBuffer(TMAXSIZE)) == NULL)
|
|
|
|
{
|
|
|
|
kprintf("Netio: Not enough memory\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((server = socket(PF_INET, SOCK_STREAM, 0)) < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("socket failed: %d\n", errno);
|
2011-10-03 03:52:50 -07:00
|
|
|
kfree(cBuffer, TMAXSIZE);
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
setsockopt(server, SOL_SOCKET, SO_RCVBUF, (char *) &sobufsize, sizeof(sobufsize));
|
|
|
|
setsockopt(server, SOL_SOCKET, SO_SNDBUF, (char *) &sobufsize, sizeof(sobufsize));
|
|
|
|
|
|
|
|
sa_server.sin_family = AF_INET;
|
|
|
|
sa_server.sin_port = htons(nPort);
|
|
|
|
sa_server.sin_addr = addr_server;
|
|
|
|
|
|
|
|
if ((err = connect(server, (struct sockaddr *) &sa_server, sizeof(sa_server))) < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("connect failed: %d\n", errno);
|
2011-10-03 03:52:50 -07:00
|
|
|
closesocket(server);
|
|
|
|
kfree(cBuffer, TMAXSIZE);
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
kprintf("\nTCP connection established.\n");
|
|
|
|
|
|
|
|
for (i = 0; i < ntSizes; i++)
|
|
|
|
{
|
|
|
|
kprintf("Packet size %s bytes: ", PacketSize(tSizes[i]));
|
|
|
|
|
|
|
|
/* tell the server we will send it data now */
|
|
|
|
|
|
|
|
ctl.cmd = htonl(CMD_C2S);
|
|
|
|
ctl.data = htonl(tSizes[i]);
|
|
|
|
|
|
|
|
if (send_data(server, (void *) &ctl, CTLSIZE, 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* 1 - Tx test */
|
|
|
|
|
|
|
|
start = rdtsc();
|
|
|
|
nData = 0;
|
|
|
|
cBuffer[0] = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
//GenerateRandomData(cBuffer, tSizes[i]);
|
|
|
|
|
|
|
|
for (nByte = 0; nByte < tSizes[i]; )
|
|
|
|
{
|
|
|
|
rc = send(server, cBuffer + nByte, tSizes[i] - nByte, 0);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("send failed: %d\n", errno);
|
|
|
|
return -1;
|
2011-10-03 03:52:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rc > 0)
|
|
|
|
nByte += rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nData += tSizes[i];
|
|
|
|
end = rdtsc();
|
|
|
|
} while((end-start)/freq < 6000000ULL /* = 6s */);
|
|
|
|
|
2011-10-07 01:48:03 -07:00
|
|
|
kprintf("%llu/100 MBytes/s", ((100ULL*nData)/(1024ULL*1024ULL))/((end-start)/(1000000ULL*freq)));
|
2011-10-03 03:52:50 -07:00
|
|
|
|
|
|
|
kprintf(" Tx, ");
|
|
|
|
|
|
|
|
cBuffer[0] = 1;
|
|
|
|
|
|
|
|
if (send_data(server, cBuffer, tSizes[i], 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* tell the server we expect him to send us data now */
|
|
|
|
|
|
|
|
ctl.cmd = htonl(CMD_S2C);
|
|
|
|
ctl.data = htonl(tSizes[i]);
|
|
|
|
|
|
|
|
if (send_data(server, (void *) &ctl, CTLSIZE, 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* 2 - Rx test */
|
|
|
|
|
|
|
|
start = rdtsc();
|
|
|
|
nData = 0;
|
|
|
|
cBuffer[0] = 0;
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
for (nByte = 0; nByte < tSizes[i]; )
|
|
|
|
{
|
|
|
|
rc = recv(server, cBuffer + nByte, tSizes[i] - nByte, 0);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
{
|
2011-10-13 15:21:45 -07:00
|
|
|
kprintf("recv failed: %d\n", errno);
|
|
|
|
return -1;
|
2011-10-03 03:52:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rc > 0)
|
|
|
|
nByte += rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nData += tSizes[i];
|
|
|
|
} while (cBuffer[0] == 0 && rc > 0);
|
|
|
|
|
|
|
|
end = rdtsc();
|
2011-10-07 01:48:03 -07:00
|
|
|
kprintf("%llu/100 MBytes/s", ((100ULL*nData)/(1024ULL*1024ULL))/((end-start)/(1000000ULL*freq)));
|
2011-10-03 03:52:50 -07:00
|
|
|
|
|
|
|
kprintf(" Rx.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
ctl.cmd = htonl(CMD_QUIT);
|
|
|
|
ctl.data = 0;
|
|
|
|
|
|
|
|
send_data(server, (void *) &ctl, CTLSIZE, 0);
|
|
|
|
|
|
|
|
kprintf("Done.\n");
|
|
|
|
|
|
|
|
closesocket(server);
|
|
|
|
kfree(cBuffer, TMAXSIZE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
int netio_init(void)
|
|
|
|
{
|
2011-10-03 03:52:50 -07:00
|
|
|
int err = 0;
|
|
|
|
|
2011-09-14 07:50:12 -07:00
|
|
|
addr_local.s_addr = INADDR_ANY;
|
2011-10-03 03:52:50 -07:00
|
|
|
//addr_server.s_addr = inet_addr("192.168.28.254");
|
2011-10-06 11:06:54 -07:00
|
|
|
addr_server.s_addr = inet_addr("192.168.0.3");
|
2011-10-03 03:52:50 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_ROCKCREEK
|
2011-10-06 11:06:54 -07:00
|
|
|
if (RCCE_ue() == 2) {
|
2011-10-03 03:52:50 -07:00
|
|
|
err = create_kernel_task(NULL, TCPServer, NULL, NORMAL_PRIO);
|
|
|
|
} else if (RCCE_ue() == 0) {
|
|
|
|
sleep(3);
|
|
|
|
err = TCP_Bench();
|
2011-10-13 15:21:45 -07:00
|
|
|
stats_display();
|
2011-10-03 03:52:50 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
err = create_kernel_task(NULL, TCPServer, NULL, NORMAL_PRIO);
|
|
|
|
#endif
|
2011-08-10 08:02:30 +02:00
|
|
|
|
2011-10-03 03:52:50 -07:00
|
|
|
return err;
|
2011-09-14 07:50:12 -07:00
|
|
|
}
|
2011-08-10 08:02:30 +02:00
|
|
|
#endif
|