Zephyr Project API 3.7.0
A Scalable Open Source RTOS
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
31#define _NET_ETHERNET_LAYER NET_MGMT_LAYER_L2
32#define _NET_ETHERNET_CODE 0x208
33#define _NET_ETHERNET_BASE (NET_MGMT_IFACE_BIT | \
34 NET_MGMT_LAYER(_NET_ETHERNET_LAYER) | \
35 NET_MGMT_LAYER_CODE(_NET_ETHERNET_CODE))
36#define _NET_ETHERNET_EVENT (_NET_ETHERNET_BASE | NET_MGMT_EVENT_BIT)
37
38enum net_request_ethernet_cmd {
39 NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION = 1,
40 NET_REQUEST_ETHERNET_CMD_SET_LINK,
41 NET_REQUEST_ETHERNET_CMD_SET_DUPLEX,
42 NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS,
43 NET_REQUEST_ETHERNET_CMD_SET_QAV_PARAM,
44 NET_REQUEST_ETHERNET_CMD_SET_QBV_PARAM,
45 NET_REQUEST_ETHERNET_CMD_SET_QBU_PARAM,
46 NET_REQUEST_ETHERNET_CMD_SET_TXTIME_PARAM,
47 NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE,
48 NET_REQUEST_ETHERNET_CMD_GET_PRIORITY_QUEUES_NUM,
49 NET_REQUEST_ETHERNET_CMD_GET_QAV_PARAM,
50 NET_REQUEST_ETHERNET_CMD_GET_PORTS_NUM,
51 NET_REQUEST_ETHERNET_CMD_GET_QBV_PARAM,
52 NET_REQUEST_ETHERNET_CMD_GET_QBU_PARAM,
53 NET_REQUEST_ETHERNET_CMD_GET_TXTIME_PARAM,
54 NET_REQUEST_ETHERNET_CMD_SET_T1S_PARAM,
55 NET_REQUEST_ETHERNET_CMD_SET_TXINJECTION_MODE,
56 NET_REQUEST_ETHERNET_CMD_GET_TXINJECTION_MODE,
57 NET_REQUEST_ETHERNET_CMD_SET_MAC_FILTER,
58};
59
60#define NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION \
61 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION)
62
63NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION);
64
65#define NET_REQUEST_ETHERNET_SET_LINK \
66 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_LINK)
67
68NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_LINK);
69
70#define NET_REQUEST_ETHERNET_SET_DUPLEX \
71 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_DUPLEX)
72
73NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_DUPLEX);
74
75#define NET_REQUEST_ETHERNET_SET_MAC_ADDRESS \
76 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS)
77
78NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS);
79
80#define NET_REQUEST_ETHERNET_SET_QAV_PARAM \
81 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QAV_PARAM)
82
83NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_PARAM);
84
85#define NET_REQUEST_ETHERNET_GET_PORTS_NUM \
86 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_PORTS_NUM)
87
88NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PORTS_NUM);
89
90#define NET_REQUEST_ETHERNET_SET_QBV_PARAM \
91 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QBV_PARAM)
92
93NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QBV_PARAM);
94
95#define NET_REQUEST_ETHERNET_SET_QBU_PARAM \
96 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QBU_PARAM)
97
98NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QBU_PARAM);
99
100#define NET_REQUEST_ETHERNET_SET_TXTIME_PARAM \
101 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_TXTIME_PARAM)
102
103NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_TXTIME_PARAM);
104
105#define NET_REQUEST_ETHERNET_SET_PROMISC_MODE \
106 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE)
107
108NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_PROMISC_MODE);
109
110#define NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM \
111 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_PRIORITY_QUEUES_NUM)
112
113NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM);
114
115#define NET_REQUEST_ETHERNET_GET_QAV_PARAM \
116 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QAV_PARAM)
117
118NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QAV_PARAM);
119
120#define NET_REQUEST_ETHERNET_GET_QBV_PARAM \
121 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QBV_PARAM)
122
123NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QBV_PARAM);
124
125#define NET_REQUEST_ETHERNET_GET_QBU_PARAM \
126 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QBU_PARAM)
127
128NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QBU_PARAM);
129
130#define NET_REQUEST_ETHERNET_GET_TXTIME_PARAM \
131 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_TXTIME_PARAM)
132
133NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_TXTIME_PARAM);
134
135#define NET_REQUEST_ETHERNET_SET_T1S_PARAM \
136 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_T1S_PARAM)
137
138NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_T1S_PARAM);
139
140#define NET_REQUEST_ETHERNET_SET_TXINJECTION_MODE \
141 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_TXINJECTION_MODE)
142
143NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_TXINJECTION_MODE);
144
145#define NET_REQUEST_ETHERNET_GET_TXINJECTION_MODE \
146 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_TXINJECTION_MODE)
147
148NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_TXINJECTION_MODE);
149
150#define NET_REQUEST_ETHERNET_SET_MAC_FILTER \
151 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_MAC_FILTER)
152
153NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_FILTER);
154
155struct net_eth_addr;
156struct ethernet_qav_param;
157struct ethernet_qbv_param;
158struct ethernet_qbu_param;
160
161struct ethernet_req_params {
162 union {
163 bool auto_negotiation;
164 bool full_duplex;
165 bool promisc_mode;
166 bool txinjection_mode;
167
168 struct {
169 bool link_10bt;
170 bool link_100bt;
171 bool link_1000bt;
172 } l;
173
174 struct net_eth_addr mac_address;
175
176 struct ethernet_qav_param qav_param;
177 struct ethernet_qbv_param qbv_param;
178 struct ethernet_qbu_param qbu_param;
179 struct ethernet_txtime_param txtime_param;
180 struct ethernet_t1s_param t1s_param;
181
182 struct ethernet_filter filter;
183
184 int priority_queues_num;
185 int ports_num;
186 };
187};
188
189enum net_event_ethernet_cmd {
190 NET_EVENT_ETHERNET_CMD_CARRIER_ON = 1,
191 NET_EVENT_ETHERNET_CMD_CARRIER_OFF,
192 NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED,
193 NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED,
194};
195
196#define NET_EVENT_ETHERNET_CARRIER_ON \
197 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_ON)
198
199#define NET_EVENT_ETHERNET_CARRIER_OFF \
200 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_OFF)
201
202#define NET_EVENT_ETHERNET_VLAN_TAG_ENABLED \
203 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED)
204
205#define NET_EVENT_ETHERNET_VLAN_TAG_DISABLED \
206 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED)
207
208struct net_if;
209
217#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
219#else
220static inline void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface)
221{
222 ARG_UNUSED(iface);
223}
224#endif
225
231#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
233#else
234static inline void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface)
235{
236 ARG_UNUSED(iface);
237}
238#endif
239
246#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
248#else
249static inline void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface,
251{
252 ARG_UNUSED(iface);
253 ARG_UNUSED(tag);
254}
255#endif
256
263#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
265 uint16_t tag);
266#else
267static inline void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface,
269{
270 ARG_UNUSED(iface);
271 ARG_UNUSED(tag);
272}
273#endif
274
279#ifdef __cplusplus
280}
281#endif
282
283#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:109
Network Management API public header.
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Ethernet filter description.
Definition ethernet.h:446
Ethernet Qav specific parameters.
Definition ethernet.h:288
Ethernet Qbu specific parameters.
Definition ethernet.h:397
Ethernet Qbv specific parameters.
Definition ethernet.h:330
Ethernet T1S specific parameters.
Definition ethernet.h:243
Ethernet TXTIME specific parameters.
Definition ethernet.h:464
Ethernet address.
Definition ethernet.h:51
Network Interface structure.
Definition net_if.h:678
static const char * tag(void)
Definition main.c:27