Skip to content

RFC: net: core: Dynamic priority and deferred processing #93341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ClaCodes
Copy link
Contributor

@ClaCodes ClaCodes commented Jul 18, 2025

Goal

To enable quality-of-service (QoS) applications, allow to reschedule/defer
the processing of a network packet based on its properties.

Based on: #93298

Future Work

  • Implement proper infrastructure to enpower application writers to hook in with custom rules for changing packet priorities based on respective properties of the packet at different layers (replace the sample update_priority)
    • At layer 2: ptype, src mac, dest mac, vlan-stuff
    • At layer 3: src ip, dest ip, protocol
    • At layer 4: port
  • Implement an interuption point between the deconding of the l2 header and the executing of the registered callbacks so that handling of layer 2 (or 3?) protocols may be defereed such as arp for example
  • Implement an interuption point between the deconding of the l3 header and the handling of udp and tcp etc.

ClaCodes added 4 commits July 18, 2025 06:39
Store the flag in the packet meta-data so that processing may be deferred
if necessary.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
Use the l2_processed-flag to decide whether a network packet needs to be
processed by an L2-handler. This could be used in the future to requeue
packets for later processing by a different traffic class queue.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
Specify the socket type, when inputing a packet into a packet-socket.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
When handling packets for inputing into packet-sockets, unconditionally
forward them, so that they may be handled by the rest of the network
stack after.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
@ClaCodes ClaCodes force-pushed the feature/delay_processing branch 2 times, most recently from 9247b83 to 47301bb Compare July 19, 2025 12:09
Store a flag about which layer has already processed a packet in its meta
information. This enables deferred processing of it.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
@ClaCodes ClaCodes force-pushed the feature/delay_processing branch from 47301bb to 26d64cc Compare July 19, 2025 12:30
Store a flag about which layer has already processed a packet in its meta
information. This enables deferred processing of it.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
@ClaCodes ClaCodes force-pushed the feature/delay_processing branch from 26d64cc to a4849f5 Compare July 19, 2025 12:37
Copy link

Copy link
Contributor

@rlubos rlubos left a comment

Choose a reason for hiding this comment

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

Some initial feedback (on the topmost 2 commits).

int priority;
int desired_priority;

thread_priority = tx_tc2thread(tc);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this use rx_tc2thread()? It looks that this function is currently used in the RX context?

update_priority(pkt);

if (!being_processed_by_correct_thread(pkt)) {
net_queue_rx(net_pkt_iface(pkt), pkt);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we requeue the packet I think we should quit processing_data() as well? The packet should be picked up by the same function, but on a different thread.

net_queue_rx(net_pkt_iface(pkt), pkt);
}

} while (true);
Copy link
Contributor

Choose a reason for hiding this comment

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

TBH I'm not too fond with this loop approach, it'll add extra processing time for each packet, regardless of whether this TC-requeueing feature is used.

default:
NET_DBG("Dropping pkt %p", pkt);

update_priority(pkt);
Copy link
Contributor

Choose a reason for hiding this comment

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

Plus, I wonder, shouldn't there be a spearate update_priority() function for each layer, by design? Just thinking out loud, but I imagine that after L3 has processed the packet, we shouldn't be using L2-specific rules anymore?

@@ -71,39 +71,39 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
if (!net_pkt_is_raw_processed(pkt)) {
net_pkt_set_raw_processed(pkt, true);
net_packet_socket_input(pkt, ETH_P_ALL, SOCK_RAW);
return NET_CONTINUE;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think packet-socket processing would require to recalculate the packet priority?

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.

4 participants