77#include "otx2_cptlf.h"
88#include "cn10k_cpt.h"
99
10+ static void cn10k_cpt_send_cmd (union otx2_cpt_inst_s * cptinst , u32 insts_num ,
11+ struct otx2_cptlf_info * lf );
12+
1013static struct cpt_hw_ops otx2_hw_ops = {
1114 .send_cmd = otx2_cpt_send_cmd ,
1215 .cpt_get_compcode = otx2_cpt_get_compcode ,
1316 .cpt_get_uc_compcode = otx2_cpt_get_uc_compcode ,
17+ .cpt_sg_info_create = otx2_sg_info_create ,
1418};
1519
1620static struct cpt_hw_ops cn10k_hw_ops = {
1721 .send_cmd = cn10k_cpt_send_cmd ,
1822 .cpt_get_compcode = cn10k_cpt_get_compcode ,
1923 .cpt_get_uc_compcode = cn10k_cpt_get_uc_compcode ,
24+ .cpt_sg_info_create = otx2_sg_info_create ,
2025};
2126
22- void cn10k_cpt_send_cmd (union otx2_cpt_inst_s * cptinst , u32 insts_num ,
23- struct otx2_cptlf_info * lf )
27+ static void cn10k_cpt_send_cmd (union otx2_cpt_inst_s * cptinst , u32 insts_num ,
28+ struct otx2_cptlf_info * lf )
2429{
2530 void __iomem * lmtline = lf -> lmtline ;
2631 u64 val = (lf -> slot & 0x7FF );
@@ -68,18 +73,16 @@ int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf)
6873
6974 return 0 ;
7075}
76+ EXPORT_SYMBOL_NS_GPL (cn10k_cptpf_lmtst_init , CRYPTO_DEV_OCTEONTX2_CPT );
7177
7278int cn10k_cptvf_lmtst_init (struct otx2_cptvf_dev * cptvf )
7379{
7480 struct pci_dev * pdev = cptvf -> pdev ;
7581 resource_size_t offset , size ;
7682
77- if (!test_bit (CN10K_LMTST , & cptvf -> cap_flag )) {
78- cptvf -> lfs .ops = & otx2_hw_ops ;
83+ if (!test_bit (CN10K_LMTST , & cptvf -> cap_flag ))
7984 return 0 ;
80- }
8185
82- cptvf -> lfs .ops = & cn10k_hw_ops ;
8386 offset = pci_resource_start (pdev , PCI_MBOX_BAR_NUM );
8487 size = pci_resource_len (pdev , PCI_MBOX_BAR_NUM );
8588 /* Map VF LMILINE region */
@@ -91,3 +94,87 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)
9194
9295 return 0 ;
9396}
97+ EXPORT_SYMBOL_NS_GPL (cn10k_cptvf_lmtst_init , CRYPTO_DEV_OCTEONTX2_CPT );
98+
99+ void cn10k_cpt_hw_ctx_clear (struct pci_dev * pdev ,
100+ struct cn10k_cpt_errata_ctx * er_ctx )
101+ {
102+ u64 cptr_dma ;
103+
104+ if (!is_dev_cn10ka_ax (pdev ))
105+ return ;
106+
107+ cptr_dma = er_ctx -> cptr_dma & ~(BIT_ULL (60 ));
108+ cn10k_cpt_ctx_flush (pdev , cptr_dma , true);
109+ dma_unmap_single (& pdev -> dev , cptr_dma , CN10K_CPT_HW_CTX_SIZE ,
110+ DMA_BIDIRECTIONAL );
111+ kfree (er_ctx -> hw_ctx );
112+ }
113+ EXPORT_SYMBOL_NS_GPL (cn10k_cpt_hw_ctx_clear , CRYPTO_DEV_OCTEONTX2_CPT );
114+
115+ void cn10k_cpt_hw_ctx_set (union cn10k_cpt_hw_ctx * hctx , u16 ctx_sz )
116+ {
117+ hctx -> w0 .aop_valid = 1 ;
118+ hctx -> w0 .ctx_hdr_sz = 0 ;
119+ hctx -> w0 .ctx_sz = ctx_sz ;
120+ hctx -> w0 .ctx_push_sz = 1 ;
121+ }
122+ EXPORT_SYMBOL_NS_GPL (cn10k_cpt_hw_ctx_set , CRYPTO_DEV_OCTEONTX2_CPT );
123+
124+ int cn10k_cpt_hw_ctx_init (struct pci_dev * pdev ,
125+ struct cn10k_cpt_errata_ctx * er_ctx )
126+ {
127+ union cn10k_cpt_hw_ctx * hctx ;
128+ u64 cptr_dma ;
129+
130+ er_ctx -> cptr_dma = 0 ;
131+ er_ctx -> hw_ctx = NULL ;
132+
133+ if (!is_dev_cn10ka_ax (pdev ))
134+ return 0 ;
135+
136+ hctx = kmalloc (CN10K_CPT_HW_CTX_SIZE , GFP_KERNEL );
137+ if (unlikely (!hctx ))
138+ return - ENOMEM ;
139+ cptr_dma = dma_map_single (& pdev -> dev , hctx , CN10K_CPT_HW_CTX_SIZE ,
140+ DMA_BIDIRECTIONAL );
141+ if (dma_mapping_error (& pdev -> dev , cptr_dma )) {
142+ kfree (hctx );
143+ return - ENOMEM ;
144+ }
145+
146+ cn10k_cpt_hw_ctx_set (hctx , 1 );
147+ er_ctx -> hw_ctx = hctx ;
148+ er_ctx -> cptr_dma = cptr_dma | BIT_ULL (60 );
149+
150+ return 0 ;
151+ }
152+ EXPORT_SYMBOL_NS_GPL (cn10k_cpt_hw_ctx_init , CRYPTO_DEV_OCTEONTX2_CPT );
153+
154+ void cn10k_cpt_ctx_flush (struct pci_dev * pdev , u64 cptr , bool inval )
155+ {
156+ struct otx2_cptvf_dev * cptvf = pci_get_drvdata (pdev );
157+ struct otx2_cptlfs_info * lfs = & cptvf -> lfs ;
158+ u64 reg ;
159+
160+ reg = (uintptr_t )cptr >> 7 ;
161+ if (inval )
162+ reg = reg | BIT_ULL (46 );
163+
164+ otx2_cpt_write64 (lfs -> reg_base , lfs -> blkaddr , lfs -> lf [0 ].slot ,
165+ OTX2_CPT_LF_CTX_FLUSH , reg );
166+ /* Make sure that the FLUSH operation is complete */
167+ wmb ();
168+ otx2_cpt_read64 (lfs -> reg_base , lfs -> blkaddr , lfs -> lf [0 ].slot ,
169+ OTX2_CPT_LF_CTX_ERR );
170+ }
171+ EXPORT_SYMBOL_NS_GPL (cn10k_cpt_ctx_flush , CRYPTO_DEV_OCTEONTX2_CPT );
172+
173+ void cptvf_hw_ops_get (struct otx2_cptvf_dev * cptvf )
174+ {
175+ if (test_bit (CN10K_LMTST , & cptvf -> cap_flag ))
176+ cptvf -> lfs .ops = & cn10k_hw_ops ;
177+ else
178+ cptvf -> lfs .ops = & otx2_hw_ops ;
179+ }
180+ EXPORT_SYMBOL_NS_GPL (cptvf_hw_ops_get , CRYPTO_DEV_OCTEONTX2_CPT );
0 commit comments