~henrix/ubuntu/precise/open-vm-dkms/lp-1416003

« back to all changes in this revision

Viewing changes to modules/linux/vmxnet3/vmxnet3_int.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-10-23 15:32:00 UTC
  • mfrom: (1.1.2 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081023153200-gc1bfx89hj35c799
Tags: 2008.10.10-123053-2
* Correcting typo in dh_installinit call.
* Downgrading depends on module-assistant to recommends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2007 VMware, Inc. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation version 2 and no later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
10
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
11
 * for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
15
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
#ifndef _VMXNET3_INT_H
 
20
#define _VMXNET3_INT_H
 
21
 
 
22
#define INCLUDE_ALLOW_MODULE
 
23
#include "includeCheck.h"
 
24
 
 
25
#include "vmxnet3_defs.h"
 
26
 
 
27
typedef struct vmxnet3_cmd_ring {
 
28
   Vmxnet3_GenericDesc *base;
 
29
   uint32               size;
 
30
   uint32               next2fill;
 
31
   uint32               next2comp;
 
32
   uint8                gen;
 
33
   dma_addr_t           basePA;
 
34
} Vmxnet3_CmdRing;
 
35
 
 
36
static INLINE void 
 
37
vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring)
 
38
{
 
39
   ring->next2fill++;
 
40
   if (UNLIKELY(ring->next2fill == ring->size)) {
 
41
      ring->next2fill = 0;
 
42
      VMXNET3_FLIP_RING_GEN(ring->gen);
 
43
   }
 
44
}
 
45
 
 
46
static INLINE void
 
47
vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring)
 
48
{
 
49
   VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size);
 
50
}
 
51
 
 
52
static INLINE int
 
53
vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring)
 
54
{
 
55
   return (ring->next2comp > ring->next2fill ? 0 : ring->size) + 
 
56
           ring->next2comp - ring->next2fill - 1;
 
57
}
 
58
 
 
59
typedef struct vmxnet3_comp_ring {
 
60
   Vmxnet3_GenericDesc *base;
 
61
   uint32               size;
 
62
   uint32               next2proc;
 
63
   uint8                gen;
 
64
   uint8                intr_idx;
 
65
   dma_addr_t           basePA;
 
66
} Vmxnet3_CompRing;
 
67
 
 
68
static INLINE void
 
69
vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring)
 
70
{
 
71
   ring->next2proc++;
 
72
   if (UNLIKELY(ring->next2proc == ring->size)) {
 
73
      ring->next2proc = 0;
 
74
      VMXNET3_FLIP_RING_GEN(ring->gen);
 
75
   }
 
76
}
 
77
 
 
78
struct vmxnet3_tx_data_ring {
 
79
   Vmxnet3_TxDataDesc *base;
 
80
   uint32              size;
 
81
   dma_addr_t          basePA;
 
82
};
 
83
 
 
84
enum vmxnet3_buf_map_type {
 
85
   VMXNET3_MAP_INVALID = 0,
 
86
   VMXNET3_MAP_NONE,
 
87
   VMXNET3_MAP_SINGLE,
 
88
   VMXNET3_MAP_PAGE,
 
89
};
 
90
 
 
91
struct vmxnet3_tx_buf_info {
 
92
   uint32      map_type;
 
93
   uint16      len;
 
94
   uint16      sop_idx;
 
95
   dma_addr_t  dma_addr;
 
96
   struct sk_buff *skb;
 
97
};
 
98
 
 
99
struct vmxnet3_tq_driver_stats {
 
100
   uint64 drop_total;     /* # of pkts dropped by the driver, the 
 
101
                           * counters below track droppings due to 
 
102
                           * different reasons
 
103
                           */
 
104
   uint64 drop_too_many_frags;
 
105
   uint64 drop_oversized_hdr;
 
106
   uint64 drop_hdr_inspect_err; 
 
107
   uint64 drop_tso;
 
108
 
 
109
   uint64 tx_ring_full;
 
110
   uint64 linearized;         /* # of pkts linearized */
 
111
   uint64 copy_skb_header;    /* # of times we have to copy skb header */
 
112
   uint64 oversized_hdr;    
 
113
};
 
114
 
 
115
struct vmxnet3_tx_ctx {
 
116
   Bool   ipv4;
 
117
   Bool   ipv6;
 
118
   uint16 mss;
 
119
   uint32 eth_ip_hdr_size; /* only valid for pkts requesting tso or csum offloading */
 
120
   uint32 l4_hdr_size;     /* only valid if mss != 0 */
 
121
   uint32 copy_size;       /* # of bytes copied into the data ring */
 
122
   Vmxnet3_GenericDesc *sop_txd;
 
123
   Vmxnet3_GenericDesc *eop_txd;
 
124
};
 
125
 
 
126
struct vmxnet3_tx_queue {
 
127
   spinlock_t                      tx_lock;
 
128
   struct vmxnet3_cmd_ring         tx_ring;
 
129
   struct vmxnet3_tx_buf_info     *buf_info;
 
130
   struct vmxnet3_tx_data_ring     data_ring;
 
131
   struct vmxnet3_comp_ring        comp_ring;
 
132
   Vmxnet3_TxQueueCtrl            *shared;
 
133
   struct vmxnet3_tq_driver_stats  stats;
 
134
   Bool                            stopped;   
 
135
   int                             num_stop;  /* # of time queue is stopped */
 
136
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
 
137
 
 
138
enum vmxnet3_rx_buf_type {
 
139
   VMXNET3_RX_BUF_NONE = 0,
 
140
   VMXNET3_RX_BUF_SKB = 1,
 
141
   VMXNET3_RX_BUF_PAGE = 2
 
142
};
 
143
 
 
144
struct vmxnet3_rx_buf_info {
 
145
   enum vmxnet3_rx_buf_type buf_type;
 
146
   uint16     len;
 
147
   union {
 
148
      struct sk_buff *skb;
 
149
      struct page    *page;
 
150
   };
 
151
   dma_addr_t dma_addr;
 
152
};
 
153
 
 
154
struct vmxnet3_rx_ctx {
 
155
   struct sk_buff *skb;
 
156
   uint32 sop_idx;
 
157
};
 
158
 
 
159
struct vmxnet3_rq_driver_stats {
 
160
   uint64 drop_total;
 
161
   uint64 drop_err;
 
162
   uint64 drop_fcs;
 
163
   uint64 rx_buf_alloc_failure;
 
164
};
 
165
 
 
166
struct vmxnet3_rx_queue {
 
167
   struct vmxnet3_cmd_ring   rx_ring[2];
 
168
   struct vmxnet3_comp_ring  comp_ring;
 
169
   struct vmxnet3_rx_ctx     rx_ctx;
 
170
   uint32 qid;            /* rqID in RCD for buffer from 1st ring */
 
171
   uint32 qid2;           /* rqID in RCD for buffer from 2nd ring */
 
172
   uint32 uncommitted[2]; /* # of buffers allocated since last RXPROD update */
 
173
   struct vmxnet3_rx_buf_info     *buf_info[2];
 
174
   Vmxnet3_RxQueueCtrl            *shared;
 
175
   struct vmxnet3_rq_driver_stats  stats;
 
176
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
 
177
 
 
178
#define VMXNET3_LINUX_MAX_MSIX_VECT     1
 
179
 
 
180
struct vmxnet3_intr {
 
181
   enum vmxnet3_intr_mask_mode  mask_mode;
 
182
   enum vmxnet3_intr_type       type;          /* MSI-X, MSI, or INTx? */
 
183
   uint8  num_intrs;                           /* # of intr vectors */
 
184
   uint8  event_intr_idx;                      /* idx of the intr vector for event */
 
185
   uint8  mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */
 
186
#ifdef CONFIG_PCI_MSI
 
187
   struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT];
 
188
#endif
 
189
};
 
190
 
 
191
#define VMXNET3_STATE_BIT_RESETTING   0  
 
192
#define VMXNET3_STATE_BIT_QUIESCED    1  
 
193
struct vmxnet3_adapter {
 
194
   struct vmxnet3_tx_queue        tx_queue;
 
195
   struct vmxnet3_rx_queue        rx_queue;
 
196
#ifdef VMXNET3_NAPI
 
197
   struct napi_struct             napi;
 
198
#endif
 
199
   struct vlan_group             *vlan_grp;
 
200
 
 
201
   struct vmxnet3_intr            intr;
 
202
 
 
203
   struct Vmxnet3_DriverShared   *shared;
 
204
   struct Vmxnet3_PMConf         *pm_conf;
 
205
   struct Vmxnet3_TxQueueDesc    *tqd_start;     /* first tx queue desc */
 
206
   struct Vmxnet3_RxQueueDesc    *rqd_start;     /* first rx queue desc */;
 
207
   struct net_device             *netdev;
 
208
   struct net_device_stats        net_stats;
 
209
   struct pci_dev                *pdev;
 
210
 
 
211
   uint8  *hw_addr0; /* for BAR 0 */
 
212
   uint8  *hw_addr1; /* for BAR 1 */
 
213
 
 
214
   /* feature control */
 
215
   Bool   rxcsum;
 
216
   Bool   lro;
 
217
   Bool   jumbo_frame;
 
218
 
 
219
   /* rx buffer related */
 
220
   unsigned   skb_buf_size;
 
221
   int        rx_buf_per_pkt;  /* only apply to the 1st ring */
 
222
   dma_addr_t shared_pa;
 
223
   dma_addr_t queue_desc_pa;
 
224
 
 
225
   /* Wake-on-LAN */
 
226
   uint32     wol;
 
227
 
 
228
   /* Link speed */
 
229
   uint32     link_speed; /* in mbps */
 
230
 
 
231
   uint64     tx_timeout_count;
 
232
   compat_work work;
 
233
 
 
234
   unsigned long  state;    /* VMXNET3_STATE_BIT_xxx */
 
235
};
 
236
 
 
237
struct vmxnet3_stat_desc {
 
238
   char desc[ETH_GSTRING_LEN];
 
239
   int  offset;
 
240
};
 
241
 
 
242
#define VMXNET3_WRITE_BAR0_REG(adapter, reg, val)  \
 
243
   writel((val), (adapter)->hw_addr0 + (reg))
 
244
#define VMXNET3_READ_BAR0_REG(adapter, reg)        \
 
245
   readl((adapter)->hw_addr0 + (reg))
 
246
 
 
247
#define VMXNET3_WRITE_BAR1_REG(adapter, reg, val)  \
 
248
   writel((val), (adapter)->hw_addr1 + (reg))
 
249
#define VMXNET3_READ_BAR1_REG(adapter, reg)        \
 
250
   readl((adapter)->hw_addr1 + (reg))
 
251
 
 
252
#define VMXNET3_WAKE_QUEUE_THRESHOLD(tq)  (5)
 
253
#define VMXNET3_RX_ALLOC_THRESHOLD(rq, ring_idx, adapter) \
 
254
   ((rq)->rx_ring[ring_idx].size >> 3)
 
255
 
 
256
#define VMXNET3_TX_OK           0
 
257
#define VMXNET3_TX_DROPPED      1
 
258
#define VMXNET3_TX_FULL         2
 
259
 
 
260
#define VMXNET3_GET_ADDR_LO(dma)   ((uint32)(dma))
 
261
#define VMXNET3_GET_ADDR_HI(dma)   ((uint32)(((uint64)(dma)) >> 32))
 
262
 
 
263
/* must be a multiple of VMXNET3_RING_SIZE_ALIGN */
 
264
#define VMXNET3_DEF_TX_RING_SIZE    512
 
265
#define VMXNET3_DEF_RX_RING_SIZE    256
 
266
 
 
267
/* FIXME: what's the right value for this? */
 
268
#define VMXNET3_MAX_ETH_HDR_SIZE    22 
 
269
 
 
270
#define VMXNET3_MAX_SKB_BUF_SIZE    (3*1024)
 
271
#endif