| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2016 Cavium, Inc. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of version 2 of the GNU General Public License |
|---|
| 6 | | - * as published by the Free Software Foundation. |
|---|
| 7 | 4 | */ |
|---|
| 8 | 5 | |
|---|
| 9 | 6 | #include "cptvf.h" |
|---|
| 7 | +#include "cptvf_algs.h" |
|---|
| 10 | 8 | #include "request_manager.h" |
|---|
| 11 | 9 | |
|---|
| 12 | 10 | /** |
|---|
| .. | .. |
|---|
| 92 | 90 | case 3: |
|---|
| 93 | 91 | sg_ptr->u.s.len2 = cpu_to_be16(list[i * 4 + 2].size); |
|---|
| 94 | 92 | sg_ptr->ptr2 = cpu_to_be64(list[i * 4 + 2].dma_addr); |
|---|
| 95 | | - /* Fall through */ |
|---|
| 93 | + fallthrough; |
|---|
| 96 | 94 | case 2: |
|---|
| 97 | 95 | sg_ptr->u.s.len1 = cpu_to_be16(list[i * 4 + 1].size); |
|---|
| 98 | 96 | sg_ptr->ptr1 = cpu_to_be64(list[i * 4 + 1].dma_addr); |
|---|
| 99 | | - /* Fall through */ |
|---|
| 97 | + fallthrough; |
|---|
| 100 | 98 | case 1: |
|---|
| 101 | 99 | sg_ptr->u.s.len0 = cpu_to_be16(list[i * 4 + 0].size); |
|---|
| 102 | 100 | sg_ptr->ptr0 = cpu_to_be64(list[i * 4 + 0].dma_addr); |
|---|
| .. | .. |
|---|
| 176 | 174 | goto scatter_gather_clean; |
|---|
| 177 | 175 | } |
|---|
| 178 | 176 | |
|---|
| 179 | | - ((u16 *)info->in_buffer)[0] = req->outcnt; |
|---|
| 180 | | - ((u16 *)info->in_buffer)[1] = req->incnt; |
|---|
| 181 | | - ((u16 *)info->in_buffer)[2] = 0; |
|---|
| 182 | | - ((u16 *)info->in_buffer)[3] = 0; |
|---|
| 183 | | - *(u64 *)info->in_buffer = cpu_to_be64p((u64 *)info->in_buffer); |
|---|
| 177 | + ((__be16 *)info->in_buffer)[0] = cpu_to_be16(req->outcnt); |
|---|
| 178 | + ((__be16 *)info->in_buffer)[1] = cpu_to_be16(req->incnt); |
|---|
| 179 | + ((__be16 *)info->in_buffer)[2] = 0; |
|---|
| 180 | + ((__be16 *)info->in_buffer)[3] = 0; |
|---|
| 184 | 181 | |
|---|
| 185 | 182 | memcpy(&info->in_buffer[8], info->gather_components, |
|---|
| 186 | 183 | g_sz_bytes); |
|---|
| .. | .. |
|---|
| 223 | 220 | return ret; |
|---|
| 224 | 221 | } |
|---|
| 225 | 222 | |
|---|
| 226 | | -int send_cpt_command(struct cpt_vf *cptvf, union cpt_inst_s *cmd, |
|---|
| 223 | +static int send_cpt_command(struct cpt_vf *cptvf, union cpt_inst_s *cmd, |
|---|
| 227 | 224 | u32 qno) |
|---|
| 228 | 225 | { |
|---|
| 229 | 226 | struct pci_dev *pdev = cptvf->pdev; |
|---|
| .. | .. |
|---|
| 270 | 267 | return ret; |
|---|
| 271 | 268 | } |
|---|
| 272 | 269 | |
|---|
| 273 | | -void do_request_cleanup(struct cpt_vf *cptvf, |
|---|
| 270 | +static void do_request_cleanup(struct cpt_vf *cptvf, |
|---|
| 274 | 271 | struct cpt_info_buffer *info) |
|---|
| 275 | 272 | { |
|---|
| 276 | 273 | int i; |
|---|
| .. | .. |
|---|
| 308 | 305 | } |
|---|
| 309 | 306 | } |
|---|
| 310 | 307 | |
|---|
| 311 | | - if (info->scatter_components) |
|---|
| 312 | | - kzfree(info->scatter_components); |
|---|
| 313 | | - |
|---|
| 314 | | - if (info->gather_components) |
|---|
| 315 | | - kzfree(info->gather_components); |
|---|
| 316 | | - |
|---|
| 317 | | - if (info->out_buffer) |
|---|
| 318 | | - kzfree(info->out_buffer); |
|---|
| 319 | | - |
|---|
| 320 | | - if (info->in_buffer) |
|---|
| 321 | | - kzfree(info->in_buffer); |
|---|
| 322 | | - |
|---|
| 323 | | - if (info->completion_addr) |
|---|
| 324 | | - kzfree((void *)info->completion_addr); |
|---|
| 325 | | - |
|---|
| 326 | | - kzfree(info); |
|---|
| 308 | + kfree_sensitive(info->scatter_components); |
|---|
| 309 | + kfree_sensitive(info->gather_components); |
|---|
| 310 | + kfree_sensitive(info->out_buffer); |
|---|
| 311 | + kfree_sensitive(info->in_buffer); |
|---|
| 312 | + kfree_sensitive((void *)info->completion_addr); |
|---|
| 313 | + kfree_sensitive(info); |
|---|
| 327 | 314 | } |
|---|
| 328 | 315 | |
|---|
| 329 | | -void do_post_process(struct cpt_vf *cptvf, struct cpt_info_buffer *info) |
|---|
| 316 | +static void do_post_process(struct cpt_vf *cptvf, struct cpt_info_buffer *info) |
|---|
| 330 | 317 | { |
|---|
| 331 | 318 | struct pci_dev *pdev = cptvf->pdev; |
|---|
| 332 | 319 | |
|---|
| .. | .. |
|---|
| 483 | 470 | vq_cmd.cmd.s.param2 = cpu_to_be16(cpt_req->param2); |
|---|
| 484 | 471 | vq_cmd.cmd.s.dlen = cpu_to_be16(cpt_req->dlen); |
|---|
| 485 | 472 | |
|---|
| 486 | | - /* 64-bit swap for microcode data reads, not needed for addresses*/ |
|---|
| 487 | | - vq_cmd.cmd.u64 = cpu_to_be64(vq_cmd.cmd.u64); |
|---|
| 488 | 473 | vq_cmd.dptr = info->dptr_baddr; |
|---|
| 489 | 474 | vq_cmd.rptr = info->rptr_baddr; |
|---|
| 490 | 475 | vq_cmd.cptr.u64 = 0; |
|---|