2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
32 #ifndef _VNIC_DATA_H_
\r
33 #define _VNIC_DATA_H_
\r
35 #include "vnic_trailer.h"
\r
37 typedef struct RdmaDest {
\r
38 LIST_ENTRY listPtrs;
\r
40 NDIS_PACKET *p_packet;
\r
44 struct ViportTrailer *pTrailer;
\r
47 typedef struct BufferPoolEntry {
\r
48 uint64_t remoteAddr;
\r
51 } BufferPoolEntry_t;
\r
53 typedef struct RecvPool {
\r
56 uint32_t eiocPoolSz;
\r
57 uint32_t eiocRdmaRkey;
\r
58 uint64_t eiocRdmaAddr;
\r
59 uint32_t nextFullBuf;
\r
60 uint32_t nextFreeBuf;
\r
61 uint32_t numFreeBufs;
\r
62 uint32_t numPostedBufs;
\r
63 uint32_t szFreeBundle;
\r
65 BufferPoolEntry_t *bufPool;
\r
66 RdmaDest_t *pRecvBufs;
\r
67 LIST_ENTRY availRecvBufs;
\r
68 NDIS_PACKET **recv_pkt_array;
\r
71 typedef struct XmitPool {
\r
74 uint32_t notifyCount;
\r
75 uint32_t notifyBundle;
\r
76 uint32_t nextXmitBuf;
\r
77 uint32_t lastCompBuf;
\r
78 uint32_t numXmitBufs;
\r
79 uint32_t nextXmitPool;
\r
81 uint32_t kickByteCount;
\r
82 uint32_t kickBundle;
\r
83 uint32_t kickByteBundle;
\r
84 BOOLEAN needBuffers;
\r
88 BufferPoolEntry_t *bufPool;
\r
89 RdmaIo_t *pXmitBufs;
\r
92 typedef struct Data {
\r
93 struct _viport *p_viport;
\r
94 DataConfig_t *p_conf;
\r
95 IbRegion_t *p_phy_region;
\r
97 IbRegion_t rbuf_region;
\r
99 uint8_t *pLocalStorage;
\r
100 uint32_t localStorageSz;
\r
101 uint8_t *p_recv_bufs;
\r
102 uint32_t recv_bufs_sz;
\r
103 Inic_RecvPoolConfig_t hostPoolParms;
\r
104 Inic_RecvPoolConfig_t eiocPoolParms;
\r
105 RecvPool_t recvPool;
\r
106 XmitPool_t xmitPool;
\r
107 RdmaIo_t freeBufsIo;
\r
109 LIST_ENTRY recvIos;
\r
110 KSPIN_LOCK recvIosLock;
\r
111 KSPIN_LOCK xmitBufLock;
\r
112 volatile LONG kickTimerOn;
\r
114 cl_timer_t kickTimer;
\r
115 NDIS_HANDLE h_recv_pkt_pool;
\r
116 NDIS_HANDLE h_recv_buf_pool;
\r
117 #ifdef VNIC_STATISTIC
\r
121 uint32_t freeBufSends;
\r
122 uint32_t freeBufNum;
\r
123 uint32_t freeBufMin;
\r
124 uint32_t kickRecvs;
\r
126 uint32_t noXmitBufs;
\r
127 uint64_t noXmitBufTime;
\r
129 #endif /* VNIC_STATISTIC */
\r
133 vnic_return_packet(
\r
134 IN NDIS_HANDLE adapter_context,
\r
135 IN NDIS_PACKET* const p_packet );
\r
140 IN struct _viport *pViport );
\r
145 DataConfig_t *p_conf,
\r
163 NDIS_PACKET* const p_pkt );
\r
169 #define data_pathId(pData) (pData)->p_conf->pathId
\r
170 #define data_eiocPool(pData) &(pData)->eiocPoolParms
\r
171 #define data_hostPool(pData) &(pData)->hostPoolParms
\r
172 #define data_eiocPoolMin(pData) &(pData)->p_conf->eiocMin
\r
173 #define data_hostPoolMin(pData) &(pData)->p_conf->hostMin
\r
174 #define data_eiocPoolMax(pData) &(pData)->p_conf->eiocMax
\r
175 #define data_hostPoolMax(pData) &(pData)->p_conf->hostMax
\r
176 #define data_localPoolAddr(pData) (pData)->xmitPool.rdmaAddr
\r
177 #define data_localPoolRkey(pData) (pData)->xmitPool.rdmaRKey
\r
178 #define data_remotePoolAddr(pData) &(pData)->recvPool.eiocRdmaAddr
\r
179 #define data_remotePoolRkey(pData) &(pData)->recvPool.eiocRdmaRkey
\r
180 #define data_maxMtu(pData) MAX_PAYLOAD(min((pData)->recvPool.bufferSz, (pData)->xmitPool.bufferSz)) - ETH_VLAN_HLEN
\r
181 #define data_len(pData, pTrailer) ntoh16(pTrailer->dataLength)
\r
182 #define data_offset(pData, pTrailer) \
\r
183 pData->recvPool.bufferSz - sizeof(struct ViportTrailer) \
\r
184 - (uint32_t)ROUNDUPP2(data_len(pData, pTrailer), VIPORT_TRAILER_ALIGNMENT) \
\r
185 + pTrailer->dataAlignmentOffset
\r
188 /* The following macros manipulate ring buffer indexes.
\r
189 * The ring buffer size must be a power of 2.
\r
191 #define ADD(index, increment, size) (((index) + (increment))&((size) - 1))
\r
192 #define NEXT(index, size) ADD(index, 1, size)
\r
193 #define INC(index, increment, size) (index) = ADD(index, increment, size)
\r
195 #define VNIC_RECV_FROM_PACKET( P ) \
\r
196 (((RdmaDest_t **)P->MiniportReservedEx)[1])
\r
198 #define VNIC_LIST_ITEM_FROM_PACKET( P ) \
\r
199 ((cl_list_item_t*)P->MiniportReservedEx)
\r
201 #define VNIC_PACKET_FROM_LIST_ITEM( I ) \
\r
202 (PARENT_STRUCT( I, NDIS_PACKET, MiniportReservedEx ))
\r
204 #endif /* _VNIC_DATA_H_ */