aboutsummaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorThomas Huth <thuth@linux.vnet.ibm.com>2011-11-15 10:55:13 +0100
committerThomas Huth <thuth@linux.vnet.ibm.com>2011-12-20 17:56:48 +0100
commit59cc316596b2a92e89323694ac88a20daba81b30 (patch)
tree22384837d7d2fe382083d28cbd2208a8b9d97f8b /clients
parent58175836650e6faccb3559fa354b9f2bd504c491 (diff)
downloadSLOF-59cc316596b2a92e89323694ac88a20daba81b30.zip
SLOF-59cc316596b2a92e89323694ac88a20daba81b30.tar.gz
SLOF-59cc316596b2a92e89323694ac88a20daba81b30.tar.bz2
Added net-snk client-interface module
So far the net-snk could only use networking cards that had corresponding drivers in the ROM filesystem. NICs that come with their of FCODE drivers were not supported yet. For these NICs I added now a pseudo-module to the net-snk that is able to use the corresponding device tree nodes via the "read" and "write" functions of the client interface. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'clients')
-rw-r--r--clients/net-snk/include/of.h3
-rw-r--r--clients/net-snk/kernel/modules.c12
-rw-r--r--clients/net-snk/oflib/Makefile2
-rw-r--r--clients/net-snk/oflib/ci_device.c124
4 files changed, 138 insertions, 3 deletions
diff --git a/clients/net-snk/include/of.h b/clients/net-snk/include/of.h
index 04d3ae8..b615297 100644
--- a/clients/net-snk/include/of.h
+++ b/clients/net-snk/include/of.h
@@ -36,7 +36,8 @@ phandle_t of_child (phandle_t);
phandle_t of_parent (phandle_t);
int of_getprop (phandle_t, const char *, void *, int);
void * of_call_method_3 (const char *, ihandle_t, int);
-
+int of_test(const char *name);
+int of_interpret_1(void *s, void *ret);
ihandle_t of_open (const char *);
void of_close(ihandle_t);
diff --git a/clients/net-snk/kernel/modules.c b/clients/net-snk/kernel/modules.c
index e06bb9f..a719f27 100644
--- a/clients/net-snk/kernel/modules.c
+++ b/clients/net-snk/kernel/modules.c
@@ -21,7 +21,9 @@
#include <pci.h>
#include "modules.h"
-extern snk_module_t of_module;
+snk_module_t * cimod_check_and_install(void);
+
+extern snk_module_t of_module, ci_module;
extern char __client_start[];
@@ -140,6 +142,14 @@ modules_init(void)
for(i=0; modules[i].name; ++i) {
load_module(modules[i].name);
}
+
+ /* Try to init client-interface module (it's built-in, not loadable) */
+ for(i=0; i<MODULES_MAX; ++i) {
+ if(snk_modules[i] == 0) {
+ snk_modules[i] = cimod_check_and_install();
+ break;
+ }
+ }
}
void
diff --git a/clients/net-snk/oflib/Makefile b/clients/net-snk/oflib/Makefile
index aad3e89..58c2fd8 100644
--- a/clients/net-snk/oflib/Makefile
+++ b/clients/net-snk/oflib/Makefile
@@ -17,7 +17,7 @@ ifndef TOP
endif
include $(TOP)/make.rules
-OBJS = rtas.o of.o pci.o
+OBJS = rtas.o of.o pci.o ci_device.o
OBJS2 = entry.o
all: oflib.o
diff --git a/clients/net-snk/oflib/ci_device.c b/clients/net-snk/oflib/ci_device.c
new file mode 100644
index 0000000..ef47c22
--- /dev/null
+++ b/clients/net-snk/oflib/ci_device.c
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * Copyright (c) 2011 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+/*
+ * A pseudo-module that uses the the "write" and "read" functions via the
+ * client interface to handle the given device.
+ * Normally the net-snk uses the various net_xxx modules from the romfs to
+ * drive the network cards. However, in case we do not have a net-snk driver
+ * for the given card and it has been initialized via FCODE instead, we've
+ * got to use the Open Firmware Client Interface "write" and "read" functions
+ * to talk to the NIC. This is achieved via this pseudo-module here.
+ */
+
+#include <of.h>
+#include <string.h>
+#include <netdriver_int.h>
+#include <fileio.h>
+#include <stdint.h>
+#include <kernel.h>
+
+#define DEBUG 0
+#if DEBUG
+#define dprintf(str, ...) snk_kernel_interface.print(str, ## __VA_ARGS__)
+#else
+#define dprintf(str, ...) do{}while(0)
+#endif
+
+extern snk_kernel_t snk_kernel_interface;
+
+static int cimod_init(void);
+static int cimod_term(void);
+static int cimod_read(char *buffer, int len);
+static int cimod_write(char *buffer, int len);
+static int cimod_ioctl(int request, void *data);
+
+snk_module_t ci_module = {
+ .version = 1,
+ .type = MOD_TYPE_NETWORK,
+ .running = 0,
+ .link_addr = (char*) 1,
+ .init = cimod_init,
+ .term = cimod_term,
+ .write = cimod_write,
+ .read = cimod_read,
+ .ioctl = cimod_ioctl
+};
+
+static ihandle_t myself;
+
+
+snk_module_t *
+cimod_check_and_install(void)
+{
+ uint8_t tmpbuf[8];
+
+ dprintf("entered cimod_check_and_install!\n");
+
+ myself = of_interpret_1("my-parent", tmpbuf);
+ dprintf("cimod: myself=%lx\n", myself);
+
+ /* Check whether "read" and "write" functions are provided by the
+ * device tree node: */
+ if (of_read(myself, tmpbuf, 0) == -1
+ || of_write(myself, tmpbuf, 0) == -1) {
+ dprintf("cimod: missing read or write!\n");
+ return NULL;
+ }
+
+ return &ci_module;
+}
+
+static int
+cimod_init(void)
+{
+ ci_module.running = 1;
+ snk_kernel_interface.print("client-interface module initialized!\n");
+ return 0;
+}
+
+static int
+cimod_term(void)
+{
+ ci_module.running = 0;
+ dprintf("cimod term called!\n");
+ return 0;
+}
+
+static int
+cimod_read(char *buffer, int len)
+{
+ int ret;
+
+ ret = of_read(myself, buffer, len);
+ dprintf("cimod read returned: %i!\n", ret);
+
+ return ret;
+}
+
+static int
+cimod_write(char *buffer, int len)
+{
+ int ret;
+
+ ret = of_write(myself, buffer, len);
+ dprintf("cimod write returned: %i!\n", ret);
+
+ return ret;
+}
+
+static int
+cimod_ioctl(int request, void *data)
+{
+ dprintf("cimod ioctl called!\n");
+
+ return 0;
+}