Lines Matching +full:mmp +full:- +full:timer

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
7 * Florian La Roche, <rzsfl@rz.uni-sb.de>
31 #include <linux/dma-mapping.h>
62 * .. flat-table:: Checksum related device features
65 * * - %NETIF_F_HW_CSUM
66 * - The driver (or its device) is able to compute one
72 * * - %NETIF_F_IP_CSUM
73 * - Driver (device) is only able to checksum plain
82 * * - %NETIF_F_IPV6_CSUM
83 * - Driver (device) is only able to checksum plain
93 * * - %NETIF_F_RXCSUM
94 * - Driver (device) performs receive checksum offload.
106 * - %CHECKSUM_NONE
110 * not in skb->csum. Thus, skb->csum is undefined in this case.
112 * - %CHECKSUM_UNNECESSARY
123 * - TCP: IPv6 and IPv4.
124 * - UDP: IPv4 and IPv6. A device may apply CHECKSUM_UNNECESSARY to a
127 * - GRE: only if the checksum is present in the header.
128 * - SCTP: indicates the CRC in SCTP header has been validated.
129 * - FCOE: indicates the CRC in FC frame has been validated.
133 * For instance if a device receives an IPv6->UDP->GRE->IPv4->TCP packet
138 * checksum is bad, skb->csum_level would be set to zero (TCP checksum is
141 * - %CHECKSUM_COMPLETE
149 * - Even if device supports only some protocols, but is able to produce
150 * skb->csum, it MUST use CHECKSUM_COMPLETE, not CHECKSUM_UNNECESSARY.
151 * - CHECKSUM_COMPLETE is not applicable to SCTP and FCoE protocols.
153 * - %CHECKSUM_PARTIAL
160 * referred to by skb->csum_start + skb->csum_offset and any preceding
165 * Checksumming on transmit for non-GSO
171 * - %CHECKSUM_PARTIAL
179 * checksum refers to a legitimate transport layer checksum -- it is the
197 * - %CHECKSUM_NONE
202 * - %CHECKSUM_UNNECESSARY
207 * - %CHECKSUM_COMPLETE
214 * Non-IP checksum (CRC) offloads
217 * .. flat-table::
220 * * - %NETIF_F_SCTP_CRC
221 * - This feature indicates that a device is capable of
231 * * - %NETIF_F_FCOE_CRC
232 * - This feature indicates that a device is capable of offloading the FCOE
258 /* Maximum value in skb->csum_level */
263 ((X) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
265 SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
297 /* always valid & non-NULL from FORWARD on, for physdev match */
355 /* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
363 * skb_frag_size() - Returns the size of a skb fragment
368 return frag->bv_len; in skb_frag_size()
372 * skb_frag_size_set() - Sets the size of a skb fragment
378 frag->bv_len = size; in skb_frag_size_set()
382 * skb_frag_size_add() - Increments the size of a skb fragment by @delta
388 frag->bv_len += delta; in skb_frag_size_add()
392 * skb_frag_size_sub() - Decrements the size of a skb fragment by @delta
398 frag->bv_len -= delta; in skb_frag_size_sub()
402 * skb_frag_must_loop - Test if %p is a high memory page
415 * skb_frag_foreach_page - loop over pages in a fragment
418 * @f_off: offset from start of f->bv_page
422 * non-zero only on first page.
427 * A fragment can hold a compound page, in which case per-page
433 p_off = (f_off) & (PAGE_SIZE - 1), \
435 min_t(u32, f_len, PAGE_SIZE - p_off) : f_len, \
439 p_len = min_t(u32, f_len - copied, PAGE_SIZE)) \
444 * struct skb_shared_hwtstamps - hardware time stamps
451 * skb->tstamp.
559 } mmp; member
562 #define skb_uarg(SKB) ((struct ubuf_info *)(skb_shinfo(SKB)->destructor_arg))
566 int mm_account_pinned_pages(struct mmpin *mmp, size_t size);
567 void mm_unaccount_pinned_pages(struct mmpin *mmp);
570 * the end of the header data, ie. at skb->end.
606 * The higher 16 bits indicate how many of the references are payload-only.
622 * doing the right thing. In practice there's usually only one payload-only skb.
623 * Having multiple payload-only skbs with different lengths of hdr_len is not
624 * possible. The payload-only skbs should never leave their owner.
627 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
697 * - data buffer, containing headers and sometimes payload;
700 * - shared info (struct skb_shared_info) which holds an array of pointers
701 * to read-only data in the (page, offset, length) format.
707 * ---------------
709 * ---------------
710 * ,--------------------------- + head
711 * / ,----------------- + data
712 * / / ,----------- + tail
716 * -----------------------------------------------
718 * -----------------------------------------------
722 * + [page frag] ---------
723 * + frag_list --> | sk_buff |
724 * ---------
729 * struct sk_buff - socket buffer
734 * for retransmit timer
751 * @csum_start: Offset from skb->head where checksumming should start
764 * @offload_fwd_mark: Packet was L2-forwarded in hardware
765 * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware
770 * @nf_skip_egress: packet shall skip nf egress - see netfilter_netdev.h
776 * @tcp_tsorted_anchor: list structure for TCP (tp->tsorted_sent_queue)
779 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
792 * @l4_hash: indicate hash is a canonical 4-tuple hash over transport
810 * @mono_delivery_time: When set, skb->tstamp has the
812 * skb->tstamp has the (rcv) timestamp at ingress and
826 * skb->inner_protocol_type == ENCAP_TYPE_IPPROTO;
839 * @users: User count - see {datagram,tcp}.c
1049 /* only useable after checking ->active_extensions != 0 */
1086 * skb_pfmemalloc - Test if the skb was allocated from PFMEMALLOC reserves
1091 return unlikely(skb->pfmemalloc); in skb_pfmemalloc()
1102 * skb_dst - returns skb dst_entry
1112 WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) && in skb_dst()
1115 return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK); in skb_dst()
1119 * skb_dst_set - sets skb dst
1128 skb->slow_gro |= !!dst; in skb_dst_set()
1129 skb->_skb_refdst = (unsigned long)dst; in skb_dst_set()
1133 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
1145 skb->slow_gro |= !!dst; in skb_dst_set_noref()
1146 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; in skb_dst_set_noref()
1150 * skb_dst_is_noref - Test if skb dst isn't refcounted
1155 return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb); in skb_dst_is_noref()
1159 * skb_rtable - Returns the skb &rtable
1167 /* For mangling skb->pkt_type from user space side from applications
1177 * skb_napi_id - Returns the skb's NAPI id
1183 return skb->napi_id; in skb_napi_id()
1190 * skb_unref - decrement the skb's reference count
1199 if (likely(refcount_read(&skb->users) == 1)) in skb_unref()
1201 else if (likely(!refcount_dec_and_test(&skb->users))) in skb_unref()
1211 * kfree_skb - free an sk_buff with 'NOT_SPECIFIED' reason
1258 * alloc_skb - allocate a network buffer
1287 * skb_fclone_busy - check if fclone is busy
1302 return skb->fclone == SKB_FCLONE_ORIG && in skb_fclone_busy()
1303 refcount_read(&fclones->fclone_ref) > 1 && in skb_fclone_busy()
1304 READ_ONCE(fclones->skb2.sk) == sk; in skb_fclone_busy()
1308 * alloc_skb_fclone - allocate a network buffer from fclone cache
1348 * skb_pad - zero pad the tail of an skb
1393 * layer-2 (L2), layer-3 (L3), or layer-4 (L4).
1422 skb->hash = 0; in skb_clear_hash()
1423 skb->sw_hash = 0; in skb_clear_hash()
1424 skb->l4_hash = 0; in skb_clear_hash()
1429 if (!skb->l4_hash) in skb_clear_hash_if_not_l4()
1436 skb->l4_hash = is_l4; in __skb_set_hash()
1437 skb->sw_hash = is_sw; in __skb_set_hash()
1438 skb->hash = hash; in __skb_set_hash()
1536 if (!skb->l4_hash && !skb->sw_hash) in skb_get_hash()
1539 return skb->hash; in skb_get_hash()
1544 if (!skb->l4_hash && !skb->sw_hash) { in skb_get_hash_flowi6()
1551 return skb->hash; in skb_get_hash_flowi6()
1559 return skb->hash; in skb_get_hash_raw()
1564 to->hash = from->hash; in skb_copy_hash()
1565 to->sw_hash = from->sw_hash; in skb_copy_hash()
1566 to->l4_hash = from->l4_hash; in skb_copy_hash()
1573 to->decrypted = from->decrypted; in skb_copy_decrypted()
1580 return skb->head + skb->end; in skb_end_pointer()
1585 return skb->end; in skb_end_offset()
1590 skb->end = offset; in skb_set_end_offset()
1595 return skb->end; in skb_end_pointer()
1600 return skb->end - skb->head; in skb_end_offset()
1605 skb->end = skb->head + offset; in skb_set_end_offset()
1624 return __zerocopy_sg_from_iter(msg, skb->sk, skb, &msg->msg_iter, len); in skb_zerocopy_iter_dgram()
1636 return &skb_shinfo(skb)->hwtstamps; in skb_hwtstamps()
1641 bool is_zcopy = skb && skb_shinfo(skb)->flags & SKBFL_ZEROCOPY_ENABLE; in skb_zcopy()
1648 return skb_shinfo(skb)->flags & SKBFL_PURE_ZEROCOPY; in skb_zcopy_pure()
1653 return skb_shinfo(skb)->flags & SKBFL_MANAGED_FRAG_REFS; in skb_zcopy_managed()
1664 refcount_inc(&uarg->refcnt); in net_zcopy_get()
1669 skb_shinfo(skb)->destructor_arg = uarg; in skb_zcopy_init()
1670 skb_shinfo(skb)->flags |= uarg->flags; in skb_zcopy_init()
1687 skb_shinfo(skb)->destructor_arg = (void *)((uintptr_t) val | 0x1UL); in skb_zcopy_set_nouarg()
1688 skb_shinfo(skb)->flags |= SKBFL_ZEROCOPY_FRAG; in skb_zcopy_set_nouarg()
1693 return (uintptr_t) skb_shinfo(skb)->destructor_arg & 0x1UL; in skb_zcopy_is_nouarg()
1698 return (void *)((uintptr_t) skb_shinfo(skb)->destructor_arg & ~0x1UL); in skb_zcopy_get_nouarg()
1704 uarg->callback(NULL, uarg, true); in net_zcopy_put()
1710 if (uarg->callback == msg_zerocopy_callback) in net_zcopy_put_abort()
1724 uarg->callback(skb, uarg, zerocopy_success); in skb_zcopy_clear()
1726 skb_shinfo(skb)->flags &= ~SKBFL_ALL_ZEROCOPY; in skb_zcopy_clear()
1740 skb->next = NULL; in skb_mark_not_on_list()
1743 /* Iterate through singly-linked GSO fragments of an skb. */
1745 for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \
1746 (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
1750 __list_del_entry(&skb->list); in skb_list_del_init()
1755 * skb_queue_empty - check if a queue is empty
1762 return list->next == (const struct sk_buff *) list; in skb_queue_empty()
1766 * skb_queue_empty_lockless - check if a queue is empty
1774 return READ_ONCE(list->next) == (const struct sk_buff *) list; in skb_queue_empty_lockless()
1779 * skb_queue_is_last - check if skb is the last entry in the queue
1788 return skb->next == (const struct sk_buff *) list; in skb_queue_is_last()
1792 * skb_queue_is_first - check if skb is the first entry in the queue
1801 return skb->prev == (const struct sk_buff *) list; in skb_queue_is_first()
1805 * skb_queue_next - return the next packet in the queue
1819 return skb->next; in skb_queue_next()
1823 * skb_queue_prev - return the prev packet in the queue
1837 return skb->prev; in skb_queue_prev()
1841 * skb_get - reference buffer
1849 refcount_inc(&skb->users); in skb_get()
1858 * skb_cloned - is the buffer a clone
1867 return skb->cloned && in skb_cloned()
1868 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1; in skb_cloned()
1881 /* This variant of skb_unclone() makes sure skb->truesize
1882 * and skb_end_offset() are not changed, whenever a new skb->head is needed.
1898 * skb_header_cloned - is the header a clone
1908 if (!skb->cloned) in skb_header_cloned()
1911 dataref = atomic_read(&skb_shinfo(skb)->dataref); in skb_header_cloned()
1912 dataref = (dataref & SKB_DATAREF_MASK) - (dataref >> SKB_DATAREF_SHIFT); in skb_header_cloned()
1927 * __skb_header_release() - allow clones to use the headroom
1934 skb->nohdr = 1; in __skb_header_release()
1935 atomic_set(&skb_shinfo(skb)->dataref, 1 + (1 << SKB_DATAREF_SHIFT)); in __skb_header_release()
1940 * skb_shared - is the buffer shared
1948 return refcount_read(&skb->users) != 1; in skb_shared()
1952 * skb_share_check - check if buffer is shared and if so clone it
1987 * skb_unshare - make a copy of a shared buffer
2017 * skb_peek - peek at the head of an &sk_buff_head
2031 struct sk_buff *skb = list_->next; in skb_peek()
2039 * __skb_peek - peek at the head of a non-empty &sk_buff_head
2046 return list_->next; in __skb_peek()
2050 * skb_peek_next - peek skb following the given one from a queue
2061 struct sk_buff *next = skb->next; in skb_peek_next()
2069 * skb_peek_tail - peek at the tail of an &sk_buff_head
2083 struct sk_buff *skb = READ_ONCE(list_->prev); in skb_peek_tail()
2092 * skb_queue_len - get queue length
2099 return list_->qlen; in skb_queue_len()
2103 * skb_queue_len_lockless - get queue length
2111 return READ_ONCE(list_->qlen); in skb_queue_len_lockless()
2115 * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
2121 * the spinlock. It can also be used for on-stack sk_buff_head
2126 list->prev = list->next = (struct sk_buff *)list; in __skb_queue_head_init()
2127 list->qlen = 0; in __skb_queue_head_init()
2132 * this is needed for now since a whole lot of users of the skb-queue
2140 spin_lock_init(&list->lock); in skb_queue_head_init()
2148 lockdep_set_class(&list->lock, class); in skb_queue_head_init_class()
2154 * The "__skb_xxxx()" functions are the non-atomic ones that
2164 WRITE_ONCE(newsk->next, next); in __skb_insert()
2165 WRITE_ONCE(newsk->prev, prev); in __skb_insert()
2166 WRITE_ONCE(((struct sk_buff_list *)next)->prev, newsk); in __skb_insert()
2167 WRITE_ONCE(((struct sk_buff_list *)prev)->next, newsk); in __skb_insert()
2168 WRITE_ONCE(list->qlen, list->qlen + 1); in __skb_insert()
2175 struct sk_buff *first = list->next; in __skb_queue_splice()
2176 struct sk_buff *last = list->prev; in __skb_queue_splice()
2178 WRITE_ONCE(first->prev, prev); in __skb_queue_splice()
2179 WRITE_ONCE(prev->next, first); in __skb_queue_splice()
2181 WRITE_ONCE(last->next, next); in __skb_queue_splice()
2182 WRITE_ONCE(next->prev, last); in __skb_queue_splice()
2186 * skb_queue_splice - join two skb lists, this is designed for stacks
2194 __skb_queue_splice(list, (struct sk_buff *) head, head->next); in skb_queue_splice()
2195 head->qlen += list->qlen; in skb_queue_splice()
2200 * skb_queue_splice_init - join two skb lists and reinitialise the emptied list
2210 __skb_queue_splice(list, (struct sk_buff *) head, head->next); in skb_queue_splice_init()
2211 head->qlen += list->qlen; in skb_queue_splice_init()
2217 * skb_queue_splice_tail - join two skb lists, each list being a queue
2225 __skb_queue_splice(list, head->prev, (struct sk_buff *) head); in skb_queue_splice_tail()
2226 head->qlen += list->qlen; in skb_queue_splice_tail()
2231 * skb_queue_splice_tail_init - join two skb lists and reinitialise the emptied list
2242 __skb_queue_splice(list, head->prev, (struct sk_buff *) head); in skb_queue_splice_tail_init()
2243 head->qlen += list->qlen; in skb_queue_splice_tail_init()
2249 * __skb_queue_after - queue a buffer at the list head
2263 __skb_insert(newsk, prev, ((struct sk_buff_list *)prev)->next, list); in __skb_queue_after()
2273 __skb_insert(newsk, ((struct sk_buff_list *)next)->prev, next, list); in __skb_queue_before()
2277 * __skb_queue_head - queue a buffer at the list head
2294 * __skb_queue_tail - queue a buffer at the list tail
2319 WRITE_ONCE(list->qlen, list->qlen - 1); in __skb_unlink()
2320 next = skb->next; in __skb_unlink()
2321 prev = skb->prev; in __skb_unlink()
2322 skb->next = skb->prev = NULL; in __skb_unlink()
2323 WRITE_ONCE(next->prev, prev); in __skb_unlink()
2324 WRITE_ONCE(prev->next, next); in __skb_unlink()
2328 * __skb_dequeue - remove from the head of the queue
2345 * __skb_dequeue_tail - remove from the tail of the queue
2364 return skb->data_len; in skb_is_nonlinear()
2369 return skb->len - skb->data_len; in skb_headlen()
2376 for (i = skb_shinfo(skb)->nr_frags - 1; (int)i >= 0; i--) in __skb_pagelen()
2377 len += skb_frag_size(&skb_shinfo(skb)->frags[i]); in __skb_pagelen()
2390 skb_frag_t *frag = &shinfo->frags[i]; in __skb_fill_page_desc_noacc()
2397 frag->bv_page = page; in __skb_fill_page_desc_noacc()
2398 frag->bv_offset = off; in __skb_fill_page_desc_noacc()
2403 * skb_len_add - adds a number to len fields of skb
2409 skb->len += delta; in skb_len_add()
2410 skb->data_len += delta; in skb_len_add()
2411 skb->truesize += delta; in skb_len_add()
2415 * __skb_fill_page_desc - initialise a paged fragment in an skb
2433 skb->pfmemalloc = true; in __skb_fill_page_desc()
2437 * skb_fill_page_desc - initialise a paged fragment in an skb
2444 * As per __skb_fill_page_desc() -- initialises the @i'th fragment of
2454 skb_shinfo(skb)->nr_frags = i + 1; in skb_fill_page_desc()
2458 * skb_fill_page_desc_noacc - initialise a paged fragment in an skb
2475 shinfo->nr_frags = i + 1; in skb_fill_page_desc_noacc()
2489 return skb->head + skb->tail; in skb_tail_pointer()
2494 skb->tail = skb->data - skb->head; in skb_reset_tail_pointer()
2500 skb->tail += offset; in skb_set_tail_pointer()
2506 return skb->tail; in skb_tail_pointer()
2511 skb->tail = skb->data; in skb_reset_tail_pointer()
2516 skb->tail = skb->data + offset; in skb_set_tail_pointer()
2524 if (WARN_ONCE(!skb->len, "%s\n", __func__)) in skb_assert_len()
2538 skb->tail += len; in __skb_put()
2539 skb->len += len; in __skb_put()
2592 skb->data -= len; in __skb_push()
2593 skb->len += len; in __skb_push()
2594 return skb->data; in __skb_push()
2600 skb->len -= len; in __skb_pull()
2601 if (unlikely(skb->len < skb->data_len)) { in __skb_pull()
2603 skb->len += len; in __skb_pull()
2609 return skb->data += len; in __skb_pull()
2614 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); in skb_pull_inline()
2625 if (unlikely(len > skb->len)) in pskb_may_pull()
2627 return __pskb_pull_tail(skb, len - skb_headlen(skb)) != NULL; in pskb_may_pull()
2635 skb->len -= len; in pskb_pull()
2636 return skb->data += len; in pskb_pull()
2642 * skb_headroom - bytes at buffer head
2649 return skb->data - skb->head; in skb_headroom()
2653 * skb_tailroom - bytes at buffer end
2660 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail; in skb_tailroom()
2664 * skb_availroom - bytes at buffer end
2675 return skb->end - skb->tail - skb->reserved_tailroom; in skb_availroom()
2679 * skb_reserve - adjust headroom
2688 skb->data += len; in skb_reserve()
2689 skb->tail += len; in skb_reserve()
2693 * skb_tailroom_reserve - adjust reserved_tailroom
2708 if (mtu < skb_tailroom(skb) - needed_tailroom) in skb_tailroom_reserve()
2710 skb->reserved_tailroom = skb_tailroom(skb) - mtu; in skb_tailroom_reserve()
2713 skb->reserved_tailroom = needed_tailroom; in skb_tailroom_reserve()
2722 skb->inner_protocol = protocol; in skb_set_inner_protocol()
2723 skb->inner_protocol_type = ENCAP_TYPE_ETHER; in skb_set_inner_protocol()
2729 skb->inner_ipproto = ipproto; in skb_set_inner_ipproto()
2730 skb->inner_protocol_type = ENCAP_TYPE_IPPROTO; in skb_set_inner_ipproto()
2735 skb->inner_mac_header = skb->mac_header; in skb_reset_inner_headers()
2736 skb->inner_network_header = skb->network_header; in skb_reset_inner_headers()
2737 skb->inner_transport_header = skb->transport_header; in skb_reset_inner_headers()
2742 skb->mac_len = skb->network_header - skb->mac_header; in skb_reset_mac_len()
2748 return skb->head + skb->inner_transport_header; in skb_inner_transport_header()
2753 return skb_inner_transport_header(skb) - skb->data; in skb_inner_transport_offset()
2758 skb->inner_transport_header = skb->data - skb->head; in skb_reset_inner_transport_header()
2765 skb->inner_transport_header += offset; in skb_set_inner_transport_header()
2770 return skb->head + skb->inner_network_header; in skb_inner_network_header()
2775 skb->inner_network_header = skb->data - skb->head; in skb_reset_inner_network_header()
2782 skb->inner_network_header += offset; in skb_set_inner_network_header()
2787 return skb->head + skb->inner_mac_header; in skb_inner_mac_header()
2792 skb->inner_mac_header = skb->data - skb->head; in skb_reset_inner_mac_header()
2799 skb->inner_mac_header += offset; in skb_set_inner_mac_header()
2803 return skb->transport_header != (typeof(skb->transport_header))~0U; in skb_transport_header_was_set()
2809 return skb->head + skb->transport_header; in skb_transport_header()
2814 skb->transport_header = skb->data - skb->head; in skb_reset_transport_header()
2821 skb->transport_header += offset; in skb_set_transport_header()
2826 return skb->head + skb->network_header; in skb_network_header()
2831 skb->network_header = skb->data - skb->head; in skb_reset_network_header()
2837 skb->network_header += offset; in skb_set_network_header()
2842 return skb->mac_header != (typeof(skb->mac_header))~0U; in skb_mac_header_was_set()
2848 return skb->head + skb->mac_header; in skb_mac_header()
2853 return skb_mac_header(skb) - skb->data; in skb_mac_offset()
2859 return skb->network_header - skb->mac_header; in skb_mac_header_len()
2864 skb->mac_header = (typeof(skb->mac_header))~0U; in skb_unset_mac_header()
2869 skb->mac_header = skb->data - skb->head; in skb_reset_mac_header()
2875 skb->mac_header += offset; in skb_set_mac_header()
2880 skb->mac_header = skb->network_header; in skb_pop_mac_header()
2900 skb_set_mac_header(skb, -skb->mac_len); in skb_mac_header_rebuild()
2901 memmove(skb_mac_header(skb), old_mac, skb->mac_len); in skb_mac_header_rebuild()
2907 return skb->csum_start - skb_headroom(skb); in skb_checksum_start_offset()
2912 return skb->head + skb->csum_start; in skb_checksum_start()
2917 return skb_transport_header(skb) - skb->data; in skb_transport_offset()
2922 return skb->transport_header - skb->network_header; in skb_network_header_len()
2927 return skb->inner_transport_header - skb->inner_network_header; in skb_inner_network_header_len()
2932 return skb_network_header(skb) - skb->data; in skb_network_offset()
2937 return skb_inner_network_header(skb) - skb->data; in skb_inner_network_offset()
2999 skb->len = len; in __skb_set_length()
3012 if (skb->data_len) in __pskb_trim()
3020 return (len < skb->len) ? __pskb_trim(skb, len) : 0; in pskb_trim()
3024 * pskb_trim_unique - remove end from a paged unique (not cloned) buffer
3029 * the skb is not cloned so we should never get an error due to out-
3030 * of-memory.
3040 unsigned int diff = len - skb->len; in __skb_grow()
3043 int ret = pskb_expand_head(skb, 0, diff - skb_tailroom(skb), in __skb_grow()
3053 * skb_orphan - orphan a buffer
3062 if (skb->destructor) { in skb_orphan()
3063 skb->destructor(skb); in skb_orphan()
3064 skb->destructor = NULL; in skb_orphan()
3065 skb->sk = NULL; in skb_orphan()
3067 BUG_ON(skb->sk); in skb_orphan()
3072 * skb_orphan_frags - orphan the frags contained in a buffer
3084 if (skb_shinfo(skb)->flags & SKBFL_DONT_ORPHAN) in skb_orphan_frags()
3098 * __skb_queue_purge - empty a list
3118 * netdev_alloc_frag - allocate a page fragment
3133 return __netdev_alloc_frag_align(fragsz, -align); in netdev_alloc_frag_align()
3140 * netdev_alloc_skb - allocate an skbuff for rx on a specific device
3204 return __napi_alloc_frag_align(fragsz, -align); in napi_alloc_frag_align()
3220 * __dev_alloc_pages - allocate page for network Rx
3250 * __dev_alloc_page - allocate a page for network Rx
3268 * dev_page_is_reusable - check whether a page can be reused for network Rx
3284 * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated after RX page
3292 skb->pfmemalloc = true; in skb_propagate_pfmemalloc()
3296 * skb_frag_off() - Returns the offset of a skb fragment
3301 return frag->bv_offset; in skb_frag_off()
3305 * skb_frag_off_add() - Increments the offset of a skb fragment by @delta
3311 frag->bv_offset += delta; in skb_frag_off_add()
3315 * skb_frag_off_set() - Sets the offset of a skb fragment
3321 frag->bv_offset = offset; in skb_frag_off_set()
3325 * skb_frag_off_copy() - Sets the offset of a skb fragment from another fragment
3332 fragto->bv_offset = fragfrom->bv_offset; in skb_frag_off_copy()
3336 * skb_frag_page - retrieve the page referred to by a paged fragment
3343 return frag->bv_page; in skb_frag_page()
3347 * __skb_frag_ref - take an addition reference on a paged fragment.
3358 * skb_frag_ref - take an addition reference on a paged fragment of an skb.
3366 __skb_frag_ref(&skb_shinfo(skb)->frags[f]); in skb_frag_ref()
3370 * __skb_frag_unref - release a reference on a paged fragment.
3389 * skb_frag_unref - release a reference on a paged fragment of an skb.
3400 __skb_frag_unref(&shinfo->frags[f], skb->pp_recycle); in skb_frag_unref()
3404 * skb_frag_address - gets the address of the data contained in a paged fragment
3416 * skb_frag_address_safe - gets the address of the data contained in a paged fragment
3432 * skb_frag_page_copy() - sets the page in a fragment from another fragment
3439 fragto->bv_page = fragfrom->bv_page; in skb_frag_page_copy()
3443 * __skb_frag_set_page - sets the page contained in a paged fragment
3451 frag->bv_page = page; in __skb_frag_set_page()
3455 * skb_frag_set_page - sets the page contained in a paged fragment of an skb
3465 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page); in skb_frag_set_page()
3471 * skb_frag_dma_map - maps a paged fragment via the DMA API
3505 * skb_clone_writable - is the header of a clone writable
3515 skb_headroom(skb) + len <= skb->hdr_len; in skb_clone_writable()
3531 delta = headroom - skb_headroom(skb); in __skb_cow()
3540 * skb_cow - copy header of skb when it is required
3548 * The result is skb with writable area skb->head...skb->tail
3557 * skb_cow_head - skb_cow but only making the head writable
3572 * skb_padto - pad an skbuff up to a minimal size
3583 unsigned int size = skb->len; in skb_padto()
3586 return skb_pad(skb, len - size); in skb_padto()
3590 * __skb_put_padto - increase size and pad an skbuff up to a minimal size
3604 unsigned int size = skb->len; in __skb_put_padto()
3607 len -= size; in __skb_put_padto()
3609 return -ENOMEM; in __skb_put_padto()
3616 * skb_put_padto - increase size and pad an skbuff up to a minimal size
3633 const int off = skb->len; in skb_add_data()
3635 if (skb->ip_summed == CHECKSUM_NONE) { in skb_add_data()
3639 skb->csum = csum_block_add(skb->csum, csum, off); in skb_add_data()
3646 return -EFAULT; in skb_add_data()
3655 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; in skb_can_coalesce()
3665 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM; in __skb_linearize()
3669 * skb_linearize - convert paged skb to linear one
3672 * If there is no free memory -ENOMEM is returned, otherwise zero
3681 * skb_has_shared_frag - can any frag be overwritten
3690 skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG; in skb_has_shared_frag()
3694 * skb_linearize_cow - make sure skb is linear and writable
3697 * If there is no free memory -ENOMEM is returned, otherwise zero
3710 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpull_rcsum()
3711 skb->csum = csum_block_sub(skb->csum, in __skb_postpull_rcsum()
3713 else if (skb->ip_summed == CHECKSUM_PARTIAL && in __skb_postpull_rcsum()
3715 skb->ip_summed = CHECKSUM_NONE; in __skb_postpull_rcsum()
3719 * skb_postpull_rcsum - update checksum for received skb after pull
3731 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_postpull_rcsum()
3732 skb->csum = wsum_negate(csum_partial(start, len, in skb_postpull_rcsum()
3733 wsum_negate(skb->csum))); in skb_postpull_rcsum()
3734 else if (skb->ip_summed == CHECKSUM_PARTIAL && in skb_postpull_rcsum()
3736 skb->ip_summed = CHECKSUM_NONE; in skb_postpull_rcsum()
3743 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpush_rcsum()
3744 skb->csum = csum_block_add(skb->csum, in __skb_postpush_rcsum()
3749 * skb_postpush_rcsum - update checksum for received skb after push
3766 * skb_push_rcsum - push skb and update receive checksum
3779 skb_postpush_rcsum(skb, skb->data, len); in skb_push_rcsum()
3780 return skb->data; in skb_push_rcsum()
3785 * pskb_trim_rcsum - trim received skb and update checksum
3796 if (likely(len >= skb->len)) in pskb_trim_rcsum()
3803 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_trim_rcsum()
3804 skb->ip_summed = CHECKSUM_NONE; in __skb_trim_rcsum()
3811 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_grow_rcsum()
3812 skb->ip_summed = CHECKSUM_NONE; in __skb_grow_rcsum()
3819 #define skb_rb_next(skb) rb_to_skb(rb_next(&(skb)->rbnode))
3820 #define skb_rb_prev(skb) rb_to_skb(rb_prev(&(skb)->rbnode))
3823 for (skb = (queue)->next; \
3825 skb = skb->next)
3828 for (skb = (queue)->next, tmp = skb->next; \
3830 skb = tmp, tmp = skb->next)
3834 skb = skb->next)
3849 for (tmp = skb->next; \
3851 skb = tmp, tmp = skb->next)
3854 for (skb = (queue)->prev; \
3856 skb = skb->prev)
3859 for (skb = (queue)->prev, tmp = skb->prev; \
3861 skb = tmp, tmp = skb->prev)
3864 for (tmp = skb->prev; \
3866 skb = tmp, tmp = skb->prev)
3870 return skb_shinfo(skb)->frag_list != NULL; in skb_has_frag_list()
3875 skb_shinfo(skb)->frag_list = NULL; in skb_frag_list_init()
3879 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
3905 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size); in skb_copy_datagram_msg()
3964 return copy_from_iter_full(data, len, &msg->msg_iter) ? 0 : -EFAULT; in memcpy_from_msg()
3969 return copy_to_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT; in memcpy_to_msg()
3988 if (likely(hlen - offset >= len)) in __skb_header_pointer()
4000 return __skb_header_pointer(skb, offset, len, skb->data, in skb_header_pointer()
4005 * skb_needs_linearize - check if we need to linearize a given skb
4019 (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG))); in skb_needs_linearize()
4026 memcpy(to, skb->data, len); in skb_copy_from_linear_data()
4033 memcpy(to, skb->data + offset, len); in skb_copy_from_linear_data_offset()
4040 memcpy(skb->data, from, len); in skb_copy_to_linear_data()
4048 memcpy(skb->data + offset, from, len); in skb_copy_to_linear_data_offset()
4055 return skb->tstamp; in skb_get_ktime()
4059 * skb_get_timestamp - get timestamp from a skb
4070 *stamp = ns_to_kernel_old_timeval(skb->tstamp); in skb_get_timestamp()
4076 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestamp()
4078 stamp->tv_sec = ts.tv_sec; in skb_get_new_timestamp()
4079 stamp->tv_usec = ts.tv_nsec / 1000; in skb_get_new_timestamp()
4085 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_timestampns()
4087 stamp->tv_sec = ts.tv_sec; in skb_get_timestampns()
4088 stamp->tv_nsec = ts.tv_nsec; in skb_get_timestampns()
4094 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestampns()
4096 stamp->tv_sec = ts.tv_sec; in skb_get_new_timestampns()
4097 stamp->tv_nsec = ts.tv_nsec; in skb_get_new_timestampns()
4102 skb->tstamp = ktime_get_real(); in __net_timestamp()
4103 skb->mono_delivery_time = 0; in __net_timestamp()
4114 skb->tstamp = kt; in skb_set_delivery_time()
4115 skb->mono_delivery_time = kt && mono; in skb_set_delivery_time()
4121 * If needed, set the skb->tstamp to the (rcv) timestamp.
4125 if (skb->mono_delivery_time) { in skb_clear_delivery_time()
4126 skb->mono_delivery_time = 0; in skb_clear_delivery_time()
4128 skb->tstamp = ktime_get_real(); in skb_clear_delivery_time()
4130 skb->tstamp = 0; in skb_clear_delivery_time()
4136 if (skb->mono_delivery_time) in skb_clear_tstamp()
4139 skb->tstamp = 0; in skb_clear_tstamp()
4144 if (skb->mono_delivery_time) in skb_tstamp()
4147 return skb->tstamp; in skb_tstamp()
4152 if (!skb->mono_delivery_time && skb->tstamp) in skb_tstamp_cond()
4153 return skb->tstamp; in skb_tstamp_cond()
4163 return skb_shinfo(skb)->meta_len; in skb_metadata_len()
4182 #define __it(x, op) (x -= sizeof(u##op)) in __skb_metadata_differs()
4203 return memcmp(a - meta_len, b - meta_len, meta_len); in __skb_metadata_differs()
4222 skb_shinfo(skb)->meta_len = meta_len; in skb_metadata_set()
4251 * skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps
4270 * skb_tstamp_tx - queue clone of skb with send time stamps
4284 * skb_tx_timestamp() - Driver hook for transmit timestamping
4298 if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP) in skb_tx_timestamp()
4303 * skb_complete_wifi_ack - deliver skb with wifi status
4316 return ((skb->ip_summed == CHECKSUM_UNNECESSARY) || in skb_csum_unnecessary()
4317 skb->csum_valid || in skb_csum_unnecessary()
4318 (skb->ip_summed == CHECKSUM_PARTIAL && in skb_csum_unnecessary()
4323 * skb_checksum_complete - Calculate checksum of an entire packet
4327 * the value of skb->csum. The latter can be used to supply the
4335 * if skb->ip_summed is CHECKSUM_UNNECESSARY which indicates that the
4346 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_decr_checksum_unnecessary()
4347 if (skb->csum_level == 0) in __skb_decr_checksum_unnecessary()
4348 skb->ip_summed = CHECKSUM_NONE; in __skb_decr_checksum_unnecessary()
4350 skb->csum_level--; in __skb_decr_checksum_unnecessary()
4356 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_incr_checksum_unnecessary()
4357 if (skb->csum_level < SKB_MAX_CSUM_LEVEL) in __skb_incr_checksum_unnecessary()
4358 skb->csum_level++; in __skb_incr_checksum_unnecessary()
4359 } else if (skb->ip_summed == CHECKSUM_NONE) { in __skb_incr_checksum_unnecessary()
4360 skb->ip_summed = CHECKSUM_UNNECESSARY; in __skb_incr_checksum_unnecessary()
4361 skb->csum_level = 0; in __skb_incr_checksum_unnecessary()
4367 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_reset_checksum_unnecessary()
4368 skb->ip_summed = CHECKSUM_NONE; in __skb_reset_checksum_unnecessary()
4369 skb->csum_level = 0; in __skb_reset_checksum_unnecessary()
4383 skb->csum_valid = 1; in __skb_checksum_validate_needed()
4396 /* Unset checksum-complete
4399 * (uncompressed for instance) and checksum-complete value is
4404 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_checksum_complete_unset()
4405 skb->ip_summed = CHECKSUM_NONE; in skb_checksum_complete_unset()
4413 * checksum is stored in skb->csum for use in __skb_checksum_complete
4414 * non-zero: value of invalid checksum
4421 if (skb->ip_summed == CHECKSUM_COMPLETE) { in __skb_checksum_validate_complete()
4422 if (!csum_fold(csum_add(psum, skb->csum))) { in __skb_checksum_validate_complete()
4423 skb->csum_valid = 1; in __skb_checksum_validate_complete()
4428 skb->csum = psum; in __skb_checksum_validate_complete()
4430 if (complete || skb->len <= CHECKSUM_BREAK) { in __skb_checksum_validate_complete()
4434 skb->csum_valid = !csum; in __skb_checksum_validate_complete()
4454 * non-zero: value of invalid checksum
4460 skb->csum_valid = 0; \
4485 return (skb->ip_summed == CHECKSUM_NONE && skb->csum_valid); in __skb_checksum_convert_check()
4490 skb->csum = ~pseudo; in __skb_checksum_convert()
4491 skb->ip_summed = CHECKSUM_COMPLETE; in __skb_checksum_convert()
4503 skb->ip_summed = CHECKSUM_PARTIAL; in skb_remcsum_adjust_partial()
4504 skb->csum_start = ((unsigned char *)ptr + start) - skb->head; in skb_remcsum_adjust_partial()
4505 skb->csum_offset = offset - start; in skb_remcsum_adjust_partial()
4509 * When called, ptr indicates the starting point for skb->csum when
4511 * here, skb_postpull_rcsum is done so skb->csum start is ptr.
4523 if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) { in skb_remcsum_process()
4525 skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data); in skb_remcsum_process()
4528 delta = remcsum_adjust(ptr, skb->csum, start, offset); in skb_remcsum_process()
4530 /* Adjust skb->csum since we changed the packet */ in skb_remcsum_process()
4531 skb->csum = csum_add(skb->csum, delta); in skb_remcsum_process()
4537 return (void *)(skb->_nfct & NFCT_PTRMASK); in skb_nfct()
4546 return skb->_nfct; in skb_get_nfct()
4555 skb->slow_gro |= !!nfct; in skb_set_nfct()
4556 skb->_nfct = nfct; in skb_set_nfct()
4581 * struct skb_ext - sk_buff extensions
4606 if (skb->active_extensions) in skb_ext_put()
4607 __skb_ext_put(skb->extensions); in skb_ext_put()
4613 dst->active_extensions = src->active_extensions; in __skb_ext_copy()
4615 if (src->active_extensions) { in __skb_ext_copy()
4616 struct skb_ext *ext = src->extensions; in __skb_ext_copy()
4618 refcount_inc(&ext->refcnt); in __skb_ext_copy()
4619 dst->extensions = ext; in __skb_ext_copy()
4631 return !!ext->offset[i]; in __skb_ext_exist()
4636 return skb->active_extensions & (1 << id); in skb_ext_exist()
4648 struct skb_ext *ext = skb->extensions; in skb_ext_find()
4650 return (void *)ext + (ext->offset[id] << 3); in skb_ext_find()
4658 if (unlikely(skb->active_extensions)) { in skb_ext_reset()
4659 __skb_ext_put(skb->extensions); in skb_ext_reset()
4660 skb->active_extensions = 0; in skb_ext_reset()
4666 return unlikely(skb->active_extensions); in skb_has_extensions()
4681 skb->_nfct = 0; in nf_reset_ct()
4688 skb->nf_trace = 0; in nf_reset_trace()
4695 skb->ipvs_property = 0; in ipvs_reset()
4704 dst->_nfct = src->_nfct; in __nf_copy()
4709 dst->nf_trace = src->nf_trace; in __nf_copy()
4718 dst->slow_gro = src->slow_gro; in nf_copy()
4725 to->secmark = from->secmark; in skb_copy_secmark()
4730 skb->secmark = 0; in skb_init_secmark()
4751 return !skb->destructor && in skb_irq_freeable()
4754 !skb->_skb_refdst && in skb_irq_freeable()
4760 skb->queue_mapping = queue_mapping; in skb_set_queue_mapping()
4765 return skb->queue_mapping; in skb_get_queue_mapping()
4770 to->queue_mapping = from->queue_mapping; in skb_copy_queue_mapping()
4775 skb->queue_mapping = rx_queue + 1; in skb_record_rx_queue()
4780 return skb->queue_mapping - 1; in skb_get_rx_queue()
4785 return skb->queue_mapping != 0; in skb_rx_queue_recorded()
4790 skb->dst_pending_confirm = val; in skb_set_dst_pending_confirm()
4795 return skb->dst_pending_confirm != 0; in skb_get_dst_pending_confirm()
4807 /* Keeps track of mac header offset relative to skb->head.
4809 * For non-tunnel skb it points to skb_mac_header() and for
4823 #define SKB_GSO_CB(skb) ((struct skb_gso_cb *)((skb)->cb + SKB_GSO_CB_OFFSET))
4827 return (skb_mac_header(inner_skb) - inner_skb->head) - in skb_tnl_header_len()
4828 SKB_GSO_CB(inner_skb)->mac_offset; in skb_tnl_header_len()
4842 SKB_GSO_CB(skb)->mac_offset += (new_headroom - headroom); in gso_pskb_expand_head()
4849 if (skb->remcsum_offload) in gso_reset_checksum()
4852 SKB_GSO_CB(skb)->csum = res; in gso_reset_checksum()
4853 SKB_GSO_CB(skb)->csum_start = skb_checksum_start(skb) - skb->head; in gso_reset_checksum()
4857 * from the start of transport header to SKB_GSO_CB(skb)->csum_start, and
4858 * then add in skb->csum (checksum from csum_start to end of packet).
4859 * skb->csum and csum_start are then updated to reflect the checksum of the
4860 * resultant packet starting from the transport header-- the resultant checksum
4867 int plen = (skb->head + SKB_GSO_CB(skb)->csum_start) - csum_start; in gso_make_checksum()
4868 __wsum partial = SKB_GSO_CB(skb)->csum; in gso_make_checksum()
4870 SKB_GSO_CB(skb)->csum = res; in gso_make_checksum()
4871 SKB_GSO_CB(skb)->csum_start = csum_start - skb->head; in gso_make_checksum()
4878 return skb_shinfo(skb)->gso_size; in skb_is_gso()
4884 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; in skb_is_gso_v6()
4890 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; in skb_is_gso_sctp()
4896 return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6); in skb_is_gso_tcp()
4901 skb_shinfo(skb)->gso_size = 0; in skb_gso_reset()
4902 skb_shinfo(skb)->gso_segs = 0; in skb_gso_reset()
4903 skb_shinfo(skb)->gso_type = 0; in skb_gso_reset()
4909 if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) in skb_increase_gso_size()
4911 shinfo->gso_size += increment; in skb_increase_gso_size()
4917 if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) in skb_decrease_gso_size()
4919 shinfo->gso_size -= decrement; in skb_decrease_gso_size()
4930 if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 && in skb_warn_if_lro()
4931 unlikely(shinfo->gso_type == 0)) { in skb_warn_if_lro()
4941 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_forward_csum()
4942 skb->ip_summed = CHECKSUM_NONE; in skb_forward_csum()
4946 * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
4955 DEBUG_NET_WARN_ON_ONCE(skb->ip_summed != CHECKSUM_NONE); in skb_checksum_none_assert()
4966 * skb_head_is_locked - Determine if the skb->head is locked down
4976 return !skb->head_frag || skb_cloned(skb); in skb_head_is_locked()
4982 * See Documentation/networking/checksum-offloads.rst for
4985 * pseudo-header) before calling.
4996 skb->csum_offset)); in lco_csum()
5001 return csum_partial(l4_hdr, csum_start - l4_hdr, partial); in lco_csum()
5006 return skb->redirected; in skb_is_redirected()
5011 skb->redirected = 1; in skb_set_redirected()
5013 skb->from_ingress = from_ingress; in skb_set_redirected()
5014 if (skb->from_ingress) in skb_set_redirected()
5021 skb->redirected = 0; in skb_reset_redirect()
5026 return skb->csum_not_inet; in skb_csum_is_sctp()
5033 skb->kcov_handle = kcov_handle; in skb_set_kcov_handle()
5040 return skb->kcov_handle; in skb_get_kcov_handle()
5049 skb->pp_recycle = 1; in skb_mark_for_recycle()
5055 if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle) in skb_pp_recycle()