dd LED support for fbnic
Subsystems (4)
cover dd LED support for fbnic
From: "Mike Marciniszyn (Meta)" <[email protected]>
Add support for fbnic leds in three patches.
The first patch adds the trigger support for the higher fbnic speeds.
The second patch stors the max speed from the firmware dialog to give the LED code a way to determine if the led needs to show amber (not full speed) or blue (at full speed).
The third patch adds the fbnic specific code to manipulate the LEDS as well as the /sys/class/leds support for user space access.
Mike Marciniszyn (Meta) (3):
leds: trigger: netdev: Extend speeds up to 100G
net: eth: fbnic: Store max_speed from firmware dialog
net: eth: fbnic: Add led support
drivers/leds/trigger/ledtrig-netdev.c | 46 +++- drivers/net/ethernet/meta/Kconfig | 8 + drivers/net/ethernet/meta/fbnic/Makefile | 2 + drivers/net/ethernet/meta/fbnic/fbnic.h | 13 + drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 15 ++ .../net/ethernet/meta/fbnic/fbnic_devlink.c | 4 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 59 +++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 3 + drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 3 + drivers/net/ethernet/meta/fbnic/fbnic_led.c | 228 +++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_mac.c | 239 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_mac.h | 62 +++++ drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 8 + .../net/ethernet/meta/fbnic/fbnic_phylink.c | 2 + include/linux/leds.h | 4 + 15 files changed, 695 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/meta/fbnic/fbnic_led.c
Signature · 1 line
2.43.0
PATCH 1/3 leds: trigger: netdev: Extend speeds up to 100G
From: "Mike Marciniszyn (Meta)" <[email protected]>
Add 25G, 40G, 50G, and 100G as available speeds to the netdev LED trigger.
--- drivers/leds/trigger/ledtrig-netdev.c | 46 ++++++++++++++++++++++++++- include/linux/leds.h | 4 +++ 2 files changed, 49 insertions(+), 1 deletion(-)
drivers/leds/trigger/ledtrig-netdev.c +45 -1
@@ -128,6 +128,22 @@ static void set_baseline_state(struct led_netdev_data *trigger_data) trigger_data->link_speed == SPEED_10000) blink_on = true; +if (test_bit (TRIGGER_NETDEV_LINK_25000 , &trigger_data->mode) && + trigger_data->link_speed ==SPEED_25000 ) + blink_on = true; + +if (test_bit (TRIGGER_NETDEV_LINK_40000 , &trigger_data->mode) && + trigger_data->link_speed ==SPEED_40000 ) + blink_on = true; + +if (test_bit (TRIGGER_NETDEV_LINK_50000 , &trigger_data->mode) && + trigger_data->link_speed ==SPEED_50000 ) + blink_on = true; + +if (test_bit (TRIGGER_NETDEV_LINK_100000 , &trigger_data->mode) && + trigger_data->link_speed ==SPEED_100000 ) + blink_on = true; +if (test_bit (TRIGGER_NETDEV_HALF_DUPLEX , &trigger_data->mode) && trigger_data->duplex ==DUPLEX_HALF ) blink_on = true;
@@ -337,6 +353,10 @@ static ssize_t netdev_led_attr_show(struct device *dev, char *buf,case TRIGGER_NETDEV_LINK_2500 :case TRIGGER_NETDEV_LINK_5000 :case TRIGGER_NETDEV_LINK_10000 : +case TRIGGER_NETDEV_LINK_25000 : +case TRIGGER_NETDEV_LINK_40000 : +case TRIGGER_NETDEV_LINK_50000 : +case TRIGGER_NETDEV_LINK_100000 :case TRIGGER_NETDEV_HALF_DUPLEX :case TRIGGER_NETDEV_FULL_DUPLEX :case TRIGGER_NETDEV_TX :
@@ -373,6 +393,10 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,case TRIGGER_NETDEV_LINK_2500 :case TRIGGER_NETDEV_LINK_5000 :case TRIGGER_NETDEV_LINK_10000 : +case TRIGGER_NETDEV_LINK_25000 : +case TRIGGER_NETDEV_LINK_40000 : +case TRIGGER_NETDEV_LINK_50000 : +case TRIGGER_NETDEV_LINK_100000 :case TRIGGER_NETDEV_HALF_DUPLEX :case TRIGGER_NETDEV_FULL_DUPLEX :case TRIGGER_NETDEV_TX :
@@ -396,7 +420,11 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,test_bit (TRIGGER_NETDEV_LINK_1000 , &mode) ||test_bit (TRIGGER_NETDEV_LINK_2500 , &mode) ||test_bit (TRIGGER_NETDEV_LINK_5000 , &mode) || - test_bit(TRIGGER_NETDEV_LINK_10000, &mode))) +test_bit (TRIGGER_NETDEV_LINK_10000 , &mode) || +test_bit (TRIGGER_NETDEV_LINK_25000 , &mode) || +test_bit (TRIGGER_NETDEV_LINK_40000 , &mode) || +test_bit (TRIGGER_NETDEV_LINK_50000 , &mode) || + test_bit(TRIGGER_NETDEV_LINK_100000, &mode))) return -EINVAL;cancel_delayed_work_sync (&trigger_data->work);
@@ -433,6 +461,10 @@ DEFINE_NETDEV_TRIGGER(link_1000, TRIGGER_NETDEV_LINK_1000);DEFINE_NETDEV_TRIGGER (link_2500,TRIGGER_NETDEV_LINK_2500 );DEFINE_NETDEV_TRIGGER (link_5000,TRIGGER_NETDEV_LINK_5000 );DEFINE_NETDEV_TRIGGER (link_10000,TRIGGER_NETDEV_LINK_10000 ); +DEFINE_NETDEV_TRIGGER (link_25000,TRIGGER_NETDEV_LINK_25000 ); +DEFINE_NETDEV_TRIGGER (link_40000,TRIGGER_NETDEV_LINK_40000 ); +DEFINE_NETDEV_TRIGGER (link_50000,TRIGGER_NETDEV_LINK_50000 ); +DEFINE_NETDEV_TRIGGER (link_100000,TRIGGER_NETDEV_LINK_100000 );DEFINE_NETDEV_TRIGGER (half_duplex,TRIGGER_NETDEV_HALF_DUPLEX );DEFINE_NETDEV_TRIGGER (full_duplex,TRIGGER_NETDEV_FULL_DUPLEX );DEFINE_NETDEV_TRIGGER (tx,TRIGGER_NETDEV_TX );
@@ -521,6 +553,10 @@ static umode_t netdev_trig_link_speed_visible(struct kobject *kobj,CHECK_LINK_MODE_ATTR (2500 );CHECK_LINK_MODE_ATTR (5000 );CHECK_LINK_MODE_ATTR (10000 ); +CHECK_LINK_MODE_ATTR (25000 ); +CHECK_LINK_MODE_ATTR (40000 ); +CHECK_LINK_MODE_ATTR (50000 ); +CHECK_LINK_MODE_ATTR (100000 ); }return 0 ;
@@ -533,6 +569,10 @@ static struct attribute *netdev_trig_link_speed_attrs[] = { &dev_attr_link_2500.attr, &dev_attr_link_5000.attr, &dev_attr_link_10000.attr, + &dev_attr_link_25000.attr, + &dev_attr_link_40000.attr, + &dev_attr_link_50000.attr, + &dev_attr_link_100000.attr, NULL };
@@ -668,6 +708,10 @@ static void netdev_trig_work(struct work_struct *work)test_bit (TRIGGER_NETDEV_LINK_2500 , &trigger_data->mode) ||test_bit (TRIGGER_NETDEV_LINK_5000 , &trigger_data->mode) ||test_bit (TRIGGER_NETDEV_LINK_10000 , &trigger_data->mode) || +test_bit (TRIGGER_NETDEV_LINK_25000 , &trigger_data->mode) || +test_bit (TRIGGER_NETDEV_LINK_40000 , &trigger_data->mode) || +test_bit (TRIGGER_NETDEV_LINK_50000 , &trigger_data->mode) || +test_bit (TRIGGER_NETDEV_LINK_100000 , &trigger_data->mode) ||test_bit (TRIGGER_NETDEV_HALF_DUPLEX , &trigger_data->mode) ||test_bit (TRIGGER_NETDEV_FULL_DUPLEX , &trigger_data->mode); interval = jiffies_to_msecs(
include/linux/leds.h +4 -0
@@ -607,6 +607,10 @@ enum led_trigger_netdev_modes {TRIGGER_NETDEV_LINK_2500 ,TRIGGER_NETDEV_LINK_5000 ,TRIGGER_NETDEV_LINK_10000 , +TRIGGER_NETDEV_LINK_25000 , +TRIGGER_NETDEV_LINK_40000 , +TRIGGER_NETDEV_LINK_50000 , +TRIGGER_NETDEV_LINK_100000 ,TRIGGER_NETDEV_HALF_DUPLEX ,TRIGGER_NETDEV_FULL_DUPLEX , TRIGGER_NETDEV_TX,
Signature · 1 line
2.43.0
Re: [PATCH net-next 1/3] leds: trigger: netdev: Extend speeds up to 100G
Quoted 5 lines · On Wed, May 20, 2026 at 04:03:35PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
Add 25G, 40G, 50G, and 100G as available speeds to the netdev LED trigger.
Signed-off-by Mike Marciniszyn (Meta) <[email protected]>
Andrew
Lee Jones
maintainerRe: [PATCH net-next 1/3] leds: trigger: netdev: Extend speeds up to 100G
Quoted 8 lines · Andrew Lunn
Quoted 5 lines · On Wed, May 20, 2026 at 04:03:35PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
Add 25G, 40G, 50G, and 100G as available speeds to the netdev LED trigger.
Signed-off-by Mike Marciniszyn (Meta) <[email protected]>Reviewed-by Andrew Lunn <[email protected]>
Should I wait until the net reviews are satisfied or take this right away?
Signature · 1 line
Lee Jones
Re: [PATCH net-next 1/3] leds: trigger: netdev: Extend speeds up to 100G
Quoted 5 lines · Lee Jones
Quoted 3 lines · Andrew Lunn
Quoted 2 lines · On Wed, May 20, 2026 at 04:03:35PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Add 25G, 40G, 50G, and 100G as available speeds to the netdev LED trigger.
Signed-off-by Mike Marciniszyn (Meta) <[email protected]>Reviewed-by Andrew Lunn <[email protected]>Should I wait until the net reviews are satisfied or take this right away?
This one can be merged any time. The speeds are generic, so even if they are not used now, they can be in future.
Andrew
Re: (subset) [PATCH net-next 1/3] leds: trigger: netdev: Extend speeds up to 100G
In reply to [email protected]Quoted 1 line · On Wed, 20 May 2026 16:03:35 -0400, [email protected] wrote:
Add 25G, 40G, 50G, and 100G as available speeds to the netdev LED trigger.
Applied, thanks!
[1/3] leds: trigger: netdev: Extend speeds up to 100G
commit: bbd8b5bdb88bf15006b078f6a2a3b452ffaa10b4
--
Lee Jones [李琼斯]
PATCH 2/3 net: eth: fbnic: Store max_speed from firmware dialog
In reply to [email protected]From: "Mike Marciniszyn (Meta)" <[email protected]>
The OCP spec required LED signalling to signal the difference between both below and at max speed capability.
The firmware init dialog already contains that attribute so store it to support follow-on patches.
--- drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 3 +++ drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 3 +++ 2 files changed, 6 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_fw.c +3 -0
@@ -561,6 +561,7 @@ static const struct fbnic_tlv_index fbnic_fw_cap_resp_index[] = {FBNIC_TLV_ATTR_U32 (FBNIC_FW_CAP_RESP_ACTIVE_FW_SLOT ),FBNIC_TLV_ATTR_STRING (FBNIC_FW_CAP_RESP_VERSION_COMMIT_STR ,FBNIC_FW_CAP_RESP_COMMIT_MAX_SIZE ), +FBNIC_TLV_ATTR_U32 (FBNIC_FW_CAP_RESP_FW_MAX_LINK_SPEED ),FBNIC_TLV_ATTR_U32 (FBNIC_FW_CAP_RESP_BMC_ALL_MULTI ),FBNIC_TLV_ATTR_U32 (FBNIC_FW_CAP_RESP_FW_LINK_SPEED ), FBNIC_TLV_ATTR_U32(FBNIC_FW_CAP_RESP_FW_LINK_FEC),
@@ -667,6 +668,8 @@ static int fbnic_fw_parse_cap_resp(void *opaque, struct fbnic_tlv_msg **results) fbd->fw_cap.active_slot =fta_get_uint (results,FBNIC_FW_CAP_RESP_ACTIVE_FW_SLOT ); + fbd->fw_cap.max_link_speed = +fta_get_uint (results,FBNIC_FW_CAP_RESP_FW_MAX_LINK_SPEED ); fbd->fw_cap.link_speed =fta_get_uint (results,FBNIC_FW_CAP_RESP_FW_LINK_SPEED ); fbd->fw_cap.link_fec =
drivers/net/ethernet/meta/fbnic/fbnic_fw.h +3 -0
@@ -58,6 +58,7 @@ struct fbnic_fw_cap { u8 need_bmc_macda_sync : 1; u8 all_multi : 1;u8 link_speed; +u8 max_link_speed;u8 link_fec;u32 anti_rollback_version; };
@@ -241,6 +242,8 @@ enum {FBNIC_FW_CAP_RESP_STORED_CMRT_COMMIT_STR =0x10 ,FBNIC_FW_CAP_RESP_UEFI_VERSION =0x11 ,FBNIC_FW_CAP_RESP_UEFI_COMMIT_STR =0x12 , +FBNIC_FW_CAP_RESP_FW_MAX_LINK_SPEED =0x13 , +/* 0x14 reserved */ FBNIC_FW_CAP_RESP_ANTI_ROLLBACK_VERSION =0x15 , FBNIC_FW_CAP_RESP_MSG_MAX };
Signature · 1 line
2.43.0
PATCH 3/3 net: eth: fbnic: Add led support
In reply to [email protected]From: "Mike Marciniszyn (Meta)" <[email protected]>
This patch adds the LED support for fbnic and adds the user /sys/class/leds interfaces based on CONFIG_FBNIC_LEDS.
--- drivers/net/ethernet/meta/Kconfig | 8 + drivers/net/ethernet/meta/fbnic/Makefile | 2 + drivers/net/ethernet/meta/fbnic/fbnic.h | 13 + drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 15 ++ .../net/ethernet/meta/fbnic/fbnic_devlink.c | 4 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 59 +++++ drivers/net/ethernet/meta/fbnic/fbnic_led.c | 228 +++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_mac.c | 239 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_mac.h | 62 +++++ drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 8 + .../net/ethernet/meta/fbnic/fbnic_phylink.c | 2 + 11 files changed, 640 insertions(+) create mode 100644 drivers/net/ethernet/meta/fbnic/fbnic_led.c
drivers/net/ethernet/meta/Kconfig +8 -0
@@ -35,4 +35,12 @@ config FBNIC To compile this driver as a module, choose M here. The module will be called fbnic. MSI-X interrupt support is required. +config FBNIC_LEDS + def_bool LEDS_TRIGGER_NETDEV + depends on FBNIC && LEDS_CLASS + depends on LEDS_CLASS=y || FBNIC=m + help + Optional support for controlling the NIC LEDs with the netdev + LED trigger. + endif # NET_VENDOR_META
drivers/net/ethernet/meta/fbnic/Makefile +2 -0
@@ -26,3 +26,5 @@ fbnic-y := fbnic_csr.o \ fbnic_tlv.o \ fbnic_txrx.o \ # End of objects + +fbnic-$(CONFIG_FBNIC_LEDS) += fbnic_led.o
drivers/net/ethernet/meta/fbnic/fbnic.h +13 -0
@@ -97,6 +97,11 @@ struct fbnic_dev {struct fbnic_fw_log fw_log; +/* Used to synchronize updates to LED state and CSR */ +struct mutex led_mutex; +bool led_link_up; +struct fbnic_led_cdev leds[FBNIC_NUM_LEDS ]; +/* MDIO bus for PHYs */ struct mii_bus *mdio_bus;
@@ -243,6 +248,14 @@ void fbnic_dbg_exit(void);void fbnic_rpc_reset_valid_entries (struct fbnic_dev *fbd); +#if IS_ENABLED (CONFIG_FBNIC_LEDS ) +int fbnic_led_init (struct fbnic_dev *fbd); +void fbnic_led_exit (struct fbnic_dev *fbd); +#else +static inline int fbnic_led_init (struct fbnic_dev *fbd) {return 0 ; } +static inline void fbnic_led_exit (struct fbnic_dev *fbd) {} +#endif +int fbnic_mdiobus_create (struct fbnic_dev *fbd);void fbnic_csr_get_regs (struct fbnic_dev *fbd,u32 *data,u32 *regs_version);
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +15 -0
@@ -857,6 +857,21 @@ enum {#define FBNIC_SIG_PCS_INTR_LINK_DOWN CSR_BIT(1)#define FBNIC_SIG_PCS_INTR_LINK_UP CSR_BIT(0)#define FBNIC_SIG_PCS_INTR_MASK 0x11816/* 0x46058 */ +#define FBNIC_SIG_LED 0x11820/* 0x46080 */ +#define FBNIC_SIG_LED_OVERRIDE_EN CSR_GENMASK(2, 0) +#define FBNIC_SIG_LED_OVERRIDE_VAL CSR_GENMASK(6, 4) + +enum { +FBNIC_SIG_LED_OVERRIDE_ACTIVITY =0x1 , +FBNIC_SIG_LED_OVERRIDE_AMBER =0x2 , +FBNIC_SIG_LED_OVERRIDE_BLUE =0x4 , +}; + +#define FBNIC_SIG_LED_BLINK_RATE_MASK CSR_GENMASK(11, 8) +enum { +FBNIC_SIG_LED_BLINK_RATE_5HZ =0xf , +}; +#define FBNIC_CSR_END_SIG 0x1184e/* CSR section delimiter */ #define FBNIC_CSR_START_MAC_STAT 0x11a00
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +4 -0
@@ -622,6 +622,8 @@ void fbnic_devlink_free(struct fbnic_dev *fbd) {struct devlink *devlink =priv_to_devlink (fbd); +mutex_destroy (&fbd->led_mutex); +devlink_free (devlink); }
@@ -651,6 +653,8 @@ struct fbnic_dev *fbnic_devlink_alloc(struct pci_dev *pdev) fbd->mac_addr_boundary =FBNIC_RPC_TCAM_MACDA_DEFAULT_BOUNDARY ; +mutex_init (&fbd->led_mutex); +return fbd; }
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +59 -0
71 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +228 -0
228 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +239 -0
257 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_mac.h +62 -0
102 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +8 -0
@@ -368,9 +368,16 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)dev_err (&pdev->dev,"Netdev registration failed: %d\n" , err); goto ifm_destroy_ptp; } + err =fbnic_led_init (fbd); +if (err) { +dev_err (&pdev->dev,"led init failed: %d\n" , err); + goto led_init_fail; + }return 0 ; +led_init_fail: +fbnic_netdev_unregister (netdev); ifm_destroy_ptp:fbnic_ptp_destroy (fbd); ifm_free_netdev:
@@ -408,6 +415,7 @@ static void fbnic_remove(struct pci_dev *pdev)if (!fbnic_init_failure (fbd)) {struct net_device *netdev = fbd->netdev; +fbnic_led_exit (fbd);fbnic_netdev_unregister (netdev);cancel_delayed_work_sync (&fbd->service_task);fbnic_ptp_destroy (fbd);
drivers/net/ethernet/meta/fbnic/fbnic_phylink.c +2 -0
@@ -154,6 +154,7 @@ fbnic_phylink_mac_link_down(struct phylink_config *config, unsigned int mode,struct fbnic_dev *fbd = fbn->fbd; fbd->mac->link_down (fbd); +fbnic_led_link_down (fbd); fbn->link_down_events++; }
@@ -172,6 +173,7 @@ fbnic_phylink_mac_link_up(struct phylink_config *config,fbnic_config_drop_mode (fbn, tx_pause); fbd->mac->link_up (fbd, tx_pause, rx_pause); +fbnic_led_link_up (fbd); }static const struct phylink_mac_ops fbnic_phylink_mac_ops = {
Signature · 1 line
2.43.0
Re: [PATCH net-next 3/3] net: eth: fbnic: Add led support
Quoted 13 lines
+/**
+ *fbnic_set_phys_id- Used to strobe the MAC LEDs in a recognizable pattern
+ * @netdev: Interface/port to strobe the LEDs for
+ * @phys_id_state: State requested by the call
+ *
+ * This function can really be broken down into two parts. There are the
+ * ACTIVE/INACTIVE states which really are meant to be defining the start
+ * and stop of the LED strobing. There is also the ON/OFF states which are
+ * used to provide us with a way of telling us that we should be turning
+ * the LED on and/or off.
+ *
+ * We translate these calls and pass them off to the MAC layer. They will
+ * be used to initialize a strobe, then on and off will be used to cycle
Quoted 8 lines
+ * between the patterns, and finally we will restore the original LED state.
+ *
+ * We will return 2 when we are requested to go active. This will tell the
+ * call that it will need to call back to turn on/off the LED twice every
+ * second.
+ *
+ * Return: blink in half second intervals on success, negative value on failure
+ */
Could you drop this for the moment. Ideally, we want the LED core to be implementing this somehow, so that all devices using the core get this functionality, rather than put it in every driver.
Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +9
-0+static int fbnic_led_hw_ctl_set (struct led_classdev *led_cdev, +unsigned long flags) +{ +struct fbnic_led_cdev *ldev =led_classdev_to_fbnic_led (led_cdev); +struct fbnic_dev *fbd =led_cdev_to_fbd (led_cdev); +int led_idx =fbnic_led_get_idx (fbd, ldev); +u32 supported_modes; + + supported_modes =fbnic_led_get_supported_modes (fbd, led_idx);
drivers/net/ethernet/meta/fbnic/fbnic_led.c line 78
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +10
-0+ +if (flags & ~supported_modes) +return -EINVAL ; + +/* Turn on activity LED only when both the TX and RX flags are set. */ +if (led_idx ==FBNIC_LED_ACTIVITY && (flags & supported_modes) && + flags != supported_modes) { +dev_warn (fbd->dev, +"Invalid activity LED mode(s): 0x%lx\n" , flags); +return -EINVAL ;
How does this happen? It should be that the core will not ask you to do something you cannot do, if you have answered -EOPNOTSUPP in fbnic_led_hw_ctl_is_supported().
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +15
-0+static int fbnic_led_brightness_set_blocking (struct led_classdev *led_cdev, +enum led_brightness brightness) +{ +struct fbnic_led_cdev *ldev =led_classdev_to_fbnic_led (led_cdev); +struct fbnic_dev *fbd =led_cdev_to_fbd (led_cdev); +int led_idx =fbnic_led_get_idx (fbd, ldev); + +mutex_lock (&fbd->led_mutex); +if (!brightness) { + fbd->leds[led_idx].enabled_modes =0 ; + fbd->leds[led_idx].strobe_mode =0 ; + }else { +u32 mode; + +switch (led_idx) {
drivers/net/ethernet/meta/fbnic/fbnic_led.c line 160
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +10
-0+case FBNIC_LED_ACTIVITY : + fbd->leds[led_idx].enabled_modes = +BIT (TRIGGER_NETDEV_TX ) |BIT (TRIGGER_NETDEV_RX ); +break ; +default : + mode =fbnic_led_get_link_speed_mode (fbd); + fbd->leds[led_idx].enabled_modes = mode; +break ; + } + }
This looks odd. led_brightness_set() is simply used to set the LED to on or off. The netdev trigger will use it to software blink the LEDs when asked to do something which cannot be offloaded to the hardware.
And when the LED is being used to show NUMLOCK, or Morse code crash dump, network activity should not intervene.
Quoted 47 lines
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +37
-0@@ -623,6 +623,53 @@ static bool fbnic_pmd_update_state(struct fbnic_dev *fbd, bool signal_detect)return false; } +u32 fbnic_get_link_speed (u8 link_speed) +{ +switch (link_speed) { +case FBNIC_FW_LINK_MODE_25CR : +return SPEED_25000 ; +case FBNIC_FW_LINK_MODE_50CR2 : +case FBNIC_FW_LINK_MODE_50CR : +return SPEED_50000 ; +case FBNIC_FW_LINK_MODE_100CR2 : +return SPEED_100000 ; +default : +return 0 ; + } +} + +static void fbnic_set_led_state (struct fbnic_dev *fbd,int state) +{ +mutex_lock (&fbd->led_mutex); + +/* alternating amber,blue IDs device every half second */ +switch (state) { +case FBNIC_LED_OFF :/* amber on, blue off */ + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode =FBNIC_STROBE_ON ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode =FBNIC_STROBE_OFF ; +break ; +case FBNIC_LED_ON :/* amber off, blue on */ + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode =FBNIC_STROBE_OFF ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode =FBNIC_STROBE_ON ; +break ; +case FBNIC_LED_RESTORE : + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode = +FBNIC_STROBE_DISABLED ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode = +FBNIC_STROBE_DISABLED ; +break ; +case FBNIC_LED_STROBE_INIT :/* a no-op */ +/* Initialization is a no-op; LED toggling happens on ON/OFF */
drivers/net/ethernet/meta/fbnic/fbnic_mac.c static bool fbnic_pmd_update_state(struct fbnic_dev *fbd, bool signal_detect) · line 672
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +10
-0+ goto out_unlock; +default : + goto out_unlock; + } + +fbnic_led_update_csr (fbd); +out_unlock: +mutex_unlock (&fbd->led_mutex); +} +
This appears to be something different to trig-netdev and sys class LED control of the LED. Please could you move this out into another patch. Add clean support for the LED first, and them mess it all up in follow up patches adding all your vendor specific stuff. We can then think about if some of that can be moved into the LED core/trig-netdev somehow.
Andrew
Re: [PATCH net-next 3/3] net: eth: fbnic: Add led support
Quoted 22 lines · Andrew Lunn
Quoted 13 lines
+/**
+ *fbnic_set_phys_id- Used to strobe the MAC LEDs in a recognizable pattern
+ * @netdev: Interface/port to strobe the LEDs for
+ * @phys_id_state: State requested by the call
+ *
+ * This function can really be broken down into two parts. There are the
+ * ACTIVE/INACTIVE states which really are meant to be defining the start
+ * and stop of the LED strobing. There is also the ON/OFF states which are
+ * used to provide us with a way of telling us that we should be turning
+ * the LED on and/or off.
+ *
+ * We translate these calls and pass them off to the MAC layer. They will
+ * be used to initialize a strobe, then on and off will be used to cycleQuoted 8 lines
+ * between the patterns, and finally we will restore the original LED state.
+ *
+ * We will return 2 when we are requested to go active. This will tell the
+ * call that it will need to call back to turn on/off the LED twice every
+ * second.
+ *
+ * Return: blink in half second intervals on success, negative value on failure
+ */
Quoted 4 lines
Could you drop this for the moment. Ideally, we want the LED core to be implementing this somehow, so that all devices using the core get this functionality, rather than put it in every driver.
The driver does exploit the LED core. The actually interface to the
LEDs are simple on/off settings. The strobing follows the OCP spec to alternate between the "below" speed color (amber for fbnic) and the "at" speed color (blue for fbnic).
The only complication is the the CSR bit for the activity LED is 1 implies off and zero implies on. The activity LED flashes automatically based on actual network activity provides it is set to 0 (on).
The return to the LED core gives the count of the number of cycles per second and each cycle alternates between amber and blue. The driver is a slave to the ETHTOOL_ID_* phys_id state from the LED core based on that timing.
I'm not sure what else would need to go into the LED core?
Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +15
-0+static int fbnic_led_hw_ctl_set (struct led_classdev *led_cdev, +unsigned long flags) +{ +struct fbnic_led_cdev *ldev =led_classdev_to_fbnic_led (led_cdev); +struct fbnic_dev *fbd =led_cdev_to_fbd (led_cdev); +int led_idx =fbnic_led_get_idx (fbd, ldev); +u32 supported_modes; + + supported_modes =fbnic_led_get_supported_modes (fbd, led_idx); + +if (flags & ~supported_modes) +return -EINVAL ; + +/* Turn on activity LED only when both the TX and RX flags are set. */ + if (led_idx == FBNIC_LED_ACTIVITY && (flags & supported_modes) &&
Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c line 78
Quoted 4 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +4
-0+ flags != supported_modes) { +dev_warn (fbd->dev, +"Invalid activity LED mode(s): 0x%lx\n" , flags); +return -EINVAL ;How does this happen? It should be that the core will not ask you to do something you cannot do, if you have answered
-EOPNOTSUPPinfbnic_led_hw_ctl_is_supported().
Will need to investigate this.
Quoted 30 lines
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +15
-0+static int fbnic_led_brightness_set_blocking (struct led_classdev *led_cdev, +enum led_brightness brightness) +{ +struct fbnic_led_cdev *ldev =led_classdev_to_fbnic_led (led_cdev); +struct fbnic_dev *fbd =led_cdev_to_fbd (led_cdev); +int led_idx =fbnic_led_get_idx (fbd, ldev); + +mutex_lock (&fbd->led_mutex); +if (!brightness) { + fbd->leds[led_idx].enabled_modes =0 ; + fbd->leds[led_idx].strobe_mode =0 ; + }else { +u32 mode; + +switch (led_idx) {drivers/net/ethernet/meta/fbnic/fbnic_led.c line 160
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +10
-0+case FBNIC_LED_ACTIVITY : + fbd->leds[led_idx].enabled_modes = +BIT (TRIGGER_NETDEV_TX ) |BIT (TRIGGER_NETDEV_RX ); +break ; +default : + mode =fbnic_led_get_link_speed_mode (fbd); + fbd->leds[led_idx].enabled_modes = mode; +break ; + } + }This looks odd.
led_brightness_set()is simply used to set the LED to on or off. The netdev trigger will use it to software blink the LEDs when asked to do something which cannot be offloaded to the hardware.
Quoted 3 lines
And when the LED is being used to show NUMLOCK, or Morse code crash dump, network activity should not intervene.
Will need to investigate this.
Quoted 56 lines
Quoted 56 lines
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +46
-0@@ -623,6 +623,53 @@ static bool fbnic_pmd_update_state(struct fbnic_dev *fbd, bool signal_detect)return false; } +u32 fbnic_get_link_speed (u8 link_speed) +{ +switch (link_speed) { +case FBNIC_FW_LINK_MODE_25CR : +return SPEED_25000 ; +case FBNIC_FW_LINK_MODE_50CR2 : +case FBNIC_FW_LINK_MODE_50CR : +return SPEED_50000 ; +case FBNIC_FW_LINK_MODE_100CR2 : +return SPEED_100000 ; +default : +return 0 ; + } +} + +static void fbnic_set_led_state (struct fbnic_dev *fbd,int state) +{ +mutex_lock (&fbd->led_mutex); + +/* alternating amber,blue IDs device every half second */ +switch (state) { +case FBNIC_LED_OFF :/* amber on, blue off */ + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode =FBNIC_STROBE_ON ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode =FBNIC_STROBE_OFF ; +break ; +case FBNIC_LED_ON :/* amber off, blue on */ + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode =FBNIC_STROBE_OFF ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode =FBNIC_STROBE_ON ; +break ; +case FBNIC_LED_RESTORE : + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode = +FBNIC_STROBE_DISABLED ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode = +FBNIC_STROBE_DISABLED ; +break ; +case FBNIC_LED_STROBE_INIT :/* a no-op */ +/* Initialization is a no-op; LED toggling happens on ON/OFF */ + goto out_unlock; +default : + goto out_unlock; + } + +fbnic_led_update_csr (fbd); +out_unlock: +mutex_unlock (&fbd->led_mutex); +}
Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_mac.c static bool fbnic_pmd_update_state(struct fbnic_dev *fbd, bool signal_detect) · line 672
Quoted 1 line
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +1
-0+This appears to be something different to trig-netdev and sys class LED control of the LED. Please could you move this out into another patch. Add clean support for the LED first, and them mess it all up in follow up patches adding all your vendor specific stuff. We can then think about if some of that can be moved into the LED core/trig-netdev somehow.
This IS the slave to the LED core ID mechanism.
If I'm understanding your suggestion the ethtool id, this routine and the fbnic_led_update_csr() need to be a separarate patch?
Quoted 1 line
Andrew
Re: [PATCH net-next 3/3] net: eth: fbnic: Add led support
Quoted 23 lines · Mike Marciniszyn
Quoted 22 lines · Andrew Lunn
Quoted 21 lines
+/**
+ *fbnic_set_phys_id- Used to strobe the MAC LEDs in a recognizable pattern
+ * @netdev: Interface/port to strobe the LEDs for
+ * @phys_id_state: State requested by the call
+ *
+ * This function can really be broken down into two parts. There are the
+ * ACTIVE/INACTIVE states which really are meant to be defining the start
+ * and stop of the LED strobing. There is also the ON/OFF states which are
+ * used to provide us with a way of telling us that we should be turning
+ * the LED on and/or off.
+ *
+ * We translate these calls and pass them off to the MAC layer. They will
+ * be used to initialize a strobe, then on and off will be used to cycle
+ * between the patterns, and finally we will restore the original LED state.
+ *
+ * We will return 2 when we are requested to go active. This will tell the
+ * call that it will need to call back to turn on/off the LED twice every
+ * second.
+ *
+ * Return: blink in half second intervals on success, negative value on failure
+ */
Quoted 6 lines
Quoted 4 lines
Could you drop this for the moment. Ideally, we want the LED core to be implementing this somehow, so that all devices using the core get this functionality, rather than put it in every driver.
The driver does exploit the LED core.
The driver does make use of the LED core, but it is not using the LED subsystem to do phys_id. Ideally, we want either the LED core, or maybe a netdev helper to expose a function which can be used as the ethtool op. The driver itself does nothing, except expose its LEDs to the core. We than have a function any driver with LEDs can use. A generic solution.
Quoted 4 lines
The actually interface to the
LEDs are simple on/off settings. The strobing follows the OCP spec to alternate between the "below" speed color (amber for fbnic) and the "at" speed color (blue for fbnic).
You appear to need a specific implementation of phys_id. What i'm asking is that you first implement MAC LEDs as Linux currently defines them. A simple clean implementation. Once that is merged, we can figure out how to implement what OCP required, in a generic way that any vendor can use.
Quoted 11 lines
The only complication is the the CSR bit for the activity LED is 1 implies off and zero implies on. The activity LED flashes automatically based on actual network activity provides it is set to 0 (on).
The return to the LED core gives the count of the number of cycles per second and each cycle alternates between amber and blue. The driver is a slave to the ETHTOOL_ID_*
phys_idstate from the LED core based on that timing.I'm not sure what else would need to go into the LED core?
An LED driver should first expose an simple on/off method. If it supports acceleration, it can then optionally expose its acceleration capabilities.
Quoted 129 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +15
-0+static int fbnic_led_hw_ctl_set (struct led_classdev *led_cdev, +unsigned long flags) +{ +struct fbnic_led_cdev *ldev =led_classdev_to_fbnic_led (led_cdev); +struct fbnic_dev *fbd =led_cdev_to_fbd (led_cdev); +int led_idx =fbnic_led_get_idx (fbd, ldev); +u32 supported_modes; + + supported_modes =fbnic_led_get_supported_modes (fbd, led_idx); + +if (flags & ~supported_modes) +return -EINVAL ; + +/* Turn on activity LED only when both the TX and RX flags are set. */ + if (led_idx == FBNIC_LED_ACTIVITY && (flags & supported_modes) &&Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c line 78
Quoted 4 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +4
-0+ flags != supported_modes) { +dev_warn (fbd->dev, +"Invalid activity LED mode(s): 0x%lx\n" , flags); +return -EINVAL ;How does this happen? It should be that the core will not ask you to do something you cannot do, if you have answered
-EOPNOTSUPPinfbnic_led_hw_ctl_is_supported().Will need to investigate this.
Quoted 30 lines
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +15
-0+static int fbnic_led_brightness_set_blocking (struct led_classdev *led_cdev, +enum led_brightness brightness) +{ +struct fbnic_led_cdev *ldev =led_classdev_to_fbnic_led (led_cdev); +struct fbnic_dev *fbd =led_cdev_to_fbd (led_cdev); +int led_idx =fbnic_led_get_idx (fbd, ldev); + +mutex_lock (&fbd->led_mutex); +if (!brightness) { + fbd->leds[led_idx].enabled_modes =0 ; + fbd->leds[led_idx].strobe_mode =0 ; + }else { +u32 mode; + +switch (led_idx) {drivers/net/ethernet/meta/fbnic/fbnic_led.c line 160
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_led.c new file +10
-0+case FBNIC_LED_ACTIVITY : + fbd->leds[led_idx].enabled_modes = +BIT (TRIGGER_NETDEV_TX ) |BIT (TRIGGER_NETDEV_RX ); +break ; +default : + mode =fbnic_led_get_link_speed_mode (fbd); + fbd->leds[led_idx].enabled_modes = mode; +break ; + } + }This looks odd.
led_brightness_set()is simply used to set the LED to on or off. The netdev trigger will use it to software blink the LEDs when asked to do something which cannot be offloaded to the hardware.Quoted 3 lines
And when the LED is being used to show NUMLOCK, or Morse code crash dump, network activity should not intervene.
Will need to investigate this.
Quoted 56 lines
Quoted 56 lines
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +46
-0@@ -623,6 +623,53 @@ static bool fbnic_pmd_update_state(struct fbnic_dev *fbd, bool signal_detect)return false; } +u32 fbnic_get_link_speed (u8 link_speed) +{ +switch (link_speed) { +case FBNIC_FW_LINK_MODE_25CR : +return SPEED_25000 ; +case FBNIC_FW_LINK_MODE_50CR2 : +case FBNIC_FW_LINK_MODE_50CR : +return SPEED_50000 ; +case FBNIC_FW_LINK_MODE_100CR2 : +return SPEED_100000 ; +default : +return 0 ; + } +} + +static void fbnic_set_led_state (struct fbnic_dev *fbd,int state) +{ +mutex_lock (&fbd->led_mutex); + +/* alternating amber,blue IDs device every half second */ +switch (state) { +case FBNIC_LED_OFF :/* amber on, blue off */ + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode =FBNIC_STROBE_ON ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode =FBNIC_STROBE_OFF ; +break ; +case FBNIC_LED_ON :/* amber off, blue on */ + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode =FBNIC_STROBE_OFF ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode =FBNIC_STROBE_ON ; +break ; +case FBNIC_LED_RESTORE : + fbd->leds[FBNIC_LED_LINK_AMBER ].strobe_mode = +FBNIC_STROBE_DISABLED ; + fbd->leds[FBNIC_LED_LINK_BLUE ].strobe_mode = +FBNIC_STROBE_DISABLED ; +break ; +case FBNIC_LED_STROBE_INIT :/* a no-op */ +/* Initialization is a no-op; LED toggling happens on ON/OFF */ + goto out_unlock; +default : + goto out_unlock; + } + +fbnic_led_update_csr (fbd); +out_unlock: +mutex_unlock (&fbd->led_mutex); +}Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_mac.c static bool fbnic_pmd_update_state(struct fbnic_dev *fbd, bool signal_detect) · line 672
Quoted 1 line
drivers/net/ethernet/meta/fbnic/fbnic_mac.c +1
-0+This appears to be something different to trig-netdev and sys class LED control of the LED. Please could you move this out into another patch. Add clean support for the LED first, and them mess it all up in follow up patches adding all your vendor specific stuff. We can then think about if some of that can be moved into the LED core/trig-netdev somehow.
Quoted 4 lines
This IS the slave to the LED core ID mechanism.
If I'm understanding your suggestion the ethtool id, this routine and the
fbnic_led_update_csr()need to be a separarate patch?
I'm saying start KISS. All the LED core really needs is on/off. It will then blink the LEDs as required.
The next step is to then expose whatever acceleration the hardware provides, so that in some configurations software blinking is not needed, the hardware does it.
Then we can think about whatever OCP requires and how we can do a generic implementation.
Andrew
Quoted 1 line · On Wed, May 20, 2026 at 04:03:34PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
The Subject: of this email has an off 'dd' in it.
Quoted 1 line
The second patch stors the max speed from the firmware dialog
stores
Andrew
Lee Jones
maintainerQuoted 8 lines · Andrew Lunn
Quoted 1 line · On Wed, May 20, 2026 at 04:03:34PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
The Subject: of this email has an off 'dd' in it.
Quoted 1 line
The second patch stors the max speed from the firmware dialog
stores
It's also just a cover-letter.
Signature · 1 line
Lee Jones
Quoted 5 lines · Lee Jones
Quoted 3 lines · Andrew Lunn
Quoted 1 line · On Wed, May 20, 2026 at 04:03:34PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
Quoted 7 lines
Quoted 5 lines
The Subject: of this email has an off 'dd' in it.
Quoted 1 line
The second patch stors the max speed from the firmware dialog
stores
It's also just a cover-letter.
It depends on the Maintainers workflow, but for netdev, a patch series is imported into a branch, and the cover letter is used for the text of the merge commit into net-next.
A well written cover letter contains the big picture, what does this set of patches do, so it has useful information in it, so we want to have it in the git history.
Andrew
Lee Jones
maintainerQuoted 14 lines · Andrew Lunn
Quoted 5 lines · Lee Jones
Quoted 3 lines · Andrew Lunn
Quoted 1 line · On Wed, May 20, 2026 at 04:03:34PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
Quoted 7 lines
Quoted 5 lines
The Subject: of this email has an off 'dd' in it.
Quoted 1 line
The second patch stors the max speed from the firmware dialog
stores
It's also just a cover-letter.
Quoted 7 lines
It depends on the Maintainers workflow, but for netdev, a patch series is imported into a branch, and the cover letter is used for the text of the merge commit into net-next.
A well written cover letter contains the big picture, what does this set of patches do, so it has useful information in it, so we want to have it in the git history.
Interesting. This is new to me. As you were.
Signature · 1 line
Lee Jones
Quoted 3 lines · Lee Jones
Quoted 2 lines · Andrew Lunn
Quoted 1 line · Lee Jones
On Wed, 20 May 2026, Andrew Lunn wrote:
...
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
It's also just a cover-letter.
It depends on the Maintainers workflow, but for netdev, a patch series is imported into a branch, and the cover letter is used for the text of the merge commit into net-next.
A well written cover letter contains the big picture, what does this set of patches do, so it has useful information in it, so we want to have it in the git history.
Interesting. This is new to me. As you were.
I also do this from time to time (depending on the series at hand), this is so cool with b4 shazam ....
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Andrew Lunn
Quoted 1 line · On Wed, May 20, 2026 at 04:03:34PM -0400, [email protected] wrote:
From: "Mike Marciniszyn (Meta)" <[email protected]>
The Subject: of this email has an off 'dd' in it.
Quoted 1 line
The second patch stors the max speed from the firmware dialog
stores
Andrew
"dd" should have read "Add" (truncated by copy/paste).
Correcting the subject I think would mess up subsequent revisions unless I retract the series, consolidate the ID mechanisms into a separate patch and follow up with the led class patch wrapped in a better cover sheet.
Mike
Quoted 2 lines
Correcting the subject I think would mess up subsequent revisions unless I retract the series
Revisions are pretty much considered independent of each other.
You can include a link in v2 pointing to v1, if want to make it easier to go backwards.
Andrew