[PATCH] iscsid sends SIGTERM to PID 0

2011-06-21 Thread Hannes Reinecke

Occasionally iscisd will send a SIGTERM to pid 0, causing
all sorts of weird things. Problem is that pid == 0 is
a valid return value for log_init(), so that all routines
only check for pid  0. However, as the signal handler
is inherited from the parent, even the logging thread
has a signal handler installed, for which the internal
pid is always '0'. So when a SIGTERM is send to the
logging thread, it'll forward the signal to PID 0.

References: bnc#589064

Signed-off-by: Hannes Reinecke h...@suse.de

diff --git a/usr/iscsid.c b/usr/iscsid.c
index 50c9b58..2e234fc 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -345,14 +345,6 @@ int main(int argc, char *argv[])
struct sigaction sa_new;
pid_t pid;
 
-   /* do not allow ctrl-c for now... */
-   sa_new.sa_handler = catch_signal;
-   sigemptyset(sa_new.sa_mask);
-   sa_new.sa_flags = 0;
-   sigaction(SIGINT, sa_new, sa_old );
-   sigaction(SIGPIPE, sa_new, sa_old );
-   sigaction(SIGTERM, sa_new, sa_old );
-
while ((ch = getopt_long(argc, argv, c:i:fd:nu:g:p:vh, long_options,
 longindex)) = 0) {
switch (ch) {
@@ -398,6 +390,14 @@ int main(int argc, char *argv[])
if (log_pid  0)
exit(1);
 
+   /* do not allow ctrl-c for now... */
+   sa_new.sa_handler = catch_signal;
+   sigemptyset(sa_new.sa_mask);
+   sa_new.sa_flags = 0;
+   sigaction(SIGINT, sa_new, sa_old );
+   sigaction(SIGPIPE, sa_new, sa_old );
+   sigaction(SIGTERM, sa_new, sa_old );
+
sysfs_init();
if (idbm_init(iscsid_get_config_file)) {
log_close(log_pid);
diff --git a/usr/log.c b/usr/log.c
index 62500cb..28e 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -458,6 +458,8 @@ void log_close(pid_t pid)
return;
}
 
-   kill(pid, SIGTERM);
-   waitpid(pid, status, 0);
+   if (pid  0) {
+   kill(pid, SIGTERM);
+   waitpid(pid, status, 0);
+   }
 }

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 0/8] SUSE SLES resync

2011-06-21 Thread Hannes Reinecke
Hi Mike,

it's the time of the year when the lilies blossom and
I finally managed to get around sending my outstanding
patches.
Mose of them are some compability issues, with the
occasional bug (cf the second patch) thrown in.
Oh, and please ignore the previous two patches;
I've generated them from my local tree and they
won't apply properly.

Hannes Reinecke (8):
  ibft scanning fails on newer kernels
  iscsid sends SIGTERM to PID 0
  iscsid: Implement --no-pid-file
  Keep startup mode in sync when specified in config file
  Allow LOCK_DIR to be set via CFLAGS
  Allow 'onboot' as loginall parameter
  Update SUSE init script
  boot.suse: Update with latest fixes

 doc/iscsid.8|3 +
 etc/initd/boot.suse |   35 +--
 etc/initd/initd.suse|  452 ---
 usr/idbm.c  |   25 ++-
 usr/initiator.h |6 +-
 usr/iscsiadm.c  |   19 +-
 usr/iscsid.c|   56 +++--
 usr/log.c   |6 +-
 utils/fwparam_ibft/fwparam_ibft_sysfs.c |   15 +-
 9 files changed, 449 insertions(+), 168 deletions(-)

-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 1/8] ibft scanning fails on newer kernels

2011-06-21 Thread Hannes Reinecke
Newer kernels provide the 'net' link as a directory, instead of the
'net:XX' link with previous kernels. The sysfs scanning code has
enablement to work with this, but the directory lookup doesn't
work properly.

References: bnc#561596

Signed-off-by: Hannes Reinecke h...@suse.de
---
 utils/fwparam_ibft/fwparam_ibft_sysfs.c |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/utils/fwparam_ibft/fwparam_ibft_sysfs.c 
b/utils/fwparam_ibft/fwparam_ibft_sysfs.c
index 9185c85..486deec 100644
--- a/utils/fwparam_ibft/fwparam_ibft_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_ibft_sysfs.c
@@ -84,7 +84,7 @@ static int find_sysfs_dirs(const char *fpath, const struct 
stat *sb,
 static int get_iface_from_device(char *id, struct boot_context *context)
 {
char dev_dir[FILENAMESZ];
-   int rc = ENODEV;
+   int rc = EOPNOTSUPP;
DIR *dirfd;
struct dirent *dent;
 
@@ -99,8 +99,7 @@ static int get_iface_from_device(char *id, struct 
boot_context *context)
return errno;
 
while ((dent = readdir(dirfd))) {
-   if (!strcmp(dent-d_name, .) || !strcmp(dent-d_name, ..) ||
-   strncmp(dent-d_name, net:, 4))
+   if (!strcmp(dent-d_name, .) || !strcmp(dent-d_name, ..))
continue;
 
if (!strncmp(dent-d_name, net:, 4)) {
@@ -116,17 +115,19 @@ static int get_iface_from_device(char *id, struct 
boot_context *context)
rc = EINVAL;
rc = 0;
break;
-   } else {
-   printf(Could not read ethernet to net link.\n);
-   rc = EOPNOTSUPP;
+   }
+   if (!strcmp(dent-d_name, net)) {
+   rc = ENODEV;
break;
}
}
 
closedir(dirfd);
 
-   if (rc != ENODEV)
+   if (rc != ENODEV) {
+   printf(Could not read ethernet to net link\n.);
return rc;
+   }
 
/* If not found try again with newer kernel networkdev sysfs layout */
strlcat(dev_dir, /net, FILENAMESZ);
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 2/8] iscsid sends SIGTERM to PID 0

2011-06-21 Thread Hannes Reinecke
Occasionally iscisd will send a SIGTERM to pid 0, causing
all sorts of weird things. Problem is that pid == 0 is
a valid return value for log_init(), so that all routines
only check for pid  0. However, as the signal handler
is inherited from the parent, even the logging thread
has a signal handler installed, for which the internal
pid is always '0'. So when a SIGTERM is send to the
logging thread, it'll forward the signal to PID 0.

References: bnc#589064

Signed-off-by: Hannes Reinecke h...@suse.de
---
 usr/iscsid.c |   16 
 usr/log.c|6 --
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/usr/iscsid.c b/usr/iscsid.c
index 67a6944..3fa3295 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -339,14 +339,6 @@ int main(int argc, char *argv[])
int control_fd;
pid_t pid;
 
-   /* do not allow ctrl-c for now... */
-   sa_new.sa_handler = catch_signal;
-   sigemptyset(sa_new.sa_mask);
-   sa_new.sa_flags = 0;
-   sigaction(SIGINT, sa_new, sa_old );
-   sigaction(SIGPIPE, sa_new, sa_old );
-   sigaction(SIGTERM, sa_new, sa_old );
-
while ((ch = getopt_long(argc, argv, c:i:fd:u:g:p:vh, long_options,
 longindex)) = 0) {
switch (ch) {
@@ -390,6 +382,14 @@ int main(int argc, char *argv[])
if (log_pid  0)
exit(ISCSI_ERR);
 
+   /* do not allow ctrl-c for now... */
+   sa_new.sa_handler = catch_signal;
+   sigemptyset(sa_new.sa_mask);
+   sa_new.sa_flags = 0;
+   sigaction(SIGINT, sa_new, sa_old );
+   sigaction(SIGPIPE, sa_new, sa_old );
+   sigaction(SIGTERM, sa_new, sa_old );
+
sysfs_init();
if (idbm_init(iscsid_get_config_file)) {
log_close(log_pid);
diff --git a/usr/log.c b/usr/log.c
index 9d5f933..5747554 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -474,6 +474,8 @@ void log_close(pid_t pid)
return;
}
 
-   kill(pid, SIGTERM);
-   waitpid(pid, status, 0);
+   if (pid  0) {
+   kill(pid, SIGTERM);
+   waitpid(pid, status, 0);
+   }
 }
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 3/8] iscsid: Implement --no-pid-file

2011-06-21 Thread Hannes Reinecke
For root on iSCSI scenarios the /var directory might not exist.
And we don't need the pid file anyway as the daemon is synchronized
via the IPC connection.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 doc/iscsid.8 |3 +++
 usr/iscsid.c |   40 
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/doc/iscsid.8 b/doc/iscsid.8
index 1dfa1e5..92b7f81 100644
--- a/doc/iscsid.8
+++ b/doc/iscsid.8
@@ -35,6 +35,9 @@ run under user ID \fIuid\fR (default is the current user ID)
 .BI [-g|--gid=]\fIgid\fP
 run under user group ID \fIgid\fR (default is the current user group ID).
 .TP
+.BI [-n|--no-pid-file]\fP
+do not write a process ID file.
+.TP
 .BI [-p|--pid=]\fIpid\-file\fP
 write process ID to \fIpid\-file\fR rather than the default
 \fI/var/run/iscsid.pid\fR
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 3fa3295..1a37347 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -69,6 +69,7 @@ static struct option const long_options[] = {
{debug, required_argument, NULL, 'd'},
{uid, required_argument, NULL, 'u'},
{gid, required_argument, NULL, 'g'},
+   {no-pid-file, no_argument, NULL, 'n'},
{pid, required_argument, NULL, 'p'},
{help, no_argument, NULL, 'h'},
{version, no_argument, NULL, 'v'},
@@ -90,6 +91,7 @@ Open-iSCSI initiator daemon.\n\
   -d, --debug debuglevel  print debugging information\n\
   -u, --uid=uid   run as uid, default is current user\n\
   -g, --gid=gid   run as gid, default is current user group\n\
+  -n, --no-pid-file   do not use a pid file\n\
   -p, --pid=pidfile   use pid file (default  PID_FILE ).\n\
   -h, --help  display this help and exit\n\
   -v, --version   display version and exit\n\
@@ -339,7 +341,7 @@ int main(int argc, char *argv[])
int control_fd;
pid_t pid;
 
-   while ((ch = getopt_long(argc, argv, c:i:fd:u:g:p:vh, long_options,
+   while ((ch = getopt_long(argc, argv, c:i:fd:nu:g:p:vh, long_options,
 longindex)) = 0) {
switch (ch) {
case 'c':
@@ -360,6 +362,9 @@ int main(int argc, char *argv[])
case 'g':
gid = strtoul(optarg, NULL, 10);
break;
+   case 'n':
+   pid_file = NULL;
+   break;
case 'p':
pid_file = optarg;
break;
@@ -415,13 +420,15 @@ int main(int argc, char *argv[])
 
if (daemonize) {
char buf[64];
-   int fd;
-
-   fd = open(pid_file, O_WRONLY|O_CREAT, 0644);
-   if (fd  0) {
-   log_error(Unable to create pid file);
-   log_close(log_pid);
-   exit(ISCSI_ERR);
+   int fd = -1;
+
+   if (pid_file) {
+   fd = open(pid_file, O_WRONLY|O_CREAT, 0644);
+   if (fd  0) {
+   log_error(Unable to create pid file);
+   log_close(log_pid);
+   exit(ISCSI_ERR);
+   }
}
pid = fork();
if (pid  0) {
@@ -439,15 +446,16 @@ int main(int argc, char *argv[])
}
 
chdir(/);
-   if (lockf(fd, F_TLOCK, 0)  0) {
-   log_error(Unable to lock pid file);
-   log_close(log_pid);
-   exit(ISCSI_ERR);
+   if (fd  0) {
+   if (lockf(fd, F_TLOCK, 0)  0) {
+   log_error(Unable to lock pid file);
+   log_close(log_pid);
+   exit(ISCSI_ERR);
+   }
+   ftruncate(fd, 0);
+   sprintf(buf, %d\n, getpid());
+   write(fd, buf, strlen(buf));
}
-   ftruncate(fd, 0);
-   sprintf(buf, %d\n, getpid());
-   write(fd, buf, strlen(buf));
-
daemon_init();
} else {
if ((control_fd = ipc-ctldev_open())  0) {
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 5/8] Allow LOCK_DIR to be set via CFLAGS

2011-06-21 Thread Hannes Reinecke
For root on iSCSI we have to move idbm's LOCK_DIR to eg /etc/iscsi,
as the /var directory might not be available. So make it configurable
during compile-time.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 usr/initiator.h |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/usr/initiator.h b/usr/initiator.h
index 93e9b3b..8497c70 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -39,9 +39,11 @@
 #define INITIATOR_NAME_FILEISCSI_CONFIG_ROOTinitiatorname.iscsi
 
 #define PID_FILE   /var/run/iscsid.pid
+#ifndef LOCK_DIR
 #define LOCK_DIR   /var/lock/iscsi
-#define LOCK_FILE  /var/lock/iscsi/lock
-#define LOCK_WRITE_FILE/var/lock/iscsi/lock.write
+#endif
+#define LOCK_FILE  LOCK_DIR/lock
+#define LOCK_WRITE_FILELOCK_DIR/lock.write
 
 typedef enum iscsi_conn_state_e {
STATE_FREE,
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 6/8] Allow 'onboot' as loginall parameter

2011-06-21 Thread Hannes Reinecke
We are using to 'onboot' parameter to setup iscsi connections
in the initrd. Thus we should be able to use 'onboot' as a valid
parameter for loginall, too.

References: 449108

Signed-off-by: Hannes Reinecke h...@suse.de
---
 usr/iscsiadm.c |   19 +--
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 5972d01..e3a6b81 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -265,15 +265,10 @@ static int print_ifaces(struct iface_rec *iface, int 
info_level)
 static int
 match_startup_mode(node_rec_t *rec, char *mode)
 {
-   /*
-* we always skip onboot because this should be handled by
-* something else
-*/
-   if (rec-startup == ISCSI_STARTUP_ONBOOT)
-   return -1;
-
if ((!strcmp(mode, automatic) 
rec-startup == ISCSI_STARTUP_AUTOMATIC) ||
+   (!strcmp(mode, onboot) 
+   rec-startup == ISCSI_STARTUP_ONBOOT) ||
(!strcmp(mode, manual) 
rec-startup == ISCSI_STARTUP_MANUAL) ||
!strcmp(mode, all))
@@ -282,6 +277,8 @@ match_startup_mode(node_rec_t *rec, char *mode)
/* support conn or session startup params */
if ((!strcmp(mode, automatic) 
rec-conn[0].startup == ISCSI_STARTUP_AUTOMATIC) ||
+   (!strcmp(mode, onboot) 
+   rec-conn[0].startup == ISCSI_STARTUP_ONBOOT) ||
(!strcmp(mode, manual) 
rec-conn[0].startup == ISCSI_STARTUP_MANUAL) ||
!strcmp(mode, all))
@@ -385,12 +382,6 @@ static int
 __login_by_startup(void *data, struct list_head *list, struct node_rec *rec)
 {
char *mode = data;
-   /*
-* we always skip onboot because this should be handled by
-* something else
-*/
-   if (rec-startup == ISCSI_STARTUP_ONBOOT)
-   return -1;
 
if (match_startup_mode(rec, mode))
return -1;
@@ -405,7 +396,7 @@ login_by_startup(char *mode)
struct list_head rec_list;
 
if (!mode || !(!strcmp(mode, automatic) || !strcmp(mode, all) ||
-   !strcmp(mode,manual))) {
+  !strcmp(mode,manual) || !strcmp(mode, onboot))) {
log_error(Invalid loginall option %s., mode);
usage(ISCSI_ERR_INVAL);
return ISCSI_ERR_INVAL;
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 7/8] Update SUSE init script

2011-06-21 Thread Hannes Reinecke
Rework the iSCSI shutdown logic to tear down the block device
stack correctly.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 etc/initd/initd.suse |  452 +++---
 1 files changed, 354 insertions(+), 98 deletions(-)

diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index a587aff..1829419 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -5,20 +5,22 @@
 ### BEGIN INIT INFO
 # Provides:  iscsi
 # Required-Start:$network
-# Should-Start:  iscsitarget
-# Required-Stop: 
-# Should-Stop:
+# Should-Start:  iscsitarget multipathd
+# Required-Stop: $network
+# Should-Stop:   multipathd
 # Default-Start: 3 5
 # Default-Stop:  
-# Short-Description: Starts and stops the iSCSI client initiator
+# Short-Description: iSCSI initiator daemon
+# Description:   The iSCSI initator is used to create and
+#manage iSCSI connections to a iSCSI Target.
 #
 ### END INIT INFO
 
-PID_FILE=/var/run/iscsi.pid
 CONFIG_FILE=/etc/iscsi/iscsid.conf
 DAEMON=/sbin/iscsid
 ISCSIADM=/sbin/iscsiadm
-ARGS=-c $CONFIG_FILE -p $PID_FILE
+BRCM_ISCSIUIO=/sbin/brcm_iscsiuio
+ARGS=-c $CONFIG_FILE -n
 
 # Source LSB init functions
 . /etc/rc.status
@@ -26,6 +28,8 @@ ARGS=-c $CONFIG_FILE -p $PID_FILE
 # Reset status of this service
 rc_reset
 
+DM_MAJOR=$(sed -n 's/\(.*\) device-mapper/\1/p' /proc/devices)
+
 iscsi_login_all_nodes()
 {
echo -n Setting up iSCSI targets: 
@@ -36,58 +40,349 @@ iscsi_login_all_nodes()
rc_status -v
 }
 
-iscsi_logout_all_nodes()
+#
+# Try to load all required modules prior to startup
+#
+iscsi_load_transport_modules()
 {
-   echo -n Closing all iSCSI connections: 
-   # Logout from all sessions marked automatic
-   if ! $ISCSIADM -m node --logoutall=automatic 2 /dev/null; then
-   if [ $? == 21 ] ; then
-   RETVAL=6
-   else
-   RETVAL=1
+loaded=$(sed -n /^iscsi_tcp/p /proc/modules)
+if [ -z $loaded ] ; then
+   modprobe iscsi_tcp
+   if [ $? = 0 ] ; then
+   echo -n  tcp
+   fi
+fi
+
+for iface in /etc/iscsi/ifaces/*; do
+   [ -f $iface ] || continue
+   [ $iface = iface.example ]  continue
+   # Check if the iface has been configured
+   result=$(sed 
'/#.*/D;/iface.iscsi_ifacename/D;/iface.hwaddress/D;/iface.transport_name/D' 
$iface)
+   if [ $result ] ; then
+   mod=$(sed -n 's/iface.transport_name *= *\(.*\)/\1/p' $iface)
+   loaded=$(sed -n /^$mod/p /proc/modules)
+   if [ -z $loaded ] ; then
+   modprobe $mod
+   if [ $? = 0 ] ; then
+   echo -n  $mod
fi
-   rc_failed $RETVAL
+   fi
fi
-   rc_status -v
+done
+}
 
-   # Not sure whether this is still needed
-   sleep 1
-   return ${RETVAL:-0}
+#
+# Set a temporary startmode for ifdown
+#
+iscsi_modify_if_startmode()
+{
+local ifname=$1
+local tmp_ifcfg=/dev/.sysconfig/network/if-$ifname
+
+if [ -e $tmp_ifcfg ] ; then
+   . $tmp_ifcfg
+   if [ $startmode ] ; then
+   return
+   fi
+fi
+: disabling shutdown on $ifname
+echo startmode=nfsroot  $tmp_ifcfg
 }
 
-iscsi_umount_all_luns()
+iscsi_get_ifacename_from_session()
 {
-local d m dev p s
+local session=$1
+local ifacename
 
-cat /proc/mounts | sed -ne '/^\/dev\/.*/p' | while read d m t o x; do 
-   if [ $m = / ] ; then 
-   continue;
+ifacename=$(iscsiadm -m session -r ${session##.*/session} 2 /dev/null | \
+   sed -n 's/iface.iscsi_ifacename = \(.*\)/\1/p')
+if [ -z $ifacename ] ; then
+   # Check for iBFT
+   ifacename=$(iscsiadm -m fw 2 /dev/null)
+   if [ -n $ifacename ] ; then
+   ifacename=fw
fi
+fi
+echo $ifacename
+}
+
+iscsi_get_hwaddress_from_iface()
+{
+local iface=$1
+local hwaddress
+
+hwaddress=$(iscsiadm -m iface -I $iface 2 /dev/null | sed -n 
's/iface.hwaddress = \(.*\)/\1/p')
+[ $hwaddress = empty ]  hwaddress=
+
+echo $hwaddress
+}
+
+iscsi_get_ifname_from_iface()
+{
+local iface=$1
+local ifname
+
+ifname=$(iscsiadm -m iface -I $iface 2 /dev/null | sed -n 
's/iface.net_ifacename = \(.*\)/\1/p')
+[ $ifname = empty ]  ifname=
+
+echo $ifname
+}
+
+iscsi_get_ipaddr_from_iface()
+{
+local iface=$1
+local ipaddr
+
+ipaddr=$(iscsiadm -m iface -I $iface 2 /dev/null | sed -n 
's/iface.ipaddress = \(.*\)/\1/p')
+[ $ipaddr = empty ]  ipaddr=
+
+echo $ipaddr
+}
+
+iscsi_get_ifname_from_firmware()
+{
+local hwaddress
+
+hwaddress=$(iscsiadm -m fw 2 /dev/null | sed -n 's/iface.net_ifacename = 
\(.*\)/\1/p')
+
+echo $hwaddress
+}
+
+#
+# cxgb3i is using the HWAddress to select
+# the correct interface
+#
+iscsi_get_ifname_from_hwaddress()
+{
+local hwaddress=$1
+
+for if in /sys/class/net/*; do
+   [ 

[PATCH 8/8] boot.suse: Update with latest fixes

2011-06-21 Thread Hannes Reinecke
Include latest fixes from SUSE.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 etc/initd/boot.suse |   35 +++
 1 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/etc/initd/boot.suse b/etc/initd/boot.suse
index df64e21..ac6abcc 100644
--- a/etc/initd/boot.suse
+++ b/etc/initd/boot.suse
@@ -4,36 +4,37 @@
 #
 ### BEGIN INIT INFO
 # Provides:  iscsiboot
-# Required-Start:boot.proc
-# Should-Start:
-# Required-Stop: 
+# Required-Start:
+# Should-Start:  boot.multipath
+# Required-Stop:
 # Should-Stop:
 # Default-Start: B
 # Default-Stop:  
-# Short-Description: Starts the iSCSI initiator daemon
-#
+# Short-Description: iSCSI initiator daemon root-fs support
+# Description:   Starts the iSCSI initiator daemon if the
+#root-filesystem is on an iSCSI device
+#   
 ### END INIT INFO
 
 ISCSIADM=/sbin/iscsiadm
-PID_FILE=/var/run/iscsi.pid
 CONFIG_FILE=/etc/iscsid.conf
 DAEMON=/sbin/iscsid
-ARGS=-c $CONFIG_FILE -p $PID_FILE
+ARGS=-c $CONFIG_FILE
 
 # Source LSB init functions
 . /etc/rc.status
 
 #
-# This service is run right after booting. So all activated targets
-# must be enabled during mkinitrd run and thus should not be removed
-# when the open-iscsi service is stopped.
+# This service is run right after booting. So all targets activated
+# during mkinitrd run should not be removed when the open-iscsi
+# service is stopped.
 #
 iscsi_mark_root_nodes()
 {
 $ISCSIADM -m session 2 /dev/null | while read t num i target ; do
ip=${i%%:*}
-   STARTUP=`$ISCSIADM -m node -p $ip -T $target | grep 
node.conn\[0\].startup | cut -d' ' -f3`
-   if [ $STARTUP != onboot ] ; then
+   STARTUP=`$ISCSIADM -m node -p $ip -T $target 2 /dev/null | grep 
node.conn\[0\].startup | cut -d' ' -f3`
+   if [ $STARTUP -a $STARTUP != onboot ] ; then
$ISCSIADM -m node -p $ip -T $target -o update -n 
node.conn[0].startup -v onboot
fi
 done
@@ -50,13 +51,12 @@ fi
 
 case $1 in
 start)
-   [ ! -d /var/lib/open-iscsi ]  mkdir -p /var/lib/open-iscsi
echo -n Starting iSCSI initiator for the root device: 
startproc $DAEMON $ARGS
rc_status -v
iscsi_mark_root_nodes
;;
-stop)
+stop|restart|reload)
rc_failed 0
;;
 status)
@@ -68,13 +68,8 @@ case $1 in
rc_status -v
fi
;;
-restart)
-   $0 stop
-   sleep 1
-   $0 start
-   ;;
 *)
-   echo Usage: $0 {start|stop|status|restart}
+   echo Usage: $0 {start|stop|status|restart|reload}
exit 1
;;
 esac
-- 
1.7.3.4

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 3/4] BNX2I: Changed the nopout_wqe-lun memcpy to use sizeof instead

2011-06-21 Thread Eddie Wai
Modified the memcpy of nopout_wqe-lun to use sizeof(struct scsi_lun)
instead of the hardcoded value 8 as noted by review comments.

Signed-off-by: Eddie Wai eddie@broadcom.com
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 64089e2..d5f3bf6 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -551,7 +551,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 
nopout_wqe-op_code = nopout_hdr-opcode;
nopout_wqe-op_attr = ISCSI_FLAG_CMD_FINAL;
-   memcpy(nopout_wqe-lun, nopout_hdr-lun, 8);
+   memcpy(nopout_wqe-lun, nopout_hdr-lun, sizeof(struct scsi_lun));
 
if (test_bit(BNX2I_NX2_DEV_57710, ep-hba-cnic_dev_type)) {
u32 tmp = nopout_wqe-lun[0];
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 2/4] BNX2I: Modified to skip CNIC registration if iSCSI is not supported

2011-06-21 Thread Eddie Wai
The init routine will now examine the cnic-max_iscsi_conn variable
before registering to CNIC during ulp_init.

Signed-off-by: Eddie Wai eddie@broadcom.com
Acked-by: Michael Chan mc...@broadcom.com
---
 drivers/scsi/bnx2i/bnx2i_init.c |   29 +++--
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 0f7fb14..28bfa9e 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -172,21 +172,14 @@ void bnx2i_start(void *handle)
struct bnx2i_hba *hba = handle;
int i = HZ;
 
-   if (!hba-cnic-max_iscsi_conn) {
-   printk(KERN_ALERT bnx2i: dev %s does not support 
-   iSCSI\n, hba-netdev-name);
+   /*
+* We should never register devices that don't support iSCSI
+* (see bnx2i_init_one), so something is wrong if we try to
+* start a iSCSI adapter on hardware with 0 supported iSCSI
+* connections
+*/
+   BUG_ON(!hba-cnic-max_iscsi_conn);
 
-   if (test_bit(BNX2I_CNIC_REGISTERED, hba-reg_with_cnic)) {
-   mutex_lock(bnx2i_dev_lock);
-   list_del_init(hba-link);
-   adapter_count--;
-   hba-cnic-unregister_device(hba-cnic, CNIC_ULP_ISCSI);
-   clear_bit(BNX2I_CNIC_REGISTERED, hba-reg_with_cnic);
-   mutex_unlock(bnx2i_dev_lock);
-   bnx2i_free_hba(hba);
-   }
-   return;
-   }
bnx2i_send_fw_iscsi_init_msg(hba);
while (!test_bit(ADAPTER_STATE_UP, hba-adapter_state)  i--)
msleep(BNX2I_INIT_POLL_TIME);
@@ -290,6 +283,13 @@ static int bnx2i_init_one(struct bnx2i_hba *hba, struct 
cnic_dev *cnic)
int rc;
 
mutex_lock(bnx2i_dev_lock);
+   if (!cnic-max_iscsi_conn) {
+   printk(KERN_ALERT bnx2i: dev %s does not support 
+   iSCSI\n, hba-netdev-name);
+   rc = -EOPNOTSUPP;
+   goto out;
+   }
+
hba-cnic = cnic;
rc = cnic-register_device(cnic, CNIC_ULP_ISCSI, hba);
if (!rc) {
@@ -307,6 +307,7 @@ static int bnx2i_init_one(struct bnx2i_hba *hba, struct 
cnic_dev *cnic)
else
printk(KERN_ERR bnx2i dev reg, unknown error, %d\n, rc);
 
+out:
mutex_unlock(bnx2i_dev_lock);
 
return rc;
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH 4/4] BNX2I: Updated copyright and bump version

2011-06-21 Thread Eddie Wai
Bumped version from 2.6.2.3 to 2.7.0.3

Signed-off-by: Eddie Wai eddie@broadcom.com
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h   |2 +-
 drivers/scsi/bnx2i/bnx2i.h|2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c|2 +-
 drivers/scsi/bnx2i/bnx2i_init.c   |6 +++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c  |2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c  |2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h 
b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 30e6bdb..aca593d 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h 
b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index dad6c8a..1c39177 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 4e5c002..bb21450 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index d5f3bf6..a031704 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 28bfa9e..4f252a9 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -18,8 +18,8 @@ static struct list_head adapter_list = 
LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAMEbnx2i
-#define DRV_MODULE_VERSION 2.6.2.3
-#define DRV_MODULE_RELDATE Dec 31, 2010
+#define DRV_MODULE_VERSION 2.7.0.3
+#define DRV_MODULE_RELDATE Jun 15, 2011
 
 static char version[] __devinitdata =
Broadcom NetXtreme II iSCSI Driver  DRV_MODULE_NAME \
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index c095c32..f92ec95 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 9174196..83a77f7 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,6 +1,6 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2010 Broadcom Corporation
+ * Copyright (c) 2004 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.



[PATCH] iscsid: Add IEEE DCB support

2011-06-21 Thread Mark Rustad
Add IEEE DCB support. This still has the same limitations as the existing
DCB support, in that it cannot dynamically track priority changes if the
configuration, or even the routing, changes over time, but it provides
equivalent support for systems running with 802.1Qaz as the current DCB
support in iscsid. This should still support CEE when run on kernels that
do not support IEEE.

Signed-off-by: Mark Rustad mark.d.rus...@intel.com
---
 usr/dcb_app.c |  201 +++--
 usr/dcb_app.h |   17 +++--
 usr/dcbnl.h   |  110 ++-
 usr/io.c  |2 -
 4 files changed, 287 insertions(+), 43 deletions(-)

diff --git a/usr/dcb_app.c b/usr/dcb_app.c
index 0131b09..78a5cd1 100644
--- a/usr/dcb_app.c
+++ b/usr/dcb_app.c
@@ -1,7 +1,7 @@
 
/***
 
   DCB application support
-  Copyright(c) 2007-2010 Intel Corporation.
+  Copyright(c) 2007-2011 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -20,8 +20,7 @@
   the file called COPYING.
 
   Contact Information:
-  e1000-eedc Mailing List e1000-e...@lists.sourceforge.net
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+  open-lldp Mailing List lldp-de...@open-lldp.org
 
 
***/
 
@@ -39,7 +38,13 @@
 #include dcb_app.h
 #include sysfs.h
 
-#define NLA_DATA(nla)((void *)((char*)(nla) + NLA_HDRLEN))
+#define IEEE_SMASK_ETHTYPE (1  IEEE_8021QAZ_APP_SEL_ETHERTYPE)
+#define IEEE_SMASK_STREAM  (1  IEEE_8021QAZ_APP_SEL_STREAM)
+#define IEEE_SMASK_DGRAM   (1  IEEE_8021QAZ_APP_SEL_DGRAM)
+#define IEEE_SMASK_ANY (1  IEEE_8021QAZ_APP_SEL_ANY)
+
+#define NLA_DATA(nla)((void *)((char *)(nla) + NLA_HDRLEN))
+#define NLA_NEXT(nla) (struct rtattr *)((char *)nla + 
NLMSG_ALIGN(nla-rta_len))
 
 /* Maximum size of response requested or message sent */
 #define MAX_MSG_SIZE1024
@@ -72,7 +77,7 @@ static struct nlmsghdr *start_dcbmsg(__u16 msg_type, __u8 arg)
 }
 
 static struct rtattr *add_rta(struct nlmsghdr *nlh, __u16 rta_type,
-  void *attr, __u16 rta_len)
+ void *attr, __u16 rta_len)
 {
struct rtattr *rta;
 
@@ -127,14 +132,49 @@ static struct nlmsghdr *dcbnl_get_msg(int nl_sd)
return nlh;
 }
 
-static int get_app_cfg(const char *ifname, __u8 req_idtype, __u16 req_id)
+static int get_dcbx_cap(int nl_sd, const char *ifname)
+{
+   struct nlmsghdr *nlh;
+   struct dcbmsg *d;
+   struct rtattr *rta;
+   int rval;
+
+   nlh = start_dcbmsg(RTM_GETDCB, DCB_CMD_GDCBX);
+   if (!nlh)
+   return -EIO;
+
+   add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
+   rval = dcbnl_send_msg(nl_sd, nlh);
+   free(nlh);
+   if (rval)
+   return -EIO;
+
+   /* Receive DCBX capabilities */
+   nlh = dcbnl_get_msg(nl_sd);
+   if (!nlh)
+   return -EIO;
+
+   d = (struct dcbmsg *)NLMSG_DATA(nlh);
+   rta = (struct rtattr *)(((char *)d) +
+   NLMSG_ALIGN(sizeof(struct dcbmsg)));
+
+   if (d-cmd != DCB_CMD_GDCBX || rta-rta_type != DCB_ATTR_DCBX) {
+   free(nlh);
+   return -EIO;
+   }
+
+   rval = *(__u8 *)NLA_DATA(rta);
+   free(nlh);
+   return rval;
+}
+
+static int get_cee_app_pri(int nl_sd, const char *ifname,
+  __u8 req_idtype, __u16 req_id)
 {
struct nlmsghdr *nlh;
struct dcbmsg *d;
struct rtattr *rta_parent, *rta_child;
int rval = 0;
-   int nl_sd;
-   unsigned int seq;
__u8 idtype;
__u16 id;
 
@@ -142,7 +182,6 @@ static int get_app_cfg(const char *ifname, __u8 req_idtype, 
__u16 req_id)
if (!nlh)
return -EIO;
 
-   seq = nlh-nlmsg_seq;
add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
rta_parent = add_rta(nlh, DCB_ATTR_APP, NULL, 0);
 
@@ -154,19 +193,12 @@ static int get_app_cfg(const char *ifname, __u8 
req_idtype, __u16 req_id)
(void *)req_id, sizeof(__u16));
rta_parent-rta_len += NLA_ALIGN(rta_child-rta_len);
 
-   nl_sd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
-   if (nl_sd  0)
-   return nl_sd;
-
rval = dcbnl_send_msg(nl_sd, nlh);
free(nlh);
-   if (rval) {
-   close(nl_sd);
+   if (rval)
return -EIO;
-   }
 
nlh = dcbnl_get_msg(nl_sd);
-   close(nl_sd);
if (!nlh)
return -EIO;
 
@@ -184,28 +216,100 @@ static int get_app_cfg(const char *ifname, __u8 
req_idtype, __u16 req_id)
}
 
rta_child = NLA_DATA(rta_parent);
-   rta_parent = (struct rtattr 

[PATCH V2] iscsid: Add IEEE DCB support

2011-06-21 Thread Mark Rustad
Add IEEE DCB support. This still has the same limitations as the existing
DCB support, in that it cannot dynamically track priority changes if the
configuration, or even the routing, changes over time, but it provides
equivalent support for systems running with 802.1Qaz as the current DCB
support in iscsid. This should still support CEE when run on kernels that
do not support IEEE.

v2: Add omitted Tested-by credit.

Tested-by: Ross Brattain ross.b.bratt...@intel.com
Signed-off-by: Mark Rustad mark.d.rus...@intel.com
---
 usr/dcb_app.c |  201 +++--
 usr/dcb_app.h |   17 +++--
 usr/dcbnl.h   |  110 ++-
 usr/io.c  |2 -
 4 files changed, 287 insertions(+), 43 deletions(-)

diff --git a/usr/dcb_app.c b/usr/dcb_app.c
index 0131b09..78a5cd1 100644
--- a/usr/dcb_app.c
+++ b/usr/dcb_app.c
@@ -1,7 +1,7 @@
 
/***
 
   DCB application support
-  Copyright(c) 2007-2010 Intel Corporation.
+  Copyright(c) 2007-2011 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -20,8 +20,7 @@
   the file called COPYING.
 
   Contact Information:
-  e1000-eedc Mailing List e1000-e...@lists.sourceforge.net
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+  open-lldp Mailing List lldp-de...@open-lldp.org
 
 
***/
 
@@ -39,7 +38,13 @@
 #include dcb_app.h
 #include sysfs.h
 
-#define NLA_DATA(nla)((void *)((char*)(nla) + NLA_HDRLEN))
+#define IEEE_SMASK_ETHTYPE (1  IEEE_8021QAZ_APP_SEL_ETHERTYPE)
+#define IEEE_SMASK_STREAM  (1  IEEE_8021QAZ_APP_SEL_STREAM)
+#define IEEE_SMASK_DGRAM   (1  IEEE_8021QAZ_APP_SEL_DGRAM)
+#define IEEE_SMASK_ANY (1  IEEE_8021QAZ_APP_SEL_ANY)
+
+#define NLA_DATA(nla)((void *)((char *)(nla) + NLA_HDRLEN))
+#define NLA_NEXT(nla) (struct rtattr *)((char *)nla + 
NLMSG_ALIGN(nla-rta_len))
 
 /* Maximum size of response requested or message sent */
 #define MAX_MSG_SIZE1024
@@ -72,7 +77,7 @@ static struct nlmsghdr *start_dcbmsg(__u16 msg_type, __u8 arg)
 }
 
 static struct rtattr *add_rta(struct nlmsghdr *nlh, __u16 rta_type,
-  void *attr, __u16 rta_len)
+ void *attr, __u16 rta_len)
 {
struct rtattr *rta;
 
@@ -127,14 +132,49 @@ static struct nlmsghdr *dcbnl_get_msg(int nl_sd)
return nlh;
 }
 
-static int get_app_cfg(const char *ifname, __u8 req_idtype, __u16 req_id)
+static int get_dcbx_cap(int nl_sd, const char *ifname)
+{
+   struct nlmsghdr *nlh;
+   struct dcbmsg *d;
+   struct rtattr *rta;
+   int rval;
+
+   nlh = start_dcbmsg(RTM_GETDCB, DCB_CMD_GDCBX);
+   if (!nlh)
+   return -EIO;
+
+   add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
+   rval = dcbnl_send_msg(nl_sd, nlh);
+   free(nlh);
+   if (rval)
+   return -EIO;
+
+   /* Receive DCBX capabilities */
+   nlh = dcbnl_get_msg(nl_sd);
+   if (!nlh)
+   return -EIO;
+
+   d = (struct dcbmsg *)NLMSG_DATA(nlh);
+   rta = (struct rtattr *)(((char *)d) +
+   NLMSG_ALIGN(sizeof(struct dcbmsg)));
+
+   if (d-cmd != DCB_CMD_GDCBX || rta-rta_type != DCB_ATTR_DCBX) {
+   free(nlh);
+   return -EIO;
+   }
+
+   rval = *(__u8 *)NLA_DATA(rta);
+   free(nlh);
+   return rval;
+}
+
+static int get_cee_app_pri(int nl_sd, const char *ifname,
+  __u8 req_idtype, __u16 req_id)
 {
struct nlmsghdr *nlh;
struct dcbmsg *d;
struct rtattr *rta_parent, *rta_child;
int rval = 0;
-   int nl_sd;
-   unsigned int seq;
__u8 idtype;
__u16 id;
 
@@ -142,7 +182,6 @@ static int get_app_cfg(const char *ifname, __u8 req_idtype, 
__u16 req_id)
if (!nlh)
return -EIO;
 
-   seq = nlh-nlmsg_seq;
add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
rta_parent = add_rta(nlh, DCB_ATTR_APP, NULL, 0);
 
@@ -154,19 +193,12 @@ static int get_app_cfg(const char *ifname, __u8 
req_idtype, __u16 req_id)
(void *)req_id, sizeof(__u16));
rta_parent-rta_len += NLA_ALIGN(rta_child-rta_len);
 
-   nl_sd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
-   if (nl_sd  0)
-   return nl_sd;
-
rval = dcbnl_send_msg(nl_sd, nlh);
free(nlh);
-   if (rval) {
-   close(nl_sd);
+   if (rval)
return -EIO;
-   }
 
nlh = dcbnl_get_msg(nl_sd);
-   close(nl_sd);
if (!nlh)
return -EIO;
 
@@ -184,28 +216,100 @@ static int get_app_cfg(const char *ifname, __u8 
req_idtype, __u16 req_id)
}
 

Re: [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion

2011-06-21 Thread Mike Christie
On 06/21/2011 11:49 AM, Eddie Wai wrote:
 This patch breaks the SCSI cmd completion into two parts:
 1. The bh will allocate and queued work to the cmd specific CPU IO
 completion kthread.  The CPU for the cmd is recorded in task_xmit.
 
 2. The CPU specific IO completion kthread will call the scsi_cmd_resp
 routine to do the actual cmd completion.


I think you should use blkio poll. Modify it so it does what you want.
But I think since other drivers are getting in without converting then
that can wait.


  struct bnx2i_cmd {
   struct iscsi_hdr hdr;
 @@ -215,6 +222,7 @@ struct bnx2i_cmd {
   struct io_bdt io_tbl;
   dma_addr_t bd_tbl_dma;
   struct bnx2i_cmd_request req;
 + u32 cpu;


You can just use scsi_cmnd-request-cpu

-- 
You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.