diff options
author | Lee Duncan <leeman.duncan@gmail.com> | 2017-08-30 14:46:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-30 14:46:51 -0700 |
commit | 49b271a0efb92c872d1b0d9a0862f2cccc66a32f (patch) | |
tree | 44b18b341f7f084bd3298043310d5618dcbb420d | |
parent | d656174595d31ee4d8b41502efd336520ffc5f2d (diff) | |
parent | 06851794fe0475410f516e874ee0c67db4a6784a (diff) | |
download | open-iscsi-49b271a0efb92c872d1b0d9a0862f2cccc66a32f.tar.gz |
Merge pull request #55 from apatters/bnx2-software-ibft-support
Add bnx2{,x} software initiator IBFT support
-rw-r--r-- | include/iscsi_net_util.h | 1 | ||||
-rw-r--r-- | iscsiuio/docs/iscsiuio.8 | 10 | ||||
-rw-r--r-- | iscsiuio/src/unix/main.c | 12 | ||||
-rw-r--r-- | usr/iscsi_net_util.c | 17 | ||||
-rw-r--r-- | utils/fwparam_ibft/fw_entry.c | 60 |
5 files changed, 66 insertions, 34 deletions
diff --git a/include/iscsi_net_util.h b/include/iscsi_net_util.h index cbf3637..16d48e3 100644 --- a/include/iscsi_net_util.h +++ b/include/iscsi_net_util.h @@ -2,6 +2,7 @@ #define __ISCSI_NET_UTIL_h__ #define ISCSI_HWADDRESS_BUF_SIZE 18 +#define ISCSIUIO_PATH "/sbin/iscsiuio" extern int net_get_transport_name_from_netdev(char *netdev, char *transport); extern int net_get_netdev_from_hwaddress(char *hwaddress, char *netdev); diff --git a/iscsiuio/docs/iscsiuio.8 b/iscsiuio/docs/iscsiuio.8 index 8b0577a..eda20c7 100644 --- a/iscsiuio/docs/iscsiuio.8 +++ b/iscsiuio/docs/iscsiuio.8 @@ -45,7 +45,7 @@ on how to configure network protocol and address. .SH PARAMETERS There are very few parameters when running this application. .TP -.BI -d <debug level> +.BI -d|--debug <debug level> This is to enable debug mode where debug messages will be sent to stdout The following debug modes are supported .P @@ -61,20 +61,20 @@ ERROR 1 - Only print critical errors .PP .TP .TP -.BI -f +.BI -f|--foreground This is to enable foreground mode so that this application doesn't get sent into the background. .PP .TP -.BI -v +.BI -v|--version This is to print the version. .PP .TP -.BI -p <pidfile> +.BI -p|--pid <pidfile> Use pidfile (default /var/run/iscsiuio.pid ) .PP .TP -.BI -h +.BI -h|--help Display this help and exit. diff --git a/iscsiuio/src/unix/main.c b/iscsiuio/src/unix/main.c index c1a72d8..5cccc76 100644 --- a/iscsiuio/src/unix/main.c +++ b/iscsiuio/src/unix/main.c @@ -82,10 +82,12 @@ static const char default_pid_filepath[] = "/var/run/iscsiuio.pid"; * Global Variables ******************************************************************************/ static const struct option long_options[] = { - {"debug", 0, 0, 0}, - {"version", 0, 0, 0}, - {"help", 0, 0, 0}, - {0, 0, 0, 0} + {"foreground", no_argument, NULL, 'f'}, + {"debug", required_argument, NULL, 'd'}, + {"pid", required_argument, NULL, 'p'}, + {"version", no_argument, NULL, 'v'}, + {"help", no_argument, NULL, 'h'}, + {NULL, no_argument, NULL, 0} }; struct options opt = { @@ -172,7 +174,7 @@ static void main_usage() printf("iscsiuio daemon.\n" "-f, --foreground make the program run in the foreground\n" "-d, --debug debuglevel print debugging information\n" - "-p, --pid=pidfile use pid file (default %s).\n" + "-p, --pid pidfile use pid file (default %s).\n" "-h, --help display this help and exit\n" "-v, --version display version and exit\n", default_pid_filepath); diff --git a/usr/iscsi_net_util.c b/usr/iscsi_net_util.c index 06df9b3..6339082 100644 --- a/usr/iscsi_net_util.c +++ b/usr/iscsi_net_util.c @@ -25,6 +25,7 @@ #include <net/route.h> #include <sys/types.h> #include <sys/socket.h> +#include <sys/stat.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <linux/sockios.h> @@ -81,6 +82,22 @@ int net_get_transport_name_from_netdev(char *netdev, char *transport) goto close_sock; } + /* + * iSCSI hardware offload for bnx2{,x} is only supported if the + * iscsiuio executable is available. + */ + if (!strcmp(drvinfo.driver, "bnx2x") || + !strcmp(drvinfo.driver, "bnx2")) { + struct stat buf; + + if (stat(ISCSIUIO_PATH, &buf)) { + log_debug(1, "ISCSI offload not supported " + "(%s not found).", ISCSIUIO_PATH); + err = ENODEV; + goto close_sock; + } + } + for (i = 0; net_drivers[i].net_drv_name != NULL; i++) { struct iscsi_net_driver *net_driver = &net_drivers[i]; diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c index 0a1b46b..42d1a55 100644 --- a/utils/fwparam_ibft/fw_entry.c +++ b/utils/fwparam_ibft/fw_entry.c @@ -64,26 +64,40 @@ int fw_setup_nics(void) * For each target in iBFT bring up required NIC and use routing * to force iSCSI traffic through correct NIC */ - list_for_each_entry(context, &targets, list) { - /* if it is a offload nic ignore it */ - if (!net_get_transport_name_from_netdev(context->iface, - transport)) - continue; - + list_for_each_entry(context, &targets, list) { if (iface_prev == NULL || strcmp(context->iface, iface_prev)) { - /* Note: test above works because there is a - * maximum of two targets in the iBFT - */ - iface_prev = context->iface; - needs_bringup = 1; + /* Note: test above works because there is a + * maximum of two targets in the iBFT + */ + iface_prev = context->iface; + needs_bringup = 1; + } + if (net_get_transport_name_from_netdev(context->iface, transport)) { + /* Setup software NIC, */ + printf("Setting up software interface %s\n", context->iface); + err = net_setup_netdev(context->iface, context->ipaddr, + context->mask, context->gateway, + context->vlan, + context->target_ipaddr, needs_bringup); + if (err) { + printf("Setting up software interface %s failed\n", + context->iface); + ret = err; + } + } else { + /* Setup offload NIC. */ + struct iface_rec iface; + + memset(&iface, 0, sizeof(iface)); + iface_setup_defaults(&iface); + printf("Setting up offload interface %s\n", context->iface); + if (!iface_setup_from_boot_context(&iface, context)) { + printf("Setting up offload interface %s failed\n", + context->iface); + + ret = ISCSI_ERR; + } } - - err = net_setup_netdev(context->iface, context->ipaddr, - context->mask, context->gateway, - context->vlan, - context->target_ipaddr, needs_bringup); - if (err) - ret = err; } fw_free_targets(&targets); @@ -147,11 +161,7 @@ void fw_free_targets(struct list_head *list) static void dump_initiator(struct boot_context *context) { - struct iface_rec iface; - - memset(&iface, 0, sizeof(iface)); - iface_setup_defaults(&iface); - iface_setup_from_boot_context(&iface, context); + char transport_name[ISCSI_TRANSPORT_NAME_MAXLEN]; if (strlen(context->initiatorname)) printf("%s = %s\n", IFACE_INAME, context->initiatorname); @@ -159,7 +169,9 @@ static void dump_initiator(struct boot_context *context) if (strlen(context->isid)) printf("%s = %s\n", IFACE_ISID, context->isid); - printf("%s = %s\n", IFACE_TRANSPORTNAME, iface.transport_name); + memset(transport_name, 0, ISCSI_TRANSPORT_NAME_MAXLEN); + if (!net_get_transport_name_from_netdev(context->iface, transport_name)) + printf("%s = %s\n", IFACE_TRANSPORTNAME, transport_name); } static void dump_target(struct boot_context *context) |