1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * Interface to RAID block. This is not available on all chips.
49 * <hr>$Revision: 41586 $<hr>
51 #include "executive-config.h"
52 #include "cvmx-config.h"
54 #include "cvmx-cmd-queue.h"
55 #include "cvmx-raid.h"
57 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
60 * Initialize the RAID block
62 * @param polynomial Coefficients for the RAID polynomial
64 * @return Zero on success, negative on failure
66 int cvmx_raid_initialize(cvmx_rad_reg_polynomial_t polynomial)
68 cvmx_cmd_queue_result_t result;
69 cvmx_rad_reg_cmd_buf_t rad_reg_cmd_buf;
71 cvmx_write_csr(CVMX_RAD_REG_POLYNOMIAL, polynomial.u64);
73 result = cvmx_cmd_queue_initialize(CVMX_CMD_QUEUE_RAID, 0,
74 CVMX_FPA_OUTPUT_BUFFER_POOL,
75 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE);
76 if (result != CVMX_CMD_QUEUE_SUCCESS)
79 rad_reg_cmd_buf.u64 = 0;
80 rad_reg_cmd_buf.s.dwb = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/128;
81 rad_reg_cmd_buf.s.pool = CVMX_FPA_OUTPUT_BUFFER_POOL;
82 rad_reg_cmd_buf.s.size = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/8;
83 rad_reg_cmd_buf.s.ptr = cvmx_ptr_to_phys(cvmx_cmd_queue_buffer(CVMX_CMD_QUEUE_RAID))>>7;
84 cvmx_write_csr(CVMX_RAD_REG_CMD_BUF, rad_reg_cmd_buf.u64);
90 * Shutdown the RAID block. RAID must be idle when
91 * this function is called.
93 * @return Zero on success, negative on failure
95 int cvmx_raid_shutdown(void)
97 cvmx_rad_reg_ctl_t rad_reg_ctl;
99 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_RAID))
101 cvmx_dprintf("ERROR: cvmx_raid_shutdown: RAID not idle.\n");
105 rad_reg_ctl.u64 = cvmx_read_csr(CVMX_RAD_REG_CTL);
106 rad_reg_ctl.s.reset = 1;
107 cvmx_write_csr(CVMX_RAD_REG_CTL, rad_reg_ctl.u64);
110 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_RAID);
111 cvmx_write_csr(CVMX_RAD_REG_CMD_BUF, 0);
117 * Submit a command to the RAID block
119 * @param num_words Number of command words to submit
120 * @param words Command words
122 * @return Zero on success, negative on failure
124 int cvmx_raid_submit(int num_words, cvmx_raid_word_t words[])
126 cvmx_cmd_queue_result_t result = cvmx_cmd_queue_write(CVMX_CMD_QUEUE_RAID, 1, num_words, (uint64_t *)words);
127 if (result == CVMX_CMD_QUEUE_SUCCESS)
128 cvmx_write_csr(CVMX_ADDR_DID(CVMX_FULL_DID(14, 0)), num_words);