Commit 0dec85bc authored by Yizhen Fan's avatar Yizhen Fan Committed by fanyizhen1995
Browse files

ub: ubcore add unadivse tp api



driver inclusion
category: feature
bugzilla: NA
CVE: NA

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

Ubcore add unadvise tp api.
Unadvise tp will finally destroy tp, which will call driver's registered
method destroy_tp.

Signed-off-by: default avatarGuoxin Qian <qianguoxin@huawei.com>
Signed-off-by: default avatarYizhen Fan <fanyizhen@huawei.com>
parent 4cc6a2cf
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -498,6 +498,23 @@ static int ubcore_destroy_peer_tp(struct ubcore_tp *tp, struct ubcore_ta *ta)
	return ret;
}

/* Destroy both local tp and remote peer tp */
static int ubcore_destroy_local_peer_tp(struct ubcore_tp *tp, struct ubcore_ta *ta)
{
	struct ubcore_device *dev = tp->ub_dev;
	int ret;

	/* Do not send destroy request to the remote if we are in the VM */
	if (!dev->attr.virtualization) {
		ret = ubcore_destroy_peer_tp(tp, ta);
		if (ret != 0) {
			ubcore_log_err("Failed to destroy peer tp");
			return ret;
		}
	}
	return ubcore_destroy_tp(tp);
}

static void ubcore_abort_tp(struct ubcore_tp *tp, struct ubcore_tp_meta *meta)
{
	struct ubcore_tp *target;
@@ -1227,6 +1244,19 @@ int ubcore_advise_tp(struct ubcore_device *dev, const union ubcore_eid *remote_e
}
EXPORT_SYMBOL(ubcore_advise_tp);

int ubcore_unadvise_tp(struct ubcore_device *dev, struct ubcore_tp_advice *advice)
{
	struct ubcore_tp *tp =
		ubcore_find_remove_tp(advice->meta.ht, advice->meta.hash, &advice->meta.key);
	if (tp == NULL) {
		ubcore_log_warn("TP is not found, already removed or under use\n");
		return 0;
	}

	return ubcore_destroy_local_peer_tp(tp, &advice->ta);
}
EXPORT_SYMBOL(ubcore_unadvise_tp);

static void ubcore_get_ta_from_tp(struct ubcore_ta *ta, struct ubcore_tp *tp)
{
	struct ubcore_tp_node *tp_node = (struct ubcore_tp_node *)tp->priv;
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ static inline bool ubcore_have_tp_ops(const struct ubcore_device *dev)
/* alpha */
int ubcore_advise_tp(struct ubcore_device *dev, const union ubcore_eid *remote_eid,
		     struct ubcore_tp_advice *advice, struct ubcore_udata *udata);
int ubcore_unadvise_tp(struct ubcore_device *dev, struct ubcore_tp_advice *advice);

struct ubcore_nlmsg *ubcore_handle_create_tp_req(struct ubcore_nlmsg *req);
struct ubcore_nlmsg *ubcore_handle_destroy_tp_req(struct ubcore_nlmsg *req);