1 /*
2  * Copyright (c) 2015-2016 Quantenna Communications, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16 
17 #ifndef _QTN_FMAC_TRANS_H_
18 #define _QTN_FMAC_TRANS_H_
19 
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/skbuff.h>
23 #include <linux/mutex.h>
24 
25 #include "qlink.h"
26 
27 #define QTNF_CMD_FLAG_RESP_REQ		BIT(0)
28 
29 #define QTNF_MAX_CMD_BUF_SIZE	2048
30 #define QTNF_DEF_CMD_HROOM	4
31 
32 struct qtnf_bus;
33 
34 struct qtnf_cmd_ctl_node {
35 	struct completion cmd_resp_completion;
36 	struct sk_buff *resp_skb;
37 	u16 seq_num;
38 	bool waiting_for_resp;
39 	spinlock_t resp_lock; /* lock for resp_skb & waiting_for_resp changes */
40 };
41 
42 struct qtnf_qlink_transport {
43 	struct qtnf_cmd_ctl_node curr_cmd;
44 	struct sk_buff_head event_queue;
45 	size_t event_queue_max_len;
46 };
47 
48 void qtnf_trans_init(struct qtnf_bus *bus);
49 void qtnf_trans_free(struct qtnf_bus *bus);
50 
51 int qtnf_trans_send_next_cmd(struct qtnf_bus *bus);
52 int qtnf_trans_handle_rx_ctl_packet(struct qtnf_bus *bus, struct sk_buff *skb);
53 int qtnf_trans_send_cmd_with_resp(struct qtnf_bus *bus,
54 				  struct sk_buff *cmd_skb,
55 				  struct sk_buff **response_skb);
56 
57 #endif /* _QTN_FMAC_TRANS_H_ */
58