ibmvnic.h 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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. atomic_t used;
  798. };
  799. struct ibmvnic_long_term_buff {
  800. unsigned char *buff;
  801. dma_addr_t addr;
  802. u64 size;
  803. u8 map_id;
  804. };
  805. struct ibmvnic_tx_buff {
  806. struct sk_buff *skb;
  807. dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
  808. unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
  809. int index;
  810. int pool_index;
  811. bool last_frag;
  812. bool used_bounce;
  813. union sub_crq indir_arr[6];
  814. u8 hdr_data[140];
  815. dma_addr_t indir_dma;
  816. };
  817. struct ibmvnic_tx_pool {
  818. struct ibmvnic_tx_buff *tx_buff;
  819. int *free_map;
  820. int consumer_index;
  821. int producer_index;
  822. wait_queue_head_t ibmvnic_tx_comp_q;
  823. struct task_struct *work_thread;
  824. struct ibmvnic_long_term_buff long_term_buff;
  825. };
  826. struct ibmvnic_rx_buff {
  827. struct sk_buff *skb;
  828. dma_addr_t dma;
  829. unsigned char *data;
  830. int size;
  831. int pool_index;
  832. };
  833. struct ibmvnic_rx_pool {
  834. struct ibmvnic_rx_buff *rx_buff;
  835. int size;
  836. int index;
  837. int buff_size;
  838. atomic_t available;
  839. int *free_map;
  840. int next_free;
  841. int next_alloc;
  842. int active;
  843. struct ibmvnic_long_term_buff long_term_buff;
  844. };
  845. struct ibmvnic_error_buff {
  846. char *buff;
  847. dma_addr_t dma;
  848. int len;
  849. struct list_head list;
  850. __be32 error_id;
  851. };
  852. struct ibmvnic_fw_comp_internal {
  853. struct ibmvnic_adapter *adapter;
  854. int num;
  855. struct debugfs_blob_wrapper desc_blob;
  856. int paused;
  857. };
  858. struct ibmvnic_inflight_cmd {
  859. union ibmvnic_crq crq;
  860. struct list_head list;
  861. };
  862. struct ibmvnic_adapter {
  863. struct vio_dev *vdev;
  864. struct net_device *netdev;
  865. struct ibmvnic_crq_queue crq;
  866. u8 mac_addr[ETH_ALEN];
  867. struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
  868. dma_addr_t ip_offload_tok;
  869. struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
  870. dma_addr_t ip_offload_ctrl_tok;
  871. bool migrated;
  872. u32 msg_enable;
  873. void *bounce_buffer;
  874. int bounce_buffer_size;
  875. dma_addr_t bounce_buffer_dma;
  876. /* Statistics */
  877. struct net_device_stats net_stats;
  878. struct ibmvnic_statistics stats;
  879. dma_addr_t stats_token;
  880. struct completion stats_done;
  881. spinlock_t stats_lock;
  882. int replenish_no_mem;
  883. int replenish_add_buff_success;
  884. int replenish_add_buff_failure;
  885. int replenish_task_cycles;
  886. int tx_send_failed;
  887. int tx_map_failed;
  888. int phys_link_state;
  889. int logical_link_state;
  890. /* login data */
  891. struct ibmvnic_login_buffer *login_buf;
  892. dma_addr_t login_buf_token;
  893. int login_buf_sz;
  894. struct ibmvnic_login_rsp_buffer *login_rsp_buf;
  895. dma_addr_t login_rsp_buf_token;
  896. int login_rsp_buf_sz;
  897. atomic_t running_cap_queries;
  898. struct ibmvnic_sub_crq_queue **tx_scrq;
  899. struct ibmvnic_sub_crq_queue **rx_scrq;
  900. int requested_caps;
  901. bool renegotiate;
  902. /* rx structs */
  903. struct napi_struct *napi;
  904. struct ibmvnic_rx_pool *rx_pool;
  905. u64 promisc;
  906. struct ibmvnic_tx_pool *tx_pool;
  907. bool closing;
  908. struct completion init_done;
  909. struct list_head errors;
  910. spinlock_t error_list_lock;
  911. /* debugfs */
  912. struct dentry *debugfs_dir;
  913. struct dentry *debugfs_dump;
  914. struct completion fw_done;
  915. char *dump_data;
  916. dma_addr_t dump_data_token;
  917. int dump_data_size;
  918. int ras_comp_num;
  919. struct ibmvnic_fw_component *ras_comps;
  920. struct ibmvnic_fw_comp_internal *ras_comp_int;
  921. dma_addr_t ras_comps_tok;
  922. struct dentry *ras_comps_ent;
  923. /* in-flight commands that allocate and/or map memory*/
  924. struct list_head inflight;
  925. spinlock_t inflight_lock;
  926. /* partner capabilities */
  927. u64 min_tx_queues;
  928. u64 min_rx_queues;
  929. u64 min_rx_add_queues;
  930. u64 max_tx_queues;
  931. u64 max_rx_queues;
  932. u64 max_rx_add_queues;
  933. u64 req_tx_queues;
  934. u64 req_rx_queues;
  935. u64 req_rx_add_queues;
  936. u64 min_tx_entries_per_subcrq;
  937. u64 min_rx_add_entries_per_subcrq;
  938. u64 max_tx_entries_per_subcrq;
  939. u64 max_rx_add_entries_per_subcrq;
  940. u64 req_tx_entries_per_subcrq;
  941. u64 req_rx_add_entries_per_subcrq;
  942. u64 tcp_ip_offload;
  943. u64 promisc_requested;
  944. u64 promisc_supported;
  945. u64 min_mtu;
  946. u64 max_mtu;
  947. u64 req_mtu;
  948. u64 max_multicast_filters;
  949. u64 vlan_header_insertion;
  950. u64 max_tx_sg_entries;
  951. u64 rx_sg_supported;
  952. u64 rx_sg_requested;
  953. u64 opt_tx_comp_sub_queues;
  954. u64 opt_rx_comp_queues;
  955. u64 opt_rx_bufadd_q_per_rx_comp_q;
  956. u64 opt_tx_entries_per_subcrq;
  957. u64 opt_rxba_entries_per_subcrq;
  958. __be64 tx_rx_desc_req;
  959. u8 map_id;
  960. struct work_struct vnic_crq_init;
  961. struct work_struct ibmvnic_xport;
  962. bool failover;
  963. };