/drivers/net/ethernet/ibm/ehea/ehea_phyp.h

http://github.com/mirrors/linux · C Header · 433 lines · 340 code · 60 blank · 33 comment · 1 complexity · 7cdc68372fec84d637804b2def000769 MD5 · raw file

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