Loading...
Searching...
No Matches
compat.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Google LLC
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include "bhp/event.h"
21#include "event.h"
22#include "lwip/netif.h"
23#include "net/netif.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
32typedef struct {
34 struct netif lwip_netif;
37#ifdef MODULE_BHP_EVENT
39#endif
40#if (IS_USED(MODULE_NETDEV_NEW_API))
41 thread_t *thread_doing_tx;
42#endif
44
50static inline void lwip_netif_dev_lock_init(struct netif *netif)
51{
52 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
53 rmutex_init(&compat_netif->lock);
54}
55
61static inline void lwip_netif_dev_acquire(struct netif *netif)
62{
63 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
64 rmutex_lock(&compat_netif->lock);
65}
66
72static inline void lwip_netif_dev_release(struct netif *netif)
73{
74 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
75 rmutex_unlock(&compat_netif->lock);
76}
77
78#ifdef __cplusplus
79}
80#endif
81
static void lwip_netif_dev_release(struct netif *netif)
Release the LWIP netif network device.
Definition compat.h:72
static void lwip_netif_dev_acquire(struct netif *netif)
Acquire the LWIP netif network device.
Definition compat.h:61
static void lwip_netif_dev_lock_init(struct netif *netif)
Init the LWIP netif network device lock.
Definition compat.h:50
#define container_of(PTR, TYPE, MEMBER)
Returns the container of a pointer to a member.
Definition container.h:58
struct _thread thread_t
forward declaration for thread_t, defined in thread.h
Definition sched.h:150
void rmutex_lock(rmutex_t *rmutex)
Locks a recursive mutex, blocking.
static void rmutex_init(rmutex_t *rmutex)
Initializes a recursive mutex object.
Definition rmutex.h:71
void rmutex_unlock(rmutex_t *rmutex)
Unlocks the recursive mutex.
struct event event_t
event structure forward declaration
Definition event.h:132
Asynchronous sock using Event Queue definitions.
Common network interface API definitions.
Event based Bottom Half Processor descriptor.
Definition event.h:28
Bottom Half Processor descriptor.
Definition bhp.h:47
Representation of a network interface.
Definition compat.h:32
struct netif lwip_netif
lwIP interface data
Definition compat.h:34
netif_t common_netif
network interface descriptor
Definition compat.h:33
event_t ev_isr
ISR event.
Definition compat.h:36
rmutex_t lock
lock for the interface
Definition compat.h:35
Network interface descriptor.
Definition netif.h:68
Mutex structure.
Definition rmutex.h:34