ibmvnic.h 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  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. #define NUM_TX_STATS 3
  160. struct ibmvnic_tx_queue_stats {
  161. u64 packets;
  162. u64 bytes;
  163. u64 dropped_packets;
  164. };
  165. #define NUM_RX_STATS 3
  166. struct ibmvnic_rx_queue_stats {
  167. u64 packets;
  168. u64 bytes;
  169. u64 interrupts;
  170. };
  171. struct ibmvnic_acl_buffer {
  172. __be32 len;
  173. __be32 version;
  174. #define INITIAL_VERSION_IOB 1
  175. u8 mac_acls_restrict;
  176. u8 vlan_acls_restrict;
  177. u8 reserved1[22];
  178. __be32 num_mac_addrs;
  179. __be32 offset_mac_addrs;
  180. __be32 num_vlan_ids;
  181. __be32 offset_vlan_ids;
  182. u8 reserved2[80];
  183. } __packed __aligned(8);
  184. /* descriptors have been changed, how should this be defined? 1? 4? */
  185. #define IBMVNIC_TX_DESC_VERSIONS 3
  186. /* is this still needed? */
  187. struct ibmvnic_tx_comp_desc {
  188. u8 first;
  189. u8 num_comps;
  190. __be16 rcs[5];
  191. __be32 correlators[5];
  192. } __packed __aligned(8);
  193. /* some flags that included in v0 descriptor, which is gone
  194. * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
  195. * and only in some offload_flags variable that doesn't seem
  196. * to be used anywhere, can probably be removed?
  197. */
  198. #define IBMVNIC_TCP_CHKSUM 0x20
  199. #define IBMVNIC_UDP_CHKSUM 0x08
  200. #define IBMVNIC_MAX_FRAGS_PER_CRQ 3
  201. struct ibmvnic_tx_desc {
  202. u8 first;
  203. u8 type;
  204. #define IBMVNIC_TX_DESC 0x10
  205. u8 n_crq_elem;
  206. u8 n_sge;
  207. u8 flags1;
  208. #define IBMVNIC_TX_COMP_NEEDED 0x80
  209. #define IBMVNIC_TX_CHKSUM_OFFLOAD 0x40
  210. #define IBMVNIC_TX_LSO 0x20
  211. #define IBMVNIC_TX_PROT_TCP 0x10
  212. #define IBMVNIC_TX_PROT_UDP 0x08
  213. #define IBMVNIC_TX_PROT_IPV4 0x04
  214. #define IBMVNIC_TX_PROT_IPV6 0x02
  215. #define IBMVNIC_TX_VLAN_PRESENT 0x01
  216. u8 flags2;
  217. #define IBMVNIC_TX_VLAN_INSERT 0x80
  218. __be16 mss;
  219. u8 reserved[4];
  220. __be32 correlator;
  221. __be16 vlan_id;
  222. __be16 dma_reg;
  223. __be32 sge_len;
  224. __be64 ioba;
  225. } __packed __aligned(8);
  226. struct ibmvnic_hdr_desc {
  227. u8 first;
  228. u8 type;
  229. #define IBMVNIC_HDR_DESC 0x11
  230. u8 len;
  231. u8 l2_len;
  232. __be16 l3_len;
  233. u8 l4_len;
  234. u8 flag;
  235. u8 data[24];
  236. } __packed __aligned(8);
  237. struct ibmvnic_hdr_ext_desc {
  238. u8 first;
  239. u8 type;
  240. #define IBMVNIC_HDR_EXT_DESC 0x12
  241. u8 len;
  242. u8 data[29];
  243. } __packed __aligned(8);
  244. struct ibmvnic_sge_desc {
  245. u8 first;
  246. u8 type;
  247. #define IBMVNIC_SGE_DESC 0x30
  248. __be16 sge1_dma_reg;
  249. __be32 sge1_len;
  250. __be64 sge1_ioba;
  251. __be16 reserved;
  252. __be16 sge2_dma_reg;
  253. __be32 sge2_len;
  254. __be64 sge2_ioba;
  255. } __packed __aligned(8);
  256. struct ibmvnic_rx_comp_desc {
  257. u8 first;
  258. u8 flags;
  259. #define IBMVNIC_IP_CHKSUM_GOOD 0x80
  260. #define IBMVNIC_TCP_UDP_CHKSUM_GOOD 0x40
  261. #define IBMVNIC_END_FRAME 0x20
  262. #define IBMVNIC_EXACT_MC 0x10
  263. #define IBMVNIC_VLAN_STRIPPED 0x08
  264. __be16 off_frame_data;
  265. __be32 len;
  266. __be64 correlator;
  267. __be16 vlan_tci;
  268. __be16 rc;
  269. u8 reserved[12];
  270. } __packed __aligned(8);
  271. struct ibmvnic_generic_scrq {
  272. u8 first;
  273. u8 reserved[31];
  274. } __packed __aligned(8);
  275. struct ibmvnic_rx_buff_add_desc {
  276. u8 first;
  277. u8 reserved[7];
  278. __be64 correlator;
  279. __be32 ioba;
  280. u8 map_id;
  281. __be32 len:24;
  282. u8 reserved2[8];
  283. } __packed __aligned(8);
  284. struct ibmvnic_rc {
  285. u8 code; /* one of enum ibmvnic_rc_codes */
  286. u8 detailed_data[3];
  287. } __packed __aligned(4);
  288. struct ibmvnic_generic_crq {
  289. u8 first;
  290. u8 cmd;
  291. u8 params[10];
  292. struct ibmvnic_rc rc;
  293. } __packed __aligned(8);
  294. struct ibmvnic_version_exchange {
  295. u8 first;
  296. u8 cmd;
  297. __be16 version;
  298. #define IBMVNIC_INITIAL_VERSION 1
  299. u8 reserved[8];
  300. struct ibmvnic_rc rc;
  301. } __packed __aligned(8);
  302. struct ibmvnic_capability {
  303. u8 first;
  304. u8 cmd;
  305. __be16 capability; /* one of ibmvnic_capabilities */
  306. __be64 number;
  307. struct ibmvnic_rc rc;
  308. } __packed __aligned(8);
  309. struct ibmvnic_login {
  310. u8 first;
  311. u8 cmd;
  312. u8 reserved[6];
  313. __be32 ioba;
  314. __be32 len;
  315. } __packed __aligned(8);
  316. struct ibmvnic_phys_parms {
  317. u8 first;
  318. u8 cmd;
  319. u8 flags1;
  320. #define IBMVNIC_EXTERNAL_LOOPBACK 0x80
  321. #define IBMVNIC_INTERNAL_LOOPBACK 0x40
  322. #define IBMVNIC_PROMISC 0x20
  323. #define IBMVNIC_PHYS_LINK_ACTIVE 0x10
  324. #define IBMVNIC_AUTONEG_DUPLEX 0x08
  325. #define IBMVNIC_FULL_DUPLEX 0x04
  326. #define IBMVNIC_HALF_DUPLEX 0x02
  327. #define IBMVNIC_CAN_CHG_PHYS_PARMS 0x01
  328. u8 flags2;
  329. #define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
  330. __be32 speed;
  331. #define IBMVNIC_AUTONEG 0x80
  332. #define IBMVNIC_10MBPS 0x40
  333. #define IBMVNIC_100MBPS 0x20
  334. #define IBMVNIC_1GBPS 0x10
  335. #define IBMVNIC_10GBPS 0x08
  336. __be32 mtu;
  337. struct ibmvnic_rc rc;
  338. } __packed __aligned(8);
  339. struct ibmvnic_logical_link_state {
  340. u8 first;
  341. u8 cmd;
  342. u8 link_state;
  343. #define IBMVNIC_LOGICAL_LNK_DN 0x00
  344. #define IBMVNIC_LOGICAL_LNK_UP 0x01
  345. #define IBMVNIC_LOGICAL_LNK_QUERY 0xff
  346. u8 reserved[9];
  347. struct ibmvnic_rc rc;
  348. } __packed __aligned(8);
  349. struct ibmvnic_query_ip_offload {
  350. u8 first;
  351. u8 cmd;
  352. u8 reserved[2];
  353. __be32 len;
  354. __be32 ioba;
  355. struct ibmvnic_rc rc;
  356. } __packed __aligned(8);
  357. struct ibmvnic_control_ip_offload {
  358. u8 first;
  359. u8 cmd;
  360. u8 reserved[2];
  361. __be32 ioba;
  362. __be32 len;
  363. struct ibmvnic_rc rc;
  364. } __packed __aligned(8);
  365. struct ibmvnic_request_dump_size {
  366. u8 first;
  367. u8 cmd;
  368. u8 reserved[6];
  369. __be32 len;
  370. struct ibmvnic_rc rc;
  371. } __packed __aligned(8);
  372. struct ibmvnic_request_dump {
  373. u8 first;
  374. u8 cmd;
  375. u8 reserved1[2];
  376. __be32 ioba;
  377. __be32 len;
  378. u8 reserved2[4];
  379. } __packed __aligned(8);
  380. struct ibmvnic_request_dump_rsp {
  381. u8 first;
  382. u8 cmd;
  383. u8 reserved[6];
  384. __be32 dumped_len;
  385. struct ibmvnic_rc rc;
  386. } __packed __aligned(8);
  387. struct ibmvnic_request_ras_comp_num {
  388. u8 first;
  389. u8 cmd;
  390. u8 reserved1[2];
  391. __be32 num_components;
  392. u8 reserved2[4];
  393. struct ibmvnic_rc rc;
  394. } __packed __aligned(8);
  395. struct ibmvnic_request_ras_comps {
  396. u8 first;
  397. u8 cmd;
  398. u8 reserved[2];
  399. __be32 ioba;
  400. __be32 len;
  401. struct ibmvnic_rc rc;
  402. } __packed __aligned(8);
  403. struct ibmvnic_control_ras {
  404. u8 first;
  405. u8 cmd;
  406. u8 correlator;
  407. u8 level;
  408. u8 op;
  409. #define IBMVNIC_TRACE_LEVEL 1
  410. #define IBMVNIC_ERROR_LEVEL 2
  411. #define IBMVNIC_TRACE_PAUSE 3
  412. #define IBMVNIC_TRACE_RESUME 4
  413. #define IBMVNIC_TRACE_ON 5
  414. #define IBMVNIC_TRACE_OFF 6
  415. #define IBMVNIC_CHG_TRACE_BUFF_SZ 7
  416. u8 trace_buff_sz[3];
  417. u8 reserved[4];
  418. struct ibmvnic_rc rc;
  419. } __packed __aligned(8);
  420. struct ibmvnic_collect_fw_trace {
  421. u8 first;
  422. u8 cmd;
  423. u8 correlator;
  424. u8 reserved;
  425. __be32 ioba;
  426. __be32 len;
  427. struct ibmvnic_rc rc;
  428. } __packed __aligned(8);
  429. struct ibmvnic_request_statistics {
  430. u8 first;
  431. u8 cmd;
  432. u8 flags;
  433. #define IBMVNIC_PHYSICAL_PORT 0x80
  434. u8 reserved1;
  435. __be32 ioba;
  436. __be32 len;
  437. u8 reserved[4];
  438. } __packed __aligned(8);
  439. struct ibmvnic_request_debug_stats {
  440. u8 first;
  441. u8 cmd;
  442. u8 reserved[2];
  443. __be32 ioba;
  444. __be32 len;
  445. struct ibmvnic_rc rc;
  446. } __packed __aligned(8);
  447. struct ibmvnic_error_indication {
  448. u8 first;
  449. u8 cmd;
  450. u8 flags;
  451. #define IBMVNIC_FATAL_ERROR 0x80
  452. u8 reserved1;
  453. __be32 error_id;
  454. __be32 detail_error_sz;
  455. __be16 error_cause;
  456. u8 reserved2[2];
  457. } __packed __aligned(8);
  458. struct ibmvnic_request_error_info {
  459. u8 first;
  460. u8 cmd;
  461. u8 reserved[2];
  462. __be32 ioba;
  463. __be32 len;
  464. __be32 error_id;
  465. } __packed __aligned(8);
  466. struct ibmvnic_request_error_rsp {
  467. u8 first;
  468. u8 cmd;
  469. u8 reserved[2];
  470. __be32 error_id;
  471. __be32 len;
  472. struct ibmvnic_rc rc;
  473. } __packed __aligned(8);
  474. struct ibmvnic_link_state_indication {
  475. u8 first;
  476. u8 cmd;
  477. u8 reserved1[2];
  478. u8 phys_link_state;
  479. u8 logical_link_state;
  480. u8 reserved2[10];
  481. } __packed __aligned(8);
  482. struct ibmvnic_change_mac_addr {
  483. u8 first;
  484. u8 cmd;
  485. u8 mac_addr[6];
  486. u8 reserved[4];
  487. struct ibmvnic_rc rc;
  488. } __packed __aligned(8);
  489. struct ibmvnic_multicast_ctrl {
  490. u8 first;
  491. u8 cmd;
  492. u8 mac_addr[6];
  493. u8 flags;
  494. #define IBMVNIC_ENABLE_MC 0x80
  495. #define IBMVNIC_DISABLE_MC 0x40
  496. #define IBMVNIC_ENABLE_ALL 0x20
  497. #define IBMVNIC_DISABLE_ALL 0x10
  498. u8 reserved1;
  499. __be16 reserved2; /* was num_enabled_mc_addr; */
  500. struct ibmvnic_rc rc;
  501. } __packed __aligned(8);
  502. struct ibmvnic_get_vpd_size_rsp {
  503. u8 first;
  504. u8 cmd;
  505. u8 reserved[2];
  506. __be64 len;
  507. struct ibmvnic_rc rc;
  508. } __packed __aligned(8);
  509. struct ibmvnic_get_vpd {
  510. u8 first;
  511. u8 cmd;
  512. u8 reserved1[2];
  513. __be32 ioba;
  514. __be32 len;
  515. u8 reserved[4];
  516. } __packed __aligned(8);
  517. struct ibmvnic_acl_change_indication {
  518. u8 first;
  519. u8 cmd;
  520. __be16 change_type;
  521. #define IBMVNIC_MAC_ACL 0
  522. #define IBMVNIC_VLAN_ACL 1
  523. u8 reserved[12];
  524. } __packed __aligned(8);
  525. struct ibmvnic_acl_query {
  526. u8 first;
  527. u8 cmd;
  528. u8 reserved1[2];
  529. __be32 ioba;
  530. __be32 len;
  531. u8 reserved2[4];
  532. } __packed __aligned(8);
  533. struct ibmvnic_tune {
  534. u8 first;
  535. u8 cmd;
  536. u8 reserved1[2];
  537. __be32 ioba;
  538. __be32 len;
  539. u8 reserved2[4];
  540. } __packed __aligned(8);
  541. struct ibmvnic_request_map {
  542. u8 first;
  543. u8 cmd;
  544. u8 reserved1;
  545. u8 map_id;
  546. __be32 ioba;
  547. __be32 len;
  548. u8 reserved2[4];
  549. } __packed __aligned(8);
  550. struct ibmvnic_request_map_rsp {
  551. u8 first;
  552. u8 cmd;
  553. u8 reserved1;
  554. u8 map_id;
  555. u8 reserved2[8];
  556. struct ibmvnic_rc rc;
  557. } __packed __aligned(8);
  558. struct ibmvnic_request_unmap {
  559. u8 first;
  560. u8 cmd;
  561. u8 reserved1;
  562. u8 map_id;
  563. u8 reserved2[12];
  564. } __packed __aligned(8);
  565. struct ibmvnic_request_unmap_rsp {
  566. u8 first;
  567. u8 cmd;
  568. u8 reserved1;
  569. u8 map_id;
  570. u8 reserved2[8];
  571. struct ibmvnic_rc rc;
  572. } __packed __aligned(8);
  573. struct ibmvnic_query_map {
  574. u8 first;
  575. u8 cmd;
  576. u8 reserved[14];
  577. } __packed __aligned(8);
  578. struct ibmvnic_query_map_rsp {
  579. u8 first;
  580. u8 cmd;
  581. u8 reserved;
  582. u8 page_size;
  583. __be32 tot_pages;
  584. __be32 free_pages;
  585. struct ibmvnic_rc rc;
  586. } __packed __aligned(8);
  587. union ibmvnic_crq {
  588. struct ibmvnic_generic_crq generic;
  589. struct ibmvnic_version_exchange version_exchange;
  590. struct ibmvnic_version_exchange version_exchange_rsp;
  591. struct ibmvnic_capability query_capability;
  592. struct ibmvnic_capability query_capability_rsp;
  593. struct ibmvnic_capability request_capability;
  594. struct ibmvnic_capability request_capability_rsp;
  595. struct ibmvnic_login login;
  596. struct ibmvnic_generic_crq login_rsp;
  597. struct ibmvnic_phys_parms query_phys_parms;
  598. struct ibmvnic_phys_parms query_phys_parms_rsp;
  599. struct ibmvnic_phys_parms query_phys_capabilities;
  600. struct ibmvnic_phys_parms query_phys_capabilities_rsp;
  601. struct ibmvnic_phys_parms set_phys_parms;
  602. struct ibmvnic_phys_parms set_phys_parms_rsp;
  603. struct ibmvnic_logical_link_state logical_link_state;
  604. struct ibmvnic_logical_link_state logical_link_state_rsp;
  605. struct ibmvnic_query_ip_offload query_ip_offload;
  606. struct ibmvnic_query_ip_offload query_ip_offload_rsp;
  607. struct ibmvnic_control_ip_offload control_ip_offload;
  608. struct ibmvnic_control_ip_offload control_ip_offload_rsp;
  609. struct ibmvnic_request_dump_size request_dump_size;
  610. struct ibmvnic_request_dump_size request_dump_size_rsp;
  611. struct ibmvnic_request_dump request_dump;
  612. struct ibmvnic_request_dump_rsp request_dump_rsp;
  613. struct ibmvnic_request_ras_comp_num request_ras_comp_num;
  614. struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
  615. struct ibmvnic_request_ras_comps request_ras_comps;
  616. struct ibmvnic_request_ras_comps request_ras_comps_rsp;
  617. struct ibmvnic_control_ras control_ras;
  618. struct ibmvnic_control_ras control_ras_rsp;
  619. struct ibmvnic_collect_fw_trace collect_fw_trace;
  620. struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
  621. struct ibmvnic_request_statistics request_statistics;
  622. struct ibmvnic_generic_crq request_statistics_rsp;
  623. struct ibmvnic_request_debug_stats request_debug_stats;
  624. struct ibmvnic_request_debug_stats request_debug_stats_rsp;
  625. struct ibmvnic_error_indication error_indication;
  626. struct ibmvnic_request_error_info request_error_info;
  627. struct ibmvnic_request_error_rsp request_error_rsp;
  628. struct ibmvnic_link_state_indication link_state_indication;
  629. struct ibmvnic_change_mac_addr change_mac_addr;
  630. struct ibmvnic_change_mac_addr change_mac_addr_rsp;
  631. struct ibmvnic_multicast_ctrl multicast_ctrl;
  632. struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
  633. struct ibmvnic_generic_crq get_vpd_size;
  634. struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
  635. struct ibmvnic_get_vpd get_vpd;
  636. struct ibmvnic_generic_crq get_vpd_rsp;
  637. struct ibmvnic_acl_change_indication acl_change_indication;
  638. struct ibmvnic_acl_query acl_query;
  639. struct ibmvnic_generic_crq acl_query_rsp;
  640. struct ibmvnic_tune tune;
  641. struct ibmvnic_generic_crq tune_rsp;
  642. struct ibmvnic_request_map request_map;
  643. struct ibmvnic_request_map_rsp request_map_rsp;
  644. struct ibmvnic_request_unmap request_unmap;
  645. struct ibmvnic_request_unmap_rsp request_unmap_rsp;
  646. struct ibmvnic_query_map query_map;
  647. struct ibmvnic_query_map_rsp query_map_rsp;
  648. };
  649. enum ibmvnic_rc_codes {
  650. SUCCESS = 0,
  651. PARTIALSUCCESS = 1,
  652. PERMISSION = 2,
  653. NOMEMORY = 3,
  654. PARAMETER = 4,
  655. UNKNOWNCOMMAND = 5,
  656. ABORTED = 6,
  657. INVALIDSTATE = 7,
  658. INVALIDIOBA = 8,
  659. INVALIDLENGTH = 9,
  660. UNSUPPORTEDOPTION = 10,
  661. };
  662. enum ibmvnic_capabilities {
  663. MIN_TX_QUEUES = 1,
  664. MIN_RX_QUEUES = 2,
  665. MIN_RX_ADD_QUEUES = 3,
  666. MAX_TX_QUEUES = 4,
  667. MAX_RX_QUEUES = 5,
  668. MAX_RX_ADD_QUEUES = 6,
  669. REQ_TX_QUEUES = 7,
  670. REQ_RX_QUEUES = 8,
  671. REQ_RX_ADD_QUEUES = 9,
  672. MIN_TX_ENTRIES_PER_SUBCRQ = 10,
  673. MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
  674. MAX_TX_ENTRIES_PER_SUBCRQ = 12,
  675. MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
  676. REQ_TX_ENTRIES_PER_SUBCRQ = 14,
  677. REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
  678. TCP_IP_OFFLOAD = 16,
  679. PROMISC_REQUESTED = 17,
  680. PROMISC_SUPPORTED = 18,
  681. MIN_MTU = 19,
  682. MAX_MTU = 20,
  683. REQ_MTU = 21,
  684. MAX_MULTICAST_FILTERS = 22,
  685. VLAN_HEADER_INSERTION = 23,
  686. RX_VLAN_HEADER_INSERTION = 24,
  687. MAX_TX_SG_ENTRIES = 25,
  688. RX_SG_SUPPORTED = 26,
  689. RX_SG_REQUESTED = 27,
  690. OPT_TX_COMP_SUB_QUEUES = 28,
  691. OPT_RX_COMP_QUEUES = 29,
  692. OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
  693. OPT_TX_ENTRIES_PER_SUBCRQ = 31,
  694. OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
  695. TX_RX_DESC_REQ = 33,
  696. };
  697. enum ibmvnic_error_cause {
  698. ADAPTER_PROBLEM = 0,
  699. BUS_PROBLEM = 1,
  700. FW_PROBLEM = 2,
  701. DD_PROBLEM = 3,
  702. EEH_RECOVERY = 4,
  703. FW_UPDATED = 5,
  704. LOW_MEMORY = 6,
  705. };
  706. enum ibmvnic_commands {
  707. VERSION_EXCHANGE = 0x01,
  708. VERSION_EXCHANGE_RSP = 0x81,
  709. QUERY_CAPABILITY = 0x02,
  710. QUERY_CAPABILITY_RSP = 0x82,
  711. REQUEST_CAPABILITY = 0x03,
  712. REQUEST_CAPABILITY_RSP = 0x83,
  713. LOGIN = 0x04,
  714. LOGIN_RSP = 0x84,
  715. QUERY_PHYS_PARMS = 0x05,
  716. QUERY_PHYS_PARMS_RSP = 0x85,
  717. QUERY_PHYS_CAPABILITIES = 0x06,
  718. QUERY_PHYS_CAPABILITIES_RSP = 0x86,
  719. SET_PHYS_PARMS = 0x07,
  720. SET_PHYS_PARMS_RSP = 0x87,
  721. ERROR_INDICATION = 0x08,
  722. REQUEST_ERROR_INFO = 0x09,
  723. REQUEST_ERROR_RSP = 0x89,
  724. LOGICAL_LINK_STATE = 0x0C,
  725. LOGICAL_LINK_STATE_RSP = 0x8C,
  726. REQUEST_STATISTICS = 0x0D,
  727. REQUEST_STATISTICS_RSP = 0x8D,
  728. COLLECT_FW_TRACE = 0x11,
  729. COLLECT_FW_TRACE_RSP = 0x91,
  730. LINK_STATE_INDICATION = 0x12,
  731. CHANGE_MAC_ADDR = 0x13,
  732. CHANGE_MAC_ADDR_RSP = 0x93,
  733. MULTICAST_CTRL = 0x14,
  734. MULTICAST_CTRL_RSP = 0x94,
  735. GET_VPD_SIZE = 0x15,
  736. GET_VPD_SIZE_RSP = 0x95,
  737. GET_VPD = 0x16,
  738. GET_VPD_RSP = 0x96,
  739. TUNE = 0x17,
  740. TUNE_RSP = 0x97,
  741. QUERY_IP_OFFLOAD = 0x18,
  742. QUERY_IP_OFFLOAD_RSP = 0x98,
  743. CONTROL_IP_OFFLOAD = 0x19,
  744. CONTROL_IP_OFFLOAD_RSP = 0x99,
  745. ACL_CHANGE_INDICATION = 0x1A,
  746. ACL_QUERY = 0x1B,
  747. ACL_QUERY_RSP = 0x9B,
  748. QUERY_MAP = 0x1D,
  749. QUERY_MAP_RSP = 0x9D,
  750. REQUEST_MAP = 0x1E,
  751. REQUEST_MAP_RSP = 0x9E,
  752. REQUEST_UNMAP = 0x1F,
  753. REQUEST_UNMAP_RSP = 0x9F,
  754. VLAN_CTRL = 0x20,
  755. VLAN_CTRL_RSP = 0xA0,
  756. };
  757. enum ibmvnic_crq_type {
  758. IBMVNIC_CRQ_CMD = 0x80,
  759. IBMVNIC_CRQ_CMD_RSP = 0x80,
  760. IBMVNIC_CRQ_INIT_CMD = 0xC0,
  761. IBMVNIC_CRQ_INIT_RSP = 0xC0,
  762. IBMVNIC_CRQ_XPORT_EVENT = 0xFF,
  763. };
  764. enum ibmvfc_crq_format {
  765. IBMVNIC_CRQ_INIT = 0x01,
  766. IBMVNIC_CRQ_INIT_COMPLETE = 0x02,
  767. IBMVNIC_PARTITION_MIGRATED = 0x06,
  768. IBMVNIC_DEVICE_FAILOVER = 0x08,
  769. };
  770. struct ibmvnic_crq_queue {
  771. union ibmvnic_crq *msgs;
  772. int size, cur;
  773. dma_addr_t msg_token;
  774. spinlock_t lock;
  775. };
  776. union sub_crq {
  777. struct ibmvnic_generic_scrq generic;
  778. struct ibmvnic_tx_comp_desc tx_comp;
  779. struct ibmvnic_tx_desc v1;
  780. struct ibmvnic_hdr_desc hdr;
  781. struct ibmvnic_hdr_ext_desc hdr_ext;
  782. struct ibmvnic_sge_desc sge;
  783. struct ibmvnic_rx_comp_desc rx_comp;
  784. struct ibmvnic_rx_buff_add_desc rx_add;
  785. };
  786. struct ibmvnic_sub_crq_queue {
  787. union sub_crq *msgs;
  788. int size, cur;
  789. dma_addr_t msg_token;
  790. unsigned long crq_num;
  791. unsigned long hw_irq;
  792. unsigned int irq;
  793. unsigned int pool_index;
  794. int scrq_num;
  795. spinlock_t lock;
  796. struct sk_buff *rx_skb_top;
  797. struct ibmvnic_adapter *adapter;
  798. atomic_t used;
  799. };
  800. struct ibmvnic_long_term_buff {
  801. unsigned char *buff;
  802. dma_addr_t addr;
  803. u64 size;
  804. u8 map_id;
  805. };
  806. struct ibmvnic_tx_buff {
  807. struct sk_buff *skb;
  808. dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
  809. unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
  810. int index;
  811. int pool_index;
  812. bool last_frag;
  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. enum vnic_state {VNIC_PROBING = 1,
  853. VNIC_PROBED,
  854. VNIC_OPENING,
  855. VNIC_OPEN,
  856. VNIC_CLOSING,
  857. VNIC_CLOSED,
  858. VNIC_REMOVING,
  859. VNIC_REMOVED};
  860. enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
  861. VNIC_RESET_MOBILITY,
  862. VNIC_RESET_FATAL,
  863. VNIC_RESET_NON_FATAL,
  864. VNIC_RESET_TIMEOUT};
  865. struct ibmvnic_rwi {
  866. enum ibmvnic_reset_reason reset_reason;
  867. struct list_head list;
  868. };
  869. struct ibmvnic_adapter {
  870. struct vio_dev *vdev;
  871. struct net_device *netdev;
  872. struct ibmvnic_crq_queue crq;
  873. u8 mac_addr[ETH_ALEN];
  874. struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
  875. dma_addr_t ip_offload_tok;
  876. struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
  877. dma_addr_t ip_offload_ctrl_tok;
  878. u32 msg_enable;
  879. /* Statistics */
  880. struct ibmvnic_statistics stats;
  881. dma_addr_t stats_token;
  882. struct completion stats_done;
  883. spinlock_t stats_lock;
  884. int replenish_no_mem;
  885. int replenish_add_buff_success;
  886. int replenish_add_buff_failure;
  887. int replenish_task_cycles;
  888. int tx_send_failed;
  889. int tx_map_failed;
  890. struct ibmvnic_tx_queue_stats *tx_stats_buffers;
  891. struct ibmvnic_rx_queue_stats *rx_stats_buffers;
  892. int phys_link_state;
  893. int logical_link_state;
  894. /* login data */
  895. struct ibmvnic_login_buffer *login_buf;
  896. dma_addr_t login_buf_token;
  897. int login_buf_sz;
  898. struct ibmvnic_login_rsp_buffer *login_rsp_buf;
  899. dma_addr_t login_rsp_buf_token;
  900. int login_rsp_buf_sz;
  901. atomic_t running_cap_crqs;
  902. bool wait_capability;
  903. struct ibmvnic_sub_crq_queue **tx_scrq;
  904. struct ibmvnic_sub_crq_queue **rx_scrq;
  905. bool renegotiate;
  906. /* rx structs */
  907. struct napi_struct *napi;
  908. struct ibmvnic_rx_pool *rx_pool;
  909. u64 promisc;
  910. struct ibmvnic_tx_pool *tx_pool;
  911. struct completion init_done;
  912. int init_done_rc;
  913. struct list_head errors;
  914. spinlock_t error_list_lock;
  915. struct completion fw_done;
  916. int fw_done_rc;
  917. /* partner capabilities */
  918. u64 min_tx_queues;
  919. u64 min_rx_queues;
  920. u64 min_rx_add_queues;
  921. u64 max_tx_queues;
  922. u64 max_rx_queues;
  923. u64 max_rx_add_queues;
  924. u64 req_tx_queues;
  925. u64 req_rx_queues;
  926. u64 req_rx_add_queues;
  927. u64 min_tx_entries_per_subcrq;
  928. u64 min_rx_add_entries_per_subcrq;
  929. u64 max_tx_entries_per_subcrq;
  930. u64 max_rx_add_entries_per_subcrq;
  931. u64 req_tx_entries_per_subcrq;
  932. u64 req_rx_add_entries_per_subcrq;
  933. u64 tcp_ip_offload;
  934. u64 promisc_requested;
  935. u64 promisc_supported;
  936. u64 min_mtu;
  937. u64 max_mtu;
  938. u64 req_mtu;
  939. u64 max_multicast_filters;
  940. u64 vlan_header_insertion;
  941. u64 rx_vlan_header_insertion;
  942. u64 max_tx_sg_entries;
  943. u64 rx_sg_supported;
  944. u64 rx_sg_requested;
  945. u64 opt_tx_comp_sub_queues;
  946. u64 opt_rx_comp_queues;
  947. u64 opt_rx_bufadd_q_per_rx_comp_q;
  948. u64 opt_tx_entries_per_subcrq;
  949. u64 opt_rxba_entries_per_subcrq;
  950. __be64 tx_rx_desc_req;
  951. u8 map_id;
  952. struct tasklet_struct tasklet;
  953. enum vnic_state state;
  954. enum ibmvnic_reset_reason reset_reason;
  955. struct mutex reset_lock, rwi_lock;
  956. struct list_head rwi_list;
  957. struct work_struct ibmvnic_reset;
  958. bool resetting;
  959. bool napi_enabled, from_passive_init;
  960. };