ibmvnic.h 25 KB

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