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"
28 * Forward declarations
32 struct bna_mcam_handle;
45 * Enums, primitive data types
50 BNA_STATUS_T_DISABLED = 0,
51 BNA_STATUS_T_ENABLED = 1
54 enum bna_cleanup_type {
64 BNA_CB_INVALID_MAC = 4,
65 BNA_CB_MCAST_LIST_FULL = 5,
66 BNA_CB_UCAST_CAM_FULL = 6,
86 enum bna_res_req_type {
87 BNA_RES_MEM_T_COM = 0,
88 BNA_RES_MEM_T_ATTR = 1,
89 BNA_RES_MEM_T_FWTRC = 2,
90 BNA_RES_MEM_T_STATS = 3,
94 enum bna_mod_res_req_type {
95 BNA_MOD_RES_MEM_T_TX_ARRAY = 0,
96 BNA_MOD_RES_MEM_T_TXQ_ARRAY = 1,
97 BNA_MOD_RES_MEM_T_RX_ARRAY = 2,
98 BNA_MOD_RES_MEM_T_RXP_ARRAY = 3,
99 BNA_MOD_RES_MEM_T_RXQ_ARRAY = 4,
100 BNA_MOD_RES_MEM_T_UCMAC_ARRAY = 5,
101 BNA_MOD_RES_MEM_T_MCMAC_ARRAY = 6,
102 BNA_MOD_RES_MEM_T_MCHANDLE_ARRAY = 7,
106 enum bna_tx_res_req_type {
107 BNA_TX_RES_MEM_T_TCB = 0,
108 BNA_TX_RES_MEM_T_UNMAPQ = 1,
109 BNA_TX_RES_MEM_T_QPT = 2,
110 BNA_TX_RES_MEM_T_SWQPT = 3,
111 BNA_TX_RES_MEM_T_PAGE = 4,
112 BNA_TX_RES_MEM_T_IBIDX = 5,
113 BNA_TX_RES_INTR_T_TXCMPL = 6,
117 enum bna_rx_mem_type {
118 BNA_RX_RES_MEM_T_CCB = 0, /* CQ context */
119 BNA_RX_RES_MEM_T_RCB = 1, /* CQ context */
120 BNA_RX_RES_MEM_T_UNMAPQ = 2, /* UnmapQ for RxQs */
121 BNA_RX_RES_MEM_T_CQPT = 3, /* CQ QPT */
122 BNA_RX_RES_MEM_T_CSWQPT = 4, /* S/W QPT */
123 BNA_RX_RES_MEM_T_CQPT_PAGE = 5, /* CQPT page */
124 BNA_RX_RES_MEM_T_HQPT = 6, /* RX QPT */
125 BNA_RX_RES_MEM_T_DQPT = 7, /* RX QPT */
126 BNA_RX_RES_MEM_T_HSWQPT = 8, /* RX s/w QPT */
127 BNA_RX_RES_MEM_T_DSWQPT = 9, /* RX s/w QPT */
128 BNA_RX_RES_MEM_T_DPAGE = 10, /* RX s/w QPT */
129 BNA_RX_RES_MEM_T_HPAGE = 11, /* RX s/w QPT */
130 BNA_RX_RES_MEM_T_IBIDX = 12,
131 BNA_RX_RES_MEM_T_RIT = 13,
132 BNA_RX_RES_T_INTR = 14, /* Rx interrupts */
133 BNA_RX_RES_T_MAX = 15
137 BNA_TX_T_REGULAR = 0,
138 BNA_TX_T_LOOPBACK = 1,
142 BNA_TX_F_ENET_STARTED = 1,
143 BNA_TX_F_ENABLED = 2,
144 BNA_TX_F_PRIO_CHANGED = 4,
145 BNA_TX_F_BW_UPDATED = 8,
148 enum bna_tx_mod_flags {
149 BNA_TX_MOD_F_ENET_STARTED = 1,
150 BNA_TX_MOD_F_ENET_LOOPBACK = 2,
154 BNA_RX_T_REGULAR = 0,
155 BNA_RX_T_LOOPBACK = 1,
165 BNA_RXMODE_PROMISC = 1,
166 BNA_RXMODE_DEFAULT = 2,
167 BNA_RXMODE_ALLMULTI = 4
176 RX_E_RXF_STARTED = 6,
177 RX_E_RXF_STOPPED = 7,
178 RX_E_CLEANUP_DONE = 8,
182 BNA_RX_F_ENET_STARTED = 1,
183 BNA_RX_F_ENABLED = 2,
186 enum bna_rx_mod_flags {
187 BNA_RX_MOD_F_ENET_STARTED = 1,
188 BNA_RX_MOD_F_ENET_LOOPBACK = 2,
192 BNA_RXF_F_PAUSED = 1,
206 BNA_ENET_T_REGULAR = 0,
207 BNA_ENET_T_LOOPBACK_INTERNAL = 1,
208 BNA_ENET_T_LOOPBACK_EXTERNAL = 2,
211 enum bna_link_status {
217 enum bna_ethport_flags {
218 BNA_ETHPORT_F_ADMIN_UP = 1,
219 BNA_ETHPORT_F_PORT_ENABLED = 2,
220 BNA_ETHPORT_F_RX_STARTED = 4,
223 enum bna_enet_flags {
224 BNA_ENET_F_IOCETH_READY = 1,
225 BNA_ENET_F_ENABLED = 2,
226 BNA_ENET_F_PAUSE_CHANGED = 4,
227 BNA_ENET_F_MTU_CHANGED = 8
231 BNA_RSS_F_RIT_PENDING = 1,
232 BNA_RSS_F_CFG_PENDING = 2,
233 BNA_RSS_F_STATUS_PENDING = 4,
237 BNA_MOD_F_INIT_DONE = 1,
241 BNA_PKT_RATE_10K = 10000,
242 BNA_PKT_RATE_20K = 20000,
243 BNA_PKT_RATE_30K = 30000,
244 BNA_PKT_RATE_40K = 40000,
245 BNA_PKT_RATE_50K = 50000,
246 BNA_PKT_RATE_60K = 60000,
247 BNA_PKT_RATE_70K = 70000,
248 BNA_PKT_RATE_80K = 80000,
251 enum bna_dim_load_types {
252 BNA_LOAD_T_HIGH_4 = 0, /* 80K <= r */
253 BNA_LOAD_T_HIGH_3 = 1, /* 60K <= r < 80K */
254 BNA_LOAD_T_HIGH_2 = 2, /* 50K <= r < 60K */
255 BNA_LOAD_T_HIGH_1 = 3, /* 40K <= r < 50K */
256 BNA_LOAD_T_LOW_1 = 4, /* 30K <= r < 40K */
257 BNA_LOAD_T_LOW_2 = 5, /* 20K <= r < 30K */
258 BNA_LOAD_T_LOW_3 = 6, /* 10K <= r < 20K */
259 BNA_LOAD_T_LOW_4 = 7, /* r < 10K */
263 enum bna_dim_bias_types {
264 BNA_BIAS_T_SMALL = 0, /* small pkts > (large pkts * 2) */
265 BNA_BIAS_T_LARGE = 1, /* Not BNA_BIAS_T_SMALL */
269 #define BNA_MAX_NAME_SIZE 64
272 char name[BNA_MAX_NAME_SIZE];
276 /* This should be the first one */
279 struct bna_mcam_handle *handle;
282 struct bna_mem_descr {
285 struct bna_dma_addr dma;
288 struct bna_mem_info {
289 enum bna_mem_type mem_type;
292 u32 align_sz; /* 0/1 = no alignment */
293 struct bna_mem_descr *mdl;
294 void *cookie; /* For bnad to unmap dma later */
297 struct bna_intr_descr {
301 struct bna_intr_info {
302 enum bna_intr_type intr_type;
304 struct bna_intr_descr *idl;
308 struct bna_mem_info mem_info;
309 struct bna_intr_info intr_info;
312 struct bna_res_info {
313 enum bna_res_type res_type;
314 union bna_res_u res_u;
319 struct bna_dma_addr hw_qpt_ptr;
326 bool fw_query_complete;
344 struct bna_attr attr;
345 struct bfa_msgq_cmd_entry msgq_cmd;
346 struct bfi_enet_attr_req attr_req;
348 void (*stop_cbfn)(struct bnad *bnad);
349 struct bnad *stop_cbarg;
360 /* Pause configuration */
361 struct bna_pause_config {
362 enum bna_status tx_pause;
363 enum bna_status rx_pause;
368 enum bna_enet_flags flags;
370 enum bna_enet_type type;
372 struct bna_pause_config pause_config;
375 /* Callback for bna_enet_disable(), enet_stop() */
376 void (*stop_cbfn)(void *);
379 /* Callback for bna_enet_pause_config() */
380 void (*pause_cbfn)(struct bnad *);
382 /* Callback for bna_enet_mtu_set() */
383 void (*mtu_cbfn)(struct bnad *);
385 struct bfa_wc chld_stop_wc;
387 struct bfa_msgq_cmd_entry msgq_cmd;
388 struct bfi_enet_set_pause_req pause_req;
401 enum bna_ethport_flags flags;
403 enum bna_link_status link_status;
405 int rx_started_count;
407 void (*stop_cbfn)(struct bna_enet *);
409 void (*adminup_cbfn)(struct bnad *, enum bna_cb_status);
411 void (*link_cbfn)(struct bnad *, enum bna_link_status);
413 struct bfa_msgq_cmd_entry msgq_cmd;
415 struct bfi_enet_enable_req admin_req;
416 struct bfi_enet_diag_lb_req lpbk_req;
428 /* Doorbell structure */
429 struct bna_ib_dbell {
430 void __iomem *doorbell_addr;
436 struct bna_dma_addr ib_seg_host_addr;
437 void *ib_seg_host_addr_kva;
439 struct bna_ib_dbell door_bell;
441 enum bna_intr_type intr_type;
444 u8 coalescing_timeo; /* Unit is 5usec. */
456 /* Tx datapath control structure */
457 #define BNA_Q_NAME_SIZE 16
464 volatile u32 *hw_consumer_index;
466 void __iomem *q_dbell;
467 struct bna_ib_dbell *i_dbell;
473 void *priv; /* BNAD's cookie */
474 enum bna_intr_type intr_type;
476 u8 priority; /* Current priority */
477 unsigned long flags; /* Used by bnad as required */
479 char name[BNA_Q_NAME_SIZE];
482 /* TxQ QPT and configuration */
484 /* This should be the first one */
503 /* This should be the first one */
509 enum bna_tx_flags flags;
511 enum bna_tx_type type;
514 struct list_head txq_q;
517 /* Tx event handlers */
518 void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
519 void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
520 void (*tx_stall_cbfn)(struct bnad *, struct bna_tx *);
521 void (*tx_resume_cbfn)(struct bnad *, struct bna_tx *);
522 void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tx *);
524 /* callback for bna_tx_disable(), bna_tx_stop() */
525 void (*stop_cbfn)(void *arg, struct bna_tx *tx);
528 /* callback for bna_tx_prio_set() */
529 void (*prio_change_cbfn)(struct bnad *bnad, struct bna_tx *tx);
531 struct bfa_msgq_cmd_entry msgq_cmd;
533 struct bfi_enet_tx_cfg_req cfg_req;
534 struct bfi_enet_req req;
535 struct bfi_enet_tx_cfg_rsp cfg_rsp;
539 void *priv; /* bnad's cookie */
542 /* Tx object configuration used during creation */
543 struct bna_tx_config {
546 int coalescing_timeo;
547 enum bna_tx_type tx_type;
550 struct bna_tx_event_cbfn {
552 void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
553 void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
555 void (*tx_stall_cbfn)(struct bnad *, struct bna_tx *);
556 void (*tx_resume_cbfn)(struct bnad *, struct bna_tx *);
557 void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tx *);
560 /* Tx module - keeps track of free, active tx objects */
562 struct bna_tx *tx; /* BFI_MAX_TXQ entries */
563 struct bna_txq *txq; /* BFI_MAX_TXQ entries */
565 struct list_head tx_free_q;
566 struct list_head tx_active_q;
568 struct list_head txq_free_q;
570 /* callback for bna_tx_mod_stop() */
571 void (*stop_cbfn)(struct bna_enet *enet);
573 struct bfa_wc tx_stop_wc;
575 enum bna_tx_mod_flags flags;
581 int prio_reconfigured;
594 /* Rx datapath control structure */
602 void __iomem *q_dbell;
609 void *priv; /* BNAD's cookie */
614 /* RxQ structure - QPT, configuration */
631 u64 rx_packets_with_error;
632 u64 rxbuf_alloc_failed;
639 struct bna_rxq *data;
642 struct bna_rxq *small;
643 struct bna_rxq *large;
646 struct bna_rxq *only;
647 struct bna_rxq *reserved;
651 /* Packet rate for Dynamic Interrupt Moderation */
652 struct bna_pkt_rate {
657 /* Completion control structure */
662 volatile u32 *hw_producer_index;
664 struct bna_ib_dbell *i_dbell;
665 struct bna_rcb *rcb[2];
666 void *ctrl; /* For bnad */
667 struct bna_pkt_rate pkt_rate;
674 void *priv; /* BNAD's cookie */
675 enum bna_intr_type intr_type;
677 u8 rx_coalescing_timeo; /* For NAPI */
679 char name[BNA_Q_NAME_SIZE];
682 /* CQ QPT, configuration */
692 struct bna_rss_config {
693 enum bfi_enet_rss_type hash_type;
695 u32 toeplitz_hash_key[BFI_ENET_RSS_KEY_LEN];
698 struct bna_hds_config {
699 enum bfi_enet_hds_type hdr_type;
703 /* Rx object configuration used during creation */
704 struct bna_rx_config {
705 enum bna_rx_type rx_type;
707 enum bna_rxp_type rxp_type;
710 int coalescing_timeo;
712 * Small/Large (or Header/Data) buffer size to be configured
713 * for SLR and HDS queue type. Large buffer size comes from
718 enum bna_status rss_status;
719 struct bna_rss_config rss_config;
721 struct bna_hds_config hds_config;
723 enum bna_status vlan_strip_status;
726 /* Rx Path structure - one per MSIX vector/CPU */
728 /* This should be the first one */
731 enum bna_rxp_type type;
737 /* MSI-x vector number for configuring RSS */
742 /* RxF structure (hardware Rx Function) */
745 enum bna_rxf_flags flags;
747 struct bfa_msgq_cmd_entry msgq_cmd;
749 struct bfi_enet_enable_req req;
750 struct bfi_enet_rss_cfg_req rss_req;
751 struct bfi_enet_rit_req rit_req;
752 struct bfi_enet_rx_vlan_req vlan_req;
753 struct bfi_enet_mcast_add_req mcast_add_req;
754 struct bfi_enet_mcast_del_req mcast_del_req;
755 struct bfi_enet_ucast_req ucast_req;
758 /* callback for bna_rxf_start() */
759 void (*start_cbfn) (struct bna_rx *rx);
760 struct bna_rx *start_cbarg;
762 /* callback for bna_rxf_stop() */
763 void (*stop_cbfn) (struct bna_rx *rx);
764 struct bna_rx *stop_cbarg;
766 /* callback for bna_rx_receive_pause() / bna_rx_receive_resume() */
767 void (*oper_state_cbfn) (struct bnad *bnad, struct bna_rx *rx);
768 struct bnad *oper_state_cbarg;
772 * bna_rxf_ucast_set()
773 * bna_rxf_{ucast/mcast}_add(),
774 * bna_rxf_{ucast/mcast}_del(),
777 void (*cam_fltr_cbfn)(struct bnad *bnad, struct bna_rx *rx);
778 struct bnad *cam_fltr_cbarg;
780 /* List of unicast addresses yet to be applied to h/w */
781 struct list_head ucast_pending_add_q;
782 struct list_head ucast_pending_del_q;
783 struct bna_mac *ucast_pending_mac;
784 int ucast_pending_set;
785 /* ucast addresses applied to the h/w */
786 struct list_head ucast_active_q;
787 struct bna_mac ucast_active_mac;
788 int ucast_active_set;
790 /* List of multicast addresses yet to be applied to h/w */
791 struct list_head mcast_pending_add_q;
792 struct list_head mcast_pending_del_q;
793 /* multicast addresses applied to the h/w */
794 struct list_head mcast_active_q;
795 struct list_head mcast_handle_q;
797 /* Rx modes yet to be applied to h/w */
798 enum bna_rxmode rxmode_pending;
799 enum bna_rxmode rxmode_pending_bitmask;
800 /* Rx modes applied to h/w */
801 enum bna_rxmode rxmode_active;
803 u8 vlan_pending_bitmask;
804 enum bna_status vlan_filter_status;
805 u32 vlan_filter_table[(BFI_ENET_VLAN_ID_MAX) / 32];
806 bool vlan_strip_pending;
807 enum bna_status vlan_strip_status;
809 enum bna_rss_flags rss_pending;
810 enum bna_status rss_status;
811 struct bna_rss_config rss_cfg;
820 /* This should be the first one */
827 enum bna_rx_type type;
830 struct list_head rxp_q;
832 struct bna_hds_config hds_cfg;
836 enum bna_rx_flags rx_flags;
838 struct bfa_msgq_cmd_entry msgq_cmd;
840 struct bfi_enet_rx_cfg_req cfg_req;
841 struct bfi_enet_req req;
842 struct bfi_enet_rx_cfg_rsp cfg_rsp;
845 /* Rx event handlers */
846 void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
847 void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
848 void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
849 void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
850 void (*rx_stall_cbfn)(struct bnad *, struct bna_rx *);
851 void (*rx_cleanup_cbfn)(struct bnad *, struct bna_rx *);
852 void (*rx_post_cbfn)(struct bnad *, struct bna_rx *);
854 /* callback for bna_rx_disable(), bna_rx_stop() */
855 void (*stop_cbfn)(void *arg, struct bna_rx *rx);
859 void *priv; /* bnad's cookie */
862 struct bna_rx_event_cbfn {
864 void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
865 void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
866 void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
867 void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
868 void (*rx_stall_cbfn)(struct bnad *, struct bna_rx *);
870 void (*rx_cleanup_cbfn)(struct bnad *, struct bna_rx *);
871 void (*rx_post_cbfn)(struct bnad *, struct bna_rx *);
874 /* Rx module - keeps track of free, active rx objects */
876 struct bna *bna; /* back pointer to parent */
877 struct bna_rx *rx; /* BFI_MAX_RXQ entries */
878 struct bna_rxp *rxp; /* BFI_MAX_RXQ entries */
879 struct bna_rxq *rxq; /* BFI_MAX_RXQ entries */
881 struct list_head rx_free_q;
882 struct list_head rx_active_q;
885 struct list_head rxp_free_q;
888 struct list_head rxq_free_q;
891 enum bna_rx_mod_flags flags;
893 /* callback for bna_rx_mod_stop() */
894 void (*stop_cbfn)(struct bna_enet *enet);
896 struct bfa_wc rx_stop_wc;
897 u32 dim_vector[BNA_LOAD_T_MAX][BNA_BIAS_T_MAX];
907 struct bna_ucam_mod {
908 struct bna_mac *ucmac; /* BFI_MAX_UCMAC entries */
909 struct list_head free_q;
914 struct bna_mcam_handle {
915 /* This should be the first one */
921 struct bna_mcam_mod {
922 struct bna_mac *mcmac; /* BFI_MAX_MCMAC entries */
923 struct bna_mcam_handle *mchandle; /* BFI_MAX_MCMAC entries */
924 struct list_head free_q;
925 struct list_head free_handle_q;
937 struct bna_dma_addr hw_stats_dma;
938 struct bfi_enet_stats *hw_stats_kva;
939 struct bfi_enet_stats hw_stats;
942 struct bna_stats_mod {
946 struct bfa_msgq_cmd_entry stats_get_cmd;
947 struct bfa_msgq_cmd_entry stats_clr_cmd;
948 struct bfi_enet_stats_req stats_get;
949 struct bfi_enet_stats_req stats_clr;
959 struct bna_ident ident;
960 struct bfa_pcidev pcidev;
963 struct bna_bit_defn bits;
965 struct bna_stats stats;
967 struct bna_ioceth ioceth;
969 struct bfa_flash flash;
970 struct bfa_msgq msgq;
972 struct bna_ethport ethport;
973 struct bna_enet enet;
974 struct bna_stats_mod stats_mod;
976 struct bna_tx_mod tx_mod;
977 struct bna_rx_mod rx_mod;
978 struct bna_ucam_mod ucam_mod;
979 struct bna_mcam_mod mcam_mod;
981 enum bna_mod_flags mod_flags;
983 int default_mode_rid;
988 #endif /* __BNA_TYPES_H__ */