• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

P_InkBulkIO.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
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  * We are following the convention of the ioctl cmd constants:
00035  *  - the first 8 bits contain the character representing the device
00036  *  - bits 8-15 refer to the ioctl
00037  */
00038 #define INKBIO_IOC ('x' << 8)   /* 'x' to represent 'xx' */
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 /* For ioctl's that are destined to the STREAMS module for getting at q ptrs */
00049 #define INKBIO_REGISTER   1024
00050 
00051 #define INKBIO_MAX_BLOCKS 512
00052 
00053 /* 1500 bytes of data; 100 bytes for header */
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 /* 100 for ethernet and anything else; 20 for ip---every pkt got an ip header */
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  * Describes a block of BulkIO memory
00065  */
00066 struct InkBulkIOBlock
00067 {
00068   void *ptr;                    /* where is it at */
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  * Describes a packet to be sent.  Found after a request header in a request block
00082  */
00083 struct InkBulkIOPkt
00084 {
00085   uint32_t blockID;
00086   /* Set only in the first fragment of a chain.  Contains the size of the packet */
00087   uint32_t pktsize;
00088   /* If the thing is a chain, the size of the fragment */
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  * Format of a sendto request:
00102  *   - sender, receiver: ip/port info.
00103  *   - list of InkBulkIOPkt terminated by a 0xffffffff
00104  */
00105 struct InkBulkIOSendtoRequest
00106 {
00107   /* declarations are done so that things in a req. block are usually 4-byte aligned */
00108   uint16_t pktCount;
00109   struct InkBulkIOAddrInfo src;
00110   struct InkBulkIOAddrInfo dest;
00111 };
00112 
00113 /*
00114  * Format of a split request:
00115  *   - sender: ip/port info. and count of # of receivers; also a boolean that
00116  *      describes if there is a per-receiver specific header that has to be
00117  *      tacked on before each data-payload.
00118  *   - a list of InkBulkIOPkt that describes the payload being split;
00119  *   - a list of tuples <receiver info, {optional InkBulkIOPkt}>
00120  *      terminate list by 0xffffffff
00121  */
00122 
00123 struct InkBulkIOSplitRequest
00124 {
00125   /* declarations are done so that things in a req. block are usually 4-byte
00126    * aligned */
00127   uint16_t recvCount;
00128   struct InkBulkIOAddrInfo src;
00129   uint16_t perDestHeader;       /* boolean */
00130 };
00131 
00132 /*
00133  * Describes a request header, part of a request block
00134  */
00135 struct InkBulkIORequest
00136 {
00137   uint16_t reqType;             /* one of sendto or split */
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  * Purposely, under specify the size; we need to leave space for the "terminating" packet.
00150  * Every block contains at least 1 request.
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  * Requests are just block-ids---the block id points to the inkbio-block
00159  * that describes the request.
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  * There is always 1 req. block and 1 pkt. block.  Next,
00167  * Leave space for 1 "NULL" block for the Address information.
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

Generated by  doxygen 1.7.1