include/net/act_api.h

Source file repositories/reference/linux-study-clean/include/net/act_api.h

File Facts

System
Linux kernel
Corpus path
include/net/act_api.h
Extension
.h
Size
9572 bytes
Lines
302
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tcf_idrinfo {
	struct mutex	lock;
	struct idr	action_idr;
	struct net	*net;
};

struct tc_action_ops;

struct tc_action {
	const struct tc_action_ops	*ops;
	__u32				type; /* for backward compat(TCA_OLD_COMPAT) */
	struct tcf_idrinfo		*idrinfo;

	u32				tcfa_index;
	refcount_t			tcfa_refcnt;
	atomic_t			tcfa_bindcnt;
	int				tcfa_action;
	struct tcf_t			tcfa_tm;
	struct gnet_stats_basic_sync	tcfa_bstats;
	struct gnet_stats_basic_sync	tcfa_bstats_hw;

	atomic_t			tcfa_drops;
	atomic_t			tcfa_overlimits;

	struct net_rate_estimator __rcu *tcfa_rate_est;
	spinlock_t			tcfa_lock;
	struct gnet_stats_basic_sync __percpu *cpu_bstats;
	struct gnet_stats_basic_sync __percpu *cpu_bstats_hw;
	struct gnet_stats_queue __percpu *cpu_qstats;
	struct tc_cookie	__rcu *user_cookie;
	struct tcf_chain	__rcu *goto_chain;
	u32			tcfa_flags;
	struct rcu_head         tcfa_rcu;
	u8			hw_stats;
	u8			used_hw_stats;
	bool			used_hw_stats_valid;
	u32			in_hw_count;
};
#define tcf_index	common.tcfa_index
#define tcf_refcnt	common.tcfa_refcnt
#define tcf_bindcnt	common.tcfa_bindcnt
#define tcf_action	common.tcfa_action
#define tcf_tm		common.tcfa_tm
#define tcf_bstats	common.tcfa_bstats
#define tcf_rate_est	common.tcfa_rate_est
#define tcf_lock	common.tcfa_lock

#define TCA_ACT_HW_STATS_ANY (TCA_ACT_HW_STATS_IMMEDIATE | \
			      TCA_ACT_HW_STATS_DELAYED)

/* Reserve 16 bits for user-space. See TCA_ACT_FLAGS_NO_PERCPU_STATS. */
#define TCA_ACT_FLAGS_USER_BITS 16
#define TCA_ACT_FLAGS_USER_MASK 0xffff
#define TCA_ACT_FLAGS_POLICE	(1U << TCA_ACT_FLAGS_USER_BITS)
#define TCA_ACT_FLAGS_BIND	(1U << (TCA_ACT_FLAGS_USER_BITS + 1))
#define TCA_ACT_FLAGS_REPLACE	(1U << (TCA_ACT_FLAGS_USER_BITS + 2))
#define TCA_ACT_FLAGS_NO_RTNL	(1U << (TCA_ACT_FLAGS_USER_BITS + 3))
#define TCA_ACT_FLAGS_AT_INGRESS	(1U << (TCA_ACT_FLAGS_USER_BITS + 4))
#define TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT	(1U << (TCA_ACT_FLAGS_USER_BITS + 5))

/* Update lastuse only if needed, to avoid dirtying a cache line.
 * We use a temp variable to avoid fetching jiffies twice.
 */
static inline void tcf_lastuse_update(struct tcf_t *tm)
{
	unsigned long now = jiffies;

	if (READ_ONCE(tm->lastuse) != now)
		WRITE_ONCE(tm->lastuse, now);
	if (unlikely(!READ_ONCE(tm->firstuse)))
		WRITE_ONCE(tm->firstuse, now);
}

static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm)
{
	unsigned long firstuse, now = jiffies;

	dtm->install = jiffies_to_clock_t(now - READ_ONCE(stm->install));
	dtm->lastuse = jiffies_to_clock_t(now - READ_ONCE(stm->lastuse));

	firstuse = READ_ONCE(stm->firstuse);
	dtm->firstuse = firstuse ?
		jiffies_to_clock_t(now - firstuse) : 0;

	dtm->expires = jiffies_to_clock_t(READ_ONCE(stm->expires));
}

static inline enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats)
{
	if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY))

Annotation

Implementation Notes