net: pkt: convert remaining users of ref to atomic_ref
The previous commit replaced the net_pkt element ref with an element atomic_ref. CI tests turned up more places where ref was used directly. This commit converts them to use the new element. Signed-off-by: Daniel Glöckner <dg@emlix.com>
This commit is contained in:
parent
5ef825fdf6
commit
d678f309b8
|
@ -677,7 +677,7 @@ static inline void ts_register_tx_event(struct eth_context *context)
|
|||
enet_ptp_time_data_t timeData;
|
||||
|
||||
pkt = ts_tx_pkt[ts_tx_rd];
|
||||
if (pkt && pkt->ref > 0) {
|
||||
if (pkt && atomic_get(&pkt->atomic_ref) > 0) {
|
||||
if (eth_get_ptp_data(net_pkt_iface(pkt), pkt, &timeData,
|
||||
true)) {
|
||||
int status;
|
||||
|
|
|
@ -355,7 +355,7 @@ struct net_pkt *net_pkt_get_reserve(struct k_mem_slab *slab,
|
|||
#if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
|
||||
NET_DBG("%s [%u] pkt %p ref %d (%s():%d)",
|
||||
slab2str(slab), k_mem_slab_num_free_get(slab),
|
||||
pkt, pkt->ref, caller, line);
|
||||
pkt, atomic_get(&pkt->atomic_ref), caller, line);
|
||||
#endif
|
||||
return pkt;
|
||||
}
|
||||
|
|
|
@ -969,12 +969,13 @@ static void tcp_sent_list_cb(struct net_tcp *tcp, void *user_data)
|
|||
struct net_buf *frag = pkt->frags;
|
||||
|
||||
if (!*printed) {
|
||||
PR("%p[%d/%zd]", pkt, pkt->ref,
|
||||
PR("%p[%d/%zd]", pkt, atomic_get(&pkt->atomic_ref),
|
||||
net_pkt_get_len(pkt));
|
||||
*printed = true;
|
||||
} else {
|
||||
PR(" %p[%d/%zd]",
|
||||
pkt, pkt->ref, net_pkt_get_len(pkt));
|
||||
pkt, atomic_get(&pkt->atomic_ref),
|
||||
net_pkt_get_len(pkt));
|
||||
}
|
||||
|
||||
if (frag) {
|
||||
|
@ -1074,7 +1075,7 @@ static void allocs_cb(struct net_pkt *pkt,
|
|||
if (func_alloc) {
|
||||
if (in_use) {
|
||||
PR("%p/%d\t%5s\t%5s\t%s():%d\n",
|
||||
pkt, pkt->ref, str,
|
||||
pkt, atomic_get(&pkt->atomic_ref), str,
|
||||
net_pkt_slab2str(pkt->slab),
|
||||
func_alloc, line_alloc);
|
||||
} else {
|
||||
|
|
|
@ -475,7 +475,7 @@ void test_arp(void)
|
|||
*/
|
||||
net_pkt_unref(pkt2);
|
||||
|
||||
zassert_equal(pkt->ref, 2,
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 2,
|
||||
"ARP cache should own the original packet");
|
||||
|
||||
/* Then a case where target is not in the same subnet */
|
||||
|
@ -579,7 +579,7 @@ void test_arp(void)
|
|||
/**TESTPOINTS: Check ARP reply*/
|
||||
zassert_false(send_status < 0, "ARP reply was not sent");
|
||||
|
||||
zassert_equal(pkt->ref, 1,
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 1,
|
||||
"ARP cache should no longer own the original packet");
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
|
|
|
@ -199,7 +199,7 @@ static void timestamp_setup(void)
|
|||
net_if_call_timestamp_cb(pkt);
|
||||
|
||||
zassert_true(timestamp_cb_called, "Timestamp callback not called\n");
|
||||
zassert_equal(pkt->ref, 0, "Pkt %p not released\n");
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 0, "Pkt %p not released\n");
|
||||
}
|
||||
|
||||
static void timestamp_callback_2(struct net_pkt *pkt)
|
||||
|
@ -246,7 +246,7 @@ static void timestamp_setup_2nd_iface(void)
|
|||
net_if_call_timestamp_cb(pkt);
|
||||
|
||||
zassert_true(timestamp_cb_called, "Timestamp callback not called\n");
|
||||
zassert_equal(pkt->ref, 0, "Pkt %p not released\n");
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 0, "Pkt %p not released\n");
|
||||
}
|
||||
|
||||
static void timestamp_setup_all(void)
|
||||
|
@ -272,7 +272,7 @@ static void timestamp_setup_all(void)
|
|||
net_if_call_timestamp_cb(pkt);
|
||||
|
||||
zassert_true(timestamp_cb_called, "Timestamp callback not called\n");
|
||||
zassert_equal(pkt->ref, 0, "Pkt %p not released\n");
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 0, "Pkt %p not released\n");
|
||||
|
||||
net_if_unregister_timestamp_cb(×tamp_cb_3);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ static void timestamp_cleanup(void)
|
|||
net_if_call_timestamp_cb(pkt);
|
||||
|
||||
zassert_false(timestamp_cb_called, "Timestamp callback called\n");
|
||||
zassert_false(pkt->ref < 1, "Pkt %p released\n");
|
||||
zassert_false(atomic_get(&pkt->atomic_ref) < 1, "Pkt %p released\n");
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
|
@ -502,8 +502,9 @@ static void check_timestamp_before_enabling(void)
|
|||
* should have unreffed the packet by now so the ref count
|
||||
* should be zero now.
|
||||
*/
|
||||
zassert_equal(pkt->ref, 0, "packet %p was not released (ref %d)\n",
|
||||
pkt, pkt->ref);
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 0,
|
||||
"packet %p was not released (ref %d)\n",
|
||||
pkt, atomic_get(&pkt->atomic_ref));
|
||||
}
|
||||
|
||||
static void check_timestamp_after_enabling(void)
|
||||
|
@ -524,8 +525,9 @@ static void check_timestamp_after_enabling(void)
|
|||
* and timestamp_cb() should have unreffed the packet by now so
|
||||
* the ref count should be zero at this point.
|
||||
*/
|
||||
zassert_equal(pkt->ref, 0, "packet %p was not released (ref %d)\n",
|
||||
pkt, pkt->ref);
|
||||
zassert_equal(atomic_get(&pkt->atomic_ref), 0,
|
||||
"packet %p was not released (ref %d)\n",
|
||||
pkt, atomic_get(&pkt->atomic_ref));
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
Loading…
Reference in a new issue