Index: if_an.c =================================================================== RCS file: /home/ncvs/src/sys/dev/an/if_an.c,v retrieving revision 1.82 diff -u -p -r1.82 if_an.c --- if_an.c 2 Aug 2007 02:20:19 -0000 1.82 +++ if_an.c 3 Aug 2007 01:46:27 -0000 @@ -569,8 +569,7 @@ an_init_mpi350_desc(struct an_softc *sc) cmd_struct.an_parm1 = AN_RX_DESC_OFFSET; cmd_struct.an_parm2 = AN_MAX_RX_DESC; if (an_cmd_struct(sc, &cmd_struct, &reply)) { - printf("an%d: failed to allocate RX descriptor\n", - sc->an_unit); + device_printf(sc->an_dev, "failed to allocate RX descriptor\n"); return(EIO); } @@ -598,8 +597,7 @@ an_init_mpi350_desc(struct an_softc *sc) cmd_struct.an_parm1 = AN_TX_DESC_OFFSET; cmd_struct.an_parm2 = AN_MAX_TX_DESC; if (an_cmd_struct(sc, &cmd_struct, &reply)) { - printf("an%d: failed to allocate TX descriptor\n", - sc->an_unit); + device_printf(sc->an_dev, "failed to allocate TX descriptor\n"); return(EIO); } @@ -628,8 +626,7 @@ an_init_mpi350_desc(struct an_softc *sc) cmd_struct.an_parm1 = AN_HOST_DESC_OFFSET; cmd_struct.an_parm2 = 1; if (an_cmd_struct(sc, &cmd_struct, &reply)) { - printf("an%d: failed to allocate host descriptor\n", - sc->an_unit); + device_printf(sc->an_dev, "failed to allocate host descriptor\n"); return(EIO); } @@ -658,7 +655,7 @@ an_attach(struct an_softc *sc, int unit, MTX_DEF | MTX_RECURSE); ifp = sc->an_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - printf("an%d: can not if_alloc()\n", sc->an_unit); + device_printf(sc->an_dev, "can not if_alloc()\n"); goto fail; } @@ -678,7 +675,7 @@ an_attach(struct an_softc *sc, int unit, /* Load factory config */ if (an_cmd(sc, AN_CMD_READCFG, 0)) { - printf("an%d: failed to load config data\n", sc->an_unit); + device_printf(sc->an_dev, "failed to load config data\n"); goto fail; } @@ -686,7 +683,7 @@ an_attach(struct an_softc *sc, int unit, sc->an_config.an_type = AN_RID_GENCONFIG; sc->an_config.an_len = sizeof(struct an_ltv_genconfig); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_config)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -694,7 +691,7 @@ an_attach(struct an_softc *sc, int unit, sc->an_caps.an_type = AN_RID_CAPABILITIES; sc->an_caps.an_len = sizeof(struct an_ltv_caps); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_caps)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -702,7 +699,7 @@ an_attach(struct an_softc *sc, int unit, sc->an_ssidlist.an_type = AN_RID_SSIDLIST; sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -710,7 +707,7 @@ an_attach(struct an_softc *sc, int unit, sc->an_aplist.an_type = AN_RID_APLIST; sc->an_aplist.an_len = sizeof(struct an_ltv_aplist); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -721,13 +718,14 @@ an_attach(struct an_softc *sc, int unit, sc->an_rssimap.an_type = AN_RID_RSSI_MAP; sc->an_rssimap.an_len = sizeof(struct an_ltv_rssi_map); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_rssimap)) { - printf("an%d: unable to get RSSI <-> dBM map\n", sc->an_unit); + device_printf(sc->an_dev, + "unable to get RSSI <-> dBM map\n"); } else { - printf("an%d: got RSSI <-> dBM map\n", sc->an_unit); + device_printf(sc->an_dev, "got RSSI <-> dBM map\n"); sc->an_have_rssimap = 1; } } else { - printf("an%d: no RSSI <-> dBM map\n", sc->an_unit); + device_printf(sc->an_dev, "no RSSI <-> dBM map\n"); } #endif @@ -874,9 +872,9 @@ an_rxeof(struct an_softc *sc) + sizeof(rx_frame); /* Check for insane frame length */ if (len > sizeof(sc->buf_802_11)) { - printf("an%d: oversized packet " - "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + device_printf(sc->an_dev, + "oversized packet received (%d, %d)\n", + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -900,9 +898,9 @@ an_rxeof(struct an_softc *sc) + ieee80211_header_len; /* Check for insane frame length */ if (len > sizeof(sc->buf_802_11)) { - printf("an%d: oversized packet " - "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + device_printf(sc->an_dev, + "oversized packet received (%d, %d)\n", + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -960,9 +958,9 @@ an_rxeof(struct an_softc *sc) len = rx_frame_802_3.an_rx_802_3_payload_len; if (len > sizeof(sc->buf_802_11)) { m_freem(m); - printf("an%d: oversized packet " - "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + device_printf(sc->an_dev, + "oversized packet received (%d, %d)\n", + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -1040,9 +1038,9 @@ an_rxeof(struct an_softc *sc) len = an_rx_desc.an_len + 12; if (len > MCLBYTES) { m_freem(m); - printf("an%d: oversized packet " - "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + device_printf(sc->an_dev, + "oversized packet received (%d, %d)\n", + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -1065,8 +1063,10 @@ an_rxeof(struct an_softc *sc) rx_frame.an_rsvd0); #endif #endif + AN_UNLOCK(sc); (*ifp->if_input)(ifp, m); - + AN_LOCK(sc); + an_rx_desc.an_valid = 1; an_rx_desc.an_len = AN_RX_BUFFER_SIZE; an_rx_desc.an_done = 0; @@ -1081,11 +1081,10 @@ an_rxeof(struct an_softc *sc) ((u_int32_t *)(void *)&an_rx_desc)[i]); } else { - printf("an%d: Didn't get valid RX packet " - "%x %x %d\n", - sc->an_unit, - an_rx_desc.an_done, - an_rx_desc.an_valid, an_rx_desc.an_len); + device_printf(sc->an_dev, + "Didn't get valid RX packet %x %x %d\n", + an_rx_desc.an_done, + an_rx_desc.an_valid, an_rx_desc.an_len); } } } @@ -1352,7 +1351,7 @@ an_reset(struct an_softc *sc) an_cmd(sc, AN_CMD_NOOP2, 0); if (an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0) == ETIMEDOUT) - printf("an%d: reset failed\n", sc->an_unit); + device_printf(sc->an_dev, "reset failed\n"); an_cmd(sc, AN_CMD_DISABLE, 0); @@ -1379,13 +1378,13 @@ an_read_record(struct an_softc *sc, stru if (!sc->mpi350){ /* Tell the NIC to enter record read mode. */ if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type)) { - printf("an%d: RID access failed\n", sc->an_unit); + device_printf(sc->an_dev, "RID access failed\n"); return(EIO); } /* Seek to the record. */ if (an_seek(sc, ltv->an_type, 0, AN_BAP1)) { - printf("an%d: seek to record failed\n", sc->an_unit); + device_printf(sc->an_dev, "seek to record failed\n"); return(EIO); } @@ -1397,9 +1396,9 @@ an_read_record(struct an_softc *sc, stru */ len = CSR_READ_2(sc, AN_DATA1); if (len > (ltv->an_len - 2)) { - printf("an%d: record length mismatch -- expected %d, " - "got %d for Rid %x\n", sc->an_unit, - ltv->an_len - 2, len, ltv->an_type); + device_printf(sc->an_dev, "record length mismatch -- " + "expected %d, got %d for Rid %x\n", + ltv->an_len - 2, len, ltv->an_type); len = ltv->an_len - 2; } else { ltv->an_len = len + 2; @@ -1434,8 +1433,8 @@ an_read_record(struct an_softc *sc, stru if (an_cmd_struct(sc, &cmd, &reply) || reply.an_status & AN_CMD_QUAL_MASK) { - printf("an%d: failed to read RID %x %x %x %x %x, %d\n", - sc->an_unit, ltv->an_type, + device_printf(sc->an_dev, "failed to read RID %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1451,9 +1450,9 @@ an_read_record(struct an_softc *sc, stru len = an_rid_desc.an_len; if (len > (ltv->an_len - 2)) { - printf("an%d: record length mismatch -- expected %d, " - "got %d for Rid %x\n", sc->an_unit, - ltv->an_len - 2, len, ltv->an_type); + device_printf(sc->an_dev, "record length mismatch -- " + "expected %d, got %d for Rid %x\n", + ltv->an_len - 2, len, ltv->an_type); len = ltv->an_len - 2; } else { ltv->an_len = len + 2; @@ -1543,8 +1542,8 @@ an_write_record(struct an_softc *sc, str DELAY(100000); if ((i = an_cmd_struct(sc, &cmd, &reply))) { - printf("an%d: failed to write RID 1 %x %x %x %x %x, %d\n", - sc->an_unit, ltv->an_type, + device_printf(sc->an_dev, "failed to write RID 1 %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1555,8 +1554,8 @@ an_write_record(struct an_softc *sc, str if (reply.an_status & AN_CMD_QUAL_MASK) { - printf("an%d: failed to write RID 2 %x %x %x %x %x, %d\n", - sc->an_unit, ltv->an_type, + device_printf(sc->an_dev, "failed to write RID 2 %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1580,11 +1579,11 @@ an_dump_record(struct an_softc *sc, stru char buf[17], temp; len = ltv->an_len - 4; - printf("an%d: RID %4x, Length %4d, Mode %s\n", - sc->an_unit, ltv->an_type, ltv->an_len - 4, string); + device_printf(sc->an_dev, "RID %4x, Length %4d, Mode %s\n", + ltv->an_type, ltv->an_len - 4, string); if (an_dump == 1 || (an_dump == ltv->an_type)) { - printf("an%d:\t", sc->an_unit); + device_printf(sc->an_dev, "\t"); bzero(buf,sizeof(buf)); ptr2 = (u_int8_t *)<v->an_val; @@ -1599,7 +1598,7 @@ an_dump_record(struct an_softc *sc, stru if (++count == 16) { count = 0; printf("%s\n",buf); - printf("an%d:\t", sc->an_unit); + device_printf(sc->an_dev, "\t"); bzero(buf,sizeof(buf)); } } @@ -1626,7 +1625,7 @@ an_seek(struct an_softc *sc, int id, int offreg = AN_OFF1; break; default: - printf("an%d: invalid data path: %x\n", sc->an_unit, chan); + device_printf(sc->an_dev, "invalid data path: %x\n", chan); return(EIO); } @@ -1700,8 +1699,8 @@ an_alloc_nicmem(struct an_softc *sc, int int i; if (an_cmd(sc, AN_CMD_ALLOC_MEM, len)) { - printf("an%d: failed to allocate %d bytes on NIC\n", - sc->an_unit, len); + device_printf(sc->an_dev, "failed to allocate %d bytes on NIC\n", + len); return(ENOMEM); } @@ -1817,7 +1816,7 @@ an_setdef(struct an_softc *sc, struct an } break; default: - printf("an%d: unknown RID: %x\n", sc->an_unit, areq->an_type); + device_printf(sc->an_dev, "unknown RID: %x\n", areq->an_type); return; } @@ -1860,6 +1859,7 @@ an_ioctl(struct ifnet *ifp, u_long comma struct ifreq *ifr; struct thread *td = curthread; struct ieee80211req *ireq; + struct ieee80211_channel ch; u_int8_t tmpstr[IEEE80211_NWID_LEN*2]; u_int8_t *tmpptr; struct an_ltv_genconfig *config; @@ -2215,6 +2215,22 @@ an_ioctl(struct ifnet *ifp, u_long comma } ireq->i_val = status->an_cur_channel; break; + case IEEE80211_IOC_CURCHAN: + sc->areq.an_type = AN_RID_STATUS; + if (an_read_record(sc, + (struct an_ltv_gen *)&sc->areq)) { + error = EINVAL; + break; + } + bzero(&ch, sizeof(ch)); + ch.ic_freq = ieee80211_ieee2mhz(status->an_cur_channel, + IEEE80211_CHAN_B); + ch.ic_flags = IEEE80211_CHAN_B; + ch.ic_ieee = status->an_cur_channel; + AN_UNLOCK(sc); + error = copyout(&ch, ireq->i_data, sizeof(ch)); + AN_LOCK(sc); + break; case IEEE80211_IOC_POWERSAVE: sc->areq.an_type = AN_RID_ACTUALCFG; if (an_read_record(sc, @@ -2517,8 +2533,8 @@ an_init(void *xsc) if (sc->mpi350) an_init_mpi350_desc(sc); if (an_init_tx_ring(sc)) { - printf("an%d: tx buffer allocation " - "failed\n", sc->an_unit); + device_printf(sc->an_dev, "tx buffer allocation " + "failed\n"); AN_UNLOCK(sc); return; } @@ -2557,7 +2573,7 @@ an_init(void *xsc) sc->an_ssidlist.an_type = AN_RID_SSIDLIST; sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new); if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) { - printf("an%d: failed to set ssid list\n", sc->an_unit); + device_printf(sc->an_dev, "failed to set ssid list\n"); AN_UNLOCK(sc); return; } @@ -2566,7 +2582,7 @@ an_init(void *xsc) sc->an_aplist.an_type = AN_RID_APLIST; sc->an_aplist.an_len = sizeof(struct an_ltv_aplist); if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) { - printf("an%d: failed to set AP list\n", sc->an_unit); + device_printf(sc->an_dev, "failed to set AP list\n"); AN_UNLOCK(sc); return; } @@ -2575,14 +2591,14 @@ an_init(void *xsc) sc->an_config.an_len = sizeof(struct an_ltv_genconfig); sc->an_config.an_type = AN_RID_GENCONFIG; if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_config)) { - printf("an%d: failed to set configuration\n", sc->an_unit); + device_printf(sc->an_dev, "failed to set configuration\n"); AN_UNLOCK(sc); return; } /* Enable the MAC */ if (an_cmd(sc, AN_CMD_ENABLE, 0)) { - printf("an%d: failed to enable MAC\n", sc->an_unit); + device_printf(sc->an_dev, "failed to enable MAC\n"); AN_UNLOCK(sc); return; } @@ -2688,7 +2704,7 @@ an_start(struct ifnet *ifp) sc->an_rdata.an_tx_ring[idx] = id; if (an_cmd(sc, AN_CMD_TX, id)) - printf("an%d: xmit failed\n", sc->an_unit); + device_printf(sc->an_dev, "xmit failed\n"); AN_INC(idx, AN_TX_RING_CNT); @@ -2836,7 +2852,7 @@ an_watchdog(struct ifnet *ifp) return; } - printf("an%d: device timeout\n", sc->an_unit); + device_printf(sc->an_dev, "device timeout\n"); an_reset(sc); if (sc->mpi350) @@ -2987,7 +3003,7 @@ an_cache_store(struct an_softc *sc, stru } #ifdef SIGDEBUG - printf("an: q value %x (MSB=0x%x, LSB=0x%x) \n", + device_printf(sc->an_dev, "q value %x (MSB=0x%x, LSB=0x%x) \n", rx_rssi & 0xffff, rx_rssi >> 8, rx_rssi & 0xff); #endif @@ -3421,8 +3437,8 @@ cmdreset(struct ifnet *ifp) an_cmd(sc, AN_CMD_DISABLE, 0); if (!(status = WaitBusy(ifp, AN_TIMEOUT))) { - printf("an%d: Waitbusy hang b4 RESET =%d\n", - sc->an_unit, status); + device_printf(sc->an_dev, "Waitbusy hang b4 RESET =%d\n", + status); return -EBUSY; } CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), AN_CMD_FW_RESTART); @@ -3431,8 +3447,8 @@ cmdreset(struct ifnet *ifp) if (!(status = WaitBusy(ifp, 100))) { - printf("an%d: Waitbusy hang AFTER RESET =%d\n", - sc->an_unit, status); + device_printf(sc->an_dev, "Waitbusy hang AFTER RESET =%d\n", + status); return -EBUSY; } return 0; @@ -3538,8 +3554,7 @@ flashpchar(struct ifnet *ifp, int byte, /* timeout for busy clear wait */ if (waittime <= 0) { - printf("an%d: flash putchar busywait timeout! \n", - sc->an_unit); + device_printf(sc->an_dev, "flash putchar busywait timeout!\n"); return -1; } /* @@ -3623,8 +3638,7 @@ flashcard(struct ifnet *ifp, struct airo sc = ifp->if_softc; if (sc->mpi350) { - printf("an%d: flashing not supported on MPI 350 yet\n", - sc->an_unit); + device_printf(sc->an_dev, "flashing not supported on MPI 350 yet\n"); return(-1); } status = l_ioctl->command; @@ -3669,7 +3683,7 @@ flashcard(struct ifnet *ifp, struct airo break; case AIROFLPUTBUF: /* Send 32k to card */ if (l_ioctl->len > FLASH_SIZE) { - printf("an%d: Buffer to big, %x %x\n", sc->an_unit, + device_printf(sc->an_dev, "Buffer to big, %x %x\n", l_ioctl->len, FLASH_SIZE); return -EINVAL; } @@ -3686,8 +3700,8 @@ flashcard(struct ifnet *ifp, struct airo break; case AIRORESTART: if ((status = flashrestart(ifp)) != 0) { - printf("an%d: FLASHRESTART returned %d\n", - sc->an_unit, status); + device_printf(sc->an_dev, "FLASHRESTART returned %d\n", + status); return -EIO; } else return 0;