Lines Matching refs:nn

31 static void nfp_net_crypto_set_op(struct nfp_net *nn, u8 opcode, bool on)  in nfp_net_crypto_set_op()  argument
35 off = nn->tlv_caps.crypto_enable_off + round_down(opcode / 8, 4); in nfp_net_crypto_set_op()
37 val = nn_readl(nn, off); in nfp_net_crypto_set_op()
42 nn_writel(nn, off, val); in nfp_net_crypto_set_op()
46 __nfp_net_tls_conn_cnt_changed(struct nfp_net *nn, int add, in __nfp_net_tls_conn_cnt_changed() argument
54 nn->ktls_tx_conn_cnt += add; in __nfp_net_tls_conn_cnt_changed()
55 cnt = nn->ktls_tx_conn_cnt; in __nfp_net_tls_conn_cnt_changed()
56 nn->dp.ktls_tx = !!nn->ktls_tx_conn_cnt; in __nfp_net_tls_conn_cnt_changed()
59 nn->ktls_rx_conn_cnt += add; in __nfp_net_tls_conn_cnt_changed()
60 cnt = nn->ktls_rx_conn_cnt; in __nfp_net_tls_conn_cnt_changed()
67 nfp_net_crypto_set_op(nn, opcode, cnt); in __nfp_net_tls_conn_cnt_changed()
72 nfp_net_tls_conn_cnt_changed(struct nfp_net *nn, int add, in nfp_net_tls_conn_cnt_changed() argument
78 nn_ctrl_bar_lock(nn); in nfp_net_tls_conn_cnt_changed()
79 if (__nfp_net_tls_conn_cnt_changed(nn, add, direction)) { in nfp_net_tls_conn_cnt_changed()
80 ret = __nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_CRYPTO); in nfp_net_tls_conn_cnt_changed()
83 __nfp_net_tls_conn_cnt_changed(nn, -add, direction); in nfp_net_tls_conn_cnt_changed()
85 nn_ctrl_bar_unlock(nn); in nfp_net_tls_conn_cnt_changed()
91 nfp_net_tls_conn_add(struct nfp_net *nn, enum tls_offload_ctx_dir direction) in nfp_net_tls_conn_add() argument
93 return nfp_net_tls_conn_cnt_changed(nn, 1, direction); in nfp_net_tls_conn_add()
97 nfp_net_tls_conn_remove(struct nfp_net *nn, enum tls_offload_ctx_dir direction) in nfp_net_tls_conn_remove() argument
99 return nfp_net_tls_conn_cnt_changed(nn, -1, direction); in nfp_net_tls_conn_remove()
103 nfp_net_tls_alloc_simple(struct nfp_net *nn, size_t req_sz, gfp_t flags) in nfp_net_tls_alloc_simple() argument
105 return nfp_ccm_mbox_msg_alloc(nn, req_sz, in nfp_net_tls_alloc_simple()
111 nfp_net_tls_communicate_simple(struct nfp_net *nn, struct sk_buff *skb, in nfp_net_tls_communicate_simple() argument
117 err = __nfp_ccm_mbox_communicate(nn, skb, type, in nfp_net_tls_communicate_simple()
121 nn_dp_warn(&nn->dp, "failed to %s TLS: %d\n", name, err); in nfp_net_tls_communicate_simple()
128 nn_dp_warn(&nn->dp, "failed to %s TLS, fw replied: %d\n", in nfp_net_tls_communicate_simple()
135 static void nfp_net_tls_del_fw(struct nfp_net *nn, __be32 *fw_handle) in nfp_net_tls_del_fw() argument
140 skb = nfp_net_tls_alloc_simple(nn, sizeof(*req), GFP_KERNEL); in nfp_net_tls_del_fw()
148 nfp_net_tls_communicate_simple(nn, skb, "delete", in nfp_net_tls_del_fw()
161 nfp_net_tls_assign_conn_id(struct nfp_net *nn, in nfp_net_tls_assign_conn_id() argument
167 id = atomic64_inc_return(&nn->ktls_conn_id_gen); in nfp_net_tls_assign_conn_id()
175 nfp_net_tls_set_ipv4(struct nfp_net *nn, struct nfp_crypto_req_add_v4 *req, in nfp_net_tls_set_ipv4() argument
183 nfp_net_tls_assign_conn_id(nn, &req->front); in nfp_net_tls_set_ipv4()
193 nfp_net_tls_set_ipv6(struct nfp_net *nn, struct nfp_crypto_req_add_v6 *req, in nfp_net_tls_set_ipv6() argument
202 nfp_net_tls_assign_conn_id(nn, &req->front); in nfp_net_tls_set_ipv6()
244 nfp_net_cipher_supported(struct nfp_net *nn, u16 cipher_type, in nfp_net_cipher_supported() argument
260 return nn->tlv_caps.crypto_ops & BIT(bit); in nfp_net_cipher_supported()
270 struct nfp_net *nn = netdev_priv(netdev); in nfp_net_tls_add() local
286 if (!nfp_net_cipher_supported(nn, crypto_info->cipher_type, direction)) in nfp_net_tls_add()
308 err = nfp_net_tls_conn_add(nn, direction); in nfp_net_tls_add()
312 skb = nfp_ccm_mbox_msg_alloc(nn, req_sz, sizeof(*reply), GFP_KERNEL); in nfp_net_tls_add()
328 back = nfp_net_tls_set_ipv6(nn, req, sk, direction); in nfp_net_tls_add()
330 back = nfp_net_tls_set_ipv4(nn, req, sk, direction); in nfp_net_tls_add()
348 err = nfp_ccm_mbox_communicate(nn, skb, NFP_CCM_TYPE_CRYPTO_ADD, in nfp_net_tls_add()
362 nn_dp_warn(&nn->dp, "failed to add TLS: %d (%d)\n", in nfp_net_tls_add()
371 if (!atomic_fetch_inc(&nn->ktls_no_space)) in nfp_net_tls_add()
372 nn_info(nn, "HW TLS table full\n"); in nfp_net_tls_add()
374 nn_dp_warn(&nn->dp, in nfp_net_tls_add()
381 nn_dp_warn(&nn->dp, "FW returned NULL handle\n"); in nfp_net_tls_add()
395 if (!nn->tlv_caps.tls_resync_ss) in nfp_net_tls_add()
401 nfp_net_tls_del_fw(nn, reply->handle); in nfp_net_tls_add()
405 nfp_net_tls_conn_remove(nn, direction); in nfp_net_tls_add()
413 struct nfp_net *nn = netdev_priv(netdev); in nfp_net_tls_del() local
416 nfp_net_tls_conn_remove(nn, direction); in nfp_net_tls_del()
419 nfp_net_tls_del_fw(nn, ntls->fw_handle); in nfp_net_tls_del()
426 struct nfp_net *nn = netdev_priv(netdev); in nfp_net_tls_resync() local
435 skb = nfp_net_tls_alloc_simple(nn, sizeof(*req), flags); in nfp_net_tls_resync()
450 err = nfp_net_tls_communicate_simple(nn, skb, "sync", type); in nfp_net_tls_resync()
455 if (nn->tlv_caps.tls_resync_ss) in nfp_net_tls_resync()
457 nfp_ccm_mbox_post(nn, skb, type, in nfp_net_tls_resync()
459 atomic_inc(&nn->ktls_rx_resync_sent); in nfp_net_tls_resync()
475 struct nfp_net *nn = netdev_priv(netdev); in nfp_net_tls_rx_resync_req() local
533 atomic_inc(&nn->ktls_rx_resync_req); in nfp_net_tls_rx_resync_req()
541 atomic_inc(&nn->ktls_rx_resync_ign); in nfp_net_tls_rx_resync_req()
545 static int nfp_net_tls_reset(struct nfp_net *nn) in nfp_net_tls_reset() argument
550 skb = nfp_net_tls_alloc_simple(nn, sizeof(*req), GFP_KERNEL); in nfp_net_tls_reset()
557 return nfp_net_tls_communicate_simple(nn, skb, "reset", in nfp_net_tls_reset()
561 int nfp_net_tls_init(struct nfp_net *nn) in nfp_net_tls_init() argument
563 struct net_device *netdev = nn->dp.netdev; in nfp_net_tls_init()
566 if (!(nn->tlv_caps.crypto_ops & NFP_NET_TLS_OPCODE_MASK)) in nfp_net_tls_init()
569 if ((nn->tlv_caps.mbox_cmsg_types & NFP_NET_TLS_CCM_MBOX_OPS_MASK) != in nfp_net_tls_init()
573 if (!nfp_ccm_mbox_fits(nn, sizeof(struct nfp_crypto_req_add_v6))) { in nfp_net_tls_init()
574 nn_warn(nn, "disabling TLS offload - mbox too small: %d\n", in nfp_net_tls_init()
575 nn->tlv_caps.mbox_len); in nfp_net_tls_init()
579 err = nfp_net_tls_reset(nn); in nfp_net_tls_init()
583 nn_ctrl_bar_lock(nn); in nfp_net_tls_init()
584 nn_writel(nn, nn->tlv_caps.crypto_enable_off, 0); in nfp_net_tls_init()
585 err = __nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_CRYPTO); in nfp_net_tls_init()
586 nn_ctrl_bar_unlock(nn); in nfp_net_tls_init()
590 if (nn->tlv_caps.crypto_ops & NFP_NET_TLS_OPCODE_MASK_RX) { in nfp_net_tls_init()
594 if (nn->tlv_caps.crypto_ops & NFP_NET_TLS_OPCODE_MASK_TX) { in nfp_net_tls_init()