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