Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - split the sk_dev
details: https://anonhg.NetBSD.org/src/rev/abd477edf90a
branches: trunk
changeset: 750319:abd477edf90a
user: christos <christos%NetBSD.org@localhost>
date: Thu Dec 24 18:27:31 2009 +0000
description:
- split the sk_dev
- don't program the interrupt mitigation to 0, only to set it to 1000 later.
- don't be verbose when setting the interrupt mitigation during reset, it
messes up the attach line and does not convey useful information.
diffstat:
sys/dev/pci/if_msk.c | 77 +++++++++++++++++++++++++-----------------------
sys/dev/pci/if_mskvar.h | 6 +-
2 files changed, 43 insertions(+), 40 deletions(-)
diffs (truncated from 322 to 300 lines):
diff -r 5d48cb35992e -r abd477edf90a sys/dev/pci/if_msk.c
--- a/sys/dev/pci/if_msk.c Thu Dec 24 16:39:39 2009 +0000
+++ b/sys/dev/pci/if_msk.c Thu Dec 24 18:27:31 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.29 2009/12/14 00:52:04 matt Exp $ */
+/* $NetBSD: if_msk.c,v 1.30 2009/12/24 18:27:31 christos Exp $ */
/* $OpenBSD: if_msk.c,v 1.42 2007/01/17 02:43:02 krw Exp $ */
/*
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.29 2009/12/14 00:52:04 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.30 2009/12/24 18:27:31 christos Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -100,11 +100,11 @@
#include <dev/pci/if_mskvar.h>
int mskc_probe(device_t, cfdata_t, void *);
-void mskc_attach(device_t, device_t self, void *aux);
+void mskc_attach(device_t, device_t, void *);
static bool mskc_suspend(device_t PMF_FN_PROTO);
static bool mskc_resume(device_t PMF_FN_PROTO);
int msk_probe(device_t, cfdata_t, void *);
-void msk_attach(device_t, device_t self, void *aux);
+void msk_attach(device_t, device_t, void *);
int mskcprint(void *, const char *);
int msk_intr(void *);
void msk_intr_yukon(struct sk_if_softc *);
@@ -126,7 +126,7 @@
int msk_init_rx_ring(struct sk_if_softc *);
int msk_init_tx_ring(struct sk_if_softc *);
-void msk_update_int_mod(struct sk_softc *);
+void msk_update_int_mod(struct sk_softc *, int);
int msk_miibus_readreg(device_t, int, int);
void msk_miibus_writereg(device_t, int, int, int);
@@ -244,7 +244,7 @@
}
if (i == SK_TIMEOUT) {
- aprint_error_dev(&sc_if->sk_dev, "phy failed to come ready\n");
+ aprint_error_dev(sc_if->sk_dev, "phy failed to come ready\n");
return (0);
}
@@ -279,7 +279,7 @@
}
if (i == SK_TIMEOUT)
- aprint_error_dev(&sc_if->sk_dev, "phy write timed out\n");
+ aprint_error_dev(sc_if->sk_dev, "phy write timed out\n");
}
void
@@ -414,8 +414,7 @@
struct msk_ring_data *rd = sc_if->sk_rdata;
int i, nexti;
- memset((char *)rd->sk_rx_ring, 0,
- sizeof(struct msk_rx_desc) * MSK_RX_RING_CNT);
+ memset(rd->sk_rx_ring, 0, sizeof(struct msk_rx_desc) * MSK_RX_RING_CNT);
for (i = 0; i < MSK_RX_RING_CNT; i++) {
cd->sk_rx_chain[i].sk_le = &rd->sk_rx_ring[i];
@@ -429,7 +428,7 @@
for (i = 0; i < MSK_RX_RING_CNT; i++) {
if (msk_newbuf(sc_if, i, NULL,
sc_if->sk_cdata.sk_rx_jumbo_map) == ENOBUFS) {
- aprint_error_dev(&sc_if->sk_dev, "failed alloc of %dth mbuf\n", i);
+ aprint_error_dev(sc_if->sk_dev, "failed alloc of %dth mbuf\n", i);
return (ENOBUFS);
}
}
@@ -450,7 +449,7 @@
struct sk_txmap_entry *entry;
int i, nexti;
- memset((char *)sc_if->sk_rdata->sk_tx_ring, 0,
+ memset(sc_if->sk_rdata->sk_tx_ring, 0,
sizeof(struct msk_tx_desc) * MSK_TX_RING_CNT);
SIMPLEQ_INIT(&sc_if->sk_txmap_head);
@@ -722,7 +721,7 @@
}
void
-msk_update_int_mod(struct sk_softc *sc)
+msk_update_int_mod(struct sk_softc *sc, int verbose)
{
u_int32_t imtimer_ticks;
@@ -749,8 +748,9 @@
default:
imtimer_ticks = SK_IMTIMER_TICKS_YUKON;
}
- aprint_verbose_dev(&sc->sk_dev, "interrupt moderation is %d us\n",
- sc->sk_int_mod);
+ if (verbose)
+ aprint_verbose_dev(sc->sk_dev,
+ "interrupt moderation is %d us\n", sc->sk_int_mod);
sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc->sk_int_mod));
sk_win_write_4(sc, SK_IMMR, SK_ISR_TX1_S_EOF|SK_ISR_TX2_S_EOF|
SK_ISR_RX1_EOF|SK_ISR_RX2_EOF);
@@ -902,7 +902,7 @@
}
/* Reset status ring. */
- memset((char *)sc->sk_status_ring, 0,
+ memset(sc->sk_status_ring, 0,
MSK_STATUS_RING_CNT * sizeof(struct msk_status_desc));
bus_dmamap_sync(sc->sc_dmatag, sc->sk_status_map, 0,
sc->sk_status_map->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -940,7 +940,7 @@
sk_win_write_1(sc, SK_Y2_TX_ITIMERCTL, SK_IMCTL_START);
sk_win_write_1(sc, SK_Y2_ISR_ITIMERCTL, SK_IMCTL_START);
- msk_update_int_mod(sc);
+ msk_update_int_mod(sc, 0);
}
int
@@ -987,6 +987,7 @@
int i, rseg;
u_int32_t chunk, val;
+ sc_if->sk_dev = self;
sc_if->sk_port = sa->skc_port;
sc_if->sk_softc = sc;
sc->sk_if[sa->skc_port] = sc_if;
@@ -1081,7 +1082,7 @@
ifp->if_baudrate = 1000000000;
IFQ_SET_MAXLEN(&ifp->if_snd, MSK_TX_RING_CNT - 1);
IFQ_SET_READY(&ifp->if_snd);
- strlcpy(ifp->if_xname, device_xname(&sc_if->sk_dev), IFNAMSIZ);
+ strlcpy(ifp->if_xname, device_xname(sc_if->sk_dev), IFNAMSIZ);
/*
* Do miibus setup.
@@ -1101,7 +1102,7 @@
mii_attach(self, &sc_if->sk_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, MIIF_DOPAUSE|MIIF_FORCEANEG);
if (LIST_FIRST(&sc_if->sk_mii.mii_phys) == NULL) {
- aprint_error_dev(&sc_if->sk_dev, "no PHY found!\n");
+ aprint_error_dev(sc_if->sk_dev, "no PHY found!\n");
ifmedia_add(&sc_if->sk_mii.mii_media, IFM_ETHER|IFM_MANUAL,
0, NULL);
ifmedia_set(&sc_if->sk_mii.mii_media, IFM_ETHER|IFM_MANUAL);
@@ -1124,7 +1125,7 @@
aprint_error_dev(self, "couldn't establish power handler\n");
#if NRND > 0
- rnd_attach_source(&sc->rnd_source, device_xname(&sc->sk_dev),
+ rnd_attach_source(&sc->rnd_source, device_xname(sc->sk_dev),
RND_TYPE_NET, 0);
#endif
@@ -1179,6 +1180,7 @@
DPRINTFN(2, ("begin mskc_attach\n"));
+ sc->sk_dev = self;
/*
* Handle power management nonsense.
*/
@@ -1195,8 +1197,8 @@
irq = pci_conf_read(pc, pa->pa_tag, SK_PCI_INTLINE);
/* Reset the power state. */
- aprint_normal_dev(&sc->sk_dev, "chip is in D%d power mode "
- "-- setting to D0\n",
+ aprint_normal_dev(sc->sk_dev, "chip is in D%d power "
+ "mode -- setting to D0\n",
command & SK_PSTATE_MASK);
command &= 0xFFFFFFFC;
pci_conf_write(pc, pa->pa_tag,
@@ -1284,6 +1286,10 @@
}
sc->sk_status_ring = (struct msk_status_desc *)kva;
+
+ sc->sk_int_mod = SK_IM_DEFAULT;
+ sc->sk_int_mod_pending = 0;
+
/* Reset the adapter. */
msk_reset(sc);
@@ -1410,13 +1416,13 @@
skca.skc_port = SK_PORT_A;
skca.skc_type = sc->sk_type;
skca.skc_rev = sc->sk_rev;
- (void)config_found(&sc->sk_dev, &skca, mskcprint);
+ (void)config_found(sc->sk_dev, &skca, mskcprint);
if (sc->sk_macs > 1) {
skca.skc_port = SK_PORT_B;
skca.skc_type = sc->sk_type;
skca.skc_rev = sc->sk_rev;
- (void)config_found(&sc->sk_dev, &skca, mskcprint);
+ (void)config_found(sc->sk_dev, &skca, mskcprint);
}
/* Turn on the 'driver is loaded' LED. */
@@ -1424,15 +1430,12 @@
/* skc sysctl setup */
- sc->sk_int_mod = SK_IM_DEFAULT;
- sc->sk_int_mod_pending = 0;
-
if ((rc = sysctl_createv(&sc->sk_clog, 0, NULL, &node,
- 0, CTLTYPE_NODE, device_xname(&sc->sk_dev),
+ 0, CTLTYPE_NODE, device_xname(sc->sk_dev),
SYSCTL_DESCR("mskc per-controller controls"),
NULL, 0, NULL, 0, CTL_HW, msk_root_num, CTL_CREATE,
CTL_EOL)) != 0) {
- aprint_normal_dev(&sc->sk_dev, "couldn't create sysctl node\n");
+ aprint_normal_dev(sc->sk_dev, "couldn't create sysctl node\n");
goto fail_6;
}
@@ -1446,7 +1449,7 @@
msk_sysctl_handler, 0, sc,
0, CTL_HW, msk_root_num, sk_nodenum, CTL_CREATE,
CTL_EOL)) != 0) {
- aprint_normal_dev(&sc->sk_dev, "couldn't create int_mod sysctl node\n");
+ aprint_normal_dev(sc->sk_dev, "couldn't create int_mod sysctl node\n");
goto fail_6;
}
@@ -1639,7 +1642,7 @@
if (sc_if->sk_cdata.sk_tx_cons != idx) {
msk_txeof(sc_if, idx);
if (sc_if->sk_cdata.sk_tx_cnt != 0) {
- aprint_error_dev(&sc_if->sk_dev, "watchdog timeout\n");
+ aprint_error_dev(sc_if->sk_dev, "watchdog timeout\n");
ifp->if_oerrors++;
@@ -1963,7 +1966,7 @@
#endif
if (sc->sk_int_mod_pending)
- msk_update_int_mod(sc);
+ msk_update_int_mod(sc, 1);
return claimed;
}
@@ -2162,7 +2165,7 @@
/* Init descriptors */
if (msk_init_rx_ring(sc_if) == ENOBUFS) {
- aprint_error_dev(&sc_if->sk_dev, "initialization failed: no "
+ aprint_error_dev(sc_if->sk_dev, "initialization failed: no "
"memory for rx buffers\n");
msk_stop(ifp,0);
splx(s);
@@ -2170,7 +2173,7 @@
}
if (msk_init_tx_ring(sc_if) == ENOBUFS) {
- aprint_error_dev(&sc_if->sk_dev, "initialization failed: no "
+ aprint_error_dev(sc_if->sk_dev, "initialization failed: no "
"memory for tx buffers\n");
msk_stop(ifp,0);
splx(s);
@@ -2196,8 +2199,8 @@
if (imr != SK_IM_USECS(sc->sk_int_mod)) {
sk_win_write_4(sc, SK_IMTIMERINIT,
SK_IM_USECS(sc->sk_int_mod));
- aprint_verbose_dev(&sc->sk_dev, "interrupt moderation is %d us\n",
- sc->sk_int_mod);
+ aprint_verbose_dev(sc->sk_dev,
+ "yinterrupt moderation is %d us\n", sc->sk_int_mod);
}
/* Initialize prefetch engine. */
@@ -2316,10 +2319,10 @@
#endif
}
-CFATTACH_DECL(mskc, sizeof(struct sk_softc), mskc_probe, mskc_attach,
+CFATTACH_DECL_NEW(mskc, sizeof(struct sk_softc), mskc_probe, mskc_attach,
NULL, NULL);
-CFATTACH_DECL(msk, sizeof(struct sk_if_softc), msk_probe, msk_attach,
+CFATTACH_DECL_NEW(msk, sizeof(struct sk_if_softc), msk_probe, msk_attach,
NULL, NULL);
#ifdef MSK_DEBUG
diff -r 5d48cb35992e -r abd477edf90a sys/dev/pci/if_mskvar.h
--- a/sys/dev/pci/if_mskvar.h Thu Dec 24 16:39:39 2009 +0000
+++ b/sys/dev/pci/if_mskvar.h Thu Dec 24 18:27:31 2009 +0000
@@ -1,5 +1,5 @@
/* $OpenBSD: if_mskvar.h,v 1.3 2006/12/28 16:34:42 kettenis Exp $ */
-/* $NetBSD: if_mskvar.h,v 1.7 2008/06/20 16:45:13 cube Exp $ */
Home |
Main Index |
Thread Index |
Old Index