Skip to content

Commit c7d1d83

Browse files
mkalderondavem330
authored andcommitted
qed: Add support for MPA header being split over two tcp packets
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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d531038 commit c7d1d83

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

drivers/net/ethernet/qlogic/qed/qed_iwarp.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,7 @@ enum qed_iwarp_mpa_pkt_type {
17421742
QED_IWARP_MPA_PKT_UNALIGNED
17431743
};
17441744

1745+
#define QED_IWARP_INVALID_FPDU_LENGTH 0xffff
17451746
#define QED_IWARP_MPA_FPDU_LENGTH_SIZE (2)
17461747
#define QED_IWARP_MPA_CRC32_DIGEST_SIZE (4)
17471748

@@ -1774,6 +1775,15 @@ qed_iwarp_mpa_classify(struct qed_hwfn *p_hwfn,
17741775
goto out;
17751776
}
17761777

1778+
/* special case of one byte remaining...
1779+
* lower byte will be read next packet
1780+
*/
1781+
if (tcp_payload_len == 1) {
1782+
fpdu->fpdu_length = *mpa_data << BITS_PER_BYTE;
1783+
pkt_type = QED_IWARP_MPA_PKT_PARTIAL;
1784+
goto out;
1785+
}
1786+
17771787
mpa_len = ntohs(*((u16 *)(mpa_data)));
17781788
fpdu->fpdu_length = QED_IWARP_FPDU_LEN_WITH_PAD(mpa_len);
17791789

@@ -1802,14 +1812,37 @@ qed_iwarp_init_fpdu(struct qed_iwarp_ll2_buff *buf,
18021812
fpdu->mpa_frag = buf->data_phys_addr + pkt_data->first_mpa_offset;
18031813
fpdu->mpa_frag_virt = (u8 *)(buf->data) + pkt_data->first_mpa_offset;
18041814

1805-
if (tcp_payload_size < fpdu->fpdu_length)
1815+
if (tcp_payload_size == 1)
1816+
fpdu->incomplete_bytes = QED_IWARP_INVALID_FPDU_LENGTH;
1817+
else if (tcp_payload_size < fpdu->fpdu_length)
18061818
fpdu->incomplete_bytes = fpdu->fpdu_length - tcp_payload_size;
18071819
else
18081820
fpdu->incomplete_bytes = 0; /* complete fpdu */
18091821

18101822
fpdu->mpa_frag_len = fpdu->fpdu_length - fpdu->incomplete_bytes;
18111823
}
18121824

1825+
static void
1826+
qed_iwarp_update_fpdu_length(struct qed_hwfn *p_hwfn,
1827+
struct qed_iwarp_fpdu *fpdu, u8 *mpa_data)
1828+
{
1829+
u16 mpa_len;
1830+
1831+
/* Update incomplete packets if needed */
1832+
if (fpdu->incomplete_bytes == QED_IWARP_INVALID_FPDU_LENGTH) {
1833+
/* Missing lower byte is now available */
1834+
mpa_len = fpdu->fpdu_length | *mpa_data;
1835+
fpdu->fpdu_length = QED_IWARP_FPDU_LEN_WITH_PAD(mpa_len);
1836+
fpdu->mpa_frag_len = fpdu->fpdu_length;
1837+
/* one byte of hdr */
1838+
fpdu->incomplete_bytes = fpdu->fpdu_length - 1;
1839+
DP_VERBOSE(p_hwfn,
1840+
QED_MSG_RDMA,
1841+
"MPA_ALIGN: Partial header mpa_len=%x fpdu_length=%x incomplete_bytes=%x\n",
1842+
mpa_len, fpdu->fpdu_length, fpdu->incomplete_bytes);
1843+
}
1844+
}
1845+
18131846
static int
18141847
qed_iwarp_send_fpdu(struct qed_hwfn *p_hwfn,
18151848
struct qed_iwarp_fpdu *fpdu,
@@ -1960,6 +1993,7 @@ qed_iwarp_process_mpa_pkt(struct qed_hwfn *p_hwfn,
19601993
curr_pkt->first_mpa_offset += fpdu->fpdu_length;
19611994
break;
19621995
case QED_IWARP_MPA_PKT_UNALIGNED:
1996+
qed_iwarp_update_fpdu_length(p_hwfn, fpdu, mpa_data);
19631997
rc = qed_iwarp_send_fpdu(p_hwfn, fpdu, curr_pkt, buf,
19641998
mpa_buf->tcp_payload_len,
19651999
pkt_type);

drivers/net/ethernet/qlogic/qed/qed_iwarp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ struct qed_iwarp_ll2_mpa_buf {
6969
u8 placement_offset;
7070
};
7171

72+
/* In some cases a fpdu will arrive with only one byte of the header, in this
73+
* case the fpdu_length will be partial (contain only higher byte and
74+
* incomplete bytes will contain the invalid value
75+
*/
76+
#define QED_IWARP_INVALID_INCOMPLETE_BYTES 0xffff
77+
7278
struct qed_iwarp_fpdu {
7379
struct qed_iwarp_ll2_buff *mpa_buf;
7480
void *mpa_frag_virt;

0 commit comments

Comments
 (0)