Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
offloaded_netdev.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2022 Nordic Semiconductor ASA
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12
13#ifndef ZEPHYR_INCLUDE_NET_OFFLOADED_NETDEV_H_
14#define ZEPHYR_INCLUDE_NET_OFFLOADED_NETDEV_H_
15
16#include <zephyr/kernel.h>
17#include <zephyr/types.h>
18#include <stdbool.h>
19#include <zephyr/net/net_if.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
33
48
53__subsystem struct offloaded_if_driver_api {
58 struct net_if_driver_api iface_api;
59
61 int (*enable)(const struct net_if *iface, bool state);
62
64 enum offloaded_net_if_types (*get_type)(void);
65};
66
68DEVICE_API_EXTENDS(offloaded_if, net_if, iface_api);
70
78static inline bool net_off_is_wifi_offloaded(struct net_if *iface)
79{
80 const struct device *dev = net_if_get_device(iface);
81 const struct offloaded_if_driver_api *api;
82
83 NET_ASSERT(dev != NULL);
84
85 api = (const struct offloaded_if_driver_api *)dev->api;
86
87 NET_ASSERT(api != NULL);
88
89 return api->get_type && api->get_type() == L2_OFFLOADED_NET_IF_TYPE_WIFI;
90}
91
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* ZEPHYR_INCLUDE_NET_OFFLOADED_NETDEV_H_ */
#define DEVICE_API_EXTENDS(_child, _parent, _member)
Declare that API class _child is an extension of device API class _parent.
Definition device.h:1470
static const struct device * net_if_get_device(struct net_if *iface)
Get an network interface's device.
Definition net_if.h:1205
offloaded_net_if_types
Types of offloaded netdev L2.
Definition offloaded_netdev.h:35
static bool net_off_is_wifi_offloaded(struct net_if *iface)
Check if the offloaded network interface supports Wi-Fi.
Definition offloaded_netdev.h:78
@ L2_OFFLOADED_NET_IF_TYPE_UNKNOWN
Unknown, device hasn't register a type.
Definition offloaded_netdev.h:37
@ L2_OFFLOADED_NET_IF_TYPE_ETHERNET
Ethernet devices.
Definition offloaded_netdev.h:40
@ L2_OFFLOADED_NET_IF_TYPE_MODEM
Modem.
Definition offloaded_netdev.h:43
@ L2_OFFLOADED_NET_IF_TYPE_WIFI
IEEE 802.11 Wi-Fi.
Definition offloaded_netdev.h:46
Public kernel APIs.
Public API for network interface.
state
Definition parser_state.h:29
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:549
Network Interface structure.
Definition net_if.h:875
Extended net_if_driver_api for offloaded ifaces/network devices, allowing handling of admin up/down s...
Definition offloaded_netdev.h:53
enum offloaded_net_if_types(* get_type)(void)
Types of offloaded net device.
Definition offloaded_netdev.h:64
int(* enable)(const struct net_if *iface, bool state)
Enable or disable the device (in response to admin state change).
Definition offloaded_netdev.h:61
struct net_if_driver_api iface_api
The net_if_driver_api must be placed in first position in this struct so that we are compatible with ...
Definition offloaded_netdev.h:58