qeth_core_mpc.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Copyright IBM Corp. 2007
  3. * Author(s): Frank Pavlic <fpavlic@de.ibm.com>,
  4. * Thomas Spatzier <tspat@de.ibm.com>,
  5. * Frank Blaschka <frank.blaschka@de.ibm.com>
  6. */
  7. #include <linux/module.h>
  8. #include <asm/cio.h>
  9. #include "qeth_core_mpc.h"
  10. unsigned char IDX_ACTIVATE_READ[] = {
  11. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
  12. 0x19, 0x01, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
  13. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc1,
  14. 0xd3, 0xd3, 0xd6, 0xd3, 0xc5, 0x40, 0x00, 0x00,
  15. 0x00, 0x00
  16. };
  17. unsigned char IDX_ACTIVATE_WRITE[] = {
  18. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
  19. 0x15, 0x01, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
  20. 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc1,
  21. 0xd3, 0xd3, 0xd6, 0xd3, 0xc5, 0x40, 0x00, 0x00,
  22. 0x00, 0x00
  23. };
  24. unsigned char CM_ENABLE[] = {
  25. 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  26. 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x63,
  27. 0x10, 0x00, 0x00, 0x01,
  28. 0x00, 0x00, 0x00, 0x00,
  29. 0x81, 0x7e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  30. 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x23,
  31. 0x00, 0x00, 0x23, 0x05, 0x00, 0x00, 0x00, 0x00,
  32. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  33. 0x01, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40,
  34. 0x00, 0x0c, 0x41, 0x02, 0x00, 0x17, 0x00, 0x00,
  35. 0x00, 0x00, 0x00, 0x00,
  36. 0x00, 0x0b, 0x04, 0x01,
  37. 0x7e, 0x04, 0x05, 0x00, 0x01, 0x01, 0x0f,
  38. 0x00,
  39. 0x0c, 0x04, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff,
  40. 0xff, 0xff, 0xff
  41. };
  42. unsigned char CM_SETUP[] = {
  43. 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
  44. 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x64,
  45. 0x10, 0x00, 0x00, 0x01,
  46. 0x00, 0x00, 0x00, 0x00,
  47. 0x81, 0x7e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  48. 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x24,
  49. 0x00, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x00,
  50. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  51. 0x01, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x40,
  52. 0x00, 0x0c, 0x41, 0x04, 0x00, 0x18, 0x00, 0x00,
  53. 0x00, 0x00, 0x00, 0x00,
  54. 0x00, 0x09, 0x04, 0x04,
  55. 0x05, 0x00, 0x01, 0x01, 0x11,
  56. 0x00, 0x09, 0x04,
  57. 0x05, 0x05, 0x00, 0x00, 0x00, 0x00,
  58. 0x00, 0x06,
  59. 0x04, 0x06, 0xc8, 0x00
  60. };
  61. unsigned char ULP_ENABLE[] = {
  62. 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
  63. 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x6b,
  64. 0x10, 0x00, 0x00, 0x01,
  65. 0x00, 0x00, 0x00, 0x00,
  66. 0x41, 0x7e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  67. 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x2b,
  68. 0x00, 0x00, 0x2b, 0x05, 0x20, 0x01, 0x00, 0x00,
  69. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  70. 0x01, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x40,
  71. 0x00, 0x0c, 0x41, 0x02, 0x00, 0x1f, 0x00, 0x00,
  72. 0x00, 0x00, 0x00, 0x00,
  73. 0x00, 0x0b, 0x04, 0x01,
  74. 0x03, 0x04, 0x05, 0x00, 0x01, 0x01, 0x12,
  75. 0x00,
  76. 0x14, 0x04, 0x0a, 0x00, 0x20, 0x00, 0x00, 0xff,
  77. 0xff, 0x00, 0x08, 0xc8, 0xe8, 0xc4, 0xf1, 0xc7,
  78. 0xf1, 0x00, 0x00
  79. };
  80. unsigned char ULP_SETUP[] = {
  81. 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
  82. 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x6c,
  83. 0x10, 0x00, 0x00, 0x01,
  84. 0x00, 0x00, 0x00, 0x00,
  85. 0x41, 0x7e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
  86. 0x00, 0x00, 0x00, 0x01, 0x00, 0x24, 0x00, 0x2c,
  87. 0x00, 0x00, 0x2c, 0x05, 0x20, 0x01, 0x00, 0x00,
  88. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  89. 0x01, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x40,
  90. 0x00, 0x0c, 0x41, 0x04, 0x00, 0x20, 0x00, 0x00,
  91. 0x00, 0x00, 0x00, 0x00,
  92. 0x00, 0x09, 0x04, 0x04,
  93. 0x05, 0x00, 0x01, 0x01, 0x14,
  94. 0x00, 0x09, 0x04,
  95. 0x05, 0x05, 0x30, 0x01, 0x00, 0x00,
  96. 0x00, 0x06,
  97. 0x04, 0x06, 0x40, 0x00,
  98. 0x00, 0x08, 0x04, 0x0b,
  99. 0x00, 0x00, 0x00, 0x00
  100. };
  101. unsigned char DM_ACT[] = {
  102. 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
  103. 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x55,
  104. 0x10, 0x00, 0x00, 0x01,
  105. 0x00, 0x00, 0x00, 0x00,
  106. 0x41, 0x7e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03,
  107. 0x00, 0x00, 0x00, 0x02, 0x00, 0x24, 0x00, 0x15,
  108. 0x00, 0x00, 0x2c, 0x05, 0x20, 0x01, 0x00, 0x00,
  109. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  110. 0x01, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x40,
  111. 0x00, 0x0c, 0x43, 0x60, 0x00, 0x09, 0x00, 0x00,
  112. 0x00, 0x00, 0x00, 0x00,
  113. 0x00, 0x09, 0x04, 0x04,
  114. 0x05, 0x40, 0x01, 0x01, 0x00
  115. };
  116. unsigned char IPA_PDU_HEADER[] = {
  117. 0x00, 0xe0, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77,
  118. 0x00, 0x00, 0x00, 0x14, 0x00, 0x00,
  119. (IPA_PDU_HEADER_SIZE+sizeof(struct qeth_ipa_cmd)) / 256,
  120. (IPA_PDU_HEADER_SIZE+sizeof(struct qeth_ipa_cmd)) % 256,
  121. 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  122. 0xc1, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  123. 0x00, 0x00, 0x00, 0x00, 0x00, 0x24,
  124. sizeof(struct qeth_ipa_cmd) / 256,
  125. sizeof(struct qeth_ipa_cmd) % 256,
  126. 0x00,
  127. sizeof(struct qeth_ipa_cmd) / 256,
  128. sizeof(struct qeth_ipa_cmd) % 256,
  129. 0x05,
  130. 0x77, 0x77, 0x77, 0x77,
  131. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  132. 0x01, 0x00,
  133. sizeof(struct qeth_ipa_cmd) / 256,
  134. sizeof(struct qeth_ipa_cmd) % 256,
  135. 0x00, 0x00, 0x00, 0x40,
  136. };
  137. EXPORT_SYMBOL_GPL(IPA_PDU_HEADER);
  138. unsigned char WRITE_CCW[] = {
  139. 0x01, CCW_FLAG_SLI, 0, 0,
  140. 0, 0, 0, 0
  141. };
  142. unsigned char READ_CCW[] = {
  143. 0x02, CCW_FLAG_SLI, 0, 0,
  144. 0, 0, 0, 0
  145. };
  146. struct ipa_rc_msg {
  147. enum qeth_ipa_return_codes rc;
  148. char *msg;
  149. };
  150. static struct ipa_rc_msg qeth_ipa_rc_msg[] = {
  151. {IPA_RC_SUCCESS, "success"},
  152. {IPA_RC_NOTSUPP, "Command not supported"},
  153. {IPA_RC_IP_TABLE_FULL, "Add Addr IP Table Full - ipv6"},
  154. {IPA_RC_UNKNOWN_ERROR, "IPA command failed - reason unknown"},
  155. {IPA_RC_UNSUPPORTED_COMMAND, "Command not supported"},
  156. {IPA_RC_DUP_IPV6_REMOTE, "ipv6 address already registered remote"},
  157. {IPA_RC_DUP_IPV6_HOME, "ipv6 address already registered"},
  158. {IPA_RC_UNREGISTERED_ADDR, "Address not registered"},
  159. {IPA_RC_NO_ID_AVAILABLE, "No identifiers available"},
  160. {IPA_RC_ID_NOT_FOUND, "Identifier not found"},
  161. {IPA_RC_INVALID_IP_VERSION, "IP version incorrect"},
  162. {IPA_RC_LAN_FRAME_MISMATCH, "LAN and frame mismatch"},
  163. {IPA_RC_L2_UNSUPPORTED_CMD, "Unsupported layer 2 command"},
  164. {IPA_RC_L2_DUP_MAC, "Duplicate MAC address"},
  165. {IPA_RC_L2_ADDR_TABLE_FULL, "Layer2 address table full"},
  166. {IPA_RC_L2_DUP_LAYER3_MAC, "Duplicate with layer 3 MAC"},
  167. {IPA_RC_L2_GMAC_NOT_FOUND, "GMAC not found"},
  168. {IPA_RC_L2_MAC_NOT_AUTH_BY_HYP, "L2 mac not authorized by hypervisor"},
  169. {IPA_RC_L2_MAC_NOT_AUTH_BY_ADP, "L2 mac not authorized by adapter"},
  170. {IPA_RC_L2_MAC_NOT_FOUND, "L2 mac address not found"},
  171. {IPA_RC_L2_INVALID_VLAN_ID, "L2 invalid vlan id"},
  172. {IPA_RC_L2_DUP_VLAN_ID, "L2 duplicate vlan id"},
  173. {IPA_RC_L2_VLAN_ID_NOT_FOUND, "L2 vlan id not found"},
  174. {IPA_RC_DATA_MISMATCH, "Data field mismatch (v4/v6 mixed)"},
  175. {IPA_RC_INVALID_MTU_SIZE, "Invalid MTU size"},
  176. {IPA_RC_INVALID_LANTYPE, "Invalid LAN type"},
  177. {IPA_RC_INVALID_LANNUM, "Invalid LAN num"},
  178. {IPA_RC_DUPLICATE_IP_ADDRESS, "Address already registered"},
  179. {IPA_RC_IP_ADDR_TABLE_FULL, "IP address table full"},
  180. {IPA_RC_LAN_PORT_STATE_ERROR, "LAN port state error"},
  181. {IPA_RC_SETIP_NO_STARTLAN, "Setip no startlan received"},
  182. {IPA_RC_SETIP_ALREADY_RECEIVED, "Setip already received"},
  183. {IPA_RC_IP_ADDR_ALREADY_USED, "IP address already in use on LAN"},
  184. {IPA_RC_MC_ADDR_NOT_FOUND, "Multicast address not found"},
  185. {IPA_RC_SETIP_INVALID_VERSION, "SETIP invalid IP version"},
  186. {IPA_RC_UNSUPPORTED_SUBCMD, "Unsupported assist subcommand"},
  187. {IPA_RC_ARP_ASSIST_NO_ENABLE, "Only partial success, no enable"},
  188. {IPA_RC_PRIMARY_ALREADY_DEFINED, "Primary already defined"},
  189. {IPA_RC_SECOND_ALREADY_DEFINED, "Secondary already defined"},
  190. {IPA_RC_INVALID_SETRTG_INDICATOR, "Invalid SETRTG indicator"},
  191. {IPA_RC_MC_ADDR_ALREADY_DEFINED, "Multicast address already defined"},
  192. {IPA_RC_LAN_OFFLINE, "STRTLAN_LAN_DISABLED - LAN offline"},
  193. {IPA_RC_VEPA_TO_VEB_TRANSITION, "Adj. switch disabled port mode RR"},
  194. {IPA_RC_INVALID_IP_VERSION2, "Invalid IP version"},
  195. {IPA_RC_ENOMEM, "Memory problem"},
  196. {IPA_RC_FFFF, "Unknown Error"}
  197. };
  198. char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc)
  199. {
  200. int x = 0;
  201. qeth_ipa_rc_msg[sizeof(qeth_ipa_rc_msg) /
  202. sizeof(struct ipa_rc_msg) - 1].rc = rc;
  203. while (qeth_ipa_rc_msg[x].rc != rc)
  204. x++;
  205. return qeth_ipa_rc_msg[x].msg;
  206. }
  207. struct ipa_cmd_names {
  208. enum qeth_ipa_cmds cmd;
  209. char *name;
  210. };
  211. static struct ipa_cmd_names qeth_ipa_cmd_names[] = {
  212. {IPA_CMD_STARTLAN, "startlan"},
  213. {IPA_CMD_STOPLAN, "stoplan"},
  214. {IPA_CMD_SETVMAC, "setvmac"},
  215. {IPA_CMD_DELVMAC, "delvmac"},
  216. {IPA_CMD_SETGMAC, "setgmac"},
  217. {IPA_CMD_DELGMAC, "delgmac"},
  218. {IPA_CMD_SETVLAN, "setvlan"},
  219. {IPA_CMD_DELVLAN, "delvlan"},
  220. {IPA_CMD_SETBRIDGEPORT_OSA, "set_bridge_port(osa)"},
  221. {IPA_CMD_SETCCID, "setccid"},
  222. {IPA_CMD_DELCCID, "delccid"},
  223. {IPA_CMD_MODCCID, "modccid"},
  224. {IPA_CMD_SETIP, "setip"},
  225. {IPA_CMD_QIPASSIST, "qipassist"},
  226. {IPA_CMD_SETASSPARMS, "setassparms"},
  227. {IPA_CMD_SETIPM, "setipm"},
  228. {IPA_CMD_DELIPM, "delipm"},
  229. {IPA_CMD_SETRTG, "setrtg"},
  230. {IPA_CMD_DELIP, "delip"},
  231. {IPA_CMD_SETADAPTERPARMS, "setadapterparms"},
  232. {IPA_CMD_SET_DIAG_ASS, "set_diag_ass"},
  233. {IPA_CMD_SETBRIDGEPORT_IQD, "set_bridge_port(hs)"},
  234. {IPA_CMD_CREATE_ADDR, "create_addr"},
  235. {IPA_CMD_DESTROY_ADDR, "destroy_addr"},
  236. {IPA_CMD_REGISTER_LOCAL_ADDR, "register_local_addr"},
  237. {IPA_CMD_UNREGISTER_LOCAL_ADDR, "unregister_local_addr"},
  238. {IPA_CMD_ADDRESS_CHANGE_NOTIF, "address_change_notification"},
  239. {IPA_CMD_UNKNOWN, "unknown"},
  240. };
  241. char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd)
  242. {
  243. int x = 0;
  244. qeth_ipa_cmd_names[
  245. sizeof(qeth_ipa_cmd_names) /
  246. sizeof(struct ipa_cmd_names)-1].cmd = cmd;
  247. while (qeth_ipa_cmd_names[x].cmd != cmd)
  248. x++;
  249. return qeth_ipa_cmd_names[x].name;
  250. }