Support for running firmware in embedded controllers - #2319
Conversation
Signed-off-by: JaiOCP <jai.kumar@broadcom.com>
Signed-off-by: JaiOCP <jai.kumar@broadcom.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
| * 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 |
There was a problem hiding this comment.
char is refering to sai_attribute_value_t::chardata which is 32 bytes, if you want longer string, use sai_s8_list_t
There was a problem hiding this comment.
same SAI_FW_ATTR_LOG_FILE_AND_PATH_NAME
| { | ||
| WriteSource "$val = { .chardata = { 0 } };"; | ||
| } | ||
| elsif ($default =~ /^0$/ and $type =~ /^(sai_fw_inst_t)/) |
There was a problem hiding this comment.
type eq "sai_fw_inst_t, you can merge this with
elsif ($default =~ /^0$/ and $type =~ /^(sai_timespec_t|sai_fw_inst_t)$/)
|
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 ? |
|
|
||
| ### 2.1 Firmware Object Lifecycle | ||
|
|
||
| There are two life cycles that need to be supported. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Accepted the feedback. Will add a callback
| * @flags CREATE_AND_SET | ||
| * @default "" | ||
| */ | ||
| SAI_FW_ATTR_FW_FILE_AND_PATH_NAME, |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
| * @flags CREATE_AND_SET | ||
| * @default 0 | ||
| */ | ||
| SAI_FW_ATTR_CORE_ID, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is a good point. Lets discuss this in meeting
| * | ||
| * @type sai_uint8_t | ||
| * @flags CREATE_AND_SET | ||
| * @default 0 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
| * @flags CREATE_AND_SET | ||
| * @default 0 | ||
| */ | ||
| SAI_FW_ATTR_CORE_ID, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| * Firmware state monitoring | ||
| * Runtime firmware configuration | ||
|
|
||
| The API is exposed through the `sai_fw_api_t` method table, using a new FW object. |
There was a problem hiding this comment.
How will the existing f/w switch attributes co-exist with this new infra ?
There was a problem hiding this comment.
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.
|
|
||
| /** Firmware admin state is unload the firmware */ | ||
| SAI_FW_ADMIN_STATE_UNLOAD_FW, | ||
| } sai_fw_admin_state_t; |
There was a problem hiding this comment.
During warm boot how do we reconnect to the f/w ?
Should we have a additional admin state like sync to indicate warm boot ?
There was a problem hiding this comment.
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.
|
|
||
| /** Firmware admin state */ | ||
| sai_fw_admin_state_t admin_state; | ||
| } sai_fw_inst_t; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 :)
| | 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 | |
There was a problem hiding this comment.
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.
| /** | ||
| * @brief Defines maximum length of firmware and log file name | ||
| */ | ||
| #define SAI_FW_NAME_SIZE 64 |
There was a problem hiding this comment.
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.
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.