Lines Matching refs:d

24 static int count_targets(struct aoedev *d, int *untainted);
78 getframe_deferred(struct aoedev *d, u32 tag) in getframe_deferred() argument
83 head = &d->rexmitq; in getframe_deferred()
95 getframe(struct aoedev *d, u32 tag) in getframe() argument
102 head = &d->factive[n]; in getframe()
119 newtag(struct aoedev *d) in newtag() argument
124 return n | (++d->lasttag & 0x7fff) << 16; in newtag()
128 aoehdr_atainit(struct aoedev *d, struct aoetgt *t, struct aoe_hdr *h) in aoehdr_atainit() argument
130 u32 host_tag = newtag(d); in aoehdr_atainit()
136 h->major = cpu_to_be16(d->aoemajor); in aoehdr_atainit()
137 h->minor = d->aoeminor; in aoehdr_atainit()
170 skb_pool_put(struct aoedev *d, struct sk_buff *skb) in skb_pool_put() argument
172 __skb_queue_tail(&d->skbpool, skb); in skb_pool_put()
176 skb_pool_get(struct aoedev *d) in skb_pool_get() argument
178 struct sk_buff *skb = skb_peek(&d->skbpool); in skb_pool_get()
181 __skb_unlink(skb, &d->skbpool); in skb_pool_get()
184 if (skb_queue_len(&d->skbpool) < NSKBPOOLMAX && in skb_pool_get()
205 newtframe(struct aoedev *d, struct aoetgt *t) in newtframe() argument
235 skb = skb_pool_get(d); in newtframe()
238 skb_pool_put(d, f->skb); in newtframe()
249 newframe(struct aoedev *d) in newframe() argument
257 if (!d->targets || !d->targets[0]) { in newframe()
261 tt = d->tgt; /* last used target */ in newframe()
264 if (tt >= &d->targets[d->ntargets] || !*tt) in newframe()
265 tt = d->targets; in newframe()
274 f = newtframe(d, t); in newframe()
277 d->tgt = tt; in newframe()
281 if (tt == d->tgt) { /* we've looped and found nada */ in newframe()
289 d->kicked++; in newframe()
290 d->flags |= DEVFL_KICKME; in newframe()
309 struct aoedev *d = f->t->d; in fhash() local
313 list_add_tail(&f->head, &d->factive[n]); in fhash()
335 f->tag = aoehdr_atainit(t->d, t, h); in ata_rw_frameinit()
344 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()
454 resend(struct aoedev *d, struct frame *f) in resend() argument
464 n = newtag(d); in resend()
477 "retransmit", d->aoemajor, d->aoeminor, in resend()
564 nf = newframe(f->t->d); in reassign_frame()
587 struct aoedev *d; in probe() local
594 d = t->d; in probe()
595 f = newtframe(d, t); in probe()
600 (long) d->aoemajor, d->aoeminor, in probe()
606 f->iter.bi_size = t->d->maxbcnt ? t->d->maxbcnt : DEFAULTBCNT; in probe()
632 rto(struct aoedev *d) in rto() argument
636 t = 2 * d->rttavg >> RTTSCALE; in rto()
637 t += 8 * d->rttdev >> RTTDSCALE; in rto()
645 rexmit_deferred(struct aoedev *d) in rexmit_deferred() argument
654 count_targets(d, &untainted); in rexmit_deferred()
656 head = &d->rexmitq; in rexmit_deferred()
678 } else if (tsince_hr(f) < t->taint * rto(d)) { in rexmit_deferred()
687 f->t->d->flags |= DEVFL_KICKME; in rexmit_deferred()
699 resend(d, f); in rexmit_deferred()
720 count_targets(struct aoedev *d, int *untainted) in count_targets() argument
724 for (i = good = 0; i < d->ntargets && d->targets[i]; ++i) in count_targets()
725 if (d->targets[i]->taint == 0) in count_targets()
736 struct aoedev *d; in rexmit_timer() local
748 d = timer_container_of(d, timer, timer); in rexmit_timer()
750 spin_lock_irqsave(&d->lock, flags); in rexmit_timer()
753 timeout = rto(d); in rexmit_timer()
755 utgts = count_targets(d, NULL); in rexmit_timer()
757 if (d->flags & (DEVFL_TKILL | DEVFL_DEAD)) { in rexmit_timer()
758 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
764 head = &d->factive[i]; in rexmit_timer()
788 list_splice(&flist, &d->factive[0]); in rexmit_timer()
789 d->flags |= DEVFL_DEAD; in rexmit_timer()
790 queue_work(aoe_wq, &d->work); in rexmit_timer()
816 list_move_tail(pos, &d->rexmitq); in rexmit_timer()
819 rexmit_deferred(d); in rexmit_timer()
822 if ((d->flags & DEVFL_KICKME) && d->blkq) { in rexmit_timer()
823 d->flags &= ~DEVFL_KICKME; in rexmit_timer()
824 blk_mq_run_hw_queues(d->blkq, true); in rexmit_timer()
827 d->timer.expires = jiffies + TIMERTICK; in rexmit_timer()
828 add_timer(&d->timer); in rexmit_timer()
830 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
843 nextbuf(struct aoedev *d) in nextbuf() argument
851 q = d->blkq; in nextbuf()
854 if (d->ip.buf) in nextbuf()
855 return d->ip.buf; in nextbuf()
856 rq = d->ip.rq; in nextbuf()
858 rq = list_first_entry_or_null(&d->rq_list, struct request, in nextbuf()
864 d->ip.rq = rq; in nextbuf()
865 d->ip.nxbio = rq->bio; in nextbuf()
872 buf = mempool_alloc(d->bufpool, GFP_ATOMIC); in nextbuf()
877 bio = d->ip.nxbio; in nextbuf()
880 d->ip.nxbio = bio; in nextbuf()
882 d->ip.rq = NULL; in nextbuf()
883 return d->ip.buf = buf; in nextbuf()
888 aoecmd_work(struct aoedev *d) in aoecmd_work() argument
890 rexmit_deferred(d); in aoecmd_work()
891 while (aoecmd_ata_rw(d)) in aoecmd_work()
900 struct aoedev *d = container_of(work, struct aoedev, work); in aoecmd_sleepwork() local
902 if (d->flags & DEVFL_DEAD) in aoecmd_sleepwork()
903 aoedev_downdev(d); in aoecmd_sleepwork()
905 if (d->flags & DEVFL_GDALLOC) in aoecmd_sleepwork()
906 aoeblk_gdalloc(d); in aoecmd_sleepwork()
908 if (d->flags & DEVFL_NEWSIZE) { in aoecmd_sleepwork()
909 set_capacity_and_notify(d->gd, d->ssize); in aoecmd_sleepwork()
911 spin_lock_irq(&d->lock); in aoecmd_sleepwork()
912 d->flags |= DEVFL_UP; in aoecmd_sleepwork()
913 d->flags &= ~DEVFL_NEWSIZE; in aoecmd_sleepwork()
914 spin_unlock_irq(&d->lock); in aoecmd_sleepwork()
930 ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) in ataid_complete() argument
942 d->flags |= DEVFL_EXT; in ataid_complete()
948 d->geo.cylinders = ssize; in ataid_complete()
949 d->geo.cylinders /= (255 * 63); in ataid_complete()
950 d->geo.heads = 255; in ataid_complete()
951 d->geo.sectors = 63; in ataid_complete()
953 d->flags &= ~DEVFL_EXT; in ataid_complete()
959 d->geo.cylinders = get_unaligned_le16(&id[54 << 1]); in ataid_complete()
960 d->geo.heads = get_unaligned_le16(&id[55 << 1]); in ataid_complete()
961 d->geo.sectors = get_unaligned_le16(&id[56 << 1]); in ataid_complete()
967 memcpy(d->ident, id, sizeof(d->ident)); in ataid_complete()
969 if (d->ssize != ssize) in ataid_complete()
973 d->aoemajor, d->aoeminor, in ataid_complete()
974 d->fw_ver, (long long)ssize); in ataid_complete()
975 d->ssize = ssize; in ataid_complete()
976 d->geo.start = 0; in ataid_complete()
977 if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) in ataid_complete()
979 if (d->gd != NULL) in ataid_complete()
980 d->flags |= DEVFL_NEWSIZE; in ataid_complete()
982 d->flags |= DEVFL_GDALLOC; in ataid_complete()
983 queue_work(aoe_wq, &d->work); in ataid_complete()
987 calc_rttavg(struct aoedev *d, struct aoetgt *t, int rtt) in calc_rttavg() argument
994 n -= d->rttavg >> RTTSCALE; in calc_rttavg()
995 d->rttavg += n; in calc_rttavg()
998 n -= d->rttdev >> RTTDSCALE; in calc_rttavg()
999 d->rttdev += n; in calc_rttavg()
1012 gettgt(struct aoedev *d, char *addr) in gettgt() argument
1016 t = d->targets; in gettgt()
1017 e = t + d->ntargets; in gettgt()
1041 aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) in aoe_end_request() argument
1048 q = d->blkq; in aoe_end_request()
1049 if (rq == d->ip.rq) in aoe_end_request()
1050 d->ip.rq = NULL; in aoe_end_request()
1066 aoe_end_buf(struct aoedev *d, struct buf *buf) in aoe_end_buf() argument
1071 if (buf == d->ip.buf) in aoe_end_buf()
1072 d->ip.buf = NULL; in aoe_end_buf()
1073 mempool_free(buf, d->bufpool); in aoe_end_buf()
1075 aoe_end_request(d, rq, 0); in aoe_end_buf()
1087 struct aoedev *d; in ktiocomplete() local
1095 d = t->d; in ktiocomplete()
1113 d->aoemajor, d->aoeminor); in ktiocomplete()
1126 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1134 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1143 spin_lock_irq(&d->lock); in ktiocomplete()
1147 spin_unlock_irq(&d->lock); in ktiocomplete()
1153 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1159 spin_lock_irq(&d->lock); in ktiocomplete()
1160 ataid_complete(d, t, skb->data); in ktiocomplete()
1161 spin_unlock_irq(&d->lock); in ktiocomplete()
1170 spin_lock_irq(&d->lock); in ktiocomplete()
1174 count_targets(d, &untainted); in ktiocomplete()
1184 aoe_end_buf(d, buf); in ktiocomplete()
1186 spin_unlock_irq(&d->lock); in ktiocomplete()
1187 aoedev_put(d); in ktiocomplete()
1214 actual_id = f->t->d->aoeminor % ncpus; in ktio()
1287 id = f->t->d->aoeminor % ncpus; in ktcomplete()
1306 struct aoedev *d; in aoecmd_ata_rsp() local
1316 d = aoedev_by_aoeaddr(aoemajor, h->minor, 0); in aoecmd_ata_rsp()
1317 if (d == NULL) { in aoecmd_ata_rsp()
1325 spin_lock_irqsave(&d->lock, flags); in aoecmd_ata_rsp()
1328 f = getframe(d, n); in aoecmd_ata_rsp()
1330 calc_rttavg(d, f->t, tsince_hr(f)); in aoecmd_ata_rsp()
1335 f = getframe_deferred(d, n); in aoecmd_ata_rsp()
1337 calc_rttavg(d, NULL, tsince_hr(f)); in aoecmd_ata_rsp()
1339 calc_rttavg(d, NULL, tsince(n)); in aoecmd_ata_rsp()
1340 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1341 aoedev_put(d); in aoecmd_ata_rsp()
1355 aoecmd_work(d); in aoecmd_ata_rsp()
1357 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1379 aoecmd_ata_id(struct aoedev *d) in aoecmd_ata_id() argument
1387 f = newframe(d); in aoecmd_ata_id()
1391 t = *d->tgt; in aoecmd_ata_id()
1399 f->tag = aoehdr_atainit(d, t, h); in aoecmd_ata_id()
1413 d->rttavg = RTTAVG_INIT; in aoecmd_ata_id()
1414 d->rttdev = RTTDEV_INIT; in aoecmd_ata_id()
1415 d->timer.function = rexmit_timer; in aoecmd_ata_id()
1427 grow_targets(struct aoedev *d) in grow_targets() argument
1432 oldn = d->ntargets; in grow_targets()
1434 tt = kzalloc_objs(*d->targets, newn, GFP_ATOMIC); in grow_targets()
1437 memmove(tt, d->targets, sizeof(*d->targets) * oldn); in grow_targets()
1438 d->tgt = tt + (d->tgt - d->targets); in grow_targets()
1439 kfree(d->targets); in grow_targets()
1440 d->targets = tt; in grow_targets()
1441 d->ntargets = newn; in grow_targets()
1443 return &d->targets[oldn]; in grow_targets()
1447 addtgt(struct aoedev *d, char *addr, ulong nframes) in addtgt() argument
1451 tt = d->targets; in addtgt()
1452 te = tt + d->ntargets; in addtgt()
1457 tt = grow_targets(d); in addtgt()
1465 t->d = d; in addtgt()
1479 setdbcnt(struct aoedev *d) in setdbcnt() argument
1484 t = d->targets; in setdbcnt()
1485 e = t + d->ntargets; in setdbcnt()
1489 if (bcnt != d->maxbcnt) { in setdbcnt()
1490 d->maxbcnt = bcnt; in setdbcnt()
1492 d->aoemajor, d->aoeminor, bcnt); in setdbcnt()
1499 struct aoedev *d; in setifbcnt() local
1503 d = t->d; in setifbcnt()
1526 setdbcnt(d); in setifbcnt()
1532 struct aoedev *d; in aoecmd_cfg_rsp() local
1570 d = aoedev_by_aoeaddr(aoemajor, h->minor, 1); in aoecmd_cfg_rsp()
1571 if (d == NULL) { in aoecmd_cfg_rsp()
1576 spin_lock_irqsave(&d->lock, flags); in aoecmd_cfg_rsp()
1578 t = gettgt(d, h->src); in aoecmd_cfg_rsp()
1584 t = addtgt(d, h->src, n); in aoecmd_cfg_rsp()
1597 if (d->nopen == 0) { in aoecmd_cfg_rsp()
1598 d->fw_ver = be16_to_cpu(ch->fwver); in aoecmd_cfg_rsp()
1599 sl = aoecmd_ata_id(d); in aoecmd_cfg_rsp()
1602 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_cfg_rsp()
1603 aoedev_put(d); in aoecmd_cfg_rsp()
1620 aoecmd_cleanslate(struct aoedev *d) in aoecmd_cleanslate() argument
1624 d->rttavg = RTTAVG_INIT; in aoecmd_cleanslate()
1625 d->rttdev = RTTDEV_INIT; in aoecmd_cleanslate()
1626 d->maxbcnt = 0; in aoecmd_cleanslate()
1628 t = d->targets; in aoecmd_cleanslate()
1629 te = t + d->ntargets; in aoecmd_cleanslate()
1635 aoe_failbuf(struct aoedev *d, struct buf *buf) in aoe_failbuf() argument
1642 aoe_end_buf(d, buf); in aoe_failbuf()
1660 struct aoedev *d; in aoe_flush_iocq_by_index() local
1673 d = f->t->d; in aoe_flush_iocq_by_index()
1675 spin_lock_irqsave(&d->lock, flags); in aoe_flush_iocq_by_index()
1678 aoe_failbuf(d, f->buf); in aoe_flush_iocq_by_index()
1681 spin_unlock_irqrestore(&d->lock, flags); in aoe_flush_iocq_by_index()
1683 aoedev_put(d); in aoe_flush_iocq_by_index()