Skip to content

Support for running firmware in embedded controllers - #2319

Open
JaiOCP wants to merge 3 commits into
opencomputeproject:masterfrom
JaiOCP:fw
Open

Support for running firmware in embedded controllers#2319
JaiOCP wants to merge 3 commits into
opencomputeproject:masterfrom
JaiOCP:fw

Conversation

@JaiOCP

@JaiOCP JaiOCP commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Modern switches have embedded controller to run firmware for low latency applications.
This PR bring in support for installing and monitoring firmware based on the hardware support.

JaiOCP added 3 commits June 24, 2026 13:12
Signed-off-by: JaiOCP <jai.kumar@broadcom.com>
Signed-off-by: JaiOCP <jai.kumar@broadcom.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Comment thread inc/saifw.h
* The maximum number of characters for the name is SAI_FW_NAME_SIZE - 1 since
* it needs the terminating null byte ('\0') at the end.
*
* @type char

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char is refering to sai_attribute_value_t::chardata which is 32 bytes, if you want longer string, use sai_s8_list_t

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same SAI_FW_ATTR_LOG_FILE_AND_PATH_NAME

Comment thread meta/parse.pl
{
WriteSource "$val = { .chardata = { 0 } };";
}
elsif ($default =~ /^0$/ and $type =~ /^(sai_fw_inst_t)/)

@kcudnik kcudnik Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type eq "sai_fw_inst_t, you can merge this with

elsif ($default =~ /^0$/ and $type =~ /^(sai_timespec_t|sai_fw_inst_t)$/)

@kcudnik

kcudnik commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

you have only SAI_OBJECT_TYPE_FW as readable variable you cant assign it anywhre, its possible to create any of thos objects ? is that by design ?

Comment thread doc/fw/SAI-FW-API.md

### 2.1 Firmware Object Lifecycle

There are two life cycles that need to be supported.

@gananthateerta gananthateerta Jul 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If firmware crashes, the only way NOS finds out is by polling SAI_FW_ATTR_FW_OP_STATE and noticing it changed to ERROR.

A notification callback, consistent with how SAI handles other async events, is neeed.

Following functionality can be added:
Crash reason?
Core dump?
Auto-restart?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted the feedback. Will add a callback

@tjchadaga tjchadaga added the reviewed PR is discussed in SAI Meeting label Jul 24, 2026
Comment thread doc/fw/SAI-FW-API.md
* @flags CREATE_AND_SET
* @default ""
*/
SAI_FW_ATTR_FW_FILE_AND_PATH_NAME,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CREATE_ONLY | MANDATORY ?
When multiple firmware objects are available, how will the NOS be able to map the firmware object to a specific firmware ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking if NOS need to modify the file name for some new encoding we should allow it run time and hence not mandatory.

Comment thread doc/fw/SAI-FW-API.md
* @flags CREATE_AND_SET
* @default 0
*/
SAI_FW_ATTR_CORE_ID,

@AnandhiDhanabalan AnandhiDhanabalan Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CORE_ID to be changed - what is the allowed oper and admin state ? How do we establish this requirment of specific admin and operstates when CORE_ID is changed ?

Ideally this can be changed only when SAI_FW_ADMIN_STATE_UNLOAD_FW, other admin state should not allow it. Is this understanding correct ?

Some additional thoughts..
The @flags for SAI_FW_ATTR_CORE_ID should be CREATE_ONLY, not CREATE_AND_SET. Changing the core assignment of a firmware object while it is in RUNNING or LOADED state is not meaningful — the F/W is already committed to that core's memory space. To move firmware to a different core, remove and recreate the FW object. If dynamic reassignment is intended (e.g., for load balancing) a new admin state and associated semantics must be defined.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. Lets discuss this in meeting

Comment thread doc/fw/SAI-FW-API.md
*
* @type sai_uint8_t
* @flags CREATE_AND_SET
* @default 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will NOS know supported core-ids ? Should we have a default read-only core-id list ?
Also should we support a default_internal option instead of default, if NOS wants to go with default option ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a readonly attribute for MAX cores. NOS can ping a FW on an abstracted core no of 0 to max-1. This can internally be mapped by the SAI adapter.

Reason I kept it this way is mainly to provide flexibility to silicon vendor to internally id the cores as applicable. Note that cores may not be in single domain space as we talked about.

Comment thread doc/fw/SAI-FW-API.md
* @flags CREATE_AND_SET
* @default 0
*/
SAI_FW_ATTR_CORE_ID,

@AnandhiDhanabalan AnandhiDhanabalan Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given core_id can have only single f/w object or multiple ?
If Single - how do you upgrade a f/w from say V1 to V2 - Can you give the flow ?
Should core_id be kept as key?

The design must address co-running FW constraints. Some implementations compile multiple features into a single F/W image.

The design doc should also clarify: when two F/W objects share Asic h/w resource, what is the resource arbitration contract? Is it implementation-defined or must it be modeled in SAI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FW is an abstracted entity and may support one or more features. As I mentioned that features are exposed via separate SAI APIs and have no correlation to FW object.

If FW need to migrated to different core, then it is a destructive event. Ideally FW object should be deleted and recreated with different core id (this is where your suggestion of CREATE_ONLY for core id is valid). And this will impact all the features supported by that instance of FW.

Comment thread doc/fw/SAI-FW-API.md
* Firmware state monitoring
* Runtime firmware configuration

The API is exposed through the `sai_fw_api_t` method table, using a new FW object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will the existing f/w switch attributes co-exist with this new infra ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing Firmware attributes are very specific to Gearbox with MDIO/EEPROM load methods and can support only single firmware instance.
These attributes are not deprecated and stay such.

NOS can choose existing or the new infra based on the capability query for the device and both can be enabled at the same time if supported.

Comment thread doc/fw/SAI-FW-API.md

/** Firmware admin state is unload the firmware */
SAI_FW_ADMIN_STATE_UNLOAD_FW,
} sai_fw_admin_state_t;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During warm boot how do we reconnect to the f/w ?
Should we have a additional admin state like sync to indicate warm boot ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not clear what reconnect means? After warmboot NOS will query the admin state and op state to figure out the state of FW.

If reconnect means some kind of RPC channel then note that NOS do not open any RPC channel. If there is one it is internal to the chip vendor.

Comment thread doc/fw/SAI-FW-API.md

/** Firmware admin state */
sai_fw_admin_state_t admin_state;
} sai_fw_inst_t;

@AnandhiDhanabalan AnandhiDhanabalan Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a vendor specific read-only string added to sai_fw_inst_t ? To identify the f/w, type etc or aA firmware role/type attribute is needed to bind a FW object to its consuming SAI subsystem.

Could you specify how the relationship between SAI_OBJECT_TYPE_FW and any other object in the sai system that uses this firmware object, say SAI_OBJECT_TYPE_TAM or SAI_OBJECT_TYPE_TAM_INT is established ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vendor specific request was discussed in meeting. If there is a need to specify any kind of hint for SDK to pick on for some vendor specific operations that can be encoded in the FW file name.

SAI_OBJECT_TYPE_FW has a naroow focus of manaigng the life cycle of the firmware. What kind of functionality it exposes is not part of this PR.

Typically any function either by the FW or the native switch silicon is abstracted independently as a SAI API. For example TAM functions can be implemented using a firmware. In this firmware life cycle management is done by the FW object and function is exposed using the TAM object. There is no coupling between two within the SAI framework.

Good question though :)

Comment thread doc/fw/SAI-FW-API.md
| SAI_FW_OP_STATE_NOT_LOADED | Firmware unavailable and not loaded|
| SAI_FW_OP_STATE_RUNNING | Firmware loaded and running |
| SAI_FW_OP_STATE_STOPPED | Firmware loaded but stopped |
| SAI_FW_OP_STATE_ERROR | Firmware loaded and encountered an error |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ASICs with async FW loading, transitional states are needed:

SAI_FW_OP_STATE_LOADING,   // image transfer in progress 
SAI_FW_OP_STATE_STOPPING,  // graceful shutdown in progress

Without these, the NOS has no way to distinguish "FW load not started" from "FW load in progress" when polling SAI_FW_ATTR_FW_OP_STATE. Also consider adding a notification callback (SAI_SWITCH_ATTR_FW_STATE_CHANGE_NOTIFY) so the NOS doesn't need to poll.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

Comment thread inc/saifw.h
/**
* @brief Defines maximum length of firmware and log file name
*/
#define SAI_FW_NAME_SIZE 64

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the limited set at 64 bytes? According to the PR documentation this is used for both the path and the file name. Under complex Linux mounting, this limit might not be enough. Consider enlarging to at least 128 if not 256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewed PR is discussed in SAI Meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants