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

ub: ubcore add set upi and add/delete ueid api impls



driver inclusion
category: feature
bugzilla: NA
CVE: NA

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

Ubcore add set upi and add/delete ueid api impls, which will finally
call hw driver's registered methods.

These apis are related to virtualization of UB.

Add ueid:
The UB Core invokes the UBN driver to set the EID and UPI values.
Input parameter:
dev: contains vendor-defined private device data.
vf_id: specifies the EID and UPI values of a VF. The value 0xFFFF
indicates that the PF is set to the PF instead of to the managed VF.
cfg: indicates the ID to be set, including the EID and UPI.
Return value:
If the value is 0, the setting is successful. If the value is less than 0,
the setting fails.

Delete ueid:
The UB Core invokes the UBN driver to delete the EID and UPI
values of the VF or PF.
Input parameter:
dev: contains vendor-defined private device data.
vf_id: specifies the UPI value of a VF. 0xFFFF indicates the PF itself.
That is, the EID and UPI of the PF are deleted, not the managed VF.
cfg: indicates the EID and UPI values to be deleted.
Return value:
The value 0 indicates that the deletion is successful. The value other
than 0 indicates that the deletion fails.

Signed-off-by: default avatarGuoxin Qian <qianguoxin@huawei.com>
Signed-off-by: default avatarYizhen Fan <fanyizhen@huawei.com>
parent 231ee390
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -324,6 +324,7 @@ static struct ubcore_ht_param g_ht_params[] = {

	[UBCORE_HT_JETTY] = { UBCORE_HASH_TABLE_SIZE, offsetof(struct ubcore_jetty, hnode),
			      offsetof(struct ubcore_jetty, id), sizeof(uint32_t), NULL, NULL },

	[UBCORE_HT_TP] = { UBCORE_HASH_TABLE_SIZE, offsetof(struct ubcore_tp_node, hnode),
			   offsetof(struct ubcore_tp_node, key), sizeof(struct ubcore_tp_key), NULL,
			   NULL },
@@ -589,6 +590,24 @@ int ubcore_set_eid(struct ubcore_device *dev, union ubcore_eid *eid)
}
EXPORT_SYMBOL(ubcore_set_eid);

int ubcore_set_upi(const struct ubcore_device *dev, uint16_t vf_id, uint16_t idx, uint32_t upi)
{
	int ret;

	if (dev == NULL || dev->ops == NULL || dev->ops->set_upi == NULL) {
		ubcore_log_err("Invalid argument.\n");
		return -EINVAL;
	}

	ret = dev->ops->set_upi(dev, vf_id, idx, upi);
	if (ret != 0) {
		ubcore_log_err("failed to set vf%hu upi%hu, ret: %d.\n", vf_id, idx, ret);
		return -EPERM;
	}
	return 0;
}
EXPORT_SYMBOL(ubcore_set_upi);

int ubcore_add_eid(struct ubcore_device *dev, union ubcore_eid *eid)
{
	int ret;
@@ -625,6 +644,42 @@ int ubcore_delete_eid(struct ubcore_device *dev, uint16_t idx)
}
EXPORT_SYMBOL(ubcore_delete_eid);

int ubcore_add_ueid(struct ubcore_device *dev, uint16_t vf_id, struct ubcore_ueid_cfg *cfg)
{
	int ret;

	if (dev == NULL || cfg == NULL || dev->ops == NULL || dev->ops->add_ueid == NULL) {
		ubcore_log_err("Invalid argument.\n");
		return -EINVAL;
	}

	ret = dev->ops->add_ueid(dev, vf_id, cfg);
	if (ret != 0) {
		ubcore_log_err("failed to add ueid, ret: %d.\n", ret);
		return -EPERM;
	}
	return ret;
}
EXPORT_SYMBOL(ubcore_add_ueid);

int ubcore_delete_ueid(struct ubcore_device *dev, uint16_t vf_id, uint16_t idx)
{
	int ret;

	if (dev == NULL || dev->ops == NULL || dev->ops->delete_ueid_by_idx == NULL) {
		ubcore_log_err("Invalid argument.\n");
		return -EINVAL;
	}

	ret = dev->ops->delete_ueid_by_idx(dev, vf_id, idx);
	if (ret != 0) {
		ubcore_log_err("failed to delete eid, ret: %d.\n", ret);
		return -EPERM;
	}
	return ret;
}
EXPORT_SYMBOL(ubcore_delete_ueid);

int ubcore_query_device_attr(struct ubcore_device *dev, struct ubcore_device_attr *attr)
{
	int ret;
+25 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#define UBCORE_UAPI_H

#include <urma/ubcore_types.h>

/**
 * Application specifies the device to allocate an context.
 * @param[in] dev: ubcore_device found by add ops in the client.
@@ -51,6 +50,15 @@ void ubcore_free_ucontext(const struct ubcore_device *dev, struct ubcore_ucontex
 * @return: 0 on success, other value on error
 */
int ubcore_set_eid(struct ubcore_device *dev, union ubcore_eid *eid);
/**
 * set upi
 * @param[in] dev: the ubcore_device handle;
 * @param[in] vf_id: vf_id;
 * @param[in] idx: idx of upi in vf;
 * @param[in] upi: upi of vf to set
 * @return: 0 on success, other value on error
 */
int ubcore_set_upi(const struct ubcore_device *dev, uint16_t vf_id, uint16_t idx, uint32_t upi);
/**
 * add a function entity id (eid) to ub device, the upi of vf to which the eid belongs
 * can be specified
@@ -67,6 +75,22 @@ int ubcore_add_eid(struct ubcore_device *dev, union ubcore_eid *eid);
 * @return: 0 on success, other value on error
 */
int ubcore_delete_eid(struct ubcore_device *dev, uint16_t idx);
/**
 * add a function entity id (eid) to ub device (for uvs)
 * @param[in] dev: the ubcore_device handle;
 * @param[in] vf_id: vf_id;
 * @param[in] cfg: eid and the upi of vf to which the eid belongs can be specified;
 * @return: the index of eid/upi, less than 0 indicating error
 */
int ubcore_add_ueid(struct ubcore_device *dev, uint16_t vf_id, struct ubcore_ueid_cfg *cfg);
/**
 * remove a function entity id (eid) specified by idx from ub device (for uvs)
 * @param[in] dev: the ubcore_device handle;
 * @param[in] vf_id: vf_id;
 * @param[in] idx: the idx of function entity id (eid) to be deleted;
 * @return: 0 on success, other value on error
 */
int ubcore_delete_ueid(struct ubcore_device *dev, uint16_t vf_id, uint16_t idx);
/**
 * query device attributes
 * @param[in] dev: the ubcore_device handle;