1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
4 */
5
6 #ifndef RTE_PMD_MLX5_RXTX_H_
7 #define RTE_PMD_MLX5_RXTX_H_
8
9 #include <stddef.h>
10 #include <stdint.h>
11 #include <sys/queue.h>
12
13 #include <rte_mbuf.h>
14 #include <rte_mempool.h>
15 #include <rte_common.h>
16 #include <rte_hexdump.h>
17 #include <rte_spinlock.h>
18 #include <rte_io.h>
19 #include <rte_cycles.h>
20
21 #include <mlx5_common.h>
22 #include <mlx5_common_mr.h>
23
24 #include "mlx5_utils.h"
25 #include "mlx5.h"
26 #include "mlx5_autoconf.h"
27
28 struct mlx5_priv;
29
30 /* mlx5_rxtx.c */
31
32 extern uint32_t mlx5_ptype_table[];
33 extern uint8_t mlx5_cksum_table[];
34 extern uint8_t mlx5_swp_types_table[];
35
36 void mlx5_set_ptype_table(void);
37 void mlx5_set_cksum_table(void);
38 void mlx5_set_swp_types_table(void);
39 void mlx5_dump_debug_information(const char *path, const char *title,
40 const void *buf, unsigned int len);
41 void mlx5_dump_to_file(FILE *fd, const char *title,
42 const void *buf, unsigned int len);
43 int mlx5_queue_state_modify_primary(struct rte_eth_dev *dev,
44 const struct mlx5_mp_arg_queue_state_modify *sm);
45 int mlx5_queue_state_modify(struct rte_eth_dev *dev,
46 struct mlx5_mp_arg_queue_state_modify *sm);
47
48 /**
49 * Convert timestamp from HW format to linear counter
50 * from Packet Pacing Clock Queue CQE timestamp format.
51 *
52 * @param sh
53 * Pointer to the device shared context. Might be needed
54 * to convert according current device configuration.
55 * @param ts
56 * Timestamp from CQE to convert.
57 * @return
58 * UTC in nanoseconds
59 */
60 static __rte_always_inline uint64_t
mlx5_txpp_convert_rx_ts(struct mlx5_dev_ctx_shared * sh,uint64_t ts)61 mlx5_txpp_convert_rx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t ts)
62 {
63 RTE_SET_USED(sh);
64 return (ts & UINT32_MAX) + (ts >> 32) * NS_PER_S;
65 }
66
67 #endif /* RTE_PMD_MLX5_RXTX_H_ */
68