Commit 40bbae58 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

net: remove enum skb_free_reason

enum skb_drop_reason is more generic, we can adopt it instead.

Provide dev_kfree_skb_irq_reason() and dev_kfree_skb_any_reason().

This means drivers can use more precise drop reasons if they want to.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Reviewed-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
Link: https://lore.kernel.org/r/20230306204313.10492-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0194b645
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <net/net_trackers.h> #include <net/net_trackers.h>
#include <net/net_debug.h> #include <net/net_debug.h>
#include <net/dropreason.h>
struct netpoll_info; struct netpoll_info;
struct device; struct device;
...@@ -3804,13 +3805,8 @@ static inline unsigned int get_netdev_rx_queue_index( ...@@ -3804,13 +3805,8 @@ static inline unsigned int get_netdev_rx_queue_index(
int netif_get_num_default_rss_queues(void); int netif_get_num_default_rss_queues(void);
enum skb_free_reason { void dev_kfree_skb_irq_reason(struct sk_buff *skb, enum skb_drop_reason reason);
SKB_REASON_CONSUMED, void dev_kfree_skb_any_reason(struct sk_buff *skb, enum skb_drop_reason reason);
SKB_REASON_DROPPED,
};
void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason);
void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason);
/* /*
* It is not allowed to call kfree_skb() or consume_skb() from hardware * It is not allowed to call kfree_skb() or consume_skb() from hardware
...@@ -3833,22 +3829,22 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason); ...@@ -3833,22 +3829,22 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason);
*/ */
static inline void dev_kfree_skb_irq(struct sk_buff *skb) static inline void dev_kfree_skb_irq(struct sk_buff *skb)
{ {
__dev_kfree_skb_irq(skb, SKB_REASON_DROPPED); dev_kfree_skb_irq_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
} }
static inline void dev_consume_skb_irq(struct sk_buff *skb) static inline void dev_consume_skb_irq(struct sk_buff *skb)
{ {
__dev_kfree_skb_irq(skb, SKB_REASON_CONSUMED); dev_kfree_skb_irq_reason(skb, SKB_CONSUMED);
} }
static inline void dev_kfree_skb_any(struct sk_buff *skb) static inline void dev_kfree_skb_any(struct sk_buff *skb)
{ {
__dev_kfree_skb_any(skb, SKB_REASON_DROPPED); dev_kfree_skb_any_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
} }
static inline void dev_consume_skb_any(struct sk_buff *skb) static inline void dev_consume_skb_any(struct sk_buff *skb)
{ {
__dev_kfree_skb_any(skb, SKB_REASON_CONSUMED); dev_kfree_skb_any_reason(skb, SKB_CONSUMED);
} }
u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp, u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,
......
...@@ -3075,7 +3075,7 @@ void __netif_schedule(struct Qdisc *q) ...@@ -3075,7 +3075,7 @@ void __netif_schedule(struct Qdisc *q)
EXPORT_SYMBOL(__netif_schedule); EXPORT_SYMBOL(__netif_schedule);
struct dev_kfree_skb_cb { struct dev_kfree_skb_cb {
enum skb_free_reason reason; enum skb_drop_reason reason;
}; };
static struct dev_kfree_skb_cb *get_kfree_skb_cb(const struct sk_buff *skb) static struct dev_kfree_skb_cb *get_kfree_skb_cb(const struct sk_buff *skb)
...@@ -3108,7 +3108,7 @@ void netif_tx_wake_queue(struct netdev_queue *dev_queue) ...@@ -3108,7 +3108,7 @@ void netif_tx_wake_queue(struct netdev_queue *dev_queue)
} }
EXPORT_SYMBOL(netif_tx_wake_queue); EXPORT_SYMBOL(netif_tx_wake_queue);
void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason) void dev_kfree_skb_irq_reason(struct sk_buff *skb, enum skb_drop_reason reason)
{ {
unsigned long flags; unsigned long flags;
...@@ -3128,18 +3128,16 @@ void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason) ...@@ -3128,18 +3128,16 @@ void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason)
raise_softirq_irqoff(NET_TX_SOFTIRQ); raise_softirq_irqoff(NET_TX_SOFTIRQ);
local_irq_restore(flags); local_irq_restore(flags);
} }
EXPORT_SYMBOL(__dev_kfree_skb_irq); EXPORT_SYMBOL(dev_kfree_skb_irq_reason);
void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason) void dev_kfree_skb_any_reason(struct sk_buff *skb, enum skb_drop_reason reason)
{ {
if (in_hardirq() || irqs_disabled()) if (in_hardirq() || irqs_disabled())
__dev_kfree_skb_irq(skb, reason); dev_kfree_skb_irq_reason(skb, reason);
else if (unlikely(reason == SKB_REASON_DROPPED))
kfree_skb(skb);
else else
consume_skb(skb); kfree_skb_reason(skb, reason);
} }
EXPORT_SYMBOL(__dev_kfree_skb_any); EXPORT_SYMBOL(dev_kfree_skb_any_reason);
/** /**
...@@ -5020,11 +5018,11 @@ static __latent_entropy void net_tx_action(struct softirq_action *h) ...@@ -5020,11 +5018,11 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)
clist = clist->next; clist = clist->next;
WARN_ON(refcount_read(&skb->users)); WARN_ON(refcount_read(&skb->users));
if (likely(get_kfree_skb_cb(skb)->reason == SKB_REASON_CONSUMED)) if (likely(get_kfree_skb_cb(skb)->reason == SKB_CONSUMED))
trace_consume_skb(skb, net_tx_action); trace_consume_skb(skb, net_tx_action);
else else
trace_kfree_skb(skb, net_tx_action, trace_kfree_skb(skb, net_tx_action,
SKB_DROP_REASON_NOT_SPECIFIED); get_kfree_skb_cb(skb)->reason);
if (skb->fclone != SKB_FCLONE_UNAVAILABLE) if (skb->fclone != SKB_FCLONE_UNAVAILABLE)
__kfree_skb(skb); __kfree_skb(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment