1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3
4#ifndef __MLX5_EN_ACCEL_MACSEC_H__
5#define __MLX5_EN_ACCEL_MACSEC_H__
6
7#ifdef CONFIG_MLX5_MACSEC
8
9#include <linux/mlx5/driver.h>
10#include <net/macsec.h>
11#include <net/dst_metadata.h>
12#include "lib/macsec_fs.h"
13
14struct mlx5e_priv;
15struct mlx5e_macsec;
16
17void mlx5e_macsec_build_netdev(struct mlx5e_priv *priv);
18int mlx5e_macsec_init(struct mlx5e_priv *priv);
19void mlx5e_macsec_cleanup(struct mlx5e_priv *priv);
20bool mlx5e_macsec_handle_tx_skb(struct mlx5e_macsec *macsec, struct sk_buff *skb);
21void mlx5e_macsec_tx_build_eseg(struct mlx5e_macsec *macsec,
22 struct sk_buff *skb,
23 struct mlx5_wqe_eth_seg *eseg);
24
25static inline bool mlx5e_macsec_skb_is_offload(struct sk_buff *skb)
26{
27 struct metadata_dst *md_dst = skb_metadata_dst(skb);
28
29 return md_dst && (md_dst->type == METADATA_MACSEC);
30}
31
32static inline bool mlx5e_macsec_is_rx_flow(struct mlx5_cqe64 *cqe)
33{
34 return MLX5_MACSEC_METADATA_MARKER(be32_to_cpu(cqe->ft_metadata));
35}
36
37void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
38 struct mlx5_cqe64 *cqe);
39
40#else
41
42static inline void mlx5e_macsec_build_netdev(struct mlx5e_priv *priv) {}
43static inline int mlx5e_macsec_init(struct mlx5e_priv *priv) { return 0; }
44static inline void mlx5e_macsec_cleanup(struct mlx5e_priv *priv) {}
45static inline bool mlx5e_macsec_skb_is_offload(struct sk_buff *skb) { return false; }
46static inline bool mlx5e_macsec_is_rx_flow(struct mlx5_cqe64 *cqe) { return false; }
47static inline void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev,
48 struct sk_buff *skb,
49 struct mlx5_cqe64 *cqe)
50{}
51#endif /* CONFIG_MLX5_MACSEC */
52
53#endif /* __MLX5_ACCEL_EN_MACSEC_H__ */
54

source code of linux/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.h