linux/net/devlink/devl_internal.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Copyright (c) 2016 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2016 Jiri Pirko <[email protected]>
 */

#include <linux/device.h>
#include <linux/etherdevice.h>
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/notifier.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include <linux/xarray.h>
#include <net/devlink.h>
#include <net/net_namespace.h>
#include <net/rtnetlink.h>
#include <rdma/ib_verbs.h>

#include "netlink_gen.h"

struct devlink_rel;

#define DEVLINK_REGISTERED

#define DEVLINK_RELOAD_STATS_ARRAY_SIZE

struct devlink_dev_stats {};

struct devlink {};

extern struct xarray devlinks;
extern struct genl_family devlink_nl_family;

/* devlink instances are open to the access from the user space after
 * devlink_register() call. Such logical barrier allows us to have certain
 * expectations related to locking.
 *
 * Before *_register() - we are in initialization stage and no parallel
 * access possible to the devlink instance. All drivers perform that phase
 * by implicitly holding device_lock.
 *
 * After *_register() - users and driver can access devlink instance at
 * the same time.
 */
#define ASSERT_DEVLINK_REGISTERED(d)
#define ASSERT_DEVLINK_NOT_REGISTERED(d)

/* Iterate over devlink pointers which were possible to get reference to.
 * devlink_put() needs to be called for each iterated devlink pointer
 * in loop body in order to release the reference.
 */
#define devlinks_xa_for_each_registered_get(net, index, devlink)

struct devlink *devlinks_xa_find_get(struct net *net, unsigned long *indexp);

static inline bool __devl_is_registered(struct devlink *devlink)
{}

static inline bool devl_is_registered(struct devlink *devlink)
{}

static inline void devl_dev_lock(struct devlink *devlink, bool dev_lock)
{}

static inline void devl_dev_unlock(struct devlink *devlink, bool dev_lock)
{}

devlink_rel_notify_cb_t;
devlink_rel_cleanup_cb_t;

void devlink_rel_nested_in_clear(u32 rel_index);
int devlink_rel_nested_in_add(u32 *rel_index, u32 devlink_index,
			      u32 obj_index, devlink_rel_notify_cb_t *notify_cb,
			      devlink_rel_cleanup_cb_t *cleanup_cb,
			      struct devlink *devlink);
void devlink_rel_nested_in_notify(struct devlink *devlink);
int devlink_rel_devlink_handle_put(struct sk_buff *msg, struct devlink *devlink,
				   u32 rel_index, int attrtype,
				   bool *msg_updated);

/* Netlink */
enum devlink_multicast_groups {};

/* state held across netlink dumps */
struct devlink_nl_dump_state {};

devlink_nl_dump_one_func_t;

struct devlink *
devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs,
			    bool dev_lock);

int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
		      devlink_nl_dump_one_func_t *dump_one);

static inline struct devlink_nl_dump_state *
devlink_dump_state(struct netlink_callback *cb)
{}

static inline int
devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink)
{}

int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
				 struct devlink *devlink, int attrtype);
int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info);

static inline bool devlink_nl_notify_need(struct devlink *devlink)
{}

struct devlink_obj_desc {};

static inline void devlink_nl_obj_desc_init(struct devlink_obj_desc *desc,
					    struct devlink *devlink)
{}

static inline void devlink_nl_obj_desc_port_set(struct devlink_obj_desc *desc,
						struct devlink_port *devlink_port)
{}

int devlink_nl_notify_filter(struct sock *dsk, struct sk_buff *skb, void *data);

static inline void devlink_nl_notify_send_desc(struct devlink *devlink,
					       struct sk_buff *msg,
					       struct devlink_obj_desc *desc)
{}

static inline void devlink_nl_notify_send(struct devlink *devlink,
					  struct sk_buff *msg)
{}

/* Notify */
void devlink_notify_register(struct devlink *devlink);
void devlink_notify_unregister(struct devlink *devlink);
void devlink_ports_notify_register(struct devlink *devlink);
void devlink_ports_notify_unregister(struct devlink *devlink);
void devlink_params_notify_register(struct devlink *devlink);
void devlink_params_notify_unregister(struct devlink *devlink);
void devlink_regions_notify_register(struct devlink *devlink);
void devlink_regions_notify_unregister(struct devlink *devlink);
void devlink_trap_policers_notify_register(struct devlink *devlink);
void devlink_trap_policers_notify_unregister(struct devlink *devlink);
void devlink_trap_groups_notify_register(struct devlink *devlink);
void devlink_trap_groups_notify_unregister(struct devlink *devlink);
void devlink_traps_notify_register(struct devlink *devlink);
void devlink_traps_notify_unregister(struct devlink *devlink);
void devlink_rates_notify_register(struct devlink *devlink);
void devlink_rates_notify_unregister(struct devlink *devlink);
void devlink_linecards_notify_register(struct devlink *devlink);
void devlink_linecards_notify_unregister(struct devlink *devlink);

/* Ports */
#define ASSERT_DEVLINK_PORT_INITIALIZED(devlink_port)

struct devlink_port *devlink_port_get_by_index(struct devlink *devlink,
					       unsigned int port_index);
int devlink_port_netdevice_event(struct notifier_block *nb,
				 unsigned long event, void *ptr);
struct devlink_port *
devlink_port_get_from_info(struct devlink *devlink, struct genl_info *info);
struct devlink_port *devlink_port_get_from_attrs(struct devlink *devlink,
						 struct nlattr **attrs);

/* Reload */
bool devlink_reload_actions_valid(const struct devlink_ops *ops);
int devlink_reload(struct devlink *devlink, struct net *dest_net,
		   enum devlink_reload_action action,
		   enum devlink_reload_limit limit,
		   u32 *actions_performed, struct netlink_ext_ack *extack);

static inline bool devlink_reload_supported(const struct devlink_ops *ops)
{}

/* Params */
void devlink_params_driverinit_load_new(struct devlink *devlink);

/* Resources */
struct devlink_resource;
int devlink_resources_validate(struct devlink *devlink,
			       struct devlink_resource *resource,
			       struct genl_info *info);

/* Rates */
int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
			     struct netlink_ext_ack *extack);

/* Linecards */
unsigned int devlink_linecard_index(struct devlink_linecard *linecard);