xref: /illumos-gate/usr/src/uts/common/io/chxge/osdep.h (revision 2d6eb4a5)
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 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * This file is part of the Chelsio T1 Ethernet driver.
29  *
30  * Copyright (C) 2003-2005 Chelsio Communications.  All rights reserved.
31  */
32 
33 #ifndef _CHELSIO_OSDEP_H
34 #define	_CHELSIO_OSDEP_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Solaris includes
42  */
43 #define	BIG_ENDIAN 4321
44 #define	LITTLE_ENDIAN 1234
45 #if defined(__sparc)
46 #define	BYTE_ORDER BIG_ENDIAN
47 #else
48 #define	BYTE_ORDER LITTLE_ENDIAN
49 #endif
50 
51 #include <sys/types.h>
52 #include <sys/systm.h>
53 #include <sys/param.h>
54 #include <sys/kmem.h>
55 #include <sys/stropts.h>
56 #include <sys/cmn_err.h>
57 #include <sys/varargs.h>
58 #include <sys/stream.h>
59 #include <sys/ddi.h>
60 #include <sys/dlpi.h>
61 #include <sys/ethernet.h>
62 #include <sys/gld.h>
63 #include "ostypes.h"
64 
65 #include "oschtoe.h"
66 #include "ch_compat.h"
67 
68 #include "ch.h"
69 
70 #define	FILE_IDENT(a) static char *id = a
71 
72 #define	ETH_ALEN 6
73 
74 typedef struct ch peobj;
75 typedef uint32_t u_int32_t;
76 typedef uint16_t u_int16_t;
77 typedef	kstat_t	*p_kstat_t;
78 
79 #define	os_printf printf
80 
81 #define	memcpy(dst, src, cnt) bcopy((src), (dst), (cnt))
82 
83 #define	adapter_name(chp) (chp->ch_name)
84 
85 typedef struct ch adapter_t;
86 
87 #define	DELAY_US(x) DELAY(x)
88 #define	DELAY_MS(x) DELAY(1000*(x))
89 
90 #define	TPI_LOCK(obj)	mutex_enter(&obj->ch_lock);
91 #define	TPI_UNLOCK(obj)	mutex_exit(&obj->ch_lock);
92 #define	MAC_LOCK(lock)	mutex_enter(&(lock))
93 #define	MAC_UNLOCK(lock)	mutex_exit(&(lock))
94 #define	__tpi_read  tpi_read
95 #define	__tpi_write tpi_write
96 
97 struct t1_rx_mode {
98 	struct ch *chp;
99 	struct ch_mc *mc;
100 };
101 
102 #define	t1_rx_mode_promisc(rmp)  (rmp->chp->ch_flags & PEPROMISC)
103 #define	t1_rx_mode_allmulti(rmp) (rmp->chp->ch_flags & PEALLMULTI)
104 #define	t1_rx_mode_mc_cnt(rmp)   (rmp->chp->ch_mc_cnt)
105 uint8_t *t1_get_next_mcaddr(struct t1_rx_mode *);
106 
107 #define	__devinit
108 
109 void t1_os_elmer0_ext_intr(adapter_t *adapter);
110 
111 void t1_os_link_changed(ch_t *adapter, int port_id, int link_status,
112     int speed, int duplex, int fc);
113 
114 #define	CH_DBG(fmt, ...)
115 
116 #define	CH_MSG(fmt, ...)
117 
118 #define	t1_os_set_hw_addr(a, b, c) memcpy(a->port[b].enaddr, c, ETH_ALEN)
119 
120 /* kludge for now */
121 #define	port_name(adapter, i) "chxge"
122 
123 #define	SPINLOCK kmutex_t
124 #define	SPIN_LOCK_INIT(x) mutex_init(&(x), NULL, MUTEX_DRIVER, NULL);
125 #undef SPIN_LOCK
126 #define	SPIN_LOCK(x) mutex_enter(&(x))
127 #define	SPIN_UNLOCK(x) mutex_exit(&(x))
128 #define	SPIN_TRYLOCK(x) mutex_tryenter(&(x))
129 #define	SPIN_LOCK_DESTROY(x) mutex_destroy(&(x))
130 
131 typedef struct ch_cyclic_s {
132 	timeout_id_t timer;
133 	void (*func)(void *);
134 	void *arg;
135 	clock_t period;
136 } ch_cyclic_t, *p_ch_cyclic_t;
137 
138 void ch_init_cyclic(void *, p_ch_cyclic_t, void (*)(void *), void *);
139 void ch_start_cyclic(p_ch_cyclic_t, unsigned long);
140 void ch_stop_cyclic(p_ch_cyclic_t);
141 void ch_cyclic(p_ch_cyclic_t);
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* _CHELSIO_OSDEP_H */
148