Lines Matching refs:d
25 static int count_targets(struct aoedev *d, int *untainted);
79 getframe_deferred(struct aoedev *d, u32 tag) in getframe_deferred() argument
84 head = &d->rexmitq; in getframe_deferred()
96 getframe(struct aoedev *d, u32 tag) in getframe() argument
103 head = &d->factive[n]; in getframe()
120 newtag(struct aoedev *d) in newtag() argument
125 return n |= (++d->lasttag & 0x7fff) << 16; in newtag()
129 aoehdr_atainit(struct aoedev *d, struct aoetgt *t, struct aoe_hdr *h) in aoehdr_atainit() argument
131 u32 host_tag = newtag(d); in aoehdr_atainit()
137 h->major = cpu_to_be16(d->aoemajor); in aoehdr_atainit()
138 h->minor = d->aoeminor; in aoehdr_atainit()
171 skb_pool_put(struct aoedev *d, struct sk_buff *skb) in skb_pool_put() argument
173 __skb_queue_tail(&d->skbpool, skb); in skb_pool_put()
177 skb_pool_get(struct aoedev *d) in skb_pool_get() argument
179 struct sk_buff *skb = skb_peek(&d->skbpool); in skb_pool_get()
182 __skb_unlink(skb, &d->skbpool); in skb_pool_get()
185 if (skb_queue_len(&d->skbpool) < NSKBPOOLMAX && in skb_pool_get()
206 newtframe(struct aoedev *d, struct aoetgt *t) in newtframe() argument
236 skb = skb_pool_get(d); in newtframe()
239 skb_pool_put(d, f->skb); in newtframe()
250 newframe(struct aoedev *d) in newframe() argument
258 if (!d->targets || !d->targets[0]) { in newframe()
262 tt = d->tgt; /* last used target */ in newframe()
265 if (tt >= &d->targets[d->ntargets] || !*tt) in newframe()
266 tt = d->targets; in newframe()
275 f = newtframe(d, t); in newframe()
278 d->tgt = tt; in newframe()
282 if (tt == d->tgt) { /* we've looped and found nada */ in newframe()
290 d->kicked++; in newframe()
291 d->flags |= DEVFL_KICKME; in newframe()
310 struct aoedev *d = f->t->d; in fhash() local
314 list_add_tail(&f->head, &d->factive[n]); in fhash()
336 f->tag = aoehdr_atainit(t->d, t, h); in ata_rw_frameinit()
345 if (t->d->flags & DEVFL_EXT) { in ata_rw_frameinit()
369 aoecmd_ata_rw(struct aoedev *d) in aoecmd_ata_rw() argument
376 buf = nextbuf(d); in aoecmd_ata_rw()
379 f = newframe(d); in aoecmd_ata_rw()
387 d->maxbcnt ?: DEFAULTBCNT, in aoecmd_ata_rw()
392 d->ip.buf = NULL; in aoecmd_ata_rw()
453 resend(struct aoedev *d, struct frame *f) in resend() argument
463 n = newtag(d); in resend()
476 "retransmit", d->aoemajor, d->aoeminor, in resend()
577 nf = newframe(f->t->d); in reassign_frame()
601 struct aoedev *d; in probe() local
608 d = t->d; in probe()
609 f = newtframe(d, t); in probe()
614 (long) d->aoemajor, d->aoeminor, in probe()
620 f->iter.bi_size = t->d->maxbcnt ? t->d->maxbcnt : DEFAULTBCNT; in probe()
645 rto(struct aoedev *d) in rto() argument
649 t = 2 * d->rttavg >> RTTSCALE; in rto()
650 t += 8 * d->rttdev >> RTTDSCALE; in rto()
658 rexmit_deferred(struct aoedev *d) in rexmit_deferred() argument
667 count_targets(d, &untainted); in rexmit_deferred()
669 head = &d->rexmitq; in rexmit_deferred()
691 } else if (tsince_hr(f) < t->taint * rto(d)) { in rexmit_deferred()
700 f->t->d->flags |= DEVFL_KICKME; in rexmit_deferred()
712 resend(d, f); in rexmit_deferred()
733 count_targets(struct aoedev *d, int *untainted) in count_targets() argument
737 for (i = good = 0; i < d->ntargets && d->targets[i]; ++i) in count_targets()
738 if (d->targets[i]->taint == 0) in count_targets()
749 struct aoedev *d; in rexmit_timer() local
761 d = (struct aoedev *) vp; in rexmit_timer()
763 spin_lock_irqsave(&d->lock, flags); in rexmit_timer()
766 timeout = rto(d); in rexmit_timer()
768 utgts = count_targets(d, NULL); in rexmit_timer()
770 if (d->flags & DEVFL_TKILL) { in rexmit_timer()
771 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
777 head = &d->factive[i]; in rexmit_timer()
801 list_splice(&flist, &d->factive[0]); in rexmit_timer()
802 aoedev_downdev(d); in rexmit_timer()
828 list_move_tail(pos, &d->rexmitq); in rexmit_timer()
831 rexmit_deferred(d); in rexmit_timer()
834 if ((d->flags & DEVFL_KICKME) && d->blkq) { in rexmit_timer()
835 d->flags &= ~DEVFL_KICKME; in rexmit_timer()
836 d->blkq->request_fn(d->blkq); in rexmit_timer()
839 d->timer.expires = jiffies + TIMERTICK; in rexmit_timer()
840 add_timer(&d->timer); in rexmit_timer()
842 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
906 nextbuf(struct aoedev *d) in nextbuf() argument
913 q = d->blkq; in nextbuf()
916 if (d->ip.buf) in nextbuf()
917 return d->ip.buf; in nextbuf()
918 rq = d->ip.rq; in nextbuf()
924 d->ip.rq = rq; in nextbuf()
925 d->ip.nxbio = rq->bio; in nextbuf()
928 buf = mempool_alloc(d->bufpool, GFP_ATOMIC); in nextbuf()
933 bio = d->ip.nxbio; in nextbuf()
936 d->ip.nxbio = bio; in nextbuf()
938 d->ip.rq = NULL; in nextbuf()
939 return d->ip.buf = buf; in nextbuf()
944 aoecmd_work(struct aoedev *d) in aoecmd_work() argument
946 rexmit_deferred(d); in aoecmd_work()
947 while (aoecmd_ata_rw(d)) in aoecmd_work()
956 struct aoedev *d = container_of(work, struct aoedev, work); in aoecmd_sleepwork() local
960 if (d->flags & DEVFL_GDALLOC) in aoecmd_sleepwork()
961 aoeblk_gdalloc(d); in aoecmd_sleepwork()
963 if (d->flags & DEVFL_NEWSIZE) { in aoecmd_sleepwork()
964 ssize = get_capacity(d->gd); in aoecmd_sleepwork()
965 bd = bdget_disk(d->gd, 0); in aoecmd_sleepwork()
972 spin_lock_irq(&d->lock); in aoecmd_sleepwork()
973 d->flags |= DEVFL_UP; in aoecmd_sleepwork()
974 d->flags &= ~DEVFL_NEWSIZE; in aoecmd_sleepwork()
975 spin_unlock_irq(&d->lock); in aoecmd_sleepwork()
991 ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) in ataid_complete() argument
1003 d->flags |= DEVFL_EXT; in ataid_complete()
1009 d->geo.cylinders = ssize; in ataid_complete()
1010 d->geo.cylinders /= (255 * 63); in ataid_complete()
1011 d->geo.heads = 255; in ataid_complete()
1012 d->geo.sectors = 63; in ataid_complete()
1014 d->flags &= ~DEVFL_EXT; in ataid_complete()
1020 d->geo.cylinders = get_unaligned_le16(&id[54 << 1]); in ataid_complete()
1021 d->geo.heads = get_unaligned_le16(&id[55 << 1]); in ataid_complete()
1022 d->geo.sectors = get_unaligned_le16(&id[56 << 1]); in ataid_complete()
1028 memcpy(d->ident, id, sizeof(d->ident)); in ataid_complete()
1030 if (d->ssize != ssize) in ataid_complete()
1034 d->aoemajor, d->aoeminor, in ataid_complete()
1035 d->fw_ver, (long long)ssize); in ataid_complete()
1036 d->ssize = ssize; in ataid_complete()
1037 d->geo.start = 0; in ataid_complete()
1038 if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) in ataid_complete()
1040 if (d->gd != NULL) { in ataid_complete()
1041 set_capacity(d->gd, ssize); in ataid_complete()
1042 d->flags |= DEVFL_NEWSIZE; in ataid_complete()
1044 d->flags |= DEVFL_GDALLOC; in ataid_complete()
1045 schedule_work(&d->work); in ataid_complete()
1049 calc_rttavg(struct aoedev *d, struct aoetgt *t, int rtt) in calc_rttavg() argument
1056 n -= d->rttavg >> RTTSCALE; in calc_rttavg()
1057 d->rttavg += n; in calc_rttavg()
1060 n -= d->rttdev >> RTTDSCALE; in calc_rttavg()
1061 d->rttdev += n; in calc_rttavg()
1074 gettgt(struct aoedev *d, char *addr) in gettgt() argument
1078 t = d->targets; in gettgt()
1079 e = t + d->ntargets; in gettgt()
1102 aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) in aoe_end_request() argument
1108 q = d->blkq; in aoe_end_request()
1109 if (rq == d->ip.rq) in aoe_end_request()
1110 d->ip.rq = NULL; in aoe_end_request()
1122 aoe_end_buf(struct aoedev *d, struct buf *buf) in aoe_end_buf() argument
1127 if (buf == d->ip.buf) in aoe_end_buf()
1128 d->ip.buf = NULL; in aoe_end_buf()
1131 mempool_free(buf, d->bufpool); in aoe_end_buf()
1135 aoe_end_request(d, rq, 0); in aoe_end_buf()
1147 struct aoedev *d; in ktiocomplete() local
1155 d = t->d; in ktiocomplete()
1173 d->aoemajor, d->aoeminor); in ktiocomplete()
1186 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1194 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1202 spin_lock_irq(&d->lock); in ktiocomplete()
1206 spin_unlock_irq(&d->lock); in ktiocomplete()
1212 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1218 spin_lock_irq(&d->lock); in ktiocomplete()
1219 ataid_complete(d, t, skb->data); in ktiocomplete()
1220 spin_unlock_irq(&d->lock); in ktiocomplete()
1229 spin_lock_irq(&d->lock); in ktiocomplete()
1233 count_targets(d, &untainted); in ktiocomplete()
1243 aoe_end_buf(d, buf); in ktiocomplete()
1245 spin_unlock_irq(&d->lock); in ktiocomplete()
1246 aoedev_put(d); in ktiocomplete()
1273 actual_id = f->t->d->aoeminor % ncpus; in ktio()
1346 id = f->t->d->aoeminor % ncpus; in ktcomplete()
1365 struct aoedev *d; in aoecmd_ata_rsp() local
1375 d = aoedev_by_aoeaddr(aoemajor, h->minor, 0); in aoecmd_ata_rsp()
1376 if (d == NULL) { in aoecmd_ata_rsp()
1384 spin_lock_irqsave(&d->lock, flags); in aoecmd_ata_rsp()
1387 f = getframe(d, n); in aoecmd_ata_rsp()
1389 calc_rttavg(d, f->t, tsince_hr(f)); in aoecmd_ata_rsp()
1394 f = getframe_deferred(d, n); in aoecmd_ata_rsp()
1396 calc_rttavg(d, NULL, tsince_hr(f)); in aoecmd_ata_rsp()
1398 calc_rttavg(d, NULL, tsince(n)); in aoecmd_ata_rsp()
1399 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1400 aoedev_put(d); in aoecmd_ata_rsp()
1414 aoecmd_work(d); in aoecmd_ata_rsp()
1416 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1438 aoecmd_ata_id(struct aoedev *d) in aoecmd_ata_id() argument
1446 f = newframe(d); in aoecmd_ata_id()
1450 t = *d->tgt; in aoecmd_ata_id()
1458 f->tag = aoehdr_atainit(d, t, h); in aoecmd_ata_id()
1471 d->rttavg = RTTAVG_INIT; in aoecmd_ata_id()
1472 d->rttdev = RTTDEV_INIT; in aoecmd_ata_id()
1473 d->timer.function = rexmit_timer; in aoecmd_ata_id()
1485 grow_targets(struct aoedev *d) in grow_targets() argument
1490 oldn = d->ntargets; in grow_targets()
1492 tt = kcalloc(newn, sizeof(*d->targets), GFP_ATOMIC); in grow_targets()
1495 memmove(tt, d->targets, sizeof(*d->targets) * oldn); in grow_targets()
1496 d->tgt = tt + (d->tgt - d->targets); in grow_targets()
1497 kfree(d->targets); in grow_targets()
1498 d->targets = tt; in grow_targets()
1499 d->ntargets = newn; in grow_targets()
1501 return &d->targets[oldn]; in grow_targets()
1505 addtgt(struct aoedev *d, char *addr, ulong nframes) in addtgt() argument
1509 tt = d->targets; in addtgt()
1510 te = tt + d->ntargets; in addtgt()
1515 tt = grow_targets(d); in addtgt()
1523 t->d = d; in addtgt()
1537 setdbcnt(struct aoedev *d) in setdbcnt() argument
1542 t = d->targets; in setdbcnt()
1543 e = t + d->ntargets; in setdbcnt()
1547 if (bcnt != d->maxbcnt) { in setdbcnt()
1548 d->maxbcnt = bcnt; in setdbcnt()
1550 d->aoemajor, d->aoeminor, bcnt); in setdbcnt()
1557 struct aoedev *d; in setifbcnt() local
1561 d = t->d; in setifbcnt()
1584 setdbcnt(d); in setifbcnt()
1590 struct aoedev *d; in aoecmd_cfg_rsp() local
1628 d = aoedev_by_aoeaddr(aoemajor, h->minor, 1); in aoecmd_cfg_rsp()
1629 if (d == NULL) { in aoecmd_cfg_rsp()
1634 spin_lock_irqsave(&d->lock, flags); in aoecmd_cfg_rsp()
1636 t = gettgt(d, h->src); in aoecmd_cfg_rsp()
1642 t = addtgt(d, h->src, n); in aoecmd_cfg_rsp()
1655 if (d->nopen == 0) { in aoecmd_cfg_rsp()
1656 d->fw_ver = be16_to_cpu(ch->fwver); in aoecmd_cfg_rsp()
1657 sl = aoecmd_ata_id(d); in aoecmd_cfg_rsp()
1660 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_cfg_rsp()
1661 aoedev_put(d); in aoecmd_cfg_rsp()
1678 aoecmd_cleanslate(struct aoedev *d) in aoecmd_cleanslate() argument
1682 d->rttavg = RTTAVG_INIT; in aoecmd_cleanslate()
1683 d->rttdev = RTTDEV_INIT; in aoecmd_cleanslate()
1684 d->maxbcnt = 0; in aoecmd_cleanslate()
1686 t = d->targets; in aoecmd_cleanslate()
1687 te = t + d->ntargets; in aoecmd_cleanslate()
1693 aoe_failbuf(struct aoedev *d, struct buf *buf) in aoe_failbuf() argument
1700 aoe_end_buf(d, buf); in aoe_failbuf()
1718 struct aoedev *d; in aoe_flush_iocq_by_index() local
1731 d = f->t->d; in aoe_flush_iocq_by_index()
1733 spin_lock_irqsave(&d->lock, flags); in aoe_flush_iocq_by_index()
1736 aoe_failbuf(d, f->buf); in aoe_flush_iocq_by_index()
1739 spin_unlock_irqrestore(&d->lock, flags); in aoe_flush_iocq_by_index()
1741 aoedev_put(d); in aoe_flush_iocq_by_index()