net: tc: Return information whether TX pkt was queued

We need to know whether the net_pkt was successfully placed
to transmit queue. It is possible in TX side, that the net_pkt
is already in TX queue when for example TCP packet is
re-transmitted, in which case the queue submit will fail.
This cannot happen in RX side as there are no timers involved.

It is required to check about such pending flag before trying to submit
it into the queue. Indeed, the work queue could be scheduled right after
such queuing, thus checking for the pending flag afterwards would
provide a false information.

It is unfortunate k_work_submit_to_queue() does not return anything as
it would simplify the code then.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-03-20 10:18:50 +02:00
commit 15dfa28c2e
2 changed files with 8 additions and 2 deletions

View file

@ -76,7 +76,7 @@ static inline enum net_verdict net_ipv6_input(struct net_pkt *pkt,
return NET_CONTINUE;
}
#endif
extern void net_tc_submit_to_tx_queue(u8_t tc, struct net_pkt *pkt);
extern bool net_tc_submit_to_tx_queue(u8_t tc, struct net_pkt *pkt);
extern void net_tc_submit_to_rx_queue(u8_t tc, struct net_pkt *pkt);
extern enum net_verdict net_promisc_mode_input(struct net_pkt *pkt);

View file

@ -29,9 +29,15 @@ K_THREAD_STACK_ARRAY_DEFINE(rx_stack, NET_TC_RX_COUNT,
static struct net_traffic_class tx_classes[NET_TC_TX_COUNT];
static struct net_traffic_class rx_classes[NET_TC_RX_COUNT];
void net_tc_submit_to_tx_queue(u8_t tc, struct net_pkt *pkt)
bool net_tc_submit_to_tx_queue(u8_t tc, struct net_pkt *pkt)
{
if (k_work_pending(net_pkt_work(pkt))) {
return false;
}
k_work_submit_to_queue(&tx_classes[tc].work_q, net_pkt_work(pkt));
return true;
}
void net_tc_submit_to_rx_queue(u8_t tc, struct net_pkt *pkt)