[Stgt-devel] [PATCH 15/18] iser rounding
Pete Wyckoff
pw
Tue Sep 4 22:11:13 CEST 2007
RDMA data packets are not padded up to 4 byte boundaries, unlike TCP.
Reasons for this can be found in doc/README.iser.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsid.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index f72073b..05ca46b 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1162,7 +1162,9 @@ static int iscsi_target_cmd_queue(struct iscsi_task *task)
uint32_t len;
void *buf;
- len = roundup(task->read_len, 4);
+ len = task->read_len;
+ if (!conn->tp->rdma)
+ len = roundup(len, 4);
buf = conn->tp->ep_malloc(conn, len);
if (!buf)
return -ENOMEM;
@@ -1428,8 +1430,12 @@ static int iscsi_scsi_cmd_rx_start(struct iscsi_connection *conn)
int ahs_len, imm_len, data_len, task_len;
ahs_len = roundup(req->hlength * 4, 4);
- imm_len = roundup(ntoh24(req->dlength), 4);
- data_len = roundup(ntohl(req->data_length), 4);
+ imm_len = ntoh24(req->dlength);
+ data_len = ntohl(req->data_length);
+ if (!conn->tp->rdma) {
+ imm_len = roundup(imm_len, 4);
+ data_len = roundup(data_len, 4);
+ }
dprintf("%u %x %d %d %d %x %x\n", conn->session->tsih,
req->cdb[0], ahs_len, imm_len, data_len,
@@ -1813,7 +1819,7 @@ again:
}
conn->req.ahssize = conn->req.bhs.hlength * 4;
conn->req.datasize = ntoh24(conn->req.bhs.dlength);
- conn->rx_size = roundup(conn->req.ahssize, 4);
+ conn->rx_size = conn->req.ahssize;
if (conn->rx_size) {
conn->rx_buffer = conn->req.ahs;
conn->rx_iostate = IOSTATE_RX_AHS;
@@ -1862,7 +1868,10 @@ again:
}
conn->rx_iostate = IOSTATE_RX_INIT_DATA;
case IOSTATE_RX_INIT_DATA:
- conn->rx_size = roundup(conn->req.datasize, 4);
+ if (conn->tp->rdma)
+ conn->rx_size = conn->req.datasize;
+ else
+ conn->rx_size = roundup(conn->req.datasize, 4);
if (conn->rx_size) {
conn->rx_iostate = IOSTATE_RX_DATA;
conn->rx_buffer = conn->req.data;
@@ -2002,12 +2011,13 @@ void iscsi_tx_handler(struct iscsi_connection *conn)
break;
case IOSTATE_TX_INIT_DATA:
if (conn->rsp.datasize) {
- int pad;
+ int pad = 0;
conn->tx_iostate = IOSTATE_TX_DATA;
conn->tx_buffer = conn->rsp.data;
conn->tx_size = conn->rsp.datasize;
- pad = conn->tx_size & (PAD_WORD_LEN - 1);
+ if (!conn->tp->rdma)
+ pad = conn->tx_size & (PAD_WORD_LEN - 1);
if (pad) {
pad = PAD_WORD_LEN - pad;
memset(conn->tx_buffer + conn->tx_size, 0, pad);
--
1.5.2.5
More information about the stgt
mailing list