525 lines · c
1#ifndef _OPA_VNIC_ENCAP_H2#define _OPA_VNIC_ENCAP_H3/*4 * Copyright(c) 2017 Intel Corporation.5 *6 * This file is provided under a dual BSD/GPLv2 license. When using or7 * redistributing this file, you may do so under either license.8 *9 * GPL LICENSE SUMMARY10 *11 * This program is free software; you can redistribute it and/or modify12 * it under the terms of version 2 of the GNU General Public License as13 * published by the Free Software Foundation.14 *15 * This program is distributed in the hope that it will be useful, but16 * WITHOUT ANY WARRANTY; without even the implied warranty of17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU18 * General Public License for more details.19 *20 * BSD LICENSE21 *22 * Redistribution and use in source and binary forms, with or without23 * modification, are permitted provided that the following conditions24 * are met:25 *26 * - Redistributions of source code must retain the above copyright27 * notice, this list of conditions and the following disclaimer.28 * - Redistributions in binary form must reproduce the above copyright29 * notice, this list of conditions and the following disclaimer in30 * the documentation and/or other materials provided with the31 * distribution.32 * - Neither the name of Intel Corporation nor the names of its33 * contributors may be used to endorse or promote products derived34 * from this software without specific prior written permission.35 *36 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS37 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT38 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR39 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT40 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,43 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY44 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT45 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE46 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.47 *48 */49 50/*51 * This file contains all OPA VNIC declaration required for encapsulation52 * and decapsulation of Ethernet packets53 */54 55#include <linux/types.h>56#include <rdma/ib_mad.h>57 58/* EMA class version */59#define OPA_EMA_CLASS_VERSION 0x8060 61/*62 * Define the Intel vendor management class for OPA63 * ETHERNET MANAGEMENT64 */65#define OPA_MGMT_CLASS_INTEL_EMA 0x3466 67/* EM attribute IDs */68#define OPA_EM_ATTR_CLASS_PORT_INFO 0x000169#define OPA_EM_ATTR_VESWPORT_INFO 0x001170#define OPA_EM_ATTR_VESWPORT_MAC_ENTRIES 0x001271#define OPA_EM_ATTR_IFACE_UCAST_MACS 0x001372#define OPA_EM_ATTR_IFACE_MCAST_MACS 0x001473#define OPA_EM_ATTR_DELETE_VESW 0x001574#define OPA_EM_ATTR_VESWPORT_SUMMARY_COUNTERS 0x002075#define OPA_EM_ATTR_VESWPORT_ERROR_COUNTERS 0x002276 77/* VNIC configured and operational state values */78#define OPA_VNIC_STATE_DROP_ALL 0x179#define OPA_VNIC_STATE_FORWARDING 0x380 81#define OPA_VESW_MAX_NUM_DEF_PORT 1682#define OPA_VNIC_MAX_NUM_PCP 883 84#define OPA_VNIC_EMA_DATA (OPA_MGMT_MAD_SIZE - IB_MGMT_VENDOR_HDR)85 86/* Defines for vendor specific notice(trap) attributes */87#define OPA_INTEL_EMA_NOTICE_TYPE_INFO 0x0488 89/* INTEL OUI */90#define INTEL_OUI_1 0x0091#define INTEL_OUI_2 0x0692#define INTEL_OUI_3 0x6a93 94/* Trap opcodes sent from VNIC */95#define OPA_VESWPORT_TRAP_IFACE_UCAST_MAC_CHANGE 0x196#define OPA_VESWPORT_TRAP_IFACE_MCAST_MAC_CHANGE 0x297#define OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE 0x398 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)101 102/* VNIC Ethernet link status */103#define OPA_VNIC_ETH_LINK_UP 1104#define OPA_VNIC_ETH_LINK_DOWN 2105 106/* routing control */107#define OPA_VNIC_ENCAP_RC_DEFAULT 0108#define OPA_VNIC_ENCAP_RC_IPV4 4109#define OPA_VNIC_ENCAP_RC_IPV4_UDP 8110#define OPA_VNIC_ENCAP_RC_IPV4_TCP 12111#define OPA_VNIC_ENCAP_RC_IPV6 16112#define OPA_VNIC_ENCAP_RC_IPV6_TCP 20113#define OPA_VNIC_ENCAP_RC_IPV6_UDP 24114 115#define OPA_VNIC_ENCAP_RC_EXT(w, b) (((w) >> OPA_VNIC_ENCAP_RC_ ## b) & 0x7)116 117/**118 * struct opa_vesw_info - OPA vnic switch information119 * @fabric_id: 10-bit fabric id120 * @vesw_id: 12-bit virtual ethernet switch id121 * @rsvd0: reserved bytes122 * @def_port_mask: bitmask of default ports123 * @rsvd1: reserved bytes124 * @pkey: partition key125 * @rsvd2: reserved bytes126 * @u_mcast_dlid: unknown multicast dlid127 * @u_ucast_dlid: array of unknown unicast dlids128 * @rsvd3: reserved bytes129 * @rc: routing control130 * @eth_mtu: Ethernet MTU131 * @rsvd4: reserved bytes132 */133struct opa_vesw_info {134 __be16 fabric_id;135 __be16 vesw_id;136 137 u8 rsvd0[6];138 __be16 def_port_mask;139 140 u8 rsvd1[2];141 __be16 pkey;142 143 u8 rsvd2[4];144 __be32 u_mcast_dlid;145 __be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];146 147 __be32 rc;148 149 u8 rsvd3[56];150 __be16 eth_mtu;151 u8 rsvd4[2];152} __packed;153 154/**155 * struct opa_per_veswport_info - OPA vnic per port information156 * @port_num: port number157 * @eth_link_status: current ethernet link state158 * @rsvd0: reserved bytes159 * @base_mac_addr: base mac address160 * @config_state: configured port state161 * @oper_state: operational port state162 * @max_mac_tbl_ent: max number of mac table entries163 * @max_smac_ent: max smac entries in mac table164 * @mac_tbl_digest: mac table digest165 * @rsvd1: reserved bytes166 * @encap_slid: base slid for the port167 * @pcp_to_sc_uc: sc by pcp index for unicast ethernet packets168 * @pcp_to_vl_uc: vl by pcp index for unicast ethernet packets169 * @pcp_to_sc_mc: sc by pcp index for multicast ethernet packets170 * @pcp_to_vl_mc: vl by pcp index for multicast ethernet packets171 * @non_vlan_sc_uc: sc for non-vlan unicast ethernet packets172 * @non_vlan_vl_uc: vl for non-vlan unicast ethernet packets173 * @non_vlan_sc_mc: sc for non-vlan multicast ethernet packets174 * @non_vlan_vl_mc: vl for non-vlan multicast ethernet packets175 * @rsvd2: reserved bytes176 * @uc_macs_gen_count: generation count for unicast macs list177 * @mc_macs_gen_count: generation count for multicast macs list178 * @rsvd3: reserved bytes179 */180struct opa_per_veswport_info {181 __be32 port_num;182 183 u8 eth_link_status;184 u8 rsvd0[3];185 186 u8 base_mac_addr[ETH_ALEN];187 u8 config_state;188 u8 oper_state;189 190 __be16 max_mac_tbl_ent;191 __be16 max_smac_ent;192 __be32 mac_tbl_digest;193 u8 rsvd1[4];194 195 __be32 encap_slid;196 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];201 202 u8 non_vlan_sc_uc;203 u8 non_vlan_vl_uc;204 u8 non_vlan_sc_mc;205 u8 non_vlan_vl_mc;206 207 u8 rsvd2[48];208 209 __be16 uc_macs_gen_count;210 __be16 mc_macs_gen_count;211 212 u8 rsvd3[8];213} __packed;214 215/**216 * struct opa_veswport_info - OPA vnic port information217 * @vesw: OPA vnic switch information218 * @vport: OPA vnic per port information219 *220 * On host, each of the virtual ethernet ports belongs221 * to a different virtual ethernet switches.222 */223struct opa_veswport_info {224 struct opa_vesw_info vesw;225 struct opa_per_veswport_info vport;226};227 228/**229 * struct opa_veswport_mactable_entry - single entry in the forwarding table230 * @mac_addr: MAC address231 * @mac_addr_mask: MAC address bit mask232 * @dlid_sd: Matching DLID and side data233 *234 * On the host each virtual ethernet port will have235 * a forwarding table. These tables are used to236 * map a MAC to a LID and other data. For more237 * details see struct opa_veswport_mactable_entries.238 * This is the structure of a single mactable entry239 */240struct opa_veswport_mactable_entry {241 u8 mac_addr[ETH_ALEN];242 u8 mac_addr_mask[ETH_ALEN];243 __be32 dlid_sd;244} __packed;245 246/**247 * struct opa_veswport_mactable - Forwarding table array248 * @offset: mac table starting offset249 * @num_entries: Number of entries to get or set250 * @mac_tbl_digest: mac table digest251 * @tbl_entries: Array of table entries252 *253 * The EM sends down this structure in a MAD indicating254 * the starting offset in the forwarding table that this255 * entry is to be loaded into and the number of entries256 * that that this MAD instance contains257 * The mac_tbl_digest has been added to this MAD structure. It will be set by258 * the EM and it will be used by the EM to check if there are any259 * discrepancies with this value and the value260 * maintained by the EM in the case of VNIC port being deleted or unloaded261 * 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 be263 * accessed by the GET and SET routines for both the mactable entries and the264 * veswport info.265 */266struct 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;272 273/**274 * struct opa_veswport_summary_counters - summary counters275 * @vp_instance: vport instance on the OPA port276 * @vesw_id: virtual ethernet switch id277 * @veswport_num: virtual ethernet switch port number278 * @tx_errors: transmit errors279 * @rx_errors: receive errors280 * @tx_packets: transmit packets281 * @rx_packets: receive packets282 * @tx_bytes: transmit bytes283 * @rx_bytes: receive bytes284 * @tx_unicast: unicast packets transmitted285 * @tx_mcastbcast: multicast/broadcast packets transmitted286 * @tx_untagged: non-vlan packets transmitted287 * @tx_vlan: vlan packets transmitted288 * @tx_64_size: transmit packet length is 64 bytes289 * @tx_65_127: transmit packet length is >=65 and < 127 bytes290 * @tx_128_255: transmit packet length is >=128 and < 255 bytes291 * @tx_256_511: transmit packet length is >=256 and < 511 bytes292 * @tx_512_1023: transmit packet length is >=512 and < 1023 bytes293 * @tx_1024_1518: transmit packet length is >=1024 and < 1518 bytes294 * @tx_1519_max: transmit packet length >= 1519 bytes295 * @rx_unicast: unicast packets received296 * @rx_mcastbcast: multicast/broadcast packets received297 * @rx_untagged: non-vlan packets received298 * @rx_vlan: vlan packets received299 * @rx_64_size: received packet length is 64 bytes300 * @rx_65_127: received packet length is >=65 and < 127 bytes301 * @rx_128_255: received packet length is >=128 and < 255 bytes302 * @rx_256_511: received packet length is >=256 and < 511 bytes303 * @rx_512_1023: received packet length is >=512 and < 1023 bytes304 * @rx_1024_1518: received packet length is >=1024 and < 1518 bytes305 * @rx_1519_max: received packet length >= 1519 bytes306 * @reserved: reserved bytes307 *308 * All the above are counters of corresponding conditions.309 */310struct opa_veswport_summary_counters {311 __be16 vp_instance;312 __be16 vesw_id;313 __be32 veswport_num;314 315 __be64 tx_errors;316 __be64 rx_errors;317 __be64 tx_packets;318 __be64 rx_packets;319 __be64 tx_bytes;320 __be64 rx_bytes;321 322 __be64 tx_unicast;323 __be64 tx_mcastbcast;324 325 __be64 tx_untagged;326 __be64 tx_vlan;327 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;335 336 __be64 rx_unicast;337 __be64 rx_mcastbcast;338 339 __be64 rx_untagged;340 __be64 rx_vlan;341 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;349 350 __be64 reserved[16];351} __packed;352 353/**354 * struct opa_veswport_error_counters - error counters355 * @vp_instance: vport instance on the OPA port356 * @vesw_id: virtual ethernet switch id357 * @veswport_num: virtual ethernet switch port number358 * @tx_errors: transmit errors359 * @rx_errors: receive errors360 * @rsvd0: reserved bytes361 * @tx_smac_filt: smac filter errors362 * @rsvd1: reserved bytes363 * @rsvd2: reserved bytes364 * @rsvd3: reserved bytes365 * @tx_dlid_zero: transmit packets with invalid dlid366 * @rsvd4: reserved bytes367 * @tx_logic: other transmit errors368 * @rsvd5: reserved bytes369 * @tx_drop_state: packet tansmission in non-forward port state370 * @rx_bad_veswid: received packet with invalid vesw id371 * @rsvd6: reserved bytes372 * @rx_runt: received ethernet packet with length < 64 bytes373 * @rx_oversize: received ethernet packet with length > MTU size374 * @rsvd7: reserved bytes375 * @rx_eth_down: received packets when interface is down376 * @rx_drop_state: received packets in non-forwarding port state377 * @rx_logic: other receive errors378 * @rsvd8: reserved bytes379 * @rsvd9: reserved bytes380 *381 * All the above are counters of corresponding error conditions.382 */383struct opa_veswport_error_counters {384 __be16 vp_instance;385 __be16 vesw_id;386 __be32 veswport_num;387 388 __be64 tx_errors;389 __be64 rx_errors;390 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;401 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;411 412 __be64 rsvd9[16];413} __packed;414 415/**416 * struct opa_veswport_trap - Trap message sent to EM by VNIC417 * @fabric_id: 10 bit fabric id418 * @veswid: 12 bit virtual ethernet switch id419 * @veswportnum: logical port number on the Virtual switch420 * @opaportnum: physical port num (redundant on host)421 * @veswportindex: switch port index on opa port 0 based422 * @opcode: operation423 * @reserved: 32 bit for alignment424 *425 * The VNIC will send trap messages to the Ethernet manager to426 * inform it about changes to the VNIC config, behaviour etc.427 * This is the format of the trap payload.428 */429struct 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;438 439/**440 * struct opa_vnic_iface_mac_entry - single entry in the mac list441 * @mac_addr: MAC address442 */443struct opa_vnic_iface_mac_entry {444 u8 mac_addr[ETH_ALEN];445};446 447/**448 * struct opa_veswport_iface_macs - Msg to set globally administered MAC449 * @start_idx: position of first entry (0 based)450 * @num_macs_in_msg: number of MACs in this message451 * @tot_macs_in_lst: The total number of MACs the agent has452 * @gen_count: gen_count to indicate change453 * @entry: The mac list entry454 *455 * Same attribute IDS and attribute modifiers as in locally administered456 * addresses used to set globally administered addresses457 */458struct 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;465 466/**467 * struct opa_vnic_vema_mad - Generic VEMA MAD468 * @mad_hdr: Generic MAD header469 * @rmpp_hdr: RMPP header for vendor specific MADs470 * @reserved: reserved bytes471 * @oui: Unique org identifier472 * @data: MAD data473 */474struct 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];480};481 482/**483 * struct opa_vnic_notice_attr - Generic Notice MAD484 * @gen_type: Generic/Specific bit and type of notice485 * @oui_1: Vendor ID byte 1486 * @oui_2: Vendor ID byte 2487 * @oui_3: Vendor ID byte 3488 * @trap_num: Trap number489 * @toggle_count: Notice toggle bit and count value490 * @issuer_lid: Trap issuer's lid491 * @reserved: reserved bytes492 * @issuer_gid: Issuer GID (only if Report method)493 * @raw_data: Trap message body494 */495struct 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;507 508/**509 * struct opa_vnic_vema_mad_trap - Generic VEMA MAD Trap510 * @mad_hdr: Generic MAD header511 * @rmpp_hdr: RMPP header for vendor specific MADs512 * @reserved: reserved bytes513 * @oui: Unique org identifier514 * @notice: Notice structure515 */516struct 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;522};523 524#endif /* _OPA_VNIC_ENCAP_H */525