enic.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. #include <linux/irq.h>
  31. #define DRV_NAME "enic"
  32. #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver"
  33. #define DRV_VERSION "2.1.1.50"
  34. #define DRV_COPYRIGHT "Copyright 2008-2013 Cisco Systems, Inc"
  35. #define ENIC_BARS_MAX 6
  36. #define ENIC_WQ_MAX 8
  37. #define ENIC_RQ_MAX 8
  38. #define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX)
  39. #define ENIC_INTR_MAX (ENIC_CQ_MAX + 2)
  40. #define ENIC_AIC_LARGE_PKT_DIFF 3
  41. struct enic_msix_entry {
  42. int requested;
  43. char devname[IFNAMSIZ];
  44. irqreturn_t (*isr)(int, void *);
  45. void *devid;
  46. };
  47. /* Store only the lower range. Higher range is given by fw. */
  48. struct enic_intr_mod_range {
  49. u32 small_pkt_range_start;
  50. u32 large_pkt_range_start;
  51. };
  52. struct enic_intr_mod_table {
  53. u32 rx_rate;
  54. u32 range_percent;
  55. };
  56. #define ENIC_MAX_LINK_SPEEDS 3
  57. #define ENIC_LINK_SPEED_10G 10000
  58. #define ENIC_LINK_SPEED_4G 4000
  59. #define ENIC_LINK_40G_INDEX 2
  60. #define ENIC_LINK_10G_INDEX 1
  61. #define ENIC_LINK_4G_INDEX 0
  62. #define ENIC_RX_COALESCE_RANGE_END 125
  63. #define ENIC_AIC_TS_BREAK 100
  64. struct enic_rx_coal {
  65. u32 small_pkt_range_start;
  66. u32 large_pkt_range_start;
  67. u32 range_end;
  68. u32 use_adaptive_rx_coalesce;
  69. };
  70. /* priv_flags */
  71. #define ENIC_SRIOV_ENABLED (1 << 0)
  72. /* enic port profile set flags */
  73. #define ENIC_PORT_REQUEST_APPLIED (1 << 0)
  74. #define ENIC_SET_REQUEST (1 << 1)
  75. #define ENIC_SET_NAME (1 << 2)
  76. #define ENIC_SET_INSTANCE (1 << 3)
  77. #define ENIC_SET_HOST (1 << 4)
  78. struct enic_port_profile {
  79. u32 set;
  80. u8 request;
  81. char name[PORT_PROFILE_MAX];
  82. u8 instance_uuid[PORT_UUID_MAX];
  83. u8 host_uuid[PORT_UUID_MAX];
  84. u8 vf_mac[ETH_ALEN];
  85. u8 mac_addr[ETH_ALEN];
  86. };
  87. /* Per-instance private data structure */
  88. struct enic {
  89. struct net_device *netdev;
  90. struct pci_dev *pdev;
  91. struct vnic_enet_config config;
  92. struct vnic_dev_bar bar[ENIC_BARS_MAX];
  93. struct vnic_dev *vdev;
  94. struct timer_list notify_timer;
  95. struct work_struct reset;
  96. struct work_struct change_mtu_work;
  97. struct msix_entry msix_entry[ENIC_INTR_MAX];
  98. struct enic_msix_entry msix[ENIC_INTR_MAX];
  99. u32 msg_enable;
  100. spinlock_t devcmd_lock;
  101. u8 mac_addr[ETH_ALEN];
  102. unsigned int flags;
  103. unsigned int priv_flags;
  104. unsigned int mc_count;
  105. unsigned int uc_count;
  106. u32 port_mtu;
  107. struct enic_rx_coal rx_coalesce_setting;
  108. u32 rx_coalesce_usecs;
  109. u32 tx_coalesce_usecs;
  110. #ifdef CONFIG_PCI_IOV
  111. u16 num_vfs;
  112. #endif
  113. spinlock_t enic_api_lock;
  114. struct enic_port_profile *pp;
  115. /* work queue cache line section */
  116. ____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX];
  117. spinlock_t wq_lock[ENIC_WQ_MAX];
  118. unsigned int wq_count;
  119. u16 loop_enable;
  120. u16 loop_tag;
  121. /* receive queue cache line section */
  122. ____cacheline_aligned struct vnic_rq rq[ENIC_RQ_MAX];
  123. unsigned int rq_count;
  124. u64 rq_truncated_pkts;
  125. u64 rq_bad_fcs;
  126. struct napi_struct napi[ENIC_RQ_MAX];
  127. /* interrupt resource cache line section */
  128. ____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX];
  129. unsigned int intr_count;
  130. u32 __iomem *legacy_pba; /* memory-mapped */
  131. /* completion queue cache line section */
  132. ____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX];
  133. unsigned int cq_count;
  134. };
  135. static inline struct device *enic_get_dev(struct enic *enic)
  136. {
  137. return &(enic->pdev->dev);
  138. }
  139. static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
  140. {
  141. return rq;
  142. }
  143. static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq)
  144. {
  145. return enic->rq_count + wq;
  146. }
  147. static inline unsigned int enic_legacy_io_intr(void)
  148. {
  149. return 0;
  150. }
  151. static inline unsigned int enic_legacy_err_intr(void)
  152. {
  153. return 1;
  154. }
  155. static inline unsigned int enic_legacy_notify_intr(void)
  156. {
  157. return 2;
  158. }
  159. static inline unsigned int enic_msix_rq_intr(struct enic *enic,
  160. unsigned int rq)
  161. {
  162. return enic->cq[enic_cq_rq(enic, rq)].interrupt_offset;
  163. }
  164. static inline unsigned int enic_msix_wq_intr(struct enic *enic,
  165. unsigned int wq)
  166. {
  167. return enic->cq[enic_cq_wq(enic, wq)].interrupt_offset;
  168. }
  169. static inline unsigned int enic_msix_err_intr(struct enic *enic)
  170. {
  171. return enic->rq_count + enic->wq_count;
  172. }
  173. static inline unsigned int enic_msix_notify_intr(struct enic *enic)
  174. {
  175. return enic->rq_count + enic->wq_count + 1;
  176. }
  177. void enic_reset_addr_lists(struct enic *enic);
  178. int enic_sriov_enabled(struct enic *enic);
  179. int enic_is_valid_vf(struct enic *enic, int vf);
  180. int enic_is_dynamic(struct enic *enic);
  181. void enic_set_ethtool_ops(struct net_device *netdev);
  182. #endif /* _ENIC_H_ */