opa_vnic_encap.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. #ifndef _OPA_VNIC_ENCAP_H
  2. #define _OPA_VNIC_ENCAP_H
  3. /*
  4. * Copyright(c) 2017 Intel Corporation.
  5. *
  6. * This file is provided under a dual BSD/GPLv2 license. When using or
  7. * redistributing this file, you may do so under either license.
  8. *
  9. * GPL LICENSE SUMMARY
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * BSD LICENSE
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. *
  26. * - Redistributions of source code must retain the above copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * - Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in
  30. * the documentation and/or other materials provided with the
  31. * distribution.
  32. * - Neither the name of Intel Corporation nor the names of its
  33. * contributors may be used to endorse or promote products derived
  34. * from this software without specific prior written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  37. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  39. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  40. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  43. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  44. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  45. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  46. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. */
  49. /*
  50. * This file contains all OPA VNIC declaration required for encapsulation
  51. * and decapsulation of Ethernet packets
  52. */
  53. #include <linux/types.h>
  54. #include <rdma/ib_mad.h>
  55. /* EMA class version */
  56. #define OPA_EMA_CLASS_VERSION 0x80
  57. /*
  58. * Define the Intel vendor management class for OPA
  59. * ETHERNET MANAGEMENT
  60. */
  61. #define OPA_MGMT_CLASS_INTEL_EMA 0x34
  62. /* EM attribute IDs */
  63. #define OPA_EM_ATTR_CLASS_PORT_INFO 0x0001
  64. #define OPA_EM_ATTR_VESWPORT_INFO 0x0011
  65. #define OPA_EM_ATTR_VESWPORT_MAC_ENTRIES 0x0012
  66. #define OPA_EM_ATTR_IFACE_UCAST_MACS 0x0013
  67. #define OPA_EM_ATTR_IFACE_MCAST_MACS 0x0014
  68. #define OPA_EM_ATTR_DELETE_VESW 0x0015
  69. #define OPA_EM_ATTR_VESWPORT_SUMMARY_COUNTERS 0x0020
  70. #define OPA_EM_ATTR_VESWPORT_ERROR_COUNTERS 0x0022
  71. /* VNIC configured and operational state values */
  72. #define OPA_VNIC_STATE_DROP_ALL 0x1
  73. #define OPA_VNIC_STATE_FORWARDING 0x3
  74. #define OPA_VESW_MAX_NUM_DEF_PORT 16
  75. #define OPA_VNIC_MAX_NUM_PCP 8
  76. #define OPA_VNIC_EMA_DATA (OPA_MGMT_MAD_SIZE - IB_MGMT_VENDOR_HDR)
  77. /* Defines for vendor specific notice(trap) attributes */
  78. #define OPA_INTEL_EMA_NOTICE_TYPE_INFO 0x04
  79. /* INTEL OUI */
  80. #define INTEL_OUI_1 0x00
  81. #define INTEL_OUI_2 0x06
  82. #define INTEL_OUI_3 0x6a
  83. /* Trap opcodes sent from VNIC */
  84. #define OPA_VESWPORT_TRAP_IFACE_UCAST_MAC_CHANGE 0x1
  85. #define OPA_VESWPORT_TRAP_IFACE_MCAST_MAC_CHANGE 0x2
  86. #define OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE 0x3
  87. #define OPA_VNIC_DLID_SD_IS_SRC_MAC(dlid_sd) (!!((dlid_sd) & 0x20))
  88. #define OPA_VNIC_DLID_SD_GET_DLID(dlid_sd) ((dlid_sd) >> 8)
  89. /* VNIC Ethernet link status */
  90. #define OPA_VNIC_ETH_LINK_UP 1
  91. #define OPA_VNIC_ETH_LINK_DOWN 2
  92. /**
  93. * struct opa_vesw_info - OPA vnic switch information
  94. * @fabric_id: 10-bit fabric id
  95. * @vesw_id: 12-bit virtual ethernet switch id
  96. * @def_port_mask: bitmask of default ports
  97. * @pkey: partition key
  98. * @u_mcast_dlid: unknown multicast dlid
  99. * @u_ucast_dlid: array of unknown unicast dlids
  100. * @eth_mtu: MTUs for each vlan PCP
  101. * @eth_mtu_non_vlan: MTU for non vlan packets
  102. */
  103. struct opa_vesw_info {
  104. __be16 fabric_id;
  105. __be16 vesw_id;
  106. u8 rsvd0[6];
  107. __be16 def_port_mask;
  108. u8 rsvd1[2];
  109. __be16 pkey;
  110. u8 rsvd2[4];
  111. __be32 u_mcast_dlid;
  112. __be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
  113. u8 rsvd3[44];
  114. __be16 eth_mtu[OPA_VNIC_MAX_NUM_PCP];
  115. __be16 eth_mtu_non_vlan;
  116. u8 rsvd4[2];
  117. } __packed;
  118. /**
  119. * struct opa_per_veswport_info - OPA vnic per port information
  120. * @port_num: port number
  121. * @eth_link_status: current ethernet link state
  122. * @base_mac_addr: base mac address
  123. * @config_state: configured port state
  124. * @oper_state: operational port state
  125. * @max_mac_tbl_ent: max number of mac table entries
  126. * @max_smac_ent: max smac entries in mac table
  127. * @mac_tbl_digest: mac table digest
  128. * @encap_slid: base slid for the port
  129. * @pcp_to_sc_uc: sc by pcp index for unicast ethernet packets
  130. * @pcp_to_vl_uc: vl by pcp index for unicast ethernet packets
  131. * @pcp_to_sc_mc: sc by pcp index for multicast ethernet packets
  132. * @pcp_to_vl_mc: vl by pcp index for multicast ethernet packets
  133. * @non_vlan_sc_uc: sc for non-vlan unicast ethernet packets
  134. * @non_vlan_vl_uc: vl for non-vlan unicast ethernet packets
  135. * @non_vlan_sc_mc: sc for non-vlan multicast ethernet packets
  136. * @non_vlan_vl_mc: vl for non-vlan multicast ethernet packets
  137. * @uc_macs_gen_count: generation count for unicast macs list
  138. * @mc_macs_gen_count: generation count for multicast macs list
  139. */
  140. struct opa_per_veswport_info {
  141. __be32 port_num;
  142. u8 eth_link_status;
  143. u8 rsvd0[3];
  144. u8 base_mac_addr[ETH_ALEN];
  145. u8 config_state;
  146. u8 oper_state;
  147. __be16 max_mac_tbl_ent;
  148. __be16 max_smac_ent;
  149. __be32 mac_tbl_digest;
  150. u8 rsvd1[4];
  151. __be32 encap_slid;
  152. u8 pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
  153. u8 pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
  154. u8 pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
  155. u8 pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
  156. u8 non_vlan_sc_uc;
  157. u8 non_vlan_vl_uc;
  158. u8 non_vlan_sc_mc;
  159. u8 non_vlan_vl_mc;
  160. u8 rsvd2[48];
  161. __be16 uc_macs_gen_count;
  162. __be16 mc_macs_gen_count;
  163. u8 rsvd3[8];
  164. } __packed;
  165. /**
  166. * struct opa_veswport_info - OPA vnic port information
  167. * @vesw: OPA vnic switch information
  168. * @vport: OPA vnic per port information
  169. *
  170. * On host, each of the virtual ethernet ports belongs
  171. * to a different virtual ethernet switches.
  172. */
  173. struct opa_veswport_info {
  174. struct opa_vesw_info vesw;
  175. struct opa_per_veswport_info vport;
  176. };
  177. /**
  178. * struct opa_veswport_mactable_entry - single entry in the forwarding table
  179. * @mac_addr: MAC address
  180. * @mac_addr_mask: MAC address bit mask
  181. * @dlid_sd: Matching DLID and side data
  182. *
  183. * On the host each virtual ethernet port will have
  184. * a forwarding table. These tables are used to
  185. * map a MAC to a LID and other data. For more
  186. * details see struct opa_veswport_mactable_entries.
  187. * This is the structure of a single mactable entry
  188. */
  189. struct opa_veswport_mactable_entry {
  190. u8 mac_addr[ETH_ALEN];
  191. u8 mac_addr_mask[ETH_ALEN];
  192. __be32 dlid_sd;
  193. } __packed;
  194. /**
  195. * struct opa_veswport_mactable - Forwarding table array
  196. * @offset: mac table starting offset
  197. * @num_entries: Number of entries to get or set
  198. * @mac_tbl_digest: mac table digest
  199. * @tbl_entries[]: Array of table entries
  200. *
  201. * The EM sends down this structure in a MAD indicating
  202. * the starting offset in the forwarding table that this
  203. * entry is to be loaded into and the number of entries
  204. * that that this MAD instance contains
  205. * The mac_tbl_digest has been added to this MAD structure. It will be set by
  206. * the EM and it will be used by the EM to check if there are any
  207. * discrepancies with this value and the value
  208. * maintained by the EM in the case of VNIC port being deleted or unloaded
  209. * A new instantiation of a VNIC will always have a value of zero.
  210. * This value is stored as part of the vnic adapter structure and will be
  211. * accessed by the GET and SET routines for both the mactable entries and the
  212. * veswport info.
  213. */
  214. struct opa_veswport_mactable {
  215. __be16 offset;
  216. __be16 num_entries;
  217. __be32 mac_tbl_digest;
  218. struct opa_veswport_mactable_entry tbl_entries[0];
  219. } __packed;
  220. /**
  221. * struct opa_veswport_summary_counters - summary counters
  222. * @vp_instance: vport instance on the OPA port
  223. * @vesw_id: virtual ethernet switch id
  224. * @veswport_num: virtual ethernet switch port number
  225. * @tx_errors: transmit errors
  226. * @rx_errors: receive errors
  227. * @tx_packets: transmit packets
  228. * @rx_packets: receive packets
  229. * @tx_bytes: transmit bytes
  230. * @rx_bytes: receive bytes
  231. * @tx_unicast: unicast packets transmitted
  232. * @tx_mcastbcast: multicast/broadcast packets transmitted
  233. * @tx_untagged: non-vlan packets transmitted
  234. * @tx_vlan: vlan packets transmitted
  235. * @tx_64_size: transmit packet length is 64 bytes
  236. * @tx_65_127: transmit packet length is >=65 and < 127 bytes
  237. * @tx_128_255: transmit packet length is >=128 and < 255 bytes
  238. * @tx_256_511: transmit packet length is >=256 and < 511 bytes
  239. * @tx_512_1023: transmit packet length is >=512 and < 1023 bytes
  240. * @tx_1024_1518: transmit packet length is >=1024 and < 1518 bytes
  241. * @tx_1519_max: transmit packet length >= 1519 bytes
  242. * @rx_unicast: unicast packets received
  243. * @rx_mcastbcast: multicast/broadcast packets received
  244. * @rx_untagged: non-vlan packets received
  245. * @rx_vlan: vlan packets received
  246. * @rx_64_size: received packet length is 64 bytes
  247. * @rx_65_127: received packet length is >=65 and < 127 bytes
  248. * @rx_128_255: received packet length is >=128 and < 255 bytes
  249. * @rx_256_511: received packet length is >=256 and < 511 bytes
  250. * @rx_512_1023: received packet length is >=512 and < 1023 bytes
  251. * @rx_1024_1518: received packet length is >=1024 and < 1518 bytes
  252. * @rx_1519_max: received packet length >= 1519 bytes
  253. *
  254. * All the above are counters of corresponding conditions.
  255. */
  256. struct opa_veswport_summary_counters {
  257. __be16 vp_instance;
  258. __be16 vesw_id;
  259. __be32 veswport_num;
  260. __be64 tx_errors;
  261. __be64 rx_errors;
  262. __be64 tx_packets;
  263. __be64 rx_packets;
  264. __be64 tx_bytes;
  265. __be64 rx_bytes;
  266. __be64 tx_unicast;
  267. __be64 tx_mcastbcast;
  268. __be64 tx_untagged;
  269. __be64 tx_vlan;
  270. __be64 tx_64_size;
  271. __be64 tx_65_127;
  272. __be64 tx_128_255;
  273. __be64 tx_256_511;
  274. __be64 tx_512_1023;
  275. __be64 tx_1024_1518;
  276. __be64 tx_1519_max;
  277. __be64 rx_unicast;
  278. __be64 rx_mcastbcast;
  279. __be64 rx_untagged;
  280. __be64 rx_vlan;
  281. __be64 rx_64_size;
  282. __be64 rx_65_127;
  283. __be64 rx_128_255;
  284. __be64 rx_256_511;
  285. __be64 rx_512_1023;
  286. __be64 rx_1024_1518;
  287. __be64 rx_1519_max;
  288. __be64 reserved[16];
  289. } __packed;
  290. /**
  291. * struct opa_veswport_error_counters - error counters
  292. * @vp_instance: vport instance on the OPA port
  293. * @vesw_id: virtual ethernet switch id
  294. * @veswport_num: virtual ethernet switch port number
  295. * @tx_errors: transmit errors
  296. * @rx_errors: receive errors
  297. * @tx_smac_filt: smac filter errors
  298. * @tx_dlid_zero: transmit packets with invalid dlid
  299. * @tx_logic: other transmit errors
  300. * @tx_drop_state: packet tansmission in non-forward port state
  301. * @rx_bad_veswid: received packet with invalid vesw id
  302. * @rx_runt: received ethernet packet with length < 64 bytes
  303. * @rx_oversize: received ethernet packet with length > MTU size
  304. * @rx_eth_down: received packets when interface is down
  305. * @rx_drop_state: received packets in non-forwarding port state
  306. * @rx_logic: other receive errors
  307. *
  308. * All the above are counters of corresponding erorr conditions.
  309. */
  310. struct opa_veswport_error_counters {
  311. __be16 vp_instance;
  312. __be16 vesw_id;
  313. __be32 veswport_num;
  314. __be64 tx_errors;
  315. __be64 rx_errors;
  316. __be64 rsvd0;
  317. __be64 tx_smac_filt;
  318. __be64 rsvd1;
  319. __be64 rsvd2;
  320. __be64 rsvd3;
  321. __be64 tx_dlid_zero;
  322. __be64 rsvd4;
  323. __be64 tx_logic;
  324. __be64 rsvd5;
  325. __be64 tx_drop_state;
  326. __be64 rx_bad_veswid;
  327. __be64 rsvd6;
  328. __be64 rx_runt;
  329. __be64 rx_oversize;
  330. __be64 rsvd7;
  331. __be64 rx_eth_down;
  332. __be64 rx_drop_state;
  333. __be64 rx_logic;
  334. __be64 rsvd8;
  335. __be64 rsvd9[16];
  336. } __packed;
  337. /**
  338. * struct opa_veswport_trap - Trap message sent to EM by VNIC
  339. * @fabric_id: 10 bit fabric id
  340. * @veswid: 12 bit virtual ethernet switch id
  341. * @veswportnum: logical port number on the Virtual switch
  342. * @opaportnum: physical port num (redundant on host)
  343. * @veswportindex: switch port index on opa port 0 based
  344. * @opcode: operation
  345. * @reserved: 32 bit for alignment
  346. *
  347. * The VNIC will send trap messages to the Ethernet manager to
  348. * inform it about changes to the VNIC config, behaviour etc.
  349. * This is the format of the trap payload.
  350. */
  351. struct opa_veswport_trap {
  352. __be16 fabric_id;
  353. __be16 veswid;
  354. __be32 veswportnum;
  355. __be16 opaportnum;
  356. u8 veswportindex;
  357. u8 opcode;
  358. __be32 reserved;
  359. } __packed;
  360. /**
  361. * struct opa_vnic_iface_macs_entry - single entry in the mac list
  362. * @mac_addr: MAC address
  363. */
  364. struct opa_vnic_iface_mac_entry {
  365. u8 mac_addr[ETH_ALEN];
  366. };
  367. /**
  368. * struct opa_veswport_iface_macs - Msg to set globally administered MAC
  369. * @start_idx: position of first entry (0 based)
  370. * @num_macs_in_msg: number of MACs in this message
  371. * @tot_macs_in_lst: The total number of MACs the agent has
  372. * @gen_count: gen_count to indicate change
  373. * @entry: The mac list entry
  374. *
  375. * Same attribute IDS and attribute modifiers as in locally administered
  376. * addresses used to set globally administered addresses
  377. */
  378. struct opa_veswport_iface_macs {
  379. __be16 start_idx;
  380. __be16 num_macs_in_msg;
  381. __be16 tot_macs_in_lst;
  382. __be16 gen_count;
  383. struct opa_vnic_iface_mac_entry entry[0];
  384. } __packed;
  385. /**
  386. * struct opa_vnic_vema_mad - Generic VEMA MAD
  387. * @mad_hdr: Generic MAD header
  388. * @rmpp_hdr: RMPP header for vendor specific MADs
  389. * @oui: Unique org identifier
  390. * @data: MAD data
  391. */
  392. struct opa_vnic_vema_mad {
  393. struct ib_mad_hdr mad_hdr;
  394. struct ib_rmpp_hdr rmpp_hdr;
  395. u8 reserved;
  396. u8 oui[3];
  397. u8 data[OPA_VNIC_EMA_DATA];
  398. };
  399. /**
  400. * struct opa_vnic_notice_attr - Generic Notice MAD
  401. * @gen_type: Generic/Specific bit and type of notice
  402. * @oui_1: Vendor ID byte 1
  403. * @oui_2: Vendor ID byte 2
  404. * @oui_3: Vendor ID byte 3
  405. * @trap_num: Trap number
  406. * @toggle_count: Notice toggle bit and count value
  407. * @issuer_lid: Trap issuer's lid
  408. * @issuer_gid: Issuer GID (only if Report method)
  409. * @raw_data: Trap message body
  410. */
  411. struct opa_vnic_notice_attr {
  412. u8 gen_type;
  413. u8 oui_1;
  414. u8 oui_2;
  415. u8 oui_3;
  416. __be16 trap_num;
  417. __be16 toggle_count;
  418. __be32 issuer_lid;
  419. __be32 reserved;
  420. u8 issuer_gid[16];
  421. u8 raw_data[64];
  422. } __packed;
  423. /**
  424. * struct opa_vnic_vema_mad_trap - Generic VEMA MAD Trap
  425. * @mad_hdr: Generic MAD header
  426. * @rmpp_hdr: RMPP header for vendor specific MADs
  427. * @oui: Unique org identifier
  428. * @notice: Notice structure
  429. */
  430. struct opa_vnic_vema_mad_trap {
  431. struct ib_mad_hdr mad_hdr;
  432. struct ib_rmpp_hdr rmpp_hdr;
  433. u8 reserved;
  434. u8 oui[3];
  435. struct opa_vnic_notice_attr notice;
  436. };
  437. #endif /* _OPA_VNIC_ENCAP_H */