From owner-svn-src-all@FreeBSD.ORG Fri Nov 6 14:52:37 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EFA651065676; Fri, 6 Nov 2009 14:52:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC3488FC18; Fri, 6 Nov 2009 14:52:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nA6EqbrT020079; Fri, 6 Nov 2009 14:52:37 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nA6Eqbxm020072; Fri, 6 Nov 2009 14:52:37 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200911061452.nA6Eqbxm020072@svn.freebsd.org> From: John Baldwin Date: Fri, 6 Nov 2009 14:52:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198987 - in head/sys/dev: an ixgb vge X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Nov 2009 14:52:38 -0000 Author: jhb Date: Fri Nov 6 14:52:37 2009 New Revision: 198987 URL: http://svn.freebsd.org/changeset/base/198987 Log: Use device_printf() and if_printf() instead of printf() with an explicit unit number and remove 'unit' members from softc. Modified: head/sys/dev/an/if_an.c head/sys/dev/an/if_anreg.h head/sys/dev/ixgb/if_ixgb.c head/sys/dev/ixgb/if_ixgb.h head/sys/dev/vge/if_vge.c head/sys/dev/vge/if_vgevar.h Modified: head/sys/dev/an/if_an.c ============================================================================== --- head/sys/dev/an/if_an.c Fri Nov 6 13:10:12 2009 (r198986) +++ head/sys/dev/an/if_an.c Fri Nov 6 14:52:37 2009 (r198987) @@ -349,7 +349,6 @@ an_probe(device_t dev) */ sc->an_bhandle = rman_get_bushandle(sc->port_res); sc->an_btag = rman_get_bustag(sc->port_res); - sc->an_unit = device_get_unit(dev); ssid.an_len = sizeof(ssid); ssid.an_type = AN_RID_SSIDLIST; @@ -600,8 +599,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); + if_printf(sc->an_ifp, "failed to allocate RX descriptor\n"); return(EIO); } @@ -629,8 +627,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); + if_printf(sc->an_ifp, "failed to allocate TX descriptor\n"); return(EIO); } @@ -659,8 +656,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); + if_printf(sc->an_ifp, "failed to allocate host descriptor\n"); return(EIO); } @@ -687,7 +683,7 @@ an_attach(struct an_softc *sc, int unit, 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; } @@ -708,7 +704,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; } @@ -716,7 +712,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; } @@ -724,7 +720,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; } @@ -732,7 +728,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; } @@ -740,7 +736,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; } @@ -751,19 +747,19 @@ 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 AN_UNLOCK(sc); ifp->if_softc = sc; - sc->an_unit = unit; if_initname(ifp, device_get_name(sc->an_dev), device_get_unit(sc->an_dev)); ifp->if_mtu = ETHERMTU; @@ -907,9 +903,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 " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -933,9 +929,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 " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -993,9 +989,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 " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -1073,9 +1069,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 " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -1116,9 +1112,8 @@ an_rxeof(struct an_softc *sc) ((u_int32_t *)(void *)&an_rx_desc)[i]); } else { - printf("an%d: Didn't get valid RX packet " + if_printf(ifp, "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); } @@ -1393,7 +1388,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); + if_printf(sc->an_ifp, "reset failed\n"); an_cmd(sc, AN_CMD_DISABLE, 0); @@ -1410,6 +1405,7 @@ an_read_record(struct an_softc *sc, stru struct an_card_rid_desc an_rid_desc; struct an_command cmd; struct an_reply reply; + struct ifnet *ifp; u_int16_t *ptr; u_int8_t *ptr2; int i, len; @@ -1418,16 +1414,17 @@ an_read_record(struct an_softc *sc, stru if (ltv->an_len < 4 || ltv->an_type == 0) return(EINVAL); + ifp = sc->an_ifp; 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); + if_printf(ifp, "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); + if_printf(ifp, "seek to record failed\n"); return(EIO); } @@ -1439,8 +1436,8 @@ 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, + if_printf(ifp, "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 { @@ -1476,8 +1473,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, + if_printf(ifp, "failed to read RID %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1493,8 +1490,8 @@ 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, + if_printf(ifp, "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 { @@ -1586,8 +1583,9 @@ 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, + if_printf(sc->an_ifp, + "failed to write RID 1 %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1598,8 +1596,9 @@ 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, + if_printf(sc->an_ifp, + "failed to write RID 2 %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1623,11 +1622,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); + if_printf(sc->an_ifp, "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); + if_printf(sc->an_ifp, "\t"); bzero(buf,sizeof(buf)); ptr2 = (u_int8_t *)<v->an_val; @@ -1642,7 +1641,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); + if_printf(sc->an_ifp, "\t"); bzero(buf,sizeof(buf)); } } @@ -1669,7 +1668,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); + if_printf(sc->an_ifp, "invalid data path: %x\n", chan); return(EIO); } @@ -1743,8 +1742,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); + if_printf(sc->an_ifp, "failed to allocate %d bytes on NIC\n", + len); return(ENOMEM); } @@ -1863,7 +1862,7 @@ an_setdef(struct an_softc *sc, struct an } break; default: - printf("an%d: unknown RID: %x\n", sc->an_unit, areq->an_type); + if_printf(ifp, "unknown RID: %x\n", areq->an_type); return; } @@ -2653,8 +2652,7 @@ 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); + if_printf(ifp, "tx buffer allocation failed\n"); AN_UNLOCK(sc); return; } @@ -2695,7 +2693,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); + if_printf(ifp, "failed to set ssid list\n"); AN_UNLOCK(sc); return; } @@ -2704,7 +2702,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); + if_printf(ifp, "failed to set AP list\n"); AN_UNLOCK(sc); return; } @@ -2713,14 +2711,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); + if_printf(ifp, "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); + if_printf(ifp, "failed to enable MAC\n"); AN_UNLOCK(sc); return; } @@ -2827,7 +2825,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); + if_printf(ifp, "xmit failed\n"); AN_INC(idx, AN_TX_RING_CNT); @@ -2976,7 +2974,7 @@ an_watchdog(struct ifnet *ifp) return; } - printf("an%d: device timeout\n", sc->an_unit); + if_printf(ifp, "device timeout\n"); an_reset(sc); if (sc->mpi350) @@ -3127,7 +3125,7 @@ an_cache_store(struct an_softc *sc, stru } #ifdef SIGDEBUG - printf("an: q value %x (MSB=0x%x, LSB=0x%x) \n", + if_printf(sc->an_ifp, "q value %x (MSB=0x%x, LSB=0x%x) \n", rx_rssi & 0xffff, rx_rssi >> 8, rx_rssi & 0xff); #endif @@ -3567,8 +3565,7 @@ 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); + if_printf(ifp, "Waitbusy hang b4 RESET =%d\n", status); AN_UNLOCK(sc); return -EBUSY; } @@ -3578,8 +3575,7 @@ cmdreset(struct ifnet *ifp) if (!(status = WaitBusy(ifp, 100))) { - printf("an%d: Waitbusy hang AFTER RESET =%d\n", - sc->an_unit, status); + if_printf(ifp, "Waitbusy hang AFTER RESET =%d\n", status); AN_UNLOCK(sc); return -EBUSY; } @@ -3687,8 +3683,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); + if_printf(ifp, "flash putchar busywait timeout!\n"); return -1; } /* @@ -3774,8 +3769,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); + if_printf(ifp, "flashing not supported on MPI 350 yet\n"); return(-1); } status = l_ioctl->command; @@ -3820,7 +3814,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, + if_printf(ifp, "Buffer to big, %x %x\n", l_ioctl->len, FLASH_SIZE); return -EINVAL; } @@ -3837,8 +3831,7 @@ 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); + if_printf(ifp, "FLASHRESTART returned %d\n", status); return -EIO; } else return 0; Modified: head/sys/dev/an/if_anreg.h ============================================================================== --- head/sys/dev/an/if_anreg.h Fri Nov 6 13:10:12 2009 (r198986) +++ head/sys/dev/an/if_anreg.h Fri Nov 6 14:52:37 2009 (r198987) @@ -442,8 +442,6 @@ struct an_tx_ring_data { struct an_softc { struct ifnet *an_ifp; - int an_unit; - int port_rid; /* resource id for port range */ struct resource* port_res; /* resource for port range */ int mem_rid; /* resource id for memory range */ Modified: head/sys/dev/ixgb/if_ixgb.c ============================================================================== --- head/sys/dev/ixgb/if_ixgb.c Fri Nov 6 13:10:12 2009 (r198986) +++ head/sys/dev/ixgb/if_ixgb.c Fri Nov 6 14:52:37 2009 (r198987) @@ -249,18 +249,17 @@ ixgb_attach(device_t dev) int tsize, rsize; int error = 0; - printf("ixgb%d: %s\n", device_get_unit(dev), ixgb_copyright); + device_printf(dev, "%s\n", ixgb_copyright); INIT_DEBUGOUT("ixgb_attach: begin"); /* Allocate, clear, and link in our adapter structure */ if (!(adapter = device_get_softc(dev))) { - printf("ixgb: adapter structure allocation failed\n"); + device_printf(dev, "adapter structure allocation failed\n"); return (ENOMEM); } bzero(adapter, sizeof(struct adapter)); adapter->dev = dev; adapter->osdep.dev = dev; - adapter->unit = device_get_unit(dev); IXGB_LOCK_INIT(adapter, device_get_nameunit(dev)); if (ixgb_adapter_list != NULL) @@ -299,8 +298,7 @@ ixgb_attach(device_t dev) ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; if (ixgb_allocate_pci_resources(adapter)) { - printf("ixgb%d: Allocation of PCI resources failed\n", - adapter->unit); + device_printf(dev, "Allocation of PCI resources failed\n"); error = ENXIO; goto err_pci; } @@ -309,8 +307,7 @@ ixgb_attach(device_t dev) /* Allocate Transmit Descriptor ring */ if (ixgb_dma_malloc(adapter, tsize, &adapter->txdma, BUS_DMA_NOWAIT)) { - printf("ixgb%d: Unable to allocate TxDescriptor memory\n", - adapter->unit); + device_printf(dev, "Unable to allocate TxDescriptor memory\n"); error = ENOMEM; goto err_tx_desc; } @@ -321,8 +318,7 @@ ixgb_attach(device_t dev) /* Allocate Receive Descriptor ring */ if (ixgb_dma_malloc(adapter, rsize, &adapter->rxdma, BUS_DMA_NOWAIT)) { - printf("ixgb%d: Unable to allocate rx_desc memory\n", - adapter->unit); + device_printf(dev, "Unable to allocate rx_desc memory\n"); error = ENOMEM; goto err_rx_desc; } @@ -330,8 +326,7 @@ ixgb_attach(device_t dev) /* Initialize the hardware */ if (ixgb_hardware_init(adapter)) { - printf("ixgb%d: Unable to initialize the hardware\n", - adapter->unit); + device_printf(dev, "Unable to initialize the hardware\n"); error = EIO; goto err_hw_init; } @@ -628,7 +623,7 @@ ixgb_watchdog(struct ifnet * ifp) ifp->if_timer = IXGB_TX_TIMEOUT; return; } - printf("ixgb%d: watchdog timeout -- resetting\n", adapter->unit); + if_printf(ifp, "watchdog timeout -- resetting\n"); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; @@ -663,23 +658,22 @@ ixgb_init_locked(struct adapter *adapter IXGB_LOCK_ASSERT(adapter); ixgb_stop(adapter); + ifp = adapter->ifp; /* Get the latest mac address, User can use a LAA */ - bcopy(IF_LLADDR(adapter->ifp), adapter->hw.curr_mac_addr, - IXGB_ETH_LENGTH_OF_ADDRESS); + bcopy(IF_LLADDR(ifp), adapter->hw.curr_mac_addr, + IXGB_ETH_LENGTH_OF_ADDRESS); /* Initialize the hardware */ if (ixgb_hardware_init(adapter)) { - printf("ixgb%d: Unable to initialize the hardware\n", - adapter->unit); + if_printf(ifp, "Unable to initialize the hardware\n"); return; } ixgb_enable_vlans(adapter); /* Prepare transmit descriptors and buffers */ if (ixgb_setup_transmit_structures(adapter)) { - printf("ixgb%d: Could not setup transmit structures\n", - adapter->unit); + if_printf(ifp, "Could not setup transmit structures\n"); ixgb_stop(adapter); return; } @@ -690,8 +684,7 @@ ixgb_init_locked(struct adapter *adapter /* Prepare receive descriptors and buffers */ if (ixgb_setup_receive_structures(adapter)) { - printf("ixgb%d: Could not setup receive structures\n", - adapter->unit); + if_printf(ifp, "Could not setup receive structures\n"); ixgb_stop(adapter); return; } @@ -959,8 +952,8 @@ ixgb_encap(struct adapter * adapter, str &nsegs, BUS_DMA_NOWAIT); if (error != 0) { adapter->no_tx_dma_setup++; - printf("ixgb%d: ixgb_encap: bus_dmamap_load_mbuf failed; " - "error %u\n", adapter->unit, error); + if_printf(ifp, "ixgb_encap: bus_dmamap_load_mbuf failed; " + "error %u\n", error); bus_dmamap_destroy(adapter->txtag, map); return (error); } @@ -1149,15 +1142,14 @@ ixgb_print_link_status(struct adapter * { if (adapter->hw.link_up) { if (!adapter->link_active) { - printf("ixgb%d: Link is up %d Mbps %s \n", - adapter->unit, + if_printf(adapter->ifp, "Link is up %d Mbps %s \n", 10000, "Full Duplex"); adapter->link_active = 1; } } else { if (adapter->link_active) { - printf("ixgb%d: Link is Down \n", adapter->unit); + if_printf(adapter->ifp, "Link is Down \n"); adapter->link_active = 0; } } @@ -1213,8 +1205,8 @@ ixgb_identify_hardware(struct adapter * adapter->hw.pci_cmd_word = pci_read_config(dev, PCIR_COMMAND, 2); if (!((adapter->hw.pci_cmd_word & PCIM_CMD_BUSMASTEREN) && (adapter->hw.pci_cmd_word & PCIM_CMD_MEMEN))) { - printf("ixgb%d: Memory Access and/or Bus Master bits were not set!\n", - adapter->unit); + device_printf(dev, + "Memory Access and/or Bus Master bits were not set!\n"); adapter->hw.pci_cmd_word |= (PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN); pci_write_config(dev, PCIR_COMMAND, adapter->hw.pci_cmd_word, 2); @@ -1234,7 +1226,8 @@ ixgb_identify_hardware(struct adapter * break; default: INIT_DEBUGOUT1("Unknown device if 0x%x", adapter->hw.device_id); - printf("ixgb%d: unsupported device id 0x%x\n", adapter->unit, adapter->hw.device_id); + device_printf(dev, "unsupported device id 0x%x\n", + adapter->hw.device_id); } return; @@ -1251,8 +1244,7 @@ ixgb_allocate_pci_resources(struct adapt &rid, 0, ~0, 1, RF_ACTIVE); if (!(adapter->res_memory)) { - printf("ixgb%d: Unable to allocate bus resource: memory\n", - adapter->unit); + device_printf(dev, "Unable to allocate bus resource: memory\n"); return (ENXIO); } adapter->osdep.mem_bus_space_tag = @@ -1266,16 +1258,15 @@ ixgb_allocate_pci_resources(struct adapt &rid, 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE); if (!(adapter->res_interrupt)) { - printf("ixgb%d: Unable to allocate bus resource: interrupt\n", - adapter->unit); + device_printf(dev, + "Unable to allocate bus resource: interrupt\n"); return (ENXIO); } if (bus_setup_intr(dev, adapter->res_interrupt, INTR_TYPE_NET | INTR_MPSAFE, NULL, (void (*) (void *))ixgb_intr, adapter, &adapter->int_handler_tag)) { - printf("ixgb%d: Error registering interrupt handler!\n", - adapter->unit); + device_printf(dev, "Error registering interrupt handler!\n"); return (ENXIO); } adapter->hw.back = &adapter->osdep; @@ -1322,13 +1313,12 @@ ixgb_hardware_init(struct adapter * adap /* Make sure we have a good EEPROM before we read from it */ if (!ixgb_validate_eeprom_checksum(&adapter->hw)) { - printf("ixgb%d: The EEPROM Checksum Is Not Valid\n", - adapter->unit); + device_printf(adapter->dev, + "The EEPROM Checksum Is Not Valid\n"); return (EIO); } if (!ixgb_init_hw(&adapter->hw)) { - printf("ixgb%d: Hardware Initialization Failed", - adapter->unit); + device_printf(adapter->dev, "Hardware Initialization Failed"); return (EIO); } @@ -1352,7 +1342,7 @@ ixgb_setup_interface(device_t dev, struc #if __FreeBSD_version >= 502000 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); #else - ifp->if_unit = adapter->unit; + ifp->if_unit = device_get_unit(dev); ifp->if_name = "ixgb"; #endif ifp->if_mtu = ETHERMTU; @@ -1420,8 +1410,10 @@ static int ixgb_dma_malloc(struct adapter * adapter, bus_size_t size, struct ixgb_dma_alloc * dma, int mapflags) { + device_t dev; int r; + dev = adapter->dev; r = bus_dma_tag_create(NULL, /* parent */ PAGE_SIZE, 0, /* alignment, bounds */ BUS_SPACE_MAXADDR, /* lowaddr */ @@ -1437,15 +1429,15 @@ ixgb_dma_malloc(struct adapter * adapter #endif &dma->dma_tag); if (r != 0) { - printf("ixgb%d: ixgb_dma_malloc: bus_dma_tag_create failed; " - "error %u\n", adapter->unit, r); + device_printf(dev, "ixgb_dma_malloc: bus_dma_tag_create failed; " + "error %u\n", r); goto fail_0; } r = bus_dmamem_alloc(dma->dma_tag, (void **)&dma->dma_vaddr, BUS_DMA_NOWAIT, &dma->dma_map); if (r != 0) { - printf("ixgb%d: ixgb_dma_malloc: bus_dmamem_alloc failed; " - "error %u\n", adapter->unit, r); + device_printf(dev, "ixgb_dma_malloc: bus_dmamem_alloc failed; " + "error %u\n", r); goto fail_1; } r = bus_dmamap_load(dma->dma_tag, dma->dma_map, dma->dma_vaddr, @@ -1454,8 +1446,8 @@ ixgb_dma_malloc(struct adapter * adapter &dma->dma_paddr, mapflags | BUS_DMA_NOWAIT); if (r != 0) { - printf("ixgb%d: ixgb_dma_malloc: bus_dmamap_load failed; " - "error %u\n", adapter->unit, r); + device_printf(dev, "ixgb_dma_malloc: bus_dmamap_load failed; " + "error %u\n", r); goto fail_2; } dma->dma_size = size; @@ -1493,8 +1485,8 @@ ixgb_allocate_transmit_structures(struct (struct ixgb_buffer *) malloc(sizeof(struct ixgb_buffer) * adapter->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) { - printf("ixgb%d: Unable to allocate tx_buffer memory\n", - adapter->unit); + device_printf(adapter->dev, + "Unable to allocate tx_buffer memory\n"); return ENOMEM; } bzero(adapter->tx_buffer_area, @@ -1528,7 +1520,7 @@ ixgb_setup_transmit_structures(struct ad NULL, /* lockfuncarg */ #endif &adapter->txtag)) { - printf("ixgb%d: Unable to allocate TX DMA tag\n", adapter->unit); + device_printf(adapter->dev, "Unable to allocate TX DMA tag\n"); return (ENOMEM); } if (ixgb_allocate_transmit_structures(adapter)) @@ -1845,8 +1837,8 @@ ixgb_allocate_receive_structures(struct (struct ixgb_buffer *) malloc(sizeof(struct ixgb_buffer) * adapter->num_rx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) { - printf("ixgb%d: Unable to allocate rx_buffer memory\n", - adapter->unit); + device_printf(adapter->dev, + "Unable to allocate rx_buffer memory\n"); return (ENOMEM); } bzero(adapter->rx_buffer_area, @@ -1867,9 +1859,9 @@ ixgb_allocate_receive_structures(struct #endif &adapter->rxtag); if (error != 0) { - printf("ixgb%d: ixgb_allocate_receive_structures: " + device_printf(adapter->dev, "ixgb_allocate_receive_structures: " "bus_dma_tag_create failed; error %u\n", - adapter->unit, error); + error); goto fail_0; } rx_buffer = adapter->rx_buffer_area; @@ -1877,9 +1869,10 @@ ixgb_allocate_receive_structures(struct error = bus_dmamap_create(adapter->rxtag, BUS_DMA_NOWAIT, &rx_buffer->map); if (error != 0) { - printf("ixgb%d: ixgb_allocate_receive_structures: " + device_printf(adapter->dev, + "ixgb_allocate_receive_structures: " "bus_dmamap_create failed; error %u\n", - adapter->unit, error); + error); goto fail_1; } } @@ -2431,20 +2424,21 @@ ixgb_print_hw_stats(struct adapter * ada char buf_speed[100], buf_type[100]; ixgb_bus_speed bus_speed; ixgb_bus_type bus_type; - int unit = adapter->unit; + device_t dev; + dev = adapter->dev; #ifdef _SV_ - printf("ixgb%d: Packets not Avail = %ld\n", unit, + device_printf(dev, "Packets not Avail = %ld\n", adapter->no_pkts_avail); - printf("ixgb%d: CleanTxInterrupts = %ld\n", unit, + device_printf(dev, "CleanTxInterrupts = %ld\n", adapter->clean_tx_interrupts); - printf("ixgb%d: ICR RXDMT0 = %lld\n", unit, + device_printf(dev, "ICR RXDMT0 = %lld\n", (long long)adapter->sv_stats.icr_rxdmt0); - printf("ixgb%d: ICR RXO = %lld\n", unit, + device_printf(dev, "ICR RXO = %lld\n", (long long)adapter->sv_stats.icr_rxo); - printf("ixgb%d: ICR RXT0 = %lld\n", unit, + device_printf(dev, "ICR RXT0 = %lld\n", (long long)adapter->sv_stats.icr_rxt0); - printf("ixgb%d: ICR TXDW = %lld\n", unit, + device_printf(dev, "ICR TXDW = %lld\n", (long long)adapter->sv_stats.icr_TXDW); #endif /* _SV_ */ @@ -2456,55 +2450,55 @@ ixgb_print_hw_stats(struct adapter * ada bus_speed == ixgb_bus_speed_100 ? "100MHz" : bus_speed == ixgb_bus_speed_133 ? "133MHz" : "UNKNOWN"); - printf("ixgb%d: PCI_Bus_Speed = %s\n", unit, + device_printf(dev, "PCI_Bus_Speed = %s\n", buf_speed); sprintf(buf_type, bus_type == ixgb_bus_type_pci ? "PCI" : bus_type == ixgb_bus_type_pcix ? "PCI-X" : "UNKNOWN"); - printf("ixgb%d: PCI_Bus_Type = %s\n", unit, + device_printf(dev, "PCI_Bus_Type = %s\n", buf_type); - printf("ixgb%d: Tx Descriptors not Avail1 = %ld\n", unit, + device_printf(dev, "Tx Descriptors not Avail1 = %ld\n", adapter->no_tx_desc_avail1); - printf("ixgb%d: Tx Descriptors not Avail2 = %ld\n", unit, + device_printf(dev, "Tx Descriptors not Avail2 = %ld\n", adapter->no_tx_desc_avail2); - printf("ixgb%d: Std Mbuf Failed = %ld\n", unit, + device_printf(dev, "Std Mbuf Failed = %ld\n", adapter->mbuf_alloc_failed); - printf("ixgb%d: Std Cluster Failed = %ld\n", unit, + device_printf(dev, "Std Cluster Failed = %ld\n", adapter->mbuf_cluster_failed); - printf("ixgb%d: Defer count = %lld\n", unit, + device_printf(dev, "Defer count = %lld\n", (long long)adapter->stats.dc); - printf("ixgb%d: Missed Packets = %lld\n", unit, + device_printf(dev, "Missed Packets = %lld\n", (long long)adapter->stats.mpc); - printf("ixgb%d: Receive No Buffers = %lld\n", unit, + device_printf(dev, "Receive No Buffers = %lld\n", (long long)adapter->stats.rnbc); - printf("ixgb%d: Receive length errors = %lld\n", unit, + device_printf(dev, "Receive length errors = %lld\n", (long long)adapter->stats.rlec); - printf("ixgb%d: Crc errors = %lld\n", unit, + device_printf(dev, "Crc errors = %lld\n", (long long)adapter->stats.crcerrs); - printf("ixgb%d: Driver dropped packets = %ld\n", unit, + device_printf(dev, "Driver dropped packets = %ld\n", adapter->dropped_pkts); - printf("ixgb%d: XON Rcvd = %lld\n", unit, + device_printf(dev, "XON Rcvd = %lld\n", (long long)adapter->stats.xonrxc); - printf("ixgb%d: XON Xmtd = %lld\n", unit, + device_printf(dev, "XON Xmtd = %lld\n", (long long)adapter->stats.xontxc); - printf("ixgb%d: XOFF Rcvd = %lld\n", unit, + device_printf(dev, "XOFF Rcvd = %lld\n", (long long)adapter->stats.xoffrxc); - printf("ixgb%d: XOFF Xmtd = %lld\n", unit, + device_printf(dev, "XOFF Xmtd = %lld\n", (long long)adapter->stats.xofftxc); - printf("ixgb%d: Good Packets Rcvd = %lld\n", unit, + device_printf(dev, "Good Packets Rcvd = %lld\n", (long long)adapter->stats.gprcl); - printf("ixgb%d: Good Packets Xmtd = %lld\n", unit, + device_printf(dev, "Good Packets Xmtd = %lld\n", (long long)adapter->stats.gptcl); - printf("ixgb%d: Jumbo frames recvd = %lld\n", unit, + device_printf(dev, "Jumbo frames recvd = %lld\n", (long long)adapter->stats.jprcl); - printf("ixgb%d: Jumbo frames Xmtd = %lld\n", unit, + device_printf(dev, "Jumbo frames Xmtd = %lld\n", (long long)adapter->stats.jptcl); return; Modified: head/sys/dev/ixgb/if_ixgb.h ============================================================================== --- head/sys/dev/ixgb/if_ixgb.h Fri Nov 6 13:10:12 2009 (r198986) +++ head/sys/dev/ixgb/if_ixgb.h Fri Nov 6 14:52:37 2009 (r198987) @@ -284,7 +284,6 @@ struct adapter { struct ifmedia media; struct callout timer; int io_rid; - u_int8_t unit; struct mtx mtx; /* Info about the board itself */ Modified: head/sys/dev/vge/if_vge.c ============================================================================== --- head/sys/dev/vge/if_vge.c Fri Nov 6 13:10:12 2009 (r198986) +++ head/sys/dev/vge/if_vge.c Fri Nov 6 14:52:37 2009 (r198987) @@ -967,8 +967,6 @@ vge_attach(dev) */ vge_read_eeprom(sc, (caddr_t)eaddr, VGE_EE_EADDR, 3, 0); - sc->vge_unit = unit; - /* * Allocate the parent bus DMA tag appropriate for PCI. */ @@ -993,7 +991,7 @@ vge_attach(dev) ifp = sc->vge_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - printf("vge%d: can not if_alloc()\n", sc->vge_unit); + device_printf(dev, "can not if_alloc()\n"); error = ENOSPC; goto fail; } @@ -1001,7 +999,7 @@ vge_attach(dev) /* Do MII setup */ if (mii_phy_probe(dev, &sc->vge_miibus, vge_ifmedia_upd, vge_ifmedia_sts)) { - printf("vge%d: MII without any phy!\n", sc->vge_unit); + device_printf(dev, "MII without any phy!\n"); error = ENXIO; goto fail; } @@ -1736,8 +1734,7 @@ vge_encap(sc, m_head, idx) m_head, vge_dma_map_tx_desc, &arg, BUS_DMA_NOWAIT); if (error && error != EFBIG) { - printf("vge%d: can't map mbuf (error %d)\n", - sc->vge_unit, error); + if_printf(sc->vge_ifp, "can't map mbuf (error %d)\n", error); return (ENOBUFS); } @@ -1758,8 +1755,8 @@ vge_encap(sc, m_head, idx) error = bus_dmamap_load_mbuf(sc->vge_ldata.vge_mtag, map, m_head, vge_dma_map_tx_desc, &arg, BUS_DMA_NOWAIT); if (error) { - printf("vge%d: can't map mbuf (error %d)\n", - sc->vge_unit, error); + if_printf(sc->vge_ifp, "can't map mbuf (error %d)\n", + error); return (EFBIG); } } @@ -2254,7 +2251,7 @@ vge_watchdog(ifp) sc = ifp->if_softc; VGE_LOCK(sc); - printf("vge%d: watchdog timeout\n", sc->vge_unit); + if_printf(ifp, "watchdog timeout\n"); ifp->if_oerrors++; vge_txeof(sc); Modified: head/sys/dev/vge/if_vgevar.h ============================================================================== --- head/sys/dev/vge/if_vgevar.h Fri Nov 6 13:10:12 2009 (r198986) +++ head/sys/dev/vge/if_vgevar.h Fri Nov 6 14:52:37 2009 (r198987) @@ -108,7 +108,6 @@ struct vge_softc { device_t vge_miibus; bus_dma_tag_t vge_parent_tag; bus_dma_tag_t vge_tag; - u_int8_t vge_unit; /* interface number */ u_int8_t vge_type; int vge_if_flags; int vge_rx_consumed;