Boot Linux faster!

Check our new training course

Boot Linux faster!

Check our new training course
and Creative Commons CC-BY-SA
lecture and lab materials

Bootlin logo

Elixir Cross Referencer

 * Copyright (c) 2017 Intel Corporation
 * SPDX-License-Identifier: Apache-2.0

#define SYS_LOG_DOMAIN "net/gptp"

#include <ptp_clock.h>
#include <net/gptp.h>

#include "gptp_messages.h"
#include "gptp_data_set.h"

#include "net_private.h"

static sys_slist_t phase_dis_callbacks;

void gptp_register_phase_dis_cb(struct gptp_phase_dis_cb *phase_dis,
				gptp_phase_dis_callback_t cb)
	sys_slist_find_and_remove(&phase_dis_callbacks, &phase_dis->node);
	sys_slist_prepend(&phase_dis_callbacks, &phase_dis->node);

	phase_dis->cb = cb;

void gptp_unregister_phase_dis_cb(struct gptp_phase_dis_cb *phase_dis)
	sys_slist_find_and_remove(&phase_dis_callbacks, &phase_dis->node);

void gptp_call_phase_dis_cb(void)
	struct gptp_global_ds *global_ds;
	sys_snode_t *sn, *sns;
	u8_t *gm_id;

	global_ds = GPTP_GLOBAL_DS();
	gm_id = &global_ds->gm_priority.root_system_id.grand_master_id[0];

	SYS_SLIST_FOR_EACH_NODE_SAFE(&phase_dis_callbacks, sn, sns) {
		struct gptp_phase_dis_cb *phase_dis =
			CONTAINER_OF(sn, struct gptp_phase_dis_cb, node);


int gptp_event_capture(struct net_ptp_time *slave_time, bool *gm_present)
	int port, key;
	struct device *clk;

	key = irq_lock();
	*gm_present =  GPTP_GLOBAL_DS()->gm_present;

	for (port = GPTP_PORT_START; port <= GPTP_PORT_END; port++) {
		/* Get first available clock, or slave clock if GM present. */
		if (!*gm_present || (GPTP_GLOBAL_DS()->selected_role[port] ==
				     GPTP_PORT_SLAVE)) {
			clk = net_eth_get_ptp_clock(GPTP_PORT_IFACE(port));
			if (clk) {
				ptp_clock_get(clk, slave_time);
				return 0;

	return -EAGAIN;

char *gptp_sprint_clock_id(const u8_t *clk_id, char *output, size_t output_len)
	return net_sprint_ll_addr_buf(clk_id, 8, output, output_len);