Lines Matching +full:t +full:- +full:head
10 #include <linux/blk-mq.h>
54 struct list_head head; member
71 skb->protocol = __constant_htons(ETH_P_AOE); in new_skb()
80 struct list_head *head, *pos, *nx; in getframe_deferred() local
83 head = &d->rexmitq; in getframe_deferred()
84 list_for_each_safe(pos, nx, head) { in getframe_deferred()
85 f = list_entry(pos, struct frame, head); in getframe_deferred()
86 if (f->tag == tag) { in getframe_deferred()
98 struct list_head *head, *pos, *nx; in getframe() local
102 head = &d->factive[n]; in getframe()
103 list_for_each_safe(pos, nx, head) { in getframe()
104 f = list_entry(pos, struct frame, head); in getframe()
105 if (f->tag == tag) { in getframe()
116 * This driver reserves tag -1 to mean "unused frame."
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
132 memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src); in aoehdr_atainit()
133 memcpy(h->dst, t->addr, sizeof h->dst); in aoehdr_atainit()
134 h->type = __constant_cpu_to_be16(ETH_P_AOE); in aoehdr_atainit()
135 h->verfl = AOE_HVER; in aoehdr_atainit()
136 h->major = cpu_to_be16(d->aoemajor); in aoehdr_atainit()
137 h->minor = d->aoeminor; in aoehdr_atainit()
138 h->cmd = AOECMD_ATA; in aoehdr_atainit()
139 h->tag = cpu_to_be32(host_tag); in aoehdr_atainit()
147 ah->lba0 = lba; in put_lba()
148 ah->lba1 = lba >>= 8; in put_lba()
149 ah->lba2 = lba >>= 8; in put_lba()
150 ah->lba3 = lba >>= 8; in put_lba()
151 ah->lba4 = lba >>= 8; in put_lba()
152 ah->lba5 = lba >>= 8; in put_lba()
156 ifrotate(struct aoetgt *t) in ifrotate() argument
160 ifp = t->ifp; in ifrotate()
162 if (ifp >= &t->ifs[NAOEIFS] || ifp->nd == NULL) in ifrotate()
163 ifp = t->ifs; in ifrotate()
164 if (ifp->nd == NULL) in ifrotate()
166 return t->ifp = ifp; in ifrotate()
172 __skb_queue_tail(&d->skbpool, skb); in skb_pool_put()
178 struct sk_buff *skb = skb_peek(&d->skbpool); in skb_pool_get()
180 if (skb && atomic_read(&skb_shinfo(skb)->dataref) == 1) { 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()
194 struct aoetgt *t; in aoe_freetframe() local
196 t = f->t; in aoe_freetframe()
197 f->buf = NULL; in aoe_freetframe()
198 memset(&f->iter, 0, sizeof(f->iter)); in aoe_freetframe()
199 f->r_skb = NULL; in aoe_freetframe()
200 f->flags = 0; in aoe_freetframe()
201 list_add(&f->head, &t->ffree); in aoe_freetframe()
205 newtframe(struct aoedev *d, struct aoetgt *t) in newtframe() argument
211 if (list_empty(&t->ffree)) { in newtframe()
212 if (t->falloc >= NSKBPOOLMAX*2) in newtframe()
217 t->falloc++; in newtframe()
218 f->t = t; in newtframe()
220 pos = t->ffree.next; in newtframe()
222 f = list_entry(pos, struct frame, head); in newtframe()
225 skb = f->skb; in newtframe()
227 f->skb = skb = new_skb(ETH_ZLEN); in newtframe()
234 if (atomic_read(&skb_shinfo(skb)->dataref) != 1) { in newtframe()
238 skb_pool_put(d, f->skb); in newtframe()
239 f->skb = skb; in newtframe()
242 skb->truesize -= skb->data_len; in newtframe()
243 skb_shinfo(skb)->nr_frags = skb->data_len = 0; in newtframe()
252 struct aoetgt *t, **tt; in newframe() local
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()
266 t = *tt; in newframe()
267 if (!t->taint) { in newframe()
269 totout += t->nout; in newframe()
271 if (t->nout < t->maxout in newframe()
272 && (use_tainted || !t->taint) in newframe()
273 && t->ifp->nd) { in newframe()
274 f = newtframe(d, t); in newframe()
276 ifrotate(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()
312 n = f->tag % NFACTIVE; in fhash()
313 list_add_tail(&f->head, &d->factive[n]); in fhash()
319 struct aoetgt *t; in ata_rw_frameinit() local
325 skb = f->skb; in ata_rw_frameinit()
329 memset(h, 0, skb->len); in ata_rw_frameinit()
334 t = f->t; in ata_rw_frameinit()
335 f->tag = aoehdr_atainit(t->d, t, h); in ata_rw_frameinit()
337 t->nout++; in ata_rw_frameinit()
338 f->waited = 0; in ata_rw_frameinit()
339 f->waited_total = 0; in ata_rw_frameinit()
342 ah->scnt = f->iter.bi_size >> 9; in ata_rw_frameinit()
343 put_lba(ah, f->iter.bi_sector); in ata_rw_frameinit()
344 if (t->d->flags & DEVFL_EXT) { in ata_rw_frameinit()
345 ah->aflags |= AOEAFL_EXT; in ata_rw_frameinit()
348 ah->lba3 &= 0x0f; in ata_rw_frameinit()
349 ah->lba3 |= 0xe0; /* LBA bit + obsolete 0xa0 */ in ata_rw_frameinit()
351 if (f->buf && bio_data_dir(f->buf->bio) == WRITE) { in ata_rw_frameinit()
352 skb_fillup(skb, f->buf->bio, f->iter); in ata_rw_frameinit()
353 ah->aflags |= AOEAFL_WRITE; in ata_rw_frameinit()
354 skb->len += f->iter.bi_size; in ata_rw_frameinit()
355 skb->data_len = f->iter.bi_size; in ata_rw_frameinit()
356 skb->truesize += f->iter.bi_size; in ata_rw_frameinit()
357 t->wpkts++; in ata_rw_frameinit()
359 t->rpkts++; in ata_rw_frameinit()
363 ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit; in ata_rw_frameinit()
364 dev_hold(t->ifp->nd); in ata_rw_frameinit()
365 skb->dev = t->ifp->nd; in ata_rw_frameinit()
384 f->buf = buf; in aoecmd_ata_rw()
385 f->iter = buf->iter; in aoecmd_ata_rw()
386 f->iter.bi_size = min_t(unsigned long, in aoecmd_ata_rw()
387 d->maxbcnt ?: DEFAULTBCNT, in aoecmd_ata_rw()
388 f->iter.bi_size); in aoecmd_ata_rw()
389 bio_advance_iter(buf->bio, &buf->iter, f->iter.bi_size); in aoecmd_ata_rw()
391 if (!buf->iter.bi_size) in aoecmd_ata_rw()
392 d->ip.buf = NULL; in aoecmd_ata_rw()
395 buf->nframesout += 1; in aoecmd_ata_rw()
399 skb = skb_clone(f->skb, GFP_ATOMIC); in aoecmd_ata_rw()
401 f->sent = ktime_get(); in aoecmd_ata_rw()
406 dev_put(f->t->ifp->nd); in aoecmd_ata_rw()
437 skb->dev = ifp; in aoecmd_cfg_pkts()
442 memset(h->dst, 0xff, sizeof h->dst); in aoecmd_cfg_pkts()
443 memcpy(h->src, ifp->dev_addr, sizeof h->src); in aoecmd_cfg_pkts()
444 h->type = __constant_cpu_to_be16(ETH_P_AOE); in aoecmd_cfg_pkts()
445 h->verfl = AOE_HVER; in aoecmd_cfg_pkts()
446 h->major = cpu_to_be16(aoemajor); in aoecmd_cfg_pkts()
447 h->minor = aoeminor; in aoecmd_cfg_pkts()
448 h->cmd = AOECMD_CFG; in aoecmd_cfg_pkts()
459 struct aoetgt *t; in resend() local
463 t = f->t; in resend()
465 skb = f->skb; in resend()
466 if (ifrotate(t) == NULL) { in resend()
467 /* probably can't happen, but set it up to fail anyway */ in resend()
474 if (!(f->flags & FFL_PROBE)) { in resend()
477 "retransmit", d->aoemajor, d->aoeminor, in resend()
478 f->tag, jiffies, n, in resend()
479 h->src, h->dst, t->nout); in resend()
483 f->tag = n; in resend()
485 h->tag = cpu_to_be32(n); in resend()
486 memcpy(h->dst, t->addr, sizeof h->dst); in resend()
487 memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src); in resend()
489 dev_hold(t->ifp->nd); in resend()
490 skb->dev = t->ifp->nd; in resend()
493 dev_put(t->ifp->nd); in resend()
496 f->sent = ktime_get(); in resend()
505 u64 delta = ktime_to_ns(ktime_sub(ktime_get(), f->sent)); in tsince_hr()
507 /* delta is normally under 4.2 seconds, avoid 64-bit division */ in tsince_hr()
524 n -= tag & 0xffff; in tsince()
531 getif(struct aoetgt *t, struct net_device *nd) in getif() argument
535 p = t->ifs; in getif()
538 if (p->nd == nd) in getif()
544 ejectif(struct aoetgt *t, struct aoeif *ifp) in ejectif() argument
550 nd = ifp->nd; in ejectif()
551 e = t->ifs + NAOEIFS - 1; in ejectif()
552 n = (e - ifp) * sizeof *ifp; in ejectif()
554 e->nd = NULL; in ejectif()
564 nf = newframe(f->t->d); in reassign_frame()
567 if (nf->t == f->t) { in reassign_frame()
572 skb = nf->skb; in reassign_frame()
573 nf->skb = f->skb; in reassign_frame()
574 nf->buf = f->buf; in reassign_frame()
575 nf->iter = f->iter; in reassign_frame()
576 nf->waited = 0; in reassign_frame()
577 nf->waited_total = f->waited_total; in reassign_frame()
578 nf->sent = f->sent; in reassign_frame()
579 f->skb = skb; in reassign_frame()
585 probe(struct aoetgt *t) in probe() argument
594 d = t->d; in probe()
595 f = newtframe(d, t); in probe()
599 t->addr, in probe()
600 (long) d->aoemajor, d->aoeminor, in probe()
604 f->flags |= FFL_PROBE; in probe()
605 ifrotate(t); in probe()
606 f->iter.bi_size = t->d->maxbcnt ? t->d->maxbcnt : DEFAULTBCNT; in probe()
608 skb = f->skb; in probe()
609 for (frag = 0, n = f->iter.bi_size; n > 0; ++frag, n -= m) { in probe()
616 skb->len += f->iter.bi_size; in probe()
617 skb->data_len = f->iter.bi_size; in probe()
618 skb->truesize += f->iter.bi_size; in probe()
620 skb = skb_clone(f->skb, GFP_ATOMIC); in probe()
622 f->sent = ktime_get(); in probe()
627 dev_put(f->t->ifp->nd); in probe()
634 long t; in rto() local
636 t = 2 * d->rttavg >> RTTSCALE; in rto()
637 t += 8 * d->rttdev >> RTTDSCALE; in rto()
638 if (t == 0) in rto()
639 t = 1; in rto()
641 return t; in rto()
647 struct aoetgt *t; in rexmit_deferred() local
650 struct list_head *pos, *nx, *head; in rexmit_deferred() local
656 head = &d->rexmitq; in rexmit_deferred()
657 list_for_each_safe(pos, nx, head) { in rexmit_deferred()
658 f = list_entry(pos, struct frame, head); in rexmit_deferred()
659 t = f->t; in rexmit_deferred()
660 if (t->taint) { in rexmit_deferred()
661 if (!(f->flags & FFL_PROBE)) { in rexmit_deferred()
664 if (t->nout_probes == 0 in rexmit_deferred()
666 probe(t); in rexmit_deferred()
667 t->nout_probes++; in rexmit_deferred()
669 list_replace(&f->head, &nf->head); in rexmit_deferred()
670 pos = &nf->head; in rexmit_deferred()
673 t = f->t; in rexmit_deferred()
676 /* don't probe w/o other untainted aoetgts */ in rexmit_deferred()
678 } else if (tsince_hr(f) < t->taint * rto(d)) { in rexmit_deferred()
682 } else if (f->flags & FFL_PROBE) { in rexmit_deferred()
683 stop_probe: /* don't probe untainted aoetgts */ in rexmit_deferred()
686 /* leaving d->kicked, because this is routine */ in rexmit_deferred()
687 f->t->d->flags |= DEVFL_KICKME; in rexmit_deferred()
690 if (t->nout >= t->maxout) in rexmit_deferred()
693 t->nout++; in rexmit_deferred()
694 if (f->flags & FFL_PROBE) in rexmit_deferred()
695 t->nout_probes++; in rexmit_deferred()
697 f->waited += since; in rexmit_deferred()
698 f->waited_total += since; in rexmit_deferred()
707 scorn(struct aoetgt *t) in scorn() argument
711 n = t->taint++; in scorn()
712 t->taint += t->taint * 2; in scorn()
713 if (n > t->taint) in scorn()
714 t->taint = n; in scorn()
715 if (t->taint > MAX_TAINT) in scorn()
716 t->taint = MAX_TAINT; in scorn()
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()
737 struct aoetgt *t; in rexmit_timer() local
740 struct list_head *head, *pos, *nx; in rexmit_timer() local
750 spin_lock_irqsave(&d->lock, flags); in rexmit_timer()
757 if (d->flags & DEVFL_TKILL) { in rexmit_timer()
758 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
764 head = &d->factive[i]; in rexmit_timer()
765 list_for_each_safe(pos, nx, head) { in rexmit_timer()
766 f = list_entry(pos, struct frame, head); in rexmit_timer()
777 f = list_entry(pos, struct frame, head); in rexmit_timer()
779 n = f->waited_total + since; in rexmit_timer()
783 && !(f->flags & FFL_PROBE)) { in rexmit_timer()
788 list_splice(&flist, &d->factive[0]); in rexmit_timer()
793 t = f->t; in rexmit_timer()
794 n = f->waited + since; in rexmit_timer()
798 scorn(t); /* avoid this target */ in rexmit_timer()
800 if (t->maxout != 1) { in rexmit_timer()
801 t->ssthresh = t->maxout / 2; in rexmit_timer()
802 t->maxout = 1; in rexmit_timer()
805 if (f->flags & FFL_PROBE) { in rexmit_timer()
806 t->nout_probes--; in rexmit_timer()
808 ifp = getif(t, f->skb->dev); in rexmit_timer()
809 if (ifp && ++ifp->lost > (t->nframes << 1) in rexmit_timer()
810 && (ifp != t->ifs || t->ifs[1].nd)) { in rexmit_timer()
811 ejectif(t, ifp); in rexmit_timer()
815 list_move_tail(pos, &d->rexmitq); in rexmit_timer()
816 t->nout--; in rexmit_timer()
821 if ((d->flags & DEVFL_KICKME) && d->blkq) { in rexmit_timer()
822 d->flags &= ~DEVFL_KICKME; in rexmit_timer()
823 blk_mq_run_hw_queues(d->blkq, true); in rexmit_timer()
826 d->timer.expires = jiffies + TIMERTICK; in rexmit_timer()
827 add_timer(&d->timer); in rexmit_timer()
829 spin_unlock_irqrestore(&d->lock, flags); in rexmit_timer()
836 buf->rq = rq; in bufinit()
837 buf->bio = bio; in bufinit()
838 buf->iter = bio->bi_iter; in bufinit()
850 q = d->blkq; in nextbuf()
853 if (d->ip.buf) in nextbuf()
854 return d->ip.buf; in nextbuf()
855 rq = d->ip.rq; in nextbuf()
857 rq = list_first_entry_or_null(&d->rq_list, struct request, in nextbuf()
861 list_del_init(&rq->queuelist); in nextbuf()
863 d->ip.rq = rq; in nextbuf()
864 d->ip.nxbio = rq->bio; in nextbuf()
867 req->nr_bios = 0; in nextbuf()
869 req->nr_bios++; in nextbuf()
871 buf = mempool_alloc(d->bufpool, GFP_ATOMIC); in nextbuf()
876 bio = d->ip.nxbio; in nextbuf()
878 bio = bio->bi_next; in nextbuf()
879 d->ip.nxbio = bio; in nextbuf()
881 d->ip.rq = NULL; in nextbuf()
882 return d->ip.buf = buf; in nextbuf()
885 /* enters with d->lock held */
901 if (d->flags & DEVFL_GDALLOC) in aoecmd_sleepwork()
904 if (d->flags & DEVFL_NEWSIZE) { in aoecmd_sleepwork()
905 set_capacity_and_notify(d->gd, d->ssize); in aoecmd_sleepwork()
907 spin_lock_irq(&d->lock); in aoecmd_sleepwork()
908 d->flags |= DEVFL_UP; in aoecmd_sleepwork()
909 d->flags &= ~DEVFL_NEWSIZE; in aoecmd_sleepwork()
910 spin_unlock_irq(&d->lock); in aoecmd_sleepwork()
919 while (ns-- > 0) { in ata_ident_fixstring()
926 ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) in ataid_complete() argument
938 d->flags |= DEVFL_EXT; in ataid_complete()
943 /* set as in ide-disk.c:init_idedisk_capacity */ in ataid_complete()
944 d->geo.cylinders = ssize; in ataid_complete()
945 d->geo.cylinders /= (255 * 63); in ataid_complete()
946 d->geo.heads = 255; in ataid_complete()
947 d->geo.sectors = 63; in ataid_complete()
949 d->flags &= ~DEVFL_EXT; in ataid_complete()
955 d->geo.cylinders = get_unaligned_le16(&id[54 << 1]); in ataid_complete()
956 d->geo.heads = get_unaligned_le16(&id[55 << 1]); in ataid_complete()
957 d->geo.sectors = get_unaligned_le16(&id[56 << 1]); in ataid_complete()
963 memcpy(d->ident, id, sizeof(d->ident)); in ataid_complete()
965 if (d->ssize != ssize) in ataid_complete()
968 t->addr, in ataid_complete()
969 d->aoemajor, d->aoeminor, in ataid_complete()
970 d->fw_ver, (long long)ssize); in ataid_complete()
971 d->ssize = ssize; in ataid_complete()
972 d->geo.start = 0; in ataid_complete()
973 if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) in ataid_complete()
975 if (d->gd != NULL) in ataid_complete()
976 d->flags |= DEVFL_NEWSIZE; in ataid_complete()
978 d->flags |= DEVFL_GDALLOC; in ataid_complete()
979 queue_work(aoe_wq, &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()
993 n = -n; in calc_rttavg()
994 n -= d->rttdev >> RTTDSCALE; in calc_rttavg()
995 d->rttdev += n; in calc_rttavg()
997 if (!t || t->maxout >= t->nframes) in calc_rttavg()
999 if (t->maxout < t->ssthresh) in calc_rttavg()
1000 t->maxout += 1; in calc_rttavg()
1001 else if (t->nout == t->maxout && t->next_cwnd-- == 0) { in calc_rttavg()
1002 t->maxout += 1; in calc_rttavg()
1003 t->next_cwnd = t->maxout; in calc_rttavg()
1010 struct aoetgt **t, **e; in gettgt() local
1012 t = d->targets; in gettgt()
1013 e = t + d->ntargets; in gettgt()
1014 for (; t < e && *t; t++) in gettgt()
1015 if (memcmp((*t)->addr, addr, sizeof((*t)->addr)) == 0) in gettgt()
1016 return *t; in gettgt()
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()
1048 bio = rq->bio; in aoe_end_request()
1049 bok = !fastfail && !bio->bi_status; in aoe_end_request()
1052 } while (blk_update_request(rq, bok ? BLK_STS_OK : BLK_STS_IOERR, bio->bi_iter.bi_size)); in aoe_end_request()
1064 struct request *rq = buf->rq; in aoe_end_buf()
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()
1070 if (--req->nr_bios == 0) in aoe_end_buf()
1081 struct aoetgt *t; in ktiocomplete() local
1090 t = f->t; in ktiocomplete()
1091 d = t->d; in ktiocomplete()
1092 skb = f->r_skb; in ktiocomplete()
1093 buf = f->buf; in ktiocomplete()
1094 if (f->flags & FFL_PROBE) in ktiocomplete()
1099 hout = (struct aoe_hdr *) skb_mac_header(f->skb); in ktiocomplete()
1102 hin = (struct aoe_hdr *) skb->data; in ktiocomplete()
1104 ahin = (struct aoe_atahdr *) skb->data; in ktiocomplete()
1106 if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */ in ktiocomplete()
1108 ahout->cmdstat, ahin->cmdstat, in ktiocomplete()
1109 d->aoemajor, d->aoeminor); in ktiocomplete()
1111 buf->bio->bi_status = BLK_STS_IOERR; in ktiocomplete()
1115 n = ahout->scnt << 9; in ktiocomplete()
1116 switch (ahout->cmdstat) { in ktiocomplete()
1119 if (skb->len < n) { in ktiocomplete()
1120 pr_err("%s e%ld.%d. skb->len=%d need=%ld\n", in ktiocomplete()
1122 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1123 skb->len, n); in ktiocomplete()
1124 buf->bio->bi_status = BLK_STS_IOERR; in ktiocomplete()
1127 if (n > f->iter.bi_size) { in ktiocomplete()
1129 "aoe: too-large data size in read from", in ktiocomplete()
1130 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1131 n, f->iter.bi_size); in ktiocomplete()
1132 buf->bio->bi_status = BLK_STS_IOERR; in ktiocomplete()
1135 bvcpy(skb, f->buf->bio, f->iter, n); in ktiocomplete()
1139 spin_lock_irq(&d->lock); in ktiocomplete()
1140 ifp = getif(t, skb->dev); in ktiocomplete()
1142 ifp->lost = 0; in ktiocomplete()
1143 spin_unlock_irq(&d->lock); in ktiocomplete()
1146 if (skb->len < 512) { in ktiocomplete()
1147 pr_info("%s e%ld.%d. skb->len=%d need=512\n", in ktiocomplete()
1149 (long) d->aoemajor, d->aoeminor, in ktiocomplete()
1150 skb->len); 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()
1161 ahout->cmdstat, in ktiocomplete()
1162 be16_to_cpu(get_unaligned(&hin->major)), in ktiocomplete()
1163 hin->minor); in ktiocomplete()
1166 spin_lock_irq(&d->lock); in ktiocomplete()
1167 if (t->taint > 0 in ktiocomplete()
1168 && --t->taint > 0 in ktiocomplete()
1169 && t->nout_probes == 0) { in ktiocomplete()
1172 probe(t); in ktiocomplete()
1173 t->nout_probes++; in ktiocomplete()
1179 if (buf && --buf->nframesout == 0 && buf->iter.bi_size == 0) in ktiocomplete()
1182 spin_unlock_irq(&d->lock); in ktiocomplete()
1201 if (list_empty(&iocq[id].head)) in ktio()
1203 pos = iocq[id].head.next; in ktio()
1205 f = list_entry(pos, struct frame, head); in ktio()
1210 actual_id = f->t->d->aoeminor % ncpus; in ktio()
1232 current->flags |= PF_NOFREEZE; in kthread()
1233 set_user_nice(current, -10); in kthread()
1234 complete(&k->rendez); /* tell spawner we're running */ in kthread()
1236 spin_lock_irq(k->lock); in kthread()
1237 more = k->fn(k->id); in kthread()
1239 add_wait_queue(k->waitq, &wait); in kthread()
1242 spin_unlock_irq(k->lock); in kthread()
1245 remove_wait_queue(k->waitq, &wait); in kthread()
1249 complete(&k->rendez); /* tell spawner we're stopping */ in kthread()
1256 kthread_stop(k->task); in aoe_ktstop()
1257 wait_for_completion(&k->rendez); in aoe_ktstop()
1265 init_completion(&k->rendez); in aoe_ktstart()
1266 task = kthread_run(kthread, k, "%s", k->name); in aoe_ktstart()
1268 return -ENOMEM; in aoe_ktstart()
1269 k->task = task; in aoe_ktstart()
1270 wait_for_completion(&k->rendez); /* allow kthread to start */ in aoe_ktstart()
1271 init_completion(&k->rendez); /* for waiting for exit later */ in aoe_ktstart()
1282 f->r_skb = skb; in ktcomplete()
1283 id = f->t->d->aoeminor % ncpus; in ktcomplete()
1294 list_add_tail(&f->head, &iocq[id].head); in ktcomplete()
1310 h = (struct aoe_hdr *) skb->data; in aoecmd_ata_rsp()
1311 aoemajor = be16_to_cpu(get_unaligned(&h->major)); in aoecmd_ata_rsp()
1312 d = aoedev_by_aoeaddr(aoemajor, h->minor, 0); in aoecmd_ata_rsp()
1316 aoemajor, h->minor); in aoecmd_ata_rsp()
1321 spin_lock_irqsave(&d->lock, flags); in aoecmd_ata_rsp()
1323 n = be32_to_cpu(get_unaligned(&h->tag)); in aoecmd_ata_rsp()
1326 calc_rttavg(d, f->t, tsince_hr(f)); in aoecmd_ata_rsp()
1327 f->t->nout--; in aoecmd_ata_rsp()
1328 if (f->flags & FFL_PROBE) in aoecmd_ata_rsp()
1329 f->t->nout_probes--; in aoecmd_ata_rsp()
1336 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1341 get_unaligned_be16(&h->major), in aoecmd_ata_rsp()
1342 h->minor, in aoecmd_ata_rsp()
1343 get_unaligned_be32(&h->tag), in aoecmd_ata_rsp()
1345 h->src, in aoecmd_ata_rsp()
1346 h->dst); in aoecmd_ata_rsp()
1353 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_ata_rsp()
1381 struct aoetgt *t; in aoecmd_ata_id() local
1387 t = *d->tgt; in aoecmd_ata_id()
1390 skb = f->skb; in aoecmd_ata_id()
1394 memset(h, 0, skb->len); in aoecmd_ata_id()
1395 f->tag = aoehdr_atainit(d, t, h); in aoecmd_ata_id()
1397 t->nout++; in aoecmd_ata_id()
1398 f->waited = 0; in aoecmd_ata_id()
1399 f->waited_total = 0; in aoecmd_ata_id()
1402 ah->scnt = 1; in aoecmd_ata_id()
1403 ah->cmdstat = ATA_CMD_ID_ATA; in aoecmd_ata_id()
1404 ah->lba3 = 0xa0; in aoecmd_ata_id()
1406 dev_hold(t->ifp->nd); in aoecmd_ata_id()
1407 skb->dev = t->ifp->nd; in aoecmd_ata_id()
1409 d->rttavg = RTTAVG_INIT; in aoecmd_ata_id()
1410 d->rttdev = RTTDEV_INIT; in aoecmd_ata_id()
1411 d->timer.function = rexmit_timer; in aoecmd_ata_id()
1415 f->sent = ktime_get(); in aoecmd_ata_id()
1417 dev_put(t->ifp->nd); in aoecmd_ata_id()
1428 oldn = d->ntargets; in grow_targets()
1430 tt = kcalloc(newn, sizeof(*d->targets), GFP_ATOMIC); in grow_targets()
1433 memmove(tt, d->targets, sizeof(*d->targets) * oldn); in grow_targets()
1434 d->tgt = tt + (d->tgt - d->targets); in grow_targets()
1435 kfree(d->targets); in grow_targets()
1436 d->targets = tt; in grow_targets()
1437 d->ntargets = newn; in grow_targets()
1439 return &d->targets[oldn]; in grow_targets()
1445 struct aoetgt *t, **tt, **te; in addtgt() local
1447 tt = d->targets; in addtgt()
1448 te = tt + d->ntargets; in addtgt()
1457 t = kzalloc(sizeof(*t), GFP_ATOMIC); in addtgt()
1458 if (!t) in addtgt()
1460 t->nframes = nframes; in addtgt()
1461 t->d = d; in addtgt()
1462 memcpy(t->addr, addr, sizeof t->addr); in addtgt()
1463 t->ifp = t->ifs; in addtgt()
1464 aoecmd_wreset(t); in addtgt()
1465 t->maxout = t->nframes / 2; in addtgt()
1466 INIT_LIST_HEAD(&t->ffree); in addtgt()
1467 return *tt = t; in addtgt()
1477 struct aoetgt **t, **e; in setdbcnt() local
1480 t = d->targets; in setdbcnt()
1481 e = t + d->ntargets; in setdbcnt()
1482 for (; t < e && *t; t++) in setdbcnt()
1483 if (bcnt == 0 || bcnt > (*t)->minbcnt) in setdbcnt()
1484 bcnt = (*t)->minbcnt; in setdbcnt()
1485 if (bcnt != d->maxbcnt) { in setdbcnt()
1486 d->maxbcnt = bcnt; in setdbcnt()
1488 d->aoemajor, d->aoeminor, bcnt); in setdbcnt()
1493 setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt) in setifbcnt() argument
1499 d = t->d; in setifbcnt()
1501 p = t->ifs; in setifbcnt()
1504 if (p->nd == NULL) in setifbcnt()
1506 if (p->nd == nd) { in setifbcnt()
1507 p->bcnt = bcnt; /* we're updating */ in setifbcnt()
1509 } else if (minbcnt > p->bcnt) in setifbcnt()
1510 minbcnt = p->bcnt; /* find the min interface */ in setifbcnt()
1518 p->nd = nd; in setifbcnt()
1519 p->bcnt = bcnt; in setifbcnt()
1521 t->minbcnt = minbcnt; in setifbcnt()
1531 struct aoetgt *t; in aoecmd_cfg_rsp() local
1545 aoemajor = get_unaligned_be16(&h->major); in aoecmd_cfg_rsp()
1553 aoemajor, (int) h->minor); in aoecmd_cfg_rsp()
1556 if (h->minor == 0xff) { in aoecmd_cfg_rsp()
1558 aoemajor, (int) h->minor); in aoecmd_cfg_rsp()
1562 n = be16_to_cpu(ch->bufcnt); in aoecmd_cfg_rsp()
1566 d = aoedev_by_aoeaddr(aoemajor, h->minor, 1); in aoecmd_cfg_rsp()
1572 spin_lock_irqsave(&d->lock, flags); in aoecmd_cfg_rsp()
1574 t = gettgt(d, h->src); in aoecmd_cfg_rsp()
1575 if (t) { in aoecmd_cfg_rsp()
1576 t->nframes = n; in aoecmd_cfg_rsp()
1577 if (n < t->maxout) in aoecmd_cfg_rsp()
1578 aoecmd_wreset(t); in aoecmd_cfg_rsp()
1580 t = addtgt(d, h->src, n); in aoecmd_cfg_rsp()
1581 if (!t) in aoecmd_cfg_rsp()
1584 n = skb->dev->mtu; in aoecmd_cfg_rsp()
1585 n -= sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr); in aoecmd_cfg_rsp()
1587 if (n > ch->scnt) in aoecmd_cfg_rsp()
1588 n = ch->scnt; in aoecmd_cfg_rsp()
1590 setifbcnt(t, skb->dev, n); in aoecmd_cfg_rsp()
1592 /* don't change users' perspective */ in aoecmd_cfg_rsp()
1593 if (d->nopen == 0) { in aoecmd_cfg_rsp()
1594 d->fw_ver = be16_to_cpu(ch->fwver); in aoecmd_cfg_rsp()
1598 spin_unlock_irqrestore(&d->lock, flags); in aoecmd_cfg_rsp()
1608 aoecmd_wreset(struct aoetgt *t) in aoecmd_wreset() argument
1610 t->maxout = 1; in aoecmd_wreset()
1611 t->ssthresh = t->nframes / 2; in aoecmd_wreset()
1612 t->next_cwnd = t->nframes; in aoecmd_wreset()
1618 struct aoetgt **t, **te; in aoecmd_cleanslate() local
1620 d->rttavg = RTTAVG_INIT; in aoecmd_cleanslate()
1621 d->rttdev = RTTDEV_INIT; in aoecmd_cleanslate()
1622 d->maxbcnt = 0; in aoecmd_cleanslate()
1624 t = d->targets; in aoecmd_cleanslate()
1625 te = t + d->ntargets; in aoecmd_cleanslate()
1626 for (; t < te && *t; t++) in aoecmd_cleanslate()
1627 aoecmd_wreset(*t); in aoecmd_cleanslate()
1635 buf->iter.bi_size = 0; in aoe_failbuf()
1636 buf->bio->bi_status = BLK_STS_IOERR; in aoe_failbuf()
1637 if (buf->nframesout == 0) in aoe_failbuf()
1663 list_splice_init(&iocq[id].head, &flist); in aoe_flush_iocq_by_index()
1668 f = list_entry(pos, struct frame, head); in aoe_flush_iocq_by_index()
1669 d = f->t->d; in aoe_flush_iocq_by_index()
1670 skb = f->r_skb; in aoe_flush_iocq_by_index()
1671 spin_lock_irqsave(&d->lock, flags); in aoe_flush_iocq_by_index()
1672 if (f->buf) { in aoe_flush_iocq_by_index()
1673 f->buf->nframesout--; in aoe_flush_iocq_by_index()
1674 aoe_failbuf(d, f->buf); in aoe_flush_iocq_by_index()
1677 spin_unlock_irqrestore(&d->lock, flags); in aoe_flush_iocq_by_index()
1693 return -ENOMEM; in aoecmd_init()
1700 return -ENOMEM; in aoecmd_init()
1704 ret = -ENOMEM; in aoecmd_init()
1710 ret = -ENOMEM; in aoecmd_init()
1715 INIT_LIST_HEAD(&iocq[i].head); in aoecmd_init()
1727 ret = -ENOMEM; in aoecmd_init()