public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Kalderon <Michal.Kalderon@cavium.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	dledford@redhat.com, Michal Kalderon <Michal.Kalderon@cavium.com>,
	Ariel Elior <Ariel.Elior@cavium.com>
Subject: [PATCH v2 net-next 11/12] qed: Add support for MPA header being split over two tcp packets
Date: Tue, 3 Oct 2017 11:55:01 +0300	[thread overview]
Message-ID: <1507020902-4952-12-git-send-email-Michal.Kalderon@cavium.com> (raw)
In-Reply-To: <1507020902-4952-1-git-send-email-Michal.Kalderon@cavium.com>

There is a special case where an MPA header is split over to tcp
packets, in this case we need to wait for the next packet to
get the fpdu length. We use the incomplete_bytes to mark this
fpdu as a "special" one which requires updating the length with
the next packet

Signed-off-by: Michal Kalderon <Michal.Kalderon@cavium.com>
Signed-off-by: Ariel Elior <Ariel.Elior@cavium.com>
---
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 36 ++++++++++++++++++++++++++++-
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h |  6 +++++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index 8b17369..2994942 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -1742,6 +1742,7 @@ enum qed_iwarp_mpa_pkt_type {
 	QED_IWARP_MPA_PKT_UNALIGNED
 };
 
+#define QED_IWARP_INVALID_FPDU_LENGTH 0xffff
 #define QED_IWARP_MPA_FPDU_LENGTH_SIZE (2)
 #define QED_IWARP_MPA_CRC32_DIGEST_SIZE (4)
 
@@ -1774,6 +1775,15 @@ enum qed_iwarp_mpa_pkt_type {
 		goto out;
 	}
 
+	/* special case of one byte remaining...
+	 * lower byte will be read next packet
+	 */
+	if (tcp_payload_len == 1) {
+		fpdu->fpdu_length = *mpa_data << BITS_PER_BYTE;
+		pkt_type = QED_IWARP_MPA_PKT_PARTIAL;
+		goto out;
+	}
+
 	mpa_len = ntohs(*((u16 *)(mpa_data)));
 	fpdu->fpdu_length = QED_IWARP_FPDU_LEN_WITH_PAD(mpa_len);
 
@@ -1802,7 +1812,9 @@ enum qed_iwarp_mpa_pkt_type {
 	fpdu->mpa_frag = buf->data_phys_addr + pkt_data->first_mpa_offset;
 	fpdu->mpa_frag_virt = (u8 *)(buf->data) + pkt_data->first_mpa_offset;
 
-	if (tcp_payload_size < fpdu->fpdu_length)
+	if (tcp_payload_size == 1)
+		fpdu->incomplete_bytes = QED_IWARP_INVALID_FPDU_LENGTH;
+	else if (tcp_payload_size < fpdu->fpdu_length)
 		fpdu->incomplete_bytes = fpdu->fpdu_length - tcp_payload_size;
 	else
 		fpdu->incomplete_bytes = 0;	/* complete fpdu */
@@ -1810,6 +1822,27 @@ enum qed_iwarp_mpa_pkt_type {
 	fpdu->mpa_frag_len = fpdu->fpdu_length - fpdu->incomplete_bytes;
 }
 
+static void
+qed_iwarp_update_fpdu_length(struct qed_hwfn *p_hwfn,
+			     struct qed_iwarp_fpdu *fpdu, u8 *mpa_data)
+{
+	u16 mpa_len;
+
+	/* Update incomplete packets if needed */
+	if (fpdu->incomplete_bytes == QED_IWARP_INVALID_FPDU_LENGTH) {
+		/* Missing lower byte is now available */
+		mpa_len = fpdu->fpdu_length | *mpa_data;
+		fpdu->fpdu_length = QED_IWARP_FPDU_LEN_WITH_PAD(mpa_len);
+		fpdu->mpa_frag_len = fpdu->fpdu_length;
+		/* one byte of hdr */
+		fpdu->incomplete_bytes = fpdu->fpdu_length - 1;
+		DP_VERBOSE(p_hwfn,
+			   QED_MSG_RDMA,
+			   "MPA_ALIGN: Partial header mpa_len=%x fpdu_length=%x incomplete_bytes=%x\n",
+			   mpa_len, fpdu->fpdu_length, fpdu->incomplete_bytes);
+	}
+}
+
 static int
 qed_iwarp_send_fpdu(struct qed_hwfn *p_hwfn,
 		    struct qed_iwarp_fpdu *fpdu,
@@ -1960,6 +1993,7 @@ enum qed_iwarp_mpa_pkt_type {
 			curr_pkt->first_mpa_offset += fpdu->fpdu_length;
 			break;
 		case QED_IWARP_MPA_PKT_UNALIGNED:
+			qed_iwarp_update_fpdu_length(p_hwfn, fpdu, mpa_data);
 			rc = qed_iwarp_send_fpdu(p_hwfn, fpdu, curr_pkt, buf,
 						 mpa_buf->tcp_payload_len,
 						 pkt_type);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.h b/drivers/net/ethernet/qlogic/qed/qed_iwarp.h
index 58db51a..c58793a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.h
@@ -69,6 +69,12 @@ struct qed_iwarp_ll2_mpa_buf {
 	u8 placement_offset;
 };
 
+/* In some cases a fpdu will arrive with only one byte of the header, in this
+ * case the fpdu_length will be partial (contain only higher byte and
+ * incomplete bytes will contain the invalid value
+ */
+#define QED_IWARP_INVALID_INCOMPLETE_BYTES 0xffff
+
 struct qed_iwarp_fpdu {
 	struct qed_iwarp_ll2_buff *mpa_buf;
 	void *mpa_frag_virt;
-- 
1.8.3.1

      parent reply	other threads:[~2017-10-03  8:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03  8:54 [PATCH v2 net-next 00/12] qed: Add iWARP support for unaligned MPA packets Michal Kalderon
2017-10-03  8:54 ` [PATCH v2 net-next 01/12] qed: Add ll2 option to limit the number of bds per packet Michal Kalderon
     [not found] ` <1507020902-4952-1-git-send-email-Michal.Kalderon-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
2017-10-03  8:54   ` [PATCH v2 net-next 02/12] qed: Add ll2 ability of opening a secondary queue Michal Kalderon
2017-10-03  8:54   ` [PATCH v2 net-next 04/12] qed: Fix initialization of ll2 offload feature Michal Kalderon
2017-10-03  8:54   ` [PATCH v2 net-next 07/12] qed: Add ll2 connection for processing unaligned MPA packets Michal Kalderon
2017-10-03  8:55   ` [PATCH v2 net-next 10/12] qed: Add support for freeing two ll2 buffers for corner cases Michal Kalderon
2017-10-03  8:55   ` [PATCH v2 net-next 12/12] qed: Add iWARP support for fpdu spanned over more than two tcp packets Michal Kalderon
2017-10-03  8:54 ` [PATCH v2 net-next 03/12] qed: Add ll2 option for dropping a tx packet Michal Kalderon
2017-10-03  8:54 ` [PATCH v2 net-next 05/12] qed: Add the source of a packet sent on an iWARP ll2 connection Michal Kalderon
2017-10-03  8:54 ` [PATCH v2 net-next 06/12] qed: Add LL2 slowpath handling Michal Kalderon
     [not found]   ` <1507020902-4952-7-git-send-email-Michal.Kalderon-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
2017-10-03 13:26     ` Leon Romanovsky
     [not found]       ` <20171003132632.GB25829-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-10-03 19:48         ` Kalderon, Michal
2017-10-03 17:17     ` David Miller
     [not found]       ` <20171003.101712.715882117516958741.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-10-03 18:05         ` Kalderon, Michal
     [not found]           ` <CY1PR0701MB20128130D21FD3C54E45B5A188720-UpKza+2NMNLHMJvQ0dyT705OhdzP3rhOnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-10-05 18:59             ` Kalderon, Michal
     [not found]               ` <CY1PR0701MB2012A2F8E3E923D98B1E1A6488700-UpKza+2NMNLHMJvQ0dyT705OhdzP3rhOnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-10-05 19:06                 ` David Miller
     [not found]                   ` <20171005.120629.2161199733119811102.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-10-05 20:27                     ` Kalderon, Michal
2017-10-06  0:20                       ` David Miller
     [not found]                         ` <20171005.172013.746380495399822.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-10-06  5:09                           ` Kalderon, Michal
2017-10-09  4:40             ` David Miller
2017-10-03  8:54 ` [PATCH v2 net-next 08/12] qed: Add mpa buffer descriptors for storing and processing mpa fpdus Michal Kalderon
2017-10-03  8:54 ` [PATCH v2 net-next 09/12] qed: Add unaligned and packed packet processing Michal Kalderon
2017-10-03  8:55 ` Michal Kalderon [this message]

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=1507020902-4952-12-git-send-email-Michal.Kalderon@cavium.com \
    --to=michal.kalderon@cavium.com \
    --cc=Ariel.Elior@cavium.com \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox