linux/drivers/net/netdevsim/dev.c

/*
 * Copyright (c) 2018 Cumulus Networks. All rights reserved.
 * Copyright (c) 2018 David Ahern <[email protected]>
 * Copyright (c) 2019 Mellanox Technologies. All rights reserved.
 *
 * This software is licensed under the GNU General License Version 2,
 * June 1991 as shown in the file COPYING in the top-level directory of this
 * source tree.
 *
 * THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
 * OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
 * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 */

#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/etherdevice.h>
#include <linux/inet.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/random.h>
#include <linux/rtnetlink.h>
#include <linux/workqueue.h>
#include <net/devlink.h>
#include <net/ip.h>
#include <net/flow_offload.h>
#include <uapi/linux/devlink.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/udp.h>

#include "netdevsim.h"

static unsigned int
nsim_dev_port_index(enum nsim_dev_port_type type, unsigned int port_index)
{}

static inline unsigned int nsim_dev_port_index_to_vf_index(unsigned int port_index)
{}

static struct dentry *nsim_dev_ddir;

unsigned int nsim_dev_get_vfs(struct nsim_dev *nsim_dev)
{}

static void
nsim_bus_dev_set_vfs(struct nsim_bus_dev *nsim_bus_dev, unsigned int num_vfs)
{}

#define NSIM_DEV_DUMMY_REGION_SIZE

static int
nsim_dev_take_snapshot(struct devlink *devlink,
		       const struct devlink_region_ops *ops,
		       struct netlink_ext_ack *extack,
		       u8 **data)
{}

static ssize_t nsim_dev_take_snapshot_write(struct file *file,
					    const char __user *data,
					    size_t count, loff_t *ppos)
{}

static const struct file_operations nsim_dev_take_snapshot_fops =;

static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
					    char __user *data,
					    size_t count, loff_t *ppos)
{}

static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file,
					     const char __user *data,
					     size_t count, loff_t *ppos)
{}

static const struct file_operations nsim_dev_trap_fa_cookie_fops =;

static ssize_t nsim_bus_dev_max_vfs_read(struct file *file, char __user *data,
					 size_t count, loff_t *ppos)
{}

static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
					  const char __user *data,
					  size_t count, loff_t *ppos)
{}

static const struct file_operations nsim_dev_max_vfs_fops =;

static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
{}

static void nsim_dev_debugfs_exit(struct nsim_dev *nsim_dev)
{}

static ssize_t nsim_dev_rate_parent_read(struct file *file,
					 char __user *data,
					 size_t count, loff_t *ppos)
{}

static const struct file_operations nsim_dev_rate_parent_fops =;

static int nsim_dev_port_debugfs_init(struct nsim_dev *nsim_dev,
				      struct nsim_dev_port *nsim_dev_port)
{}

static void nsim_dev_port_debugfs_exit(struct nsim_dev_port *nsim_dev_port)
{}

static int nsim_dev_resources_register(struct devlink *devlink)
{}

enum nsim_devlink_param_id {};

static const struct devlink_param nsim_devlink_params[] =;

static void nsim_devlink_set_params_init_values(struct nsim_dev *nsim_dev,
						struct devlink *devlink)
{}

static void nsim_devlink_param_load_driverinit_values(struct devlink *devlink)
{}

#define NSIM_DEV_DUMMY_REGION_SNAPSHOT_MAX

static const struct devlink_region_ops dummy_region_ops =;

static int nsim_dev_dummy_region_init(struct nsim_dev *nsim_dev,
				      struct devlink *devlink)
{}

static void nsim_dev_dummy_region_exit(struct nsim_dev *nsim_dev)
{}

static int
__nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
		    unsigned int port_index);
static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port);

static int nsim_esw_legacy_enable(struct nsim_dev *nsim_dev,
				  struct netlink_ext_ack *extack)
{}

static int nsim_esw_switchdev_enable(struct nsim_dev *nsim_dev,
				     struct netlink_ext_ack *extack)
{}

static int nsim_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
					 struct netlink_ext_ack *extack)
{}

static int nsim_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
{}

struct nsim_trap_item {};

struct nsim_trap_data {};

/* All driver-specific traps must be documented in
 * Documentation/networking/devlink/netdevsim.rst
 */
enum {};

#define NSIM_TRAP_NAME_FID_MISS

#define NSIM_TRAP_METADATA

#define NSIM_TRAP_DROP(_id, _group_id)
#define NSIM_TRAP_DROP_EXT(_id, _group_id, _metadata)
#define NSIM_TRAP_EXCEPTION(_id, _group_id)
#define NSIM_TRAP_CONTROL(_id, _group_id, _action)
#define NSIM_TRAP_DRIVER_EXCEPTION(_id, _group_id)

#define NSIM_DEV_TRAP_POLICER_MIN_RATE
#define NSIM_DEV_TRAP_POLICER_MAX_RATE
#define NSIM_DEV_TRAP_POLICER_MIN_BURST
#define NSIM_DEV_TRAP_POLICER_MAX_BURST

#define NSIM_TRAP_POLICER(_id, _rate, _burst)

static const struct devlink_trap_policer nsim_trap_policers_arr[] =;

static const struct devlink_trap_group nsim_trap_groups_arr[] =;

static const struct devlink_trap nsim_traps_arr[] =;

#define NSIM_TRAP_L4_DATA_LEN

static struct sk_buff *nsim_dev_trap_skb_build(void)
{}

static void nsim_dev_trap_report(struct nsim_dev_port *nsim_dev_port)
{}

#define NSIM_TRAP_REPORT_INTERVAL_MS

static void nsim_dev_trap_report_work(struct work_struct *work)
{}

static int nsim_dev_traps_init(struct devlink *devlink)
{}

static void nsim_dev_traps_exit(struct devlink *devlink)
{}

static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
				  struct netlink_ext_ack *extack);
static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev);

static int nsim_dev_reload_down(struct devlink *devlink, bool netns_change,
				enum devlink_reload_action action, enum devlink_reload_limit limit,
				struct netlink_ext_ack *extack)
{}

static int nsim_dev_reload_up(struct devlink *devlink, enum devlink_reload_action action,
			      enum devlink_reload_limit limit, u32 *actions_performed,
			      struct netlink_ext_ack *extack)
{}

static int nsim_dev_info_get(struct devlink *devlink,
			     struct devlink_info_req *req,
			     struct netlink_ext_ack *extack)
{}

#define NSIM_DEV_FLASH_SIZE
#define NSIM_DEV_FLASH_CHUNK_SIZE
#define NSIM_DEV_FLASH_CHUNK_TIME_MS

static int nsim_dev_flash_update(struct devlink *devlink,
				 struct devlink_flash_update_params *params,
				 struct netlink_ext_ack *extack)
{}

static struct nsim_trap_item *
nsim_dev_trap_item_lookup(struct nsim_dev *nsim_dev, u16 trap_id)
{}

static int nsim_dev_devlink_trap_init(struct devlink *devlink,
				      const struct devlink_trap *trap,
				      void *trap_ctx)
{}

static int
nsim_dev_devlink_trap_action_set(struct devlink *devlink,
				 const struct devlink_trap *trap,
				 enum devlink_trap_action action,
				 struct netlink_ext_ack *extack)
{}

static int
nsim_dev_devlink_trap_group_set(struct devlink *devlink,
				const struct devlink_trap_group *group,
				const struct devlink_trap_policer *policer,
				struct netlink_ext_ack *extack)
{}

static int
nsim_dev_devlink_trap_policer_set(struct devlink *devlink,
				  const struct devlink_trap_policer *policer,
				  u64 rate, u64 burst,
				  struct netlink_ext_ack *extack)
{}

static int
nsim_dev_devlink_trap_policer_counter_get(struct devlink *devlink,
					  const struct devlink_trap_policer *policer,
					  u64 *p_drops)
{}

#define NSIM_LINK_SPEED_MAX
#define NSIM_LINK_SPEED_UNIT

static int nsim_rate_bytes_to_units(char *name, u64 *rate, struct netlink_ext_ack *extack)
{}

static int nsim_leaf_tx_share_set(struct devlink_rate *devlink_rate, void *priv,
				  u64 tx_share, struct netlink_ext_ack *extack)
{}

static int nsim_leaf_tx_max_set(struct devlink_rate *devlink_rate, void *priv,
				u64 tx_max, struct netlink_ext_ack *extack)
{}

struct nsim_rate_node {};

static int nsim_node_tx_share_set(struct devlink_rate *devlink_rate, void *priv,
				  u64 tx_share, struct netlink_ext_ack *extack)
{}

static int nsim_node_tx_max_set(struct devlink_rate *devlink_rate, void *priv,
				u64 tx_max, struct netlink_ext_ack *extack)
{}

static int nsim_rate_node_new(struct devlink_rate *node, void **priv,
			      struct netlink_ext_ack *extack)
{}

static int nsim_rate_node_del(struct devlink_rate *node, void *priv,
			      struct netlink_ext_ack *extack)
{}

static int nsim_rate_leaf_parent_set(struct devlink_rate *child,
				     struct devlink_rate *parent,
				     void *priv_child, void *priv_parent,
				     struct netlink_ext_ack *extack)
{}

static int nsim_rate_node_parent_set(struct devlink_rate *child,
				     struct devlink_rate *parent,
				     void *priv_child, void *priv_parent,
				     struct netlink_ext_ack *extack)
{}

static int
nsim_dev_devlink_trap_drop_counter_get(struct devlink *devlink,
				       const struct devlink_trap *trap,
				       u64 *p_drops)
{}

static const struct devlink_ops nsim_dev_devlink_ops =;

#define NSIM_DEV_MAX_MACS_DEFAULT
#define NSIM_DEV_TEST1_DEFAULT

static int __nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
			       unsigned int port_index)
{}

static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port)
{}

static void nsim_dev_port_del_all(struct nsim_dev *nsim_dev)
{}

static int nsim_dev_port_add_all(struct nsim_dev *nsim_dev,
				 unsigned int port_count)
{}

static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
				  struct netlink_ext_ack *extack)
{}

int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
{}

static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
{}

void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev)
{}

static struct nsim_dev_port *
__nsim_dev_port_lookup(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
		       unsigned int port_index)
{}

int nsim_drv_port_add(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type type,
		      unsigned int port_index)
{}

int nsim_drv_port_del(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type type,
		      unsigned int port_index)
{}

int nsim_drv_configure_vfs(struct nsim_bus_dev *nsim_bus_dev,
			   unsigned int num_vfs)
{}

int nsim_dev_init(void)
{}

void nsim_dev_exit(void)
{}