xref: /titanic_41/usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/device/context.h (revision f391a51a4e9639750045473dba1cc2831267c93e)
1 #ifndef __CONTEXT_H
2 #define __CONTEXT_H
3 /*
4 functions for managing Chip per-connection context
5 */
6 #include "lm5710.h"
7 
8 #define CONN_ID_INVALID                            (0xFFFFFFFF)
9 
10 #define LM_CONN_MAX_FUNC(_pdev,_conn)             (((_pdev)->context_info->proto_end[_conn]- \
11                                                     (_pdev)->context_info->proto_start[_conn]) + 1)
12 
13 #define LM_CONN_BASE(_pdev,_conn)               ((_pdev)->context_info->proto_start[_conn])
14 
15 /* returns a pionter to a connections chip context*/
16 void * lm_get_context(struct _lm_device_t *pdev, u32_t cid);
17 
18 /* same as above but returns phys address in 64 bit pointer */
19 u64_t lm_get_context_phys(struct _lm_device_t *pdev, u32_t cid);
20 
21 /* context pool initializer and release functions */
22 lm_status_t lm_alloc_context_pool(struct _lm_device_t *pdev);
23 lm_status_t lm_setup_context_pool(struct _lm_device_t *pdev);
24 void lm_release_context_pool(struct _lm_device_t *pdev);
25 
26 typedef struct _lm_4tuple_t {
27     u32_t src_ip[4]; /* in host order */
28     u32_t dst_ip[4]; /* in host order */
29 
30     u8_t ip_type;
31     #define LM_IP_TYPE_V4   1
32     #define LM_IP_TYPE_V6   2
33 
34     u16_t dst_port; /* in host order */
35     u16_t src_port; /* in host order */
36 } lm_4tuple_t;
37 
38 /* allocate a free context by type
39    returns CID or -1 if none are avaliable
40    takes the list spinlock */
41 lm_status_t lm_allocate_cid(struct _lm_device_t *pdev, u32_t type, void * cookie, s32_t * cid);
42 
43 /* returns the size of a context */
44 lm_status_t lm_get_context_size(struct _lm_device_t *pdev, s32_t * context_size);
45 
46 
47 /**
48  * sets the CDU validation data to be valid for a given cid
49  *
50  * @param pdev - the physical device handle
51  * @param cid - the context of this cid will be initialized with the cdu validataion data
52  * @param invalidate - the cdu-validation data can be set, and it can be invalidated... this parameters
53  *                   determines which it is.
54  * @return lm_status_t
55  */
56 lm_status_t lm_set_cdu_validation_data(struct _lm_device_t *pdev, s32_t cid, u8_t invalidate);
57 
58 /* free a context
59    takes the list spinlock */
60 void lm_free_cid(struct _lm_device_t *pdev, u32_t type, u32_t cid, u8_t notify_fw);
61 
62 /* inserts 4 tuple to SRC mirror hash
63    to be called after lm_allocate_cid and before init offload ramrod
64    returns failure if hash is full
65    takes the CID lock */
66 lm_status_t lm_searcher_mirror_hash_insert(struct _lm_device_t *pdev, u32_t cid, lm_4tuple_t *tuple);
67 
68 /* removes 4 tuple to SRC mirror hash
69    to be called after cfc del ramrod completion and before lm_recycle_cid
70    takes the CID lock */
71 void lm_searcher_mirror_hash_remove(struct _lm_device_t *pdev, u32_t cid);
72 
73 /* lookup the protocol cookie for a given CID
74    does not take a lock
75    will assert if the CID is not allocated */
76 void * lm_cid_cookie(struct _lm_device_t *pdev, u32_t type, u32_t cid);
77 
78 /* lookup the protocol cid_resc for a given CID
79    does not take a lock
80    will DbgBreakIf( if the CID is not allocated */
81 lm_cid_resc_t * lm_cid_resc(struct _lm_device_t *pdev, u32_t cid);
82 
83 /* Find the protocol that 'cid' belongs to. */
84 u8_t lm_map_cid_to_proto(struct _lm_device_t * pdev, u32_t cid);
85 
86 void lm_init_connection_context(struct _lm_device_t *pdev, u32_t const sw_cid, u8_t sb_id);
87 
88 void lm_recycle_cid(struct _lm_device_t *pdev, u32_t cid);
89 
90 lm_status_t lm_set_cid_resc(struct _lm_device_t *pdev, u32_t type, void *cookie, u32_t cid);
91 
92 lm_status_t lm_free_cid_resc(struct _lm_device_t *pdev, u32_t type, u32_t cid, u8_t notify_fw);
93 
94 /* lookup the slow path request manager from within
95    the protocol cid_resc for a given CID
96    does not take a lock
97    will DbgBreakIf( if the CID is not allocated */
98 lm_sp_req_manager_t *lm_cid_sp_req_mgr(struct _lm_device_t *pdev, u32_t cid);
99 
100 typedef enum {
101     LM_CID_STATE_VALID,
102     LM_CID_STATE_PENDING,
103     LM_CID_STATE_ERROR
104 } lm_cid_state_enum;
105 
106 lm_cid_state_enum
107 lm_cid_state(
108     IN struct _lm_device_t *pdev,
109     IN u32_t cid
110     );
111 
112 lm_status_t
113 lm_set_cid_state(
114     IN struct _lm_device_t *pdev,
115     IN u32_t cid,
116     IN lm_cid_state_enum state
117     );
118 
119 
120 void lm_cid_recycled_cb_register(struct _lm_device_t *pdev, u8_t type, lm_cid_recycled_cb_t cb);
121 
122 void lm_cid_recycled_cb_deregister(struct _lm_device_t *pdev, u8_t type);
123 
124 lm_status_t lm_set_con_state(struct _lm_device_t *pdev, u32_t cid, u32_t state);
125 
126 u32_t lm_get_con_state(struct _lm_device_t *pdev, u32_t cid);
127 
128 #endif /* __CONTEXT_H */
129 
130 
131