Re: [PATCH 1/3] scsi_transport_iscsi: Add stats support for iscsi host

2016-04-22 Thread Mike Christie
On 04/22/2016 08:39 AM, adheer.chandravan...@qlogic.com wrote:
> From: Adheer Chandravanshi 
> 
> Add stats for iscsi initiator that will be maintained at iscsi host level
> and will be exported as iscsi_host sysfs attributes.
> 
> Signed-off-by: Adheer Chandravanshi 
> ---
>  drivers/scsi/scsi_transport_iscsi.c | 51 
> +
>  include/scsi/iscsi_if.h | 24 +
>  2 files changed, 75 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_transport_iscsi.c 
> b/drivers/scsi/scsi_transport_iscsi.c
> index 42bca61..076843c 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -4253,6 +4253,21 @@ iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS);
>  iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME);
>  iscsi_host_attr(port_state, ISCSI_HOST_PARAM_PORT_STATE);
>  iscsi_host_attr(port_speed, ISCSI_HOST_PARAM_PORT_SPEED);
> +iscsi_host_attr(login_accept_rsps, ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS);
> +iscsi_host_attr(login_other_fails, ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS);
> +iscsi_host_attr(login_authentication_fails,
> + ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS);
> +iscsi_host_attr(login_authorization_fails,
> + ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS);
> +iscsi_host_attr(login_negotiation_fails,
> + ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS);
> +iscsi_host_attr(login_redirect_rsps, ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS);
> +iscsi_host_attr(logout_normal_rsps, ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS);
> +iscsi_host_attr(logout_other_rsps, ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS);
> +iscsi_host_attr(digest_err, ISCSI_HOST_PARAM_DIGEST_ERR);
> +iscsi_host_attr(timeout_err, ISCSI_HOST_PARAM_TIMEOUT_ERR);
> +iscsi_host_attr(format_err, ISCSI_HOST_PARAM_FORMAT_ERR);
> +iscsi_host_attr(session_fails, ISCSI_HOST_PARAM_SESSION_FAILS);
>  
>  static struct attribute *iscsi_host_attrs[] = {
>   &dev_attr_host_netdev.attr,
> @@ -4261,6 +4276,18 @@ static struct attribute *iscsi_host_attrs[] = {
>   &dev_attr_host_initiatorname.attr,
>   &dev_attr_host_port_state.attr,
>   &dev_attr_host_port_speed.attr,
> + &dev_attr_host_login_accept_rsps.attr,
> + &dev_attr_host_login_other_fails.attr,
> + &dev_attr_host_login_authentication_fails.attr,
> + &dev_attr_host_login_authorization_fails.attr,
> + &dev_attr_host_login_negotiation_fails.attr,
> + &dev_attr_host_login_redirect_rsps.attr,
> + &dev_attr_host_logout_normal_rsps.attr,
> + &dev_attr_host_logout_other_rsps.attr,
> + &dev_attr_host_digest_err.attr,
> + &dev_attr_host_timeout_err.attr,
> + &dev_attr_host_format_err.attr,
> + &dev_attr_host_session_fails.attr,
>   NULL,
>  };
>  
> @@ -4284,6 +4311,30 @@ static umode_t iscsi_host_attr_is_visible(struct 
> kobject *kobj,
>   param = ISCSI_HOST_PARAM_PORT_STATE;
>   else if (attr == &dev_attr_host_port_speed.attr)
>   param = ISCSI_HOST_PARAM_PORT_SPEED;
> + else if (attr == &dev_attr_host_login_accept_rsps.attr)
> + param = ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS;
> + else if (attr == &dev_attr_host_login_other_fails.attr)
> + param = ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS;
> + else if (attr == &dev_attr_host_login_authentication_fails.attr)
> + param = ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS;
> + else if (attr == &dev_attr_host_login_authorization_fails.attr)
> + param = ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS;
> + else if (attr == &dev_attr_host_login_negotiation_fails.attr)
> + param = ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS;
> + else if (attr == &dev_attr_host_login_redirect_rsps.attr)
> + param = ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS;
> + else if (attr == &dev_attr_host_logout_normal_rsps.attr)
> + param = ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS;
> + else if (attr == &dev_attr_host_logout_other_rsps.attr)
> + param = ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS;
> + else if (attr == &dev_attr_host_digest_err.attr)
> + param = ISCSI_HOST_PARAM_DIGEST_ERR;
> + else if (attr == &dev_attr_host_timeout_err.attr)
> + param = ISCSI_HOST_PARAM_TIMEOUT_ERR;
> + else if (attr == &dev_attr_host_format_err.attr)
> + param = ISCSI_HOST_PARAM_FORMAT_ERR;
> + else if (attr == &dev_attr_host_session_fails.attr)
> + param = ISCSI_HOST_PARAM_SESSION_FAILS;
>   else {
>   WARN_ONCE(1, "Invalid host attr");
>   return 0;
> diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
> index d66c070..d6a3909 100644
> --- a/include/scsi/iscsi_if.h
> +++ b/include/scsi/iscsi_if.h
> @@ -632,6 +632,18 @@ enum iscsi_host_param {
>   ISCSI_HOST_PARAM_IPADDRESS,
>   ISCSI_HOST_PARAM_PORT_STATE,
>   ISCSI_HOST_PARAM_PORT_SPEED,
> + ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS,
> + ISCSI_HOST_PARAM

[ANNOUNCE] new open-iscsi maintainers

2016-04-22 Thread Mike Christie
Hi open-iscsi list,

I am very happy to announce that Chris Leech and Lee Duncan will be
taking over open-iscsi maintainership.

They have created a new github organization:

https://github.com/open-iscsi

that will host the userspace code.

Send all userspace patches to the list and to Chris Leech
(cle...@redhat.com) and Lee Duncan (ldun...@suse.com).

Send kernel patches to this list, myself, and also to Lee and Chris. In
the hopefully near future, they will be comfortable with taking over the
kernel code as well.

Thanks to Lee and Chris for taking this over!

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH] SCSI: LIBSCSI: Fixed codeing style errors

2016-04-22 Thread Bob Stlt
Fixed codeing style formatting errors.

Signed-off-by: Bob Stlt 
---
 drivers/scsi/libiscsi.c | 90 -
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 6bffd91..41be9d3 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -197,7 +197,7 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
pad_len = iscsi_padding(rlen);
 
rc = iscsi_add_hdr(task, sizeof(ecdb_ahdr->ahslength) +
-  sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
+   sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
if (rc)
return rc;
 
@@ -210,10 +210,10 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
memcpy(ecdb_ahdr->ecdb, cmd->cmnd + ISCSI_CDB_SIZE, rlen);
 
ISCSI_DBG_SESSION(task->conn->session,
- "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
- "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
- "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
- task->hdr_len);
+   "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
+   "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
+   "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
+   task->hdr_len);
return 0;
 }
 
@@ -236,10 +236,10 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task)
rlen_ahdr->read_length = cpu_to_be32(scsi_in(sc)->length);
 
ISCSI_DBG_SESSION(task->conn->session,
- "bidi-in rlen_ahdr->read_length(%d) "
- "rlen_ahdr->ahslength(%d)\n",
- be32_to_cpu(rlen_ahdr->read_length),
- be16_to_cpu(rlen_ahdr->ahslength));
+   "bidi-in rlen_ahdr->read_length(%d) "
+   "rlen_ahdr->ahslength(%d)\n",
+   be32_to_cpu(rlen_ahdr->read_length),
+   be16_to_cpu(rlen_ahdr->ahslength));
return 0;
 }
 
@@ -500,7 +500,7 @@ static void iscsi_free_task(struct iscsi_task *task)
if (conn->login_task == task)
return;
 
-   kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));
+   kfifo_in(&session->cmdpool.queue, (void *)&task, sizeof(void *));
 
if (sc) {
/* SCSI eh reuses commands to verify us */
@@ -736,7 +736,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
 
if (!kfifo_out(&session->cmdpool.queue,
-(void*)&task, sizeof(void*)))
+(void *)&task, sizeof(void *)))
return NULL;
}
/*
@@ -831,7 +831,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
struct iscsi_session *session = conn->session;
struct scsi_cmnd *sc = task->sc;
 
-   iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
+   iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr);
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
 
sc->result = (DID_OK << 16) | rhdr->cmd_status;
@@ -901,12 +901,12 @@ invalid_datalen:
}
 
if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
-  ISCSI_FLAG_CMD_OVERFLOW)) {
+   ISCSI_FLAG_CMD_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);
 
if (res_count > 0 &&
(rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
-res_count <= scsi_bufflen(sc)))
+   res_count <= scsi_bufflen(sc)))
/* write side for bidi or uni-io set_resid */
scsi_set_resid(sc, res_count);
else
@@ -939,7 +939,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr 
*hdr,
sc->result = (DID_OK << 16) | rhdr->cmd_status;
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
-  ISCSI_FLAG_DATA_OVERFLOW)) {
+   ISCSI_FLAG_DATA_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);
 
if (res_count > 0 &&
@@ -978,7 +978,7 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr)
 
 static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
 {
-struct iscsi_nopout hdr;
+   struct iscsi_nopout hdr;
struct iscsi_task *task;
 
if (!rhdr && conn->ping_task)
@@ -1080,7 +1080,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
spin_unlock(&conn->session->back_lock);
spin_lock(

Re: libiscsi: Use scsi helper to set information descriptor

2016-04-22 Thread Sagi Grimberg

Hey Dan,


Hello Sagi Grimberg,

The patch a73c2a2f9123: "libiscsi: Use scsi helper to set information
descriptor" from Jul 15, 2015, leads to the following static checker
warning:

drivers/scsi/libiscsi.c:858 iscsi_scsi_cmd_rsp()
error: XXX uninitialized symbol 'sector'.

drivers/scsi/libiscsi.c
850  ascq = session->tt->check_protection(task, §or);

If "ascq" is 0x1 then there sector might not be initialized.  The
documentation is not clear on how that works.  Har dee har har.  The
oldest jokes are still the best...  :P


iscsi transports that implement this callout are expected
to set the sector which is passed by reference.

would it make the checker happy if we set sector to 0 before
calling check_protection (although it's not needed by no means)?

--
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


re: libiscsi: Use scsi helper to set information descriptor

2016-04-22 Thread Dan Carpenter
Hello Sagi Grimberg,

The patch a73c2a2f9123: "libiscsi: Use scsi helper to set information
descriptor" from Jul 15, 2015, leads to the following static checker
warning:

drivers/scsi/libiscsi.c:858 iscsi_scsi_cmd_rsp()
error: XXX uninitialized symbol 'sector'.

drivers/scsi/libiscsi.c
   850  ascq = session->tt->check_protection(task, §or);

If "ascq" is 0x1 then there sector might not be initialized.  The
documentation is not clear on how that works.  Har dee har har.  The
oldest jokes are still the best...  :P

   851  if (ascq) {
   852  sc->result = DRIVER_SENSE << 24 |
   853   SAM_STAT_CHECK_CONDITION;
   854  scsi_build_sense_buffer(1, sc->sense_buffer,
   855  ILLEGAL_REQUEST, 0x10, 
ascq);
   856  scsi_set_sense_information(sc->sense_buffer,
   857 
SCSI_SENSE_BUFFERSIZE,
   858 sector);
   859  goto out;
   860  }

regards,
dan carpenter

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH] SCSI: LIBSCSI: Fixed codeing style errors

2016-04-22 Thread Bob Stlt
Fixed codeing style formatting errors.

Signed-off-by: Bob Stlt 
---
 drivers/scsi/libiscsi.c | 90 -
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 6bffd91..41be9d3 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -197,7 +197,7 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
pad_len = iscsi_padding(rlen);
 
rc = iscsi_add_hdr(task, sizeof(ecdb_ahdr->ahslength) +
-  sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
+   sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
if (rc)
return rc;
 
@@ -210,10 +210,10 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
memcpy(ecdb_ahdr->ecdb, cmd->cmnd + ISCSI_CDB_SIZE, rlen);
 
ISCSI_DBG_SESSION(task->conn->session,
- "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
- "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
- "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
- task->hdr_len);
+   "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
+   "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
+   "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
+   task->hdr_len);
return 0;
 }
 
@@ -236,10 +236,10 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task)
rlen_ahdr->read_length = cpu_to_be32(scsi_in(sc)->length);
 
ISCSI_DBG_SESSION(task->conn->session,
- "bidi-in rlen_ahdr->read_length(%d) "
- "rlen_ahdr->ahslength(%d)\n",
- be32_to_cpu(rlen_ahdr->read_length),
- be16_to_cpu(rlen_ahdr->ahslength));
+   "bidi-in rlen_ahdr->read_length(%d) "
+   "rlen_ahdr->ahslength(%d)\n",
+   be32_to_cpu(rlen_ahdr->read_length),
+   be16_to_cpu(rlen_ahdr->ahslength));
return 0;
 }
 
@@ -500,7 +500,7 @@ static void iscsi_free_task(struct iscsi_task *task)
if (conn->login_task == task)
return;
 
-   kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));
+   kfifo_in(&session->cmdpool.queue, (void *)&task, sizeof(void *));
 
if (sc) {
/* SCSI eh reuses commands to verify us */
@@ -736,7 +736,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
 
if (!kfifo_out(&session->cmdpool.queue,
-(void*)&task, sizeof(void*)))
+(void *)&task, sizeof(void *)))
return NULL;
}
/*
@@ -831,7 +831,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
struct iscsi_session *session = conn->session;
struct scsi_cmnd *sc = task->sc;
 
-   iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
+   iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr);
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
 
sc->result = (DID_OK << 16) | rhdr->cmd_status;
@@ -901,12 +901,12 @@ invalid_datalen:
}
 
if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
-  ISCSI_FLAG_CMD_OVERFLOW)) {
+   ISCSI_FLAG_CMD_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);
 
if (res_count > 0 &&
(rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
-res_count <= scsi_bufflen(sc)))
+   res_count <= scsi_bufflen(sc)))
/* write side for bidi or uni-io set_resid */
scsi_set_resid(sc, res_count);
else
@@ -939,7 +939,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr 
*hdr,
sc->result = (DID_OK << 16) | rhdr->cmd_status;
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
-  ISCSI_FLAG_DATA_OVERFLOW)) {
+   ISCSI_FLAG_DATA_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);
 
if (res_count > 0 &&
@@ -978,7 +978,7 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr)
 
 static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
 {
-struct iscsi_nopout hdr;
+   struct iscsi_nopout hdr;
struct iscsi_task *task;
 
if (!rhdr && conn->ping_task)
@@ -1080,7 +1080,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
spin_unlock(&conn->session->back_lock);
spin_lock(

[PATCH] SCSI: LIBSCSI: Fixed codeing style errors

2016-04-22 Thread Bob Stlt
Fixed codeing style formatting errors.

Signed-off-by: Bob Stlt 
---
 drivers/scsi/libiscsi.c | 90 -
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 6bffd91..41be9d3 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -197,7 +197,7 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
pad_len = iscsi_padding(rlen);
 
rc = iscsi_add_hdr(task, sizeof(ecdb_ahdr->ahslength) +
-  sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
+   sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
if (rc)
return rc;
 
@@ -210,10 +210,10 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
memcpy(ecdb_ahdr->ecdb, cmd->cmnd + ISCSI_CDB_SIZE, rlen);
 
ISCSI_DBG_SESSION(task->conn->session,
- "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
- "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
- "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
- task->hdr_len);
+   "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
+   "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
+   "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
+   task->hdr_len);
return 0;
 }
 
@@ -236,10 +236,10 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task)
rlen_ahdr->read_length = cpu_to_be32(scsi_in(sc)->length);
 
ISCSI_DBG_SESSION(task->conn->session,
- "bidi-in rlen_ahdr->read_length(%d) "
- "rlen_ahdr->ahslength(%d)\n",
- be32_to_cpu(rlen_ahdr->read_length),
- be16_to_cpu(rlen_ahdr->ahslength));
+   "bidi-in rlen_ahdr->read_length(%d) "
+   "rlen_ahdr->ahslength(%d)\n",
+   be32_to_cpu(rlen_ahdr->read_length),
+   be16_to_cpu(rlen_ahdr->ahslength));
return 0;
 }
 
@@ -500,7 +500,7 @@ static void iscsi_free_task(struct iscsi_task *task)
if (conn->login_task == task)
return;
 
-   kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));
+   kfifo_in(&session->cmdpool.queue, (void *)&task, sizeof(void *));
 
if (sc) {
/* SCSI eh reuses commands to verify us */
@@ -736,7 +736,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
 
if (!kfifo_out(&session->cmdpool.queue,
-(void*)&task, sizeof(void*)))
+(void *)&task, sizeof(void *)))
return NULL;
}
/*
@@ -831,7 +831,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
struct iscsi_session *session = conn->session;
struct scsi_cmnd *sc = task->sc;
 
-   iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
+   iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr);
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
 
sc->result = (DID_OK << 16) | rhdr->cmd_status;
@@ -901,12 +901,12 @@ invalid_datalen:
}
 
if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
-  ISCSI_FLAG_CMD_OVERFLOW)) {
+   ISCSI_FLAG_CMD_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);
 
if (res_count > 0 &&
(rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
-res_count <= scsi_bufflen(sc)))
+   res_count <= scsi_bufflen(sc)))
/* write side for bidi or uni-io set_resid */
scsi_set_resid(sc, res_count);
else
@@ -939,7 +939,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr 
*hdr,
sc->result = (DID_OK << 16) | rhdr->cmd_status;
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
-  ISCSI_FLAG_DATA_OVERFLOW)) {
+   ISCSI_FLAG_DATA_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);
 
if (res_count > 0 &&
@@ -978,7 +978,7 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr)
 
 static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
 {
-struct iscsi_nopout hdr;
+   struct iscsi_nopout hdr;
struct iscsi_task *task;
 
if (!rhdr && conn->ping_task)
@@ -1080,7 +1080,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
spin_unlock(&conn->session->back_lock);
spin_lock(

Re: libiscsi: Use scsi helper to set information descriptor

2016-04-22 Thread Dan Carpenter
On Wed, Apr 13, 2016 at 05:53:08PM +0300, Sagi Grimberg wrote:
> Hey Dan,
> 
> >Hello Sagi Grimberg,
> >
> >The patch a73c2a2f9123: "libiscsi: Use scsi helper to set information
> >descriptor" from Jul 15, 2015, leads to the following static checker
> >warning:
> >
> > drivers/scsi/libiscsi.c:858 iscsi_scsi_cmd_rsp()
> > error: XXX uninitialized symbol 'sector'.
> >
> >drivers/scsi/libiscsi.c
> >850  ascq = session->tt->check_protection(task, §or);
> >
> >If "ascq" is 0x1 then there sector might not be initialized.  The
> >documentation is not clear on how that works.  Har dee har har.  The
> >oldest jokes are still the best...  :P
> 
> iscsi transports that implement this callout are expected
> to set the sector which is passed by reference.

There is only iscsi_iser_check_protection() I think. It behaves how I
described in my original email.  If ib_check_mr_status() fails it
returns without setting sector.

> 
> would it make the checker happy if we set sector to 0 before
> calling check_protection (although it's not needed by no means)?

It looks for if there is any possible way that it could be uninitialized
so that would solve the problem.

regards,
dan carpenter

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


Re: [PATCH] SCSI: LIBSCSI: Fixed codeing style errors

2016-04-22 Thread Douglas Gilbert

On 16-04-20 03:51 AM, Bob Stlt wrote:

Fixed codeing style formatting errors.

Signed-off-by: Bob Stlt 
---
  drivers/scsi/libiscsi.c | 90 -
  1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 6bffd91..41be9d3 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -197,7 +197,7 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
pad_len = iscsi_padding(rlen);

rc = iscsi_add_hdr(task, sizeof(ecdb_ahdr->ahslength) +
-  sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);
+   sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len);


Seriously? checkpatch.pl in the current linux-stable.git is
allowing me to add a minimum number of spaces immediately
before a name so it is aligned to beginning of the first
argument of a function. IMO that is more readable that what is
proposed above.


if (rc)
return rc;

@@ -210,10 +210,10 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
memcpy(ecdb_ahdr->ecdb, cmd->cmnd + ISCSI_CDB_SIZE, rlen);

ISCSI_DBG_SESSION(task->conn->session,
- "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
- "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
- "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
- task->hdr_len);
+   "iscsi_prep_ecdb_ahs: varlen_cdb_len %d "
+   "rlen %d pad_len %d ahs_length %d iscsi_headers_size "
+   "%u\n", cmd->cmd_len, rlen, pad_len, ahslength,
+   task->hdr_len);
return 0;


When I try something like the above, checkpatch.pl complains
about string concatenation across lines. When I put the whole
string on one line, it complains that the line is longer than 80
characters. That leads me to some string obfuscation which is
much less readable but gets the okay from checkpatch.pl :-)

Doug Gilbert


  }

@@ -236,10 +236,10 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task)
rlen_ahdr->read_length = cpu_to_be32(scsi_in(sc)->length);

ISCSI_DBG_SESSION(task->conn->session,
- "bidi-in rlen_ahdr->read_length(%d) "
- "rlen_ahdr->ahslength(%d)\n",
- be32_to_cpu(rlen_ahdr->read_length),
- be16_to_cpu(rlen_ahdr->ahslength));
+   "bidi-in rlen_ahdr->read_length(%d) "
+   "rlen_ahdr->ahslength(%d)\n",
+   be32_to_cpu(rlen_ahdr->read_length),
+   be16_to_cpu(rlen_ahdr->ahslength));
return 0;
  }

@@ -500,7 +500,7 @@ static void iscsi_free_task(struct iscsi_task *task)
if (conn->login_task == task)
return;

-   kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));
+   kfifo_in(&session->cmdpool.queue, (void *)&task, sizeof(void *));

if (sc) {
/* SCSI eh reuses commands to verify us */
@@ -736,7 +736,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);

if (!kfifo_out(&session->cmdpool.queue,
-(void*)&task, sizeof(void*)))
+(void *)&task, sizeof(void *)))
return NULL;
}
/*
@@ -831,7 +831,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
struct iscsi_session *session = conn->session;
struct scsi_cmnd *sc = task->sc;

-   iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
+   iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr);
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;

sc->result = (DID_OK << 16) | rhdr->cmd_status;
@@ -901,12 +901,12 @@ invalid_datalen:
}

if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
-  ISCSI_FLAG_CMD_OVERFLOW)) {
+   ISCSI_FLAG_CMD_OVERFLOW)) {
int res_count = be32_to_cpu(rhdr->residual_count);

if (res_count > 0 &&
(rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
-res_count <= scsi_bufflen(sc)))
+   res_count <= scsi_bufflen(sc)))
/* write side for bidi or uni-io set_resid */
scsi_set_resid(sc, res_count);
else
@@ -939,7 +939,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr 
*hdr,
sc->result = (DID_OK << 16) | rhdr->cmd_status;
conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
-  ISCSI_FLAG_DATA_OVERFLOW)) {
+   ISCSI_FLAG_DATA_OVERFLOW)) {
  

iscsi tools: Support for host statistics

2016-04-22 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

The following patch obsoletes the patchset posted earlier for
host stats.

This patch is based on kernel-based solution for host stats and
depends on following patches posted on linux-scsi list:
  scsi_transport_iscsi: Add support for stats param at host level
  libiscsi: Add support to update host stats param
  bnx2i: Enable support for host stats param

Adheer Chandravanshi (1):
  iscsiadm: Add support to show host stats from sysfs

 include/iscsi_if.h |   24 ++
 usr/idbm.c |   39 +++
 usr/idbm.h |4 ++-
 usr/idbm_fields.h  |   13 
 usr/iscsi_sysfs.c  |   86 
 usr/iscsi_sysfs.h  |3 ++
 usr/iscsiadm.c |   41 -
 usr/transport.c|1 +
 usr/transport.h|1 +
 9 files changed, 203 insertions(+), 9 deletions(-)

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH] iscsiadm: Add support to show host stats from sysfs

2016-04-22 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

This fetches and shows the host stats that are exported by kernel
iscsi modules through iscsi host sysfs attrs.

Signed-off-by: Adheer Chandravanshi 
---
 include/iscsi_if.h |   24 ++
 usr/idbm.c |   39 +++
 usr/idbm.h |4 ++-
 usr/idbm_fields.h  |   13 
 usr/iscsi_sysfs.c  |   86 
 usr/iscsi_sysfs.h  |3 ++
 usr/iscsiadm.c |   41 -
 usr/transport.c|1 +
 usr/transport.h|1 +
 9 files changed, 203 insertions(+), 9 deletions(-)

diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index 9d15811..7380541 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -639,6 +639,18 @@ enum iscsi_host_param {
ISCSI_HOST_PARAM_IPADDRESS,
ISCSI_HOST_PARAM_PORT_STATE,
ISCSI_HOST_PARAM_PORT_SPEED,
+   ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS,
+   ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS,
+   ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS,
+   ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS,
+   ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS,
+   ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS,
+   ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS,
+   ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS,
+   ISCSI_HOST_PARAM_DIGEST_ERR,
+   ISCSI_HOST_PARAM_TIMEOUT_ERR,
+   ISCSI_HOST_PARAM_FORMAT_ERR,
+   ISCSI_HOST_PARAM_SESSION_FAILS,
ISCSI_HOST_PARAM_MAX,
 };
 
@@ -824,6 +836,18 @@ struct iscsi_stats {
/* errors */
uint32_t digest_err;
uint32_t timeout_err;
+   uint32_t format_err;
+   uint32_t session_fails;
+
+   /* login/logout stats */
+   uint32_t login_accept_rsps;
+   uint32_t login_other_fails;
+   uint32_t login_authentication_fails;
+   uint32_t login_authorization_fails;
+   uint32_t login_negotiation_fails;
+   uint32_t login_redirect_rsps;
+   uint32_t logout_normal_rsps;
+   uint32_t logout_other_rsps;
 
/*
 * iSCSI Custom Statistics support, i.e. Transport could
diff --git a/usr/idbm.c b/usr/idbm.c
index 198a5ef..854b624 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -822,6 +822,36 @@ void idbm_recinfo_flashnode(struct flashnode_rec *r, 
recinfo_t *ri)
}
 }
 
+void idbm_recinfo_host_stats(struct iscsi_stats *r, recinfo_t *ri)
+{
+   int num = 0;
+
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGIN_ACCEPT_RSPS, ri, r,
+login_accept_rsps, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGIN_OTHER_FAILS, ri, r,
+login_other_fails, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGIN_AUTHENTICATION_FAILS, ri, r,
+login_authentication_fails, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGIN_AUTHORIZATION_FAILS, ri, r,
+login_authorization_fails, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGIN_NEGOTIATION_FAILS, ri, r,
+login_negotiation_fails, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGIN_REDIRECT_RSPS, ri, r,
+login_redirect_rsps, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGOUT_NORMAL_RSPS, ri, r,
+   logout_normal_rsps, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_LOGOUT_OTHER_RSPS, ri, r,
+logout_other_rsps, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_DIGEST_ERR, ri, r,
+digest_err, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_TIMEOUT_ERR, ri, r,
+timeout_err, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_FORMAT_ERR, ri, r,
+format_err, IDBM_SHOW, num, 1);
+   __recinfo_uint32(ISCSI_HOST_STATS_SESSION_FAILS, ri, r,
+session_fails, IDBM_SHOW, num, 1);
+}
+
 recinfo_t *idbm_recinfo_alloc(int max_keys)
 {
recinfo_t *info;
@@ -858,6 +888,9 @@ void idbm_print(int type, void *rec, int show, FILE *f)
case IDBM_PRINT_TYPE_FLASHNODE:
idbm_recinfo_flashnode((struct flashnode_rec *)rec, info);
break;
+   case IDBM_PRINT_TYPE_HOST_STATS:
+   idbm_recinfo_host_stats((struct iscsi_stats *)rec, info);
+   break;
}
 
fprintf(f, "%s\n", ISCSI_BEGIN_REC);
@@ -1296,6 +1329,12 @@ int idbm_print_node_and_iface_tree(void *data, 
node_rec_t *rec)
return 0;
 }
 
+int idbm_print_host_stats(struct iscsi_stats *stats)
+{
+   idbm_print(IDBM_PRINT_TYPE_HOST_STATS, stats, 1, stdout);
+   return 0;
+}
+
 static int
 get_params_from_disc_link(char *link, char **target, char **tpgt,
  char **address, char **port, char **ifaceid)
diff --git a/usr/idbm.h b/usr/idbm.h
index b9020fe..0f6fc6f 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -171,7 +171,8 @@ enum {
I

[PATCH 1/3] scsi_transport_iscsi: Add stats support for iscsi host

2016-04-22 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

Add stats for iscsi initiator that will be maintained at iscsi host level
and will be exported as iscsi_host sysfs attributes.

Signed-off-by: Adheer Chandravanshi 
---
 drivers/scsi/scsi_transport_iscsi.c | 51 +
 include/scsi/iscsi_if.h | 24 +
 2 files changed, 75 insertions(+)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 42bca61..076843c 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -4253,6 +4253,21 @@ iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS);
 iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME);
 iscsi_host_attr(port_state, ISCSI_HOST_PARAM_PORT_STATE);
 iscsi_host_attr(port_speed, ISCSI_HOST_PARAM_PORT_SPEED);
+iscsi_host_attr(login_accept_rsps, ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS);
+iscsi_host_attr(login_other_fails, ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS);
+iscsi_host_attr(login_authentication_fails,
+   ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS);
+iscsi_host_attr(login_authorization_fails,
+   ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS);
+iscsi_host_attr(login_negotiation_fails,
+   ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS);
+iscsi_host_attr(login_redirect_rsps, ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS);
+iscsi_host_attr(logout_normal_rsps, ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS);
+iscsi_host_attr(logout_other_rsps, ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS);
+iscsi_host_attr(digest_err, ISCSI_HOST_PARAM_DIGEST_ERR);
+iscsi_host_attr(timeout_err, ISCSI_HOST_PARAM_TIMEOUT_ERR);
+iscsi_host_attr(format_err, ISCSI_HOST_PARAM_FORMAT_ERR);
+iscsi_host_attr(session_fails, ISCSI_HOST_PARAM_SESSION_FAILS);
 
 static struct attribute *iscsi_host_attrs[] = {
&dev_attr_host_netdev.attr,
@@ -4261,6 +4276,18 @@ static struct attribute *iscsi_host_attrs[] = {
&dev_attr_host_initiatorname.attr,
&dev_attr_host_port_state.attr,
&dev_attr_host_port_speed.attr,
+   &dev_attr_host_login_accept_rsps.attr,
+   &dev_attr_host_login_other_fails.attr,
+   &dev_attr_host_login_authentication_fails.attr,
+   &dev_attr_host_login_authorization_fails.attr,
+   &dev_attr_host_login_negotiation_fails.attr,
+   &dev_attr_host_login_redirect_rsps.attr,
+   &dev_attr_host_logout_normal_rsps.attr,
+   &dev_attr_host_logout_other_rsps.attr,
+   &dev_attr_host_digest_err.attr,
+   &dev_attr_host_timeout_err.attr,
+   &dev_attr_host_format_err.attr,
+   &dev_attr_host_session_fails.attr,
NULL,
 };
 
@@ -4284,6 +4311,30 @@ static umode_t iscsi_host_attr_is_visible(struct kobject 
*kobj,
param = ISCSI_HOST_PARAM_PORT_STATE;
else if (attr == &dev_attr_host_port_speed.attr)
param = ISCSI_HOST_PARAM_PORT_SPEED;
+   else if (attr == &dev_attr_host_login_accept_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS;
+   else if (attr == &dev_attr_host_login_other_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS;
+   else if (attr == &dev_attr_host_login_authentication_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS;
+   else if (attr == &dev_attr_host_login_authorization_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS;
+   else if (attr == &dev_attr_host_login_negotiation_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS;
+   else if (attr == &dev_attr_host_login_redirect_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS;
+   else if (attr == &dev_attr_host_logout_normal_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS;
+   else if (attr == &dev_attr_host_logout_other_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS;
+   else if (attr == &dev_attr_host_digest_err.attr)
+   param = ISCSI_HOST_PARAM_DIGEST_ERR;
+   else if (attr == &dev_attr_host_timeout_err.attr)
+   param = ISCSI_HOST_PARAM_TIMEOUT_ERR;
+   else if (attr == &dev_attr_host_format_err.attr)
+   param = ISCSI_HOST_PARAM_FORMAT_ERR;
+   else if (attr == &dev_attr_host_session_fails.attr)
+   param = ISCSI_HOST_PARAM_SESSION_FAILS;
else {
WARN_ONCE(1, "Invalid host attr");
return 0;
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index d66c070..d6a3909 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -632,6 +632,18 @@ enum iscsi_host_param {
ISCSI_HOST_PARAM_IPADDRESS,
ISCSI_HOST_PARAM_PORT_STATE,
ISCSI_HOST_PARAM_PORT_SPEED,
+   ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS,
+   ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS,
+   ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS,
+   ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS,
+   ISCSI_HOST_PARAM_LOGI

[PATCH 2/3] libiscsi: Add support to update host stats param

2016-04-22 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

This adds support to update the stats param maintained at host level.
The stats are updated based on the status in response pdus.

Signed-off-by: Adheer Chandravanshi 
---
 drivers/scsi/libiscsi.c | 114 +++-
 include/scsi/libiscsi.h |   5 +++
 2 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c051694..d2481b6 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1034,6 +1034,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
struct iscsi_reject *reject = (struct iscsi_reject *)hdr;
struct iscsi_hdr rejected_pdu;
int opcode, rc = 0;
+   struct iscsi_host *ihost = shost_priv(conn->session->host);
 
conn->exp_statsn = be32_to_cpu(reject->statsn) + 1;
 
@@ -1050,12 +1051,14 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
 
switch (reject->reason) {
case ISCSI_REASON_DATA_DIGEST_ERROR:
+   ihost->ihost_stats.digest_err++;
iscsi_conn_printk(KERN_ERR, conn,
  "pdu (op 0x%x itt 0x%x) rejected "
  "due to DataDigest error.\n",
  opcode, rejected_pdu.itt);
break;
case ISCSI_REASON_IMM_CMD_REJECT:
+   ihost->ihost_stats.format_err++;
iscsi_conn_printk(KERN_ERR, conn,
  "pdu (op 0x%x itt 0x%x) rejected. Too many "
  "immediate commands.\n",
@@ -1102,6 +1105,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
}
break;
default:
+   ihost->ihost_stats.format_err++;
iscsi_conn_printk(KERN_ERR, conn,
  "pdu (op 0x%x itt 0x%x) rejected. Reason "
  "code 0x%x\n", rejected_pdu.opcode,
@@ -1241,6 +1245,8 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
iscsi_data_in_rsp(conn, hdr, task);
break;
case ISCSI_OP_LOGOUT_RSP:
+   iscsi_update_logout_stats(session->host,
+ (struct iscsi_logout_rsp *)hdr);
iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr);
if (datalen) {
rc = ISCSI_ERR_PROTO;
@@ -1249,6 +1255,9 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
goto recv_pdu;
case ISCSI_OP_LOGIN_RSP:
+   iscsi_update_login_stats(session->host,
+(struct iscsi_login_rsp *)hdr);
+
case ISCSI_OP_TEXT_RSP:
iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr);
/*
@@ -1372,6 +1381,7 @@ void iscsi_session_failure(struct iscsi_session *session,
 {
struct iscsi_conn *conn;
struct device *dev;
+   struct iscsi_host *ihost;
 
spin_lock_bh(&session->frwd_lock);
conn = session->leadconn;
@@ -1389,10 +1399,13 @@ void iscsi_session_failure(struct iscsi_session 
*session,
 * recovery initialization because we are going to kill
 * the session.
 */
-   if (err == ISCSI_ERR_INVALID_HOST)
+   if (err == ISCSI_ERR_INVALID_HOST) {
iscsi_conn_error_event(conn->cls_conn, err);
-   else
+   } else {
+   ihost = shost_priv(session->host);
+   ihost->ihost_stats.session_fails++;
iscsi_conn_failure(conn, err);
+   }
put_device(dev);
 }
 EXPORT_SYMBOL_GPL(iscsi_session_failure);
@@ -2069,6 +2082,7 @@ static void iscsi_check_transport_timeouts(unsigned long 
data)
struct iscsi_conn *conn = (struct iscsi_conn *)data;
struct iscsi_session *session = conn->session;
unsigned long recv_timeout, next_timeout = 0, last_recv;
+   struct iscsi_host *ihost;
 
spin_lock(&session->frwd_lock);
if (session->state != ISCSI_STATE_LOGGED_IN)
@@ -2088,6 +2102,8 @@ static void iscsi_check_transport_timeouts(unsigned long 
data)
  conn->ping_timeout, conn->recv_timeout,
  last_recv, conn->last_ping, jiffies);
spin_unlock(&session->frwd_lock);
+   ihost = shost_priv(session->host);
+   ihost->ihost_stats.timeout_err++;
iscsi_conn_failure(conn, ISCSI_ERR_NOP_TIMEDOUT);
return;
}
@@ -3594,6 +3610,50 @@ int iscsi_host_get_param(struct Scsi_Host *shost, enum 
iscsi_host_param param,
case ISCSI_HOST_PARAM_INITIATOR_NAME:
len = sprintf(buf, "%s\n", ihost->initiatorname);
b

[PATCH 0/3] iscsi: Add statistics support for iscsi host

2016-04-22 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

The following patches add the support to maintain some iscsi initiator
stats at the iscsi host level. The stats will be exposed using iscsi
host sysfs attrs.

This adds support for following stats:
   ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS
   ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS
   ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS
   ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS
   ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS
   ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS
   ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS
   ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS
   ISCSI_HOST_PARAM_DIGEST_ERR
   ISCSI_HOST_PARAM_TIMEOUT_ERR
   ISCSI_HOST_PARAM_FORMAT_ERR
   ISCSI_HOST_PARAM_SESSION_FAILS


Adheer Chandravanshi (3):
  scsi_transport_iscsi: Add support for stats param at host level
  libiscsi: Add support to update host stats param
  bnx2i: Enable support for host stats param

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH 3/3] bnx2i: Enable support for host stats param

2016-04-22 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

This enables the support for host stats param.

Signed-off-by: Adheer Chandravanshi 
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 7289437..8b44c9a 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -2201,6 +2201,18 @@ static umode_t bnx2i_attr_is_visible(int param_type, int 
param)
case ISCSI_HOST_PARAM_NETDEV_NAME:
case ISCSI_HOST_PARAM_HWADDRESS:
case ISCSI_HOST_PARAM_IPADDRESS:
+   case ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS:
+   case ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS:
+   case ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS:
+   case ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS:
+   case ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS:
+   case ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS:
+   case ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS:
+   case ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS:
+   case ISCSI_HOST_PARAM_DIGEST_ERR:
+   case ISCSI_HOST_PARAM_TIMEOUT_ERR:
+   case ISCSI_HOST_PARAM_FORMAT_ERR:
+   case ISCSI_HOST_PARAM_SESSION_FAILS:
return S_IRUGO;
default:
return 0;
-- 
1.8.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.