linux/net/smc/smc_core.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Shared Memory Communications over RDMA (SMC-R) and RoCE
 *
 *  Definitions for SMC Connections, Link Groups and Links
 *
 *  Copyright IBM Corp. 2016
 *
 *  Author(s):  Ursula Braun <[email protected]>
 */

#ifndef _SMC_CORE_H
#define _SMC_CORE_H

#include <linux/atomic.h>
#include <linux/smc.h>
#include <linux/pci.h>
#include <rdma/ib_verbs.h>
#include <net/genetlink.h>
#include <net/smc.h>

#include "smc.h"
#include "smc_ib.h"
#include "smc_clc.h"

#define SMC_RMBS_PER_LGR_MAX
#define SMC_CONN_PER_LGR_MIN
#define SMC_CONN_PER_LGR_MAX
#define SMC_CONN_PER_LGR_PREFER

struct smc_lgr_list {};

enum smc_lgr_role {};

enum smc_link_state {};

#define SMC_WR_BUF_SIZE
#define SMC_WR_BUF_V2_SIZE

struct smc_wr_buf {};

struct smc_wr_v2_buf {};

#define SMC_WR_REG_MR_WAIT_TIME

enum smc_wr_reg_state {};

struct smc_rdma_sge {};

#define SMC_MAX_RDMA_WRITES

struct smc_rdma_sges {};

struct smc_rdma_wr {};

#define SMC_LGR_ID_SIZE

struct smc_link {};

/* For now we just allow one parallel link per link group. The SMC protocol
 * allows more (up to 8).
 */
#define SMC_LINKS_PER_LGR_MAX
#define SMC_SINGLE_LINK
#define SMC_LINKS_ADD_LNK_MIN
#define SMC_LINKS_ADD_LNK_MAX
#define SMC_LINKS_PER_LGR_MAX_PREFER

/* tx/rx buffer list element for sndbufs list and rmbs list of a lgr */
struct smc_buf_desc {};

struct smc_rtoken {};

#define SMC_BUF_MIN_SIZE
#define SMC_RMBE_SIZES
/* theoretically, the RFC states that largest size would be 512K,
 * i.e. compressed 5 and thus 6 sizes (0..5), despite
 * struct smc_clc_msg_accept_confirm.rmbe_size being a 4 bit value (0..15)
 */

struct smcd_dev;

enum smc_lgr_type {};

enum smcr_buf_type {};

enum smc_llc_flowtype {};

struct smc_llc_qentry;

struct smc_llc_flow {};

struct smc_link_group {};

struct smc_clc_msg_local;

#define GID_LIST_SIZE

struct smc_gidlist {};

struct smc_init_info_smcrv2 {};

#define SMC_MAX_V2_ISM_DEVS
				/* max # of proposed non-native ISM devices,
				 * which can't exceed the max # of CHID-GID
				 * entries in CLC proposal SMC-Dv2 extension.
				 */
struct smc_init_info {};

/* Find the connection associated with the given alert token in the link group.
 * To use rbtrees we have to implement our own search core.
 * Requires @conns_lock
 * @token	alert token to search for
 * @lgr		 link group to search in
 * Returns connection associated with token if found, NULL otherwise.
 */
static inline struct smc_connection *smc_lgr_find_conn(
	u32 token, struct smc_link_group *lgr)
{}

static inline bool smc_conn_lgr_valid(struct smc_connection *conn)
{}

/*
 * Returns true if the specified link is usable.
 *
 * usable means the link is ready to receive RDMA messages, map memory
 * on the link, etc. This doesn't ensure we are able to send RDMA messages
 * on this link, if sending RDMA messages is needed, use smc_link_sendable()
 */
static inline bool smc_link_usable(struct smc_link *lnk)
{}

/*
 * Returns true if the specified link is ready to receive AND send RDMA
 * messages.
 *
 * For the client side in first contact, the underlying QP may still in
 * RESET or RTR when the link state is ACTIVATING, checks in smc_link_usable()
 * is not strong enough. For those places that need to send any CDC or LLC
 * messages, use smc_link_sendable(), otherwise, use smc_link_usable() instead
 */
static inline bool smc_link_sendable(struct smc_link *lnk)
{}

static inline bool smc_link_active(struct smc_link *lnk)
{}

static inline void smc_gid_be16_convert(__u8 *buf, u8 *gid_raw)
{}

struct smc_pci_dev {};

static inline void smc_set_pci_values(struct pci_dev *pci_dev,
				      struct smc_pci_dev *smc_dev)
{}

struct smc_sock;
struct smc_clc_msg_accept_confirm;

void smc_lgr_cleanup_early(struct smc_link_group *lgr);
void smc_lgr_terminate_sched(struct smc_link_group *lgr);
void smc_lgr_hold(struct smc_link_group *lgr);
void smc_lgr_put(struct smc_link_group *lgr);
void smcr_port_add(struct smc_ib_device *smcibdev, u8 ibport);
void smcr_port_err(struct smc_ib_device *smcibdev, u8 ibport);
void smc_smcd_terminate(struct smcd_dev *dev, struct smcd_gid *peer_gid,
			unsigned short vlan);
void smc_smcd_terminate_all(struct smcd_dev *dev);
void smc_smcr_terminate_all(struct smc_ib_device *smcibdev);
int smc_buf_create(struct smc_sock *smc, bool is_smcd);
int smcd_buf_attach(struct smc_sock *smc);
int smc_uncompress_bufsize(u8 compressed);
int smc_rmb_rtoken_handling(struct smc_connection *conn, struct smc_link *link,
			    struct smc_clc_msg_accept_confirm *clc);
int smc_rtoken_add(struct smc_link *lnk, __be64 nw_vaddr, __be32 nw_rkey);
int smc_rtoken_delete(struct smc_link *lnk, __be32 nw_rkey);
void smc_rtoken_set(struct smc_link_group *lgr, int link_idx, int link_idx_new,
		    __be32 nw_rkey_known, __be64 nw_vaddr, __be32 nw_rkey);
void smc_rtoken_set2(struct smc_link_group *lgr, int rtok_idx, int link_id,
		     __be64 nw_vaddr, __be32 nw_rkey);
void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn);
void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn);
int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini);

void smc_conn_free(struct smc_connection *conn);
int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini);
int smc_core_init(void);
void smc_core_exit(void);

int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
		   u8 link_idx, struct smc_init_info *ini);
void smcr_link_clear(struct smc_link *lnk, bool log);
void smcr_link_hold(struct smc_link *lnk);
void smcr_link_put(struct smc_link *lnk);
void smc_switch_link_and_count(struct smc_connection *conn,
			       struct smc_link *to_lnk);
int smcr_buf_map_lgr(struct smc_link *lnk);
int smcr_buf_reg_lgr(struct smc_link *lnk);
void smcr_lgr_set_type(struct smc_link_group *lgr, enum smc_lgr_type new_type);
void smcr_lgr_set_type_asym(struct smc_link_group *lgr,
			    enum smc_lgr_type new_type, int asym_lnk_idx);
int smcr_link_reg_buf(struct smc_link *link, struct smc_buf_desc *rmb_desc);
struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
				  struct smc_link *from_lnk, bool is_dev_err);
void smcr_link_down_cond(struct smc_link *lnk);
void smcr_link_down_cond_sched(struct smc_link *lnk);
int smc_nl_get_sys_info(struct sk_buff *skb, struct netlink_callback *cb);
int smcr_nl_get_lgr(struct sk_buff *skb, struct netlink_callback *cb);
int smcr_nl_get_link(struct sk_buff *skb, struct netlink_callback *cb);
int smcd_nl_get_lgr(struct sk_buff *skb, struct netlink_callback *cb);

static inline struct smc_link_group *smc_get_lgr(struct smc_link *link)
{}
#endif