root/drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   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 /*
  51  * This file contains all OPA VNIC declaration required for encapsulation
  52  * and decapsulation of Ethernet packets
  53  */
  54 
  55 #include <linux/types.h>
  56 #include <rdma/ib_mad.h>
  57 
  58 /* EMA class version */
  59 #define OPA_EMA_CLASS_VERSION               0x80
  60 
  61 /*
  62  * Define the Intel vendor management class for OPA
  63  * ETHERNET MANAGEMENT
  64  */
  65 #define OPA_MGMT_CLASS_INTEL_EMA            0x34
  66 
  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
  76 
  77 /* VNIC configured and operational state values */
  78 #define OPA_VNIC_STATE_DROP_ALL        0x1
  79 #define OPA_VNIC_STATE_FORWARDING      0x3
  80 
  81 #define OPA_VESW_MAX_NUM_DEF_PORT   16
  82 #define OPA_VNIC_MAX_NUM_PCP        8
  83 
  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 0x04
  88 
  89 /* INTEL OUI */
  90 #define INTEL_OUI_1 0x00
  91 #define INTEL_OUI_2 0x06
  92 #define INTEL_OUI_3 0x6a
  93 
  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
  98 
  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     1
 104 #define OPA_VNIC_ETH_LINK_DOWN   2
 105 
 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
 114 
 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 information
 119  * @fabric_id: 10-bit fabric id
 120  * @vesw_id: 12-bit virtual ethernet switch id
 121  * @def_port_mask: bitmask of default ports
 122  * @pkey: partition key
 123  * @u_mcast_dlid: unknown multicast dlid
 124  * @u_ucast_dlid: array of unknown unicast dlids
 125  * @rc: routing control
 126  * @eth_mtu: Ethernet MTU
 127  */
 128 struct opa_vesw_info {
 129         __be16  fabric_id;
 130         __be16  vesw_id;
 131 
 132         u8      rsvd0[6];
 133         __be16  def_port_mask;
 134 
 135         u8      rsvd1[2];
 136         __be16  pkey;
 137 
 138         u8      rsvd2[4];
 139         __be32  u_mcast_dlid;
 140         __be32  u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
 141 
 142         __be32  rc;
 143 
 144         u8      rsvd3[56];
 145         __be16  eth_mtu;
 146         u8      rsvd4[2];
 147 } __packed;
 148 
 149 /**
 150  * struct opa_per_veswport_info - OPA vnic per port information
 151  * @port_num: port number
 152  * @eth_link_status: current ethernet link state
 153  * @base_mac_addr: base mac address
 154  * @config_state: configured port state
 155  * @oper_state: operational port state
 156  * @max_mac_tbl_ent: max number of mac table entries
 157  * @max_smac_ent: max smac entries in mac table
 158  * @mac_tbl_digest: mac table digest
 159  * @encap_slid: base slid for the port
 160  * @pcp_to_sc_uc: sc by pcp index for unicast ethernet packets
 161  * @pcp_to_vl_uc: vl by pcp index for unicast ethernet packets
 162  * @pcp_to_sc_mc: sc by pcp index for multicast ethernet packets
 163  * @pcp_to_vl_mc: vl by pcp index for multicast ethernet packets
 164  * @non_vlan_sc_uc: sc for non-vlan unicast ethernet packets
 165  * @non_vlan_vl_uc: vl for non-vlan unicast ethernet packets
 166  * @non_vlan_sc_mc: sc for non-vlan multicast ethernet packets
 167  * @non_vlan_vl_mc: vl for non-vlan multicast ethernet packets
 168  * @uc_macs_gen_count: generation count for unicast macs list
 169  * @mc_macs_gen_count: generation count for multicast macs list
 170  */
 171 struct opa_per_veswport_info {
 172         __be32  port_num;
 173 
 174         u8      eth_link_status;
 175         u8      rsvd0[3];
 176 
 177         u8      base_mac_addr[ETH_ALEN];
 178         u8      config_state;
 179         u8      oper_state;
 180 
 181         __be16  max_mac_tbl_ent;
 182         __be16  max_smac_ent;
 183         __be32  mac_tbl_digest;
 184         u8      rsvd1[4];
 185 
 186         __be32  encap_slid;
 187 
 188         u8      pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
 189         u8      pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
 190         u8      pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
 191         u8      pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
 192 
 193         u8      non_vlan_sc_uc;
 194         u8      non_vlan_vl_uc;
 195         u8      non_vlan_sc_mc;
 196         u8      non_vlan_vl_mc;
 197 
 198         u8      rsvd2[48];
 199 
 200         __be16  uc_macs_gen_count;
 201         __be16  mc_macs_gen_count;
 202 
 203         u8      rsvd3[8];
 204 } __packed;
 205 
 206 /**
 207  * struct opa_veswport_info - OPA vnic port information
 208  * @vesw: OPA vnic switch information
 209  * @vport: OPA vnic per port information
 210  *
 211  * On host, each of the virtual ethernet ports belongs
 212  * to a different virtual ethernet switches.
 213  */
 214 struct opa_veswport_info {
 215         struct opa_vesw_info          vesw;
 216         struct opa_per_veswport_info  vport;
 217 };
 218 
 219 /**
 220  * struct opa_veswport_mactable_entry - single entry in the forwarding table
 221  * @mac_addr: MAC address
 222  * @mac_addr_mask: MAC address bit mask
 223  * @dlid_sd: Matching DLID and side data
 224  *
 225  * On the host each virtual ethernet port will have
 226  * a forwarding table. These tables are used to
 227  * map a MAC to a LID and other data. For more
 228  * details see struct opa_veswport_mactable_entries.
 229  * This is the structure of a single mactable entry
 230  */
 231 struct opa_veswport_mactable_entry {
 232         u8      mac_addr[ETH_ALEN];
 233         u8      mac_addr_mask[ETH_ALEN];
 234         __be32  dlid_sd;
 235 } __packed;
 236 
 237 /**
 238  * struct opa_veswport_mactable - Forwarding table array
 239  * @offset: mac table starting offset
 240  * @num_entries: Number of entries to get or set
 241  * @mac_tbl_digest: mac table digest
 242  * @tbl_entries[]: Array of table entries
 243  *
 244  * The EM sends down this structure in a MAD indicating
 245  * the starting offset in the forwarding table that this
 246  * entry is to be loaded into and the number of entries
 247  * that that this MAD instance contains
 248  * The mac_tbl_digest has been added to this MAD structure. It will be set by
 249  * the EM and it will be used by the EM to check if there are any
 250  * discrepancies with this value and the value
 251  * maintained by the EM in the case of VNIC port being deleted or unloaded
 252  * A new instantiation of a VNIC will always have a value of zero.
 253  * This value is stored as part of the vnic adapter structure and will be
 254  * accessed by the GET and SET routines for both the mactable entries and the
 255  * veswport info.
 256  */
 257 struct opa_veswport_mactable {
 258         __be16                              offset;
 259         __be16                              num_entries;
 260         __be32                              mac_tbl_digest;
 261         struct opa_veswport_mactable_entry  tbl_entries[0];
 262 } __packed;
 263 
 264 /**
 265  * struct opa_veswport_summary_counters - summary counters
 266  * @vp_instance: vport instance on the OPA port
 267  * @vesw_id: virtual ethernet switch id
 268  * @veswport_num: virtual ethernet switch port number
 269  * @tx_errors: transmit errors
 270  * @rx_errors: receive errors
 271  * @tx_packets: transmit packets
 272  * @rx_packets: receive packets
 273  * @tx_bytes: transmit bytes
 274  * @rx_bytes: receive bytes
 275  * @tx_unicast: unicast packets transmitted
 276  * @tx_mcastbcast: multicast/broadcast packets transmitted
 277  * @tx_untagged: non-vlan packets transmitted
 278  * @tx_vlan: vlan packets transmitted
 279  * @tx_64_size: transmit packet length is 64 bytes
 280  * @tx_65_127: transmit packet length is >=65 and < 127 bytes
 281  * @tx_128_255: transmit packet length is >=128 and < 255 bytes
 282  * @tx_256_511: transmit packet length is >=256 and < 511 bytes
 283  * @tx_512_1023: transmit packet length is >=512 and < 1023 bytes
 284  * @tx_1024_1518: transmit packet length is >=1024 and < 1518 bytes
 285  * @tx_1519_max: transmit packet length >= 1519 bytes
 286  * @rx_unicast: unicast packets received
 287  * @rx_mcastbcast: multicast/broadcast packets received
 288  * @rx_untagged: non-vlan packets received
 289  * @rx_vlan: vlan packets received
 290  * @rx_64_size: received packet length is 64 bytes
 291  * @rx_65_127: received packet length is >=65 and < 127 bytes
 292  * @rx_128_255: received packet length is >=128 and < 255 bytes
 293  * @rx_256_511: received packet length is >=256 and < 511 bytes
 294  * @rx_512_1023: received packet length is >=512 and < 1023 bytes
 295  * @rx_1024_1518: received packet length is >=1024 and < 1518 bytes
 296  * @rx_1519_max: received packet length >= 1519 bytes
 297  *
 298  * All the above are counters of corresponding conditions.
 299  */
 300 struct opa_veswport_summary_counters {
 301         __be16  vp_instance;
 302         __be16  vesw_id;
 303         __be32  veswport_num;
 304 
 305         __be64  tx_errors;
 306         __be64  rx_errors;
 307         __be64  tx_packets;
 308         __be64  rx_packets;
 309         __be64  tx_bytes;
 310         __be64  rx_bytes;
 311 
 312         __be64  tx_unicast;
 313         __be64  tx_mcastbcast;
 314 
 315         __be64  tx_untagged;
 316         __be64  tx_vlan;
 317 
 318         __be64  tx_64_size;
 319         __be64  tx_65_127;
 320         __be64  tx_128_255;
 321         __be64  tx_256_511;
 322         __be64  tx_512_1023;
 323         __be64  tx_1024_1518;
 324         __be64  tx_1519_max;
 325 
 326         __be64  rx_unicast;
 327         __be64  rx_mcastbcast;
 328 
 329         __be64  rx_untagged;
 330         __be64  rx_vlan;
 331 
 332         __be64  rx_64_size;
 333         __be64  rx_65_127;
 334         __be64  rx_128_255;
 335         __be64  rx_256_511;
 336         __be64  rx_512_1023;
 337         __be64  rx_1024_1518;
 338         __be64  rx_1519_max;
 339 
 340         __be64  reserved[16];
 341 } __packed;
 342 
 343 /**
 344  * struct opa_veswport_error_counters - error counters
 345  * @vp_instance: vport instance on the OPA port
 346  * @vesw_id: virtual ethernet switch id
 347  * @veswport_num: virtual ethernet switch port number
 348  * @tx_errors: transmit errors
 349  * @rx_errors: receive errors
 350  * @tx_smac_filt: smac filter errors
 351  * @tx_dlid_zero: transmit packets with invalid dlid
 352  * @tx_logic: other transmit errors
 353  * @tx_drop_state: packet tansmission in non-forward port state
 354  * @rx_bad_veswid: received packet with invalid vesw id
 355  * @rx_runt: received ethernet packet with length < 64 bytes
 356  * @rx_oversize: received ethernet packet with length > MTU size
 357  * @rx_eth_down: received packets when interface is down
 358  * @rx_drop_state: received packets in non-forwarding port state
 359  * @rx_logic: other receive errors
 360  *
 361  * All the above are counters of corresponding erorr conditions.
 362  */
 363 struct opa_veswport_error_counters {
 364         __be16  vp_instance;
 365         __be16  vesw_id;
 366         __be32  veswport_num;
 367 
 368         __be64  tx_errors;
 369         __be64  rx_errors;
 370 
 371         __be64  rsvd0;
 372         __be64  tx_smac_filt;
 373         __be64  rsvd1;
 374         __be64  rsvd2;
 375         __be64  rsvd3;
 376         __be64  tx_dlid_zero;
 377         __be64  rsvd4;
 378         __be64  tx_logic;
 379         __be64  rsvd5;
 380         __be64  tx_drop_state;
 381 
 382         __be64  rx_bad_veswid;
 383         __be64  rsvd6;
 384         __be64  rx_runt;
 385         __be64  rx_oversize;
 386         __be64  rsvd7;
 387         __be64  rx_eth_down;
 388         __be64  rx_drop_state;
 389         __be64  rx_logic;
 390         __be64  rsvd8;
 391 
 392         __be64  rsvd9[16];
 393 } __packed;
 394 
 395 /**
 396  * struct opa_veswport_trap - Trap message sent to EM by VNIC
 397  * @fabric_id: 10 bit fabric id
 398  * @veswid: 12 bit virtual ethernet switch id
 399  * @veswportnum: logical port number on the Virtual switch
 400  * @opaportnum: physical port num (redundant on host)
 401  * @veswportindex: switch port index on opa port 0 based
 402  * @opcode: operation
 403  * @reserved: 32 bit for alignment
 404  *
 405  * The VNIC will send trap messages to the Ethernet manager to
 406  * inform it about changes to the VNIC config, behaviour etc.
 407  * This is the format of the trap payload.
 408  */
 409 struct opa_veswport_trap {
 410         __be16  fabric_id;
 411         __be16  veswid;
 412         __be32  veswportnum;
 413         __be16  opaportnum;
 414         u8      veswportindex;
 415         u8      opcode;
 416         __be32  reserved;
 417 } __packed;
 418 
 419 /**
 420  * struct opa_vnic_iface_macs_entry - single entry in the mac list
 421  * @mac_addr: MAC address
 422  */
 423 struct opa_vnic_iface_mac_entry {
 424         u8 mac_addr[ETH_ALEN];
 425 };
 426 
 427 /**
 428  * struct opa_veswport_iface_macs - Msg to set globally administered MAC
 429  * @start_idx: position of first entry (0 based)
 430  * @num_macs_in_msg: number of MACs in this message
 431  * @tot_macs_in_lst: The total number of MACs the agent has
 432  * @gen_count: gen_count to indicate change
 433  * @entry: The mac list entry
 434  *
 435  * Same attribute IDS and attribute modifiers as in locally administered
 436  * addresses used to set globally administered addresses
 437  */
 438 struct opa_veswport_iface_macs {
 439         __be16 start_idx;
 440         __be16 num_macs_in_msg;
 441         __be16 tot_macs_in_lst;
 442         __be16 gen_count;
 443         struct opa_vnic_iface_mac_entry entry[0];
 444 } __packed;
 445 
 446 /**
 447  * struct opa_vnic_vema_mad - Generic VEMA MAD
 448  * @mad_hdr: Generic MAD header
 449  * @rmpp_hdr: RMPP header for vendor specific MADs
 450  * @oui: Unique org identifier
 451  * @data: MAD data
 452  */
 453 struct opa_vnic_vema_mad {
 454         struct ib_mad_hdr  mad_hdr;
 455         struct ib_rmpp_hdr rmpp_hdr;
 456         u8                 reserved;
 457         u8                 oui[3];
 458         u8                 data[OPA_VNIC_EMA_DATA];
 459 };
 460 
 461 /**
 462  * struct opa_vnic_notice_attr - Generic Notice MAD
 463  * @gen_type: Generic/Specific bit and type of notice
 464  * @oui_1: Vendor ID byte 1
 465  * @oui_2: Vendor ID byte 2
 466  * @oui_3: Vendor ID byte 3
 467  * @trap_num: Trap number
 468  * @toggle_count: Notice toggle bit and count value
 469  * @issuer_lid: Trap issuer's lid
 470  * @issuer_gid: Issuer GID (only if Report method)
 471  * @raw_data: Trap message body
 472  */
 473 struct opa_vnic_notice_attr {
 474         u8     gen_type;
 475         u8     oui_1;
 476         u8     oui_2;
 477         u8     oui_3;
 478         __be16 trap_num;
 479         __be16 toggle_count;
 480         __be32 issuer_lid;
 481         __be32 reserved;
 482         u8     issuer_gid[16];
 483         u8     raw_data[64];
 484 } __packed;
 485 
 486 /**
 487  * struct opa_vnic_vema_mad_trap - Generic VEMA MAD Trap
 488  * @mad_hdr: Generic MAD header
 489  * @rmpp_hdr: RMPP header for vendor specific MADs
 490  * @oui: Unique org identifier
 491  * @notice: Notice structure
 492  */
 493 struct opa_vnic_vema_mad_trap {
 494         struct ib_mad_hdr            mad_hdr;
 495         struct ib_rmpp_hdr           rmpp_hdr;
 496         u8                           reserved;
 497         u8                           oui[3];
 498         struct opa_vnic_notice_attr  notice;
 499 };
 500 
 501 #endif /* _OPA_VNIC_ENCAP_H */

/* [<][>][^][v][top][bottom][index][help] */