diff options
author | Garrett D'Amore <garrett@dey-sys.com> | 2013-09-28 07:26:40 -0700 |
---|---|---|
committer | Garrett D'Amore <garrett@dey-sys.com> | 2013-10-11 06:54:00 -0700 |
commit | 506aa7c68b127eefb0197e329af7e9abcc3ebc98 (patch) | |
tree | 9332a6aefe0c0778993e49259cab5c3b76ce48f3 | |
parent | 746f551ddc191f00808cd4121966c1ee42d5b74f (diff) | |
download | illumos-joyent-506aa7c68b127eefb0197e329af7e9abcc3ebc98.tar.gz |
4166 EOF pcata
4167 EOF pcser
2995 pcan and pcwl wifi device drivers EOL
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>
54 files changed, 27 insertions, 21240 deletions
diff --git a/exception_lists/closed-bins b/exception_lists/closed-bins index e059e69b93..bc8ea576bf 100644 --- a/exception_lists/closed-bins +++ b/exception_lists/closed-bins @@ -20,6 +20,8 @@ ./kernel/drv/amd64/iprb ./kernel/drv/pcn ./kernel/drv/amd64/pcn +./kernel/drv/pcser +./kernel/drv/amd64/pcser ./kernel/misc/klmmod ./kernel/misc/amd64/klmmod ./kernel/misc/klmops @@ -34,13 +36,14 @@ ./usr/has ./usr/has/bin ./usr/has/bin/patch +./usr/include/sys/pcmcia ./usr/kernel ./usr/kernel/strmod ./usr/kernel/strmod/amd64 ./usr/kernel/strmod/sparcv9 ./usr/kernel/drv -./usr/kenrel/drv/amd64 -./usr/kenrel/drv/sparcv9 +./usr/kernel/drv/amd64 +./usr/kernel/drv/sparcv9 ./usr/kernel/drv/amd64/llc2 ./usr/kernel/drv/sparcv9/llc2 ./usr/kernel/drv/llc2.conf diff --git a/usr/src/cmd/devfsadm/port_link.c b/usr/src/cmd/devfsadm/port_link.c index 70579acbbc..f62254e3bc 100644 --- a/usr/src/cmd/devfsadm/port_link.c +++ b/usr/src/cmd/devfsadm/port_link.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -144,8 +145,6 @@ static int dialout_create(di_minor_t minor, di_node_t node); static int onbrd_dialout_create(di_minor_t minor, di_node_t node); static int rsc_port_create(di_minor_t minor, di_node_t node); static int lom_port_create(di_minor_t minor, di_node_t node); -static int pcmcia_port_create(di_minor_t minor, di_node_t node); -static int pcmcia_dialout_create(di_minor_t minor, di_node_t node); static void rm_dangling_port(char *devname); static void update_sacadm_db(void); static int parse_portno(char *dname); @@ -170,10 +169,6 @@ static devfsadm_create_t ports_cbt[] = { TYPE_EXACT | DRV_EXACT, ILEVEL_1, rsc_port_create}, {"port", "ddi_serial:lomcon", "su", TYPE_EXACT | DRV_EXACT, ILEVEL_1, lom_port_create}, - {"port", "ddi_serial", "pcser", - TYPE_EXACT | DRV_EXACT, ILEVEL_1, pcmcia_port_create}, - {"port", "ddi_serial:dialout", "pcser", - TYPE_EXACT | DRV_EXACT, ILEVEL_1, pcmcia_dialout_create}, {"port", "ddi_serial", NULL, TYPE_EXACT, ILEVEL_0, serial_port_create}, {"port", "ddi_serial:mb", NULL, @@ -675,78 +670,6 @@ lom_port_create(di_minor_t minor, di_node_t node) return (DEVFSADM_CONTINUE); } -/* - * PCMCIA serial ports - * Creates links of the form "/dev/term/pcN", where N is the PCMCIA - * socket # the device is plugged into. - */ -#define PCMCIA_MAX_SOCKETS 64 -#define PCMCIA_SOCKETNO(x) ((x) & (PCMCIA_MAX_SOCKETS - 1)) - -static int -pcmcia_port_create(di_minor_t minor, di_node_t node) -{ - char l_path[MAXPATHLEN]; - char *devfspath; - int socket, *intp; - - devfspath = di_devfs_path(node); - if (devfspath == NULL) { - devfsadm_errprint("%s: di_devfs_path() failed\n", modname); - return (DEVFSADM_TERMINATE); - } - - if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "socket", &intp) <= 0) { - devfsadm_errprint("%s: failed pcmcia socket lookup\n\t%s\n", - modname, devfspath); - di_devfs_path_free(devfspath); - return (DEVFSADM_TERMINATE); - } - - socket = PCMCIA_SOCKETNO(*intp); - - di_devfs_path_free(devfspath); - - (void) sprintf(l_path, "term/pc%d", socket); - (void) devfsadm_mklink(l_path, node, minor, 0); - - return (DEVFSADM_TERMINATE); -} - -/* - * PCMCIA dialout serial ports - * Creates links of the form "/dev/cua/pcN", where N is the PCMCIA - * socket number the device is plugged into. - */ -static int -pcmcia_dialout_create(di_minor_t minor, di_node_t node) -{ - char l_path[MAXPATHLEN]; - char *devfspath; - int socket, *intp; - - devfspath = di_devfs_path(node); - if (devfspath == NULL) { - devfsadm_errprint("%s: di_devfs_path() failed\n", modname); - return (DEVFSADM_TERMINATE); - } - - if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "socket", &intp) <= 0) { - devfsadm_errprint("%s: failed socket lookup\n\t%s\n", - modname, devfspath); - di_devfs_path_free(devfspath); - return (DEVFSADM_TERMINATE); - } - - socket = PCMCIA_SOCKETNO(*intp); - - di_devfs_path_free(devfspath); - (void) sprintf(l_path, "cua/pc%d", socket); - (void) devfsadm_mklink(l_path, node, minor, 0); - - return (DEVFSADM_TERMINATE); -} - /* * Removes port entries that no longer have devices diff --git a/usr/src/cmd/hal/hald/solaris/devinfo.c b/usr/src/cmd/hal/hald/solaris/devinfo.c index be12ce2fd6..4600c09224 100644 --- a/usr/src/cmd/hal/hald/solaris/devinfo.c +++ b/usr/src/cmd/hal/hald/solaris/devinfo.c @@ -2,6 +2,7 @@ * * devinfo.c : main file for libdevinfo-based device enumeration * + * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * * Licensed under the Academic Free License version 2.1 @@ -131,7 +132,6 @@ static DevinfoDevHandler *devinfo_handlers[] = { &devinfo_cpu_handler, &devinfo_ide_handler, &devinfo_scsi_handler, - &devinfo_pcata_handler, &devinfo_blkdev_handler, &devinfo_floppy_handler, &devinfo_usb_handler, diff --git a/usr/src/cmd/hal/hald/solaris/devinfo_storage.c b/usr/src/cmd/hal/hald/solaris/devinfo_storage.c index 7a5b1d84aa..0bf1a563dd 100644 --- a/usr/src/cmd/hal/hald/solaris/devinfo_storage.c +++ b/usr/src/cmd/hal/hald/solaris/devinfo_storage.c @@ -3,6 +3,7 @@ * devinfo_storage.c : storage devices * * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2013 Garrett D'Amore <garrett@damore.org> * * Licensed under the Academic Free License version 2.1 * @@ -60,8 +61,6 @@ static HalDevice *devinfo_ide_device_add(HalDevice *parent, di_node_t node, char static HalDevice *devinfo_ide_storage_add(HalDevice *parent, di_node_t node, char *devfs_path); HalDevice *devinfo_scsi_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type); static HalDevice *devinfo_scsi_storage_add(HalDevice *parent, di_node_t node, char *devfs_path); -HalDevice *devinfo_pcata_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type); -static HalDevice *devinfo_pcata_storage_add(HalDevice *parent, di_node_t node, char *devfs_path); HalDevice *devinfo_blkdev_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type); static HalDevice *devinfo_blkdev_storage_add(HalDevice *parent, di_node_t node, char *devfs_path); HalDevice *devinfo_floppy_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type); @@ -103,14 +102,6 @@ DevinfoDevHandler devinfo_scsi_handler = { NULL, NULL }; -DevinfoDevHandler devinfo_pcata_handler = { - devinfo_pcata_add, - NULL, - NULL, - NULL, - NULL, - NULL -}; DevinfoDevHandler devinfo_blkdev_handler = { devinfo_blkdev_add, NULL, @@ -375,73 +366,6 @@ devinfo_scsi_dtype2str(int dtype) } -/* PCMCIA */ - -HalDevice * -devinfo_pcata_add(HalDevice *parent, di_node_t node, char *devfs_path, char *device_type) -{ - int *i; - char *driver_name; - HalDevice *d; - char udi[HAL_PATH_MAX]; - - driver_name = di_driver_name (node); - if ((driver_name == NULL) || (strcmp (driver_name, "pcata") != 0)) { - return (NULL); - } - - d = hal_device_new (); - - devinfo_set_default_properties (d, parent, node, devfs_path); - hal_device_property_set_string (d, "info.subsystem", "pcmcia"); - - hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), - "%s/%s%d", hal_device_get_udi (parent), di_node_name(node), di_instance (node)); - hal_device_set_udi (d, udi); - hal_device_property_set_string (d, "info.udi", udi); - hal_device_property_set_string (d, "info.product", "PCMCIA Disk"); - - devinfo_add_enqueue (d, devfs_path, &devinfo_pcata_handler); - - return (devinfo_pcata_storage_add (d, node, devfs_path)); -} - -static HalDevice * -devinfo_pcata_storage_add(HalDevice *parent, di_node_t node, char *devfs_path) -{ - HalDevice *d; - char *driver_name; - int *i; - char *s; - char udi[HAL_PATH_MAX]; - - d = hal_device_new (); - - devinfo_set_default_properties (d, parent, node, devfs_path); - hal_device_property_set_string (d, "info.category", "storage"); - - hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), - "%s/sd%d", hal_device_get_udi (parent), di_instance (node)); - hal_device_set_udi (d, udi); - hal_device_property_set_string (d, "info.udi", udi); - - hal_device_add_capability (d, "storage"); - - hal_device_property_set_int (d, "storage.lun", 0); - hal_device_property_set_bool (d, "storage.hotpluggable", TRUE); - hal_device_property_set_bool (d, "storage.removable", FALSE); - hal_device_property_set_bool (d, "storage.requires_eject", FALSE); - hal_device_property_set_bool (d, "storage.media_check_enabled", TRUE); - hal_device_property_set_string (d, "storage.drive_type", "disk"); - hal_device_property_set_bool (d, "storage.requires_eject", FALSE); - - hal_device_add_capability (d, "block"); - - devinfo_storage_minors (d, node, devfs_path, FALSE); - - return (d); -} - /* blkdev */ HalDevice * diff --git a/usr/src/cmd/netadm/iu.ap.sh b/usr/src/cmd/netadm/iu.ap.sh index df73f30fae..9ac9b143d4 100644 --- a/usr/src/cmd/netadm/iu.ap.sh +++ b/usr/src/cmd/netadm/iu.ap.sh @@ -44,7 +44,6 @@ case "$MACH" in usbftdi -1 0 ldterm ttcompat ipsecesp -1 0 ipsecesp ipsecah -1 0 ipsecah - pcser 0 255 ldterm ttcompat " > iu.ap ;; "sparc" ) @@ -77,7 +76,6 @@ case "$MACH" in ipsecesp -1 0 ipsecesp ipsecah -1 0 ipsecah oplmsu 0 0 ldterm ttcompat - pcser 0 255 ldterm ttcompat " >iu.ap ;; * ) diff --git a/usr/src/lib/libsmedia/plugins/Makefile b/usr/src/lib/libsmedia/plugins/Makefile index 510d33968c..d4e3468005 100644 --- a/usr/src/lib/libsmedia/plugins/Makefile +++ b/usr/src/lib/libsmedia/plugins/Makefile @@ -20,6 +20,7 @@ # # # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # # lib/libsmedia/plugins/Makefile @@ -27,8 +28,7 @@ SUBDIRS = \ blkdev \ scsi \ - floppy \ - pcata + floppy def := TARGET= def all := TARGET= all diff --git a/usr/src/lib/libsmedia/plugins/pcata/Makefile b/usr/src/lib/libsmedia/plugins/pcata/Makefile deleted file mode 100644 index 9d5b6a152d..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# lib/libsmedia/plugins/pcata/Makefile - -include ../../../Makefile.lib -include Makefile.targ -include ../Makefile.plugin - diff --git a/usr/src/lib/libsmedia/plugins/pcata/Makefile.targ b/usr/src/lib/libsmedia/plugins/pcata/Makefile.targ deleted file mode 100644 index 44e58f3e57..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/Makefile.targ +++ /dev/null @@ -1,36 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# lib/libmedia/plugins/pcata/Makefile.targ -# - -LIBRARY= sm_pcata.a -VERS= .1 - -OBJECTS= a_generic.o - diff --git a/usr/src/lib/libsmedia/plugins/pcata/amd64/Makefile b/usr/src/lib/libsmedia/plugins/pcata/amd64/Makefile deleted file mode 100644 index 26912cfea9..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/amd64/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.targ -include ../../../../Makefile.lib -include ../../../../Makefile.targ -include ../../Makefile.com -include ../../../../Makefile.lib.64 - -.KEEP_STATE: - -all: $(LIBS) $(TXTS) - -install: all $(PLUGINDIR64) .WAIT $(PLUGINS64) diff --git a/usr/src/lib/libsmedia/plugins/pcata/common/a_generic.c b/usr/src/lib/libsmedia/plugins/pcata/common/a_generic.c deleted file mode 100644 index a8cfc6f5f0..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/common/a_generic.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * a_generic.c : - * This file contains generic PCATA related functions for pcata plug-in - * for libsm.so. - */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <dirent.h> -#include <fcntl.h> -#include <sys/dkio.h> -#include <sys/dktp/dadkio.h> -#include <string.h> -#include "../../../library/inc/smedia.h" -#include "../../../library/inc/rmedia.h" -#include "../../../library/common/l_defines.h" - -#define PERROR(string) my_perror(gettext(string)) - -static void -my_perror(char *err_string) -{ - - int error_no; - if (errno == 0) - return; - - error_no = errno; - (void) fprintf(stderr, gettext(err_string)); - (void) fprintf(stderr, gettext(" : ")); - errno = error_no; - perror(""); -} - -int32_t -_m_version_no(void) -{ - return (SM_PCATA_VERSION_1); -} - -int32_t -_m_device_type(ushort_t ctype, ushort_t mtype) -{ - if (ctype == DKC_PCMCIA_ATA) { - if (mtype == 0) - return (0); - } - return (-1); -} - - -int32_t -_m_get_media_info(rmedia_handle_t *handle, void *ip) -{ - smmedium_prop_t *medinfo = ip; - struct dk_minfo media_info; - struct dk_geom dkgeom; - int32_t ret_val; - enum dkio_state state = DKIO_NONE; - - if (handle == NULL) { - DPRINTF("Null Handle\n"); - errno = EINVAL; - return (-1); - } - if (handle->sm_signature != (int32_t)LIBSMEDIA_SIGNATURE) { - DPRINTF2( - "Signature expected=0x%x, found=0x%x\n", - LIBSMEDIA_SIGNATURE, handle->sm_signature); - errno = EINVAL; - return (-1); - } - if (handle->sm_fd < 0) { - DPRINTF("Invalid file handle.\n"); - errno = EINVAL; - return (-1); - } - if (ioctl(handle->sm_fd, DKIOCSTATE, &state) < 0) { - PERROR("DKIOCSTATE failed"); - return (-1); - } - if (state != DKIO_INSERTED) { - DPRINTF("No media.\n"); - medinfo->sm_media_type = SM_NOT_PRESENT; - medinfo->sm_version = SMMEDIA_PROP_V_1; - return (0); - } - - (void) memset((void *) medinfo, 0, sizeof (smmedium_prop_t)); - - ret_val = ioctl(handle->sm_fd, DKIOCGMEDIAINFO, &media_info); - if (ret_val < 0) { - DPRINTF("DKIOCGMEDIAINFO ioctl failed"); - return (ret_val); - } - - medinfo->sm_media_type = media_info.dki_media_type; - medinfo->sm_blocksize = media_info.dki_lbsize; - medinfo->sm_capacity = media_info.dki_capacity; - - /* Is it a removable magnetic disk? */ - if (medinfo->sm_media_type == DK_FIXED_DISK) { - int32_t removable = 0; - - ret_val = ioctl(handle->sm_fd, DKIOCREMOVABLE, &removable); - if (ret_val < 0) { - DPRINTF("DKIOCREMOVABLE ioctl failed"); - return (ret_val); - } - if (removable) { - medinfo->sm_media_type = SM_PCMCIA_ATA; - } - } - ret_val = ioctl(handle->sm_fd, DKIOCGGEOM, &dkgeom); - if (ret_val < 0) { -#ifdef sparc - DPRINTF("DKIOCGGEOM ioctl failed"); - return (ret_val); -#else /* !sparc */ - /* - * Try getting Physical geometry on x86. - */ - ret_val = ioctl(handle->sm_fd, DKIOCG_PHYGEOM, &dkgeom); - if (ret_val < 0) { - DPRINTF("DKIOCG_PHYGEOM ioctl failed"); - return (ret_val); - } -#endif /* sparc */ - } - - medinfo->sm_pcyl = dkgeom.dkg_pcyl; - medinfo->sm_nhead = dkgeom.dkg_nhead; - medinfo->sm_nsect = dkgeom.dkg_nsect; - - return (0); -} - -/* ARGSUSED0 */ - -int32_t -_m_get_device_info(rmedia_handle_t *handle, void *ip) -{ - smdevice_info_t *mp = (smdevice_info_t *)ip; - char *vendor_name, *product_name, *fw_version; - - if (handle == NULL) { - DPRINTF("Null Handle\n"); - errno = EINVAL; - return (-1); - } - if (handle->sm_signature != (int32_t)LIBSMEDIA_SIGNATURE) { - DPRINTF2( - "Signature expected=0x%x, found=0x%x\n", - LIBSMEDIA_SIGNATURE, handle->sm_signature); - errno = EINVAL; - return (-1); - } - if (handle->sm_fd < 0) { - DPRINTF("Invalid file handle.\n"); - errno = EINVAL; - return (-1); - } - vendor_name = (char *)malloc(1); - if (vendor_name == NULL) { - if (!errno) - errno = ENOMEM; - return (-1); - } - product_name = (char *)malloc(1); - if (product_name == NULL) { - free(vendor_name); - if (!errno) - errno = ENOMEM; - return (-1); - } - - fw_version = (char *)malloc(1); - if (fw_version == NULL) { - free(vendor_name); - free(product_name); - if (!errno) - errno = ENOMEM; - return (-1); - } - - vendor_name[0] = NULL; - product_name[0] = NULL; - fw_version[0] = NULL; - mp->sm_interface_type = IF_PCMCIA; - mp->sm_vendor_name = vendor_name; - mp->sm_product_name = product_name; - mp->sm_firmware_version = fw_version; - return (0); -} - - -int32_t -_m_free_device_info(rmedia_handle_t *handle, void *ip) -{ - struct smdevice_info *dev_info = ip; - - /* Check for valid handle */ - if (handle == NULL) { - DPRINTF("Null Handle\n"); - errno = EINVAL; - return (-1); - } - if (handle->sm_signature != LIBSMEDIA_SIGNATURE) { - DPRINTF("Invalid signature in handle.\n"); - errno = EINVAL; - return (-1); - } - - free(dev_info->sm_vendor_name); - free(dev_info->sm_product_name); - free(dev_info->sm_firmware_version); - return (0); -} diff --git a/usr/src/lib/libsmedia/plugins/pcata/common/mapfile-vers b/usr/src/lib/libsmedia/plugins/pcata/common/mapfile-vers deleted file mode 100644 index 9bf0fa1ee1..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/common/mapfile-vers +++ /dev/null @@ -1,50 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - _m_device_type; - _m_free_device_info; - _m_get_device_info; - _m_get_media_info; - _m_version_no; - local: - *; -}; diff --git a/usr/src/lib/libsmedia/plugins/pcata/i386/Makefile b/usr/src/lib/libsmedia/plugins/pcata/i386/Makefile deleted file mode 100644 index b402f394dc..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/i386/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.targ -include ../../../../Makefile.lib -include ../../../../Makefile.targ -include ../../Makefile.com - -.KEEP_STATE: - -all: $(LIBS) $(TXTS) - -install: all $(PLUGINDIR) .WAIT $(PLUGINS) diff --git a/usr/src/lib/libsmedia/plugins/pcata/sparc/Makefile b/usr/src/lib/libsmedia/plugins/pcata/sparc/Makefile deleted file mode 100644 index b402f394dc..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/sparc/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.targ -include ../../../../Makefile.lib -include ../../../../Makefile.targ -include ../../Makefile.com - -.KEEP_STATE: - -all: $(LIBS) $(TXTS) - -install: all $(PLUGINDIR) .WAIT $(PLUGINS) diff --git a/usr/src/lib/libsmedia/plugins/pcata/sparcv9/Makefile b/usr/src/lib/libsmedia/plugins/pcata/sparcv9/Makefile deleted file mode 100644 index 26912cfea9..0000000000 --- a/usr/src/lib/libsmedia/plugins/pcata/sparcv9/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.targ -include ../../../../Makefile.lib -include ../../../../Makefile.targ -include ../../Makefile.com -include ../../../../Makefile.lib.64 - -.KEEP_STATE: - -all: $(LIBS) $(TXTS) - -install: all $(PLUGINDIR64) .WAIT $(PLUGINS64) diff --git a/usr/src/man/man7d/Makefile b/usr/src/man/man7d/Makefile index 981dbb7abb..8922d97ed8 100644 --- a/usr/src/man/man7d/Makefile +++ b/usr/src/man/man7d/Makefile @@ -12,6 +12,7 @@ # # Copyright 2011, Richard Lowe # Copyright 2013 Nexenta Systems, Inc. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # include $(SRC)/Makefile.master @@ -93,11 +94,8 @@ _MANFILES= aac.7d \ nxge.7d \ ohci.7d \ openprom.7d \ - pcan.7d \ - pcata.7d \ pcic.7d \ pcmcia.7d \ - pcwl.7d \ physmem.7d \ pm.7d \ poll.7d \ diff --git a/usr/src/man/man7d/pcan.7d b/usr/src/man/man7d/pcan.7d deleted file mode 100644 index 34f0ee3bd6..0000000000 --- a/usr/src/man/man7d/pcan.7d +++ /dev/null @@ -1,89 +0,0 @@ -'\" te -.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PCAN 7D "Jan 24, 2007" -.SH NAME -pcan \- Cisco Aironet 802.11b wireless NIC driver -.SH DESCRIPTION -.sp -.LP -The \fBpcan\fR wireless NIC driver is a multi-threaded, loadable, clonable, -GLDv3-based STREAMS driver. It supports the pccard and PCI/MiniPCI cards with -the Cisco Aironet \fI802.11b\fR chipset. For pccard, the driver works in both -SPARC and x86 (32-bit/64-bit) modes. For PCI/MiniPCI card, the driver works in -32-bit x86 mode only. -.SH DRIVER CONFIGURATION -.sp -.LP -The \fBpcan\fR driver supports \fI802.11b\fR data rates of 1, 2, 5.5 and 11 -(Mbits/sec). The default is 11. -.sp -.LP -The \fBpcan\fR driver supports BSS networks (also known as "ap" or -"infrastructure" networks) and IBSS networks (also known as "ad-hoc" networks). -For authentication type, the \fBpcan\fR driver supports the "open" (or -"open-system") mode. For encryption type, only WEP is currently supported. You -perform configuration and administration tasks using the \fBdladm\fR(1M) and -\fBwificonfig\fR(1M) utilities. -.SH FILES -.sp -.ne 2 -.na -\fB\fB/dev/pcan*\fR\fR -.ad -.RS 28n -Special character device. -.RE - -.sp -.ne 2 -.na -\fB/kernel/drv/pcan \fR -.ad -.RS 28n -32-bit ELF kernel module (x86). -.RE - -.sp -.ne 2 -.na -\fB\fB/kernel/drv/amd64/pcan\fR\fR -.ad -.RS 28n -64-bit ELF kernel module (x86). -.RE - -.sp -.ne 2 -.na -\fB\fB/kernel/drv/sparcv9/pcan\fR\fR -.ad -.RS 28n -64-bit ELF kernel module (SPARC). -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for a description of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Architecture x86 -.TE - -.SH SEE ALSO -.sp -.LP -\fBdladm\fR(1M), \fBwificonfig\fR(1M), \fBattributes\fR(5), \fBgld\fR(7D) -.sp -.LP -\fI802.11b Standard for Wireless Local Area Networks (WLANs)\fR - IEEE diff --git a/usr/src/man/man7d/pcata.7d b/usr/src/man/man7d/pcata.7d deleted file mode 100644 index 31a6da3dab..0000000000 --- a/usr/src/man/man7d/pcata.7d +++ /dev/null @@ -1,231 +0,0 @@ -'\" te -.\" Copyright (c) 2000 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PCATA 7D "Mar 2, 2007" -.SH NAME -pcata \- PCMCIA ATA card device driver -.SH SYNOPSIS -.LP -.nf -pcata@socket#:a -u -.fi - -.LP -.nf -pcata@socket#:a -u,raw -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBPCMCIA ATA\fR card device driver supports \fBPCMCIA ATA\fR disk and -flash cards that follow the following standards: -.RS +4 -.TP -.ie t \(bu -.el o -\fBPC\fR card 2.01 compliance (\fBMBR+fdisk\fR table required for all -platforms). -.RE -.RS +4 -.TP -.ie t \(bu -.el o -\fBPC\fR card \fBATA\fR 2.01 compliance. -.RE -.RS +4 -.TP -.ie t \(bu -.el o -\fBPC\fR card services 2.1 compliance. -.RE -.sp -.LP -The driver supports standard \fBPCMCIA ATA\fR cards that contain a Card -Information Structure (CIS). For \fBPCMCIA,\fR nodes are created in -\fB/devices\fR that include the socket number as one component of the device -name referred to by the node. However, the names in \fB/dev\fR, \fB/dev/dsk\fR, -and \fB/dev/rdsk\fR follow the current conventions for \fBATA\fR devices, which -do not encode the socket number in any part of the name. For example, you may -have the following: -.sp - -.sp -.TS -box; -l | l | l -l | l | l . -\fBPlatform\fR \fB/devices name\fR \fB/dev/dsk name\fR -_ -\fBx86\fR \fB/devices/isa/pcic@1,3e0 /disk@0:a\fR /dev/dsk/c1d0s0 -_ -SPARC T{ -\fB/devices/iommu@f,e0000000 /sbus@f,e0001000 /SUNW, pcmcia@3,0 /disk@0:a\fR -T} /dev/dsk/c1d0s0 -.TE - -.SH PRECONFIGURATION -.sp -.LP -If a PC Card ATA device is recognized, the pcata driver is automatically -loaded, IRQs allocated, devices nodes created, and special files created (if -they do not already exist). -.SS "Known Problems and Limitations" -.RS +4 -.TP -.ie t \(bu -.el o -You need to umount the file system before removing the disk. -.RE -.RS +4 -.TP -.ie t \(bu -.el o -The \fBufs\fR file systems on removable media (PC Card ATA) should have one of -the \fBonerror={panic, lock, umount\fR} mount options set. -.RE -.SH CONFIGURATION -.sp -.LP -Configuration topics include initial installation and configuration, -identifying an unrecognized device, special files and hot-plugging. -.SS "Initial Installation and Configuration" -.RS +4 -.TP -1. -Install the Solaris software. -.RE -.RS +4 -.TP -2. -Boot the system. -.RE -.RS +4 -.TP -3. -Insert the PC card ATA device. -.RE -.SS "Identifying an Unrecognized Device" -.sp -.LP -If you insert a PC card ATA device and it is not recognized (no special files -created), use the \fBprtconf\fR command to identify the problem. -.RS +4 -.TP -1. -Run the \fBprtconf -D\fR command to see if your \fBpcata\fR card is -recognized. (A recognized device will appear at the end of the \fBprtconf\fR -output. For example: -.sp -.in +2 -.nf -# prtconf -D -\&. . . -pcic, instance #0 (driver name: pcic) - . . . - disk, instance #0 -.fi -.in -2 - -.RE -.RS +4 -.TP -2. -If \fBpcata\fR does not appear in the \fBprtconf\fR output, there is a -problem with the PC card adapter configuration or with the hardware. Check to -see whether the problem is with the card or the adapter by trying to use the -card on another machine and by seeing if it works on the same machine using -DOS. -.RE -.SS "Special Files" -.sp -.LP -For PC card devices, nodes are created in \fB/devices\fR that include the -socket number as one component of a device name that the node refers to. -However, the \fB/prtc/dev\fR names and the names in \fB/dev/dsk\fR and -\fB/dev/rdsk\fR do follow the current convention for ATA devices, which do not -encode the socket number in any part of the name. -.SS "Hot-Plugging" -.RS +4 -.TP -.ie t \(bu -.el o -If you want to remove the disk, you must unmount the file system. -.RE -.RS +4 -.TP -.ie t \(bu -.el o -Use the \fBmkfs_pcfs\fR(1M) command to create a \fBpcfs\fR file system: -.sp -.in +2 -.nf -# mkfs -F pcfs /dev/rdsk/c#d#p0:d -.fi -.in -2 - -.RE -.RS +4 -.TP -.ie t \(bu -.el o -To mount a \fBpcfs\fR file system, type: -.sp -.in +2 -.nf -# mount -F pcfs /dev/dsk/c#d#p0:c /mnt -.fi -.in -2 - -.RE -.RS +4 -.TP -.ie t \(bu -.el o -If you want to create a \fBufs\fR file system, use the \fBnewfs\fR command and -type: -.sp -.in +2 -.nf -# newfs /dev/rdsk/c#d#s# -.fi -.in -2 - -.RE -.RS +4 -.TP -.ie t \(bu -.el o -To mount a \fBufs\fR file system, type: -.sp -.in +2 -.nf -# mount -F ufs /dev/dsk/c#d#s# /mnt -.fi -.in -2 - -.RE -.RS +4 -.TP -.ie t \(bu -.el o -To create a Solaris partition, run the format command and go to the Partition -menu. For more information, see the \fBformat\fR(1M) man page. -.RE -.SH FILES -.sp -.ne 2 -.na -\fB\fB/kernel/drv/pcata\fR\fR -.ad -.RS 21n -\fBpcata\fR driver -.RE - -.SH SEE ALSO -.sp -.LP -\fBformat\fR(1M), \fBmount\fR(1M), \fBnewfs\fR(1M), \fBpcmcia\fR(7D), -\fBattributes\fR(5), \fBpcfs\fR(7FS) diff --git a/usr/src/man/man7d/pcwl.7d b/usr/src/man/man7d/pcwl.7d deleted file mode 100644 index 852da94b7b..0000000000 --- a/usr/src/man/man7d/pcwl.7d +++ /dev/null @@ -1,88 +0,0 @@ -'\" te -.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PCWL 7D "Jan 24, 2007" -.SH NAME -pcwl \- Lucent/PrismII 802.11b wireless NIC driver -.SH DESCRIPTION -.sp -.LP -The \fBpcwl\fR \fI802.11b\fR wireless NIC driver is a multi- threaded, -loadable, clonable, GLDv3-based STREAMS driver. It supports the pccard and -PCI/MiniPCI cards with the Lucent and PrismII \fI802.11b\fR chipsets on x86 and -SPARC. -.SH DRIVER CONFIGURATION -.sp -.LP -The \fBpcwl\fR driver supports \fI802.11b\fR data rates of 1, 2, 5.5 and 11 -(Mbits/sec). The default is 11. -.sp -.LP -The \fBpcwl\fR driver supports BSS networks (also known as "ap" or -"infrastructure" networks) and IBSS (or "ad-hoc") networks. For authentication -type, the \fBpcwl\fR driver supports the "open" (or "open-system") mode and the -"shared-key" mode. For encryption type, only WEP is currently supported. You -perform configuration and administration tasks using the \fBdladm\fR(1M) and -\fBwificonfig\fR(1M) utilities. -.SH FILES -.sp -.ne 2 -.na -\fB\fB/dev/pcwl*\fR\fR -.ad -.RS 28n -Special character device. -.RE - -.sp -.ne 2 -.na -\fB/kernel/drv/pcwl \fR -.ad -.RS 28n -32-bit ELF kernel module (x86). -.RE - -.sp -.ne 2 -.na -\fB\fB/kernel/drv/amd64/pcwl\fR\fR -.ad -.RS 28n -64-bit ELF kernel module (x86). -.RE - -.sp -.ne 2 -.na -\fB\fB/kernel/drv/sparcv9/pcwl\fR\fR -.ad -.RS 28n -64-bit ELF kernel module (SPARC). -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for a description of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Architecture x86 -.TE - -.SH SEE ALSO -.sp -.LP -\fBdladm\fR(1M), \fBwificonfig\fR(1M), \fBattributes\fR(5), \fBgld\fR(7D) -.sp -.LP -\fI802.11b Standard for Wireless Local Area Networks (WLANs)\fR - IEEE diff --git a/usr/src/pkg/manifests/driver-network-pcan.mf b/usr/src/pkg/manifests/driver-network-pcan.mf index 85c655e3ba..27d64ea164 100644 --- a/usr/src/pkg/manifests/driver-network-pcan.mf +++ b/usr/src/pkg/manifests/driver-network-pcan.mf @@ -29,26 +29,6 @@ # information about overriding the defaults. # <include global_zone_only_component> -set name=pkg.fmri value=pkg:/driver/network/pcan@$(PKGVERS) -set name=pkg.description value="Cisco-Aironet 802.11b driver" -set name=pkg.summary value="Cisco-Aironet 802.11b driver" -set name=info.classification \ - value=org.opensolaris.category.2008:Drivers/Networking +set name=pkg.fmri value=pkg:/driver/network/pcan@0.5.11,5.11-0.148 +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=kernel group=sys -dir path=kernel/drv group=sys -dir path=kernel/drv/$(ARCH64) group=sys -dir path=usr/share/man -dir path=usr/share/man/man7d -driver name=pcan clone_perms="pcan 0666 root sys" perms="* 0666 root sys" \ - alias=pccard15f,7 \ - alias=pccard15f,a \ - alias=pci14b9,5000 \ - alias=pci14b9,a504 -file path=kernel/drv/$(ARCH64)/pcan group=sys -$(i386_ONLY)file path=kernel/drv/pcan group=sys -file path=usr/share/man/man7d/pcan.7d -legacy pkg=SUNWpcan desc="Cisco-Aironet 802.11b driver" \ - name="Cisco-Aironet 802.11b driver" -license usr/src/uts/common/io/pcan/THIRDPARTYLICENSE \ - license=usr/src/uts/common/io/pcan/THIRDPARTYLICENSE diff --git a/usr/src/pkg/manifests/driver-network-pcwl.mf b/usr/src/pkg/manifests/driver-network-pcwl.mf index 0d1d8d6f5d..ecef6ab523 100644 --- a/usr/src/pkg/manifests/driver-network-pcwl.mf +++ b/usr/src/pkg/manifests/driver-network-pcwl.mf @@ -29,28 +29,6 @@ # information about overriding the defaults. # <include global_zone_only_component> -set name=pkg.fmri value=pkg:/driver/network/pcwl@$(PKGVERS) -set name=pkg.description value="Lucent/PRISM-II 802.11b driver" -set name=pkg.summary value="Lucent/PRISM-II 802.11b driver" -set name=info.classification \ - value=org.opensolaris.category.2008:Drivers/Networking +set name=pkg.fmri value=pkg:/driver/network/pcwl@0.5.11,5.11-0.148 +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=kernel group=sys -dir path=kernel/drv group=sys -dir path=kernel/drv/$(ARCH64) group=sys -dir path=usr/share/man -dir path=usr/share/man/man7d -driver name=pcwl clone_perms="pcwl 0666 root sys" perms="* 0666 root sys" \ - alias=pccard138,2 \ - alias=pccard156,2 \ - alias=pccardb,7300 \ - alias=pci1260,3872 \ - alias=pci1260,3873 \ - alias=pci1385,4105 -file path=kernel/drv/$(ARCH64)/pcwl group=sys -$(i386_ONLY)file path=kernel/drv/pcwl group=sys -file path=usr/share/man/man7d/pcwl.7d -legacy pkg=SUNWpcwl desc="Lucent/PRISM-II 802.11b driver" \ - name="Lucent/PRISM-II 802.11b driver" -license usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE \ - license=usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE diff --git a/usr/src/pkg/manifests/driver-serial-pcser.mf b/usr/src/pkg/manifests/driver-serial-pcser.mf index c326c67f74..b8e055bb4d 100644 --- a/usr/src/pkg/manifests/driver-serial-pcser.mf +++ b/usr/src/pkg/manifests/driver-serial-pcser.mf @@ -29,24 +29,6 @@ # information about overriding the defaults. # <include global_zone_only_component> -set name=pkg.fmri value=pkg:/driver/serial/pcser@$(PKGVERS) -set name=pkg.description value="PCMCIA serial card driver" -set name=pkg.summary value="PCMCIA serial card driver" -set name=info.classification \ - value="org.opensolaris.category.2008:Drivers/Other Peripherals" +set name=pkg.fmri value=pkg:/driver/serial/pcser@0.5.11,5.11-0.148 +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=kernel group=sys -dir path=kernel/drv group=sys -dir path=kernel/drv/$(ARCH64) group=sys -driver name=pcser perms="* 0666 uucp uucp" \ - alias=pccard,Intel_MODEM_2400+_iNC110US_A- \ - alias=pccard,serial \ - alias=pccard102,2 \ - alias=pccard102,5 -file path=kernel/drv/$(ARCH64)/pcser group=sys -$(i386_ONLY)file path=kernel/drv/pcser group=sys -legacy pkg=SUNWpcser desc="PCMCIA serial card driver" \ - name="PCMCIA serial card driver" -license cr_Sun license=cr_Sun -license lic_OSBL license=lic_OSBL -license lic_OSBL_preamble license=lic_OSBL_preamble diff --git a/usr/src/pkg/manifests/driver-storage-pcata.mf b/usr/src/pkg/manifests/driver-storage-pcata.mf index 6da2f654b9..b27cc7b59e 100644 --- a/usr/src/pkg/manifests/driver-storage-pcata.mf +++ b/usr/src/pkg/manifests/driver-storage-pcata.mf @@ -28,23 +28,8 @@ # global zone only. See the include file for greater detail, as well as # information about overriding the defaults. # + <include global_zone_only_component> -set name=pkg.fmri value=pkg:/driver/storage/pcata@$(PKGVERS) -set name=pkg.description value="PCMCIA ATA card driver" -set name=pkg.summary value="PCMCIA ATA card driver" -set name=info.classification \ - value="org.opensolaris.category.2008:Drivers/Other Peripherals" +set name=pkg.fmri value=pkg:/driver/storage/pcata@0.5.11,5.11-0.148 +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=kernel group=sys -dir path=kernel/drv group=sys -dir path=kernel/drv/$(ARCH64) group=sys -dir path=usr/share/man -dir path=usr/share/man/man7d -driver name=pcata alias=pccard,disk -file path=kernel/drv/$(ARCH64)/pcata group=sys -$(i386_ONLY)file path=kernel/drv/pcata group=sys -file path=usr/share/man/man7d/pcata.7d -legacy pkg=SUNWpsdpr desc="PCMCIA ATA card driver" \ - name="PCMCIA ATA card driver" -license cr_Sun license=cr_Sun -license lic_CDDL license=lic_CDDL diff --git a/usr/src/pkg/manifests/service-storage-removable-media.mf b/usr/src/pkg/manifests/service-storage-removable-media.mf index 68027cffe9..f7f16b2d22 100644 --- a/usr/src/pkg/manifests/service-storage-removable-media.mf +++ b/usr/src/pkg/manifests/service-storage-removable-media.mf @@ -21,6 +21,7 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # set name=pkg.fmri value=pkg:/service/storage/removable-media@$(PKGVERS) @@ -48,12 +49,10 @@ file path=usr/lib/llib-lsmedia file path=usr/lib/llib-lsmedia.ln file path=usr/lib/smedia/$(ARCH64)/sm_blkdev.so.1 mode=0555 file path=usr/lib/smedia/$(ARCH64)/sm_fd.so.1 mode=0555 -file path=usr/lib/smedia/$(ARCH64)/sm_pcata.so.1 mode=0555 file path=usr/lib/smedia/$(ARCH64)/sm_scsi.so.1 mode=0555 file path=usr/lib/smedia/rpc.smserverd mode=0555 file path=usr/lib/smedia/sm_blkdev.so.1 mode=0555 file path=usr/lib/smedia/sm_fd.so.1 mode=0555 -file path=usr/lib/smedia/sm_pcata.so.1 mode=0555 file path=usr/lib/smedia/sm_scsi.so.1 mode=0555 file path=usr/share/man/man1m/rpc.smserverd.1m legacy pkg=SUNWsmedia desc="Storage media management library" \ diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf index 329bec1470..dd231b99ea 100644 --- a/usr/src/pkg/manifests/system-header.mf +++ b/usr/src/pkg/manifests/system-header.mf @@ -23,6 +23,7 @@ # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright 2012 Nexenta Systems, Inc. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # set name=pkg.fmri value=pkg:/system/header@$(PKGVERS) @@ -102,7 +103,6 @@ dir path=usr/include/sys/ib/mgt dir path=usr/include/sys/ib/mgt/ibmf dir path=usr/include/sys/iso dir path=usr/include/sys/lvm -dir path=usr/include/sys/pcmcia dir path=usr/include/sys/proc dir path=usr/include/sys/rsm $(i386_ONLY)dir path=usr/include/sys/sata group=sys @@ -1284,12 +1284,6 @@ $(i386_ONLY)file path=usr/include/sys/pcic_reg.h $(i386_ONLY)file path=usr/include/sys/pcic_var.h file path=usr/include/sys/pcie.h file path=usr/include/sys/pcmcia.h -file path=usr/include/sys/pcmcia/pcata.h -file path=usr/include/sys/pcmcia/pcser_conf.h -file path=usr/include/sys/pcmcia/pcser_io.h -file path=usr/include/sys/pcmcia/pcser_manuspec.h -file path=usr/include/sys/pcmcia/pcser_reg.h -file path=usr/include/sys/pcmcia/pcser_var.h file path=usr/include/sys/pctypes.h file path=usr/include/sys/pfmod.h file path=usr/include/sys/pg.h diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index db00154c56..075432f012 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -1724,14 +1724,6 @@ BUSRA_OBJS += busra.o PCS_OBJS += pcs.o -PCAN_OBJS += pcan.o - -PCATA_OBJS += pcide.o pcdisk.o pclabel.o pcata.o - -PCSER_OBJS += pcser.o pcser_cis.o - -PCWL_OBJS += pcwl.o - PSET_OBJS += pset.o OHCI_OBJS += ohci.o ohci_hub.o ohci_polled.o diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules index ed81764ae2..cc71c7ba85 100644 --- a/usr/src/uts/common/Makefile.rules +++ b/usr/src/uts/common/Makefile.rules @@ -22,6 +22,7 @@ # # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # # @@ -968,22 +969,10 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pci-ide/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) -$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pcmcia/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - -$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pcan/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pcn/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) -$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pcwl/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/ppp/sppp/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) @@ -2265,18 +2254,9 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/nxge/npi/%.c $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/pci-ide/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) -$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/pcmcia/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) - -$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/pcan/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) - $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/pcn/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) -$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/pcwl/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) - $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ppp/sppp/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/common/io/pcan/THIRDPARTYLICENSE b/usr/src/uts/common/io/pcan/THIRDPARTYLICENSE deleted file mode 100644 index 0b1d072bb3..0000000000 --- a/usr/src/uts/common/io/pcan/THIRDPARTYLICENSE +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/usr/src/uts/common/io/pcan/THIRDPARTYLICENSE.descrip b/usr/src/uts/common/io/pcan/THIRDPARTYLICENSE.descrip deleted file mode 100644 index 8860754322..0000000000 --- a/usr/src/uts/common/io/pcan/THIRDPARTYLICENSE.descrip +++ /dev/null @@ -1 +0,0 @@ -PCAN DRIVER diff --git a/usr/src/uts/common/io/pcan/pcan.c b/usr/src/uts/common/io/pcan/pcan.c deleted file mode 100644 index be1fbf4aec..0000000000 --- a/usr/src/uts/common/io/pcan/pcan.c +++ /dev/null @@ -1,4651 +0,0 @@ -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/conf.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/dlpi.h> -#include <sys/ethernet.h> -#include <sys/strsubr.h> -#include <sys/strsun.h> -#include <sys/stat.h> -#include <sys/byteorder.h> -#include <sys/pccard.h> -#include <sys/pci.h> -#include <sys/policy.h> -#include <sys/mac_provider.h> -#include <sys/stream.h> -#include <inet/common.h> -#include <inet/nd.h> -#include <inet/mi.h> - -#include "pcan.h" -#include <sys/mac_wifi.h> -#include <inet/wifi_ioctl.h> - -#ifdef DEBUG -#define PCAN_DBG_BASIC 0x1 -#define PCAN_DBG_INFO 0x2 -#define PCAN_DBG_SEND 0x4 -#define PCAN_DBG_RCV 0x8 -#define PCAN_DBG_LINKINFO 0x10 -#define PCAN_DBG_FW_VERSION 0x20 -#define PCAN_DBG_CMD 0x40 -uint32_t pcan_debug = 0; -#define PCANDBG(x) \ - if (pcan_debug & PCAN_DBG_BASIC) cmn_err x -#else -#define PCANDBG(x) -#endif - -static ddi_device_acc_attr_t accattr = { - DDI_DEVICE_ATTR_V0, - DDI_STRUCTURE_LE_ACC, - DDI_STRICTORDER_ACC, -}; - -static ddi_dma_attr_t control_cmd_dma_attr = { - DMA_ATTR_V0, /* version of this structure */ - 0, /* lowest usable address */ - 0xffffffffffffffffull, /* highest usable address */ - 0xffffffffull, /* maximum DMAable byte count */ - 4, /* alignment in bytes */ - 0xfff, /* burst sizes (any) */ - 1, /* minimum transfer */ - 0xffffull, /* maximum transfer */ - 0xffffffffffffffffull, /* maximum segment length */ - 1, /* maximum number of segments */ - 1, /* granularity */ - 0, /* flags (reserved) */ -}; - -void *pcan_soft_state_p = NULL; -static int pcan_device_type; - -/* - * brussels - */ -static int pcan_m_setprop(void *arg, const char *pr_name, - mac_prop_id_t wldp_pr_num, uint_t wldp_length, - const void *wldp_buf); -static int pcan_m_getprop(void *arg, const char *pr_name, - mac_prop_id_t wldp_pr_num, uint_t wldp_length, void *wldp_buf); -static void pcan_m_propinfo(void *arg, const char *pr_name, - mac_prop_id_t wldp_pr_num, mac_prop_info_handle_t mph); - -mac_callbacks_t pcan_m_callbacks = { - MC_IOCTL | MC_SETPROP | MC_GETPROP | MC_PROPINFO, - pcan_gstat, - pcan_start, - pcan_stop, - pcan_prom, - pcan_sdmulti, - pcan_saddr, - pcan_tx, - NULL, - pcan_ioctl, - NULL, - NULL, - NULL, - pcan_m_setprop, - pcan_m_getprop, - pcan_m_propinfo -}; - -static char *pcan_name_str = "pcan"; - -#ifdef __sparc -#define pcan_quiesce ddi_quiesce_not_supported -#else -static int pcan_quiesce(dev_info_t *); -#endif - -DDI_DEFINE_STREAM_OPS(pcan_dev_ops, nulldev, pcan_probe, pcan_attach, - pcan_detach, nodev, NULL, D_MP, NULL, pcan_quiesce); - -extern struct mod_ops mod_driverops; -static struct modldrv modldrv = { - &mod_driverops, - "Cisco-Aironet 802.11b driver", - &pcan_dev_ops -}; - -static struct modlinkage modlinkage = { - MODREV_1, (void *)&modldrv, NULL - }; - -int -_init(void) -{ - int stat; - - /* Allocate soft state */ - if ((stat = ddi_soft_state_init(&pcan_soft_state_p, - sizeof (pcan_maci_t), 2)) != DDI_SUCCESS) - return (stat); - - mac_init_ops(&pcan_dev_ops, "pcan"); - stat = mod_install(&modlinkage); - if (stat != 0) { - mac_fini_ops(&pcan_dev_ops); - ddi_soft_state_fini(&pcan_soft_state_p); - } - - return (stat); -} - -int -_fini(void) -{ - int stat; - - stat = mod_remove(&modlinkage); - if (stat != DDI_SUCCESS) - return (stat); - mac_fini_ops(&pcan_dev_ops); - ddi_soft_state_fini(&pcan_soft_state_p); - return (stat); -} - -int -_info(struct modinfo *modinfop) -{ - return (mod_info(&modlinkage, modinfop)); -} - -static int -pcan_probe(dev_info_t *dip) -{ - int len, ret; - char *buf; - dev_info_t *pdip = ddi_get_parent(dip); - - PCANDBG((CE_NOTE, "pcan probe: parent dip=0x%p-%s(%d)\n", (void *)pdip, - ddi_driver_name(pdip), ddi_get_instance(pdip))); - - ret = ddi_getlongprop(DDI_DEV_T_ANY, pdip, 0, "device_type", - (caddr_t)&buf, &len); - if (ret != DDI_SUCCESS) - return (DDI_PROBE_FAILURE); - - PCANDBG((CE_NOTE, "pcan probe: device_type %s\n", buf)); - if ((strcmp(buf, "pccard") == 0) || (strcmp(buf, "pcmcia") == 0)) { - pcan_device_type = PCAN_DEVICE_PCCARD; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_FW_VERSION) { - cmn_err(CE_NOTE, "Cisco 802.11 pccard\n"); - } -#endif - ret = DDI_PROBE_SUCCESS; - } else if (strcmp(buf, "pci") == 0) { - pcan_device_type = PCAN_DEVICE_PCI; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_FW_VERSION) { - cmn_err(CE_NOTE, "Cisco 802.11 minipci card\n"); - } -#endif - ret = DDI_PROBE_SUCCESS; - } else { - cmn_err(CE_NOTE, "pcan probe: unsupported card\n"); - ret = DDI_PROBE_FAILURE; - } - - kmem_free(buf, len); - return (ret); -} - -static int -pcan_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - int ret; - int instance; - uint16_t stat; - uint32_t err; - pcan_maci_t *pcan_p; - wifi_data_t wd = { 0 }; - mac_register_t *macp; - modify_config_t cfgmod; - char strbuf[256]; - - PCANDBG((CE_NOTE, "dip=0x%p cmd=%x\n", (void *)dip, cmd)); - if (cmd != DDI_ATTACH) - goto attach_fail1; - - /* - * Since this driver is porting from freebsd, so just like - * the original driver, the minipci card doesn't work on amd64 - * machine. - * For sparc, since no pci card is available for the test, so this - * version doesn't support sparc. If there is card available and - * requirement, future version will try to support sparc. - * This driver works well for minipci card on 32bit x86 - * machine, so keep the code to just support minipci card on 32bit - * mode. - */ -#if defined(sparc) || defined(__sparc) - if (pcan_device_type == PCAN_DEVICE_PCI) { - cmn_err(CE_NOTE, "pcan attach: this driver does not support " - "PCI/MiniPCI card on Sparc\n"); - goto attach_fail1; - } -#endif /* sparc */ -#if defined(__amd64) - if (pcan_device_type == PCAN_DEVICE_PCI) { - cmn_err(CE_NOTE, "pcan attach: this driver does not support " - "PCI/MiniPCI card on amd64\n"); - goto attach_fail1; - } -#endif /* amd64 */ - - /* Allocate soft state associated with this instance. */ - if (ddi_soft_state_zalloc(pcan_soft_state_p, - ddi_get_instance(dip)) != DDI_SUCCESS) { - cmn_err(CE_CONT, "pcan attach: alloc softstate failed\n"); - goto attach_fail1; - } - pcan_p = (pcan_maci_t *)ddi_get_soft_state(pcan_soft_state_p, - ddi_get_instance(dip)); - - pcan_p->pcan_device_type = pcan_device_type; - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - if (ddi_regs_map_setup(dip, 0, - (caddr_t *)&pcan_p->pcan_cfg_base, 0, 0, - &accattr, &pcan_p->pcan_cfg_handle) != DDI_SUCCESS) - goto attach_fail2; - - stat = ddi_get16(pcan_p->pcan_cfg_handle, - (uint16_t *)(pcan_p->pcan_cfg_base + PCI_CONF_COMM)); - stat |= (PCI_COMM_IO | PCI_COMM_MAE); - ddi_put16(pcan_p->pcan_cfg_handle, - (uint16_t *)(pcan_p->pcan_cfg_base + PCI_CONF_COMM), stat); - - ddi_regs_map_free(&pcan_p->pcan_cfg_handle); - if (ddi_regs_map_setup(dip, 1, (caddr_t *)&pcan_p->pcan_bar0, - 0, 0, &accattr, &pcan_p->pcan_handle0) != DDI_SUCCESS) - goto attach_fail3; - if (ddi_regs_map_setup(dip, 2, (caddr_t *)&pcan_p->pcan_bar1, - 0, 0, &accattr, &pcan_p->pcan_handle1) != DDI_SUCCESS) - goto attach_fail3; - if (ddi_regs_map_setup(dip, 3, (caddr_t *)&pcan_p->pcan_bar2, - 0, 0, &accattr, &pcan_p->pcan_handle2) != DDI_SUCCESS) - goto attach_fail3; - } - - pcan_p->pcan_dip = dip; - pcan_p->pcan_flag = 0; - pcan_p->glds_nocarrier = 0; - pcan_p->glds_noxmtbuf = 0; - pcan_p->glds_norcvbuf = 0; - pcan_p->pcan_socket = ddi_getprop(DDI_DEV_T_NONE, dip, - DDI_PROP_DONTPASS, "socket", -1); - - pcan_p->pcan_reschedule_need = B_FALSE; - pcan_p->pcan_info_softint_pending = 0; - pcan_p->pcan_reset_delay = ddi_getprop(DDI_DEV_T_ANY, dip, - DDI_PROP_DONTPASS, "reset-delay", 5000); - - if (ddi_get_iblock_cookie(dip, - 0, &pcan_p->pcan_ib_cookie) != DDI_SUCCESS) { - cmn_err(CE_WARN, "pcan attach: get_iblk_cookie failed\n"); - goto attach_fail3; - } - - mutex_init(&pcan_p->pcan_glock, NULL, - MUTEX_DRIVER, pcan_p->pcan_ib_cookie); - mutex_init(&pcan_p->pcan_scanlist_lock, NULL, - MUTEX_DRIVER, pcan_p->pcan_ib_cookie); - mutex_init(&pcan_p->pcan_txring.an_tx_lock, NULL, - MUTEX_DRIVER, pcan_p->pcan_ib_cookie); - - if (ret = ddi_add_softintr(dip, DDI_SOFTINT_LOW, - &pcan_p->pcan_info_softint_id, &pcan_p->pcan_ib_cookie, NULL, - pcan_info_softint, (caddr_t)pcan_p)) { - cmn_err(CE_WARN, "pcan attach: add info_softintr failed\n"); - goto attach_fail3a; - } - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - if (ret = ddi_add_intr(dip, 0, NULL, NULL, - pcan_intr, (caddr_t)pcan_p)) { - cmn_err(CE_WARN, "pcan attach: add intr failed\n"); - goto attach_fail4; - } - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - if (ret = pcan_register_cs(dip, pcan_p)) { - PCANDBG((CE_NOTE, "pcan attach: register_cs failed" - " %x\n", ret)); - goto attach_fail4; - } - } else { - cmn_err(CE_WARN, "pcan attach: unsupported device type\n"); - goto attach_fail4; - } - - mutex_enter(&pcan_p->pcan_glock); - pcan_reset_backend(pcan_p, pcan_p->pcan_reset_delay); - /* leaves IF down, intr disabled */ - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - if (ret = pcan_init_dma(dip, pcan_p)) { - cmn_err(CE_WARN, "pcan init_dma: failed\n"); - mutex_exit(&pcan_p->pcan_glock); - goto attach_fail5; - } - } - if (ret = pcan_get_cap(pcan_p)) { /* sets macaddr for gld_register */ - cmn_err(CE_WARN, "pcan attach: get_cap failed %x\n", ret); - mutex_exit(&pcan_p->pcan_glock); - goto attach_fail6; - } - - mutex_exit(&pcan_p->pcan_glock); - /* - * Provide initial settings for the WiFi plugin; whenever this - * information changes, we need to call mac_pdata_update() - */ - wd.wd_secalloc = WIFI_SEC_NONE; - wd.wd_opmode = IEEE80211_M_STA; - - macp = mac_alloc(MAC_VERSION); - if (macp == NULL) { - PCANDBG((CE_NOTE, "pcan attach: " - "MAC version mismatch\n")); - goto attach_fail6; - } - - macp->m_type_ident = MAC_PLUGIN_IDENT_WIFI; - macp->m_driver = pcan_p; - macp->m_dip = dip; - macp->m_src_addr = pcan_p->pcan_mac_addr; - macp->m_callbacks = &pcan_m_callbacks; - macp->m_min_sdu = 0; - macp->m_max_sdu = IEEE80211_MTU; - macp->m_pdata = &wd; - macp->m_pdata_size = sizeof (wd); - - err = mac_register(macp, &pcan_p->pcan_mh); - mac_free(macp); - if (err != 0) { - PCANDBG((CE_NOTE, "pcan attach: " - "mac_register err\n")); - goto attach_fail6; - } - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - /* turn on CS interrupt */ - cfgmod.Attributes = CONF_ENABLE_IRQ_STEERING | - CONF_IRQ_CHANGE_VALID; - cfgmod.Vpp1 = 50; - cfgmod.Vpp2 = 50; - (void) csx_ModifyConfiguration(pcan_p->pcan_chdl, &cfgmod); - - mutex_enter(&pcan_p->pcan_glock); - if (ret = pcan_init_nicmem(pcan_p)) { - cmn_err(CE_WARN, "pcan attach: init_nicmem failed %x\n", - ret); - mutex_exit(&pcan_p->pcan_glock); - goto attach_fail7; - } - mutex_exit(&pcan_p->pcan_glock); - } - (void) ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, - "bad-rids", (caddr_t)&pcan_p->pcan_badrids, - &pcan_p->pcan_badrids_len); - - pcan_p->an_config.an_rxmode = AN_NORMAL_RXMODE; - ether_copy(pcan_p->pcan_mac_addr, pcan_p->an_config.an_macaddr); - mutex_enter(&pcan_p->pcan_glock); - list_create(&pcan_p->an_scan_list, sizeof (an_scan_list_t), - offsetof(an_scan_list_t, an_scan_node)); - pcan_p->an_scan_num = 0; - mutex_exit(&pcan_p->pcan_glock); - pcan_p->an_scanlist_timeout_id = timeout(pcan_scanlist_timeout, - pcan_p, drv_usectohz(1000000)); - - instance = ddi_get_instance(dip); - (void) snprintf(strbuf, sizeof (strbuf), "pcan%d", instance); - if (ddi_create_minor_node(dip, strbuf, S_IFCHR, - instance + 1, DDI_NT_NET_WIFI, 0) != DDI_SUCCESS) { - goto attach_fail8; - } - mutex_enter(&pcan_p->pcan_glock); - PCAN_DISABLE_INTR_CLEAR(pcan_p); - (void) pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0); - pcan_p->pcan_flag |= PCAN_ATTACHED; - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - pcan_p->pcan_flag |= PCAN_CARD_READY; - } - mutex_exit(&pcan_p->pcan_glock); - return (DDI_SUCCESS); -attach_fail8: - if (pcan_p->an_scanlist_timeout_id != 0) { - (void) untimeout(pcan_p->an_scanlist_timeout_id); - pcan_p->an_scanlist_timeout_id = 0; - } - list_destroy(&pcan_p->an_scan_list); -attach_fail7: - (void) mac_unregister(pcan_p->pcan_mh); -attach_fail6: - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) - pcan_free_dma(pcan_p); -attach_fail5: - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - ddi_remove_intr(dip, 0, pcan_p->pcan_ib_cookie); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - pcan_unregister_cs(pcan_p); - } -attach_fail4: - if (pcan_p->pcan_info_softint_id) - ddi_remove_softintr(pcan_p->pcan_info_softint_id); -attach_fail3a: - pcan_destroy_locks(pcan_p); -attach_fail3: - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - if (pcan_p->pcan_handle0) - ddi_regs_map_free(&pcan_p->pcan_handle0); - if (pcan_p->pcan_handle1) - ddi_regs_map_free(&pcan_p->pcan_handle1); - if (pcan_p->pcan_handle2) - ddi_regs_map_free(&pcan_p->pcan_handle2); - } -attach_fail2: - ddi_soft_state_free(pcan_soft_state_p, ddi_get_instance(dip)); -attach_fail1: - return (DDI_FAILURE); -} - -static int -pcan_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - pcan_maci_t *pcan_p; - an_scan_list_t *scan_item0; - int ret; - pcan_p = ddi_get_soft_state(pcan_soft_state_p, ddi_get_instance(dip)); - - if (cmd != DDI_DETACH) - return (DDI_FAILURE); - if (!(pcan_p->pcan_flag & PCAN_ATTACHED)) - return (DDI_FAILURE); - - ret = mac_disable(pcan_p->pcan_mh); - if (ret != 0) - return (DDI_FAILURE); - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - mutex_enter(&pcan_p->pcan_glock); - pcan_stop_locked(pcan_p); - PCAN_DISABLE_INTR(pcan_p); - mutex_exit(&pcan_p->pcan_glock); - } - if (pcan_p->an_scanlist_timeout_id != 0) { - (void) untimeout(pcan_p->an_scanlist_timeout_id); - pcan_p->an_scanlist_timeout_id = 0; - } - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - mutex_enter(&pcan_p->pcan_scanlist_lock); - scan_item0 = list_head(&pcan_p->an_scan_list); - while (scan_item0) { - pcan_delete_scan_item(pcan_p, scan_item0); - scan_item0 = list_head(&pcan_p->an_scan_list); - } - list_destroy(&pcan_p->an_scan_list); - mutex_exit(&pcan_p->pcan_scanlist_lock); - - (void) mac_unregister(pcan_p->pcan_mh); - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - mutex_enter(&pcan_p->pcan_glock); - ddi_remove_intr(dip, 0, pcan_p->pcan_ib_cookie); - pcan_free_dma(pcan_p); - if (pcan_p->pcan_handle0) - ddi_regs_map_free(&pcan_p->pcan_handle0); - if (pcan_p->pcan_handle1) - ddi_regs_map_free(&pcan_p->pcan_handle1); - if (pcan_p->pcan_handle2) - ddi_regs_map_free(&pcan_p->pcan_handle2); - mutex_exit(&pcan_p->pcan_glock); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - pcan_unregister_cs(pcan_p); - } else { - cmn_err(CE_WARN, "pcan detach: unsupported device type\n"); - } - pcan_destroy_locks(pcan_p); - if (pcan_p->pcan_info_softint_id) - ddi_remove_softintr(pcan_p->pcan_info_softint_id); - - if (pcan_p->pcan_badrids_len) - kmem_free(pcan_p->pcan_badrids, pcan_p->pcan_badrids_len); - - ddi_soft_state_free(pcan_soft_state_p, ddi_get_instance(dip)); - ddi_remove_minor_node(dip, NULL); - - return (DDI_SUCCESS); -} - -/* - * card services and event handlers - */ - -static int -pcan_register_cs(dev_info_t *dip, pcan_maci_t *pcan_p) -{ - int ret; - client_reg_t cr; - client_handle_t chdl; /* uint encoding of socket, function, client */ - get_status_t card_status; - request_socket_mask_t sock_req; - - bzero(&cr, sizeof (cr)); - cr.Attributes = INFO_IO_CLIENT|INFO_CARD_EXCL|INFO_CARD_SHARE; - cr.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_REGISTRATION_COMPLETE | CS_EVENT_CARD_REMOVAL_LOWP | - CS_EVENT_CARD_READY | CS_EVENT_PM_RESUME | CS_EVENT_PM_SUSPEND | - CS_EVENT_CLIENT_INFO; - cr.event_callback_args.client_data = pcan_p; - cr.Version = CS_VERSION; - cr.event_handler = (csfunction_t *)pcan_ev_hdlr; - cr.dip = dip; - (void) strcpy(cr.driver_name, pcan_name_str); - if (ret = csx_RegisterClient(&chdl, &cr)) { - cmn_err(CE_WARN, "pcan: RegisterClient failed %x", ret); - goto regcs_ret; - } - - pcan_p->pcan_chdl = chdl; - - bzero(&card_status, sizeof (card_status)); - (void) csx_GetStatus(chdl, &card_status); - PCANDBG((CE_NOTE, "pcan: getstat Sock=%x CState=%x SState=%x rState=%x", - card_status.Socket, card_status.CardState, - card_status.SocketState, card_status.raw_CardState)); - if (!(card_status.CardState & CS_STATUS_CARD_INSERTED)) { - /* card is not present, why are we attaching ? */ - ret = CS_NO_CARD; - goto unreg; - } - cv_init(&pcan_p->pcan_cscv, NULL, CV_DRIVER, NULL); - mutex_init(&pcan_p->pcan_cslock, NULL, MUTEX_DRIVER, *cr.iblk_cookie); - mutex_enter(&pcan_p->pcan_cslock); - if (ret = csx_MapLogSocket(chdl, &pcan_p->pcan_log_sock)) { - cmn_err(CE_WARN, "pcan: MapLogSocket failed %x", ret); - goto fail; - } - PCANDBG((CE_NOTE, "pcan: logsock: LogSock=%x PhyAdapter=%x PhySock=%x", - pcan_p->pcan_log_sock.LogSocket, - pcan_p->pcan_log_sock.PhyAdapter, - pcan_p->pcan_log_sock.PhySocket)); - - /* turn on initialization events */ - sock_req.Socket = 0; - sock_req.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_REGISTRATION_COMPLETE; - if (ret = csx_RequestSocketMask(chdl, &sock_req)) { - cmn_err(CE_WARN, "pcan: RequestSocketMask failed %x\n", ret); - goto fail; - } - - /* wait for and process card insertion events */ - while (!(pcan_p->pcan_flag & PCAN_CARD_READY)) - cv_wait(&pcan_p->pcan_cscv, &pcan_p->pcan_cslock); - mutex_exit(&pcan_p->pcan_cslock); - - pcan_p->pcan_flag |= PCAN_CS_REGISTERED; - return (CS_SUCCESS); -fail: - mutex_destroy(&pcan_p->pcan_cslock); - cv_destroy(&pcan_p->pcan_cscv); -unreg: - (void) csx_DeregisterClient(chdl); -regcs_ret: - pcan_p->pcan_flag &= ~PCAN_CS_REGISTERED; - return (ret); -} - -static void -pcan_unregister_cs(pcan_maci_t *pcan_p) -{ - int ret; - release_socket_mask_t mask; - mask.Socket = pcan_p->pcan_socket; - - /* - * The card service not registered means register_cs function - * doesnot return TRUE. Then all the lelated resource has been - * released in register_cs. - */ - if (!(pcan_p->pcan_flag | PCAN_CS_REGISTERED)) - return; - (void) csx_ReleaseSocketMask(pcan_p->pcan_chdl, &mask); - - if (pcan_p->pcan_flag & PCAN_CARD_READY) { - pcan_card_remove(pcan_p); - } - mutex_destroy(&pcan_p->pcan_cslock); - cv_destroy(&pcan_p->pcan_cscv); - if (ret = csx_DeregisterClient(pcan_p->pcan_chdl)) - cmn_err(CE_WARN, "pcan: deregister failed %x\n", ret); -} -static void -pcan_destroy_locks(pcan_maci_t *pcan_p) -{ - mutex_destroy(&pcan_p->pcan_txring.an_tx_lock); - mutex_destroy(&pcan_p->pcan_scanlist_lock); - mutex_destroy(&pcan_p->pcan_glock); -} - -static int -pcan_ev_hdlr(event_t event, int priority, event_callback_args_t *arg) -{ - int ret = CS_SUCCESS; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg->client_data; - client_info_t *ci_p = (client_info_t *)&arg->client_info; - - mutex_enter(&pcan_p->pcan_cslock); - switch (event) { - case CS_EVENT_CARD_INSERTION: - ret = pcan_card_insert(pcan_p); - cv_broadcast(&pcan_p->pcan_cscv); - break; - case CS_EVENT_REGISTRATION_COMPLETE: - cv_broadcast(&pcan_p->pcan_cscv); - break; - case CS_EVENT_CARD_REMOVAL: - if (priority & CS_EVENT_PRI_HIGH) - break; - pcan_card_remove(pcan_p); - cv_broadcast(&pcan_p->pcan_cscv); - break; - case CS_EVENT_CLIENT_INFO: - if (GET_CLIENT_INFO_SUBSVC(ci_p->Attributes) != - CS_CLIENT_INFO_SUBSVC_CS) - break; - - ci_p->Revision = 0x0101; - ci_p->CSLevel = CS_VERSION; - ci_p->RevDate = CS_CLIENT_INFO_MAKE_DATE(9, 12, 14); - (void) strcpy(ci_p->ClientName, PCAN_IDENT_STRING); - (void) strcpy(ci_p->VendorName, CS_SUN_VENDOR_DESCRIPTION); - ci_p->Attributes |= CS_CLIENT_INFO_VALID; - break; - case CS_EVENT_PM_SUSPEND: - pcan_do_suspend(pcan_p); - break; - default: - ret = CS_UNSUPPORTED_EVENT; - break; - } - mutex_exit(&pcan_p->pcan_cslock); - return (ret); -} - -static int -pcan_card_insert(pcan_maci_t *pcan_p) -{ - int ret, hi, lo; - tuple_t tuple; - cisparse_t cisparse; - io_req_t io; - irq_req_t irq; - config_req_t cfg; - cistpl_config_t config; - cistpl_cftable_entry_t *tbl_p; - register client_handle_t chdl = pcan_p->pcan_chdl; - modify_config_t cfgmod; - - bzero(&tuple, sizeof (tuple)); - tuple.DesiredTuple = CISTPL_MANFID; - if (ret = csx_GetFirstTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcan: get manufacture id failed %x\n", ret); - goto insert_ret; - } - bzero(&cisparse, sizeof (cisparse)); - if (ret = csx_Parse_CISTPL_MANFID(chdl, &tuple, &cisparse.manfid)) { - cmn_err(CE_WARN, "pcan: parse manufacture id failed %x\n", ret); - goto insert_ret; - } - /* verify manufacture ID */ - PCANDBG((CE_NOTE, "pcan: manufacturer_id=%x card=%x\n", - cisparse.manfid.manf, cisparse.manfid.card)); - - bzero(&tuple, sizeof (tuple)); - tuple.DesiredTuple = CISTPL_FUNCID; - if (ret = csx_GetFirstTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcan: get function id failed %x\n", ret); - goto insert_ret; - } - bzero(&cisparse, sizeof (cisparse)); - if (ret = csx_Parse_CISTPL_FUNCID(chdl, &tuple, &cisparse.funcid)) { - cmn_err(CE_WARN, "pcan: parse function id failed %x\n", ret); - goto insert_ret; - } - /* verify function ID */ - PCANDBG((CE_NOTE, "funcid=%x\n", cisparse.funcid.function)); - - bzero(&tuple, sizeof (tuple)); - tuple.DesiredTuple = CISTPL_CONFIG; - if (ret = csx_GetFirstTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcan: get config failed %x\n", ret); - goto insert_ret; - } - bzero(&config, sizeof (config)); - if (ret = csx_Parse_CISTPL_CONFIG(chdl, &tuple, &config)) { - cmn_err(CE_WARN, "pcan: parse config failed %x\n", ret); - goto insert_ret; - } - PCANDBG((CE_NOTE, - "pcan: config present=%x nr=%x hr=%x regs[0]=%x base=%x last=%x\n", - config.present, config.nr, config.hr, config.regs[0], - config.base, config.last)); - - hi = 0; - lo = (int)-1; /* really big number */ - tbl_p = &cisparse.cftable; - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - for (tbl_p->index = 0; tbl_p->index <= config.hr; ) { - PCANDBG((CE_NOTE, "pcan: tuple idx=%x:\n", tbl_p->index)); - if (ret = csx_GetNextTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcan: get cftable failed %x\n", ret); - break; - } - bzero((caddr_t)&cisparse, sizeof (cisparse)); - if (ret = csx_Parse_CISTPL_CFTABLE_ENTRY(chdl, &tuple, tbl_p)) { - cmn_err(CE_WARN, "pcan: parse cftable failed%x\n", ret); - break; - } - if (tbl_p->flags & CISTPL_CFTABLE_TPCE_FS_PWR && - tbl_p->pd.flags & CISTPL_CFTABLE_TPCE_FS_PWR_VCC) { - if (tbl_p->pd.pd_vcc.avgI > hi) { - hi = tbl_p->pd.pd_vcc.avgI; - pcan_p->pcan_config_hi = tbl_p->index; - } - if (tbl_p->pd.pd_vcc.avgI < lo) { - lo = tbl_p->pd.pd_vcc.avgI; - pcan_p->pcan_config = tbl_p->index; - } - } - if (tbl_p->flags & CISTPL_CFTABLE_TPCE_DEFAULT) { - if (tbl_p->pd.flags & CISTPL_CFTABLE_TPCE_FS_PWR_VCC) - pcan_p->pcan_vcc = tbl_p->pd.pd_vcc.nomV; - if (tbl_p->flags & CISTPL_CFTABLE_TPCE_FS_IO) - pcan_p->pcan_iodecode = tbl_p->io.addr_lines; - } - } - PCANDBG((CE_NOTE, "pcan: cfg_hi=%x cfg=%x vcc=%x iodecode=%x\n", - pcan_p->pcan_config_hi, pcan_p->pcan_config, - pcan_p->pcan_vcc, pcan_p->pcan_iodecode)); - - bzero(&io, sizeof (io)); - io.BasePort1.base = 0; - io.NumPorts1 = 1 << pcan_p->pcan_iodecode; - io.Attributes1 = IO_DATA_PATH_WIDTH_16; - io.IOAddrLines = pcan_p->pcan_iodecode; - if (ret = csx_RequestIO(chdl, &io)) { - cmn_err(CE_WARN, "pcan: RequestIO failed %x\n", ret); - goto insert_ret; - } - pcan_p->pcan_port = io.BasePort1.handle; - - if (ret = ddi_add_softintr(DIP(pcan_p), DDI_SOFTINT_HIGH, - &pcan_p->pcan_softint_id, &pcan_p->pcan_ib_cookie, NULL, - pcan_intr, (caddr_t)pcan_p)) { - cmn_err(CE_NOTE, "pcan: Add softintr failed\n"); - goto insert_ret; - } - irq.Attributes = IRQ_TYPE_EXCLUSIVE; - irq.irq_handler = ddi_intr_hilevel(DIP(pcan_p), 0) ? - (csfunction_t *)pcan_intr_hi : (csfunction_t *)pcan_intr; - irq.irq_handler_arg = pcan_p; - if (ret = csx_RequestIRQ(chdl, &irq)) { - cmn_err(CE_WARN, "pcan: RequestIRQ failed %x\n", ret); - goto un_io; - } - - bzero(&cfg, sizeof (cfg)); - cfg.Attributes = 0; /* not ready for CONF_ENABLE_IRQ_STEERING yet */ - cfg.Vcc = 50; /* pcan_vcc == 0 */ - cfg.Vpp1 = 50; - cfg.Vpp2 = 50; - cfg.IntType = SOCKET_INTERFACE_MEMORY_AND_IO; - cfg.ConfigBase = config.base; - cfg.ConfigIndex = pcan_p->pcan_config; - cfg.Status = CCSR_IO_IS_8; /* no use */ - cfg.Present = config.present; - pcan_p->pcan_flag |= PCAN_CARD_READY; - if (ret = csx_RequestConfiguration(chdl, &cfg)) { - cmn_err(CE_WARN, "pcan: RequestConfiguration failed %x\n", ret); - goto un_irq; - } - - if (pcan_p->pcan_flag & PCAN_SUSPENDED) { - mutex_enter(&pcan_p->pcan_glock); - pcan_reset_backend(pcan_p, pcan_p->pcan_reset_delay); - /* turn on CS interrupt */ - cfgmod.Attributes = CONF_ENABLE_IRQ_STEERING | - CONF_IRQ_CHANGE_VALID; - cfgmod.Vpp1 = 50; - cfgmod.Vpp2 = 50; - (void) csx_ModifyConfiguration(pcan_p->pcan_chdl, &cfgmod); - - if (ret = pcan_init_nicmem(pcan_p)) { - cmn_err(CE_WARN, "pcan insert: init_nicmem failed %x\n", - ret); - } - PCAN_DISABLE_INTR_CLEAR(pcan_p); - ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0); - PCANDBG((CE_NOTE, "pcan insert set cmd ret =%x\n", ret)); - pcan_p->pcan_flag &= ~PCAN_SUSPENDED; - mutex_exit(&pcan_p->pcan_glock); - } - - if (pcan_p->pcan_flag & PCAN_PLUMBED) { - (void) pcan_start(pcan_p); - pcan_p->pcan_flag &= ~PCAN_PLUMBED; - PCANDBG((CE_NOTE, "pcan insert: active interrupt\n")); - } - return (CS_SUCCESS); -un_irq: - (void) csx_ReleaseIRQ(chdl, &irq); -un_io: - ddi_remove_softintr(pcan_p->pcan_softint_id); - - (void) csx_ReleaseIO(chdl, &io); - pcan_p->pcan_port = 0; -insert_ret: - pcan_p->pcan_flag &= ~PCAN_CARD_READY; - return (ret); -} - -/* - * assume card is already removed, don't touch the hardware - */ -static void -pcan_do_suspend(pcan_maci_t *pcan_p) -{ - int ret; - if (pcan_p->pcan_flag & PCAN_CARD_LINKUP) { - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - mutex_enter(&pcan_p->pcan_glock); - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - if (ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0)) - PCANDBG((CE_NOTE, "pcan: disable failed, ret %d\n", - ret)); - if (ret = pcan_loaddef(pcan_p)) - PCANDBG((CE_NOTE, "pcan: loaddef failed, ret %d\n", - ret)); - mac_link_update(GLD3(pcan_p), LINK_STATE_DOWN); - mutex_exit(&pcan_p->pcan_glock); - } - pcan_p->pcan_flag |= PCAN_SUSPENDED; -} - - -/* - * assume card is already removed, don't touch the hardware - */ -static void -pcan_card_remove(pcan_maci_t *pcan_p) -{ - int ret; - io_req_t io; - irq_req_t irq; - - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) - return; - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - - if (pcan_p->pcan_flag & PCAN_CARD_LINKUP) { - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - mac_link_update(GLD3(pcan_p), LINK_STATE_DOWN); - } - mutex_enter(&pcan_p->pcan_glock); - if (pcan_p->pcan_flag & PCAN_CARD_INTREN) { - pcan_stop_locked(pcan_p); - pcan_p->pcan_flag |= PCAN_PLUMBED; - } - pcan_p->pcan_flag &= ~PCAN_CARD_READY; - mutex_exit(&pcan_p->pcan_glock); - - if (ret = csx_ReleaseConfiguration(pcan_p->pcan_chdl, NULL)) - cmn_err(CE_WARN, "pcan: ReleaseConfiguration failed %x\n", ret); - - bzero(&irq, sizeof (irq)); - if (ret = csx_ReleaseIRQ(pcan_p->pcan_chdl, &irq)) - cmn_err(CE_WARN, "pcan: ReleaseIRQ failed %x\n", ret); - - ddi_remove_softintr(pcan_p->pcan_softint_id); - pcan_p->pcan_softint_id = 0; - - bzero(&io, sizeof (io)); - io.BasePort1.handle = pcan_p->pcan_port; - io.NumPorts1 = 16; - if (ret = csx_ReleaseIO(pcan_p->pcan_chdl, &io)) - cmn_err(CE_WARN, "pcan: Release IO failed %x\n", ret); - - pcan_p->pcan_port = 0; - PCANDBG((CE_NOTE, "pcan: removed\n")); -} - -/* - * gld operation interface routines - */ -static int -pcan_start(void *arg) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_FAIL); - } - (void) pcan_loaddef(pcan_p); - pcan_start_locked(pcan_p); - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_SUCCESS); -} - -static void -pcan_stop(void *arg) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return; - } - pcan_stop_locked(pcan_p); - mutex_exit(&pcan_p->pcan_glock); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } -} - -/* - * mac address can only be set in 'disable' state and - * be effective after 'enable' state. - */ -static int -pcan_saddr(void *arg, const uint8_t *macaddr) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - int ret = PCAN_SUCCESS; - ether_copy(macaddr, pcan_p->pcan_mac_addr); - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - ret = PCAN_FAIL; - goto done; - } - ether_copy(pcan_p->pcan_mac_addr, pcan_p->an_config.an_macaddr); - if (pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0)) { - cmn_err(CE_WARN, "pcan set mac addr: failed\n"); - ret = PCAN_FAIL; - goto done; - } - if (pcan_config_mac(pcan_p)) { - cmn_err(CE_WARN, "pcan set mac addr: config_mac failed\n"); - ret = PCAN_FAIL; - goto done; - } - if (pcan_set_cmd(pcan_p, AN_CMD_ENABLE, 0)) { - cmn_err(CE_WARN, "pcan set mac addr: failed\n"); - ret = PCAN_FAIL; - } -done: - mutex_exit(&pcan_p->pcan_glock); - return (ret); -} - -/* - * send a packet out for pccard - */ -static int -pcan_send(pcan_maci_t *pcan_p, mblk_t *mblk_p) -{ - char *buf, *buf_p; - an_txfrm_t *frm_p; -#ifdef PCAN_SEND_DEBUG - struct an_ltv_status radio_status; -#endif /* PCAN_SEND_DEBUG */ - uint16_t pkt_len, xmt_id, ring_idx, r = 0; - struct ieee80211_frame *wh; - int i = 0; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - if (!(pcan_p->pcan_flag & PCAN_CARD_LINKUP)) { /* link down */ - PCANDBG((CE_NOTE, "pcan: link down, dropped\n")); - pcan_p->glds_nocarrier++; - mutex_exit(&pcan_p->pcan_glock); - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - mutex_exit(&pcan_p->pcan_glock); - if (pullupmsg(mblk_p, -1) == 0) { - cmn_err(CE_NOTE, "pcan send: pullupmsg failed\n"); - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - wh = (struct ieee80211_frame *)mblk_p->b_rptr; - - mutex_enter(&pcan_p->pcan_txring.an_tx_lock); - ring_idx = pcan_p->pcan_txring.an_tx_prod; - pcan_p->pcan_txring.an_tx_prod = (ring_idx + 1) & AN_TX_RING_MASK; - - /* check whether there is a xmt buffer available */ - while ((i < AN_TX_RING_CNT) && - (pcan_p->pcan_txring.an_tx_ring[ring_idx])) { - ring_idx = pcan_p->pcan_txring.an_tx_prod; - pcan_p->pcan_txring.an_tx_prod = - (ring_idx + 1) & AN_TX_RING_MASK; - i++; - } - - if (i == AN_TX_RING_CNT) { - mutex_exit(&pcan_p->pcan_txring.an_tx_lock); - PCANDBG((CE_NOTE, "pcan: ring full, retrying\n")); - mutex_enter(&pcan_p->pcan_glock); - pcan_p->pcan_reschedule_need = B_TRUE; - mutex_exit(&pcan_p->pcan_glock); - pcan_p->glds_noxmtbuf++; - return (PCAN_FAIL); - } - xmt_id = pcan_p->pcan_txring.an_tx_fids[ring_idx]; - pcan_p->pcan_txring.an_tx_ring[ring_idx] = xmt_id; - mutex_exit(&pcan_p->pcan_txring.an_tx_lock); - - buf = kmem_zalloc(PCAN_NICMEM_SZ, KM_SLEEP); /* too big for stack */ - buf_p = (ulong_t)buf & 1 ? buf + 1 : buf; /* 16-bit round up */ - frm_p = (an_txfrm_t *)buf_p; - -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_SEND) { - cmn_err(CE_NOTE, "pcan send: packet from plugin"); - for (i = 0; i < MBLKL(mblk_p); i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((unsigned char *)mblk_p->b_rptr + i)); - } -#endif - pkt_len = msgdsize(mblk_p); - if (pkt_len > PCAN_NICMEM_SZ - sizeof (an_txfrm_t)) { - cmn_err(CE_WARN, "pcan send: mblk is too long"); - kmem_free(buf, PCAN_NICMEM_SZ); - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) != - IEEE80211_FC1_DIR_TODS) { - kmem_free(buf, PCAN_NICMEM_SZ); - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - - /* initialize xmt frame header, payload_len must be stored in LE */ - bzero(frm_p, sizeof (an_txfrm_t) + 2); - frm_p->an_tx_ctl = AN_TXCTL_8023; - - /* - * mblk sent down from plugin includes station mode 802.11 frame and - * llc, so we here need to remove them and add an ethernet header. - */ - pkt_len = pkt_len - (sizeof (*wh) + sizeof (struct ieee80211_llc)) - + 2; - bcopy(wh->i_addr3, buf_p + 0x38, ETHERADDRL); /* dst macaddr */ - bcopy(wh->i_addr2, buf_p + 0x3e, ETHERADDRL); /* src macaddr */ - *((uint16_t *)(buf_p + 0x36)) = pkt_len; - bcopy(mblk_p->b_rptr + sizeof (*wh) + sizeof (struct ieee80211_llc) - - 2, buf_p + 0x44, pkt_len); - - if (pkt_len & 1) { /* round up to 16-bit boundary and pad 0 */ - buf_p[pkt_len + 0x44] = 0; - pkt_len++; - } - ASSERT(pkt_len <= PCAN_NICMEM_SZ); -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_SEND) { - cmn_err(CE_NOTE, "pcan send: packet to hardware--pkt_len=%x", - pkt_len); - for (i = 0; i < pkt_len + 4; i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((unsigned char *)buf_p + 0x36 + i)); - } -#endif - mutex_enter(&pcan_p->pcan_glock); - (void) WRCH1(pcan_p, xmt_id, 0, (uint16_t *)buf_p, 0x38); /* frm */ - (void) WRPKT(pcan_p, xmt_id, 0x38, (uint16_t *)(buf_p + 0x38), - pkt_len + 12); - r = pcan_set_cmd(pcan_p, AN_CMD_TX, xmt_id); - mutex_exit(&pcan_p->pcan_glock); - - PCANDBG((CE_NOTE, "pcan: pkt_len=0x44+%x=%x xmt=%x ret=%x\n", - pkt_len, 0x44 + pkt_len, xmt_id, ring_idx)); - kmem_free(buf, PCAN_NICMEM_SZ); -#ifdef PCAN_SEND_DEBUG - if (pkt_len = pcan_status_ltv(PCAN_READ_LTV, pcan_p, &radio_status)) { - PCANDBG((CE_NOTE, "pcan: bad radio status %x\n", pkt_len)); - } else { - PCANDBG((CE_NOTE, "pcan: radio status:\n")); - } -#endif /* PCAN_SEND_DEBUG */ - if (r) - return (PCAN_FAIL); - else { - freemsg(mblk_p); - return (PCAN_SUCCESS); - } -} - -/* - * send a packet out for PCI/MiniPCI card - */ -static int -pcian_send(pcan_maci_t *pcan_p, mblk_t *mblk_p) -{ - char *buf; - uint16_t pkt_len = msgdsize(mblk_p), ring_idx; - uint32_t i; - struct ieee80211_frame *wh; - struct an_card_tx_desc an_tx_desc; - - ring_idx = pcan_p->pcan_txring.an_tx_prod; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_LINKUP)) { /* link down */ - mutex_exit(&pcan_p->pcan_glock); - pcan_p->glds_nocarrier++; - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - mutex_exit(&pcan_p->pcan_glock); - if (pullupmsg(mblk_p, -1) == 0) { - cmn_err(CE_NOTE, "pcan(pci) send: pullupmsg failed\n"); - freemsg(mblk_p); - return (PCAN_SUCCESS); /* drop packet */ - } - wh = (struct ieee80211_frame *)mblk_p->b_rptr; - - mutex_enter(&pcan_p->pcan_txring.an_tx_lock); - if ((pcan_p->pcan_flag & PCAN_CARD_SEND) && - (ring_idx == pcan_p->pcan_txring.an_tx_cons)) { - pcan_p->glds_noxmtbuf++; - pcan_p->pcan_reschedule_need = B_TRUE; - mutex_exit(&pcan_p->pcan_txring.an_tx_lock); - return (PCAN_FAIL); - } - mutex_exit(&pcan_p->pcan_txring.an_tx_lock); - -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_SEND) { - cmn_err(CE_NOTE, "pcan(pci) send: packet from plugin"); - for (i = 0; i < MBLKL(mblk_p); i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((unsigned char *)mblk_p->b_rptr + i)); - } -#endif - mutex_enter(&pcan_p->pcan_glock); - - buf = pcan_p->pcan_tx[ring_idx].dma_virtaddr; - bzero(buf, AN_TX_BUFFER_SIZE); - - /* - * mblk sent down from plugin includes station mode 802.11 frame and - * llc, so we here need to remove them and add an ethernet header. - */ - *((uint16_t *)(buf + 8)) = htons(AN_TXCTL_8023); - pkt_len = pkt_len - (sizeof (*wh) + sizeof (struct ieee80211_llc)) - + 2; - bcopy(wh->i_addr3, buf + 0x38, ETHERADDRL); /* dst macaddr */ - bcopy(wh->i_addr2, buf + 0x3e, ETHERADDRL); /* src macaddr */ - *((uint16_t *)(buf + 0x36)) = pkt_len; - bcopy(mblk_p->b_rptr + sizeof (*wh) + sizeof (struct ieee80211_llc) - - 2, buf + 0x44, pkt_len); - -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_SEND) { - cmn_err(CE_NOTE, "pcan(pci) send: packet to hardware " - "pkt_len=%x", pkt_len); - for (i = 0; i < pkt_len + 14; i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((unsigned char *)buf + 0x36 + i)); - } -#endif - bzero(&an_tx_desc, sizeof (an_tx_desc)); - an_tx_desc.an_offset = 0; - an_tx_desc.an_eoc = (ring_idx == (AN_MAX_TX_DESC-1) ? 1 : 0); - an_tx_desc.an_valid = 1; - an_tx_desc.an_len = 0x44 + pkt_len; - an_tx_desc.an_phys = pcan_p->pcan_tx[ring_idx].dma_physaddr; - for (i = 0; i < sizeof (an_tx_desc) / 4; i++) { - PCAN_AUX_PUT32(pcan_p, AN_TX_DESC_OFFSET + - (ring_idx * sizeof (an_tx_desc)) + (i * 4), - ((uint32_t *)&an_tx_desc)[i]); - } - - mutex_enter(&pcan_p->pcan_txring.an_tx_lock); - pcan_p->pcan_txring.an_tx_prod = (ring_idx + 1) % AN_MAX_TX_DESC; - pcan_p->pcan_flag |= PCAN_CARD_SEND; - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_ALLOC); - mutex_exit(&pcan_p->pcan_txring.an_tx_lock); - - freemsg(mblk_p); - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_SUCCESS); -} - -static mblk_t * -pcan_tx(void *arg, mblk_t *mp) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - mblk_t *next; - int ret = 0; - - ASSERT(mp != NULL); - mutex_enter(&pcan_p->pcan_glock); - if ((pcan_p->pcan_flag & (PCAN_CARD_LINKUP | PCAN_CARD_READY)) != - (PCAN_CARD_LINKUP | PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - freemsgchain(mp); - return (NULL); - } - mutex_exit(&pcan_p->pcan_glock); - while (mp != NULL) { - next = mp->b_next; - mp->b_next = NULL; - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - ret = pcian_send(pcan_p, mp); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - ret = pcan_send(pcan_p, mp); - } - if (ret) { - mp->b_next = next; - break; - } - mp = next; - } - return (mp); -} - -/* - * this driver is porting from freebsd, the code in freebsd - * doesn't show how to set promiscous mode. - */ -/*ARGSUSED*/ -static int -pcan_prom(void *arg, boolean_t on) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - int ret = PCAN_SUCCESS; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - ret = PCAN_FAIL; - } - mutex_exit(&pcan_p->pcan_glock); - return (ret); -} - -/*ARGSUSED*/ -static int -pcan_gstat(void *arg, uint_t statitem, uint64_t *val) -{ - uint16_t i; - int ret = PCAN_SUCCESS; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - uint64_t *cntr_p = pcan_p->pcan_cntrs_s; - - PCANDBG((CE_NOTE, "pcan: gstat called\n")); - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - ret = PCAN_FAIL; - goto done; - } - if (pcan_get_ltv(pcan_p, sizeof (pcan_p->an_stats), - AN_RID_16BITS_DELTACLR, (uint16_t *)&pcan_p->an_stats)) { - cmn_err(CE_WARN, "pcan kstat: get ltv(32 delta statistics)" - " failed \n"); - ret = PCAN_FAIL; - goto done; - } - for (i = 0; i < ANC_STAT_CNT; i++) { - cntr_p[i] += *((uint16_t *)&pcan_p->an_stats + 1 + i); - } - if (pcan_status_ltv(PCAN_READ_LTV, pcan_p, &pcan_p->an_status)) { - cmn_err(CE_WARN, "pcan kstat: read status failed \n"); - ret = PCAN_FAIL; - goto done; - } - - switch (statitem) { - case MAC_STAT_IFSPEED: - *val = 500000 * pcan_p->an_status.an_cur_tx_rate; - break; - case MAC_STAT_NOXMTBUF: - *val = pcan_p->glds_noxmtbuf; - break; - case MAC_STAT_NORCVBUF: - *val = pcan_p->glds_norcvbuf; - break; - case MAC_STAT_IERRORS: - *val = cntr_p[ANC_RX_OVERRUNS] + - cntr_p[ANC_RX_PLCP_CSUM_ERRS] + - cntr_p[ANC_RX_PLCP_FORMAT_ERRS] + - cntr_p[ANC_RX_PLCP_LEN_ERRS] + - cntr_p[ANC_RX_MAC_CRC_ERRS] + - cntr_p[ANC_RX_WEP_ERRS]; - break; - case MAC_STAT_OERRORS: - *val = cntr_p[ANC_TX_HOST_FAILED]; - break; - case MAC_STAT_RBYTES: - *val = cntr_p[ANC_HOST_RX_BYTES]; - break; - case MAC_STAT_IPACKETS: - *val = cntr_p[ANC_RX_HOST_UCASTS]; - break; - case MAC_STAT_OBYTES: - *val = cntr_p[ANC_HOST_TX_BYTES]; - break; - case MAC_STAT_OPACKETS: - *val = cntr_p[ANC_TX_HOST_UCASTS]; - break; - case WIFI_STAT_TX_FAILED: - *val = cntr_p[ANC_TX_HOST_FAILED]; - break; - case WIFI_STAT_TX_RETRANS: - *val = cntr_p[ANC_HOST_RETRIES]; - break; - case WIFI_STAT_FCS_ERRORS: - *val = cntr_p[ANC_RX_MAC_CRC_ERRS]; - break; - case WIFI_STAT_WEP_ERRORS: - *val = cntr_p[ANC_RX_WEP_ERRS]; - break; - case WIFI_STAT_MCAST_TX: - *val = cntr_p[ANC_TX_HOST_MCASTS]; - break; - case WIFI_STAT_MCAST_RX: - *val = cntr_p[ANC_RX_HOST_MCASTS]; - break; - case WIFI_STAT_TX_FRAGS: - case WIFI_STAT_RX_FRAGS: - *val = 0; - break; - case WIFI_STAT_RTS_SUCCESS: - *val = cntr_p[ANC_TX_RTS_OK]; - break; - case WIFI_STAT_RTS_FAILURE: - *val = cntr_p[ANC_NO_CTS]; - break; - case WIFI_STAT_ACK_FAILURE: - *val = cntr_p[ANC_NO_ACK]; - break; - case WIFI_STAT_RX_DUPS: - *val = cntr_p[ANC_RX_DUPS]; - break; - default: - ret = ENOTSUP; - } - - -done: - mutex_exit(&pcan_p->pcan_glock); - return (ret); -} - -/* - * this driver is porting from freebsd, the code in freebsd - * doesn't show how to set multi address. - */ -/*ARGSUSED*/ -static int -pcan_sdmulti(void *arg, boolean_t add, const uint8_t *eth_p) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_FAIL); - } - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_SUCCESS); -} - -static uint_t -pcan_info_softint(caddr_t arg) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - wifi_data_t wd = { 0 }; - uint16_t link; - uint32_t link_up; - - mutex_enter(&pcan_p->pcan_glock); - if (pcan_p->pcan_info_softint_pending != 1) { - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_UNCLAIMED); - } - - PCAN_READ(pcan_p, AN_LINKSTAT(pcan_p), link); - link_up = pcan_p->pcan_flag & PCAN_CARD_LINKUP; - if ((link == AN_LINKSTAT_ASSOCIATED) && !link_up) { - pcan_p->pcan_flag |= PCAN_CARD_LINKUP; - mutex_exit(&pcan_p->pcan_glock); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - mac_link_update(GLD3(pcan_p), LINK_STATE_UP); - mutex_enter(&pcan_p->pcan_glock); - (void) pcan_status_ltv(PCAN_READ_LTV, pcan_p, - &pcan_p->an_status); - bcopy(pcan_p->an_status.an_cur_bssid, wd.wd_bssid, 6); - wd.wd_secalloc = WIFI_SEC_NONE; - wd.wd_opmode = IEEE80211_M_STA; - (void) mac_pdata_update(pcan_p->pcan_mh, &wd, - sizeof (wd)); -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_LINKINFO) { - cmn_err(CE_NOTE, "pcan: link Up, chan=%d, " - "ssid=\"%s\"" - " (%02x:%02x:%02x:%02x:%02x:%02x)\n", - pcan_p->an_status.an_channel_set, - pcan_p->an_status.an_ssid, - pcan_p->an_status.an_cur_bssid[0], - pcan_p->an_status.an_cur_bssid[1], - pcan_p->an_status.an_cur_bssid[2], - pcan_p->an_status.an_cur_bssid[3], - pcan_p->an_status.an_cur_bssid[4], - pcan_p->an_status.an_cur_bssid[5]); - } -#endif - } - if ((link != AN_LINKSTAT_ASSOCIATED) && link_up) { - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_LINKINFO) { - cmn_err(CE_NOTE, "pcan: link Down 0x%x\n", link); - } -#endif - if (link != AN_LINKSTAT_SYNCLOST_HOSTREQ) { - pcan_p->pcan_connect_timeout_id = - timeout(pcan_connect_timeout, - pcan_p, drv_usectohz(1000)); - } - mutex_exit(&pcan_p->pcan_glock); - mac_link_update(GLD3(pcan_p), LINK_STATE_DOWN); - mutex_enter(&pcan_p->pcan_glock); - } - - pcan_p->pcan_info_softint_pending = 0; - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_CLAIMED); -} - -static uint_t -pcan_intr(caddr_t arg) -{ - uint16_t stat; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if ((pcan_p->pcan_flag & (PCAN_CARD_READY | PCAN_CARD_INTREN)) != - (PCAN_CARD_READY | PCAN_CARD_INTREN)) { - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_UNCLAIMED); - } - PCAN_READ(pcan_p, AN_EVENT_STAT(pcan_p), stat); - - if (!(stat & AN_INTRS(pcan_p)) || stat == AN_EV_ALL) { - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_UNCLAIMED); - } - - PCAN_DISABLE_INTR(pcan_p); - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), ~AN_INTRS(pcan_p)); - - PCANDBG((CE_NOTE, "pcan intr: stat=%x pcan_flags=%x\n", stat, - pcan_p->pcan_flag)); - - if (stat & AN_EV_AWAKE) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_AWAKE); - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_AWAKE); - } - if (stat & AN_EV_LINKSTAT) { - pcan_p->pcan_info_softint_pending = 1; - ddi_trigger_softintr(pcan_p->pcan_info_softint_id); - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_LINKSTAT); - } - if (stat & AN_EV_RX) { - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - pcian_rcv(pcan_p); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - pcan_rcv(pcan_p); - } - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_RX); - } - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - if (stat & AN_EV_TX_CPY) { - (void) pcan_txdone(pcan_p, stat & AN_EV_TX_CPY); - if (pcan_p->pcan_reschedule_need == B_TRUE) { - mac_tx_update(GLD3(pcan_p)); - pcan_p->pcan_reschedule_need = B_FALSE; - } - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_TX_CPY); - } - } - if (stat & AN_EV_TX) { - if (pcan_txdone(pcan_p, stat & AN_EV_TX) == 0) { - if (pcan_p->pcan_reschedule_need == B_TRUE) { - mac_tx_update(GLD3(pcan_p)); - pcan_p->pcan_reschedule_need = B_FALSE; - } - } - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_TX); - } - if (stat & AN_EV_TX_EXC) { - if (pcan_txdone(pcan_p, stat & AN_EV_TX_EXC) == 0) { - if (pcan_p->pcan_reschedule_need == B_TRUE) { - mutex_exit(&pcan_p->pcan_glock); - mac_tx_update(GLD3(pcan_p)); - mutex_enter(&pcan_p->pcan_glock); - pcan_p->pcan_reschedule_need = B_FALSE; - } - } - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_TX_EXC); - } - if (stat & AN_EV_ALLOC) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_ALLOC); - PCANDBG((CE_NOTE, "pcan intr: nicmem alloc done\n")); - } - if (stat & AN_EV_MIC) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_MIC); - } - PCAN_ENABLE_INTR(pcan_p); - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_CLAIMED); -} - -static uint_t -pcan_intr_hi(caddr_t arg) -{ - uint16_t stat; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if ((pcan_p->pcan_flag & (PCAN_CARD_READY | PCAN_CARD_INTREN)) != - (PCAN_CARD_READY | PCAN_CARD_INTREN)) { - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_UNCLAIMED); - } - PCAN_READ(pcan_p, AN_EVENT_STAT(pcan_p), stat); - PCANDBG((CE_NOTE, "pcan intr(hi): stat=%x pcan_flags=%x\n", stat, - pcan_p->pcan_flag)); - - if (!(stat & AN_INTRS(pcan_p)) || stat == AN_EV_ALL) { - mutex_exit(&pcan_p->pcan_glock); - return (DDI_INTR_UNCLAIMED); - } - /* disable interrupt without ack */ - PCAN_WRITE(pcan_p, AN_INT_EN(pcan_p), 0); - mutex_exit(&pcan_p->pcan_glock); - ddi_trigger_softintr(pcan_p->pcan_softint_id); - return (DDI_INTR_CLAIMED); -} - -/* - * retrieve data from pccard - */ -static void -pcan_rcv(pcan_maci_t *pcan_p) -{ - uint16_t id, off, ret, data_len, pkt_stat, frm_ctl; - an_rxfrm_t frm; - struct ieee80211_llc *llc; - - mblk_t *mp = allocb(PCAN_NICMEM_SZ, BPRI_MED); - if (!mp) { - cmn_err(CE_WARN, "pcan: failed to alloc rcv buf"); - pcan_p->glds_norcvbuf++; - return; - } - ASSERT(mp->b_rptr == mp->b_wptr); - - PCAN_READ(pcan_p, AN_RX_FID, id); - if (id == AN_INVALID_FID) { - PCANDBG((CE_NOTE, "pcan rcv: can't get rx_fid\n")); - pcan_p->glds_norcvbuf++; - ret = PCAN_FAIL; - goto done; - } - if (ret = RDCH0(pcan_p, id, 0, (uint16_t *)&frm, sizeof (frm))) { - PCANDBG((CE_NOTE, "pcan rcv: read frm err %x\n", ret)); - goto done; - } - off = sizeof (frm); - if (frm.an_rx_status) { - PCANDBG((CE_NOTE, "pcan rcv: err stat %x\n", frm.an_rx_status)); - ret = frm.an_rx_status; - goto done; - } - PCANDBG((CE_NOTE, "pcan rcv: payload_len=%x gap_len=%x\n", - frm.an_rx_payload_len, frm.an_gaplen)); - if (frm.an_rx_payload_len > PCAN_NICMEM_SZ || - frm.an_gaplen > AN_RXGAP_MAX) { - PCANDBG((CE_NOTE, "pcan rcv: bad len\n")); - ret = PCAN_FAIL; - goto done; - } - if (ret = RDCH0(pcan_p, id, off, &pkt_stat, sizeof (pkt_stat))) { - PCANDBG((CE_NOTE, "pcan rcv: pkt status err %x\n", ret)); - ret = PCAN_FAIL; - goto done; - } - off += sizeof (pkt_stat); - if (ret = RDCH0(pcan_p, id, off, &data_len, sizeof (data_len))) { - PCANDBG((CE_NOTE, "pcan rcv: payload len err %x\n", ret)); - ret = PCAN_FAIL; - goto done; - } - off += sizeof (data_len); - off += ETHERADDRL << 1; - PCANDBG((CE_NOTE, "pcan rcv: pkt_stat=%x payload_len=%x+c off=%x\n", - pkt_stat, data_len, off)); - -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_RCV) { - int i; - cmn_err(CE_NOTE, "pcan rcv: frm header\n"); - for (i = 0; i < sizeof (frm); i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((uint8_t *)&frm + i)); - } -#endif - /* - * this driver deal with WEP by itself. so plugin always thinks no wep. - */ - frm.an_frame_ctl &= ~(IEEE80211_FC1_WEP << 8); - frm_ctl = frm.an_frame_ctl; - PCAN_SWAP16((uint16_t *)&frm.an_frame_ctl, - sizeof (struct ieee80211_frame)); - /* - * discard those frames which are not from the AP we connect or - * without 'ap->sta' direction - */ - if (((pcan_p->an_config.an_opmode == AN_OPMODE_INFR_STATION)) && - ((((frm_ctl >> 8) & IEEE80211_FC1_DIR_MASK) != - IEEE80211_FC1_DIR_FROMDS) || - bcmp(pcan_p->an_status.an_cur_bssid, frm.an_addr2, 6) != 0)) { - ret = PCAN_FAIL; - goto done; - } - bcopy(&frm.an_frame_ctl, mp->b_wptr, - sizeof (struct ieee80211_frame)); - mp->b_wptr += sizeof (struct ieee80211_frame); - - /* the plugin need a llc here */ - llc = (struct ieee80211_llc *)mp->b_wptr; - llc->illc_dsap = llc->illc_ssap = AN_SNAP_K1; - llc->illc_control = AN_SNAP_CONTROL; - bzero(llc->illc_oc, sizeof (llc->illc_oc)); - mp->b_wptr += AN_SNAPHDR_LEN; - - /* read in the rest of data */ - data_len += data_len & 1; /* adjust to word boundary */ - if (data_len > MBLKSIZE(mp)) { - cmn_err(CE_NOTE, "pcan rcv: data over length%x\n", data_len); - ret = PCAN_FAIL; - goto done; - } - - if (ret = RDPKT(pcan_p, id, off, (uint16_t *)mp->b_wptr, data_len)) { - PCANDBG((CE_NOTE, "pcan rcv: err read data %x\n", ret)); - } -done: - if (ret) { - PCANDBG((CE_NOTE, "pcan rcv: rd data %x\n", ret)); - freemsg(mp); - return; - } - mp->b_wptr += data_len; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_RCV) { - int i; - cmn_err(CE_NOTE, "pcan rcv: len=0x%x\n", data_len); - for (i = 0; i < data_len + sizeof (frm); i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((uint8_t *)mp->b_rptr + i)); - } -#endif - mutex_exit(&pcan_p->pcan_glock); - mac_rx(GLD3(pcan_p), NULL, mp); - mutex_enter(&pcan_p->pcan_glock); -} - -/* - * retrieve data from mini-pci card - */ -static void -pcian_rcv(pcan_maci_t *pcan_p) -{ - struct an_card_rx_desc an_rx_desc; - char *buf; - uint16_t ret = 0, data_len; - int i, j; - struct ieee80211_frame *frm; - struct ieee80211_llc *llc; - - mblk_t *mp = allocb(AN_RX_BUFFER_SIZE, BPRI_MED); - if (!mp) { - cmn_err(CE_WARN, "pcan(pci): failed to alloc rcv buf"); - pcan_p->glds_norcvbuf++; - return; - } - ASSERT(mp->b_rptr == mp->b_wptr); - - for (i = 0; i < sizeof (an_rx_desc) / 4; i++) - PCAN_AUX_GET32(pcan_p, AN_RX_DESC_OFFSET + (i * 4), - ((uint32_t *)&an_rx_desc)[i]); - if (an_rx_desc.an_done && !an_rx_desc.an_valid) { - buf = pcan_p->pcan_rx[0].dma_virtaddr; - data_len = an_rx_desc.an_len; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_RCV) { - cmn_err(CE_NOTE, "pcan(pci) rcv: data_len=%x", - data_len); - for (j = 0; j < data_len + 14; j++) - cmn_err(CE_NOTE, "pcan_rcv %d: %x", j, - *((uint8_t *)buf + j)); - } -#endif - if (data_len > MBLKSIZE(mp)) { - cmn_err(CE_NOTE, "pcan(pci) rcv: data over length%x\n", - data_len); - ret = PCAN_FAIL; - goto done; - } - /* - * minipci card receive an ethernet frame, so assembly a 802.11 - * frame here manually. - */ - frm = (struct ieee80211_frame *)mp->b_wptr; - bzero(frm, sizeof (*frm)); - frm->i_fc[0] |= IEEE80211_FC0_TYPE_DATA; - frm->i_fc[1] |= IEEE80211_FC1_DIR_FROMDS; - bcopy(pcan_p->an_status.an_cur_bssid, frm->i_addr2, 6); - bcopy(buf, frm->i_addr1, 6); - bcopy(buf + 6, frm->i_addr3, 6); - mp->b_wptr += sizeof (struct ieee80211_frame); - - llc = (struct ieee80211_llc *)mp->b_wptr; - llc->illc_dsap = llc->illc_ssap = AN_SNAP_K1; - llc->illc_control = AN_SNAP_CONTROL; - bzero(llc->illc_oc, sizeof (llc->illc_oc)); - mp->b_wptr += AN_SNAPHDR_LEN; - - bcopy(buf + 12, mp->b_wptr, data_len); - mp->b_wptr += data_len; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_RCV) { - int i; - cmn_err(CE_NOTE, "pcan(pci) rcv: len=0x%x\n", data_len); - for (i = 0; i < data_len + sizeof (*frm) - + sizeof (*llc); i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((uint8_t *)mp->b_rptr + i)); - } -#endif - mutex_exit(&pcan_p->pcan_glock); - mac_rx(GLD3(pcan_p), NULL, mp); - mutex_enter(&pcan_p->pcan_glock); - } -done: - bzero(&an_rx_desc, sizeof (an_rx_desc)); - an_rx_desc.an_valid = 1; - an_rx_desc.an_len = AN_RX_BUFFER_SIZE; - an_rx_desc.an_done = 0; - an_rx_desc.an_phys = pcan_p->pcan_rx[0].dma_physaddr; - - for (i = 0; i < sizeof (an_rx_desc) / 4; i++) - PCAN_AUX_PUT32(pcan_p, AN_RX_DESC_OFFSET + (i * 4), - ((uint32_t *)&an_rx_desc)[i]); - if (ret) { - freemsg(mp); - } -} - -/*ARGSUSED*/ -static uint32_t -pcan_txdone(pcan_maci_t *pcan_p, uint16_t err) -{ - uint16_t fid, i, ring_idx; - uint32_t ret = 0; - - PCAN_READ(pcan_p, AN_TX_CMP_FID(pcan_p), fid); - mutex_enter(&pcan_p->pcan_txring.an_tx_lock); - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - if (pcan_p->pcan_flag & PCAN_CARD_SEND) { - ring_idx = pcan_p->pcan_txring.an_tx_cons; - pcan_p->pcan_txring.an_tx_cons = - (ring_idx + 1) % AN_MAX_TX_DESC; - if (pcan_p->pcan_txring.an_tx_prod == - pcan_p->pcan_txring.an_tx_cons) { - pcan_p->pcan_flag &= ~PCAN_CARD_SEND; - } - } - ret = 0; - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - for (i = 0; i < AN_TX_RING_CNT; i++) { - if (fid == pcan_p->pcan_txring.an_tx_ring[i]) { - pcan_p->pcan_txring.an_tx_ring[i] = 0; - break; - } - } - pcan_p->pcan_txring.an_tx_cons = - (pcan_p->pcan_txring.an_tx_cons + 1) & AN_TX_RING_MASK; - ret = (i == AN_TX_RING_CNT ? 1 : 0); - } - mutex_exit(&pcan_p->pcan_txring.an_tx_lock); - return (ret); -} - -/* - * delay in which the mutex is not hold. - * assuming the mutex has already been hold. - */ -static void -pcan_delay(pcan_maci_t *pcan_p, clock_t microsecs) -{ - ASSERT(mutex_owned(&pcan_p->pcan_glock)); - - mutex_exit(&pcan_p->pcan_glock); - delay(drv_usectohz(microsecs)); - mutex_enter(&pcan_p->pcan_glock); -} - -static void -pcan_reset_backend(pcan_maci_t *pcan_p, int timeout) -{ - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - (void) pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0); - PCAN_DISABLE_INTR_CLEAR(pcan_p); - (void) pcan_set_cmd(pcan_p, AN_CMD_FW_RESTART, 0); - (void) pcan_set_cmd(pcan_p, AN_CMD_NOOP2, 0); - (void) pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - (void) pcan_set_cmd0(pcan_p, AN_CMD_DISABLE, 0, 0, 0); - (void) pcan_set_cmd0(pcan_p, AN_CMD_NOOP2, 0, 0, 0); - PCAN_WRITE(pcan_p, AN_COMMAND(pcan_p), AN_CMD_FW_RESTART); - pcan_delay(pcan_p, timeout); /* wait for firmware restart */ - - (void) pcan_set_cmd(pcan_p, AN_CMD_NOOP, 0); - (void) pcan_set_cmd0(pcan_p, AN_CMD_DISABLE, 0, 0, 0); - - PCAN_DISABLE_INTR_CLEAR(pcan_p); - } -} - -/* - * set command without the need of ACK. - */ -static uint16_t -pcan_set_cmd0(pcan_maci_t *pcan_p, uint16_t cmd, uint16_t p0, - uint16_t p1, uint16_t p2) -{ - int i; - uint16_t stat, r0, r1, r2; - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, AN_COMMAND(pcan_p), stat); - if (!(stat & AN_CMD_BUSY)) - break; - } - if (i == AN_TIMEOUT) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), - AN_EV_CLR_STUCK_BUSY); - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - drv_usecwait(10); - } - PCAN_WRITE(pcan_p, AN_PARAM0(pcan_p), p0); - PCAN_WRITE(pcan_p, AN_PARAM1(pcan_p), p1); - PCAN_WRITE(pcan_p, AN_PARAM2(pcan_p), p2); - } - PCAN_WRITE(pcan_p, AN_COMMAND(pcan_p), cmd); - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, AN_EVENT_STAT(pcan_p), stat); - if (stat & AN_EV_CMD) - break; - } - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - PCAN_READ(pcan_p, AN_RESP0(pcan_p), r0); - PCAN_READ(pcan_p, AN_RESP1(pcan_p), r1); - PCAN_READ(pcan_p, AN_RESP2(pcan_p), r2); - PCAN_READ(pcan_p, AN_COMMAND(pcan_p), stat); - if (stat & AN_CMD_BUSY) - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), - AN_EV_CLR_STUCK_BUSY); - PCANDBG((CE_NOTE, "pcan set_cmd0: " - "stat=%x, r0=%x, r1=%x, r2=%x\n", - stat, r0, r1, r2)); - } - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - return (i == AN_TIMEOUT ? PCAN_TIMEDOUT_ACCESS : PCAN_SUCCESS); -} - -static uint16_t -pcan_set_cmd(pcan_maci_t *pcan_p, uint16_t cmd, uint16_t param) -{ - int i; - uint16_t stat, r0, r1, r2; - uint16_t ret; - - if (((cmd == AN_CMD_ENABLE) && - ((pcan_p->pcan_flag & PCAN_ENABLED) != 0)) || - ((cmd == AN_CMD_DISABLE) && - ((pcan_p->pcan_flag & PCAN_ENABLED) == 0))) - return (PCAN_SUCCESS); - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, AN_COMMAND(pcan_p), stat); - if (!(stat & AN_CMD_BUSY)) { - break; - } - } - if (i == AN_TIMEOUT) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CLR_STUCK_BUSY); - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - drv_usecwait(10); - } - - PCAN_WRITE(pcan_p, AN_PARAM0(pcan_p), param); - PCAN_WRITE(pcan_p, AN_PARAM1(pcan_p), 0); - PCAN_WRITE(pcan_p, AN_PARAM2(pcan_p), 0); - PCAN_WRITE(pcan_p, AN_COMMAND(pcan_p), cmd); - - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, AN_EVENT_STAT(pcan_p), stat); - if (stat & AN_EV_CMD) { - break; - } - PCAN_READ(pcan_p, AN_COMMAND(pcan_p), stat); - if (stat == cmd) - PCAN_WRITE(pcan_p, AN_COMMAND(pcan_p), cmd); - } - if (i == AN_TIMEOUT) { - if (cmd == AN_CMD_FW_RESTART) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - return (PCAN_SUCCESS); - } -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_CMD) { - cmn_err(CE_WARN, "pcan set_cmd: %x timeout stat=%x\n", - cmd, stat); - } -#endif - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - return (PCAN_TIMEDOUT_CMD); - } - - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, AN_STATUS(pcan_p), stat); - PCAN_READ(pcan_p, AN_RESP0(pcan_p), r0); - PCAN_READ(pcan_p, AN_RESP1(pcan_p), r1); - PCAN_READ(pcan_p, AN_RESP2(pcan_p), r2); - if ((stat & AN_STAT_CMD_CODE) == (cmd & AN_STAT_CMD_CODE)) - break; - } - if (cmd == AN_CMD_FW_RESTART) { - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - return (PCAN_SUCCESS); - } - if (i == AN_TIMEOUT) { -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_CMD) { - cmn_err(CE_WARN, "pcan set_cmd<%x,%x>: timeout " - "%x,%x,%x,%x\n", cmd, param, stat, r0, r1, r2); - } -#endif - ret = PCAN_TIMEDOUT_ACCESS; - } else { - if (stat & AN_STAT_CMD_RESULT) { -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_CMD) { - cmn_err(CE_WARN, "pcan set_cmd<%x,%x>: failed " - "%x,%x,%x,%x\n", - cmd, param, stat, r0, r1, r2); - } -#endif - ret = PCAN_TIMEDOUT_ACCESS; - } else { - ret = PCAN_SUCCESS; - } - } - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CMD); - PCAN_READ(pcan_p, AN_COMMAND(pcan_p), stat); - if (stat & AN_CMD_BUSY) - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_CLR_STUCK_BUSY); - if (ret == PCAN_SUCCESS) { - if (cmd == AN_CMD_ENABLE) - pcan_p->pcan_flag |= PCAN_ENABLED; - if (cmd == AN_CMD_DISABLE) - pcan_p->pcan_flag &= (~PCAN_ENABLED); - } - return (ret); -} - -static uint16_t -pcan_set_ch(pcan_maci_t *pcan_p, uint16_t type, uint16_t off, uint16_t channel) -{ - int i; - uint16_t stat, select, offset; - - if (channel) { - select = AN_SEL1; - offset = AN_OFF1; - } else { - select = AN_SEL0; - offset = AN_OFF0; - } - PCAN_WRITE(pcan_p, select, type); - PCAN_WRITE(pcan_p, offset, off); - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, offset, stat); - if (!(stat & (AN_OFF_BUSY|AN_OFF_ERR))) - break; - } - if (stat & (AN_OFF_BUSY|AN_OFF_ERR)) { /* time out */ - PCANDBG((CE_WARN, "pcan: set_ch%d %x %x TO %x\n", - channel, type, off, stat)); - return (PCAN_TIMEDOUT_TARGET); - } - return (PCAN_SUCCESS); -} - -static uint16_t -pcan_get_ltv(pcan_maci_t *pcan_p, uint16_t len, uint16_t type, uint16_t *val_p) -{ - uint16_t stat; - - PCANDBG((CE_NOTE, "pcan: get_ltv(%p,%x,%x,%p)\n", - (void *)pcan_p, len, type, (void *)val_p)); - ASSERT(!(len & 1)); - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - uint32_t i; - struct an_card_rid_desc an_rid_desc; - struct an_ltv_gen *an_ltv; - if (!pcan_p->pcan_cmd.dma_virtaddr) - return (EIO); - an_rid_desc.an_valid = 1; - an_rid_desc.an_len = AN_RID_BUFFER_SIZE; - an_rid_desc.an_rid = 0; - an_rid_desc.an_phys = pcan_p->pcan_cmd.dma_physaddr; - bzero(pcan_p->pcan_cmd.dma_virtaddr, AN_RID_BUFFER_SIZE); - - for (i = 0; i < sizeof (an_rid_desc) / 4; i++) - PCAN_AUX_PUT32(pcan_p, AN_HOST_DESC_OFFSET + i * 4, - ((uint32_t *)&an_rid_desc)[i]); - - if (pcan_set_cmd0(pcan_p, AN_CMD_ACCESS | - AN_ACCESS_READ, type, 0, 0)) { - cmn_err(CE_WARN, "pcan get_ltv: set cmd error"); - return (EIO); - } - - an_ltv = (struct an_ltv_gen *)pcan_p->pcan_cmd.dma_virtaddr; -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_INFO) { - cmn_err(CE_NOTE, "pcan get_ltv: type=%x," - "expected len=%d," "actual len=%d", - type, len, an_ltv->an_len); - for (i = 0; i < an_ltv->an_len; i++) - cmn_err(CE_NOTE, "%d: %x", i, - *(((uint8_t *)an_ltv) + i)); - } -#endif - if (an_ltv->an_len != len) { - PCANDBG((CE_WARN, "pcan get_ltv: rid=%x expected len=%d" - "actual: len=%d", type, - len, an_ltv->an_len)); - /* return (EIO); */ - } - bcopy(an_ltv, val_p, len); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - len >>= 1; /* convert bytes to 16-bit words */ - - /* 1. select read mode */ - if (stat = pcan_set_cmd(pcan_p, AN_CMD_ACCESS | - AN_ACCESS_READ, type)) - return (stat); - - /* 2. select Buffer Access Path (channel) 1 for PIO */ - if (stat = pcan_set_ch(pcan_p, type, 0, 1)) - return (stat); - - /* 3. read length */ - PCAN_READ(pcan_p, AN_DATA1, stat); - *val_p++ = stat; - if (stat != (len << 1)) { - PCANDBG((CE_NOTE, "pcan get_ltv[%x]:expect %x," - "got %x\n", type, (len + 1) << 1, stat)); - stat = (stat >> 1) - 1; - len = MIN(stat, len); - } - /* 4. read value */ - for (stat = 0; stat < len - 1; stat++, val_p++) { - PCAN_READ_P(pcan_p, AN_DATA1, val_p, 1); - } - } - return (PCAN_SUCCESS); -} - -static uint16_t -pcan_put_ltv(pcan_maci_t *pcan_p, uint16_t len, uint16_t type, uint16_t *val_p) -{ - uint16_t stat; - int i; - - ASSERT(!(len & 1)); - - if (pcan_p->pcan_device_type == PCAN_DEVICE_PCI) { - struct an_card_rid_desc an_rid_desc; - - for (i = 0; i < AN_TIMEOUT; i++) { - PCAN_READ(pcan_p, AN_COMMAND(pcan_p), stat); - if (!(stat & AN_CMD_BUSY)) { - break; - } - } - if (i == AN_TIMEOUT) { - cmn_err(CE_WARN, "pcan put_ltv: busy"); - } - - an_rid_desc.an_valid = 1; - an_rid_desc.an_len = len; - an_rid_desc.an_rid = type; - an_rid_desc.an_phys = pcan_p->pcan_cmd.dma_physaddr; - - bcopy(val_p, pcan_p->pcan_cmd.dma_virtaddr, - an_rid_desc.an_len); - - for (i = 0; i < sizeof (an_rid_desc) / 4; i++) - PCAN_AUX_PUT32(pcan_p, AN_HOST_DESC_OFFSET + i * 4, - ((uint32_t *)&an_rid_desc)[i]); - pcan_delay(pcan_p, 100000); - stat = pcan_set_cmd0(pcan_p, AN_CMD_ACCESS | - AN_ACCESS_WRITE, type, 0, 0); - pcan_delay(pcan_p, 100000); - return (stat); - } else if (pcan_p->pcan_device_type == PCAN_DEVICE_PCCARD) { - /* 0. select read mode first */ - if (stat = pcan_set_cmd(pcan_p, AN_CMD_ACCESS | - AN_ACCESS_READ, type)) - return (stat); - - /* 1. select Buffer Access Path (channel) 1 for PIO */ - if (stat = pcan_set_ch(pcan_p, type, 0, 1)) - return (stat); - - /* 2. write length */ - len >>= 1; /* convert bytes to 16-bit words */ - stat = len; - PCAN_WRITE(pcan_p, AN_DATA1, stat); - - /* 3. write value */ - val_p++; - for (stat = 0; stat < len-1; stat++, val_p++) { - PCAN_WRITE_P(pcan_p, AN_DATA1, val_p, 1); - } - - /* 4. select write mode */ - return (pcan_set_cmd(pcan_p, AN_CMD_ACCESS | - AN_ACCESS_WRITE, type)); - } - return (PCAN_FAIL); -} - -/*ARGSUSED*/ -static uint16_t -pcan_rdch0(pcan_maci_t *pcan_p, uint16_t type, uint16_t off, uint16_t *buf_p, - int len, int order) -{ - ASSERT(!(len & 1)); - - if (pcan_set_ch(pcan_p, type, off, 0) != PCAN_SUCCESS) - return (PCAN_FAIL); - len >>= 1; - for (off = 0; off < len; off++, buf_p++) { - PCAN_READ_P(pcan_p, AN_DATA0, buf_p, order); - } - return (PCAN_SUCCESS); -} - -/*ARGSUSED*/ -static uint16_t -pcan_wrch1(pcan_maci_t *pcan_p, uint16_t type, uint16_t off, uint16_t *buf_p, - int len, int order) -{ - ASSERT(!(len & 1)); - - if (pcan_set_ch(pcan_p, type, off, 1) != PCAN_SUCCESS) - return (PCAN_FAIL); - len >>= 1; - for (off = 0; off < len; off++, buf_p++) { - PCAN_WRITE_P(pcan_p, AN_DATA1, buf_p, order); - } - return (PCAN_SUCCESS); -} - -static uint16_t -pcan_status_ltv(int rw, pcan_maci_t *pcan_p, struct an_ltv_status *status_p) -{ - uint16_t ret, len; - - if (rw != PCAN_READ_LTV) { - cmn_err(CE_WARN, "pcan status_ltv: unsupported op %x", rw); - return (PCAN_FAIL); - } - if (ret = pcan_get_ltv(pcan_p, sizeof (*status_p), AN_RID_STATUS, - (uint16_t *)status_p)) - return (ret); - - PCAN_SWAP16_BUF(status_p->an_macaddr); - PCAN_SWAP16_BUF(status_p->an_ssid); - len = min(status_p->an_ssidlen, 31); - status_p->an_ssid[len] = '\0'; - PCAN_SWAP16_BUF(status_p->an_ap_name); - PCAN_SWAP16_BUF(status_p->an_cur_bssid); - PCAN_SWAP16_BUF(status_p->an_prev_bssid1); - PCAN_SWAP16_BUF(status_p->an_prev_bssid2); - PCAN_SWAP16_BUF(status_p->an_prev_bssid3); - PCAN_SWAP16_BUF(status_p->an_ap_ip_address); - PCAN_SWAP16_BUF(status_p->an_carrier); - return (PCAN_SUCCESS); -} - -static uint16_t -pcan_cfg_ltv(int rw, pcan_maci_t *pcan_p, struct an_ltv_genconfig *cfg_p) -{ - uint16_t ret; - uint16_t rid = cfg_p == &pcan_p->an_config ? - AN_RID_GENCONFIG : AN_RID_ACTUALCFG; - - if (rw == PCAN_READ_LTV) { - if (ret = pcan_get_ltv(pcan_p, sizeof (*cfg_p), rid, - (uint16_t *)cfg_p)) - return (ret); - goto done; - } - PCAN_SWAP16_BUF(cfg_p->an_macaddr); - PCAN_SWAP16_BUF(cfg_p->an_rates); - if (ret = pcan_put_ltv(pcan_p, sizeof (*cfg_p), - rid, (uint16_t *)cfg_p)) - return (ret); -done: - PCAN_SWAP16_BUF(cfg_p->an_macaddr); - PCAN_SWAP16_BUF(cfg_p->an_rates); - return (ret); -} - -static uint16_t -pcan_cap_ltv(int rw, pcan_maci_t *pcan_p) -{ - uint16_t ret; - - if (rw != PCAN_READ_LTV) { - cmn_err(CE_WARN, "pcan cap_ltv: unsupported op %x", rw); - return (PCAN_FAIL); - } - if (ret = pcan_get_ltv(pcan_p, sizeof (struct an_ltv_caps), - AN_RID_CAPABILITIES, (uint16_t *)&pcan_p->an_caps)) - return (ret); - - PCAN_SWAP16_BUF(pcan_p->an_caps.an_oui); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_manufname); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_prodname); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_prodvers); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_oemaddr); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_aironetaddr); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_callid); - PCAN_SWAP16_BUF(pcan_p->an_caps.an_supported_rates); - return (PCAN_SUCCESS); -} - -static uint16_t -pcan_ssid_ltv(int rw, pcan_maci_t *pcan_p) -{ - uint16_t ret; - - if (rw == PCAN_READ_LTV) { - if (ret = pcan_get_ltv(pcan_p, sizeof (struct an_ltv_ssidlist), - AN_RID_SSIDLIST, (uint16_t *)&pcan_p->an_ssidlist)) - return (ret); - goto done; - } - PCAN_SWAP16_BUF(pcan_p->an_ssidlist.an_ssid1); - PCAN_SWAP16_BUF(pcan_p->an_ssidlist.an_ssid2); - PCAN_SWAP16_BUF(pcan_p->an_ssidlist.an_ssid3); - if (ret = pcan_put_ltv(pcan_p, sizeof (struct an_ltv_ssidlist), - AN_RID_SSIDLIST, (uint16_t *)&pcan_p->an_ssidlist)) - return (ret); -done: - PCAN_SWAP16_BUF(pcan_p->an_ssidlist.an_ssid1); - PCAN_SWAP16_BUF(pcan_p->an_ssidlist.an_ssid2); - PCAN_SWAP16_BUF(pcan_p->an_ssidlist.an_ssid3); - return (ret); -} - -static uint16_t -pcan_aplist_ltv(int rw, pcan_maci_t *pcan_p) -{ - uint16_t ret; - - if (rw == PCAN_READ_LTV) { - if (ret = pcan_get_ltv(pcan_p, sizeof (struct an_ltv_aplist), - AN_RID_APLIST, (uint16_t *)&pcan_p->an_aplist)) - return (ret); - goto done; - } - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap1); - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap2); - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap3); - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap4); - if (ret = pcan_put_ltv(pcan_p, sizeof (struct an_ltv_aplist), - AN_RID_APLIST, (uint16_t *)&pcan_p->an_aplist)) - return (ret); -done: - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap1); - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap2); - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap3); - PCAN_SWAP16_BUF(pcan_p->an_aplist.an_ap4); - return (ret); -} - -static uint16_t -pcan_scanresult_ltv(int rw, pcan_maci_t *pcan_p, uint16_t type, - struct an_ltv_scanresult *scanresult_p) -{ - uint16_t ret, len; - if (rw != PCAN_READ_LTV) { - cmn_err(CE_WARN, "pcan scan_ltv: readonly rid %x\n", type); - return (PCAN_FAIL); - } - if (ret = pcan_get_ltv(pcan_p, sizeof (struct an_ltv_scanresult), - type, (uint16_t *)scanresult_p)) - return (ret); - PCAN_SWAP16_BUF(scanresult_p->an_bssid); - PCAN_SWAP16_BUF(scanresult_p->an_ssid); - len = min(scanresult_p->an_ssidlen, 31); - scanresult_p->an_ssid[len] = '\0'; - PCAN_SWAP16_BUF(scanresult_p->an_rates); - return (PCAN_SUCCESS); -} - -static uint16_t -pcan_one_wepkey(int rw, pcan_maci_t *pcan_p, struct an_ltv_wepkey *wkp, - uint16_t rid) -{ - uint16_t ret; - - if (rw == PCAN_READ_LTV) { - if (ret = pcan_get_ltv(pcan_p, sizeof (struct an_ltv_wepkey), - rid, (uint16_t *)wkp)) { - return (ret); - } - goto done; - } - PCAN_SWAP16_BUF(wkp->an_macaddr); - PCAN_SWAP16_BUF(wkp->an_key); - if (ret = pcan_put_ltv(pcan_p, sizeof (struct an_ltv_wepkey), - rid, (uint16_t *)wkp)) - return (ret); -done: - PCAN_SWAP16_BUF(wkp->an_macaddr); - PCAN_SWAP16_BUF(wkp->an_key); - return (ret); -} - -static uint16_t -pcan_wepkey_ltv(int rw, pcan_maci_t *pcan_p) -{ - uint16_t ret, i; - struct an_ltv_wepkey wk; - - if (rw == PCAN_READ_LTV) { - uint16_t rid = AN_RID_WEPKEY2; - - if (ret = pcan_one_wepkey(rw, pcan_p, &wk, rid)) - return (ret); - for (i = 0; i < 5; i++) { - if (wk.an_index < 4) - pcan_p->an_wepkey[wk.an_index] = wk; - else if (wk.an_index == 0xffff) - pcan_p->an_cur_wepkey = wk.an_macaddr[0]; - rid = AN_RID_WEPKEY; - } - return (PCAN_SUCCESS); - } - for (i = 0; i < MAX_NWEPKEYS; i++) { - if (pcan_p->an_wepkey[i].an_index == i) { - if (ret = pcan_one_wepkey(rw, pcan_p, - &pcan_p->an_wepkey[i], AN_RID_WEPKEY2)) - return (ret); - } - } - /* Now set the default key */ - (void) memset(&wk, 0, sizeof (wk)); - wk.an_index = 0xffff; - wk.an_macaddr[0] = pcan_p->an_cur_wepkey; - ret = pcan_one_wepkey(rw, pcan_p, &wk, AN_RID_WEPKEY2); - return (ret); -} - -static uint16_t -pcan_alloc_nicmem(pcan_maci_t *pcan_p, uint16_t len, uint16_t *id_p) -{ - int i; - uint16_t stat; - - len = ((len + 1) >> 1) << 1; /* round up to 16-bit boundary */ - - if (stat = pcan_set_cmd(pcan_p, AN_CMD_ALLOC_MEM, len)) - return (stat); - for (i = 0; !(stat & AN_EV_ALLOC) && (i < AN_TIMEOUT); i++) { - PCAN_READ(pcan_p, AN_EVENT_STAT(pcan_p), stat); - } - if (!(stat & AN_EV_ALLOC)) - return (PCAN_TIMEDOUT_ALLOC); - PCAN_READ(pcan_p, AN_ALLOC_FID, stat); - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), AN_EV_ALLOC); - *id_p = stat; - - /* zero fill the allocated NIC mem - sort of pcan_fill_ch0 */ - (void) pcan_set_ch(pcan_p, stat, 0, 0); - for (len >>= 1, stat = 0; stat < len; stat++) { - PCAN_WRITE(pcan_p, AN_DATA0, 0); - } - return (PCAN_SUCCESS); -} - -static void -pcan_stop_rx_dma(pcan_maci_t *pcan_p) -{ - int i, j; - struct an_card_rx_desc an_rx_desc; - - for (i = 0; i < AN_MAX_RX_DESC; i++) { - bzero(&an_rx_desc, sizeof (an_rx_desc)); - an_rx_desc.an_valid = 0; - an_rx_desc.an_len = AN_RX_BUFFER_SIZE; - an_rx_desc.an_done = 1; - an_rx_desc.an_phys = pcan_p->pcan_rx[i].dma_physaddr; - for (j = 0; j < sizeof (an_rx_desc) / 4; j++) - PCAN_AUX_PUT32(pcan_p, AN_RX_DESC_OFFSET - + (i * sizeof (an_rx_desc)) - + (j * 4), ((uint32_t *)&an_rx_desc)[j]); - } -} - -static int -pcan_init_dma_desc(pcan_maci_t *pcan_p) -{ - int i, j; - struct an_card_rid_desc an_rid_desc; - struct an_card_rx_desc an_rx_desc; - struct an_card_tx_desc an_tx_desc; - - /* Allocate DMA for rx */ - if (pcan_set_cmd0(pcan_p, AN_CMD_ALLOC_DESC, - AN_DESCRIPTOR_RX, AN_RX_DESC_OFFSET, - AN_MAX_RX_DESC) != PCAN_SUCCESS) { - cmn_err(CE_WARN, "pcan init_dma: fail to alloc rx descriptor"); - goto error; - } - for (i = 0; i < AN_MAX_RX_DESC; i++) { - bzero(&an_rx_desc, sizeof (an_rx_desc)); - an_rx_desc.an_valid = 1; - an_rx_desc.an_len = AN_RX_BUFFER_SIZE; - an_rx_desc.an_done = 0; - an_rx_desc.an_phys = pcan_p->pcan_rx[i].dma_physaddr; - for (j = 0; j < sizeof (an_rx_desc) / 4; j++) - PCAN_AUX_PUT32(pcan_p, AN_RX_DESC_OFFSET - + (i * sizeof (an_rx_desc)) - + (j * 4), ((uint32_t *)&an_rx_desc)[j]); - } - - - /* Allocate DMA for tx */ - if (pcan_set_cmd0(pcan_p, AN_CMD_ALLOC_DESC, - AN_DESCRIPTOR_TX, AN_TX_DESC_OFFSET, - AN_MAX_TX_DESC) != PCAN_SUCCESS) { - cmn_err(CE_WARN, "pcan init_dma: fail to alloc tx descriptor"); - goto error; - } - - for (i = 0; i < AN_MAX_TX_DESC; i++) { - an_tx_desc.an_offset = 0; - an_tx_desc.an_eoc = 0; - an_tx_desc.an_valid = 0; - an_tx_desc.an_len = 0; - an_tx_desc.an_phys = pcan_p->pcan_tx[i].dma_physaddr; - - for (j = 0; j < sizeof (an_tx_desc) / 4; j++) - PCAN_AUX_PUT32(pcan_p, AN_TX_DESC_OFFSET - + (i * sizeof (an_tx_desc)) - + (j * 4), ((uint32_t *)&an_tx_desc)[j]); - } - - /* Allocate DMA for rid */ - if (pcan_set_cmd0(pcan_p, AN_CMD_ALLOC_DESC, - AN_DESCRIPTOR_HOSTRW, AN_HOST_DESC_OFFSET, 1) != PCAN_SUCCESS) { - cmn_err(CE_WARN, "pcan init_dma: fail to alloc rid descriptor"); - goto error; - } - bzero(&an_rid_desc, sizeof (an_rid_desc)); - an_rid_desc.an_valid = 1; - an_rid_desc.an_len = AN_RID_BUFFER_SIZE; - an_rid_desc.an_rid = 0; - an_rid_desc.an_phys = pcan_p->pcan_cmd.dma_physaddr; - - for (i = 0; i < sizeof (an_rid_desc) / 4; i++) - PCAN_AUX_PUT32(pcan_p, AN_HOST_DESC_OFFSET + i * 4, - ((uint32_t *)&an_rid_desc)[i]); - - pcan_p->pcan_txring.an_tx_prod = 0; - pcan_p->pcan_txring.an_tx_cons = 0; - pcan_p->pcan_flag &= ~PCAN_CARD_SEND; - return (PCAN_SUCCESS); -error: - return (PCAN_FAIL); -} - -static int -pcan_init_dma(dev_info_t *dip, pcan_maci_t *pcan_p) -{ - int i, ret = PCAN_FAIL; - ddi_dma_cookie_t dma_cookie; - size_t len; - - /* Allocate DMA for rx */ - for (i = 0; i < AN_MAX_RX_DESC; i++) { - if (ddi_dma_alloc_handle(dip, &control_cmd_dma_attr, - DDI_DMA_SLEEP, 0, - &pcan_p->pcan_rx[i].dma_handle) != DDI_SUCCESS) - goto error; - - if (ddi_dma_mem_alloc(pcan_p->pcan_rx[i].dma_handle, - AN_RX_BUFFER_SIZE, &accattr, - DDI_DMA_STREAMING, DDI_DMA_SLEEP, 0, - (caddr_t *)&pcan_p->pcan_rx[i].dma_virtaddr, &len, - &pcan_p->pcan_rx[i].dma_acc_handle) != DDI_SUCCESS) { - goto error; - } - if (ddi_dma_addr_bind_handle( - pcan_p->pcan_rx[i].dma_handle, - NULL, (caddr_t)pcan_p->pcan_rx[i].dma_virtaddr, - len, DDI_DMA_READ | - DDI_DMA_STREAMING, DDI_DMA_SLEEP, 0, &dma_cookie, - &pcan_p->pcan_rx[i].ncookies) != DDI_DMA_MAPPED) { - goto error; - } - ASSERT(pcan_p->pcan_rx[i].ncookies == 1); - pcan_p->pcan_rx[i].dma_physaddr = dma_cookie.dmac_address; - } - - /* Allocate DMA for tx */ - for (i = 0; i < AN_MAX_TX_DESC; i++) { - if (ddi_dma_alloc_handle(dip, &control_cmd_dma_attr, - DDI_DMA_SLEEP, 0, - &pcan_p->pcan_tx[i].dma_handle) != DDI_SUCCESS) - goto error; - - if (ddi_dma_mem_alloc(pcan_p->pcan_tx[i].dma_handle, - AN_TX_BUFFER_SIZE, &accattr, - DDI_DMA_STREAMING, DDI_DMA_SLEEP, 0, - (caddr_t *)&pcan_p->pcan_tx[i].dma_virtaddr, &len, - &pcan_p->pcan_tx[i].dma_acc_handle) != DDI_SUCCESS) { - goto error; - } - if (ddi_dma_addr_bind_handle( - pcan_p->pcan_tx[i].dma_handle, - NULL, (caddr_t)pcan_p->pcan_tx[i].dma_virtaddr, - len, DDI_DMA_WRITE | - DDI_DMA_STREAMING, DDI_DMA_SLEEP, 0, &dma_cookie, - &pcan_p->pcan_tx[i].ncookies) != DDI_DMA_MAPPED) { - goto error; - } - ASSERT(pcan_p->pcan_tx[i].ncookies == 1); - pcan_p->pcan_tx[i].dma_physaddr = dma_cookie.dmac_address; - } - - /* Allocate DMA for rid */ - if (ddi_dma_alloc_handle(dip, &control_cmd_dma_attr, - DDI_DMA_SLEEP, 0, - &pcan_p->pcan_cmd.dma_handle) != DDI_SUCCESS) - goto error; - - if (ddi_dma_mem_alloc(pcan_p->pcan_cmd.dma_handle, - AN_RID_BUFFER_SIZE, &accattr, - DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, - (caddr_t *)&pcan_p->pcan_cmd.dma_virtaddr, &len, - &pcan_p->pcan_cmd.dma_acc_handle) != DDI_SUCCESS) { - goto error; - } - if (ddi_dma_addr_bind_handle( - pcan_p->pcan_cmd.dma_handle, - NULL, (caddr_t)pcan_p->pcan_cmd.dma_virtaddr, - len, DDI_DMA_RDWR | - DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, &dma_cookie, - &pcan_p->pcan_cmd.ncookies) != DDI_DMA_MAPPED) { - goto error; - } - ASSERT(pcan_p->pcan_cmd.ncookies == 1); - pcan_p->pcan_cmd.dma_physaddr = dma_cookie.dmac_address; - - if (ret = pcan_init_dma_desc(pcan_p)) { - cmn_err(CE_WARN, "pcan init_dma_desc: failed\n"); - goto error; - } - - return (PCAN_SUCCESS); -error: - pcan_free_dma(pcan_p); - return (ret); -} - -static void -pcan_free_dma(pcan_maci_t *pcan_p) -{ - int i; - - /* free RX dma */ - pcan_stop_rx_dma(pcan_p); - for (i = 0; i < AN_MAX_RX_DESC; i++) { - if (pcan_p->pcan_rx[i].dma_handle != NULL) { - if (pcan_p->pcan_rx[i].ncookies) { - (void) ddi_dma_unbind_handle( - pcan_p->pcan_rx[i].dma_handle); - pcan_p->pcan_rx[i].ncookies = 0; - } - ddi_dma_free_handle( - &pcan_p->pcan_rx[i].dma_handle); - pcan_p->pcan_rx[i].dma_handle = NULL; - } - if (pcan_p->pcan_rx[i].dma_acc_handle != NULL) { - ddi_dma_mem_free( - &pcan_p->pcan_rx[i].dma_acc_handle); - pcan_p->pcan_rx[i].dma_acc_handle = NULL; - } - } - - /* free TX dma */ - for (i = 0; i < AN_MAX_TX_DESC; i++) { - if (pcan_p->pcan_tx[i].dma_handle != NULL) { - if (pcan_p->pcan_tx[i].ncookies) { - (void) ddi_dma_unbind_handle( - pcan_p->pcan_tx[i].dma_handle); - pcan_p->pcan_tx[i].ncookies = 0; - } - ddi_dma_free_handle( - &pcan_p->pcan_tx[i].dma_handle); - pcan_p->pcan_tx[i].dma_handle = NULL; - } - if (pcan_p->pcan_tx[i].dma_acc_handle != NULL) { - ddi_dma_mem_free( - &pcan_p->pcan_tx[i].dma_acc_handle); - pcan_p->pcan_tx[i].dma_acc_handle = NULL; - } - } - - /* free cmd dma */ - if (pcan_p->pcan_cmd.dma_handle != NULL) { - if (pcan_p->pcan_cmd.ncookies) { - (void) ddi_dma_unbind_handle( - pcan_p->pcan_cmd.dma_handle); - pcan_p->pcan_cmd.ncookies = 0; - } - ddi_dma_free_handle( - &pcan_p->pcan_cmd.dma_handle); - pcan_p->pcan_cmd.dma_handle = NULL; - } - if (pcan_p->pcan_cmd.dma_acc_handle != NULL) { - ddi_dma_mem_free( - &pcan_p->pcan_cmd.dma_acc_handle); - pcan_p->pcan_cmd.dma_acc_handle = NULL; - } -} - -/* - * get card capability (WEP, default channel), setup broadcast, mac addresses - */ -static uint32_t -pcan_get_cap(pcan_maci_t *pcan_p) -{ - uint16_t stat; - - if (stat = pcan_cfg_ltv(PCAN_READ_LTV, pcan_p, &pcan_p->an_config)) { - PCANDBG((CE_NOTE, "pcan get_cap: read cfg fail %x", stat)); - return ((uint32_t)AN_RID_GENCONFIG << 16 | stat); - } - - if (stat = pcan_cap_ltv(PCAN_READ_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan get_cap: read cap fail %x", stat)); - return ((uint32_t)AN_RID_CAPABILITIES << 16 | stat); - } -#ifdef DEBUG - if (pcan_debug & PCAN_DBG_FW_VERSION) { - cmn_err(CE_NOTE, "the version of the firmware in the wifi card " - "'%s %s %s' is %s\n", - pcan_p->an_caps.an_manufname, - pcan_p->an_caps.an_prodname, - pcan_p->pcan_device_type == PCAN_DEVICE_PCI ? - "minipci" : "pccard", - pcan_p->an_caps.an_prodvers); - } -#endif - - if (stat = pcan_ssid_ltv(PCAN_READ_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan get_cap: read ssid fail %x", stat)); - return ((uint32_t)AN_RID_SSIDLIST << 16 | stat); - } - - if (stat = pcan_aplist_ltv(PCAN_READ_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan get_cap: read aplist fail %x", stat)); - return ((uint32_t)AN_RID_APLIST << 16 | stat); - } - if (stat = pcan_wepkey_ltv(PCAN_READ_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan get_cap: read wepkey fail %x", stat)); - return ((uint32_t)AN_RID_WEPKEY2 << 16 | stat); - } - ether_copy(pcan_p->an_caps.an_oemaddr, pcan_p->pcan_mac_addr); - return (PCAN_SUCCESS); -} - -static int -pcan_config_mac(pcan_maci_t *pcan_p) -{ - uint16_t stat; - - if (stat = pcan_ssid_ltv(PCAN_WRITE_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan config_mac: write SSID failed%x\n", - stat)); - return ((int)stat); - } - - if (stat = pcan_aplist_ltv(PCAN_WRITE_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan config_mac: write APlist failed%x\n", - stat)); - return ((int)stat); - } - if (stat = pcan_wepkey_ltv(PCAN_WRITE_LTV, pcan_p)) { - PCANDBG((CE_NOTE, "pcan config_mac: write wepkey failed%x\n", - stat)); - return ((int)stat); - } - if (pcan_p->pcan_usewep) - pcan_p->an_config.an_authtype |= - AN_AUTHTYPE_ENABLEWEP | AN_AUTHTYPE_ALLOW_UNENCRYPTED; - PCANDBG((CE_NOTE, "pcan config_mac: usewep=%x authtype=%x opmode=%x\n", - pcan_p->pcan_usewep, pcan_p->an_config.an_authtype, - pcan_p->an_config.an_opmode)); - - pcan_p->an_config.an_assoc_timeout = 5000; /* stop assoc seq in 5 sec */ - if (stat = pcan_cfg_ltv(PCAN_WRITE_LTV, pcan_p, &pcan_p->an_config)) { - PCANDBG((CE_NOTE, "pcan config_mac: write cfg failed %x\n", - stat)); - return ((int)stat); - } - - if (stat = pcan_cfg_ltv(PCAN_READ_LTV, pcan_p, - &pcan_p->an_actual_config)) { - PCANDBG((CE_NOTE, "pcan config_mac: read cfg failed%x\n", - stat)); - return ((int)stat); - } - PCANDBG((CE_NOTE, "pcan config_mac: optionmask=%x authtype=%x\n", 0, - pcan_p->an_actual_config.an_authtype)); - - if (stat = pcan_status_ltv(PCAN_READ_LTV, pcan_p, &pcan_p->an_status)) { - PCANDBG((CE_NOTE, "pcan config_mac: read status failed %x\n", - stat)); - return ((int)stat); - } - return (PCAN_SUCCESS); -} - -static int -pcan_loaddef(pcan_maci_t *pcan_p) -{ - int i; - - pcan_p->an_ssidlist.an_ssid1_len = 0; - bzero(pcan_p->an_ssidlist.an_ssid1, - sizeof (pcan_p->an_ssidlist.an_ssid1)); - for (i = 0; i < MAX_NWEPKEYS; i++) { - pcan_p->an_wepkey[i].an_index = 0xffff; - bzero(pcan_p->an_wepkey[i].an_key, - sizeof (pcan_p->an_wepkey[i].an_key)); - pcan_p->an_wepkey[i].an_keylen = 0; - bzero(pcan_p->an_wepkey[i].an_macaddr, - sizeof (pcan_p->an_wepkey[i].an_macaddr)); - pcan_p->an_wepkey[i].an_macaddr[0] = 1; - } - pcan_p->an_cur_wepkey = 0; - - pcan_p->pcan_usewep = 0; - pcan_p->an_config.an_opmode = AN_OPMODE_INFR_STATION; - pcan_p->an_config.an_authtype = AN_AUTHTYPE_OPEN; - pcan_p->an_config.an_stationary = 1; - pcan_p->an_config.an_max_beacon_lost_time = 0xffff; - i = pcan_config_mac(pcan_p); - - return (i); -} - -static int -pcan_init_nicmem(pcan_maci_t *pcan_p) -{ - int i; - uint16_t ret; - pcan_txring_t *ring_p = &pcan_p->pcan_txring; - - for (i = 0; i < AN_TX_RING_CNT; i++) { - uint16_t rc; - ret = pcan_alloc_nicmem(pcan_p, PCAN_NICMEM_SZ, &rc); - if (ret) { - cmn_err(CE_WARN, "pcan alloc NIC Tx buf[%x]: failed " - "%x\n", i, ret); - return (DDI_FAILURE); - } - ring_p->an_tx_fids[i] = rc; - ring_p->an_tx_ring[i] = 0; - PCANDBG((CE_NOTE, "pcan: NIC tx_id[%x]=%x\n", i, rc)); - } - ring_p->an_tx_prod = ring_p->an_tx_cons = 0; - return (PCAN_SUCCESS); -} - - - -static void -pcan_start_locked(pcan_maci_t *pcan_p) -{ - pcan_p->pcan_flag |= PCAN_CARD_INTREN; - PCAN_ENABLE_INTR(pcan_p); -} - -static void -pcan_stop_locked(pcan_maci_t *pcan_p) -{ - PCAN_DISABLE_INTR_CLEAR(pcan_p); - pcan_p->pcan_flag &= ~PCAN_CARD_INTREN; -} - -/* - * for scan result - */ -static int -pcan_add_scan_item(pcan_maci_t *pcan_p, struct an_ltv_scanresult s) -{ - an_scan_list_t *scan_item; - - scan_item = kmem_zalloc(sizeof (an_scan_list_t), KM_SLEEP); - if (scan_item == NULL) { - cmn_err(CE_WARN, "pcan add_scan_item: zalloc failed\n"); - return (PCAN_FAIL); - } - scan_item->an_val = s; - scan_item->an_timeout = AN_SCAN_TIMEOUT_MAX; - list_insert_tail(&pcan_p->an_scan_list, scan_item); - pcan_p->an_scan_num++; - return (PCAN_SUCCESS); -} - -static void -pcan_delete_scan_item(pcan_maci_t *pcan_p, an_scan_list_t *s) -{ - list_remove(&pcan_p->an_scan_list, s); - kmem_free(s, sizeof (*s)); - pcan_p->an_scan_num--; -} - -static void -pcan_scanlist_timeout(void *arg) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - an_scan_list_t *scan_item0, *scan_item1; - - mutex_enter(&pcan_p->pcan_scanlist_lock); - scan_item0 = list_head(&pcan_p->an_scan_list); - for (; scan_item0; ) { - PCANDBG((CE_NOTE, "pcan scanlist: ssid = %s\n", - scan_item0->an_val.an_ssid)); - PCANDBG((CE_NOTE, "pcan scanlist: timeout left: %ds", - scan_item0->an_timeout)); - scan_item1 = list_next(&pcan_p->an_scan_list, scan_item0); - if (scan_item0->an_timeout == 0) { - pcan_delete_scan_item(pcan_p, scan_item0); - } else { - scan_item0->an_timeout--; - } - scan_item0 = scan_item1; - } - mutex_exit(&pcan_p->pcan_scanlist_lock); - pcan_p->an_scanlist_timeout_id = timeout(pcan_scanlist_timeout, - pcan_p, drv_usectohz(1000000)); -} - -/* - * Brussels support - */ -/* - * MAC_PROP_WL_ESSID - */ -static int -pcan_set_essid(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - char *value; - struct an_ltv_ssidlist *ssidlist_p; - wl_essid_t *iw_essid = (wl_essid_t *)wldp_buf; - - ssidlist_p = &pcan_p->an_ssidlist; - bzero(ssidlist_p, sizeof (*ssidlist_p)); - value = iw_essid->wl_essid_essid; - (void) strncpy(ssidlist_p->an_ssid1, value, - MIN(32, strlen(value))); - ssidlist_p->an_ssid1_len = strlen(value); - - return (ENETRESET); -} - -static int -pcan_get_essid(pcan_maci_t *pcan_p, void *wldp_buf) -{ - int err = 0; - struct an_ltv_status *status_p; - wl_essid_t *ow_essid = (wl_essid_t *)wldp_buf; - - status_p = &pcan_p->an_status; - - if (pcan_status_ltv(PCAN_READ_LTV, pcan_p, status_p)) { - err = EIO; - return (err); - } - ow_essid->wl_essid_length = status_p->an_ssidlen; - bcopy(status_p->an_ssid, ow_essid->wl_essid_essid, - status_p->an_ssidlen); - - return (err); -} - -/* - * MAC_PROP_WL_BSSID - */ -static int -pcan_set_bssid(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - wl_bssid_t *value; - struct an_ltv_aplist *aplist_p; - - aplist_p = &pcan_p->an_aplist; - - value = (wl_bssid_t *)wldp_buf; - (void) strncpy((char *)aplist_p->an_ap1, (char *)value, 6); - - return (ENETRESET); -} - -static int -pcan_get_bssid(pcan_maci_t *pcan_p, void *wldp_buf) -{ - int err = 0; - struct an_ltv_status *status_p; - - status_p = &pcan_p->an_status; - - if (pcan_status_ltv(PCAN_READ_LTV, pcan_p, status_p)) { - err = EIO; - return (err); - } - - bcopy(status_p->an_cur_bssid, wldp_buf, sizeof (wl_bssid_t)); - PCANDBG((CE_CONT, - "pcan: cfg_bssid: bssid=%x %x %x %x %x %x\n", - status_p->an_cur_bssid[0], - status_p->an_cur_bssid[1], - status_p->an_cur_bssid[2], - status_p->an_cur_bssid[3], - status_p->an_cur_bssid[4], - status_p->an_cur_bssid[5])); - - return (err); -} - -/* - * MAC_PROP_WL_LINKSTATUS - */ -static void -pcan_get_linkstatus(pcan_maci_t *pcan_p, void *wldp_buf) -{ - if (pcan_p->pcan_flag & PCAN_CARD_LINKUP) - *(wl_linkstatus_t *)wldp_buf = WL_CONNECTED; - else - *(wl_linkstatus_t *)wldp_buf = WL_NOTCONNECTED; - -} - -/* - * MAC_PROP_WL_BSSTYP - */ -static int -pcan_set_bsstype(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - - if (*(wl_bss_type_t *)wldp_buf == WL_BSS_BSS) - cfg_p->an_opmode = AN_OPMODE_INFR_STATION; - if (*(wl_bss_type_t *)wldp_buf == WL_BSS_IBSS) - cfg_p->an_opmode = AN_OPMODE_IBSS_ADHOC; - if (*(wl_bss_type_t *)wldp_buf == WL_BSS_ANY) - cfg_p->an_opmode = AN_OPMODE_INFR_STATION; - cfg_p->an_assoc_timeout = 5000; - - return (ENETRESET); -} - -static void -pcan_get_bsstype(pcan_maci_t *pcan_p, void *wldp_buf) -{ - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - - if (cfg_p->an_opmode == AN_OPMODE_INFR_STATION) { - *(wl_bss_type_t *)wldp_buf = WL_BSS_BSS; - } else if (cfg_p->an_opmode == AN_OPMODE_IBSS_ADHOC) { - *(wl_bss_type_t *)wldp_buf = WL_BSS_IBSS; - } -} - -/* - * MAC_PROP_WL_PHY_CONFIG - */ -static int -pcan_set_phy(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - uint16_t ret; - int err = ENETRESET; - wl_phy_conf_t *phy = (wl_phy_conf_t *)wldp_buf; - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - - ret = (uint16_t)(phy->wl_phy_dsss_conf.wl_dsss_channel); - if (ret < 1 || ret > 14) { - err = ENOTSUP; - return (err); - } - cfg_p->an_ds_channel = ret; - cfg_p->an_assoc_timeout = 5000; - - return (err); -} - -static int -pcan_get_phy(pcan_maci_t *pcan_p, void *wldp_buf) -{ - int err = 0; - struct an_ltv_status *status_p; - wl_dsss_t *dsss = (wl_dsss_t *)wldp_buf; - - status_p = &pcan_p->an_status; - - if (pcan_status_ltv(PCAN_READ_LTV, pcan_p, status_p)) { - err = EIO; - return (err); - } - - dsss->wl_dsss_channel = status_p->an_channel_set; - dsss->wl_dsss_subtype = WL_DSSS; - - return (err); -} - -/* - * MAC_PROP_WL_DESIRED_RATESa - */ -static int -pcan_set_desrates(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - uint16_t i; - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - - bzero(cfg_p->an_rates, sizeof (cfg_p->an_rates)); - for (i = 0; i < ((wl_rates_t *)wldp_buf)->wl_rates_num; i++) { - cfg_p->an_rates[i] = - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[i]; - } - cfg_p->an_assoc_timeout = 5000; - - return (ENETRESET); -} - -static int -pcan_get_desrates(pcan_maci_t *pcan_p, void *wldp_buf) -{ - uint16_t i; - uint8_t rates = 0; - int err = 0; - struct an_ltv_genconfig *actcfg_p; - - actcfg_p = &pcan_p->an_actual_config; - - if (pcan_cfg_ltv(PCAN_READ_LTV, pcan_p, actcfg_p)) { - err = EIO; - return (err); - } - - for (i = 0; i < sizeof (actcfg_p->an_rates); i++) { - if (actcfg_p->an_rates[i] == 0) - break; - rates = MAX(rates, actcfg_p->an_rates[i]); - } - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = rates; - ((wl_rates_t *)wldp_buf)->wl_rates_num = 1; - - return (err); -} - -/* - * MAC_PROP_WL_SUP_RATE - */ -static void -pcan_get_suprates(void *wldp_buf) -{ - wl_rates_t *wl_rates = (wl_rates_t *)wldp_buf; - - wl_rates->wl_rates_num = 4; - wl_rates->wl_rates_rates[0] = WL_RATE_1M; - wl_rates->wl_rates_rates[1] = WL_RATE_2M; - wl_rates->wl_rates_rates[2] = WL_RATE_5_5M; - wl_rates->wl_rates_rates[3] = WL_RATE_11M; -} - -/* - * MAC_PROP_WL_POWER_MODE - */ -static int -pcan_get_powermode(pcan_maci_t *pcan_p, void *wldp_buf) -{ - int err = 0; - wl_ps_mode_t *powermode = (wl_ps_mode_t *)wldp_buf; - struct an_ltv_genconfig *actcfg_p; - - actcfg_p = &pcan_p->an_actual_config; - if (pcan_cfg_ltv(PCAN_READ_LTV, pcan_p, actcfg_p)) { - err = EIO; - return (err); - } - powermode->wl_ps_mode = actcfg_p->an_psave_mode; - - return (err); -} - -/* - * MAC_PROP_AUTH_MODE - */ -static int -pcan_set_authmode(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - struct an_ltv_genconfig *cfg_p; - int err = ENETRESET; - - cfg_p = &pcan_p->an_config; - if (*(wl_authmode_t *)wldp_buf == WL_OPENSYSTEM) { - cfg_p->an_authtype |= AN_AUTHTYPE_OPEN; - cfg_p->an_assoc_timeout = 5000; - } else { - err = EINVAL; - } - - return (err); -} - -static void -pcan_get_authmode(pcan_maci_t *pcan_p, void *wldp_buf) -{ - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - if (cfg_p->an_authtype & AN_AUTHTYPE_SHAREDKEY) { - *(wl_bss_type_t *)wldp_buf = WL_SHAREDKEY; - } else { - *(wl_bss_type_t *)wldp_buf = WL_OPENSYSTEM; - } -} - -/* - * MAC_PROP_WL_ENCRYPTION - */ -static int -pcan_set_encrypt(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - if (*(wl_encryption_t *)wldp_buf == WL_ENC_WEP) { - cfg_p->an_authtype |= (AN_AUTHTYPE_ENABLEWEP | - AN_AUTHTYPE_ALLOW_UNENCRYPTED); - pcan_p->pcan_usewep = 1; - } - if (*(wl_authmode_t *)wldp_buf == WL_NOENCRYPTION) { - cfg_p->an_authtype &= (~(AN_AUTHTYPE_ENABLEWEP | - AN_AUTHTYPE_ALLOW_UNENCRYPTED)); - pcan_p->pcan_usewep = 0; - } - cfg_p->an_assoc_timeout = 5000; - - return (ENETRESET); -} - -static void -pcan_get_encrypt(pcan_maci_t *pcan_p, void *wldp_buf) -{ - struct an_ltv_genconfig *cfg_p; - - cfg_p = &pcan_p->an_config; - if (cfg_p->an_authtype & AN_AUTHTYPE_ENABLEWEP) { - *(wl_bss_type_t *)wldp_buf = WL_ENC_WEP; - } else { - *(wl_bss_type_t *)wldp_buf = WL_NOENCRYPTION; - } -} - -/* - * MAC_PROP_WL_KEY_TAB - */ -static int -pcan_set_wepkey(pcan_maci_t *pcan_p, const void *wldp_buf) -{ - uint16_t i; - wl_wep_key_t *p_wepkey_tab; - struct an_ltv_wepkey *wepkey_p; - - p_wepkey_tab = (wl_wep_key_t *)wldp_buf; - for (i = 0; i < MAX_NWEPKEYS; i++) { - if (p_wepkey_tab[i].wl_wep_operation == WL_ADD) { - wepkey_p = &pcan_p->an_wepkey[i]; - bzero(wepkey_p, sizeof (*wepkey_p)); - wepkey_p->an_keylen = - p_wepkey_tab[i].wl_wep_length; - bcopy(p_wepkey_tab[i].wl_wep_key, - wepkey_p->an_key, - p_wepkey_tab[i].wl_wep_length); - wepkey_p->an_index = i; - wepkey_p->an_macaddr[0] = 1; - } - } - - return (ENETRESET); -} - -/* - * MAC_PROP_WL_RSSI - */ -static int -pcan_get_rssi(pcan_maci_t *pcan_p, void *wldp_buf) -{ - uint16_t val; - int err = 0; - wl_rssi_t *rssi = (wl_rssi_t *)wldp_buf; - struct an_ltv_status *status_p; - - status_p = &pcan_p->an_status; - - if (val = pcan_status_ltv(PCAN_READ_LTV, pcan_p, status_p)) { - err = EIO; - return (err); - } - val = status_p->an_cur_signal_quality; - PCANDBG((CE_NOTE, "pcan cfg_rssi: sl=%x", val)); - /* - * we reflect the value to 1-15 as rssi - */ - *rssi = 15 - ((val & 0xff) * 15 / 128 + 1); - - return (err); -} - -/* - * MAC_PROP_WL_RADIO - */ -static void -pcan_get_radio(void *wldp_buf) -{ - wl_radio_t *radio = (wl_radio_t *)wldp_buf; - - *radio = B_TRUE; -} - -/* - * MAC_PROP_WL_ESSLIST - */ -static void -pcan_get_esslist(pcan_maci_t *pcan_p, void *wldp_buf) -{ - uint16_t i; - wl_ess_conf_t *p_ess_conf; - an_scan_list_t *scan_item; - - mutex_enter(&pcan_p->pcan_scanlist_lock); - - ((wl_ess_list_t *)wldp_buf)->wl_ess_list_num = - pcan_p->an_scan_num; - scan_item = list_head(&pcan_p->an_scan_list); - for (i = 0; i < pcan_p->an_scan_num; i++) { - if (!scan_item) - break; - p_ess_conf = (wl_ess_conf_t *)((char *)wldp_buf + - offsetof(wl_ess_list_t, wl_ess_list_ess) + - i * sizeof (wl_ess_conf_t)); - bcopy(scan_item->an_val.an_ssid, - p_ess_conf->wl_ess_conf_essid.wl_essid_essid, - mi_strlen(scan_item->an_val.an_ssid)); - bcopy(scan_item->an_val.an_bssid, - p_ess_conf->wl_ess_conf_bssid, 6); - (p_ess_conf->wl_phy_conf).wl_phy_dsss_conf.wl_dsss_subtype - = WL_DSSS; - p_ess_conf->wl_ess_conf_wepenabled = - (scan_item->an_val.an_cap & 0x10 ? - WL_ENC_WEP : WL_NOENCRYPTION); - p_ess_conf->wl_ess_conf_bsstype = - (scan_item->an_val.an_cap & 0x1 ? - WL_BSS_BSS : WL_BSS_IBSS); - p_ess_conf->wl_phy_conf.wl_phy_dsss_conf.wl_dsss_channel = - scan_item->an_val.an_dschannel; - p_ess_conf->wl_ess_conf_sl = 15 - - ((scan_item->an_val.an_rssi & 0xff) * 15 / 128); - p_ess_conf->wl_supported_rates[0] = WL_RATE_1M; - p_ess_conf->wl_supported_rates[1] = WL_RATE_2M; - p_ess_conf->wl_supported_rates[2] = WL_RATE_5_5M; - p_ess_conf->wl_supported_rates[3] = WL_RATE_11M; - scan_item = list_next(&pcan_p->an_scan_list, scan_item); - } - - mutex_exit(&pcan_p->pcan_scanlist_lock); -} - -/* - * for wificonfig and dlamd ioctl - */ -static int -pcan_cfg_essid(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_essid: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - if (cmd == WLAN_GET_PARAM) { - err = pcan_get_essid(pcan_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcan_set_essid(pcan_p, infp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) { - (void) mi_mpprintf_putc((char *)mp, buf[i]); - } - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcan_cfg_bssid(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_bssid: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_bssid_t); - - if (cmd == WLAN_GET_PARAM) { - err = pcan_get_bssid(pcan_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcan_set_bssid(pcan_p, infp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) { - (void) mi_mpprintf_putc((char *)mp, buf[i]); - } - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcan_cmd_scan(pcan_maci_t *pcan_p) -{ - uint16_t i = 0, j, ret = WL_SUCCESS; - uint8_t bssid_t[6]; - uint32_t check_num, enable; - an_scan_list_t *scan_item0; - - enable = pcan_p->pcan_flag & PCAN_ENABLED; - if ((!enable) && - (ret = pcan_set_cmd(pcan_p, AN_CMD_ENABLE, 0))) { - ret = (int)WL_HW_ERROR; - goto exit; - } - if (ret = pcan_set_cmd(pcan_p, AN_CMD_SCAN, 0)) { - ret = (int)WL_HW_ERROR; - goto exit; - } - - pcan_delay(pcan_p, 500000); - ret = pcan_scanresult_ltv(PCAN_READ_LTV, - pcan_p, AN_RID_ESSIDLIST_FIRST, &pcan_p->an_scanresult[i]); - if ((ret) || pcan_p->an_scanresult[i].an_index == 0xffff) { - goto done; - } - do - { - i++; - ret = pcan_scanresult_ltv(PCAN_READ_LTV, - pcan_p, AN_RID_ESSIDLIST_NEXT, &pcan_p->an_scanresult[i]); - } while ((!ret) && (i < 32) && - (pcan_p->an_scanresult[i].an_index != 0xffff)); -done: - if ((!enable) && - (ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0))) { - ret = (int)WL_HW_ERROR; - goto exit; - } - /* record the scan result for future use */ - bzero(bssid_t, sizeof (bssid_t)); - for (j = 0; j < i; j++) { - /* - * sometimes, those empty items are recorded by hardware, - * this is wrong, just ignore those items here. - */ - if (bcmp(pcan_p->an_scanresult[j].an_bssid, - bssid_t, 6) == 0) { - continue; - } - /* - * save/update the scan item in scanlist - */ - mutex_enter(&pcan_p->pcan_scanlist_lock); - check_num = 0; - scan_item0 = list_head(&pcan_p->an_scan_list); - if (scan_item0 == NULL) { - if (pcan_add_scan_item(pcan_p, - pcan_p->an_scanresult[j]) != 0) { - mutex_exit(&pcan_p->pcan_scanlist_lock); - return (WL_SUCCESS); - } - } - for (; scan_item0; ) { - if (bcmp(pcan_p->an_scanresult[j].an_bssid, - scan_item0->an_val.an_bssid, 6) == 0) { - scan_item0->an_val = pcan_p->an_scanresult[j]; - scan_item0->an_timeout = AN_SCAN_TIMEOUT_MAX; - break; - } else { - check_num++; - } - scan_item0 = list_next(&pcan_p->an_scan_list, - scan_item0); - } - if (check_num == pcan_p->an_scan_num) { - if (pcan_add_scan_item(pcan_p, - pcan_p->an_scanresult[j]) != 0) { - mutex_exit(&pcan_p->pcan_scanlist_lock); - return (WL_SUCCESS); - } - } - mutex_exit(&pcan_p->pcan_scanlist_lock); - } -exit: - if (ret) - cmn_err(CE_WARN, "pcan: scan failed due to hardware error"); - return (ret); -} - -/*ARGSUSED*/ -static int -pcan_cfg_scan(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - wldp_t *outfp; - char *buf; - uint16_t i; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_scanlist: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - pcan_get_esslist(pcan_p, outfp->wldp_buf); - - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_ess_list_t, wl_ess_list_ess) + - pcan_p->an_scan_num * sizeof (wl_ess_conf_t); - outfp->wldp_result = WL_SUCCESS; - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - kmem_free(buf, MAX_BUF_LEN); - return (WL_SUCCESS); -} - -/*ARGSUSED*/ -static int -pcan_cfg_linkstatus(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - wldp_t *outfp; - char *buf; - uint16_t i; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_linkstatus: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - pcan_get_linkstatus(pcan_p, outfp->wldp_buf); - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_linkstatus_t); - outfp->wldp_result = WL_SUCCESS; - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - kmem_free(buf, MAX_BUF_LEN); - return (WL_SUCCESS); -} - -static int -pcan_cfg_bsstype(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_bsstype: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_bss_type_t); - - if (cmd == WLAN_GET_PARAM) { - pcan_get_bsstype(pcan_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcan_set_bsstype(pcan_p, infp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcan_cfg_phy(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_phy: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_dsss_t); - - if (cmd == WLAN_GET_PARAM) { - err = pcan_get_phy(pcan_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcan_set_phy(pcan_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); - -} - -/*ARGSUSED*/ -static int -pcan_cfg_desiredrates(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_rates: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - if (cmd == WLAN_GET_PARAM) { - err = pcan_get_desrates(pcan_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + sizeof (char); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcan_set_desrates(pcan_p, infp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcan_cfg_supportrates(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - int iret; - wldp_t *outfp; - char *buf; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_supportedrates: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - pcan_get_suprates(outfp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 4 * sizeof (char); - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcan_cfg_powermode(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_powermode: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - err = pcan_get_powermode(pcan_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_length = WIFI_BUF_OFFSET + - sizeof (wl_ps_mode_t); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_LACK_FEATURE; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); - -} - -static int -pcan_cfg_authmode(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - struct an_ltv_genconfig *actcfg_p; - - actcfg_p = &pcan_p->an_actual_config; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_autymode: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - pcan_get_authmode(pcan_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcan_set_authmode(pcan_p, outfp->wldp_buf); - if (err == EINVAL) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_LACK_FEATURE; - } else { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - PCANDBG((CE_NOTE, "pcan cfg_authmode: actual.authmode=%x", - actcfg_p->an_authtype)); - PCANDBG((CE_NOTE, "pcan cfg_authmode: actual.home_product=%x", - actcfg_p->an_rsvd6[2])); - - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcan_cfg_encryption(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *outfp; - char *buf; - int iret; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_encryption: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - pcan_get_encrypt(pcan_p, outfp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_encryption_t); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcan_set_encrypt(pcan_p, outfp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcan_cfg_wepkeyid(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i, ret; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - struct an_ltv_wepkey wepkey; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_wepkeyid: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - if (cmd == WLAN_GET_PARAM) { - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_wep_key_id_t); - outfp->wldp_result = WL_SUCCESS; - *(wl_wep_key_id_t *)(outfp->wldp_buf) = pcan_p->an_cur_wepkey; - } else if (cmd == WLAN_SET_PARAM) { - ret = (uint16_t)(*(wl_wep_key_id_t *)(infp->wldp_buf)); - if (ret > 3) { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - wepkey.an_index = 0xffff; - wepkey.an_macaddr[0] = ret & 0xff; - pcan_p->an_cur_wepkey = ret; - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcan_cfg_createibss(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *outfp; - char *buf; - int iret; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_createibss: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_create_ibss_t); - outfp->wldp_result = WL_LACK_FEATURE; - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcan_cfg_rssi(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - int iret; - wldp_t *outfp; - char *buf; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_rssi: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_rssi_t); - - if (cmd == WLAN_GET_PARAM) { - err = pcan_get_rssi(pcan_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - outfp->wldp_result = WL_READONLY; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcan_cfg_radio(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - int iret; - wldp_t *outfp; - char *buf; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_radio: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - *(wl_radio_t *)(outfp->wldp_buf) = B_TRUE; - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_radio_t); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_LACK_FEATURE; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcan_cfg_wepkey(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *outfp; - char *buf; - int iret; - wldp_t *infp; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCANDBG((CE_NOTE, "pcan cfg_wep: failed to alloc " - "memory(%d)\n", MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - if (cmd == WLAN_GET_PARAM) { - outfp->wldp_length = WIFI_BUF_OFFSET + - sizeof (wl_wep_key_tab_t); - outfp->wldp_result = WL_WRITEONLY; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcan_set_wepkey(pcan_p, infp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static void -pcan_connect_timeout(void *arg) -{ - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - uint16_t ret; - - mutex_enter(&pcan_p->pcan_glock); - if (ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0)) - goto done; - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - if (ret = pcan_config_mac(pcan_p)) - goto done; - ret = pcan_set_cmd(pcan_p, AN_CMD_ENABLE, 0); -done: - if (ret) - cmn_err(CE_WARN, "pcan: connect failed due to hardware error"); - mutex_exit(&pcan_p->pcan_glock); - pcan_p->pcan_connect_timeout_id = 0; -} - -static int -pcan_getset(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd) -{ - int ret = WL_SUCCESS; - int connect = 0; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_FAIL); - } - - switch (((wldp_t *)mp->b_rptr)->wldp_id) { - case WL_ESSID: - ret = pcan_cfg_essid(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_essid\n")); - break; - case WL_BSSID: - ret = pcan_cfg_bssid(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_bssid\n")); - break; - case WL_ESS_LIST: - ret = pcan_cfg_scan(mp, pcan_p, cmd); - PCANDBG((CE_NOTE, "cfg_scan\n")); - break; - case WL_LINKSTATUS: - ret = pcan_cfg_linkstatus(mp, pcan_p, cmd); - PCANDBG((CE_NOTE, "cfg_linkstatus\n")); - break; - case WL_BSS_TYPE: - ret = pcan_cfg_bsstype(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_bsstype\n")); - break; - case WL_PHY_CONFIG: - ret = pcan_cfg_phy(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_phy\n")); - break; - case WL_DESIRED_RATES: - ret = pcan_cfg_desiredrates(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_disred-rates\n")); - break; - case WL_SUPPORTED_RATES: - ret = pcan_cfg_supportrates(mp, pcan_p, cmd); - PCANDBG((CE_NOTE, "cfg_supported-rates\n")); - break; - case WL_POWER_MODE: - ret = pcan_cfg_powermode(mp, pcan_p, cmd); - PCANDBG((CE_NOTE, "cfg_powermode\n")); - break; - case WL_AUTH_MODE: - ret = pcan_cfg_authmode(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_authmode\n")); - break; - case WL_ENCRYPTION: - ret = pcan_cfg_encryption(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_encryption\n")); - break; - case WL_WEP_KEY_ID: - ret = pcan_cfg_wepkeyid(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_wepkeyid\n")); - break; - case WL_CREATE_IBSS: - ret = pcan_cfg_createibss(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_create-ibss\n")); - break; - case WL_RSSI: - ret = pcan_cfg_rssi(mp, pcan_p, cmd); - PCANDBG((CE_NOTE, "cfg_rssi\n")); - break; - case WL_RADIO: - ret = pcan_cfg_radio(mp, pcan_p, cmd); - PCANDBG((CE_NOTE, "cfg_radio\n")); - break; - case WL_WEP_KEY_TAB: - ret = pcan_cfg_wepkey(mp, pcan_p, cmd); - connect = 1; - PCANDBG((CE_NOTE, "cfg_wepkey\n")); - break; - case WL_SCAN: - mutex_exit(&pcan_p->pcan_glock); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_FAIL); - } - ret = pcan_cmd_scan(pcan_p); - /* - * a trick here. - * since the scan doesn't return too many items due to hardware - * reason, so the current scan result is an accumulation of - * several scans. For the first time or after many of the items - * aged, we scan again if too few items now in the scan table. - */ - if (pcan_p->an_scan_num < AN_SCAN_AGAIN_THRESHOLD) - ret = pcan_cmd_scan(pcan_p); - break; - case WL_LOAD_DEFAULTS: - if (ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcan_loaddef(pcan_p)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcan_set_cmd(pcan_p, AN_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - PCANDBG((CE_NOTE, "loaddef\n")); - break; - case WL_DISASSOCIATE: - mutex_exit(&pcan_p->pcan_glock); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_FAIL); - } - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - if (ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcan_loaddef(pcan_p)) { - ret = (int)WL_HW_ERROR; - break; - } - PCANDBG((CE_NOTE, "disassociate\n")); - break; - case WL_REASSOCIATE: - case WL_ASSOCIAT: - mutex_exit(&pcan_p->pcan_glock); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - return (PCAN_FAIL); - } - if (ret = pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - if (ret = pcan_config_mac(pcan_p)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcan_set_cmd(pcan_p, AN_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - PCANDBG((CE_NOTE, "associate")); - break; - - default: - break; - } - mutex_exit(&pcan_p->pcan_glock); - if ((cmd == WLAN_SET_PARAM) && (ret == WL_SUCCESS) && (connect)) { - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - (void) pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - pcan_p->pcan_connect_timeout_id = timeout(pcan_connect_timeout, - pcan_p, drv_usectohz(1000000)); - } - return (ret); -} - -static void -pcan_wlan_ioctl(pcan_maci_t *pcan_p, queue_t *wq, mblk_t *mp, uint32_t cmd) -{ - - struct iocblk *iocp = (struct iocblk *)mp->b_rptr; - uint32_t len, ret; - mblk_t *mp1; - - /* sanity check */ - if (iocp->ioc_count == 0 || !(mp1 = mp->b_cont)) { - miocnak(wq, mp, 0, EINVAL); - return; - } - - /* assuming single data block */ - if (mp1->b_cont) { - freemsg(mp1->b_cont); - mp1->b_cont = NULL; - } - - /* we will overwrite everything */ - mp1->b_wptr = mp1->b_rptr; - - ret = pcan_getset(mp1, pcan_p, cmd); - len = msgdsize(mp1); - miocack(wq, mp, len, ret); -} - -static void -pcan_ioctl(void *arg, queue_t *wq, mblk_t *mp) -{ - struct iocblk *iocp; - uint32_t cmd, ret; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - boolean_t need_privilege = B_TRUE; - - iocp = (struct iocblk *)mp->b_rptr; - iocp->ioc_error = 0; - cmd = iocp->ioc_cmd; - switch (cmd) { - default: - miocnak(wq, mp, 0, EINVAL); - return; - case WLAN_GET_PARAM: - need_privilege = B_FALSE; - break; - case WLAN_SET_PARAM: - case WLAN_COMMAND: - break; - } - - if (need_privilege && (ret = secpolicy_dl_config(iocp->ioc_cr)) != 0) - miocnak(wq, mp, 0, ret); - else - pcan_wlan_ioctl(pcan_p, wq, mp, cmd); -} -/* - * brussels - */ -/* ARGSUSED */ -static int -pcan_m_setprop(void *arg, const char *pr_name, mac_prop_id_t wldp_pr_num, - uint_t wldp_length, const void *wldp_buf) -{ - int err = 0; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - err = EINVAL; - return (err); - } - - switch (wldp_pr_num) { - /* mac_prop_id */ - case MAC_PROP_WL_ESSID: - err = pcan_set_essid(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_BSSID: - err = pcan_set_bssid(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_PHY_CONFIG: - err = pcan_set_phy(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_KEY_TAB: - err = pcan_set_wepkey(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_AUTH_MODE: - err = pcan_set_authmode(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_ENCRYPTION: - err = pcan_set_encrypt(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_BSSTYPE: - err = pcan_set_bsstype(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_DESIRED_RATES: - err = pcan_set_desrates(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_POWER_MODE: - case MAC_PROP_WL_CREATE_IBSS: - case MAC_PROP_WL_RADIO: - case MAC_PROP_WL_WPA: - case MAC_PROP_WL_KEY: - case MAC_PROP_WL_DELKEY: - case MAC_PROP_WL_SETOPTIE: - case MAC_PROP_WL_MLME: - case MAC_PROP_WL_LINKSTATUS: - case MAC_PROP_WL_ESS_LIST: - case MAC_PROP_WL_SUPPORTED_RATES: - case MAC_PROP_WL_RSSI: - case MAC_PROP_WL_CAPABILITY: - case MAC_PROP_WL_SCANRESULTS: - cmn_err(CE_WARN, "pcan_setprop:" - "opmode not support\n"); - err = ENOTSUP; - break; - default: - cmn_err(CE_WARN, "pcan_setprop:" - "opmode err\n"); - err = EINVAL; - break; - } - - mutex_exit(&pcan_p->pcan_glock); - - if (err == ENETRESET) { - pcan_p->pcan_flag &= ~PCAN_CARD_LINKUP; - (void) pcan_set_cmd(pcan_p, AN_CMD_DISABLE, 0); - if (pcan_p->pcan_connect_timeout_id != 0) { - (void) untimeout(pcan_p->pcan_connect_timeout_id); - pcan_p->pcan_connect_timeout_id = 0; - } - pcan_p->pcan_connect_timeout_id = timeout(pcan_connect_timeout, - pcan_p, drv_usectohz(1000000)); - - err = 0; - } - - return (err); -} /* ARGSUSED */ - -/* ARGSUSED */ -static int -pcan_m_getprop(void *arg, const char *pr_name, mac_prop_id_t wldp_pr_num, - uint_t wldp_length, void *wldp_buf) -{ - int err = 0; - pcan_maci_t *pcan_p = (pcan_maci_t *)arg; - - mutex_enter(&pcan_p->pcan_glock); - if (!(pcan_p->pcan_flag & PCAN_CARD_READY)) { - mutex_exit(&pcan_p->pcan_glock); - err = EINVAL; - return (err); - } - - switch (wldp_pr_num) { - /* mac_prop_id */ - case MAC_PROP_WL_ESSID: - err = pcan_get_essid(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_BSSID: - err = pcan_get_bssid(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_PHY_CONFIG: - err = pcan_get_phy(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_AUTH_MODE: - pcan_get_authmode(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_ENCRYPTION: - pcan_get_encrypt(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_BSSTYPE: - pcan_get_bsstype(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_LINKSTATUS: - pcan_get_linkstatus(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_ESS_LIST: - pcan_get_esslist(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_SUPPORTED_RATES: - pcan_get_suprates(wldp_buf); - break; - case MAC_PROP_WL_RSSI: - err = pcan_get_rssi(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_RADIO: - pcan_get_radio(wldp_buf); - break; - case MAC_PROP_WL_POWER_MODE: - err = pcan_get_powermode(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_DESIRED_RATES: - err = pcan_get_desrates(pcan_p, wldp_buf); - break; - case MAC_PROP_WL_CREATE_IBSS: - case MAC_PROP_WL_CAPABILITY: - case MAC_PROP_WL_WPA: - case MAC_PROP_WL_SCANRESULTS: - case MAC_PROP_WL_KEY_TAB: - case MAC_PROP_WL_KEY: - case MAC_PROP_WL_DELKEY: - case MAC_PROP_WL_SETOPTIE: - case MAC_PROP_WL_MLME: - cmn_err(CE_WARN, "pcan_getprop:" - "opmode not support %x\n", wldp_pr_num); - err = ENOTSUP; - break; - default: - cmn_err(CE_WARN, "pcan_getprop:" - "opmode err\n"); - err = EINVAL; - break; - } - - mutex_exit(&pcan_p->pcan_glock); - - return (err); -} - -static void -pcan_m_propinfo(void *arg, const char *pr_name, mac_prop_id_t wldp_pr_num, - mac_prop_info_handle_t mph) -{ - _NOTE(ARGUNUSED(arg, pr_name)); - - switch (wldp_pr_num) { - case MAC_PROP_WL_BSSTYPE: - case MAC_PROP_WL_ESS_LIST: - case MAC_PROP_WL_SUPPORTED_RATES: - case MAC_PROP_WL_RSSI: - mac_prop_info_set_perm(mph, MAC_PROP_PERM_READ); - break; - } -} - - -/* - * quiesce(9E) entry point. - * - * This function is called when the system is single-threaded at high - * PIL with preemption disabled. Therefore, this function must not be - * blocked. - * - * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure. - * DDI_FAILURE indicates an error condition and should almost never happen. - */ -#ifndef __sparc -static int -pcan_quiesce(dev_info_t *dip) -{ - pcan_maci_t *pcan_p; - - pcan_p = ddi_get_soft_state(pcan_soft_state_p, ddi_get_instance(dip)); - if (pcan_p == NULL) - return (DDI_FAILURE); - - if (pcan_p->pcan_flag & PCAN_CARD_READY) - pcan_stop_locked(pcan_p); - - return (DDI_SUCCESS); -} -#endif diff --git a/usr/src/uts/common/io/pcan/pcan.h b/usr/src/uts/common/io/pcan/pcan.h deleted file mode 100644 index e6338521b9..0000000000 --- a/usr/src/uts/common/io/pcan/pcan.h +++ /dev/null @@ -1,1394 +0,0 @@ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _SYS_PCAN_H -#define _SYS_PCAN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define AN_TIMEOUT 600000 - -/* - * Size of Aironet I/O space. - */ -#define AN_IOSIZ 0x40 - -#define PCAN_DEVICE_PCI 0x100 -#define PCAN_DEVICE_PCCARD 0x200 - -/* - * Hermes register definitions and what little I know about them. - */ - -/* - * Hermes command/status registers. - */ -#define AN_COMMAND(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x00 : 0x00) -#define AN_PARAM0(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x04 : 0x02) -#define AN_PARAM1(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x08 : 0x04) -#define AN_PARAM2(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x0c : 0x06) -#define AN_STATUS(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x10 : 0x08) -#define AN_RESP0(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x14 : 0x0A) -#define AN_RESP1(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x18 : 0x0C) -#define AN_RESP2(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x1c : 0x0E) -#define AN_LINKSTAT(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x20 : 0x10) - -/* - * Command register - */ -#define AN_CMD_BUSY 0x8000 /* busy bit */ -#define AN_CMD_NO_ACK 0x0080 /* don't acknowledge command */ -#define AN_CMD_CODE_MASK 0x003F -#define AN_CMD_QUAL_MASK 0x7F00 - -/* - * Command codes - */ -#define AN_CMD_NOOP 0x0000 /* no-op */ -#define AN_CMD_ENABLE 0x0001 /* enable */ -#define AN_CMD_DISABLE 0x0002 /* disable */ -#define AN_CMD_FORCE_SYNCLOSS 0x0003 /* force loss of sync */ -#define AN_CMD_FW_RESTART 0x0004 /* firmware resrart */ -#define AN_CMD_HOST_SLEEP 0x0005 -#define AN_CMD_MAGIC_PKT 0x0006 -#define AN_CMD_READCFG 0x0008 -#define AN_CMD_ALLOC_MEM 0x000A /* allocate NIC memory */ -#define AN_CMD_TX 0x000B /* transmit */ -#define AN_CMD_DEALLOC_MEM 0x000C -#define AN_CMD_NOOP2 0x0010 -#define AN_CMD_ALLOC_DESC 0x0020 -#define AN_CMD_ACCESS 0x0021 -#define AN_CMD_ALLOC_BUF 0x0028 -#define AN_CMD_PSP_NODES 0x0030 -#define AN_CMD_SET_PHYREG 0x003E -#define AN_CMD_TX_TEST 0x003F -#define AN_CMD_SLEEP 0x0085 -#define AN_CMD_SCAN 0x0103 -#define AN_CMD_SAVECFG 0x0108 - -/* - * Reclaim qualifier bit, applicable to the - * TX command. - */ -#define AN_RECLAIM 0x0100 /* reclaim NIC memory */ - -/* - * MPI 350 DMA descriptor information - */ -#define AN_DESCRIPTOR_TX 0x01 -#define AN_DESCRIPTOR_RX 0x02 -#define AN_DESCRIPTOR_TXCMP 0x04 -#define AN_DESCRIPTOR_HOSTWRITE 0x08 -#define AN_DESCRIPTOR_HOSTREAD 0x10 -#define AN_DESCRIPTOR_HOSTRW 0x20 - -#define AN_MAX_RX_DESC 1 -#define AN_MAX_TX_DESC 1 -#define AN_HOSTBUFSIZ 1840 - -/* - * dma descriptor definition for miniPci card. - * the miniPci card only works on x86. - */ -struct an_card_rid_desc -{ - uint32_t an_rid:16; - uint32_t an_len:15; - uint32_t an_valid:1; - uint64_t an_phys; -}; - -struct an_card_rx_desc -{ - uint32_t an_ctrl:15; - uint32_t an_done:1; - uint32_t an_len:15; - uint32_t an_valid:1; - uint64_t an_phys; -}; - -struct an_card_tx_desc -{ - uint32_t an_offset:15; - uint32_t an_eoc:1; - uint32_t an_len:15; - uint32_t an_valid:1; - uint64_t an_phys; -}; - -#define AN_MAX_DATALEN 4096 -#define AN_RID_BUFFER_SIZE AN_MAX_DATALEN -#define AN_RX_BUFFER_SIZE AN_HOSTBUFSIZ -#define AN_TX_BUFFER_SIZE AN_HOSTBUFSIZ -#define AN_HOST_DESC_OFFSET 0x800 -#define AN_RX_DESC_OFFSET (AN_HOST_DESC_OFFSET + \ - sizeof (struct an_card_rid_desc)) -#define AN_TX_DESC_OFFSET (AN_RX_DESC_OFFSET + \ - (AN_MAX_RX_DESC * sizeof (struct an_card_rx_desc))) - -/* - * ACCESS command qualifier bits. - */ -#define AN_ACCESS_READ 0x0000 -#define AN_ACCESS_WRITE 0x0100 - -/* - * PROGRAM command qualifier bits. - */ -#define AN_PROGRAM_DISABLE 0x0000 -#define AN_PROGRAM_ENABLE_RAM 0x0100 -#define AN_PROGRAM_ENABLE_NVRAM 0x0200 -#define AN_PROGRAM_NVRAM 0x0300 - -/* - * Status register values - */ -#define AN_STAT_CMD_CODE 0x003F -#define AN_STAT_CMD_RESULT 0x7F00 - -/* - * Linkstat register - */ -#define AN_LINKSTAT_ASSOCIATED 0x0400 -#define AN_LINKSTAT_AUTHFAIL 0x0300 -#define AN_LINKSTAT_ASSOC_FAIL 0x8400 /* (low byte is reason code) */ -#define AN_LINKSTAT_DISASSOC 0x8200 /* (low byte is reason code) */ -#define AN_LINKSTAT_DEAUTH 0x8100 /* (low byte is reason code) */ -#define AN_LINKSTAT_SYNCLOST_TSF 0x8004 -#define AN_LINKSTAT_SYNCLOST_HOSTREQ 0x8003 -#define AN_LINKSTAT_SYNCLOST_AVGRETRY 0x8002 -#define AN_LINKSTAT_SYNCLOST_MAXRETRY 0x8001 -#define AN_LINKSTAT_SYNCLOST_MISSBEACON 0x8000 - -/* - * Link stat low byte reason code - */ -#define AN_LINKSTAT_RC_RESERVED 0 /* Reserved return code */ -#define AN_LINKSTAT_RC_NOREASON 1 /* Unspecified reason */ -#define AN_LINKSTAT_RC_AUTHINV 2 /* Prev auth invalid */ -#define AN_LINKSTAT_RC_DEAUTH 3 /* Deauth due sender leaving */ -#define AN_LINKSTAT_RC_NOACT 4 /* Disassociated due inactivity */ -#define AN_LINKSTAT_RC_MAXLOAD 5 /* Disassociated due 2many stations */ -/* - * Class 2 frame received from non-Authenticated station - */ -#define AN_LINKSTAT_RC_BADCLASS2 6 -/* - * Class 3 frame received from non-Associated station - */ -#define AN_LINKSTAT_RC_BADCLASS3 7 -/* - * Disassociated because sending station is leaving BSS - */ -#define AN_LINKSTAT_RC_STATLEAVE 8 -/* - * Station requesting (Re)Association not Authenticated w/responding station - */ -#define AN_LINKSTAT_RC_NOAUTH 9 - -/* - * memory handle management registers - */ -#define AN_RX_FID 0x20 -#define AN_ALLOC_FID 0x22 -#define AN_TX_CMP_FID(p) \ - (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x1a : 0x24) - -#define AN_INVALID_FID 0xffff /* invalid fid value */ - -/* - * Buffer Access Path (BAP) registers. - * These are I/O channels. I believe you can use each one for - * any desired purpose independently of the other. In general - * though, we use BAP1 for reading and writing LTV records and - * reading received data frames, and BAP0 for writing transmit - * frames. This is a convention though, not a rule. - */ -#define AN_SEL0 0x18 -#define AN_SEL1 0x1A -#define AN_OFF0 0x1C -#define AN_OFF1 0x1E -#define AN_DATA0 0x36 -#define AN_DATA1 0x38 -#define AN_BAP0 AN_DATA0 -#define AN_BAP1 AN_DATA1 - -#define AN_OFF_BUSY 0x8000 -#define AN_OFF_ERR 0x4000 -#define AN_OFF_DONE 0x2000 -#define AN_OFF_DATAOFF 0x0FFF - -/* - * Event registers - */ -#define AN_EVENT_STAT(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x60 : 0x30) -/* - * Interrupt enable/disable - */ -#define AN_INT_EN(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x64 : 0x32) -#define AN_EVENT_ACK(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x68 : 0x34) - -/* - * Events - AN_EVENT_ACK register only - */ -#define AN_EV_CLR_STUCK_BUSY 0x4000 /* clear stuck busy bit */ -#define AN_EV_WAKEREQUEST 0x2000 /* awaken from PSP mode */ - /* Events shared by all 3 event regs: */ -#define AN_EV_MIC 0x1000 /* Message Integrity Check */ -#define AN_EV_AWAKE 0x0100 /* station woke up from PSP mode */ -#define AN_EV_LINKSTAT 0x0080 /* link status available */ -#define AN_EV_CMD 0x0010 /* command completed */ -#define AN_EV_ALLOC 0x0008 /* async alloc/reclaim completed */ -#define AN_EV_TX_EXC 0x0004 /* async xmit completed with failure */ -#define AN_EV_TX 0x0002 /* async xmit completed succesfully */ -#define AN_EV_RX 0x0001 /* async rx completed */ -#define AN_EV_TX_CPY 0x0400 - -#define AN_EV_ALL 0xffff /* all events */ -#define AN_INTRS(p) \ - (p->pcan_device_type == PCAN_DEVICE_PCI ? \ - (AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_ALLOC|AN_EV_LINKSTAT|AN_EV_MIC \ - |AN_EV_TX_CPY) : \ - (AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_ALLOC|AN_EV_LINKSTAT|AN_EV_MIC)) - -/* - * Host software registers - */ -#define AN_SW0(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x50 : 0x28) -#define AN_SW1(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x54 : 0x2A) -#define AN_SW2(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x58 : 0x2C) -#define AN_SW3(p) (p->pcan_device_type == PCAN_DEVICE_PCI ? 0x5c : 0x2E) - -#define AN_CNTL 0x14 - -#define AN_CNTL_AUX_ENA 0xC000 -#define AN_CNTL_AUX_ENA_STAT 0xC000 -#define AN_CNTL_AUX_DIS_STAT 0x0000 -#define AN_CNTL_AUX_ENA_CNTL 0x8000 -#define AN_CNTL_AUX_DIS_CNTL 0x4000 - -#define AN_AUX_PAGE 0x3A -#define AN_AUX_OFFSET 0x3C -#define AN_AUX_DATA 0x3E - -struct an_ltv_gen { - uint16_t an_len; - uint16_t an_type; - uint16_t an_val; -}; - -/* - * General configuration information. - */ -#define AN_RID_GENCONFIG 0xFF10 -struct an_ltv_genconfig { - uint16_t an_len; /* 0x00 */ - uint16_t an_opmode; /* 0x02 */ - uint16_t an_rxmode; /* 0x04 */ - uint16_t an_fragthresh; /* 0x06 */ - uint16_t an_rtsthresh; /* 0x08 */ - uint8_t an_macaddr[6]; /* 0x0A */ - uint8_t an_rates[8]; /* 0x10 */ - uint16_t an_shortretry_limit; /* 0x18 */ - uint16_t an_longretry_limit; /* 0x1A */ - uint16_t an_tx_msdu_lifetime; /* 0x1C */ - uint16_t an_rx_msdu_lifetime; /* 0x1E */ - uint16_t an_stationary; /* 0x20 */ - uint16_t an_ordering; /* 0x22 */ - uint16_t an_devtype; /* 0x24 */ - uint16_t an_rsvd0[5]; /* 0x26 */ - /* - * Scanning associating. - */ - uint16_t an_scanmode; /* 0x30 */ - uint16_t an_probedelay; /* 0x32 */ - uint16_t an_probe_energy_timeout; /* 0x34 */ - uint16_t an_probe_response_timeout; /* 0x36 */ - uint16_t an_beacon_listen_timeout; /* 0x38 */ - uint16_t an_ibss_join_net_timeout; /* 0x3A */ - uint16_t an_auth_timeout; /* 0x3C */ - uint16_t an_authtype; /* 0x3E */ - uint16_t an_assoc_timeout; /* 0x40 */ - uint16_t an_specified_ap_timeout; /* 0x42 */ - uint16_t an_offline_scan_interval; /* 0x44 */ - uint16_t an_offline_scan_duration; /* 0x46 */ - uint16_t an_link_loss_delay; /* 0x48 */ - uint16_t an_max_beacon_lost_time; /* 0x4A */ - uint16_t an_refresh_interval; /* 0x4C */ - uint16_t an_rsvd1; /* 0x4E */ - /* - * Power save operation - */ - uint16_t an_psave_mode; /* 0x50 */ - uint16_t an_sleep_for_dtims; /* 0x52 */ - uint16_t an_listen_interval; /* 0x54 */ - uint16_t an_fast_listen_interval; /* 0x56 */ - uint16_t an_listen_decay; /* 0x58 */ - uint16_t an_fast_listen_decay; /* 0x5A */ - uint16_t an_rsvd2[2]; /* 0x5C */ - /* - * Ad-hoc (or AP) operation. - */ - uint16_t an_beacon_period; /* 0x60 */ - uint16_t an_atim_duration; /* 0x62 */ - uint16_t an_rsvd3; /* 0x64 */ - uint16_t an_ds_channel; /* 0x66 */ - uint16_t an_rsvd4; /* 0x68 */ - uint16_t an_dtim_period; /* 0x6A */ - uint16_t an_rsvd5[2]; /* 0x6C */ - /* - * Radio operation. - */ - uint16_t an_radiotype; /* 0x70 */ - uint16_t an_diversity; /* 0x72 */ - uint16_t an_tx_power; /* 0x74 */ - uint16_t an_rss_thresh; /* 0x76 */ - uint16_t an_rsvd6[4]; /* 0x78 */ - /* - * Aironet extensions. - */ - uint8_t an_nodename[16]; /* 0x80 */ - uint16_t an_arl_thresh; /* 0x90 */ - uint16_t an_arl_decay; /* 0x92 */ - uint16_t an_arl_delay; /* 0x94 */ - uint8_t an_rsvd7; /* 0x96 */ - uint8_t an_rsvd8; /* 0x97 */ - uint8_t an_magic_packet_action; /* 0x98 */ - uint8_t an_magic_packet_ctl; /* 0x99 */ - uint16_t an_auto_wake; /* 0x9A */ - uint16_t an_pad[20]; -}; - -#define AN_OPMODE_IBSS_ADHOC 0x0000 -#define AN_OPMODE_INFR_STATION 0x0001 -#define AN_OPMODE_AP 0x0002 -#define AN_OPMODE_AP_REPEATER 0x0003 -#define AN_OPMODE_UNMODIFIED_PAYLOAD 0x0100 -#define AN_OPMODE_AIRONET_EXTENSIONS 0x0200 -#define AN_OPMODE_AP_EXTENSIONS 0x0400 - -#define AN_RXMODE_BC_MC_ADDR 0x0000 -#define AN_RXMODE_BC_ADDR 0x0001 -#define AN_RXMODE_ADDR 0x0002 -#define AN_RXMODE_80211_MONITOR_CURBSS 0x0003 -#define AN_RXMODE_80211_MONITOR_ANYBSS 0x0004 -#define AN_RXMODE_LAN_MONITOR_CURBSS 0x0005 -#define AN_RXMODE_NO_8023_HEADER 0x0100 -#define AN_RXMODE_USE_8023_HEADER 0x0000 - -#define AN_RATE_1MBPS 0x0002 -#define AN_RATE_2MBPS 0x0004 -#define AN_RATE_5_5MBPS 0x000B -#define AN_RATE_11MBPS 0x0016 - -#define AN_DEVTYPE_PC4500 0x0065 -#define AN_DEVTYPE_PC4800 0x006D - -#define AN_SCANMODE_ACTIVE 0x0000 -#define AN_SCANMODE_PASSIVE 0x0001 -#define AN_SCANMODE_AIRONET_ACTIVE 0x0002 - -#define AN_AUTHTYPE_NONE 0x0000 -#define AN_AUTHTYPE_OPEN 0x0001 -#define AN_AUTHTYPE_SHAREDKEY 0x0002 -#define AN_AUTHTYPE_EXCLUDE_UNENCRYPTED 0x0004 -#define AN_AUTHTYPE_ENABLEWEP 0x0100 -#define AN_AUTHTYPE_ALLOW_UNENCRYPTED 0x0200 - -#define AN_PSAVE_NONE 0x0000 -#define AN_PSAVE_CAM 0x0001 -#define AN_PSAVE_PSP 0x0002 -#define AN_PSAVE_PSP_CAM 0x0003 - -#define AN_RADIOTYPE_80211_FH 0x0001 -#define AN_RADIOTYPE_80211_DS 0x0002 -#define AN_RADIOTYPE_LM2000_DS 0x0004 - -#define AN_DIVERSITY_FACTORY_DEFAULT 0x0000 -#define AN_DIVERSITY_ANTENNA_1_ONLY 0x0001 -#define AN_DIVERSITY_ANTENNA_2_ONLY 0x0002 -#define AN_DIVERSITY_ANTENNA_1_AND_2 0x0003 - -#define AN_TXPOWER_FACTORY_DEFAULT 0x0000 -#define AN_TXPOWER_50MW 50 -#define AN_TXPOWER_100MW 100 -#define AN_TXPOWER_250MW 250 - -/* - * Valid SSID list. You can specify up to three SSIDs denoting - * the service sets that you want to join. The first SSID always - * defaults to "tsunami" which is a handy way to detect the - * card. - */ -#define AN_RID_SSIDLIST 0xFF11 -struct an_ltv_ssidlist { - uint16_t an_len; - uint16_t an_ssid1_len; - char an_ssid1[32]; - uint16_t an_ssid2_len; - char an_ssid2[32]; - uint16_t an_ssid3_len; - char an_ssid3[32]; - uint8_t an_pad[748]; -}; - -#define AN_DEF_SSID_LEN 7 -#define AN_DEF_SSID "tsunami" - -/* - * Valid AP list. - */ -#define AN_RID_APLIST 0xFF12 -struct an_ltv_aplist { - uint16_t an_len; - uint8_t an_ap1[6]; - uint8_t an_ap2[6]; - uint8_t an_ap3[6]; - uint8_t an_ap4[6]; -}; - -/* - * Driver name. - */ -#define AN_RID_DRVNAME 0xFF13 -struct an_ltv_drvname { - uint16_t an_len; - uint8_t an_drvname[16]; -}; - -/* - * Frame encapsulation. - */ -#define AN_RID_ENCAP 0xFF14 -struct an_rid_encap { - uint16_t an_len; - uint16_t an_ethertype_default; - uint16_t an_action_default; - uint16_t an_ethertype0; - uint16_t an_action0; - uint16_t an_ethertype1; - uint16_t an_action1; - uint16_t an_ethertype2; - uint16_t an_action2; - uint16_t an_ethertype3; - uint16_t an_action3; - uint16_t an_ethertype4; - uint16_t an_action4; - uint16_t an_ethertype5; - uint16_t an_action5; - uint16_t an_ethertype6; - uint16_t an_action6; -}; - -#define AN_ENCAP_ACTION_RX 0x0001 -#define AN_ENCAP_ACTION_TX 0x0002 - -#define AN_RXENCAP_NONE 0x0000 -#define AN_RXENCAP_RFC1024 0x0001 - -#define AN_TXENCAP_RFC1024 0x0000 -#define AN_TXENCAP_80211 0x0002 - -#define AN_RID_WEPKEY 0xFF15 -#define AN_RID_WEPKEY2 0xFF16 -struct an_ltv_wepkey { - uint16_t an_len; - uint16_t an_index; - uint8_t an_macaddr[6]; - uint16_t an_keylen; /* WEP40: 5, WEP128: 13 bytes */ - uint8_t an_key[16]; /* key value */ -}; - -#define AN_RID_CRYPT 0xFF18 -struct an_ltv_crypt { - uint16_t an_operation; /* 0: enable 1: disable */ - uint8_t an_optionmask[2]; /* 1: WEP40 2: WEP128 */ - uint8_t an_filler[8]; /* put struct 6 bytes longer */ -}; - -/* - * Actual config, same structure as general config (read only). - */ -#define AN_RID_ACTUALCFG 0xFF20 - -/* - * Card capabilities (read only). - */ -#define AN_RID_CAPABILITIES 0xFF00 -struct an_ltv_caps { - uint16_t an_len; - uint8_t an_oui[3]; /* 0x02 */ - uint8_t an_pad0; /* 0x05 */ - uint16_t an_prodnum; /* 0x06 */ - uint8_t an_manufname[32]; /* 0x08 */ - uint8_t an_prodname[16]; /* 0x28 */ - uint8_t an_prodvers[8]; /* 0x38 */ - uint8_t an_oemaddr[6]; /* 0x40 */ - uint8_t an_aironetaddr[6]; /* 0x46 */ - uint16_t an_radiotype; /* 0x4C */ - uint16_t an_country; /* 0x4E */ - uint8_t an_callid[6]; /* 0x50 */ - uint8_t an_supported_rates[8]; /* 0x56 */ - uint8_t an_rx_diversity; /* 0x5E */ - uint8_t an_tx_diversity; /* 0x5F */ - uint16_t an_tx_powerlevels[8]; /* 0x60 */ - uint16_t an_hwver; /* 0x70 */ - uint16_t an_hwcaps; /* 0x72 */ - uint16_t an_temprange; /* 0x74 */ - uint16_t an_fwrev; /* 0x76 */ - uint16_t an_fwsubrev; /* 0x78 */ - uint16_t an_interfacerev; /* 0x7A */ - uint16_t an_softcap; /* 0x7C */ - uint16_t an_bootblockrev; /* 0x7E */ - uint16_t an_requiredhw; /* 0x80 */ - uint16_t an_pad; -}; - -/* - * Access point (read only) - */ -#define AN_RID_APINFO 0xFF01 -struct an_ltv_apinfo { - uint16_t an_len; - uint16_t an_tim_addr; - uint16_t an_airo_addr; -}; - -/* - * Radio info (read only). - */ -#define AN_RID_RADIOINFO 0xFF02 -struct an_ltv_radioinfo { - uint16_t an_len; - /* - * some more fields here, waiting for freebsd code update. - */ -}; - -/* - * Status (read only). Note: the manual claims this RID is 108 bytes - * long (0x6A is the last datum, which is 2 bytes long) however when - * this RID is read from the NIC, it returns a length of 110. To be - * on the safe side, this structure is padded with an extra 16-bit - * word. (There is a misprint in the manual which says the macaddr - * field is 8 bytes long.) - * - * Also, the channel_set and current_channel fields appear to be - * reversed. Either that, or the hop_period field is unused. - */ -#define AN_RID_STATUS 0xFF50 -struct an_ltv_status { - uint16_t an_len; - uint8_t an_macaddr[6]; /* 0x02 */ - uint16_t an_opmode; /* 0x08 */ - uint16_t an_errcode; /* 0x0A */ - uint16_t an_cur_signal_quality; /* 0x0C */ - uint16_t an_ssidlen; /* 0x0E */ - uint8_t an_ssid[32]; /* 0x10 */ - uint8_t an_ap_name[16]; /* 0x30 */ - uint8_t an_cur_bssid[6]; /* 0x40 */ - uint8_t an_prev_bssid1[6]; /* 0x46 */ - uint8_t an_prev_bssid2[6]; /* 0x4C */ - uint8_t an_prev_bssid3[6]; /* 0x52 */ - uint16_t an_beacon_period; /* 0x58 */ - uint16_t an_dtim_period; /* 0x5A */ - uint16_t an_atim_duration; /* 0x5C */ - uint16_t an_hop_period; /* 0x5E */ - uint16_t an_channel_set; /* 0x60 */ - uint16_t an_cur_channel; /* 0x62 */ - uint16_t an_hops_to_backbone; /* 0x64 */ - uint16_t an_ap_total_load; /* 0x66 */ - uint16_t an_our_generated_load; /* 0x68 */ - uint16_t an_accumulated_arl; /* 0x6A */ - uint16_t an_signale_quality; /* 0x6C */ - uint16_t an_cur_tx_rate; /* 0x6E */ - uint16_t an_ap_device; /* 0x70 */ - uint16_t an_normallized_rssi; /* 0x72 */ - uint16_t an_short_preamble; /* 0x74 */ - uint8_t an_ap_ip_address[4]; /* 0x76 */ - uint8_t an_noise_pct; /* 0x7A */ - uint8_t an_noise_dbm; /* 0x7B */ - uint8_t an_noise_average_pct; /* 0x7C */ - uint8_t an_noise_average_dbm; /* 0x7D */ - uint8_t an_noise_max_pct; /* 0x7E */ - uint8_t an_noise_max_dbm; /* 0x7F */ - uint16_t an_load; /* 0x80 */ - uint8_t an_carrier[4]; /* 0x82 */ - uint16_t an_assoc_status; /* 0x86 */ - uint16_t an_pad; -}; - -#define AN_STATUS_OPMODE_CONFIGURED 0x0001 -#define AN_STATUS_OPMODE_MAC_ENABLED 0x0002 -#define AN_STATUS_OPMODE_RX_ENABLED 0x0004 -#define AN_STATUS_OPMODE_IN_SYNC 0x0010 -#define AN_STATUS_OPMODE_ASSOCIATED 0x0020 -#define AN_STATUS_OPMODE_ERROR 0x8000 - - -/* - * Statistics - */ -#define AN_RID_16BITS_CUM 0xFF60 /* Cumulative 16-bit stats counters */ -#define AN_RID_16BITS_DELTA 0xFF61 /* 16-bit stats (since last clear) */ -#define AN_RID_16BITS_DELTACLR 0xFF62 /* 16-bit stats, clear on read */ -#define AN_RID_32BITS_CUM 0xFF68 /* Cumulative 32-bit stats counters */ -#define AN_RID_32BITS_DELTA 0xFF69 /* 32-bit stats (since last clear) */ -#define AN_RID_32BITS_DELTACLR 0xFF6A /* 32-bit stats, clear on read */ - -/* - * Grrr. The manual says the statistics record is 384 bytes in length, - * but the card says the record is 404 bytes. There's some padding left - * at the end of this structure to account for any discrepancies. - */ -struct an_ltv_stats { - uint16_t an_len; - uint16_t an_rx_overruns; /* 0x02 */ - uint16_t an_rx_plcp_csum_errs; /* 0x04 */ - uint16_t an_rx_plcp_format_errs; /* 0x06 */ - uint16_t an_rx_plcp_len_errs; /* 0x08 */ - uint16_t an_rx_mac_crc_errs; /* 0x0A */ - uint16_t an_rx_mac_crc_ok; /* 0x0C */ - uint16_t an_rx_wep_errs; /* 0x0E */ - uint16_t an_rx_wep_ok; /* 0x10 */ - uint16_t an_retry_long; /* 0x12 */ - uint16_t an_retry_short; /* 0x14 */ - uint16_t an_retry_max; /* 0x16 */ - uint16_t an_no_ack; /* 0x18 */ - uint16_t an_no_cts; /* 0x1A */ - uint16_t an_rx_ack_ok; /* 0x1C */ - uint16_t an_rx_cts_ok; /* 0x1E */ - uint16_t an_tx_ack_ok; /* 0x20 */ - uint16_t an_tx_rts_ok; /* 0x22 */ - uint16_t an_tx_cts_ok; /* 0x24 */ - uint16_t an_tx_lmac_mcasts; /* 0x26 */ - uint16_t an_tx_lmac_bcasts; /* 0x28 */ - uint16_t an_tx_lmac_ucast_frags; /* 0x2A */ - uint16_t an_tx_lmac_ucasts; /* 0x2C */ - uint16_t an_tx_beacons; /* 0x2E */ - uint16_t an_rx_beacons; /* 0x30 */ - uint16_t an_tx_single_cols; /* 0x32 */ - uint16_t an_tx_multi_cols; /* 0x34 */ - uint16_t an_tx_defers_no; /* 0x36 */ - uint16_t an_tx_defers_prot; /* 0x38 */ - uint16_t an_tx_defers_energy; /* 0x3A */ - uint16_t an_rx_dups; /* 0x3C */ - uint16_t an_rx_partial; /* 0x3E */ - uint16_t an_tx_too_old; /* 0x40 */ - uint16_t an_rx_too_old; /* 0x42 */ - uint16_t an_lostsync_max_retries; /* 0x44 */ - uint16_t an_lostsync_missed_beacons; /* 0x46 */ - uint16_t an_lostsync_arl_exceeded; /* 0x48 */ - uint16_t an_lostsync_deauthed; /* 0x4A */ - uint16_t an_lostsync_disassociated; /* 0x4C */ - uint16_t an_lostsync_tsf_timing; /* 0x4E */ - uint16_t an_tx_host_mcasts; /* 0x50 */ - uint16_t an_tx_host_bcasts; /* 0x52 */ - uint16_t an_tx_host_ucasts; /* 0x54 */ - uint16_t an_tx_host_failed; /* 0x56 */ - uint16_t an_rx_host_mcasts; /* 0x58 */ - uint16_t an_rx_host_bcasts; /* 0x5A */ - uint16_t an_rx_host_ucasts; /* 0x5C */ - uint16_t an_rx_host_discarded; /* 0x5E */ - uint16_t an_tx_hmac_mcasts; /* 0x60 */ - uint16_t an_tx_hmac_bcasts; /* 0x62 */ - uint16_t an_tx_hmac_ucasts; /* 0x64 */ - uint16_t an_tx_hmac_failed; /* 0x66 */ - uint16_t an_rx_hmac_mcasts; /* 0x68 */ - uint16_t an_rx_hmac_bcasts; /* 0x6A */ - uint16_t an_rx_hmac_ucasts; /* 0x6C */ - uint16_t an_rx_hmac_discarded; /* 0x6E */ - uint16_t an_tx_hmac_accepted; /* 0x70 */ - uint16_t an_ssid_mismatches; /* 0x72 */ - uint16_t an_ap_mismatches; /* 0x74 */ - uint16_t an_rates_mismatches; /* 0x76 */ - uint16_t an_auth_rejects; /* 0x78 */ - uint16_t an_auth_timeouts; /* 0x7A */ - uint16_t an_assoc_rejects; /* 0x7C */ - uint16_t an_assoc_timeouts; /* 0x7E */ - uint16_t an_reason_outside_table; /* 0x80 */ - uint16_t an_reason1; /* 0x82 */ - uint16_t an_reason2; /* 0x84 */ - uint16_t an_reason3; /* 0x86 */ - uint16_t an_reason4; /* 0x88 */ - uint16_t an_reason5; /* 0x8A */ - uint16_t an_reason6; /* 0x8C */ - uint16_t an_reason7; /* 0x8E */ - uint16_t an_reason8; /* 0x90 */ - uint16_t an_reason9; /* 0x92 */ - uint16_t an_reason10; /* 0x94 */ - uint16_t an_reason11; /* 0x96 */ - uint16_t an_reason12; /* 0x98 */ - uint16_t an_reason13; /* 0x9A */ - uint16_t an_reason14; /* 0x9C */ - uint16_t an_reason15; /* 0x9E */ - uint16_t an_reason16; /* 0xA0 */ - uint16_t an_reason17; /* 0xA2 */ - uint16_t an_reason18; /* 0xA4 */ - uint16_t an_reason19; /* 0xA6 */ - uint16_t an_rx_mgmt_pkts; /* 0xA8 */ - uint16_t an_tx_mgmt_pkts; /* 0xAA */ - uint16_t an_rx_refresh_pkts; /* 0xAC */ - uint16_t an_tx_refresh_pkts; /* 0xAE */ - uint16_t an_rx_poll_pkts; /* 0xB0 */ - uint16_t an_tx_poll_pkts; /* 0xB2 */ - uint16_t an_host_retries; /* 0xB4 */ - uint16_t an_lostsync_hostreq; /* 0xB6 */ - uint16_t an_host_tx_bytes; /* 0xB8 */ - uint16_t an_host_rx_bytes; /* 0xBA */ - uint16_t an_uptime_usecs; /* 0xBC */ - uint16_t an_uptime_secs; /* 0xBE */ - uint16_t an_lostsync_better_ap; /* 0xC0 */ - uint16_t an_privacy_mismatch; /* 0xC2 */ - uint16_t an_jammed; /* 0xC4 */ - uint16_t an_rx_disc_wep_off; /* 0xC6 */ - uint16_t an_phy_ele_mismatch; /* 0xC8 */ - uint16_t an_leap_success; /* 0xCA */ - uint16_t an_leap_failure; /* 0xCC */ - uint16_t an_leap_timeouts; /* 0xCE */ - uint16_t an_leap_keylen_fail; /* 0xD0 */ -}; - -#define AN_RID_ESSIDLIST_FIRST 0xFF72 -#define AN_RID_ESSIDLIST_NEXT 0xFF73 - -struct an_ltv_scanresult { - uint16_t an_len; - uint16_t an_index; - uint16_t an_radiotype; - uint8_t an_bssid[6]; -#ifdef _BIG_ENDIAN - uint8_t an_ssidlen; - uint8_t an_zero; -#else - uint8_t an_zero; - uint8_t an_ssidlen; -#endif - char an_ssid[32]; - uint16_t an_rssi; - uint16_t an_cap; - uint16_t an_beaconinterval; - uint8_t an_rates[8]; - struct { - uint16_t dwell; - uint8_t hopset; - uint8_t hoppattern; - uint8_t hopindex; - uint8_t pad; - } an_fh; - uint16_t an_dschannel; - uint16_t an_atimwindow; -}; - -/* - * seconds after which the scan item ages - */ -#define AN_SCAN_TIMEOUT_MAX 30 - -/* - * threshold of scan result items below which scan will run again. - */ -#define AN_SCAN_AGAIN_THRESHOLD 5 - -typedef struct an_scan_list { - struct an_ltv_scanresult an_val; - uint32_t an_timeout; - list_node_t an_scan_node; -} an_scan_list_t; - -/* - * Receive frame structure. - */ -typedef struct an_rxframe { - uint32_t an_rx_time; /* 0x00 */ - uint16_t an_rx_status; /* 0x04 */ - uint16_t an_rx_payload_len; /* 0x06 */ - uint8_t an_rsvd0; /* 0x08 */ - uint8_t an_rx_signal_strength; /* 0x09 */ - uint8_t an_rx_rate; /* 0x0A */ - uint8_t an_rx_chan; /* 0x0B */ - uint8_t an_rx_assoc_cnt; /* 0x0C */ - uint8_t an_rsvd1[3]; /* 0x0D */ - uint8_t an_plcp_hdr[4]; /* 0x10 */ - uint16_t an_frame_ctl; /* 0x14 */ - uint16_t an_duration; /* 0x16 */ - uint8_t an_addr1[6]; /* 0x18 */ - uint8_t an_addr2[6]; /* 0x1E */ - uint8_t an_addr3[6]; /* 0x24 */ - uint16_t an_seq_ctl; /* 0x2A */ - uint8_t an_addr4[6]; /* 0x2C */ - uint16_t an_gaplen; /* 0x32 */ -} an_rxfrm_t; - -#define AN_RXGAP_MAX 8 - -/* - * Transmit frame structure. - */ -typedef struct an_txframe { - uint32_t an_tx_sw; /* 0x00 */ - uint16_t an_tx_status; /* 0x04 */ - uint16_t an_tx_payload_len; /* 0x06 */ - uint16_t an_tx_ctl; /* 0x08 */ - uint16_t an_tx_assoc_id; /* 0x0A */ - uint16_t an_tx_retry; /* 0x0C */ - uint8_t an_tx_assoc_cnt; /* 0x0E */ - uint8_t an_tx_rate; /* 0x0F */ - uint8_t an_tx_max_long_retries; /* 0x10 */ - uint8_t an_tx_max_short_retries; /* 0x11 */ - uint8_t an_rsvd0[2]; /* 0x12 */ - uint16_t an_frame_ctl; /* 0x14 */ - uint16_t an_duration; /* 0x16 */ - uint8_t an_addr1[6]; /* 0x18 */ - uint8_t an_addr2[6]; /* 0x1E */ - uint8_t an_addr3[6]; /* 0x24 */ - uint16_t an_seq_ctl; /* 0x2A */ - uint8_t an_addr4[6]; /* 0x2C */ - uint16_t an_gaplen; /* 0x32 */ -} an_txfrm_t; - -typedef struct an_frame { - union { - an_rxfrm_t rxfrm; - an_txfrm_t txfrm; - } frm; -} an_frm_t; - -#define AN_TXSTAT_EXCESS_RETRY 0x0002 -#define AN_TXSTAT_LIFE_EXCEEDED 0x0004 -#define AN_TXSTAT_AID_FAIL 0x0008 -#define AN_TXSTAT_MAC_DISABLED 0x0010 -#define AN_TXSTAT_ASSOC_LOST 0x0020 - -#define AN_TXCTL_RSVD 0x0001 -#define AN_TXCTL_TXOK_INTR 0x0002 -#define AN_TXCTL_TXERR_INTR 0x0004 -#define AN_TXCTL_HEADER_TYPE 0x0008 -#define AN_TXCTL_PAYLOAD_TYPE 0x0010 -#define AN_TXCTL_NORELEASE 0x0020 -#define AN_TXCTL_NORETRIES 0x0040 -#define AN_TXCTL_CLEAR_AID 0x0080 -#define AN_TXCTL_STRICT_ORDER 0x0100 -#define AN_TXCTL_USE_RTS 0x0200 - -#define AN_HEADERTYPE_8023 0x0000 -#define AN_HEADERTYPE_80211 0x0008 - -#define AN_PAYLOADTYPE_ETHER 0x0000 -#define AN_PAYLOADTYPE_LLC 0x0010 - -typedef enum { - ANC_RX_OVERRUNS, /* 0x04 */ - ANC_RX_PLCP_CSUM_ERRS, /* 0x08 */ - ANC_RX_PLCP_FORMAT_ERRS, /* 0x0c */ - ANC_RX_PLCP_LEN_ERRS, /* 0x10 */ - ANC_RX_MAC_CRC_ERRS, /* 0x14 */ - ANC_RX_MAC_CRC_OK, /* 0x18 */ - ANC_RX_WEP_ERRS, /* 0x1c */ - ANC_RX_WEP_OK, /* 0x20 */ - ANC_RETRY_LONG, /* 0x24 */ - ANC_RETRY_SHORT, /* 0x28 */ - ANC_RETRY_MAX, /* 0x2c */ - ANC_NO_ACK, /* 0x30 */ - ANC_NO_CTS, /* 0x34 */ - ANC_RX_ACK_OK, /* 0x38 */ - ANC_RX_CTS_OK, /* 0x3c */ - ANC_TX_ACK_OK, /* 0x40 */ - ANC_TX_RTS_OK, /* 0x44 */ - ANC_TX_CTS_OK, /* 0x48 */ - ANC_TX_LMAC_MCASTS, /* 0x4c */ - ANC_TX_LMAC_BCASTS, /* 0x50 */ - ANC_TX_LMAC_UCAST_FRAGS, /* 0x54 */ - ANC_TX_LMAC_UCASTS, /* 0x58 */ - ANC_TX_BEACONS, /* 0x5c */ - ANC_RX_BEACONS, /* 0x60 */ - ANC_TX_SINGLE_COLS, /* 0x64 */ - ANC_TX_MULTI_COLS, /* 0x68 */ - ANC_TX_DEFERS_NO, /* 0x6c */ - ANC_TX_DEFERS_PROT, /* 0x70 */ - ANC_TX_DEFERS_ENERGY, /* 0x74 */ - ANC_RX_DUPS, /* 0x78 */ - ANC_RX_PARTIAL, /* 0x7c */ - ANC_TX_TOO_OLD, /* 0x80 */ - ANC_RX_TOO_OLD, /* 0x84 */ - ANC_LOSTSYNC_MAX_RETRIES, /* 0x88 */ - ANC_LOSTSYNC_MISSED_BEACONS, /* 0x8c */ - ANC_LOSTSYNC_ARL_EXCEEDED, /* 0x90 */ - ANC_LOSTSYNC_DEAUTHED, /* 0x94 */ - ANC_LOSTSYNC_DISASSOCIATED, /* 0x98 */ - ANC_LOSTSYNC_TSF_TIMING, /* 0x9c */ - ANC_TX_HOST_MCASTS, /* 0xa0 */ - ANC_TX_HOST_BCASTS, /* 0xa4 */ - ANC_TX_HOST_UCASTS, /* 0xa8 */ - ANC_TX_HOST_FAILED, /* 0xac */ - ANC_RX_HOST_MCASTS, /* 0xb0 */ - ANC_RX_HOST_BCASTS, /* 0xb4 */ - ANC_RX_HOST_UCASTS, /* 0xb8 */ - ANC_RX_HOST_DISCARDED, /* 0xbc */ - ANC_TX_HMAC_MCASTS, /* 0xc0 */ - ANC_TX_HMAC_BCASTS, /* 0xc4 */ - ANC_TX_HMAC_UCASTS, /* 0xc8 */ - ANC_TX_HMAC_FAILED, /* 0xcc */ - ANC_RX_HMAC_MCASTS, /* 0xd0 */ - ANC_RX_HMAC_BCASTS, /* 0xd4 */ - ANC_RX_HMAC_UCASTS, /* 0xd8 */ - ANC_RX_HMAC_DISCARDED, /* 0xdc */ - ANC_TX_HMAC_ACCEPTED, /* 0xe0 */ - ANC_SSID_MISMATCHES, /* 0xe4 */ - ANC_AP_MISMATCHES, /* 0xe8 */ - ANC_RATES_MISMATCHES, /* 0xec */ - ANC_AUTH_REJECTS, /* 0xf0 */ - ANC_AUTH_TIMEOUTS, /* 0xf4 */ - ANC_ASSOC_REJECTS, /* 0xf8 */ - ANC_ASSOC_TIMEOUTS, /* 0xfc */ - ANC_REASON_OUTSIDE_TABLE, /* 0x100 */ - ANC_REASON1, /* 0x104 */ - ANC_REASON2, /* 0x108 */ - ANC_REASON3, /* 0x10c */ - ANC_REASON4, /* 0x110 */ - ANC_REASON5, /* 0x114 */ - ANC_REASON6, /* 0x118 */ - ANC_REASON7, /* 0x11c */ - ANC_REASON8, /* 0x120 */ - ANC_REASON9, /* 0x124 */ - ANC_REASON10, /* 0x128 */ - ANC_REASON11, /* 0x12c */ - ANC_REASON12, /* 0x130 */ - ANC_REASON13, /* 0x134 */ - ANC_REASON14, /* 0x138 */ - ANC_REASON15, /* 0x13c */ - ANC_REASON16, /* 0x140 */ - ANC_REASON17, /* 0x144 */ - ANC_REASON18, /* 0x148 */ - ANC_REASON19, /* 0x14c */ - ANC_RX_MGMT_PKTS, /* 0x150 */ - ANC_TX_MGMT_PKTS, /* 0x154 */ - ANC_RX_REFRESH_PKTS, /* 0x158 */ - ANC_TX_REFRESH_PKTS, /* 0x15c */ - ANC_RX_POLL_PKTS, /* 0x160 */ - ANC_TX_POLL_PKTS, /* 0x164 */ - ANC_HOST_RETRIES, /* 0x168 */ - ANC_LOSTSYNC_HOSTREQ, /* 0x16c */ - ANC_HOST_TX_BYTES, /* 0x170 */ - ANC_HOST_RX_BYTES, /* 0x174 */ - ANC_UPTIME_USECS, /* 0x178 */ - ANC_UPTIME_SECS, /* 0x17c */ - ANC_LOSTSYNC_BETTER_AP, /* 0x180 */ - ANC_PRIVACY_MISMATCH, /* 0x184 */ - ANC_JAMMED, /* 0x188 */ - ANC_RX_DISC_WEP_OFF, /* 0x18c */ - ANC_PHY_ELE_MISMATCH, /* 0x190 */ - ANC_LEAP_SUCCESS, /* 0x194 */ - ANC_LEAP_FAILURE, /* 0x198 */ - ANC_LEAP_TIMEOUTS, /* 0x19c */ - ANC_LEAP_KEYLEN_FAIL, /* 0x1a0 */ - ANC_STAT_CNT /* - keep it as the last entry */ -} pcan_cntr_offset; - -#define AN_TXCTL_80211 (AN_TXCTL_TXOK_INTR | AN_TXCTL_TXERR_INTR | \ - AN_HEADERTYPE_80211 | AN_PAYLOADTYPE_LLC | AN_TXCTL_NORELEASE) - -#define AN_TXCTL_8023 (AN_TXCTL_TXOK_INTR | AN_TXCTL_TXERR_INTR |\ - AN_HEADERTYPE_8023 | AN_PAYLOADTYPE_ETHER | AN_TXCTL_NORELEASE) - -#define AN_TXGAP_80211 6 -#define AN_TXGAP_8023 0 - -#define AN_NORMAL_RXMODE (AN_RXMODE_BC_MC_ADDR | \ - AN_RXMODE_USE_8023_HEADER) -#define AN_MONITOR_RXMODE (AN_RXMODE_LAN_MONITOR_CURBSS | \ - AN_RXMODE_USE_8023_HEADER) -struct an_802_3_hdr { - uint16_t an_8023_status; - uint16_t an_8023_payload_len; - uint8_t an_8023_dst_addr[6]; - uint8_t an_8023_src_addr[6]; - uint16_t an_8023_dat[3]; /* SNAP header */ - uint16_t an_8023_type; -}; - -typedef struct an_snap_hdr { - uint16_t an_snap_dat[3]; /* SNAP header */ - uint16_t an_snap_type; -} pcan_snaphdr_t; - -#define AN_TX_RING_CNT 4 -#define AN_TX_RING_MASK (4 - 1) -#define AN_INC(x, y) (x) = (x + 1) % (y) - -typedef struct an_tx_ring_data { - uint16_t an_tx_fids[AN_TX_RING_CNT]; - uint16_t an_tx_ring[AN_TX_RING_CNT]; - int an_tx_prod; - int an_tx_cons; - kmutex_t an_tx_lock; /* for send only */ -} pcan_txring_t; - -#define AN_802_3_OFFSET 0x2E -#define AN_802_11_OFFSET 0x44 -#define AN_802_11_OFFSET_RAW 0x3C - -#define AN_STAT_BADCRC 0x0001 -#define AN_STAT_UNDECRYPTABLE 0x0002 -#define AN_STAT_ERRSTAT 0x0003 -#define AN_STAT_MAC_PORT 0x0700 -#define AN_STAT_1042 0x2000 /* RFC1042 encoded */ -#define AN_STAT_TUNNEL 0x4000 /* Bridge-tunnel encoded */ -#define AN_STAT_WMP_MSG 0x6000 /* WaveLAN-II management protocol */ -#define AN_RXSTAT_MSG_TYPE 0xE000 - -#define AN_ENC_TX_802_3 0x00 -#define AN_ENC_TX_802_11 0x11 -#define AN_ENC_TX_E_II 0x0E - -#define AN_ENC_TX_1042 0x00 -#define AN_ENC_TX_TUNNEL 0xF8 - -#define AN_TXCNTL_MACPORT 0x00FF -#define AN_TXCNTL_STRUCTTYPE 0xFF00 - -/* - * SNAP (sub-network access protocol) constants for transmission - * of IP datagrams over IEEE 802 networks, taken from RFC1042. - * We need these for the LLC/SNAP header fields in the TX/RX frame - * structure. - */ -#define AN_SNAP_K1 0xaa /* assigned global SAP for SNAP */ -#define AN_SNAP_K2 0x00 -#define AN_SNAP_CONTROL 0x03 /* unnumbered information format */ -#define AN_SNAP_WORD0 (AN_SNAP_K1 | (AN_SNAP_K1 << 8)) -#define AN_SNAP_WORD1 (AN_SNAP_K2 | (AN_SNAP_CONTROL << 8)) -#define AN_SNAPHDR_LEN 0x6 - -#define AN_FTYPE_DATA 0x8 -#define ETH_HDRLEN (sizeof (struct ether_header)) /* 14 bytes */ -#define MLEN(mp) ((mp)->b_wptr - (mp)->b_rptr) - -typedef struct pcan_dma_info { - ddi_dma_handle_t dma_handle; - ddi_acc_handle_t dma_acc_handle; - uint32_t dma_physaddr; - caddr_t dma_virtaddr; - uint_t ncookies; -} pcan_dma_info_t; - -#define PCAN_DMA_SYNC(hdl, len, flag) ((void) ddi_dma_sync(hdl, 0, len, (flag))) - -/* - * The macinfo is really used as the softstate structure. - * - * pcan_mh - mac_handle_t structure - * pcan_cslock - lock for card services request. Used with pcan_cscv - * pcan_cscv - condition variable to wait for card events - * pcan_chdl - client handle, an uint32_t bit mask encoding for socket, - * function, and client info. - * See cs_priv.h MAKE_CLIENT_HANDLE. - * pcan_log_sock - holds the logical to physical translation for this card. - * Specifically has physical adapter and socket #. - * Socket # is the same as part of the pcan_chdl encoding. - * Physical adapter # is from card service socket impl. - */ -typedef struct pcan_macinfo { - mac_handle_t pcan_mh; - dev_info_t *pcan_dip; - - kmutex_t pcan_cslock; /* for card services */ - kcondvar_t pcan_cscv; /* for card services */ - client_handle_t pcan_chdl; /* s,f,c encoding, cs_priv.h */ - map_log_socket_t pcan_log_sock; /* logical/phys socket map */ - int pcan_socket; /* socket number */ - int pcan_config_hi; /* cfttbl index */ - int pcan_config; /* default config index */ - int pcan_vcc; /* vcc level */ - int pcan_iodecode; /* # of address lines */ - int pcan_usewep; - int pcan_reset_delay; - - caddr_t pcan_cfg_base; - ddi_acc_handle_t pcan_cfg_handle; - caddr_t pcan_bar0; - ddi_acc_handle_t pcan_handle0; - caddr_t pcan_bar1; - ddi_acc_handle_t pcan_handle1; - caddr_t pcan_bar2; - ddi_acc_handle_t pcan_handle2; - int pcan_device_type; /* pci or pcmcia card */ - - uint8_t pcan_mac_addr[ETHERADDRL]; - uint32_t pcan_flag; - uint32_t pcan_reschedule_need; - uint32_t glds_nocarrier; - uint32_t glds_noxmtbuf; - uint32_t glds_norcvbuf; - uint32_t glds_intr; - - pcan_dma_info_t pcan_cmd; - pcan_dma_info_t pcan_rx[AN_MAX_RX_DESC]; - pcan_dma_info_t pcan_tx[AN_MAX_TX_DESC]; - - kmutex_t pcan_glock; /* generic lock */ - kmutex_t pcan_scanlist_lock; /* scanlist lock */ - pcan_txring_t pcan_txring; - - struct an_ltv_ssidlist an_ssidlist; - struct an_ltv_aplist an_aplist; - struct an_ltv_caps an_caps; - struct an_ltv_crypt an_crypt; - struct an_ltv_wepkey an_wepkey[4]; - struct an_ltv_scanresult an_scanresult[32]; - uint16_t an_cur_wepkey; - uint16_t an_scan_num; - timeout_id_t an_scanlist_timeout_id; - list_t an_scan_list; - struct an_ltv_status an_status; - struct an_ltv_genconfig an_config; - struct an_ltv_genconfig an_actual_config; - struct an_ltv_stats an_stats; - uint64_t pcan_cntrs_s[ANC_STAT_CNT]; - - ddi_acc_handle_t pcan_port; - ddi_iblock_cookie_t pcan_ib_cookie; - ddi_softintr_t pcan_softint_id; - - ddi_softintr_t pcan_info_softint_id; - uint32_t pcan_info_softint_pending; - - timeout_id_t pcan_connect_timeout_id; - timeout_id_t pcan_linkdown_timeout_id; - int pcan_badrids_len; - prop_1275_cell_t *pcan_badrids; -} pcan_maci_t; - -#define PCAN_IDENT_STRING modldrv.drv_linkinfo - -#define HDL(pcan_p) ((pcan_p)->pcan_port) -#define GLD3(pcan_p) ((pcan_p)->pcan_mh) -#define DIP(pcan_p) ((pcan_p)->pcan_dip) - -#define PCAN_CARD_INTREN 0x1 -#define PCAN_CARD_LINKUP 0x2 -#define PCAN_ATTACHED 0x4 -#define PCAN_CS_REGISTERED 0x8 -#define PCAN_ENABLED 0x10 -#define PCAN_CARD_SEND 0x20 -#define PCAN_CARD_READY 0x40 -#define PCAN_CARD_FAILED 0x80 -#define PCAN_PLUMBED 0x100 -#define PCAN_SUSPENDED 0x200 - -#define PCAN_STATE_IDLE 0x1 - -#define PCAN_NICMEM_SZ (2048) /* 80211MTU set as 1500, so 2k here */ - -static int pcan_probe(dev_info_t *dip); -static int pcan_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); -static int pcan_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); - -static int pcan_register_cs(dev_info_t *dip, pcan_maci_t *pcan_p); -static void pcan_unregister_cs(pcan_maci_t *pcan_p); -static void pcan_destroy_locks(pcan_maci_t *pcan_p); -static void pcan_reset_backend(pcan_maci_t *pcan_p, int timeout); -static uint32_t pcan_get_cap(pcan_maci_t *pcan_p); -static int pcan_card_insert(pcan_maci_t *pcan_p); -static int pcan_ev_hdlr(event_t ev, int pri, event_callback_args_t *arg); -static void pcan_card_remove(pcan_maci_t *pcan_p); -static int pcan_init_nicmem(pcan_maci_t *pcan_p); -static void pcan_do_suspend(pcan_maci_t *pcan_p); - -/* - * high level device access primitives, glock must held before calling - */ -static uint16_t pcan_set_cmd0(pcan_maci_t *pcan_p, uint16_t cmd, uint16_t p0, - uint16_t p1, uint16_t p2); -static uint16_t pcan_set_cmd(pcan_maci_t *pcan_p, uint16_t cmd, uint16_t param); -static uint16_t pcan_set_ch(pcan_maci_t *, uint16_t, uint16_t, uint16_t); -static int pcan_init_dma_desc(pcan_maci_t *pcan_p); -static int pcan_init_dma(dev_info_t *dip, pcan_maci_t *pcan_p); -static void pcan_free_dma(pcan_maci_t *pcan_p); -static uint16_t pcan_put_ltv(pcan_maci_t *pcan_p, uint16_t len, uint16_t type, - uint16_t *val_p); -static uint16_t pcan_get_ltv(pcan_maci_t *pcan_p, uint16_t len, uint16_t type, - uint16_t *val_p); -#define PCAN_READ_LTV 0 -#define PCAN_WRITE_LTV 1 -static uint16_t pcan_status_ltv(int rw, pcan_maci_t *pcan_p, - struct an_ltv_status *status_p); -static uint16_t pcan_cfg_ltv(int rw, pcan_maci_t *pcan_p, - struct an_ltv_genconfig *cfg_p); -static uint16_t pcan_cap_ltv(int rw, pcan_maci_t *pcan_p); -static uint16_t pcan_ssid_ltv(int rw, pcan_maci_t *pcan_p); -static uint16_t pcan_aplist_ltv(int rw, pcan_maci_t *pcan_p); -static uint16_t pcan_scanresult_ltv(int rw, pcan_maci_t *pcan_p, uint16_t type, - struct an_ltv_scanresult *scanresult_p); -static uint16_t pcan_wepkey_ltv(int rw, pcan_maci_t *pcan_p); -static uint16_t pcan_rdch0(pcan_maci_t *pcan_p, uint16_t type, uint16_t off, - uint16_t *buf_p, int len, int order); -static uint16_t pcan_wrch1(pcan_maci_t *pcan_p, uint16_t type, uint16_t off, - uint16_t *buf_p, int len, int order); -static int pcan_config_mac(pcan_maci_t *pcan_p); -static void pcan_start_locked(pcan_maci_t *pcan_p); -static void pcan_stop_locked(pcan_maci_t *pcan_p); -static uint16_t pcan_alloc_nicmem(pcan_maci_t *pcan_p, uint16_t len, - uint16_t *id_p); - -/* - * Required driver entry points for gld - */ -static int pcan_start(void *); -static void pcan_stop(void *); -static int pcan_saddr(void *, const uint8_t *); -static mblk_t *pcan_tx(void *, mblk_t *); -static int pcan_send(pcan_maci_t *, mblk_t *); -static int pcian_send(pcan_maci_t *, mblk_t *); -static int pcan_prom(void *, boolean_t); -static int pcan_gstat(void *, uint_t, uint64_t *); -static int pcan_sdmulti(void *, boolean_t, const uint8_t *); -static void pcan_ioctl(void *, queue_t *, mblk_t *); - -static uint_t pcan_intr(caddr_t arg); -static uint_t pcan_intr_hi(caddr_t arg); -static void pcan_rcv(pcan_maci_t *pcan_p); -static void pcian_rcv(pcan_maci_t *pcan_p); -static uint_t pcan_info_softint(caddr_t arg); -static uint32_t pcan_txdone(pcan_maci_t *pcan_p, uint16_t err); -static int pcan_getset(mblk_t *mp, pcan_maci_t *pcan_p, uint32_t cmd); -static void pcan_wlan_ioctl(pcan_maci_t *pcan_p, queue_t *wq, - mblk_t *mp, uint32_t cmd); -static int pcan_loaddef(pcan_maci_t *pcan_p); - -static void pcan_scanlist_timeout(void *); -static void pcan_delete_scan_item(pcan_maci_t *, an_scan_list_t *); -static int pcan_add_scan_item(pcan_maci_t *, struct an_ltv_scanresult); -static void pcan_connect_timeout(void *arg); - -#define RDCH0(h, t, o, bufp, l) pcan_rdch0(h, t, o, bufp, l, 1) -#define WRCH1(h, t, o, bufp, l) pcan_wrch1(h, t, o, bufp, l, 1) -#define RDPKT(h, t, o, bufp, l) pcan_rdch0(h, t, o, bufp, l, 0) -#define WRPKT(h, t, o, bufp, l) pcan_wrch1(h, t, o, bufp, l, 0) - -#define PCAN_READ(p, o, v) { \ - if (p->pcan_device_type == PCAN_DEVICE_PCI) { \ - uint16_t t = ddi_get16(p->pcan_handle0, \ - (uint16_t *)(p->pcan_bar0 + o)); \ - v = LE_16(t); \ - } else { \ - uint16_t t = csx_Get16(HDL(p), o); \ - v = LE_16(t); \ - }\ -} -#define PCAN_WRITE(p, o, v) { \ - if (p->pcan_device_type == PCAN_DEVICE_PCI) { \ - ddi_put16(p->pcan_handle0, \ - (uint16_t *)(p->pcan_bar0 + o), LE_16(v)); \ - } else { \ - csx_Put16(HDL(p), o, LE_16(v)); \ - }\ -} -#define PCAN_READ_P(p, o, v, h) { \ - if (p->pcan_device_type == PCAN_DEVICE_PCI) { \ - uint16_t t = ddi_get16(p->pcan_handle0, \ - (uint16_t *)(p->pcan_bar0 + o)); \ - *(v) = h ? LE_16(t) : t; \ - } else { \ - uint16_t t = csx_Get16(HDL(p), o); \ - *(v) = h ? LE_16(t) : t; \ - }\ -} -#define PCAN_WRITE_P(p, o, v, h) { \ - if (p->pcan_device_type == PCAN_DEVICE_PCI) { \ - ddi_put16(p->pcan_handle0, (uint16_t *)(p->pcan_bar0 + o), \ - h ? LE_16(*(v)) : (*(v))); \ - } else {\ - csx_Put16(HDL(p), o, h ? LE_16(*(v)) : (*(v))); \ - }\ -} - -#ifdef _BIG_ENDIAN -#define PCAN_SWAP16(buf_p, len) { \ - uint16_t pcan_swap_len = len; \ - for (pcan_swap_len = (pcan_swap_len + 1) >> 1; pcan_swap_len; ) { \ - uint16_t val; \ - pcan_swap_len--; \ - val = *((uint16_t *)(buf_p) + pcan_swap_len); \ - *((uint16_t *)(buf_p) + pcan_swap_len) = LE_16(val); \ - } \ -} -#define PCAN_SWAP16_BUF(buf_p) PCAN_SWAP16(buf_p, sizeof (buf_p)) -#else /* _BIG_ENDIAN */ -#define PCAN_SWAP16(buf_p, len) -#define PCAN_SWAP16_BUF(buf_p) -#endif /* _BIG_ENDIAN */ - -#define PCAN_ENABLE_INTR(pcan_p) {\ - PCAN_WRITE(pcan_p, AN_INT_EN(pcan_p), AN_INTRS(pcan_p));\ -} -#define PCAN_DISABLE_INTR(pcan_p) { \ - PCAN_WRITE(pcan_p, AN_INT_EN(pcan_p), 0); \ -} -#define PCAN_DISABLE_INTR_CLEAR(pcan_p) { \ - PCAN_WRITE(pcan_p, AN_INT_EN(pcan_p), 0); \ - PCAN_WRITE(pcan_p, AN_EVENT_ACK(pcan_p), 0xffff);\ -} - -#define PCAN_AUX_PUT32(p, o, v)\ - ddi_put32(p->pcan_handle2, (uint32_t *)(p->pcan_bar2 + o), v) -#define PCAN_AUX_GET32(p, o, v) {\ - v = ddi_get32(p->pcan_handle2, (uint32_t *)(p->pcan_bar2 + o));\ -} - -/* - * 16-bit driver private status code - */ -#define PCAN_SUCCESS 0 -#define PCAN_FAIL 1 -#define PCAN_TIMEDOUT_CMD 0x10 -#define PCAN_TIMEDOUT_ACCESS 0x11 -#define PCAN_TIMEDOUT_TARGET 0x12 -#define PCAN_BADLEN 0x13 -#define PCAN_BADTYPE 0x14 -#define PCAN_TIMEDOUT_ALLOC 0x15 - -#define PCAN_STATUS_MAX 0xffff - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_PCAN_H */ diff --git a/usr/src/uts/common/io/pcmcia/pcata.c b/usr/src/uts/common/io/pcmcia/pcata.c deleted file mode 100644 index 31169332bc..0000000000 --- a/usr/src/uts/common/io/pcmcia/pcata.c +++ /dev/null @@ -1,1577 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/user.h> -#include <sys/buf.h> -#include <sys/ioctl.h> -#include <sys/file.h> -#include <sys/uio.h> -#include <sys/fcntl.h> -#include <sys/cmn_err.h> -#include <sys/kmem.h> -#include <sys/sysmacros.h> -#include <sys/stat.h> -#include <sys/scsi/scsi.h> - -#include <sys/fdio.h> - -#include <sys/errno.h> -#include <sys/open.h> -#include <sys/varargs.h> -#include <sys/fs/pc_label.h> - -#include <sys/hdio.h> -#include <sys/dkio.h> - -#include <sys/dklabel.h> - -#include <sys/vtoc.h> - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/dditypes.h> -#include <sys/dktp/cm.h> - -#include <sys/dktp/fdisk.h> - -#include <sys/fs/pc_label.h> - -/* - * PCMCIA and DDI related header files - */ -#include <sys/pccard.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> - -#include <sys/pcmcia/pcata.h> - -int pcata_event(event_t event, int priority, event_callback_args_t *eca); -static int pcata_create_device_node(ata_soft_t *softp); -static int pcata_initchild(ata_soft_t *softp, int targ); -static int pcata_drive_setup(ata_soft_t *softp); -static void pcata_drive_unsetup(ata_soft_t *softp); -static int pcata_card_insertion(ata_soft_t *softp); - -event2text_t event2text = { - 0, 0, 0, NULL }; - -char *pcata_name = PCATA_NAME; /* Global not local */ - - -/* - * pcata_event - this is the event handler - */ - -int -pcata_event(event_t event, int priority, event_callback_args_t *eca) -{ - ata_soft_t *softp = eca->client_data; - int retcode = CS_UNSUPPORTED_EVENT; - -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) { - event2text.event = event; - - (void) csx_Event2Text(&event2text); - cmn_err(CE_CONT, "_event (0x%x) %s priority 0x%x\n", - event, - event2text.text, - priority); - } -#endif - - - /* - * Find out which event we got and do the appropriate thing - */ - switch (event) { - case CS_EVENT_REGISTRATION_COMPLETE: - retcode = CS_SUCCESS; - break; - case CS_EVENT_CARD_INSERTION: - /* if this is NOT low priority, ignore it */ - if ((priority & CS_EVENT_PRI_LOW) == 0) - break; - - mutex_enter(&softp->event_hilock); - softp->card_state = PCATA_WAITINIT; - mutex_exit(&softp->event_hilock); - - retcode = pcata_card_insertion(softp); - if (retcode == CS_SUCCESS) { - if (pcata_drive_setup(softp) != DDI_SUCCESS) { - retcode = CS_GENERAL_FAILURE; - } - } - mutex_enter(&softp->event_hilock); - softp->card_state &= ~PCATA_WAITINIT; - /* kick start any threads that were blocked */ - cv_broadcast(&softp->readywait_cv); - mutex_exit(&softp->event_hilock); - - break; - /* - * Note that we get two CS_EVENT_CARD_REMOVAL events - - * one at high priority and the other at low priority. - * This is determined by the setting of the - * CS_EVENT_CARD_REMOVAL_LOWP bit in either of the - * event masks. - * (See the call to RegisterClient). - * We handle the CS_EVENT_PM_SUSPEND event the same - * way that we handle a CS_EVENT_CARD_REMOVAL event - * since if we're being asked to suspend, then we - * can't tell if the same card is inserted after - * a resume. - */ - case CS_EVENT_CARD_REMOVAL: - retcode = pcata_card_removal(softp, priority); - break; - - case CS_EVENT_PM_SUSPEND: - break; - } - - return (retcode); -} - - -/* - * at card insertion allocate I/O addresses - */ -int -pcata_ci_ioaddr(ata_soft_t *softp) -{ - pcata_cis_vars_t *cis_vars = &softp->cis_vars; - pcata_cftable_t *cftable = NULL; - pcata_cftable_t *cft; - io_req_t io_req; - int ret; - - /* - * Read CIS and setup the variables. - */ - ret = pcata_parse_cis(softp, &cftable); - if (ret != CS_SUCCESS) { - cmn_err(CE_CONT, "_ci_ioaddr " - "socket %d unable to get CIS information\n", - softp->sn); - pcata_destroy_cftable_list(&cftable); - return (ret); - } - - /* - * Parse CIS data - */ - cft = cftable; - while (cft) { - /* skip config index 0 (memory mapped config) */ - if (cft->p.config_index) { - /* - * Allocate IO resources. - */ - io_req.Attributes1 = IO_DATA_PATH_WIDTH_16; - io_req.IOAddrLines = cft->p.addr_lines; - io_req.BasePort1.base = (cft->p.ata_base[0] & 0xfff0); - io_req.NumPorts1 = cft->p.ata_length[0]; - - io_req.Attributes2 = 0; - io_req.NumPorts2 = 0; - if (cft->p.ranges == 2) { - io_req.Attributes2 = IO_DATA_PATH_WIDTH_16; - io_req.NumPorts2 = cft->p.ata_length[1]; - io_req.BasePort2.base = - (cft->p.ata_base[1] & 0xfff0); - } - - ret = csx_RequestIO(softp->client_handle, &io_req); - if (ret == CS_SUCCESS) { - /* found a good IO range */ - break; - } - } - cft = cft->next; - } - - - /* - * save all the CIS data - */ - if (cft) { - cis_vars->ata_base[0] = cft->p.ata_base[0] & 0xfff0; - cis_vars->ata_length[0] = cft->p.ata_length[0]; - cis_vars->addr_lines = cft->p.addr_lines; - cis_vars->ata_vcc = cft->p.ata_vcc; - cis_vars->ata_vpp1 = cft->p.ata_vpp1; - cis_vars->ata_vpp2 = cft->p.ata_vpp2; - cis_vars->pin = cft->p.pin; - cis_vars->config_index = cft->p.config_index; - if (cft->p.ranges == 2) { - cis_vars->ata_base[1] = cft->p.ata_base[1] & 0xfff0; - cis_vars->ata_length[1] = cft->p.ata_length[1]; - } - } - - /* release config table entries list */ - pcata_destroy_cftable_list(&cftable); - - /* - * if we could not find a usable set of address - */ - if (!cft) { - cmn_err(CE_CONT, "socket %d RequestIO failed %s\n", - softp->sn, pcata_CS_etext(ret)); - return (CS_GENERAL_FAILURE); - } - - softp->handle = io_req.BasePort1.handle; - softp->flags |= PCATA_REQUESTIO; - -#ifdef ATA_DEBUG - if (pcata_debug & DINIT) { - cmn_err(CE_CONT, - "\npresent mask: 0x%x\n" - "PRR pin mask: 0x%x\n" - "major_revision: 0x%x\n" - "minor_revision: 0x%x\n" - "manufacturer_id: 0x%x\n" - "card_id: 0x%x\n" - "config_base: 0x%x\n" - "config_index: 0x%x\n", - cis_vars->present, cis_vars->pin, - cis_vars->major_revision, - cis_vars->minor_revision, - cis_vars->manufacturer_id, - cis_vars->card_id, - cis_vars->config_base, - cis_vars->config_index); - - cmn_err(CE_CONT, - "\nata_vcc: %u\n" - "ata_vpp1: %u\n" - "ata_vpp2: %u\n" - "addr_lines: %u\n" - "ata_base[0]: %u\n" - "ata_length[0]: %u\n" - "ata_base[1]: %u\n" - "ata_length[1]: %u\n", - cis_vars->ata_vcc, - cis_vars->ata_vpp1, - cis_vars->ata_vpp2, - cis_vars->addr_lines, - cis_vars->ata_base[0], - cis_vars->ata_length[0], - cis_vars->ata_base[1], - cis_vars->ata_length[1]); - } -#endif -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) { - cmn_err(CE_CONT, "ports assigned: 0x%p+%u & 0x%p+%u\n", - (void *)io_req.BasePort1.handle, - io_req.NumPorts1, - (void *)io_req.BasePort2.handle, - io_req.NumPorts2); - cmn_err(CE_CONT, - "_ci_ioaddr: socket %d base_0 0x%x len_0 0x%x" - " base_1 0x%x len_1 0x%x\n", - softp->sn, - cis_vars->ata_base[0], cis_vars->ata_length[0], - cis_vars->ata_base[0], cis_vars->ata_length[1]); - } -#endif - return (CS_SUCCESS); -} - -/* - * The card must be inserted before some things can be done - * 1) determine the I/O address space - * 2) determine the IRQ - * 3) configure the card - */ -static int -pcata_card_insertion(ata_soft_t *softp) -{ - get_status_t get_status; - pcata_cis_vars_t *cis_vars = &softp->cis_vars; - irq_req_t irq_req; - config_req_t config_req; - modify_config_t modify_config; - int ret; - int i; - -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) - cmn_err(CE_CONT, "_card_insertion: socket %d\n", - softp->sn); -#endif - - mutex_enter(&softp->ata_mutex); - - /* - * Allocate io address space - */ - if ((softp->flags & PCATA_REQUESTIO) == 0) { - ret = pcata_ci_ioaddr(softp); - if (ret != CS_SUCCESS) { - mutex_exit(&softp->ata_mutex); - return (ret); - } - } - - /* - * Allocate an IRQ. - */ - softp->intr_pending = 0; - irq_req.Attributes = IRQ_TYPE_EXCLUSIVE; - irq_req.irq_handler = (csfunction_t *)pcata_intr_hi; - irq_req.irq_handler_arg = (caddr_t)softp; - if (!(softp->flags & PCATA_REQUESTIRQ)) { - ret = csx_RequestIRQ(softp->client_handle, &irq_req); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "socket %d RequestIRQ failed %s\n", - softp->sn, pcata_CS_etext(ret)); -#endif - mutex_exit(&softp->ata_mutex); - return (ret); - } - softp->flags |= PCATA_REQUESTIRQ; - } - - /* - * Initialize high level interrupt mutex. - */ - if (!(softp->flags & PCATA_DIDLOCKS2)) { - mutex_init(&softp->hi_mutex, NULL, - MUTEX_DRIVER, *(irq_req.iblk_cookie)); - softp->flags |= PCATA_DIDLOCKS2; - } - - /* - * Configure the card. - */ - config_req.Attributes = 0; - config_req.Vcc = cis_vars->ata_vcc; - config_req.Vpp1 = cis_vars->ata_vpp1; - config_req.Vpp2 = cis_vars->ata_vpp2; - config_req.IntType = SOCKET_INTERFACE_MEMORY_AND_IO; - config_req.ConfigBase = cis_vars->config_base; - config_req.Status = 0; - config_req.Pin = cis_vars->pin; - config_req.Copy = 0; - config_req.ConfigIndex = cis_vars->config_index; - config_req.Present = cis_vars->present; - - if (!(softp->flags & PCATA_REQUESTCONFIG)) { - - ret = csx_RequestConfiguration( - softp->client_handle, - &config_req); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, - "socket %d RequestConfiguration failed %s\n", - softp->sn, - pcata_CS_etext(ret)); -#endif - mutex_exit(&softp->ata_mutex); - return (ret); - } - softp->flags |= PCATA_REQUESTCONFIG; - } - -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) - cmn_err(CE_CONT, "_card_insertion: configuration complete\n"); -#endif - - mutex_exit(&softp->ata_mutex); - mutex_enter(&softp->event_hilock); - softp->card_state = PCATA_WAIT_FOR_READY; - mutex_exit(&softp->event_hilock); - - /* - * check the disk (every .05 sec) to see if it is ready - */ - for (i = 0; i < PCATA_READY_TIMEOUT; i += 50000) { - (void) csx_GetStatus(softp->client_handle, &get_status); - if (get_status.CardState & CS_EVENT_CARD_READY) - break; - drv_usecwait(50000); - } - - if ((get_status.CardState & CS_EVENT_CARD_READY) == 0) { - /* the disk is NOT ready */ - return (CS_GENERAL_FAILURE); - } - - mutex_enter(&softp->ata_mutex); - - /* - * create the device tree - */ - if (!(softp->flags & PCATA_MAKEDEVICENODE)) { - if (pcata_create_device_node(softp) != CS_SUCCESS) { - mutex_enter(&softp->event_hilock); - cv_broadcast(&softp->readywait_cv); - mutex_exit(&softp->event_hilock); - mutex_exit(&softp->ata_mutex); - return (CS_GENERAL_FAILURE); - } - softp->flags |= PCATA_MAKEDEVICENODE; - } - - /* - * enable interrupts thru the CSX context - */ - bzero((caddr_t)&modify_config, sizeof (modify_config_t)); - modify_config.Socket = softp->sn; - modify_config.Attributes = - CONF_IRQ_CHANGE_VALID | CONF_ENABLE_IRQ_STEERING; - ret = csx_ModifyConfiguration(softp->client_handle, &modify_config); - if (ret != CS_SUCCESS) { - cmn_err(CE_CONT, "ModifyConfiguration failed %s\n", - pcata_CS_etext(ret)); - mutex_exit(&softp->ata_mutex); - return (CS_GENERAL_FAILURE); - } - - mutex_enter(&softp->event_hilock); - softp->card_state &= ~PCATA_WAIT_FOR_READY; - softp->card_state |= PCATA_CARD_IS_READY; - softp->card_state |= PCATA_CARD_INSERTED; - cv_broadcast(&softp->readywait_cv); - mutex_exit(&softp->event_hilock); - - /* XXXX - for Volume Manager */ - if (softp->checkmedia_flag) { - softp->checkmedia_flag = 0; - softp->media_state = DKIO_INSERTED; - cv_broadcast(&softp->condvar_mediastate); -#ifdef ATA_DEBUG - if (pcata_debug & DVOLD) { - cmn_err(CE_CONT, "pcata_card_insertion: socket %d \n" - "\tdoing cv_broadcast - " - "softp->media_state of DKIO_INSERTED\n", softp->sn); - } -#endif - } - - mutex_exit(&softp->ata_mutex); - return (CS_SUCCESS); -} - -/* - * this function may be called by several different threads simultaneously - * the normal calling sequence is - */ -int -pcata_readywait(ata_soft_t *softp) -{ - mutex_enter(&softp->event_hilock); - - if (softp->card_state & PCATA_WAITINIT) - cv_wait(&softp->readywait_cv, &softp->event_hilock); - - mutex_exit(&softp->event_hilock); - return (softp->card_state & PCATA_CARD_IS_READY); -} - -/* - * Wait for minor nodes to be created before returning from attach, - * with a 5 sec. timeout to avoid hangs should an error occur. - */ -void -pcata_minor_wait(ata_soft_t *softp) -{ - clock_t timeout; - - timeout = ddi_get_lbolt() + drv_usectohz(5000000); - mutex_enter(&softp->event_hilock); - while ((softp->flags & PCATA_MAKEDEVICENODE) == 0) { - if (cv_timedwait(&softp->readywait_cv, &softp->event_hilock, - timeout) == (clock_t)-1) - break; - } - mutex_exit(&softp->event_hilock); -} - - -int -pcata_card_removal(ata_soft_t *softp, int priority) -{ - int ret; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) - cmn_err(CE_CONT, "_card_removal: priority=%x\n", - priority); -#endif - - mutex_enter(&softp->event_hilock); - softp->card_state &= ~(PCATA_CARD_INSERTED | PCATA_WAIT_FOR_READY); - softp->flags &= ~PCATA_READY; - mutex_exit(&softp->event_hilock); - - /* - * If we're being called at high priority, we can't do much more - * than note that the card went away. - */ - if (priority & CS_EVENT_PRI_HIGH) - return (CS_SUCCESS); - - mutex_enter(&softp->ata_mutex); - - /* - * If the device was open at the time the card was removed - * we set the ejected_while_mounted flag until all instances of the - * device are closed. - * If the device is mounted by vold it will remain open when - * the card is removed. If the card is inserted again it will - * be mounted again by vold. - */ - if ((softp->blk_open) || (softp->chr_open)) - softp->ejected_while_mounted = 1; - else { - int i; - for (i = 0; i < NUM_PARTS; i++) { - if (softp->lyr_open[i] != 0) - softp->ejected_while_mounted = 1; - } - } - - if (softp->ejected_while_mounted) { - cmn_err(CE_WARN, "socket%d " - "Card is ejected & " - "Data integrity is not guaranteed", - softp->sn); - } - - /* XXXX - for Volume Manager */ - if (softp->checkmedia_flag) { - softp->checkmedia_flag = 0; - softp->media_state = DKIO_EJECTED; - cv_broadcast(&softp->condvar_mediastate); -#ifdef ATA_DEBUG - if (pcata_debug & DVOLD) { - cmn_err(CE_CONT, - "pcata_card_removal: socket %d \n" - "\tdoing cv_broadcast - " - "softp->media_state of DKIO_EJECTED\n", - softp->sn); - } -#endif - } - - if (softp->flags & PCATA_REQUESTCONFIG) { - /* - * Release card configuration. - */ - release_config_t release_config; - if ((ret = csx_ReleaseConfiguration(softp->client_handle, - &release_config)) != CS_SUCCESS) { - - cmn_err(CE_CONT, "socket %d ReleaseConfiguration failed" - "%s\n", - softp->sn, pcata_CS_etext(ret)); - } /* ReleaseConfiguration */ - - softp->flags &= ~PCATA_REQUESTCONFIG; - } /* PCATA_REQUESTCONFIG */ - - if (softp->flags & PCATA_REQUESTIRQ) { - irq_req_t irq_req; - /* - * Release allocated IRQ resources. - */ - ret = csx_ReleaseIRQ(softp->client_handle, &irq_req); - if (ret != CS_SUCCESS) { - cmn_err(CE_CONT, "socket %d ReleaseIRQ failed %s\n", - softp->sn, pcata_CS_etext(ret)); - } /* ReleaseIRQ */ - softp->flags &= ~PCATA_REQUESTIRQ; - - } /* PCATA_REQUESTIRQ */ - - if (softp->flags & PCATA_DIDLOCKS2) { - mutex_destroy(&softp->hi_mutex); - softp->flags &= ~PCATA_DIDLOCKS2; - } - - - if (softp->flags & PCATA_REQUESTIO) { - /* - * Release allocated IO resources. - */ - io_req_t io_req; - if ((ret = csx_ReleaseIO(softp->client_handle, - &io_req)) != CS_SUCCESS) { - cmn_err(CE_CONT, "socket %d" - "ReleaseIO failed %s\n", - softp->sn, pcata_CS_etext(ret)); - } /* ReleaseIO */ - softp->flags &= ~PCATA_REQUESTIO; - } /* PCATA_REQUESTIO */ - - /* - * Remove all the device nodes. We don't have to explictly - * specify the names if we want Card Services to remove - * all of the devices. - * Note that when you call RemoveDeviceNode with the Action - * argument set to REMOVE_ALL_DEVICE_NODES, the - * NumDevNodes must be zero. - */ - if (softp->flags & PCATA_MAKEDEVICENODE) { - remove_device_node_t remove_device_node; - - remove_device_node.Action = REMOVE_ALL_DEVICE_NODES; - remove_device_node.NumDevNodes = 0; - - if ((ret = csx_RemoveDeviceNode(softp->client_handle, - &remove_device_node)) != CS_SUCCESS) { - cmn_err(CE_CONT, "_card_removal: socket %d " - "RemoveDeviceNode failed %s\n", - softp->sn, pcata_CS_etext(ret)); - } /* RemoveDeviceNode */ - softp->flags &= ~PCATA_MAKEDEVICENODE; - } /* PCATA_MAKEDEVICENODE */ - - pcata_drive_unsetup(softp); - mutex_exit(&softp->ata_mutex); - - mutex_enter(&softp->event_hilock); - cv_broadcast(&softp->readywait_cv); - mutex_exit(&softp->event_hilock); - return (CS_SUCCESS); -} - -static void -pcata_drive_unsetup(ata_soft_t *softp) -{ - ata_unit_t *unitp; - struct ata_cmpkt *pktp; - int drive; - buf_t *bp; - - /* - * free ab_active - */ - if ((pktp = softp->ab_active) != NULL) { - bp = pktp->cp_bp; - if (bp && ((bp->b_flags & B_DONE) == 0)) { - bioerror(bp, ENXIO); - biodone(bp); - } - kmem_free((void *)pktp, sizeof (*pktp)); - softp->ab_active = NULL; - } - - /* release any packets queued on the controller */ - while ((pktp = softp->ab_head) != NULL) { - softp->ab_head = pktp->pkt_forw; - bp = pktp->cp_bp; - if (bp && ((bp->b_flags & B_DONE) == 0)) { - /* first free the packets */ - bioerror(bp, ENXIO); - biodone(bp); - } - kmem_free((void *)pktp, sizeof (*pktp)); - } - - /* release the unit structures */ - while ((unitp = softp->ab_link) != NULL) { - softp->ab_link = unitp->a_forw; - kmem_free(unitp, sizeof (ata_unit_t)); - } - - /* - * now free the atarpbuf memory - * It is poor code practice to use artificial number of drives, - * but we need to be consistant with the rest of the code, hence the - * drive=1 value. - */ - for (drive = 0; drive < 1; drive++) { - if (softp->ab_rpbp[drive]) { - kmem_free(softp->ab_rpbp[drive], - (sizeof (struct atarpbuf) + - sizeof (struct scsi_inquiry))); - softp->ab_rpbp[drive] = NULL; - } - } -} - - -/* - * pcata_parse_cis - gets CIS information to configure the card. - * - * returns: CS_SUCCESS - if CIS information retreived correctly - * CS_OUT_OF_RESOURCE - if no memory for cftable entry - * {various CS return codes} - if problem getting CIS information - */ -int -pcata_parse_cis(ata_soft_t *softp, pcata_cftable_t **cftable) -{ - - - pcata_cis_vars_t *cis_vars = &softp->cis_vars; - cistpl_config_t cistpl_config; - cistpl_cftable_entry_t cistpl_cftable_entry; - struct cistpl_cftable_entry_io_t *io = &cistpl_cftable_entry.io; - cistpl_vers_1_t cistpl_vers_1; - tuple_t tuple; - pcata_cftable_t *cft, *ocft, *dcft, default_cftable; - int ret, last_config_index; - cistpl_manfid_t cistpl_manfid; - - dcft = &default_cftable; - - /* - * Clear the PCATA_VALID_IO_INFO flags here. - * These will be set if necessary as we parse the CIS and - * check the manufacturer specific overrides later on. - */ - softp->flags &= ~PCATA_VALID_IO_INFO; - - - /* - * Clear the CIS information structure. - */ - bzero((caddr_t)cis_vars, sizeof (pcata_cis_vars_t)); - - /* - * CISTPL_CONFIG processing. Search for the first config tuple - * so that we can get a pointer to the card's configuration - * registers. If this tuple is not found, there's no point - * in searching for anything else. - */ - tuple.Attributes = 0; - tuple.DesiredTuple = CISTPL_CONFIG; - if ((ret = csx_GetFirstTuple(softp->client_handle, - &tuple)) != CS_SUCCESS) { - cmn_err(CE_CONT, "_parse_cis: socket %d CISTPL_CONFIG " - "tuple not found\n", softp->sn); - return (ret); - } /* GetFirstTuple */ - - /* - * We shouldn't ever fail parsing this tuple. If we do, - * there's probably an internal error in the CIS parser. - */ - ret = csx_Parse_CISTPL_CONFIG(softp->client_handle, &tuple, - &cistpl_config); - if (ret != CS_SUCCESS) { - return (ret); - } - - /* - * This is the last CISTPL_CFTABLE_ENTRY tuple index that - * we need to look at. - */ - last_config_index = cistpl_config.last; - - if (cistpl_config.nr) { - cis_vars->config_base = cistpl_config.base; - cis_vars->present = cistpl_config.present; - } else { - cmn_err(CE_CONT, "_parse_cis: socket %d" - "CISTPL_CONFIG no configuration registers" - "found\n", softp->sn); - return (CS_BAD_CIS); - } /* if (cistpl_config.nr) */ - - /* - * CISTPL_VERS_1 processing. The information from this tuple is - * mainly used for display purposes. - */ - tuple.Attributes = 0; - tuple.DesiredTuple = CISTPL_VERS_1; - ret = csx_GetFirstTuple(softp->client_handle, &tuple); - if (ret != CS_SUCCESS) { - /* - * It's OK not to find the tuple if it's not in the CIS, but - * this test will catch other errors. - */ - if (ret != CS_NO_MORE_ITEMS) { - return (ret); - } - } else { - /* - * We shouldn't ever fail parsing this tuple. If we do, - * there's probably an internal error in the CIS parser. - */ - if ((ret = csx_Parse_CISTPL_VERS_1(softp->client_handle, - &tuple, &cistpl_vers_1)) != CS_SUCCESS) { - - return (ret); - } else { - int i; - - cis_vars->major_revision = cistpl_vers_1.major; - cis_vars->minor_revision = cistpl_vers_1.minor; - - - /* - * The first byte of the unused prod_strings will be - * NULL since we did a bzero(cis_vars) above. - */ - for (i = 0; i < cistpl_vers_1.ns; i++) - (void) strcpy(cis_vars->prod_strings[i], - cistpl_vers_1.pi[i]); - - } /* csx_Parse_CISTPL_VERS_1 */ - } /* GetFirstTuple */ - - /* - * CISTPL_CFTABLE_ENTRY processing. Search for the first config tuple - * so that we can get a card configuration. If this tuple is not - * found, there's no point in searching for anything else. - */ - tuple.Attributes = 0; - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - if ((ret = csx_GetFirstTuple(softp->client_handle, - &tuple)) != CS_SUCCESS) { - cmn_err(CE_CONT, - "_parse_cis: socket %d CISTPL_CFTABLE_ENTRY " - "tuple not found\n", softp->sn); - return (ret); - } /* GetFirstTuple */ - - /* - * Clear the default values. - */ - bzero((caddr_t)dcft, sizeof (pcata_cftable_t)); - - - /* - * Some cards don't provide enough information - * in their CIS to allow us to configure them - * using CIS information alone, so we have to - * set some default values here. - */ - dcft->p.ata_vcc = 50; - - - /* - * Loop through the CISTPL_CFTABLE_ENTRY tuple until we find a - * valid configuration. - */ - do { - - ocft = kmem_zalloc(sizeof (pcata_cftable_t), KM_NOSLEEP); - if (!ocft) { - return (CS_OUT_OF_RESOURCE); - } - bzero((caddr_t)ocft, sizeof (pcata_cftable_t)); - - if (!*cftable) { - *cftable = ocft; - cft = ocft; - cft->prev = NULL; - } else { - cft->next = ocft; - cft->next->prev = cft; - cft = cft->next; - } - - cft->next = NULL; - - bzero((caddr_t)&cistpl_cftable_entry, - sizeof (struct cistpl_cftable_entry_t)); - - /* - * We shouldn't ever fail parsing this tuple. If we do, - * there's probably an internal error in the CIS parser. - */ - if ((ret = csx_Parse_CISTPL_CFTABLE_ENTRY( - softp->client_handle, &tuple, - &cistpl_cftable_entry)) != CS_SUCCESS) { - return (ret); - - } else { - int default_cftable; - - /* - * See if this tuple has default values that we - * should save. If so, copy the default values - * that we've seen so far into the current cftable - * structure. - */ - if (cistpl_cftable_entry.flags & - CISTPL_CFTABLE_TPCE_DEFAULT) { - default_cftable = 1; - } else { - default_cftable = 0; - } - - bcopy((caddr_t)&dcft->p, (caddr_t)&cft->p, - sizeof (pcata_cftable_params_t)); - - cft->p.config_index = cistpl_cftable_entry.index; - - - if (cistpl_cftable_entry.flags & - CISTPL_CFTABLE_TPCE_IF) { - cft->p.pin = cistpl_cftable_entry.pin; - if (default_cftable) - dcft->p.pin = cistpl_cftable_entry.pin; - } - - - if (cistpl_cftable_entry.flags & - CISTPL_CFTABLE_TPCE_FS_PWR) { - struct cistpl_cftable_entry_pd_t *pd; - - pd = &cistpl_cftable_entry.pd; - - if (pd->flags & - CISTPL_CFTABLE_TPCE_FS_PWR_VCC) { - if (pd->pd_vcc.nomV_flags & - CISTPL_CFTABLE_PD_EXISTS) { - cft->p.ata_vcc = - pd->pd_vcc.nomV; - if (default_cftable) - dcft->p.ata_vcc = - pd->pd_vcc.nomV; - } /* CISTPL_CFTABLE_PD_EXISTS */ - } /* CISTPL_CFTABLE_TPCE_FS_PWR_VCC */ - - if (pd->flags & - CISTPL_CFTABLE_TPCE_FS_PWR_VPP1) { - if (pd->pd_vpp1.nomV_flags & - CISTPL_CFTABLE_PD_EXISTS) { - cft->p.ata_vpp1 = - pd->pd_vpp1.nomV; - if (default_cftable) - dcft->p.ata_vpp1 = - pd->pd_vpp1.nomV; - } /* CISTPL_CFTABLE_PD_EXISTS */ - } /* CISTPL_CFTABLE_TPCE_FS_PWR_VPP1 */ - - if (pd->flags & - CISTPL_CFTABLE_TPCE_FS_PWR_VPP2) { - if (pd->pd_vpp2.nomV_flags & - CISTPL_CFTABLE_PD_EXISTS) { - cft->p.ata_vpp2 = - pd->pd_vpp2.nomV; - if (default_cftable) - dcft->p.ata_vpp2 = - pd->pd_vpp2.nomV; - } /* CISTPL_CFTABLE_PD_EXISTS */ - } /* CISTPL_CFTABLE_TPCE_FS_PWR_VPP2 */ - - } /* CISTPL_CFTABLE_TPCE_FS_PWR */ - - if (cistpl_cftable_entry.flags & - CISTPL_CFTABLE_TPCE_FS_IO) { - softp->flags |= PCATA_VALID_IO_INFO; - cft->p.addr_lines = io->addr_lines; - if (default_cftable) - dcft->p.addr_lines = io->addr_lines; - - if (io->ranges) { - - cft->p.ranges = io->ranges; -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) - cmn_err(CE_CONT, - "CS says ranges present: %d\n", - io->ranges); -#endif - - cft->p.ata_base[0] = - (uint32_t)io->range[0].addr; - cft->p.ata_length[0] = - (uint32_t)io->range[0].length; - - if (io->ranges == 2) { - cft->p.ata_base[1] = - (uint32_t)io->range[1].addr; - cft->p.ata_length[1] = - (uint32_t)io->range[1]. - length; - } - if (default_cftable) { - dcft->p.ata_base[0] = - (uint32_t)io->range[0].addr; - dcft->p.ata_length[0] = - (uint32_t)io->range[0].length; - if (io->ranges == 2) { - dcft->p.ata_base[1] = - (uint32_t) - io->range[1].addr; - dcft->p.ata_length[1] = - (uint32_t) - io->range[1].length; - } - } -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) { - cmn_err(CE_CONT, - "CS 1st io range: 0x%x+%d\n", - (uint32_t)io->range[0].addr, - (uint32_t)io->range[0].length); - cmn_err(CE_CONT, - "CS 2nd io range: 0x%x+%d\n", - (uint32_t)io->range[1].addr, - (uint32_t)io->range[1].length); - } -#endif - } else { - /* - * If there's no IO ranges for this - * configuration, then we need to calculate - * the length of the IO space by using the - * number of IO address lines value. - * Or we can set the base to zero and the - * length to 0xf. - */ - - if (!(cistpl_cftable_entry.io.flags & - CISTPL_CFTABLE_TPCE_FS_IO_RANGE)) { - cft->p.ata_length[0] = - (1 << cft->p.addr_lines); - } /* CISTPL_CFTABLE_TPCE_FS_IO_RANGE */ - } /* io->ranges */ - } /* CISTPL_CFTABLE_TPCE_FS_IO */ - - } /* csx_Parse_CISTPL_CFTABLE_ENTRY */ - } while ((cistpl_cftable_entry.index != last_config_index) && - ((ret = csx_GetNextTuple(softp->client_handle, - &tuple)) == CS_SUCCESS)); - -#ifdef ATA_DEBUG -if (pcata_debug) { - pcata_cftable_t *cft; - - cmn_err(CE_CONT, "====== socket %d unsorted cftable ======\n", - (int)softp->sn); - for (cft = *cftable; cft; cft = cft->next) { - cmn_err(CE_CONT, - "\n====== cftable entry ======\n" - "desireability: 0x%x\n" - " config_index: 0x%x\n" - " addr_lines: 0x%x\n" - " length[0]: 0x%x\n" - " length[1]: 0x%x\n" - " pin: 0x%x\n", - (int)cft->desireability, (int)cft->p.config_index, - (int)cft->p.addr_lines, cft->p.ata_length[0], - cft->p.ata_length[1], (int)cft->p.pin); - - cmn_err(CE_CONT, - "\n ata_vcc: %d\n" - " ata_vpp1: %d\n" - " ata_vpp2: %d\n" - " ata_base[0]: 0x%p\n" - " ata_base[1]: 0x%p\n" - "====\n", - (int)cft->p.ata_vcc, (int)cft->p.ata_vpp1, - (int)cft->p.ata_vpp2, - (void *)(uintptr_t)cft->p.ata_base[0], - (void *)(uintptr_t)cft->p.ata_base[1]); - } - -} -#endif - - /* - * If GetNextTuple gave us any error code other than - * CS_NO_MORE_ITEMS, it means that there is probably - * an internal error in the CIS parser. - */ - if ((ret != CS_SUCCESS) && (ret != CS_NO_MORE_ITEMS)) { - - return (ret); /* this is a real error */ - - } - /* - * CISTPL_FUNCID and CISTPL_FUNCE processing - */ - tuple.Attributes = 0; - tuple.DesiredTuple = CISTPL_FUNCID; - if ((ret = csx_GetFirstTuple(softp->client_handle, - &tuple)) != CS_SUCCESS) { - /* - * It's OK not to find the tuple if it's not in the CIS, but - * this test will catch other errors. - */ - if (ret != CS_NO_MORE_ITEMS) { - return (ret); - } - } else { - - do { - cistpl_funcid_t cistpl_funcid; - cistpl_funce_t cistpl_funce; - - bzero((caddr_t)&cistpl_funcid, - sizeof (struct cistpl_funcid_t)); - - if ((ret = csx_Parse_CISTPL_FUNCID( - softp->client_handle, - &tuple, &cistpl_funcid)) != CS_SUCCESS) { - return (ret); - } - - - tuple.DesiredTuple = CISTPL_FUNCE; - while ((ret = csx_GetNextTuple(softp->client_handle, - &tuple)) == CS_SUCCESS) { - bzero((caddr_t)&cistpl_funce, - sizeof (cistpl_funce_t)); - - /* - * Function extention parsing needs to be added - * for pcata in cardservices. Function - * extention is required by spec but not used - * in the code. - */ - - if ((ret = csx_Parse_CISTPL_FUNCE( - softp->client_handle, - &tuple, &cistpl_funce, - cistpl_funcid.function)) == - CS_SUCCESS) { - cmn_err(CE_WARN, "have funce!!!!!\n"); - - } - } - tuple.DesiredTuple = CISTPL_FUNCID; - } while ((ret = csx_GetNextTuple(softp->client_handle, - &tuple)) == CS_SUCCESS); - } /* GetFirstTuple */ - - /* - * CISTPL_MANFID processing. The information from this tuple is - * used to augment the information we get from the - * CISTPL_FUNCID and CISTPL_FUNCE tuples. - */ - tuple.Attributes = 0; - tuple.DesiredTuple = CISTPL_MANFID; - if ((ret = csx_GetFirstTuple(softp->client_handle, - &tuple)) != CS_SUCCESS) { - /* - * It's OK not to find the tuple if it's not in the CIS, but - * this test will catch other errors. - */ - if (ret != CS_NO_MORE_ITEMS) { - cmn_err(CE_CONT, " %x \n", ret); - return (ret); - } - } else { - if ((ret = csx_Parse_CISTPL_MANFID(softp->client_handle, - &tuple, &cistpl_manfid)) != CS_SUCCESS) { - return (ret); - } else { - cis_vars->manufacturer_id = cistpl_manfid.manf; - cis_vars->card_id = cistpl_manfid.card; - } /* csx_Parse_CISTPL_MANFID */ - - - - } /* GetFirstTuple */ - - return (CS_SUCCESS); -} - - -void -pcata_destroy_cftable_list(pcata_cftable_t **cftable) -{ - pcata_cftable_t *cft, *ocft = NULL; - - cft = *cftable; - - while (cft) { - ocft = cft; - cft = cft->next; - } - - while (ocft) { - cft = ocft->prev; - kmem_free(ocft, sizeof (pcata_cftable_t)); - ocft = cft; - } - - *cftable = NULL; -} - - - -char * -pcata_CS_etext(int ret) -{ - static error2text_t cft; - - cft.item = ret; - (void) csx_Error2Text(&cft); - - return (cft.text); -} - - -/* - * pcata_getinfo() - this routine translates the dip info dev_t and - * vice versa. - * - * Returns: DDI_SUCCESS, if successful. - * DDI_FAILURE, if unsuccessful. - */ -/* ARGSUSED */ -int -pcata_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result) -{ - ata_soft_t *softp; - int ret; - cs_ddi_info_t cs_ddi_info; - - switch (cmd) { - case DDI_INFO_DEVT2DEVINFO: - case DDI_INFO_DEVT2INSTANCE: - - cs_ddi_info.Socket = PCATA_SOCKET((dev_t)arg); - cs_ddi_info.driver_name = pcata_name; - ret = csx_CS_DDI_Info(&cs_ddi_info); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_getinfo: " - "socket %d CS_DD_Info failed %s (0x%x)\n", - cs_ddi_info.Socket, - pcata_CS_etext(ret), - ret); -#endif - return (DDI_FAILURE); - } - - switch (cmd) { - case DDI_INFO_DEVT2DEVINFO: - softp = ddi_get_soft_state(pcata_soft, - cs_ddi_info.instance); - *result = NULL; - if (softp) { - *result = softp->dip; - } - break; - case DDI_INFO_DEVT2INSTANCE: - *result = (void *)(uintptr_t)cs_ddi_info.instance; - break; - } /* switch */ - break; - default: - return (DDI_FAILURE); - } - return (DDI_SUCCESS); -} - -static int -pcata_initchild(ata_soft_t *softp, int targ) -{ - ata_unit_t *unitp; - - ASSERT(mutex_owned(&softp->ata_mutex)); - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_initchild(%p, %d)\n", - (void *)softp, targ); - } -#endif - - if (softp->ab_rpbp[targ] == NULL) - return (DDI_NOT_WELL_FORMED); - - unitp = (ata_unit_t *)kmem_zalloc(sizeof (*unitp), KM_NOSLEEP); - if (!unitp) { - return (DDI_NOT_WELL_FORMED); - } - - unitp->a_blkp = softp; - unitp->a_forw = softp->ab_link; - softp->ab_link = unitp; - - unitp->au_targ = (char)targ; - unitp->au_drive_bits = (targ == 0 ? ATDH_DRIVE0 : ATDH_DRIVE1); - unitp->au_rpbuf = softp->ab_rpbp[targ]; - unitp->au_acyl = 2; - unitp->au_cyl = unitp->au_rpbuf->atarp_fixcyls + - unitp->au_rpbuf->atarp_remcyls - - unitp->au_acyl; - unitp->au_hd = unitp->au_rpbuf->atarp_heads; - unitp->au_sec = unitp->au_rpbuf->atarp_sectors; - unitp->au_ctl_bits = AT_DEVCTL_D3; - unitp->au_block_factor = softp->ab_block_factor[targ]; - unitp->au_rd_cmd = softp->ab_rd_cmd[targ]; - unitp->au_wr_cmd = softp->ab_wr_cmd[targ]; - - unitp->au_bytes_per_block = unitp->au_block_factor << SCTRSHFT; - -#ifdef ATA_DEBUG - if (pcata_debug & DINIT) - cmn_err(CE_CONT, "_initchild: " - "targ = %d cyl = %d acyl = %d head = %d sec = %d\n", - targ, - unitp->au_cyl, - unitp->au_acyl, - unitp->au_hd, - unitp->au_sec); -#endif - - return (DDI_SUCCESS); -} - -static int -pcata_drive_setup(ata_soft_t *softp) -{ - major_t devmajor; - int ret; - - devmajor = ddi_name_to_major(pcata_name); - -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) { - cmn_err(CE_CONT, "_drive_setup(%p)\n", (void *)softp); - } -#endif - - if (!(CARD_PRESENT_VALID(softp))) { - goto err; - } - - /* setup card */ - softp->ab_block_factor[0] = 1; - softp->ab_block_factor[1] = 1; - softp->ab_max_transfer = 0x100; - softp->ab_status_flag = 0; - - /* - * port addresses - */ - softp->ab_data = AT_DATA; - softp->ab_error = AT_ERROR; - softp->ab_feature = AT_FEATURE; - softp->ab_count = AT_COUNT; - softp->ab_sect = AT_SECT; - softp->ab_lcyl = AT_LCYL; - softp->ab_hcyl = AT_HCYL; - softp->ab_drvhd = AT_DRVHD; - softp->ab_status = AT_STATUS; - softp->ab_cmd = AT_CMD; - - softp->ab_altstatus = AT_ALTSTATUS; - softp->ab_devctl = AT_DEVCTL; - softp->ab_drvaddr = AT_DRVADDR; - - /* - * Future work second arg should not be hard coded (# of drives per - * socket). - * Right now in PCMCIA we have one disk per target, - * if and when we have disks that have multiple targets - * in the same socket (unlikely) then we will have multiple - * disks per socket. - */ - - if (pcata_getedt(softp, 1) == DDI_FAILURE) { - goto err; - } - - softp->ab_block_factor[0] = (-1); - if (pcata_set_rw_multiple(softp, 0)) { - goto err; - } - - mutex_enter(&softp->ata_mutex); - ret = pcata_initchild(softp, 0); - mutex_exit(&softp->ata_mutex); - if (ret != DDI_SUCCESS) - goto err; - - if (pcata_spinup(softp, 0) != DDI_SUCCESS) { - goto err; - } - - if (!(softp->ab_link)) { - goto err; - } - /* - * Initialise the Partition table so that pcata_strategy can - * successfully read the actual vtoc information. - */ - pcinit_pmap(softp->ab_link); - - if (pcata_update_vtoc(softp, makedevice(devmajor, - PCATA_SETMINOR(softp->sn, FDISK_OFFSET)))) { - goto err; - } - - mutex_enter(&softp->event_hilock); - softp->flags |= PCATA_READY; - cv_broadcast(&softp->readywait_cv); - mutex_exit(&softp->event_hilock); - return (DDI_SUCCESS); -err: - mutex_enter(&softp->event_hilock); - cv_broadcast(&softp->readywait_cv); - mutex_exit(&softp->event_hilock); - return (DDI_FAILURE); -} - -/* probably want to replace this with struct devnode_desc */ - -static struct driver_minor_data { - char *name; - int minor; - int type; -} id_minor_data[] = { - { "a", 0, S_IFBLK}, - { "b", 1, S_IFBLK}, - { "c", 2, S_IFBLK}, - { "d", 3, S_IFBLK}, - { "e", 4, S_IFBLK}, - { "f", 5, S_IFBLK}, - { "g", 6, S_IFBLK}, - { "h", 7, S_IFBLK}, - { "i", 8, S_IFBLK}, - { "j", 9, S_IFBLK}, - { "k", 10, S_IFBLK}, - { "l", 11, S_IFBLK}, - { "m", 12, S_IFBLK}, - { "n", 13, S_IFBLK}, - { "o", 14, S_IFBLK}, - { "p", 15, S_IFBLK}, - { "q", 16, S_IFBLK}, - { "r", 17, S_IFBLK}, - { "s", 18, S_IFBLK}, - { "t", 19, S_IFBLK}, - { "u", 20, S_IFBLK}, - - { "a,raw", 0, S_IFCHR}, - { "b,raw", 1, S_IFCHR}, - { "c,raw", 2, S_IFCHR}, - { "d,raw", 3, S_IFCHR}, - { "e,raw", 4, S_IFCHR}, - { "f,raw", 5, S_IFCHR}, - { "g,raw", 6, S_IFCHR}, - { "h,raw", 7, S_IFCHR}, - { "i,raw", 8, S_IFCHR}, - { "j,raw", 9, S_IFCHR}, - { "k,raw", 10, S_IFCHR}, - { "l,raw", 11, S_IFCHR}, - { "m,raw", 12, S_IFCHR}, - { "n,raw", 13, S_IFCHR}, - { "o,raw", 14, S_IFCHR}, - { "p,raw", 15, S_IFCHR}, - { "q,raw", 16, S_IFCHR}, - { "r,raw", 17, S_IFCHR}, - { "s,raw", 18, S_IFCHR}, - { "t,raw", 19, S_IFCHR}, - { "u,raw", 20, S_IFCHR}, -}; - - -/* - * create the device nodes - */ -static int -pcata_create_device_node(ata_soft_t *softp) -{ - struct driver_minor_data *dmdp; - devnode_desc_t *dnd; - make_device_node_t make_device_node; - int ret; - - make_device_node.Action = CREATE_DEVICE_NODE; - - - make_device_node.NumDevNodes = - sizeof (id_minor_data)/sizeof (*id_minor_data); - - make_device_node.devnode_desc = - kmem_zalloc(sizeof (devnode_desc_t) * - make_device_node.NumDevNodes, KM_SLEEP); - - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "_create_device_nodes socket=%d\n", - softp->sn); - } -#endif - - for (dnd = make_device_node.devnode_desc, dmdp = id_minor_data; - dmdp < (id_minor_data + - sizeof (id_minor_data) / sizeof (id_minor_data[0])); - dmdp++, dnd++) { - dnd->name = dmdp->name; - - /* - * Later on need to incorporate the target number - * Right now in PCMCIA we have one disk per target, - * if and when we have disks that have multiple targets - * in the same socket (unlikely) then we will have multiple - * disks per socket. - */ - - dnd->minor_num = PCATA_SETMINOR(softp->sn, dmdp->minor); - -#ifdef ATA_DEBUG - if (pcata_debug & DMKDEV) { - cmn_err(CE_CONT, - "_create_device_node: " - "socket %d minor = %d minor_num = %d\n", - softp->sn, dmdp->minor, dnd->minor_num); - } -#endif - dnd->node_type = DDI_NT_BLOCK; - dnd->spec_type = dmdp->type; - } - - - ret = csx_MakeDeviceNode(softp->client_handle, &make_device_node); - if (ret != CS_SUCCESS) { - cmn_err(CE_CONT, "_create_device_node " - "socket %d MakeDeviceNode failed %s (0x%x)\n", - softp->sn, pcata_CS_etext(ret), ret); - } - - /* - * We don't need this structure anymore since we've - * created the devices. If we need to keep - * track of the devices that we've created - * for some reason, then you' want to keep - * this structure and the make_device_node_t - * structure around in a global data area. - */ - kmem_free(make_device_node.devnode_desc, - sizeof (devnode_desc_t) * make_device_node.NumDevNodes); - - make_device_node.devnode_desc = NULL; - return (ret); -} diff --git a/usr/src/uts/common/io/pcmcia/pcdisk.c b/usr/src/uts/common/io/pcmcia/pcdisk.c deleted file mode 100644 index 8f38f17ae2..0000000000 --- a/usr/src/uts/common/io/pcmcia/pcdisk.c +++ /dev/null @@ -1,1206 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/dditypes.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> - -#include <sys/errno.h> -#include <sys/debug.h> -#include <sys/open.h> -#include <sys/file.h> -#include <sys/cmn_err.h> -#include <sys/varargs.h> -#include <sys/fs/pc_label.h> - -#include <sys/hdio.h> -#include <sys/dkio.h> -#include <sys/dktp/dadkio.h> - -#include <sys/dklabel.h> - -#include <sys/vtoc.h> - - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/dditypes.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/dktp/cm.h> - -#include <sys/dktp/fdisk.h> - -#include <sys/pccard.h> -#include <sys/pcmcia/pcata.h> - -#define MIN_SEC_SIZE 512 - -static int pcata_redo_vtoc(ata_soft_t *softp, buf_t *fdiskbp); -static buf_t *pcata_lblk_alloc(dev_t dev); - -/* Check media insertion/ejection status */ -static int pcata_check_media(ata_soft_t *rs, enum dkio_state state); - -/* - * Queue a request and call start routine. - * - * If the request is not a special buffer request, - * do validation on it and generate both an absolute - * block number (which we will leave in b_resid), - * and a actual block count value (which we will - * leave in av_back). - */ - -int -pcata_strategy(buf_t *bp) -{ - ata_soft_t *softp; - ata_unit_t *unitp; - void *instance; - daddr_t blkno; - int part; - int ret; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, "_strategy\n"); -#endif - bp->b_resid = bp->b_bcount; - - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *)bp->b_edev, - &instance) != DDI_SUCCESS) { - cmn_err(CE_CONT, "_strategy: pcata_getinfo ENODEV\n"); - bioerror(bp, ENODEV); - biodone(bp); - return (0); - } - - if (!(softp = ddi_get_soft_state(pcata_soft, - (int)(uintptr_t)instance))) { - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - - if (!(CARD_PRESENT_VALID(softp))) { -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, "_strategy card_state = %d bp=%p\n", - softp->card_state, - (void *)bp); -#endif - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - - if (bp->b_bcount & (NBPSCTR-1)) { - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "_strategy: bp->b_private = %p\n", - (void *)bp->b_private); - cmn_err(CE_CONT, "_strategy %s request for buf: %p\n", - bp->b_flags & B_READ ? "read" : "write", (void *)bp); - } -#endif - - mutex_enter(&softp->ata_mutex); - - /* - * pointer to structure for physical drive - */ - /* - * XXX/lcl since we don't traverse a_forw with some bits from minor - * (aka the UNIT macro) this means only 1 physical disk - * this error occurs everywhere ab_link is used! - */ - unitp = softp->ab_link; - if (!unitp) { - mutex_exit(&softp->ata_mutex); - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - - /* - * A normal read/write command. - * - * If the transfer size would take it past the end of the - * partition, trim it down. Also trim it down to a multiple - * of the block size. - */ - bp->b_flags &= ~(B_DONE|B_ERROR); - bp->av_forw = NULL; - blkno = bp->b_blkno; - part = LPART(bp->b_edev); - - - /* - * Map block number within partition to absolute - * block number. - */ -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, "_strategy " - "%c%d: %s block %ld mapped to %ld dev %lx\n", - (part > 15 ? 'p' : 's'), - (part > 15 ? part - 16 : part), - bp->b_flags & B_READ ? "read" : "write", - blkno, - blkno + unitp->lbl.pmap[part].p_start, - bp->b_edev); -#endif - - /* make sure this partition exists */ - if (unitp->lbl.pmap[part].p_size == 0) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_strategy:invalid slice part=%d\n", part); -#endif - mutex_exit(&softp->ata_mutex); - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - - /* make sure the I/O begins at a block within the partition */ - if (blkno < 0 || blkno >= unitp->lbl.pmap[part].p_size) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_strategy:block number out of range\n"); -#endif - mutex_exit(&softp->ata_mutex); - bioerror(bp, ENXIO); - biodone(bp); - return (0); - } - - /* XXX/lcl check to make sure I/O doesn't go past end of partition */ - - /* put block number into b_resid and number of blocks into av_back */ - bp->b_resid = bp->b_bcount; - bp->av_back = (buf_t *)(ROUNDUP(bp->b_bcount, NBPSCTR) >> SCTRSHFT); - - blkno += unitp->lbl.pmap[part].p_start; - - ret = pcata_start(unitp, bp, blkno); - mutex_exit(&softp->ata_mutex); - - if (ret != CTL_SEND_SUCCESS) { - bp->b_resid = bp->b_bcount; -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_strategy: ata_start failed bp 0x%p\n", - (void *)bp); -#endif - bioerror(bp, EIO); - biodone(bp); - return (0); - } - - /* - * If the disk block to be written to is disk block 0, it would - * mean the partition table is changing from underneath us - * we shoud trap and update the in memory image. - * By now the buffer is mapped in and we should be able to - * use the contents as the new fdisk partition. - */ - if ((bp->b_flags & B_WRITE) && ((bp->b_flags & B_ERROR) != B_ERROR) && - blkno == 0) { - if (pcata_redo_vtoc(softp, bp)) { - bioerror(bp, EFAULT); - biodone(bp); - return (0); - } - } - - return (0); -} - -/* - * This routine implements the ioctl calls for the ATA - */ -#define COPYOUT(a, b, c, f) \ - ddi_copyout((caddr_t)(a), (caddr_t)(b), sizeof (c), f) -#define COPYIN(a, b, c, f) \ - ddi_copyin((caddr_t)(a), (caddr_t)(b), sizeof (c), f) - -/* ARGSUSED3 */ -int -pcata_ioctl( - dev_t dev, - int cmd, - intptr_t arg, - int flag, - cred_t *cred_p, - int *rval_p) -{ - uint32_t data[512 / (sizeof (uint32_t))]; - void *instance; - ata_soft_t *softp; - ata_unit_t *unitp; - struct dk_cinfo *info; - int i, status; - int err; - enum dkio_state state; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) cmn_err(CE_CONT, "_ioctl\n"); -#endif - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *)dev, - &instance) != DDI_SUCCESS) - return (ENODEV); - - if (!(softp = ddi_get_soft_state(pcata_soft, - (int)(uintptr_t)instance))) { - return (ENXIO); - } - - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - char *cmdname; - - switch (cmd) { - case DKIOCINFO: cmdname = "DKIOCINFO "; break; - case DKIOCREMOVABLE: cmdname = "DKIOCREMOVABLE "; break; - case DKIOCGMEDIAINFO: cmdname = "DKIOCGMEDIAINFO "; break; - case DKIOCGGEOM: cmdname = "DKIOCGGEOM "; break; - case DKIOCGAPART: cmdname = "DKIOCGAPART "; break; - case DKIOCSAPART: cmdname = "DKIOCSAPART "; break; - case DKIOCGVTOC: cmdname = "DKIOCGVTOC "; break; - case DKIOCSVTOC: cmdname = "DKIOCSVTOC "; break; - case DKIOCG_VIRTGEOM: cmdname = "DKIOCG_VIRTGEOM "; break; - case DKIOCG_PHYGEOM: cmdname = "DKIOCG_PHYGEOM "; break; - case DKIOCEJECT: cmdname = "DKIOCEJECT *"; break; - case DKIOCSGEOM: cmdname = "DKIOCSGEOM *"; break; - case DKIOCSTATE: cmdname = "DKIOCSTATE *"; break; - case DKIOCADDBAD: cmdname = "DKIOCADDBAD *"; break; - case DKIOCGETDEF: cmdname = "DKIOCGETDEF *"; break; - case DKIOCPARTINFO: cmdname = "DKIOCPARTINFO *"; break; - case DIOCTL_RWCMD: cmdname = "DIOCTL_RWCMD "; break; - default: cmdname = "UNKNOWN *"; break; - } - cmn_err(CE_CONT, - "_ioctl%d: cmd %x(%s) arg %p softp %p\n", - (int)(uintptr_t)instance, cmd, cmdname, (void *)arg, - (void *)softp); - } -#endif - - /* - * We should process DKIOCSTATE cmd even if CARD is not PRESENT. - * The DKIOCSTATE command should BLOCK if there is no change in state. - * Only when softp->state != state the control returns to the caller. - * This check is done in pcata_check_media(). - * There are 3 states for the device. - * DKIO_NONE - * DKIO_INSERTED - * DKIO_EJECTED - * The state transitions are as follows - * DKIO_NONE-DKIO_INSERTED-DKIO_EJECTED-DKIO_NONE-DKIO_INSERTED... - */ - if (cmd == DKIOCSTATE) { - if (ddi_copyin((caddr_t)arg, (caddr_t)&state, - sizeof (state), flag)) { - return (EFAULT); - } - - /* - * This function is used by the volume management - * to check the pcata card state - */ - if (err = pcata_check_media(softp, state)) { - return (err); - } - - if (ddi_copyout((caddr_t)&softp->media_state, - (caddr_t)arg, sizeof (softp->media_state), flag)) { - return (EFAULT); - } - return (0); - } - - if (!(CARD_PRESENT_VALID(softp))) { - return (ENODEV); - } - - - /* - * we can respond to get geom ioctl() only while the driver has - * not completed initialization. - */ - if ((softp->flags & PCATA_READY) == 0 && cmd != DKIOCG_PHYGEOM) { - (void) pcata_readywait(softp); - if (!(softp->flags & PCATA_READY)) - return (EFAULT); - } - - ASSERT(softp->ab_link); - unitp = softp->ab_link; - bzero((caddr_t)data, sizeof (data)); - - switch (cmd) { - case DKIOCGGEOM: - case DKIOCSGEOM: - case DKIOCGAPART: - case DKIOCSAPART: - case DKIOCGVTOC: - case DKIOCSVTOC: - status = 0; - mutex_enter(&softp->label_mutex); - status = pcata_lbl_ioctl(dev, cmd, arg, flag); - mutex_exit(&softp->label_mutex); - return (status); - } - - switch (cmd) { - - case DKIOCINFO: - - info = (struct dk_cinfo *)data; - /* - * Controller Information - */ - info->dki_ctype = DKC_PCMCIA_ATA; - info->dki_cnum = ddi_get_instance(softp->dip); - (void) strcpy(info->dki_cname, - ddi_get_name(ddi_get_parent(softp->dip))); - - /* - * Unit Information - */ - info->dki_unit = ddi_get_instance(softp->dip); - info->dki_slave = 0; - (void) strcpy(info->dki_dname, "card"); - info->dki_flags = DKI_FMTVOL; - info->dki_partition = LPART(dev); - info->dki_maxtransfer = softp->ab_max_transfer; - - /* - * We can't get from here to there yet - */ - info->dki_addr = 0; - info->dki_space = 0; - info->dki_prio = 0; - info->dki_vec = 0; - - if (COPYOUT(data, arg, struct dk_cinfo, flag)) - return (EFAULT); - break; - - case DKIOCG_VIRTGEOM: - case DKIOCG_PHYGEOM: - - { - struct dk_geom dkg; - status = 0; - - bzero((caddr_t)&dkg, sizeof (struct dk_geom)); - mutex_enter(&softp->ata_mutex); - unitp = softp->ab_link; - if (unitp != 0) { - dkg.dkg_ncyl = unitp->au_cyl; - dkg.dkg_acyl = unitp->au_acyl; - dkg.dkg_pcyl = unitp->au_cyl+unitp->au_acyl; - dkg.dkg_nhead = unitp->au_hd; - dkg.dkg_nsect = unitp->au_sec; - } else - status = EFAULT; - mutex_exit(&softp->ata_mutex); - if (status) - return (EFAULT); - - if (ddi_copyout((caddr_t)&dkg, (caddr_t)arg, - sizeof (struct dk_geom), flag)) - return (EFAULT); - else - return (0); - } - - case DKIOCGMEDIAINFO: - - { - struct dk_minfo media_info; - int secsize; - - media_info.dki_media_type = DK_FIXED_DISK; - /* - * atarp_secsize contains the unformatted sector size. - * Using this we determine the actual sector size. - * sector sizes are a multiple of MIN_SEC_SIZE(512). - */ - secsize = softp->ab_rpbp[0]->atarp_secsiz; - secsize = (((secsize)/MIN_SEC_SIZE) * MIN_SEC_SIZE); - media_info.dki_lbsize = secsize; - media_info.dki_capacity = unitp->au_cyl * unitp->au_hd * - unitp->au_sec; - if (ddi_copyout((caddr_t)&media_info, (caddr_t)arg, - sizeof (struct dk_minfo), flag)) - return (EFAULT); - else - return (0); - } - - case DKIOCREMOVABLE: - - { - /* - * Supporting volmgt by returning a constant - * since PCMCIA is a removable media. - * Refer to PSARC/1996/004. - */ - i = 1; - if (ddi_copyout((caddr_t)&i, (caddr_t)arg, sizeof (int), - flag)) { - return (EFAULT); - } - break; - } - - case DIOCTL_RWCMD: - { - int rw; - int status; - struct dadkio_rwcmd rwcmd; - struct buf *bp; - struct iovec aiov; - struct uio auio; - -#if defined(_MULTI_DATAMODEL) - switch (ddi_model_convert_from(flag & FMODELS)) { - - case DDI_MODEL_ILP32: { - struct dadkio_rwcmd32 rwcmd32; - - if (ddi_copyin((caddr_t)arg, (caddr_t)&rwcmd32, - sizeof (struct dadkio_rwcmd32), flag)) { - return (EFAULT); - } - rwcmd.cmd = rwcmd32.cmd; - rwcmd.flags = rwcmd32.flags; - rwcmd.blkaddr = (daddr_t)rwcmd32.blkaddr; - rwcmd.buflen = rwcmd32.buflen; - rwcmd.bufaddr = (caddr_t)(uintptr_t)rwcmd32.bufaddr; - break; - } - - case DDI_MODEL_NONE: - if (ddi_copyin((caddr_t)arg, (caddr_t)&rwcmd, - sizeof (struct dadkio_rwcmd), flag)) { - return (EFAULT); - } - break; - } -#else /* _MULTI_DATAMODEL */ - if (ddi_copyin((caddr_t)arg, (caddr_t)&rwcmd, - sizeof (struct dadkio_rwcmd), flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODEL */ - - switch (rwcmd.cmd) { - case DADKIO_RWCMD_READ: - rw = B_READ; - break; - case DADKIO_RWCMD_WRITE: - rw = B_WRITE; - break; - default: - return (EINVAL); - } - - bp = getrbuf(KM_SLEEP); - bp->b_back = (buf_t *)&rwcmd; /* ioctl packet */ - bp->b_private = (void *)0xBEE; - - bzero((caddr_t)&aiov, sizeof (struct iovec)); - aiov.iov_base = rwcmd.bufaddr; - aiov.iov_len = rwcmd.buflen; - - bzero((caddr_t)&auio, sizeof (struct uio)); - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_resid = rwcmd.buflen; - auio.uio_segflg = flag & FKIOCTL ? UIO_SYSSPACE : UIO_USERSPACE; - - status = physio(pcata_strategy, bp, dev, rw, pcata_min, &auio); - - freerbuf(bp); - - return (status); - } - - case DKIOCEJECT: - /* - * Since we do not have hardware support for ejecting - * a pcata card, we must not support the generic eject - * ioctl (DKIOCEJECT) which is used for eject(1) command - * because it leads the user to expect behavior that is - * not present. - */ - return (ENOSYS); - - case HDKIOCSCMD: - case HDKIOCGDIAG: - break; - default: - return (ENOTTY); - } - return (0); -} - -int -pcata_lbl_ioctl(dev_t dev, int cmd, intptr_t arg, int flag) -{ - uint32_t data[512 / (sizeof (uint32_t))]; - void *instance; - ata_soft_t *softp; - ata_unit_t *unitp; - int i; - struct vtoc vtoc; - - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *)dev, - &instance) != DDI_SUCCESS) - return (ENODEV); - - if (!(softp = ddi_get_soft_state(pcata_soft, - (int)(uintptr_t)instance))) { - return (ENXIO); - } - - if (!(CARD_PRESENT_VALID(softp))) { - return (ENODEV); - } - - ASSERT(softp->ab_link); - bzero((caddr_t)data, sizeof (data)); - unitp = softp->ab_link; - - switch (cmd) { - case DKIOCGGEOM: - case DKIOCGAPART: - case DKIOCGVTOC: - if (pcata_update_vtoc(softp, dev)) - return (EFAULT); - } - - switch (cmd) { - case DKIOCGGEOM: - { - struct dk_geom up; - - pcdsklbl_dgtoug(&up, &unitp->lbl.ondsklbl); - if (COPYOUT(&up, arg, struct dk_geom, flag)) { - return (EFAULT); - } - break; - } - - case DKIOCSGEOM: - i = sizeof (struct dk_geom); - if (ddi_copyin((caddr_t)arg, (caddr_t)data, i, flag)) - return (EFAULT); - pcdsklbl_ugtodg((struct dk_geom *)data, &unitp->lbl.ondsklbl); - break; - - case DKIOCGAPART: - /* - * Return the map for all logical partitions. - */ -#if defined(_MULTI_DATAMODEL) - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: { - struct dk_map32 dk_map32[NDKMAP]; - int i; - - for (i = 0; i < NDKMAP; i++) { - dk_map32[i].dkl_cylno = - unitp->lbl.un_map[i].dkl_cylno; - dk_map32[i].dkl_nblk = - unitp->lbl.un_map[i].dkl_nblk; - } - i = NDKMAP * sizeof (struct dk_map32); - if (ddi_copyout(dk_map32, (caddr_t)arg, i, flag)) - return (EFAULT); - break; - } - - case DDI_MODEL_NONE: - i = NDKMAP * sizeof (struct dk_map); - if (ddi_copyout((caddr_t)unitp->lbl.un_map, - (caddr_t)arg, i, flag)) - return (EFAULT); - break; - } - -#else /* _MULTI_DATAMODEL */ - i = NDKMAP * sizeof (struct dk_map); - if (ddi_copyout((caddr_t)unitp->lbl.un_map, - (caddr_t)arg, i, flag)) - return (EFAULT); -#endif /* _MULTI_DATAMODEL */ - break; - - case DKIOCSAPART: - /* - * Set the map for all logical partitions. - */ -#if defined(_MULTI_DATAMODEL) - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: { - struct dk_map32 dk_map32[NDKMAP]; - int i; - - i = NDKMAP * sizeof (struct dk_map32); - if (ddi_copyin((caddr_t)arg, dk_map32, i, flag)) - return (EFAULT); - for (i = 0; i < NDKMAP; i++) { - unitp->lbl.un_map[i].dkl_cylno = - dk_map32[i].dkl_cylno; - unitp->lbl.un_map[i].dkl_nblk = - dk_map32[i].dkl_nblk; - } - i = NDKMAP * sizeof (struct dk_map32); - break; - } - - case DDI_MODEL_NONE: - i = NDKMAP * sizeof (struct dk_map); - if (ddi_copyout((caddr_t)unitp->lbl.un_map, - (caddr_t)arg, i, flag)) - return (EFAULT); - break; - } - break; -#else /* _MULTI_DATAMODEL */ - i = NDKMAP * sizeof (struct dk_map); - if (ddi_copyin((caddr_t)arg, (caddr_t)data, i, flag)) - return (EFAULT); - bcopy((caddr_t)data, (caddr_t)unitp->lbl.un_map, i); - break; -#endif /* _MULTI_DATAMODEL */ - - case DKIOCGVTOC: -#if defined(_MULTI_DATAMODEL) - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: { - struct vtoc32 vtoc32; - - pcdsklbl_ondsklabel_to_vtoc(&unitp->lbl, &vtoc); - vtoctovtoc32(vtoc, vtoc32); - if (ddi_copyout(&vtoc32, (caddr_t)arg, - sizeof (struct vtoc32), flag)) - return (EFAULT); - break; - } - - case DDI_MODEL_NONE: - pcdsklbl_ondsklabel_to_vtoc(&unitp->lbl, &vtoc); - if (ddi_copyout((caddr_t)&vtoc, (caddr_t)arg, - sizeof (struct vtoc), flag)) - return (EFAULT); - break; - } - return (0); -#else /* _MULTI_DATAMODEL */ - pcdsklbl_ondsklabel_to_vtoc(&unitp->lbl, &vtoc); - if (ddi_copyout((caddr_t)&vtoc, (caddr_t)arg, - sizeof (struct vtoc), flag)) - return (EFAULT); - return (0); -#endif /* _MULTI_DATAMODEL */ - - case DKIOCSVTOC: -#if defined(_MULTI_DATAMODEL) - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: { - struct vtoc32 vtoc32; - - if (ddi_copyin((caddr_t)arg, &vtoc32, - sizeof (struct vtoc32), flag)) - return (EFAULT); - vtoc32tovtoc(vtoc32, vtoc); - - if (pcata_write_dskvtoc(softp, dev, &unitp->lbl, &vtoc)) - return (EFAULT); - break; - } - - case DDI_MODEL_NONE: - if (ddi_copyin((caddr_t)arg, (caddr_t)&vtoc, - sizeof (struct vtoc), flag)) - return (EFAULT); - - if (pcata_write_dskvtoc(softp, dev, &unitp->lbl, &vtoc)) - return (EFAULT); - - break; - } -#else /* _MULTI_DATAMODEL */ - if (ddi_copyin((caddr_t)arg, (caddr_t)&vtoc, - sizeof (struct vtoc), flag)) - return (EFAULT); - - if (pcata_write_dskvtoc(softp, dev, &unitp->lbl, &vtoc)) - return (EFAULT); - - break; -#endif /* _MULTI_DATAMODEL */ - } - return (0); -} - -/* ARGSUSED */ -int -pcata_open(dev_t *dev_p, int flag, int otyp, cred_t *cred_p) -{ - register dev_t dev = *dev_p; - ata_soft_t *softp; - void *instance; - int i; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, "_open: " - "dev_p=%p dev=%x flag=%x otyp=%x cred_p=%p\n", - (void *)dev_p, (int)dev, flag, otyp, (void *)cred_p); -#endif - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *) *dev_p, - &instance) != DDI_SUCCESS) - return (ENODEV); - - softp = ddi_get_soft_state(pcata_soft, (int)(uintptr_t)instance); - - /* - * open and getinfo may be called before attach completes - */ - for (i = 0; i < 300; i++) { - if (softp->flags & PCATA_READY) - break; - drv_usecwait(10000); - } - if (!pcata_readywait(softp)) - return (ENXIO); - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, - "_open: part=%d blk_open=%x chr_open=%x lyr_open=%d\n", - LPART(dev), softp->blk_open, softp->chr_open, - softp->lyr_open[LPART(dev)]); -#endif - - mutex_enter(&(softp)->ata_mutex); - /* - * Only honor FEXCL. If a regular open or a layered open - * is still outstanding on the device, the exclusive open - * must fail. - */ - if (flag & FEXCL) { - if ((softp->chr_open & (1 << LPART(dev))) || - (softp->blk_open & (1 << LPART(dev))) || - (softp->lyr_open[LPART(dev)])) { - mutex_exit(&(softp)->ata_mutex); - return (EAGAIN); - } - } - - switch (otyp) { - case OTYP_BLK: - softp->blk_open |= (1 << LPART(dev)); - break; - case OTYP_CHR: - softp->chr_open |= (1 << LPART(dev)); - break; - case OTYP_LYR: - softp->lyr_open[LPART(dev)]++; - break; - default: - mutex_exit(&(softp)->ata_mutex); - return (EINVAL); - } - - mutex_exit(&(softp)->ata_mutex); - - return (0); -} - - - -/* ARGSUSED */ -int -pcata_close(dev_t dev, int flag, int otyp, cred_t *cred_p) -{ - ata_soft_t *softp; - int i; - int lyr_count = 0; - void *instance; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, "_close: dev=%x flag=%x otyp=%x cred_p=%p\n", - (int)dev, flag, otyp, (void *)cred_p); -#endif - - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *) dev, - &instance) != DDI_SUCCESS) - return (ENODEV); - - softp = ddi_get_soft_state(pcata_soft, (int)(uintptr_t)instance); - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, - "_close: part=%d blk_open=%x chr_open=%x lyr_open=%d\n", - LPART(dev), softp->blk_open, softp->chr_open, - softp->lyr_open[LPART(dev)]); -#endif - - - mutex_enter(&(softp)->ata_mutex); - - switch (otyp) { - case OTYP_BLK: - softp->blk_open &= ~(1 << LPART(dev)); - break; - case OTYP_CHR: - softp->chr_open &= ~(1 << LPART(dev)); - break; - case OTYP_LYR: - softp->lyr_open[LPART(dev)]--; - break; - default: - mutex_exit(&(softp)->ata_mutex); - return (EINVAL); - } - - if ((softp->blk_open) || (softp->chr_open)) { - /* not done yet */ - mutex_exit(&(softp)->ata_mutex); - return (0); - } else { - for (i = 0; i < LPART(dev); i++) { - if (softp->lyr_open[LPART(dev)] != 0) - lyr_count++; - } - - if (lyr_count) { - /* not done yet */ - mutex_exit(&(softp)->ata_mutex); - return (0); - } - } - - if (softp->ejected_while_mounted) - softp->ejected_while_mounted = 0; - - mutex_exit(&(softp)->ata_mutex); - - return (0); -} - -static int -pcata_redo_vtoc(ata_soft_t *softp, buf_t *fdiskbp) -{ - struct dk_geom dkg; - ata_unit_t *unitp; - buf_t *bp; - int status; - dev_t dev; - - - unitp = softp->ab_link; - if (!unitp) - return (EFAULT); - - /* given any maj/min convert to fdisk partition 0 */ - dev = makedevice(getmajor(fdiskbp->b_edev), - PCATA_SETMINOR(softp->sn, FDISK_OFFSET)); - - if ((bp = pcata_lblk_alloc(dev)) == NULL) - return (EFAULT); - - bcopy(fdiskbp->b_un.b_addr, bp->b_un.b_addr, NBPSCTR); - - bzero((caddr_t)&dkg, sizeof (struct dk_geom)); - dkg.dkg_ncyl = unitp->au_cyl; - dkg.dkg_nhead = unitp->au_hd; - dkg.dkg_nsect = unitp->au_sec; - - status = pcfdisk_parse(bp, unitp); - - /* release buffer allocated by getrbuf */ - kmem_free(bp->b_un.b_addr, NBPSCTR); - freerbuf(bp); - - if (status == DDI_FAILURE) - return (EFAULT); - return (0); -} - -/* - * - */ -int -pcata_update_vtoc(ata_soft_t *softp, dev_t dev) -{ - ata_unit_t *unitp; - buf_t *bp; - int status; - - unitp = softp->ab_link; - if (!unitp) - return (EFAULT); - - /* given any maj/min convert to fdisk partition 0 */ - dev = makedevice(getmajor(dev), - PCATA_SETMINOR(softp->sn, FDISK_OFFSET)); - - if ((bp = pcata_lblk_alloc(dev)) == NULL) - return (EFAULT); - - /* - * The dev is passed here for use later by the dsklbl_rdvtoc() - * and pcata_dsklbl_read_label() to check for card present before - * calling biowait. - */ - status = pcfdisk_read(bp, unitp); - - /* release buffer allocated by getrbuf */ - kmem_free(bp->b_un.b_addr, NBPSCTR); - freerbuf(bp); - - if (status == DDI_FAILURE) - return (EFAULT); - return (0); -} - -static buf_t * -pcata_lblk_alloc(dev_t dev) -{ - buf_t *bp; - char *secbuf; - - /* allocate memory to hold disk label */ - secbuf = kmem_zalloc(NBPSCTR, KM_SLEEP); - if (!secbuf) - return (NULL); - - /* allocate a buf_t to manage the disk label block */ - bp = getrbuf(KM_SLEEP); - if (!bp) { - kmem_free(secbuf, NBPSCTR); - return (NULL); - } - - /* initialize the buf_t */ - bp->b_edev = dev; - bp->b_dev = cmpdev(dev); - bp->b_flags |= B_BUSY; - bp->b_resid = 0; - bp->b_bcount = NBPSCTR; - bp->b_un.b_addr = (caddr_t)secbuf; - - return (bp); -} - - -int -pcata_write_dskvtoc(ata_soft_t *softp, dev_t dev, dsk_label_t *lblp, - struct vtoc *vtocp) -{ - buf_t *bp; - int status; - - dev = makedevice(getmajor(dev), - PCATA_SETMINOR(softp->sn, FDISK_OFFSET)); - - if ((bp = pcata_lblk_alloc(dev)) == NULL) - return (EFAULT); - -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_write_dskvtoc: edev = %lx dev = %x\n", - bp->b_edev, - bp->b_dev); -#endif - - - bp->b_edev = dev; /* used by probe_for_card() */ - status = pcdsklbl_wrvtoc(lblp, vtocp, bp); - - /* release buffer allocated by getrbuf */ - kmem_free(bp->b_un.b_addr, NBPSCTR); - freerbuf(bp); - - return (status); -} -/* - * Check media insertion/ejection status - */ -static int -pcata_check_media(ata_soft_t *rs, enum dkio_state state) -{ - int err; - get_status_t get_status; - - - mutex_enter(&rs->ata_mutex); - - /* - * Do a CS call to see if the card is present - */ - if ((err = csx_GetStatus(rs->client_handle, &get_status)) - != CS_SUCCESS) { - error2text_t cft; - - mutex_exit(&rs->ata_mutex); - - cft.item = err; - (void) csx_Error2Text(&cft); - cmn_err(CE_CONT, "pcata_check_media: socket %d " - "GetStatus failed %s (0x%x)\n", - rs->sn, cft.text, err); - return (ENXIO); - } - - /* Register rs->media_state */ - if ((get_status.CardState & CS_EVENT_CARD_INSERTION)) { - rs->media_state = DKIO_INSERTED; - } else { - if (state == DKIO_NONE) { - rs->media_state = DKIO_NONE; - } else { - rs->media_state = DKIO_EJECTED; - } - } - - - /* - * XXXX - In order not to modify the volume management - * we have to follow the current SCSI CDROM model - * for checking media state (broken way, sigh!) - * start with state = DKIO_NONE - * wait until mediastate = DKIO_INSERTED - * wait until mediastate = DKIO_EJECTED - * if DKIOCSTATE ioctl() is called second time - * with state = DKIO_EJECTED, - * return state = DKIO_NONE - * restart with state = DKIO_NONE - * - */ - if (state != DKIO_NONE) { - if (rs->ejected_media_flag && - (rs->media_state == DKIO_EJECTED)) { - rs->media_state = DKIO_NONE; - rs->ejected_media_flag = 0; - mutex_exit(&rs->ata_mutex); - return (0); - } - } - -#ifdef ATA_DEBUG - if (pcata_debug & DVOLD) { - cmn_err(CE_CONT, "pcata_check_media: socket %d \n" - "\tWaiting state change: rs->media_state %d state %d\n" - "\tDKIO_NONE %d DKIO_EJECTED %d DKIO_INSERTED %d\n", - rs->sn, rs->media_state, state, - DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED); - } -#endif - - /* - * wait for Card Detect Change Interrupt handler - * see either pcata_card_insertion/pcata_card_removal - * for cv_broadcast - */ - while (rs->media_state == state) { - rs->checkmedia_flag++; - if (cv_wait_sig(&rs->condvar_mediastate, - &rs->ata_mutex) == 0) { - mutex_exit(&rs->ata_mutex); - return (EINTR); - } - } - -#ifdef ATA_DEBUG - if (pcata_debug & DVOLD) { - cmn_err(CE_CONT, "pcata_check_media: socket %d \n" - "\tAfter state change: rs->media_state %d state %d\n" - "\tDKIO_NONE %d DKIO_EJECTED %d DKIO_INSERTED %d\n", - rs->sn, rs->media_state, state, - DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED); - } -#endif - - if (state != DKIO_NONE) { - if (!rs->ejected_media_flag && - (rs->media_state == DKIO_EJECTED)) { - rs->ejected_media_flag++; - } - } - - mutex_exit(&rs->ata_mutex); - - return (0); -} - -int -pcata_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, - int mod_flags, char *name, caddr_t valuep, int *lengthp) -{ - int instance = ddi_get_instance(dip); - ata_soft_t *softp; - ata_unit_t *unitp; - uint64_t nblocks64; - - /* - * Our dynamic properties are all device specific and size oriented. - * Requests issued under conditions where size is valid are passed - * to ddi_prop_op_nblocks with the size information, otherwise the - * request is passed to ddi_prop_op. - */ - softp = ddi_get_soft_state(pcata_soft, instance); - if ((dev == DDI_DEV_T_ANY) || (softp == NULL) || - !(CARD_PRESENT_VALID(softp)) || - ((unitp = softp->ab_link) == NULL)) { - return (ddi_prop_op(dev, dip, prop_op, mod_flags, - name, valuep, lengthp)); - } else { - /* get nblocks value */ - nblocks64 = (ulong_t)unitp->lbl.pmap[LPART(dev)].p_size; - - return (ddi_prop_op_nblocks(dev, dip, prop_op, mod_flags, - name, valuep, lengthp, nblocks64)); - } -} diff --git a/usr/src/uts/common/io/pcmcia/pcide.c b/usr/src/uts/common/io/pcmcia/pcide.c deleted file mode 100644 index 521a0fb46e..0000000000 --- a/usr/src/uts/common/io/pcmcia/pcide.c +++ /dev/null @@ -1,2125 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - - -/* - * ATA disk driver - * - * Handles the standard PCMCIA ATA interface - * - */ -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/user.h> -#include <sys/buf.h> -#include <sys/ioctl.h> -#include <sys/file.h> -#include <sys/uio.h> -#include <sys/fcntl.h> -#include <sys/cmn_err.h> -#include <sys/kmem.h> -#include <sys/sysmacros.h> -#include <sys/stat.h> -#include <sys/scsi/scsi.h> - -#include <sys/fdio.h> - -#include <sys/errno.h> -#include <sys/open.h> -#include <sys/varargs.h> -#include <sys/fs/pc_label.h> - -#include <sys/hdio.h> -#include <sys/dkio.h> -#include <sys/dktp/dadkio.h> - -#include <sys/dklabel.h> - -#include <sys/vtoc.h> - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/dditypes.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/dktp/cm.h> - -#include <sys/dktp/fdisk.h> - -#include <sys/fs/pc_label.h> - -#include <sys/pctypes.h> - - -/* - * PCMCIA and DDI related header files - */ -#include <sys/pccard.h> - -#include <sys/pcmcia/pcata.h> - -int pcata_debug = 0; - -static int pcata_detach(dev_info_t *devi, ddi_detach_cmd_t cmd); -static int pcata_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); -static int pcata_att1(dev_info_t *dip, ata_soft_t *softp); -static int pcata_go(ata_unit_t *unitp); -static int pcata_wait(uint32_t port, ushort_t onbits, ushort_t offbits, - ata_soft_t *softp); -static int pcata_wait1(uint32_t port, ushort_t onbits, ushort_t offbits, - int interval, ata_soft_t *softp); -static void pcata_wait_complete(ata_soft_t *softp); -static uchar_t pcata_drive_type(ata_soft_t *softp, ushort_t *secbuf); -static int pcata_setpar(int drive, int heads, int sectors, ata_soft_t *softp); -static int pcata_dump(dev_t dev, caddr_t addr, daddr_t blkno, int nblk); -static int pcata_print(dev_t dev, char *str); -static int pcata_rdrw(dev_t dev, struct uio *uio, int flag); -static int pcata_read(dev_t dev, struct uio *uio, cred_t *cred_p); -static int pcata_write(dev_t dev, struct uio *uio, cred_t *cred_p); -#ifdef ATA_DEBUG -static void pcata_print_sttflag(int svalue); -#endif -static void pcata_clear_queues(ata_unit_t *unitp); -static void pcata_nack_packet(struct ata_cmpkt *pktp); -static void pcata_iosetup(ata_unit_t *unitp, struct ata_cmpkt *pktp); -static int pcata_send_data(ata_unit_t *unitp, int count); -static int pcata_get_data(ata_unit_t *unitp, int count); - -struct cb_ops pcata_cb_ops = { - pcata_open, /* driver open routine */ - pcata_close, /* driver close routine */ - pcata_strategy, /* driver strategy routine */ - pcata_print, /* driver print routine */ - pcata_dump, /* driver dump routine */ - pcata_read, /* driver read routine */ - pcata_write, /* driver write routine */ - pcata_ioctl, /* driver ioctl routine */ - nodev, /* driver devmap routine */ - nodev, /* driver mmap routine */ - nodev, /* driver segmap routine */ - nochpoll, /* driver chpoll routine */ - pcata_prop_op, /* driver prop_op routine */ - 0, /* driver cb_str - STREAMS only */ - D_NEW | D_MTSAFE, /* driver compatibility flag */ - }; - -static struct dev_ops ata_ops = { - DEVO_REV, /* devo_rev, */ - 0, /* refcnt */ - pcata_getinfo, /* info */ - nulldev, /* identify */ - nulldev, /* probe */ - pcata_attach, /* attach */ - pcata_detach, /* detach */ - nulldev, /* reset */ - &pcata_cb_ops, /* driver operations */ - NULL, /* bus operations */ - NULL, /* power */ - ddi_quiesce_not_needed, /* quiesce */ - }; - - - -void *pcata_soft = NULL; - - -#include <sys/modctl.h> - -extern struct mod_ops mod_driverops; - -static struct modldrv modldrv = { - &mod_driverops, /* Type of module. This one is a driver */ - "PCMCIA ATA disk controller", - &ata_ops, /* driver ops */ - }; - -static struct modlinkage modlinkage = { - MODREV_1, (void *)&modldrv, NULL - }; - -int -_init(void) -{ - int status; - - status = mod_install(&modlinkage); - if (status) - return (status); - - status = ddi_soft_state_init(&pcata_soft, sizeof (ata_soft_t), 1); - - return (status); -} - - -int -_fini(void) -{ - int status; - - status = mod_remove(&modlinkage); - if (!status) - ddi_soft_state_fini(&pcata_soft); - - return (status); -} - - -int -_info(struct modinfo *modinfop) -{ - return (mod_info(&modlinkage, modinfop)); -} - -static int -pcata_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - int instance = ddi_get_instance(dip); - ata_soft_t *softp; - int ret; - - /* resume from a checkpoint */ - if (cmd == DDI_RESUME) - return (DDI_SUCCESS); - - if (cmd != DDI_ATTACH) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach returning FAILURE\n"); -#endif - return (DDI_FAILURE); - } - - /* Allocate soft state associated with this instance. */ - ret = ddi_soft_state_zalloc(pcata_soft, ddi_get_instance(dip)); - if (ret != DDI_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach: Unable to alloc state\n"); -#endif - return (DDI_FAILURE); - } - - softp = ddi_get_soft_state(pcata_soft, instance); - -#ifdef ATA_DEBUG - if (pcata_debug & DINIT) - cmn_err(CE_CONT, "_attach softp=%p\n", (void *)softp); -#endif - - softp->dip = dip; - softp->instance = instance; - softp->ab_dip = dip; - softp->crashbuf = getrbuf(KM_SLEEP); - softp->flags = 0; - softp->card_state = 0; - softp->intr_pending = 0; - softp->softint_pending = 0; - softp->write_in_progress = 0; - softp->blk_open = 0; - softp->chr_open = 0; - softp->ejected_while_mounted = 0; - bzero(softp->lyr_open, sizeof (softp->lyr_open[NUM_PARTS])); - - /* - * Initialize to 0 until it is incremented in pcram_check_media - */ - softp->checkmedia_flag = 0; - softp->ejected_media_flag = 0; - softp->media_state = DKIO_NONE; - - /* - * if attach fails, Solaris won't call detach - * so we call detach here to release all flagged resources - */ - ret = pcata_att1(dip, softp); - if (ret == DDI_FAILURE) { - (void) pcata_detach(dip, DDI_DETACH); - return (DDI_FAILURE); - } - - return (DDI_SUCCESS); -} - -static int -pcata_att1(dev_info_t *dip, ata_soft_t *softp) -{ - int ret; - client_reg_t client_reg; - sockmask_t sockmask; - map_log_socket_t map_log_socket; - cs_ddi_info_t cs_ddi_info; - get_status_t get_status; - - - /* - * create ata_mutex - */ - ret = ddi_get_soft_iblock_cookie(dip, DDI_SOFTINT_MED, - &softp->soft_blk_cookie); - if (ret != DDI_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach: unable to get iblock cookie\n"); -#endif - return (ret); - } - - - /* - * Setup the mutexii and condition variables. - * Initialize the mutex that protects the ATA registers. - */ - mutex_init(&softp->ata_mutex, NULL, MUTEX_DRIVER, - (void *)(softp->soft_blk_cookie)); - mutex_init(&softp->label_mutex, NULL, MUTEX_DRIVER, NULL); - - cv_init(&softp->readywait_cv, NULL, CV_DRIVER, NULL); - /* for DKIOCSTATE ioctl() */ - cv_init(&softp->condvar_mediastate, NULL, CV_DRIVER, NULL); - softp->flags |= PCATA_DIDLOCKS; - - - /* - * link in soft interrupt - */ - ret = ddi_add_softintr(dip, DDI_SOFTINT_MED, &softp->softint_id, - NULL, NULL, pcata_intr, (caddr_t)softp); - if (ret != DDI_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach: unable to get soft interrupt\n"); -#endif - return (DDI_FAILURE); - } - softp->flags |= PCATA_SOFTINTROK; - - - /* - * Register with Card Services - */ - client_reg.Attributes = - INFO_IO_CLIENT | INFO_CARD_SHARE | INFO_CARD_EXCL; - - client_reg.EventMask = - CS_EVENT_CARD_INSERTION | - CS_EVENT_CARD_REMOVAL | - CS_EVENT_CARD_REMOVAL_LOWP | - CS_EVENT_PM_RESUME | - CS_EVENT_CLIENT_INFO | - CS_EVENT_PM_SUSPEND | - CS_EVENT_REGISTRATION_COMPLETE; - - client_reg.event_handler = (csfunction_t *)pcata_event; - client_reg.event_callback_args.client_data = softp; - client_reg.Version = _VERSION(2, 1); - client_reg.dip = dip; - (void) strcpy(client_reg.driver_name, pcata_name); - - ret = csx_RegisterClient(&softp->client_handle, &client_reg); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach RegisterClient failed %s\n", - pcata_CS_etext(ret)); -#endif - return (DDI_FAILURE); - } - - mutex_init(&softp->event_hilock, NULL, MUTEX_DRIVER, - *(client_reg.iblk_cookie)); - - softp->flags |= PCATA_REGCLIENT; - - - /* - * Get logical socket number and store in softp struct - */ - ret = csx_MapLogSocket(softp->client_handle, &map_log_socket); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach: MapLogSocket failed %s\n", - pcata_CS_etext(ret)); -#endif - return (DDI_FAILURE); - } - softp->sn = map_log_socket.PhySocket; - - - /* - * - */ - cs_ddi_info.Socket = softp->sn; - cs_ddi_info.driver_name = pcata_name; - cs_ddi_info.dip = dip; - cs_ddi_info.instance = softp->instance; - if ((ret = csx_CS_DDI_Info(&cs_ddi_info)) != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach: socket %d CS_DDI_Info failed %s\n", - softp->sn, pcata_CS_etext(ret)); -#endif - return (DDI_FAILURE); - } - - /* - * After the RequestSocketMask call, we start receiving events - */ - sockmask.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL; - ret = csx_RequestSocketMask(softp->client_handle, &sockmask); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_attach: RequestSocketMask failed %s\n", - pcata_CS_etext(ret)); -#endif - return (DDI_FAILURE); - } - softp->flags |= PCATA_REQSOCKMASK; - - /* - * We may not get the CARD_READY event - * until after we leave this function. - */ - mutex_enter(&softp->event_hilock); - softp->card_state |= PCATA_READY_WAIT; - mutex_exit(&softp->event_hilock); - - (void) csx_GetStatus(softp->client_handle, &get_status); - if (get_status.raw_CardState & CS_STATUS_CARD_INSERTED) { - - /* wait for drive to be initialized */ - (void) pcata_readywait(softp); - - if ((softp->card_state & PCATA_CARD_INSERTED) == 0 || - (softp->flags & PCATA_READY) == 0) { - - mutex_enter(&softp->ata_mutex); - mutex_enter(&softp->event_hilock); - - softp->card_state &= ~PCATA_READY_WAIT; - - mutex_exit(&softp->event_hilock); - mutex_exit(&softp->ata_mutex); - } - } - - /* - * Wait for minor node creation before returning - */ - pcata_minor_wait(softp); - - /* - * print banner to announce device - */ - ddi_report_dev(dip); - - return (DDI_SUCCESS); -} - -static int -pcata_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) -{ - int instance = ddi_get_instance(devi); - ata_soft_t *softp; - int ret; - - if (cmd == DDI_SUSPEND) - return (DDI_SUCCESS); - - if (cmd != DDI_DETACH) - return (DDI_FAILURE); - - softp = ddi_get_soft_state(pcata_soft, instance); - - - /* - * Call the card_removal routine to do any final card cleanup - */ - if (CARD_PRESENT_VALID(softp)) { - (void) pcata_card_removal(softp, CS_EVENT_PRI_LOW); - } - - - /* - * Release our socket mask - note that we can't do much - * if we fail these calls other than to note that - * the system will probably panic shortly. Perhaps - * we should fail the detach in the case where these - * CS calls fail? - */ - - if (softp->flags & PCATA_REQSOCKMASK) { - release_socket_mask_t rsm; - ret = csx_ReleaseSocketMask(softp->client_handle, &rsm); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_detach " - "ReleaseSocketMask failed %s\n", - pcata_CS_etext(ret)); -#endif - } - } - - - /* - * Deregister with Card Services - we will stop getting - * events at this point. - */ - if (softp->flags & PCATA_REGCLIENT) { - ret = csx_DeregisterClient(softp->client_handle); - if (ret != CS_SUCCESS) { -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_detach: " - "DeregisterClient failed %s\n", - pcata_CS_etext(ret)); -#endif - return (DDI_FAILURE); - - } - softp->flags &= ~PCATA_REGCLIENT; - } - - - /* unregister the softintrrupt handler */ - if (softp->flags & PCATA_SOFTINTROK) { - ddi_remove_softintr(softp->softint_id); - softp->flags &= ~PCATA_SOFTINTROK; - - } - - if (softp->flags & PCATA_DIDLOCKS) { - - /* - * XXX/lcl make sure no threads are blocked - */ - mutex_destroy(&softp->ata_mutex); - mutex_destroy(&softp->event_hilock); - mutex_destroy(&softp->label_mutex); - cv_destroy(&softp->readywait_cv); - /* for DKIOCSTATE ioctl() */ - cv_destroy(&softp->condvar_mediastate); - softp->flags &= ~PCATA_DIDLOCKS; - } - - /* Free various structures and memory here. */ - if (softp && softp->crashbuf) - freerbuf(softp->crashbuf); - - /* Free the soft state structure here */ - ddi_soft_state_free(pcata_soft, instance); - -#ifdef ATA_DEBUG - if (pcata_debug & DPCM) - cmn_err(CE_NOTE, "successful detach\n"); -#endif - - return (DDI_SUCCESS); -} - - -/* - * Common controller object interface - */ -/* - * initiate a new I/O request - * either start it or add it to the request queue - */ -int -pcata_start(ata_unit_t *unitp, buf_t *bp, int blkno) -{ - ata_soft_t *softp = unitp->a_blkp; - struct ata_cmpkt *pktp; - int ret; - int kf = 0; - - ASSERT(mutex_owned(&softp->ata_mutex)); - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_start unitp=%p, bp=%p bp->b_private=%p\n", - (void *)unitp, - (void *)bp, - bp->b_private); - } -#endif - - if (!CARD_PRESENT_VALID(softp)) - return (CTL_SEND_FAILURE); - - /* XXX/lcl why is this different from CARD_PRESENT_VALID */ - if (softp->ab_status_flag & ATA_OFFLINE) { - return (CTL_SEND_FAILURE); - } - - pktp = (struct ata_cmpkt *)kmem_zalloc(sizeof (*pktp), kf); - if (!pktp) { - cmn_err(CE_NOTE, "_start kmem_zalloc failed\n"); - return (CTL_SEND_FAILURE); - } - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) - cmn_err(CE_CONT, "_start pktp=%p\n", (void *)pktp); -#endif - - if ((bp->b_flags & B_PAGEIO) || (bp->b_flags & B_PHYS)) - bp_mapin(bp); - - pktp->ac_bytes_per_block = unitp->au_bytes_per_block; - pktp->ac_start_v_addr = bp->b_un.b_addr; /* xfer address */ - pktp->cp_bytexfer = bp->b_bcount; - pktp->cp_bp = bp; - pktp->cp_ctl_private = unitp; - pktp->cp_srtsec = blkno; - - if (bp->b_flags & B_READ) { - pktp->ac_direction = AT_IN; - pktp->ac_cdb = DCMD_READ; - } else { - pktp->ac_direction = AT_OUT; - pktp->ac_cdb = DCMD_WRITE; - } - - /* - * b_private is set to 0xBEE by pcata_buf_setup - * which is called by an ioctl DIOCTL_RWCMD with a subcommand - * of either DADKIO_RWCMD_READ or DADKIO_RWCMD_WRITE - * - * these commands are used to do I/O through the IOCTL interface - * - * b_back contains a pointer to the ioctl packet struct (dadkio_rwcmd) - */ - if (bp->b_private == (void *)0xBEE) - pktp->cp_passthru = bp->b_back; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "passthru command seen: 0x%p\n", - pktp->cp_passthru); - } -#endif - - pcata_iosetup(unitp, pktp); /* fill a packet */ - pktp->pkt_forw = 0; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "_start: active: %c head: %c\n", - (softp->ab_active == NULL ? 'N' : 'Y'), - (softp->ab_head == NULL ? 'N' : 'Y')); - } -#endif - - if (softp->ab_active == NULL) { - /* - * The controller is idle. - * Put the packet in ab_active.... - */ - softp->ab_active = pktp; - /* - * ... and start it off - */ - ret = PCATA_GO_RETRY; - while (ret == PCATA_GO_RETRY) { - ret = pcata_go(unitp); - } - if (ret == DDI_FAILURE) { - cmn_err(CE_NOTE, "start_cmd failure \n"); - softp->ab_active = NULL; - return (CTL_SEND_FAILURE); - } - - } else { - /* - * the controller is busy now so put the packet - * on ab_head or ab_last. - */ - - if (softp->ab_head == NULL) - softp->ab_head = pktp; - else - softp->ab_last->pkt_forw = pktp; - - softp->ab_last = pktp; - } - - return (CTL_SEND_SUCCESS); -} - - -/* - * initiate I/O for packet linked on ab_active - */ -static int -pcata_go(ata_unit_t *unitp) -{ - ata_soft_t *softp = unitp->a_blkp; - struct ata_cmpkt *pktp = softp->ab_active; - uint32_t nbytes; - uint32_t start_sec; - uint32_t cyl; - uint32_t resid; - uchar_t head; - uchar_t drvheads; - uchar_t drvsectors; - - uchar_t ac_devctl; - uchar_t ac_sec; - uchar_t ac_count; - uchar_t ac_lwcyl; - uchar_t ac_hicyl; - uchar_t ac_hd; - - ASSERT(mutex_owned(&softp->ata_mutex)); - - if (pktp == NULL) - return (DDI_SUCCESS); - - if (!CARD_PRESENT_VALID(softp)) { - pktp->ac_scb = DERR_ABORT; - pktp->cp_reason = CPS_CHKERR; - return (DDI_FAILURE); - } - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_go (%p) altstatus %x error %x\n", - (void *)unitp, - csx_Get8(softp->handle, AT_ALTSTATUS), - csx_Get8(softp->handle, AT_ERROR)); - cmn_err(CE_CONT, "_go handle=%p\n", softp->handle); - } -#endif - - /* - * calculate drive address based on pktp->cp_srtsec - */ - start_sec = pktp->cp_srtsec; - drvheads = unitp->au_hd; - drvsectors = unitp->au_sec; - resid = start_sec / drvsectors; - head = resid % drvheads; - cyl = resid / drvheads; - nbytes = min(pktp->cp_resid, pktp->ac_bytes_per_block); - ac_count = (nbytes >> SCTRSHFT); - ac_devctl = unitp->au_ctl_bits; - ac_sec = (start_sec % drvsectors) + 1; - ac_hd = head | unitp->au_drive_bits; - ac_lwcyl = cyl; - ac_hicyl = (cyl >> 8); - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, - "_go %s at lba=%d (%uc %uh %us) " - "%d sectors cmd=%x ctl=%x\n", - (pktp->ac_direction == AT_OUT) ? "WT" : "RD", - start_sec, cyl, head, ac_sec, - ac_count, - pktp->ac_cmd, ac_devctl); - } -#endif - - if (pcata_wait(AT_ALTSTATUS, ATS_DRDY, ATS_BSY, softp)) - return (DDI_FAILURE); - - pcata_wait_complete(softp); - - PCIDE_OUTB(softp->handle, AT_DEVCTL, ac_devctl); - PCIDE_OUTB(softp->handle, AT_SECT, ac_sec); - PCIDE_OUTB(softp->handle, AT_COUNT, ac_count); - PCIDE_OUTB(softp->handle, AT_LCYL, ac_lwcyl); - PCIDE_OUTB(softp->handle, AT_HCYL, ac_hicyl); - PCIDE_OUTB(softp->handle, AT_DRVHD, ac_hd); - - /* - * the command should make the controller status show BSY - * the ISR intr_hi will not record status while the controller is BSY - * therefore set interrupt expected state now - * the next time we receive an interrupt and the controller is not BSY - * the ISR will do the right thing - */ - - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - if (pktp->ac_direction == AT_OUT) - softp->write_in_progress++; - csx_Put8(softp->handle, AT_CMD, pktp->ac_cmd); - mutex_exit(&softp->hi_mutex); - - /* - * If there's data to go along with the command, send it now. - */ - if (pktp->ac_direction == AT_OUT) { - if (pcata_send_data(unitp, nbytes) == DDI_FAILURE) { - if (pktp->cp_retry >= RETRY_CNT) { - pcata_clear_queues(unitp); - return (DDI_FAILURE); - } else { - pktp->cp_retry++; - cmn_err(CE_CONT, "_go: write failure," - " retry=%d \n", pktp->cp_retry); - cmn_err(CE_CONT, - "_go at lba=%d (%uc %uh %us) " - "%d sectors cmd=%x ctl=%x \n", - start_sec, cyl, head, ac_sec, - ac_count, - pktp->ac_cmd, ac_devctl); - return (PCATA_GO_RETRY); - } - } - } - - return (DDI_SUCCESS); -} - -/* - * return value - * success means go on o next block - * failure means continue with current block - */ -static void -pcata_iocmpl(ata_soft_t *softp) -{ - struct ata_cmpkt *pktp; - ata_unit_t *unitp; - int nbytes; - int ret; - uchar_t status; - uchar_t error; - - ASSERT(mutex_owned(&softp->ata_mutex)); - - if (!CARD_PRESENT_VALID(softp)) { - cmn_err(CE_CONT, "?_iocmpl Device not present\n"); - return; - } - - pktp = softp->ab_active; - - error = pktp->ac_error; - status = pktp->ac_status; - - unitp = (ata_unit_t *)pktp->cp_ctl_private; - - /* - * If there was an error, quit now - * XXX/lcl no retry is attempted? - */ - if ((status & ATS_ERR) || (error & ATE_ABORT)) { -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, - "_iocmpl I/O error status=%04x error=%04x\n", - status, - error); -#endif - pktp->cp_reason = CPS_CHKERR; - return; - } - - nbytes = min(pktp->cp_resid, pktp->ac_bytes_per_block); - - if (pktp->ac_direction == AT_IN) { - /* - * do the read of the block - */ - ret = pcata_get_data(unitp, nbytes); - if (ret == DDI_FAILURE) { - /* - * If the controller never presented the data - * and the error bit isn't set, - * there's a real problem. Kill it now. - */ - pcata_clear_queues(unitp); - return; - } - } - - /* - * update counts... - */ - pktp->ac_v_addr += nbytes; - pktp->cp_resid -= nbytes; - pktp->cp_reason = CPS_SUCCESS; - pktp->cp_srtsec += (nbytes >> SCTRSHFT); - - /* If last command was a GET_DEFECTS delay a bit */ - if (pktp->ac_cmd == ATC_READDEFECTS) - drv_usecwait(1000); -} - -int -pcata_intr_hi(ata_soft_t *softp) -{ - /* - * In ata there is no hardware support to tell if the interrupt - * belongs to ata or not. So no checks necessary here. Later - * will check the buffer and see if we have started a transaction. - */ - - int rval = DDI_INTR_UNCLAIMED; - struct ata_cmpkt *pktp; - uchar_t status; - uchar_t error; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, - "_intr_hi sn=%d status=%x intr_pending=%d " - "softint_pending=%d wr_in_prog=%d\n", - softp->sn, csx_Get8(softp->handle, AT_ALTSTATUS), - softp->intr_pending, softp->softint_pending, - softp->write_in_progress); - } -#endif - mutex_enter(&softp->hi_mutex); - - /* - * this test is not redundant (don't remove it) - * it is part of card removal processing - * and prevents losing interrupt threads - */ - if (!CARD_PRESENT_VALID(softp)) { - mutex_exit(&softp->hi_mutex); - return (rval); - } - - status = csx_Get8(softp->handle, AT_ALTSTATUS); - - /* - * this is a shared interrupt - * if the controller is NOT busy, - * and an interrupt is expected - */ - - if ((status & ATS_ERR) && - ((status & ATS_BSY) == 0) && - (softp->intr_pending > 0)) { - cmn_err(CE_CONT, - "?_intr_hi sn=%d status=%x\n", - softp->sn, status); - /* handle aborted commands */ - error = csx_Get8(softp->handle, AT_ERROR); - if ((error & ATE_ABORT) && - (softp->write_in_progress > 0)) { - softp->write_in_progress = 0; - } - } - - if ((status & ATS_BSY) == 0 && - (softp->write_in_progress == 0) && - (softp->intr_pending > 0)) { - /* - * Read the status register, - * this clears an interrupt from the ata device - */ - status = csx_Get8(softp->handle, AT_STATUS); - error = csx_Get8(softp->handle, AT_ERROR); - rval = DDI_INTR_CLAIMED; - softp->intr_pending--; - /* - * Make sure the interrupt is cleared, occasionally it is not - * cleared by the first status read. - */ - status = csx_Get8(softp->handle, AT_STATUS); - /* put the error status in the right place */ - if ((pktp = softp->ab_active) != 0) { - pktp->ac_error = error; - pktp->ac_status = status; - } - } - mutex_exit(&softp->hi_mutex); - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) - cmn_err(CE_CONT, - "_intr_hi status=%x error=%x claimed=%d pending=%d\n", - status, error, - (rval == DDI_INTR_CLAIMED), - softp->intr_pending); -#endif - - if ((rval == DDI_INTR_CLAIMED) && - (softp->ab_active != NULL)) { - mutex_enter(&softp->hi_mutex); - softp->softint_pending++; - mutex_exit(&softp->hi_mutex); - ddi_trigger_softintr(softp->softint_id); - } - - return (rval); -} - -uint32_t -pcata_intr(char *parm) -{ - ata_soft_t *softp = (ata_soft_t *)parm; - ata_unit_t *unitp; - struct ata_cmpkt *pktp; - buf_t *bp; - uint32_t nbytes; - uint32_t start_sec; - uint32_t cyl; - uint32_t resid; - uchar_t head; - uchar_t drvheads; - uchar_t drvsectors; - uchar_t ac_devctl; - uchar_t ac_sec; - uchar_t ac_count; - int ret; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_intr entry (%p) sn=%d softint_pending=%d\n", - (void *)softp, softp->sn, softp->softint_pending); - } -#endif - - - if (softp->softint_pending == 0) { - return (DDI_INTR_UNCLAIMED); - } - - mutex_enter(&softp->ata_mutex); - - if (softp->ab_active == NULL) { - cmn_err(CE_CONT, "?_intr No outstanding I/O\n"); - goto done; - } - - /* perform I/O completion */ - pcata_iocmpl(softp); - - if (!CARD_PRESENT_VALID(softp)) - goto done; - - /* - * if packet is done (either errors or all bytes transfered) - * pktp points to current packet - * ab_active is cleared - * else - * pktp is null - * ab_active is unchanged - */ - pktp = softp->ab_active; - if (pktp != NULL) { - if (pktp->cp_resid == 0 || pktp->cp_reason != CPS_SUCCESS) { -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_intr retry=%d reason=%d" - " CPS_SUCCESS=%d pkpt=%p cp_resid = %d\n", - pktp->cp_retry, pktp->cp_reason, - CPS_SUCCESS, (void *)pktp, - pktp->cp_resid); - } -#endif - if ((pktp->cp_retry < RETRY_CNT) && - (pktp->cp_reason != CPS_SUCCESS)) { - pktp->cp_retry++; - unitp = softp->ab_active->cp_ctl_private; - - /* - * calculate drive address based on - * pktp->cp_srtsec - */ - start_sec = pktp->cp_srtsec; - drvheads = unitp->au_hd; - drvsectors = unitp->au_sec; - resid = start_sec / drvsectors; - head = resid % drvheads; - cyl = resid / drvheads; - nbytes = min(pktp->cp_resid, - pktp->ac_bytes_per_block); - ac_count = (nbytes >> SCTRSHFT); - ac_devctl = unitp->au_ctl_bits; - ac_sec = (start_sec % drvsectors) + 1; - - cmn_err(CE_CONT, "_intr I/O failure," - " retry %d\n", pktp->cp_retry); - cmn_err(CE_CONT, - "_intr %s at lba=%d (%uc %uh %us) " - "%d sectors cmd=%x ctl=%x\n", - (pktp->ac_direction == AT_OUT) ? - "write" : "read", - start_sec, cyl, head, ac_sec, - ac_count, - pktp->ac_cmd, ac_devctl); - - pktp = 0; - } else { - /* I/O is complete or an error has occured */ - softp->ab_active = NULL; - } - } else { - /* I/O is still in progress */ - pktp = 0; - } - } - - /* - * packet which caused this interrupt is now complete - */ - if (pktp) { - if ((pktp->ac_status & ATS_ERR) || (pktp->ac_error)) { - bioerror(pktp->cp_bp, EIO); -#ifdef ATA_DEBUG - cmn_err(CE_NOTE, "_intr ATA ERROR status=%x error=%x\n", - pktp->ac_status, pktp->ac_error); -#endif - } - - bp = pktp->cp_bp; - bp->b_resid = bp->b_bcount - pktp->cp_bytexfer; - - /* release the thread for the I/O just completed */ - biodone(bp); - - kmem_free((void *)pktp, sizeof (*pktp)); - } - - - /* if ab_active is NULL attempt to dequeue next I/O request */ - if (softp->ab_active == NULL && softp->ab_head != NULL) { - softp->ab_active = softp->ab_head; - softp->ab_head = softp->ab_head->pkt_forw; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, - "_start_next_cmd current:%p head:%p\n", - (void *)softp->ab_active, - (void *)softp->ab_head); - } -#endif - } - - mutex_enter(&softp->hi_mutex); - softp->softint_pending--; - mutex_exit(&softp->hi_mutex); - - /* if ab_active is not NULL, attempt to initiate I/O */ - if (softp->ab_active != NULL) { - unitp = softp->ab_active->cp_ctl_private; - - ret = PCATA_GO_RETRY; - while (ret == PCATA_GO_RETRY) { - ret = pcata_go(unitp); - } - } - goto exit; - -done: - mutex_enter(&softp->hi_mutex); - softp->softint_pending--; - mutex_exit(&softp->hi_mutex); -exit: - mutex_exit(&softp->ata_mutex); -#ifdef ATA_DEBUG - if (pcata_debug & DENT) - cmn_err(CE_CONT, "_intr exit (%p)\n", (void *)softp); -#endif - return (DDI_INTR_CLAIMED); -} - - -/* - * XXX/lcl need determine if all drives or a single drive is to be cleared - * if all drives then eliminate tests for pktp->cp_ctl_private == unitp - * if single drive then examine usage of flag ATA_OFFLINE - */ -static void -pcata_clear_queues(ata_unit_t *unitp) -{ - ata_soft_t *softp = unitp->a_blkp; - struct ata_cmpkt *pktp; - buf_t *bp; - - ASSERT(mutex_owned(&softp->ata_mutex)); - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_clear_queues (%p)\n", (void *)unitp); - } -#endif - /* - * nack the active request - */ - softp->ab_status_flag |= ATA_OFFLINE; - - pktp = softp->ab_active; - if (pktp && pktp->cp_ctl_private == unitp) - pcata_nack_packet(pktp); - - /* - * now nack all queued requests - */ - for (pktp = softp->ab_head; pktp; pktp = pktp->pkt_forw) { - bp = pktp->cp_bp; - if (bp && ((bp->b_flags & B_DONE) == 0)) { - if ((pktp->ac_status & ATS_ERR) || (pktp->ac_error)) { - bioerror(bp, EIO); - } - - /* release the thread for the I/O */ - biodone(bp); - } - if (pktp->cp_ctl_private == unitp) - pcata_nack_packet(pktp); - } -} - -static void -pcata_nack_packet(struct ata_cmpkt *pktp) -{ -#ifdef ATA_DEBUG - if (pcata_debug & DENT) - cmn_err(CE_CONT, "pcata_nack_packet (%p)\n", (void *)pktp); -#endif - if (pktp != NULL) { - pktp->cp_reason = CPS_CHKERR; - pktp->ac_scb = DERR_ABORT; - } -} - -/* - * pcata_wait -- wait for a register of a controller to achieve a - * specific state. Arguments are a mask of bits we care about, - * and two sub-masks. To return normally, all the bits in the - * first sub-mask must be ON, all the bits in the second sub- - * mask must be OFF. If 5 seconds pass without the controller - * achieving the desired bit configuration, we return 1, else - * 0. - */ -static int -pcata_wait(uint32_t port, ushort_t onbits, ushort_t offbits, ata_soft_t *softp) -{ - register int i; - register ushort_t maskval; - int ival = csx_Get8(softp->handle, port); - - for (i = 400000; i && (CARD_PRESENT_VALID(softp)); i--) { - maskval = csx_Get8(softp->handle, port); - if (((maskval & onbits) == onbits) && - ((maskval & offbits) == 0)) - return (0); - drv_usecwait(10); - } -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "_wait timeout: " - "sn=%d port=%x on: 0x%x off: 0x%x ival: 0x%x eval: 0x%x\n", - softp->sn, port, onbits, offbits, ival, maskval); -#endif - return (1); -} - - -/* - * Similar to pcata_wait but the timeout is much shorter. It is only used - * during initialization when long delays are noticable. - */ -static int -pcata_wait1(uint32_t port, ushort_t onbits, ushort_t offbits, int interval, - ata_soft_t *softp) -{ - register int i; - register ushort_t maskval; - - for (i = interval; i && (CARD_PRESENT_VALID(softp)); i--) { - maskval = csx_Get8(softp->handle, port); - if (((maskval & onbits) == onbits) && - ((maskval & offbits) == 0)) - return (0); - drv_usecwait(10); - } - return (1); -} - -/* - * Wait until the command interrupt has been serviced before starting - * another command. - * - */ -static void -pcata_wait_complete(ata_soft_t *softp) -{ - int i; - - for (i = 0; i < PCATA_WAIT_CNT && - ((softp->intr_pending > 0) || (softp->softint_pending > 0)); i++) { - drv_usecwait(10); - } -} - -static int -pcata_send_data(ata_unit_t *unitp, int count) -{ - ata_soft_t *softp = unitp->a_blkp; - struct ata_cmpkt *pktp = unitp->a_blkp->ab_active; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_send_data (%p, %x)\n", - (void *)unitp, count); - } -#endif - if (pcata_wait(AT_ALTSTATUS, ATS_DRQ, 0, softp)) { - cmn_err(CE_CONT, "_send_data - NOT READY\n"); - mutex_enter(&softp->hi_mutex); - softp->write_in_progress = 0; - mutex_exit(&softp->hi_mutex); - return (DDI_FAILURE); - } - - /* - * copy count bytes from pktp->v_addr to the data port - */ -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "_send_data: port=%x addr=0x%p count=0x%x\n", - unitp->a_blkp->ab_data, - (void *)pktp->ac_v_addr, - count); - } -#endif - - if (!CARD_PRESENT_VALID(softp)) { - mutex_enter(&softp->hi_mutex); - softp->write_in_progress = 0; - mutex_exit(&softp->hi_mutex); - return (DDI_FAILURE); - } - - mutex_enter(&softp->hi_mutex); - csx_RepPut16(softp->handle, (ushort_t *)pktp->ac_v_addr, AT_DATA, - (count >> 1), DDI_DEV_NO_AUTOINCR); - if (softp->write_in_progress > 0) - softp->write_in_progress--; - mutex_exit(&softp->hi_mutex); - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "_send_data: "); - pcata_print_sttflag(csx_Get8(softp->handle, AT_ALTSTATUS)); - } - -#endif - return (DDI_SUCCESS); -} - - -static int -pcata_get_data(ata_unit_t *unitp, int count) -{ - ata_soft_t *softp = unitp->a_blkp; - register struct ata_cmpkt *pktp = unitp->a_blkp->ab_active; - - if (pcata_wait(AT_ALTSTATUS, ATS_DRQ, 0, softp)) { - cmn_err(CE_CONT, "_get_data - NOT READY\n"); - return (DDI_FAILURE); - } - /* - * copy count bytes from the data port to pktp->ac_v_addr - */ - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, "_get_data port=%x addr=0x%p count=0x%x\n", - unitp->a_blkp->ab_data, (void *)pktp->ac_v_addr, count); - } -#endif - - if (!CARD_PRESENT_VALID(softp)) - return (DDI_FAILURE); - - csx_RepGet8(softp->handle, (uchar_t *)pktp->ac_v_addr, - AT_DATA, count, DDI_DEV_NO_AUTOINCR); - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) - cmn_err(CE_CONT, "_get_data complete\n"); -#endif - return (DDI_SUCCESS); -} - - -int -pcata_getedt(ata_soft_t *softp, int dmax) -{ - ushort_t *secbuf; - struct atarpbuf *rpbp; - int drive, dcount; - char buf[41]; - int i; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_getedt (%p)\n", (void *)softp); - } -#endif - /* toggle reset bit to trigger a software reset */ - if (!(CARD_PRESENT_VALID(softp))) - return (DDI_FAILURE); - csx_Put8(softp->handle, AT_DEVCTL, AT_DEVCTL_D3|AT_SRST); - - drv_usecwait(1000); - if (!(CARD_PRESENT_VALID(softp))) - return (DDI_FAILURE); - - /* - * The interrupt disable command does not work reliably with - * all PC ATA cards. It is better to leave interupts enabled - * and process them as they occur. - */ - - PCIDE_OUTB(softp->handle, AT_DEVCTL, ENABLE_INTERRUPT); - - secbuf = (ushort_t *)kmem_zalloc(NBPSCTR, KM_NOSLEEP); - if (!secbuf) { - return (DDI_FAILURE); - } - - for (dcount = drive = 0; drive < dmax; drive++) { - if (!(rpbp = (struct atarpbuf *)kmem_zalloc( - (sizeof (struct atarpbuf) + - sizeof (struct scsi_inquiry)), KM_NOSLEEP))) { - kmem_free(secbuf, NBPSCTR); - return (DDI_FAILURE); - } - - /* - * load up with the drive number - */ - if (drive == 0) { - PCIDE_OUTB(softp->handle, AT_DRVHD, ATDH_DRIVE0); - } else { - PCIDE_OUTB(softp->handle, AT_DRVHD, ATDH_DRIVE1); - } - PCIDE_OUTB(softp->handle, AT_FEATURE, 0); - - softp->ab_dev_type[drive] = pcata_drive_type(softp, secbuf); - - if (softp->ab_dev_type[drive] == ATA_DEV_NONE) { - kmem_free(rpbp, (sizeof (struct atarpbuf) + - sizeof (struct scsi_inquiry))); - continue; - } - dcount++; - bcopy((caddr_t)secbuf, (caddr_t)rpbp, sizeof (struct atarpbuf)); - - mutex_enter(&softp->ata_mutex); - if (!(softp->card_state & PCATA_CARD_INSERTED)) { - kmem_free(rpbp, (sizeof (struct atarpbuf) + - sizeof (struct scsi_inquiry))); - dcount--; - mutex_exit(&softp->ata_mutex); - break; - } - - softp->ab_rpbp[drive] = rpbp; - - /* - * We need to swap the strings on both platforms. - */ -#ifdef _BIG_ENDIAN - pcata_byte_swap((char *)rpbp, sizeof (*rpbp)); -#else - pcata_byte_swap(rpbp->atarp_drvser, - sizeof (rpbp->atarp_drvser)); - pcata_byte_swap(rpbp->atarp_fw, sizeof (rpbp->atarp_fw)); - pcata_byte_swap(rpbp->atarp_model, sizeof (rpbp->atarp_model)); -#endif - - mutex_exit(&softp->ata_mutex); - -#ifdef ATA_DEBUG - if (pcata_debug & DINIT) { - (void) strncpy(buf, - rpbp->atarp_model, sizeof (rpbp->atarp_model)); - buf[sizeof (rpbp->atarp_model)-1] = '\0'; - - /* truncate model */ - for (i = sizeof (rpbp->atarp_model) - 2; i && buf[i] == ' '; - i--) { - buf[i] = '\0'; - } - cmn_err(CE_CONT, "_getedt model %s, targ %d, stat %x, err %x\n", - buf, - drive, - csx_Get8(softp->handle, AT_STATUS), - csx_Get8(softp->handle, AT_ERROR)); - cmn_err(CE_CONT, " cfg 0x%x, cyl %d, hd %d, sec/trk %d\n", - rpbp->atarp_config, - rpbp->atarp_fixcyls, - rpbp->atarp_heads, - rpbp->atarp_sectors); - cmn_err(CE_CONT, " mult1 0x%x, mult2 0x%x, dwcap 0x%x," - " cap 0x%x\n", - rpbp->atarp_mult1, - rpbp->atarp_mult2, - rpbp->atarp_dwcap, - rpbp->atarp_cap); - cmn_err(CE_CONT, " piomode 0x%x, dmamode 0x%x," - " advpiomode 0x%x\n", - rpbp->atarp_piomode, - rpbp->atarp_dmamode, - rpbp->atarp_advpiomode); - cmn_err(CE_CONT, " minpio %d, minpioflow %d", - rpbp->atarp_minpio, - rpbp->atarp_minpioflow); - cmn_err(CE_CONT, " valid 0x%x, dwdma 0x%x\n", - rpbp->atarp_validinfo, - rpbp->atarp_dworddma); - } -#endif - - if (!(CARD_PRESENT_VALID(softp))) - return (DDI_FAILURE); - (void) csx_Get8(softp->handle, AT_STATUS); - (void) csx_Get8(softp->handle, AT_ERROR); - } - - kmem_free(secbuf, NBPSCTR); - if (dcount == 0) - return (DDI_FAILURE); - - for (dcount = drive = 0; drive < dmax; drive++) { - - if ((rpbp = softp->ab_rpbp[drive]) == NULL) { - continue; /* no drive here */ - } - - if (softp->ab_dev_type[drive] != ATA_DEV_DISK) { - cmn_err(CE_CONT, "Unknown IDE attachment at 0x%x.\n", - softp->ab_cmd - AT_CMD); - continue; - } - - /* - * feed some of the info back in a set_params call. - */ - mutex_enter(&softp->ata_mutex); - if (pcata_setpar(drive, rpbp->atarp_heads, - rpbp->atarp_sectors, softp) - == DDI_FAILURE) { - /* - * there should have been a drive here but it - * didn't respond properly. It stayed BUSY. - */ - if (softp->ab_rpbp[drive]) { - kmem_free(rpbp, - (sizeof (struct atarpbuf) + - sizeof (struct scsi_inquiry))); - } - softp->ab_rpbp[drive] = NULL; - softp->ab_dev_type[drive] = ATA_DEV_NONE; - mutex_exit(&softp->ata_mutex); - continue; - } - mutex_exit(&softp->ata_mutex); - dcount++; - } - -#ifdef ATA_DEBUG - if (pcata_debug) - cmn_err(CE_CONT, "**** probed %d device%s 0x%x\n", - dcount, dcount == 1 ? "." : "s.", - softp->ab_cmd - AT_CMD); -#endif - - return (dcount ? DDI_SUCCESS : DDI_FAILURE); -} - -/* - * pcata_drive_type() - */ -static uchar_t -pcata_drive_type(ata_soft_t *softp, ushort_t *buf) -{ - struct atarpbuf *rpbp = (struct atarpbuf *)buf; - - if (pcata_wait1(AT_ALTSTATUS, - (ATS_DRDY | ATS_DSC), (ATS_BSY | ATS_ERR), 100000, softp)) - return (ATA_DEV_NONE); - - pcata_wait_complete(softp); - - /* - * note: pcata_drive_type is only called by pcata_getedt() - * the drive (master/slave) is selected there - */ - /* command also known as IDENTIFY DEVICE */ - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - csx_Put8(softp->handle, AT_CMD, ATC_READPARMS); - mutex_exit(&softp->hi_mutex); - - if (pcata_wait1(AT_ALTSTATUS, ATS_DRQ, ATS_BSY, 1000000, softp)) { - -#ifdef ATA_DEBUG - if (pcata_debug) { - cmn_err(CE_NOTE, "failed drive did not settle:"); - pcata_print_sttflag(csx_Get8(softp->handle, AT_STATUS)); - } -#endif - return (ATA_DEV_NONE); - } - - csx_RepGet16(softp->handle, (ushort_t *)buf, AT_DATA, NBPSCTR >> 1, - DDI_DEV_NO_AUTOINCR); - -#ifdef ATA_DEBUG - if (pcata_debug) { - if ((csx_Get8(softp->handle, AT_STATUS) & ATS_ERR) == 0) { - pcata_byte_swap(rpbp->atarp_model, - sizeof (rpbp->atarp_model)); - rpbp->atarp_model[sizeof (rpbp->atarp_model)-1] = '\0'; - cmn_err(CE_CONT, "succeeded: %s\n", - rpbp->atarp_model); - pcata_byte_swap(rpbp->atarp_model, - sizeof (rpbp->atarp_model)); - } else { - cmn_err(CE_CONT, "failed drive drive read error.\n"); - } - } -#endif - - /* - * wait for the drive to recognize I've read all the data. some - * drives have been observed to take as much as 3msec to finish - * sending the data; allow 5 msec just in case. - */ - if (pcata_wait1(AT_ALTSTATUS, ATS_DRDY, ATS_BSY | ATS_DRQ, 500, softp)) - return (ATA_DEV_NONE); - - if (!CARD_PRESENT_VALID(softp)) - return (ATA_DEV_NONE); - - if (csx_Get8(softp->handle, AT_ALTSTATUS) & ATS_ERR) - return (ATA_DEV_NONE); - - return (ATA_DEV_DISK); -} - - -/* - * Drive set params command. - */ -static int -pcata_setpar(int drive, int heads, int sectors, ata_soft_t *softp) -{ - -#ifdef ATA_DEBUG - if (pcata_debug & DINIT) - cmn_err(CE_CONT, "_setpar status=0x%x drive=%d heads=%d\n", - csx_Get8(softp->handle, AT_STATUS), drive, heads); -#endif - if (!CARD_PRESENT_VALID(softp)) - return (DDI_FAILURE); - - if (pcata_wait(AT_ALTSTATUS, ATS_DRDY, ATS_BSY, softp)) - return (DDI_FAILURE); - - pcata_wait_complete(softp); - - PCIDE_OUTB(softp->handle, AT_DRVHD, (heads - 1) | - (drive == 0 ? ATDH_DRIVE0 : ATDH_DRIVE1)); - PCIDE_OUTB(softp->handle, AT_COUNT, sectors); - - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - csx_Put8(softp->handle, AT_CMD, ATC_SETPARAM); - mutex_exit(&softp->hi_mutex); - - if (pcata_wait(AT_ALTSTATUS, 0, ATS_BSY, softp)) - return (DDI_FAILURE); - return (DDI_SUCCESS); -} - -void -pcata_byte_swap(char *buf, int n) -{ - int i; - char c; - - n &= ~1; - for (i = 0; i < n; i += 2) { - c = buf[i]; - buf[i] = buf[i + 1]; - buf[i + 1] = c; - } -} - - -int -pcata_set_rw_multiple(ata_soft_t *softp, int drive) -{ - int i; - int laststat; - char size; - char accepted_size = -1; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_set_rw_multiple (%p, %d)\n", - (void *)softp, drive); - } -#endif - - if (!CARD_PRESENT_VALID(softp)) - return (DDI_FAILURE); - /* - * Assume we're going to use read/write multiple until the controller - * says it doesn't understand them. - */ - softp->ab_rd_cmd[drive] = ATC_RDMULT; - softp->ab_wr_cmd[drive] = ATC_WRMULT; - - /* - * set drive number - */ - PCIDE_OUTB(softp->handle, AT_DRVHD, drive == 0 ? ATDH_DRIVE0 : - ATDH_DRIVE1); - - for (size = 32; size > 0 && accepted_size == -1 && - CARD_PRESENT_VALID(softp); size >>= 1) { - - if (pcata_wait(AT_ALTSTATUS, ATS_DRDY, ATS_BSY, softp)) - return (DDI_FAILURE); - - pcata_wait_complete(softp); - - /* - * send the command - */ - PCIDE_OUTB(softp->handle, AT_COUNT, size); - - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - csx_Put8(softp->handle, AT_CMD, ATC_SETMULT); - mutex_exit(&softp->hi_mutex); - - if (pcata_wait(AT_ALTSTATUS, 0, ATS_BSY, softp)) - /* - * there should have been a drive here but it - * didn't respond properly. It stayed BUSY. - * complete failure! - */ - return (DDI_FAILURE); - /* - * Wait for DRDY or error status - */ - for (i = 0; i < ATA_LOOP_CNT && CARD_PRESENT_VALID(softp); - i++) { - if (((laststat = csx_Get8(softp->handle, AT_ALTSTATUS)) - & (ATS_DRDY | ATS_ERR)) != 0) - break; - drv_usecwait(10); - } - if (i == ATA_LOOP_CNT) - /* - * Didn't get ready OR error... complete failure! - * there should have been a drive here but it - * didn't respond properly. It didn't set ERR or DRQ. - */ - return (DDI_FAILURE); - - /* - * See if DRQ or error - */ - if (laststat & ATS_ERR) { - /* - * there should have been a drive here but it - * didn't respond properly. There was an error. - * Try the next value. - */ - continue; - } - /* - * Got ready.. use the value that worked. - */ - accepted_size = size; - } - if (accepted_size == -1) { - /* - * None of the values worked... - * the controller responded correctly though so it probably - * doesn't support the read/write multiple commands. - */ - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "Using STD R/W cmds and setting" - "block factor to 1\n"); - } -#endif - softp->ab_rd_cmd[drive] = ATC_RDSEC; - softp->ab_wr_cmd[drive] = ATC_WRSEC; - softp->ab_block_factor[drive] = 1; - softp->ab_max_transfer = 1; - return (DDI_SUCCESS); - } - if (accepted_size == 1) { - /* - * OK... Leave it at 1 - */ -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "setting block factor to 1\n"); - } -#endif - softp->ab_block_factor[drive] = accepted_size; - softp->ab_max_transfer = accepted_size; - return (DDI_SUCCESS); - } - accepted_size >>= 1; - /* - * Allow a user specified block factor to override the system chosen - * value. Only allow the user to reduce the value. - * -1 indicates the user didn't specify anything - */ - if ((softp->ab_block_factor[drive] != -1) && - (softp->ab_block_factor[drive] < accepted_size)) - accepted_size = softp->ab_block_factor[drive]; - - if (pcata_wait(AT_ALTSTATUS, ATS_DRDY, ATS_BSY, softp)) - return (DDI_FAILURE); - - pcata_wait_complete(softp); - - PCIDE_OUTB(softp->handle, AT_COUNT, accepted_size); - - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - csx_Put8(softp->handle, AT_CMD, ATC_SETMULT); - mutex_exit(&softp->hi_mutex); - - if (pcata_wait(AT_ALTSTATUS, 0, ATS_BSY, softp)) - /* - * there should have been a drive here but it - * didn't respond properly. It stayed BUSY. - */ - return (DDI_FAILURE); - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "setting block factor for drive %d to %d\n", - drive, accepted_size); - } -#endif - - softp->ab_block_factor[drive] = accepted_size; - return (DDI_SUCCESS); -} - -static int -pcata_dump(dev_t dev, caddr_t addr, daddr_t blkno, int nblk) -{ - ata_soft_t *softp; - buf_t *bp; - void *instance; - - - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *)dev, - &instance) != DDI_SUCCESS) - return (ENODEV); - - softp = ddi_get_soft_state(pcata_soft, (int)(uintptr_t)instance); - if (!softp) { - return (ENXIO); - } - - if (!CARD_PRESENT_VALID(softp)) - return (ENODEV); - - bp = softp->crashbuf; - bp->b_un.b_addr = addr; - bp->b_edev = dev; - bp->b_dev = cmpdev(dev); - bp->b_bcount = nblk * DEV_BSIZE; - bp->b_flags |= B_WRITE | B_PHYS; - bp->b_blkno = blkno; - bp->b_private = 0; - - /* - * If pcata_strategy() encounters an exception, or card_removal - * is called, before this is complete, it is possible that - * biodone will be called but the buffer (bp) wont - * be released unless B_ASYNC flag is set. So - * don't set B_ASYNC flag unless you mean it. - */ - (void) pcata_strategy(bp); - if (bp->b_error) - return (bp->b_error); - - for (;;) { - if (!CARD_PRESENT_VALID(softp)) - return (ENODEV); - if (bp->b_flags & B_DONE) { - if (bp->b_flags & B_ERROR) - return (bp->b_error); - else - return (0); - } - drv_usecwait(1000); - } -} - -/* ddi print */ -static int -pcata_print(dev_t dev, char *str) -{ - void *instance; - ata_soft_t *softp; - - - /* get instance number */ - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *)dev, - &instance) != DDI_SUCCESS) { - cmn_err(CE_CONT, "_print: pcata_getinfo" - "return ENODEV\n"); - return (ENODEV); - } - - if (!(softp = ddi_get_soft_state(pcata_soft, - (int)(uintptr_t)instance))) { - return (ENXIO); - } - - cmn_err(CE_NOTE, "_print: socket %d %s", softp->sn, str); - return (0); - -} - -static int -pcata_rdrw(dev_t dev, struct uio *uio, int flag) -{ - return (physio(pcata_strategy, (buf_t *)0, dev, flag, pcata_min, uio)); -} - - - -/* ARGSUSED2 */ -static int -pcata_read(dev_t dev, struct uio *uio, cred_t *cred_p) -{ - return (pcata_rdrw(dev, uio, B_READ)); -} - - - -/* ARGSUSED2 */ -static int -pcata_write(dev_t dev, struct uio *uio, cred_t *cred_p) -{ - return (pcata_rdrw(dev, uio, B_WRITE)); -} - - -void -pcata_min(buf_t *bp) -{ - ata_soft_t *softp; - void *instance; - - if (pcata_getinfo(NULL, DDI_INFO_DEVT2INSTANCE, (void *)bp->b_edev, - &instance) != DDI_SUCCESS) - cmn_err(CE_CONT, "Error in pcata_min\n"); - - softp = ddi_get_soft_state(pcata_soft, (int)(uintptr_t)instance); - - if ((ROUNDUP(bp->b_bcount, NBPSCTR) >> SCTRSHFT) > - softp->ab_max_transfer) - - bp->b_bcount = softp->ab_max_transfer << SCTRSHFT; -} - -static void -pcata_iosetup(ata_unit_t *unitp, struct ata_cmpkt *pktp) -{ - uint32_t sec_count; - -#ifdef ATA_DEBUG - if (pcata_debug & DENT) { - cmn_err(CE_CONT, "_iosetup (%p, %p)\n", - (void *)unitp, (void *)pktp); - } -#endif - - /* check for error retry */ - if (pktp->ac_flags & CFLAG_ERROR) { - pktp->ac_bytes_per_block = NBPSCTR; - sec_count = 1; - } else { - /* - * Limit requetst to ab_max_transfer sectors. - * The value is specified by the user in the - * max_transfer property. It must be in the range 1 to 256. - * When max_transfer is 0x100 it is bigger than 8 bits. - * The spec says 0 represents 256 so it should be OK. - */ - sec_count = min((pktp->cp_bytexfer >> SCTRSHFT), - unitp->a_blkp->ab_max_transfer); - } - pktp->ac_v_addr = pktp->ac_start_v_addr; - pktp->cp_resid = pktp->cp_bytexfer; - pktp->cp_bytexfer = sec_count << SCTRSHFT; - -#ifdef ATA_DEBUG - if (pcata_debug & DIO) { - cmn_err(CE_CONT, - "_iosetup: asking for start 0x%lx count 0x%x\n", - pktp->cp_srtsec, pktp->cp_bytexfer >> SCTRSHFT); - } -#endif - /* - * setup the task file registers - */ - - if (pktp->cp_passthru) { - switch (((struct dadkio_rwcmd *)(pktp->cp_passthru))->cmd) { - case DADKIO_RWCMD_READ: - pktp->ac_cmd = unitp->au_rd_cmd; - pktp->ac_direction = AT_IN; - break; - case DADKIO_RWCMD_WRITE: - pktp->ac_cmd = unitp->au_wr_cmd; - pktp->ac_direction = AT_OUT; - break; - } - } else { - switch (pktp->ac_cdb) { - case DCMD_READ: - case DCMD_WRITE: - case DCMD_RECAL: - case DCMD_SEEK: - case DCMD_RDVER: - switch (pktp->ac_cdb) { - case DCMD_READ: - pktp->ac_cmd = unitp->au_rd_cmd; - pktp->ac_direction = AT_IN; - break; - case DCMD_WRITE: - pktp->ac_cmd = unitp->au_wr_cmd; - pktp->ac_direction = AT_OUT; - break; - case DCMD_RECAL: - pktp->ac_cmd = ATC_RECAL; - pktp->ac_direction = AT_NO_DATA; - break; - case DCMD_SEEK: - pktp->ac_cmd = ATC_SEEK; - pktp->ac_direction = AT_NO_DATA; - break; - case DCMD_RDVER: - pktp->ac_cmd = ATC_RDVER; - pktp->ac_direction = AT_NO_DATA; - break; - } - break; - default: - cmn_err(CE_CONT, "_iosetup: " - "unrecognized cmd 0x%x\n", - pktp->ac_cdb); - break; - } - } -} - - -/* ARGSUSED */ -int -pcata_spinup(ata_soft_t *softp, int slot) -{ - - if (!(CARD_PRESENT_VALID(softp))) - return (DDI_FAILURE); - - if (pcata_wait(AT_ALTSTATUS, ATS_DRDY, ATS_BSY, softp)) - return (DDI_FAILURE); - - pcata_wait_complete(softp); - - /* spin up the drive */ - PCIDE_OUTB(softp->handle, AT_DRVHD, ATDH_DRIVE0); - - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - csx_Put8(softp->handle, AT_CMD, ATC_IDLE_IMMED); - mutex_exit(&softp->hi_mutex); - - if (pcata_wait(AT_ALTSTATUS, - (ATS_DRDY | ATS_DSC), (ATS_BSY | ATS_ERR), softp)) { -#ifdef ATA_DEBUG - cmn_err(CE_NOTE, "TIMEOUT SPINNING UP: "); - pcata_print_sttflag(csx_Get8(softp->handle, AT_ALTSTATUS)); -#endif - return (DDI_FAILURE); - } - - pcata_wait_complete(softp); - - /* set the R/W multiple value decided at first init time */ - - PCIDE_OUTB(softp->handle, AT_COUNT, softp->ab_block_factor[0]); - - mutex_enter(&softp->hi_mutex); - softp->intr_pending++; - csx_Put8(softp->handle, AT_CMD, ATC_SETMULT); - mutex_exit(&softp->hi_mutex); - - if (pcata_wait(AT_STATUS, 0, ATS_BSY, softp)) { - /* - * there should have been a drive here but it - * didn't respond properly. It stayed BUSY. - */ -#ifdef ATA_DEBUG - cmn_err(CE_NOTE, "Error Spinning up ATA drive (after CPR)\n"); -#endif - return (DDI_FAILURE); - } - - return (DDI_SUCCESS); -} - -#ifdef ATA_DEBUG -static char * -ata_sttvals[] = { "err", "idx", "corr", "drq", "dsc", "dwf", "drdy", "bsy" }; - - -static void -pcata_print_sttflag(int svalue) -{ - int i; - char buf[80]; - - (void) sprintf(buf, "_sttflag = 0x%x [ ", svalue); - - for (i = 7; i >= 0; i--, svalue <<= 1) { - if (svalue & 0x80) { - (void) strcat(buf, ata_sttvals[i]); - (void) strcat(buf, " "); - } - } - cmn_err(CE_CONT, "%s ]\n", buf); -} -#endif diff --git a/usr/src/uts/common/io/pcmcia/pclabel.c b/usr/src/uts/common/io/pcmcia/pclabel.c deleted file mode 100644 index 9c634f97d8..0000000000 --- a/usr/src/uts/common/io/pcmcia/pclabel.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/user.h> -#include <sys/buf.h> -#include <sys/file.h> -#include <sys/cmn_err.h> -#include <sys/uio.h> -#include <sys/kmem.h> -#include <sys/sysmacros.h> -#include <sys/stat.h> -#include <sys/scsi/scsi.h> - -#include <sys/fdio.h> - -#include <sys/errno.h> -#include <sys/open.h> -#include <sys/debug.h> -#include <sys/varargs.h> -#include <sys/fs/pc_label.h> - -#include <sys/hdio.h> -#include <sys/dkio.h> - -#include <sys/dklabel.h> - -#include <sys/vtoc.h> - - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/dditypes.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/dktp/cm.h> - -#include <sys/dktp/fdisk.h> - -#include <sys/pctypes.h> - - -/* Future WORK */ -/* Card Services header files should be removed. When pcata.h is split */ - -#include <sys/cis.h> -#include <sys/cis_handlers.h> -#include <sys/cs_types.h> -#include <sys/cs.h> - -#include <sys/fs/pc_label.h> - -#include <sys/pctypes.h> -#include <sys/pcmcia/pcata.h> - -static int pcdsklbl_chk(struct dk_label *, unsigned short *); -static void pcdsklbl_preplb(ata_unit_t *unitp); -static int pcdsklbl_rdvtoc(ata_unit_t *unitp, buf_t *bp); - -/* - * accepts pointer to buffer containing the on-disk label data - * data could be VTOC8 or VTOC16 - * data could be in a struct buf or in lbl - * - * verifies magic numbers in label and checksum - * - * if the parameter pointing to the checksum points to a location - * within the label, this routine will generate the checksum - */ -static int -pcdsklbl_chk(struct dk_label *lbp, unsigned short *cksum) -{ - short *sp; - short count; - unsigned short sum; - - /* - * Check magic number of the label - */ - if (lbp->dkl_magic != DKL_MAGIC) { -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) { - cmn_err(CE_CONT, "pcdsklbl_chk: " - "magic: 0x%x not MAGIC:0x%x\n", - lbp->dkl_magic, - DKL_MAGIC); - } -#endif - return (DDI_FAILURE); - } - if (lbp->dkl_vtoc.v_sanity != VTOC_SANE) { -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) { - cmn_err(CE_CONT, "pcdsklbl_chk: " - "sanity: 0x%x not SANE:0x%x\n", - lbp->dkl_vtoc.v_sanity, - VTOC_SANE); - } -#endif - return (DDI_FAILURE); - } - if (lbp->dkl_vtoc.v_version != V_VERSION) { -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) { - cmn_err(CE_CONT, "pcdsklbl_chk: " - "version: 0x%x not 0x%x\n", - lbp->dkl_vtoc.v_version, - V_VERSION); - } -#endif - return (DDI_FAILURE); - } - - /* - * Check the checksum of the label - */ - sp = (short *)lbp; - sum = 0; - count = sizeof (struct dk_label) / sizeof (short); - while (count--) { - sum ^= *sp++; - } - - *cksum = sum; - if (sum) - return (DDI_FAILURE); - return (DDI_SUCCESS); -} - -void -pcinit_pmap(ata_unit_t *unitp) -{ - dsk_label_t *lblp = &unitp->lbl; - struct partition *pmapp = lblp->pmap; - uint32_t disksize; /* maximum block number */ - - /* - * clear pmap (all 20 slices) - */ - bzero((caddr_t)pmapp, sizeof (struct partition) * NUM_PARTS); - - /* - * calc total blocks on device - */ - disksize = (unitp->au_cyl + unitp->au_acyl) - * unitp->au_hd * unitp->au_sec; - - /* - * The whole disk is represented here (this is the p0 partition.) - */ - pmapp[FDISK_OFFSET].p_tag = 0; - pmapp[FDISK_OFFSET].p_flag = V_UNMNT; - pmapp[FDISK_OFFSET].p_start = 0; - pmapp[FDISK_OFFSET].p_size = disksize; - - lblp->fdiskpresent = 0; /* NO MBR fdisk record */ - lblp->uidx = FDISK_OFFSET; /* NO unix fdisk partition */ -} - -/* - * read sector 0 of the disk and call fdisk parse - */ -int -pcfdisk_read(buf_t *bp, ata_unit_t *unitp) -{ - int ret; - - /* - * read fdisk sector (device block 0) - */ - bp->b_bcount = 1 * DEV_BSIZE; - bp->b_flags = B_READ; - bp->b_blkno = 0; - - (void) pcata_strategy(bp); - if (biowait(bp)) - return (DDI_FAILURE); - - ret = pcfdisk_parse(bp, unitp); - return (ret); -} - -/* - * We have this wonderful scenario - * where there exists two different kinds of labeling schemes, - * the x86/ppc vs. Sparc - * - * Procedurely we do the following - * clear pmap[s0-s15,p0-p5] - * set pmap[p0] to entire disk - * set uidx = p0 - * - * read disk block 0 and check for fdisk record - * if (fdisk record exists) { - * set pmap[p1-p4] - * if (Solaris partiton exists) { - * set uidx to px - * } - * } - * - * if (fdisk record does not exist OR a Solaris partiton exists) { - * read disk block 1 of pmap[uidx] and check for VTOC - * if (VTOC exists) { - * set pmap[s0-s15] from vtoc - * } - * set pmap[s2] to entire Solaris partition - * } - * - * for s0 to s15 - * add start address of pmap[uidx] to pmap [s0-s15] - * (do not change incore vtoc record) - */ - -int -pcfdisk_parse(buf_t *bp, ata_unit_t *unitp) -{ - dsk_label_t *lblp = &unitp->lbl; - struct partition *pmapp = lblp->pmap; - struct mboot *mbp; - struct ipart *fdp; - int i; - struct ipart fdisk[FD_NUMPART]; - - - /* check to see if valid fdisk record exists */ - mbp = (struct mboot *)bp->b_un.b_addr; -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) - cmn_err(CE_CONT, "pcfdisk_parse " - "fdisk signature=%04x MBB_MAGIC=%04x\n", - ltohs(mbp->signature), - MBB_MAGIC); -#endif - if (ltohs(mbp->signature) == MBB_MAGIC) { - - /* fdisk record exists */ - lblp->fdiskpresent = 1; - - /* copy fdisk table so it is aligned on 4 byte boundry */ - fdp = fdisk; - bcopy((caddr_t)&(mbp->parts[0]), (caddr_t)fdp, sizeof (fdisk)); - - for (i = 1; i <= FD_NUMPART; i++, fdp++) { - int num, rel; - -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) - cmn_err(CE_CONT, "%d sy=%02x rel=%7d num=%7d\n", - i, - fdp->systid, - ltohi(fdp->relsect), - ltohi(fdp->numsect)); -#endif - - /* - * make sure numbers are reasonable - * XXX/lcl partitions can still overlap - * XXX/lcl in fdisk.h, num and rel are signed - */ - rel = ltohi(fdp->relsect); - num = ltohi(fdp->numsect); - - if (fdp->systid == 0 || - rel < 0 || - num <= 0 || - rel+num > pmapp[FDISK_OFFSET].p_size) { - continue; - } - - pmapp[i+FDISK_OFFSET].p_tag = fdp->systid; - pmapp[i+FDISK_OFFSET].p_flag = 0; - pmapp[i+FDISK_OFFSET].p_start = rel; - pmapp[i+FDISK_OFFSET].p_size = num; - if (fdp->systid == SUNIXOS || fdp->systid == SUNIXOS2) { - if (lblp->uidx == FDISK_OFFSET) - lblp->uidx = i+FDISK_OFFSET; - else if (fdp->bootid == ACTIVE) - lblp->uidx = i+FDISK_OFFSET; - } - } - } - - /* - * Partitions p0 - p4 are established correctly - * now check for Solaris vtoc - */ - - /* - * if there is no MBR (fdisk label) - * or there is an FDISK label which defines a Solaris partition - * then call rdvtoc. - * - * note: if fdisk does exist, but does not define a Solaris partiton - * s0-s15 are set to zero length - */ - if (!lblp->fdiskpresent || lblp->uidx != FDISK_OFFSET) { - /* failures leave pmap in the correct state, so we don't care */ - (void) pcdsklbl_rdvtoc(unitp, bp); - } - -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) { - cmn_err(CE_CONT, "DEFINED PARTITIONS\n"); - for (i = 0; i <= NUM_PARTS; i++) - if (pmapp[i].p_size > 0) - cmn_err(CE_CONT, "s%2d beg=%6ld siz=%ld\n", - i, - pmapp[i].p_start, - pmapp[i].p_size); - } -#endif - - return (DDI_SUCCESS); -} - -static int -pcdsklbl_rdvtoc(ata_unit_t *unitp, buf_t *bp) -{ - dsk_label_t *lblp = &unitp->lbl; - struct dk_label *lbp; /* points to data in buf_t */ - unsigned short sum; - int i; - - /* - * read the label from the uidx partition (p0-p4) - */ - bp->b_bcount = 1 * DEV_BSIZE; - bp->b_flags = B_READ; - bp->b_blkno = lblp->pmap[lblp->uidx].p_start+VTOC_OFFSET; - (void) pcata_strategy(bp); - if (biowait(bp)) { - return (DDI_FAILURE); - } - - lbp = (struct dk_label *)bp->b_un.b_addr; - if (!lbp) { - return (DDI_FAILURE); - } - - /* - * check label - */ - if (pcdsklbl_chk(lbp, &sum) == DDI_SUCCESS) { - - /* - * record label information - * copy the data from the buf_t memory to the lblp memory - */ - bcopy((caddr_t)lbp, (caddr_t)&lblp->ondsklbl, sizeof (*lbp)); - } else { -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) - cmn_err(CE_CONT, "vtoc label has invalid checksum\n"); -#endif - /* - * Since there is no valid vtoc and there should be - * create one based on the solaris partition (possibly p0) - */ - pcdsklbl_preplb(unitp); - } - - /* - * adjust the lbp to point to data in the lbl structures - * rather than the data in the buf_t structure - * this is where the data was left by either the bcopy or preplb - */ - lbp = &lblp->ondsklbl; - -#if defined(_SUNOS_VTOC_16) - bcopy((caddr_t)&lbp->dkl_vtoc.v_part, - (caddr_t)lblp->pmap, sizeof (lbp->dkl_vtoc.v_part)); -#elif defined(_SUNOS_VTOC_8) - for (i = 0; i < NDKMAP; i++) { - /* - * convert SUNOS (VTOC8) info - */ - lblp->pmap[i].p_tag = lbp->dkl_vtoc.v_part[i].p_tag; - lblp->pmap[i].p_flag = lbp->dkl_vtoc.v_part[i].p_flag; - lblp->pmap[i].p_start = lbp->dkl_map[i].dkl_cylno * - lblp->ondsklbl.dkl_nhead * lblp->ondsklbl.dkl_nsect; - lblp->pmap[i].p_size = lbp->dkl_map[i].dkl_nblk; - } -#else -#error No VTOC format defined. -#endif - - /* - * adjust the offsets of slices 0-15 or 0-7 by the base of the uidx - */ - for (i = 0; i < NDKMAP; i++) { - /* - * Initialize logical partition info when VTOC is read. - */ -#if defined(_SUNOS_VTOC_8) - lblp->un_map[i].dkl_cylno = lbp->dkl_map[i].dkl_cylno; - lblp->un_map[i].dkl_nblk = lbp->dkl_map[i].dkl_nblk; -#endif - lblp->pmap[i].p_start += lblp->pmap[lblp->uidx].p_start; - } - - return (DDI_SUCCESS); -} - -/* - * Using the disk size information in unit and the partition data (p0-p4) - * construct a default device label - * Note - all offsets for slices 0-15 are zero based - * (do not include the offset of the partition which defines s2) - * - * There is a number of cases we have to worry about: - * - * 1) There is an fdisk partition but no Solaris partition. - * In this case the s2 slice size is zero since a valid - * Solaris partition must be present for us to decide the - * the size of the Solaris partition. - * - * 2) There is an fdisk parition and a Solaris partition. - * We got here because the Solaris partition was not labeled - * or the label has been corrupted, declare the entire Solaris - * parition as the s2 slice - * - * 3) There is no fdisk partition. - * We have to declare the entire disk as the s2 slice, - * with some room for the fdisk partition (I think) - */ -static void -pcdsklbl_preplb(ata_unit_t *unitp) -{ - dsk_label_t *lblp = &unitp->lbl; - struct dk_label *odlp = &lblp->ondsklbl; /* on disk label */ - int s2size; - int nspc; - - /* sectors per cylinder */ - nspc = unitp->au_hd * unitp->au_sec; - - bzero((caddr_t)odlp, sizeof (struct dk_label)); - - odlp->dkl_vtoc.v_nparts = V_NUMPAR; - odlp->dkl_vtoc.v_sanity = VTOC_SANE; - odlp->dkl_vtoc.v_version = V_VERSION; - - odlp->dkl_pcyl = lblp->pmap[lblp->uidx].p_size / nspc; - odlp->dkl_acyl = 2; - odlp->dkl_ncyl = odlp->dkl_pcyl - odlp->dkl_acyl; - - odlp->dkl_nhead = unitp->au_hd; - odlp->dkl_nsect = unitp->au_sec; - - odlp->dkl_rpm = 3600; - - odlp->dkl_intrlv = 1; - odlp->dkl_apc = 0; - odlp->dkl_magic = DKL_MAGIC; - - /* - * set size of s2 from uidx - */ - s2size = lblp->pmap[lblp->uidx].p_size; - -#if defined(_SUNOS_VTOC_16) - /* - * If this is x86/PowerPC format label - */ - - odlp->dkl_vtoc.v_sectorsz = NBPSCTR; - - /* Add full disk slice as slice 2 to the disk */ - odlp->dkl_vtoc.v_part[USLICE_WHOLE].p_start = 0; - odlp->dkl_vtoc.v_part[USLICE_WHOLE].p_size = s2size; - odlp->dkl_vtoc.v_part[USLICE_WHOLE].p_tag = V_BACKUP; - odlp->dkl_vtoc.v_part[USLICE_WHOLE].p_flag = V_UNMNT; - - /* Boot slice */ - odlp->dkl_vtoc.v_part[8].p_start = 0; - odlp->dkl_vtoc.v_part[8].p_size = nspc; - odlp->dkl_vtoc.v_part[8].p_tag = V_BOOT; - odlp->dkl_vtoc.v_part[8].p_flag = V_UNMNT; - - (void) sprintf(odlp->dkl_vtoc.v_asciilabel, - "DEFAULT cyl %d alt %d hd %d sec %d", - odlp->dkl_ncyl, - odlp->dkl_acyl, - odlp->dkl_nhead, - odlp->dkl_nsect); -#elif defined(_SUNOS_VTOC_8) - - /* Add full disk slice as slice 2 to the disk */ - odlp->dkl_map[USLICE_WHOLE].dkl_cylno = 0; - odlp->dkl_map[USLICE_WHOLE].dkl_nblk = s2size; - - (void) sprintf(odlp->dkl_asciilabel, - "DEFAULT cyl %d alt %d hd %d sec %d", - odlp->dkl_ncyl, - odlp->dkl_acyl, - odlp->dkl_nhead, - odlp->dkl_nsect); -#else -#error No VTOC format defined. -#endif - - /* - * an on-disk label has been constructed above - * call pcdsklbl_chk with the 2nd parm pointing into the label - * will generate a correct checksum in the label - */ - (void) pcdsklbl_chk(&lblp->ondsklbl, &(lblp->ondsklbl.dkl_cksum)); -} - -int -pcdsklbl_wrvtoc(dsk_label_t *lblp, struct vtoc *vtocp, buf_t *bp) -{ - register struct dk_label *lbp, *dp; - int status; - int backup_block; - int count; - - /* - * Data is originated from vtoc. One copy of the data is stored in - * lblp->ondsklbl. This is what we think of as the copy of the lable - * on this held in memory. The other copy (to the lbp) is to be - * written out to the disk. - */ - dp = &lblp->ondsklbl; - - bp->b_bcount = 1 * DEV_BSIZE; - bp->b_flags = B_WRITE; - - lbp = (struct dk_label *)bp->b_un.b_addr; - - pcdsklbl_vtoc_to_ondsklabel(lblp, vtocp); - *lbp = lblp->ondsklbl; - - /* - * check label - */ - bp->b_blkno = lblp->pmap[lblp->uidx].p_start + VTOC_OFFSET; - -#ifdef ATA_DEBUG - if (pcata_debug & DLBL) - cmn_err(CE_NOTE, "dsklbl_wrvtoc: calling strategy \n"); -#endif - (void) pcata_strategy(bp); - status = biowait(bp); - - if (status != 0 || dp->dkl_acyl == 0) - return (status); - - /* - * DO backup copies of vtoc - */ - - backup_block = ((dp->dkl_ncyl + dp->dkl_acyl - 1) * - (dp->dkl_nhead * dp->dkl_nsect)) + - ((dp->dkl_nhead - 1) * dp->dkl_nsect) + 1; - - bcopy((caddr_t)&(lblp->ondsklbl), (caddr_t)lbp, sizeof (*lbp)); - for (count = 1; count < 6; count++) { - - bp->b_blkno = lblp->pmap[lblp->uidx].p_start+backup_block; - - /* issue read */ - (void) pcata_strategy(bp); - if (biowait(bp)) - return (bp->b_error); - - backup_block += 2; - } - return (0); -} - - - -void -pcdsklbl_ondsklabel_to_vtoc(dsk_label_t *lblp, struct vtoc *vtocp) -{ - -#if defined(_SUNOS_VTOC_16) - bcopy((caddr_t)&lblp->ondsklbl.dkl_vtoc, (caddr_t)vtocp, - sizeof (*vtocp)); -#elif defined(_SUNOS_VTOC_8) - int i; - uint32_t nblks; - struct dk_map2 *lpart; -#ifdef _SYSCALL32 - struct dk_map32 *lmap; -#else - struct dk_map *lmap; -#endif - struct partition *vpart; - /* - * Data is originated from vtoc. One copy of the data is stored in - * lblp->ondsklbl. This is what we think of as the copy of the label - * on the disk held in memory. The other copy (to the lbp) is to be - * written out to the disk. - */ - - /* - * Put appropriate vtoc structure fields into the disk label - * - */ - bcopy((caddr_t)(lblp->ondsklbl.dkl_vtoc.v_bootinfo), - (caddr_t)vtocp->v_bootinfo, sizeof (vtocp->v_bootinfo)); - - /* For now may want to add the sectorsz field to the generic structur */ - vtocp->v_sectorsz = NBPSCTR; /* sector size in bytes */ - - vtocp->v_sanity = lblp->ondsklbl.dkl_vtoc.v_sanity; - vtocp->v_version = lblp->ondsklbl.dkl_vtoc.v_version; - - bcopy((caddr_t)lblp->ondsklbl.dkl_vtoc.v_volume, - (caddr_t)vtocp->v_volume, LEN_DKL_VVOL); - - vtocp->v_nparts = lblp->ondsklbl.dkl_vtoc.v_nparts; - - bcopy((caddr_t)lblp->ondsklbl.dkl_vtoc.v_reserved, - (caddr_t)vtocp->v_reserved, sizeof (vtocp->v_reserved)); - - /* - * Note the conversion from starting sector number - * to starting cylinder number. - */ - /* Bug Check this */ - nblks = lblp->ondsklbl.dkl_nsect * lblp->ondsklbl.dkl_nhead; - - lmap = lblp->ondsklbl.dkl_map; - lpart = (struct dk_map2 *)lblp->ondsklbl.dkl_vtoc.v_part; - vpart = vtocp->v_part; - - for (i = 0; i < (int)vtocp->v_nparts; i++) { - vpart->p_tag = lpart->p_tag; - vpart->p_flag = lpart->p_flag; - vpart->p_start = lmap->dkl_cylno * nblks; - vpart->p_size = lmap->dkl_nblk; - - lmap++; - lpart++; - vpart++; - } - - bcopy((caddr_t)lblp->ondsklbl.dkl_vtoc.v_timestamp, - (caddr_t)vtocp->timestamp, sizeof (vtocp->timestamp)); - - bcopy((caddr_t)lblp->ondsklbl.dkl_asciilabel, - (caddr_t)vtocp->v_asciilabel, - LEN_DKL_ASCII); - -#else -#error No VTOC format defined. -#endif -} - -void -pcdsklbl_vtoc_to_ondsklabel(dsk_label_t *lblp, struct vtoc *vtocp) -{ -#if defined(_SUNOS_VTOC_16) - bcopy((caddr_t)vtocp, (caddr_t)&(lblp->ondsklbl.dkl_vtoc), - sizeof (*vtocp)); -#elif defined(_SUNOS_VTOC_8) - /* - * Put appropriate vtoc structure fields into the disk label - * - */ - { - int i; - uint32_t nblks; - struct dk_map2 *lpart; -#ifdef _SYSCALL32 - struct dk_map32 *lmap; -#else - struct dk_map *lmap; -#endif - struct partition *vpart; - register struct dk_label *dp; - - /* - * Data is originated from vtoc. One copy of the data is stored in - * lblp->ondsklbl. This is what we think of as the copy of the label - * on this disk held in memory. - */ - - dp = &lblp->ondsklbl; - - bcopy((caddr_t)vtocp->v_bootinfo, - (caddr_t)(lblp->ondsklbl.dkl_vtoc.v_bootinfo), - sizeof (vtocp->v_bootinfo)); - - lblp->ondsklbl.dkl_vtoc.v_sanity = vtocp->v_sanity; - lblp->ondsklbl.dkl_vtoc.v_version = vtocp->v_version; - - bcopy((caddr_t)vtocp->v_volume, - (caddr_t)lblp->ondsklbl.dkl_vtoc.v_volume, - LEN_DKL_VVOL); - - lblp->ondsklbl.dkl_vtoc.v_nparts = vtocp->v_nparts; - - bcopy((caddr_t)vtocp->v_reserved, - (caddr_t)lblp->ondsklbl.dkl_vtoc.v_reserved, - sizeof (vtocp->v_reserved)); - - /* - * Note the conversion from starting sector number - * to starting cylinder number. - */ - nblks = dp->dkl_nsect * dp->dkl_nhead; - lmap = lblp->ondsklbl.dkl_map; - lpart = (struct dk_map2 *)lblp->ondsklbl.dkl_vtoc.v_part; - vpart = vtocp->v_part; - - for (i = 0; i < (int)vtocp->v_nparts; i++) { - lpart->p_tag = vpart->p_tag; - lpart->p_flag = vpart->p_flag; - lmap->dkl_cylno = vpart->p_start / nblks; - lmap->dkl_nblk = vpart->p_size; - - lmap++; - lpart++; - vpart++; - } - - bcopy((caddr_t)vtocp->timestamp, - (caddr_t)lblp->ondsklbl.dkl_vtoc.v_timestamp, - sizeof (vtocp->timestamp)); - - bcopy((caddr_t)vtocp->v_asciilabel, - (caddr_t)lblp->ondsklbl.dkl_asciilabel, - LEN_DKL_ASCII); - - } -#else -#error No VTOC format defined. -#endif - - lblp->ondsklbl.dkl_cksum = 0; - (void) pcdsklbl_chk(&lblp->ondsklbl, &(lblp->ondsklbl.dkl_cksum)); -} - -void -pcdsklbl_dgtoug(struct dk_geom *up, struct dk_label *dp) -{ - -#ifdef ATA_DEBUG - cmn_err(CE_CONT, "pcdsklbl_dgtoug: pcyl = %d ncyl = %d acyl = %d" - " head= %d sect = %d intrlv = %d \n", - dp->dkl_pcyl, - dp->dkl_ncyl, - dp->dkl_acyl, - dp->dkl_nhead, - dp->dkl_nsect, - dp->dkl_intrlv); -#endif - - up->dkg_pcyl = dp->dkl_pcyl; - up->dkg_ncyl = dp->dkl_ncyl; - up->dkg_acyl = dp->dkl_acyl; -#if !defined(__sparc) - up->dkg_bcyl = dp->dkl_bcyl; -#endif - up->dkg_nhead = dp->dkl_nhead; - up->dkg_nsect = dp->dkl_nsect; - up->dkg_intrlv = dp->dkl_intrlv; - up->dkg_apc = dp->dkl_apc; - up->dkg_rpm = dp->dkl_rpm; - up->dkg_write_reinstruct = dp->dkl_write_reinstruct; - up->dkg_read_reinstruct = dp->dkl_read_reinstruct; -} - - - - -void -pcdsklbl_ugtodg(struct dk_geom *up, struct dk_label *dp) -{ - dp->dkl_pcyl = up->dkg_pcyl; - dp->dkl_ncyl = up->dkg_ncyl; - dp->dkl_acyl = up->dkg_acyl; -#if !defined(__sparc) - dp->dkl_bcyl = up->dkg_bcyl; -#endif - dp->dkl_nhead = up->dkg_nhead; - dp->dkl_nsect = up->dkg_nsect; - dp->dkl_intrlv = up->dkg_intrlv; - dp->dkl_apc = up->dkg_apc; - dp->dkl_rpm = up->dkg_rpm; - dp->dkl_write_reinstruct = up->dkg_write_reinstruct; - dp->dkl_read_reinstruct = up->dkg_read_reinstruct; -} diff --git a/usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE b/usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE deleted file mode 100644 index 0b1d072bb3..0000000000 --- a/usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE.descrip b/usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE.descrip deleted file mode 100644 index 521a207309..0000000000 --- a/usr/src/uts/common/io/pcwl/THIRDPARTYLICENSE.descrip +++ /dev/null @@ -1 +0,0 @@ -PCWL DRIVER diff --git a/usr/src/uts/common/io/pcwl/pcwl.c b/usr/src/uts/common/io/pcwl/pcwl.c deleted file mode 100644 index bf1bfc7fd4..0000000000 --- a/usr/src/uts/common/io/pcwl/pcwl.c +++ /dev/null @@ -1,4528 +0,0 @@ -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/conf.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/dlpi.h> -#include <sys/ethernet.h> -#include <sys/strsubr.h> -#include <sys/strsun.h> -#include <sys/stat.h> -#include <sys/byteorder.h> -#include <sys/pccard.h> -#include <sys/pci.h> -#include <sys/policy.h> -#include <sys/mac_provider.h> -#include <sys/stream.h> -#include <inet/common.h> -#include <inet/nd.h> -#include <inet/mi.h> - -#include "pcwl.h" -#include <sys/mac_wifi.h> -#include <inet/wifi_ioctl.h> - -#ifdef DEBUG -#define PCWL_DBG_BASIC 0x1 -#define PCWL_DBG_INFO 0x2 -#define PCWL_DBG_SEND 0x4 -#define PCWL_DBG_RCV 0x8 -#define PCWL_DBG_LINKINFO 0x10 -uint32_t pcwl_debug = 0; -#define PCWLDBG(x) \ - if (pcwl_debug & PCWL_DBG_BASIC) cmn_err x -#else -#define PCWLDBG(x) -#endif - -/* for pci card */ -static ddi_device_acc_attr_t accattr = { - DDI_DEVICE_ATTR_V0, - DDI_NEVERSWAP_ACC, - DDI_STRICTORDER_ACC, - DDI_DEFAULT_ACC -}; - -void *pcwl_soft_state_p = NULL; -static int pcwl_device_type; - -static int pcwl_m_setprop(void *arg, const char *pr_name, - mac_prop_id_t wldp_pr_num, uint_t wldp_length, - const void *wldp_buf); -static int pcwl_m_getprop(void *arg, const char *pr_name, - mac_prop_id_t wldp_pr_num, uint_t wldp_length, void *wldp_buf); -static void pcwl_m_propinfo(void *arg, const char *pr_name, - mac_prop_id_t wlpd_pr_num, mac_prop_info_handle_t mph); -static void -pcwl_delay(pcwl_maci_t *, clock_t); - -mac_callbacks_t pcwl_m_callbacks = { - MC_IOCTL | MC_SETPROP | MC_GETPROP | MC_PROPINFO, - pcwl_gstat, - pcwl_start, - pcwl_stop, - pcwl_prom, - pcwl_sdmulti, - pcwl_saddr, - pcwl_tx, - NULL, - pcwl_ioctl, - NULL, - NULL, - NULL, - pcwl_m_setprop, - pcwl_m_getprop, - pcwl_m_propinfo -}; - -static char *pcwl_name_str = "pcwl"; - -#ifdef __sparc -#define pcwl_quiesce ddi_quiesce_not_supported -#else -static int pcwl_quiesce(dev_info_t *); -#endif - -DDI_DEFINE_STREAM_OPS(pcwl_dev_ops, nulldev, pcwl_probe, pcwl_attach, - pcwl_detach, nodev, NULL, D_MP, NULL, pcwl_quiesce); - -extern struct mod_ops mod_driverops; -static struct modldrv modldrv = { - &mod_driverops, - "Lucent/PRISM-II 802.11b driver", - &pcwl_dev_ops -}; - -static struct modlinkage modlinkage = { - MODREV_1, (void *)&modldrv, NULL - }; - -int -_init(void) -{ - int stat; - - /* Allocate soft state */ - if ((stat = ddi_soft_state_init(&pcwl_soft_state_p, - sizeof (pcwl_maci_t), N_PCWL)) != DDI_SUCCESS) - return (stat); - - mac_init_ops(&pcwl_dev_ops, "pcwl"); - wl_frame_default.wl_dat[0] = htons(WL_SNAP_WORD0); - wl_frame_default.wl_dat[1] = htons(WL_SNAP_WORD1); - stat = mod_install(&modlinkage); - if (stat != DDI_SUCCESS) { - mac_fini_ops(&pcwl_dev_ops); - ddi_soft_state_fini(&pcwl_soft_state_p); - } - return (stat); -} - -int -_fini(void) -{ - int stat; - - if ((stat = mod_remove(&modlinkage)) != DDI_SUCCESS) - return (stat); - mac_fini_ops(&pcwl_dev_ops); - ddi_soft_state_fini(&pcwl_soft_state_p); - - return (stat); -} - -int -_info(struct modinfo *modinfop) -{ - return (mod_info(&modlinkage, modinfop)); -} - -static int -pcwl_probe(dev_info_t *dip) -{ - int len, ret; - char *buf; - dev_info_t *pdip = ddi_get_parent(dip); - - ret = ddi_getlongprop(DDI_DEV_T_ANY, pdip, 0, "device_type", - (caddr_t)&buf, &len); - if (ret != DDI_SUCCESS) - return (DDI_PROBE_FAILURE); - - PCWLDBG((CE_NOTE, "pcwl probe: device_type %s\n", buf)); - if ((strcmp(buf, "pccard") == 0) || (strcmp(buf, "pcmcia") == 0)) { - pcwl_device_type = PCWL_DEVICE_PCCARD; - ret = DDI_PROBE_SUCCESS; - } else if (strcmp(buf, "pci") == 0) { - pcwl_device_type = PCWL_DEVICE_PCI; - ret = DDI_PROBE_SUCCESS; - } else { - ret = DDI_PROBE_FAILURE; - } - kmem_free(buf, len); - return (ret); -} - -static int -pcwl_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - int ret, i; - int instance; - uint16_t stat; - uint32_t err; - pcwl_maci_t *pcwl_p; - wifi_data_t wd = { 0 }; - mac_register_t *macp; - modify_config_t cfgmod; - char strbuf[256]; - - PCWLDBG((CE_NOTE, "pcwl attach: dip=0x%p cmd=%x\n", (void *)dip, cmd)); - if (cmd != DDI_ATTACH) - goto attach_fail1; - /* - * Allocate soft state associated with this instance. - */ - if (ddi_soft_state_zalloc(pcwl_soft_state_p, - ddi_get_instance(dip)) != DDI_SUCCESS) { - cmn_err(CE_CONT, "pcwl attach: alloc softstate failed\n"); - goto attach_fail1; - } - pcwl_p = (pcwl_maci_t *)ddi_get_soft_state(pcwl_soft_state_p, - ddi_get_instance(dip)); - pcwl_p->pcwl_device_type = pcwl_device_type; - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) { - if (ddi_regs_map_setup(dip, 0, - (caddr_t *)&pcwl_p->pcwl_cfg_base, 0, 0, - &accattr, &pcwl_p->pcwl_cfg_handle) != DDI_SUCCESS) { - cmn_err(CE_WARN, "pcwl(pci) attach: pci_regs_map_setup" - " failed\n"); - goto attach_fail2; - } - - stat = ddi_get16(pcwl_p->pcwl_cfg_handle, - (uint16_t *)(pcwl_p->pcwl_cfg_base + PCI_CONF_COMM)); - stat |= (PCI_COMM_IO | PCI_COMM_MAE); - ddi_put16(pcwl_p->pcwl_cfg_handle, - (uint16_t *)(pcwl_p->pcwl_cfg_base + PCI_CONF_COMM), stat); - stat = ddi_get16(pcwl_p->pcwl_cfg_handle, - (uint16_t *)(pcwl_p->pcwl_cfg_base + PCI_CONF_COMM)); - if ((stat & (PCI_COMM_IO | PCI_COMM_MAE)) != - (PCI_COMM_IO | PCI_COMM_MAE)) { - cmn_err(CE_WARN, "pcwl(pci) attach: pci command" - " reg enable failed\n"); - goto attach_fail2a; - } - - - if (ddi_regs_map_setup(dip, 1, (caddr_t *)&pcwl_p->pcwl_bar, - 0, 0, &accattr, (ddi_acc_handle_t *)&pcwl_p->pcwl_handle) - != DDI_SUCCESS) { - cmn_err(CE_WARN, "pcwl(pci) attach: pci_regs_map_setup" - " failed\n"); - goto attach_fail2a; - } - PCWLDBG((CE_NOTE, "pcwl(pci): regs_map_setup,bar=%p\n", - (void *)pcwl_p->pcwl_bar)); - - /* - * tricky! copy from freebsd code. - */ - PCWL_WRITE(pcwl_p, 0x26, 0x80); - drv_usecwait(500000); - PCWL_WRITE(pcwl_p, 0x26, 0x0); - drv_usecwait(500000); - - for (i = 0; i < WL_TIMEOUT; i++) { - PCWL_READ(pcwl_p, 0x0, stat); - if (stat & WL_CMD_BUSY) - drv_usecwait(10); - else - break; - } - if (i == WL_TIMEOUT) { - cmn_err(CE_WARN, "pcwl(pci) attach: hardware init" - " failed\n"); - goto attach_fail3; - } - - /* - * magic number verification. - * tricky! copy from freebsd code. - */ - PCWL_WRITE(pcwl_p, 0x28, 0x4a2d); - PCWL_READ(pcwl_p, 0x28, stat); - PCWLDBG((CE_NOTE, "pcwl(pci):magic number = %x\n", stat)); - if (stat != 0x4a2d) { - cmn_err(CE_WARN, "pcwl(pci) attach: magic verify" - " failed\n"); - goto attach_fail3; - } - } - pcwl_p->pcwl_dip = dip; - pcwl_p->pcwl_flag = 0; - pcwl_p->pcwl_socket = ddi_getprop(DDI_DEV_T_NONE, dip, - DDI_PROP_DONTPASS, "socket", -1); - pcwl_p->pcwl_reschedule_need = B_FALSE; - - if (ddi_get_iblock_cookie(dip, - 0, &pcwl_p->pcwl_ib_cookie) != DDI_SUCCESS) { - cmn_err(CE_WARN, "pcwl attach: get_iblk_cookie failed\n"); - goto attach_fail3; - } - - mutex_init(&pcwl_p->pcwl_glock, NULL, MUTEX_DRIVER, - pcwl_p->pcwl_ib_cookie); - mutex_init(&pcwl_p->pcwl_scanlist_lock, NULL, MUTEX_DRIVER, - pcwl_p->pcwl_ib_cookie); - mutex_init(&pcwl_p->pcwl_txring.wl_tx_lock, NULL, MUTEX_DRIVER, - pcwl_p->pcwl_ib_cookie); - - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) { - if (ret = ddi_add_intr(dip, 0, NULL, NULL, - pcwl_intr, (caddr_t)pcwl_p)) { - cmn_err(CE_NOTE, "pcwl(pci) attach: add intr failed\n"); - goto attach_fail3a; - } - } else if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCCARD) { - if (ret = pcwl_register_cs(dip, pcwl_p)) { - cmn_err(CE_WARN, "pcwl attach(pccard): " - "register_cs err %x\n", ret); - goto attach_fail3a; - } - } else { - cmn_err(CE_WARN, "pcwl attach: unsupported device type\n"); - goto attach_fail3a; - } - mutex_enter(&pcwl_p->pcwl_glock); - if (ret = pcwl_reset_backend(pcwl_p)) { - cmn_err(CE_WARN, "pcwl attach: reset_backend failed %x\n", ret); - mutex_exit(&pcwl_p->pcwl_glock); - goto attach_fail4; - } - if (ret = pcwl_get_cap(pcwl_p)) { /* sets macaddr for mac_register */ - cmn_err(CE_WARN, "pcwl attach: get_cap failed %x\n", ret); - mutex_exit(&pcwl_p->pcwl_glock); - goto attach_fail4; - } - mutex_exit(&pcwl_p->pcwl_glock); - /* - * Provide initial settings for the WiFi plugin; whenever this - * information changes, we need to call mac_pdata_update() - */ - wd.wd_secalloc = WIFI_SEC_NONE; - wd.wd_opmode = IEEE80211_M_STA; - - macp = mac_alloc(MAC_VERSION); - if (macp == NULL) { - PCWLDBG((CE_NOTE, "pcwl attach: " - "MAC version mismatch\n")); - goto attach_fail4; - } - - macp->m_type_ident = MAC_PLUGIN_IDENT_WIFI; - macp->m_driver = pcwl_p; - macp->m_dip = dip; - macp->m_src_addr = pcwl_p->pcwl_mac_addr; - macp->m_callbacks = &pcwl_m_callbacks; - macp->m_min_sdu = 0; - macp->m_max_sdu = IEEE80211_MTU; - macp->m_pdata = &wd; - macp->m_pdata_size = sizeof (wd); - - err = mac_register(macp, &pcwl_p->pcwl_mh); - mac_free(macp); - if (err != 0) { - PCWLDBG((CE_NOTE, "pcwl attach: " - "mac_register err\n")); - goto attach_fail4; - } - - mutex_enter(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCCARD) { - /* - * turn on CS interrupt - */ - cfgmod.Attributes = CONF_ENABLE_IRQ_STEERING | - CONF_IRQ_CHANGE_VALID; - cfgmod.Vpp1 = 0; - cfgmod.Vpp2 = 0; - (void) csx_ModifyConfiguration(pcwl_p->pcwl_chdl, &cfgmod); - - } - if (ret = pcwl_init_nicmem(pcwl_p)) { - cmn_err(CE_WARN, "pcwl(pccard) attach: pcwl_init_nicmem" - " failed %x\n", ret); - mutex_exit(&pcwl_p->pcwl_glock); - goto attach_fail5; - } - pcwl_chip_type(pcwl_p); - if (ret = pcwl_loaddef_rf(pcwl_p)) { - cmn_err(CE_WARN, "pcwl attach: config_rf failed%x\n", ret); - mutex_exit(&pcwl_p->pcwl_glock); - goto attach_fail5; - } - (void) pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0); - pcwl_stop_locked(pcwl_p); /* leaves interface down */ - list_create(&pcwl_p->pcwl_scan_list, sizeof (wl_scan_list_t), - offsetof(wl_scan_list_t, wl_scan_node)); - pcwl_p->pcwl_scan_num = 0; - mutex_exit(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_scanlist_timeout_id = timeout(pcwl_scanlist_timeout, - pcwl_p, drv_usectohz(1000000)); - instance = ddi_get_instance(dip); - (void) snprintf(strbuf, sizeof (strbuf), "pcwl%d", instance); - if (ddi_create_minor_node(dip, strbuf, S_IFCHR, - instance + 1, DDI_NT_NET_WIFI, 0) != DDI_SUCCESS) { - goto attach_fail6; - } - pcwl_p->pcwl_flag |= PCWL_ATTACHED; - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) { - pcwl_p->pcwl_flag |= PCWL_CARD_READY; - } - return (DDI_SUCCESS); -attach_fail6: - if (pcwl_p->pcwl_scanlist_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_scanlist_timeout_id); - pcwl_p->pcwl_scanlist_timeout_id = 0; - } - list_destroy(&pcwl_p->pcwl_scan_list); -attach_fail5: - (void) mac_unregister(pcwl_p->pcwl_mh); -attach_fail4: - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) { - ddi_remove_intr(dip, 0, pcwl_p->pcwl_ib_cookie); - } else if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCCARD) { - pcwl_unregister_cs(pcwl_p); - } -attach_fail3a: - pcwl_destroy_locks(pcwl_p); -attach_fail3: - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) - ddi_regs_map_free(&pcwl_p->pcwl_handle); -attach_fail2a: - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) - ddi_regs_map_free(&pcwl_p->pcwl_cfg_handle); -attach_fail2: - ddi_soft_state_free(pcwl_soft_state_p, ddi_get_instance(dip)); -attach_fail1: - return (DDI_FAILURE); -} - -static int -pcwl_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - pcwl_maci_t *pcwl_p; - wl_scan_list_t *scan_item0; - int ret; - pcwl_p = ddi_get_soft_state(pcwl_soft_state_p, ddi_get_instance(dip)); - - PCWLDBG((CE_NOTE, "pcwl detach: dip=0x%p cmd=%x\n", (void *)dip, cmd)); - if (cmd != DDI_DETACH) - return (DDI_FAILURE); - if (!(pcwl_p->pcwl_flag & PCWL_ATTACHED)) - return (DDI_FAILURE); - - ret = mac_disable(pcwl_p->pcwl_mh); - if (ret != 0) - return (DDI_FAILURE); - - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) { - mutex_enter(&pcwl_p->pcwl_glock); - (void) pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0); - PCWL_DISABLE_INTR(pcwl_p); - mutex_exit(&pcwl_p->pcwl_glock); - } - if (pcwl_p->pcwl_scanlist_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_scanlist_timeout_id); - pcwl_p->pcwl_scanlist_timeout_id = 0; - } - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - mutex_enter(&pcwl_p->pcwl_scanlist_lock); - scan_item0 = list_head(&pcwl_p->pcwl_scan_list); - while (scan_item0) { - pcwl_delete_scan_item(pcwl_p, scan_item0); - scan_item0 = list_head(&pcwl_p->pcwl_scan_list); - } - list_destroy(&pcwl_p->pcwl_scan_list); - mutex_exit(&pcwl_p->pcwl_scanlist_lock); - (void) mac_unregister(pcwl_p->pcwl_mh); - - if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) { - mutex_enter(&pcwl_p->pcwl_glock); - ddi_remove_intr(dip, 0, pcwl_p->pcwl_ib_cookie); - ddi_regs_map_free(&pcwl_p->pcwl_handle); - ddi_regs_map_free(&pcwl_p->pcwl_cfg_handle); - mutex_exit(&pcwl_p->pcwl_glock); - } else if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCCARD) { - pcwl_unregister_cs(pcwl_p); - } - pcwl_destroy_locks(pcwl_p); - ddi_remove_minor_node(dip, NULL); - ddi_soft_state_free(pcwl_soft_state_p, ddi_get_instance(dip)); - return (DDI_SUCCESS); -} - -/* - * card services and event handlers - */ -static int -pcwl_register_cs(dev_info_t *dip, pcwl_maci_t *pcwl_p) -{ - int ret; - client_reg_t cr; - client_handle_t chdl; /* uint encoding of socket, function, client */ - get_status_t card_status; - request_socket_mask_t sock_req; - - bzero(&cr, sizeof (cr)); - cr.Attributes = INFO_IO_CLIENT|INFO_CARD_EXCL|INFO_CARD_SHARE; - cr.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_REGISTRATION_COMPLETE | CS_EVENT_CARD_REMOVAL_LOWP | - CS_EVENT_CARD_READY | CS_EVENT_PM_RESUME | - CS_EVENT_PM_SUSPEND | CS_EVENT_CLIENT_INFO; - cr.event_callback_args.client_data = pcwl_p; - cr.Version = CS_VERSION; - cr.event_handler = (csfunction_t *)pcwl_ev_hdlr; - cr.dip = dip; - (void) strcpy(cr.driver_name, pcwl_name_str); - if (ret = csx_RegisterClient(&chdl, &cr)) { - cmn_err(CE_WARN, "pcwl: RegisterClient failed %x\n", ret); - goto regcs_ret; - } - pcwl_p->pcwl_chdl = chdl; - - bzero(&card_status, sizeof (card_status)); - (void) csx_GetStatus(chdl, &card_status); - PCWLDBG((CE_NOTE, - "pcwl: register_cs: Sock=%x CState=%x SState=%x rState=%x\n", - card_status.Socket, card_status.CardState, - card_status.SocketState, card_status.raw_CardState)); - if (!(card_status.CardState & CS_STATUS_CARD_INSERTED)) { - /* card is not present, why are we attaching ? */ - ret = CS_NO_CARD; - goto regcs_unreg; - } - cv_init(&pcwl_p->pcwl_cscv, NULL, CV_DRIVER, NULL); - mutex_init(&pcwl_p->pcwl_cslock, NULL, MUTEX_DRIVER, *cr.iblk_cookie); - mutex_enter(&pcwl_p->pcwl_cslock); - if (ret = csx_MapLogSocket(chdl, &pcwl_p->pcwl_log_sock)) { - cmn_err(CE_WARN, "pcwl: MapLogSocket failed %x\n", ret); - goto regcs_fail; - } - PCWLDBG((CE_NOTE, - "pcwl: register_cs: LogSock=%x PhyAdapter=%x PhySock=%x\n", - pcwl_p->pcwl_log_sock.LogSocket, - pcwl_p->pcwl_log_sock.PhyAdapter, - pcwl_p->pcwl_log_sock.PhySocket)); - /* turn on initialization events */ - sock_req.Socket = 0; - sock_req.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_REGISTRATION_COMPLETE; - if (ret = csx_RequestSocketMask(chdl, &sock_req)) { - cmn_err(CE_WARN, "pcwl: RequestSocketMask failed %x\n", ret); - goto regcs_fail; - } - /* wait for and process card insertion events */ - while (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) - cv_wait(&pcwl_p->pcwl_cscv, &pcwl_p->pcwl_cslock); - mutex_exit(&pcwl_p->pcwl_cslock); - - pcwl_p->pcwl_flag |= PCWL_CS_REGISTERED; - return (PCWL_SUCCESS); -regcs_fail: - mutex_destroy(&pcwl_p->pcwl_cslock); - cv_destroy(&pcwl_p->pcwl_cscv); -regcs_unreg: - (void) csx_DeregisterClient(chdl); -regcs_ret: - pcwl_p->pcwl_flag &= ~PCWL_CS_REGISTERED; - return (ret); -} - -static void -pcwl_unregister_cs(pcwl_maci_t *pcwl_p) -{ - int ret; - release_socket_mask_t mask; - mask.Socket = pcwl_p->pcwl_socket; - - /* - * The card service not registered means register_cs function - * doesnot return TRUE. Then all the lelated resource has been - * released in register_cs. - */ - if (!(pcwl_p->pcwl_flag | PCWL_CS_REGISTERED)) - return; - - if (ret = csx_ReleaseSocketMask(pcwl_p->pcwl_chdl, &mask)) - cmn_err(CE_WARN, "pcwl: ReleaseSocket mask failed %x\n", ret); - - if (pcwl_p->pcwl_flag & PCWL_CARD_READY) { - pcwl_card_remove(pcwl_p); - pcwl_p->pcwl_flag &= ~PCWL_CARD_READY; - } - mutex_destroy(&pcwl_p->pcwl_cslock); - cv_destroy(&pcwl_p->pcwl_cscv); - if (ret = csx_DeregisterClient(pcwl_p->pcwl_chdl)) - cmn_err(CE_WARN, "pcwl: Deregister failed %x\n", ret); -} - -static void -pcwl_destroy_locks(pcwl_maci_t *pcwl_p) -{ - mutex_destroy(&pcwl_p->pcwl_txring.wl_tx_lock); - mutex_destroy(&pcwl_p->pcwl_scanlist_lock); - mutex_destroy(&pcwl_p->pcwl_glock); -} - -static void -pcwl_do_suspend(pcwl_maci_t *pcwl_p); - -static int -pcwl_ev_hdlr(event_t event, int priority, event_callback_args_t *arg) -{ - int ret = CS_SUCCESS; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg->client_data; - client_info_t *ci_p = (client_info_t *)&arg->client_info; - - mutex_enter(&pcwl_p->pcwl_cslock); - switch (event) { - case CS_EVENT_CARD_INSERTION: - ret = pcwl_card_insert(pcwl_p); - cv_broadcast(&pcwl_p->pcwl_cscv); - break; - case CS_EVENT_REGISTRATION_COMPLETE: - cv_broadcast(&pcwl_p->pcwl_cscv); - break; - case CS_EVENT_CARD_REMOVAL: - if (priority & CS_EVENT_PRI_HIGH) - break; - pcwl_card_remove(pcwl_p); - cv_broadcast(&pcwl_p->pcwl_cscv); - break; - case CS_EVENT_CLIENT_INFO: - if (GET_CLIENT_INFO_SUBSVC(ci_p->Attributes) != - CS_CLIENT_INFO_SUBSVC_CS) - break; - - ci_p->Revision = 0x0101; - ci_p->CSLevel = CS_VERSION; - ci_p->RevDate = CS_CLIENT_INFO_MAKE_DATE(9, 12, 14); - (void) strcpy(ci_p->ClientName, PCWL_IDENT_STRING); - (void) strcpy(ci_p->VendorName, CS_SUN_VENDOR_DESCRIPTION); - ci_p->Attributes |= CS_CLIENT_INFO_VALID; - break; - case CS_EVENT_PM_SUSPEND: - pcwl_do_suspend(pcwl_p); - break; - default: - ret = CS_UNSUPPORTED_EVENT; - break; - } - mutex_exit(&pcwl_p->pcwl_cslock); - return (ret); -} - -/* - * assume card is already removed, don't touch the hardware - */ -static void -pcwl_do_suspend(pcwl_maci_t *pcwl_p) -{ - int ret; - - if (pcwl_p->pcwl_flag & PCWL_CARD_LINKUP) { - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - mutex_enter(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_flag &= ~PCWL_CARD_LINKUP; - (void) pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0); - /* - * A workaround here: If the card is in ad-hoc mode, the - * following scan will not work correctly, so any - * 'dladm connect-wifi' which need a scan first will not - * succeed. software reset the card here as a workround. - */ - if ((pcwl_p->pcwl_rf.rf_porttype == WL_BSS_IBSS) && - (pcwl_p->pcwl_chip_type == PCWL_CHIP_LUCENT)) { - (void) pcwl_reset_backend(pcwl_p); - (void) pcwl_init_nicmem(pcwl_p); - pcwl_start_locked(pcwl_p); - } - if (ret = pcwl_loaddef_rf(pcwl_p)) { - PCWLDBG((CE_WARN, "cfg_loaddef_err %d\n", ret)); - } - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - PCWLDBG((CE_WARN, "set enable cmd err\n")); - } - pcwl_delay(pcwl_p, 1000000); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - PCWLDBG((CE_WARN, "set disable cmd err\n")); - } - mac_link_update(GLD3(pcwl_p), LINK_STATE_DOWN); - mutex_exit(&pcwl_p->pcwl_glock); - } - pcwl_p->pcwl_flag |= PCWL_CARD_SUSPEND; - PCWLDBG((CE_WARN, "pcwl: do suspend\n")); -} - - -static int -pcwl_card_insert(pcwl_maci_t *pcwl_p) -{ - int ret, hi, lo; - tuple_t tuple; - cisparse_t cisparse; - io_req_t io; - irq_req_t irq; - config_req_t cfg; - cistpl_config_t config; - cistpl_cftable_entry_t *tbl_p; - register client_handle_t chdl = pcwl_p->pcwl_chdl; - modify_config_t cfgmod; - - bzero(&tuple, sizeof (tuple)); - tuple.DesiredTuple = CISTPL_MANFID; - if (ret = csx_GetFirstTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcwl: get manufacture id failed %x\n", ret); - goto insert_ret; - } - bzero(&cisparse, sizeof (cisparse)); - if (ret = csx_Parse_CISTPL_MANFID(chdl, &tuple, &cisparse.manfid)) { - cmn_err(CE_WARN, "pcwl: parse manufacture id failed %x\n", ret); - goto insert_ret; - } - - /* - * verify manufacture ID - */ - PCWLDBG((CE_NOTE, "pcwl insert: manufacturer_id=%x card=%x\n", - cisparse.manfid.manf, cisparse.manfid.card)); - bzero(&tuple, sizeof (tuple)); - tuple.DesiredTuple = CISTPL_FUNCID; - if (ret = csx_GetFirstTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcwl: get function id failed %x\n", ret); - goto insert_ret; - } - bzero(&cisparse, sizeof (cisparse)); - if (ret = csx_Parse_CISTPL_FUNCID(chdl, &tuple, &cisparse.funcid)) { - cmn_err(CE_WARN, "pcwl: parse function id failed %x\n", ret); - goto insert_ret; - } - - /* - * verify function ID - */ - PCWLDBG((CE_NOTE, "insert:fun_id=%x\n", cisparse.funcid.function)); - bzero(&tuple, sizeof (tuple)); - tuple.DesiredTuple = CISTPL_CONFIG; - if (ret = csx_GetFirstTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcwl: get config failed %x\n", ret); - goto insert_ret; - } - bzero(&config, sizeof (config)); - if (ret = csx_Parse_CISTPL_CONFIG(chdl, &tuple, &config)) { - cmn_err(CE_WARN, "pcwl: parse config failed %x\n", ret); - goto insert_ret; - } - PCWLDBG((CE_NOTE, - "pcwl: config present=%x nr=%x hr=%x regs[0]=%x base=%x last=%x\n", - config.present, config.nr, config.hr, config.regs[0], - config.base, config.last)); - hi = 0; - lo = (int)-1; /* really big number */ - tbl_p = &cisparse.cftable; - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - for (tbl_p->index = 0; tbl_p->index <= config.hr; ) { - PCWLDBG((CE_NOTE, "pcwl insert:tuple idx=%x:\n", tbl_p->index)); - if (ret = csx_GetNextTuple(chdl, &tuple)) { - cmn_err(CE_WARN, "pcwl: get cftable failed %x\n", - ret); - break; - } - bzero((caddr_t)&cisparse, sizeof (cisparse)); - if (ret = csx_Parse_CISTPL_CFTABLE_ENTRY(chdl, &tuple, tbl_p)) { - cmn_err(CE_WARN, "pcwl: parse cftable failed %x\n", - ret); - break; - } - if (tbl_p->flags & CISTPL_CFTABLE_TPCE_FS_PWR && - tbl_p->pd.flags & CISTPL_CFTABLE_TPCE_FS_PWR_VCC) { - if (tbl_p->pd.pd_vcc.avgI > hi) { - hi = tbl_p->pd.pd_vcc.avgI; - pcwl_p->pcwl_config_hi = tbl_p->index; - } - if (tbl_p->pd.pd_vcc.avgI < lo) { - lo = tbl_p->pd.pd_vcc.avgI; - pcwl_p->pcwl_config = tbl_p->index; - } - } - if (tbl_p->flags & CISTPL_CFTABLE_TPCE_DEFAULT) { - if (tbl_p->pd.flags & CISTPL_CFTABLE_TPCE_FS_PWR_VCC) - pcwl_p->pcwl_vcc = tbl_p->pd.pd_vcc.nomV; - if (tbl_p->flags & CISTPL_CFTABLE_TPCE_FS_IO) - pcwl_p->pcwl_iodecode = tbl_p->io.addr_lines; - } - } - PCWLDBG((CE_NOTE, "pcwl: insert:cfg_hi=%x cfg=%x vcc=%x iodecode=%x\n", - pcwl_p->pcwl_config_hi, pcwl_p->pcwl_config, - pcwl_p->pcwl_vcc, pcwl_p->pcwl_iodecode)); - bzero(&io, sizeof (io)); - io.BasePort1.base = 0; - io.NumPorts1 = 1 << pcwl_p->pcwl_iodecode; - io.Attributes1 = IO_DATA_PATH_WIDTH_16; - io.IOAddrLines = pcwl_p->pcwl_iodecode; - if (ret = csx_RequestIO(chdl, &io)) { - cmn_err(CE_WARN, "pcwl: RequestIO failed %x\n", ret); - goto insert_ret; - } - pcwl_p->pcwl_port = io.BasePort1.handle; - if (ret = ddi_add_softintr(DIP(pcwl_p), DDI_SOFTINT_HIGH, - &pcwl_p->pcwl_softint_id, &pcwl_p->pcwl_ib_cookie, NULL, - pcwl_intr, (caddr_t)pcwl_p)) { - cmn_err(CE_NOTE, "pcwl(pccard): add softintr failed\n"); - goto insert_ret; - } - irq.Attributes = IRQ_TYPE_EXCLUSIVE; - irq.irq_handler = ddi_intr_hilevel(DIP(pcwl_p), 0) ? - (csfunction_t *)pcwl_intr_hi : (csfunction_t *)pcwl_intr; - irq.irq_handler_arg = pcwl_p; - if (ret = csx_RequestIRQ(pcwl_p->pcwl_chdl, &irq)) { - cmn_err(CE_WARN, "pcwl: RequestIRQ failed %x\n", ret); - goto un_io; - } - bzero(&cfg, sizeof (cfg)); - cfg.Attributes = 0; /* not ready for CONF_ENABLE_IRQ_STEERING yet */ - cfg.Vcc = 50; - cfg.IntType = SOCKET_INTERFACE_MEMORY_AND_IO; - cfg.ConfigBase = config.base; - cfg.ConfigIndex = pcwl_p->pcwl_config; - cfg.Status = CCSR_IO_IS_8; - cfg.Present = config.present; - pcwl_p->pcwl_flag |= PCWL_CARD_READY; - if (ret = csx_RequestConfiguration(chdl, &cfg)) { - cmn_err(CE_WARN, "pcwl: RequestConfiguration failed %x\n", ret); - goto un_irq; - } - - if (pcwl_p->pcwl_flag & PCWL_CARD_SUSPEND) { - mutex_enter(&pcwl_p->pcwl_glock); - (void) pcwl_reset_backend(pcwl_p); - /* turn on CS interrupt */ - cfgmod.Attributes = CONF_ENABLE_IRQ_STEERING | - CONF_IRQ_CHANGE_VALID; - cfgmod.Vpp1 = 50; - cfgmod.Vpp2 = 50; - (void) csx_ModifyConfiguration(pcwl_p->pcwl_chdl, &cfgmod); - - (void) pcwl_init_nicmem(pcwl_p); - pcwl_chip_type(pcwl_p); - (void) pcwl_loaddef_rf(pcwl_p); - (void) pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0); - pcwl_stop_locked(pcwl_p); /* leaves interface down */ - pcwl_p->pcwl_flag &= ~PCWL_CARD_SUSPEND; - mutex_exit(&pcwl_p->pcwl_glock); - } - if (pcwl_p->pcwl_flag & PCWL_CARD_PLUMBED) { - (void) pcwl_start(pcwl_p); - pcwl_p->pcwl_flag &= ~PCWL_CARD_PLUMBED; - } - return (CS_SUCCESS); -un_irq: - (void) csx_ReleaseIRQ(chdl, &irq); -un_io: - ddi_remove_softintr(pcwl_p->pcwl_softint_id); - (void) csx_ReleaseIO(chdl, &io); - pcwl_p->pcwl_port = 0; -insert_ret: - pcwl_p->pcwl_flag &= ~PCWL_CARD_READY; - return (ret); - -} - -/* - * assume card is already removed, don't touch the hardware - */ -static void -pcwl_card_remove(pcwl_maci_t *pcwl_p) -{ - int ret; - io_req_t io; - irq_req_t irq; - - /* - * The card not ready means Insert function doesnot return TRUE. - * then the IO and IRQ has been released in Insert - */ - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) - return; - - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - - if (pcwl_p->pcwl_flag & PCWL_CARD_LINKUP) { - pcwl_p->pcwl_flag &= ~PCWL_CARD_LINKUP; - mac_link_update(GLD3(pcwl_p), LINK_STATE_DOWN); - } - mutex_enter(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_flag & PCWL_CARD_INTREN) { - pcwl_stop_locked(pcwl_p); - pcwl_p->pcwl_flag |= PCWL_CARD_PLUMBED; - } - pcwl_p->pcwl_flag &= ~PCWL_CARD_READY; - mutex_exit(&pcwl_p->pcwl_glock); - if (ret = csx_ReleaseConfiguration(pcwl_p->pcwl_chdl, NULL)) - cmn_err(CE_WARN, "pcwl: ReleaseConfiguration failed %x\n", ret); - - bzero(&irq, sizeof (irq)); - if (ret = csx_ReleaseIRQ(pcwl_p->pcwl_chdl, &irq)) - cmn_err(CE_WARN, "pcwl: ReleaseIRQ failed %x\n", ret); - - ddi_remove_softintr(pcwl_p->pcwl_softint_id); - - bzero(&io, sizeof (io)); - io.BasePort1.handle = pcwl_p->pcwl_port; - io.NumPorts1 = 16; - if (ret = csx_ReleaseIO(pcwl_p->pcwl_chdl, &io)) - cmn_err(CE_WARN, "pcwl: ReleaseIO failed %x\n", ret); - - pcwl_p->pcwl_port = 0; -} - -/* - * mac operation interface routines - */ -static int -pcwl_start(void *arg) -{ - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - mutex_exit(&pcwl_p->pcwl_glock); - return (PCWL_FAIL); - } - pcwl_start_locked(pcwl_p); - mutex_exit(&pcwl_p->pcwl_glock); - return (PCWL_SUCCESS); -} - -static void -pcwl_stop(void *arg) -{ - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - PCWLDBG((CE_NOTE, "pcwl_stop called\n")); - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - mutex_exit(&pcwl_p->pcwl_glock); - return; - } - - pcwl_stop_locked(pcwl_p); - mutex_exit(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } -} - -static int -pcwl_saddr(void *arg, const uint8_t *macaddr) -{ - int ret = PCWL_SUCCESS; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - ret = PCWL_FAIL; - goto done; - } - ether_copy(macaddr, pcwl_p->pcwl_mac_addr); - if (pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = PCWL_FAIL; - goto done; - } - if (pcwl_saddr_locked(pcwl_p)) { - ret = PCWL_FAIL; - goto done; - } - if (pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - ret = PCWL_FAIL; - } -done: - if (ret) - cmn_err(CE_WARN, "pcwl set_mac_addr: failed\n"); - mutex_exit(&pcwl_p->pcwl_glock); - return (ret); -} - -static int -pcwl_send(pcwl_maci_t *pcwl_p, mblk_t *mblk_p) -{ - int i = 0; - char *buf, *buf_p; - wl_frame_t *frm_p; - uint16_t pkt_len, ret; - uint16_t xmt_id, ring_idx; - struct ieee80211_frame *wh; - struct ieee80211_llc *llc; - - mutex_enter(&pcwl_p->pcwl_glock); - if ((pcwl_p->pcwl_flag & (PCWL_CARD_READY | PCWL_CARD_LINKUP)) != - (PCWL_CARD_READY | PCWL_CARD_LINKUP)) { - mutex_exit(&pcwl_p->pcwl_glock); - freemsg(mblk_p); - return (PCWL_SUCCESS); /* drop packet */ - } - mutex_exit(&pcwl_p->pcwl_glock); - - if (pullupmsg(mblk_p, -1) == 0) { - freemsg(mblk_p); - return (PCWL_SUCCESS); /* drop packet */ - } - wh = (struct ieee80211_frame *)mblk_p->b_rptr; - llc = (struct ieee80211_llc *)&wh[1]; - - mutex_enter(&pcwl_p->pcwl_txring.wl_tx_lock); - ring_idx = pcwl_p->pcwl_txring.wl_tx_prod; - pcwl_p->pcwl_txring.wl_tx_prod = (ring_idx + 1) & (WL_XMT_BUF_NUM - 1); - - /* - * check whether there is a xmt buffer available - */ - while ((i < WL_XMT_BUF_NUM) && - (pcwl_p->pcwl_txring.wl_tx_ring[ring_idx])) { - ring_idx = pcwl_p->pcwl_txring.wl_tx_prod; - pcwl_p->pcwl_txring.wl_tx_prod = - (ring_idx + 1) & (WL_XMT_BUF_NUM - 1); - i++; - } - if (i == WL_XMT_BUF_NUM) { - mutex_exit(&pcwl_p->pcwl_txring.wl_tx_lock); - mutex_enter(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_reschedule_need = B_TRUE; - mutex_exit(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_noxmtbuf++; - return (PCWL_FAIL); - } - xmt_id = pcwl_p->pcwl_txring.wl_tx_fids[ring_idx]; - pcwl_p->pcwl_txring.wl_tx_ring[ring_idx] = xmt_id; - mutex_exit(&pcwl_p->pcwl_txring.wl_tx_lock); - - buf = kmem_zalloc(PCWL_NICMEM_SZ, KM_SLEEP); - buf_p = (ulong_t)buf & 1 ? buf + 1 : buf; - frm_p = (wl_frame_t *)buf_p; -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_SEND) { - cmn_err(CE_NOTE, "pcwl send: packet"); - for (i = 0; i < MBLKL(mblk_p); i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((unsigned char *)mblk_p->b_rptr + i)); - } -#endif - pkt_len = msgdsize(mblk_p); - if (pkt_len > (PCWL_NICMEM_SZ - sizeof (wl_frame_t))) { - cmn_err(CE_WARN, "pcwl: send mblk is too long"); - kmem_free(buf, PCWL_NICMEM_SZ); - freemsg(mblk_p); - return (PCWL_SUCCESS); /* drop packet */ - } - if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) != - IEEE80211_FC1_DIR_TODS) { - kmem_free(buf, PCWL_NICMEM_SZ); - freemsg(mblk_p); - return (PCWL_SUCCESS); /* drop packet */ - } - bzero(frm_p, WL_802_11_HDRLEN); - - frm_p->wl_tx_ctl = WL_TXCNTL_SET; - bcopy(wh->i_addr3, frm_p->wl_dst_addr, ETHERADDRL); /* dst macaddr */ - bcopy(wh->i_addr2, frm_p->wl_src_addr, ETHERADDRL); /* src macaddr */ - frm_p->wl_len = htons(pkt_len - sizeof (*wh)); - bcopy(llc, &frm_p->wl_dat[0], pkt_len - sizeof (*wh)); - pkt_len = pkt_len - (sizeof (*wh) + sizeof (*llc)) + - WL_802_11_HDRLEN; - PCWLDBG((CE_NOTE, "send: DIX frmsz=%x pkt_len=%x\n", - WL_802_11_HDRLEN, pkt_len)); - - if (pkt_len & 1) /* round up to 16-bit boundary and pad 0 */ - buf_p[pkt_len++] = 0; - - ASSERT(pkt_len <= PCWL_NICMEM_SZ); -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_SEND) { - cmn_err(CE_NOTE, "pkt_len = %x\n", pkt_len); - for (i = 0; i < pkt_len; i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((unsigned char *)buf + i)); - } -#endif - mutex_enter(&pcwl_p->pcwl_glock); - ret = (WRCH1(pcwl_p, xmt_id, 0, (uint16_t *)buf_p, 0x2e) || - WRPKT(pcwl_p, xmt_id, 0x2e, (uint16_t *)(buf_p + 0x2e), - pkt_len - 0x2e)); - if (ret) { - goto done; - } - PCWLDBG((CE_NOTE, "send: xmt_id=%x send=%x\n", xmt_id, pkt_len)); - (void) pcwl_set_cmd(pcwl_p, WL_CMD_TX | WL_RECLAIM, xmt_id); - -done: - mutex_exit(&pcwl_p->pcwl_glock); - kmem_free(buf, PCWL_NICMEM_SZ); - freemsg(mblk_p); - return (PCWL_SUCCESS); -} - -static mblk_t * -pcwl_tx(void *arg, mblk_t *mp) -{ - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - mblk_t *next; - - ASSERT(mp != NULL); - mutex_enter(&pcwl_p->pcwl_glock); - if ((pcwl_p->pcwl_flag & (PCWL_CARD_LINKUP | PCWL_CARD_READY)) != - (PCWL_CARD_LINKUP | PCWL_CARD_READY)) { - mutex_exit(&pcwl_p->pcwl_glock); - freemsgchain(mp); - return (NULL); - } - mutex_exit(&pcwl_p->pcwl_glock); - while (mp != NULL) { - next = mp->b_next; - mp->b_next = NULL; - - if (pcwl_send(pcwl_p, mp)) { - mp->b_next = next; - break; - } - mp = next; - } - return (mp); -} - -static int -pcwl_prom(void *arg, boolean_t on) -{ - int ret = PCWL_SUCCESS; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - ret = PCWL_FAIL; - goto done; - } - - PCWLDBG((CE_NOTE, "pcwl_prom called %x\n", on)); - - if (on) - pcwl_p->pcwl_rf.rf_promiscuous = 1; - else - pcwl_p->pcwl_rf.rf_promiscuous = 0; - if (ret = pcwl_fil_ltv(pcwl_p, 2, WL_RID_PROMISC, - pcwl_p->pcwl_rf.rf_promiscuous)) { - ret = PCWL_FAIL; - } -done: - if (ret) - cmn_err(CE_WARN, "pcwl promisc: failed\n"); - mutex_exit(&pcwl_p->pcwl_glock); - return (ret); -} - -static int -pcwl_gstat(void *arg, uint_t statitem, uint64_t *val) -{ - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - int ret = PCWL_SUCCESS; - uint64_t *cntr_p = pcwl_p->pcwl_cntrs_s; - uint16_t rate = 0; - uint64_t speed; - - PCWLDBG((CE_NOTE, "pcwl_gstat called\n")); - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - ret = PCWL_FAIL; - goto done; - } - - if (pcwl_get_ltv(pcwl_p, 2, WL_RID_CUR_TX_RATE, &rate)) { - cmn_err(CE_WARN, "pcwl kstat: get speed failed\n"); - ret = PCWL_FAIL; - goto done; - } - switch (pcwl_p->pcwl_chip_type) { - case PCWL_CHIP_PRISMII: - switch (rate) { - case WL_SPEED_1Mbps_P2: rate = 2; break; - case WL_SPEED_2Mbps_P2: rate = 4; break; - case WL_SPEED_55Mbps_P2: rate = 11; break; - case WL_SPEED_11Mbps_P2: rate = 22; break; - default: rate = 0; break; - } - speed = rate * 500000; - break; - case PCWL_CHIP_LUCENT: - default: - speed = rate * 1000000; - if (rate == 6) - speed = 5500000; - break; - } - - switch (statitem) { - case MAC_STAT_IFSPEED: - *val = speed; - break; - case MAC_STAT_NOXMTBUF: - *val = pcwl_p->pcwl_noxmtbuf; - break; - case MAC_STAT_NORCVBUF: - *val = cntr_p[WLC_RX_DISCARDS_NOBUF]; - break; - case MAC_STAT_IERRORS: - *val = 0; - break; - case MAC_STAT_OERRORS: - *val = cntr_p[WLC_TX_DISCARDS] + - cntr_p[WLC_TX_DISCARDS_WRONG_SA]; - break; - case MAC_STAT_RBYTES: - *val = cntr_p[WLC_RX_UNICAST_OCTETS]; - break; - case MAC_STAT_IPACKETS: - *val = cntr_p[WLC_RX_UNICAST_FRAMES]; - break; - case MAC_STAT_OBYTES: - *val = cntr_p[WLC_TX_UNICAST_OCTETS]; - break; - case MAC_STAT_OPACKETS: - *val = cntr_p[WLC_TX_UNICAST_FRAMES]; - break; - case WIFI_STAT_TX_FAILED: - *val = cntr_p[WLC_TX_RETRY_LIMIT] + - cntr_p[WLC_TX_DEFERRED_XMITS]; - break; - case WIFI_STAT_TX_RETRANS: - *val = cntr_p[WLC_TX_SINGLE_RETRIES] + - cntr_p[WLC_TX_MULTI_RETRIES]; - break; - case WIFI_STAT_FCS_ERRORS: - *val = cntr_p[WLC_RX_FCS_ERRORS]; - break; - case WIFI_STAT_WEP_ERRORS: - *val = cntr_p[WLC_RX_WEP_CANT_DECRYPT]; - break; - case WIFI_STAT_MCAST_TX: - *val = cntr_p[WLC_TX_MULTICAST_FRAMES]; - break; - case WIFI_STAT_MCAST_RX: - *val = cntr_p[WLC_RX_MULTICAST_FRAMES]; - break; - case WIFI_STAT_TX_FRAGS: - *val = cntr_p[WLC_TX_FRAGMENTS]; - break; - case WIFI_STAT_RX_FRAGS: - *val = cntr_p[WLC_RX_FRAGMENTS] + - cntr_p[WLC_RX_MSG_IN_MSG_FRAGS] + - cntr_p[WLC_RX_MSG_IN_BAD_MSG_FRAGS]; - break; - case WIFI_STAT_RTS_SUCCESS: - case WIFI_STAT_RTS_FAILURE: - case WIFI_STAT_ACK_FAILURE: - case WIFI_STAT_RX_DUPS: - *val = 0; - break; - default: - ret = ENOTSUP; - } -done: - mutex_exit(&pcwl_p->pcwl_glock); - return (ret); -} - -static int -pcwl_sdmulti(void *arg, boolean_t add, const uint8_t *eth_p) -{ - int ret = PCWL_SUCCESS; - uint16_t i; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - uint16_t *mc_p = pcwl_p->pcwl_mcast; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - ret = PCWL_FAIL; - goto done; - } - - if (add) { /* enable multicast on eth_p, search for available entries */ - for (i = 0; i < 16; i++, mc_p += (ETHERADDRL >> 1)) { - if (!ether_cmp(eth_p, mc_p)) - break; - } - if (i < 16) /* already part of the filter */ - goto done; - mc_p = pcwl_p->pcwl_mcast; /* reset mc_p for 2nd scan */ - for (i = 0; i < 16; i++, mc_p += (ETHERADDRL >> 1)) { - PCWLDBG((CE_NOTE, "smulti: mc[%x]=%s\n", i, - ether_sprintf((struct ether_addr *)mc_p))); - if (mc_p[0] == 0 && mc_p[1] == 0 && mc_p[2] == 0) - break; - } - if (i >= 16) /* can't find a vacant entry */ - goto done; - ether_copy(eth_p, mc_p); - } else { /* disable multicast, locate the entry and clear it */ - for (i = 0; i < 16; i++, mc_p += (ETHERADDRL >> 1)) { - if (!ether_cmp(eth_p, mc_p)) - break; - } - if (i >= 16) - goto done; - mc_p[0] = 0; - mc_p[1] = 0; - mc_p[2] = 0; - } - /* - * re-blow the entire 16 entries buffer - */ - if (i = pcwl_put_ltv(pcwl_p, ETHERADDRL << 4, WL_RID_MCAST, - pcwl_p->pcwl_mcast)) { - ret = PCWL_FAIL; - } -done: - if (ret) - cmn_err(CE_WARN, "pcwl set multi addr: failed\n"); - mutex_exit(&pcwl_p->pcwl_glock); - return (ret); -} - -static uint_t -pcwl_intr(caddr_t arg) -{ - uint16_t stat; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if ((pcwl_p->pcwl_flag & (PCWL_CARD_READY | PCWL_CARD_INTREN)) != - (PCWL_CARD_READY | PCWL_CARD_INTREN)) { - mutex_exit(&pcwl_p->pcwl_glock); - return (DDI_INTR_UNCLAIMED); - } - PCWL_READ(pcwl_p, WL_EVENT_STAT, stat); - if (!(stat & WL_INTRS) || stat == WL_EV_ALL) { - mutex_exit(&pcwl_p->pcwl_glock); - return (DDI_INTR_UNCLAIMED); - } - - PCWL_WRITE(pcwl_p, WL_INT_EN, 0); - if (stat & WL_EV_RX) { - pcwl_rcv(pcwl_p); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_RX); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_RX); - } - if (stat & WL_EV_TX) { - if (pcwl_txdone(pcwl_p) == PCWL_SUCCESS) { - if (pcwl_p->pcwl_reschedule_need == B_TRUE) { - mutex_exit(&pcwl_p->pcwl_glock); - mac_tx_update(GLD3(pcwl_p)); - mutex_enter(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_reschedule_need = B_FALSE; - } - } - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_TX); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_TX); - } - if (stat & WL_EV_ALLOC) { - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_ALLOC | 0x1000); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, 0x1000); - } - if (stat & WL_EV_INFO) { - pcwl_infodone(pcwl_p); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_INFO); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_INFO); - } - if (stat & WL_EV_TX_EXC) { - if (pcwl_txdone(pcwl_p) == PCWL_SUCCESS) { - if (pcwl_p->pcwl_reschedule_need == B_TRUE) { - mutex_exit(&pcwl_p->pcwl_glock); - mac_tx_update(GLD3(pcwl_p)); - mutex_enter(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_reschedule_need = B_FALSE; - } - } - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_TX_EXC); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_TX_EXC); - } - if (stat & WL_EV_INFO_DROP) { - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_INFO_DROP); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_INFO_DROP); - } - PCWL_ENABLE_INTR(pcwl_p); - mutex_exit(&pcwl_p->pcwl_glock); - - return (DDI_INTR_CLAIMED); -} - -static uint_t -pcwl_intr_hi(caddr_t arg) -{ - uint16_t stat; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if ((pcwl_p->pcwl_flag & (PCWL_CARD_READY | PCWL_CARD_INTREN)) != - (PCWL_CARD_READY | PCWL_CARD_INTREN)) { - mutex_exit(&pcwl_p->pcwl_glock); - return (DDI_INTR_UNCLAIMED); - } - PCWL_READ(pcwl_p, WL_EVENT_STAT, stat); - if (!(stat & WL_INTRS) || stat == WL_EV_ALL) { - mutex_exit(&pcwl_p->pcwl_glock); - return (DDI_INTR_UNCLAIMED); - } - PCWL_WRITE(pcwl_p, WL_INT_EN, 0); /* disable interrupt without ack */ - mutex_exit(&pcwl_p->pcwl_glock); - ddi_trigger_softintr(pcwl_p->pcwl_softint_id); - return (DDI_INTR_CLAIMED); -} - -/* - * called at interrupt context to retrieve data from card - */ -static void -pcwl_rcv(pcwl_maci_t *pcwl_p) -{ - uint16_t id, len, off, ret, frm_ctl; - wl_frame_t frm; - mblk_t *mp = allocb(PCWL_NICMEM_SZ, BPRI_MED); - if (!mp) - return; - ASSERT(mp->b_rptr == mp->b_wptr); - - PCWL_READ(pcwl_p, WL_RX_FID, id); - PCWL_WRITE(pcwl_p, WL_RX_FID, 0); - if (id == WL_INVALID_FID) { - PCWLDBG((CE_NOTE, "pcwl rcv: get rx_fid failed\n")); - ret = PCWL_FAIL; - goto done; - } - if (ret = RDCH0(pcwl_p, id, 0, (uint16_t *)&frm, sizeof (frm))) { - PCWLDBG((CE_NOTE, "pcwl rcv: read frm failed %x\n", ret)); - goto done; - } - if (frm.wl_status & WL_STAT_ERRSTAT) { - PCWLDBG((CE_NOTE, "pcwl rcv: errstat %x\n", frm.wl_status)); - ret = frm.wl_status; - goto done; - } - PCWLDBG((CE_NOTE, "pcwl rcv: frame type %x\n", frm.wl_status)); -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_RCV) { - int i; - cmn_err(CE_NOTE, "pcwl rcv: frm header\n"); - for (i = 0; i < WL_802_11_HDRLEN; i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((uint8_t *)&frm + i)); - } -#endif - len = frm.wl_dat_len; - /* - * this driver deal with WEP by itself. so plugin always thinks no wep. - */ - frm.wl_frame_ctl &= ~(IEEE80211_FC1_WEP << 8); - frm_ctl = frm.wl_frame_ctl; - switch (frm.wl_status) { - case WL_STAT_1042: - case WL_STAT_TUNNEL: - case WL_STAT_WMP_MSG: - PCWL_SWAP16((uint16_t *)&frm.wl_frame_ctl, - sizeof (struct ieee80211_frame)); - /* - * discard those frames which are not from the AP we connect or - * without 'ap->sta' direction - */ - if ((pcwl_p->pcwl_rf.rf_porttype == WL_BSS_BSS) && - ((((frm_ctl >> 8) & IEEE80211_FC1_DIR_MASK) != - IEEE80211_FC1_DIR_FROMDS) || - bcmp(pcwl_p->pcwl_bssid, frm.wl_addr2, 6) != 0)) { - ret = PCWL_FAIL; - goto done; - } - - bcopy(&frm.wl_frame_ctl, mp->b_wptr, - sizeof (struct ieee80211_frame)); - mp->b_wptr += sizeof (struct ieee80211_frame); - - PCWL_SWAP16((uint16_t *)&frm.wl_dat[0], - sizeof (struct ieee80211_llc)); - bcopy(&frm.wl_dat[0], mp->b_wptr, - sizeof (struct ieee80211_llc)); - mp->b_wptr += sizeof (struct ieee80211_llc); - - len -= (2 + WL_SNAPHDR_LEN); - off = WL_802_11_HDRLEN; - break; - default: - PCWLDBG((CE_NOTE, "pcwl rcv: incorrect pkt\n")); - break; - } - if (len > MBLKSIZE(mp)) { - PCWLDBG((CE_NOTE, "pcwl rcv: oversz pkt %x\n", len)); - ret = PCWL_FAIL; - goto done; - } - if (len & 1) - len++; - ret = RDPKT(pcwl_p, id, off, (uint16_t *)mp->b_wptr, len); -done: - if (ret) { - PCWLDBG((CE_NOTE, "pcwl rcv: rd data %x\n", ret)); - freemsg(mp); - return; - } - mp->b_wptr = mp->b_wptr + len; -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_RCV) { - int i; - cmn_err(CE_NOTE, "pcwl rcv: len=0x%x\n", len); - for (i = 0; i < len+14; i++) - cmn_err(CE_NOTE, "%x: %x\n", i, - *((uint8_t *)mp->b_rptr + i)); - } -#endif - mutex_exit(&pcwl_p->pcwl_glock); - mac_rx(GLD3(pcwl_p), NULL, mp); - mutex_enter(&pcwl_p->pcwl_glock); -} - -static uint32_t -pcwl_txdone(pcwl_maci_t *pcwl_p) -{ - uint16_t fid, i; - PCWL_READ(pcwl_p, WL_ALLOC_FID, fid); - PCWL_WRITE(pcwl_p, WL_ALLOC_FID, 0); - - mutex_enter(&pcwl_p->pcwl_txring.wl_tx_lock); - for (i = 0; i < WL_XMT_BUF_NUM; i++) { - if (fid == pcwl_p->pcwl_txring.wl_tx_ring[i]) { - pcwl_p->pcwl_txring.wl_tx_ring[i] = 0; - break; - } - } - pcwl_p->pcwl_txring.wl_tx_cons = - (pcwl_p->pcwl_txring.wl_tx_cons + 1) & (WL_XMT_BUF_NUM - 1); - mutex_exit(&pcwl_p->pcwl_txring.wl_tx_lock); - if (i == WL_XMT_BUF_NUM) - return (PCWL_FAIL); - return (PCWL_SUCCESS); - -} - -static void -pcwl_infodone(pcwl_maci_t *pcwl_p) -{ - uint16_t id, ret, i; - uint16_t linkStatus[2]; - uint16_t linkStat; - wifi_data_t wd = { 0 }; - - PCWL_READ(pcwl_p, WL_INFO_FID, id); - if (id == WL_INVALID_FID) { - cmn_err(CE_WARN, "pcwl infodone: read info_fid failed\n"); - return; - } - if (ret = RDCH0(pcwl_p, id, 0, linkStatus, sizeof (linkStatus))) { - PCWLDBG((CE_WARN, "pcwl infodone read infoFrm failed %x\n", - ret)); - return; - } - PCWLDBG((CE_NOTE, "pcwl infodone: Frame length= %x, Frame Type = %x\n", - linkStatus[0], linkStatus[1])); - - switch (linkStatus[1]) { - case WL_INFO_LINK_STAT: - (void) RDCH0(pcwl_p, id, sizeof (linkStatus), &linkStat, - sizeof (linkStat)); - PCWLDBG((CE_NOTE, "pcwl infodone: link status=%x\n", linkStat)); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_LINKUP) && - linkStat == WL_LINK_CONNECT) { -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_LINKINFO) - cmn_err(CE_NOTE, "pcwl: Link up \n"); -#endif - pcwl_p->pcwl_flag |= PCWL_CARD_LINKUP; - mutex_exit(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p-> - pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - mutex_enter(&pcwl_p->pcwl_glock); - mac_link_update(GLD3(pcwl_p), LINK_STATE_UP); - (void) pcwl_get_ltv(pcwl_p, 6, - WL_RID_BSSID, (uint16_t *)pcwl_p->pcwl_bssid); - PCWL_SWAP16((uint16_t *)pcwl_p->pcwl_bssid, 6); - pcwl_get_rssi(pcwl_p); - bcopy(pcwl_p->pcwl_bssid, wd.wd_bssid, 6); - wd.wd_secalloc = WIFI_SEC_NONE; - wd.wd_opmode = IEEE80211_M_STA; - (void) mac_pdata_update(pcwl_p->pcwl_mh, &wd, - sizeof (wd)); - } - if ((pcwl_p->pcwl_flag & PCWL_CARD_LINKUP) && - ((linkStat == WL_LINK_DISCONNECT) || - (linkStat == WL_LINK_AP_OOR))) { -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_LINKINFO) - cmn_err(CE_NOTE, "pcwl: Link down \n"); -#endif - PCWLDBG((CE_NOTE, "pcwl infodone: link status = %d\n", - linkStat)); - pcwl_p->pcwl_flag &= ~PCWL_CARD_LINKUP; - if (linkStat == WL_LINK_AP_OOR) - pcwl_p->pcwl_connect_timeout_id = - timeout(pcwl_connect_timeout, - pcwl_p, drv_usectohz(1000)); - mutex_exit(&pcwl_p->pcwl_glock); - mac_link_update(GLD3(pcwl_p), LINK_STATE_DOWN); - mutex_enter(&pcwl_p->pcwl_glock); - } - break; - case WL_INFO_SCAN_RESULTS: - case WL_INFO_HSCAN_RESULTS: - pcwl_ssid_scan(pcwl_p, id, linkStatus[0], linkStatus[1]); - break; - case WL_INFO_COUNTERS: - linkStatus[0]--; - if (linkStatus[0] > WLC_STAT_CNT) { - linkStatus[0] = MIN(linkStatus[0], WLC_STAT_CNT); - } - (void) RDCH0(pcwl_p, id, sizeof (linkStatus), - pcwl_p->pcwl_cntrs_t, linkStatus[0]<<1); - /* - * accumulate all the statistics items for kstat use. - */ - for (i = 0; i < WLC_STAT_CNT; i++) - pcwl_p->pcwl_cntrs_s[i] += pcwl_p->pcwl_cntrs_t[i]; - break; - default: - break; - } -} - -static uint16_t -pcwl_set_cmd(pcwl_maci_t *pcwl_p, uint16_t cmd, uint16_t param) -{ - int i; - uint16_t stat; - - if (((cmd == WL_CMD_ENABLE) && - ((pcwl_p->pcwl_flag & PCWL_ENABLED) != 0)) || - ((cmd == WL_CMD_DISABLE) && - ((pcwl_p->pcwl_flag & PCWL_ENABLED) == 0))) - return (PCWL_SUCCESS); - - for (i = 0; i < WL_TIMEOUT; i++) { - PCWL_READ(pcwl_p, WL_COMMAND, stat); - if (stat & WL_CMD_BUSY) { - drv_usecwait(1); - } else { - break; - } - } - if (i == WL_TIMEOUT) { - cmn_err(CE_WARN, "pcwl: setcmd %x, %x timeout %x due to " - "busy bit\n", cmd, param, stat); - return (PCWL_TIMEDOUT_CMD); - } - - PCWL_WRITE(pcwl_p, WL_PARAM0, param); - PCWL_WRITE(pcwl_p, WL_PARAM1, 0); - PCWL_WRITE(pcwl_p, WL_PARAM2, 0); - PCWL_WRITE(pcwl_p, WL_COMMAND, cmd); - if (cmd == WL_CMD_INI) - drv_usecwait(100000); /* wait .1 sec */ - - for (i = 0; i < WL_TIMEOUT; i++) { - PCWL_READ(pcwl_p, WL_EVENT_STAT, stat); - if (!(stat & WL_EV_CMD)) { - drv_usecwait(1); - } else { - break; - } - } - if (i == WL_TIMEOUT) { - cmn_err(CE_WARN, "pcwl: setcmd %x,%x timeout %x\n", - cmd, param, stat); - if (stat & (WL_EV_ALLOC | WL_EV_RX)) - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, stat); - return (PCWL_TIMEDOUT_CMD); - } - PCWL_READ(pcwl_p, WL_STATUS, stat); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_CMD); - if (stat & WL_STAT_CMD_RESULT) { /* err in feedback status */ - cmn_err(CE_WARN, "pcwl: set_cmd %x,%x failed %x\n", - cmd, param, stat); - return (PCWL_FAILURE_CMD); - } - if (cmd == WL_CMD_ENABLE) - pcwl_p->pcwl_flag |= PCWL_ENABLED; - if (cmd == WL_CMD_DISABLE) - pcwl_p->pcwl_flag &= (~PCWL_ENABLED); - return (PCWL_SUCCESS); -} - -static uint16_t -pcwl_set_ch(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off, uint16_t channel) -{ - int i; - uint16_t stat, select, offset; - - if (channel) { - select = WL_SEL1; - offset = WL_OFF1; - } else { - select = WL_SEL0; - offset = WL_OFF0; - } - PCWL_WRITE(pcwl_p, select, type); - PCWL_WRITE(pcwl_p, offset, off); - for (stat = 0, i = 0; i < WL_TIMEOUT; i++) { - PCWL_READ(pcwl_p, offset, stat); - if (!(stat & (WL_OFF_BUSY|WL_OFF_ERR))) - break; - else { - drv_usecwait(1); - } - } - if (i == WL_TIMEOUT) { - cmn_err(CE_WARN, "set_ch%d %x,%x failed %x\n", - channel, type, off, stat); - return (PCWL_TIMEDOUT_TARGET); - } - return (PCWL_SUCCESS); -} - -static uint16_t -pcwl_get_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type, uint16_t *val_p) -{ - uint16_t stat; - - ASSERT(!(len & 1)); - len >>= 1; /* convert bytes to 16-bit words */ - - /* - * 1. select read mode - */ - if (stat = pcwl_set_cmd(pcwl_p, WL_CMD_ACCESS | WL_ACCESS_READ, type)) - return (stat); - - /* - * 2. select Buffer Access Path (channel) 1 for PIO - */ - if (stat = pcwl_set_ch(pcwl_p, type, 0, 1)) - return (stat); - - /* - * 3. read length - */ - PCWL_READ(pcwl_p, WL_DATA1, stat); - if (stat != (len + 1)) { - PCWLDBG((CE_NOTE, "get_ltv 0x%x expected 0x%x+1, got 0x%x\n", - type, (len + 1) << 1, stat)); - stat = (stat >> 1) - 1; - len = MIN(stat, len); - } - - /* - * 4. read type - */ - PCWL_READ(pcwl_p, WL_DATA1, stat); - if (stat != type) - return (PCWL_BADTYPE); - - /* - * 5. read value - */ - for (stat = 0; stat < len; stat++, val_p++) { - PCWL_READ_P(pcwl_p, WL_DATA1, val_p, 1); - } - return (PCWL_SUCCESS); -} - -static uint16_t -pcwl_fil_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type, uint16_t val) -{ - uint16_t stat; - - ASSERT(!(len & 1)); - - /* - * 1. select Buffer Access Path (channel) 1 for PIO - */ - if (stat = pcwl_set_ch(pcwl_p, type, 0, 1)) - return (stat); - - /* - * 2. write length - */ - len >>= 1; /* convert bytes to 16-bit words */ - stat = len + 1; /* 1 extra word */ - PCWL_WRITE(pcwl_p, WL_DATA1, stat); - - /* - * 3. write type - */ - PCWL_WRITE(pcwl_p, WL_DATA1, type); - - /* - * 4. fill value - */ - for (stat = 0; stat < len; stat++) { - PCWL_WRITE(pcwl_p, WL_DATA1, val); - } - - /* - * 5. select write mode - */ - return (pcwl_set_cmd(pcwl_p, WL_CMD_ACCESS|WL_ACCESS_WRITE, type)); -} - -static uint16_t -pcwl_put_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type, uint16_t *val_p) -{ - uint16_t stat; - - ASSERT(!(len & 1)); - - /* - * 1. select Buffer Access Path (channel) 1 for PIO - */ - if (stat = pcwl_set_ch(pcwl_p, type, 0, 1)) - return (stat); - - /* - * 2. write length - */ - len >>= 1; /* convert bytes to 16-bit words */ - stat = len + 1; /* 1 extra word */ - PCWL_WRITE(pcwl_p, WL_DATA1, stat); - - /* - * 3. write type - */ - PCWL_WRITE(pcwl_p, WL_DATA1, type); - - /* - * 4. write value - */ - for (stat = 0; stat < len; stat++, val_p++) { - PCWL_WRITE_P(pcwl_p, WL_DATA1, val_p, 1); - } - - /* - * 5. select write mode - */ - return (pcwl_set_cmd(pcwl_p, WL_CMD_ACCESS|WL_ACCESS_WRITE, type)); -} - -#define PCWL_COMPSTR_LEN 34 -static uint16_t -pcwl_put_str(pcwl_maci_t *pcwl_p, uint16_t type, char *str_p) -{ - uint16_t buf[PCWL_COMPSTR_LEN / 2]; - uint8_t str_len = strlen(str_p); - - bzero(buf, PCWL_COMPSTR_LEN); - buf[0] = str_len; - bcopy(str_p, (caddr_t)(buf + 1), str_len); - PCWLDBG((CE_NOTE, "put_str: buf[0]=%x buf=%s\n", - buf[0], (caddr_t)(buf + 1))); - PCWL_SWAP16(buf + 1, PCWL_COMPSTR_LEN - 2); - return (pcwl_put_ltv(pcwl_p, PCWL_COMPSTR_LEN, type, buf)); -} - -/*ARGSUSED*/ -static uint16_t -pcwl_rdch0(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off, uint16_t *buf_p, - int len, int order) -{ - uint16_t o; - ASSERT(!(len & 1)); - /* - * It seems that for PrismII chip, frequently overlap use of path0 - * and path1 may hang the hardware. So for PrismII chip, just use - * path1. Test proves this workaround is OK. - */ - if (pcwl_p->pcwl_chip_type == PCWL_CHIP_PRISMII) { - if (type = pcwl_set_ch(pcwl_p, type, off, 1)) - return (type); - o = WL_DATA1; - } else { - if (type = pcwl_set_ch(pcwl_p, type, off, 0)) - return (type); - o = WL_DATA0; - } - len >>= 1; - for (off = 0; off < len; off++, buf_p++) { - PCWL_READ_P(pcwl_p, o, buf_p, order); - } - return (PCWL_SUCCESS); -} - -/*ARGSUSED*/ -static uint16_t -pcwl_wrch1(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off, uint16_t *buf_p, - int len, int order) -{ - ASSERT(!(len & 1)); - if (type = pcwl_set_ch(pcwl_p, type, off, 1)) - return (type); - len >>= 1; - for (off = 0; off < len; off++, buf_p++) { - PCWL_WRITE_P(pcwl_p, WL_DATA1, buf_p, order); - } - return (PCWL_SUCCESS); -} - -static uint16_t -pcwl_alloc_nicmem(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t *id_p) -{ - int i; - uint16_t stat; - - len = ((len + 1) >> 1) << 1; /* round up to 16-bit boundary */ - - if (stat = pcwl_set_cmd(pcwl_p, WL_CMD_ALLOC_MEM, len)) - return (stat); - for (stat = 0, i = 0; i < WL_TIMEOUT; i++) { - PCWL_READ(pcwl_p, WL_EVENT_STAT, stat); - if (stat & WL_EV_ALLOC) - break; - else - drv_usecwait(1); - } - if (i == WL_TIMEOUT) - return (PCWL_TIMEDOUT_ALLOC); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_ALLOC); - PCWL_READ(pcwl_p, WL_ALLOC_FID, stat); - *id_p = stat; - - /* - * zero fill the allocated NIC mem - sort of pcwl_fill_ch - */ - (void) pcwl_set_ch(pcwl_p, stat, 0, 1); - - for (len >>= 1, stat = 0; stat < len; stat++) { - PCWL_WRITE(pcwl_p, WL_DATA1, 0); - } - return (PCWL_SUCCESS); -} - -static int -pcwl_add_scan_item(pcwl_maci_t *pcwl_p, wl_scan_result_t s) -{ - wl_scan_list_t *scan_item; - - scan_item = kmem_zalloc(sizeof (wl_scan_list_t), KM_SLEEP); - if (scan_item == NULL) { - cmn_err(CE_WARN, "pcwl add_scan_item: zalloc failed\n"); - return (PCWL_FAIL); - } - scan_item->wl_val = s; - scan_item->wl_timeout = WL_SCAN_TIMEOUT_MAX; - list_insert_tail(&pcwl_p->pcwl_scan_list, scan_item); - pcwl_p->pcwl_scan_num++; - return (PCWL_SUCCESS); -} - -static void -pcwl_delete_scan_item(pcwl_maci_t *pcwl_p, wl_scan_list_t *s) -{ - list_remove(&pcwl_p->pcwl_scan_list, s); - kmem_free(s, sizeof (*s)); - pcwl_p->pcwl_scan_num--; -} - -static void -pcwl_scanlist_timeout(void *arg) -{ - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - wl_scan_list_t *scan_item0, *scan_item1; - - mutex_enter(&pcwl_p->pcwl_scanlist_lock); - scan_item0 = list_head(&pcwl_p->pcwl_scan_list); - for (; scan_item0; ) { - PCWLDBG((CE_NOTE, "ssid = %s\n", - scan_item0->wl_val.wl_srt_ssid)); - PCWLDBG((CE_NOTE, "timeout left: %ds", - scan_item0->wl_timeout)); - scan_item1 = list_next(&pcwl_p->pcwl_scan_list, scan_item0); - if (scan_item0->wl_timeout == 0) { - pcwl_delete_scan_item(pcwl_p, scan_item0); - } else { - scan_item0->wl_timeout--; - } - scan_item0 = scan_item1; - } - mutex_exit(&pcwl_p->pcwl_scanlist_lock); - pcwl_p->pcwl_scanlist_timeout_id = timeout(pcwl_scanlist_timeout, - pcwl_p, drv_usectohz(1000000)); -} - -static void -pcwl_get_rssi(pcwl_maci_t *pcwl_p) -{ - wl_scan_list_t *scan_item0; - uint16_t cq[3]; - - bzero(cq, sizeof (cq)); - mutex_enter(&pcwl_p->pcwl_scanlist_lock); - scan_item0 = list_head(&pcwl_p->pcwl_scan_list); - for (; scan_item0; ) { - if (bcmp(scan_item0->wl_val.wl_srt_bssid, - pcwl_p->pcwl_bssid, 6) == 0) { - pcwl_p->pcwl_rssi = scan_item0->wl_val.wl_srt_sl; - } - scan_item0 = list_next(&pcwl_p->pcwl_scan_list, scan_item0); - } - mutex_exit(&pcwl_p->pcwl_scanlist_lock); - if (!pcwl_p->pcwl_rssi) { - (void) pcwl_get_ltv(pcwl_p, 6, WL_RID_COMMQUAL, cq); - pcwl_p->pcwl_rssi = cq[1]; - } -} - -/* - * Note: - * PrismII chipset has 2 extra space for the reason why scan is initiated - */ -static void -pcwl_ssid_scan(pcwl_maci_t *pcwl_p, uint16_t fid, uint16_t flen, uint16_t stype) -{ - uint16_t stat; - uint16_t ssidNum, i; - uint16_t off, szbuf; - uint16_t tmp[2]; - wl_scan_list_t *scan_item0; - uint32_t check_num; - uint8_t bssid_t[6]; - - wl_scan_result_t sctbl; - - off = sizeof (uint16_t) * 2; - switch (pcwl_p->pcwl_chip_type) { - case PCWL_CHIP_PRISMII: - (void) RDCH0(pcwl_p, fid, off, tmp, 4); - off += 4; - szbuf = (stype == WL_INFO_SCAN_RESULTS ? 31 : 32); - PCWLDBG((CE_NOTE, "pcwl ssid_scan: PRISM chip\n")); - break; - case PCWL_CHIP_LUCENT: - PCWLDBG((CE_NOTE, "pcwl ssid_scan LUCENT chip\n")); - default: - szbuf = 25; - } - - flen = flen + 1 - (off >> 1); - ssidNum = flen/szbuf; - ssidNum = min(WL_SRT_MAX_NUM, ssidNum); - - PCWLDBG((CE_NOTE, "pcwl: ssid_scan frame length = %d\n", flen)); - - PCWLDBG((CE_NOTE, "pcwl ssid_scan: %d ssid(s) available", ssidNum)); - - bzero(bssid_t, sizeof (bssid_t)); - for (i = 0; i < ssidNum; i++) { - (void) RDCH0(pcwl_p, fid, off, (uint16_t *)&sctbl, 2*szbuf); - -#ifdef DEBUG - if (pcwl_debug & PCWL_DBG_INFO) { - int j; - for (j = 0; j < sizeof (sctbl); j++) - cmn_err(CE_NOTE, "%d: %x\n", j, - *((uint8_t *)&sctbl + j)); - } -#endif - - off += (szbuf << 1); - stat = min(sctbl.wl_srt_ssidlen, 31); - PCWL_SWAP16((uint16_t *)(sctbl.wl_srt_bssid), 6); - PCWL_SWAP16((uint16_t *)(sctbl.wl_srt_ssid), stat); - sctbl.wl_srt_ssid[stat] = '\0'; - sctbl.wl_srt_sl &= 0x7f; - - /* - * sometimes, those empty items are recorded by hardware, - * this is wrong, just ignore those items here. - */ - if (bcmp(sctbl.wl_srt_bssid, - bssid_t, 6) == 0) { - continue; - } - if (bcmp(sctbl.wl_srt_bssid, - pcwl_p->pcwl_bssid, 6) == 0) { - pcwl_p->pcwl_rssi = sctbl.wl_srt_sl; - } - /* - * save/update the scan item in scanlist - */ - mutex_enter(&pcwl_p->pcwl_scanlist_lock); - check_num = 0; - scan_item0 = list_head(&pcwl_p->pcwl_scan_list); - if (scan_item0 == NULL) { - if (pcwl_add_scan_item(pcwl_p, sctbl) - != 0) { - mutex_exit(&pcwl_p->pcwl_scanlist_lock); - return; - } - } - for (; scan_item0; ) { - if (bcmp(sctbl.wl_srt_bssid, - scan_item0->wl_val.wl_srt_bssid, 6) == 0) { - scan_item0->wl_val = sctbl; - scan_item0->wl_timeout = WL_SCAN_TIMEOUT_MAX; - break; - } else { - check_num++; - } - scan_item0 = list_next(&pcwl_p->pcwl_scan_list, - scan_item0); - } - if (check_num == pcwl_p->pcwl_scan_num) { - if (pcwl_add_scan_item(pcwl_p, sctbl) - != 0) { - mutex_exit(&pcwl_p->pcwl_scanlist_lock); - return; - } - } - mutex_exit(&pcwl_p->pcwl_scanlist_lock); - PCWLDBG((CE_NOTE, "pcwl ssid_scan: ssid%d = %s\n", i+1, - sctbl.wl_srt_ssid)); - PCWLDBG((CE_NOTE, "pcwl ssid_scan: channel = %d\n", - sctbl.wl_srt_chid)); - PCWLDBG((CE_NOTE, "pcwl ssid_scan: signal level= %d\n", - sctbl.wl_srt_sl)); - PCWLDBG((CE_NOTE, "pcwl ssid_scan: noise level = %d\n", - sctbl.wl_srt_anl)); - PCWLDBG((CE_NOTE, "pcwl ssid_scan: bssid%d =" - " %x %x %x %x %x %x\n\n", i+1, - sctbl.wl_srt_bssid[0], - sctbl.wl_srt_bssid[1], - sctbl.wl_srt_bssid[2], - sctbl.wl_srt_bssid[3], - sctbl.wl_srt_bssid[4], - sctbl.wl_srt_bssid[5])); - } - -} - -/* - * delay in which the mutex is not hold. - * assuming the mutex has already been hold. - */ -static void -pcwl_delay(pcwl_maci_t *pcwl_p, clock_t microsecs) -{ - ASSERT(mutex_owned(&pcwl_p->pcwl_glock)); - - mutex_exit(&pcwl_p->pcwl_glock); - delay(drv_usectohz(microsecs)); - mutex_enter(&pcwl_p->pcwl_glock); -} - -static int -pcwl_reset_backend(pcwl_maci_t *pcwl_p) -{ - uint16_t ret = 0; - - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_INI, 0)) { - return ((int)ret); - } - - pcwl_delay(pcwl_p, 100000); /* wait .1 sec */ - - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_INI, 0)) { - return ((int)ret); - } - pcwl_delay(pcwl_p, 100000); /* wait .1 sec */ - - PCWL_DISABLE_INTR(pcwl_p); - return (PCWL_SUCCESS); -} - - -/* - * get card capability (WEP, default channel), setup broadcast, mac addresses - */ -static int -pcwl_get_cap(pcwl_maci_t *pcwl_p) -{ - uint16_t stat, ch_no; - uint16_t buf[ETHERADDRL >> 1]; - - bzero(buf, ETHERADDRL); - if (stat = pcwl_get_ltv(pcwl_p, 2, WL_RID_OWN_CHNL, &ch_no)) { - cmn_err(CE_CONT, "pcwl get_cap: get def channel failed" - " %x\n", stat); - return ((int)stat); - } - if (stat = pcwl_get_ltv(pcwl_p, 2, WL_RID_WEP_AVAIL, - &pcwl_p->pcwl_has_wep)) { - cmn_err(CE_CONT, "pcwl get_cap: get WEP capability failed" - " %x\n", stat); - return ((int)stat); - } - if (stat = pcwl_get_ltv(pcwl_p, ETHERADDRL, WL_RID_MAC_NODE, buf)) { - cmn_err(CE_CONT, "pcwl get_cap: get macaddr failed" - " %x\n", stat); - return ((int)stat); - } - - /* - * don't assume m_xxx members are 16-bit aligned - */ - PCWL_SWAP16(buf, ETHERADDRL); - ether_copy(buf, pcwl_p->pcwl_mac_addr); - return (PCWL_SUCCESS); -} - -static int -pcwl_init_nicmem(pcwl_maci_t *pcwl_p) -{ - uint16_t ret, i; - uint16_t rc; - - for (i = 0; i < WL_XMT_BUF_NUM; i++) { - ret = pcwl_alloc_nicmem(pcwl_p, PCWL_NICMEM_SZ, &rc); - if (ret) { - cmn_err(CE_WARN, - "pcwl: alloc NIC Tx buf failed %x\n", ret); - return (PCWL_FAIL); - } - pcwl_p->pcwl_txring.wl_tx_fids[i] = rc; - pcwl_p->pcwl_txring.wl_tx_ring[i] = 0; - PCWLDBG((CE_NOTE, "pcwl: alloc_nicmem_id[%d]=%x\n", i, rc)); - } - pcwl_p->pcwl_txring.wl_tx_prod = pcwl_p->pcwl_txring.wl_tx_cons = 0; - - ret = pcwl_alloc_nicmem(pcwl_p, PCWL_NICMEM_SZ, &pcwl_p->pcwl_mgmt_id); - if (ret) { - cmn_err(CE_WARN, "pcwl: alloc NIC Mgmt buf failed %x\n", ret); - return (PCWL_FAIL); - } - PCWLDBG((CE_NOTE, "pcwl: alloc_nicmem mgmt_id=%x\n", - pcwl_p->pcwl_mgmt_id)); - return (PCWL_SUCCESS); -} - -static int -pcwl_loaddef_rf(pcwl_maci_t *pcwl_p) -{ - pcwl_p->pcwl_rf.rf_max_datalen = WL_DEFAULT_DATALEN; - pcwl_p->pcwl_rf.rf_create_ibss = WL_DEFAULT_CREATE_IBSS; - pcwl_p->pcwl_rf.rf_porttype = WL_BSS_BSS; - pcwl_p->pcwl_rf.rf_rts_thresh = WL_DEFAULT_RTS_THRESH; - pcwl_p->pcwl_rf.rf_tx_rate = WL_TX_RATE_FIX_11M(pcwl_p); - pcwl_p->pcwl_rf.rf_pm_enabled = WL_DEFAULT_PM_ENABLED; - pcwl_p->pcwl_rf.rf_own_chnl = WL_DEFAULT_CHAN; - (void) strcpy(pcwl_p->pcwl_rf.rf_own_ssid, ""); - (void) strcpy(pcwl_p->pcwl_rf.rf_desired_ssid, ""); - (void) strcpy(pcwl_p->pcwl_rf.rf_nodename, ""); - pcwl_p->pcwl_rf.rf_encryption = WL_NOENCRYPTION; - pcwl_p->pcwl_rf.rf_authtype = WL_OPENSYSTEM; - pcwl_p->pcwl_rf.rf_tx_crypt_key = WL_DEFAULT_TX_CRYPT_KEY; - bzero((pcwl_p->pcwl_rf.rf_ckeys), sizeof (rf_ckey_t) * 4); - - pcwl_p->pcwl_rf.rf_promiscuous = 0; - - return (pcwl_config_rf(pcwl_p)); -} - -static int -pcwl_config_rf(pcwl_maci_t *pcwl_p) -{ - pcwl_rf_t *rf_p = &pcwl_p->pcwl_rf; - uint16_t create_ibss, porttype; - - /* - * Lucent card: - * 0 Join ESS or IBSS; 1 Join ESS or join/create IBSS - * PrismII card: - * 3 Join ESS or IBSS(do not create IBSS); - * 1 Join ESS or join/create IBSS - */ - create_ibss = rf_p->rf_create_ibss; - if (pcwl_p->pcwl_chip_type == PCWL_CHIP_PRISMII) { - if (rf_p->rf_create_ibss == 0) - create_ibss = 3; - } - /* - * Lucent card: - * 1 BSS; 3 pseudo IBSS(only for test,not the 802.11 IBSS) - * so porttype register should always be set to 1 - * PrismII card: - * 0 IBSS; 1 BSS; 2 WDS; 3 pseudo IBSS; 6 hostAP - */ - switch (pcwl_p->pcwl_chip_type) { - case PCWL_CHIP_PRISMII: - if (rf_p->rf_porttype == WL_BSS_BSS) - porttype = 1; - else if (rf_p->rf_porttype == WL_BSS_IBSS) - porttype = 0; - else - porttype = 0; - break; - case PCWL_CHIP_LUCENT: - default: - porttype = 1; - } - - - FIL_LTV(pcwl_p, PCWL_MCBUF_LEN, WL_RID_MCAST, 0); - FIL_LTV(pcwl_p, 2, WL_RID_PROMISC, 0); - FIL_LTV(pcwl_p, 2, WL_RID_TICK_TIME, 0); - - FIL_LTV(pcwl_p, 2, WL_RID_MAX_DATALEN, rf_p->rf_max_datalen); - FIL_LTV(pcwl_p, 2, WL_RID_CREATE_IBSS, create_ibss); - FIL_LTV(pcwl_p, 2, WL_RID_PORTTYPE, porttype); - FIL_LTV(pcwl_p, 2, WL_RID_RTS_THRESH, rf_p->rf_rts_thresh); - FIL_LTV(pcwl_p, 2, WL_RID_TX_RATE, rf_p->rf_tx_rate); - FIL_LTV(pcwl_p, 2, WL_RID_SYSTEM_SCALE, rf_p->rf_system_scale); - FIL_LTV(pcwl_p, 2, WL_RID_PM_ENABLED, rf_p->rf_pm_enabled); - FIL_LTV(pcwl_p, 2, WL_RID_MAX_SLEEP, rf_p->rf_max_sleep); - FIL_LTV(pcwl_p, 2, WL_RID_OWN_CHNL, rf_p->rf_own_chnl); - - PUT_STR(pcwl_p, WL_RID_OWN_SSID, rf_p->rf_own_ssid); - PUT_STR(pcwl_p, WL_RID_DESIRED_SSID, rf_p->rf_desired_ssid); - PUT_STR(pcwl_p, WL_RID_NODENAME, rf_p->rf_nodename); - - if (!pcwl_p->pcwl_has_wep) - goto done; - - switch (pcwl_p->pcwl_chip_type) { - case PCWL_CHIP_PRISMII: { - int i; - - for (i = 0; i < 4; i++) { - int k_len = strlen((char *)rf_p->rf_ckeys[i].ckey_dat); - if (k_len == 0) - continue; - k_len = k_len > 5 ? 14 : 6; - PUT_LTV(pcwl_p, k_len, WL_RID_CRYPT_KEY0_P2 + i, - (uint16_t *)&rf_p->rf_ckeys[i].ckey_dat); - } - FIL_LTV(pcwl_p, 2, WL_RID_TX_CRYPT_KEY_P2, - rf_p->rf_tx_crypt_key); - FIL_LTV(pcwl_p, 2, WL_RID_AUTHTYPE_P2, - rf_p->rf_authtype); - FIL_LTV(pcwl_p, 2, WL_RID_ENCRYPTION_P2, - rf_p->rf_encryption); - if (pcwl_p->pcwl_rf.rf_promiscuous) - FIL_LTV(pcwl_p, 2, WL_RID_PROMISC, 1); - } - break; - case PCWL_CHIP_LUCENT: - default: - FIL_LTV(pcwl_p, 2, WL_RID_ENCRYPTION, - rf_p->rf_encryption); - FIL_LTV(pcwl_p, 2, WL_RID_AUTHTYPE_L, - rf_p->rf_authtype); - FIL_LTV(pcwl_p, 2, WL_RID_TX_CRYPT_KEY, - rf_p->rf_tx_crypt_key); - PUT_LTV(pcwl_p, sizeof (rf_p->rf_ckeys), - WL_RID_DEFLT_CRYPT_KEYS, - (uint16_t *)rf_p->rf_ckeys); - break; - } -done: - return (PCWL_SUCCESS); -} - -static void -pcwl_start_locked(pcwl_maci_t *pcwl_p) -{ - pcwl_p->pcwl_flag |= PCWL_CARD_INTREN; - PCWL_ENABLE_INTR(pcwl_p); -} - -static void -pcwl_stop_locked(pcwl_maci_t *pcwl_p) -{ - PCWL_DISABLE_INTR(pcwl_p); - pcwl_p->pcwl_flag &= (~PCWL_CARD_INTREN); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_TX|WL_EV_RX|WL_EV_TX_EXC| - WL_EV_ALLOC|WL_EV_INFO|WL_EV_INFO_DROP); - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, WL_EV_TX|WL_EV_RX|WL_EV_TX_EXC| - WL_EV_ALLOC| WL_EV_INFO|WL_EV_INFO_DROP); -} - -/*ARGSUSED*/ -static int -pcwl_saddr_locked(pcwl_maci_t *pcwl_p) -{ - int ret; - uint16_t buf[ETHERADDRL >> 1]; - - ether_copy(pcwl_p->pcwl_mac_addr, buf); - PCWL_SWAP16(buf, ETHERADDRL); - ret = pcwl_put_ltv(pcwl_p, ETHERADDRL, WL_RID_MAC_NODE, buf); - if (ret) { - cmn_err(CE_WARN, "pcwl set_mac_addr: failed %x\n", ret); - return (PCWL_FAIL); - } - return (PCWL_SUCCESS); -} - -static void -pcwl_chip_type(pcwl_maci_t *pcwl_p) -{ - pcwl_ltv_ver_t ver; - pcwl_ltv_fwver_t f; - - bzero(&ver, sizeof (ver)); - (void) pcwl_get_ltv(pcwl_p, sizeof (ver), - WL_RID_CARD_ID, (uint16_t *)&ver); - PCWLDBG((CE_NOTE, "card id:%04x-%04x-%04x-%04x\n", - ver.wl_compid, ver.wl_variant, ver.wl_major, ver.wl_minor)); - if ((ver.wl_compid & 0xf000) != 0x8000) - return; /* lucent */ - - pcwl_p->pcwl_chip_type = PCWL_CHIP_PRISMII; - (void) pcwl_get_ltv(pcwl_p, sizeof (ver), WL_RID_COMP_IDENT, - (uint16_t *)&ver); - PCWLDBG((CE_NOTE, "PRISM-II ver:%04x-%04x-%04x-%04x\n", - ver.wl_compid, ver.wl_variant, ver.wl_major, ver.wl_minor)); - - bzero(&f, sizeof (f)); - (void) pcwl_get_ltv(pcwl_p, sizeof (f), WL_RID_FWVER, (uint16_t *)&f); - PCWL_SWAP16((uint16_t *)&f, sizeof (f)); - PCWLDBG((CE_NOTE, "Firmware Pri:%s 2,3:%s\n", - (char *)f.pri, (char *)f.st)); -} - -/* - * Brussels support - */ -/* - * MAC_PROP_WL_ESSID - */ -static int -pcwl_set_essid(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - char *value; - pcwl_rf_t *rf_p; - wl_essid_t *iw_essid = (wl_essid_t *)wldp_buf; - - rf_p = &pcwl_p->pcwl_rf; - - value = iw_essid->wl_essid_essid; - (void) strncpy(rf_p->rf_desired_ssid, value, - MIN(32, strlen(value))); - rf_p->rf_desired_ssid[strlen(value)] = '\0'; - (void) strncpy(rf_p->rf_own_ssid, value, - MIN(32, strlen(value))); - rf_p->rf_own_ssid[strlen(value)] = '\0'; - - PCWLDBG((CE_CONT, "pcwl: set: desired essid=%s\n", - rf_p->rf_desired_ssid)); - - return (ENETRESET); - -} - -static int -pcwl_get_essid(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - char ssid[36]; - uint16_t ret; - uint16_t val; - int len; - int err = 0; - wl_essid_t ow_essid; - pcwl_rf_t *rf_p; - - rf_p = &pcwl_p->pcwl_rf; - bzero(&ow_essid, sizeof (wl_essid_t)); - bzero(ssid, sizeof (ssid)); - - ret = pcwl_get_ltv(pcwl_p, 2, WL_RID_PORTSTATUS, &val); - if (ret) { - err = EIO; - return (err); - } - PCWLDBG((CE_NOTE, "PortStatus = %d\n", val)); - - switch (val) { - case WL_PORT_DISABLED: - case WL_PORT_INITIAL: - len = mi_strlen(rf_p->rf_desired_ssid); - ow_essid.wl_essid_length = len; - bcopy(rf_p->rf_desired_ssid, ow_essid.wl_essid_essid, - len); - break; - case WL_PORT_TO_IBSS: - case WL_PORT_TO_BSS: - case WL_PORT_OOR: - (void) pcwl_get_ltv((pcwl_p), 34, WL_RID_SSID, - (uint16_t *)ssid); - PCWL_SWAP16((uint16_t *)(ssid+2), *(uint16_t *)ssid); - ssid[*(uint16_t *)ssid + 2] = '\0'; - len = mi_strlen(ssid+2); - ow_essid.wl_essid_length = len; - bcopy(ssid + 2, ow_essid.wl_essid_essid, len); - break; - default: - err = EINVAL; - break; - } - - bcopy(&ow_essid, wldp_buf, sizeof (wl_essid_t)); - - return (err); -} - -/* - * MAC_PROP_WL_BSSID - */ -static int -pcwl_get_bssid(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - uint16_t ret; - uint16_t retval; - uint8_t bssid[6]; - int err = 0; - - if (ret = pcwl_get_ltv(pcwl_p, 2, WL_RID_PORTSTATUS, &retval)) { - err = EIO; - return (err); - } - - PCWLDBG((CE_NOTE, "PortStatus = %d\n", ret)); - - if (retval == WL_PORT_DISABLED || retval == WL_PORT_INITIAL) { - bzero(wldp_buf, sizeof (wl_bssid_t)); - } else if (retval == WL_PORT_TO_IBSS || - retval == WL_PORT_TO_BSS || retval == WL_PORT_OOR) { - (void) pcwl_get_ltv(pcwl_p, 6, - WL_RID_BSSID, (uint16_t *)bssid); - PCWL_SWAP16((uint16_t *)bssid, 6); - bcopy(bssid, wldp_buf, sizeof (wl_bssid_t)); - } - - PCWLDBG((CE_CONT, "pcwl_get_bssid: bssid=%x %x %x %x %x %x\n", - bssid[0], bssid[1], bssid[2], - bssid[3], bssid[4], bssid[5])); - - return (err); -} - -/* - * MAC_PROP_WL_LINKSTATUS - */ -static int -pcwl_get_linkstatus(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - uint16_t ret; - uint16_t retval; - int err = 0; - - ret = pcwl_get_ltv(pcwl_p, 2, WL_RID_PORTSTATUS, &retval); - if (ret) { - err = EIO; - PCWLDBG((CE_WARN, "cfg_linkstatus_get_error\n")); - return (err); - } - PCWLDBG((CE_NOTE, "PortStatus = %d\n", retval)); - - switch (retval) { - case WL_PORT_DISABLED: - case WL_PORT_INITIAL: - *(wl_linkstatus_t *)wldp_buf = WL_NOTCONNECTED; - break; - case WL_PORT_TO_IBSS: - case WL_PORT_TO_BSS: - case WL_PORT_OOR: - *(wl_linkstatus_t *)wldp_buf = WL_CONNECTED; - break; - default: - err = EINVAL; - break; - } - - return (err); -} - -/* - * MAC_PROP_WL_BSSTYP - */ -static int -pcwl_set_bsstype(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t ret; - pcwl_rf_t *rf_p; - int err = ENETRESET; - - rf_p = &pcwl_p->pcwl_rf; - - ret = (uint16_t)(*(wl_bss_type_t *)wldp_buf); - if ((ret != WL_BSS_BSS) && - (ret != WL_BSS_IBSS) && - (ret != WL_BSS_ANY)) { - err = ENOTSUP; - return (err); - } - - rf_p->rf_porttype = ret; - - return (err); -} - -static void -pcwl_get_bsstype(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - pcwl_rf_t *rf_p; - - rf_p = &pcwl_p->pcwl_rf; - - *(wl_bss_type_t *)wldp_buf = rf_p->rf_porttype; - - PCWLDBG((CE_CONT, "pcwl_get_bsstype: porttype=%d\n", - rf_p->rf_porttype)); -} - -/* - * MAC_PROP_WL_PHY_CONFIG - */ -static int -pcwl_set_phy(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t ret; - pcwl_rf_t *rf_p; - int err = ENETRESET; - wl_phy_conf_t *phy = (wl_phy_conf_t *)wldp_buf; - - rf_p = &pcwl_p->pcwl_rf; - ret = (uint16_t)(phy->wl_phy_dsss_conf.wl_dsss_channel); - if (ret < 1 || ret > 14) { - err = ENOTSUP; - return (err); - } - - rf_p->rf_own_chnl = ret; - - PCWLDBG((CE_CONT, "pcwl: set channel=%d\n", rf_p->rf_own_chnl)); - - return (err); -} - -static int -pcwl_get_phy(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - uint16_t retval; - wl_dsss_t *dsss = (wl_dsss_t *)wldp_buf; - int err = 0; - - if (pcwl_get_ltv(pcwl_p, 2, WL_RID_CURRENT_CHNL, &retval)) { - err = EIO; - return (err); - } - - dsss->wl_dsss_channel = retval; - PCWLDBG((CE_CONT, "pcwl_get_phy: channel=%d\n", retval)); - dsss->wl_dsss_subtype = WL_DSSS; - - return (err); -} - -/* - * MAC_PROP_WL_DESIRED_RATESa - */ -static int -pcwl_set_desrates(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - int err = ENETRESET; - char rates[4]; - char maxrate; - uint16_t i; - pcwl_rf_t *rf_p; - wl_rates_t *iw_rates = (wl_rates_t *)wldp_buf; - - rf_p = &pcwl_p->pcwl_rf; - - bzero(rates, sizeof (rates)); - - for (i = 0; i < 4; i++) { - rates[i] = iw_rates->wl_rates_rates[i]; - PCWLDBG((CE_CONT, "pcwl: set tx_rate[%d]=%d\n", i, rates[i])); - } - PCWLDBG((CE_CONT, "pcwl: set rate_num=%d\n", iw_rates->wl_rates_num)); - - switch (iw_rates->wl_rates_num) { - case 1: - switch (rates[0]) { - case WL_RATE_1M: - rf_p->rf_tx_rate = WL_TX_RATE_FIX_1M(pcwl_p); - break; - case WL_RATE_2M: - rf_p->rf_tx_rate = WL_TX_RATE_FIX_2M(pcwl_p); - break; - case WL_RATE_11M: - rf_p->rf_tx_rate = WL_TX_RATE_FIX_11M(pcwl_p); - break; - case WL_RATE_5_5M: - rf_p->rf_tx_rate = WL_TX_RATE_FIX_5M(pcwl_p); - break; - default: - err = EINVAL; - break; - } - break; - case 2: - maxrate = (rates[0] > rates[1] ? rates[0] : rates[1]); - switch (maxrate) { - case WL_RATE_2M: - rf_p->rf_tx_rate = WL_TX_RATE_AUTO_L(pcwl_p); - break; - case WL_RATE_11M: - rf_p->rf_tx_rate = WL_TX_RATE_AUTO_H(pcwl_p); - break; - case WL_RATE_5_5M: - rf_p->rf_tx_rate = WL_TX_RATE_AUTO_M(pcwl_p); - break; - default: - err = EINVAL; - break; - } - break; - case 3: - maxrate = (rates[0] > rates[1] ? rates[0] : rates[1]); - maxrate = (rates[2] > maxrate ? rates[2] : maxrate); - switch (maxrate) { - case WL_RATE_11M: - rf_p->rf_tx_rate = WL_TX_RATE_AUTO_H(pcwl_p); - break; - case WL_RATE_5_5M: - rf_p->rf_tx_rate = WL_TX_RATE_AUTO_M(pcwl_p); - break; - default: - err = EINVAL; - break; - } - break; - case 4: - rf_p->rf_tx_rate = WL_TX_RATE_AUTO_H(pcwl_p); - break; - default: - err = ENOTSUP; - break; - } - PCWLDBG((CE_CONT, "pcwl: set tx_rate=%d\n", rf_p->rf_tx_rate)); - - return (err); -} - -static int -pcwl_get_desrates(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - uint16_t rate; - int err = 0; - - if (pcwl_get_ltv(pcwl_p, 2, WL_RID_TX_RATE, &rate)) { - err = EIO; - return (err); - } - - if (pcwl_p->pcwl_chip_type == PCWL_CHIP_PRISMII) { - ((wl_rates_t *)wldp_buf)->wl_rates_num = 1; - switch (rate) { - case WL_SPEED_1Mbps_P2: - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_1M; - break; - case WL_SPEED_2Mbps_P2: - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_2M; - break; - case WL_SPEED_55Mbps_P2: - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_5_5M; - break; - case WL_SPEED_11Mbps_P2: - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_11M; - break; - default: - err = EINVAL; - break; - } - } else { - switch (rate) { - case WL_L_TX_RATE_FIX_1M: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 1; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_1M; - break; - case WL_L_TX_RATE_FIX_2M: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 1; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_2M; - break; - case WL_L_TX_RATE_AUTO_H: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 4; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_1M; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[1] = - WL_RATE_2M; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[2] = - WL_RATE_5_5M; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[3] = - WL_RATE_11M; - break; - case WL_L_TX_RATE_FIX_5M: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 1; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_5_5M; - break; - case WL_L_TX_RATE_FIX_11M: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 1; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_11M; - break; - case WL_L_TX_RATE_AUTO_L: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 2; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_1M; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[1] = - WL_RATE_2M; - break; - case WL_L_TX_RATE_AUTO_M: - ((wl_rates_t *)wldp_buf)->wl_rates_num = 3; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[0] = - WL_RATE_1M; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[1] = - WL_RATE_2M; - (((wl_rates_t *)wldp_buf)->wl_rates_rates)[2] = - WL_RATE_5_5M; - break; - default: - err = EINVAL; - break; - } - } - PCWLDBG((CE_CONT, "pcwl: get rate=%d\n", rate)); - - return (err); -} - -/* - * MAC_PROP_WL_SUP_RATE - */ -static void -pcwl_get_suprates(void *wldp_buf) -{ - wl_rates_t *wl_rates = (wl_rates_t *)wldp_buf; - - wl_rates->wl_rates_num = 4; - wl_rates->wl_rates_rates[0] = WL_RATE_1M; - wl_rates->wl_rates_rates[1] = WL_RATE_2M; - wl_rates->wl_rates_rates[2] = WL_RATE_5_5M; - wl_rates->wl_rates_rates[3] = WL_RATE_11M; -} - -/* - * MAC_PROP_WL_POWER_MODE - */ -static int -pcwl_set_powermode(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t ret; - pcwl_rf_t *rf_p; - int err = 0; - - rf_p = &pcwl_p->pcwl_rf; - - ret = (uint16_t)(((wl_ps_mode_t *)wldp_buf)->wl_ps_mode); - if (ret != WL_PM_AM && ret != WL_PM_MPS && ret != WL_PM_FAST) { - err = ENOTSUP; - return (err); - } - - rf_p->rf_pm_enabled = ret; - - return (err); - -} - -static void -pcwl_get_powermode(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - pcwl_rf_t *rf_p; - - rf_p = &pcwl_p->pcwl_rf; - ((wl_ps_mode_t *)wldp_buf)->wl_ps_mode = rf_p->rf_pm_enabled; -} - -/* - * MAC_PROP_AUTH_MODE - */ -static int -pcwl_set_authmode(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t ret; - pcwl_rf_t *rf_p; - int err = ENETRESET; - - rf_p = &pcwl_p->pcwl_rf; - - ret = (uint16_t)(*(wl_authmode_t *)wldp_buf); - if (ret != WL_OPENSYSTEM && ret != WL_SHAREDKEY) { - err = ENOTSUP; - return (err); - } - - rf_p->rf_authtype = ret; - - return (err); -} - -static void -pcwl_get_authmode(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - pcwl_rf_t *rf_p; - - rf_p = &pcwl_p->pcwl_rf; - *(wl_authmode_t *)wldp_buf = rf_p->rf_authtype; -} - -/* - * MAC_PROP_WL_ENCRYPTION - */ -static int -pcwl_set_encrypt(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t ret; - pcwl_rf_t *rf_p; - int err = ENETRESET; - - rf_p = &pcwl_p->pcwl_rf; - - ret = (uint16_t)(*(wl_encryption_t *)wldp_buf); - PCWLDBG((CE_NOTE, "pcwl_set_encrypt: %d\n", ret)); - if (ret != WL_NOENCRYPTION && ret != WL_ENC_WEP) { - err = ENOTSUP; - return (err); - } - - rf_p->rf_encryption = ret; - - return (err); -} - -static void -pcwl_get_encrypt(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - pcwl_rf_t *rf_p; - - rf_p = &pcwl_p->pcwl_rf; - *(wl_encryption_t *)wldp_buf = rf_p->rf_encryption; -} - -/* - * MAC_PROP_WL_CREATE_IBSS - */ -static int -pcwl_set_ibss(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t ret; - pcwl_rf_t *rf_p; - int err = ENETRESET; - - rf_p = &pcwl_p->pcwl_rf; - - ret = (uint16_t)(*(wl_create_ibss_t *)wldp_buf); - if (ret != 0 && ret != 1) { - err = ENOTSUP; - return (err); - } - - rf_p->rf_create_ibss = ret; - - return (err); -} - -static void -pcwl_get_ibss(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - pcwl_rf_t *rf_p; - - rf_p = &pcwl_p->pcwl_rf; - *(wl_create_ibss_t *)wldp_buf = rf_p->rf_create_ibss; -} - -/* - * MAC_PROP_WL_RSSI - */ -static void -pcwl_get_param_rssi(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - - if (pcwl_p->pcwl_chip_type == PCWL_CHIP_PRISMII) { - *(wl_rssi_t *)wldp_buf = - min((pcwl_p->pcwl_rssi * 15 / 85 + 1), 15); - } else { - /* - * According to the description of the - * datasheet(Lucent card), the signal level - * value is between 27 -- 154. - * we reflect these value to 1-15 as rssi. - */ - if (pcwl_p->pcwl_rssi <= 27) - *(wl_rssi_t *)wldp_buf = 1; - else if (pcwl_p->pcwl_rssi > 154) - *(wl_rssi_t *)wldp_buf = 15; - else - *(wl_rssi_t *)wldp_buf = - min(15, ((pcwl_p->pcwl_rssi - 27) * 15 / 127)); - } -} - -/* - * MAC_PROP_WL_KEY_TAB - */ -static int -pcwl_set_wepkey(pcwl_maci_t *pcwl_p, const void *wldp_buf) -{ - uint16_t i; - pcwl_rf_t *rf_p; - wl_wep_key_t *p_wepkey_tab; - - rf_p = &pcwl_p->pcwl_rf; - bzero((rf_p->rf_ckeys), sizeof (rf_ckey_t) * MAX_NWEPKEYS); - - p_wepkey_tab = (wl_wep_key_t *)wldp_buf; - for (i = 0; i < MAX_NWEPKEYS; i++) { - if (p_wepkey_tab[i].wl_wep_operation == WL_ADD) { - rf_p->rf_ckeys[i].ckey_len = - p_wepkey_tab[i].wl_wep_length; - bcopy(p_wepkey_tab[i].wl_wep_key, - rf_p->rf_ckeys[i].ckey_dat, - p_wepkey_tab[i].wl_wep_length); - PCWL_SWAP16((uint16_t *) - &rf_p->rf_ckeys[i].ckey_dat, - rf_p->rf_ckeys[i].ckey_len + 1); - PCWLDBG((CE_CONT, "%s, %d\n", - rf_p->rf_ckeys[i].ckey_dat, i)); - } - PCWLDBG((CE_CONT, "pcwl: rf_ckeys[%d]=%s\n", i, - (char *)(rf_p->rf_ckeys[i].ckey_dat))); - } - - return (ENETRESET); -} - -/* - * MAC_PROP_WL_RADIO - */ -static void -pcwl_get_radio(void *wldp_buf) -{ - wl_radio_t *radio = (wl_radio_t *)wldp_buf; - - *radio = B_TRUE; -} - -/* - * MAC_PROP_WL_ESSLIST - */ -static void -pcwl_get_esslist(pcwl_maci_t *pcwl_p, void *wldp_buf) -{ - uint16_t i; - wl_ess_conf_t *p_ess_conf; - wl_scan_list_t *scan_item; - - mutex_enter(&pcwl_p->pcwl_scanlist_lock); - - ((wl_ess_list_t *)wldp_buf)->wl_ess_list_num = - pcwl_p->pcwl_scan_num; - - scan_item = list_head(&pcwl_p->pcwl_scan_list); - - for (i = 0; i < pcwl_p->pcwl_scan_num; i++) { - if (!scan_item) - break; - - p_ess_conf = (wl_ess_conf_t *)((char *)wldp_buf + - offsetof(wl_ess_list_t, wl_ess_list_ess) + - i * sizeof (wl_ess_conf_t)); - bcopy(scan_item->wl_val.wl_srt_ssid, - p_ess_conf->wl_ess_conf_essid.wl_essid_essid, - mi_strlen(scan_item->wl_val.wl_srt_ssid)); - bcopy(scan_item->wl_val.wl_srt_bssid, - p_ess_conf->wl_ess_conf_bssid, 6); - (p_ess_conf->wl_phy_conf).wl_phy_dsss_conf.wl_dsss_subtype - = WL_DSSS; - p_ess_conf->wl_ess_conf_wepenabled = - (scan_item->wl_val.wl_srt_cap & 0x10 ? - WL_ENC_WEP : WL_NOENCRYPTION); - p_ess_conf->wl_ess_conf_bsstype = - (scan_item->wl_val.wl_srt_cap & 0x1 ? - WL_BSS_BSS : WL_BSS_IBSS); - p_ess_conf->wl_phy_conf.wl_phy_dsss_conf.wl_dsss_channel = - scan_item->wl_val.wl_srt_chid; - if (pcwl_p->pcwl_chip_type == PCWL_CHIP_PRISMII) { - p_ess_conf->wl_ess_conf_sl = - min(scan_item->wl_val.wl_srt_sl * 15 / 85 + 1, - 15); - } else { - if (scan_item->wl_val.wl_srt_sl <= 27) - p_ess_conf->wl_ess_conf_sl = 1; - else if (scan_item->wl_val.wl_srt_sl > 154) - p_ess_conf->wl_ess_conf_sl = 15; - else - p_ess_conf->wl_ess_conf_sl = min(15, - ((scan_item->wl_val.wl_srt_sl - 27) - * 15 / 127)); - } - - p_ess_conf->wl_supported_rates[0] = WL_RATE_1M; - p_ess_conf->wl_supported_rates[0] = WL_RATE_2M; - p_ess_conf->wl_supported_rates[0] = WL_RATE_5_5M; - p_ess_conf->wl_supported_rates[0] = WL_RATE_11M; - - scan_item = list_next(&pcwl_p->pcwl_scan_list, scan_item); - } - - mutex_exit(&pcwl_p->pcwl_scanlist_lock); -} - - -/* - * for wificonfig and dladm ioctl - */ - -static int -pcwl_cfg_essid(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - char ssid[36]; - uint16_t i; - uint16_t val; - pcwl_rf_t *rf_p; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - rf_p = &pcwl_p->pcwl_rf; - - - bzero(ssid, sizeof (ssid)); - if (cmd == WLAN_GET_PARAM) { - err = pcwl_get_essid(pcwl_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - (void) pcwl_get_ltv(pcwl_p, 2, WL_RID_PORTSTATUS, &val); - if (val == WL_PORT_DISABLED || val == WL_PORT_INITIAL) { - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_essid_t, wl_essid_essid) + - mi_strlen(rf_p->rf_desired_ssid); - } else if (val == WL_PORT_TO_IBSS || - val == WL_PORT_TO_BSS || - val == WL_PORT_OOR) { - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_essid_t, wl_essid_essid) + - mi_strlen(ssid+2); - } else { - outfp->wldp_length = WIFI_BUF_OFFSET; - } - outfp->wldp_result = WL_SUCCESS; - PCWLDBG((CE_CONT, "outfp->length=%d\n", outfp->wldp_length)); - PCWLDBG((CE_CONT, "pcwl: get desired essid=%s\n", - rf_p->rf_desired_ssid)); - } else if (cmd == WLAN_SET_PARAM) { - (void) pcwl_set_essid(pcwl_p, infp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_bssid(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - int iret; - wldp_t *outfp; - char *buf; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_bssid_t); - if (cmd == WLAN_GET_PARAM) { - err = pcwl_get_bssid(pcwl_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - outfp->wldp_result = WL_READONLY; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcwl_cmd_scan(pcwl_maci_t *pcwl_p) -{ - uint16_t vall[18], ret = WL_SUCCESS; - pcwl_rf_t *rf_p; - uint32_t enable, i; - size_t len; - - rf_p = &pcwl_p->pcwl_rf; - - /* - * The logic of this funtion is really tricky. - * Firstly, the chip can only scan in BSS mode, so necessary - * backup and restore is required before and after the scan - * command. - * Secondly, for Lucent chip, Alrealy associated with an AP - * can only scan the APes on the fixed channel, so we must - * set the desired_ssid as "" before scan and restore after. - * Thirdly, scan cmd is effective only when the card is enabled - * and any 'set' operation(such as set bsstype, ssid)must disable - * the card first and then enable the card after the 'set' - */ - enable = pcwl_p->pcwl_flag & PCWL_ENABLED; - len = strlen(rf_p->rf_desired_ssid); - - if (pcwl_p->pcwl_rf.rf_porttype != WL_BSS_BSS) { - if ((enable) && - (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0))) { - ret = (int)WL_HW_ERROR; - goto done; - } - FIL_LTV(pcwl_p, 2, WL_RID_PORTTYPE, WL_BSS_BSS); - } - - if ((pcwl_p->pcwl_chip_type == PCWL_CHIP_LUCENT) && (len != 0)) { - if ((enable) && - (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0))) { - ret = (int)WL_HW_ERROR; - goto done; - } - PUT_STR(pcwl_p, WL_RID_DESIRED_SSID, ""); - } - - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - goto done; - } - pcwl_delay(pcwl_p, 1000000); - - switch (pcwl_p->pcwl_chip_type) { - case PCWL_CHIP_PRISMII: - bzero(vall, sizeof (vall)); - vall[0] = 0x3fff; /* channel mask */ - vall[1] = 0x1; /* tx rate */ - for (i = 0; i < WL_MAX_SCAN_TIMES; i++) { - PUT_LTV(pcwl_p, sizeof (vall), - WL_RID_HSCAN_REQUEST, vall); - pcwl_delay(pcwl_p, 1000000); - if (pcwl_p->pcwl_scan_num >= WL_SCAN_AGAIN_THRESHOLD) - break; - } - PCWLDBG((CE_NOTE, "PRISM chip\n")); - break; - - case PCWL_CHIP_LUCENT: - PCWLDBG((CE_NOTE, "LUCENT chip\n")); - default: - for (i = 0; i < WL_MAX_SCAN_TIMES; i++) { - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_INQUIRE, - WL_INFO_SCAN_RESULTS)) { - ret = (int)WL_HW_ERROR; - goto done; - } - pcwl_delay(pcwl_p, 500000); - if (pcwl_p->pcwl_scan_num >= WL_SCAN_AGAIN_THRESHOLD) - break; - } - break; - } - if ((pcwl_p->pcwl_rf.rf_porttype != WL_BSS_BSS) || - ((pcwl_p->pcwl_chip_type == PCWL_CHIP_LUCENT) && (len != 0))) { - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - goto done; - } - if (ret = pcwl_config_rf(pcwl_p)) { - ret = (int)WL_HW_ERROR; - goto done; - } - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - goto done; - } - - pcwl_delay(pcwl_p, 1000000); - } - - if ((!enable) && (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0))) { - ret = (int)WL_HW_ERROR; - } -done: - if (ret) - cmn_err(CE_WARN, "pcwl: scan failed due to hardware error"); - return (ret); - -} - -/*ARGSUSED*/ -static int -pcwl_cfg_scan(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - wldp_t *outfp; - char *buf; - uint16_t i; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - pcwl_get_esslist(pcwl_p, outfp->wldp_buf); - - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_ess_list_t, wl_ess_list_ess) + - pcwl_p->pcwl_scan_num * sizeof (wl_ess_conf_t); - outfp->wldp_result = WL_SUCCESS; - - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - kmem_free(buf, MAX_BUF_LEN); - return (WL_SUCCESS); - -} - -/*ARGSUSED*/ -static int -pcwl_cfg_linkstatus(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - wldp_t *outfp; - char *buf; - uint16_t i, val; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - err = pcwl_get_linkstatus(pcwl_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - - (void) pcwl_get_ltv(pcwl_p, 2, WL_RID_PORTSTATUS, &val); - if (val == WL_PORT_DISABLED || val == WL_PORT_INITIAL) { - outfp->wldp_length = WIFI_BUF_OFFSET + - sizeof (wl_linkstatus_t); - } else if (val == WL_PORT_TO_IBSS || - val == WL_PORT_TO_BSS || - val == WL_PORT_OOR) { - outfp->wldp_length = WIFI_BUF_OFFSET + - sizeof (wl_linkstatus_t); - } else { - outfp->wldp_length = WIFI_BUF_OFFSET; - } - - outfp->wldp_result = WL_SUCCESS; -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_bsstype(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_bss_type_t); - if (cmd == WLAN_GET_PARAM) { - pcwl_get_bsstype(pcwl_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_bsstype(pcwl_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_phy(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_dsss_t); - if (cmd == WLAN_GET_PARAM) { - err = pcwl_get_phy(pcwl_p, outfp->wldp_buf); - if (err == EIO) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_HW_ERROR; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_phy(pcwl_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); - -} - -static int -pcwl_cfg_desiredrates(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t rate; - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - if (cmd == WLAN_GET_PARAM) { - err = pcwl_get_desrates(pcwl_p, outfp->wldp_buf); - if (err == EIO || err == EINVAL) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - if (pcwl_p->pcwl_chip_type == PCWL_CHIP_PRISMII) { - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 1 * sizeof (char); - } else { - (void) pcwl_get_ltv(pcwl_p, 2, WL_RID_TX_RATE, &rate); - switch (rate) { - case WL_L_TX_RATE_FIX_1M: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 1 * sizeof (char); - break; - case WL_L_TX_RATE_FIX_2M: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 1 * sizeof (char); - break; - case WL_L_TX_RATE_AUTO_H: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 4 * sizeof (char); - break; - case WL_L_TX_RATE_FIX_5M: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 1 * sizeof (char); - break; - case WL_L_TX_RATE_FIX_11M: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 1 * sizeof (char); - break; - case WL_L_TX_RATE_AUTO_L: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 2 * sizeof (char); - break; - case WL_L_TX_RATE_AUTO_M: - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 3 * sizeof (char); - break; - default: - break; - } - } - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_desrates(pcwl_p, infp->wldp_buf); - if (err == EINVAL) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_LACK_FEATURE; - goto done; - } - - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcwl_cfg_supportrates(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *outfp; - char *buf; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - pcwl_get_suprates(outfp->wldp_buf); - outfp->wldp_length = WIFI_BUF_OFFSET + - offsetof(wl_rates_t, wl_rates_rates) + - 4 * sizeof (char); - outfp->wldp_result = WL_SUCCESS; - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - kmem_free(buf, MAX_BUF_LEN); - return (WL_SUCCESS); - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -} - -static int -pcwl_cfg_powermode(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_ps_mode_t); - if (cmd == WLAN_GET_PARAM) { - pcwl_get_powermode(pcwl_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_powermode(pcwl_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); - -} - -static int -pcwl_cfg_authmode(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_authmode_t); - if (cmd == WLAN_GET_PARAM) { - pcwl_get_authmode(pcwl_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_authmode(pcwl_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_encryption(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_encryption_t); - if (cmd == WLAN_GET_PARAM) { - pcwl_get_encrypt(pcwl_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_encrypt(pcwl_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_wepkeyid(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i, ret; - pcwl_rf_t *rf_p; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - rf_p = &pcwl_p->pcwl_rf; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_wep_key_id_t); - if (cmd == WLAN_GET_PARAM) { - *(wl_wep_key_id_t *)(outfp->wldp_buf) = rf_p->rf_tx_crypt_key; - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - ret = (uint16_t)(*(wl_wep_key_id_t *)(infp->wldp_buf)); - if (ret >= MAX_NWEPKEYS) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - rf_p->rf_tx_crypt_key = ret; - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_createibss(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - int err = 0; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_create_ibss_t); - if (cmd == WLAN_GET_PARAM) { - pcwl_get_ibss(pcwl_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - err = pcwl_set_ibss(pcwl_p, infp->wldp_buf); - if (err == ENOTSUP) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_NOTSUPPORTED; - goto done; - } - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_rssi(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - int iret; - wldp_t *outfp; - char *buf; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_rssi_t); - - if (cmd == WLAN_GET_PARAM) { - pcwl_get_param_rssi(pcwl_p, outfp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - outfp->wldp_result = WL_READONLY; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -/*ARGSUSED*/ -static int -pcwl_cfg_radio(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - int iret; - wldp_t *outfp; - char *buf; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - - if (cmd == WLAN_GET_PARAM) { - *(wl_radio_t *)(outfp->wldp_buf) = B_TRUE; - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_radio_t); - outfp->wldp_result = WL_SUCCESS; - } else if (cmd == WLAN_SET_PARAM) { - outfp->wldp_length = WIFI_BUF_OFFSET; - outfp->wldp_result = WL_LACK_FEATURE; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static int -pcwl_cfg_wepkey(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - uint16_t i; - wldp_t *infp; - wldp_t *outfp; - char *buf; - int iret; - - buf = kmem_zalloc(MAX_BUF_LEN, KM_NOSLEEP); - if (buf == NULL) { - PCWLDBG((CE_NOTE, "can not alloc so much memory!(%d)\n", - MAX_BUF_LEN)); - return (ENOMEM); - } - outfp = (wldp_t *)buf; - bcopy(mp->b_rptr, buf, sizeof (wldp_t)); - infp = (wldp_t *)mp->b_rptr; - - outfp->wldp_length = WIFI_BUF_OFFSET + sizeof (wl_wep_key_tab_t); - if (cmd == WLAN_GET_PARAM) { - outfp->wldp_result = WL_WRITEONLY; - } else if (cmd == WLAN_SET_PARAM) { - (void) pcwl_set_wepkey(pcwl_p, infp->wldp_buf); - outfp->wldp_result = WL_SUCCESS; - } else { - kmem_free(buf, MAX_BUF_LEN); - return (EINVAL); - } -done: - for (i = 0; i < (outfp->wldp_length); i++) - (void) mi_mpprintf_putc((char *)mp, buf[i]); - iret = (int)(outfp->wldp_result); - kmem_free(buf, MAX_BUF_LEN); - return (iret); -} - -static void -pcwl_connect_timeout(void *arg) -{ - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - uint16_t ret = 0; - - mutex_enter(&pcwl_p->pcwl_glock); - PCWL_DISABLE_INTR(pcwl_p); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - goto done; - } - if (ret = pcwl_config_rf(pcwl_p)) { - goto done; - } - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - goto done; - } - PCWL_ENABLE_INTR(pcwl_p); -done: - if (ret) - cmn_err(CE_WARN, "pcwl: connect failed due to hardware error"); - mutex_exit(&pcwl_p->pcwl_glock); - pcwl_p->pcwl_connect_timeout_id = 0; -} - -static int -pcwl_getset(mblk_t *mp, pcwl_maci_t *pcwl_p, uint32_t cmd) -{ - int ret = WL_SUCCESS; - int connect = 0; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - mutex_exit(&pcwl_p->pcwl_glock); - return (PCWL_FAIL); - } - switch (((wldp_t *)mp->b_rptr)->wldp_id) { - case WL_ESSID: - ret = pcwl_cfg_essid(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_essid\n")); - break; - case WL_BSSID: - ret = pcwl_cfg_bssid(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_bssid\n")); - break; - case WL_ESS_LIST: - ret = pcwl_cfg_scan(mp, pcwl_p, cmd); - PCWLDBG((CE_NOTE, "cfg_scan\n")); - break; - case WL_LINKSTATUS: - ret = pcwl_cfg_linkstatus(mp, pcwl_p, cmd); - PCWLDBG((CE_NOTE, "cfg_linkstatus\n")); - break; - case WL_BSS_TYPE: - ret = pcwl_cfg_bsstype(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_bsstype\n")); - break; - case WL_PHY_CONFIG: - ret = pcwl_cfg_phy(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_phy\n")); - break; - case WL_DESIRED_RATES: - ret = pcwl_cfg_desiredrates(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_disred-rates\n")); - break; - case WL_SUPPORTED_RATES: - ret = pcwl_cfg_supportrates(mp, pcwl_p, cmd); - PCWLDBG((CE_NOTE, "cfg_supported-rates\n")); - break; - case WL_POWER_MODE: - ret = pcwl_cfg_powermode(mp, pcwl_p, cmd); - PCWLDBG((CE_NOTE, "cfg_powermode\n")); - break; - case WL_AUTH_MODE: - ret = pcwl_cfg_authmode(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_authmode\n")); - break; - case WL_ENCRYPTION: - ret = pcwl_cfg_encryption(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_encryption\n")); - break; - case WL_WEP_KEY_ID: - ret = pcwl_cfg_wepkeyid(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_wepkeyid\n")); - break; - case WL_CREATE_IBSS: - ret = pcwl_cfg_createibss(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_create-ibss\n")); - break; - case WL_RSSI: - ret = pcwl_cfg_rssi(mp, pcwl_p, cmd); - PCWLDBG((CE_NOTE, "cfg_rssi\n")); - break; - case WL_RADIO: - ret = pcwl_cfg_radio(mp, pcwl_p, cmd); - PCWLDBG((CE_NOTE, "cfg_radio\n")); - break; - case WL_WEP_KEY_TAB: - ret = pcwl_cfg_wepkey(mp, pcwl_p, cmd); - connect = 1; - PCWLDBG((CE_NOTE, "cfg_wepkey\n")); - break; - case WL_SCAN: - mutex_exit(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - mutex_enter(&pcwl_p->pcwl_glock); - ret = pcwl_cmd_scan(pcwl_p); - break; - case WL_LOAD_DEFAULTS: - mutex_exit(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - mutex_enter(&pcwl_p->pcwl_glock); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcwl_loaddef_rf(pcwl_p)) { - ret = (int)WL_HW_ERROR; - PCWLDBG((CE_WARN, "cfg_loaddef_err\n")); - break; - } - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - pcwl_delay(pcwl_p, 1000000); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - PCWLDBG((CE_NOTE, "loaddef\n")); - break; - case WL_DISASSOCIATE: - mutex_exit(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - - mutex_enter(&pcwl_p->pcwl_glock); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - /* - * A workaround here: If the card is in ad-hoc mode, the - * following scan will not work correctly, so any - * 'dladm connect-wifi' which need a scan first will not - * succeed. software reset the card here as a workround. - */ - if ((pcwl_p->pcwl_rf.rf_porttype == WL_BSS_IBSS) && - (pcwl_p->pcwl_chip_type == PCWL_CHIP_LUCENT)) { - if (ret = pcwl_reset_backend(pcwl_p)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcwl_init_nicmem(pcwl_p)) { - ret = (int)WL_HW_ERROR; - break; - } - pcwl_start_locked(pcwl_p); - } - if (ret = pcwl_loaddef_rf(pcwl_p)) { - ret = (int)WL_HW_ERROR; - PCWLDBG((CE_WARN, "cfg_loaddef_err\n")); - break; - } - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - pcwl_delay(pcwl_p, 1000000); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - PCWLDBG((CE_NOTE, "disassociate\n")); - break; - case WL_REASSOCIATE: - case WL_ASSOCIAT: - mutex_exit(&pcwl_p->pcwl_glock); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - mutex_enter(&pcwl_p->pcwl_glock); - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcwl_config_rf(pcwl_p)) { - ret = (int)WL_HW_ERROR; - break; - } - if (ret = pcwl_set_cmd(pcwl_p, WL_CMD_ENABLE, 0)) { - ret = (int)WL_HW_ERROR; - break; - } - PCWLDBG((CE_NOTE, "associate")); - break; - default: - break; - } - mutex_exit(&pcwl_p->pcwl_glock); - if ((cmd == WLAN_SET_PARAM) && (connect)) { - (void) pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - pcwl_p->pcwl_connect_timeout_id = timeout(pcwl_connect_timeout, - pcwl_p, 2 * drv_usectohz(1000000)); - } - return (ret); -} - -static void -pcwl_wlan_ioctl(pcwl_maci_t *pcwl_p, queue_t *wq, mblk_t *mp, uint32_t cmd) -{ - - struct iocblk *iocp = (struct iocblk *)mp->b_rptr; - wldp_t *infp; - uint32_t len, ret; - mblk_t *mp1; - - /* - * sanity check - */ - if (iocp->ioc_count == 0 || !(mp1 = mp->b_cont)) { - miocnak(wq, mp, 0, EINVAL); - return; - } - - /* - * assuming single data block - */ - if (mp1->b_cont) { - freemsg(mp1->b_cont); - mp1->b_cont = NULL; - } - - /* - * we will overwrite everything - */ - mp1->b_wptr = mp1->b_rptr; - - infp = (wldp_t *)mp1->b_rptr; - PCWLDBG((CE_NOTE, "pcwl: wldp->length=0x%x\n", infp->wldp_length)); - PCWLDBG((CE_NOTE, "pcwl: wldp->type =:%s\n", - infp->wldp_type == NET_802_11 ? "NET_802_11" : "Unknown")); - PCWLDBG((CE_NOTE, "pcwl: wldp->id=0x%x\n", infp->wldp_id)); - PCWLDBG((CE_NOTE, "pcwl: wldp->result=0x%x\n", infp->wldp_result)); - - ret = pcwl_getset(mp1, pcwl_p, cmd); - len = msgdsize(mp1); - PCWLDBG((CE_CONT, "pcwl: ioctl message length = %d\n", len)); - miocack(wq, mp, len, ret); - -} - - -static void -pcwl_ioctl(void *arg, queue_t *wq, mblk_t *mp) -{ - struct iocblk *iocp; - uint32_t cmd, ret; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - boolean_t need_privilege = B_TRUE; - - /* - * Validate the command before bothering with the mutexen ... - */ - iocp = (struct iocblk *)mp->b_rptr; - iocp->ioc_error = 0; - cmd = iocp->ioc_cmd; - switch (cmd) { - default: - PCWLDBG((CE_CONT, "pcwl_ioctl: unknown cmd 0x%x", cmd)); - miocnak(wq, mp, 0, EINVAL); - return; - case WLAN_GET_PARAM: - need_privilege = B_FALSE; - break; - case WLAN_SET_PARAM: - case WLAN_COMMAND: - break; - } - - if (need_privilege && (ret = secpolicy_dl_config(iocp->ioc_cr)) != 0) - miocnak(wq, mp, 0, ret); - else - pcwl_wlan_ioctl(pcwl_p, wq, mp, cmd); -} - -/* - * brussels - */ -/* ARGSUSED */ -static int -pcwl_m_setprop(void *arg, const char *pr_name, mac_prop_id_t wldp_pr_num, - uint_t wldp_length, const void *wldp_buf) -{ - int err = 0; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - mutex_exit(&pcwl_p->pcwl_glock); - err = EINVAL; - return (err); - } - - switch (wldp_pr_num) { - /* mac_prop_id */ - case MAC_PROP_WL_ESSID: - err = pcwl_set_essid(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_PHY_CONFIG: - err = pcwl_set_phy(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_KEY_TAB: - err = pcwl_set_wepkey(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_AUTH_MODE: - err = pcwl_set_authmode(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_ENCRYPTION: - err = pcwl_set_encrypt(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_BSSTYPE: - err = pcwl_set_bsstype(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_DESIRED_RATES: - err = pcwl_set_desrates(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_POWER_MODE: - err = pcwl_set_powermode(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_CREATE_IBSS: - err = pcwl_set_ibss(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_BSSID: - case MAC_PROP_WL_RADIO: - case MAC_PROP_WL_WPA: - case MAC_PROP_WL_KEY: - case MAC_PROP_WL_DELKEY: - case MAC_PROP_WL_SETOPTIE: - case MAC_PROP_WL_MLME: - case MAC_PROP_WL_LINKSTATUS: - case MAC_PROP_WL_ESS_LIST: - case MAC_PROP_WL_SUPPORTED_RATES: - case MAC_PROP_WL_RSSI: - case MAC_PROP_WL_CAPABILITY: - case MAC_PROP_WL_SCANRESULTS: - cmn_err(CE_WARN, "pcwl_setprop:" - "opmode not support\n"); - err = ENOTSUP; - break; - default: - cmn_err(CE_WARN, "pcwl_setprop:" - "opmode err\n"); - err = EINVAL; - break; - } - - mutex_exit(&pcwl_p->pcwl_glock); - - if (err == ENETRESET) { - (void) pcwl_set_cmd(pcwl_p, WL_CMD_DISABLE, 0); - if (pcwl_p->pcwl_connect_timeout_id != 0) { - (void) untimeout(pcwl_p->pcwl_connect_timeout_id); - pcwl_p->pcwl_connect_timeout_id = 0; - } - pcwl_p->pcwl_connect_timeout_id = timeout(pcwl_connect_timeout, - pcwl_p, 2 * drv_usectohz(1000000)); - - err = 0; - } - - return (err); -} /* ARGSUSED */ - -/* ARGSUSED */ -static int -pcwl_m_getprop(void *arg, const char *pr_name, mac_prop_id_t wldp_pr_num, - uint_t wldp_length, void *wldp_buf) -{ - int err = 0; - pcwl_maci_t *pcwl_p = (pcwl_maci_t *)arg; - - mutex_enter(&pcwl_p->pcwl_glock); - if (!(pcwl_p->pcwl_flag & PCWL_CARD_READY)) { - mutex_exit(&pcwl_p->pcwl_glock); - err = EINVAL; - return (err); - } - - switch (wldp_pr_num) { - /* mac_prop_id */ - case MAC_PROP_WL_ESSID: - err = pcwl_get_essid(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_BSSID: - err = pcwl_get_bssid(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_PHY_CONFIG: - err = pcwl_get_phy(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_AUTH_MODE: - pcwl_get_authmode(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_ENCRYPTION: - pcwl_get_encrypt(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_BSSTYPE: - pcwl_get_bsstype(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_LINKSTATUS: - err = pcwl_get_linkstatus(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_ESS_LIST: - pcwl_get_esslist(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_SUPPORTED_RATES: - pcwl_get_suprates(wldp_buf); - break; - case MAC_PROP_WL_RSSI: - pcwl_get_param_rssi(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_RADIO: - pcwl_get_radio(wldp_buf); - break; - case MAC_PROP_WL_POWER_MODE: - pcwl_get_powermode(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_CREATE_IBSS: - pcwl_get_ibss(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_DESIRED_RATES: - err = pcwl_get_desrates(pcwl_p, wldp_buf); - break; - case MAC_PROP_WL_CAPABILITY: - case MAC_PROP_WL_WPA: - case MAC_PROP_WL_SCANRESULTS: - case MAC_PROP_WL_KEY_TAB: - case MAC_PROP_WL_KEY: - case MAC_PROP_WL_DELKEY: - case MAC_PROP_WL_SETOPTIE: - case MAC_PROP_WL_MLME: - cmn_err(CE_WARN, "pcwl_getprop:" - "opmode not support\n"); - err = ENOTSUP; - break; - default: - cmn_err(CE_WARN, "pcwl_getprop:" - "opmode err\n"); - err = EINVAL; - break; - } - - mutex_exit(&pcwl_p->pcwl_glock); - - return (err); -} - - -static void -pcwl_m_propinfo(void *arg, const char *pr_name, mac_prop_id_t wlpd_pr_num, - mac_prop_info_handle_t prh) -{ - _NOTE(ARGUNUSED(arg, pr_name)); - - switch (wlpd_pr_num) { - case MAC_PROP_WL_LINKSTATUS: - case MAC_PROP_WL_ESS_LIST: - case MAC_PROP_WL_SUPPORTED_RATES: - case MAC_PROP_WL_RSSI: - mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ); - } -} - - -/* - * quiesce(9E) entry point. - * - * This function is called when the system is single-threaded at high - * PIL with preemption disabled. Therefore, this function must not be - * blocked. - * - * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure. - * DDI_FAILURE indicates an error condition and should almost never happen. - */ -#ifndef __sparc -static int -pcwl_quiesce(dev_info_t *dip) -{ - pcwl_maci_t *pcwl_p; - - pcwl_p = ddi_get_soft_state(pcwl_soft_state_p, ddi_get_instance(dip)); - if (pcwl_p == NULL) - return (DDI_FAILURE); - - if (pcwl_p->pcwl_flag & PCWL_CARD_READY) - pcwl_stop_locked(pcwl_p); - - return (DDI_SUCCESS); -} -#endif diff --git a/usr/src/uts/common/io/pcwl/pcwl.h b/usr/src/uts/common/io/pcwl/pcwl.h deleted file mode 100644 index 4d52a65da2..0000000000 --- a/usr/src/uts/common/io/pcwl/pcwl.h +++ /dev/null @@ -1,948 +0,0 @@ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Hardware specific driver declarations for Lucent and PrismII - * chipsets. - */ - -#ifndef _SYS_PCWL_H -#define _SYS_PCWL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/list.h> - -/* - * Encryption controls. We can enable or disable encryption as - * well as specify up to 4 encryption keys. We can also specify - * which of the four keys will be used for transmit encryption. - */ -#define WL_RID_ENCRYPTION 0xFC20 -#define WL_RID_ENCRYPTION_P2 0xFC28 -#define WL_RID_DEFLT_CRYPT_KEYS 0xFCB0 -#define WL_RID_CRYPT_KEY0_P2 0xFC24 -#define WL_RID_TX_CRYPT_KEY 0xFCB1 -#define WL_RID_TX_CRYPT_KEY_P2 0xFC23 -#define WL_RID_COMP_IDENT 0xFD20 /* version */ -#define WL_RID_WEP_AVAIL 0xFD4F - -#define WL_RID_AUTHTYPE_P2 0xFC2A /* PRISM-II */ -#define WL_RID_AUTHTYPE_L 0xFC21 /* 0xFC21 on Lucent */ -#define WL_AUTHTYPE_SYS_P2 0x1 -#define WL_AUTHTYPE_KEY_P2 0x2 -#define WL_AUTHTYPE_ALL_P2 (WL_AUTHTYPE_SYS_P2 | WL_AUTHTYPE_KEY_P2) - -#define WL_SPEED_1Mbps_P2 0x1 -#define WL_SPEED_2Mbps_P2 0x2 -#define WL_SPEED_55Mbps_P2 0x4 -#define WL_SPEED_11Mbps_P2 0x8 - -/* - * PrismII Tx rate - */ -#define WL_P_TX_RATE_FIX_1M WL_SPEED_1Mbps_P2 -#define WL_P_TX_RATE_FIX_2M WL_SPEED_2Mbps_P2 -#define WL_P_TX_RATE_FIX_5M WL_SPEED_55Mbps_P2 -#define WL_P_TX_RATE_FIX_11M WL_SPEED_11Mbps_P2 -#define WL_P_TX_RATE_AUTO_H \ - (WL_SPEED_11Mbps_P2 | WL_SPEED_55Mbps_P2 | \ - WL_SPEED_2Mbps_P2 | WL_SPEED_1Mbps_P2) -#define WL_P_TX_RATE_AUTO_M \ - (WL_SPEED_55Mbps_P2 | WL_SPEED_2Mbps_P2 | \ - WL_SPEED_1Mbps_P2) -#define WL_P_TX_RATE_AUTO_L \ - (WL_SPEED_2Mbps_P2 | WL_SPEED_1Mbps_P2) - - -#define WL_TIMEOUT 500000 - -/* - * Default port: 0 (only 0 exists on stations) - */ -#define WL_DEFAULT_PORT 0 - -/* - * Lucent TX rate: Default 11Mbps - */ -#define WL_L_TX_RATE_FIX_1M 1 -#define WL_L_TX_RATE_FIX_2M 2 -#define WL_L_TX_RATE_AUTO_H 3 -#define WL_L_TX_RATE_FIX_5M 4 /* 5.5M */ -#define WL_L_TX_RATE_FIX_11M 5 -#define WL_L_TX_RATE_AUTO_L 6 -#define WL_L_TX_RATE_AUTO_M 7 - -#define WL_TX_RATE_FIX_1M(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_FIX_1M : WL_L_TX_RATE_FIX_1M) -#define WL_TX_RATE_FIX_2M(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_FIX_2M : WL_L_TX_RATE_FIX_2M) -#define WL_TX_RATE_AUTO_H(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_AUTO_H : WL_L_TX_RATE_AUTO_H) -#define WL_TX_RATE_FIX_5M(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_FIX_5M : WL_L_TX_RATE_FIX_5M) -#define WL_TX_RATE_FIX_11M(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_FIX_11M : WL_L_TX_RATE_FIX_11M) -#define WL_TX_RATE_AUTO_L(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_AUTO_L : WL_L_TX_RATE_AUTO_L) -#define WL_TX_RATE_AUTO_M(p) \ - (p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \ - WL_P_TX_RATE_AUTO_M : WL_L_TX_RATE_AUTO_M) - -/* - * Default network name: empty string implies any - */ -#define WL_DEFAULT_NETNAME ("") -#define WL_DEFAULT_NODENAME ("solaris node") -#define WL_DEFAULT_AP_DENSITY 1 -#define WL_DEFAULT_RTS_THRESH 2347 -#define WL_DEFAULT_DATALEN 2304 -#define WL_DEFAULT_CREATE_IBSS 0 -#define WL_DEFAULT_PM_ENABLED 0 -#define WL_DEFAULT_MAX_SLEEP 100 -#define WL_DEFAULT_CHAN 3 -#define WL_DEFAULT_TX_CRYPT_KEY 0 - -/* - * Size of Hermes I/O space. - */ -#define WL_IOSIZ 0x40 - -/* - * Hermes command/status registers. - */ -#define WL_COMMAND 0x00 -#define WL_PARAM0 0x02 -#define WL_PARAM1 0x04 -#define WL_PARAM2 0x06 -#define WL_STATUS 0x08 -#define WL_RESP0 0x0A -#define WL_RESP1 0x0C -#define WL_RESP2 0x0E - -/* - * Command register values. - */ -#define WL_CMD_BUSY 0x8000 /* busy bit */ -#define WL_CMD_INI 0x0000 /* initialize */ -#define WL_CMD_ENABLE 0x0001 /* enable */ -#define WL_CMD_DISABLE 0x0002 /* disable */ -#define WL_CMD_DIAG 0x0003 -#define WL_CMD_ALLOC_MEM 0x000A /* allocate NIC memory */ -#define WL_CMD_TX 0x000B /* transmit */ -#define WL_CMD_NOTIFY 0x0010 -#define WL_CMD_INQUIRE 0x0011 -#define WL_CMD_ACCESS 0x0021 -#define WL_CMD_PROGRAM 0x0022 - -#define WL_CMD_CODE_MASK 0x003F - -/* - * Reclaim qualifier bit, applicable to the - * TX and INQUIRE commands. - */ -#define WL_RECLAIM 0x0100 /* reclaim NIC memory */ - -/* - * ACCESS command qualifier bits. - */ -#define WL_ACCESS_READ 0x0000 -#define WL_ACCESS_WRITE 0x0100 - -/* - * PROGRAM command qualifier bits. - */ -#define WL_PROGRAM_DISABLE 0x0000 -#define WL_PROGRAM_ENABLE_RAM 0x0100 -#define WL_PROGRAM_ENABLE_NVRAM 0x0200 -#define WL_PROGRAM_NVRAM 0x0300 - -/* - * Status register values - */ -#define WL_STAT_CMD_CODE 0x003F -#define WL_STAT_DIAG_ERR 0x0100 -#define WL_STAT_INQ_ERR 0x0500 -#define WL_STAT_CMD_RESULT 0x7F00 - -/* - * memory handle management registers - */ -#define WL_INFO_FID 0x10 -#define WL_RX_FID 0x20 -#define WL_ALLOC_FID 0x22 -#define WL_TX_CMP_FID 0x24 - -#define WL_INVALID_FID 0xffff - -/* - * Buffer Access Path (BAP) registers. - * These are I/O channels. you can use each one for - * any desired purpose independently of the other. In general - * though, we use BAP1 for reading and writing LTV records and - * reading received data frames, and BAP0 for writing transmit - * frames. This is a convention though, not a rule. - * For PrismII chip, frequently overlap between BAP0 and BAP1 - * may hang the hardware. this is a known bug, so just use BAP1 - * for PrismII. - */ -#define WL_SEL0 0x18 -#define WL_SEL1 0x1A -#define WL_OFF0 0x1C -#define WL_OFF1 0x1E -#define WL_DATA0 0x36 -#define WL_DATA1 0x38 -#define WL_BAP0 WL_DATA0 -#define WL_BAP1 WL_DATA1 - -#define WL_OFF_BUSY 0x8000 -#define WL_OFF_ERR 0x4000 -#define WL_OFF_DATAOFF 0x0FFF - -/* - * Event registers - */ -#define WL_EVENT_STAT 0x30 /* Event status */ -#define WL_INT_EN 0x32 /* Interrupt enable/disable */ -#define WL_EVENT_ACK 0x34 /* Ack event */ - -/* - * Events - */ -#define WL_EV_TICK 0x8000 /* aux timer tick */ -#define WL_EV_RES 0x4000 /* controller h/w error (time out) */ -#define WL_EV_INFO_DROP 0x2000 /* no RAM to build unsolicited frame */ -#define WL_EV_NO_CARD 0x0800 /* card removed (hunh?) */ -#define WL_EV_DUIF_RX 0x0400 /* wavelan management packet received */ -#define WL_EV_INFO 0x0080 /* async info frame */ -#define WL_EV_CMD 0x0010 /* command completed */ -#define WL_EV_ALLOC 0x0008 /* async alloc/reclaim completed */ -#define WL_EV_TX_EXC 0x0004 /* async xmit completed with failure */ -#define WL_EV_TX 0x0002 /* async xmit completed succesfully */ -#define WL_EV_RX 0x0001 /* async rx completed */ - -#define WL_EV_ALL 0xffff /* all events */ -#define WL_INTRS \ - (WL_EV_RX|WL_EV_TX|WL_EV_TX_EXC|WL_EV_ALLOC|WL_EV_INFO|WL_EV_INFO_DROP) - -/* - * Host software registers - */ -#define WL_SW0 0x28 -#define WL_SW1 0x2A -#define WL_SW2 0x2C -#define WL_SW3 0x2E - -#define WL_CNTL 0x14 - -#define WL_CNTL_AUX_ENA 0xC000 -#define WL_CNTL_AUX_ENA_STAT 0xC000 -#define WL_CNTL_AUX_DIS_STAT 0x0000 -#define WL_CNTL_AUX_ENA_CNTL 0x8000 -#define WL_CNTL_AUX_DIS_CNTL 0x4000 - -#define WL_AUX_PAGE 0x3A -#define WL_AUX_OFFSET 0x3C -#define WL_AUX_DATA 0x3E - -#define WL_RID_DNLD_BUF 0xFD01 - -/* - * Mem sizes (0xFD02). - */ -#define WL_RID_MEMSZ 0xFD02 -#define WL_RID_FWIDENT_P2 0xFD02 - -/* - * NIC Identification (0xFD0B). - */ -#define WL_RID_CARD_ID 0xFD0B - -typedef struct pcwl_ltv_ver { - uint16_t wl_compid; - uint16_t wl_variant; - uint16_t wl_major; - uint16_t wl_minor; -} pcwl_ltv_ver_t; - -#define WL_RID_FWVER 0xFFFF -typedef struct pcwl_ltv_fwver { - uint16_t pri[7]; - uint16_t st[7]; -} pcwl_ltv_fwver_t; - -#define WI_NIC_EVB2 0x8000 -#define WI_NIC_HWB3763 0x8001 -#define WI_NIC_HWB3163 0x8002 -#define WI_NIC_HWB3163B 0x8003 -#define WI_NIC_EVB3 0x8004 -#define WI_NIC_HWB1153 0x8007 -#define WI_NIC_P2_SST 0x8008 /* Prism2 with SST flush */ -#define WI_NIC_PRISM2_5 0x800C -#define WI_NIC_3874A 0x8013 /* Prism2.5 Mini-PCI */ - -/* - * List of intended regulatory domains (0xFD11). - */ -#define WL_RID_DOMAINS 0xFD11 -/* - * CIS struct (0xFD13). - */ -#define WL_RID_CIS 0xFD13 - -/* - * Current MAC port connection status - */ -#define WL_RID_PORTSTATUS 0xFD40 -#define WL_PORT_DISABLED 1 -#define WL_PORT_INITIAL 2 -#define WL_PORT_TO_IBSS 3 -#define WL_PORT_TO_BSS 4 -#define WL_PORT_OOR 5 -#define WL_PORT_RADIO_OFF 7 /* only for miniPci */ - -/* - * Current Service Set the station is connected to - */ -#define WL_RID_SSID 0xFD41 - -/* - * MAC address used as identifier of the BSS the station - * is connected to - */ -#define WL_RID_BSSID 0xFD42 - -/* - * Communications quality (0xFD43). - */ -#define WL_RID_COMMQUAL 0xFD43 - -/* - * Actual system scale thresholds (0xFD46). - */ -#define WL_RID_SYSTEM_SCALE 0xFC06 - -/* - * Actual current transmission rate - */ -#define WL_RID_CUR_TX_RATE 0xFD44 - -/* - * Connection control characteristics. - * 1 == Basic Service Set (BSS), a.k.a IEEE 802.11 Infrastructure - * 2 == Wireless Distribudion System (WDS), Access Point only - * 3 == Pseudo IBSS / Ad Hoc - */ -#define WL_RID_PORTTYPE 0xFC00 -#define WL_PORTTYPE_BSS 0x1 -#define WL_PORTTYPE_WDS 0x2 -#define WL_PORTTYPE_ADHOC 0x3 - -/* - * Mac addresses. - */ -#define WL_RID_MAC_NODE 0xFC01 -#define WL_RID_MAC_WDS 0xFC08 - -/* - * Station set identification (SSID). - */ -#define WL_RID_DESIRED_SSID 0xFC02 -#define WL_RID_OWN_SSID 0xFC04 - -/* - * Set communications channel (radio frequency). - */ -#define WL_RID_OWN_CHNL 0xFC03 -#define WL_RID_CURRENT_CHNL 0xFDC1 - -/* - * Frame data size. - */ -#define WL_RID_MAX_DATALEN 0xFC07 - -/* - * ESS power management enable - */ -#define WL_RID_PM_ENABLED 0xFC09 - -/* - * ESS max PM sleep internal - */ -#define WL_RID_MAX_SLEEP 0xFC0C - -/* - * Set our station name. - */ -#define WL_RID_NODENAME 0xFC0E - -/* - * Multicast addresses to be put in filter. We're - * allowed up to 16 addresses in the filter. - */ -#define WL_RID_MCAST 0xFC80 - -/* - * Create IBSS. - */ -#define WL_RID_CREATE_IBSS 0xFC81 - -#define WL_RID_FRAG_THRESH 0xFC82 -#define WL_RID_RTS_THRESH 0xFC83 - -/* - * TX rate control - * 0 == Fixed 1mbps - * 1 == Fixed 2mbps - * 2 == auto fallback - */ -#define WL_RID_TX_RATE 0xFC84 - -/* - * promiscuous mode. - */ -#define WL_RID_PROMISC 0xFC85 - -/* - * scan ssid - */ -#define WL_RID_SCAN_SSID 0xFCB2 - -/* - * Auxiliary Timer tick interval - */ -#define WL_RID_TICK_TIME 0xFCE0 - -/* - * PrismII scan - */ -#define WL_RID_SCAN_REQUEST 0xFCE1 -#define WL_RID_HSCAN_REQUEST 0xFCE5 - -/* - * Information frame types. - */ -#define WL_INFO_NOTIFY 0xF000 /* Handover address */ -#define WL_INFO_COUNTERS 0xF100 /* Statistics counters */ -#define WL_INFO_SCAN_RESULTS 0xF101 /* Scan results */ -#define WL_INFO_HSCAN_RESULTS 0xF103 /* HostScan results */ -#define WL_INFO_LINK_STAT 0xF200 /* Link status */ -#define WL_INFO_ASSOC_STAT 0xF201 /* Association status */ - -/* - * Link status - */ -#define WL_LINK_CONNECT 1 -#define WL_LINK_DISCONNECT 2 -#define WL_LINK_AP_CR 3 /* AP change */ -#define WL_LINK_AP_OOR 4 /* AP out of range */ -#define WL_LINK_AP_IR 5 /* AP in range */ - -typedef struct wl_scan_result { - uint16_t wl_srt_chid; /* bss channel id */ - uint16_t wl_srt_anl; /* noise level */ - uint16_t wl_srt_sl; /* signal level */ - uint8_t wl_srt_bssid[6]; /* mac address of the bss */ - uint16_t wl_srt_bcnint; /* bss beacon interval */ - uint16_t wl_srt_cap; /* bss capability */ - - uint16_t wl_srt_ssidlen; /* ssid name length */ - char wl_srt_ssid[32]; /* ssid */ - - uint16_t wl_srt_suprates[5]; /* supported rates */ - uint16_t wl_srt_rate; /* actual data rate of the probe */ - uint16_t wl_srt_atim; -} wl_scan_result_t; - -#define WL_SRT_MAX_NUM 32 /* max number of scan result stored */ -#define WL_SCAN_TIMEOUT_MAX 30 /* seconds after which the scan item ages */ -#define WL_SCAN_AGAIN_THRESHOLD 5 /* threshold below which card scan again */ -#define WL_MAX_SCAN_TIMES 2 /* max scan times per scan command */ - -typedef struct wl_scan_list { - wl_scan_result_t wl_val; - uint32_t wl_timeout; - list_node_t wl_scan_node; -} wl_scan_list_t; - -#define WL_FTYPE_MGMT 0x0000 -#define WL_FTYPE_CTL 0x0004 -#define WL_FTYPE_DATA 0x0008 - -/* - * SNAP (sub-network access protocol) constants for transmission - * of IP datagrams over IEEE 802 networks, taken from RFC1042. - * We need these for the LLC/SNAP header fields in the TX/RX frame - * structure. - */ -#define WL_SNAP_K1 0xaa /* assigned global SAP for SNAP */ -#define WL_SNAP_K2 0x00 -#define WL_SNAP_CONTROL 0x03 /* unnumbered information format */ -#define WL_SNAP_WORD0 (WL_SNAP_K1 | (WL_SNAP_K1 << 8)) -#define WL_SNAP_WORD1 (WL_SNAP_K2 | (WL_SNAP_CONTROL << 8)) -#define WL_SNAPHDR_LEN 0x6 - -/* - * Hermes transmit/receive frame structure - */ -typedef struct wl_frame { - uint16_t wl_status; /* 0x00 */ - uint16_t wl_rsvd0; /* 0x02 */ - uint16_t wl_rsvd1; /* 0x04 */ - uint16_t wl_q_info; /* 0x06 */ - uint16_t wl_rsvd2; /* 0x08 */ - uint16_t wl_rsvd3; /* 0x0A */ - uint16_t wl_tx_ctl; /* 0x0C */ - uint16_t wl_frame_ctl; /* 0x0E */ - uint16_t wl_id; /* 0x10 */ - uint8_t wl_addr1[6]; /* 0x12 */ - uint8_t wl_addr2[6]; /* 0x18 */ - uint8_t wl_addr3[6]; /* 0x1E */ - uint16_t wl_seq_ctl; /* 0x24 */ - uint8_t wl_addr4[6]; /* 0x26 */ - uint16_t wl_dat_len; /* 0x2C */ - - uint8_t wl_dst_addr[6]; /* 0x2E */ - uint8_t wl_src_addr[6]; /* 0x34 */ - uint16_t wl_len; /* 0x3A */ - uint16_t wl_dat[3]; /* 0x3C */ /* SNAP header */ - uint16_t wl_type; /* 0x42 */ -} wl_frame_t; - -static wl_frame_t wl_frame_default = { - 0, /* wl_status 0x00 */ - 0, /* wl_rsvd0 0x02 */ - 0, /* wl_rsvd1 0x04 */ - 0, /* wl_q_info 0x06 */ - 0, /* wl_rsvd2 0x08 */ - 0, /* wl_rsvd3 0x0A */ - 0, /* wl_tx_ctl 0x0C */ - WL_FTYPE_DATA, /* wl_frame_ctl 0x0E */ - 0, /* wl_id 0x10 */ - { 0, 0, 0, 0, 0, 0 }, /* wl_addr1[6] 0x12 */ - { 0, 0, 0, 0, 0, 0 }, /* wl_addr2[6] 0x18 */ - { 0, 0, 0, 0, 0, 0 }, /* wl_addr3[6] 0x1E */ - 0, /* wl_seq_ctl 0x24 */ - { 0, 0, 0, 0, 0, 0 }, /* wl_addr4[6] 0x26 */ - (uint16_t)-WL_SNAPHDR_LEN, /* wl_dat_len 0x2C */ - - { 0, 0, 0, 0, 0, 0 }, /* wl_dst_addr[6] 0x2E */ - { 0, 0, 0, 0, 0, 0 }, /* wl_src_addr[6] 0x34 */ - (uint16_t)-WL_SNAPHDR_LEN, /* wl_len 0x3A */ - { WL_SNAP_WORD0, - WL_SNAP_WORD1, 0 }, /* wl_dat[3] 0x3C */ /* SNAP header */ - 0 /* wl_type 0x42 */ -}; - -#define MLEN(mp) ((mp)->b_wptr - (mp)->b_rptr) -#define ETH_HDRLEN (sizeof (struct ether_header)) -#define WL_802_3_HDRLEN 0x2E -#define WL_802_11_HDRLEN 0x44 -#define WL_802_11_RAW_HDRLEN 0x3C - -#define WL_STAT_BADCRC 0x0001 -#define WL_STAT_UNDECRYPTABLE 0x0002 -#define WL_STAT_ERRSTAT 0x0003 -#define WL_STAT_MAC_PORT 0x0700 -#define WL_STAT_1042 0x2000 /* RFC1042 encoded */ -#define WL_STAT_TUNNEL 0x4000 /* Bridge-tunnel encoded */ -#define WL_STAT_WMP_MSG 0x6000 /* WaveLAN-II management protocol */ -#define WL_RXSTAT_MSG_TYPE 0xE000 - -#define WL_ENC_TX_802_3 0x00 -#define WL_ENC_TX_802_11 0x11 -#define WL_ENC_TX_E_II 0x0E - -#define WL_ENC_TX_1042 0x00 -#define WL_ENC_TX_TUNNEL 0xF8 - -#define WL_TXCNTL_MACPORT 0x00FF -#define WL_TXCNTL_STRUCTTYPE 0xFF00 -#define WL_TXCNTL_TXOK 0x2 -#define WL_TXCNTL_TXEX 0x4 -#define WL_TXCNTL_SET (WL_TXCNTL_TXOK | WL_TXCNTL_TXEX) - -typedef struct rf_ckey { - uint16_t ckey_len; - uint8_t ckey_dat[14]; -} rf_ckey_t; - -/* - * Configurable parameters of the RF interface - * All the info here is passed to the card through PIO. - */ -typedef struct pcwl_rf { - uint16_t rf_max_datalen; - uint16_t rf_create_ibss; - uint16_t rf_porttype; - uint16_t rf_rts_thresh; - uint16_t rf_tx_rate; - uint16_t rf_system_scale; - uint16_t rf_pm_enabled; - uint16_t rf_max_sleep; - uint16_t rf_own_chnl; - uint16_t rf_port_no; - char rf_own_ssid[34]; - char rf_desired_ssid[34]; - char rf_nodename[34]; - uint16_t rf_promiscuous; - uint16_t rf_encryption; /* use encryption? */ - uint16_t rf_authtype; /* prism2 only */ - uint16_t rf_tx_crypt_key; - rf_ckey_t rf_ckeys[4]; -} pcwl_rf_t; - -#define PCWL_MCAST_ENTSHIFT 4 -#define PCWL_MCAST_ENTRIES (1 << PCWL_MCAST_ENTSHIFT) -#define PCWL_MCBUF_LEN (ETHERADDRL << PCWL_MCAST_ENTSHIFT) -#define PCWL_MCBUF_WORDS (PCWL_MCBUF_LEN >> 1) - -typedef enum { - WLC_TX_UNICAST_FRAMES, /* 0+ */ - WLC_TX_MULTICAST_FRAMES, /* 1+ */ - WLC_TX_FRAGMENTS, /* 2+ */ - WLC_TX_UNICAST_OCTETS, /* 3+ */ - WLC_TX_MULTICAST_OCTETS, /* 4 */ - WLC_TX_DEFERRED_XMITS, /* 5+ */ - WLC_TX_SINGLE_RETRIES, /* 6+ */ - WLC_TX_MULTI_RETRIES, /* 7+ */ - WLC_TX_RETRY_LIMIT, /* 8+ */ - WLC_TX_DISCARDS, /* 9+ */ - WLC_RX_UNICAST_FRAMES, /* 10+ */ - WLC_RX_MULTICAST_FRAMES, /* 11+ */ - WLC_RX_FRAGMENTS, /* 12+ */ - WLC_RX_UNICAST_OCTETS, /* 13+ */ - WLC_RX_MULTICAST_OCTETS, /* 14 */ - WLC_RX_FCS_ERRORS, /* 15+ */ - WLC_RX_DISCARDS_NOBUF, /* 16+ */ - WLC_TX_DISCARDS_WRONG_SA, /* 17+ */ - WLC_RX_WEP_CANT_DECRYPT, /* 18+ */ - WLC_RX_MSG_IN_MSG_FRAGS, /* 19+ */ - WLC_RX_MSG_IN_BAD_MSG_FRAGS, /* 20+ */ - WLC_STAT_CNT /* 21 - keep it as the last entry */ -} pcwl_cntr_offset; - -#define WL_XMT_BUF_NUM 8 -typedef struct wl_tx_ring_data { - uint16_t wl_tx_fids[WL_XMT_BUF_NUM]; - uint16_t wl_tx_ring[WL_XMT_BUF_NUM]; - int wl_tx_prod; - int wl_tx_cons; - kmutex_t wl_tx_lock; /* for send only */ -} pcwl_txring_t; - -#define PCWL_DEVICE_PCI 0 -#define PCWL_DEVICE_PCCARD 1 - -/* - * The macinfo is really used as the softstate structure. - * - * pcwl_mh - mac_handle_t structure - * pcwl_cslock - lock for card services request. Used with pcwl_cscv - * pcwl_cscv - condition variable to wait for card events - * pcwl_chdl - client handle, an uint32_t bit mask encoding for socket, - * function, and client info. - * See cs_priv.h MAKE_CLIENT_HANDLE. - * pcwl_log_sock - holds the logical to physical translation for this card. - * Specifically has physical adapter and socket #. - * Socket # is the same as part of the pcwl_chdl encoding. - * Physical adapter # is from card service socket impl. - */ -typedef struct pcwl_macinfo { - mac_handle_t pcwl_mh; - dev_info_t *pcwl_dip; - int pcwl_device_type; /* pci or pcmcia card */ - kmutex_t pcwl_cslock; /* for card services */ - kcondvar_t pcwl_cscv; /* for card services */ - client_handle_t pcwl_chdl; /* s,f,c encoding, cs_priv.h */ - map_log_socket_t pcwl_log_sock; /* logical/phys socket map */ - - int pcwl_socket; /* socket number */ - int pcwl_config_hi; /* cfttbl index */ - int pcwl_config; /* default config index */ - int pcwl_vcc; /* vcc level */ - int pcwl_iodecode; /* # of address lines */ - int pcwl_chip_type; /* Lucent or Prism-II */ - - uint8_t pcwl_mac_addr[ETHERADDRL]; - uint8_t pcwl_bssid[ETHERADDRL]; - uint16_t pcwl_has_wep; /* has encryption capability */ - uint32_t pcwl_flag; - uint32_t pcwl_reschedule_need; - pcwl_rf_t pcwl_rf; /* RF interface parameters */ - - uint16_t pcwl_dmem_id; /* nic mem id for tx buffer */ - uint16_t pcwl_mgmt_id; /* nic mem id for mgmt buffer */ - pcwl_txring_t pcwl_txring; - - uint16_t pcwl_mcast[PCWL_MCBUF_WORDS]; /* MC filters */ - - kmutex_t pcwl_scanlist_lock; /* scanlist lock */ - kmutex_t pcwl_glock; /* generic lock */ - - caddr_t pcwl_bar; /* for pci device only */ - ddi_acc_handle_t pcwl_handle; - caddr_t pcwl_cfg_base; - ddi_acc_handle_t pcwl_cfg_handle; - - ddi_acc_handle_t pcwl_port; /* for pcmcia device only */ - - ddi_iblock_cookie_t pcwl_ib_cookie; - ddi_softintr_t pcwl_softint_id; /* pcwl_intr soft intr id */ - - uint16_t pcwl_cntrs_t[WLC_STAT_CNT]; - uint64_t pcwl_cntrs_s[WLC_STAT_CNT]; - uint64_t pcwl_noxmtbuf; - timeout_id_t pcwl_scanlist_timeout_id; - list_t pcwl_scan_list; - uint16_t pcwl_scan_num; - uint16_t pcwl_rssi; - timeout_id_t pcwl_connect_timeout_id; -} pcwl_maci_t; - -#define PCWL_IDENT_STRING modldrv.drv_linkinfo -#define PCWL_CHIP_LUCENT 0 -#define PCWL_CHIP_PRISMII 1 -#define HDL(pcwl_p) ((pcwl_p)->pcwl_port) -#define GLD3(pcwl_p) ((pcwl_p)->pcwl_mh) -#define DIP(pcwl_p) ((pcwl_p)->pcwl_dip) -#define RF(pcwl_p) (&(pcwl_p)->pcwl_rf) - -#define PCWL_CARD_INTREN 0x1 -#define PCWL_SOFTINTR 0x2 /* high level and soft intr enabled */ -#define PCWL_CARD_LINKUP 0x4 /* link status of the STA */ -#define PCWL_CARD_GSTAT 0x8 -#define PCWL_ATTACHED 0x10 -#define PCWL_CS_REGISTERED 0x20 -#define PCWL_ENABLED 0x40 -#define PCWL_CARD_READY 0x80 -#define PCWL_CARD_FAILED 0x100 -#define PCWL_CARD_INTR 0x200 -#define PCWL_CARD_PLUMBED 0x400 -#define PCWL_CARD_SUSPEND 0x800 - -#define PCWL_STATE_IDLE 0x1 - -#define PCWL_NICMEM_SZ (2048) /* 80211MTU set as 1500, so 2k here */ - -static int pcwl_probe(dev_info_t *dip); -static int pcwl_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); -static int pcwl_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); - -static int pcwl_register_cs(dev_info_t *dip, pcwl_maci_t *pcwl_p); -static void pcwl_unregister_cs(pcwl_maci_t *pcwl_p); -static void pcwl_destroy_locks(pcwl_maci_t *pcwl_p); -static int pcwl_reset_backend(pcwl_maci_t *pcwl_p); -static int pcwl_get_cap(pcwl_maci_t *pcwl_p); -static int pcwl_card_insert(pcwl_maci_t *pcwl_p); -static int pcwl_ev_hdlr(event_t ev, int pri, event_callback_args_t *arg); -static void pcwl_card_remove(pcwl_maci_t *pcwl_p); -static int pcwl_init_nicmem(pcwl_maci_t *pcwl_p); - -/* - * high level device access primitives, glock must held before calling - */ -static uint16_t pcwl_set_cmd(pcwl_maci_t *pcwl_p, uint16_t mode, uint16_t type); -static uint16_t pcwl_set_ch(pcwl_maci_t *, uint16_t, uint16_t, uint16_t); -static uint16_t pcwl_get_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type, - uint16_t *val_p); -static uint16_t pcwl_put_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type, - uint16_t *val_p); -static uint16_t pcwl_fil_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type, - uint16_t val); -static uint16_t pcwl_put_str(pcwl_maci_t *pcwl_p, uint16_t type, char *str_p); -static uint16_t pcwl_rdch0(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off, - uint16_t *buf_p, int len, int order); -static uint16_t pcwl_wrch1(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off, - uint16_t *buf_p, int len, int order); -static int pcwl_config_rf(pcwl_maci_t *pcwl_p); -static int pcwl_loaddef_rf(pcwl_maci_t *pcwl_p); -static void pcwl_start_locked(pcwl_maci_t *pcwl_p); -static void pcwl_stop_locked(pcwl_maci_t *pcwl_p); -static int pcwl_saddr_locked(pcwl_maci_t *pcwl_p); -static uint16_t pcwl_alloc_nicmem(pcwl_maci_t *pcwl_p, uint16_t len, - uint16_t *id_p); -static void pcwl_chip_type(pcwl_maci_t *pcwl_p); - -/* - * Required driver entry points for mac - */ -static int pcwl_start(void *); -static void pcwl_stop(void *); -static int pcwl_saddr(void *, const uint8_t *); -static mblk_t *pcwl_tx(void *, mblk_t *); -static int pcwl_send(pcwl_maci_t *, mblk_t *); -static int pcwl_prom(void *, boolean_t); -static int pcwl_gstat(void *, uint_t, uint64_t *); -static int pcwl_sdmulti(void *, boolean_t, const uint8_t *); -static void pcwl_ioctl(void *, queue_t *, mblk_t *); - -static uint_t pcwl_intr(caddr_t arg); -static uint_t pcwl_intr_hi(caddr_t arg); -static void pcwl_rcv(pcwl_maci_t *pcwl_p); -static uint32_t pcwl_txdone(pcwl_maci_t *pcwl_p); -static void pcwl_infodone(pcwl_maci_t *pcwl_p); -static void pcwl_ssid_scan(pcwl_maci_t *, uint16_t, uint16_t, uint16_t); - -/* - * prototypes of the function for wifi ioctl - */ -static int pcwl_cfg_essid(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_bssid(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_scan(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_linkstatus(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_bsstype(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_phy(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_desiredrates(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_supportrates(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_powermode(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_authmode(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_encryption(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_wepkeyid(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_createibss(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_rssi(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_radio(mblk_t *, pcwl_maci_t *, uint32_t); -static int pcwl_cfg_wepkey(mblk_t *, pcwl_maci_t *, uint32_t); -static void pcwl_wlan_ioctl(pcwl_maci_t *, queue_t *, mblk_t *, uint32_t); -static int pcwl_getset(mblk_t *, pcwl_maci_t *, uint32_t); - -static void pcwl_scanlist_timeout(void *); -static void pcwl_delete_scan_item(pcwl_maci_t *, wl_scan_list_t *); -static int pcwl_add_scan_item(pcwl_maci_t *, wl_scan_result_t); -static void pcwl_get_rssi(pcwl_maci_t *); -static void pcwl_connect_timeout(void *arg); - -#define RDCH0(h, t, o, b_p, l) pcwl_rdch0(h, t, o, b_p, l, 1) -#define WRCH1(h, t, o, b_p, l) pcwl_wrch1(h, t, o, b_p, l, 1) -#define RDPKT(h, t, o, b_p, l) pcwl_rdch0(h, t, o, b_p, l, 0) -#define WRPKT(h, t, o, b_p, l) pcwl_wrch1(h, t, o, b_p, l, 0) - -#define FIL_LTV(pcwl_p, len, type, val) \ - (void) pcwl_fil_ltv(pcwl_p, len, type, val) -#define PUT_LTV(pcwl_p, len, type, v_p) \ - (void) pcwl_put_ltv(pcwl_p, len, type, v_p) -#define PUT_STR(pcwl_p, type, str_p) \ - (void) pcwl_put_str(pcwl_p, type, str_p) - -#define PCWL_READ(p, o, v) { \ - if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \ - uint16_t t = ddi_get16(p->pcwl_handle, \ - (uint16_t *)(p->pcwl_bar + 2*(o))); \ - v = LE_16(t); \ - } else { \ - uint16_t t = csx_Get16(HDL(p), o); \ - v = LE_16(t); \ - }\ -} -#define PCWL_WRITE(p, o, v) { \ - if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \ - ddi_put16(p->pcwl_handle, \ - (uint16_t *)(p->pcwl_bar + 2*(o)), LE_16(v)); \ - } else { \ - csx_Put16(HDL(p), o, LE_16(v)); \ - }\ -} -#define PCWL_READ_P(p, o, v, h) { \ - if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \ - uint16_t t = ddi_get16(p->pcwl_handle, \ - (uint16_t *)(p->pcwl_bar + 2*(o))); \ - *(v) = h ? LE_16(t) : t; \ - } else { \ - uint16_t t = csx_Get16(HDL(p), o); \ - *(v) = h ? LE_16(t) : t; \ - }\ -} -#define PCWL_WRITE_P(p, o, v, h) { \ - if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \ - ddi_put16(p->pcwl_handle, (uint16_t *)(p->pcwl_bar + 2*(o)), \ - h ? LE_16(*(v)) : (*(v))); \ - } else {\ - csx_Put16(HDL(p), o, h ? LE_16(*(v)) : (*(v))); \ - }\ -} - -#ifdef _BIG_ENDIAN -#define PCWL_SWAP16(buf_p, len) { \ - int pcwl_swap_len = len; \ - for (pcwl_swap_len = (pcwl_swap_len + 1) >> 1; pcwl_swap_len; ) { \ - uint16_t val; \ - pcwl_swap_len--; \ - val = *((uint16_t *)(buf_p) + pcwl_swap_len); \ - *((uint16_t *)(buf_p) + pcwl_swap_len) = LE_16(val); \ - } \ -} -#else /* _BIG_ENDIAN */ -#define PCWL_SWAP16(buf_p, len) -#endif /* _BIG_ENDIAN */ - -#define PCWL_ENABLE_INTR(pcwl_p) {\ - PCWL_WRITE(pcwl_p, WL_INT_EN, WL_INTRS);\ -} -#define PCWL_DISABLE_INTR(pcwl_p) { \ - PCWL_WRITE(pcwl_p, WL_INT_EN, 0); \ - PCWL_WRITE(pcwl_p, WL_EVENT_ACK, 0xffff);\ -} - -/* - * 16-bit driver private status code - */ -#define PCWL_SUCCESS 0x0 -#define PCWL_FAIL 0x1 -#define PCWL_TIMEDOUT_CMD 0x10 -#define PCWL_TIMEDOUT_ACCESS 0x11 -#define PCWL_TIMEDOUT_TARGET 0x12 -#define PCWL_BADLEN 0x13 -#define PCWL_BADTYPE 0x14 -#define PCWL_TIMEDOUT_ALLOC 0x15 -#define PCWL_FAILURE_CMD 0x16 - -#define PCWL_STATUS_MAX 0xffff -#define N_PCWL 2 - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_PCWL_H */ diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index a24490bf15..033dc2d703 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -21,6 +21,7 @@ # # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2013, Joyent, Inc. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # include $(SRC)/uts/Makefile.uts @@ -889,14 +890,6 @@ FSHDRS= \ zfs.h \ zut.h -PCMCIAHDRS= \ - pcata.h \ - pcser_conf.h \ - pcser_io.h \ - pcser_reg.h \ - pcser_manuspec.h \ - pcser_var.h - SCSIHDRS= \ scsi.h \ scsi_address.h \ @@ -1190,7 +1183,6 @@ CHECKHDRS= \ $(FMIOHDRS:%.h=fm/io/%.check) \ $(FSHDRS:%.h=fs/%.check) \ $(LVMHDRS:%.h=lvm/%.check) \ - $(PCMCIAHDRS:%.h=pcmcia/%.check) \ $(SCSIHDRS:%.h=scsi/%.check) \ $(SCSIADHDRS:%.h=scsi/adapters/%.check) \ $(SCSICONFHDRS:%.h=scsi/conf/%.check) \ @@ -1260,7 +1252,6 @@ CHECKHDRS= \ $(ROOTHERMONHDRS) \ $(ROOTMLNXHDRS) \ $(ROOTLVMHDRS) \ - $(ROOTPCMCIAHDRS) \ $(ROOTSCSIHDRS) \ $(ROOTSCSIADHDRS) \ $(ROOTSCSICONFHDRS) \ @@ -1330,7 +1321,6 @@ install_h: \ $(ROOTHERMONHDRS) \ $(ROOTMLNXHDRS) \ $(ROOTLVMHDRS) \ - $(ROOTPCMCIAHDRS) \ $(ROOTSCSIHDRS) \ $(ROOTSCSIADHDRS) \ $(ROOTSCSIISCSIHDRS) \ diff --git a/usr/src/uts/common/sys/Makefile.syshdrs b/usr/src/uts/common/sys/Makefile.syshdrs index a20451fbff..1871c019f1 100644 --- a/usr/src/uts/common/sys/Makefile.syshdrs +++ b/usr/src/uts/common/sys/Makefile.syshdrs @@ -19,6 +19,7 @@ # CDDL HEADER END # # Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2013 Garrett D'Amore <garrett@damore.org> # # Common definitions for open and closed headers. @@ -103,9 +104,6 @@ iscsit/%.check: iscsit/%.h lvm/%.check: lvm/%.h $(DOT_H_CHECK) -pcmcia/%.check: pcmcia/%.h - $(DOT_H_CHECK) - scsi/%.check: scsi/%.h $(DOT_H_CHECK) @@ -219,7 +217,6 @@ ROOTDIRS= \ $(ROOTDIR)/idm \ $(ROOTDIR)/iscsit \ $(ROOTDIR)/lvm \ - $(ROOTDIR)/pcmcia \ $(ROOTDIR)/scsi \ $(ROOTDIR)/scsi/conf \ $(ROOTDIR)/scsi/generic \ @@ -290,8 +287,6 @@ ROOTFSHDRS= $(FSHDRS:%=$(ROOTDIR)/fs/%) ROOTLVMHDRS= $(ALL_LVMHDRS:%=$(ROOTDIR)/lvm/%) -ROOTPCMCIAHDRS= $(PCMCIAHDRS:%=$(ROOTDIR)/pcmcia/%) - ROOTSCSIHDRS= $(SCSIHDRS:%=$(ROOTDIR)/scsi/%) ROOTSATAGENHDRS= $(SATAGENHDRS:%=$(ROOTDIR)/sata/%) ROOTSCSICONFHDRS= $(SCSICONFHDRS:%=$(ROOTDIR)/scsi/conf/%) @@ -342,13 +337,13 @@ ROOTHOTPLUGPCIHDRS= $(HOTPLUGPCIHDRS:%=$(ROOTDIR)/hotplug/pci/%) ROOTTSOLHDRS= $(TSOLHDRS:%=$(ROOTDIR)/tsol/%) sparc_ROOTHDRS= $(ROOTSDKTPHDRS) $(ROOTSCSICADHDRS) $(ROOTSCSITARGETSHDRS) \ - $(ROOTUSBHDRS) $(ROOTUSBHUBDHDRS) $(ROOTPCMCIAHDRS) \ + $(ROOTUSBHDRS) $(ROOTUSBHUBDHDRS) \ $(ROOTUSBAUDHDRS) $(ROOTUSBHIDHDRS) $(ROOTUSBMSHDRS) \ $(ROOTUSBPRNHDRS) $(ROOTUGENHDRS) $(ROOTUSBVIDHDRS) \ $(ROOTUWBHDRS) $(ROOTUWBAHDRS) $(ROOTUSBHWARCHDRS) i386_ROOTHDRS= $(ROOTDKTPHDRS) $(ROOTPCHDRS) $(ROOTSCSITARGETSHDRS) \ - $(ROOTSCSIVHCIHDRS) $(ROOTPCMCIAHDRS) $(ROOTHOTPLUGHDRS) \ + $(ROOTSCSIVHCIHDRS) $(ROOTHOTPLUGHDRS) \ $(ROOTHOTPLUGPCIHDRS) $(ROOTSATAGENHDRS) \ $(ROOTUWBHDRS) $(ROOTUWBAHDRS) $(ROOTUSBHWARCHDRS) @@ -434,9 +429,6 @@ $(ROOTDIR)/ib/adapters/%: ib/adapters/% $(ROOTDIR)/lvm/%: lvm/% $(INS.file) -$(ROOTDIR)/pcmcia/%: pcmcia/% - $(INS.file) - $(ROOTDIR)/scsi/%: scsi/% $(INS.file) diff --git a/usr/src/uts/common/sys/pcmcia/pcata.h b/usr/src/uts/common/sys/pcmcia/pcata.h deleted file mode 100644 index 40b4b59018..0000000000 --- a/usr/src/uts/common/sys/pcmcia/pcata.h +++ /dev/null @@ -1,658 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_PCATA_H -#define _SYS_PCATA_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#define FALSE 0 -#define TRUE 1 - -#if defined(DEBUG) -#define ATA_DEBUG 1 -#endif /* defined(DEBUG) */ - -/* - * port offsets from base address ioaddr1 - */ -#define AT_DATA 0x00 /* data register */ -#define AT_ERROR 0x01 /* error register (read) */ -#define AT_FEATURE 0x01 /* feature (write) */ -#define AT_COUNT 0x02 /* sector count */ -#define AT_SECT 0x03 /* sector number */ -#define AT_LCYL 0x04 /* cylinder low byte */ -#define AT_HCYL 0x05 /* cylinder high byte */ -#define AT_DRVHD 0x06 /* drive/head register */ -#define AT_STATUS 0x07 /* status/command register */ -#define AT_CMD 0x07 /* status/command register */ - -/* - * port offsets from base address ioaddr2 - */ -#define AT_ALTSTATUS 0x0E /* alternate status (read) */ -#define AT_DEVCTL 0x0E /* device control (write) */ -#define AT_DRVADDR 0x0F /* drive address (read) */ - - -/* - * Device control register - */ - -#define AT_NIEN 0x02 /* disable interrupts */ -#define AT_SRST 0x04 /* controller reset */ -#define AT_DEVCTL_D3 0x08 /* bit 3 is always set, see spec */ - -#define ENABLE_INTERRUPT AT_DEVCTL_D3 /* clear AT_NIEN bit */ -#define DISABLE_INTERRUPT AT_DEVCTL_D3|AT_NIEN - -/* - * Status bits from AT_STATUS register - */ -#define ATS_BSY 0x80 /* controller busy */ -#define ATS_DRDY 0x40 /* drive ready */ -#define ATS_DWF 0x20 /* write fault */ -#define ATS_DSC 0x10 /* seek operation complete */ -#define ATS_DRQ 0x08 /* data request */ -#define ATS_CORR 0x04 /* ECC correction applied */ -#define ATS_IDX 0x02 /* disk revolution index */ -#define ATS_ERR 0x01 /* error flag */ - -/* - * Status bits from AT_ERROR register - */ -#define ATE_AMNF 0x01 /* address mark not found */ -#define ATE_TKONF 0x02 /* track 0 not found */ -#define ATE_ABORT 0x04 /* aborted command */ -#define ATE_IDNF 0x10 /* ID not found */ -#define ATE_UNC 0x40 /* uncorrectable data error */ -#define ATE_BBK 0x80 /* bad block detected */ - -/* - * Drive selectors for AT_DRVHD register - */ -#define ATDH_DRIVE0 0xa0 /* or into AT_DRVHD to select drive 0 */ -#define ATDH_DRIVE1 0xb0 /* or into AT_DRVHD to select drive 1 */ - -/* - * ATA commands. - */ -#define ATC_DIAG 0x90 /* diagnose command */ -#define ATC_RECAL 0x10 /* restore cmd, bottom 4 bits step rate */ -#define ATC_SEEK 0x70 /* seek cmd, bottom 4 bits step rate */ -#define ATC_RDVER 0x40 /* read verify cmd */ -#define ATC_RDSEC 0x20 /* read sector cmd */ -#define ATC_RDLONG 0x23 /* read long without retry */ -#define ATC_WRSEC 0x30 /* write sector cmd */ -#define ATC_SETMULT 0xc6 /* set multiple mode */ -#define ATC_RDMULT 0xc4 /* read multiple */ -#define ATC_WRMULT 0xc5 /* write multiple */ -#define ATC_FORMAT 0x50 /* format track command */ -#define ATC_SETPARAM 0x91 /* set parameters command */ -#define ATC_READPARMS 0xec /* Read Parameters command */ -#define ATC_READDEFECTS 0xa0 /* Read defect list */ -#define ATC_SET_FEAT 0xef /* set features */ -#define ATC_IDLE_IMMED 0xe1 /* idle immediate */ -#define ATC_STANDBY_IM 0xe0 /* standby immediate */ -#define ATC_ACK_MC 0xdb /* acknowledge media change */ -#define ATC_DOOR_LOCK 0xde /* door lock */ -#define ATC_DOOR_UNLOCK 0xdf /* door unlock */ -#define ATC_PI_SRESET 0x08 /* ATAPI soft reset */ -#define ATC_PI_ID_DEV 0xa1 /* ATAPI identify device */ -#define ATC_PI_PKT 0xa0 /* ATAPI packet command */ - -/* - * ata device type - */ -#define ATA_DEV_NONE 0 -#define ATA_DEV_DISK 1 -#define ATA_DEV_12 2 /* atapi 1.2 spec unit */ -#define ATA_DEV_17 3 /* atapi 1.7B spec unit */ - -/* - * write into config. opt. reg to configure level interrupt and - * I/O mapped addressing. - */ -#define LEVEL_MODE_IO_MAP 0x41 - - -/* - * Low bits for Read/Write commands... - */ -#define ATCM_ECCRETRY 0x01 /* Enable ECC and RETRY by controller */ - /* enabled if bit is CLEARED!!! */ -#define ATCM_LONGMODE 0x02 /* Use Long Mode (get/send data & ECC) */ - /* enabled if bit is SET!!! */ - -/* - * direction bits - * for ac_direction - */ -#define AT_NO_DATA 0 /* No data transfer */ -#define AT_OUT 1 /* for writes */ -#define AT_IN 2 /* for reads */ - -/* - * status bits for ab_ctl_status - */ -#define ATA_ONLINE 0 -#define ATA_OFFLINE 1 -#define ATA_PRESENT 2 - -#define B_PASSTHRU 0x1000000 - -/* - * timeout and timing parameters - * - */ -#define MS2HZ(time) drv_usectohz(time * 1000) -#define PCATA_READY_TIMEOUT (MS2HZ(6000)) /* card ready */ -#define PCATA_READYWAIT_TIMEOUT (MS2HZ(8000)) /* wait for ready in open */ - -/* for non attached driver or when instance is unknown */ -#define PCATA_BIO_TIMEOUT1 (MS2HZ(100)) /* sometimes we need it fast */ - -/* for attached driver or when instance is known */ -#define PCATA_BIO_TIMEOUT2 (MS2HZ(200)) /* pcata bio timeout */ - -/* for non attached driver or when instance is unknown */ -#define PCATA_BIOTIMEOUT_CNT1 10 /* maximum of 10 pkts id */ - -/* for attached driver or when instance is known */ -#define PCATA_BIOTIMEOUT_CNT2 40 /* maximum of 40 pkts id */ - -#define PCATA_DRIVESETUP_TIMEOUT MS2HZ(1000) /* drive setup timeout */ -#define PCATA_DRIVESETUP_CNT 2 /* only two instances for now */ - -struct ata_cmpkt { - struct ata_cmpkt *pkt_forw; /* link in chain of packets */ - - struct ata_unit *cp_ctl_private; /* link to struct ata_unit */ - struct buf *cp_bp; /* link to buf structure */ - caddr_t ac_start_v_addr; /* start memory I/O address */ - daddr_t cp_srtsec; /* starting sector number */ - int cp_bytexfer; /* bytes xfer in this operation */ - - char ac_cdb; /* target driver command */ - char ac_scb; /* controller status aft cmd */ - ushort_t ac_flags; /* controller flags */ - - int ac_bytes_per_block; /* blk mode factor per xfer */ - caddr_t ac_v_addr; /* I/O should be done to/from */ - - int cp_resid; /* data bytes not transferred */ - int cp_reason; /* error status */ - int cp_flags; - void *cp_passthru; - char ac_direction; /* AT_IN - read AT_OUT - write */ - int cp_retry; - /* - * task file registers setting - */ - /* sec count in ac_pkt */ -#ifdef NOT_USED - uchar_t ac_devctl; - uchar_t ac_sec; - uchar_t ac_count; - uchar_t ac_lwcyl; - uchar_t ac_hicyl; - uchar_t ac_hd; -#endif - uchar_t ac_cmd; - - /* - * error status - */ - uchar_t ac_error; - uchar_t ac_status; -}; - - - - -/* structure of 'Read Parameters' command */ -struct atarpbuf { -/* WORD */ -/* OFFSET COMMENT */ - ushort_t atarp_config; /* 0 general configuration bits */ - ushort_t atarp_fixcyls; /* 1 # of fixed cylinders */ - ushort_t atarp_remcyls; /* 2 # of removable cylinders */ - ushort_t atarp_heads; /* 3 # of heads */ - ushort_t atarp_trksiz; /* 4 # of unformatted bytes/track */ - ushort_t atarp_secsiz; /* 5 # of unformatted bytes/sector */ - ushort_t atarp_sectors; /* 6 # of sectors/track */ - ushort_t atarp_resv1[3]; /* 7 "Vendor Unique" */ - char atarp_drvser[20]; /* 10 Serial number */ - ushort_t atarp_buftype; /* 20 Buffer type */ - ushort_t atarp_bufsz; /* 21 Buffer size in 512 byte incr */ - ushort_t atarp_ecc; /* 22 # of ecc bytes avail on rd/wr */ - char atarp_fw[8]; /* 23 Firmware revision */ - char atarp_model[40]; /* 27 Model # */ - ushort_t atarp_mult1; /* 47 Multiple command flags */ - ushort_t atarp_dwcap; /* 48 Doubleword capabilities */ - ushort_t atarp_cap; /* 49 Capabilities */ - ushort_t atarp_resv2; /* 50 Reserved */ - ushort_t atarp_piomode; /* 51 PIO timing mode */ - ushort_t atarp_dmamode; /* 52 DMA timing mode */ - ushort_t atarp_validinfo; /* 53 bit0: wds 54-58, bit1: 64-70 */ - ushort_t atarp_curcyls; /* 54 # of current cylinders */ - ushort_t atarp_curheads; /* 55 # of current heads */ - ushort_t atarp_cursectrk; /* 56 # of current sectors/track */ - ushort_t atarp_cursccp[2]; /* 57 current sectors capacity */ - ushort_t atarp_mult2; /* 59 multiple sectors info */ - ushort_t atarp_addrsec[2]; /* 60 LBA only: no of addr secs */ - ushort_t atarp_sworddma; /* 62 single word dma modes */ - ushort_t atarp_dworddma; /* 63 double word dma modes */ - ushort_t atarp_advpiomode; /* 64 advanced PIO modes supported */ - ushort_t atarp_minmwdma; /* 65 min multi-word dma cycle info */ - ushort_t atarp_recmwdma; /* 66 rec multi-word dma cycle info */ - ushort_t atarp_minpio; /* 67 min PIO cycle info */ - ushort_t atarp_minpioflow; /* 68 min PIO cycle info w/flow ctl */ -}; - -/* direct coupled disk driver command */ -#define DCMD_READ 1 /* Read Sectors/Blocks */ -#define DCMD_WRITE 2 /* Write Sectors/Blocks */ -#define DCMD_FMTTRK 3 /* Format Track */ -#define DCMD_FMTDRV 4 /* Format entire drive */ -#define DCMD_RECAL 5 /* Recalibrate */ -#define DCMD_SEEK 6 /* Seek to Cylinder */ -#define DCMD_RDVER 7 /* Read Verify sectors on disk */ -#define DCMD_GETDEF 8 /* Read manufacturers defect list */ - -/* driver error code */ -#define DERR_SUCCESS 0 /* success */ -#define DERR_AMNF 1 /* address mark not found */ -#define DERR_TKONF 2 /* track 0 not found */ -#define DERR_ABORT 3 /* aborted command */ -#define DERR_DWF 4 /* write fault */ -#define DERR_IDNF 5 /* ID not found */ -#define DERR_BUSY 6 /* drive busy */ -#define DERR_UNC 7 /* uncorrectable data error */ -#define DERR_BBK 8 /* bad block detected */ -#define DERR_INVCDB 9 /* invalid cdb */ - -/* reason code for completion status */ -#define CPS_SUCCESS 0 /* command completes with no err */ -#define CPS_FAILURE 1 /* command fails */ -#define CPS_CHKERR 2 /* command fails with status */ -#define CPS_ABORTED 3 /* command aborted */ - -/* flags definitions */ -#define CPF_NOINTR 0x0001 /* polling mode */ - - -/* debug definitions */ -#ifdef ATA_DEBUG - -#define DENT 0x0001 -#define DPKT 0x0002 -#define DIO 0x0004 -#define DDAT 0x0008 -#define DPCM 0x0010 -#define DLBL 0x0020 /* disk label routines */ -#define DINT 0x0040 -#define DINIT 0x0080 -#define DOPEN 0x0100 -#define DMKDEV 0x0200 /* creation of devices */ -#define DERR 0x0400 /* Error Condition */ -#define DMUTEX 0x0800 /* mutex entry/exit */ -#define DVOLD 0x1000 /* volmgt debug */ -#endif /* ATA_DEBUG */ - - -/* - * misc definition - */ -#define ATA_LOOP_CNT 10000 /* for looping on registers */ -#define DDI_XSUSPEND 1 -#define DDI_XRESUME 2 -#define CFLAG_ERROR 1 -#define CFLAG_FREE 2 -#define CTL_SEND_FAILURE 1 -#define CTL_SEND_SUCCESS 0 -#define RETRY_CNT 10 -#define PCATA_GO_RETRY 1 -#define PCATA_WAIT_CNT 100 -#define ROUNDUP(a, n) (((a) + ((n) - 1)) & ~((n) - 1)) -#define LPART(dev) (((getminor(dev) & 0x1F) % NUM_PARTS)) -#define PCIDE_OUTB(a, b, c) csx_Put8(a, b, c);\ - drv_usecwait(5); - -/* - * XXX/lcl - LPART uses 5 bits, shouldn't unit shift right 5? - * also UNIT seems to be incompatible with PCATA_SETMINOR - * also in sysmacros.h O_MAXMIN seems to be 0xff which means << 10 is bad - */ -#define UNIT(dev) (getminor(dev)>>2 &1) - -#define PCATA_SOCKET(dev) ((getminor(dev) >> 10) & 0x3f) -#define PCATA_SETMINOR(skt, part) ((skt<<10) | (part)) - -#define MAX_SLICES 16 -#define NUM_PARTS (MAX_SLICES + FD_NUMPART + 1) -#define PCATA_NAME "pcata" -#define FDISK_OFFSET MAX_SLICES /* vtoc slice 16 == fdisk partition 0 */ -#if defined(_SUNOS_VTOC_16) -#define VTOC_OFFSET 1 -#elif defined(_SUNOS_VTOC_8) -#define VTOC_OFFSET 0 -#else -#error No VTOC format defined. -#endif -#define USLICE_WHOLE 2 - -typedef struct { - kmutex_t mutex; - struct dk_label ondsklbl; - struct partition pmap[NUM_PARTS]; - struct dk_map un_map[NDKMAP]; /* logical partitions */ - int fdiskpresent; /* fdisk present */ - int uidx; /* UNIX partition number */ - } dsk_label_t; - -/* - * linked list of drives on this controller - */ -typedef struct ata_unit { - struct ata_soft *a_blkp; /* controller structure */ - - uchar_t au_targ; - uchar_t au_drive_bits; - uchar_t au_ctl_bits; - int au_cyl; /* cylinders */ - int au_acyl; /* alternate cylinders */ - int au_hd; - int au_sec; - int au_blksz; - short au_block_factor; - short au_bytes_per_block; - uchar_t au_rd_cmd; - uchar_t au_wr_cmd; - buf_t *un_sbufp; - struct atarpbuf *au_rpbuf; - - struct ata_unit *a_forw; /* linked list for all ata's */ - dsk_label_t lbl; /* per targer label information */ -} ata_unit_t; - -/* - * pcata_cftable_t and pcata_cftable_params_t structures are used - * to store values from the CISTPL_CFTABLE_ENTRY tuples. - */ -typedef struct pcata_cftable_params_t { - uchar_t config_index; - uint32_t addr_lines; /* IO addr lines decoded */ - uint32_t ata_length[2]; /* length of first IO range */ - uint32_t pin; /* PRR bits valid mask */ - uint32_t ata_vcc; - uint32_t ata_vpp1; - uint32_t ata_vpp2; - uint32_t ata_base[2]; /* base of IO range ata registers */ - int ranges; /* number of IO range */ -} pcata_cftable_params_t; - -typedef struct pcata_cftable_t { - uint32_t desireability; /* desireability factor */ - pcata_cftable_params_t p; /* parameters */ - struct pcata_cftable_t *prev; - struct pcata_cftable_t *next; -} pcata_cftable_t; - - - -typedef struct pcata_cis_vars_t { - uint32_t present; /* config register present flags */ - uint32_t pin; /* PRR bits valid mask */ - char prod_strings[CISTPL_VERS_1_MAX_PROD_STRINGS] - [CIS_MAX_TUPLE_DATA_LEN]; - uint32_t major_revision; /* card major revision level */ - uint32_t minor_revision; /* card minor revision level */ - uint32_t manufacturer_id; /* manufacturer ID */ - uint32_t card_id; /* card ID */ - uint32_t config_base; /* base offset of config registers */ - uint32_t ata_base[2]; /* base offset of ata registers */ - uint32_t ata_length[2]; - uchar_t config_index; - uint32_t addr_lines; /* number of IO addr lines decoded */ - /* misc card requirements */ - uint32_t ata_vcc; - uint32_t ata_vpp1; - uint32_t ata_vpp2; - pcata_cftable_t cftable; /* active CFTABLE_ENTRY values */ -} pcata_cis_vars_t; - -typedef struct pcata_biotimeout { - timeout_id_t timeout_id; - buf_t *bp; -} pcata_biotimeout_t; - -#define ATA_MAXDRIVE 8 - -/* - * soft state structure - */ -typedef struct ata_soft { - int flags; /* misc state info */ - int sn; /* socket number */ - - enum dkio_state media_state; /* up-to-date media state */ - int checkmedia_flag; - int ejected_media_flag; - - int instance; /* instantiation of ourselves */ - struct buf *crashbuf; /* dumping to root device */ - uint32_t card_state; /* like it says */ - int ejected_while_mounted; - int chr_open; /* open in character mode */ - int blk_open; /* open in block mode */ - int lyr_open[NUM_PARTS]; /* open in layered mode */ - client_handle_t client_handle; /* client handle for socket */ - acc_handle_t handle; /* pcata registers handle */ - ddi_iblock_cookie_t soft_blk_cookie; /* soft intr cookie */ - ddi_softintr_t softint_id; - timeout_id_t ready_timeout_id; - timeout_id_t readywait_timeout_id; - dev_info_t *dip; /* pointer to device node */ - kmutex_t hi_mutex; /* protect hi-level interrupt */ - kmutex_t ata_mutex; - kmutex_t event_hilock; /* protects hi-level events */ - /* - * wait for cv_broadcast of condvar_mediastate - * in pcata_check_media - */ - kcondvar_t condvar_mediastate; /* for DKIOCSTATE ioctl() */ - kcondvar_t readywait_cv; - pcata_cis_vars_t cis_vars; /* saved things ATA's CIS */ - int intr_pending; /* an interrupt is pending */ - int softint_pending; - int write_in_progress; - uint32_t flash; - struct ata_unit *ab_link; /* linked units */ - struct ata_cmpkt *ab_active; /* outstanding requests */ - kmutex_t ab_mutex; - void *ab_lkarg; - ushort_t ab_status_flag; - ushort_t ab_resv; - - /* - * Even though we can only have 2 targets, we need 8 slots - * for the generic code - */ - struct atarpbuf *ab_rpbp[ATA_MAXDRIVE]; - uchar_t ab_dev_type[ATA_MAXDRIVE]; - dev_info_t *ab_dip; - /* - * port addresses associated with ioaddr1 - */ - uint32_t ab_data; /* data register */ - uint32_t ab_error; /* error register (read) */ - uint32_t ab_feature; /* features (write) */ - uint32_t ab_count; /* sector count */ - uint32_t ab_sect; /* sector number */ - uint32_t ab_lcyl; /* cylinder low byte */ - uint32_t ab_hcyl; /* cylinder high byte */ - uint32_t ab_drvhd; /* drive/head register */ - uint32_t ab_status; /* status/command register */ - uint32_t ab_cmd; /* status/command register */ - - /* - * port addresses associated with ioaddr2 - */ - uint32_t ab_altstatus; /* alternate status (read) */ - uint32_t ab_devctl; /* device control (write) */ - uint32_t ab_drvaddr; /* drive address (read) */ - - int ab_block_factor[2]; /* hold dev blk factor */ - /* until unit structure is alloc */ - uchar_t ab_rd_cmd[2]; /* hold read command until */ - /* unit structure is alloc */ - uchar_t ab_wr_cmd[2]; /* hold write command until */ - /* unit structure is alloc */ - int ab_max_transfer; - - struct ata_cmpkt *ab_head; /* linked list of I/O requests */ - struct ata_cmpkt *ab_last; - kmutex_t label_mutex; /* protect dsk_label_t */ -} ata_soft_t; - - -/* - * flags in ata_soft.flags field - */ -#define PCATA_DIDLOCKS 0x00000001 /* cv/mutex_init in attach */ -#define PCATA_REGCLIENT 0x00000002 /* RegisterClient is OK */ -#define PCATA_REQSOCKMASK 0x00000004 /* RequestSocketMask is OK */ -#define PCATA_SOFTINTROK 0x00000008 /* added to interrupt chain */ -#define PCATA_ATTACHOK 0x00000010 /* made it through attach(OK) */ -#define PCATA_REQUESTIO 0x00000020 /* did RequestIO */ -#define PCATA_REQUESTIRQ 0x00000040 /* did RequestIRQ */ -#define PCATA_REQUESTCONFIG 0x00000080 /* did RequestConfiguration */ -#define PCATA_MAKEDEVICENODE 0x00000100 /* did MakeDeviceNode */ -#define PCATA_SUSPENDED 0x00000200 /* device is suspended ? */ -#define PCATA_READY 0x00000400 /* device is ready to be used */ -#define PCATA_VALID_IO_INFO 0x00000800 /* have valid IO info frm CIS */ -#define PCATA_DIDLOCKS2 0x00001000 /* cv/mutex_init in attach */ -#define PCATA_LABELLOCK 0x00002000 /* Disk label lock */ -#define PCATA_DIDLOCKS3 0x00004000 /* ata_mutex initialized */ - -/* - * flags in card_state field - */ -#define PCATA_CARD_INSERTED 0x00000001 /* card is here */ -#define PCATA_WAIT_FOR_READY 0x00000002 /* waiting for card ready */ -#define PCATA_CARD_IS_READY 0x00000004 /* card is ready */ -#define PCATA_READY_WAIT 0x00000008 /* waiting for READY */ -#define PCATA_HAS_WINDOW 0x00000010 /* we have a register window */ -#define PCATA_WAITINIT 0x00000020 /* initialization in progress */ - -#define CARD_PRESENT_VALID(pm) ((pm)->card_state & PCATA_CARD_INSERTED) - -/* - * UNTIMEOUT() macro to make sure we're not trying untimeout a bogus timeout - */ -#define UNTIMEOUT(utt) { \ - if (utt) { \ - (void) untimeout(utt); \ - utt = 0; \ - } \ -} - -/* - * global variables - */ -/* - * linkage to soft state structures by instance (see ddi_get_soft_state) - */ -extern void *pcata_soft; -extern char *pcata_name; -extern int pcata_debug; -extern struct cb_ops pcata_cb_ops; - -/* - * pcata.c - */ -int pcata_event(event_t event, int priority, event_callback_args_t *eca); -int pcata_card_removal(ata_soft_t *softp, int priority); -int pcata_parse_cis(ata_soft_t *softp, pcata_cftable_t **cftable); -void pcata_destroy_cftable_list(pcata_cftable_t **cftable); -char *pcata_CS_etext(int ret); -int pcata_readywait(ata_soft_t *softp); -void pcata_minor_wait(ata_soft_t *softp); -int pcata_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, - void **result); - -/* - * pcide.c - */ -int _init(void); -int _fini(void); -int _info(struct modinfo *modinfop); -int pcata_start(ata_unit_t *, buf_t *, int); -int pcata_intr_hi(ata_soft_t *softp); -uint32_t pcata_intr(char *softp); -int pcata_getedt(ata_soft_t *ata_blkp, int dmax); -void pcata_byte_swap(char *buf, int n); -int pcata_set_rw_multiple(ata_soft_t *ata_blkp, int drive); -void pcata_min(buf_t *bp); -int pcata_spinup(ata_soft_t *softp, int slot); - -/* - * pcdisk.c - */ -int pcata_strategy(buf_t *bp); -int pcata_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, - int *rval_p); -int pcata_lbl_ioctl(dev_t dev, int cmd, intptr_t arg, int flag); -int pcata_open(dev_t *dev_p, int flag, int otyp, cred_t *cred_p); -int pcata_close(dev_t dev, int flag, int otyp, cred_t *cred_p); -int pcata_update_vtoc(ata_soft_t *softp, dev_t dev); -int pcata_write_dskvtoc(ata_soft_t *softp, dev_t dev, dsk_label_t *lblp, - struct vtoc *vtocp); -int pcata_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, - int mod_flags, char *name, caddr_t valuep, int *lengthp); - -/* - * pclabel.c - */ -int pcfdisk_parse(buf_t *bp, ata_unit_t *unitp); -int pcfdisk_read(buf_t *bp, ata_unit_t *unitp); -int pcdsklbl_wrvtoc(dsk_label_t *lblp, struct vtoc *vtocp, buf_t *bp); -void pcdsklbl_ondsklabel_to_vtoc(dsk_label_t *lblp, struct vtoc *vtocp); -void pcdsklbl_vtoc_to_ondsklabel(dsk_label_t *lblp, struct vtoc *vtocp); -void pcdsklbl_dgtoug(struct dk_geom *up, struct dk_label *dp); -void pcdsklbl_ugtodg(struct dk_geom *up, struct dk_label *dp); -void pcinit_pmap(ata_unit_t *unitp); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_PCATA_H */ diff --git a/usr/src/uts/common/sys/pcmcia/pcser_conf.h b/usr/src/uts/common/sys/pcmcia/pcser_conf.h deleted file mode 100644 index bb3237b28c..0000000000 --- a/usr/src/uts/common/sys/pcmcia/pcser_conf.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1995,2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _PCSER_CONF_H -#define _PCSER_CONF_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * pcserconf.h - misc stuff - */ - -#ifdef ZIP -/* - * default setting for the serial lines - */ -static struct pcser_defaults_t pcser_initmodes = { - /* flags */ - SDFLAGS, - /* drain_size */ - PCSER_DRAIN_BSIZE, - /* pcser_hiwater */ - PCSER_HIWATER, - /* pcser_lowwater */ - PCSER_LOWWATER, - /* rtpr */ - PCSER_RTPR, - /* rx_fifo_thld */ - RX_FIFO_SIZE, - /* struct termios */ - { - BRKINT|ICRNL|IXON|ISTRIP, /* iflag */ - OPOST|ONLCR|XTABS, /* oflag */ - CFLAGS|TX_BAUD, /* cflag */ - ISIG|ICANON|ECHO, /* lflag */ - { /* cc[NCCS] */ - CINTR, CQUIT, CERASE, CKILL, - CEOF, CEOL, CEOL2, CSWTCH, - CSTART, CSTOP, CSUSP, CDSUSP, - CRPRNT, CFLUSH, CWERASE, CLNEXT, - }, - }, -}; -#endif /* ZIP */ - -/* - * baud rate conversion table - note that for speeds that we don't - * support, the table entry is 0 - */ -unsigned short pcser_baud_table[PCSER_MAX_SPEEDS] = { - 0x00000, /* B0 (hangup line, not really a speed) */ - 0x00900, /* B50 */ - 0x00600, /* B75 */ - 0x00417, /* B110 */ - 0x00359, /* B134 */ - 0x00300, /* B150 */ - 0x00240, /* B200 */ - 0x00180, /* B300 */ - 0x000c0, /* B600 */ - 0x00060, /* B1200 */ - 0x00040, /* B1800 */ - 0x00030, /* B2400 */ - 0x00018, /* B4800 */ - 0x0000c, /* B9600 */ - 0x00006, /* B19200 */ - 0x00003, /* B38400 */ - 0x00002, /* B57600 */ - 0x00000, /* B76800 */ - 0x00001, /* B115200 */ - 0x00000, /* B153600 */ - 0x00000, /* B230400 */ - 0x00000, /* B307200 */ - 0x00000, /* B460800 */ -}; - -/* - * ioctl debugging stuff - */ -#ifdef DEBUG_PCSERIOCTL - -struct ioc_txt_t { - char *name; - int ioc_cmd; -}; - -struct ioc_txt_t ioc_txt[] = { - { "TCSBRK", TCSBRK }, - { "TCSETSW", TCSETSW }, - { "TCSETSF", TCSETSF }, - { "TCSETAW", TCSETAW }, - { "TCSETAF", TCSETAF }, - { "TIOCSBRK", TIOCSBRK }, - { "TIOCCBRK", TIOCCBRK }, - { "TCGETA", TCGETA }, - { "TCSETA", TCSETA }, - { "TCSETAW", TCSETAW }, - { "TCSETAF", TCSETAF }, - { "TCXONC", TCXONC }, - { "TCFLSH", TCFLSH }, - { "TIOCKBON", TIOCKBON }, - { "TIOCKBOF", TIOCKBOF }, - { "KBENABLED", KBENABLED }, - { "TCDSET", TCDSET }, - { "RTS_TOG", RTS_TOG }, - { "TIOCGWINSZ", TIOCGWINSZ }, - { "TIOCSWINSZ", TIOCSWINSZ }, - { "TIOCGSOFTCAR", TIOCGSOFTCAR }, - { "TIOCSSOFTCAR", TIOCSSOFTCAR }, - { "TCGETS", TCGETS }, - { "TCSETS", TCSETS }, - { "TCSANOW", TCSANOW }, - { "TCSADRAIN", TCSADRAIN }, - { "TCSAFLUSH", TCSAFLUSH }, - { "STGET", STGET }, - { "STSET", STSET }, - { "STTHROW", STTHROW }, - { "STWLINE", STWLINE }, - { "STTSV", STTSV }, - { "TCGETX", TCGETX }, - { "TCSETX", TCSETX }, - { "TCSETXW", TCSETXW }, - { "TCSETXF", TCSETXF }, - { "TIOCMSET", TIOCMSET }, - { "TIOCMBIS", TIOCMBIS }, - { "TIOCMBIC", TIOCMBIC }, - { "TIOCMGET", TIOCMGET }, - { "TIOCFLUSH", TIOCFLUSH }, - { "TIOCCDTR", TIOCCDTR }, - { "TIOCSDTR", TIOCSDTR }, - { (char *)NULL, 0 } -}; -#endif /* DEBUG_PCSERIOCTL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _PCSER_CONF_H */ diff --git a/usr/src/uts/common/sys/pcmcia/pcser_io.h b/usr/src/uts/common/sys/pcmcia/pcser_io.h deleted file mode 100644 index cc317842c6..0000000000 --- a/usr/src/uts/common/sys/pcmcia/pcser_io.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1995,2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _PCSER_IO_H -#define _PCSER_IO_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Definitions for users of pcser devices. - */ - -/* - * Minor device number encoding: - * - * o c s s | s s s s - * - * o - set if this device is an outgoing serial line - * c - set if this device is a control device - * s - socket number of this device - */ - -/* - * Ioctl definitions - why 'd'? why, for "defaults", of course - * - * PCSER_DCONTROL - sets/gets default parameters for any line - * flushes write queues for any line - * and a miscellany of other functions, read the man page - * PCSER_SDEFAULTS - sets default parameters for line that take effect on - * next open - * PCSER_GDEFAULTS - get default parameters (may not be active yet) - */ -#define sIOC ('s'<<8) -#define PCSER_DCONTROL (sIOC|250) -#define PCSER_SDEFAULTS (sIOC|251) -#define PCSER_GDEFAULTS (sIOC|252) -#define PCSER_GSTATS (sIOC|255) - -/* - * we define this here so that it can be exported to users using the - * serial ioctl()'s to manipulate line default parameters; if you - * change this, the driver must be recompiled - */ -#define PCSER_SILOSIZE 1024 /* size of (soft) rx silo in line struct */ - -/* - * macro that returns 1 if parameter is out of range, used for range checking - * on valued parameters passed to driver via pcser_defaults_t and ppc_params_t - */ -#define FUNKY(v, min, max) ((v < min) || (v > max)) - -/* - * fields of pcser_default_t structure - * - * flags for the serial lines in the pcser_line_t->flags member - */ -#define DTR_ASSERT 0x0001 /* assert DTR on open */ -#define SOFT_CARR 0x0002 /* ignore CD input on open */ -#define PCSER_DTRCLOSE 0x0004 /* zs DTR close semantics if clear */ -#define PCSER_CFLOWFLUSH 0x0008 /* flush data in close if blocked */ -#define PCSER_CFLOWMSG 0x0010 /* display message in close */ -#define PCSER_INSTANTFLOW 0x0020 /* if s/w flow disabled, enable xmtr */ -#define PCSER_DTRFORCE 0x0040 /* force DTR always on */ -#define PCSER_IGNORE_CD_ON_OPEN 0x0080 /* ignore CD timeout on every open */ -#define PCSER_VALID_IO_INFO 0x0100 /* have valid IO infor from CIS */ - -/* - * parameters for the serial lines. min and max values are listed. - * if you put a strange value in, the ioctl will return an EINVAL and - * no defaults will be changed - */ -#define MIN_DRAIN_SIZE 4 /* min buf size in pcser_drainsilo() */ -#define MAX_DRAIN_SIZE 1024 /* max buf size in pcser_drainsilo() */ -#define MIN_HIWATER 2 /* min hiwater mark for Rx silo */ -#define MAX_HIWATER (PCSER_SILOSIZE - 2) /* max hiwater for Rx silo */ -#define MIN_LOWWATER 2 /* min lowwater for Rx silo */ -#define MAX_LOWWATER ((pcser_defaults->pcser_hiwater)-2) /* max lowwater */ -#define MIN_RTPR 1 /* min Rx timeout regtister value */ -#define MAX_RTPR 255 /* max Rx timeout regtister value */ -#define MIN_RX_FIFO 1 /* min value for Rx FIFO threshold */ -#define MAX_RX_FIFO 8 /* max value for Rx FIFO threshold */ - -#ifdef XXXNODEFSXXX -/* - * the structure that gets passed back and forth to deal with the defaults - */ -struct pcser_defaults_t { - int flags; /* things like soft carrier, etc... */ - /* serial port Rx handler parameters */ - int drain_size; /* size of buf in pcser_drainsilo() */ - int pcser_hiwater; /* high water mark in CHECK_RTS() */ - int pcser_lowwater; /* low water mark in CHECK_RTS() */ - int rtpr; /* inter-character receive timer */ - int rx_fifo_thld; /* cd-180 RxFIFO threshold */ - struct termios termios; /* baud rates, parity, etc... */ - /* for the control device */ - int line_no; /* line number to operate on */ - int op; /* operation */ -}; - -/* - * op field return values for PCSER_GDEFAULTS, PCSER_DCONTROL(PCSER_CDEFGET) - * and PCSER_DCONTROL(PCSER_SPARAM_GET) - */ -#define PCSER_SERIAL 0x01 /* this is a serial line */ -#define PCSER_CNTRL 0x04 /* this is the control line */ - -/* - * the op parameters, only written for the control device per board - * used only with the PCSER_DCONTROL ioctl() and then only if the - * device is the board control device (read the man page) - * - * PCSER_GDEFAULTS will return the type of line it's connected to - * in the op field - * - * PCSER_DCONTROL(PCSER_CDEFGET) and PCSER_DCONTROL(PCSER_SPARAM_GET) will - * return the type of line specified by the line_no field in - * the op field - * - * PCSER_DCONTROL(PCSER_SPARAM_SET) and PCSER_DCONTROL(PCSER_SPARAM_GET) will - * return an PCSER_NOTOPEN_ERR error if the referenced line is not open - * - * Note on PCSER_CFLUSH: set the line # that you want to flush in - * the "line_no" field of the "pcser_defaults_t" struct that you - * pass to PCSER_DCONTROL; if you want to flush the printer, set - * the line number to 64 or use the PCSER_LP_SETLINE() macro - * - * PCSER_REGIOR, PCSER_REGIOW, PCSER_PPCREGR and PCSER_PPCREGW are designed - * mostly for diagnostic use - don't try them unless you know what - * you're doing; you can cause all sorts of problems like enabling - * interrupts when they shouldn't be, resetting the cd180 and/or the - * PPC and generally wreaking havoc with the whole system - * to get register offsets for these, include <sbusdev/pcserreg.h> - * for the diagnostic ops, specify the line number to operate on - * as 0 (unless you want the passed line number to be loaded into - * the cd180's CAR (channel address register) before each cd180 - * register access; if so, OR in PCSER_SETCAR to the op field) - */ -/* set another line's defaults */ -#define PCSER_CDEFSET 0x00000001 -/* get another line's defaults */ -#define PCSER_CDEFGET 0x00000002 -/* set serial port parameters immediately */ -#define PCSER_SPARAM_SET 0x00000004 -/* get serial port parameters currently in use */ -#define PCSER_SPARAM_GET 0x00000008 -/* flush a line's write queue */ -#define PCSER_CFLUSH 0x00008000 -/* return if line is not open for PCSER_SPARAM_SET/PCSER_SPARAM_GET */ -#define PCSER_NOTOPEN_ERR ESRCH - -#endif /* XXXNODEFSXXX */ - -/* - * the pcser_stats_t struct is used for statistics gathering and monitoring - * driver performance of the serial lines (statistics gathering is - * not supported on the parallel line) - */ -struct pcser_stats_t { - int cmd; /* command (see flags below) */ - int qpunt; /* punting in pcser_drainsilo */ - int drain_timer; /* posted a timer in pcser_drainsilo */ - int no_canput; /* canput failed in pcser_drainsilo */ - int no_rcv_drain; /* pcser_rcv no call pcser_drainsilo */ - int pcser_drain; /* PCSER_DRAIN flag set */ - int pcser_break; /* BREAK requested on XMIT */ - int pcser_sbreak; /* start BREAK requested pcser_ioctl */ - int pcser_ebreak; /* end BREAK requested pcser_ioctl */ - int set_modem; /* set modem lines in pcser_ioctl */ - int get_modem; /* get modem lines in pcser_ioctl */ - int ioc_error; /* bad ioctl */ - int set_params; /* call to pcser_param */ - int no_start; /* already in pcser_start */ - int xmit_int; /* transmit int errupts */ - int rcv_int; /* receive int errupts */ - int rcvex_int; /* receive exception interrupts */ - int modem_int; /* modem change interrupts */ - int xmit_cc; /* characters transmitted */ - int rcv_cc; /* characters received */ - int break_cnt; /* BREAKs received */ - int bufcall; /* times couldn't get STREAMS buffer */ - int canwait; /* pending timer in pcser_drainsilo */ - int nqfretry; /* num q retries in pcser_drainsilo */ - unsigned flags; /* misc flags */ -}; -/* - * flags in pcser_stats_t.cmd field - */ -#define STAT_SET 0x0002 /* set line parameters */ -#define STAT_CLEAR 0x0001 /* clear line statistics */ -#define STAT_GET 0x0000 /* get line statistics */ - -/* - * flags in pcser_stats_t.flags field - */ -#define CARD_IN_SOCKET 0x0001 /* card is in socket */ - -#ifdef __cplusplus -} -#endif - -#endif /* _PCSER_IO_H */ diff --git a/usr/src/uts/common/sys/pcmcia/pcser_manuspec.h b/usr/src/uts/common/sys/pcmcia/pcser_manuspec.h deleted file mode 100644 index f5a455121f..0000000000 --- a/usr/src/uts/common/sys/pcmcia/pcser_manuspec.h +++ /dev/null @@ -1,314 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _PCSER_MANUSPEC_H -#define _PCSER_MANUSPEC_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file describes any manufacturer-specific capabilities of the - * card. These capabilities are stored in an array of structures - * and are keyed off of the card's manufacturer and card IDs; these - * come from the CISTPL_MANFID tuple. - * We need this file since some cards have additional features that can - * not be specified in the CIS since there are not tuples to do so - * while other cards have a broken CIS which prevents them from - * being initialized properly. - */ - -/* - * Property used to provide manufacturer-specific parameter overrides. - * This property is typically specified in a .conf file. - */ -#define PCSER_MODIFY_MANSPEC_PARAMS "pcser_modify_manspec_params" - -#define PCSPP_DEBUG_PARSE_LINE 0x00000001 -#define PCSPP_DEBUG_SET_MSP 0x00000002 -#define PCSPP_DSPMATCH 0x00000004 -#define PCSPP_DISPLAY 0x10000000 -#define PCSPP_COMMENT 0x20000000 - -#define PCSER_PARSE_QUOTE '\'' -#define PCSER_PARSE_COMMENT '#' -#define PCSER_PARSE_ESCAPE '\\' -#define PCSER_PARSE_UNDERSCORE '_' - -/* - * state defines for the valued variable state machine - */ -#define PT_STATE_UNKNOWN 0 -#define PT_STATE_TOKEN 1 -#define PT_STATE_STRING_VAR 2 -#define PT_STATE_HEX_VAR 3 -#define PT_STATE_DEC_VAR 4 -#define PT_STATE_ESCAPE 5 - -/* - * Flags for pcser_manuspec_t.flags - * - * Matching flags - */ -#define PCSER_MATCH_MANUFACTURER 0x00000001 /* match manf ID */ -#define PCSER_MATCH_CARD 0x00000002 /* match card ID */ -#define PCSER_MATCH_VERS_1 0x00000004 /* match vers_1 */ -#define PCSER_MATCH_MASK 0x00000fff - -/* - * Parameter override flags - */ -#define PCSER_MANSPEC_TXBUFSIZE 0x00001000 /* txbufsize valid */ -#define PCSER_MANSPEC_RXBUFSIZE 0x00002000 /* rxbufsize valid */ -#define PCSER_MANSPEC_FIFO_ENABLE 0x00004000 /* Tx/Rx FIFO valid */ -#define PCSER_MANSPEC_FIFO_DISABLE 0x00008000 /* Tx/Rx FIFO valid */ -#define PCSER_MANSPEC_AUTO_RTS 0x00010000 /* auto_rts valid */ -#define PCSER_MANSPEC_AUTO_CTS 0x00020000 /* auto_cts valid */ -#define PCSER_MANSPEC_READY_DELAY_1 0x00040000 /* delay before cfg */ -#define PCSER_MANSPEC_READY_DELAY_2 0x00080000 /* delay after cfg */ -#define PCSER_MANSPEC_CONFIG_INDEX 0x00100000 /* config index */ -#define PCSER_MANSPEC_CONFIG_ADDR 0x00200000 /* config address */ -#define PCSER_MANSPEC_CONFIG_PRESENT 0x00400000 /* regs present mask */ -#define PCSER_MANSPEC_NUM_IO_LINES 0x00800000 /* IO addr lines */ -#define PCSER_MANSPEC_NUM_IO_PORTS 0x01000000 /* num IO ports */ -#define PCSER_MANSPEC_IO_ADDR 0x02000000 /* IO address */ -#define PCSER_MANSPEC_CD_TIME 0x04000000 /* CD ignore time */ -#define PCSER_MANSPEC_IGN_CD_ON_OPEN 0x08000000 /* CD timer on open */ - -typedef struct pcser_manuspec_parse_tree_t { - char *token; /* token to look for */ - int state; /* state machine state */ - unsigned flags; /* flags to set in manuspec struc */ - unsigned ctl; /* control flags */ - int fmt; /* data format type */ - void *var; /* pointer to manuspec struct var */ -} pcser_manuspec_parse_tree_t; - -typedef struct pcser_manuspec_t { - uint32_t flags; /* matching flags */ - uint32_t manufacturer; /* manufacturer ID */ - uint32_t card; /* card ID */ - uint32_t txbufsize; /* Tx FIFO buffer size */ - uint32_t rxbufsize; /* Rx FIFO buffer size */ - uint32_t fifo_enable; /* Tx/Rx FIFO enable code */ - uint32_t fifo_disable; /* Tx/Rx FIFO disable code */ - uint32_t auto_rts; /* Auto RTS enable code */ - uint32_t auto_cts; /* Auto CTS enable code */ - uint32_t ready_delay_1; /* READY delay before config in mS */ - uint32_t ready_delay_2; /* READY delay after config in mS */ - uint32_t config_index; /* config index */ - uint32_t config_address; /* config regs address */ - uint32_t present; /* config regs present mask */ - uint32_t addr_lines; /* IO addr lines decoded */ - uint32_t length; /* length of IO range */ - uint32_t modem_base; /* base of UART registers */ - uint32_t CD_ignore_time; /* mS to ignore CD changes */ - char *vers_1; /* VERS_1 string */ -} pcser_manuspec_t; - -pcser_manuspec_t pcser_manuspec[] = { - /* Sun/USRobotics Worldport modem */ - { (PCSER_MATCH_MANUFACTURER | /* matching flags */ - PCSER_MATCH_CARD | - PCSER_MANSPEC_TXBUFSIZE | - PCSER_MANSPEC_RXBUFSIZE | - PCSER_MANSPEC_FIFO_ENABLE | - PCSER_MANSPEC_FIFO_DISABLE | - PCSER_MANSPEC_AUTO_RTS), - 0x0115, /* manufacturer ID */ - 0x3330, /* card ID */ - 64, /* Tx FIFO buffer size */ - 64, /* Rx FIFO buffer size */ - 0x0e1, /* Tx/Rx FIFO enable code */ - 0, /* Tx/Rx FIFO disable code */ - 0x010, /* Auto RTS enable code */ - 0, /* Auto CTS enable code */ - 0, /* READY_1 delay before config in mS */ - 0, /* READY_2 delay after config in mS */ - 0, /* config index */ - 0, /* config regs address */ - 0, /* config regs present mask */ - 0, /* IO addr lines decoded */ - 0, /* length of IO range */ - 0, /* base of UART registers */ - 0, /* mS to ignore CD changes */ - NULL /* VERS_1 string */ - }, - /* USRobotics Worldport modem with broken CIS */ - { (PCSER_MATCH_VERS_1 | /* matching flags */ - PCSER_MANSPEC_TXBUFSIZE | - PCSER_MANSPEC_RXBUFSIZE | - PCSER_MANSPEC_READY_DELAY_1), - 0, /* manufacturer ID */ - 0, /* card ID */ - 1, /* Tx FIFO buffer size */ - 1, /* Rx FIFO buffer size */ - 0, /* Tx/Rx FIFO enable code */ - 0, /* Tx/Rx FIFO disable code */ - 0, /* Auto RTS enable code */ - 0, /* Auto CTS enable code */ - 10000, /* READY_1 delay before config in mS */ - 0, /* READY_2 delay after config in mS */ - 0, /* config index */ - 0, /* config regs address */ - 0, /* config regs present mask */ - 0, /* IO addr lines decoded */ - 0, /* length of IO range */ - 0, /* base of UART registers */ - 0, /* mS to ignore CD changes */ - "Intel MODEM 2400+ iNC110US A-0" /* VERS_1 string */ - }, -}; - -#define PT_VAR_OFFSET(v) ((void *)&(((pcser_manuspec_t *)0)->v)) -/* - * The PT_VAR_* values specify what type of variable should be - * extracted from the token parameters. We know how to - * extract hex and decimal unsigned values and strings. - */ -#define PT_VAR_HEX 0x0001 -#define PT_VAR_DEC 0x0002 -#define PT_VAR_STRING 0x0003 -#define PT_VAR_BOOL 0x0004 -#define PT_VAR_HEX_CTL 0x0005 - -/* - * PT_VAR_BOOL has several sub-modes defined below - */ -#define PT_VAR_BOOL_NONE 0x0000 -#define PT_VAR_BOOL_DISPLAY_ON 0x0001 -#define PT_VAR_BOOL_DISPLAY_OFF 0x0002 -#define PT_VAR_HEX_CTL_DEBUG 0x0003 -#define PT_VAR_BOOL_DEBUG_STAT 0x0004 -#define PT_VAR_BOOL_COMMENT_ON 0x0005 -#define PT_VAR_BOOL_COMMENT_OFF 0x0006 -#define PT_VAR_HEX_CTL_PCSER_DEBUG 0x0007 -#define PT_VAR_BOOL_DSPMATCH_ON 0x0008 -#define PT_VAR_BOOL_DSPMATCH_OFF 0x0009 -#define PT_VAR_BOOL_CD_IGN 0x000a - -/* - * Initialize the parse tree structure - */ -pcser_manuspec_parse_tree_t pcser_manuspec_parse_tree[] = { - - { "flags", PT_STATE_HEX_VAR, - 0, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(flags) }, - { "manufacturer", PT_STATE_HEX_VAR, - PCSER_MATCH_MANUFACTURER, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(manufacturer) }, - { "card", PT_STATE_HEX_VAR, - PCSER_MATCH_CARD, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(card) }, - { "vers_1", PT_STATE_STRING_VAR, - PCSER_MATCH_VERS_1, PT_VAR_BOOL_NONE, - PT_VAR_STRING, PT_VAR_OFFSET(vers_1) }, - { "txbufsize", PT_STATE_HEX_VAR, - PCSER_MANSPEC_TXBUFSIZE, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(txbufsize) }, - { "rxbufsize", PT_STATE_HEX_VAR, - PCSER_MANSPEC_RXBUFSIZE, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(rxbufsize) }, - { "fifo_enable", PT_STATE_HEX_VAR, - PCSER_MANSPEC_FIFO_ENABLE, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(fifo_enable) }, - { "fifo_disable", PT_STATE_HEX_VAR, - PCSER_MANSPEC_FIFO_DISABLE, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(fifo_disable) }, - { "auto_rts", PT_STATE_HEX_VAR, - PCSER_MANSPEC_AUTO_RTS, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(auto_rts) }, - { "auto_cts", PT_STATE_HEX_VAR, - PCSER_MANSPEC_AUTO_CTS, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(auto_cts) }, - { "ready_delay_1", PT_STATE_DEC_VAR, - PCSER_MANSPEC_READY_DELAY_1, PT_VAR_BOOL_NONE, - PT_VAR_DEC, PT_VAR_OFFSET(ready_delay_1) }, - { "ready_delay_2", PT_STATE_DEC_VAR, - PCSER_MANSPEC_READY_DELAY_2, PT_VAR_BOOL_NONE, - PT_VAR_DEC, PT_VAR_OFFSET(ready_delay_2) }, - { "config_index", PT_STATE_HEX_VAR, - PCSER_MANSPEC_CONFIG_INDEX, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(config_index) }, - { "config_address", PT_STATE_HEX_VAR, - PCSER_MANSPEC_CONFIG_ADDR, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(config_address) }, - { "config_regs_present", PT_STATE_HEX_VAR, - PCSER_MANSPEC_CONFIG_PRESENT, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(present) }, - { "IO_addr_lines", PT_STATE_HEX_VAR, - PCSER_MANSPEC_NUM_IO_LINES, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(addr_lines) }, - { "IO_num_ports", PT_STATE_HEX_VAR, - PCSER_MANSPEC_NUM_IO_PORTS, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(length) }, - { "IO_base_addr", PT_STATE_HEX_VAR, - PCSER_MANSPEC_IO_ADDR, PT_VAR_BOOL_NONE, - PT_VAR_HEX, PT_VAR_OFFSET(modem_base) }, - { "CD_ignore_time", PT_STATE_DEC_VAR, - PCSER_MANSPEC_CD_TIME, PT_VAR_BOOL_NONE, - PT_VAR_DEC, PT_VAR_OFFSET(CD_ignore_time) }, - { "ignore_CD_on_open", PT_STATE_TOKEN, - PCSER_MANSPEC_IGN_CD_ON_OPEN, PT_VAR_BOOL_CD_IGN, - PT_VAR_BOOL, 0 }, - { "display_on", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_DISPLAY_ON, - PT_VAR_BOOL, 0 }, - { "display_match_on", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_DSPMATCH_ON, - PT_VAR_BOOL, 0 }, - { "comment_on", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_COMMENT_ON, - PT_VAR_BOOL, 0 }, - { "display_off", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_DISPLAY_OFF, - PT_VAR_BOOL, 0 }, - { "display_match_off", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_DSPMATCH_OFF, - PT_VAR_BOOL, 0 }, - { "comment_off", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_COMMENT_OFF, - PT_VAR_BOOL, 0 }, - { "debug_stat", PT_STATE_TOKEN, - 0, PT_VAR_BOOL_DEBUG_STAT, - PT_VAR_BOOL, 0 }, - { "debug", PT_STATE_HEX_VAR, - 0, PT_VAR_HEX_CTL_DEBUG, - PT_VAR_HEX_CTL, 0 }, - { "pcser_debug", PT_STATE_HEX_VAR, - 0, PT_VAR_HEX_CTL_PCSER_DEBUG, - PT_VAR_HEX_CTL, 0 }, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _PCSER_MANUSPEC_H */ diff --git a/usr/src/uts/common/sys/pcmcia/pcser_reg.h b/usr/src/uts/common/sys/pcmcia/pcser_reg.h deleted file mode 100644 index 35cd5e172a..0000000000 --- a/usr/src/uts/common/sys/pcmcia/pcser_reg.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1995 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _PCSER_REG_H -#define _PCSER_REG_H - -#pragma ident "%W% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Register offset definitions - */ -#define PCSER_REGS_RBRTHR 0x00 /* Rx/Tx buffer */ -#define PCSER_REGS_IER 0x01 /* interrupt enable register */ -#define PCSER_REGS_IIR 0x02 /* interrupt identification register */ -#define PCSER_REGS_LCR 0x03 /* line control register */ -#define PCSER_REGS_MCR 0x04 /* modem control register */ -#define PCSER_REGS_LSR 0x05 /* line status register */ -#define PCSER_REGS_MSR 0x06 /* modem status register */ -#define PCSER_REGS_SCR 0x07 /* scratch pad register */ - -#ifdef __cplusplus -} -#endif - -#endif /* _PCSER_REG_H */ diff --git a/usr/src/uts/common/sys/pcmcia/pcser_var.h b/usr/src/uts/common/sys/pcmcia/pcser_var.h deleted file mode 100644 index f20a82001e..0000000000 --- a/usr/src/uts/common/sys/pcmcia/pcser_var.h +++ /dev/null @@ -1,627 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1999,2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _PCSER_VAR_H -#define _PCSER_VAR_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#define PCSER_DEBUG_LOWMASK 0x0000000ff -#define PCSER_DEBUG_DEFAULT 0x000000100 -#define PCSER_DEBUG_POLL 0x000000200 -#define PCSER_DEBUG_XMIT 0x000000400 -#define PCSER_DEBUG_RCV 0x000000800 -#define PCSER_DEBUG_MODEM 0x000001000 -#define PCSER_DEBUG_RCVEX 0x000002000 -#define PCSER_DEBUG_CIS 0x000004000 -#define PCSER_DEBUG_CIS_SCFT 0x000008000 /* sorted cftable */ -#define PCSER_DEBUG_CIS_UCFT 0x000010000 /* unsorted cftable */ -#define PCSER_DEBUG_RTSCTS 0x000020000 -#define PCSER_DEBUG_DRAINSILO 0x000040000 -#define PCSER_DEBUG_PARAM 0x000080000 -#define PCSER_DEBUG_READY 0x000100000 -#define PCSER_DEBUG_MANUSPEC 0x000200000 -#define PCSER_DEBUG_READY_DELAY 0x000400000 -#define PCSER_DEBUG_CISVARS 0x000800000 -#define PCSER_DEBUG_SOFTINT 0x001000000 - -/* #define DEBUG_PCSERIOCTL */ - -/* - * Values for CS_EVENT_CLIENT_INFO event handler - */ -#define PCSER_CLIENT_DESCRIPTION "PCMCIA serial/modem card driver" -#define PCSER_VENDOR_DESCRIPTION CS_SUN_VENDOR_DESCRIPTION -#define PCSER_REV_LEVEL 0x100 -#define PCSER_REV_DAY 31 -#define PCSER_REV_MONTH 3 -#define PCSER_REV_YEAR 16 -#define PCSER_REV_DATE CS_CLIENT_INFO_MAKE_DATE( \ - PCSER_REV_DAY, \ - PCSER_REV_MONTH, \ - PCSER_REV_YEAR) - -/* - * Private data structures for PCMCIA async serial communications cards - * and modems using the 8250-type UART. - * - * various device things - */ -#define PCSER_NAME "pcser" /* driver name */ -#define PCSER_SOCKET(dev) (getminor(dev) & 0x3f) -#define PCSER_OUTLINE(dev) (getminor(dev) & 0x80) -#define PCSER_CONTROL_LINE(dev) (getminor(dev) & 0x40) -#define N_PCSER 2 /* hint to ddi_soft_state_init() */ -#define USE_CCSR(L) (L->cis_vars.present & \ - CONFIG_STATUS_REG_PRESENT) -#define MAX_TX_BUF_SIZE 64 - -#define PCSER_HIMUTEX_ENTER(pcser) {mutex_enter(&(pcser)->event_hilock);\ - mutex_enter((pcser)->pcser_mutex); } -#define PCSER_HIMUTEX_EXIT(pcser) {mutex_exit((pcser)->pcser_mutex); \ - mutex_exit(&(pcser)->event_hilock); } - -#ifdef CBAUDEXT -#define PCSER_DUALHW_FLOW "pcser_use_dualflow" -#endif -#ifndef CBAUDEXT -#define PCSER_HIGHSPEED_PROP "pcser_use_hispeed" -#endif - -/* - * These macros return device minor numbers given a socket number. - */ -#define PCSER_DINODE(skt) (skt & 0x3f) /* dial-in */ -#define PCSER_DONODE(skt) ((skt & 0x3f) | 0x80) /* dial-out */ -#define PCSER_CTLNODE(skt) ((skt & 0x3f) | 0x40) /* control */ - -/* - * The driver uses a two-level interrupt scheme; the hardware interrupts - * at a high level, and the driver schedules a softint on a lower - * level to deal with the STREAMS processing. - */ -#define PCSER_SOFT_PREF DDI_SOFTINT_MED /* soft interrupt level */ - -/* - * some general sizing and enumeration constants - * the silo sizes are the same for both the cd180 and the ppc, and are - * located in pcserio.h as PCSER_SILOSIZE - * the TXBUF sizes determine how many characters pcser_start() will try to - * stuff into the soft tx buffers in the line struct. you should leave - * PCSER_TXBUFSIZE at 8 since the interrupt handler for the cd180 doesn't - * know what to do if it gets larger. - * PPC_TXBUFSIZE is made a little larger since the ppc interrupt handler - * is smart enough to take data from the soft tx buffer if there is any - * both PCSER_TXBUFSIZE and PPC_TXBUFSIZE must be <= to LINE_TXBUFSIZE - */ -/* when to disable RTS if we're using CTS/RTS flow control */ -#define PCSER_HIWATER 960 -/* when to enable RTS if we're using CTS/RTS flow control */ -#define PCSER_LOWWATER 300 -/* default STREAMS buffer size in pcser_drainsilo() */ -#define PCSER_DRAIN_BSIZE 16 - -/* - * If CRTSXOFF is not defined, then we're probably being built on - * a pre-2.5 kernel, so alias CRTSXOFF to CRTSCTS. This will - * cause the driver to treat CRTSCTS as a bidirectional flow - * control enable bit rather than a unidirectional flow control - * enable bit as it is in 2.5 and above. - */ -#ifndef CRTSXOFF -#define CRTSXOFF CRTSCTS -#endif - -/* - * The number of unidentified IRQ's that we allow before we - * shut down the card. - */ -#define PCSER_UNID_IRQ_MAX 10 /* max unknown IRQs */ - -/* - * The number of different possible line speeds (not all of which - * may be supported) - */ -#define PCSER_MAX_SPEEDS 23 /* max baud rates we support */ - -/* - * timeout and timing parameters - * - * serial lines - * NQFRETRY and QFRETRYTIME are used in pcser_drainsilo() - */ -#define MS2HZ(time) drv_usectohz(time * 1000) -/* CSTYLED */ -#define PCSER_TIMEOUT (MS2HZ(15000)) /* ctrl lines in close */ -/* CSTYLED */ -#define PCSER_IGNORE_CD_TIMEOUT 3000 /* ignore CD in mS */ -/* CSTYLED */ -#define NQFRETRY 26 /* put tries to receive q */ -/* CSTYLED */ -#define QFRETRYTIME (MS2HZ( 100)) /* queue retry */ -/* CSTYLED */ -#define BREAK1_TIMEOUT (MS2HZ( 90)) /* 90mS pre-BREAK */ -/* CSTYLED */ -#define BREAK2_TIMEOUT (MS2HZ( 350)) /* 350mS BREAK */ -/* CSTYLED */ -#define DRAIN_TIMEOUT (MS2HZ( 10)) /* 10mS DRAIN */ -/* CSTYLED */ -#define PCSER_READY_TIMEOUT (MS2HZ( 6000)) /* card ready */ -/* CSTYLED */ -#define PCSER_READYWAIT_TIMEOUT (MS2HZ(20000)) /* wait for ready in attach */ -/* CSTYLED */ -#define PCSER_DTR_DROP_DELAY (MS2HZ( 200)) /* delay around DTR drop */ - -/* - * The next two items are used in pcser_card_insertion() to handle - * cards that require a delay after resetting and after - * configuring the card. - * - * PCSER_INSERT_READY_TMO1 - time to wait between checking READY before - * doing a RequestConfiguration - * PCSER_INSERT_READY_TMO2 - time to wait between checking READY after - * doing a RequestConfiguration - */ -/* CSTYLED */ -#define PCSER_INSERT_READY_TMO1 (MS2HZ(20)) /* ready wait in card_insert */ -#define PCSER_INSERT_READY_TMO2 (MS2HZ(200)) /* ready wait in card_insert */ -#define PCSER_INSERT_READY_CNT 5 /* max times to try */ - -/* - * UNTIMEOUT() macro to make sure we're not trying untimeout a bogus timeout - */ -#define UNTIMEOUT(utt) { \ - if (utt) { \ - (void) untimeout(utt); \ - utt = 0; \ - } \ -} - -/* - * XXX card present macro - */ -#define CARD_PRESENT(pm) ((pm)->card_state & PCSER_CARD_INSERTED) - -#define CARD_INSERT_CHECK(pm) \ - ((pm)->card_state & (PCSER_CARD_INSERTED | PCSER_READY_ERR)) - -/* - * user-level audio control - note that we overload the TIOCMBIS and - * TIOCMBIC ioctls by using the TIOCM_SR bit to control - * the audio signal from the modem to the system speaker XXX - */ -#define TIOCM_AUDIO TIOCM_SR -#define AUDIO_GET(L) (((L->saved_state) & PCSER_AUDIO_ON)?1:0) - -/* - * for modem_init() - */ -#define MODEM_SET_AUDIO_ON 1 /* enable card audio */ -#define MODEM_SET_AUDIO_OFF 2 /* disable card audio */ -#define MODEM_FIFO_FLUSH 3 /* flush Tx and Rx FIFOs */ - -/* - * UART defines - */ - -/* - * IIR - interrupt identification register - */ -#define IIR_MASK 0x007 /* the only bits of interest */ -#define MODEM_CHANGE 0x000 -#define XMIT_DATA 0x002 -#define RCV_DATA 0x004 -#define RCV_EXP 0x006 -#define IIR_PENDING 0x001 /* note: 0 == pending!! */ - -/* - * IER - interrupt enable register - */ -#define RX_DATA_E 0x001 /* receive data */ -#define TX_READY_E 0x002 /* transmitter empty */ -#define TX_EMPTY_E 0x002 /* transmitter empty */ -#define RX_EXCEPTION_E 0x004 /* receive exception (line status) */ -#define MODEM_CHANGE_E 0x008 /* modem lines changed state */ - -/* - * LSR - line status register - */ -#define RX_DATA_AVAIL 0x001 /* char available */ -#define RX_OVERRUN 0x002 /* overrun error */ -#define RX_PARITY 0x004 /* parity error */ -#define RX_FRAMING 0x008 /* framing error */ -#define RX_BREAK 0x010 /* BREAK detected */ -#define TX_THR_EMPTY 0x020 /* THR empty */ -#define TX_SHIFT_EMPTY 0x040 /* Tx shift register empty */ - -/* - * MCR - modem control register - */ -#define DTR_ON_MCR 0x001 -#define RTS_ON_MCR 0x002 -#define OUT1_ON_MCR 0x004 -#define OUT2_ON_MCR 0x008 -#define LOOP_ON_MCR 0x010 - -/* - * MSR - modem status register - */ -#define CTS_CHANGE 0x001 -#define DSR_CHANGE 0x002 -#define RI_CHANGE 0x004 -#define CD_CHANGE 0x008 -#define CTS_ON_MSR 0x010 -#define DSR_ON_MSR 0x020 -#define RI_ON_MSR 0x040 -#define CD_ON_MSR 0x080 - -/* - * LCR - line control register - */ -#define CHAR_5 0x00 -#define CHAR_6 0x01 -#define CHAR_7 0x02 -#define CHAR_8 0x03 - -#define STOP_1 0x00 -#define STOP_15 0x04 -#define STOP_2 0x04 - -#define USE_P 0x08 -#define ODD_P 0x00 -#define EVEN_P 0x10 - -#define MARK_P 0x00 -#define SPACE_P 0x20 - -#define IGNORE_P 0x000 /* XXX ?? */ - -#define SET_BREAK 0x040 -#define DLAB 0x080 - -/* - * DTR latch values - */ -#define DTR_OFF_SHADOW 0x000 /* drop DTR */ -#define DTR_ON_SHADOW 0x001 /* assert DTR */ - -/* - * macros to get/set the shadow state of the line's DTR pin - */ -#define DTR_GET(L) (((L->dtr_shadow)&DTR_ON_SHADOW)?1:0) -#define DTR_SET(L, S) (L->dtr_shadow = S) - -/* - * define driver defaults for all the serial lines; these can be manipulated - * via the PCSER_SDEFAULTS/PCSER_GDEFAULTS ioctl()'s; see "pcserio.h" - */ -/* assert DTR on open, use zs DTR semantics on close */ -#define SDFLAGS DTR_ASSERT -#define CFLAGS (CS8|CREAD|HUPCL) /* UNIX line flags in t_cflag */ -#define RX_BAUD B9600 /* default receiver baud rate */ -#define TX_BAUD B9600 /* default transmitter baud rate */ - -/* - * all the bytes we get from the modem get put into a soft silo before being - * handed off to STREAMS; the following macros handle the RTS line if - * we're using CTS/RTS flow control: - * CHECK_RTS_OFF(line) should be called by the Rx interrupt handler for - * each character put into the soft silo; if the soft silo nears - * full, RTS will be deasserted - * CHECK_RTS_ON(line) should be called by the soft interrupt soft silo - * drain code; once the soft silo level has gone below the low - * water mark, RTS will be asserted - * FLUSHSILO(line) is used to flush the silo in case there's an error - * PUTSILO(line,char) puts a character into the soft silo and calls - * CHECK_RTS_OFF(line) to see if RTS should be deasserted - */ -#ifdef USE_MACRO_RTSCTS -#define CHECK_RTS_OFF(line) { \ - if (line->pcser_ttycommon.t_cflag & CRTSXOFF) { \ - if (line->pcser_sscnt > line->pcser_hiwater) \ - OUTB(&line->regs->mcr, \ - (INB(&line->regs->mcr) & ~RTS_ON_MCR)); \ - } \ -} -#define CHECK_RTS_ON(line) { \ - if (line->pcser_ttycommon.t_cflag & CRTSXOFF) { \ - if (line->pcser_sscnt < line->pcser_lowwater) \ - OUTB(&line->regs->mcr, \ - (INB(&line->regs->mcr) | RTS_ON_MCR)); \ - } \ -} -#endif /* USE_MACRO_RTSCTS */ - -#ifdef PX_IFLUSH_DEBUG - -#define FLUSHSILO(zline) { \ - cmn_err(CE_CONT, "pcser_FLUSHSILO: socket %d flushing soft silo\n", \ - (int)zline->pcser->sn); \ - zline->pcser_source = zline->pcser_sink = zline->pcser_ssilo; \ - zline->pcser_sscnt = 0; \ -} - -#else - -#define FLUSHSILO(line) { \ - line->pcser_source = line->pcser_sink = line->pcser_ssilo; \ - line->pcser_sscnt = 0; \ -} - -#endif /* PX_IFLUSH_DEBUG */ - -#define PUTSILO(zline, c) { \ - if (zline->pcser_sscnt < PCSER_SILOSIZE) { \ - zline->pcser_sscnt++;\ - if (zline->pcser_source == &zline->pcser_ssilo[PCSER_SILOSIZE]) \ - zline->pcser_source = zline->pcser_ssilo;\ - *zline->pcser_source++ = c; \ - CHECK_RTS_OFF(zline); \ - } else { \ - FLUSHSILO(zline); \ - CHECK_RTS_ON(zline); \ - cmn_err(CE_CONT, "pcser: socket %d soft silo overflow\n", \ - (int)zline->pcser->sn); \ - } \ -} - -/* - * pcser_cftable_t and pcser_cftable_params_t structures are used - * to store values from the CISTPL_CFTABLE_ENTRY tuples. - */ -typedef struct pcser_cftable_params_t { - uchar_t config_index; - uint32_t addr_lines; /* IO addr lines decoded */ - uint32_t length; /* length of IO range */ - uint32_t pin; /* PRR bits valid mask */ - unsigned modem_vcc; - unsigned modem_vpp1; - unsigned modem_vpp2; - uint32_t modem_base; /* base of UART registers */ -} pcser_cftable_params_t; - -typedef struct pcser_cftable_t { - uint32_t desireability; /* desireability factor */ - pcser_cftable_params_t p; /* parameters */ - struct pcser_cftable_t *prev; - struct pcser_cftable_t *next; -} pcser_cftable_t; - -/* - * pcser_cis_vars_t structure used to save interesting information - * gleaned from the CIS. - * The configuration registers present flags are defined in the Card - * Services header files. - */ -typedef struct pcser_cis_vars_t { - uint32_t flags; /* general capability flags */ - uint32_t present; /* config register present flags */ - char prod_strings[CISTPL_VERS_1_MAX_PROD_STRINGS] - [CIS_MAX_TUPLE_DATA_LEN]; - uint32_t major_revision; /* card major revision level */ - uint32_t minor_revision; /* card minor revision level */ - uint32_t manufacturer_id; /* manufacturer ID */ - uint32_t card_id; /* card ID */ - uint32_t config_base; /* base offset of config registers */ - /* resource configuration */ - uchar_t config_index; - uint32_t addr_lines; /* IO addr lines decoded */ - uint32_t length; /* length of IO range */ - uint32_t pin; /* PRR bits valid mask */ - unsigned modem_vcc; - unsigned modem_vpp1; - unsigned modem_vpp2; - uint32_t modem_base; /* base of UART registers */ - /* UART features */ - uint32_t txbufsize; /* Tx FIFO buffer size */ - uint32_t rxbufsize; /* Rx FIFO buffer size */ - uchar_t fifo_enable; /* Tx/Rx FIFO enable code */ - uchar_t fifo_disable; /* Tx/Rx FIFO disable code */ - uchar_t auto_rts; /* Auto RTS enable code */ - uchar_t auto_cts; /* Auto CTS enable code */ - uint32_t ready_delay_1; /* READY delay before config in mS */ - uint32_t ready_delay_2; /* READY delay after config in mS */ - pcser_cftable_t cftable; /* active CFTABLE_ENTRY values */ -} pcser_cis_vars_t; - -/* - * Flgas for pcser_cis_vars_t.flags field - */ -#define PCSER_FIFO_ENABLE 0x00000001 /* fifo_enable code OK */ -#define PCSER_FIFO_DISABLE 0x00000002 /* fifo_disable code OK */ -#define PCSER_AUTO_RTS 0x00000004 /* auto_rts enable code OK */ -#define PCSER_AUTO_CTS 0x00000008 /* auto_cts enable code OK */ - -/* - * Per line structure - * there is one of these for each serial line plus one more for - * the ppc. - */ -typedef struct pcser_line_t { - /* stuff common to both the cd180 and the ppc */ - unsigned state; /* various state flags */ - unsigned flags; /* default mode flags */ - unsigned saved_state; /* saved over open/close */ - acc_handle_t handle; /* modem registers handle */ - pcser_cis_vars_t cis_vars; - timeout_id_t pcser_timeout_id; /* timeout id */ - timeout_id_t pcser_draintimeout_id; /* timeout id */ - timeout_id_t ignore_cd_timeout_id; /* timeout id */ - timeout_id_t restart_timeout_id; /* timeout id */ - int pcser_ignore_cd_time; /* ignore CD in mS */ - struct pcser_unit_t *pcser; - kcondvar_t cvp; - kmutex_t line_mutex; - uchar_t dtr_shadow; /* shadow of DTR latch */ - uchar_t pcser_flowc; /* flow control character */ - int pcser_max_txbufsize; /* soft Tx buf size */ - int pcser_txbufsize; /* soft Tx buf size */ - int pcser_rxfifo_size; /* size of Rx FIFO */ - uchar_t *pcser_txbuf; /* soft tx buffer */ - int pcser_txcount; /* num chars in pcser_txbuf */ - int pcser_silosize; /* size of rx silo */ - int pcser_sscnt; /* silo count */ - uchar_t *pcser_source; /* silo source */ - uchar_t *pcser_sink; /* silo sink */ - uchar_t pcser_ssilo[PCSER_SILOSIZE]; /* soft silo */ - int pcser_qfcnt; /* queue full retry count */ - bufcall_id_t pcser_wbufcid; /* write-side bufcall id */ - /* stuff that affects the reception of data */ - int drain_size; /* buf size pcser_drainsilo */ - int pcser_hiwater; /* high water mark CHECK_RTS */ - int pcser_lowwater; /* low water mark CHECK_RTS */ - int rx_fifo_thld; /* cd-180 RxFIFO threshold */ - struct pcser_stats_t pcser_stats; /* support PCSER_GSTATS ioctl */ - tty_common_t pcser_ttycommon; /* common tty stuff */ -} pcser_line_t; - -/* - * flags in pcser_line_t.state field - */ -#define PCSER_WOPEN 0x00000001 /* wait for open to complete */ -#define PCSER_ISOPEN 0x00000002 /* open is complete */ -#define PCSER_OUT 0x00000004 /* line used for dialout */ -#define PCSER_CARR_ON 0x00000008 /* CD on last time we looked */ -#define PCSER_RTSOFF_MESSAGE 0x00000010 -#define PCSER_STOPPED 0x00000020 /* output is stopped */ -#define PCSER_DELAY 0x00000040 /* waiting for delay */ -#define PCSER_BREAK 0x00000080 /* waiting for break */ -#define PCSER_BUSY 0x00000100 /* waiting for transmission */ -#define PCSER_FLUSH 0x00000200 /* flushing Tx output */ -#define PCSER_OPEN_READY 0x00000400 /* ready for IRQs in open */ -#define PCSER_WCLOSE 0x00000800 /* wakeup from close in open */ -#define PCSER_XWAIT 0x00001000 /* waiting for xmtr to drain */ -#define PCSER_IXOFF 0x00002000 /* using s/w Rx flow control */ -#define PCSER_CANWAIT 0x00004000 /* pcser_drainsilo waiting */ -#define PCSER_CONTROL 0x00008000 /* control line */ -#define PCSER_SBREAK 0x00010000 /* start BREAK */ -#define PCSER_EBREAK 0x00020000 /* end BREAK */ -#define PCSER_ISROOT 0x00040000 /* line was root at open */ -#define PCSER_CTSWAIT 0x00080000 /* wait for CTS for next Tx */ -/* flags used with pcser_softint() */ -#define PCSER_TXWORK 0x00100000 /* Tx work to do */ -#define PCSER_RXWORK 0x00200000 /* Rx work to do */ -#define PCSER_CVBROADCAST 0x00400000 /* need a cv_broadcast */ -#define PCSER_UNTIMEOUT 0x00800000 /* need an untimeout */ -#define PCSER_MHANGUP 0x01000000 /* send M_HANGUP message */ -#define PCSER_MUNHANGUP 0x02000000 /* send M_UNHANGUP message */ -#define PCSER_MBREAK 0x04000000 /* send M_BREAK message */ -#define PCSER_IGNORE_CD 0x08000000 /* ignore CD transitions */ -#define PCSER_FIRST_OPEN 0x10000000 /* first open since config */ -#define PCSER_INDRAIN 0x20000000 /* in pcser_drainsilo */ -#define PCSER_RTSON_MESSAGE 0x40000000 -#define PCSER_DRAIN 0x80000000 /* pcser_start flushing */ - -/* - * flags in pcser_line_t.saved_state field - */ -#define PCSER_AUDIO_ON 0x00000001 /* audio enabled */ - -/* - * flags in pcser_line_t.flags field are in pcser_io.h - */ - -/* - * private flags for pcser_xmit and pcser_modem - */ -#define PCSER_CALL 0x00000001 /* OK to call routine */ -#define PCSER_DONTCALL 0x00000002 /* don't call routine */ - -/* - * Per board (controller) structure - */ -typedef struct pcser_unit_t { - client_handle_t client_handle; /* client handle for socket */ - uint32_t sn; /* socket number */ - int instance; /* instance number */ - uint32_t card_state; - kmutex_t *pcser_mutex; /* protects UART registers */ - kmutex_t irq_mutex; - kmutex_t noirq_mutex; - kmutex_t event_hilock; /* protects hi-level events */ - timeout_id_t ready_timeout_id; - timeout_id_t readywait_timeout_id; - int unid_irq; /* unknown IRQ count */ - ddi_iblock_cookie_t soft_blk_cookie; /* soft int cookie */ - ddi_softintr_t softint_id; - unsigned flags; - struct pcser_line_t line; - struct pcser_line_t control_line; - dev_info_t *dip; /* Device dev_info_t */ - kcondvar_t readywait_cv; -} pcser_unit_t; - -/* - * flags in pcser_unit_t.flags field - */ -#define PCSER_DIDLOCKS 0x00000001 /* cv/mutex_init in attach */ -#define PCSER_REGCLIENT 0x00000002 /* RegisterClient is OK */ -#define PCSER_REQSOCKMASK 0x00000004 /* RequestSocketMask is OK */ -#define PCSER_SOFTINTROK 0x00000008 /* added to interrupt chain */ -#define PCSER_ATTACHOK 0x00000010 /* pcser_attach is OK */ -#define PCSER_REQUESTIO 0x00000020 /* did RequestIO */ -#define PCSER_REQUESTIRQ 0x00000040 /* did RequestIRQ */ -#define PCSER_REQUESTCONFIG 0x00000080 /* did RequestConfiguration */ -#define PCSER_MAKEDEVICENODE 0x00000100 /* did MakeDeviceNode */ -#ifdef CBAUDEXT -#define PCSER_USE_DUALFLOW 0x40000000 /* alias CRTSCTS and CRTSXOF */ -#endif -#ifndef CBAUDEXT -#define PCSER_USE_HIGHSPEED 0x80000000 /* use high baud rates */ -#endif - -/* - * flags in pcser_unit_t.card_state field - */ -#define PCSER_CARD_INSERTED 0x00000001 /* card is here */ -#define PCSER_WAIT_FOR_READY 0x00000002 /* waiting for card ready */ -#define PCSER_CARD_IS_READY 0x00000004 /* card is ready */ -#define PCSER_READY_WAIT 0x00000008 /* waiting for READY */ -#define PCSER_READY_ERR 0x00000010 /* failure to become ready */ - -/* - * the state struct for transparent ioctl()s - */ -struct pcser_state_t { - int state; - caddr_t addr; -}; - -/* - * state for transparent ioctl()'s used in pcser_state_t - */ -#define PCSER_COPYIN 1 -#define PCSER_COPYOUT 2 - -#ifdef __cplusplus -} -#endif - -#endif /* _PCSER_VAR_H */ diff --git a/usr/src/uts/intel/Makefile.intel.shared b/usr/src/uts/intel/Makefile.intel.shared index e5f0e47376..b86fb0a65a 100644 --- a/usr/src/uts/intel/Makefile.intel.shared +++ b/usr/src/uts/intel/Makefile.intel.shared @@ -290,8 +290,6 @@ DRV_KMODS += pci_pci DRV_KMODS += pcic DRV_KMODS += pcieb DRV_KMODS += physmem -DRV_KMODS += pcan -DRV_KMODS += pcwl DRV_KMODS += pit_beep DRV_KMODS += pm DRV_KMODS += poll @@ -456,9 +454,7 @@ DRV_KMODS += iscsi # PCMCIA specific module(s) # DRV_KMODS += pcs -DRV_KMODS += pcata MISC_KMODS += cardbus -$(CLOSED_BUILD)CLOSED_DRV_KMODS += pcser # # SCSI Enclosure Services driver diff --git a/usr/src/uts/intel/pcan/Makefile b/usr/src/uts/intel/pcan/Makefile deleted file mode 100644 index 45f6946b66..0000000000 --- a/usr/src/uts/intel/pcan/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the pcan driver kernel module. -# -# intel implementation architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = pcan -OBJECTS = $(PCAN_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(PCAN_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) - - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(ITUMOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Override defaults to build a unique, local modstubs.o. -# -MODSTUBS_DIR = $(OBJS_DIR) -CLEANFILES += $(MODSTUBS_O) -INC_PATH += -I$(UTSBASE)/common/pcmcia - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - -# -# STREAMS API limitations force us to turn off these lint checks. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-switch - -# -# dependency -# -LDFLAGS += -dy -Nmisc/mac -Ndrv/ip - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ - diff --git a/usr/src/uts/intel/pcata/Makefile b/usr/src/uts/intel/pcata/Makefile deleted file mode 100644 index 90a3bd0074..0000000000 --- a/usr/src/uts/intel/pcata/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# uts/intel/pcata/Makefile -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the pcata driver kernel module. -# -# intel implementation architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = pcata -OBJECTS = $(PCATA_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(PCATA_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) - - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Override defaults to build a unique, local modstubs.o. -# -MODSTUBS_DIR = $(OBJS_DIR) -CLEANFILES += $(MODSTUBS_O) -INC_PATH += -I$(UTSBASE)/common/pcmcia - -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-uninitialized - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ - diff --git a/usr/src/uts/intel/pcwl/Makefile b/usr/src/uts/intel/pcwl/Makefile deleted file mode 100644 index ee5da418f8..0000000000 --- a/usr/src/uts/intel/pcwl/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the pcwl driver kernel module. -# -# intel implementation architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = pcwl -OBJECTS = $(PCWL_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(PCWL_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) - - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(ITUMOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Override defaults to build a unique, local modstubs.o. -# -MODSTUBS_DIR = $(OBJS_DIR) -CLEANFILES += $(MODSTUBS_O) -INC_PATH += -I$(UTSBASE)/common/pcmcia - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - -# -# STREAMS API limitations force us to turn off these lint checks. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-switch -CERRWARN += -_gcc=-Wno-uninitialized - -# -# dependency -# -LDFLAGS += -dy -Nmisc/mac -Ndrv/ip - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ - diff --git a/usr/src/uts/sparc/Makefile.sparc.shared b/usr/src/uts/sparc/Makefile.sparc.shared index 24d2ff9110..c49103913b 100644 --- a/usr/src/uts/sparc/Makefile.sparc.shared +++ b/usr/src/uts/sparc/Makefile.sparc.shared @@ -257,8 +257,6 @@ DRV_KMODS += e1000g DRV_KMODS += efe DRV_KMODS += hxge DRV_KMODS += mxfe -DRV_KMODS += pcan -DRV_KMODS += pcwl DRV_KMODS += rge DRV_KMODS += rtls DRV_KMODS += sfe @@ -341,11 +339,8 @@ DRV_KMODS += emul64 # DRV_KMODS += pcs MISC_KMODS += busra cardbus dada pcmcia -DRV_KMODS += pcata DRV_KMODS += pcic -$(CLOSED_BUILD)CLOSED_DRV_KMODS += pcser - # Add lvm # DRV_KMODS += md diff --git a/usr/src/uts/sparc/pcan/Makefile b/usr/src/uts/sparc/pcan/Makefile deleted file mode 100644 index 7b9f5a7d97..0000000000 --- a/usr/src/uts/sparc/pcan/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the pcan driver kernel module. -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = pcan -OBJECTS = $(PCAN_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(PCAN_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) - - -# -# Include common rules. -# -include $(UTSBASE)/sparc/Makefile.sparc - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(ITUMOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Override defaults to build a unique, local modstubs.o. -# -MODSTUBS_DIR = $(OBJS_DIR) -CLEANFILES += $(MODSTUBS_O) -INC_PATH += -I$(UTSBASE)/common/pcmcia - -# -# lint pass one enforcement -# -CFLAGS += -v - -# -# STREAMS API limitations force us to turn off these lint checks. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-switch - -# -# dependency -# -LDFLAGS += -dy -Nmisc/mac -Ndrv/ip - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sparc/Makefile.targ - diff --git a/usr/src/uts/sparc/pcata/Makefile b/usr/src/uts/sparc/pcata/Makefile deleted file mode 100644 index cf45d848c5..0000000000 --- a/usr/src/uts/sparc/pcata/Makefile +++ /dev/null @@ -1,105 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# uts/sparc/pcata/Makefile -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the pcata driver kernel module. -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = pcata -OBJECTS = $(PCATA_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(PCATA_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) - - -# -# Include common rules. -# -include $(UTSBASE)/sparc/Makefile.sparc - -# -# Define targets -# -ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Override defaults to build a unique, local modstubs.o. -# -MODSTUBS_DIR = $(OBJS_DIR) -CLEANFILES += $(MODSTUBS_O) -INC_PATH += -I$(UTSBASE)/common/pcmcia - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-uninitialized - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) lint64 - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sparc/Makefile.targ - diff --git a/usr/src/uts/sparc/pcwl/Makefile b/usr/src/uts/sparc/pcwl/Makefile deleted file mode 100644 index 2206f3c9c4..0000000000 --- a/usr/src/uts/sparc/pcwl/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the pcwl driver kernel module. -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = pcwl -OBJECTS = $(PCWL_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(PCWL_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) - - -# -# Include common rules. -# -include $(UTSBASE)/sparc/Makefile.sparc - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(ITUMOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Override defaults to build a unique, local modstubs.o. -# -MODSTUBS_DIR = $(OBJS_DIR) -CLEANFILES += $(MODSTUBS_O) -INC_PATH += -I$(UTSBASE)/common/pcmcia - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - -# -# STREAMS API limitations force us to turn off these lint checks. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-switch -CERRWARN += -_gcc=-Wno-uninitialized - -# -# dependency -# -LDFLAGS += -dy -Nmisc/mac -Ndrv/ip - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sparc/Makefile.targ - |