net: Push highest priority net_pkt directly to driver

If user has set the priority of the sent net_pkt to highest
priority (NET_PRIORITY_CA) and enabled CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO
option, then push that packet directly to driver instead of TX queue.
This will make the TX sending latency smaller for the high priority
packet. This is not enabled by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-05-18 13:40:18 +03:00 committed by Jukka Rissanen
commit c59372b6e6
2 changed files with 20 additions and 2 deletions

View file

@ -170,6 +170,13 @@ config NET_TC_RX_COUNT
handled equally. In this implementation, the higher traffic class handled equally. In this implementation, the higher traffic class
value corresponds to lower thread priority. value corresponds to lower thread priority.
config NET_TC_SKIP_FOR_HIGH_PRIO
bool "Push high priority packets directly to network driver"
help
If this is set, then high priority (NET_PRIORITY_CA) net_pkt will be
pushed directly to network driver and will skip the traffic class
queues. This is currently not enabled by default.
choice NET_TC_THREAD_TYPE choice NET_TC_THREAD_TYPE
prompt "How the network RX/TX threads should work" prompt "How the network RX/TX threads should work"
help help

View file

@ -341,12 +341,23 @@ void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt)
uint8_t prio = net_pkt_priority(pkt); uint8_t prio = net_pkt_priority(pkt);
uint8_t tc = net_tx_priority2tc(prio); uint8_t tc = net_tx_priority2tc(prio);
k_work_init(net_pkt_work(pkt), process_tx_packet);
net_stats_update_tc_sent_pkt(iface, tc); net_stats_update_tc_sent_pkt(iface, tc);
net_stats_update_tc_sent_bytes(iface, tc, net_pkt_get_len(pkt)); net_stats_update_tc_sent_bytes(iface, tc, net_pkt_get_len(pkt));
net_stats_update_tc_sent_priority(iface, tc, prio); net_stats_update_tc_sent_priority(iface, tc, prio);
/* For highest priority packet, skip the TX queue and push directly to
* the driver.
*/
if (IS_ENABLED(CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO) &&
prio == NET_PRIORITY_CA) {
net_pkt_set_tx_stats_tick(pkt, k_cycle_get_32());
net_if_tx(net_pkt_iface(pkt), pkt);
return;
}
k_work_init(net_pkt_work(pkt), process_tx_packet);
#if NET_TC_TX_COUNT > 1 #if NET_TC_TX_COUNT > 1
NET_DBG("TC %d with prio %d pkt %p", tc, prio, pkt); NET_DBG("TC %d with prio %d pkt %p", tc, prio, pkt);
#endif #endif