5810N/A/*
5810N/A * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
5810N/A */
5810N/A
5810N/A/*
5810N/A * Redistribution and use in source and binary forms, with or without
5810N/A * modification, are permitted provided that the following conditions are met:
5810N/A *
5810N/A * 1. Redistributions of source code must retain the above copyright notice,
5810N/A * this list of conditions and the following disclaimer.
5810N/A *
5810N/A * 2. Redistributions in binary form must reproduce the above copyright notice,
5810N/A * this list of conditions and the following disclaimer in the documentation
5810N/A * and/or other materials provided with the distribution.
5810N/A *
5810N/A * 3. Neither the name of the copyright holder nor the names of its contributors
5810N/A * may be used to endorse or promote products derived from this software
5810N/A * without specific prior written permission.
5810N/A *
5810N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5810N/A * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5810N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5810N/A * ARE DISCLAIMED.
5810N/A * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
5810N/A * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
5810N/A * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5810N/A * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
5810N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5810N/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5810N/A * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5810N/A */
5810N/A
5810N/A/*
5810N/A * Userspace library for Oracle SIF Infiniband PCI Express
5810N/A * host channel adapter (HCA)
5810N/A *
5810N/A * sif_user.h: This file defines sif specific verbs extension request/response.
5810N/A * This file is included both from user space and kernel space so
5810N/A * it must not contain any kernel/user specific header file includes.
5810N/A */
5810N/A
5810N/A#ifndef _SIF_USER_H
5810N/A#define _SIF_USER_H
5810N/A
5810N/A#ifdef __cplusplus
5810N/Aextern "C" {
5810N/A#endif
5810N/A
5810N/A/*
5810N/A * Binary interface control:
5810N/A * Major version difference indicate backward incompatible changes
5810N/A * Minor version difference indicate that only a common subset of
5810N/A * features are available.
5810N/A *
5810N/A */
6477N/A#define SIF_UVERBS_ABI_MAJOR_VERSION 4
6477N/A#define SIF_UVERBS_ABI_MINOR_VERSION 0
5810N/A
5810N/A/* Bw comp */
5810N/A#define SIF_UVERBS_VERSION(x, y) ((x) << 8 | (y))
5810N/A#define SIF_UVERBS_ABI_VERSION \
5810N/A SIF_UVERBS_VERSION(SIF_UVERBS_ABI_MAJOR_VERSION, \
5810N/A SIF_UVERBS_ABI_MINOR_VERSION)
5810N/A
5810N/A/*
5810N/A * Bit 5 is not used by the PSIF_WC_OPCODE_FOO_BAR enums. Hence, using
5810N/A * it to indicate if QP has been destroyed before the CQE has been
5810N/A * polled
5810N/A */
5810N/A#define SIF_WC_QP_DESTROYED (1<<5)
5810N/A
5810N/A/*
5810N/A * This struct will be amended to an un-polled cqe, in case the QP has
5810N/A * been destroyed before the CQEs are polled. The information is
5810N/A * needed in order to handle flushing of SRQs and generation of Last
5810N/A * WQE Reached event.
5810N/A *
5810N/A * The information amended to the CQE is _only_ valid if the CQE has
5810N/A * been marked with SIF_WC_QP_DESTROYED.
5810N/A */
5810N/Astruct sif_post_mortem_qp_info_in_cqe {
5810N/A int was_srq;
5810N/A int srq_idx;
5810N/A int qpn; /* Could be useful for de-bugging/logging */
5810N/A};
5810N/A
5810N/A#ifndef __u32
5810N/A#define __u32 uint32_t
5810N/A#endif
5810N/A
5810N/A/*
5810N/A * These definitions must be kept in sync with
5810N/A * the ones in libsif's sif.h
5810N/A */
5810N/Atypedef enum sif_vendor_flags {
5810N/A /*
5810N/A * Use special mmu setup in associated mappings
5810N/A * NB! Modifies input to ibv_reg_mr!
5810N/A */
5810N/A MMU_special = 0x1,
5810N/A /* Trigger send queue mode instead of using VCBs */
5810N/A SQ_mode = 0x2,
5810N/A /* Enable EPS-A proxying - requires the eps_a field to be set */
5810N/A proxy_mode = 0x4,
5810N/A /* Enable kernel mode - default is direct user mode */
5810N/A SVF_kernel_mode = 0x8,
5810N/A /* Value to use for the qosl bit in the qp state */
5810N/A tsu_qosl = 0x10
5810N/A} sif_vendor_flags_t;
5810N/A
5810N/Atypedef enum sif_mem_type {
5810N/A SIFMT_BYPASS, /* Use MMU bypass in associated mmu contexts */
5810N/A SIFMT_UMEM, /* Normal default umem based user level mapping */
5810N/A /* Mapping of user memory based on the process' own page table */
5810N/A SIFMT_UMEM_SPT,
5810N/A /*
5810N/A * A large (sparsely populated) SIF only vaddr mapping
5810N/A * (used for a.o.SQ CMPL)
5810N/A */
5810N/A SIFMT_CS,
5810N/A /* Special mapping of a vaddr range to a single page (see #1931) */
5810N/A SIFMT_ZERO,
5810N/A /* MMU bypass mapped read only for device (requires IOMMU enabled) */
5810N/A SIFMT_BYPASS_RO,
5810N/A /* GVA2GPA mapped read only for device (requires IOMMU enabled) */
5810N/A SIFMT_UMEM_RO,
5810N/A /* Use GVA2GPA but input is based on a phys_buf array instead of umem */
5810N/A SIFMT_PHYS,
5810N/A /*
5810N/A * Use GVA2GPA but input is based on a page address array instead
5810N/A * of umem
5810N/A */
5810N/A SIFMT_FMR,
5810N/A /* Similar to FMR but input pages are 2M instead of 4K */
5810N/A SIFMT_2M,
5810N/A /* Bypass mode - special kernel mappings with no memory allocated */
5810N/A SIFMT_NOMEM,
5810N/A /* sif_kmem based 4K page allocation - mostly for test purposes */
5810N/A SIFMT_4K,
5810N/A SIFMT_RDMA,
5810N/A SIFMT_PTONLY,
5810N/A SIFMT_CTRL_PT,
5810N/A SIFMT_MAX
5810N/A} sif_mem_type_t;
5810N/A
5810N/Atypedef enum sif_proxy_type {
5810N/A SIFPX_OFF, /* Default value - no proxying */
5810N/A SIFPX_EPSA_1,
5810N/A SIFPX_EPSA_2,
5810N/A SIFPX_EPSA_3,
5810N/A SIFPX_EPSA_4
5810N/A} sif_proxy_type_t;
5810N/A
5810N/A
5810N/Atypedef enum sif_flush_type {
5810N/A NO_FLUSH,
5810N/A FLUSH_SQ,
5810N/A FLUSH_RQ
5810N/A} sif_flush_type_t;
5810N/A
5810N/A/* These should be multiple of 64 bytes and densely packed: */
5810N/A
5810N/Atypedef struct sif_get_context_ext {
5810N/A uint32_t abi_version;
5810N/A uint32_t reserved;
5810N/A} sif_get_context_ext_t;
5810N/A
5810N/Atypedef struct sif_get_context_resp_ext {
5810N/A /* Distance in bytes between descriptor elements */
5810N/A uint32_t sq_sw_ext_sz;
5810N/A uint32_t rq_ext_sz;
5810N/A uint32_t cq_ext_sz;
5810N/A /* Number of entries per block of descriptors */
5810N/A uint32_t sq_entry_per_block;
5810N/A uint32_t rq_entry_per_block;
5810N/A uint32_t cq_entry_per_block;
5810N/A /* Dist between sq hw descriptor elms, from >= v.3.3 */
5810N/A uint32_t sq_hw_ext_sz;
5810N/A uint32_t reserved;
5810N/A} sif_get_context_resp_ext_t;
5810N/A
5810N/Atypedef struct sif_alloc_pd_resp_ext {
5810N/A /* The virtual collect buffer to use by this protection domain */
5810N/A int cb_idx;
5810N/A uint32_t reserved;
5810N/A} sif_alloc_pd_resp_ext_t;
5810N/A
5810N/Atypedef struct sif_create_cq_ext {
5810N/A enum sif_vendor_flags flags;
5810N/A enum sif_proxy_type proxy;
5810N/A} sif_create_cq_ext_t;
5810N/A
5810N/Atypedef struct sif_create_cq_resp_ext {
5810N/A uint32_t cq_idx;
5810N/A uint32_t reserved;
5810N/A uint32_t cq_entries;
5810N/A} sif_create_cq_resp_ext_t;
5810N/A
5810N/A
5810N/Atypedef struct sif_create_qp_ext {
5810N/A enum sif_vendor_flags flags;
5810N/A enum sif_proxy_type proxy;
5810N/A} sif_create_qp_ext_t;
5810N/A
5810N/Atypedef struct sif_create_qp_resp_ext {
5810N/A uint32_t qp_idx;
5810N/A uint32_t rq_idx;
5810N/A uint32_t magic;
5810N/A uint32_t sq_extent;
5810N/A uint32_t rq_extent;
5810N/A uint32_t sq_sgl_offset;
5810N/A uint32_t sq_mr_idx;
5810N/A uint32_t reserved;
5810N/A uint64_t sq_dma_handle;
5810N/A} sif_create_qp_resp_ext_t;
5810N/A
5810N/Atypedef struct sif_modify_qp_ext
5810N/A{
5810N/A enum sif_flush_type flush;
5810N/A uint32_t reserved;
5810N/A} sif_modify_qp_ext_t;
5810N/A
5810N/A
5810N/Atypedef struct sif_reg_mr_ext {
5810N/A enum sif_vendor_flags flags;
5810N/A enum sif_mem_type mem_type;
5810N/A /* Used by gva_type SIFGT_ZERO - indicates psif vmap length */
5810N/A uint64_t map_length;
5810N/A /* Used by gva_type SIFGT_ZERO - indicates valid memory length */
5810N/A uint64_t phys_length;
5810N/A} sif_reg_mr_ext_t;
5810N/A
5810N/Atypedef struct sif_reg_mr_resp_ext {
5810N/A uint64_t uv2dma; /* Used to support bypass mode */
5810N/A} sif_reg_mr_resp_ext_t;
5810N/A
5810N/Atypedef struct sif_create_srq_ext {
5810N/A enum sif_vendor_flags flags;
5810N/A uint32_t res1;
5810N/A} sif_create_srq_ext_t;
5810N/A
5810N/Atypedef struct sif_create_srq_resp_ext {
5810N/A uint32_t index;
5810N/A uint32_t extent;
5810N/A} sif_create_srq_resp_ext_t;
5810N/A
5810N/Atypedef struct sif_create_ah_resp_ext {
5810N/A uint32_t index;
5810N/A uint32_t reserved;
5810N/A} sif_create_ah_resp_ext_t;
5810N/A
5810N/A/* mmap offset encoding */
5810N/A
5810N/Aenum sif_mmap_cmd {
5810N/A SIF_MAP_NONE, /* No mapping */
5810N/A /* Map a collect buffer - cb index as argument */
5810N/A SIF_MAP_CB,
5810N/A /* Map an SQ, RQ or CQ (entries) - queue index as argument */
5810N/A SIF_MAP_SQ,
5810N/A SIF_MAP_RQ,
5810N/A SIF_MAP_CQ,
5810N/A /*
5810N/A * Map a block of SQ, RQ or CQ software descriptors -
5810N/A * block index as argument
5810N/A */
5810N/A SIF_MAP_SQ_SW,
5810N/A SIF_MAP_RQ_SW,
5810N/A SIF_MAP_CQ_SW,
5810N/A /* These are safe to map read-only (so far only sq_hw in use) */
5810N/A /* Map a block of qp descriptors - block index as argument */
5810N/A SIF_MAP_QP,
5810N/A /*
5810N/A * Map a block of SQ, RQ or CQ hardware descriptors -
5810N/A * block index as argument
5810N/A */
5810N/A SIF_MAP_SQ_HW,
5810N/A SIF_MAP_RQ_HW,
5810N/A SIF_MAP_CQ_HW,
5810N/A SIF_MAP_MAX
5810N/A};
5810N/A
5810N/Astatic inline uint64_t mmap_set_cmd(enum sif_mmap_cmd cmd, uint32_t index)
5810N/A{
5810N/A return ((uint64_t)cmd << 44) | ((uint64_t)index << 13);
5810N/A}
5810N/A
5810N/Astatic inline void mmap_get_cmd(uint64_t offset, enum sif_mmap_cmd *cmdp,
5810N/A uint32_t *idxp)
5810N/A{
5810N/A *cmdp = (offset >> 44) & 0xff;
5810N/A *idxp = (offset >> 13) & 0x7fffffff;
5810N/A}
5810N/A
5810N/A#ifdef __cplusplus
5810N/A}
5810N/A#endif
5810N/A
5810N/A#endif /* _SIF_USER_H */