xref: /illumos-gate/usr/src/uts/common/io/chxge/osdep.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
1*d39a76e7Sxw161283 /*
2*d39a76e7Sxw161283  * CDDL HEADER START
3*d39a76e7Sxw161283  *
4*d39a76e7Sxw161283  * The contents of this file are subject to the terms of the
5*d39a76e7Sxw161283  * Common Development and Distribution License (the "License").
6*d39a76e7Sxw161283  * You may not use this file except in compliance with the License.
7*d39a76e7Sxw161283  *
8*d39a76e7Sxw161283  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*d39a76e7Sxw161283  * or http://www.opensolaris.org/os/licensing.
10*d39a76e7Sxw161283  * See the License for the specific language governing permissions
11*d39a76e7Sxw161283  * and limitations under the License.
12*d39a76e7Sxw161283  *
13*d39a76e7Sxw161283  * When distributing Covered Code, include this CDDL HEADER in each
14*d39a76e7Sxw161283  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*d39a76e7Sxw161283  * If applicable, add the following below this CDDL HEADER, with the
16*d39a76e7Sxw161283  * fields enclosed by brackets "[]" replaced with your own identifying
17*d39a76e7Sxw161283  * information: Portions Copyright [yyyy] [name of copyright owner]
18*d39a76e7Sxw161283  *
19*d39a76e7Sxw161283  * CDDL HEADER END
20*d39a76e7Sxw161283  */
21*d39a76e7Sxw161283 
22*d39a76e7Sxw161283 /*
23*d39a76e7Sxw161283  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*d39a76e7Sxw161283  * Use is subject to license terms.
25*d39a76e7Sxw161283  */
26*d39a76e7Sxw161283 
27*d39a76e7Sxw161283 /*
28*d39a76e7Sxw161283  * This file is part of the Chelsio T1 Ethernet driver.
29*d39a76e7Sxw161283  *
30*d39a76e7Sxw161283  * Copyright (C) 2003-2005 Chelsio Communications.  All rights reserved.
31*d39a76e7Sxw161283  */
32*d39a76e7Sxw161283 
33*d39a76e7Sxw161283 #ifndef _CHELSIO_OSDEP_H
34*d39a76e7Sxw161283 #define	_CHELSIO_OSDEP_H
35*d39a76e7Sxw161283 
36*d39a76e7Sxw161283 #ifdef __cplusplus
37*d39a76e7Sxw161283 extern "C" {
38*d39a76e7Sxw161283 #endif
39*d39a76e7Sxw161283 
40*d39a76e7Sxw161283 /*
41*d39a76e7Sxw161283  * Solaris includes
42*d39a76e7Sxw161283  */
43*d39a76e7Sxw161283 #define	BIG_ENDIAN 4321
44*d39a76e7Sxw161283 #define	LITTLE_ENDIAN 1234
45*d39a76e7Sxw161283 #if defined(__sparc)
46*d39a76e7Sxw161283 #define	BYTE_ORDER BIG_ENDIAN
47*d39a76e7Sxw161283 #else
48*d39a76e7Sxw161283 #define	BYTE_ORDER LITTLE_ENDIAN
49*d39a76e7Sxw161283 #endif
50*d39a76e7Sxw161283 
51*d39a76e7Sxw161283 #include <sys/types.h>
52*d39a76e7Sxw161283 #include <sys/systm.h>
53*d39a76e7Sxw161283 #include <sys/param.h>
54*d39a76e7Sxw161283 #include <sys/kmem.h>
55*d39a76e7Sxw161283 #include <sys/stropts.h>
56*d39a76e7Sxw161283 #include <sys/cmn_err.h>
57*d39a76e7Sxw161283 #include <sys/varargs.h>
58*d39a76e7Sxw161283 #include <sys/stream.h>
59*d39a76e7Sxw161283 #include <sys/ddi.h>
60*d39a76e7Sxw161283 #include <sys/dlpi.h>
61*d39a76e7Sxw161283 #include <sys/ethernet.h>
62*d39a76e7Sxw161283 #include <sys/gld.h>
63*d39a76e7Sxw161283 #include "ostypes.h"
64*d39a76e7Sxw161283 
65*d39a76e7Sxw161283 #include "oschtoe.h"
66*d39a76e7Sxw161283 #include "ch_compat.h"
67*d39a76e7Sxw161283 
68*d39a76e7Sxw161283 #include "ch.h"
69*d39a76e7Sxw161283 
70*d39a76e7Sxw161283 #define	FILE_IDENT(a) static char *id = a
71*d39a76e7Sxw161283 
72*d39a76e7Sxw161283 #define	ETH_ALEN 6
73*d39a76e7Sxw161283 
74*d39a76e7Sxw161283 typedef struct ch peobj;
75*d39a76e7Sxw161283 typedef uint32_t u_int32_t;
76*d39a76e7Sxw161283 typedef uint16_t u_int16_t;
77*d39a76e7Sxw161283 typedef	kstat_t	*p_kstat_t;
78*d39a76e7Sxw161283 
79*d39a76e7Sxw161283 #define	os_printf printf
80*d39a76e7Sxw161283 
81*d39a76e7Sxw161283 #define	memcpy(dst, src, cnt) bcopy((src), (dst), (cnt))
82*d39a76e7Sxw161283 
83*d39a76e7Sxw161283 #define	adapter_name(chp) (chp->ch_name)
84*d39a76e7Sxw161283 
85*d39a76e7Sxw161283 typedef struct ch adapter_t;
86*d39a76e7Sxw161283 
87*d39a76e7Sxw161283 #define	DELAY_US(x) DELAY(x)
88*d39a76e7Sxw161283 #define	DELAY_MS(x) DELAY(1000*(x))
89*d39a76e7Sxw161283 
90*d39a76e7Sxw161283 #define	TPI_LOCK(obj)	mutex_enter(&obj->ch_lock);
91*d39a76e7Sxw161283 #define	TPI_UNLOCK(obj)	mutex_exit(&obj->ch_lock);
92*d39a76e7Sxw161283 #define	MAC_LOCK(lock)	mutex_enter(&(lock))
93*d39a76e7Sxw161283 #define	MAC_UNLOCK(lock)	mutex_exit(&(lock))
94*d39a76e7Sxw161283 #define	__tpi_read  tpi_read
95*d39a76e7Sxw161283 #define	__tpi_write tpi_write
96*d39a76e7Sxw161283 
97*d39a76e7Sxw161283 struct t1_rx_mode {
98*d39a76e7Sxw161283 	struct ch *chp;
99*d39a76e7Sxw161283 	struct ch_mc *mc;
100*d39a76e7Sxw161283 };
101*d39a76e7Sxw161283 
102*d39a76e7Sxw161283 #define	t1_rx_mode_promisc(rmp)  (rmp->chp->ch_flags & PEPROMISC)
103*d39a76e7Sxw161283 #define	t1_rx_mode_allmulti(rmp) (rmp->chp->ch_flags & PEALLMULTI)
104*d39a76e7Sxw161283 #define	t1_rx_mode_mc_cnt(rmp)   (rmp->chp->ch_mc_cnt)
105*d39a76e7Sxw161283 uint8_t *t1_get_next_mcaddr(struct t1_rx_mode *);
106*d39a76e7Sxw161283 
107*d39a76e7Sxw161283 #define	__devinit
108*d39a76e7Sxw161283 
109*d39a76e7Sxw161283 void t1_os_elmer0_ext_intr(adapter_t *adapter);
110*d39a76e7Sxw161283 
111*d39a76e7Sxw161283 void t1_os_link_changed(ch_t *adapter, int port_id, int link_status,
112*d39a76e7Sxw161283     int speed, int duplex, int fc);
113*d39a76e7Sxw161283 
114*d39a76e7Sxw161283 #define	CH_DBG(fmt, ...)
115*d39a76e7Sxw161283 
116*d39a76e7Sxw161283 #define	CH_MSG(fmt, ...)
117*d39a76e7Sxw161283 
118*d39a76e7Sxw161283 #define	t1_os_set_hw_addr(a, b, c) memcpy(a->port[b].enaddr, c, ETH_ALEN)
119*d39a76e7Sxw161283 
120*d39a76e7Sxw161283 /* kludge for now */
121*d39a76e7Sxw161283 #define	port_name(adapter, i) "chxge"
122*d39a76e7Sxw161283 
123*d39a76e7Sxw161283 #define	SPINLOCK kmutex_t
124*d39a76e7Sxw161283 #define	SPIN_LOCK_INIT(x) mutex_init(&(x), NULL, MUTEX_DRIVER, NULL);
125*d39a76e7Sxw161283 #undef SPIN_LOCK
126*d39a76e7Sxw161283 #define	SPIN_LOCK(x) mutex_enter(&(x))
127*d39a76e7Sxw161283 #define	SPIN_UNLOCK(x) mutex_exit(&(x))
128*d39a76e7Sxw161283 #define	SPIN_TRYLOCK(x) mutex_tryenter(&(x))
129*d39a76e7Sxw161283 #define	SPIN_LOCK_DESTROY(x) mutex_destroy(&(x))
130*d39a76e7Sxw161283 
131*d39a76e7Sxw161283 typedef struct ch_cyclic_s {
132*d39a76e7Sxw161283 	timeout_id_t timer;
133*d39a76e7Sxw161283 	void (*func)(void *);
134*d39a76e7Sxw161283 	void *arg;
135*d39a76e7Sxw161283 	clock_t period;
136*d39a76e7Sxw161283 } ch_cyclic_t, *p_ch_cyclic_t;
137*d39a76e7Sxw161283 
138*d39a76e7Sxw161283 void ch_init_cyclic(void *, p_ch_cyclic_t, void (*)(void *), void *);
139*d39a76e7Sxw161283 void ch_start_cyclic(p_ch_cyclic_t, unsigned long);
140*d39a76e7Sxw161283 void ch_stop_cyclic(p_ch_cyclic_t);
141*d39a76e7Sxw161283 void ch_cyclic(p_ch_cyclic_t);
142*d39a76e7Sxw161283 
143*d39a76e7Sxw161283 #ifdef __cplusplus
144*d39a76e7Sxw161283 }
145*d39a76e7Sxw161283 #endif
146*d39a76e7Sxw161283 
147*d39a76e7Sxw161283 #endif /* _CHELSIO_OSDEP_H */
148