Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /* Copyright (c) 2019 Mellanox Technologies. All rights reserved */
0003 
0004 #ifndef _MLXSW_SPECTRUM_PTP_H
0005 #define _MLXSW_SPECTRUM_PTP_H
0006 
0007 #include <linux/device.h>
0008 #include <linux/rhashtable.h>
0009 
0010 struct mlxsw_sp;
0011 struct mlxsw_sp_port;
0012 struct mlxsw_sp_ptp_clock;
0013 
0014 static inline int mlxsw_sp_ptp_get_ts_info_noptp(struct ethtool_ts_info *info)
0015 {
0016     info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
0017                 SOF_TIMESTAMPING_SOFTWARE;
0018     info->phc_index = -1;
0019     return 0;
0020 }
0021 
0022 #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
0023 
0024 struct mlxsw_sp_ptp_clock *
0025 mlxsw_sp1_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev);
0026 
0027 void mlxsw_sp1_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock);
0028 
0029 struct mlxsw_sp_ptp_state *mlxsw_sp1_ptp_init(struct mlxsw_sp *mlxsw_sp);
0030 
0031 void mlxsw_sp1_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state);
0032 
0033 void mlxsw_sp1_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
0034                u16 local_port);
0035 
0036 void mlxsw_sp1_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,
0037                    struct sk_buff *skb, u16 local_port);
0038 
0039 void mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress,
0040                  u16 local_port, u8 message_type,
0041                  u8 domain_number, u16 sequence_id,
0042                  u64 timestamp);
0043 
0044 int mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
0045                    struct hwtstamp_config *config);
0046 
0047 int mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
0048                    struct hwtstamp_config *config);
0049 
0050 void mlxsw_sp1_ptp_shaper_work(struct work_struct *work);
0051 
0052 int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
0053                   struct ethtool_ts_info *info);
0054 
0055 int mlxsw_sp1_get_stats_count(void);
0056 void mlxsw_sp1_get_stats_strings(u8 **p);
0057 void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,
0058              u64 *data, int data_index);
0059 
0060 int mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
0061                  struct mlxsw_sp_port *mlxsw_sp_port,
0062                  struct sk_buff *skb,
0063                  const struct mlxsw_tx_info *tx_info);
0064 
0065 struct mlxsw_sp_ptp_clock *
0066 mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev);
0067 
0068 void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock);
0069 
0070 struct mlxsw_sp_ptp_state *mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp);
0071 
0072 void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state);
0073 
0074 void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
0075                u16 local_port);
0076 
0077 void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,
0078                    struct sk_buff *skb, u16 local_port);
0079 
0080 int mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
0081                    struct hwtstamp_config *config);
0082 
0083 int mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
0084                    struct hwtstamp_config *config);
0085 
0086 int mlxsw_sp2_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
0087                   struct ethtool_ts_info *info);
0088 
0089 int mlxsw_sp2_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
0090                   struct mlxsw_sp_port *mlxsw_sp_port,
0091                   struct sk_buff *skb,
0092                   const struct mlxsw_tx_info *tx_info);
0093 
0094 #else
0095 
0096 static inline struct mlxsw_sp_ptp_clock *
0097 mlxsw_sp1_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev)
0098 {
0099     return NULL;
0100 }
0101 
0102 static inline void mlxsw_sp1_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock)
0103 {
0104 }
0105 
0106 static inline struct mlxsw_sp_ptp_state *
0107 mlxsw_sp1_ptp_init(struct mlxsw_sp *mlxsw_sp)
0108 {
0109     return NULL;
0110 }
0111 
0112 static inline void mlxsw_sp1_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state)
0113 {
0114 }
0115 
0116 static inline void mlxsw_sp1_ptp_receive(struct mlxsw_sp *mlxsw_sp,
0117                      struct sk_buff *skb, u16 local_port)
0118 {
0119     mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp);
0120 }
0121 
0122 static inline void mlxsw_sp1_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,
0123                          struct sk_buff *skb, u16 local_port)
0124 {
0125     dev_kfree_skb_any(skb);
0126 }
0127 
0128 static inline void
0129 mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress,
0130                 u16 local_port, u8 message_type,
0131                 u8 domain_number,
0132                 u16 sequence_id, u64 timestamp)
0133 {
0134 }
0135 
0136 static inline int
0137 mlxsw_sp1_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
0138                struct hwtstamp_config *config)
0139 {
0140     return -EOPNOTSUPP;
0141 }
0142 
0143 static inline int
0144 mlxsw_sp1_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
0145                struct hwtstamp_config *config)
0146 {
0147     return -EOPNOTSUPP;
0148 }
0149 
0150 static inline void mlxsw_sp1_ptp_shaper_work(struct work_struct *work)
0151 {
0152 }
0153 
0154 static inline int mlxsw_sp1_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
0155                         struct ethtool_ts_info *info)
0156 {
0157     return mlxsw_sp_ptp_get_ts_info_noptp(info);
0158 }
0159 
0160 static inline int mlxsw_sp1_get_stats_count(void)
0161 {
0162     return 0;
0163 }
0164 
0165 static inline void mlxsw_sp1_get_stats_strings(u8 **p)
0166 {
0167 }
0168 
0169 static inline void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,
0170                        u64 *data, int data_index)
0171 {
0172 }
0173 
0174 static inline int
0175 mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
0176                  struct mlxsw_sp_port *mlxsw_sp_port,
0177                  struct sk_buff *skb,
0178                  const struct mlxsw_tx_info *tx_info)
0179 {
0180     return -EOPNOTSUPP;
0181 }
0182 
0183 static inline struct mlxsw_sp_ptp_clock *
0184 mlxsw_sp2_ptp_clock_init(struct mlxsw_sp *mlxsw_sp, struct device *dev)
0185 {
0186     return NULL;
0187 }
0188 
0189 static inline void mlxsw_sp2_ptp_clock_fini(struct mlxsw_sp_ptp_clock *clock)
0190 {
0191 }
0192 
0193 static inline struct mlxsw_sp_ptp_state *
0194 mlxsw_sp2_ptp_init(struct mlxsw_sp *mlxsw_sp)
0195 {
0196     return NULL;
0197 }
0198 
0199 static inline void mlxsw_sp2_ptp_fini(struct mlxsw_sp_ptp_state *ptp_state)
0200 {
0201 }
0202 
0203 static inline void mlxsw_sp2_ptp_receive(struct mlxsw_sp *mlxsw_sp,
0204                      struct sk_buff *skb, u16 local_port)
0205 {
0206     mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp);
0207 }
0208 
0209 static inline void mlxsw_sp2_ptp_transmitted(struct mlxsw_sp *mlxsw_sp,
0210                          struct sk_buff *skb, u16 local_port)
0211 {
0212     dev_kfree_skb_any(skb);
0213 }
0214 
0215 static inline int
0216 mlxsw_sp2_ptp_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port,
0217                struct hwtstamp_config *config)
0218 {
0219     return -EOPNOTSUPP;
0220 }
0221 
0222 static inline int
0223 mlxsw_sp2_ptp_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port,
0224                struct hwtstamp_config *config)
0225 {
0226     return -EOPNOTSUPP;
0227 }
0228 
0229 static inline int mlxsw_sp2_ptp_get_ts_info(struct mlxsw_sp *mlxsw_sp,
0230                         struct ethtool_ts_info *info)
0231 {
0232     return mlxsw_sp_ptp_get_ts_info_noptp(info);
0233 }
0234 
0235 static inline int
0236 mlxsw_sp2_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
0237                   struct mlxsw_sp_port *mlxsw_sp_port,
0238                   struct sk_buff *skb,
0239                   const struct mlxsw_tx_info *tx_info)
0240 {
0241     return -EOPNOTSUPP;
0242 }
0243 #endif
0244 
0245 static inline void mlxsw_sp2_ptp_shaper_work(struct work_struct *work)
0246 {
0247 }
0248 
0249 static inline int mlxsw_sp2_get_stats_count(void)
0250 {
0251     return 0;
0252 }
0253 
0254 static inline void mlxsw_sp2_get_stats_strings(u8 **p)
0255 {
0256 }
0257 
0258 static inline void mlxsw_sp2_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,
0259                        u64 *data, int data_index)
0260 {
0261 }
0262 
0263 #endif