net/smc: send failover validation message
authorKarsten Graul <kgraul@linux.ibm.com>
Mon, 4 May 2020 12:18:39 +0000 (14:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 May 2020 17:54:39 +0000 (10:54 -0700)
When a connection is switched to a new link then a link validation
message must be sent to the peer over the new link, containing the
sequence number of the last CDC message that was sent over the old link.
The peer will validate if this sequence number is the same or lower then
the number he received, and abort the connection if messages were lost.
Add smcr_cdc_msg_send_validation() to send the message validation
message and call it when a connection was switched in
smc_switch_cursor().

Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/smc_cdc.c
net/smc/smc_cdc.h
net/smc/smc_core.c

index 3ca986066f3286d655ea9f4fb55a79fce45a0efd..e6b7eef71831f9d9cc9e1f0c4896f643b4b80333 100644 (file)
@@ -115,6 +115,31 @@ int smc_cdc_msg_send(struct smc_connection *conn,
        return rc;
 }
 
+/* send a validation msg indicating the move of a conn to an other QP link */
+int smcr_cdc_msg_send_validation(struct smc_connection *conn)
+{
+       struct smc_host_cdc_msg *local = &conn->local_tx_ctrl;
+       struct smc_link *link = conn->lnk;
+       struct smc_cdc_tx_pend *pend;
+       struct smc_wr_buf *wr_buf;
+       struct smc_cdc_msg *peer;
+       int rc;
+
+       rc = smc_cdc_get_free_slot(conn, link, &wr_buf, NULL, &pend);
+       if (rc)
+               return rc;
+
+       peer = (struct smc_cdc_msg *)wr_buf;
+       peer->common.type = local->common.type;
+       peer->len = local->len;
+       peer->seqno = htons(conn->tx_cdc_seq_fin); /* seqno last compl. tx */
+       peer->token = htonl(local->token);
+       peer->prod_flags.failover_validation = 1;
+
+       rc = smc_wr_tx_send(link, (struct smc_wr_tx_pend_priv *)pend);
+       return rc;
+}
+
 static int smcr_cdc_get_slot_and_msg_send(struct smc_connection *conn)
 {
        struct smc_cdc_tx_pend *pend;
index 42246b4bdcc9f1674d05eadc987816402cdc41ed..9cfabc9af120828c3c579720806f862d5c100a41 100644 (file)
@@ -313,6 +313,7 @@ int smc_cdc_msg_send(struct smc_connection *conn, struct smc_wr_buf *wr_buf,
                     struct smc_cdc_tx_pend *pend);
 int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn);
 int smcd_cdc_msg_send(struct smc_connection *conn);
+int smcr_cdc_msg_send_validation(struct smc_connection *conn);
 int smc_cdc_init(void) __init;
 void smcd_cdc_rx_init(struct smc_connection *conn);
 
index 21bc1ec07e997a19b50bd0ab193f4e835390cd1d..a558ce0bde9724c4fb17b475aae34ac282987f9f 100644 (file)
@@ -483,7 +483,7 @@ static int smc_switch_cursor(struct smc_sock *smc)
 
        if (smc->sk.sk_state != SMC_INIT &&
            smc->sk.sk_state != SMC_CLOSED) {
-               /* tbd: call rc = smc_cdc_get_slot_and_msg_send(conn); */
+               rc = smcr_cdc_msg_send_validation(conn);
                if (!rc) {
                        schedule_delayed_work(&conn->tx_work, 0);
                        smc->sk.sk_data_ready(&smc->sk);