qeth_core_mpc.c 8.9 KB

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