Commit 17e6c600 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/aoe-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/aoe-2.6:
  aoe: fix sysfs_create_file warnings
  aoe: revert printk macros
  aoe: update driver version
  aoe: remove sysfs comment
  aoe: use bio->bi_idx
  aoe: module parameter for device timeout
  aoe: zero copy write 2 of 2
  aoe: improve retransmission heuristics
  aoe: jumbo frame support 2 of 2
  aoe: clean up printks via macros
  aoe: jumbo frame support 1 of 2
  aoe: zero copy write 1 of 2
  aoe: remove unused NARGS enum
  aoe: update copyright date
  aoe: eliminate isbusy message
parents b6aefcce 4ca5224f
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
#define VERSION "22" #define VERSION "32"
#define AOE_MAJOR 152 #define AOE_MAJOR 152
#define DEVICE_NAME "aoe" #define DEVICE_NAME "aoe"
...@@ -65,7 +65,7 @@ struct aoe_atahdr { ...@@ -65,7 +65,7 @@ struct aoe_atahdr {
struct aoe_cfghdr { struct aoe_cfghdr {
__be16 bufcnt; __be16 bufcnt;
__be16 fwver; __be16 fwver;
unsigned char res; unsigned char scnt;
unsigned char aoeccmd; unsigned char aoeccmd;
unsigned char cslen[2]; unsigned char cslen[2];
}; };
...@@ -78,12 +78,14 @@ enum { ...@@ -78,12 +78,14 @@ enum {
DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */ DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */
DEVFL_PAUSE = (1<<5), DEVFL_PAUSE = (1<<5),
DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */ DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
DEVFL_MAXBCNT = (1<<7), /* d->maxbcnt is not changeable */
DEVFL_KICKME = (1<<8),
BUFFL_FAIL = 1, BUFFL_FAIL = 1,
}; };
enum { enum {
MAXATADATA = 1024, DEFAULTBCNT = 2 * 512, /* 2 sectors */
NPERSHELF = 16, /* number of slots per shelf address */ NPERSHELF = 16, /* number of slots per shelf address */
FREETAG = -1, FREETAG = -1,
MIN_BUFS = 8, MIN_BUFS = 8,
...@@ -107,11 +109,9 @@ struct frame { ...@@ -107,11 +109,9 @@ struct frame {
ulong waited; ulong waited;
struct buf *buf; struct buf *buf;
char *bufaddr; char *bufaddr;
int writedatalen; ulong bcnt;
int ndata; sector_t lba;
struct sk_buff *skb;
/* largest possible */
unsigned char data[sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr)];
}; };
struct aoedev { struct aoedev {
...@@ -121,9 +121,12 @@ struct aoedev { ...@@ -121,9 +121,12 @@ struct aoedev {
ulong sysminor; ulong sysminor;
ulong aoemajor; ulong aoemajor;
ulong aoeminor; ulong aoeminor;
ulong nopen; /* (bd_openers isn't available without sleeping) */ u16 nopen; /* (bd_openers isn't available without sleeping) */
ulong rttavg; /* round trip average of requests/responses */ u16 lasttag; /* last tag sent */
u16 rttavg; /* round trip average of requests/responses */
u16 mintimer;
u16 fw_ver; /* version of blade's firmware */ u16 fw_ver; /* version of blade's firmware */
u16 maxbcnt;
struct work_struct work;/* disk create work struct */ struct work_struct work;/* disk create work struct */
struct gendisk *gd; struct gendisk *gd;
request_queue_t blkq; request_queue_t blkq;
...@@ -137,8 +140,8 @@ struct aoedev { ...@@ -137,8 +140,8 @@ struct aoedev {
mempool_t *bufpool; /* for deadlock-free Buf allocation */ mempool_t *bufpool; /* for deadlock-free Buf allocation */
struct list_head bufq; /* queue of bios to work on */ struct list_head bufq; /* queue of bios to work on */
struct buf *inprocess; /* the one we're currently working on */ struct buf *inprocess; /* the one we're currently working on */
ulong lasttag; /* last tag sent */ ushort lostjumbo;
ulong nframes; /* number of frames below */ ushort nframes; /* number of frames below */
struct frame *frames; struct frame *frames;
}; };
...@@ -157,6 +160,7 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor); ...@@ -157,6 +160,7 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
void aoecmd_ata_rsp(struct sk_buff *); void aoecmd_ata_rsp(struct sk_buff *);
void aoecmd_cfg_rsp(struct sk_buff *); void aoecmd_cfg_rsp(struct sk_buff *);
void aoecmd_sleepwork(void *vp); void aoecmd_sleepwork(void *vp);
struct sk_buff *new_skb(ulong);
int aoedev_init(void); int aoedev_init(void);
void aoedev_exit(void); void aoedev_exit(void);
......
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
/* /*
* aoeblk.c * aoeblk.c
* block device routines * block device routines
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
static kmem_cache_t *buf_pool_cache; static kmem_cache_t *buf_pool_cache;
/* add attributes for our block devices in sysfs */
static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
{ {
struct aoedev *d = disk->private_data; struct aoedev *d = disk->private_data;
...@@ -64,21 +63,26 @@ static struct disk_attribute disk_attr_fwver = { ...@@ -64,21 +63,26 @@ static struct disk_attribute disk_attr_fwver = {
.show = aoedisk_show_fwver .show = aoedisk_show_fwver
}; };
static void static struct attribute *aoe_attrs[] = {
&disk_attr_state.attr,
&disk_attr_mac.attr,
&disk_attr_netif.attr,
&disk_attr_fwver.attr,
};
static const struct attribute_group attr_group = {
.attrs = aoe_attrs,
};
static int
aoedisk_add_sysfs(struct aoedev *d) aoedisk_add_sysfs(struct aoedev *d)
{ {
sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); return sysfs_create_group(&d->gd->kobj, &attr_group);
sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
} }
void void
aoedisk_rm_sysfs(struct aoedev *d) aoedisk_rm_sysfs(struct aoedev *d)
{ {
sysfs_remove_link(&d->gd->kobj, "state"); sysfs_remove_group(&d->gd->kobj, &attr_group);
sysfs_remove_link(&d->gd->kobj, "mac");
sysfs_remove_link(&d->gd->kobj, "netif");
sysfs_remove_link(&d->gd->kobj, "firmware-version");
} }
static int static int
...@@ -132,8 +136,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) ...@@ -132,8 +136,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
d = bio->bi_bdev->bd_disk->private_data; d = bio->bi_bdev->bd_disk->private_data;
buf = mempool_alloc(d->bufpool, GFP_NOIO); buf = mempool_alloc(d->bufpool, GFP_NOIO);
if (buf == NULL) { if (buf == NULL) {
printk(KERN_INFO "aoe: aoeblk_make_request: buf allocation " printk(KERN_INFO "aoe: buf allocation failure\n");
"failure\n");
bio_endio(bio, bio->bi_size, -ENOMEM); bio_endio(bio, bio->bi_size, -ENOMEM);
return 0; return 0;
} }
...@@ -143,14 +146,15 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) ...@@ -143,14 +146,15 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
buf->bio = bio; buf->bio = bio;
buf->resid = bio->bi_size; buf->resid = bio->bi_size;
buf->sector = bio->bi_sector; buf->sector = bio->bi_sector;
buf->bv = buf->bio->bi_io_vec; buf->bv = &bio->bi_io_vec[bio->bi_idx];
WARN_ON(buf->bv->bv_len == 0);
buf->bv_resid = buf->bv->bv_len; buf->bv_resid = buf->bv->bv_len;
buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
spin_lock_irqsave(&d->lock, flags); spin_lock_irqsave(&d->lock, flags);
if ((d->flags & DEVFL_UP) == 0) { if ((d->flags & DEVFL_UP) == 0) {
printk(KERN_INFO "aoe: aoeblk_make_request: device %ld.%ld is not up\n", printk(KERN_INFO "aoe: device %ld.%ld is not up\n",
d->aoemajor, d->aoeminor); d->aoemajor, d->aoeminor);
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
mempool_free(buf, d->bufpool); mempool_free(buf, d->bufpool);
...@@ -176,7 +180,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo) ...@@ -176,7 +180,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
struct aoedev *d = bdev->bd_disk->private_data; struct aoedev *d = bdev->bd_disk->private_data;
if ((d->flags & DEVFL_UP) == 0) { if ((d->flags & DEVFL_UP) == 0) {
printk(KERN_ERR "aoe: aoeblk_ioctl: disk not up\n"); printk(KERN_ERR "aoe: disk not up\n");
return -ENODEV; return -ENODEV;
} }
...@@ -203,8 +207,8 @@ aoeblk_gdalloc(void *vp) ...@@ -203,8 +207,8 @@ aoeblk_gdalloc(void *vp)
gd = alloc_disk(AOE_PARTITIONS); gd = alloc_disk(AOE_PARTITIONS);
if (gd == NULL) { if (gd == NULL) {
printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate disk " printk(KERN_ERR "aoe: cannot allocate disk structure for %ld.%ld\n",
"structure for %ld.%ld\n", d->aoemajor, d->aoeminor); d->aoemajor, d->aoeminor);
spin_lock_irqsave(&d->lock, flags); spin_lock_irqsave(&d->lock, flags);
d->flags &= ~DEVFL_GDALLOC; d->flags &= ~DEVFL_GDALLOC;
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
...@@ -213,8 +217,8 @@ aoeblk_gdalloc(void *vp) ...@@ -213,8 +217,8 @@ aoeblk_gdalloc(void *vp)
d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache); d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
if (d->bufpool == NULL) { if (d->bufpool == NULL) {
printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool " printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%ld\n",
"for %ld.%ld\n", d->aoemajor, d->aoeminor); d->aoemajor, d->aoeminor);
put_disk(gd); put_disk(gd);
spin_lock_irqsave(&d->lock, flags); spin_lock_irqsave(&d->lock, flags);
d->flags &= ~DEVFL_GDALLOC; d->flags &= ~DEVFL_GDALLOC;
......
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
/* /*
* aoechr.c * aoechr.c
* AoE character device driver * AoE character device driver
...@@ -15,7 +15,6 @@ enum { ...@@ -15,7 +15,6 @@ enum {
MINOR_INTERFACES, MINOR_INTERFACES,
MINOR_REVALIDATE, MINOR_REVALIDATE,
MSGSZ = 2048, MSGSZ = 2048,
NARGS = 10,
NMSG = 100, /* message backlog to retain */ NMSG = 100, /* message backlog to retain */
}; };
...@@ -56,9 +55,8 @@ static int ...@@ -56,9 +55,8 @@ static int
interfaces(const char __user *str, size_t size) interfaces(const char __user *str, size_t size)
{ {
if (set_aoe_iflist(str, size)) { if (set_aoe_iflist(str, size)) {
printk(KERN_CRIT printk(KERN_ERR
"%s: could not set interface list: %s\n", "aoe: could not set interface list: too many interfaces\n");
__FUNCTION__, "too many interfaces");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -81,8 +79,7 @@ revalidate(const char __user *str, size_t size) ...@@ -81,8 +79,7 @@ revalidate(const char __user *str, size_t size)
/* should be e%d.%d format */ /* should be e%d.%d format */
n = sscanf(buf, "e%d.%d", &major, &minor); n = sscanf(buf, "e%d.%d", &major, &minor);
if (n != 2) { if (n != 2) {
printk(KERN_ERR "aoe: %s: invalid device specification\n", printk(KERN_ERR "aoe: invalid device specification\n");
__FUNCTION__);
return -EINVAL; return -EINVAL;
} }
d = aoedev_by_aoeaddr(major, minor); d = aoedev_by_aoeaddr(major, minor);
...@@ -90,6 +87,7 @@ revalidate(const char __user *str, size_t size) ...@@ -90,6 +87,7 @@ revalidate(const char __user *str, size_t size)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&d->lock, flags); spin_lock_irqsave(&d->lock, flags);
d->flags &= ~DEVFL_MAXBCNT;
d->flags |= DEVFL_PAUSE; d->flags |= DEVFL_PAUSE;
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
aoecmd_cfg(major, minor); aoecmd_cfg(major, minor);
...@@ -116,7 +114,7 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags); ...@@ -116,7 +114,7 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags);
mp = kmalloc(n, GFP_ATOMIC); mp = kmalloc(n, GFP_ATOMIC);
if (mp == NULL) { if (mp == NULL) {
printk(KERN_CRIT "aoe: aoechr_error: allocation failure, len=%ld\n", n); printk(KERN_ERR "aoe: allocation failure, len=%ld\n", n);
goto bail; goto bail;
} }
...@@ -141,7 +139,7 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp ...@@ -141,7 +139,7 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp
switch ((unsigned long) filp->private_data) { switch ((unsigned long) filp->private_data) {
default: default:
printk(KERN_INFO "aoe: aoechr_write: can't write to that file.\n"); printk(KERN_INFO "aoe: can't write to that file.\n");
break; break;
case MINOR_DISCOVER: case MINOR_DISCOVER:
ret = discover(); ret = discover();
...@@ -250,7 +248,7 @@ aoechr_init(void) ...@@ -250,7 +248,7 @@ aoechr_init(void)
n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops); n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
if (n < 0) { if (n < 0) {
printk(KERN_ERR "aoe: aoechr_init: can't register char device\n"); printk(KERN_ERR "aoe: can't register char device\n");
return n; return n;
} }
sema_init(&emsgs_sema, 0); sema_init(&emsgs_sema, 0);
......
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
/* /*
* aoecmd.c * aoecmd.c
* Filesystem request handling methods * Filesystem request handling methods
...@@ -15,17 +15,19 @@ ...@@ -15,17 +15,19 @@
#define TIMERTICK (HZ / 10) #define TIMERTICK (HZ / 10)
#define MINTIMER (2 * TIMERTICK) #define MINTIMER (2 * TIMERTICK)
#define MAXTIMER (HZ << 1) #define MAXTIMER (HZ << 1)
#define MAXWAIT (60 * 3) /* After MAXWAIT seconds, give up and fail dev */
static struct sk_buff * static int aoe_deadsecs = 60 * 3;
new_skb(struct net_device *if_dev, ulong len) module_param(aoe_deadsecs, int, 0644);
MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev.");
struct sk_buff *
new_skb(ulong len)
{ {
struct sk_buff *skb; struct sk_buff *skb;
skb = alloc_skb(len, GFP_ATOMIC); skb = alloc_skb(len, GFP_ATOMIC);
if (skb) { if (skb) {
skb->nh.raw = skb->mac.raw = skb->data; skb->nh.raw = skb->mac.raw = skb->data;
skb->dev = if_dev;
skb->protocol = __constant_htons(ETH_P_AOE); skb->protocol = __constant_htons(ETH_P_AOE);
skb->priority = 0; skb->priority = 0;
skb_put(skb, len); skb_put(skb, len);
...@@ -40,29 +42,6 @@ new_skb(struct net_device *if_dev, ulong len) ...@@ -40,29 +42,6 @@ new_skb(struct net_device *if_dev, ulong len)
return skb; return skb;
} }
static struct sk_buff *
skb_prepare(struct aoedev *d, struct frame *f)
{
struct sk_buff *skb;
char *p;
skb = new_skb(d->ifp, f->ndata + f->writedatalen);
if (!skb) {
printk(KERN_INFO "aoe: skb_prepare: failure to allocate skb\n");
return NULL;
}
p = skb->mac.raw;
memcpy(p, f->data, f->ndata);
if (f->writedatalen) {
p += sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr);
memcpy(p, f->bufaddr, f->writedatalen);
}
return skb;
}
static struct frame * static struct frame *
getframe(struct aoedev *d, int tag) getframe(struct aoedev *d, int tag)
{ {
...@@ -107,6 +86,17 @@ aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h) ...@@ -107,6 +86,17 @@ aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h)
return host_tag; return host_tag;
} }
static inline void
put_lba(struct aoe_atahdr *ah, sector_t lba)
{
ah->lba0 = lba;
ah->lba1 = lba >>= 8;
ah->lba2 = lba >>= 8;
ah->lba3 = lba >>= 8;
ah->lba4 = lba >>= 8;
ah->lba5 = lba >>= 8;
}
static void static void
aoecmd_ata_rw(struct aoedev *d, struct frame *f) aoecmd_ata_rw(struct aoedev *d, struct frame *f)
{ {
...@@ -125,29 +115,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f) ...@@ -125,29 +115,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
sector = buf->sector; sector = buf->sector;
bcnt = buf->bv_resid; bcnt = buf->bv_resid;
if (bcnt > MAXATADATA) if (bcnt > d->maxbcnt)
bcnt = MAXATADATA; bcnt = d->maxbcnt;
/* initialize the headers & frame */ /* initialize the headers & frame */
h = (struct aoe_hdr *) f->data; skb = f->skb;
h = (struct aoe_hdr *) skb->mac.raw;
ah = (struct aoe_atahdr *) (h+1); ah = (struct aoe_atahdr *) (h+1);
f->ndata = sizeof *h + sizeof *ah; skb->len = sizeof *h + sizeof *ah;
memset(h, 0, f->ndata); memset(h, 0, ETH_ZLEN);
f->tag = aoehdr_atainit(d, h); f->tag = aoehdr_atainit(d, h);
f->waited = 0; f->waited = 0;
f->buf = buf; f->buf = buf;
f->bufaddr = buf->bufaddr; f->bufaddr = buf->bufaddr;
f->bcnt = bcnt;
f->lba = sector;
/* set up ata header */ /* set up ata header */
ah->scnt = bcnt >> 9; ah->scnt = bcnt >> 9;
ah->lba0 = sector; put_lba(ah, sector);
ah->lba1 = sector >>= 8;
ah->lba2 = sector >>= 8;
ah->lba3 = sector >>= 8;
if (d->flags & DEVFL_EXT) { if (d->flags & DEVFL_EXT) {
ah->aflags |= AOEAFL_EXT; ah->aflags |= AOEAFL_EXT;
ah->lba4 = sector >>= 8;
ah->lba5 = sector >>= 8;
} else { } else {
extbit = 0; extbit = 0;
ah->lba3 &= 0x0f; ah->lba3 &= 0x0f;
...@@ -155,11 +143,14 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f) ...@@ -155,11 +143,14 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
} }
if (bio_data_dir(buf->bio) == WRITE) { if (bio_data_dir(buf->bio) == WRITE) {
skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr),
offset_in_page(f->bufaddr), bcnt);
ah->aflags |= AOEAFL_WRITE; ah->aflags |= AOEAFL_WRITE;
f->writedatalen = bcnt; skb->len += bcnt;
skb->data_len = bcnt;
} else { } else {
skb->len = ETH_ZLEN;
writebit = 0; writebit = 0;
f->writedatalen = 0;
} }
ah->cmdstat = WIN_READ | writebit | extbit; ah->cmdstat = WIN_READ | writebit | extbit;
...@@ -168,26 +159,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f) ...@@ -168,26 +159,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
buf->nframesout += 1; buf->nframesout += 1;
buf->bufaddr += bcnt; buf->bufaddr += bcnt;
buf->bv_resid -= bcnt; buf->bv_resid -= bcnt;
/* printk(KERN_INFO "aoe: bv_resid=%ld\n", buf->bv_resid); */ /* printk(KERN_DEBUG "aoe: bv_resid=%ld\n", buf->bv_resid); */
buf->resid -= bcnt; buf->resid -= bcnt;
buf->sector += bcnt >> 9; buf->sector += bcnt >> 9;
if (buf->resid == 0) { if (buf->resid == 0) {
d->inprocess = NULL; d->inprocess = NULL;
} else if (buf->bv_resid == 0) { } else if (buf->bv_resid == 0) {
buf->bv++; buf->bv++;
WARN_ON(buf->bv->bv_len == 0);
buf->bv_resid = buf->bv->bv_len; buf->bv_resid = buf->bv->bv_len;
buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
} }
skb = skb_prepare(d, f); skb->dev = d->ifp;
if (skb) { skb = skb_clone(skb, GFP_ATOMIC);
skb->next = NULL; if (skb == NULL)
if (d->sendq_hd) return;
d->sendq_tl->next = skb; if (d->sendq_hd)
else d->sendq_tl->next = skb;
d->sendq_hd = skb; else
d->sendq_tl = skb; d->sendq_hd = skb;
} d->sendq_tl = skb;
} }
/* some callers cannot sleep, and they can call this function, /* some callers cannot sleep, and they can call this function,
...@@ -209,11 +201,12 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail) ...@@ -209,11 +201,12 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
if (!is_aoe_netif(ifp)) if (!is_aoe_netif(ifp))
continue; continue;
skb = new_skb(ifp, sizeof *h + sizeof *ch); skb = new_skb(sizeof *h + sizeof *ch);
if (skb == NULL) { if (skb == NULL) {
printk(KERN_INFO "aoe: aoecmd_cfg: skb alloc failure\n"); printk(KERN_INFO "aoe: skb alloc failure\n");
continue; continue;
} }
skb->dev = ifp;
if (sl_tail == NULL) if (sl_tail == NULL)
sl_tail = skb; sl_tail = skb;
h = (struct aoe_hdr *) skb->mac.raw; h = (struct aoe_hdr *) skb->mac.raw;
...@@ -237,6 +230,29 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail) ...@@ -237,6 +230,29 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
return sl; return sl;
} }
static struct frame *
freeframe(struct aoedev *d)
{
struct frame *f, *e;
int n = 0;
f = d->frames;
e = f + d->nframes;
for (; f<e; f++) {
if (f->tag != FREETAG)
continue;
if (atomic_read(&skb_shinfo(f->skb)->dataref) == 1) {
skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
return f;
}
n++;
}
if (n == d->nframes) /* wait for network layer */
d->flags |= DEVFL_KICKME;
return NULL;
}
/* enters with d->lock held */ /* enters with d->lock held */
void void
aoecmd_work(struct aoedev *d) aoecmd_work(struct aoedev *d)
...@@ -252,7 +268,7 @@ aoecmd_work(struct aoedev *d) ...@@ -252,7 +268,7 @@ aoecmd_work(struct aoedev *d)
} }
loop: loop:
f = getframe(d, FREETAG); f = freeframe(d);
if (f == NULL) if (f == NULL)
return; return;
if (d->inprocess == NULL) { if (d->inprocess == NULL) {
...@@ -260,7 +276,7 @@ aoecmd_work(struct aoedev *d) ...@@ -260,7 +276,7 @@ aoecmd_work(struct aoedev *d)
return; return;
buf = container_of(d->bufq.next, struct buf, bufs); buf = container_of(d->bufq.next, struct buf, bufs);
list_del(d->bufq.next); list_del(d->bufq.next);
/*printk(KERN_INFO "aoecmd_work: bi_size=%ld\n", buf->bio->bi_size); */ /*printk(KERN_DEBUG "aoe: bi_size=%ld\n", buf->bio->bi_size); */
d->inprocess = buf; d->inprocess = buf;
} }
aoecmd_ata_rw(d, f); aoecmd_ata_rw(d, f);
...@@ -272,6 +288,7 @@ rexmit(struct aoedev *d, struct frame *f) ...@@ -272,6 +288,7 @@ rexmit(struct aoedev *d, struct frame *f)
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct aoe_hdr *h; struct aoe_hdr *h;
struct aoe_atahdr *ah;
char buf[128]; char buf[128];
u32 n; u32 n;
...@@ -283,21 +300,41 @@ rexmit(struct aoedev *d, struct frame *f) ...@@ -283,21 +300,41 @@ rexmit(struct aoedev *d, struct frame *f)
d->aoemajor, d->aoeminor, f->tag, jiffies, n); d->aoemajor, d->aoeminor, f->tag, jiffies, n);
aoechr_error(buf); aoechr_error(buf);
h = (struct aoe_hdr *) f->data; skb = f->skb;
h = (struct aoe_hdr *) skb->mac.raw;
ah = (struct aoe_atahdr *) (h+1);
f->tag = n; f->tag = n;
h->tag = cpu_to_be32(n); h->tag = cpu_to_be32(n);
memcpy(h->dst, d->addr, sizeof h->dst); memcpy(h->dst, d->addr, sizeof h->dst);
memcpy(h->src, d->ifp->dev_addr, sizeof h->src); memcpy(h->src, d->ifp->dev_addr, sizeof h->src);
skb = skb_prepare(d, f); n = DEFAULTBCNT / 512;
if (skb) { if (ah->scnt > n) {
skb->next = NULL; ah->scnt = n;
if (d->sendq_hd) if (ah->aflags & AOEAFL_WRITE) {
d->sendq_tl->next = skb; skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr),
else offset_in_page(f->bufaddr), DEFAULTBCNT);
d->sendq_hd = skb; skb->len = sizeof *h + sizeof *ah + DEFAULTBCNT;
d->sendq_tl = skb; skb->data_len = DEFAULTBCNT;
}
if (++d->lostjumbo > (d->nframes << 1))
if (d->maxbcnt != DEFAULTBCNT) {
printk(KERN_INFO "aoe: e%ld.%ld: too many lost jumbo on %s - using 1KB frames.\n",
d->aoemajor, d->aoeminor, d->ifp->name);
d->maxbcnt = DEFAULTBCNT;
d->flags |= DEVFL_MAXBCNT;
}
} }
skb->dev = d->ifp;
skb = skb_clone(skb, GFP_ATOMIC);
if (skb == NULL)
return;
if (d->sendq_hd)
d->sendq_tl->next = skb;
else
d->sendq_hd = skb;
d->sendq_tl = skb;
} }
static int static int
...@@ -340,13 +377,17 @@ rexmit_timer(ulong vp) ...@@ -340,13 +377,17 @@ rexmit_timer(ulong vp)
if (f->tag != FREETAG && tsince(f->tag) >= timeout) { if (f->tag != FREETAG && tsince(f->tag) >= timeout) {
n = f->waited += timeout; n = f->waited += timeout;
n /= HZ; n /= HZ;
if (n > MAXWAIT) { /* waited too long. device failure. */ if (n > aoe_deadsecs) { /* waited too long for response */
aoedev_downdev(d); aoedev_downdev(d);
break; break;
} }
rexmit(d, f); rexmit(d, f);
} }
} }
if (d->flags & DEVFL_KICKME) {
d->flags &= ~DEVFL_KICKME;
aoecmd_work(d);
}
sl = d->sendq_hd; sl = d->sendq_hd;
d->sendq_hd = d->sendq_tl = NULL; d->sendq_hd = d->sendq_tl = NULL;
...@@ -431,8 +472,8 @@ ataid_complete(struct aoedev *d, unsigned char *id) ...@@ -431,8 +472,8 @@ ataid_complete(struct aoedev *d, unsigned char *id)
} }
if (d->ssize != ssize) if (d->ssize != ssize)
printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu " printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu sectors\n",
"sectors\n", (unsigned long long)mac_addr(d->addr), (unsigned long long)mac_addr(d->addr),
d->aoemajor, d->aoeminor, d->aoemajor, d->aoeminor,
d->fw_ver, (long long)ssize); d->fw_ver, (long long)ssize);
d->ssize = ssize; d->ssize = ssize;
...@@ -442,11 +483,9 @@ ataid_complete(struct aoedev *d, unsigned char *id) ...@@ -442,11 +483,9 @@ ataid_complete(struct aoedev *d, unsigned char *id)
d->flags |= DEVFL_NEWSIZE; d->flags |= DEVFL_NEWSIZE;
} else { } else {
if (d->flags & DEVFL_GDALLOC) { if (d->flags & DEVFL_GDALLOC) {
printk(KERN_INFO "aoe: %s: %s e%lu.%lu, %s\n", printk(KERN_ERR "aoe: can't schedule work for e%lu.%lu, %s\n",
__FUNCTION__,
"can't schedule work for",
d->aoemajor, d->aoeminor, d->aoemajor, d->aoeminor,
"it's already on! (This really shouldn't happen).\n"); "it's already on! This shouldn't happen.\n");
return; return;
} }
d->flags |= DEVFL_GDALLOC; d->flags |= DEVFL_GDALLOC;
...@@ -460,8 +499,15 @@ calc_rttavg(struct aoedev *d, int rtt) ...@@ -460,8 +499,15 @@ calc_rttavg(struct aoedev *d, int rtt)
register long n; register long n;
n = rtt; n = rtt;
if (n < MINTIMER) if (n < 0) {
n = MINTIMER; n = -rtt;
if (n < MINTIMER)
n = MINTIMER;
else if (n > MAXTIMER)
n = MAXTIMER;
d->mintimer += (n - d->mintimer) >> 1;
} else if (n < d->mintimer)
n = d->mintimer;
else if (n > MAXTIMER) else if (n > MAXTIMER)
n = MAXTIMER; n = MAXTIMER;
...@@ -474,7 +520,7 @@ void ...@@ -474,7 +520,7 @@ void
aoecmd_ata_rsp(struct sk_buff *skb) aoecmd_ata_rsp(struct sk_buff *skb)
{ {
struct aoedev *d; struct aoedev *d;
struct aoe_hdr *hin; struct aoe_hdr *hin, *hout;
struct aoe_atahdr *ahin, *ahout; struct aoe_atahdr *ahin, *ahout;
struct frame *f; struct frame *f;
struct buf *buf; struct buf *buf;
...@@ -497,8 +543,10 @@ aoecmd_ata_rsp(struct sk_buff *skb) ...@@ -497,8 +543,10 @@ aoecmd_ata_rsp(struct sk_buff *skb)
spin_lock_irqsave(&d->lock, flags); spin_lock_irqsave(&d->lock, flags);
f = getframe(d, be32_to_cpu(hin->tag)); n = be32_to_cpu(hin->tag);
f = getframe(d, n);
if (f == NULL) { if (f == NULL) {
calc_rttavg(d, -tsince(n));
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
snprintf(ebuf, sizeof ebuf, snprintf(ebuf, sizeof ebuf,
"%15s e%d.%d tag=%08x@%08lx\n", "%15s e%d.%d tag=%08x@%08lx\n",
...@@ -514,26 +562,27 @@ aoecmd_ata_rsp(struct sk_buff *skb) ...@@ -514,26 +562,27 @@ aoecmd_ata_rsp(struct sk_buff *skb)
calc_rttavg(d, tsince(f->tag)); calc_rttavg(d, tsince(f->tag));
ahin = (struct aoe_atahdr *) (hin+1); ahin = (struct aoe_atahdr *) (hin+1);
ahout = (struct aoe_atahdr *) (f->data + sizeof(struct aoe_hdr)); hout = (struct aoe_hdr *) f->skb->mac.raw;
ahout = (struct aoe_atahdr *) (hout+1);
buf = f->buf; buf = f->buf;
if (ahout->cmdstat == WIN_IDENTIFY) if (ahout->cmdstat == WIN_IDENTIFY)
d->flags &= ~DEVFL_PAUSE; d->flags &= ~DEVFL_PAUSE;
if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */ if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */
printk(KERN_CRIT "aoe: aoecmd_ata_rsp: ata error cmd=%2.2Xh " printk(KERN_ERR
"stat=%2.2Xh from e%ld.%ld\n", "aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%ld\n",
ahout->cmdstat, ahin->cmdstat, ahout->cmdstat, ahin->cmdstat,
d->aoemajor, d->aoeminor); d->aoemajor, d->aoeminor);
if (buf) if (buf)
buf->flags |= BUFFL_FAIL; buf->flags |= BUFFL_FAIL;
} else { } else {
n = ahout->scnt << 9;
switch (ahout->cmdstat) { switch (ahout->cmdstat) {
case WIN_READ: case WIN_READ:
case WIN_READ_EXT: case WIN_READ_EXT:
n = ahout->scnt << 9;
if (skb->len - sizeof *hin - sizeof *ahin < n) { if (skb->len - sizeof *hin - sizeof *ahin < n) {
printk(KERN_CRIT "aoe: aoecmd_ata_rsp: runt " printk(KERN_ERR
"ata data size in read. skb->len=%d\n", "aoe: runt data size in read. skb->len=%d\n",
skb->len); skb->len);
/* fail frame f? just returning will rexmit. */ /* fail frame f? just returning will rexmit. */
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
...@@ -542,22 +591,49 @@ aoecmd_ata_rsp(struct sk_buff *skb) ...@@ -542,22 +591,49 @@ aoecmd_ata_rsp(struct sk_buff *skb)
memcpy(f->bufaddr, ahin+1, n); memcpy(f->bufaddr, ahin+1, n);
case WIN_WRITE: case WIN_WRITE:
case WIN_WRITE_EXT: case WIN_WRITE_EXT:
if (f->bcnt -= n) {
skb = f->skb;
f->bufaddr += n;
put_lba(ahout, f->lba += ahout->scnt);
n = f->bcnt;
if (n > DEFAULTBCNT)
n = DEFAULTBCNT;
ahout->scnt = n >> 9;
if (ahout->aflags & AOEAFL_WRITE) {
skb_fill_page_desc(skb, 0,
virt_to_page(f->bufaddr),
offset_in_page(f->bufaddr), n);
skb->len = sizeof *hout + sizeof *ahout + n;
skb->data_len = n;
}
f->tag = newtag(d);
hout->tag = cpu_to_be32(f->tag);
skb->dev = d->ifp;
skb = skb_clone(skb, GFP_ATOMIC);
spin_unlock_irqrestore(&d->lock, flags);
if (skb)
aoenet_xmit(skb);
return;
}
if (n > DEFAULTBCNT)
d->lostjumbo = 0;
break; break;
case WIN_IDENTIFY: case WIN_IDENTIFY:
if (skb->len - sizeof *hin - sizeof *ahin < 512) { if (skb->len - sizeof *hin - sizeof *ahin < 512) {
printk(KERN_INFO "aoe: aoecmd_ata_rsp: runt data size " printk(KERN_INFO
"in ataid. skb->len=%d\n", skb->len); "aoe: runt data size in ataid. skb->len=%d\n",
skb->len);
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
return; return;
} }
ataid_complete(d, (char *) (ahin+1)); ataid_complete(d, (char *) (ahin+1));
break; break;
default: default:
printk(KERN_INFO "aoe: aoecmd_ata_rsp: unrecognized " printk(KERN_INFO
"outbound ata command %2.2Xh for %d.%d\n", "aoe: unrecognized ata command %2.2Xh for %d.%d\n",
ahout->cmdstat, ahout->cmdstat,
be16_to_cpu(hin->major), be16_to_cpu(hin->major),
hin->minor); hin->minor);
} }
} }
...@@ -612,33 +688,32 @@ aoecmd_ata_id(struct aoedev *d) ...@@ -612,33 +688,32 @@ aoecmd_ata_id(struct aoedev *d)
struct frame *f; struct frame *f;
struct sk_buff *skb; struct sk_buff *skb;
f = getframe(d, FREETAG); f = freeframe(d);
if (f == NULL) { if (f == NULL) {
printk(KERN_CRIT "aoe: aoecmd_ata_id: can't get a frame. " printk(KERN_ERR "aoe: can't get a frame. This shouldn't happen.\n");
"This shouldn't happen.\n");
return NULL; return NULL;
} }
/* initialize the headers & frame */ /* initialize the headers & frame */
h = (struct aoe_hdr *) f->data; skb = f->skb;
h = (struct aoe_hdr *) skb->mac.raw;
ah = (struct aoe_atahdr *) (h+1); ah = (struct aoe_atahdr *) (h+1);
f->ndata = sizeof *h + sizeof *ah; skb->len = ETH_ZLEN;
memset(h, 0, f->ndata); memset(h, 0, ETH_ZLEN);
f->tag = aoehdr_atainit(d, h); f->tag = aoehdr_atainit(d, h);
f->waited = 0; f->waited = 0;
f->writedatalen = 0;
/* set up ata header */ /* set up ata header */
ah->scnt = 1; ah->scnt = 1;
ah->cmdstat = WIN_IDENTIFY; ah->cmdstat = WIN_IDENTIFY;
ah->lba3 = 0xa0; ah->lba3 = 0xa0;
skb = skb_prepare(d, f); skb->dev = d->ifp;
d->rttavg = MAXTIMER; d->rttavg = MAXTIMER;
d->timer.function = rexmit_timer; d->timer.function = rexmit_timer;
return skb; return skb_clone(skb, GFP_ATOMIC);
} }
void void
...@@ -648,9 +723,9 @@ aoecmd_cfg_rsp(struct sk_buff *skb) ...@@ -648,9 +723,9 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
struct aoe_hdr *h; struct aoe_hdr *h;
struct aoe_cfghdr *ch; struct aoe_cfghdr *ch;
ulong flags, sysminor, aoemajor; ulong flags, sysminor, aoemajor;
u16 bufcnt;
struct sk_buff *sl; struct sk_buff *sl;
enum { MAXFRAMES = 16 }; enum { MAXFRAMES = 16 };
u16 n;
h = (struct aoe_hdr *) skb->mac.raw; h = (struct aoe_hdr *) skb->mac.raw;
ch = (struct aoe_cfghdr *) (h+1); ch = (struct aoe_cfghdr *) (h+1);
...@@ -661,26 +736,25 @@ aoecmd_cfg_rsp(struct sk_buff *skb) ...@@ -661,26 +736,25 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
*/ */
aoemajor = be16_to_cpu(h->major); aoemajor = be16_to_cpu(h->major);
if (aoemajor == 0xfff) { if (aoemajor == 0xfff) {
printk(KERN_CRIT "aoe: aoecmd_cfg_rsp: Warning: shelf " printk(KERN_ERR "aoe: Warning: shelf address is all ones. "
"address is all ones. Check shelf dip switches\n"); "Check shelf dip switches.\n");
return; return;
} }
sysminor = SYSMINOR(aoemajor, h->minor); sysminor = SYSMINOR(aoemajor, h->minor);
if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) { if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) {
printk(KERN_INFO printk(KERN_INFO "aoe: e%ld.%d: minor number too large\n",
"aoe: e%ld.%d: minor number too large\n",
aoemajor, (int) h->minor); aoemajor, (int) h->minor);
return; return;
} }
bufcnt = be16_to_cpu(ch->bufcnt); n = be16_to_cpu(ch->bufcnt);
if (bufcnt > MAXFRAMES) /* keep it reasonable */ if (n > MAXFRAMES) /* keep it reasonable */
bufcnt = MAXFRAMES; n = MAXFRAMES;
d = aoedev_by_sysminor_m(sysminor, bufcnt); d = aoedev_by_sysminor_m(sysminor, n);
if (d == NULL) { if (d == NULL) {
printk(KERN_INFO "aoe: aoecmd_cfg_rsp: device sysminor_m failure\n"); printk(KERN_INFO "aoe: device sysminor_m failure\n");
return; return;
} }
...@@ -689,6 +763,20 @@ aoecmd_cfg_rsp(struct sk_buff *skb) ...@@ -689,6 +763,20 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
/* permit device to migrate mac and network interface */ /* permit device to migrate mac and network interface */
d->ifp = skb->dev; d->ifp = skb->dev;
memcpy(d->addr, h->src, sizeof d->addr); memcpy(d->addr, h->src, sizeof d->addr);
if (!(d->flags & DEVFL_MAXBCNT)) {
n = d->ifp->mtu;
n -= sizeof (struct aoe_hdr) + sizeof (struct aoe_atahdr);
n /= 512;
if (n > ch->scnt)
n = ch->scnt;
n = n ? n * 512 : DEFAULTBCNT;
if (n != d->maxbcnt) {
printk(KERN_INFO
"aoe: e%ld.%ld: setting %d byte data frames on %s\n",
d->aoemajor, d->aoeminor, n, d->ifp->name);
d->maxbcnt = n;
}
}
/* don't change users' perspective */ /* don't change users' perspective */
if (d->nopen && !(d->flags & DEVFL_PAUSE)) { if (d->nopen && !(d->flags & DEVFL_PAUSE)) {
...@@ -696,6 +784,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb) ...@@ -696,6 +784,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
return; return;
} }
d->flags |= DEVFL_PAUSE; /* force pause */ d->flags |= DEVFL_PAUSE; /* force pause */
d->mintimer = MINTIMER;
d->fw_ver = be16_to_cpu(ch->fwver); d->fw_ver = be16_to_cpu(ch->fwver);
/* check for already outstanding ataid */ /* check for already outstanding ataid */
......
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
/* /*
* aoedev.c * aoedev.c
* AoE device utility functions; maintains device list. * AoE device utility functions; maintains device list.
...@@ -20,11 +20,8 @@ aoedev_isbusy(struct aoedev *d) ...@@ -20,11 +20,8 @@ aoedev_isbusy(struct aoedev *d)
f = d->frames; f = d->frames;
e = f + d->nframes; e = f + d->nframes;
do { do {
if (f->tag != FREETAG) { if (f->tag != FREETAG)
printk(KERN_DEBUG "aoe: %ld.%ld isbusy\n",
d->aoemajor, d->aoeminor);
return 1; return 1;
}
} while (++f < e); } while (++f < e);
return 0; return 0;
...@@ -66,22 +63,32 @@ aoedev_newdev(ulong nframes) ...@@ -66,22 +63,32 @@ aoedev_newdev(ulong nframes)
struct frame *f, *e; struct frame *f, *e;
d = kzalloc(sizeof *d, GFP_ATOMIC); d = kzalloc(sizeof *d, GFP_ATOMIC);
if (d == NULL)
return NULL;
f = kcalloc(nframes, sizeof *f, GFP_ATOMIC); f = kcalloc(nframes, sizeof *f, GFP_ATOMIC);
if (f == NULL) { switch (!d || !f) {
kfree(d); case 0:
d->nframes = nframes;
d->frames = f;
e = f + nframes;
for (; f<e; f++) {
f->tag = FREETAG;
f->skb = new_skb(ETH_ZLEN);
if (!f->skb)
break;
}
if (f == e)
break;
while (f > d->frames) {
f--;
dev_kfree_skb(f->skb);
}
default:
if (f)
kfree(f);
if (d)
kfree(d);
return NULL; return NULL;
} }
INIT_WORK(&d->work, aoecmd_sleepwork, d); INIT_WORK(&d->work, aoecmd_sleepwork, d);
d->nframes = nframes;
d->frames = f;
e = f + nframes;
for (; f<e; f++)
f->tag = FREETAG;
spin_lock_init(&d->lock); spin_lock_init(&d->lock);
init_timer(&d->timer); init_timer(&d->timer);
d->timer.data = (ulong) d; d->timer.data = (ulong) d;
...@@ -114,6 +121,7 @@ aoedev_downdev(struct aoedev *d) ...@@ -114,6 +121,7 @@ aoedev_downdev(struct aoedev *d)
mempool_free(buf, d->bufpool); mempool_free(buf, d->bufpool);
bio_endio(bio, bio->bi_size, -EIO); bio_endio(bio, bio->bi_size, -EIO);
} }
skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
} }
d->inprocess = NULL; d->inprocess = NULL;
...@@ -148,7 +156,7 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt) ...@@ -148,7 +156,7 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt)
d = aoedev_newdev(bufcnt); d = aoedev_newdev(bufcnt);
if (d == NULL) { if (d == NULL) {
spin_unlock_irqrestore(&devlist_lock, flags); spin_unlock_irqrestore(&devlist_lock, flags);
printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); printk(KERN_INFO "aoe: aoedev_newdev failure.\n");
return NULL; return NULL;
} }
d->sysminor = sysminor; d->sysminor = sysminor;
...@@ -163,11 +171,19 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt) ...@@ -163,11 +171,19 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt)
static void static void
aoedev_freedev(struct aoedev *d) aoedev_freedev(struct aoedev *d)
{ {
struct frame *f, *e;
if (d->gd) { if (d->gd) {
aoedisk_rm_sysfs(d); aoedisk_rm_sysfs(d);
del_gendisk(d->gd); del_gendisk(d->gd);
put_disk(d->gd); put_disk(d->gd);
} }
f = d->frames;
e = f + d->nframes;
for (; f<e; f++) {
skb_shinfo(f->skb)->nr_frags = 0;
dev_kfree_skb(f->skb);
}
kfree(d->frames); kfree(d->frames);
if (d->bufpool) if (d->bufpool)
mempool_destroy(d->bufpool); mempool_destroy(d->bufpool);
......
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
/* /*
* aoemain.c * aoemain.c
* Module initialization routines, discover timer * Module initialization routines, discover timer
...@@ -84,13 +84,11 @@ aoe_init(void) ...@@ -84,13 +84,11 @@ aoe_init(void)
goto net_fail; goto net_fail;
ret = register_blkdev(AOE_MAJOR, DEVICE_NAME); ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "aoe: aoeblk_init: can't register major\n"); printk(KERN_ERR "aoe: can't register major\n");
goto blkreg_fail; goto blkreg_fail;
} }
printk(KERN_INFO printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
"aoe: aoe_init: AoE v%s initialised.\n",
VERSION);
discover_timer(TINIT); discover_timer(TINIT);
return 0; return 0;
...@@ -103,7 +101,7 @@ aoe_init(void) ...@@ -103,7 +101,7 @@ aoe_init(void)
chr_fail: chr_fail:
aoedev_exit(); aoedev_exit();
printk(KERN_INFO "aoe: aoe_init: initialisation failure.\n"); printk(KERN_INFO "aoe: initialisation failure.\n");
return ret; return ret;
} }
......
/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
/* /*
* aoenet.c * aoenet.c
* Ethernet portion of AoE driver * Ethernet portion of AoE driver
...@@ -74,7 +74,7 @@ set_aoe_iflist(const char __user *user_str, size_t size) ...@@ -74,7 +74,7 @@ set_aoe_iflist(const char __user *user_str, size_t size)
return -EINVAL; return -EINVAL;
if (copy_from_user(aoe_iflist, user_str, size)) { if (copy_from_user(aoe_iflist, user_str, size)) {
printk(KERN_INFO "aoe: %s: copy from user failed\n", __FUNCTION__); printk(KERN_INFO "aoe: copy from user failed\n");
return -EFAULT; return -EFAULT;
} }
aoe_iflist[size] = 0x00; aoe_iflist[size] = 0x00;
...@@ -132,8 +132,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, ...@@ -132,8 +132,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
if (n > NECODES) if (n > NECODES)
n = 0; n = 0;
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR "aoe: aoenet_rcv: error packet from %d.%d; " printk(KERN_ERR "aoe: error packet from %d.%d; ecode=%d '%s'\n",
"ecode=%d '%s'\n",
be16_to_cpu(h->major), h->minor, be16_to_cpu(h->major), h->minor,
h->err, aoe_errlist[n]); h->err, aoe_errlist[n]);
goto exit; goto exit;
...@@ -147,7 +146,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, ...@@ -147,7 +146,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
aoecmd_cfg_rsp(skb); aoecmd_cfg_rsp(skb);
break; break;
default: default:
printk(KERN_INFO "aoe: aoenet_rcv: unknown cmd %d\n", h->cmd); printk(KERN_INFO "aoe: unknown cmd %d\n", h->cmd);
} }
exit: exit:
dev_kfree_skb(skb); dev_kfree_skb(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment