Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/buildomat/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
TOFINO_STAGES=20

# These describe which version of the SDE to download and where to find it
SDE_COMMIT=53519b8cf74fe832cc7838ea92683564ce4026f2
SDE_PKG_SHA256=ed783a1e7c8d59c392e8cc89114fb0d495b5475373b762068a719e0fb215f5a0
SDE_DEB_SHA256=90a18b65a6c65f4d15d5f75a00e42ae55a27ffaff2066061aa95feefbe85e163
SDE_COMMIT=4c7f6924d47ec3ac65312e142586d919c05ad5ec
SDE_PKG_SHA256=f2dd0bfabad0e60f92d9972cfcfbbd685e37036ab3135e72c4b82b333418983c
SDE_DEB_SHA256=59a40e1d4f753c2d15f4949403f3c2d2cf4c3f199bfc30ccf688b9e48c6bce21

[ `uname -s` == "SunOS" ] && SERIES=illumos
[ `uname -s` == "SunOS" ] || SERIES=linux
Expand Down
7 changes: 7 additions & 0 deletions aal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ pub trait AsicOps {
mode: PortPrbsMode,
) -> AsicResult<()>;

/// Get a port's PRBS error counts
fn port_prbs_get_err(
&self,
port_hdl: PortHdl,
ms: u32,
) -> AsicResult<Vec<u32>>;

/// "Add" a port to the ASIC. This carves out a collection of lanes on a
/// physical connector and instructs the ASIC to start managing them as a
/// single logical port.
Expand Down
13 changes: 13 additions & 0 deletions asic/src/chaos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use common::ports::{PortFec, PortId, PortMedia, PortPrbsMode, PortSpeed};

use crate::Identifiers;
pub use crate::faux_fsm::FsmState;
pub use crate::faux_fsm::FsmType;
pub use crate::faux_fsm::PortFsmState;

pub mod table;
Expand Down Expand Up @@ -157,6 +158,7 @@ pub struct AsicConfig {
pub port_enable_get: Chaos,
pub port_enable_set: Chaos,
pub port_prbs_set: Chaos,
pub port_prbs_get_err: Chaos,
pub port_add: Chaos,
pub port_delete: Chaos,
pub register_port_update_handler: Chaos,
Expand Down Expand Up @@ -190,6 +192,7 @@ impl AsicConfig {
port_enable_get: Chaos::new(v),
port_enable_set: Chaos::new(v),
port_prbs_set: Chaos::new(v),
port_prbs_get_err: Chaos::new(v),
port_add: Chaos::new(v),
port_delete: Chaos::new(v),
register_port_update_handler: Chaos::new(v),
Expand Down Expand Up @@ -250,6 +253,7 @@ impl AsicConfig {
port_autoneg_set: Chaos::new(v),
port_enable_set: Chaos::new(v),
port_prbs_set: Chaos::new(v),
port_prbs_get_err: Chaos::new(v),
port_add: Chaos::new(v),
port_delete: Chaos::new(v),
// TODO this can cause dpd to fail to start
Expand Down Expand Up @@ -510,6 +514,15 @@ impl AsicOps for Handle {
Ok(())
}

fn port_prbs_get_err(
&self,
_port_hdl: PortHdl,
_ms: u32,
) -> AsicResult<Vec<u32>> {
unfurl!(self, port_prbs_get_err);
Ok(Vec::new())
}

fn port_add(
&self,
connector: Connector,
Expand Down
45 changes: 25 additions & 20 deletions asic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,48 +180,53 @@ pub mod tofino_asic;

#[cfg(feature = "tofino_asic")]
mod plat {
pub use super::tofino_asic::FsmState;
pub use super::tofino_asic::Handle;
pub use super::tofino_asic::PortFsmState;
pub use super::tofino_asic::stats::AsicLinkStats;
pub use super::tofino_asic::table::Table;
pub use crate::tofino_asic::FsmState;
pub use crate::tofino_asic::FsmType;
pub use crate::tofino_asic::Handle;
pub use crate::tofino_asic::PortFsmState;
pub use crate::tofino_asic::stats::AsicLinkStats;
pub use crate::tofino_asic::table::Table;
}

#[cfg(feature = "tofino_stub")]
pub mod tofino_stub;
#[cfg(feature = "tofino_stub")]
mod plat {
pub use super::tofino_stub::AsicLinkStats;
pub use super::tofino_stub::FsmState;
pub use super::tofino_stub::PortFsmState;
pub use super::tofino_stub::StubHandle as Handle;
pub use super::tofino_stub::table::Table;
pub use crate::tofino_stub::AsicLinkStats;
pub use crate::tofino_stub::FsmState;
pub use crate::tofino_stub::FsmType;
pub use crate::tofino_stub::PortFsmState;
pub use crate::tofino_stub::StubHandle as Handle;
pub use crate::tofino_stub::table::Table;
}

#[cfg(feature = "softnpu")]
pub mod softnpu;
#[cfg(feature = "softnpu")]
mod plat {
pub use super::softnpu::AsicLinkStats;
pub use super::softnpu::FsmState;
pub use super::softnpu::Handle;
pub use super::softnpu::PortFsmState;
pub use super::softnpu::table::Table;
pub use crate::softnpu::AsicLinkStats;
pub use crate::softnpu::FsmState;
pub use crate::softnpu::FsmType;
pub use crate::softnpu::Handle;
pub use crate::softnpu::PortFsmState;
pub use crate::softnpu::table::Table;
}

#[cfg(feature = "chaos")]
pub mod chaos;
#[cfg(feature = "chaos")]
mod plat {
pub use super::chaos::AsicLinkStats;
pub use super::chaos::FsmState;
pub use super::chaos::Handle;
pub use super::chaos::PortFsmState;
pub use super::chaos::table::Table;
pub use crate::chaos::AsicLinkStats;
pub use crate::chaos::FsmState;
pub use crate::chaos::FsmType;
pub use crate::chaos::Handle;
pub use crate::chaos::PortFsmState;
pub use crate::chaos::table::Table;
}

pub use plat::AsicLinkStats;
pub use plat::FsmState;
pub use plat::FsmType;
pub use plat::Handle;
pub use plat::PortFsmState;
pub use plat::Table;
8 changes: 8 additions & 0 deletions asic/src/softnpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ impl AsicOps for Handle {
Ok(())
}

fn port_prbs_get_err(
&self,
_port_hdl: PortHdl,
_ms: u32,
) -> AsicResult<Vec<u32>> {
Ok(Vec::new())
}

fn port_add(
&self,
connector: Connector,
Expand Down
17 changes: 9 additions & 8 deletions asic/src/tofino_asic/imported_bf_functions
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bf_rt_operations_counter_sync_set
bf_rt_begin_batch
bf_rt_end_batch

# pipe manager calls
# port manager calls
bf_pm_port_add
bf_pm_port_delete
bf_pm_port_delete_all
Expand All @@ -96,23 +96,24 @@ bf_pm_port_kr_mode_get
bf_pm_port_autoneg_set
bf_pm_port_autoneg_get
bf_pm_port_prbs_mode_set
bf_pm_port_prbs_mode_clear
bf_pm_port_prbs_mode_stats_get
bf_pm_port_ber_get
bf_pm_port_media_type_get
bf_pm_port_front_panel_port_get_first
bf_pm_port_front_panel_port_get_next
bf_pm_port_front_panel_port_to_dev_port_get
bf_pm_port_valid_speed_and_channel

bf_eth_cpu_port_get
bf_port_oper_state_get

bf_port_oper_state_get
bf_port_mac_stats_hw_sync_get
bf_port_pcs_counters_get
bf_port_rs_fec_status_and_counters_get
bf_port_encoding_mode_get
bf_port_speed_get

bf_pm_port_media_type_get
bf_pm_port_front_panel_port_get_first
bf_pm_port_front_panel_port_get_next
bf_pm_port_front_panel_port_to_dev_port_get
bf_pm_port_valid_speed_and_channel

bf_pm_serdes_tx_eq_override_set

# Platform functions
Expand Down
2 changes: 2 additions & 0 deletions asic/src/tofino_asic/imported_bf_types
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
bf_rmon_counter_t
bf_rmon_counter_array_t
bf_pm_fsm_st
bf_pm_port_info_t
pm_intf_fsm_states_t
bf_port_sds_prbs_stats_t
bf_port_ber_t
qsfp_fsm_state_t
qsfp_fsm_ch_en_state_t
Expand Down
78 changes: 64 additions & 14 deletions asic/src/tofino_asic/link_fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,52 @@ use aal::AsicResult;
/// The set of finite state machines we track
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum FsmType {
Port,
PortDfe,
PortAn,
PortPRBS,
PortPipeLoopback,
PortMacNearLoopback,
PortMacFarLoopback,
PortPcsLoopback,
PortSwModel,
PortTxMode,
PortEmulator,
Media,
Qsfp,
QsfpChannel,
}

impl FsmType {
pub fn is_port_fsm(&self) -> bool {
matches!(
self,
FsmType::PortDfe
| FsmType::PortAn
| FsmType::PortPRBS
| FsmType::PortPipeLoopback
| FsmType::PortMacNearLoopback
| FsmType::PortMacFarLoopback
| FsmType::PortPcsLoopback
| FsmType::PortSwModel
| FsmType::PortTxMode
| FsmType::PortEmulator
)
}
}

impl fmt::Display for FsmType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FsmType::Port => write!(f, "Port"),
FsmType::PortDfe => write!(f, "Port (Dfe)"),
FsmType::PortAn => write!(f, "Port (An)"),
FsmType::PortPRBS => write!(f, "Port (PRBS)"),
FsmType::PortPipeLoopback => write!(f, "Port (PipeLoopback)"),
FsmType::PortMacNearLoopback => write!(f, "Port (MacNearLoopback)"),
FsmType::PortMacFarLoopback => write!(f, "Port (MacFarLoopback)"),
FsmType::PortPcsLoopback => write!(f, "Port (PcsLoopback)"),
FsmType::PortSwModel => write!(f, "Port (SwModel)"),
FsmType::PortTxMode => write!(f, "Port (TxMode)"),
FsmType::PortEmulator => write!(f, "Port (Emulator)"),
FsmType::Media => write!(f, "Media"),
FsmType::Qsfp => write!(f, "Qsfp"),
FsmType::QsfpChannel => write!(f, "QsfpChannel"),
Expand All @@ -38,7 +74,28 @@ impl TryFrom<genpd::bf_fsm_type_t> for FsmType {

fn try_from(t: genpd::bf_fsm_type_t) -> AsicResult<Self> {
match t {
genpd::bf_fsm_type_t_BF_FSM_PORT => Ok(FsmType::Port),
genpd::bf_fsm_type_t_BF_FSM_PORT_DFE => Ok(FsmType::PortDfe),
genpd::bf_fsm_type_t_BF_FSM_PORT_AUTONEG => Ok(FsmType::PortAn),
genpd::bf_fsm_type_t_BF_FSM_PORT_PRBS => Ok(FsmType::PortPRBS),
genpd::bf_fsm_type_t_BF_FSM_PORT_PIPE_LOOPBACK => {
Ok(FsmType::PortPipeLoopback)
}
genpd::bf_fsm_type_t_BF_FSM_PORT_MAC_NEAR_LOOPBACK => {
Ok(FsmType::PortMacNearLoopback)
}
genpd::bf_fsm_type_t_BF_FSM_PORT_MAC_FAR_LOOPBACK => {
Ok(FsmType::PortMacFarLoopback)
}
genpd::bf_fsm_type_t_BF_FSM_PORT_PCS_LOOPBACK => {
Ok(FsmType::PortPcsLoopback)
}
genpd::bf_fsm_type_t_BF_FSM_PORT_SW_MODEL => {
Ok(FsmType::PortSwModel)
}
genpd::bf_fsm_type_t_BF_FSM_PORT_TX_MODE => Ok(FsmType::PortTxMode),
genpd::bf_fsm_type_t_BF_FSM_PORT_EMULATOR => {
Ok(FsmType::PortEmulator)
}
genpd::bf_fsm_type_t_BF_FSM_MEDIA => Ok(FsmType::Media),
genpd::bf_fsm_type_t_BF_FSM_QSFP => Ok(FsmType::Qsfp),
genpd::bf_fsm_type_t_BF_FSM_QSFP_CHANNEL => {
Expand All @@ -63,24 +120,17 @@ impl FsmState {
/// instance
pub fn new(fsm: u32, state: u32) -> AsicResult<Self> {
match FsmType::try_from(fsm)? {
FsmType::Port => Ok(FsmState::Port(PortFsmState::try_from(state)?)),
FsmType::Media => {
Ok(FsmState::Media(MediaFsmState::try_from(state)?))
}
FsmType::Qsfp => Ok(FsmState::Qsfp(QsfpFsmState::try_from(state)?)),
FsmType::QsfpChannel => {
Ok(FsmState::QsfpChannel(QsfpChannelFsmState::try_from(state)?))
}
}
}

/// Given an FsmState, return the name of the FSM to which it belongs
pub fn fsm(&self) -> FsmType {
match self {
FsmState::Port(_) => FsmType::Port,
FsmState::Media(_) => FsmType::Media,
FsmState::Qsfp(_) => FsmType::Qsfp,
FsmState::QsfpChannel(_) => FsmType::QsfpChannel,
x => {
assert!(x.is_port_fsm());
Ok(FsmState::Port(PortFsmState::try_from(state)?))
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions asic/src/tofino_asic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use aal::{
AsicError, AsicOps, AsicResult, Connector, PortHdl, SidecarIdentifiers,
};
pub use link_fsm::FsmState;
pub use link_fsm::FsmType;
pub use link_fsm::PortFsmState;

/// There are three generations of the Tofino ASIC, which the SDE refers to as
Expand Down Expand Up @@ -173,6 +174,14 @@ impl AsicOps for Handle {
ports::set_prbs(self, port_hdl, mode)
}

fn port_prbs_get_err(
&self,
port_hdl: PortHdl,
ms: u32,
) -> AsicResult<Vec<u32>> {
ports::get_err_prbs(self, port_hdl, ms)
}

fn port_ber_get(&self, port_hdl: PortHdl) -> AsicResult<aal::Ber> {
ports::get_ber(self, port_hdl)
}
Expand Down
Loading