2018-01-29 13:11:31 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright 2017 6WIND S.A.
|
2018-03-20 19:20:35 +00:00
|
|
|
* Copyright 2017 Mellanox Technologies, Ltd
|
2017-10-12 12:29:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MLX4_PRM_H_
|
|
|
|
#define MLX4_PRM_H_
|
|
|
|
|
|
|
|
#include <rte_atomic.h>
|
|
|
|
#include <rte_branch_prediction.h>
|
|
|
|
#include <rte_byteorder.h>
|
|
|
|
|
|
|
|
/* Verbs headers do not support -pedantic. */
|
|
|
|
#ifdef PEDANTIC
|
|
|
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
|
|
|
#endif
|
|
|
|
#include <infiniband/mlx4dv.h>
|
|
|
|
#include <infiniband/verbs.h>
|
|
|
|
#ifdef PEDANTIC
|
|
|
|
#pragma GCC diagnostic error "-Wpedantic"
|
|
|
|
#endif
|
2018-07-10 10:45:54 +00:00
|
|
|
#include "mlx4_autoconf.h"
|
2017-10-12 12:29:56 +00:00
|
|
|
|
|
|
|
/* ConnectX-3 Tx queue basic block. */
|
|
|
|
#define MLX4_TXBB_SHIFT 6
|
|
|
|
#define MLX4_TXBB_SIZE (1 << MLX4_TXBB_SHIFT)
|
|
|
|
|
|
|
|
/* Typical TSO descriptor with 16 gather entries is 352 bytes. */
|
2018-01-04 16:12:03 +00:00
|
|
|
#define MLX4_MAX_SGE 32
|
|
|
|
#define MLX4_MAX_WQE_SIZE \
|
|
|
|
(MLX4_MAX_SGE * sizeof(struct mlx4_wqe_data_seg) + \
|
|
|
|
sizeof(struct mlx4_wqe_ctrl_seg))
|
2017-12-06 17:57:53 +00:00
|
|
|
#define MLX4_SEG_SHIFT 4
|
2017-10-12 12:29:56 +00:00
|
|
|
|
|
|
|
/* Send queue stamping/invalidating information. */
|
|
|
|
#define MLX4_SQ_STAMP_STRIDE 64
|
|
|
|
#define MLX4_SQ_STAMP_DWORDS (MLX4_SQ_STAMP_STRIDE / 4)
|
2017-12-06 17:57:53 +00:00
|
|
|
#define MLX4_SQ_OWNER_BIT 31
|
2017-10-12 12:29:56 +00:00
|
|
|
#define MLX4_SQ_STAMP_VAL 0x7fffffff
|
|
|
|
|
|
|
|
/* Work queue element (WQE) flags. */
|
2017-10-12 12:29:58 +00:00
|
|
|
#define MLX4_WQE_CTRL_IIP_HDR_CSUM (1 << 28)
|
|
|
|
#define MLX4_WQE_CTRL_IL4_HDR_CSUM (1 << 27)
|
2018-07-10 10:45:54 +00:00
|
|
|
#define MLX4_WQE_CTRL_RR (1 << 6)
|
2017-10-12 12:29:56 +00:00
|
|
|
|
2017-10-12 12:29:59 +00:00
|
|
|
/* CQE checksum flags. */
|
|
|
|
enum {
|
|
|
|
MLX4_CQE_L2_TUNNEL_IPV4 = (int)(1u << 25),
|
|
|
|
MLX4_CQE_L2_TUNNEL_L4_CSUM = (int)(1u << 26),
|
|
|
|
MLX4_CQE_L2_TUNNEL = (int)(1u << 27),
|
2017-11-05 17:26:56 +00:00
|
|
|
MLX4_CQE_L2_VLAN_MASK = (int)(3u << 29),
|
2017-10-12 12:29:59 +00:00
|
|
|
MLX4_CQE_L2_TUNNEL_IPOK = (int)(1u << 31),
|
|
|
|
};
|
|
|
|
|
2017-11-05 17:26:56 +00:00
|
|
|
/* CQE status flags. */
|
2018-06-28 06:30:28 +00:00
|
|
|
#define MLX4_CQE_STATUS_IPV6F (1 << 12)
|
2017-11-05 17:26:56 +00:00
|
|
|
#define MLX4_CQE_STATUS_IPV4 (1 << 22)
|
|
|
|
#define MLX4_CQE_STATUS_IPV4F (1 << 23)
|
|
|
|
#define MLX4_CQE_STATUS_IPV6 (1 << 24)
|
|
|
|
#define MLX4_CQE_STATUS_IPV4OPT (1 << 25)
|
|
|
|
#define MLX4_CQE_STATUS_TCP (1 << 26)
|
|
|
|
#define MLX4_CQE_STATUS_UDP (1 << 27)
|
|
|
|
#define MLX4_CQE_STATUS_PTYPE_MASK \
|
|
|
|
(MLX4_CQE_STATUS_IPV4 | \
|
|
|
|
MLX4_CQE_STATUS_IPV4F | \
|
|
|
|
MLX4_CQE_STATUS_IPV6 | \
|
|
|
|
MLX4_CQE_STATUS_IPV4OPT | \
|
|
|
|
MLX4_CQE_STATUS_TCP | \
|
|
|
|
MLX4_CQE_STATUS_UDP)
|
|
|
|
|
2017-10-12 12:29:56 +00:00
|
|
|
/* Send queue information. */
|
|
|
|
struct mlx4_sq {
|
2017-11-02 16:42:50 +00:00
|
|
|
volatile uint8_t *buf; /**< SQ buffer. */
|
|
|
|
volatile uint8_t *eob; /**< End of SQ buffer */
|
2017-12-06 17:57:53 +00:00
|
|
|
uint32_t size; /**< SQ size includes headroom. */
|
|
|
|
uint32_t remain_size; /**< Remaining WQE room in SQ (bytes). */
|
|
|
|
uint32_t owner_opcode;
|
|
|
|
/**< Default owner opcode with HW valid owner bit. */
|
|
|
|
uint32_t stamp; /**< Stamp value with an invalid HW owner bit. */
|
2019-04-10 18:41:18 +00:00
|
|
|
uint32_t *db; /**< Pointer to the doorbell. */
|
2019-04-01 21:15:53 +00:00
|
|
|
off_t uar_mmap_offset; /* UAR mmap offset for non-primary process. */
|
2017-10-12 12:29:56 +00:00
|
|
|
uint32_t doorbell_qpn; /**< qp number to write to the doorbell. */
|
|
|
|
};
|
|
|
|
|
2017-10-25 15:37:27 +00:00
|
|
|
/* Completion queue events, numbers and masks. */
|
|
|
|
#define MLX4_CQ_DB_GEQ_N_MASK 0x3
|
|
|
|
#define MLX4_CQ_DOORBELL 0x20
|
2017-10-25 15:37:26 +00:00
|
|
|
#define MLX4_CQ_DB_CI_MASK 0xffffff
|
|
|
|
|
2017-10-12 12:29:56 +00:00
|
|
|
/* Completion queue information. */
|
|
|
|
struct mlx4_cq {
|
2017-11-02 16:42:50 +00:00
|
|
|
volatile void *cq_uar; /**< CQ user access region. */
|
|
|
|
volatile void *cq_db_reg; /**< CQ doorbell register. */
|
|
|
|
volatile uint32_t *set_ci_db; /**< Pointer to the CQ doorbell. */
|
|
|
|
volatile uint32_t *arm_db; /**< Arming Rx events doorbell. */
|
|
|
|
volatile uint8_t *buf; /**< Pointer to the completion queue buffer. */
|
2017-10-12 12:29:56 +00:00
|
|
|
uint32_t cqe_cnt; /**< Number of entries in the queue. */
|
|
|
|
uint32_t cqe_64:1; /**< CQ entry size is 64 bytes. */
|
|
|
|
uint32_t cons_index; /**< Last queue entry that was handled. */
|
2017-10-25 15:37:27 +00:00
|
|
|
uint32_t cqn; /**< CQ number. */
|
|
|
|
int arm_sn; /**< Rx event counter. */
|
2017-10-12 12:29:56 +00:00
|
|
|
};
|
|
|
|
|
2018-07-10 10:45:54 +00:00
|
|
|
#ifndef HAVE_IBV_MLX4_WQE_LSO_SEG
|
|
|
|
/*
|
|
|
|
* WQE LSO segment structure.
|
|
|
|
* Defined here as backward compatibility for rdma-core v17 and below.
|
|
|
|
* Similar definition is found in infiniband/mlx4dv.h in rdma-core v18
|
|
|
|
* and above.
|
|
|
|
*/
|
|
|
|
struct mlx4_wqe_lso_seg {
|
|
|
|
rte_be32_t mss_hdr_size;
|
|
|
|
rte_be32_t header[];
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2017-10-12 12:29:56 +00:00
|
|
|
/**
|
|
|
|
* Retrieve a CQE entry from a CQ.
|
|
|
|
*
|
|
|
|
* cqe = cq->buf + cons_index * cqe_size + cqe_offset
|
|
|
|
*
|
|
|
|
* Where cqe_size is 32 or 64 bytes and cqe_offset is 0 or 32 (depending on
|
|
|
|
* cqe_size).
|
|
|
|
*
|
|
|
|
* @param cq
|
|
|
|
* CQ to retrieve entry from.
|
|
|
|
* @param index
|
|
|
|
* Entry index.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Pointer to CQE entry.
|
|
|
|
*/
|
2017-11-02 16:42:50 +00:00
|
|
|
static inline volatile struct mlx4_cqe *
|
2017-10-12 12:29:56 +00:00
|
|
|
mlx4_get_cqe(struct mlx4_cq *cq, uint32_t index)
|
|
|
|
{
|
2017-11-02 16:42:50 +00:00
|
|
|
return (volatile struct mlx4_cqe *)(cq->buf +
|
2017-10-12 12:29:56 +00:00
|
|
|
((index & (cq->cqe_cnt - 1)) <<
|
|
|
|
(5 + cq->cqe_64)) +
|
|
|
|
(cq->cqe_64 << 5));
|
|
|
|
}
|
|
|
|
|
2017-10-12 12:29:59 +00:00
|
|
|
/**
|
|
|
|
* Transpose a flag in a value.
|
|
|
|
*
|
|
|
|
* @param val
|
|
|
|
* Input value.
|
|
|
|
* @param from
|
|
|
|
* Flag to retrieve from input value.
|
|
|
|
* @param to
|
|
|
|
* Flag to set in output value.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Output value with transposed flag enabled if present on input.
|
|
|
|
*/
|
|
|
|
static inline uint64_t
|
|
|
|
mlx4_transpose(uint64_t val, uint64_t from, uint64_t to)
|
|
|
|
{
|
|
|
|
return (from >= to ?
|
|
|
|
(val & from) / (from / to) :
|
|
|
|
(val & from) * (to / from));
|
|
|
|
}
|
|
|
|
|
2017-10-12 12:29:56 +00:00
|
|
|
#endif /* MLX4_PRM_H_ */
|