xref: /dpdk/drivers/bus/dpaa/base/qbman/dpaa_alloc.c (revision c47ff048b99ac88349b0796dbde9d1f0bf0653da)
1*c47ff048SShreyansh Jain /*-
2*c47ff048SShreyansh Jain  * This file is provided under a dual BSD/GPLv2 license. When using or
3*c47ff048SShreyansh Jain  * redistributing this file, you may do so under either license.
4*c47ff048SShreyansh Jain  *
5*c47ff048SShreyansh Jain  *   BSD LICENSE
6*c47ff048SShreyansh Jain  *
7*c47ff048SShreyansh Jain  * Copyright 2009-2016 Freescale Semiconductor Inc.
8*c47ff048SShreyansh Jain  * Copyright 2017 NXP.
9*c47ff048SShreyansh Jain  *
10*c47ff048SShreyansh Jain  * Redistribution and use in source and binary forms, with or without
11*c47ff048SShreyansh Jain  * modification, are permitted provided that the following conditions are met:
12*c47ff048SShreyansh Jain  * * Redistributions of source code must retain the above copyright
13*c47ff048SShreyansh Jain  * notice, this list of conditions and the following disclaimer.
14*c47ff048SShreyansh Jain  * * Redistributions in binary form must reproduce the above copyright
15*c47ff048SShreyansh Jain  * notice, this list of conditions and the following disclaimer in the
16*c47ff048SShreyansh Jain  * documentation and/or other materials provided with the distribution.
17*c47ff048SShreyansh Jain  * * Neither the name of the above-listed copyright holders nor the
18*c47ff048SShreyansh Jain  * names of any contributors may be used to endorse or promote products
19*c47ff048SShreyansh Jain  * derived from this software without specific prior written permission.
20*c47ff048SShreyansh Jain  *
21*c47ff048SShreyansh Jain  *   GPL LICENSE SUMMARY
22*c47ff048SShreyansh Jain  *
23*c47ff048SShreyansh Jain  * ALTERNATIVELY, this software may be distributed under the terms of the
24*c47ff048SShreyansh Jain  * GNU General Public License ("GPL") as published by the Free Software
25*c47ff048SShreyansh Jain  * Foundation, either version 2 of that License or (at your option) any
26*c47ff048SShreyansh Jain  * later version.
27*c47ff048SShreyansh Jain  *
28*c47ff048SShreyansh Jain  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29*c47ff048SShreyansh Jain  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30*c47ff048SShreyansh Jain  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31*c47ff048SShreyansh Jain  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32*c47ff048SShreyansh Jain  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33*c47ff048SShreyansh Jain  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34*c47ff048SShreyansh Jain  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35*c47ff048SShreyansh Jain  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36*c47ff048SShreyansh Jain  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37*c47ff048SShreyansh Jain  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38*c47ff048SShreyansh Jain  * POSSIBILITY OF SUCH DAMAGE.
39*c47ff048SShreyansh Jain  */
40*c47ff048SShreyansh Jain 
41*c47ff048SShreyansh Jain #include "dpaa_sys.h"
42*c47ff048SShreyansh Jain #include <process.h>
43*c47ff048SShreyansh Jain #include <fsl_qman.h>
44*c47ff048SShreyansh Jain 
45*c47ff048SShreyansh Jain int qman_alloc_fqid_range(u32 *result, u32 count, u32 align, int partial)
46*c47ff048SShreyansh Jain {
47*c47ff048SShreyansh Jain 	return process_alloc(dpaa_id_fqid, result, count, align, partial);
48*c47ff048SShreyansh Jain }
49*c47ff048SShreyansh Jain 
50*c47ff048SShreyansh Jain void qman_release_fqid_range(u32 fqid, u32 count)
51*c47ff048SShreyansh Jain {
52*c47ff048SShreyansh Jain 	process_release(dpaa_id_fqid, fqid, count);
53*c47ff048SShreyansh Jain }
54*c47ff048SShreyansh Jain 
55*c47ff048SShreyansh Jain int qman_reserve_fqid_range(u32 fqid, unsigned int count)
56*c47ff048SShreyansh Jain {
57*c47ff048SShreyansh Jain 	return process_reserve(dpaa_id_fqid, fqid, count);
58*c47ff048SShreyansh Jain }
59*c47ff048SShreyansh Jain 
60*c47ff048SShreyansh Jain int qman_alloc_pool_range(u32 *result, u32 count, u32 align, int partial)
61*c47ff048SShreyansh Jain {
62*c47ff048SShreyansh Jain 	return process_alloc(dpaa_id_qpool, result, count, align, partial);
63*c47ff048SShreyansh Jain }
64*c47ff048SShreyansh Jain 
65*c47ff048SShreyansh Jain void qman_release_pool_range(u32 pool, u32 count)
66*c47ff048SShreyansh Jain {
67*c47ff048SShreyansh Jain 	process_release(dpaa_id_qpool, pool, count);
68*c47ff048SShreyansh Jain }
69*c47ff048SShreyansh Jain 
70*c47ff048SShreyansh Jain int qman_reserve_pool_range(u32 pool, u32 count)
71*c47ff048SShreyansh Jain {
72*c47ff048SShreyansh Jain 	return process_reserve(dpaa_id_qpool, pool, count);
73*c47ff048SShreyansh Jain }
74*c47ff048SShreyansh Jain 
75*c47ff048SShreyansh Jain int qman_alloc_cgrid_range(u32 *result, u32 count, u32 align, int partial)
76*c47ff048SShreyansh Jain {
77*c47ff048SShreyansh Jain 	return process_alloc(dpaa_id_cgrid, result, count, align, partial);
78*c47ff048SShreyansh Jain }
79*c47ff048SShreyansh Jain 
80*c47ff048SShreyansh Jain void qman_release_cgrid_range(u32 cgrid, u32 count)
81*c47ff048SShreyansh Jain {
82*c47ff048SShreyansh Jain 	process_release(dpaa_id_cgrid, cgrid, count);
83*c47ff048SShreyansh Jain }
84*c47ff048SShreyansh Jain 
85*c47ff048SShreyansh Jain int qman_reserve_cgrid_range(u32 cgrid, u32 count)
86*c47ff048SShreyansh Jain {
87*c47ff048SShreyansh Jain 	return process_reserve(dpaa_id_cgrid, cgrid, count);
88*c47ff048SShreyansh Jain }
89