From 3d4001a4ffb0765198644f90bc9819d2e00c2039 Mon Sep 17 00:00:00 2001 From: Yongqiang Guo Date: Sat, 29 Nov 2025 20:16:45 +0800 Subject: [PATCH 1/8] ubcore: fix query route list by eid pair. commit c78127c4b6ebb6d94cf2155af3831407143cc084 openEuler This patch fix ubcore_get_topo_eid to make query all routes between a pair of ubcore bonding eid correctly, including primary eids and port eids. Signed-off-by: Yongqiang Guo Signed-off-by: Yongqiang Guo --- drivers/ub/urma/ubcore/ubcore_cmd_tlv.c | 40 +++++-- drivers/ub/urma/ubcore/ubcore_cmd_tlv.h | 8 ++ drivers/ub/urma/ubcore/ubcore_topo_info.c | 136 ++++++++++------------ drivers/ub/urma/ubcore/ubcore_uvs_cmd.c | 26 ++++- drivers/ub/urma/ubcore/ubcore_uvs_cmd.h | 12 +- include/ub/urma/ubcore_uapi.h | 47 +++++--- 6 files changed, 174 insertions(+), 95 deletions(-) diff --git a/drivers/ub/urma/ubcore/ubcore_cmd_tlv.c b/drivers/ub/urma/ubcore/ubcore_cmd_tlv.c index 1c1dd5e47df1..5b2321aedba4 100644 --- a/drivers/ub/urma/ubcore/ubcore_cmd_tlv.c +++ b/drivers/ub/urma/ubcore/ubcore_cmd_tlv.c @@ -67,14 +67,40 @@ static void ubcore_set_topo_fill_spec_in(void *arg_addr, SPEC(s++, SET_TOPO_IN_TOPO_NUM, arg->in.topo_num); } +static void ubcore_get_route_list_fill_spec_in(void *arg_addr, + struct ubcore_cmd_spec *spec) +{ + struct ubcore_cmd_get_route_list *arg = arg_addr; + struct ubcore_cmd_spec *s = spec; + + SPEC(s++, GET_ROUTE_LIST_IN_ROUTE_PAIR, arg->in); +} + +static void ubcore_get_route_list_fill_spec_out(void *arg_addr, + struct ubcore_cmd_spec *spec) +{ + struct ubcore_cmd_get_route_list *arg = arg_addr; + struct ubcore_cmd_spec *s = spec; + + SPEC(s++, GET_ROUTE_LIST_OUT_ROUTE_LIST, arg->out); +} + static struct ubcore_tlv_handler - g_global_tlv_handler[] = { [0] = { 0 }, - [UBCORE_CMD_SET_TOPO] = { - ubcore_set_topo_fill_spec_in, - SET_TOPO_IN_NUM, - NULL, - 0, - } }; + g_global_tlv_handler[] = { + [0] = { 0 }, + [UBCORE_CMD_SET_TOPO] = { + ubcore_set_topo_fill_spec_in, + SET_TOPO_IN_NUM, + NULL, + 0, + }, + [UBCORE_CMD_GET_ROUTE_LIST] = { + ubcore_get_route_list_fill_spec_in, + GET_ROUTE_LIST_IN_NUM, + ubcore_get_route_list_fill_spec_out, + GET_ROUTE_LIST_OUT_NUM, + } + }; static struct ubcore_cmd_attr * ubcore_create_tlv_attr(struct ubcore_cmd_hdr *hdr, uint32_t *attr_size) diff --git a/drivers/ub/urma/ubcore/ubcore_cmd_tlv.h b/drivers/ub/urma/ubcore/ubcore_cmd_tlv.h index 5c0ff8832a96..7df1ebc819cb 100644 --- a/drivers/ub/urma/ubcore/ubcore_cmd_tlv.h +++ b/drivers/ub/urma/ubcore/ubcore_cmd_tlv.h @@ -907,6 +907,14 @@ enum ubcore_cmd_set_topo_type { SET_TOPO_IN_NUM /* Only for calculating number of types */ }; +enum ubcore_get_route_list_type { + GET_ROUTE_LIST_IN_ROUTE_PAIR, + GET_ROUTE_LIST_IN_NUM, + + GET_ROUTE_LIST_OUT_ROUTE_LIST = UBCORE_CMD_OUT_TYPE_INIT, + GET_ROUTE_LIST_OUT_NUM, +}; + int ubcore_mue_tlv_parse(struct ubcore_cmd_hdr *hdr, void *arg); int ubcore_mue_tlv_append(struct ubcore_cmd_hdr *hdr, void *arg); int ubcore_global_tlv_parse(struct ubcore_cmd_hdr *hdr, void *arg); diff --git a/drivers/ub/urma/ubcore/ubcore_topo_info.c b/drivers/ub/urma/ubcore/ubcore_topo_info.c index f21a6b426810..e4a09f08e816 100644 --- a/drivers/ub/urma/ubcore/ubcore_topo_info.c +++ b/drivers/ub/urma/ubcore/ubcore_topo_info.c @@ -11,8 +11,9 @@ #include #include -#include "ubcore_log.h" #include +#include +#include "ubcore_log.h" #include "ubcore_topo_info.h" static struct ubcore_topo_map *g_ubcore_topo_map; @@ -324,9 +325,8 @@ static struct ubcore_topo_info * return NULL; } -static int ubcore_get_topo_port_eid(union ubcore_eid *src_v_eid, - union ubcore_eid *dst_v_eid, union ubcore_eid *src_p_eid, - union ubcore_eid *dst_p_eid) +static int ubcore_get_route_port_eid(union ubcore_eid *src_v_eid, + union ubcore_eid *dst_v_eid, struct ubcore_route_list *route_list) { struct ubcore_topo_info *src_topo_info = NULL; struct ubcore_topo_info *dst_topo_info = NULL; @@ -345,48 +345,39 @@ static int ubcore_get_topo_port_eid(union ubcore_eid *src_v_eid, ubcore_log_err("Failed to get dst_topo_info.\n"); return -EINVAL; } + uint32_t *len = &route_list->route_num; + uint32_t sz = *len; - /* loop up in source topo info */ - for (i = 0; i < MAX_PORT_NUM; i++) { - if (!is_eid_valid(src_topo_info->io_die_info[0].port_eid[i]) || - !is_eid_valid(src_topo_info->io_die_info[0].peer_port_eid[i])) { - continue; - } - for (j = 0; j < MAX_PORT_NUM; j++) { - if (compare_eids(src_topo_info->io_die_info[0].peer_port_eid[i], - dst_topo_info->io_die_info[0].port_eid[j])) { - (void)memcpy(src_p_eid, - src_topo_info->io_die_info[0].port_eid[i], EID_LEN); - (void)memcpy(dst_p_eid, - src_topo_info->io_die_info[0].peer_port_eid[i], EID_LEN); - return 0; + for (int k = 0; k < IODIE_NUM; k++) { + for (i = 0; i < MAX_PORT_NUM; i++) { + if (!is_eid_valid(src_topo_info->io_die_info[k].port_eid[i]) || + !is_eid_valid(src_topo_info->io_die_info[k].peer_port_eid[i])) { + continue; } - } - } - - /* loop up in dest topo info */ - for (i = 0; i < MAX_PORT_NUM; i++) { - if (!is_eid_valid(dst_topo_info->io_die_info[0].port_eid[i]) || - !is_eid_valid(dst_topo_info->io_die_info[0].peer_port_eid[i])) { - continue; - } - for (j = 0; j < MAX_PORT_NUM; j++) { - if (compare_eids( - dst_topo_info->io_die_info[0].peer_port_eid[i], - src_topo_info->io_die_info[0].port_eid[j])) { - (void)memcpy(src_p_eid, - dst_topo_info->io_die_info[0].peer_port_eid[i], EID_LEN); - (void)memcpy(dst_p_eid, - dst_topo_info->io_die_info[0].port_eid[i], EID_LEN); - return 0; + for (j = 0; j < MAX_PORT_NUM; j++) { + if (compare_eids( + src_topo_info->io_die_info[k].peer_port_eid[i], + dst_topo_info->io_die_info[k].port_eid[j])) { + route_list->buf[*len].src = *(union ubcore_eid *) + src_topo_info->io_die_info[k].port_eid[i]; + route_list->buf[*len].dst = *(union ubcore_eid *) + src_topo_info->io_die_info[k].peer_port_eid[i]; + route_list->buf[*len].flag.bs.rtp = 1; + route_list->buf[*len].flag.bs.utp = 1; + route_list->buf[*len].flag.bs.ctp = 1; + (void) *len++; + } } } } - - ubcore_log_err( - "Failed to get topo port eid, src_v_eid: "EID_FMT", dst_v_eid: "EID_FMT".\n", - EID_ARGS(*src_v_eid), EID_ARGS(*dst_v_eid)); - return -EINVAL; + if (*len == sz) { + ubcore_log_err( + "Failed to get topo port eid, src_v_eid: " EID_FMT "," + "dst_v_eid: "EID_FMT".\n", + EID_ARGS(*src_v_eid), EID_ARGS(*dst_v_eid)); + return -EINVAL; + } + return 0; } int ubcore_get_primary_eid_by_bonding_eid(union ubcore_eid *bonding_eid, @@ -412,42 +403,45 @@ int ubcore_get_primary_eid_by_bonding_eid(union ubcore_eid *bonding_eid, return -EINVAL; } -static int ubcore_get_topo_primary_eid(union ubcore_eid *src_v_eid, - union ubcore_eid *dst_v_eid, union ubcore_eid *src_p_eid, - union ubcore_eid *dst_p_eid) +static int ubcore_get_route_primary_eid(union ubcore_eid *src_v_eid, + union ubcore_eid *dst_v_eid, struct ubcore_route_list *route_list) { - int ret; - - ret = ubcore_get_primary_eid_by_bonding_eid(src_v_eid, src_p_eid); - if (ret != 0) { - ubcore_log_err( - "Failed to get src_p_eid, src_v_eid: "EID_FMT".\n", - EID_ARGS(*src_v_eid)); - return ret; - } - - ret = ubcore_get_primary_eid_by_bonding_eid(dst_v_eid, dst_p_eid); - if (ret != 0) { - ubcore_log_err( - "Failed to get dst_p_eid, dst_v_eid: "EID_FMT".\n", - EID_ARGS(*dst_v_eid)); - return ret; + uint32_t *len = &route_list->route_num; + uint32_t sz = *len; + struct ubcore_topo_info *topo_info = g_ubcore_topo_map->topo_infos; + + for (int k = 0; k < IODIE_NUM; k++) { + for (int i = 0; i < g_ubcore_topo_map->node_num; i++) { + if (!memcmp(src_v_eid, topo_info[i].bonding_eid, + sizeof(*src_v_eid))) { + route_list->buf[*len].flag.bs.ctp = 1; + route_list->buf[*len].src = *(union ubcore_eid *) + topo_info[i].io_die_info[k].primary_eid; + } + if (!memcmp(dst_v_eid, topo_info[i].bonding_eid, + sizeof(*dst_v_eid))) { + route_list->buf[*len].dst = *(union ubcore_eid *) + topo_info[i].io_die_info[k].primary_eid; + (void) *len++; + } + } } - - return 0; + return (*len == sz) ? -EINVAL : 0; } -int ubcore_get_topo_eid(uint32_t tp_type, union ubcore_eid *src_v_eid, - union ubcore_eid *dst_v_eid, union ubcore_eid *src_p_eid, - union ubcore_eid *dst_p_eid) +int ubcore_get_route_list(struct ubcore_route *route, + struct ubcore_route_list *route_list) { int ret = 0; - if (!src_v_eid || !dst_v_eid || - !src_p_eid || !dst_p_eid) { + // check valid pointer to v_eid + if (IS_ERR_OR_NULL(route) || IS_ERR_OR_NULL(route_list)) { ubcore_log_err("Invalid parameter.\n"); return -EINVAL; } + union ubcore_eid *src_v_eid = &route->src; + union ubcore_eid *dst_v_eid = &route->dst; + uint32_t tp_type = route->flag.value; if (!g_ubcore_topo_map) { ubcore_log_err( @@ -458,12 +452,10 @@ int ubcore_get_topo_eid(uint32_t tp_type, union ubcore_eid *src_v_eid, switch (tp_type) { case UBCORE_RTP: case UBCORE_UTP: - ret = ubcore_get_topo_port_eid(src_v_eid, dst_v_eid, - src_p_eid, dst_p_eid); + ret = ubcore_get_route_port_eid(src_v_eid, dst_v_eid, route_list); break; case UBCORE_CTP: - ret = ubcore_get_topo_primary_eid(src_v_eid, dst_v_eid, - src_p_eid, dst_p_eid); + ret = ubcore_get_route_primary_eid(src_v_eid, dst_v_eid, route_list); break; default: ubcore_log_err("Invalid tp tpye: %u.\n", tp_type); @@ -472,4 +464,4 @@ int ubcore_get_topo_eid(uint32_t tp_type, union ubcore_eid *src_v_eid, return ret; } -EXPORT_SYMBOL(ubcore_get_topo_eid); +EXPORT_SYMBOL(ubcore_get_route_list); diff --git a/drivers/ub/urma/ubcore/ubcore_uvs_cmd.c b/drivers/ub/urma/ubcore/ubcore_uvs_cmd.c index 58415d6cef97..e33be9653314 100644 --- a/drivers/ub/urma/ubcore/ubcore_uvs_cmd.c +++ b/drivers/ub/urma/ubcore/ubcore_uvs_cmd.c @@ -276,6 +276,29 @@ static int ubcore_cmd_set_topo(struct ubcore_global_file *file, return 0; } +static int ubcore_cmd_get_route_list(struct ubcore_global_file *file, + struct ubcore_cmd_hdr *hdr) +{ + struct ubcore_cmd_get_route_list arg; + + int ret = 0; + + ret = ubcore_global_tlv_parse(hdr, (void *)&arg); + if (ret != 0) { + ubcore_log_err("Failed to parse ubcore cmd tlv.\n"); + return ret; + } + ret = ubcore_get_route_list(&arg.in, &arg.out); + if (ret != 0) { + ubcore_log_err("Failed to get_route_list, ret: %d.\n", ret); + return ret; + } + if (ubcore_global_tlv_append(hdr, (void *)&arg) != 0) + ret = -EPERM; + + return ret; +} + typedef int (*ubcore_uvs_global_cmd_handler)(struct ubcore_global_file *file, struct ubcore_cmd_hdr *hdr); struct ubcore_uvs_global_cmd_func { @@ -286,10 +309,11 @@ struct ubcore_uvs_global_cmd_func { static struct ubcore_uvs_global_cmd_func g_ubcore_uvs_global_cmd_funcs[] = { [0] = { NULL, false }, [UBCORE_CMD_SET_TOPO] = { ubcore_cmd_set_topo, true }, + [UBCORE_CMD_GET_ROUTE_LIST] = { ubcore_cmd_get_route_list, true}, }; int ubcore_uvs_global_cmd_parse(struct ubcore_global_file *file, - struct ubcore_cmd_hdr *hdr) + struct ubcore_cmd_hdr *hdr) { if (hdr->command < UBCORE_CMD_SET_TOPO || hdr->command >= UBCORE_CMD_GLOBAL_LAST || diff --git a/drivers/ub/urma/ubcore/ubcore_uvs_cmd.h b/drivers/ub/urma/ubcore/ubcore_uvs_cmd.h index 31ce8ae64642..f4e9bfb44a12 100644 --- a/drivers/ub/urma/ubcore/ubcore_uvs_cmd.h +++ b/drivers/ub/urma/ubcore/ubcore_uvs_cmd.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "ubcore_cmd.h" #include "ubcore_log.h" #include "ubcore_priv.h" @@ -27,7 +28,11 @@ #define UBCORE_MAX_DSCP_VL_NUM 64 #define UBCORE_CMD_MAX_MUE_NUM 128 -enum ubcore_uvs_global_cmd { UBCORE_CMD_SET_TOPO = 1, UBCORE_CMD_GLOBAL_LAST }; +enum ubcore_uvs_global_cmd { + UBCORE_CMD_SET_TOPO = 1, + UBCORE_CMD_GET_ROUTE_LIST = 2, + UBCORE_CMD_GLOBAL_LAST +}; struct ubcore_cmd_set_topo { struct { @@ -36,6 +41,11 @@ struct ubcore_cmd_set_topo { } in; }; +struct ubcore_cmd_get_route_list { + struct ubcore_route in; + struct ubcore_route_list out; +}; + int ubcore_uvs_mue_cmd_parse(struct ubcore_mue_file *file, struct ubcore_cmd_hdr *hdr); diff --git a/include/ub/urma/ubcore_uapi.h b/include/ub/urma/ubcore_uapi.h index f744eaa98b74..f41f3f536436 100644 --- a/include/ub/urma/ubcore_uapi.h +++ b/include/ub/urma/ubcore_uapi.h @@ -15,6 +15,29 @@ #define UBCORE_UAPI_H #include "ubcore_types.h" + +union ubcore_route_flag { + struct { + uint32_t rtp: 1; + uint32_t ctp: 1; + uint32_t utp: 1; + uint32_t reserved: 29; + } bs; + uint32_t value; +}; + +struct ubcore_route { + union ubcore_eid src; + union ubcore_eid dst; + union ubcore_route_flag flag; + uint32_t hops; // Only supports direct routes, currently 0. +}; + +struct ubcore_route_list { + uint32_t route_num; + struct ubcore_route buf[16]; +}; + /** * Application specifies the device to allocate an context. * @param[in] dev: ubcore_device found by add ops in the client. @@ -757,19 +780,15 @@ void ubcore_cgroup_uncharge(struct ubcore_cg_object *cg_obj, /** * Get primary or port eid from topo info - * @param[in] tp_type: tp type, 0-RTP, 1-CTP, 2-UTP, - * refer to enum ubcore_tp_type; - * @param[in] src_v_eid: source virtual eid, refer - * to source bonding eid; - * @param[in] dst_v_eid: dest virtual eid, refer to - * dest bonding eid; - * @param[out] src_p_eid: source physical eid, refer - * to source primary or port eid; - * @param[out] dst_p_eid: dest physical eid, refer - * to dest primary or port eid; - */ -int ubcore_get_topo_eid(uint32_t tp_type, union ubcore_eid *src_v_eid, - union ubcore_eid *dst_v_eid, union ubcore_eid *src_p_eid, - union ubcore_eid *dst_p_eid); + * @param[in] route_v: bonding route represented as a pair of eid, + * only src and dst is needed as input. + * refer to ubcore_route; + * @param[out] route_list: list of all ubcore_route, which is + * get from global topo_map. + * refer to source bonding eid; + * @return: 0 on success, other value on error + */ +int ubcore_get_route_list(struct ubcore_route *route_v, + struct ubcore_route_list *route_list); #endif -- Gitee From f4f8302c102798697b950ceab57ce207f7679e51 Mon Sep 17 00:00:00 2001 From: Wen Chen Date: Mon, 1 Dec 2025 20:11:03 +0800 Subject: [PATCH 2/8] urma: fixing ubcore hash table initialization failure. commit 46936650256695f9bc706eb7d586761eb6555628 openEuler This patch primarily addresses the issue of hash table entry failures The implementation provides the following key functionalities: 1. Adjust the hash type enumeration value. 2. Remove and deregister unused hash table entries. 3. The device's active TP and deactive TP logic is inverted, causing the interception to fail. 4. Fixed the failure of user-space calls to the set_tp/get_tp interface. Signed-off-by: Wen Chen Signed-off-by: Yongqiang Guo --- .../ub/urma/ubcore/ubcore_connect_adapter.c | 4 +- drivers/ub/urma/ubcore/ubcore_device.c | 57 +---------------- drivers/ub/urma/ubcore/ubcore_jetty.c | 2 +- drivers/ub/urma/uburma/uburma_cmd.c | 64 +++++++++++++++++++ 4 files changed, 69 insertions(+), 58 deletions(-) diff --git a/drivers/ub/urma/ubcore/ubcore_connect_adapter.c b/drivers/ub/urma/ubcore/ubcore_connect_adapter.c index b4a0f0b96c85..dbb8dccd68ef 100644 --- a/drivers/ub/urma/ubcore/ubcore_connect_adapter.c +++ b/drivers/ub/urma/ubcore/ubcore_connect_adapter.c @@ -52,7 +52,7 @@ static int ubcore_active_tp(struct ubcore_device *dev, { int ret; - if (!dev || !dev->ops || dev->ops->active_tp || + if (!dev || !dev->ops || !dev->ops->active_tp || active_cfg == NULL) { ubcore_log_err("Invalid parameter.\n"); return -EINVAL; @@ -76,7 +76,7 @@ static int ubcore_deactive_tp(struct ubcore_device *dev, { int ret; - if (!dev || !dev->ops || dev->ops->active_tp) { + if (!dev || !dev->ops || !dev->ops->deactive_tp) { ubcore_log_err("Invalid parameter.\n"); return -EINVAL; } diff --git a/drivers/ub/urma/ubcore/ubcore_device.c b/drivers/ub/urma/ubcore/ubcore_device.c index 213cce97f809..6170ad347863 100644 --- a/drivers/ub/urma/ubcore/ubcore_device.c +++ b/drivers/ub/urma/ubcore/ubcore_device.c @@ -624,6 +624,8 @@ static int ubcore_alloc_hash_tables(struct ubcore_device *dev) ubcore_update_hash_tables_size(&dev->attr.dev_cap); for (i = 0; i < ARRAY_SIZE(g_ht_params); i++) { + if (g_ht_params[i].size == 0) + continue; ret = ubcore_hash_table_alloc(&dev->ht[i], &g_ht_params[i]); if (ret != 0) { ubcore_log_err("alloc hash tables failed.\n"); @@ -639,60 +641,6 @@ static int ubcore_alloc_hash_tables(struct ubcore_device *dev) return -1; } -static void ubcore_destroy_vtp_in_unreg_dev(void *arg) -{ - struct ubcore_vtp *vtp = (struct ubcore_vtp *)arg; - - if (vtp->cfg.vtpn != UINT_MAX && vtp->ub_dev->ops->destroy_vtp != NULL) - (void)vtp->ub_dev->ops->destroy_vtp(vtp); - else - kfree(vtp); -} - -static void ubcore_destroy_tp_in_unreg_dev(void *arg) -{ - struct ubcore_tp *tp = (struct ubcore_tp *)arg; - - if (tp->ub_dev->ops->destroy_tp != NULL) - (void)tp->ub_dev->ops->destroy_tp(tp); -} - -static void ubcore_destroy_utp_in_unreg_dev(void *arg) -{ - struct ubcore_utp *utp = (struct ubcore_utp *)arg; - - if (utp->ub_dev->ops->destroy_utp != NULL) - (void)utp->ub_dev->ops->destroy_utp(utp); -} - -static void ubcore_destroy_tpg_in_unreg_dev(void *arg) -{ - struct ubcore_tpg *tpg = (struct ubcore_tpg *)arg; - - if (tpg->ub_dev->ops->destroy_tpg != NULL) - (void)tpg->ub_dev->ops->destroy_tpg(tpg); -} - -static void ubcore_free_driver_res(struct ubcore_device *dev) -{ - if (!dev->attr.tp_maintainer) - return; - - ubcore_hash_table_free_with_cb(&dev->ht[UBCORE_HT_RM_VTP], - ubcore_destroy_vtp_in_unreg_dev); - ubcore_hash_table_free_with_cb(&dev->ht[UBCORE_HT_RC_VTP], - ubcore_destroy_vtp_in_unreg_dev); - ubcore_hash_table_free_with_cb(&dev->ht[UBCORE_HT_UM_VTP], - ubcore_destroy_vtp_in_unreg_dev); - ubcore_hash_table_free_with_cb(&dev->ht[UBCORE_HT_TP], - ubcore_destroy_tp_in_unreg_dev); - ubcore_hash_table_free_with_cb(&dev->ht[UBCORE_HT_UTP], - ubcore_destroy_utp_in_unreg_dev); - - ubcore_hash_table_free_with_cb(&dev->ht[UBCORE_HT_TPG], - ubcore_destroy_tpg_in_unreg_dev); -} - static void ubcore_free_hash_tables(struct ubcore_device *dev) { uint32_t i; @@ -928,7 +876,6 @@ static int init_ubcore_device(struct ubcore_device *dev) static void uninit_ubcore_device(struct ubcore_device *dev) { mutex_destroy(&dev->ldev_mutex); - ubcore_free_driver_res(dev); ubcore_free_hash_tables(dev); ubcore_destroy_eidtable(dev); uninit_ubcore_mue(dev); diff --git a/drivers/ub/urma/ubcore/ubcore_jetty.c b/drivers/ub/urma/ubcore/ubcore_jetty.c index efa5c2163ad8..3d630a5d30cf 100644 --- a/drivers/ub/urma/ubcore/ubcore_jetty.c +++ b/drivers/ub/urma/ubcore/ubcore_jetty.c @@ -1938,7 +1938,7 @@ int ubcore_bind_jetty_ex(struct ubcore_jetty *jetty, struct ubcore_active_tp_cfg *active_tp_cfg, struct ubcore_udata *udata) { - if (!jetty || !tjetty || jetty->ub_dev || + if (!jetty || !tjetty || !jetty->ub_dev || !jetty->ub_dev->ops || !active_tp_cfg) { ubcore_log_err("Invalid parameter.\n"); return -EINVAL; diff --git a/drivers/ub/urma/uburma/uburma_cmd.c b/drivers/ub/urma/uburma/uburma_cmd.c index 79cbb7a999dd..4bf939a8fc3b 100644 --- a/drivers/ub/urma/uburma/uburma_cmd.c +++ b/drivers/ub/urma/uburma/uburma_cmd.c @@ -2990,6 +2990,68 @@ static int uburma_cmd_get_tp_list(struct ubcore_device *ubc_dev, return ret; } +static int uburma_cmd_set_tp_attr(struct ubcore_device *ubc_dev, + struct uburma_file *file, + struct uburma_cmd_hdr *hdr) +{ + struct ubcore_tp_attr_value tp_attr = { 0 }; + struct uburma_cmd_set_tp_attr arg = { 0 }; + struct ubcore_udata udata = { 0 }; + int ret; + + ret = uburma_tlv_parse(hdr, &arg); + if (ret != 0) + return ret; + + if (sizeof(arg.in.tp_attr) != sizeof(struct ubcore_tp_attr_value)) { + uburma_log_err("Invalid parameter.\n"); + return -EINVAL; + } + fill_udata(&udata, file->ucontext, &arg.udata); + (void)memcpy(&tp_attr, arg.in.tp_attr, sizeof(arg.in.tp_attr)); + + ret = ubcore_set_tp_attr(ubc_dev, arg.in.tp_handle, arg.in.tp_attr_cnt, + arg.in.tp_attr_bitmap, &tp_attr, &udata); + if (ret != 0) + uburma_log_err( + "Failed to set tp attribution values, ret: %d.\n", ret); + + return ret; +} + +static int uburma_cmd_get_tp_attr(struct ubcore_device *ubc_dev, + struct uburma_file *file, + struct uburma_cmd_hdr *hdr) +{ + struct ubcore_tp_attr_value tp_attr = { 0 }; + struct uburma_cmd_get_tp_attr arg = { 0 }; + struct ubcore_udata udata = { 0 }; + int ret; + + ret = uburma_tlv_parse(hdr, &arg); + if (ret != 0) + return ret; + + if (sizeof(arg.out.tp_attr) != sizeof(struct ubcore_tp_attr_value)) { + uburma_log_err("Invalid parameter.\n"); + return -EINVAL; + } + fill_udata(&udata, file->ucontext, &arg.udata); + + ret = ubcore_get_tp_attr(ubc_dev, arg.in.tp_handle, + &arg.out.tp_attr_cnt, &arg.out.tp_attr_bitmap, + &tp_attr, &udata); + if (ret != 0) { + uburma_log_err( + "Failed to get tp attribution values, ret: %d.\n", ret); + return ret; + } + (void)memcpy(arg.out.tp_attr, &tp_attr, + sizeof(struct ubcore_tp_attr_value)); + + return uburma_tlv_append(hdr, &arg); +} + static int uburma_cmd_exchange_tp_info(struct ubcore_device *ubc_dev, struct uburma_file *file, struct uburma_cmd_hdr *hdr) @@ -3139,6 +3201,8 @@ static uburma_cmd_handler g_uburma_cmd_handlers[] = { [UBURMA_CMD_DELETE_JFR_BATCH] = uburma_cmd_delete_jfr_batch, [UBURMA_CMD_DELETE_JFC_BATCH] = uburma_cmd_delete_jfc_batch, [UBURMA_CMD_DELETE_JETTY_BATCH] = uburma_cmd_delete_jetty_batch, + [UBURMA_CMD_SET_TP_ATTR] = uburma_cmd_set_tp_attr, + [UBURMA_CMD_GET_TP_ATTR] = uburma_cmd_get_tp_attr, [UBURMA_CMD_EXCHANGE_TP_INFO] = uburma_cmd_exchange_tp_info, }; -- Gitee From 279ee267b44b3597afe8fba2c0e9d74bf5318a76 Mon Sep 17 00:00:00 2001 From: Wen Chen Date: Tue, 2 Dec 2025 22:07:26 +0800 Subject: [PATCH 3/8] urma: bugfix ubagg drivers refent error commit c25f37d4e464aa730f453f85c5389ff158b76ab9 openEuler This patch primarily fixes the ubagg driver referent exception issue. The implementation provides the following key functionalities: 1. uburma_open did not call module_get, causing an error in resource reference counting. Signed-off-by: Wen Chen Signed-off-by: Yongqiang Guo --- drivers/ub/urma/uburma/uburma_dev_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ub/urma/uburma/uburma_dev_ops.c b/drivers/ub/urma/uburma/uburma_dev_ops.c index 1e9cc302deed..3e7693b422dd 100644 --- a/drivers/ub/urma/uburma/uburma_dev_ops.c +++ b/drivers/ub/urma/uburma/uburma_dev_ops.c @@ -145,7 +145,7 @@ void uburma_release_file(struct kref *ref) ubc_dev = srcu_dereference(file->ubu_dev->ubc_dev, &file->ubu_dev->ubc_dev_srcu); if (ubc_dev && !ubc_dev->ops->disassociate_ucontext && - ubc_dev->ops->owner != NULL) + ubc_dev->ops->owner) module_put(ubc_dev->ops->owner); srcu_read_unlock(&file->ubu_dev->ubc_dev_srcu, srcu_idx); @@ -184,7 +184,7 @@ int uburma_open(struct inode *inode, struct file *filp) } if (!ubc_dev->ops->disassociate_ucontext && - !ubc_dev->ops->owner) { + ubc_dev->ops->owner) { if (!try_module_get(ubc_dev->ops->owner)) { ret = -ENODEV; goto err; -- Gitee From 36dd726d77b7fb211296e4d43f2484f7d0b63d5b Mon Sep 17 00:00:00 2001 From: chenyutao Date: Thu, 4 Dec 2025 13:26:26 +0800 Subject: [PATCH 4/8] urma: Bugfix for ubcore_get_route_list implement commit 3868a60b7f0383777da1f38f7bf1e64c72691920 openEuler The inplementation includes: 1. Bugfix for ubcore_get_route_list implement. Fixes: c78127c4b6eb ("ubcore: fix query route list by eid pair.") Signed-off-by: chenyutao Signed-off-by: Yongqiang Guo --- drivers/ub/urma/ubcore/ubcore_topo_info.c | 121 ++++++++++++++-------- include/ub/urma/ubcore_types.h | 1 + include/ub/urma/ubcore_uapi.h | 2 +- 3 files changed, 79 insertions(+), 45 deletions(-) diff --git a/drivers/ub/urma/ubcore/ubcore_topo_info.c b/drivers/ub/urma/ubcore/ubcore_topo_info.c index e4a09f08e816..20ad3e79ae45 100644 --- a/drivers/ub/urma/ubcore/ubcore_topo_info.c +++ b/drivers/ub/urma/ubcore/ubcore_topo_info.c @@ -330,6 +330,7 @@ static int ubcore_get_route_port_eid(union ubcore_eid *src_v_eid, { struct ubcore_topo_info *src_topo_info = NULL; struct ubcore_topo_info *dst_topo_info = NULL; + uint32_t num = route_list->route_num; int i, j; src_topo_info = @@ -345,8 +346,6 @@ static int ubcore_get_route_port_eid(union ubcore_eid *src_v_eid, ubcore_log_err("Failed to get dst_topo_info.\n"); return -EINVAL; } - uint32_t *len = &route_list->route_num; - uint32_t sz = *len; for (int k = 0; k < IODIE_NUM; k++) { for (i = 0; i < MAX_PORT_NUM; i++) { @@ -355,28 +354,35 @@ static int ubcore_get_route_port_eid(union ubcore_eid *src_v_eid, continue; } for (j = 0; j < MAX_PORT_NUM; j++) { + if (num >= UBCORE_MAX_ROUTE_NUM) { + ubcore_log_warn("Invalid route num.\n"); + return -EINVAL; + } if (compare_eids( src_topo_info->io_die_info[k].peer_port_eid[i], dst_topo_info->io_die_info[k].port_eid[j])) { - route_list->buf[*len].src = *(union ubcore_eid *) - src_topo_info->io_die_info[k].port_eid[i]; - route_list->buf[*len].dst = *(union ubcore_eid *) - src_topo_info->io_die_info[k].peer_port_eid[i]; - route_list->buf[*len].flag.bs.rtp = 1; - route_list->buf[*len].flag.bs.utp = 1; - route_list->buf[*len].flag.bs.ctp = 1; - (void) *len++; + (void)memcpy(&route_list->buf[num].src, + src_topo_info->io_die_info[k].port_eid[i], + sizeof(union ubcore_eid)); + (void)memcpy(&route_list->buf[num].dst, + src_topo_info->io_die_info[k].peer_port_eid[i], + sizeof(union ubcore_eid)); + route_list->buf[num].flag.bs.rtp = 1; + route_list->buf[num].flag.bs.ctp = 1; + route_list->buf[num].flag.bs.utp = 1; + num++; } } } } - if (*len == sz) { + + if (route_list->route_num == num) { ubcore_log_err( - "Failed to get topo port eid, src_v_eid: " EID_FMT "," - "dst_v_eid: "EID_FMT".\n", - EID_ARGS(*src_v_eid), EID_ARGS(*dst_v_eid)); + "Failed to get topo port eid, route_num: %u.\n", num); return -EINVAL; } + + route_list->route_num = num; return 0; } @@ -406,27 +412,52 @@ int ubcore_get_primary_eid_by_bonding_eid(union ubcore_eid *bonding_eid, static int ubcore_get_route_primary_eid(union ubcore_eid *src_v_eid, union ubcore_eid *dst_v_eid, struct ubcore_route_list *route_list) { - uint32_t *len = &route_list->route_num; - uint32_t sz = *len; + uint32_t num = route_list->route_num; struct ubcore_topo_info *topo_info = g_ubcore_topo_map->topo_infos; + bool src_match = false; + bool dst_match = false; - for (int k = 0; k < IODIE_NUM; k++) { - for (int i = 0; i < g_ubcore_topo_map->node_num; i++) { - if (!memcmp(src_v_eid, topo_info[i].bonding_eid, - sizeof(*src_v_eid))) { - route_list->buf[*len].flag.bs.ctp = 1; - route_list->buf[*len].src = *(union ubcore_eid *) - topo_info[i].io_die_info[k].primary_eid; - } - if (!memcmp(dst_v_eid, topo_info[i].bonding_eid, - sizeof(*dst_v_eid))) { - route_list->buf[*len].dst = *(union ubcore_eid *) - topo_info[i].io_die_info[k].primary_eid; - (void) *len++; - } + for (int i = 0; i < g_ubcore_topo_map->node_num; i++) { + if (num >= UBCORE_MAX_ROUTE_NUM - 1 || i >= IODIE_NUM) { + ubcore_log_warn("Finish to query topo map.\n"); + return -EINVAL; + } + if (!memcmp(src_v_eid, topo_info[i].bonding_eid, + sizeof(*src_v_eid))) { + route_list->buf[num].flag.bs.ctp = 1; + route_list->buf[num + 1].flag.bs.ctp = 1; + route_list->buf[num].hops = 0; + route_list->buf[num + 1].hops = 0; + (void)memcpy(&route_list->buf[num].src, + topo_info[i].io_die_info[0].primary_eid, + sizeof(union ubcore_eid)); + (void)memcpy(&route_list->buf[num + 1].src, + topo_info[i].io_die_info[1].primary_eid, + sizeof(union ubcore_eid)); + src_match = true; + } + if (!memcmp(dst_v_eid, topo_info[i].bonding_eid, + sizeof(*dst_v_eid))) { + route_list->buf[num].flag.bs.ctp = 1; + route_list->buf[num + 1].flag.bs.ctp = 1; + route_list->buf[num].hops = 0; + route_list->buf[num + 1].hops = 0; + (void)memcpy(&route_list->buf[num].dst, + topo_info[i].io_die_info[0].primary_eid, + sizeof(union ubcore_eid)); + (void)memcpy(&route_list->buf[num + 1].dst, + topo_info[i].io_die_info[1].primary_eid, + sizeof(union ubcore_eid)); + dst_match = true; + } + if (src_match && dst_match) { + num += 2; + break; } } - return (*len == sz) ? -EINVAL : 0; + + route_list->route_num = num; + return (num == 0) ? -EINVAL : 0; } int ubcore_get_route_list(struct ubcore_route *route, @@ -441,7 +472,6 @@ int ubcore_get_route_list(struct ubcore_route *route, } union ubcore_eid *src_v_eid = &route->src; union ubcore_eid *dst_v_eid = &route->dst; - uint32_t tp_type = route->flag.value; if (!g_ubcore_topo_map) { ubcore_log_err( @@ -449,19 +479,22 @@ int ubcore_get_route_list(struct ubcore_route *route, return -EINVAL; } - switch (tp_type) { - case UBCORE_RTP: - case UBCORE_UTP: - ret = ubcore_get_route_port_eid(src_v_eid, dst_v_eid, route_list); - break; - case UBCORE_CTP: - ret = ubcore_get_route_primary_eid(src_v_eid, dst_v_eid, route_list); - break; - default: - ubcore_log_err("Invalid tp tpye: %u.\n", tp_type); - return -EINVAL; + (void)memset(route_list, 0, sizeof(struct ubcore_route_list)); + + ret = ubcore_get_route_primary_eid(src_v_eid, dst_v_eid, route_list); + if (ret != 0) { + ubcore_log_err("Failed to get primary eid, ret: %d.\n", ret); + return ret; } - return ret; + ret = ubcore_get_route_port_eid(src_v_eid, dst_v_eid, route_list); + if (ret != 0) { + ubcore_log_err("Failed to get port eid, ret: %d.\n", ret); + return ret; + } + + ubcore_log_info("Finish to query primary port eid, route_num: %u.\n", + route_list->route_num); + return 0; } EXPORT_SYMBOL(ubcore_get_route_list); diff --git a/include/ub/urma/ubcore_types.h b/include/ub/urma/ubcore_types.h index 15070a50d1de..b2563d84cb5c 100644 --- a/include/ub/urma/ubcore_types.h +++ b/include/ub/urma/ubcore_types.h @@ -81,6 +81,7 @@ ((ptr) == NULL ? ERR_PTR(-(err)) : (ptr)) #define UBCORE_MAX_DSCP_NUM (64) +#define UBCORE_MAX_ROUTE_NUM 16 enum ubcore_transport_type { UBCORE_TRANSPORT_INVALID = -1, diff --git a/include/ub/urma/ubcore_uapi.h b/include/ub/urma/ubcore_uapi.h index f41f3f536436..666ac3be990b 100644 --- a/include/ub/urma/ubcore_uapi.h +++ b/include/ub/urma/ubcore_uapi.h @@ -35,7 +35,7 @@ struct ubcore_route { struct ubcore_route_list { uint32_t route_num; - struct ubcore_route buf[16]; + struct ubcore_route buf[UBCORE_MAX_ROUTE_NUM]; }; /** -- Gitee From ec5ea2e35fe1257a707e67ba37790ec6480770a7 Mon Sep 17 00:00:00 2001 From: Wen Chen Date: Wed, 10 Dec 2025 10:07:54 +0800 Subject: [PATCH 5/8] urma: fixed process exiting uburma driver's private memory UAF commit 9b424fbe748154d8ceb161ce126d5d7331c82797 openEuler 1. This patch primarily modifies uburma private resource management and logging (DFX). The implementation provides the following key functionalities: 1. Modifies the opening, releasing, and unmapping of uburma umap. 2. Modifies the default warning in ubcm logging; adds log level settings to ubcore. 3. Supports write atomic semantics. Fixes: c25f37d4e464 ("urma: bugfix ubagg drivers refent error") Signed-off-by: Wen Chen Signed-off-by: Yongqiang Guo --- drivers/ub/urma/ubcore/ubcm/ubcm_log.c | 2 +- drivers/ub/urma/ubcore/ubcm/ubmad_datapath.c | 24 +++--- drivers/ub/urma/ubcore/ubcore_main.c | 6 +- drivers/ub/urma/uburma/uburma_mmap.c | 82 +++++++------------- include/ub/urma/ubcore_opcode.h | 1 + include/ub/urma/ubcore_types.h | 6 +- 6 files changed, 53 insertions(+), 68 deletions(-) diff --git a/drivers/ub/urma/ubcore/ubcm/ubcm_log.c b/drivers/ub/urma/ubcore/ubcm/ubcm_log.c index dd0154308276..1d462e4e632b 100644 --- a/drivers/ub/urma/ubcore/ubcm/ubcm_log.c +++ b/drivers/ub/urma/ubcore/ubcm/ubcm_log.c @@ -12,4 +12,4 @@ #include #include "ubcm_log.h" -uint32_t g_ubcm_log_level = UBCM_LOG_LEVEL_INFO; +uint32_t g_ubcm_log_level = UBCM_LOG_LEVEL_WARNING; diff --git a/drivers/ub/urma/ubcore/ubcm/ubmad_datapath.c b/drivers/ub/urma/ubcore/ubcm/ubmad_datapath.c index e6897e29c62c..e0e45948a8de 100644 --- a/drivers/ub/urma/ubcore/ubcm/ubmad_datapath.c +++ b/drivers/ub/urma/ubcore/ubcm/ubmad_datapath.c @@ -121,7 +121,7 @@ static void ubmad_rt_work_handler(struct work_struct *work) ubcm_log_err("repost send failed. msg type %d msn %llu\n", msg->msg_type, msg->msn); } - ubcm_log_info("Do not repost, found: %u, rt_work->rt_cnt: %u.\n", + ubcm_log_info_rl("Do not repost, found: %u, rt_work->rt_cnt: %u.\n", (uint32_t)found, rt_work->rt_cnt); /* not found OR repost failed @@ -369,7 +369,7 @@ static int ubmad_do_post_send_conn_data(struct ubcore_jetty *jetty, goto destroy_msn_node; } - ubcm_log_info("send conn data successfully. msn %llu eid " EID_FMT "\n", + ubcm_log_info_rl("send conn data successfully. msn %llu eid " EID_FMT "\n", msn, EID_ARGS(*dst_eid)); return 0; @@ -587,7 +587,7 @@ int ubmad_repost_send_conn_data(struct ubcore_jetty *jetty, return -1; } - ubcm_log_info("send conn data successfully. msn %llu eid " EID_FMT "\n", + ubcm_log_info_rl("send conn data successfully. msn %llu eid " EID_FMT "\n", msn, EID_ARGS(*dst_eid)); return 0; } @@ -603,7 +603,7 @@ int ubmad_repost_send(struct ubmad_msg *msg, struct ubmad_tjetty *tjetty, struct ubcore_jfs_wr jfs_wr = { 0 }; int ret; - ubcm_log_info("timeout and repost. msn %llu eid " EID_FMT "\n", + ubcm_log_info_rl("timeout and repost. msn %llu eid " EID_FMT "\n", msg->msn, EID_ARGS(*dst_eid)); // prepare wr @@ -802,7 +802,7 @@ static int ubmad_process_conn_data(struct ubcore_cr *cr, } } - ubcm_log_info( + ubcm_log_info_rl( "Finish to recv request. msn %llu right_end %llu, seid " EID_FMT "\n", msg->msn, seid_node->rx_bitmap->right_end, EID_ARGS(*seid)); @@ -854,12 +854,12 @@ static void ubmad_process_conn_ack(struct ubcore_cr *cr, } spin_unlock_irqrestore(&msn_mgr->msn_hlist_lock, flag); // msn_node not in msn_hlist, indicates already removed by previous ack with same msn - ubcm_log_info("redundant ack. msn %llu seid " EID_FMT "\n", msg->msn, + ubcm_log_info_rl("redundant ack. msn %llu seid " EID_FMT "\n", msg->msn, EID_ARGS(*seid)); put_tjetty: ubmad_put_tjetty(tjetty); - ubcm_log_info("recv conn ack. msn %llu seid " EID_FMT "\n", msg->msn, + ubcm_log_info_rl("recv conn ack. msn %llu seid " EID_FMT "\n", msg->msn, EID_ARGS(*seid)); } @@ -887,7 +887,7 @@ static inline void ubmad_process_close_req(struct ubcore_cr *cr, ubmad_remove_tjetty(&cr->remote_id.eid, rsrc); ubmad_delete_seid_node(&cr->remote_id.eid, rsrc); - ubcm_log_info("Finish to process close request, remote eid: " EID_FMT + ubcm_log_info_rl("Finish to process close request, remote eid: " EID_FMT ", remote id: %u.\n", EID_ARGS(cr->remote_id.eid), cr->remote_id.id); } @@ -965,7 +965,7 @@ int ubmad_ubc_send(struct ubcore_device *device, send_buf->src_eid = dev_priv->eid_info.eid; ubmad_put_device_priv(dev_priv); - ubcm_log_info("ubc dev: %s, s_eid: " EID_FMT ", d_eid: " EID_FMT " ", + ubcm_log_info_rl("ubc dev: %s, s_eid: " EID_FMT ", d_eid: " EID_FMT " ", device->dev_name, EID_ARGS(send_buf->src_eid), EID_ARGS(send_buf->dst_eid)); @@ -1043,7 +1043,7 @@ static void ubmad_send_work_handler(struct ubmad_device_priv *dev_priv, } while (cr_cnt > 0); ret = ubcore_rearm_jfc(jfc, false); - ubcm_log_info("Rearm send jfc, jfc_id: %u, ret: %d.\n", jfc->id, ret); + ubcm_log_info_rl("Rearm send jfc, jfc_id: %u, ret: %d.\n", jfc->id, ret); } // polling here indicates if recv msg @@ -1106,7 +1106,7 @@ static void ubmad_recv_work_handler(struct ubmad_device_priv *dev_priv, } while (cr_cnt > 0); ret = ubcore_rearm_jfc(jfc, false); - ubcm_log_info("Rearm recv jfc, jfc_id: %u, ret: %d.\n", jfc->id, ret); + ubcm_log_info_rl("Rearm recv jfc, jfc_id: %u, ret: %d.\n", jfc->id, ret); } // continue from ubmad_jfce_handler() @@ -1164,7 +1164,7 @@ static void ubmad_jfce_handler(struct ubcore_jfc *jfc, jfc->ub_dev->dev_name); return; } - ubcm_log_info("Start to handle jfce, type: %d, jfc_id: %u.\n", type, jfc->id); + ubcm_log_info_rl("Start to handle jfce, type: %d, jfc_id: %u.\n", type, jfc->id); // free in ubmad_jfce_work_handler() jfce_work = kzalloc(sizeof(struct ubmad_jfce_work), GFP_ATOMIC); diff --git a/drivers/ub/urma/ubcore/ubcore_main.c b/drivers/ub/urma/ubcore/ubcore_main.c index b0cb2ca68823..2d090829e947 100644 --- a/drivers/ub/urma/ubcore/ubcore_main.c +++ b/drivers/ub/urma/ubcore/ubcore_main.c @@ -10,7 +10,6 @@ */ #include - #include "ubcore_main.h" #include "ubcore_log.h" #include "ubcore_workqueue.h" @@ -21,6 +20,11 @@ #include "ubcore_genl.h" #include "ubcm/ub_cm.h" +#define UBCORE_LOG_FILE_PERMISSION (0644) + +module_param(g_ubcore_log_level, uint, UBCORE_LOG_FILE_PERMISSION); +MODULE_PARM_DESC(g_ubcore_log_level, " 3: ERR, 4: WARNING, 6: INFO, 7: DEBUG"); + static int __init ubcore_init(void) { int ret; diff --git a/drivers/ub/urma/uburma/uburma_mmap.c b/drivers/ub/urma/uburma/uburma_mmap.c index c9ce4439b7a7..090fe4a05653 100644 --- a/drivers/ub/urma/uburma/uburma_mmap.c +++ b/drivers/ub/urma/uburma/uburma_mmap.c @@ -33,54 +33,43 @@ void uburma_umap_priv_init(struct uburma_umap_priv *priv, void uburma_unmap_vma_pages(struct uburma_file *ufile) { struct uburma_umap_priv *priv, *next_priv; - struct mm_struct *mm; + struct mm_struct *mm = NULL; + struct vm_area_struct *vma; int ret; if (list_empty(&ufile->umaps_list)) return; lockdep_assert_held(&ufile->cleanup_rwsem); - while (1) { - struct list_head local_list; - INIT_LIST_HEAD(&local_list); + while (1) { mm = NULL; mutex_lock(&ufile->umap_mutex); list_for_each_entry_safe(priv, next_priv, &ufile->umaps_list, node) { - struct mm_struct *curr_mm = priv->vma->vm_mm; - ret = mmget_not_zero(curr_mm); + mm = priv->vma->vm_mm; + ret = mmget_not_zero(mm); if (!ret) { list_del_init(&priv->node); + mm = NULL; continue; } - if (!mm) { - mm = curr_mm; - list_move_tail(&priv->node, &local_list); - } else if (curr_mm == mm) { - list_move_tail(&priv->node, &local_list); - } + break; } mutex_unlock(&ufile->umap_mutex); - - if (list_empty(&local_list)) { - if (mm) - mmput(mm); + if (!mm) return; - } mmap_read_lock(mm); - - list_for_each_entry_safe(priv, next_priv, &local_list, node) { - struct vm_area_struct *vma = priv->vma; - + mutex_lock(&ufile->umap_mutex); + list_for_each_entry_safe(priv, next_priv, &ufile->umaps_list, node) { + vma = priv->vma; + if (vma->vm_mm != mm) + continue; list_del_init(&priv->node); - if (vma->vm_mm == mm) { - vma->vm_private_data = NULL; - zap_vma_ptes(vma, vma->vm_start, - vma->vm_end - vma->vm_start); - } + zap_vma_ptes(vma, vma->vm_start, vma->vm_end - vma->vm_start); } + mutex_unlock(&ufile->umap_mutex); mmap_read_unlock(mm); mmput(mm); @@ -114,18 +103,14 @@ static void uburma_umap_open(struct vm_area_struct *vma) static void uburma_umap_close(struct vm_area_struct *vma) { struct uburma_file *ufile = vma->vm_file->private_data; - struct uburma_umap_priv *next_priv = NULL; - struct uburma_umap_priv *priv = NULL; + struct uburma_umap_priv *priv = vma->vm_private_data; + + if (!priv) + return; mutex_lock(&ufile->umap_mutex); - list_for_each_entry_safe(priv, next_priv, &ufile->umaps_list, node) { - if (priv->vma == vma) { - list_del_init(&priv->node); - break; - } - } + list_del(&priv->node); mutex_unlock(&ufile->umap_mutex); - kfree(priv); vma->vm_private_data = NULL; } @@ -134,9 +119,9 @@ static vm_fault_t uburma_umap_fault(struct vm_fault *vmf) { struct uburma_file *ufile = vmf->vma->vm_file->private_data; struct uburma_umap_priv *priv = vmf->vma->vm_private_data; - struct page *page; + vm_fault_t ret = 0; - if (unlikely(!priv)) + if (!priv) return VM_FAULT_SIGBUS; if (!(vmf->vma->vm_flags & (VM_WRITE | VM_MAYWRITE))) { @@ -145,26 +130,19 @@ static vm_fault_t uburma_umap_fault(struct vm_fault *vmf) return 0; } - page = READ_ONCE(ufile->fault_page); - if (likely(page)) { - vmf->page = page; - get_page(vmf->page); - return 0; - } - mutex_lock(&ufile->umap_mutex); - if (!ufile->fault_page) { + if (!ufile->fault_page) ufile->fault_page = alloc_pages(vmf->gfp_mask | __GFP_ZERO, 0); - if (!ufile->fault_page) { - mutex_unlock(&ufile->umap_mutex); - return VM_FAULT_SIGBUS; - } + + if (ufile->fault_page) { + vmf->page = ufile->fault_page; + get_page(vmf->page); + } else { + ret = VM_FAULT_SIGBUS; } - vmf->page = ufile->fault_page; - get_page(vmf->page); mutex_unlock(&ufile->umap_mutex); - return 0; + return ret; } static const struct vm_operations_struct g_urma_umap_ops = { diff --git a/include/ub/urma/ubcore_opcode.h b/include/ub/urma/ubcore_opcode.h index d02bcd0d467d..583d4f85f8ff 100644 --- a/include/ub/urma/ubcore_opcode.h +++ b/include/ub/urma/ubcore_opcode.h @@ -72,6 +72,7 @@ enum ubcore_opcode { UBCORE_OPC_SEND_INVALIDATE = 0x42, // remote JFR/jetty ID and seg token id UBCORE_OPC_NOP = 0x51, + UBCORE_OPC_WRITE_ATOMIC = 0x60, UBCORE_OPC_LAST }; diff --git a/include/ub/urma/ubcore_types.h b/include/ub/urma/ubcore_types.h index b2563d84cb5c..8aa1306ee321 100644 --- a/include/ub/urma/ubcore_types.h +++ b/include/ub/urma/ubcore_types.h @@ -218,7 +218,8 @@ union ubcore_jfs_flag { /* (0x3): OL, low layer ordering */ /* (0x4): UNO, unreliable non ordering */ uint32_t multi_path : 1; - uint32_t reserved : 20; + uint32_t ctp_rc_mul_path_mode : 1; + uint32_t reserved : 19; } bs; uint32_t value; }; @@ -1344,7 +1345,8 @@ union ubcore_jetty_flag { /* (0x3): OL, low layer ordering */ /* (0x4): UNO, unreliable non ordering */ uint32_t multi_path : 1; - uint32_t reserved : 19; + uint32_t ctp_rc_mul_path_mode : 1; + uint32_t reserved : 18; } bs; uint32_t value; }; -- Gitee From cc32bbb3af80a9e80a5706fcb2f449dd8f94c63d Mon Sep 17 00:00:00 2001 From: Yongqiang Guo Date: Wed, 10 Dec 2025 16:49:02 +0800 Subject: [PATCH 6/8] ubagg: fix mismatched spin unlock. commit 82dc3906a798df872268f07aef9d44929827d07c openEuler This patch fixes a missuse of spin_unlock_irqrestore, which may cause lock issues. Fixes: 1fe6d02bf7ba ("urma: add ubagg ioctl interface and topology management") Signed-off-by: Yongqiang Guo Signed-off-by: Yongqiang Guo --- drivers/ub/urma/ubagg/ubagg_ioctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ub/urma/ubagg/ubagg_ioctl.c b/drivers/ub/urma/ubagg/ubagg_ioctl.c index f36db2955e3f..8f7545306f78 100644 --- a/drivers/ub/urma/ubagg/ubagg_ioctl.c +++ b/drivers/ub/urma/ubagg/ubagg_ioctl.c @@ -182,13 +182,12 @@ static bool ubagg_dev_exists(char *dev_name) static struct ubagg_device *ubagg_find_dev_by_name(char *dev_name) { struct ubagg_device *dev; - unsigned long flags; spin_lock(&g_ubagg_dev_list_lock); list_for_each_entry(dev, &g_ubagg_dev_list, list_node) { if (strncmp(dev_name, dev->master_dev_name, UBAGG_MAX_DEV_NAME_LEN) == 0) { - spin_unlock_irqrestore(&g_ubagg_dev_list_lock, flags); + spin_unlock(&g_ubagg_dev_list_lock); return dev; } } -- Gitee From db0122dc91e1c44798c274888459d2abc661acbd Mon Sep 17 00:00:00 2001 From: Wen Chen Date: Sat, 13 Dec 2025 14:44:32 +0800 Subject: [PATCH 7/8] Packet throughput decreases with multiple jetty streams commit e3710471e4d39dbfc7862eb463b1f043d20a1e71 openEuler 1. The main modifications in this patch are as follows: 1. Symptom: When using RC write/read packet rate, with 8 ports, the total packet rate for 32 jetties is 113M, and for 8 jetties it is 254M.Increasing the number of jetties leads to a decrease in the total packet rate. 2. Root Cause: The 4K page table has 2K page table entries, and the UMMU-TLB has a capacity of 1K, causing UMMU-TLB overflow. TLB misses occur under multiple jetty scenarios. 3. Solution: JFS's write-queue and cqe use 2M large pages. The UMMU-TLB can accommodate a maximum of 2GB of address access, supporting 8K depths of 2048 (JFS + JFC). Fixes: 9b424fbe7481 ("urma: fixed process exiting uburma driver's private memory UAF") Signed-off-by: Wen Chen Signed-off-by: Yongqiang Guo --- drivers/ub/urma/uburma/uburma_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ub/urma/uburma/uburma_main.c b/drivers/ub/urma/uburma/uburma_main.c index b2e11fe5344c..67871364e206 100644 --- a/drivers/ub/urma/uburma/uburma_main.c +++ b/drivers/ub/urma/uburma/uburma_main.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "ub/urma/ubcore_types.h" #include "ub/urma/ubcore_uapi.h" @@ -63,13 +64,13 @@ static struct class g_uburma_class = { static const struct file_operations g_uburma_fops = { .owner = THIS_MODULE, - // .write = uburma_write, .mmap = uburma_mmap, .open = uburma_open, .release = uburma_close, .llseek = no_llseek, .unlocked_ioctl = uburma_ioctl, .compat_ioctl = uburma_ioctl, + .get_unmapped_area = thp_get_unmapped_area, }; static int uburma_add_device(struct ubcore_device *ubc_dev); -- Gitee From d390e21052ec5d448ccc00103997da580e553235 Mon Sep 17 00:00:00 2001 From: Yongqiang Guo Date: Fri, 12 Dec 2025 15:29:15 +0800 Subject: [PATCH 8/8] ubcore: fix route_list when no full match. commit 48a849d00a561603f2dbba2f8eddafc39d8b6c4c openEuler This patch adds the headers of ubcore module. It's the core module of the UMDK network stack, implementing functionalities such as data plane connection establishment and management. Fixes: c78127c4b6eb ("ubcore: fix query route list by eid pair.") Signed-off-by: Yongqiang Guo Signed-off-by: Yongqiang Guo --- drivers/ub/urma/ubcore/ubcore_topo_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ub/urma/ubcore/ubcore_topo_info.c b/drivers/ub/urma/ubcore/ubcore_topo_info.c index 20ad3e79ae45..e9f56ff09500 100644 --- a/drivers/ub/urma/ubcore/ubcore_topo_info.c +++ b/drivers/ub/urma/ubcore/ubcore_topo_info.c @@ -418,7 +418,7 @@ static int ubcore_get_route_primary_eid(union ubcore_eid *src_v_eid, bool dst_match = false; for (int i = 0; i < g_ubcore_topo_map->node_num; i++) { - if (num >= UBCORE_MAX_ROUTE_NUM - 1 || i >= IODIE_NUM) { + if (num >= UBCORE_MAX_ROUTE_NUM - 1) { ubcore_log_warn("Finish to query topo map.\n"); return -EINVAL; } -- Gitee