Lines Matching +full:min +full:- +full:len
3 /*-
58 KASSERT(len >= 0, ("%s: len %d < 0", __func__, len)); \
61 if (off < iov->iov_len) \
63 off -= iov->iov_len; \
64 iol--; \
71 KASSERT(len >= 0, ("%s: len %d < 0", __func__, len)); \
75 processed += PAGE_SIZE - off; \
76 off -= PAGE_SIZE - off; \
82 cuio_copydata(struct uio* uio, int off, int len, caddr_t cp) in cuio_copydata() argument
84 struct iovec *iov = uio->uio_iov; in cuio_copydata()
85 int iol __diagused = uio->uio_iovcnt; in cuio_copydata()
89 while (len > 0) { in cuio_copydata()
91 count = min(iov->iov_len - off, len); in cuio_copydata()
92 bcopy(((caddr_t)iov->iov_base) + off, cp, count); in cuio_copydata()
93 len -= count; in cuio_copydata()
96 iol--; in cuio_copydata()
102 cuio_copyback(struct uio* uio, int off, int len, c_caddr_t cp) in cuio_copyback() argument
104 struct iovec *iov = uio->uio_iov; in cuio_copyback()
105 int iol __diagused = uio->uio_iovcnt; in cuio_copyback()
109 while (len > 0) { in cuio_copyback()
111 count = min(iov->iov_len - off, len); in cuio_copyback()
112 bcopy(cp, ((caddr_t)iov->iov_base) + off, count); in cuio_copyback()
113 len -= count; in cuio_copyback()
116 iol--; in cuio_copyback()
127 int ind, len; in cuio_getptr() local
130 while (loc >= 0 && ind < uio->uio_iovcnt) { in cuio_getptr()
131 len = uio->uio_iov[ind].iov_len; in cuio_getptr()
132 if (len > loc) { in cuio_getptr()
136 loc -= len; in cuio_getptr()
141 ind--; in cuio_getptr()
142 *off = uio->uio_iov[ind].iov_len; in cuio_getptr()
146 return (-1); in cuio_getptr()
152 * the beginning, continuing for "len" bytes.
155 cvm_page_apply(vm_page_t *pages, int off, int len, in cvm_page_apply() argument
164 while (len > 0) { in cvm_page_apply()
166 count = min(PAGE_SIZE - off, len); in cvm_page_apply()
170 len -= count; in cvm_page_apply()
179 cvm_page_contiguous_segment(vm_page_t *pages, size_t skip, int len) in cvm_page_contiguous_segment() argument
181 if ((skip + len - 1) / PAGE_SIZE > skip / PAGE_SIZE) in cvm_page_contiguous_segment()
185 skip -= rounddown(skip, PAGE_SIZE); in cvm_page_contiguous_segment()
190 * Copy len bytes of data from the vm_page_t array, skipping the first off
195 cvm_page_copyback(vm_page_t *pages, int off, int len, c_caddr_t cp) in cvm_page_copyback() argument
201 while (len > 0) { in cvm_page_copyback()
202 count = min(PAGE_SIZE - off, len); in cvm_page_copyback()
205 len -= count; in cvm_page_copyback()
215 * Copy len bytes of data from the pointer cp into the vm_page_t array,
220 cvm_page_copydata(vm_page_t *pages, int off, int len, caddr_t cp) in cvm_page_copydata() argument
226 while (len > 0) { in cvm_page_copydata()
227 count = min(PAGE_SIZE - off, len); in cvm_page_copydata()
230 len -= count; in cvm_page_copydata()
247 size_t len; in m_epg_pages_extent() local
250 len = pglen; in m_epg_pages_extent()
251 for (i = idx + 1; i < m->m_epg_npgs; i++) { in m_epg_pages_extent()
252 if (m->m_epg_pa[i - 1] + PAGE_SIZE != m->m_epg_pa[i]) in m_epg_pages_extent()
254 len += m_epg_pagelen(m, i, 0); in m_epg_pages_extent()
256 return (len); in m_epg_pages_extent()
260 m_epg_segment(struct mbuf *m, size_t offset, size_t *len) in m_epg_segment() argument
265 if (offset < m->m_epg_hdrlen) { in m_epg_segment()
266 *len = m->m_epg_hdrlen - offset; in m_epg_segment()
267 return (m->m_epg_hdr + offset); in m_epg_segment()
269 offset -= m->m_epg_hdrlen; in m_epg_segment()
270 pgoff = m->m_epg_1st_off; in m_epg_segment()
271 for (i = 0; i < m->m_epg_npgs; i++) { in m_epg_segment()
274 *len = m_epg_pages_extent(m, i, pglen) - offset; in m_epg_segment()
275 return ((void *)PHYS_TO_DMAP(m->m_epg_pa[i] + pgoff + in m_epg_segment()
278 offset -= pglen; in m_epg_segment()
281 KASSERT(offset <= m->m_epg_trllen, ("%s: offset beyond trailer", in m_epg_segment()
283 *len = m->m_epg_trllen - offset; in m_epg_segment()
284 return (m->m_epg_trail + offset); in m_epg_segment()
288 m_epg_contiguous_subsegment(struct mbuf *m, size_t skip, size_t len) in m_epg_contiguous_subsegment() argument
294 if (len > seglen) in m_epg_contiguous_subsegment()
304 cc->cc_type = cb->cb_type; in crypto_cursor_init()
305 switch (cc->cc_type) { in crypto_cursor_init()
307 cc->cc_buf = cb->cb_buf; in crypto_cursor_init()
308 cc->cc_buf_len = cb->cb_buf_len; in crypto_cursor_init()
312 cc->cc_mbuf = cb->cb_mbuf; in crypto_cursor_init()
315 cc->cc_vmpage = cb->cb_vm_page; in crypto_cursor_init()
316 cc->cc_buf_len = cb->cb_vm_page_len; in crypto_cursor_init()
317 cc->cc_offset = cb->cb_vm_page_offset; in crypto_cursor_init()
320 cc->cc_iov = cb->cb_uio->uio_iov; in crypto_cursor_init()
321 cc->cc_buf_len = cb->cb_uio->uio_resid; in crypto_cursor_init()
325 panic("%s: invalid buffer type %d", __func__, cb->cb_type); in crypto_cursor_init()
338 switch (cc->cc_type) { in crypto_cursor_advance()
340 MPASS(cc->cc_buf_len >= amount); in crypto_cursor_advance()
341 cc->cc_buf += amount; in crypto_cursor_advance()
342 cc->cc_buf_len -= amount; in crypto_cursor_advance()
346 remain = cc->cc_mbuf->m_len - cc->cc_offset; in crypto_cursor_advance()
348 cc->cc_offset += amount; in crypto_cursor_advance()
351 amount -= remain; in crypto_cursor_advance()
352 cc->cc_mbuf = cc->cc_mbuf->m_next; in crypto_cursor_advance()
353 cc->cc_offset = 0; in crypto_cursor_advance()
359 MPASS(cc->cc_mbuf->m_len >= cc->cc_offset + amount); in crypto_cursor_advance()
360 cc->cc_offset += amount; in crypto_cursor_advance()
366 remain = MIN(PAGE_SIZE - cc->cc_offset, cc->cc_buf_len); in crypto_cursor_advance()
368 cc->cc_buf_len -= amount; in crypto_cursor_advance()
369 cc->cc_offset += amount; in crypto_cursor_advance()
372 cc->cc_buf_len -= remain; in crypto_cursor_advance()
373 amount -= remain; in crypto_cursor_advance()
374 cc->cc_vmpage++; in crypto_cursor_advance()
375 cc->cc_offset = 0; in crypto_cursor_advance()
376 if (amount == 0 || cc->cc_buf_len == 0) in crypto_cursor_advance()
382 remain = cc->cc_iov->iov_len - cc->cc_offset; in crypto_cursor_advance()
384 cc->cc_offset += amount; in crypto_cursor_advance()
387 cc->cc_buf_len -= remain; in crypto_cursor_advance()
388 amount -= remain; in crypto_cursor_advance()
389 cc->cc_iov++; in crypto_cursor_advance()
390 cc->cc_offset = 0; in crypto_cursor_advance()
397 panic("%s: invalid buffer type %d", __func__, cc->cc_type); in crypto_cursor_advance()
404 crypto_cursor_segment(struct crypto_buffer_cursor *cc, size_t *len) in crypto_cursor_segment() argument
406 switch (cc->cc_type) { in crypto_cursor_segment()
410 if (cc->cc_buf_len == 0) { in crypto_cursor_segment()
411 *len = 0; in crypto_cursor_segment()
417 if (cc->cc_mbuf == NULL) { in crypto_cursor_segment()
418 *len = 0; in crypto_cursor_segment()
424 panic("%s: invalid buffer type %d", __func__, cc->cc_type); in crypto_cursor_segment()
426 *len = 0; in crypto_cursor_segment()
430 switch (cc->cc_type) { in crypto_cursor_segment()
432 *len = cc->cc_buf_len; in crypto_cursor_segment()
433 return (cc->cc_buf); in crypto_cursor_segment()
436 if (cc->cc_mbuf->m_flags & M_EXTPG) in crypto_cursor_segment()
437 return (m_epg_segment(cc->cc_mbuf, cc->cc_offset, len)); in crypto_cursor_segment()
438 *len = cc->cc_mbuf->m_len - cc->cc_offset; in crypto_cursor_segment()
439 return (mtod(cc->cc_mbuf, char *) + cc->cc_offset); in crypto_cursor_segment()
441 *len = PAGE_SIZE - cc->cc_offset; in crypto_cursor_segment()
443 *cc->cc_vmpage)) + cc->cc_offset); in crypto_cursor_segment()
445 *len = cc->cc_iov->iov_len - cc->cc_offset; in crypto_cursor_segment()
446 return ((char *)cc->cc_iov->iov_base + cc->cc_offset); in crypto_cursor_segment()
461 switch (cc->cc_type) { in crypto_cursor_copyback()
463 MPASS(cc->cc_buf_len >= size); in crypto_cursor_copyback()
464 memcpy(cc->cc_buf, src, size); in crypto_cursor_copyback()
465 cc->cc_buf += size; in crypto_cursor_copyback()
466 cc->cc_buf_len -= size; in crypto_cursor_copyback()
475 remain = cc->cc_mbuf->m_len - cc->cc_offset; in crypto_cursor_copyback()
476 todo = MIN(remain, size); in crypto_cursor_copyback()
477 m_copyback(cc->cc_mbuf, cc->cc_offset, todo, src); in crypto_cursor_copyback()
480 cc->cc_offset += todo; in crypto_cursor_copyback()
483 size -= todo; in crypto_cursor_copyback()
484 cc->cc_mbuf = cc->cc_mbuf->m_next; in crypto_cursor_copyback()
485 cc->cc_offset = 0; in crypto_cursor_copyback()
491 MPASS(cc->cc_mbuf->m_len >= cc->cc_offset + size); in crypto_cursor_copyback()
492 m_copyback(cc->cc_mbuf, cc->cc_offset, size, src); in crypto_cursor_copyback()
493 cc->cc_offset += size; in crypto_cursor_copyback()
498 *cc->cc_vmpage)) + cc->cc_offset; in crypto_cursor_copyback()
499 remain = MIN(PAGE_SIZE - cc->cc_offset, cc->cc_buf_len); in crypto_cursor_copyback()
500 todo = MIN(remain, size); in crypto_cursor_copyback()
503 cc->cc_buf_len -= todo; in crypto_cursor_copyback()
505 cc->cc_offset += todo; in crypto_cursor_copyback()
508 size -= todo; in crypto_cursor_copyback()
509 cc->cc_vmpage++; in crypto_cursor_copyback()
510 cc->cc_offset = 0; in crypto_cursor_copyback()
517 dst = (char *)cc->cc_iov->iov_base + cc->cc_offset; in crypto_cursor_copyback()
518 remain = cc->cc_iov->iov_len - cc->cc_offset; in crypto_cursor_copyback()
519 todo = MIN(remain, size); in crypto_cursor_copyback()
522 cc->cc_buf_len -= todo; in crypto_cursor_copyback()
524 cc->cc_offset += todo; in crypto_cursor_copyback()
527 size -= todo; in crypto_cursor_copyback()
528 cc->cc_iov++; in crypto_cursor_copyback()
529 cc->cc_offset = 0; in crypto_cursor_copyback()
536 panic("%s: invalid buffer type %d", __func__, cc->cc_type); in crypto_cursor_copyback()
550 switch (cc->cc_type) { in crypto_cursor_copydata()
552 MPASS(cc->cc_buf_len >= size); in crypto_cursor_copydata()
553 memcpy(dst, cc->cc_buf, size); in crypto_cursor_copydata()
554 cc->cc_buf += size; in crypto_cursor_copydata()
555 cc->cc_buf_len -= size; in crypto_cursor_copydata()
564 remain = cc->cc_mbuf->m_len - cc->cc_offset; in crypto_cursor_copydata()
565 todo = MIN(remain, size); in crypto_cursor_copydata()
566 m_copydata(cc->cc_mbuf, cc->cc_offset, todo, dst); in crypto_cursor_copydata()
569 cc->cc_offset += todo; in crypto_cursor_copydata()
572 size -= todo; in crypto_cursor_copydata()
573 cc->cc_mbuf = cc->cc_mbuf->m_next; in crypto_cursor_copydata()
574 cc->cc_offset = 0; in crypto_cursor_copydata()
580 MPASS(cc->cc_mbuf->m_len >= cc->cc_offset + size); in crypto_cursor_copydata()
581 m_copydata(cc->cc_mbuf, cc->cc_offset, size, dst); in crypto_cursor_copydata()
582 cc->cc_offset += size; in crypto_cursor_copydata()
587 *cc->cc_vmpage)) + cc->cc_offset; in crypto_cursor_copydata()
588 remain = MIN(PAGE_SIZE - cc->cc_offset, cc->cc_buf_len); in crypto_cursor_copydata()
589 todo = MIN(remain, size); in crypto_cursor_copydata()
592 cc->cc_buf_len -= todo; in crypto_cursor_copydata()
594 cc->cc_offset += todo; in crypto_cursor_copydata()
597 size -= todo; in crypto_cursor_copydata()
598 cc->cc_vmpage++; in crypto_cursor_copydata()
599 cc->cc_offset = 0; in crypto_cursor_copydata()
606 src = (const char *)cc->cc_iov->iov_base + in crypto_cursor_copydata()
607 cc->cc_offset; in crypto_cursor_copydata()
608 remain = cc->cc_iov->iov_len - cc->cc_offset; in crypto_cursor_copydata()
609 todo = MIN(remain, size); in crypto_cursor_copydata()
612 cc->cc_buf_len -= todo; in crypto_cursor_copydata()
614 cc->cc_offset += todo; in crypto_cursor_copydata()
617 size -= todo; in crypto_cursor_copydata()
618 cc->cc_iov++; in crypto_cursor_copydata()
619 cc->cc_offset = 0; in crypto_cursor_copydata()
626 panic("%s: invalid buffer type %d", __func__, cc->cc_type); in crypto_cursor_copydata()
648 * the beginning, continuing for "len" bytes.
651 cuio_apply(struct uio *uio, int off, int len, in cuio_apply() argument
654 struct iovec *iov = uio->uio_iov; in cuio_apply()
655 int iol __diagused = uio->uio_iovcnt; in cuio_apply()
660 while (len > 0) { in cuio_apply()
662 count = min(iov->iov_len - off, len); in cuio_apply()
663 rval = (*f)(arg, ((caddr_t)iov->iov_base) + off, count); in cuio_apply()
666 len -= count; in cuio_apply()
668 iol--; in cuio_apply()
679 if (crp->crp_obuf.cb_type != CRYPTO_BUF_NONE) in crypto_copyback()
680 cb = &crp->crp_obuf; in crypto_copyback()
682 cb = &crp->crp_buf; in crypto_copyback()
683 switch (cb->cb_type) { in crypto_copyback()
686 m_copyback(cb->cb_mbuf, off, size, src); in crypto_copyback()
690 MPASS(size <= cb->cb_vm_page_len); in crypto_copyback()
692 cb->cb_vm_page_len + cb->cb_vm_page_offset); in crypto_copyback()
693 cvm_page_copyback(cb->cb_vm_page, in crypto_copyback()
694 off + cb->cb_vm_page_offset, size, src); in crypto_copyback()
698 cuio_copyback(cb->cb_uio, off, size, src); in crypto_copyback()
701 MPASS(off + size <= cb->cb_buf_len); in crypto_copyback()
702 bcopy(src, cb->cb_buf + off, size); in crypto_copyback()
706 panic("invalid crp buf type %d", cb->cb_type); in crypto_copyback()
716 switch (crp->crp_buf.cb_type) { in crypto_copydata()
719 m_copydata(crp->crp_buf.cb_mbuf, off, size, dst); in crypto_copydata()
723 MPASS(size <= crp->crp_buf.cb_vm_page_len); in crypto_copydata()
724 MPASS(size + off <= crp->crp_buf.cb_vm_page_len + in crypto_copydata()
725 crp->crp_buf.cb_vm_page_offset); in crypto_copydata()
726 cvm_page_copydata(crp->crp_buf.cb_vm_page, in crypto_copydata()
727 off + crp->crp_buf.cb_vm_page_offset, size, dst); in crypto_copydata()
731 cuio_copydata(crp->crp_buf.cb_uio, off, size, dst); in crypto_copydata()
734 MPASS(off + size <= crp->crp_buf.cb_buf_len); in crypto_copydata()
735 bcopy(crp->crp_buf.cb_buf + off, dst, size); in crypto_copydata()
739 panic("invalid crp buf type %d", crp->crp_buf.cb_type); in crypto_copydata()
746 crypto_apply_buf(struct crypto_buffer *cb, int off, int len, in crypto_apply_buf() argument
751 switch (cb->cb_type) { in crypto_apply_buf()
754 error = m_apply(cb->cb_mbuf, off, len, in crypto_apply_buf()
758 error = cuio_apply(cb->cb_uio, off, len, f, arg); in crypto_apply_buf()
762 error = cvm_page_apply(cb->cb_vm_page, in crypto_apply_buf()
763 off + cb->cb_vm_page_offset, len, f, arg); in crypto_apply_buf()
767 MPASS(off + len <= cb->cb_buf_len); in crypto_apply_buf()
768 error = (*f)(arg, cb->cb_buf + off, len); in crypto_apply_buf()
772 panic("invalid crypto buf type %d", cb->cb_type); in crypto_apply_buf()
781 crypto_apply(struct cryptop *crp, int off, int len, in crypto_apply() argument
784 return (crypto_apply_buf(&crp->crp_buf, off, len, f, arg)); in crypto_apply()
788 m_contiguous_subsegment(struct mbuf *m, size_t skip, size_t len) in m_contiguous_subsegment() argument
800 if (skip + len > m->m_len) in m_contiguous_subsegment()
803 if (m->m_flags & M_EXTPG) in m_contiguous_subsegment()
804 return (m_epg_contiguous_subsegment(m, skip, len)); in m_contiguous_subsegment()
809 cuio_contiguous_segment(struct uio *uio, size_t skip, size_t len) in cuio_contiguous_segment() argument
820 if (skip + len > uio->uio_iov[idx].iov_len) in cuio_contiguous_segment()
822 return ((char *)uio->uio_iov[idx].iov_base + skip); in cuio_contiguous_segment()
827 size_t len) in crypto_buffer_contiguous_subsegment() argument
830 switch (cb->cb_type) { in crypto_buffer_contiguous_subsegment()
833 return (m_contiguous_subsegment(cb->cb_mbuf, skip, len)); in crypto_buffer_contiguous_subsegment()
835 return (cuio_contiguous_segment(cb->cb_uio, skip, len)); in crypto_buffer_contiguous_subsegment()
838 MPASS(skip + len <= cb->cb_vm_page_len); in crypto_buffer_contiguous_subsegment()
839 return (cvm_page_contiguous_segment(cb->cb_vm_page, in crypto_buffer_contiguous_subsegment()
840 skip + cb->cb_vm_page_offset, len)); in crypto_buffer_contiguous_subsegment()
843 MPASS(skip + len <= cb->cb_buf_len); in crypto_buffer_contiguous_subsegment()
844 return (cb->cb_buf + skip); in crypto_buffer_contiguous_subsegment()
847 panic("invalid crp buf type %d", cb->cb_type); in crypto_buffer_contiguous_subsegment()
854 crypto_contiguous_subsegment(struct cryptop *crp, size_t skip, size_t len) in crypto_contiguous_subsegment() argument
856 return (crypto_buffer_contiguous_subsegment(&crp->crp_buf, skip, len)); in crypto_contiguous_subsegment()