Skip to content

Commit

Permalink
Merge branch 'PHY-subsystem-kernel-doc'
Browse files Browse the repository at this point in the history
Andrew Lunn says:

====================
PHY subsystem kernel doc

The first patches fix existing warnings in the kerneldoc for the PHY
subsystem, and then the 2nd extend the kernel documentation for the
major structures and functions in the PHY subsystem.

v2:
Drop the other fixes which have already been merged.
s/phy/PHY/g
TBI
TypOs
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 24, 2020
2 parents 3fc826f + 4069a57 commit e0da743
Show file tree
Hide file tree
Showing 5 changed files with 404 additions and 135 deletions.
9 changes: 9 additions & 0 deletions Documentation/networking/kapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ PHY Support
.. kernel-doc:: drivers/net/phy/phy.c
: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
:export:

Expand Down
32 changes: 31 additions & 1 deletion drivers/net/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include <linux/phy.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)
{
BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 92,
Expand Down Expand Up @@ -52,6 +57,11 @@ const char *phy_speed_to_str(int speed)
}
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)
{
if (duplex == DUPLEX_HALF)
Expand Down Expand Up @@ -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);
}

/**
* 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 err;
Expand Down Expand Up @@ -308,6 +328,16 @@ void of_set_phy_eee_broken(struct phy_device *phydev)
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)
{
if (phydev->duplex == DUPLEX_FULL) {
Expand All @@ -321,7 +351,7 @@ void phy_resolve_aneg_pause(struct phy_device *phydev)
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
*
* Resolve our and the link partner advertisements into their corresponding
Expand Down
69 changes: 68 additions & 1 deletion drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,16 @@ int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
}
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)
{
if (!netif_running(dev))
Expand All @@ -466,13 +475,24 @@ int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
}
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)
{
mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,
jiffies);
}
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)
{
phy_queue_state_machine(phydev, 0);
Expand All @@ -489,6 +509,12 @@ static void phy_abort_cable_test(struct phy_device *phydev)
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)
{
if (!phydev->drv)
Expand All @@ -502,6 +528,11 @@ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
}
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 ret;
Expand All @@ -523,6 +554,13 @@ int phy_ethtool_get_sset_count(struct phy_device *phydev)
}
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,
struct ethtool_stats *stats, u64 *data)
{
Expand All @@ -537,6 +575,12 @@ int phy_ethtool_get_stats(struct phy_device *phydev,
}
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,
struct netlink_ext_ack *extack)
{
Expand Down Expand Up @@ -600,6 +644,13 @@ int phy_start_cable_test(struct phy_device *phydev,
}
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,
struct netlink_ext_ack *extack,
const struct phy_tdr_config *config)
Expand Down Expand Up @@ -1363,6 +1414,12 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
}
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)
{
if (phydev->drv && phydev->drv->set_wol)
Expand All @@ -1372,6 +1429,12 @@ int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *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)
{
if (phydev->drv && phydev->drv->get_wol)
Expand Down Expand Up @@ -1405,6 +1468,10 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
}
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)
{
struct phy_device *phydev = ndev->phydev;
Expand Down
3 changes: 2 additions & 1 deletion include/linux/mdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static inline u32 linkmode_adv_to_mii_10gbt_adv_t(unsigned long *advertising)
/**
* mii_10gbt_stat_mod_linkmode_lpa_t
* @advertising: target the linkmode advertisement settings
* @adv: value of the C45 10GBASE-T AN STATUS register
* @lpa: value of the C45 10GBASE-T AN STATUS register
*
* A small helper function that translates C45 10GBASE-T AN STATUS register bits
* to linkmode advertisement settings. Other bits in advertising aren't changed.
Expand Down Expand Up @@ -371,6 +371,7 @@ struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr);

/**
* mdio_module_driver() - Helper macro for registering mdio drivers
* @_mdio_driver: driver to register
*
* Helper macro for MDIO drivers which do not do anything special in module
* init/exit. Each module may only use this macro once, and calling it
Expand Down
Loading

0 comments on commit e0da743

Please sign in to comment.