mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
wiiu: Network optimisations - WINSCALE, TCP sACK, large buffers
See code sample in https://github.com/devkitPro/wut/issues/169 and
2430789406/src/net.c (L88)
This commit is contained in:
parent
6521bfcdc1
commit
e5553bde4e
@ -158,6 +158,11 @@ static INLINE bool isagain(int bytes)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIIU
|
||||||
|
#define WIIU_RCVBUF (128 * 2 * 1024)
|
||||||
|
#define WIIU_SNDBUF (128 * 2 * 1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#define socklen_t int
|
#define socklen_t int
|
||||||
|
|
||||||
|
@ -264,6 +264,25 @@ void freeaddrinfo_retro(struct addrinfo *res)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WIIU)
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
static OSThread wiiu_net_cmpt_thread;
|
||||||
|
static void wiiu_net_cmpt_thread_cleanup(OSThread *thread, void *stack) {
|
||||||
|
free(stack);
|
||||||
|
}
|
||||||
|
static int wiiu_net_cmpt_thread_entry(int argc, const char** argv) {
|
||||||
|
const int buf_size = WIIU_RCVBUF + WIIU_SNDBUF;
|
||||||
|
void* buf = memalign(128, buf_size);
|
||||||
|
if (!buf) return -1;
|
||||||
|
|
||||||
|
somemopt(1, buf, buf_size, 0);
|
||||||
|
|
||||||
|
free(buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* network_init:
|
* network_init:
|
||||||
*
|
*
|
||||||
@ -332,6 +351,18 @@ bool network_init(void)
|
|||||||
return false;
|
return false;
|
||||||
#elif defined(WIIU)
|
#elif defined(WIIU)
|
||||||
socket_lib_init();
|
socket_lib_init();
|
||||||
|
|
||||||
|
const int stack_size = 4096;
|
||||||
|
void* stack = malloc(stack_size);
|
||||||
|
if (stack && OSCreateThread(&wiiu_net_cmpt_thread,
|
||||||
|
wiiu_net_cmpt_thread_entry, 0, NULL, stack+stack_size, stack_size,
|
||||||
|
3, OS_THREAD_ATTRIB_AFFINITY_ANY)) {
|
||||||
|
|
||||||
|
OSSetThreadName(&wiiu_net_cmpt_thread, "Network compat thread");
|
||||||
|
OSSetThreadDeallocator(&wiiu_net_cmpt_thread,
|
||||||
|
wiiu_net_cmpt_thread_cleanup);
|
||||||
|
OSResumeThread(&wiiu_net_cmpt_thread);
|
||||||
|
}
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
_net_compat_net_memory = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE);
|
_net_compat_net_memory = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE);
|
||||||
if (!_net_compat_net_memory)
|
if (!_net_compat_net_memory)
|
||||||
|
@ -256,6 +256,20 @@ int socket_connect(int fd, void *data, bool timeout_enable)
|
|||||||
|
|
||||||
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout);
|
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(WIIU)
|
||||||
|
int op = 1;
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_WINSCALE, &op, sizeof(op));
|
||||||
|
if (addr->ai_socktype == SOCK_STREAM) {
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_TCPSACK, &op, sizeof(op));
|
||||||
|
|
||||||
|
setsockopt(fd, SOL_SOCKET, 0x10000, &op, sizeof(op));
|
||||||
|
int recvsz = WIIU_RCVBUF;
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &recvsz, sizeof(recvsz));
|
||||||
|
int sendsz = WIIU_SNDBUF;
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sendsz, sizeof(sendsz));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return connect(fd, addr->ai_addr, addr->ai_addrlen);
|
return connect(fd, addr->ai_addr, addr->ai_addrlen);
|
||||||
|
@ -21,6 +21,10 @@ extern "C" {
|
|||||||
/* #define MSG_DONTWAIT 0x0004 */
|
/* #define MSG_DONTWAIT 0x0004 */
|
||||||
|
|
||||||
#define SO_REUSEADDR 0x0004
|
#define SO_REUSEADDR 0x0004
|
||||||
|
#define SO_WINSCALE 0x0400
|
||||||
|
#define SO_TCPSACK 0x0200
|
||||||
|
#define SO_SNDBUF 0x1001
|
||||||
|
#define SO_RCVBUF 0x1002
|
||||||
#define SO_NBIO 0x1014
|
#define SO_NBIO 0x1014
|
||||||
#define SO_NONBLOCK 0x1016
|
#define SO_NONBLOCK 0x1016
|
||||||
|
|
||||||
@ -70,6 +74,7 @@ int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t
|
|||||||
int shutdown(int sockfd, int how);
|
int shutdown(int sockfd, int how);
|
||||||
int socket(int domain, int type, int protocol);
|
int socket(int domain, int type, int protocol);
|
||||||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
|
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
|
||||||
|
int somemopt (int req_type, char* mem, unsigned int memlen, int flags);
|
||||||
|
|
||||||
int socketlasterr(void);
|
int socketlasterr(void);
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ typedef struct
|
|||||||
|
|
||||||
#define OS_THREAD_TAG 0x74487244u
|
#define OS_THREAD_TAG 0x74487244u
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
typedef struct OSThread
|
typedef struct __attribute__ ((aligned (8))) OSThread
|
||||||
{
|
{
|
||||||
OSContext context;
|
OSContext context;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ IMPORT(OSIsThreadTerminated);
|
|||||||
IMPORT(OSSetThreadPriority);
|
IMPORT(OSSetThreadPriority);
|
||||||
IMPORT(OSCreateThread);
|
IMPORT(OSCreateThread);
|
||||||
IMPORT(OSSetThreadCleanupCallback);
|
IMPORT(OSSetThreadCleanupCallback);
|
||||||
|
IMPORT(OSSetThreadDeallocator);
|
||||||
IMPORT(OSResumeThread);
|
IMPORT(OSResumeThread);
|
||||||
IMPORT(OSIsThreadSuspended);
|
IMPORT(OSIsThreadSuspended);
|
||||||
IMPORT(OSSuspendThread);
|
IMPORT(OSSuspendThread);
|
||||||
@ -39,6 +40,7 @@ IMPORT(OSGetCurrentThread);
|
|||||||
IMPORT(OSExitThread);
|
IMPORT(OSExitThread);
|
||||||
IMPORT(OSJoinThread);
|
IMPORT(OSJoinThread);
|
||||||
IMPORT(OSYieldThread);
|
IMPORT(OSYieldThread);
|
||||||
|
IMPORT(OSSetThreadName);
|
||||||
IMPORT(OSGetCoreId);
|
IMPORT(OSGetCoreId);
|
||||||
IMPORT(OSIsMainCore);
|
IMPORT(OSIsMainCore);
|
||||||
IMPORT(OSGetSystemTime);
|
IMPORT(OSGetSystemTime);
|
||||||
@ -153,6 +155,12 @@ IMPORT(socketlasterr);
|
|||||||
|
|
||||||
IMPORT_END();
|
IMPORT_END();
|
||||||
|
|
||||||
|
IMPORT_BEGIN(nn_nets2);
|
||||||
|
|
||||||
|
IMPORT(somemopt);
|
||||||
|
|
||||||
|
IMPORT_END();
|
||||||
|
|
||||||
/* gx2 */
|
/* gx2 */
|
||||||
IMPORT_BEGIN(gx2);
|
IMPORT_BEGIN(gx2);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user