コード例 #1
0
static void
ind_cxn_cfg_commit(void)
{
    aim_log_t *lobj;
    int i;

    if ((lobj = aim_log_find("ofconnectionmanager")) == NULL) {
        AIM_LOG_WARN("Could not find log module");
    } else {
        lobj->common_flags = staged_config.log_flags;
    }

    for (i = 0; i < staged_config.num_controllers; i++) {
        struct controller *c = &staged_config.controllers[i];
        const struct controller *old_controller;
        int rv;
        indigo_cxn_params_tcp_over_ipv4_t *proto = &c->proto.tcp_over_ipv4;
        AIM_LOG_INFO("controller %d: %s:%hu", i,
                     proto->controller_ip, proto->controller_port);

        /* Keep existing connections to the same controller. */
        if ((old_controller = find_controller(&current_config, &c->proto))) {
            c->cxn_id = old_controller->cxn_id;
            /* TODO apply keepalive_period to existing connection. */
            continue;
        }

        rv = indigo_cxn_connection_add(&c->proto, &c->config, &c->cxn_id);
        if (rv != 0) {
            AIM_LOG_ERROR("failed to add controller connection %d: %s:%u",
                          i, proto->controller_ip, proto->controller_port);
        }
    }

    /* Remove connections that don't exist in the new configuration. */
    for (i = 0; i < current_config.num_controllers; i++) {
        const struct controller *c = &current_config.controllers[i];
        if (!find_controller(&staged_config, &c->proto)) {
            (void) indigo_cxn_connection_remove(c->cxn_id);
        }
    }

    /* Save config so we can diff the controllers next time */
    current_config = staged_config;
}
コード例 #2
0
ファイル: skelvme.c プロジェクト: GSI-CS-CO/kernel_modules
static void *do_vme_mapping(InsLibVmeAddressSpace * v,
			    struct pdparam_master *pm)
{
	unsigned long map;
/*
 * linux' implementation of find_controller() needs a proper datawidth.
 * Note that it doesn't do a test access to the module.
 */

	unsigned long datawidth = v->DataWidth / 8;

	map =
	    find_controller(v->BaseAddress, v->WindowSize,
			    v->AddressModifier, 0, datawidth, pm);
	return (void *) map;
}
コード例 #3
0
ファイル: testctr_ces.c プロジェクト: bradomyn/coht
int main(int argc, char **argv)
{
	struct pdparam_master param;
	struct vme_mapping *desc;
	unsigned int *vme_buf;
	int i;
	unsigned int val;
	unsigned int saved;

	memset(&param, 0, sizeof(struct pdparam_master));

	if ((vme_buf = (unsigned int *)find_controller(MODULE_VME_ADDR,
						       MODULE_VME_SIZE,
						       MODULE_AM, 0, 4,
						       &param)) == 0) {
		printf("Failed to find_controller: %s\n", strerror(errno));
		exit(1);
	}

	printf("find_controller mmap'ed at %p\n\n", vme_buf);

	desc = (struct vme_mapping *)param.sgmin;

	/* Now test read access */
	for (i = 1; i <= 5; i++) {
		val = swapbe32(vme_buf[i]);

		printf("%x:  0x%08x\n", MODULE_VME_ADDR + i*4, val);
	}

	/* Check for a bus error */
	if (vme_bus_error_check(desc))
		printf("Bus error occured\n");

	/* Test a write access */
	printf("\n");
	saved = swapbe32(vme_buf[1]);
	printf("Read 0x%08x at 0x%08x\n", saved, MODULE_VME_ADDR + 4);

	/* Check for a bus error */
	if (vme_bus_error_check(desc))
		printf("Bus error occured\n");

	printf("\n");

	printf("Writing 0x55aa55aa at address %x\n", MODULE_VME_ADDR + 4);
	vme_buf[1] = swapbe32(0x55aa55aa);
	fsync(desc->fd);

	/* Check for a bus error */
	if (vme_bus_error_check(desc))
		printf("Bus error occured\n");

	val = swapbe32(vme_buf[1]);

	/* Check for a bus error */
	if (vme_bus_error_check(desc))
		printf("Bus error occured\n");

	printf("Read back 0x%08x at address %x\n", val, MODULE_VME_ADDR + 4);
/*
	vme_buf[1] = swapbe32(saved);

	if (vme_bus_error_check(desc))
		printf("Bus error occured\n");
*/
	printf("\n");

	if (return_controller(desc))
		printf("Failed to return_controler: %s\n", strerror(errno));


	return 0;
}
コード例 #4
0
static void
ind_cxn_cfg_commit(void)
{
    aim_log_t *lobj;
    int i, enable;

    if (staged_config.valid != true)
        return;

    /* Commit config only if connection manager is enabled. */
    (void) ind_cxn_enable_get(&enable);
    if (!enable)
        return;

    if ((lobj = aim_log_find("ofconnectionmanager")) == NULL) {
        AIM_LOG_WARN("Could not find log module");
    } else {
        lobj->common_flags = staged_config.log_flags;
    }

    /* configure TLS before parsing controller configs */
    (void) indigo_cxn_config_tls(staged_config.cipher_list,
                                 staged_config.ca_cert,
                                 staged_config.switch_cert,
                                 staged_config.switch_priv_key,
                                 staged_config.exp_controller_suffix);

    for (i = 0; i < staged_config.num_controllers; i++) {
        struct controller *c = &staged_config.controllers[i];
        const struct controller *old_controller;
        int rv;
        char desc[256];

        ind_cxn_proto_ip_string(&c->proto, desc, sizeof(desc));
        AIM_LOG_INFO("controller %d: %s", i, desc);

        /* Keep existing connections to the same controller. */
        if ((old_controller = find_controller(&current_config, &c->proto))) {
            c->controller_id = old_controller->controller_id;
            /* TODO apply keepalive_period to existing connection. */
            continue;
        }

        rv = indigo_controller_add(&c->proto, &c->config, &c->controller_id);
        if (rv != 0) {
            AIM_LOG_ERROR("failed to add controller connection %d: %s",
                          i, desc);
        }
    }

    /* Remove controller's that don't exist in the new configuration. */
    for (i = 0; i < current_config.num_controllers; i++) {
        const struct controller *c = &current_config.controllers[i];
        if (!find_controller(&staged_config, &c->proto)) {
            (void) indigo_controller_remove(c->controller_id);
        }
    }

    /* Save config so we can diff the controllers next time */
    current_config = staged_config;
    staged_config.valid = false;
}
コード例 #5
0
ファイル: findevs.c プロジェクト: jasonbking/illumos-gate
static controller_t *
add_controller(struct search_args *args, di_node_t node, di_minor_t minor)
{
	char		*devpath;
	controller_t	*cp;
	char		kstat_name[MAXPATHLEN];
	char		*c_type = DM_CTYPE_UNKNOWN;

	devpath = di_devfs_path(node);

	if ((cp = find_controller(args, devpath)) != NULL) {
		di_devfs_path_free((void *) devpath);
		return (cp);
	}

	/* Special handling for fp attachment node. */
	if (strcmp(di_node_name(node), "fp") == 0) {
		di_node_t pnode;

		pnode = di_parent_node(node);
		if (pnode != DI_NODE_NIL) {
			di_devfs_path_free((void *) devpath);
			devpath = di_devfs_path(pnode);

			if ((cp = find_controller(args, devpath)) != NULL) {
				di_devfs_path_free((void *) devpath);
				return (cp);
			}

			/* not in the list, create it */
			node = pnode;
			c_type = DM_CTYPE_FIBRE;
		}
	}

	if (dm_debug) {
		(void) fprintf(stderr, "INFO: add_controller %s\n", devpath);
	}

	cp = (controller_t *)calloc(1, sizeof (controller_t));
	if (cp == NULL) {
		return (NULL);
	}

	cp->name = strdup(devpath);
	di_devfs_path_free((void *) devpath);
	if (cp->name == NULL) {
		cache_free_controller(cp);
		return (NULL);
	}

	if (strcmp(c_type, DM_CTYPE_UNKNOWN) == 0) {
		c_type = ctype(node, minor);
	}
	cp->ctype = c_type;

	(void) snprintf(kstat_name, sizeof (kstat_name), "%s%d",
	    di_node_name(node), di_instance(node));

	if ((cp->kstat_name = strdup(kstat_name)) == NULL) {
		cache_free_controller(cp);
		return (NULL);
	}

	if (libdiskmgt_str_eq(cp->ctype, "scsi")) {
		cp->scsi_options = get_prop(SCSI_OPTIONS_PROP, node);
	}

	if (libdiskmgt_str_eq(di_node_name(node), "scsi_vhci")) {
		cp->multiplex = 1;
	} else {
		cp->multiplex = 0;
	}

	cp->freq = get_prom_int("clock-frequency", node, args->ph);

	cp->disks = (disk_t **)calloc(1, sizeof (disk_t *));
	if (cp->disks == NULL) {
		cache_free_controller(cp);
		return (NULL);
	}
	cp->disks[0] = NULL;

	cp->next = args->controller_listp;
	args->controller_listp = cp;

	cp->bus = add_bus(args, di_parent_node(node),
	    di_minor_next(di_parent_node(node), NULL), cp);

	return (cp);
}