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
--- 

[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[] = {
_attr_host_netdev.attr,
@@ -4261,6 +4276,18 @@ static struct attribute *iscsi_host_attrs[] = {
_attr_host_initiatorname.attr,
_attr_host_port_state.attr,
_attr_host_port_speed.attr,
+   _attr_host_login_accept_rsps.attr,
+   _attr_host_login_other_fails.attr,
+   _attr_host_login_authentication_fails.attr,
+   _attr_host_login_authorization_fails.attr,
+   _attr_host_login_negotiation_fails.attr,
+   _attr_host_login_redirect_rsps.attr,
+   _attr_host_logout_normal_rsps.attr,
+   _attr_host_logout_other_rsps.attr,
+   _attr_host_digest_err.attr,
+   _attr_host_timeout_err.attr,
+   _attr_host_format_err.attr,
+   _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 == _attr_host_port_speed.attr)
param = ISCSI_HOST_PARAM_PORT_SPEED;
+   else if (attr == _attr_host_login_accept_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_ACCEPT_RSPS;
+   else if (attr == _attr_host_login_other_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_OTHER_FAILS;
+   else if (attr == _attr_host_login_authentication_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_AUTHENTICATION_FAILS;
+   else if (attr == _attr_host_login_authorization_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_AUTHORIZATION_FAILS;
+   else if (attr == _attr_host_login_negotiation_fails.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_NEGOTIATION_FAILS;
+   else if (attr == _attr_host_login_redirect_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGIN_REDIRECT_RSPS;
+   else if (attr == _attr_host_logout_normal_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGOUT_NORMAL_RSPS;
+   else if (attr == _attr_host_logout_other_rsps.attr)
+   param = ISCSI_HOST_PARAM_LOGOUT_OTHER_RSPS;
+   else if (attr == _attr_host_digest_err.attr)
+   param = ISCSI_HOST_PARAM_DIGEST_ERR;
+   else if (attr == _attr_host_timeout_err.attr)
+   param = ISCSI_HOST_PARAM_TIMEOUT_ERR;
+   else if (attr == _attr_host_format_err.attr)
+   param = ISCSI_HOST_PARAM_FORMAT_ERR;
+   else if (attr == _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_LOGIN_NEGOTIATION_FAILS,
+   

[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(>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(>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(>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", 

[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.


[PATCH] iscsi tools: Add support for some host statistics

2016-03-02 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

Add support to maintain and show some host statistics in iscsid.
This provides following host specific stats:
iscsi_login_accept_rsps
iscsi_login_other_fail_rsps
iscsi_login_negotiate_fails
iscsi_login_authenticate_fails
iscsi_login_auth_fail_rsps
iscsi_login_redirect_rsps
iscsi_logout_normals
iscsi_logout_others
iscsi_connection_timeout_errors
iscsi_session_failures

Signed-off-by: Adheer Chandravanshi 
---
 include/iscsi_if.h |   1 +
 usr/discovery.c|  32 +-
 usr/event_poll.c   |  12 +++-
 usr/event_poll.h   |   3 +-
 usr/host.c |  45 ++
 usr/host.h |  14 +
 usr/initiator.c| 100 +-
 usr/initiator.h|  16 -
 usr/initiator_common.c | 162 -
 usr/iscsiadm.c |  25 +---
 usr/iscsid.c   |  12 +++-
 usr/iscsistart.c   |  10 ++-
 usr/mgmt_ipc.c |  19 ++
 usr/mgmt_ipc.h |   9 +++
 usr/netlink.c  |   3 +-
 usr/transport.c|   1 +
 usr/transport.h|   1 +
 17 files changed, 416 insertions(+), 49 deletions(-)

diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index 9d15811..0576dfb 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -536,6 +536,7 @@ enum iscsi_err {
ISCSI_ERR_XMIT_FAILED   = ISCSI_ERR_BASE + 19,
ISCSI_ERR_TCP_CONN_CLOSE= ISCSI_ERR_BASE + 20,
ISCSI_ERR_SCSI_EH_SESSION_RST   = ISCSI_ERR_BASE + 21,
+   ISCSI_ERR_NOP_TIMEDOUT  = ISCSI_ERR_BASE + 22,
 };
 
 /*
diff --git a/usr/discovery.c b/usr/discovery.c
index 593d226..4d23381 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -1060,6 +1060,11 @@ done:
conn->socket_fd = -1;
}
session->id = -1;
+
+   if (session->host) {
+   iscsi_host_put(session->host);
+   session->host = NULL;
+   }
 }
 
 static int iscsi_create_leading_conn(struct iscsi_session *session)
@@ -1104,7 +1109,15 @@ static int iscsi_create_leading_conn(struct 
iscsi_session *session)
 * if offload is used.
 */
session->conn[0].bind_ep = 1;
-   session->hostno = host_no;
+   /*
+* some offload functions need the host so create now for
+* them
+*/
+   session->host = iscsi_host_create(host_no);
+   if (!session->host) {
+   rc = ISCSI_ERR_NOMEM;
+   goto close_ipc;
+   }
}
 
rc = iscsi_host_set_net_params(iface, session);
@@ -1113,7 +1126,7 @@ static int iscsi_create_leading_conn(struct iscsi_session 
*session)
  rc);
if (rc != ISCSI_ERR_AGAIN)
rc = ISCSI_ERR_INTERNAL;
-   goto close_ipc;
+   goto free_host;
}
 
/* create interconnect endpoint */
@@ -1121,7 +1134,7 @@ static int iscsi_create_leading_conn(struct iscsi_session 
*session)
rc = t->template->ep_connect(conn, 1);
if (rc < 0) {
rc = ISCSI_ERR_TRANS;
-   goto close_ipc;
+   goto free_host;
}
 
do {
@@ -1150,6 +1163,15 @@ static int iscsi_create_leading_conn(struct 
iscsi_session *session)
rc = ISCSI_ERR_INTERNAL;
goto disconnect;
}
+
+   if (!session->host) {
+   session->host = iscsi_host_create(host_no);
+   if (!session->host) {
+   rc = ISCSI_ERR_NOMEM;
+   goto disconnect;
+   }
+   }
+
log_debug(2, "%s discovery created session %u", __FUNCTION__,
  session->id);
session->isid[3] = (session->id >> 16) & 0xff;
@@ -1196,6 +1218,10 @@ disconnect:
session->id = -1;
}
 
+free_host:
+   iscsi_host_put(session->host);
+   session->host = NULL;
+
 close_ipc:
if (conn->socket_fd >= 0) {
ipc->ctldev_close();
diff --git a/usr/event_poll.c b/usr/event_poll.c
index 209ee02..52391db 100644
--- a/usr/event_poll.c
+++ b/usr/event_poll.c
@@ -38,6 +38,7 @@
 #include "actor.h"
 #include "initiator.h"
 #include "iscsi_err.h"
+#include "host.h"
 
 static unsigned int reap_count;
 
@@ -121,7 +122,8 @@ static int shutdown_wait_pids(void)
 #define POLL_CTRL  0
 #define POLL_IPC   1
 #define POLL_ALARM 2
-#define POLL_MAX   3
+#define POLL_UDEV  3
+#define POLL_MAX   4
 
 static int event_loop_stop;
 static queue_task_t *shutdown_qtask; 
@@ -132,7 +134,8 @@ void event_loop_exit(queue_task_t *qtask)
event_loop_stop = 1;
 }
 
-void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd)
+void 

[PATCH] iscsiuio: Get the library to use based on uio sysfs name

2015-12-28 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

This makes iscsiuio more compatible with newer adapters by eliminating
the need to always update iscsiuio with the PCI IDs of the new adapter.

Signed-off-by: Adheer Chandravanshi 
---
 iscsiuio/src/unix/nic.c   |   22 +++---
 iscsiuio/src/unix/nic.h   |6 ++-
 iscsiuio/src/unix/nic_id.c|2 +
 iscsiuio/src/unix/nic_utils.c |   65 +++--
 4 files changed, 66 insertions(+), 29 deletions(-)

diff --git a/iscsiuio/src/unix/nic.c b/iscsiuio/src/unix/nic.c
index 38a5776..fb3b7c3 100644
--- a/iscsiuio/src/unix/nic.c
+++ b/iscsiuio/src/unix/nic.c
@@ -152,7 +152,6 @@ static int load_nic_library(nic_lib_handle_t *handle)
/*  Validate the NIC library ops table to ensure that all the proper
 *  fields are filled */
if ((handle->ops->lib_ops.get_library_name == NULL) ||
-   (handle->ops->lib_ops.get_pci_table == NULL) ||
(handle->ops->lib_ops.get_library_version == NULL) ||
(handle->ops->lib_ops.get_build_date == NULL) ||
(handle->ops->lib_ops.get_transport_name == NULL)) {
@@ -247,7 +246,8 @@ int unload_all_nic_libraries()
return 0;
 }
 
-NIC_LIBRARY_EXIST_T does_nic_uio_name_exist(char *name)
+NIC_LIBRARY_EXIST_T does_nic_uio_name_exist(char *name,
+   nic_lib_handle_t **handle)
 {
NIC_LIBRARY_EXIST_T rc;
nic_lib_handle_t *current;
@@ -263,6 +263,9 @@ NIC_LIBRARY_EXIST_T does_nic_uio_name_exist(char *name)
   _name_size);
 
if (strncmp(name, uio_name, uio_name_size) == 0) {
+   if (handle)
+   *handle = current;
+
rc = NIC_LIBRARY_EXSITS;
goto done;
}
@@ -277,7 +280,8 @@ done:
return rc;
 }
 
-NIC_LIBRARY_EXIST_T does_nic_library_exist(char *name)
+NIC_LIBRARY_EXIST_T does_nic_library_exist(char *name,
+  nic_lib_handle_t **handle)
 {
NIC_LIBRARY_EXIST_T rc;
nic_lib_handle_t *current;
@@ -293,6 +297,9 @@ NIC_LIBRARY_EXIST_T does_nic_library_exist(char *name)
   _name_size);
 
if (strncmp(name, library_name, library_name_size) == 0) {
+   if (handle)
+   *handle = current;
+
rc = NIC_LIBRARY_EXSITS;
goto done;
}
@@ -333,8 +340,13 @@ int find_nic_lib_using_pci_id(uint32_t vendor, uint32_t 
device,
uint32_t entries;
int i;
 
-   current->ops->lib_ops.get_pci_table(_table, );
-
+   if (current->ops->lib_ops.get_pci_table != NULL) {
+   current->ops->lib_ops.get_pci_table(_table,
+   );
+   } else {
+   current = current->next;
+   continue;
+   }
/*  Sanity check the the pci table coming from the
 *  hardware library */
if (entries > MAX_PCI_DEVICE_ENTRIES) {
diff --git a/iscsiuio/src/unix/nic.h b/iscsiuio/src/unix/nic.h
index 8484032..e99fd8e 100644
--- a/iscsiuio/src/unix/nic.h
+++ b/iscsiuio/src/unix/nic.h
@@ -351,8 +351,10 @@ typedef enum {
NIC_LIBRARY_DOESNT_EXIST = 2,
 } NIC_LIBRARY_EXIST_T;
 
-NIC_LIBRARY_EXIST_T does_nic_uio_name_exist(char *name);
-NIC_LIBRARY_EXIST_T does_nic_library_exist(char *name);
+NIC_LIBRARY_EXIST_T does_nic_uio_name_exist(char *name,
+   nic_lib_handle_t **handle);
+NIC_LIBRARY_EXIST_T does_nic_library_exist(char *name,
+  nic_lib_handle_t **handle);
 
 
/***
  *  Packet management utility functions
diff --git a/iscsiuio/src/unix/nic_id.c b/iscsiuio/src/unix/nic_id.c
index 6b2467c..6da0a38 100644
--- a/iscsiuio/src/unix/nic_id.c
+++ b/iscsiuio/src/unix/nic_id.c
@@ -308,6 +308,7 @@ int find_set_nic_lib(nic_t *nic)
 
nic_lib_handle_t *handle;
struct pci_device_id *pci_entry;
+   size_t name_size;
 
rc = get_vendor(nic, );
if (rc != 0) {
@@ -357,6 +358,7 @@ int find_set_nic_lib(nic_t *nic)
 
/*  Prepare the NIC library op table */
nic->ops = handle->ops;
+   (*nic->ops->lib_ops.get_library_name) (>library_name, _size);
 
return 0;
 }
diff --git a/iscsiuio/src/unix/nic_utils.c b/iscsiuio/src/unix/nic_utils.c
index d57cc4f..0daffd2 100644
--- a/iscsiuio/src/unix/nic_utils.c
+++ b/iscsiuio/src/unix/nic_utils.c
@@ -700,6 +700,9 @@ int nic_verify_uio_sysfs_name(nic_t *nic)
uint32_t raw_size = 0;
char 

[PATCH] iscsiuio: Add QLogic Vendor ID to support newer NX2 HBAs

2015-09-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

The newer 57840 NX2 HBAs have started using QLogic Vendor ID.
Adding the support for it.

Signed-off-by: Adheer Chandravanshi 
---
 iscsiuio/src/unix/libs/bnx2x.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/iscsiuio/src/unix/libs/bnx2x.c b/iscsiuio/src/unix/libs/bnx2x.c
index a364d76..c9e3436 100644
--- a/iscsiuio/src/unix/libs/bnx2x.c
+++ b/iscsiuio/src/unix/libs/bnx2x.c
@@ -120,6 +120,7 @@ static const char brcm_57840_2_20[] = "QLogic NetXtreme II 
BCM57840 2x"
  * PCI ID constants
  
**/
 #define PCI_VENDOR_ID_BROADCOM 0x14e4
+#define PCI_VENDOR_ID_QLOGIC   0x1077
 #define PCI_DEVICE_ID_NX2_577100x164e
 #define PCI_DEVICE_ID_NX2_577110x164f
 #define PCI_DEVICE_ID_NX2_57711E   0x1650
@@ -194,6 +195,14 @@ static const struct pci_device_id bnx2x_pci_tbl[] = {
 PCI_ANY_ID, PCI_ANY_ID, brcm_57840_MF},
{PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_57840_VF,
 PCI_ANY_ID, PCI_ANY_ID, brcm_57840_VF},
+   {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_NX2_57840_4_10,
+PCI_ANY_ID, PCI_ANY_ID, brcm_57840_4_10},
+   {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_NX2_57840_2_20,
+PCI_ANY_ID, PCI_ANY_ID, brcm_57840_2_20},
+   {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_NX2_57840_MF,
+PCI_ANY_ID, PCI_ANY_ID, brcm_57840_MF},
+   {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_NX2_57840_VF,
+PCI_ANY_ID, PCI_ANY_ID, brcm_57840_VF},
 };
 
 static struct iro e1_iro[2] = {
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH v3 2/2] iscsiuio: Add ping support through iscsiuio

2015-09-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

This adds the support of ping from drivers like bnx2i
that use iscsiuio. It supports both IPv4 and IPv6 ping.

Two new files are added: ping.c and ping.h

Signed-off-by: Adheer Chandravanshi 
---
 iscsiuio/src/uip/ipv6.c|9 +
 iscsiuio/src/uip/uip.c |7 +
 iscsiuio/src/uip/uip.h |5 +
 iscsiuio/src/unix/Makefile.am  |3 +-
 iscsiuio/src/unix/iscsid_ipc.c |  136 ++-
 iscsiuio/src/unix/libs/cnic.c  |   12 +-
 iscsiuio/src/unix/nic.c|   20 +-
 iscsiuio/src/unix/nic.h|   20 ++
 iscsiuio/src/unix/ping.c   |  518 
 iscsiuio/src/unix/ping.h   |   73 ++
 10 files changed, 779 insertions(+), 24 deletions(-)
 create mode 100644 iscsiuio/src/unix/ping.c
 create mode 100644 iscsiuio/src/unix/ping.h

diff --git a/iscsiuio/src/uip/ipv6.c b/iscsiuio/src/uip/ipv6.c
index 5c627ac..ced98a6 100644
--- a/iscsiuio/src/uip/ipv6.c
+++ b/iscsiuio/src/uip/ipv6.c
@@ -47,6 +47,7 @@
 #include "icmpv6.h"
 #include "uipopt.h"
 #include "dhcpv6.h"
+#include "ping.h"
 
 inline int best_match_bufcmp(u8_t *a, u8_t *b, int len)
 {
@@ -811,6 +812,9 @@ static void ipv6_icmp_rx(struct ipv6_context *context)
(struct ipv6_hdr *)context->ustack->network_layer;
struct icmpv6_hdr *icmp = (struct icmpv6_hdr *)((u8_t *)ipv6 +
sizeof(struct ipv6_hdr));
+   uip_icmp_echo_hdr_t *icmp_echo_hdr =
+   (uip_icmp_echo_hdr_t *)((u8_t *)ipv6 +
+   sizeof(struct ipv6_hdr));
 
switch (icmp->icmpv6_type) {
case ICMPV6_RTR_ADV:
@@ -830,6 +834,11 @@ static void ipv6_icmp_rx(struct ipv6_context *context)
ipv6_icmp_handle_echo_request(context);
break;
 
+   case ICMPV6_ECHO_REPLY:
+   /* Handle ICMP reply */
+   process_icmp_packet(icmp_echo_hdr, context->ustack);
+   break;
+
default:
break;
}
diff --git a/iscsiuio/src/uip/uip.c b/iscsiuio/src/uip/uip.c
index ec3d6ce..178d7ac 100644
--- a/iscsiuio/src/uip/uip.c
+++ b/iscsiuio/src/uip/uip.c
@@ -7,6 +7,7 @@
 #include "dhcpc.h"
 #include "ipv6_ndpc.h"
 #include "brcm_iscsi.h"
+#include "ping.h"
 
 /**
  * \defgroup uip The uIP TCP/IP stack
@@ -441,6 +442,7 @@ void uip_init(struct uip_stack *ustack, uint8_t 
ipv6_enabled)
 
ustack->dhcpc = NULL;
ustack->ndpc = NULL;
+   ustack->ping_conf = NULL;
 }
 void uip_reset(struct uip_stack *ustack)
 {
@@ -1425,6 +1427,11 @@ icmp_input:
 #endif /* UIP_PINGADDRCONF */
++ustack->stats.icmp.recv;
 
+   if (icmpv4_hdr->type == ICMP_ECHO_REPLY) {
+   if (process_icmp_packet(icmpv4_hdr, ustack) == 0)
+   goto drop;
+   }
+
/* ICMP echo (i.e., ping) processing. This is simple, we only
   change the ICMP type from ECHO to ECHO_REPLY and adjust the
   ICMP checksum before we return the packet. */
diff --git a/iscsiuio/src/uip/uip.h b/iscsiuio/src/uip/uip.h
index 0225f6a..1180ab5 100644
--- a/iscsiuio/src/uip/uip.h
+++ b/iscsiuio/src/uip/uip.h
@@ -1283,6 +1283,8 @@ struct __attribute__ ((__packed__)) uip_icmpv4_hdr {
u16_t id, seqno;
 };
 
+typedef struct uip_icmpv4_hdr uip_icmp_echo_hdr_t;
+
 /* The ICMPv6 */
 struct __attribute__ ((__packed__)) uip_icmpv6_hdr {
/* ICMP (echo) header. */
@@ -1554,6 +1556,8 @@ struct uip_stack {
 
/* NDP client */
void *ndpc;
+
+   void *ping_conf;
 };
 
 
/***
@@ -1563,6 +1567,7 @@ int set_ipv6_link_local_address(struct uip_stack *ustack);
 int is_ipv6_link_local_address(uip_ip6addr_t *addr);
 
 void dump_uip_packet(struct uip_stack *ustack);
+u16_t uip_icmp6chksum(struct uip_stack *ustack);
 
 #endif /* __UIP_H__ */
 
diff --git a/iscsiuio/src/unix/Makefile.am b/iscsiuio/src/unix/Makefile.am
index 898691d..71d5463 100644
--- a/iscsiuio/src/unix/Makefile.am
+++ b/iscsiuio/src/unix/Makefile.am
@@ -19,7 +19,8 @@ iscsiuio_SOURCES =build_date.c\
nic_nl.c\
nic_utils.c \
packet.c\
-   iscsid_ipc.c
+   iscsid_ipc.c\
+   ping.c
 
 iscsiuio_CFLAGS =  $(AM_CFLAGS)\
$(LIBNL_CFLAGS) \
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
index 3e92d90..01eba6c 100644
--- a/iscsiuio/src/unix/iscsid_ipc.c
+++ b/iscsiuio/src/unix/iscsid_ipc.c
@@ -64,6 +64,7 @@
 
 #include "logger.h"
 #include "uip.h"
+#include "ping.h"
 
 /*  private iscsid options stucture */
 

[PATCH v3 1/2] iscsid: Changes to support ping through iscsiuio

2015-09-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

These changes are done in order to support ping operation for drivers
like bnx2i that use iscsiuio.

Signed-off-by: Adheer Chandravanshi 
---
 usr/iscsiadm.c |   28 
 usr/iscsid_req.c   |   37 -
 usr/iscsid_req.h   |3 ++-
 usr/transport.c|1 +
 usr/transport.h|3 +++
 usr/uip_mgmt_ipc.c |   39 ++-
 usr/uip_mgmt_ipc.h |   13 +
 7 files changed, 113 insertions(+), 11 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 692981d..7a01480 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -3117,6 +3117,7 @@ static int exec_ping_op(struct iface_rec *iface, char 
*ip, int size, int count,
struct iscsi_transport *t = NULL;
uint32_t host_no, status = 0;
struct sockaddr_storage addr;
+   struct host_info hinfo;
int i;
 
if (!iface) {
@@ -3185,13 +3186,32 @@ static int exec_ping_op(struct iface_rec *iface, char 
*ip, int size, int count,
for (i = 1; i <= count; i++) {
/*
 * To support drivers like bnx2i that do not use
-* the iscsi if to send a ping, we can add a transport
+* the iscsi iface to send a ping, we invoke transport
 * callout here.
 */
status = 0;
-   rc = ipc->exec_ping(t->handle, host_no,
-   (struct sockaddr *), iface->iface_num,
-   iface_type, size, );
+   if (t->template->exec_ping) {
+   if (!strlen(iface->netdev)) {
+   memset(, 0, sizeof(hinfo));
+   hinfo.host_no = host_no;
+   iscsi_sysfs_get_hostinfo_by_host_no();
+   strcpy(iface->netdev, hinfo.iface.netdev);
+   }
+
+   rc = iscsi_set_net_config(t, NULL, iface);
+   if (rc)
+   goto ping_err;
+
+   rc = t->template->exec_ping(t, iface, size, ,
+   );
+   } else {
+   rc = ipc->exec_ping(t->handle, host_no,
+   (struct sockaddr *),
+   iface->iface_num, iface_type,
+   (uint32_t)size, );
+   }
+
+ping_err:
if (!rc && !status)
printf("Ping %d completed\n", i);
else if (status)
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index 75bcf22..839b491 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -203,7 +203,7 @@ static int uip_connect(int *fd)
return ipc_connect(fd, ISCSID_UIP_NAMESPACE, 0);
 }
 
-int uip_broadcast(void *buf, size_t buf_len)
+int uip_broadcast(void *buf, size_t buf_len, int fd_flags, uint32_t *status)
 {
int err;
int fd;
@@ -235,7 +235,11 @@ int uip_broadcast(void *buf, size_t buf_len)
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1)
flags = 0;
-   err = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
+   if (fd_flags)
+   flags |= fd_flags;
+
+   err = fcntl(fd, F_SETFL, flags);
if (err) {
log_error("could not set uip broadcast to non-blocking: %d",
  errno);
@@ -268,11 +272,34 @@ int uip_broadcast(void *buf, size_t buf_len)
log_error("Could not broadcast to uIP after %d tries",
  count);
err = ISCSI_ERR_AGAIN;
-   } else if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP) {
-   log_debug(3, "Device is not ready");
-   err = ISCSI_ERR_AGAIN;
}
 
+   if (err)
+   goto done;
+
+   switch (rsp.command) {
+   case ISCSID_UIP_IPC_GET_IFACE:
+   if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP) {
+   log_debug(3, "Device is not ready\n");
+   err = ISCSI_ERR_AGAIN;
+   }
+
+   break;
+   case ISCSID_UIP_IPC_PING:
+   *status = rsp.ping_sc;
+   if (rsp.err == ISCSID_UIP_MGMT_IPC_DEVICE_INITIALIZING) {
+   log_debug(3, "Device is not ready\n");
+   err = ISCSI_ERR_AGAIN;
+   } else if (*status) {
+   err = ISCSI_ERR;
+   }
+
+   break;
+   default:
+   err = ISCSI_ERR;
+   }
+
+done:
close(fd);
return err;
 }
diff --git a/usr/iscsid_req.h b/usr/iscsid_req.h
index 4fff43d..8cb4a92 100644
--- a/usr/iscsid_req.h
+++ b/usr/iscsid_req.h
@@ -33,6 +33,7 @@ extern int iscsid_req_by_rec(int cmd, 

[PATCH v3 0/2] open-iscsi: Ping support in iscsiuio

2015-09-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi 

Mike,

This is patchset v3 to add ping support in iscsiuio.
Please review and apply following patches to open-iscsi.git tree at your 
earliest convenience.

Changes with respect to v2 patchset:
 * Corrected the logic for ping status message
 * Change the transport callout name to exec_ping 

Adheer Chandravanshi (2):
  iscsid: Changes to support ping through iscsiuio
  iscsiuio: Add ping support through iscsiuio


Thanks,
Adheer

-- 
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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH v2 2/2] iscsiuio: Add ping support through iscsiuio

2015-07-09 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This adds the support of ping from drivers like bnx2i
that use iscsiuio. It supports both IPv4 and IPv6 ping.

Two new files are added: ping.c and ping.h

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 iscsiuio/src/uip/ipv6.c|9 +
 iscsiuio/src/uip/uip.c |7 +
 iscsiuio/src/uip/uip.h |5 +
 iscsiuio/src/unix/Makefile.am  |3 +-
 iscsiuio/src/unix/iscsid_ipc.c |  136 ++-
 iscsiuio/src/unix/libs/cnic.c  |   12 +-
 iscsiuio/src/unix/nic.c|   20 +-
 iscsiuio/src/unix/nic.h|   20 ++
 iscsiuio/src/unix/ping.c   |  513 
 iscsiuio/src/unix/ping.h   |   73 ++
 10 files changed, 774 insertions(+), 24 deletions(-)
 create mode 100644 iscsiuio/src/unix/ping.c
 create mode 100644 iscsiuio/src/unix/ping.h

diff --git a/iscsiuio/src/uip/ipv6.c b/iscsiuio/src/uip/ipv6.c
index 5c627ac..ced98a6 100644
--- a/iscsiuio/src/uip/ipv6.c
+++ b/iscsiuio/src/uip/ipv6.c
@@ -47,6 +47,7 @@
 #include icmpv6.h
 #include uipopt.h
 #include dhcpv6.h
+#include ping.h
 
 inline int best_match_bufcmp(u8_t *a, u8_t *b, int len)
 {
@@ -811,6 +812,9 @@ static void ipv6_icmp_rx(struct ipv6_context *context)
(struct ipv6_hdr *)context-ustack-network_layer;
struct icmpv6_hdr *icmp = (struct icmpv6_hdr *)((u8_t *)ipv6 +
sizeof(struct ipv6_hdr));
+   uip_icmp_echo_hdr_t *icmp_echo_hdr =
+   (uip_icmp_echo_hdr_t *)((u8_t *)ipv6 +
+   sizeof(struct ipv6_hdr));
 
switch (icmp-icmpv6_type) {
case ICMPV6_RTR_ADV:
@@ -830,6 +834,11 @@ static void ipv6_icmp_rx(struct ipv6_context *context)
ipv6_icmp_handle_echo_request(context);
break;
 
+   case ICMPV6_ECHO_REPLY:
+   /* Handle ICMP reply */
+   process_icmp_packet(icmp_echo_hdr, context-ustack);
+   break;
+
default:
break;
}
diff --git a/iscsiuio/src/uip/uip.c b/iscsiuio/src/uip/uip.c
index ec3d6ce..178d7ac 100644
--- a/iscsiuio/src/uip/uip.c
+++ b/iscsiuio/src/uip/uip.c
@@ -7,6 +7,7 @@
 #include dhcpc.h
 #include ipv6_ndpc.h
 #include brcm_iscsi.h
+#include ping.h
 
 /**
  * \defgroup uip The uIP TCP/IP stack
@@ -441,6 +442,7 @@ void uip_init(struct uip_stack *ustack, uint8_t 
ipv6_enabled)
 
ustack-dhcpc = NULL;
ustack-ndpc = NULL;
+   ustack-ping_conf = NULL;
 }
 void uip_reset(struct uip_stack *ustack)
 {
@@ -1425,6 +1427,11 @@ icmp_input:
 #endif /* UIP_PINGADDRCONF */
++ustack-stats.icmp.recv;
 
+   if (icmpv4_hdr-type == ICMP_ECHO_REPLY) {
+   if (process_icmp_packet(icmpv4_hdr, ustack) == 0)
+   goto drop;
+   }
+
/* ICMP echo (i.e., ping) processing. This is simple, we only
   change the ICMP type from ECHO to ECHO_REPLY and adjust the
   ICMP checksum before we return the packet. */
diff --git a/iscsiuio/src/uip/uip.h b/iscsiuio/src/uip/uip.h
index 0225f6a..1180ab5 100644
--- a/iscsiuio/src/uip/uip.h
+++ b/iscsiuio/src/uip/uip.h
@@ -1283,6 +1283,8 @@ struct __attribute__ ((__packed__)) uip_icmpv4_hdr {
u16_t id, seqno;
 };
 
+typedef struct uip_icmpv4_hdr uip_icmp_echo_hdr_t;
+
 /* The ICMPv6 */
 struct __attribute__ ((__packed__)) uip_icmpv6_hdr {
/* ICMP (echo) header. */
@@ -1554,6 +1556,8 @@ struct uip_stack {
 
/* NDP client */
void *ndpc;
+
+   void *ping_conf;
 };
 
 
/***
@@ -1563,6 +1567,7 @@ int set_ipv6_link_local_address(struct uip_stack *ustack);
 int is_ipv6_link_local_address(uip_ip6addr_t *addr);
 
 void dump_uip_packet(struct uip_stack *ustack);
+u16_t uip_icmp6chksum(struct uip_stack *ustack);
 
 #endif /* __UIP_H__ */
 
diff --git a/iscsiuio/src/unix/Makefile.am b/iscsiuio/src/unix/Makefile.am
index 898691d..71d5463 100644
--- a/iscsiuio/src/unix/Makefile.am
+++ b/iscsiuio/src/unix/Makefile.am
@@ -19,7 +19,8 @@ iscsiuio_SOURCES =build_date.c\
nic_nl.c\
nic_utils.c \
packet.c\
-   iscsid_ipc.c
+   iscsid_ipc.c\
+   ping.c
 
 iscsiuio_CFLAGS =  $(AM_CFLAGS)\
$(LIBNL_CFLAGS) \
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
index 3e92d90..01eba6c 100644
--- a/iscsiuio/src/unix/iscsid_ipc.c
+++ b/iscsiuio/src/unix/iscsid_ipc.c
@@ -64,6 +64,7 @@
 
 #include logger.h
 #include uip.h
+#include ping.h
 
 /*  private iscsid options stucture */
 struct iscsid_options {
@@ -323,7 

[PATCH v2 1/2] iscsid: Changes to support ping through iscsiuio

2015-07-09 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

These changes are done in order to support ping operation for drivers
like bnx2i that use iscsiuio.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 usr/iscsiadm.c |   38 +++---
 usr/iscsid_req.c   |   38 +-
 usr/iscsid_req.h   |2 +-
 usr/transport.c|1 +
 usr/transport.h|3 +++
 usr/uip_mgmt_ipc.c |   38 +-
 usr/uip_mgmt_ipc.h |   13 +
 7 files changed, 119 insertions(+), 14 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index aa7cf07..495af3a 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -3099,10 +3099,10 @@ static char *iscsi_ping_stat_strs[] = {
No ARP response received,
 };
 
-static char *iscsi_ping_stat_to_str(uint32_t status)
+static char *iscsi_ping_stat_to_str(int status)
 {
if (status  0 || status  ISCSI_PING_NO_ARP_RECEIVED) {
-   log_error(Invalid ping status %u, status);
+   log_error(Ping error: %s\n, strerror(status));
return NULL;
}
 
@@ -3115,8 +3115,10 @@ static int exec_ping_op(struct iface_rec *iface, char 
*ip, int size, int count,
int rc = ISCSI_ERR;
uint32_t iface_type = ISCSI_IFACE_TYPE_IPV4;
struct iscsi_transport *t = NULL;
-   uint32_t host_no, status = 0;
+   uint32_t host_no;
+   int status = 0;
struct sockaddr_storage addr;
+   struct host_info hinfo;
int i;
 
if (!iface) {
@@ -3185,13 +3187,35 @@ static int exec_ping_op(struct iface_rec *iface, char 
*ip, int size, int count,
for (i = 1; i = count; i++) {
/*
 * To support drivers like bnx2i that do not use
-* the iscsi if to send a ping, we can add a transport
+* the iscsi iface to send a ping, we invoke transport
 * callout here.
 */
status = 0;
-   rc = ipc-exec_ping(t-handle, host_no,
-   (struct sockaddr *)addr, iface-iface_num,
-   iface_type, size, status);
+   if (t-template-send_ping) {
+   if (!strlen(iface-netdev)) {
+   memset(hinfo, 0, sizeof(hinfo));
+   hinfo.host_no = host_no;
+   iscsi_sysfs_get_hostinfo_by_host_no(hinfo);
+   strcpy(iface-netdev, hinfo.iface.netdev);
+   }
+
+   rc = iscsi_set_net_config(t, NULL, iface);
+   if (rc)
+   goto ping_err1;
+
+   rc = t-template-send_ping(t, iface, size, addr,
+   status);
+   if (rc)
+   rc = ISCSI_ERR_INTERNAL;
+   } else {
+   rc = ipc-exec_ping(t-handle, host_no,
+   (struct sockaddr *)addr,
+   iface-iface_num, iface_type,
+   (uint32_t)size,
+   (uint32_t *)status);
+   }
+
+ping_err1:
if (!rc  !status)
printf(Ping %d completed\n, i);
else if (status)
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index 75bcf22..764975a 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -203,7 +203,7 @@ static int uip_connect(int *fd)
return ipc_connect(fd, ISCSID_UIP_NAMESPACE, 0);
 }
 
-int uip_broadcast(void *buf, size_t buf_len)
+int uip_broadcast(void *buf, size_t buf_len, int fd_flags, int *status)
 {
int err;
int fd;
@@ -235,7 +235,11 @@ int uip_broadcast(void *buf, size_t buf_len)
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1)
flags = 0;
-   err = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
+   if (fd_flags)
+   flags |= fd_flags;
+
+   err = fcntl(fd, F_SETFL, flags);
if (err) {
log_error(could not set uip broadcast to non-blocking: %d,
  errno);
@@ -268,11 +272,35 @@ int uip_broadcast(void *buf, size_t buf_len)
log_error(Could not broadcast to uIP after %d tries,
  count);
err = ISCSI_ERR_AGAIN;
-   } else if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP) {
-   log_debug(3, Device is not ready);
-   err = ISCSI_ERR_AGAIN;
}
 
+   if (err)
+   goto done;
+
+   switch (rsp.command) {
+   case ISCSID_UIP_IPC_GET_IFACE:
+   if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP) {
+   log_debug(3, Device is not ready\n);
+   err = 

[PATCH v2 0/2] open-iscsi: Ping support in iscsiuio

2015-07-09 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Mike,

This is patchset v2 to add ping support in iscsiuio.
Please review and apply following patches to open-iscsi.git tree at your 
earliest convenience.

Changes with respect to first patchset:
- Removed the iface apply operation for bnx2i transport
  Now, iface config will be passed to iscsiuio during ping operation itself.

- Reduced the patchset to only two necessary patches for the required support

Adheer Chandravanshi (2):
  iscsid: Changes to support ping through iscsiuio
  iscsiuio: Add ping support through iscsiuio

Thanks,
Adheer

-- 
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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH] iscsiuio: Correct the handling of Multi Function mode

2015-06-16 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Handle the Multi Function mode correctly when dealing with bnx2x driver.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 iscsiuio/src/unix/libs/bnx2x.c |   23 ---
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/iscsiuio/src/unix/libs/bnx2x.c b/iscsiuio/src/unix/libs/bnx2x.c
index 1495762..a364d76 100644
--- a/iscsiuio/src/unix/libs/bnx2x.c
+++ b/iscsiuio/src/unix/libs/bnx2x.c
@@ -672,6 +672,9 @@ static int bnx2x_open(nic_t *nic)
uint32_t bus;
uint32_t slot;
uint32_t func;
+   uint32_t mode;
+   __u32 proto_offset;
+   __u32 ovtag_offset;
 
/*  Sanity Check: validate the parameters */
if (nic == NULL) {
@@ -1002,9 +1005,11 @@ static int bnx2x_open(nic_t *nic)
mf_cfg_addr = bp-shmem_base + 0x7e4;
 
/* shared_feat_cfg.config */
-   val = bnx2x_rd32(bp, bp-shmem_base + 0x354);
-   /* SI mode */
-   if ((val  0x700) == 0x300) {
+   mode = bnx2x_rd32(bp, bp-shmem_base + 0x354);
+   mode = 0x700;
+   LOG_DEBUG(PFX %s: mode = 0x%x, nic-log_name, mode);
+   switch (mode) {
+   case 0x300: /* SI mode */
mac_offset = 0xe4 + (bp-func * 0x28) + 4;
val = bnx2x_rd32(bp, mf_cfg_addr + mac_offset);
mac[0] = (__u8) (val  8);
@@ -1027,9 +1032,13 @@ static int bnx2x_open(nic_t *nic)
rc = -ENOTSUP;
goto open_error;
}
-   } else if ((val  0x700) == 0) {
-   __u32 proto_offset = 0x24 + (bp-func * 0x18);
-   __u32 ovtag_offset = proto_offset + 0xc;
+   break;
+
+   case 0x0: /* MF SD mode */
+   case 0x500:
+   case 0x600:
+   proto_offset = 0x24 + (bp-func * 0x18);
+   ovtag_offset = proto_offset + 0xc;
 
rc = -ENOTSUP;
val = bnx2x_rd32(bp, mf_cfg_addr + ovtag_offset);
@@ -1057,7 +1066,7 @@ static int bnx2x_open(nic_t *nic)
mac[4] = (__u8) (val  8);
mac[5] = (__u8) val;
memcpy(nic-mac_addr, mac, 6);
-
+   break;
}
}
 SF:
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH 2/5] iscsiadm: Add iface apply operation support for bnx2i transport

2015-03-31 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Currently bnx2i sets up its interface as part of login/discovery
process. Adding this support will help to setup bnx2i interfaces
independent of any other operation.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 usr/iscsiadm.c |   43 +--
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 9081ac8..6f96755 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1277,7 +1277,7 @@ static int iface_apply_net_config(struct iface_rec 
*iface, int op)
int rc = ISCSI_ERR;
uint32_t host_no;
int param_count;
-   int param_used;
+   int param_used = 0;
int iface_all = 0;
int i;
struct iovec *iovs = NULL;
@@ -1291,10 +1291,24 @@ static int iface_apply_net_config(struct iface_rec 
*iface, int op)
if (op == OP_APPLY_ALL)
iface_all = 1;
 
+   t = iscsi_sysfs_get_transport_by_name(iface-transport_name);
+   if (!t) {
+   log_error(Can't find transport %s, iface-transport_name);
+   rc = ISCSI_ERR_TRANS_NOT_FOUND;
+   goto apply_done;
+   }
+
+   /* iface config from transport hook, if applicable */
+   if (t-template-set_net_config) {
+   rc = iscsi_set_net_config(t, NULL, iface);
+   goto apply_done;
+   }
+
param_count = iface_get_param_count(iface, iface_all);
if (!param_count) {
log_error(Nothing to configure.);
-   return ISCSI_SUCCESS;
+   rc = ISCSI_SUCCESS;
+   goto apply_done;
}
 
/*
@@ -1308,38 +1322,39 @@ static int iface_apply_net_config(struct iface_rec 
*iface, int op)
   sizeof(char));
if (!iovs) {
log_error(Out of Memory.);
-   return ISCSI_ERR_NOMEM;
+   rc = ISCSI_ERR_NOMEM;
+   goto apply_done;
}
 
/* param_used gives actual number of iovecs used for netconfig */
param_used = iface_build_net_config(iface, iface_all, iovs);
if (!param_used) {
log_error(Build netconfig failed.);
-   goto free_buf;
-   }
-
-   t = iscsi_sysfs_get_transport_by_name(iface-transport_name);
-   if (!t) {
-   log_error(Can't find transport.);
+   rc = ISCSI_ERR_INVAL;
goto free_buf;
}
 
host_no = iscsi_sysfs_get_host_no_from_hwinfo(iface, rc);
if (host_no == -1) {
log_error(Can't find host_no.);
+   rc = ISCSI_ERR_HOST_NOT_FOUND;
goto free_buf;
}
-   rc = ISCSI_ERR;
 
fd = ipc-ctldev_open();
if (fd  0) {
log_error(Netlink open failed.);
+   rc = ISCSI_ERR_INTERNAL;
goto free_buf;
}
 
rc = ipc-set_net_config(t-handle, host_no, iovs, param_count);
-   if (rc  0)
+   if (rc  0) {
log_error(Set net_config failed. errno=%d, errno);
+   rc = ISCSI_ERR;
+   } else {
+   rc = ISCSI_SUCCESS;
+   }
 
ipc-ctldev_close();
 
@@ -1352,9 +1367,9 @@ free_buf:
}
 
free(iovs);
-   if (rc)
-   return ISCSI_ERR;
-   return ISCSI_SUCCESS;
+
+apply_done:
+   return rc;
 }
 
 static int get_host_chap_info(uint32_t host_no)
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH 3/5] iscsid: Changes to support ping through iscsiuio

2015-03-31 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

These changes are done in order to support ping operation for drivers
like bnx2i that use iscsiuio.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 usr/iscsiadm.c |   29 +++--
 usr/iscsid_req.c   |   38 +-
 usr/iscsid_req.h   |2 +-
 usr/transport.c|1 +
 usr/transport.h|3 +++
 usr/uip_mgmt_ipc.c |   38 +-
 usr/uip_mgmt_ipc.h |   13 +
 7 files changed, 111 insertions(+), 13 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 6f96755..bb86d21 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -3114,10 +3114,10 @@ static char *iscsi_ping_stat_strs[] = {
No ARP response received,
 };
 
-static char *iscsi_ping_stat_to_str(uint32_t status)
+static char *iscsi_ping_stat_to_str(int status)
 {
if (status  0 || status  ISCSI_PING_NO_ARP_RECEIVED) {
-   log_error(Invalid ping status %u\n, status);
+   log_error(Ping error: %s\n, strerror(status));
return NULL;
}
 
@@ -3130,8 +3130,10 @@ static int exec_ping_op(struct iface_rec *iface, char 
*ip, int size, int count,
int rc = ISCSI_ERR;
uint32_t iface_type = ISCSI_IFACE_TYPE_IPV4;
struct iscsi_transport *t = NULL;
-   uint32_t host_no, status = 0;
+   uint32_t host_no;
+   int status = 0;
struct sockaddr_storage addr;
+   struct host_info hinfo;
int i;
 
if (!iface) {
@@ -3200,12 +3202,27 @@ static int exec_ping_op(struct iface_rec *iface, char 
*ip, int size, int count,
for (i = 1; i = count; i++) {
/*
 * To support drivers like bnx2i that do not use
-* the iscsi if to send a ping, we can add a transport
+* the iscsi iface to send a ping, we invoke transport
 * callout here.
 */
status = 0;
-   rc = ipc-exec_ping(t-handle, host_no, addr, iface-iface_num,
-   iface_type, size, status);
+   if (t-template-send_ping) {
+   if (!strlen(iface-netdev)) {
+   memset(hinfo, 0, sizeof(hinfo));
+   hinfo.host_no = host_no;
+   iscsi_sysfs_get_hostinfo_by_host_no(hinfo);
+   strcpy(iface-netdev, hinfo.iface.netdev);
+   }
+   rc = t-template-send_ping(t, iface, size, addr,
+   status);
+   if (rc)
+   rc = ISCSI_ERR_INTERNAL;
+   } else {
+   rc = ipc-exec_ping(t-handle, host_no, addr,
+   iface-iface_num, iface_type,
+   size, (uint32_t *)status);
+   }
+
if (!rc  !status)
printf(Ping %d completed\n, i);
else if (status)
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index 0e91dee..f19d194 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -203,7 +203,7 @@ static int uip_connect(int *fd)
return ipc_connect(fd, ISCSID_UIP_NAMESPACE, 0);
 }
 
-int uip_broadcast(void *buf, size_t buf_len)
+int uip_broadcast(void *buf, size_t buf_len, int fd_flags, int *status)
 {
int err;
int fd;
@@ -235,7 +235,11 @@ int uip_broadcast(void *buf, size_t buf_len)
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1)
flags = 0;
-   err = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
+   if (fd_flags)
+   flags |= fd_flags;
+
+   err = fcntl(fd, F_SETFL, flags);
if (err) {
log_error(could not set uip broadcast to non-blocking: %d,
  errno);
@@ -268,11 +272,35 @@ int uip_broadcast(void *buf, size_t buf_len)
log_error(Could not broadcast to uIP after %d tries,
  count);
err = ISCSI_ERR_AGAIN;
-   } else if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP) {
-   log_debug(3, Device is not ready\n);
-   err = ISCSI_ERR_AGAIN;
}
 
+   if (err)
+   goto done;
+
+   switch (rsp.command) {
+   case ISCSID_UIP_IPC_GET_IFACE:
+   if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP) {
+   log_debug(3, Device is not ready\n);
+   err = ISCSI_ERR_AGAIN;
+   }
+
+   break;
+   case ISCSID_UIP_IPC_PING:
+   *status = rsp.ping_sc;
+   if (rsp.err != ISCSID_UIP_MGMT_IPC_DEVICE_UP ||
+   *status == -EAGAIN) {
+   log_debug(3, Device is not ready\n);
+   err = 

[PATCH 0/5] open-iscsi: Ping support in iscsiuio

2015-03-31 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Mike,

Please review and apply following patches to open-iscsi.git tree
at your earliest convenience.

These patches add the ping support in iscsiuio and also contain
some fixes identified during the implementation and testing.

Adheer Chandravanshi (5):
  iscsiadm: Use struct sockaddr_storage instead of struct sockaddr
  iscsiadm: Add iface apply operation support for bnx2i transport
  iscsid: Changes to support ping through iscsiuio
  iscsiuio: Add ping support through iscsiuio
  iscsiuio: Correctly check the IPv6 RA flags for stateful IP config

Thanks,
Adheer

-- 
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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH 5/5] iscsiuio: Correctly check the IPv6 RA flags for stateful IP config

2015-03-31 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

The RA flag bits M  O were not being correctly checked for stateful config.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 iscsiuio/src/uip/ipv6.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/iscsiuio/src/uip/ipv6.c b/iscsiuio/src/uip/ipv6.c
index ced98a6..afafd19 100644
--- a/iscsiuio/src/uip/ipv6.c
+++ b/iscsiuio/src/uip/ipv6.c
@@ -1262,11 +1262,11 @@ u16_t ipv6_do_stateful_dhcpv6(struct ipv6_context 
*context, u32_t flags)
}
 
if ((flags  ISCSI_FLAGS_DHCP_TCPIP_CONFIG) 
-   (ra_flags  IPV6_FLAGS_MANAGED_ADDR_CONFIG))
+   !(ra_flags  IPV6_FLAGS_MANAGED_ADDR_CONFIG))
task |= DHCPV6_TASK_GET_IP_ADDRESS;
 
if ((flags  ISCSI_FLAGS_DHCP_ISCSI_CONFIG) 
-   (ra_flags  IPV6_FLAGS_OTHER_STATEFUL_CONFIG))
+   !(ra_flags  IPV6_FLAGS_OTHER_STATEFUL_CONFIG))
task |= DHCPV6_TASK_GET_OTHER_PARAMS;
 
LOG_DEBUG(IPv6: Stateful flags = 0x%x, ra_flags = 0x%x, task = 0x%x,
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.


[PATCH 4/5] iscsiuio: Add ping support through iscsiuio

2015-03-31 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This adds the support of ping from drivers like bnx2i
that use iscsiuio. It supports both IPv4 and IPv6 ping.

Two new files are added: ping.c and ping.h

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 iscsiuio/src/uip/ipv6.c|9 +
 iscsiuio/src/uip/uip.c |7 +
 iscsiuio/src/uip/uip.h |5 +
 iscsiuio/src/unix/Makefile.am  |3 +-
 iscsiuio/src/unix/iscsid_ipc.c |  136 ++-
 iscsiuio/src/unix/libs/cnic.c  |   12 +-
 iscsiuio/src/unix/nic.c|   20 +-
 iscsiuio/src/unix/nic.h|   20 ++
 iscsiuio/src/unix/ping.c   |  530 
 iscsiuio/src/unix/ping.h   |   75 ++
 10 files changed, 793 insertions(+), 24 deletions(-)
 create mode 100644 iscsiuio/src/unix/ping.c
 create mode 100644 iscsiuio/src/unix/ping.h

diff --git a/iscsiuio/src/uip/ipv6.c b/iscsiuio/src/uip/ipv6.c
index 5c627ac..ced98a6 100644
--- a/iscsiuio/src/uip/ipv6.c
+++ b/iscsiuio/src/uip/ipv6.c
@@ -47,6 +47,7 @@
 #include icmpv6.h
 #include uipopt.h
 #include dhcpv6.h
+#include ping.h
 
 inline int best_match_bufcmp(u8_t *a, u8_t *b, int len)
 {
@@ -811,6 +812,9 @@ static void ipv6_icmp_rx(struct ipv6_context *context)
(struct ipv6_hdr *)context-ustack-network_layer;
struct icmpv6_hdr *icmp = (struct icmpv6_hdr *)((u8_t *)ipv6 +
sizeof(struct ipv6_hdr));
+   uip_icmp_echo_hdr_t *icmp_echo_hdr =
+   (uip_icmp_echo_hdr_t *)((u8_t *)ipv6 +
+   sizeof(struct ipv6_hdr));
 
switch (icmp-icmpv6_type) {
case ICMPV6_RTR_ADV:
@@ -830,6 +834,11 @@ static void ipv6_icmp_rx(struct ipv6_context *context)
ipv6_icmp_handle_echo_request(context);
break;
 
+   case ICMPV6_ECHO_REPLY:
+   /* Handle ICMP reply */
+   process_icmp_packet(icmp_echo_hdr, context-ustack);
+   break;
+
default:
break;
}
diff --git a/iscsiuio/src/uip/uip.c b/iscsiuio/src/uip/uip.c
index ec3d6ce..178d7ac 100644
--- a/iscsiuio/src/uip/uip.c
+++ b/iscsiuio/src/uip/uip.c
@@ -7,6 +7,7 @@
 #include dhcpc.h
 #include ipv6_ndpc.h
 #include brcm_iscsi.h
+#include ping.h
 
 /**
  * \defgroup uip The uIP TCP/IP stack
@@ -441,6 +442,7 @@ void uip_init(struct uip_stack *ustack, uint8_t 
ipv6_enabled)
 
ustack-dhcpc = NULL;
ustack-ndpc = NULL;
+   ustack-ping_conf = NULL;
 }
 void uip_reset(struct uip_stack *ustack)
 {
@@ -1425,6 +1427,11 @@ icmp_input:
 #endif /* UIP_PINGADDRCONF */
++ustack-stats.icmp.recv;
 
+   if (icmpv4_hdr-type == ICMP_ECHO_REPLY) {
+   if (process_icmp_packet(icmpv4_hdr, ustack) == 0)
+   goto drop;
+   }
+
/* ICMP echo (i.e., ping) processing. This is simple, we only
   change the ICMP type from ECHO to ECHO_REPLY and adjust the
   ICMP checksum before we return the packet. */
diff --git a/iscsiuio/src/uip/uip.h b/iscsiuio/src/uip/uip.h
index 0225f6a..1180ab5 100644
--- a/iscsiuio/src/uip/uip.h
+++ b/iscsiuio/src/uip/uip.h
@@ -1283,6 +1283,8 @@ struct __attribute__ ((__packed__)) uip_icmpv4_hdr {
u16_t id, seqno;
 };
 
+typedef struct uip_icmpv4_hdr uip_icmp_echo_hdr_t;
+
 /* The ICMPv6 */
 struct __attribute__ ((__packed__)) uip_icmpv6_hdr {
/* ICMP (echo) header. */
@@ -1554,6 +1556,8 @@ struct uip_stack {
 
/* NDP client */
void *ndpc;
+
+   void *ping_conf;
 };
 
 
/***
@@ -1563,6 +1567,7 @@ int set_ipv6_link_local_address(struct uip_stack *ustack);
 int is_ipv6_link_local_address(uip_ip6addr_t *addr);
 
 void dump_uip_packet(struct uip_stack *ustack);
+u16_t uip_icmp6chksum(struct uip_stack *ustack);
 
 #endif /* __UIP_H__ */
 
diff --git a/iscsiuio/src/unix/Makefile.am b/iscsiuio/src/unix/Makefile.am
index 898691d..71d5463 100644
--- a/iscsiuio/src/unix/Makefile.am
+++ b/iscsiuio/src/unix/Makefile.am
@@ -19,7 +19,8 @@ iscsiuio_SOURCES =build_date.c\
nic_nl.c\
nic_utils.c \
packet.c\
-   iscsid_ipc.c
+   iscsid_ipc.c\
+   ping.c
 
 iscsiuio_CFLAGS =  $(AM_CFLAGS)\
$(LIBNL_CFLAGS) \
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
index 3e92d90..01eba6c 100644
--- a/iscsiuio/src/unix/iscsid_ipc.c
+++ b/iscsiuio/src/unix/iscsid_ipc.c
@@ -64,6 +64,7 @@
 
 #include logger.h
 #include uip.h
+#include ping.h
 
 /*  private iscsid options stucture */
 struct iscsid_options {
@@ -323,7 

[PATCH 2/2] iscsiadm: Fix the compile time warning

2014-02-24 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This fixes the following compile time warning message:

iscsiadm.c:2248: warning: passing argument 1 of 'print_host_stats' from 
incompatible pointer type

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 usr/iscsiadm.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 36617ab..389f4b8 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -2245,7 +2245,8 @@ static int exec_host_stats_op(int op, int info_level, 
uint32_t host_no)
goto exit_host_stats;
}
 
-   print_host_stats(req_buf + sizeof(struct iscsi_uevent));
+   print_host_stats((struct iscsi_offload_host_stats *)(req_buf +
+sizeof(struct iscsi_uevent)));
 
ipc-ctldev_close();
 
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 1/2] iscsiadm: Fix the hostno check for stats submode of host mode

2014-02-24 Thread adheer.chandravanshi
From: Chris Leech cle...@redhat.com

This fixes the condition where hostno value of 0 was being treated
as invalid.

Signed-off-by: Chris Leech cle...@redhat.com
Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 usr/iscsiadm.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 3cde8d1..36617ab 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -3470,7 +3470,7 @@ main(int argc, char **argv)
   params);
break;
case MODE_HOST_STATS:
-   if (!host_no) {
+   if (host_no  MAX_HOST_NO) {
log_error(STATS mode requires host 
no);
rc = ISCSI_ERR_INVAL;
break;
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 2/2] Man page correction for host mode options of iscsiadm

2013-12-30 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Correct the help options of iscsiadm host mode in its man page.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 doc/iscsiadm.8 |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
index d59af43..9a945d1 100644
--- a/doc/iscsiadm.8
+++ b/doc/iscsiadm.8
@@ -16,9 +16,7 @@ iscsiadm \- open-iscsi administration utility
 
 \fBiscsiadm\fR \-m fw [ \-d debug_level ] [\-l]
 
-\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ [ \-C chap [ 
\-x chap_tbl_idx ] ] | [ \-C flashnode [ \-A portal_type ] [ \-x flashnode_idx 
] ] ] [ [ \-o operation ] [ \-n name ] [ \-v value ] ]
-
-\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ [ \-C chap [ 
\-o operation ] [ \-v chap_tbl_idx ] ] | [ \-C flashnode [ \-o operation ] [ 
\-A portal_type ] [ \-x flashnode_idx ] [ \-n name ] [ \-v value ] ] | [ \-C 
stats ]]
+\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ [ \-C chap [ 
\-x chap_tbl_idx ] ] | [ \-C flashnode [ \-A portal_type ] [ \-x flashnode_idx 
] ] | [ \-C stats ] ] [ [ \-o operation ] [ \-n name ] [ \-v value ] ]
 
 \fBiscsiadm\fR \-k priority
 
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH V2 00/11] Add support for additional network parameters

2013-10-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Mike,

Following patches add support for setting and display of additional network
parameters.

Please review and apply following patches to open-iscsi source tree at your
earliest convenience.

Corresponding kernel patches are submitted to linux-scsi list here:
http://marc.info/?l=linux-scsim=138210321629250w=2

Adheer Chandravanshi (5):
  iscsi tools: Setup iface conf file with all iface attrs exported in
sysfs
  iscsi_if.h: Additional parameters for network param settings
  iscsi tools: iface params should be updated for node_rec as well.
  iscsi tools: Let default type of iface be ipv4
  iscsi tools: Show iface params based on iface type

Harish Zunjarrao (6):
  iscsi_if.h: Remove numbers used for network parameter settings
  iscsi tools: Use macro to set IPv4/IPv6 IP addresses
  iscsi tools: Use single function to enable/disable network parameters
  iscsi tools: Use single function to set integer network parameters
  iscsi tools: Ignore network parameter if not enabled/disabled
  iscsi tools: Additional parameters for network settings

Thanks,
Adheer

-- 
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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH V2 11/11] iscsi tools: Show iface params based on iface type

2013-10-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/idbm.c |  250 +---
 1 files changed, 138 insertions(+), 112 deletions(-)

diff --git a/usr/idbm.c b/usr/idbm.c
index c6460ad..1ade099 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -237,6 +237,9 @@ void
 idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
 {
int num = 0, i;
+   int iface_type;
+
+   iface_type = iface_get_iptype(r-iface);
 
__recinfo_str(NODE_NAME, ri, r, name, IDBM_SHOW, num, 0);
__recinfo_int(NODE_TPGT, ri, r, tpgt, IDBM_SHOW, num, 0);
@@ -266,21 +269,6 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
__recinfo_str(IFACE_TRANSPORTNAME, ri, r, iface.transport_name,
  IDBM_SHOW, num, 1);
__recinfo_str(IFACE_INAME, ri, r, iface.iname, IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_BOOT_PROTO, ri, r, iface.bootproto, IDBM_SHOW,
- num, 1);
-   __recinfo_str(IFACE_SUBNET_MASK, ri, r, iface.subnet_mask,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_GATEWAY, ri, r, iface.gateway, IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_IPV6_AUTOCFG, ri, r, iface.ipv6_autocfg,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_LINKLOCAL_AUTOCFG, ri, r, iface.linklocal_autocfg,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_ROUTER_AUTOCFG, ri, r, iface.router_autocfg,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_LINKLOCAL, ri, r, iface.ipv6_linklocal,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_ROUTER, ri, r, iface.ipv6_router, IDBM_SHOW, num,
- 1);
__recinfo_str(IFACE_STATE, ri, r, iface.state, IDBM_SHOW, num, 1);
__recinfo_uint16(IFACE_VLAN_ID, ri, r, iface.vlan_id, IDBM_SHOW, num,
 1);
@@ -292,50 +280,73 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
__recinfo_uint16(IFACE_MTU, ri, r, iface.mtu, IDBM_SHOW, num, 1);
__recinfo_uint16(IFACE_PORT, ri, r, iface.port, IDBM_SHOW, num, 1);
 
-   __recinfo_str(IFACE_DHCP_ALT_CID, ri, r, iface.dhcp_alt_client_id_state,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_ALT_CID_STR, ri, r, iface.dhcp_alt_client_id,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_DNS, ri, r, iface.dhcp_dns, IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_LEARN_IQN, ri, r, iface.dhcp_learn_iqn,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_REQ_VID, ri, r, iface.dhcp_req_vendor_id_state,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_VID, ri, r, iface.dhcp_vendor_id_state,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_VID_STR, ri, r, iface.dhcp_vendor_id,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_DHCP_SLP_DA, ri, r, iface.dhcp_slp_da, IDBM_SHOW,
- num, 1);
-   __recinfo_str(IFACE_FRAGMENTATION, ri, r, iface.fragmentation,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_GRAT_ARP, ri, r, iface.gratuitous_arp, IDBM_SHOW,
- num, 1);
-   __recinfo_str(IFACE_IN_FORWARD, ri, r, iface.incoming_forwarding,
- IDBM_SHOW, num, 1);
-   __recinfo_str(IFACE_TOS_STATE, ri, r, iface.tos_state, IDBM_SHOW, num,
- 1);
-   __recinfo_uint8(IFACE_TOS, ri, r, iface.tos, IDBM_SHOW, num, 1);
-   __recinfo_uint8(IFACE_TTL, ri, r, iface.ttl, IDBM_SHOW, num, 1);
-   __recinfo_uint8(IFACE_DUP_ADDR_DETECT_CNT, ri, r,
-   iface.dup_addr_detect_cnt, IDBM_SHOW, num, 1);
-   __recinfo_uint32(IFACE_FLOW_LABEL, ri, r, iface.flow_label, IDBM_SHOW,
-num, 1);
-   __recinfo_str(IFACE_GRAT_NEIGHBOR_ADV, ri, r,
- iface.gratuitous_neighbor_adv, IDBM_SHOW, num, 1);
-   __recinfo_uint8(IFACE_HOP_LIMIT, ri, r, iface.hop_limit, IDBM_SHOW,
-   num, 1);
-   __recinfo_str(IFACE_MLD, ri, r, iface.mld, IDBM_SHOW, num, 1);
-   __recinfo_uint32(IFACE_ND_REACHABLE_TMO, ri, r, iface.nd_reachable_tmo,
-IDBM_SHOW, num, 1);
-   __recinfo_uint32(IFACE_ND_REXMIT_TIME, ri, r, iface.nd_rexmit_time,
-IDBM_SHOW, num, 1);
-   __recinfo_uint32(IFACE_ND_STALE_TMO, ri, r, iface.nd_stale_tmo,
-IDBM_SHOW, num, 1);
-   __recinfo_uint32(IFACE_RTR_ADV_LINK_MTU, ri, r,
-iface.router_adv_link_mtu, IDBM_SHOW, num, 1);
-   __recinfo_uint8(IFACE_TRAFFIC_CLASS, ri, r, iface.traffic_class,
-   IDBM_SHOW, num, 1);
+   if (iface_type == ISCSI_IFACE_TYPE_IPV4) {
+   __recinfo_str(IFACE_BOOT_PROTO, 

[PATCH V2 10/11] iscsi tools: Let default type of iface be ipv4

2013-10-18 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

While using iface name to determine its type if the name does not
contain iface type then assume it be to of type ipv4 by default.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/iface.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/usr/iface.c b/usr/iface.c
index 87ac875..870dba0 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -450,8 +450,10 @@ int iface_get_iptype(struct iface_rec *iface)
/* try to figure out by name */
if (strstr(iface-name, ipv4))
return ISCSI_IFACE_TYPE_IPV4;
-   else
+   else if (strstr(iface-name, ipv6))
return ISCSI_IFACE_TYPE_IPV6;
+   else/* assume ipv4 by default */
+   return ISCSI_IFACE_TYPE_IPV4;
} else {
if (strcmp(iface-bootproto, dhcp) 
!strstr(iface-ipaddress, .))
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH V2 08/11] iscsi tools: Additional parameters for network settings

2013-10-18 Thread adheer.chandravanshi
From: Harish Zunjarrao harish.zunjar...@qlogic.com

Signed-off-by: Harish Zunjarrao harish.zunjar...@qlogic.com
Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/config.h  |   50 -
 usr/idbm.c|   76 +
 usr/idbm_fields.h |   49 
 usr/iface.c   |  823 -
 usr/iscsi_sysfs.c |  200 +
 5 files changed, 1120 insertions(+), 78 deletions(-)

diff --git a/usr/config.h b/usr/config.h
index d457bdd..fd31a54 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -232,11 +232,59 @@ typedef struct iface_rec {
   * 1 = enable */
uint16_tmtu;
uint16_tport;
+   chardelayed_ack[ISCSI_MAX_STR_LEN];
+   charnagle[ISCSI_MAX_STR_LEN];
+   chartcp_wsf_state[ISCSI_MAX_STR_LEN];
+   uint8_t tcp_wsf;
+   uint8_t tcp_timer_scale;
+   chartcp_timestamp[ISCSI_MAX_STR_LEN];
+   chardhcp_dns[ISCSI_MAX_STR_LEN];
+   chardhcp_slp_da[ISCSI_MAX_STR_LEN];
+   chartos_state[ISCSI_MAX_STR_LEN];
+   uint8_t tos;
+   chargratuitous_arp[ISCSI_MAX_STR_LEN];
+   chardhcp_alt_client_id_state[ISCSI_MAX_STR_LEN];
+   chardhcp_alt_client_id[ISCSI_MAX_STR_LEN];
+   chardhcp_req_vendor_id_state[ISCSI_MAX_STR_LEN];
+   chardhcp_vendor_id_state[ISCSI_MAX_STR_LEN];
+   chardhcp_vendor_id[ISCSI_MAX_STR_LEN];
+   chardhcp_learn_iqn[ISCSI_MAX_STR_LEN];
+   charfragmentation[ISCSI_MAX_STR_LEN];
+   charincoming_forwarding[ISCSI_MAX_STR_LEN];
+   uint8_t ttl;
+   chargratuitous_neighbor_adv[ISCSI_MAX_STR_LEN];
+   charredirect[ISCSI_MAX_STR_LEN];
+   charmld[ISCSI_MAX_STR_LEN];
+   uint32_tflow_label;
+   uint32_ttraffic_class;
+   uint8_t hop_limit;
+   uint32_tnd_reachable_tmo;
+   uint32_tnd_rexmit_time;
+   uint32_tnd_stale_tmo;
+   uint8_t dup_addr_detect_cnt;
+   uint32_trouter_adv_link_mtu;
+   uint16_tdef_task_mgmt_tmo;
+   charheader_digest[ISCSI_MAX_STR_LEN];
+   chardata_digest[ISCSI_MAX_STR_LEN];
+   charimmediate_data[ISCSI_MAX_STR_LEN];
+   charinitial_r2t[ISCSI_MAX_STR_LEN];
+   chardata_seq_inorder[ISCSI_MAX_STR_LEN];
+   chardata_pdu_inorder[ISCSI_MAX_STR_LEN];
+   uint8_t erl;
+   uint32_tmax_recv_dlength;
+   uint32_tfirst_burst_len;
+   uint16_tmax_out_r2t;
+   uint32_tmax_burst_len;
+   charchap_auth[ISCSI_MAX_STR_LEN];
+   charbidi_chap[ISCSI_MAX_STR_LEN];
+   charstrict_login_comp[ISCSI_MAX_STR_LEN];
+   chardiscovery_auth[ISCSI_MAX_STR_LEN];
+   chardiscovery_logout[ISCSI_MAX_STR_LEN];
charport_state[ISCSI_MAX_STR_LEN];
charport_speed[ISCSI_MAX_STR_LEN];
/*
 * TODO: we may have to make this bigger and interconnect
-* specific for infinniband 
+* specific for infiniband
 */
charhwaddress[ISCSI_HWADDRESS_BUF_SIZE];
chartransport_name[ISCSI_TRANSPORT_NAME_MAXLEN];
diff --git a/usr/idbm.c b/usr/idbm.c
index 6b6f57c..4428ebe 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -454,6 +454,82 @@ void idbm_recinfo_iface(iface_rec_t *r, recinfo_t *ri)
__recinfo_int(IFACE_NUM, ri, r, iface_num, IDBM_SHOW, num, 1);
__recinfo_uint16(IFACE_MTU, ri, r, mtu, IDBM_SHOW, num, 1);
__recinfo_uint16(IFACE_PORT, ri, r, port, IDBM_SHOW, num, 1);
+   __recinfo_str(IFACE_DHCP_ALT_CID, ri, r, dhcp_alt_client_id_state,
+ IDBM_SHOW, num, 1);
+   __recinfo_str(IFACE_DHCP_ALT_CID_STR, ri, r, dhcp_alt_client_id,
+ IDBM_SHOW, num, 1);
+   __recinfo_str(IFACE_DHCP_DNS, ri, r, dhcp_dns, IDBM_SHOW, num, 1);
+   __recinfo_str(IFACE_DHCP_LEARN_IQN, ri, r, dhcp_learn_iqn, IDBM_SHOW,
+ num, 1);
+   __recinfo_str(IFACE_DHCP_REQ_VID, ri, r, dhcp_req_vendor_id_state,
+ IDBM_SHOW, num, 1);

[PATCH 0/7] Open-iSCSI changes to support setting of CHAP entry

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Mike,

Following patches allow iscsiadm to add/update CHAP entry in
adapter's flash.

The kernel changes to support this are posted on linux-scsi
list here:
http://marc.info/?l=linux-scsim=137942076502663w=2

Please merge these patches to open-iscsi.git tree at your earliest
convenience.

Adheer Chandravanshi (7):
  flashnode: Add support to set ISCSI_FLASHNODE_CHAP_OUT_IDX param
  iscsiadm: Use '-x' option instead of '-v' to specify chap_tbl_idx
  iscsiadm: Man page changes to use -x option for chap_tbl_idx
  README changes to use long option --index instead of --flashnode_idx
  iscsiadm: Add support to set CHAP entry using host chap mode
  iscsi tools: Correctly get username_in and password_in flashnode
params
  README changes for adding support to set CHAP entry

Thanks,
Adheer

-- 
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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 6/7] iscsi tools: Correctly get username_in and password_in flashnode params

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Fix to correctly read username_in and password_in sysfs params for
flashnode session.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/iscsi_sysfs.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 56cb90c..04c3673 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -601,12 +601,12 @@ int iscsi_sysfs_get_flashnode_info(struct flashnode_rec 
*fnode,
sysfs_get_str(sess_id, ISCSI_FLASHNODE_SUBSYS, username,
  (fnode-sess).username, sizeof((fnode-sess).username));
sysfs_get_str(sess_id, ISCSI_FLASHNODE_SUBSYS, username_in,
- (fnode-sess).username,
+ (fnode-sess).username_in,
  sizeof((fnode-sess).username_in));
sysfs_get_str(sess_id, ISCSI_FLASHNODE_SUBSYS, password,
  (fnode-sess).password, sizeof((fnode-sess).password));
sysfs_get_str(sess_id, ISCSI_FLASHNODE_SUBSYS, password_in,
- (fnode-sess).password,
+ (fnode-sess).password_in,
  sizeof((fnode-sess).password_in));
sysfs_get_uint(conn_id, ISCSI_FLASHNODE_SUBSYS, statsn,
   ((fnode-conn[0]).stat_sn));
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 3/7] iscsiadm: Man page changes to use -x option for chap_tbl_idx

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Changes in iscsiadm man page to use -x option instead of -v option
for chap_tbl_idx cmdline param.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 doc/iscsiadm.8 |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
index 6b15fcd..0e8149c 100644
--- a/doc/iscsiadm.8
+++ b/doc/iscsiadm.8
@@ -16,7 +16,7 @@ iscsiadm \- open-iscsi administration utility
 
 \fBiscsiadm\fR \-m fw [ \-d debug_level ] [\-l]
 
-\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ [ \-C chap [ 
\-o operation ] [ \-v chap_tbl_idx ] ] | [ \-C flashnode [ \-o operation ] [ 
\-A portal_type ] [ \-x flashnode_idx ] [ \-n name ] [ \-v value ] ] ]
+\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ [ \-C chap [ 
\-x chap_tbl_idx ] ] | [ \-C flashnode [ \-A portal_type ] [ \-x flashnode_idx 
] ] ] [ [ \-o operation ] [ \-n name ] [ \-v value ] ]
 
 \fBiscsiadm\fR \-k priority
 
@@ -74,7 +74,7 @@ iscsiadm -m iface -I ifacename -C ping -a ipaddr -b 
packetsize -c count -i inter
 
 For host, it supports chap and flashnode as submodes. For example,
 
-iscsiadm -m host -H hostno -C chap -v chap_tbl_idx -o operation
+iscsiadm -m host -H hostno -C chap -x chap_tbl_idx -o operation
 
 iscsiadm -m host -H hostno -C flashnode -x flashnode_idx -o operation
 
@@ -320,10 +320,10 @@ This option is only valid for node mode and flashnode 
submode of host mode.
 display version and exit
 
 .TP
-\fB\-x\fR, \fB\-\-flashnode_idx=\fIindex\fR
-Specify the \fIindex\fR of the flash node to operate on.
+\fB\-x\fR, \fB\-\-index=\fIindex\fR
+Specify the \fIindex\fR of the entity to operate on.
 .IP
-This option is only valid for flashnode submode of host mode.
+This option is only valid for chap and flashnode submodes of host mode.
 
 .SH DISCOVERY TYPES
 iSCSI defines 3 discovery types: SendTargets, SLP, and iSNS.
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 1/7] flashnode: Add support to set ISCSI_FLASHNODE_CHAP_OUT_IDX param

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Add support to set the chap_out_idx session param of flashnode
entry.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/flashnode.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/usr/flashnode.c b/usr/flashnode.c
index da1392a..fe5ab57 100644
--- a/usr/flashnode.c
+++ b/usr/flashnode.c
@@ -449,6 +449,12 @@ int flashnode_build_config(struct list_head *params,
fnode-sess.portal_type,
sizeof(fnode-sess.portal_type)))
count++;
+   } else if (!strcmp(param-name,
+ to_key(FLASHNODE_SESS_CHAP_OUT_IDX))) {
+   if (!flashnode_fill_uint32(fnode, iov[count],
+   ISCSI_FLASHNODE_CHAP_OUT_IDX,
+   fnode-sess.chap_out_idx))
+   count++;
} else if (!strcmp(param-name, to_key(FLASHNODE_CONN_PORT))) {
if (fnode-conn[0].port)
port = fnode-conn[0].port;
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 7/7] README changes for adding support to set CHAP entry

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

README changes for the support added to set CHAP entry using chap
submode of iscsiadm host mode.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 README |   42 +-
 1 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/README b/README
index dda16c9..813548d 100644
--- a/README
+++ b/README
@@ -393,7 +393,7 @@ Usage: iscsiadm [OPTION]
  See below for examples.
   -m iface --interface=iscsi_ifacename -C ping --ip=[ipaddr] 
--packetsize=[size]
--count=[count] --interval=[interval]
-  -m host --host=hostno|MAC --print=level -C chap --op=[op] 
--index=[chap_tbl_idx]
+  -m host --host=hostno|MAC --print=level -C chap --op=[SHOW]
  Display information for a specific host. The host
  can be passed in by host number or by MAC address.
  If a host is not passed in then info
@@ -406,6 +406,14 @@ Usage: iscsiadm [OPTION]
  is connected to.
  3 = Print iscsi params used.
  4 = Print SCSI info like LUNs, device state.
+  -m host --host=hostno|MAC -C chap --op=[DELETE] --index=[chap_tbl_idx]
+  Delete chap entry at the given index from chap table.
+  -m host --host=hostno|MAC -C chap --op=[NEW | UPDATE] --index=[chap_tbl_idx] 
\
+   --name=[name] --value=[value]
+ Add new or update existing chap entry at the given
+ index with given username and password pair. If index
+ is not passed then entry is added at the first free
+ index in chap table.
   -m host --host=hostno|MAC -C flashnode
  Display list of all the targets in adapter's
  flash (flash node), for the specified host,
@@ -1033,6 +1041,38 @@ To now log into targets it is the same as with sofware 
iscsi. See section
 - Delete a flash node entry
./iscsiadm -m host -H 6 -C flashnode -x 1 -o delete
 
+Host mode with chap submode:
+
+- Display list of chap entries for a host
+
+   ./iscsiadm -m host -H 6 -C chap -o show
+
+   This will list all the chap entries for the given host.
+
+- Delete a chap entry for a host
+
+   ./iscsiadm -m host -H 6 -C chap -o delete -x 5
+
+   This will delete any chap entry present at given index 5.
+
+- Add/Update a local chap entry for a host
+
+   ./iscsiadm -m host -H 6 -C chap -o update -x 4 -n username \
+   -v value -n password -v value
+
+   This will update the local chap entry present at index 4. If index 4
+   is free then entry of type local chap will be created at that index
+   with given username and password values.
+
+- Add/Update a bidi chap entry for a host
+
+   ./iscsiadm -m host -H 6 -C chap -o update -x 5 -n username_in \
+   -v value -n password_in -v value
+
+   This will update the bidi chap entry present at index 5. If index 5
+   is free then entry of type bidi chap will be created at that index
+   with given username_in and password_in values.
+
 6. Configuration
 
 
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 5/7] iscsiadm: Add support to set CHAP entry using host chap mode

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Provide support to add and update CHAP entry using chap submode of
iscsiadm host mode.
Both, new and update, iscsiadm operations perform the same function.
Currently only one entry can be added or updated at a time.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 include/iscsi_if.h |   19 +-
 usr/host.c |  110 +++
 usr/host.h |1 +
 usr/idbm.c |8 +-
 usr/idbm.h |1 +
 usr/iscsi_ipc.h|3 +
 usr/iscsiadm.c |  207 +---
 usr/netlink.c  |   25 ++
 8 files changed, 360 insertions(+), 14 deletions(-)

diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index 01d38e7..0284662 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -74,8 +74,9 @@ enum iscsi_uevent_e {
ISCSI_UEVENT_LOGIN_FLASHNODE= UEVENT_BASE + 28,
ISCSI_UEVENT_LOGOUT_FLASHNODE   = UEVENT_BASE + 29,
ISCSI_UEVENT_LOGOUT_FLASHNODE_SID   = UEVENT_BASE + 30,
+   ISCSI_UEVENT_SET_CHAP   = UEVENT_BASE + 31,
 
-   ISCSI_UEVENT_MAX= ISCSI_UEVENT_LOGOUT_FLASHNODE_SID,
+   ISCSI_UEVENT_MAX= ISCSI_UEVENT_SET_CHAP,
 
/* up events */
ISCSI_KEVENT_RECV_PDU   = KEVENT_BASE + 1,
@@ -318,8 +319,16 @@ enum iscsi_param_type {
ISCSI_HOST_PARAM,   /* iscsi_host_param */
ISCSI_NET_PARAM,/* iscsi_net_param */
ISCSI_FLASHNODE_PARAM,  /* iscsi_flashnode_param */
+   ISCSI_CHAP_PARAM,   /* iscsi_chap_param */
 };
 
+/* structure for minimalist usecase */
+struct iscsi_param_info {
+   uint32_t len;   /* Actual length of the param value */
+   uint16_t param; /* iscsi param */
+   uint8_t value[0];   /* length sized value follows */
+} __attribute__((__packed__));
+
 struct iscsi_iface_param_info {
uint32_t iface_num; /* iface number, 0 - n */
uint32_t len;   /* Actual length of the param */
@@ -748,6 +757,14 @@ enum chap_type_e {
CHAP_TYPE_IN,
 };
 
+enum iscsi_chap_param {
+   ISCSI_CHAP_PARAM_INDEX,
+   ISCSI_CHAP_PARAM_CHAP_TYPE,
+   ISCSI_CHAP_PARAM_USERNAME,
+   ISCSI_CHAP_PARAM_PASSWORD,
+   ISCSI_CHAP_PARAM_PASSWORD_LEN
+};
+
 #define ISCSI_CHAP_AUTH_NAME_MAX_LEN   256
 #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
 struct iscsi_chap_rec {
diff --git a/usr/host.c b/usr/host.c
index 1fcb350..f2052d3 100644
--- a/usr/host.c
+++ b/usr/host.c
@@ -34,6 +34,7 @@
 #include initiator.h
 #include iface.h
 #include iscsi_err.h
+#include iscsi_netlink.h
 
 static int match_host_to_session(void *data, struct session_info *info)
 {
@@ -314,3 +315,112 @@ int host_info_print(int info_level, uint32_t host_no)
}
return 0;
 }
+
+static int chap_fill_param_uint(struct iovec *iov, int param,
+   uint32_t param_val, int param_len)
+{
+   struct iscsi_param_info *param_info;
+   struct nlattr *attr;
+   int len;
+   uint8_t val8 = 0;
+   uint16_t val16 = 0;
+   uint32_t val32 = 0;
+   char *val = NULL;
+
+   len = sizeof(struct iscsi_param_info) + param_len;
+   iov-iov_base = iscsi_nla_alloc(param, len);
+   if (!iov-iov_base)
+   return 1;
+
+   attr = iov-iov_base;
+   iov-iov_len = NLA_ALIGN(attr-nla_len);
+
+   param_info = (struct iscsi_param_info *)ISCSI_NLA_DATA(attr);
+   param_info-param = param;
+   param_info-len = param_len;
+
+   switch (param_len) {
+   case 1:
+   val8 = (uint8_t)param_val;
+   val = (char *)val8;
+   break;
+
+   case 2:
+   val16 = (uint16_t)param_val;
+   val = (char *)val16;
+   break;
+
+   case 4:
+   val32 = (uint32_t)param_val;
+   val = (char *)val32;
+   break;
+
+   default:
+   goto free;
+   }
+   memcpy(param_info-value, val, param_len);
+
+   return 0;
+
+free:
+   free(iov-iov_base);
+   iov-iov_base = NULL;
+   iov-iov_len = 0;
+   return 1;
+}
+
+static int chap_fill_param_str(struct iovec *iov, int param, char *param_val,
+  int param_len)
+{
+   struct iscsi_param_info *param_info;
+   struct nlattr *attr;
+   int len;
+
+   len = sizeof(struct iscsi_param_info) + param_len;
+   iov-iov_base = iscsi_nla_alloc(param, len);
+   if (!iov-iov_base)
+   return 1;
+
+   attr = iov-iov_base;
+   iov-iov_len = NLA_ALIGN(attr-nla_len);
+
+   param_info = (struct iscsi_param_info *)ISCSI_NLA_DATA(attr);
+   param_info-param = param;
+   param_info-len = param_len;
+   memcpy(param_info-value, param_val, param_len);
+   return 0;
+}
+
+int chap_build_config(struct 

[PATCH 2/7] iscsiadm: Use '-x' option instead of '-v' to specify chap_tbl_idx

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Make appropriate changes to use -x option for chap_tbl_idx cmdline
param. This is done because -v option is used along with -n option
to get the name/value pair.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/host.h |1 +
 usr/iscsiadm.c |   36 +---
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/usr/host.h b/usr/host.h
index db44cfa..52e5b9e 100644
--- a/usr/host.h
+++ b/usr/host.h
@@ -7,6 +7,7 @@
 
 #define MAX_HOST_NO UINT_MAX
 
+#define MAX_CHAP_ENTRIES 2048
 #define MAX_CHAP_BUF_SZ 4096
 #define REQ_CHAP_BUF_SZ (MAX_CHAP_BUF_SZ + sizeof(struct iscsi_uevent))
 
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index c7337ae..beabdf0 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -115,7 +115,7 @@ static struct option const long_options[] =
{packetsize, required_argument, NULL, 'b'},
{count, required_argument, NULL, 'c'},
{interval, required_argument, NULL, 'i'},
-   {flashnode_idx, optional_argument, NULL, 'x'},
+   {index, optional_argument, NULL, 'x'},
{portal_type, optional_argument, NULL, 'A'},
{NULL, 0, NULL, 0},
 };
@@ -136,7 +136,7 @@ iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel 
] [ -L all,manual,au
 iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P  printlevel] [ -r 
sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] 
]\n\
 iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename 
| -H hostno|MAC ] [ [ -o  operation  ] [ -n name ] [ -v value ] ] [ -C ping [ 
-a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]\n\
 iscsiadm -m fw [ -d debug_level ] [ -l ]\n\
-iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -o 
operation ] [ -v chap_tbl_idx ] ] | [ -C flashnode [ -o operation ] [ -A 
portal_type ] [ -x flashnode_idx ] [ -n name ] [ -v value ] ] ]\n\
+iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -x 
chap_tbl_idx ] ] | [ -C flashnode [ -A portal_type ] [ -x flashnode_idx ] ] ] [ 
[ -o operation ] [ -n name ] [ -v value ] ] \n\
 iscsiadm -k priority\n);
}
exit(status);
@@ -1426,18 +1426,10 @@ exit_chap_info:
return rc;
 }
 
-static int delete_host_chap_info(uint32_t host_no, char *value)
+static int delete_host_chap_info(uint32_t host_no, uint16_t chap_tbl_idx)
 {
struct iscsi_transport *t = NULL;
int fd, rc = 0;
-   uint16_t chap_tbl_idx;
-
-   if (!value) {
-   log_error(CHAP deletion requires --value=table_index.);
-   return ISCSI_ERR_INVAL;
-   }
-
-   chap_tbl_idx = (uint16_t)atoi(value);
 
t = iscsi_sysfs_get_transport_by_hba(host_no);
if (!t) {
@@ -1472,22 +1464,28 @@ exit_delete_chap:
 }
 
 static int exec_host_chap_op(int op, int info_level, uint32_t host_no,
-char *value)
+uint64_t chap_index)
 {
int rc = ISCSI_ERR_INVAL;
 
+   if (op != OP_SHOW  (chap_index  (uint64_t)MAX_CHAP_ENTRIES)) {
+   log_error(Invalid chap table index.);
+   goto exit_chap_op;
+   }
+
switch (op) {
case OP_SHOW:
rc = get_host_chap_info(host_no);
break;
case OP_DELETE:
-   rc = delete_host_chap_info(host_no, value);
+   rc = delete_host_chap_info(host_no, chap_index);
break;
default:
log_error(Invalid operation.);
break;
}
 
+exit_chap_op:
return rc;
 }
 
@@ -2818,7 +2816,7 @@ main(int argc, char **argv)
struct iface_rec *iface = NULL, *tmp;
struct node_rec *rec = NULL;
uint64_t host_no =  (uint64_t)MAX_HOST_NO + 1;
-   uint64_t flashnode_idx = (uint64_t)MAX_FLASHNODE_IDX + 1;
+   uint64_t index = (uint64_t)MAX_FLASHNODE_IDX + 1;
struct user_param *param;
struct list_head params;
 
@@ -2962,9 +2960,9 @@ main(int argc, char **argv)
ISCSI_VERSION_STR);
return 0;
case 'x':
-   flashnode_idx = strtoull(optarg, NULL, 10);
+   index = strtoull(optarg, NULL, 10);
if (errno) {
-   log_error(Invalid flashnode index %s. %s.,
+   log_error(Invalid index %s. %s.,
  optarg, strerror(errno));
rc = ISCSI_ERR_INVAL;
goto free_ifaces;
@@ -3041,7 +3039,7 @@ main(int argc, char **argv)
break;
}
rc = exec_host_chap_op(op, info_level, host_no,
-  

[PATCH 4/7] README changes to use long option --index instead of --flashnode_idx

2013-09-17 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This change supports use of -x option instead of -v option for
chap_tbl_idx cmdline param.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 README |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 29b00a9..dda16c9 100644
--- a/README
+++ b/README
@@ -393,7 +393,7 @@ Usage: iscsiadm [OPTION]
  See below for examples.
   -m iface --interface=iscsi_ifacename -C ping --ip=[ipaddr] 
--packetsize=[size]
--count=[count] --interval=[interval]
-  -m host --host=hostno|MAC --print=level -C chap --op=[op] 
--value=[chap_tbl_idx]
+  -m host --host=hostno|MAC --print=level -C chap --op=[op] 
--index=[chap_tbl_idx]
  Display information for a specific host. The host
  can be passed in by host number or by MAC address.
  If a host is not passed in then info
@@ -414,13 +414,13 @@ Usage: iscsiadm [OPTION]
  Create new flash node entry for the given host of the
  specified portal_type. This returns the index of the
  newly created entry on success.
-  -m host --host=hostno|MAC -C flashnode --flashnode_idx=[flashnode index] \
+  -m host --host=hostno|MAC -C flashnode --index=[flashnode index] \
--op=[UPDATE] --name=[name] --value=[value]
  Update the params of the speficied flash node.
  The [name] and [value] pairs must be provided for the
  params that need to be updated. Multiple params can
  be updated using a single command.
-  -m host --host=hostno|MAC -C flashnode--flashnode_idx=[flashnode index] \
+  -m host --host=hostno|MAC -C flashnode --index=[flashnode index] \
--op=[SHOW | DELETE | LOGIN | LOGOUT]
  op=DELETE|LOGIN|LOGOUT will perform deletion/login/
  logout operation on the specified flash node.
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.


[PATCH 1/2] iscsiadm: Correctly check for invalid hostno and flashnode index

2013-07-09 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

In host mode, correctly compare for invalid hostno and flashnode index.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/flashnode.h |2 ++
 usr/host.h  |2 ++
 usr/iscsiadm.c  |   48 ++--
 usr/types.h |1 +
 4 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/usr/flashnode.h b/usr/flashnode.h
index c1de9cc..2950fb5 100644
--- a/usr/flashnode.h
+++ b/usr/flashnode.h
@@ -26,6 +26,8 @@
 #include config.h
 #include auth.h
 
+#define MAX_FLASHNODE_IDX UINT_MAX
+
 typedef enum portal_type {
IPV4,
IPV6,
diff --git a/usr/host.h b/usr/host.h
index 894ab91..db44cfa 100644
--- a/usr/host.h
+++ b/usr/host.h
@@ -5,6 +5,8 @@
 #include types.h
 #include config.h
 
+#define MAX_HOST_NO UINT_MAX
+
 #define MAX_CHAP_BUF_SZ 4096
 #define REQ_CHAP_BUF_SZ (MAX_CHAP_BUF_SZ + sizeof(struct iscsi_uevent))
 
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 5030894..d74c387 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1742,20 +1742,22 @@ exit_logout_sid:
 }
 
 static int exec_flashnode_op(int op, int info_level, uint32_t host_no,
-uint32_t flashnode_idx, int type,
+uint64_t fnode_idx, int type,
 struct list_head *params)
 {
struct iscsi_transport *t = NULL;
int rc = ISCSI_SUCCESS;
char *portal_type;
+   uint32_t flashnode_idx;
 
if (op != OP_SHOW  op != OP_NOOP  op != OP_NEW 
-   flashnode_idx == 0x) {
+   fnode_idx  MAX_FLASHNODE_IDX) {
log_error(Invalid flashnode index);
rc = ISCSI_ERR_INVAL;
goto exit_flashnode_op;
}
 
+   flashnode_idx = (uint32_t)fnode_idx;
t = iscsi_sysfs_get_transport_by_hba(host_no);
if (!t) {
log_error(Could not match hostno %u to transport., host_no);
@@ -1766,7 +1768,7 @@ static int exec_flashnode_op(int op, int info_level, 
uint32_t host_no,
switch (op) {
case OP_NOOP:
case OP_SHOW:
-   if (flashnode_idx == 0x)
+   if (fnode_idx  MAX_FLASHNODE_IDX)
rc = list_flashnodes(info_level, host_no);
else
rc = get_flashnode_info(host_no, flashnode_idx);
@@ -1878,7 +1880,7 @@ static int verify_iface_params(struct list_head *params, 
struct node_rec *rec)
 
 /* TODO: merge iter helpers and clean them up, so we can use them here */
 static int exec_iface_op(int op, int do_show, int info_level,
-struct iface_rec *iface, uint32_t host_no,
+struct iface_rec *iface, uint64_t host_no,
 struct list_head *params)
 {
struct host_info hinfo;
@@ -1999,9 +2001,9 @@ update_fail:
printf(%s applied.\n, iface-name);
break;
case OP_APPLY_ALL:
-   if (host_no == -1) {
-   log_error(Applyall requires a host number or MAC 
- passed in with the --host argument.);
+   if (host_no  MAX_HOST_NO) {
+   log_error(Applyall requires a valid host number or MAC
+  passed in with the --host argument.);
rc = ISCSI_ERR_INVAL;
break;
}
@@ -2012,7 +2014,7 @@ update_fail:
memset(hinfo, 0, sizeof(struct host_info));
hinfo.host_no = host_no;
if (iscsi_sysfs_get_hostinfo_by_host_no(hinfo)) {
-   log_error(Could not match host%u to ifaces., host_no);
+   log_error(Could not match host%lu to ifaces., 
host_no);
rc = ISCSI_ERR_INVAL;
break;
}
@@ -2023,7 +2025,7 @@ update_fail:
break;
}
 
-   printf(Applied settings to ifaces attached to host%u.\n,
+   printf(Applied settings to ifaces attached to host%lu.\n,
   host_no);
break;
default:
@@ -2635,10 +2637,10 @@ done:
return rc;
 }
 
-static uint32_t parse_host_info(char *optarg, int *rc)
+static uint64_t parse_host_info(char *optarg, int *rc)
 {
int err = 0;
-   uint32_t host_no = -1;
+   uint64_t host_no;
 
*rc = 0;
if (strstr(optarg, :)) {
@@ -2651,8 +2653,11 @@ static uint32_t parse_host_info(char *optarg, int *rc)
*rc = ISCSI_ERR_INVAL;
}
} else {
-   host_no = strtoul(optarg, NULL, 10);
-   if (errno) {
+   host_no = strtoull(optarg, NULL, 10);
+   if (errno || (host_no  MAX_HOST_NO)) {
+   if 

[PATCH 2/2] iscsi tools: Print additional session info for flashnode session

2013-07-09 Thread adheer.chandravanshi
From: Vikas Chaudhary vikas.chaudh...@qlogic.com

Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
---
 usr/session_info.c |   24 +++-
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/usr/session_info.c b/usr/session_info.c
index 1f84c49..c2ea429 100644
--- a/usr/session_info.c
+++ b/usr/session_info.c
@@ -64,20 +64,32 @@ void session_info_free_list(struct list_head *list)
}
 }
 
+static char *get_iscsi_node_type(struct session_info *info)
+{
+   int pid = iscsi_sysfs_session_user_created(info-sid);
+
+   if (!pid)
+   return flash;
+   else
+   return non-flash;
+}
+
 static int session_info_print_flat(void *data, struct session_info *info)
 {
struct iscsi_transport *t = iscsi_sysfs_get_transport_by_sid(info-sid);
 
if (strchr(info-persistent_address, '.'))
-   printf(%s: [%d] %s:%d,%d %s\n,
+   printf(%s: [%d] %s:%d,%d %s (%s)\n,
t ? t-name : UNKNOWN_VALUE,
info-sid, info-persistent_address,
-   info-persistent_port, info-tpgt, info-targetname);
+   info-persistent_port, info-tpgt, info-targetname,
+   get_iscsi_node_type(info));
else
-   printf(%s: [%d] [%s]:%d,%d %s\n,
+   printf(%s: [%d] [%s]:%d,%d %s (%s)\n,
t ? t-name : UNKNOWN_VALUE,
info-sid, info-persistent_address,
-   info-persistent_port, info-tpgt, info-targetname);
+   info-persistent_port, info-tpgt, info-targetname,
+   get_iscsi_node_type(info));
return 0;
 }
 
@@ -230,7 +242,8 @@ void session_info_print_tree(struct list_head *list, char 
*prefix,
 
list_for_each_entry(curr, list, list) {
if (!prev || strcmp(prev-targetname, curr-targetname)) {
-   printf(%sTarget: %s\n, prefix, curr-targetname);
+   printf(%sTarget: %s (%s)\n, prefix, curr-targetname,
+   get_iscsi_node_type(curr));
prev = NULL;
}
 
@@ -278,6 +291,7 @@ void session_info_print_tree(struct list_head *list, char 
*prefix,
printf(%s\t\tSID: %d\n, prefix, curr-sid);
print_iscsi_state(curr-sid, prefix);
}
+
if (flags  SESSION_INFO_ISCSI_TIM) {
printf(%s\t\t*\n, prefix);
printf(%s\t\tTimeouts:\n, prefix);
-- 
1.7.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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.




[PATCH 0/2] Fixes for open-iscsi

2013-07-09 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Mike,

Please apply the following patches to the open-iscsi tree at your earliest
convenience.

Adheer Chandravanshi (1):
  iscsiadm: Correctly check for invalid hostno and flashnode index

Vikas Chaudhary (1):
  iscsi tools: Print additional session info for flashnode session

Thanks,
Adheer.

-- 
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 http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.