Beispiel #1
0
int main(int argc, char *argv[])
{
	struct pqos_config cfg;
	const struct pqos_cpuinfo *p_cpu = NULL;
	const struct pqos_cap *p_cap = NULL;
	unsigned sock_count, sockets[PQOS_MAX_SOCKETS];
	int ret, exit_val = EXIT_SUCCESS;

	memset(&cfg, 0, sizeof(cfg));
        cfg.fd_log = STDOUT_FILENO;
        cfg.verbose = 0;
	/* PQoS Initialization - Check and initialize CAT and CMT capability */
	ret = pqos_init(&cfg);
	if (ret != PQOS_RETVAL_OK) {
		printf("Error initializing PQoS library!\n");
		exit_val = EXIT_FAILURE;
		goto error_exit;
	}
	/* Get CMT capability and CPU info pointer */
	ret = pqos_cap_get(&p_cap, &p_cpu);
	if (ret != PQOS_RETVAL_OK) {
		printf("Error retrieving PQoS capabilities!\n");
		exit_val = EXIT_FAILURE;
		goto error_exit;
	}
	/* Get CPU socket information to set COS */
	ret = pqos_cpu_get_sockets(p_cpu, PQOS_MAX_SOCKETS,
                                   &sock_count,
                                   sockets);
	if (ret != PQOS_RETVAL_OK) {
		printf("Error retrieving CPU socket information!\n");
		exit_val = EXIT_FAILURE;
		goto error_exit;
	}
	/* Get input from user	*/
	allocation_get_input(argc, argv);
	if (sel_l3ca_cos_num != 0) {
		/* Set bit mask for COS allocation */
		ret = set_allocation_class(sock_count, sockets);
		if (ret < 0) {
			printf("Allocation configuration error!\n");
			goto error_exit;
		}
		printf("Allocation configuration altered.\n");
	}
	/* Print COS and associated bit mask */
	ret = print_allocation_config(sock_count, sockets);
	if (ret != PQOS_RETVAL_OK) {
		printf("Allocation capability not detected!\n");
		exit_val = EXIT_FAILURE;
		goto error_exit;
	}
 error_exit:
	/* reset and deallocate all the resources */
	ret = pqos_fini();
	if (ret != PQOS_RETVAL_OK)
		printf("Error shutting down PQoS library!\n");
	return exit_val;
}
Beispiel #2
0
int alloc_apply(const struct pqos_capability *cap_l3ca,
                const struct pqos_capability *cap_l2ca,
                unsigned sock_count, unsigned *sockets)
{
        if (cap_l3ca != NULL || cap_l2ca != NULL) {
                /**
                 * If allocation config changed then exit.
                 * For monitoring, start the program again unless
                 * config file was provided
                 */
                int ret_assoc = 0, ret_cos = 0;

                ret_cos = set_allocation_class(sock_count, sockets);
                if (ret_cos < 0) {
                        printf("Allocation configuration error!\n");
                        return -1;
                }

                ret_assoc = set_allocation_assoc();
                if (ret_assoc < 0) {
                        printf("CAT association error!\n");
                        return -1;
                }
                /**
                 * Check if any allocation configuration has changed
                 */
                if (ret_assoc > 0 || ret_cos > 0) {
                        printf("Allocation configuration altered.\n");
                        return 1;
                }
        } else {
                if (sel_cat_assoc_num > 0 || sel_cat_cos_num > 0) {
                        printf("Allocation capability not detected!\n");
                        return -1;
                }
        }

        return 0;
}