mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
- Replace printf() with device_printf().
- Separate fc->dev (i.e. fwohci0) and fc->bdev (i.e. firewire0). - Remove unused firewirebusreg.h. - Reduce size of descriptor block for asynchronous transmit and check the number of descriptor when copying from mbuf. - Skip mbuf whose length is zero. NFS seems passing such mbuf and some chips generates unrecoverable error.
This commit is contained in:
parent
33161c7a6e
commit
d6105b602c
5 changed files with 37 additions and 64 deletions
|
|
@ -369,8 +369,8 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer)
|
|||
return EINVAL;
|
||||
}
|
||||
if(!(xferq->queued < xferq->maxq)){
|
||||
printf("%s:Discard a packet (queued=%d)\n",
|
||||
device_get_nameunit(fc->dev), xferq->queued);
|
||||
device_printf(fc->bdev, "Discard a packet (queued=%d)\n",
|
||||
xferq->queued);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -494,7 +494,6 @@ firewire_attach( device_t dev )
|
|||
|
||||
fc = (struct firewire_comm *)device_get_softc(pa);
|
||||
sc->fc = fc;
|
||||
sc->fc->dev = dev;
|
||||
|
||||
unitmask = UNIT2MIN(device_get_unit(dev));
|
||||
|
||||
|
|
@ -1163,7 +1162,7 @@ void fw_sidrcv(struct firewire_comm* fc, caddr_t buf, u_int len, u_int off)
|
|||
self_id++;
|
||||
fc->topology_map->self_id_count ++;
|
||||
}
|
||||
printf("%s: %d nodes", device_get_nameunit(fc->dev), fc->max_node + 1);
|
||||
device_printf(fc->bdev, "%d nodes", fc->max_node + 1);
|
||||
/* CRC */
|
||||
fc->topology_map->crc = fw_crc16(
|
||||
(u_int32_t *)&fc->topology_map->generation,
|
||||
|
|
@ -1206,7 +1205,8 @@ void fw_sidrcv(struct firewire_comm* fc, caddr_t buf, u_int len, u_int off)
|
|||
}
|
||||
}else{
|
||||
fc->status = FWBUSMGRDONE;
|
||||
printf("%s: BMR = %x\n", device_get_nameunit(fc->dev), CSRARC(fc, BUS_MGR_ID));
|
||||
device_printf(fc->bdev, "BMR = %x\n",
|
||||
CSRARC(fc, BUS_MGR_ID));
|
||||
}
|
||||
free(buf, M_DEVBUF);
|
||||
#if 1
|
||||
|
|
@ -1343,7 +1343,7 @@ loop:
|
|||
TAILQ_INSERT_BEFORE(tfwdev, fwdev, link);
|
||||
}
|
||||
|
||||
device_printf(fc->dev, "New %s device ID:%08x%08x\n",
|
||||
device_printf(fc->bdev, "New %s device ID:%08x%08x\n",
|
||||
linkspeed[fwdev->speed],
|
||||
fc->ongoeui.hi, fc->ongoeui.lo);
|
||||
|
||||
|
|
@ -1643,7 +1643,7 @@ fw_attach_dev(struct firewire_comm *fc)
|
|||
continue;
|
||||
fwdev->maxrec = (fwdev->csrrom[2] >> 12) & 0xf;
|
||||
|
||||
device_printf(fc->dev, "Device ");
|
||||
device_printf(fc->bdev, "Device ");
|
||||
switch(fwdev->spec){
|
||||
case CSRVAL_ANSIT10:
|
||||
switch(fwdev->ver){
|
||||
|
|
@ -1913,8 +1913,8 @@ fw_rcv(struct firewire_comm* fc, caddr_t buf, u_int len, u_int sub, u_int off, u
|
|||
case FWACT_CH:
|
||||
if(fc->ir[bind->xfer->sub]->queued >=
|
||||
fc->ir[bind->xfer->sub]->maxq){
|
||||
printf("%s:Discard a packet %x %d\n",
|
||||
device_get_nameunit(fc->dev),
|
||||
device_printf(fc->bdev,
|
||||
"Discard a packet %x %d\n",
|
||||
bind->xfer->sub,
|
||||
fc->ir[bind->xfer->sub]->queued);
|
||||
goto err;
|
||||
|
|
@ -2013,8 +2013,8 @@ fw_try_bmr_callback(struct fw_xfer *xfer)
|
|||
rfp = (struct fw_pkt *)xfer->recv.buf;
|
||||
CSRARC(fc, BUS_MGR_ID)
|
||||
= fc->set_bmr(fc, ntohl(rfp->mode.lres.payload[0]) & 0x3f);
|
||||
printf("%s: new bus manager %d ",
|
||||
device_get_nameunit(fc->dev), CSRARC(fc, BUS_MGR_ID));
|
||||
device_printf(fc->bdev, "new bus manager %d ",
|
||||
CSRARC(fc, BUS_MGR_ID));
|
||||
if((htonl(rfp->mode.lres.payload[0]) & 0x3f) == fc->nodeid){
|
||||
printf("(me)\n");
|
||||
/* If I am bus manager, optimize gapcount */
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the acknowledgement as bellow:
|
||||
*
|
||||
* This product includes software developed by K. Kobayashi and H. Shimokawa
|
||||
*
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
struct firewire_bus{
|
||||
device_t bdev;
|
||||
};
|
||||
|
|
@ -69,7 +69,6 @@
|
|||
#include <vm/pmap.h> /* for vtophys proto */
|
||||
|
||||
#include <dev/firewire/firewire.h>
|
||||
#include <dev/firewire/firewirebusreg.h>
|
||||
#include <dev/firewire/firewirereg.h>
|
||||
#include <dev/firewire/fwohcireg.h>
|
||||
#include <dev/firewire/fwohcivar.h>
|
||||
|
|
@ -601,8 +600,8 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
|
|||
|
||||
sc->arrq.ndesc = 1;
|
||||
sc->arrs.ndesc = 1;
|
||||
sc->atrq.ndesc = 10;
|
||||
sc->atrs.ndesc = 10 / 2;
|
||||
sc->atrq.ndesc = 6; /* equal to maximum of mbuf chains */
|
||||
sc->atrs.ndesc = 6 / 2;
|
||||
|
||||
sc->arrq.ndb = NDB;
|
||||
sc->arrs.ndb = NDB / 2;
|
||||
|
|
@ -719,12 +718,6 @@ fwohci_cyctimer(struct firewire_comm *fc)
|
|||
return(OREAD(sc, OHCI_CYCLETIMER));
|
||||
}
|
||||
|
||||
#define LAST_DB(dbtr, db) do { \
|
||||
struct fwohcidb_tr *_dbtr = (dbtr); \
|
||||
int _cnt = _dbtr->dbcnt; \
|
||||
db = &_dbtr->db[ (_cnt > 2) ? (_cnt -1) : 0]; \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
fwohci_detach(struct fwohci_softc *sc, device_t dev)
|
||||
{
|
||||
|
|
@ -750,6 +743,12 @@ fwohci_detach(struct fwohci_softc *sc, device_t dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define LAST_DB(dbtr, db) do { \
|
||||
struct fwohcidb_tr *_dbtr = (dbtr); \
|
||||
int _cnt = _dbtr->dbcnt; \
|
||||
db = &_dbtr->db[ (_cnt > 2) ? (_cnt -1) : 0]; \
|
||||
} while (0)
|
||||
|
||||
static void
|
||||
fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
|
||||
{
|
||||
|
|
@ -764,6 +763,7 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
|
|||
volatile struct fwohcidb *db;
|
||||
struct mbuf *m;
|
||||
struct tcode_info *info;
|
||||
static int maxdesc=0;
|
||||
|
||||
if(&sc->atrq == dbch){
|
||||
off = OHCI_ATQOFF;
|
||||
|
|
@ -839,18 +839,30 @@ txloop:
|
|||
db_tr->dbcnt++;
|
||||
} else {
|
||||
/* XXX we assume mbuf chain is shorter than ndesc */
|
||||
m = xfer->mbuf;
|
||||
do {
|
||||
for (m = xfer->mbuf; m != NULL; m = m->m_next) {
|
||||
if (m->m_len == 0)
|
||||
/* unrecoverable error could ocurre. */
|
||||
continue;
|
||||
if (db_tr->dbcnt >= dbch->ndesc) {
|
||||
device_printf(sc->fc.dev,
|
||||
"dbch->ndesc is too small"
|
||||
", trancated.\n");
|
||||
break;
|
||||
}
|
||||
db->db.desc.addr
|
||||
= vtophys(mtod(m, caddr_t));
|
||||
db->db.desc.cmd = OHCI_OUTPUT_MORE | m->m_len;
|
||||
db->db.desc.status = 0;
|
||||
db++;
|
||||
db_tr->dbcnt++;
|
||||
m = m->m_next;
|
||||
} while (m != NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxdesc < db_tr->dbcnt) {
|
||||
maxdesc = db_tr->dbcnt;
|
||||
if (bootverbose)
|
||||
device_printf(sc->fc.dev, "maxdesc: %d\n", maxdesc);
|
||||
}
|
||||
/* last db */
|
||||
LAST_DB(db_tr, db);
|
||||
db->db.desc.cmd |= OHCI_OUTPUT_LAST
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
#include <pci/pcireg.h>
|
||||
|
||||
#include <dev/firewire/firewire.h>
|
||||
#include <dev/firewire/firewirebusreg.h>
|
||||
#include <dev/firewire/firewirereg.h>
|
||||
|
||||
#include <dev/firewire/fwohcireg.h>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
KMOD= firewire
|
||||
SRCS = bus_if.h device_if.h pci_if.h \
|
||||
firewire.c firewire.h firewire_phy.h firewirebusreg.h firewirereg.h \
|
||||
firewire.c firewire.h firewire_phy.h firewirereg.h \
|
||||
fwohci.c fwohci_pci.c fwohcireg.h fwohcivar.h \
|
||||
iec13213.h iec68113.h \
|
||||
fwcrom.c fwdev.c fwmem.c fwmem.h
|
||||
|
|
|
|||
Loading…
Reference in a new issue