Back to home page

OSCL-LXR

 
 

    


0001 #ifndef _OPA_VNIC_ENCAP_H
0002 #define _OPA_VNIC_ENCAP_H
0003 /*
0004  * Copyright(c) 2017 Intel Corporation.
0005  *
0006  * This file is provided under a dual BSD/GPLv2 license.  When using or
0007  * redistributing this file, you may do so under either license.
0008  *
0009  * GPL LICENSE SUMMARY
0010  *
0011  * This program is free software; you can redistribute it and/or modify
0012  * it under the terms of version 2 of the GNU General Public License as
0013  * published by the Free Software Foundation.
0014  *
0015  * This program is distributed in the hope that it will be useful, but
0016  * WITHOUT ANY WARRANTY; without even the implied warranty of
0017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018  * General Public License for more details.
0019  *
0020  * BSD LICENSE
0021  *
0022  * Redistribution and use in source and binary forms, with or without
0023  * modification, are permitted provided that the following conditions
0024  * are met:
0025  *
0026  *  - Redistributions of source code must retain the above copyright
0027  *    notice, this list of conditions and the following disclaimer.
0028  *  - Redistributions in binary form must reproduce the above copyright
0029  *    notice, this list of conditions and the following disclaimer in
0030  *    the documentation and/or other materials provided with the
0031  *    distribution.
0032  *  - Neither the name of Intel Corporation nor the names of its
0033  *    contributors may be used to endorse or promote products derived
0034  *    from this software without specific prior written permission.
0035  *
0036  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0037  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0038  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0039  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0040  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0043  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0044  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0045  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0046  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0047  *
0048  */
0049 
0050 /*
0051  * This file contains all OPA VNIC declaration required for encapsulation
0052  * and decapsulation of Ethernet packets
0053  */
0054 
0055 #include <linux/types.h>
0056 #include <rdma/ib_mad.h>
0057 
0058 /* EMA class version */
0059 #define OPA_EMA_CLASS_VERSION               0x80
0060 
0061 /*
0062  * Define the Intel vendor management class for OPA
0063  * ETHERNET MANAGEMENT
0064  */
0065 #define OPA_MGMT_CLASS_INTEL_EMA            0x34
0066 
0067 /* EM attribute IDs */
0068 #define OPA_EM_ATTR_CLASS_PORT_INFO                 0x0001
0069 #define OPA_EM_ATTR_VESWPORT_INFO                   0x0011
0070 #define OPA_EM_ATTR_VESWPORT_MAC_ENTRIES            0x0012
0071 #define OPA_EM_ATTR_IFACE_UCAST_MACS                0x0013
0072 #define OPA_EM_ATTR_IFACE_MCAST_MACS                0x0014
0073 #define OPA_EM_ATTR_DELETE_VESW                     0x0015
0074 #define OPA_EM_ATTR_VESWPORT_SUMMARY_COUNTERS       0x0020
0075 #define OPA_EM_ATTR_VESWPORT_ERROR_COUNTERS         0x0022
0076 
0077 /* VNIC configured and operational state values */
0078 #define OPA_VNIC_STATE_DROP_ALL        0x1
0079 #define OPA_VNIC_STATE_FORWARDING      0x3
0080 
0081 #define OPA_VESW_MAX_NUM_DEF_PORT   16
0082 #define OPA_VNIC_MAX_NUM_PCP        8
0083 
0084 #define OPA_VNIC_EMA_DATA    (OPA_MGMT_MAD_SIZE - IB_MGMT_VENDOR_HDR)
0085 
0086 /* Defines for vendor specific notice(trap) attributes */
0087 #define OPA_INTEL_EMA_NOTICE_TYPE_INFO 0x04
0088 
0089 /* INTEL OUI */
0090 #define INTEL_OUI_1 0x00
0091 #define INTEL_OUI_2 0x06
0092 #define INTEL_OUI_3 0x6a
0093 
0094 /* Trap opcodes sent from VNIC */
0095 #define OPA_VESWPORT_TRAP_IFACE_UCAST_MAC_CHANGE 0x1
0096 #define OPA_VESWPORT_TRAP_IFACE_MCAST_MAC_CHANGE 0x2
0097 #define OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE 0x3
0098 
0099 #define OPA_VNIC_DLID_SD_IS_SRC_MAC(dlid_sd)  (!!((dlid_sd) & 0x20))
0100 #define OPA_VNIC_DLID_SD_GET_DLID(dlid_sd)    ((dlid_sd) >> 8)
0101 
0102 /* VNIC Ethernet link status */
0103 #define OPA_VNIC_ETH_LINK_UP     1
0104 #define OPA_VNIC_ETH_LINK_DOWN   2
0105 
0106 /* routing control */
0107 #define OPA_VNIC_ENCAP_RC_DEFAULT   0
0108 #define OPA_VNIC_ENCAP_RC_IPV4      4
0109 #define OPA_VNIC_ENCAP_RC_IPV4_UDP  8
0110 #define OPA_VNIC_ENCAP_RC_IPV4_TCP  12
0111 #define OPA_VNIC_ENCAP_RC_IPV6      16
0112 #define OPA_VNIC_ENCAP_RC_IPV6_TCP  20
0113 #define OPA_VNIC_ENCAP_RC_IPV6_UDP  24
0114 
0115 #define OPA_VNIC_ENCAP_RC_EXT(w, b) (((w) >> OPA_VNIC_ENCAP_RC_ ## b) & 0x7)
0116 
0117 /**
0118  * struct opa_vesw_info - OPA vnic switch information
0119  * @fabric_id: 10-bit fabric id
0120  * @vesw_id: 12-bit virtual ethernet switch id
0121  * @rsvd0: reserved bytes
0122  * @def_port_mask: bitmask of default ports
0123  * @rsvd1: reserved bytes
0124  * @pkey: partition key
0125  * @rsvd2: reserved bytes
0126  * @u_mcast_dlid: unknown multicast dlid
0127  * @u_ucast_dlid: array of unknown unicast dlids
0128  * @rsvd3: reserved bytes
0129  * @rc: routing control
0130  * @eth_mtu: Ethernet MTU
0131  * @rsvd4: reserved bytes
0132  */
0133 struct opa_vesw_info {
0134     __be16  fabric_id;
0135     __be16  vesw_id;
0136 
0137     u8      rsvd0[6];
0138     __be16  def_port_mask;
0139 
0140     u8      rsvd1[2];
0141     __be16  pkey;
0142 
0143     u8      rsvd2[4];
0144     __be32  u_mcast_dlid;
0145     __be32  u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
0146 
0147     __be32  rc;
0148 
0149     u8      rsvd3[56];
0150     __be16  eth_mtu;
0151     u8      rsvd4[2];
0152 } __packed;
0153 
0154 /**
0155  * struct opa_per_veswport_info - OPA vnic per port information
0156  * @port_num: port number
0157  * @eth_link_status: current ethernet link state
0158  * @rsvd0: reserved bytes
0159  * @base_mac_addr: base mac address
0160  * @config_state: configured port state
0161  * @oper_state: operational port state
0162  * @max_mac_tbl_ent: max number of mac table entries
0163  * @max_smac_ent: max smac entries in mac table
0164  * @mac_tbl_digest: mac table digest
0165  * @rsvd1: reserved bytes
0166  * @encap_slid: base slid for the port
0167  * @pcp_to_sc_uc: sc by pcp index for unicast ethernet packets
0168  * @pcp_to_vl_uc: vl by pcp index for unicast ethernet packets
0169  * @pcp_to_sc_mc: sc by pcp index for multicast ethernet packets
0170  * @pcp_to_vl_mc: vl by pcp index for multicast ethernet packets
0171  * @non_vlan_sc_uc: sc for non-vlan unicast ethernet packets
0172  * @non_vlan_vl_uc: vl for non-vlan unicast ethernet packets
0173  * @non_vlan_sc_mc: sc for non-vlan multicast ethernet packets
0174  * @non_vlan_vl_mc: vl for non-vlan multicast ethernet packets
0175  * @rsvd2: reserved bytes
0176  * @uc_macs_gen_count: generation count for unicast macs list
0177  * @mc_macs_gen_count: generation count for multicast macs list
0178  * @rsvd3: reserved bytes
0179  */
0180 struct opa_per_veswport_info {
0181     __be32  port_num;
0182 
0183     u8      eth_link_status;
0184     u8      rsvd0[3];
0185 
0186     u8      base_mac_addr[ETH_ALEN];
0187     u8      config_state;
0188     u8      oper_state;
0189 
0190     __be16  max_mac_tbl_ent;
0191     __be16  max_smac_ent;
0192     __be32  mac_tbl_digest;
0193     u8      rsvd1[4];
0194 
0195     __be32  encap_slid;
0196 
0197     u8      pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
0198     u8      pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
0199     u8      pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
0200     u8      pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
0201 
0202     u8      non_vlan_sc_uc;
0203     u8      non_vlan_vl_uc;
0204     u8      non_vlan_sc_mc;
0205     u8      non_vlan_vl_mc;
0206 
0207     u8      rsvd2[48];
0208 
0209     __be16  uc_macs_gen_count;
0210     __be16  mc_macs_gen_count;
0211 
0212     u8      rsvd3[8];
0213 } __packed;
0214 
0215 /**
0216  * struct opa_veswport_info - OPA vnic port information
0217  * @vesw: OPA vnic switch information
0218  * @vport: OPA vnic per port information
0219  *
0220  * On host, each of the virtual ethernet ports belongs
0221  * to a different virtual ethernet switches.
0222  */
0223 struct opa_veswport_info {
0224     struct opa_vesw_info          vesw;
0225     struct opa_per_veswport_info  vport;
0226 };
0227 
0228 /**
0229  * struct opa_veswport_mactable_entry - single entry in the forwarding table
0230  * @mac_addr: MAC address
0231  * @mac_addr_mask: MAC address bit mask
0232  * @dlid_sd: Matching DLID and side data
0233  *
0234  * On the host each virtual ethernet port will have
0235  * a forwarding table. These tables are used to
0236  * map a MAC to a LID and other data. For more
0237  * details see struct opa_veswport_mactable_entries.
0238  * This is the structure of a single mactable entry
0239  */
0240 struct opa_veswport_mactable_entry {
0241     u8      mac_addr[ETH_ALEN];
0242     u8      mac_addr_mask[ETH_ALEN];
0243     __be32  dlid_sd;
0244 } __packed;
0245 
0246 /**
0247  * struct opa_veswport_mactable - Forwarding table array
0248  * @offset: mac table starting offset
0249  * @num_entries: Number of entries to get or set
0250  * @mac_tbl_digest: mac table digest
0251  * @tbl_entries: Array of table entries
0252  *
0253  * The EM sends down this structure in a MAD indicating
0254  * the starting offset in the forwarding table that this
0255  * entry is to be loaded into and the number of entries
0256  * that that this MAD instance contains
0257  * The mac_tbl_digest has been added to this MAD structure. It will be set by
0258  * the EM and it will be used by the EM to check if there are any
0259  * discrepancies with this value and the value
0260  * maintained by the EM in the case of VNIC port being deleted or unloaded
0261  * A new instantiation of a VNIC will always have a value of zero.
0262  * This value is stored as part of the vnic adapter structure and will be
0263  * accessed by the GET and SET routines for both the mactable entries and the
0264  * veswport info.
0265  */
0266 struct opa_veswport_mactable {
0267     __be16                              offset;
0268     __be16                              num_entries;
0269     __be32                              mac_tbl_digest;
0270     struct opa_veswport_mactable_entry  tbl_entries[];
0271 } __packed;
0272 
0273 /**
0274  * struct opa_veswport_summary_counters - summary counters
0275  * @vp_instance: vport instance on the OPA port
0276  * @vesw_id: virtual ethernet switch id
0277  * @veswport_num: virtual ethernet switch port number
0278  * @tx_errors: transmit errors
0279  * @rx_errors: receive errors
0280  * @tx_packets: transmit packets
0281  * @rx_packets: receive packets
0282  * @tx_bytes: transmit bytes
0283  * @rx_bytes: receive bytes
0284  * @tx_unicast: unicast packets transmitted
0285  * @tx_mcastbcast: multicast/broadcast packets transmitted
0286  * @tx_untagged: non-vlan packets transmitted
0287  * @tx_vlan: vlan packets transmitted
0288  * @tx_64_size: transmit packet length is 64 bytes
0289  * @tx_65_127: transmit packet length is >=65 and < 127 bytes
0290  * @tx_128_255: transmit packet length is >=128 and < 255 bytes
0291  * @tx_256_511: transmit packet length is >=256 and < 511 bytes
0292  * @tx_512_1023: transmit packet length is >=512 and < 1023 bytes
0293  * @tx_1024_1518: transmit packet length is >=1024 and < 1518 bytes
0294  * @tx_1519_max: transmit packet length >= 1519 bytes
0295  * @rx_unicast: unicast packets received
0296  * @rx_mcastbcast: multicast/broadcast packets received
0297  * @rx_untagged: non-vlan packets received
0298  * @rx_vlan: vlan packets received
0299  * @rx_64_size: received packet length is 64 bytes
0300  * @rx_65_127: received packet length is >=65 and < 127 bytes
0301  * @rx_128_255: received packet length is >=128 and < 255 bytes
0302  * @rx_256_511: received packet length is >=256 and < 511 bytes
0303  * @rx_512_1023: received packet length is >=512 and < 1023 bytes
0304  * @rx_1024_1518: received packet length is >=1024 and < 1518 bytes
0305  * @rx_1519_max: received packet length >= 1519 bytes
0306  * @reserved: reserved bytes
0307  *
0308  * All the above are counters of corresponding conditions.
0309  */
0310 struct opa_veswport_summary_counters {
0311     __be16  vp_instance;
0312     __be16  vesw_id;
0313     __be32  veswport_num;
0314 
0315     __be64  tx_errors;
0316     __be64  rx_errors;
0317     __be64  tx_packets;
0318     __be64  rx_packets;
0319     __be64  tx_bytes;
0320     __be64  rx_bytes;
0321 
0322     __be64  tx_unicast;
0323     __be64  tx_mcastbcast;
0324 
0325     __be64  tx_untagged;
0326     __be64  tx_vlan;
0327 
0328     __be64  tx_64_size;
0329     __be64  tx_65_127;
0330     __be64  tx_128_255;
0331     __be64  tx_256_511;
0332     __be64  tx_512_1023;
0333     __be64  tx_1024_1518;
0334     __be64  tx_1519_max;
0335 
0336     __be64  rx_unicast;
0337     __be64  rx_mcastbcast;
0338 
0339     __be64  rx_untagged;
0340     __be64  rx_vlan;
0341 
0342     __be64  rx_64_size;
0343     __be64  rx_65_127;
0344     __be64  rx_128_255;
0345     __be64  rx_256_511;
0346     __be64  rx_512_1023;
0347     __be64  rx_1024_1518;
0348     __be64  rx_1519_max;
0349 
0350     __be64  reserved[16];
0351 } __packed;
0352 
0353 /**
0354  * struct opa_veswport_error_counters - error counters
0355  * @vp_instance: vport instance on the OPA port
0356  * @vesw_id: virtual ethernet switch id
0357  * @veswport_num: virtual ethernet switch port number
0358  * @tx_errors: transmit errors
0359  * @rx_errors: receive errors
0360  * @rsvd0: reserved bytes
0361  * @tx_smac_filt: smac filter errors
0362  * @rsvd1: reserved bytes
0363  * @rsvd2: reserved bytes
0364  * @rsvd3: reserved bytes
0365  * @tx_dlid_zero: transmit packets with invalid dlid
0366  * @rsvd4: reserved bytes
0367  * @tx_logic: other transmit errors
0368  * @rsvd5: reserved bytes
0369  * @tx_drop_state: packet tansmission in non-forward port state
0370  * @rx_bad_veswid: received packet with invalid vesw id
0371  * @rsvd6: reserved bytes
0372  * @rx_runt: received ethernet packet with length < 64 bytes
0373  * @rx_oversize: received ethernet packet with length > MTU size
0374  * @rsvd7: reserved bytes
0375  * @rx_eth_down: received packets when interface is down
0376  * @rx_drop_state: received packets in non-forwarding port state
0377  * @rx_logic: other receive errors
0378  * @rsvd8: reserved bytes
0379  * @rsvd9: reserved bytes
0380  *
0381  * All the above are counters of corresponding error conditions.
0382  */
0383 struct opa_veswport_error_counters {
0384     __be16  vp_instance;
0385     __be16  vesw_id;
0386     __be32  veswport_num;
0387 
0388     __be64  tx_errors;
0389     __be64  rx_errors;
0390 
0391     __be64  rsvd0;
0392     __be64  tx_smac_filt;
0393     __be64  rsvd1;
0394     __be64  rsvd2;
0395     __be64  rsvd3;
0396     __be64  tx_dlid_zero;
0397     __be64  rsvd4;
0398     __be64  tx_logic;
0399     __be64  rsvd5;
0400     __be64  tx_drop_state;
0401 
0402     __be64  rx_bad_veswid;
0403     __be64  rsvd6;
0404     __be64  rx_runt;
0405     __be64  rx_oversize;
0406     __be64  rsvd7;
0407     __be64  rx_eth_down;
0408     __be64  rx_drop_state;
0409     __be64  rx_logic;
0410     __be64  rsvd8;
0411 
0412     __be64  rsvd9[16];
0413 } __packed;
0414 
0415 /**
0416  * struct opa_veswport_trap - Trap message sent to EM by VNIC
0417  * @fabric_id: 10 bit fabric id
0418  * @veswid: 12 bit virtual ethernet switch id
0419  * @veswportnum: logical port number on the Virtual switch
0420  * @opaportnum: physical port num (redundant on host)
0421  * @veswportindex: switch port index on opa port 0 based
0422  * @opcode: operation
0423  * @reserved: 32 bit for alignment
0424  *
0425  * The VNIC will send trap messages to the Ethernet manager to
0426  * inform it about changes to the VNIC config, behaviour etc.
0427  * This is the format of the trap payload.
0428  */
0429 struct opa_veswport_trap {
0430     __be16  fabric_id;
0431     __be16  veswid;
0432     __be32  veswportnum;
0433     __be16  opaportnum;
0434     u8      veswportindex;
0435     u8      opcode;
0436     __be32  reserved;
0437 } __packed;
0438 
0439 /**
0440  * struct opa_vnic_iface_mac_entry - single entry in the mac list
0441  * @mac_addr: MAC address
0442  */
0443 struct opa_vnic_iface_mac_entry {
0444     u8 mac_addr[ETH_ALEN];
0445 };
0446 
0447 /**
0448  * struct opa_veswport_iface_macs - Msg to set globally administered MAC
0449  * @start_idx: position of first entry (0 based)
0450  * @num_macs_in_msg: number of MACs in this message
0451  * @tot_macs_in_lst: The total number of MACs the agent has
0452  * @gen_count: gen_count to indicate change
0453  * @entry: The mac list entry
0454  *
0455  * Same attribute IDS and attribute modifiers as in locally administered
0456  * addresses used to set globally administered addresses
0457  */
0458 struct opa_veswport_iface_macs {
0459     __be16 start_idx;
0460     __be16 num_macs_in_msg;
0461     __be16 tot_macs_in_lst;
0462     __be16 gen_count;
0463     struct opa_vnic_iface_mac_entry entry[];
0464 } __packed;
0465 
0466 /**
0467  * struct opa_vnic_vema_mad - Generic VEMA MAD
0468  * @mad_hdr: Generic MAD header
0469  * @rmpp_hdr: RMPP header for vendor specific MADs
0470  * @reserved: reserved bytes
0471  * @oui: Unique org identifier
0472  * @data: MAD data
0473  */
0474 struct opa_vnic_vema_mad {
0475     struct ib_mad_hdr  mad_hdr;
0476     struct ib_rmpp_hdr rmpp_hdr;
0477     u8                 reserved;
0478     u8                 oui[3];
0479     u8                 data[OPA_VNIC_EMA_DATA];
0480 };
0481 
0482 /**
0483  * struct opa_vnic_notice_attr - Generic Notice MAD
0484  * @gen_type: Generic/Specific bit and type of notice
0485  * @oui_1: Vendor ID byte 1
0486  * @oui_2: Vendor ID byte 2
0487  * @oui_3: Vendor ID byte 3
0488  * @trap_num: Trap number
0489  * @toggle_count: Notice toggle bit and count value
0490  * @issuer_lid: Trap issuer's lid
0491  * @reserved: reserved bytes
0492  * @issuer_gid: Issuer GID (only if Report method)
0493  * @raw_data: Trap message body
0494  */
0495 struct opa_vnic_notice_attr {
0496     u8     gen_type;
0497     u8     oui_1;
0498     u8     oui_2;
0499     u8     oui_3;
0500     __be16 trap_num;
0501     __be16 toggle_count;
0502     __be32 issuer_lid;
0503     __be32 reserved;
0504     u8     issuer_gid[16];
0505     u8     raw_data[64];
0506 } __packed;
0507 
0508 /**
0509  * struct opa_vnic_vema_mad_trap - Generic VEMA MAD Trap
0510  * @mad_hdr: Generic MAD header
0511  * @rmpp_hdr: RMPP header for vendor specific MADs
0512  * @reserved: reserved bytes
0513  * @oui: Unique org identifier
0514  * @notice: Notice structure
0515  */
0516 struct opa_vnic_vema_mad_trap {
0517     struct ib_mad_hdr            mad_hdr;
0518     struct ib_rmpp_hdr           rmpp_hdr;
0519     u8                           reserved;
0520     u8                           oui[3];
0521     struct opa_vnic_notice_attr  notice;
0522 };
0523 
0524 #endif /* _OPA_VNIC_ENCAP_H */