Lines Matching +full:record +full:- +full:size

13  *      - Redistributions of source code must retain the above
17 * - Redistributions in binary form must reproduce the above
60 if (ctx->tx_conf == TLS_HW) in tls_device_free_ctx()
63 if (ctx->rx_conf == TLS_HW) in tls_device_free_ctx()
73 struct tls_context *ctx = offload_ctx->ctx; in tls_device_tx_del_task()
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()
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()
115 queue_work(destruct_wq, &offload_ctx->destruct_work); in tls_device_queue_ctx_destruction()
130 netdev = netdev_sk_get_lowest_dev(dst->dev, sk); in get_netdev_for_sock()
139 static void destroy_record(struct tls_record_info *record) in destroy_record() argument
143 for (i = 0; i < record->num_frags; i++) in destroy_record()
144 __skb_frag_unref(&record->frags[i], false); in destroy_record()
145 kfree(record); in destroy_record()
152 list_for_each_entry_safe(info, temp, &offload_ctx->records_list, list) { in delete_all_records()
153 list_del(&info->list); in delete_all_records()
157 offload_ctx->retransmit_hint = NULL; in delete_all_records()
173 spin_lock_irqsave(&ctx->lock, flags); in tls_tcp_clean_acked()
174 info = ctx->retransmit_hint; in tls_tcp_clean_acked()
175 if (info && !before(acked_seq, info->end_seq)) 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()
179 if (before(acked_seq, info->end_seq)) in tls_tcp_clean_acked()
181 list_del(&info->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()
192 * socket and no in-flight SKBs associated with this
200 tls_ctx->sk_destruct(sk); in tls_device_sk_destruct()
202 if (tls_ctx->tx_conf == TLS_HW) { in tls_device_sk_destruct()
203 if (ctx->open_record) in tls_device_sk_destruct()
204 destroy_record(ctx->open_record); in tls_device_sk_destruct()
206 crypto_free_aead(ctx->aead_send); in tls_device_sk_destruct()
226 WARN_ON(test_and_set_bit(TLS_TX_SYNC_SCHED, &tls_ctx->flags)); in tls_offload_tx_resync_request()
238 rcd_sn = tls_ctx->tx.rec_seq; in tls_device_resync_tx()
242 netdev = rcu_dereference_protected(tls_ctx->netdev, in tls_device_resync_tx()
245 err = netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, in tls_device_resync_tx()
252 clear_bit_unlock(TLS_TX_SYNC_SCHED, &tls_ctx->flags); in tls_device_resync_tx()
255 static void tls_append_frag(struct tls_record_info *record, in tls_append_frag() argument
257 int size) in tls_append_frag() argument
261 frag = &record->frags[record->num_frags - 1]; in tls_append_frag()
262 if (skb_frag_page(frag) == pfrag->page && in tls_append_frag()
263 skb_frag_off(frag) + skb_frag_size(frag) == pfrag->offset) { in tls_append_frag()
264 skb_frag_size_add(frag, size); in tls_append_frag()
267 skb_frag_fill_page_desc(frag, pfrag->page, pfrag->offset, in tls_append_frag()
268 size); in tls_append_frag()
269 ++record->num_frags; in tls_append_frag()
270 get_page(pfrag->page); in tls_append_frag()
273 pfrag->offset += size; in tls_append_frag()
274 record->len += size; in tls_append_frag()
280 struct tls_record_info *record, in tls_push_record() argument
283 struct tls_prot_info *prot = &ctx->prot_info; in tls_push_record()
288 record->end_seq = tp->write_seq + record->len; in tls_push_record()
289 list_add_tail_rcu(&record->list, &offload_ctx->records_list); in tls_push_record()
290 offload_ctx->open_record = NULL; 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()
297 for (i = 0; i < record->num_frags; i++) { in tls_push_record()
298 frag = &record->frags[i]; in tls_push_record()
299 sg_unmark_end(&offload_ctx->sg_tx_data[i]); in tls_push_record()
300 sg_set_page(&offload_ctx->sg_tx_data[i], skb_frag_page(frag), in tls_push_record()
305 sg_mark_end(&offload_ctx->sg_tx_data[record->num_frags - 1]); in tls_push_record()
308 return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags); in tls_push_record()
313 struct tls_record_info *record, in tls_device_record_close() argument
317 struct tls_prot_info *prot = &ctx->prot_info; in tls_device_record_close()
322 * use socket memory to improve coalescing (re-using a single buffer in tls_device_record_close()
326 if (unlikely(pfrag->size - pfrag->offset < prot->tag_size) && in tls_device_record_close()
327 !skb_page_frag_refill(prot->tag_size, pfrag, sk->sk_allocation)) { in tls_device_record_close()
332 tls_append_frag(record, pfrag, prot->tag_size); in tls_device_record_close()
335 tls_fill_prepend(ctx, skb_frag_address(&record->frags[0]), in tls_device_record_close()
336 record->len - prot->overhead_size, in tls_device_record_close()
344 struct tls_record_info *record; in tls_create_new_record() local
347 record = kmalloc(sizeof(*record), GFP_KERNEL); in tls_create_new_record()
348 if (!record) in tls_create_new_record()
349 return -ENOMEM; in tls_create_new_record()
351 frag = &record->frags[0]; in tls_create_new_record()
352 skb_frag_fill_page_desc(frag, pfrag->page, pfrag->offset, in tls_create_new_record()
355 get_page(pfrag->page); in tls_create_new_record()
356 pfrag->offset += prepend_size; in tls_create_new_record()
358 record->num_frags = 1; in tls_create_new_record()
359 record->len = prepend_size; in tls_create_new_record()
360 offload_ctx->open_record = record; in tls_create_new_record()
371 if (!offload_ctx->open_record) { in tls_do_allocation()
373 sk->sk_allocation))) { in tls_do_allocation()
374 READ_ONCE(sk->sk_prot)->enter_memory_pressure(sk); in tls_do_allocation()
376 return -ENOMEM; in tls_do_allocation()
383 if (pfrag->size > pfrag->offset) in tls_do_allocation()
388 return -ENOMEM; in tls_do_allocation()
397 pre_copy = ~((unsigned long)addr - 1) & (SMP_CACHE_BYTES - 1); in tls_device_copy_data()
401 return -EFAULT; in tls_device_copy_data()
402 bytes -= pre_copy; in tls_device_copy_data()
408 return -EFAULT; in tls_device_copy_data()
409 bytes -= nocache; in tls_device_copy_data()
413 return -EFAULT; in tls_device_copy_data()
420 size_t size, int flags, in tls_push_data() argument
424 struct tls_prot_info *prot = &tls_ctx->prot_info; in tls_push_data()
426 struct tls_record_info *record; in tls_push_data() local
429 size_t orig_size = size; in tls_push_data()
439 return -EOPNOTSUPP; in tls_push_data()
442 return -EINVAL; in tls_push_data()
444 if (unlikely(sk->sk_err)) in tls_push_data()
445 return -sk->sk_err; in tls_push_data()
459 /* TLS_HEADER_SIZE is not counted as part of the TLS record, and in tls_push_data()
463 prot->prepend_size; in tls_push_data()
465 rc = tls_do_allocation(sk, ctx, pfrag, prot->prepend_size); in tls_push_data()
471 record = ctx->open_record; in tls_push_data()
472 if (!record) in tls_push_data()
477 * record with type != in tls_push_data()
480 size = orig_size; in tls_push_data()
481 destroy_record(record); in tls_push_data()
482 ctx->open_record = NULL; in tls_push_data()
483 } else if (record->len > prot->prepend_size) { in tls_push_data()
490 record = ctx->open_record; in tls_push_data()
492 copy = min_t(size_t, size, max_open_record_len - record->len); in tls_push_data()
502 rc = -EIO; in tls_push_data()
509 rc = -EIO; in tls_push_data()
514 zc_pfrag.size = copy; in tls_push_data()
515 tls_append_frag(record, &zc_pfrag, copy); in tls_push_data()
517 copy = min_t(size_t, copy, pfrag->size - pfrag->offset); in tls_push_data()
519 rc = tls_device_copy_data(page_address(pfrag->page) + in tls_push_data()
520 pfrag->offset, copy, in tls_push_data()
524 tls_append_frag(record, pfrag, copy); in tls_push_data()
527 size -= copy; in tls_push_data()
528 if (!size) { in tls_push_data()
539 if (done || record->len >= max_open_record_len || in tls_push_data()
540 (record->num_frags >= MAX_SKB_FRAGS - 1)) { in tls_push_data()
541 tls_device_record_close(sk, tls_ctx, record, in tls_push_data()
547 record, in tls_push_data()
554 tls_ctx->pending_open_record_frags = more; in tls_push_data()
556 if (orig_size - size > 0) in tls_push_data()
557 rc = orig_size - size; in tls_push_data()
562 int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) in tls_device_sendmsg() argument
568 if (!tls_ctx->zerocopy_sendfile) in tls_device_sendmsg()
569 msg->msg_flags &= ~MSG_SPLICE_PAGES; in tls_device_sendmsg()
571 mutex_lock(&tls_ctx->tx_lock); in tls_device_sendmsg()
574 if (unlikely(msg->msg_controllen)) { in tls_device_sendmsg()
580 rc = tls_push_data(sk, &msg->msg_iter, size, msg->msg_flags, in tls_device_sendmsg()
585 mutex_unlock(&tls_ctx->tx_lock); in tls_device_sendmsg()
591 struct sock *sk = sock->sk; in tls_device_splice_eof()
598 mutex_lock(&tls_ctx->tx_lock); in tls_device_splice_eof()
607 mutex_unlock(&tls_ctx->tx_lock); in tls_device_splice_eof()
613 u64 record_sn = context->hint_record_sn; in tls_get_record()
616 info = context->retransmit_hint; in tls_get_record()
618 before(seq, info->end_seq - info->len)) { in tls_get_record()
622 info = list_first_entry_or_null(&context->records_list, in tls_get_record()
626 /* send the start_marker record if seq number is before the in tls_get_record()
627 * tls offload start marker sequence number. This record is in tls_get_record()
634 /* we have the first record, get the last record to see in tls_get_record()
637 last = list_last_entry(&context->records_list, in tls_get_record()
641 last->end_seq)) in tls_get_record()
644 record_sn = context->unacked_record_sn; in tls_get_record()
649 list_for_each_entry_from_rcu(info, &context->records_list, list) { in tls_get_record()
650 if (before(seq, info->end_seq)) { in tls_get_record()
651 if (!context->retransmit_hint || in tls_get_record()
652 after(info->end_seq, in tls_get_record()
653 context->retransmit_hint->end_seq)) { in tls_get_record()
654 context->hint_record_sn = record_sn; in tls_get_record()
655 context->retransmit_hint = info; in tls_get_record()
681 gfp_t sk_allocation = sk->sk_allocation; in tls_device_write_space()
683 WARN_ON_ONCE(sk->sk_write_pending); in tls_device_write_space()
685 sk->sk_allocation = GFP_ATOMIC; in tls_device_write_space()
689 sk->sk_allocation = sk_allocation; in tls_device_write_space()
699 trace_tls_device_rx_resync_send(sk, seq, rcd_sn, rx_ctx->resync_type); in tls_device_resync_rx()
701 netdev = rcu_dereference(tls_ctx->netdev); in tls_device_resync_rx()
703 netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, rcd_sn, in tls_device_resync_rx()
724 if (WARN_ON_ONCE(resync_async->rcd_delta == USHRT_MAX)) in tls_device_rx_resync_async()
733 resync_async->loglen < TLS_DEVICE_RESYNC_ASYNC_LOGMAX) in tls_device_rx_resync_async()
734 resync_async->log[resync_async->loglen++] = *seq; in tls_device_rx_resync_async()
736 resync_async->rcd_delta++; in tls_device_rx_resync_async()
744 for (i = 0; i < resync_async->loglen; i++) in tls_device_rx_resync_async()
745 if (req_seq == resync_async->log[i] && in tls_device_rx_resync_async()
746 atomic64_try_cmpxchg(&resync_async->req, &resync_req, 0)) { in tls_device_rx_resync_async()
747 *rcd_delta = resync_async->rcd_delta - i; in tls_device_rx_resync_async()
749 resync_async->loglen = 0; in tls_device_rx_resync_async()
750 resync_async->rcd_delta = 0; in tls_device_rx_resync_async()
754 resync_async->loglen = 0; in tls_device_rx_resync_async()
755 resync_async->rcd_delta = 0; in tls_device_rx_resync_async()
758 atomic64_try_cmpxchg(&resync_async->req, in tls_device_rx_resync_async()
776 if (tls_ctx->rx_conf != TLS_HW) in tls_device_rx_resync_new_rec()
778 if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) in tls_device_rx_resync_new_rec()
781 prot = &tls_ctx->prot_info; in tls_device_rx_resync_new_rec()
783 memcpy(rcd_sn, tls_ctx->rx.rec_seq, prot->rec_seq_size); in tls_device_rx_resync_new_rec()
785 switch (rx_ctx->resync_type) { in tls_device_rx_resync_new_rec()
787 resync_req = atomic64_read(&rx_ctx->resync_req); in tls_device_rx_resync_new_rec()
789 seq += TLS_HEADER_SIZE - 1; in tls_device_rx_resync_new_rec()
793 !atomic64_try_cmpxchg(&rx_ctx->resync_req, &resync_req, 0)) in tls_device_rx_resync_new_rec()
797 if (likely(!rx_ctx->resync_nh_do_now)) in tls_device_rx_resync_new_rec()
810 rx_ctx->resync_nh_do_now = 0; in tls_device_rx_resync_new_rec()
812 tls_bigint_increment(rcd_sn, prot->rec_seq_size); in tls_device_rx_resync_new_rec()
815 resync_req = atomic64_read(&rx_ctx->resync_async->req); in tls_device_rx_resync_new_rec()
820 if (!tls_device_rx_resync_async(rx_ctx->resync_async, in tls_device_rx_resync_new_rec()
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()
842 /* seen decrypted fragments since last fully-failed record */ 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()
862 if (tcp_inq(sk) > rxm->full_len) { in tls_device_core_ctrl_rx_resync()
864 ctx->resync_nh_do_now = 1; in tls_device_core_ctrl_rx_resync()
866 struct tls_prot_info *prot = &tls_ctx->prot_info; in tls_device_core_ctrl_rx_resync()
869 memcpy(rcd_sn, tls_ctx->rx.rec_seq, prot->rec_seq_size); in tls_device_core_ctrl_rx_resync()
870 tls_bigint_increment(rcd_sn, prot->rec_seq_size); in tls_device_core_ctrl_rx_resync()
872 tls_device_resync_rx(tls_ctx, sk, tcp_sk(sk)->copied_seq, in tls_device_core_ctrl_rx_resync()
888 cipher_desc = get_cipher_desc(tls_ctx->crypto_recv.info.cipher_type); in tls_device_reencrypt()
889 DEBUG_NET_WARN_ON_ONCE(!cipher_desc || !cipher_desc->offloadable); in tls_device_reencrypt()
892 orig_buf = kmalloc(rxm->full_len + TLS_HEADER_SIZE + cipher_desc->iv, in tls_device_reencrypt()
893 sk->sk_allocation); in tls_device_reencrypt()
895 return -ENOMEM; in tls_device_reencrypt()
904 offset = rxm->offset; in tls_device_reencrypt()
908 rxm->full_len + TLS_HEADER_SIZE + cipher_desc->iv); in tls_device_reencrypt()
909 err = skb_copy_bits(skb, offset, buf, TLS_HEADER_SIZE + cipher_desc->iv); in tls_device_reencrypt()
915 if (err != -EBADMSG) in tls_device_reencrypt()
920 data_len = rxm->full_len - cipher_desc->tag; in tls_device_reencrypt()
923 copy = min_t(int, skb_pagelen(skb) - offset, data_len); in tls_device_reencrypt()
925 if (skb->decrypted) { in tls_device_reencrypt()
943 if (pos + skb_iter->len <= offset) in tls_device_reencrypt()
945 if (pos >= data_len + rxm->offset) in tls_device_reencrypt()
948 frag_pos = offset - pos; in tls_device_reencrypt()
949 copy = min_t(int, skb_iter->len - frag_pos, in tls_device_reencrypt()
950 data_len + rxm->offset - offset); in tls_device_reencrypt()
952 if (skb_iter->decrypted) { in tls_device_reencrypt()
961 pos += skb_iter->len; in tls_device_reencrypt()
978 is_decrypted = skb->decrypted; in tls_device_decrypted()
985 trace_tls_device_decrypted(sk, tcp_sk(sk)->copied_seq - rxm->full_len, in tls_device_decrypted()
986 tls_ctx->rx.rec_seq, rxm->full_len, in tls_device_decrypted()
989 if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) { in tls_device_decrypted()
1000 /* Return immediately if the record is either entirely plaintext or in tls_device_decrypted()
1002 * record. in tls_device_decrypted()
1005 ctx->resync_nh_reset = 1; in tls_device_decrypted()
1013 ctx->resync_nh_reset = 1; in tls_device_decrypted()
1020 if (sk->sk_destruct != tls_device_sk_destruct) { in tls_device_attach()
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()
1029 smp_store_release(&sk->sk_destruct, tls_device_sk_destruct); in tls_device_attach()
1042 INIT_WORK(&offload_ctx->destruct_work, tls_device_tx_del_task); in alloc_offload_ctx_tx()
1043 INIT_LIST_HEAD(&offload_ctx->records_list); in alloc_offload_ctx_tx()
1044 spin_lock_init(&offload_ctx->lock); in alloc_offload_ctx_tx()
1045 sg_init_table(offload_ctx->sg_tx_data, in alloc_offload_ctx_tx()
1046 ARRAY_SIZE(offload_ctx->sg_tx_data)); in alloc_offload_ctx_tx()
1048 /* start at rec_seq - 1 to account for the start marker record */ in alloc_offload_ctx_tx()
1049 memcpy(&rcd_sn, ctx->tx.rec_seq, sizeof(rcd_sn)); in alloc_offload_ctx_tx()
1050 offload_ctx->unacked_record_sn = be64_to_cpu(rcd_sn) - 1; in alloc_offload_ctx_tx()
1052 offload_ctx->ctx = ctx; in alloc_offload_ctx_tx()
1070 prot = &ctx->prot_info; in tls_set_device_offload()
1072 if (ctx->priv_ctx_tx) in tls_set_device_offload()
1073 return -EEXIST; in tls_set_device_offload()
1078 return -EINVAL; in tls_set_device_offload()
1081 if (!(netdev->features & NETIF_F_HW_TLS_TX)) { in tls_set_device_offload()
1082 rc = -EOPNOTSUPP; in tls_set_device_offload()
1086 crypto_info = &ctx->crypto_send.info; in tls_set_device_offload()
1087 if (crypto_info->version != TLS_1_2_VERSION) { in tls_set_device_offload()
1088 rc = -EOPNOTSUPP; in tls_set_device_offload()
1092 cipher_desc = get_cipher_desc(crypto_info->cipher_type); in tls_set_device_offload()
1093 if (!cipher_desc || !cipher_desc->offloadable) { in tls_set_device_offload()
1094 rc = -EINVAL; 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()
1110 rc = -ENOMEM; in tls_set_device_offload()
1116 rc = -ENOMEM; in tls_set_device_offload()
1124 start_marker_record->end_seq = tcp_sk(sk)->write_seq; in tls_set_device_offload()
1125 start_marker_record->len = 0; in tls_set_device_offload()
1126 start_marker_record->num_frags = 0; in tls_set_device_offload()
1127 list_add_tail(&start_marker_record->list, &offload_ctx->records_list); in tls_set_device_offload()
1130 ctx->push_pending_record = tls_device_push_pending_record; in tls_set_device_offload()
1134 * So mark the last skb in the write queue as end of record. in tls_set_device_offload()
1147 if (!(netdev->flags & IFF_UP)) { in tls_set_device_offload()
1148 rc = -EINVAL; in tls_set_device_offload()
1152 ctx->priv_ctx_tx = offload_ctx; in tls_set_device_offload()
1153 rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_TX, in tls_set_device_offload()
1154 &ctx->crypto_send.info, in tls_set_device_offload()
1155 tcp_sk(sk)->write_seq); in tls_set_device_offload()
1157 tcp_sk(sk)->write_seq, rec_seq, rc); in tls_set_device_offload()
1168 smp_store_release(&sk->sk_validate_xmit_skb, tls_validate_xmit_skb); in tls_set_device_offload()
1176 crypto_free_aead(offload_ctx->aead_send); in tls_set_device_offload()
1179 ctx->priv_ctx_tx = NULL; in tls_set_device_offload()
1194 if (ctx->crypto_recv.info.version != TLS_1_2_VERSION) in tls_set_device_offload_rx()
1195 return -EOPNOTSUPP; in tls_set_device_offload_rx()
1200 return -EINVAL; in tls_set_device_offload_rx()
1203 if (!(netdev->features & NETIF_F_HW_TLS_RX)) { in tls_set_device_offload_rx()
1204 rc = -EOPNOTSUPP; in tls_set_device_offload_rx()
1217 if (!(netdev->flags & IFF_UP)) { in tls_set_device_offload_rx()
1218 rc = -EINVAL; in tls_set_device_offload_rx()
1224 rc = -ENOMEM; in tls_set_device_offload_rx()
1227 context->resync_nh_reset = 1; in tls_set_device_offload_rx()
1229 ctx->priv_ctx_rx = context; in tls_set_device_offload_rx()
1234 rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_RX, in tls_set_device_offload_rx()
1235 &ctx->crypto_recv.info, in tls_set_device_offload_rx()
1236 tcp_sk(sk)->copied_seq); in tls_set_device_offload_rx()
1237 info = (void *)&ctx->crypto_recv.info; in tls_set_device_offload_rx()
1239 tcp_sk(sk)->copied_seq, info->rec_seq, rc); in tls_set_device_offload_rx()
1255 ctx->priv_ctx_rx = NULL; in tls_set_device_offload_rx()
1269 netdev = rcu_dereference_protected(tls_ctx->netdev, in tls_device_offload_cleanup_rx()
1274 netdev->tlsdev_ops->tls_dev_del(netdev, tls_ctx, in tls_device_offload_cleanup_rx()
1277 if (tls_ctx->tx_conf != TLS_HW) { in tls_device_offload_cleanup_rx()
1279 rcu_assign_pointer(tls_ctx->netdev, NULL); in tls_device_offload_cleanup_rx()
1281 set_bit(TLS_RX_DEV_CLOSED, &tls_ctx->flags); in tls_device_offload_cleanup_rx()
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()
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()
1326 * TX: no non-encrypted packets will be passed to the driver. 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()
1345 * run offload-specific code on this context. 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()
1376 if (!dev->tlsdev_ops && in tls_dev_event()
1377 !(dev->features & (NETIF_F_HW_TLS_RX | NETIF_F_HW_TLS_TX))) in tls_dev_event()
1385 if ((dev->features & NETIF_F_HW_TLS_RX) && in tls_dev_event()
1386 !dev->tlsdev_ops->tls_dev_resync) in tls_dev_event()
1389 if (dev->tlsdev_ops && in tls_dev_event()
1390 dev->tlsdev_ops->tls_dev_add && in tls_dev_event()
1391 dev->tlsdev_ops->tls_dev_del) in tls_dev_event()
1411 return -ENOMEM; in tls_device_init()
1415 err = -ENOMEM; in tls_device_init()