Lines Matching +full:ptp +full:- +full:clock
1 /* main.c - Application main entry point */
6 * SPDX-License-Identifier: Apache-2.0
10 /* Custom PTP device name to avoid conflicts with PTP devices on SOC */
67 static ZTEST_BMEM int ptp_clocks[MAX_NUM_INTERFACES - 1];
68 static int ptp_interface[MAX_NUM_INTERFACES - 1];
92 struct eth_context *context = dev->data; in eth_iface_init()
94 net_if_set_link_addr(iface, context->mac_addr, in eth_iface_init()
95 sizeof(context->mac_addr), in eth_iface_init()
103 struct eth_context *context = dev->data; in eth_tx()
109 if (!pkt->frags) { in eth_tx()
111 return -ENODATA; in eth_tx()
129 struct eth_context *context = dev->data; in eth_get_ptp_clock()
131 return context->ptp_clock; in eth_get_ptp_clock()
144 /* 00-00-5E-00-53-xx Documentation RFC 7042 */ in generate_mac()
155 struct eth_context *context = dev->data; in eth_init()
157 generate_mac(context->mac_addr); in eth_init()
180 return (ts->second * NSEC_PER_SEC) + ts->nanosecond; in timestamp_to_nsec()
189 struct ptp_context *ptp_ctx = dev->data; in my_ptp_clock_set()
190 struct eth_context *eth_ctx = ptp_ctx->eth_context; in my_ptp_clock_set()
196 memcpy(ð_ctx->time, tm, sizeof(struct net_ptp_time)); in my_ptp_clock_set()
203 struct ptp_context *ptp_ctx = dev->data; in my_ptp_clock_get()
204 struct eth_context *eth_ctx = ptp_ctx->eth_context; in my_ptp_clock_get()
206 memcpy(tm, ð_ctx->time, sizeof(struct net_ptp_time)); in my_ptp_clock_get()
213 struct ptp_context *ptp_ctx = dev->data; in my_ptp_clock_adjust()
214 struct eth_context *eth_ctx = ptp_ctx->eth_context; in my_ptp_clock_adjust()
216 eth_ctx->time.nanosecond += increment; in my_ptp_clock_adjust()
239 struct eth_context *context = eth_dev->data; in ptp_test_1_init()
240 struct ptp_context *ptp_context = port->data; in ptp_test_1_init()
242 context->ptp_clock = port; in ptp_test_1_init()
243 ptp_context->eth_context = context; in ptp_test_1_init()
255 struct eth_context *context = eth_dev->data; in ptp_test_2_init()
256 struct ptp_context *ptp_context = port->data; in ptp_test_2_init()
258 context->ptp_clock = port; in ptp_test_2_init()
259 ptp_context->eth_context = context; in ptp_test_2_init()
310 if (ud->eth_if_count >= ARRAY_SIZE(eth_interfaces)) { in iface_cb()
317 non_ptp_interface = ud->eth_if_count; in iface_cb()
319 ptp_interface[ptp_iface_idx] = ud->eth_if_count; in iface_cb()
324 eth_interfaces[ud->eth_if_count++] = iface; in iface_cb()
330 ud->total_if_count++; in iface_cb()
349 /* As we are testing the ethernet controller clock, the IP addresses are not
375 ifaddr->addr_state = NET_ADDR_PREFERRED; in test_address_setup()
385 ifaddr->addr_state = NET_ADDR_PREFERRED; in test_address_setup()
395 ifaddr->addr_state = NET_ADDR_PREFERRED; in test_address_setup()
420 zassert_not_null(clk, "Clock not found for interface %p\n", in test_ptp_clock_interfaces()
425 zassert_not_null(clk, "Clock not found for interface %p\n", in test_ptp_clock_interfaces()
429 zassert_is_null(clk, "Clock found for interface %p\n", in test_ptp_clock_interfaces()
434 "Clock not found for interface index %d\n", in test_ptp_clock_interfaces()
450 zassert_not_null(clk, "Clock not found for interface %p\n", in test_ptp_clock_iface()
468 /* The clock value must be the same after incrementing it */ in test_ptp_clock_iface()
495 zassert_not_null(clk, "PTP 0 not found"); in test_ptp_clock_get_by_index()
500 zassert_not_null(clk_by_index, "PTP 0 not found"); in test_ptp_clock_get_by_index()
507 zassert_not_null(clk, "PTP 1 not found"); in test_ptp_clock_get_by_index()
512 zassert_not_null(clk_by_index, "PTP 1 not found"); in test_ptp_clock_get_by_index()
522 zassert_not_null(clk_by_index, "PTP 0 not found"); in test_ptp_clock_get_by_index_user()
523 zassert_equal(clk0, clk_by_index, "Invalid PTP clock 0"); in test_ptp_clock_get_by_index_user()
526 zassert_not_null(clk_by_index, "PTP 1 not found"); in test_ptp_clock_get_by_index_user()
527 zassert_equal(clk1, clk_by_index, "Invalid PTP clock 1"); in test_ptp_clock_get_by_index_user()
539 zassert_not_null(clk_by_index, "PTP 0 not found (%s)", who); in test_ptp_clock_get_by_xxx()
540 zassert_equal(clk0, clk_by_index, "Invalid PTP clock 0 (%s)", who); in test_ptp_clock_get_by_xxx()