Zephyr API Documentation 4.5.0-rc1
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
210
211enum dsa_port_type {
212 NON_DSA_PORT,
213 DSA_CONDUIT_PORT,
214 DSA_USER_PORT,
215 DSA_CPU_PORT,
216 DSA_PORT,
217};
218
219enum ethernet_config_type {
220 ETHERNET_CONFIG_TYPE_MAC_ADDRESS,
221 ETHERNET_CONFIG_TYPE_QAV_PARAM,
222 ETHERNET_CONFIG_TYPE_QBV_PARAM,
223 ETHERNET_CONFIG_TYPE_QBU_PARAM,
224 ETHERNET_CONFIG_TYPE_TXTIME_PARAM,
225 ETHERNET_CONFIG_TYPE_PROMISC_MODE,
226 ETHERNET_CONFIG_TYPE_PRIORITY_QUEUES_NUM,
227 ETHERNET_CONFIG_TYPE_FILTER,
228 ETHERNET_CONFIG_TYPE_PORTS_NUM,
229 ETHERNET_CONFIG_TYPE_TXINJECTION_MODE,
230 ETHERNET_CONFIG_TYPE_RX_CHECKSUM_SUPPORT,
231 ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT,
232 ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM,
233};
234
235enum ethernet_qav_param_type {
236 ETHERNET_QAV_PARAM_TYPE_DELTA_BANDWIDTH,
237 ETHERNET_QAV_PARAM_TYPE_IDLE_SLOPE,
238 ETHERNET_QAV_PARAM_TYPE_OPER_IDLE_SLOPE,
239 ETHERNET_QAV_PARAM_TYPE_TRAFFIC_CLASS,
240 ETHERNET_QAV_PARAM_TYPE_STATUS,
241};
242
244
250 enum ethernet_qav_param_type type;
251 union {
255 unsigned int delta_bandwidth;
257 unsigned int idle_slope;
259 unsigned int oper_idle_slope;
261 unsigned int traffic_class;
262 } ;
263};
264
266
267enum ethernet_qbv_param_type {
268 ETHERNET_QBV_PARAM_TYPE_STATUS,
269 ETHERNET_QBV_PARAM_TYPE_GATE_CONTROL_LIST,
270 ETHERNET_QBV_PARAM_TYPE_GATE_CONTROL_LIST_LEN,
271 ETHERNET_QBV_PARAM_TYPE_TIME,
272};
273
274enum ethernet_qbv_state_type {
275 ETHERNET_QBV_STATE_TYPE_ADMIN,
276 ETHERNET_QBV_STATE_TYPE_OPER,
277};
278
279enum ethernet_gate_state_operation {
280 ETHERNET_SET_GATE_STATE,
281 ETHERNET_SET_AND_HOLD_MAC_STATE,
282 ETHERNET_SET_AND_RELEASE_MAC_STATE,
283};
284
286
292 enum ethernet_qbv_param_type type;
294 enum ethernet_qbv_state_type state;
295 union {
298
300 struct {
302 bool gate_status[NET_TC_TX_COUNT];
303
305 enum ethernet_gate_state_operation operation;
306
309
313
316
321 struct {
324
327
330 };
331 } ;
332};
333
335
336enum ethernet_qbu_param_type {
337 ETHERNET_QBU_PARAM_TYPE_STATUS,
338 ETHERNET_QBU_PARAM_TYPE_RELEASE_ADVANCE,
339 ETHERNET_QBU_PARAM_TYPE_HOLD_ADVANCE,
340 ETHERNET_QBU_PARAM_TYPE_PREEMPTION_STATUS_TABLE,
341
342 /* Some preemption settings are from Qbr spec. */
343 ETHERNET_QBR_PARAM_TYPE_LINK_PARTNER_STATUS,
344 ETHERNET_QBR_PARAM_TYPE_ADDITIONAL_FRAGMENT_SIZE,
345};
346
347enum ethernet_qbu_preempt_status {
348 ETHERNET_QBU_STATUS_EXPRESS,
349 ETHERNET_QBU_STATUS_PREEMPTABLE
350} __packed;
351
353
359 enum ethernet_qbu_param_type type;
360 union {
363
366
368 enum ethernet_qbu_preempt_status
369 frame_preempt_statuses[NET_TC_TX_COUNT];
370
373
376
382 } ;
383};
384
386
387enum ethernet_filter_type {
388 ETHERNET_FILTER_TYPE_SRC_MAC_ADDRESS,
389 ETHERNET_FILTER_TYPE_DST_MAC_ADDRESS,
390};
391
393
402
430 enum ethernet_filter_type type;
434 bool set;
435};
436
438
439/* How many L2 multicast addresses one interface can track. The build system
440 * sums up what the subsystems asked for and gives the result here, the
441 * Kconfig value is only the floor and is used if the header is compiled
442 * outside of a Zephyr build.
443 */
444#ifndef NET_ETH_MCAST_FILTER_COUNT
445#define NET_ETH_MCAST_FILTER_COUNT CONFIG_NET_L2_ETHERNET_MCAST_FILTER_COUNT
446#endif
447
448/* The L2 multicast addresses are tracked only if something joins the groups,
449 * either the IP level, a packet socket, or other parts of the system.
450 */
451#if defined(CONFIG_NET_L2_ETHERNET) && !defined(CONFIG_NET_RAW_MODE) && \
452 (NET_ETH_MCAST_FILTER_COUNT > 0)
453#define NET_ETH_MCAST_FILTER_SUPPORTED 1
454#endif
455
457
467
472
475
476 uint8_t _unused : 7;
477};
478
480
481enum ethernet_txtime_param_type {
482 ETHERNET_TXTIME_PARAM_TYPE_ENABLE_QUEUES,
483};
484
486
490 enum ethernet_txtime_param_type type;
495};
496
500 ETHERNET_CHECKSUM_SUPPORT_NONE = NET_IF_CHECKSUM_NONE_BIT,
502 ETHERNET_CHECKSUM_SUPPORT_IPV4_HEADER = NET_IF_CHECKSUM_IPV4_HEADER_BIT,
504 ETHERNET_CHECKSUM_SUPPORT_IPV4_ICMP = NET_IF_CHECKSUM_IPV4_ICMP_BIT,
506 ETHERNET_CHECKSUM_SUPPORT_IPV6_HEADER = NET_IF_CHECKSUM_IPV6_HEADER_BIT,
508 ETHERNET_CHECKSUM_SUPPORT_IPV6_ICMP = NET_IF_CHECKSUM_IPV6_ICMP_BIT,
510 ETHERNET_CHECKSUM_SUPPORT_TCP = NET_IF_CHECKSUM_TCP_BIT,
512 ETHERNET_CHECKSUM_SUPPORT_UDP = NET_IF_CHECKSUM_UDP_BIT,
513};
514
516
517struct ethernet_config {
518 union {
519 bool promisc_mode;
520 bool txinjection_mode;
521
522 struct net_eth_addr mac_address;
523
524 struct ethernet_qav_param qav_param;
525 struct ethernet_qbv_param qbv_param;
526 struct ethernet_qbu_param qbu_param;
527 struct ethernet_txtime_param txtime_param;
528
529 int priority_queues_num;
530 int ports_num;
531
532 enum ethernet_checksum_support chksum_support;
533
534 struct ethernet_filter filter;
535
536 uint16_t extra_tx_pkt_headroom;
537 } ;
538};
539
541
551
558 struct net_if_api iface_api;
559
564#if defined(CONFIG_NET_STATISTICS_ETHERNET)
565 struct net_stats_eth *(*get_stats)(const struct device *dev, struct net_if *iface);
566
572 struct net_stats_eth *(*get_stats_type)(const struct device *dev,
573 struct net_if *iface,
574 uint32_t type);
575#endif
576
578 int (*start)(const struct device *dev, struct net_if *iface);
579
581 int (*stop)(const struct device *dev, struct net_if *iface);
582
584 enum ethernet_hw_caps (*get_capabilities)(const struct device *dev, struct net_if *iface);
585
587 int (*set_config)(const struct device *dev,
588 struct net_if *iface,
589 enum ethernet_config_type type,
590 const struct ethernet_config *config);
591
593 int (*get_config)(const struct device *dev,
594 struct net_if *iface,
595 enum ethernet_config_type type,
596 struct ethernet_config *config);
597
603#if defined(CONFIG_NET_VLAN)
604 int (*vlan_setup)(const struct device *dev, struct net_if *iface,
605 uint16_t tag, bool enable);
606#endif /* CONFIG_NET_VLAN */
607
609#if defined(CONFIG_PTP_CLOCK)
610 const struct device *(*get_ptp_clock)(const struct device *dev, struct net_if *iface);
611#endif /* CONFIG_PTP_CLOCK */
612
614 const struct device *(*get_phy)(const struct device *dev, struct net_if *iface);
615
617 int (*send)(const struct device *dev, struct net_pkt *pkt);
618};
619
621
622/* Make sure that the network interface API is properly setup inside
623 * Ethernet API struct (it is the first one).
624 */
625BUILD_ASSERT(offsetof(struct ethernet_api, iface_api) == 0);
626
627struct net_eth_hdr {
628 struct net_eth_addr dst;
629 struct net_eth_addr src;
630 uint16_t type;
631} __packed;
632
633struct ethernet_vlan {
635 struct net_if *iface;
636
638 uint16_t tag;
639};
640
641#if defined(CONFIG_NET_VLAN_COUNT)
642#define NET_VLAN_MAX_COUNT CONFIG_NET_VLAN_COUNT
643#else
644#define NET_VLAN_MAX_COUNT 0
645#endif
646
648
669
671
672enum ethernet_flags {
673 ETH_CARRIER_UP,
674};
675
677struct ethernet_context {
682
683#if defined(CONFIG_NET_ETHERNET_BRIDGE)
684 struct net_if *bridge;
685#endif
686
693 struct k_work carrier_work;
694
696 struct net_if *iface;
697
698#if defined(CONFIG_NET_LLDP)
700 struct ethernet_lldp lldp;
701#endif
702
706 enum net_l2_flags ethernet_l2_flags;
707
708#if defined(CONFIG_NET_GPTP)
713 uint16_t gptp_port;
714#endif
715
716#if defined(CONFIG_NET_DSA)
718 enum dsa_port_type dsa_port;
719
721 void *dsa_switch_ctx;
722#endif
723
724#if defined(NET_ETH_MCAST_FILTER_SUPPORTED)
726 struct net_eth_mcast_addr mcast_addrs[NET_ETH_MCAST_FILTER_COUNT];
727#endif
728
730 bool is_net_carrier_up : 1;
731
733 bool is_init : 1;
734
736 enum ethernet_if_types eth_if_type;
737};
738
744void ethernet_init(struct net_if *iface);
745
746#define ETHERNET_L2_CTX_TYPE struct ethernet_context
747
748/* Separate header for VLAN as some of device interfaces might not
749 * support VLAN.
750 */
751struct net_eth_vlan_hdr {
752 struct net_eth_addr dst;
753 struct net_eth_addr src;
754 struct {
755 uint16_t tpid; /* tag protocol id */
756 uint16_t tci; /* tag control info */
757 } vlan;
758 uint16_t type;
759} __packed;
760
762
770static inline bool net_eth_is_addr_broadcast(struct net_eth_addr *addr)
771{
772 if (addr->addr[0] == 0xff &&
773 addr->addr[1] == 0xff &&
774 addr->addr[2] == 0xff &&
775 addr->addr[3] == 0xff &&
776 addr->addr[4] == 0xff &&
777 addr->addr[5] == 0xff) {
778 return true;
779 }
780
781 return false;
782}
783
791static inline bool net_eth_is_addr_all_zeroes(struct net_eth_addr *addr)
792{
793 if (addr->addr[0] == 0x00 &&
794 addr->addr[1] == 0x00 &&
795 addr->addr[2] == 0x00 &&
796 addr->addr[3] == 0x00 &&
797 addr->addr[4] == 0x00 &&
798 addr->addr[5] == 0x00) {
799 return true;
800 }
801
802 return false;
803}
804
812static inline bool net_eth_is_addr_unspecified(struct net_eth_addr *addr)
813{
814 if (addr->addr[0] == 0x00 &&
815 addr->addr[1] == 0x00 &&
816 addr->addr[2] == 0x00 &&
817 addr->addr[3] == 0x00 &&
818 addr->addr[4] == 0x00 &&
819 addr->addr[5] == 0x00) {
820 return true;
821 }
822
823 return false;
824}
825
833static inline bool net_eth_is_addr_multicast(struct net_eth_addr *addr)
834{
835 return addr->addr[0] & 0x01;
836}
837
845static inline bool net_eth_is_addr_unicast(struct net_eth_addr *addr)
846{
848}
849
857static inline bool net_eth_is_addr_valid(struct net_eth_addr *addr)
858{
860}
861
869static inline bool net_eth_is_addr_lldp_multicast(struct net_eth_addr *addr)
870{
871 if (addr->addr[0] == 0x01 &&
872 addr->addr[1] == 0x80 &&
873 addr->addr[2] == 0xc2 &&
874 addr->addr[3] == 0x00 &&
875 addr->addr[4] == 0x00 &&
876 addr->addr[5] == 0x0e) {
877 return true;
878 }
879
880 return false;
881}
882
890static inline bool net_eth_is_addr_ptp_multicast(struct net_eth_addr *addr)
891{
892 if (addr->addr[0] == 0x01 &&
893 addr->addr[1] == 0x1b &&
894 addr->addr[2] == 0x19 &&
895 addr->addr[3] == 0x00 &&
896 addr->addr[4] == 0x00 &&
897 addr->addr[5] == 0x00) {
898 return true;
899 }
900
901 return false;
902}
903
910
917void net_eth_ipv4_mcast_to_mac_addr(const struct net_in_addr *ipv4_addr,
918 struct net_eth_addr *mac_addr);
919
926void net_eth_ipv6_mcast_to_mac_addr(const struct net_in6_addr *ipv6_addr,
927 struct net_eth_addr *mac_addr);
928
937typedef void (*net_eth_mcast_addr_cb_t)(struct net_if *iface,
938 const struct net_eth_mcast_addr *addr,
939 void *user_data);
940
941#if defined(NET_ETH_MCAST_FILTER_SUPPORTED) || defined(__DOXYGEN__)
942
962 const struct net_eth_addr *addr);
963
979 const struct net_eth_addr *addr);
980
994 void *user_data);
995
997
1011int net_eth_mcast_ip_addr_update(struct net_if *iface, const struct net_addr *addr, bool add);
1012
1014
1015#else /* NET_ETH_MCAST_FILTER_SUPPORTED */
1016
1017static inline int net_eth_mcast_addr_add(struct net_if *iface,
1018 const struct net_eth_addr *addr)
1019{
1020 ARG_UNUSED(iface);
1021 ARG_UNUSED(addr);
1022
1023 return -ENOTSUP;
1024}
1025
1026static inline int net_eth_mcast_addr_rm(struct net_if *iface,
1027 const struct net_eth_addr *addr)
1028{
1029 ARG_UNUSED(iface);
1030 ARG_UNUSED(addr);
1031
1032 return -ENOTSUP;
1033}
1034
1035static inline void net_eth_mcast_addr_foreach(struct net_if *iface,
1037 void *user_data)
1038{
1039 ARG_UNUSED(iface);
1040 ARG_UNUSED(cb);
1041 ARG_UNUSED(user_data);
1042}
1043
1044static inline int net_eth_mcast_ip_addr_update(struct net_if *iface __unused,
1045 const struct net_addr *addr __unused,
1046 bool add __unused)
1047{
1048 return -ENOTSUP;
1049}
1050
1051#endif /* NET_ETH_MCAST_FILTER_SUPPORTED */
1052
1060static inline
1062{
1063 const struct device *dev = net_if_get_device(iface);
1064 const struct ethernet_api *api;
1065 enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0;
1066#if defined(CONFIG_NET_DSA)
1067 struct ethernet_context *eth_ctx = net_if_l2_data(iface);
1068
1069 NET_ASSERT(eth_ctx != NULL);
1070
1071 if (eth_ctx->dsa_port == DSA_CONDUIT_PORT) {
1073 } else if (eth_ctx->dsa_port == DSA_USER_PORT) {
1075 }
1076#endif
1077 NET_ASSERT(dev != NULL);
1078
1079 api = (const struct ethernet_api *)dev->api;
1080 if (api == NULL || api->get_capabilities == NULL) {
1081 return caps;
1082 }
1083
1084 return (enum ethernet_hw_caps)(caps | api->get_capabilities(dev, iface));
1085}
1086
1096static inline
1097int net_eth_get_hw_config(struct net_if *iface, enum ethernet_config_type type,
1098 struct ethernet_config *config)
1099{
1100 const struct device *dev = net_if_get_device(iface);
1101 const struct ethernet_api *eth;
1102
1103 NET_ASSERT(dev != NULL);
1104
1105 eth = (const struct ethernet_api *)dev->api;
1106
1107 NET_ASSERT(eth != NULL);
1108
1109 if (!eth->get_config) {
1110 return -ENOTSUP;
1111 }
1112
1113 return eth->get_config(dev, iface, type, config);
1114}
1115
1116
1125#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1126int net_eth_vlan_enable(struct net_if *iface, uint16_t tag);
1127#else
1128static inline int net_eth_vlan_enable(struct net_if *iface, uint16_t tag)
1129{
1130 ARG_UNUSED(iface);
1131 ARG_UNUSED(tag);
1132
1133 return -EINVAL;
1134}
1135#endif
1136
1145#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1146int net_eth_vlan_disable(struct net_if *iface, uint16_t tag);
1147#else
1148static inline int net_eth_vlan_disable(struct net_if *iface, uint16_t tag)
1149{
1150 ARG_UNUSED(iface);
1151 ARG_UNUSED(tag);
1152
1153 return -EINVAL;
1154}
1155#endif
1156
1168#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1169uint16_t net_eth_get_vlan_tag(struct net_if *iface);
1170#else
1171static inline uint16_t net_eth_get_vlan_tag(struct net_if *iface)
1172{
1173 ARG_UNUSED(iface);
1174
1175 return NET_VLAN_TAG_UNSPEC;
1176}
1177#endif
1178
1188#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1189struct net_if *net_eth_get_vlan_iface(struct net_if *iface, uint16_t tag);
1190#else
1191static inline
1193{
1194 /* Special case for priority tagged frames, without vlan ifaces being present */
1195 if (IS_ENABLED(CONFIG_NET_VLAN) && (tag == NET_VLAN_TAG_PRIORITY)) {
1196 return iface;
1197 }
1198
1199 return NULL;
1200}
1201#endif
1202
1212static inline struct net_if *net_eth_get_vlan_main(struct net_if *iface)
1213{
1214 return net_virtual_get_iface(iface);
1215}
1216
1231#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1232bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
1233 struct net_if *iface);
1234#else
1235static inline bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
1236 struct net_if *iface)
1237{
1238 ARG_UNUSED(ctx);
1239 ARG_UNUSED(iface);
1240
1241 return IS_ENABLED(CONFIG_NET_VLAN);
1242}
1243#endif
1244
1252#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1253bool net_eth_get_vlan_status(struct net_if *iface);
1254#else
1255static inline bool net_eth_get_vlan_status(struct net_if *iface)
1256{
1257 ARG_UNUSED(iface);
1258
1259 return false;
1260}
1261#endif
1262
1270#if defined(CONFIG_NET_VLAN) && NET_VLAN_MAX_COUNT > 0
1271bool net_eth_is_vlan_interface(struct net_if *iface);
1272#else
1273static inline bool net_eth_is_vlan_interface(struct net_if *iface)
1274{
1275 ARG_UNUSED(iface);
1276
1277 return false;
1278}
1279#endif
1280
1282
1283#if !defined(CONFIG_ETH_DRIVER_RAW_MODE)
1284
1285#define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
1286 init_fn, pm, data, config, prio, \
1287 api, mtu) \
1288 Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
1289 init_fn, pm, data, config, prio, \
1290 api, ETHERNET_L2, \
1291 NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)
1292
1293#else /* CONFIG_ETH_DRIVER_RAW_MODE */
1294
1295#define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
1296 init_fn, pm, data, config, prio, \
1297 api, mtu) \
1298 Z_DEVICE_STATE_DEFINE(dev_id); \
1299 Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, NULL, \
1300 Z_DEVICE_DT_FLAGS(node_id), pm, data, \
1301 config, POST_KERNEL, prio, api, \
1302 &Z_DEVICE_STATE_NAME(dev_id));
1303
1304#endif /* CONFIG_ETH_DRIVER_RAW_MODE */
1305
1306#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
1307 config, prio, api, mtu) \
1308 Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, 0, \
1309 init_fn, pm, data, config, prio, \
1310 api, mtu)
1311
1313
1331#define ETH_NET_DEVICE_INIT(dev_id, name, init_fn, pm, data, config, \
1332 prio, api, mtu) \
1333 Z_ETH_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, name, init_fn, \
1334 pm, data, config, prio, api, mtu)
1335
1358#define ETH_NET_DEVICE_INIT_INSTANCE(dev_id, name, instance, init_fn, \
1359 pm, data, config, prio, api, mtu) \
1360 Z_ETH_NET_DEVICE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, name, \
1361 instance, init_fn, pm, data, \
1362 config, prio, api, mtu)
1363
1380#define ETH_NET_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, \
1381 prio, api, mtu) \
1382 Z_ETH_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
1383 DEVICE_DT_NAME(node_id), init_fn, pm, \
1384 data, config, prio, api, mtu)
1385
1395#define ETH_NET_DEVICE_DT_INST_DEFINE(inst, ...) \
1396 ETH_NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
1397
1405#define ETH_NET_L3_REGISTER(name, ptype, handler) \
1406 NET_L3_REGISTER(&NET_L2_GET_NAME(ETHERNET), name, ptype, handler)
1407
1422
1436#if defined(CONFIG_NVMEM) || defined(__DOXYGEN__)
1442#endif
1443};
1444
1459static inline int net_eth_mac_load(const struct net_eth_mac_config *cfg, uint8_t *mac_addr)
1460{
1461 if (cfg == NULL || cfg->type == NET_ETH_MAC_DEFAULT) {
1462 return -ENODATA;
1463 }
1464
1465 /* Copy the static part */
1466 memcpy(mac_addr, cfg->addr, cfg->addr_len);
1467
1468 if (cfg->type == NET_ETH_MAC_RANDOM) {
1469 sys_rand_get(&mac_addr[cfg->addr_len], NET_ETH_ADDR_LEN - cfg->addr_len);
1470
1471 /* Clear group bit, multicast (I/G) */
1472 mac_addr[0] &= ~0x01;
1473 /* Set MAC address locally administered, unicast (LAA) */
1474 mac_addr[0] |= 0x02;
1475
1476 return 0;
1477 }
1478
1479#if defined(CONFIG_NVMEM)
1480 if (cfg->type == NET_ETH_MAC_NVMEM) {
1481 return nvmem_cell_read(&cfg->cell, &mac_addr[cfg->addr_len], 0,
1482 NET_ETH_ADDR_LEN - cfg->addr_len);
1483 }
1484#endif
1485
1486 if (cfg->type == NET_ETH_MAC_STATIC) {
1487 return 0;
1488 }
1489
1490 return -ENODATA;
1491}
1492
1494
1495#if defined(CONFIG_NVMEM) || defined(__DOXYGEN__)
1502#define Z_NET_ETH_MAC_DEV_CONFIG_INIT_CELL(node_id) \
1503 .cell = NVMEM_CELL_GET_BY_NAME_OR(node_id, mac_address, {0}),
1504#else
1505#define Z_NET_ETH_MAC_DEV_CONFIG_INIT_CELL(node_id)
1506#endif
1507
1508#define Z_NET_ETH_MAC_DT_CONFIG_INIT_RANDOM(node_id) \
1509 { \
1510 .type = NET_ETH_MAC_RANDOM, \
1511 .addr = DT_PROP_OR(node_id, zephyr_mac_address_prefix, {0}), \
1512 .addr_len = DT_PROP_LEN_OR(node_id, zephyr_mac_address_prefix, 0), \
1513 }
1514
1515#define Z_NET_ETH_MAC_DT_CONFIG_INIT_NVMEM(node_id) \
1516 { \
1517 .type = NET_ETH_MAC_NVMEM, \
1518 .addr = DT_PROP_OR(node_id, zephyr_mac_address_prefix, {0}), \
1519 .addr_len = DT_PROP_LEN_OR(node_id, zephyr_mac_address_prefix, 0), \
1520 Z_NET_ETH_MAC_DEV_CONFIG_INIT_CELL(node_id) \
1521 }
1522
1523#define Z_NET_ETH_MAC_DT_CONFIG_INIT_STATIC(node_id) \
1524 { \
1525 .type = NET_ETH_MAC_STATIC, \
1526 .addr = DT_PROP(node_id, local_mac_address), \
1527 .addr_len = DT_PROP_LEN(node_id, local_mac_address), \
1528 }
1529
1530#define Z_NET_ETH_MAC_DT_CONFIG_INIT_DEFAULT(node_id) \
1531 { \
1532 .type = NET_ETH_MAC_DEFAULT, \
1533 }
1534
1536
1542#define NET_ETH_MAC_DT_CONFIG_INIT(node_id) \
1543 COND_CASE_1(DT_PROP(node_id, zephyr_random_mac_address), \
1544 (Z_NET_ETH_MAC_DT_CONFIG_INIT_RANDOM(node_id)), \
1545 DT_NVMEM_CELLS_HAS_NAME(node_id, mac_address), \
1546 (Z_NET_ETH_MAC_DT_CONFIG_INIT_NVMEM(node_id)), \
1547 DT_NODE_HAS_PROP(node_id, local_mac_address), \
1548 (Z_NET_ETH_MAC_DT_CONFIG_INIT_STATIC(node_id)), \
1549 (Z_NET_ETH_MAC_DT_CONFIG_INIT_DEFAULT(node_id)))
1550
1558#define NET_ETH_MAC_DT_INST_CONFIG_INIT(inst) \
1559 NET_ETH_MAC_DT_CONFIG_INIT(DT_DRV_INST(inst))
1560
1568void net_eth_carrier_set(struct net_if *iface, bool carrier_up);
1569
1576static inline void net_eth_carrier_on(struct net_if *iface)
1577{
1578 net_eth_carrier_set(iface, true);
1579}
1580
1587static inline void net_eth_carrier_off(struct net_if *iface)
1588{
1589 net_eth_carrier_set(iface, false);
1590}
1591
1601int net_eth_promisc_mode(struct net_if *iface, bool enable);
1602
1612int net_eth_txinjection_mode(struct net_if *iface, bool enable);
1613
1632int net_eth_mac_filter(struct net_if *iface, struct net_eth_addr *mac,
1633 enum ethernet_filter_type type, bool enable);
1634
1642const struct device *net_eth_get_phy(struct net_if *iface);
1643
1652#if defined(CONFIG_PTP_CLOCK)
1653const struct device *net_eth_get_ptp_clock(struct net_if *iface);
1654#else
1655static inline const struct device *net_eth_get_ptp_clock(struct net_if *iface)
1656{
1657 ARG_UNUSED(iface);
1658
1659 return NULL;
1660}
1661#endif
1662
1672__syscall const struct device *net_eth_get_ptp_clock_by_index(int index);
1673
1681static inline bool net_eth_type_is_wifi(struct net_if *iface)
1682{
1683 const struct ethernet_context *ctx = (struct ethernet_context *)
1684 net_if_l2_data(iface);
1685
1686 NET_ASSERT(ctx != NULL);
1687
1688 return ctx->eth_if_type == L2_ETH_IF_TYPE_WIFI;
1689}
1690
1698static inline bool net_eth_type_is_ethernet(struct net_if *iface)
1699{
1700 const struct ethernet_context *ctx = (struct ethernet_context *)net_if_l2_data(iface);
1701
1702 NET_ASSERT(ctx != NULL);
1703
1704 return ctx->eth_if_type == L2_ETH_IF_TYPE_ETHERNET;
1705}
1706
1712static inline void net_eth_set_if_type_wifi(struct net_if *iface)
1713{
1714 struct ethernet_context *ctx = (struct ethernet_context *)net_if_l2_data(iface);
1715
1716 NET_ASSERT(ctx != NULL);
1717
1718 ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI;
1719}
1720
1724
1725#ifdef __cplusplus
1726}
1727#endif
1728
1729#include <zephyr/syscalls/ethernet.h>
1730
1731#endif /* ZEPHYR_INCLUDE_NET_ETHERNET_H_ */
Header file for the Atomic operations API.
System clock APIs.
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:1212
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:1097
ethernet_if_types
Types of Ethernet L2.
Definition ethernet.h:395
static int net_eth_vlan_enable(struct net_if *iface, uint16_t tag)
Add VLAN tag to the interface.
Definition ethernet.h:1128
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:791
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:833
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:1655
#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:1171
static void net_eth_carrier_on(struct net_if *iface)
Inform ethernet L2 driver that ethernet carrier is detected.
Definition ethernet.h:1576
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:1681
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:770
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:1255
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:812
static bool net_eth_is_vlan_interface(struct net_if *iface)
Check if the given interface is a VLAN interface.
Definition ethernet.h:1273
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:937
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:1587
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:1459
static void net_eth_set_if_type_wifi(struct net_if *iface)
Set the Ethernet interface type to Wi-Fi.
Definition ethernet.h:1712
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:1061
static int net_eth_vlan_disable(struct net_if *iface, uint16_t tag)
Remove VLAN tag from the interface.
Definition ethernet.h:1148
ethernet_checksum_support
Protocols that are supported by checksum offloading.
Definition ethernet.h:498
ethernet_stats_type
Ethernet statistics type (bitmap).
Definition ethernet.h:543
net_eth_mac_type
MAC address configuration types.
Definition ethernet.h:1409
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:1235
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:1192
static bool net_eth_type_is_ethernet(struct net_if *iface)
Check if the Ethernet L2 network interface is cabled ethernet.
Definition ethernet.h:1698
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:845
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:869
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:890
static bool net_eth_is_addr_valid(struct net_eth_addr *addr)
Check if the Ethernet MAC address is valid.
Definition ethernet.h:857
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:397
@ L2_ETH_IF_TYPE_WIFI
IEEE 802.11 Wi-Fi.
Definition ethernet.h:400
@ ETHERNET_HW_VLAN
VLAN supported.
Definition ethernet.h:155
@ ETHERNET_DSA_USER_PORT
DSA switch user port.
Definition ethernet.h:191
@ ETHERNET_PRIORITY_QUEUES
Priority queues available.
Definition ethernet.h:179
@ ETHERNET_HW_VLAN_TAG_STRIP
VLAN Tag stripping.
Definition ethernet.h:188
@ ETHERNET_LINK_100BASE
100 Mbits link supported
Definition ethernet.h:161
@ ETHERNET_DSA_CONDUIT_PORT
DSA switch conduit port.
Definition ethernet.h:194
@ 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:200
@ ETHERNET_TXINJECTION_MODE
TX-Injection supported.
Definition ethernet.h:206
@ 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_LLDP
Link Layer Discovery Protocol supported.
Definition ethernet.h:185
@ ETHERNET_LINK_5000BASE
5 Gbits link supported
Definition ethernet.h:170
@ ETHERNET_TXTIME
TXTIME supported.
Definition ethernet.h:203
@ ETHERNET_QBV
IEEE 802.1Qbv (scheduled traffic) supported.
Definition ethernet.h:197
@ ETHERNET_PROMISC_MODE
Promiscuous mode supported.
Definition ethernet.h:176
@ 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_UDP
Device supports UDP checksum offloading for all supported IP protocols.
Definition ethernet.h:512
@ ETHERNET_CHECKSUM_SUPPORT_TCP
Device supports TCP checksum offloading for all supported IP protocols.
Definition ethernet.h:510
@ ETHERNET_CHECKSUM_SUPPORT_IPV6_HEADER
Device supports checksum offloading for the IPv6 header.
Definition ethernet.h:506
@ ETHERNET_CHECKSUM_SUPPORT_IPV4_ICMP
Device supports checksum offloading for ICMPv4 payload (implies IPv4 header).
Definition ethernet.h:504
@ ETHERNET_CHECKSUM_SUPPORT_IPV4_HEADER
Device supports checksum offloading for the IPv4 header.
Definition ethernet.h:502
@ ETHERNET_CHECKSUM_SUPPORT_NONE
Device does not support any L3/L4 checksum offloading.
Definition ethernet.h:500
@ ETHERNET_CHECKSUM_SUPPORT_IPV6_ICMP
Device supports checksum offloading for ICMPv6 payload (implies IPv6 header).
Definition ethernet.h:508
@ ETHERNET_STATS_TYPE_VENDOR
Vendor statistics only.
Definition ethernet.h:547
@ ETHERNET_STATS_TYPE_ALL
All statistics.
Definition ethernet.h:549
@ ETHERNET_STATS_TYPE_COMMON
Common statistics only (excludes vendor statistics).
Definition ethernet.h:545
@ NET_ETH_MAC_RANDOM
A random MAC address is generated during initialization.
Definition ethernet.h:1413
@ NET_ETH_MAC_NVMEM
The MAC address is read from an NVMEM cell.
Definition ethernet.h:1418
@ NET_ETH_MAC_DEFAULT
MAC address is handled by the driver (backwards compatible case).
Definition ethernet.h:1411
@ NET_ETH_MAC_STATIC
A static MAC address is provided in the device tree.
Definition ethernet.h:1420
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:1207
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:154
#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:553
struct net_if_api iface_api
The net_if_api must be placed in first position in this struct so that we are compatible with network...
Definition ethernet.h:558
int(* start)(const struct device *dev, struct net_if *iface)
Collect optional ethernet specific statistics.
Definition ethernet.h:578
int(* stop)(const struct device *dev, struct net_if *iface)
Stop the device.
Definition ethernet.h:581
int(* send)(const struct device *dev, struct net_pkt *pkt)
Send a network packet.
Definition ethernet.h:617
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:587
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:593
enum ethernet_hw_caps(* get_capabilities)(const struct device *dev, struct net_if *iface)
Get the device capabilities.
Definition ethernet.h:584
Ethernet filter description.
Definition ethernet.h:428
struct net_eth_addr mac_address
MAC address to filter.
Definition ethernet.h:432
bool set
Set (true) or unset (false) the filter.
Definition ethernet.h:434
enum ethernet_filter_type type
Type of filter.
Definition ethernet.h:430
Ethernet LLDP specific parameters.
Definition ethernet.h:650
const uint8_t * optional_du
LLDP Data Unit optional TLVs for the interface.
Definition ethernet.h:658
sys_snode_t node
Used for track timers.
Definition ethernet.h:652
net_lldp_recv_cb_t cb
LLDP RX callback function.
Definition ethernet.h:667
k_timepoint_t tx_timer_timeout
LLDP TX timer timeout.
Definition ethernet.h:664
size_t optional_len
Length of the optional Data Unit TLVs.
Definition ethernet.h:661
const struct net_lldpdu * lldpdu
LLDP Data Unit mandatory TLVs for the interface.
Definition ethernet.h:655
Ethernet Qav specific parameters.
Definition ethernet.h:246
bool enabled
True if Qav is enabled for queue.
Definition ethernet.h:253
unsigned int oper_idle_slope
Oper Idle Slope (bits per second).
Definition ethernet.h:259
enum ethernet_qav_param_type type
Type of Qav parameter.
Definition ethernet.h:250
unsigned int traffic_class
Traffic class the queue is bound to.
Definition ethernet.h:261
int queue_id
ID of the priority queue to use.
Definition ethernet.h:248
unsigned int idle_slope
Idle Slope (bits per second).
Definition ethernet.h:257
unsigned int delta_bandwidth
Delta Bandwidth (percentage of bandwidth).
Definition ethernet.h:255
Ethernet Qbu specific parameters.
Definition ethernet.h:355
enum ethernet_qbu_preempt_status frame_preempt_statuses[NET_TC_TX_COUNT]
sequence of framePreemptionAdminStatus values
Definition ethernet.h:368
uint32_t release_advance
Release advance (nanoseconds).
Definition ethernet.h:365
enum ethernet_qbu_param_type type
Type of Qbu parameter.
Definition ethernet.h:359
uint32_t hold_advance
Hold advance (nanoseconds).
Definition ethernet.h:362
bool enabled
True if Qbu is enabled or not.
Definition ethernet.h:372
bool link_partner_status
Link partner status (from Qbr).
Definition ethernet.h:375
int port_id
Port id.
Definition ethernet.h:357
uint8_t additional_fragment_size
Additional fragment size (from Qbr).
Definition ethernet.h:381
Ethernet Qbv specific parameters.
Definition ethernet.h:288
int port_id
Port id.
Definition ethernet.h:290
bool enabled
True if Qbv is enabled or not.
Definition ethernet.h:297
struct ethernet_qbv_param::@055246010323023270273151373302031315361103011354::@066201007326270006176246045126267167014036102070 gate_control
Gate control information.
enum ethernet_qbv_param_type type
Type of Qbv parameter.
Definition ethernet.h:292
uint16_t row
Gate control list row.
Definition ethernet.h:311
enum ethernet_qbv_state_type state
What state (Admin/Oper) parameters are these.
Definition ethernet.h:294
bool gate_status[NET_TC_TX_COUNT]
True = open, False = closed.
Definition ethernet.h:302
struct net_ptp_extended_time base_time
Base time.
Definition ethernet.h:323
uint32_t extension_time
Extension time (nanoseconds).
Definition ethernet.h:329
enum ethernet_gate_state_operation operation
GateState operation.
Definition ethernet.h:305
uint32_t time_interval
Time interval ticks (nanoseconds).
Definition ethernet.h:308
struct net_ptp_time cycle_time
Cycle time.
Definition ethernet.h:326
uint32_t gate_control_list_len
Number of entries in gate control list.
Definition ethernet.h:315
Ethernet TXTIME specific parameters.
Definition ethernet.h:488
bool enable_txtime
Enable or disable TXTIME per queue.
Definition ethernet.h:494
int queue_id
Queue number for configuring TXTIME.
Definition ethernet.h:492
enum ethernet_txtime_param_type type
Type of TXTIME parameter.
Definition ethernet.h:490
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:1424
enum net_eth_mac_type type
The configuration type.
Definition ethernet.h:1426
struct nvmem_cell cell
The NVMEM cell to read the MAC address from.
Definition ethernet.h:1441
uint8_t addr[6U]
The static MAC address part.
Definition ethernet.h:1433
uint8_t addr_len
The length of the statically provided part.
Definition ethernet.h:1435
L2 multicast address of a network interface.
Definition ethernet.h:464
struct net_eth_addr addr
Multicast MAC address.
Definition ethernet.h:466
uint8_t is_used
Is this address used or not.
Definition ethernet.h:474
atomic_t atomic_ref
Reference counter.
Definition ethernet.h:471
Network Interface structure.
Definition net_if.h:857
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:647
Non-Volatile Memory cell representation.
Definition nvmem.h:37
Misc utilities.
Virtual Network Interface.