xref: /illumos-gate/usr/src/uts/common/io/ntxn/unm_nic_hw.h (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 NetXen, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 #ifndef _UNM_NIC_HW_
26 #define	_UNM_NIC_HW_
27 
28 #include "unm_inc.h"
29 
30 /* Hardware memory size of 128 meg */
31 #define	BAR0_SIZE (128 * 1024 * 1024)
32 /*
33  * It can be calculated by looking at the first 1 bit of the BAR0 addr after
34  * bit 4 For us lets assume that BAR0 is D8000008, then the size is 0x8000000,
35  * 8 represents first bit containing 1.   FSL temp notes....pg 162 of PCI
36  * systems arch...
37  */
38 
39 #define	UNM_NIC_HW_BLOCK_WRITE_64(DATA_PTR, ADDR, NUM_WORDS)        \
40 {                                                           \
41 	int i;                                              \
42 	u64 *a = (u64 *) (DATA_PTR);                        \
43 	u64 *b = (u64 *) (ADDR);                            \
44 	u64 tmp;					    \
45 	for (i = 0; i < (NUM_WORDS); i++, a++, b++) {       \
46 		tmp = UNM_NIC_PCI_READ_64(a);		    \
47 		UNM_NIC_PCI_WRITE_64(tmp, b);		    \
48 	}						    \
49 }
50 
51 #define	UNM_NIC_HW_BLOCK_READ_64(DATA_PTR, ADDR, NUM_WORDS)           \
52 {                                                             \
53 	int i;                                                \
54 	u64 *a = (u64 *) (DATA_PTR);                          \
55 	u64 *b = (u64 *) (ADDR);                              \
56 	u64 tmp;					      \
57 	for (i = 0; i < (NUM_WORDS); i++, a++, b++) {            \
58 		tmp = UNM_NIC_PCI_READ_64(b);		      \
59 		UNM_NIC_PCI_WRITE_64(tmp, a);		      \
60 	}                                                     \
61 }
62 
63 #define	UNM_PCI_MAPSIZE_BYTES  (UNM_PCI_MAPSIZE << 20)
64 
65 #define	UNM_NIC_LOCKED_READ_REG(X, Y)   \
66 	addr = (void *)(pci_base_offset(adapter, (X)));     \
67 	*(uint32_t *)(Y) = UNM_NIC_PCI_READ_32(addr);
68 
69 #define	UNM_NIC_LOCKED_WRITE_REG(X, Y)   \
70 	addr = (void *)(pci_base_offset(adapter, (X))); \
71 	UNM_NIC_PCI_WRITE_32(*(uint32_t *)(Y), addr);
72 
73 /* For Multicard support */
74 #define	UNM_CRB_READ_VAL_ADAPTER(ADDR, ADAPTER) \
75 	unm_crb_read_val_adapter((ADDR), (struct unm_adapter_s *)ADAPTER)
76 
77 #define	UNM_CRB_READ_CHECK_ADAPTER(ADDR, VALUE, ADAPTER)		\
78 	{								\
79 		if (unm_crb_read_adapter(ADDR, VALUE,			\
80 		    (struct unm_adapter_s *)ADAPTER)) return -1;	\
81 	}
82 
83 #define	UNM_CRB_WRITELIT_ADAPTER(ADDR, VALUE, ADAPTER)			\
84 	{								\
85 		adapter->unm_crb_writelit_adapter(			\
86 		    (struct unm_adapter_s *)ADAPTER,			\
87 		    (unsigned long)ADDR, (int)VALUE);			\
88 	}
89 
90 struct unm_adapter_s;
91 void unm_nic_set_link_parameters(struct unm_adapter_s *adapter);
92 long xge_mdio_init(struct unm_adapter_s *adapter);
93 void unm_nic_flash_print(struct unm_adapter_s *adapter);
94 void unm_nic_get_serial_num(struct unm_adapter_s *adapter);
95 
96 typedef struct {
97 	unsigned valid;
98 	unsigned start_128M;
99 	unsigned end_128M;
100 	unsigned start_2M;
101 } crb_128M_2M_sub_block_map_t;
102 
103 typedef struct {
104 	crb_128M_2M_sub_block_map_t sub_block[16];
105 } crb_128M_2M_block_map_t;
106 
107 #endif /* _UNM_NIC_HW_ */
108