Lines Matching refs:ctx
57 static void tls_device_free_ctx(struct tls_context *ctx) in tls_device_free_ctx() argument
59 if (ctx->tx_conf == TLS_HW) { in tls_device_free_ctx()
60 kfree(tls_offload_ctx_tx(ctx)); in tls_device_free_ctx()
61 kfree(ctx->tx.rec_seq); in tls_device_free_ctx()
62 kfree(ctx->tx.iv); in tls_device_free_ctx()
65 if (ctx->rx_conf == TLS_HW) in tls_device_free_ctx()
66 kfree(tls_offload_ctx_rx(ctx)); in tls_device_free_ctx()
68 tls_ctx_free(NULL, ctx); in tls_device_free_ctx()
75 struct tls_context *ctx = offload_ctx->ctx; in tls_device_tx_del_task() local
81 netdev = rcu_dereference_protected(ctx->netdev, in tls_device_tx_del_task()
82 !refcount_read(&ctx->refcount)); in tls_device_tx_del_task()
84 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, TLS_OFFLOAD_CTX_DIR_TX); in tls_device_tx_del_task()
86 ctx->netdev = NULL; in tls_device_tx_del_task()
87 tls_device_free_ctx(ctx); in tls_device_tx_del_task()
90 static void tls_device_queue_ctx_destruction(struct tls_context *ctx) in tls_device_queue_ctx_destruction() argument
97 if (unlikely(!refcount_dec_and_test(&ctx->refcount))) { in tls_device_queue_ctx_destruction()
102 list_del(&ctx->list); /* Remove from tls_device_list / tls_device_down_list */ in tls_device_queue_ctx_destruction()
107 netdev = rcu_dereference_protected(ctx->netdev, in tls_device_queue_ctx_destruction()
108 !refcount_read(&ctx->refcount)); in tls_device_queue_ctx_destruction()
110 async_cleanup = netdev && ctx->tx_conf == TLS_HW; in tls_device_queue_ctx_destruction()
112 struct tls_offload_context_tx *offload_ctx = tls_offload_ctx_tx(ctx); in tls_device_queue_ctx_destruction()
122 tls_device_free_ctx(ctx); in tls_device_queue_ctx_destruction()
166 struct tls_offload_context_tx *ctx; in tls_icsk_clean_acked() local
173 ctx = tls_offload_ctx_tx(tls_ctx); in tls_icsk_clean_acked()
175 spin_lock_irqsave(&ctx->lock, flags); in tls_icsk_clean_acked()
176 info = ctx->retransmit_hint; in tls_icsk_clean_acked()
178 ctx->retransmit_hint = NULL; in tls_icsk_clean_acked()
180 list_for_each_entry_safe(info, temp, &ctx->records_list, list) { in tls_icsk_clean_acked()
189 ctx->unacked_record_sn += deleted_records; in tls_icsk_clean_acked()
190 spin_unlock_irqrestore(&ctx->lock, flags); in tls_icsk_clean_acked()
200 struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); in tls_device_sk_destruct() local
205 if (ctx->open_record) in tls_device_sk_destruct()
206 destroy_record(ctx->open_record); in tls_device_sk_destruct()
207 delete_all_records(ctx); in tls_device_sk_destruct()
208 crypto_free_aead(ctx->aead_send); in tls_device_sk_destruct()
284 struct tls_context *ctx, in tls_push_record() argument
289 struct tls_prot_info *prot = &ctx->prot_info; in tls_push_record()
298 if (test_bit(TLS_TX_SYNC_SCHED, &ctx->flags)) in tls_push_record()
299 tls_device_resync_tx(sk, ctx, tp->write_seq); in tls_push_record()
301 tls_advance_record_sn(sk, prot, &ctx->tx); in tls_push_record()
314 return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags); in tls_push_record()
318 struct tls_context *ctx, in tls_device_record_close() argument
323 struct tls_prot_info *prot = &ctx->prot_info; in tls_device_record_close()
341 tls_fill_prepend(ctx, skb_frag_address(&record->frags[0]), in tls_device_record_close()
431 struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); in tls_push_data() local
471 rc = tls_do_allocation(sk, ctx, pfrag, prot->prepend_size); in tls_push_data()
477 record = ctx->open_record; in tls_push_data()
488 ctx->open_record = NULL; in tls_push_data()
496 record = ctx->open_record; in tls_push_data()
552 ctx, in tls_push_data()
684 void tls_device_write_space(struct sock *sk, struct tls_context *ctx) in tls_device_write_space() argument
686 if (tls_is_partially_sent_record(ctx)) { in tls_device_write_space()
692 tls_push_partial_record(sk, ctx, in tls_device_write_space()
837 struct tls_offload_context_rx *ctx, in tls_device_core_ctrl_rx_resync() argument
843 if (ctx->resync_type != TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT) in tls_device_core_ctrl_rx_resync()
846 if (ctx->resync_nh_do_now) in tls_device_core_ctrl_rx_resync()
849 if (ctx->resync_nh_reset) { in tls_device_core_ctrl_rx_resync()
850 ctx->resync_nh_reset = 0; in tls_device_core_ctrl_rx_resync()
851 ctx->resync_nh.decrypted_failed = 1; in tls_device_core_ctrl_rx_resync()
852 ctx->resync_nh.decrypted_tgt = TLS_DEVICE_RESYNC_NH_START_IVAL; in tls_device_core_ctrl_rx_resync()
856 if (++ctx->resync_nh.decrypted_failed <= ctx->resync_nh.decrypted_tgt) in tls_device_core_ctrl_rx_resync()
860 if (ctx->resync_nh.decrypted_tgt < TLS_DEVICE_RESYNC_NH_MAX_IVAL) in tls_device_core_ctrl_rx_resync()
861 ctx->resync_nh.decrypted_tgt *= 2; in tls_device_core_ctrl_rx_resync()
863 ctx->resync_nh.decrypted_tgt += TLS_DEVICE_RESYNC_NH_MAX_IVAL; in tls_device_core_ctrl_rx_resync()
870 ctx->resync_nh_do_now = 1; in tls_device_core_ctrl_rx_resync()
983 struct tls_offload_context_rx *ctx = tls_offload_ctx_rx(tls_ctx); in tls_device_decrypted() local
1017 ctx->resync_nh_reset = 1; in tls_device_decrypted()
1021 tls_device_core_ctrl_rx_resync(tls_ctx, ctx, sk, skb); in tls_device_decrypted()
1025 ctx->resync_nh_reset = 1; in tls_device_decrypted()
1029 static void tls_device_attach(struct tls_context *ctx, struct sock *sk, in tls_device_attach() argument
1033 refcount_set(&ctx->refcount, 1); in tls_device_attach()
1035 RCU_INIT_POINTER(ctx->netdev, netdev); in tls_device_attach()
1037 list_add_tail(&ctx->list, &tls_device_list); in tls_device_attach()
1040 ctx->sk_destruct = sk->sk_destruct; in tls_device_attach()
1045 int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) in tls_set_device_offload() argument
1059 if (!ctx) in tls_set_device_offload()
1062 if (ctx->priv_ctx_tx) in tls_set_device_offload()
1076 crypto_info = &ctx->crypto_send.info; in tls_set_device_offload()
1098 ctx->tx.iv = kmalloc(cipher_desc->iv + cipher_desc->salt, GFP_KERNEL); in tls_set_device_offload()
1099 if (!ctx->tx.iv) { in tls_set_device_offload()
1104 memcpy(ctx->tx.iv + cipher_desc->salt, iv, cipher_desc->iv); in tls_set_device_offload()
1107 ctx->tx.rec_seq = kmemdup(rec_seq, cipher_desc->rec_seq, GFP_KERNEL); in tls_set_device_offload()
1108 if (!ctx->tx.rec_seq) { in tls_set_device_offload()
1130 memcpy(&rcd_sn, ctx->tx.rec_seq, sizeof(rcd_sn)); in tls_set_device_offload()
1138 offload_ctx->ctx = ctx; in tls_set_device_offload()
1147 ctx->push_pending_record = tls_device_push_pending_record; in tls_set_device_offload()
1171 ctx->priv_ctx_tx = offload_ctx; in tls_set_device_offload()
1173 &ctx->crypto_send.info, in tls_set_device_offload()
1180 tls_device_attach(ctx, sk, netdev); in tls_set_device_offload()
1198 ctx->priv_ctx_tx = NULL; in tls_set_device_offload()
1202 kfree(ctx->tx.rec_seq); in tls_set_device_offload()
1204 kfree(ctx->tx.iv); in tls_set_device_offload()
1210 int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx) in tls_set_device_offload_rx() argument
1217 if (ctx->crypto_recv.info.version != TLS_1_2_VERSION) in tls_set_device_offload_rx()
1252 ctx->priv_ctx_rx = context; in tls_set_device_offload_rx()
1253 rc = tls_set_sw_offload(sk, ctx, 0); in tls_set_device_offload_rx()
1258 &ctx->crypto_recv.info, in tls_set_device_offload_rx()
1260 info = (void *)&ctx->crypto_recv.info; in tls_set_device_offload_rx()
1266 tls_device_attach(ctx, sk, netdev); in tls_set_device_offload_rx()
1278 ctx->priv_ctx_rx = NULL; in tls_set_device_offload_rx()
1313 struct tls_context *ctx, *tmp; in tls_device_down() local
1321 list_for_each_entry_safe(ctx, tmp, &tls_device_list, list) { in tls_device_down()
1323 rcu_dereference_protected(ctx->netdev, in tls_device_down()
1327 !refcount_inc_not_zero(&ctx->refcount)) in tls_device_down()
1330 list_move(&ctx->list, &list); in tls_device_down()
1334 list_for_each_entry_safe(ctx, tmp, &list, list) { in tls_device_down()
1338 WRITE_ONCE(ctx->sk->sk_validate_xmit_skb, tls_validate_xmit_skb_sw); in tls_device_down()
1343 rcu_assign_pointer(ctx->netdev, NULL); in tls_device_down()
1346 set_bit(TLS_RX_DEV_DEGRADED, &ctx->flags); in tls_device_down()
1355 if (ctx->tx_conf == TLS_HW) in tls_device_down()
1356 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_down()
1358 if (ctx->rx_conf == TLS_HW && in tls_device_down()
1359 !test_bit(TLS_RX_DEV_CLOSED, &ctx->flags)) in tls_device_down()
1360 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, in tls_device_down()
1371 list_move_tail(&ctx->list, &tls_device_down_list); in tls_device_down()
1378 if (refcount_dec_and_test(&ctx->refcount)) { in tls_device_down()
1382 list_del(&ctx->list); in tls_device_down()
1383 tls_device_free_ctx(ctx); in tls_device_down()