ibmvnic.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /**************************************************************************/
  3. /* */
  4. /* IBM System i and System p Virtual NIC Device Driver */
  5. /* Copyright (C) 2014 IBM Corp. */
  6. /* Santiago Leon (santi_leon@yahoo.com) */
  7. /* Thomas Falcon (tlfalcon@linux.vnet.ibm.com) */
  8. /* John Allen (jallen@linux.vnet.ibm.com) */
  9. /* */
  10. /* */
  11. /* This module contains the implementation of a virtual ethernet device */
  12. /* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */
  13. /* option of the RS/6000 Platform Architecture to interface with virtual */
  14. /* ethernet NICs that are presented to the partition by the hypervisor. */
  15. /* */
  16. /**************************************************************************/
  17. #define IBMVNIC_NAME "ibmvnic"
  18. #define IBMVNIC_DRIVER_VERSION "1.0.1"
  19. #define IBMVNIC_INVALID_MAP -1
  20. #define IBMVNIC_STATS_TIMEOUT 1
  21. #define IBMVNIC_INIT_FAILED 2
  22. #define IBMVNIC_OPEN_FAILED 3
  23. /* basic structures plus 100 2k buffers */
  24. #define IBMVNIC_IO_ENTITLEMENT_DEFAULT 610305
  25. /* Initial module_parameters */
  26. #define IBMVNIC_RX_WEIGHT 16
  27. /* when changing this, update IBMVNIC_IO_ENTITLEMENT_DEFAULT */
  28. #define IBMVNIC_BUFFS_PER_POOL 100
  29. #define IBMVNIC_MAX_QUEUES 16
  30. #define IBMVNIC_MAX_QUEUE_SZ 4096
  31. #define IBMVNIC_TSO_BUF_SZ 65536
  32. #define IBMVNIC_TSO_BUFS 64
  33. #define IBMVNIC_TSO_POOL_MASK 0x80000000
  34. #define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE)
  35. #define IBMVNIC_BUFFER_HLEN 500
  36. #define IBMVNIC_RESET_DELAY 100
  37. static const char ibmvnic_priv_flags[][ETH_GSTRING_LEN] = {
  38. #define IBMVNIC_USE_SERVER_MAXES 0x1
  39. "use-server-maxes"
  40. };
  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. __be32 client_data_offset;
  52. __be32 client_data_len;
  53. } __packed __aligned(8);
  54. struct ibmvnic_login_rsp_buffer {
  55. __be32 len;
  56. __be32 version;
  57. #define INITIAL_VERSION_LRB 1
  58. __be32 num_txsubm_subcrqs;
  59. __be32 off_txsubm_subcrqs;
  60. __be32 num_rxadd_subcrqs;
  61. __be32 off_rxadd_subcrqs;
  62. __be32 off_rxadd_buff_size;
  63. __be32 num_supp_tx_desc;
  64. __be32 off_supp_tx_desc;
  65. } __packed __aligned(8);
  66. struct ibmvnic_query_ip_offload_buffer {
  67. __be32 len;
  68. __be32 version;
  69. #define INITIAL_VERSION_IOB 1
  70. u8 ipv4_chksum;
  71. u8 ipv6_chksum;
  72. u8 tcp_ipv4_chksum;
  73. u8 tcp_ipv6_chksum;
  74. u8 udp_ipv4_chksum;
  75. u8 udp_ipv6_chksum;
  76. u8 large_tx_ipv4;
  77. u8 large_tx_ipv6;
  78. u8 large_rx_ipv4;
  79. u8 large_rx_ipv6;
  80. u8 reserved1[14];
  81. __be16 max_ipv4_header_size;
  82. __be16 max_ipv6_header_size;
  83. __be16 max_tcp_header_size;
  84. __be16 max_udp_header_size;
  85. __be32 max_large_tx_size;
  86. __be32 max_large_rx_size;
  87. u8 reserved2[16];
  88. u8 ipv6_extension_header;
  89. #define IPV6_EH_NOT_SUPPORTED 0x00
  90. #define IPV6_EH_SUPPORTED_LIM 0x01
  91. #define IPV6_EH_SUPPORTED 0xFF
  92. u8 tcp_pseudosum_req;
  93. #define TCP_PS_NOT_REQUIRED 0x00
  94. #define TCP_PS_REQUIRED 0x01
  95. u8 reserved3[30];
  96. __be16 num_ipv6_ext_headers;
  97. __be32 off_ipv6_ext_headers;
  98. u8 reserved4[154];
  99. } __packed __aligned(8);
  100. struct ibmvnic_control_ip_offload_buffer {
  101. __be32 len;
  102. __be32 version;
  103. #define INITIAL_VERSION_IOB 1
  104. u8 ipv4_chksum;
  105. u8 ipv6_chksum;
  106. u8 tcp_ipv4_chksum;
  107. u8 tcp_ipv6_chksum;
  108. u8 udp_ipv4_chksum;
  109. u8 udp_ipv6_chksum;
  110. u8 large_tx_ipv4;
  111. u8 large_tx_ipv6;
  112. u8 bad_packet_rx;
  113. u8 large_rx_ipv4;
  114. u8 large_rx_ipv6;
  115. u8 reserved4[111];
  116. } __packed __aligned(8);
  117. struct ibmvnic_fw_component {
  118. u8 name[48];
  119. __be32 trace_buff_size;
  120. u8 correlator;
  121. u8 trace_level;
  122. u8 parent_correlator;
  123. u8 error_check_level;
  124. u8 trace_on;
  125. u8 reserved[7];
  126. u8 description[192];
  127. } __packed __aligned(8);
  128. struct ibmvnic_fw_trace_entry {
  129. __be32 trace_id;
  130. u8 num_valid_data;
  131. u8 reserved[3];
  132. __be64 pmc_registers;
  133. __be64 timebase;
  134. __be64 trace_data[5];
  135. } __packed __aligned(8);
  136. struct ibmvnic_statistics {
  137. __be32 version;
  138. __be32 promiscuous;
  139. __be64 rx_packets;
  140. __be64 rx_bytes;
  141. __be64 tx_packets;
  142. __be64 tx_bytes;
  143. __be64 ucast_tx_packets;
  144. __be64 ucast_rx_packets;
  145. __be64 mcast_tx_packets;
  146. __be64 mcast_rx_packets;
  147. __be64 bcast_tx_packets;
  148. __be64 bcast_rx_packets;
  149. __be64 align_errors;
  150. __be64 fcs_errors;
  151. __be64 single_collision_frames;
  152. __be64 multi_collision_frames;
  153. __be64 sqe_test_errors;
  154. __be64 deferred_tx;
  155. __be64 late_collisions;
  156. __be64 excess_collisions;
  157. __be64 internal_mac_tx_errors;
  158. __be64 carrier_sense;
  159. __be64 too_long_frames;
  160. __be64 internal_mac_rx_errors;
  161. u8 reserved[72];
  162. } __packed __aligned(8);
  163. #define NUM_TX_STATS 3
  164. struct ibmvnic_tx_queue_stats {
  165. u64 packets;
  166. u64 bytes;
  167. u64 dropped_packets;
  168. };
  169. #define NUM_RX_STATS 3
  170. struct ibmvnic_rx_queue_stats {
  171. u64 packets;
  172. u64 bytes;
  173. u64 interrupts;
  174. };
  175. struct ibmvnic_acl_buffer {
  176. __be32 len;
  177. __be32 version;
  178. #define INITIAL_VERSION_IOB 1
  179. u8 mac_acls_restrict;
  180. u8 vlan_acls_restrict;
  181. u8 reserved1[22];
  182. __be32 num_mac_addrs;
  183. __be32 offset_mac_addrs;
  184. __be32 num_vlan_ids;
  185. __be32 offset_vlan_ids;
  186. u8 reserved2[80];
  187. } __packed __aligned(8);
  188. /* descriptors have been changed, how should this be defined? 1? 4? */
  189. #define IBMVNIC_TX_DESC_VERSIONS 3
  190. /* is this still needed? */
  191. struct ibmvnic_tx_comp_desc {
  192. u8 first;
  193. u8 num_comps;
  194. __be16 rcs[5];
  195. __be32 correlators[5];
  196. } __packed __aligned(8);
  197. /* some flags that included in v0 descriptor, which is gone
  198. * only used for IBMVNIC_TCP_CHKSUM and IBMVNIC_UDP_CHKSUM
  199. * and only in some offload_flags variable that doesn't seem
  200. * to be used anywhere, can probably be removed?
  201. */
  202. #define IBMVNIC_TCP_CHKSUM 0x20
  203. #define IBMVNIC_UDP_CHKSUM 0x08
  204. #define IBMVNIC_MAX_FRAGS_PER_CRQ 3
  205. struct ibmvnic_tx_desc {
  206. u8 first;
  207. u8 type;
  208. #define IBMVNIC_TX_DESC 0x10
  209. u8 n_crq_elem;
  210. u8 n_sge;
  211. u8 flags1;
  212. #define IBMVNIC_TX_COMP_NEEDED 0x80
  213. #define IBMVNIC_TX_CHKSUM_OFFLOAD 0x40
  214. #define IBMVNIC_TX_LSO 0x20
  215. #define IBMVNIC_TX_PROT_TCP 0x10
  216. #define IBMVNIC_TX_PROT_UDP 0x08
  217. #define IBMVNIC_TX_PROT_IPV4 0x04
  218. #define IBMVNIC_TX_PROT_IPV6 0x02
  219. #define IBMVNIC_TX_VLAN_PRESENT 0x01
  220. u8 flags2;
  221. #define IBMVNIC_TX_VLAN_INSERT 0x80
  222. __be16 mss;
  223. u8 reserved[4];
  224. __be32 correlator;
  225. __be16 vlan_id;
  226. __be16 dma_reg;
  227. __be32 sge_len;
  228. __be64 ioba;
  229. } __packed __aligned(8);
  230. struct ibmvnic_hdr_desc {
  231. u8 first;
  232. u8 type;
  233. #define IBMVNIC_HDR_DESC 0x11
  234. u8 len;
  235. u8 l2_len;
  236. __be16 l3_len;
  237. u8 l4_len;
  238. u8 flag;
  239. u8 data[24];
  240. } __packed __aligned(8);
  241. struct ibmvnic_hdr_ext_desc {
  242. u8 first;
  243. u8 type;
  244. #define IBMVNIC_HDR_EXT_DESC 0x12
  245. u8 len;
  246. u8 data[29];
  247. } __packed __aligned(8);
  248. struct ibmvnic_sge_desc {
  249. u8 first;
  250. u8 type;
  251. #define IBMVNIC_SGE_DESC 0x30
  252. __be16 sge1_dma_reg;
  253. __be32 sge1_len;
  254. __be64 sge1_ioba;
  255. __be16 reserved;
  256. __be16 sge2_dma_reg;
  257. __be32 sge2_len;
  258. __be64 sge2_ioba;
  259. } __packed __aligned(8);
  260. struct ibmvnic_rx_comp_desc {
  261. u8 first;
  262. u8 flags;
  263. #define IBMVNIC_IP_CHKSUM_GOOD 0x80
  264. #define IBMVNIC_TCP_UDP_CHKSUM_GOOD 0x40
  265. #define IBMVNIC_END_FRAME 0x20
  266. #define IBMVNIC_EXACT_MC 0x10
  267. #define IBMVNIC_VLAN_STRIPPED 0x08
  268. __be16 off_frame_data;
  269. __be32 len;
  270. __be64 correlator;
  271. __be16 vlan_tci;
  272. __be16 rc;
  273. u8 reserved[12];
  274. } __packed __aligned(8);
  275. struct ibmvnic_generic_scrq {
  276. u8 first;
  277. u8 reserved[31];
  278. } __packed __aligned(8);
  279. struct ibmvnic_rx_buff_add_desc {
  280. u8 first;
  281. u8 reserved[7];
  282. __be64 correlator;
  283. __be32 ioba;
  284. u8 map_id;
  285. __be32 len:24;
  286. u8 reserved2[8];
  287. } __packed __aligned(8);
  288. struct ibmvnic_rc {
  289. u8 code; /* one of enum ibmvnic_rc_codes */
  290. u8 detailed_data[3];
  291. } __packed __aligned(4);
  292. struct ibmvnic_generic_crq {
  293. u8 first;
  294. u8 cmd;
  295. u8 params[10];
  296. struct ibmvnic_rc rc;
  297. } __packed __aligned(8);
  298. struct ibmvnic_version_exchange {
  299. u8 first;
  300. u8 cmd;
  301. __be16 version;
  302. #define IBMVNIC_INITIAL_VERSION 1
  303. u8 reserved[8];
  304. struct ibmvnic_rc rc;
  305. } __packed __aligned(8);
  306. struct ibmvnic_capability {
  307. u8 first;
  308. u8 cmd;
  309. __be16 capability; /* one of ibmvnic_capabilities */
  310. __be64 number;
  311. struct ibmvnic_rc rc;
  312. } __packed __aligned(8);
  313. struct ibmvnic_login {
  314. u8 first;
  315. u8 cmd;
  316. u8 reserved[6];
  317. __be32 ioba;
  318. __be32 len;
  319. } __packed __aligned(8);
  320. struct ibmvnic_phys_parms {
  321. u8 first;
  322. u8 cmd;
  323. u8 flags1;
  324. #define IBMVNIC_EXTERNAL_LOOPBACK 0x80
  325. #define IBMVNIC_INTERNAL_LOOPBACK 0x40
  326. #define IBMVNIC_PROMISC 0x20
  327. #define IBMVNIC_PHYS_LINK_ACTIVE 0x10
  328. #define IBMVNIC_AUTONEG_DUPLEX 0x08
  329. #define IBMVNIC_FULL_DUPLEX 0x04
  330. #define IBMVNIC_HALF_DUPLEX 0x02
  331. #define IBMVNIC_CAN_CHG_PHYS_PARMS 0x01
  332. u8 flags2;
  333. #define IBMVNIC_LOGICAL_LNK_ACTIVE 0x80
  334. __be32 speed;
  335. #define IBMVNIC_AUTONEG 0x80000000
  336. #define IBMVNIC_10MBPS 0x40000000
  337. #define IBMVNIC_100MBPS 0x20000000
  338. #define IBMVNIC_1GBPS 0x10000000
  339. #define IBMVNIC_10GBPS 0x08000000
  340. #define IBMVNIC_40GBPS 0x04000000
  341. #define IBMVNIC_100GBPS 0x02000000
  342. #define IBMVNIC_25GBPS 0x01000000
  343. #define IBMVNIC_50GBPS 0x00800000
  344. #define IBMVNIC_200GBPS 0x00400000
  345. __be32 mtu;
  346. struct ibmvnic_rc rc;
  347. } __packed __aligned(8);
  348. struct ibmvnic_logical_link_state {
  349. u8 first;
  350. u8 cmd;
  351. u8 link_state;
  352. #define IBMVNIC_LOGICAL_LNK_DN 0x00
  353. #define IBMVNIC_LOGICAL_LNK_UP 0x01
  354. #define IBMVNIC_LOGICAL_LNK_QUERY 0xff
  355. u8 reserved[9];
  356. struct ibmvnic_rc rc;
  357. } __packed __aligned(8);
  358. struct ibmvnic_query_ip_offload {
  359. u8 first;
  360. u8 cmd;
  361. u8 reserved[2];
  362. __be32 len;
  363. __be32 ioba;
  364. struct ibmvnic_rc rc;
  365. } __packed __aligned(8);
  366. struct ibmvnic_control_ip_offload {
  367. u8 first;
  368. u8 cmd;
  369. u8 reserved[2];
  370. __be32 ioba;
  371. __be32 len;
  372. struct ibmvnic_rc rc;
  373. } __packed __aligned(8);
  374. struct ibmvnic_request_dump_size {
  375. u8 first;
  376. u8 cmd;
  377. u8 reserved[6];
  378. __be32 len;
  379. struct ibmvnic_rc rc;
  380. } __packed __aligned(8);
  381. struct ibmvnic_request_dump {
  382. u8 first;
  383. u8 cmd;
  384. u8 reserved1[2];
  385. __be32 ioba;
  386. __be32 len;
  387. u8 reserved2[4];
  388. } __packed __aligned(8);
  389. struct ibmvnic_request_dump_rsp {
  390. u8 first;
  391. u8 cmd;
  392. u8 reserved[6];
  393. __be32 dumped_len;
  394. struct ibmvnic_rc rc;
  395. } __packed __aligned(8);
  396. struct ibmvnic_request_ras_comp_num {
  397. u8 first;
  398. u8 cmd;
  399. u8 reserved1[2];
  400. __be32 num_components;
  401. u8 reserved2[4];
  402. struct ibmvnic_rc rc;
  403. } __packed __aligned(8);
  404. struct ibmvnic_request_ras_comps {
  405. u8 first;
  406. u8 cmd;
  407. u8 reserved[2];
  408. __be32 ioba;
  409. __be32 len;
  410. struct ibmvnic_rc rc;
  411. } __packed __aligned(8);
  412. struct ibmvnic_control_ras {
  413. u8 first;
  414. u8 cmd;
  415. u8 correlator;
  416. u8 level;
  417. u8 op;
  418. #define IBMVNIC_TRACE_LEVEL 1
  419. #define IBMVNIC_ERROR_LEVEL 2
  420. #define IBMVNIC_TRACE_PAUSE 3
  421. #define IBMVNIC_TRACE_RESUME 4
  422. #define IBMVNIC_TRACE_ON 5
  423. #define IBMVNIC_TRACE_OFF 6
  424. #define IBMVNIC_CHG_TRACE_BUFF_SZ 7
  425. u8 trace_buff_sz[3];
  426. u8 reserved[4];
  427. struct ibmvnic_rc rc;
  428. } __packed __aligned(8);
  429. struct ibmvnic_collect_fw_trace {
  430. u8 first;
  431. u8 cmd;
  432. u8 correlator;
  433. u8 reserved;
  434. __be32 ioba;
  435. __be32 len;
  436. struct ibmvnic_rc rc;
  437. } __packed __aligned(8);
  438. struct ibmvnic_request_statistics {
  439. u8 first;
  440. u8 cmd;
  441. u8 flags;
  442. #define IBMVNIC_PHYSICAL_PORT 0x80
  443. u8 reserved1;
  444. __be32 ioba;
  445. __be32 len;
  446. u8 reserved[4];
  447. } __packed __aligned(8);
  448. struct ibmvnic_request_debug_stats {
  449. u8 first;
  450. u8 cmd;
  451. u8 reserved[2];
  452. __be32 ioba;
  453. __be32 len;
  454. struct ibmvnic_rc rc;
  455. } __packed __aligned(8);
  456. struct ibmvnic_error_indication {
  457. u8 first;
  458. u8 cmd;
  459. u8 flags;
  460. #define IBMVNIC_FATAL_ERROR 0x80
  461. u8 reserved1;
  462. __be32 error_id;
  463. __be32 detail_error_sz;
  464. __be16 error_cause;
  465. u8 reserved2[2];
  466. } __packed __aligned(8);
  467. struct ibmvnic_link_state_indication {
  468. u8 first;
  469. u8 cmd;
  470. u8 reserved1[2];
  471. u8 phys_link_state;
  472. u8 logical_link_state;
  473. u8 reserved2[10];
  474. } __packed __aligned(8);
  475. struct ibmvnic_change_mac_addr {
  476. u8 first;
  477. u8 cmd;
  478. u8 mac_addr[6];
  479. u8 reserved[4];
  480. struct ibmvnic_rc rc;
  481. } __packed __aligned(8);
  482. struct ibmvnic_multicast_ctrl {
  483. u8 first;
  484. u8 cmd;
  485. u8 mac_addr[6];
  486. u8 flags;
  487. #define IBMVNIC_ENABLE_MC 0x80
  488. #define IBMVNIC_DISABLE_MC 0x40
  489. #define IBMVNIC_ENABLE_ALL 0x20
  490. #define IBMVNIC_DISABLE_ALL 0x10
  491. u8 reserved1;
  492. __be16 reserved2; /* was num_enabled_mc_addr; */
  493. struct ibmvnic_rc rc;
  494. } __packed __aligned(8);
  495. struct ibmvnic_get_vpd_size {
  496. u8 first;
  497. u8 cmd;
  498. u8 reserved[14];
  499. } __packed __aligned(8);
  500. struct ibmvnic_get_vpd_size_rsp {
  501. u8 first;
  502. u8 cmd;
  503. u8 reserved[2];
  504. __be64 len;
  505. struct ibmvnic_rc rc;
  506. } __packed __aligned(8);
  507. struct ibmvnic_get_vpd {
  508. u8 first;
  509. u8 cmd;
  510. u8 reserved1[2];
  511. __be32 ioba;
  512. __be32 len;
  513. u8 reserved[4];
  514. } __packed __aligned(8);
  515. struct ibmvnic_get_vpd_rsp {
  516. u8 first;
  517. u8 cmd;
  518. u8 reserved[10];
  519. struct ibmvnic_rc rc;
  520. } __packed __aligned(8);
  521. struct ibmvnic_acl_change_indication {
  522. u8 first;
  523. u8 cmd;
  524. __be16 change_type;
  525. #define IBMVNIC_MAC_ACL 0
  526. #define IBMVNIC_VLAN_ACL 1
  527. u8 reserved[12];
  528. } __packed __aligned(8);
  529. struct ibmvnic_acl_query {
  530. u8 first;
  531. u8 cmd;
  532. u8 reserved1[2];
  533. __be32 ioba;
  534. __be32 len;
  535. u8 reserved2[4];
  536. } __packed __aligned(8);
  537. struct ibmvnic_tune {
  538. u8 first;
  539. u8 cmd;
  540. u8 reserved1[2];
  541. __be32 ioba;
  542. __be32 len;
  543. u8 reserved2[4];
  544. } __packed __aligned(8);
  545. struct ibmvnic_request_map {
  546. u8 first;
  547. u8 cmd;
  548. u8 reserved1;
  549. u8 map_id;
  550. __be32 ioba;
  551. __be32 len;
  552. u8 reserved2[4];
  553. } __packed __aligned(8);
  554. struct ibmvnic_request_map_rsp {
  555. u8 first;
  556. u8 cmd;
  557. u8 reserved1;
  558. u8 map_id;
  559. u8 reserved2[8];
  560. struct ibmvnic_rc rc;
  561. } __packed __aligned(8);
  562. struct ibmvnic_request_unmap {
  563. u8 first;
  564. u8 cmd;
  565. u8 reserved1;
  566. u8 map_id;
  567. u8 reserved2[12];
  568. } __packed __aligned(8);
  569. struct ibmvnic_request_unmap_rsp {
  570. u8 first;
  571. u8 cmd;
  572. u8 reserved1;
  573. u8 map_id;
  574. u8 reserved2[8];
  575. struct ibmvnic_rc rc;
  576. } __packed __aligned(8);
  577. struct ibmvnic_query_map {
  578. u8 first;
  579. u8 cmd;
  580. u8 reserved[14];
  581. } __packed __aligned(8);
  582. struct ibmvnic_query_map_rsp {
  583. u8 first;
  584. u8 cmd;
  585. u8 reserved;
  586. u8 page_size;
  587. __be32 tot_pages;
  588. __be32 free_pages;
  589. struct ibmvnic_rc rc;
  590. } __packed __aligned(8);
  591. union ibmvnic_crq {
  592. struct ibmvnic_generic_crq generic;
  593. struct ibmvnic_version_exchange version_exchange;
  594. struct ibmvnic_version_exchange version_exchange_rsp;
  595. struct ibmvnic_capability query_capability;
  596. struct ibmvnic_capability query_capability_rsp;
  597. struct ibmvnic_capability request_capability;
  598. struct ibmvnic_capability request_capability_rsp;
  599. struct ibmvnic_login login;
  600. struct ibmvnic_generic_crq login_rsp;
  601. struct ibmvnic_phys_parms query_phys_parms;
  602. struct ibmvnic_phys_parms query_phys_parms_rsp;
  603. struct ibmvnic_phys_parms query_phys_capabilities;
  604. struct ibmvnic_phys_parms query_phys_capabilities_rsp;
  605. struct ibmvnic_phys_parms set_phys_parms;
  606. struct ibmvnic_phys_parms set_phys_parms_rsp;
  607. struct ibmvnic_logical_link_state logical_link_state;
  608. struct ibmvnic_logical_link_state logical_link_state_rsp;
  609. struct ibmvnic_query_ip_offload query_ip_offload;
  610. struct ibmvnic_query_ip_offload query_ip_offload_rsp;
  611. struct ibmvnic_control_ip_offload control_ip_offload;
  612. struct ibmvnic_control_ip_offload control_ip_offload_rsp;
  613. struct ibmvnic_request_dump_size request_dump_size;
  614. struct ibmvnic_request_dump_size request_dump_size_rsp;
  615. struct ibmvnic_request_dump request_dump;
  616. struct ibmvnic_request_dump_rsp request_dump_rsp;
  617. struct ibmvnic_request_ras_comp_num request_ras_comp_num;
  618. struct ibmvnic_request_ras_comp_num request_ras_comp_num_rsp;
  619. struct ibmvnic_request_ras_comps request_ras_comps;
  620. struct ibmvnic_request_ras_comps request_ras_comps_rsp;
  621. struct ibmvnic_control_ras control_ras;
  622. struct ibmvnic_control_ras control_ras_rsp;
  623. struct ibmvnic_collect_fw_trace collect_fw_trace;
  624. struct ibmvnic_collect_fw_trace collect_fw_trace_rsp;
  625. struct ibmvnic_request_statistics request_statistics;
  626. struct ibmvnic_generic_crq request_statistics_rsp;
  627. struct ibmvnic_request_debug_stats request_debug_stats;
  628. struct ibmvnic_request_debug_stats request_debug_stats_rsp;
  629. struct ibmvnic_error_indication error_indication;
  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_get_vpd_size get_vpd_size;
  636. struct ibmvnic_get_vpd_size_rsp get_vpd_size_rsp;
  637. struct ibmvnic_get_vpd get_vpd;
  638. struct ibmvnic_get_vpd_rsp 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. LOGICAL_LINK_STATE = 0x0C,
  725. LOGICAL_LINK_STATE_RSP = 0x8C,
  726. REQUEST_STATISTICS = 0x0D,
  727. REQUEST_STATISTICS_RSP = 0x8D,
  728. COLLECT_FW_TRACE = 0x11,
  729. COLLECT_FW_TRACE_RSP = 0x91,
  730. LINK_STATE_INDICATION = 0x12,
  731. CHANGE_MAC_ADDR = 0x13,
  732. CHANGE_MAC_ADDR_RSP = 0x93,
  733. MULTICAST_CTRL = 0x14,
  734. MULTICAST_CTRL_RSP = 0x94,
  735. GET_VPD_SIZE = 0x15,
  736. GET_VPD_SIZE_RSP = 0x95,
  737. GET_VPD = 0x16,
  738. GET_VPD_RSP = 0x96,
  739. TUNE = 0x17,
  740. TUNE_RSP = 0x97,
  741. QUERY_IP_OFFLOAD = 0x18,
  742. QUERY_IP_OFFLOAD_RSP = 0x98,
  743. CONTROL_IP_OFFLOAD = 0x19,
  744. CONTROL_IP_OFFLOAD_RSP = 0x99,
  745. ACL_CHANGE_INDICATION = 0x1A,
  746. ACL_QUERY = 0x1B,
  747. ACL_QUERY_RSP = 0x9B,
  748. QUERY_MAP = 0x1D,
  749. QUERY_MAP_RSP = 0x9D,
  750. REQUEST_MAP = 0x1E,
  751. REQUEST_MAP_RSP = 0x9E,
  752. REQUEST_UNMAP = 0x1F,
  753. REQUEST_UNMAP_RSP = 0x9F,
  754. VLAN_CTRL = 0x20,
  755. VLAN_CTRL_RSP = 0xA0,
  756. };
  757. enum ibmvnic_crq_type {
  758. IBMVNIC_CRQ_CMD = 0x80,
  759. IBMVNIC_CRQ_CMD_RSP = 0x80,
  760. IBMVNIC_CRQ_INIT_CMD = 0xC0,
  761. IBMVNIC_CRQ_INIT_RSP = 0xC0,
  762. IBMVNIC_CRQ_XPORT_EVENT = 0xFF,
  763. };
  764. enum ibmvfc_crq_format {
  765. IBMVNIC_CRQ_INIT = 0x01,
  766. IBMVNIC_CRQ_INIT_COMPLETE = 0x02,
  767. IBMVNIC_PARTITION_MIGRATED = 0x06,
  768. IBMVNIC_DEVICE_FAILOVER = 0x08,
  769. };
  770. struct ibmvnic_crq_queue {
  771. union ibmvnic_crq *msgs;
  772. int size, cur;
  773. dma_addr_t msg_token;
  774. spinlock_t lock;
  775. bool active;
  776. char name[32];
  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. char name[32];
  802. };
  803. struct ibmvnic_long_term_buff {
  804. unsigned char *buff;
  805. dma_addr_t addr;
  806. u64 size;
  807. u8 map_id;
  808. };
  809. struct ibmvnic_tx_buff {
  810. struct sk_buff *skb;
  811. dma_addr_t data_dma[IBMVNIC_MAX_FRAGS_PER_CRQ];
  812. unsigned int data_len[IBMVNIC_MAX_FRAGS_PER_CRQ];
  813. int index;
  814. int pool_index;
  815. bool last_frag;
  816. union sub_crq indir_arr[6];
  817. u8 hdr_data[140];
  818. dma_addr_t indir_dma;
  819. int num_entries;
  820. };
  821. struct ibmvnic_tx_pool {
  822. struct ibmvnic_tx_buff *tx_buff;
  823. int *free_map;
  824. int consumer_index;
  825. int producer_index;
  826. struct ibmvnic_long_term_buff long_term_buff;
  827. int num_buffers;
  828. int buf_size;
  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_vpd {
  850. unsigned char *buff;
  851. dma_addr_t dma_addr;
  852. u64 len;
  853. };
  854. enum vnic_state {VNIC_PROBING = 1,
  855. VNIC_PROBED,
  856. VNIC_OPENING,
  857. VNIC_OPEN,
  858. VNIC_CLOSING,
  859. VNIC_CLOSED,
  860. VNIC_REMOVING,
  861. VNIC_REMOVED};
  862. enum ibmvnic_reset_reason {VNIC_RESET_FAILOVER = 1,
  863. VNIC_RESET_MOBILITY,
  864. VNIC_RESET_FATAL,
  865. VNIC_RESET_NON_FATAL,
  866. VNIC_RESET_TIMEOUT,
  867. VNIC_RESET_CHANGE_PARAM};
  868. struct ibmvnic_rwi {
  869. enum ibmvnic_reset_reason reset_reason;
  870. struct list_head list;
  871. };
  872. struct ibmvnic_tunables {
  873. u64 rx_queues;
  874. u64 tx_queues;
  875. u64 rx_entries;
  876. u64 tx_entries;
  877. u64 mtu;
  878. };
  879. struct ibmvnic_adapter {
  880. struct vio_dev *vdev;
  881. struct net_device *netdev;
  882. struct ibmvnic_crq_queue crq;
  883. u8 mac_addr[ETH_ALEN];
  884. struct ibmvnic_query_ip_offload_buffer ip_offload_buf;
  885. dma_addr_t ip_offload_tok;
  886. struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
  887. dma_addr_t ip_offload_ctrl_tok;
  888. u32 msg_enable;
  889. u32 priv_flags;
  890. /* Vital Product Data (VPD) */
  891. struct ibmvnic_vpd *vpd;
  892. char fw_version[32];
  893. /* Statistics */
  894. struct ibmvnic_statistics stats;
  895. dma_addr_t stats_token;
  896. struct completion stats_done;
  897. spinlock_t stats_lock;
  898. int replenish_no_mem;
  899. int replenish_add_buff_success;
  900. int replenish_add_buff_failure;
  901. int replenish_task_cycles;
  902. int tx_send_failed;
  903. int tx_map_failed;
  904. struct ibmvnic_tx_queue_stats *tx_stats_buffers;
  905. struct ibmvnic_rx_queue_stats *rx_stats_buffers;
  906. int phys_link_state;
  907. int logical_link_state;
  908. u32 speed;
  909. u8 duplex;
  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. /* rx structs */
  922. struct napi_struct *napi;
  923. struct ibmvnic_rx_pool *rx_pool;
  924. u64 promisc;
  925. struct ibmvnic_tx_pool *tx_pool;
  926. struct ibmvnic_tx_pool *tso_pool;
  927. struct completion init_done;
  928. int init_done_rc;
  929. struct completion fw_done;
  930. int fw_done_rc;
  931. struct completion reset_done;
  932. int reset_done_rc;
  933. bool wait_for_reset;
  934. /* partner capabilities */
  935. u64 min_tx_queues;
  936. u64 min_rx_queues;
  937. u64 min_rx_add_queues;
  938. u64 max_tx_queues;
  939. u64 max_rx_queues;
  940. u64 max_rx_add_queues;
  941. u64 req_tx_queues;
  942. u64 req_rx_queues;
  943. u64 req_rx_add_queues;
  944. u64 min_tx_entries_per_subcrq;
  945. u64 min_rx_add_entries_per_subcrq;
  946. u64 max_tx_entries_per_subcrq;
  947. u64 max_rx_add_entries_per_subcrq;
  948. u64 req_tx_entries_per_subcrq;
  949. u64 req_rx_add_entries_per_subcrq;
  950. u64 tcp_ip_offload;
  951. u64 promisc_requested;
  952. u64 promisc_supported;
  953. u64 min_mtu;
  954. u64 max_mtu;
  955. u64 req_mtu;
  956. u64 max_multicast_filters;
  957. u64 vlan_header_insertion;
  958. u64 rx_vlan_header_insertion;
  959. u64 max_tx_sg_entries;
  960. u64 rx_sg_supported;
  961. u64 rx_sg_requested;
  962. u64 opt_tx_comp_sub_queues;
  963. u64 opt_rx_comp_queues;
  964. u64 opt_rx_bufadd_q_per_rx_comp_q;
  965. u64 opt_tx_entries_per_subcrq;
  966. u64 opt_rxba_entries_per_subcrq;
  967. __be64 tx_rx_desc_req;
  968. u8 map_id;
  969. u32 num_active_rx_scrqs;
  970. u32 num_active_rx_pools;
  971. u32 num_active_rx_napi;
  972. u32 num_active_tx_scrqs;
  973. u32 num_active_tx_pools;
  974. struct tasklet_struct tasklet;
  975. enum vnic_state state;
  976. enum ibmvnic_reset_reason reset_reason;
  977. spinlock_t rwi_lock;
  978. struct list_head rwi_list;
  979. struct work_struct ibmvnic_reset;
  980. struct delayed_work ibmvnic_delayed_reset;
  981. unsigned long resetting;
  982. bool napi_enabled, from_passive_init;
  983. bool failover_pending;
  984. bool force_reset_recovery;
  985. struct ibmvnic_tunables desired;
  986. struct ibmvnic_tunables fallback;
  987. };