Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ethernet.h
Go to the documentation of this file.
1
5
6/*
7 * Copyright (c) 2016 Intel Corporation
8 *
9 * SPDX-License-Identifier: Apache-2.0
10 */
11
12#ifndef ZEPHYR_INCLUDE_NET_ETHERNET_H_
13#define ZEPHYR_INCLUDE_NET_ETHERNET_H_
14
15#include <zephyr/kernel.h>
16#include <zephyr/types.h>
17#include <stdbool.h>
18#include <zephyr/sys/atomic.h>
19
20#include <zephyr/net/net_ip.h>
21#include <zephyr/net/net_pkt.h>
22#include <zephyr/net/lldp.h>
23#include <zephyr/sys/clock.h>
24#include <zephyr/sys/util.h>
25#include <zephyr/net/net_if.h>
27#include <zephyr/net/ptp_time.h>
28#include <zephyr/net/virtual.h>
30
31#if defined(CONFIG_NVMEM)
32#include <zephyr/nvmem.h>
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
47
48#define NET_ETH_ADDR_LEN 6U
49
54
56
57#define NET_ETH_HDR(pkt) ((struct net_eth_hdr *)net_pkt_data(pkt))
58
59/* clang-format off */
60/* zephyr-keep-sorted-start */
61#define NET_ETH_PTYPE_ALL 0x0003 /* from linux/if_ether.h */
62#define NET_ETH_PTYPE_ARP 0x0806
63#define NET_ETH_PTYPE_CAN 0x000C /* CAN: Controller Area Network */
64#define NET_ETH_PTYPE_CANFD 0x000D /* CANFD: CAN flexible data rate*/
65#define NET_ETH_PTYPE_EAPOL 0x888e
66#define NET_ETH_PTYPE_ECAT 0x88a4
67#define NET_ETH_PTYPE_HDLC 0x0019 /* HDLC frames (like in PPP) */
68#define NET_ETH_PTYPE_IEEE802154 0x00F6 /* from linux/if_ether.h: IEEE802.15.4 frame */
69#define NET_ETH_PTYPE_IP 0x0800
70#define NET_ETH_PTYPE_IPV6 0x86dd
71#define NET_ETH_PTYPE_LLDP 0x88cc
72#define NET_ETH_PTYPE_OAM 0x8902
73#define NET_ETH_PTYPE_PTP 0x88f7
74#define NET_ETH_PTYPE_TSN 0x22f0 /* TSN (IEEE 1722) packet */
75#define NET_ETH_PTYPE_VLAN 0x8100
76/* zephyr-keep-sorted-stop */
77/* clang-format on */
78
79/* zephyr-keep-sorted-start re(^#define) */
80#if !defined(ETH_P_8021Q)
81#define ETH_P_8021Q NET_ETH_PTYPE_VLAN
82#endif
83#if !defined(ETH_P_ALL)
84#define ETH_P_ALL NET_ETH_PTYPE_ALL
85#endif
86#if !defined(ETH_P_ARP)
87#define ETH_P_ARP NET_ETH_PTYPE_ARP
88#endif
89#if !defined(ETH_P_CAN)
90#define ETH_P_CAN NET_ETH_PTYPE_CAN
91#endif
92#if !defined(ETH_P_CANFD)
93#define ETH_P_CANFD NET_ETH_PTYPE_CANFD
94#endif
95#if !defined(ETH_P_EAPOL)
96#define ETH_P_EAPOL NET_ETH_PTYPE_EAPOL
97#endif
98#if !defined(ETH_P_ECAT)
99#define ETH_P_ECAT NET_ETH_PTYPE_ECAT
100#endif
101#if !defined(ETH_P_HDLC)
102#define ETH_P_HDLC NET_ETH_PTYPE_HDLC
103#endif
104#if !defined(ETH_P_IEEE802154)
105#define ETH_P_IEEE802154 NET_ETH_PTYPE_IEEE802154
106#endif
107#if !defined(ETH_P_IP)
108#define ETH_P_IP NET_ETH_PTYPE_IP
109#endif
110#if !defined(ETH_P_IPV6)
111#define ETH_P_IPV6 NET_ETH_PTYPE_IPV6
112#endif
113#if !defined(ETH_P_TSN)
114#define ETH_P_TSN NET_ETH_PTYPE_TSN
115#endif
116/* zephyr-keep-sorted-stop */
117
119
120#define NET_ETH_MINIMAL_FRAME_SIZE 60
121#define NET_ETH_MTU 1500
122
124
125#if defined(CONFIG_NET_VLAN)
126#define _NET_ETH_MAX_HDR_SIZE (sizeof(struct net_eth_vlan_hdr))
127#else
128#define _NET_ETH_MAX_HDR_SIZE (sizeof(struct net_eth_hdr))
129#endif
130
131#define _NET_ETH_MAX_FRAME_SIZE (NET_ETH_MTU + _NET_ETH_MAX_HDR_SIZE)
132
133#if defined(CONFIG_DSA_TAG_SIZE)
134#define DSA_TAG_SIZE CONFIG_DSA_TAG_SIZE
135#else
136#define DSA_TAG_SIZE 0
137#endif
138
139#define NET_ETH_MAX_FRAME_SIZE (_NET_ETH_MAX_FRAME_SIZE + DSA_TAG_SIZE)
140#define NET_ETH_MAX_HDR_SIZE (_NET_ETH_MAX_HDR_SIZE + DSA_TAG_SIZE)
141
142#define NET_ETH_VLAN_HDR_SIZE 4
143
145
208
222
224
225enum ethernet_config_type {
226 ETHERNET_CONFIG_TYPE_MAC_ADDRESS,
227 ETHERNET_CONFIG_TYPE_QAV_PARAM,
228 ETHERNET_CONFIG_TYPE_QBV_PARAM,
229 ETHERNET_CONFIG_TYPE_QBU_PARAM,
230 ETHERNET_CONFIG_TYPE_TXTIME_PARAM,
231 ETHERNET_CONFIG_TYPE_PROMISC_MODE,
232 ETHERNET_CONFIG_TYPE_PRIORITY_QUEUES_NUM,
233 ETHERNET_CONFIG_TYPE_FILTER,
234 ETHERNET_CONFIG_TYPE_PORTS_NUM,
235 ETHERNET_CONFIG_TYPE_TXINJECTION_MODE,
236 ETHERNET_CONFIG_TYPE_RX_CHECKSUM_SUPPORT,
237 ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT,
238 ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM,
239 ETHERNET_CONFIG_TYPE_STP_PORT_STATE,
240 ETHERNET_CONFIG_TYPE_FDB_FLUSH,
241};
242
243enum ethernet_qav_param_type {
244 ETHERNET_QAV_PARAM_TYPE_DELTA_BANDWIDTH,
245 ETHERNET_QAV_PARAM_TYPE_IDLE_SLOPE,
246 ETHERNET_QAV_PARAM_TYPE_OPER_IDLE_SLOPE,
247 ETHERNET_QAV_PARAM_TYPE_TRAFFIC_CLASS,
248 ETHERNET_QAV_PARAM_TYPE_STATUS,
249};
250
252
258 enum ethernet_qav_param_type type;
259 union {
263 unsigned int delta_bandwidth;
265 unsigned int idle_slope;
267 unsigned int oper_idle_slope;
269 unsigned int traffic_class;
270 } ;
271};
272
274
275enum ethernet_qbv_param_type {
276 ETHERNET_QBV_PARAM_TYPE_STATUS,
277 ETHERNET_QBV_PARAM_TYPE_GATE_CONTROL_LIST,
278 ETHERNET_QBV_PARAM_TYPE_GATE_CONTROL_LIST_LEN,
279 ETHERNET_QBV_PARAM_TYPE_TIME,
280};
281
282enum ethernet_qbv_state_type {
283 ETHERNET_QBV_STATE_TYPE_ADMIN,
284 ETHERNET_QBV_STATE_TYPE_OPER,
285};
286
287enum ethernet_gate_state_operation {
288 ETHERNET_SET_GATE_STATE,
289 ETHERNET_SET_AND_HOLD_MAC_STATE,
290 ETHERNET_SET_AND_RELEASE_MAC_STATE,
291};
292
294
300 enum ethernet_qbv_param_type type;
302 enum ethernet_qbv_state_type state;
303 union {
306
308 struct {
310 bool gate_status[NET_TC_TX_COUNT];
311
313 enum ethernet_gate_state_operation operation;
314
317
321
324
329 struct {
332
335
338 };
339 } ;
340};
341
343
344enum ethernet_qbu_param_type {
345 ETHERNET_QBU_PARAM_TYPE_STATUS,
346 ETHERNET_QBU_PARAM_TYPE_RELEASE_ADVANCE,
347 ETHERNET_QBU_PARAM_TYPE_HOLD_ADVANCE,
348 ETHERNET_QBU_PARAM_TYPE_PREEMPTION_STATUS_TABLE,
349
350 /* Some preemption settings are from Qbr spec. */
351 ETHERNET_QBR_PARAM_TYPE_LINK_PARTNER_STATUS,
352 ETHERNET_QBR_PARAM_TYPE_ADDITIONAL_FRAGMENT_SIZE,
353};
354
355enum ethernet_qbu_preempt_status {
356 ETHERNET_QBU_STATUS_EXPRESS,
357 ETHERNET_QBU_STATUS_PREEMPTABLE
358} __packed;
359
361
367 enum ethernet_qbu_param_type type;
368 union {
371
374
376 enum ethernet_qbu_preempt_status
377 frame_preempt_statuses[NET_TC_TX_COUNT];
378
381
384
390 } ;
391};
392
394
395enum ethernet_filter_type {
396 ETHERNET_FILTER_TYPE_SRC_MAC_ADDRESS,
397 ETHERNET_FILTER_TYPE_DST_MAC_ADDRESS,
398};
399
401
410
438 enum ethernet_filter_type type;
442 bool set;
443};
444
446
447/* How many L2 multicast addresses one interface can track. The build system
448 * sums up what the subsystems asked for and gives the result here, the
449 * Kconfig value is only the floor and is used if the header is compiled
450 * outside of a Zephyr build.
451 */
452#ifndef NET_ETH_MCAST_FILTER_COUNT
453#define NET_ETH_MCAST_FILTER_COUNT CONFIG_NET_L2_ETHERNET_MCAST_FILTER_COUNT
454#endif
455
456/* The L2 multicast addresses are tracked only if something joins the groups,
457 * either the IP level, a packet socket, or other parts of the system.
458 */
459#if defined(CONFIG_NET_L2_ETHERNET) && !defined(CONFIG_NET_RAW_MODE) && \
460 (NET_ETH_MCAST_FILTER_COUNT > 0)
461#define NET_ETH_MCAST_FILTER_SUPPORTED 1
462#endif
463
465
475
480
483
484 uint8_t _unused : 7;
485};
486
488
489enum ethernet_txtime_param_type {
490 ETHERNET_TXTIME_PARAM_TYPE_ENABLE_QUEUES,
491};
492
494
498 enum ethernet_txtime_param_type type;
503};
504
508 ETHERNET_CHECKSUM_SUPPORT_NONE = NET_IF_CHECKSUM_NONE_BIT,
510 ETHERNET_CHECKSUM_SUPPORT_IPV4_HEADER = NET_IF_CHECKSUM_IPV4_HEADER_BIT,
512 ETHERNET_CHECKSUM_SUPPORT_IPV4_ICMP = NET_IF_CHECKSUM_IPV4_ICMP_BIT,
514 ETHERNET_CHECKSUM_SUPPORT_IPV4_TCP = NET_IF_CHECKSUM_IPV4_TCP_BIT,
516 ETHERNET_CHECKSUM_SUPPORT_IPV4_UDP = NET_IF_CHECKSUM_IPV4_UDP_BIT,
518 ETHERNET_CHECKSUM_SUPPORT_IPV6_ICMP = NET_IF_CHECKSUM_IPV6_ICMP_BIT,
520 ETHERNET_CHECKSUM_SUPPORT_IPV6_TCP = NET_IF_CHECKSUM_IPV6_TCP_BIT,
522 ETHERNET_CHECKSUM_SUPPORT_IPV6_UDP = NET_IF_CHECKSUM_IPV6_UDP_BIT,
523};
524
543
545
546struct ethernet_config {
547 union {
548 bool promisc_mode;
549 bool txinjection_mode;
550
551 struct net_eth_addr mac_address;
552
553 struct ethernet_qav_param qav_param;
554 struct ethernet_qbv_param qbv_param;
555 struct ethernet_qbu_param qbu_param;
556 struct ethernet_txtime_param txtime_param;
557
558 int priority_queues_num;
559 int ports_num;
560
561 enum ethernet_checksum_support chksum_support;
562
563 struct ethernet_filter filter;
564
565 uint16_t extra_tx_pkt_headroom;
566
567 enum ethernet_stp_port_state stp_port_state;
568 } ;
569};
570
572
582
584__subsystem struct ethernet_driver_api {
589 struct net_if_driver_api iface_api;
590
595#if defined(CONFIG_NET_STATISTICS_ETHERNET)
596 struct net_stats_eth *(*get_stats)(const struct device *dev, struct net_if *iface);
597
603 struct net_stats_eth *(*get_stats_type)(const struct device *dev,
604 struct net_if *iface,
605 uint32_t type);
606#endif
607
609 int (*start)(const struct device *dev, struct net_if *iface);
610
612 int (*stop)(const struct device *dev, struct net_if *iface);
613
615 enum ethernet_hw_caps (*get_capabilities)(const struct device *dev, struct net_if *iface);
616
618 int (*set_config)(const struct device *dev,
619 struct net_if *iface,
620 enum ethernet_config_type type,
621 const struct ethernet_config *config);
622
624 int (*get_config)(const struct device *dev,
625 struct net_if *iface,
626 enum ethernet_config_type type,
627 struct ethernet_config *config);
628
634#if defined(CONFIG_NET_VLAN)
635 int (*vlan_setup)(const struct device *dev, struct net_if *iface,
636 uint16_t tag, bool enable);
637#endif /* CONFIG_NET_VLAN */
638
640#if defined(CONFIG_PTP_CLOCK)
641 const struct device *(*get_ptp_clock)(const struct device *dev, struct net_if *iface);
642#endif /* CONFIG_PTP_CLOCK */
643
645 const struct device *(*get_phy)(const struct device *dev, struct net_if *iface);
646
648 int (*send)(const struct device *dev, struct net_pkt *pkt);
649};
650
652
653DEVICE_API_EXTENDS(ethernet, net_if, iface_api);
654
655struct net_eth_hdr {
656 struct net_eth_addr dst;
657 struct net_eth_addr src;
658 uint16_t type;
659} __packed;
660
661struct ethernet_vlan {
663 struct net_if *iface;
664
666 uint16_t tag;
667};
668
669#if defined(CONFIG_NET_VLAN_COUNT)
670#define NET_VLAN_MAX_COUNT CONFIG_NET_VLAN_COUNT
671#else
672#define NET_VLAN_MAX_COUNT 0
673#endif
674
676
697
699
700enum ethernet_flags {
701 ETH_CARRIER_UP,
702};
703
705struct ethernet_context {
710
711#if defined(CONFIG_NET_ETHERNET_BRIDGE)
712 struct net_if *bridge;
713
714 /* Index of this interface in the port table of its bridge */
715 uint8_t bridge_port;
716#endif
717
724 struct k_work carrier_work;
725
727 struct net_if *iface;
728
729#if defined(CONFIG_NET_LLDP)
731 struct ethernet_lldp lldp;
732#endif
733
737 enum net_l2_flags ethernet_l2_flags;
738
739#if defined(CONFIG_NET_GPTP)
744 uint16_t gptp_port;
745#endif
746
747#if defined(CONFIG_NET_DSA)
749 enum dsa_port_type dsa_port;
750
752 void *dsa_switch_ctx;
753#endif
754
755#if defined(NET_ETH_MCAST_FILTER_SUPPORTED)
757 struct net_eth_mcast_addr mcast_addrs[NET_ETH_MCAST_FILTER_COUNT];
758#endif
759
761 bool is_net_carrier_up : 1;
762
764 bool is_init : 1;
765
767 enum ethernet_if_types eth_if_type;
768};
769
775void ethernet_init(struct net_if *iface);
776
777#define ETHERNET_L2_CTX_TYPE struct ethernet_context
778
779/* Separate header for VLAN as some of device interfaces might not
780 * support VLAN.
781 */
782struct net_eth_vlan_hdr {
783 struct net_eth_addr dst;
784 struct net_eth_addr src;
785 struct {
786 uint16_t tpid; /* tag protocol id */
787 uint16_t tci; /* tag control info */
788 } vlan;
789 uint16_t type;
790} __packed;
791
793
801static inline bool net_eth_is_addr_broadcast(struct net_eth_addr *addr)
802{
803 if (addr->addr[0] == 0xff &&
804 addr->addr[1] == 0xff &&
805 addr->addr[2] == 0xff &&
806 addr->addr[3] == 0xff &&
807 addr->addr[4] == 0xff &&
808 addr->addr[5] == 0xff) {
809 return true;
810 }
811
812 return false;
813}
814
822static inline bool net_eth_is_addr_all_zeroes(struct net_eth_addr *addr)
823{
824 if (addr->addr[0] == 0x00 &&
825 addr->addr[1] == 0x00 &&
826 addr->addr[2] == 0x00 &&
827 addr->addr[3] == 0x00 &&
828 addr->addr[4] == 0x00 &&
829 addr->addr[5] == 0x00) {
830 return true;
831 }
832
833 return false;
834}
835
843static inline bool net_eth_is_addr_unspecified(struct net_eth_addr *addr)
844{
845 if (addr->addr[0] == 0x00 &&
846 addr->addr[1] == 0x00 &&
847 addr->addr[2] == 0x00 &&
848 addr->addr[3] == 0x00 &&
849 addr->addr[4] == 0x00 &&
850 addr->addr[5] == 0x00) {
851 return true;
852 }
853
854 return false;
855}
856
864static inline bool net_eth_is_addr_multicast(struct net_eth_addr *addr)
865{
866 return addr->addr[0] & 0x01;
867}
868
876static inline bool net_eth_is_addr_unicast(struct net_eth_addr *addr)
877{
879}
880
888static inline bool net_eth_is_addr_valid(struct net_eth_addr *addr)
889{
891}
892
900static inline bool net_eth_is_addr_lldp_multicast(struct net_eth_addr *addr)
901{
902 if (addr->addr[0] == 0x01 &&
903 addr->addr[1] == 0x80 &&
904 addr->addr[2] == 0xc2 &&
905 addr->addr[3] == 0x00 &&
906 addr->addr[4] == 0x00 &&
907 addr->addr[5] == 0x0e) {
908 return true;
909 }
910
911 return false;
912}
913
921static inline bool net_eth_is_addr_ptp_multicast(struct net_eth_addr *addr)
922{
923 if (addr->addr[0] == 0x01 &&
924 addr->addr[1] == 0x1b &&
925 addr->addr[2] == 0x19 &&
926 addr->addr[3] == 0x00 &&
927 addr->addr[4] == 0x00 &&
928 addr->addr[5] == 0x00) {
929 return true;
930 }
931
932 return false;
933}
934
941
948void net_eth_ipv4_mcast_to_mac_addr(const struct net_in_addr *ipv4_addr,
949 struct net_eth_addr *mac_addr);
950
957void net_eth_ipv6_mcast_to_mac_addr(const struct net_in6_addr *ipv6_addr,
958 struct net_eth_addr *mac_addr);
959
968typedef void (*net_eth_mcast_addr_cb_t)(struct net_if *iface,
969 const struct net_eth_mcast_addr *addr,
970 void *user_data);
971
972#if defined(NET_ETH_MCAST_FILTER_SUPPORTED) || defined(__DOXYGEN__)
973
993 const struct net_eth_addr *addr);
994
1010 const struct net_eth_addr *addr);
1011
1025 void *user_data);
1026
1028
1042int net_eth_mcast_ip_addr_update(struct net_if *iface, const struct net_addr *addr, bool add);
1043
1045
1046#else /* NET_ETH_MCAST_FILTER_SUPPORTED */
1047
1048static inline int net_eth_mcast_addr_add(struct net_if *iface,
1049 const struct net_eth_addr *addr)
1050{
1051 ARG_UNUSED(iface);
1052 ARG_UNUSED(addr);
1053
1054 return -ENOTSUP;
1055}
1056
1057static inline int net_eth_mcast_addr_rm(struct net_if *iface,
1058 const struct net_eth_addr *addr)
1059{
1060 ARG_UNUSED(iface);
1061 ARG_UNUSED(addr);
1062
1063 return -ENOTSUP;
1064}
1065
1066static inline void net_eth_mcast_addr_foreach(struct net_if *iface,
1068 void *user_data)
1069{
1070 ARG_UNUSED(iface);
1071 ARG_UNUSED(cb);
1072 ARG_UNUSED(user_data);
1073}
1074
1075static inline int net_eth_mcast_ip_addr_update(struct net_if *iface __unused,
1076 const struct net_addr *addr __unused,
1077 bool add __unused)
1078{
1079 return -ENOTSUP;
1080}
1081
1082#endif /* NET_ETH_MCAST_FILTER_SUPPORTED */
1083
1091static inline
1093{
1094 const struct device *dev = net_if_get_device(iface);
1095 const struct ethernet_driver_api *api;
1096
1097 NET_ASSERT(dev != NULL);
1098
1099 api = (const struct ethernet_driver_api *)dev->api;
1100 if (api->get_capabilities == NULL) {
1101 return (enum ethernet_hw_caps)0;
1102 }
1103
1104 return api->get_capabilities(dev, iface);
1105}
1106
1114static inline enum dsa_port_type net_eth_get_dsa_port_type(struct net_if *iface)
1115{
1116#if defined(CONFIG_NET_DSA)
1117 struct ethernet_context *eth_ctx = net_if_l2_data(iface);
1118
1119 NET_ASSERT(eth_ctx != NULL);
1120
1121 return eth_ctx->dsa_port;
1122#else
1123 ARG_UNUSED(iface);
1124
1125 return NON_DSA_PORT;
1126#endif
1127}
1128
1138static inline
1139int net_eth_get_hw_config(struct net_if *iface, enum ethernet_config_type type,
1140 struct ethernet_config *config)
1141{
1142 const struct device *dev = net_if_get_device(iface);
1143 const struct ethernet_driver_api *eth;
1144
1145 NET_ASSERT(dev != NULL);
1146
1147 eth = (const struct ethernet_driver_api *)dev->api;
1148
1149 NET_ASSERT(eth != NULL);
1150
1151 if (!eth->get_config) {
1152 return -ENOTSUP;
1153 }
1154
1155 return eth->get_config(dev, iface, type, config);
1156}
1157
1158
1167#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1168int net_eth_vlan_enable(struct net_if *iface, uint16_t tag);
1169#else
1170static inline int net_eth_vlan_enable(struct net_if *iface, uint16_t tag)
1171{
1172 ARG_UNUSED(iface);
1173 ARG_UNUSED(tag);
1174
1175 return -EINVAL;
1176}
1177#endif
1178
1187#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1188int net_eth_vlan_disable(struct net_if *iface, uint16_t tag);
1189#else
1190static inline int net_eth_vlan_disable(struct net_if *iface, uint16_t tag)
1191{
1192 ARG_UNUSED(iface);
1193 ARG_UNUSED(tag);
1194
1195 return -EINVAL;
1196}
1197#endif
1198
1210#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1211uint16_t net_eth_get_vlan_tag(struct net_if *iface);
1212#else
1213static inline uint16_t net_eth_get_vlan_tag(struct net_if *iface)
1214{
1215 ARG_UNUSED(iface);
1216
1217 return NET_VLAN_TAG_UNSPEC;
1218}
1219#endif
1220
1230#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1231struct net_if *net_eth_get_vlan_iface(struct net_if *iface, uint16_t tag);
1232#else
1233static inline
1235{
1236 /* Special case for priority tagged frames, without vlan ifaces being present */
1237 if (IS_ENABLED(CONFIG_NET_VLAN) && (tag == NET_VLAN_TAG_PRIORITY)) {
1238 return iface;
1239 }
1240
1241 return NULL;
1242}
1243#endif
1244
1254static inline struct net_if *net_eth_get_vlan_main(struct net_if *iface)
1255{
1256 return net_virtual_get_iface(iface);
1257}
1258
1273#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1274bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
1275 struct net_if *iface);
1276#else
1277static inline bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
1278 struct net_if *iface)
1279{
1280 ARG_UNUSED(ctx);
1281 ARG_UNUSED(iface);
1282
1283 return IS_ENABLED(CONFIG_NET_VLAN);
1284}
1285#endif
1286
1294#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1295bool net_eth_get_vlan_status(struct net_if *iface);
1296#else
1297static inline bool net_eth_get_vlan_status(struct net_if *iface)
1298{
1299 ARG_UNUSED(iface);
1300
1301 return false;
1302}
1303#endif
1304
1312#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1313bool net_eth_is_vlan_interface(struct net_if *iface);
1314#else
1315static inline bool net_eth_is_vlan_interface(struct net_if *iface)
1316{
1317 ARG_UNUSED(iface);
1318
1319 return false;
1320}
1321#endif
1322
1324
1325#if !defined(CONFIG_ETH_DRIVER_RAW_MODE)
1326
1327#define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
1328 init_fn, pm, data, config, prio, \
1329 api, mtu) \
1330 Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
1331 init_fn, pm, data, config, prio, \
1332 api, ETHERNET_L2, \
1333 NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)
1334
1335#else /* CONFIG_ETH_DRIVER_RAW_MODE */
1336
1337#define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
1338 init_fn, pm, data, config, prio, \
1339 api, mtu) \
1340 Z_DEVICE_STATE_DEFINE(dev_id); \
1341 Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, NULL, \
1342 Z_DEVICE_DT_FLAGS(node_id), pm, data, \
1343 config, POST_KERNEL, prio, api, \
1344 &Z_DEVICE_STATE_NAME(dev_id));
1345
1346#endif /* CONFIG_ETH_DRIVER_RAW_MODE */
1347
1348#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
1349 config, prio, api, mtu) \
1350 Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, 0, \
1351 init_fn, pm, data, config, prio, \
1352 api, mtu)
1353
1355
1373#define ETH_NET_DEVICE_INIT(dev_id, name, init_fn, pm, data, config, \
1374 prio, api, mtu) \
1375 Z_ETH_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, name, init_fn, \
1376 pm, data, config, prio, api, mtu)
1377
1400#define ETH_NET_DEVICE_INIT_INSTANCE(dev_id, name, instance, init_fn, \
1401 pm, data, config, prio, api, mtu) \
1402 Z_ETH_NET_DEVICE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, name, \
1403 instance, init_fn, pm, data, \
1404 config, prio, api, mtu)
1405
1422#define ETH_NET_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, \
1423 prio, api, mtu) \
1424 Z_ETH_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
1425 DEVICE_DT_NAME(node_id), init_fn, pm, \
1426 data, config, prio, api, mtu)
1427
1437#define ETH_NET_DEVICE_DT_INST_DEFINE(inst, ...) \
1438 ETH_NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
1439
1447#define ETH_NET_L3_REGISTER(name, ptype, handler) \
1448 NET_L3_REGISTER(&NET_L2_GET_NAME(ETHERNET), name, ptype, handler)
1449
1464
1478#if defined(CONFIG_NVMEM) || defined(__DOXYGEN__)
1484#endif
1485};
1486
1501static inline int net_eth_mac_load(const struct net_eth_mac_config *cfg, uint8_t *mac_addr)
1502{
1503 if (cfg == NULL || cfg->type == NET_ETH_MAC_DEFAULT) {
1504 return -ENODATA;
1505 }
1506
1507 /* Copy the static part */
1508 memcpy(mac_addr, cfg->addr, cfg->addr_len);
1509
1510 if (cfg->type == NET_ETH_MAC_RANDOM) {
1511 sys_rand_get(&mac_addr[cfg->addr_len], NET_ETH_ADDR_LEN - cfg->addr_len);
1512
1513 /* Clear group bit, multicast (I/G) */
1514 mac_addr[0] &= ~0x01;
1515 /* Set MAC address locally administered, unicast (LAA) */
1516 mac_addr[0] |= 0x02;
1517
1518 return 0;
1519 }
1520
1521#if defined(CONFIG_NVMEM)
1522 if (cfg->type == NET_ETH_MAC_NVMEM) {
1523 return nvmem_cell_read(&cfg->cell, &mac_addr[cfg->addr_len], 0,
1524 NET_ETH_ADDR_LEN - cfg->addr_len);
1525 }
1526#endif
1527
1528 if (cfg->type == NET_ETH_MAC_STATIC) {
1529 return 0;
1530 }
1531
1532 return -ENODATA;
1533}
1534
1536
1537#if defined(CONFIG_NVMEM) || defined(__DOXYGEN__)
1544#define Z_NET_ETH_MAC_DEV_CONFIG_INIT_CELL(node_id) \
1545 .cell = NVMEM_CELL_GET_BY_NAME_OR(node_id, mac_address, {0}),
1546#else
1547#define Z_NET_ETH_MAC_DEV_CONFIG_INIT_CELL(node_id)
1548#endif
1549
1550#define Z_NET_ETH_MAC_DT_CONFIG_INIT_RANDOM(node_id) \
1551 { \
1552 .type = NET_ETH_MAC_RANDOM, \
1553 .addr = DT_PROP_OR(node_id, zephyr_mac_address_prefix, {0}), \
1554 .addr_len = DT_PROP_LEN_OR(node_id, zephyr_mac_address_prefix, 0), \
1555 }
1556
1557#define Z_NET_ETH_MAC_DT_CONFIG_INIT_NVMEM(node_id) \
1558 { \
1559 .type = NET_ETH_MAC_NVMEM, \
1560 .addr = DT_PROP_OR(node_id, zephyr_mac_address_prefix, {0}), \
1561 .addr_len = DT_PROP_LEN_OR(node_id, zephyr_mac_address_prefix, 0), \
1562 Z_NET_ETH_MAC_DEV_CONFIG_INIT_CELL(node_id) \
1563 }
1564
1565#define Z_NET_ETH_MAC_DT_CONFIG_INIT_STATIC(node_id) \
1566 { \
1567 .type = NET_ETH_MAC_STATIC, \
1568 .addr = DT_PROP(node_id, local_mac_address), \
1569 .addr_len = DT_PROP_LEN(node_id, local_mac_address), \
1570 }
1571
1572#define Z_NET_ETH_MAC_DT_CONFIG_INIT_DEFAULT(node_id) \
1573 { \
1574 .type = NET_ETH_MAC_DEFAULT, \
1575 }
1576
1578
1584#define NET_ETH_MAC_DT_CONFIG_INIT(node_id) \
1585 COND_CASE_1(DT_PROP(node_id, zephyr_random_mac_address), \
1586 (Z_NET_ETH_MAC_DT_CONFIG_INIT_RANDOM(node_id)), \
1587 DT_NVMEM_CELLS_HAS_NAME(node_id, mac_address), \
1588 (Z_NET_ETH_MAC_DT_CONFIG_INIT_NVMEM(node_id)), \
1589 DT_NODE_HAS_PROP(node_id, local_mac_address), \
1590 (Z_NET_ETH_MAC_DT_CONFIG_INIT_STATIC(node_id)), \
1591 (Z_NET_ETH_MAC_DT_CONFIG_INIT_DEFAULT(node_id)))
1592
1600#define NET_ETH_MAC_DT_INST_CONFIG_INIT(inst) \
1601 NET_ETH_MAC_DT_CONFIG_INIT(DT_DRV_INST(inst))
1602
1610void net_eth_carrier_set(struct net_if *iface, bool carrier_up);
1611
1618static inline void net_eth_carrier_on(struct net_if *iface)
1619{
1620 net_eth_carrier_set(iface, true);
1621}
1622
1629static inline void net_eth_carrier_off(struct net_if *iface)
1630{
1631 net_eth_carrier_set(iface, false);
1632}
1633
1643int net_eth_promisc_mode(struct net_if *iface, bool enable);
1644
1654int net_eth_txinjection_mode(struct net_if *iface, bool enable);
1655
1674int net_eth_mac_filter(struct net_if *iface, struct net_eth_addr *mac,
1675 enum ethernet_filter_type type, bool enable);
1676
1684const struct device *net_eth_get_phy(struct net_if *iface);
1685
1694#if defined(CONFIG_PTP_CLOCK)
1695const struct device *net_eth_get_ptp_clock(struct net_if *iface);
1696#else
1697static inline const struct device *net_eth_get_ptp_clock(struct net_if *iface)
1698{
1699 ARG_UNUSED(iface);
1700
1701 return NULL;
1702}
1703#endif
1704
1714__syscall const struct device *net_eth_get_ptp_clock_by_index(int index);
1715
1723static inline bool net_eth_type_is_wifi(struct net_if *iface)
1724{
1725 const struct ethernet_context *ctx = (struct ethernet_context *)
1726 net_if_l2_data(iface);
1727
1728 NET_ASSERT(ctx != NULL);
1729
1730 return ctx->eth_if_type == L2_ETH_IF_TYPE_WIFI;
1731}
1732
1740static inline bool net_eth_type_is_ethernet(struct net_if *iface)
1741{
1742 const struct ethernet_context *ctx = (struct ethernet_context *)net_if_l2_data(iface);
1743
1744 NET_ASSERT(ctx != NULL);
1745
1746 return ctx->eth_if_type == L2_ETH_IF_TYPE_ETHERNET;
1747}
1748
1754static inline void net_eth_set_if_type_wifi(struct net_if *iface)
1755{
1756 struct ethernet_context *ctx = (struct ethernet_context *)net_if_l2_data(iface);
1757
1758 NET_ASSERT(ctx != NULL);
1759
1760 ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI;
1761}
1762
1766
1767#ifdef __cplusplus
1768}
1769#endif
1770
1771#include <zephyr/syscalls/ethernet.h>
1772
1773#endif /* ZEPHYR_INCLUDE_NET_ETHERNET_H_ */
Header file for the Atomic operations API.
System clock APIs.
#define DEVICE_API_EXTENDS(_child, _parent, _member)
Declare that API class _child is an extension of device API class _parent.
Definition device.h:1470
VLAN specific definitions.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
static struct net_if * net_eth_get_vlan_main(struct net_if *iface)
Return main network interface that is attached to this VLAN tag.
Definition ethernet.h:1254
static int net_eth_get_hw_config(struct net_if *iface, enum ethernet_config_type type, struct ethernet_config *config)
Return ethernet device hardware configuration information.
Definition ethernet.h:1139
ethernet_if_types
Types of Ethernet L2.
Definition ethernet.h:403
static int net_eth_vlan_enable(struct net_if *iface, uint16_t tag)
Add VLAN tag to the interface.
Definition ethernet.h:1170
static enum dsa_port_type net_eth_get_dsa_port_type(struct net_if *iface)
Return the DSA port type of an Ethernet interface.
Definition ethernet.h:1114
static bool net_eth_is_addr_all_zeroes(struct net_eth_addr *addr)
Check if the Ethernet MAC address is a all zeroes address.
Definition ethernet.h:822
ethernet_stp_port_state
Spanning tree state of a port that forwards in hardware.
Definition ethernet.h:535
void net_eth_ipv4_mcast_to_mac_addr(const struct net_in_addr *ipv4_addr, struct net_eth_addr *mac_addr)
Convert IPv4 multicast address to Ethernet address.
static bool net_eth_is_addr_multicast(struct net_eth_addr *addr)
Check if the Ethernet MAC address is a multicast address.
Definition ethernet.h:864
static const struct device * net_eth_get_ptp_clock(struct net_if *iface)
Return PTP clock that is tied to this ethernet network interface.
Definition ethernet.h:1697
#define NET_ETH_ADDR_LEN
Ethernet MAC address length.
Definition ethernet.h:48
int net_eth_mcast_addr_rm(struct net_if *iface, const struct net_eth_addr *addr)
Leave a L2 multicast group on a network interface.
int net_eth_mcast_addr_add(struct net_if *iface, const struct net_eth_addr *addr)
Join a L2 multicast group on a network interface.
int net_eth_promisc_mode(struct net_if *iface, bool enable)
Set promiscuous mode either ON or OFF.
static uint16_t net_eth_get_vlan_tag(struct net_if *iface)
Return VLAN tag specified to network interface.
Definition ethernet.h:1213
static void net_eth_carrier_on(struct net_if *iface)
Inform ethernet L2 driver that ethernet carrier is detected.
Definition ethernet.h:1618
static bool net_eth_type_is_wifi(struct net_if *iface)
Check if the Ethernet L2 network interface can perform Wi-Fi.
Definition ethernet.h:1723
const struct device * net_eth_get_phy(struct net_if *iface)
Return the PHY device that is tied to this ethernet network interface.
static bool net_eth_is_addr_broadcast(struct net_eth_addr *addr)
Check if the Ethernet MAC address is a broadcast address.
Definition ethernet.h:801
static bool net_eth_get_vlan_status(struct net_if *iface)
Get VLAN status for a given network interface (enabled or not).
Definition ethernet.h:1297
void net_eth_mcast_addr_foreach(struct net_if *iface, net_eth_mcast_addr_cb_t cb, void *user_data)
Go through all the L2 multicast addresses of a network interface.
const struct device * net_eth_get_ptp_clock_by_index(int index)
Return PTP clock that is tied to this ethernet network interface index.
static bool net_eth_is_addr_unspecified(struct net_eth_addr *addr)
Check if the Ethernet MAC address is unspecified.
Definition ethernet.h:843
static bool net_eth_is_vlan_interface(struct net_if *iface)
Check if the given interface is a VLAN interface.
Definition ethernet.h:1315
void(* net_eth_mcast_addr_cb_t)(struct net_if *iface, const struct net_eth_mcast_addr *addr, void *user_data)
Callback used by net_eth_mcast_addr_foreach().
Definition ethernet.h:968
ethernet_hw_caps
Ethernet hardware capabilities.
Definition ethernet.h:147
int net_eth_mac_filter(struct net_if *iface, struct net_eth_addr *mac, enum ethernet_filter_type type, bool enable)
Set or unset HW filtering for MAC address mac.
void net_eth_ipv6_mcast_to_mac_addr(const struct net_in6_addr *ipv6_addr, struct net_eth_addr *mac_addr)
Convert IPv6 multicast address to Ethernet address.
static void net_eth_carrier_off(struct net_if *iface)
Inform ethernet L2 driver that ethernet carrier was lost.
Definition ethernet.h:1629
static int net_eth_mac_load(const struct net_eth_mac_config *cfg, uint8_t *mac_addr)
Load a MAC address from a MAC address configuration structure with the specified type.
Definition ethernet.h:1501
static void net_eth_set_if_type_wifi(struct net_if *iface)
Set the Ethernet interface type to Wi-Fi.
Definition ethernet.h:1754
void net_eth_carrier_set(struct net_if *iface, bool carrier_up)
Inform ethernet L2 driver that ethernet carrier is detected or was lost.
static enum ethernet_hw_caps net_eth_get_hw_capabilities(struct net_if *iface)
Return ethernet device hardware capability information.
Definition ethernet.h:1092
static int net_eth_vlan_disable(struct net_if *iface, uint16_t tag)
Remove VLAN tag from the interface.
Definition ethernet.h:1190
ethernet_checksum_support
Protocols that are supported by checksum offloading.
Definition ethernet.h:506
ethernet_stats_type
Ethernet statistics type (bitmap).
Definition ethernet.h:574
net_eth_mac_type
MAC address configuration types.
Definition ethernet.h:1451
static bool net_eth_is_vlan_enabled(struct ethernet_context *ctx, struct net_if *iface)
Check if there are any VLAN interfaces enabled to this specific Ethernet network interface or if prio...
Definition ethernet.h:1277
static struct net_if * net_eth_get_vlan_iface(struct net_if *iface, uint16_t tag)
Return network interface related to this VLAN tag.
Definition ethernet.h:1234
dsa_port_type
DSA port type of an Ethernet interface.
Definition ethernet.h:210
static bool net_eth_type_is_ethernet(struct net_if *iface)
Check if the Ethernet L2 network interface is cabled ethernet.
Definition ethernet.h:1740
const struct net_eth_addr * net_eth_broadcast_addr(void)
Return Ethernet broadcast address.
static bool net_eth_is_addr_unicast(struct net_eth_addr *addr)
Check if the Ethernet MAC address is an unicast address.
Definition ethernet.h:876
static bool net_eth_is_addr_lldp_multicast(struct net_eth_addr *addr)
Check if the Ethernet MAC address is a LLDP multicast address.
Definition ethernet.h:900
static bool net_eth_is_addr_ptp_multicast(struct net_eth_addr *addr)
Check if the Ethernet MAC address is a PTP multicast address.
Definition ethernet.h:921
static bool net_eth_is_addr_valid(struct net_eth_addr *addr)
Check if the Ethernet MAC address is valid.
Definition ethernet.h:888
int net_eth_txinjection_mode(struct net_if *iface, bool enable)
Set TX-Injection mode either ON or OFF.
@ L2_ETH_IF_TYPE_ETHERNET
IEEE 802.3 Ethernet (default).
Definition ethernet.h:405
@ L2_ETH_IF_TYPE_WIFI
IEEE 802.11 Wi-Fi.
Definition ethernet.h:408
@ ETHERNET_STP_PORT_STATE_DISCARDING
Neither learn source addresses nor forward frames.
Definition ethernet.h:537
@ ETHERNET_STP_PORT_STATE_LEARNING
Learn source addresses, do not forward frames.
Definition ethernet.h:539
@ ETHERNET_STP_PORT_STATE_FORWARDING
Learn source addresses and forward frames.
Definition ethernet.h:541
@ ETHERNET_HW_VLAN
VLAN supported.
Definition ethernet.h:155
@ ETHERNET_PRIORITY_QUEUES
Priority queues available.
Definition ethernet.h:179
@ ETHERNET_HW_VLAN_TAG_STRIP
VLAN Tag stripping.
Definition ethernet.h:185
@ ETHERNET_LINK_100BASE
100 Mbits link supported
Definition ethernet.h:161
@ ETHERNET_LINK_10BASE
10 Mbits link supported
Definition ethernet.h:158
@ ETHERNET_HW_FILTERING
MAC address filtering supported.
Definition ethernet.h:182
@ ETHERNET_LINK_1000BASE
1 Gbits link supported
Definition ethernet.h:164
@ ETHERNET_QBU
IEEE 802.1Qbu (frame preemption) supported.
Definition ethernet.h:191
@ ETHERNET_TXINJECTION_MODE
TX-Injection supported.
Definition ethernet.h:197
@ ETHERNET_QAV
IEEE 802.1Qav (credit-based shaping) supported.
Definition ethernet.h:173
@ ETHERNET_HW_RX_CHKSUM_OFFLOAD
RX Checksum offloading supported for all of IPv4, UDP, TCP.
Definition ethernet.h:152
@ ETHERNET_LINK_5000BASE
5 Gbits link supported
Definition ethernet.h:170
@ ETHERNET_HW_STP_PORT_STATE
The device applies a spanning tree port state to its hardware forwarding and passes BPDUs to the host...
Definition ethernet.h:206
@ ETHERNET_TXTIME
TXTIME supported.
Definition ethernet.h:194
@ ETHERNET_QBV
IEEE 802.1Qbv (scheduled traffic) supported.
Definition ethernet.h:188
@ ETHERNET_PROMISC_MODE
Promiscuous mode supported.
Definition ethernet.h:176
@ ETHERNET_HW_PORT_FORWARDING
The device forwards frames between its ports in hardware.
Definition ethernet.h:200
@ ETHERNET_HW_TX_CHKSUM_OFFLOAD
TX Checksum offloading supported for all of IPv4, UDP, TCP.
Definition ethernet.h:149
@ ETHERNET_LINK_2500BASE
2.5 Gbits link supported
Definition ethernet.h:167
@ ETHERNET_CHECKSUM_SUPPORT_IPV6_TCP
Device supports checksum offloading for TCP payload in IPv6.
Definition ethernet.h:520
@ ETHERNET_CHECKSUM_SUPPORT_IPV4_ICMP
Device supports checksum offloading for ICMPv4 payload.
Definition ethernet.h:512
@ ETHERNET_CHECKSUM_SUPPORT_IPV4_TCP
Device supports checksum offloading for TCP payload in IPv4.
Definition ethernet.h:514
@ ETHERNET_CHECKSUM_SUPPORT_IPV4_UDP
Device supports checksum offloading for UDP payload in IPv4.
Definition ethernet.h:516
@ ETHERNET_CHECKSUM_SUPPORT_IPV4_HEADER
Device supports checksum offloading for the IPv4 header.
Definition ethernet.h:510
@ ETHERNET_CHECKSUM_SUPPORT_IPV6_UDP
Device supports checksum offloading for UDP payload in IPv6.
Definition ethernet.h:522
@ ETHERNET_CHECKSUM_SUPPORT_NONE
Device does not support any L3/L4 checksum offloading.
Definition ethernet.h:508
@ ETHERNET_CHECKSUM_SUPPORT_IPV6_ICMP
Device supports checksum offloading for ICMPv6 payload.
Definition ethernet.h:518
@ ETHERNET_STATS_TYPE_VENDOR
Vendor statistics only.
Definition ethernet.h:578
@ ETHERNET_STATS_TYPE_ALL
All statistics.
Definition ethernet.h:580
@ ETHERNET_STATS_TYPE_COMMON
Common statistics only (excludes vendor statistics).
Definition ethernet.h:576
@ NET_ETH_MAC_RANDOM
A random MAC address is generated during initialization.
Definition ethernet.h:1455
@ NET_ETH_MAC_NVMEM
The MAC address is read from an NVMEM cell.
Definition ethernet.h:1460
@ NET_ETH_MAC_DEFAULT
MAC address is handled by the driver (backwards compatible case).
Definition ethernet.h:1453
@ NET_ETH_MAC_STATIC
A static MAC address is provided in the device tree.
Definition ethernet.h:1462
@ DSA_PORT
DSA switch port connected to another DSA switch.
Definition ethernet.h:220
@ DSA_CPU_PORT
DSA switch CPU port.
Definition ethernet.h:218
@ NON_DSA_PORT
Not a DSA port.
Definition ethernet.h:212
@ DSA_CONDUIT_PORT
Ethernet interface connected to the CPU port of a DSA switch.
Definition ethernet.h:214
@ DSA_USER_PORT
DSA switch user port.
Definition ethernet.h:216
enum net_verdict(* net_lldp_recv_cb_t)(struct net_if *iface, struct net_pkt *pkt)
LLDP Receive packet callback.
Definition lldp.h:213
static void * net_if_l2_data(struct net_if *iface)
Get a pointer to the interface L2 private data.
Definition net_if.h:1189
static const struct device * net_if_get_device(struct net_if *iface)
Get an network interface's device.
Definition net_if.h:1205
net_l2_flags
L2 flags.
Definition net_l2.h:37
int nvmem_cell_read(const struct nvmem_cell *cell, void *data, off_t off, size_t len)
Read data from an NVMEM cell.
void sys_rand_get(void *dst, size_t len)
Fill the destination buffer with random data values that should pass general randomness tests.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:166
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENODATA
Missing expected message data.
Definition errno.h:78
#define EINVAL
Invalid argument.
Definition errno.h:61
#define ENOTSUP
Unsupported value.
Definition errno.h:115
struct net_if * net_virtual_get_iface(struct net_if *iface)
Return network interface related to this virtual network interface.
#define NET_VLAN_TAG_UNSPEC
Unspecified VLAN tag value.
Definition ethernet_vlan.h:32
#define NET_VLAN_TAG_PRIORITY
VLAN ID for forwarding to the native interface (priority tagging).
Definition ethernet_vlan.h:35
Public kernel APIs.
LLDP definitions and handler.
Public API for network interface.
IPv6 and IPv4 definitions.
Network packet buffer descriptor API.
Public NVMEM header file.
flags
Definition parser.h:86
Public functions for the Precision Time Protocol time specification.
Random number generator header file.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
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
Ethernet L2 API operations.
Definition ethernet.h:584
int(* get_config)(const struct device *dev, struct net_if *iface, enum ethernet_config_type type, struct ethernet_config *config)
Get hardware specific configuration.
Definition ethernet.h:624
int(* send)(const struct device *dev, struct net_pkt *pkt)
Send a network packet.
Definition ethernet.h:648
enum ethernet_hw_caps(* get_capabilities)(const struct device *dev, struct net_if *iface)
Get the device capabilities.
Definition ethernet.h:615
int(* stop)(const struct device *dev, struct net_if *iface)
Stop the device.
Definition ethernet.h:612
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 ethernet.h:589
int(* set_config)(const struct device *dev, struct net_if *iface, enum ethernet_config_type type, const struct ethernet_config *config)
Set specific hardware configuration.
Definition ethernet.h:618
int(* start)(const struct device *dev, struct net_if *iface)
Collect optional ethernet specific statistics.
Definition ethernet.h:609
Ethernet filter description.
Definition ethernet.h:436
struct net_eth_addr mac_address
MAC address to filter.
Definition ethernet.h:440
bool set
Set (true) or unset (false) the filter.
Definition ethernet.h:442
enum ethernet_filter_type type
Type of filter.
Definition ethernet.h:438
Ethernet LLDP specific parameters.
Definition ethernet.h:678
const uint8_t * optional_du
LLDP Data Unit optional TLVs for the interface.
Definition ethernet.h:686
sys_snode_t node
Used for track timers.
Definition ethernet.h:680
net_lldp_recv_cb_t cb
LLDP RX callback function.
Definition ethernet.h:695
k_timepoint_t tx_timer_timeout
LLDP TX timer timeout.
Definition ethernet.h:692
size_t optional_len
Length of the optional Data Unit TLVs.
Definition ethernet.h:689
const struct net_lldpdu * lldpdu
LLDP Data Unit mandatory TLVs for the interface.
Definition ethernet.h:683
Ethernet Qav specific parameters.
Definition ethernet.h:254
bool enabled
True if Qav is enabled for queue.
Definition ethernet.h:261
unsigned int oper_idle_slope
Oper Idle Slope (bits per second).
Definition ethernet.h:267
enum ethernet_qav_param_type type
Type of Qav parameter.
Definition ethernet.h:258
unsigned int traffic_class
Traffic class the queue is bound to.
Definition ethernet.h:269
int queue_id
ID of the priority queue to use.
Definition ethernet.h:256
unsigned int idle_slope
Idle Slope (bits per second).
Definition ethernet.h:265
unsigned int delta_bandwidth
Delta Bandwidth (percentage of bandwidth).
Definition ethernet.h:263
Ethernet Qbu specific parameters.
Definition ethernet.h:363
enum ethernet_qbu_preempt_status frame_preempt_statuses[NET_TC_TX_COUNT]
sequence of framePreemptionAdminStatus values
Definition ethernet.h:376
uint32_t release_advance
Release advance (nanoseconds).
Definition ethernet.h:373
enum ethernet_qbu_param_type type
Type of Qbu parameter.
Definition ethernet.h:367
uint32_t hold_advance
Hold advance (nanoseconds).
Definition ethernet.h:370
bool enabled
True if Qbu is enabled or not.
Definition ethernet.h:380
bool link_partner_status
Link partner status (from Qbr).
Definition ethernet.h:383
int port_id
Port id.
Definition ethernet.h:365
uint8_t additional_fragment_size
Additional fragment size (from Qbr).
Definition ethernet.h:389
Ethernet Qbv specific parameters.
Definition ethernet.h:296
int port_id
Port id.
Definition ethernet.h:298
bool enabled
True if Qbv is enabled or not.
Definition ethernet.h:305
struct ethernet_qbv_param::@055246010323023270273151373302031315361103011354::@066201007326270006176246045126267167014036102070 gate_control
Gate control information.
enum ethernet_qbv_param_type type
Type of Qbv parameter.
Definition ethernet.h:300
uint16_t row
Gate control list row.
Definition ethernet.h:319
enum ethernet_qbv_state_type state
What state (Admin/Oper) parameters are these.
Definition ethernet.h:302
bool gate_status[NET_TC_TX_COUNT]
True = open, False = closed.
Definition ethernet.h:310
struct net_ptp_extended_time base_time
Base time.
Definition ethernet.h:331
uint32_t extension_time
Extension time (nanoseconds).
Definition ethernet.h:337
enum ethernet_gate_state_operation operation
GateState operation.
Definition ethernet.h:313
uint32_t time_interval
Time interval ticks (nanoseconds).
Definition ethernet.h:316
struct net_ptp_time cycle_time
Cycle time.
Definition ethernet.h:334
uint32_t gate_control_list_len
Number of entries in gate control list.
Definition ethernet.h:323
Ethernet TXTIME specific parameters.
Definition ethernet.h:496
bool enable_txtime
Enable or disable TXTIME per queue.
Definition ethernet.h:502
int queue_id
Queue number for configuring TXTIME.
Definition ethernet.h:500
enum ethernet_txtime_param_type type
Type of TXTIME parameter.
Definition ethernet.h:498
Kernel timepoint type.
Definition clock.h:289
Ethernet address.
Definition ethernet.h:51
uint8_t addr[6U]
Buffer storing the address.
Definition ethernet.h:52
MAC address configuration.
Definition ethernet.h:1466
enum net_eth_mac_type type
The configuration type.
Definition ethernet.h:1468
struct nvmem_cell cell
The NVMEM cell to read the MAC address from.
Definition ethernet.h:1483
uint8_t addr[6U]
The static MAC address part.
Definition ethernet.h:1475
uint8_t addr_len
The length of the statically provided part.
Definition ethernet.h:1477
L2 multicast address of a network interface.
Definition ethernet.h:472
struct net_eth_addr addr
Multicast MAC address.
Definition ethernet.h:474
uint8_t is_used
Is this address used or not.
Definition ethernet.h:482
atomic_t atomic_ref
Reference counter.
Definition ethernet.h:479
Network Interface structure.
Definition net_if.h:875
IPv6 address struct.
Definition net_ip.h:144
IPv4 address struct.
Definition net_ip.h:156
LLDP Data Unit (LLDPDU) shall contain the following ordered TLVs as stated in "8.2 LLDPDU format" fro...
Definition lldp.h:172
Network packet.
Definition net_pkt.h:119
Generalized Precision Time Protocol Extended Timestamp format.
Definition ptp_time.h:154
(Generalized) Precision Time Protocol Timestamp format.
Definition ptp_time.h:111
All Ethernet specific statistics.
Definition net_stats.h:650
Non-Volatile Memory cell representation.
Definition nvmem.h:37
Misc utilities.
Virtual Network Interface.