enic.h 3.7 KB

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