Skip to content

Selector Packet Fanout - Core implementation#1329

Open
Hoooao wants to merge 4 commits intop4lang:mainfrom
Hoooao:main
Open

Selector Packet Fanout - Core implementation#1329
Hoooao wants to merge 4 commits intop4lang:mainfrom
Hoooao:main

Conversation

@Hoooao
Copy link
Copy Markdown
Contributor

@Hoooao Hoooao commented Oct 5, 2025

This PR is derived from #1316 .
The testcases will be in another PR.

Main updates after #1316 :

  1. Added command-line option --enable-pkt-fanout to configure, which defines PKT_FANOUT_ON. Is not supported in cmake for now.
  2. Raise an exception when selector_fanout mode is used while the above option is not given.
  3. Set the grp_selector for all specified selectors during switch start_and_return_, less intrusive.
  4. Previously, replicated pkts are pushed to ingress/egress-buffers in the ingress/egree_thread after the original packet gets processed. Now the logic is colocated with packet replication, which is much cleaner.

@Hoooao Hoooao force-pushed the main branch 2 times, most recently from 040e724 to 9ee035b Compare October 5, 2025 19:58
Hoooao added 4 commits October 6, 2025 19:03
Signed-off-by: Hoooao <hao021014@163.com>
Signed-off-by: Hoooao <hao021014@163.com>
Signed-off-by: Hoooao <hao021014@163.com>
Signed-off-by: Hoooao <hao021014@163.com>
@jafingerhut
Copy link
Copy Markdown
Contributor

@jonathan-dilorenzo FYI it would be good for someone in Google who wants this feature to learn enough about the code base to give it a good review. Unless you employ someone who knows this feature and how it works, or can contract with someone who does, any bugs discovered in it later are unlikely to be fixed by someone who is not interested in the feature.

Copy link
Copy Markdown
Contributor

@matthewtlam matthewtlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving behind first set of comments. Will add more later today

Comment thread configure.ac
])
])

# TODO: add this to cmake build as well
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this comment? I think you already added it to cmake build

fanout_ctx_map.emplace(thread_id, FanoutCtx(buffer_push_fn));
}

// TODO(Hao): deduplicate packets fanout, optional
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this comment?

std::unordered_map<grp_hdl_t, std::vector<mbr_hdl_t>> groups;
};

class FanoutPktMgr {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some documentation regarding the FanoutPktMgr. For example how it is used and use cases

bm::Logger::get()->error("[{}] [cxt {}] " s, (pkt).get_unique_id(), \
(pkt).get_context(), ##__VA_ARGS__)

#define BMLOG_WARN(...) bm::Logger::get()->warn(__VA_ARGS__)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see this MACRO being used anywhere so we can remove? Correct me if I am incorrect

packet->get_checksum_error() ? 1 : 0);
}
// Check if the packet has an optional continue node for pkt fanout
// TODO(Hao): update the doc/simple_switch.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this TODO?

@fruffy
Copy link
Copy Markdown
Contributor

fruffy commented Feb 6, 2026

@Hoooao What's the status of this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants