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

ub: add config device ops in ubcore



driver inclusion
category: feature
bugzilla: NA
CVE: NA

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

config_device is a function pointer
and a member of the ubcore_ops_t structure.
When the ubcore_register_device interface is invoked,
the vendor driver registers with the UB protocol stack.
The administrator or cloud management system
uses uvs-admin or uvs to invoke the UB protocol stack
to provide a device configuration interface for tools.
The UB protocol stack invokes this interface
to configure basic device information through drivers.

Input parameter:
dev: contains vendor-defined private device data.
cfg: configuration information.
The UBN driver obtains information from this field for configuration.
timeout: specifies the timeout interval, in ms.

Signed-off-by: default avatarGuoxin Qian <qianguoxin@huawei.com>
Signed-off-by: default avatarYizhen Fan <fanyizhen@huawei.com>
parent f6206cf0
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -462,6 +462,24 @@ int ubcore_query_device_attr(struct ubcore_device *dev, struct ubcore_device_att
}
EXPORT_SYMBOL(ubcore_query_device_attr);

int ubcore_config_device(struct ubcore_device *dev, const struct ubcore_device_cfg *cfg)
{
	int ret;

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

	ret = dev->ops->config_device(dev, cfg);
	if (ret != 0) {
		ubcore_log_err("failed to config device, ret: %d.\n", ret);
		return -EPERM;
	}
	return 0;
}
EXPORT_SYMBOL(ubcore_config_device);

int ubcore_query_stats(const struct ubcore_device *dev, struct ubcore_stats_key *key,
		       struct ubcore_stats_val *val)
{
+42 −0
Original line number Diff line number Diff line
@@ -71,6 +71,32 @@ struct ubcore_device_attr {
	uint32_t max_eid_cnt;
};

union ubcore_device_cfg_mask {
	struct {
		uint32_t port_ets : 1;
		uint32_t port_fec : 1;
	} bs;
	uint32_t value;
};

struct ubcore_congestion_control {
	uint32_t data;
};

struct ubcore_port_ets {
	uint32_t data;
};

struct ubcore_port_fec {
	uint32_t data;
};

struct ubcore_device_cfg {
	union ubcore_device_cfg_mask mask;
	struct ubcore_port_fec fec;
	struct ubcore_port_ets ets;
};

struct ubcore_net_addr {
	union {
		uint8_t raw[UBCORE_NET_ADDR_BYTES];
@@ -141,6 +167,13 @@ struct ubcore_ops {
	 * @return: 0 on success, other value on error
	 */
	int (*query_device_attr)(struct ubcore_device *dev, struct ubcore_device_attr *attr);
	/**
	 * config device
	 * @param[in] dev: the ub device handle;
	 * @param[in] cfg: device configuration
	 * @return: 0 on success, other value on error
	 */
	int (*config_device)(struct ubcore_device *dev, const struct ubcore_device_cfg *cfg);
	/**
	 * set ub network address
	 * @param[in] dev: the ub device handle;
@@ -182,6 +215,8 @@ struct ubcore_device {
	struct attribute_group *group[UBCORE_MAX_ATTR_GROUP]; /* driver may fill group [1] */
	/* driver fills end */

	struct ubcore_device_cfg cfg;

	/* port management */
	struct kobject *ports_parent; /* kobject parent of the ports in the port list */
	struct list_head port_list;
@@ -197,6 +232,13 @@ struct ubcore_device {
	struct completion comp;
};

struct ubcore_port {
	struct kobject kobj; /* add to port list */
	struct ubcore_device *ub_dev;
	uint32_t port_no;
	struct ubcore_net_addr net_addr;
};

struct ubcore_client {
	struct list_head list_node;
	char *client_name;
+8 −0
Original line number Diff line number Diff line
@@ -39,6 +39,14 @@ int ubcore_set_eid(struct ubcore_device *dev, union ubcore_eid *eid);
 * @return: 0 on success, other value on error
 */
int ubcore_query_device_attr(struct ubcore_device *dev, struct ubcore_device_attr *attr);
/**
 * config device
 * @param[in] dev: the ubcore_device handle;
 * @param[in] cfg: device configuration
 * @return: 0 on success, other value on error
 */
int ubcore_config_device(struct ubcore_device *dev, const struct ubcore_device_cfg *cfg);

/**
 * set ctx data of a client
 * @param[in] dev: the ubcore_device handle;