blob: 8624442f643be8e0423133b71f8f7032449fe87d [file] [log] [blame]
Sagar Gore8d91a622017-02-23 14:57:18 -08001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _CAM_REQ_MGR_UTIL_PRIV_H_
14#define _CAM_REQ_MGR_UTIL_PRIV_H_
15
16/**
17 * handle format:
18 * @bits (0-7): handle index
19 * @bits (8-11): handle type
20 * @bits (12-15): reserved
21 * @bits (16-23): random bits
22 * @bits (24-31): zeros
23 */
24
25#define CAM_REQ_MGR_HDL_SIZE 32
26#define CAM_REQ_MGR_RND1_SIZE 8
27#define CAM_REQ_MGR_RVD_SIZE 4
28#define CAM_REQ_MGR_HDL_TYPE_SIZE 4
29#define CAM_REQ_MGR_HDL_IDX_SIZE 8
30
31#define CAM_REQ_MGR_RND1_POS 24
32#define CAM_REQ_MGR_RVD_POS 16
33#define CAM_REQ_MGR_HDL_TYPE_POS 12
34
35#define CAM_REQ_MGR_RND1_BYTES 1
36
37#define CAM_REQ_MGR_HDL_TYPE_MASK ((1 << CAM_REQ_MGR_HDL_TYPE_SIZE) - 1)
38
39#define GET_DEV_HANDLE(rnd1, type, idx) \
40 ((rnd1 << (CAM_REQ_MGR_RND1_POS - CAM_REQ_MGR_RND1_SIZE)) | \
41 (0x0 << (CAM_REQ_MGR_RVD_POS - CAM_REQ_MGR_RVD_SIZE)) | \
42 (type << (CAM_REQ_MGR_HDL_TYPE_POS - CAM_REQ_MGR_HDL_TYPE_SIZE)) | \
43 (idx << (CAM_REQ_MGR_HDL_IDX_POS - CAM_REQ_MGR_HDL_IDX_SIZE))) \
44
45#define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK)
46#define CAM_REQ_MGR_GET_HDL_TYPE(hdl) \
47 ((hdl >> CAM_REQ_MGR_HDL_IDX_POS) & CAM_REQ_MGR_HDL_TYPE_MASK)
48
49#endif