svn commit: r229421 - stable/9/sys/dev/ti
Pyun YongHyeon
yongari at FreeBSD.org
Tue Jan 3 20:48:28 UTC 2012
Author: yongari
Date: Tue Jan 3 20:48:28 2012
New Revision: 229421
URL: http://svn.freebsd.org/changeset/base/229421
Log:
MFC r227311-227312,227318-227319,227322-227324:
r227311:
Remove ti_unit member variable in softc.
While I'm here use PCIR_BAR macro.
r227312:
o Remove unnecessary controller reinitialization.
o Do not blindly UP controller when MTU is changed. Reinitialize
controller only if driver is running.
o Remove useless ti_stop() in ti_watchdog() since ti_init_locked()
always invokes ti_stop().
r227318:
Track which ring was updated in RX handler and update only modified
ring. This should reduce unnecessary register accesses.
r227319:
Mini ring is not available on Tigon 1 so do not create DMA maps for
mini ring on Tigon 1 to save resources.
r227322:
Show RX buffer allocation failure and do not blindly send alive
message to firmware. Probably the correct way for this error is to
send a TI_CMD_CODE_STACK_DOWN message to firmware and let firmware
handle the rest.
r227323:
If ti_chipinit() fails in ti_stop(), ignore the error and release
all allocated TX/RX buffer resources. If the interface is brought
to up again after the error, we will leak allocated TX/RX buffers.
r227324:
Do not allow changing MTU to be less than the minimum.
Modified:
stable/9/sys/dev/ti/if_ti.c
stable/9/sys/dev/ti/if_tireg.h
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/amd64/include/xen/ (props changed)
stable/9/sys/boot/ (props changed)
stable/9/sys/boot/i386/efi/ (props changed)
stable/9/sys/boot/ia64/efi/ (props changed)
stable/9/sys/boot/ia64/ski/ (props changed)
stable/9/sys/boot/powerpc/boot1.chrp/ (props changed)
stable/9/sys/boot/powerpc/ofw/ (props changed)
stable/9/sys/cddl/contrib/opensolaris/ (props changed)
stable/9/sys/conf/ (props changed)
stable/9/sys/contrib/dev/acpica/ (props changed)
stable/9/sys/contrib/octeon-sdk/ (props changed)
stable/9/sys/contrib/pf/ (props changed)
stable/9/sys/contrib/x86emu/ (props changed)
Modified: stable/9/sys/dev/ti/if_ti.c
==============================================================================
--- stable/9/sys/dev/ti/if_ti.c Tue Jan 3 20:34:52 2012 (r229420)
+++ stable/9/sys/dev/ti/if_ti.c Tue Jan 3 20:48:28 2012 (r229421)
@@ -998,6 +998,11 @@ ti_alloc_dmamaps(struct ti_softc *sc)
&sc->ti_cdata.ti_rx_jumbo_maps[i]))
return (ENOBUFS);
}
+
+ /* Mini ring is not available on Tigon 1. */
+ if (sc->ti_hwrev == TI_HWREV_TIGON)
+ return (0);
+
for (i = 0; i < TI_MINI_RX_RING_CNT; i++) {
if (bus_dmamap_create(sc->ti_mbufrx_dmat, 0,
&sc->ti_cdata.ti_rx_mini_maps[i]))
@@ -2222,7 +2227,6 @@ ti_attach(device_t dev)
u_char eaddr[6];
sc = device_get_softc(dev);
- sc->ti_unit = device_get_unit(dev);
sc->ti_dev = dev;
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
@@ -2244,7 +2248,7 @@ ti_attach(device_t dev)
*/
pci_enable_busmaster(dev);
- rid = TI_PCI_LOMEM;
+ rid = PCIR_BAR(0);
sc->ti_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
@@ -2471,8 +2475,8 @@ ti_attach(device_t dev)
*/
/* Register the device */
- sc->dev = make_dev(&ti_cdevsw, sc->ti_unit, UID_ROOT, GID_OPERATOR,
- 0600, "ti%d", sc->ti_unit);
+ sc->dev = make_dev(&ti_cdevsw, device_get_unit(dev), UID_ROOT,
+ GID_OPERATOR, 0600, "ti%d", device_get_unit(dev));
sc->dev->si_drv1 = sc;
/*
@@ -2563,7 +2567,7 @@ ti_detach(device_t dev)
if (sc->ti_irq)
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
if (sc->ti_res) {
- bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM,
+ bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0),
sc->ti_res);
}
if (ifp)
@@ -2648,15 +2652,17 @@ ti_rxeof(struct ti_softc *sc)
struct ifnet *ifp;
bus_dmamap_t map;
struct ti_cmd_desc cmd;
+ int jumbocnt, minicnt, stdcnt;
TI_LOCK_ASSERT(sc);
ifp = sc->ti_ifp;
+ jumbocnt = minicnt = stdcnt = 0;
while (sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) {
struct ti_rx_desc *cur_rx;
- struct mbuf *m = NULL;
uint32_t rxidx;
+ struct mbuf *m = NULL;
uint16_t vlan_tag = 0;
int have_tag = 0;
@@ -2671,7 +2677,7 @@ ti_rxeof(struct ti_softc *sc)
}
if (cur_rx->ti_flags & TI_BDFLAG_JUMBO_RING) {
-
+ jumbocnt++;
TI_INC(sc->ti_jumbo, TI_JUMBO_RX_RING_CNT);
m = sc->ti_cdata.ti_rx_jumbo_chain[rxidx];
sc->ti_cdata.ti_rx_jumbo_chain[rxidx] = NULL;
@@ -2701,6 +2707,7 @@ ti_rxeof(struct ti_softc *sc)
m_adj(m, cur_rx->ti_len - m->m_pkthdr.len);
#endif /* TI_PRIVATE_JUMBOS */
} else if (cur_rx->ti_flags & TI_BDFLAG_MINI_RING) {
+ minicnt++;
TI_INC(sc->ti_mini, TI_MINI_RX_RING_CNT);
m = sc->ti_cdata.ti_rx_mini_chain[rxidx];
sc->ti_cdata.ti_rx_mini_chain[rxidx] = NULL;
@@ -2720,6 +2727,7 @@ ti_rxeof(struct ti_softc *sc)
}
m->m_len = cur_rx->ti_len;
} else {
+ stdcnt++;
TI_INC(sc->ti_std, TI_STD_RX_RING_CNT);
m = sc->ti_cdata.ti_rx_std_chain[rxidx];
sc->ti_cdata.ti_rx_std_chain[rxidx] = NULL;
@@ -2775,9 +2783,12 @@ ti_rxeof(struct ti_softc *sc)
CSR_WRITE_4(sc, TI_GCR_RXRETURNCONS_IDX,
sc->ti_rx_saved_considx);
- TI_UPDATE_STDPROD(sc, sc->ti_std);
- TI_UPDATE_MINIPROD(sc, sc->ti_mini);
- TI_UPDATE_JUMBOPROD(sc, sc->ti_jumbo);
+ if (stdcnt > 0)
+ TI_UPDATE_STDPROD(sc, sc->ti_std);
+ if (minicnt > 0)
+ TI_UPDATE_MINIPROD(sc, sc->ti_mini);
+ if (jumbocnt > 0)
+ TI_UPDATE_JUMBOPROD(sc, sc->ti_jumbo);
}
static void
@@ -3092,6 +3103,9 @@ ti_init_locked(void *xsc)
{
struct ti_softc *sc = xsc;
+ if (sc->ti_ifp->if_drv_flags & IFF_DRV_RUNNING)
+ return;
+
/* Cancel pending I/O and flush buffers. */
ti_stop(sc);
@@ -3115,7 +3129,7 @@ static void ti_init2(struct ti_softc *sc
ifp = sc->ti_ifp;
/* Specify MTU and interface index. */
- CSR_WRITE_4(sc, TI_GCR_IFINDEX, sc->ti_unit);
+ CSR_WRITE_4(sc, TI_GCR_IFINDEX, device_get_unit(sc->ti_dev));
CSR_WRITE_4(sc, TI_GCR_IFMTU, ifp->if_mtu +
ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
TI_DO_CMD(TI_CMD_UPDATE_GENCOM, 0, 0);
@@ -3146,18 +3160,34 @@ static void ti_init2(struct ti_softc *sc
}
/* Init RX ring. */
- ti_init_rx_ring_std(sc);
+ if (ti_init_rx_ring_std(sc) != 0) {
+ /* XXX */
+ device_printf(sc->ti_dev, "no memory for std Rx buffers.\n");
+ return;
+ }
/* Init jumbo RX ring. */
- if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
- ti_init_rx_ring_jumbo(sc);
+ if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN)) {
+ if (ti_init_rx_ring_jumbo(sc) != 0) {
+ /* XXX */
+ device_printf(sc->ti_dev,
+ "no memory for jumbo Rx buffers.\n");
+ return;
+ }
+ }
/*
* If this is a Tigon 2, we can also configure the
* mini ring.
*/
- if (sc->ti_hwrev == TI_HWREV_TIGON_II)
- ti_init_rx_ring_mini(sc);
+ if (sc->ti_hwrev == TI_HWREV_TIGON_II) {
+ if (ti_init_rx_ring_mini(sc) != 0) {
+ /* XXX */
+ device_printf(sc->ti_dev,
+ "no memory for mini Rx buffers.\n");
+ return;
+ }
+ }
CSR_WRITE_4(sc, TI_GCR_RXRETURNCONS_IDX, 0);
sc->ti_rx_saved_considx = 0;
@@ -3366,11 +3396,14 @@ ti_ioctl(struct ifnet *ifp, u_long comma
switch (command) {
case SIOCSIFMTU:
TI_LOCK(sc);
- if (ifr->ifr_mtu > TI_JUMBO_MTU)
+ if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > TI_JUMBO_MTU)
error = EINVAL;
else {
ifp->if_mtu = ifr->ifr_mtu;
- ti_init_locked(sc);
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ ti_init_locked(sc);
+ }
}
TI_UNLOCK(sc);
break;
@@ -3784,7 +3817,7 @@ ti_watchdog(void *arg)
ifp = sc->ti_ifp;
if_printf(ifp, "watchdog timeout -- resetting\n");
- ti_stop(sc);
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
ti_init_locked(sc);
ifp->if_oerrors++;
@@ -3812,11 +3845,11 @@ ti_stop(struct ti_softc *sc)
TI_DO_CMD(TI_CMD_HOST_STATE, TI_CMD_CODE_STACK_DOWN, 0);
/* Halt and reinitialize. */
- if (ti_chipinit(sc) != 0)
- return;
- ti_mem_zero(sc, 0x2000, 0x100000 - 0x2000);
- if (ti_chipinit(sc) != 0)
- return;
+ if (ti_chipinit(sc) == 0) {
+ ti_mem_zero(sc, 0x2000, 0x100000 - 0x2000);
+ /* XXX ignore init errors. */
+ ti_chipinit(sc);
+ }
/* Free the RX lists. */
ti_free_rx_ring_std(sc);
Modified: stable/9/sys/dev/ti/if_tireg.h
==============================================================================
--- stable/9/sys/dev/ti/if_tireg.h Tue Jan 3 20:34:52 2012 (r229420)
+++ stable/9/sys/dev/ti/if_tireg.h Tue Jan 3 20:48:28 2012 (r229421)
@@ -1000,7 +1000,6 @@ struct ti_softc {
struct resource *ti_irq;
struct resource *ti_res;
struct ifmedia ifmedia; /* media info */
- uint8_t ti_unit; /* interface number */
uint8_t ti_hwrev; /* Tigon rev (1 or 2) */
uint8_t ti_copper; /* 1000baseTX card */
uint8_t ti_linkstat; /* Link state */
More information about the svn-src-stable-9
mailing list