Improve types for channels and lanes

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
rust
领域
networking

调研方向

从 asic/src/tofino_common/ports.rs、asic/src/tofino_asic/ports.rs 和 asic/src/tofino_asic/serdes.rs 开始,包括所引用的注释和通道跟踪代码。调查 lanes 和 channels 是否应保持区分,newtype 是否可以强制约束它们的范围,以及 Vec 是否合适。完成的标准是:实现所选表示,并记录其区别、边界和存储方面的理由。

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

描述

Explanation

Dendrite refers to channels in connector code and lanes in serdes code. I believe the types used for representing these could be improved. Here are some concerns in the current design:

https://github.com/oxidecomputer/dendrite/blob/f6d41dd821f88f09ce7539ec981642efd32797d5/asic/src/tofino_common/ports.rs#L19-L25
https://github.com/oxidecomputer/dendrite/blob/f6d41dd821f88f09ce7539ec981642efd32797d5/asic/src/tofino_asic/serdes.rs#L50-L58

  • The channels used by a port are stored in a Vec<u8>. But afaict the SDE uses base + offset during port creation, so we'd never have a port using non-contiguous lanes.

https://github.com/oxidecomputer/dendrite/blob/f6d41dd821f88f09ce7539ec981642efd32797d5/asic/src/tofino_common/ports.rs#L68-L72

Some non-contiguous tracking is required, but we also have a BTreeSet for available_channels.

https://github.com/oxidecomputer/dendrite/blob/f6d41dd821f88f09ce7539ec981642efd32797d5/asic/src/tofino_common/ports.rs#L221-L227

A final design will require further investigation, but I feel like we can use a more descriptive type than Vec<u8> for this. And if not, a doc comment is warranted.

Proposal
  • Decide whether we should continue differentiating lanes and channels in this code. Changes if warranted.
  • Explore if a newtype wrapper makes sense for lanes/channels. If keeping lanes and channels distinct, define and document how exactly they're different and why we're differentiating. Move boundary and range checking into the type(s).
  • Determine whether there's any more appropriate way to track channels than a Vec<u8>. If not, document why Vec is needed here.
主要语言
Rust
星标
22
派生
4
平均合并
4 天 20 小时
30 天内合并 PR
6

环境准备

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

从这里开始

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

oxidecomputer/dendrite 的其他 Issue

查看 oxidecomputer/dendrite 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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