Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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 <net/ethernet.h>
16#include <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};
55
56#define NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION \
57 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_AUTO_NEGOTIATION)
58
59NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION);
60
61#define NET_REQUEST_ETHERNET_SET_LINK \
62 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_LINK)
63
64NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_LINK);
65
66#define NET_REQUEST_ETHERNET_SET_DUPLEX \
67 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_DUPLEX)
68
69NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_DUPLEX);
70
71#define NET_REQUEST_ETHERNET_SET_MAC_ADDRESS \
72 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS)
73
74NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS);
75
76#define NET_REQUEST_ETHERNET_SET_QAV_PARAM \
77 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QAV_PARAM)
78
79NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_PARAM);
80
81#define NET_REQUEST_ETHERNET_GET_PORTS_NUM \
82 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_PORTS_NUM)
83
84NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PORTS_NUM);
85
86#define NET_REQUEST_ETHERNET_SET_QBV_PARAM \
87 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QBV_PARAM)
88
89NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QBV_PARAM);
90
91#define NET_REQUEST_ETHERNET_SET_QBU_PARAM \
92 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QBU_PARAM)
93
94NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QBU_PARAM);
95
96#define NET_REQUEST_ETHERNET_SET_TXTIME_PARAM \
97 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_TXTIME_PARAM)
98
99NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_TXTIME_PARAM);
100
101#define NET_REQUEST_ETHERNET_SET_PROMISC_MODE \
102 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE)
103
104NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_PROMISC_MODE);
105
106#define NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM \
107 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_PRIORITY_QUEUES_NUM)
108
109NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM);
110
111#define NET_REQUEST_ETHERNET_GET_QAV_PARAM \
112 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QAV_PARAM)
113
114NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QAV_PARAM);
115
116#define NET_REQUEST_ETHERNET_GET_QBV_PARAM \
117 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QBV_PARAM)
118
119NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QBV_PARAM);
120
121#define NET_REQUEST_ETHERNET_GET_QBU_PARAM \
122 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QBU_PARAM)
123
124NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QBU_PARAM);
125
126#define NET_REQUEST_ETHERNET_GET_TXTIME_PARAM \
127 (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_TXTIME_PARAM)
128
129NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_TXTIME_PARAM);
130
131struct net_eth_addr;
132struct ethernet_qav_param;
133struct ethernet_qbv_param;
134struct ethernet_qbu_param;
136
137struct ethernet_req_params {
138 union {
139 bool auto_negotiation;
140 bool full_duplex;
141 bool promisc_mode;
142
143 struct {
144 bool link_10bt;
145 bool link_100bt;
146 bool link_1000bt;
147 } l;
148
149 struct net_eth_addr mac_address;
150
151 struct ethernet_qav_param qav_param;
152 struct ethernet_qbv_param qbv_param;
153 struct ethernet_qbu_param qbu_param;
154 struct ethernet_txtime_param txtime_param;
155
156 int priority_queues_num;
157 int ports_num;
158 };
159};
160
161enum net_event_ethernet_cmd {
162 NET_EVENT_ETHERNET_CMD_CARRIER_ON = 1,
163 NET_EVENT_ETHERNET_CMD_CARRIER_OFF,
164 NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED,
165 NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED,
166};
167
168#define NET_EVENT_ETHERNET_CARRIER_ON \
169 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_ON)
170
171#define NET_EVENT_ETHERNET_CARRIER_OFF \
172 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_OFF)
173
174#define NET_EVENT_ETHERNET_VLAN_TAG_ENABLED \
175 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED)
176
177#define NET_EVENT_ETHERNET_VLAN_TAG_DISABLED \
178 (_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED)
179
180struct net_if;
181
189#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
191#else
192static inline void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface)
193{
194 ARG_UNUSED(iface);
195}
196#endif
197
203#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
205#else
206static inline void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface)
207{
208 ARG_UNUSED(iface);
209}
210#endif
211
218#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
220#else
221static inline void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface,
223{
224 ARG_UNUSED(iface);
225 ARG_UNUSED(tag);
226}
227#endif
228
235#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
237 uint16_t tag);
238#else
239static inline void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface,
241{
242 ARG_UNUSED(iface);
243 ARG_UNUSED(tag);
244}
245#endif
246
251#ifdef __cplusplus
252}
253#endif
254
255#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)
Definition: net_mgmt.h:95
Network Management API public header.
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Definition: ethernet.h:196
Definition: ethernet.h:301
Definition: ethernet.h:237
Definition: ethernet.h:358
Network Interface structure.
Definition: net_if.h:468
static const char * tag(void)
Definition: main.c:27