1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2020 Mellanox Technologies. */
3 
4 #ifndef __MLX5_EN_PTP_H__
5 #define __MLX5_EN_PTP_H__
6 
7 #include "en.h"
8 #include "en/params.h"
9 #include "en_stats.h"
10 
11 struct mlx5e_ptpsq {
12 	struct mlx5e_txqsq       txqsq;
13 	struct mlx5e_cq          ts_cq;
14 	u16                      skb_fifo_cc;
15 	u16                      skb_fifo_pc;
16 	struct mlx5e_skb_fifo    skb_fifo;
17 	struct mlx5e_ptp_cq_stats *cq_stats;
18 };
19 
20 struct mlx5e_port_ptp {
21 	/* data path */
22 	struct mlx5e_ptpsq         ptpsq[MLX5E_MAX_NUM_TC];
23 	struct napi_struct         napi;
24 	struct device             *pdev;
25 	struct net_device         *netdev;
26 	__be32                     mkey_be;
27 	u8                         num_tc;
28 	u8                         lag_port;
29 
30 	/* data path - accessed per napi poll */
31 	struct mlx5e_ch_stats     *stats;
32 
33 	/* control */
34 	struct mlx5e_priv         *priv;
35 	struct mlx5_core_dev      *mdev;
36 	struct hwtstamp_config    *tstamp;
37 	DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
38 	int                        ix;
39 };
40 
41 struct mlx5e_ptp_params {
42 	struct mlx5e_params        params;
43 	struct mlx5e_sq_param      txq_sq_param;
44 };
45 
46 int mlx5e_port_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
47 			u8 lag_port, struct mlx5e_port_ptp **cp);
48 void mlx5e_port_ptp_close(struct mlx5e_port_ptp *c);
49 void mlx5e_ptp_activate_channel(struct mlx5e_port_ptp *c);
50 void mlx5e_ptp_deactivate_channel(struct mlx5e_port_ptp *c);
51 
52 enum {
53 	MLX5E_SKB_CB_CQE_HWTSTAMP  = BIT(0),
54 	MLX5E_SKB_CB_PORT_HWTSTAMP = BIT(1),
55 };
56 
57 void mlx5e_skb_cb_hwtstamp_handler(struct sk_buff *skb, int hwtstamp_type,
58 				   ktime_t hwtstamp,
59 				   struct mlx5e_ptp_cq_stats *cq_stats);
60 
61 void mlx5e_skb_cb_hwtstamp_init(struct sk_buff *skb);
62 #endif /* __MLX5_EN_PTP_H__ */
63