aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/bna/bna_types.h
blob: 6877310f6ef4acffbfca169a94258862f3d257eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
/*
 * Linux network driver for Brocade Converged Network Adapter.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License (GPL) Version 2 as
 * published by the Free Software Foundation
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */
/*
 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
 * All rights reserved
 * www.brocade.com
 */
#ifndef __BNA_TYPES_H__
#define __BNA_TYPES_H__

#include "cna.h"
#include "bna_hw.h"
#include "bfa_cee.h"

/**
 *
 * Forward declarations
 *
 */

struct bna_txq;
struct bna_tx;
struct bna_rxq;
struct bna_cq;
struct bna_rx;
struct bna_rxf;
struct bna_port;
struct bna;
struct bnad;

/**
 *
 * Enums, primitive data types
 *
 */

enum bna_status {
	BNA_STATUS_T_DISABLED	= 0,
	BNA_STATUS_T_ENABLED	= 1
};

enum bna_cleanup_type {
	BNA_HARD_CLEANUP 	= 0,
	BNA_SOFT_CLEANUP 	= 1
};

enum bna_cb_status {
	BNA_CB_SUCCESS 		= 0,
	BNA_CB_FAIL		= 1,
	BNA_CB_INTERRUPT	= 2,
	BNA_CB_BUSY		= 3,
	BNA_CB_INVALID_MAC	= 4,
	BNA_CB_MCAST_LIST_FULL	= 5,
	BNA_CB_UCAST_CAM_FULL	= 6,
	BNA_CB_WAITING		= 7,
	BNA_CB_NOT_EXEC		= 8
};

enum bna_res_type {
	BNA_RES_T_MEM		= 1,
	BNA_RES_T_INTR		= 2
};

enum bna_mem_type {
	BNA_MEM_T_KVA 		= 1,
	BNA_MEM_T_DMA 		= 2
};

enum bna_intr_type {
	BNA_INTR_T_INTX		= 1,
	BNA_INTR_T_MSIX		= 2
};

enum bna_res_req_type {
	BNA_RES_MEM_T_COM 		= 0,
	BNA_RES_MEM_T_ATTR 		= 1,
	BNA_RES_MEM_T_FWTRC 		= 2,
	BNA_RES_MEM_T_STATS 		= 3,
	BNA_RES_MEM_T_SWSTATS		= 4,
	BNA_RES_MEM_T_IBIDX		= 5,
	BNA_RES_MEM_T_IB_ARRAY		= 6,
	BNA_RES_MEM_T_INTR_ARRAY	= 7,
	BNA_RES_MEM_T_IDXSEG_ARRAY	= 8,
	BNA_RES_MEM_T_TX_ARRAY		= 9,
	BNA_RES_MEM_T_TXQ_ARRAY		= 10,
	BNA_RES_MEM_T_RX_ARRAY		= 11,
	BNA_RES_MEM_T_RXP_ARRAY		= 12,
	BNA_RES_MEM_T_RXQ_ARRAY		= 13,
	BNA_RES_MEM_T_UCMAC_ARRAY	= 14,
	BNA_RES_MEM_T_MCMAC_ARRAY	= 15,
	BNA_RES_MEM_T_RIT_ENTRY		= 16,
	BNA_RES_MEM_T_RIT_SEGMENT	= 17,
	BNA_RES_INTR_T_MBOX		= 18,
	BNA_RES_T_MAX
};

enum bna_tx_res_req_type {
	BNA_TX_RES_MEM_T_TCB	= 0,
	BNA_TX_RES_MEM_T_UNMAPQ	= 1,
	BNA_TX_RES_MEM_T_QPT 	= 2,
	BNA_TX_RES_MEM_T_SWQPT	= 3,
	BNA_TX_RES_MEM_T_PAGE 	= 4,
	BNA_TX_RES_INTR_T_TXCMPL = 5,
	BNA_TX_RES_T_MAX,
};

enum bna_rx_mem_type {
	BNA_RX_RES_MEM_T_CCB		= 0,	/* CQ context */
	BNA_RX_RES_MEM_T_RCB		= 1,	/* CQ context */
	BNA_RX_RES_MEM_T_UNMAPQ		= 2,	/* UnmapQ for RxQs */
	BNA_RX_RES_MEM_T_CQPT		= 3,	/* CQ QPT */
	BNA_RX_RES_MEM_T_CSWQPT		= 4,	/* S/W QPT */
	BNA_RX_RES_MEM_T_CQPT_PAGE	= 5,	/* CQPT page */
	BNA_RX_RES_MEM_T_HQPT		= 6,	/* RX QPT */
	BNA_RX_RES_MEM_T_DQPT		= 7,	/* RX QPT */
	BNA_RX_RES_MEM_T_HSWQPT		= 8,	/* RX s/w QPT */
	BNA_RX_RES_MEM_T_DSWQPT		= 9,	/* RX s/w QPT */
	BNA_RX_RES_MEM_T_DPAGE		= 10,	/* RX s/w QPT */
	BNA_RX_RES_MEM_T_HPAGE		= 11,	/* RX s/w QPT */
	BNA_RX_RES_T_INTR		= 12,	/* Rx interrupts */
	BNA_RX_RES_T_MAX		= 13
};

enum bna_mbox_state {
	BNA_MBOX_FREE		= 0,
	BNA_MBOX_POSTED		= 1
};

enum bna_tx_type {
	BNA_TX_T_REGULAR	= 0,
	BNA_TX_T_LOOPBACK	= 1,
};

enum bna_tx_flags {
	BNA_TX_F_PORT_STARTED	= 1,
	BNA_TX_F_ENABLED	= 2,
	BNA_TX_F_PRIO_LOCK	= 4,
};

enum bna_tx_mod_flags {
	BNA_TX_MOD_F_PORT_STARTED	= 1,
	BNA_TX_MOD_F_PORT_LOOPBACK	= 2,
};

enum bna_rx_type {
	BNA_RX_T_REGULAR	= 0,
	BNA_RX_T_LOOPBACK	= 1,
};

enum bna_rxp_type {
	BNA_RXP_SINGLE 		= 1,
	BNA_RXP_SLR 		= 2,
	BNA_RXP_HDS 		= 3
};

enum bna_rxmode {
	BNA_RXMODE_PROMISC 	= 1,
	BNA_RXMODE_DEFAULT 	= 2,
	BNA_RXMODE_ALLMULTI 	= 4
};

enum bna_rx_event {
	RX_E_START			= 1,
	RX_E_STOP			= 2,
	RX_E_FAIL			= 3,
	RX_E_RXF_STARTED		= 4,
	RX_E_RXF_STOPPED		= 5,
	RX_E_RXQ_STOPPED		= 6,
};

enum bna_rx_state {
	BNA_RX_STOPPED			= 1,
	BNA_RX_RXF_START_WAIT		= 2,
	BNA_RX_STARTED			= 3,
	BNA_RX_RXF_STOP_WAIT		= 4,
	BNA_RX_RXQ_STOP_WAIT		= 5,
};

enum bna_rx_flags {
	BNA_RX_F_ENABLE		= 0x01,		/* bnad enabled rxf */
	BNA_RX_F_PORT_ENABLED	= 0x02,		/* Port object is enabled */
	BNA_RX_F_PORT_FAILED	= 0x04,		/* Port in failed state */
};

enum bna_rx_mod_flags {
	BNA_RX_MOD_F_PORT_STARTED	= 1,
	BNA_RX_MOD_F_PORT_LOOPBACK	= 2,
};

enum bna_rxf_oper_state {
	BNA_RXF_OPER_STATE_RUNNING	= 0x01, /* rxf operational */
	BNA_RXF_OPER_STATE_PAUSED	= 0x02,	/* rxf in PAUSED state */
};

enum bna_rxf_flags {
	BNA_RXF_FL_STOP_PENDING 	= 0x01,
	BNA_RXF_FL_FAILED		= 0x02,
	BNA_RXF_FL_RSS_CONFIG_PENDING	= 0x04,
	BNA_RXF_FL_OPERSTATE_CHANGED	= 0x08,
	BNA_RXF_FL_RXF_ENABLED		= 0x10,
	BNA_RXF_FL_VLAN_CONFIG_PENDING	= 0x20,
};

enum bna_rxf_event {
	RXF_E_START			= 1,
	RXF_E_STOP			= 2,
	RXF_E_FAIL			= 3,
	RXF_E_CAM_FLTR_MOD		= 4,
	RXF_E_STARTED			= 5,
	RXF_E_STOPPED			= 6,
	RXF_E_CAM_FLTR_RESP		= 7,
	RXF_E_PAUSE			= 8,
	RXF_E_RESUME			= 9,
	RXF_E_STAT_CLEARED		= 10,
};

enum bna_rxf_state {
	BNA_RXF_STOPPED			= 1,
	BNA_RXF_START_WAIT		= 2,
	BNA_RXF_CAM_FLTR_MOD_WAIT	= 3,
	BNA_RXF_STARTED			= 4,
	BNA_RXF_CAM_FLTR_CLR_WAIT	= 5,
	BNA_RXF_STOP_WAIT		= 6,
	BNA_RXF_PAUSE_WAIT		= 7,
	BNA_RXF_RESUME_WAIT		= 8,
	BNA_RXF_STAT_CLR_WAIT		= 9,
};

enum bna_port_type {
	BNA_PORT_T_REGULAR		= 0,
	BNA_PORT_T_LOOPBACK_INTERNAL	= 1,
	BNA_PORT_T_LOOPBACK_EXTERNAL	= 2,
};

enum bna_link_status {
	BNA_LINK_DOWN		= 0,
	BNA_LINK_UP		= 1,
	BNA_CEE_UP 		= 2
};

enum bna_llport_flags {
	BNA_LLPORT_F_ENABLED 	= 1,
	BNA_LLPORT_F_RX_ENABLED	= 2
};

enum bna_port_flags {
	BNA_PORT_F_DEVICE_READY	= 1,
	BNA_PORT_F_ENABLED	= 2,
	BNA_PORT_F_PAUSE_CHANGED = 4,
	BNA_PORT_F_MTU_CHANGED	= 8
};

enum bna_pkt_rates {
	BNA_PKT_RATE_10K		= 10000,
	BNA_PKT_RATE_20K		= 20000,
	BNA_PKT_RATE_30K		= 30000,
	BNA_PKT_RATE_40K		= 40000,
	BNA_PKT_RATE_50K		= 50000,
	BNA_PKT_RATE_60K		= 60000,
	BNA_PKT_RATE_70K		= 70000,
	BNA_PKT_RATE_80K		= 80000,
};

enum bna_dim_load_types {
	BNA_LOAD_T_HIGH_4		= 0, /* 80K <= r */
	BNA_LOAD_T_HIGH_3		= 1, /* 60K <= r < 80K */
	BNA_LOAD_T_HIGH_2		= 2, /* 50K <= r < 60K */
	BNA_LOAD_T_HIGH_1		= 3, /* 40K <= r < 50K */
	BNA_LOAD_T_LOW_1		= 4, /* 30K <= r < 40K */
	BNA_LOAD_T_LOW_2		= 5, /* 20K <= r < 30K */
	BNA_LOAD_T_LOW_3		= 6, /* 10K <= r < 20K */
	BNA_LOAD_T_LOW_4		= 7, /* r < 10K */
	BNA_LOAD_T_MAX			= 8
};

enum bna_dim_bias_types {
	BNA_BIAS_T_SMALL		= 0, /* small pkts > (large pkts * 2) */
	BNA_BIAS_T_LARGE		= 1, /* Not BNA_BIAS_T_SMALL */
	BNA_BIAS_T_MAX			= 2
};

struct bna_mac {
	/* This should be the first one */
	struct list_head			qe;
	u8			addr[ETH_ALEN];
};

struct bna_mem_descr {
	u32		len;
	void		*kva;
	struct bna_dma_addr dma;
};

struct bna_mem_info {
	enum bna_mem_type mem_type;
	u32		len;
	u32 		num;
	u32		align_sz; /* 0/1 = no alignment */
	struct bna_mem_descr *mdl;
	void			*cookie; /* For bnad to unmap dma later */
};

struct bna_intr_descr {
	int			vector;
};

struct bna_intr_info {
	enum bna_intr_type intr_type;
	int			num;
	struct bna_intr_descr *idl;
};

union bna_res_u {
	struct bna_mem_info mem_info;
	struct bna_intr_info intr_info;
};

struct bna_res_info {
	enum bna_res_type res_type;
	union bna_res_u		res_u;
};

/* HW QPT */
struct bna_qpt {
	struct bna_dma_addr hw_qpt_ptr;
	void		*kv_qpt_ptr;
	u32		page_count;
	u32		page_size;
};

/**
 *
 * Device
 *
 */

struct bna_device {
	bfa_fsm_t		fsm;
	struct bfa_ioc ioc;

	enum bna_intr_type intr_type;
	int			vector;

	void (*ready_cbfn)(struct bnad *bnad, enum bna_cb_status status);
	struct bnad *ready_cbarg;

	void (*stop_cbfn)(struct bnad *bnad, enum bna_cb_status status);
	struct bnad *stop_cbarg;

	struct bna *bna;
};

/**
 *
 * Mail box
 *
 */

struct bna_mbox_qe {
	/* This should be the first one */
	struct list_head			qe;

	struct bfa_mbox_cmd cmd;
	u32 		cmd_len;
	/* Callback for port, tx, rx, rxf */
	void (*cbfn)(void *arg, int status);
	void 			*cbarg;
};

struct bna_mbox_mod {
	enum bna_mbox_state state;
	struct list_head			posted_q;
	u32		msg_pending;
	u32		msg_ctr;
	struct bna *bna;
};

/**
 *
 * Port
 *
 */

/* Pause configuration */
struct bna_pause_config {
	enum bna_status tx_pause;
	enum bna_status rx_pause;
};

struct bna_llport {
	bfa_fsm_t		fsm;
	enum bna_llport_flags flags;

	enum bna_port_type type;

	enum bna_link_status link_status;

	int			admin_up_count;

	void (*stop_cbfn)(struct bna_port *, enum bna_cb_status);

	struct bna_mbox_qe mbox_qe;

	struct bna *bna;
};

struct bna_port {
	bfa_fsm_t		fsm;
	enum bna_port_flags flags;

	enum bna_port_type type;

	struct bna_llport llport;

	struct bna_pause_config pause_config;
	u8			priority;
	int			mtu;

	/* Callback for bna_port_disable(), port_stop() */
	void (*stop_cbfn)(void *, enum bna_cb_status);
	void			*stop_cbarg;

	/* Callback for bna_port_pause_config() */
	void (*pause_cbfn)(struct bnad *, enum bna_cb_status);

	/* Callback for bna_port_mtu_set() */
	void (*mtu_cbfn)(struct bnad *, enum bna_cb_status);

	void (*link_cbfn)(struct bnad *, enum bna_link_status);

	struct bfa_wc		chld_stop_wc;

	struct bna_mbox_qe mbox_qe;

	struct bna *bna;
};

/**
 *
 * Interrupt Block
 *
 */

/* IB index segment structure */
struct bna_ibidx_seg {
	/* This should be the first one */
	struct list_head			qe;

	u8			ib_seg_size;
	u8			ib_idx_tbl_offset;
};

/* Interrupt structure */
struct bna_intr {
	/* This should be the first one */
	struct list_head			qe;
	int			ref_count;

	enum bna_intr_type intr_type;
	int			vector;

	struct bna_ib *ib;
};

/* Doorbell structure */
struct bna_ib_dbell {
	void *__iomem doorbell_addr;
	u32		doorbell_ack;
};

/* Interrupt timer configuration */
struct bna_ib_config {
	u8 		coalescing_timeo;    /* Unit is 5usec. */

	int			interpkt_count;
	int			interpkt_timeo;

	enum ib_flags ctrl_flags;
};

/* IB structure */
struct bna_ib {
	/* This should be the first one */
	struct list_head			qe;

	int			ib_id;

	int			ref_count;
	int			start_count;

	struct bna_dma_addr ib_seg_host_addr;
	void		*ib_seg_host_addr_kva;
	u32		idx_mask; /* Size >= BNA_IBIDX_MAX_SEGSIZE */

	struct bna_ibidx_seg *idx_seg;

	struct bna_ib_dbell door_bell;

	struct bna_intr *intr;

	struct bna_ib_config ib_config;

	struct bna *bna;
};

/* IB module - keeps track of IBs and interrupts */
struct bna_ib_mod {
	struct bna_ib *ib;		/* BFI_MAX_IB entries */
	struct bna_intr *intr;		/* BFI_MAX_IB entries */
	struct bna_ibidx_seg *idx_seg;	/* BNA_IBIDX_TOTAL_SEGS */

	struct list_head			ib_free_q;

	struct list_head		ibidx_seg_pool[BFI_IBIDX_TOTAL_POOLS];

	struct list_head			intr_free_q;
	struct list_head			intr_active_q;

	struct bna *bna;
};

/**
 *
 * Tx object
 *
 */

/* Tx datapath control structure */
#define BNA_Q_NAME_SIZE		16
struct bna_tcb {
	/* Fast path */
	void			**sw_qpt;
	void			*unmap_q;
	u32		producer_index;
	u32		consumer_index;
	volatile u32	*hw_consumer_index;
	u32		q_depth;
	void *__iomem q_dbell;
	struct bna_ib_dbell *i_dbell;
	int			page_idx;
	int			page_count;
	/* Control path */
	struct bna_txq *txq;
	struct bnad *bnad;
	enum bna_intr_type intr_type;
	int			intr_vector;
	u8			priority; /* Current priority */
	unsigned long		flags; /* Used by bnad as required */
	int			id;
	char			name[BNA_Q_NAME_SIZE];
};

/* TxQ QPT and configuration */
struct bna_txq {
	/* This should be the first one */
	struct list_head			qe;

	int			txq_id;

	u8			priority;

	struct bna_qpt qpt;
	struct bna_tcb *tcb;
	struct bna_ib *ib;
	int			ib_seg_offset;

	struct bna_tx *tx;

	u64 		tx_packets;
	u64 		tx_bytes;
};

/* TxF structure (hardware Tx Function) */
struct bna_txf {
	int			txf_id;
	enum txf_flags ctrl_flags;
	u16		vlan;
};

/* Tx object */
struct bna_tx {
	/* This should be the first one */
	struct list_head			qe;

	bfa_fsm_t		fsm;
	enum bna_tx_flags flags;

	enum bna_tx_type type;

	struct list_head			txq_q;
	struct bna_txf txf;

	/* Tx event handlers */
	void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tx_stall_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tx_resume_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tcb *);

	/* callback for bna_tx_disable(), bna_tx_stop() */
	void (*stop_cbfn)(void *arg, struct bna_tx *tx,
				enum bna_cb_status status);
	void			*stop_cbarg;

	/* callback for bna_tx_prio_set() */
	void (*prio_change_cbfn)(struct bnad *bnad, struct bna_tx *tx,
				enum bna_cb_status status);

	struct bfa_wc		txq_stop_wc;

	struct bna_mbox_qe mbox_qe;

	struct bna *bna;
	void			*priv;	/* bnad's cookie */
};

struct bna_tx_config {
	int			num_txq;
	int			txq_depth;
	enum bna_tx_type tx_type;
};

struct bna_tx_event_cbfn {
	/* Optional */
	void (*tcb_setup_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tcb_destroy_cbfn)(struct bnad *, struct bna_tcb *);
	/* Mandatory */
	void (*tx_stall_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tx_resume_cbfn)(struct bnad *, struct bna_tcb *);
	void (*tx_cleanup_cbfn)(struct bnad *, struct bna_tcb *);
};

/* Tx module - keeps track of free, active tx objects */
struct bna_tx_mod {
	struct bna_tx *tx;		/* BFI_MAX_TXQ entries */
	struct bna_txq *txq;		/* BFI_MAX_TXQ entries */

	struct list_head			tx_free_q;
	struct list_head			tx_active_q;

	struct list_head			txq_free_q;

	/* callback for bna_tx_mod_stop() */
	void (*stop_cbfn)(struct bna_port *port,
				enum bna_cb_status status);

	struct bfa_wc		tx_stop_wc;

	enum bna_tx_mod_flags flags;

	int			priority;
	int			cee_link;

	u32		txf_bmap[2];

	struct bna *bna;
};

/**
 *
 * Receive Indirection Table
 *
 */

/* One row of RIT table */
struct bna_rit_entry {
	u8 large_rxq_id;	/* used for either large or data buffers */
	u8 small_rxq_id;	/* used for either small or header buffers */
};

/* RIT segment */
struct bna_rit_segment {
	struct list_head			qe;

	u32		rit_offset;
	u32		rit_size;
	/**
	 * max_rit_size: Varies per RIT segment depending on how RIT is
	 * partitioned
	 */
	u32		max_rit_size;

	struct bna_rit_entry *rit;
};

struct bna_rit_mod {
	struct bna_rit_entry *rit;
	struct bna_rit_segment *rit_segment;

	struct list_head		rit_seg_pool[BFI_RIT_SEG_TOTAL_POOLS];
};

/**
 *
 * Rx object
 *
 */

/* Rx datapath control structure */
struct bna_rcb {
	/* Fast path */
	void			**sw_qpt;
	void			*unmap_q;
	u32		producer_index;
	u32		consumer_index;
	u32		q_depth;
	void *__iomem q_dbell;
	int			page_idx;
	int			page_count;
	/* Control path */
	struct bna_rxq *rxq;
	struct bna_cq *cq;
	struct bnad *bnad;
	unsigned long		flags;
	int			id;
};

/* RxQ structure - QPT, configuration */
struct bna_rxq {
	struct list_head			qe;
	int			rxq_id;

	int			buffer_size;
	int			q_depth;

	struct bna_qpt qpt;
	struct bna_rcb *rcb;

	struct bna_rxp *rxp;
	struct bna_rx *rx;

	u64 		rx_packets;
	u64		rx_bytes;
	u64 		rx_packets_with_error;
	u64 		rxbuf_alloc_failed;
};

/* RxQ pair */
union bna_rxq_u {
	struct {
		struct bna_rxq *hdr;
		struct bna_rxq *data;
	} hds;
	struct {
		struct bna_rxq *small;
		struct bna_rxq *large;
	} slr;
	struct {
		struct bna_rxq *only;
		struct bna_rxq *reserved;
	} single;
};

/* Packet rate for Dynamic Interrupt Moderation */
struct bna_pkt_rate {
	u32		small_pkt_cnt;
	u32		large_pkt_cnt;
};

/* Completion control structure */
struct bna_ccb {
	/* Fast path */
	void			**sw_qpt;
	u32		producer_index;
	volatile u32	*hw_producer_index;
	u32		q_depth;
	struct bna_ib_dbell *i_dbell;
	struct bna_rcb *rcb[2];
	void			*ctrl; /* For bnad */
	struct bna_pkt_rate pkt_rate;
	int			page_idx;
	int			page_count;

	/* Control path */
	struct bna_cq *cq;
	struct bnad *bnad;
	enum bna_intr_type intr_type;
	int			intr_vector;
	u8			rx_coalescing_timeo; /* For NAPI */
	int			id;
	char			name[BNA_Q_NAME_SIZE];
};

/* CQ QPT, configuration  */
struct bna_cq {
	int			cq_id;

	struct bna_qpt qpt;
	struct bna_ccb *ccb;

	struct bna_ib *ib;
	u8			ib_seg_offset;

	struct bna_rx *rx;
};

struct bna_rss_config {
	enum rss_hash_type hash_type;
	u8			hash_mask;
	u32		toeplitz_hash_key[BFI_RSS_HASH_KEY_LEN];
};

struct bna_hds_config {
	enum hds_header_type hdr_type;
	int			header_size;
};

/* This structure is used during RX creation */
struct bna_rx_config {
	enum bna_rx_type rx_type;
	int			num_paths;
	enum bna_rxp_type rxp_type;
	int			paused;
	int			q_depth;
	/*
	 * Small/Large (or Header/Data) buffer size to be configured
	 * for SLR and HDS queue type. Large buffer size comes from
	 * port->mtu.
	 */
	int			small_buff_size;

	enum bna_status rss_status;
	struct bna_rss_config rss_config;

	enum bna_status hds_status;
	struct bna_hds_config hds_config;

	enum bna_status vlan_strip_status;
};

/* Rx Path structure - one per MSIX vector/CPU */
struct bna_rxp {
	/* This should be the first one */
	struct list_head			qe;

	enum bna_rxp_type type;
	union	bna_rxq_u	rxq;
	struct bna_cq cq;

	struct bna_rx *rx;

	/* MSI-x vector number for configuring RSS */
	int			vector;

	struct bna_mbox_qe mbox_qe;
};

/* HDS configuration structure */
struct bna_rxf_hds {
	enum hds_header_type hdr_type;
	int			header_size;
};

/* RSS configuration structure */
struct bna_rxf_rss {
	enum rss_hash_type hash_type;
	u8			hash_mask;
	u32		toeplitz_hash_key[BFI_RSS_HASH_KEY_LEN];
};

/* RxF structure (hardware Rx Function) */
struct bna_rxf {
	bfa_fsm_t		fsm;
	int			rxf_id;
	enum rxf_flags ctrl_flags;
	u16		default_vlan_tag;
	enum bna_rxf_oper_state rxf_oper_state;
	enum bna_status hds_status;
	struct bna_rxf_hds hds_cfg;
	enum bna_status rss_status;
	struct bna_rxf_rss rss_cfg;
	struct bna_rit_segment *rit_segment;
	struct bna_rx *rx;
	u32		forced_offset;
	struct bna_mbox_qe mbox_qe;
	int			mcast_rxq_id;

	/* callback for bna_rxf_start() */
	void (*start_cbfn) (struct bna_rx *rx, enum bna_cb_status status);
	struct bna_rx *start_cbarg;

	/* callback for bna_rxf_stop() */
	void (*stop_cbfn) (struct bna_rx *rx, enum bna_cb_status status);
	struct bna_rx *stop_cbarg;

	/* callback for bna_rxf_receive_enable() / bna_rxf_receive_disable() */
	void (*oper_state_cbfn) (struct bnad *bnad, struct bna_rx *rx,
			enum bna_cb_status status);
	struct bnad *oper_state_cbarg;

	/**
	 * callback for:
	 *	bna_rxf_ucast_set()
	 *	bna_rxf_{ucast/mcast}_add(),
	 * 	bna_rxf_{ucast/mcast}_del(),
	 *	bna_rxf_mode_set()
	 */
	void (*cam_fltr_cbfn)(struct bnad *bnad, struct bna_rx *rx,
				enum bna_cb_status status);
	struct bnad *cam_fltr_cbarg;

	enum bna_rxf_flags rxf_flags;

	/* List of unicast addresses yet to be applied to h/w */
	struct list_head			ucast_pending_add_q;
	struct list_head			ucast_pending_del_q;
	int			ucast_pending_set;
	/* ucast addresses applied to the h/w */
	struct list_head			ucast_active_q;
	struct bna_mac *ucast_active_mac;

	/* List of multicast addresses yet to be applied to h/w */
	struct list_head			mcast_pending_add_q;
	struct list_head			mcast_pending_del_q;
	/* multicast addresses applied to the h/w */
	struct list_head			mcast_active_q;

	/* Rx modes yet to be applied to h/w */
	enum bna_rxmode rxmode_pending;
	enum bna_rxmode rxmode_pending_bitmask;
	/* Rx modes applied to h/w */
	enum bna_rxmode rxmode_active;

	enum bna_status vlan_filter_status;
	u32		vlan_filter_table[(BFI_MAX_VLAN + 1) / 32];
};

/* Rx object */
struct bna_rx {
	/* This should be the first one */
	struct list_head			qe;

	bfa_fsm_t		fsm;

	enum bna_rx_type type;

	/* list-head for RX path objects */
	struct list_head			rxp_q;

	struct bna_rxf rxf;

	enum bna_rx_flags rx_flags;

	struct bna_mbox_qe mbox_qe;

	struct bfa_wc		rxq_stop_wc;

	/* Rx event handlers */
	void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
	void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
	void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
	void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
	void (*rx_cleanup_cbfn)(struct bnad *, struct bna_ccb *);
	void (*rx_post_cbfn)(struct bnad *, struct bna_rcb *);

	/* callback for bna_rx_disable(), bna_rx_stop() */
	void (*stop_cbfn)(void *arg, struct bna_rx *rx,
				enum bna_cb_status status);
	void			*stop_cbarg;

	struct bna *bna;
	void			*priv; /* bnad's cookie */
};

struct bna_rx_event_cbfn {
	/* Optional */
	void (*rcb_setup_cbfn)(struct bnad *, struct bna_rcb *);
	void (*rcb_destroy_cbfn)(struct bnad *, struct bna_rcb *);
	void (*ccb_setup_cbfn)(struct bnad *, struct bna_ccb *);
	void (*ccb_destroy_cbfn)(struct bnad *, struct bna_ccb *);
	/* Mandatory */
	void (*rx_cleanup_cbfn)(struct bnad *, struct bna_ccb *);
	void (*rx_post_cbfn)(struct bnad *, struct bna_rcb *);
};

/* Rx module - keeps track of free, active rx objects */
struct bna_rx_mod {
	struct bna *bna;		/* back pointer to parent */
	struct bna_rx *rx;		/* BFI_MAX_RXQ entries */
	struct bna_rxp *rxp;		/* BFI_MAX_RXQ entries */
	struct bna_rxq *rxq;		/* BFI_MAX_RXQ entries */

	struct list_head			rx_free_q;
	struct list_head			rx_active_q;
	int			rx_free_count;

	struct list_head			rxp_free_q;
	int			rxp_free_count;

	struct list_head			rxq_free_q;
	int			rxq_free_count;

	enum bna_rx_mod_flags flags;

	/* callback for bna_rx_mod_stop() */
	void (*stop_cbfn)(struct bna_port *port,
				enum bna_cb_status status);

	struct bfa_wc		rx_stop_wc;
	u32		dim_vector[BNA_LOAD_T_MAX][BNA_BIAS_T_MAX];
	u32		rxf_bmap[2];
};

/**
 *
 * CAM
 *
 */

struct bna_ucam_mod {
	struct bna_mac *ucmac;		/* BFI_MAX_UCMAC entries */
	struct list_head			free_q;

	struct bna *bna;
};

struct bna_mcam_mod {
	struct bna_mac *mcmac;		/* BFI_MAX_MCMAC entries */
	struct list_head			free_q;

	struct bna *bna;
};

/**
 *
 * Statistics
 *
 */

struct bna_tx_stats {
	int			tx_state;
	int			tx_flags;
	int			num_txqs;
	u32		txq_bmap[2];
	int			txf_id;
};

struct bna_rx_stats {
	int			rx_state;
	int			rx_flags;
	int			num_rxps;
	int			num_rxqs;
	u32		rxq_bmap[2];
	u32		cq_bmap[2];
	int			rxf_id;
	int			rxf_state;
	int			rxf_oper_state;
	int			num_active_ucast;
	int			num_active_mcast;
	int			rxmode_active;
	int			vlan_filter_status;
	u32		vlan_filter_table[(BFI_MAX_VLAN + 1) / 32];
	int			rss_status;
	int			hds_status;
};

struct bna_sw_stats {
	int			device_state;
	int			port_state;
	int			port_flags;
	int			llport_state;
	int			priority;
	int			num_active_tx;
	int			num_active_rx;
	struct bna_tx_stats tx_stats[BFI_MAX_TXQ];
	struct bna_rx_stats rx_stats[BFI_MAX_RXQ];
};

struct bna_stats {
	u32		txf_bmap[2];
	u32		rxf_bmap[2];
	struct bfi_ll_stats	*hw_stats;
	struct bna_sw_stats *sw_stats;
};

/**
 *
 * BNA
 *
 */

struct bna {
	struct bfa_pcidev pcidev;

	int			port_num;

	struct bna_chip_regs regs;

	struct bna_dma_addr hw_stats_dma;
	struct bna_stats stats;

	struct bna_device device;
	struct bfa_cee cee;

	struct bna_mbox_mod mbox_mod;

	struct bna_port port;

	struct bna_tx_mod tx_mod;

	struct bna_rx_mod rx_mod;

	struct bna_ib_mod ib_mod;

	struct bna_ucam_mod ucam_mod;
	struct bna_mcam_mod mcam_mod;

	struct bna_rit_mod rit_mod;

	int			rxf_default_id;
	int			rxf_promisc_id;

	struct bna_mbox_qe mbox_qe;

	struct bnad *bnad;
};

#endif	/* __BNA_TYPES_H__ */