linux/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c

// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/* Copyright (c) 2019 Mellanox Technologies. All rights reserved */

#include <linux/ptp_clock_kernel.h>
#include <linux/clocksource.h>
#include <linux/timecounter.h>
#include <linux/spinlock.h>
#include <linux/device.h>
#include <linux/rhashtable.h>
#include <linux/ptp_classify.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/net_tstamp.h>
#include <linux/refcount.h>

#include "spectrum.h"
#include "spectrum_ptp.h"
#include "core.h"
#include "txheader.h"

#define MLXSW_SP1_PTP_CLOCK_CYCLES_SHIFT
#define MLXSW_SP1_PTP_CLOCK_FREQ_KHZ
#define MLXSW_SP1_PTP_CLOCK_MASK

#define MLXSW_SP1_PTP_HT_GC_INTERVAL

/* How long, approximately, should the unmatched entries stay in the hash table
 * before they are collected. Should be evenly divisible by the GC interval.
 */
#define MLXSW_SP1_PTP_HT_GC_TIMEOUT

struct mlxsw_sp_ptp_state {};

struct mlxsw_sp1_ptp_state {};

struct mlxsw_sp2_ptp_state {};

struct mlxsw_sp1_ptp_key {};

struct mlxsw_sp1_ptp_unmatched {};

static const struct rhashtable_params mlxsw_sp1_ptp_unmatched_ht_params =;

struct mlxsw_sp_ptp_clock {};

struct mlxsw_sp1_ptp_clock {};

static struct mlxsw_sp1_ptp_state *
mlxsw_sp1_ptp_state(struct mlxsw_sp *mlxsw_sp)
{}

static struct mlxsw_sp2_ptp_state *
mlxsw_sp2_ptp_state(struct mlxsw_sp *mlxsw_sp)
{}

static struct mlxsw_sp1_ptp_clock *
mlxsw_sp1_ptp_clock(struct ptp_clock_info *ptp)
{}

static u64 __mlxsw_sp1_ptp_read_frc(struct mlxsw_sp1_ptp_clock *clock,
				    struct ptp_system_timestamp *sts)
{}

static u64 mlxsw_sp1_ptp_read_frc(const struct cyclecounter *cc)
{}

static int
mlxsw_sp_ptp_phc_adjfreq(struct mlxsw_sp_ptp_clock *clock, int freq_adj)
{}

static u64 mlxsw_sp1_ptp_ns2cycles(const struct timecounter *tc, u64 nsec)
{}

static int
mlxsw_sp1_ptp_phc_settime(struct mlxsw_sp1_ptp_clock *clock, u64 nsec)
{}

static int mlxsw_sp1_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
{}

static int mlxsw_sp1_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
{}

static int mlxsw_sp1_ptp_gettimex(struct ptp_clock_info *ptp,
				  struct timespec64 *ts,
				  struct ptp_system_timestamp *sts)
{}

static int mlxsw_sp1_ptp_settime(struct ptp_clock_info *ptp,
				 const struct timespec64 *ts)
{}

static const struct ptp_clock_info mlxsw_sp1_ptp_clock_info =;

static void mlxsw_sp1_ptp_clock_overflow(struct work_struct *work)
{}

struct mlxsw_sp_ptp_clock *
mlxsw_sp1_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev)
{}

void mlxsw_sp1_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock_common)
{}

static u64 mlxsw_sp2_ptp_read_utc(struct mlxsw_sp_ptp_clock *clock,
				  struct ptp_system_timestamp *sts)
{}

static int
mlxsw_sp2_ptp_phc_settime(struct mlxsw_sp_ptp_clock *clock, u64 nsec)
{}

static int mlxsw_sp2_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
{}

static int mlxsw_sp2_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
{}

static int mlxsw_sp2_ptp_gettimex(struct ptp_clock_info *ptp,
				  struct timespec64 *ts,
				  struct ptp_system_timestamp *sts)
{}

static int mlxsw_sp2_ptp_settime(struct ptp_clock_info *ptp,
				 const struct timespec64 *ts)
{}

static const struct ptp_clock_info mlxsw_sp2_ptp_clock_info =;

struct mlxsw_sp_ptp_clock *
mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev)
{}

void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock)
{}

static int mlxsw_sp_ptp_parse(struct sk_buff *skb,
			      u8 *p_domain_number,
			      u8 *p_message_type,
			      u16 *p_sequence_id)
{}

/* Returns NULL on successful insertion, a pointer on conflict, or an ERR_PTR on
 * error.
 */
static int
mlxsw_sp1_ptp_unmatched_save(struct mlxsw_sp *mlxsw_sp,
			     struct mlxsw_sp1_ptp_key key,
			     struct sk_buff *skb,
			     u64 timestamp)
{}

static struct mlxsw_sp1_ptp_unmatched *
mlxsw_sp1_ptp_unmatched_lookup(struct mlxsw_sp *mlxsw_sp,
			       struct mlxsw_sp1_ptp_key key, int *p_length)
{}

static int
mlxsw_sp1_ptp_unmatched_remove(struct mlxsw_sp *mlxsw_sp,
			       struct mlxsw_sp1_ptp_unmatched *unmatched)
{}

/* This function is called in the following scenarios:
 *
 * 1) When a packet is matched with its timestamp.
 * 2) In several situation when it is necessary to immediately pass on
 *    an SKB without a timestamp.
 * 3) From GC indirectly through mlxsw_sp1_ptp_unmatched_finish().
 *    This case is similar to 2) above.
 */
static void mlxsw_sp1_ptp_packet_finish(struct mlxsw_sp *mlxsw_sp,
					struct sk_buff *skb, u16 local_port,
					bool ingress,
					struct skb_shared_hwtstamps *hwtstamps)
{}

static void mlxsw_sp1_packet_timestamp(struct mlxsw_sp *mlxsw_sp,
				       struct mlxsw_sp1_ptp_key key,
				       struct sk_buff *skb,
				       u64 timestamp)
{}

static void
mlxsw_sp1_ptp_unmatched_finish(struct mlxsw_sp *mlxsw_sp,
			       struct mlxsw_sp1_ptp_unmatched *unmatched)
{}

static void mlxsw_sp1_ptp_unmatched_free_fn(void *ptr, void *arg)
{}

static void mlxsw_sp1_ptp_got_piece(struct mlxsw_sp *mlxsw_sp,
				    struct mlxsw_sp1_ptp_key key,
				    struct sk_buff *skb, u64 timestamp)
{}

static void mlxsw_sp1_ptp_got_packet(struct mlxsw_sp *mlxsw_sp,
				     struct sk_buff *skb, u16 local_port,
				     bool ingress)
{}

void mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress,
				 u16 local_port, u8 message_type,
				 u8 domain_number, u16 sequence_id,
				 u64 timestamp)
{}

void mlxsw_sp1_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
			   u16 local_port)
{}

void mlxsw_sp1_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,
			       struct sk_buff *skb, u16 local_port)
{}

static void
mlxsw_sp1_ptp_ht_gc_collect(struct mlxsw_sp1_ptp_state *ptp_state,
			    struct mlxsw_sp1_ptp_unmatched *unmatched)
{}

static void mlxsw_sp1_ptp_ht_gc(struct work_struct *work)
{}

static int mlxsw_sp_ptp_mtptpt_set(struct mlxsw_sp *mlxsw_sp,
				   enum mlxsw_reg_mtptpt_trap_id trap_id,
				   u16 message_type)
{}

static int mlxsw_sp1_ptp_set_fifo_clr_on_trap(struct mlxsw_sp *mlxsw_sp,
					      bool clr)
{}

static int mlxsw_sp1_ptp_mtpppc_set(struct mlxsw_sp *mlxsw_sp,
				    u16 ing_types, u16 egr_types)
{}

struct mlxsw_sp1_ptp_shaper_params {};

static const struct mlxsw_sp1_ptp_shaper_params
mlxsw_sp1_ptp_shaper_params[] =;

#define MLXSW_SP1_PTP_SHAPER_PARAMS_LEN

static int mlxsw_sp1_ptp_shaper_params_set(struct mlxsw_sp *mlxsw_sp)
{}

static int mlxsw_sp_ptp_traps_set(struct mlxsw_sp *mlxsw_sp)
{}

static void mlxsw_sp_ptp_traps_unset(struct mlxsw_sp *mlxsw_sp)
{}

struct mlxsw_sp_ptp_state *mlxsw_sp1_ptp_init(struct mlxsw_sp *mlxsw_sp)
{}

void mlxsw_sp1_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state_common)
{}

int mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
			       struct hwtstamp_config *config)
{}

static int
mlxsw_sp1_ptp_get_message_types(const struct hwtstamp_config *config,
				u16 *p_ing_types, u16 *p_egr_types,
				enum hwtstamp_rx_filters *p_rx_filter)
{}

static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port,
				       u16 ing_types, u16 egr_types)
{}

static bool mlxsw_sp1_ptp_hwtstamp_enabled(struct mlxsw_sp_port *mlxsw_sp_port)
{}

static int
mlxsw_sp1_ptp_port_shaper_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable)
{}

static int mlxsw_sp1_ptp_port_shaper_check(struct mlxsw_sp_port *mlxsw_sp_port)
{}

void mlxsw_sp1_ptp_shaper_work(struct work_struct *work)
{}

int mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
			       struct hwtstamp_config *config)
{}

int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
			      struct kernel_ethtool_ts_info *info)
{}

struct mlxsw_sp_ptp_port_stat {};

#define MLXSW_SP_PTP_PORT_STAT

static const struct mlxsw_sp_ptp_port_stat mlxsw_sp_ptp_port_stats[] =;

#undef MLXSW_SP_PTP_PORT_STAT

#define MLXSW_SP_PTP_PORT_STATS_LEN

int mlxsw_sp1_get_stats_count(void)
{}

void mlxsw_sp1_get_stats_strings(u8 **p)
{}

void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,
			 u64 *data, int data_index)
{}

struct mlxsw_sp_ptp_state *mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp)
{}

void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state_common)
{}

static u32 mlxsw_ptp_utc_time_stamp_sec_get(struct mlxsw_core *mlxsw_core,
					    u8 cqe_ts_sec)
{}

static void mlxsw_sp2_ptp_hwtstamp_fill(struct mlxsw_core *mlxsw_core,
					const struct mlxsw_skb_cb *cb,
					struct skb_shared_hwtstamps *hwtstamps)
{}

void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
			   u16 local_port)
{}

void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,
			       struct sk_buff *skb, u16 local_port)
{}

int mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
			       struct hwtstamp_config *config)
{}

static int
mlxsw_sp2_ptp_get_message_types(const struct hwtstamp_config *config,
				u16 *p_ing_types, u16 *p_egr_types,
				enum hwtstamp_rx_filters *p_rx_filter)
{}

static int mlxsw_sp2_ptp_mtpcpc_set(struct mlxsw_sp *mlxsw_sp, bool ptp_trap_en,
				    u16 ing_types, u16 egr_types)
{}

static int mlxsw_sp2_ptp_enable(struct mlxsw_sp *mlxsw_sp, u16 ing_types,
				u16 egr_types,
				struct hwtstamp_config new_config)
{}

static int mlxsw_sp2_ptp_disable(struct mlxsw_sp *mlxsw_sp,
				 struct hwtstamp_config new_config)
{}

static int mlxsw_sp2_ptp_configure_port(struct mlxsw_sp_port *mlxsw_sp_port,
					u16 ing_types, u16 egr_types,
					struct hwtstamp_config new_config)
{}

static int mlxsw_sp2_ptp_deconfigure_port(struct mlxsw_sp_port *mlxsw_sp_port,
					  struct hwtstamp_config new_config)
{}

int mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
			       struct hwtstamp_config *config)
{}

int mlxsw_sp2_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
			      struct kernel_ethtool_ts_info *info)
{}

int mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
				 struct mlxsw_sp_port *mlxsw_sp_port,
				 struct sk_buff *skb,
				 const struct mlxsw_tx_info *tx_info)
{}

int mlxsw_sp2_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
				  struct mlxsw_sp_port *mlxsw_sp_port,
				  struct sk_buff *skb,
				  const struct mlxsw_tx_info *tx_info)
{}