244 lines · c
1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */2/* Copyright (c) 2019 Mellanox Technologies. All rights reserved */3 4#ifndef _MLXSW_SPECTRUM_PTP_H5#define _MLXSW_SPECTRUM_PTP_H6 7#include <linux/device.h>8#include <linux/rhashtable.h>9 10struct mlxsw_sp;11struct mlxsw_sp_port;12struct mlxsw_sp_ptp_clock;13 14#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)15 16struct mlxsw_sp_ptp_clock *17mlxsw_sp1_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev);18 19void mlxsw_sp1_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock);20 21struct mlxsw_sp_ptp_state *mlxsw_sp1_ptp_init(struct mlxsw_sp *mlxsw_sp);22 23void mlxsw_sp1_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state);24 25void mlxsw_sp1_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,26 u16 local_port);27 28void mlxsw_sp1_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,29 struct sk_buff *skb, u16 local_port);30 31void mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress,32 u16 local_port, u8 message_type,33 u8 domain_number, u16 sequence_id,34 u64 timestamp);35 36int mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,37 struct hwtstamp_config *config);38 39int mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,40 struct hwtstamp_config *config);41 42void mlxsw_sp1_ptp_shaper_work(struct work_struct *work);43 44int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,45 struct kernel_ethtool_ts_info *info);46 47int mlxsw_sp1_get_stats_count(void);48void mlxsw_sp1_get_stats_strings(u8 **p);49void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,50 u64 *data, int data_index);51 52int mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,53 struct mlxsw_sp_port *mlxsw_sp_port,54 struct sk_buff *skb,55 const struct mlxsw_tx_info *tx_info);56 57struct mlxsw_sp_ptp_clock *58mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev);59 60void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock);61 62struct mlxsw_sp_ptp_state *mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp);63 64void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state);65 66void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,67 u16 local_port);68 69void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,70 struct sk_buff *skb, u16 local_port);71 72int mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,73 struct hwtstamp_config *config);74 75int mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,76 struct hwtstamp_config *config);77 78int mlxsw_sp2_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,79 struct kernel_ethtool_ts_info *info);80 81int mlxsw_sp2_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,82 struct mlxsw_sp_port *mlxsw_sp_port,83 struct sk_buff *skb,84 const struct mlxsw_tx_info *tx_info);85 86#else87 88static inline struct mlxsw_sp_ptp_clock *89mlxsw_sp1_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev)90{91 return NULL;92}93 94static inline void mlxsw_sp1_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock)95{96}97 98static inline struct mlxsw_sp_ptp_state *99mlxsw_sp1_ptp_init(struct mlxsw_sp *mlxsw_sp)100{101 return NULL;102}103 104static inline void mlxsw_sp1_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state)105{106}107 108static inline void mlxsw_sp1_ptp_receive(struct mlxsw_sp *mlxsw_sp,109 struct sk_buff *skb, u16 local_port)110{111 mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp);112}113 114static inline void mlxsw_sp1_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,115 struct sk_buff *skb, u16 local_port)116{117 dev_kfree_skb_any(skb);118}119 120static inline void121mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress,122 u16 local_port, u8 message_type,123 u8 domain_number,124 u16 sequence_id, u64 timestamp)125{126}127 128static inline int129mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,130 struct hwtstamp_config *config)131{132 return -EOPNOTSUPP;133}134 135static inline int136mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,137 struct hwtstamp_config *config)138{139 return -EOPNOTSUPP;140}141 142static inline void mlxsw_sp1_ptp_shaper_work(struct work_struct *work)143{144}145 146static inline int mlxsw_sp1_get_stats_count(void)147{148 return 0;149}150 151static inline void mlxsw_sp1_get_stats_strings(u8 **p)152{153}154 155static inline void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,156 u64 *data, int data_index)157{158}159 160static inline int161mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,162 struct mlxsw_sp_port *mlxsw_sp_port,163 struct sk_buff *skb,164 const struct mlxsw_tx_info *tx_info)165{166 return -EOPNOTSUPP;167}168 169static inline struct mlxsw_sp_ptp_clock *170mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev)171{172 return NULL;173}174 175static inline void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock)176{177}178 179static inline struct mlxsw_sp_ptp_state *180mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp)181{182 return NULL;183}184 185static inline void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state)186{187}188 189static inline void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp,190 struct sk_buff *skb, u16 local_port)191{192 mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp);193}194 195static inline void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,196 struct sk_buff *skb, u16 local_port)197{198 dev_kfree_skb_any(skb);199}200 201static inline int202mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,203 struct hwtstamp_config *config)204{205 return -EOPNOTSUPP;206}207 208static inline int209mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,210 struct hwtstamp_config *config)211{212 return -EOPNOTSUPP;213}214 215static inline int216mlxsw_sp2_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,217 struct mlxsw_sp_port *mlxsw_sp_port,218 struct sk_buff *skb,219 const struct mlxsw_tx_info *tx_info)220{221 return -EOPNOTSUPP;222}223#endif224 225static inline void mlxsw_sp2_ptp_shaper_work(struct work_struct *work)226{227}228 229static inline int mlxsw_sp2_get_stats_count(void)230{231 return 0;232}233 234static inline void mlxsw_sp2_get_stats_strings(u8 **p)235{236}237 238static inline void mlxsw_sp2_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,239 u64 *data, int data_index)240{241}242 243#endif244