-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpageset.h
More file actions
167 lines (141 loc) · 4.46 KB
/
pageset.h
File metadata and controls
167 lines (141 loc) · 4.46 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
#ifndef _MORSE_PAGESET_H_
#define _MORSE_PAGESET_H_
/*
* Copyright 2017-2022 Morse Micro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#include <linux/skbuff.h>
#include <linux/workqueue.h>
#include <linux/kfifo.h>
#include <linux/types.h>
#include "skbq.h"
#include "pager_if.h"
#include "chip_if.h"
#include "pageset_trace.h"
/*
* A pageset uses a pair of pagers to implement the paging system
* for transferring messages and data between the host and chip.
* This module handles data from network queues on one end and multiple
* pager interfaces on the other end.
*
* Paging works by requesting a page from the chip,
* filling the page location on chip with data, then passing the page
* back to the chip through a different pager. The reverse is true for rx.
*
* Typically one pageset would be used for chip to host communication and
* a separate one would be used for host to chip communication.
*/
/* Number of HOST->CHIP pages to reserve for commands and beacons to avoid starvation */
#define CMD_RSVED_PAGES_MAX 2
/** Must be power ^2 and >= CMD_RSVED_PAGES_MAX */
#define CMD_RSVED_KFIFO_LEN 2
/* Number of HOST->CHIP pages to reserve exclusively for commands to avoid starvation */
#define CMD_RSVED_CMD_PAGES_MAX 1
/**
* Number of CHIP->HOST returned pages to cache in the host to speed up TX
*
* Nominally, this should be >= the amount of pages allocated to the
* FROM_HOST pager
*/
#define CACHED_PAGES_MAX 32
/** Must be power ^2 and >= CACHED_PAGES_MAX */
#define CACHED_PAGES_KFIFO_LEN 32
/**
* Number of TX queues used to store different priority packets
*
* Nominally, this should be equal to the number of QoS queues the chip supports
*
*/
#define PAGESET_TX_SKBQ_MAX 4
extern const struct chip_if_ops morse_pageset_hw_ops;
extern const struct chip_if_ops morse_pageset_sw_ops;
struct morse_page {
u32 addr; /* Address of page in chip memory */
u32 size_bytes; /* Number of bytes in the page */
};
struct morse_pager_pkt_memory {
u32 base_addr;
u16 page_len;
u8 page_len_reserved;
u8 num;
};
struct morse_pageset {
struct morse *mors;
struct morse_skbq data_qs[PAGESET_TX_SKBQ_MAX];
struct morse_skbq beacon_q;
struct morse_skbq mgmt_q;
struct morse_skbq cmd_q;
unsigned long access_lock;
u8 flags;
struct morse_pager *populated_pager;
struct morse_pager *return_pager;
DECLARE_KFIFO(reserved_pages, struct morse_page, CMD_RSVED_KFIFO_LEN);
DECLARE_KFIFO(cached_pages, struct morse_page, CACHED_PAGES_KFIFO_LEN);
#ifdef CONFIG_MORSE_PAGESET_TRACE
struct pageset_trace trace;
#endif
};
/**
* Initialise the morse pageset instance.
* Does not perform any initialisation of the underlying pager implementation,
* it is expected you call the implementation specific init on *pager first.
*
* @mors: Morse chip instance
* @pageset: Pointer to pageset struct to initialise
* @flags: Pageset flags (see pageset.h)
* @populated_pager: Where pages are sent to
* (Populated pages if Host->Chip, free pages if Chip->Host)
* @return_pager: Where pages fetched from
* (Free pages if Host->Chip, populated pages if Chip->Host)
*
* @return: Error code
*/
int morse_pageset_init(struct morse *mors, struct morse_pageset *pageset,
u8 flags,
struct morse_pager *populated_pager, struct morse_pager *return_pager);
/**
* Prints info about the pageset instance to a file.
*
* @mors: Morse chip instance
* @pageset: Pointer to pageset struct to print
* @file: Pointer to file to print to
*/
void morse_pageset_show(struct morse *mors, struct morse_pageset *pageset, struct seq_file *file);
/**
* Cleans up memory used by pageset instance.
*
* @pageset: Pointer to pageset struct to delete.
*/
void morse_pageset_finish(struct morse_pageset *pageset);
void morse_pageset_flush_tx_data(struct morse_pageset *pageset);
/**
* Return a count of all the TX SKBs awaiting a status return
*
* @mors: Morse chip instance
*
* @return int
*/
int morse_pagesets_get_tx_status_pending_count(struct morse *mors);
/**
* Work function to remove stale pending tx SKBs
*
* @work: Pointer to the work struct.
*/
void morse_pagesets_stale_tx_work(struct work_struct *work);
/**
* Return a count of all the TX SKBs buffered
*
* @mors: Morse chip instance
*
* @return int
*/
int morse_pagesets_get_tx_buffered_count(struct morse *mors);
/**
* Work function executed to perform pageset operations
*
* @work: Pointer to work struct.
*/
void morse_pagesets_work(struct work_struct *work);
#endif /* !_MORSE_PAGESET_H_ */