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()
452 resend(struct aoedev *d, struct frame *f) in resend() argument
462 n = newtag(d); in resend()
475 "retransmit", d->aoemajor, d->aoeminor, in resend()
559 nf = newframe(f->t->d); in reassign_frame()
582 struct aoedev *d; in probe() local
589 d = t->d; in probe()
590 f = newtframe(d, t); in probe()
595 (long) d->aoemajor, d->aoeminor, in probe()
601 f->iter.bi_size = t->d->maxbcnt ? t->d->maxbcnt : DEFAULTBCNT; in probe()
625 rto(struct aoedev *d) in rto() argument
629 t = 2 * d->rttavg >> RTTSCALE; in rto()
630 t += 8 * d->rttdev >> RTTDSCALE; in rto()
638 rexmit_deferred(struct aoedev *d) in rexmit_deferred() argument
647 count_targets(d, &untainted); in rexmit_deferred()
649 head = &d->rexmitq; in rexmit_deferred()
671 } else if (tsince_hr(f) < t->taint * rto(d)) { in rexmit_deferred()
680 f->t->d->flags |= DEVFL_KICKME; in rexmit_deferred()
692 resend(d, f); in rexmit_deferred()
713 count_targets(struct aoedev *d, int *untainted) in count_targets() argument
717 for (i = good = 0; i < d->ntargets && d->targets[i]; ++i) in count_targets()
718 if (d->targets[i]->taint == 0) in count_targets()
729 struct aoedev *d; in rexmit_timer() local
741 d = from_timer(d, timer, timer); in rexmit_timer()
743 spin_lock_irqsave(&d->lock, flags); in rexmit_timer()
746 timeout = rto(d); in rexmit_timer()
748 utgts = count_targets(d, NULL); in rexmit_timer()
750 if (d->flags & DEVFL_TKILL) { in rexmit_timer()
751 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
757 head = &d->factive[i]; in rexmit_timer()
781 list_splice(&flist, &d->factive[0]); in rexmit_timer()
782 aoedev_downdev(d); in rexmit_timer()
808 list_move_tail(pos, &d->rexmitq); in rexmit_timer()
811 rexmit_deferred(d); in rexmit_timer()
814 if ((d->flags & DEVFL_KICKME) && d->blkq) { in rexmit_timer()
815 d->flags &= ~DEVFL_KICKME; in rexmit_timer()
816 blk_mq_run_hw_queues(d->blkq, true); in rexmit_timer()
819 d->timer.expires = jiffies + TIMERTICK; in rexmit_timer()
820 add_timer(&d->timer); in rexmit_timer()
822 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
835 nextbuf(struct aoedev *d) in nextbuf() argument
843 q = d->blkq; in nextbuf()
846 if (d->ip.buf) in nextbuf()
847 return d->ip.buf; in nextbuf()
848 rq = d->ip.rq; in nextbuf()
850 rq = list_first_entry_or_null(&d->rq_list, struct request, in nextbuf()
856 d->ip.rq = rq; in nextbuf()
857 d->ip.nxbio = rq->bio; in nextbuf()
864 buf = mempool_alloc(d->bufpool, GFP_ATOMIC); in nextbuf()
869 bio = d->ip.nxbio; in nextbuf()
872 d->ip.nxbio = bio; in nextbuf()
874 d->ip.rq = NULL; in nextbuf()
875 return d->ip.buf = buf; in nextbuf()
880 aoecmd_work(struct aoedev *d) in aoecmd_work() argument
882 rexmit_deferred(d); in aoecmd_work()
883 while (aoecmd_ata_rw(d)) in aoecmd_work()
892 struct aoedev *d = container_of(work, struct aoedev, work); in aoecmd_sleepwork() local
896 if (d->flags & DEVFL_GDALLOC) in aoecmd_sleepwork()
897 aoeblk_gdalloc(d); in aoecmd_sleepwork()
899 if (d->flags & DEVFL_NEWSIZE) { in aoecmd_sleepwork()
900 ssize = get_capacity(d->gd); in aoecmd_sleepwork()
901 bd = bdget_disk(d->gd, 0); in aoecmd_sleepwork()
906 spin_lock_irq(&d->lock); in aoecmd_sleepwork()
907 d->flags |= DEVFL_UP; in aoecmd_sleepwork()
908 d->flags &= ~DEVFL_NEWSIZE; in aoecmd_sleepwork()
909 spin_unlock_irq(&d->lock); in aoecmd_sleepwork()
925 ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) in ataid_complete() argument
937 d->flags |= DEVFL_EXT; in ataid_complete()
943 d->geo.cylinders = ssize; in ataid_complete()
944 d->geo.cylinders /= (255 * 63); in ataid_complete()
945 d->geo.heads = 255; in ataid_complete()
946 d->geo.sectors = 63; in ataid_complete()
948 d->flags &= ~DEVFL_EXT; in ataid_complete()
954 d->geo.cylinders = get_unaligned_le16(&id[54 << 1]); in ataid_complete()
955 d->geo.heads = get_unaligned_le16(&id[55 << 1]); in ataid_complete()
956 d->geo.sectors = get_unaligned_le16(&id[56 << 1]); in ataid_complete()
962 memcpy(d->ident, id, sizeof(d->ident)); in ataid_complete()
964 if (d->ssize != ssize) in ataid_complete()
968 d->aoemajor, d->aoeminor, in ataid_complete()
969 d->fw_ver, (long long)ssize); in ataid_complete()
970 d->ssize = ssize; in ataid_complete()
971 d->geo.start = 0; in ataid_complete()
972 if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) in ataid_complete()
974 if (d->gd != NULL) { in ataid_complete()
975 set_capacity(d->gd, ssize); in ataid_complete()
976 d->flags |= DEVFL_NEWSIZE; in ataid_complete()
978 d->flags |= DEVFL_GDALLOC; in ataid_complete()
979 schedule_work(&d->work); in ataid_complete()
983 calc_rttavg(struct aoedev *d, struct aoetgt *t, int rtt) in calc_rttavg() argument
990 n -= d->rttavg >> RTTSCALE; in calc_rttavg()
991 d->rttavg += n; in calc_rttavg()
994 n -= d->rttdev >> RTTDSCALE; in calc_rttavg()
995 d->rttdev += n; in calc_rttavg()
1008 gettgt(struct aoedev *d, char *addr) in gettgt() argument
1012 t = d->targets; in gettgt()
1013 e = t + d->ntargets; in gettgt()
1037 aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) in aoe_end_request() argument
1044 q = d->blkq; in aoe_end_request()
1045 if (rq == d->ip.rq) in aoe_end_request()
1046 d->ip.rq = NULL; in aoe_end_request()
1062 aoe_end_buf(struct aoedev *d, struct buf *buf) in aoe_end_buf() argument
1067 if (buf == d->ip.buf) in aoe_end_buf()
1068 d->ip.buf = NULL; in aoe_end_buf()
1069 mempool_free(buf, d->bufpool); in aoe_end_buf()
1071 aoe_end_request(d, rq, 0); in aoe_end_buf()
1083 struct aoedev *d; in ktiocomplete() local
1091 d = t->d; in ktiocomplete()
1109 d->aoemajor, d->aoeminor); in ktiocomplete()
1122 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1130 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1139 spin_lock_irq(&d->lock); in ktiocomplete()
1143 spin_unlock_irq(&d->lock); in ktiocomplete()
1149 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1155 spin_lock_irq(&d->lock); in ktiocomplete()
1156 ataid_complete(d, t, skb->data); in ktiocomplete()
1157 spin_unlock_irq(&d->lock); in ktiocomplete()
1166 spin_lock_irq(&d->lock); in ktiocomplete()
1170 count_targets(d, &untainted); in ktiocomplete()
1180 aoe_end_buf(d, buf); in ktiocomplete()
1182 spin_unlock_irq(&d->lock); in ktiocomplete()
1183 aoedev_put(d); in ktiocomplete()
1210 actual_id = f->t->d->aoeminor % ncpus; in ktio()
1283 id = f->t->d->aoeminor % ncpus; in ktcomplete()
1302 struct aoedev *d; in aoecmd_ata_rsp() local
1312 d = aoedev_by_aoeaddr(aoemajor, h->minor, 0); in aoecmd_ata_rsp()
1313 if (d == NULL) { in aoecmd_ata_rsp()
1321 spin_lock_irqsave(&d->lock, flags); in aoecmd_ata_rsp()
1324 f = getframe(d, n); in aoecmd_ata_rsp()
1326 calc_rttavg(d, f->t, tsince_hr(f)); in aoecmd_ata_rsp()
1331 f = getframe_deferred(d, n); in aoecmd_ata_rsp()
1333 calc_rttavg(d, NULL, tsince_hr(f)); in aoecmd_ata_rsp()
1335 calc_rttavg(d, NULL, tsince(n)); in aoecmd_ata_rsp()
1336 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1337 aoedev_put(d); in aoecmd_ata_rsp()
1351 aoecmd_work(d); in aoecmd_ata_rsp()
1353 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1375 aoecmd_ata_id(struct aoedev *d) in aoecmd_ata_id() argument
1383 f = newframe(d); in aoecmd_ata_id()
1387 t = *d->tgt; in aoecmd_ata_id()
1395 f->tag = aoehdr_atainit(d, t, h); in aoecmd_ata_id()
1408 d->rttavg = RTTAVG_INIT; in aoecmd_ata_id()
1409 d->rttdev = RTTDEV_INIT; in aoecmd_ata_id()
1410 d->timer.function = rexmit_timer; in aoecmd_ata_id()
1420 grow_targets(struct aoedev *d) in grow_targets() argument
1425 oldn = d->ntargets; in grow_targets()
1427 tt = kcalloc(newn, sizeof(*d->targets), GFP_ATOMIC); in grow_targets()
1430 memmove(tt, d->targets, sizeof(*d->targets) * oldn); in grow_targets()
1431 d->tgt = tt + (d->tgt - d->targets); in grow_targets()
1432 kfree(d->targets); in grow_targets()
1433 d->targets = tt; in grow_targets()
1434 d->ntargets = newn; in grow_targets()
1436 return &d->targets[oldn]; in grow_targets()
1440 addtgt(struct aoedev *d, char *addr, ulong nframes) in addtgt() argument
1444 tt = d->targets; in addtgt()
1445 te = tt + d->ntargets; in addtgt()
1450 tt = grow_targets(d); in addtgt()
1458 t->d = d; in addtgt()
1472 setdbcnt(struct aoedev *d) in setdbcnt() argument
1477 t = d->targets; in setdbcnt()
1478 e = t + d->ntargets; in setdbcnt()
1482 if (bcnt != d->maxbcnt) { in setdbcnt()
1483 d->maxbcnt = bcnt; in setdbcnt()
1485 d->aoemajor, d->aoeminor, bcnt); in setdbcnt()
1492 struct aoedev *d; in setifbcnt() local
1496 d = t->d; in setifbcnt()
1519 setdbcnt(d); in setifbcnt()
1525 struct aoedev *d; in aoecmd_cfg_rsp() local
1563 d = aoedev_by_aoeaddr(aoemajor, h->minor, 1); in aoecmd_cfg_rsp()
1564 if (d == NULL) { in aoecmd_cfg_rsp()
1569 spin_lock_irqsave(&d->lock, flags); in aoecmd_cfg_rsp()
1571 t = gettgt(d, h->src); in aoecmd_cfg_rsp()
1577 t = addtgt(d, h->src, n); in aoecmd_cfg_rsp()
1590 if (d->nopen == 0) { in aoecmd_cfg_rsp()
1591 d->fw_ver = be16_to_cpu(ch->fwver); in aoecmd_cfg_rsp()
1592 sl = aoecmd_ata_id(d); in aoecmd_cfg_rsp()
1595 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_cfg_rsp()
1596 aoedev_put(d); in aoecmd_cfg_rsp()
1613 aoecmd_cleanslate(struct aoedev *d) in aoecmd_cleanslate() argument
1617 d->rttavg = RTTAVG_INIT; in aoecmd_cleanslate()
1618 d->rttdev = RTTDEV_INIT; in aoecmd_cleanslate()
1619 d->maxbcnt = 0; in aoecmd_cleanslate()
1621 t = d->targets; in aoecmd_cleanslate()
1622 te = t + d->ntargets; in aoecmd_cleanslate()
1628 aoe_failbuf(struct aoedev *d, struct buf *buf) in aoe_failbuf() argument
1635 aoe_end_buf(d, buf); in aoe_failbuf()
1653 struct aoedev *d; in aoe_flush_iocq_by_index() local
1666 d = f->t->d; in aoe_flush_iocq_by_index()
1668 spin_lock_irqsave(&d->lock, flags); in aoe_flush_iocq_by_index()
1671 aoe_failbuf(d, f->buf); in aoe_flush_iocq_by_index()
1674 spin_unlock_irqrestore(&d->lock, flags); in aoe_flush_iocq_by_index()
1676 aoedev_put(d); in aoe_flush_iocq_by_index()