Lines Matching refs:ctx
53 static void tls_device_free_ctx(struct tls_context *ctx) in tls_device_free_ctx() argument
55 if (ctx->tx_conf == TLS_HW) { in tls_device_free_ctx()
56 kfree(tls_offload_ctx_tx(ctx)); in tls_device_free_ctx()
57 kfree(ctx->tx.rec_seq); in tls_device_free_ctx()
58 kfree(ctx->tx.iv); in tls_device_free_ctx()
61 if (ctx->rx_conf == TLS_HW) in tls_device_free_ctx()
62 kfree(tls_offload_ctx_rx(ctx)); in tls_device_free_ctx()
64 tls_ctx_free(NULL, ctx); in tls_device_free_ctx()
69 struct tls_context *ctx, *tmp; in tls_device_gc_task() local
77 list_for_each_entry_safe(ctx, tmp, &gc_list, list) { in tls_device_gc_task()
78 struct net_device *netdev = ctx->netdev; in tls_device_gc_task()
80 if (netdev && ctx->tx_conf == TLS_HW) { in tls_device_gc_task()
81 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_gc_task()
84 ctx->netdev = NULL; in tls_device_gc_task()
87 list_del(&ctx->list); in tls_device_gc_task()
88 tls_device_free_ctx(ctx); in tls_device_gc_task()
92 static void tls_device_queue_ctx_destruction(struct tls_context *ctx) in tls_device_queue_ctx_destruction() argument
97 list_move_tail(&ctx->list, &tls_device_gc_list); in tls_device_queue_ctx_destruction()
148 struct tls_offload_context_tx *ctx; in tls_icsk_clean_acked() local
155 ctx = tls_offload_ctx_tx(tls_ctx); in tls_icsk_clean_acked()
157 spin_lock_irqsave(&ctx->lock, flags); in tls_icsk_clean_acked()
158 info = ctx->retransmit_hint; in tls_icsk_clean_acked()
160 ctx->retransmit_hint = NULL; in tls_icsk_clean_acked()
162 list_for_each_entry_safe(info, temp, &ctx->records_list, list) { in tls_icsk_clean_acked()
171 ctx->unacked_record_sn += deleted_records; in tls_icsk_clean_acked()
172 spin_unlock_irqrestore(&ctx->lock, flags); in tls_icsk_clean_acked()
182 struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); in tls_device_sk_destruct() local
187 if (ctx->open_record) in tls_device_sk_destruct()
188 destroy_record(ctx->open_record); in tls_device_sk_destruct()
189 delete_all_records(ctx); in tls_device_sk_destruct()
190 crypto_free_aead(ctx->aead_send); in tls_device_sk_destruct()
256 struct tls_context *ctx, in tls_push_record() argument
261 struct tls_prot_info *prot = &ctx->prot_info; in tls_push_record()
270 if (test_bit(TLS_TX_SYNC_SCHED, &ctx->flags)) in tls_push_record()
271 tls_device_resync_tx(sk, ctx, tp->write_seq); in tls_push_record()
273 tls_advance_record_sn(sk, prot, &ctx->tx); in tls_push_record()
286 return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags); in tls_push_record()
290 struct tls_context *ctx, in tls_device_record_close() argument
295 struct tls_prot_info *prot = &ctx->prot_info; in tls_device_record_close()
315 tls_fill_prepend(ctx, skb_frag_address(&record->frags[0]), in tls_device_record_close()
407 struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); in tls_push_data() local
409 struct tls_record_info *record = ctx->open_record; in tls_push_data()
443 rc = tls_do_allocation(sk, ctx, pfrag, in tls_push_data()
450 record = ctx->open_record; in tls_push_data()
461 ctx->open_record = NULL; in tls_push_data()
469 record = ctx->open_record; in tls_push_data()
502 ctx->open_record = NULL; in tls_push_data()
509 ctx, in tls_push_data()
630 void tls_device_write_space(struct sock *sk, struct tls_context *ctx) in tls_device_write_space() argument
632 if (tls_is_partially_sent_record(ctx)) { in tls_device_write_space()
638 tls_push_partial_record(sk, ctx, in tls_device_write_space()
707 struct tls_offload_context_rx *ctx, in tls_device_core_ctrl_rx_resync() argument
713 if (ctx->resync_type != TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT) in tls_device_core_ctrl_rx_resync()
716 if (ctx->resync_nh_do_now) in tls_device_core_ctrl_rx_resync()
719 if (ctx->resync_nh_reset) { in tls_device_core_ctrl_rx_resync()
720 ctx->resync_nh_reset = 0; in tls_device_core_ctrl_rx_resync()
721 ctx->resync_nh.decrypted_failed = 1; in tls_device_core_ctrl_rx_resync()
722 ctx->resync_nh.decrypted_tgt = TLS_DEVICE_RESYNC_NH_START_IVAL; in tls_device_core_ctrl_rx_resync()
726 if (++ctx->resync_nh.decrypted_failed <= ctx->resync_nh.decrypted_tgt) in tls_device_core_ctrl_rx_resync()
730 if (ctx->resync_nh.decrypted_tgt < TLS_DEVICE_RESYNC_NH_MAX_IVAL) in tls_device_core_ctrl_rx_resync()
731 ctx->resync_nh.decrypted_tgt *= 2; in tls_device_core_ctrl_rx_resync()
733 ctx->resync_nh.decrypted_tgt += TLS_DEVICE_RESYNC_NH_MAX_IVAL; in tls_device_core_ctrl_rx_resync()
739 ctx->resync_nh_do_now = 1; in tls_device_core_ctrl_rx_resync()
840 struct tls_offload_context_rx *ctx = tls_offload_ctx_rx(tls_ctx); in tls_device_decrypted() local
851 ctx->sw.decrypted |= is_decrypted; in tls_device_decrypted()
858 ctx->resync_nh_reset = 1; in tls_device_decrypted()
862 tls_device_core_ctrl_rx_resync(tls_ctx, ctx, sk, skb); in tls_device_decrypted()
866 ctx->resync_nh_reset = 1; in tls_device_decrypted()
870 static void tls_device_attach(struct tls_context *ctx, struct sock *sk, in tls_device_attach() argument
874 refcount_set(&ctx->refcount, 1); in tls_device_attach()
876 ctx->netdev = netdev; in tls_device_attach()
878 list_add_tail(&ctx->list, &tls_device_list); in tls_device_attach()
881 ctx->sk_destruct = sk->sk_destruct; in tls_device_attach()
886 int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) in tls_set_device_offload() argument
900 if (!ctx) in tls_set_device_offload()
903 if (ctx->priv_ctx_tx) in tls_set_device_offload()
916 crypto_info = &ctx->crypto_send.info; in tls_set_device_offload()
949 ctx->tx.iv = kmalloc(iv_size + TLS_CIPHER_AES_GCM_128_SALT_SIZE, in tls_set_device_offload()
951 if (!ctx->tx.iv) { in tls_set_device_offload()
956 memcpy(ctx->tx.iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, iv, iv_size); in tls_set_device_offload()
959 ctx->tx.rec_seq = kmemdup(rec_seq, rec_seq_size, GFP_KERNEL); in tls_set_device_offload()
960 if (!ctx->tx.rec_seq) { in tls_set_device_offload()
970 memcpy(&rcd_sn, ctx->tx.rec_seq, sizeof(rcd_sn)); in tls_set_device_offload()
984 ctx->push_pending_record = tls_device_push_pending_record; in tls_set_device_offload()
1020 ctx->priv_ctx_tx = offload_ctx; in tls_set_device_offload()
1022 &ctx->crypto_send.info, in tls_set_device_offload()
1027 tls_device_attach(ctx, sk, netdev); in tls_set_device_offload()
1047 kfree(ctx->tx.rec_seq); in tls_set_device_offload()
1049 kfree(ctx->tx.iv); in tls_set_device_offload()
1052 ctx->priv_ctx_tx = NULL; in tls_set_device_offload()
1058 int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx) in tls_set_device_offload_rx() argument
1064 if (ctx->crypto_recv.info.version != TLS_1_2_VERSION) in tls_set_device_offload_rx()
1099 ctx->priv_ctx_rx = context; in tls_set_device_offload_rx()
1100 rc = tls_set_sw_offload(sk, ctx, 0); in tls_set_device_offload_rx()
1105 &ctx->crypto_recv.info, in tls_set_device_offload_rx()
1110 tls_device_attach(ctx, sk, netdev); in tls_set_device_offload_rx()
1122 ctx->priv_ctx_rx = NULL; in tls_set_device_offload_rx()
1154 struct tls_context *ctx, *tmp; in tls_device_down() local
1162 list_for_each_entry_safe(ctx, tmp, &tls_device_list, list) { in tls_device_down()
1163 if (ctx->netdev != netdev || in tls_device_down()
1164 !refcount_inc_not_zero(&ctx->refcount)) in tls_device_down()
1167 list_move(&ctx->list, &list); in tls_device_down()
1171 list_for_each_entry_safe(ctx, tmp, &list, list) { in tls_device_down()
1172 if (ctx->tx_conf == TLS_HW) in tls_device_down()
1173 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_down()
1175 if (ctx->rx_conf == TLS_HW) in tls_device_down()
1176 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_down()
1178 WRITE_ONCE(ctx->netdev, NULL); in tls_device_down()
1180 while (test_bit(TLS_RX_SYNC_RUNNING, &ctx->flags)) in tls_device_down()
1183 list_del_init(&ctx->list); in tls_device_down()
1185 if (refcount_dec_and_test(&ctx->refcount)) in tls_device_down()
1186 tls_device_free_ctx(ctx); in tls_device_down()