linux/drivers/leds/trigger/ledtrig-netdev.c

// SPDX-License-Identifier: GPL-2.0
// Copyright 2017 Ben Whitten <[email protected]>
// Copyright 2007 Oliver Jowett <[email protected]>
//
// LED Kernel Netdev Trigger
//
// Toggles the LED to reflect the link and traffic state of a named net device
//
// Derived from ledtrig-timer.c which is:
//  Copyright 2005-2006 Openedhand Ltd.
//  Author: Richard Purdie <[email protected]>

#include <linux/atomic.h>
#include <linux/ctype.h>
#include <linux/device.h>
#include <linux/ethtool.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/leds.h>
#include <linux/linkmode.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/mutex.h>
#include <linux/phy.h>
#include <linux/rtnetlink.h>
#include <linux/timer.h>
#include "../leds.h"

#define NETDEV_LED_DEFAULT_INTERVAL

/*
 * Configurable sysfs attributes:
 *
 * device_name - network device name to monitor
 * interval - duration of LED blink, in milliseconds
 * link -  LED's normal state reflects whether the link is up
 *         (has carrier) or not
 * tx -  LED blinks on transmitted data
 * rx -  LED blinks on receive data
 * tx_err -  LED blinks on transmit error
 * rx_err -  LED blinks on receive error
 *
 * Note: If the user selects a mode that is not supported by hw, default
 * behavior is to fall back to software control of the LED. However not every
 * hw supports software control. LED callbacks brightness_set() and
 * brightness_set_blocking() are NULL in this case. hw_control_is_supported()
 * should use available means supported by hw to inform the user that selected
 * mode isn't supported by hw. This could be switching off the LED or any
 * hw blink mode. If software control fallback isn't possible, we return
 * -EOPNOTSUPP to the user, but still store the selected mode. This is needed
 * in case an intermediate unsupported mode is necessary to switch from one
 * supported mode to another.
 */

struct led_netdev_data {};

static const struct attribute_group netdev_trig_link_speed_attrs_group;

static void set_baseline_state(struct led_netdev_data *trigger_data)
{}

static bool supports_hw_control(struct led_classdev *led_cdev)
{}

/*
 * Validate the configured netdev is the same as the one associated with
 * the LED driver in hw control.
 */
static bool validate_net_dev(struct led_classdev *led_cdev,
			     struct net_device *net_dev)
{}

static bool can_hw_control(struct led_netdev_data *trigger_data)
{}

static void get_device_state(struct led_netdev_data *trigger_data)
{}

static ssize_t device_name_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

static int set_device_name(struct led_netdev_data *trigger_data,
			   const char *name, size_t size)
{}

static ssize_t device_name_store(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t size)
{}

static DEVICE_ATTR_RW(device_name);

static ssize_t netdev_led_attr_show(struct device *dev, char *buf,
				    enum led_trigger_netdev_modes attr)
{}

static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
				     size_t size, enum led_trigger_netdev_modes attr)
{}

#define DEFINE_NETDEV_TRIGGER(trigger_name, trigger)

DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();
DEFINE_NETDEV_TRIGGER();

static ssize_t interval_show(struct device *dev,
			     struct device_attribute *attr, char *buf)
{}

static ssize_t interval_store(struct device *dev,
			      struct device_attribute *attr, const char *buf,
			      size_t size)
{}

static DEVICE_ATTR_RW(interval);

static ssize_t offloaded_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(offloaded);

#define CHECK_LINK_MODE_ATTR(link_speed)

static umode_t netdev_trig_link_speed_visible(struct kobject *kobj,
					      struct attribute *attr, int n)
{}

static struct attribute *netdev_trig_link_speed_attrs[] =;

static const struct attribute_group netdev_trig_link_speed_attrs_group =;

static struct attribute *netdev_trig_attrs[] =;

static const struct attribute_group netdev_trig_attrs_group =;

static const struct attribute_group *netdev_trig_groups[] =;

static int netdev_trig_notify(struct notifier_block *nb,
			      unsigned long evt, void *dv)
{}

/* here's the real work! */
static void netdev_trig_work(struct work_struct *work)
{}

static int netdev_trig_activate(struct led_classdev *led_cdev)
{}

static void netdev_trig_deactivate(struct led_classdev *led_cdev)
{}

static struct led_trigger netdev_led_trigger =;

module_led_trigger();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();