]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/cnic.h
Merge branch 'x86-uv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[net-next-2.6.git] / drivers / net / cnic.h
CommitLineData
a4636960
MC
1/* cnic.h: Broadcom CNIC core network driver.
2 *
1d9cfc4e 3 * Copyright (c) 2006-2010 Broadcom Corporation
a4636960
MC
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
8 *
9 */
10
11
12#ifndef CNIC_H
13#define CNIC_H
14
15#define KWQ_PAGE_CNT 4
16#define KCQ_PAGE_CNT 16
17
18#define KWQ_CID 24
19#define KCQ_CID 25
20
21/*
22 * krnlq_context definition
23 */
24#define L5_KRNLQ_FLAGS 0x00000000
25#define L5_KRNLQ_SIZE 0x00000000
26#define L5_KRNLQ_TYPE 0x00000000
27#define KRNLQ_FLAGS_PG_SZ (0xf<<0)
28#define KRNLQ_FLAGS_PG_SZ_256 (0<<0)
29#define KRNLQ_FLAGS_PG_SZ_512 (1<<0)
30#define KRNLQ_FLAGS_PG_SZ_1K (2<<0)
31#define KRNLQ_FLAGS_PG_SZ_2K (3<<0)
32#define KRNLQ_FLAGS_PG_SZ_4K (4<<0)
33#define KRNLQ_FLAGS_PG_SZ_8K (5<<0)
34#define KRNLQ_FLAGS_PG_SZ_16K (6<<0)
35#define KRNLQ_FLAGS_PG_SZ_32K (7<<0)
36#define KRNLQ_FLAGS_PG_SZ_64K (8<<0)
37#define KRNLQ_FLAGS_PG_SZ_128K (9<<0)
38#define KRNLQ_FLAGS_PG_SZ_256K (10<<0)
39#define KRNLQ_FLAGS_PG_SZ_512K (11<<0)
40#define KRNLQ_FLAGS_PG_SZ_1M (12<<0)
41#define KRNLQ_FLAGS_PG_SZ_2M (13<<0)
42#define KRNLQ_FLAGS_QE_SELF_SEQ (1<<15)
43#define KRNLQ_SIZE_TYPE_SIZE ((((0x28 + 0x1f) & ~0x1f) / 0x20) << 16)
44#define KRNLQ_TYPE_TYPE (0xf<<28)
45#define KRNLQ_TYPE_TYPE_EMPTY (0<<28)
46#define KRNLQ_TYPE_TYPE_KRNLQ (6<<28)
47
48#define L5_KRNLQ_HOST_QIDX 0x00000004
49#define L5_KRNLQ_HOST_FW_QIDX 0x00000008
50#define L5_KRNLQ_NX_QE_SELF_SEQ 0x0000000c
51#define L5_KRNLQ_QE_SELF_SEQ_MAX 0x0000000c
52#define L5_KRNLQ_NX_QE_HADDR_HI 0x00000010
53#define L5_KRNLQ_NX_QE_HADDR_LO 0x00000014
54#define L5_KRNLQ_PGTBL_PGIDX 0x00000018
55#define L5_KRNLQ_NX_PG_QIDX 0x00000018
56#define L5_KRNLQ_PGTBL_NPAGES 0x0000001c
57#define L5_KRNLQ_QIDX_INCR 0x0000001c
58#define L5_KRNLQ_PGTBL_HADDR_HI 0x00000020
59#define L5_KRNLQ_PGTBL_HADDR_LO 0x00000024
60
61#define BNX2_PG_CTX_MAP 0x1a0034
62#define BNX2_ISCSI_CTX_MAP 0x1a0074
63
64struct cnic_redirect_entry {
65 struct dst_entry *old_dst;
66 struct dst_entry *new_dst;
67};
68
69#define MAX_COMPLETED_KCQE 64
70
71#define MAX_CNIC_L5_CONTEXT 256
72
73#define MAX_CM_SK_TBL_SZ MAX_CNIC_L5_CONTEXT
74
75#define MAX_ISCSI_TBL_SZ 256
76
77#define CNIC_LOCAL_PORT_MIN 60000
78#define CNIC_LOCAL_PORT_MAX 61000
79#define CNIC_LOCAL_PORT_RANGE (CNIC_LOCAL_PORT_MAX - CNIC_LOCAL_PORT_MIN)
80
81#define KWQE_CNT (BCM_PAGE_SIZE / sizeof(struct kwqe))
82#define KCQE_CNT (BCM_PAGE_SIZE / sizeof(struct kcqe))
83#define MAX_KWQE_CNT (KWQE_CNT - 1)
84#define MAX_KCQE_CNT (KCQE_CNT - 1)
85
86#define MAX_KWQ_IDX ((KWQ_PAGE_CNT * KWQE_CNT) - 1)
87#define MAX_KCQ_IDX ((KCQ_PAGE_CNT * KCQE_CNT) - 1)
88
89#define KWQ_PG(x) (((x) & ~MAX_KWQE_CNT) >> (BCM_PAGE_BITS - 5))
90#define KWQ_IDX(x) ((x) & MAX_KWQE_CNT)
91
92#define KCQ_PG(x) (((x) & ~MAX_KCQE_CNT) >> (BCM_PAGE_BITS - 5))
93#define KCQ_IDX(x) ((x) & MAX_KCQE_CNT)
94
95#define BNX2X_NEXT_KCQE(x) (((x) & (MAX_KCQE_CNT - 1)) == \
96 (MAX_KCQE_CNT - 1)) ? \
97 (x) + 2 : (x) + 1
98
99#define BNX2X_KWQ_DATA_PG(cp, x) ((x) / (cp)->kwq_16_data_pp)
100#define BNX2X_KWQ_DATA_IDX(cp, x) ((x) % (cp)->kwq_16_data_pp)
101#define BNX2X_KWQ_DATA(cp, x) \
102 &(cp)->kwq_16_data[BNX2X_KWQ_DATA_PG(cp, x)][BNX2X_KWQ_DATA_IDX(cp, x)]
103
a9736c08 104#define DEF_IPID_START 0x8000
a4636960
MC
105
106#define DEF_KA_TIMEOUT 10000
107#define DEF_KA_INTERVAL 300000
108#define DEF_KA_MAX_PROBE_COUNT 3
109#define DEF_TOS 0
110#define DEF_TTL 0xfe
111#define DEF_SND_SEQ_SCALE 0
112#define DEF_RCV_BUF 0xffff
113#define DEF_SND_BUF 0xffff
114#define DEF_SEED 0
115#define DEF_MAX_RT_TIME 500
116#define DEF_MAX_DA_COUNT 2
117#define DEF_SWS_TIMER 1000
118#define DEF_MAX_CWND 0xffff
119
120struct cnic_ctx {
121 u32 cid;
122 void *ctx;
123 dma_addr_t mapping;
124};
125
126#define BNX2_MAX_CID 0x2000
127
128struct cnic_dma {
129 int num_pages;
130 void **pg_arr;
131 dma_addr_t *pg_map_arr;
132 int pgtbl_size;
133 u32 *pgtbl;
134 dma_addr_t pgtbl_map;
135};
136
137struct cnic_id_tbl {
138 spinlock_t lock;
139 u32 start;
140 u32 max;
141 u32 next;
142 unsigned long *table;
143};
144
145#define CNIC_KWQ16_DATA_SIZE 128
146
147struct kwqe_16_data {
148 u8 data[CNIC_KWQ16_DATA_SIZE];
149};
150
151struct cnic_iscsi {
152 struct cnic_dma task_array_info;
153 struct cnic_dma r2tq_info;
154 struct cnic_dma hq_info;
155};
156
157struct cnic_context {
158 u32 cid;
159 struct kwqe_16_data *kwqe_data;
160 dma_addr_t kwqe_data_mapping;
161 wait_queue_head_t waitq;
162 int wait_cond;
163 unsigned long timestamp;
164 u32 ctx_flags;
165#define CTX_FL_OFFLD_START 0x00000001
166 u8 ulp_proto_id;
167 union {
168 struct cnic_iscsi *iscsi;
169 } proto;
170};
171
e6c28894
MC
172struct kcq_info {
173 struct cnic_dma dma;
174 struct kcqe **kcq;
175
176 u16 *hw_prod_idx_ptr;
177 u16 sw_prod_idx;
178 u16 *status_idx_ptr;
179 u32 io_addr;
180};
181
a4636960
MC
182struct cnic_local {
183
184 spinlock_t cnic_ulp_lock;
185 void *ulp_handle[MAX_CNIC_ULP_TYPE];
186 unsigned long ulp_flags[MAX_CNIC_ULP_TYPE];
187#define ULP_F_INIT 0
188#define ULP_F_START 1
681dbd71 189#define ULP_F_CALL_PENDING 2
a4636960
MC
190 struct cnic_ulp_ops *ulp_ops[MAX_CNIC_ULP_TYPE];
191
1f1332a3
MC
192 unsigned long cnic_local_flags;
193#define CNIC_LCL_FL_KWQ_INIT 0x0
48f753d2 194#define CNIC_LCL_FL_L2_WAIT 0x1
a4636960
MC
195
196 struct cnic_dev *dev;
197
198 struct cnic_eth_dev *ethdev;
199
200 void *l2_ring;
201 dma_addr_t l2_ring_map;
202 int l2_ring_size;
203 int l2_rx_ring_size;
204
205 void *l2_buf;
206 dma_addr_t l2_buf_map;
207 int l2_buf_size;
208 int l2_single_buf_size;
209
210 u16 *rx_cons_ptr;
211 u16 *tx_cons_ptr;
212 u16 rx_cons;
213 u16 tx_cons;
214
a4636960
MC
215 struct cnic_dma kwq_info;
216 struct kwqe **kwq;
217
218 struct cnic_dma kwq_16_data_info;
219
220 u16 max_kwq_idx;
221
222 u16 kwq_prod_idx;
223 u32 kwq_io_addr;
224
225 u16 *kwq_con_idx_ptr;
226 u16 kwq_con_idx;
227
e6c28894 228 struct kcq_info kcq1;
a4636960 229
a4dde3ab
MC
230 union {
231 void *gen;
232 struct status_block_msix *bnx2;
233 struct host_status_block *bnx2x;
234 } status_blk;
235
e2513065 236 struct host_def_status_block *bnx2x_def_status_blk;
a4636960
MC
237
238 u32 status_blk_num;
239 u32 int_num;
240 u32 last_status_idx;
241 struct tasklet_struct cnic_irq_task;
242
243 struct kcqe *completed_kcq[MAX_COMPLETED_KCQE];
244
245 struct cnic_sock *csk_tbl;
246 struct cnic_id_tbl csk_port_tbl;
247
248 struct cnic_dma conn_buf_info;
249 struct cnic_dma gbl_buf_info;
250
251 struct cnic_iscsi *iscsi_tbl;
252 struct cnic_context *ctx_tbl;
253 struct cnic_id_tbl cid_tbl;
a4636960 254 atomic_t iscsi_conn;
520efdf4
MC
255 u32 iscsi_start_cid;
256
257 u32 max_cid_space;
a4636960
MC
258
259 /* per connection parameters */
260 int num_iscsi_tasks;
261 int num_ccells;
262 int task_array_size;
263 int r2tq_size;
264 int hq_size;
265 int num_cqs;
266
267 struct cnic_ctx *ctx_arr;
268 int ctx_blks;
269 int ctx_blk_size;
e2513065 270 unsigned long ctx_align;
a4636960
MC
271 int cids_per_blk;
272
273 u32 chip_id;
274 int func;
275 u32 shmem_base;
276
277 u32 uio_dev;
278 struct uio_info *cnic_uinfo;
279
280 struct cnic_ops *cnic_ops;
281 int (*start_hw)(struct cnic_dev *);
282 void (*stop_hw)(struct cnic_dev *);
283 void (*setup_pgtbl)(struct cnic_dev *,
284 struct cnic_dma *);
285 int (*alloc_resc)(struct cnic_dev *);
286 void (*free_resc)(struct cnic_dev *);
287 int (*start_cm)(struct cnic_dev *);
288 void (*stop_cm)(struct cnic_dev *);
289 void (*enable_int)(struct cnic_dev *);
290 void (*disable_int_sync)(struct cnic_dev *);
291 void (*ack_int)(struct cnic_dev *);
292 void (*close_conn)(struct cnic_sock *, u32 opcode);
293 u16 (*next_idx)(u16);
294 u16 (*hw_idx)(u16);
295};
296
297struct bnx2x_bd_chain_next {
298 u32 addr_lo;
299 u32 addr_hi;
300 u8 reserved[8];
301};
302
e2513065
MC
303#define ISCSI_DEFAULT_MAX_OUTSTANDING_R2T (1)
304
a4636960
MC
305#define ISCSI_RAMROD_CMD_ID_UPDATE_CONN (ISCSI_KCQE_OPCODE_UPDATE_CONN)
306#define ISCSI_RAMROD_CMD_ID_INIT (ISCSI_KCQE_OPCODE_INIT)
307
308#define CDU_REGION_NUMBER_XCM_AG 2
309#define CDU_REGION_NUMBER_UCM_AG 4
310
e2513065
MC
311#define CDU_VALID_DATA(_cid, _region, _type) \
312 (((_cid) << 8) | (((_region)&0xf)<<4) | (((_type)&0xf)))
313
314#define CDU_CRC8(_cid, _region, _type) \
315 (calc_crc8(CDU_VALID_DATA(_cid, _region, _type), 0xff))
316
317#define CDU_RSRVD_VALUE_TYPE_A(_cid, _region, _type) \
318 (0x80 | ((CDU_CRC8(_cid, _region, _type)) & 0x7f))
319
320#define BNX2X_CONTEXT_MEM_SIZE 1024
321#define BNX2X_FCOE_CID 16
322
323/* iSCSI client IDs are 17, 19, 21, 23 */
324#define BNX2X_ISCSI_BASE_CL_ID 17
325#define BNX2X_ISCSI_CL_ID(vn) (BNX2X_ISCSI_BASE_CL_ID + ((vn) << 1))
326
327#define BNX2X_ISCSI_L2_CID 17
328#define BNX2X_ISCSI_START_CID 18
329#define BNX2X_ISCSI_NUM_CONNECTIONS 128
330#define BNX2X_ISCSI_TASK_CONTEXT_SIZE 128
331#define BNX2X_ISCSI_MAX_PENDING_R2TS 4
332#define BNX2X_ISCSI_R2TQE_SIZE 8
333#define BNX2X_ISCSI_HQ_BD_SIZE 64
334#define BNX2X_ISCSI_CONN_BUF_SIZE 64
335#define BNX2X_ISCSI_GLB_BUF_SIZE 64
336#define BNX2X_ISCSI_PBL_NOT_CACHED 0xff
337#define BNX2X_ISCSI_PDU_HEADER_NOT_CACHED 0xff
338#define BNX2X_HW_CID(x, func) ((x) | (((func) % PORT_MAX) << 23) | \
339 (((func) >> 1) << 17))
340#define BNX2X_SW_CID(x) (x & 0x1ffff)
341#define BNX2X_CHIP_NUM_57711 0x164f
342#define BNX2X_CHIP_NUM_57711E 0x1650
343#define BNX2X_CHIP_NUM(x) (x >> 16)
344#define BNX2X_CHIP_IS_57711(x) \
345 (BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57711)
346#define BNX2X_CHIP_IS_57711E(x) \
347 (BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57711E)
348#define BNX2X_CHIP_IS_E1H(x) \
349 (BNX2X_CHIP_IS_57711(x) || BNX2X_CHIP_IS_57711E(x))
350#define IS_E1H_OFFSET BNX2X_CHIP_IS_E1H(cp->chip_id)
351
352#define BNX2X_RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
353#define BNX2X_MAX_RX_DESC_CNT (BNX2X_RX_DESC_CNT - 2)
354#define BNX2X_RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
355#define BNX2X_MAX_RCQ_DESC_CNT (BNX2X_RCQ_DESC_CNT - 1)
356
48f753d2
MC
357#define BNX2X_NEXT_RCQE(x) (((x) & BNX2X_MAX_RCQ_DESC_CNT) == \
358 (BNX2X_MAX_RCQ_DESC_CNT - 1)) ? \
359 ((x) + 2) : ((x) + 1)
360
e2513065
MC
361#define BNX2X_DEF_SB_ID 16
362
363#define BNX2X_ISCSI_RX_SB_INDEX_NUM \
364 ((HC_INDEX_DEF_U_ETH_ISCSI_RX_CQ_CONS << \
365 USTORM_ETH_ST_CONTEXT_CONFIG_CQE_SB_INDEX_NUMBER_SHIFT) & \
366 USTORM_ETH_ST_CONTEXT_CONFIG_CQE_SB_INDEX_NUMBER)
367
368#define BNX2X_SHMEM_ADDR(base, field) (base + \
369 offsetof(struct shmem_region, field))
370
371#define CNIC_PORT(cp) ((cp)->func % PORT_MAX)
372#define CNIC_FUNC(cp) ((cp)->func)
373#define CNIC_E1HVN(cp) ((cp)->func >> 1)
374
a4636960
MC
375#endif
376