-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
net: tc: Limit the max amount of packets in the queue per traffic class #84442
base: main
Are you sure you want to change the base?
net: tc: Limit the max amount of packets in the queue per traffic class #84442
Conversation
Proposal for: #84415 |
12e8b94
to
20b7d7d
Compare
@@ -254,6 +269,8 @@ static void tc_rx_handler(void *p1, void *p2, void *p3) | |||
continue; | |||
} | |||
|
|||
k_sem_give(fifo_slot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted.
20b7d7d
to
5c78ff1
Compare
5c78ff1
to
5ff607b
Compare
5ff607b
to
830ae9a
Compare
Something that came to mind. The proposed approach is too conservative. It could be allowed for higher priority queues to hold all available packets. It could be only forbidden for lower priority queues.
Less conservative, but also starvation avoiding:
|
830ae9a
to
83c35af
Compare
Fixed copy paste mistake |
83c35af
to
44bc833
Compare
|
5db4c26
to
aa5c538
Compare
Thanks in advance |
b80466a
to
e67accc
Compare
Fixed silly mistakes |
e67accc
to
dc86bf0
Compare
Rebased and fixed build failure in tests. |
dc86bf0
to
e9fc34d
Compare
Fixed minor oversight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments for this, will continue the review later.
net_pkt_set_rx_stats_tick(pkt, k_cycle_get_32()); | ||
|
||
if (NET_TC_RX_COUNT == 0) { | ||
net_process_rx_packet(pkt); | ||
} else { | ||
net_tc_submit_to_rx_queue(tc, pkt); | ||
if (net_tc_submit_to_rx_queue(tc, pkt) != NET_OK) { | ||
goto drop; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit seems to be mixing statistics with other changes. Please only do the statistics update in this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, I have pushed the other stuff in the initial commit. Let me know if more splitting is needed.
@@ -328,6 +328,8 @@ struct net_stats_tc { | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tautology in commit net: net_tc: ...
subject, it is enough to have net: tc: ...
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -318,10 +364,14 @@ void net_tc_tx_init(void) | |||
|
|||
k_fifo_init(&tx_classes[i].fifo); | |||
|
|||
k_sem_init(&tx_classes[i].fifo_slot, NET_TC_TX_SLOTS, NET_TC_TX_SLOTS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing #if NET_TC_RX_COUNT > 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was of the opinion, that init
ing did not hurt.
Added
@@ -376,10 +426,14 @@ void net_tc_rx_init(void) | |||
|
|||
k_fifo_init(&rx_classes[i].fifo); | |||
|
|||
k_sem_init(&rx_classes[i].fifo_slot, NET_TC_RX_SLOTS, NET_TC_RX_SLOTS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -614,6 +614,9 @@ struct net_traffic_class { | |||
/** Fifo for handling this Tx or Rx packet */ | |||
struct k_fifo fifo; | |||
|
|||
/** Semaphore for tracking the available slots in the fifo */ | |||
struct k_sem fifo_slot; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we need a separate Kconfig option to enable this. User should be able to select if this is to be used or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not do that. If someone enables NET_TC_XX_COUNT>1
they expect the different traffic classes not being able to starve each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise it is effectively as if NET_TC_XX_COUNT==1
To avoid starvation of a traffic class by another, limit the maximum amount of packets, that can sit in a single traffic-class-fifo to a fraction of the maximum amount of available packets. In the tx-case also reserve packets for direct sending, in the case, where CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO is enabled. Signed-off-by: Cla Mattia Galliard <[email protected]>
e9fc34d
to
e853c6b
Compare
|
e853c6b
to
e8cff89
Compare
|
Add statistics about packets dropped in net_tc. Signed-off-by: Cla Mattia Galliard <[email protected]>
e8cff89
to
fe9a5b3
Compare
|
To avoid starvation of a traffic class by another, limit the maximum amount of packets, that can sit in a single traffic-class-fifo to a fraction of the maximum amount of available rx-packets.