Lines Matching +full:- +full:eproto

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 #include "nx-842.h"
18 #include <asm/opal-api.h>
25 MODULE_ALIAS_CRYPTO("842-nx");
76 * setup_indirect_dde - Setup an indirect DDE
85 dde->flags = 0; in setup_indirect_dde()
86 dde->count = dde_count; in setup_indirect_dde()
87 dde->index = 0; in setup_indirect_dde()
88 dde->length = cpu_to_be32(byte_count); in setup_indirect_dde()
89 dde->address = cpu_to_be64(nx842_get_pa(ddl)); in setup_indirect_dde()
93 * setup_direct_dde - Setup single DDE from buffer
105 dde->flags = 0; in setup_direct_dde()
106 dde->count = 0; in setup_direct_dde()
107 dde->index = 0; in setup_direct_dde()
108 dde->length = cpu_to_be32(l); in setup_direct_dde()
109 dde->address = cpu_to_be64(pa); in setup_direct_dde()
115 * setup_ddl - Setup DDL from buffer
129 pr_debug("%s buffer pa 0x%lx not 0x%x-byte aligned\n", in setup_ddl()
131 return -EINVAL; in setup_ddl()
136 * DDE_BUFFER_SIZE_MULT, and pre-last page DDE buffers in setup_ddl()
143 return -EINVAL; in setup_ddl()
158 len -= ret; in setup_ddl()
166 return -EMSGSIZE; in setup_ddl()
167 total_len -= len; in setup_ddl()
176 ##__VA_ARGS__, (csb)->flags, \
177 (csb)->cs, (csb)->cc, (csb)->ce, \
178 be32_to_cpu((csb)->count))
182 (unsigned long)be64_to_cpu((csb)->address))
187 ktime_t start = wmem->start, now = ktime_get(); in wait_for_csb()
190 while (!(READ_ONCE(csb->flags) & CSB_V)) { in wait_for_csb()
201 if (!(csb->flags & CSB_V)) { in wait_for_csb()
204 return -ETIMEDOUT; in wait_for_csb()
206 if (csb->flags & CSB_F) { in wait_for_csb()
208 return -EPROTO; in wait_for_csb()
210 if (csb->flags & CSB_CH) { in wait_for_csb()
212 return -EPROTO; in wait_for_csb()
216 if (csb->cs) { in wait_for_csb()
218 return -EPROTO; in wait_for_csb()
222 switch (csb->cc) { in wait_for_csb()
236 return -EINVAL; in wait_for_csb()
239 return -EINVAL; in wait_for_csb()
242 return -ENOSPC; in wait_for_csb()
245 return -EINTR; in wait_for_csb()
248 return -EINVAL; in wait_for_csb()
251 return -EINVAL; in wait_for_csb()
254 return -EINVAL; in wait_for_csb()
261 return -EINVAL; in wait_for_csb()
267 return -EINVAL; in wait_for_csb()
271 return -EINVAL; in wait_for_csb()
282 return -EPROTO; in wait_for_csb()
293 return -EPROTO; in wait_for_csb()
297 return -EPROTO; in wait_for_csb()
301 return -EINVAL; in wait_for_csb()
306 return -EINVAL; in wait_for_csb()
313 return -EINVAL; in wait_for_csb()
317 return -EINVAL; in wait_for_csb()
321 return -EINVAL; in wait_for_csb()
325 return -EPROTO; in wait_for_csb()
329 return -EPROTO; in wait_for_csb()
333 return -EPROTO; in wait_for_csb()
336 return -EPROTO; in wait_for_csb()
344 return -EPROTO; in wait_for_csb()
347 return -EPROTO; in wait_for_csb()
350 return -EPROTO; in wait_for_csb()
353 return -EPROTO; in wait_for_csb()
356 return -EPROTO; in wait_for_csb()
359 return -EPROTO; in wait_for_csb()
362 CSB_ERR(csb, "Invalid CC %d", csb->cc); in wait_for_csb()
363 return -EPROTO; in wait_for_csb()
367 if (csb->ce & CSB_CE_TERMINATION) { in wait_for_csb()
369 return -EPROTO; in wait_for_csb()
371 if (csb->ce & CSB_CE_INCOMPLETE) { in wait_for_csb()
373 return -EPROTO; in wait_for_csb()
375 if (!(csb->ce & CSB_CE_TPBC)) { in wait_for_csb()
377 return -EPROTO; in wait_for_csb()
382 be32_to_cpu(csb->count), in wait_for_csb()
397 crb = &wmem->crb; in nx842_config_crb()
398 csb = &crb->csb; in nx842_config_crb()
404 ret = setup_ddl(&crb->source, wmem->ddl_in, in nx842_config_crb()
409 ret = setup_ddl(&crb->target, wmem->ddl_out, in nx842_config_crb()
417 crb->csb_addr = cpu_to_be64(csb_addr); in nx842_config_crb()
423 * nx842_exec_icswx - compress/decompress data using the 842 algorithm
441 * @fc: function code, see CCW Function Codes in nx-842.h
445 * -ENODEV Hardware unavailable
446 * -ENOSPC Output buffer is to small
447 * -EMSGSIZE Input buffer too large
448 * -EINVAL buffer constraints do not fix nx842_constraints
449 * -EPROTO hardware error during operation
450 * -ETIMEDOUT hardware did not complete operation in reasonable time
451 * -EINTR operation was aborted
471 return -ENODEV; in nx842_exec_icswx()
478 crb = &wmem->crb; in nx842_exec_icswx()
479 csb = &crb->csb; in nx842_exec_icswx()
484 ccw = SET_FIELD(CCW_CI_842, ccw, 0); /* use 0 for hw auto-selection */ in nx842_exec_icswx()
487 wmem->start = ktime_get(); in nx842_exec_icswx()
492 pr_debug_ratelimited("icswx CR %x ccw %x crb->ccw %x\n", ret, in nx842_exec_icswx()
494 (unsigned int)be32_to_cpu(crb->ccw)); in nx842_exec_icswx()
510 ret = -EBUSY; in nx842_exec_icswx()
514 ret = -EPROTO; in nx842_exec_icswx()
519 *outlenp = be32_to_cpu(csb->count); in nx842_exec_icswx()
525 * nx842_exec_vas - compress/decompress data using the 842 algorithm
543 * @fc: function code, see CCW Function Codes in nx-842.h
548 * -ENODEV Hardware unavailable
549 * -ENOSPC Output buffer is to small
550 * -EMSGSIZE Input buffer too large
551 * -EINVAL buffer constraints do not fix nx842_constraints
552 * -EPROTO hardware error during operation
553 * -ETIMEDOUT hardware did not complete operation in reasonable time
554 * -EINTR operation was aborted
572 crb = &wmem->crb; in nx842_exec_vas()
573 csb = &crb->csb; in nx842_exec_vas()
581 crb->ccw = cpu_to_be32(ccw); in nx842_exec_vas()
584 wmem->start = ktime_get(); in nx842_exec_vas()
612 *outlenp = be32_to_cpu(csb->count); in nx842_exec_vas()
618 * nx842_powernv_compress - Compress data using the 842 algorithm
646 * nx842_powernv_decompress - Decompress data using the 842 algorithm
676 coproc->chip_id = chipid; in nx_add_coprocs_list()
677 INIT_LIST_HEAD(&coproc->list); in nx_add_coprocs_list()
678 list_add(&coproc->list, &nx_coprocs); in nx_add_coprocs_list()
690 vas_init_tx_win_attr(&txattr, coproc->ct); in nx_alloc_txwin()
696 txwin = vas_tx_win_open(coproc->vas.id, coproc->ct, &txattr); in nx_alloc_txwin()
698 pr_err("ibm,nx-842: Can not open TX window: %ld\n", in nx_alloc_txwin()
727 if (coproc->ct != VAS_COP_TYPE_842_HIPRI) in nx_open_percpu_txwins()
730 if (coproc->chip_id == chip_id) { in nx_open_percpu_txwins()
743 return -EINVAL; in nx_open_percpu_txwins()
754 coproc->ct = high; in nx_set_ct()
756 coproc->ct = normal; in nx_set_ct()
759 return -EINVAL; in nx_set_ct()
776 ret = of_property_read_u64(dn, "rx-fifo-address", &rx_fifo); in vas_cfg_coproc_info()
778 pr_err("Missing rx-fifo-address property\n"); in vas_cfg_coproc_info()
782 ret = of_property_read_u32(dn, "rx-fifo-size", &fifo_size); in vas_cfg_coproc_info()
784 pr_err("Missing rx-fifo-size property\n"); in vas_cfg_coproc_info()
814 return -ENOMEM; in vas_cfg_coproc_info()
826 vas_init_rx_win_attr(&rxattr, coproc->ct); in vas_cfg_coproc_info()
842 rxwin = vas_rx_win_open(vasid, coproc->ct, &rxattr); in vas_cfg_coproc_info()
850 coproc->vas.rxwin = rxwin; in vas_cfg_coproc_info()
851 coproc->vas.id = vasid; in vas_cfg_coproc_info()
859 * device-tree property. in vas_cfg_coproc_info()
914 pr_err("ibm,chip-id missing\n"); in nx_powernv_probe_vas()
915 return -EINVAL; in nx_powernv_probe_vas()
921 return -EINVAL; in nx_powernv_probe_vas()
926 "ibm,p9-nx-842", &ct_842); in nx_powernv_probe_vas()
930 NX_CT_GZIP, "ibm,p9-nx-gzip", &ct_gzip); in nx_powernv_probe_vas()
940 return -EINVAL; in nx_powernv_probe_vas()
959 pr_err("ibm,chip-id missing\n"); in nx842_powernv_probe()
960 return -EINVAL; in nx842_powernv_probe()
963 if (of_property_read_u32(dn, "ibm,842-coprocessor-type", &ct)) { in nx842_powernv_probe()
964 pr_err("ibm,842-coprocessor-type missing\n"); in nx842_powernv_probe()
965 return -EINVAL; in nx842_powernv_probe()
968 if (of_property_read_u32(dn, "ibm,842-coprocessor-instance", &ci)) { in nx842_powernv_probe()
969 pr_err("ibm,842-coprocessor-instance missing\n"); in nx842_powernv_probe()
970 return -EINVAL; in nx842_powernv_probe()
975 return -ENOMEM; in nx842_powernv_probe()
977 coproc->ct = ct; in nx842_powernv_probe()
978 coproc->ci = ci; in nx842_powernv_probe()
1010 if (coproc->vas.rxwin) in nx_delete_coprocs()
1011 vas_win_close(coproc->vas.rxwin); in nx_delete_coprocs()
1013 list_del(&coproc->list); in nx_delete_coprocs()
1022 .maximum = (DDL_LEN_MAX - 1) * PAGE_SIZE,
1041 .cra_driver_name = "842-nx",
1067 for_each_compatible_node(dn, NULL, "ibm,power9-nx") { in nx_compress_powernv_init()
1077 for_each_compatible_node(dn, NULL, "ibm,power-nx") in nx_compress_powernv_init()
1081 return -ENODEV; in nx_compress_powernv_init()
1093 "nx-gzip"); in nx_compress_powernv_init()