ibmvnic.h 25 KB

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