1a6a5580cSJeff Kirsher /*
2a6a5580cSJeff Kirsher  * Copyright 2008-2010 Cisco Systems, Inc.  All rights reserved.
3a6a5580cSJeff Kirsher  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
4a6a5580cSJeff Kirsher  *
5a6a5580cSJeff Kirsher  * This program is free software; you may redistribute it and/or modify
6a6a5580cSJeff Kirsher  * it under the terms of the GNU General Public License as published by
7a6a5580cSJeff Kirsher  * the Free Software Foundation; version 2 of the License.
8a6a5580cSJeff Kirsher  *
9a6a5580cSJeff Kirsher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10a6a5580cSJeff Kirsher  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11a6a5580cSJeff Kirsher  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12a6a5580cSJeff Kirsher  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13a6a5580cSJeff Kirsher  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14a6a5580cSJeff Kirsher  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15a6a5580cSJeff Kirsher  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16a6a5580cSJeff Kirsher  * SOFTWARE.
17a6a5580cSJeff Kirsher  *
18a6a5580cSJeff Kirsher  */
19a6a5580cSJeff Kirsher 
20a6a5580cSJeff Kirsher #ifndef _ENIC_H_
21a6a5580cSJeff Kirsher #define _ENIC_H_
22a6a5580cSJeff Kirsher 
23a6a5580cSJeff Kirsher #include "vnic_enet.h"
24a6a5580cSJeff Kirsher #include "vnic_dev.h"
25a6a5580cSJeff Kirsher #include "vnic_wq.h"
26a6a5580cSJeff Kirsher #include "vnic_rq.h"
27a6a5580cSJeff Kirsher #include "vnic_cq.h"
28a6a5580cSJeff Kirsher #include "vnic_intr.h"
29a6a5580cSJeff Kirsher #include "vnic_stats.h"
30a6a5580cSJeff Kirsher #include "vnic_nic.h"
31a6a5580cSJeff Kirsher #include "vnic_rss.h"
32a6a5580cSJeff Kirsher 
33a6a5580cSJeff Kirsher #define DRV_NAME		"enic"
34a6a5580cSJeff Kirsher #define DRV_DESCRIPTION		"Cisco VIC Ethernet NIC Driver"
358749b427SRoopa Prabhu #define DRV_VERSION		"2.1.1.28"
36a6a5580cSJeff Kirsher #define DRV_COPYRIGHT		"Copyright 2008-2011 Cisco Systems, Inc"
37a6a5580cSJeff Kirsher 
38a6a5580cSJeff Kirsher #define ENIC_BARS_MAX		6
39a6a5580cSJeff Kirsher 
40a6a5580cSJeff Kirsher #define ENIC_WQ_MAX		1
41a6a5580cSJeff Kirsher #define ENIC_RQ_MAX		1
42a6a5580cSJeff Kirsher #define ENIC_CQ_MAX		(ENIC_WQ_MAX + ENIC_RQ_MAX)
43a6a5580cSJeff Kirsher #define ENIC_INTR_MAX		(ENIC_CQ_MAX + 2)
44a6a5580cSJeff Kirsher 
45a6a5580cSJeff Kirsher struct enic_msix_entry {
46a6a5580cSJeff Kirsher 	int requested;
47a6a5580cSJeff Kirsher 	char devname[IFNAMSIZ];
48a6a5580cSJeff Kirsher 	irqreturn_t (*isr)(int, void *);
49a6a5580cSJeff Kirsher 	void *devid;
50a6a5580cSJeff Kirsher };
51a6a5580cSJeff Kirsher 
528749b427SRoopa Prabhu /* priv_flags */
538749b427SRoopa Prabhu #define ENIC_SRIOV_ENABLED		(1 << 0)
548749b427SRoopa Prabhu 
558749b427SRoopa Prabhu /* enic port profile set flags */
56a6a5580cSJeff Kirsher #define ENIC_PORT_REQUEST_APPLIED	(1 << 0)
57a6a5580cSJeff Kirsher #define ENIC_SET_REQUEST		(1 << 1)
58a6a5580cSJeff Kirsher #define ENIC_SET_NAME			(1 << 2)
59a6a5580cSJeff Kirsher #define ENIC_SET_INSTANCE		(1 << 3)
60a6a5580cSJeff Kirsher #define ENIC_SET_HOST			(1 << 4)
61a6a5580cSJeff Kirsher 
62a6a5580cSJeff Kirsher struct enic_port_profile {
63a6a5580cSJeff Kirsher 	u32 set;
64a6a5580cSJeff Kirsher 	u8 request;
65a6a5580cSJeff Kirsher 	char name[PORT_PROFILE_MAX];
66a6a5580cSJeff Kirsher 	u8 instance_uuid[PORT_UUID_MAX];
67a6a5580cSJeff Kirsher 	u8 host_uuid[PORT_UUID_MAX];
68a6a5580cSJeff Kirsher 	u8 vf_mac[ETH_ALEN];
69a6a5580cSJeff Kirsher 	u8 mac_addr[ETH_ALEN];
70a6a5580cSJeff Kirsher };
71a6a5580cSJeff Kirsher 
72a6a5580cSJeff Kirsher /* Per-instance private data structure */
73a6a5580cSJeff Kirsher struct enic {
74a6a5580cSJeff Kirsher 	struct net_device *netdev;
75a6a5580cSJeff Kirsher 	struct pci_dev *pdev;
76a6a5580cSJeff Kirsher 	struct vnic_enet_config config;
77a6a5580cSJeff Kirsher 	struct vnic_dev_bar bar[ENIC_BARS_MAX];
78a6a5580cSJeff Kirsher 	struct vnic_dev *vdev;
79a6a5580cSJeff Kirsher 	struct timer_list notify_timer;
80a6a5580cSJeff Kirsher 	struct work_struct reset;
81a6a5580cSJeff Kirsher 	struct work_struct change_mtu_work;
82a6a5580cSJeff Kirsher 	struct msix_entry msix_entry[ENIC_INTR_MAX];
83a6a5580cSJeff Kirsher 	struct enic_msix_entry msix[ENIC_INTR_MAX];
84a6a5580cSJeff Kirsher 	u32 msg_enable;
85a6a5580cSJeff Kirsher 	spinlock_t devcmd_lock;
86a6a5580cSJeff Kirsher 	u8 mac_addr[ETH_ALEN];
87a6a5580cSJeff Kirsher 	u8 mc_addr[ENIC_MULTICAST_PERFECT_FILTERS][ETH_ALEN];
88a6a5580cSJeff Kirsher 	u8 uc_addr[ENIC_UNICAST_PERFECT_FILTERS][ETH_ALEN];
89a6a5580cSJeff Kirsher 	unsigned int flags;
908749b427SRoopa Prabhu 	unsigned int priv_flags;
91a6a5580cSJeff Kirsher 	unsigned int mc_count;
92a6a5580cSJeff Kirsher 	unsigned int uc_count;
93a6a5580cSJeff Kirsher 	u32 port_mtu;
94a6a5580cSJeff Kirsher 	u32 rx_coalesce_usecs;
95a6a5580cSJeff Kirsher 	u32 tx_coalesce_usecs;
968749b427SRoopa Prabhu #ifdef CONFIG_PCI_IOV
978749b427SRoopa Prabhu 	u32 num_vfs;
988749b427SRoopa Prabhu #endif
99a6a5580cSJeff Kirsher 	struct enic_port_profile pp;
100a6a5580cSJeff Kirsher 
101a6a5580cSJeff Kirsher 	/* work queue cache line section */
102a6a5580cSJeff Kirsher 	____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX];
103a6a5580cSJeff Kirsher 	spinlock_t wq_lock[ENIC_WQ_MAX];
104a6a5580cSJeff Kirsher 	unsigned int wq_count;
105a6a5580cSJeff Kirsher 	u16 loop_enable;
106a6a5580cSJeff Kirsher 	u16 loop_tag;
107a6a5580cSJeff Kirsher 
108a6a5580cSJeff Kirsher 	/* receive queue cache line section */
109a6a5580cSJeff Kirsher 	____cacheline_aligned struct vnic_rq rq[ENIC_RQ_MAX];
110a6a5580cSJeff Kirsher 	unsigned int rq_count;
111a6a5580cSJeff Kirsher 	u64 rq_truncated_pkts;
112a6a5580cSJeff Kirsher 	u64 rq_bad_fcs;
113a6a5580cSJeff Kirsher 	struct napi_struct napi[ENIC_RQ_MAX];
114a6a5580cSJeff Kirsher 
115a6a5580cSJeff Kirsher 	/* interrupt resource cache line section */
116a6a5580cSJeff Kirsher 	____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX];
117a6a5580cSJeff Kirsher 	unsigned int intr_count;
118a6a5580cSJeff Kirsher 	u32 __iomem *legacy_pba;		/* memory-mapped */
119a6a5580cSJeff Kirsher 
120a6a5580cSJeff Kirsher 	/* completion queue cache line section */
121a6a5580cSJeff Kirsher 	____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX];
122a6a5580cSJeff Kirsher 	unsigned int cq_count;
123a6a5580cSJeff Kirsher };
124a6a5580cSJeff Kirsher 
125a6a5580cSJeff Kirsher static inline struct device *enic_get_dev(struct enic *enic)
126a6a5580cSJeff Kirsher {
127a6a5580cSJeff Kirsher 	return &(enic->pdev->dev);
128a6a5580cSJeff Kirsher }
129a6a5580cSJeff Kirsher 
130a6a5580cSJeff Kirsher void enic_reset_addr_lists(struct enic *enic);
1318749b427SRoopa Prabhu int enic_sriov_enabled(struct enic *enic);
132a6a5580cSJeff Kirsher 
133a6a5580cSJeff Kirsher #endif /* _ENIC_H_ */
134