xref: /linux/drivers/net/ethernet/apm/xgene-v2/main.h (revision 617d795c)
1 /*
2  * Applied Micro X-Gene SoC Ethernet v2 Driver
3  *
4  * Copyright (c) 2017, Applied Micro Circuits Corporation
5  * Author(s): Iyappan Subramanian <isubramanian@apm.com>
6  *	      Keyur Chudgar <kchudgar@apm.com>
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __XGENE_ENET_V2_MAIN_H__
23 #define __XGENE_ENET_V2_MAIN_H__
24 
25 #include <linux/acpi.h>
26 #include <linux/clk.h>
27 #include <linux/efi.h>
28 #include <linux/if_vlan.h>
29 #include <linux/irq.h>
30 #include <linux/io.h>
31 #include <linux/module.h>
32 #include <linux/of_platform.h>
33 #include <linux/of_net.h>
34 #include <linux/of_mdio.h>
35 #include <linux/prefetch.h>
36 #include <linux/phy.h>
37 #include <net/ip.h>
38 #include "mac.h"
39 #include "enet.h"
40 #include "ring.h"
41 
42 #define XGENE_ENET_V2_VERSION	"v1.0"
43 #define XGENE_ENET_STD_MTU	1536
44 #define XGENE_ENET_MIN_FRAME	60
45 #define IRQ_ID_SIZE             16
46 
47 struct xge_resource {
48 	void __iomem *base_addr;
49 	int phy_mode;
50 	u32 irq;
51 };
52 
53 struct xge_stats {
54 	u64 tx_packets;
55 	u64 tx_bytes;
56 	u64 rx_packets;
57 	u64 rx_bytes;
58 	u64 rx_errors;
59 };
60 
61 /* ethernet private data */
62 struct xge_pdata {
63 	struct xge_resource resources;
64 	struct xge_desc_ring *tx_ring;
65 	struct xge_desc_ring *rx_ring;
66 	struct platform_device *pdev;
67 	char irq_name[IRQ_ID_SIZE];
68 	struct mii_bus *mdio_bus;
69 	struct net_device *ndev;
70 	struct napi_struct napi;
71 	struct xge_stats stats;
72 	int phy_speed;
73 	u8 nbufs;
74 };
75 
76 int xge_mdio_config(struct net_device *ndev);
77 void xge_mdio_remove(struct net_device *ndev);
78 void xge_set_ethtool_ops(struct net_device *ndev);
79 
80 #endif /* __XGENE_ENET_V2_MAIN_H__ */
81