linux/drivers/infiniband/sw/siw/siw.h

/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */

/* Authors: Bernard Metzler <[email protected]> */
/* Copyright (c) 2008-2019, IBM Corporation */

#ifndef _SIW_H
#define _SIW_H

#include <rdma/ib_verbs.h>
#include <rdma/restrack.h>
#include <linux/socket.h>
#include <linux/skbuff.h>
#include <crypto/hash.h>
#include <linux/crc32.h>
#include <linux/crc32c.h>

#include <rdma/siw-abi.h>
#include "iwarp.h"

#define SIW_VENDOR_ID
#define SIW_VENDORT_PART_ID
#define SIW_MAX_QP
#define SIW_MAX_QP_WR
#define SIW_MAX_ORD_QP
#define SIW_MAX_IRD_QP
#define SIW_MAX_SGE_PBL
#define SIW_MAX_SGE_RD
#define SIW_MAX_CQ
#define SIW_MAX_CQE
#define SIW_MAX_MR
#define SIW_MAX_PD
#define SIW_MAX_MW
#define SIW_MAX_SRQ
#define SIW_MAX_SRQ_WR
#define SIW_MAX_CONTEXT

/* Min number of bytes for using zero copy transmit */
#define SENDPAGE_THRESH

/* Maximum number of frames which can be send in one SQ processing */
#define SQ_USER_MAXBURST

/* Maximum number of consecutive IRQ elements which get served
 * if SQ has pending work. Prevents starving local SQ processing
 * by serving peer Read Requests.
 */
#define SIW_IRQ_MAXBURST_SQ_ACTIVE

struct siw_dev_cap {};

struct siw_pd {};

struct siw_device {};

struct siw_ucontext {};

/*
 * The RDMA core does not define LOCAL_READ access, which is always
 * enabled implictely.
 */
#define IWARP_ACCESS_MASK

/*
 * siw presentation of user memory registered as source
 * or target of RDMA operations.
 */

struct siw_page_chunk {};

struct siw_umem {};

struct siw_pble {};

struct siw_pbl {};

/*
 * Generic memory representation for registered siw memory.
 * Memory lookup always via higher 24 bit of STag (STag index).
 */
struct siw_mem {};

struct siw_mr {};

/*
 * Error codes for local or remote
 * access to registered memory
 */
enum siw_access_state {};

enum siw_wr_state {};

/* The WQE currently being processed (RX or TX) */
struct siw_wqe {};

struct siw_cq {};

enum siw_qp_state {};

enum siw_qp_flags {};

enum siw_qp_attr_mask {};

struct siw_srq {};

struct siw_qp_attrs {};

enum siw_tx_ctx {};

enum siw_rx_state {};

struct siw_rx_stream {};

struct siw_rx_fpdu {};

/*
 * Shorthands for short packets w/o payload
 * to be transmitted more efficient.
 */
struct siw_send_pkt {};

struct siw_write_pkt {};

struct siw_rreq_pkt {};

struct siw_rresp_pkt {};

struct siw_iwarp_tx {};

struct siw_qp {};

/* helper macros */
#define rx_qp(rx)
#define tx_qp(tx)
#define tx_wqe(qp)
#define rx_wqe(rctx)
#define rx_mem(rctx)
#define tx_type(wqe)
#define rx_type(wqe)
#define tx_flags(wqe)

struct iwarp_msg_info {};

struct siw_user_mmap_entry {};

/* Global siw parameters. Currently set in siw_main.c */
extern const bool zcopy_tx;
extern const bool try_gso;
extern const bool loopback_enabled;
extern const bool mpa_crc_required;
extern const bool mpa_crc_strict;
extern const bool siw_tcp_nagle;
extern u_char mpa_version;
extern const bool peer_to_peer;
extern struct task_struct *siw_tx_thread[];

extern struct crypto_shash *siw_crypto_shash;
extern struct iwarp_msg_info iwarp_pktinfo[RDMAP_TERMINATE + 1];

/* QP general functions */
int siw_qp_modify(struct siw_qp *qp, struct siw_qp_attrs *attr,
		  enum siw_qp_attr_mask mask);
int siw_qp_mpa_rts(struct siw_qp *qp, enum mpa_v2_ctrl ctrl);
void siw_qp_llp_close(struct siw_qp *qp);
void siw_qp_cm_drop(struct siw_qp *qp, int schedule);
void siw_send_terminate(struct siw_qp *qp);

void siw_qp_get_ref(struct ib_qp *qp);
void siw_qp_put_ref(struct ib_qp *qp);
int siw_qp_add(struct siw_device *sdev, struct siw_qp *qp);
void siw_free_qp(struct kref *ref);

void siw_init_terminate(struct siw_qp *qp, enum term_elayer layer,
			u8 etype, u8 ecode, int in_tx);
enum ddp_ecode siw_tagged_error(enum siw_access_state state);
enum rdmap_ecode siw_rdmap_error(enum siw_access_state state);

void siw_read_to_orq(struct siw_sqe *rreq, struct siw_sqe *sqe);
int siw_sqe_complete(struct siw_qp *qp, struct siw_sqe *sqe, u32 bytes,
		     enum siw_wc_status status);
int siw_rqe_complete(struct siw_qp *qp, struct siw_rqe *rqe, u32 bytes,
		     u32 inval_stag, enum siw_wc_status status);
void siw_qp_llp_data_ready(struct sock *sk);
void siw_qp_llp_write_space(struct sock *sk);

/* QP TX path functions */
int siw_create_tx_threads(void);
void siw_stop_tx_threads(void);
int siw_run_sq(void *arg);
int siw_qp_sq_process(struct siw_qp *qp);
int siw_sq_start(struct siw_qp *qp);
int siw_activate_tx(struct siw_qp *qp);
int siw_get_tx_cpu(struct siw_device *sdev);
void siw_put_tx_cpu(int cpu);

/* QP RX path functions */
int siw_proc_send(struct siw_qp *qp);
int siw_proc_rreq(struct siw_qp *qp);
int siw_proc_rresp(struct siw_qp *qp);
int siw_proc_write(struct siw_qp *qp);
int siw_proc_terminate(struct siw_qp *qp);

int siw_tcp_rx_data(read_descriptor_t *rd_desc, struct sk_buff *skb,
		    unsigned int off, size_t len);

static inline void set_rx_fpdu_context(struct siw_qp *qp, u8 opcode)
{}

static inline struct siw_ucontext *to_siw_ctx(struct ib_ucontext *base_ctx)
{}

static inline struct siw_qp *to_siw_qp(struct ib_qp *base_qp)
{}

static inline struct siw_cq *to_siw_cq(struct ib_cq *base_cq)
{}

static inline struct siw_srq *to_siw_srq(struct ib_srq *base_srq)
{}

static inline struct siw_device *to_siw_dev(struct ib_device *base_dev)
{}

static inline struct siw_mr *to_siw_mr(struct ib_mr *base_mr)
{}

static inline struct siw_user_mmap_entry *
to_siw_mmap_entry(struct rdma_user_mmap_entry *rdma_mmap)
{}

static inline struct siw_qp *siw_qp_id2obj(struct siw_device *sdev, int id)
{}

static inline u32 qp_id(struct siw_qp *qp)
{}

static inline void siw_qp_get(struct siw_qp *qp)
{}

static inline void siw_qp_put(struct siw_qp *qp)
{}

static inline int siw_sq_empty(struct siw_qp *qp)
{}

static inline struct siw_sqe *sq_get_next(struct siw_qp *qp)
{}

static inline struct siw_sqe *orq_get_current(struct siw_qp *qp)
{}

static inline struct siw_sqe *orq_get_free(struct siw_qp *qp)
{}

static inline int siw_orq_empty(struct siw_qp *qp)
{}

static inline struct siw_sqe *irq_alloc_free(struct siw_qp *qp)
{}

static inline __wsum siw_csum_update(const void *buff, int len, __wsum sum)
{}

static inline __wsum siw_csum_combine(__wsum csum, __wsum csum2, int offset,
				      int len)
{}

static inline void siw_crc_skb(struct siw_rx_stream *srx, unsigned int len)
{}

#define siw_dbg(ibdev, fmt, ...)

#define siw_dbg_qp(qp, fmt, ...)

#define siw_dbg_cq(cq, fmt, ...)

#define siw_dbg_pd(pd, fmt, ...)

#define siw_dbg_mem(mem, fmt, ...)

#define siw_dbg_cep(cep, fmt, ...)

void siw_cq_flush(struct siw_cq *cq);
void siw_sq_flush(struct siw_qp *qp);
void siw_rq_flush(struct siw_qp *qp);
int siw_reap_cqe(struct siw_cq *cq, struct ib_wc *wc);

#endif