ehea_hw.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * linux/drivers/net/ethernet/ibm/ehea/ehea_hw.h
  3. *
  4. * eHEA ethernet device driver for IBM eServer System p
  5. *
  6. * (C) Copyright IBM Corp. 2006
  7. *
  8. * Authors:
  9. * Christoph Raisch <raisch@de.ibm.com>
  10. * Jan-Bernd Themann <themann@de.ibm.com>
  11. * Thomas Klein <tklein@de.ibm.com>
  12. *
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2, or (at your option)
  17. * any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #ifndef __EHEA_HW_H__
  29. #define __EHEA_HW_H__
  30. #define QPX_SQA_VALUE EHEA_BMASK_IBM(48, 63)
  31. #define QPX_RQ1A_VALUE EHEA_BMASK_IBM(48, 63)
  32. #define QPX_RQ2A_VALUE EHEA_BMASK_IBM(48, 63)
  33. #define QPX_RQ3A_VALUE EHEA_BMASK_IBM(48, 63)
  34. #define QPTEMM_OFFSET(x) offsetof(struct ehea_qptemm, x)
  35. struct ehea_qptemm {
  36. u64 qpx_hcr;
  37. u64 qpx_c;
  38. u64 qpx_herr;
  39. u64 qpx_aer;
  40. u64 qpx_sqa;
  41. u64 qpx_sqc;
  42. u64 qpx_rq1a;
  43. u64 qpx_rq1c;
  44. u64 qpx_st;
  45. u64 qpx_aerr;
  46. u64 qpx_tenure;
  47. u64 qpx_reserved1[(0x098 - 0x058) / 8];
  48. u64 qpx_portp;
  49. u64 qpx_reserved2[(0x100 - 0x0A0) / 8];
  50. u64 qpx_t;
  51. u64 qpx_sqhp;
  52. u64 qpx_sqptp;
  53. u64 qpx_reserved3[(0x140 - 0x118) / 8];
  54. u64 qpx_sqwsize;
  55. u64 qpx_reserved4[(0x170 - 0x148) / 8];
  56. u64 qpx_sqsize;
  57. u64 qpx_reserved5[(0x1B0 - 0x178) / 8];
  58. u64 qpx_sigt;
  59. u64 qpx_wqecnt;
  60. u64 qpx_rq1hp;
  61. u64 qpx_rq1ptp;
  62. u64 qpx_rq1size;
  63. u64 qpx_reserved6[(0x220 - 0x1D8) / 8];
  64. u64 qpx_rq1wsize;
  65. u64 qpx_reserved7[(0x240 - 0x228) / 8];
  66. u64 qpx_pd;
  67. u64 qpx_scqn;
  68. u64 qpx_rcqn;
  69. u64 qpx_aeqn;
  70. u64 reserved49;
  71. u64 qpx_ram;
  72. u64 qpx_reserved8[(0x300 - 0x270) / 8];
  73. u64 qpx_rq2a;
  74. u64 qpx_rq2c;
  75. u64 qpx_rq2hp;
  76. u64 qpx_rq2ptp;
  77. u64 qpx_rq2size;
  78. u64 qpx_rq2wsize;
  79. u64 qpx_rq2th;
  80. u64 qpx_rq3a;
  81. u64 qpx_rq3c;
  82. u64 qpx_rq3hp;
  83. u64 qpx_rq3ptp;
  84. u64 qpx_rq3size;
  85. u64 qpx_rq3wsize;
  86. u64 qpx_rq3th;
  87. u64 qpx_lpn;
  88. u64 qpx_reserved9[(0x400 - 0x378) / 8];
  89. u64 reserved_ext[(0x500 - 0x400) / 8];
  90. u64 reserved2[(0x1000 - 0x500) / 8];
  91. };
  92. #define MRx_HCR_LPARID_VALID EHEA_BMASK_IBM(0, 0)
  93. #define MRMWMM_OFFSET(x) offsetof(struct ehea_mrmwmm, x)
  94. struct ehea_mrmwmm {
  95. u64 mrx_hcr;
  96. u64 mrx_c;
  97. u64 mrx_herr;
  98. u64 mrx_aer;
  99. u64 mrx_pp;
  100. u64 reserved1;
  101. u64 reserved2;
  102. u64 reserved3;
  103. u64 reserved4[(0x200 - 0x40) / 8];
  104. u64 mrx_ctl[64];
  105. };
  106. #define QPEDMM_OFFSET(x) offsetof(struct ehea_qpedmm, x)
  107. struct ehea_qpedmm {
  108. u64 reserved0[(0x400) / 8];
  109. u64 qpedx_phh;
  110. u64 qpedx_ppsgp;
  111. u64 qpedx_ppsgu;
  112. u64 qpedx_ppdgp;
  113. u64 qpedx_ppdgu;
  114. u64 qpedx_aph;
  115. u64 qpedx_apsgp;
  116. u64 qpedx_apsgu;
  117. u64 qpedx_apdgp;
  118. u64 qpedx_apdgu;
  119. u64 qpedx_apav;
  120. u64 qpedx_apsav;
  121. u64 qpedx_hcr;
  122. u64 reserved1[4];
  123. u64 qpedx_rrl0;
  124. u64 qpedx_rrrkey0;
  125. u64 qpedx_rrva0;
  126. u64 reserved2;
  127. u64 qpedx_rrl1;
  128. u64 qpedx_rrrkey1;
  129. u64 qpedx_rrva1;
  130. u64 reserved3;
  131. u64 qpedx_rrl2;
  132. u64 qpedx_rrrkey2;
  133. u64 qpedx_rrva2;
  134. u64 reserved4;
  135. u64 qpedx_rrl3;
  136. u64 qpedx_rrrkey3;
  137. u64 qpedx_rrva3;
  138. };
  139. #define CQX_FECADDER EHEA_BMASK_IBM(32, 63)
  140. #define CQX_FEC_CQE_CNT EHEA_BMASK_IBM(32, 63)
  141. #define CQX_N1_GENERATE_COMP_EVENT EHEA_BMASK_IBM(0, 0)
  142. #define CQX_EP_EVENT_PENDING EHEA_BMASK_IBM(0, 0)
  143. #define CQTEMM_OFFSET(x) offsetof(struct ehea_cqtemm, x)
  144. struct ehea_cqtemm {
  145. u64 cqx_hcr;
  146. u64 cqx_c;
  147. u64 cqx_herr;
  148. u64 cqx_aer;
  149. u64 cqx_ptp;
  150. u64 cqx_tp;
  151. u64 cqx_fec;
  152. u64 cqx_feca;
  153. u64 cqx_ep;
  154. u64 cqx_eq;
  155. u64 reserved1;
  156. u64 cqx_n0;
  157. u64 cqx_n1;
  158. u64 reserved2[(0x1000 - 0x60) / 8];
  159. };
  160. #define EQTEMM_OFFSET(x) offsetof(struct ehea_eqtemm, x)
  161. struct ehea_eqtemm {
  162. u64 eqx_hcr;
  163. u64 eqx_c;
  164. u64 eqx_herr;
  165. u64 eqx_aer;
  166. u64 eqx_ptp;
  167. u64 eqx_tp;
  168. u64 eqx_ssba;
  169. u64 eqx_psba;
  170. u64 eqx_cec;
  171. u64 eqx_meql;
  172. u64 eqx_xisbi;
  173. u64 eqx_xisc;
  174. u64 eqx_it;
  175. };
  176. /*
  177. * These access functions will be changed when the dissuccsion about
  178. * the new access methods for POWER has settled.
  179. */
  180. static inline u64 epa_load(struct h_epa epa, u32 offset)
  181. {
  182. return __raw_readq((void __iomem *)(epa.addr + offset));
  183. }
  184. static inline void epa_store(struct h_epa epa, u32 offset, u64 value)
  185. {
  186. __raw_writeq(value, (void __iomem *)(epa.addr + offset));
  187. epa_load(epa, offset); /* synchronize explicitly to eHEA */
  188. }
  189. static inline void epa_store_acc(struct h_epa epa, u32 offset, u64 value)
  190. {
  191. __raw_writeq(value, (void __iomem *)(epa.addr + offset));
  192. }
  193. #define epa_store_cq(epa, offset, value)\
  194. epa_store(epa, CQTEMM_OFFSET(offset), value)
  195. #define epa_load_cq(epa, offset)\
  196. epa_load(epa, CQTEMM_OFFSET(offset))
  197. static inline void ehea_update_sqa(struct ehea_qp *qp, u16 nr_wqes)
  198. {
  199. struct h_epa epa = qp->epas.kernel;
  200. epa_store_acc(epa, QPTEMM_OFFSET(qpx_sqa),
  201. EHEA_BMASK_SET(QPX_SQA_VALUE, nr_wqes));
  202. }
  203. static inline void ehea_update_rq3a(struct ehea_qp *qp, u16 nr_wqes)
  204. {
  205. struct h_epa epa = qp->epas.kernel;
  206. epa_store_acc(epa, QPTEMM_OFFSET(qpx_rq3a),
  207. EHEA_BMASK_SET(QPX_RQ1A_VALUE, nr_wqes));
  208. }
  209. static inline void ehea_update_rq2a(struct ehea_qp *qp, u16 nr_wqes)
  210. {
  211. struct h_epa epa = qp->epas.kernel;
  212. epa_store_acc(epa, QPTEMM_OFFSET(qpx_rq2a),
  213. EHEA_BMASK_SET(QPX_RQ2A_VALUE, nr_wqes));
  214. }
  215. static inline void ehea_update_rq1a(struct ehea_qp *qp, u16 nr_wqes)
  216. {
  217. struct h_epa epa = qp->epas.kernel;
  218. epa_store_acc(epa, QPTEMM_OFFSET(qpx_rq1a),
  219. EHEA_BMASK_SET(QPX_RQ3A_VALUE, nr_wqes));
  220. }
  221. static inline void ehea_update_feca(struct ehea_cq *cq, u32 nr_cqes)
  222. {
  223. struct h_epa epa = cq->epas.kernel;
  224. epa_store_acc(epa, CQTEMM_OFFSET(cqx_feca),
  225. EHEA_BMASK_SET(CQX_FECADDER, nr_cqes));
  226. }
  227. static inline void ehea_reset_cq_n1(struct ehea_cq *cq)
  228. {
  229. struct h_epa epa = cq->epas.kernel;
  230. epa_store_cq(epa, cqx_n1,
  231. EHEA_BMASK_SET(CQX_N1_GENERATE_COMP_EVENT, 1));
  232. }
  233. static inline void ehea_reset_cq_ep(struct ehea_cq *my_cq)
  234. {
  235. struct h_epa epa = my_cq->epas.kernel;
  236. epa_store_acc(epa, CQTEMM_OFFSET(cqx_ep),
  237. EHEA_BMASK_SET(CQX_EP_EVENT_PENDING, 0));
  238. }
  239. #endif /* __EHEA_HW_H__ */