Commit 4069a572 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: phy: Document core PHY structures

Add kerneldoc for the core PHY data structures, a few inline functions
and exported functions which are not already documented.

v2
Typos
g/phy/PHY/s
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 39097ab6
...@@ -134,6 +134,15 @@ PHY Support ...@@ -134,6 +134,15 @@ PHY Support
.. kernel-doc:: drivers/net/phy/phy.c .. kernel-doc:: drivers/net/phy/phy.c
:internal: :internal:
.. kernel-doc:: drivers/net/phy/phy-core.c
:export:
.. kernel-doc:: drivers/net/phy/phy-c45.c
:export:
.. kernel-doc:: include/linux/phy.h
:internal:
.. kernel-doc:: drivers/net/phy/phy_device.c .. kernel-doc:: drivers/net/phy/phy_device.c
:export: :export:
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/of.h> #include <linux/of.h>
/**
* phy_speed_to_str - Return a string representing the PHY link speed
*
* @speed: Speed of the link
*/
const char *phy_speed_to_str(int speed) const char *phy_speed_to_str(int speed)
{ {
BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 92, BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 92,
...@@ -52,6 +57,11 @@ const char *phy_speed_to_str(int speed) ...@@ -52,6 +57,11 @@ const char *phy_speed_to_str(int speed)
} }
EXPORT_SYMBOL_GPL(phy_speed_to_str); EXPORT_SYMBOL_GPL(phy_speed_to_str);
/**
* phy_duplex_to_str - Return string describing the duplex
*
* @duplex: Duplex setting to describe
*/
const char *phy_duplex_to_str(unsigned int duplex) const char *phy_duplex_to_str(unsigned int duplex)
{ {
if (duplex == DUPLEX_HALF) if (duplex == DUPLEX_HALF)
...@@ -252,6 +262,16 @@ static int __set_phy_supported(struct phy_device *phydev, u32 max_speed) ...@@ -252,6 +262,16 @@ static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
return __set_linkmode_max_speed(max_speed, phydev->supported); return __set_linkmode_max_speed(max_speed, phydev->supported);
} }
/**
* phy_set_max_speed - Set the maximum speed the PHY should support
*
* @phydev: The phy_device struct
* @max_speed: Maximum speed
*
* The PHY might be more capable than the MAC. For example a Fast Ethernet
* is connected to a 1G PHY. This function allows the MAC to indicate its
* maximum speed, and so limit what the PHY will advertise.
*/
int phy_set_max_speed(struct phy_device *phydev, u32 max_speed) int phy_set_max_speed(struct phy_device *phydev, u32 max_speed)
{ {
int err; int err;
...@@ -308,6 +328,16 @@ void of_set_phy_eee_broken(struct phy_device *phydev) ...@@ -308,6 +328,16 @@ void of_set_phy_eee_broken(struct phy_device *phydev)
phydev->eee_broken_modes = broken; phydev->eee_broken_modes = broken;
} }
/**
* phy_resolve_aneg_pause - Determine pause autoneg results
*
* @phydev: The phy_device struct
*
* Once autoneg has completed the local pause settings can be
* resolved. Determine if pause and asymmetric pause should be used
* by the MAC.
*/
void phy_resolve_aneg_pause(struct phy_device *phydev) void phy_resolve_aneg_pause(struct phy_device *phydev)
{ {
if (phydev->duplex == DUPLEX_FULL) { if (phydev->duplex == DUPLEX_FULL) {
...@@ -321,7 +351,7 @@ void phy_resolve_aneg_pause(struct phy_device *phydev) ...@@ -321,7 +351,7 @@ void phy_resolve_aneg_pause(struct phy_device *phydev)
EXPORT_SYMBOL_GPL(phy_resolve_aneg_pause); EXPORT_SYMBOL_GPL(phy_resolve_aneg_pause);
/** /**
* phy_resolve_aneg_linkmode - resolve the advertisements into phy settings * phy_resolve_aneg_linkmode - resolve the advertisements into PHY settings
* @phydev: The phy_device struct * @phydev: The phy_device struct
* *
* Resolve our and the link partner advertisements into their corresponding * Resolve our and the link partner advertisements into their corresponding
......
...@@ -456,7 +456,16 @@ int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -456,7 +456,16 @@ int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
} }
EXPORT_SYMBOL(phy_do_ioctl); EXPORT_SYMBOL(phy_do_ioctl);
/* same as phy_do_ioctl, but ensures that net_device is running */ /**
* phy_do_ioctl_running - generic ndo_do_ioctl implementation but test first
*
* @dev: the net_device struct
* @ifr: &struct ifreq for socket ioctl's
* @cmd: ioctl cmd to execute
*
* Same as phy_do_ioctl, but ensures that net_device is running before
* handling the ioctl.
*/
int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd) int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
{ {
if (!netif_running(dev)) if (!netif_running(dev))
...@@ -466,6 +475,12 @@ int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -466,6 +475,12 @@ int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
} }
EXPORT_SYMBOL(phy_do_ioctl_running); EXPORT_SYMBOL(phy_do_ioctl_running);
/**
* phy_queue_state_machine - Trigger the state machine to run soon
*
* @phydev: the phy_device struct
* @jiffies: Run the state machine after these jiffies
*/
void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies) void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
{ {
mod_delayed_work(system_power_efficient_wq, &phydev->state_queue, mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,
...@@ -473,6 +488,11 @@ void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies) ...@@ -473,6 +488,11 @@ void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
} }
EXPORT_SYMBOL(phy_queue_state_machine); EXPORT_SYMBOL(phy_queue_state_machine);
/**
* phy_queue_state_machine - Trigger the state machine to run now
*
* @phydev: the phy_device struct
*/
static void phy_trigger_machine(struct phy_device *phydev) static void phy_trigger_machine(struct phy_device *phydev)
{ {
phy_queue_state_machine(phydev, 0); phy_queue_state_machine(phydev, 0);
...@@ -489,6 +509,12 @@ static void phy_abort_cable_test(struct phy_device *phydev) ...@@ -489,6 +509,12 @@ static void phy_abort_cable_test(struct phy_device *phydev)
phydev_err(phydev, "Error while aborting cable test"); phydev_err(phydev, "Error while aborting cable test");
} }
/**
* phy_ethtool_get_strings - Get the statistic counter names
*
* @phydev: the phy_device struct
* @data: Where to put the strings
*/
int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
{ {
if (!phydev->drv) if (!phydev->drv)
...@@ -502,6 +528,11 @@ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) ...@@ -502,6 +528,11 @@ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
} }
EXPORT_SYMBOL(phy_ethtool_get_strings); EXPORT_SYMBOL(phy_ethtool_get_strings);
/**
* phy_ethtool_get_sset_count - Get the number of statistic counters
*
* @phydev: the phy_device struct
*/
int phy_ethtool_get_sset_count(struct phy_device *phydev) int phy_ethtool_get_sset_count(struct phy_device *phydev)
{ {
int ret; int ret;
...@@ -523,6 +554,13 @@ int phy_ethtool_get_sset_count(struct phy_device *phydev) ...@@ -523,6 +554,13 @@ int phy_ethtool_get_sset_count(struct phy_device *phydev)
} }
EXPORT_SYMBOL(phy_ethtool_get_sset_count); EXPORT_SYMBOL(phy_ethtool_get_sset_count);
/**
* phy_ethtool_get_stats - Get the statistic counters
*
* @phydev: the phy_device struct
* @stats: What counters to get
* @data: Where to store the counters
*/
int phy_ethtool_get_stats(struct phy_device *phydev, int phy_ethtool_get_stats(struct phy_device *phydev,
struct ethtool_stats *stats, u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
...@@ -537,6 +575,12 @@ int phy_ethtool_get_stats(struct phy_device *phydev, ...@@ -537,6 +575,12 @@ int phy_ethtool_get_stats(struct phy_device *phydev,
} }
EXPORT_SYMBOL(phy_ethtool_get_stats); EXPORT_SYMBOL(phy_ethtool_get_stats);
/**
* phy_start_cable_test - Start a cable test
*
* @phydev: the phy_device struct
* @extack: extack for reporting useful error messages
*/
int phy_start_cable_test(struct phy_device *phydev, int phy_start_cable_test(struct phy_device *phydev,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
...@@ -600,6 +644,13 @@ int phy_start_cable_test(struct phy_device *phydev, ...@@ -600,6 +644,13 @@ int phy_start_cable_test(struct phy_device *phydev,
} }
EXPORT_SYMBOL(phy_start_cable_test); EXPORT_SYMBOL(phy_start_cable_test);
/**
* phy_start_cable_test_tdr - Start a raw TDR cable test
*
* @phydev: the phy_device struct
* @extack: extack for reporting useful error messages
* @config: Configuration of the test to run
*/
int phy_start_cable_test_tdr(struct phy_device *phydev, int phy_start_cable_test_tdr(struct phy_device *phydev,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
const struct phy_tdr_config *config) const struct phy_tdr_config *config)
...@@ -1363,6 +1414,12 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data) ...@@ -1363,6 +1414,12 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
} }
EXPORT_SYMBOL(phy_ethtool_set_eee); EXPORT_SYMBOL(phy_ethtool_set_eee);
/**
* phy_ethtool_set_wol - Configure Wake On LAN
*
* @phydev: target phy_device struct
* @wol: Configuration requested
*/
int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
{ {
if (phydev->drv && phydev->drv->set_wol) if (phydev->drv && phydev->drv->set_wol)
...@@ -1372,6 +1429,12 @@ int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) ...@@ -1372,6 +1429,12 @@ int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
} }
EXPORT_SYMBOL(phy_ethtool_set_wol); EXPORT_SYMBOL(phy_ethtool_set_wol);
/**
* phy_ethtool_get_wol - Get the current Wake On LAN configuration
*
* @phydev: target phy_device struct
* @wol: Store the current configuration here
*/
void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
{ {
if (phydev->drv && phydev->drv->get_wol) if (phydev->drv && phydev->drv->get_wol)
...@@ -1405,6 +1468,10 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev, ...@@ -1405,6 +1468,10 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
} }
EXPORT_SYMBOL(phy_ethtool_set_link_ksettings); EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
/**
* phy_ethtool_nway_reset - Restart auto negotiation
* @ndev: Network device to restart autoneg for
*/
int phy_ethtool_nway_reset(struct net_device *ndev) int phy_ethtool_nway_reset(struct net_device *ndev)
{ {
struct phy_device *phydev = ndev->phydev; struct phy_device *phydev = ndev->phydev;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment