Skip to content

Commit cb2f4ea

Browse files
committed
samples: net: gptp: Allow running gPTP over VLAN
By default gPTP is not run over VLAN but if needed that can be done by uncommenting statement at the beginning of the file. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 6df76e0 commit cb2f4ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

samples/net/gptp/src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
static struct gptp_phase_dis_cb phase_dis;
2323

24+
/* Enable following if you want to run gPTP over VLAN with this application */
25+
#define GPTP_OVER_VLAN 0
26+
#define GPTP_VLAN_TAG 42
27+
2428
#if defined(CONFIG_NET_VLAN)
2529
/* User data for the interface callback */
2630
struct ud {
@@ -102,6 +106,14 @@ static int init_vlan(void)
102106

103107
net_if_foreach(iface_cb, &ud);
104108

109+
#if GPTP_OVER_VLAN
110+
ret = net_eth_vlan_enable(ud.first, GPTP_VLAN_TAG);
111+
if (ret < 0) {
112+
NET_ERR("Cannot enable VLAN for tag %d (%d)", GPTP_VLAN_TAG,
113+
ret);
114+
}
115+
#endif
116+
105117
/* This sample has two VLANs. For the second one we need to manually
106118
* create IP address for this test. But first the VLAN needs to be
107119
* added to the interface so that IPv6 DAD can work properly.

0 commit comments

Comments
 (0)