| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ |
| 2 |
/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ |
| 3 |
|
| 4 |
#ifndef __MLX5E_ACCEL_PSP_H__ |
| 5 |
#define __MLX5E_ACCEL_PSP_H__ |
| 6 |
#if IS_ENABLED(CONFIG_MLX5_EN_PSP) |
| 7 |
#include <net/psp/types.h> |
| 8 |
#include "en.h" |
| 9 |
|
| 10 |
struct mlx5e_psp_stats { |
| 11 |
u64 psp_rx_pkts; |
| 12 |
u64 psp_rx_bytes; |
| 13 |
u64 psp_rx_pkts_auth_fail; |
| 14 |
u64 psp_rx_bytes_auth_fail; |
| 15 |
u64 psp_rx_pkts_frame_err; |
| 16 |
u64 psp_rx_bytes_frame_err; |
| 17 |
u64 psp_rx_pkts_drop; |
| 18 |
u64 psp_rx_bytes_drop; |
| 19 |
u64 psp_tx_pkts; |
| 20 |
u64 psp_tx_bytes; |
| 21 |
u64 psp_tx_pkts_drop; |
| 22 |
u64 psp_tx_bytes_drop; |
| 23 |
}; |
| 24 |
|
| 25 |
struct mlx5e_psp { |
| 26 |
struct psp_dev *psp; |
| 27 |
struct psp_dev_caps caps; |
| 28 |
struct mlx5e_psp_fs *fs; |
| 29 |
atomic_t tx_key_cnt; |
| 30 |
atomic_t tx_drop; |
| 31 |
}; |
| 32 |
|
| 33 |
static inline bool mlx5_is_psp_device(struct mlx5_core_dev *mdev) |
| 34 |
{ |
| 35 |
if (!MLX5_CAP_GEN(mdev, psp)) |
| 36 |
return false; |
| 37 |
|
| 38 |
if (!MLX5_CAP_PSP(mdev, psp_crypto_offload) || |
| 39 |
!MLX5_CAP_PSP(mdev, psp_crypto_esp_aes_gcm_128_encrypt) || |
| 40 |
!MLX5_CAP_PSP(mdev, psp_crypto_esp_aes_gcm_128_decrypt)) |
| 41 |
return false; |
| 42 |
|
| 43 |
return true; |
| 44 |
} |
| 45 |
|
| 46 |
int mlx5_accel_psp_fs_init_rx_tables(struct mlx5e_priv *priv); |
| 47 |
void mlx5_accel_psp_fs_cleanup_rx_tables(struct mlx5e_priv *priv); |
| 48 |
int mlx5_accel_psp_fs_init_tx_tables(struct mlx5e_priv *priv); |
| 49 |
void mlx5_accel_psp_fs_cleanup_tx_tables(struct mlx5e_priv *priv); |
| 50 |
void mlx5e_psp_register(struct mlx5e_priv *priv); |
| 51 |
void mlx5e_psp_unregister(struct mlx5e_priv *priv); |
| 52 |
int mlx5e_psp_init(struct mlx5e_priv *priv); |
| 53 |
void mlx5e_psp_cleanup(struct mlx5e_priv *priv); |
| 54 |
#else |
| 55 |
static inline int mlx5_accel_psp_fs_init_rx_tables(struct mlx5e_priv *priv) |
| 56 |
{ |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
static inline void mlx5_accel_psp_fs_cleanup_rx_tables(struct mlx5e_priv *priv) { } |
| 61 |
static inline int mlx5_accel_psp_fs_init_tx_tables(struct mlx5e_priv *priv) |
| 62 |
{ |
| 63 |
return 0; |
| 64 |
} |
| 65 |
|
| 66 |
static inline void mlx5_accel_psp_fs_cleanup_tx_tables(struct mlx5e_priv *priv) { } |
| 67 |
static inline bool mlx5_is_psp_device(struct mlx5_core_dev *mdev) |
| 68 |
{ |
| 69 |
return false; |
| 70 |
} |
| 71 |
|
| 72 |
static inline void mlx5e_psp_register(struct mlx5e_priv *priv) { } |
| 73 |
static inline void mlx5e_psp_unregister(struct mlx5e_priv *priv) { } |
| 74 |
static inline int mlx5e_psp_init(struct mlx5e_priv *priv) { return 0; } |
| 75 |
static inline void mlx5e_psp_cleanup(struct mlx5e_priv *priv) { } |
| 76 |
#endif /* CONFIG_MLX5_EN_PSP */ |
| 77 |
#endif /* __MLX5E_ACCEL_PSP_H__ */ |