Commit 9b89f07f authored by David S. Miller's avatar David S. Miller

Merge branch 'SFP-phylink-updates'

Russell King says:

====================
SFP/phylink updates

This series, which follows on from the fixes posted earlier, improves
the phylink/sfp support.  Changes included here are:

- Merge 802.3z and SGMII modes into one "in-band" mode, using the
  PHY_INTERFACE_MODE_xxx definition to determine which should be used.
  This allows more flexibility as more interface modes become
  available.

- Allow 2500base-X and 10GBASE-KR to be requested from SFP.

- Remove unused and unnecessary phylink_init_eee()

- Restart 802.3z autonegotiation when starting the network device to
  ensure that the negotiated parameters are always correct.  It has
  been observed on mvneta that this is not always the case without
  this change.

- Add kerneldoc documentation for phylink and sfp upstream facing APIs
  and link it in to the networking documentation.

- Resolve a sparse warning in sfp-bus.c

- Convert phylink/sfp to use fwnode rather than DT so that other firmware
  systems can take advantage of this - I have received a request for it
  to be usable with ACPI.  The exception to this is our interactions with
  phylib, as phylib itself does not yet support fwnode.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b0e9fe1b 8fa7b9b6
......@@ -145,3 +145,27 @@ PHY Support
.. kernel-doc:: drivers/net/phy/mdio_bus.c
:internal:
PHYLINK
-------
PHYLINK interfaces traditional network drivers with PHYLIB, fixed-links,
and SFF modules (eg, hot-pluggable SFP) that may contain PHYs. PHYLINK
provides management of the link state and link modes.
.. kernel-doc:: include/linux/phylink.h
:internal:
.. kernel-doc:: drivers/net/phy/phylink.c
SFP support
-----------
.. kernel-doc:: drivers/net/phy/sfp-bus.c
:internal:
.. kernel-doc:: include/linux/sfp.h
:internal:
.. kernel-doc:: drivers/net/phy/sfp-bus.c
:export:
......@@ -36,7 +36,11 @@ enum {
PHYLINK_DISABLE_LINK,
};
/**
* struct phylink - internal data type for phylink
*/
struct phylink {
/* private: */
struct net_device *netdev;
const struct phylink_mac_ops *ops;
......@@ -87,6 +91,13 @@ static inline bool linkmode_empty(const unsigned long *src)
return bitmap_empty(src, __ETHTOOL_LINK_MODE_MASK_NBITS);
}
/**
* phylink_set_port_modes() - set the port type modes in the ethtool mask
* @mask: ethtool link mode mask
*
* Sets all the port type modes in the ethtool mask. MAC drivers should
* use this in their 'validate' callback.
*/
void phylink_set_port_modes(unsigned long *mask)
{
phylink_set(mask, TP);
......@@ -117,8 +128,7 @@ static const char *phylink_an_mode_str(unsigned int mode)
static const char *modestr[] = {
[MLO_AN_PHY] = "phy",
[MLO_AN_FIXED] = "fixed",
[MLO_AN_SGMII] = "SGMII",
[MLO_AN_8023Z] = "802.3z",
[MLO_AN_INBAND] = "inband",
};
return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown";
......@@ -132,59 +142,64 @@ static int phylink_validate(struct phylink *pl, unsigned long *supported,
return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
}
static int phylink_parse_fixedlink(struct phylink *pl, struct device_node *np)
static int phylink_parse_fixedlink(struct phylink *pl,
struct fwnode_handle *fwnode)
{
struct device_node *fixed_node;
struct fwnode_handle *fixed_node;
const struct phy_setting *s;
struct gpio_desc *desc;
const __be32 *fixed_prop;
u32 speed;
int ret, len;
int ret;
fixed_node = of_get_child_by_name(np, "fixed-link");
fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
if (fixed_node) {
ret = of_property_read_u32(fixed_node, "speed", &speed);
ret = fwnode_property_read_u32(fixed_node, "speed", &speed);
pl->link_config.speed = speed;
pl->link_config.duplex = DUPLEX_HALF;
if (of_property_read_bool(fixed_node, "full-duplex"))
if (fwnode_property_read_bool(fixed_node, "full-duplex"))
pl->link_config.duplex = DUPLEX_FULL;
/* We treat the "pause" and "asym-pause" terminology as
* defining the link partner's ability. */
if (of_property_read_bool(fixed_node, "pause"))
if (fwnode_property_read_bool(fixed_node, "pause"))
pl->link_config.pause |= MLO_PAUSE_SYM;
if (of_property_read_bool(fixed_node, "asym-pause"))
if (fwnode_property_read_bool(fixed_node, "asym-pause"))
pl->link_config.pause |= MLO_PAUSE_ASYM;
if (ret == 0) {
desc = fwnode_get_named_gpiod(&fixed_node->fwnode,
"link-gpios", 0,
GPIOD_IN, "?");
desc = fwnode_get_named_gpiod(fixed_node, "link-gpios",
0, GPIOD_IN, "?");
if (!IS_ERR(desc))
pl->link_gpio = desc;
else if (desc == ERR_PTR(-EPROBE_DEFER))
ret = -EPROBE_DEFER;
}
of_node_put(fixed_node);
fwnode_handle_put(fixed_node);
if (ret)
return ret;
} else {
fixed_prop = of_get_property(np, "fixed-link", &len);
if (!fixed_prop) {
u32 prop[5];
ret = fwnode_property_read_u32_array(fwnode, "fixed-link",
NULL, 0);
if (ret != ARRAY_SIZE(prop)) {
netdev_err(pl->netdev, "broken fixed-link?\n");
return -EINVAL;
}
if (len == 5 * sizeof(*fixed_prop)) {
pl->link_config.duplex = be32_to_cpu(fixed_prop[1]) ?
ret = fwnode_property_read_u32_array(fwnode, "fixed-link",
prop, ARRAY_SIZE(prop));
if (!ret) {
pl->link_config.duplex = prop[1] ?
DUPLEX_FULL : DUPLEX_HALF;
pl->link_config.speed = be32_to_cpu(fixed_prop[2]);
if (be32_to_cpu(fixed_prop[3]))
pl->link_config.speed = prop[2];
if (prop[3])
pl->link_config.pause |= MLO_PAUSE_SYM;
if (be32_to_cpu(fixed_prop[4]))
if (prop[4])
pl->link_config.pause |= MLO_PAUSE_ASYM;
}
}
......@@ -220,17 +235,17 @@ static int phylink_parse_fixedlink(struct phylink *pl, struct device_node *np)
return 0;
}
static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
{
struct device_node *dn;
struct fwnode_handle *dn;
const char *managed;
dn = of_get_child_by_name(np, "fixed-link");
if (dn || of_find_property(np, "fixed-link", NULL))
dn = fwnode_get_named_child_node(fwnode, "fixed-link");
if (dn || fwnode_property_present(fwnode, "fixed-link"))
pl->link_an_mode = MLO_AN_FIXED;
of_node_put(dn);
fwnode_handle_put(dn);
if (of_property_read_string(np, "managed", &managed) == 0 &&
if (fwnode_property_read_string(fwnode, "managed", &managed) == 0 &&
strcmp(managed, "in-band-status") == 0) {
if (pl->link_an_mode == MLO_AN_FIXED) {
netdev_err(pl->netdev,
......@@ -244,6 +259,7 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
phylink_set(pl->supported, Asym_Pause);
phylink_set(pl->supported, Pause);
pl->link_config.an_enabled = true;
pl->link_an_mode = MLO_AN_INBAND;
switch (pl->link_config.interface) {
case PHY_INTERFACE_MODE_SGMII:
......@@ -253,17 +269,14 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
phylink_set(pl->supported, 100baseT_Full);
phylink_set(pl->supported, 1000baseT_Half);
phylink_set(pl->supported, 1000baseT_Full);
pl->link_an_mode = MLO_AN_SGMII;
break;
case PHY_INTERFACE_MODE_1000BASEX:
phylink_set(pl->supported, 1000baseX_Full);
pl->link_an_mode = MLO_AN_8023Z;
break;
case PHY_INTERFACE_MODE_2500BASEX:
phylink_set(pl->supported, 2500baseX_Full);
pl->link_an_mode = MLO_AN_8023Z;
break;
case PHY_INTERFACE_MODE_10GKR:
......@@ -280,7 +293,6 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
phylink_set(pl->supported, 10000baseLR_Full);
phylink_set(pl->supported, 10000baseLRM_Full);
phylink_set(pl->supported, 10000baseER_Full);
pl->link_an_mode = MLO_AN_SGMII;
break;
default:
......@@ -320,8 +332,7 @@ static void phylink_mac_config(struct phylink *pl,
static void phylink_mac_an_restart(struct phylink *pl)
{
if (pl->link_config.an_enabled &&
(pl->link_config.interface == PHY_INTERFACE_MODE_1000BASEX ||
pl->link_config.interface == PHY_INTERFACE_MODE_2500BASEX))
phy_interface_mode_is_8023z(pl->link_config.interface))
pl->ops->mac_an_restart(pl->netdev);
}
......@@ -423,7 +434,7 @@ static void phylink_resolve(struct work_struct *w)
phylink_mac_config(pl, &link_state);
break;
case MLO_AN_SGMII:
case MLO_AN_INBAND:
phylink_get_mac_state(pl, &link_state);
if (pl->phydev) {
bool changed = false;
......@@ -449,10 +460,6 @@ static void phylink_resolve(struct work_struct *w)
}
}
break;
case MLO_AN_8023Z:
phylink_get_mac_state(pl, &link_state);
break;
}
}
......@@ -489,15 +496,24 @@ static void phylink_run_resolve(struct phylink *pl)
static const struct sfp_upstream_ops sfp_phylink_ops;
static int phylink_register_sfp(struct phylink *pl, struct device_node *np)
static int phylink_register_sfp(struct phylink *pl,
struct fwnode_handle *fwnode)
{
struct device_node *sfp_np;
struct fwnode_reference_args ref;
int ret;
sfp_np = of_parse_phandle(np, "sfp", 0);
if (!sfp_np)
return 0;
ret = fwnode_property_get_reference_args(fwnode, "sfp", NULL,
0, 0, &ref);
if (ret < 0) {
if (ret == -ENOENT)
return 0;
pl->sfp_bus = sfp_register_upstream(sfp_np, pl->netdev, pl,
netdev_err(pl->netdev, "unable to parse \"sfp\" node: %d\n",
ret);
return ret;
}
pl->sfp_bus = sfp_register_upstream(ref.fwnode, pl->netdev, pl,
&sfp_phylink_ops);
if (!pl->sfp_bus)
return -ENOMEM;
......@@ -505,7 +521,22 @@ static int phylink_register_sfp(struct phylink *pl, struct device_node *np)
return 0;
}
struct phylink *phylink_create(struct net_device *ndev, struct device_node *np,
/**
* phylink_create() - create a phylink instance
* @ndev: a pointer to the &struct net_device
* @fwnode: a pointer to a &struct fwnode_handle describing the network
* interface
* @iface: the desired link mode defined by &typedef phy_interface_t
* @ops: a pointer to a &struct phylink_mac_ops for the MAC.
*
* Create a new phylink instance, and parse the link parameters found in @np.
* This will parse in-band modes, fixed-link or SFP configuration.
*
* Returns a pointer to a &struct phylink, or an error-pointer value. Users
* must use IS_ERR() to check for errors from this function.
*/
struct phylink *phylink_create(struct net_device *ndev,
struct fwnode_handle *fwnode,
phy_interface_t iface,
const struct phylink_mac_ops *ops)
{
......@@ -533,21 +564,21 @@ struct phylink *phylink_create(struct net_device *ndev, struct device_node *np,
linkmode_copy(pl->link_config.advertising, pl->supported);
phylink_validate(pl, pl->supported, &pl->link_config);
ret = phylink_parse_mode(pl, np);
ret = phylink_parse_mode(pl, fwnode);
if (ret < 0) {
kfree(pl);
return ERR_PTR(ret);
}
if (pl->link_an_mode == MLO_AN_FIXED) {
ret = phylink_parse_fixedlink(pl, np);
ret = phylink_parse_fixedlink(pl, fwnode);
if (ret < 0) {
kfree(pl);
return ERR_PTR(ret);
}
}
ret = phylink_register_sfp(pl, np);
ret = phylink_register_sfp(pl, fwnode);
if (ret < 0) {
kfree(pl);
return ERR_PTR(ret);
......@@ -557,6 +588,13 @@ struct phylink *phylink_create(struct net_device *ndev, struct device_node *np,
}
EXPORT_SYMBOL_GPL(phylink_create);
/**
* phylink_destroy() - cleanup and destroy the phylink instance
* @pl: a pointer to a &struct phylink returned from phylink_create()
*
* Destroy a phylink instance. Any PHY that has been attached must have been
* cleaned up via phylink_disconnect_phy() prior to calling this function.
*/
void phylink_destroy(struct phylink *pl)
{
if (pl->sfp_bus)
......@@ -653,10 +691,30 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
return 0;
}
/**
* phylink_connect_phy() - connect a PHY to the phylink instance
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @phy: a pointer to a &struct phy_device.
*
* Connect @phy to the phylink instance specified by @pl by calling
* phy_attach_direct(). Configure the @phy according to the MAC driver's
* capabilities, start the PHYLIB state machine and enable any interrupts
* that the PHY supports.
*
* This updates the phylink's ethtool supported and advertising link mode
* masks.
*
* Returns 0 on success or a negative errno.
*/
int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
{
int ret;
if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED ||
(pl->link_an_mode == MLO_AN_INBAND &&
phy_interface_mode_is_8023z(pl->link_interface))))
return -EINVAL;
ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface);
if (ret)
return ret;
......@@ -669,14 +727,27 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
}
EXPORT_SYMBOL_GPL(phylink_connect_phy);
/**
* phylink_of_phy_connect() - connect the PHY specified in the DT mode.
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @dn: a pointer to a &struct device_node.
*
* Connect the phy specified in the device node @dn to the phylink instance
* specified by @pl. Actions specified in phylink_connect_phy() will be
* performed.
*
* Returns 0 on success or a negative errno.
*/
int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
{
struct device_node *phy_node;
struct phy_device *phy_dev;
int ret;
/* Fixed links are handled without needing a PHY */
if (pl->link_an_mode == MLO_AN_FIXED)
/* Fixed links and 802.3z are handled without needing a PHY */
if (pl->link_an_mode == MLO_AN_FIXED ||
(pl->link_an_mode == MLO_AN_INBAND &&
phy_interface_mode_is_8023z(pl->link_interface)))
return 0;
phy_node = of_parse_phandle(dn, "phy-handle", 0);
......@@ -708,6 +779,13 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
}
EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
/**
* phylink_disconnect_phy() - disconnect any PHY attached to the phylink
* instance.
* @pl: a pointer to a &struct phylink returned from phylink_create()
*
* Disconnect any current PHY from the phylink instance described by @pl.
*/
void phylink_disconnect_phy(struct phylink *pl)
{
struct phy_device *phy;
......@@ -729,6 +807,14 @@ void phylink_disconnect_phy(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_disconnect_phy);
/**
* phylink_mac_change() - notify phylink of a change in MAC state
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @up: indicates whether the link is currently up.
*
* The MAC driver should call this driver when the state of its link
* changes (eg, link failure, new negotiation results, etc.)
*/
void phylink_mac_change(struct phylink *pl, bool up)
{
if (!up)
......@@ -738,6 +824,14 @@ void phylink_mac_change(struct phylink *pl, bool up)
}
EXPORT_SYMBOL_GPL(phylink_mac_change);
/**
* phylink_start() - start a phylink instance
* @pl: a pointer to a &struct phylink returned from phylink_create()
*
* Start the phylink instance specified by @pl, configuring the MAC for the
* desired link mode(s) and negotiation style. This should be called from the
* network device driver's &struct net_device_ops ndo_open() method.
*/
void phylink_start(struct phylink *pl)
{
WARN_ON(!lockdep_rtnl_is_held());
......@@ -753,6 +847,12 @@ void phylink_start(struct phylink *pl)
phylink_resolve_flow(pl, &pl->link_config);
phylink_mac_config(pl, &pl->link_config);
/* Restart autonegotiation if using 802.3z to ensure that the link
* parameters are properly negotiated. This is necessary for DSA
* switches using 802.3z negotiation to ensure they see our modes.
*/
phylink_mac_an_restart(pl);
clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
phylink_run_resolve(pl);
......@@ -763,6 +863,15 @@ void phylink_start(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_start);
/**
* phylink_stop() - stop a phylink instance
* @pl: a pointer to a &struct phylink returned from phylink_create()
*
* Stop the phylink instance specified by @pl. This should be called from the
* network device driver's &struct net_device_ops ndo_stop() method. The
* network device's carrier state should not be changed prior to calling this
* function.
*/
void phylink_stop(struct phylink *pl)
{
WARN_ON(!lockdep_rtnl_is_held());
......@@ -778,6 +887,15 @@ void phylink_stop(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_stop);
/**
* phylink_ethtool_get_wol() - get the wake on lan parameters for the PHY
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @wol: a pointer to &struct ethtool_wolinfo to hold the read parameters
*
* Read the wake on lan parameters from the PHY attached to the phylink
* instance specified by @pl. If no PHY is currently attached, report no
* support for wake on lan.
*/
void phylink_ethtool_get_wol(struct phylink *pl, struct ethtool_wolinfo *wol)
{
WARN_ON(!lockdep_rtnl_is_held());
......@@ -790,6 +908,17 @@ void phylink_ethtool_get_wol(struct phylink *pl, struct ethtool_wolinfo *wol)
}
EXPORT_SYMBOL_GPL(phylink_ethtool_get_wol);
/**
* phylink_ethtool_set_wol() - set wake on lan parameters
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @wol: a pointer to &struct ethtool_wolinfo for the desired parameters
*
* Set the wake on lan parameters for the PHY attached to the phylink
* instance specified by @pl. If no PHY is attached, returns %EOPNOTSUPP
* error.
*
* Returns zero on success or negative errno code.
*/
int phylink_ethtool_set_wol(struct phylink *pl, struct ethtool_wolinfo *wol)
{
int ret = -EOPNOTSUPP;
......@@ -825,6 +954,15 @@ static void phylink_get_ksettings(const struct phylink_link_state *state,
AUTONEG_DISABLE;
}
/**
* phylink_ethtool_ksettings_get() - get the current link settings
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @kset: a pointer to a &struct ethtool_link_ksettings to hold link settings
*
* Read the current link settings for the phylink instance specified by @pl.
* This will be the link settings read from the MAC, PHY or fixed link
* settings depending on the current negotiation mode.
*/
int phylink_ethtool_ksettings_get(struct phylink *pl,
struct ethtool_link_ksettings *kset)
{
......@@ -850,14 +988,13 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
phylink_get_ksettings(&link_state, kset);
break;
case MLO_AN_SGMII:
case MLO_AN_INBAND:
/* If there is a phy attached, then use the reported
* settings from the phy with no modification.
*/
if (pl->phydev)
break;
case MLO_AN_8023Z:
phylink_get_mac_state(pl, &link_state);
/* The MAC is reporting the link results from its own PCS
......@@ -872,6 +1009,11 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
}
EXPORT_SYMBOL_GPL(phylink_ethtool_ksettings_get);
/**
* phylink_ethtool_ksettings_set() - set the link settings
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @kset: a pointer to a &struct ethtool_link_ksettings for the desired modes
*/
int phylink_ethtool_ksettings_set(struct phylink *pl,
const struct ethtool_link_ksettings *kset)
{
......@@ -965,6 +1107,17 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
}
EXPORT_SYMBOL_GPL(phylink_ethtool_ksettings_set);
/**
* phylink_ethtool_nway_reset() - restart negotiation
* @pl: a pointer to a &struct phylink returned from phylink_create()
*
* Restart negotiation for the phylink instance specified by @pl. This will
* cause any attached phy to restart negotiation with the link partner, and
* if the MAC is in a BaseX mode, the MAC will also be requested to restart
* negotiation.
*
* Returns zero on success, or negative error code.
*/
int phylink_ethtool_nway_reset(struct phylink *pl)
{
int ret = 0;
......@@ -979,6 +1132,11 @@ int phylink_ethtool_nway_reset(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_ethtool_nway_reset);
/**
* phylink_ethtool_get_pauseparam() - get the current pause parameters
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @pause: a pointer to a &struct ethtool_pauseparam
*/
void phylink_ethtool_get_pauseparam(struct phylink *pl,
struct ethtool_pauseparam *pause)
{
......@@ -990,6 +1148,11 @@ void phylink_ethtool_get_pauseparam(struct phylink *pl,
}
EXPORT_SYMBOL_GPL(phylink_ethtool_get_pauseparam);
/**
* phylink_ethtool_set_pauseparam() - set the current pause parameters
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @pause: a pointer to a &struct ethtool_pauseparam
*/
int phylink_ethtool_set_pauseparam(struct phylink *pl,
struct ethtool_pauseparam *pause)
{
......@@ -1028,8 +1191,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
phylink_mac_config(pl, config);
break;
case MLO_AN_SGMII:
case MLO_AN_8023Z:
case MLO_AN_INBAND:
phylink_mac_config(pl, config);
phylink_mac_an_restart(pl);
break;
......@@ -1068,19 +1230,16 @@ int phylink_ethtool_get_module_eeprom(struct phylink *pl,
}
EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
{
int ret = -EPROTONOSUPPORT;
WARN_ON(!lockdep_rtnl_is_held());
if (pl->phydev)
ret = phy_init_eee(pl->phydev, clk_stop_enable);
return ret;
}
EXPORT_SYMBOL_GPL(phylink_init_eee);
/**
* phylink_ethtool_get_eee_err() - read the energy efficient ethernet error
* counter
* @pl: a pointer to a &struct phylink returned from phylink_create().
*
* Read the Energy Efficient Ethernet error counter from the PHY associated
* with the phylink instance specified by @pl.
*
* Returns positive error counter value, or negative error code.
*/
int phylink_get_eee_err(struct phylink *pl)
{
int ret = 0;
......@@ -1094,6 +1253,11 @@ int phylink_get_eee_err(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_get_eee_err);
/**
* phylink_ethtool_get_eee() - read the energy efficient ethernet parameters
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @eee: a pointer to a &struct ethtool_eee for the read parameters
*/
int phylink_ethtool_get_eee(struct phylink *pl, struct ethtool_eee *eee)
{
int ret = -EOPNOTSUPP;
......@@ -1107,6 +1271,11 @@ int phylink_ethtool_get_eee(struct phylink *pl, struct ethtool_eee *eee)
}
EXPORT_SYMBOL_GPL(phylink_ethtool_get_eee);
/**
* phylink_ethtool_set_eee() - set the energy efficient ethernet parameters
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @eee: a pointer to a &struct ethtool_eee for the desired parameters
*/
int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_eee *eee)
{
int ret = -EOPNOTSUPP;
......@@ -1246,9 +1415,7 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id,
case MLO_AN_PHY:
return -EOPNOTSUPP;
case MLO_AN_SGMII:
/* No phy, fall through to 8023z method */
case MLO_AN_8023Z:
case MLO_AN_INBAND:
if (phy_id == 0) {
val = phylink_get_mac_state(pl, &state);
if (val < 0)
......@@ -1273,15 +1440,31 @@ static int phylink_mii_write(struct phylink *pl, unsigned int phy_id,
case MLO_AN_PHY:
return -EOPNOTSUPP;
case MLO_AN_SGMII:
/* No phy, fall through to 8023z method */
case MLO_AN_8023Z:
case MLO_AN_INBAND:
break;
}
return 0;
}
/**
* phylink_mii_ioctl() - generic mii ioctl interface
* @pl: a pointer to a &struct phylink returned from phylink_create()
* @ifr: a pointer to a &struct ifreq for socket ioctls
* @cmd: ioctl cmd to execute
*
* Perform the specified MII ioctl on the PHY attached to the phylink instance
* specified by @pl. If no PHY is attached, emulate the presence of the PHY.
*
* Returns: zero on success or negative error code.
*
* %SIOCGMIIPHY:
* read register from the current PHY.
* %SIOCGMIIREG:
* read register from the specified PHY.
* %SIOCSMIIREG:
* set a register on the specified PHY.
*/
int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
{
struct mii_ioctl_data *mii = if_mii(ifr);
......@@ -1290,7 +1473,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
WARN_ON(!lockdep_rtnl_is_held());
if (pl->phydev) {
/* PHYs only exist for MLO_AN_PHY and MLO_AN_SGMII */
/* PHYs only exist for MLO_AN_PHY and SGMII */
switch (cmd) {
case SIOCGMIIPHY:
mii->phy_id = pl->phydev->mdio.addr;
......@@ -1359,10 +1542,10 @@ static int phylink_sfp_module_insert(void *upstream,
switch (iface) {
case PHY_INTERFACE_MODE_SGMII:
mode = MLO_AN_SGMII;
break;
case PHY_INTERFACE_MODE_1000BASEX:
mode = MLO_AN_8023Z;
case PHY_INTERFACE_MODE_2500BASEX:
case PHY_INTERFACE_MODE_10GKR:
mode = MLO_AN_INBAND;
break;
default:
return -EINVAL;
......@@ -1389,7 +1572,7 @@ static int phylink_sfp_module_insert(void *upstream,
phylink_an_mode_str(mode), phy_modes(config.interface),
__ETHTOOL_LINK_MODE_MASK_NBITS, support);
if (mode == MLO_AN_8023Z && pl->phydev)
if (phy_interface_mode_is_8023z(iface) && pl->phydev)
return -EINVAL;
changed = !bitmap_equal(pl->supported, support,
......
......@@ -8,10 +8,14 @@
#include "sfp.h"
/**
* struct sfp_bus - internal representation of a sfp bus
*/
struct sfp_bus {
/* private: */
struct kref kref;
struct list_head node;
struct device_node *device_node;
struct fwnode_handle *fwnode;
const struct sfp_socket_ops *socket_ops;
struct device *sfp_dev;
......@@ -26,6 +30,20 @@ struct sfp_bus {
bool started;
};
/**
* sfp_parse_port() - Parse the EEPROM base ID, setting the port type
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
* @id: a pointer to the module's &struct sfp_eeprom_id
* @support: optional pointer to an array of unsigned long for the
* ethtool support mask
*
* Parse the EEPROM identification given in @id, and return one of
* %PORT_TP, %PORT_FIBRE or %PORT_OTHER. If @support is non-%NULL,
* also set the ethtool %ETHTOOL_LINK_MODE_xxx_BIT corresponding with
* the connector type.
*
* If the port type is not known, returns %PORT_OTHER.
*/
int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
unsigned long *support)
{
......@@ -78,6 +96,24 @@ int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
}
EXPORT_SYMBOL_GPL(sfp_parse_port);
/**
* sfp_parse_interface() - Parse the phy_interface_t
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
* @id: a pointer to the module's &struct sfp_eeprom_id
*
* Derive the phy_interface_t mode for the information found in the
* module's identifying EEPROM. There is no standard or defined way
* to derive this information, so we use some heuristics.
*
* If the encoding is 64b66b, then the module must be >= 10G, so
* return %PHY_INTERFACE_MODE_10GKR.
*
* If it's 8b10b, then it's 1G or slower. If it's definitely a fibre
* module, return %PHY_INTERFACE_MODE_1000BASEX mode, otherwise return
* %PHY_INTERFACE_MODE_SGMII mode.
*
* If the encoding is not known, return %PHY_INTERFACE_MODE_NA.
*/
phy_interface_t sfp_parse_interface(struct sfp_bus *bus,
const struct sfp_eeprom_id *id)
{
......@@ -117,6 +153,15 @@ phy_interface_t sfp_parse_interface(struct sfp_bus *bus,
}
EXPORT_SYMBOL_GPL(sfp_parse_interface);
/**
* sfp_parse_support() - Parse the eeprom id for supported link modes
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
* @id: a pointer to the module's &struct sfp_eeprom_id
* @support: pointer to an array of unsigned long for the ethtool support mask
*
* Parse the EEPROM identification information and derive the supported
* ethtool link modes for the module.
*/
void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
unsigned long *support)
{
......@@ -215,7 +260,7 @@ static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus)
return bus->registered ? bus->upstream_ops : NULL;
}
static struct sfp_bus *sfp_bus_get(struct device_node *np)
static struct sfp_bus *sfp_bus_get(struct fwnode_handle *fwnode)
{
struct sfp_bus *sfp, *new, *found = NULL;
......@@ -224,7 +269,7 @@ static struct sfp_bus *sfp_bus_get(struct device_node *np)
mutex_lock(&sfp_mutex);
list_for_each_entry(sfp, &sfp_buses, node) {
if (sfp->device_node == np) {
if (sfp->fwnode == fwnode) {
kref_get(&sfp->kref);
found = sfp;
break;
......@@ -233,7 +278,7 @@ static struct sfp_bus *sfp_bus_get(struct device_node *np)
if (!found && new) {
kref_init(&new->kref);
new->device_node = np;
new->fwnode = fwnode;
list_add(&new->node, &sfp_buses);
found = new;
new = NULL;
......@@ -246,7 +291,7 @@ static struct sfp_bus *sfp_bus_get(struct device_node *np)
return found;
}
static void sfp_bus_release(struct kref *kref) __releases(sfp_mutex)
static void sfp_bus_release(struct kref *kref)
{
struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref);
......@@ -293,6 +338,16 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
bus->registered = false;
}
/**
* sfp_get_module_info() - Get the ethtool_modinfo for a SFP module
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
* @modinfo: a &struct ethtool_modinfo
*
* Fill in the type and eeprom_len parameters in @modinfo for a module on
* the sfp bus specified by @bus.
*
* Returns 0 on success or a negative errno number.
*/
int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo)
{
if (!bus->registered)
......@@ -301,6 +356,17 @@ int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo)
}
EXPORT_SYMBOL_GPL(sfp_get_module_info);
/**
* sfp_get_module_eeprom() - Read the SFP module EEPROM
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
* @ee: a &struct ethtool_eeprom
* @data: buffer to contain the EEPROM data (must be at least @ee->len bytes)
*
* Read the EEPROM as specified by the supplied @ee. See the documentation
* for &struct ethtool_eeprom for the region to be read.
*
* Returns 0 on success or a negative errno number.
*/
int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
u8 *data)
{
......@@ -310,6 +376,15 @@ int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
}
EXPORT_SYMBOL_GPL(sfp_get_module_eeprom);
/**
* sfp_upstream_start() - Inform the SFP that the network device is up
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
*
* Inform the SFP socket that the network device is now up, so that the
* module can be enabled by allowing TX_DISABLE to be deasserted. This
* should be called from the network device driver's &struct net_device_ops
* ndo_open() method.
*/
void sfp_upstream_start(struct sfp_bus *bus)
{
if (bus->registered)
......@@ -318,6 +393,15 @@ void sfp_upstream_start(struct sfp_bus *bus)
}
EXPORT_SYMBOL_GPL(sfp_upstream_start);
/**
* sfp_upstream_stop() - Inform the SFP that the network device is down
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
*
* Inform the SFP socket that the network device is now up, so that the
* module can be disabled by asserting TX_DISABLE, disabling the laser
* in optical modules. This should be called from the network device
* driver's &struct net_device_ops ndo_stop() method.
*/
void sfp_upstream_stop(struct sfp_bus *bus)
{
if (bus->registered)
......@@ -326,11 +410,24 @@ void sfp_upstream_stop(struct sfp_bus *bus)
}
EXPORT_SYMBOL_GPL(sfp_upstream_stop);
struct sfp_bus *sfp_register_upstream(struct device_node *np,
/**
* sfp_register_upstream() - Register the neighbouring device
* @np: device node for the SFP bus
* @ndev: network device associated with the interface
* @upstream: the upstream private data
* @ops: the upstream's &struct sfp_upstream_ops
*
* Register the upstream device (eg, PHY) with the SFP bus. MAC drivers
* should use phylink, which will call this function for them. Returns
* a pointer to the allocated &struct sfp_bus.
*
* On error, returns %NULL.
*/
struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
struct net_device *ndev, void *upstream,
const struct sfp_upstream_ops *ops)
{
struct sfp_bus *bus = sfp_bus_get(np);
struct sfp_bus *bus = sfp_bus_get(fwnode);
int ret = 0;
if (bus) {
......@@ -353,6 +450,13 @@ struct sfp_bus *sfp_register_upstream(struct device_node *np,
}
EXPORT_SYMBOL_GPL(sfp_register_upstream);
/**
* sfp_unregister_upstream() - Unregister sfp bus
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
*
* Unregister a previously registered upstream connection for the SFP
* module. @bus is returned from sfp_register_upstream().
*/
void sfp_unregister_upstream(struct sfp_bus *bus)
{
rtnl_lock();
......@@ -433,7 +537,7 @@ EXPORT_SYMBOL_GPL(sfp_module_remove);
struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp,
const struct sfp_socket_ops *ops)
{
struct sfp_bus *bus = sfp_bus_get(dev->of_node);
struct sfp_bus *bus = sfp_bus_get(dev->fwnode);
int ret = 0;
if (bus) {
......
......@@ -761,6 +761,20 @@ static inline bool phy_interface_mode_is_rgmii(phy_interface_t mode)
mode <= PHY_INTERFACE_MODE_RGMII_TXID;
};
/**
* phy_interface_mode_is_8023z() - does the phy interface mode use 802.3z
* negotiation
* @mode: one of &enum phy_interface_t
*
* Returns true if the phy interface mode uses the 16-bit negotiation
* word as defined in 802.3z. (See 802.3-2015 37.2.1 Config_Reg encoding)
*/
static inline bool phy_interface_mode_is_8023z(phy_interface_t mode)
{
return mode == PHY_INTERFACE_MODE_1000BASEX ||
mode == PHY_INTERFACE_MODE_2500BASEX;
}
/**
* phy_interface_is_rgmii - Convenience function for testing if a PHY interface
* is RGMII (all variants)
......
......@@ -7,6 +7,7 @@
struct device_node;
struct ethtool_cmd;
struct fwnode_handle;
struct net_device;
enum {
......@@ -20,19 +21,31 @@ enum {
MLO_AN_PHY = 0, /* Conventional PHY */
MLO_AN_FIXED, /* Fixed-link mode */
MLO_AN_SGMII, /* Cisco SGMII protocol */
MLO_AN_8023Z, /* 1000base-X protocol */
MLO_AN_INBAND, /* In-band protocol */
};
static inline bool phylink_autoneg_inband(unsigned int mode)
{
return mode == MLO_AN_SGMII || mode == MLO_AN_8023Z;
return mode == MLO_AN_INBAND;
}
/**
* struct phylink_link_state - link state structure
* @advertising: ethtool bitmask containing advertised link modes
* @lp_advertising: ethtool bitmask containing link partner advertised link
* modes
* @interface: link &typedef phy_interface_t mode
* @speed: link speed, one of the SPEED_* constants.
* @duplex: link duplex mode, one of DUPLEX_* constants.
* @pause: link pause state, described by MLO_PAUSE_* constants.
* @link: true if the link is up.
* @an_enabled: true if autonegotiation is enabled/desired.
* @an_complete: true if autonegotiation has completed.
*/
struct phylink_link_state {
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
phy_interface_t interface; /* PHY_INTERFACE_xxx */
phy_interface_t interface;
int speed;
int duplex;
int pause;
......@@ -41,66 +54,136 @@ struct phylink_link_state {
unsigned int an_complete:1;
};
/**
* struct phylink_mac_ops - MAC operations structure.
* @validate: Validate and update the link configuration.
* @mac_link_state: Read the current link state from the hardware.
* @mac_config: configure the MAC for the selected mode and state.
* @mac_an_restart: restart 802.3z BaseX autonegotiation.
* @mac_link_down: take the link down.
* @mac_link_up: allow the link to come up.
*
* The individual methods are described more fully below.
*/
struct phylink_mac_ops {
/**
* validate: validate and update the link configuration
* @ndev: net_device structure associated with MAC
* @config: configuration to validate
*
* Update the %config->supported and %config->advertised masks
* clearing bits that can not be supported.
*
* Note: the PHY may be able to transform from one connection
* technology to another, so, eg, don't clear 1000BaseX just
* because the MAC is unable to support it. This is more about
* clearing unsupported speeds and duplex settings.
*
* If the %config->interface mode is %PHY_INTERFACE_MODE_1000BASEX
* or %PHY_INTERFACE_MODE_2500BASEX, select the appropriate mode
* based on %config->advertised and/or %config->speed.
*/
void (*validate)(struct net_device *ndev, unsigned long *supported,
struct phylink_link_state *state);
/* Read the current link state from the hardware */
int (*mac_link_state)(struct net_device *, struct phylink_link_state *);
/* Configure the MAC */
/**
* mac_config: configure the MAC for the selected mode and state
* @ndev: net_device structure for the MAC
* @mode: one of MLO_AN_FIXED, MLO_AN_PHY, MLO_AN_8023Z, MLO_AN_SGMII
* @state: state structure
*
* The action performed depends on the currently selected mode:
*
* %MLO_AN_FIXED, %MLO_AN_PHY:
* set the specified speed, duplex, pause mode, and phy interface
* mode in the provided @state.
* %MLO_AN_8023Z:
* place the link in 1000base-X mode, advertising the parameters
* given in advertising in @state.
* %MLO_AN_SGMII:
* place the link in Cisco SGMII mode - there is no advertisment
* to make as the PHY communicates the speed and duplex to the
* MAC over the in-band control word. Configuration of the pause
* mode is as per MLO_AN_PHY since this is not included.
*/
int (*mac_link_state)(struct net_device *ndev,
struct phylink_link_state *state);
void (*mac_config)(struct net_device *ndev, unsigned int mode,
const struct phylink_link_state *state);
/**
* mac_an_restart: restart 802.3z BaseX autonegotiation
* @ndev: net_device structure for the MAC
*/
void (*mac_an_restart)(struct net_device *ndev);
void (*mac_link_down)(struct net_device *, unsigned int mode);
void (*mac_link_up)(struct net_device *, unsigned int mode,
struct phy_device *);
void (*mac_link_down)(struct net_device *ndev, unsigned int mode);
void (*mac_link_up)(struct net_device *ndev, unsigned int mode,
struct phy_device *phy);
};
struct phylink *phylink_create(struct net_device *, struct device_node *,
#if 0 /* For kernel-doc purposes only. */
/**
* validate - Validate and update the link configuration
* @ndev: a pointer to a &struct net_device for the MAC.
* @supported: ethtool bitmask for supported link modes.
* @state: a pointer to a &struct phylink_link_state.
*
* Clear bits in the @supported and @state->advertising masks that
* are not supportable by the MAC.
*
* Note that the PHY may be able to transform from one connection
* technology to another, so, eg, don't clear 1000BaseX just
* because the MAC is unable to BaseX mode. This is more about
* clearing unsupported speeds and duplex settings.
*
* If the @state->interface mode is %PHY_INTERFACE_MODE_1000BASEX
* or %PHY_INTERFACE_MODE_2500BASEX, select the appropriate mode
* based on @state->advertising and/or @state->speed and update
* @state->interface accordingly.
*/
void validate(struct net_device *ndev, unsigned long *supported,
struct phylink_link_state *state);
/**
* mac_link_state() - Read the current link state from the hardware
* @ndev: a pointer to a &struct net_device for the MAC.
* @state: a pointer to a &struct phylink_link_state.
*
* Read the current link state from the MAC, reporting the current
* speed in @state->speed, duplex mode in @state->duplex, pause mode
* in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
* negotiation completion state in @state->an_complete, and link
* up state in @state->link.
*/
int mac_link_state(struct net_device *ndev,
struct phylink_link_state *state);
/**
* mac_config() - configure the MAC for the selected mode and state
* @ndev: a pointer to a &struct net_device for the MAC.
* @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
* @state: a pointer to a &struct phylink_link_state.
*
* The action performed depends on the currently selected mode:
*
* %MLO_AN_FIXED, %MLO_AN_PHY:
* Configure the specified @state->speed, @state->duplex and
* @state->pause (%MLO_PAUSE_TX / %MLO_PAUSE_RX) mode.
*
* %MLO_AN_INBAND:
* place the link in an inband negotiation mode (such as 802.3z
* 1000base-X or Cisco SGMII mode depending on the @state->interface
* mode). In both cases, link state management (whether the link
* is up or not) is performed by the MAC, and reported via the
* mac_link_state() callback. Changes in link state must be made
* by calling phylink_mac_change().
*
* If in 802.3z mode, the link speed is fixed, dependent on the
* @state->interface. Duplex is negotiated, and pause is advertised
* according to @state->an_enabled, @state->pause and
* @state->advertising flags. Beware of MACs which only support full
* duplex at gigabit and higher speeds.
*
* If in Cisco SGMII mode, the link speed and duplex mode are passed
* in the serial bitstream 16-bit configuration word, and the MAC
* should be configured to read these bits and acknowledge the
* configuration word. Nothing is advertised by the MAC. The MAC is
* responsible for reading the configuration word and configuring
* itself accordingly.
*/
void mac_config(struct net_device *ndev, unsigned int mode,
const struct phylink_link_state *state);
/**
* mac_an_restart() - restart 802.3z BaseX autonegotiation
* @ndev: a pointer to a &struct net_device for the MAC.
*/
void mac_an_restart(struct net_device *ndev);
/**
* mac_link_down() - take the link down
* @ndev: a pointer to a &struct net_device for the MAC.
* @mode: link autonegotiation mode
*
* If @mode is not an in-band negotiation mode (as defined by
* phylink_autoneg_inband()), force the link down and disable any
* Energy Efficient Ethernet MAC configuration.
*/
void mac_link_down(struct net_device *ndev, unsigned int mode);
/**
* mac_link_up() - allow the link to come up
* @ndev: a pointer to a &struct net_device for the MAC.
* @mode: link autonegotiation mode
* @phy: any attached phy
*
* If @mode is not an in-band negotiation mode (as defined by
* phylink_autoneg_inband()), allow the link to come up. If @phy
* is non-%NULL, configure Energy Efficient Ethernet by calling
* phy_init_eee() and perform appropriate MAC configuration for EEE.
*/
void mac_link_up(struct net_device *ndev, unsigned int mode,
struct phy_device *phy);
#endif
struct phylink *phylink_create(struct net_device *, struct fwnode_handle *,
phy_interface_t iface, const struct phylink_mac_ops *ops);
void phylink_destroy(struct phylink *);
......@@ -128,7 +211,6 @@ int phylink_ethtool_set_pauseparam(struct phylink *,
int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *);
int phylink_ethtool_get_module_eeprom(struct phylink *,
struct ethtool_eeprom *, u8 *);
int phylink_init_eee(struct phylink *, bool);
int phylink_get_eee_err(struct phylink *);
int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
......
......@@ -3,7 +3,7 @@
#include <linux/phy.h>
struct __packed sfp_eeprom_base {
struct sfp_eeprom_base {
u8 phys_id;
u8 phys_ext_id;
u8 connector;
......@@ -166,12 +166,12 @@ struct __packed sfp_eeprom_base {
union {
__be16 optical_wavelength;
u8 cable_spec;
};
} __packed;
u8 reserved62;
u8 cc_base;
};
} __packed;
struct __packed sfp_eeprom_ext {
struct sfp_eeprom_ext {
__be16 options;
u8 br_max;
u8 br_min;
......@@ -181,12 +181,21 @@ struct __packed sfp_eeprom_ext {
u8 enhopts;
u8 sff8472_compliance;
u8 cc_ext;
};
struct __packed sfp_eeprom_id {
} __packed;
/**
* struct sfp_eeprom_id - raw SFP module identification information
* @base: base SFP module identification structure
* @ext: extended SFP module identification structure
*
* See the SFF-8472 specification and related documents for the definition
* of these structure members. This can be obtained from
* ftp://ftp.seagate.com/sff
*/
struct sfp_eeprom_id {
struct sfp_eeprom_base base;
struct sfp_eeprom_ext ext;
};
} __packed;
/* SFP EEPROM registers */
enum {
......@@ -347,19 +356,32 @@ enum {
SFP_PAGE = 0x7f,
};
struct device_node;
struct fwnode_handle;
struct ethtool_eeprom;
struct ethtool_modinfo;
struct net_device;
struct sfp_bus;
/**
* struct sfp_upstream_ops - upstream operations structure
* @module_insert: called after a module has been detected to determine
* whether the module is supported for the upstream device.
* @module_remove: called after the module has been removed.
* @link_down: called when the link is non-operational for whatever
* reason.
* @link_up: called when the link is operational.
* @connect_phy: called when an I2C accessible PHY has been detected
* on the module.
* @disconnect_phy: called when a module with an I2C accessible PHY has
* been removed.
*/
struct sfp_upstream_ops {
int (*module_insert)(void *, const struct sfp_eeprom_id *id);
void (*module_remove)(void *);
void (*link_down)(void *);
void (*link_up)(void *);
int (*connect_phy)(void *, struct phy_device *);
void (*disconnect_phy)(void *);
int (*module_insert)(void *priv, const struct sfp_eeprom_id *id);
void (*module_remove)(void *priv);
void (*link_down)(void *priv);
void (*link_up)(void *priv);
int (*connect_phy)(void *priv, struct phy_device *);
void (*disconnect_phy)(void *priv);
};
#if IS_ENABLED(CONFIG_SFP)
......@@ -375,7 +397,7 @@ int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
u8 *data);
void sfp_upstream_start(struct sfp_bus *bus);
void sfp_upstream_stop(struct sfp_bus *bus);
struct sfp_bus *sfp_register_upstream(struct device_node *np,
struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
struct net_device *ndev, void *upstream,
const struct sfp_upstream_ops *ops);
void sfp_unregister_upstream(struct sfp_bus *bus);
......@@ -419,7 +441,8 @@ static inline void sfp_upstream_stop(struct sfp_bus *bus)
{
}
static inline struct sfp_bus *sfp_register_upstream(struct device_node *np,
static inline struct sfp_bus *sfp_register_upstream(
struct fwnode_handle *fwnode,
struct net_device *ndev, void *upstream,
const struct sfp_upstream_ops *ops)
{
......
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