1 /***********************license start***************
2 * Copyright (c) 2003-2010 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 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
49 * Interface to RAID block. This is not available on all chips.
51 * <hr>$Revision: 49448 $<hr>
53 #include "executive-config.h"
54 #include "cvmx-config.h"
56 #include "cvmx-cmd-queue.h"
57 #include "cvmx-raid.h"
59 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
62 * Initialize the RAID block
64 * @param polynomial Coefficients for the RAID polynomial
66 * @return Zero on success, negative on failure
68 int cvmx_raid_initialize(cvmx_rad_reg_polynomial_t polynomial)
70 cvmx_cmd_queue_result_t result;
71 cvmx_rad_reg_cmd_buf_t rad_reg_cmd_buf;
73 cvmx_write_csr(CVMX_RAD_REG_POLYNOMIAL, polynomial.u64);
75 result = cvmx_cmd_queue_initialize(CVMX_CMD_QUEUE_RAID, 0,
76 CVMX_FPA_OUTPUT_BUFFER_POOL,
77 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE);
78 if (result != CVMX_CMD_QUEUE_SUCCESS)
81 rad_reg_cmd_buf.u64 = 0;
82 rad_reg_cmd_buf.s.dwb = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/128;
83 rad_reg_cmd_buf.s.pool = CVMX_FPA_OUTPUT_BUFFER_POOL;
84 rad_reg_cmd_buf.s.size = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/8;
85 rad_reg_cmd_buf.s.ptr = cvmx_ptr_to_phys(cvmx_cmd_queue_buffer(CVMX_CMD_QUEUE_RAID))>>7;
86 cvmx_write_csr(CVMX_RAD_REG_CMD_BUF, rad_reg_cmd_buf.u64);
92 * Shutdown the RAID block. RAID must be idle when
93 * this function is called.
95 * @return Zero on success, negative on failure
97 int cvmx_raid_shutdown(void)
99 cvmx_rad_reg_ctl_t rad_reg_ctl;
101 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_RAID))
103 cvmx_dprintf("ERROR: cvmx_raid_shutdown: RAID not idle.\n");
107 rad_reg_ctl.u64 = cvmx_read_csr(CVMX_RAD_REG_CTL);
108 rad_reg_ctl.s.reset = 1;
109 cvmx_write_csr(CVMX_RAD_REG_CTL, rad_reg_ctl.u64);
112 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_RAID);
113 cvmx_write_csr(CVMX_RAD_REG_CMD_BUF, 0);
119 * Submit a command to the RAID block
121 * @param num_words Number of command words to submit
122 * @param words Command words
124 * @return Zero on success, negative on failure
126 int cvmx_raid_submit(int num_words, cvmx_raid_word_t words[])
128 cvmx_cmd_queue_result_t result = cvmx_cmd_queue_write(CVMX_CMD_QUEUE_RAID, 1, num_words, (uint64_t *)words);
129 if (result == CVMX_CMD_QUEUE_SUCCESS)
130 cvmx_write_csr(CVMX_ADDR_DID(CVMX_FULL_DID(14, 0)), num_words);