Skip to content

Commit 2d15696

Browse files
committed
net: shell: filter: Update table
Adjust table to print newly available information. Signed-off-by: Cla Mattia Galliard <[email protected]>
1 parent 78c703e commit 2d15696

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

subsys/net/ip/net_core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,7 @@ static void net_queue_rx(struct net_if *iface, struct net_pkt *pkt)
507507
#if NET_TC_RX_COUNT > 1
508508
NET_DBG("TC %d with prio %d pkt %p", tc, prio, pkt);
509509
#endif
510-
511-
if ((IS_ENABLED(CONFIG_NET_TC_RX_SKIP_FOR_HIGH_PRIO) &&
512-
prio >= NET_PRIORITY_CA) || NET_TC_RX_COUNT == 0) {
510+
if (!net_tc_rx_is_deferred(tc, prio)) {
513511
net_process_rx_packet(pkt);
514512
} else {
515513
if (net_tc_submit_to_rx_queue(tc, pkt) != NET_OK) {

subsys/net/ip/net_if.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,8 @@ void net_if_try_queue_tx(struct net_if *iface, struct net_pkt *pkt, k_timeout_t
366366
* the driver. Also if there are no TX queue/thread, push the packet
367367
* directly to the driver.
368368
*/
369-
if ((IS_ENABLED(CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO) &&
370-
prio >= NET_PRIORITY_CA) || NET_TC_TX_COUNT == 0) {
369+
if (!net_tc_tx_is_deferred(tc, prio)) {
371370
net_pkt_set_tx_stats_tick(pkt, k_cycle_get_32());
372-
373371
net_if_tx(net_pkt_iface(pkt), pkt);
374372
} else {
375373
if (net_tc_try_submit_to_tx_queue(tc, pkt, timeout) != NET_OK) {

subsys/net/ip/net_private.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ enum net_verdict net_tc_try_submit_to_tx_queue(uint8_t tc, struct net_pkt *pkt,
210210
extern enum net_verdict net_tc_submit_to_rx_queue(uint8_t tc, struct net_pkt *pkt);
211211
extern int net_tc_tx_thread_priority(int tc);
212212
extern int net_tc_rx_thread_priority(int tc);
213+
static inline bool net_tc_tx_is_deferred(int tc, int prio)
214+
{
215+
bool high_prio = (prio >= NET_PRIORITY_CA);
216+
bool skipping = IS_ENABLED(CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO);
217+
bool no_queues = (0 == CONFIG_NET_TC_TX_COUNT);
218+
return no_queues || !(high_prio && skipping);
219+
}
220+
static inline bool net_tc_rx_is_deferred(int tc, int prio)
221+
{
222+
bool high_prio = (prio >= NET_PRIORITY_CA);
223+
bool skipping = IS_ENABLED(CONFIG_NET_TC_RX_SKIP_FOR_HIGH_PRIO);
224+
bool no_queues = (0 == NET_TC_RX_COUNT);
225+
return no_queues || !(high_prio && skipping);
226+
}
213227
extern enum net_verdict net_promisc_mode_input(struct net_pkt *pkt);
214228

215229
char *net_sprint_addr(sa_family_t af, const void *addr);

subsys/net/lib/shell/filter.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,31 @@ static void rule_cb(struct npf_rule *rule, enum npf_rule_type type, void *user_d
5757
const struct shell *sh = data->sh;
5858
int *count = data->user_data;
5959

60-
PR("[%2d] %-10s %-7s %-5d",
61-
(*count) + 1, rule_type2str(type), verdict2str(rule->result), rule->nb_tests);
60+
PR("[%2d] %-10s %-8s ",
61+
(*count) + 1, rule_type2str(type), verdict2str(rule->result));
62+
63+
/* int thread_prio = net_tc_rx_thread_priority(int tc); */
64+
if (rule->result == NET_CONTINUE && type == NPF_RULE_TYPE_SEND) {
65+
uint8_t tc = net_tx_priority2tc(rule->priority);
66+
if (net_tc_tx_is_deferred(tc, rule->priority)) {
67+
int thread_prio = net_tc_tx_thread_priority(tc);
68+
PR("%8d %5d %11d ", rule->priority, tc, thread_prio);
69+
} else {
70+
PR("%8d %5d SKIP ", rule->priority, tc);
71+
}
72+
} else if (rule->result == NET_CONTINUE) {
73+
uint8_t tc = net_rx_priority2tc(rule->priority);
74+
if (net_tc_rx_is_deferred(tc, rule->priority)) {
75+
int thread_prio = net_tc_rx_thread_priority(tc);
76+
PR("%8d %5d %11d ", rule->priority, tc, thread_prio);
77+
} else {
78+
PR("%8d %5d SKIP ", rule->priority, tc);
79+
}
80+
} else {
81+
PR(" N/A N/A N/A ");
82+
}
83+
84+
PR("%-5d", rule->nb_tests);
6285

6386
for (int i = 0; i < rule->nb_tests; i++) {
6487
/* Allocate room for storing two full IPv4/6 addresses */
@@ -89,7 +112,7 @@ static int cmd_net_filter(const struct shell *sh, size_t argc, char *argv[])
89112
struct net_shell_user_data user_data;
90113
int count = 0;
91114

92-
PR("Rule %-10s Verdict Tests\n", "Type");
115+
PR("Rule %-10s Verdict Pkt-Prio Queue Thread-Prio Tests\n", "Type");
93116

94117
user_data.sh = sh;
95118
user_data.user_data = &count;

0 commit comments

Comments
 (0)