ethtool: transceiver reset and presence pin control
Subsystems (5)
PATCH 1/2 ethtool: transceiver reset and presence pin control
Signal Definition section (Other signals) of SFF-8636 Spec mentions that additional signals like reset and module present may be implemented for a specific hardware. There is currently no user space API for control of those signals so user space management applications have no chance to perform some diagnostic or configuration operations. This patch uses get_phy_tunable/set_phy_tunable ioctl API to provide above control to user space. Despite ethtool reset option seems to be more suitable for transceiver module reset control, ethtool reset doesn't allow for reset pin assertion and deassertion. Userspace API may require control over when pin will be asserte and deasserted so we cannot trigger reset and leave it to the driver when deassert should be perfromed.
--- include/uapi/linux/ethtool.h | 14 ++++++++++++++ net/ethtool/common.c | 1 + net/ethtool/ioctl.c | 1 + 3 files changed, 16 insertions(+)
include/uapi/linux/ethtool.h +13 -0
@@ -289,11 +289,24 @@ struct ethtool_tunable {#define ETHTOOL_PHY_EDPD_NO_TX 0xfffe#define ETHTOOL_PHY_EDPD_DISABLE 0 +/** +* SFF-8636 Spec in Signal Definition section (Other signals) mentions +* that 'Additional signals such as power, module present, interrupt, reset, +* and low-power mode may be implemented'. Below defines reflect present +* and reset signal statuses. Additionally ETHTOOL_PHY_MODULE_RESET +* in 'enum phy_tunable_id' will be used for reset pin toggle. +*/ +#define ETHTOOL_PHY_MODULE_RESET_OFF 0x00 +#define ETHTOOL_PHY_MODULE_RESET_ON 0x01 +/* Not Available if module not present */ +#define ETHTOOL_PHY_MODULE_RESET_NA 0xff +enum phy_tunable_id {ETHTOOL_PHY_ID_UNSPEC ,ETHTOOL_PHY_DOWNSHIFT ,ETHTOOL_PHY_FAST_LINK_DOWN ,ETHTOOL_PHY_EDPD , +ETHTOOL_PHY_MODULE_RESET ,/* * Add your fresh new phy tunable attribute above and remember to update * phy_tunable_strings[] in net/ethtool/common.c
net/ethtool/common.c +1 -0
@@ -101,6 +101,7 @@ phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = { [ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift", [ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down", [ETHTOOL_PHY_EDPD] = "phy-energy-detect-power-down", + [ETHTOOL_PHY_MODULE_RESET] = "phy-transceiver-module-reset", };#define __LINK_MODE_NAME (speed, type, duplex) \
net/ethtool/ioctl.c +1 -0
@@ -2954,6 +2954,7 @@ static int ethtool_phy_tunable_valid(const struct ethtool_tunable *tuna)switch (tuna->id) {case ETHTOOL_PHY_DOWNSHIFT :case ETHTOOL_PHY_FAST_LINK_DOWN : +case ETHTOOL_PHY_MODULE_RESET :if (tuna->len !=sizeof (u8) || tuna->type_id !=ETHTOOL_TUNABLE_U8 )return -EINVAL ;
Signature · 1 line
2.47.0
PATCH 2/2 ice: add qsfp transceiver reset and presence pin control
Commit f3c1c896f5a8 ("ethtool: transceiver reset and presence pin control") adds ioctl API extension for get/set-phy-tunable so that transceiver reset and presence pin control is enabled.
This commit adds functionality to utilize the API in ice driver. According to E810 datasheet QSFP reset and presence pins are being connected to SDP0 and SDP2 pins on controller host. Those pins can be accessed using AQ commands for GPIO get/set.[O
--- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_common.c | 21 ++++++ drivers/net/ethernet/intel/ice/ice_common.h | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 72 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_type.h | 2 + 6 files changed, 99 insertions(+)
drivers/net/ethernet/intel/ice/ice.h +2 -0
@@ -106,6 +106,8 @@#define ICE_Q_WAIT_MAX_RETRY (5 * ICE_Q_WAIT_RETRY_LIMIT)#define ICE_MAX_LG_RSS_QS 256#define ICE_INVAL_Q_INDEX 0xffff +#define ICE_GPIO_QSFP0_RESET 0 +#define ICE_GPIO_QSFP0_PRESENT 2#define ICE_MAX_RXQS_PER_TC 256/* Used when setting VSI context per TC Rx queues */
drivers/net/ethernet/intel/ice/ice_common.c +21 -0
@@ -6096,3 +6096,24 @@ u32 ice_get_link_speed(u16 index)return ice_aq_to_link_speed[index]; } + +/** +* ice_set_has_gpios - Sets availability of SDP GPIO pins. +* @hw: pointer to the HW structure +* +* This function sets availability of GPIO software defined pins +* (SDP) which are connected to transceiver slots and are used +* for transceiver control. +*/ +bool ice_set_has_gpios (struct ice_hw *hw) +{ +if (hw->vendor_id !=PCI_VENDOR_ID_INTEL ) +return false; + +switch (hw->device_id) { +case ICE_DEV_ID_E810C_QSFP : +return true; +default : +return false; + } +}
drivers/net/ethernet/intel/ice/ice_common.h +1 -0
@@ -304,4 +304,5 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,int ice_get_pca9575_handle (struct ice_hw *hw,u16 *pca9575_handle);int ice_read_pca9575_reg (struct ice_hw *hw,u8 offset,u8 *data);bool ice_fw_supports_report_dflt_cfg (struct ice_hw *hw); +bool ice_set_has_gpios (struct ice_hw *hw);#endif /* _ICE_COMMON_H_ */
drivers/net/ethernet/intel/ice/ice_ethtool.c +72 -0
84 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -5294,6 +5294,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) hw->port_info =NULL ; hw->vendor_id = pdev->vendor; hw->device_id = pdev->device; + hw->has_gpios =ice_set_has_gpios (hw);pci_read_config_byte (pdev,PCI_REVISION_ID , &hw->revision_id); hw->subsystem_vendor_id = pdev->subsystem_vendor; hw->subsystem_device_id = pdev->subsystem_device;
drivers/net/ethernet/intel/ice/ice_type.h +2 -0
@@ -896,6 +896,8 @@ struct ice_hw {u64 debug_mask;/* bitmap for debug mask */ enum ice_mac_type mac_type; +bool has_gpios; +u16 fd_ctr_base;/* FD counter base index */ /* pci info */
Signature · 1 line
2.47.0
Quoted 11 lines · On Mon, 7 Apr 2025 12:35:37 +0000 Marek Pazdan <[email protected]> wrote:
Signal Definition section (Other signals) of SFF-8636 Spec mentions that additional signals like reset and module present may be implemented for a specific hardware. There is currently no user space API for control of those signals so user space management applications have no chance to perform some diagnostic or configuration operations. This patch uses get_phy_tunable/set_phy_tunable ioctl API to provide above control to user space. Despite ethtool reset option seems to be more suitable for transceiver module reset control, ethtool reset doesn't allow for reset pin assertion and deassertion. Userspace API may require control over when pin will be asserte and deasserted so we cannot trigger reset and leave it to the driver when deassert should be perfromed.
nit: performed
ETHTOOL_PHY_G/STUNABLE IOCTLs are targeting the PHY of the NIC but IIUC in your case you are targeting the reset of the QSFP module. Maybe phylink API is more appropriate for this feature.
You have to add net-next prefix in the subject like this [PATCH net-next 1/2] when you add new support to net subsystem.
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH 2/2] ice: add qsfp transceiver reset and presence pin control
In reply to Marek PazdanQuoted 3 lines · On Mon, 7 Apr 2025 12:35:38 +0000 Marek Pazdan <[email protected]> wrote:
Commit
f3c1c896f5a8("ethtool: transceiver reset and presence pin control") adds ioctl API extension for get/set-phy-tunable so that transceiver reset and presence pin control is enabled.
I don't think pointing and explaining the first commit is relevant here.
Quoted 1 line
This commit adds functionality to utilize the API in ice driver.
Please do not use "This commit/patch/change", but imperative mood. See longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
You could simply write:
Add support for the newly introduced transceiver reset feature in the ice driver.
Quoted 3 lines
According to E810 datasheet QSFP reset and presence pins are being connected to SDP0 and SDP2 pins on controller host. Those pins can be accessed using AQ commands for GPIO get/set.[O
Weird character at the end.
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Andrew Lunn
maintainerRe: [PATCH 2/2] ice: add qsfp transceiver reset and presence pin control
In reply to Marek PazdanQuoted 3 lines · Marek Pazdan
Commit
f3c1c896f5a8("ethtool: transceiver reset and presence pin control") adds ioctl API extension for get/set-phy-tunable so that transceiver reset and presence pin control is enabled.
As the name get/set-phy-tunable suggests, these are for PHY properties, like downshift, fast link down, energy detected power down.
What PHY are you using here?
Andrew
Andrew Lunn
maintainerQuoted 5 lines · Marek Pazdan
Signal Definition section (Other signals) of SFF-8636 Spec mentions that additional signals like reset and module present may be implemented for a specific hardware. There is currently no user space API for control of those signals so user space management applications have no chance to perform some diagnostic or configuration operations.
How do you tell the kernel to stop managing the SFP? If you hit the module with a reset from user space, the kernel is going to get confused. And how are you talking to the module? Are you going to hijack the i2c device via i2-dev? Again, you need to stop the kernel from using the device.
Before you go any further, i think you need to zoom out and tell us the big picture....
Andrew
Re: [Intel-wired-lan] [PATCH 2/2] ice: add qsfp transceiver reset and presence pin control
In reply to Andrew LunnQuoted 5 lines · On Mon, 7 Apr 2025 22:30:54 +0200 Andrew Lunn wrote:
As the name get/set-phy-tunable suggests, these are for PHY properties, like downshift, fast link down, energy detected power down.
What PHY are you using here?
Thanks for review.
It's PHY E810-C in this case. According to spreadsheet: E810_Datasheet_Rev2.4.pdf (Chapter 17.3.3 E810 SDP[0:7] (GPIO) Connection), it's SDP0 and SDP2 GPIOs
are being connected to QSFP Reset and Presence pins correspondingly.
I assume you may suggest this use case is not directly PHY related. In first approach I tried to use reset operation which has following flag in enum ethtool_reset_flags:ETH_RESET_PHY = 1 << 6, /* Transceiver/PHY */
but this doesn't allow for reset asserting and later deasserting so I took 'get/set-phy-tunable'.
Andrew Lunn
maintainerRe: [Intel-wired-lan] [PATCH 2/2] ice: add qsfp transceiver reset and presence pin control
Quoted 8 lines · Marek Pazdan
Quoted 5 lines · On Mon, 7 Apr 2025 22:30:54 +0200 Andrew Lunn wrote:
As the name get/set-phy-tunable suggests, these are for PHY properties, like downshift, fast link down, energy detected power down.
What PHY are you using here?
Quoted 8 lines
Thanks for review.
It's PHY E810-C in this case. According to spreadsheet: E810_Datasheet_Rev2.4.pdf (Chapter 17.3.3 E810 SDP[0:7] (GPIO) Connection), it's SDP0 and SDP2 GPIOs
are being connected to QSFP Reset and Presence pins correspondingly.
I assume you may suggest this use case is not directly PHY related. In first approach I tried to use reset operation which has following flag in enumethtool_reset_flags:ETH_RESET_PHY= 1 << 6, /* Transceiver/PHY */
but this doesn't allow for reset asserting and later deasserting so I took 'get/set-phy-tunable'.
This does look like an abuse of the phy tunables. Lets get the big picture, and then we can maybe suggest a better API.
Please consider my previous questions, how do you tell the kernel not to use the SFP? How do you ensure you don't reset the SFP in the middle of the kernel performing a firmware upgrade of the SFP, etc.
Andrew
Quoted 5 lines · On Mon, 7 Apr 2025 22:39:17 +0200 Andrew Lunn wrote:
How do you tell the kernel to stop managing the SFP? If you hit the module with a reset from user space, the kernel is going to get confused. And how are you talking to the module? Are you going to hijack the i2c device via i2-dev? Again, you need to stop the kernel from using the device.
This is something to implement in driver code. For ice driver this reset will be executed through AQ command (Admin Queue) which is communication channel between driver and firmware. What I probably need to do is to add additional PHY state (like USER_MODULE_RESET) and check it when driver wants to execute AQ command.
Quoted 2 lines
Before you go any further, i think you need to zoom out and tell us the big picture....
In my use case I need to have ability to reset transceiver module. There are several reasons for that. Most common is to reinit module if case of error state. (this according to CMIS spec). Another use case is that in our switch's cli there is a command for transceiver reinitialisation which involves transceiver reset.
Quoted 6 lines · On Mon, 7 Apr 2025 15:32:03 +0200 Kory Maincent wrote:
ETHTOOL_PHY_G/STUNABLE IOCTLs are targeting the PHY of the NIC but IIUC in your case you are targeting the reset of the QSFP module. Maybe phylink API is more appropriate for this feature.
You have to add net-next prefix in the subject like this [PATCH net-next 1/2] when you add new support to net subsystem.
Thanks for review.
From up to now replies I see that there are concerns regarding usage phy-tunable ethtool option for this purpose, so I will post updated patches after we clarify proper way to go. I need to check more on phylink API, from the overview I read:
"phylink is a mechanism to support hot-pluggable networking modules directly connected to a MAC without needing to re-initialise the adapter on hot-plug events.
phylink supports conventional phylib-based setups, fixed link setups and SFP (Small Formfactor Pluggable) modules at present."
I don't see QSFP modules are being supported but I need to verify impact of this. As I mentioned in other reply this API should allow for transceiver module reset from user space if orchestration agent detects transceiver failure state or when it gets direct request from Cli.
Andrew Lunn
maintainerQuoted 12 lines · Marek Pazdan
Quoted 5 lines · On Mon, 7 Apr 2025 22:39:17 +0200 Andrew Lunn wrote:
How do you tell the kernel to stop managing the SFP? If you hit the module with a reset from user space, the kernel is going to get confused. And how are you talking to the module? Are you going to hijack the i2c device via i2-dev? Again, you need to stop the kernel from using the device.
This is something to implement in driver code. For ice driver this reset will be executed through AQ command (Admin Queue) which is communication channel between driver and firmware. What I probably need to do is to add additional PHY state (like
USER_MODULE_RESET) and check it when driver wants to execute AQ command.
Quoted 7 lines
Quoted 2 lines
Before you go any further, i think you need to zoom out and tell us the big picture....
In my use case I need to have ability to reset transceiver module. There are several reasons for that. Most common is to reinit module if case of error state. (this according to CMIS spec). Another use case is that in our switch's cli there is a command for transceiver reinitialisation which involves transceiver reset.
Now zoom out, ignore your hardware, look at the Linux abstraction for an SFP, across all NICs and switches.
There are ethtool calls to retrieve the modules eeprom contents. There is an ethtool call to program the modules firmware. There is an ethtool call to get/set the power mode. Modules can also export their sensors via HWMON, the temperature, receive power, etc.
How does your wish to reset the module fit into the general Linux model of an SFP? Should it be allowed in the middle of a firmware upgrade? Should the power mode be lost due to a reset? Can you still read from the EEPROM etc while it is in reset? What should HWMON report? Should it be a foot gun?
It does however seem to me, what you want should somehow be an ethtool operation. And it probably needs to be plumbed through net/ethtool/module.c, and you need to look at how it interacts with all the other code in that file. And you maybe need to force the netdev to do a down/up so that it gets the new state of the module, or you only allow it on an netdev which is admin down?
Your patch needs to explain the big picture, how it fits into the Linux abstraction of an SFP, and how other vendors should implement the same operation, if they wish to implement it.
Andrew
PATCH v2 2/2 ice: add qsfp transceiver reset, interrupt and presence pin control
In reply to Marek PazdanAdd get/set implenentation for ethtool's module management signal API.
Examples:
ethtool --get-module-mgmt-signal eth16 type reset
reset: low
ethtool --get-module-mgmt-signal eth16 type int
reset: low
ethtool --get-module-mgmt-signal eth16 type present
reset: high
sudo ethtool --set-module-mgmt-signal eth16 type reset value high ethtool --get-module-mgmt-signal eth16 type reset
reset: high
sudo ethtool --set-module-mgmt-signal eth16 type reset value low ethtool --get-module-mgmt-signal eth16 type reset
reset: low
Ice driver gets link event notification when module gets restarted. There is 'ice_handle_link_event' which handles the notification and updates link status information.
--- drivers/net/ethernet/intel/ice/ice.h | 6 ++ drivers/net/ethernet/intel/ice/ice_common.c | 21 +++++ drivers/net/ethernet/intel/ice/ice_common.h | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 94 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_type.h | 2 +- 6 files changed, 124 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice.h +6 -0
@@ -195,6 +195,12 @@#define ice_pf_src_tmr_owned (pf) ((pf)->hw.func_caps.ts_func_info.src_tmr_owned) +enum ice_mgmt_pin { +ICE_MGMT_PIN_RESET =0 , +ICE_MGMT_PIN_INT , +ICE_MGMT_PIN_PRESENT +}; +enum ice_feature {ICE_F_DSCP ,ICE_F_PHY_RCLK ,
drivers/net/ethernet/intel/ice/ice_common.c +21 -0
@@ -6096,3 +6096,24 @@ u32 ice_get_link_speed(u16 index)return ice_aq_to_link_speed[index]; } + +/** +* ice_set_has_gpios - Sets availability of SDP GPIO pins. +* @hw: pointer to the HW structure +* +* This function sets availability of GPIO software defined pins +* (SDP) which are connected to transceiver slots and are used +* for transceiver control. +*/ +bool ice_set_has_gpios (struct ice_hw *hw) +{ +if (hw->vendor_id !=PCI_VENDOR_ID_INTEL ) +return false; + +switch (hw->device_id) { +case ICE_DEV_ID_E810C_QSFP : +return true; +default : +return false; + } +}
drivers/net/ethernet/intel/ice/ice_common.h +1 -0
@@ -304,4 +304,5 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,int ice_get_pca9575_handle (struct ice_hw *hw,u16 *pca9575_handle);int ice_read_pca9575_reg (struct ice_hw *hw,u8 offset,u8 *data);bool ice_fw_supports_report_dflt_cfg (struct ice_hw *hw); +bool ice_set_has_gpios (struct ice_hw *hw);#endif /* _ICE_COMMON_H_ */
drivers/net/ethernet/intel/ice/ice_ethtool.c +94 -0
112 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -5294,6 +5294,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) hw->port_info =NULL ; hw->vendor_id = pdev->vendor; hw->device_id = pdev->device; + hw->has_module_mgmt_gpio =ice_set_has_gpios (hw);pci_read_config_byte (pdev,PCI_REVISION_ID , &hw->revision_id); hw->subsystem_vendor_id = pdev->subsystem_vendor; hw->subsystem_device_id = pdev->subsystem_device;
drivers/net/ethernet/intel/ice/ice_type.h +1 -1
@@ -895,7 +895,7 @@ struct ice_hw {u32 psm_clk_freq;u64 debug_mask;/* bitmap for debug mask */ enum ice_mac_type mac_type; - +bool has_module_mgmt_gpio;/* has GPIO for module management */ u16 fd_ctr_base;/* FD counter base index */ /* pci info */
Signature · 1 line
2.45.2
PATCH v2 1/2 ethtool: qsfp transceiver reset, interrupt and presence pin control
In reply to Andrew LunnCommon Management Interface Specification defines
Management Signaling Layer (MSL) control and status signals. This change provides API for following signals status reading:
- signal allowing the host to request module reset (Reset)
- signal allowing the host to detect module presence (Presence)
- signal allowing the host to detect module interrupt (Int) Additionally API allows for Reset signal assertion with following constraints:
- reset cannot be asserted if firmware update is in progress
- if reset is asserted, firmware update cannot be started
- if reset is asserted, power mode cannot be get/set
In all above constraint cases -EBUSY error is returned.
After reset, module will set all registers to default
values. Default value for Page0 byte 93 register is 0x00 what implies that module power mode after reset depends on LPMode HW pin state. If software power mode control is required, bit 0 of Page0 byte93 needs to be enabled.
Module reset assertion implies failure of every module's related SMBus transactions. Device driver developers should take this into consideration if driver provides API for querying module's related data. One example can be HWMON providing module temperature report. In such case driver should monitor module status and in time of reset assertion it should return HWMON report which informs that temperature data is not available due to module's reset state.
The same applies to power mode set/get. Ethtool API has already checking for module reset state but similar checking needs to be implemented in the driver if it requests power mode for other functionality.
Additionally module reset is link hitful operation. Link is brought down when reset is asserted. If device driver doesn't provide functionality for monitoring transceiver state, it needs to be implemented in parallel to get/set_module_mgmt_signal API. When module reset gets deasserted, transceiver process reinitialization. The end of reinitialization process is signalled via Page 00h Byte 6 bit 0 "Initialization complete flags". If there is no implementation for monitoring this bit in place, it needs to be added to bring up the link after transceiver initialization is complete.
--- Documentation/netlink/specs/ethtool.yaml | 48 +++++ include/linux/ethtool.h | 29 ++- include/uapi/linux/ethtool.h | 29 +++ net/ethtool/module.c | 230 +++++++++++++++++++++-- net/ethtool/netlink.c | 20 ++ net/ethtool/netlink.h | 3 + 6 files changed, 347 insertions(+), 12 deletions(-)
Documentation/netlink/specs/ethtool.yaml +48 -0
@@ -1528,6 +1528,24 @@ attribute-sets: name: hwtstamp-flags type: nest nested-attributes: bitset + - + name: module-mgmt + attr-cnt-name: __ethtool-a-module-mgmt-cnt + attributes: + - + name: unspec + type: unused + value: 0 + - + name: header + type: nest + nested-attributes: header + - + name: type + type: u8 + - + name: value + type: u8 operations: enum-model: directional
@@ -2384,3 +2402,33 @@ operations: attributes: *tsconfig reply: attributes: *tsconfig + - + name: module-mgmt-get + doc: Get module management signal status. + + attribute-set: module-mgmt + + do: &module-mgmt-get-op + request: + attributes: + - header + - type + reply: + attributes: &module-mgmt + - header + - type + - value + dump: *module-mgmt-get-op + - + name: module-mgmt-set + doc: Set module management signal state. + + attribute-set: module-mgmt + + do: + request: + attributes: *module-mgmt + - + name: module-mgmt-ntf + doc: Notification for change in module management signal status. + notify: module-mgmt-get
include/linux/ethtool.h +28 -1
@@ -126,6 +126,7 @@ enum ethtool_supported_ring_param {struct net_device ;struct netlink_ext_ack ; +struct ethtool_module_mgmt_params ;/* Link extended state and substate. */ struct ethtool_link_ext_state_info {
@@ -626,6 +627,19 @@ struct ethtool_module_power_mode_params {enum ethtool_module_power_mode mode; }; +/** +* struct ethtool_module_mgmt_params - module management signal parameters +* @type: The management signal type of the MSL (Management Signaling Layer) signal +* connecting host with the plug-in module to be set or get. +* @value: The management signal value of the MSL signal connecting host with +* the plug-in module. It is filled by user for set operation or by +* the driver for get operation. +*/ +struct ethtool_module_mgmt_params { +enum ethtool_module_mgmt_signal_type type; +enum ethtool_module_mgmt_signal_value value; +}; +/** * struct ethtool_mm_state - 802.3 MAC merge layer state * @verify_time:
@@ -985,6 +999,11 @@ struct kernel_ethtool_ts_info {* plugged-in. * @set_module_power_mode: Set the power mode policy for the plug-in module * used by the network device. +* @get_module_mgmt_signal: Get the MSL (Management Signaling Layer) signal +* value for the plug-in module used by network device. MSL layer +* description is included in CMIS Common Management Interface Specification. +* @set_module_mgmt_signal: Set the MSL (Management Signaling Layer) output +* signal value for the plug-in module used by network device, if plugged-in. * @get_mm: Query the 802.3 MAC Merge layer state. * @set_mm: Set the 802.3 MAC Merge layer parameters. * @get_mm_stats: Query the 802.3 MAC Merge layer statistics.
@@ -1146,6 +1165,12 @@ struct ethtool_ops {int (*set_module_power_mode)(struct net_device *dev,const struct ethtool_module_power_mode_params *params,struct netlink_ext_ack *extack); +int (*get_module_mgmt_signal)(struct net_device *dev, +struct ethtool_module_mgmt_params *params, +struct netlink_ext_ack *extack); +int (*set_module_mgmt_signal)(struct net_device *dev, +const struct ethtool_module_mgmt_params *params, +struct netlink_ext_ack *extack);int (*get_mm)(struct net_device *dev,struct ethtool_mm_state *state);int (*set_mm)(struct net_device *dev,struct ethtool_mm_cfg *cfg,struct netlink_ext_ack *extack);
@@ -1179,13 +1204,15 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,* @rss_lock: Protects entries in @rss_ctx. May be taken from * within RTNL. * @wol_enabled: Wake-on-LAN is enabled -* @module_fw_flash_in_progress: Module firmware flashing is in progress. +* @module_fw_flash_in_progress: Module firmware flashing is in progress. +* @module_reset_asserted: Module reset signal is asserted. */ struct ethtool_netdev_state {struct xarray rss_ctx;struct mutex rss_lock;unsigned wol_enabled:1 ;unsigned module_fw_flash_in_progress:1 ; +unsigned module_reset_asserted:1 ; };struct phy_device ;
include/uapi/linux/ethtool.h +29 -0
@@ -756,6 +756,35 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; +/** +* enum ethtool_module_mgmt_signal_type - plug-in module discrete +* status hardware signals for management as per CMIS spec. +* @ETHTOOL_MODULE_MGMT_RESET: Signal allowing the host to request +* a module reset. +* @ETHTOOL_MODULE_MGMT_INT: Signal allowing the module to assert +* an interrupt request to the host. +* @ETHTOOL_MODULE_MGMT_PRESENT: Signal allowing the module to signal +* its presence status to the host. +*/ +enum ethtool_module_mgmt_signal_type { +ETHTOOL_MODULE_MGMT_RESET =1 , +ETHTOOL_MODULE_MGMT_INT , +ETHTOOL_MODULE_MGMT_PRESENT , +}; + +/** +* enum ethtool_module_mgmt_signal_value - Value of plug-in module +* hardware signal status for management signaling +* as specified in CMIS spec. +* @ETHTOOL_MODULE_MGMT_SIGNAL_LOW: Signal low value. +* @ETHTOOL_MODULE_MGMT_SIGNAL_HIGH: Signal high value. +* for reset signal when plug-in module is not inserted. +*/ +enum ethtool_module_mgmt_signal_value { +ETHTOOL_MODULE_MGMT_SIGNAL_LOW =1 , +ETHTOOL_MODULE_MGMT_SIGNAL_HIGH , +}; +/** * enum ethtool_c33_pse_ext_state - groups of PSE extended states * functions. IEEE 802.3-2022 33.2.4.4 Variables
net/ethtool/module.c +219 -11
263 lines not on this page · raw message
net/ethtool/netlink.c +20 -0
@@ -400,6 +400,8 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_MM_SET] = ðnl_mm_request_ops, [ETHTOOL_MSG_TSCONFIG_GET] = ðnl_tsconfig_request_ops, [ETHTOOL_MSG_TSCONFIG_SET] = ðnl_tsconfig_request_ops, + [ETHTOOL_MSG_MODULE_MGMT_GET] = ðnl_module_mgmt_request_ops, + [ETHTOOL_MSG_MODULE_MGMT_SET] = ðnl_module_mgmt_request_ops, };static struct ethnl_dump_ctx *ethnl_dump_context (struct netlink_callback *cb)
@@ -755,6 +757,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_MODULE_NTF] = ðnl_module_request_ops, [ETHTOOL_MSG_PLCA_NTF] = ðnl_plca_cfg_request_ops, [ETHTOOL_MSG_MM_NTF] = ðnl_mm_request_ops, + [ETHTOOL_MSG_MODULE_MGMT_NTF] = ðnl_module_mgmt_request_ops, };/* default notification handler */
@@ -856,6 +859,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify, [ETHTOOL_MSG_PLCA_NTF] = ethnl_default_notify, [ETHTOOL_MSG_MM_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_MODULE_MGMT_NTF] = ethnl_default_notify, };void ethtool_notify (struct net_device *dev,unsigned int cmd,const void *data)
@@ -1294,6 +1298,22 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_tsconfig_set_policy, .maxattr = ARRAY_SIZE(ethnl_tsconfig_set_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_MODULE_MGMT_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_module_mgmt_get_policy, + .maxattr = ARRAY_SIZE(ethnl_module_mgmt_get_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_MODULE_MGMT_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_default_set_doit, + .policy = ethnl_module_mgmt_set_policy, + .maxattr = ARRAY_SIZE(ethnl_module_mgmt_set_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
net/ethtool/netlink.h +3 -0
@@ -437,6 +437,7 @@ extern const struct ethnl_request_ops ethnl_plca_status_request_ops;extern const struct ethnl_request_ops ethnl_mm_request_ops;extern const struct ethnl_request_ops ethnl_phy_request_ops;extern const struct ethnl_request_ops ethnl_tsconfig_request_ops; +extern const struct ethnl_request_ops ethnl_module_mgmt_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 ];
@@ -489,6 +490,8 @@ extern const struct nla_policy ethnl_module_fw_flash_act_policy[ETHTOOL_A_MODULEextern const struct nla_policy ethnl_phy_get_policy[ETHTOOL_A_PHY_HEADER +1 ];extern const struct nla_policy ethnl_tsconfig_get_policy[ETHTOOL_A_TSCONFIG_HEADER +1 ];extern const struct nla_policy ethnl_tsconfig_set_policy[ETHTOOL_A_TSCONFIG_MAX +1 ]; +extern const struct nla_policy ethnl_module_mgmt_get_policy[ETHTOOL_A_MODULE_MGMT_TYPE +1 ]; +extern const struct nla_policy ethnl_module_mgmt_set_policy[ETHTOOL_A_MODULE_MGMT_VALUE +1 ];int ethnl_set_features (struct sk_buff *skb,struct genl_info *info);int ethnl_act_cable_test (struct sk_buff *skb,struct genl_info *info);
Signature · 1 line
2.45.2
Jakub Kicinski
maintainerRe: [PATCH net-next v2 1/2] ethtool: qsfp transceiver reset, interrupt and presence pin control
Quoted 39 lines · On Tue, 13 May 2025 22:40:00 +0000 Marek Pazdan wrote:
Common Management Interface Specification defines
Management Signaling Layer (MSL) control and status signals. This change provides API for following signals status reading:
- signal allowing the host to request module reset (Reset)
- signal allowing the host to detect module presence (Presence)
- signal allowing the host to detect module interrupt (Int) Additionally API allows for Reset signal assertion with following constraints:
- reset cannot be asserted if firmware update is in progress
- if reset is asserted, firmware update cannot be started
- if reset is asserted, power mode cannot be get/set
In all above constraint cases-EBUSYerror is returned.After reset, module will set all registers to default
values. Default value for Page0 byte 93 register is0x00what implies that module power mode after reset depends on LPMode HW pin state. If software power mode control is required, bit 0 of Page0 byte93 needs to be enabled.
Module reset assertion implies failure of every module's related SMBus transactions. Device driver developers should take this into consideration if driver provides API for querying module's related data. One example can be HWMON providing module temperature report. In such case driver should monitor module status and in time of reset assertion it should return HWMON report which informs that temperature data is not available due to module's reset state.
The same applies to power mode set/get. Ethtool API has already checking for module reset state but similar checking needs to be implemented in the driver if it requests power mode for other functionality.
Additionally module reset is link hitful operation. Link is brought down when reset is asserted. If device driver doesn't provide functionality for monitoring transceiver state, it needs to be implemented in parallel to get/set_module_mgmt_signal API. When module reset gets deasserted, transceiver process reinitialization. The end of reinitialization process is signalled via Page 00h Byte 6 bit 0 "Initialization complete flags". If there is no implementation for monitoring this bit in place, it needs to be added to bring up the link after transceiver initialization is complete.
Quoted 1 line
Signed-off-by Marek Pazdan <[email protected]>
A few drive by comments, I leave the real review to Andrew.
Instead of posting in-reply-to please add lore links to previous
versions, eg.
v2:
https://lore.kernel.org/all/[email protected]/ under the --- separator.
I almost missed this posting.
When you post v3 please make sure to CC Ido and Danielle who implemented the FW flashing for modules.
Quoted 6 lines
Documentation/netlink/specs/ethtool.yaml +0
-0@@ -1528,6 +1528,24 @@ attribute-sets: name: hwtstamp-flags
Documentation/netlink/specs/ethtool.yaml attribute-sets: · line 1538
Quoted 10 lines
Documentation/netlink/specs/ethtool.yaml +8
-0type: nest nested-attributes: bitset + - + name: module-mgmt + attr-cnt-name: __ethtool-a-module-mgmt-cnt + attributes: + - + name: unspec + type: unused + value: 0
no need, just skip the unspec attr and YNL will number the first one from 1 keeping 0 as rejected type.
Documentation/netlink/specs/ethtool.yaml attribute-sets: · line 1545
Quoted 7 lines
Documentation/netlink/specs/ethtool.yaml +7
-0+ - + name: header + type: nest + nested-attributes: header + - + name: type + type: u8
u32 will give us more flexibility later. And attr sizes in netlink are aligned to 4B so a u8 consumes 4 bytes anyway.
Documentation/netlink/specs/ethtool.yaml attribute-sets: · line 1548
Quoted 3 lines
Documentation/netlink/specs/ethtool.yaml +3
-0+ - + name: value + type: u8
Do you think we'll never need to set / clear / change multiple bits at once? We could wrap the type / value into a nest and support repeating that nest (multi-attr: true)
Documentation/netlink/specs/ethtool.yaml attribute-sets:
Quoted 9 lines
Documentation/netlink/specs/ethtool.yaml +9
-0+/** + * enum ethtool_module_mgmt_signal_type - plug-in module discrete + * status hardware signals for management as per CMIS spec. + * @ETHTOOL_MODULE_MGMT_RESET: Signal allowing the host to request + * a module reset. + * @ETHTOOL_MODULE_MGMT_INT: Signal allowing the module to assert + * an interrupt request to the host. + * @ETHTOOL_MODULE_MGMT_PRESENT: Signal allowing the module to signal + * its presence status to the host.
Not sure what the use case would be for setting INT and PRESENT. So the combined API (driver facing) to treat RESET and read-only bits as equivalent may not be the best fit. Just a feeling tho.
Documentation/netlink/specs/ethtool.yaml
Quoted 5 lines
+ */
Documentation/netlink/specs/ethtool.yaml +4
-0+enum ethtool_module_mgmt_signal_type { + ETHTOOL_MODULE_MGMT_RESET = 1, + ETHTOOL_MODULE_MGMT_INT, + ETHTOOL_MODULE_MGMT_PRESENT,
Please define the enums in the YNL spec, see
https://lore.kernel.org/all/[email protected]/
Andrew Lunn
maintainerRe: [PATCH net-next v2 1/2] ethtool: qsfp transceiver reset, interrupt and presence pin control
In reply to Marek PazdanQuoted 6 lines · Marek Pazdan
Common Management Interface Specification defines
Management Signaling Layer (MSL) control and status signals. This change provides API for following signals status reading:
- signal allowing the host to request module reset (Reset)
- signal allowing the host to detect module presence (Presence)
- signal allowing the host to detect module interrupt (Int)
What is missing from here is the use cases you are trying to address. Why should user space want to reset the module? Why does user spare care if there is a module inserted or not. What is user space going to do with an interrupt?
Quoted 6 lines
Additionally API allows for Reset signal assertion with following constraints:
- reset cannot be asserted if firmware update is in progress
- if reset is asserted, firmware update cannot be started
- if reset is asserted, power mode cannot be get/set In all above constraint cases-EBUSYerror is returned.
Seems like there should be one more condition. Reset cannot be asserted if the interface is admin up. I assume a reset is disruptive to the link, so you don't want it to happen when the link is in use.
net/ethtool/module.c const struct ethnl_request_ops ethnl_module_request_ops = { · line 225
Quoted 11 lines
net/ethtool/module.c +11
-0+static int module_mgmt_get (struct net_device *dev, +struct module_mgmt_reply_data *data, +const struct genl_info *info) +{ +const struct ethtool_ops *ops = dev->ethtool_ops; +struct netlink_ext_ack *extack = info ? info->extack :NULL ; + +if (!ops->get_module_mgmt_signal) +return -EOPNOTSUPP ; + +return ops->get_module_mgmt_signal (dev, &data->mgmt, extack);
Should there be a module_busy() check here? Can you get these parameters if the module is in reset?
Andrew
Andrew Lunn
maintainerRe: [Intel-wired-lan] [PATCH net-next v2 2/2] ice: add qsfp transceiver reset, interrupt and presence pin control
In reply to Marek PazdanQuoted 16 lines
+ *
ice_get_module_mgmt_signal- get module management signal status
+ * @dev: network interface device structure
+ * @params: ethtool module management signal params
+ * @extack: extended ACK from the Netlink message
+ *
+ * Returns-EIOif AQ command for GPIO get failed, otherwise
+ * returns 0 and current status of requested signal in params.
+ */drivers/net/ethernet/intel/ice/ice_ethtool.c +8
-0+static int +ice_get_module_mgmt_signal (struct net_device *dev, +struct ethtool_module_mgmt_params *params, +struct netlink_ext_ack *extack) +{ +struct ice_netdev_priv *np =netdev_priv (dev); +struct ice_pf *pf = np->vsi->back; +struct ice_hw *hw = &pf->hw;
drivers/net/ethernet/intel/ice/ice_ethtool.c ice_get_channels(struct net_device *dev, struct ethtool_channels *ch) · line 3877
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ethtool.c +10
-0+u16 gpio_handle =0 ;/* SOC/on-chip GPIO */ +bool value; +int ret =0 ; + +if (hw->has_module_mgmt_gpio) { +switch (params->type) { +case ETHTOOL_MODULE_MGMT_RESET : + ret =ice_aq_get_gpio (hw, gpio_handle, +ICE_MGMT_PIN_RESET , &value,NULL ); +break ;
Reset, i can kind of understand being used this way.
drivers/net/ethernet/intel/ice/ice_ethtool.c ice_get_channels(struct net_device *dev, struct ethtool_channels *ch) · line 3885
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ethtool.c +8
-0+case ETHTOOL_MODULE_MGMT_INT : + ret =ice_aq_get_gpio (hw, gpio_handle, +ICE_MGMT_PIN_INT , &value,NULL ); +break ; +case ETHTOOL_MODULE_MGMT_PRESENT : + ret =ice_aq_get_gpio (hw, gpio_handle, +ICE_MGMT_PIN_PRESENT , &value,NULL ); +break ;
but not these two. These represent events. I've not looked at the datasheet... Does the GPIO controller support interrupts? For PRESENT you are interested in the edges, maybe with some debounce logic. For INT, i _guess_ it is active low? But i've no idea what user space is going to actually do on an interrupt, and how is it going to clear the interrupt? This smells like a user space driver, which is not something we want. Even if there is a legitimate use case, which there might be for PRESENT, polling does not make much sense when the kernel can broadcast a netlink message to user space if the GPIO controller has interrupt support.
Andrew
---
pw-bot: cr