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 irq_desc *irq_desc;
32 	struct mlx5e_ch_stats     *stats;
33 
34 	/* control */
35 	struct mlx5e_priv         *priv;
36 	struct mlx5_core_dev      *mdev;
37 	struct hwtstamp_config    *tstamp;
38 	DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
39 	int                        ix;
40 };
41 
42 struct mlx5e_ptp_params {
43 	struct mlx5e_params        params;
44 	struct mlx5e_sq_param      txq_sq_param;
45 };
46 
47 int mlx5e_port_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
48 			u8 lag_port, struct mlx5e_port_ptp **cp);
49 void mlx5e_port_ptp_close(struct mlx5e_port_ptp *c);
50 void mlx5e_ptp_activate_channel(struct mlx5e_port_ptp *c);
51 void mlx5e_ptp_deactivate_channel(struct mlx5e_port_ptp *c);
52 
53 enum {
54 	MLX5E_SKB_CB_CQE_HWTSTAMP  = BIT(0),
55 	MLX5E_SKB_CB_PORT_HWTSTAMP = BIT(1),
56 };
57 
58 void mlx5e_skb_cb_hwtstamp_handler(struct sk_buff *skb, int hwtstamp_type,
59 				   ktime_t hwtstamp,
60 				   struct mlx5e_ptp_cq_stats *cq_stats);
61 
62 void mlx5e_skb_cb_hwtstamp_init(struct sk_buff *skb);
63 #endif /* __MLX5_EN_PTP_H__ */
64