net: phylink: Add phylinksetfixed_link() to configure fixed link state in phylink
Subsystems (4)
PATCH 1/1 net: phylink: Add phylinksetfixed_link() to configure fixed link state in phylink
From: Russell King <[email protected]>
The function allows for the configuration of a fixed link state for a given phylink instance. This addition is particularly useful for network devices that operate with a fixed link configuration, where the link parameters do not change dynamically. By using phylink_set_fixed_link(), drivers can easily set up the fixed link state during initialization or configuration changes.
---
Note: This code was developed by Mr.Russell King.
drivers/net/phy/phylink.c | 42 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 2 ++ 2 files changed, 44 insertions(+)
drivers/net/phy/phylink.c +42 -0
@@ -1635,6 +1635,48 @@ static int phylink_register_sfp(struct phylink *pl,return ret; } +/** +* phylink_set_fixed_link() - set the fixed link +* @pl: a pointer to a &struct phylink returned from phylink_create() +* @state: a pointer to a struct phylink_link_state. +* +* This function is used when the link parameters are known and do not change, +* making it suitable for certain types of network connections. +* +* Returns zero on success, or negative error code. +*/ +int phylink_set_fixed_link (struct phylink *pl, +const struct phylink_link_state *state) +{ +const struct phy_setting *s; +unsigned long *adv; + +if (pl->cfg_link_an_mode !=MLO_AN_PHY || !state || + !test_bit (PHYLINK_DISABLE_STOPPED , &pl->phylink_disable_state)) +return -EINVAL ; + + s =phy_lookup_setting (state->speed, state->duplex, + pl->supported, true); +if (!s) +return -EINVAL ; + + adv = pl->link_config.advertising; +linkmode_zero (adv); +linkmode_set_bit (s->bit, adv); +linkmode_set_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, adv); + + pl->link_config.speed = state->speed; + pl->link_config.duplex = state->duplex; + pl->link_config.link =1 ; + pl->link_config.an_complete =1 ; + + pl->cfg_link_an_mode =MLO_AN_FIXED ; + pl->cur_link_an_mode = pl->cfg_link_an_mode; + +return 0 ; +} +EXPORT_SYMBOL_GPL (phylink_set_fixed_link); +/** * phylink_create() - create a phylink instance * @config: a pointer to the target &struct phylink_config
include/linux/phylink.h +2 -0
@@ -598,6 +598,8 @@ int phylink_fwnode_phy_connect(struct phylink *pl,const struct fwnode_handle *fwnode, u32 flags);void phylink_disconnect_phy (struct phylink *); +int phylink_set_fixed_link (struct phylink *, +const struct phylink_link_state *);void phylink_mac_change (struct phylink *,bool up);void phylink_pcs_change (struct phylink_pcs *,bool up);
Signature · 1 line
2.34.1
Andrew Lunn
maintainerQuoted 9 lines
+/**
+ *phylink_set_fixed_link()- set the fixed link
+ * @pl: a pointer to a &struct phylink returned fromphylink_create()
+ * @state: a pointer to a structphylink_link_state.
+ *
+ * This function is used when the link parameters are known and do not change,
+ * making it suitable for certain types of network connections.
+ *
+ * Returns zero on success, or negative error code.
kernel doc requires a : after Returns. The tooling is getting more picky about this and pointing out this error. But there is a lot of code which gets this wrong, so you probably cut/paste a bad example.
Andrew
---
pw-bot: cr
Hi Andrew,
Thank you for review the patch.
Quoted 16 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Monday, August 19, 2024 9:39 PM
To: Raju Lakkaraju - I30499 <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Bryan Whitehead - C21958 <[email protected]>; [email protected]; [email protected]; [email protected]; UNGLinuxDriver <[email protected]>
Subject: Re: [PATCH net-next] net: phylink: Addphylinksetfixed_link()to configure fixed link state in phylinkEXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 15 lines
drivers/net/phy/phylink.c static int phylink_register_sfp(struct phylink *pl, · line 1646
Quoted 10 lines
drivers/net/phy/phylink.c +10
-0+/** +* phylink_set_fixed_link() - set the fixed link +* @pl: a pointer to a &struct phylink returned from phylink_create() +* @state: a pointer to a struct phylink_link_state. +* +* This function is used when the link parameters are known and do +not change, +* making it suitable for certain types of network connections. +* +* Returns zero on success, or negative error code. kernel doc requires a : after Returns. The tooling is getting more picky about this and pointing out this error. But there is a lot of code which gets this wrong, so you probably cut/paste a bad example.
Ok. I will fix.
You are correct. I did copy/paste the string.
Quoted 4 lines
Andrew
---
pw-bot: cr
Thanks,
Raju
Simon Horman
reviewerQuoted 8 lines · Raju Lakkaraju
From: Russell King <[email protected]>
The function allows for the configuration of a fixed link state for a given phylink instance. This addition is particularly useful for network devices that operate with a fixed link configuration, where the link parameters do not change dynamically. By using
phylink_set_fixed_link(), drivers can easily set up the fixed link state during initialization or configuration changes.
Quoted 4 lines
Signed-off-by Russell King <[email protected]>Signed-off-by Raju Lakkaraju <[email protected]>---
Note: This code was developed by Mr.Russell King.
Hi,
I am wondering if we need a user of this function in order for this patch to be accepted, as is often the practice for new features.
Hi Simon,
Thank you for review the patch.
Quoted 31 lines
-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Monday, August 19, 2024 9:54 PM
To: Raju Lakkaraju - I30499 <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Bryan Whitehead - C21958 <[email protected]>; [email protected]; [email protected]; [email protected]; UNGLinuxDriver <[email protected]>
Subject: Re: [PATCH net-next] net: phylink: Addphylinksetfixed_link()to configure fixed link state in phylinkEXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 7 lines · Raju Lakkaraju
From: Russell King <[email protected]>
The function allows for the configuration of a fixed link state for a given phylink instance. This addition is particularly useful for network devices that operate with a fixed link configuration, where the link parameters do not change dynamically. By using
phylink_set_fixed_link(), drivers can easily set up the fixed link state duringinitialization or configuration changes.
Quoted 5 lines
Signed-off-by Russell King <[email protected]>Signed-off-by Raju Lakkaraju <[email protected]>---
Note: This code was developed by Mr.Russell King.
Quoted 4 lines
Hi,
I am wondering if we need a user of this function in order for this patch to be accepted, as is often the practice for new features.
This patch is Mr. Russell King's developed code which I'm submitting to Linux community for review. just following Russell's request.
i.e.
https://lore.kernel.org/netdev/[email protected]/
if it is required, I can send both together in a single series. Please confirm
Hi Russell, Do you any concerns about Mr. Simon comments?
Thanks,
Raju