net: phy: Introduce PHY ports representation
Subsystems (9)
Maxime Chevallier
maintainerv22 cover net: phy: Introduce PHY ports representation
Hi everyone,
This is v22 of the phy_port work. Main items from this versions are :
- Rebase on net-next :)
- Removed a "contains" keyword in the binding
- Added a comment for phy_port SFP implementation
Patch 1 now lacks DT maintainer ACK,
Patches 2 and 3 lack PHY maintainer ACK
As a remainder, a few important notes :
- This is only a first phase. It instantiates the port, and leverage that to make the MAC <-> PHY <-> SFP usecase simpler.
- Next phase will deal with controlling the port state, as well as the netlink uAPI for that.
- The end-goal is to enable support for complex port MUX. This preliminary work focuses on PHY-driven ports, but this will be extended to support muxing at the MII level (Multi-phy, or compo PHY
+ SFP as found on Turris Omnia for example).
- The naming is definitely not set in stone. I named that "phy_port", but this may convey the false sense that this is phylib-specific. Even the word "port" is not that great, as it already has several different meanings in the net world (switch port, devlink port, etc.). I used the term "connector" in the binding.
A bit of history on that work :
The end goal that I personnaly want to achieve is :
+ PHY - RJ45
|
MAC - MUX -+ PHY - RJ45
After many discussions here on netdev@, but also at netdevconf[1] and LPC[2], there appears to be several analoguous designs that exist out there.
[1] : https://netdevconf.info/0x17/sessions/talk/improving-multi-phy-and-multi-port-interfaces.html
[2] : https://lpc.events/event/18/contributions/1964/ (video isn't the
right one)
Take the MAchiatobin, it has 2 interfaces that looks like this :
MAC - PHY -+ RJ45
|
+ SFP - Whatever the module does
Now, looking at the Turris Omnia, we have :
MAC - MUX -+ PHY - RJ45
|
+ SFP - Whatever the module does
We can find more example of this kind of designs, the common part is that we expose multiple front-facing media ports. This is what this current work aims at supporting. As of right now, it does'nt add any support for muxing, but this will come later on.
This first phase focuses on phy-driven ports only, but there are already quite some challenges already. For one, we can't really autodetect how many ports are sitting behind a PHY. That's why this series introduces a new binding. Describing ports in DT should however be a last-resort thing when we need to clear some ambiguity about the PHY media-side.
The only use-cases that we have today for multi-port PHYs are combo PHYs that drive both a Copper port and an SFP (the Macchiatobin case). This in itself is challenging and this series only addresses part of this support, by registering a phy_port for the PHY <-> SFP connection. The SFP module should in the end be considered as a port as well, but that's not yet the case.
However, because now PHYs can register phy_ports for every media-side interface they have, they can register the capabilities of their ports, which allows making the PHY-driver SFP case much more generic.
Let me know what you think, I'm all in for discussions :)
Regards,
Changes in v22:
- remove 'contains' in DT binding, as per AI review
- Added a comment indicating that phy_port parameters will be initialized eventually, as per AI review.
Changes in v21:
- Drop unused variable in marvell10g.c
- Address Russell's comments on 100BaseTX and 1000BaseX in commit logs
Changes in V20:
- Drop dp83822 SFP support, untested for too long
- Fix some cleanup sequences following claude's review
Changes in v19:
- Rebase on net-next, add the 4 new 1600G linkmodes
Changes in v18:
- Added a missing 'static' when declaring the medium names.
Changes in v17:
- Moved the medium names to patch 3
- Moved some mediums helpers out of uapi, and the logic into net/ethtool/common.c instead of inline functions in headers
- Added a MAINTAINERS entry
- Aggregated reviews/tests
- Rebased on net-next
Changes in v16:
- From Andrew, relaxed the check on the number of pairs so that we only fail when baseT is missing pairs
- Add a check for either 1, 2 or 4 pairs
- Lots of typos (mostly lanes -> pairs)
- Added Andrew's review tags (thanks again)
- From Rob, added an "else" statement in the ethernet-connector binding
- Changed the node name for ethernet connectors to be decimal
Changes in V15:
- Update bindings, docs and code to use pairs instead of lanes
- Make pairs only relevant for BaseT
Changes in V14:
- Fixed kdoc
- Use the sfp module_caps feature.
Changes in V13:
- Added phy_caps support for interface selection
- Aggregated tested-by tags
Changes in V12:
- Moved some of phylink's internal helpers to phy_caps for reuse in phylib
- Fixed SFP interface selection
- Added Rob's review and changes in patch 6
Changes in V11:
- The ti,fiber-mode property was deprecated in favor of the ethernet-connector binding
- The .attach_port was split into an MDI and an MII version
- I added the warning back in the AR8031 PHY driver
- There is now an init-time check on the number of lanes associated to every linkmode, making sure the number of lanes is above or equal to the minimum required
- Various typos were fixed all around
- We no longer use sfp_select_interface() for SFP interface validation
Changes in V10:
- Rebase on net-next
- Fix a typo reported by Köry
- Aggregate all reviews
- Fix the conflict on the qcom driver
Changes in V9:
- Removed maxItems and items from the connector binding
- Fixed a typo in the binding
Changes in V8:
- Added maxItems on the connector media binding
- Made sure we parse a single medium
- Added a missing bitwise macro
Changes in V7:
- Move ethtool_medium_get_supported to phy_caps
- support combo-ports, each with a given set of supported modes
- Introduce the notion of 'not-described' ports
Changes in V6:
- Fixed kdoc on patch 3
- Addressed a missing port-ops registration for the Marvell 88x2222 driver
- Addressed a warning reported by Simon on the DP83822 when building without CONFIG_OF_MDIO
Changes in V5 :
- renamed the bindings to use the term "connector" instead of "port"
- Rebased, and fixed some issues reported on the 83822 driver
- Use phy_caps
Changes in V4 :
- Introduced a kernel doc
- Reworked the mediums definitions in patch 2
- QCA807x now uses the generic SFP support
- Fixed some implementation bugs to build the support list based on the interfaces supported on a port
V21: https://lore.kernel.org/netdev/[email protected]/
V20: https://lore.kernel.org/r/[email protected]
V19: https://lore.kernel.org/r/[email protected]
V18: https://lore.kernel.org/r/[email protected]
V17: https://lore.kernel.org/all/[email protected]/
V16: https://lore.kernel.org/all/[email protected]/
V15: https://lore.kernel.org/all/[email protected]/
V14: https://lore.kernel.org/netdev/[email protected]/
V13: https://lore.kernel.org/netdev/[email protected]/
V12: https://lore.kernel.org/netdev/[email protected]/
V11: https://lore.kernel.org/netdev/[email protected]/
V10: https://lore.kernel.org/netdev/[email protected]/
V9: https://lore.kernel.org/netdev/[email protected]/
V8: https://lore.kernel.org/netdev/[email protected]/
v7: https://lore.kernel.org/netdev/[email protected]/
V6: https://lore.kernel.org/netdev/[email protected]/
V5: https://lore.kernel.org/netdev/[email protected]/
V4: https://lore.kernel.org/netdev/[email protected]/
V3: https://lore.kernel.org/netdev/[email protected]/
RFC V2: https://lore.kernel.org/netdev/[email protected]/
RFC V1: https://lore.kernel.org/netdev/[email protected]/
Maxime Chevallier (14):
dt-bindings: net: Introduce the ethernet-connector description
net: ethtool: Introduce ETHTOOL_LINK_MEDIUM_* values
net: phy: Introduce PHY ports representation
net: phy: dp83822: Add support for phy_port representation
dt-bindings: net: dp83822: Deprecate ti,fiber-mode
net: phy: Create a phy_port for PHY-driven SFPs
net: phy: Introduce generic SFP handling for PHY drivers
net: phy: marvell-88x2222: Support SFP through phy_port interface
net: phy: marvell: Support SFP through phy_port interface
net: phy: marvell10g: Support SFP through phy_port
net: phy: at803x: Support SFP through phy_port interface
net: phy: qca807x: Support SFP through phy_port interface
net: phy: Only rely on phy_port for PHY-driven SFP
Documentation: networking: Document the phy_port infrastructure
.../bindings/net/ethernet-connector.yaml | 56 +++ .../devicetree/bindings/net/ethernet-phy.yaml | 18 + .../devicetree/bindings/net/ti,dp83822.yaml | 9 +- Documentation/networking/index.rst | 1 + Documentation/networking/phy-port.rst | 111 ++++++ MAINTAINERS | 10 + drivers/net/phy/Makefile | 2 +- drivers/net/phy/dp83822.c | 71 ++-- drivers/net/phy/marvell-88x2222.c | 94 ++--- drivers/net/phy/marvell.c | 92 ++--- drivers/net/phy/marvell10g.c | 49 ++- drivers/net/phy/phy-caps.h | 5 + drivers/net/phy/phy-core.c | 6 + drivers/net/phy/phy_caps.c | 65 ++++ drivers/net/phy/phy_device.c | 345 +++++++++++++++++- drivers/net/phy/phy_port.c | 212 +++++++++++ drivers/net/phy/qcom/at803x.c | 77 ++-- drivers/net/phy/qcom/qca807x.c | 72 ++-- include/linux/ethtool.h | 36 +- include/linux/phy.h | 63 +++- include/linux/phy_port.h | 99 +++++ net/ethtool/common.c | 287 +++++++++------ 22 files changed, 1394 insertions(+), 386 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ethernet-connector.yaml create mode 100644 Documentation/networking/phy-port.rst create mode 100644 drivers/net/phy/phy_port.c create mode 100644 include/linux/phy_port.h
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 1/14 dt-bindings: net: Introduce the ethernet-connector description
The ability to describe the physical ports of Ethernet devices is useful to describe multi-port devices, as well as to remove any ambiguity with regard to the nature of the port.
Moreover, describing ports allows for a better description of features that are tied to connectors, such as PoE through the PSE-PD devices.
Introduce a binding to allow describing the ports, for now with 2 attributes :
- The number of pairs, which is a quite generic property that allows differentating between multiple similar technologies such as BaseT1 and "regular" BaseT (which usually means BaseT4).
- The media that can be used on that port, such as BaseT for Twisted Copper, BaseC for coax copper, BaseS/L for Fiber, BaseK for backplane ethernet, etc. This allows defining the nature of the port, and therefore avoids the need for vendor-specific properties such as "micrel,fiber-mode" or "ti,fiber-mode".
The port description lives in its own file, as it is intended in the future to allow describing the ports for phy-less devices.
--- .../bindings/net/ethernet-connector.yaml | 56 +++++++++++++++++++ .../devicetree/bindings/net/ethernet-phy.yaml | 18 ++++++ MAINTAINERS | 1 + 3 files changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ethernet-connector.yaml
Documentation/devicetree/bindings/net/ethernet-connector.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ethernet-connector.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic Ethernet Connector + +maintainers: + - Maxime Chevallier <[email protected]> + +description: + An Ethernet Connector represents the output of a network component such as + a PHY, an Ethernet controller with no PHY, or an SFP module. + +properties: + + pairs: + description: + Defines the number of BaseT pairs that are used on the connector. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 4] + + media: + description: + The mediums, as defined in 802.3, that can be used on the port. + enum: + - BaseT + - BaseK + - BaseS + - BaseC + - BaseL + - BaseD + - BaseE + - BaseF + - BaseV + - BaseMLD + +required: + - media + +allOf: + - if: + properties: + media: + const: BaseT + then: + required: + - pairs + else: + properties: + pairs: false + +additionalProperties: true + +...
Documentation/devicetree/bindings/net/ethernet-phy.yaml +18 -0
@@ -281,6 +281,17 @@ properties: additionalProperties: false + mdi: + type: object + + patternProperties: + '^connector-[0-9]+$': + $ref: /schemas/net/ethernet-connector.yaml# + + unevaluatedProperties: false + + additionalProperties: false + required: - reg
@@ -317,5 +328,12 @@ examples: default-state = "keep"; }; }; + /* Fast Ethernet port, with only 2 pairs wired */ + mdi { + connector-0 { + pairs = <2>; + media = "BaseT"; + }; + }; }; };
MAINTAINERS +1 -0
@@ -9394,6 +9394,7 @@ R: Russell King <[email protected]> L: [email protected] S: Maintained F: Documentation/ABI/testing/sysfs-class-net-phydev +F: Documentation/devicetree/bindings/net/ethernet-connector.yaml F: Documentation/devicetree/bindings/net/ethernet-phy.yaml F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml
Signature · 1 line
2.49.0
Re: [PATCH net-next v22 01/14] dt-bindings: net: Introduce the ethernet-connector description
Quoted 23 lines · Maxime Chevallier
The ability to describe the physical ports of Ethernet devices is useful to describe multi-port devices, as well as to remove any ambiguity with regard to the nature of the port.
Moreover, describing ports allows for a better description of features that are tied to connectors, such as PoE through the PSE-PD devices.
Introduce a binding to allow describing the ports, for now with 2 attributes :
- The number of pairs, which is a quite generic property that allows differentating between multiple similar technologies such as BaseT1 and "regular" BaseT (which usually means BaseT4).
- The media that can be used on that port, such as BaseT for Twisted Copper, BaseC for coax copper, BaseS/L for Fiber, BaseK for backplane ethernet, etc. This allows defining the nature of the port, and therefore avoids the need for vendor-specific properties such as "micrel,fiber-mode" or "ti,fiber-mode".
The port description lives in its own file, as it is intended in the future to allow describing the ports for phy-less devices.
Quoted 8 lines
Signed-off-by Maxime Chevallier <[email protected]>--- .../bindings/net/ethernet-connector.yaml | 56 +++++++++++++++++++ .../devicetree/bindings/net/ethernet-phy.yaml | 18 ++++++ MAINTAINERS | 1 + 3 files changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ethernet-connector.yaml
Maxime Chevallier
maintainerPATCH v22 2/14 net: ethtool: Introduce ETHTOOL_LINK_MEDIUM_* values
In reply to Maxime ChevallierIn an effort to have a better representation of Ethernet ports, introduce enumeration values representing the various ethernet Mediums.
This is part of the 802.3 naming convention, for example :
1000 Base T 4
| | | | | | | \_ pairs (4) | | \___ Medium (T == Twisted Copper Pairs) | \_______ Baseband transmission
\____________ Speed
Other example :
10000 Base K X 4
| | \_ lanes (4)
| \___ encoding (BaseX is 8b/10b while BaseR is 66b/64b)\_____ Medium (K is backplane ethernet)
In the case of representing a physical port, only the medium and number of pairs should be relevant. One exception would be 1000BaseX, which is currently also used as a medium in what appears to be any of 1000BaseSX, 1000BaseCX, 1000BaseLX, 1000BaseEX, 1000BaseBX10 and some other.
This was reflected in the mediums associated with the 1000BaseX linkmode.
These mediums are set in the net/ethtool/common.c lookup table that maintains a list of all linkmodes with their number of pairs, medium, encoding, speed and duplex.
One notable exception to this is 100BaseT Ethernet. It emcompasses 100BaseTX, which is a 2-pairs protocol but also 100BaseT4, that will also work on 4-pairs cables. As we don't make a disctinction between these, the lookup table contains 2 sets of pair numbers, indicating the min number of pairs for a protocol to work and the "nominal" number of pairs as well.
Another set of exceptions are linkmodes such 100000baseLR4_ER4, where the same link mode seems to represent 100GBaseLR4 and 100GBaseER4. The macro __DEFINE_LINK_MODE_PARAMS_MEDIUMS is here used to populate the .mediums bitfield with all appropriate mediums.
--- drivers/net/phy/phy_caps.c | 8 ++ include/linux/ethtool.h | 25 +++- net/ethtool/common.c | 260 +++++++++++++++++++++---------------- 3 files changed, 177 insertions(+), 116 deletions(-)
drivers/net/phy/phy_caps.c +8 -0
@@ -80,6 +80,14 @@ int __init phy_caps_init(void)/* Fill the caps array from net/ethtool/common.c */ for (i =0 ; i < __ETHTOOL_LINK_MODE_MASK_NBITS; i++) { linkmode = &link_mode_params[i]; + +/* Sanity check the linkmodes array for number of pairs */ +if (linkmode->pairs < linkmode->min_pairs) { +pr_err ("Pairs count must not be under min_pairs for linkmode %d\n" , + i); +return -EINVAL ; + } + capa =speed_duplex_to_capa (linkmode->speed, linkmode->duplex);if (capa <0 ) {
include/linux/ethtool.h +22 -3
@@ -216,13 +216,32 @@ static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx)void ethtool_rxfh_context_lost (struct net_device *dev,u32 context_id);struct link_mode_info { -int speed; -u8 lanes; -u8 duplex; +int speed; +u8 lanes; +u8 min_pairs; +u8 pairs; +u8 duplex; +u16 mediums; };extern const struct link_mode_info link_mode_params[]; +enum ethtool_link_medium { +ETHTOOL_LINK_MEDIUM_BASET =0 , +ETHTOOL_LINK_MEDIUM_BASEK , +ETHTOOL_LINK_MEDIUM_BASES , +ETHTOOL_LINK_MEDIUM_BASEC , +ETHTOOL_LINK_MEDIUM_BASEL , +ETHTOOL_LINK_MEDIUM_BASED , +ETHTOOL_LINK_MEDIUM_BASEE , +ETHTOOL_LINK_MEDIUM_BASEF , +ETHTOOL_LINK_MEDIUM_BASEV , +ETHTOOL_LINK_MEDIUM_BASEMLD , +ETHTOOL_LINK_MEDIUM_NONE , + + __ETHTOOL_LINK_MEDIUM_LAST, +}; +/* declare a link mode bitmap */ #define __ETHTOOL_DECLARE_LINK_MODE_MASK (name) \ DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
net/ethtool/common.c +147 -113
297 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH net-next v22 02/14] net: ethtool: Introduce ETHTOOL_LINK_MEDIUM_* values
Quoted 36 lines · Maxime Chevallier
In an effort to have a better representation of Ethernet ports, introduce enumeration values representing the various ethernet Mediums.
This is part of the 802.3 naming convention, for example :
1000 Base T 4
| | | | | | | \_ pairs (4) | | \___ Medium (T == Twisted Copper Pairs) | \_______ Baseband transmission\____________ Speed
Other example :
10000 Base K X 4
| | \_ lanes (4) | \___ encoding (BaseX is 8b/10b while BaseR is 66b/64b)\_____ Medium (K is backplane ethernet)
In the case of representing a physical port, only the medium and number of pairs should be relevant. One exception would be 1000BaseX, which is currently also used as a medium in what appears to be any of 1000BaseSX, 1000BaseCX, 1000BaseLX, 1000BaseEX, 1000BaseBX10 and some other.
This was reflected in the mediums associated with the 1000BaseX linkmode.
These mediums are set in the
net/ethtool/common.clookup table that maintains a list of all linkmodes with their number of pairs, medium, encoding, speed and duplex.One notable exception to this is 100BaseT Ethernet. It emcompasses 100BaseTX, which is a 2-pairs protocol but also 100BaseT4, that will also work on 4-pairs cables. As we don't make a disctinction between these, the lookup table contains 2 sets of pair numbers, indicating the min number of pairs for a protocol to work and the "nominal" number of pairs as well.
Quoted 7 lines
Another set of exceptions are linkmodes such 100000baseLR4_ER4, where the same link mode seems to represent 100GBaseLR4 and 100GBaseER4. The macro
__DEFINE_LINK_MODE_PARAMS_MEDIUMSis here used to populate the .mediums bitfield with all appropriate mediums.Reviewed-by Christophe Leroy <[email protected]>Signed-off-by Maxime Chevallier <[email protected]>
Andrew
Maxime Chevallier
maintainerPATCH v22 3/14 net: phy: Introduce PHY ports representation
In reply to Maxime ChevallierEthernet provides a wide variety of layer 1 protocols and standards for data transmission. The front-facing ports of an interface have their own complexity and configurability.
Introduce a representation of these front-facing ports. The current code is minimalistic and only support ports controlled by PHY devices, but the plan is to extend that to SFP as well as raw Ethernet MACs that don't use PHY devices.
This minimal port representation allows describing the media and number of pairs of a BaseT port. From that information, we can derive the linkmodes usable on the port, which can be used to limit the capabilities of an interface.
For now, the port pairs and medium is derived from devicetree, defined by the PHY driver, or populated with default values (as we assume that all PHYs expose at least one port).
The typical example is 100M ethernet. 100BaseTX works using only 2 pairs on a Cat 5 cables. However, in the situation where a 10/100/1000 capable PHY is wired to its RJ45 port through 2 pairs only, we have no way of detecting that. The "max-speed" DT property can be used, but a more accurate representation can be used :
mdi {
connector-0 {
media = "BaseT";
pairs = <2>;
};
};From that information, we can derive the max speed reachable on the port.
Another benefit of having that is to avoid vendor-specific DT properties (micrel,fiber-mode or ti,fiber-mode).
This basic representation is meant to be expanded, by the introduction of port ops, userspace listing of ports, and support for multi-port devices.
--- MAINTAINERS | 7 ++ drivers/net/phy/Makefile | 2 +- drivers/net/phy/phy-caps.h | 5 + drivers/net/phy/phy-core.c | 6 ++ drivers/net/phy/phy_caps.c | 57 +++++++++++ drivers/net/phy/phy_device.c | 192 +++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_port.c | 153 ++++++++++++++++++++++++++++ include/linux/ethtool.h | 11 ++ include/linux/phy.h | 55 ++++++++++ include/linux/phy_port.h | 96 ++++++++++++++++++ net/ethtool/common.c | 27 +++++ 11 files changed, 610 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/phy_port.c create mode 100644 include/linux/phy_port.h
MAINTAINERS +7 -0
@@ -18210,6 +18210,13 @@ F: drivers/net/phy/phy_link_topology.c F: include/linux/phy_link_topology.h F: net/ethtool/phy.c +NETWORKING [ETHTOOL PHY PORT] +M: Maxime Chevallier <[email protected]> +F: Documentation/devicetree/bindings/net/ethernet-connector.yaml +F: drivers/net/phy/phy_port.c +F: include/linux/phy_port.h +K: struct\s+phy_port|phy_port_ + NETWORKING [GENERAL] M: "David S. Miller" <[email protected]> M: Eric Dumazet <[email protected]>
drivers/net/phy/Makefile +1 -1
@@ -3,7 +3,7 @@ libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \ linkmode.o phy_link_topology.o \ - phy_caps.o mdio_bus_provider.o + phy_caps.o mdio_bus_provider.o phy_port.o mdio-bus-y += mdio_bus.o mdio_device.o ifdef CONFIG_PHYLIB
drivers/net/phy/phy-caps.h +5 -0
@@ -61,4 +61,9 @@ const struct link_capabilities * phy_caps_lookup(int speed, unsigned int duplex, const unsigned long *supported, bool exact); +void phy_caps_medium_get_supported (unsigned long *supported, +enum ethtool_link_medium medium, +int lanes); +u32 phy_caps_mediums_from_linkmodes (unsigned long *linkmodes); +#endif /* __PHY_CAPS_H */
drivers/net/phy/phy-core.c +6 -0
@@ -4,6 +4,7 @@*/ #include <linux/export.h> #include <linux/phy.h> +#include <linux/phy_port.h> #include <linux/of.h> #include "phylib.h"
@@ -208,7 +209,12 @@ EXPORT_SYMBOL_GPL(phy_interface_num_ports);static void __set_phy_supported (struct phy_device *phydev,u32 max_speed) { +struct phy_port *port; +phy_caps_linkmode_max_speed (max_speed, phydev->supported); + +phy_for_each_port (phydev, port) +phy_caps_linkmode_max_speed (max_speed, port->supported); }/**
drivers/net/phy/phy_caps.c +57 -0
60 lines not on this page · raw message
drivers/net/phy/phy_device.c +192 -0
228 lines not on this page · raw message
drivers/net/phy/phy_port.c new file +153 -0
153 lines not on this page · raw message
include/linux/ethtool.h +11 -0
@@ -242,6 +242,17 @@ enum ethtool_link_medium { __ETHTOOL_LINK_MEDIUM_LAST, }; +#define ETHTOOL_MEDIUM_FIBER_BITS (BIT(ETHTOOL_LINK_MEDIUM_BASES) | \ + BIT(ETHTOOL_LINK_MEDIUM_BASEL) | \ + BIT(ETHTOOL_LINK_MEDIUM_BASEF)) + +enum ethtool_link_medium ethtool_str_to_medium (const char *str); + +static inline int ethtool_linkmode_n_pairs (unsigned int mode) +{ +return link_mode_params[mode].pairs; +} +/* declare a link mode bitmap */ #define __ETHTOOL_DECLARE_LINK_MODE_MASK (name) \ DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
include/linux/phy.h +55 -0
91 lines not on this page · raw message
include/linux/phy_port.h new file +96 -0
96 lines not on this page · raw message
net/ethtool/common.c +27 -0
@@ -468,6 +468,21 @@ const struct link_mode_info link_mode_params[] = {static_assert (ARRAY_SIZE (link_mode_params) == __ETHTOOL_LINK_MODE_MASK_NBITS);EXPORT_SYMBOL_GPL (link_mode_params); +static const char ethtool_link_medium_names[][ETH_GSTRING_LEN ] = { + [ETHTOOL_LINK_MEDIUM_BASET ] ="BaseT" , + [ETHTOOL_LINK_MEDIUM_BASEK ] ="BaseK" , + [ETHTOOL_LINK_MEDIUM_BASES ] ="BaseS" , + [ETHTOOL_LINK_MEDIUM_BASEC ] ="BaseC" , + [ETHTOOL_LINK_MEDIUM_BASEL ] ="BaseL" , + [ETHTOOL_LINK_MEDIUM_BASED ] ="BaseD" , + [ETHTOOL_LINK_MEDIUM_BASEE ] ="BaseE" , + [ETHTOOL_LINK_MEDIUM_BASEF ] ="BaseF" , + [ETHTOOL_LINK_MEDIUM_BASEV ] ="BaseV" , + [ETHTOOL_LINK_MEDIUM_BASEMLD ] ="BaseMLD" , + [ETHTOOL_LINK_MEDIUM_NONE ] ="None" , +}; +static_assert (ARRAY_SIZE (ethtool_link_medium_names) == __ETHTOOL_LINK_MEDIUM_LAST); +const char netif_msg_class_names[][ETH_GSTRING_LEN ] = { [NETIF_MSG_DRV_BIT ] ="drv" , [NETIF_MSG_PROBE_BIT ] ="probe" ,
@@ -1201,3 +1216,15 @@ void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id)ethtool_rss_notify (dev,ETHTOOL_MSG_RSS_DELETE_NTF , context_id); }EXPORT_SYMBOL (ethtool_rxfh_context_lost); + +enum ethtool_link_medium ethtool_str_to_medium (const char *str) +{ +int i; + +for (i =0 ; i < __ETHTOOL_LINK_MEDIUM_LAST; i++) +if (!strcmp (ethtool_link_medium_names[i], str)) +return i; + +return ETHTOOL_LINK_MEDIUM_NONE ; +} +EXPORT_SYMBOL_GPL (ethtool_str_to_medium);
Signature · 1 line
2.49.0
Quoted 37 lines · Maxime Chevallier
Ethernet provides a wide variety of layer 1 protocols and standards for data transmission. The front-facing ports of an interface have their own complexity and configurability.
Introduce a representation of these front-facing ports. The current code is minimalistic and only support ports controlled by PHY devices, but the plan is to extend that to SFP as well as raw Ethernet MACs that don't use PHY devices.
This minimal port representation allows describing the media and number of pairs of a BaseT port. From that information, we can derive the linkmodes usable on the port, which can be used to limit the capabilities of an interface.
For now, the port pairs and medium is derived from devicetree, defined by the PHY driver, or populated with default values (as we assume that all PHYs expose at least one port).
The typical example is 100M ethernet. 100BaseTX works using only 2 pairs on a Cat 5 cables. However, in the situation where a 10/100/1000 capable PHY is wired to its RJ45 port through 2 pairs only, we have no way of detecting that. The "max-speed" DT property can be used, but a more accurate representation can be used :
mdi { connector-0 { media = "BaseT"; pairs = <2>; }; };Quoted 1 line
From that information, we can derive the max speed reachable on the
port.
Another benefit of having that is to avoid vendor-specific DT properties (micrel,fiber-mode or ti,fiber-mode).
Quoted 6 lines
This basic representation is meant to be expanded, by the introduction of port ops, userspace listing of ports, and support for multi-port devices.
Reviewed-by Christophe Leroy <[email protected]>Signed-off-by Maxime Chevallier <[email protected]>
Andrew
Maxime Chevallier
maintainerPATCH v22 4/14 net: phy: dp83822: Add support for phy_port representation
In reply to Maxime ChevallierWith the phy_port representation introduced, we can use .attach_port to populate the port information based on either the straps or the ti,fiber-mode property. This allows simplifying the probe function and allow users to override the strapping configuration.
--- drivers/net/phy/dp83822.c | 71 +++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 26 deletions(-)
drivers/net/phy/dp83822.c +45 -26
@@ -11,6 +11,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/phy.h> +#include <linux/phy_port.h> #include <linux/netdevice.h> #include <linux/bitfield.h>
@@ -811,17 +812,6 @@ static int dp83822_of_init(struct phy_device *phydev)int i, ret;u32 val; -/* Signal detection for the PHY is only enabled if the FX_EN and the -* SD_EN pins are strapped. Signal detection can only enabled if FX_EN -* is strapped otherwise signal detection is disabled for the PHY. -*/ -if (dp83822->fx_enabled && dp83822->fx_sd_enable) - dp83822->fx_signal_det_low =device_property_present (dev, -"ti,link-loss-low" ); -if (!dp83822->fx_enabled) - dp83822->fx_enabled =device_property_present (dev, -"ti,fiber-mode" ); -if (!device_property_read_string (dev,"ti,gpio2-clk-out" , &of_val)) {if (strcmp (of_val,"mac-if" ) ==0 ) { dp83822->gpio2_clk_out =DP83822_CLK_SRC_MAC_IF ;
@@ -950,6 +940,48 @@ static int dp83822_read_straps(struct phy_device *phydev)return 0 ; } +static int dp83822_attach_mdi_port (struct phy_device *phydev, +struct phy_port *port) +{ +struct dp83822_private *dp83822 = phydev->priv; +int ret; + +if (port->mediums) { +if (phy_port_is_fiber (port)) + dp83822->fx_enabled = true; + }else { + ret =dp83822_read_straps (phydev); +if (ret) +return ret; + +#if IS_ENABLED (CONFIG_OF_MDIO ) +if (dp83822->fx_enabled && dp83822->fx_sd_enable) + dp83822->fx_signal_det_low = +device_property_present (&phydev->mdio.dev, +"ti,link-loss-low" ); + +/* ti,fiber-mode is still used for backwards compatibility, but +* has been replaced with the mdi node definition, see +* ethernet-port.yaml +*/ +if (!dp83822->fx_enabled) + dp83822->fx_enabled = +device_property_present (&phydev->mdio.dev, +"ti,fiber-mode" ); +#endif /* CONFIG_OF_MDIO */ + +if (dp83822->fx_enabled) { + port->mediums =BIT (ETHTOOL_LINK_MEDIUM_BASEF ); + }else { +/* This PHY can only to 100BaseTX max, so on 2 pairs */ + port->pairs =2 ; + port->mediums =BIT (ETHTOOL_LINK_MEDIUM_BASET ); + } + } + +return 0 ; +} +static int dp8382x_probe (struct phy_device *phydev) {struct dp83822_private *dp83822;
@@ -968,27 +1000,13 @@ static int dp8382x_probe(struct phy_device *phydev)static int dp83822_probe (struct phy_device *phydev) { -struct dp83822_private *dp83822;int ret; ret =dp8382x_probe (phydev);if (ret)return ret; - dp83822 = phydev->priv; - - ret =dp83822_read_straps (phydev); -if (ret) -return ret; - - ret =dp83822_of_init (phydev); -if (ret) -return ret; - -if (dp83822->fx_enabled) - phydev->port =PORT_FIBRE ; - -return 0 ; +return dp83822_of_init (phydev); }static int dp83826_probe (struct phy_device *phydev)
@@ -1172,6 +1190,7 @@ static int dp83822_led_hw_control_get(struct phy_device *phydev, u8 index, .led_hw_is_supported = dp83822_led_hw_is_supported, \ .led_hw_control_set = dp83822_led_hw_control_set, \ .led_hw_control_get = dp83822_led_hw_control_get, \ + .attach_mdi_port = dp83822_attach_mdi_port \ }#define DP83825_PHY_DRIVER (_id, _name) \
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 5/14 dt-bindings: net: dp83822: Deprecate ti,fiber-mode
In reply to Maxime ChevallierThe newly added ethernet-connector binding allows describing an Ethernet connector with greater precision, and in a more generic manner, than ti,fiber-mode. Deprecate this property.
--- Documentation/devicetree/bindings/net/ti,dp83822.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/ti,dp83822.yaml +8 -1
@@ -47,6 +47,9 @@ properties: is disabled. In fiber mode, auto-negotiation is disabled and the PHY can only work in 100base-fx (full and half duplex) modes. + This property is deprecated, for details please refer to + Documentation/devicetree/bindings/net/ethernet-connector.yaml + deprecated: true rx-internal-delay-ps: description: |
@@ -141,7 +144,11 @@ examples: tx-internal-delay-ps = <1>; ti,gpio2-clk-out = "xi"; mac-termination-ohms = <43>; + mdi { + connector-0 { + media = "BaseF"; + }; + }; }; }; - ...
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 6/14 net: phy: Create a phy_port for PHY-driven SFPs
In reply to Maxime ChevallierSome PHY devices may be used as media-converters to drive SFP ports (for example, to allow using SFP when the SoC can only output RGMII). This is already supported to some extend by allowing PHY drivers to registers themselves as being SFP upstream.
However, the logic to drive the SFP can actually be split to a per-port control logic, allowing support for multi-port PHYs, or PHYs that can either drive SFPs or Copper.
To that extent, create a phy_port when registering an SFP bus onto a PHY. This port is considered a "serdes" port, in that it can feed data to another entity on the link. The PHY driver needs to specify the various PHY_INTERFACE_MODE_XXX that this port supports.
--- drivers/net/phy/phy_device.c | 30 ++++++++++++++++++++++++++++++ drivers/net/phy/phy_port.c | 15 +++++++++++++++ 2 files changed, 45 insertions(+)
drivers/net/phy/phy_device.c +30 -0
@@ -1643,6 +1643,32 @@ static void phy_del_port(struct phy_device *phydev, struct phy_port *port) phydev->n_ports--; } +static int phy_setup_sfp_port (struct phy_device *phydev) +{ +struct phy_port *port =phy_port_alloc (); +int ret; + +if (!port) +return -ENOMEM ; + + port->parent_type =PHY_PORT_PHY ; + port->phy = phydev; + +/* The PHY is a media converter, the port connected to the SFP cage +* is a MII port. +*/ + port->is_mii = true; + +/* The port->supported and port->interfaces list will be populated +* when attaching the port to the phydev. +*/ + ret =phy_add_port (phydev, port); +if (ret) +phy_port_destroy (port); + +return ret; +} +/** * phy_sfp_probe - probe for a SFP cage attached to this PHY device * @phydev: Pointer to phy_device
@@ -1664,6 +1690,10 @@ int phy_sfp_probe(struct phy_device *phydev, ret =sfp_bus_add_upstream (bus, phydev, ops);sfp_bus_put (bus); } + +if (!ret && phydev->sfp_bus) + ret =phy_setup_sfp_port (phydev); +return ret; }EXPORT_SYMBOL (phy_sfp_probe);
drivers/net/phy/phy_port.c +15 -0
@@ -131,6 +131,21 @@ void phy_port_update_supported(struct phy_port *port) __ETHTOOL_LINK_MODE_MASK_NBITS) port->pairs = max_t(int, port->pairs,ethtool_linkmode_n_pairs (mode)); + +/* Serdes ports supported through SFP may not have any medium set, +* as they will output PHY_INTERFACE_MODE_XXX modes. In that case, derive +* the supported list based on these interfaces +*/ +if (port->is_mii && !port->mediums) { +unsigned long interface, link_caps =0 ; + +/* Get each interface's caps */ +for_each_set_bit (interface, port->interfaces, +PHY_INTERFACE_MODE_MAX ) + link_caps |=phy_caps_from_interface (interface); + +phy_caps_linkmodes (link_caps, port->supported); + } }EXPORT_SYMBOL_GPL (phy_port_update_supported);
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 7/14 net: phy: Introduce generic SFP handling for PHY drivers
In reply to Maxime ChevallierThere are currently 4 PHY drivers that can drive downstream SFPs:marvell.c, marvell10g.c, at803x.c and marvell-88x2222.c. Most of the logic is boilerplate, either calling into generic phylib helpers (for SFP PHY attach, bus attach, etc.) or performing the same tasks with a bit of validation :
- Getting the module's expected interface mode
- Making sure the PHY supports it
- Optionaly perform some configuration to make sure the PHY outputs the right mode
This can be made more generic by leveraging the phy_port, and its configure_mii() callback which allows setting a port's interfaces when the port is a serdes.
Introduce a generic PHY SFP support. If a driver doesn't probe the SFP bus itself, but an SFP phandle is found in devicetree/firmware, then the generic PHY SFP support will be used, relying on port ops.
PHY driver need to :
- Register a .attach_port() callback
- When a serdes port is registered to the PHY, drivers must set port->interfaces to the set of PHY_INTERFACE_MODE the port can output
- If the port has limitations regarding speed, duplex and aneg, the port can also fine-tune the final linkmodes that can be supported
- The port may register a set of ops, including .configure_mii(), that will be called at module_insert time to adjust the interface based on the module detected.
--- drivers/net/phy/phy_device.c | 107 +++++++++++++++++++++++++++++++++++ include/linux/phy.h | 2 + include/linux/phy_port.h | 2 + 3 files changed, 111 insertions(+)
drivers/net/phy/phy_device.c +107 -0
@@ -1598,6 +1598,86 @@ void phy_sfp_detach(void *upstream, struct sfp_bus *bus) }EXPORT_SYMBOL (phy_sfp_detach); +static int phy_sfp_module_insert (void *upstream,const struct sfp_eeprom_id *id) +{ +__ETHTOOL_DECLARE_LINK_MODE_MASK (sfp_support); +struct phy_device *phydev = upstream; +const struct sfp_module_caps *caps; +struct phy_port *port; + +phy_interface_t iface; + +linkmode_zero (sfp_support); + + port =phy_get_sfp_port (phydev); +if (!port) +return -EINVAL ; + + caps =sfp_get_module_caps (phydev->sfp_bus); + +linkmode_and (sfp_support, port->supported, caps->link_modes); +if (linkmode_empty (sfp_support)) { +dev_err (&phydev->mdio.dev,"incompatible SFP module inserted, no common linkmode\n" ); +return -EINVAL ; + } + + iface =sfp_select_interface (phydev->sfp_bus, sfp_support); +if (iface ==PHY_INTERFACE_MODE_NA ) { +dev_err (&phydev->mdio.dev,"PHY %s does not support the SFP module's requested MII interfaces\n" , +phydev_name (phydev)); +return -EINVAL ; + } + +if (phydev->n_ports ==1 ) + phydev->port = caps->port; + +if (port->ops && port->ops->configure_mii) +return port->ops->configure_mii (port, true, iface); + +return 0 ; +} + +static void phy_sfp_module_remove (void *upstream) +{ +struct phy_device *phydev = upstream; +struct phy_port *port =phy_get_sfp_port (phydev); + +if (port && port->ops && port->ops->configure_mii) + port->ops->configure_mii (port, false,PHY_INTERFACE_MODE_NA ); + +if (phydev->n_ports ==1 ) + phydev->port =PORT_NONE ; +} + +static void phy_sfp_link_up (void *upstream) +{ +struct phy_device *phydev = upstream; +struct phy_port *port =phy_get_sfp_port (phydev); + +if (port && port->ops && port->ops->link_up) + port->ops->link_up (port); +} + +static void phy_sfp_link_down (void *upstream) +{ +struct phy_device *phydev = upstream; +struct phy_port *port =phy_get_sfp_port (phydev); + +if (port && port->ops && port->ops->link_down) + port->ops->link_down (port); +} + +static const struct sfp_upstream_ops sfp_phydev_ops = { + .attach = phy_sfp_attach, + .detach = phy_sfp_detach, + .module_insert = phy_sfp_module_insert, + .module_remove = phy_sfp_module_remove, + .link_up = phy_sfp_link_up, + .link_down = phy_sfp_link_down, + .connect_phy = phy_sfp_connect_phy, + .disconnect_phy = phy_sfp_disconnect_phy, +}; +static int phy_add_port (struct phy_device *phydev,struct phy_port *port) {int ret =0 ;
@@ -1658,6 +1738,7 @@ static int phy_setup_sfp_port(struct phy_device *phydev)* is a MII port. */ port->is_mii = true; + port->is_sfp = true;/* The port->supported and port->interfaces list will be populated * when attaching the port to the phydev.
@@ -3505,6 +3586,13 @@ static int phy_setup_ports(struct phy_device *phydev)if (ret)return ret; +/* Use generic SFP probing only if the driver didn't do so already */ +if (!phydev->sfp_bus) { + ret =phy_sfp_probe (phydev, &sfp_phydev_ops); +if (ret) + goto out; + } +if (phydev->n_ports < phydev->max_n_ports) { ret =phy_default_setup_single_port (phydev);if (ret)
@@ -3540,6 +3628,25 @@ static int phy_setup_ports(struct phy_device *phydev)return ret; } +/** +* phy_get_sfp_port() - Returns the first valid SFP port of a PHY +* @phydev: pointer to the PHY device to get the SFP port from +* +* Returns: The first active SFP (serdes) port of a PHY device, NULL if none +* exist. +*/ +struct phy_port *phy_get_sfp_port (struct phy_device *phydev) +{ +struct phy_port *port; + +list_for_each_entry (port, &phydev->ports, head) +if (port->active && port->is_sfp) +return port; + +return NULL ; +} +EXPORT_SYMBOL_GPL (phy_get_sfp_port); +/** * fwnode_mdio_find_device - Given a fwnode, find the mdio_device * @fwnode: pointer to the mdio_device's fwnode
include/linux/phy.h +2 -0
@@ -2455,6 +2455,8 @@ int __phy_hwtstamp_set(struct phy_device *phydev,struct kernel_hwtstamp_config *config, struct netlink_ext_ack *extack); +struct phy_port *phy_get_sfp_port (struct phy_device *phydev); +extern const struct bus_type mdio_bus_type;extern const struct class mdio_bus_class;
include/linux/phy_port.h +2 -0
@@ -49,6 +49,7 @@ struct phy_port_ops {* @active: Indicates if the port is currently part of the active link. * @is_mii: Indicates if this port is MII (Media Independent Interface), * or MDI (Media Dependent Interface). +* @is_sfp: Indicates if this port drives an SFP cage. */ struct phy_port {struct list_head head;
@@ -67,6 +68,7 @@ struct phy_port { unsigned int not_described:1; unsigned int active:1; unsigned int is_mii:1; + unsigned int is_sfp:1; };struct phy_port *phy_port_alloc (void );
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 8/14 net: phy: marvell-88x2222: Support SFP through phy_port interface
In reply to Maxime ChevallierThe 88x2222 PHY from Marvell only supports serialised modes as its line-facing interfaces. Convert that driver to the generic phylib SFP handling.
--- drivers/net/phy/marvell-88x2222.c | 94 +++++++++++++------------------ 1 file changed, 38 insertions(+), 56 deletions(-)
drivers/net/phy/marvell-88x2222.c +38 -56
@@ -13,7 +13,7 @@#include <linux/mdio.h> #include <linux/marvell_phy.h> #include <linux/of.h> -#include <linux/sfp.h> +#include <linux/phy_port.h> #include <linux/netdevice.h> /* Port PCS Configuration */
@@ -473,89 +473,70 @@ static int mv2222_config_init(struct phy_device *phydev)return 0 ; } -static int mv2222_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) +static int mv2222_configure_serdes (struct phy_port *port,bool enable, +phy_interface_t interface) { -struct phy_device *phydev = upstream; -const struct sfp_module_caps *caps; -phy_interface_t sfp_interface; +struct phy_device *phydev =port_phydev (port);struct mv2222_data *priv; -struct device *dev; -int ret; +int ret =0 ; priv = phydev->priv; - dev = &phydev->mdio.dev; - - caps =sfp_get_module_caps (phydev->sfp_bus); - - phydev->port = caps->port; - sfp_interface =sfp_select_interface (phydev->sfp_bus, caps->link_modes); - -dev_info (dev,"%s SFP module inserted\n" ,phy_modes (sfp_interface)); + priv->line_interface = interface; -if (sfp_interface !=PHY_INTERFACE_MODE_10GBASER && - sfp_interface !=PHY_INTERFACE_MODE_1000BASEX && - sfp_interface !=PHY_INTERFACE_MODE_SGMII ) { -dev_err (dev,"Incompatible SFP module inserted\n" ); +if (enable) { +linkmode_and (priv->supported, phydev->supported, port->supported); -return -EINVAL ; - } - - priv->line_interface = sfp_interface; -linkmode_and (priv->supported, phydev->supported, caps->link_modes); + ret =mv2222_config_line (phydev); +if (ret <0 ) +return ret; - ret =mv2222_config_line (phydev); -if (ret <0 ) -return ret; +if (mutex_trylock (&phydev->lock)) { + ret =mv2222_config_aneg (phydev); +mutex_unlock (&phydev->lock); + } -if (mutex_trylock (&phydev->lock)) { - ret =mv2222_config_aneg (phydev); -mutex_unlock (&phydev->lock); + }else { +linkmode_zero (priv->supported); }return ret; } -static void mv2222_sfp_remove (void *upstream) +static void mv2222_port_link_up (struct phy_port *port) { -struct phy_device *phydev = upstream; -struct mv2222_data *priv; - - priv = phydev->priv; - - priv->line_interface =PHY_INTERFACE_MODE_NA ; -linkmode_zero (priv->supported); - phydev->port =PORT_NONE ; -} - -static void mv2222_sfp_link_up (void *upstream) -{ -struct phy_device *phydev = upstream; +struct phy_device *phydev =port_phydev (port);struct mv2222_data *priv; priv = phydev->priv; priv->sfp_link = true; } -static void mv2222_sfp_link_down (void *upstream) +static void mv2222_port_link_down (struct phy_port *port) { -struct phy_device *phydev = upstream; +struct phy_device *phydev =port_phydev (port);struct mv2222_data *priv; priv = phydev->priv; priv->sfp_link = false; } -static const struct sfp_upstream_ops sfp_phy_ops = { - .module_insert = mv2222_sfp_insert, - .module_remove = mv2222_sfp_remove, - .link_up = mv2222_sfp_link_up, - .link_down = mv2222_sfp_link_down, - .attach = phy_sfp_attach, - .detach = phy_sfp_detach, - .connect_phy = phy_sfp_connect_phy, - .disconnect_phy = phy_sfp_disconnect_phy, +static const struct phy_port_ops mv2222_port_ops = { + .link_up = mv2222_port_link_up, + .link_down = mv2222_port_link_down, + .configure_mii = mv2222_configure_serdes, }; +static int mv2222_attach_mii_port (struct phy_device *phydev,struct phy_port *port) +{ + port->ops = &mv2222_port_ops; + +__set_bit (PHY_INTERFACE_MODE_10GBASER , port->interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , port->interfaces); +__set_bit (PHY_INTERFACE_MODE_SGMII , port->interfaces); + +return 0 ; +} +static int mv2222_probe (struct phy_device *phydev) {struct device *dev = &phydev->mdio.dev;
@@ -591,7 +572,7 @@ static int mv2222_probe(struct phy_device *phydev) priv->line_interface =PHY_INTERFACE_MODE_NA ; phydev->priv = priv; -return phy_sfp_probe (phydev, &sfp_phy_ops); +return 0 ; }static struct phy_driver mv2222_drivers[] = {
@@ -608,6 +589,7 @@ static struct phy_driver mv2222_drivers[] = { .suspend = mv2222_suspend, .resume = mv2222_resume, .read_status = mv2222_read_status, + .attach_mii_port = mv2222_attach_mii_port, }, };module_phy_driver (mv2222_drivers);
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 9/14 net: phy: marvell: Support SFP through phy_port interface
In reply to Maxime ChevallierConvert the Marvell driver (especially the 88e1512 driver) to use the phy_port interface to handle SFPs. This means registering a .attach_port() handler to detect when a serdes line interface is used (most likely, and SFP module).
--- drivers/net/phy/marvell.c | 92 ++++++++++++++------------------------- 1 file changed, 32 insertions(+), 60 deletions(-)
drivers/net/phy/marvell.c +32 -60
@@ -29,10 +29,10 @@#include <linux/ethtool.h> #include <linux/ethtool_netlink.h> #include <linux/phy.h> +#include <linux/phy_port.h> #include <linux/marvell_phy.h> #include <linux/bitfield.h> #include <linux/of.h> -#include <linux/sfp.h> #include <linux/io.h> #include <asm/irq.h>
@@ -3598,11 +3598,10 @@ static int marvell_probe(struct phy_device *phydev)return marvell_hwmon_probe (phydev); } -static int m88e1510_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) +static int m88e1510_port_configure_serdes (struct phy_port *port,bool enable, +phy_interface_t interface) { -struct phy_device *phydev = upstream; -const struct sfp_module_caps *caps; -phy_interface_t interface; +struct phy_device *phydev =port_phydev (port);struct device *dev;int oldpage;int ret =0 ;
@@ -3610,28 +3609,27 @@ static int m88e1510_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) dev = &phydev->mdio.dev; - caps =sfp_get_module_caps (phydev->sfp_bus); - interface =sfp_select_interface (phydev->sfp_bus, caps->link_modes); +if (enable) { +switch (interface) { +case PHY_INTERFACE_MODE_1000BASEX : + mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_1000X ; -dev_info (dev,"%s SFP module inserted\n" ,phy_modes (interface)); +break ; +case PHY_INTERFACE_MODE_100BASEX : + mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_100FX ; -switch (interface) { -case PHY_INTERFACE_MODE_1000BASEX : - mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_1000X ; +break ; +case PHY_INTERFACE_MODE_SGMII : + mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_SGMII ; -break ; -case PHY_INTERFACE_MODE_100BASEX : - mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_100FX ; - -break ; -case PHY_INTERFACE_MODE_SGMII : - mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_SGMII ; +break ; +default : +dev_err (dev,"Incompatible SFP module inserted\n" ); -break ; -default : -dev_err (dev,"Incompatible SFP module inserted\n" ); - -return -EINVAL ; +return -EINVAL ; + } + }else { + mode =MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII ; } oldpage =phy_select_page (phydev,MII_MARVELL_MODE_PAGE );
@@ -3650,47 +3648,20 @@ static int m88e1510_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)return phy_restore_page (phydev, oldpage, ret); } -static void m88e1510_sfp_remove (void *upstream) -{ -struct phy_device *phydev = upstream; -int oldpage; -int ret =0 ; - - oldpage =phy_select_page (phydev,MII_MARVELL_MODE_PAGE ); -if (oldpage <0 ) - goto error; - - ret =__phy_modify (phydev,MII_88E1510_GEN_CTRL_REG_1 , -MII_88E1510_GEN_CTRL_REG_1_MODE_MASK , -MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII ); -if (ret <0 ) - goto error; - - ret =__phy_set_bits (phydev,MII_88E1510_GEN_CTRL_REG_1 , -MII_88E1510_GEN_CTRL_REG_1_RESET ); - -error: -phy_restore_page (phydev, oldpage, ret); -} - -static const struct sfp_upstream_ops m88e1510_sfp_ops = { - .module_insert = m88e1510_sfp_insert, - .module_remove = m88e1510_sfp_remove, - .attach = phy_sfp_attach, - .detach = phy_sfp_detach, - .connect_phy = phy_sfp_connect_phy, - .disconnect_phy = phy_sfp_disconnect_phy, +static const struct phy_port_ops m88e1510_serdes_port_ops = { + .configure_mii = m88e1510_port_configure_serdes, }; -static int m88e1510_probe (struct phy_device *phydev) +static int m88e1510_attach_mii_port (struct phy_device *phy_device, +struct phy_port *port) { -int err; + port->ops = &m88e1510_serdes_port_ops; - err =marvell_probe (phydev); -if (err) -return err; +__set_bit (PHY_INTERFACE_MODE_SGMII , port->interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , port->interfaces); +__set_bit (PHY_INTERFACE_MODE_100BASEX , port->interfaces); -return phy_sfp_probe (phydev, &m88e1510_sfp_ops); +return 0 ; }static struct phy_driver marvell_drivers[] = {
@@ -3950,7 +3921,7 @@ static struct phy_driver marvell_drivers[] = { .driver_data = DEF_MARVELL_HWMON_OPS(m88e1510_hwmon_ops), .features = PHY_GBIT_FIBRE_FEATURES, .flags = PHY_POLL_CABLE_TEST, - .probe = m88e1510_probe, + .probe = marvell_probe, .config_init = m88e1510_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status,
@@ -3976,6 +3947,7 @@ static struct phy_driver marvell_drivers[] = { .led_hw_is_supported = m88e1318_led_hw_is_supported, .led_hw_control_set = m88e1318_led_hw_control_set, .led_hw_control_get = m88e1318_led_hw_control_get, + .attach_mii_port = m88e1510_attach_mii_port, }, { .phy_id = MARVELL_PHY_ID_88E1540,
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 10/14 net: phy: marvell10g: Support SFP through phy_port
In reply to Maxime ChevallierConvert the Marvell10G driver to use the generic SFP handling, through a dedicated .attach_port() handler to populate the port's supported interfaces.
As the 88x3310 supports multiple MDI, the .attach_port() logic handles both SFP attach with 10GBaseR support, and support for the "regular" port that usually is a BaseT port.
--- drivers/net/phy/marvell10g.c | 49 +++++++++++++++++++++--------------- drivers/net/phy/phy_port.c | 44 ++++++++++++++++++++++++++++++++ include/linux/phy_port.h | 1 + 3 files changed, 74 insertions(+), 20 deletions(-)
drivers/net/phy/marvell10g.c +29 -20
@@ -28,7 +28,7 @@#include <linux/hwmon.h> #include <linux/marvell_phy.h> #include <linux/phy.h> -#include <linux/sfp.h> +#include <linux/phy_port.h> #include <linux/netdevice.h> #define MV_PHY_ALASKA_NBT_QUIRK_MASK 0xfffffffe
@@ -463,30 +463,29 @@ static int mv3310_set_edpd(struct phy_device *phydev, u16 edpd)return err; } -static int mv3310_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) +static int mv3310_attach_mii_port (struct phy_device *phydev, +struct phy_port *port) { -struct phy_device *phydev = upstream; -const struct sfp_module_caps *caps; -phy_interface_t iface; +__set_bit (PHY_INTERFACE_MODE_10GBASER , port->interfaces); +return 0 ; +} - caps =sfp_get_module_caps (phydev->sfp_bus); - iface =sfp_select_interface (phydev->sfp_bus, caps->link_modes); +static int mv3310_attach_mdi_port (struct phy_device *phydev, +struct phy_port *port) +{ +/* This PHY can do combo-ports, i.e. 2 MDI outputs, usually one +* of them going to an SFP and the other one to a RJ45 +* connector. If we don't have any representation for the port +* in DT, and we are dealing with a non-SFP port, then we +* mask the port's capabilities to report BaseT-only modes +*/ +if (port->not_described) +return phy_port_restrict_mediums (port, +BIT (ETHTOOL_LINK_MEDIUM_BASET )); -if (iface !=PHY_INTERFACE_MODE_10GBASER ) { -dev_err (&phydev->mdio.dev,"incompatible SFP module inserted\n" ); -return -EINVAL ; - }return 0 ; } -static const struct sfp_upstream_ops mv3310_sfp_ops = { - .attach = phy_sfp_attach, - .detach = phy_sfp_detach, - .connect_phy = phy_sfp_connect_phy, - .disconnect_phy = phy_sfp_disconnect_phy, - .module_insert = mv3310_sfp_insert, -}; -static int mv3310_probe (struct phy_device *phydev) {const struct mv3310_chip *chip =to_mv3310_chip (phydev);
@@ -544,7 +543,9 @@ static int mv3310_probe(struct phy_device *phydev) chip->init_supported_interfaces (priv->supported_interfaces); -return phy_sfp_probe (phydev, &mv3310_sfp_ops); + phydev->max_n_ports =2 ; + +return 0 ; }static void mv3310_remove (struct phy_device *phydev)
@@ -1405,6 +1406,8 @@ static struct phy_driver mv3310_drivers[] = { .set_loopback = genphy_c45_loopback, .get_wol = mv3110_get_wol, .set_wol = mv3110_set_wol, + .attach_mii_port = mv3310_attach_mii_port, + .attach_mdi_port = mv3310_attach_mdi_port, }, { .phy_id = MARVELL_PHY_ID_88X3310,
@@ -1424,6 +1427,8 @@ static struct phy_driver mv3310_drivers[] = { .set_tunable = mv3310_set_tunable, .remove = mv3310_remove, .set_loopback = genphy_c45_loopback, + .attach_mii_port = mv3310_attach_mii_port, + .attach_mdi_port = mv3310_attach_mdi_port, }, { .phy_id = MARVELL_PHY_ID_88E2110,
@@ -1444,6 +1449,8 @@ static struct phy_driver mv3310_drivers[] = { .set_loopback = genphy_c45_loopback, .get_wol = mv3110_get_wol, .set_wol = mv3110_set_wol, + .attach_mii_port = mv3310_attach_mii_port, + .attach_mdi_port = mv3310_attach_mdi_port, }, { .phy_id = MARVELL_PHY_ID_88E2110,
@@ -1462,6 +1469,8 @@ static struct phy_driver mv3310_drivers[] = { .set_tunable = mv3310_set_tunable, .remove = mv3310_remove, .set_loopback = genphy_c45_loopback, + .attach_mii_port = mv3310_attach_mii_port, + .attach_mdi_port = mv3310_attach_mdi_port, }, };
drivers/net/phy/phy_port.c +44 -0
50 lines not on this page · raw message
include/linux/phy_port.h +1 -0
@@ -92,6 +92,7 @@ static inline bool phy_port_is_fiber(struct phy_port *port) }void phy_port_update_supported (struct phy_port *port); +int phy_port_restrict_mediums (struct phy_port *port,unsigned long mediums);int phy_port_get_type (struct phy_port *port);
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 11/14 net: phy: at803x: Support SFP through phy_port interface
In reply to Maxime ChevallierConvert the at803x driver to use the generic phylib SFP handling, via a dedicated .attach_port() callback, populating the supported interfaces.
As these devices are limited to 1000BaseX, a workaround is used to also support, in a very limited way, copper modules. This is done by supporting SGMII but limiting it to 1G full duplex (in which case it's somewhat compatible with 1000BaseX).
--- drivers/net/phy/qcom/at803x.c | 77 +++++++++++++++-------------------- 1 file changed, 32 insertions(+), 45 deletions(-)
drivers/net/phy/qcom/at803x.c +32 -45
@@ -20,7 +20,7 @@#include <linux/of.h> #include <linux/phylink.h> #include <linux/reset.h> -#include <linux/sfp.h> +#include <linux/phy_port.h> #include <dt-bindings/net/qca-ar803x.h> #include "qcom.h"
@@ -769,57 +769,44 @@ static int at8031_register_regulators(struct phy_device *phydev)return 0 ; } -static int at8031_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) +static int at803x_configure_mii (struct phy_port *port,bool enable, +phy_interface_t interface) { -__ETHTOOL_DECLARE_LINK_MODE_MASK (phy_support); -__ETHTOOL_DECLARE_LINK_MODE_MASK (sfp_support); -struct phy_device *phydev = upstream; -const struct sfp_module_caps *caps; -phy_interface_t iface; - -linkmode_zero (phy_support); - phylink_set(phy_support, 1000baseX_Full); - phylink_set(phy_support, 1000baseT_Full); -phylink_set (phy_support, Autoneg); -phylink_set (phy_support, Pause); -phylink_set (phy_support, Asym_Pause); - - caps =sfp_get_module_caps (phydev->sfp_bus); -/* Some modules support 10G modes as well as others we support. -* Mask out non-supported modes so the correct interface is picked. -*/ -linkmode_and (sfp_support, phy_support, caps->link_modes); +struct phy_device *phydev =port_phydev (port); -if (linkmode_empty (sfp_support)) { -dev_err (&phydev->mdio.dev,"incompatible SFP module inserted\n" ); -return -EINVAL ; - } +if (interface ==PHY_INTERFACE_MODE_SGMII ) +dev_warn (&phydev->mdio.dev, +"module may not function if 1000Base-X not supported\n" ); + +return 0 ; +} - iface =sfp_select_interface (phydev->sfp_bus, sfp_support); +static const struct phy_port_ops at803x_port_ops = { + .configure_mii = at803x_configure_mii, +}; -/* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes -* interface for use with SFP modules. -* However, some copper modules detected as having a preferred SGMII -* interface do default to and function in 1000Base-X mode, so just -* print a warning and allow such modules, as they may have some chance -* of working. +static int at8031_attach_mii_port (struct phy_device *phydev, +struct phy_port *port) +{ +linkmode_zero (port->supported); + phylink_set(port->supported, 1000baseX_Full); + phylink_set(port->supported, 1000baseT_Full); +phylink_set (port->supported, Autoneg); +phylink_set (port->supported, Pause); +phylink_set (port->supported, Asym_Pause); + +/* This device doesn't really support SGMII. However, do our best +* to be compatible with copper modules (that usually require SGMII), +* in a degraded mode as we only allow 1000BaseT Full */ -if (iface ==PHY_INTERFACE_MODE_SGMII ) -dev_warn (&phydev->mdio.dev,"module may not function if 1000Base-X not supported\n" ); -else if (iface !=PHY_INTERFACE_MODE_1000BASEX ) -return -EINVAL ; +__set_bit (PHY_INTERFACE_MODE_SGMII , port->interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , port->interfaces); + + port->ops = &at803x_port_ops;return 0 ; } -static const struct sfp_upstream_ops at8031_sfp_ops = { - .attach = phy_sfp_attach, - .detach = phy_sfp_detach, - .module_insert = at8031_sfp_insert, - .connect_phy = phy_sfp_connect_phy, - .disconnect_phy = phy_sfp_disconnect_phy, -}; -static int at8031_parse_dt (struct phy_device *phydev) {struct device_node *node = phydev->mdio.dev.of_node;
@@ -840,8 +827,7 @@ static int at8031_parse_dt(struct phy_device *phydev)return ret; } -/* Only AR8031/8033 support 1000Base-X for SFP modules */ -return phy_sfp_probe (phydev, &at8031_sfp_ops); +return 0 ; }static int at8031_probe (struct phy_device *phydev)
@@ -1172,6 +1158,7 @@ static struct phy_driver at803x_driver[] = { .set_tunable = at803x_set_tunable, .cable_test_start = at8031_cable_test_start, .cable_test_get_status = at8031_cable_test_get_status, + .attach_mii_port = at8031_attach_mii_port, }, {/* Qualcomm Atheros AR8032 */ PHY_ID_MATCH_EXACT(ATH8032_PHY_ID),
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 12/14 net: phy: qca807x: Support SFP through phy_port interface
In reply to Maxime ChevallierQCA8072/8075 may be used as combo-port PHYs, with Serdes (100/1000BaseX)
and Copper interfaces. The PHY has the ability to read the configuration
it's in. If the configuration indicates the PHY is in combo mode, allow registering up to 2 ports.
Register a dedicated set of port ops to handle the serdes port, and rely on generic phylib SFP support for the SFP handling.
--- drivers/net/phy/qcom/qca807x.c | 72 ++++++++++++++-------------------- 1 file changed, 30 insertions(+), 42 deletions(-)
drivers/net/phy/qcom/qca807x.c +30 -42
@@ -13,7 +13,7 @@#include <linux/phy.h> #include <linux/bitfield.h> #include <linux/gpio/driver.h> -#include <linux/sfp.h> +#include <linux/phy_port.h> #include "../phylib.h" #include "qcom.h"
@@ -643,67 +643,54 @@ static int qca807x_phy_package_config_init_once(struct phy_device *phydev)return ret; } -static int qca807x_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) +static int qca807x_configure_serdes (struct phy_port *port,bool enable, +phy_interface_t interface) { -struct phy_device *phydev = upstream; -const struct sfp_module_caps *caps; -phy_interface_t iface; +struct phy_device *phydev =port_phydev (port);int ret; - caps =sfp_get_module_caps (phydev->sfp_bus); - iface =sfp_select_interface (phydev->sfp_bus, caps->link_modes); +if (!phydev) +return -ENODEV ; -dev_info (&phydev->mdio.dev,"%s SFP module inserted\n" ,phy_modes (iface)); - -switch (iface) { -case PHY_INTERFACE_MODE_1000BASEX : -case PHY_INTERFACE_MODE_100BASEX : +if (enable) {/* Set PHY mode to PSGMII combo (1/4 copper + combo ports) mode */ ret =phy_modify (phydev,QCA807X_CHIP_CONFIGURATION ,QCA807X_CHIP_CONFIGURATION_MODE_CFG_MASK ,QCA807X_CHIP_CONFIGURATION_MODE_PSGMII_FIBER ); +if (ret) +return ret;/* Enable fiber mode autodection (1000Base-X or 100Base-FX) */ ret =phy_set_bits_mmd (phydev,MDIO_MMD_AN ,QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION ,QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION_EN ); -/* Select fiber page */ - ret =phy_clear_bits (phydev, -QCA807X_CHIP_CONFIGURATION , -QCA807X_BT_BX_REG_SEL ); - - phydev->port =PORT_FIBRE ; -break ; -default : -dev_err (&phydev->mdio.dev,"Incompatible SFP module inserted\n" ); -return -EINVAL ; +if (ret) +return ret; } -return ret; + phydev->port = enable ?PORT_FIBRE :PORT_TP ; + +return phy_modify (phydev,QCA807X_CHIP_CONFIGURATION , +QCA807X_BT_BX_REG_SEL , + enable ?0 :QCA807X_BT_BX_REG_SEL ); } -static void qca807x_sfp_remove (void *upstream) +static const struct phy_port_ops qca807x_serdes_port_ops = { + .configure_mii = qca807x_configure_serdes, +}; + +static int qca807x_attach_mii_port (struct phy_device *phydev, +struct phy_port *port) { -struct phy_device *phydev = upstream; +__set_bit (PHY_INTERFACE_MODE_1000BASEX , port->interfaces); +__set_bit (PHY_INTERFACE_MODE_100BASEX , port->interfaces); -/* Select copper page */ -phy_set_bits (phydev, -QCA807X_CHIP_CONFIGURATION , -QCA807X_BT_BX_REG_SEL ); + port->ops = &qca807x_serdes_port_ops; - phydev->port =PORT_TP ; +return 0 ; } -static const struct sfp_upstream_ops qca807x_sfp_ops = { - .attach = phy_sfp_attach, - .detach = phy_sfp_detach, - .module_insert = qca807x_sfp_insert, - .module_remove = qca807x_sfp_remove, - .connect_phy = phy_sfp_connect_phy, - .disconnect_phy = phy_sfp_disconnect_phy, -}; -static int qca807x_probe (struct phy_device *phydev) {struct device_node *node = phydev->mdio.dev.of_node;
@@ -744,9 +731,8 @@ static int qca807x_probe(struct phy_device *phydev)/* Attach SFP bus on combo port*/ if (phy_read (phydev,QCA807X_CHIP_CONFIGURATION )) { - ret =phy_sfp_probe (phydev, &qca807x_sfp_ops); -if (ret) -return ret; + phydev->max_n_ports =2 ; +linkmode_set_bit (ETHTOOL_LINK_MODE_FIBRE_BIT , phydev->supported);linkmode_set_bit (ETHTOOL_LINK_MODE_FIBRE_BIT , phydev->advertising); }
@@ -824,6 +810,7 @@ static struct phy_driver qca807x_drivers[] = { .get_phy_stats = qca807x_get_phy_stats, .set_wol = at8031_set_wol, .get_wol = at803x_get_wol, + .attach_mii_port = qca807x_attach_mii_port, }, { PHY_ID_MATCH_EXACT(PHY_ID_QCA8075),
@@ -851,6 +838,7 @@ static struct phy_driver qca807x_drivers[] = { .get_phy_stats = qca807x_get_phy_stats, .set_wol = at8031_set_wol, .get_wol = at803x_get_wol, + .attach_mii_port = qca807x_attach_mii_port, }, };module_phy_driver (qca807x_drivers);
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 13/14 net: phy: Only rely on phy_port for PHY-driven SFP
In reply to Maxime ChevallierNow that all PHY drivers that support downstream SFP have been converted to phy_port serdes handling, we can make the generic PHY SFP handling mandatory, thus making all phylib sfp helpers static.
--- drivers/net/phy/phy_device.c | 28 +++++++++------------------- include/linux/phy.h | 6 ------ 2 files changed, 9 insertions(+), 25 deletions(-)
drivers/net/phy/phy_device.c +9 -19
@@ -1532,7 +1532,7 @@ static DEVICE_ATTR_RO(phy_standalone);* * Return: 0 on success, otherwise a negative error code. */ -int phy_sfp_connect_phy (void *upstream,struct phy_device *phy) +static int phy_sfp_connect_phy (void *upstream,struct phy_device *phy) {struct phy_device *phydev = upstream;struct net_device *dev = phydev->attached_dev;
@@ -1542,7 +1542,6 @@ int phy_sfp_connect_phy(void *upstream, struct phy_device *phy)return 0 ; } -EXPORT_SYMBOL (phy_sfp_connect_phy);/** * phy_sfp_disconnect_phy - Disconnect the SFP module's PHY from the upstream PHY
@@ -1554,7 +1553,7 @@ EXPORT_SYMBOL(phy_sfp_connect_phy);* will be destroyed, re-inserting the same module will add a new phy with a * new index. */ -void phy_sfp_disconnect_phy (void *upstream,struct phy_device *phy) +static void phy_sfp_disconnect_phy (void *upstream,struct phy_device *phy) {struct phy_device *phydev = upstream;struct net_device *dev = phydev->attached_dev;
@@ -1562,7 +1561,6 @@ void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy)if (dev)phy_link_topo_del_phy (dev, phy); } -EXPORT_SYMBOL (phy_sfp_disconnect_phy);/** * phy_sfp_attach - attach the SFP bus to the PHY upstream network device
@@ -1571,7 +1569,7 @@ EXPORT_SYMBOL(phy_sfp_disconnect_phy);* * This is used to fill in the sfp_upstream_ops .attach member. */ -void phy_sfp_attach (void *upstream,struct sfp_bus *bus) +static void phy_sfp_attach (void *upstream,struct sfp_bus *bus) {struct phy_device *phydev = upstream;
@@ -1579,7 +1577,6 @@ void phy_sfp_attach(void *upstream, struct sfp_bus *bus) phydev->attached_dev->sfp_bus = bus; phydev->sfp_bus_attached = true; } -EXPORT_SYMBOL (phy_sfp_attach);/** * phy_sfp_detach - detach the SFP bus from the PHY upstream network device
@@ -1588,7 +1585,7 @@ EXPORT_SYMBOL(phy_sfp_attach);* * This is used to fill in the sfp_upstream_ops .detach member. */ -void phy_sfp_detach (void *upstream,struct sfp_bus *bus) +static void phy_sfp_detach (void *upstream,struct sfp_bus *bus) {struct phy_device *phydev = upstream;
@@ -1596,7 +1593,6 @@ void phy_sfp_detach(void *upstream, struct sfp_bus *bus) phydev->attached_dev->sfp_bus =NULL ; phydev->sfp_bus_attached = false; } -EXPORT_SYMBOL (phy_sfp_detach);static int phy_sfp_module_insert (void *upstream,const struct sfp_eeprom_id *id) {
@@ -1753,10 +1749,8 @@ static int phy_setup_sfp_port(struct phy_device *phydev)/** * phy_sfp_probe - probe for a SFP cage attached to this PHY device * @phydev: Pointer to phy_device -* @ops: SFP's upstream operations */ -int phy_sfp_probe (struct phy_device *phydev, -const struct sfp_upstream_ops *ops) +static int phy_sfp_probe (struct phy_device *phydev) {struct sfp_bus *bus;int ret =0 ;
@@ -1768,7 +1762,7 @@ int phy_sfp_probe(struct phy_device *phydev, phydev->sfp_bus = bus; - ret =sfp_bus_add_upstream (bus, phydev, ops); + ret =sfp_bus_add_upstream (bus, phydev, &sfp_phydev_ops);sfp_bus_put (bus); }
@@ -1777,7 +1771,6 @@ int phy_sfp_probe(struct phy_device *phydev,return ret; } -EXPORT_SYMBOL (phy_sfp_probe);static bool phy_drv_supports_irq (const struct phy_driver *phydrv) {
@@ -3586,12 +3579,9 @@ static int phy_setup_ports(struct phy_device *phydev)if (ret)return ret; -/* Use generic SFP probing only if the driver didn't do so already */ -if (!phydev->sfp_bus) { - ret =phy_sfp_probe (phydev, &sfp_phydev_ops); -if (ret) - goto out; - } + ret =phy_sfp_probe (phydev); +if (ret) + goto out;if (phydev->n_ports < phydev->max_n_ports) { ret =phy_default_setup_single_port (phydev);
include/linux/phy.h +0 -6
@@ -2151,12 +2151,6 @@ int phy_suspend(struct phy_device *phydev);int phy_resume (struct phy_device *phydev);int __phy_resume (struct phy_device *phydev);int phy_loopback (struct phy_device *phydev,bool enable,int speed); -int phy_sfp_connect_phy (void *upstream,struct phy_device *phy); -void phy_sfp_disconnect_phy (void *upstream,struct phy_device *phy); -void phy_sfp_attach (void *upstream,struct sfp_bus *bus); -void phy_sfp_detach (void *upstream,struct sfp_bus *bus); -int phy_sfp_probe (struct phy_device *phydev, -const struct sfp_upstream_ops *ops);struct phy_device *phy_attach (struct net_device *dev,const char *bus_id,phy_interface_t interface);struct phy_device *phy_find_next (struct mii_bus *bus,struct phy_device *pos);
Signature · 1 line
2.49.0
Maxime Chevallier
maintainerPATCH v22 14/14 Documentation: networking: Document the phy_port infrastructure
In reply to Maxime ChevallierThis documentation aims at describing the main goal of the phy_port infrastructure.
--- Documentation/networking/index.rst | 1 + Documentation/networking/phy-port.rst | 111 ++++++++++++++++++++++++++ MAINTAINERS | 2 + 3 files changed, 114 insertions(+) create mode 100644 Documentation/networking/phy-port.rst
Documentation/networking/index.rst +1 -0
@@ -96,6 +96,7 @@ Contents: packet_mmap phonet phy-link-topology + phy-port pktgen plip ppp_generic
Documentation/networking/phy-port.rst new file +111 -0
111 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -9398,6 +9398,7 @@ F: Documentation/devicetree/bindings/net/ethernet-connector.yaml F: Documentation/devicetree/bindings/net/ethernet-phy.yaml F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml +F: Documentation/networking/phy-port.rst F: Documentation/networking/phy.rst F: drivers/net/mdio/ F: drivers/net/mdio/acpi_mdio.c
@@ -18213,6 +18214,7 @@ F: net/ethtool/phy.c NETWORKING [ETHTOOL PHY PORT] M: Maxime Chevallier <[email protected]> F: Documentation/devicetree/bindings/net/ethernet-connector.yaml +F: Documentation/networking/phy-port.rst F: drivers/net/phy/phy_port.c F: include/linux/phy_port.h K: struct\s+phy_port|phy_port_
Signature · 1 line
2.49.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 8 Jan 2026 09:00:25 +0100 you wrote:
Hi everyone,
This is v22 of the
phy_portwork. Main items from this versions are :- Rebase on net-next :)
- Removed a "contains" keyword in the binding
- Added a comment forphy_portSFP implementation[...]
Here is the summary with links:
- [net-next,v22,01/14] dt-bindings: net: Introduce the ethernet-connector description
https://git.kernel.org/netdev/net-next/c/fb7a8d0786e4 - [net-next,v22,02/14] net: ethtool: Introduce ETHTOOL_LINK_MEDIUM_* values https://git.kernel.org/netdev/net-next/c/3f25ff740950 - [net-next,v22,03/14] net: phy: Introduce PHY ports representation https://git.kernel.org/netdev/net-next/c/589e934d2735 - [net-next,v22,04/14] net: phy: dp83822: Add support for phy_port representation https://git.kernel.org/netdev/net-next/c/333c29a27f96 - [net-next,v22,05/14] dt-bindings: net: dp83822: Deprecate ti,fiber-mode https://git.kernel.org/netdev/net-next/c/ffb8587363a3 - [net-next,v22,06/14] net: phy: Create a phy_port for PHY-driven SFPs https://git.kernel.org/netdev/net-next/c/07f3ca9e092c - [net-next,v22,07/14] net: phy: Introduce generic SFP handling for PHY drivers https://git.kernel.org/netdev/net-next/c/d7c6082f7e77 - [net-next,v22,08/14] net: phy: marvell-88x2222: Support SFP through phy_port interface https://git.kernel.org/netdev/net-next/c/ea317f077a38 - [net-next,v22,09/14] net: phy: marvell: Support SFP through phy_port interface https://git.kernel.org/netdev/net-next/c/1384e1383829 - [net-next,v22,10/14] net: phy: marvell10g: Support SFP through phy_port https://git.kernel.org/netdev/net-next/c/35d1a5464b47 - [net-next,v22,11/14] net: phy: at803x: Support SFP through phy_port interface https://git.kernel.org/netdev/net-next/c/4e26a284b9be - [net-next,v22,12/14] net: phy: qca807x: Support SFP through phy_port interface https://git.kernel.org/netdev/net-next/c/154bc3b66c31 - [net-next,v22,13/14] net: phy: Only rely on phy_port for PHY-driven SFP https://git.kernel.org/netdev/net-next/c/bad869b5e41a - [net-next,v22,14/14] Documentation: networking: Document the phy_port infrastructure https://git.kernel.org/netdev/net-next/c/62518b5b3d8e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html