Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f06f095f authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'smc-next'



Ursula Braun says:

====================
net/smc: patches 2019-02-07

here are patches for SMC:
* patches 1, 3, and 6 are cleanups without functional change
* patch 2 postpones closing of internal clcsock
* patches 4 and 5 improve link group creation locking
* patch 7 restores AF_SMC as diag_family field
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents fc4aa1ca 232dc8ef
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -11,13 +11,5 @@
#include <linux/device.h>
#include <linux/types.h>

#define PNETIDS_LEN		64	/* Total utility string length in bytes
					 * to cover up to 4 PNETIDs of 16 bytes
					 * for up to 4 device ports
					 */
#define MAX_PNETID_LEN		16	/* Max.length of a single port PNETID */
#define MAX_PNETID_PORTS	(PNETIDS_LEN / MAX_PNETID_LEN)
					/* Max. # of ports with a PNETID */

int pnet_id_by_dev_port(struct device *dev, unsigned short port, u8 *pnetid);
#endif /* _ASM_S390_PNET_H */
+8 −0
Original line number Diff line number Diff line
@@ -13,6 +13,14 @@
#include <asm/ccwdev.h>
#include <asm/pnet.h>

#define PNETIDS_LEN		64	/* Total utility string length in bytes
					 * to cover up to 4 PNETIDs of 16 bytes
					 * for up to 4 device ports
					 */
#define MAX_PNETID_LEN		16	/* Max.length of a single port PNETID */
#define MAX_PNETID_PORTS	(PNETIDS_LEN / MAX_PNETID_LEN)
					/* Max. # of ports with a PNETID */

/*
 * Get the PNETIDs from a device.
 * s390 hardware supports the definition of a so-called Physical Network
+51 −34
Original line number Diff line number Diff line
@@ -42,8 +42,11 @@
#include "smc_rx.h"
#include "smc_close.h"

static DEFINE_MUTEX(smc_create_lgr_pending);	/* serialize link group
						 * creation
static DEFINE_MUTEX(smc_server_lgr_pending);	/* serialize link group
						 * creation on server
						 */
static DEFINE_MUTEX(smc_client_lgr_pending);	/* serialize link group
						 * creation on client
						 */

static void smc_tcp_listen_work(struct work_struct *);
@@ -145,32 +148,33 @@ static int smc_release(struct socket *sock)
		rc = smc_close_active(smc);
		sock_set_flag(sk, SOCK_DEAD);
		sk->sk_shutdown |= SHUTDOWN_MASK;
	} else {
		if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT)
			sock_put(sk); /* passive closing */
		if (sk->sk_state == SMC_LISTEN) {
			/* wake up clcsock accept */
			rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
		}
		sk->sk_state = SMC_CLOSED;
		sk->sk_state_change(sk);
	}

	sk->sk_prot->unhash(sk);

	if (sk->sk_state == SMC_CLOSED) {
		if (smc->clcsock) {
		if (smc->use_fallback && sk->sk_state == SMC_LISTEN) {
			/* wake up clcsock accept */
			rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
		}
			mutex_lock(&smc->clcsock_release_lock);
			sock_release(smc->clcsock);
			smc->clcsock = NULL;
			mutex_unlock(&smc->clcsock_release_lock);
		}
	if (smc->use_fallback) {
		if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT)
			sock_put(sk); /* passive closing */
		sk->sk_state = SMC_CLOSED;
		sk->sk_state_change(sk);
		if (!smc->use_fallback)
			smc_conn_free(&smc->conn);
	}

	/* detach socket */
	sock_orphan(sk);
	sock->sk = NULL;
	if (!smc->use_fallback && sk->sk_state == SMC_CLOSED)
		smc_conn_free(&smc->conn);
	release_sock(sk);

	sock_put(sk); /* final sock_put */
@@ -476,7 +480,12 @@ static int smc_connect_abort(struct smc_sock *smc, int reason_code,
{
	if (local_contact == SMC_FIRST_CONTACT)
		smc_lgr_forget(smc->conn.lgr);
	mutex_unlock(&smc_create_lgr_pending);
	if (smc->conn.lgr->is_smcd)
		/* there is only one lgr role for SMC-D; use server lock */
		mutex_unlock(&smc_server_lgr_pending);
	else
		mutex_unlock(&smc_client_lgr_pending);

	smc_conn_free(&smc->conn);
	return reason_code;
}
@@ -561,7 +570,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
	struct smc_link *link;
	int reason_code = 0;

	mutex_lock(&smc_create_lgr_pending);
	mutex_lock(&smc_client_lgr_pending);
	local_contact = smc_conn_create(smc, false, aclc->hdr.flag, ibdev,
					ibport, ntoh24(aclc->qpn), &aclc->lcl,
					NULL, 0);
@@ -572,7 +581,8 @@ static int smc_connect_rdma(struct smc_sock *smc,
			reason_code = SMC_CLC_DECL_SYNCERR; /* synchr. error */
		else
			reason_code = SMC_CLC_DECL_INTERR; /* other error */
		return smc_connect_abort(smc, reason_code, 0);
		mutex_unlock(&smc_client_lgr_pending);
		return reason_code;
	}
	link = &smc->conn.lgr->lnk[SMC_SINGLE_LINK];

@@ -616,7 +626,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
			return smc_connect_abort(smc, reason_code,
						 local_contact);
	}
	mutex_unlock(&smc_create_lgr_pending);
	mutex_unlock(&smc_client_lgr_pending);

	smc_copy_sock_settings_to_clc(smc);
	if (smc->sk.sk_state == SMC_INIT)
@@ -633,11 +643,14 @@ static int smc_connect_ism(struct smc_sock *smc,
	int local_contact = SMC_FIRST_CONTACT;
	int rc = 0;

	mutex_lock(&smc_create_lgr_pending);
	/* there is only one lgr role for SMC-D; use server lock */
	mutex_lock(&smc_server_lgr_pending);
	local_contact = smc_conn_create(smc, true, aclc->hdr.flag, NULL, 0, 0,
					NULL, ismdev, aclc->gid);
	if (local_contact < 0)
		return smc_connect_abort(smc, SMC_CLC_DECL_MEM, 0);
	if (local_contact < 0) {
		mutex_unlock(&smc_server_lgr_pending);
		return SMC_CLC_DECL_MEM;
	}

	/* Create send and receive buffers */
	if (smc_buf_create(smc, true))
@@ -651,7 +664,7 @@ static int smc_connect_ism(struct smc_sock *smc,
	rc = smc_clc_send_confirm(smc);
	if (rc)
		return smc_connect_abort(smc, rc, local_contact);
	mutex_unlock(&smc_create_lgr_pending);
	mutex_unlock(&smc_server_lgr_pending);

	smc_copy_sock_settings_to_clc(smc);
	if (smc->sk.sk_state == SMC_INIT)
@@ -1250,7 +1263,7 @@ static void smc_listen_work(struct work_struct *work)
		return;
	}

	mutex_lock(&smc_create_lgr_pending);
	mutex_lock(&smc_server_lgr_pending);
	smc_close_init(new_smc);
	smc_rx_init(new_smc);
	smc_tx_init(new_smc);
@@ -1272,7 +1285,7 @@ static void smc_listen_work(struct work_struct *work)
				  &local_contact) ||
	     smc_listen_rdma_reg(new_smc, local_contact))) {
		/* SMC not supported, decline */
		mutex_unlock(&smc_create_lgr_pending);
		mutex_unlock(&smc_server_lgr_pending);
		smc_listen_decline(new_smc, SMC_CLC_DECL_MODEUNSUPP,
				   local_contact);
		return;
@@ -1281,29 +1294,33 @@ static void smc_listen_work(struct work_struct *work)
	/* send SMC Accept CLC message */
	rc = smc_clc_send_accept(new_smc, local_contact);
	if (rc) {
		mutex_unlock(&smc_create_lgr_pending);
		mutex_unlock(&smc_server_lgr_pending);
		smc_listen_decline(new_smc, rc, local_contact);
		return;
	}

	/* SMC-D does not need this lock any more */
	if (ism_supported)
		mutex_unlock(&smc_server_lgr_pending);

	/* receive SMC Confirm CLC message */
	reason_code = smc_clc_wait_msg(new_smc, &cclc, sizeof(cclc),
				       SMC_CLC_CONFIRM, CLC_WAIT_TIME);
	if (reason_code) {
		mutex_unlock(&smc_create_lgr_pending);
		if (!ism_supported)
			mutex_unlock(&smc_server_lgr_pending);
		smc_listen_decline(new_smc, reason_code, local_contact);
		return;
	}

	/* finish worker */
	if (!ism_supported) {
		if (smc_listen_rdma_finish(new_smc, &cclc, local_contact)) {
			mutex_unlock(&smc_create_lgr_pending);
		rc = smc_listen_rdma_finish(new_smc, &cclc, local_contact);
		mutex_unlock(&smc_server_lgr_pending);
		if (rc)
			return;
	}
	}
	smc_conn_save_peer_info(new_smc, &cclc);
	mutex_unlock(&smc_create_lgr_pending);
	smc_listen_out_connected(new_smc);
}

+5 −4
Original line number Diff line number Diff line
@@ -245,17 +245,18 @@ static inline void smcr_cdc_msg_to_host(struct smc_host_cdc_msg *local,
}

static inline void smcd_cdc_msg_to_host(struct smc_host_cdc_msg *local,
					struct smcd_cdc_msg *peer)
					struct smcd_cdc_msg *peer,
					struct smc_connection *conn)
{
	union smc_host_cursor temp;

	temp.wrap = peer->prod.wrap;
	temp.count = peer->prod.count;
	atomic64_set(&local->prod.acurs, atomic64_read(&temp.acurs));
	smc_curs_copy(&local->prod, &temp, conn);

	temp.wrap = peer->cons.wrap;
	temp.count = peer->cons.count;
	atomic64_set(&local->cons.acurs, atomic64_read(&temp.acurs));
	smc_curs_copy(&local->cons, &temp, conn);
	local->prod_flags = peer->cons.prod_flags;
	local->conn_state_flags = peer->cons.conn_state_flags;
}
@@ -265,7 +266,7 @@ static inline void smc_cdc_msg_to_host(struct smc_host_cdc_msg *local,
				       struct smc_connection *conn)
{
	if (conn->lgr->is_smcd)
		smcd_cdc_msg_to_host(local, (struct smcd_cdc_msg *)peer);
		smcd_cdc_msg_to_host(local, (struct smcd_cdc_msg *)peer, conn);
	else
		smcr_cdc_msg_to_host(local, peer, conn);
}
+6 −1
Original line number Diff line number Diff line
@@ -405,8 +405,13 @@ static void smc_close_passive_work(struct work_struct *work)
	if (old_state != sk->sk_state) {
		sk->sk_state_change(sk);
		if ((sk->sk_state == SMC_CLOSED) &&
		    (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket))
		    (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket)) {
			smc_conn_free(conn);
			if (smc->clcsock) {
				sock_release(smc->clcsock);
				smc->clcsock = NULL;
			}
		}
	}
	release_sock(sk);
	sock_put(sk); /* sock_hold done by schedulers of close_work */
Loading