1 /*
2  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  */
13 
14 #ifndef _GDM_LTE_H_
15 #define _GDM_LTE_H_
16 
17 #include <linux/netdevice.h>
18 #include <linux/types.h>
19 
20 #include "gdm_endian.h"
21 
22 #define MAX_NIC_TYPE		4
23 #define MAX_RX_SUBMIT_COUNT	3
24 #define DRIVER_VERSION		"3.7.17.0"
25 
26 enum TX_ERROR_CODE {
27 	TX_NO_ERROR = 0,
28 	TX_NO_DEV,
29 	TX_NO_SPC,
30 	TX_NO_BUFFER,
31 };
32 
33 enum CALLBACK_CONTEXT {
34 	KERNEL_THREAD = 0,
35 	USB_COMPLETE,
36 };
37 
38 struct pdn_table {
39 	u8 activate;
40 	u32 dft_eps_id;
41 	u32 nic_type;
42 } __packed;
43 
44 struct nic;
45 
46 struct phy_dev {
47 	void	*priv_dev;
48 	struct net_device *dev[MAX_NIC_TYPE];
49 	int	(*send_hci_func)(void *priv_dev, void *data, int len,
50 				 void (*cb)(void *cb_data), void *cb_data);
51 	int	(*send_sdu_func)(void *priv_dev, void *data, int len,
52 				 unsigned int dft_eps_id, unsigned int eps_id,
53 				 void (*cb)(void *cb_data), void *cb_data,
54 				 int dev_idx, int nic_type);
55 	int	(*rcv_func)(void *priv_dev,
56 			    int (*cb)(void *cb_data, void *data, int len,
57 				      int context),
58 			    void *cb_data, int context);
59 	struct gdm_endian * (*get_endian)(void *priv_dev);
60 };
61 
62 struct nic {
63 	struct net_device *netdev;
64 	struct phy_dev *phy_dev;
65 	struct net_device_stats stats;
66 	struct pdn_table pdn_table;
67 	u8 dest_mac_addr[ETH_ALEN];
68 	u8 src_mac_addr[ETH_ALEN];
69 	u32 nic_id;
70 	u16 vlan_id;
71 };
72 
73 int gdm_lte_event_init(void);
74 void gdm_lte_event_exit(void);
75 
76 void start_rx_proc(struct phy_dev *phy_dev);
77 int register_lte_device(struct phy_dev *phy_dev, struct device *dev,
78 			u8 *mac_address);
79 void unregister_lte_device(struct phy_dev *phy_dev);
80 
81 #endif /* _GDM_LTE_H_ */
82