ibmvnic.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053
  1. /**************************************************************************/
  2. /* */
  3. /* IBM System i and System p Virtual NIC Device Driver */
  4. /* Copyright (C) 2014 IBM Corp. */
  5. /* Santiago Leon (santi_leon@yahoo.com) */
  6. /* Thomas Falcon (tlfalcon@linux.vnet.ibm.com) */
  7. /* John Allen (jallen@linux.vnet.ibm.com) */
  8. /* */
  9. /* This program is free software; you can redistribute it and/or modify */
  10. /* it under the terms of the GNU General Public License as published by */
  11. /* the Free Software Foundation; either version 2 of the License, or */
  12. /* (at your option) any later version. */
  13. /* */
  14. /* This program is distributed in the hope that it will be useful, */
  15. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  16. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  17. /* GNU General Public License for more details. */
  18. /* */
  19. /* You should have received a copy of the GNU General Public License */
  20. /* along with this program. */
  21. /* */
  22. /* This module contains the implementation of a virtual ethernet device */
  23. /* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */
  24. /* option of the RS/6000 Platform Architecture to interface with virtual */
  25. /* ethernet NICs that are presented to the partition by the hypervisor. */
  26. /* */
  27. /**************************************************************************/
  28. #define IBMVNIC_NAME "ibmvnic"
  29. #define IBMVNIC_DRIVER_VERSION "1.0.1"
  30. #define IBMVNIC_INVALID_MAP -1
  31. #define IBMVNIC_STATS_TIMEOUT 1
  32. /* basic structures plus 100 2k buffers */
  33. #define IBMVNIC_IO_ENTITLEMENT_DEFAULT 610305
  34. /* Initial module_parameters */
  35. #define IBMVNIC_RX_WEIGHT 16
  36. /* when changing this, update IBMVNIC_IO_ENTITLEMENT_DEFAULT */
  37. #define IBMVNIC_BUFFS_PER_POOL 100
  38. #define IBMVNIC_MAX_TX_QUEUES 5
  39. struct ibmvnic_login_buffer {
  40. __be32 len;
  41. __be32 version;
  42. #define INITIAL_VERSION_LB 1
  43. __be32 num_txcomp_subcrqs;
  44. __be32 off_txcomp_subcrqs;
  45. __be32 num_rxcomp_subcrqs;
  46. __be32 off_rxcomp_subcrqs;
  47. __be32 login_rsp_ioba;
  48. __be32 login_rsp_len;
  49. } __packed __aligned(8);
  50. struct ibmvnic_login_rsp_buffer {
  51. __be32 len;
  52. __be32 version;
  53. #define INITIAL_VERSION_LRB 1
  54. __be32 num_txsubm_subcrqs;
  55. __be32 off_txsubm_subcrqs;
  56. __be32 num_rxadd_subcrqs;
  57. __be32 off_rxadd_subcrqs;
  58. __be32 off_rxadd_buff_size;
  59. __be32 num_supp_tx_desc;
  60. __be32 off_supp_tx_desc;
  61. } __packed __aligned(8);
  62. struct ibmvnic_query_ip_offload_buffer {
  63. __be32 len;
  64. __be32 version;
  65. #define INITIAL_VERSION_IOB 1
  66. u8 ipv4_chksum;
  67. u8 ipv6_chksum;
  68. u8 tcp_ipv4_chksum;
  69. u8 tcp_ipv6_chksum;
  70. u8 udp_ipv4_chksum;
  71. u8 udp_ipv6_chksum;
  72. u8 large_tx_ipv4;
  73. u8 large_tx_ipv6;
  74. u8 large_rx_ipv4;
  75. u8 large_rx_ipv6;
  76. u8 reserved1[14];
  77. __be16 max_ipv4_header_size;
  78. __be16 max_ipv6_header_size;
  79. __be16 max_tcp_header_size;
  80. __be16 max_udp_header_size;
  81. __be32 max_large_tx_size;
  82. __be32 max_large_rx_size;
  83. u8 reserved2[16];
  84. u8 ipv6_extension_header;
  85. #define IPV6_EH_NOT_SUPPORTED 0x00
  86. #define IPV6_EH_SUPPORTED_LIM 0x01
  87. #define IPV6_EH_SUPPORTED 0xFF
  88. u8 tcp_pseudosum_req;
  89. #define TCP_PS_NOT_REQUIRED 0x00
  90. #define TCP_PS_REQUIRED 0x01
  91. u8 reserved3[30];
  92. __be16 num_ipv6_ext_headers;
  93. __be32 off_ipv6_ext_headers;
  94. u8 reserved4[154];
  95. } __packed __aligned(8);
  96. struct ibmvnic_control_ip_offload_buffer {
  97. __be32 len;
  98. __be32 version;
  99. #define INITIAL_VERSION_IOB 1
  100. u8 ipv4_chksum;
  101. u8 ipv6_chksum;
  102. u8 tcp_ipv4_chksum;
  103. u8 tcp_ipv6_chksum;
  104. u8 udp_ipv4_chksum;
  105. u8 udp_ipv6_chksum;
  106. u8 large_tx_ipv4;
  107. u8 large_tx_ipv6;
  108. u8 bad_packet_rx;
  109. u8 large_rx_ipv4;
  110. u8 large_rx_ipv6;
  111. u8 reserved4[111];
  112. } __packed __aligned(8);
  113. struct ibmvnic_fw_component {
  114. u8 name[48];
  115. __be32 trace_buff_size;
  116. u8 correlator;
  117. u8 trace_level;
  118. u8 parent_correlator;
  119. u8 error_check_level;
  120. u8 trace_on;
  121. u8 reserved[7];
  122. u8 description[192];
  123. } __packed __aligned(8);
  124. struct ibmvnic_fw_trace_entry {
  125. __be32 trace_id;
  126. u8 num_valid_data;
  127. u8 reserved[3];
  128. __be64 pmc_registers;
  129. __be64 timebase;
  130. __be64 trace_data[5];
  131. } __packed __aligned(8);
  132. struct ibmvnic_statistics {
  133. __be32 version;
  134. __be32 promiscuous;
  135. __be64 rx_packets;
  136. __be64 rx_bytes;
  137. __be64 tx_packets;
  138. __be64 tx_bytes;
  139. __be64 ucast_tx_packets;
  140. __be64 ucast_rx_packets;
  141. __be64 mcast_tx_packets;
  142. __be64 mcast_rx_packets;
  143. __be64 bcast_tx_packets;
  144. __be64 bcast_rx_packets;
  145. __be64 align_errors;
  146. __be64 fcs_errors;
  147. __be64 single_collision_frames;
  148. __be64 multi_collision_frames;
  149. __be64 sqe_test_errors;
  150. __be64 deferred_tx;
  151. __be64 late_collisions;
  152. __be64 excess_collisions;
  153. __be64 internal_mac_tx_errors;
  154. __be64 carrier_sense;
  155. __be64 too_long_frames;
  156. __be64 internal_mac_rx_errors;
  157. u8 reserved[72];
  158. } __packed __aligned(8);
  159. struct ibmvnic_acl_buffer {
  160. __be32 len;
  161. __be32 version;
  162. #define INITIAL_VERSION_IOB 1
  163. u8 mac_acls_restrict;
  164. u8 vlan_acls_restrict;
  165. u8 reserved1[22];
  166. __be32 num_mac_addrs;
  167. __be32 offset_mac_addrs;
  168. __be32 num_vlan_ids;
  169. __be32 offset_vlan_ids;
  170. u8 reserved2[80];
  171. } __packed __aligned(8);
  172. /* descriptors have been changed, how should this be defined? 1? 4? */
  173. #define IBMVNIC_TX_DESC_VERSIONS 3
  174. /* is this still needed? */
  175. struct ibmvnic_tx_comp_desc {
  176. u8 first;
  177. u8 num_comps;
  178. __be16 rcs[5];
  179. __be32 correlators[5];
  180. } __packed __aligned(8);
  181. /* some flags that included in v0 descriptor, which is gone
  182. * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
  183. * and only in some offload_flags variable that doesn't seem
  184. * to be used anywhere, can probably be removed?
  185. */
  186. #define IBMVNIC_TCP_CHKSUM 0x20
  187. #define IBMVNIC_UDP_CHKSUM 0x08
  188. #define IBMVNIC_MAX_FRAGS_PER_CRQ 3
  189. struct ibmvnic_tx_desc {
  190. u8 first;
  191. u8 type;
  192. #define IBMVNIC_TX_DESC 0x10
  193. u8 n_crq_elem;
  194. u8 n_sge;
  195. u8 flags1;
  196. #define IBMVNIC_TX_COMP_NEEDED 0x80
  197. #define IBMVNIC_TX_CHKSUM_OFFLOAD 0x40
  198. #define IBMVNIC_TX_LSO 0x20
  199. #define IBMVNIC_TX_PROT_TCP 0x10
  200. #define IBMVNIC_TX_PROT_UDP 0x08
  201. #define IBMVNIC_TX_PROT_IPV4 0x04
  202. #define IBMVNIC_TX_PROT_IPV6 0x02
  203. #define IBMVNIC_TX_VLAN_PRESENT 0x01
  204. u8 flags2;
  205. #define IBMVNIC_TX_VLAN_INSERT 0x80
  206. __be16 mss;
  207. u8 reserved[4];
  208. __be32 correlator;
  209. __be16 vlan_id;
  210. __be16 dma_reg;
  211. __be32 sge_len;
  212. __be64 ioba;
  213. } __packed __aligned(8);
  214. struct ibmvnic_hdr_desc {
  215. u8 first;
  216. u8 type;
  217. #define IBMVNIC_HDR_DESC 0x11
  218. u8 len;
  219. u8 l2_len;
  220. __be16 l3_len;
  221. u8 l4_len;
  222. u8 flag;
  223. u8 data[24];
  224. } __packed __aligned(8);
  225. struct ibmvnic_hdr_ext_desc {
  226. u8 first;
  227. u8 type;
  228. #define IBMVNIC_HDR_EXT_DESC 0x12
  229. u8 len;
  230. u8 data[29];
  231. } __packed __aligned(8);
  232. struct ibmvnic_sge_desc {
  233. u8 first;
  234. u8 type;
  235. #define IBMVNIC_SGE_DESC 0x30
  236. __be16 sge1_dma_reg;
  237. __be32 sge1_len;
  238. __be64 sge1_ioba;
  239. __be16 reserved;
  240. __be16 sge2_dma_reg;
  241. __be32 sge2_len;
  242. __be64 sge2_ioba;
  243. } __packed __aligned(8);
  244. struct ibmvnic_rx_comp_desc {
  245. u8 first;
  246. u8 flags;
  247. #define IBMVNIC_IP_CHKSUM_GOOD 0x80
  248. #define IBMVNIC_TCP_UDP_CHKSUM_GOOD 0x40
  249. #define IBMVNIC_END_FRAME 0x20
  250. #define IBMVNIC_EXACT_MC 0x10
  251. #define IBMVNIC_VLAN_STRIPPED 0x08
  252. __be16 off_frame_data;
  253. __be32 len;
  254. __be64 correlator;
  255. __be16 vlan_tci;
  256. __be16 rc;
  257. u8 reserved[12];
  258. } __packed __aligned(8);
  259. struct ibmvnic_generic_scrq {
  260. u8 first;
  261. u8 reserved[31];
  262. } __packed __aligned(8);
  263. struct ibmvnic_rx_buff_add_desc {
  264. u8 first;
  265. u8 reserved[7];
  266. __be64 correlator;
  267. __be32 ioba;
  268. u8 map_id;
  269. __be32 len:24;
  270. u8 reserved2[8];
  271. } __packed __aligned(8);
  272. struct ibmvnic_rc {
  273. u8 code; /* one of enum ibmvnic_rc_codes */
  274. u8 detailed_data[3];
  275. } __packed __aligned(4);
  276. struct ibmvnic_generic_crq {
  277. u8 first;
  278. u8 cmd;
  279. u8 params[10];
  280. struct ibmvnic_rc rc;
  281. } __packed __aligned(8);
  282. struct ibmvnic_version_exchange {
  283. u8 first;
  284. u8 cmd;
  285. __be16 version;
  286. #define IBMVNIC_INITIAL_VERSION 1
  287. u8 reserved[8];
  288. struct ibmvnic_rc rc;
  289. } __packed __aligned(8);
  290. struct ibmvnic_capability {
  291. u8 first;
  292. u8 cmd;
  293. __be16 capability; /* one of ibmvnic_capabilities */
  294. __be64 number;
  295. struct ibmvnic_rc rc;
  296. } __packed __aligned(8);
  297. struct ibmvnic_login {
  298. u8 first;
  299. u8 cmd;
  300. u8 reserved[6];
  301. __be32 ioba;
  302. __be32 len;
  303. } __packed __aligned(8);
  304. struct ibmvnic_phys_parms {
  305. u8 first;
  306. u8 cmd;
  307. u8 flags1;
  308. #define IBMVNIC_EXTERNAL_LOOPBACK 0x80
  309. #define IBMVNIC_INTERNAL_LOOPBACK 0x40
  310. #define IBMVNIC_PROMISC 0x20
  311. #define IBMVNIC_PHYS_LINK_ACTIVE 0x10
  312. #define IBMVNIC_AUTONEG_DUPLEX 0x08
  313. #define IBMVNIC_FULL_DUPLEX 0x04
  314. #define IBMVNIC_HALF_DUPLEX 0x02
  315. #define IBMVNIC_CAN_CHG_PHYS_PARMS 0x01
  316. u8 flags2;
  317. #define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
  318. __be32 speed;
  319. #define IBMVNIC_AUTONEG 0x80
  320. #define IBMVNIC_10MBPS 0x40
  321. #define IBMVNIC_100MBPS 0x20
  322. #define IBMVNIC_1GBPS 0x10
  323. #define IBMVNIC_10GBPS 0x08
  324. __be32 mtu;
  325. struct ibmvnic_rc rc;
  326. } __packed __aligned(8);
  327. struct ibmvnic_logical_link_state {
  328. u8 first;
  329. u8 cmd;
  330. u8 link_state;
  331. #define IBMVNIC_LOGICAL_LNK_DN 0x00
  332. #define IBMVNIC_LOGICAL_LNK_UP 0x01
  333. #define IBMVNIC_LOGICAL_LNK_QUERY 0xff
  334. u8 reserved[9];
  335. struct ibmvnic_rc rc;
  336. } __packed __aligned(8);
  337. struct ibmvnic_query_ip_offload {
  338. u8 first;
  339. u8 cmd;
  340. u8 reserved[2];
  341. __be32 len;
  342. __be32 ioba;
  343. struct ibmvnic_rc rc;
  344. } __packed __aligned(8);
  345. struct ibmvnic_control_ip_offload {
  346. u8 first;
  347. u8 cmd;
  348. u8 reserved[2];
  349. __be32 ioba;
  350. __be32 len;
  351. struct ibmvnic_rc rc;
  352. } __packed __aligned(8);
  353. struct ibmvnic_request_dump_size {
  354. u8 first;
  355. u8 cmd;
  356. u8 reserved[6];
  357. __be32 len;
  358. struct ibmvnic_rc rc;
  359. } __packed __aligned(8);
  360. struct ibmvnic_request_dump {
  361. u8 first;
  362. u8 cmd;
  363. u8 reserved1[2];
  364. __be32 ioba;
  365. __be32 len;
  366. u8 reserved2[4];
  367. } __packed __aligned(8);
  368. struct ibmvnic_request_dump_rsp {
  369. u8 first;
  370. u8 cmd;
  371. u8 reserved[6];
  372. __be32 dumped_len;
  373. struct ibmvnic_rc rc;
  374. } __packed __aligned(8);
  375. struct ibmvnic_request_ras_comp_num {
  376. u8 first;
  377. u8 cmd;
  378. u8 reserved1[2];
  379. __be32 num_components;
  380. u8 reserved2[4];
  381. struct ibmvnic_rc rc;
  382. } __packed __aligned(8);
  383. struct ibmvnic_request_ras_comps {
  384. u8 first;
  385. u8 cmd;
  386. u8 reserved[2];
  387. __be32 ioba;
  388. __be32 len;
  389. struct ibmvnic_rc rc;
  390. } __packed __aligned(8);
  391. struct ibmvnic_control_ras {
  392. u8 first;
  393. u8 cmd;
  394. u8 correlator;
  395. u8 level;
  396. u8 op;
  397. #define IBMVNIC_TRACE_LEVEL 1
  398. #define IBMVNIC_ERROR_LEVEL 2
  399. #define IBMVNIC_TRACE_PAUSE 3
  400. #define IBMVNIC_TRACE_RESUME 4
  401. #define IBMVNIC_TRACE_ON 5
  402. #define IBMVNIC_TRACE_OFF 6
  403. #define IBMVNIC_CHG_TRACE_BUFF_SZ 7
  404. u8 trace_buff_sz[3];
  405. u8 reserved[4];
  406. struct ibmvnic_rc rc;
  407. } __packed __aligned(8);
  408. struct ibmvnic_collect_fw_trace {
  409. u8 first;
  410. u8 cmd;
  411. u8 correlator;
  412. u8 reserved;
  413. __be32 ioba;
  414. __be32 len;
  415. struct ibmvnic_rc rc;
  416. } __packed __aligned(8);
  417. struct ibmvnic_request_statistics {
  418. u8 first;
  419. u8 cmd;
  420. u8 flags;
  421. #define IBMVNIC_PHYSICAL_PORT 0x80
  422. u8 reserved1;
  423. __be32 ioba;
  424. __be32 len;
  425. u8 reserved[4];
  426. } __packed __aligned(8);
  427. struct ibmvnic_request_debug_stats {
  428. u8 first;
  429. u8 cmd;
  430. u8 reserved[2];
  431. __be32 ioba;
  432. __be32 len;
  433. struct ibmvnic_rc rc;
  434. } __packed __aligned(8);
  435. struct ibmvnic_error_indication {
  436. u8 first;
  437. u8 cmd;
  438. u8 flags;
  439. #define IBMVNIC_FATAL_ERROR 0x80
  440. u8 reserved1;
  441. __be32 error_id;
  442. __be32 detail_error_sz;
  443. __be16 error_cause;
  444. u8 reserved2[2];
  445. } __packed __aligned(8);
  446. struct ibmvnic_request_error_info {
  447. u8 first;
  448. u8 cmd;
  449. u8 reserved[2];
  450. __be32 ioba;
  451. __be32 len;
  452. __be32 error_id;
  453. } __packed __aligned(8);
  454. struct ibmvnic_request_error_rsp {
  455. u8 first;
  456. u8 cmd;
  457. u8 reserved[2];
  458. __be32 error_id;
  459. __be32 len;
  460. struct ibmvnic_rc rc;
  461. } __packed __aligned(8);
  462. struct ibmvnic_link_state_indication {
  463. u8 first;
  464. u8 cmd;
  465. u8 reserved1[2];
  466. u8 phys_link_state;
  467. u8 logical_link_state;
  468. u8 reserved2[10];
  469. } __packed __aligned(8);
  470. struct ibmvnic_change_mac_addr {
  471. u8 first;
  472. u8 cmd;
  473. u8 mac_addr[6];
  474. struct ibmvnic_rc rc;
  475. u8 reserved[4];
  476. } __packed __aligned(8);
  477. struct ibmvnic_multicast_ctrl {
  478. u8 first;
  479. u8 cmd;
  480. u8 mac_addr[6];
  481. u8 flags;
  482. #define IBMVNIC_ENABLE_MC 0x80
  483. #define IBMVNIC_DISABLE_MC 0x40
  484. #define IBMVNIC_ENABLE_ALL 0x20
  485. #define IBMVNIC_DISABLE_ALL 0x10
  486. u8 reserved1;
  487. __be16 reserved2; /* was num_enabled_mc_addr; */
  488. struct ibmvnic_rc rc;
  489. } __packed __aligned(8);
  490. struct ibmvnic_get_vpd_size_rsp {
  491. u8 first;
  492. u8 cmd;
  493. u8 reserved[2];
  494. __be64 len;
  495. struct ibmvnic_rc rc;
  496. } __packed __aligned(8);
  497. struct ibmvnic_get_vpd {
  498. u8 first;
  499. u8 cmd;
  500. u8 reserved1[2];
  501. __be32 ioba;
  502. __be32 len;
  503. u8 reserved[4];
  504. } __packed __aligned(8);
  505. struct ibmvnic_acl_change_indication {
  506. u8 first;
  507. u8 cmd;
  508. __be16 change_type;
  509. #define IBMVNIC_MAC_ACL 0
  510. #define IBMVNIC_VLAN_ACL 1
  511. u8 reserved[12];
  512. } __packed __aligned(8);
  513. struct ibmvnic_acl_query {
  514. u8 first;
  515. u8 cmd;
  516. u8 reserved1[2];
  517. __be32 ioba;
  518. __be32 len;
  519. u8 reserved2[4];
  520. } __packed __aligned(8);
  521. struct ibmvnic_tune {
  522. u8 first;
  523. u8 cmd;
  524. u8 reserved1[2];
  525. __be32 ioba;
  526. __be32 len;
  527. u8 reserved2[4];
  528. } __packed __aligned(8);
  529. struct ibmvnic_request_map {
  530. u8 first;
  531. u8 cmd;
  532. u8 reserved1;
  533. u8 map_id;
  534. __be32 ioba;
  535. __be32 len;
  536. u8 reserved2[4];
  537. } __packed __aligned(8);
  538. struct ibmvnic_request_map_rsp {
  539. u8 first;
  540. u8 cmd;
  541. u8 reserved1;
  542. u8 map_id;
  543. u8 reserved2[4];
  544. struct ibmvnic_rc rc;
  545. } __packed __aligned(8);
  546. struct ibmvnic_request_unmap {
  547. u8 first;
  548. u8 cmd;
  549. u8 reserved1;
  550. u8 map_id;
  551. u8 reserved2[12];
  552. } __packed __aligned(8);
  553. struct ibmvnic_request_unmap_rsp {
  554. u8 first;
  555. u8 cmd;
  556. u8 reserved1;
  557. u8 map_id;
  558. u8 reserved2[8];
  559. struct ibmvnic_rc rc;
  560. } __packed __aligned(8);
  561. struct ibmvnic_query_map {
  562. u8 first;
  563. u8 cmd;
  564. u8 reserved[14];
  565. } __packed __aligned(8);
  566. struct ibmvnic_query_map_rsp {
  567. u8 first;
  568. u8 cmd;
  569. u8 reserved;
  570. u8 page_size;
  571. __be32 tot_pages;
  572. __be32 free_pages;
  573. struct ibmvnic_rc rc;
  574. } __packed __aligned(8);
  575. union ibmvnic_crq {
  576. struct ibmvnic_generic_crq generic;
  577. struct ibmvnic_version_exchange version_exchange;
  578. struct ibmvnic_version_exchange version_exchange_rsp;
  579. struct ibmvnic_capability query_capability;
  580. struct ibmvnic_capability query_capability_rsp;
  581. struct ibmvnic_capability request_capability;
  582. struct ibmvnic_capability request_capability_rsp;
  583. struct ibmvnic_login login;
  584. struct ibmvnic_generic_crq login_rsp;
  585. struct ibmvnic_phys_parms query_phys_parms;
  586. struct ibmvnic_phys_parms query_phys_parms_rsp;
  587. struct ibmvnic_phys_parms query_phys_capabilities;
  588. struct ibmvnic_phys_parms query_phys_capabilities_rsp;
  589. struct ibmvnic_phys_parms set_phys_parms;
  590. struct ibmvnic_phys_parms set_phys_parms_rsp;
  591. struct ibmvnic_logical_link_state logical_link_state;
  592. struct ibmvnic_logical_link_state logical_link_state_rsp;
  593. struct ibmvnic_query_ip_offload query_ip_offload;
  594. struct ibmvnic_query_ip_offload query_ip_offload_rsp;
  595. struct ibmvnic_control_ip_offload control_ip_offload;
  596. struct ibmvnic_control_ip_offload control_ip_offload_rsp;
  597. struct ibmvnic_request_dump_size request_dump_size;
  598. struct ibmvnic_request_dump_size request_dump_size_rsp;
  599. struct ibmvnic_request_dump request_dump;
  600. struct ibmvnic_request_dump_rsp request_dump_rsp;
  601. struct ibmvnic_request_ras_comp_num request_ras_comp_num;
  602. struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
  603. struct ibmvnic_request_ras_comps request_ras_comps;
  604. struct ibmvnic_request_ras_comps request_ras_comps_rsp;
  605. struct ibmvnic_control_ras control_ras;
  606. struct ibmvnic_control_ras control_ras_rsp;
  607. struct ibmvnic_collect_fw_trace collect_fw_trace;
  608. struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
  609. struct ibmvnic_request_statistics request_statistics;
  610. struct ibmvnic_generic_crq request_statistics_rsp;
  611. struct ibmvnic_request_debug_stats request_debug_stats;
  612. struct ibmvnic_request_debug_stats request_debug_stats_rsp;
  613. struct ibmvnic_error_indication error_indication;
  614. struct ibmvnic_request_error_info request_error_info;
  615. struct ibmvnic_request_error_rsp request_error_rsp;
  616. struct ibmvnic_link_state_indication link_state_indication;
  617. struct ibmvnic_change_mac_addr change_mac_addr;
  618. struct ibmvnic_change_mac_addr change_mac_addr_rsp;
  619. struct ibmvnic_multicast_ctrl multicast_ctrl;
  620. struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
  621. struct ibmvnic_generic_crq get_vpd_size;
  622. struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
  623. struct ibmvnic_get_vpd get_vpd;
  624. struct ibmvnic_generic_crq get_vpd_rsp;
  625. struct ibmvnic_acl_change_indication acl_change_indication;
  626. struct ibmvnic_acl_query acl_query;
  627. struct ibmvnic_generic_crq acl_query_rsp;
  628. struct ibmvnic_tune tune;
  629. struct ibmvnic_generic_crq tune_rsp;
  630. struct ibmvnic_request_map request_map;
  631. struct ibmvnic_request_map_rsp request_map_rsp;
  632. struct ibmvnic_request_unmap request_unmap;
  633. struct ibmvnic_request_unmap_rsp request_unmap_rsp;
  634. struct ibmvnic_query_map query_map;
  635. struct ibmvnic_query_map_rsp query_map_rsp;
  636. };
  637. enum ibmvnic_rc_codes {
  638. SUCCESS = 0,
  639. PARTIALSUCCESS = 1,
  640. PERMISSION = 2,
  641. NOMEMORY = 3,
  642. PARAMETER = 4,
  643. UNKNOWNCOMMAND = 5,
  644. ABORTED = 6,
  645. INVALIDSTATE = 7,
  646. INVALIDIOBA = 8,
  647. INVALIDLENGTH = 9,
  648. UNSUPPORTEDOPTION = 10,
  649. };
  650. enum ibmvnic_capabilities {
  651. MIN_TX_QUEUES = 1,
  652. MIN_RX_QUEUES = 2,
  653. MIN_RX_ADD_QUEUES = 3,
  654. MAX_TX_QUEUES = 4,
  655. MAX_RX_QUEUES = 5,
  656. MAX_RX_ADD_QUEUES = 6,
  657. REQ_TX_QUEUES = 7,
  658. REQ_RX_QUEUES = 8,
  659. REQ_RX_ADD_QUEUES = 9,
  660. MIN_TX_ENTRIES_PER_SUBCRQ = 10,
  661. MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
  662. MAX_TX_ENTRIES_PER_SUBCRQ = 12,
  663. MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
  664. REQ_TX_ENTRIES_PER_SUBCRQ = 14,
  665. REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
  666. TCP_IP_OFFLOAD = 16,
  667. PROMISC_REQUESTED = 17,
  668. PROMISC_SUPPORTED = 18,
  669. MIN_MTU = 19,
  670. MAX_MTU = 20,
  671. REQ_MTU = 21,
  672. MAX_MULTICAST_FILTERS = 22,
  673. VLAN_HEADER_INSERTION = 23,
  674. MAX_TX_SG_ENTRIES = 25,
  675. RX_SG_SUPPORTED = 26,
  676. RX_SG_REQUESTED = 27,
  677. OPT_TX_COMP_SUB_QUEUES = 28,
  678. OPT_RX_COMP_QUEUES = 29,
  679. OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
  680. OPT_TX_ENTRIES_PER_SUBCRQ = 31,
  681. OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
  682. TX_RX_DESC_REQ = 33,
  683. };
  684. enum ibmvnic_error_cause {
  685. ADAPTER_PROBLEM = 0,
  686. BUS_PROBLEM = 1,
  687. FW_PROBLEM = 2,
  688. DD_PROBLEM = 3,
  689. EEH_RECOVERY = 4,
  690. FW_UPDATED = 5,
  691. LOW_MEMORY = 6,
  692. };
  693. enum ibmvnic_commands {
  694. VERSION_EXCHANGE = 0x01,
  695. VERSION_EXCHANGE_RSP = 0x81,
  696. QUERY_CAPABILITY = 0x02,
  697. QUERY_CAPABILITY_RSP = 0x82,
  698. REQUEST_CAPABILITY = 0x03,
  699. REQUEST_CAPABILITY_RSP = 0x83,
  700. LOGIN = 0x04,
  701. LOGIN_RSP = 0x84,
  702. QUERY_PHYS_PARMS = 0x05,
  703. QUERY_PHYS_PARMS_RSP = 0x85,
  704. QUERY_PHYS_CAPABILITIES = 0x06,
  705. QUERY_PHYS_CAPABILITIES_RSP = 0x86,
  706. SET_PHYS_PARMS = 0x07,
  707. SET_PHYS_PARMS_RSP = 0x87,
  708. ERROR_INDICATION = 0x08,
  709. REQUEST_ERROR_INFO = 0x09,
  710. REQUEST_ERROR_RSP = 0x89,
  711. REQUEST_DUMP_SIZE = 0x0A,
  712. REQUEST_DUMP_SIZE_RSP = 0x8A,
  713. REQUEST_DUMP = 0x0B,
  714. REQUEST_DUMP_RSP = 0x8B,
  715. LOGICAL_LINK_STATE = 0x0C,
  716. LOGICAL_LINK_STATE_RSP = 0x8C,
  717. REQUEST_STATISTICS = 0x0D,
  718. REQUEST_STATISTICS_RSP = 0x8D,
  719. REQUEST_RAS_COMP_NUM = 0x0E,
  720. REQUEST_RAS_COMP_NUM_RSP = 0x8E,
  721. REQUEST_RAS_COMPS = 0x0F,
  722. REQUEST_RAS_COMPS_RSP = 0x8F,
  723. CONTROL_RAS = 0x10,
  724. CONTROL_RAS_RSP = 0x90,
  725. COLLECT_FW_TRACE = 0x11,
  726. COLLECT_FW_TRACE_RSP = 0x91,
  727. LINK_STATE_INDICATION = 0x12,
  728. CHANGE_MAC_ADDR = 0x13,
  729. CHANGE_MAC_ADDR_RSP = 0x93,
  730. MULTICAST_CTRL = 0x14,
  731. MULTICAST_CTRL_RSP = 0x94,
  732. GET_VPD_SIZE = 0x15,
  733. GET_VPD_SIZE_RSP = 0x95,
  734. GET_VPD = 0x16,
  735. GET_VPD_RSP = 0x96,
  736. TUNE = 0x17,
  737. TUNE_RSP = 0x97,
  738. QUERY_IP_OFFLOAD = 0x18,
  739. QUERY_IP_OFFLOAD_RSP = 0x98,
  740. CONTROL_IP_OFFLOAD = 0x19,
  741. CONTROL_IP_OFFLOAD_RSP = 0x99,
  742. ACL_CHANGE_INDICATION = 0x1A,
  743. ACL_QUERY = 0x1B,
  744. ACL_QUERY_RSP = 0x9B,
  745. REQUEST_DEBUG_STATS = 0x1C,
  746. REQUEST_DEBUG_STATS_RSP = 0x9C,
  747. QUERY_MAP = 0x1D,
  748. QUERY_MAP_RSP = 0x9D,
  749. REQUEST_MAP = 0x1E,
  750. REQUEST_MAP_RSP = 0x9E,
  751. REQUEST_UNMAP = 0x1F,
  752. REQUEST_UNMAP_RSP = 0x9F,
  753. VLAN_CTRL = 0x20,
  754. VLAN_CTRL_RSP = 0xA0,
  755. };
  756. enum ibmvnic_crq_type {
  757. IBMVNIC_CRQ_CMD = 0x80,
  758. IBMVNIC_CRQ_CMD_RSP = 0x80,
  759. IBMVNIC_CRQ_INIT_CMD = 0xC0,
  760. IBMVNIC_CRQ_INIT_RSP = 0xC0,
  761. IBMVNIC_CRQ_XPORT_EVENT = 0xFF,
  762. };
  763. enum ibmvfc_crq_format {
  764. IBMVNIC_CRQ_INIT = 0x01,
  765. IBMVNIC_CRQ_INIT_COMPLETE = 0x02,
  766. IBMVNIC_PARTITION_MIGRATED = 0x06,
  767. IBMVNIC_DEVICE_FAILOVER = 0x08,
  768. };
  769. struct ibmvnic_crq_queue {
  770. union ibmvnic_crq *msgs;
  771. int size, cur;
  772. dma_addr_t msg_token;
  773. spinlock_t lock;
  774. };
  775. union sub_crq {
  776. struct ibmvnic_generic_scrq generic;
  777. struct ibmvnic_tx_comp_desc tx_comp;
  778. struct ibmvnic_tx_desc v1;
  779. struct ibmvnic_hdr_desc hdr;
  780. struct ibmvnic_hdr_ext_desc hdr_ext;
  781. struct ibmvnic_sge_desc sge;
  782. struct ibmvnic_rx_comp_desc rx_comp;
  783. struct ibmvnic_rx_buff_add_desc rx_add;
  784. };
  785. struct ibmvnic_sub_crq_queue {
  786. union sub_crq *msgs;
  787. int size, cur;
  788. dma_addr_t msg_token;
  789. unsigned long crq_num;
  790. unsigned long hw_irq;
  791. unsigned int irq;
  792. unsigned int pool_index;
  793. int scrq_num;
  794. spinlock_t lock;
  795. struct sk_buff *rx_skb_top;
  796. struct ibmvnic_adapter *adapter;
  797. };
  798. struct ibmvnic_long_term_buff {
  799. unsigned char *buff;
  800. dma_addr_t addr;
  801. u64 size;
  802. u8 map_id;
  803. };
  804. struct ibmvnic_tx_buff {
  805. struct sk_buff *skb;
  806. dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
  807. unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
  808. int index;
  809. int pool_index;
  810. bool last_frag;
  811. bool used_bounce;
  812. union sub_crq indir_arr[6];
  813. u8 hdr_data[140];
  814. dma_addr_t indir_dma;
  815. };
  816. struct ibmvnic_tx_pool {
  817. struct ibmvnic_tx_buff *tx_buff;
  818. int *free_map;
  819. int consumer_index;
  820. int producer_index;
  821. wait_queue_head_t ibmvnic_tx_comp_q;
  822. struct task_struct *work_thread;
  823. struct ibmvnic_long_term_buff long_term_buff;
  824. };
  825. struct ibmvnic_rx_buff {
  826. struct sk_buff *skb;
  827. dma_addr_t dma;
  828. unsigned char *data;
  829. int size;
  830. int pool_index;
  831. };
  832. struct ibmvnic_rx_pool {
  833. struct ibmvnic_rx_buff *rx_buff;
  834. int size;
  835. int index;
  836. int buff_size;
  837. atomic_t available;
  838. int *free_map;
  839. int next_free;
  840. int next_alloc;
  841. int active;
  842. struct ibmvnic_long_term_buff long_term_buff;
  843. };
  844. struct ibmvnic_error_buff {
  845. char *buff;
  846. dma_addr_t dma;
  847. int len;
  848. struct list_head list;
  849. __be32 error_id;
  850. };
  851. struct ibmvnic_fw_comp_internal {
  852. struct ibmvnic_adapter *adapter;
  853. int num;
  854. struct debugfs_blob_wrapper desc_blob;
  855. int paused;
  856. };
  857. struct ibmvnic_inflight_cmd {
  858. union ibmvnic_crq crq;
  859. struct list_head list;
  860. };
  861. struct ibmvnic_adapter {
  862. struct vio_dev *vdev;
  863. struct net_device *netdev;
  864. struct ibmvnic_crq_queue crq;
  865. u8 mac_addr[ETH_ALEN];
  866. struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
  867. dma_addr_t ip_offload_tok;
  868. struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
  869. dma_addr_t ip_offload_ctrl_tok;
  870. bool migrated;
  871. u32 msg_enable;
  872. void *bounce_buffer;
  873. int bounce_buffer_size;
  874. dma_addr_t bounce_buffer_dma;
  875. /* Statistics */
  876. struct net_device_stats net_stats;
  877. struct ibmvnic_statistics stats;
  878. dma_addr_t stats_token;
  879. struct completion stats_done;
  880. spinlock_t stats_lock;
  881. int replenish_no_mem;
  882. int replenish_add_buff_success;
  883. int replenish_add_buff_failure;
  884. int replenish_task_cycles;
  885. int tx_send_failed;
  886. int tx_map_failed;
  887. int phys_link_state;
  888. int logical_link_state;
  889. /* login data */
  890. struct ibmvnic_login_buffer *login_buf;
  891. dma_addr_t login_buf_token;
  892. int login_buf_sz;
  893. struct ibmvnic_login_rsp_buffer *login_rsp_buf;
  894. dma_addr_t login_rsp_buf_token;
  895. int login_rsp_buf_sz;
  896. atomic_t running_cap_queries;
  897. struct ibmvnic_sub_crq_queue **tx_scrq;
  898. struct ibmvnic_sub_crq_queue **rx_scrq;
  899. int requested_caps;
  900. bool renegotiate;
  901. /* rx structs */
  902. struct napi_struct *napi;
  903. struct ibmvnic_rx_pool *rx_pool;
  904. u64 promisc;
  905. struct ibmvnic_tx_pool *tx_pool;
  906. bool closing;
  907. struct completion init_done;
  908. struct list_head errors;
  909. spinlock_t error_list_lock;
  910. /* debugfs */
  911. struct dentry *debugfs_dir;
  912. struct dentry *debugfs_dump;
  913. struct completion fw_done;
  914. char *dump_data;
  915. dma_addr_t dump_data_token;
  916. int dump_data_size;
  917. int ras_comp_num;
  918. struct ibmvnic_fw_component *ras_comps;
  919. struct ibmvnic_fw_comp_internal *ras_comp_int;
  920. dma_addr_t ras_comps_tok;
  921. struct dentry *ras_comps_ent;
  922. /* in-flight commands that allocate and/or map memory*/
  923. struct list_head inflight;
  924. spinlock_t inflight_lock;
  925. /* partner capabilities */
  926. u64 min_tx_queues;
  927. u64 min_rx_queues;
  928. u64 min_rx_add_queues;
  929. u64 max_tx_queues;
  930. u64 max_rx_queues;
  931. u64 max_rx_add_queues;
  932. u64 req_tx_queues;
  933. u64 req_rx_queues;
  934. u64 req_rx_add_queues;
  935. u64 min_tx_entries_per_subcrq;
  936. u64 min_rx_add_entries_per_subcrq;
  937. u64 max_tx_entries_per_subcrq;
  938. u64 max_rx_add_entries_per_subcrq;
  939. u64 req_tx_entries_per_subcrq;
  940. u64 req_rx_add_entries_per_subcrq;
  941. u64 tcp_ip_offload;
  942. u64 promisc_requested;
  943. u64 promisc_supported;
  944. u64 min_mtu;
  945. u64 max_mtu;
  946. u64 req_mtu;
  947. u64 max_multicast_filters;
  948. u64 vlan_header_insertion;
  949. u64 max_tx_sg_entries;
  950. u64 rx_sg_supported;
  951. u64 rx_sg_requested;
  952. u64 opt_tx_comp_sub_queues;
  953. u64 opt_rx_comp_queues;
  954. u64 opt_rx_bufadd_q_per_rx_comp_q;
  955. u64 opt_tx_entries_per_subcrq;
  956. u64 opt_rxba_entries_per_subcrq;
  957. __be64 tx_rx_desc_req;
  958. u8 map_id;
  959. struct work_struct vnic_crq_init;
  960. struct work_struct ibmvnic_xport;
  961. bool failover;
  962. };