]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/bna/bnad.h
bna: scope and dead code cleanup
[net-next-2.6.git] / drivers / net / bna / bnad.h
CommitLineData
8b230ed8
RM
1/*
2 * Linux network driver for Brocade Converged Network Adapter.
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 (GPL) Version 2 as
6 * published by the Free Software Foundation
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
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13/*
14 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
15 * All rights reserved
16 * www.brocade.com
17 */
18#ifndef __BNAD_H__
19#define __BNAD_H__
20
21#include <linux/rtnetlink.h>
22#include <linux/workqueue.h>
23#include <linux/ipv6.h>
24#include <linux/etherdevice.h>
25#include <linux/mutex.h>
26#include <linux/firmware.h>
27
28/* Fix for IA64 */
29#include <asm/checksum.h>
30#include <net/ip6_checksum.h>
31
32#include <net/ip.h>
33#include <net/tcp.h>
34
35#include "bna.h"
36
37#define BNAD_TXQ_DEPTH 2048
38#define BNAD_RXQ_DEPTH 2048
39
40#define BNAD_MAX_TXS 1
41#define BNAD_MAX_TXQ_PER_TX 8 /* 8 priority queues */
42#define BNAD_TXQ_NUM 1
43
44#define BNAD_MAX_RXS 1
45#define BNAD_MAX_RXPS_PER_RX 16
46
47/*
48 * Control structure pointed to ccb->ctrl, which
49 * determines the NAPI / LRO behavior CCB
50 * There is 1:1 corres. between ccb & ctrl
51 */
52struct bnad_rx_ctrl {
53 struct bna_ccb *ccb;
54 struct napi_struct napi;
55};
56
57#define BNAD_RXMODE_PROMISC_DEFAULT BNA_RXMODE_PROMISC
58
59#define BNAD_GET_TX_ID(_skb) (0)
60
61/*
62 * GLOBAL #defines (CONSTANTS)
63 */
64#define BNAD_NAME "bna"
65#define BNAD_NAME_LEN 64
66
67#define BNAD_VERSION "2.3.2.0"
68
69#define BNAD_MAILBOX_MSIX_VECTORS 1
70
71#define BNAD_STATS_TIMER_FREQ 1000 /* in msecs */
72#define BNAD_DIM_TIMER_FREQ 1000 /* in msecs */
73
74#define BNAD_MAX_Q_DEPTH 0x10000
75#define BNAD_MIN_Q_DEPTH 0x200
76
77#define BNAD_JUMBO_MTU 9000
78
79#define BNAD_NETIF_WAKE_THRESHOLD 8
80
81#define BNAD_RXQ_REFILL_THRESHOLD_SHIFT 3
82
83/* Bit positions for tcb->flags */
84#define BNAD_TXQ_FREE_SENT 0
85
86/* Bit positions for rcb->flags */
87#define BNAD_RXQ_REFILL 0
88#define BNAD_RXQ_STARTED 1
89
90/*
91 * DATA STRUCTURES
92 */
93
94/* enums */
95enum bnad_intr_source {
96 BNAD_INTR_TX = 1,
97 BNAD_INTR_RX = 2
98};
99
100enum bnad_link_state {
101 BNAD_LS_DOWN = 0,
102 BNAD_LS_UP = 1
103};
104
105struct bnad_completion {
106 struct completion ioc_comp;
107 struct completion ucast_comp;
108 struct completion mcast_comp;
109 struct completion tx_comp;
110 struct completion rx_comp;
111 struct completion stats_comp;
112 struct completion port_comp;
113
114 u8 ioc_comp_status;
115 u8 ucast_comp_status;
116 u8 mcast_comp_status;
117 u8 tx_comp_status;
118 u8 rx_comp_status;
119 u8 stats_comp_status;
120 u8 port_comp_status;
121};
122
123/* Tx Rx Control Stats */
124struct bnad_drv_stats {
125 u64 netif_queue_stop;
126 u64 netif_queue_wakeup;
127 u64 tso4;
128 u64 tso6;
129 u64 tso_err;
130 u64 tcpcsum_offload;
131 u64 udpcsum_offload;
132 u64 csum_help;
133 u64 csum_help_err;
134
135 u64 hw_stats_updates;
136 u64 netif_rx_schedule;
137 u64 netif_rx_complete;
138 u64 netif_rx_dropped;
139
140 u64 link_toggle;
141 u64 cee_up;
142
143 u64 rxp_info_alloc_failed;
144 u64 mbox_intr_disabled;
145 u64 mbox_intr_enabled;
146 u64 tx_unmap_q_alloc_failed;
147 u64 rx_unmap_q_alloc_failed;
148
149 u64 rxbuf_alloc_failed;
150};
151
152/* Complete driver stats */
153struct bnad_stats {
154 struct bnad_drv_stats drv_stats;
155 struct bna_stats *bna_stats;
156};
157
158/* Tx / Rx Resources */
159struct bnad_tx_res_info {
160 struct bna_res_info res_info[BNA_TX_RES_T_MAX];
161};
162
163struct bnad_rx_res_info {
164 struct bna_res_info res_info[BNA_RX_RES_T_MAX];
165};
166
167struct bnad_tx_info {
168 struct bna_tx *tx; /* 1:1 between tx_info & tx */
169 struct bna_tcb *tcb[BNAD_MAX_TXQ_PER_TX];
170} ____cacheline_aligned;
171
172struct bnad_rx_info {
173 struct bna_rx *rx; /* 1:1 between rx_info & rx */
174
175 struct bnad_rx_ctrl rx_ctrl[BNAD_MAX_RXPS_PER_RX];
176} ____cacheline_aligned;
177
178/* Unmap queues for Tx / Rx cleanup */
179struct bnad_skb_unmap {
180 struct sk_buff *skb;
181 DECLARE_PCI_UNMAP_ADDR(dma_addr)
182};
183
184struct bnad_unmap_q {
185 u32 producer_index;
186 u32 consumer_index;
187 u32 q_depth;
188 /* This should be the last one */
189 struct bnad_skb_unmap unmap_array[1];
190};
191
192/* Bit mask values for bnad->cfg_flags */
193#define BNAD_CF_DIM_ENABLED 0x01 /* DIM */
194#define BNAD_CF_PROMISC 0x02
195#define BNAD_CF_ALLMULTI 0x04
196#define BNAD_CF_MSIX 0x08 /* If in MSIx mode */
197
198/* Defines for run_flags bit-mask */
199/* Set, tested & cleared using xxx_bit() functions */
200/* Values indicated bit positions */
201#define BNAD_RF_CEE_RUNNING 1
202#define BNAD_RF_HW_ERROR 2
203#define BNAD_RF_MBOX_IRQ_DISABLED 3
204#define BNAD_RF_TX_STARTED 4
205#define BNAD_RF_RX_STARTED 5
206#define BNAD_RF_DIM_TIMER_RUNNING 6
207#define BNAD_RF_STATS_TIMER_RUNNING 7
208
209struct bnad {
210 struct net_device *netdev;
211
212 /* Data path */
213 struct bnad_tx_info tx_info[BNAD_MAX_TXS];
214 struct bnad_rx_info rx_info[BNAD_MAX_RXS];
215
216 struct vlan_group *vlan_grp;
217 /*
218 * These q numbers are global only because
219 * they are used to calculate MSIx vectors.
220 * Actually the exact # of queues are per Tx/Rx
221 * object.
222 */
223 u32 num_tx;
224 u32 num_rx;
225 u32 num_txq_per_tx;
226 u32 num_rxp_per_rx;
227
228 u32 txq_depth;
229 u32 rxq_depth;
230
231 u8 tx_coalescing_timeo;
232 u8 rx_coalescing_timeo;
233
234 struct bna_rx_config rx_config[BNAD_MAX_RXS];
235 struct bna_tx_config tx_config[BNAD_MAX_TXS];
236
237 u32 rx_csum;
238
239 void __iomem *bar0; /* BAR0 address */
240
241 struct bna bna;
242
243 u32 cfg_flags;
244 unsigned long run_flags;
245
246 struct pci_dev *pcidev;
247 u64 mmio_start;
248 u64 mmio_len;
249
250 u32 msix_num;
8b230ed8
RM
251 struct msix_entry *msix_table;
252
253 struct mutex conf_mutex;
254 spinlock_t bna_lock ____cacheline_aligned;
255
256 /* Timers */
257 struct timer_list ioc_timer;
258 struct timer_list dim_timer;
259 struct timer_list stats_timer;
260
261 /* Control path resources, memory & irq */
262 struct bna_res_info res_info[BNA_RES_T_MAX];
263 struct bnad_tx_res_info tx_res_info[BNAD_MAX_TXS];
264 struct bnad_rx_res_info rx_res_info[BNAD_MAX_RXS];
265
266 struct bnad_completion bnad_completions;
267
268 /* Burnt in MAC address */
269 mac_t perm_addr;
270
271 struct tasklet_struct tx_free_tasklet;
272
273 /* Statistics */
274 struct bnad_stats stats;
8b230ed8
RM
275
276 struct bnad_diag *diag;
277
278 char adapter_name[BNAD_NAME_LEN];
279 char port_name[BNAD_NAME_LEN];
280 char mbox_irq_name[BNAD_NAME_LEN];
281};
282
283/*
284 * EXTERN VARIABLES
285 */
286extern struct firmware *bfi_fw;
287extern u32 bnad_rxqs_per_cq;
288
289/*
290 * EXTERN PROTOTYPES
291 */
292extern u32 *cna_get_firmware_buf(struct pci_dev *pdev);
293/* Netdev entry point prototypes */
294extern void bnad_set_ethtool_ops(struct net_device *netdev);
295
296/* Configuration & setup */
297extern void bnad_tx_coalescing_timeo_set(struct bnad *bnad);
298extern void bnad_rx_coalescing_timeo_set(struct bnad *bnad);
299
300extern int bnad_setup_rx(struct bnad *bnad, uint rx_id);
301extern int bnad_setup_tx(struct bnad *bnad, uint tx_id);
302extern void bnad_cleanup_tx(struct bnad *bnad, uint tx_id);
303extern void bnad_cleanup_rx(struct bnad *bnad, uint rx_id);
304
305/* Timer start/stop protos */
306extern void bnad_dim_timer_start(struct bnad *bnad);
307
308/* Statistics */
250e061e
ED
309extern void bnad_netdev_qstats_fill(struct bnad *bnad, struct rtnl_link_stats64 *stats);
310extern void bnad_netdev_hwstats_fill(struct bnad *bnad, struct rtnl_link_stats64 *stats);
8b230ed8
RM
311
312/**
313 * MACROS
314 */
315/* To set & get the stats counters */
316#define BNAD_UPDATE_CTR(_bnad, _ctr) \
317 (((_bnad)->stats.drv_stats._ctr)++)
318
319#define BNAD_GET_CTR(_bnad, _ctr) ((_bnad)->stats.drv_stats._ctr)
320
321#define bnad_enable_rx_irq_unsafe(_ccb) \
322{ \
323 bna_ib_coalescing_timer_set((_ccb)->i_dbell, \
324 (_ccb)->rx_coalescing_timeo); \
325 bna_ib_ack((_ccb)->i_dbell, 0); \
326}
327
328#define bnad_dim_timer_running(_bnad) \
329 (((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED) && \
330 (test_bit(BNAD_RF_DIM_TIMER_RUNNING, &((_bnad)->run_flags))))
331
332#endif /* __BNAD_H__ */