alx.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 2013 Johannes Berg <johannes@sipsolutions.net>
  3. *
  4. * This file is free software: you may copy, redistribute and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * This file incorporates work covered by the following copyright and
  18. * permission notice:
  19. *
  20. * Copyright (c) 2012 Qualcomm Atheros, Inc.
  21. *
  22. * Permission to use, copy, modify, and/or distribute this software for any
  23. * purpose with or without fee is hereby granted, provided that the above
  24. * copyright notice and this permission notice appear in all copies.
  25. *
  26. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  27. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  28. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  29. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  30. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  31. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  32. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33. */
  34. #ifndef _ALX_H_
  35. #define _ALX_H_
  36. #include <linux/types.h>
  37. #include <linux/etherdevice.h>
  38. #include <linux/dma-mapping.h>
  39. #include <linux/spinlock.h>
  40. #include "hw.h"
  41. #define ALX_WATCHDOG_TIME (5 * HZ)
  42. struct alx_buffer {
  43. struct sk_buff *skb;
  44. DEFINE_DMA_UNMAP_ADDR(dma);
  45. DEFINE_DMA_UNMAP_LEN(size);
  46. };
  47. struct alx_rx_queue {
  48. struct net_device *netdev;
  49. struct device *dev;
  50. struct alx_napi *np;
  51. struct alx_rrd *rrd;
  52. dma_addr_t rrd_dma;
  53. struct alx_rfd *rfd;
  54. dma_addr_t rfd_dma;
  55. struct alx_buffer *bufs;
  56. u16 count;
  57. u16 write_idx, read_idx;
  58. u16 rrd_read_idx;
  59. u16 queue_idx;
  60. };
  61. #define ALX_RX_ALLOC_THRESH 32
  62. struct alx_tx_queue {
  63. struct net_device *netdev;
  64. struct device *dev;
  65. struct alx_txd *tpd;
  66. dma_addr_t tpd_dma;
  67. struct alx_buffer *bufs;
  68. u16 count;
  69. u16 write_idx, read_idx;
  70. u16 queue_idx;
  71. u16 p_reg, c_reg;
  72. };
  73. #define ALX_DEFAULT_TX_WORK 128
  74. enum alx_device_quirks {
  75. ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG = BIT(0),
  76. };
  77. struct alx_napi {
  78. struct napi_struct napi;
  79. struct alx_priv *alx;
  80. struct alx_rx_queue *rxq;
  81. struct alx_tx_queue *txq;
  82. int vec_idx;
  83. u32 vec_mask;
  84. char irq_lbl[IFNAMSIZ + 8];
  85. };
  86. #define ALX_MAX_NAPIS 8
  87. #define ALX_FLAG_USING_MSIX BIT(0)
  88. #define ALX_FLAG_USING_MSI BIT(1)
  89. struct alx_priv {
  90. struct net_device *dev;
  91. struct alx_hw hw;
  92. /* msi-x vectors */
  93. int num_vec;
  94. struct msix_entry *msix_entries;
  95. /* all descriptor memory */
  96. struct {
  97. dma_addr_t dma;
  98. void *virt;
  99. unsigned int size;
  100. } descmem;
  101. struct alx_napi *qnapi[ALX_MAX_NAPIS];
  102. int num_txq;
  103. int num_rxq;
  104. int num_napi;
  105. /* protect int_mask updates */
  106. spinlock_t irq_lock;
  107. u32 int_mask;
  108. unsigned int tx_ringsz;
  109. unsigned int rx_ringsz;
  110. unsigned int rxbuf_size;
  111. struct work_struct link_check_wk;
  112. struct work_struct reset_wk;
  113. u16 msg_enable;
  114. int flags;
  115. /* protects hw.stats */
  116. spinlock_t stats_lock;
  117. };
  118. extern const struct ethtool_ops alx_ethtool_ops;
  119. extern const char alx_drv_name[];
  120. #endif