Home | History | Annotate | Download | only in ddk
      1 /*
      2  * ws2san.h
      3  *
      4  * WinSock Direct (SAN) support
      5  *
      6  * This file is part of the w32api package.
      7  *
      8  * Contributors:
      9  *   Created by Casper S. Hornstrup <chorns (at) users.sourceforge.net>
     10  *
     11  * THIS SOFTWARE IS NOT COPYRIGHTED
     12  *
     13  * This source code is offered for use in the public domain. You may
     14  * use, modify or distribute it freely.
     15  *
     16  * This code is distributed in the hope that it will be useful but
     17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
     18  * DISCLAIMED. This includes but is not limited to warranties of
     19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     20  *
     21  */
     22 
     23 #pragma once
     24 
     25 #define _WS2SAN_H_
     26 
     27 #ifdef __cplusplus
     28 extern "C" {
     29 #endif
     30 
     31 #define SO_MAX_RDMA_SIZE                  0x700D
     32 #define SO_RDMA_THRESHOLD_SIZE            0x700E
     33 
     34 #define MEM_READ                          1
     35 #define MEM_WRITE                         2
     36 #define MEM_READWRITE                     3
     37 
     38 #define WSAID_REGISTERMEMORY \
     39   {0xC0B422F5, 0xF58C, 0x11d1, {0xAD, 0x6C, 0x00, 0xC0, 0x4F, 0xA3, 0x4A, 0x2D}}
     40 
     41 #define WSAID_DEREGISTERMEMORY \
     42   {0xC0B422F6, 0xF58C, 0x11d1, {0xAD, 0x6C, 0x00, 0xC0, 0x4F, 0xA3, 0x4A, 0x2D}}
     43 
     44 #define WSAID_REGISTERRDMAMEMORY \
     45   {0xC0B422F7, 0xF58C, 0x11d1, {0xAD, 0x6C, 0x00, 0xC0, 0x4F, 0xA3, 0x4A, 0x2D}}
     46 
     47 #define WSAID_DEREGISTERRDMAMEMORY \
     48   {0xC0B422F8, 0xF58C, 0x11d1, {0xAD, 0x6C, 0x00, 0xC0, 0x4F, 0xA3, 0x4A, 0x2D}}
     49 
     50 #define WSAID_RDMAWRITE \
     51   {0xC0B422F9, 0xF58C, 0x11d1, {0xAD, 0x6C, 0x00, 0xC0, 0x4F, 0xA3, 0x4A, 0x2D}}
     52 
     53 #define WSAID_RDMAREAD \
     54   {0xC0B422FA, 0xF58C, 0x11d1, {0xAD, 0x6C, 0x00, 0xC0, 0x4F, 0xA3, 0x4A, 0x2D}}
     55 
     56 #if(_WIN32_WINNT >= 0x0501)
     57 #define WSAID_MEMORYREGISTRATIONCACHECALLBACK \
     58   {0xE5DA4AF8, 0xD824, 0x48CD, {0xA7, 0x99, 0x63, 0x37, 0xA9, 0x8E, 0xD2, 0xAF}}
     59 #endif
     60 
     61 typedef struct _WSPUPCALLTABLEEX {
     62   LPWPUCLOSEEVENT lpWPUCloseEvent;
     63   LPWPUCLOSESOCKETHANDLE lpWPUCloseSocketHandle;
     64   LPWPUCREATEEVENT lpWPUCreateEvent;
     65   LPWPUCREATESOCKETHANDLE lpWPUCreateSocketHandle;
     66   LPWPUFDISSET lpWPUFDIsSet;
     67   LPWPUGETPROVIDERPATH lpWPUGetProviderPath;
     68   LPWPUMODIFYIFSHANDLE lpWPUModifyIFSHandle;
     69   LPWPUPOSTMESSAGE lpWPUPostMessage;
     70   LPWPUQUERYBLOCKINGCALLBACK lpWPUQueryBlockingCallback;
     71   LPWPUQUERYSOCKETHANDLECONTEXT lpWPUQuerySocketHandleContext;
     72   LPWPUQUEUEAPC lpWPUQueueApc;
     73   LPWPURESETEVENT lpWPUResetEvent;
     74   LPWPUSETEVENT lpWPUSetEvent;
     75   LPWPUOPENCURRENTTHREAD lpWPUOpenCurrentThread;
     76   LPWPUCLOSETHREAD lpWPUCloseThread;
     77   LPWPUCOMPLETEOVERLAPPEDREQUEST lpWPUCompleteOverlappedRequest;
     78 } WSPUPCALLTABLEEX, FAR *LPWSPUPCALLTABLEEX;
     79 
     80 typedef struct _WSABUFEX {
     81   u_long len;
     82   char FAR *buf;
     83   HANDLE handle;
     84 } WSABUFEX, FAR * LPWSABUFEX;
     85 
     86 typedef int
     87 (WSPAPI *LPWSPSTARTUPEX)(
     88   IN WORD wVersionRequested,
     89   OUT LPWSPDATA lpWSPData,
     90   IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
     91   IN LPWSPUPCALLTABLEEX lpUpcallTable,
     92   OUT LPWSPPROC_TABLE lpProcTable);
     93 
     94 typedef HANDLE
     95 (WSPAPI *LPFN_WSPREGISTERMEMORY)(
     96   IN SOCKET s,
     97   IN PVOID lpBuffer,
     98   IN DWORD dwBufferLength,
     99   IN DWORD dwFlags,
    100   OUT LPINT lpErrno);
    101 
    102 typedef int
    103 (WSPAPI *LPFN_WSPDEREGISTERMEMORY)(
    104   IN SOCKET s,
    105   IN HANDLE Handle,
    106   OUT LPINT lpErrno);
    107 
    108 typedef int
    109 (WSPAPI *LPFN_WSPREGISTERRDMAMEMORY)(
    110   IN SOCKET s,
    111   IN PVOID lpBuffer,
    112   IN DWORD dwBufferLength,
    113   IN DWORD dwFlags,
    114   OUT LPVOID lpRdmaBufferDescriptor,
    115   IN OUT LPDWORD lpdwDescriptorLength,
    116   OUT LPINT lpErrno);
    117 
    118 typedef int
    119 (WSPAPI *LPFN_WSPDEREGISTERRDMAMEMORY)(
    120   IN SOCKET s,
    121   IN LPVOID lpRdmaBufferDescriptor,
    122   IN DWORD dwDescriptorLength,
    123   OUT LPINT lpErrno);
    124 
    125 typedef int
    126 (WSPAPI *LPFN_WSPRDMAWRITE)(
    127   IN SOCKET s,
    128   IN LPWSABUFEX lpBuffers,
    129   IN DWORD dwBufferCount,
    130   IN LPVOID lpTargetBufferDescriptor,
    131   IN DWORD dwTargetDescriptorLength,
    132   IN DWORD dwTargetBufferOffset,
    133   OUT LPDWORD lpdwNumberOfBytesWritten,
    134   IN DWORD dwFlags,
    135   IN LPWSAOVERLAPPED lpOverlapped OPTIONAL,
    136   IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine OPTIONAL,
    137   IN LPWSATHREADID lpThreadId,
    138   OUT LPINT lpErrno);
    139 
    140 typedef int
    141 (WSPAPI *LPFN_WSPRDMAREAD)(
    142   IN SOCKET s,
    143   IN LPWSABUFEX lpBuffers,
    144   IN DWORD dwBufferCount,
    145   IN LPVOID lpTargetBufferDescriptor,
    146   IN DWORD dwTargetDescriptorLength,
    147   IN DWORD dwTargetBufferOffset,
    148   OUT LPDWORD lpdwNumberOfBytesRead,
    149   IN DWORD dwFlags,
    150   IN LPWSAOVERLAPPED lpOverlapped OPTIONAL,
    151   IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine OPTIONAL,
    152   IN LPWSATHREADID lpThreadId,
    153   OUT LPINT lpErrno);
    154 
    155 #if(_WIN32_WINNT >= 0x0501)
    156 typedef int
    157 (WSPAPI *LPFN_WSPMEMORYREGISTRATIONCACHECALLBACK)(
    158   IN PVOID lpvAddress,
    159   IN SIZE_T Size,
    160   OUT LPINT lpErrno);
    161 #endif
    162 
    163 int
    164 WSPAPI
    165 WSPStartupEx(
    166   IN WORD wVersionRequested,
    167   OUT LPWSPDATA lpWSPData,
    168   IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
    169   IN LPWSPUPCALLTABLEEX lpUpcallTable,
    170   OUT LPWSPPROC_TABLE lpProcTable);
    171 
    172 HANDLE
    173 WSPAPI
    174 WSPRegisterMemory(
    175   IN SOCKET s,
    176   IN PVOID lpBuffer,
    177   IN DWORD dwBufferLength,
    178   IN DWORD dwFlags,
    179   OUT LPINT lpErrno);
    180 
    181 int
    182 WSPAPI
    183 WSPDeregisterMemory(
    184   IN SOCKET s,
    185   IN HANDLE Handle,
    186   OUT LPINT lpErrno);
    187 
    188 int
    189 WSPAPI
    190 WSPRegisterRdmaMemory(
    191   IN SOCKET s,
    192   IN PVOID lpBuffer,
    193   IN DWORD dwBufferLength,
    194   IN DWORD dwFlags,
    195   OUT LPVOID lpRdmaBufferDescriptor,
    196   IN OUT LPDWORD lpdwDescriptorLength,
    197   OUT LPINT lpErrno);
    198 
    199 int
    200 WSPAPI
    201 WSPDeregisterRdmaMemory(
    202   IN SOCKET s,
    203   IN LPVOID lpRdmaBufferDescriptor,
    204   IN DWORD dwDescriptorLength,
    205   OUT LPINT lpErrno);
    206 
    207 int
    208 WSPAPI
    209 WSPRdmaWrite(
    210   IN SOCKET s,
    211   IN LPWSABUFEX lpBuffers,
    212   IN DWORD dwBufferCount,
    213   IN LPVOID lpTargetBufferDescriptor,
    214   IN DWORD dwTargetDescriptorLength,
    215   IN DWORD dwTargetBufferOffset,
    216   OUT LPDWORD lpdwNumberOfBytesWritten,
    217   IN DWORD dwFlags,
    218   IN LPWSAOVERLAPPED lpOverlapped OPTIONAL,
    219   IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine OPTIONAL,
    220   IN LPWSATHREADID lpThreadId,
    221   OUT LPINT lpErrno);
    222 
    223 int
    224 WSPAPI
    225 WSPRdmaRead(
    226   IN SOCKET s,
    227   IN LPWSABUFEX lpBuffers,
    228   IN DWORD dwBufferCount,
    229   IN LPVOID lpTargetBufferDescriptor,
    230   IN DWORD dwTargetDescriptorLength,
    231   IN DWORD dwTargetBufferOffset,
    232   OUT LPDWORD lpdwNumberOfBytesRead,
    233   IN DWORD dwFlags,
    234   IN LPWSAOVERLAPPED lpOverlapped OPTIONAL,
    235   IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine OPTIONAL,
    236   IN LPWSATHREADID lpThreadId,
    237   OUT LPINT lpErrno);
    238 
    239 #if(_WIN32_WINNT >= 0x0501)
    240 int
    241 WSPAPI
    242 WSPMemoryRegistrationCacheCallback(
    243   IN PVOID lpvAddress,
    244   IN SIZE_T Size,
    245   OUT LPINT lpErrno);
    246 #endif
    247 
    248 #ifdef __cplusplus
    249 }
    250 #endif
    251