Lines Matching refs:len
31 unsigned int quadlen = XDR_QUADLEN(obj->len); in xdr_encode_netobj()
34 *p++ = cpu_to_be32(obj->len); in xdr_encode_netobj()
35 memcpy(p, obj->data, obj->len); in xdr_encode_netobj()
36 return p + XDR_QUADLEN(obj->len); in xdr_encode_netobj()
43 unsigned int len; in xdr_decode_netobj() local
45 if ((len = be32_to_cpu(*p++)) > XDR_MAX_NETOBJ) in xdr_decode_netobj()
47 obj->len = len; in xdr_decode_netobj()
49 return p + XDR_QUADLEN(len); in xdr_decode_netobj()
109 u32 len; in xdr_decode_string_inplace() local
111 len = be32_to_cpu(*p++); in xdr_decode_string_inplace()
112 if (len > maxlen) in xdr_decode_string_inplace()
114 *lenp = len; in xdr_decode_string_inplace()
116 return p + XDR_QUADLEN(len); in xdr_decode_string_inplace()
126 void xdr_terminate_string(const struct xdr_buf *buf, const u32 len) in xdr_terminate_string() argument
131 kaddr[buf->page_base + len] = '\0'; in xdr_terminate_string()
188 unsigned int offset, len, remaining; in xdr_buf_to_bvec() local
194 len = min_t(unsigned int, remaining, in xdr_buf_to_bvec()
196 bvec_set_page(bvec++, *pages++, len, offset); in xdr_buf_to_bvec()
197 remaining -= len; in xdr_buf_to_bvec()
228 struct page **pages, unsigned int base, unsigned int len) in xdr_inline_pages() argument
239 xdr->page_len = len; in xdr_inline_pages()
243 xdr->buflen += len; in xdr_inline_pages()
267 size_t pgfrom_base, size_t len) in _shift_data_left_pages() argument
275 if (!len) in _shift_data_left_pages()
294 copy = len; in _shift_data_left_pages()
313 } while ((len -= copy) != 0); in _shift_data_left_pages()
332 size_t pgfrom_base, size_t len) in _shift_data_right_pages() argument
340 if (!len) in _shift_data_right_pages()
343 pgto_base += len; in _shift_data_right_pages()
344 pgfrom_base += len; in _shift_data_right_pages()
363 copy = len; in _shift_data_right_pages()
381 } while ((len -= copy) != 0); in _shift_data_right_pages()
395 _copy_to_pages(struct page **pages, size_t pgbase, const char *p, size_t len) in _copy_to_pages() argument
401 if (!len) in _copy_to_pages()
409 if (copy > len) in _copy_to_pages()
410 copy = len; in _copy_to_pages()
416 len -= copy; in _copy_to_pages()
417 if (len == 0) in _copy_to_pages()
442 _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len) in _copy_from_pages() argument
448 if (!len) in _copy_from_pages()
456 if (copy > len) in _copy_from_pages()
457 copy = len; in _copy_from_pages()
470 } while ((len -= copy) != 0); in _copy_from_pages()
475 unsigned int len) in xdr_buf_iov_zero() argument
479 if (len > iov->iov_len - base) in xdr_buf_iov_zero()
480 len = iov->iov_len - base; in xdr_buf_iov_zero()
481 memset(iov->iov_base + base, 0, len); in xdr_buf_iov_zero()
491 unsigned int len) in xdr_buf_pages_zero() argument
498 if (!len) in xdr_buf_pages_zero()
501 xdr_buf_iov_zero(buf->tail, pgbase - buf->page_len, len); in xdr_buf_pages_zero()
504 if (pgbase + len > buf->page_len) { in xdr_buf_pages_zero()
505 xdr_buf_iov_zero(buf->tail, 0, pgbase + len - buf->page_len); in xdr_buf_pages_zero()
506 len = buf->page_len - pgbase; in xdr_buf_pages_zero()
516 if (zero > len) in xdr_buf_pages_zero()
517 zero = len; in xdr_buf_pages_zero()
527 } while ((len -= zero) != 0); in xdr_buf_pages_zero()
558 static void xdr_buf_try_expand(struct xdr_buf *buf, unsigned int len) in xdr_buf_try_expand() argument
565 if (sum > buf->len) { in xdr_buf_try_expand()
566 free_space = min_t(unsigned int, sum - buf->len, len); in xdr_buf_try_expand()
567 newlen = xdr_buf_pages_fill_sparse(buf, buf->len + free_space, in xdr_buf_try_expand()
569 free_space = newlen - buf->len; in xdr_buf_try_expand()
570 buf->len = newlen; in xdr_buf_try_expand()
571 len -= free_space; in xdr_buf_try_expand()
572 if (!len) in xdr_buf_try_expand()
578 free_space = min_t(unsigned int, buf->buflen - sum, len); in xdr_buf_try_expand()
580 buf->len += free_space; in xdr_buf_try_expand()
585 unsigned int base, unsigned int len, in xdr_buf_tail_copy_right() argument
593 if (len + to > tail->iov_len) in xdr_buf_tail_copy_right()
594 len = tail->iov_len - to; in xdr_buf_tail_copy_right()
595 memmove(tail->iov_base + to, tail->iov_base + base, len); in xdr_buf_tail_copy_right()
599 unsigned int base, unsigned int len, in xdr_buf_pages_copy_right() argument
609 if (len > buf->page_len - base) in xdr_buf_pages_copy_right()
610 len = buf->page_len - base; in xdr_buf_pages_copy_right()
613 if (tail->iov_len >= len + tato) in xdr_buf_pages_copy_right()
614 talen = len; in xdr_buf_pages_copy_right()
617 } else if (len + to >= buf->page_len) { in xdr_buf_pages_copy_right()
619 talen = len - pglen; in xdr_buf_pages_copy_right()
623 pglen = len; in xdr_buf_pages_copy_right()
632 unsigned int base, unsigned int len, in xdr_buf_head_copy_right() argument
643 if (len > head->iov_len - base) in xdr_buf_head_copy_right()
644 len = head->iov_len - base; in xdr_buf_head_copy_right()
647 talen = len; in xdr_buf_head_copy_right()
650 pglen = len; in xdr_buf_head_copy_right()
656 pglen = len - to; in xdr_buf_head_copy_right()
663 len -= talen; in xdr_buf_head_copy_right()
664 base += len; in xdr_buf_head_copy_right()
669 len -= pglen; in xdr_buf_head_copy_right()
674 base -= len; in xdr_buf_head_copy_right()
675 memmove(head->iov_base + to, head->iov_base + base, len); in xdr_buf_head_copy_right()
679 unsigned int base, unsigned int len, in xdr_buf_tail_shift_right() argument
684 if (base >= tail->iov_len || !shift || !len) in xdr_buf_tail_shift_right()
686 xdr_buf_tail_copy_right(buf, base, len, shift); in xdr_buf_tail_shift_right()
690 unsigned int base, unsigned int len, in xdr_buf_pages_shift_right() argument
693 if (!shift || !len) in xdr_buf_pages_shift_right()
696 xdr_buf_tail_shift_right(buf, base - buf->page_len, len, shift); in xdr_buf_pages_shift_right()
699 if (base + len > buf->page_len) in xdr_buf_pages_shift_right()
700 xdr_buf_tail_shift_right(buf, 0, base + len - buf->page_len, in xdr_buf_pages_shift_right()
702 xdr_buf_pages_copy_right(buf, base, len, shift); in xdr_buf_pages_shift_right()
706 unsigned int base, unsigned int len, in xdr_buf_head_shift_right() argument
714 xdr_buf_pages_shift_right(buf, head->iov_len - base, len, in xdr_buf_head_shift_right()
718 if (base + len > head->iov_len) in xdr_buf_head_shift_right()
719 xdr_buf_pages_shift_right(buf, 0, base + len - head->iov_len, in xdr_buf_head_shift_right()
721 xdr_buf_head_copy_right(buf, base, len, shift); in xdr_buf_head_shift_right()
725 unsigned int len, unsigned int shift) in xdr_buf_tail_copy_left() argument
731 if (len > tail->iov_len - base) in xdr_buf_tail_copy_left()
732 len = tail->iov_len - base; in xdr_buf_tail_copy_left()
738 unsigned int hdlen = len; in xdr_buf_tail_copy_left()
747 len -= hdlen; in xdr_buf_tail_copy_left()
748 if (!len) in xdr_buf_tail_copy_left()
754 unsigned int pglen = len; in xdr_buf_tail_copy_left()
761 len -= pglen; in xdr_buf_tail_copy_left()
762 if (!len) in xdr_buf_tail_copy_left()
765 memmove(tail->iov_base + base - shift, tail->iov_base + base, len); in xdr_buf_tail_copy_left()
769 unsigned int base, unsigned int len, in xdr_buf_pages_copy_left() argument
776 if (len > buf->page_len - base) in xdr_buf_pages_copy_left()
777 len = buf->page_len - base; in xdr_buf_pages_copy_left()
782 unsigned int hdlen = len; in xdr_buf_pages_copy_left()
792 len -= hdlen; in xdr_buf_pages_copy_left()
793 if (!len) in xdr_buf_pages_copy_left()
798 buf->page_base + base, len); in xdr_buf_pages_copy_left()
802 unsigned int base, unsigned int len, in xdr_buf_tail_shift_left() argument
805 if (!shift || !len) in xdr_buf_tail_shift_left()
807 xdr_buf_tail_copy_left(buf, base, len, shift); in xdr_buf_tail_shift_left()
811 unsigned int base, unsigned int len, in xdr_buf_pages_shift_left() argument
814 if (!shift || !len) in xdr_buf_pages_shift_left()
817 xdr_buf_tail_shift_left(buf, base - buf->page_len, len, shift); in xdr_buf_pages_shift_left()
820 xdr_buf_pages_copy_left(buf, base, len, shift); in xdr_buf_pages_shift_left()
821 len += base; in xdr_buf_pages_shift_left()
822 if (len <= buf->page_len) in xdr_buf_pages_shift_left()
824 xdr_buf_tail_copy_left(buf, 0, len - buf->page_len, shift); in xdr_buf_pages_shift_left()
828 unsigned int base, unsigned int len, in xdr_buf_head_shift_left() argument
834 if (!shift || !len) in xdr_buf_head_shift_left()
839 if (bytes >= len) in xdr_buf_head_shift_left()
842 len -= bytes; in xdr_buf_head_shift_left()
846 bytes = min_t(unsigned int, len, head->iov_len - base); in xdr_buf_head_shift_left()
850 len -= bytes; in xdr_buf_head_shift_left()
852 xdr_buf_pages_shift_left(buf, base - head->iov_len, len, shift); in xdr_buf_head_shift_left()
864 static unsigned int xdr_shrink_bufhead(struct xdr_buf *buf, unsigned int len) in xdr_shrink_bufhead() argument
867 unsigned int shift, buflen = max(buf->len, len); in xdr_shrink_bufhead()
869 WARN_ON_ONCE(len > head->iov_len); in xdr_shrink_bufhead()
874 if (len >= head->iov_len) in xdr_shrink_bufhead()
876 shift = head->iov_len - len; in xdr_shrink_bufhead()
878 xdr_buf_head_shift_right(buf, len, buflen - len, shift); in xdr_shrink_bufhead()
879 head->iov_len = len; in xdr_shrink_bufhead()
881 buf->len -= shift; in xdr_shrink_bufhead()
893 static unsigned int xdr_shrink_pagelen(struct xdr_buf *buf, unsigned int len) in xdr_shrink_pagelen() argument
895 unsigned int shift, buflen = buf->len - buf->head->iov_len; in xdr_shrink_pagelen()
897 WARN_ON_ONCE(len > buf->page_len); in xdr_shrink_pagelen()
898 if (buf->head->iov_len >= buf->len || len > buflen) in xdr_shrink_pagelen()
899 buflen = len; in xdr_shrink_pagelen()
904 if (len >= buf->page_len) in xdr_shrink_pagelen()
906 shift = buf->page_len - len; in xdr_shrink_pagelen()
908 xdr_buf_pages_shift_right(buf, len, buflen - len, shift); in xdr_shrink_pagelen()
909 buf->page_len = len; in xdr_shrink_pagelen()
910 buf->len -= shift; in xdr_shrink_pagelen()
921 return (unsigned int)(XDR_QUADLEN(xdr->buf->len) - xdr->nwords) << 2; in xdr_stream_pos()
927 unsigned int blen = xdr->buf->len; in xdr_stream_set_pos()
979 size_t len; in xdr_init_encode() local
982 len = (char *)p - (char *)xdr->p; in xdr_init_encode()
984 buf->len += len; in xdr_init_encode()
985 iov->iov_len += len; in xdr_init_encode()
1052 if (xdr->buf->len + nbytes > xdr->buf->buflen) in xdr_get_next_encode_buffer()
1078 space_left = xdr->buf->buflen - xdr->buf->len; in xdr_get_next_encode_buffer()
1085 xdr->buf->len += nbytes; in xdr_get_next_encode_buffer()
1118 xdr->buf->len += nbytes; in xdr_reserve_space()
1185 void xdr_truncate_encode(struct xdr_stream *xdr, size_t len) in xdr_truncate_encode() argument
1193 if (len > buf->len) { in xdr_truncate_encode()
1199 fraglen = min_t(int, buf->len - len, tail->iov_len); in xdr_truncate_encode()
1201 buf->len -= fraglen; in xdr_truncate_encode()
1209 fraglen = min_t(int, buf->len - len, buf->page_len); in xdr_truncate_encode()
1211 buf->len -= fraglen; in xdr_truncate_encode()
1228 head->iov_len = len; in xdr_truncate_encode()
1229 buf->len = len; in xdr_truncate_encode()
1241 void xdr_truncate_decode(struct xdr_stream *xdr, size_t len) in xdr_truncate_decode() argument
1243 unsigned int nbytes = xdr_align_size(len); in xdr_truncate_decode()
1245 xdr->buf->len -= nbytes; in xdr_truncate_decode()
1266 int end_offset = buf->len + left_in_this_buf; in xdr_restrict_buflen()
1268 if (newbuflen < 0 || newbuflen < buf->len) in xdr_restrict_buflen()
1291 unsigned int len) in xdr_write_pages() argument
1298 buf->page_len = len; in xdr_write_pages()
1304 if (len & 3) { in xdr_write_pages()
1305 unsigned int pad = 4 - (len & 3); in xdr_write_pages()
1308 tail->iov_base = (char *)xdr->p + (len & 3); in xdr_write_pages()
1310 len += pad; in xdr_write_pages()
1313 buf->buflen += len; in xdr_write_pages()
1314 buf->len += len; in xdr_write_pages()
1319 unsigned int base, unsigned int len) in xdr_set_iov() argument
1321 if (len > iov->iov_len) in xdr_set_iov()
1322 len = iov->iov_len; in xdr_set_iov()
1323 if (unlikely(base > len)) in xdr_set_iov()
1324 base = len; in xdr_set_iov()
1326 xdr->end = (__be32*)(iov->iov_base + len); in xdr_set_iov()
1329 return len - base; in xdr_set_iov()
1333 unsigned int base, unsigned int len) in xdr_set_tail_base() argument
1338 return xdr_set_iov(xdr, buf->tail, base, len); in xdr_set_tail_base()
1350 unsigned int base, unsigned int len) in xdr_set_page_base() argument
1363 if (len > maxlen) in xdr_set_page_base()
1364 len = maxlen; in xdr_set_page_base()
1382 pgend = pgoff + len; in xdr_set_page_base()
1387 return len; in xdr_set_page_base()
1391 unsigned int len) in xdr_set_page() argument
1393 if (xdr_set_page_base(xdr, base, len) == 0) { in xdr_set_page()
1395 xdr_set_tail_base(xdr, base, len); in xdr_set_page()
1433 xdr->nwords = XDR_QUADLEN(buf->len); in xdr_init_decode()
1434 if (xdr_set_iov(xdr, buf->head, 0, buf->len) == 0 && in xdr_init_decode()
1435 xdr_set_page_base(xdr, 0, buf->len) == 0) in xdr_init_decode()
1436 xdr_set_iov(xdr, buf->tail, 0, buf->len); in xdr_init_decode()
1453 struct page **pages, unsigned int len) in xdr_init_decode_pages() argument
1457 buf->page_len = len; in xdr_init_decode_pages()
1458 buf->buflen = len; in xdr_init_decode_pages()
1459 buf->len = len; in xdr_init_decode_pages()
1556 static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) in xdr_align_pages() argument
1559 unsigned int nwords = XDR_QUADLEN(len); in xdr_align_pages()
1568 len = nwords << 2; in xdr_align_pages()
1570 if (buf->page_len <= len) in xdr_align_pages()
1571 len = buf->page_len; in xdr_align_pages()
1574 copied = xdr_shrink_pagelen(buf, len); in xdr_align_pages()
1575 trace_rpc_xdr_alignment(xdr, len, copied); in xdr_align_pages()
1577 return len; in xdr_align_pages()
1592 unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) in xdr_read_pages() argument
1594 unsigned int nwords = XDR_QUADLEN(len); in xdr_read_pages()
1605 return len <= pglen ? len : pglen; in xdr_read_pages()
1620 void xdr_set_pagelen(struct xdr_stream *xdr, unsigned int len) in xdr_set_pagelen() argument
1626 if (len < buf->page_len) { in xdr_set_pagelen()
1627 base = buf->page_len - len; in xdr_set_pagelen()
1628 xdr_shrink_pagelen(buf, len); in xdr_set_pagelen()
1632 if (len > buf->page_len) in xdr_set_pagelen()
1633 xdr_buf_try_expand(buf, len - buf->page_len); in xdr_set_pagelen()
1649 void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) in xdr_enter_page() argument
1651 len = xdr_align_pages(xdr, len); in xdr_enter_page()
1656 if (len != 0) in xdr_enter_page()
1657 xdr_set_page_base(xdr, 0, len); in xdr_enter_page()
1668 buf->buflen = buf->len = iov->iov_len; in xdr_buf_from_iov()
1687 unsigned int base, unsigned int len) in xdr_buf_subsegment() argument
1689 subbuf->buflen = subbuf->len = len; in xdr_buf_subsegment()
1692 subbuf->head[0].iov_len = min_t(unsigned int, len, in xdr_buf_subsegment()
1694 len -= subbuf->head[0].iov_len; in xdr_buf_subsegment()
1703 subbuf->page_len = min(buf->page_len - base, len); in xdr_buf_subsegment()
1707 len -= subbuf->page_len; in xdr_buf_subsegment()
1718 subbuf->tail[0].iov_len = min_t(unsigned int, len, in xdr_buf_subsegment()
1720 len -= subbuf->tail[0].iov_len; in xdr_buf_subsegment()
1728 if (base || len) in xdr_buf_subsegment()
1753 unsigned int remaining, len; in xdr_stream_subsegment() local
1764 len = (char *)xdr->end - (char *)xdr->p; in xdr_stream_subsegment()
1765 if (remaining <= len) { in xdr_stream_subsegment()
1771 xdr->p = (__be32 *)((char *)xdr->p + len); in xdr_stream_subsegment()
1773 remaining -= len; in xdr_stream_subsegment()
1845 void xdr_buf_trim(struct xdr_buf *buf, unsigned int len) in xdr_buf_trim() argument
1848 unsigned int trim = len; in xdr_buf_trim()
1872 buf->len -= (len - trim); in xdr_buf_trim()
1877 void *obj, unsigned int len) in __read_bytes_from_xdr_buf() argument
1881 this_len = min_t(unsigned int, len, subbuf->head[0].iov_len); in __read_bytes_from_xdr_buf()
1883 len -= this_len; in __read_bytes_from_xdr_buf()
1885 this_len = min_t(unsigned int, len, subbuf->page_len); in __read_bytes_from_xdr_buf()
1887 len -= this_len; in __read_bytes_from_xdr_buf()
1889 this_len = min_t(unsigned int, len, subbuf->tail[0].iov_len); in __read_bytes_from_xdr_buf()
1895 void *obj, unsigned int len) in read_bytes_from_xdr_buf() argument
1900 status = xdr_buf_subsegment(buf, &subbuf, base, len); in read_bytes_from_xdr_buf()
1903 __read_bytes_from_xdr_buf(&subbuf, obj, len); in read_bytes_from_xdr_buf()
1909 void *obj, unsigned int len) in __write_bytes_to_xdr_buf() argument
1913 this_len = min_t(unsigned int, len, subbuf->head[0].iov_len); in __write_bytes_to_xdr_buf()
1915 len -= this_len; in __write_bytes_to_xdr_buf()
1917 this_len = min_t(unsigned int, len, subbuf->page_len); in __write_bytes_to_xdr_buf()
1919 len -= this_len; in __write_bytes_to_xdr_buf()
1921 this_len = min_t(unsigned int, len, subbuf->tail[0].iov_len); in __write_bytes_to_xdr_buf()
1927 void *obj, unsigned int len) in write_bytes_to_xdr_buf() argument
1932 status = xdr_buf_subsegment(buf, &subbuf, base, len); in write_bytes_to_xdr_buf()
1935 __write_bytes_to_xdr_buf(&subbuf, obj, len); in write_bytes_to_xdr_buf()
1977 desc->elem_size > buf->len) in xdr_xcode_array2()
2158 if (base >= buf->len) in xdr_decode_array2()
2177 unsigned int len, in xdr_process_buf() argument
2190 if (thislen > len) in xdr_process_buf()
2191 thislen = len; in xdr_process_buf()
2197 len -= thislen; in xdr_process_buf()
2199 if (len == 0) in xdr_process_buf()
2206 if (page_len > len) in xdr_process_buf()
2207 page_len = len; in xdr_process_buf()
2208 len -= page_len; in xdr_process_buf()
2226 if (len == 0) in xdr_process_buf()
2230 if (thislen > len) in xdr_process_buf()
2231 thislen = len; in xdr_process_buf()
2234 len -= thislen; in xdr_process_buf()
2236 if (len != 0) in xdr_process_buf()
2373 ssize_t ret, len; in xdr_stream_decode_opaque_auth() local
2375 len = xdr_stream_decode_u32(xdr, flavor); in xdr_stream_decode_opaque_auth()
2376 if (unlikely(len < 0)) in xdr_stream_decode_opaque_auth()
2377 return len; in xdr_stream_decode_opaque_auth()
2382 return len + ret; in xdr_stream_decode_opaque_auth()
2401 ssize_t ret, len; in xdr_stream_encode_opaque_auth() local
2405 len = xdr_stream_encode_u32(xdr, flavor); in xdr_stream_encode_opaque_auth()
2406 if (unlikely(len < 0)) in xdr_stream_encode_opaque_auth()
2407 return len; in xdr_stream_encode_opaque_auth()
2411 return len + ret; in xdr_stream_encode_opaque_auth()