bna: ENET and Tx Rx Redesign Enablement
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / brocade / bna / bna.h
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 #ifndef __BNA_H__
14 #define __BNA_H__
15
16 #include "bfa_cs.h"
17 #include "bfa_ioc.h"
18 #include "cna.h"
19 #include "bfi_ll.h"
20 #include "bna_types.h"
21
22 extern const u32 bna_napi_dim_vector[][BNA_BIAS_T_MAX];
23
24 /**
25  *
26  *  Macros and constants
27  *
28  */
29
30 #define BNA_IOC_TIMER_FREQ              200
31
32 /* Log string size */
33 #define BNA_MESSAGE_SIZE                256
34
35 /* MBOX API for PORT, TX, RX */
36 #define bna_mbox_qe_fill(_qe, _cmd, _cmd_len, _cbfn, _cbarg)            \
37 do {                                                                    \
38         memcpy(&((_qe)->cmd.msg[0]), (_cmd), (_cmd_len));       \
39         (_qe)->cbfn = (_cbfn);                                          \
40         (_qe)->cbarg = (_cbarg);                                        \
41 } while (0)
42
43 #define bna_is_small_rxq(_id) ((_id) & 0x1)
44
45 #define BNA_MAC_IS_EQUAL(_mac1, _mac2)                                  \
46         (!memcmp((_mac1), (_mac2), sizeof(mac_t)))
47
48 #define BNA_POWER_OF_2(x) (((x) & ((x) - 1)) == 0)
49
50 #define BNA_TO_POWER_OF_2(x)                                            \
51 do {                                                                    \
52         int _shift = 0;                                                 \
53         while ((x) && (x) != 1) {                                       \
54                 (x) >>= 1;                                              \
55                 _shift++;                                               \
56         }                                                               \
57         (x) <<= _shift;                                                 \
58 } while (0)
59
60 #define BNA_TO_POWER_OF_2_HIGH(x)                                       \
61 do {                                                                    \
62         int n = 1;                                                      \
63         while (n < (x))                                                 \
64                 n <<= 1;                                                \
65         (x) = n;                                                        \
66 } while (0)
67
68 /*
69  * input : _addr-> os dma addr in host endian format,
70  * output : _bna_dma_addr-> pointer to hw dma addr
71  */
72 #define BNA_SET_DMA_ADDR(_addr, _bna_dma_addr)                          \
73 do {                                                                    \
74         u64 tmp_addr =                                          \
75         cpu_to_be64((u64)(_addr));                              \
76         (_bna_dma_addr)->msb = ((struct bna_dma_addr *)&tmp_addr)->msb; \
77         (_bna_dma_addr)->lsb = ((struct bna_dma_addr *)&tmp_addr)->lsb; \
78 } while (0)
79
80 /*
81  * input : _bna_dma_addr-> pointer to hw dma addr
82  * output : _addr-> os dma addr in host endian format
83  */
84 #define BNA_GET_DMA_ADDR(_bna_dma_addr, _addr)                  \
85 do {                                                            \
86         (_addr) = ((((u64)ntohl((_bna_dma_addr)->msb))) << 32)          \
87         | ((ntohl((_bna_dma_addr)->lsb) & 0xffffffff)); \
88 } while (0)
89
90 #define containing_rec(addr, type, field)                               \
91         ((type *)((unsigned char *)(addr) -                             \
92         (unsigned char *)(&((type *)0)->field)))
93
94 #define BNA_TXQ_WI_NEEDED(_vectors)     (((_vectors) + 3) >> 2)
95
96 /* TxQ element is 64 bytes */
97 #define BNA_TXQ_PAGE_INDEX_MAX          (PAGE_SIZE >> 6)
98 #define BNA_TXQ_PAGE_INDEX_MAX_SHIFT    (PAGE_SHIFT - 6)
99
100 #define BNA_TXQ_QPGE_PTR_GET(_qe_idx, _qpt_ptr, _qe_ptr, _qe_ptr_range) \
101 {                                                                       \
102         unsigned int page_index;        /* index within a page */       \
103         void *page_addr;                                                \
104         page_index = (_qe_idx) & (BNA_TXQ_PAGE_INDEX_MAX - 1);          \
105         (_qe_ptr_range) = (BNA_TXQ_PAGE_INDEX_MAX - page_index);        \
106         page_addr = (_qpt_ptr)[((_qe_idx) >>  BNA_TXQ_PAGE_INDEX_MAX_SHIFT)];\
107         (_qe_ptr) = &((struct bna_txq_entry *)(page_addr))[page_index]; \
108 }
109
110 /* RxQ element is 8 bytes */
111 #define BNA_RXQ_PAGE_INDEX_MAX          (PAGE_SIZE >> 3)
112 #define BNA_RXQ_PAGE_INDEX_MAX_SHIFT    (PAGE_SHIFT - 3)
113
114 #define BNA_RXQ_QPGE_PTR_GET(_qe_idx, _qpt_ptr, _qe_ptr, _qe_ptr_range) \
115 {                                                                       \
116         unsigned int page_index;        /* index within a page */       \
117         void *page_addr;                                                \
118         page_index = (_qe_idx) & (BNA_RXQ_PAGE_INDEX_MAX - 1);          \
119         (_qe_ptr_range) = (BNA_RXQ_PAGE_INDEX_MAX - page_index);        \
120         page_addr = (_qpt_ptr)[((_qe_idx) >>                            \
121                                 BNA_RXQ_PAGE_INDEX_MAX_SHIFT)];         \
122         (_qe_ptr) = &((struct bna_rxq_entry *)(page_addr))[page_index]; \
123 }
124
125 /* CQ element is 16 bytes */
126 #define BNA_CQ_PAGE_INDEX_MAX           (PAGE_SIZE >> 4)
127 #define BNA_CQ_PAGE_INDEX_MAX_SHIFT     (PAGE_SHIFT - 4)
128
129 #define BNA_CQ_QPGE_PTR_GET(_qe_idx, _qpt_ptr, _qe_ptr, _qe_ptr_range)  \
130 {                                                                       \
131         unsigned int page_index;          /* index within a page */     \
132         void *page_addr;                                                \
133                                                                         \
134         page_index = (_qe_idx) & (BNA_CQ_PAGE_INDEX_MAX - 1);           \
135         (_qe_ptr_range) = (BNA_CQ_PAGE_INDEX_MAX - page_index);         \
136         page_addr = (_qpt_ptr)[((_qe_idx) >>                            \
137                                     BNA_CQ_PAGE_INDEX_MAX_SHIFT)];      \
138         (_qe_ptr) = &((struct bna_cq_entry *)(page_addr))[page_index];\
139 }
140
141 #define BNA_QE_INDX_2_PTR(_cast, _qe_idx, _q_base)                      \
142         (&((_cast *)(_q_base))[(_qe_idx)])
143
144 #define BNA_QE_INDX_RANGE(_qe_idx, _q_depth) ((_q_depth) - (_qe_idx))
145
146 #define BNA_QE_INDX_ADD(_qe_idx, _qe_num, _q_depth)                     \
147         ((_qe_idx) = ((_qe_idx) + (_qe_num)) & ((_q_depth) - 1))
148
149 #define BNA_Q_INDEX_CHANGE(_old_idx, _updated_idx, _q_depth)            \
150         (((_updated_idx) - (_old_idx)) & ((_q_depth) - 1))
151
152 #define BNA_QE_FREE_CNT(_q_ptr, _q_depth)                               \
153         (((_q_ptr)->consumer_index - (_q_ptr)->producer_index - 1) &    \
154          ((_q_depth) - 1))
155
156 #define BNA_QE_IN_USE_CNT(_q_ptr, _q_depth)                             \
157         ((((_q_ptr)->producer_index - (_q_ptr)->consumer_index)) &      \
158          (_q_depth - 1))
159
160 #define BNA_Q_GET_CI(_q_ptr)            ((_q_ptr)->q.consumer_index)
161
162 #define BNA_Q_GET_PI(_q_ptr)            ((_q_ptr)->q.producer_index)
163
164 #define BNA_Q_PI_ADD(_q_ptr, _num)                                      \
165         (_q_ptr)->q.producer_index =                                    \
166                 (((_q_ptr)->q.producer_index + (_num)) &                \
167                 ((_q_ptr)->q.q_depth - 1))
168
169 #define BNA_Q_CI_ADD(_q_ptr, _num)                                      \
170         (_q_ptr)->q.consumer_index =                                    \
171                 (((_q_ptr)->q.consumer_index + (_num))                  \
172                 & ((_q_ptr)->q.q_depth - 1))
173
174 #define BNA_Q_FREE_COUNT(_q_ptr)                                        \
175         (BNA_QE_FREE_CNT(&((_q_ptr)->q), (_q_ptr)->q.q_depth))
176
177 #define BNA_Q_IN_USE_COUNT(_q_ptr)                                      \
178         (BNA_QE_IN_USE_CNT(&(_q_ptr)->q, (_q_ptr)->q.q_depth))
179
180 /* These macros build the data portion of the TxQ/RxQ doorbell */
181 #define BNA_DOORBELL_Q_PRD_IDX(_pi)     (0x80000000 | (_pi))
182 #define BNA_DOORBELL_Q_STOP             (0x40000000)
183
184 /* These macros build the data portion of the IB doorbell */
185 #define BNA_DOORBELL_IB_INT_ACK(_timeout, _events) \
186         (0x80000000 | ((_timeout) << 16) | (_events))
187 #define BNA_DOORBELL_IB_INT_DISABLE     (0x40000000)
188
189 /* Set the coalescing timer for the given ib */
190 #define bna_ib_coalescing_timer_set(_i_dbell, _cls_timer)               \
191         ((_i_dbell)->doorbell_ack = BNA_DOORBELL_IB_INT_ACK((_cls_timer), 0));
192
193 /* Acks 'events' # of events for a given ib */
194 #define bna_ib_ack(_i_dbell, _events)                                   \
195         (writel(((_i_dbell)->doorbell_ack | (_events)), \
196                 (_i_dbell)->doorbell_addr));
197
198 #define bna_txq_prod_indx_doorbell(_tcb)                                \
199         (writel(BNA_DOORBELL_Q_PRD_IDX((_tcb)->producer_index), \
200                 (_tcb)->q_dbell));
201
202 #define bna_rxq_prod_indx_doorbell(_rcb)                                \
203         (writel(BNA_DOORBELL_Q_PRD_IDX((_rcb)->producer_index), \
204                 (_rcb)->q_dbell));
205
206 #define BNA_LARGE_PKT_SIZE              1000
207
208 #define BNA_UPDATE_PKT_CNT(_pkt, _len)                                  \
209 do {                                                                    \
210         if ((_len) > BNA_LARGE_PKT_SIZE) {                              \
211                 (_pkt)->large_pkt_cnt++;                                \
212         } else {                                                        \
213                 (_pkt)->small_pkt_cnt++;                                \
214         }                                                               \
215 } while (0)
216
217 #define call_rxf_stop_cbfn(rxf)                                         \
218 do {                                                                    \
219         if ((rxf)->stop_cbfn) {                                         \
220                 void (*cbfn)(struct bna_rx *);                  \
221                 struct bna_rx *cbarg;                                   \
222                 cbfn = (rxf)->stop_cbfn;                                \
223                 cbarg = (rxf)->stop_cbarg;                              \
224                 (rxf)->stop_cbfn = NULL;                                \
225                 (rxf)->stop_cbarg = NULL;                               \
226                 cbfn(cbarg);                                            \
227         }                                                               \
228 } while (0)
229
230 #define call_rxf_start_cbfn(rxf)                                        \
231 do {                                                                    \
232         if ((rxf)->start_cbfn) {                                        \
233                 void (*cbfn)(struct bna_rx *);                  \
234                 struct bna_rx *cbarg;                                   \
235                 cbfn = (rxf)->start_cbfn;                               \
236                 cbarg = (rxf)->start_cbarg;                             \
237                 (rxf)->start_cbfn = NULL;                               \
238                 (rxf)->start_cbarg = NULL;                              \
239                 cbfn(cbarg);                                            \
240         }                                                               \
241 } while (0)
242
243 #define call_rxf_cam_fltr_cbfn(rxf)                                     \
244 do {                                                                    \
245         if ((rxf)->cam_fltr_cbfn) {                                     \
246                 void (*cbfn)(struct bnad *, struct bna_rx *);   \
247                 struct bnad *cbarg;                                     \
248                 cbfn = (rxf)->cam_fltr_cbfn;                            \
249                 cbarg = (rxf)->cam_fltr_cbarg;                          \
250                 (rxf)->cam_fltr_cbfn = NULL;                            \
251                 (rxf)->cam_fltr_cbarg = NULL;                           \
252                 cbfn(cbarg, rxf->rx);                                   \
253         }                                                               \
254 } while (0)
255
256 #define call_rxf_pause_cbfn(rxf)                                        \
257 do {                                                                    \
258         if ((rxf)->oper_state_cbfn) {                                   \
259                 void (*cbfn)(struct bnad *, struct bna_rx *);   \
260                 struct bnad *cbarg;                                     \
261                 cbfn = (rxf)->oper_state_cbfn;                          \
262                 cbarg = (rxf)->oper_state_cbarg;                        \
263                 (rxf)->oper_state_cbfn = NULL;                          \
264                 (rxf)->oper_state_cbarg = NULL;                         \
265                 cbfn(cbarg, rxf->rx);                                   \
266         }                                                               \
267 } while (0)
268
269 #define call_rxf_resume_cbfn(rxf) call_rxf_pause_cbfn(rxf)
270
271 #define is_xxx_enable(mode, bitmask, xxx) ((bitmask & xxx) && (mode & xxx))
272
273 #define is_xxx_disable(mode, bitmask, xxx) ((bitmask & xxx) && !(mode & xxx))
274
275 #define xxx_enable(mode, bitmask, xxx)                                  \
276 do {                                                                    \
277         bitmask |= xxx;                                                 \
278         mode |= xxx;                                                    \
279 } while (0)
280
281 #define xxx_disable(mode, bitmask, xxx)                                 \
282 do {                                                                    \
283         bitmask |= xxx;                                                 \
284         mode &= ~xxx;                                                   \
285 } while (0)
286
287 #define xxx_inactive(mode, bitmask, xxx)                                \
288 do {                                                                    \
289         bitmask &= ~xxx;                                                \
290         mode &= ~xxx;                                                   \
291 } while (0)
292
293 #define is_promisc_enable(mode, bitmask)                                \
294         is_xxx_enable(mode, bitmask, BNA_RXMODE_PROMISC)
295
296 #define is_promisc_disable(mode, bitmask)                               \
297         is_xxx_disable(mode, bitmask, BNA_RXMODE_PROMISC)
298
299 #define promisc_enable(mode, bitmask)                                   \
300         xxx_enable(mode, bitmask, BNA_RXMODE_PROMISC)
301
302 #define promisc_disable(mode, bitmask)                                  \
303         xxx_disable(mode, bitmask, BNA_RXMODE_PROMISC)
304
305 #define promisc_inactive(mode, bitmask)                                 \
306         xxx_inactive(mode, bitmask, BNA_RXMODE_PROMISC)
307
308 #define is_default_enable(mode, bitmask)                                \
309         is_xxx_enable(mode, bitmask, BNA_RXMODE_DEFAULT)
310
311 #define is_default_disable(mode, bitmask)                               \
312         is_xxx_disable(mode, bitmask, BNA_RXMODE_DEFAULT)
313
314 #define default_enable(mode, bitmask)                                   \
315         xxx_enable(mode, bitmask, BNA_RXMODE_DEFAULT)
316
317 #define default_disable(mode, bitmask)                                  \
318         xxx_disable(mode, bitmask, BNA_RXMODE_DEFAULT)
319
320 #define default_inactive(mode, bitmask)                                 \
321         xxx_inactive(mode, bitmask, BNA_RXMODE_DEFAULT)
322
323 #define is_allmulti_enable(mode, bitmask)                               \
324         is_xxx_enable(mode, bitmask, BNA_RXMODE_ALLMULTI)
325
326 #define is_allmulti_disable(mode, bitmask)                              \
327         is_xxx_disable(mode, bitmask, BNA_RXMODE_ALLMULTI)
328
329 #define allmulti_enable(mode, bitmask)                                  \
330         xxx_enable(mode, bitmask, BNA_RXMODE_ALLMULTI)
331
332 #define allmulti_disable(mode, bitmask)                                 \
333         xxx_disable(mode, bitmask, BNA_RXMODE_ALLMULTI)
334
335 #define allmulti_inactive(mode, bitmask)                                \
336         xxx_inactive(mode, bitmask, BNA_RXMODE_ALLMULTI)
337
338 #define GET_RXQS(rxp, q0, q1)   do {                                    \
339         switch ((rxp)->type) {                                          \
340         case BNA_RXP_SINGLE:                                            \
341                 (q0) = rxp->rxq.single.only;                            \
342                 (q1) = NULL;                                            \
343                 break;                                                  \
344         case BNA_RXP_SLR:                                               \
345                 (q0) = rxp->rxq.slr.large;                              \
346                 (q1) = rxp->rxq.slr.small;                              \
347                 break;                                                  \
348         case BNA_RXP_HDS:                                               \
349                 (q0) = rxp->rxq.hds.data;                               \
350                 (q1) = rxp->rxq.hds.hdr;                                \
351                 break;                                                  \
352         }                                                               \
353 } while (0)
354
355 #define bna_tx_rid_mask(_bna) ((_bna)->tx_mod.rid_mask)
356
357 #define bna_rx_rid_mask(_bna) ((_bna)->rx_mod.rid_mask)
358
359 #define bna_tx_from_rid(_bna, _rid, _tx)                                \
360 do {                                                                \
361         struct bna_tx_mod *__tx_mod = &(_bna)->tx_mod;    \
362         struct bna_tx *__tx;                                        \
363         struct list_head *qe;                                      \
364         _tx = NULL;                                                  \
365         list_for_each(qe, &__tx_mod->tx_active_q) {                  \
366                 __tx = (struct bna_tx *)qe;                          \
367                 if (__tx->rid == (_rid)) {                            \
368                         (_tx) = __tx;                              \
369                         break;                                    \
370                 }                                                      \
371         }                                                              \
372 } while (0)
373
374 #define bna_rx_from_rid(_bna, _rid, _rx)                                \
375 do {                                                                    \
376         struct bna_rx_mod *__rx_mod = &(_bna)->rx_mod;                  \
377         struct bna_rx *__rx;                                            \
378         struct list_head *qe;                                           \
379         _rx = NULL;                                                     \
380         list_for_each(qe, &__rx_mod->rx_active_q) {                     \
381                 __rx = (struct bna_rx *)qe;                             \
382                 if (__rx->rid == (_rid)) {                              \
383                         (_rx) = __rx;                                   \
384                         break;                                          \
385                 }                                                       \
386         }                                                               \
387 } while (0)
388
389 /**
390  *
391  *  Inline functions
392  *
393  */
394
395 static inline struct bna_mac *bna_mac_find(struct list_head *q, u8 *addr)
396 {
397         struct bna_mac *mac = NULL;
398         struct list_head *qe;
399         list_for_each(qe, q) {
400                 if (BNA_MAC_IS_EQUAL(((struct bna_mac *)qe)->addr, addr)) {
401                         mac = (struct bna_mac *)qe;
402                         break;
403                 }
404         }
405         return mac;
406 }
407
408 #define bna_attr(_bna) (&(_bna)->ioceth.attr)
409
410 /**
411  *
412  * Function prototypes
413  *
414  */
415
416 /**
417  * BNA
418  */
419
420 /* FW response handlers */
421 void bna_bfi_stats_clr_rsp(struct bna *bna, struct bfi_msgq_mhdr *msghdr);
422
423 /* APIs for BNAD */
424 void bna_res_req(struct bna_res_info *res_info);
425 void bna_mod_res_req(struct bna *bna, struct bna_res_info *res_info);
426 void bna_init(struct bna *bna, struct bnad *bnad,
427                         struct bfa_pcidev *pcidev,
428                         struct bna_res_info *res_info);
429 void bna_mod_init(struct bna *bna, struct bna_res_info *res_info);
430 void bna_uninit(struct bna *bna);
431 int bna_num_txq_set(struct bna *bna, int num_txq);
432 int bna_num_rxp_set(struct bna *bna, int num_rxp);
433 void bna_stats_get(struct bna *bna);
434 void bna_get_perm_mac(struct bna *bna, u8 *mac);
435 void bna_hw_stats_get(struct bna *bna);
436
437 /* APIs for Rx */
438 int bna_rit_mod_can_satisfy(struct bna_rit_mod *rit_mod, int seg_size);
439
440 /* APIs for RxF */
441 struct bna_mac *bna_ucam_mod_mac_get(struct bna_ucam_mod *ucam_mod);
442 void bna_ucam_mod_mac_put(struct bna_ucam_mod *ucam_mod,
443                           struct bna_mac *mac);
444 struct bna_mac *bna_mcam_mod_mac_get(struct bna_mcam_mod *mcam_mod);
445 void bna_mcam_mod_mac_put(struct bna_mcam_mod *mcam_mod,
446                           struct bna_mac *mac);
447 struct bna_mcam_handle *bna_mcam_mod_handle_get(struct bna_mcam_mod *mod);
448 void bna_mcam_mod_handle_put(struct bna_mcam_mod *mcam_mod,
449                           struct bna_mcam_handle *handle);
450 struct bna_rit_segment *
451 bna_rit_mod_seg_get(struct bna_rit_mod *rit_mod, int seg_size);
452 void bna_rit_mod_seg_put(struct bna_rit_mod *rit_mod,
453                         struct bna_rit_segment *seg);
454
455 /**
456  * DEVICE
457  */
458
459 /* APIs for BNAD */
460 void bna_device_enable(struct bna_device *device);
461 void bna_device_disable(struct bna_device *device,
462                         enum bna_cleanup_type type);
463
464 /**
465  * MBOX
466  */
467
468 /* APIs for PORT, TX, RX */
469 void bna_mbox_handler(struct bna *bna, u32 intr_status);
470 void bna_mbox_send(struct bna *bna, struct bna_mbox_qe *mbox_qe);
471
472 /**
473  * PORT
474  */
475
476 /* API for RX */
477 int bna_port_mtu_get(struct bna_port *port);
478 void bna_llport_rx_started(struct bna_llport *llport);
479 void bna_llport_rx_stopped(struct bna_llport *llport);
480
481 /* API for BNAD */
482 void bna_port_enable(struct bna_port *port);
483 void bna_port_disable(struct bna_port *port, enum bna_cleanup_type type,
484                       void (*cbfn)(void *, enum bna_cb_status));
485 void bna_port_pause_config(struct bna_port *port,
486                            struct bna_pause_config *pause_config,
487                            void (*cbfn)(struct bnad *, enum bna_cb_status));
488 void bna_port_mtu_set(struct bna_port *port, int mtu,
489                       void (*cbfn)(struct bnad *, enum bna_cb_status));
490 void bna_port_mac_get(struct bna_port *port, mac_t *mac);
491
492 /* Callbacks for TX, RX */
493 void bna_port_cb_tx_stopped(struct bna_port *port,
494                             enum bna_cb_status status);
495 void bna_port_cb_rx_stopped(struct bna_port *port,
496                             enum bna_cb_status status);
497
498 /**
499  * ETHPORT
500  */
501
502 /* Callbacks for RX */
503 void bna_ethport_cb_rx_started(struct bna_ethport *ethport);
504 void bna_ethport_cb_rx_stopped(struct bna_ethport *ethport);
505
506 /**
507  * IB
508  */
509
510 /* APIs for BNA */
511 void bna_ib_mod_init(struct bna_ib_mod *ib_mod, struct bna *bna,
512                      struct bna_res_info *res_info);
513 void bna_ib_mod_uninit(struct bna_ib_mod *ib_mod);
514
515 /**
516  * TX MODULE AND TX
517  */
518 /* FW response handelrs */
519 void bna_bfi_tx_enet_start_rsp(struct bna_tx *tx,
520                                struct bfi_msgq_mhdr *msghdr);
521 void bna_bfi_tx_enet_stop_rsp(struct bna_tx *tx,
522                               struct bfi_msgq_mhdr *msghdr);
523 void bna_bfi_bw_update_aen(struct bna_tx_mod *tx_mod);
524
525 /* APIs for BNA */
526 void bna_tx_mod_init(struct bna_tx_mod *tx_mod, struct bna *bna,
527                      struct bna_res_info *res_info);
528 void bna_tx_mod_uninit(struct bna_tx_mod *tx_mod);
529 int bna_tx_state_get(struct bna_tx *tx);
530
531 /* APIs for ENET */
532 void bna_tx_mod_start(struct bna_tx_mod *tx_mod, enum bna_tx_type type);
533 void bna_tx_mod_stop(struct bna_tx_mod *tx_mod, enum bna_tx_type type);
534 void bna_tx_mod_fail(struct bna_tx_mod *tx_mod);
535 void bna_tx_mod_prio_changed(struct bna_tx_mod *tx_mod, int prio);
536 void bna_tx_mod_cee_link_status(struct bna_tx_mod *tx_mod, int cee_link);
537
538 /* APIs for BNAD */
539 void bna_tx_res_req(int num_txq, int txq_depth,
540                     struct bna_res_info *res_info);
541 struct bna_tx *bna_tx_create(struct bna *bna, struct bnad *bnad,
542                                struct bna_tx_config *tx_cfg,
543                                struct bna_tx_event_cbfn *tx_cbfn,
544                                struct bna_res_info *res_info, void *priv);
545 void bna_tx_destroy(struct bna_tx *tx);
546 void bna_tx_enable(struct bna_tx *tx);
547 void bna_tx_disable(struct bna_tx *tx, enum bna_cleanup_type type,
548                     void (*cbfn)(void *, struct bna_tx *));
549 void bna_tx_cleanup_complete(struct bna_tx *tx);
550 void bna_tx_coalescing_timeo_set(struct bna_tx *tx, int coalescing_timeo);
551
552 /**
553  * RX MODULE, RX, RXF
554  */
555
556 /* Internal APIs */
557 void rxf_cb_cam_fltr_mbox_cmd(void *arg, int status);
558 void rxf_cam_mbox_cmd(struct bna_rxf *rxf, u8 cmd,
559                 const struct bna_mac *mac_addr);
560 void __rxf_vlan_filter_set(struct bna_rxf *rxf, enum bna_status status);
561 void bna_rxf_adv_init(struct bna_rxf *rxf,
562                 struct bna_rx *rx,
563                 struct bna_rx_config *q_config);
564 int rxf_process_packet_filter_ucast(struct bna_rxf *rxf);
565 int rxf_process_packet_filter_promisc(struct bna_rxf *rxf);
566 int rxf_process_packet_filter_default(struct bna_rxf *rxf);
567 int rxf_process_packet_filter_allmulti(struct bna_rxf *rxf);
568 int rxf_clear_packet_filter_ucast(struct bna_rxf *rxf);
569 int rxf_clear_packet_filter_promisc(struct bna_rxf *rxf);
570 int rxf_clear_packet_filter_default(struct bna_rxf *rxf);
571 int rxf_clear_packet_filter_allmulti(struct bna_rxf *rxf);
572 void rxf_reset_packet_filter_ucast(struct bna_rxf *rxf);
573 void rxf_reset_packet_filter_promisc(struct bna_rxf *rxf);
574 void rxf_reset_packet_filter_default(struct bna_rxf *rxf);
575 void rxf_reset_packet_filter_allmulti(struct bna_rxf *rxf);
576
577 /* FW response handlers */
578 void bna_bfi_rx_enet_start_rsp(struct bna_rx *rx,
579                                struct bfi_msgq_mhdr *msghdr);
580 void bna_bfi_rx_enet_stop_rsp(struct bna_rx *rx,
581                               struct bfi_msgq_mhdr *msghdr);
582 void bna_bfi_rxf_cfg_rsp(struct bna_rxf *rxf, struct bfi_msgq_mhdr *msghdr);
583 void bna_bfi_rxf_mcast_add_rsp(struct bna_rxf *rxf,
584                                struct bfi_msgq_mhdr *msghdr);
585
586 /* APIs for BNA */
587 void bna_rx_mod_init(struct bna_rx_mod *rx_mod, struct bna *bna,
588                      struct bna_res_info *res_info);
589 void bna_rx_mod_uninit(struct bna_rx_mod *rx_mod);
590 int bna_rx_state_get(struct bna_rx *rx);
591 int bna_rxf_state_get(struct bna_rxf *rxf);
592
593 /* APIs for ENET */
594 void bna_rx_mod_start(struct bna_rx_mod *rx_mod, enum bna_rx_type type);
595 void bna_rx_mod_stop(struct bna_rx_mod *rx_mod, enum bna_rx_type type);
596 void bna_rx_mod_fail(struct bna_rx_mod *rx_mod);
597
598 /* APIs for BNAD */
599 void bna_rx_res_req(struct bna_rx_config *rx_config,
600                     struct bna_res_info *res_info);
601 struct bna_rx *bna_rx_create(struct bna *bna, struct bnad *bnad,
602                                struct bna_rx_config *rx_cfg,
603                                struct bna_rx_event_cbfn *rx_cbfn,
604                                struct bna_res_info *res_info, void *priv);
605 void bna_rx_destroy(struct bna_rx *rx);
606 void bna_rx_enable(struct bna_rx *rx);
607 void bna_rx_disable(struct bna_rx *rx, enum bna_cleanup_type type,
608                     void (*cbfn)(void *, struct bna_rx *));
609 void bna_rx_cleanup_complete(struct bna_rx *rx);
610 void bna_rx_coalescing_timeo_set(struct bna_rx *rx, int coalescing_timeo);
611 void bna_rx_dim_reconfig(struct bna *bna, const u32 vector[][BNA_BIAS_T_MAX]);
612 void bna_rx_dim_update(struct bna_ccb *ccb);
613 enum bna_cb_status
614 bna_rx_ucast_set(struct bna_rx *rx, u8 *ucmac,
615                  void (*cbfn)(struct bnad *, struct bna_rx *));
616 enum bna_cb_status
617 bna_rx_ucast_add(struct bna_rx *rx, u8* ucmac,
618                  void (*cbfn)(struct bnad *, struct bna_rx *));
619 enum bna_cb_status
620 bna_rx_ucast_del(struct bna_rx *rx, u8 *ucmac,
621                  void (*cbfn)(struct bnad *, struct bna_rx *));
622 enum bna_cb_status
623 bna_rx_mcast_add(struct bna_rx *rx, u8 *mcmac,
624                  void (*cbfn)(struct bnad *, struct bna_rx *));
625 enum bna_cb_status
626 bna_rx_mcast_listset(struct bna_rx *rx, int count, u8 *mcmac,
627                      void (*cbfn)(struct bnad *, struct bna_rx *));
628 enum bna_cb_status
629 bna_rx_mode_set(struct bna_rx *rx, enum bna_rxmode rxmode,
630                 enum bna_rxmode bitmask,
631                 void (*cbfn)(struct bnad *, struct bna_rx *));
632 void bna_rx_vlan_add(struct bna_rx *rx, int vlan_id);
633 void bna_rx_vlan_del(struct bna_rx *rx, int vlan_id);
634 void bna_rx_vlanfilter_enable(struct bna_rx *rx);
635 void bna_rx_hds_enable(struct bna_rx *rx, struct bna_hds_config *hds_config,
636                        void (*cbfn)(struct bnad *, struct bna_rx *));
637 void bna_rx_hds_disable(struct bna_rx *rx,
638                         void (*cbfn)(struct bnad *, struct bna_rx *));
639
640 /**
641  * ENET
642  */
643
644 /* API for RX */
645 int bna_enet_mtu_get(struct bna_enet *enet);
646
647 /* Callbacks for TX, RX */
648 void bna_enet_cb_tx_stopped(struct bna_enet *enet);
649 void bna_enet_cb_rx_stopped(struct bna_enet *enet);
650
651 /* API for BNAD */
652 void bna_enet_enable(struct bna_enet *enet);
653 void bna_enet_disable(struct bna_enet *enet, enum bna_cleanup_type type,
654                       void (*cbfn)(void *));
655 void bna_enet_pause_config(struct bna_enet *enet,
656                            struct bna_pause_config *pause_config,
657                            void (*cbfn)(struct bnad *));
658 void bna_enet_mtu_set(struct bna_enet *enet, int mtu,
659                       void (*cbfn)(struct bnad *));
660 void bna_enet_perm_mac_get(struct bna_enet *enet, mac_t *mac);
661
662 /**
663  * IOCETH
664  */
665
666 /* APIs for BNAD */
667 void bna_ioceth_enable(struct bna_ioceth *ioceth);
668 void bna_ioceth_disable(struct bna_ioceth *ioceth,
669                         enum bna_cleanup_type type);
670
671 /**
672  * BNAD
673  */
674
675 /* Callbacks for ENET */
676 void bnad_cb_ethport_link_status(struct bnad *bnad,
677                               enum bna_link_status status);
678
679 /* Callbacks for IOCETH */
680 void bnad_cb_ioceth_ready(struct bnad *bnad);
681 void bnad_cb_ioceth_failed(struct bnad *bnad);
682 void bnad_cb_ioceth_disabled(struct bnad *bnad);
683 void bnad_cb_mbox_intr_enable(struct bnad *bnad);
684 void bnad_cb_mbox_intr_disable(struct bnad *bnad);
685
686 /* Callbacks for BNA */
687 void bnad_cb_stats_get(struct bnad *bnad, enum bna_cb_status status,
688                        struct bna_stats *stats);
689
690 /* Callbacks for DEVICE */
691 void bnad_cb_device_enabled(struct bnad *bnad, enum bna_cb_status status);
692 void bnad_cb_device_disabled(struct bnad *bnad, enum bna_cb_status status);
693 void bnad_cb_device_enable_mbox_intr(struct bnad *bnad);
694 void bnad_cb_device_disable_mbox_intr(struct bnad *bnad);
695
696 /* Callbacks for port */
697 void bnad_cb_port_link_status(struct bnad *bnad,
698                               enum bna_link_status status);
699
700 #endif  /* __BNA_H__ */