add PLCA RS support and onsemi NCN26000
Subsystems (8)
Piergiorgio Beruto
maintainerv3 cover add PLCA RS support and onsemi NCN26000
This patchset adds support for getting/setting the Physical Layer Collision Avoidace (PLCA) Reconciliation Sublayer (RS) configuration and status on Ethernet PHYs that supports it.
PLCA is a feature that provides improved media-access performance in terms of throughput, latency and fairness for multi-drop (P2MP) half-duplex PHYs. PLCA is defined in Clause 148 of the IEEE802.3 specifications as amended by 802.3cg-2019. Currently, PLCA is supported by the 10BASE-T1S single-pair Ethernet PHY defined in the same standard and related amendments. The OPEN Alliance SIG TC14 defines additional specifications for the 10BASE-T1S PHY, including a standard register map for PHYs that embeds the PLCA RS (see PLCA management registers at https://www.opensig.org/about/specifications/).
The changes proposed herein add the appropriate ethtool netlink interface for configuring the PLCA RS on PHYs that supports it. A separate patchset further modifies the ethtool userspace program to show and modify the configuration/status of the PLCA RS.
Additionally, this patchset adds support for the onsemi NCN26000 Industrial Ethernet 10BASE-T1S PHY that uses the newly added PLCA infrastructure.
Piergiorgio Beruto (5):
net/ethtool: add netlink interface for the PLCA RS drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY drivers/net/phy: add connection between ethtool and phylib for PLCA drivers/net/phy: add helpers to get/set PLCA configuration drivers/net/phy: add driver for the onsemi NCN26000 10BASE-T1S PHY
Documentation/networking/ethtool-netlink.rst | 138 +++++++++ MAINTAINERS | 14 + drivers/net/phy/Kconfig | 7 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-open-alliance.h | 46 +++ drivers/net/phy/ncn26000.c | 171 ++++++++++++ drivers/net/phy/phy-c45.c | 191 +++++++++++++ drivers/net/phy/phy-core.c | 5 +- drivers/net/phy/phy.c | 192 +++++++++++++ drivers/net/phy/phy_device.c | 17 ++ drivers/net/phy/phylink.c | 6 +- include/linux/ethtool.h | 12 + include/linux/phy.h | 84 ++++++ include/uapi/linux/ethtool.h | 3 + include/uapi/linux/ethtool_netlink.h | 25 ++ net/ethtool/Makefile | 2 +- net/ethtool/common.c | 8 + net/ethtool/netlink.c | 29 ++ net/ethtool/netlink.h | 6 + net/ethtool/plca.c | 277 +++++++++++++++++++ 20 files changed, 1231 insertions(+), 3 deletions(-) create mode 100644 drivers/net/phy/mdio-open-alliance.h create mode 100644 drivers/net/phy/ncn26000.c create mode 100644 net/ethtool/plca.c
Signature · 1 line
2.37.4
Piergiorgio Beruto
maintainerPATCH v3 1/5 net/ethtool: add netlink interface for the PLCA RS
Add support for configuring the PLCA Reconciliation Sublayer on multi-drop PHYs that support IEEE802.3cg-2019 Clause 148 (e.g., 10BASE-T1S). This patch adds the appropriate netlink interface to ethtool.
--- Documentation/networking/ethtool-netlink.rst | 138 +++++++++ MAINTAINERS | 6 + include/linux/ethtool.h | 12 + include/linux/phy.h | 57 ++++ include/uapi/linux/ethtool_netlink.h | 25 ++ net/ethtool/Makefile | 2 +- net/ethtool/netlink.c | 29 ++ net/ethtool/netlink.h | 6 + net/ethtool/plca.c | 277 +++++++++++++++++++ 9 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 net/ethtool/plca.c
Documentation/networking/ethtool-netlink.rst +138 -0
@@ -1716,6 +1716,141 @@ being used. Current supported options are toeplitz, xor or crc32. ETHTOOL_A_RSS_INDIR attribute returns RSS indrection table where each byte indicates queue number. +PLCA_GET_CFG +============ + +Gets the IEEE 802.3cg-2019 Clause 148 Physical Layer Collision Avoidance +(PLCA) Reconciliation Sublayer (RS) attributes. + +Request contents: + + ===================================== ====== ========================== + ``ETHTOOL_A_PLCA_HEADER`` nested request header + ===================================== ====== ========================== + +Kernel response contents: + + ====================================== ====== ============================= + ``ETHTOOL_A_PLCA_HEADER`` nested reply header + ``ETHTOOL_A_PLCA_VERSION`` u16 Supported PLCA management + interface standard/version + ``ETHTOOL_A_PLCA_ENABLED`` u8 PLCA Admin State + ``ETHTOOL_A_PLCA_NODE_ID`` u32 PLCA unique local node ID + ``ETHTOOL_A_PLCA_NODE_CNT`` u32 Number of PLCA nodes on the + network, including the + coordinator + ``ETHTOOL_A_PLCA_TO_TMR`` u32 Transmit Opportunity Timer + value in bit-times (BT) + ``ETHTOOL_A_PLCA_BURST_CNT`` u32 Number of additional packets + the node is allowed to send + within a single TO + ``ETHTOOL_A_PLCA_BURST_TMR`` u32 Time to wait for the MAC to + transmit a new frame before + terminating the burst + ====================================== ====== ============================= + +When set, the optional ``ETHTOOL_A_PLCA_VERSION`` attribute indicates which +standard and version the PLCA management interface complies to. When not set, +the interface is vendor-specific and (possibly) supplied by the driver. +The OPEN Alliance SIG specifies a standard register map for 10BASE-T1S PHYs +embedding the PLCA Reconcialiation Sublayer. See "10BASE-T1S PLCA Management +Registers" at https://www.opensig.org/about/specifications/. + +When set, the optional ``ETHTOOL_A_PLCA_ENABLED`` attribute indicates the +administrative state of the PLCA RS. When not set, the node operates in "plain" +CSMA/CD mode. This option is corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.1 +aPLCAAdminState / 30.16.1.2.1 acPLCAAdminControl. + +When set, the optional ``ETHTOOL_A_PLCA_NODE_ID`` attribute indicates the +configured local node ID of the PHY. This ID determines which transmit +opportunity (TO) is reserved for the node to transmit into. This option is +corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.4 aPLCALocalNodeID. The valid +range for this attribute is [0 .. 255] where 255 means "not configured". + +When set, the optional ``ETHTOOL_A_PLCA_NODE_CNT`` attribute indicates the +configured maximum number of PLCA nodes on the mixing-segment. This number +determines the total number of transmit opportunities generated during a +PLCA cycle. This attribute is relevant only for the PLCA coordinator, which is +the node with aPLCALocalNodeID set to 0. Follower nodes ignore this setting. +This option is corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.3 +aPLCANodeCount. The valid range for this attribute is [1 .. 255]. + +When set, the optional ``ETHTOOL_A_PLCA_TO_TMR`` attribute indicates the +configured value of the transmit opportunity timer in bit-times. This value +must be set equal across all nodes sharing the medium for PLCA to work +correctly. This option is corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.5 +aPLCATransmitOpportunityTimer. The valid range for this attribute is +[0 .. 255]. + +When set, the optional ``ETHTOOL_A_PLCA_BURST_CNT`` attribute indicates the +configured number of extra packets that the node is allowed to send during a +single transmit opportunity. By default, this attribute is 0, meaning that +the node can only send a sigle frame per TO. When greater than 0, the PLCA RS +keeps the TO after any transmission, waiting for the MAC to send a new frame +for up to aPLCABurstTimer BTs. This can only happen a number of times per PLCA +cycle up to the value of this parameter. After that, the burst is over and the +normal counting of TOs resumes. This option is corresponding to +``IEEE 802.3cg-2019`` 30.16.1.1.6 aPLCAMaxBurstCount. The valid range for this +attribute is [0 .. 255]. + +When set, the optional ``ETHTOOL_A_PLCA_BURST_TMR`` attribute indicates how +many bit-times the PLCA RS waits for the MAC to initiate a new transmission +when aPLCAMaxBurstCount is greater than 0. If the MAC fails to send a new +frame within this time, the burst ends and the counting of TOs resumes. +Otherwise, the new frame is sent as part of the current burst. This option +is corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.7 aPLCABurstTimer. The +valid range for this attribute is [0 .. 255]. Although, the value should be +set greater than the Inter-Frame-Gap (IFG) time of the MAC (plus some margin) +for PLCA burst mode to work as intended. + +PLCA_SET_CFG +============ + +Sets PLCA RS parameters. + +Request contents: + + ====================================== ====== ============================= + ``ETHTOOL_A_PLCA_HEADER`` nested request header + ``ETHTOOL_A_PLCA_ENABLED`` u8 PLCA Admin State + ``ETHTOOL_A_PLCA_NODE_ID`` u8 PLCA unique local node ID + ``ETHTOOL_A_PLCA_NODE_CNT`` u8 Number of PLCA nodes on the + netkork, including the + coordinator + ``ETHTOOL_A_PLCA_TO_TMR`` u8 Transmit Opportunity Timer + value in bit-times (BT) + ``ETHTOOL_A_PLCA_BURST_CNT`` u8 Number of additional packets + the node is allowed to send + within a single TO + ``ETHTOOL_A_PLCA_BURST_TMR`` u8 Time to wait for the MAC to + transmit a new frame before + terminating the burst + ====================================== ====== ============================= + +For a description of each attribute, see ``PLCA_GET_CFG``. + +PLCA_GET_STATUS +=============== + +Gets PLCA RS status information. + +Request contents: + + ===================================== ====== ========================== + ``ETHTOOL_A_PLCA_HEADER`` nested request header + ===================================== ====== ========================== + +Kernel response contents: + + ====================================== ====== ============================= + ``ETHTOOL_A_PLCA_HEADER`` nested reply header + ``ETHTOOL_A_PLCA_STATUS`` u8 PLCA RS operational status + ====================================== ====== ============================= + +When set, the ``ETHTOOL_A_PLCA_STATUS`` attribute indicates whether the node is +detecting the presence of the BEACON on the network. This flag is +corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.2 aPLCAStatus. + Request translation ===================
@@ -1817,4 +1952,7 @@ are netlink only. n/a ``ETHTOOL_MSG_PHC_VCLOCKS_GET`` n/a ``ETHTOOL_MSG_MODULE_GET`` n/a ``ETHTOOL_MSG_MODULE_SET`` + n/a ``ETHTOOL_MSG_PLCA_GET_CFG`` + n/a ``ETHTOOL_MSG_PLCA_SET_CFG`` + n/a ``ETHTOOL_MSG_PLCA_GET_STATUS`` =================================== =====================================
MAINTAINERS +6 -0
@@ -16613,6 +16613,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.yaml F: drivers/iio/chemical/pms7003.c +PLCA RECONCILIATION SUBLAYER (IEEE802.3 Clause 148) +M: Piergiorgio Beruto <[email protected]> +L: [email protected] +S: Maintained +F: net/ethtool/plca.c + PLDMFW LIBRARY M: Jacob Keller <[email protected]> S: Maintained
include/linux/ethtool.h +12 -0
@@ -802,12 +802,17 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,struct phy_device ;struct phy_tdr_config ; +struct phy_plca_cfg ; +struct phy_plca_status ;/** * struct ethtool_phy_ops - Optional PHY device options * @get_sset_count: Get number of strings that @get_strings will write. * @get_strings: Return a set of strings that describe the requested objects * @get_stats: Return extended statistics about the PHY device. +* @get_plca_cfg: Return PLCA configuration. +* @set_plca_cfg: Set PLCA configuration. +* @get_plca_status: Get PLCA configuration. * @start_cable_test: Start a cable test * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test *
@@ -819,6 +824,13 @@ struct ethtool_phy_ops {int (*get_strings)(struct phy_device *dev,u8 *data);int (*get_stats)(struct phy_device *dev,struct ethtool_stats *stats,u64 *data); +int (*get_plca_cfg)(struct phy_device *dev, +struct phy_plca_cfg *plca_cfg); +int (*set_plca_cfg)(struct phy_device *dev, +const struct phy_plca_cfg *plca_cfg, +struct netlink_ext_ack *extack); +int (*get_plca_status)(struct phy_device *dev, +struct phy_plca_status *plca_st);int (*start_cable_test)(struct phy_device *phydev,struct netlink_ext_ack *extack); int (*start_cable_test_tdr)(struct phy_device *phydev,
include/linux/phy.h +57 -0
63 lines not on this page · raw message
include/uapi/linux/ethtool_netlink.h +25 -0
@@ -52,6 +52,9 @@ enum {ETHTOOL_MSG_PSE_GET ,ETHTOOL_MSG_PSE_SET ,ETHTOOL_MSG_RSS_GET , +ETHTOOL_MSG_PLCA_GET_CFG , +ETHTOOL_MSG_PLCA_SET_CFG , +ETHTOOL_MSG_PLCA_GET_STATUS ,/* add new constants above here */ __ETHTOOL_MSG_USER_CNT,
@@ -99,6 +102,9 @@ enum {ETHTOOL_MSG_MODULE_NTF ,ETHTOOL_MSG_PSE_GET_REPLY ,ETHTOOL_MSG_RSS_GET_REPLY , +ETHTOOL_MSG_PLCA_GET_CFG_REPLY , +ETHTOOL_MSG_PLCA_GET_STATUS_REPLY , +ETHTOOL_MSG_PLCA_NTF ,/* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT,
@@ -894,6 +900,25 @@ enum { ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1), }; +/* PLCA */ + +enum { +ETHTOOL_A_PLCA_UNSPEC , +ETHTOOL_A_PLCA_HEADER ,/* nest - _A_HEADER_* */ +ETHTOOL_A_PLCA_VERSION ,/* u16 */ +ETHTOOL_A_PLCA_ENABLED ,/* u8 */ +ETHTOOL_A_PLCA_STATUS ,/* u8 */ +ETHTOOL_A_PLCA_NODE_CNT ,/* u32 */ +ETHTOOL_A_PLCA_NODE_ID ,/* u32 */ +ETHTOOL_A_PLCA_TO_TMR ,/* u32 */ +ETHTOOL_A_PLCA_BURST_CNT ,/* u32 */ +ETHTOOL_A_PLCA_BURST_TMR ,/* u32 */ + +/* add new constants above here */ + __ETHTOOL_A_PLCA_CNT, +ETHTOOL_A_PLCA_MAX = (__ETHTOOL_A_PLCA_CNT -1 ) +}; +/* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool"#define ETHTOOL_GENL_VERSION 1
net/ethtool/Makefile +1 -1
@@ -8,4 +8,4 @@ ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \ linkstate.o debug.o wol.o features.o privflags.o rings.o \ channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ tunnels.o fec.o eeprom.o stats.o phc_vclocks.o module.o \ - pse-pd.o + pse-pd.o plca.o
net/ethtool/netlink.c +29 -0
@@ -288,6 +288,8 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_MODULE_GET] = ðnl_module_request_ops, [ETHTOOL_MSG_PSE_GET] = ðnl_pse_request_ops, [ETHTOOL_MSG_RSS_GET] = ðnl_rss_request_ops, + [ETHTOOL_MSG_PLCA_GET_CFG] = ðnl_plca_cfg_request_ops, + [ETHTOOL_MSG_PLCA_GET_STATUS] = ðnl_plca_status_request_ops, };static struct ethnl_dump_ctx *ethnl_dump_context (struct netlink_callback *cb)
@@ -603,6 +605,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_EEE_NTF] = ðnl_eee_request_ops, [ETHTOOL_MSG_FEC_NTF] = ðnl_fec_request_ops, [ETHTOOL_MSG_MODULE_NTF] = ðnl_module_request_ops, + [ETHTOOL_MSG_PLCA_NTF] = ðnl_plca_cfg_request_ops, };/* default notification handler */
@@ -696,6 +699,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_EEE_NTF] = ethnl_default_notify, [ETHTOOL_MSG_FEC_NTF] = ethnl_default_notify, [ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_PLCA_NTF] = ethnl_default_notify, };void ethtool_notify (struct net_device *dev,unsigned int cmd,const void *data)
@@ -1047,6 +1051,31 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_rss_get_policy, .maxattr = ARRAY_SIZE(ethnl_rss_get_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_PLCA_GET_CFG, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_plca_get_cfg_policy, + .maxattr = ARRAY_SIZE(ethnl_plca_get_cfg_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_PLCA_SET_CFG, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_set_plca_cfg, + .policy = ethnl_plca_set_cfg_policy, + .maxattr = ARRAY_SIZE(ethnl_plca_set_cfg_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_PLCA_GET_STATUS, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_plca_get_status_policy, + .maxattr = ARRAY_SIZE(ethnl_plca_get_status_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
net/ethtool/netlink.h +6 -0
@@ -347,6 +347,8 @@ extern const struct ethnl_request_ops ethnl_phc_vclocks_request_ops;extern const struct ethnl_request_ops ethnl_module_request_ops;extern const struct ethnl_request_ops ethnl_pse_request_ops;extern const struct ethnl_request_ops ethnl_rss_request_ops; +extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; +extern const struct ethnl_request_ops ethnl_plca_status_request_ops;extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS +1 ];extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS +1 ];
@@ -388,6 +390,9 @@ extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MOextern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER +1 ];extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX +1 ];extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_CONTEXT +1 ]; +extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER +1 ]; +extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX +1 ]; +extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER +1 ];int ethnl_set_linkinfo (struct sk_buff *skb,struct genl_info *info);int ethnl_set_linkmodes (struct sk_buff *skb,struct genl_info *info);
@@ -408,6 +413,7 @@ int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb);int ethnl_set_fec (struct sk_buff *skb,struct genl_info *info);int ethnl_set_module (struct sk_buff *skb,struct genl_info *info);int ethnl_set_pse (struct sk_buff *skb,struct genl_info *info); +int ethnl_set_plca_cfg (struct sk_buff *skb,struct genl_info *info);extern const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN ];extern const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN ];
net/ethtool/plca.c new file +277 -0
277 lines not on this page · raw message
Signature · 1 line
2.37.4
Piergiorgio Beruto
maintainerPATCH v3 2/5 drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY
In reply to Piergiorgio BerutoThis patch adds the link modes for the IEEE 802.3cg Clause 147 10BASE-T1S Ethernet PHY. According to the specifications, the 10BASE-T1S supports Point-To-Point Full-Duplex, Point-To-Point Half-Duplex and/or Point-To-Multipoint (AKA Multi-Drop) Half-Duplex operations.
--- drivers/net/phy/phy-core.c | 5 ++++- drivers/net/phy/phy_device.c | 14 ++++++++++++++ drivers/net/phy/phylink.c | 6 +++++- include/linux/phy.h | 14 ++++++++++++++ include/uapi/linux/ethtool.h | 3 +++ net/ethtool/common.c | 8 ++++++++ 6 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/phy/phy-core.c +4 -1
@@ -13,7 +13,7 @@*/ const char *phy_speed_to_str (int speed) { -BUILD_BUG_ON_MSG (__ETHTOOL_LINK_MODE_MASK_NBITS !=99 , +BUILD_BUG_ON_MSG (__ETHTOOL_LINK_MODE_MASK_NBITS !=102 ,"Enum ethtool_link_mode_bit_indices and phylib are out of sync. " "If a speed or mode has been added please update phy_speed_to_str " "and the PHY settings array.\n" );
@@ -260,6 +260,9 @@ static const struct phy_setting settings[] = { PHY_SETTING( 10, FULL, 10baseT_Full ), PHY_SETTING( 10, HALF, 10baseT_Half ), PHY_SETTING( 10, FULL, 10baseT1L_Full ), + PHY_SETTING( 10, FULL, 10baseT1S_Full ), + PHY_SETTING( 10, HALF, 10baseT1S_Half ), + PHY_SETTING( 10, HALF, 10baseT1S_P2MP_Half ), };#undef PHY_SETTING
drivers/net/phy/phy_device.c +14 -0
@@ -45,6 +45,9 @@ EXPORT_SYMBOL_GPL(phy_basic_features);__ETHTOOL_DECLARE_LINK_MODE_MASK (phy_basic_t1_features)__ro_after_init ;EXPORT_SYMBOL_GPL (phy_basic_t1_features); +__ETHTOOL_DECLARE_LINK_MODE_MASK (phy_basic_t1s_p2mp_features)__ro_after_init ; +EXPORT_SYMBOL_GPL (phy_basic_t1s_p2mp_features); +__ETHTOOL_DECLARE_LINK_MODE_MASK (phy_gbit_features)__ro_after_init ;EXPORT_SYMBOL_GPL (phy_gbit_features);
@@ -98,6 +101,12 @@ const int phy_basic_t1_features_array[3] = { };EXPORT_SYMBOL_GPL (phy_basic_t1_features_array); +const int phy_basic_t1s_p2mp_features_array[2 ] = { +ETHTOOL_LINK_MODE_TP_BIT , + ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT, +}; +EXPORT_SYMBOL_GPL (phy_basic_t1s_p2mp_features_array); +const int phy_gbit_features_array[2 ] = { ETHTOOL_LINK_MODE_1000baseT_Half_BIT, ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
@@ -138,6 +147,11 @@ static void features_init(void)ARRAY_SIZE (phy_basic_t1_features_array), phy_basic_t1_features); +/* 10 half, P2MP, TP */ +linkmode_set_bit_array (phy_basic_t1s_p2mp_features_array, +ARRAY_SIZE (phy_basic_t1s_p2mp_features_array), + phy_basic_t1s_p2mp_features); +/* 10/100 half/full + 1000 half/full */ linkmode_set_bit_array(phy_basic_ports_array, ARRAY_SIZE(phy_basic_ports_array),
drivers/net/phy/phylink.c +5 -1
@@ -241,12 +241,16 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps)if (caps &MAC_ASYM_PAUSE )__set_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, linkmodes); -if (caps &MAC_10HD ) +if (caps &MAC_10HD ) {__set_bit (ETHTOOL_LINK_MODE_10baseT_Half_BIT, linkmodes); +__set_bit (ETHTOOL_LINK_MODE_10baseT1S_Half_BIT, linkmodes); +__set_bit (ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT, linkmodes); + }if (caps &MAC_10FD ) {__set_bit (ETHTOOL_LINK_MODE_10baseT_Full_BIT, linkmodes);__set_bit (ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, linkmodes); +__set_bit (ETHTOOL_LINK_MODE_10baseT1S_Full_BIT, linkmodes); }if (caps &MAC_100HD ) {
include/linux/phy.h +14 -0
@@ -45,6 +45,7 @@extern __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_basic_features)__ro_after_init ;extern __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_basic_t1_features)__ro_after_init ; +extern __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_basic_t1s_p2mp_features)__ro_after_init ;extern __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_gbit_features)__ro_after_init ;extern __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_gbit_fibre_features)__ro_after_init ;extern __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_gbit_all_ports_features)__ro_after_init ;
@@ -54,6 +55,7 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_full_features) __ro_after_ini#define PHY_BASIC_FEATURES ((unsigned long *)&phy_basic_features)#define PHY_BASIC_T1_FEATURES ((unsigned long *)&phy_basic_t1_features) +#define PHY_BASIC_T1S_P2MP_FEATURES ((unsigned long *)&phy_basic_t1s_p2mp_features)#define PHY_GBIT_FEATURES ((unsigned long *)&phy_gbit_features)#define PHY_GBIT_FIBRE_FEATURES ((unsigned long *)&phy_gbit_fibre_features)#define PHY_GBIT_ALL_PORTS_FEATURES ((unsigned long *)&phy_gbit_all_ports_features)
@@ -66,6 +68,7 @@ extern const int phy_fibre_port_array[1];extern const int phy_all_ports_features_array[7 ];extern const int phy_10_100_features_array[4 ];extern const int phy_basic_t1_features_array[3 ]; +extern const int phy_basic_t1s_p2mp_features_array[2 ];extern const int phy_gbit_features_array[2 ];extern const int phy_10gbit_features_array[1 ];
@@ -1036,6 +1039,17 @@ struct phy_driver {int (*get_sqi)(struct phy_device *dev);/** @get_sqi_max: Get the maximum signal quality indication */ int (*get_sqi_max)(struct phy_device *dev); + +/* PLCA RS interface */ +/** @get_plca_cfg: Return the current PLCA configuration */ +int (*get_plca_cfg)(struct phy_device *dev, +struct phy_plca_cfg *plca_cfg); +/** @set_plca_cfg: Set the PLCA configuration */ +int (*set_plca_cfg)(struct phy_device *dev, +const struct phy_plca_cfg *plca_cfg); +/** @get_plca_status: Return the current PLCA status info */ +int (*get_plca_status)(struct phy_device *dev, +struct phy_plca_status *plca_st); };#define to_phy_driver (d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv)
include/uapi/linux/ethtool.h +3 -0
@@ -1741,6 +1741,9 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT =96 , ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT =97 , ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT =98 , + ETHTOOL_LINK_MODE_10baseT1S_Full_BIT =99 , + ETHTOOL_LINK_MODE_10baseT1S_Half_BIT =100 , + ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT =101 ,/* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS
net/ethtool/common.c +8 -0
@@ -208,6 +208,9 @@ const char link_mode_names[][ETH_GSTRING_LEN] = {__DEFINE_LINK_MODE_NAME (800000 ,DR8_2 , Full),__DEFINE_LINK_MODE_NAME (800000 ,SR8 , Full),__DEFINE_LINK_MODE_NAME (800000 ,VR8 , Full), +__DEFINE_LINK_MODE_NAME (10 ,T1S , Full), +__DEFINE_LINK_MODE_NAME (10 ,T1S , Half), +__DEFINE_LINK_MODE_NAME (10 ,T1S_P2MP , Half), };static_assert (ARRAY_SIZE (link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);
@@ -244,6 +247,8 @@ static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);#define __LINK_MODE_LANES_X 1#define __LINK_MODE_LANES_FX 1#define __LINK_MODE_LANES_T1L 1 +#define __LINK_MODE_LANES_T1S 1 +#define __LINK_MODE_LANES_T1S_P2MP 1#define __LINK_MODE_LANES_VR8 8#define __LINK_MODE_LANES_DR8_2 8
@@ -366,6 +371,9 @@ const struct link_mode_info link_mode_params[] = {__DEFINE_LINK_MODE_PARAMS (800000 ,DR8_2 , Full),__DEFINE_LINK_MODE_PARAMS (800000 ,SR8 , Full),__DEFINE_LINK_MODE_PARAMS (800000 ,VR8 , Full), +__DEFINE_LINK_MODE_PARAMS (10 ,T1S , Full), +__DEFINE_LINK_MODE_PARAMS (10 ,T1S , Half), +__DEFINE_LINK_MODE_PARAMS (10 ,T1S_P2MP , Half), };static_assert (ARRAY_SIZE (link_mode_params) == __ETHTOOL_LINK_MODE_MASK_NBITS);
Signature · 1 line
2.37.4
Piergiorgio Beruto
maintainerPATCH v3 3/5 drivers/net/phy: add connection between ethtool and phylib for PLCA
In reply to Piergiorgio BerutoThis patch adds the required connection between netlink ethtool and phylib to resolve PLCA get/set config and get status messages.
--- drivers/net/phy/phy.c | 192 +++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 3 + include/linux/phy.h | 7 ++ 3 files changed, 202 insertions(+)
drivers/net/phy/phy.c +192 -0
@@ -543,6 +543,198 @@ int phy_ethtool_get_stats(struct phy_device *phydev, }EXPORT_SYMBOL (phy_ethtool_get_stats); +/** +* phy_ethtool_get_plca_cfg - Get PLCA RS configuration +* @phydev: the phy_device struct +* @plca_cfg: where to store the retrieved configuration +* +* Retrieve the PLCA configuration from the PHY. Return 0 on success or a +* negative value if an error occurred. +*/ +int phy_ethtool_get_plca_cfg (struct phy_device *phydev, +struct phy_plca_cfg *plca_cfg) +{ +int ret; + +if (!phydev->drv) { + ret = -EIO ; + goto out; + } + +if (!phydev->drv->get_plca_cfg) { + ret = -EOPNOTSUPP ; + goto out; + } + +mutex_lock (&phydev->lock); + ret = phydev->drv->get_plca_cfg (phydev, plca_cfg); + +mutex_unlock (&phydev->lock); +out: +return ret; +} + +/** +* plca_check_valid - Check PLCA configuration before enabling +* @phydev: the phy_device struct +* @plca_cfg: current PLCA configuration +* @extack: extack for reporting useful error messages +* +* Checks whether the PLCA and PHY configuration are consistent and it is safe +* to enable PLCA. Returns 0 on success or a negative value if the PLCA or PHY +* configuration is not consistent. +*/ +static int plca_check_valid (struct phy_device *phydev, +const struct phy_plca_cfg *plca_cfg, +struct netlink_ext_ack *extack) +{ +int ret =0 ; + +if (!linkmode_test_bit (ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT, + phydev->advertising)) { + ret = -EOPNOTSUPP ; +NL_SET_ERR_MSG (extack, +"Point to Multi-Point mode is not enabled" ); + }else if (plca_cfg->node_id >=255 ) { +NL_SET_ERR_MSG (extack,"PLCA node ID is not set" ); + ret = -EINVAL ; + } + +return ret; +} + +/** +* phy_ethtool_set_plca_cfg - Set PLCA RS configuration +* @phydev: the phy_device struct +* @plca_cfg: new PLCA configuration to apply +* @extack: extack for reporting useful error messages +* +* Sets the PLCA configuration in the PHY. Return 0 on success or a +* negative value if an error occurred. +*/ +int phy_ethtool_set_plca_cfg (struct phy_device *phydev, +const struct phy_plca_cfg *plca_cfg, +struct netlink_ext_ack *extack) +{ +struct phy_plca_cfg *curr_plca_cfg; +int ret; + +if (!phydev->drv) { + ret = -EIO ; + goto out; + } + +if (!phydev->drv->set_plca_cfg || + !phydev->drv->get_plca_cfg) { + ret = -EOPNOTSUPP ; + goto out; + } + + curr_plca_cfg =kmalloc (sizeof (*curr_plca_cfg),GFP_KERNEL ); +if (!curr_plca_cfg) { + ret = -ENOMEM ; + goto out; + } + +mutex_lock (&phydev->lock); + + ret = phydev->drv->get_plca_cfg (phydev, curr_plca_cfg); +if (ret) + goto out_drv; + +if (curr_plca_cfg->enabled <0 && plca_cfg->enabled >=0 ) { +NL_SET_ERR_MSG (extack, +"PHY does not support changing the PLCA 'enable' attribute" ); + ret = -EINVAL ; + goto out_drv; + } + +if (curr_plca_cfg->node_id <0 && plca_cfg->node_id >=0 ) { +NL_SET_ERR_MSG (extack, +"PHY does not support changing the PLCA 'local node ID' attribute" ); + ret = -EINVAL ; + goto out_drv; + } + +if (curr_plca_cfg->node_cnt <0 && plca_cfg->node_cnt >=0 ) { +NL_SET_ERR_MSG (extack, +"PHY does not support changing the PLCA 'node count' attribute" ); + ret = -EINVAL ; + goto out_drv; + } + +if (curr_plca_cfg->to_tmr <0 && plca_cfg->to_tmr >=0 ) { +NL_SET_ERR_MSG (extack, +"PHY does not support changing the PLCA 'TO timer' attribute" ); + ret = -EINVAL ; + goto out_drv; + } + +if (curr_plca_cfg->burst_cnt <0 && plca_cfg->burst_cnt >=0 ) { +NL_SET_ERR_MSG (extack, +"PHY does not support changing the PLCA 'burst count' attribute" ); + ret = -EINVAL ; + goto out_drv; + } + +if (curr_plca_cfg->burst_tmr <0 && plca_cfg->burst_tmr >=0 ) { +NL_SET_ERR_MSG (extack, +"PHY does not support changing the PLCA 'burst timer' attribute" ); + ret = -EINVAL ; + goto out_drv; + } + +// if enabling PLCA, perform a few sanity checks +if (plca_cfg->enabled >0 ) { +// allow setting node_id concurrently with enabled +if (plca_cfg->node_id >=0 ) + curr_plca_cfg->node_id = plca_cfg->node_id; + + ret =plca_check_valid (phydev, curr_plca_cfg, extack); +if (ret) + goto out_drv; + } + + ret = phydev->drv->set_plca_cfg (phydev, plca_cfg); + +out_drv: +kfree (curr_plca_cfg); +mutex_unlock (&phydev->lock); +out: +return ret; +} + +/** +* phy_ethtool_get_plca_status - Get PLCA RS status information +* @phydev: the phy_device struct +* @plca_st: where to store the retrieved status information +* +* Retrieve the PLCA status information from the PHY. Return 0 on success or a +* negative value if an error occurred. +*/ +int phy_ethtool_get_plca_status (struct phy_device *phydev, +struct phy_plca_status *plca_st) +{ +int ret; + +if (!phydev->drv) { + ret = -EIO ; + goto out; + } + +if (!phydev->drv->get_plca_status) { + ret = -EOPNOTSUPP ; + goto out; + } + +mutex_lock (&phydev->lock); + ret = phydev->drv->get_plca_status (phydev, plca_st); + +mutex_unlock (&phydev->lock); +out: +return ret; +} +/** * phy_start_cable_test - Start a cable test *
drivers/net/phy/phy_device.c +3 -0
@@ -3276,6 +3276,9 @@ static const struct ethtool_phy_ops phy_ethtool_phy_ops = { .get_sset_count = phy_ethtool_get_sset_count, .get_strings = phy_ethtool_get_strings, .get_stats = phy_ethtool_get_stats, + .get_plca_cfg = phy_ethtool_get_plca_cfg, + .set_plca_cfg = phy_ethtool_set_plca_cfg, + .get_plca_status = phy_ethtool_get_plca_status, .start_cable_test = phy_start_cable_test, .start_cable_test_tdr = phy_start_cable_test_tdr, };
include/linux/phy.h +7 -0
@@ -1846,6 +1846,13 @@ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);int phy_ethtool_get_sset_count (struct phy_device *phydev);int phy_ethtool_get_stats (struct phy_device *phydev,struct ethtool_stats *stats,u64 *data); +int phy_ethtool_get_plca_cfg (struct phy_device *phydev, +struct phy_plca_cfg *plca_cfg); +int phy_ethtool_set_plca_cfg (struct phy_device *phydev, +const struct phy_plca_cfg *plca_cfg, +struct netlink_ext_ack *extack); +int phy_ethtool_get_plca_status (struct phy_device *phydev, +struct phy_plca_status *plca_st);static inline int phy_package_read (struct phy_device *phydev,u32 regnum) {
Signature · 1 line
2.37.4
Piergiorgio Beruto
maintainerPATCH v3 4/5 drivers/net/phy: add helpers to get/set PLCA configuration
In reply to Piergiorgio BerutoThis patch adds support in phylib to read/write PLCA configuration for Ethernet PHYs that support the OPEN Alliance "10BASE-T1S PLCA Management Registers" specifications. These can be found at
https://www.opensig.org/about/specifications/
--- MAINTAINERS | 1 + drivers/net/phy/mdio-open-alliance.h | 46 +++++++ drivers/net/phy/phy-c45.c | 191 +++++++++++++++++++++++++++ include/linux/phy.h | 6 + 4 files changed, 244 insertions(+) create mode 100644 drivers/net/phy/mdio-open-alliance.h
MAINTAINERS +1 -0
@@ -16617,6 +16617,7 @@ PLCA RECONCILIATION SUBLAYER (IEEE802.3 Clause 148) M: Piergiorgio Beruto <[email protected]> L: [email protected] S: Maintained +F: drivers/net/phy/mdio-open-alliance.h F: net/ethtool/plca.c PLDMFW LIBRARY
drivers/net/phy/mdio-open-alliance.h new file +46 -0
46 lines not on this page · raw message
drivers/net/phy/phy-c45.c +191 -0
203 lines not on this page · raw message
include/linux/phy.h +6 -0
@@ -1748,6 +1748,12 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable);int genphy_c45_pma_resume (struct phy_device *phydev);int genphy_c45_pma_suspend (struct phy_device *phydev);int genphy_c45_fast_retrain (struct phy_device *phydev,bool enable); +int genphy_c45_plca_get_cfg (struct phy_device *phydev, +struct phy_plca_cfg *plca_cfg); +int genphy_c45_plca_set_cfg (struct phy_device *phydev, +const struct phy_plca_cfg *plca_cfg); +int genphy_c45_plca_get_status (struct phy_device *phydev, +struct phy_plca_status *plca_st);/* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver;
Signature · 1 line
2.37.4
Piergiorgio Beruto
maintainerPATCH v3 5/5 drivers/net/phy: add driver for the onsemi NCN26000 10BASE-T1S PHY
In reply to Piergiorgio BerutoThis patch adds support for the onsemi NCN26000 10BASE-T1S industrial Ethernet PHY. The driver supports Point-to-Multipoint operation without auto-negotiation and with link control handling. The PHY also features PLCA for improving performance in P2MP mode.
--- MAINTAINERS | 7 ++ drivers/net/phy/Kconfig | 7 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/ncn26000.c | 171 +++++++++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 drivers/net/phy/ncn26000.c
MAINTAINERS +7 -0
@@ -15581,6 +15581,13 @@ L: [email protected] S: Maintained F: arch/mips/boot/dts/ralink/omega2p.dts +ONSEMI ETHERNET PHY DRIVERS +M: Piergiorgio Beruto <[email protected]> +L: [email protected] +S: Supported +W: http://www.onsemi.com +F: drivers/net/phy/ncn* + OP-TEE DRIVER M: Jens Wiklander <[email protected]> L: [email protected]
drivers/net/phy/Kconfig +7 -0
@@ -277,6 +277,13 @@ config NXP_TJA11XX_PHY help Currently supports the NXP TJA1100 and TJA1101 PHY. +config NCN26000_PHY + tristate "onsemi 10BASE-T1S Ethernet PHY" + help + Adds support for the onsemi 10BASE-T1S Ethernet PHY. + Currently supports the NCN26000 10BASE-T1S Industrial PHY + with MII interface. + config AT803X_PHY tristate "Qualcomm Atheros AR803X PHYs and QCA833x PHYs" depends on REGULATOR
drivers/net/phy/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_MICROCHIP_T1_PHY) += microchip_t1.o obj-$(CONFIG_MICROSEMI_PHY) += mscc/ obj-$(CONFIG_MOTORCOMM_PHY) += motorcomm.o obj-$(CONFIG_NATIONAL_PHY) += national.o +obj-$(CONFIG_NCN26000_PHY) += ncn26000.o obj-$(CONFIG_NXP_C45_TJA11XX_PHY) += nxp-c45-tja11xx.o obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o
drivers/net/phy/ncn26000.c new file +171 -0
171 lines not on this page · raw message
Signature · 1 line
2.37.4