-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathchip_if.h
More file actions
217 lines (193 loc) · 4.87 KB
/
chip_if.h
File metadata and controls
217 lines (193 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
* Copyright 2022 Morse Micro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#ifndef _MORSE_CHIP_IF_H_
#define _MORSE_CHIP_IF_H_
#include "pageset.h"
#include "pager_hw.h"
#include "yaps.h"
#include "yaps_hw.h"
#define MORSE_PAGER_BYPASS_TX_STATUS_FIFO_DEPTH (4)
#define MORSE_PAGER_BYPASS_CMD_RESP_FIFO_DEPTH (2)
enum morse_chip_if_flags {
MORSE_CHIP_IF_FLAGS_DIR_TO_HOST = BIT(0),
MORSE_CHIP_IF_FLAGS_DIR_TO_CHIP = BIT(1),
MORSE_CHIP_IF_FLAGS_COMMAND = BIT(2),
/* Note: There is no support for beacon-specific pagesets yet */
MORSE_CHIP_IF_FLAGS_BEACON = BIT(3),
MORSE_CHIP_IF_FLAGS_DATA = BIT(4)
};
enum morse_chip_if {
MORSE_CHIP_IF_PAGESET,
MORSE_CHIP_IF_YAPS
};
/** Event flags for talking to chip interface from skbq or pager */
enum morse_chip_if_event_flags {
MORSE_RX_PEND,
MORSE_PAGE_RETURN_PEND,
MORSE_TX_COMMAND_PEND,
MORSE_TX_BEACON_PEND,
MORSE_TX_MGMT_PEND,
MORSE_TX_DATA_PEND,
MORSE_TX_PACKET_FREED_UP_PEND,
MORSE_DATA_TRAFFIC_PAUSE_PEND,
MORSE_DATA_TRAFFIC_RESUME_PEND,
MORSE_UPDATE_HW_CLOCK_REFERENCE,
};
struct chip_if_ops {
/**
* Initialises the chip interface
*
* @mors: Morse chip struct
*
* @return: Error code
*/
int (*init)(struct morse *mors);
/**
* Initialises the chip interface after hardware restart
*
* @mors: Morse chip struct
*
* @return: Error code
*/
int (*hw_restarted)(struct morse *mors);
/**
* Flush all tx data queues.
*
* @mors: Morse chip struct
*/
void (*flush_tx_data)(struct morse *mors);
/**
* Flush all cmd queues.
*
* @mors: Morse chip struct
*/
void (*flush_cmds)(struct morse *mors);
/**
* Flush all buffers that may have been cached in the chip interface.
*
* @mors: Morse chip struct
*/
void (*flush_cache)(struct morse *mors);
/**
* Cleans up chip interface.
*
* @mors: Morse chip struct
*/
void (*finish)(struct morse *mors);
/**
* Prepare chip interface for Linux host suspend
*
* @mors: Morse chip struct
*/
void (*suspend)(struct morse *mors);
/**
* Linux host has resumed from suspend. Pair with @ref suspend
*
* @mors: Morse chip struct
*/
void (*resume)(struct morse *mors);
/**
* Gets a pointer to the tx queue array and the number of items in the array.
* @mors: Morse object
* @qs: Pointer to store pointer to queue array
* @num_qs: Pointer to store count of items in queue array
*/
void (*skbq_get_tx_qs)(struct morse *mors, struct morse_skbq **qs, int *num_qs);
/**
* Gets the command skbq
* @mors: Morse object
*
* @returns command skbq
*/
struct morse_skbq *(*skbq_cmd_tc_q)(struct morse *mors);
/**
* Gets the beacon skbq
* @mors: Morse object
*
* @returns beacon skbq
*/
struct morse_skbq *(*skbq_bcn_tc_q)(struct morse *mors);
/**
* Gets the mgmt skbq
* @mors: Morse object
*
* @returns mgmt skbq
*/
struct morse_skbq *(*skbq_mgmt_tc_q)(struct morse *mors);
/**
* Gets the tx skbq associated with given aci
* @mors: Morse object
* @aci: access category
*
* @returns skbq for skbs of given aci
*/
struct morse_skbq *(*skbq_tc_q_from_aci)(struct morse *mors, int aci);
/**
* A callback that is called when a hostsync interrupt is raised
* @mors: Morse object
* @status: Hostsync interrupt register (bitmask of hostsync IRQs)
*
* @returns 0 if successful, otherwise error code
*/
int (*chip_if_handle_irq)(struct morse *mors, u32 status);
/**
* Counts the total number of TX SKBs across all the queue types
* contained in the chip interface object. It includes the SKBs yet to
* be sent, and the SKBs that are awaiting a status return from the chip.
* @mors: Morse object
*
* @returns count
*/
int (*skbq_get_tx_buffered_count)(struct morse *mors);
/**
* Counts the total number of TX SKBs that are pending a status return
* from the chip across all the queue types contained in the chip interface
* object.
* @mors: Morse object
*
* @returns count
*/
int (*skbq_get_tx_status_pending_count)(struct morse *mors);
};
struct morse_chip_if_state {
enum morse_chip_if active_chip_if;
union {
struct {
int pager_count;
struct morse_pager *pagers;
int pageset_count;
struct morse_pageset *pagesets;
struct morse_pageset *to_chip_pageset;
struct morse_pageset *from_chip_pageset;
struct {
struct {
u32 location;
DECLARE_KFIFO(to_process, u32,
MORSE_PAGER_BYPASS_TX_STATUS_FIFO_DEPTH);
} tx_sts;
struct {
u32 location;
DECLARE_KFIFO(to_process, u32,
MORSE_PAGER_BYPASS_CMD_RESP_FIFO_DEPTH);
} cmd_resp;
} bypass;
struct morse_pager_pkt_memory pkt_memory;
u32 headless_cfg_addr;
};
struct {
struct morse_yaps *yaps;
};
};
/* See enum morse_chip_if_event_flags for values */
unsigned long event_flags;
bool validate_skb_checksum;
};
struct morse_chip_if_host_table {
u32 pager_count;
struct morse_pager_hw_entry pager_table[];
} __packed;
#endif /* !_MORSE_CHIP_IF_H_ */