Add support for creating FCoE sessions with /sys/bus/fcoe
interfaces.

Signed-off-by: Robert Love <[email protected]>
Tested-by: Marcus Dennis <[email protected]>
---
 fipvlan.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/fipvlan.c b/fipvlan.c
index 80e4190..882ebbc 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -78,6 +78,8 @@ struct {
        .suffix = "",
 };
 
+int (*fcoe_instance_start)(const char *ifname);
+
 char *exe;
 
 static struct pollfd *pfd = NULL;
@@ -549,13 +551,13 @@ void create_missing_vlans()
        printf("\n");
 }
 
-int fcoe_instance_start(char *ifname)
+int fcoe_mod_instance_start(const char *ifname)
 {
        enum fcoe_status ret = EFAIL;
 
        ret = fcm_write_str_to_sysfs_file(FCOE_CREATE, ifname);
        if (ret) {
-               FIP_LOG_ERRNO("Failed to open file:%s", FCOE_CREATE);
+               FIP_LOG_ERRNO("Failed to open file: %s", FCOE_CREATE);
                FIP_LOG_ERRNO("May be fcoe stack not loaded, starting"
                              " fcoe service will fix that");
 
@@ -565,6 +567,48 @@ int fcoe_instance_start(char *ifname)
        return 0;
 }
 
+int fcoe_bus_instance_start(const char *ifname)
+{
+       enum fcoe_status ret = EFAIL;
+       char fchost[FCHOSTBUFLEN];
+       char ctlr[FCHOSTBUFLEN];
+
+       ret = fcm_write_str_to_sysfs_file(FCOE_BUS_CREATE, ifname);
+       if (ret) {
+               FIP_LOG_ERRNO("Failed to open file: %s", FCOE_BUS_CREATE);
+               FIP_LOG_ERRNO("May be fcoe stack not loaded, starting"
+                             " fcoe service will fix that");
+               return ret;
+       }
+
+       if (fcoe_find_fchost(ifname, fchost, FCHOSTBUFLEN)) {
+               FIP_LOG_DBG("Failed to find fc_host for %s\n", ifname);
+               return ENOSYSFS;
+       }
+
+       if (fcoe_find_ctlr(fchost, ctlr, FCHOSTBUFLEN)) {
+               FIP_LOG_DBG("Failed to get ctlr for %s\n", ifname);
+               return ENOSYSFS;
+       }
+
+       ret = fcm_write_str_to_ctlr_attr(ctlr, FCOE_CTLR_ATTR_ENABLED, "1");
+       if (ret)
+               FIP_LOG_DBG("Failed to enable interface %s\n", ifname);
+
+       return 0;
+}
+
+void determine_libfcoe_interface()
+{
+       if (!access(FCOE_BUS_CREATE, F_OK)) {
+               FIP_LOG_DBG("Using /sys/bus/fcoe interfaces\n");
+               fcoe_instance_start = &fcoe_bus_instance_start;
+       } else {
+               FIP_LOG_DBG("Using libfcoe module parameter interfaces\n");
+               fcoe_instance_start = &fcoe_mod_instance_start;
+       }
+}
+
 void start_fcoe()
 {
        struct fcf *fcf;
@@ -836,6 +880,8 @@ int main(int argc, char **argv)
        }
        pfd_add(ns);
 
+       determine_libfcoe_interface();
+
        find_interfaces(ns);
        while ((TAILQ_EMPTY(&interfaces)) && ++find_cnt < 5) {
                FIP_LOG_DBG("no interfaces found, trying again");

_______________________________________________
fcoe-devel mailing list
[email protected]
http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel

Reply via email to