コード例 #1
0
static int qat_alg_aead_setkey(struct crypto_aead *tfm, const uint8_t *key,
			       unsigned int keylen)
{
	struct qat_alg_aead_ctx *ctx = crypto_aead_ctx(tfm);
	struct device *dev;

	spin_lock(&ctx->lock);
	if (ctx->enc_cd) {
		/* rekeying */
		dev = &GET_DEV(ctx->inst->accel_dev);
		memset(ctx->enc_cd, 0, sizeof(*ctx->enc_cd));
		memset(ctx->dec_cd, 0, sizeof(*ctx->dec_cd));
		memset(&ctx->enc_fw_req, 0, sizeof(ctx->enc_fw_req));
		memset(&ctx->dec_fw_req, 0, sizeof(ctx->dec_fw_req));
	} else {
		/* new key */
		int node = get_current_node();
		struct qat_crypto_instance *inst =
				qat_crypto_get_instance_node(node);
		if (!inst) {
			spin_unlock(&ctx->lock);
			return -EINVAL;
		}

		dev = &GET_DEV(inst->accel_dev);
		ctx->inst = inst;
		ctx->enc_cd = dma_zalloc_coherent(dev, sizeof(*ctx->enc_cd),
						  &ctx->enc_cd_paddr,
						  GFP_ATOMIC);
		if (!ctx->enc_cd) {
			spin_unlock(&ctx->lock);
			return -ENOMEM;
		}
		ctx->dec_cd = dma_zalloc_coherent(dev, sizeof(*ctx->dec_cd),
						  &ctx->dec_cd_paddr,
						  GFP_ATOMIC);
		if (!ctx->dec_cd) {
			spin_unlock(&ctx->lock);
			goto out_free_enc;
		}
	}
	spin_unlock(&ctx->lock);
	if (qat_alg_aead_init_sessions(tfm, key, keylen,
				       ICP_QAT_HW_CIPHER_CBC_MODE))
		goto out_free_all;

	return 0;

out_free_all:
	memset(ctx->dec_cd, 0, sizeof(struct qat_alg_cd));
	dma_free_coherent(dev, sizeof(struct qat_alg_cd),
			  ctx->dec_cd, ctx->dec_cd_paddr);
	ctx->dec_cd = NULL;
out_free_enc:
	memset(ctx->enc_cd, 0, sizeof(struct qat_alg_cd));
	dma_free_coherent(dev, sizeof(struct qat_alg_cd),
			  ctx->enc_cd, ctx->enc_cd_paddr);
	ctx->enc_cd = NULL;
	return -ENOMEM;
}
コード例 #2
0
ファイル: task.cpp プロジェクト: shengofsun/rDSN
task::task(dsn::task_code code, int hash, service_node *node)
    : _state(TASK_STATE_READY), _wait_event(nullptr)
{
    _spec = task_spec::get(code);
    _hash = hash;
    _delay_milliseconds = 0;
    _wait_for_cancel = false;
    _is_null = false;
    next = nullptr;

    if (node != nullptr) {
        _node = node;
    } else {
        auto p = get_current_node();
        dassert(p != nullptr,
                "tasks without explicit service node "
                "can only be created inside threads which is attached to specific node");
        _node = p;
    }

    if (tls_dsn.magic != 0xdeadbeef) {
        set_tls_dsn_context(nullptr, nullptr);
    }

    _task_id = tls_dsn.node_pool_thread_ids + (++tls_dsn.last_lower32_task_id);
}
コード例 #3
0
ファイル: out_curses.c プロジェクト: raguedo/cursoasl
static void
draw_intf_list_entry(intf_t *intf, node_t *node)
{
	float rx, tx;
	char *rx_u, *tx_u;
	char pad[IFNAMSIZ + 32];
	
	rx = sumup(intf->i_rx_bytes.r_tps, &rx_u);
	tx = sumup(intf->i_tx_bytes.r_tps, &tx_u);

	memset(pad, ' ', sizeof(pad));
	pad[sizeof(pad) - 1] = '\0';
	if (intf->i_level >= 15)
		strcpy(&pad[sizeof(pad) - 1], intf->i_name);
	else
		strcpy(&pad[2 * intf->i_level], intf->i_name);

	NEXT_ROW;

	if (intf->i_index == node->n_selected && node == get_current_node()) {
		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_SELECTED) | layout[LAYOUT_SELECTED].attr);
		else
			attron(A_REVERSE);
	}
	
	printw("  %-3d%s", intf->i_index, intf->i_folded ? "+" : " ");

	if (intf->i_index == node->n_selected && node == get_current_node()) {
		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_LIST) | layout[LAYOUT_LIST].attr);
		else
			attroff(A_REVERSE);
	}

	
	putl("%-20s %10.2f%s %10d %10.2f%s %10d", pad,
		rx, rx_u, intf->i_rx_packets.r_tps,
		tx, tx_u, intf->i_tx_packets.r_tps);
}
コード例 #4
0
ファイル: qat_asym_algs.c プロジェクト: DenisLug/mptcp
static int qat_rsa_init_tfm(struct crypto_akcipher *tfm)
{
	struct qat_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
	struct qat_crypto_instance *inst =
			qat_crypto_get_instance_node(get_current_node());

	if (!inst)
		return -EINVAL;

	ctx->key_sz = 0;
	ctx->inst = inst;
	return 0;
}
コード例 #5
0
static int qat_dh_init_tfm(struct crypto_kpp *tfm)
{
	struct qat_dh_ctx *ctx = kpp_tfm_ctx(tfm);
	struct qat_crypto_instance *inst =
			qat_crypto_get_instance_node(get_current_node());

	if (!inst)
		return -EINVAL;

	ctx->p_size = 0;
	ctx->g2 = false;
	ctx->inst = inst;
	return 0;
}
コード例 #6
0
ファイル: task.cpp プロジェクト: shengofsun/rDSN
void task::enqueue(task_worker_pool *pool)
{
    this->add_ref(); // released in exec_internal (even when cancelled)

    dassert(pool != nullptr,
            "pool %s not ready, and there are usually two cases: "
            "(1). thread pool not designatd in '[%s] pools'; "
            "(2). the caller is executed in io threads "
            "which is forbidden unless you explicitly set [task.%s].allow_inline = true",
            _spec->pool_code.to_string(),
            _node->spec().config_section.c_str(),
            _spec->name.c_str());

    if (spec().type == TASK_TYPE_COMPUTE) {
        spec().on_task_enqueue.execute(get_current_task(), this);
    }

    // for delayed tasks, refering to timer service
    if (_delay_milliseconds != 0) {
        pool->add_timer(this);
        return;
    }

    // fast execution
    if (_is_null) {
        dassert(_node == task::get_current_node(), "");
        exec_internal();
        return;
    }

    if (_spec->allow_inline) {
        // inlined
        // warning - this may lead to deadlocks, e.g., allow_inlined
        // task tries to get a non-recursive lock that is already hold
        // by the caller task

        if (_node != get_current_node()) {
            tools::node_scoper ns(_node);
            exec_internal();
            return;
        } else {
            exec_internal();
            return;
        }
    }

    // normal path
    pool->enqueue(this);
}
コード例 #7
0
ファイル: out_curses.c プロジェクト: raguedo/cursoasl
static void
fold(void)
{
	intf_t *intf = get_current_intf();
	node_t *node = get_current_node();
	int fix = 0;

	if (NULL == intf || NULL == node)
		return;

	if (intf->i_is_child)
		fix = 1;

	while (intf->i_is_child)
		intf = get_intf(node, intf->i_parent);

	intf->i_folded = intf->i_folded ? 0 : 1;

	if (fix)
		prev_intf();
}
コード例 #8
0
ファイル: out_curses.c プロジェクト: ebichu/dd-wrt
static void fold(void)
{
	item_t *intf = get_current_item();
	node_t *node = get_current_node();
	int fix = 0;

	if (NULL == intf || NULL == node)
		return;

	if (intf->i_flags & ITEM_FLAG_IS_CHILD)
		fix = 1;

	while (intf->i_flags & ITEM_FLAG_IS_CHILD)
		intf = get_item(node, intf->i_parent);

	if (intf->i_flags & ITEM_FLAG_FOLDED)
		intf->i_flags &= ~ITEM_FLAG_FOLDED;
	else
		intf->i_flags |= ITEM_FLAG_FOLDED;

	if (fix)
		prev_item();
}
コード例 #9
0
ファイル: out_curses.c プロジェクト: raguedo/cursoasl
static void
curses_draw(void)
{
	if (NULL == get_current_node()) {
		first_node();
		first_intf();
	}

    row = 0;
    move(0,0);
	
	getmaxyx(stdscr, rows, cols);
	
	if (cols < 80) {
		clear();
		putl("Screen must be at least 80 columns wide");
		refresh();
		return;
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (get_current_node() && get_current_intf()) {
		putl(" interface: %s at %s",
			get_current_intf()->i_name, get_current_node()->n_name);
	}

	move(row, COLS - strlen(PACKAGE_STRING) - 1);
	putl("%s", PACKAGE_STRING);
	move(row, 0);
	
	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
	else
		attroff(A_REVERSE);
	
	print_content();

	if (quit_mode)
		print_quit();
	else if (print_help)
		draw_help();

	for (; row < rows-2;) {
		move(++row, 0);
		putl("");
	}
	
	row = rows-1;
	move(row, 0);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	putl(" ^ prev interface, v next interface, <- prev node, -> next node, ? help");
	
	attrset(0);
	refresh();
}
コード例 #10
0
ファイル: out_curses.c プロジェクト: raguedo/cursoasl
static void
print_content(void)
{
	int required_lines = 0, disable_detailed = 0, disabled_graphical = 0;

	if (NULL == get_current_node())
		return;

	if (c_list_in_list) {
		NEXT_ROW;
		putl("");

		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_HEADER) | layout[LAYOUT_HEADER].attr);
	
		NEXT_ROW;
		putl("  #   Tarjeta                RX Tasa         RX #   " \
			"  TX Tasa         TX #");
	
		NEXT_ROW;
		hline(ACS_HLINE, cols);

		if (c_combined_node_list)
			foreach_node(draw_node, NULL);
		else
			draw_node(get_current_node(), NULL);
	} else {
		NEXT_ROW;
		hline(ACS_HLINE, cols);
		move(row, 24);
		addstr(" Press l to enable list view ");
		move(row, 0);
	}

	/*
	 * calculate lines required for graphical and detailed stats unfolded
	 */
	if (c_graphical_in_list)
		required_lines += lines_required_for_graphical();
	else
		required_lines++;

	if (c_detailed_in_list)
		required_lines += lines_required_for_detailed();
	else
		required_lines++;

	if ((rows - row) <= (required_lines + 1)) {
		/*
		 * not enough lines, start over with detailed stats disabled
		 */
		required_lines = 0;
		disable_detailed = 1;

		/*
		 * 1 line for folded detailed stats display
		 */
		required_lines++;

		if (c_graphical_in_list)
			required_lines += lines_required_for_graphical();
		else
			required_lines++;

		if ((rows - row) <= (required_lines + 1)) {
			/*
			 * bad luck, not even enough space for graphical stats
			 * reserve 2 lines for displaying folded detailed and
			 * graphical stats
			 */
			required_lines = 2;
			disabled_graphical = 1;
		}
	}

	/*
	 * Clear out spare space
	 */
	while (row < (rows - (required_lines + 2))) {
		NEXT_ROW; putl("");
	}

	NEXT_ROW;
	hline(ACS_HLINE, cols);

	if (c_graphical_in_list) {
		if (disabled_graphical) {
			move(row, 15);
			addstr(" Increase screen size to see graphical statistics ");
			move(row, 0);
		} else
			draw_graphic();
	} else {
		move(row, 20);
		addstr(" Press g to enable graphical statistics ");
		move(row, 0);
	}

	NEXT_ROW;
	hline(ACS_HLINE, cols);

	if (c_detailed_in_list) {
		if (disable_detailed) {
			move(row, 15);
			addstr(" Increase screen size to see detailed statistics ");
			move(row, 0);
		} else
			draw_detailed();
	} else {
		move(row, 20);
		addstr(" Press d to enable detailed statistics ");
		move(row, 0);
	}
}
コード例 #11
0
ファイル: out_curses.c プロジェクト: ebichu/dd-wrt
static void curses_draw(void)
{
	if (NULL == get_current_node()) {
		first_node();
		first_item();
	}

	row = 0;
	move(0,0);
	
	getmaxyx(stdscr, rows, cols);
	
	if (cols < 80) {
		clear();
		putl("Screen must be at least 80 columns wide");
		refresh();
		return;
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (get_current_node() && get_current_item()) {
		putl(" %s on %s",
			get_current_item()->i_name, get_current_node()->n_name);
	}

	move(row, COLS - strlen(PACKAGE_STRING) - 1);
	putl("%s", PACKAGE_STRING);
	move(row, 0);
	
	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
	else
		attroff(A_REVERSE);
	
	print_content();

	if (quit_mode)
		print_quit();
	else if (print_help) {
		if (help_page == 0)
			draw_help();
		else
			draw_help_2();
	}

	for (; row < rows-2;) {
		move(++row, 0);
		putl("");
	}
	
	row = rows-1;
	move(row, 0);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (1) {
		char s[27];
		time_t t = time(0);
		double d;
		int h, m;

		asctime_r(localtime(&t), s);
		s[strlen(s) - 1] = '\0';
		d = difftime(time(0), start_time);

		if (d / 3600) {
			h = (int) d / 3600;
			m = (int) d % 3600;
			m /= 60;
		} else {
			h = 0;
			m = (int) d / 60;
		}
		
		putl(" %s (%dh/%dm)", s, h, m);
		move(row, COLS - strlen("Press ? for help") - 1);
		putl("%s", "Press ? for help");
		move(row, 0);
	}
	
	attrset(0);
	refresh();
}
コード例 #12
0
ファイル: out_curses.c プロジェクト: ebichu/dd-wrt
static void draw_item_list_entry(item_t *intf, node_t *node)
{
	int rxprec, txprec, rxpprec, txpprec;
	stat_attr_t *bytes, *packets;
	double rx, tx, rxp, txp;
	char *rx_u, *tx_u, *rxp_u, *txp_u;
	char pad[23];

	bytes = lookup_attr(intf, intf->i_major_attr);
	packets = lookup_attr(intf, intf->i_minor_attr);

	if (bytes == NULL || packets == NULL)
		return;

	rx = cancel_down(attr_get_rx_rate(bytes), bytes->a_unit, &rx_u, &rxprec);
	tx = cancel_down(attr_get_tx_rate(bytes), bytes->a_unit, &tx_u, &txprec);

	rxp = cancel_down(attr_get_rx_rate(packets), packets->a_unit, &rxp_u, &rxpprec);
	txp = cancel_down(attr_get_tx_rate(packets), packets->a_unit, &txp_u, &txpprec);

	memset(pad, 0, sizeof(pad));
	memset(pad, ' ', intf->i_level < 15 ? intf->i_level : 15);

	strncat(pad, intf->i_name, sizeof(pad) - strlen(pad) - 1);

	if (intf->i_desc) {
		strncat(pad, " (", sizeof(pad) - strlen(pad) - 1);
		strncat(pad, intf->i_desc, sizeof(pad) - strlen(pad) - 1);
		strncat(pad, ")", sizeof(pad) - strlen(pad) - 1);
	}
	NEXT_ROW;

	if (intf->i_index == node->n_selected && node == get_current_node()) {
		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_SELECTED) | layout[LAYOUT_SELECTED].attr);
		else
			attron(A_REVERSE);
	}
	
	printw("  %-3d%s", intf->i_index, (intf->i_flags & ITEM_FLAG_FOLDED) ? "+" : " ");

	if (intf->i_index == node->n_selected && node == get_current_node()) {
		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_LIST) | layout[LAYOUT_LIST].attr);
		else
			attroff(A_REVERSE);
	}

	putl("%-22s %8.*f%s %8.*f%s %2d%% %8.*f%s %8.*f%s %2d%%", pad,
		rxprec, rx, rx_u, rxpprec, rxp, rxp_u, intf->i_rx_usage,
		txprec, tx, tx_u, txpprec, txp, txp_u, intf->i_tx_usage);

	if (intf->i_rx_usage == -1) {
		move(row, 51);
		addstr("   ");
	}

	if (intf->i_tx_usage == -1) {
		move(row, 77);
		addstr("   ");
	}

	move(row, 28);
	addch(ACS_VLINE);
	move(row, 54);
	addch(ACS_VLINE);
}