MFp4: FireWire

* all
- s/__FUNCTION__/__func__/.
	Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>
- Compatibility for RELENG_4 and DragonFly.

* firewire
- Timestamp just before queuing.
- Retry bus probe if it fails.
- Use device_printf() for debug message.
- Invalidiate CROM while update.
- Don't process minimum/invalid CROM.

* sbp
- Add ORB_SHORTAGE flag.
- Add sbp.tags tunable.
- Revive doorbell support. It's not enabled by default.
This commit is contained in:
Hidetoshi Shimokawa 2004-03-26 23:17:10 +00:00
parent 2754e7333e
commit 10d3ed6459
13 changed files with 451 additions and 245 deletions

View File

@ -44,18 +44,26 @@
#include <sys/conf.h>
#include <sys/sysctl.h>
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#include <machine/clock.h> /* for DELAY() */
#endif
#include <sys/bus.h> /* used by smbus and newbus */
#include <machine/bus.h>
#ifdef __DragonFly__
#include "firewire.h"
#include "firewirereg.h"
#include "fwmem.h"
#include "iec13213.h"
#include "iec68113.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwmem.h>
#include <dev/firewire/iec13213.h>
#include <dev/firewire/iec68113.h>
#endif
struct crom_src_buf {
struct crom_src src;
@ -238,7 +246,6 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer)
return EINVAL;
}
microtime(&xfer->tv);
if (info->flag & FWTI_TLABEL) {
if((tl = fw_get_tlabel(fc, xfer)) == -1 )
return EIO;
@ -301,6 +308,7 @@ fw_asystart(struct fw_xfer *xfer)
return;
}
#endif
microtime(&xfer->tv);
s = splfw();
xfer->state = FWXF_INQ;
STAILQ_INSERT_TAIL(&xfer->q->q, xfer, link);
@ -633,8 +641,13 @@ fw_reset_crom(struct firewire_comm *fc)
crom_add_entry(root, CSRKEY_NCAP, 0x0083c0); /* XXX */
/* private company_id */
crom_add_entry(root, CSRKEY_VENDOR, CSRVAL_VENDOR_PRIVATE);
#ifdef __DragonFly__
crom_add_simple_text(src, root, &buf->vendor, "DragonFly Project");
crom_add_entry(root, CSRKEY_HW, __DragonFly_cc_version);
#else
crom_add_simple_text(src, root, &buf->vendor, "FreeBSD Project");
crom_add_entry(root, CSRKEY_HW, __FreeBSD_version);
#endif
crom_add_simple_text(src, root, &buf->hw, hostname);
}
@ -839,7 +852,7 @@ fw_bindadd(struct firewire_comm *fc, struct fw_bind *fwb)
struct fw_bind *tfw, *prev = NULL;
if (fwb->start > fwb->end) {
printf("%s: invalid range\n", __FUNCTION__);
printf("%s: invalid range\n", __func__);
return EINVAL;
}
@ -857,7 +870,7 @@ fw_bindadd(struct firewire_comm *fc, struct fw_bind *fwb)
goto out;
}
printf("%s: bind failed\n", __FUNCTION__);
printf("%s: bind failed\n", __func__);
return (EBUSY);
out:
@ -885,7 +898,7 @@ fw_bindremove(struct firewire_comm *fc, struct fw_bind *fwb)
goto found;
}
printf("%s: no such bind\n", __FUNCTION__);
printf("%s: no such bind\n", __func__);
splx(s);
return (1);
found:
@ -1049,7 +1062,7 @@ void
fw_xfer_free_buf( struct fw_xfer* xfer)
{
if (xfer == NULL) {
printf("%s: xfer == NULL\n", __FUNCTION__);
printf("%s: xfer == NULL\n", __func__);
return;
}
fw_xfer_unload(xfer);
@ -1066,7 +1079,7 @@ void
fw_xfer_free( struct fw_xfer* xfer)
{
if (xfer == NULL) {
printf("%s: xfer == NULL\n", __FUNCTION__);
printf("%s: xfer == NULL\n", __func__);
return;
}
fw_xfer_unload(xfer);
@ -1471,8 +1484,13 @@ fw_bus_explore_callback(struct fw_xfer *xfer)
fc->ongonode, fc->ongoaddr);
if(xfer->resp != 0){
printf("node%d: resp=%d addr=0x%x\n",
fc->ongonode, xfer->resp, fc->ongoaddr);
device_printf(fc->bdev,
"bus_explore node=%d addr=0x%x resp=%d retry=%d\n",
fc->ongonode, fc->ongoaddr, xfer->resp, xfer->retry);
if (xfer->retry < fc->max_asyretry) {
fw_asystart(xfer);
return;
}
goto errnode;
}
@ -1591,8 +1609,11 @@ fw_bus_explore_callback(struct fw_xfer *xfer)
return;
errnode:
fc->retry_count++;
if (fc->ongodev != NULL)
if (fc->ongodev != NULL) {
fc->ongodev->status = FWDEVINVAL;
/* Invalidate ROM */
fc->ongodev->csrrom[0] = 0;
}
nextnode:
fw_xfer_free( xfer);
fc->ongonode++;
@ -1651,7 +1672,8 @@ fw_attach_dev(struct firewire_comm *fc)
free(devlistp, M_TEMP);
if (fc->retry_count > 0) {
printf("probe failed for %d node\n", fc->retry_count);
device_printf(fc->bdev, "bus_explore failed for %d nodes\n",
fc->retry_count);
#if 0
callout_reset(&fc->retry_probe_callout, hz*2,
(void *)fc->ibr, (void *)fc);
@ -1838,10 +1860,10 @@ fw_rcv(struct fw_rcv_buf *rb)
fp->mode.rreqq.dest_lo);
if(bind == NULL){
printf("Unknown service addr 0x%04x:0x%08x %s(%x)"
#if __FreeBSD_version >= 500000
" src=0x%x data=%x\n",
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
" src=0x%x data=%lx\n",
#else
" src=0x%x data=%x\n",
#endif
fp->mode.wreqq.dest_hi, fp->mode.wreqq.dest_lo,
tcode_str[tcode], tcode,
@ -1960,10 +1982,10 @@ fw_rcv(struct fw_rcv_buf *rb)
STAILQ_INSERT_TAIL(&xferq->q, rb->xfer, link);
splx(s);
sc = device_get_softc(rb->fc->bdev);
#if __FreeBSD_version >= 500000
if (SEL_WAITING(&xferq->rsel))
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
if (&xferq->rsel.si_pid != 0)
#else
if (SEL_WAITING(&xferq->rsel))
#endif
selwakeuppri(&xferq->rsel, FWPRI);
if (xferq->flag & FWXFERQ_WAKEUP) {
@ -2211,19 +2233,19 @@ static int
fw_modevent(module_t mode, int type, void *data)
{
int err = 0;
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
static eventhandler_tag fwdev_ehtag = NULL;
#endif
switch (type) {
case MOD_LOAD:
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
fwdev_ehtag = EVENTHANDLER_REGISTER(dev_clone,
fwdev_clone, 0, 1000);
#endif
break;
case MOD_UNLOAD:
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
if (fwdev_ehtag != NULL)
EVENTHANDLER_DEREGISTER(dev_clone, fwdev_ehtag);
#endif
@ -2235,5 +2257,8 @@ fw_modevent(module_t mode, int type, void *data)
}
#ifdef __DragonFly__
DECLARE_DUMMY_MODULE(firewire);
#endif
DRIVER_MODULE(firewire,fwohci,firewire_driver,firewire_devclass,fw_modevent,0);
MODULE_VERSION(firewire, 1);

View File

@ -411,7 +411,7 @@ struct fw_crom_buf {
#define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8))
#define unit2minor(x) (((x) & 0xff) | (((x) << 8) & ~0xffff))
#endif

View File

@ -35,7 +35,10 @@
*
*/
#if __FreeBSD_version >= 500000
#ifdef __DragonFly__
typedef d_thread_t fw_proc;
#include <sys/select.h>
#elif __FreeBSD_version >= 500000
typedef struct thread fw_proc;
#include <sys/selinfo.h>
#else
@ -68,7 +71,7 @@ struct fw_device{
};
struct firewire_softc {
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
dev_t dev;
#endif
struct firewire_comm *fc;
@ -305,15 +308,19 @@ void fwdev_clone (void *, char *, int, dev_t *);
extern int firewire_debug;
extern devclass_t firewire_devclass;
#define FWPRI ((PZERO+8)|PCATCH)
#if __FreeBSD_version >= 500000
#define CALLOUT_INIT(x) callout_init(x, 0 /* mpsafe */)
#ifdef __DragonFly__
#define FWPRI PCATCH
#else
#define CALLOUT_INIT(x) callout_init(x)
#define FWPRI ((PZERO+8)|PCATCH)
#endif
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#define CALLOUT_INIT(x) callout_init(x)
#else
#define CALLOUT_INIT(x) callout_init(x, 0 /* mpsafe */)
#endif
#if defined(__DragonFly__) || __FreeBSD_version < 500000
/* compatibility shim for 4.X */
#define bio buf
#define bio_bcount b_bcount

View File

@ -32,8 +32,10 @@
* SUCH DAMAGE.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#include <sys/param.h>
#if defined(_KERNEL) || defined(TEST)
@ -50,8 +52,14 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#endif
#ifdef __DragonFly__
#include "firewire.h"
#include "iec13213.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/iec13213.h>
#endif
#define MAX_ROM (1024 - sizeof(u_int32_t) * 5)
#define CROM_END(cc) ((vm_offset_t)(cc)->stack[0].dir + MAX_ROM - 1)
@ -62,9 +70,10 @@ crom_init_context(struct crom_context *cc, u_int32_t *p)
struct csrhdr *hdr;
hdr = (struct csrhdr *)p;
if (hdr->info_len == 1) {
/* minimum ROM */
if (hdr->info_len <= 1) {
/* minimum or invalid ROM */
cc->depth = -1;
return;
}
p += 1 + hdr->info_len;
@ -436,7 +445,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
len = strlen(buf);
if (len > MAX_TEXT) {
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("text(%d) trancated to %d.\n", len, MAX_TEXT);
#else
printf("text(%d) trancated to %td.\n", len, MAX_TEXT);
@ -574,9 +583,15 @@ main () {
/* private company_id */
crom_add_entry(&root, CSRKEY_VENDOR, 0xacde48);
#ifdef __DragonFly__
crom_add_simple_text(&src, &root, &text1, "DragonFly");
crom_add_entry(&root, CSRKEY_HW, __DragonFly_cc_version);
crom_add_simple_text(&src, &root, &text2, "DragonFly-1");
#else
crom_add_simple_text(&src, &root, &text1, "FreeBSD");
crom_add_entry(&root, CSRKEY_HW, __FreeBSD_version);
crom_add_simple_text(&src, &root, &text2, "FreeBSD-5");
#endif
/* SBP unit directory */
crom_add_chunk(&src, &root, &unit1, CROM_UDIR);

View File

@ -39,7 +39,7 @@
#include <sys/systm.h>
#include <sys/types.h>
#include <sys/mbuf.h>
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#include <sys/buf.h>
#else
#include <sys/bio.h>
@ -56,11 +56,19 @@
#include <sys/ioccom.h>
#ifdef __DragonFly__
#include "firewire.h"
#include "firewirereg.h"
#include "fwdma.h"
#include "fwmem.h"
#include "iec68113.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwdma.h>
#include <dev/firewire/fwmem.h>
#include <dev/firewire/iec68113.h>
#endif
#define FWNODE_INVAL 0xffff
@ -74,7 +82,12 @@ static d_mmap_t fw_mmap;
static d_strategy_t fw_strategy;
struct cdevsw firewire_cdevsw = {
#if __FreeBSD_version >= 500104
#ifdef __DragonFly__
#define CDEV_MAJOR 127
"fw", CDEV_MAJOR, D_MEM, NULL, 0,
fw_open, fw_close, fw_read, fw_write, fw_ioctl,
fw_poll, fw_mmap, fw_strategy, nodump, nopsize,
#elif __FreeBSD_version >= 500104
.d_version = D_VERSION,
.d_open = fw_open,
.d_close = fw_close,
@ -87,6 +100,7 @@ struct cdevsw firewire_cdevsw = {
.d_name = "fw",
.d_flags = D_MEM | D_NEEDGIANT
#else
#define CDEV_MAJOR 127
fw_open, fw_close, fw_read, fw_write, fw_ioctl,
fw_poll, fw_mmap, fw_strategy, "fw", CDEV_MAJOR,
nodump, nopsize, D_MEM, -1
@ -174,7 +188,7 @@ fw_open (dev_t dev, int flags, int fmt, fw_proc *td)
if (dev->si_drv1 != NULL)
return (EBUSY);
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
if ((dev->si_flags & SI_NAMED) == 0) {
int unit = DEV2UNIT(dev);
int sub = DEV2SUB(dev);
@ -737,7 +751,7 @@ fw_poll(dev_t dev, int events, fw_proc *td)
}
static int
#if __FreeBSD_version < 500102
#if defined(__DragonFly__) || __FreeBSD_version < 500102
fw_mmap (dev_t dev, vm_offset_t offset, int nproto)
#else
fw_mmap (dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nproto)
@ -747,7 +761,7 @@ fw_mmap (dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nproto)
int unit = DEV2UNIT(dev);
if (DEV_FWMEM(dev))
#if __FreeBSD_version < 500102
#if defined(__DragonFly__) || __FreeBSD_version < 500102
return fwmem_mmap(dev, offset, nproto);
#else
return fwmem_mmap(dev, offset, paddr, nproto);
@ -780,7 +794,9 @@ fwdev_makedev(struct firewire_softc *sc)
{
int err = 0;
#if __FreeBSD_version >= 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
cdevsw_add(&firewire_cdevsw);
#else
dev_t d;
int unit;
@ -795,8 +811,6 @@ fwdev_makedev(struct firewire_softc *sc)
dev_depends(sc->dev, d);
make_dev_alias(sc->dev, "fw%d", unit);
make_dev_alias(d, "fwmem%d", unit);
#else
cdevsw_add(&firewire_cdevsw);
#endif
return (err);
@ -807,15 +821,15 @@ fwdev_destroydev(struct firewire_softc *sc)
{
int err = 0;
#if __FreeBSD_version >= 500000
destroy_dev(sc->dev);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
cdevsw_remove(&firewire_cdevsw);
#else
destroy_dev(sc->dev);
#endif
return (err);
}
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
#define NDEVTYPE 2
void
fwdev_clone(void *arg, char *name, int namelen, dev_t *dev)

View File

@ -33,14 +33,17 @@
*
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/types.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
#include <sys/lock.h>
#include <sys/mutex.h>
#endif
@ -48,9 +51,15 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <machine/bus.h>
#ifdef __DragonFly__
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
#include <bus/firewire/fwdma.h>
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwdma.h>
#endif
static void
fwdma_map_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
@ -81,7 +90,7 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size,
/*nsegments*/ 1,
/*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT,
/*flags*/ BUS_DMA_ALLOCNOW,
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant,
#endif
@ -179,7 +188,7 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment,
/*nsegments*/ 1,
/*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT,
/*flags*/ BUS_DMA_ALLOCNOW,
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant,
#endif
@ -190,7 +199,7 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment,
}
#if 0
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("malloc_multi: ssize=%d nseg=%d\n", ssize, nseg);
#else
printf("malloc_multi: ssize=%td nseg=%d\n", ssize, nseg);

View File

@ -33,8 +33,10 @@
*
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#include <sys/param.h>
#include <sys/systm.h>
@ -44,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/sysctl.h>
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#include <sys/buf.h>
#else
#include <sys/bio.h>
@ -58,9 +60,15 @@ __FBSDID("$FreeBSD$");
#include <sys/ioccom.h>
#include <sys/fcntl.h>
#ifdef __DragonFly__
#include "firewire.h"
#include "firewirereg.h"
#include "fwmem.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwmem.h>
#endif
static int fwmem_speed=2, fwmem_debug=0;
static struct fw_eui64 fwmem_eui64;
@ -286,7 +294,7 @@ fwmem_open (dev_t dev, int flags, int fmt, fw_proc *td)
fms->refcount = 1;
}
if (fwmem_debug)
printf("%s: refcount=%d\n", __FUNCTION__, fms->refcount);
printf("%s: refcount=%d\n", __func__, fms->refcount);
return (0);
}
@ -299,7 +307,7 @@ fwmem_close (dev_t dev, int flags, int fmt, fw_proc *td)
fms = (struct fwmem_softc *)dev->si_drv1;
fms->refcount --;
if (fwmem_debug)
printf("%s: refcount=%d\n", __FUNCTION__, fms->refcount);
printf("%s: refcount=%d\n", __func__, fms->refcount);
if (fms->refcount < 1) {
free(dev->si_drv1, M_FW);
dev->si_drv1 = NULL;
@ -319,7 +327,7 @@ fwmem_biodone(struct fw_xfer *xfer)
if (bp->bio_error != 0) {
if (fwmem_debug)
printf("%s: err=%d\n", __FUNCTION__, bp->bio_error);
printf("%s: err=%d\n", __func__, bp->bio_error);
bp->bio_flags |= BIO_ERROR;
bp->bio_resid = bp->bio_bcount;
}
@ -389,7 +397,7 @@ fwmem_strategy(struct bio *bp)
splx(s);
if (err != 0) {
if (fwmem_debug)
printf("%s: err=%d\n", __FUNCTION__, err);
printf("%s: err=%d\n", __func__, err);
bp->bio_error = err;
bp->bio_flags |= BIO_ERROR;
bp->bio_resid = bp->bio_bcount;
@ -422,7 +430,7 @@ fwmem_poll (dev_t dev, int events, fw_proc *td)
return EINVAL;
}
int
#if __FreeBSD_version < 500102
#if defined(__DragonFly__) || __FreeBSD_version < 500102
fwmem_mmap (dev_t dev, vm_offset_t offset, int nproto)
#else
fwmem_mmap (dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nproto)

View File

@ -54,16 +54,25 @@
#include <machine/bus.h>
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#include <machine/clock.h> /* for DELAY() */
#endif
#ifdef __DragonFly__
#include "firewire.h"
#include "firewirereg.h"
#include "fwdma.h"
#include "fwohcireg.h"
#include "fwohcivar.h"
#include "firewire_phy.h"
#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwdma.h>
#include <dev/firewire/fwohcireg.h>
#include <dev/firewire/fwohcivar.h>
#include <dev/firewire/firewire_phy.h>
#endif
#undef OHCI_DEBUG
@ -1206,7 +1215,7 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
/*nsegments*/ dbch->ndesc > 3 ? dbch->ndesc - 2 : 1,
/*maxsegsz*/ MAX_REQCOUNT,
/*flags*/ 0,
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant,
#endif
@ -1814,11 +1823,11 @@ fwohci_intr_body(struct fwohci_softc *sc, u_int32_t stat, int count)
#ifndef ACK_ALL
OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_DMA_IR);
#endif
#if __FreeBSD_version >= 500000
irstat = atomic_readandclear_int(&sc->irstat);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
irstat = sc->irstat;
sc->irstat = 0;
#else
irstat = atomic_readandclear_int(&sc->irstat);
#endif
for(i = 0; i < fc->nisodma ; i++){
struct fwohci_dbch *dbch;
@ -1838,11 +1847,11 @@ fwohci_intr_body(struct fwohci_softc *sc, u_int32_t stat, int count)
#ifndef ACK_ALL
OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_DMA_IT);
#endif
#if __FreeBSD_version >= 500000
itstat = atomic_readandclear_int(&sc->itstat);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
itstat = sc->itstat;
sc->itstat = 0;
#else
itstat = atomic_readandclear_int(&sc->itstat);
#endif
for(i = 0; i < fc->nisodma ; i++){
if((itstat & (1 << i)) != 0){
@ -1928,7 +1937,7 @@ fwohci_intr_body(struct fwohci_softc *sc, u_int32_t stat, int count)
}
for (i = 0; i < plen / 4; i ++)
buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i+1]);
#if 1
#if 1 /* XXX needed?? */
/* pending all pre-bus_reset packets */
fwohci_txd(sc, &sc->atrq);
fwohci_txd(sc, &sc->atrs);
@ -2355,12 +2364,12 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db,
res = FWOHCI_DMA_READ(db[i].db.desc.res);
key = cmd & OHCI_KEY_MASK;
stat = res >> OHCI_STATUS_SHIFT;
#if __FreeBSD_version >= 500000
printf("%08jx %s %s %s %s %5d %08x %08x %04x:%04x",
(uintmax_t)db_tr->bus_addr,
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("%08x %s %s %s %s %5d %08x %08x %04x:%04x",
db_tr->bus_addr,
#else
printf("%08jx %s %s %s %s %5d %08x %08x %04x:%04x",
(uintmax_t)db_tr->bus_addr,
#endif
dbcode[(cmd >> 28) & 0xf],
dbkey[(cmd >> 24) & 0x7],

View File

@ -45,16 +45,27 @@
#include <machine/bus.h>
#include <sys/rman.h>
#include <sys/malloc.h>
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
#include <sys/lock.h>
#include <sys/mutex.h>
#endif
#include <machine/resource.h>
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#include <machine/clock.h> /* for DELAY() */
#endif
#ifdef __DragonFly__
#include <bus/pci/pcivar.h>
#include <bus/pci/pcireg.h>
#include "firewire.h"
#include "firewirereg.h"
#include "fwdma.h"
#include "fwohcireg.h"
#include "fwohcivar.h"
#else
#if __FreeBSD_version < 500000
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@ -69,6 +80,7 @@
#include <dev/firewire/fwdma.h>
#include <dev/firewire/fwohcireg.h>
#include <dev/firewire/fwohcivar.h>
#endif
static int fwohci_pci_attach(device_t self);
static int fwohci_pci_detach(device_t self);
@ -184,7 +196,7 @@ fwohci_pci_probe( device_t dev )
return ENXIO;
}
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
static void
fwohci_dummy_intr(void *arg)
{
@ -236,7 +248,7 @@ fwohci_pci_attach(device_t self)
fwohci_softc_t *sc = device_get_softc(self);
int err;
int rid;
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
int intr;
/* For the moment, put in a message stating what is wrong */
intr = pci_read_config(self, PCIR_INTLINE, 1);
@ -254,7 +266,12 @@ fwohci_pci_attach(device_t self)
fwohci_pci_init(self);
rid = PCI_CBMEM;
#if __FreeBSD_version >= 502109
sc->bsr = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE);
#else
sc->bsr = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
0, ~0, 1, RF_ACTIVE);
#endif
if (!sc->bsr) {
device_printf(self, "Could not map memory\n");
return ENXIO;
@ -264,8 +281,13 @@ fwohci_pci_attach(device_t self)
sc->bsh = rman_get_bushandle(sc->bsr);
rid = 0;
#if __FreeBSD_version >= 502109
sc->irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
RF_SHAREABLE | RF_ACTIVE);
#else
sc->irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
RF_SHAREABLE | RF_ACTIVE);
#endif
if (sc->irq_res == NULL) {
device_printf(self, "Could not allocate irq\n");
fwohci_pci_detach(self);
@ -280,7 +302,7 @@ fwohci_pci_attach(device_t self)
INTR_TYPE_NET,
#endif
(driver_intr_t *) fwohci_intr, sc, &sc->ih);
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
/* XXX splcam() should mask this irq for sbp.c*/
err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_CAM,
(driver_intr_t *) fwohci_dummy_intr, sc, &sc->ih_cam);
@ -307,7 +329,7 @@ fwohci_pci_attach(device_t self)
/*nsegments*/0x20,
/*maxsegsz*/0x8000,
/*flags*/BUS_DMA_ALLOCNOW,
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant,
#endif
@ -362,7 +384,7 @@ fwohci_pci_detach(device_t self)
/* XXX or should we panic? */
device_printf(self, "Could not tear down irq, %d\n",
err);
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
bus_teardown_intr(self, sc->irq_res, sc->ih_cam);
bus_teardown_intr(self, sc->irq_res, sc->ih_bio);
#endif
@ -486,7 +508,7 @@ static driver_t fwohci_driver = {
static devclass_t fwohci_devclass;
#ifdef FWOHCI_MODULE
#ifdef FWOHCI_MODULE
MODULE_DEPEND(fwohci, firewire, 1, 1, 1);
#endif
DRIVER_MODULE(fwohci, pci, fwohci_driver, fwohci_devclass, 0, 0);

View File

@ -35,10 +35,10 @@
*
*/
#if __FreeBSD_version >= 500000
#define FWOHCI_TASKQUEUE 1
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#define FWOHCI_TASKQUEUE 0
#else
#define FWOHCI_TASKQUEUE 1
#endif
#if FWOHCI_TASKQUEUE
#include <sys/taskqueue.h>
@ -49,7 +49,7 @@ typedef struct fwohci_softc {
bus_space_tag_t bst;
bus_space_handle_t bsh;
void *ih;
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
void *ih_cam;
void *ih_bio;
#endif

View File

@ -52,11 +52,18 @@
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#ifdef __DragonFly__
#include <net/vlan/if_vlan_var.h>
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
#include "if_fwevar.h"
#else
#include <net/if_vlan_var.h>
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/if_fwevar.h>
#endif
#define FWEDEBUG if (fwedebug) if_printf
#define TX_MAX_QUEUE (FWMAXQUEUE - 1)
@ -195,7 +202,7 @@ fwe_attach(device_t dev)
ifp = &fwe->fwe_if;
ifp->if_softc = &fwe->eth_softc;
#if __FreeBSD_version >= 501113
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
if_initname(ifp, device_get_name(dev), unit);
#else
ifp->if_unit = unit;
@ -210,16 +217,16 @@ fwe_attach(device_t dev)
ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE;
s = splimp();
#if __FreeBSD_version >= 500000
ether_ifattach(ifp, eaddr);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
ether_ifattach(ifp, 1);
#else
ether_ifattach(ifp, eaddr);
#endif
splx(s);
/* Tell the upper layer(s) we support long frames. */
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
ifp->if_capabilities |= IFCAP_VLAN_MTU;
#endif
@ -279,10 +286,10 @@ fwe_detach(device_t dev)
s = splimp();
fwe_stop(fwe);
#if __FreeBSD_version >= 500000
ether_ifdetach(&fwe->fwe_if);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
ether_ifdetach(&fwe->fwe_if, 1);
#else
ether_ifdetach(&fwe->fwe_if);
#endif
splx(s);
@ -345,10 +352,10 @@ fwe_init(void *arg)
xferq->stproc = NULL;
for (i = 0; i < xferq->bnchunk; i ++) {
m =
#if __FreeBSD_version >= 500000
m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
m_getcl(M_WAIT, MT_DATA, M_PKTHDR);
#else
m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);
#endif
xferq->bulkxfer[i].mbuf = m;
if (m != NULL) {
@ -425,7 +432,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
fwe->stream_ch, fwe->dma_ch);
splx(s);
break;
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
default:
#else
case SIOCSIFADDR:
@ -436,7 +443,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = ether_ioctl(ifp, cmd, data);
splx(s);
return (error);
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
default:
return (EINVAL);
#endif
@ -532,11 +539,11 @@ fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp)
if (m == NULL)
break;
STAILQ_REMOVE_HEAD(&fwe->xferlist, link);
#if __FreeBSD_version >= 500000
BPF_MTAP(ifp, m);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
if (ifp->if_bpf != NULL)
bpf_mtap(ifp, m);
#else
BPF_MTAP(ifp, m);
#endif
/* keep ip packet alignment for alpha */
@ -575,7 +582,7 @@ fwe_as_input(struct fw_xferq *xferq)
struct fw_bulkxfer *sxfer;
struct fw_pkt *fp;
u_char *c;
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
struct ether_header *eh;
#endif
@ -608,7 +615,7 @@ fwe_as_input(struct fw_xferq *xferq)
m->m_data += HDR_LEN + ETHER_ALIGN;
c = mtod(m, char *);
#if __FreeBSD_version < 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
eh = (struct ether_header *)c;
m->m_data += sizeof(struct ether_header);
#endif
@ -630,10 +637,10 @@ fwe_as_input(struct fw_xferq *xferq)
c[20], c[21], c[22], c[23]
);
#endif
#if __FreeBSD_version >= 500000
(*ifp->if_input)(ifp, m);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
ether_input(ifp, eh, m);
#else
(*ifp->if_input)(ifp, m);
#endif
ifp->if_ipackets ++;
}
@ -660,6 +667,9 @@ static driver_t fwe_driver = {
};
#ifdef __DragonFly__
DECLARE_DUMMY_MODULE(fwe);
#endif
DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0);
MODULE_VERSION(fwe, 1);
MODULE_DEPEND(fwe, firewire, 1, 1, 1);

View File

@ -39,34 +39,48 @@
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <machine/bus.h>
#include <sys/malloc.h>
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
#include <sys/lock.h>
#include <sys/mutex.h>
#endif
#if __FreeBSD_version < 500106
#if defined(__DragonFly__) || __FreeBSD_version < 500106
#include <sys/devicestat.h> /* for struct devstat */
#endif
#ifdef __DragonFly__
#include <bus/cam/cam.h>
#include <bus/cam/cam_ccb.h>
#include <bus/cam/cam_sim.h>
#include <bus/cam/cam_xpt_sim.h>
#include <bus/cam/cam_debug.h>
#include <bus/cam/cam_periph.h>
#include <bus/cam/scsi/scsi_all.h>
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
#include <bus/firewire/fwdma.h>
#include <bus/firewire/iec13213.h>
#include "sbp.h"
#else
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_sim.h>
#include <cam/cam_xpt_sim.h>
#include <cam/cam_debug.h>
#include <cam/cam_periph.h>
#include <cam/scsi/scsi_all.h>
#include <sys/kernel.h>
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwdma.h>
#include <dev/firewire/iec13213.h>
#include <dev/firewire/sbp.h>
#endif
#define ccb_sdev_ptr spriv_ptr0
#define ccb_sbp_ptr spriv_ptr1
@ -113,6 +127,8 @@ static int sbp_cold = 1;
static int ex_login = 1;
static int login_delay = 1000; /* msec */
static int scan_delay = 500; /* msec */
static int use_doorbell = 0;
static int sbp_tags = 0;
SYSCTL_DECL(_hw_firewire);
SYSCTL_NODE(_hw_firewire, OID_AUTO, sbp, CTLFLAG_RD, 0, "SBP-II Subsystem");
@ -128,12 +144,18 @@ SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RW,
&login_delay, 0, "SBP login delay in msec");
SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RW,
&scan_delay, 0, "SBP scan delay in msec");
SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RW,
&use_doorbell, 0, "SBP use doorbell request");
SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RW, &sbp_tags, 0,
"SBP tagged queuing support");
TUNABLE_INT("hw.firewire.sbp.auto_login", &auto_login);
TUNABLE_INT("hw.firewire.sbp.max_speed", &max_speed);
TUNABLE_INT("hw.firewire.sbp.exclusive_login", &ex_login);
TUNABLE_INT("hw.firewire.sbp.login_delay", &login_delay);
TUNABLE_INT("hw.firewire.sbp.scan_delay", &scan_delay);
TUNABLE_INT("hw.firewire.sbp.use_doorbell", &use_doorbell);
TUNABLE_INT("hw.firewire.sbp.tags", &sbp_tags);
#define NEED_RESPONSE 0
@ -179,6 +201,9 @@ struct sbp_dev{
#define VALID_LUN (1 << 1)
#define ORB_POINTER_ACTIVE (1 << 2)
#define ORB_POINTER_NEED (1 << 3)
#define ORB_DOORBELL_ACTIVE (1 << 4)
#define ORB_DOORBELL_NEED (1 << 5)
#define ORB_SHORTAGE (1 << 6)
u_int16_t flags;
struct cam_path *path;
struct sbp_target *target;
@ -188,6 +213,7 @@ struct sbp_dev{
struct sbp_ocb *ocb;
STAILQ_HEAD(, sbp_ocb) ocbs;
STAILQ_HEAD(, sbp_ocb) free_ocbs;
struct sbp_ocb *last_ocb;
char vendor[32];
char product[32];
char revision[10];
@ -227,6 +253,7 @@ static void sbp_mgm_callback (struct fw_xfer *);
static void sbp_cmd_callback (struct fw_xfer *);
#endif
static void sbp_orb_pointer (struct sbp_dev *, struct sbp_ocb *);
static void sbp_doorbell(struct sbp_dev *);
static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int);
static void sbp_free_ocb (struct sbp_dev *, struct sbp_ocb *);
static void sbp_abort_ocb (struct sbp_ocb *, int);
@ -468,7 +495,7 @@ END_DEBUG
M_SBP, M_NOWAIT | M_ZERO);
if (newluns == NULL) {
printf("%s: realloc failed\n", __FUNCTION__);
printf("%s: realloc failed\n", __func__);
newluns = target->luns;
maxlun = target->num_lun;
}
@ -504,7 +531,7 @@ END_DEBUG
sdev = malloc(sizeof(struct sbp_dev),
M_SBP, M_NOWAIT | M_ZERO);
if (sdev == NULL) {
printf("%s: malloc failed\n", __FUNCTION__);
printf("%s: malloc failed\n", __func__);
goto next;
}
target->luns[lun] = sdev;
@ -526,7 +553,7 @@ END_DEBUG
SBP_DMA_SIZE, &sdev->dma, BUS_DMA_NOWAIT);
if (sdev->dma.v_addr == NULL) {
printf("%s: dma space allocation failed\n",
__FUNCTION__);
__func__);
free(sdev, M_SBP);
target->luns[lun] = NULL;
goto next;
@ -668,7 +695,7 @@ sbp_login(struct sbp_dev *sdev)
if (t.tv_sec >= 0 && t.tv_usec > 0)
ticks = (t.tv_sec * 1000 + t.tv_usec / 1000) * hz / 1000;
SBP_DEBUG(0)
printf("%s: sec = %ld usec = %ld ticks = %d\n", __FUNCTION__,
printf("%s: sec = %ld usec = %ld ticks = %d\n", __func__,
t.tv_sec, t.tv_usec, ticks);
END_DEBUG
callout_reset(&sdev->login_callout, ticks,
@ -1068,11 +1095,11 @@ sbp_agent_reset_callback(struct fw_xfer *xfer)
sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2);
printf("%s\n", __FUNCTION__);
printf("%s\n", __func__);
END_DEBUG
if (xfer->resp != 0) {
sbp_show_sdev_info(sdev, 2);
printf("%s: resp=%d\n", __FUNCTION__, xfer->resp);
printf("%s: resp=%d\n", __func__, xfer->resp);
}
sbp_xfer_free(xfer);
@ -1146,11 +1173,11 @@ sbp_orb_pointer_callback(struct fw_xfer *xfer)
SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2);
printf("%s\n", __FUNCTION__);
printf("%s\n", __func__);
END_DEBUG
if (xfer->resp != 0) {
/* XXX */
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
}
sbp_xfer_free(xfer);
sdev->flags &= ~ORB_POINTER_ACTIVE;
@ -1173,12 +1200,12 @@ sbp_orb_pointer(struct sbp_dev *sdev, struct sbp_ocb *ocb)
struct fw_pkt *fp;
SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2);
printf("%s: 0x%08x\n", __FUNCTION__, (u_int32_t)ocb->bus_addr);
printf("%s: 0x%08x\n", __func__, (u_int32_t)ocb->bus_addr);
END_DEBUG
if ((sdev->flags & ORB_POINTER_ACTIVE) != 0) {
SBP_DEBUG(0)
printf("%s: orb pointer active\n", __FUNCTION__);
printf("%s: orb pointer active\n", __func__);
END_DEBUG
sdev->flags |= ORB_POINTER_NEED;
return;
@ -1204,21 +1231,26 @@ END_DEBUG
}
}
#if 0
static void
sbp_cmd_callback(struct fw_xfer *xfer)
sbp_doorbell_callback(struct fw_xfer *xfer)
{
SBP_DEBUG(1)
struct sbp_dev *sdev;
sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2);
printf("sbp_cmd_callback\n");
printf("sbp_doorbell_callback\n");
END_DEBUG
if (xfer->resp != 0) {
/* XXX */
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
}
sbp_xfer_free(xfer);
sdev->flags &= ~ORB_DOORBELL_ACTIVE;
if ((sdev->flags & ORB_DOORBELL_NEED) != 0) {
sdev->flags &= ~ORB_DOORBELL_NEED;
sbp_doorbell(sdev);
}
return;
}
@ -1232,15 +1264,19 @@ SBP_DEBUG(1)
printf("sbp_doorbell\n");
END_DEBUG
if ((sdev->flags & ORB_DOORBELL_ACTIVE) != 0) {
sdev->flags |= ORB_DOORBELL_NEED;
return;
}
sdev->flags |= ORB_DOORBELL_ACTIVE;
xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x10);
if (xfer == NULL)
return;
xfer->act.hand = sbp_cmd_callback;
fp = (struct fw_pkt *)xfer->send.buf;
xfer->act.hand = sbp_doorbell_callback;
fp = &xfer->send.hdr;
fp->mode.wreqq.data = htonl(0xf);
fw_asyreq(xfer->fc, -1, xfer);
}
#endif
static struct fw_xfer *
sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
@ -1539,10 +1575,6 @@ END_DEBUG
#endif
/* fall through */
case T_RBC:
/* enable tagged queuing */
#if 1
inq->flags |= SID_CmdQue;
#endif
/*
* Override vendor/product/revision information.
* Some devices sometimes return strange strings.
@ -1554,6 +1586,15 @@ END_DEBUG
#endif
break;
}
/*
* Force to enable/disable tagged queuing.
* XXX CAM also checks SCP_QUEUE_DQUE flag in the control mode page.
*/
if (sbp_tags > 0)
inq->flags |= SID_CmdQue;
else if (sbp_tags < 0)
inq->flags &= ~SID_CmdQue;
}
static void
@ -1629,10 +1670,10 @@ END_DEBUG
ocb = sbp_dequeue_ocb(sdev, sbp_status);
if (ocb == NULL) {
sbp_show_sdev_info(sdev, 2);
#if __FreeBSD_version >= 500000
printf("No ocb(%x) on the queue\n",
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("No ocb(%lx) on the queue\n",
#else
printf("No ocb(%x) on the queue\n",
#endif
ntohl(sbp_status->orb_lo));
}
@ -1657,10 +1698,10 @@ END_DEBUG
SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2);
printf("ORB status src:%x resp:%x dead:%x"
#if __FreeBSD_version >= 500000
" len:%x stat:%x orb:%x%08x\n",
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
" len:%x stat:%x orb:%x%08lx\n",
#else
" len:%x stat:%x orb:%x%08x\n",
#endif
sbp_status->src, sbp_status->resp, sbp_status->dead,
sbp_status->len, sbp_status->status,
@ -1811,7 +1852,8 @@ printf("len %d\n", sbp_status->len);
}
}
sbp_free_ocb(sdev, ocb);
if (!use_doorbell)
sbp_free_ocb(sdev, ocb);
done:
if (reset_agent)
sbp_agent_reset(sdev);
@ -1893,7 +1935,7 @@ END_DEBUG
/*maxsize*/0x100000, /*nsegments*/SBP_IND_MAX,
/*maxsegsz*/SBP_SEG_MAX,
/*flags*/BUS_DMA_ALLOCNOW,
#if __FreeBSD_version >= 501102
#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant,
#endif
@ -2340,6 +2382,10 @@ END_DEBUG
#endif
if ((ocb = sbp_get_ocb(sdev)) == NULL) {
ccb->ccb_h.status = CAM_REQUEUE_REQ;
if (sdev->freeze == 0) {
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
}
xpt_done(ccb);
return;
}
@ -2394,7 +2440,7 @@ printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntoh
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
#if __FreeBSD_version < 501100
#if defined(__DragonFly__) || __FreeBSD_version < 501100
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended = 1;
@ -2409,21 +2455,21 @@ printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntoh
}
SBP_DEBUG(1)
printf("%s:%d:%d:%d:XPT_CALC_GEOMETRY: "
#if __FreeBSD_version >= 500000
"Volume size = %jd\n",
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
"Volume size = %d\n",
#else
"Volume size = %jd\n",
#endif
device_get_nameunit(sbp->fd.dev),
cam_sim_path(sbp->sim),
ccb->ccb_h.target_id, ccb->ccb_h.target_lun,
#if __FreeBSD_version >= 500000
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
(uintmax_t)
#endif
ccg->volume_size);
END_DEBUG
#if __FreeBSD_version < 501100
#if defined(__DragonFly__) || __FreeBSD_version < 501100
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
@ -2539,11 +2585,11 @@ sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error)
SBP_DEBUG(2)
printf("sbp_execute_ocb: seg %d", seg);
for (i = 0; i < seg; i++)
#if __FreeBSD_version >= 500000
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf(", %x:%d", segments[i].ds_addr, segments[i].ds_len);
#else
printf(", %jx:%jd", (uintmax_t)segments[i].ds_addr,
(uintmax_t)segments[i].ds_len);
#else
printf(", %x:%d", segments[i].ds_addr, segments[i].ds_len);
#endif
printf("\n");
END_DEBUG
@ -2563,10 +2609,10 @@ SBP_DEBUG(0)
/* XXX LSI Logic "< 16 byte" bug might be hit */
if (s->ds_len < 16)
printf("sbp_execute_ocb: warning, "
#if __FreeBSD_version >= 500000
"segment length(%zd) is less than 16."
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
"segment length(%d) is less than 16."
#else
"segment length(%zd) is less than 16."
#endif
"(seg=%d/%d)\n", s->ds_len, i+1, seg);
END_DEBUG
@ -2584,9 +2630,18 @@ END_DEBUG
BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
prev = sbp_enqueue_ocb(ocb->sdev, ocb);
fwdma_sync(&ocb->sdev->dma, BUS_DMASYNC_PREWRITE);
if (prev == NULL || (ocb->sdev->flags & ORB_LINK_DEAD) != 0) {
ocb->sdev->flags &= ~ORB_LINK_DEAD;
sbp_orb_pointer(ocb->sdev, ocb);
if (use_doorbell) {
if (prev == NULL) {
if (ocb->sdev->last_ocb != NULL)
sbp_doorbell(ocb->sdev);
else
sbp_orb_pointer(ocb->sdev, ocb);
}
} else {
if (prev == NULL || (ocb->sdev->flags & ORB_LINK_DEAD) != 0) {
ocb->sdev->flags &= ~ORB_LINK_DEAD;
sbp_orb_pointer(ocb->sdev, ocb);
}
}
}
@ -2614,12 +2669,12 @@ sbp_dequeue_ocb(struct sbp_dev *sdev, struct sbp_status *sbp_status)
SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2);
#if __FreeBSD_version >= 500000
printf("%s: 0x%08x src %d\n",
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("%s: 0x%08lx src %d\n",
#else
printf("%s: 0x%08x src %d\n",
#endif
__FUNCTION__, ntohl(sbp_status->orb_lo), sbp_status->src);
__func__, ntohl(sbp_status->orb_lo), sbp_status->src);
END_DEBUG
for (ocb = STAILQ_FIRST(&sdev->ocbs); ocb != NULL; ocb = next) {
next = STAILQ_NEXT(ocb, ocb);
@ -2639,17 +2694,30 @@ END_DEBUG
bus_dmamap_unload(sdev->target->sbp->dmat,
ocb->dmamap);
}
if (sbp_status->src == SRC_NO_NEXT) {
if (next != NULL)
sbp_orb_pointer(sdev, next);
else if (order > 0) {
/*
* Unordered execution
* We need to send pointer for
* next ORB
*/
sdev->flags |= ORB_LINK_DEAD;
if (!use_doorbell) {
if (sbp_status->src == SRC_NO_NEXT) {
if (next != NULL)
sbp_orb_pointer(sdev, next);
else if (order > 0) {
/*
* Unordered execution
* We need to send pointer for
* next ORB
*/
sdev->flags |= ORB_LINK_DEAD;
}
}
} else {
/*
* XXX this is not correct for unordered
* execution.
*/
if (sdev->last_ocb != NULL)
sbp_free_ocb(sdev, sdev->last_ocb);
sdev->last_ocb = ocb;
if (next != NULL &&
sbp_status->src == SRC_NO_NEXT)
sbp_doorbell(sdev);
}
break;
} else
@ -2669,35 +2737,38 @@ static struct sbp_ocb *
sbp_enqueue_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb)
{
int s = splfw();
struct sbp_ocb *prev;
struct sbp_ocb *prev, *prev2;
SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2);
#if __FreeBSD_version >= 500000
printf("%s: 0x%08jx\n", __FUNCTION__, (uintmax_t)ocb->bus_addr);
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("%s: 0x%08x\n", __func__, ocb->bus_addr);
#else
printf("%s: 0x%08x\n", __FUNCTION__, ocb->bus_addr);
printf("%s: 0x%08jx\n", __func__, (uintmax_t)ocb->bus_addr);
#endif
END_DEBUG
prev = STAILQ_LAST(&sdev->ocbs, sbp_ocb, ocb);
prev2 = prev = STAILQ_LAST(&sdev->ocbs, sbp_ocb, ocb);
STAILQ_INSERT_TAIL(&sdev->ocbs, ocb, ocb);
if (ocb->ccb != NULL)
ocb->ccb->ccb_h.timeout_ch = timeout(sbp_timeout, (caddr_t)ocb,
(ocb->ccb->ccb_h.timeout * hz) / 1000);
if (prev != NULL) {
if (use_doorbell && prev == NULL)
prev2 = sdev->last_ocb;
if (prev2 != NULL) {
SBP_DEBUG(2)
#if __FreeBSD_version >= 500000
printf("linking chain 0x%jx -> 0x%jx\n",
(uintmax_t)prev->bus_addr, (uintmax_t)ocb->bus_addr);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("linking chain 0x%x -> 0x%x\n",
prev->bus_addr, ocb->bus_addr);
prev2->bus_addr, ocb->bus_addr);
#else
printf("linking chain 0x%jx -> 0x%jx\n",
(uintmax_t)prev2->bus_addr, (uintmax_t)ocb->bus_addr);
#endif
END_DEBUG
prev->orb[1] = htonl(ocb->bus_addr);
prev->orb[0] = 0;
prev2->orb[1] = htonl(ocb->bus_addr);
prev2->orb[0] = 0;
}
splx(s);
@ -2711,6 +2782,7 @@ sbp_get_ocb(struct sbp_dev *sdev)
int s = splfw();
ocb = STAILQ_FIRST(&sdev->free_ocbs);
if (ocb == NULL) {
sdev->flags |= ORB_SHORTAGE;
printf("ocb shortage!!!\n");
return NULL;
}
@ -2726,6 +2798,14 @@ sbp_free_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb)
ocb->flags = 0;
ocb->ccb = NULL;
STAILQ_INSERT_TAIL(&sdev->free_ocbs, ocb, ocb);
if ((sdev->flags & ORB_SHORTAGE) != 0) {
int count;
sdev->flags &= ~ORB_SHORTAGE;
count = sdev->freeze;
sdev->freeze = 0;
xpt_release_devq(sdev->path, count, TRUE);
}
}
static void
@ -2736,10 +2816,10 @@ sbp_abort_ocb(struct sbp_ocb *ocb, int status)
sdev = ocb->sdev;
SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2);
#if __FreeBSD_version >= 500000
printf("sbp_abort_ocb 0x%jx\n", (uintmax_t)ocb->bus_addr);
#else
#if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("sbp_abort_ocb 0x%x\n", ocb->bus_addr);
#else
printf("sbp_abort_ocb 0x%jx\n", (uintmax_t)ocb->bus_addr);
#endif
END_DEBUG
SBP_DEBUG(1)
@ -2776,6 +2856,10 @@ sbp_abort_all_ocbs(struct sbp_dev *sdev, int status)
next = STAILQ_NEXT(ocb, ocb);
sbp_abort_ocb(ocb, status);
}
if (sdev->last_ocb != NULL) {
sbp_free_ocb(sdev, sdev->last_ocb);
sdev->last_ocb = NULL;
}
splx(s);
}
@ -2798,6 +2882,9 @@ static driver_t sbp_driver = {
sbp_methods,
sizeof(struct sbp_softc),
};
#ifdef __DragonFly__
DECLARE_DUMMY_MODULE(sbp);
#endif
DRIVER_MODULE(sbp, firewire, sbp_driver, sbp_devclass, 0, 0);
MODULE_VERSION(sbp, 1);
MODULE_DEPEND(sbp, firewire, 1, 1, 1);

View File

@ -242,7 +242,7 @@ sbp_targ_dealloc_login(struct sbp_targ_login *login)
struct orb_info *orbi, *next;
if (login == NULL) {
printf("%s: login = NULL\n", __FUNCTION__);
printf("%s: login = NULL\n", __func__);
return;
}
for (orbi = STAILQ_FIRST(&login->orbs); orbi != NULL; orbi = next) {
@ -264,10 +264,10 @@ sbp_targ_hold_expire(void *arg)
login = (struct sbp_targ_login *)arg;
if (login->flags & F_HOLD) {
printf("%s: login_id=%d expired\n", __FUNCTION__, login->id);
printf("%s: login_id=%d expired\n", __func__, login->id);
sbp_targ_dealloc_login(login);
} else {
printf("%s: login_id=%d not hold\n", __FUNCTION__, login->id);
printf("%s: login_id=%d not hold\n", __func__, login->id);
}
}
@ -292,7 +292,7 @@ sbp_targ_post_busreset(void *arg)
sc->flags |= F_FREEZED;
xpt_freeze_simq(sc->sim, /*count*/1);
} else {
printf("%s: already freezed\n", __FUNCTION__);
printf("%s: already freezed\n", __func__);
}
bzero(unit, sizeof(struct crom_chunk));
@ -480,7 +480,7 @@ sbp_targ_send_lstate_events(struct sbp_targ_softc *sc,
struct ccb_hdr *ccbh;
struct ccb_immed_notify *inot;
printf("%s: not implemented yet\n", __FUNCTION__);
printf("%s: not implemented yet\n", __func__);
#endif
}
@ -512,13 +512,13 @@ sbp_targ_get_orb_info(struct sbp_targ_lstate *lstate,
login = lstate->sc->logins[init_id];
if (login == NULL) {
printf("%s: no such login\n", __FUNCTION__);
printf("%s: no such login\n", __func__);
return (NULL);
}
STAILQ_FOREACH(orbi, &login->orbs, link)
if (orbi->orb_lo == tag_id)
goto found;
printf("%s: orb not found tag_id=0x%08x\n", __FUNCTION__, tag_id);
printf("%s: orb not found tag_id=0x%08x\n", __func__, tag_id);
return (NULL);
found:
return (orbi);
@ -530,7 +530,7 @@ sbp_targ_abort(struct orb_info *orbi)
struct orb_info *norbi;
for (; orbi != NULL; orbi = norbi) {
printf("%s: status=%d\n", __FUNCTION__, orbi->state);
printf("%s: status=%d\n", __func__, orbi->state);
norbi = STAILQ_NEXT(orbi, link);
if (orbi->state != ORBI_STATUS_ABORTED) {
if (orbi->ccb != NULL) {
@ -555,7 +555,7 @@ sbp_targ_free_orbi(struct fw_xfer *xfer)
orbi = (struct orb_info *)xfer->sc;
if (xfer->resp != 0) {
/* XXX */
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
}
free(orbi, M_SBP_TARG);
fw_xfer_free(xfer);
@ -577,7 +577,7 @@ sbp_targ_status_FIFO(struct orb_info *orbi,
if (xfer == NULL) {
/* XXX */
printf("%s: xfer == NULL\n", __FUNCTION__);
printf("%s: xfer == NULL\n", __func__);
}
}
@ -597,7 +597,7 @@ sbp_targ_send_status(struct orb_info *orbi, union ccb *ccb)
switch (ccb->csio.scsi_status) {
case SCSI_STATUS_OK:
if (debug)
printf("%s: STATUS_OK\n", __FUNCTION__);
printf("%s: STATUS_OK\n", __func__);
sbp_status->len = 1;
break;
case SCSI_STATUS_CHECK_COND:
@ -608,7 +608,7 @@ sbp_targ_send_status(struct orb_info *orbi, union ccb *ccb)
struct scsi_sense_data *sense;
if (debug)
printf("%s: STATUS %d\n", __FUNCTION__,
printf("%s: STATUS %d\n", __func__,
ccb->csio.scsi_status);
sbp_cmd_status = (struct sbp_cmd_status *)&sbp_status->data[0];
sbp_cmd_status->status = ccb->csio.scsi_status;
@ -649,7 +649,7 @@ sbp_targ_send_status(struct orb_info *orbi, union ccb *ccb)
break;
}
default:
printf("%s: unknown scsi status 0x%x\n", __FUNCTION__,
printf("%s: unknown scsi status 0x%x\n", __func__,
sbp_status->status);
}
@ -669,11 +669,11 @@ sbp_targ_cam_done(struct fw_xfer *xfer)
orbi = (struct orb_info *)xfer->sc;
if (debug > 1)
printf("%s: resp=%d refcount=%d\n", __FUNCTION__,
printf("%s: resp=%d refcount=%d\n", __func__,
xfer->resp, orbi->refcount);
if (xfer->resp != 0) {
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
orbi->status.resp = SBP_TRANS_FAIL;
orbi->status.status = OBJ_DATA | SBE_TIMEOUT/*XXX*/;
orbi->status.dead = 1;
@ -686,7 +686,7 @@ sbp_targ_cam_done(struct fw_xfer *xfer)
if (orbi->refcount == 0) {
if (orbi->state == ORBI_STATUS_ABORTED) {
if (debug)
printf("%s: orbi aborted\n", __FUNCTION__);
printf("%s: orbi aborted\n", __func__);
sbp_targ_remove_orb_info(orbi->login, orbi);
if (orbi->page_table != NULL)
free(orbi->page_table, M_SBP_TARG);
@ -756,7 +756,7 @@ sbp_targ_abort_ccb(struct sbp_targ_softc *sc, union ccb *ccb)
xpt_done(accb);
return (CAM_REQ_CMP);
}
printf("%s: not found\n", __FUNCTION__);
printf("%s: not found\n", __func__);
return (CAM_PATH_INVALID);
}
@ -770,7 +770,7 @@ sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset,
char *ptr;
if (debug > 1)
printf("%s: offset=%d size=%d\n", __FUNCTION__, offset, size);
printf("%s: offset=%d size=%d\n", __func__, offset, size);
ccb_dir = orbi->ccb->ccb_h.flags & CAM_DIR_MASK;
ptr = (char *)orbi->ccb->csio.data_ptr + offset;
@ -790,7 +790,7 @@ sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset,
dst_hi, dst_lo + off, len,
ptr + off, hand);
if (xfer == NULL) {
printf("%s: xfer == NULL", __FUNCTION__);
printf("%s: xfer == NULL", __func__);
/* XXX what should we do?? */
orbi->refcount --;
}
@ -810,7 +810,7 @@ sbp_targ_pt_done(struct fw_xfer *xfer)
ccb = orbi->ccb;
if (orbi->state == ORBI_STATUS_ABORTED) {
if (debug)
printf("%s: orbi aborted\n", __FUNCTION__);
printf("%s: orbi aborted\n", __func__);
sbp_targ_remove_orb_info(orbi->login, orbi);
free(orbi->page_table, M_SBP_TARG);
free(orbi, M_SBP_TARG);
@ -818,7 +818,7 @@ sbp_targ_pt_done(struct fw_xfer *xfer)
return;
}
if (xfer->resp != 0) {
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
orbi->status.resp = SBP_TRANS_FAIL;
orbi->status.status = OBJ_PT | SBE_TIMEOUT/*XXX*/;
orbi->status.dead = 1;
@ -834,7 +834,7 @@ sbp_targ_pt_done(struct fw_xfer *xfer)
res = ccb->csio.dxfer_len;
offset = 0;
if (debug)
printf("%s: dxfer_len=%d\n", __FUNCTION__, res);
printf("%s: dxfer_len=%d\n", __func__, res);
orbi->refcount ++;
for (p = orbi->page_table, i = orbi->orb4.data_size; i > 0; i --) {
t1 = ntohl(*p++);
@ -852,10 +852,10 @@ sbp_targ_pt_done(struct fw_xfer *xfer)
}
orbi->refcount --;
if (orbi->refcount == 0)
printf("%s: refcount == 0\n", __FUNCTION__);
printf("%s: refcount == 0\n", __func__);
if (res !=0)
/* XXX handle res != 0 case */
printf("%s: page table is too small(%d)\n", __FUNCTION__, res);
printf("%s: page table is too small(%d)\n", __func__, res);
fw_xfer_free(xfer);
return;
@ -868,7 +868,7 @@ sbp_targ_fetch_pt(struct orb_info *orbi)
if (debug)
printf("%s: page_table_size=%d\n",
__FUNCTION__, orbi->orb4.data_size);
__func__, orbi->orb4.data_size);
orbi->page_table = malloc(orbi->orb4.data_size*8, M_SBP_TARG, M_NOWAIT);
if (orbi->page_table == NULL)
goto error;
@ -901,7 +901,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
struct orb_info *orbi;
if (debug)
printf("%s: XPT_CONT_TARGET_IO\n", __FUNCTION__);
printf("%s: XPT_CONT_TARGET_IO\n", __func__);
if (status != CAM_REQ_CMP) {
ccb->ccb_h.status = status;
@ -918,7 +918,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
}
if (orbi->state == ORBI_STATUS_ABORTED) {
if (debug)
printf("%s: ctio aborted\n", __FUNCTION__);
printf("%s: ctio aborted\n", __func__);
sbp_targ_remove_orb_info(orbi->login, orbi);
free(orbi, M_SBP_TARG);
break;
@ -934,16 +934,16 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
/* Sanity check */
if (ccb_dir == CAM_DIR_IN && orbi->orb4.dir == 0)
printf("%s: direction mismatch\n", __FUNCTION__);
printf("%s: direction mismatch\n", __func__);
/* check page table */
if (ccb_dir != CAM_DIR_NONE && orbi->orb4.page_table_present) {
if (debug)
printf("%s: page_table_present\n",
__FUNCTION__);
__func__);
if (orbi->orb4.page_size != 0) {
printf("%s: unsupported pagesize %d != 0\n",
__FUNCTION__, orbi->orb4.page_size);
__func__, orbi->orb4.page_size);
ccb->ccb_h.status = CAM_REQ_INVALID;
xpt_done(ccb);
break;
@ -956,7 +956,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
if (ccb_dir != CAM_DIR_NONE &&
orbi->orb4.data_size != ccb->csio.dxfer_len)
printf("%s: data_size(%d) != dxfer_len(%d)\n",
__FUNCTION__, orbi->orb4.data_size,
__func__, orbi->orb4.data_size,
ccb->csio.dxfer_len);
if (ccb_dir != CAM_DIR_NONE)
@ -986,7 +986,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
struct sbp_targ_login *login;
if (debug)
printf("%s: new atio arrived\n", __FUNCTION__);
printf("%s: new atio arrived\n", __func__);
lstate->flags &= ~F_ATIO_STARVED;
STAILQ_FOREACH(login, &lstate->logins, link)
if ((login->flags & F_ATIO_STARVED) != 0) {
@ -1054,7 +1054,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
break;
default:
printf("%s: aborting unknown function %d\n",
__FUNCTION__, accb->ccb_h.func_code);
__func__, accb->ccb_h.func_code);
ccb->ccb_h.status = CAM_REQ_INVALID;
break;
}
@ -1063,7 +1063,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
}
default:
printf("%s: unknown function %d\n",
__FUNCTION__, ccb->ccb_h.func_code);
__func__, ccb->ccb_h.func_code);
ccb->ccb_h.status = CAM_REQ_INVALID;
xpt_done(ccb);
break;
@ -1101,7 +1101,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
orbi = (struct orb_info *)xfer->sc;
if (xfer->resp != 0) {
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
orbi->status.resp = SBP_TRANS_FAIL;
orbi->status.status = OBJ_ORB | SBE_TIMEOUT/*XXX*/;
orbi->status.dead = 1;
@ -1116,7 +1116,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
fp = &xfer->recv.hdr;
if (orbi->state == ORBI_STATUS_ABORTED) {
printf("%s: aborted\n", __FUNCTION__);
printf("%s: aborted\n", __func__);
sbp_targ_remove_orb_info(orbi->login, orbi);
free(orbi, M_SBP_TARG);
goto done0;
@ -1131,7 +1131,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
orb4 = (struct corb4 *)&orb[4];
if (orb4->rq_fmt != 0) {
/* XXX */
printf("%s: rq_fmt(%d) != 0\n", __FUNCTION__, orb4->rq_fmt);
printf("%s: rq_fmt(%d) != 0\n", __func__, orb4->rq_fmt);
}
atio = orbi->atio;
@ -1146,7 +1146,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
bytes = (char *)&orb[5];
if (debug)
printf("%s: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
__FUNCTION__,
__func__,
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4],
bytes[5], bytes[6], bytes[7], bytes[8], bytes[9]);
switch (bytes[0] >> 5) {
@ -1178,7 +1178,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
/* next ORB */
if ((orb[0] & (1<<31)) == 0) {
if (debug)
printf("%s: fetch next orb\n", __FUNCTION__);
printf("%s: fetch next orb\n", __func__);
orbi->status.src = SRC_NEXT_EXISTS;
sbp_targ_fetch_orb(orbi->sc, orbi->fwdev,
orb[0], orb[1], orbi->login, FETCH_CMD);
@ -1214,7 +1214,7 @@ sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun)
if (sc->logins[i] == NULL)
goto found;
printf("%s: increase MAX_LOGIN\n", __FUNCTION__);
printf("%s: increase MAX_LOGIN\n", __func__);
return (NULL);
found:
@ -1222,7 +1222,7 @@ sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun)
sizeof(struct sbp_targ_login), M_SBP_TARG, M_NOWAIT | M_ZERO);
if (login == NULL) {
printf("%s: malloc failed\n", __FUNCTION__);
printf("%s: malloc failed\n", __func__);
return (NULL);
}
@ -1250,7 +1250,7 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
orbi = (struct orb_info *)xfer->sc;
if (xfer->resp != 0) {
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
orbi->status.resp = SBP_TRANS_FAIL;
orbi->status.status = OBJ_ORB | SBE_TIMEOUT/*XXX*/;
orbi->status.dead = 1;
@ -1271,7 +1271,7 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
}
orb4 = (struct morb4 *)&orb[4];
if (debug)
printf("%s: %s\n", __FUNCTION__, orb_fun_name[orb4->fun]);
printf("%s: %s\n", __func__, orb_fun_name[orb4->fun]);
orbi->status.src = SRC_NO_NEXT;
@ -1302,7 +1302,7 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
login = sbp_targ_get_login(orbi->sc, orbi->fwdev, lun);
if (login == NULL) {
printf("%s: sbp_targ_get_login failed\n",
__FUNCTION__);
__func__);
orbi->status.dead = 1;
orbi->status.status = STATUS_RES_UNAVAIL;
orbi->status.len = 1;
@ -1330,25 +1330,25 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
login->flags &= ~F_HOLD;
callout_stop(&login->hold_callout);
printf("%s: reconnected id=%d\n",
__FUNCTION__, login->id);
__func__, login->id);
} else {
orbi->status.dead = 1;
orbi->status.status = STATUS_ACCESS_DENY;
printf("%s: reconnection faild id=%d\n",
__FUNCTION__, orb4->id);
__func__, orb4->id);
}
break;
case ORB_FUN_LGO:
login = orbi->sc->logins[orb4->id];
if (login->fwdev != orbi->fwdev) {
printf("%s: wrong initiator\n", __FUNCTION__);
printf("%s: wrong initiator\n", __func__);
break;
}
sbp_targ_dealloc_login(login);
break;
default:
printf("%s: %s not implemented yet\n",
__FUNCTION__, orb_fun_name[orb4->fun]);
__func__, orb_fun_name[orb4->fun]);
break;
}
orbi->status.len = 1;
@ -1365,14 +1365,14 @@ sbp_targ_pointer_handler(struct fw_xfer *xfer)
orbi = (struct orb_info *)xfer->sc;
if (xfer->resp != 0) {
printf("%s: xfer->resp = %d\n", __FUNCTION__, xfer->resp);
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
goto done;
}
orb0 = ntohl(orbi->orb[0]);
orb1 = ntohl(orbi->orb[1]);
if ((orb0 & (1 << 31)) != 0) {
printf("%s: invalid pointer\n", __FUNCTION__);
printf("%s: invalid pointer\n", __func__);
goto done;
}
sbp_targ_fetch_orb(orbi->login->lstate->sc, orbi->fwdev,
@ -1391,10 +1391,10 @@ sbp_targ_fetch_orb(struct sbp_targ_softc *sc, struct fw_device *fwdev,
struct orb_info *orbi;
if (debug)
printf("%s: fetch orb %04x:%08x\n", __FUNCTION__, orb_hi, orb_lo);
printf("%s: fetch orb %04x:%08x\n", __func__, orb_hi, orb_lo);
orbi = malloc(sizeof(struct orb_info), M_SBP_TARG, M_NOWAIT | M_ZERO);
if (orbi == NULL) {
printf("%s: malloc failed\n", __FUNCTION__);
printf("%s: malloc failed\n", __func__);
return;
}
orbi->sc = sc;
@ -1420,7 +1420,7 @@ sbp_targ_fetch_orb(struct sbp_targ_softc *sc, struct fw_device *fwdev,
orbi->atio = (struct ccb_accept_tio *)
SLIST_FIRST(&login->lstate->accept_tios);
if (orbi->atio == NULL) {
printf("%s: no free atio\n", __FUNCTION__);
printf("%s: no free atio\n", __func__);
login->lstate->flags |= F_ATIO_STARVED;
login->flags |= F_ATIO_STARVED;
#if 0
@ -1443,7 +1443,7 @@ sbp_targ_fetch_orb(struct sbp_targ_softc *sc, struct fw_device *fwdev,
sbp_targ_pointer_handler);
break;
default:
printf("%s: invalid mode %d\n", __FUNCTION__, mode);
printf("%s: invalid mode %d\n", __func__, mode);
}
}
@ -1454,7 +1454,7 @@ sbp_targ_resp_callback(struct fw_xfer *xfer)
int s;
if (debug)
printf("%s: xfer=%p\n", __FUNCTION__, xfer);
printf("%s: xfer=%p\n", __func__, xfer);
sc = (struct sbp_targ_softc *)xfer->sc;
fw_xfer_unload(xfer);
xfer->recv.pay_len = SBP_TARG_RECV_LEN;
@ -1488,7 +1488,7 @@ sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id,
switch (reg) {
case 0x08: /* ORB_POINTER */
if (debug)
printf("%s: ORB_POINTER\n", __FUNCTION__);
printf("%s: ORB_POINTER\n", __func__);
if ((login->flags & F_LINK_ACTIVE) != 0) {
if (debug)
printf("link active (ORB_POINTER)\n");
@ -1501,18 +1501,18 @@ sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id,
break;
case 0x04: /* AGENT_RESET */
if (debug)
printf("%s: AGENT RESET\n", __FUNCTION__);
printf("%s: AGENT RESET\n", __func__);
login->last_hi = 0xffff;
login->last_lo = 0xffffffff;
sbp_targ_abort(STAILQ_FIRST(&login->orbs));
break;
case 0x10: /* DOORBELL */
if (debug)
printf("%s: DOORBELL\n", __FUNCTION__);
printf("%s: DOORBELL\n", __func__);
if (login->last_hi == 0xffff &&
login->last_lo == 0xffffffff) {
printf("%s: no previous pointer(DOORBELL)\n",
__FUNCTION__);
__func__);
break;
}
if ((login->flags & F_LINK_ACTIVE) != 0) {
@ -1525,13 +1525,13 @@ sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id,
login, FETCH_POINTER);
break;
case 0x00: /* AGENT_STATE */
printf("%s: AGENT_STATE (ignore)\n", __FUNCTION__);
printf("%s: AGENT_STATE (ignore)\n", __func__);
break;
case 0x14: /* UNSOLICITED_STATE_ENABLE */
printf("%s: UNSOLICITED_STATE_ENABLE (ignore)\n", __FUNCTION__);
printf("%s: UNSOLICITED_STATE_ENABLE (ignore)\n", __func__);
break;
default:
printf("%s: invalid register %d\n", __FUNCTION__, reg);
printf("%s: invalid register %d\n", __func__, reg);
rtcode = RESP_ADDRESS_ERROR;
}
@ -1548,7 +1548,7 @@ sbp_targ_mgm(struct fw_xfer *xfer, struct fw_device *fwdev)
fp = &xfer->recv.hdr;
if (fp->mode.wreqb.tcode != FWTCODE_WREQB){
printf("%s: tcode = %d\n", __FUNCTION__, fp->mode.wreqb.tcode);
printf("%s: tcode = %d\n", __func__, fp->mode.wreqb.tcode);
return(RESP_TYPE_ERROR);
}
@ -1576,7 +1576,7 @@ sbp_targ_recv(struct fw_xfer *xfer)
fwdev = fw_noderesolve_nodeid(sc->fd.fc, fp->mode.wreqb.src & 0x3f);
if (fwdev == NULL) {
printf("%s: cannot resolve nodeid=%d\n",
__FUNCTION__, fp->mode.wreqb.src & 0x3f);
__func__, fp->mode.wreqb.src & 0x3f);
rtcode = RESP_TYPE_ERROR; /* XXX */
goto done;
}
@ -1591,7 +1591,7 @@ sbp_targ_recv(struct fw_xfer *xfer)
done:
if (rtcode != 0)
printf("%s: rtcode = %d\n", __FUNCTION__, rtcode);
printf("%s: rtcode = %d\n", __func__, rtcode);
sfp = &xfer->send.hdr;
xfer->send.spd = 2; /* XXX */
xfer->act.hand = sbp_targ_resp_callback;