linux/net/core/gen_stats.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * net/core/gen_stats.c
 *
 * Authors:  Thomas Graf <[email protected]>
 *           Jamal Hadi Salim
 *           Alexey Kuznetsov, <[email protected]>
 *
 * See Documentation/networking/gen_stats.rst
 */

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/socket.h>
#include <linux/rtnetlink.h>
#include <linux/gen_stats.h>
#include <net/netlink.h>
#include <net/gen_stats.h>
#include <net/sch_generic.h>

static inline int
gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size, int padattr)
{}

/**
 * gnet_stats_start_copy_compat - start dumping procedure in compatibility mode
 * @skb: socket buffer to put statistics TLVs into
 * @type: TLV type for top level statistic TLV
 * @tc_stats_type: TLV type for backward compatibility struct tc_stats TLV
 * @xstats_type: TLV type for backward compatibility xstats TLV
 * @lock: statistics lock
 * @d: dumping handle
 * @padattr: padding attribute
 *
 * Initializes the dumping handle, grabs the statistic lock and appends
 * an empty TLV header to the socket buffer for use a container for all
 * other statistic TLVS.
 *
 * The dumping handle is marked to be in backward compatibility mode telling
 * all gnet_stats_copy_XXX() functions to fill a local copy of struct tc_stats.
 *
 * Returns 0 on success or -1 if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
			     int xstats_type, spinlock_t *lock,
			     struct gnet_dump *d, int padattr)
	__acquires(lock)
{}
EXPORT_SYMBOL();

/**
 * gnet_stats_start_copy - start dumping procedure in compatibility mode
 * @skb: socket buffer to put statistics TLVs into
 * @type: TLV type for top level statistic TLV
 * @lock: statistics lock
 * @d: dumping handle
 * @padattr: padding attribute
 *
 * Initializes the dumping handle, grabs the statistic lock and appends
 * an empty TLV header to the socket buffer for use a container for all
 * other statistic TLVS.
 *
 * Returns 0 on success or -1 if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock,
		      struct gnet_dump *d, int padattr)
{}
EXPORT_SYMBOL();

/* Must not be inlined, due to u64_stats seqcount_t lockdep key */
void gnet_stats_basic_sync_init(struct gnet_stats_basic_sync *b)
{}
EXPORT_SYMBOL();

static void gnet_stats_add_basic_cpu(struct gnet_stats_basic_sync *bstats,
				     struct gnet_stats_basic_sync __percpu *cpu)
{}

void gnet_stats_add_basic(struct gnet_stats_basic_sync *bstats,
			  struct gnet_stats_basic_sync __percpu *cpu,
			  struct gnet_stats_basic_sync *b, bool running)
{}
EXPORT_SYMBOL();

static void gnet_stats_read_basic(u64 *ret_bytes, u64 *ret_packets,
				  struct gnet_stats_basic_sync __percpu *cpu,
				  struct gnet_stats_basic_sync *b, bool running)
{}

static int
___gnet_stats_copy_basic(struct gnet_dump *d,
			 struct gnet_stats_basic_sync __percpu *cpu,
			 struct gnet_stats_basic_sync *b,
			 int type, bool running)
{}

/**
 * gnet_stats_copy_basic - copy basic statistics into statistic TLV
 * @d: dumping handle
 * @cpu: copy statistic per cpu
 * @b: basic statistics
 * @running: true if @b represents a running qdisc, thus @b's
 *           internal values might change during basic reads.
 *           Only used if @cpu is NULL
 *
 * Context: task; must not be run from IRQ or BH contexts
 *
 * Appends the basic statistics to the top level TLV created by
 * gnet_stats_start_copy().
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_basic(struct gnet_dump *d,
		      struct gnet_stats_basic_sync __percpu *cpu,
		      struct gnet_stats_basic_sync *b,
		      bool running)
{}
EXPORT_SYMBOL();

/**
 * gnet_stats_copy_basic_hw - copy basic hw statistics into statistic TLV
 * @d: dumping handle
 * @cpu: copy statistic per cpu
 * @b: basic statistics
 * @running: true if @b represents a running qdisc, thus @b's
 *           internal values might change during basic reads.
 *           Only used if @cpu is NULL
 *
 * Context: task; must not be run from IRQ or BH contexts
 *
 * Appends the basic statistics to the top level TLV created by
 * gnet_stats_start_copy().
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_basic_hw(struct gnet_dump *d,
			 struct gnet_stats_basic_sync __percpu *cpu,
			 struct gnet_stats_basic_sync *b,
			 bool running)
{}
EXPORT_SYMBOL();

/**
 * gnet_stats_copy_rate_est - copy rate estimator statistics into statistics TLV
 * @d: dumping handle
 * @rate_est: rate estimator
 *
 * Appends the rate estimator statistics to the top level TLV created by
 * gnet_stats_start_copy().
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_rate_est(struct gnet_dump *d,
			 struct net_rate_estimator __rcu **rate_est)
{}
EXPORT_SYMBOL();

static void gnet_stats_add_queue_cpu(struct gnet_stats_queue *qstats,
				     const struct gnet_stats_queue __percpu *q)
{}

void gnet_stats_add_queue(struct gnet_stats_queue *qstats,
			  const struct gnet_stats_queue __percpu *cpu,
			  const struct gnet_stats_queue *q)
{}
EXPORT_SYMBOL();

/**
 * gnet_stats_copy_queue - copy queue statistics into statistics TLV
 * @d: dumping handle
 * @cpu_q: per cpu queue statistics
 * @q: queue statistics
 * @qlen: queue length statistics
 *
 * Appends the queue statistics to the top level TLV created by
 * gnet_stats_start_copy(). Using per cpu queue statistics if
 * they are available.
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_queue(struct gnet_dump *d,
		      struct gnet_stats_queue __percpu *cpu_q,
		      struct gnet_stats_queue *q, __u32 qlen)
{}
EXPORT_SYMBOL();

/**
 * gnet_stats_copy_app - copy application specific statistics into statistics TLV
 * @d: dumping handle
 * @st: application specific statistics data
 * @len: length of data
 *
 * Appends the application specific statistics to the top level TLV created by
 * gnet_stats_start_copy() and remembers the data for XSTATS if the dumping
 * handle is in backward compatibility mode.
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_app(struct gnet_dump *d, void *st, int len)
{}
EXPORT_SYMBOL();

/**
 * gnet_stats_finish_copy - finish dumping procedure
 * @d: dumping handle
 *
 * Corrects the length of the top level TLV to include all TLVs added
 * by gnet_stats_copy_XXX() calls. Adds the backward compatibility TLVs
 * if gnet_stats_start_copy_compat() was used and releases the statistics
 * lock.
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_finish_copy(struct gnet_dump *d)
{}
EXPORT_SYMBOL();