Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
net_core.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2015 Intel Corporation
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12
13#ifndef ZEPHYR_INCLUDE_NET_NET_CORE_H_
14#define ZEPHYR_INCLUDE_NET_NET_CORE_H_
15
16#include <stdbool.h>
17#include <string.h>
18
19#include <zephyr/sys/__assert.h>
20#include <zephyr/kernel.h>
21
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
38
47
49
50#define NET_ASSERT(cond, ...) __ASSERT(cond, "" __VA_ARGS__)
51
52/* This needs to be here in order to avoid circular include dependency between
53 * net_pkt.h and net_if.h
54 */
55#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
56 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
57#if !defined(NET_PKT_DETAIL_STATS_COUNT)
58#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
59
60#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
61#define NET_PKT_DETAIL_STATS_COUNT 4
62#else
63#define NET_PKT_DETAIL_STATS_COUNT 3
64#endif /* CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
65
66#else
67#define NET_PKT_DETAIL_STATS_COUNT 4
68#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL */
69
70#endif /* !NET_PKT_DETAIL_STATS_COUNT */
71#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
72 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
73
75
76struct net_buf;
77struct net_pkt;
78struct net_context;
79struct net_if;
80
94
105int net_recv_data(struct net_if *iface, struct net_pkt *pkt);
106
120int net_try_send_data(struct net_pkt *pkt, k_timeout_t timeout);
121
134static inline int net_send_data(struct net_pkt *pkt)
135{
137
138 return net_try_send_data(pkt, timeout);
139}
140
142
143/* Some helper defines for traffic class support */
144#if defined(CONFIG_NET_TC_TX_COUNT) && defined(CONFIG_NET_TC_RX_COUNT)
145#define NET_TC_TX_COUNT CONFIG_NET_TC_TX_COUNT
146#define NET_TC_RX_COUNT CONFIG_NET_TC_RX_COUNT
147
148#if NET_TC_TX_COUNT > NET_TC_RX_COUNT
149#define NET_TC_COUNT NET_TC_TX_COUNT
150#else
151#define NET_TC_COUNT NET_TC_RX_COUNT
152#endif
153#else /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
154#define NET_TC_TX_COUNT 0
155#define NET_TC_RX_COUNT 0
156#define NET_TC_COUNT 0
157#endif /* CONFIG_NET_TC_TX_COUNT && CONFIG_NET_TC_RX_COUNT */
158
159#if CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO
160#define NET_TC_TX_EFFECTIVE_COUNT (NET_TC_TX_COUNT + 1)
161#else
162#define NET_TC_TX_EFFECTIVE_COUNT NET_TC_TX_COUNT
163#endif
164
165#if CONFIG_NET_TC_RX_SKIP_FOR_HIGH_PRIO
166#define NET_TC_RX_EFFECTIVE_COUNT (NET_TC_RX_COUNT + 1)
167#else
168#define NET_TC_RX_EFFECTIVE_COUNT NET_TC_RX_COUNT
169#endif
170
178struct net_l3_register {
182 const char * const name;
184 const struct net_l2 * const l2;
193 enum net_verdict (*handler)(struct net_if *iface,
194 uint16_t ptype,
195 struct net_pkt *pkt);
197 uint16_t ptype;
198};
199
200#define NET_L3_GET_NAME(l3_name, ptype) __net_l3_register_##l3_name##_##ptype
201
202#define NET_L3_REGISTER(_l2_type, _name, _ptype, _handler) \
203 static const STRUCT_SECTION_ITERABLE(net_l3_register, \
204 NET_L3_GET_NAME(_name, _ptype)) = { \
205 .ptype = _ptype, \
206 .handler = _handler, \
207 .name = STRINGIFY(_name), \
208 .l2 = _l2_type, \
209 };
210
211/* @endcond */
212
216
217#ifdef __cplusplus
218}
219#endif
220
221#endif /* ZEPHYR_INCLUDE_NET_NET_CORE_H_ */
#define K_FOREVER
Generate infinite timeout delay.
Definition kernel.h:1664
#define K_NO_WAIT
Generate null timeout delay.
Definition kernel.h:1554
bool k_is_in_isr(void)
Determine if code is running at interrupt level.
int net_recv_data(struct net_if *iface, struct net_pkt *pkt)
Called by lower network stack or network device driver when a network packet has been received.
static int net_send_data(struct net_pkt *pkt)
Send data to network.
Definition net_core.h:134
net_verdict
Net Verdict.
Definition net_core.h:84
int net_try_send_data(struct net_pkt *pkt, k_timeout_t timeout)
Try sending data to network.
@ NET_OK
Packet has been taken care of.
Definition net_core.h:86
@ NET_DROP
Packet must be dropped.
Definition net_core.h:92
@ NET_CONTINUE
Packet has not been touched, other part should decide about its fate.
Definition net_core.h:90
Public kernel APIs.
Public API for network link address.
Network timer with wrap around.
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Kernel timeout type.
Definition clock.h:65
Network buffer representation.
Definition net_buf.h:1006
Note that we do not store the actual source IP address in the context because the address is already ...
Definition net_context.h:209
Network Interface structure.
Definition net_if.h:731
Network packet.
Definition net_pkt.h:92