1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Freescale Layerscape MC I/O wrapper
4  * Data Path Buffer Pool API
5  *  Contains initialization APIs and runtime control APIs for DPBP
6  *
7  * Copyright 2013-2016 Freescale Semiconductor, Inc.
8  * Copyright 2017-2023 NXP
9  */
10 
11 #ifndef __FSL_DPBP_H
12 #define __FSL_DPBP_H
13 
14 /* DPBP Version */
15 #define DPBP_VER_MAJOR				3
16 #define DPBP_VER_MINOR				3
17 
18 /* Command IDs */
19 #define DPBP_CMDID_CLOSE				0x8001
20 #define DPBP_CMDID_OPEN					0x8041
21 #define DPBP_CMDID_CREATE				0x9041
22 #define DPBP_CMDID_DESTROY				0x9841
23 #define DPBP_CMDID_GET_API_VERSION			0xa041
24 
25 #define DPBP_CMDID_ENABLE				0x0021
26 #define DPBP_CMDID_DISABLE				0x0031
27 #define DPBP_CMDID_GET_ATTR				0x0041
28 #define DPBP_CMDID_RESET				0x0051
29 
30 #pragma pack(push, 1)
31 
32 struct dpbp_cmd_open {
33 	__le32 dpbp_id;
34 };
35 
36 struct dpbp_cmd_destroy {
37 	__le32 object_id;
38 };
39 
40 struct dpbp_rsp_get_attributes {
41 	__le16 pad;
42 	__le16 bpid;
43 	__le32 id;
44 };
45 
46 #pragma pack(pop)
47 
48 struct fsl_mc_io;
49 
50 int dpbp_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpbp_id, u16 *token);
51 
52 int dpbp_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
53 
54 /**
55  * struct dpbp_cfg - Structure representing DPBP configuration
56  * @options:	place holder
57  */
58 struct dpbp_cfg {
59 	u32 options;
60 };
61 
62 int dpbp_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
63 		const struct dpbp_cfg *cfg, u32 *obj_id);
64 
65 int dpbp_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
66 		 u32 obj_id);
67 
68 int dpbp_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
69 
70 int dpbp_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
71 
72 int dpbp_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
73 
74 /**
75  * struct dpbp_attr - Structure representing DPBP attributes
76  * @id:		DPBP object ID
77  * @version:	DPBP version
78  * @bpid:	Hardware buffer pool ID; should be used as an argument in
79  *		acquire/release operations on buffers
80  */
81 struct dpbp_attr {
82 	u32 id;
83 	u16 bpid;
84 };
85 
86 int dpbp_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
87 			struct dpbp_attr *attr);
88 
89 int dpbp_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
90 			 u16 *major_ver, u16 *minor_ver);
91 
92 #endif /* __FSL_DPBP_H */
93