.. | .. |
---|
1 | | -/* |
---|
2 | | - This file is provided under a dual BSD/GPLv2 license. When using or |
---|
3 | | - redistributing this file, you may do so under either license. |
---|
4 | | - |
---|
5 | | - GPL LICENSE SUMMARY |
---|
6 | | - Copyright(c) 2014 Intel Corporation. |
---|
7 | | - This program is free software; you can redistribute it and/or modify |
---|
8 | | - it under the terms of version 2 of the GNU General Public License as |
---|
9 | | - published by the Free Software Foundation. |
---|
10 | | - |
---|
11 | | - This program is distributed in the hope that it will be useful, but |
---|
12 | | - WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | | - General Public License for more details. |
---|
15 | | - |
---|
16 | | - Contact Information: |
---|
17 | | - qat-linux@intel.com |
---|
18 | | - |
---|
19 | | - BSD LICENSE |
---|
20 | | - Copyright(c) 2014 Intel Corporation. |
---|
21 | | - Redistribution and use in source and binary forms, with or without |
---|
22 | | - modification, are permitted provided that the following conditions |
---|
23 | | - are met: |
---|
24 | | - |
---|
25 | | - * Redistributions of source code must retain the above copyright |
---|
26 | | - notice, this list of conditions and the following disclaimer. |
---|
27 | | - * Redistributions in binary form must reproduce the above copyright |
---|
28 | | - notice, this list of conditions and the following disclaimer in |
---|
29 | | - the documentation and/or other materials provided with the |
---|
30 | | - distribution. |
---|
31 | | - * Neither the name of Intel Corporation nor the names of its |
---|
32 | | - contributors may be used to endorse or promote products derived |
---|
33 | | - from this software without specific prior written permission. |
---|
34 | | - |
---|
35 | | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
36 | | - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
37 | | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
38 | | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
39 | | - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
40 | | - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
41 | | - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
42 | | - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
43 | | - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
44 | | - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
45 | | - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
46 | | -*/ |
---|
| 1 | +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) |
---|
| 2 | +/* Copyright(c) 2014 - 2020 Intel Corporation */ |
---|
47 | 3 | #include <linux/slab.h> |
---|
48 | 4 | #include <linux/delay.h> |
---|
| 5 | +#include <linux/pci_ids.h> |
---|
49 | 6 | |
---|
50 | 7 | #include "adf_accel_devices.h" |
---|
51 | 8 | #include "adf_common_drv.h" |
---|
.. | .. |
---|
78 | 35 | |
---|
79 | 36 | #define AE(handle, ae) handle->hal_handle->aes[ae] |
---|
80 | 37 | |
---|
81 | | -static const uint64_t inst_4b[] = { |
---|
| 38 | +static const u64 inst_4b[] = { |
---|
82 | 39 | 0x0F0400C0000ull, 0x0F4400C0000ull, 0x0F040000300ull, 0x0F440000300ull, |
---|
83 | 40 | 0x0FC066C0000ull, 0x0F0000C0300ull, 0x0F0000C0300ull, 0x0F0000C0300ull, |
---|
84 | 41 | 0x0A021000000ull |
---|
85 | 42 | }; |
---|
86 | 43 | |
---|
87 | | -static const uint64_t inst[] = { |
---|
| 44 | +static const u64 inst[] = { |
---|
88 | 45 | 0x0F0000C0000ull, 0x0F000000380ull, 0x0D805000011ull, 0x0FC082C0300ull, |
---|
89 | 46 | 0x0F0000C0300ull, 0x0F0000C0300ull, 0x0F0000C0300ull, 0x0F0000C0300ull, |
---|
90 | 47 | 0x0A0643C0000ull, 0x0BAC0000301ull, 0x0D802000101ull, 0x0F0000C0001ull, |
---|
.. | .. |
---|
456 | 413 | unsigned int csr_val; |
---|
457 | 414 | int times = 30; |
---|
458 | 415 | |
---|
459 | | - if (handle->pci_dev->device != ADF_DH895XCC_PCI_DEVICE_ID) |
---|
| 416 | + if (handle->pci_dev->device != PCI_DEVICE_ID_INTEL_QAT_DH895XCC) |
---|
460 | 417 | return 0; |
---|
461 | 418 | |
---|
462 | 419 | csr_val = ADF_CSR_RD(csr_addr, 0); |
---|
.. | .. |
---|
546 | 503 | qat_hal_wr_ae_csr(handle, ae, CTX_ENABLES, ctx); |
---|
547 | 504 | } |
---|
548 | 505 | |
---|
549 | | -static uint64_t qat_hal_parity_64bit(uint64_t word) |
---|
| 506 | +static u64 qat_hal_parity_64bit(u64 word) |
---|
550 | 507 | { |
---|
551 | 508 | word ^= word >> 1; |
---|
552 | 509 | word ^= word >> 2; |
---|
.. | .. |
---|
557 | 514 | return word & 1; |
---|
558 | 515 | } |
---|
559 | 516 | |
---|
560 | | -static uint64_t qat_hal_set_uword_ecc(uint64_t uword) |
---|
| 517 | +static u64 qat_hal_set_uword_ecc(u64 uword) |
---|
561 | 518 | { |
---|
562 | | - uint64_t bit0_mask = 0xff800007fffULL, bit1_mask = 0x1f801ff801fULL, |
---|
| 519 | + u64 bit0_mask = 0xff800007fffULL, bit1_mask = 0x1f801ff801fULL, |
---|
563 | 520 | bit2_mask = 0xe387e0781e1ULL, bit3_mask = 0x7cb8e388e22ULL, |
---|
564 | 521 | bit4_mask = 0xaf5b2c93244ULL, bit5_mask = 0xf56d5525488ULL, |
---|
565 | 522 | bit6_mask = 0xdaf69a46910ULL; |
---|
.. | .. |
---|
578 | 535 | |
---|
579 | 536 | void qat_hal_wr_uwords(struct icp_qat_fw_loader_handle *handle, |
---|
580 | 537 | unsigned char ae, unsigned int uaddr, |
---|
581 | | - unsigned int words_num, uint64_t *uword) |
---|
| 538 | + unsigned int words_num, u64 *uword) |
---|
582 | 539 | { |
---|
583 | 540 | unsigned int ustore_addr; |
---|
584 | 541 | unsigned int i; |
---|
.. | .. |
---|
588 | 545 | qat_hal_wr_ae_csr(handle, ae, USTORE_ADDRESS, uaddr); |
---|
589 | 546 | for (i = 0; i < words_num; i++) { |
---|
590 | 547 | unsigned int uwrd_lo, uwrd_hi; |
---|
591 | | - uint64_t tmp; |
---|
| 548 | + u64 tmp; |
---|
592 | 549 | |
---|
593 | 550 | tmp = qat_hal_set_uword_ecc(uword[i]); |
---|
594 | 551 | uwrd_lo = (unsigned int)(tmp & 0xffffffff); |
---|
.. | .. |
---|
644 | 601 | csr_val |= CE_NN_MODE; |
---|
645 | 602 | qat_hal_wr_ae_csr(handle, ae, CTX_ENABLES, csr_val); |
---|
646 | 603 | qat_hal_wr_uwords(handle, ae, 0, ARRAY_SIZE(inst), |
---|
647 | | - (uint64_t *)inst); |
---|
| 604 | + (u64 *)inst); |
---|
648 | 605 | qat_hal_wr_indr_csr(handle, ae, ctx_mask, CTX_STS_INDIRECT, |
---|
649 | 606 | handle->hal_handle->upc_mask & |
---|
650 | 607 | INIT_PC_VALUE); |
---|
.. | .. |
---|
716 | 673 | (void __iomem *)((uintptr_t)handle->hal_cap_ae_xfer_csr_addr_v + |
---|
717 | 674 | LOCAL_TO_XFER_REG_OFFSET); |
---|
718 | 675 | handle->pci_dev = pci_info->pci_dev; |
---|
719 | | - if (handle->pci_dev->device == ADF_DH895XCC_PCI_DEVICE_ID) { |
---|
| 676 | + if (handle->pci_dev->device == PCI_DEVICE_ID_INTEL_QAT_DH895XCC) { |
---|
720 | 677 | sram_bar = |
---|
721 | 678 | &pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)]; |
---|
722 | 679 | handle->hal_sram_addr_v = sram_bar->virt_addr; |
---|
723 | 680 | } |
---|
724 | 681 | handle->fw_auth = (handle->pci_dev->device == |
---|
725 | | - ADF_DH895XCC_PCI_DEVICE_ID) ? false : true; |
---|
| 682 | + PCI_DEVICE_ID_INTEL_QAT_DH895XCC) ? false : true; |
---|
726 | 683 | handle->hal_handle = kzalloc(sizeof(*handle->hal_handle), GFP_KERNEL); |
---|
727 | 684 | if (!handle->hal_handle) |
---|
728 | 685 | goto out_hal_handle; |
---|
.. | .. |
---|
821 | 778 | |
---|
822 | 779 | static void qat_hal_get_uwords(struct icp_qat_fw_loader_handle *handle, |
---|
823 | 780 | unsigned char ae, unsigned int uaddr, |
---|
824 | | - unsigned int words_num, uint64_t *uword) |
---|
| 781 | + unsigned int words_num, u64 *uword) |
---|
825 | 782 | { |
---|
826 | 783 | unsigned int i, uwrd_lo, uwrd_hi; |
---|
827 | 784 | unsigned int ustore_addr, misc_control; |
---|
.. | .. |
---|
871 | 828 | #define MAX_EXEC_INST 100 |
---|
872 | 829 | static int qat_hal_exec_micro_inst(struct icp_qat_fw_loader_handle *handle, |
---|
873 | 830 | unsigned char ae, unsigned char ctx, |
---|
874 | | - uint64_t *micro_inst, unsigned int inst_num, |
---|
| 831 | + u64 *micro_inst, unsigned int inst_num, |
---|
875 | 832 | int code_off, unsigned int max_cycle, |
---|
876 | 833 | unsigned int *endpc) |
---|
877 | 834 | { |
---|
878 | | - uint64_t savuwords[MAX_EXEC_INST]; |
---|
| 835 | + u64 savuwords[MAX_EXEC_INST]; |
---|
879 | 836 | unsigned int ind_lm_addr0, ind_lm_addr1; |
---|
880 | 837 | unsigned int ind_lm_addr_byte0, ind_lm_addr_byte1; |
---|
881 | 838 | unsigned int ind_cnt_sig; |
---|
.. | .. |
---|
972 | 929 | unsigned int ctxarb_cntl, ustore_addr, ctx_enables; |
---|
973 | 930 | unsigned short reg_addr; |
---|
974 | 931 | int status = 0; |
---|
975 | | - uint64_t insts, savuword; |
---|
| 932 | + u64 insts, savuword; |
---|
976 | 933 | |
---|
977 | 934 | reg_addr = qat_hal_get_reg_addr(reg_type, reg_num); |
---|
978 | 935 | if (reg_addr == BAD_REGADDR) { |
---|
.. | .. |
---|
984 | 941 | insts = 0xA070000000ull | (reg_addr & 0x3ff); |
---|
985 | 942 | break; |
---|
986 | 943 | default: |
---|
987 | | - insts = (uint64_t)0xA030000000ull | ((reg_addr & 0x3ff) << 10); |
---|
| 944 | + insts = (u64)0xA030000000ull | ((reg_addr & 0x3ff) << 10); |
---|
988 | 945 | break; |
---|
989 | 946 | } |
---|
990 | 947 | savctx = qat_hal_rd_ae_csr(handle, ae, ACTIVE_CTX_STATUS); |
---|
.. | .. |
---|
1030 | 987 | unsigned short reg_num, unsigned int data) |
---|
1031 | 988 | { |
---|
1032 | 989 | unsigned short src_hiaddr, src_lowaddr, dest_addr, data16hi, data16lo; |
---|
1033 | | - uint64_t insts[] = { |
---|
| 990 | + u64 insts[] = { |
---|
1034 | 991 | 0x0F440000000ull, |
---|
1035 | 992 | 0x0F040000000ull, |
---|
1036 | 993 | 0x0F0000C0300ull, |
---|
.. | .. |
---|
1076 | 1033 | return ARRAY_SIZE(inst_4b); |
---|
1077 | 1034 | } |
---|
1078 | 1035 | |
---|
1079 | | -static int qat_hal_concat_micro_code(uint64_t *micro_inst, |
---|
| 1036 | +static int qat_hal_concat_micro_code(u64 *micro_inst, |
---|
1080 | 1037 | unsigned int inst_num, unsigned int size, |
---|
1081 | 1038 | unsigned int addr, unsigned int *value) |
---|
1082 | 1039 | { |
---|
1083 | 1040 | int i; |
---|
1084 | 1041 | unsigned int cur_value; |
---|
1085 | | - const uint64_t *inst_arr; |
---|
| 1042 | + const u64 *inst_arr; |
---|
1086 | 1043 | int fixup_offset; |
---|
1087 | 1044 | int usize = 0; |
---|
1088 | 1045 | int orig_num; |
---|
.. | .. |
---|
1107 | 1064 | |
---|
1108 | 1065 | static int qat_hal_exec_micro_init_lm(struct icp_qat_fw_loader_handle *handle, |
---|
1109 | 1066 | unsigned char ae, unsigned char ctx, |
---|
1110 | | - int *pfirst_exec, uint64_t *micro_inst, |
---|
| 1067 | + int *pfirst_exec, u64 *micro_inst, |
---|
1111 | 1068 | unsigned int inst_num) |
---|
1112 | 1069 | { |
---|
1113 | 1070 | int stat = 0; |
---|
.. | .. |
---|
1140 | 1097 | struct icp_qat_uof_batch_init *lm_init_header) |
---|
1141 | 1098 | { |
---|
1142 | 1099 | struct icp_qat_uof_batch_init *plm_init; |
---|
1143 | | - uint64_t *micro_inst_arry; |
---|
| 1100 | + u64 *micro_inst_arry; |
---|
1144 | 1101 | int micro_inst_num; |
---|
1145 | 1102 | int alloc_inst_size; |
---|
1146 | 1103 | int first_exec = 1; |
---|
.. | .. |
---|
1150 | 1107 | alloc_inst_size = lm_init_header->size; |
---|
1151 | 1108 | if ((unsigned int)alloc_inst_size > handle->hal_handle->max_ustore) |
---|
1152 | 1109 | alloc_inst_size = handle->hal_handle->max_ustore; |
---|
1153 | | - micro_inst_arry = kmalloc_array(alloc_inst_size, sizeof(uint64_t), |
---|
| 1110 | + micro_inst_arry = kmalloc_array(alloc_inst_size, sizeof(u64), |
---|
1154 | 1111 | GFP_KERNEL); |
---|
1155 | 1112 | if (!micro_inst_arry) |
---|
1156 | 1113 | return -ENOMEM; |
---|
.. | .. |
---|
1229 | 1186 | data16low; |
---|
1230 | 1187 | unsigned short reg_mask; |
---|
1231 | 1188 | int status = 0; |
---|
1232 | | - uint64_t micro_inst[] = { |
---|
| 1189 | + u64 micro_inst[] = { |
---|
1233 | 1190 | 0x0F440000000ull, |
---|
1234 | 1191 | 0x0F040000000ull, |
---|
1235 | 1192 | 0x0A000000000ull, |
---|