The libfcoe module parameter interface for create, destroy, enable and disable
are being deprecated. The first step is to generalize and abstract the legacy
interface by making calls to it through a function template. The next patch in
this series will add a new template implemenation with calls to the new 
fcoe_sysfs
based interface.

Signed-off-by: Robert Love <robert.w.l...@intel.com>
---
 fcoemon.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/fcoemon.c b/fcoemon.c
index 0ec3afb..1d00e73 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -156,6 +156,46 @@ static void fcm_fcoe_action(struct fcm_netif *, struct 
fcoe_port *);
 static void fcp_set_next_action(struct fcoe_port *, enum fcp_action);
 static enum fcoe_status fcm_fcoe_if_action(char *, char *);
 
+/*
+ * Used for backwards compatibility amongst libfcoe
+ * "control" interfaces.
+ */
+struct libfcoe_interface_template {
+       int (*create)(struct fcm_netif *, struct fcoe_port *);
+       int (*destroy)(struct fcm_netif *, struct fcoe_port *);
+       int (*enable)(struct fcm_netif *, struct fcoe_port *);
+       int (*disable)(struct fcm_netif *, struct fcoe_port *);
+};
+
+const struct libfcoe_interface_template *libfcoe_control;
+
+static int fcm_module_create(struct fcm_netif *ff, struct fcoe_port *p)
+{
+       return fcm_fcoe_if_action(FCOE_CREATE, p->ifname);
+}
+
+static int fcm_module_destroy(struct fcm_netif *ff, struct fcoe_port *p)
+{
+       return fcm_fcoe_if_action(FCOE_DESTROY, p->ifname);
+}
+
+static int fcm_module_enable(struct fcm_netif *ff, struct fcoe_port *p)
+{
+       return fcm_fcoe_if_action(FCOE_ENABLE, p->ifname);
+}
+
+static int fcm_module_disable(struct fcm_netif *ff, struct fcoe_port *p)
+{
+       return fcm_fcoe_if_action(FCOE_DISABLE, p->ifname);
+}
+
+static struct libfcoe_interface_template libfcoe_module_tmpl = {
+       .create = fcm_module_create,
+       .destroy = fcm_module_destroy,
+       .enable = fcm_module_enable,
+       .disable = fcm_module_disable,
+};
+
 struct fcm_clif {
        int cl_fd;
        int cl_busy;            /* non-zero if command pending */
@@ -1615,6 +1655,8 @@ static void fcm_fcoe_init(void)
 {
        if (fcm_read_config_files())
                exit(1);
+
+       libfcoe_control = &libfcoe_module_tmpl;
 }
 
 /*
@@ -2587,7 +2629,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct 
fcoe_port *p)
        switch (p->action) {
        case FCP_CREATE_IF:
                FCM_LOG_DBG("OP: CREATE %s\n", p->ifname);
-               rc = fcm_fcoe_if_action(FCOE_CREATE, ifname);
+               rc = libfcoe_control->create(ff, p);
                /*
                 * This call validates that the interface name
                 * has an active fcoe session by checking for
@@ -2616,12 +2658,12 @@ static void fcm_fcoe_action(struct fcm_netif *ff, 
struct fcoe_port *p)
                        rc = SUCCESS;
                        break;
                }
-               rc = fcm_fcoe_if_action(FCOE_DESTROY, ifname);
+               rc = libfcoe_control->destroy(ff, p);
                p->fchost[0] = '\0';
                break;
        case FCP_ENABLE_IF:
                FCM_LOG_DBG("OP: ENABLE %s\n", p->ifname);
-               rc = fcm_fcoe_if_action(FCOE_ENABLE, ifname);
+               rc = libfcoe_control->enable(ff, p);
                break;
        case FCP_DISABLE_IF:
                FCM_LOG_DBG("OP: DISABLE %s\n", p->ifname);
@@ -2637,7 +2679,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct 
fcoe_port *p)
                        }
                        break;
                }
-               rc = fcm_fcoe_if_action(FCOE_DISABLE, ifname);
+               rc = libfcoe_control->disable(ff, p);
                break;
        case FCP_RESET_IF:
                FCM_LOG_DBG("OP: RESET %s\n", p->ifname);

_______________________________________________
devel mailing list
devel@open-fcoe.org
https://lists.open-fcoe.org/mailman/listinfo/devel

Reply via email to