2 * Copyright (c) 2018 Mellanox Technologies. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #ifndef __MLX5E_TLS_H__
34 #define __MLX5E_TLS_H__
36 #ifdef CONFIG_MLX5_EN_TLS
41 struct mlx5e_tls_sw_stats {
42 atomic64_t tx_tls_drop_metadata;
43 atomic64_t tx_tls_drop_resync_alloc;
44 atomic64_t tx_tls_drop_no_sync_data;
45 atomic64_t tx_tls_drop_bypass_required;
46 atomic64_t rx_tls_drop_resync_request;
47 atomic64_t rx_tls_resync_request;
48 atomic64_t rx_tls_resync_reply;
49 atomic64_t rx_tls_auth_fail;
53 struct mlx5e_tls_sw_stats sw_stats;
56 struct mlx5e_tls_offload_context_tx {
57 struct tls_offload_context_tx base;
62 static inline struct mlx5e_tls_offload_context_tx *
63 mlx5e_get_tls_tx_context(struct tls_context *tls_ctx)
65 BUILD_BUG_ON(sizeof(struct mlx5e_tls_offload_context_tx) >
66 TLS_OFFLOAD_CONTEXT_SIZE_TX);
67 return container_of(tls_offload_ctx_tx(tls_ctx),
68 struct mlx5e_tls_offload_context_tx,
72 struct mlx5e_tls_offload_context_rx {
73 struct tls_offload_context_rx base;
77 static inline struct mlx5e_tls_offload_context_rx *
78 mlx5e_get_tls_rx_context(struct tls_context *tls_ctx)
80 BUILD_BUG_ON(sizeof(struct mlx5e_tls_offload_context_rx) >
81 TLS_OFFLOAD_CONTEXT_SIZE_RX);
82 return container_of(tls_offload_ctx_rx(tls_ctx),
83 struct mlx5e_tls_offload_context_rx,
87 void mlx5e_tls_build_netdev(struct mlx5e_priv *priv);
88 int mlx5e_tls_init(struct mlx5e_priv *priv);
89 void mlx5e_tls_cleanup(struct mlx5e_priv *priv);
91 int mlx5e_tls_get_count(struct mlx5e_priv *priv);
92 int mlx5e_tls_get_strings(struct mlx5e_priv *priv, uint8_t *data);
93 int mlx5e_tls_get_stats(struct mlx5e_priv *priv, u64 *data);
97 static inline void mlx5e_tls_build_netdev(struct mlx5e_priv *priv) { }
98 static inline int mlx5e_tls_init(struct mlx5e_priv *priv) { return 0; }
99 static inline void mlx5e_tls_cleanup(struct mlx5e_priv *priv) { }
100 static inline int mlx5e_tls_get_count(struct mlx5e_priv *priv) { return 0; }
101 static inline int mlx5e_tls_get_strings(struct mlx5e_priv *priv, uint8_t *data) { return 0; }
102 static inline int mlx5e_tls_get_stats(struct mlx5e_priv *priv, u64 *data) { return 0; }
106 #endif /* __MLX5E_TLS_H__ */