2 * Linux network driver for QLogic BR-series 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-2014 Brocade Communications Systems, Inc.
15 * Copyright (c) 2014-2015 QLogic Corporation
19 #ifndef __BNA_TYPES_H__
20 #define __BNA_TYPES_H__
23 #include "bna_hw_defs.h"
27 /* Forward declarations */
29 struct bna_mcam_handle;
40 /* Enums, primitive data types */
43 BNA_STATUS_T_DISABLED = 0,
44 BNA_STATUS_T_ENABLED = 1
47 enum bna_cleanup_type {
57 BNA_CB_INVALID_MAC = 4,
58 BNA_CB_MCAST_LIST_FULL = 5,
59 BNA_CB_UCAST_CAM_FULL = 6,
79 enum bna_res_req_type {
80 BNA_RES_MEM_T_COM = 0,
81 BNA_RES_MEM_T_ATTR = 1,
82 BNA_RES_MEM_T_FWTRC = 2,
83 BNA_RES_MEM_T_STATS = 3,
87 enum bna_mod_res_req_type {
88 BNA_MOD_RES_MEM_T_TX_ARRAY = 0,
89 BNA_MOD_RES_MEM_T_TXQ_ARRAY = 1,
90 BNA_MOD_RES_MEM_T_RX_ARRAY = 2,
91 BNA_MOD_RES_MEM_T_RXP_ARRAY = 3,
92 BNA_MOD_RES_MEM_T_RXQ_ARRAY = 4,
93 BNA_MOD_RES_MEM_T_UCMAC_ARRAY = 5,
94 BNA_MOD_RES_MEM_T_MCMAC_ARRAY = 6,
95 BNA_MOD_RES_MEM_T_MCHANDLE_ARRAY = 7,
99 enum bna_tx_res_req_type {
100 BNA_TX_RES_MEM_T_TCB = 0,
101 BNA_TX_RES_MEM_T_UNMAPQ = 1,
102 BNA_TX_RES_MEM_T_QPT = 2,
103 BNA_TX_RES_MEM_T_SWQPT = 3,
104 BNA_TX_RES_MEM_T_PAGE = 4,
105 BNA_TX_RES_MEM_T_IBIDX = 5,
106 BNA_TX_RES_INTR_T_TXCMPL = 6,
110 enum bna_rx_mem_type {
111 BNA_RX_RES_MEM_T_CCB = 0, /* CQ context */
112 BNA_RX_RES_MEM_T_RCB = 1, /* CQ context */
113 BNA_RX_RES_MEM_T_UNMAPHQ = 2,
114 BNA_RX_RES_MEM_T_UNMAPDQ = 3,
115 BNA_RX_RES_MEM_T_CQPT = 4,
116 BNA_RX_RES_MEM_T_CSWQPT = 5,
117 BNA_RX_RES_MEM_T_CQPT_PAGE = 6,
118 BNA_RX_RES_MEM_T_HQPT = 7,
119 BNA_RX_RES_MEM_T_DQPT = 8,
120 BNA_RX_RES_MEM_T_HSWQPT = 9,
121 BNA_RX_RES_MEM_T_DSWQPT = 10,
122 BNA_RX_RES_MEM_T_DPAGE = 11,
123 BNA_RX_RES_MEM_T_HPAGE = 12,
124 BNA_RX_RES_MEM_T_IBIDX = 13,
125 BNA_RX_RES_MEM_T_RIT = 14,
126 BNA_RX_RES_T_INTR = 15,
127 BNA_RX_RES_T_MAX = 16
131 BNA_TX_T_REGULAR = 0,
132 BNA_TX_T_LOOPBACK = 1,
136 BNA_TX_F_ENET_STARTED = 1,
137 BNA_TX_F_ENABLED = 2,
138 BNA_TX_F_PRIO_CHANGED = 4,
139 BNA_TX_F_BW_UPDATED = 8,
142 enum bna_tx_mod_flags {
143 BNA_TX_MOD_F_ENET_STARTED = 1,
144 BNA_TX_MOD_F_ENET_LOOPBACK = 2,
148 BNA_RX_T_REGULAR = 0,
149 BNA_RX_T_LOOPBACK = 1,
159 BNA_RXMODE_PROMISC = 1,
160 BNA_RXMODE_DEFAULT = 2,
161 BNA_RXMODE_ALLMULTI = 4
170 RX_E_RXF_STARTED = 6,
171 RX_E_RXF_STOPPED = 7,
172 RX_E_CLEANUP_DONE = 8,
176 BNA_RX_F_ENET_STARTED = 1,
177 BNA_RX_F_ENABLED = 2,
180 enum bna_rx_mod_flags {
181 BNA_RX_MOD_F_ENET_STARTED = 1,
182 BNA_RX_MOD_F_ENET_LOOPBACK = 2,
186 BNA_RXF_F_PAUSED = 1,
200 BNA_ENET_T_REGULAR = 0,
201 BNA_ENET_T_LOOPBACK_INTERNAL = 1,
202 BNA_ENET_T_LOOPBACK_EXTERNAL = 2,
205 enum bna_link_status {
211 enum bna_ethport_flags {
212 BNA_ETHPORT_F_ADMIN_UP = 1,
213 BNA_ETHPORT_F_PORT_ENABLED = 2,
214 BNA_ETHPORT_F_RX_STARTED = 4,
217 enum bna_enet_flags {
218 BNA_ENET_F_IOCETH_READY = 1,
219 BNA_ENET_F_ENABLED = 2,
220 BNA_ENET_F_PAUSE_CHANGED = 4,
221 BNA_ENET_F_MTU_CHANGED = 8
225 BNA_RSS_F_RIT_PENDING = 1,
226 BNA_RSS_F_CFG_PENDING = 2,
227 BNA_RSS_F_STATUS_PENDING = 4,
231 BNA_MOD_F_INIT_DONE = 1,
235 BNA_PKT_RATE_10K = 10000,
236 BNA_PKT_RATE_20K = 20000,
237 BNA_PKT_RATE_30K = 30000,
238 BNA_PKT_RATE_40K = 40000,
239 BNA_PKT_RATE_50K = 50000,
240 BNA_PKT_RATE_60K = 60000,
241 BNA_PKT_RATE_70K = 70000,
242 BNA_PKT_RATE_80K = 80000,
245 enum bna_dim_load_types {
246 BNA_LOAD_T_HIGH_4 = 0, /* 80K <= r */
247 BNA_LOAD_T_HIGH_3 = 1, /* 60K <= r < 80K */
248 BNA_LOAD_T_HIGH_2 = 2, /* 50K <= r < 60K */
249 BNA_LOAD_T_HIGH_1 = 3, /* 40K <= r < 50K */
250 BNA_LOAD_T_LOW_1 = 4, /* 30K <= r < 40K */
251 BNA_LOAD_T_LOW_2 = 5, /* 20K <= r < 30K */
252 BNA_LOAD_T_LOW_3 = 6, /* 10K <= r < 20K */
253 BNA_LOAD_T_LOW_4 = 7, /* r < 10K */
257 enum bna_dim_bias_types {
258 BNA_BIAS_T_SMALL = 0, /* small pkts > (large pkts * 2) */
259 BNA_BIAS_T_LARGE = 1, /* Not BNA_BIAS_T_SMALL */
263 #define BNA_MAX_NAME_SIZE 64
266 char name[BNA_MAX_NAME_SIZE];
270 /* This should be the first one */
273 struct bna_mcam_handle *handle;
276 struct bna_mem_descr {
279 struct bna_dma_addr dma;
282 struct bna_mem_info {
283 enum bna_mem_type mem_type;
286 u32 align_sz; /* 0/1 = no alignment */
287 struct bna_mem_descr *mdl;
288 void *cookie; /* For bnad to unmap dma later */
291 struct bna_intr_descr {
295 struct bna_intr_info {
296 enum bna_intr_type intr_type;
298 struct bna_intr_descr *idl;
302 struct bna_mem_info mem_info;
303 struct bna_intr_info intr_info;
306 struct bna_res_info {
307 enum bna_res_type res_type;
308 union bna_res_u res_u;
313 struct bna_dma_addr hw_qpt_ptr;
320 bool fw_query_complete;
334 struct bna_attr attr;
335 struct bfa_msgq_cmd_entry msgq_cmd;
336 struct bfi_enet_attr_req attr_req;
338 void (*stop_cbfn)(struct bnad *bnad);
339 struct bnad *stop_cbarg;
346 /* Pause configuration */
347 struct bna_pause_config {
348 enum bna_status tx_pause;
349 enum bna_status rx_pause;
354 enum bna_enet_flags flags;
356 enum bna_enet_type type;
358 struct bna_pause_config pause_config;
361 /* Callback for bna_enet_disable(), enet_stop() */
362 void (*stop_cbfn)(void *);
365 /* Callback for bna_enet_pause_config() */
366 void (*pause_cbfn)(struct bnad *);
368 /* Callback for bna_enet_mtu_set() */
369 void (*mtu_cbfn)(struct bnad *);
371 struct bfa_wc chld_stop_wc;
373 struct bfa_msgq_cmd_entry msgq_cmd;
374 struct bfi_enet_set_pause_req pause_req;
383 enum bna_ethport_flags flags;
385 enum bna_link_status link_status;
387 int rx_started_count;
389 void (*stop_cbfn)(struct bna_enet *);
391 void (*adminup_cbfn)(struct bnad *, enum bna_cb_status);
393 void (*link_cbfn)(struct bnad *, enum bna_link_status);
395 struct bfa_msgq_cmd_entry msgq_cmd;
397 struct bfi_enet_enable_req admin_req;
398 struct bfi_enet_diag_lb_req lpbk_req;
404 /* Interrupt Block */
406 /* Doorbell structure */
407 struct bna_ib_dbell {
408 void __iomem *doorbell_addr;
414 struct bna_dma_addr ib_seg_host_addr;
415 void *ib_seg_host_addr_kva;
417 struct bna_ib_dbell door_bell;
419 enum bna_intr_type intr_type;
422 u8 coalescing_timeo; /* Unit is 5usec. */
430 /* Tx datapath control structure */
431 #define BNA_Q_NAME_SIZE 16
439 volatile u32 *hw_consumer_index;
441 void __iomem *q_dbell;
442 struct bna_ib_dbell *i_dbell;
446 void *priv; /* BNAD's cookie */
447 enum bna_intr_type intr_type;
449 u8 priority; /* Current priority */
450 unsigned long flags; /* Used by bnad as required */
452 char name[BNA_Q_NAME_SIZE];
455 /* TxQ QPT and configuration */
457 /* This should be the first one */
476 /* This should be the first one */
482 enum bna_tx_flags flags;
484 enum bna_tx_type type;
487 struct list_head txq_q;
490 /* Tx event handlers */
491 void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
492 void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
493 void (*tx_stall_cbfn)(struct bnad *, struct bna_tx *);
494 void (*tx_resume_cbfn)(struct bnad *, struct bna_tx *);
495 void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tx *);
497 /* callback for bna_tx_disable(), bna_tx_stop() */
498 void (*stop_cbfn)(void *arg, struct bna_tx *tx);
501 /* callback for bna_tx_prio_set() */
502 void (*prio_change_cbfn)(struct bnad *bnad, struct bna_tx *tx);
504 struct bfa_msgq_cmd_entry msgq_cmd;
506 struct bfi_enet_tx_cfg_req cfg_req;
507 struct bfi_enet_req req;
508 struct bfi_enet_tx_cfg_rsp cfg_rsp;
512 void *priv; /* bnad's cookie */
515 /* Tx object configuration used during creation */
516 struct bna_tx_config {
519 int coalescing_timeo;
520 enum bna_tx_type tx_type;
523 struct bna_tx_event_cbfn {
525 void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
526 void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
528 void (*tx_stall_cbfn)(struct bnad *, struct bna_tx *);
529 void (*tx_resume_cbfn)(struct bnad *, struct bna_tx *);
530 void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tx *);
533 /* Tx module - keeps track of free, active tx objects */
535 struct bna_tx *tx; /* BFI_MAX_TXQ entries */
536 struct bna_txq *txq; /* BFI_MAX_TXQ entries */
538 struct list_head tx_free_q;
539 struct list_head tx_active_q;
541 struct list_head txq_free_q;
543 /* callback for bna_tx_mod_stop() */
544 void (*stop_cbfn)(struct bna_enet *enet);
546 struct bfa_wc tx_stop_wc;
548 enum bna_tx_mod_flags flags;
554 int prio_reconfigured;
563 /* Rx datapath control structure */
572 void __iomem *q_dbell;
577 void *priv; /* BNAD's cookie */
582 /* RxQ structure - QPT, configuration */
589 enum bna_status multi_buffer;
601 u64 rx_packets_with_error;
602 u64 rxbuf_alloc_failed;
609 struct bna_rxq *data;
612 struct bna_rxq *small;
613 struct bna_rxq *large;
616 struct bna_rxq *only;
617 struct bna_rxq *reserved;
621 /* Packet rate for Dynamic Interrupt Moderation */
622 struct bna_pkt_rate {
627 /* Completion control structure */
633 volatile u32 *hw_producer_index;
635 struct bna_ib_dbell *i_dbell;
636 struct bna_rcb *rcb[2];
637 void *ctrl; /* For bnad */
638 struct bna_pkt_rate pkt_rate;
645 void *priv; /* BNAD's cookie */
646 enum bna_intr_type intr_type;
648 u8 rx_coalescing_timeo; /* For NAPI */
650 char name[BNA_Q_NAME_SIZE];
653 /* CQ QPT, configuration */
663 struct bna_rss_config {
664 enum bfi_enet_rss_type hash_type;
666 u32 toeplitz_hash_key[BFI_ENET_RSS_KEY_LEN];
669 struct bna_hds_config {
670 enum bfi_enet_hds_type hdr_type;
674 /* Rx object configuration used during creation */
675 struct bna_rx_config {
676 enum bna_rx_type rx_type;
678 enum bna_rxp_type rxp_type;
680 int coalescing_timeo;
682 * Small/Large (or Header/Data) buffer size to be configured
683 * for SLR and HDS queue type.
687 /* header or small queue */
691 /* data or large queue */
695 enum bna_status q0_multi_buf;
697 enum bna_status rss_status;
698 struct bna_rss_config rss_config;
700 struct bna_hds_config hds_config;
702 enum bna_status vlan_strip_status;
705 /* Rx Path structure - one per MSIX vector/CPU */
707 /* This should be the first one */
710 enum bna_rxp_type type;
716 /* MSI-x vector number for configuring RSS */
721 /* RxF structure (hardware Rx Function) */
724 enum bna_rxf_flags flags;
726 struct bfa_msgq_cmd_entry msgq_cmd;
728 struct bfi_enet_enable_req req;
729 struct bfi_enet_rss_cfg_req rss_req;
730 struct bfi_enet_rit_req rit_req;
731 struct bfi_enet_rx_vlan_req vlan_req;
732 struct bfi_enet_mcast_add_req mcast_add_req;
733 struct bfi_enet_mcast_del_req mcast_del_req;
734 struct bfi_enet_ucast_req ucast_req;
737 /* callback for bna_rxf_start() */
738 void (*start_cbfn) (struct bna_rx *rx);
739 struct bna_rx *start_cbarg;
741 /* callback for bna_rxf_stop() */
742 void (*stop_cbfn) (struct bna_rx *rx);
743 struct bna_rx *stop_cbarg;
745 /* callback for bna_rx_receive_pause() / bna_rx_receive_resume() */
746 void (*oper_state_cbfn) (struct bnad *bnad, struct bna_rx *rx);
747 struct bnad *oper_state_cbarg;
751 * bna_rxf_ucast_set()
752 * bna_rxf_{ucast/mcast}_add(),
753 * bna_rxf_{ucast/mcast}_del(),
756 void (*cam_fltr_cbfn)(struct bnad *bnad, struct bna_rx *rx);
757 struct bnad *cam_fltr_cbarg;
759 /* List of unicast addresses yet to be applied to h/w */
760 struct list_head ucast_pending_add_q;
761 struct list_head ucast_pending_del_q;
762 struct bna_mac *ucast_pending_mac;
763 int ucast_pending_set;
764 /* ucast addresses applied to the h/w */
765 struct list_head ucast_active_q;
766 struct bna_mac ucast_active_mac;
767 int ucast_active_set;
769 /* List of multicast addresses yet to be applied to h/w */
770 struct list_head mcast_pending_add_q;
771 struct list_head mcast_pending_del_q;
772 /* multicast addresses applied to the h/w */
773 struct list_head mcast_active_q;
774 struct list_head mcast_handle_q;
776 /* Rx modes yet to be applied to h/w */
777 enum bna_rxmode rxmode_pending;
778 enum bna_rxmode rxmode_pending_bitmask;
779 /* Rx modes applied to h/w */
780 enum bna_rxmode rxmode_active;
782 u8 vlan_pending_bitmask;
783 enum bna_status vlan_filter_status;
784 u32 vlan_filter_table[(BFI_ENET_VLAN_ID_MAX) / 32];
785 bool vlan_strip_pending;
786 enum bna_status vlan_strip_status;
788 enum bna_rss_flags rss_pending;
789 enum bna_status rss_status;
790 struct bna_rss_config rss_cfg;
799 /* This should be the first one */
806 enum bna_rx_type type;
809 struct list_head rxp_q;
811 struct bna_hds_config hds_cfg;
815 enum bna_rx_flags rx_flags;
817 struct bfa_msgq_cmd_entry msgq_cmd;
819 struct bfi_enet_rx_cfg_req cfg_req;
820 struct bfi_enet_req req;
821 struct bfi_enet_rx_cfg_rsp cfg_rsp;
824 /* Rx event handlers */
825 void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
826 void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
827 void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
828 void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
829 void (*rx_stall_cbfn)(struct bnad *, struct bna_rx *);
830 void (*rx_cleanup_cbfn)(struct bnad *, struct bna_rx *);
831 void (*rx_post_cbfn)(struct bnad *, struct bna_rx *);
833 /* callback for bna_rx_disable(), bna_rx_stop() */
834 void (*stop_cbfn)(void *arg, struct bna_rx *rx);
838 void *priv; /* bnad's cookie */
841 struct bna_rx_event_cbfn {
843 void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
844 void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
845 void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
846 void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
847 void (*rx_stall_cbfn)(struct bnad *, struct bna_rx *);
849 void (*rx_cleanup_cbfn)(struct bnad *, struct bna_rx *);
850 void (*rx_post_cbfn)(struct bnad *, struct bna_rx *);
853 /* Rx module - keeps track of free, active rx objects */
855 struct bna *bna; /* back pointer to parent */
856 struct bna_rx *rx; /* BFI_MAX_RXQ entries */
857 struct bna_rxp *rxp; /* BFI_MAX_RXQ entries */
858 struct bna_rxq *rxq; /* BFI_MAX_RXQ entries */
860 struct list_head rx_free_q;
861 struct list_head rx_active_q;
864 struct list_head rxp_free_q;
867 struct list_head rxq_free_q;
870 enum bna_rx_mod_flags flags;
872 /* callback for bna_rx_mod_stop() */
873 void (*stop_cbfn)(struct bna_enet *enet);
875 struct bfa_wc rx_stop_wc;
876 u32 dim_vector[BNA_LOAD_T_MAX][BNA_BIAS_T_MAX];
882 struct bna_ucam_mod {
883 struct bna_mac *ucmac; /* num_ucmac * 2 entries */
884 struct list_head free_q;
885 struct list_head del_q;
890 struct bna_mcam_handle {
891 /* This should be the first one */
897 struct bna_mcam_mod {
898 struct bna_mac *mcmac; /* num_mcmac * 2 entries */
899 struct bna_mcam_handle *mchandle; /* num_mcmac entries */
900 struct list_head free_q;
901 struct list_head del_q;
902 struct list_head free_handle_q;
910 struct bna_dma_addr hw_stats_dma;
911 struct bfi_enet_stats *hw_stats_kva;
912 struct bfi_enet_stats hw_stats;
915 struct bna_stats_mod {
919 struct bfa_msgq_cmd_entry stats_get_cmd;
920 struct bfa_msgq_cmd_entry stats_clr_cmd;
921 struct bfi_enet_stats_req stats_get;
922 struct bfi_enet_stats_req stats_clr;
928 struct bna_ident ident;
929 struct bfa_pcidev pcidev;
932 struct bna_bit_defn bits;
934 struct bna_stats stats;
936 struct bna_ioceth ioceth;
938 struct bfa_flash flash;
939 struct bfa_msgq msgq;
941 struct bna_ethport ethport;
942 struct bna_enet enet;
943 struct bna_stats_mod stats_mod;
945 struct bna_tx_mod tx_mod;
946 struct bna_rx_mod rx_mod;
947 struct bna_ucam_mod ucam_mod;
948 struct bna_mcam_mod mcam_mod;
950 enum bna_mod_flags mod_flags;
952 int default_mode_rid;
957 #endif /* __BNA_TYPES_H__ */