From 173c289a018a039f5bad4842727eb44930f9b38d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roni=20H=C3=A4cki?= Date: Mon, 18 Sep 2017 16:39:03 +0200 Subject: [PATCH] kaluga: starting net_socket server for each of the cards. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For each of driver also start a net_socket server that manages the default queue for a NIC for basic networking. e1000 does not have multiple queues so there is no need to start the driver. Signed-off-by: Roni Häcki --- platforms/Hakefile | 5 +-- usr/kaluga/driver_startup.c | 84 ++++++++++++++++++++++++++---------------- usr/kaluga/main.c | 6 +++- 3 files changed, 59 insertions(+), 36 deletions(-) diff --git a/platforms/Hakefile b/platforms/Hakefile index c51dc9e..1b1c489 100644 --- a/platforms/Hakefile +++ b/platforms/Hakefile @@ -138,8 +138,6 @@ let bin_rcce_lu = [ "/sbin/" ++ f | f <- [ "bulkbench_micro_echo", "bulkbench_micro_rtt", "bulkbench_micro_throughput", - "elb_app", - "elb_app_tcp", "lrpc_bench", "mdb_bench", "mdb_bench_old", @@ -226,7 +224,8 @@ let bin_rcce_lu = [ "/sbin/" ++ f | f <- [ "vnode_map_test", "webserver", "xeon_phi", - "xeon_phi_mgr" + "xeon_phi_mgr", + "net_sockets_server" ]] ++ modules_common -- the following are broken in the newidc system diff --git a/usr/kaluga/driver_startup.c b/usr/kaluga/driver_startup.c index 09a7fcf..deb7981 100644 --- a/usr/kaluga/driver_startup.c +++ b/usr/kaluga/driver_startup.c @@ -49,6 +49,7 @@ errval_t default_start_function(coreid_t where, assert(mi != NULL); errval_t err = SYS_ERR_OK; coreid_t core; + /* * XXX: there may be more device using this driver, so starting it a second time * may be needed. @@ -128,9 +129,9 @@ errval_t start_networking(coreid_t core, assert(driver != NULL); errval_t err = SYS_ERR_OK; - uint64_t vendor_id, device_id, bus, dev, fun; /* check if we are using the supplied pci address of eth0 */ + /* if (eth0.bus != 0xff || eth0.device != 0xff || eth0.function != 0xff) { err = oct_read(record, "_ { bus: %d, device: %d, function: %d, vendor: %d, device_id: %d }", &bus, &dev, &fun, &vendor_id, &device_id); @@ -139,56 +140,75 @@ errval_t start_networking(coreid_t core, if ((eth0.bus != (uint8_t)bus) | (eth0.device != (uint8_t)dev) | (eth0.function != (uint8_t)fun)) { - KALUGA_DEBUG("start_networking: skipping card %" PRIu64 ":%" PRIu64 ":%" - PRIu64"\n", bus, dev, fun); + printf("start_networking: skipping card %" PRIu64 ":%" PRIu64 ":%" + PRIu64"\n", bus, dev, fun); + printf("eth0 %" PRIu8 ":%" PRIu8 ":%" + PRIu8"\n", eth0.bus, eth0.device, eth0.function); return KALUGA_ERR_DRIVER_NOT_AUTO; } } + */ + if (is_started(driver)) { + printf("Already started %s\n", driver->binary); return KALUGA_ERR_DRIVER_ALREADY_STARTED; } if (!is_auto_driver(driver)) { + printf("Not auto %s\n", driver->binary); return KALUGA_ERR_DRIVER_NOT_AUTO; } - struct module_info* netd = find_module("netd"); - if (netd == NULL || !is_auto_driver(netd)) { - printf("Kaluga: netd not found or not declared as auto.\n"); - return KALUGA_ERR_DRIVER_NOT_AUTO; - } - struct module_info* ngd_mng = find_module("NGD_mng"); - if (ngd_mng == NULL || !is_auto_driver(ngd_mng)) { - printf("Kaluga: NGD_mng not found or not declared as auto.\n"); - return KALUGA_ERR_DRIVER_NOT_AUTO; - } + if (!(strcmp(driver->binary, "net_sockets_server") == 0)) { + + err = default_start_function(core, driver, record, arg); + if (err_is_fail(err)) { + DEBUG_ERR(err, "Spawning %s failed.", driver->path); + return err; + } - err = default_start_function(core, driver, record, arg); - if (err_is_fail(err)) { - DEBUG_ERR(err, "Spawning %s failed.", driver->path); - return err; - } + // cards with driver in seperate process + struct module_info* net_sockets = find_module("net_sockets_server"); + if (net_sockets == NULL) { + printf("Net sockets server not found\n"); + return KALUGA_ERR_DRIVER_NOT_AUTO; + } - // XXX: Manually add cardname (overwrite first (auto) argument) - // +Weird convention, e1000n binary but cardname=e1000 - char* cardname = strcmp(driver->binary, "e1000n") == 0 ? "e1000" : driver->binary; + uint64_t vendor_id, device_id, bus, dev, fun; + err = oct_read(record, "_ { bus: %d, device: %d, function: %d, vendor: %d, device_id: %d }", + &bus, &dev, &fun, &vendor_id, &device_id); - size_t name_len = strlen("cardname=") + strlen(cardname) + 1; - char* card_argument = malloc(name_len); - sprintf(card_argument, "cardname=%s", cardname); - printf("############# starting network with arguments %s\n", card_argument); + char* pci_arg_str = malloc(26); + snprintf(pci_arg_str, 26, "%04"PRIx64":%04"PRIx64":%04"PRIx64":%04" + PRIx64":%04"PRIx64, vendor_id, device_id, bus, dev, fun); - // Spawn netd and ngd_mng - netd->argv[0] = card_argument; - err = spawn_program(core, netd->path, netd->argv, environ, 0, get_did_ptr(netd)); + // Spawn net_sockets_server + net_sockets->argv[0] = "net_sockets_server"; + net_sockets->argv[1] = "auto"; + net_sockets->argv[2] = driver->binary; + net_sockets->argv[3] = pci_arg_str; + + err = spawn_program(core, net_sockets->path, net_sockets->argv, environ, 0, + get_did_ptr(net_sockets)); + free (pci_arg_str); + } else { + // TODO currently only for e1000, might be other cards that + // start the driver by creating a queue + for (int i = 0; i < driver->argc; i++) { + printf("argv[%d]=%s \n", i, driver->argv[i]); + } + + if (!(driver->argc > 2)) { + driver->argv[driver->argc] = "e1000"; + driver->argc++; + } - ngd_mng->argv[0] = card_argument; - err = spawn_program(core, ngd_mng->path, ngd_mng->argv, environ, 0, - get_did_ptr(ngd_mng)); + // All cards that start the driver by creating a device queue + err = default_start_function(core, driver, record, arg); + } - free(card_argument); return err; } diff --git a/usr/kaluga/main.c b/usr/kaluga/main.c index f03d3bf..b8cb215 100644 --- a/usr/kaluga/main.c +++ b/usr/kaluga/main.c @@ -46,7 +46,10 @@ size_t cpu_count = 0; static void add_start_function_overrides(void) { - set_start_function("e1000n", start_networking); + + set_start_function("e10k", start_networking); + set_start_function("net_sockets_server", start_networking); + set_start_function("sfn5122f", start_networking); set_start_function("rtl8029", start_networking); set_start_function("corectrl", start_boot_driver); #ifdef __ARM_ARCH_7A__ @@ -110,6 +113,7 @@ int main(int argc, char** argv) if (err_is_fail(err)) { USER_PANIC_ERR(err, "Parse boot modules."); } + add_start_function_overrides(); err = arch_startup(add_device_db_file); -- 1.7.2.5