common.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*****************************************************************************
  2. * *
  3. * File: common.h *
  4. * $Revision: 1.5 $ *
  5. * $Date: 2005/03/23 07:41:27 $ *
  6. * Description: *
  7. * part of the Chelsio 10Gb Ethernet Driver. *
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License, version 2, as *
  11. * published by the Free Software Foundation. *
  12. * *
  13. * You should have received a copy of the GNU General Public License along *
  14. * with this program; if not, write to the Free Software Foundation, Inc., *
  15. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  16. * *
  17. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED *
  18. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF *
  19. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
  20. * *
  21. * http://www.chelsio.com *
  22. * *
  23. * Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
  24. * All rights reserved. *
  25. * *
  26. * Maintainers: maintainers@chelsio.com *
  27. * *
  28. * Authors: Dimitrios Michailidis <dm@chelsio.com> *
  29. * Tina Yang <tainay@chelsio.com> *
  30. * Felix Marti <felix@chelsio.com> *
  31. * Scott Bardone <sbardone@chelsio.com> *
  32. * Kurt Ottaway <kottaway@chelsio.com> *
  33. * Frank DiMambro <frank@chelsio.com> *
  34. * *
  35. * History: *
  36. * *
  37. ****************************************************************************/
  38. #ifndef CHELSIO_COMMON_H
  39. #define CHELSIO_COMMON_H
  40. #define DIMOF(x) (sizeof(x)/sizeof(x[0]))
  41. #define NMTUS 8
  42. #define MAX_NPORTS 4
  43. #define TCB_SIZE 128
  44. enum {
  45. CHBT_BOARD_7500,
  46. CHBT_BOARD_8000,
  47. CHBT_BOARD_CHT101,
  48. CHBT_BOARD_CHT110,
  49. CHBT_BOARD_CHT210,
  50. CHBT_BOARD_CHT204,
  51. CHBT_BOARD_N110,
  52. CHBT_BOARD_N210,
  53. CHBT_BOARD_COUGAR,
  54. CHBT_BOARD_6800,
  55. CHBT_BOARD_SIMUL
  56. };
  57. enum {
  58. CHBT_TERM_FPGA,
  59. CHBT_TERM_T1,
  60. CHBT_TERM_T2,
  61. CHBT_TERM_T3
  62. };
  63. enum {
  64. CHBT_MAC_CHELSIO_A,
  65. CHBT_MAC_IXF1010,
  66. CHBT_MAC_PM3393,
  67. CHBT_MAC_VSC7321,
  68. CHBT_MAC_DUMMY
  69. };
  70. enum {
  71. CHBT_PHY_88E1041,
  72. CHBT_PHY_88E1111,
  73. CHBT_PHY_88X2010,
  74. CHBT_PHY_XPAK,
  75. CHBT_PHY_MY3126,
  76. CHBT_PHY_DUMMY
  77. };
  78. enum {
  79. PAUSE_RX = 1,
  80. PAUSE_TX = 2,
  81. PAUSE_AUTONEG = 4
  82. };
  83. /* Revisions of T1 chip */
  84. #define TERM_T1A 0
  85. #define TERM_T1B 1
  86. #define TERM_T2 3
  87. struct tp_params {
  88. unsigned int pm_size;
  89. unsigned int cm_size;
  90. unsigned int pm_rx_base;
  91. unsigned int pm_tx_base;
  92. unsigned int pm_rx_pg_size;
  93. unsigned int pm_tx_pg_size;
  94. unsigned int pm_rx_num_pgs;
  95. unsigned int pm_tx_num_pgs;
  96. unsigned int use_5tuple_mode;
  97. };
  98. struct sge_params {
  99. unsigned int cmdQ_size[2];
  100. unsigned int freelQ_size[2];
  101. unsigned int large_buf_capacity;
  102. unsigned int rx_coalesce_usecs;
  103. unsigned int last_rx_coalesce_raw;
  104. unsigned int default_rx_coalesce_usecs;
  105. unsigned int sample_interval_usecs;
  106. unsigned int coalesce_enable;
  107. unsigned int polling;
  108. };
  109. struct mc5_params {
  110. unsigned int mode; /* selects MC5 width */
  111. unsigned int nservers; /* size of server region */
  112. unsigned int nroutes; /* size of routing region */
  113. };
  114. /* Default MC5 region sizes */
  115. #define DEFAULT_SERVER_REGION_LEN 256
  116. #define DEFAULT_RT_REGION_LEN 1024
  117. struct pci_params {
  118. unsigned short speed;
  119. unsigned char width;
  120. unsigned char is_pcix;
  121. };
  122. struct adapter_params {
  123. struct sge_params sge;
  124. struct mc5_params mc5;
  125. struct tp_params tp;
  126. struct pci_params pci;
  127. const struct board_info *brd_info;
  128. unsigned short mtus[NMTUS];
  129. unsigned int nports; /* # of ethernet ports */
  130. unsigned int stats_update_period;
  131. unsigned short chip_revision;
  132. unsigned char chip_version;
  133. unsigned char is_asic;
  134. };
  135. struct pci_err_cnt {
  136. unsigned int master_parity_err;
  137. unsigned int sig_target_abort;
  138. unsigned int rcv_target_abort;
  139. unsigned int rcv_master_abort;
  140. unsigned int sig_sys_err;
  141. unsigned int det_parity_err;
  142. unsigned int pio_parity_err;
  143. unsigned int wf_parity_err;
  144. unsigned int rf_parity_err;
  145. unsigned int cf_parity_err;
  146. };
  147. struct link_config {
  148. unsigned int supported; /* link capabilities */
  149. unsigned int advertising; /* advertised capabilities */
  150. unsigned short requested_speed; /* speed user has requested */
  151. unsigned short speed; /* actual link speed */
  152. unsigned char requested_duplex; /* duplex user has requested */
  153. unsigned char duplex; /* actual link duplex */
  154. unsigned char requested_fc; /* flow control user has requested */
  155. unsigned char fc; /* actual link flow control */
  156. unsigned char autoneg; /* autonegotiating? */
  157. };
  158. #define SPEED_INVALID 0xffff
  159. #define DUPLEX_INVALID 0xff
  160. struct mdio_ops;
  161. struct gmac;
  162. struct gphy;
  163. struct board_info {
  164. unsigned char board;
  165. unsigned char port_number;
  166. unsigned long caps;
  167. unsigned char chip_term;
  168. unsigned char chip_mac;
  169. unsigned char chip_phy;
  170. unsigned int clock_core;
  171. unsigned int clock_mc3;
  172. unsigned int clock_mc4;
  173. unsigned int espi_nports;
  174. unsigned int clock_cspi;
  175. unsigned int clock_elmer0;
  176. unsigned char mdio_mdien;
  177. unsigned char mdio_mdiinv;
  178. unsigned char mdio_mdc;
  179. unsigned char mdio_phybaseaddr;
  180. struct gmac *gmac;
  181. struct gphy *gphy;
  182. struct mdio_ops *mdio_ops;
  183. const char *desc;
  184. };
  185. #include "osdep.h"
  186. #ifndef PCI_VENDOR_ID_CHELSIO
  187. #define PCI_VENDOR_ID_CHELSIO 0x1425
  188. #endif
  189. extern struct pci_device_id t1_pci_tbl[];
  190. static inline int t1_is_asic(const adapter_t *adapter)
  191. {
  192. return adapter->params.is_asic;
  193. }
  194. static inline int adapter_matches_type(const adapter_t *adapter,
  195. int version, int revision)
  196. {
  197. return adapter->params.chip_version == version &&
  198. adapter->params.chip_revision == revision;
  199. }
  200. #define t1_is_T1B(adap) adapter_matches_type(adap, CHBT_TERM_T1, TERM_T1B)
  201. #define is_T2(adap) adapter_matches_type(adap, CHBT_TERM_T2, TERM_T2)
  202. /* Returns true if an adapter supports VLAN acceleration and TSO */
  203. static inline int vlan_tso_capable(const adapter_t *adapter)
  204. {
  205. return !t1_is_T1B(adapter);
  206. }
  207. #define for_each_port(adapter, iter) \
  208. for (iter = 0; iter < (adapter)->params.nports; ++iter)
  209. #define board_info(adapter) ((adapter)->params.brd_info)
  210. #define is_10G(adapter) (board_info(adapter)->caps & SUPPORTED_10000baseT_Full)
  211. static inline unsigned int core_ticks_per_usec(const adapter_t *adap)
  212. {
  213. return board_info(adap)->clock_core / 1000000;
  214. }
  215. int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value);
  216. int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value);
  217. void t1_interrupts_enable(adapter_t *adapter);
  218. void t1_interrupts_disable(adapter_t *adapter);
  219. void t1_interrupts_clear(adapter_t *adapter);
  220. int elmer0_ext_intr_handler(adapter_t *adapter);
  221. int t1_slow_intr_handler(adapter_t *adapter);
  222. int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
  223. const struct board_info *t1_get_board_info(unsigned int board_id);
  224. const struct board_info *t1_get_board_info_from_ids(unsigned int devid,
  225. unsigned short ssid);
  226. int t1_seeprom_read(adapter_t *adapter, u32 addr, u32 *data);
  227. int t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
  228. struct adapter_params *p);
  229. int t1_init_hw_modules(adapter_t *adapter);
  230. int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi);
  231. void t1_free_sw_modules(adapter_t *adapter);
  232. void t1_fatal_err(adapter_t *adapter);
  233. #endif