ibmvnic.h 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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. #define IBMVNIC_INIT_FAILED 2
  33. /* basic structures plus 100 2k buffers */
  34. #define IBMVNIC_IO_ENTITLEMENT_DEFAULT 610305
  35. /* Initial module_parameters */
  36. #define IBMVNIC_RX_WEIGHT 16
  37. /* when changing this, update IBMVNIC_IO_ENTITLEMENT_DEFAULT */
  38. #define IBMVNIC_BUFFS_PER_POOL 100
  39. #define IBMVNIC_MAX_QUEUES 10
  40. #define IBMVNIC_TSO_BUF_SZ 65536
  41. #define IBMVNIC_TSO_BUFS 64
  42. #define IBMVNIC_TSO_POOL_MASK 0x80000000
  43. #define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE)
  44. #define IBMVNIC_BUFFER_HLEN 500
  45. struct ibmvnic_login_buffer {
  46. __be32 len;
  47. __be32 version;
  48. #define INITIAL_VERSION_LB 1
  49. __be32 num_txcomp_subcrqs;
  50. __be32 off_txcomp_subcrqs;
  51. __be32 num_rxcomp_subcrqs;
  52. __be32 off_rxcomp_subcrqs;
  53. __be32 login_rsp_ioba;
  54. __be32 login_rsp_len;
  55. __be32 client_data_offset;
  56. __be32 client_data_len;
  57. } __packed __aligned(8);
  58. struct ibmvnic_login_rsp_buffer {
  59. __be32 len;
  60. __be32 version;
  61. #define INITIAL_VERSION_LRB 1
  62. __be32 num_txsubm_subcrqs;
  63. __be32 off_txsubm_subcrqs;
  64. __be32 num_rxadd_subcrqs;
  65. __be32 off_rxadd_subcrqs;
  66. __be32 off_rxadd_buff_size;
  67. __be32 num_supp_tx_desc;
  68. __be32 off_supp_tx_desc;
  69. } __packed __aligned(8);
  70. struct ibmvnic_query_ip_offload_buffer {
  71. __be32 len;
  72. __be32 version;
  73. #define INITIAL_VERSION_IOB 1
  74. u8 ipv4_chksum;
  75. u8 ipv6_chksum;
  76. u8 tcp_ipv4_chksum;
  77. u8 tcp_ipv6_chksum;
  78. u8 udp_ipv4_chksum;
  79. u8 udp_ipv6_chksum;
  80. u8 large_tx_ipv4;
  81. u8 large_tx_ipv6;
  82. u8 large_rx_ipv4;
  83. u8 large_rx_ipv6;
  84. u8 reserved1[14];
  85. __be16 max_ipv4_header_size;
  86. __be16 max_ipv6_header_size;
  87. __be16 max_tcp_header_size;
  88. __be16 max_udp_header_size;
  89. __be32 max_large_tx_size;
  90. __be32 max_large_rx_size;
  91. u8 reserved2[16];
  92. u8 ipv6_extension_header;
  93. #define IPV6_EH_NOT_SUPPORTED 0x00
  94. #define IPV6_EH_SUPPORTED_LIM 0x01
  95. #define IPV6_EH_SUPPORTED 0xFF
  96. u8 tcp_pseudosum_req;
  97. #define TCP_PS_NOT_REQUIRED 0x00
  98. #define TCP_PS_REQUIRED 0x01
  99. u8 reserved3[30];
  100. __be16 num_ipv6_ext_headers;
  101. __be32 off_ipv6_ext_headers;
  102. u8 reserved4[154];
  103. } __packed __aligned(8);
  104. struct ibmvnic_control_ip_offload_buffer {
  105. __be32 len;
  106. __be32 version;
  107. #define INITIAL_VERSION_IOB 1
  108. u8 ipv4_chksum;
  109. u8 ipv6_chksum;
  110. u8 tcp_ipv4_chksum;
  111. u8 tcp_ipv6_chksum;
  112. u8 udp_ipv4_chksum;
  113. u8 udp_ipv6_chksum;
  114. u8 large_tx_ipv4;
  115. u8 large_tx_ipv6;
  116. u8 bad_packet_rx;
  117. u8 large_rx_ipv4;
  118. u8 large_rx_ipv6;
  119. u8 reserved4[111];
  120. } __packed __aligned(8);
  121. struct ibmvnic_fw_component {
  122. u8 name[48];
  123. __be32 trace_buff_size;
  124. u8 correlator;
  125. u8 trace_level;
  126. u8 parent_correlator;
  127. u8 error_check_level;
  128. u8 trace_on;
  129. u8 reserved[7];
  130. u8 description[192];
  131. } __packed __aligned(8);
  132. struct ibmvnic_fw_trace_entry {
  133. __be32 trace_id;
  134. u8 num_valid_data;
  135. u8 reserved[3];
  136. __be64 pmc_registers;
  137. __be64 timebase;
  138. __be64 trace_data[5];
  139. } __packed __aligned(8);
  140. struct ibmvnic_statistics {
  141. __be32 version;
  142. __be32 promiscuous;
  143. __be64 rx_packets;
  144. __be64 rx_bytes;
  145. __be64 tx_packets;
  146. __be64 tx_bytes;
  147. __be64 ucast_tx_packets;
  148. __be64 ucast_rx_packets;
  149. __be64 mcast_tx_packets;
  150. __be64 mcast_rx_packets;
  151. __be64 bcast_tx_packets;
  152. __be64 bcast_rx_packets;
  153. __be64 align_errors;
  154. __be64 fcs_errors;
  155. __be64 single_collision_frames;
  156. __be64 multi_collision_frames;
  157. __be64 sqe_test_errors;
  158. __be64 deferred_tx;
  159. __be64 late_collisions;
  160. __be64 excess_collisions;
  161. __be64 internal_mac_tx_errors;
  162. __be64 carrier_sense;
  163. __be64 too_long_frames;
  164. __be64 internal_mac_rx_errors;
  165. u8 reserved[72];
  166. } __packed __aligned(8);
  167. #define NUM_TX_STATS 3
  168. struct ibmvnic_tx_queue_stats {
  169. u64 packets;
  170. u64 bytes;
  171. u64 dropped_packets;
  172. };
  173. #define NUM_RX_STATS 3
  174. struct ibmvnic_rx_queue_stats {
  175. u64 packets;
  176. u64 bytes;
  177. u64 interrupts;
  178. };
  179. struct ibmvnic_acl_buffer {
  180. __be32 len;
  181. __be32 version;
  182. #define INITIAL_VERSION_IOB 1
  183. u8 mac_acls_restrict;
  184. u8 vlan_acls_restrict;
  185. u8 reserved1[22];
  186. __be32 num_mac_addrs;
  187. __be32 offset_mac_addrs;
  188. __be32 num_vlan_ids;
  189. __be32 offset_vlan_ids;
  190. u8 reserved2[80];
  191. } __packed __aligned(8);
  192. /* descriptors have been changed, how should this be defined? 1? 4? */
  193. #define IBMVNIC_TX_DESC_VERSIONS 3
  194. /* is this still needed? */
  195. struct ibmvnic_tx_comp_desc {
  196. u8 first;
  197. u8 num_comps;
  198. __be16 rcs[5];
  199. __be32 correlators[5];
  200. } __packed __aligned(8);
  201. /* some flags that included in v0 descriptor, which is gone
  202. * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
  203. * and only in some offload_flags variable that doesn't seem
  204. * to be used anywhere, can probably be removed?
  205. */
  206. #define IBMVNIC_TCP_CHKSUM 0x20
  207. #define IBMVNIC_UDP_CHKSUM 0x08
  208. #define IBMVNIC_MAX_FRAGS_PER_CRQ 3
  209. struct ibmvnic_tx_desc {
  210. u8 first;
  211. u8 type;
  212. #define IBMVNIC_TX_DESC 0x10
  213. u8 n_crq_elem;
  214. u8 n_sge;
  215. u8 flags1;
  216. #define IBMVNIC_TX_COMP_NEEDED 0x80
  217. #define IBMVNIC_TX_CHKSUM_OFFLOAD 0x40
  218. #define IBMVNIC_TX_LSO 0x20
  219. #define IBMVNIC_TX_PROT_TCP 0x10
  220. #define IBMVNIC_TX_PROT_UDP 0x08
  221. #define IBMVNIC_TX_PROT_IPV4 0x04
  222. #define IBMVNIC_TX_PROT_IPV6 0x02
  223. #define IBMVNIC_TX_VLAN_PRESENT 0x01
  224. u8 flags2;
  225. #define IBMVNIC_TX_VLAN_INSERT 0x80
  226. __be16 mss;
  227. u8 reserved[4];
  228. __be32 correlator;
  229. __be16 vlan_id;
  230. __be16 dma_reg;
  231. __be32 sge_len;
  232. __be64 ioba;
  233. } __packed __aligned(8);
  234. struct ibmvnic_hdr_desc {
  235. u8 first;
  236. u8 type;
  237. #define IBMVNIC_HDR_DESC 0x11
  238. u8 len;
  239. u8 l2_len;
  240. __be16 l3_len;
  241. u8 l4_len;
  242. u8 flag;
  243. u8 data[24];
  244. } __packed __aligned(8);
  245. struct ibmvnic_hdr_ext_desc {
  246. u8 first;
  247. u8 type;
  248. #define IBMVNIC_HDR_EXT_DESC 0x12
  249. u8 len;
  250. u8 data[29];
  251. } __packed __aligned(8);
  252. struct ibmvnic_sge_desc {
  253. u8 first;
  254. u8 type;
  255. #define IBMVNIC_SGE_DESC 0x30
  256. __be16 sge1_dma_reg;
  257. __be32 sge1_len;
  258. __be64 sge1_ioba;
  259. __be16 reserved;
  260. __be16 sge2_dma_reg;
  261. __be32 sge2_len;
  262. __be64 sge2_ioba;
  263. } __packed __aligned(8);
  264. struct ibmvnic_rx_comp_desc {
  265. u8 first;
  266. u8 flags;
  267. #define IBMVNIC_IP_CHKSUM_GOOD 0x80
  268. #define IBMVNIC_TCP_UDP_CHKSUM_GOOD 0x40
  269. #define IBMVNIC_END_FRAME 0x20
  270. #define IBMVNIC_EXACT_MC 0x10
  271. #define IBMVNIC_VLAN_STRIPPED 0x08
  272. __be16 off_frame_data;
  273. __be32 len;
  274. __be64 correlator;
  275. __be16 vlan_tci;
  276. __be16 rc;
  277. u8 reserved[12];
  278. } __packed __aligned(8);
  279. struct ibmvnic_generic_scrq {
  280. u8 first;
  281. u8 reserved[31];
  282. } __packed __aligned(8);
  283. struct ibmvnic_rx_buff_add_desc {
  284. u8 first;
  285. u8 reserved[7];
  286. __be64 correlator;
  287. __be32 ioba;
  288. u8 map_id;
  289. __be32 len:24;
  290. u8 reserved2[8];
  291. } __packed __aligned(8);
  292. struct ibmvnic_rc {
  293. u8 code; /* one of enum ibmvnic_rc_codes */
  294. u8 detailed_data[3];
  295. } __packed __aligned(4);
  296. struct ibmvnic_generic_crq {
  297. u8 first;
  298. u8 cmd;
  299. u8 params[10];
  300. struct ibmvnic_rc rc;
  301. } __packed __aligned(8);
  302. struct ibmvnic_version_exchange {
  303. u8 first;
  304. u8 cmd;
  305. __be16 version;
  306. #define IBMVNIC_INITIAL_VERSION 1
  307. u8 reserved[8];
  308. struct ibmvnic_rc rc;
  309. } __packed __aligned(8);
  310. struct ibmvnic_capability {
  311. u8 first;
  312. u8 cmd;
  313. __be16 capability; /* one of ibmvnic_capabilities */
  314. __be64 number;
  315. struct ibmvnic_rc rc;
  316. } __packed __aligned(8);
  317. struct ibmvnic_login {
  318. u8 first;
  319. u8 cmd;
  320. u8 reserved[6];
  321. __be32 ioba;
  322. __be32 len;
  323. } __packed __aligned(8);
  324. struct ibmvnic_phys_parms {
  325. u8 first;
  326. u8 cmd;
  327. u8 flags1;
  328. #define IBMVNIC_EXTERNAL_LOOPBACK 0x80
  329. #define IBMVNIC_INTERNAL_LOOPBACK 0x40
  330. #define IBMVNIC_PROMISC 0x20
  331. #define IBMVNIC_PHYS_LINK_ACTIVE 0x10
  332. #define IBMVNIC_AUTONEG_DUPLEX 0x08
  333. #define IBMVNIC_FULL_DUPLEX 0x04
  334. #define IBMVNIC_HALF_DUPLEX 0x02
  335. #define IBMVNIC_CAN_CHG_PHYS_PARMS 0x01
  336. u8 flags2;
  337. #define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
  338. __be32 speed;
  339. #define IBMVNIC_AUTONEG 0x80
  340. #define IBMVNIC_10MBPS 0x40
  341. #define IBMVNIC_100MBPS 0x20
  342. #define IBMVNIC_1GBPS 0x10
  343. #define IBMVNIC_10GBPS 0x08
  344. __be32 mtu;
  345. struct ibmvnic_rc rc;
  346. } __packed __aligned(8);
  347. struct ibmvnic_logical_link_state {
  348. u8 first;
  349. u8 cmd;
  350. u8 link_state;
  351. #define IBMVNIC_LOGICAL_LNK_DN 0x00
  352. #define IBMVNIC_LOGICAL_LNK_UP 0x01
  353. #define IBMVNIC_LOGICAL_LNK_QUERY 0xff
  354. u8 reserved[9];
  355. struct ibmvnic_rc rc;
  356. } __packed __aligned(8);
  357. struct ibmvnic_query_ip_offload {
  358. u8 first;
  359. u8 cmd;
  360. u8 reserved[2];
  361. __be32 len;
  362. __be32 ioba;
  363. struct ibmvnic_rc rc;
  364. } __packed __aligned(8);
  365. struct ibmvnic_control_ip_offload {
  366. u8 first;
  367. u8 cmd;
  368. u8 reserved[2];
  369. __be32 ioba;
  370. __be32 len;
  371. struct ibmvnic_rc rc;
  372. } __packed __aligned(8);
  373. struct ibmvnic_request_dump_size {
  374. u8 first;
  375. u8 cmd;
  376. u8 reserved[6];
  377. __be32 len;
  378. struct ibmvnic_rc rc;
  379. } __packed __aligned(8);
  380. struct ibmvnic_request_dump {
  381. u8 first;
  382. u8 cmd;
  383. u8 reserved1[2];
  384. __be32 ioba;
  385. __be32 len;
  386. u8 reserved2[4];
  387. } __packed __aligned(8);
  388. struct ibmvnic_request_dump_rsp {
  389. u8 first;
  390. u8 cmd;
  391. u8 reserved[6];
  392. __be32 dumped_len;
  393. struct ibmvnic_rc rc;
  394. } __packed __aligned(8);
  395. struct ibmvnic_request_ras_comp_num {
  396. u8 first;
  397. u8 cmd;
  398. u8 reserved1[2];
  399. __be32 num_components;
  400. u8 reserved2[4];
  401. struct ibmvnic_rc rc;
  402. } __packed __aligned(8);
  403. struct ibmvnic_request_ras_comps {
  404. u8 first;
  405. u8 cmd;
  406. u8 reserved[2];
  407. __be32 ioba;
  408. __be32 len;
  409. struct ibmvnic_rc rc;
  410. } __packed __aligned(8);
  411. struct ibmvnic_control_ras {
  412. u8 first;
  413. u8 cmd;
  414. u8 correlator;
  415. u8 level;
  416. u8 op;
  417. #define IBMVNIC_TRACE_LEVEL 1
  418. #define IBMVNIC_ERROR_LEVEL 2
  419. #define IBMVNIC_TRACE_PAUSE 3
  420. #define IBMVNIC_TRACE_RESUME 4
  421. #define IBMVNIC_TRACE_ON 5
  422. #define IBMVNIC_TRACE_OFF 6
  423. #define IBMVNIC_CHG_TRACE_BUFF_SZ 7
  424. u8 trace_buff_sz[3];
  425. u8 reserved[4];
  426. struct ibmvnic_rc rc;
  427. } __packed __aligned(8);
  428. struct ibmvnic_collect_fw_trace {
  429. u8 first;
  430. u8 cmd;
  431. u8 correlator;
  432. u8 reserved;
  433. __be32 ioba;
  434. __be32 len;
  435. struct ibmvnic_rc rc;
  436. } __packed __aligned(8);
  437. struct ibmvnic_request_statistics {
  438. u8 first;
  439. u8 cmd;
  440. u8 flags;
  441. #define IBMVNIC_PHYSICAL_PORT 0x80
  442. u8 reserved1;
  443. __be32 ioba;
  444. __be32 len;
  445. u8 reserved[4];
  446. } __packed __aligned(8);
  447. struct ibmvnic_request_debug_stats {
  448. u8 first;
  449. u8 cmd;
  450. u8 reserved[2];
  451. __be32 ioba;
  452. __be32 len;
  453. struct ibmvnic_rc rc;
  454. } __packed __aligned(8);
  455. struct ibmvnic_error_indication {
  456. u8 first;
  457. u8 cmd;
  458. u8 flags;
  459. #define IBMVNIC_FATAL_ERROR 0x80
  460. u8 reserved1;
  461. __be32 error_id;
  462. __be32 detail_error_sz;
  463. __be16 error_cause;
  464. u8 reserved2[2];
  465. } __packed __aligned(8);
  466. struct ibmvnic_link_state_indication {
  467. u8 first;
  468. u8 cmd;
  469. u8 reserved1[2];
  470. u8 phys_link_state;
  471. u8 logical_link_state;
  472. u8 reserved2[10];
  473. } __packed __aligned(8);
  474. struct ibmvnic_change_mac_addr {
  475. u8 first;
  476. u8 cmd;
  477. u8 mac_addr[6];
  478. u8 reserved[4];
  479. struct ibmvnic_rc rc;
  480. } __packed __aligned(8);
  481. struct ibmvnic_multicast_ctrl {
  482. u8 first;
  483. u8 cmd;
  484. u8 mac_addr[6];
  485. u8 flags;
  486. #define IBMVNIC_ENABLE_MC 0x80
  487. #define IBMVNIC_DISABLE_MC 0x40
  488. #define IBMVNIC_ENABLE_ALL 0x20
  489. #define IBMVNIC_DISABLE_ALL 0x10
  490. u8 reserved1;
  491. __be16 reserved2; /* was num_enabled_mc_addr; */
  492. struct ibmvnic_rc rc;
  493. } __packed __aligned(8);
  494. struct ibmvnic_get_vpd_size {
  495. u8 first;
  496. u8 cmd;
  497. u8 reserved[14];
  498. } __packed __aligned(8);
  499. struct ibmvnic_get_vpd_size_rsp {
  500. u8 first;
  501. u8 cmd;
  502. u8 reserved[2];
  503. __be64 len;
  504. struct ibmvnic_rc rc;
  505. } __packed __aligned(8);
  506. struct ibmvnic_get_vpd {
  507. u8 first;
  508. u8 cmd;
  509. u8 reserved1[2];
  510. __be32 ioba;
  511. __be32 len;
  512. u8 reserved[4];
  513. } __packed __aligned(8);
  514. struct ibmvnic_get_vpd_rsp {
  515. u8 first;
  516. u8 cmd;
  517. u8 reserved[10];
  518. struct ibmvnic_rc rc;
  519. } __packed __aligned(8);
  520. struct ibmvnic_acl_change_indication {
  521. u8 first;
  522. u8 cmd;
  523. __be16 change_type;
  524. #define IBMVNIC_MAC_ACL 0
  525. #define IBMVNIC_VLAN_ACL 1
  526. u8 reserved[12];
  527. } __packed __aligned(8);
  528. struct ibmvnic_acl_query {
  529. u8 first;
  530. u8 cmd;
  531. u8 reserved1[2];
  532. __be32 ioba;
  533. __be32 len;
  534. u8 reserved2[4];
  535. } __packed __aligned(8);
  536. struct ibmvnic_tune {
  537. u8 first;
  538. u8 cmd;
  539. u8 reserved1[2];
  540. __be32 ioba;
  541. __be32 len;
  542. u8 reserved2[4];
  543. } __packed __aligned(8);
  544. struct ibmvnic_request_map {
  545. u8 first;
  546. u8 cmd;
  547. u8 reserved1;
  548. u8 map_id;
  549. __be32 ioba;
  550. __be32 len;
  551. u8 reserved2[4];
  552. } __packed __aligned(8);
  553. struct ibmvnic_request_map_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_request_unmap {
  562. u8 first;
  563. u8 cmd;
  564. u8 reserved1;
  565. u8 map_id;
  566. u8 reserved2[12];
  567. } __packed __aligned(8);
  568. struct ibmvnic_request_unmap_rsp {
  569. u8 first;
  570. u8 cmd;
  571. u8 reserved1;
  572. u8 map_id;
  573. u8 reserved2[8];
  574. struct ibmvnic_rc rc;
  575. } __packed __aligned(8);
  576. struct ibmvnic_query_map {
  577. u8 first;
  578. u8 cmd;
  579. u8 reserved[14];
  580. } __packed __aligned(8);
  581. struct ibmvnic_query_map_rsp {
  582. u8 first;
  583. u8 cmd;
  584. u8 reserved;
  585. u8 page_size;
  586. __be32 tot_pages;
  587. __be32 free_pages;
  588. struct ibmvnic_rc rc;
  589. } __packed __aligned(8);
  590. union ibmvnic_crq {
  591. struct ibmvnic_generic_crq generic;
  592. struct ibmvnic_version_exchange version_exchange;
  593. struct ibmvnic_version_exchange version_exchange_rsp;
  594. struct ibmvnic_capability query_capability;
  595. struct ibmvnic_capability query_capability_rsp;
  596. struct ibmvnic_capability request_capability;
  597. struct ibmvnic_capability request_capability_rsp;
  598. struct ibmvnic_login login;
  599. struct ibmvnic_generic_crq login_rsp;
  600. struct ibmvnic_phys_parms query_phys_parms;
  601. struct ibmvnic_phys_parms query_phys_parms_rsp;
  602. struct ibmvnic_phys_parms query_phys_capabilities;
  603. struct ibmvnic_phys_parms query_phys_capabilities_rsp;
  604. struct ibmvnic_phys_parms set_phys_parms;
  605. struct ibmvnic_phys_parms set_phys_parms_rsp;
  606. struct ibmvnic_logical_link_state logical_link_state;
  607. struct ibmvnic_logical_link_state logical_link_state_rsp;
  608. struct ibmvnic_query_ip_offload query_ip_offload;
  609. struct ibmvnic_query_ip_offload query_ip_offload_rsp;
  610. struct ibmvnic_control_ip_offload control_ip_offload;
  611. struct ibmvnic_control_ip_offload control_ip_offload_rsp;
  612. struct ibmvnic_request_dump_size request_dump_size;
  613. struct ibmvnic_request_dump_size request_dump_size_rsp;
  614. struct ibmvnic_request_dump request_dump;
  615. struct ibmvnic_request_dump_rsp request_dump_rsp;
  616. struct ibmvnic_request_ras_comp_num request_ras_comp_num;
  617. struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
  618. struct ibmvnic_request_ras_comps request_ras_comps;
  619. struct ibmvnic_request_ras_comps request_ras_comps_rsp;
  620. struct ibmvnic_control_ras control_ras;
  621. struct ibmvnic_control_ras control_ras_rsp;
  622. struct ibmvnic_collect_fw_trace collect_fw_trace;
  623. struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
  624. struct ibmvnic_request_statistics request_statistics;
  625. struct ibmvnic_generic_crq request_statistics_rsp;
  626. struct ibmvnic_request_debug_stats request_debug_stats;
  627. struct ibmvnic_request_debug_stats request_debug_stats_rsp;
  628. struct ibmvnic_error_indication error_indication;
  629. struct ibmvnic_link_state_indication link_state_indication;
  630. struct ibmvnic_change_mac_addr change_mac_addr;
  631. struct ibmvnic_change_mac_addr change_mac_addr_rsp;
  632. struct ibmvnic_multicast_ctrl multicast_ctrl;
  633. struct ibmvnic_multicast_ctrl multicast_ctrl_rsp;
  634. struct ibmvnic_get_vpd_size get_vpd_size;
  635. struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
  636. struct ibmvnic_get_vpd get_vpd;
  637. struct ibmvnic_get_vpd_rsp get_vpd_rsp;
  638. struct ibmvnic_acl_change_indication acl_change_indication;
  639. struct ibmvnic_acl_query acl_query;
  640. struct ibmvnic_generic_crq acl_query_rsp;
  641. struct ibmvnic_tune tune;
  642. struct ibmvnic_generic_crq tune_rsp;
  643. struct ibmvnic_request_map request_map;
  644. struct ibmvnic_request_map_rsp request_map_rsp;
  645. struct ibmvnic_request_unmap request_unmap;
  646. struct ibmvnic_request_unmap_rsp request_unmap_rsp;
  647. struct ibmvnic_query_map query_map;
  648. struct ibmvnic_query_map_rsp query_map_rsp;
  649. };
  650. enum ibmvnic_rc_codes {
  651. SUCCESS = 0,
  652. PARTIALSUCCESS = 1,
  653. PERMISSION = 2,
  654. NOMEMORY = 3,
  655. PARAMETER = 4,
  656. UNKNOWNCOMMAND = 5,
  657. ABORTED = 6,
  658. INVALIDSTATE = 7,
  659. INVALIDIOBA = 8,
  660. INVALIDLENGTH = 9,
  661. UNSUPPORTEDOPTION = 10,
  662. };
  663. enum ibmvnic_capabilities {
  664. MIN_TX_QUEUES = 1,
  665. MIN_RX_QUEUES = 2,
  666. MIN_RX_ADD_QUEUES = 3,
  667. MAX_TX_QUEUES = 4,
  668. MAX_RX_QUEUES = 5,
  669. MAX_RX_ADD_QUEUES = 6,
  670. REQ_TX_QUEUES = 7,
  671. REQ_RX_QUEUES = 8,
  672. REQ_RX_ADD_QUEUES = 9,
  673. MIN_TX_ENTRIES_PER_SUBCRQ = 10,
  674. MIN_RX_ADD_ENTRIES_PER_SUBCRQ = 11,
  675. MAX_TX_ENTRIES_PER_SUBCRQ = 12,
  676. MAX_RX_ADD_ENTRIES_PER_SUBCRQ = 13,
  677. REQ_TX_ENTRIES_PER_SUBCRQ = 14,
  678. REQ_RX_ADD_ENTRIES_PER_SUBCRQ = 15,
  679. TCP_IP_OFFLOAD = 16,
  680. PROMISC_REQUESTED = 17,
  681. PROMISC_SUPPORTED = 18,
  682. MIN_MTU = 19,
  683. MAX_MTU = 20,
  684. REQ_MTU = 21,
  685. MAX_MULTICAST_FILTERS = 22,
  686. VLAN_HEADER_INSERTION = 23,
  687. RX_VLAN_HEADER_INSERTION = 24,
  688. MAX_TX_SG_ENTRIES = 25,
  689. RX_SG_SUPPORTED = 26,
  690. RX_SG_REQUESTED = 27,
  691. OPT_TX_COMP_SUB_QUEUES = 28,
  692. OPT_RX_COMP_QUEUES = 29,
  693. OPT_RX_BUFADD_Q_PER_RX_COMP_Q = 30,
  694. OPT_TX_ENTRIES_PER_SUBCRQ = 31,
  695. OPT_RXBA_ENTRIES_PER_SUBCRQ = 32,
  696. TX_RX_DESC_REQ = 33,
  697. };
  698. enum ibmvnic_error_cause {
  699. ADAPTER_PROBLEM = 0,
  700. BUS_PROBLEM = 1,
  701. FW_PROBLEM = 2,
  702. DD_PROBLEM = 3,
  703. EEH_RECOVERY = 4,
  704. FW_UPDATED = 5,
  705. LOW_MEMORY = 6,
  706. };
  707. enum ibmvnic_commands {
  708. VERSION_EXCHANGE = 0x01,
  709. VERSION_EXCHANGE_RSP = 0x81,
  710. QUERY_CAPABILITY = 0x02,
  711. QUERY_CAPABILITY_RSP = 0x82,
  712. REQUEST_CAPABILITY = 0x03,
  713. REQUEST_CAPABILITY_RSP = 0x83,
  714. LOGIN = 0x04,
  715. LOGIN_RSP = 0x84,
  716. QUERY_PHYS_PARMS = 0x05,
  717. QUERY_PHYS_PARMS_RSP = 0x85,
  718. QUERY_PHYS_CAPABILITIES = 0x06,
  719. QUERY_PHYS_CAPABILITIES_RSP = 0x86,
  720. SET_PHYS_PARMS = 0x07,
  721. SET_PHYS_PARMS_RSP = 0x87,
  722. ERROR_INDICATION = 0x08,
  723. LOGICAL_LINK_STATE = 0x0C,
  724. LOGICAL_LINK_STATE_RSP = 0x8C,
  725. REQUEST_STATISTICS = 0x0D,
  726. REQUEST_STATISTICS_RSP = 0x8D,
  727. COLLECT_FW_TRACE = 0x11,
  728. COLLECT_FW_TRACE_RSP = 0x91,
  729. LINK_STATE_INDICATION = 0x12,
  730. CHANGE_MAC_ADDR = 0x13,
  731. CHANGE_MAC_ADDR_RSP = 0x93,
  732. MULTICAST_CTRL = 0x14,
  733. MULTICAST_CTRL_RSP = 0x94,
  734. GET_VPD_SIZE = 0x15,
  735. GET_VPD_SIZE_RSP = 0x95,
  736. GET_VPD = 0x16,
  737. GET_VPD_RSP = 0x96,
  738. TUNE = 0x17,
  739. TUNE_RSP = 0x97,
  740. QUERY_IP_OFFLOAD = 0x18,
  741. QUERY_IP_OFFLOAD_RSP = 0x98,
  742. CONTROL_IP_OFFLOAD = 0x19,
  743. CONTROL_IP_OFFLOAD_RSP = 0x99,
  744. ACL_CHANGE_INDICATION = 0x1A,
  745. ACL_QUERY = 0x1B,
  746. ACL_QUERY_RSP = 0x9B,
  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. bool active;
  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. int num_entries;
  817. };
  818. struct ibmvnic_tx_pool {
  819. struct ibmvnic_tx_buff *tx_buff;
  820. int *free_map;
  821. int consumer_index;
  822. int producer_index;
  823. struct ibmvnic_long_term_buff long_term_buff;
  824. int num_buffers;
  825. int buf_size;
  826. };
  827. struct ibmvnic_rx_buff {
  828. struct sk_buff *skb;
  829. dma_addr_t dma;
  830. unsigned char *data;
  831. int size;
  832. int pool_index;
  833. };
  834. struct ibmvnic_rx_pool {
  835. struct ibmvnic_rx_buff *rx_buff;
  836. int size;
  837. int index;
  838. int buff_size;
  839. atomic_t available;
  840. int *free_map;
  841. int next_free;
  842. int next_alloc;
  843. int active;
  844. struct ibmvnic_long_term_buff long_term_buff;
  845. };
  846. struct ibmvnic_vpd {
  847. unsigned char *buff;
  848. dma_addr_t dma_addr;
  849. u64 len;
  850. };
  851. enum vnic_state {VNIC_PROBING = 1,
  852. VNIC_PROBED,
  853. VNIC_OPENING,
  854. VNIC_OPEN,
  855. VNIC_CLOSING,
  856. VNIC_CLOSED,
  857. VNIC_REMOVING,
  858. VNIC_REMOVED};
  859. enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
  860. VNIC_RESET_MOBILITY,
  861. VNIC_RESET_FATAL,
  862. VNIC_RESET_NON_FATAL,
  863. VNIC_RESET_TIMEOUT,
  864. VNIC_RESET_CHANGE_PARAM};
  865. struct ibmvnic_rwi {
  866. enum ibmvnic_reset_reason reset_reason;
  867. struct list_head list;
  868. };
  869. struct ibmvnic_tunables {
  870. u64 rx_queues;
  871. u64 tx_queues;
  872. u64 rx_entries;
  873. u64 tx_entries;
  874. u64 mtu;
  875. struct sockaddr mac;
  876. };
  877. struct ibmvnic_adapter {
  878. struct vio_dev *vdev;
  879. struct net_device *netdev;
  880. struct ibmvnic_crq_queue crq;
  881. u8 mac_addr[ETH_ALEN];
  882. struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
  883. dma_addr_t ip_offload_tok;
  884. struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
  885. dma_addr_t ip_offload_ctrl_tok;
  886. u32 msg_enable;
  887. /* Vital Product Data (VPD) */
  888. struct ibmvnic_vpd *vpd;
  889. char fw_version[32];
  890. /* Statistics */
  891. struct ibmvnic_statistics stats;
  892. dma_addr_t stats_token;
  893. struct completion stats_done;
  894. spinlock_t stats_lock;
  895. int replenish_no_mem;
  896. int replenish_add_buff_success;
  897. int replenish_add_buff_failure;
  898. int replenish_task_cycles;
  899. int tx_send_failed;
  900. int tx_map_failed;
  901. struct ibmvnic_tx_queue_stats *tx_stats_buffers;
  902. struct ibmvnic_rx_queue_stats *rx_stats_buffers;
  903. int phys_link_state;
  904. int logical_link_state;
  905. /* login data */
  906. struct ibmvnic_login_buffer *login_buf;
  907. dma_addr_t login_buf_token;
  908. int login_buf_sz;
  909. struct ibmvnic_login_rsp_buffer *login_rsp_buf;
  910. dma_addr_t login_rsp_buf_token;
  911. int login_rsp_buf_sz;
  912. atomic_t running_cap_crqs;
  913. bool wait_capability;
  914. struct ibmvnic_sub_crq_queue **tx_scrq;
  915. struct ibmvnic_sub_crq_queue **rx_scrq;
  916. /* rx structs */
  917. struct napi_struct *napi;
  918. struct ibmvnic_rx_pool *rx_pool;
  919. u64 promisc;
  920. struct ibmvnic_tx_pool *tx_pool;
  921. struct ibmvnic_tx_pool *tso_pool;
  922. struct completion init_done;
  923. int init_done_rc;
  924. struct completion fw_done;
  925. int fw_done_rc;
  926. struct completion reset_done;
  927. int reset_done_rc;
  928. bool wait_for_reset;
  929. /* partner capabilities */
  930. u64 min_tx_queues;
  931. u64 min_rx_queues;
  932. u64 min_rx_add_queues;
  933. u64 max_tx_queues;
  934. u64 max_rx_queues;
  935. u64 max_rx_add_queues;
  936. u64 req_tx_queues;
  937. u64 req_rx_queues;
  938. u64 req_rx_add_queues;
  939. u64 min_tx_entries_per_subcrq;
  940. u64 min_rx_add_entries_per_subcrq;
  941. u64 max_tx_entries_per_subcrq;
  942. u64 max_rx_add_entries_per_subcrq;
  943. u64 req_tx_entries_per_subcrq;
  944. u64 req_rx_add_entries_per_subcrq;
  945. u64 tcp_ip_offload;
  946. u64 promisc_requested;
  947. u64 promisc_supported;
  948. u64 min_mtu;
  949. u64 max_mtu;
  950. u64 req_mtu;
  951. u64 max_multicast_filters;
  952. u64 vlan_header_insertion;
  953. u64 rx_vlan_header_insertion;
  954. u64 max_tx_sg_entries;
  955. u64 rx_sg_supported;
  956. u64 rx_sg_requested;
  957. u64 opt_tx_comp_sub_queues;
  958. u64 opt_rx_comp_queues;
  959. u64 opt_rx_bufadd_q_per_rx_comp_q;
  960. u64 opt_tx_entries_per_subcrq;
  961. u64 opt_rxba_entries_per_subcrq;
  962. __be64 tx_rx_desc_req;
  963. u8 map_id;
  964. u32 num_active_rx_scrqs;
  965. u32 num_active_rx_pools;
  966. u32 num_active_rx_napi;
  967. u32 num_active_tx_scrqs;
  968. u32 num_active_tx_pools;
  969. struct tasklet_struct tasklet;
  970. enum vnic_state state;
  971. enum ibmvnic_reset_reason reset_reason;
  972. spinlock_t rwi_lock;
  973. struct list_head rwi_list;
  974. struct work_struct ibmvnic_reset;
  975. bool resetting;
  976. bool napi_enabled, from_passive_init;
  977. bool mac_change_pending;
  978. bool failover_pending;
  979. bool force_reset_recovery;
  980. struct ibmvnic_tunables desired;
  981. struct ibmvnic_tunables fallback;
  982. };