Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #ifndef _INK_BULK_IO_H
00026 #define _INK_BULK_IO_H
00027 
00028 #ifndef _KERNEL_
00029 #include <netinet/ip.h>
00030 #include <netinet/udp.h>
00031 #endif
00032 
00033 
00034 
00035 
00036 
00037 
00038 #define INKBIO_IOC ('x' << 8)   
00039 
00040 #define INKBIO_SEND      (INKBIO_IOC | 1)
00041 #define INKBIO_BALLOC    (INKBIO_IOC | 2)
00042 
00043 #define INKBIO_GET_STATS (INKBIO_IOC | 3)
00044 
00045 #define INKBIO_NOP       (INKBIO_IOC | 7)
00046 #define INKBIO_MEMCPY    (INKBIO_IOC | 8)
00047 
00048 
00049 #define INKBIO_REGISTER   1024
00050 
00051 #define INKBIO_MAX_BLOCKS 512
00052 
00053 
00054 #define INKBIO_MTU_SIZE 1500
00055 #define INKBIO_PKT_SIZE_WITH_UDPHDR (INKBIO_MTU_SIZE - (sizeof(struct ip) + sizeof(struct udphdr)))
00056 #define INKBIO_PKT_SIZE_WO_UDPHDR (INKBIO_MTU_SIZE - sizeof(struct ip))
00057 
00058 #define INKBIO_PKT_HEADER_SIZE (100 + sizeof(struct ip))
00059 #define INKBIO_PKT_FOOTER_SIZE 0
00060 #define INKBIO_BLOCK_SIZE (INKBIO_MTU_SIZE + INKBIO_PKT_HEADER_SIZE + INKBIO_PKT_FOOTER_SIZE)
00061 
00062 #define INKBIO_MAX_UMEM_SIZE (INKBIO_BLOCK_SIZE * INKBIO_MAX_BLOCKS)
00063 
00064 
00065 
00066 struct InkBulkIOBlock
00067 {
00068   void *ptr;                    
00069   uint32_t id;
00070 };
00071 
00072 typedef struct
00073 {
00074   uint32_t nextFreeIdx;
00075   uint32_t numFreeBlocks;
00076   uint32_t freeBlockId[INKBIO_MAX_BLOCKS];
00077 } InkBulkIOFreeBlockInfo_t;
00078 
00079 
00080 
00081 
00082 
00083 struct InkBulkIOPkt
00084 {
00085   uint32_t blockID;
00086   
00087   uint32_t pktsize;
00088   
00089   uint16_t fragsize;
00090   uint16_t inChain:1;
00091   uint16_t reserved:15;
00092 };
00093 
00094 struct InkBulkIOAddrInfo
00095 {
00096   uint32_t ip;
00097   uint16_t port;
00098 };
00099 
00100 
00101 
00102 
00103 
00104 
00105 struct InkBulkIOSendtoRequest
00106 {
00107   
00108   uint16_t pktCount;
00109   struct InkBulkIOAddrInfo src;
00110   struct InkBulkIOAddrInfo dest;
00111 };
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 struct InkBulkIOSplitRequest
00124 {
00125   
00126 
00127   uint16_t recvCount;
00128   struct InkBulkIOAddrInfo src;
00129   uint16_t perDestHeader;       
00130 };
00131 
00132 
00133 
00134 
00135 struct InkBulkIORequest
00136 {
00137   uint16_t reqType;             
00138   union
00139   {
00140     struct InkBulkIOSendtoRequest sendto;
00141     struct InkBulkIOSplitRequest split;
00142   } request;
00143 };
00144 
00145 #define INKBIO_SENDTO_REQUEST 0x0a
00146 #define INKBIO_SPLIT_REQUEST  0xf1
00147 
00148 
00149 
00150 
00151 
00152 #define INKBIO_MAX_PKTS_PER_REQ_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - \
00153                                         (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt))) / \
00154                                        MAX((sizeof (struct InkBulkIORequest)), \
00155                                            (sizeof(struct InkBulkIOPkt))))
00156 
00157 
00158 
00159 
00160 
00161 #define INKBIO_MAX_REQS_PER_REQ_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - sizeof(uint32_t)) / sizeof(uint32_t))
00162 
00163 #define INKBIO_MAX_FRAGS_PER_REQ_BLOCK INKBIO_MAX_PKTS_PER_REQ_BLOCK
00164 
00165 
00166 
00167 
00168 
00169 
00170 #define INKBIO_MAX_SPLIT_WO_HDR_PER_SPLIT_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - \
00171                                         (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) / \
00172                                         (sizeof(struct InkBulkIOAddrInfo)))
00173 
00174 #define INKBIO_MAX_SPLIT_WITH_HDR_PER_SPLIT_BLOCK ((INKBIO_PKT_SIZE_WO_UDPHDR - \
00175                                         (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo))) / \
00176                                         (sizeof(struct InkBulkIOPkt) + sizeof(struct InkBulkIOAddrInfo)))
00177 
00178 
00179 #endif