All of lore.kernel.org
 help / color / mirror / Atom feed
From: Long Li <longli@exchange.microsoft.com>
To: Steve French <sfrench@samba.org>,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org
Cc: Long Li <longli@microsoft.com>
Subject: [[PATCH v1] 16/37] [CIFS] SMBD: Post a SMBD message with no payload
Date: Wed,  2 Aug 2017 13:10:27 -0700	[thread overview]
Message-ID: <1501704648-20159-17-git-send-email-longli@exchange.microsoft.com> (raw)
In-Reply-To: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com>

From: Long Li <longli@microsoft.com>

Implement the function to send a SMBD message with no payload. This is required at times when we want to extend credtis to server to have it continue to send data, without sending any actual data payload.

Signed-off-by: Long Li <longli@microsoft.com>
---
 fs/cifs/cifsrdma.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/cifs/cifsrdma.h | 11 +++++++
 2 files changed, 107 insertions(+)

diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c
index 989cad8..cf71bb1 100644
--- a/fs/cifs/cifsrdma.c
+++ b/fs/cifs/cifsrdma.c
@@ -66,6 +66,7 @@ static int cifs_rdma_post_recv(
 		struct cifs_rdma_info *info,
 		struct cifs_rdma_response *response);
 
+static int cifs_rdma_post_send_empty(struct cifs_rdma_info *info);
 static int cifs_rdma_post_send_data(
 		struct cifs_rdma_info *info,
 		struct kvec *iov, int n_vec, int remaining_data_length);
@@ -674,6 +675,101 @@ static int cifs_rdma_post_send_page(struct cifs_rdma_info *info, struct page *pa
 }
 
 /*
+ * Send an empty message
+ * Empty message is used to extend credits to peer to for keep live
+ */
+static int cifs_rdma_post_send_empty(struct cifs_rdma_info *info)
+{
+	struct cifs_rdma_request *request;
+	struct smbd_data_transfer_no_data *packet;
+	struct ib_send_wr send_wr, *send_wr_fail;
+	int rc;
+	u16 credits_granted, flags=0;
+
+	request = mempool_alloc(info->request_mempool, GFP_KERNEL);
+	if (!request) {
+		log_rdma_send("failed to get send buffer for empty packet\n");
+		return -ENOMEM;
+	}
+
+	request->info = info;
+	packet = (struct smbd_data_transfer_no_data *) request->packet;
+
+	/* nothing to do? */
+	if (credits_granted==0 && flags==0) {
+		mempool_free(request, info->request_mempool);
+		log_keep_alive("nothing to do, not sending anything\n");
+		return 0;
+	}
+
+	packet->credits_requested = cpu_to_le16(info->send_credit_target);
+	packet->credits_granted = cpu_to_le16(credits_granted);
+	packet->flags = cpu_to_le16(flags);
+	packet->reserved = cpu_to_le16(0);
+	packet->remaining_data_length = cpu_to_le32(0);
+	packet->data_offset = cpu_to_le32(0);
+	packet->data_length = cpu_to_le32(0);
+
+	log_outgoing("credits_requested=%d credits_granted=%d data_offset=%d "
+		     "data_length=%d remaining_data_length=%d\n",
+		le16_to_cpu(packet->credits_requested),
+		le16_to_cpu(packet->credits_granted),
+		le32_to_cpu(packet->data_offset),
+		le32_to_cpu(packet->data_length),
+		le32_to_cpu(packet->remaining_data_length));
+
+	request->num_sge = 1;
+	request->sge = kzalloc(sizeof(struct ib_sge), GFP_KERNEL);
+	if (!request->sge) {
+		rc = -ENOMEM;
+		goto allocate_sge_failed;
+	}
+
+	request->sge[0].addr = ib_dma_map_single(info->id->device,
+				(void *)packet, sizeof(*packet), DMA_TO_DEVICE);
+	if(ib_dma_mapping_error(info->id->device, request->sge[0].addr)) {
+		rc = -EIO;
+		goto dma_mapping_failure;
+	}
+
+	request->sge[0].length = sizeof(*packet);
+	request->sge[0].lkey = info->pd->local_dma_lkey;
+	ib_dma_sync_single_for_device(info->id->device, request->sge[0].addr,
+				request->sge[0].length, DMA_TO_DEVICE);
+
+	wait_event(info->wait_send_queue, atomic_read(&info->send_credits) > 0);
+	atomic_dec(&info->send_credits);
+	info->count_send_empty++;
+	log_rdma_send("rdma_request sge addr=%llu legnth=%u lkey=%u\n",
+		request->sge[0].addr, request->sge[0].length,
+		request->sge[0].lkey);
+
+	request->cqe.done = send_done;
+
+	send_wr.next = NULL;
+	send_wr.wr_cqe = &request->cqe;
+	send_wr.sg_list = request->sge;
+	send_wr.num_sge = request->num_sge;
+	send_wr.opcode = IB_WR_SEND;
+	send_wr.send_flags = IB_SEND_SIGNALED;
+
+	rc = ib_post_send(info->id->qp, &send_wr, &send_wr_fail);
+	if (!rc)
+		return 0;
+
+	log_rdma_send("ib_post_send failed rc=%d\n", rc);
+	ib_dma_unmap_single(info->id->device, request->sge[0].addr,
+			    request->sge[0].length, DMA_TO_DEVICE);
+
+dma_mapping_failure:
+	kfree(request->sge);
+
+allocate_sge_failed:
+	mempool_free(request, info->request_mempool);
+	return rc;
+}
+
+/*
  * Send a data buffer
  * iov: the iov array describing the data buffers
  * n_vec: number of iov array
diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h
index a766cbf..4a4c191 100644
--- a/fs/cifs/cifsrdma.h
+++ b/fs/cifs/cifsrdma.h
@@ -120,6 +120,17 @@ struct smbd_negotiate_resp {
 	__le32 max_fragmented_size;
 } __packed;
 
+// SMBD data transfer packet with no payload [MS-SMBD] 2.2.3
+struct smbd_data_transfer_no_data {
+	__le16 credits_requested;
+	__le16 credits_granted;
+	__le16 flags;
+	__le16 reserved;
+	__le32 remaining_data_length;
+	__le32 data_offset;
+	__le32 data_length;
+} __packed;
+
 // SMBD data transfer packet with payload [MS-SMBD] 2.2.3
 struct smbd_data_transfer {
 	__le16 credits_requested;
-- 
2.7.4

  parent reply	other threads:[~2017-08-02 20:10 UTC|newest]

Thread overview: 139+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 20:10 [[PATCH v1] 00/37] Implement SMBD protocol: Series 1 Long Li
2017-08-02 20:10 ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 01/37] [CIFS] SMBD: Add parsing for new rdma mount option Long Li
     [not found]   ` <1501704648-20159-2-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 19:10     ` Tom Talpey
2017-08-14 19:10       ` Tom Talpey
     [not found]       ` <CY4PR21MB01823BD35679AE110E9008B8A08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 22:53         ` Long Li
2017-08-14 22:53           ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 02/37] [CIFS] SMBD: Add structure for SMBD transport Long Li
2017-08-08  6:58   ` Stefan Metzmacher
     [not found]     ` <9632c208-d6a5-2c47-b583-274d046d97bd-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2017-08-12  8:32       ` Long Li
2017-08-12  8:32         ` Long Li
     [not found]         ` <MWHPR21MB019089DF6B0B68C5C2F4FE56CE8E0-saRRjQKJ25M/hL2NnenhuM1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-12 18:49           ` Christoph Hellwig
2017-08-12 18:49             ` Christoph Hellwig
2017-08-14 13:41           ` Stefan Metzmacher
2017-08-14 13:41             ` Stefan Metzmacher
     [not found]             ` <61ab1564-d699-e8f2-631e-67a6c28b678b-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2017-08-14 18:10               ` Long Li
2017-08-14 18:10                 ` Long Li
     [not found]   ` <1501704648-20159-3-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-13 10:10     ` Christoph Hellwig
2017-08-13 10:10       ` Christoph Hellwig
2017-08-02 20:10 ` [[PATCH v1] 03/37] [CIFS] SMBD: Add logging functions for debug Long Li
2017-08-02 20:10 ` [[PATCH v1] 04/37] [CIFS] SMBD: Define per-channel SMBD transport parameters and default values Long Li
     [not found]   ` <1501704648-20159-5-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-13 10:11     ` Christoph Hellwig
2017-08-13 10:11       ` Christoph Hellwig
2017-08-14 19:28       ` Tom Talpey
     [not found]         ` <CY4PR21MB0182A8FC1B6900BD6EBA96B0A08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 22:57           ` Long Li
2017-08-14 22:57             ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 05/37] [CIFS] SMBD: Implement API for upper layer to create SMBD transport and establish RDMA connection Long Li
2017-08-14 19:54   ` Tom Talpey
2017-08-30  2:35     ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 06/37] [CIFS] SMBD: Add definition and cache for SMBD response Long Li
2017-08-02 20:10 ` [[PATCH v1] 08/37] [CIFS] SMBD: Define packet format for SMBD data transfer message Long Li
     [not found]   ` <1501704648-20159-9-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-13 10:15     ` Christoph Hellwig
2017-08-13 10:15       ` Christoph Hellwig
     [not found]       ` <20170813101510.GC17287-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-08-14 10:24         ` Jeff Layton
2017-08-14 10:24           ` Jeff Layton
2017-08-02 20:10 ` [[PATCH v1] 09/37] [CIFS] SMBD: Add SMBD request and cache Long Li
2017-08-02 20:10 ` [[PATCH v1] 10/37] [CIFS] SMBD: Introduce wait queue when sending SMBD request Long Li
2017-08-02 20:10 ` [[PATCH v1] 12/37] [CIFS] SMBD: Handle send completion from CQ Long Li
2017-08-13 10:19   ` Christoph Hellwig
2017-08-14 18:16     ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 13/37] [CIFS] SMBD: Implement SMBD protocol negotiation Long Li
     [not found]   ` <1501704648-20159-14-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-13 10:22     ` Christoph Hellwig
2017-08-13 10:22       ` Christoph Hellwig
2017-08-02 20:10 ` [[PATCH v1] 14/37] [CIFS] SMBD: Post a SMBD data transfer message with page payload Long Li
     [not found]   ` <1501704648-20159-15-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 20:23     ` Tom Talpey
2017-08-14 20:23       ` Tom Talpey
     [not found]       ` <CY4PR21MB01822E48269CAD772EE1B3A1A08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 22:58         ` Long Li
2017-08-14 22:58           ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 15/37] [CIFS] SMBD: Post a SMBD data transfer message with data payload Long Li
     [not found]   ` <1501704648-20159-16-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-13 10:23     ` Christoph Hellwig
2017-08-13 10:23       ` Christoph Hellwig
2017-08-30  2:17       ` Long Li
2017-08-30  8:51         ` Christoph Hellwig
2017-08-30 18:17           ` Long Li
2017-08-14 20:26     ` Tom Talpey
2017-08-14 20:26       ` Tom Talpey
2017-08-02 20:10 ` Long Li [this message]
     [not found]   ` <1501704648-20159-17-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-13 10:24     ` [[PATCH v1] 16/37] [CIFS] SMBD: Post a SMBD message with no payload Christoph Hellwig
2017-08-13 10:24       ` Christoph Hellwig
     [not found]       ` <20170813102412.GH17287-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-08-14 18:20         ` Long Li
2017-08-14 18:20           ` Long Li
2017-08-14 19:00           ` Tom Talpey
2017-08-14 22:51             ` Long Li
     [not found]               ` <CY4PR21MB0182E3DB8E034407509E3205CE8C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:12                 ` Tom Talpey
2017-08-14 23:12                   ` Tom Talpey
2017-08-02 20:10 ` [[PATCH v1] 17/37] [CIFS] SMBD: Track status for transport Long Li
2017-08-02 20:10 ` [[PATCH v1] 19/37] [CIFS] SMBD: Manage credits on SMBD client and server Long Li
     [not found]   ` <1501704648-20159-20-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 20:47     ` Tom Talpey
2017-08-14 20:47       ` Tom Talpey
     [not found]       ` <CY4PR21MB01823211DE659BEAA7932309A08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:03         ` Long Li
2017-08-14 23:03           ` Long Li
     [not found] ` <1501704648-20159-1-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-02 20:10   ` [[PATCH v1] 07/37] [CIFS] SMBD: Implement receive buffer for handling SMBD response Long Li
2017-08-02 20:10     ` Long Li
     [not found]     ` <1501704648-20159-8-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 20:09       ` Tom Talpey
2017-08-14 20:09         ` Tom Talpey
2017-08-19 23:41         ` Long Li
2017-08-02 20:10   ` [[PATCH v1] 11/37] [CIFS] SMBD: Post a receive request Long Li
2017-08-02 20:10     ` Long Li
2017-08-13 10:18     ` Christoph Hellwig
2017-08-02 20:10   ` [[PATCH v1] 18/37] [CIFS] SMBD: Implement API for upper layer to send data Long Li
2017-08-02 20:10     ` Long Li
     [not found]     ` <1501704648-20159-19-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 20:44       ` Tom Talpey
2017-08-14 20:44         ` Tom Talpey
     [not found]         ` <CY4PR21MB01827F735F570CCAECD5AD8BA08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-19 23:41           ` Long Li
2017-08-19 23:41             ` Long Li
2017-08-30  2:30           ` Long Li
2017-08-30  2:30             ` Long Li
2017-08-02 20:10   ` [[PATCH v1] 20/37] [CIFS] SMBD: Implement reassembly queue for receiving data Long Li
2017-08-02 20:10     ` Long Li
2017-08-02 20:10   ` [[PATCH v1] 21/37] [CIFS] SMBD: Implement API for upper layer to receive data Long Li
2017-08-02 20:10     ` Long Li
     [not found]     ` <1501704648-20159-22-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 20:57       ` Tom Talpey
2017-08-14 20:57         ` Tom Talpey
     [not found]         ` <CY4PR21MB0182E84B76541E0EE6FCAF4EA08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:24           ` Long Li
2017-08-14 23:24             ` Long Li
2017-08-14 23:35             ` Tom Talpey
2017-08-02 20:10   ` [[PATCH v1] 22/37] [CIFS] SMBD: Implement API for upper layer to receive data to page Long Li
2017-08-02 20:10     ` Long Li
2017-08-14 20:59     ` Tom Talpey
2017-08-02 20:10   ` [[PATCH v1] 30/37] [CIFS] SMBD: Add SMBDirect transport to Makefile Long Li
2017-08-02 20:10     ` Long Li
     [not found]     ` <1501704648-20159-31-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 21:20       ` Tom Talpey
2017-08-14 21:20         ` Tom Talpey
2017-08-14 23:30         ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 23/37] [CIFS] SMBD: Implement API for upper layer to reconnect transport Long Li
     [not found]   ` <1501704648-20159-24-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 21:02     ` Tom Talpey
2017-08-14 21:02       ` Tom Talpey
     [not found]       ` <CY4PR21MB0182025BB8A39FB3F7291F94A08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:37         ` Long Li
2017-08-14 23:37           ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 24/37] [CIFS] SMBD: Support for SMBD keep alive protocol Long Li
2017-08-14 21:06   ` Tom Talpey
     [not found]     ` <CY4PR21MB0182CBEB4F76488B2FB9480FA08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:27       ` Long Li
2017-08-14 23:27         ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 25/37] [CIFS] SMBD: Support SMBD idle connection timer Long Li
     [not found]   ` <1501704648-20159-26-git-send-email-longli-Lp/cVzEoVyZiJJESP9tAQJZ3qXmFLfmx@public.gmane.org>
2017-08-14 21:12     ` Tom Talpey
2017-08-14 21:12       ` Tom Talpey
     [not found]       ` <CY4PR21MB018266B47622680566B48575A08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:29         ` Long Li
2017-08-14 23:29           ` Long Li
     [not found]           ` <CY4PR21MB01829CD26D97DF63CAB08666CE8C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-14 23:42             ` Tom Talpey
2017-08-14 23:42               ` Tom Talpey
     [not found]               ` <CY4PR21MB01829585183A42669B962B4AA08C0-kUhI0YP1syo7ifcEnHlXec1VXTxX1y3OvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-15  0:10                 ` Long Li
2017-08-15  0:10                   ` Long Li
2017-08-02 20:10 ` [[PATCH v1] 26/37] [CIFS] SMBD: Send an immediate packet when it's needed Long Li
2017-08-14 21:15   ` Tom Talpey
2017-08-02 20:10 ` [[PATCH v1] 27/37] [CIFS] SMBD: Destroy transport when RDMA channel is disconnected Long Li
2017-08-02 20:10 ` [[PATCH v1] 28/37] [CIFS] SMBD: Implement API for upper layer to destroy the transport Long Li
2017-08-02 20:10 ` [[PATCH v1] 29/37] [CIFS] SMBD: Disconnect RDMA connection on QP errors Long Li
2017-08-02 20:10 ` [[PATCH v1] 31/37] [CIFS] Add SMBD transport to SMB session context Long Li
2017-08-02 20:10 ` [[PATCH v1] 32/37] [CIFS] Add SMBD debug couters to CIFS debug exports Long Li
2017-08-02 20:10 ` [[PATCH v1] 33/37] [CIFS] Connect to SMBD transport when specified in mount option Long Li
2017-08-02 20:10 ` [[PATCH v1] 34/37] [CIFS] Reconnect to SMBD transport when it's used Long Li
2017-08-02 20:10 ` [[PATCH v1] 35/37] [CIFS] Destroy SMBD transport on exit Long Li
2017-08-02 20:10 ` [[PATCH v1] 36/37] [CIFS] Read from SMBD transport when it's used Long Li
2017-08-02 20:10 ` [[PATCH v1] 37/37] [CIFS] Write to " Long Li
2017-08-13 10:27 ` [[PATCH v1] 00/37] Implement SMBD protocol: Series 1 Christoph Hellwig
     [not found]   ` <20170813102735.GI17287-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-08-13 10:31     ` Christoph Hellwig
2017-08-13 10:31       ` Christoph Hellwig
2017-08-14 17:04     ` Long Li
2017-08-14 17:04       ` Long Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1501704648-20159-17-git-send-email-longli@exchange.microsoft.com \
    --to=longli@exchange.microsoft.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.