Lines Matching +full:rx +full:- +full:sched +full:- +full:sp
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
7 * Florian La Roche, <rzsfl@rz.uni-sb.de>
31 #include <linux/dma-mapping.h>
33 #include <linux/sched.h>
34 #include <linux/sched/clock.h>
56 * NETIF_F_HW_CSUM - The driver (or its device) is able to compute one
62 * NETIF_F_IP_CSUM - Driver (device) is only able to checksum plain
71 * NETIF_F_IPV6_CSUM - Driver (device) is only able to checksum plain
81 * NETIF_F_RXCSUM - Driver (device) performs receive checksum offload.
82 * This flag is only used to disable the RX checksum
88 * verification is set in skb->ip_summed. Possible values are:
94 * not in skb->csum. Thus, skb->csum is undefined in this case.
101 * if their checksums are okay. skb->csum is still undefined in this case
114 * skb->csum_level indicates the number of consecutive checksums found in
116 * For instance if a device receives an IPv6->UDP->GRE->IPv4->TCP packet
118 * GRE (checksum flag is set) and TCP, skb->csum_level would be set to
121 * checksum is bad, skb->csum_level would be set to zero (TCP checksum is
127 * packet as seen by netif_rx() and fills in skb->csum. This means the
131 * - Even if device supports only some protocols, but is able to produce
132 * skb->csum, it MUST use CHECKSUM_COMPLETE, not CHECKSUM_UNNECESSARY.
133 * - CHECKSUM_COMPLETE is not applicable to SCTP and FCoE protocols.
142 * referred to by skb->csum_start + skb->csum_offset and any preceding
147 * C. Checksumming on transmit for non-GSO. The stack requests checksum offload
148 * in the skb->ip_summed for a packet. Values are:
153 * from skb->csum_start up to the end, and to record/write the checksum at
154 * offset skb->csum_start + skb->csum_offset. A driver may verify that the
157 * checksum refers to a legitimate transport layer checksum -- it is the
188 * D. Non-IP checksum (CRC) offloads
190 * NETIF_F_SCTP_CRC - This feature indicates that a device is capable of
197 * value of skb->csum_not_inet; skb_crc32c_csum_help is provided to resolve
200 * NETIF_F_FCOE_CRC - This feature indicates that a device is capable of
225 /* Maximum value in skb->csum_level */
230 ((X) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
232 SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
264 /* always valid & non-NULL from FORWARD on, for physdev match */
316 /* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
324 * skb_frag_size() - Returns the size of a skb fragment
329 return frag->bv_len; in skb_frag_size()
333 * skb_frag_size_set() - Sets the size of a skb fragment
339 frag->bv_len = size; in skb_frag_size_set()
343 * skb_frag_size_add() - Increments the size of a skb fragment by @delta
349 frag->bv_len += delta; in skb_frag_size_add()
353 * skb_frag_size_sub() - Decrements the size of a skb fragment by @delta
359 frag->bv_len -= delta; in skb_frag_size_sub()
363 * skb_frag_must_loop - Test if %p is a high memory page
376 * skb_frag_foreach_page - loop over pages in a fragment
379 * @f_off: offset from start of f->bv_page
383 * non-zero only on first page.
388 * A fragment can hold a compound page, in which case per-page
394 p_off = (f_off) & (PAGE_SIZE - 1), \
396 min_t(u32, f_len, PAGE_SIZE - p_off) : f_len, \
400 p_len = min_t(u32, f_len - copied, PAGE_SIZE)) \
405 * struct skb_shared_hwtstamps - hardware time stamps
410 * skb->tstamp.
433 /* device driver supports TX zero-copy buffers */
485 #define skb_uarg(SKB) ((struct ubuf_info *)(skb_shinfo(SKB)->destructor_arg))
496 refcount_inc(&uarg->refcnt); in sock_zerocopy_get()
510 * the end of the header data, ie. at skb->end.
539 * to the payload part of skb->data. The lower 16 bits hold references to
540 * the entire skb->data. A clone of a headerless skb holds the length of
541 * the header in skb->hdr_len.
543 * All users must obey the rule that the skb->data reference count must be
547 * care about modifications to the header part of skb->data.
550 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
612 * struct sk_buff - socket buffer
627 * @sp: the security path, used for xfrm
633 * @csum_start: Offset from skb->head where checksumming should start
646 * @offload_fwd_mark: Packet was L2-forwarded in hardware
647 * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware
657 * @tcp_tsorted_anchor: list structure for TCP (tp->tsorted_sent_queue)
659 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
670 * @l4_hash: indicate hash is a canonical 4-tuple hash over transport
697 * skb->inner_protocol_type == ENCAP_TYPE_IPPROTO;
709 * @users: User count - see {datagram,tcp}.c
920 /* only useable after checking ->active_extensions != 0 */
935 * skb_pfmemalloc - Test if the skb was allocated from PFMEMALLOC reserves
940 return unlikely(skb->pfmemalloc); in skb_pfmemalloc()
951 * skb_dst - returns skb dst_entry
961 WARN_ON((skb->_skb_refdst & SKB_DST_NOREF) && in skb_dst()
964 return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK); in skb_dst()
968 * skb_dst_set - sets skb dst
977 skb->_skb_refdst = (unsigned long)dst; in skb_dst_set()
981 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
993 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; in skb_dst_set_noref()
997 * skb_dst_is_noref - Test if skb dst isn't refcounted
1002 return (skb->_skb_refdst & SKB_DST_NOREF) && skb_dst(skb); in skb_dst_is_noref()
1006 * skb_rtable - Returns the skb &rtable
1014 /* For mangling skb->pkt_type from user space side from applications
1024 * skb_napi_id - Returns the skb's NAPI id
1030 return skb->napi_id; in skb_napi_id()
1037 * skb_unref - decrement the skb's reference count
1046 if (likely(refcount_read(&skb->users) == 1)) in skb_unref()
1048 else if (likely(!refcount_dec_and_test(&skb->users))) in skb_unref()
1085 * alloc_skb - allocate a network buffer
1114 * skb_fclone_busy - check if fclone is busy
1129 return skb->fclone == SKB_FCLONE_ORIG && in skb_fclone_busy()
1130 refcount_read(&fclones->fclone_ref) > 1 && in skb_fclone_busy()
1131 fclones->skb2.sk == sk; in skb_fclone_busy()
1135 * alloc_skb_fclone - allocate a network buffer from fclone cache
1174 * skb_pad - zero pad the tail of an skb
1218 * layer-2 (L2), layer-3 (L3), or layer-4 (L4).
1247 skb->hash = 0; in skb_clear_hash()
1248 skb->sw_hash = 0; in skb_clear_hash()
1249 skb->l4_hash = 0; in skb_clear_hash()
1254 if (!skb->l4_hash) in skb_clear_hash_if_not_l4()
1261 skb->l4_hash = is_l4; in __skb_set_hash()
1262 skb->sw_hash = is_sw; in __skb_set_hash()
1263 skb->hash = hash; in __skb_set_hash()
1362 if (!skb->l4_hash && !skb->sw_hash) in skb_get_hash()
1365 return skb->hash; in skb_get_hash()
1370 if (!skb->l4_hash && !skb->sw_hash) { in skb_get_hash_flowi6()
1377 return skb->hash; in skb_get_hash_flowi6()
1385 return skb->hash; in skb_get_hash_raw()
1390 to->hash = from->hash; in skb_copy_hash()
1391 to->sw_hash = from->sw_hash; in skb_copy_hash()
1392 to->l4_hash = from->l4_hash; in skb_copy_hash()
1399 to->decrypted = from->decrypted; in skb_copy_decrypted()
1406 return skb->head + skb->end; in skb_end_pointer()
1411 return skb->end; in skb_end_offset()
1416 return skb->end; in skb_end_pointer()
1421 return skb->end - skb->head; in skb_end_offset()
1430 return &skb_shinfo(skb)->hwtstamps; in skb_hwtstamps()
1435 bool is_zcopy = skb && skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY; in skb_zcopy()
1448 skb_shinfo(skb)->destructor_arg = uarg; in skb_zcopy_set()
1449 skb_shinfo(skb)->tx_flags |= SKBTX_ZEROCOPY_FRAG; in skb_zcopy_set()
1455 skb_shinfo(skb)->destructor_arg = (void *)((uintptr_t) val | 0x1UL); in skb_zcopy_set_nouarg()
1456 skb_shinfo(skb)->tx_flags |= SKBTX_ZEROCOPY_FRAG; in skb_zcopy_set_nouarg()
1461 return (uintptr_t) skb_shinfo(skb)->destructor_arg & 0x1UL; in skb_zcopy_is_nouarg()
1466 return (void *)((uintptr_t) skb_shinfo(skb)->destructor_arg & ~0x1UL); in skb_zcopy_get_nouarg()
1477 } else if (uarg->callback == sock_zerocopy_callback) { in skb_zcopy_clear()
1478 uarg->zerocopy = uarg->zerocopy && zerocopy; in skb_zcopy_clear()
1481 uarg->callback(uarg, zerocopy); in skb_zcopy_clear()
1484 skb_shinfo(skb)->tx_flags &= ~SKBTX_ZEROCOPY_FRAG; in skb_zcopy_clear()
1495 skb_shinfo(skb)->tx_flags &= ~SKBTX_ZEROCOPY_FRAG; in skb_zcopy_abort()
1501 skb->next = NULL; in skb_mark_not_on_list()
1504 /* Iterate through singly-linked GSO fragments of an skb. */
1506 for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \
1507 (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
1511 __list_del_entry(&skb->list); in skb_list_del_init()
1516 * skb_queue_empty - check if a queue is empty
1523 return list->next == (const struct sk_buff *) list; in skb_queue_empty()
1527 * skb_queue_empty_lockless - check if a queue is empty
1535 return READ_ONCE(list->next) == (const struct sk_buff *) list; in skb_queue_empty_lockless()
1540 * skb_queue_is_last - check if skb is the last entry in the queue
1549 return skb->next == (const struct sk_buff *) list; in skb_queue_is_last()
1553 * skb_queue_is_first - check if skb is the first entry in the queue
1562 return skb->prev == (const struct sk_buff *) list; in skb_queue_is_first()
1566 * skb_queue_next - return the next packet in the queue
1580 return skb->next; in skb_queue_next()
1584 * skb_queue_prev - return the prev packet in the queue
1598 return skb->prev; in skb_queue_prev()
1602 * skb_get - reference buffer
1610 refcount_inc(&skb->users); in skb_get()
1619 * skb_cloned - is the buffer a clone
1628 return skb->cloned && in skb_cloned()
1629 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1; in skb_cloned()
1643 * skb_header_cloned - is the header a clone
1653 if (!skb->cloned) in skb_header_cloned()
1656 dataref = atomic_read(&skb_shinfo(skb)->dataref); in skb_header_cloned()
1657 dataref = (dataref & SKB_DATAREF_MASK) - (dataref >> SKB_DATAREF_SHIFT); in skb_header_cloned()
1672 * __skb_header_release - release reference to header
1677 skb->nohdr = 1; in __skb_header_release()
1678 atomic_set(&skb_shinfo(skb)->dataref, 1 + (1 << SKB_DATAREF_SHIFT)); in __skb_header_release()
1683 * skb_shared - is the buffer shared
1691 return refcount_read(&skb->users) != 1; in skb_shared()
1695 * skb_share_check - check if buffer is shared and if so clone it
1730 * skb_unshare - make a copy of a shared buffer
1760 * skb_peek - peek at the head of an &sk_buff_head
1774 struct sk_buff *skb = list_->next; in skb_peek()
1782 * __skb_peek - peek at the head of a non-empty &sk_buff_head
1789 return list_->next; in __skb_peek()
1793 * skb_peek_next - peek skb following the given one from a queue
1804 struct sk_buff *next = skb->next; in skb_peek_next()
1812 * skb_peek_tail - peek at the tail of an &sk_buff_head
1826 struct sk_buff *skb = READ_ONCE(list_->prev); in skb_peek_tail()
1835 * skb_queue_len - get queue length
1842 return list_->qlen; in skb_queue_len()
1846 * skb_queue_len_lockless - get queue length
1854 return READ_ONCE(list_->qlen); in skb_queue_len_lockless()
1858 * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
1864 * the spinlock. It can also be used for on-stack sk_buff_head
1869 list->prev = list->next = (struct sk_buff *)list; in __skb_queue_head_init()
1870 list->qlen = 0; in __skb_queue_head_init()
1875 * this is needed for now since a whole lot of users of the skb-queue
1883 spin_lock_init(&list->lock); in skb_queue_head_init()
1891 lockdep_set_class(&list->lock, class); in skb_queue_head_init_class()
1897 * The "__skb_xxxx()" functions are the non-atomic ones that
1907 WRITE_ONCE(newsk->next, next); in __skb_insert()
1908 WRITE_ONCE(newsk->prev, prev); in __skb_insert()
1909 WRITE_ONCE(next->prev, newsk); in __skb_insert()
1910 WRITE_ONCE(prev->next, newsk); in __skb_insert()
1911 list->qlen++; in __skb_insert()
1918 struct sk_buff *first = list->next; in __skb_queue_splice()
1919 struct sk_buff *last = list->prev; in __skb_queue_splice()
1921 WRITE_ONCE(first->prev, prev); in __skb_queue_splice()
1922 WRITE_ONCE(prev->next, first); in __skb_queue_splice()
1924 WRITE_ONCE(last->next, next); in __skb_queue_splice()
1925 WRITE_ONCE(next->prev, last); in __skb_queue_splice()
1929 * skb_queue_splice - join two skb lists, this is designed for stacks
1937 __skb_queue_splice(list, (struct sk_buff *) head, head->next); in skb_queue_splice()
1938 head->qlen += list->qlen; in skb_queue_splice()
1943 * skb_queue_splice_init - join two skb lists and reinitialise the emptied list
1953 __skb_queue_splice(list, (struct sk_buff *) head, head->next); in skb_queue_splice_init()
1954 head->qlen += list->qlen; in skb_queue_splice_init()
1960 * skb_queue_splice_tail - join two skb lists, each list being a queue
1968 __skb_queue_splice(list, head->prev, (struct sk_buff *) head); in skb_queue_splice_tail()
1969 head->qlen += list->qlen; in skb_queue_splice_tail()
1974 * skb_queue_splice_tail_init - join two skb lists and reinitialise the emptied list
1985 __skb_queue_splice(list, head->prev, (struct sk_buff *) head); in skb_queue_splice_tail_init()
1986 head->qlen += list->qlen; in skb_queue_splice_tail_init()
1992 * __skb_queue_after - queue a buffer at the list head
2006 __skb_insert(newsk, prev, prev->next, list); in __skb_queue_after()
2016 __skb_insert(newsk, next->prev, next, list); in __skb_queue_before()
2020 * __skb_queue_head - queue a buffer at the list head
2037 * __skb_queue_tail - queue a buffer at the list tail
2062 WRITE_ONCE(list->qlen, list->qlen - 1); in __skb_unlink()
2063 next = skb->next; in __skb_unlink()
2064 prev = skb->prev; in __skb_unlink()
2065 skb->next = skb->prev = NULL; in __skb_unlink()
2066 WRITE_ONCE(next->prev, prev); in __skb_unlink()
2067 WRITE_ONCE(prev->next, next); in __skb_unlink()
2071 * __skb_dequeue - remove from the head of the queue
2088 * __skb_dequeue_tail - remove from the tail of the queue
2107 return skb->data_len; in skb_is_nonlinear()
2112 return skb->len - skb->data_len; in skb_headlen()
2119 for (i = skb_shinfo(skb)->nr_frags - 1; (int)i >= 0; i--) in __skb_pagelen()
2120 len += skb_frag_size(&skb_shinfo(skb)->frags[i]); in __skb_pagelen()
2130 * __skb_fill_page_desc - initialise a paged fragment in an skb
2145 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in __skb_fill_page_desc()
2152 frag->bv_page = page; in __skb_fill_page_desc()
2153 frag->bv_offset = off; in __skb_fill_page_desc()
2158 skb->pfmemalloc = true; in __skb_fill_page_desc()
2162 * skb_fill_page_desc - initialise a paged fragment in an skb
2169 * As per __skb_fill_page_desc() -- initialises the @i'th fragment of
2179 skb_shinfo(skb)->nr_frags = i + 1; in skb_fill_page_desc()
2193 return skb->head + skb->tail; in skb_tail_pointer()
2198 skb->tail = skb->data - skb->head; in skb_reset_tail_pointer()
2204 skb->tail += offset; in skb_set_tail_pointer()
2210 return skb->tail; in skb_tail_pointer()
2215 skb->tail = skb->data; in skb_reset_tail_pointer()
2220 skb->tail = skb->data + offset; in skb_set_tail_pointer()
2234 skb->tail += len; in __skb_put()
2235 skb->len += len; in __skb_put()
2288 skb->data -= len; in __skb_push()
2289 skb->len += len; in __skb_push()
2290 return skb->data; in __skb_push()
2296 skb->len -= len; in __skb_pull()
2297 BUG_ON(skb->len < skb->data_len); in __skb_pull()
2298 return skb->data += len; in __skb_pull()
2303 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); in skb_pull_inline()
2311 !__pskb_pull_tail(skb, len - skb_headlen(skb))) in __pskb_pull()
2313 skb->len -= len; in __pskb_pull()
2314 return skb->data += len; in __pskb_pull()
2319 return unlikely(len > skb->len) ? NULL : __pskb_pull(skb, len); in pskb_pull()
2326 if (unlikely(len > skb->len)) in pskb_may_pull()
2328 return __pskb_pull_tail(skb, len - skb_headlen(skb)) != NULL; in pskb_may_pull()
2334 * skb_headroom - bytes at buffer head
2341 return skb->data - skb->head; in skb_headroom()
2345 * skb_tailroom - bytes at buffer end
2352 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail; in skb_tailroom()
2356 * skb_availroom - bytes at buffer end
2367 return skb->end - skb->tail - skb->reserved_tailroom; in skb_availroom()
2371 * skb_reserve - adjust headroom
2380 skb->data += len; in skb_reserve()
2381 skb->tail += len; in skb_reserve()
2385 * skb_tailroom_reserve - adjust reserved_tailroom
2400 if (mtu < skb_tailroom(skb) - needed_tailroom) in skb_tailroom_reserve()
2402 skb->reserved_tailroom = skb_tailroom(skb) - mtu; in skb_tailroom_reserve()
2405 skb->reserved_tailroom = needed_tailroom; in skb_tailroom_reserve()
2414 skb->inner_protocol = protocol; in skb_set_inner_protocol()
2415 skb->inner_protocol_type = ENCAP_TYPE_ETHER; in skb_set_inner_protocol()
2421 skb->inner_ipproto = ipproto; in skb_set_inner_ipproto()
2422 skb->inner_protocol_type = ENCAP_TYPE_IPPROTO; in skb_set_inner_ipproto()
2427 skb->inner_mac_header = skb->mac_header; in skb_reset_inner_headers()
2428 skb->inner_network_header = skb->network_header; in skb_reset_inner_headers()
2429 skb->inner_transport_header = skb->transport_header; in skb_reset_inner_headers()
2434 skb->mac_len = skb->network_header - skb->mac_header; in skb_reset_mac_len()
2440 return skb->head + skb->inner_transport_header; in skb_inner_transport_header()
2445 return skb_inner_transport_header(skb) - skb->data; in skb_inner_transport_offset()
2450 skb->inner_transport_header = skb->data - skb->head; in skb_reset_inner_transport_header()
2457 skb->inner_transport_header += offset; in skb_set_inner_transport_header()
2462 return skb->head + skb->inner_network_header; in skb_inner_network_header()
2467 skb->inner_network_header = skb->data - skb->head; in skb_reset_inner_network_header()
2474 skb->inner_network_header += offset; in skb_set_inner_network_header()
2479 return skb->head + skb->inner_mac_header; in skb_inner_mac_header()
2484 skb->inner_mac_header = skb->data - skb->head; in skb_reset_inner_mac_header()
2491 skb->inner_mac_header += offset; in skb_set_inner_mac_header()
2495 return skb->transport_header != (typeof(skb->transport_header))~0U; in skb_transport_header_was_set()
2500 return skb->head + skb->transport_header; in skb_transport_header()
2505 skb->transport_header = skb->data - skb->head; in skb_reset_transport_header()
2512 skb->transport_header += offset; in skb_set_transport_header()
2517 return skb->head + skb->network_header; in skb_network_header()
2522 skb->network_header = skb->data - skb->head; in skb_reset_network_header()
2528 skb->network_header += offset; in skb_set_network_header()
2533 return skb->head + skb->mac_header; in skb_mac_header()
2538 return skb_mac_header(skb) - skb->data; in skb_mac_offset()
2543 return skb->network_header - skb->mac_header; in skb_mac_header_len()
2548 return skb->mac_header != (typeof(skb->mac_header))~0U; in skb_mac_header_was_set()
2553 skb->mac_header = (typeof(skb->mac_header))~0U; in skb_unset_mac_header()
2558 skb->mac_header = skb->data - skb->head; in skb_reset_mac_header()
2564 skb->mac_header += offset; in skb_set_mac_header()
2569 skb->mac_header = skb->network_header; in skb_pop_mac_header()
2589 skb_set_mac_header(skb, -skb->mac_len); in skb_mac_header_rebuild()
2590 memmove(skb_mac_header(skb), old_mac, skb->mac_len); in skb_mac_header_rebuild()
2596 return skb->csum_start - skb_headroom(skb); in skb_checksum_start_offset()
2601 return skb->head + skb->csum_start; in skb_checksum_start()
2606 return skb_transport_header(skb) - skb->data; in skb_transport_offset()
2611 return skb->transport_header - skb->network_header; in skb_network_header_len()
2616 return skb->inner_transport_header - skb->inner_network_header; in skb_inner_network_header_len()
2621 return skb_network_header(skb) - skb->data; in skb_network_offset()
2626 return skb_inner_network_header(skb) - skb->data; in skb_inner_network_offset()
2688 skb->len = len; in __skb_set_length()
2701 if (skb->data_len) in __pskb_trim()
2709 return (len < skb->len) ? __pskb_trim(skb, len) : 0; in pskb_trim()
2713 * pskb_trim_unique - remove end from a paged unique (not cloned) buffer
2718 * the skb is not cloned so we should never get an error due to out-
2719 * of-memory.
2729 unsigned int diff = len - skb->len; in __skb_grow()
2732 int ret = pskb_expand_head(skb, 0, diff - skb_tailroom(skb), in __skb_grow()
2742 * skb_orphan - orphan a buffer
2751 if (skb->destructor) { in skb_orphan()
2752 skb->destructor(skb); in skb_orphan()
2753 skb->destructor = NULL; in skb_orphan()
2754 skb->sk = NULL; in skb_orphan()
2756 BUG_ON(skb->sk); in skb_orphan()
2761 * skb_orphan_frags - orphan the frags contained in a buffer
2774 skb_uarg(skb)->callback == sock_zerocopy_callback) in skb_orphan_frags()
2779 /* Frags must be orphaned, even if refcounted, if skb might loop to rx path */
2788 * __skb_queue_purge - empty a list
2811 * netdev_alloc_skb - allocate an skbuff for rx on a specific device
2878 * __dev_alloc_pages - allocate page for network Rx
2879 * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
2890 * 1. This is for device Rx, therefor a cold page is preferred. in __dev_alloc_pages()
2908 * __dev_alloc_page - allocate a page for network Rx
2909 * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
2926 * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated after RX page
2934 skb->pfmemalloc = true; in skb_propagate_pfmemalloc()
2938 * skb_frag_off() - Returns the offset of a skb fragment
2943 return frag->bv_offset; in skb_frag_off()
2947 * skb_frag_off_add() - Increments the offset of a skb fragment by @delta
2953 frag->bv_offset += delta; in skb_frag_off_add()
2957 * skb_frag_off_set() - Sets the offset of a skb fragment
2963 frag->bv_offset = offset; in skb_frag_off_set()
2967 * skb_frag_off_copy() - Sets the offset of a skb fragment from another fragment
2974 fragto->bv_offset = fragfrom->bv_offset; in skb_frag_off_copy()
2978 * skb_frag_page - retrieve the page referred to by a paged fragment
2985 return frag->bv_page; in skb_frag_page()
2989 * __skb_frag_ref - take an addition reference on a paged fragment.
3000 * skb_frag_ref - take an addition reference on a paged fragment of an skb.
3008 __skb_frag_ref(&skb_shinfo(skb)->frags[f]); in skb_frag_ref()
3012 * __skb_frag_unref - release a reference on a paged fragment.
3023 * skb_frag_unref - release a reference on a paged fragment of an skb.
3031 __skb_frag_unref(&skb_shinfo(skb)->frags[f]); in skb_frag_unref()
3035 * skb_frag_address - gets the address of the data contained in a paged fragment
3047 * skb_frag_address_safe - gets the address of the data contained in a paged fragment
3063 * skb_frag_page_copy() - sets the page in a fragment from another fragment
3070 fragto->bv_page = fragfrom->bv_page; in skb_frag_page_copy()
3074 * __skb_frag_set_page - sets the page contained in a paged fragment
3082 frag->bv_page = page; in __skb_frag_set_page()
3086 * skb_frag_set_page - sets the page contained in a paged fragment of an skb
3096 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page); in skb_frag_set_page()
3102 * skb_frag_dma_map - maps a paged fragment via the DMA API
3136 * skb_clone_writable - is the header of a clone writable
3146 skb_headroom(skb) + len <= skb->hdr_len; in skb_clone_writable()
3162 delta = headroom - skb_headroom(skb); in __skb_cow()
3171 * skb_cow - copy header of skb when it is required
3179 * The result is skb with writable area skb->head...skb->tail
3188 * skb_cow_head - skb_cow but only making the head writable
3203 * skb_padto - pad an skbuff up to a minimal size
3214 unsigned int size = skb->len; in skb_padto()
3217 return skb_pad(skb, len - size); in skb_padto()
3221 * __skb_put_padto - increase size and pad an skbuff up to a minimal size
3235 unsigned int size = skb->len; in __skb_put_padto()
3238 len -= size; in __skb_put_padto()
3240 return -ENOMEM; in __skb_put_padto()
3247 * skb_put_padto - increase size and pad an skbuff up to a minimal size
3264 const int off = skb->len; in skb_add_data()
3266 if (skb->ip_summed == CHECKSUM_NONE) { in skb_add_data()
3270 skb->csum = csum_block_add(skb->csum, csum, off); in skb_add_data()
3277 return -EFAULT; in skb_add_data()
3286 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; in skb_can_coalesce()
3296 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM; in __skb_linearize()
3300 * skb_linearize - convert paged skb to linear one
3303 * If there is no free memory -ENOMEM is returned, otherwise zero
3312 * skb_has_shared_frag - can any frag be overwritten
3321 skb_shinfo(skb)->tx_flags & SKBTX_SHARED_FRAG; in skb_has_shared_frag()
3325 * skb_linearize_cow - make sure skb is linear and writable
3328 * If there is no free memory -ENOMEM is returned, otherwise zero
3341 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpull_rcsum()
3342 skb->csum = csum_block_sub(skb->csum, in __skb_postpull_rcsum()
3344 else if (skb->ip_summed == CHECKSUM_PARTIAL && in __skb_postpull_rcsum()
3346 skb->ip_summed = CHECKSUM_NONE; in __skb_postpull_rcsum()
3350 * skb_postpull_rcsum - update checksum for received skb after pull
3369 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_postpush_rcsum()
3370 skb->csum = csum_block_add(skb->csum, in __skb_postpush_rcsum()
3375 * skb_postpush_rcsum - update checksum for received skb after push
3392 * skb_push_rcsum - push skb and update receive checksum
3405 skb_postpush_rcsum(skb, skb->data, len); in skb_push_rcsum()
3406 return skb->data; in skb_push_rcsum()
3411 * pskb_trim_rcsum - trim received skb and update checksum
3422 if (likely(len >= skb->len)) in pskb_trim_rcsum()
3429 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_trim_rcsum()
3430 skb->ip_summed = CHECKSUM_NONE; in __skb_trim_rcsum()
3437 if (skb->ip_summed == CHECKSUM_COMPLETE) in __skb_grow_rcsum()
3438 skb->ip_summed = CHECKSUM_NONE; in __skb_grow_rcsum()
3445 #define skb_rb_next(skb) rb_to_skb(rb_next(&(skb)->rbnode))
3446 #define skb_rb_prev(skb) rb_to_skb(rb_prev(&(skb)->rbnode))
3449 for (skb = (queue)->next; \
3451 skb = skb->next)
3454 for (skb = (queue)->next, tmp = skb->next; \
3456 skb = tmp, tmp = skb->next)
3460 skb = skb->next)
3475 for (tmp = skb->next; \
3477 skb = tmp, tmp = skb->next)
3480 for (skb = (queue)->prev; \
3482 skb = skb->prev)
3485 for (skb = (queue)->prev, tmp = skb->prev; \
3487 skb = tmp, tmp = skb->prev)
3490 for (tmp = skb->prev; \
3492 skb = tmp, tmp = skb->prev)
3496 return skb_shinfo(skb)->frag_list != NULL; in skb_has_frag_list()
3501 skb_shinfo(skb)->frag_list = NULL; in skb_frag_list_init()
3505 for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
3532 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size); in skb_copy_datagram_msg()
3590 return copy_from_iter_full(data, len, &msg->msg_iter) ? 0 : -EFAULT; in memcpy_from_msg()
3595 return copy_to_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT; in memcpy_to_msg()
3614 if (hlen - offset >= len) in __skb_header_pointer()
3627 return __skb_header_pointer(skb, offset, len, skb->data, in skb_header_pointer()
3632 * skb_needs_linearize - check if we need to linearize a given skb
3646 (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG))); in skb_needs_linearize()
3653 memcpy(to, skb->data, len); in skb_copy_from_linear_data()
3660 memcpy(to, skb->data + offset, len); in skb_copy_from_linear_data_offset()
3667 memcpy(skb->data, from, len); in skb_copy_to_linear_data()
3675 memcpy(skb->data + offset, from, len); in skb_copy_to_linear_data_offset()
3682 return skb->tstamp; in skb_get_ktime()
3686 * skb_get_timestamp - get timestamp from a skb
3697 *stamp = ns_to_kernel_old_timeval(skb->tstamp); in skb_get_timestamp()
3703 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestamp()
3705 stamp->tv_sec = ts.tv_sec; in skb_get_new_timestamp()
3706 stamp->tv_usec = ts.tv_nsec / 1000; in skb_get_new_timestamp()
3712 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_timestampns()
3714 stamp->tv_sec = ts.tv_sec; in skb_get_timestampns()
3715 stamp->tv_nsec = ts.tv_nsec; in skb_get_timestampns()
3721 struct timespec64 ts = ktime_to_timespec64(skb->tstamp); in skb_get_new_timestampns()
3723 stamp->tv_sec = ts.tv_sec; in skb_get_new_timestampns()
3724 stamp->tv_nsec = ts.tv_nsec; in skb_get_new_timestampns()
3729 skb->tstamp = ktime_get_real(); in __net_timestamp()
3744 return skb_shinfo(skb)->meta_len; in skb_metadata_len()
3763 #define __it(x, op) (x -= sizeof(u##op)) in __skb_metadata_differs()
3784 return memcmp(a - meta_len, b - meta_len, meta_len); in __skb_metadata_differs()
3803 skb_shinfo(skb)->meta_len = meta_len; in skb_metadata_set()
3832 * skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps
3851 * skb_tstamp_tx - queue clone of skb with send time stamps
3865 * skb_tx_timestamp() - Driver hook for transmit timestamping
3879 if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP) in skb_tx_timestamp()
3884 * skb_complete_wifi_ack - deliver skb with wifi status
3897 return ((skb->ip_summed == CHECKSUM_UNNECESSARY) || in skb_csum_unnecessary()
3898 skb->csum_valid || in skb_csum_unnecessary()
3899 (skb->ip_summed == CHECKSUM_PARTIAL && in skb_csum_unnecessary()
3904 * skb_checksum_complete - Calculate checksum of an entire packet
3908 * the value of skb->csum. The latter can be used to supply the
3916 * if skb->ip_summed is CHECKSUM_UNNECESSARY which indicates that the
3927 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_decr_checksum_unnecessary()
3928 if (skb->csum_level == 0) in __skb_decr_checksum_unnecessary()
3929 skb->ip_summed = CHECKSUM_NONE; in __skb_decr_checksum_unnecessary()
3931 skb->csum_level--; in __skb_decr_checksum_unnecessary()
3937 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_incr_checksum_unnecessary()
3938 if (skb->csum_level < SKB_MAX_CSUM_LEVEL) in __skb_incr_checksum_unnecessary()
3939 skb->csum_level++; in __skb_incr_checksum_unnecessary()
3940 } else if (skb->ip_summed == CHECKSUM_NONE) { in __skb_incr_checksum_unnecessary()
3941 skb->ip_summed = CHECKSUM_UNNECESSARY; in __skb_incr_checksum_unnecessary()
3942 skb->csum_level = 0; in __skb_incr_checksum_unnecessary()
3948 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in __skb_reset_checksum_unnecessary()
3949 skb->ip_summed = CHECKSUM_NONE; in __skb_reset_checksum_unnecessary()
3950 skb->csum_level = 0; in __skb_reset_checksum_unnecessary()
3964 skb->csum_valid = 1; in __skb_checksum_validate_needed()
3977 /* Unset checksum-complete
3980 * (uncompressed for instance) and checksum-complete value is
3985 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_checksum_complete_unset()
3986 skb->ip_summed = CHECKSUM_NONE; in skb_checksum_complete_unset()
3994 * checksum is stored in skb->csum for use in __skb_checksum_complete
3995 * non-zero: value of invalid checksum
4002 if (skb->ip_summed == CHECKSUM_COMPLETE) { in __skb_checksum_validate_complete()
4003 if (!csum_fold(csum_add(psum, skb->csum))) { in __skb_checksum_validate_complete()
4004 skb->csum_valid = 1; in __skb_checksum_validate_complete()
4009 skb->csum = psum; in __skb_checksum_validate_complete()
4011 if (complete || skb->len <= CHECKSUM_BREAK) { in __skb_checksum_validate_complete()
4015 skb->csum_valid = !csum; in __skb_checksum_validate_complete()
4035 * non-zero: value of invalid checksum
4041 skb->csum_valid = 0; \
4066 return (skb->ip_summed == CHECKSUM_NONE && skb->csum_valid); in __skb_checksum_convert_check()
4071 skb->csum = ~pseudo; in __skb_checksum_convert()
4072 skb->ip_summed = CHECKSUM_COMPLETE; in __skb_checksum_convert()
4084 skb->ip_summed = CHECKSUM_PARTIAL; in skb_remcsum_adjust_partial()
4085 skb->csum_start = ((unsigned char *)ptr + start) - skb->head; in skb_remcsum_adjust_partial()
4086 skb->csum_offset = offset - start; in skb_remcsum_adjust_partial()
4090 * When called, ptr indicates the starting point for skb->csum when
4092 * here, skb_postpull_rcsum is done so skb->csum start is ptr.
4104 if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) { in skb_remcsum_process()
4106 skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data); in skb_remcsum_process()
4109 delta = remcsum_adjust(ptr, skb->csum, start, offset); in skb_remcsum_process()
4111 /* Adjust skb->csum since we changed the packet */ in skb_remcsum_process()
4112 skb->csum = csum_add(skb->csum, delta); in skb_remcsum_process()
4118 return (void *)(skb->_nfct & NFCT_PTRMASK); in skb_nfct()
4127 return skb->_nfct; in skb_get_nfct()
4136 skb->_nfct = nfct; in skb_set_nfct()
4158 * struct skb_ext - sk_buff extensions
4183 if (skb->active_extensions) in skb_ext_put()
4184 __skb_ext_put(skb->extensions); in skb_ext_put()
4190 dst->active_extensions = src->active_extensions; in __skb_ext_copy()
4192 if (src->active_extensions) { in __skb_ext_copy()
4193 struct skb_ext *ext = src->extensions; in __skb_ext_copy()
4195 refcount_inc(&ext->refcnt); in __skb_ext_copy()
4196 dst->extensions = ext; in __skb_ext_copy()
4208 return !!ext->offset[i]; in __skb_ext_exist()
4213 return skb->active_extensions & (1 << id); in skb_ext_exist()
4225 struct skb_ext *ext = skb->extensions; in skb_ext_find()
4227 return (void *)ext + (ext->offset[id] << 3); in skb_ext_find()
4235 if (unlikely(skb->active_extensions)) { in skb_ext_reset()
4236 __skb_ext_put(skb->extensions); in skb_ext_reset()
4237 skb->active_extensions = 0; in skb_ext_reset()
4243 return unlikely(skb->active_extensions); in skb_has_extensions()
4258 skb->_nfct = 0; in nf_reset_ct()
4265 skb->nf_trace = 0; in nf_reset_trace()
4272 skb->ipvs_property = 0; in ipvs_reset()
4281 dst->_nfct = src->_nfct; in __nf_copy()
4286 dst->nf_trace = src->nf_trace; in __nf_copy()
4301 to->secmark = from->secmark; in skb_copy_secmark()
4306 skb->secmark = 0; in skb_init_secmark()
4327 return !skb->destructor && in skb_irq_freeable()
4330 !skb->_skb_refdst && in skb_irq_freeable()
4336 skb->queue_mapping = queue_mapping; in skb_set_queue_mapping()
4341 return skb->queue_mapping; in skb_get_queue_mapping()
4346 to->queue_mapping = from->queue_mapping; in skb_copy_queue_mapping()
4351 skb->queue_mapping = rx_queue + 1; in skb_record_rx_queue()
4356 return skb->queue_mapping - 1; in skb_get_rx_queue()
4361 return skb->queue_mapping != 0; in skb_rx_queue_recorded()
4366 skb->dst_pending_confirm = val; in skb_set_dst_pending_confirm()
4371 return skb->dst_pending_confirm != 0; in skb_get_dst_pending_confirm()
4383 /* Keeps track of mac header offset relative to skb->head.
4385 * For non-tunnel skb it points to skb_mac_header() and for
4399 #define SKB_GSO_CB(skb) ((struct skb_gso_cb *)((skb)->cb + SKB_GSO_CB_OFFSET))
4403 return (skb_mac_header(inner_skb) - inner_skb->head) - in skb_tnl_header_len()
4404 SKB_GSO_CB(inner_skb)->mac_offset; in skb_tnl_header_len()
4418 SKB_GSO_CB(skb)->mac_offset += (new_headroom - headroom); in gso_pskb_expand_head()
4425 if (skb->remcsum_offload) in gso_reset_checksum()
4428 SKB_GSO_CB(skb)->csum = res; in gso_reset_checksum()
4429 SKB_GSO_CB(skb)->csum_start = skb_checksum_start(skb) - skb->head; in gso_reset_checksum()
4433 * from the start of transport header to SKB_GSO_CB(skb)->csum_start, and
4434 * then add in skb->csum (checksum from csum_start to end of packet).
4435 * skb->csum and csum_start are then updated to reflect the checksum of the
4436 * resultant packet starting from the transport header-- the resultant checksum
4443 int plen = (skb->head + SKB_GSO_CB(skb)->csum_start) - csum_start; in gso_make_checksum()
4444 __wsum partial = SKB_GSO_CB(skb)->csum; in gso_make_checksum()
4446 SKB_GSO_CB(skb)->csum = res; in gso_make_checksum()
4447 SKB_GSO_CB(skb)->csum_start = csum_start - skb->head; in gso_make_checksum()
4454 return skb_shinfo(skb)->gso_size; in skb_is_gso()
4460 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; in skb_is_gso_v6()
4466 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; in skb_is_gso_sctp()
4472 return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6); in skb_is_gso_tcp()
4477 skb_shinfo(skb)->gso_size = 0; in skb_gso_reset()
4478 skb_shinfo(skb)->gso_segs = 0; in skb_gso_reset()
4479 skb_shinfo(skb)->gso_type = 0; in skb_gso_reset()
4485 if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) in skb_increase_gso_size()
4487 shinfo->gso_size += increment; in skb_increase_gso_size()
4493 if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) in skb_decrease_gso_size()
4495 shinfo->gso_size -= decrement; in skb_decrease_gso_size()
4506 if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 && in skb_warn_if_lro()
4507 unlikely(shinfo->gso_type == 0)) { in skb_warn_if_lro()
4517 if (skb->ip_summed == CHECKSUM_COMPLETE) in skb_forward_csum()
4518 skb->ip_summed = CHECKSUM_NONE; in skb_forward_csum()
4522 * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
4532 BUG_ON(skb->ip_summed != CHECKSUM_NONE); in skb_checksum_none_assert()
4544 * skb_head_is_locked - Determine if the skb->head is locked down
4554 return !skb->head_frag || skb_cloned(skb); in skb_head_is_locked()
4560 * See Documentation/networking/checksum-offloads.rst for
4563 * pseudo-header) before calling.
4574 skb->csum_offset)); in lco_csum()
4579 return csum_partial(l4_hdr, csum_start - l4_hdr, partial); in lco_csum()
4585 return skb->redirected; in skb_is_redirected()
4594 skb->redirected = 1; in skb_set_redirected()
4595 skb->from_ingress = from_ingress; in skb_set_redirected()
4596 if (skb->from_ingress) in skb_set_redirected()
4597 skb->tstamp = 0; in skb_set_redirected()
4604 skb->redirected = 0; in skb_reset_redirect()