Zephyr API 3.6.99
Loading...
Searching...
No Matches
ethernet_mgmt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_NET_ETHERNET_MGMT_H_
13#define ZEPHYR_INCLUDE_NET_ETHERNET_MGMT_H_
14
15#include <zephyr/net/ethernet.h>
16#include <zephyr/net/net_mgmt.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
33#define _NET_ETHERNET_LAYER NET_MGMT_LAYER_L2
34#define _NET_ETHERNET_CODE 0x208
35#define _NET_ETHERNET_BASE (NET_MGMT_IFACE_BIT | \
36 NET_MGMT_LAYER(_NET_ETHERNET_LAYER) | \
37 NET_MGMT_LAYER_CODE(_NET_ETHERNET_CODE))
38#define _NET_ETHERNET_EVENT (_NET_ETHERNET_BASE | NET_MGMT_EVENT_BIT)
39
40enum net_request_ethernet_cmd {
41 NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION = 1,
42 NET_REQUEST_ETHERNET_CMD_SET_LINK,
43 NET_REQUEST_ETHERNET_CMD_SET_DUPLEX,
44 NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS,
45 NET_REQUEST_ETHERNET_CMD_SET_QAV_PARAM,
46 NET_REQUEST_ETHERNET_CMD_SET_QBV_PARAM,
47 NET_REQUEST_ETHERNET_CMD_SET_QBU_PARAM,
48 NET_REQUEST_ETHERNET_CMD_SET_TXTIME_PARAM,
49 NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE,
50 NET_REQUEST_ETHERNET_CMD_GET_PRIORITY_QUEUES_NUM,
51 NET_REQUEST_ETHERNET_CMD_GET_QAV_PARAM,
52 NET_REQUEST_ETHERNET_CMD_GET_PORTS_NUM,
53 NET_REQUEST_ETHERNET_CMD_GET_QBV_PARAM,
54 NET_REQUEST_ETHERNET_CMD_GET_QBU_PARAM,
55 NET_REQUEST_ETHERNET_CMD_GET_TXTIME_PARAM,
56 NET_REQUEST_ETHERNET_CMD_SET_T1S_PARAM,
57 NET_REQUEST_ETHERNET_CMD_SET_TXINJECTION_MODE,
58 NET_REQUEST_ETHERNET_CMD_GET_TXINJECTION_MODE,
59 NET_REQUEST_ETHERNET_CMD_SET_MAC_FILTER,
60};
61
62#define NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION \
63 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION)
64
65NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION);
66
67#define NET_REQUEST_ETHERNET_SET_LINK \
68 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_LINK)
69
70NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_LINK);
71
72#define NET_REQUEST_ETHERNET_SET_DUPLEX \
73 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_DUPLEX)
74
75NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_DUPLEX);
76
77#define NET_REQUEST_ETHERNET_SET_MAC_ADDRESS \
78 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS)
79
80NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS);
81
82#define NET_REQUEST_ETHERNET_SET_QAV_PARAM \
83 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QAV_PARAM)
84
85NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_PARAM);
86
87#define NET_REQUEST_ETHERNET_GET_PORTS_NUM \
88 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_PORTS_NUM)
89
90NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PORTS_NUM);
91
92#define NET_REQUEST_ETHERNET_SET_QBV_PARAM \
93 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QBV_PARAM)
94
95NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QBV_PARAM);
96
97#define NET_REQUEST_ETHERNET_SET_QBU_PARAM \
98 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QBU_PARAM)
99
100NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QBU_PARAM);
101
102#define NET_REQUEST_ETHERNET_SET_TXTIME_PARAM \
103 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_TXTIME_PARAM)
104
105NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_TXTIME_PARAM);
106
107#define NET_REQUEST_ETHERNET_SET_PROMISC_MODE \
108 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE)
109
110NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_PROMISC_MODE);
111
112#define NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM \
113 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_PRIORITY_QUEUES_NUM)
114
115NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM);
116
117#define NET_REQUEST_ETHERNET_GET_QAV_PARAM \
118 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QAV_PARAM)
119
120NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QAV_PARAM);
121
122#define NET_REQUEST_ETHERNET_GET_QBV_PARAM \
123 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QBV_PARAM)
124
125NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QBV_PARAM);
126
127#define NET_REQUEST_ETHERNET_GET_QBU_PARAM \
128 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QBU_PARAM)
129
130NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QBU_PARAM);
131
132#define NET_REQUEST_ETHERNET_GET_TXTIME_PARAM \
133 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_TXTIME_PARAM)
134
135NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_TXTIME_PARAM);
136
137#define NET_REQUEST_ETHERNET_SET_T1S_PARAM \
138 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_T1S_PARAM)
139
140NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_T1S_PARAM);
141
142#define NET_REQUEST_ETHERNET_SET_TXINJECTION_MODE \
143 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_TXINJECTION_MODE)
144
145NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_TXINJECTION_MODE);
146
147#define NET_REQUEST_ETHERNET_GET_TXINJECTION_MODE \
148 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_TXINJECTION_MODE)
149
150NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_TXINJECTION_MODE);
151
152#define NET_REQUEST_ETHERNET_SET_MAC_FILTER \
153 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_MAC_FILTER)
154
155NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_FILTER);
156
157struct net_eth_addr;
158struct ethernet_qav_param;
159struct ethernet_qbv_param;
160struct ethernet_qbu_param;
162
163struct ethernet_req_params {
164 union {
165 bool auto_negotiation;
166 bool full_duplex;
167 bool promisc_mode;
168 bool txinjection_mode;
169
170 struct {
171 bool link_10bt;
172 bool link_100bt;
173 bool link_1000bt;
174 } l;
175
176 struct net_eth_addr mac_address;
177
178 struct ethernet_qav_param qav_param;
179 struct ethernet_qbv_param qbv_param;
180 struct ethernet_qbu_param qbu_param;
181 struct ethernet_txtime_param txtime_param;
182 struct ethernet_t1s_param t1s_param;
183
184 struct ethernet_filter filter;
185
186 int priority_queues_num;
187 int ports_num;
188 };
189};
190
191enum net_event_ethernet_cmd {
192 NET_EVENT_ETHERNET_CMD_CARRIER_ON = 1,
193 NET_EVENT_ETHERNET_CMD_CARRIER_OFF,
194 NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED,
195 NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED,
196};
197
198#define NET_EVENT_ETHERNET_CARRIER_ON \
199 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_ON)
200
201#define NET_EVENT_ETHERNET_CARRIER_OFF \
202 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_OFF)
203
204#define NET_EVENT_ETHERNET_VLAN_TAG_ENABLED \
205 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED)
206
207#define NET_EVENT_ETHERNET_VLAN_TAG_DISABLED \
208 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED)
209
210struct net_if;
211
219#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
221#else
222static inline void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface)
223{
224 ARG_UNUSED(iface);
225}
226#endif
227
233#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
235#else
236static inline void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface)
237{
238 ARG_UNUSED(iface);
239}
240#endif
241
248#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
250#else
251static inline void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface,
252 uint16_t tag)
253{
254 ARG_UNUSED(iface);
255 ARG_UNUSED(tag);
256}
257#endif
258
265#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
267 uint16_t tag);
268#else
269static inline void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface,
270 uint16_t tag)
271{
272 ARG_UNUSED(iface);
273 ARG_UNUSED(tag);
274}
275#endif
276
281#ifdef __cplusplus
282}
283#endif
284
285#endif /* ZEPHYR_INCLUDE_NET_ETHERNET_MGMT_H_ */
Ethernet.
void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface)
Raise CARRIER_OFF event when Ethernet is disconnected.
void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface)
Raise CARRIER_ON event when Ethernet is connected.
void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface, uint16_t tag)
Raise VLAN_DISABLED event when VLAN is disabled.
void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface, uint16_t tag)
Raise VLAN_ENABLED event when VLAN is enabled.
#define NET_MGMT_DEFINE_REQUEST_HANDLER(_mgmt_request)
Declare a request handler function for the given network event.
Definition net_mgmt.h:111
Network Management API public header.
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Ethernet filter description.
Definition ethernet.h:448
Ethernet Qav specific parameters.
Definition ethernet.h:290
Ethernet Qbu specific parameters.
Definition ethernet.h:399
Ethernet Qbv specific parameters.
Definition ethernet.h:332
Ethernet T1S specific parameters.
Definition ethernet.h:245
Ethernet TXTIME specific parameters.
Definition ethernet.h:466
Ethernet address.
Definition ethernet.h:53
Network Interface structure.
Definition net_if.h:680