blob: 3cdc94e4129d3eca598102143f6df81845160372 [file] [log] [blame]
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07001/*
2 * Freescale Layerscape MC I/O wrapper
3 *
4 * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5 * Author: German Rivera <German.Rivera@freescale.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9/*!
10 * @file fsl_dpbp.h
11 * @brief Data Path Buffer Pool API
12 */
13#ifndef __FSL_DPBP_H
14#define __FSL_DPBP_H
15
16/* DPBP Version */
17#define DPBP_VER_MAJOR 2
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053018#define DPBP_VER_MINOR 1
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070019
20/* Command IDs */
21#define DPBP_CMDID_CLOSE 0x800
22#define DPBP_CMDID_OPEN 0x804
23
24#define DPBP_CMDID_ENABLE 0x002
25#define DPBP_CMDID_DISABLE 0x003
26#define DPBP_CMDID_GET_ATTR 0x004
27#define DPBP_CMDID_RESET 0x005
28
29/* cmd, param, offset, width, type, arg_name */
30#define DPBP_CMD_OPEN(cmd, dpbp_id) \
31 MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
32
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053033/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070034#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
35do { \
36 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
37 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
38 MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
39 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
40} while (0)
41
42/* Data Path Buffer Pool API
43 * Contains initialization APIs and runtime control APIs for DPBP
44 */
45
46struct fsl_mc_io;
47
48/**
49 * dpbp_open() - Open a control session for the specified object.
50 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053051 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070052 * @dpbp_id: DPBP unique ID
53 * @token: Returned token; use in subsequent API calls
54 *
55 * This function can be used to open a control session for an
56 * already created object; an object may have been declared in
57 * the DPL or by calling the dpbp_create function.
58 * This function returns a unique authentication token,
59 * associated with the specific object ID and the specific MC
60 * portal; this token must be used in all subsequent commands for
61 * this specific object
62 *
63 * Return: '0' on Success; Error code otherwise.
64 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053065int dpbp_open(struct fsl_mc_io *mc_io,
66 uint32_t cmd_flags,
67 int dpbp_id,
68 uint16_t *token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070069
70/**
71 * dpbp_close() - Close the control session of the object
72 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053073 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070074 * @token: Token of DPBP object
75 *
76 * After this function is called, no further operations are
77 * allowed on the object without opening a new control session.
78 *
79 * Return: '0' on Success; Error code otherwise.
80 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053081int dpbp_close(struct fsl_mc_io *mc_io,
82 uint32_t cmd_flags,
83 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070084
85/**
86 * dpbp_enable() - Enable the DPBP.
87 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053088 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070089 * @token: Token of DPBP object
90 *
91 * Return: '0' on Success; Error code otherwise.
92 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053093int dpbp_enable(struct fsl_mc_io *mc_io,
94 uint32_t cmd_flags,
95 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070096
97/**
98 * dpbp_disable() - Disable the DPBP.
99 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530100 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700101 * @token: Token of DPBP object
102 *
103 * Return: '0' on Success; Error code otherwise.
104 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530105int dpbp_disable(struct fsl_mc_io *mc_io,
106 uint32_t cmd_flags,
107 uint16_t token);
108
109/**
110 * dpbp_is_enabled() - Check if the DPBP is enabled.
111 * @mc_io: Pointer to MC portal's I/O object
112 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
113 * @token: Token of DPBP object
114 * @en: Returns '1' if object is enabled; '0' otherwise
115 *
116 * Return: '0' on Success; Error code otherwise.
117 */
118int dpbp_is_enabled(struct fsl_mc_io *mc_io,
119 uint32_t cmd_flags,
120 uint16_t token,
121 int *en);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700122
123/**
124 * dpbp_reset() - Reset the DPBP, returns the object to initial state.
125 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530126 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700127 * @token: Token of DPBP object
128 *
129 * Return: '0' on Success; Error code otherwise.
130 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530131int dpbp_reset(struct fsl_mc_io *mc_io,
132 uint32_t cmd_flags,
133 uint16_t token);
134
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700135
136/**
137 * struct dpbp_attr - Structure representing DPBP attributes
138 * @id: DPBP object ID
139 * @version: DPBP version
140 * @bpid: Hardware buffer pool ID; should be used as an argument in
141 * acquire/release operations on buffers
142 */
143struct dpbp_attr {
144 int id;
145 /**
146 * struct version - Structure representing DPBP version
147 * @major: DPBP major version
148 * @minor: DPBP minor version
149 */
150 struct {
151 uint16_t major;
152 uint16_t minor;
153 } version;
154 uint16_t bpid;
155};
156
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700157/**
158 * dpbp_get_attributes - Retrieve DPBP attributes.
159 *
160 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530161 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700162 * @token: Token of DPBP object
163 * @attr: Returned object's attributes
164 *
165 * Return: '0' on Success; Error code otherwise.
166 */
167int dpbp_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530168 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700169 uint16_t token,
170 struct dpbp_attr *attr);
171
172/** @} */
173
174#endif /* __FSL_DPBP_H */