Exemple #1
0
/* the routine to dump routing table
 *
 * @route:
 */
static
void _vroute_dump(struct vroute* route)
{
    struct vroute_node_space* node_space = &route->node_space;
    struct vroute_srvc_space* srvc_space = &route->srvc_space;
    vassert(route);

    vdump(printf("-> ROUTE"));
    vlock_enter(&route->lock);
    node_space->ops->dump(node_space);
    srvc_space->ops->dump(srvc_space);
    vlock_leave(&route->lock);
    vdump(printf("<- ROUTE"));
    return;
}
Exemple #2
0
int main(int argc, char **argv)
{
	vme_bus_handle_t bus_handle;
	vme_master_handle_t handle = NULL;
	uint64_t vme_addr;
	int am, dw, flags, use_memcpy, c;
	void *phys_addr, *buffer, *addr;
	size_t nelem, size;
	int rval = 0;

	/* Set up default values
	 */
	vme_addr = 0;
	am = VME_A32SD;
	dw = VME_D8;
	flags = VME_CTL_PWEN;
	nelem = 1;
	phys_addr = NULL;
	use_memcpy = 1;
	rval = 0;

	/* Parse the argument list
	 */
	while (-1 != (c = getopt(argc, argv, "a:A:d:e:f:p:")))
		switch (c) {
		case 'a':	/* Address modifier */
			if (strtoam(optarg, &am)) {
				fprintf(stderr, "Invalid address modifier\n");
				return -1;
			}
			break;
		case 'A':	/* VMEbus address */
			vme_addr = strtoul(optarg, NULL, 0);
			break;
		case 'd':	/* VMEbus access data width */
			if (strtodw(optarg, &dw)) {
				fprintf(stderr, "Invalid access data width\n");
				return -1;
			}
			/* If a specific data width was requested, then don't
			   use memcpy. */
			use_memcpy = 0;
			break;
		case 'e':	/* Number of elements */
			nelem = strtoul(optarg, NULL, 0);
			break;
		case 'f':	/* Flags */
			if (strtoflags(optarg, &flags)) {
				fprintf(stderr, "Invalid flags\n");
				return -1;
			}
			break;
		case 'p':	/* Physical address */
			phys_addr = (void *) strtoul(optarg, NULL, 0);
			break;
		default:
			fprintf(stderr,
				"USAGE: vme_peek [-a addr_mod] [-A vme_addr]"
				"[-d dwidth][-e num_elem][-f flags]"
				"[-p phys_addr]");
			return -1;
		}

	/* Use number of elements and data width to calculate the size.
	 */
	size = nelem * dw;

	/* Initialize
	 */
	if (vme_init(&bus_handle)) {
		perror("vme_init");
		return -1;
	}

	DPRINTF("vme_addr=0x%lx\n", (unsigned long) vme_addr);
	DPRINTF("am=0x%x\n", am);
	DPRINTF("dw=0x%x\n", dw);
	DPRINTF("size=0x%x\n", size);
	DPRINTF("flags=0x%x\n", flags);
	DPRINTF("phys_addr=0x%lx\n", (unsigned long) phys_addr);

	/* Create a handle to the necessary window
	 */
	if (vme_master_window_create(bus_handle, &handle, vme_addr, am,
				     size, flags, phys_addr)) {
		perror("vme_master_window_create");
		rval = -1;
		goto error_create;
	}

	/* This is not necessary, I just put this function here to test it and
	   demonstrate it's use.
	 */
	phys_addr = vme_master_window_phys_addr(bus_handle, handle);
	if (NULL == phys_addr) {
		perror("vme_master_window_phys_addr");
	}

	DPRINTF("Window physical address = 0x%lx\n", (unsigned long) phys_addr);

	/* Map in the window
	 */
	addr = vme_master_window_map(bus_handle, handle, 0);
	if (NULL == addr) {
		perror("vme_master_window_map");
		rval = -1;
		goto error_map;
	}

	/* Create a temporary buffer to copy data into before printing it so 
	   performance measurements won't account for local I/O.
	 */
	buffer = malloc(size);
	if (NULL == buffer) {
		perror("malloc");
		rval = -1;
		goto error_malloc;
	}

	/* Do the transfer. If data width was not given at the command line,
	   then use memcpy for fast transfers. Note that this may cause the
	   output to be byte-swapped.
	 */
	if (use_memcpy) {
		memcpy(buffer, addr, size);
	} else {
		if (vmemcpy(buffer, addr, nelem, dw)) {
			perror("vmemcpy");
			rval = -1;
			goto error_transfer;
		}
	}

	/* Print data to stdout.
	 */
	if (vdump(buffer, nelem, dw)) {
		perror("vdump");
		rval = -1;
		goto error_transfer;
	}

      error_transfer:
	free(buffer);

      error_malloc:
	if (vme_master_window_unmap(bus_handle, handle)) {
		perror("vme_master_window_unmap");
		rval = -1;
	}

      error_map:
	if (vme_master_window_release(bus_handle, handle)) {
		perror("vme_master_window_release");
		rval = -1;
	}

      error_create:
	if (vme_term(bus_handle)) {
		perror("vme_term");
		return -1;
	}

	return rval;
}
Exemple #3
0
void cproxy_dump_behavior_ex(proxy_behavior *b, char *prefix, int level,
                             void (*dump)(const void *dump_opaque,
                                          const char *prefix,
                                          const char *key,
                                          const char *buf),
                             const void *dump_opaque) {
    assert(b);
    assert(dump);

    char vbuf[8000];

#define vdump(key, vfmt, val) {              \
    snprintf(vbuf, sizeof(vbuf), vfmt, val); \
    dump(dump_opaque, prefix, key, vbuf);    \
}

    if (level >= 2) {
        vdump("cycle", "%u", b->cycle);
    }
    if (level >= 1) {
        vdump("downstream_max", "%u", b->downstream_max);
        vdump("downstream_conn_max", "%u", b->downstream_conn_max);
    }

    vdump("downstream_weight",   "%u", b->downstream_weight);
    vdump("downstream_retry",    "%u", b->downstream_retry);
    vdump("downstream_protocol", "%d", b->downstream_protocol);
    vdump("downstream_timeout", "%ld", // In millisecs.
          (b->downstream_timeout.tv_sec * 1000 +
           b->downstream_timeout.tv_usec / 1000));
    vdump("downstream_conn_queue_timeout", "%ld", // In millisecs.
          (b->downstream_conn_queue_timeout.tv_sec * 1000 +
           b->downstream_conn_queue_timeout.tv_usec / 1000));

    if (level >= 1) {
        vdump("wait_queue_timeout", "%ld", // In millisecs.
              (b->wait_queue_timeout.tv_sec * 1000 +
               b->wait_queue_timeout.tv_usec / 1000));
        vdump("connect_timeout", "%ld", // In millisecs.
              (b->connect_timeout.tv_sec * 1000 +
               b->connect_timeout.tv_usec / 1000));
        vdump("auth_timeout", "%ld", // In millisecs.
              (b->auth_timeout.tv_sec * 1000 +
               b->auth_timeout.tv_usec / 1000));
        vdump("time_stats", "%d", b->time_stats);
        vdump("mcs_opts", "%s", b->mcs_opts);
        vdump("connect_max_errors", "%u", b->connect_max_errors);
        vdump("connect_retry_interval", "%u", b->connect_retry_interval);
        vdump("front_cache_max", "%u", b->front_cache_max);
        vdump("front_cache_lifespan", "%u", b->front_cache_lifespan);
        vdump("front_cache_spec", "%s", b->front_cache_spec);
        vdump("front_cache_unspec", "%s", b->front_cache_unspec);
        vdump("key_stats_max", "%u", b->key_stats_max);
        vdump("key_stats_lifespan", "%u", b->key_stats_lifespan);
        vdump("key_stats_spec", "%s", b->key_stats_spec);
        vdump("key_stats_unspec", "%s", b->key_stats_unspec);
        vdump("optimize_set", "%s", b->optimize_set);
    }

    vdump("usr",    "%s", b->usr);
    vdump("host",   "%s", b->host);
    vdump("port",   "%d", b->port);
    vdump("bucket", "%s", b->bucket);

    if (level >= 1) {
        vdump("port_listen", "%d", b->port_listen);
        vdump("default_bucket_name", "%s", b->default_bucket_name);
    }
}