if_ne_pcmcia.c revision 1.120 1 /* $NetBSD: if_ne_pcmcia.c,v 1.120 2004/07/07 06:43:22 mycroft Exp $ */
2
3 /*
4 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Marc Horowitz.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: if_ne_pcmcia.c,v 1.120 2004/07/07 06:43:22 mycroft Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/select.h>
38 #include <sys/device.h>
39 #include <sys/socket.h>
40
41 #include <net/if_types.h>
42 #include <net/if.h>
43 #include <net/if_media.h>
44 #include <net/if_ether.h>
45
46 #include <machine/bus.h>
47 #include <machine/intr.h>
48
49 #include <dev/pcmcia/pcmciareg.h>
50 #include <dev/pcmcia/pcmciavar.h>
51 #include <dev/pcmcia/pcmciadevs.h>
52
53 #include <dev/ic/dp8390reg.h>
54 #include <dev/ic/dp8390var.h>
55
56 #include <dev/ic/ne2000reg.h>
57 #include <dev/ic/ne2000var.h>
58
59 #include <dev/ic/rtl80x9reg.h>
60 #include <dev/ic/rtl80x9var.h>
61
62 #include <dev/ic/dl10019var.h>
63
64 #include <dev/ic/ax88190reg.h>
65 #include <dev/ic/ax88190var.h>
66
67 int ne_pcmcia_match __P((struct device *, struct cfdata *, void *));
68 void ne_pcmcia_attach __P((struct device *, struct device *, void *));
69 int ne_pcmcia_detach __P((struct device *, int));
70
71 int ne_pcmcia_enable __P((struct dp8390_softc *));
72 void ne_pcmcia_disable __P((struct dp8390_softc *));
73
74 struct ne_pcmcia_softc {
75 struct ne2000_softc sc_ne2000; /* real "ne2000" softc */
76
77 /* PCMCIA-specific goo */
78 struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o information */
79 int sc_asic_io_window; /* i/o window for ASIC */
80 int sc_nic_io_window; /* i/o window for NIC */
81 struct pcmcia_function *sc_pf; /* our PCMCIA function */
82 void *sc_ih; /* interrupt handle */
83 };
84
85 u_int8_t *
86 ne_pcmcia_get_enaddr __P((struct ne_pcmcia_softc *, int,
87 u_int8_t [ETHER_ADDR_LEN]));
88 u_int8_t *
89 ne_pcmcia_dl10019_get_enaddr __P((struct ne_pcmcia_softc *,
90 u_int8_t [ETHER_ADDR_LEN]));
91 int ne_pcmcia_ax88190_set_iobase __P((struct ne_pcmcia_softc *));
92
93 CFATTACH_DECL(ne_pcmcia, sizeof(struct ne_pcmcia_softc),
94 ne_pcmcia_match, ne_pcmcia_attach, ne_pcmcia_detach, dp8390_activate);
95
96 static const struct ne2000dev {
97 int32_t manufacturer;
98 int32_t product;
99 char *cis_info[4];
100 int function;
101 int enet_maddr;
102 unsigned char enet_vendor[3];
103 int flags;
104 #define NE2000DVF_DL10019 0x0001 /* chip is D-Link DL10019 */
105 #define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */
106 #define NE2000DVF_AX88790 0x0004 /* chip is ASIX AX88790 */
107 } ne2000devs[] = {
108 { PCMCIA_VENDOR_EDIMAX, PCMCIA_PRODUCT_EDIMAX_EP4000A,
109 PCMCIA_CIS_EDIMAX_EP4000A,
110 0, -1, { 0x00, 0xa0, 0x0c } },
111
112 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
113 PCMCIA_CIS_SYNERGY21_S21810,
114 0, -1, { 0x00, 0x48, 0x54 } },
115
116 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
117 PCMCIA_CIS_AMBICOM_AMB8002T,
118 0, -1, { 0x00, 0x10, 0x7a } },
119
120 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
121 PCMCIA_CIS_AMBICOM_AMB8110,
122 0, -1, { 0x00, 0x10, 0x7a }, NE2000DVF_AX88190 },
123
124 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
125 PCMCIA_CIS_PREMAX_PE200,
126 0, 0x07f0, { 0x00, 0x20, 0xe0 } },
127
128 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
129 PCMCIA_CIS_PREMAX_PE200,
130 0, -1, { 0x00, 0x20, 0xe0 } },
131
132 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
133 PCMCIA_CIS_DIGITAL_DEPCMXX,
134 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
135
136 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
137 PCMCIA_CIS_PLANET_SMARTCOM2000,
138 0, 0xff0, { 0x00, 0x00, 0xe8 } },
139
140 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
141 PCMCIA_CIS_DLINK_DE660,
142 0, -1, { 0x00, 0x80, 0xc8 } },
143
144 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
145 PCMCIA_CIS_DLINK_DE660PLUS,
146 0, -1, { 0x00, 0x80, 0xc8 } },
147
148 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
149 PCMCIA_CIS_RPTI_EP400,
150 0, 0x110, { 0x00, 0x40, 0x95 } },
151
152 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
153 PCMCIA_CIS_RPTI_EP401,
154 0, -1, { 0x00, 0x40, 0x95 } },
155
156 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
157 PCMCIA_CIS_ACCTON_EN2212,
158 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
159
160 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
161 PCMCIA_CIS_ACCTON_EN2216,
162 0, -1, { 0x00, 0x00, 0xe8 } },
163
164 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
165 PCMCIA_CIS_SVEC_COMBOCARD,
166 0, -1, { 0x00, 0xe0, 0x98 } },
167
168 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
169 PCMCIA_CIS_SVEC_LANCARD,
170 0, 0x7f0, { 0x00, 0xc0, 0x6c } },
171
172 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_EPSON_EEN10B,
173 PCMCIA_CIS_EPSON_EEN10B,
174 0, 0xff0, { 0x00, 0x00, 0x48 } },
175
176 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
177 PCMCIA_CIS_TAMARACK_ETHERNET,
178 0, -1, { 0x00, 0x00, 0x00 } },
179
180 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
181 PCMCIA_CIS_CNET_NE2000,
182 0, -1, { 0x00, 0x80, 0xad } },
183
184 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
185 PCMCIA_CIS_GENIUS_ME3000II,
186 0, -1, { 0x00, 0x40, 0x95 } },
187
188
189 { PCMCIA_VENDOR_ZONET, PCMCIA_PRODUCT_ZONET_ZEN,
190 PCMCIA_CIS_ZONET_ZEN,
191 0, -1, { 0x00, 0x00, 0x00 } },
192
193 /*
194 * You have to add new entries which contains
195 * PCMCIA_VENDOR_INVALID and/or PCMCIA_PRODUCT_INVALID
196 * in front of this comment.
197 *
198 * There are cards which use a generic vendor and product id but needs
199 * a different handling depending on the cis_info, so ne2000_match
200 * needs a table where the exceptions comes first and then the normal
201 * product and vendor entries.
202 */
203
204 { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
205 PCMCIA_CIS_IBM_INFOMOVER,
206 0, 0x0ff0, { 0xff, 0xff, 0xff } },
207
208 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ECARD_1,
209 PCMCIA_CIS_LINKSYS_ECARD_1,
210 0, -1, { 0x00, 0x80, 0xc8 } },
211
212 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
213 PCMCIA_CIS_PLANEX_FNW3600T,
214 0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_DL10019 },
215
216 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
217 PCMCIA_CIS_SVEC_PN650TX,
218 0, -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 },
219
220 /*
221 * This entry should be here so that above two cards doesn't
222 * match with this. FNW-3700T won't match above entries due to
223 * MAC address check.
224 */
225 { PCMCIA_VENDOR_LANTECH, PCMCIA_PRODUCT_LANTECH_FASTNETTX,
226 PCMCIA_CIS_LANTECH_FASTNETTX,
227 0, -1, { 0x00, 0x04, 0x1c }, NE2000DVF_AX88190 },
228
229 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
230 PCMCIA_CIS_PLANEX_FNW3700T,
231 0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 },
232
233 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
234 PCMCIA_CIS_LINKSYS_ETHERFAST,
235 0, -1, { 0xff, 0xff, 0xff }, NE2000DVF_DL10019 },
236
237 /*
238 * There are two entries for the DFE-670TXD because there are
239 * several possible Vendor IDs for the MAC address. Both are
240 * from D-Link, though.
241 *
242 * Oh, wait, there's a third possible vendor code, apparently.
243 * And it's from "ANI Communications" this time...
244 */
245 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
246 PCMCIA_CIS_DLINK_DFE670TXD,
247 0, -1, { 0xff, 0xff, 0xff }, NE2000DVF_DL10019 },
248
249 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
250 PCMCIA_CIS_MELCO_LPC2_TX,
251 0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_DL10019 },
252
253 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
254 PCMCIA_CIS_LINKSYS_COMBO_ECARD,
255 0, -1, { 0x00, 0x80, 0xc8 } },
256
257 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_TRUST_COMBO_ECARD,
258 PCMCIA_CIS_LINKSYS_TRUST_COMBO_ECARD,
259 0, 0x0120, { 0x20, 0x04, 0x49 } },
260
261 /* Although the comments above say to put VENDOR/PRODUCT INVALID IDs
262 above this list, we need to keep this one below the ECARD_1, or else
263 both will match the same more-generic entry rather than the more
264 specific one above with proper vendor and product IDs. */
265 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
266 PCMCIA_CIS_LINKSYS_ECARD_2,
267 0, -1, { 0x00, 0x80, 0xc8 } },
268
269 /*
270 * D-Link DE-650 has many minor versions:
271 *
272 * CIS information Manufacturer Product Note
273 * 1 "D-Link, DE-650" INVALID INVALID white card
274 * 2 "D-Link, DE-650, Ver 01.00" INVALID INVALID became bare metal
275 * 3 "D-Link, DE-650, Ver 01.00" 0x149 0x265 minor change in look
276 * 4 "D-Link, DE-650, Ver 01.00" 0x149 0x265 collision LED added
277 *
278 * While the 1st and the 2nd types should use the "D-Link DE-650" entry,
279 * the 3rd and the 4th types should use the "Linksys EtherCard" entry.
280 * Therefore, this enty must be below the LINKSYS_ECARD_1. --itohy
281 */
282 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
283 PCMCIA_CIS_DLINK_DE650,
284 0, 0x0040, { 0x00, 0x80, 0xc8 } },
285
286 /*
287 * IO-DATA PCLA/TE and later version of PCLA/T has valid
288 * vendor/product ID and it is possible to read MAC address
289 * using standard I/O ports. It also read from CIS offset 0x01c0.
290 * On the other hand, earlier version of PCLA/T doesn't have valid
291 * vendor/product ID and MAC address must be read from CIS offset
292 * 0x0ff0 (i.e., usual ne2000 way to read it doesn't work).
293 * And CIS information of earlier and later version of PCLA/T are
294 * same except fourth element. So, for now, we place the entry for
295 * PCLA/TE (and later version of PCLA/T) followed by entry
296 * for the earlier version of PCLA/T (or, modify to match all CIS
297 * information and have three or more individual entries).
298 */
299 { PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_PCLATE,
300 PCMCIA_CIS_IODATA_PCLATE,
301 0, -1, { 0x00, 0xa0, 0xb0 } },
302
303 /*
304 * This entry should be placed after above PCLA-TE entry.
305 * See above comments for detail.
306 */
307 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
308 PCMCIA_CIS_IODATA_PCLAT,
309 0, 0x0ff0, { 0x00, 0xa0, 0xb0 } },
310
311 { PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_1,
312 PCMCIA_CIS_DAYNA_COMMUNICARD_E_1,
313 0, 0x0110, { 0x00, 0x80, 0x19 } },
314
315 { PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_2,
316 PCMCIA_CIS_DAYNA_COMMUNICARD_E_2,
317 0, -1, { 0x00, 0x80, 0x19 } },
318
319 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_T,
320 PCMCIA_CIS_COREGA_ETHER_PCC_T,
321 0, -1, { 0x00, 0x00, 0xf4 } },
322
323 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_TD,
324 PCMCIA_CIS_COREGA_ETHER_PCC_TD,
325 0, -1, { 0x00, 0x00, 0xf4 } },
326
327 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_TL,
328 PCMCIA_CIS_COREGA_ETHER_PCC_TL,
329 0, -1, { 0x00, 0x00, 0xf4 } },
330
331 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_T,
332 PCMCIA_CIS_COREGA_ETHER_II_PCC_T,
333 0, -1, { 0x00, 0x00, 0xf4 } },
334
335 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_TD,
336 PCMCIA_CIS_COREGA_ETHER_II_PCC_TD,
337 0, -1, { 0x00, 0x00, 0xf4 } },
338
339 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FAST_ETHER_PCC_TX,
340 PCMCIA_CIS_COREGA_FAST_ETHER_PCC_TX,
341 0, -1, { 0x00, 0x00, 0xf4 }, NE2000DVF_DL10019 },
342
343 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXF,
344 PCMCIA_CIS_COREGA_FETHER_PCC_TXF,
345 0, -1, { 0x00, 0x90, 0x99 }, NE2000DVF_DL10019 },
346
347 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXD,
348 PCMCIA_CIS_COREGA_FETHER_PCC_TXD,
349 0, -1, { 0x00, 0x90, 0x99 } },
350
351 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_II_PCC_TXD,
352 PCMCIA_CIS_COREGA_FETHER_II_PCC_TXD,
353 0, -1, { 0x00, 0x90, 0x99 }, NE2000DVF_AX88190 | NE2000DVF_AX88790 },
354
355 { PCMCIA_VENDOR_COMPEX, PCMCIA_PRODUCT_COMPEX_LINKPORT_ENET_B,
356 PCMCIA_CIS_COMPEX_LINKPORT_ENET_B,
357 0, 0x01c0, { 0x00, 0xa0, 0x0c } },
358
359 { PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_EZCARD,
360 PCMCIA_CIS_SMC_EZCARD,
361 0, 0x01c0, { 0x00, 0xe0, 0x29 } },
362
363 { PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_8041,
364 PCMCIA_CIS_SMC_8041,
365 0, -1, { 0x00, 0x04, 0xe2 } },
366
367 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_EA_ETHER,
368 PCMCIA_CIS_SOCKET_EA_ETHER,
369 0, -1, { 0x00, 0xc0, 0x1b } },
370
371 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER_CF,
372 PCMCIA_CIS_SOCKET_LP_ETHER_CF,
373 0, -1, { 0x00, 0xc0, 0x1b } },
374
375 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETH_10_100_CF,
376 PCMCIA_CIS_SOCKET_LP_ETH_10_100_CF,
377 0, -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 },
378
379 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER,
380 PCMCIA_CIS_SOCKET_LP_ETHER,
381 0, -1, { 0x00, 0xc0, 0x1b } },
382
383 { PCMCIA_VENDOR_KINGSTON, PCMCIA_PRODUCT_KINGSTON_KNE2,
384 PCMCIA_CIS_KINGSTON_KNE2,
385 0, -1, { 0x00, 0xc0, 0xf0 } },
386
387 { PCMCIA_VENDOR_XIRCOM, PCMCIA_PRODUCT_XIRCOM_CFE_10,
388 PCMCIA_CIS_XIRCOM_CFE_10,
389 0, -1, { 0x00, 0x10, 0xa4 } },
390
391 { PCMCIA_VENDOR_MELCO, PCMCIA_PRODUCT_MELCO_LPC3_TX,
392 PCMCIA_CIS_MELCO_LPC3_TX,
393 0, -1, { 0xff, 0xff, 0xff }, NE2000DVF_AX88190 },
394
395 { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC3_CLT,
396 PCMCIA_CIS_BUFFALO_LPC3_CLT,
397 0, -1, { 0x00, 0x07, 0x40 } },
398
399 { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC4_CLX,
400 PCMCIA_CIS_BUFFALO_LPC4_CLX,
401 0, -1, { 0x00, 0x40, 0xfa }, NE2000DVF_AX88190 | NE2000DVF_AX88790 },
402
403 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
404 PCMCIA_CIS_BILLIONTON_LNT10TN,
405 0, -1, { 0x00, 0x00, 0x00 } },
406
407 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
408 PCMCIA_CIS_BILLIONTON_CFLT10N,
409 0, -1, { 0x00, 0x00, 0x00 } },
410
411 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
412 PCMCIA_CIS_NDC_ND5100_E,
413 0, -1, { 0x00, 0x80, 0xc6 } },
414
415 { PCMCIA_VENDOR_TELECOMDEVICE, PCMCIA_PRODUCT_TELECOMDEVICE_TCD_HPC100,
416 PCMCIA_CIS_TELECOMDEVICE_TCD_HPC100,
417 0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
418
419 { PCMCIA_VENDOR_MACNICA, PCMCIA_PRODUCT_MACNICA_ME1_JEIDA,
420 PCMCIA_CIS_MACNICA_ME1_JEIDA,
421 0, 0x00b8, { 0x08, 0x00, 0x42 } },
422
423 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA411,
424 PCMCIA_CIS_NETGEAR_FA411,
425 0, -1, { 0x00, 0x40, 0xf4 } },
426
427 { PCMCIA_VENDOR_DYNALINK, PCMCIA_PRODUCT_DYNALINK_L10C,
428 PCMCIA_CIS_DYNALINK_L10C,
429 0, -1, { 0x00, 0x00, 0x00 } },
430
431 #if 0
432 /* the rest of these are stolen from the linux pcnet pcmcia device
433 driver. Since I don't know the manfid or cis info strings for
434 any of them, they're not compiled in until I do. */
435 { "APEX MultiCard",
436 0x0000, 0x0000, NULL, NULL, 0,
437 0x03f4, { 0x00, 0x20, 0xe5 } },
438 { "ASANTE FriendlyNet",
439 0x0000, 0x0000, NULL, NULL, 0,
440 0x4910, { 0x00, 0x00, 0x94 } },
441 { "Danpex EN-6200P2",
442 0x0000, 0x0000, NULL, NULL, 0,
443 0x0110, { 0x00, 0x40, 0xc7 } },
444 { "DataTrek NetCard",
445 0x0000, 0x0000, NULL, NULL, 0,
446 0x0ff0, { 0x00, 0x20, 0xe8 } },
447 { "Dayna CommuniCard E",
448 0x0000, 0x0000, NULL, NULL, 0,
449 0x0110, { 0x00, 0x80, 0x19 } },
450 { "EP-210 Ethernet",
451 0x0000, 0x0000, NULL, NULL, 0,
452 0x0110, { 0x00, 0x40, 0x33 } },
453 { "ELECOM Laneed LD-CDWA",
454 0x0000, 0x0000, NULL, NULL, 0,
455 0x00b8, { 0x08, 0x00, 0x42 } },
456 { "Grey Cell GCS2220",
457 0x0000, 0x0000, NULL, NULL, 0,
458 0x0000, { 0x00, 0x47, 0x43 } },
459 { "Hypertec Ethernet",
460 0x0000, 0x0000, NULL, NULL, 0,
461 0x01c0, { 0x00, 0x40, 0x4c } },
462 { "IBM CCAE",
463 0x0000, 0x0000, NULL, NULL, 0,
464 0x0ff0, { 0x08, 0x00, 0x5a } },
465 { "IBM CCAE",
466 0x0000, 0x0000, NULL, NULL, 0,
467 0x0ff0, { 0x00, 0x04, 0xac } },
468 { "IBM CCAE",
469 0x0000, 0x0000, NULL, NULL, 0,
470 0x0ff0, { 0x00, 0x06, 0x29 } },
471 { "IBM FME",
472 0x0000, 0x0000, NULL, NULL, 0,
473 0x0374, { 0x00, 0x04, 0xac } },
474 { "IBM FME",
475 0x0000, 0x0000, NULL, NULL, 0,
476 0x0374, { 0x08, 0x00, 0x5a } },
477 { "Katron PE-520",
478 0x0000, 0x0000, NULL, NULL, 0,
479 0x0110, { 0x00, 0x40, 0xf6 } },
480 { "Kingston KNE-PCM/x",
481 0x0000, 0x0000, NULL, NULL, 0,
482 0x0ff0, { 0x00, 0xc0, 0xf0 } },
483 { "Kingston KNE-PCM/x",
484 0x0000, 0x0000, NULL, NULL, 0,
485 0x0ff0, { 0xe2, 0x0c, 0x0f } },
486 { "Longshine LCS-8534",
487 0x0000, 0x0000, NULL, NULL, 0,
488 0x0000, { 0x08, 0x00, 0x00 } },
489 { "Maxtech PCN2000",
490 0x0000, 0x0000, NULL, NULL, 0,
491 0x5000, { 0x00, 0x00, 0xe8 } },
492 { "NDC Instant-Link",
493 0x0000, 0x0000, NULL, NULL, 0,
494 0x003a, { 0x00, 0x80, 0xc6 } },
495 { "NE2000 Compatible",
496 0x0000, 0x0000, NULL, NULL, 0,
497 0x0ff0, { 0x00, 0xa0, 0x0c } },
498 { "Network General Sniffer",
499 0x0000, 0x0000, NULL, NULL, 0,
500 0x0ff0, { 0x00, 0x00, 0x65 } },
501 { "Panasonic VEL211",
502 0x0000, 0x0000, NULL, NULL, 0,
503 0x0ff0, { 0x00, 0x80, 0x45 } },
504 { "SCM Ethernet",
505 0x0000, 0x0000, NULL, NULL, 0,
506 0x0ff0, { 0x00, 0x20, 0xcb } },
507 { "Volktek NPL-402CT",
508 0x0000, 0x0000, NULL, NULL, 0,
509 0x0060, { 0x00, 0x40, 0x05 } },
510 #endif
511
512 { PCMCIA_VENDOR_ALLIEDTELESIS, PCMCIA_PRODUCT_ALLIEDTELESIS_LA_PCM,
513 PCMCIA_CIS_ALLIEDTELESIS_LA_PCM,
514 0, 0x0ff0, { 0x00, 0x00, 0xf4 } },
515
516 { PCMCIA_VENDOR_NEXTCOM, PCMCIA_PRODUCT_NEXTCOM_NEXTHAWK,
517 PCMCIA_CIS_NEXTCOM_NEXTHAWK,
518 0, -1, { 0x00, 0x40, 0xb4 } },
519 };
520
521 #define NE2000_NDEVS (sizeof(ne2000devs) / sizeof(ne2000devs[0]))
522
523 #define ne2000_match(card, fct, n) \
524 ((((((card)->manufacturer != PCMCIA_VENDOR_INVALID) && \
525 ((card)->manufacturer == ne2000devs[(n)].manufacturer) && \
526 ((card)->product != PCMCIA_PRODUCT_INVALID) && \
527 ((card)->product == ne2000devs[(n)].product)) || \
528 ((ne2000devs[(n)].cis_info[0]) && (ne2000devs[(n)].cis_info[1]) && \
529 (strcmp((card)->cis1_info[0], ne2000devs[(n)].cis_info[0]) == 0) && \
530 (strcmp((card)->cis1_info[1], ne2000devs[(n)].cis_info[1]) == 0))) && \
531 ((fct) == ne2000devs[(n)].function))? \
532 &ne2000devs[(n)]:NULL)
533
534 int
535 ne_pcmcia_match(parent, match, aux)
536 struct device *parent;
537 struct cfdata *match;
538 void *aux;
539 {
540 struct pcmcia_attach_args *pa = aux;
541 int i;
542
543 for (i = 0; i < NE2000_NDEVS; i++) {
544 if (ne2000_match(pa->card, pa->pf->number, i))
545 return (1);
546 }
547
548 return (0);
549 }
550
551 void
552 ne_pcmcia_attach(parent, self, aux)
553 struct device *parent, *self;
554 void *aux;
555 {
556 struct ne_pcmcia_softc *psc = (void *) self;
557 struct ne2000_softc *nsc = &psc->sc_ne2000;
558 struct dp8390_softc *dsc = &nsc->sc_dp8390;
559 struct pcmcia_attach_args *pa = aux;
560 struct pcmcia_config_entry *cfe;
561 const struct ne2000dev *ne_dev;
562 int i;
563 u_int8_t myea[6], *enaddr;
564 const char *typestr = "";
565
566 psc->sc_pf = pa->pf;
567
568 SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
569 #if 0
570 /*
571 * Some ne2000 driver's claim to have memory; others don't.
572 * Since I don't care, I don't check.
573 */
574
575 if (cfe->num_memspace != 1) {
576 printf(": unexpected number of memory spaces "
577 " %d should be 1\n", cfe->num_memspace);
578 continue;
579 }
580 #endif
581
582 if (cfe->num_iospace == 1) {
583 if (cfe->iospace[0].length != NE2000_NPORTS) {
584 printf(": unexpected I/O space configuration"
585 " (continued)\n%s", dsc->sc_dev.dv_xname);
586 /* XXX really safe for all other cards? */
587 }
588 } else if (cfe->num_iospace == 2) {
589 /*
590 * Some cards report a separate space for NIC and ASIC.
591 * This make some sense, but we must allocate a single
592 * NE2000_NPORTS-sized chunk, due to brain damaged
593 * address decoders on some of these cards.
594 */
595 if (cfe->iospace[0].length + cfe->iospace[1].length !=
596 NE2000_NPORTS) {
597 #ifdef DIAGNOSTIC
598 printf(": unexpected I/O "
599 "space configuration; ignored\n%s",
600 dsc->sc_dev.dv_xname);
601 #endif
602 continue;
603 }
604 } else {
605 #ifdef DIAGNOSTIC
606 printf(": unexpected number of i/o spaces %d"
607 " should be 1 or 2; ignored\n%s",
608 cfe->num_iospace, dsc->sc_dev.dv_xname);
609 #endif
610 continue;
611 }
612
613 if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
614 NE2000_NPORTS, NE2000_NPORTS, &psc->sc_pcioh)) {
615 #ifdef DIAGNOSTIC
616 printf(": can't allocate i/o space %lx; ignored\n%s",
617 cfe->iospace[0].start, dsc->sc_dev.dv_xname);
618 #endif
619 continue;
620 }
621
622 /* Ok, found. */
623 break;
624 }
625
626 if (cfe == NULL) {
627 printf(": no suitable config entry\n");
628 goto fail_1;
629 }
630
631 dsc->sc_regt = psc->sc_pcioh.iot;
632 dsc->sc_regh = psc->sc_pcioh.ioh;
633
634 nsc->sc_asict = psc->sc_pcioh.iot;
635 if (bus_space_subregion(dsc->sc_regt, dsc->sc_regh,
636 NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
637 &nsc->sc_asich)) {
638 printf(": can't get subregion for asic\n");
639 goto fail_2;
640 }
641
642 /* Set up power management hooks. */
643 dsc->sc_enable = ne_pcmcia_enable;
644 dsc->sc_disable = ne_pcmcia_disable;
645
646 /* Enable the card. */
647 pcmcia_function_init(pa->pf, cfe);
648 if (pcmcia_function_enable(pa->pf)) {
649 printf(": function enable failed\n");
650 goto fail_2;
651 }
652
653 /* some cards claim to be io16, but they're lying. */
654 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO8,
655 NE2000_NIC_OFFSET, NE2000_NIC_NPORTS,
656 &psc->sc_pcioh, &psc->sc_nic_io_window)) {
657 printf(": can't map NIC i/o space\n");
658 goto fail_3;
659 }
660
661 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16,
662 NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
663 &psc->sc_pcioh, &psc->sc_asic_io_window)) {
664 printf(": can't map ASIC i/o space\n");
665 goto fail_4;
666 }
667
668 aprint_normal("\n");
669
670 /*
671 * Read the station address from the board.
672 */
673 i = 0;
674 again:
675 enaddr = NULL; /* Ask ASIC by default */
676 typestr = ""; /* clear previous card-type */
677 for (; i < NE2000_NDEVS; i++) {
678 ne_dev = ne2000_match(pa->card, pa->pf->number, i);
679 if (ne_dev != NULL) {
680 if (ne_dev->enet_maddr >= 0) {
681 enaddr = ne_pcmcia_get_enaddr(psc,
682 ne_dev->enet_maddr, myea);
683 if (enaddr == NULL)
684 continue;
685 }
686 goto found;
687 }
688 }
689 aprint_error("%s: can't match ethernet vendor code\n", self->dv_xname);
690 if (enaddr != NULL)
691 aprint_error("%s: ethernet vendor code %02x:%02x:%02x\n",
692 self->dv_xname, enaddr[0], enaddr[1], enaddr[2]);
693 goto fail_5;
694
695 found:
696 if ((ne_dev->flags & NE2000DVF_DL10019) != 0) {
697 u_int8_t type;
698
699 enaddr = ne_pcmcia_dl10019_get_enaddr(psc, myea);
700 if (enaddr == NULL) {
701 ++i;
702 goto again;
703 }
704
705 dsc->sc_mediachange = dl10019_mediachange;
706 dsc->sc_mediastatus = dl10019_mediastatus;
707 dsc->init_card = dl10019_init_card;
708 dsc->stop_card = dl10019_stop_card;
709 dsc->sc_media_init = dl10019_media_init;
710 dsc->sc_media_fini = dl10019_media_fini;
711
712 /* Determine if this is a DL10019 or a DL10022. */
713 type = bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 0x0f);
714 if (type == 0x91 || type == 0x99) {
715 nsc->sc_type = NE2000_TYPE_DL10022;
716 typestr = " (DL10022)";
717 } else {
718 nsc->sc_type = NE2000_TYPE_DL10019;
719 typestr = " (DL10019)";
720 }
721 }
722
723 if ((ne_dev->flags & NE2000DVF_AX88190) != 0) {
724 if (ne_pcmcia_ax88190_set_iobase(psc)) {
725 ++i;
726 goto again;
727 }
728
729 dsc->sc_mediachange = ax88190_mediachange;
730 dsc->sc_mediastatus = ax88190_mediastatus;
731 dsc->init_card = ax88190_init_card;
732 dsc->stop_card = ax88190_stop_card;
733 dsc->sc_media_init = ax88190_media_init;
734 dsc->sc_media_fini = ax88190_media_fini;
735
736 if ((ne_dev->flags & NE2000DVF_AX88790) != 0) {
737 nsc->sc_type = NE2000_TYPE_AX88790;
738 typestr = " (AX88790)";
739 } else {
740 nsc->sc_type = NE2000_TYPE_AX88190;
741 typestr = " (AX88190)";
742 }
743 }
744
745 if (enaddr != NULL &&
746 ne_dev->enet_vendor[0] != 0xff) {
747 /*
748 * Make sure this is what we expect.
749 */
750 if (enaddr[0] != ne_dev->enet_vendor[0] ||
751 enaddr[1] != ne_dev->enet_vendor[1] ||
752 enaddr[2] != ne_dev->enet_vendor[2]) {
753 ++i;
754 goto again;
755 }
756 }
757
758 /*
759 * Check for a Realtek 8019.
760 */
761 if (nsc->sc_type == 0) {
762 bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR,
763 ED_CR_PAGE_0 | ED_CR_STP);
764 if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh,
765 NERTL_RTL0_8019ID0) == RTL0_8019ID0 &&
766 bus_space_read_1(dsc->sc_regt, dsc->sc_regh,
767 NERTL_RTL0_8019ID1) == RTL0_8019ID1) {
768 typestr = " (RTL8019)";
769 dsc->sc_mediachange = rtl80x9_mediachange;
770 dsc->sc_mediastatus = rtl80x9_mediastatus;
771 dsc->init_card = rtl80x9_init_card;
772 dsc->sc_media_init = rtl80x9_media_init;
773 }
774 }
775
776 if (ne2000_attach(nsc, enaddr))
777 goto fail_5;
778
779 pcmcia_function_disable(pa->pf);
780 return;
781
782 fail_5:
783 /* Unmap ASIC i/o windows. */
784 pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
785
786 fail_4:
787 /* Unmap NIC i/o windows. */
788 pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
789
790 fail_3:
791 pcmcia_function_disable(pa->pf);
792
793 fail_2:
794 /* Free our i/o space. */
795 pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
796
797 fail_1:
798 psc->sc_nic_io_window = -1;
799 }
800
801 int
802 ne_pcmcia_detach(self, flags)
803 struct device *self;
804 int flags;
805 {
806 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)self;
807 int error;
808
809 if (psc->sc_nic_io_window == -1)
810 /* Nothing to detach. */
811 return (0);
812
813 error = ne2000_detach(&psc->sc_ne2000, flags);
814 if (error != 0)
815 return (error);
816
817 /* Unmap our i/o windows. */
818 pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
819 pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
820
821 /* Free our i/o space. */
822 pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
823
824 return (0);
825 }
826
827 int
828 ne_pcmcia_enable(dsc)
829 struct dp8390_softc *dsc;
830 {
831 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
832 struct ne2000_softc *nsc = &psc->sc_ne2000;
833 struct pcmcia_mem_handle pcmh;
834
835 /* set up the interrupt */
836 psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
837 dsc);
838 if (psc->sc_ih == NULL) {
839 printf("%s: couldn't establish interrupt\n",
840 dsc->sc_dev.dv_xname);
841 goto fail_1;
842 }
843
844 if (pcmcia_function_enable(psc->sc_pf))
845 goto fail_2;
846
847 if (nsc->sc_type == NE2000_TYPE_AX88190 ||
848 nsc->sc_type == NE2000_TYPE_AX88790) {
849 if (ne_pcmcia_ax88190_set_iobase(psc))
850 goto fail_3;
851 if (nsc->sc_type == NE2000_TYPE_AX88790) {
852 bus_size_t offset;
853 int mwindow;
854
855 if (pcmcia_mem_alloc(psc->sc_pf,
856 AX88790_CSR_SIZE, &pcmh)) {
857 printf("%s: can't alloc mem for CSR\n",
858 dsc->sc_dev.dv_xname);
859 goto fail_3;
860 }
861
862 if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR,
863 AX88790_CSR, AX88790_CSR_SIZE,
864 &pcmh, &offset, &mwindow)) {
865 printf("%s: can't map mem for CSR\n",
866 dsc->sc_dev.dv_xname);
867 goto fail_4;
868 }
869
870 bus_space_write_1(pcmh.memt, pcmh.memh, offset, 0x4);
871 pcmcia_mem_unmap(psc->sc_pf, mwindow);
872 pcmcia_mem_free(psc->sc_pf, &pcmh);
873 }
874 }
875
876 return (0);
877
878 fail_4:
879 pcmcia_mem_free(psc->sc_pf, &pcmh);
880 fail_3:
881 pcmcia_function_disable(psc->sc_pf);
882 fail_2:
883 pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
884 fail_1:
885 return (1);
886 }
887
888 void
889 ne_pcmcia_disable(dsc)
890 struct dp8390_softc *dsc;
891 {
892 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
893
894 pcmcia_function_disable(psc->sc_pf);
895 pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
896 }
897
898 u_int8_t *
899 ne_pcmcia_get_enaddr(psc, maddr, myea)
900 struct ne_pcmcia_softc *psc;
901 int maddr;
902 u_int8_t myea[ETHER_ADDR_LEN];
903 {
904 struct ne2000_softc *nsc = &psc->sc_ne2000;
905 struct dp8390_softc *dsc = &nsc->sc_dp8390;
906 struct pcmcia_mem_handle pcmh;
907 bus_size_t offset;
908 u_int8_t *enaddr = NULL;
909 int j, mwindow;
910
911 if (maddr < 0)
912 return (NULL);
913
914 if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) {
915 printf("%s: can't alloc mem for enet addr\n",
916 dsc->sc_dev.dv_xname);
917 goto fail_1;
918 }
919 if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, maddr,
920 ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) {
921 printf("%s: can't map mem for enet addr\n",
922 dsc->sc_dev.dv_xname);
923 goto fail_2;
924 }
925 for (j = 0; j < ETHER_ADDR_LEN; j++)
926 myea[j] = bus_space_read_1(pcmh.memt, pcmh.memh,
927 offset + (j * 2));
928 enaddr = myea;
929
930 pcmcia_mem_unmap(psc->sc_pf, mwindow);
931 fail_2:
932 pcmcia_mem_free(psc->sc_pf, &pcmh);
933 fail_1:
934 return (enaddr);
935 }
936
937 u_int8_t *
938 ne_pcmcia_dl10019_get_enaddr(psc, myea)
939 struct ne_pcmcia_softc *psc;
940 u_int8_t myea[ETHER_ADDR_LEN];
941 {
942 struct ne2000_softc *nsc = &psc->sc_ne2000;
943 u_int8_t sum;
944 int j;
945
946 #define PAR0 0x04
947 for (j = 0, sum = 0; j < 8; j++)
948 sum += bus_space_read_1(nsc->sc_asict, nsc->sc_asich,
949 PAR0 + j);
950 if (sum != 0xff)
951 return (NULL);
952 for (j = 0; j < ETHER_ADDR_LEN; j++)
953 myea[j] = bus_space_read_1(nsc->sc_asict,
954 nsc->sc_asich, PAR0 + j);
955 #undef PAR0
956 return (myea);
957 }
958
959 int
960 ne_pcmcia_ax88190_set_iobase(psc)
961 struct ne_pcmcia_softc *psc;
962 {
963 struct ne2000_softc *nsc = &psc->sc_ne2000;
964 struct dp8390_softc *dsc = &nsc->sc_dp8390;
965 struct pcmcia_mem_handle pcmh;
966 bus_size_t offset;
967 int rv = 1, mwindow;
968 u_int last_liobase, new_liobase;
969
970 if (pcmcia_mem_alloc(psc->sc_pf, AX88190_LAN_IOSIZE, &pcmh)) {
971 #if 0
972 printf("%s: can't alloc mem for LAN iobase\n",
973 dsc->sc_dev.dv_xname);
974 #endif
975 goto fail_1;
976 }
977 if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR,
978 AX88190_LAN_IOBASE, AX88190_LAN_IOSIZE,
979 &pcmh, &offset, &mwindow)) {
980 printf("%s: can't map mem for LAN iobase\n",
981 dsc->sc_dev.dv_xname);
982 goto fail_2;
983 }
984
985 last_liobase = bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
986 (bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
987 #ifdef DIAGNOSTIC
988 printf("%s: LAN iobase 0x%x (0x%x) ->", dsc->sc_dev.dv_xname,
989 last_liobase, (u_int)psc->sc_pcioh.addr);
990 #endif
991 bus_space_write_1(pcmh.memt, pcmh.memh, offset,
992 psc->sc_pcioh.addr & 0xff);
993 bus_space_write_1(pcmh.memt, pcmh.memh, offset + 2,
994 psc->sc_pcioh.addr >> 8);
995
996 new_liobase = bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
997 (bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
998 #ifdef DIAGNOSTIC
999 printf(" 0x%x\n", new_liobase);
1000 #endif
1001 if ((last_liobase == psc->sc_pcioh.addr)
1002 || (last_liobase != new_liobase))
1003 rv = 0;
1004
1005 pcmcia_mem_unmap(psc->sc_pf, mwindow);
1006 fail_2:
1007 pcmcia_mem_free(psc->sc_pf, &pcmh);
1008 fail_1:
1009 return (rv);
1010 }
1011