FILE
spectrum_ptp.h
File preview with syntax highlighting.
linux-6.19.14/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.h
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_H 5#define _MLXSW_SPECTRUM_PTP_H 6 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 kernel_hwtstamp_config *config); 38 39int mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port, 40 struct kernel_hwtstamp_config *config, 41 struct netlink_ext_ack *extack); 42 43void mlxsw_sp1_ptp_shaper_work(struct work_struct *work); 44 45int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp, 46 struct kernel_ethtool_ts_info *info); 47 48int mlxsw_sp1_get_stats_count(void); 49void mlxsw_sp1_get_stats_strings(u8 **p); 50void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port, 51 u64 *data, int data_index); 52 53struct mlxsw_sp_ptp_clock * 54mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev); 55 56void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock); 57 58struct mlxsw_sp_ptp_state *mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp); 59 60void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state); 61 62void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 63 u16 local_port); 64 65void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp, 66 struct sk_buff *skb, u16 local_port); 67 68int mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port, 69 struct kernel_hwtstamp_config *config); 70 71int mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port, 72 struct kernel_hwtstamp_config *config, 73 struct netlink_ext_ack *extack); 74 75int mlxsw_sp2_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp, 76 struct kernel_ethtool_ts_info *info); 77 78#else 79 80static inline struct mlxsw_sp_ptp_clock * 81mlxsw_sp1_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev) 82{ 83 return NULL; 84} 85 86static inline void mlxsw_sp1_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock) 87{ 88} 89 90static inline struct mlxsw_sp_ptp_state * 91mlxsw_sp1_ptp_init(struct mlxsw_sp *mlxsw_sp) 92{ 93 return NULL; 94} 95 96static inline void mlxsw_sp1_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state) 97{ 98} 99 100static inline void mlxsw_sp1_ptp_receive(struct mlxsw_sp *mlxsw_sp, 101 struct sk_buff *skb, u16 local_port) 102{ 103 mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp); 104} 105 106static inline void mlxsw_sp1_ptp_transmitted(struct mlxsw_sp *mlxsw_sp, 107 struct sk_buff *skb, u16 local_port) 108{ 109 dev_kfree_skb_any(skb); 110} 111 112static inline void 113mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress, 114 u16 local_port, u8 message_type, 115 u8 domain_number, 116 u16 sequence_id, u64 timestamp) 117{ 118} 119 120static inline int 121mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port, 122 struct kernel_hwtstamp_config *config) 123{ 124 return -EOPNOTSUPP; 125} 126 127static inline int 128mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port, 129 struct kernel_hwtstamp_config *config, 130 struct netlink_ext_ack *extack) 131{ 132 return -EOPNOTSUPP; 133} 134 135static inline void mlxsw_sp1_ptp_shaper_work(struct work_struct *work) 136{ 137} 138 139static inline int mlxsw_sp1_get_stats_count(void) 140{ 141 return 0; 142} 143 144static inline void mlxsw_sp1_get_stats_strings(u8 **p) 145{ 146} 147 148static inline void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port, 149 u64 *data, int data_index) 150{ 151} 152 153static inline struct mlxsw_sp_ptp_clock * 154mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev) 155{ 156 return NULL; 157} 158 159static inline void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock) 160{ 161} 162 163static inline struct mlxsw_sp_ptp_state * 164mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp) 165{ 166 return NULL; 167} 168 169static inline void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state) 170{ 171} 172 173static inline void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp, 174 struct sk_buff *skb, u16 local_port) 175{ 176 mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp); 177} 178 179static inline void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp, 180 struct sk_buff *skb, u16 local_port) 181{ 182 dev_kfree_skb_any(skb); 183} 184 185static inline int 186mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port, 187 struct kernel_hwtstamp_config *config) 188{ 189 return -EOPNOTSUPP; 190} 191 192static inline int 193mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port, 194 struct kernel_hwtstamp_config *config, 195 struct netlink_ext_ack *extack) 196{ 197 return -EOPNOTSUPP; 198} 199#endif 200 201static inline void mlxsw_sp2_ptp_shaper_work(struct work_struct *work) 202{ 203} 204 205static inline int mlxsw_sp2_get_stats_count(void) 206{ 207 return 0; 208} 209 210static inline void mlxsw_sp2_get_stats_strings(u8 **p) 211{ 212} 213 214static inline void mlxsw_sp2_get_stats(struct mlxsw_sp_port *mlxsw_sp_port, 215 u64 *data, int data_index) 216{ 217} 218 219#endif
~/
Read-only file preview.