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