ibmvnic.h 25 KB

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