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" 35d765bb41SNeel Patel #define DRV_VERSION "2.1.1.43" 3692e2b469SNeel Patel #define DRV_COPYRIGHT "Copyright 2008-2013 Cisco Systems, Inc" 37a6a5580cSJeff Kirsher 38a6a5580cSJeff Kirsher #define ENIC_BARS_MAX 6 39a6a5580cSJeff Kirsher 40a6a5580cSJeff Kirsher #define ENIC_WQ_MAX 1 4163da93d9SNeel Patel #define ENIC_RQ_MAX 8 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 97413708bbSDan Carpenter u16 num_vfs; 988749b427SRoopa Prabhu #endif 990b038566SNeel Patel spinlock_t enic_api_lock; 1003f192795SRoopa Prabhu struct enic_port_profile *pp; 101a6a5580cSJeff Kirsher 102a6a5580cSJeff Kirsher /* work queue cache line section */ 103a6a5580cSJeff Kirsher ____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX]; 104a6a5580cSJeff Kirsher spinlock_t wq_lock[ENIC_WQ_MAX]; 105a6a5580cSJeff Kirsher unsigned int wq_count; 106a6a5580cSJeff Kirsher u16 loop_enable; 107a6a5580cSJeff Kirsher u16 loop_tag; 108a6a5580cSJeff Kirsher 109a6a5580cSJeff Kirsher /* receive queue cache line section */ 110a6a5580cSJeff Kirsher ____cacheline_aligned struct vnic_rq rq[ENIC_RQ_MAX]; 111a6a5580cSJeff Kirsher unsigned int rq_count; 112a6a5580cSJeff Kirsher u64 rq_truncated_pkts; 113a6a5580cSJeff Kirsher u64 rq_bad_fcs; 114a6a5580cSJeff Kirsher struct napi_struct napi[ENIC_RQ_MAX]; 115a6a5580cSJeff Kirsher 116a6a5580cSJeff Kirsher /* interrupt resource cache line section */ 117a6a5580cSJeff Kirsher ____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX]; 118a6a5580cSJeff Kirsher unsigned int intr_count; 119a6a5580cSJeff Kirsher u32 __iomem *legacy_pba; /* memory-mapped */ 120a6a5580cSJeff Kirsher 121a6a5580cSJeff Kirsher /* completion queue cache line section */ 122a6a5580cSJeff Kirsher ____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX]; 123a6a5580cSJeff Kirsher unsigned int cq_count; 124a6a5580cSJeff Kirsher }; 125a6a5580cSJeff Kirsher 126a6a5580cSJeff Kirsher static inline struct device *enic_get_dev(struct enic *enic) 127a6a5580cSJeff Kirsher { 128a6a5580cSJeff Kirsher return &(enic->pdev->dev); 129a6a5580cSJeff Kirsher } 130a6a5580cSJeff Kirsher 131f13bbc2fSNeel Patel static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq) 132f13bbc2fSNeel Patel { 133f13bbc2fSNeel Patel return rq; 134f13bbc2fSNeel Patel } 135f13bbc2fSNeel Patel 136f13bbc2fSNeel Patel static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq) 137f13bbc2fSNeel Patel { 138f13bbc2fSNeel Patel return enic->rq_count + wq; 139f13bbc2fSNeel Patel } 140f13bbc2fSNeel Patel 141f13bbc2fSNeel Patel static inline unsigned int enic_legacy_io_intr(void) 142f13bbc2fSNeel Patel { 143f13bbc2fSNeel Patel return 0; 144f13bbc2fSNeel Patel } 145f13bbc2fSNeel Patel 146f13bbc2fSNeel Patel static inline unsigned int enic_legacy_err_intr(void) 147f13bbc2fSNeel Patel { 148f13bbc2fSNeel Patel return 1; 149f13bbc2fSNeel Patel } 150f13bbc2fSNeel Patel 151f13bbc2fSNeel Patel static inline unsigned int enic_legacy_notify_intr(void) 152f13bbc2fSNeel Patel { 153f13bbc2fSNeel Patel return 2; 154f13bbc2fSNeel Patel } 155f13bbc2fSNeel Patel 156f13bbc2fSNeel Patel static inline unsigned int enic_msix_rq_intr(struct enic *enic, 157f13bbc2fSNeel Patel unsigned int rq) 158f13bbc2fSNeel Patel { 159f13bbc2fSNeel Patel return enic->cq[enic_cq_rq(enic, rq)].interrupt_offset; 160f13bbc2fSNeel Patel } 161f13bbc2fSNeel Patel 162f13bbc2fSNeel Patel static inline unsigned int enic_msix_wq_intr(struct enic *enic, 163f13bbc2fSNeel Patel unsigned int wq) 164f13bbc2fSNeel Patel { 165f13bbc2fSNeel Patel return enic->cq[enic_cq_wq(enic, wq)].interrupt_offset; 166f13bbc2fSNeel Patel } 167f13bbc2fSNeel Patel 168f13bbc2fSNeel Patel static inline unsigned int enic_msix_err_intr(struct enic *enic) 169f13bbc2fSNeel Patel { 170f13bbc2fSNeel Patel return enic->rq_count + enic->wq_count; 171f13bbc2fSNeel Patel } 172f13bbc2fSNeel Patel 173f13bbc2fSNeel Patel static inline unsigned int enic_msix_notify_intr(struct enic *enic) 174f13bbc2fSNeel Patel { 175f13bbc2fSNeel Patel return enic->rq_count + enic->wq_count + 1; 176f13bbc2fSNeel Patel } 177f13bbc2fSNeel Patel 178a6a5580cSJeff Kirsher void enic_reset_addr_lists(struct enic *enic); 1798749b427SRoopa Prabhu int enic_sriov_enabled(struct enic *enic); 180889d13f5SRoopa Prabhu int enic_is_valid_vf(struct enic *enic, int vf); 1813f192795SRoopa Prabhu int enic_is_dynamic(struct enic *enic); 182f13bbc2fSNeel Patel void enic_set_ethtool_ops(struct net_device *netdev); 183a6a5580cSJeff Kirsher 184a6a5580cSJeff Kirsher #endif /* _ENIC_H_ */ 185