@@ -63,6 +63,28 @@ LOG_MODULE_REGISTER(net_core, CONFIG_NET_CORE_LOG_LEVEL);
63
63
64
64
#include "net_stats.h"
65
65
66
+ static void net_queue_rx (struct net_if * iface , struct net_pkt * pkt );
67
+
68
+ static void update_priority_l2 (struct net_pkt * pkt )
69
+ {
70
+ /* This is just an example.
71
+ * Similar infrastructure with custom application rules like
72
+ * net_pkt_filter could be established
73
+ */
74
+ if (net_pkt_ll_proto_type (pkt ) == NET_ETH_PTYPE_PTP ) {
75
+ net_pkt_set_priority (pkt , NET_PRIORITY_IC );
76
+ }
77
+ }
78
+
79
+ static bool being_processed_by_correct_thread (struct net_pkt * pkt )
80
+ {
81
+ uint8_t prio = net_pkt_priority (pkt );
82
+ uint8_t tc = net_rx_priority2tc (prio );
83
+
84
+ return net_tc_rx_is_current_thread (tc );
85
+ }
86
+
87
+
66
88
#if defined(CONFIG_NET_NATIVE )
67
89
static inline enum net_verdict process_data (struct net_pkt * pkt )
68
90
{
@@ -77,27 +99,30 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
77
99
if (!pkt -> frags ) {
78
100
NET_DBG ("Corrupted packet (frags %p)" , pkt -> frags );
79
101
net_stats_update_processing_error (net_pkt_iface (pkt ));
80
-
81
102
return NET_DROP ;
82
103
}
83
104
84
105
if (!net_pkt_is_l2_processed (pkt )) {
85
- ret = net_if_recv_data (net_pkt_iface (pkt ), pkt );
86
106
net_pkt_set_l2_processed (pkt , true);
107
+ ret = net_if_recv_data (net_pkt_iface (pkt ), pkt );
87
108
if (ret != NET_CONTINUE ) {
88
109
if (ret == NET_DROP ) {
89
110
NET_DBG ("Packet %p discarded by L2" , pkt );
90
111
net_stats_update_processing_error (
91
112
net_pkt_iface (pkt ));
92
113
}
93
-
94
114
return ret ;
95
115
}
96
-
97
116
/* L2 has modified the buffer starting point, it is easier
98
117
* to re-initialize the cursor rather than updating it.
99
118
*/
100
119
net_pkt_cursor_init (pkt );
120
+
121
+ update_priority_l2 (pkt );
122
+ if (!being_processed_by_correct_thread (pkt )) {
123
+ net_queue_rx (net_pkt_iface (pkt ), pkt );
124
+ return NET_OK ;
125
+ }
101
126
}
102
127
103
128
if (IS_ENABLED (CONFIG_NET_SOCKETS_PACKET_DGRAM ) &&
@@ -128,7 +153,6 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
128
153
} else if (IS_ENABLED (CONFIG_NET_SOCKETS_CAN ) && family == AF_CAN ) {
129
154
return net_canbus_socket_input (pkt );
130
155
}
131
-
132
156
NET_DBG ("Unknown protocol family packet (0x%x)" , family );
133
157
return NET_DROP ;
134
158
}
@@ -137,6 +161,7 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
137
161
138
162
}
139
163
164
+
140
165
static void processing_data (struct net_pkt * pkt )
141
166
{
142
167
again :
0 commit comments