Unverified Commit 7a00ec8d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!845 [OLK-5.10] net/smc: Introduce generic netlink interface for diagnostic purposes

Merge Pull Request from: @zengyingyu11 
 
Content:
merge mainline net/smc generic netlink interface patches for connection diagnosis

Related issue:
https://gitee.com/openeuler/kernel/issues/I78IFM 
 
Link:https://gitee.com/openeuler/kernel/pulls/845

 

Reviewed-by: default avatarJiao Litao <jiaolitao@sangfor.com.cn>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 717f8e51 7c3101c4
Loading
Loading
Loading
Loading
+209 −0
Original line number Diff line number Diff line
@@ -33,4 +33,213 @@ enum { /* SMC PNET Table commands */
#define SMCR_GENL_FAMILY_NAME		"SMC_PNETID"
#define SMCR_GENL_FAMILY_VERSION	1

/* gennetlink interface to access non-socket information from SMC module */
#define SMC_GENL_FAMILY_NAME		"SMC_GEN_NETLINK"
#define SMC_GENL_FAMILY_VERSION		1

#define SMC_PCI_ID_STR_LEN		16 /* Max length of pci id string */

/* SMC_GENL_FAMILY commands */
enum {
	SMC_NETLINK_GET_SYS_INFO = 1,
	SMC_NETLINK_GET_LGR_SMCR,
	SMC_NETLINK_GET_LINK_SMCR,
	SMC_NETLINK_GET_LGR_SMCD,
	SMC_NETLINK_GET_DEV_SMCD,
	SMC_NETLINK_GET_DEV_SMCR,
	SMC_NETLINK_GET_STATS,
	SMC_NETLINK_GET_FBACK_STATS,
};

/* SMC_GENL_FAMILY top level attributes */
enum {
	SMC_GEN_UNSPEC,
	SMC_GEN_SYS_INFO,		/* nest */
	SMC_GEN_LGR_SMCR,		/* nest */
	SMC_GEN_LINK_SMCR,		/* nest */
	SMC_GEN_LGR_SMCD,		/* nest */
	SMC_GEN_DEV_SMCD,		/* nest */
	SMC_GEN_DEV_SMCR,		/* nest */
	SMC_GEN_STATS,			/* nest */
	SMC_GEN_FBACK_STATS,		/* nest */
	__SMC_GEN_MAX,
	SMC_GEN_MAX = __SMC_GEN_MAX - 1
};

/* SMC_GEN_SYS_INFO attributes */
enum {
	SMC_NLA_SYS_UNSPEC,
	SMC_NLA_SYS_VER,		/* u8 */
	SMC_NLA_SYS_REL,		/* u8 */
	SMC_NLA_SYS_IS_ISM_V2,		/* u8 */
	SMC_NLA_SYS_LOCAL_HOST,		/* string */
	SMC_NLA_SYS_SEID,		/* string */
	__SMC_NLA_SYS_MAX,
	SMC_NLA_SYS_MAX = __SMC_NLA_SYS_MAX - 1
};

/* SMC_NLA_LGR_V2 nested attributes */
enum {
	SMC_NLA_LGR_V2_VER,		/* u8 */
	SMC_NLA_LGR_V2_REL,		/* u8 */
	SMC_NLA_LGR_V2_OS,		/* u8 */
	SMC_NLA_LGR_V2_NEG_EID,		/* string */
	SMC_NLA_LGR_V2_PEER_HOST,	/* string */
};

/* SMC_GEN_LGR_SMCR attributes */
enum {
	SMC_NLA_LGR_R_UNSPEC,
	SMC_NLA_LGR_R_ID,		/* u32 */
	SMC_NLA_LGR_R_ROLE,		/* u8 */
	SMC_NLA_LGR_R_TYPE,		/* u8 */
	SMC_NLA_LGR_R_PNETID,		/* string */
	SMC_NLA_LGR_R_VLAN_ID,		/* u8 */
	SMC_NLA_LGR_R_CONNS_NUM,	/* u32 */
	__SMC_NLA_LGR_R_MAX,
	SMC_NLA_LGR_R_MAX = __SMC_NLA_LGR_R_MAX - 1
};

/* SMC_GEN_LINK_SMCR attributes */
enum {
	SMC_NLA_LINK_UNSPEC,
	SMC_NLA_LINK_ID,		/* u8 */
	SMC_NLA_LINK_IB_DEV,		/* string */
	SMC_NLA_LINK_IB_PORT,		/* u8 */
	SMC_NLA_LINK_GID,		/* string */
	SMC_NLA_LINK_PEER_GID,		/* string */
	SMC_NLA_LINK_CONN_CNT,		/* u32 */
	SMC_NLA_LINK_NET_DEV,		/* u32 */
	SMC_NLA_LINK_UID,		/* u32 */
	SMC_NLA_LINK_PEER_UID,		/* u32 */
	SMC_NLA_LINK_STATE,		/* u32 */
	__SMC_NLA_LINK_MAX,
	SMC_NLA_LINK_MAX = __SMC_NLA_LINK_MAX - 1
};

/* SMC_GEN_LGR_SMCD attributes */
enum {
	SMC_NLA_LGR_D_UNSPEC,
	SMC_NLA_LGR_D_ID,		/* u32 */
	SMC_NLA_LGR_D_GID,		/* u64 */
	SMC_NLA_LGR_D_PEER_GID,		/* u64 */
	SMC_NLA_LGR_D_VLAN_ID,		/* u8 */
	SMC_NLA_LGR_D_CONNS_NUM,	/* u32 */
	SMC_NLA_LGR_D_PNETID,		/* string */
	SMC_NLA_LGR_D_CHID,		/* u16 */
	SMC_NLA_LGR_D_PAD,		/* flag */
	SMC_NLA_LGR_V2,			/* nest */
	__SMC_NLA_LGR_D_MAX,
	SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX - 1
};

/* SMC_NLA_DEV_PORT nested attributes */
enum {
	SMC_NLA_DEV_PORT_UNSPEC,
	SMC_NLA_DEV_PORT_PNET_USR,	/* u8 */
	SMC_NLA_DEV_PORT_PNETID,	/* string */
	SMC_NLA_DEV_PORT_NETDEV,	/* u32 */
	SMC_NLA_DEV_PORT_STATE,		/* u8 */
	SMC_NLA_DEV_PORT_VALID,		/* u8 */
	SMC_NLA_DEV_PORT_LNK_CNT,	/* u32 */
	__SMC_NLA_DEV_PORT_MAX,
	SMC_NLA_DEV_PORT_MAX = __SMC_NLA_DEV_PORT_MAX - 1
};

/* SMC_GEN_DEV_SMCD and SMC_GEN_DEV_SMCR attributes */
enum {
	SMC_NLA_DEV_UNSPEC,
	SMC_NLA_DEV_USE_CNT,		/* u32 */
	SMC_NLA_DEV_IS_CRIT,		/* u8 */
	SMC_NLA_DEV_PCI_FID,		/* u32 */
	SMC_NLA_DEV_PCI_CHID,		/* u16 */
	SMC_NLA_DEV_PCI_VENDOR,		/* u16 */
	SMC_NLA_DEV_PCI_DEVICE,		/* u16 */
	SMC_NLA_DEV_PCI_ID,		/* string */
	SMC_NLA_DEV_PORT,		/* nest */
	SMC_NLA_DEV_PORT2,		/* nest */
	SMC_NLA_DEV_IB_NAME,		/* string */
	__SMC_NLA_DEV_MAX,
	SMC_NLA_DEV_MAX = __SMC_NLA_DEV_MAX - 1
};

/* SMC_NLA_STATS_T_TX(RX)_RMB_SIZE nested attributes */
/* SMC_NLA_STATS_TX(RX)PLOAD_SIZE nested attributes */
enum {
	SMC_NLA_STATS_PLOAD_PAD,
	SMC_NLA_STATS_PLOAD_8K,		/* u64 */
	SMC_NLA_STATS_PLOAD_16K,	/* u64 */
	SMC_NLA_STATS_PLOAD_32K,	/* u64 */
	SMC_NLA_STATS_PLOAD_64K,	/* u64 */
	SMC_NLA_STATS_PLOAD_128K,	/* u64 */
	SMC_NLA_STATS_PLOAD_256K,	/* u64 */
	SMC_NLA_STATS_PLOAD_512K,	/* u64 */
	SMC_NLA_STATS_PLOAD_1024K,	/* u64 */
	SMC_NLA_STATS_PLOAD_G_1024K,	/* u64 */
	__SMC_NLA_STATS_PLOAD_MAX,
	SMC_NLA_STATS_PLOAD_MAX = __SMC_NLA_STATS_PLOAD_MAX - 1
};

/* SMC_NLA_STATS_T_TX(RX)_RMB_STATS nested attributes */
enum {
	SMC_NLA_STATS_RMB_PAD,
	SMC_NLA_STATS_RMB_SIZE_SM_PEER_CNT,	/* u64 */
	SMC_NLA_STATS_RMB_SIZE_SM_CNT,		/* u64 */
	SMC_NLA_STATS_RMB_FULL_PEER_CNT,	/* u64 */
	SMC_NLA_STATS_RMB_FULL_CNT,		/* u64 */
	SMC_NLA_STATS_RMB_REUSE_CNT,		/* u64 */
	SMC_NLA_STATS_RMB_ALLOC_CNT,		/* u64 */
	SMC_NLA_STATS_RMB_DGRADE_CNT,		/* u64 */
	__SMC_NLA_STATS_RMB_MAX,
	SMC_NLA_STATS_RMB_MAX = __SMC_NLA_STATS_RMB_MAX - 1
};

/* SMC_NLA_STATS_SMCD_TECH and _SMCR_TECH nested attributes */
enum {
	SMC_NLA_STATS_T_PAD,
	SMC_NLA_STATS_T_TX_RMB_SIZE,	/* nest */
	SMC_NLA_STATS_T_RX_RMB_SIZE,	/* nest */
	SMC_NLA_STATS_T_TXPLOAD_SIZE,	/* nest */
	SMC_NLA_STATS_T_RXPLOAD_SIZE,	/* nest */
	SMC_NLA_STATS_T_TX_RMB_STATS,	/* nest */
	SMC_NLA_STATS_T_RX_RMB_STATS,	/* nest */
	SMC_NLA_STATS_T_CLNT_V1_SUCC,	/* u64 */
	SMC_NLA_STATS_T_CLNT_V2_SUCC,	/* u64 */
	SMC_NLA_STATS_T_SRV_V1_SUCC,	/* u64 */
	SMC_NLA_STATS_T_SRV_V2_SUCC,	/* u64 */
	SMC_NLA_STATS_T_SENDPAGE_CNT,	/* u64 */
	SMC_NLA_STATS_T_SPLICE_CNT,	/* u64 */
	SMC_NLA_STATS_T_CORK_CNT,	/* u64 */
	SMC_NLA_STATS_T_NDLY_CNT,	/* u64 */
	SMC_NLA_STATS_T_URG_DATA_CNT,	/* u64 */
	SMC_NLA_STATS_T_RX_BYTES,	/* u64 */
	SMC_NLA_STATS_T_TX_BYTES,	/* u64 */
	SMC_NLA_STATS_T_RX_CNT,		/* u64 */
	SMC_NLA_STATS_T_TX_CNT,		/* u64 */
	__SMC_NLA_STATS_T_MAX,
	SMC_NLA_STATS_T_MAX = __SMC_NLA_STATS_T_MAX - 1
};

/* SMC_GEN_STATS attributes */
enum {
	SMC_NLA_STATS_PAD,
	SMC_NLA_STATS_SMCD_TECH,	/* nest */
	SMC_NLA_STATS_SMCR_TECH,	/* nest */
	SMC_NLA_STATS_CLNT_HS_ERR_CNT,	/* u64 */
	SMC_NLA_STATS_SRV_HS_ERR_CNT,	/* u64 */
	__SMC_NLA_STATS_MAX,
	SMC_NLA_STATS_MAX = __SMC_NLA_STATS_MAX - 1
};

/* SMC_GEN_FBACK_STATS attributes */
enum {
	SMC_NLA_FBACK_STATS_PAD,
	SMC_NLA_FBACK_STATS_TYPE,	/* u8 */
	SMC_NLA_FBACK_STATS_SRV_CNT,	/* u64 */
	SMC_NLA_FBACK_STATS_CLNT_CNT,	/* u64 */
	SMC_NLA_FBACK_STATS_RSN_CODE,	/* u32 */
	SMC_NLA_FBACK_STATS_RSN_CNT,	/* u16 */
	__SMC_NLA_FBACK_STATS_MAX,
	SMC_NLA_FBACK_STATS_MAX = __SMC_NLA_FBACK_STATS_MAX - 1
};
#endif /* _UAPI_LINUX_SMC_H */
+1 −1
Original line number Diff line number Diff line
@@ -2,5 +2,5 @@
obj-$(CONFIG_SMC)	+= smc.o
obj-$(CONFIG_SMC_DIAG)	+= smc_diag.o
smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o
smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o
smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o smc_stats.o
smc-$(CONFIG_SYSCTL) 	+= smc_sysctl.o
+83 −27
Original line number Diff line number Diff line
@@ -45,10 +45,12 @@
#include "smc_ib.h"
#include "smc_ism.h"
#include "smc_pnet.h"
#include "smc_netlink.h"
#include "smc_tx.h"
#include "smc_rx.h"
#include "smc_close.h"
#include "smc_sysctl.h"
#include "smc_stats.h"

static DEFINE_MUTEX(smc_server_lgr_pending);	/* serialize link group
						 * creation on server
@@ -622,6 +624,37 @@ static void smc_link_save_peer_info(struct smc_link *link,
	link->peer_mtu = clc->r0.qp_mtu;
}

static void smc_stat_inc_fback_rsn_cnt(struct smc_sock *smc,
				       struct smc_stats_fback *fback_arr)
{
	int cnt;

	for (cnt = 0; cnt < SMC_MAX_FBACK_RSN_CNT; cnt++) {
		if (fback_arr[cnt].fback_code == smc->fallback_rsn) {
			fback_arr[cnt].count++;
			break;
		}
		if (!fback_arr[cnt].fback_code) {
			fback_arr[cnt].fback_code = smc->fallback_rsn;
			fback_arr[cnt].count++;
			break;
		}
	}
}

static void smc_stat_fallback(struct smc_sock *smc)
{
	mutex_lock(&smc_stat_fback_rsn);
	if (smc->listen_smc) {
		smc_stat_inc_fback_rsn_cnt(smc, fback_rsn.srv);
		fback_rsn.srv_fback_cnt++;
	} else {
		smc_stat_inc_fback_rsn_cnt(smc, fback_rsn.clnt);
		fback_rsn.clnt_fback_cnt++;
	}
	mutex_unlock(&smc_stat_fback_rsn);
}

/* must be called under rcu read lock */
static void smc_fback_wakeup_waitqueue(struct smc_sock *smc, void *key)
{
@@ -747,7 +780,7 @@ static void smc_fback_replace_callbacks(struct smc_sock *smc)
	write_unlock_bh(&clcsk->sk_callback_lock);
}

static int smc_switch_to_fallback(struct smc_sock *smc)
static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code)
{
	int rc = 0;

@@ -758,6 +791,8 @@ static int smc_switch_to_fallback(struct smc_sock *smc)
	}

	smc->use_fallback = true;
	smc->fallback_rsn = reason_code;
	smc_stat_fallback(smc);
	if (smc->sk.sk_socket && smc->sk.sk_socket->file) {
		smc->clcsock->file = smc->sk.sk_socket->file;
		smc->clcsock->file->private_data = smc->clcsock;
@@ -780,13 +815,12 @@ static int smc_connect_fallback(struct smc_sock *smc, int reason_code)
{
	int rc = 0;

	rc = smc_switch_to_fallback(smc);
	rc = smc_switch_to_fallback(smc, reason_code);
	if (rc) { /* fallback fails */
		if (smc->sk.sk_state == SMC_INIT)
			sock_put(&smc->sk); /* passive closing */
		return rc;
	}
	smc->fallback_rsn = reason_code;
	smc_copy_sock_settings_to_clc(smc);
	smc->connect_nonblock = 0;
	if (smc->sk.sk_state == SMC_INIT)
@@ -801,6 +835,7 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code,
	int rc;

	if (reason_code < 0) { /* error, fallback is not possible */
		this_cpu_inc(smc_stats->clnt_hshake_err_cnt);
		if (smc->sk.sk_state == SMC_INIT)
			sock_put(&smc->sk); /* passive closing */
		return reason_code;
@@ -808,6 +843,7 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code,
	if (reason_code != SMC_CLC_DECL_PEERDECL) {
		rc = smc_clc_send_decline(smc, reason_code, version);
		if (rc < 0) {
			this_cpu_inc(smc_stats->clnt_hshake_err_cnt);
			if (smc->sk.sk_state == SMC_INIT)
				sock_put(&smc->sk); /* passive closing */
			return rc;
@@ -933,7 +969,7 @@ static int smc_find_proposal_devices(struct smc_sock *smc,
				ini->smc_type_v1 = SMC_TYPE_N;
		} /* else RDMA is supported for this connection */
	}
	if (smc_ism_v2_capable && smc_find_ism_v2_device_clnt(smc, ini))
	if (smc_ism_is_v2_capable() && smc_find_ism_v2_device_clnt(smc, ini))
		ini->smc_type_v2 = SMC_TYPE_N;

	/* if neither ISM nor RDMA are supported, fallback */
@@ -1191,7 +1227,7 @@ static int smc_connect_check_aclc(struct smc_init_info *ini,
/* perform steps before actually connecting */
static int __smc_connect(struct smc_sock *smc)
{
	u8 version = smc_ism_v2_capable ? SMC_V2 : SMC_V1;
	u8 version = smc_ism_is_v2_capable() ? SMC_V2 : SMC_V1;
	struct smc_clc_msg_accept_confirm_v2 *aclc2;
	struct smc_clc_msg_accept_confirm *aclc;
	struct smc_init_info *ini = NULL;
@@ -1216,9 +1252,9 @@ static int __smc_connect(struct smc_sock *smc)
						    version);

	ini->smcd_version = SMC_V1;
	ini->smcd_version |= smc_ism_v2_capable ? SMC_V2 : 0;
	ini->smcd_version |= smc_ism_is_v2_capable() ? SMC_V2 : 0;
	ini->smc_type_v1 = SMC_TYPE_B;
	ini->smc_type_v2 = smc_ism_v2_capable ? SMC_TYPE_D : SMC_TYPE_N;
	ini->smc_type_v2 = smc_ism_is_v2_capable() ? SMC_TYPE_D : SMC_TYPE_N;

	/* get vlan id from IP device */
	if (smc_vlan_by_tcpsk(smc->clcsock, ini)) {
@@ -1262,6 +1298,7 @@ static int __smc_connect(struct smc_sock *smc)
	if (rc)
		goto vlan_cleanup;

	SMC_STAT_CLNT_SUCC_INC(aclc);
	smc_connect_ism_vlan_cleanup(smc, ini);
	kfree(buf);
	kfree(ini);
@@ -1637,6 +1674,7 @@ static void smc_listen_out_err(struct smc_sock *new_smc)
{
	struct sock *newsmcsk = &new_smc->sk;

	this_cpu_inc(smc_stats->srv_hshake_err_cnt);
	if (newsmcsk->sk_state == SMC_INIT)
		sock_put(&new_smc->sk); /* passive closing */
	newsmcsk->sk_state = SMC_CLOSED;
@@ -1654,12 +1692,11 @@ static void smc_listen_decline(struct smc_sock *new_smc, int reason_code,
	else
		smc_conn_free(&new_smc->conn);
	if (reason_code < 0 ||
	    smc_switch_to_fallback(new_smc)) {
	    smc_switch_to_fallback(new_smc, reason_code)) {
		/* error, no fallback possible */
		smc_listen_out_err(new_smc);
		return;
	}
	new_smc->fallback_rsn = reason_code;
	if (reason_code && reason_code != SMC_CLC_DECL_PEERDECL) {
		if (smc_clc_send_decline(new_smc, reason_code, version) < 0) {
			smc_listen_out_err(new_smc);
@@ -1683,7 +1720,7 @@ static int smc_listen_v2_check(struct smc_sock *new_smc,
	if (pclc->hdr.version > SMC_V1)
		ini->smcd_version |=
				ini->smc_type_v2 != SMC_TYPE_N ? SMC_V2 : 0;
	if (!smc_ism_v2_capable) {
	if (!smc_ism_is_v2_capable()) {
		ini->smcd_version &= ~SMC_V2;
		goto out;
	}
@@ -2001,7 +2038,7 @@ static void smc_listen_work(struct work_struct *work)
{
	struct smc_sock *new_smc = container_of(work, struct smc_sock,
						smc_listen_work);
	u8 version = smc_ism_v2_capable ? SMC_V2 : SMC_V1;
	u8 version = smc_ism_is_v2_capable() ? SMC_V2 : SMC_V1;
	struct socket *newclcsock = new_smc->clcsock;
	struct smc_clc_msg_accept_confirm *cclc;
	struct smc_clc_msg_proposal_area *buf;
@@ -2019,13 +2056,11 @@ static void smc_listen_work(struct work_struct *work)

	/* check if peer is smc capable */
	if (!tcp_sk(newclcsock->sk)->syn_smc) {
		rc = smc_switch_to_fallback(new_smc);
		if (rc) {
		rc = smc_switch_to_fallback(new_smc, SMC_CLC_DECL_PEERNOSMC);
		if (rc)
			smc_listen_out_err(new_smc);
		} else {
			new_smc->fallback_rsn = SMC_CLC_DECL_PEERNOSMC;
		else
			smc_listen_out_connected(new_smc);
		}
		return;
	}

@@ -2102,6 +2137,7 @@ static void smc_listen_work(struct work_struct *work)
	}
	smc_conn_save_peer_info(new_smc, cclc);
	smc_listen_out_connected(new_smc);
	SMC_STAT_SERV_SUCC_INC(ini);
	goto out_free;

out_unlock:
@@ -2319,10 +2355,9 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
	if (msg->msg_flags & MSG_FASTOPEN) {
		/* not connected yet, fallback */
		if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) {
			rc = smc_switch_to_fallback(smc);
			rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP);
			if (rc)
				goto out;
			smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP;
		} else {
			rc = -EINVAL;
			goto out;
@@ -2334,10 +2369,12 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
		goto out;
	}

	if (smc->use_fallback)
	if (smc->use_fallback) {
		rc = smc->clcsock->ops->sendmsg(smc->clcsock, msg, len);
	else
	} else {
		rc = smc_tx_sendmsg(smc, msg, len);
		SMC_STAT_TX_PAYLOAD(smc, len, rc);
	}
out:
	release_sock(sk);
	return rc;
@@ -2372,6 +2409,7 @@ static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
	} else {
		msg->msg_namelen = 0;
		rc = smc_rx_recvmsg(smc, msg, NULL, len, flags);
		SMC_STAT_RX_PAYLOAD(smc, rc, rc);
	}

out:
@@ -2561,9 +2599,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
	case TCP_FASTOPEN_NO_COOKIE:
		/* option not supported by SMC */
		if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) {
			rc = smc_switch_to_fallback(smc);
			if (!rc)
				smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP;
			rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP);
		} else {
			rc = -EINVAL;
		}
@@ -2573,6 +2609,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
		    sk->sk_state != SMC_LISTEN &&
		    sk->sk_state != SMC_CLOSED) {
			if (val) {
				SMC_STAT_INC(!smc->conn.lnk, ndly_cnt);
				smc_tx_pending(&smc->conn);
				cancel_delayed_work(&smc->conn.tx_work);
			}
@@ -2583,6 +2620,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
		    sk->sk_state != SMC_LISTEN &&
		    sk->sk_state != SMC_CLOSED) {
			if (!val) {
				SMC_STAT_INC(!smc->conn.lnk, cork_cnt);
				smc_tx_pending(&smc->conn);
				cancel_delayed_work(&smc->conn.tx_work);
			}
@@ -2718,10 +2756,11 @@ static ssize_t smc_sendpage(struct socket *sock, struct page *page,
		goto out;
	}
	release_sock(sk);
	if (smc->use_fallback)
	if (smc->use_fallback) {
		rc = kernel_sendpage(smc->clcsock, page, offset,
				     size, flags);
	else {
	} else {
		SMC_STAT_INC(!smc->conn.lnk, sendpage_cnt);
		lock_sock(sk);
		rc = smc_tx_sendpage(smc, page, offset, size, flags);
		release_sock(sk);
@@ -2774,6 +2813,7 @@ static ssize_t smc_splice_read(struct socket *sock, loff_t *ppos,
			flags = MSG_DONTWAIT;
		else
			flags = 0;
		SMC_STAT_INC(!smc->conn.lnk, splice_cnt);
		rc = smc_rx_recvmsg(smc, NULL, pipe, len, flags);
	}
out:
@@ -2886,10 +2926,14 @@ static int __init smc_init(void)
	smc_ism_init();
	smc_clc_init();

	rc = smc_pnet_init();
	rc = smc_nl_init();
	if (rc)
		goto out_pernet_subsys;

	rc = smc_pnet_init();
	if (rc)
		goto out_nl;

	rc = -ENOMEM;

	smc_tcp_ls_wq = alloc_workqueue("smc_tcp_ls_wq", WQ_UNBOUND | WQ_HIGHPRI, 0);
@@ -2903,10 +2947,16 @@ static int __init smc_init(void)
	if (!smc_close_wq)
		goto out_alloc_hs_wq;

	rc = smc_stats_init();
	if (rc) {
		pr_err("%s: smc_stats_init fails with %d\n", __func__, rc);
		goto out_alloc_wqs;
	}

	rc = smc_core_init();
	if (rc) {
		pr_err("%s: smc_core_init fails with %d\n", __func__, rc);
		goto out_alloc_wqs;
		goto out_smc_stat;
	}

	rc = smc_llc_init();
@@ -2958,6 +3008,8 @@ static int __init smc_init(void)
	proto_unregister(&smc_proto);
out_core:
	smc_core_exit();
out_smc_stat:
	smc_stats_exit();
out_alloc_wqs:
	destroy_workqueue(smc_close_wq);
out_alloc_hs_wq:
@@ -2966,6 +3018,8 @@ static int __init smc_init(void)
	destroy_workqueue(smc_tcp_ls_wq);
out_pnet:
	smc_pnet_exit();
out_nl:
	smc_nl_exit();
out_pernet_subsys:
	unregister_pernet_subsys(&smc_net_ops);

@@ -2981,9 +3035,11 @@ static void __exit smc_exit(void)
	destroy_workqueue(smc_close_wq);
	destroy_workqueue(smc_tcp_ls_wq);
	destroy_workqueue(smc_hs_wq);
	smc_stats_exit();
	proto_unregister(&smc_proto6);
	proto_unregister(&smc_proto);
	smc_pnet_exit();
	smc_nl_exit();
	unregister_pernet_subsys(&smc_net_ops);
	rcu_barrier();
}
+5 −0
Original line number Diff line number Diff line
@@ -775,6 +775,11 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,
	return len > 0 ? 0 : len;
}

void smc_clc_get_hostname(u8 **host)
{
	*host = &smc_hostname[0];
}

void __init smc_clc_init(void)
{
	struct new_utsname *u;
+1 −0
Original line number Diff line number Diff line
@@ -329,5 +329,6 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
			u8 version);
void smc_clc_init(void) __init;
void smc_clc_get_hostname(u8 **host);

#endif
Loading