1 | /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ |
2 | /* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ |
3 | |
4 | #ifndef __MLX5_MACSEC_STEERING_H__ |
5 | #define __MLX5_MACSEC_STEERING_H__ |
6 | |
7 | #ifdef CONFIG_MLX5_MACSEC |
8 | |
9 | /* Bit31 - 30: MACsec marker, Bit15-0: MACsec id */ |
10 | #define MLX5_MACEC_RX_FS_ID_MAX USHRT_MAX /* Must be power of two */ |
11 | #define MLX5_MACSEC_RX_FS_ID_MASK MLX5_MACEC_RX_FS_ID_MAX |
12 | #define MLX5_MACSEC_METADATA_MARKER(metadata) ((((metadata) >> 30) & 0x3) == 0x1) |
13 | #define MLX5_MACSEC_RX_METADAT_HANDLE(metadata) ((metadata) & MLX5_MACSEC_RX_FS_ID_MASK) |
14 | |
15 | #define MLX5_MACSEC_NUM_OF_SUPPORTED_INTERFACES 16 |
16 | |
17 | struct mlx5_macsec_fs; |
18 | union mlx5_macsec_rule; |
19 | |
20 | struct mlx5_macsec_rule_attrs { |
21 | sci_t sci; |
22 | u32 macsec_obj_id; |
23 | u8 assoc_num; |
24 | int action; |
25 | }; |
26 | |
27 | struct mlx5_macsec_stats { |
28 | u64 macsec_rx_pkts; |
29 | u64 macsec_rx_bytes; |
30 | u64 macsec_rx_pkts_drop; |
31 | u64 macsec_rx_bytes_drop; |
32 | u64 macsec_tx_pkts; |
33 | u64 macsec_tx_bytes; |
34 | u64 macsec_tx_pkts_drop; |
35 | u64 macsec_tx_bytes_drop; |
36 | }; |
37 | |
38 | enum mlx5_macsec_action { |
39 | MLX5_ACCEL_MACSEC_ACTION_ENCRYPT, |
40 | MLX5_ACCEL_MACSEC_ACTION_DECRYPT, |
41 | }; |
42 | |
43 | void mlx5_macsec_fs_cleanup(struct mlx5_macsec_fs *macsec_fs); |
44 | |
45 | struct mlx5_macsec_fs * |
46 | mlx5_macsec_fs_init(struct mlx5_core_dev *mdev); |
47 | |
48 | union mlx5_macsec_rule * |
49 | mlx5_macsec_fs_add_rule(struct mlx5_macsec_fs *macsec_fs, |
50 | const struct macsec_context *ctx, |
51 | struct mlx5_macsec_rule_attrs *attrs, |
52 | u32 *sa_fs_id); |
53 | |
54 | void mlx5_macsec_fs_del_rule(struct mlx5_macsec_fs *macsec_fs, |
55 | union mlx5_macsec_rule *macsec_rule, |
56 | int action, void *macdev, u32 sa_fs_id); |
57 | |
58 | void mlx5_macsec_fs_get_stats_fill(struct mlx5_macsec_fs *macsec_fs, void *macsec_stats); |
59 | struct mlx5_macsec_stats *mlx5_macsec_fs_get_stats(struct mlx5_macsec_fs *macsec_fs); |
60 | u32 mlx5_macsec_fs_get_fs_id_from_hashtable(struct mlx5_macsec_fs *macsec_fs, sci_t *sci); |
61 | |
62 | #endif |
63 | |
64 | #endif /* __MLX5_MACSEC_STEERING_H__ */ |
65 | |