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**************************************/
39 /*------------------------------------------------------------------
40 * octeon_ipd.c Input Packet Unit
42 *------------------------------------------------------------------
45 #include <sys/cdefs.h>
46 __FBSDID("$FreeBSD$");
48 #include <sys/param.h>
49 #include <sys/systm.h>
51 #include <mips/cavium/octeon_pcmap_regs.h>
52 #include "octeon_ipd.h"
59 void octeon_ipd_enable (void)
61 octeon_ipd_ctl_status_t octeon_ipd_reg;
63 octeon_ipd_reg.word64 = oct_read64(OCTEON_IPD_CTL_STATUS);
64 octeon_ipd_reg.bits.ipd_en = 1;
65 oct_write64(OCTEON_IPD_CTL_STATUS, octeon_ipd_reg.word64);
74 void octeon_ipd_disable (void)
76 octeon_ipd_ctl_status_t octeon_ipd_reg;
78 octeon_ipd_reg.word64 = oct_read64(OCTEON_IPD_CTL_STATUS);
79 octeon_ipd_reg.bits.ipd_en = 0;
80 oct_write64(OCTEON_IPD_CTL_STATUS, octeon_ipd_reg.word64);
89 * mbuff_size Packets buffer size in 8 byte words
91 * Number of 8 byte words to skip in the first buffer
92 * not_first_mbuff_skip
93 * Number of 8 byte words to skip in each following buffer
94 * first_back Must be same as first_mbuff_skip / Cache_Line_size
96 * Must be same as not_first_mbuff_skip / Cache_Line_Size
98 * FPA pool to get work entries from
100 * back_pres_enable_flag
101 * Enable or disable port back pressure
103 void octeon_ipd_config (u_int mbuff_size,
104 u_int first_mbuff_skip,
105 u_int not_first_mbuff_skip,
109 octeon_ipd_mode_t cache_mode,
110 u_int back_pres_enable_flag)
112 octeon_ipd_mbuff_first_skip_t first_skip;
113 octeon_ipd_mbuff_not_first_skip_t not_first_skip;
114 octeon_ipd_mbuff_size_t size;
115 octeon_ipd_first_next_ptr_back_t first_back_struct;
116 octeon_ipd_second_next_ptr_back_t second_back_struct;
117 octeon_ipd_wqe_fpa_pool_t wqe_pool;
118 octeon_ipd_ctl_status_t octeon_ipd_ctl_reg;
120 first_skip.word64 = 0;
121 first_skip.bits.skip_sz = first_mbuff_skip;
122 oct_write64(OCTEON_IPD_1ST_MBUFF_SKIP, first_skip.word64);
124 not_first_skip.word64 = 0;
125 not_first_skip.bits.skip_sz = not_first_mbuff_skip;
126 oct_write64(OCTEON_IPD_NOT_1ST_MBUFF_SKIP, not_first_skip.word64);
129 size.bits.mb_size = mbuff_size;
130 oct_write64(OCTEON_IPD_PACKET_MBUFF_SIZE, size.word64);
132 first_back_struct.word64 = 0;
133 first_back_struct.bits.back = first_back;
134 oct_write64(OCTEON_IPD_1ST_NEXT_PTR_BACK, first_back_struct.word64);
136 second_back_struct.word64 = 0;
137 second_back_struct.bits.back = second_back;
138 oct_write64(OCTEON_IPD_2ND_NEXT_PTR_BACK, second_back_struct.word64);
141 wqe_pool.bits.wqe_pool = wqe_fpa_pool;
142 oct_write64(OCTEON_IPD_WQE_FPA_QUEUE, wqe_pool.word64);
144 octeon_ipd_ctl_reg.word64 = 0;
145 octeon_ipd_ctl_reg.bits.opc_mode = cache_mode;
146 octeon_ipd_ctl_reg.bits.pbp_en = back_pres_enable_flag;
147 oct_write64(OCTEON_IPD_CTL_STATUS, octeon_ipd_ctl_reg.word64);