Skip to content

Commit d80a1b9

Browse files
Boris Pismennydavem330
authored andcommitted
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: Boris Pismenny <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 41ed9c0 commit d80a1b9

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct mlx5e_tls {
5050
};
5151

5252
struct mlx5e_tls_offload_context {
53-
struct tls_offload_context base;
53+
struct tls_offload_context_tx base;
5454
u32 expected_seq;
5555
__be32 swid;
5656
};
@@ -59,8 +59,8 @@ static inline struct mlx5e_tls_offload_context *
5959
mlx5e_get_tls_tx_context(struct tls_context *tls_ctx)
6060
{
6161
BUILD_BUG_ON(sizeof(struct mlx5e_tls_offload_context) >
62-
TLS_OFFLOAD_CONTEXT_SIZE);
63-
return container_of(tls_offload_ctx(tls_ctx),
62+
TLS_OFFLOAD_CONTEXT_SIZE_TX);
63+
return container_of(tls_offload_ctx_tx(tls_ctx),
6464
struct mlx5e_tls_offload_context,
6565
base);
6666
}

include/net/tls.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct tls_record_info {
128128
skb_frag_t frags[MAX_SKB_FRAGS];
129129
};
130130

131-
struct tls_offload_context {
131+
struct tls_offload_context_tx {
132132
struct crypto_aead *aead_send;
133133
spinlock_t lock; /* protects records list */
134134
struct list_head records_list;
@@ -147,8 +147,8 @@ struct tls_offload_context {
147147
#define TLS_DRIVER_STATE_SIZE (max_t(size_t, 8, sizeof(void *)))
148148
};
149149

150-
#define TLS_OFFLOAD_CONTEXT_SIZE \
151-
(ALIGN(sizeof(struct tls_offload_context), sizeof(void *)) + \
150+
#define TLS_OFFLOAD_CONTEXT_SIZE_TX \
151+
(ALIGN(sizeof(struct tls_offload_context_tx), sizeof(void *)) + \
152152
TLS_DRIVER_STATE_SIZE)
153153

154154
enum {
@@ -239,7 +239,7 @@ void tls_device_sk_destruct(struct sock *sk);
239239
void tls_device_init(void);
240240
void tls_device_cleanup(void);
241241

242-
struct tls_record_info *tls_get_record(struct tls_offload_context *context,
242+
struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context,
243243
u32 seq, u64 *p_record_sn);
244244

245245
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(
380380
return (struct tls_sw_context_tx *)tls_ctx->priv_ctx_tx;
381381
}
382382

383-
static inline struct tls_offload_context *tls_offload_ctx(
384-
const struct tls_context *tls_ctx)
383+
static inline struct tls_offload_context_tx *
384+
tls_offload_ctx_tx(const struct tls_context *tls_ctx)
385385
{
386-
return (struct tls_offload_context *)tls_ctx->priv_ctx_tx;
386+
return (struct tls_offload_context_tx *)tls_ctx->priv_ctx_tx;
387387
}
388388

389389
int tls_proccess_cmsg(struct sock *sk, struct msghdr *msg,
@@ -396,7 +396,7 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk,
396396
struct sk_buff *skb);
397397

398398
int tls_sw_fallback_init(struct sock *sk,
399-
struct tls_offload_context *offload_ctx,
399+
struct tls_offload_context_tx *offload_ctx,
400400
struct tls_crypto_info *crypto_info);
401401

402402
#endif /* _TLS_OFFLOAD_H */

net/tls/tls_device.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ static DEFINE_SPINLOCK(tls_device_lock);
5252

5353
static void tls_device_free_ctx(struct tls_context *ctx)
5454
{
55-
struct tls_offload_context *offload_ctx = tls_offload_ctx(ctx);
55+
kfree(tls_offload_ctx_tx(ctx));
5656

57-
kfree(offload_ctx);
5857
kfree(ctx);
5958
}
6059

@@ -125,7 +124,7 @@ static void destroy_record(struct tls_record_info *record)
125124
kfree(record);
126125
}
127126

128-
static void delete_all_records(struct tls_offload_context *offload_ctx)
127+
static void delete_all_records(struct tls_offload_context_tx *offload_ctx)
129128
{
130129
struct tls_record_info *info, *temp;
131130

@@ -141,14 +140,14 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq)
141140
{
142141
struct tls_context *tls_ctx = tls_get_ctx(sk);
143142
struct tls_record_info *info, *temp;
144-
struct tls_offload_context *ctx;
143+
struct tls_offload_context_tx *ctx;
145144
u64 deleted_records = 0;
146145
unsigned long flags;
147146

148147
if (!tls_ctx)
149148
return;
150149

151-
ctx = tls_offload_ctx(tls_ctx);
150+
ctx = tls_offload_ctx_tx(tls_ctx);
152151

153152
spin_lock_irqsave(&ctx->lock, flags);
154153
info = ctx->retransmit_hint;
@@ -179,7 +178,7 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq)
179178
void tls_device_sk_destruct(struct sock *sk)
180179
{
181180
struct tls_context *tls_ctx = tls_get_ctx(sk);
182-
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx);
181+
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
183182

184183
if (ctx->open_record)
185184
destroy_record(ctx->open_record);
@@ -219,7 +218,7 @@ static void tls_append_frag(struct tls_record_info *record,
219218

220219
static int tls_push_record(struct sock *sk,
221220
struct tls_context *ctx,
222-
struct tls_offload_context *offload_ctx,
221+
struct tls_offload_context_tx *offload_ctx,
223222
struct tls_record_info *record,
224223
struct page_frag *pfrag,
225224
int flags,
@@ -264,7 +263,7 @@ static int tls_push_record(struct sock *sk,
264263
return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags);
265264
}
266265

267-
static int tls_create_new_record(struct tls_offload_context *offload_ctx,
266+
static int tls_create_new_record(struct tls_offload_context_tx *offload_ctx,
268267
struct page_frag *pfrag,
269268
size_t prepend_size)
270269
{
@@ -290,7 +289,7 @@ static int tls_create_new_record(struct tls_offload_context *offload_ctx,
290289
}
291290

292291
static int tls_do_allocation(struct sock *sk,
293-
struct tls_offload_context *offload_ctx,
292+
struct tls_offload_context_tx *offload_ctx,
294293
struct page_frag *pfrag,
295294
size_t prepend_size)
296295
{
@@ -324,7 +323,7 @@ static int tls_push_data(struct sock *sk,
324323
unsigned char record_type)
325324
{
326325
struct tls_context *tls_ctx = tls_get_ctx(sk);
327-
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx);
326+
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
328327
int tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST;
329328
int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE);
330329
struct tls_record_info *record = ctx->open_record;
@@ -477,7 +476,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
477476
return rc;
478477
}
479478

480-
struct tls_record_info *tls_get_record(struct tls_offload_context *context,
479+
struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context,
481480
u32 seq, u64 *p_record_sn)
482481
{
483482
u64 record_sn = context->hint_record_sn;
@@ -524,7 +523,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
524523
{
525524
u16 nonce_size, tag_size, iv_size, rec_seq_size;
526525
struct tls_record_info *start_marker_record;
527-
struct tls_offload_context *offload_ctx;
526+
struct tls_offload_context_tx *offload_ctx;
528527
struct tls_crypto_info *crypto_info;
529528
struct net_device *netdev;
530529
char *iv, *rec_seq;
@@ -546,7 +545,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
546545
goto out;
547546
}
548547

549-
offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE, GFP_KERNEL);
548+
offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE_TX, GFP_KERNEL);
550549
if (!offload_ctx) {
551550
rc = -ENOMEM;
552551
goto free_marker_record;

net/tls/tls_device_fallback.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static void complete_skb(struct sk_buff *nskb, struct sk_buff *skb, int headln)
214214

215215
static int fill_sg_in(struct scatterlist *sg_in,
216216
struct sk_buff *skb,
217-
struct tls_offload_context *ctx,
217+
struct tls_offload_context_tx *ctx,
218218
u64 *rcd_sn,
219219
s32 *sync_size,
220220
int *resync_sgs)
@@ -299,7 +299,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx,
299299
s32 sync_size, u64 rcd_sn)
300300
{
301301
int tcp_payload_offset = skb_transport_offset(skb) + tcp_hdrlen(skb);
302-
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx);
302+
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
303303
int payload_len = skb->len - tcp_payload_offset;
304304
void *buf, *iv, *aad, *dummy_buf;
305305
struct aead_request *aead_req;
@@ -361,7 +361,7 @@ static struct sk_buff *tls_sw_fallback(struct sock *sk, struct sk_buff *skb)
361361
{
362362
int tcp_payload_offset = skb_transport_offset(skb) + tcp_hdrlen(skb);
363363
struct tls_context *tls_ctx = tls_get_ctx(sk);
364-
struct tls_offload_context *ctx = tls_offload_ctx(tls_ctx);
364+
struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
365365
int payload_len = skb->len - tcp_payload_offset;
366366
struct scatterlist *sg_in, sg_out[3];
367367
struct sk_buff *nskb = NULL;
@@ -415,7 +415,7 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk,
415415
}
416416

417417
int tls_sw_fallback_init(struct sock *sk,
418-
struct tls_offload_context *offload_ctx,
418+
struct tls_offload_context_tx *offload_ctx,
419419
struct tls_crypto_info *crypto_info)
420420
{
421421
const u8 *key;

0 commit comments

Comments
 (0)