drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / drivers / infiniband / ulp / opa_vnic / opa_vnic_encap.h
blob012fc27c5c93b2f31085100579dd6c3cd08f02be
1 #ifndef _OPA_VNIC_ENCAP_H
2 #define _OPA_VNIC_ENCAP_H
3 /*
4 * Copyright(c) 2017 Intel Corporation.
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.
9 * GPL LICENSE SUMMARY
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.
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.
20 * BSD LICENSE
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
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.
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.
51 * This file contains all OPA VNIC declaration required for encapsulation
52 * and decapsulation of Ethernet packets
55 #include <linux/types.h>
56 #include <rdma/ib_mad.h>
58 /* EMA class version */
59 #define OPA_EMA_CLASS_VERSION 0x80
62 * Define the Intel vendor management class for OPA
63 * ETHERNET MANAGEMENT
65 #define OPA_MGMT_CLASS_INTEL_EMA 0x34
67 /* EM attribute IDs */
68 #define OPA_EM_ATTR_CLASS_PORT_INFO 0x0001
69 #define OPA_EM_ATTR_VESWPORT_INFO 0x0011
70 #define OPA_EM_ATTR_VESWPORT_MAC_ENTRIES 0x0012
71 #define OPA_EM_ATTR_IFACE_UCAST_MACS 0x0013
72 #define OPA_EM_ATTR_IFACE_MCAST_MACS 0x0014
73 #define OPA_EM_ATTR_DELETE_VESW 0x0015
74 #define OPA_EM_ATTR_VESWPORT_SUMMARY_COUNTERS 0x0020
75 #define OPA_EM_ATTR_VESWPORT_ERROR_COUNTERS 0x0022
77 /* VNIC configured and operational state values */
78 #define OPA_VNIC_STATE_DROP_ALL 0x1
79 #define OPA_VNIC_STATE_FORWARDING 0x3
81 #define OPA_VESW_MAX_NUM_DEF_PORT 16
82 #define OPA_VNIC_MAX_NUM_PCP 8
84 #define OPA_VNIC_EMA_DATA (OPA_MGMT_MAD_SIZE - IB_MGMT_VENDOR_HDR)
86 /* Defines for vendor specific notice(trap) attributes */
87 #define OPA_INTEL_EMA_NOTICE_TYPE_INFO 0x04
89 /* INTEL OUI */
90 #define INTEL_OUI_1 0x00
91 #define INTEL_OUI_2 0x06
92 #define INTEL_OUI_3 0x6a
94 /* Trap opcodes sent from VNIC */
95 #define OPA_VESWPORT_TRAP_IFACE_UCAST_MAC_CHANGE 0x1
96 #define OPA_VESWPORT_TRAP_IFACE_MCAST_MAC_CHANGE 0x2
97 #define OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE 0x3
99 #define OPA_VNIC_DLID_SD_IS_SRC_MAC(dlid_sd) (!!((dlid_sd) & 0x20))
100 #define OPA_VNIC_DLID_SD_GET_DLID(dlid_sd) ((dlid_sd) >> 8)
102 /* VNIC Ethernet link status */
103 #define OPA_VNIC_ETH_LINK_UP 1
104 #define OPA_VNIC_ETH_LINK_DOWN 2
106 /* routing control */
107 #define OPA_VNIC_ENCAP_RC_DEFAULT 0
108 #define OPA_VNIC_ENCAP_RC_IPV4 4
109 #define OPA_VNIC_ENCAP_RC_IPV4_UDP 8
110 #define OPA_VNIC_ENCAP_RC_IPV4_TCP 12
111 #define OPA_VNIC_ENCAP_RC_IPV6 16
112 #define OPA_VNIC_ENCAP_RC_IPV6_TCP 20
113 #define OPA_VNIC_ENCAP_RC_IPV6_UDP 24
115 #define OPA_VNIC_ENCAP_RC_EXT(w, b) (((w) >> OPA_VNIC_ENCAP_RC_ ## b) & 0x7)
118 * struct opa_vesw_info - OPA vnic switch information
119 * @fabric_id: 10-bit fabric id
120 * @vesw_id: 12-bit virtual ethernet switch id
121 * @rsvd0: reserved bytes
122 * @def_port_mask: bitmask of default ports
123 * @rsvd1: reserved bytes
124 * @pkey: partition key
125 * @rsvd2: reserved bytes
126 * @u_mcast_dlid: unknown multicast dlid
127 * @u_ucast_dlid: array of unknown unicast dlids
128 * @rsvd3: reserved bytes
129 * @rc: routing control
130 * @eth_mtu: Ethernet MTU
131 * @rsvd4: reserved bytes
133 struct opa_vesw_info {
134 __be16 fabric_id;
135 __be16 vesw_id;
137 u8 rsvd0[6];
138 __be16 def_port_mask;
140 u8 rsvd1[2];
141 __be16 pkey;
143 u8 rsvd2[4];
144 __be32 u_mcast_dlid;
145 __be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
147 __be32 rc;
149 u8 rsvd3[56];
150 __be16 eth_mtu;
151 u8 rsvd4[2];
152 } __packed;
155 * struct opa_per_veswport_info - OPA vnic per port information
156 * @port_num: port number
157 * @eth_link_status: current ethernet link state
158 * @rsvd0: reserved bytes
159 * @base_mac_addr: base mac address
160 * @config_state: configured port state
161 * @oper_state: operational port state
162 * @max_mac_tbl_ent: max number of mac table entries
163 * @max_smac_ent: max smac entries in mac table
164 * @mac_tbl_digest: mac table digest
165 * @rsvd1: reserved bytes
166 * @encap_slid: base slid for the port
167 * @pcp_to_sc_uc: sc by pcp index for unicast ethernet packets
168 * @pcp_to_vl_uc: vl by pcp index for unicast ethernet packets
169 * @pcp_to_sc_mc: sc by pcp index for multicast ethernet packets
170 * @pcp_to_vl_mc: vl by pcp index for multicast ethernet packets
171 * @non_vlan_sc_uc: sc for non-vlan unicast ethernet packets
172 * @non_vlan_vl_uc: vl for non-vlan unicast ethernet packets
173 * @non_vlan_sc_mc: sc for non-vlan multicast ethernet packets
174 * @non_vlan_vl_mc: vl for non-vlan multicast ethernet packets
175 * @rsvd2: reserved bytes
176 * @uc_macs_gen_count: generation count for unicast macs list
177 * @mc_macs_gen_count: generation count for multicast macs list
178 * @rsvd3: reserved bytes
180 struct opa_per_veswport_info {
181 __be32 port_num;
183 u8 eth_link_status;
184 u8 rsvd0[3];
186 u8 base_mac_addr[ETH_ALEN];
187 u8 config_state;
188 u8 oper_state;
190 __be16 max_mac_tbl_ent;
191 __be16 max_smac_ent;
192 __be32 mac_tbl_digest;
193 u8 rsvd1[4];
195 __be32 encap_slid;
197 u8 pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
198 u8 pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
199 u8 pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
200 u8 pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
202 u8 non_vlan_sc_uc;
203 u8 non_vlan_vl_uc;
204 u8 non_vlan_sc_mc;
205 u8 non_vlan_vl_mc;
207 u8 rsvd2[48];
209 __be16 uc_macs_gen_count;
210 __be16 mc_macs_gen_count;
212 u8 rsvd3[8];
213 } __packed;
216 * struct opa_veswport_info - OPA vnic port information
217 * @vesw: OPA vnic switch information
218 * @vport: OPA vnic per port information
220 * On host, each of the virtual ethernet ports belongs
221 * to a different virtual ethernet switches.
223 struct opa_veswport_info {
224 struct opa_vesw_info vesw;
225 struct opa_per_veswport_info vport;
229 * struct opa_veswport_mactable_entry - single entry in the forwarding table
230 * @mac_addr: MAC address
231 * @mac_addr_mask: MAC address bit mask
232 * @dlid_sd: Matching DLID and side data
234 * On the host each virtual ethernet port will have
235 * a forwarding table. These tables are used to
236 * map a MAC to a LID and other data. For more
237 * details see struct opa_veswport_mactable_entries.
238 * This is the structure of a single mactable entry
240 struct opa_veswport_mactable_entry {
241 u8 mac_addr[ETH_ALEN];
242 u8 mac_addr_mask[ETH_ALEN];
243 __be32 dlid_sd;
244 } __packed;
247 * struct opa_veswport_mactable - Forwarding table array
248 * @offset: mac table starting offset
249 * @num_entries: Number of entries to get or set
250 * @mac_tbl_digest: mac table digest
251 * @tbl_entries: Array of table entries
253 * The EM sends down this structure in a MAD indicating
254 * the starting offset in the forwarding table that this
255 * entry is to be loaded into and the number of entries
256 * that that this MAD instance contains
257 * The mac_tbl_digest has been added to this MAD structure. It will be set by
258 * the EM and it will be used by the EM to check if there are any
259 * discrepancies with this value and the value
260 * maintained by the EM in the case of VNIC port being deleted or unloaded
261 * A new instantiation of a VNIC will always have a value of zero.
262 * This value is stored as part of the vnic adapter structure and will be
263 * accessed by the GET and SET routines for both the mactable entries and the
264 * veswport info.
266 struct opa_veswport_mactable {
267 __be16 offset;
268 __be16 num_entries;
269 __be32 mac_tbl_digest;
270 struct opa_veswport_mactable_entry tbl_entries[];
271 } __packed;
274 * struct opa_veswport_summary_counters - summary counters
275 * @vp_instance: vport instance on the OPA port
276 * @vesw_id: virtual ethernet switch id
277 * @veswport_num: virtual ethernet switch port number
278 * @tx_errors: transmit errors
279 * @rx_errors: receive errors
280 * @tx_packets: transmit packets
281 * @rx_packets: receive packets
282 * @tx_bytes: transmit bytes
283 * @rx_bytes: receive bytes
284 * @tx_unicast: unicast packets transmitted
285 * @tx_mcastbcast: multicast/broadcast packets transmitted
286 * @tx_untagged: non-vlan packets transmitted
287 * @tx_vlan: vlan packets transmitted
288 * @tx_64_size: transmit packet length is 64 bytes
289 * @tx_65_127: transmit packet length is >=65 and < 127 bytes
290 * @tx_128_255: transmit packet length is >=128 and < 255 bytes
291 * @tx_256_511: transmit packet length is >=256 and < 511 bytes
292 * @tx_512_1023: transmit packet length is >=512 and < 1023 bytes
293 * @tx_1024_1518: transmit packet length is >=1024 and < 1518 bytes
294 * @tx_1519_max: transmit packet length >= 1519 bytes
295 * @rx_unicast: unicast packets received
296 * @rx_mcastbcast: multicast/broadcast packets received
297 * @rx_untagged: non-vlan packets received
298 * @rx_vlan: vlan packets received
299 * @rx_64_size: received packet length is 64 bytes
300 * @rx_65_127: received packet length is >=65 and < 127 bytes
301 * @rx_128_255: received packet length is >=128 and < 255 bytes
302 * @rx_256_511: received packet length is >=256 and < 511 bytes
303 * @rx_512_1023: received packet length is >=512 and < 1023 bytes
304 * @rx_1024_1518: received packet length is >=1024 and < 1518 bytes
305 * @rx_1519_max: received packet length >= 1519 bytes
306 * @reserved: reserved bytes
308 * All the above are counters of corresponding conditions.
310 struct opa_veswport_summary_counters {
311 __be16 vp_instance;
312 __be16 vesw_id;
313 __be32 veswport_num;
315 __be64 tx_errors;
316 __be64 rx_errors;
317 __be64 tx_packets;
318 __be64 rx_packets;
319 __be64 tx_bytes;
320 __be64 rx_bytes;
322 __be64 tx_unicast;
323 __be64 tx_mcastbcast;
325 __be64 tx_untagged;
326 __be64 tx_vlan;
328 __be64 tx_64_size;
329 __be64 tx_65_127;
330 __be64 tx_128_255;
331 __be64 tx_256_511;
332 __be64 tx_512_1023;
333 __be64 tx_1024_1518;
334 __be64 tx_1519_max;
336 __be64 rx_unicast;
337 __be64 rx_mcastbcast;
339 __be64 rx_untagged;
340 __be64 rx_vlan;
342 __be64 rx_64_size;
343 __be64 rx_65_127;
344 __be64 rx_128_255;
345 __be64 rx_256_511;
346 __be64 rx_512_1023;
347 __be64 rx_1024_1518;
348 __be64 rx_1519_max;
350 __be64 reserved[16];
351 } __packed;
354 * struct opa_veswport_error_counters - error counters
355 * @vp_instance: vport instance on the OPA port
356 * @vesw_id: virtual ethernet switch id
357 * @veswport_num: virtual ethernet switch port number
358 * @tx_errors: transmit errors
359 * @rx_errors: receive errors
360 * @rsvd0: reserved bytes
361 * @tx_smac_filt: smac filter errors
362 * @rsvd1: reserved bytes
363 * @rsvd2: reserved bytes
364 * @rsvd3: reserved bytes
365 * @tx_dlid_zero: transmit packets with invalid dlid
366 * @rsvd4: reserved bytes
367 * @tx_logic: other transmit errors
368 * @rsvd5: reserved bytes
369 * @tx_drop_state: packet tansmission in non-forward port state
370 * @rx_bad_veswid: received packet with invalid vesw id
371 * @rsvd6: reserved bytes
372 * @rx_runt: received ethernet packet with length < 64 bytes
373 * @rx_oversize: received ethernet packet with length > MTU size
374 * @rsvd7: reserved bytes
375 * @rx_eth_down: received packets when interface is down
376 * @rx_drop_state: received packets in non-forwarding port state
377 * @rx_logic: other receive errors
378 * @rsvd8: reserved bytes
379 * @rsvd9: reserved bytes
381 * All the above are counters of corresponding error conditions.
383 struct opa_veswport_error_counters {
384 __be16 vp_instance;
385 __be16 vesw_id;
386 __be32 veswport_num;
388 __be64 tx_errors;
389 __be64 rx_errors;
391 __be64 rsvd0;
392 __be64 tx_smac_filt;
393 __be64 rsvd1;
394 __be64 rsvd2;
395 __be64 rsvd3;
396 __be64 tx_dlid_zero;
397 __be64 rsvd4;
398 __be64 tx_logic;
399 __be64 rsvd5;
400 __be64 tx_drop_state;
402 __be64 rx_bad_veswid;
403 __be64 rsvd6;
404 __be64 rx_runt;
405 __be64 rx_oversize;
406 __be64 rsvd7;
407 __be64 rx_eth_down;
408 __be64 rx_drop_state;
409 __be64 rx_logic;
410 __be64 rsvd8;
412 __be64 rsvd9[16];
413 } __packed;
416 * struct opa_veswport_trap - Trap message sent to EM by VNIC
417 * @fabric_id: 10 bit fabric id
418 * @veswid: 12 bit virtual ethernet switch id
419 * @veswportnum: logical port number on the Virtual switch
420 * @opaportnum: physical port num (redundant on host)
421 * @veswportindex: switch port index on opa port 0 based
422 * @opcode: operation
423 * @reserved: 32 bit for alignment
425 * The VNIC will send trap messages to the Ethernet manager to
426 * inform it about changes to the VNIC config, behaviour etc.
427 * This is the format of the trap payload.
429 struct opa_veswport_trap {
430 __be16 fabric_id;
431 __be16 veswid;
432 __be32 veswportnum;
433 __be16 opaportnum;
434 u8 veswportindex;
435 u8 opcode;
436 __be32 reserved;
437 } __packed;
440 * struct opa_vnic_iface_mac_entry - single entry in the mac list
441 * @mac_addr: MAC address
443 struct opa_vnic_iface_mac_entry {
444 u8 mac_addr[ETH_ALEN];
448 * struct opa_veswport_iface_macs - Msg to set globally administered MAC
449 * @start_idx: position of first entry (0 based)
450 * @num_macs_in_msg: number of MACs in this message
451 * @tot_macs_in_lst: The total number of MACs the agent has
452 * @gen_count: gen_count to indicate change
453 * @entry: The mac list entry
455 * Same attribute IDS and attribute modifiers as in locally administered
456 * addresses used to set globally administered addresses
458 struct opa_veswport_iface_macs {
459 __be16 start_idx;
460 __be16 num_macs_in_msg;
461 __be16 tot_macs_in_lst;
462 __be16 gen_count;
463 struct opa_vnic_iface_mac_entry entry[];
464 } __packed;
467 * struct opa_vnic_vema_mad - Generic VEMA MAD
468 * @mad_hdr: Generic MAD header
469 * @rmpp_hdr: RMPP header for vendor specific MADs
470 * @reserved: reserved bytes
471 * @oui: Unique org identifier
472 * @data: MAD data
474 struct opa_vnic_vema_mad {
475 struct ib_mad_hdr mad_hdr;
476 struct ib_rmpp_hdr rmpp_hdr;
477 u8 reserved;
478 u8 oui[3];
479 u8 data[OPA_VNIC_EMA_DATA];
483 * struct opa_vnic_notice_attr - Generic Notice MAD
484 * @gen_type: Generic/Specific bit and type of notice
485 * @oui_1: Vendor ID byte 1
486 * @oui_2: Vendor ID byte 2
487 * @oui_3: Vendor ID byte 3
488 * @trap_num: Trap number
489 * @toggle_count: Notice toggle bit and count value
490 * @issuer_lid: Trap issuer's lid
491 * @reserved: reserved bytes
492 * @issuer_gid: Issuer GID (only if Report method)
493 * @raw_data: Trap message body
495 struct opa_vnic_notice_attr {
496 u8 gen_type;
497 u8 oui_1;
498 u8 oui_2;
499 u8 oui_3;
500 __be16 trap_num;
501 __be16 toggle_count;
502 __be32 issuer_lid;
503 __be32 reserved;
504 u8 issuer_gid[16];
505 u8 raw_data[64];
506 } __packed;
509 * struct opa_vnic_vema_mad_trap - Generic VEMA MAD Trap
510 * @mad_hdr: Generic MAD header
511 * @rmpp_hdr: RMPP header for vendor specific MADs
512 * @reserved: reserved bytes
513 * @oui: Unique org identifier
514 * @notice: Notice structure
516 struct opa_vnic_vema_mad_trap {
517 struct ib_mad_hdr mad_hdr;
518 struct ib_rmpp_hdr rmpp_hdr;
519 u8 reserved;
520 u8 oui[3];
521 struct opa_vnic_notice_attr notice;
524 #endif /* _OPA_VNIC_ENCAP_H */