Commit 07d04c76 authored by Yizhen Fan's avatar Yizhen Fan Committed by fanyizhen1995
Browse files

ub: ubcore add bind and unbind jetty api.



driver inclusion
category: feature
bugzilla: NA
CVE: NA

--------------------------------

Ubcore add bind and unbind jetty api.
Bind jetty: Bind local jetty with remote jetty, and construct a
transport channel between them.
Unbind jetty: Unbind local jetty with remote jetty.

Signed-off-by: default avatarGuoxin Qian <qianguoxin@huawei.com>
Signed-off-by: default avatarYizhen Fan <fanyizhen@huawei.com>
parent 6c0c23b9
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -793,6 +793,71 @@ int ubcore_unadvise_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjet
}
EXPORT_SYMBOL(ubcore_unadvise_jetty);

int ubcore_bind_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjetty,
		      struct ubcore_udata *udata)
{
	struct ubcore_tp_advice advice;
	int ret;

	if (jetty == NULL || tjetty == NULL || !ubcore_have_tp_ops(jetty->ub_dev)) {
		ubcore_log_err("invalid parameter.\n");
		return -1;
	}
	if ((jetty->jetty_cfg.trans_mode != UBCORE_TP_RC) ||
	    (tjetty->cfg.trans_mode != UBCORE_TP_RC)) {
		ubcore_log_err("trans mode is not rc type.\n");
		return -1;
	}
	if (jetty->remote_jetty != NULL) {
		ubcore_log_err("The same jetty, different tjetty, prevent duplicate bind.\n");
		return -1;
	}

	ret = ubcore_advice_jetty_tjetty(&advice, jetty, tjetty);
	if (ret != 0)
		return ret;

	ret = ubcore_bind_tp(jetty, tjetty, &advice, udata);

	ubcore_put_advice(&advice);
	if (ret != 0) {
		ubcore_log_err("Failed to setup tp connection.\n");
		return ret;
	}
	jetty->remote_jetty = tjetty;
	return 0;
}
EXPORT_SYMBOL(ubcore_bind_jetty);

int ubcore_unbind_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjetty)
{
	struct ubcore_tp_advice advice;
	int ret;

	if (jetty == NULL || tjetty == NULL) {
		ubcore_log_err("invalid parameter.\n");
		return -1;
	}
	if ((jetty->jetty_cfg.trans_mode != UBCORE_TP_RC) ||
	    (tjetty->cfg.trans_mode != UBCORE_TP_RC)) {
		ubcore_log_err("trans mode is not rc type.\n");
		return -1;
	}

	ret = ubcore_advice_jetty_tjetty(&advice, jetty, tjetty);
	if (ret != 0)
		return ret;

	ret = ubcore_unbind_tp(jetty, tjetty, &advice);
	ubcore_put_advice(&advice);
	if (ret != 0)
		ubcore_log_err("Failed to destroy jetty tp.\n");

	jetty->remote_jetty = NULL;
	return ret;
}
EXPORT_SYMBOL(ubcore_unbind_jetty);

struct ubcore_jetty *ubcore_find_jetty(struct ubcore_device *dev, uint32_t jetty_id)
{
	return ubcore_hash_table_lookup(&dev->ht[UBCORE_HT_JETTY], jetty_id, &jetty_id);
+19 −0
Original line number Diff line number Diff line
@@ -359,6 +359,25 @@ int ubcore_advise_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjetty
 * @return: 0 on success, other value on error
 */
int ubcore_unadvise_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjetty);
/**
 * Bind jetty: Bind local jetty with remote jetty, and construct a transport channel between them.
 * @param[in] jetty: local jetty to bind;
 * @param[in] tjetty: target jetty imported before;
 * @param[in] udata (optional): ucontext and user space driver data
 * @return: 0 on success, other value on error
 * Note: A local jetty can be binded with only one remote jetty.
 * Only supported by jetty with URMA_TM_RC.
 */
int ubcore_bind_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjetty,
		      struct ubcore_udata *udata);
/**
 * Unbind jetty: Unbind local jetty with remote jetty,
 * and tear down the transport channel between them.
 * @param[in] jetty: local jetty to unbind;
 * @param[in] tjetty: target jetty advised before;
 * @return: 0 on success, other value on error
 */
int ubcore_unbind_jetty(struct ubcore_jetty *jetty, struct ubcore_tjetty *tjetty);
/**
 * operation of user ioctl cmd.
 * @param[in] k_user_ctl: kdrv user control command pointer;