proc: Fix proc_sys_prune_dcache to hold a sb reference
[cris-mirror.git] / drivers / infiniband / ulp / opa_vnic / opa_vnic_encap.h
blob4c434b9dd84c904e875c45520b8c280e523e594f
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
107 * struct opa_vesw_info - OPA vnic switch information
108 * @fabric_id: 10-bit fabric id
109 * @vesw_id: 12-bit virtual ethernet switch id
110 * @def_port_mask: bitmask of default ports
111 * @pkey: partition key
112 * @u_mcast_dlid: unknown multicast dlid
113 * @u_ucast_dlid: array of unknown unicast dlids
114 * @eth_mtu: MTUs for each vlan PCP
115 * @eth_mtu_non_vlan: MTU for non vlan packets
117 struct opa_vesw_info {
118 __be16 fabric_id;
119 __be16 vesw_id;
121 u8 rsvd0[6];
122 __be16 def_port_mask;
124 u8 rsvd1[2];
125 __be16 pkey;
127 u8 rsvd2[4];
128 __be32 u_mcast_dlid;
129 __be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
131 u8 rsvd3[44];
132 __be16 eth_mtu[OPA_VNIC_MAX_NUM_PCP];
133 __be16 eth_mtu_non_vlan;
134 u8 rsvd4[2];
135 } __packed;
138 * struct opa_per_veswport_info - OPA vnic per port information
139 * @port_num: port number
140 * @eth_link_status: current ethernet link state
141 * @base_mac_addr: base mac address
142 * @config_state: configured port state
143 * @oper_state: operational port state
144 * @max_mac_tbl_ent: max number of mac table entries
145 * @max_smac_ent: max smac entries in mac table
146 * @mac_tbl_digest: mac table digest
147 * @encap_slid: base slid for the port
148 * @pcp_to_sc_uc: sc by pcp index for unicast ethernet packets
149 * @pcp_to_vl_uc: vl by pcp index for unicast ethernet packets
150 * @pcp_to_sc_mc: sc by pcp index for multicast ethernet packets
151 * @pcp_to_vl_mc: vl by pcp index for multicast ethernet packets
152 * @non_vlan_sc_uc: sc for non-vlan unicast ethernet packets
153 * @non_vlan_vl_uc: vl for non-vlan unicast ethernet packets
154 * @non_vlan_sc_mc: sc for non-vlan multicast ethernet packets
155 * @non_vlan_vl_mc: vl for non-vlan multicast ethernet packets
156 * @uc_macs_gen_count: generation count for unicast macs list
157 * @mc_macs_gen_count: generation count for multicast macs list
159 struct opa_per_veswport_info {
160 __be32 port_num;
162 u8 eth_link_status;
163 u8 rsvd0[3];
165 u8 base_mac_addr[ETH_ALEN];
166 u8 config_state;
167 u8 oper_state;
169 __be16 max_mac_tbl_ent;
170 __be16 max_smac_ent;
171 __be32 mac_tbl_digest;
172 u8 rsvd1[4];
174 __be32 encap_slid;
176 u8 pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
177 u8 pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
178 u8 pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
179 u8 pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
181 u8 non_vlan_sc_uc;
182 u8 non_vlan_vl_uc;
183 u8 non_vlan_sc_mc;
184 u8 non_vlan_vl_mc;
186 u8 rsvd2[48];
188 __be16 uc_macs_gen_count;
189 __be16 mc_macs_gen_count;
191 u8 rsvd3[8];
192 } __packed;
195 * struct opa_veswport_info - OPA vnic port information
196 * @vesw: OPA vnic switch information
197 * @vport: OPA vnic per port information
199 * On host, each of the virtual ethernet ports belongs
200 * to a different virtual ethernet switches.
202 struct opa_veswport_info {
203 struct opa_vesw_info vesw;
204 struct opa_per_veswport_info vport;
208 * struct opa_veswport_mactable_entry - single entry in the forwarding table
209 * @mac_addr: MAC address
210 * @mac_addr_mask: MAC address bit mask
211 * @dlid_sd: Matching DLID and side data
213 * On the host each virtual ethernet port will have
214 * a forwarding table. These tables are used to
215 * map a MAC to a LID and other data. For more
216 * details see struct opa_veswport_mactable_entries.
217 * This is the structure of a single mactable entry
219 struct opa_veswport_mactable_entry {
220 u8 mac_addr[ETH_ALEN];
221 u8 mac_addr_mask[ETH_ALEN];
222 __be32 dlid_sd;
223 } __packed;
226 * struct opa_veswport_mactable - Forwarding table array
227 * @offset: mac table starting offset
228 * @num_entries: Number of entries to get or set
229 * @mac_tbl_digest: mac table digest
230 * @tbl_entries[]: Array of table entries
232 * The EM sends down this structure in a MAD indicating
233 * the starting offset in the forwarding table that this
234 * entry is to be loaded into and the number of entries
235 * that that this MAD instance contains
236 * The mac_tbl_digest has been added to this MAD structure. It will be set by
237 * the EM and it will be used by the EM to check if there are any
238 * discrepancies with this value and the value
239 * maintained by the EM in the case of VNIC port being deleted or unloaded
240 * A new instantiation of a VNIC will always have a value of zero.
241 * This value is stored as part of the vnic adapter structure and will be
242 * accessed by the GET and SET routines for both the mactable entries and the
243 * veswport info.
245 struct opa_veswport_mactable {
246 __be16 offset;
247 __be16 num_entries;
248 __be32 mac_tbl_digest;
249 struct opa_veswport_mactable_entry tbl_entries[0];
250 } __packed;
253 * struct opa_veswport_summary_counters - summary counters
254 * @vp_instance: vport instance on the OPA port
255 * @vesw_id: virtual ethernet switch id
256 * @veswport_num: virtual ethernet switch port number
257 * @tx_errors: transmit errors
258 * @rx_errors: receive errors
259 * @tx_packets: transmit packets
260 * @rx_packets: receive packets
261 * @tx_bytes: transmit bytes
262 * @rx_bytes: receive bytes
263 * @tx_unicast: unicast packets transmitted
264 * @tx_mcastbcast: multicast/broadcast packets transmitted
265 * @tx_untagged: non-vlan packets transmitted
266 * @tx_vlan: vlan packets transmitted
267 * @tx_64_size: transmit packet length is 64 bytes
268 * @tx_65_127: transmit packet length is >=65 and < 127 bytes
269 * @tx_128_255: transmit packet length is >=128 and < 255 bytes
270 * @tx_256_511: transmit packet length is >=256 and < 511 bytes
271 * @tx_512_1023: transmit packet length is >=512 and < 1023 bytes
272 * @tx_1024_1518: transmit packet length is >=1024 and < 1518 bytes
273 * @tx_1519_max: transmit packet length >= 1519 bytes
274 * @rx_unicast: unicast packets received
275 * @rx_mcastbcast: multicast/broadcast packets received
276 * @rx_untagged: non-vlan packets received
277 * @rx_vlan: vlan packets received
278 * @rx_64_size: received packet length is 64 bytes
279 * @rx_65_127: received packet length is >=65 and < 127 bytes
280 * @rx_128_255: received packet length is >=128 and < 255 bytes
281 * @rx_256_511: received packet length is >=256 and < 511 bytes
282 * @rx_512_1023: received packet length is >=512 and < 1023 bytes
283 * @rx_1024_1518: received packet length is >=1024 and < 1518 bytes
284 * @rx_1519_max: received packet length >= 1519 bytes
286 * All the above are counters of corresponding conditions.
288 struct opa_veswport_summary_counters {
289 __be16 vp_instance;
290 __be16 vesw_id;
291 __be32 veswport_num;
293 __be64 tx_errors;
294 __be64 rx_errors;
295 __be64 tx_packets;
296 __be64 rx_packets;
297 __be64 tx_bytes;
298 __be64 rx_bytes;
300 __be64 tx_unicast;
301 __be64 tx_mcastbcast;
303 __be64 tx_untagged;
304 __be64 tx_vlan;
306 __be64 tx_64_size;
307 __be64 tx_65_127;
308 __be64 tx_128_255;
309 __be64 tx_256_511;
310 __be64 tx_512_1023;
311 __be64 tx_1024_1518;
312 __be64 tx_1519_max;
314 __be64 rx_unicast;
315 __be64 rx_mcastbcast;
317 __be64 rx_untagged;
318 __be64 rx_vlan;
320 __be64 rx_64_size;
321 __be64 rx_65_127;
322 __be64 rx_128_255;
323 __be64 rx_256_511;
324 __be64 rx_512_1023;
325 __be64 rx_1024_1518;
326 __be64 rx_1519_max;
328 __be64 reserved[16];
329 } __packed;
332 * struct opa_veswport_error_counters - error counters
333 * @vp_instance: vport instance on the OPA port
334 * @vesw_id: virtual ethernet switch id
335 * @veswport_num: virtual ethernet switch port number
336 * @tx_errors: transmit errors
337 * @rx_errors: receive errors
338 * @tx_smac_filt: smac filter errors
339 * @tx_dlid_zero: transmit packets with invalid dlid
340 * @tx_logic: other transmit errors
341 * @tx_drop_state: packet tansmission in non-forward port state
342 * @rx_bad_veswid: received packet with invalid vesw id
343 * @rx_runt: received ethernet packet with length < 64 bytes
344 * @rx_oversize: received ethernet packet with length > MTU size
345 * @rx_eth_down: received packets when interface is down
346 * @rx_drop_state: received packets in non-forwarding port state
347 * @rx_logic: other receive errors
349 * All the above are counters of corresponding erorr conditions.
351 struct opa_veswport_error_counters {
352 __be16 vp_instance;
353 __be16 vesw_id;
354 __be32 veswport_num;
356 __be64 tx_errors;
357 __be64 rx_errors;
359 __be64 rsvd0;
360 __be64 tx_smac_filt;
361 __be64 rsvd1;
362 __be64 rsvd2;
363 __be64 rsvd3;
364 __be64 tx_dlid_zero;
365 __be64 rsvd4;
366 __be64 tx_logic;
367 __be64 rsvd5;
368 __be64 tx_drop_state;
370 __be64 rx_bad_veswid;
371 __be64 rsvd6;
372 __be64 rx_runt;
373 __be64 rx_oversize;
374 __be64 rsvd7;
375 __be64 rx_eth_down;
376 __be64 rx_drop_state;
377 __be64 rx_logic;
378 __be64 rsvd8;
380 __be64 rsvd9[16];
381 } __packed;
384 * struct opa_veswport_trap - Trap message sent to EM by VNIC
385 * @fabric_id: 10 bit fabric id
386 * @veswid: 12 bit virtual ethernet switch id
387 * @veswportnum: logical port number on the Virtual switch
388 * @opaportnum: physical port num (redundant on host)
389 * @veswportindex: switch port index on opa port 0 based
390 * @opcode: operation
391 * @reserved: 32 bit for alignment
393 * The VNIC will send trap messages to the Ethernet manager to
394 * inform it about changes to the VNIC config, behaviour etc.
395 * This is the format of the trap payload.
397 struct opa_veswport_trap {
398 __be16 fabric_id;
399 __be16 veswid;
400 __be32 veswportnum;
401 __be16 opaportnum;
402 u8 veswportindex;
403 u8 opcode;
404 __be32 reserved;
405 } __packed;
408 * struct opa_vnic_iface_macs_entry - single entry in the mac list
409 * @mac_addr: MAC address
411 struct opa_vnic_iface_mac_entry {
412 u8 mac_addr[ETH_ALEN];
416 * struct opa_veswport_iface_macs - Msg to set globally administered MAC
417 * @start_idx: position of first entry (0 based)
418 * @num_macs_in_msg: number of MACs in this message
419 * @tot_macs_in_lst: The total number of MACs the agent has
420 * @gen_count: gen_count to indicate change
421 * @entry: The mac list entry
423 * Same attribute IDS and attribute modifiers as in locally administered
424 * addresses used to set globally administered addresses
426 struct opa_veswport_iface_macs {
427 __be16 start_idx;
428 __be16 num_macs_in_msg;
429 __be16 tot_macs_in_lst;
430 __be16 gen_count;
431 struct opa_vnic_iface_mac_entry entry[0];
432 } __packed;
435 * struct opa_vnic_vema_mad - Generic VEMA MAD
436 * @mad_hdr: Generic MAD header
437 * @rmpp_hdr: RMPP header for vendor specific MADs
438 * @oui: Unique org identifier
439 * @data: MAD data
441 struct opa_vnic_vema_mad {
442 struct ib_mad_hdr mad_hdr;
443 struct ib_rmpp_hdr rmpp_hdr;
444 u8 reserved;
445 u8 oui[3];
446 u8 data[OPA_VNIC_EMA_DATA];
450 * struct opa_vnic_notice_attr - Generic Notice MAD
451 * @gen_type: Generic/Specific bit and type of notice
452 * @oui_1: Vendor ID byte 1
453 * @oui_2: Vendor ID byte 2
454 * @oui_3: Vendor ID byte 3
455 * @trap_num: Trap number
456 * @toggle_count: Notice toggle bit and count value
457 * @issuer_lid: Trap issuer's lid
458 * @issuer_gid: Issuer GID (only if Report method)
459 * @raw_data: Trap message body
461 struct opa_vnic_notice_attr {
462 u8 gen_type;
463 u8 oui_1;
464 u8 oui_2;
465 u8 oui_3;
466 __be16 trap_num;
467 __be16 toggle_count;
468 __be32 issuer_lid;
469 __be32 reserved;
470 u8 issuer_gid[16];
471 u8 raw_data[64];
472 } __packed;
475 * struct opa_vnic_vema_mad_trap - Generic VEMA MAD Trap
476 * @mad_hdr: Generic MAD header
477 * @rmpp_hdr: RMPP header for vendor specific MADs
478 * @oui: Unique org identifier
479 * @notice: Notice structure
481 struct opa_vnic_vema_mad_trap {
482 struct ib_mad_hdr mad_hdr;
483 struct ib_rmpp_hdr rmpp_hdr;
484 u8 reserved;
485 u8 oui[3];
486 struct opa_vnic_notice_attr notice;
489 #endif /* _OPA_VNIC_ENCAP_H */