xref: /linux/drivers/net/wireless/morsemicro/mm81x/yaps.h (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2017-2026 Morse Micro
4  */
5 
6 #ifndef _MM81X_YAPS_H_
7 #define _MM81X_YAPS_H_
8 
9 #include <linux/skbuff.h>
10 #include <linux/workqueue.h>
11 #include "skbq.h"
12 
13 #define YAPS_TX_SKBQ_MAX 4
14 
15 struct mm81x_hif_ops;
16 extern const struct mm81x_hif_ops mm81x_yaps_ops;
17 
18 enum mm81x_yaps_to_chip_q {
19 	MM81X_YAPS_TX_Q = 0,
20 	MM81X_YAPS_CMD_Q,
21 	MM81X_YAPS_BEACON_Q,
22 	MM81X_YAPS_MGMT_Q,
23 	/* Keep this last */
24 	MM81X_YAPS_NUM_TC_Q
25 };
26 
27 struct mm81x_yaps_pkt {
28 	struct sk_buff *skb;
29 	enum mm81x_yaps_to_chip_q tc_queue;
30 };
31 
32 struct mm81x_yaps {
33 	struct mm81x *mors;
34 	struct mm81x_yaps_hw_aux_data *aux_data;
35 	const struct mm81x_yaps_ops *ops;
36 	u8 flags;
37 	struct {
38 		struct mm81x_yaps_pkt *to_chip_pkts;
39 		struct mm81x_yaps_pkt *from_chip_pkts;
40 	} hw;
41 
42 	/* Chip interface is stopping, new work should not be enqueued. */
43 	bool finish;
44 
45 	struct mm81x_skbq data_tx_qs[YAPS_TX_SKBQ_MAX];
46 	struct mm81x_skbq beacon_q;
47 	struct mm81x_skbq mgmt_q;
48 	struct mm81x_skbq data_rx_q;
49 	struct mm81x_skbq cmd_q;
50 	struct mm81x_skbq cmd_resp_q;
51 
52 	struct {
53 		struct timer_list timer;
54 		unsigned long retry_expiry;
55 		bool is_full;
56 	} chip_queue_full;
57 };
58 
59 struct mm81x_yaps_ops {
60 	int (*write_pkts)(struct mm81x_yaps *yaps, struct mm81x_yaps_pkt *pkts,
61 			  int num_pkts, int *num_pkts_sent);
62 	int (*read_pkts)(struct mm81x_yaps *yaps, struct mm81x_yaps_pkt *pkts,
63 			 int num_pkts_max, int *num_pkts_received);
64 	int (*update_status)(struct mm81x_yaps *yaps);
65 };
66 
67 int mm81x_yaps_init(struct mm81x *mors);
68 void mm81x_yaps_show(struct mm81x_yaps *yaps, struct seq_file *file);
69 void mm81x_yaps_finish(struct mm81x *mors);
70 void mm81x_yaps_flush_tx_data(struct mm81x *mors);
71 void mm81x_yaps_flush_cmds(struct mm81x *mors);
72 void mm81x_yaps_work(struct work_struct *work);
73 void mm81x_yaps_stale_tx_work(struct work_struct *work);
74 int mm81x_yaps_get_tx_status_pending_count(struct mm81x *mors);
75 int mm81x_yaps_get_tx_buffered_count(struct mm81x *mors);
76 
77 #endif /* !_MM81X_YAPS_H_ */
78