Lines Matching refs:ctx
58 static void tls_device_free_ctx(struct tls_context *ctx) in tls_device_free_ctx() argument
60 if (ctx->tx_conf == TLS_HW) in tls_device_free_ctx()
61 kfree(tls_offload_ctx_tx(ctx)); in tls_device_free_ctx()
63 if (ctx->rx_conf == TLS_HW) in tls_device_free_ctx()
64 kfree(tls_offload_ctx_rx(ctx)); in tls_device_free_ctx()
66 tls_ctx_free(NULL, ctx); in tls_device_free_ctx()
73 struct tls_context *ctx = offload_ctx->ctx; in tls_device_tx_del_task() local
79 netdev = rcu_dereference_protected(ctx->netdev, in tls_device_tx_del_task()
80 !refcount_read(&ctx->refcount)); in tls_device_tx_del_task()
82 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, TLS_OFFLOAD_CTX_DIR_TX); in tls_device_tx_del_task()
84 ctx->netdev = NULL; in tls_device_tx_del_task()
85 tls_device_free_ctx(ctx); in tls_device_tx_del_task()
88 static void tls_device_queue_ctx_destruction(struct tls_context *ctx) in tls_device_queue_ctx_destruction() argument
95 if (unlikely(!refcount_dec_and_test(&ctx->refcount))) { in tls_device_queue_ctx_destruction()
100 list_del(&ctx->list); /* Remove from tls_device_list / tls_device_down_list */ in tls_device_queue_ctx_destruction()
105 netdev = rcu_dereference_protected(ctx->netdev, in tls_device_queue_ctx_destruction()
106 !refcount_read(&ctx->refcount)); in tls_device_queue_ctx_destruction()
108 async_cleanup = netdev && ctx->tx_conf == TLS_HW; in tls_device_queue_ctx_destruction()
110 struct tls_offload_context_tx *offload_ctx = tls_offload_ctx_tx(ctx); in tls_device_queue_ctx_destruction()
120 tls_device_free_ctx(ctx); in tls_device_queue_ctx_destruction()
164 struct tls_offload_context_tx *ctx; in tls_tcp_clean_acked() local
171 ctx = tls_offload_ctx_tx(tls_ctx); in tls_tcp_clean_acked()
173 spin_lock_irqsave(&ctx->lock, flags); in tls_tcp_clean_acked()
174 info = ctx->retransmit_hint; in tls_tcp_clean_acked()
176 ctx->retransmit_hint = NULL; in tls_tcp_clean_acked()
178 list_for_each_entry_safe(info, temp, &ctx->records_list, list) { in tls_tcp_clean_acked()
187 ctx->unacked_record_sn += deleted_records; in tls_tcp_clean_acked()
188 spin_unlock_irqrestore(&ctx->lock, flags); in tls_tcp_clean_acked()
198 struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); in tls_device_sk_destruct() local
203 if (ctx->open_record) in tls_device_sk_destruct()
204 destroy_record(ctx->open_record); in tls_device_sk_destruct()
205 delete_all_records(ctx); in tls_device_sk_destruct()
206 crypto_free_aead(ctx->aead_send); in tls_device_sk_destruct()
278 struct tls_context *ctx, in tls_push_record() argument
283 struct tls_prot_info *prot = &ctx->prot_info; in tls_push_record()
292 if (test_bit(TLS_TX_SYNC_SCHED, &ctx->flags)) in tls_push_record()
293 tls_device_resync_tx(sk, ctx, tp->write_seq); in tls_push_record()
295 tls_advance_record_sn(sk, prot, &ctx->tx); in tls_push_record()
308 return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags); in tls_push_record()
312 struct tls_context *ctx, in tls_device_record_close() argument
317 struct tls_prot_info *prot = &ctx->prot_info; in tls_device_record_close()
335 tls_fill_prepend(ctx, skb_frag_address(&record->frags[0]), in tls_device_record_close()
425 struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); in tls_push_data() local
465 rc = tls_do_allocation(sk, ctx, pfrag, prot->prepend_size); in tls_push_data()
471 record = ctx->open_record; in tls_push_data()
482 ctx->open_record = NULL; in tls_push_data()
490 record = ctx->open_record; in tls_push_data()
546 ctx, in tls_push_data()
678 void tls_device_write_space(struct sock *sk, struct tls_context *ctx) in tls_device_write_space() argument
680 if (tls_is_partially_sent_record(ctx)) { in tls_device_write_space()
686 tls_push_partial_record(sk, ctx, in tls_device_write_space()
831 struct tls_offload_context_rx *ctx, in tls_device_core_ctrl_rx_resync() argument
837 if (ctx->resync_type != TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT) in tls_device_core_ctrl_rx_resync()
840 if (ctx->resync_nh_do_now) in tls_device_core_ctrl_rx_resync()
843 if (ctx->resync_nh_reset) { in tls_device_core_ctrl_rx_resync()
844 ctx->resync_nh_reset = 0; in tls_device_core_ctrl_rx_resync()
845 ctx->resync_nh.decrypted_failed = 1; in tls_device_core_ctrl_rx_resync()
846 ctx->resync_nh.decrypted_tgt = TLS_DEVICE_RESYNC_NH_START_IVAL; in tls_device_core_ctrl_rx_resync()
850 if (++ctx->resync_nh.decrypted_failed <= ctx->resync_nh.decrypted_tgt) in tls_device_core_ctrl_rx_resync()
854 if (ctx->resync_nh.decrypted_tgt < TLS_DEVICE_RESYNC_NH_MAX_IVAL) in tls_device_core_ctrl_rx_resync()
855 ctx->resync_nh.decrypted_tgt *= 2; in tls_device_core_ctrl_rx_resync()
857 ctx->resync_nh.decrypted_tgt += TLS_DEVICE_RESYNC_NH_MAX_IVAL; in tls_device_core_ctrl_rx_resync()
864 ctx->resync_nh_do_now = 1; in tls_device_core_ctrl_rx_resync()
971 struct tls_offload_context_rx *ctx = tls_offload_ctx_rx(tls_ctx); in tls_device_decrypted() local
1005 ctx->resync_nh_reset = 1; in tls_device_decrypted()
1009 tls_device_core_ctrl_rx_resync(tls_ctx, ctx, sk, skb); in tls_device_decrypted()
1013 ctx->resync_nh_reset = 1; in tls_device_decrypted()
1017 static void tls_device_attach(struct tls_context *ctx, struct sock *sk, in tls_device_attach() argument
1021 refcount_set(&ctx->refcount, 1); in tls_device_attach()
1023 RCU_INIT_POINTER(ctx->netdev, netdev); in tls_device_attach()
1025 list_add_tail(&ctx->list, &tls_device_list); in tls_device_attach()
1028 ctx->sk_destruct = sk->sk_destruct; in tls_device_attach()
1033 static struct tls_offload_context_tx *alloc_offload_ctx_tx(struct tls_context *ctx) in alloc_offload_ctx_tx() argument
1049 memcpy(&rcd_sn, ctx->tx.rec_seq, sizeof(rcd_sn)); in alloc_offload_ctx_tx()
1052 offload_ctx->ctx = ctx; in alloc_offload_ctx_tx()
1065 struct tls_context *ctx; in tls_set_device_offload() local
1069 ctx = tls_get_ctx(sk); in tls_set_device_offload()
1070 prot = &ctx->prot_info; in tls_set_device_offload()
1072 if (ctx->priv_ctx_tx) in tls_set_device_offload()
1086 crypto_info = &ctx->crypto_send.info; in tls_set_device_offload()
1105 memcpy(ctx->tx.iv + cipher_desc->salt, iv, cipher_desc->iv); in tls_set_device_offload()
1106 memcpy(ctx->tx.rec_seq, rec_seq, cipher_desc->rec_seq); in tls_set_device_offload()
1114 offload_ctx = alloc_offload_ctx_tx(ctx); in tls_set_device_offload()
1130 ctx->push_pending_record = tls_device_push_pending_record; in tls_set_device_offload()
1152 ctx->priv_ctx_tx = offload_ctx; in tls_set_device_offload()
1154 &ctx->crypto_send.info, in tls_set_device_offload()
1161 tls_device_attach(ctx, sk, netdev); in tls_set_device_offload()
1179 ctx->priv_ctx_tx = NULL; in tls_set_device_offload()
1187 int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx) in tls_set_device_offload_rx() argument
1194 if (ctx->crypto_recv.info.version != TLS_1_2_VERSION) in tls_set_device_offload_rx()
1229 ctx->priv_ctx_rx = context; in tls_set_device_offload_rx()
1235 &ctx->crypto_recv.info, in tls_set_device_offload_rx()
1237 info = (void *)&ctx->crypto_recv.info; in tls_set_device_offload_rx()
1243 tls_device_attach(ctx, sk, netdev); in tls_set_device_offload_rx()
1255 ctx->priv_ctx_rx = NULL; in tls_set_device_offload_rx()
1290 struct tls_context *ctx, *tmp; in tls_device_down() local
1298 list_for_each_entry_safe(ctx, tmp, &tls_device_list, list) { in tls_device_down()
1300 rcu_dereference_protected(ctx->netdev, in tls_device_down()
1304 !refcount_inc_not_zero(&ctx->refcount)) in tls_device_down()
1307 list_move(&ctx->list, &list); in tls_device_down()
1311 list_for_each_entry_safe(ctx, tmp, &list, list) { in tls_device_down()
1315 WRITE_ONCE(ctx->sk->sk_validate_xmit_skb, tls_validate_xmit_skb_sw); in tls_device_down()
1320 rcu_assign_pointer(ctx->netdev, NULL); in tls_device_down()
1323 set_bit(TLS_RX_DEV_DEGRADED, &ctx->flags); in tls_device_down()
1332 if (ctx->tx_conf == TLS_HW) in tls_device_down()
1333 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_down()
1335 if (ctx->rx_conf == TLS_HW && in tls_device_down()
1336 !test_bit(TLS_RX_DEV_CLOSED, &ctx->flags)) in tls_device_down()
1337 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_down()
1348 list_move_tail(&ctx->list, &tls_device_down_list); in tls_device_down()
1355 if (refcount_dec_and_test(&ctx->refcount)) { in tls_device_down()
1359 list_del(&ctx->list); in tls_device_down()
1360 tls_device_free_ctx(ctx); in tls_device_down()