Imported Upstream version 16.07-rc1
[deb_dpdk.git] / drivers / net / qede / base / ecore_cxt_api.h
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #ifndef __ECORE_CXT_API_H__
10 #define __ECORE_CXT_API_H__
11
12 struct ecore_hwfn;
13
14 struct ecore_cxt_info {
15         void *p_cxt;
16         u32 iid;
17         enum protocol_type type;
18 };
19
20 #define MAX_TID_BLOCKS                  512
21 struct ecore_tid_mem {
22         u32 tid_size;
23         u32 num_tids_per_block;
24         u32 waste;
25         u8 *blocks[MAX_TID_BLOCKS];     /* 4K */
26 };
27
28 static OSAL_INLINE void *get_task_mem(struct ecore_tid_mem *info, u32 tid)
29 {
30         /* note: waste is superfluous */
31         return (void *)(info->blocks[tid / info->num_tids_per_block] +
32                         (tid % info->num_tids_per_block) * info->tid_size);
33
34         /* more elaborate alternative with no modulo
35          * u32 mask = info->tid_size * info->num_tids_per_block +
36          *            info->waste - 1;
37          * u32 index = tid / info->num_tids_per_block;
38          * u32 offset = tid * info->tid_size + index * info->waste;
39          * return (void *)(blocks[index] + (offset & mask));
40          */
41 }
42
43 /**
44 * @brief ecore_cxt_acquire - Acquire a new cid of a specific protocol type
45 *
46 * @param p_hwfn
47 * @param type
48 * @param p_cid
49 *
50 * @return enum _ecore_status_t
51 */
52 enum _ecore_status_t ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
53                                            enum protocol_type type,
54                                            u32 *p_cid);
55
56 /**
57 * @brief ecoreo_cid_get_cxt_info - Returns the context info for a specific cid
58 *
59 *
60 * @param p_hwfn
61 * @param p_info in/out
62 *
63 * @return enum _ecore_status_t
64 */
65 enum _ecore_status_t ecore_cxt_get_cid_info(struct ecore_hwfn *p_hwfn,
66                                             struct ecore_cxt_info *p_info);
67
68 /**
69 * @brief ecore_cxt_get_tid_mem_info
70 *
71 * @param p_hwfn
72 * @param p_info
73 *
74 * @return enum _ecore_status_t
75 */
76 enum _ecore_status_t ecore_cxt_get_tid_mem_info(struct ecore_hwfn *p_hwfn,
77                                                 struct ecore_tid_mem *p_info);
78
79 #endif