Commit d80a1b9d authored by Boris Pismenny's avatar Boris Pismenny Committed by David S. Miller

tls: Refactor tls_offload variable names

For symmetry, we rename tls_offload_context to
tls_offload_context_tx before we add tls_offload_context_rx.
Signed-off-by: default avatarBoris Pismenny <borisp@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 41ed9c04
...@@ -50,7 +50,7 @@ struct mlx5e_tls { ...@@ -50,7 +50,7 @@ struct mlx5e_tls {
}; };
struct mlx5e_tls_offload_context { struct mlx5e_tls_offload_context {
struct tls_offload_context base; struct tls_offload_context_tx base;
u32 expected_seq; u32 expected_seq;
__be32 swid; __be32 swid;
}; };
...@@ -59,8 +59,8 @@ static inline struct mlx5e_tls_offload_context * ...@@ -59,8 +59,8 @@ static inline struct mlx5e_tls_offload_context *
mlx5e_get_tls_tx_context(struct tls_context *tls_ctx) mlx5e_get_tls_tx_context(struct tls_context *tls_ctx)
{ {
BUILD_BUG_ON(sizeof(struct mlx5e_tls_offload_context) > BUILD_BUG_ON(sizeof(struct mlx5e_tls_offload_context) >
TLS_OFFLOAD_CONTEXT_SIZE); TLS_OFFLOAD_CONTEXT_SIZE_TX);
return container_of(tls_offload_ctx(tls_ctx), return container_of(tls_offload_ctx_tx(tls_ctx),
struct mlx5e_tls_offload_context, struct mlx5e_tls_offload_context,
base); base);
} }
......
...@@ -128,7 +128,7 @@ struct tls_record_info { ...@@ -128,7 +128,7 @@ struct tls_record_info {
skb_frag_t frags[MAX_SKB_FRAGS]; skb_frag_t frags[MAX_SKB_FRAGS];
}; };
struct tls_offload_context { struct tls_offload_context_tx {
struct crypto_aead *aead_send; struct crypto_aead *aead_send;
spinlock_t lock; /* protects records list */ spinlock_t lock; /* protects records list */
struct list_head records_list; struct list_head records_list;
...@@ -147,8 +147,8 @@ struct tls_offload_context { ...@@ -147,8 +147,8 @@ struct tls_offload_context {
#define TLS_DRIVER_STATE_SIZE (max_t(size_t, 8, sizeof(void *))) #define TLS_DRIVER_STATE_SIZE (max_t(size_t, 8, sizeof(void *)))
}; };
#define TLS_OFFLOAD_CONTEXT_SIZE \ #define TLS_OFFLOAD_CONTEXT_SIZE_TX \
(ALIGN(sizeof(struct tls_offload_context), sizeof(void *)) + \ (ALIGN(sizeof(struct tls_offload_context_tx), sizeof(void *)) + \
TLS_DRIVER_STATE_SIZE) TLS_DRIVER_STATE_SIZE)
enum { enum {
...@@ -239,7 +239,7 @@ void tls_device_sk_destruct(struct sock *sk); ...@@ -239,7 +239,7 @@ void tls_device_sk_destruct(struct sock *sk);
void tls_device_init(void); void tls_device_init(void);
void tls_device_cleanup(void); void tls_device_cleanup(void);
struct tls_record_info *tls_get_record(struct tls_offload_context *context, struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context,
u32 seq, u64 *p_record_sn); u32 seq, u64 *p_record_sn);
static inline bool tls_record_is_start_marker(struct tls_record_info *rec) static inline bool tls_record_is_start_marker(struct tls_record_info *rec)
...@@ -380,10 +380,10 @@ static inline struct tls_sw_context_tx *tls_sw_ctx_tx( ...@@ -380,10 +380,10 @@ static inline struct tls_sw_context_tx *tls_sw_ctx_tx(
return (struct tls_sw_context_tx *)tls_ctx->priv_ctx_tx; return (struct tls_sw_context_tx *)tls_ctx->priv_ctx_tx;
} }
static inline struct tls_offload_context *tls_offload_ctx( static inline struct tls_offload_context_tx *
const struct tls_context *tls_ctx) tls_offload_ctx_tx(const struct tls_context *tls_ctx)
{ {
return (struct tls_offload_context *)tls_ctx->priv_ctx_tx; return (struct tls_offload_context_tx *)tls_ctx->priv_ctx_tx;
} }
int tls_proccess_cmsg(struct sock *sk, struct msghdr *msg, int tls_proccess_cmsg(struct sock *sk, struct msghdr *msg,
...@@ -396,7 +396,7 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk, ...@@ -396,7 +396,7 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk,
struct sk_buff *skb); struct sk_buff *skb);
int tls_sw_fallback_init(struct sock *sk, int tls_sw_fallback_init(struct sock *sk,
struct tls_offload_context *offload_ctx, struct tls_offload_context_tx *offload_ctx,
struct tls_crypto_info *crypto_info); struct tls_crypto_info *crypto_info);
#endif /* _TLS_OFFLOAD_H */ #endif /* _TLS_OFFLOAD_H */
...@@ -52,9 +52,8 @@ static DEFINE_SPINLOCK(tls_device_lock); ...@@ -52,9 +52,8 @@ static DEFINE_SPINLOCK(tls_device_lock);
static void tls_device_free_ctx(struct tls_context *ctx) static void tls_device_free_ctx(struct tls_context *ctx)
{ {
struct tls_offload_context *offload_ctx = tls_offload_ctx(ctx); kfree(tls_offload_ctx_tx(ctx));
kfree(offload_ctx);
kfree(ctx); kfree(ctx);
} }
...@@ -125,7 +124,7 @@ static void destroy_record(struct tls_record_info *record) ...@@ -125,7 +124,7 @@ static void destroy_record(struct tls_record_info *record)
kfree(record); kfree(record);
} }
static void delete_all_records(struct tls_offload_context *offload_ctx) static void delete_all_records(struct tls_offload_context_tx *offload_ctx)
{ {
struct tls_record_info *info, *temp; struct tls_record_info *info, *temp;
...@@ -141,14 +140,14 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq) ...@@ -141,14 +140,14 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq)
{ {
struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_record_info *info, *temp; struct tls_record_info *info, *temp;
struct tls_offload_context *ctx; struct tls_offload_context_tx *ctx;
u64 deleted_records = 0; u64 deleted_records = 0;
unsigned long flags; unsigned long flags;
if (!tls_ctx) if (!tls_ctx)
return; return;
ctx = tls_offload_ctx(tls_ctx); ctx = tls_offload_ctx_tx(tls_ctx);
spin_lock_irqsave(&ctx->lock, flags); spin_lock_irqsave(&ctx->lock, flags);
info = ctx->retransmit_hint; info = ctx->retransmit_hint;
...@@ -179,7 +178,7 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq) ...@@ -179,7 +178,7 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq)
void tls_device_sk_destruct(struct sock *sk) void tls_device_sk_destruct(struct sock *sk)
{ {
struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx); struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
if (ctx->open_record) if (ctx->open_record)
destroy_record(ctx->open_record); destroy_record(ctx->open_record);
...@@ -219,7 +218,7 @@ static void tls_append_frag(struct tls_record_info *record, ...@@ -219,7 +218,7 @@ static void tls_append_frag(struct tls_record_info *record,
static int tls_push_record(struct sock *sk, static int tls_push_record(struct sock *sk,
struct tls_context *ctx, struct tls_context *ctx,
struct tls_offload_context *offload_ctx, struct tls_offload_context_tx *offload_ctx,
struct tls_record_info *record, struct tls_record_info *record,
struct page_frag *pfrag, struct page_frag *pfrag,
int flags, int flags,
...@@ -264,7 +263,7 @@ static int tls_push_record(struct sock *sk, ...@@ -264,7 +263,7 @@ static int tls_push_record(struct sock *sk,
return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags); return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags);
} }
static int tls_create_new_record(struct tls_offload_context *offload_ctx, static int tls_create_new_record(struct tls_offload_context_tx *offload_ctx,
struct page_frag *pfrag, struct page_frag *pfrag,
size_t prepend_size) size_t prepend_size)
{ {
...@@ -290,7 +289,7 @@ static int tls_create_new_record(struct tls_offload_context *offload_ctx, ...@@ -290,7 +289,7 @@ static int tls_create_new_record(struct tls_offload_context *offload_ctx,
} }
static int tls_do_allocation(struct sock *sk, static int tls_do_allocation(struct sock *sk,
struct tls_offload_context *offload_ctx, struct tls_offload_context_tx *offload_ctx,
struct page_frag *pfrag, struct page_frag *pfrag,
size_t prepend_size) size_t prepend_size)
{ {
...@@ -324,7 +323,7 @@ static int tls_push_data(struct sock *sk, ...@@ -324,7 +323,7 @@ static int tls_push_data(struct sock *sk,
unsigned char record_type) unsigned char record_type)
{ {
struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx); struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
int tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST; int tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST;
int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE); int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE);
struct tls_record_info *record = ctx->open_record; struct tls_record_info *record = ctx->open_record;
...@@ -477,7 +476,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page, ...@@ -477,7 +476,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
return rc; return rc;
} }
struct tls_record_info *tls_get_record(struct tls_offload_context *context, struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context,
u32 seq, u64 *p_record_sn) u32 seq, u64 *p_record_sn)
{ {
u64 record_sn = context->hint_record_sn; u64 record_sn = context->hint_record_sn;
...@@ -524,7 +523,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) ...@@ -524,7 +523,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
{ {
u16 nonce_size, tag_size, iv_size, rec_seq_size; u16 nonce_size, tag_size, iv_size, rec_seq_size;
struct tls_record_info *start_marker_record; struct tls_record_info *start_marker_record;
struct tls_offload_context *offload_ctx; struct tls_offload_context_tx *offload_ctx;
struct tls_crypto_info *crypto_info; struct tls_crypto_info *crypto_info;
struct net_device *netdev; struct net_device *netdev;
char *iv, *rec_seq; char *iv, *rec_seq;
...@@ -546,7 +545,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) ...@@ -546,7 +545,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
goto out; goto out;
} }
offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE, GFP_KERNEL); offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE_TX, GFP_KERNEL);
if (!offload_ctx) { if (!offload_ctx) {
rc = -ENOMEM; rc = -ENOMEM;
goto free_marker_record; goto free_marker_record;
......
...@@ -214,7 +214,7 @@ static void complete_skb(struct sk_buff *nskb, struct sk_buff *skb, int headln) ...@@ -214,7 +214,7 @@ static void complete_skb(struct sk_buff *nskb, struct sk_buff *skb, int headln)
static int fill_sg_in(struct scatterlist *sg_in, static int fill_sg_in(struct scatterlist *sg_in,
struct sk_buff *skb, struct sk_buff *skb,
struct tls_offload_context *ctx, struct tls_offload_context_tx *ctx,
u64 *rcd_sn, u64 *rcd_sn,
s32 *sync_size, s32 *sync_size,
int *resync_sgs) int *resync_sgs)
...@@ -299,7 +299,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx, ...@@ -299,7 +299,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx,
s32 sync_size, u64 rcd_sn) s32 sync_size, u64 rcd_sn)
{ {
int tcp_payload_offset = skb_transport_offset(skb) + tcp_hdrlen(skb); int tcp_payload_offset = skb_transport_offset(skb) + tcp_hdrlen(skb);
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx); struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
int payload_len = skb->len - tcp_payload_offset; int payload_len = skb->len - tcp_payload_offset;
void *buf, *iv, *aad, *dummy_buf; void *buf, *iv, *aad, *dummy_buf;
struct aead_request *aead_req; struct aead_request *aead_req;
...@@ -361,7 +361,7 @@ static struct sk_buff *tls_sw_fallback(struct sock *sk, struct sk_buff *skb) ...@@ -361,7 +361,7 @@ static struct sk_buff *tls_sw_fallback(struct sock *sk, struct sk_buff *skb)
{ {
int tcp_payload_offset = skb_transport_offset(skb) + tcp_hdrlen(skb); int tcp_payload_offset = skb_transport_offset(skb) + tcp_hdrlen(skb);
struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx); struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
int payload_len = skb->len - tcp_payload_offset; int payload_len = skb->len - tcp_payload_offset;
struct scatterlist *sg_in, sg_out[3]; struct scatterlist *sg_in, sg_out[3];
struct sk_buff *nskb = NULL; struct sk_buff *nskb = NULL;
...@@ -415,7 +415,7 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk, ...@@ -415,7 +415,7 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk,
} }
int tls_sw_fallback_init(struct sock *sk, int tls_sw_fallback_init(struct sock *sk,
struct tls_offload_context *offload_ctx, struct tls_offload_context_tx *offload_ctx,
struct tls_crypto_info *crypto_info) struct tls_crypto_info *crypto_info)
{ {
const u8 *key; const u8 *key;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment