Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`tofino_stub` returns port not found when trying to apply settings to `qsfp31`

未关闭
#271 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
rust
领域
networking

调研方向

从 asic/src/tofino_stub/ports.rs 开始,重点查看 tofino_stub::ports::init(),并追踪 PortMap 和 PortData 如何表示 QSFP 连接器。复现针对 Linux dpd stub 的 curl 请求,然后验证 qsfp31 成功,同时不使 qsfp0–qsfp30 的 settings 请求发生回归。

由索引模型根据 Issue 内容生成。

描述

On main, attempting to apply settings to port qsfp31 fails. Little dummy test with curl that hits the dpd stub binary built for Linux:

# request body
% cat req.json
{"links":{"0":{"addrs":[],"params":{"autoneg":false,"kr":false,"lane":0,"speed":"Speed0G"}}}}

# posting to qsfp0, ..., qsfp30 is fine
% curl -X POST -H 'content-type: application/json' -H 'api-version: 12.0.0' --data @req.json 'http://[::1]:12224/port/qsfp0/settings'
{"links":{"0":{"params":{"lane":0,"speed":"Speed0G","fec":null,"autoneg":false,"kr":false,"tx_eq":null},"addrs":[]}}}
% curl -X POST -H 'content-type: application/json' -H 'api-version: 12.0.0' --data @req.json 'http://[::1]:12224/port/qsfp30/settings'
{"links":{"0":{"params":{"lane":0,"speed":"Speed0G","fec":null,"autoneg":false,"kr":false,"tx_eq":null},"addrs":[]}}}

# posting to qsfp31 fails
% curl -X POST -H 'content-type: application/json' -H 'api-version: 12.0.0' --data @req.json 'http://[::1]:12224/port/qsfp31/settings'
{
  "request_id": "038b79cd-d798-41d8-8a73-90dbef511cfc",
  "error_code": "invalid data: no such port",
  "message": "no such port"
}

qsfp31 definitely works in the product (@sion42x has tested it on a racklette), so this appears to be a stub-only bug. I tried tracing through what's going on, and I think there's an off-by-one disagreement in Connector numbering between PortMap (which maps an API-level PortId to a Connector) and PortData (which maps a (Connector, channel) tuple to an ASIC ID):

  • PortMap maps PortId::Rear(0..32) to connectors QSFP(1..33) (but the order is scrambled) and then maps PortId::Qsfp(0..32) to connectors Qsfp(33..65) (not scrambled: PortId::Qsfp(0) becomes connector QSFP(33), up through PortId::Qsfp(31) mapping to connector QSFP(64)).
  • PortData's map of connectors to ASIC IDs contains keys for connectors QSFP(0..64); this does not have an entry for QSFP(64) itself.

When we try to map PortId::Qsfp(31) to an ASIC ID, PortMap tells us it's connector QSFP(64), and then we get the not found error when trying to look up QSFP(64) in PortData.

I'm very unfamiliar with all of this, but AFAICT, PortMap is shared between the stub and real ASIC, so the problem is presumably in the stub's PortData. If I change this line in asic::tofino_stub::ports::init():

+++ b/asic/src/tofino_stub/ports.rs
@@ -249,12 +249,13 @@ pub fn init() -> AsicResult<PortData> {
     let eth_port = Some(CPU_PORT as u16);
     connectors.insert(Connector::CPU, PhysPort::new(Connector::CPU)?);

-    for id in 0..QSFP_PORT_COUNT {
+    for id in 1..=QSFP_PORT_COUNT {
         let connector = Connector::QSFP(id);
         let mut phys_port = PhysPort::new(connector)?;
         phys_port.media = PortMedia::Optical;

I'm able to apply settings to qsfp31. But I don't know if shifting the connector indexing like this may cause other problems somewhere else in the stub.

主要语言
Rust
星标
21
派生
3
平均合并
8 小时 29 分钟
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oxidecomputer/dendrite 的其他 Issue

查看 oxidecomputer/dendrite 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。