Merge tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux/fpc-iii.git] / net / rxrpc / skbuff.c
blob0348d2bf6f7d8e85ea075c992a5b5368ca0362a0
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* ar-skbuff.c: socket buffer destruction handling
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/module.h>
11 #include <linux/net.h>
12 #include <linux/skbuff.h>
13 #include <net/sock.h>
14 #include <net/af_rxrpc.h>
15 #include "ar-internal.h"
17 #define is_tx_skb(skb) (rxrpc_skb(skb)->rx_flags & RXRPC_SKB_TX_BUFFER)
18 #define select_skb_count(skb) (is_tx_skb(skb) ? &rxrpc_n_tx_skbs : &rxrpc_n_rx_skbs)
21 * Note the allocation or reception of a socket buffer.
23 void rxrpc_new_skb(struct sk_buff *skb, enum rxrpc_skb_trace op)
25 const void *here = __builtin_return_address(0);
26 int n = atomic_inc_return(select_skb_count(skb));
27 trace_rxrpc_skb(skb, op, refcount_read(&skb->users), n,
28 rxrpc_skb(skb)->rx_flags, here);
32 * Note the re-emergence of a socket buffer from a queue or buffer.
34 void rxrpc_see_skb(struct sk_buff *skb, enum rxrpc_skb_trace op)
36 const void *here = __builtin_return_address(0);
37 if (skb) {
38 int n = atomic_read(select_skb_count(skb));
39 trace_rxrpc_skb(skb, op, refcount_read(&skb->users), n,
40 rxrpc_skb(skb)->rx_flags, here);
45 * Note the addition of a ref on a socket buffer.
47 void rxrpc_get_skb(struct sk_buff *skb, enum rxrpc_skb_trace op)
49 const void *here = __builtin_return_address(0);
50 int n = atomic_inc_return(select_skb_count(skb));
51 trace_rxrpc_skb(skb, op, refcount_read(&skb->users), n,
52 rxrpc_skb(skb)->rx_flags, here);
53 skb_get(skb);
57 * Note the dropping of a ref on a socket buffer by the core.
59 void rxrpc_eaten_skb(struct sk_buff *skb, enum rxrpc_skb_trace op)
61 const void *here = __builtin_return_address(0);
62 int n = atomic_inc_return(&rxrpc_n_rx_skbs);
63 trace_rxrpc_skb(skb, op, 0, n, 0, here);
67 * Note the destruction of a socket buffer.
69 void rxrpc_free_skb(struct sk_buff *skb, enum rxrpc_skb_trace op)
71 const void *here = __builtin_return_address(0);
72 if (skb) {
73 int n;
74 CHECK_SLAB_OKAY(&skb->users);
75 n = atomic_dec_return(select_skb_count(skb));
76 trace_rxrpc_skb(skb, op, refcount_read(&skb->users), n,
77 rxrpc_skb(skb)->rx_flags, here);
78 kfree_skb(skb);
83 * Clear a queue of socket buffers.
85 void rxrpc_purge_queue(struct sk_buff_head *list)
87 const void *here = __builtin_return_address(0);
88 struct sk_buff *skb;
89 while ((skb = skb_dequeue((list))) != NULL) {
90 int n = atomic_dec_return(select_skb_count(skb));
91 trace_rxrpc_skb(skb, rxrpc_skb_purged,
92 refcount_read(&skb->users), n,
93 rxrpc_skb(skb)->rx_flags, here);
94 kfree_skb(skb);