target: iscsi: cxgbit: fix max iso npdu calculation
PATCH 1/1 target: iscsi: cxgbit: fix max iso npdu calculation
- rounddown CXGBIT_MAX_ISO_PAYLOAD by csk->emss before calculating max_iso_npdu to get max TCP payload in multiple of mss.
- call cxgbit_set_digest() before cxgbit_set_iso_npdu() to set csk->submode, it is used in calculating number of iso pdus.
--- drivers/target/iscsi/cxgbit/cxgbit_target.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/target/iscsi/cxgbit/cxgbit_target.c +9 -7
@@ -652,6 +652,7 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)struct iscsi_param *param;u32 mrdsl, mbl;u32 max_npdu, max_iso_npdu; +u32 max_iso_payload;if (conn->login->leading_connection) { param = iscsi_find_param_from_key(MAXBURSTLENGTH,
@@ -670,8 +671,10 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk) mrdsl = conn_ops->MaxRecvDataSegmentLength; max_npdu = mbl / mrdsl; - max_iso_npdu =CXGBIT_MAX_ISO_PAYLOAD / - (ISCSI_HDR_LEN + mrdsl + + max_iso_payload =rounddown (CXGBIT_MAX_ISO_PAYLOAD , csk->emss); + + max_iso_npdu = max_iso_payload / + (ISCSI_HDR_LEN + mrdsl + cxgbit_digest_len[csk->submode]); csk->max_iso_npdu =min (max_npdu, max_iso_npdu);
@@ -741,6 +744,9 @@ static int cxgbit_set_params(struct iscsi_conn *conn)if (conn_ops->MaxRecvDataSegmentLength > cdev->mdsl) conn_ops->MaxRecvDataSegmentLength = cdev->mdsl; +if (cxgbit_set_digest (csk)) +return -1 ; +if (conn->login->leading_connection) { param =iscsi_find_param_from_key (ERRORRECOVERYLEVEL , conn->param_list);
@@ -764,7 +770,7 @@ static int cxgbit_set_params(struct iscsi_conn *conn)if (is_t5 (cdev->lldi.adapter_type)) goto enable_ddp;else - goto enable_digest; +return 0 ; }if (test_bit (CDEV_ISO_ENABLE , &cdev->flags)) {
@@ -781,10 +787,6 @@ static int cxgbit_set_params(struct iscsi_conn *conn) } } -enable_digest: -if (cxgbit_set_digest (csk)) -return -1 ; -return 0 ; }
Signature · 1 line
2.0.2
Quoted 58 lines · Varun Prakash
- rounddown
CXGBIT_MAX_ISO_PAYLOADbycsk->emssbefore calculatingmax_iso_npduto get max TCP payload in multiple of mss.- call
cxgbit_set_digest()beforecxgbit_set_iso_npdu()to setcsk->submode, it is used in calculating number of iso pdus.Signed-off-by Varun Prakash <[email protected]>--- drivers/target/iscsi/cxgbit/cxgbit_target.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/target/iscsi/cxgbit/cxgbit_target.c +9
-3@@ -652,6 +652,7 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)struct iscsi_param *param;u32 mrdsl, mbl;u32 max_npdu, max_iso_npdu; +u32 max_iso_payload;if (conn->login->leading_connection) { param = iscsi_find_param_from_key(MAXBURSTLENGTH,@@ -670,8 +671,10 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk) mrdsl = conn_ops->MaxRecvDataSegmentLength; max_npdu = mbl / mrdsl; - max_iso_npdu =CXGBIT_MAX_ISO_PAYLOAD / - (ISCSI_HDR_LEN + mrdsl + + max_iso_payload =rounddown (CXGBIT_MAX_ISO_PAYLOAD , csk->emss); + + max_iso_npdu = max_iso_payload / + (ISCSI_HDR_LEN + mrdsl + cxgbit_digest_len[csk->submode]); csk->max_iso_npdu =min (max_npdu, max_iso_npdu);@@ -741,6 +744,9 @@ static int cxgbit_set_params(struct iscsi_conn *conn)if (conn_ops->MaxRecvDataSegmentLength > cdev->mdsl) conn_ops->MaxRecvDataSegmentLength = cdev->mdsl; +if (cxgbit_set_digest (csk)) +return -1 ; +if (conn->login->leading_connection) { param =iscsi_find_param_from_key (ERRORRECOVERYLEVEL , conn->param_list);@@ -764,7 +770,7 @@ static int cxgbit_set_params(struct iscsi_conn *conn)if (is_t5 (cdev->lldi.adapter_type)) goto enable_ddp;else - goto enable_digest; +return 0 ; }if (test_bit (CDEV_ISO_ENABLE , &cdev->flags)) {
drivers/target/iscsi/cxgbit/cxgbit_target.c static int cxgbit_set_params(struct iscsi_conn *conn) · line 792
Quoted 10 lines
drivers/target/iscsi/cxgbit/cxgbit_target.c +0
-4@@ -781,10 +787,6 @@ static int cxgbit_set_params(struct iscsi_conn *conn) } } -enable_digest: -if (cxgbit_set_digest (csk)) -return -1 ; -return 0 ; }
Looks ok to me.
Martin K. Petersen
AppliedVarun,
Quoted 7 lines
- rounddown
CXGBIT_MAX_ISO_PAYLOADbycsk->emssbefore calculatingmax_iso_npduto get max TCP payload in multiple of mss.- call
cxgbit_set_digest()beforecxgbit_set_iso_npdu()to setcsk->submode, it is used in calculating number of iso pdus.
Applied to 4.18/scsi-fixes. Thank you!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering