Skip to content

[Nexthop][fboss2-dev] Add interface profile cli command#1072

Open
hillol-nexthop wants to merge 3 commits intofacebook:mainfrom
nexthop-ai:add-interface-speed-cli-command
Open

[Nexthop][fboss2-dev] Add interface profile cli command#1072
hillol-nexthop wants to merge 3 commits intofacebook:mainfrom
nexthop-ai:add-interface-speed-cli-command

Conversation

@hillol-nexthop
Copy link
Copy Markdown
Contributor

@hillol-nexthop hillol-nexthop commented Apr 10, 2026

Summary

Implements fboss2-dev config interface <port-list> profile <profile-id> — the command specified in NOS-4544. Profile-id is a PortProfileID enum string (e.g. PROFILE_100G_4_NRZ_RS528_COPPER, case-insensitive). Setting a profile also updates port->speed() to the corresponding speed derived from PlatformMapping, keeping both fields consistent.

This PR also reverts #635 (which implemented speed under NOS-4544 instead of profile). The speed attribute has been removed from the CLI for now; it will be re-added in a follow-up ticket if needed.

New command syntax:

fboss2-dev config interface eth1/1/1 profile PROFILE_100G_4_NRZ_RS528_COPPER
fboss2-dev config interface eth1/1/1 profile profile_100g_4_nrz_rs528_copper   # case-insensitive
fboss2-dev config interface eth1/1/1,eth1/2/1 profile PROFILE_400G_8_PAM4_RS544X2N_OPTICAL
fboss2-dev config interface eth1/1/1 profile PROFILE_DEFAULT   # resets to default

Implementation

Added ProfileValidator class (ProfileValidation.h/.cpp) mirroring the SpeedValidator pattern:

  • Constructor queries FbossCtrl::getPlatformMapping + QsfpService::getAllPortSupportedProfiles once
  • Validation strategy: QSFP-primary (optics-aware), PlatformMapping fallback (hardware capabilities)
  • parseProfile(): case-insensitive via TEnumTraits<cfg::PortProfileID>::findValue(toUpper(str))
  • validateProfile(): checks requested profile is in supported list; PROFILE_DEFAULT always passes
  • getProfileSpeed() called once before the per-port loop (speed is a property of the profile, not the port — avoids rebuilding PlatformMapping per port)

Both port->profileID() and port->speed() are set on apply, keeping them consistent.

 

Test Plan

Unit tests in CmdConfigInterfaceTest.cpp (21 new test cases):

  • parseProfileValidUppercase / parseProfileValidLowercase — case-insensitive parsing
  • parseProfileDefault — PROFILE_DEFAULT accepted
  • parseProfileUnknown / parseProfileEmpty — invalid strings rejected
  • validateProfileSupported — supported profile validated and returned
  • validateProfileDefault — PROFILE_DEFAULT bypasses hardware check
  • validateProfileNotSupported — unsupported profile rejected with helpful error
  • validateProfilePortNotFound — unknown port throws runtime_error
  • validateProfileQsfpPrimaryFallback — QSFP primary, PlatformMapping fallback verified
  • getProfileSpeedKnown / getProfileSpeedUnknown — speed lookup from PlatformMapping
  • queryClientSetsProfile — full command sets both profileID and speed
  • queryClientSetsProfileDefault — PROFILE_DEFAULT resets both fields
  • queryClientProfileUnsupportedThrows — unsupported profile rejected
  • queryClientProfileInvalidStringThrows — bad string rejected before Thrift calls
  • queryClientSetProfileMultiPort — all ports updated in multi-port command
  • queryClientSetProfileAndDescription — combined attributes work correctly
  • queryClientNoAttributesErrorMentionsProfile — error message lists profile

Integration tests added in ConfigInterfaceProfileTest.cpp:

  • SetValidProfileSuccess, SetInvalidProfileFails, SetProfileDefaultResetsSpeed, SetProfileMultiInterface

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

@meta-cla meta-cla bot added the CLA Signed label Apr 10, 2026
@hillol-nexthop hillol-nexthop changed the title Add interface speed cli command [Nexthop][fboss2-dev] Add interface speed cli command Apr 10, 2026
@hillol-nexthop hillol-nexthop force-pushed the add-interface-speed-cli-command branch 2 times, most recently from 6674eb9 to 4ad270d Compare April 10, 2026 08:41
@hillol-nexthop hillol-nexthop force-pushed the add-interface-speed-cli-command branch from 4ad270d to b4b3786 Compare April 10, 2026 11:20
@hillol-nexthop hillol-nexthop marked this pull request as ready for review April 10, 2026 14:50
@hillol-nexthop hillol-nexthop requested review from a team as code owners April 10, 2026 14:50
@joseph5wu
Copy link
Copy Markdown
Contributor

@hillol-nexthop : FBOSS has been using this PortProfileID concept to program our port/interface for a long time
https://github.com/facebook/fboss/blob/main/fboss/agent/switch_config.thrift#L129
Basically this port profile idea is to capture multiple port speed and phy configs into one single profile so we can program such interface with the specified port profile all at once.
Therefore, I highly recommend to continue using the term of profiles to program port speed instead of the single speed here. Otherwise, fboss2 won't be able to tell which exactly profile to use based on the speed, like when you want to use 200G, you won't be able to tell it's PROFILE_200G_4_PAM4_RS544X2N_COPPER or PROFILE_200G_4_PAM4_RS544X2N_OPTICAL.

Please consider to support the following cli instead

fboss2-dev config interface eth1/1/1 profile PROFILE_200G_4_PAM4_RS544X2N_COPPER

The cli can still use getAllPortSupportedProfiles() to check whether the user input profile is valid or not.

> fboss2 -H rsw029.p066.f01.nha6 show interface eth1/8/5 capabilities
 Interface  Profiles
-------------------------------------------------------------------
 eth1/8/5   PROFILE_100G_4_NRZ_RS528_COPPER
            PROFILE_100G_4_NRZ_RS528_OPTICAL
            PROFILE_200G_4_PAM4_RS544X2N_COPPER
            PROFILE_200G_4_PAM4_RS544X2N_OPTICAL
            PROFILE_400G_4_PAM4_RS544X2N_OPTICAL
            PROFILE_400G_4_PAM4_RS544X2N_COPPER


> fboss2 -H rsw029.p066.f01.nha6 show interface eth1/8/5
+-----------+--------+-------+------+------+------------------------------+-------------+
| Interface | Status | Speed | VLAN | MTU  | Addresses                    | Description |
-----------------------------------------------------------------------------------------
| eth1/8/5  | down   | 200G  | 3002 | 9000 | fe80::d849:bfff:fe9c:eae9/64 |             |
-----------------------------------------------------------------------------------------

> fboss2 -H rsw029.p066.f01.nha6 show port eth1/8/5
 ID  Name      AdminState  LinkState  ActiveState  Transceiver  TcvrID  Speed  ProfileID                             HwLogicalPortId  Drained  PeerSwitchDrained  PeerPortDrainedOrDown  Errors  Core Id  Virtual device Id  Cable Len meters
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 42  eth1/8/5  Enabled     Down       --           Present      7       200G   PROFILE_200G_4_PAM4_RS544X2N_OPTICAL  36               No       --                 --                     --      --       --                 --

@hillol-nexthop
Copy link
Copy Markdown
Contributor Author

@hillol-nexthop : FBOSS has been using this PortProfileID concept to program our port/interface for a long time https://github.com/facebook/fboss/blob/main/fboss/agent/switch_config.thrift#L129 Basically this port profile idea is to capture multiple port speed and phy configs into one single profile so we can program such interface with the specified port profile all at once. Therefore, I highly recommend to continue using the term of profiles to program port speed instead of the single speed here. Otherwise, fboss2 won't be able to tell which exactly profile to use based on the speed, like when you want to use 200G, you won't be able to tell it's PROFILE_200G_4_PAM4_RS544X2N_COPPER or PROFILE_200G_4_PAM4_RS544X2N_OPTICAL.

Please consider to support the following cli instead

fboss2-dev config interface eth1/1/1 profile PROFILE_200G_4_PAM4_RS544X2N_COPPER

The cli can still use getAllPortSupportedProfiles() to check whether the user input profile is valid or not.

> fboss2 -H rsw029.p066.f01.nha6 show interface eth1/8/5 capabilities
 Interface  Profiles
-------------------------------------------------------------------
 eth1/8/5   PROFILE_100G_4_NRZ_RS528_COPPER
            PROFILE_100G_4_NRZ_RS528_OPTICAL
            PROFILE_200G_4_PAM4_RS544X2N_COPPER
            PROFILE_200G_4_PAM4_RS544X2N_OPTICAL
            PROFILE_400G_4_PAM4_RS544X2N_OPTICAL
            PROFILE_400G_4_PAM4_RS544X2N_COPPER


> fboss2 -H rsw029.p066.f01.nha6 show interface eth1/8/5
+-----------+--------+-------+------+------+------------------------------+-------------+
| Interface | Status | Speed | VLAN | MTU  | Addresses                    | Description |
-----------------------------------------------------------------------------------------
| eth1/8/5  | down   | 200G  | 3002 | 9000 | fe80::d849:bfff:fe9c:eae9/64 |             |
-----------------------------------------------------------------------------------------

> fboss2 -H rsw029.p066.f01.nha6 show port eth1/8/5
 ID  Name      AdminState  LinkState  ActiveState  Transceiver  TcvrID  Speed  ProfileID                             HwLogicalPortId  Drained  PeerSwitchDrained  PeerPortDrainedOrDown  Errors  Core Id  Virtual device Id  Cable Len meters
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 42  eth1/8/5  Enabled     Down       --           Present      7       200G   PROFILE_200G_4_PAM4_RS544X2N_OPTICAL  36               No       --                 --                     --      --       --                 --

Okay I will implement
config interface <> profile
instead of speed.
In that case do we need to query qsfp? I think if we just query agent for supportedProfiles, we can see valid/invalid.

@hillol-nexthop hillol-nexthop marked this pull request as draft April 16, 2026 03:54
@hillol-nexthop hillol-nexthop force-pushed the add-interface-speed-cli-command branch from 5d25b15 to ba48c15 Compare April 16, 2026 06:19
@hillol-nexthop hillol-nexthop changed the title [Nexthop][fboss2-dev] Add interface speed cli command [Nexthop][fboss2-dev] Add interface profile cli command Apr 16, 2026
@hillol-nexthop hillol-nexthop marked this pull request as ready for review April 16, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants