ehea_phyp.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*
  2. * linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.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_PHYP_H__
  29. #define __EHEA_PHYP_H__
  30. #include <linux/delay.h>
  31. #include <asm/hvcall.h>
  32. #include "ehea.h"
  33. #include "ehea_hw.h"
  34. /* Some abbreviations used here:
  35. *
  36. * hcp_* - structures, variables and functions releated to Hypervisor Calls
  37. */
  38. /* Number of pages which can be registered at once by H_REGISTER_HEA_RPAGES */
  39. #define EHEA_MAX_RPAGE 512
  40. /* Notification Event Queue (NEQ) Entry bit masks */
  41. #define NEQE_EVENT_CODE EHEA_BMASK_IBM(2, 7)
  42. #define NEQE_PORTNUM EHEA_BMASK_IBM(32, 47)
  43. #define NEQE_PORT_UP EHEA_BMASK_IBM(16, 16)
  44. #define NEQE_EXTSWITCH_PORT_UP EHEA_BMASK_IBM(17, 17)
  45. #define NEQE_EXTSWITCH_PRIMARY EHEA_BMASK_IBM(18, 18)
  46. #define NEQE_PLID EHEA_BMASK_IBM(16, 47)
  47. /* Notification Event Codes */
  48. #define EHEA_EC_PORTSTATE_CHG 0x30
  49. #define EHEA_EC_ADAPTER_MALFUNC 0x32
  50. #define EHEA_EC_PORT_MALFUNC 0x33
  51. /* Notification Event Log Register (NELR) bit masks */
  52. #define NELR_PORT_MALFUNC EHEA_BMASK_IBM(61, 61)
  53. #define NELR_ADAPTER_MALFUNC EHEA_BMASK_IBM(62, 62)
  54. #define NELR_PORTSTATE_CHG EHEA_BMASK_IBM(63, 63)
  55. static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel,
  56. u64 paddr_user)
  57. {
  58. /* To support 64k pages we must round to 64k page boundary */
  59. epas->kernel.addr = ioremap((paddr_kernel & PAGE_MASK), PAGE_SIZE) +
  60. (paddr_kernel & ~PAGE_MASK);
  61. epas->user.addr = paddr_user;
  62. }
  63. static inline void hcp_epas_dtor(struct h_epas *epas)
  64. {
  65. if (epas->kernel.addr)
  66. iounmap((void __iomem *)((u64)epas->kernel.addr & PAGE_MASK));
  67. epas->user.addr = 0;
  68. epas->kernel.addr = 0;
  69. }
  70. struct hcp_modify_qp_cb0 {
  71. u64 qp_ctl_reg; /* 00 */
  72. u32 max_swqe; /* 02 */
  73. u32 max_rwqe; /* 03 */
  74. u32 port_nb; /* 04 */
  75. u32 reserved0; /* 05 */
  76. u64 qp_aer; /* 06 */
  77. u64 qp_tenure; /* 08 */
  78. };
  79. /* Hcall Query/Modify Queue Pair Control Block 0 Selection Mask Bits */
  80. #define H_QPCB0_ALL EHEA_BMASK_IBM(0, 5)
  81. #define H_QPCB0_QP_CTL_REG EHEA_BMASK_IBM(0, 0)
  82. #define H_QPCB0_MAX_SWQE EHEA_BMASK_IBM(1, 1)
  83. #define H_QPCB0_MAX_RWQE EHEA_BMASK_IBM(2, 2)
  84. #define H_QPCB0_PORT_NB EHEA_BMASK_IBM(3, 3)
  85. #define H_QPCB0_QP_AER EHEA_BMASK_IBM(4, 4)
  86. #define H_QPCB0_QP_TENURE EHEA_BMASK_IBM(5, 5)
  87. /* Queue Pair Control Register Status Bits */
  88. #define H_QP_CR_ENABLED 0x8000000000000000ULL /* QP enabled */
  89. /* QP States: */
  90. #define H_QP_CR_STATE_RESET 0x0000010000000000ULL /* Reset */
  91. #define H_QP_CR_STATE_INITIALIZED 0x0000020000000000ULL /* Initialized */
  92. #define H_QP_CR_STATE_RDY2RCV 0x0000030000000000ULL /* Ready to recv */
  93. #define H_QP_CR_STATE_RDY2SND 0x0000050000000000ULL /* Ready to send */
  94. #define H_QP_CR_STATE_ERROR 0x0000800000000000ULL /* Error */
  95. #define H_QP_CR_RES_STATE 0x0000007F00000000ULL /* Resultant state */
  96. struct hcp_modify_qp_cb1 {
  97. u32 qpn; /* 00 */
  98. u32 qp_asyn_ev_eq_nb; /* 01 */
  99. u64 sq_cq_handle; /* 02 */
  100. u64 rq_cq_handle; /* 04 */
  101. /* sgel = scatter gather element */
  102. u32 sgel_nb_sq; /* 06 */
  103. u32 sgel_nb_rq1; /* 07 */
  104. u32 sgel_nb_rq2; /* 08 */
  105. u32 sgel_nb_rq3; /* 09 */
  106. };
  107. /* Hcall Query/Modify Queue Pair Control Block 1 Selection Mask Bits */
  108. #define H_QPCB1_ALL EHEA_BMASK_IBM(0, 7)
  109. #define H_QPCB1_QPN EHEA_BMASK_IBM(0, 0)
  110. #define H_QPCB1_ASYN_EV_EQ_NB EHEA_BMASK_IBM(1, 1)
  111. #define H_QPCB1_SQ_CQ_HANDLE EHEA_BMASK_IBM(2, 2)
  112. #define H_QPCB1_RQ_CQ_HANDLE EHEA_BMASK_IBM(3, 3)
  113. #define H_QPCB1_SGEL_NB_SQ EHEA_BMASK_IBM(4, 4)
  114. #define H_QPCB1_SGEL_NB_RQ1 EHEA_BMASK_IBM(5, 5)
  115. #define H_QPCB1_SGEL_NB_RQ2 EHEA_BMASK_IBM(6, 6)
  116. #define H_QPCB1_SGEL_NB_RQ3 EHEA_BMASK_IBM(7, 7)
  117. struct hcp_query_ehea {
  118. u32 cur_num_qps; /* 00 */
  119. u32 cur_num_cqs; /* 01 */
  120. u32 cur_num_eqs; /* 02 */
  121. u32 cur_num_mrs; /* 03 */
  122. u32 auth_level; /* 04 */
  123. u32 max_num_qps; /* 05 */
  124. u32 max_num_cqs; /* 06 */
  125. u32 max_num_eqs; /* 07 */
  126. u32 max_num_mrs; /* 08 */
  127. u32 reserved0; /* 09 */
  128. u32 int_clock_freq; /* 10 */
  129. u32 max_num_pds; /* 11 */
  130. u32 max_num_addr_handles; /* 12 */
  131. u32 max_num_cqes; /* 13 */
  132. u32 max_num_wqes; /* 14 */
  133. u32 max_num_sgel_rq1wqe; /* 15 */
  134. u32 max_num_sgel_rq2wqe; /* 16 */
  135. u32 max_num_sgel_rq3wqe; /* 17 */
  136. u32 mr_page_size; /* 18 */
  137. u32 reserved1; /* 19 */
  138. u64 max_mr_size; /* 20 */
  139. u64 reserved2; /* 22 */
  140. u32 num_ports; /* 24 */
  141. u32 reserved3; /* 25 */
  142. u32 reserved4; /* 26 */
  143. u32 reserved5; /* 27 */
  144. u64 max_mc_mac; /* 28 */
  145. u64 ehea_cap; /* 30 */
  146. u32 max_isn_per_eq; /* 32 */
  147. u32 max_num_neq; /* 33 */
  148. u64 max_num_vlan_ids; /* 34 */
  149. u32 max_num_port_group; /* 36 */
  150. u32 max_num_phys_port; /* 37 */
  151. };
  152. /* Hcall Query/Modify Port Control Block defines */
  153. #define H_PORT_CB0 0
  154. #define H_PORT_CB1 1
  155. #define H_PORT_CB2 2
  156. #define H_PORT_CB3 3
  157. #define H_PORT_CB4 4
  158. #define H_PORT_CB5 5
  159. #define H_PORT_CB6 6
  160. #define H_PORT_CB7 7
  161. struct hcp_ehea_port_cb0 {
  162. u64 port_mac_addr;
  163. u64 port_rc;
  164. u64 reserved0;
  165. u32 port_op_state;
  166. u32 port_speed;
  167. u32 ext_swport_op_state;
  168. u32 neg_tpf_prpf;
  169. u32 num_default_qps;
  170. u32 reserved1;
  171. u64 default_qpn_arr[16];
  172. };
  173. /* Hcall Query/Modify Port Control Block 0 Selection Mask Bits */
  174. #define H_PORT_CB0_ALL EHEA_BMASK_IBM(0, 7) /* Set all bits */
  175. #define H_PORT_CB0_MAC EHEA_BMASK_IBM(0, 0) /* MAC address */
  176. #define H_PORT_CB0_PRC EHEA_BMASK_IBM(1, 1) /* Port Recv Control */
  177. #define H_PORT_CB0_DEFQPNARRAY EHEA_BMASK_IBM(7, 7) /* Default QPN Array */
  178. /* Hcall Query Port: Returned port speed values */
  179. #define H_SPEED_10M_H 1 /* 10 Mbps, Half Duplex */
  180. #define H_SPEED_10M_F 2 /* 10 Mbps, Full Duplex */
  181. #define H_SPEED_100M_H 3 /* 100 Mbps, Half Duplex */
  182. #define H_SPEED_100M_F 4 /* 100 Mbps, Full Duplex */
  183. #define H_SPEED_1G_F 6 /* 1 Gbps, Full Duplex */
  184. #define H_SPEED_10G_F 8 /* 10 Gbps, Full Duplex */
  185. /* Port Receive Control Status Bits */
  186. #define PXLY_RC_VALID EHEA_BMASK_IBM(49, 49)
  187. #define PXLY_RC_VLAN_XTRACT EHEA_BMASK_IBM(50, 50)
  188. #define PXLY_RC_TCP_6_TUPLE EHEA_BMASK_IBM(51, 51)
  189. #define PXLY_RC_UDP_6_TUPLE EHEA_BMASK_IBM(52, 52)
  190. #define PXLY_RC_TCP_3_TUPLE EHEA_BMASK_IBM(53, 53)
  191. #define PXLY_RC_TCP_2_TUPLE EHEA_BMASK_IBM(54, 54)
  192. #define PXLY_RC_LLC_SNAP EHEA_BMASK_IBM(55, 55)
  193. #define PXLY_RC_JUMBO_FRAME EHEA_BMASK_IBM(56, 56)
  194. #define PXLY_RC_FRAG_IP_PKT EHEA_BMASK_IBM(57, 57)
  195. #define PXLY_RC_TCP_UDP_CHKSUM EHEA_BMASK_IBM(58, 58)
  196. #define PXLY_RC_IP_CHKSUM EHEA_BMASK_IBM(59, 59)
  197. #define PXLY_RC_MAC_FILTER EHEA_BMASK_IBM(60, 60)
  198. #define PXLY_RC_UNTAG_FILTER EHEA_BMASK_IBM(61, 61)
  199. #define PXLY_RC_VLAN_TAG_FILTER EHEA_BMASK_IBM(62, 63)
  200. #define PXLY_RC_VLAN_FILTER 2
  201. #define PXLY_RC_VLAN_PERM 0
  202. #define H_PORT_CB1_ALL 0x8000000000000000ULL
  203. struct hcp_ehea_port_cb1 {
  204. u64 vlan_filter[64];
  205. };
  206. #define H_PORT_CB2_ALL 0xFFE0000000000000ULL
  207. struct hcp_ehea_port_cb2 {
  208. u64 rxo;
  209. u64 rxucp;
  210. u64 rxufd;
  211. u64 rxuerr;
  212. u64 rxftl;
  213. u64 rxmcp;
  214. u64 rxbcp;
  215. u64 txo;
  216. u64 txucp;
  217. u64 txmcp;
  218. u64 txbcp;
  219. };
  220. struct hcp_ehea_port_cb3 {
  221. u64 vlan_bc_filter[64];
  222. u64 vlan_mc_filter[64];
  223. u64 vlan_un_filter[64];
  224. u64 port_mac_hash_array[64];
  225. };
  226. #define H_PORT_CB4_ALL 0xF000000000000000ULL
  227. #define H_PORT_CB4_JUMBO 0x1000000000000000ULL
  228. #define H_PORT_CB4_SPEED 0x8000000000000000ULL
  229. struct hcp_ehea_port_cb4 {
  230. u32 port_speed;
  231. u32 pause_frame;
  232. u32 ens_port_op_state;
  233. u32 jumbo_frame;
  234. u32 ens_port_wrap;
  235. };
  236. /* Hcall Query/Modify Port Control Block 5 Selection Mask Bits */
  237. #define H_PORT_CB5_RCU 0x0001000000000000ULL
  238. #define PXS_RCU EHEA_BMASK_IBM(61, 63)
  239. struct hcp_ehea_port_cb5 {
  240. u64 prc; /* 00 */
  241. u64 uaa; /* 01 */
  242. u64 macvc; /* 02 */
  243. u64 xpcsc; /* 03 */
  244. u64 xpcsp; /* 04 */
  245. u64 pcsid; /* 05 */
  246. u64 xpcsst; /* 06 */
  247. u64 pthlb; /* 07 */
  248. u64 pthrb; /* 08 */
  249. u64 pqu; /* 09 */
  250. u64 pqd; /* 10 */
  251. u64 prt; /* 11 */
  252. u64 wsth; /* 12 */
  253. u64 rcb; /* 13 */
  254. u64 rcm; /* 14 */
  255. u64 rcu; /* 15 */
  256. u64 macc; /* 16 */
  257. u64 pc; /* 17 */
  258. u64 pst; /* 18 */
  259. u64 ducqpn; /* 19 */
  260. u64 mcqpn; /* 20 */
  261. u64 mma; /* 21 */
  262. u64 pmc0h; /* 22 */
  263. u64 pmc0l; /* 23 */
  264. u64 lbc; /* 24 */
  265. };
  266. #define H_PORT_CB6_ALL 0xFFFFFE7FFFFF8000ULL
  267. struct hcp_ehea_port_cb6 {
  268. u64 rxo; /* 00 */
  269. u64 rx64; /* 01 */
  270. u64 rx65; /* 02 */
  271. u64 rx128; /* 03 */
  272. u64 rx256; /* 04 */
  273. u64 rx512; /* 05 */
  274. u64 rx1024; /* 06 */
  275. u64 rxbfcs; /* 07 */
  276. u64 rxime; /* 08 */
  277. u64 rxrle; /* 09 */
  278. u64 rxorle; /* 10 */
  279. u64 rxftl; /* 11 */
  280. u64 rxjab; /* 12 */
  281. u64 rxse; /* 13 */
  282. u64 rxce; /* 14 */
  283. u64 rxrf; /* 15 */
  284. u64 rxfrag; /* 16 */
  285. u64 rxuoc; /* 17 */
  286. u64 rxcpf; /* 18 */
  287. u64 rxsb; /* 19 */
  288. u64 rxfd; /* 20 */
  289. u64 rxoerr; /* 21 */
  290. u64 rxaln; /* 22 */
  291. u64 ducqpn; /* 23 */
  292. u64 reserved0; /* 24 */
  293. u64 rxmcp; /* 25 */
  294. u64 rxbcp; /* 26 */
  295. u64 txmcp; /* 27 */
  296. u64 txbcp; /* 28 */
  297. u64 txo; /* 29 */
  298. u64 tx64; /* 30 */
  299. u64 tx65; /* 31 */
  300. u64 tx128; /* 32 */
  301. u64 tx256; /* 33 */
  302. u64 tx512; /* 34 */
  303. u64 tx1024; /* 35 */
  304. u64 txbfcs; /* 36 */
  305. u64 txcpf; /* 37 */
  306. u64 txlf; /* 38 */
  307. u64 txrf; /* 39 */
  308. u64 txime; /* 40 */
  309. u64 txsc; /* 41 */
  310. u64 txmc; /* 42 */
  311. u64 txsqe; /* 43 */
  312. u64 txdef; /* 44 */
  313. u64 txlcol; /* 45 */
  314. u64 txexcol; /* 46 */
  315. u64 txcse; /* 47 */
  316. u64 txbor; /* 48 */
  317. };
  318. #define H_PORT_CB7_DUCQPN 0x8000000000000000ULL
  319. struct hcp_ehea_port_cb7 {
  320. u64 def_uc_qpn;
  321. };
  322. u64 ehea_h_query_ehea_qp(const u64 adapter_handle,
  323. const u8 qp_category,
  324. const u64 qp_handle, const u64 sel_mask,
  325. void *cb_addr);
  326. u64 ehea_h_modify_ehea_qp(const u64 adapter_handle,
  327. const u8 cat,
  328. const u64 qp_handle,
  329. const u64 sel_mask,
  330. void *cb_addr,
  331. u64 *inv_attr_id,
  332. u64 *proc_mask, u16 *out_swr, u16 *out_rwr);
  333. u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
  334. struct ehea_eq_attr *eq_attr, u64 *eq_handle);
  335. u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
  336. struct ehea_cq_attr *cq_attr,
  337. u64 *cq_handle, struct h_epas *epas);
  338. u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
  339. struct ehea_qp_init_attr *init_attr,
  340. const u32 pd,
  341. u64 *qp_handle, struct h_epas *h_epas);
  342. #define H_REG_RPAGE_PAGE_SIZE EHEA_BMASK_IBM(48, 55)
  343. #define H_REG_RPAGE_QT EHEA_BMASK_IBM(62, 63)
  344. u64 ehea_h_register_rpage(const u64 adapter_handle,
  345. const u8 pagesize,
  346. const u8 queue_type,
  347. const u64 resource_handle,
  348. const u64 log_pageaddr, u64 count);
  349. #define H_DISABLE_GET_EHEA_WQE_P 1
  350. #define H_DISABLE_GET_SQ_WQE_P 2
  351. #define H_DISABLE_GET_RQC 3
  352. u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle);
  353. #define FORCE_FREE 1
  354. #define NORMAL_FREE 0
  355. u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle,
  356. u64 force_bit);
  357. u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
  358. const u64 length, const u32 access_ctrl,
  359. const u32 pd, u64 *mr_handle, u32 *lkey);
  360. u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
  361. const u8 pagesize, const u8 queue_type,
  362. const u64 log_pageaddr, const u64 count);
  363. u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
  364. const u64 vaddr_in, const u32 access_ctrl, const u32 pd,
  365. struct ehea_mr *mr);
  366. u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr);
  367. /* output param R5 */
  368. #define H_MEHEAPORT_CAT EHEA_BMASK_IBM(40, 47)
  369. #define H_MEHEAPORT_PN EHEA_BMASK_IBM(48, 63)
  370. u64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num,
  371. const u8 cb_cat, const u64 select_mask,
  372. void *cb_addr);
  373. u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
  374. const u8 cb_cat, const u64 select_mask,
  375. void *cb_addr);
  376. #define H_REGBCMC_PN EHEA_BMASK_IBM(48, 63)
  377. #define H_REGBCMC_REGTYPE EHEA_BMASK_IBM(60, 63)
  378. #define H_REGBCMC_MACADDR EHEA_BMASK_IBM(16, 63)
  379. #define H_REGBCMC_VLANID EHEA_BMASK_IBM(52, 63)
  380. u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
  381. const u8 reg_type, const u64 mc_mac_addr,
  382. const u16 vlan_id, const u32 hcall_id);
  383. u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle,
  384. const u64 event_mask);
  385. u64 ehea_h_error_data(const u64 adapter_handle, const u64 ressource_handle,
  386. void *rblock);
  387. #endif /* __EHEA_PHYP_H__ */