pcwl.c revision 305a15047c0c4be5ad9c852e8de5c2c56cb6134b
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * Use is subject to license terms.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * Copyright (c) 1997, 1998, 1999
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * Redistribution and use in source and binary forms, with or without
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * modification, are permitted provided that the following conditions
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * 1. Redistributions of source code must retain the above copyright
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * notice, this list of conditions and the following disclaimer.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * 2. Redistributions in binary form must reproduce the above copyright
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * notice, this list of conditions and the following disclaimer in the
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * documentation and/or other materials provided with the distribution.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * 3. All advertising materials mentioning features or use of this software
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * must display the following acknowledgement:
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * This product includes software developed by Bill Paul.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * 4. Neither the name of the author nor the names of any co-contributors
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * may be used to endorse or promote products derived from this software
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * without specific prior written permission.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * THE POSSIBILITY OF SUCH DAMAGE.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden#pragma ident "%Z%%M% %I% %E% SMI"
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden/* for pci card */
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil MaddenDDI_DEFINE_STREAM_OPS(pcwl_dev_ops, nulldev, pcwl_probe, pcwl_attach,
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden "Lucent/PRISM-II 802.11b driver",
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden /* Allocate soft state */
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden if ((stat = ddi_soft_state_init(&pcwl_soft_state_p,
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden wl_frame_default.wl_dat[0] = htons(WL_SNAP_WORD0);
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden wl_frame_default.wl_dat[1] = htons(WL_SNAP_WORD1);
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden if ((stat = mod_remove(&modlinkage)) != DDI_SUCCESS)
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden ret = ddi_getlongprop(DDI_DEV_T_ANY, pdip, 0, "device_type",
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden PCWLDBG((CE_NOTE, "pcwl probe: device_type %s\n", buf));
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden if ((strcmp(buf, "pccard") == 0) || (strcmp(buf, "pcmcia") == 0)) {
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Maddenpcwl_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden PCWLDBG((CE_NOTE, "pcwl attach: dip=0x%p cmd=%x\n", (void *)dip, cmd));
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden * Allocate soft state associated with this instance.
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden cmn_err(CE_CONT, "pcwl attach: alloc softstate failed\n");
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden pcwl_p = (pcwl_maci_t *)ddi_get_soft_state(pcwl_soft_state_p,
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden if (pcwl_p->pcwl_device_type == PCWL_DEVICE_PCI) {
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden &accattr, &pcwl_p->pcwl_cfg_handle) != DDI_SUCCESS) {
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden cmn_err(CE_WARN, "pcwl(pci) attach: pci_regs_map_setup"
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden " failed\n");
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden (uint16_t *)(pcwl_p->pcwl_cfg_base + PCI_CONF_COMM));
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden (uint16_t *)(pcwl_p->pcwl_cfg_base + PCI_CONF_COMM), stat);
971de91bce73bb05574a64c4304daf9f60e2b5b8Neil Madden (uint16_t *)(pcwl_p->pcwl_cfg_base + PCI_CONF_COMM));
goto attach_fail2a;
!= DDI_SUCCESS) {
goto attach_fail2a;
for (i = 0; i < WL_TIMEOUT; i++) {
if (i == WL_TIMEOUT) {
goto attach_fail3;
goto attach_fail3;
goto attach_fail3;
goto attach_fail3a;
goto attach_fail3a;
goto attach_fail3a;
goto attach_fail4;
goto attach_fail4;
goto attach_fail4;
if (err != 0) {
goto attach_fail4;
goto attach_fail5;
goto attach_fail5;
goto attach_fail6;
return (DDI_SUCCESS);
return (DDI_FAILURE);
int ret;
return (DDI_FAILURE);
return (DDI_FAILURE);
while (scan_item0) {
if (ret != 0)
return (DDI_FAILURE);
return (DDI_SUCCESS);
int ret;
goto regcs_ret;
goto regcs_unreg;
goto regcs_fail;
goto regcs_fail;
return (PCWL_SUCCESS);
return (ret);
int ret;
switch (event) {
case CS_EVENT_CARD_INSERTION:
case CS_EVENT_CARD_REMOVAL:
case CS_EVENT_CLIENT_INFO:
return (ret);
goto insert_ret;
goto insert_ret;
goto insert_ret;
goto insert_ret;
goto insert_ret;
goto insert_ret;
hi = 0;
ret);
ret);
goto insert_ret;
goto insert_ret;
goto un_io;
goto un_irq;
return (CS_SUCCESS);
return (ret);
int ret;
return (PCWL_FAIL);
return (PCWL_SUCCESS);
goto done;
goto done;
goto done;
done:
if (ret)
return (ret);
while ((i < WL_XMT_BUF_NUM) &&
if (i == WL_XMT_BUF_NUM) {
return (PCWL_FAIL);
#ifdef DEBUG
#ifdef DEBUG
for (i = 0; i < pkt_len; i++)
*((unsigned char *)buf + i));
if (ret) {
goto done;
done:
return (PCWL_SUCCESS);
static mblk_t *
return (mp);
return (mp);
goto done;
if (on)
done:
if (ret)
return (ret);
goto done;
goto done;
case PCWL_CHIP_PRISMII:
switch (rate) {
default: rate = 0; break;
case PCWL_CHIP_LUCENT:
switch (statitem) {
case MAC_STAT_IFSPEED:
case MAC_STAT_NOXMTBUF:
case MAC_STAT_NORCVBUF:
case MAC_STAT_IERRORS:
*val = 0;
case MAC_STAT_OERRORS:
case MAC_STAT_RBYTES:
case MAC_STAT_IPACKETS:
case MAC_STAT_OBYTES:
case MAC_STAT_OPACKETS:
case WIFI_STAT_TX_FAILED:
case WIFI_STAT_TX_RETRANS:
case WIFI_STAT_FCS_ERRORS:
case WIFI_STAT_WEP_ERRORS:
case WIFI_STAT_MCAST_TX:
case WIFI_STAT_MCAST_RX:
case WIFI_STAT_TX_FRAGS:
case WIFI_STAT_RX_FRAGS:
case WIFI_STAT_RTS_SUCCESS:
case WIFI_STAT_RTS_FAILURE:
case WIFI_STAT_ACK_FAILURE:
case WIFI_STAT_RX_DUPS:
*val = 0;
done:
return (ret);
uint16_t i;
goto done;
goto done;
goto done;
goto done;
mc_p[0] = 0;
done:
if (ret)
return (ret);
static uint_t
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_CLAIMED);
static uint_t
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_CLAIMED);
if (!mp)
goto done;
goto done;
goto done;
#ifdef DEBUG
for (i = 0; i < WL_802_11_HDRLEN; i++)
case WL_STAT_1042:
case WL_STAT_TUNNEL:
case WL_STAT_WMP_MSG:
sizeof (struct ieee80211_frame));
goto done;
sizeof (struct ieee80211_frame));
sizeof (struct ieee80211_llc));
sizeof (struct ieee80211_llc));
goto done;
len++;
done:
if (ret) {
#ifdef DEBUG
static uint32_t
for (i = 0; i < WL_XMT_BUF_NUM; i++) {
if (i == WL_XMT_BUF_NUM)
return (PCWL_FAIL);
return (PCWL_SUCCESS);
ret));
case WL_INFO_LINK_STAT:
sizeof (linkStat));
#ifdef DEBUG
sizeof (wd));
#ifdef DEBUG
linkStat));
case WL_INFO_SCAN_RESULTS:
case WL_INFO_HSCAN_RESULTS:
case WL_INFO_COUNTERS:
linkStatus[0]--;
for (i = 0; i < WLC_STAT_CNT; i++)
static uint16_t
return (PCWL_SUCCESS);
for (i = 0; i < WL_TIMEOUT; i++) {
if (i == WL_TIMEOUT) {
return (PCWL_TIMEDOUT_CMD);
for (i = 0; i < WL_TIMEOUT; i++) {
if (i == WL_TIMEOUT) {
return (PCWL_TIMEDOUT_CMD);
return (PCWL_FAILURE_CMD);
return (PCWL_SUCCESS);
static uint16_t
if (channel) {
if (i == WL_TIMEOUT) {
return (PCWL_TIMEDOUT_TARGET);
return (PCWL_SUCCESS);
static uint16_t
return (stat);
return (stat);
return (PCWL_BADTYPE);
return (PCWL_SUCCESS);
static uint16_t
return (stat);
static uint16_t
return (stat);
static uint16_t
static uint16_t
uint16_t o;
return (type);
o = WL_DATA1;
return (type);
o = WL_DATA0;
return (PCWL_SUCCESS);
static uint16_t
return (type);
return (PCWL_SUCCESS);
static uint16_t
return (stat);
if (i == WL_TIMEOUT)
return (PCWL_TIMEDOUT_ALLOC);
return (PCWL_SUCCESS);
return (PCWL_FAIL);
return (PCWL_SUCCESS);
kmem_free(s, sizeof (*s));
for (; scan_item0; ) {
for (; scan_item0; ) {
case PCWL_CHIP_PRISMII:
case PCWL_CHIP_LUCENT:
for (i = 0; i < ssidNum; i++) {
#ifdef DEBUG
for (j = 0; j < sizeof (sctbl); j++)
check_num = 0;
for (; scan_item0; ) {
check_num++;
return ((int)ret);
return ((int)ret);
return (PCWL_SUCCESS);
return ((int)stat);
return ((int)stat);
return ((int)stat);
return (PCWL_SUCCESS);
for (i = 0; i < WL_XMT_BUF_NUM; i++) {
if (ret) {
return (PCWL_FAIL);
if (ret) {
return (PCWL_FAIL);
return (PCWL_SUCCESS);
case PCWL_CHIP_PRISMII:
porttype = 0;
porttype = 0;
case PCWL_CHIP_LUCENT:
goto done;
case PCWL_CHIP_PRISMII: {
if (k_len == 0)
case PCWL_CHIP_LUCENT:
done:
return (PCWL_SUCCESS);
int ret;
if (ret) {
return (PCWL_FAIL);
return (PCWL_SUCCESS);
bzero(&f, sizeof (f));
char *value;
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
if (ret) {
goto done;
return (EINVAL);
done:
return (iret);
int iret;
char *buf;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
sizeof (wl_bssid_t));
sizeof (wl_bssid_t));
return (EINVAL);
done:
return (iret);
if ((enable) &&
goto done;
if ((enable) &&
goto done;
goto done;
case PCWL_CHIP_PRISMII:
for (i = 0; i < WL_MAX_SCAN_TIMES; i++) {
case PCWL_CHIP_LUCENT:
for (i = 0; i < WL_MAX_SCAN_TIMES; i++) {
goto done;
goto done;
goto done;
goto done;
done:
if (ret)
return (ret);
char *buf;
uint16_t i;
MAX_BUF_LEN));
return (ENOMEM);
if (!scan_item)
goto done;
i * sizeof (wl_ess_conf_t));
= WL_DSSS;
done:
return (WL_SUCCESS);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
if (ret) {
goto done;
sizeof (wl_linkstatus_t);
sizeof (wl_linkstatus_t);
done:
return (iret);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
return (EINVAL);
done:
return (iret);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
goto done;
return (EINVAL);
done:
return (iret);
uint16_t i;
char *buf;
int iret;
char maxrate;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
switch (rate) {
case WL_SPEED_1Mbps_P2:
case WL_SPEED_2Mbps_P2:
case WL_SPEED_55Mbps_P2:
case WL_SPEED_11Mbps_P2:
goto done;
switch (rate) {
case WL_L_TX_RATE_FIX_1M:
case WL_L_TX_RATE_FIX_2M:
case WL_L_TX_RATE_AUTO_H:
case WL_L_TX_RATE_FIX_5M:
case WL_L_TX_RATE_FIX_11M:
case WL_L_TX_RATE_AUTO_L:
case WL_L_TX_RATE_AUTO_M:
goto done;
i, rates[i]));
->wl_rates_num));
switch (((wl_rates_t *)
switch (rates[0]) {
case WL_RATE_1M:
case WL_RATE_2M:
case WL_RATE_11M:
case WL_RATE_5_5M:
goto done;
switch (maxrate) {
case WL_RATE_2M:
case WL_RATE_11M:
case WL_RATE_5_5M:
goto done;
switch (maxrate) {
case WL_RATE_11M:
case WL_RATE_5_5M:
goto done;
goto done;
return (EINVAL);
done:
return (iret);
uint16_t i;
char *buf;
MAX_BUF_LEN));
return (ENOMEM);
= WL_RATE_1M;
= WL_RATE_2M;
= WL_RATE_5_5M;
= WL_RATE_11M;
return (WL_SUCCESS);
return (EINVAL);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
->wl_ps_mode);
goto done;
return (EINVAL);
done:
return (iret);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
return (EINVAL);
done:
return (iret);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
return (EINVAL);
done:
return (iret);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
return (EINVAL);
done:
return (iret);
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
goto done;
return (EINVAL);
done:
return (iret);
uint16_t i;
int iret;
char *buf;
MAX_BUF_LEN));
return (ENOMEM);
return (EINVAL);
done:
return (iret);
uint16_t i;
int iret;
char *buf;
MAX_BUF_LEN));
return (ENOMEM);
return (EINVAL);
return (iret);
uint16_t i;
char *buf;
int iret;
MAX_BUF_LEN));
return (ENOMEM);
for (i = 0; i < MAX_NWEPKEYS; i++) {
return (EINVAL);
done:
return (iret);
goto done;
goto done;
goto done;
done:
if (ret)
int connect = 0;
return (PCWL_FAIL);
case WL_ESSID:
case WL_BSSID:
case WL_ESS_LIST:
case WL_LINKSTATUS:
case WL_BSS_TYPE:
case WL_PHY_CONFIG:
case WL_DESIRED_RATES:
case WL_SUPPORTED_RATES:
case WL_POWER_MODE:
case WL_AUTH_MODE:
case WL_ENCRYPTION:
case WL_WEP_KEY_ID:
case WL_CREATE_IBSS:
case WL_RSSI:
case WL_RADIO:
case WL_WEP_KEY_TAB:
case WL_SCAN:
case WL_LOAD_DEFAULTS:
case WL_DISASSOCIATE:
case WL_REASSOCIATE:
case WL_ASSOCIAT:
return (ret);
switch (cmd) {
case WLAN_GET_PARAM:
case WLAN_SET_PARAM:
case WLAN_COMMAND:
if (need_privilege) {