2 * Linux network driver for Brocade Converged Network Adapter.
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
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.
14 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
18 #ifndef __BNA_TYPES_H__
19 #define __BNA_TYPES_H__
22 #include "bna_hw_defs.h"
26 /* Forward declarations */
28 struct bna_mcam_handle;
39 /* Enums, primitive data types */
42 BNA_STATUS_T_DISABLED = 0,
43 BNA_STATUS_T_ENABLED = 1
46 enum bna_cleanup_type {
56 BNA_CB_INVALID_MAC = 4,
57 BNA_CB_MCAST_LIST_FULL = 5,
58 BNA_CB_UCAST_CAM_FULL = 6,
78 enum bna_res_req_type {
79 BNA_RES_MEM_T_COM = 0,
80 BNA_RES_MEM_T_ATTR = 1,
81 BNA_RES_MEM_T_FWTRC = 2,
82 BNA_RES_MEM_T_STATS = 3,
86 enum bna_mod_res_req_type {
87 BNA_MOD_RES_MEM_T_TX_ARRAY = 0,
88 BNA_MOD_RES_MEM_T_TXQ_ARRAY = 1,
89 BNA_MOD_RES_MEM_T_RX_ARRAY = 2,
90 BNA_MOD_RES_MEM_T_RXP_ARRAY = 3,
91 BNA_MOD_RES_MEM_T_RXQ_ARRAY = 4,
92 BNA_MOD_RES_MEM_T_UCMAC_ARRAY = 5,
93 BNA_MOD_RES_MEM_T_MCMAC_ARRAY = 6,
94 BNA_MOD_RES_MEM_T_MCHANDLE_ARRAY = 7,
98 enum bna_tx_res_req_type {
99 BNA_TX_RES_MEM_T_TCB = 0,
100 BNA_TX_RES_MEM_T_UNMAPQ = 1,
101 BNA_TX_RES_MEM_T_QPT = 2,
102 BNA_TX_RES_MEM_T_SWQPT = 3,
103 BNA_TX_RES_MEM_T_PAGE = 4,
104 BNA_TX_RES_MEM_T_IBIDX = 5,
105 BNA_TX_RES_INTR_T_TXCMPL = 6,
109 enum bna_rx_mem_type {
110 BNA_RX_RES_MEM_T_CCB = 0, /* CQ context */
111 BNA_RX_RES_MEM_T_RCB = 1, /* CQ context */
112 BNA_RX_RES_MEM_T_UNMAPQ = 2, /* UnmapQ for RxQs */
113 BNA_RX_RES_MEM_T_CQPT = 3, /* CQ QPT */
114 BNA_RX_RES_MEM_T_CSWQPT = 4, /* S/W QPT */
115 BNA_RX_RES_MEM_T_CQPT_PAGE = 5, /* CQPT page */
116 BNA_RX_RES_MEM_T_HQPT = 6, /* RX QPT */
117 BNA_RX_RES_MEM_T_DQPT = 7, /* RX QPT */
118 BNA_RX_RES_MEM_T_HSWQPT = 8, /* RX s/w QPT */
119 BNA_RX_RES_MEM_T_DSWQPT = 9, /* RX s/w QPT */
120 BNA_RX_RES_MEM_T_DPAGE = 10, /* RX s/w QPT */
121 BNA_RX_RES_MEM_T_HPAGE = 11, /* RX s/w QPT */
122 BNA_RX_RES_MEM_T_IBIDX = 12,
123 BNA_RX_RES_MEM_T_RIT = 13,
124 BNA_RX_RES_T_INTR = 14, /* Rx interrupts */
125 BNA_RX_RES_T_MAX = 15
129 BNA_TX_T_REGULAR = 0,
130 BNA_TX_T_LOOPBACK = 1,
134 BNA_TX_F_ENET_STARTED = 1,
135 BNA_TX_F_ENABLED = 2,
136 BNA_TX_F_PRIO_CHANGED = 4,
137 BNA_TX_F_BW_UPDATED = 8,
140 enum bna_tx_mod_flags {
141 BNA_TX_MOD_F_ENET_STARTED = 1,
142 BNA_TX_MOD_F_ENET_LOOPBACK = 2,
146 BNA_RX_T_REGULAR = 0,
147 BNA_RX_T_LOOPBACK = 1,
157 BNA_RXMODE_PROMISC = 1,
158 BNA_RXMODE_DEFAULT = 2,
159 BNA_RXMODE_ALLMULTI = 4
168 RX_E_RXF_STARTED = 6,
169 RX_E_RXF_STOPPED = 7,
170 RX_E_CLEANUP_DONE = 8,
174 BNA_RX_F_ENET_STARTED = 1,
175 BNA_RX_F_ENABLED = 2,
178 enum bna_rx_mod_flags {
179 BNA_RX_MOD_F_ENET_STARTED = 1,
180 BNA_RX_MOD_F_ENET_LOOPBACK = 2,
184 BNA_RXF_F_PAUSED = 1,
198 BNA_ENET_T_REGULAR = 0,
199 BNA_ENET_T_LOOPBACK_INTERNAL = 1,
200 BNA_ENET_T_LOOPBACK_EXTERNAL = 2,
203 enum bna_link_status {
209 enum bna_ethport_flags {
210 BNA_ETHPORT_F_ADMIN_UP = 1,
211 BNA_ETHPORT_F_PORT_ENABLED = 2,
212 BNA_ETHPORT_F_RX_STARTED = 4,
215 enum bna_enet_flags {
216 BNA_ENET_F_IOCETH_READY = 1,
217 BNA_ENET_F_ENABLED = 2,
218 BNA_ENET_F_PAUSE_CHANGED = 4,
219 BNA_ENET_F_MTU_CHANGED = 8
223 BNA_RSS_F_RIT_PENDING = 1,
224 BNA_RSS_F_CFG_PENDING = 2,
225 BNA_RSS_F_STATUS_PENDING = 4,
229 BNA_MOD_F_INIT_DONE = 1,
233 BNA_PKT_RATE_10K = 10000,
234 BNA_PKT_RATE_20K = 20000,
235 BNA_PKT_RATE_30K = 30000,
236 BNA_PKT_RATE_40K = 40000,
237 BNA_PKT_RATE_50K = 50000,
238 BNA_PKT_RATE_60K = 60000,
239 BNA_PKT_RATE_70K = 70000,
240 BNA_PKT_RATE_80K = 80000,
243 enum bna_dim_load_types {
244 BNA_LOAD_T_HIGH_4 = 0, /* 80K <= r */
245 BNA_LOAD_T_HIGH_3 = 1, /* 60K <= r < 80K */
246 BNA_LOAD_T_HIGH_2 = 2, /* 50K <= r < 60K */
247 BNA_LOAD_T_HIGH_1 = 3, /* 40K <= r < 50K */
248 BNA_LOAD_T_LOW_1 = 4, /* 30K <= r < 40K */
249 BNA_LOAD_T_LOW_2 = 5, /* 20K <= r < 30K */
250 BNA_LOAD_T_LOW_3 = 6, /* 10K <= r < 20K */
251 BNA_LOAD_T_LOW_4 = 7, /* r < 10K */
255 enum bna_dim_bias_types {
256 BNA_BIAS_T_SMALL = 0, /* small pkts > (large pkts * 2) */
257 BNA_BIAS_T_LARGE = 1, /* Not BNA_BIAS_T_SMALL */
261 #define BNA_MAX_NAME_SIZE 64
264 char name[BNA_MAX_NAME_SIZE];
268 /* This should be the first one */
271 struct bna_mcam_handle *handle;
274 struct bna_mem_descr {
277 struct bna_dma_addr dma;
280 struct bna_mem_info {
281 enum bna_mem_type mem_type;
284 u32 align_sz; /* 0/1 = no alignment */
285 struct bna_mem_descr *mdl;
286 void *cookie; /* For bnad to unmap dma later */
289 struct bna_intr_descr {
293 struct bna_intr_info {
294 enum bna_intr_type intr_type;
296 struct bna_intr_descr *idl;
300 struct bna_mem_info mem_info;
301 struct bna_intr_info intr_info;
304 struct bna_res_info {
305 enum bna_res_type res_type;
306 union bna_res_u res_u;
311 struct bna_dma_addr hw_qpt_ptr;
318 bool fw_query_complete;
332 struct bna_attr attr;
333 struct bfa_msgq_cmd_entry msgq_cmd;
334 struct bfi_enet_attr_req attr_req;
336 void (*stop_cbfn)(struct bnad *bnad);
337 struct bnad *stop_cbarg;
344 /* Pause configuration */
345 struct bna_pause_config {
346 enum bna_status tx_pause;
347 enum bna_status rx_pause;
352 enum bna_enet_flags flags;
354 enum bna_enet_type type;
356 struct bna_pause_config pause_config;
359 /* Callback for bna_enet_disable(), enet_stop() */
360 void (*stop_cbfn)(void *);
363 /* Callback for bna_enet_pause_config() */
364 void (*pause_cbfn)(struct bnad *);
366 /* Callback for bna_enet_mtu_set() */
367 void (*mtu_cbfn)(struct bnad *);
369 struct bfa_wc chld_stop_wc;
371 struct bfa_msgq_cmd_entry msgq_cmd;
372 struct bfi_enet_set_pause_req pause_req;
381 enum bna_ethport_flags flags;
383 enum bna_link_status link_status;
385 int rx_started_count;
387 void (*stop_cbfn)(struct bna_enet *);
389 void (*adminup_cbfn)(struct bnad *, enum bna_cb_status);
391 void (*link_cbfn)(struct bnad *, enum bna_link_status);
393 struct bfa_msgq_cmd_entry msgq_cmd;
395 struct bfi_enet_enable_req admin_req;
396 struct bfi_enet_diag_lb_req lpbk_req;
402 /* Interrupt Block */
404 /* Doorbell structure */
405 struct bna_ib_dbell {
406 void __iomem *doorbell_addr;
412 struct bna_dma_addr ib_seg_host_addr;
413 void *ib_seg_host_addr_kva;
415 struct bna_ib_dbell door_bell;
417 enum bna_intr_type intr_type;
420 u8 coalescing_timeo; /* Unit is 5usec. */
428 /* Tx datapath control structure */
429 #define BNA_Q_NAME_SIZE 16
437 volatile u32 *hw_consumer_index;
439 void __iomem *q_dbell;
440 struct bna_ib_dbell *i_dbell;
444 void *priv; /* BNAD's cookie */
445 enum bna_intr_type intr_type;
447 u8 priority; /* Current priority */
448 unsigned long flags; /* Used by bnad as required */
450 char name[BNA_Q_NAME_SIZE];
453 /* TxQ QPT and configuration */
455 /* This should be the first one */
474 /* This should be the first one */
480 enum bna_tx_flags flags;
482 enum bna_tx_type type;
485 struct list_head txq_q;
488 /* Tx event handlers */
489 void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
490 void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
491 void (*tx_stall_cbfn)(struct bnad *, struct bna_tx *);
492 void (*tx_resume_cbfn)(struct bnad *, struct bna_tx *);
493 void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tx *);
495 /* callback for bna_tx_disable(), bna_tx_stop() */
496 void (*stop_cbfn)(void *arg, struct bna_tx *tx);
499 /* callback for bna_tx_prio_set() */
500 void (*prio_change_cbfn)(struct bnad *bnad, struct bna_tx *tx);
502 struct bfa_msgq_cmd_entry msgq_cmd;
504 struct bfi_enet_tx_cfg_req cfg_req;
505 struct bfi_enet_req req;
506 struct bfi_enet_tx_cfg_rsp cfg_rsp;
510 void *priv; /* bnad's cookie */
513 /* Tx object configuration used during creation */
514 struct bna_tx_config {
517 int coalescing_timeo;
518 enum bna_tx_type tx_type;
521 struct bna_tx_event_cbfn {
523 void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
524 void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
526 void (*tx_stall_cbfn)(struct bnad *, struct bna_tx *);
527 void (*tx_resume_cbfn)(struct bnad *, struct bna_tx *);
528 void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tx *);
531 /* Tx module - keeps track of free, active tx objects */
533 struct bna_tx *tx; /* BFI_MAX_TXQ entries */
534 struct bna_txq *txq; /* BFI_MAX_TXQ entries */
536 struct list_head tx_free_q;
537 struct list_head tx_active_q;
539 struct list_head txq_free_q;
541 /* callback for bna_tx_mod_stop() */
542 void (*stop_cbfn)(struct bna_enet *enet);
544 struct bfa_wc tx_stop_wc;
546 enum bna_tx_mod_flags flags;
552 int prio_reconfigured;
561 /* Rx datapath control structure */
570 void __iomem *q_dbell;
575 void *priv; /* BNAD's cookie */
580 /* RxQ structure - QPT, configuration */
597 u64 rx_packets_with_error;
598 u64 rxbuf_alloc_failed;
605 struct bna_rxq *data;
608 struct bna_rxq *small;
609 struct bna_rxq *large;
612 struct bna_rxq *only;
613 struct bna_rxq *reserved;
617 /* Packet rate for Dynamic Interrupt Moderation */
618 struct bna_pkt_rate {
623 /* Completion control structure */
629 volatile u32 *hw_producer_index;
631 struct bna_ib_dbell *i_dbell;
632 struct bna_rcb *rcb[2];
633 void *ctrl; /* For bnad */
634 struct bna_pkt_rate pkt_rate;
639 void *priv; /* BNAD's cookie */
640 enum bna_intr_type intr_type;
642 u8 rx_coalescing_timeo; /* For NAPI */
644 char name[BNA_Q_NAME_SIZE];
647 /* CQ QPT, configuration */
657 struct bna_rss_config {
658 enum bfi_enet_rss_type hash_type;
660 u32 toeplitz_hash_key[BFI_ENET_RSS_KEY_LEN];
663 struct bna_hds_config {
664 enum bfi_enet_hds_type hdr_type;
668 /* Rx object configuration used during creation */
669 struct bna_rx_config {
670 enum bna_rx_type rx_type;
672 enum bna_rxp_type rxp_type;
675 int coalescing_timeo;
677 * Small/Large (or Header/Data) buffer size to be configured
678 * for SLR and HDS queue type. Large buffer size comes from
683 enum bna_status rss_status;
684 struct bna_rss_config rss_config;
686 struct bna_hds_config hds_config;
688 enum bna_status vlan_strip_status;
691 /* Rx Path structure - one per MSIX vector/CPU */
693 /* This should be the first one */
696 enum bna_rxp_type type;
702 /* MSI-x vector number for configuring RSS */
707 /* RxF structure (hardware Rx Function) */
710 enum bna_rxf_flags flags;
712 struct bfa_msgq_cmd_entry msgq_cmd;
714 struct bfi_enet_enable_req req;
715 struct bfi_enet_rss_cfg_req rss_req;
716 struct bfi_enet_rit_req rit_req;
717 struct bfi_enet_rx_vlan_req vlan_req;
718 struct bfi_enet_mcast_add_req mcast_add_req;
719 struct bfi_enet_mcast_del_req mcast_del_req;
720 struct bfi_enet_ucast_req ucast_req;
723 /* callback for bna_rxf_start() */
724 void (*start_cbfn) (struct bna_rx *rx);
725 struct bna_rx *start_cbarg;
727 /* callback for bna_rxf_stop() */
728 void (*stop_cbfn) (struct bna_rx *rx);
729 struct bna_rx *stop_cbarg;
731 /* callback for bna_rx_receive_pause() / bna_rx_receive_resume() */
732 void (*oper_state_cbfn) (struct bnad *bnad, struct bna_rx *rx);
733 struct bnad *oper_state_cbarg;
737 * bna_rxf_ucast_set()
738 * bna_rxf_{ucast/mcast}_add(),
739 * bna_rxf_{ucast/mcast}_del(),
742 void (*cam_fltr_cbfn)(struct bnad *bnad, struct bna_rx *rx);
743 struct bnad *cam_fltr_cbarg;
745 /* List of unicast addresses yet to be applied to h/w */
746 struct list_head ucast_pending_add_q;
747 struct list_head ucast_pending_del_q;
748 struct bna_mac *ucast_pending_mac;
749 int ucast_pending_set;
750 /* ucast addresses applied to the h/w */
751 struct list_head ucast_active_q;
752 struct bna_mac ucast_active_mac;
753 int ucast_active_set;
755 /* List of multicast addresses yet to be applied to h/w */
756 struct list_head mcast_pending_add_q;
757 struct list_head mcast_pending_del_q;
758 /* multicast addresses applied to the h/w */
759 struct list_head mcast_active_q;
760 struct list_head mcast_handle_q;
762 /* Rx modes yet to be applied to h/w */
763 enum bna_rxmode rxmode_pending;
764 enum bna_rxmode rxmode_pending_bitmask;
765 /* Rx modes applied to h/w */
766 enum bna_rxmode rxmode_active;
768 u8 vlan_pending_bitmask;
769 enum bna_status vlan_filter_status;
770 u32 vlan_filter_table[(BFI_ENET_VLAN_ID_MAX) / 32];
771 bool vlan_strip_pending;
772 enum bna_status vlan_strip_status;
774 enum bna_rss_flags rss_pending;
775 enum bna_status rss_status;
776 struct bna_rss_config rss_cfg;
785 /* This should be the first one */
792 enum bna_rx_type type;
795 struct list_head rxp_q;
797 struct bna_hds_config hds_cfg;
801 enum bna_rx_flags rx_flags;
803 struct bfa_msgq_cmd_entry msgq_cmd;
805 struct bfi_enet_rx_cfg_req cfg_req;
806 struct bfi_enet_req req;
807 struct bfi_enet_rx_cfg_rsp cfg_rsp;
810 /* Rx event handlers */
811 void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
812 void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
813 void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
814 void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
815 void (*rx_stall_cbfn)(struct bnad *, struct bna_rx *);
816 void (*rx_cleanup_cbfn)(struct bnad *, struct bna_rx *);
817 void (*rx_post_cbfn)(struct bnad *, struct bna_rx *);
819 /* callback for bna_rx_disable(), bna_rx_stop() */
820 void (*stop_cbfn)(void *arg, struct bna_rx *rx);
824 void *priv; /* bnad's cookie */
827 struct bna_rx_event_cbfn {
829 void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
830 void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
831 void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
832 void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
833 void (*rx_stall_cbfn)(struct bnad *, struct bna_rx *);
835 void (*rx_cleanup_cbfn)(struct bnad *, struct bna_rx *);
836 void (*rx_post_cbfn)(struct bnad *, struct bna_rx *);
839 /* Rx module - keeps track of free, active rx objects */
841 struct bna *bna; /* back pointer to parent */
842 struct bna_rx *rx; /* BFI_MAX_RXQ entries */
843 struct bna_rxp *rxp; /* BFI_MAX_RXQ entries */
844 struct bna_rxq *rxq; /* BFI_MAX_RXQ entries */
846 struct list_head rx_free_q;
847 struct list_head rx_active_q;
850 struct list_head rxp_free_q;
853 struct list_head rxq_free_q;
856 enum bna_rx_mod_flags flags;
858 /* callback for bna_rx_mod_stop() */
859 void (*stop_cbfn)(struct bna_enet *enet);
861 struct bfa_wc rx_stop_wc;
862 u32 dim_vector[BNA_LOAD_T_MAX][BNA_BIAS_T_MAX];
868 struct bna_ucam_mod {
869 struct bna_mac *ucmac; /* BFI_MAX_UCMAC entries */
870 struct list_head free_q;
875 struct bna_mcam_handle {
876 /* This should be the first one */
882 struct bna_mcam_mod {
883 struct bna_mac *mcmac; /* BFI_MAX_MCMAC entries */
884 struct bna_mcam_handle *mchandle; /* BFI_MAX_MCMAC entries */
885 struct list_head free_q;
886 struct list_head free_handle_q;
894 struct bna_dma_addr hw_stats_dma;
895 struct bfi_enet_stats *hw_stats_kva;
896 struct bfi_enet_stats hw_stats;
899 struct bna_stats_mod {
903 struct bfa_msgq_cmd_entry stats_get_cmd;
904 struct bfa_msgq_cmd_entry stats_clr_cmd;
905 struct bfi_enet_stats_req stats_get;
906 struct bfi_enet_stats_req stats_clr;
912 struct bna_ident ident;
913 struct bfa_pcidev pcidev;
916 struct bna_bit_defn bits;
918 struct bna_stats stats;
920 struct bna_ioceth ioceth;
922 struct bfa_flash flash;
923 struct bfa_msgq msgq;
925 struct bna_ethport ethport;
926 struct bna_enet enet;
927 struct bna_stats_mod stats_mod;
929 struct bna_tx_mod tx_mod;
930 struct bna_rx_mod rx_mod;
931 struct bna_ucam_mod ucam_mod;
932 struct bna_mcam_mod mcam_mod;
934 enum bna_mod_flags mod_flags;
936 int default_mode_rid;
941 #endif /* __BNA_TYPES_H__ */