Merge tag 'sound-fix-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / en / ptp.h
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_stats.h"
9
10 struct mlx5e_ptpsq {
11         struct mlx5e_txqsq       txqsq;
12         struct mlx5e_cq          ts_cq;
13         u16                      skb_fifo_cc;
14         u16                      skb_fifo_pc;
15         struct mlx5e_skb_fifo    skb_fifo;
16         struct mlx5e_ptp_cq_stats *cq_stats;
17 };
18
19 enum {
20         MLX5E_PTP_STATE_TX,
21         MLX5E_PTP_STATE_RX,
22         MLX5E_PTP_STATE_NUM_STATES,
23 };
24
25 struct mlx5e_ptp {
26         /* data path */
27         struct mlx5e_ptpsq         ptpsq[MLX5E_MAX_NUM_TC];
28         struct mlx5e_rq            rq;
29         struct napi_struct         napi;
30         struct device             *pdev;
31         struct net_device         *netdev;
32         __be32                     mkey_be;
33         u8                         num_tc;
34         u8                         lag_port;
35
36         /* data path - accessed per napi poll */
37         struct mlx5e_ch_stats     *stats;
38
39         /* control */
40         struct mlx5e_priv         *priv;
41         struct mlx5_core_dev      *mdev;
42         struct hwtstamp_config    *tstamp;
43         DECLARE_BITMAP(state, MLX5E_PTP_STATE_NUM_STATES);
44 };
45
46 int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
47                    u8 lag_port, struct mlx5e_ptp **cp);
48 void mlx5e_ptp_close(struct mlx5e_ptp *c);
49 void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c);
50 void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c);
51 int mlx5e_ptp_get_rqn(struct mlx5e_ptp *c, u32 *rqn);
52 int mlx5e_ptp_alloc_rx_fs(struct mlx5e_priv *priv);
53 void mlx5e_ptp_free_rx_fs(struct mlx5e_priv *priv);
54 int mlx5e_ptp_rx_manage_fs(struct mlx5e_priv *priv, bool set);
55
56 enum {
57         MLX5E_SKB_CB_CQE_HWTSTAMP  = BIT(0),
58         MLX5E_SKB_CB_PORT_HWTSTAMP = BIT(1),
59 };
60
61 void mlx5e_skb_cb_hwtstamp_handler(struct sk_buff *skb, int hwtstamp_type,
62                                    ktime_t hwtstamp,
63                                    struct mlx5e_ptp_cq_stats *cq_stats);
64
65 void mlx5e_skb_cb_hwtstamp_init(struct sk_buff *skb);
66 #endif /* __MLX5_EN_PTP_H__ */