From 728b60b6400ddf7bef6cfade3468a447b5142d1b Mon Sep 17 00:00:00 2001 From: Yixi Shen Date: Wed, 3 Dec 2025 15:03:40 +0800 Subject: [PATCH 01/12] net: unic: Resolve the bandwidth jitter problem drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ------------------------------------------------------------------ In the IO process, frequent logging in the rx direction caused bandwidth jitter. The logging method was modified to trace. Fixes: d8164d3745d4 ("net: unic: add io basic Rx/Tx functionality for unic") Signed-off-by: Yixi Shen --- drivers/net/ub/unic/unic_event.c | 8 -------- drivers/net/ub/unic/unic_rx.c | 6 +----- drivers/net/ub/unic/unic_trace.h | 23 +++++++++++++++++++++++ drivers/net/ub/unic/unic_txrx.h | 1 - 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/net/ub/unic/unic_event.c b/drivers/net/ub/unic/unic_event.c index 5e0df058d067..c72614e70640 100644 --- a/drivers/net/ub/unic/unic_event.c +++ b/drivers/net/ub/unic/unic_event.c @@ -32,7 +32,6 @@ int unic_comp_handler(struct notifier_block *nb, unsigned long jfcn, void *data) struct auxiliary_device *adev = (struct auxiliary_device *)data; struct unic_dev *unic_dev = dev_get_drvdata(&adev->dev); struct unic_channels *channels = &unic_dev->channels; - struct unic_cq *cq; u32 index; if (test_bit(UNIC_STATE_CHANNEL_INVALID, &unic_dev->state)) @@ -42,13 +41,6 @@ int unic_comp_handler(struct notifier_block *nb, unsigned long jfcn, void *data) if (index >= channels->num) return -EINVAL; - if (jfcn > channels->num) - cq = channels->c[index].rq->cq; - else - cq = channels->c[index].sq->cq; - - cq->event_cnt++; - napi_schedule(&channels->c[index].napi); return 0; diff --git a/drivers/net/ub/unic/unic_rx.c b/drivers/net/ub/unic/unic_rx.c index 34095fbac40d..dfc108380186 100644 --- a/drivers/net/ub/unic/unic_rx.c +++ b/drivers/net/ub/unic/unic_rx.c @@ -1024,15 +1024,11 @@ static int unic_create_skb(struct unic_rq *rq, struct napi_struct *napi, static void unic_fix_rq_ci(struct unic_rq *rq, union unic_cqe *cqe) { - struct unic_dev *unic_dev = netdev_priv(rq->netdev); u32 start_rqe_idx = cqe->rx.start_rqe_idx; u32 put_page_num; if (unlikely(rq->ci != cqe->rx.start_rqe_idx)) { - if (net_ratelimit()) - unic_warn(unic_dev, - "queue_index(%u) sw_rq_ci(%hu) hw_rq_ci(%u) do not match.\n", - rq->queue_index, rq->ci, start_rqe_idx); + trace_unic_rq_ci_mismatch(rq, start_rqe_idx); if (start_rqe_idx < rq->ci) start_rqe_idx += UNIC_RQ_CI_REVERSE; put_page_num = start_rqe_idx - rq->ci; diff --git a/drivers/net/ub/unic/unic_trace.h b/drivers/net/ub/unic/unic_trace.h index 5b6bc7f19bd2..3ef2695635d4 100644 --- a/drivers/net/ub/unic/unic_trace.h +++ b/drivers/net/ub/unic/unic_trace.h @@ -146,6 +146,29 @@ TRACE_EVENT(unic_ip_req_skb, sizeof(u32)) ) ); + +TRACE_EVENT(unic_rq_ci_mismatch, + TP_PROTO(struct unic_rq *rq, const u32 start_rqe_idx), + TP_ARGS(rq, start_rqe_idx), + + TP_STRUCT__entry(__field(u16, queue_index) + __field(u16, ci) + __field(u32, start_rqe_idx) + __string(devname, rq->netdev->name) + ), + + TP_fast_assign(__entry->queue_index = rq->queue_index; + __entry->ci = rq->ci; + __entry->start_rqe_idx = start_rqe_idx; + __assign_str(devname, rq->netdev->name); + ), + + TP_printk("%s rq_ci: queue_index=%u sw_rq_ci=%u hw_rq_ci=%u", + __get_str(devname), __entry->queue_index, __entry->ci, + __entry->start_rqe_idx + ) +); + #endif /* _UNIC_TRACE_H_ */ /* This must be outside ifdef _UNIC_TRACE_H */ diff --git a/drivers/net/ub/unic/unic_txrx.h b/drivers/net/ub/unic/unic_txrx.h index b52354c8989f..b6229d1d0d04 100644 --- a/drivers/net/ub/unic/unic_txrx.h +++ b/drivers/net/ub/unic/unic_txrx.h @@ -238,7 +238,6 @@ struct unic_cq { struct unic_jfc_ctx jfc_ctx; u32 jfcn; u32 ci; /* the start of next to consume */ - u64 event_cnt; }; static inline u8 unic_get_cqe_size(void) -- Gitee From f568241d59838b2f9723db1c1d387ed530e8e42e Mon Sep 17 00:00:00 2001 From: Guangwei Zhang Date: Tue, 9 Dec 2025 17:53:23 +0800 Subject: [PATCH 02/12] ub: ubase: Remove non-cluster mode code. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ----------------------------------------------------------------- This patch fixes the following issues: 1. Remove non-cluster mode code. 2. Provide an interface for accessing netdev to the UDMA auxiliary device. 3. Fixing the issue of debugfs querying TP VL as 0 in the uboe scenario Fixes: acb96f3cf8c8 ("ub: ubase: support querying sl information in initialization phase") Signed-off-by: Guangwei Zhang Signed-off-by: Haiqing Fang --- drivers/net/ub/unic/unic_dev.c | 2 +- drivers/net/ub/unic/unic_event.c | 8 +- drivers/net/ub/unic/unic_ip.c | 67 +++++----- drivers/net/ub/unic/unic_ip.h | 2 +- drivers/net/ub/unic/unic_reset.c | 2 +- drivers/ub/ubase/debugfs/ubase_debugfs.c | 38 +++--- drivers/ub/ubase/debugfs/ubase_qos_debugfs.c | 12 +- drivers/ub/ubase/debugfs/ubase_qos_debugfs.h | 2 +- drivers/ub/ubase/ubase_dev.c | 30 +++++ drivers/ub/ubase/ubase_dev.h | 1 - drivers/ub/ubase/ubase_hw.c | 8 +- drivers/ub/ubase/ubase_hw.h | 19 +-- drivers/ub/ubase/ubase_mailbox.c | 13 +- drivers/ub/ubase/ubase_qos_hw.c | 130 +++++++++---------- drivers/ub/ubase/ubase_tp.c | 29 +++-- drivers/ub/ubase/ubase_tp.h | 2 - include/ub/ubase/ubase_comm_dev.h | 26 +--- 17 files changed, 182 insertions(+), 209 deletions(-) diff --git a/drivers/net/ub/unic/unic_dev.c b/drivers/net/ub/unic/unic_dev.c index c63ea8116ca8..7d0405e751b0 100644 --- a/drivers/net/ub/unic/unic_dev.c +++ b/drivers/net/ub/unic/unic_dev.c @@ -1096,7 +1096,7 @@ int unic_dev_init(struct auxiliary_device *adev) goto err_unregister_event; } - unic_query_ip_by_ctrlq(adev); + unic_query_ip_addr(adev); unic_start_dev_period_task(netdev); return 0; diff --git a/drivers/net/ub/unic/unic_event.c b/drivers/net/ub/unic/unic_event.c index c72614e70640..796966703751 100644 --- a/drivers/net/ub/unic/unic_event.c +++ b/drivers/net/ub/unic/unic_event.c @@ -151,7 +151,7 @@ static void unic_activate_handler(struct auxiliary_device *adev, bool activate) unic_deactivate_event_process(unic_dev); } -static void unic_rack_port_reset(struct unic_dev *unic_dev, bool link_up) +static void unic_ub_port_reset(struct unic_dev *unic_dev, bool link_up) { if (link_up) unic_dev->hw.mac.link_status = UNIC_LINK_STATUS_UP; @@ -159,7 +159,7 @@ static void unic_rack_port_reset(struct unic_dev *unic_dev, bool link_up) unic_dev->hw.mac.link_status = UNIC_LINK_STATUS_DOWN; } -static void unic_port_reset(struct net_device *netdev, bool link_up) +static void unic_eth_port_reset(struct net_device *netdev, bool link_up) { rtnl_lock(); @@ -180,9 +180,9 @@ static void unic_port_handler(struct auxiliary_device *adev, bool link_up) return; if (unic_dev_ubl_supported(unic_dev)) - unic_rack_port_reset(unic_dev, link_up); + unic_ub_port_reset(unic_dev, link_up); else - unic_port_reset(netdev, link_up); + unic_eth_port_reset(netdev, link_up); } static struct ubase_ctrlq_event_nb unic_ctrlq_events[] = { diff --git a/drivers/net/ub/unic/unic_ip.c b/drivers/net/ub/unic/unic_ip.c index e83baddded87..dff8b2e87201 100644 --- a/drivers/net/ub/unic/unic_ip.c +++ b/drivers/net/ub/unic/unic_ip.c @@ -15,10 +15,10 @@ #include "unic_trace.h" #include "unic_ip.h" -static void unic_update_rack_addr_state(struct unic_vport *vport, - struct unic_comm_addr_node *addr_node, - enum UNIC_COMM_ADDR_STATE state, - const u8 *addr) +static void unic_update_addr_state(struct unic_vport *vport, + struct unic_comm_addr_node *addr_node, + enum UNIC_COMM_ADDR_STATE state, + const u8 *addr) { struct auxiliary_device *adev = vport->back->comdev.adev; struct unic_dev *unic_dev = dev_get_drvdata(&adev->dev); @@ -26,7 +26,7 @@ static void unic_update_rack_addr_state(struct unic_vport *vport, /* update the state of address node by stack in rack server. * if ip node exist in ip_list and receive the ack form stack, - * update_rack_addr_state and handle accidental deletion. + * update_addr_state and handle accidental deletion. */ switch (state) { case UNIC_COMM_ADDR_TO_ADD: @@ -68,7 +68,7 @@ static int unic_update_stack_ip_addr(struct unic_vport *vport, addr_node = unic_comm_find_addr_node(list, addr, ip_mask); if (addr_node) { - unic_update_rack_addr_state(vport, addr_node, state, addr); + unic_update_addr_state(vport, addr_node, state, addr); goto finish_update_state; } @@ -274,9 +274,8 @@ static int unic_sync_stack_ip(struct unic_vport *vport, return ret; } -static void unic_sync_rack_ip_list(struct unic_vport *vport, - struct list_head *list, - enum unic_ctrlq_ip_event state) +static void unic_sync_ip_list(struct unic_vport *vport, struct list_head *list, + enum unic_ctrlq_ip_event state) { struct unic_comm_addr_node *ip_node, *tmp; int ret; @@ -291,9 +290,9 @@ static void unic_sync_rack_ip_list(struct unic_vport *vport, } } -static void unic_rack_sync_addr_table(struct unic_vport *vport, - struct list_head *list, - spinlock_t *addr_list_lock) +static void unic_sync_addr_table(struct unic_vport *vport, + struct list_head *list, + spinlock_t *addr_list_lock) { struct auxiliary_device *adev = vport->back->comdev.adev; struct unic_comm_addr_node *addr_node, *tmp, *new_node; @@ -330,8 +329,8 @@ static void unic_rack_sync_addr_table(struct unic_vport *vport, stop_traverse: spin_unlock_bh(addr_list_lock); - unic_sync_rack_ip_list(vport, &tmp_del_list, UNIC_CTRLQ_DEL_IP); - unic_sync_rack_ip_list(vport, &tmp_add_list, UNIC_CTRLQ_ADD_IP); + unic_sync_ip_list(vport, &tmp_del_list, UNIC_CTRLQ_DEL_IP); + unic_sync_ip_list(vport, &tmp_add_list, UNIC_CTRLQ_ADD_IP); } void unic_sync_ip_table(struct unic_dev *unic_dev) @@ -341,8 +340,8 @@ void unic_sync_ip_table(struct unic_dev *unic_dev) if (!test_bit(UNIC_VPORT_STATE_IP_TBL_CHANGE, &vport->state)) return; - unic_rack_sync_addr_table(vport, &vport->addr_tbl.ip_list, - &vport->addr_tbl.ip_list_lock); + unic_sync_addr_table(vport, &vport->addr_tbl.ip_list, + &vport->addr_tbl.ip_list_lock); } static void unic_build_stack_ip_info(struct unic_ctrlq_ip_notify_req *req, @@ -358,10 +357,10 @@ static void unic_build_stack_ip_info(struct unic_ctrlq_ip_notify_req *req, st_ip->ip_addr[3] = le32_to_be32(req->ip_addr[0]); } -static int unic_update_rack_addr_list(struct list_head *list, - spinlock_t *addr_list_lock, - enum UNIC_COMM_ADDR_STATE state, - const u8 *addr, u16 ip_mask) +static int unic_update_addr_list(struct list_head *list, + spinlock_t *addr_list_lock, + enum UNIC_COMM_ADDR_STATE state, + const u8 *addr, u16 ip_mask) { struct unic_comm_addr_node *addr_node; @@ -489,17 +488,17 @@ int unic_handle_notify_ip_event(struct auxiliary_device *adev, u8 service_ver, } if (st_ip.ip_cmd == UNIC_CTRLQ_ADD_IP) { - ret = unic_update_rack_addr_list(&vport->addr_tbl.ip_list, - &vport->addr_tbl.ip_list_lock, - UNIC_COMM_ADDR_TO_ADD, - (u8 *)&st_ip.ip_addr, - st_ip.ip_mask); + ret = unic_update_addr_list(&vport->addr_tbl.ip_list, + &vport->addr_tbl.ip_list_lock, + UNIC_COMM_ADDR_TO_ADD, + (u8 *)&st_ip.ip_addr, + st_ip.ip_mask); } else if (st_ip.ip_cmd == UNIC_CTRLQ_DEL_IP) { - ret = unic_update_rack_addr_list(&vport->addr_tbl.ip_list, - &vport->addr_tbl.ip_list_lock, - UNIC_COMM_ADDR_TO_DEL, - (u8 *)&st_ip.ip_addr, - st_ip.ip_mask); + ret = unic_update_addr_list(&vport->addr_tbl.ip_list, + &vport->addr_tbl.ip_list_lock, + UNIC_COMM_ADDR_TO_DEL, + (u8 *)&st_ip.ip_addr, + st_ip.ip_mask); } else { ret = -EINVAL; unic_err(priv, "invalid ip cmd by ctrlq, cmd = %u.\n", st_ip.ip_cmd); @@ -618,8 +617,8 @@ static int unic_ctrlq_query_ip(struct auxiliary_device *adev, u16 *ip_index, return ret; } -static void unic_update_rack_ip_list(struct unic_vport *vport, - struct list_head *list) +static void unic_update_ip_list(struct unic_vport *vport, + struct list_head *list) { struct unic_comm_addr_node *ip_node, *tmp, *new_node; @@ -655,7 +654,7 @@ static void unic_update_rack_ip_list(struct unic_vport *vport, spin_unlock_bh(&vport->addr_tbl.ip_list_lock); } -void unic_query_ip_by_ctrlq(struct auxiliary_device *adev) +void unic_query_ip_addr(struct auxiliary_device *adev) { #define UNIC_LOOP_COUNT(total_size, size) ((total_size) / (size) + 1) @@ -690,7 +689,7 @@ void unic_query_ip_by_ctrlq(struct auxiliary_device *adev) spin_lock_bh(&vport->addr_tbl.tmp_ip_lock); - unic_update_rack_ip_list(vport, &tmp_list); + unic_update_ip_list(vport, &tmp_list); clear_bit(UNIC_VPORT_STATE_IP_QUERYING, &vport->state); list_for_each_entry_safe(ip_node, tmp, &vport->addr_tbl.tmp_ip_list, node) { diff --git a/drivers/net/ub/unic/unic_ip.h b/drivers/net/ub/unic/unic_ip.h index a73e8490536c..ac95a26c0df5 100644 --- a/drivers/net/ub/unic/unic_ip.h +++ b/drivers/net/ub/unic/unic_ip.h @@ -75,7 +75,7 @@ static inline void unic_format_masked_ip_addr(char *format_masked_ip_addr, void unic_sync_ip_table(struct unic_dev *unic_dev); int unic_handle_notify_ip_event(struct auxiliary_device *adev, u8 service_ver, void *data, u16 len, u16 seq); -void unic_query_ip_by_ctrlq(struct auxiliary_device *adev); +void unic_query_ip_addr(struct auxiliary_device *adev); void unic_uninit_ip_table(struct unic_dev *unic_dev); int unic_add_ip_addr(struct unic_dev *unic_dev, struct sockaddr *addr, u16 ip_mask); diff --git a/drivers/net/ub/unic/unic_reset.c b/drivers/net/ub/unic/unic_reset.c index 69995449b2df..6946e8976da0 100644 --- a/drivers/net/ub/unic/unic_reset.c +++ b/drivers/net/ub/unic/unic_reset.c @@ -94,7 +94,7 @@ static void unic_reset_init(struct auxiliary_device *adev) if (ret) goto err_unic_resume; - unic_query_ip_by_ctrlq(adev); + unic_query_ip_addr(adev); unic_start_period_task(netdev); if_running = netif_running(netdev); diff --git a/drivers/ub/ubase/debugfs/ubase_debugfs.c b/drivers/ub/ubase/debugfs/ubase_debugfs.c index e7cb577444a9..f8c7fbecf4b2 100644 --- a/drivers/ub/ubase/debugfs/ubase_debugfs.c +++ b/drivers/ub/ubase/debugfs/ubase_debugfs.c @@ -36,24 +36,24 @@ static int ubase_dbg_dump_rst_info(struct seq_file *s, void *data) static void ubase_dbg_dump_caps_bits(struct seq_file *s, struct ubase_dev *udev) { #define CAP_FMT(name) "\tsupport_" #name ": %d\n" -#define PRTINT_CAP(name, func) seq_printf(s, CAP_FMT(name), func(udev)) - - PRTINT_CAP(ub_link, ubase_dev_ubl_supported); - PRTINT_CAP(ta_extdb_buffer_config, ubase_dev_ta_extdb_buf_supported); - PRTINT_CAP(ta_timer_buffer_config, ubase_dev_ta_timer_buf_supported); - PRTINT_CAP(err_handle, ubase_dev_err_handle_supported); - PRTINT_CAP(ctrlq, ubase_dev_ctrlq_supported); - PRTINT_CAP(eth_mac, ubase_dev_eth_mac_supported); - PRTINT_CAP(mac_stats, ubase_dev_mac_stats_supported); - PRTINT_CAP(prealloc, __ubase_dev_prealloc_supported); - PRTINT_CAP(udma, ubase_dev_udma_supported); - PRTINT_CAP(unic, ubase_dev_unic_supported); - PRTINT_CAP(uvb, ubase_dev_uvb_supported); - PRTINT_CAP(ip_over_urma, ubase_ip_over_urma_supported); +#define PRINT_CAP(name, func) seq_printf(s, CAP_FMT(name), func(udev)) + + PRINT_CAP(ub_link, ubase_dev_ubl_supported); + PRINT_CAP(ta_extdb_buffer_config, ubase_dev_ta_extdb_buf_supported); + PRINT_CAP(ta_timer_buffer_config, ubase_dev_ta_timer_buf_supported); + PRINT_CAP(err_handle, ubase_dev_err_handle_supported); + PRINT_CAP(ctrlq, ubase_dev_ctrlq_supported); + PRINT_CAP(eth_mac, ubase_dev_eth_mac_supported); + PRINT_CAP(mac_stats, ubase_dev_mac_stats_supported); + PRINT_CAP(prealloc, __ubase_dev_prealloc_supported); + PRINT_CAP(udma, ubase_dev_udma_supported); + PRINT_CAP(unic, ubase_dev_unic_supported); + PRINT_CAP(uvb, ubase_dev_uvb_supported); + PRINT_CAP(ip_over_urma, ubase_ip_over_urma_supported); if (ubase_ip_over_urma_supported(udev)) - PRTINT_CAP(ip_over_urma_utp, ubase_ip_over_urma_utp_supported); - PRTINT_CAP(activate_proxy, ubase_activate_proxy_supported); - PRTINT_CAP(utp, ubase_utp_supported); + PRINT_CAP(ip_over_urma_utp, ubase_ip_over_urma_utp_supported); + PRINT_CAP(activate_proxy, ubase_activate_proxy_supported); + PRINT_CAP(utp, ubase_utp_supported); } static void ubase_dbg_dump_caps_info(struct seq_file *s, struct ubase_dev *udev) @@ -612,12 +612,12 @@ static struct ubase_dbg_cmd_info ubase_dbg_cmd[] = { .read_func = ubase_dbg_dump_perf_stats, }, { - .name = "rack_vl_bitmap", + .name = "vl_bitmap", .dentry_index = UBASE_DBG_DENTRY_QOS, .property = UBASE_SUP_URMA | UBASE_SUP_CDMA | UBASE_SUP_UBL, .support = __ubase_dbg_dentry_support, .init = __ubase_dbg_seq_file_init, - .read_func = ubase_dbg_dump_rack_vl_bitmap, + .read_func = ubase_dbg_dump_vl_bitmap, }, { .name = "adev_qos", diff --git a/drivers/ub/ubase/debugfs/ubase_qos_debugfs.c b/drivers/ub/ubase/debugfs/ubase_qos_debugfs.c index 91e05df180bb..070b0d363f61 100644 --- a/drivers/ub/ubase/debugfs/ubase_qos_debugfs.c +++ b/drivers/ub/ubase/debugfs/ubase_qos_debugfs.c @@ -156,7 +156,7 @@ int ubase_dbg_dump_ets_port_info(struct seq_file *s, void *data) return 0; } -int ubase_dbg_dump_rack_vl_bitmap(struct seq_file *s, void *data) +int ubase_dbg_dump_vl_bitmap(struct seq_file *s, void *data) { struct ubase_dev *udev = dev_get_drvdata(s->private); struct ubase_ctrlq_query_vl_resp resp = {0}; @@ -184,7 +184,7 @@ int ubase_dbg_dump_rack_vl_bitmap(struct seq_file *s, void *data) vl_bitmap = le16_to_cpu(resp.vl_bitmap); - seq_printf(s, "rack vl bitmap : 0x%x", vl_bitmap); + seq_printf(s, "vl bitmap : 0x%x", vl_bitmap); return 0; } @@ -192,9 +192,6 @@ int ubase_dbg_dump_rack_vl_bitmap(struct seq_file *s, void *data) static void ubase_dbg_dump_adev_vl_info(struct seq_file *s, struct ubase_adev_qos *qos) { - seq_puts(s, "vl:"); - ubase_dbg_dump_arr_info(s, qos->vl, qos->vl_num); - seq_puts(s, "tp_req_vl:"); ubase_dbg_dump_arr_info(s, qos->tp_req_vl, qos->tp_vl_num); @@ -208,9 +205,6 @@ static void ubase_dbg_dump_adev_vl_info(struct seq_file *s, static void ubase_dbg_dump_adev_sl_info(struct seq_file *s, struct ubase_adev_qos *qos) { - seq_puts(s, "sl:"); - ubase_dbg_dump_arr_info(s, qos->sl, qos->sl_num); - seq_puts(s, "tp_sl:"); ubase_dbg_dump_arr_info(s, qos->tp_sl, qos->tp_sl_num); @@ -229,12 +223,10 @@ int ubase_dbg_dump_adev_qos_info(struct seq_file *s, void *data) const char *format; u8 qos_info; } adev_qos_info[] = { - {"vl_num: %u\n", qos->vl_num}, {"tp_vl_num: %u\n", qos->tp_vl_num}, {"ctp_vl_num: %u\n", qos->ctp_vl_num}, {"tp_resp_vl_offset: %u\n", qos->tp_resp_vl_offset}, {"ctp_resp_vl_offset: %u\n", qos->ctp_resp_vl_offset}, - {"sl_num: %u\n", qos->sl_num}, {"tp_sl_num: %u\n", qos->tp_sl_num}, {"ctp_sl_num: %u\n", qos->ctp_sl_num}, {"nic_sl_num: %u\n", qos->nic_sl_num}, diff --git a/drivers/ub/ubase/debugfs/ubase_qos_debugfs.h b/drivers/ub/ubase/debugfs/ubase_qos_debugfs.h index e44b4cacd21e..060e4b847283 100644 --- a/drivers/ub/ubase/debugfs/ubase_qos_debugfs.h +++ b/drivers/ub/ubase/debugfs/ubase_qos_debugfs.h @@ -14,7 +14,7 @@ int ubase_dbg_dump_udma_dscp_vl_map(struct seq_file *s, void *data); int ubase_dbg_dump_ets_tc_info(struct seq_file *s, void *data); int ubase_dbg_dump_ets_tcg_info(struct seq_file *s, void *data); int ubase_dbg_dump_ets_port_info(struct seq_file *s, void *data); -int ubase_dbg_dump_rack_vl_bitmap(struct seq_file *s, void *data); +int ubase_dbg_dump_vl_bitmap(struct seq_file *s, void *data); int ubase_dbg_dump_adev_qos_info(struct seq_file *s, void *data); int ubase_dbg_dump_fsv_fvt_rqmt(struct seq_file *s, void *data); int ubase_dbg_dump_tm_queue_info(struct seq_file *s, void *data); diff --git a/drivers/ub/ubase/ubase_dev.c b/drivers/ub/ubase/ubase_dev.c index 4765610b7f09..086e16cef4b6 100644 --- a/drivers/ub/ubase/ubase_dev.c +++ b/drivers/ub/ubase/ubase_dev.c @@ -1010,6 +1010,36 @@ struct ubase_caps *ubase_get_dev_caps(struct auxiliary_device *adev) } EXPORT_SYMBOL(ubase_get_dev_caps); +/** + * ubase_get_mdrv_data() - get unic netdev + * @adev: auxiliary device + * + * The function is used to get unic netdev. + * + * Context: Any context. + * Return: NULL if the adev is empty or does not support the unic device, + * otherwise the pointer to struct ubase_adev_com + */ +const struct ubase_adev_com *ubase_get_mdrv_data(struct auxiliary_device *adev) +{ + struct auxiliary_device *unic_adev; + struct ubase_priv *priv; + struct ubase_dev *udev; + + if (!adev) + return NULL; + + udev = __ubase_get_udev_by_adev(adev); + if (!ubase_dev_unic_supported(udev)) + return NULL; + + priv = &udev->priv; + unic_adev = &priv->uadev[UBASE_DRV_UNIC]->adev; + + return dev_get_drvdata(&unic_adev->dev); +} +EXPORT_SYMBOL(ubase_get_mdrv_data); + /** * ubase_get_udma_caps() - get udma auxiliary device capabilities * @adev: udma auxiliary device pointer diff --git a/drivers/ub/ubase/ubase_dev.h b/drivers/ub/ubase/ubase_dev.h index ee7c5f605e65..5270246540e7 100644 --- a/drivers/ub/ubase/ubase_dev.h +++ b/drivers/ub/ubase/ubase_dev.h @@ -70,7 +70,6 @@ struct ubase_dev_caps { struct ubase_adev_caps udma_caps; struct ubase_adev_caps unic_caps; struct ubase_caps dev_caps; - struct ubase_ue_caps ue_caps; }; struct ubase_mbox_cmd { diff --git a/drivers/ub/ubase/ubase_hw.c b/drivers/ub/ubase/ubase_hw.c index c473d12ddf72..d58fd69cd25f 100644 --- a/drivers/ub/ubase/ubase_hw.c +++ b/drivers/ub/ubase/ubase_hw.c @@ -24,7 +24,7 @@ struct ubase_dma_buf_desc { bool (*is_supported)(struct ubase_dev *dev); }; -#define UBASE_DEFINE_DMA_BUFS(udev) \ +#define UBASE_DEFINE_TA_DMA_BUFS(udev) \ struct ubase_dma_buf_desc bufs[] = { \ { &(udev)->ta_ctx.extdb_buf, UBASE_OPC_TA_EXTDB_VA_CONFIG, \ &ubase_dev_ta_extdb_buf_supported }, \ @@ -107,7 +107,7 @@ static void ubase_check_dev_caps_comm(struct ubase_dev *udev) static int ubase_check_dev_caps_extdb(struct ubase_dev *udev) { - UBASE_DEFINE_DMA_BUFS(udev); + UBASE_DEFINE_TA_DMA_BUFS(udev); int i; for (i = 0; i < ARRAY_SIZE(bufs); i++) { @@ -586,7 +586,7 @@ static void ubase_uninit_dma_buf(struct ubase_dev *udev, static int ubase_init_ta_ext_buf(struct ubase_dev *udev) { - UBASE_DEFINE_DMA_BUFS(udev); + UBASE_DEFINE_TA_DMA_BUFS(udev); int i, ret; for (i = 0; i < ARRAY_SIZE(bufs); i++) { @@ -610,7 +610,7 @@ static int ubase_init_ta_ext_buf(struct ubase_dev *udev) static void ubase_uninit_ta_ext_buf(struct ubase_dev *udev) { - UBASE_DEFINE_DMA_BUFS(udev); + UBASE_DEFINE_TA_DMA_BUFS(udev); int i; for (i = 0; i < ARRAY_SIZE(bufs); i++) { diff --git a/drivers/ub/ubase/ubase_hw.h b/drivers/ub/ubase/ubase_hw.h index e292053905ec..1655331cb4d5 100644 --- a/drivers/ub/ubase/ubase_hw.h +++ b/drivers/ub/ubase/ubase_hw.h @@ -49,9 +49,7 @@ struct ubase_res_cmd_resp { __le32 udma_jfr_max_cnt; u8 rsvd3[4]; __le32 udma_jfr_depth; - u8 nic_vl_num; - u8 rsvd4[3]; - u8 nic_vl[UBASE_MAX_REQ_VL_NUM]; + u8 rsvd4[12]; __le32 udma_jfc_max_cnt; u8 rsvd5[4]; @@ -81,22 +79,19 @@ struct ubase_res_cmd_resp { __le32 ta_extdb_buf_size; __le32 ta_timer_buf_size; __le32 public_jetty_cnt; - u8 rsvd15[9]; - u8 udma_vl_num; + u8 rsvd15[10]; u8 udma_tp_resp_vl_offset; u8 ue_num; - __le32 port_bitmap; - u8 rsvd16[4]; + u8 rsvd16[8]; - /* include udma tp and ctp req vl */ - u8 udma_req_vl[UBASE_MAX_REQ_VL_NUM]; + u8 rsvd17[8]; __le32 udma_rc_depth; - u8 rsvd17[4]; + u8 rsvd18[4]; __le32 jtg_max_cnt; __le32 rc_max_cnt_per_vl; - u8 rsvd18[8]; + u8 rsvd19[8]; - u8 rsvd19[32]; + u8 rsvd20[32]; }; struct ubase_query_oor_resp { diff --git a/drivers/ub/ubase/ubase_mailbox.c b/drivers/ub/ubase/ubase_mailbox.c index a92993f5ac0b..b530d555af3b 100644 --- a/drivers/ub/ubase/ubase_mailbox.c +++ b/drivers/ub/ubase/ubase_mailbox.c @@ -401,8 +401,8 @@ static bool ubase_is_jfs_opcode(u8 op) } static struct ubase_ctx_buf_cap* -ubase_parse_ta_opcode_buf(struct ubase_dev *udev, struct ubase_mbx_attr *attr, - enum ubase_mb_type *type) +ubase_parse_opcode_buf(struct ubase_dev *udev, struct ubase_mbx_attr *attr, + enum ubase_mb_type *type) { struct mbx_op_match ta_matches[] = { {UBASE_MB_CREATE_JFS_CONTEXT, UBASE_MB_CREATE, &udev->ctx_buf.jfs}, @@ -428,18 +428,11 @@ ubase_parse_ta_opcode_buf(struct ubase_dev *udev, struct ubase_mbx_attr *attr, }; u32 size = ARRAY_SIZE(ta_matches); - return ubase_parse_common_buf(attr, ta_matches, type, size); -} - -static struct ubase_ctx_buf_cap* -ubase_parse_opcode_buf(struct ubase_dev *udev, struct ubase_mbx_attr *attr, - enum ubase_mb_type *type) -{ if (ubase_is_jfs_opcode(attr->op) && test_bit(UBASE_STATE_PREALLOC_OK_B, &udev->state_bits)) return NULL; - return ubase_parse_ta_opcode_buf(udev, attr, type); + return ubase_parse_common_buf(attr, ta_matches, type, size); } static int ubase_check_buf_ctx_page(struct ubase_dev *udev, diff --git a/drivers/ub/ubase/ubase_qos_hw.c b/drivers/ub/ubase/ubase_qos_hw.c index ca5051ce4c44..e7737e98e1e5 100644 --- a/drivers/ub/ubase/ubase_qos_hw.c +++ b/drivers/ub/ubase/ubase_qos_hw.c @@ -414,8 +414,12 @@ static unsigned long ubase_get_sl_bitmap(struct ubase_dev *udev) for (i = 0; i < qos->nic_sl_num; i++) sl_bitmap |= 1 << qos->nic_sl[i]; - for (i = 0; i < qos->sl_num; i++) - sl_bitmap |= 1 << qos->sl[i]; + + for (i = 0; i < qos->tp_sl_num; i++) + sl_bitmap |= 1 << qos->tp_sl[i]; + + for (i = 0; i < qos->ctp_sl_num; i++) + sl_bitmap |= 1 << qos->ctp_sl[i]; return sl_bitmap; } @@ -594,14 +598,6 @@ static int ubase_query_ctp_vl_offset(struct ubase_dev *udev, u8 *ctp_vl_offset) return 0; } -static inline void ubase_parse_udma_req_vl_uboe(struct ubase_dev *udev) -{ - struct ubase_adev_qos *qos = &udev->qos; - - qos->tp_vl_num = qos->vl_num; - memcpy(qos->tp_req_vl, qos->vl, qos->vl_num); -} - static int ubase_check_ctp_resp_vl(struct ubase_dev *udev, u8 ctp_vl_offset) { struct ubase_adev_qos *qos = &udev->qos; @@ -639,24 +635,18 @@ static int ubase_parse_ctp_resp_vl(struct ubase_dev *udev) return 0; } -static bool ubase_get_vl_sl(struct ubase_dev *udev, u8 vl, u8 *sl, u8 *sl_num) +static void ubase_get_vl_sl(struct ubase_dev *udev, u8 vl, u8 *sl, u8 *sl_num) { - bool sl_exist = false; u8 i; for (i = 0; i < UBASE_MAX_SL_NUM; i++) { - if (udev->qos.ue_sl_vl[i] == vl) { + if (udev->qos.ue_sl_vl[i] == vl) sl[(*sl_num)++] = i; - sl_exist = true; - } } - - return sl_exist; } -static void ubase_gather_udma_req_resp_vl(struct ubase_dev *udev, - u8 *req_vl, u8 req_vl_num, - u8 resp_vl_off) +static void ubase_gather_udma_req_resp_vl(struct ubase_dev *udev, u8 *req_vl, + u8 req_vl_num, u8 resp_vl_off) { struct ubase_caps *dev_caps = &udev->caps.dev_caps; struct ubase_adev_qos *qos = &udev->qos; @@ -689,11 +679,9 @@ static void ubase_gather_urma_req_resp_vl(struct ubase_dev *udev) dev_caps->vl_num = qos->nic_vl_num; /* Restriction: The unic vl can't be used as the dma resp vl. */ - ubase_gather_udma_req_resp_vl(udev, qos->tp_req_vl, - qos->tp_vl_num, + ubase_gather_udma_req_resp_vl(udev, qos->tp_req_vl, qos->tp_vl_num, qos->tp_resp_vl_offset); - ubase_gather_udma_req_resp_vl(udev, qos->ctp_req_vl, - qos->ctp_vl_num, + ubase_gather_udma_req_resp_vl(udev, qos->ctp_req_vl, qos->ctp_vl_num, qos->ctp_resp_vl_offset); /* dev_caps->vl_num is used for DCB tool configuration. Therefore, @@ -751,7 +739,7 @@ static int ubase_parse_nic_vl(struct ubase_dev *udev) udev->qos.nic_vl, &udev->qos.nic_vl_num); } -static int ubase_parse_rack_udma_req_vl_ub(struct ubase_dev *udev) +static int ubase_parse_udma_req_vl(struct ubase_dev *udev) { struct ubase_adev_qos *qos = &udev->qos; int ret; @@ -761,51 +749,40 @@ static int ubase_parse_rack_udma_req_vl_ub(struct ubase_dev *udev) if (ret) return ret; - return ubase_assign_urma_vl(udev, qos->ctp_sl, qos->ctp_sl_num, - qos->ctp_req_vl, &qos->ctp_vl_num); -} - -static int ubase_parse_rack_udma_req_vl(struct ubase_dev *udev) -{ if (ubase_dev_ubl_supported(udev)) - return ubase_parse_rack_udma_req_vl_ub(udev); - - ubase_parse_udma_req_vl_uboe(udev); + return ubase_assign_urma_vl(udev, qos->ctp_sl, qos->ctp_sl_num, + qos->ctp_req_vl, &qos->ctp_vl_num); return 0; } -static int ubase_parse_rack_udma_vl(struct ubase_dev *udev) +static int ubase_parse_udma_vl(struct ubase_dev *udev) { int ret; - ret = ubase_parse_rack_udma_req_vl(udev); + ret = ubase_parse_udma_req_vl(udev); if (ret) return ret; return ubase_parse_udma_resp_vl(udev); } -static int ubase_parse_rack_cdma_resp_vl(struct ubase_dev *udev) +static int ubase_parse_cdma_resp_vl(struct ubase_dev *udev) { return ubase_parse_ctp_resp_vl(udev); } -static int ubase_parse_rack_cdma_req_sl_vl(struct ubase_dev *udev) +static int ubase_parse_cdma_sl(struct ubase_dev *udev) { struct ubase_adev_qos *qos = &udev->qos; - bool exist = false; u8 i; - for (i = 0; i < qos->vl_num; i++) { - exist = ubase_get_vl_sl(udev, qos->vl[i], qos->ctp_sl, - &qos->ctp_sl_num); - if (exist) - qos->ctp_req_vl[qos->ctp_vl_num++] = qos->vl[i]; - } + for (i = 0; i < qos->ctp_vl_num; i++) + ubase_get_vl_sl(udev, qos->ctp_req_vl[i], qos->ctp_sl, + &qos->ctp_sl_num); - if (!qos->ctp_vl_num) { - ubase_err(udev, "cdma doesn't have any req vl.\n"); + if (!qos->ctp_sl_num) { + ubase_err(udev, "cdma doesn't have any sl.\n"); return -EINVAL; } @@ -816,11 +793,11 @@ static int ubase_parse_cdma_sl_vl(struct ubase_dev *udev) { int ret; - ret = ubase_parse_rack_cdma_req_sl_vl(udev); + ret = ubase_parse_cdma_sl(udev); if (ret) return ret; - ret = ubase_parse_rack_cdma_resp_vl(udev); + ret = ubase_parse_cdma_resp_vl(udev); if (ret) return ret; @@ -828,21 +805,16 @@ static int ubase_parse_cdma_sl_vl(struct ubase_dev *udev) return 0; } -static inline int ubase_parse_nic_sl_vl(struct ubase_dev *udev) -{ - return ubase_parse_nic_vl(udev); -} - static int ubase_parse_urma_sl_vl(struct ubase_dev *udev) { int ret; - ret = ubase_parse_nic_sl_vl(udev); + ret = ubase_parse_nic_vl(udev); if (ret) return ret; if (ubase_dev_udma_supported(udev)) { - ret = ubase_parse_rack_udma_vl(udev); + ret = ubase_parse_udma_vl(udev); if (ret) return ret; } @@ -875,23 +847,23 @@ static void ubase_parse_max_vl(struct ubase_dev *udev) { struct ubase_adev_caps *udma_caps = &udev->caps.udma_caps; struct ubase_adev_qos *qos = &udev->qos; - u8 i, max_vl = 0; + u8 i, ue_max_vl_id = 0; for (i = 0; i < qos->nic_vl_num; i++) - max_vl = max(qos->nic_vl[i], max_vl); + ue_max_vl_id = max(qos->nic_vl[i], ue_max_vl_id); for (i = 0; i < qos->tp_vl_num; i++) - max_vl = max(qos->tp_req_vl[i] + - qos->tp_resp_vl_offset, max_vl); + ue_max_vl_id = max(qos->tp_req_vl[i] + qos->tp_resp_vl_offset, + ue_max_vl_id); for (i = 0; i < qos->ctp_vl_num; i++) - max_vl = max(qos->ctp_req_vl[i] + - qos->ctp_resp_vl_offset, max_vl); + ue_max_vl_id = max(qos->ctp_req_vl[i] + qos->ctp_resp_vl_offset, + ue_max_vl_id); - qos->ue_max_vl_id = max_vl; + qos->ue_max_vl_id = ue_max_vl_id; if (ubase_dev_urma_supported(udev)) - udma_caps->rc_max_cnt *= (max_vl + 1); + udma_caps->rc_max_cnt *= (ue_max_vl_id + 1); } static int ubase_get_nic_max_vl(struct ubase_dev *udev) @@ -934,7 +906,7 @@ static int ubase_ctrlq_query_vl(struct ubase_dev *udev) struct ubase_ctrlq_query_vl_req req = {0}; struct ubase_ctrlq_msg msg = {0}; unsigned long vl_bitmap; - u8 i, vl_cnt = 0; + u8 i, cdma_vl_cnt = 0; int ret; msg.service_ver = UBASE_CTRLQ_SER_VER_01; @@ -958,18 +930,35 @@ static int ubase_ctrlq_query_vl(struct ubase_dev *udev) for (i = 0; i < UBASE_MAX_VL_NUM; i++) if (test_bit(i, &vl_bitmap)) - udev->qos.vl[vl_cnt++] = i; + udev->qos.ctp_req_vl[cdma_vl_cnt++] = i; - if (!vl_cnt) - return -EBUSY; + if (!cdma_vl_cnt) { + ubase_err(udev, "cdma doesn't have any vl.\n"); + return -EIO; + } - udev->qos.vl_num = vl_cnt; + udev->qos.ctp_vl_num = cdma_vl_cnt; ubase_dbg(udev, "ctrlq query vl_bitmap = %lx.\n", vl_bitmap); return 0; } +static bool ubase_check_udma_sl_valid(struct ubase_dev *udev, u8 udma_tp_sl_cnt, + u8 udma_ctp_sl_cnt) +{ + if (!ubase_dev_udma_supported(udev)) + return true; + + if (ubase_dev_ubl_supported(udev) && !(udma_tp_sl_cnt + udma_ctp_sl_cnt)) + return false; + + if (!ubase_dev_ubl_supported(udev) && !udma_tp_sl_cnt) + return false; + + return true; +} + static int ubase_ctrlq_query_sl(struct ubase_dev *udev) { unsigned long unic_sl_bitmap, udma_tp_sl_bitmap, udma_ctp_sl_bitmap; @@ -1015,8 +1004,7 @@ static int ubase_ctrlq_query_sl(struct ubase_dev *udev) return -EIO; } - if (ubase_dev_udma_supported(udev) && - !(udma_tp_sl_cnt + udma_ctp_sl_cnt)) { + if (!ubase_check_udma_sl_valid(udev, udma_tp_sl_cnt, udma_ctp_sl_cnt)) { ubase_err(udev, "udma doesn't have any sl.\n"); return -EIO; } diff --git a/drivers/ub/ubase/ubase_tp.c b/drivers/ub/ubase/ubase_tp.c index f18854fdc319..083ac656c457 100644 --- a/drivers/ub/ubase/ubase_tp.c +++ b/drivers/ub/ubase/ubase_tp.c @@ -7,10 +7,13 @@ #include #include "ubase_ctrlq.h" +#include "ubase_dev.h" #include "ubase_reset.h" #include "ubase_tp.h" -int ubase_notify_tp_fd_by_ctrlq(struct ubase_dev *udev, u32 tpn) +#define UBASE_TRANS_TYPE_UM_TP 0x2 + +static int ubase_notify_tp_flush_done(struct ubase_dev *udev, u32 tpn) { struct ubase_ctrlq_tp_fd_req req = {0}; struct ubase_ctrlq_msg msg = {0}; @@ -74,7 +77,7 @@ int ubase_ae_tp_flush_done(struct notifier_block *nb, unsigned long event, tp_num = info->aeqe->event.queue_event.num; - return ubase_notify_tp_fd_by_ctrlq(udev, tp_num); + return ubase_notify_tp_flush_done(udev, tp_num); } int ubase_ae_tp_level_error(struct notifier_block *nb, unsigned long event, @@ -96,7 +99,7 @@ int ubase_ae_tp_level_error(struct notifier_block *nb, unsigned long event, return 0; } -static int ubase_create_tp_tpg_by_ctrlq(struct ubase_dev *udev, u32 vl) +static int ubase_create_tp_tpg(struct ubase_dev *udev, u32 vl) { struct ubase_tp_layer_ctx *tp_ctx = &udev->tp_ctx; struct ubase_ctrlq_create_tp_resp resp = {0}; @@ -133,7 +136,7 @@ static int ubase_create_tp_tpg_by_ctrlq(struct ubase_dev *udev, u32 vl) return 0; } -static void ubase_wait_tp_flush_done_by_ctrlq(struct ubase_dev *udev, u32 vl) +static void ubase_wait_tp_flush_done(struct ubase_dev *udev, u32 vl) { struct ubase_tpg *tpg = &udev->tp_ctx.tpg[vl]; int i; @@ -150,7 +153,7 @@ static void ubase_wait_tp_flush_done_by_ctrlq(struct ubase_dev *udev, u32 vl) vl, atomic_read(&tpg->tp_fd_cnt)); } -static void ubase_destroy_tp_tpg_by_ctrlq(struct ubase_dev *udev, u32 vl) +static void ubase_destroy_tp_tpg(struct ubase_dev *udev, u32 vl) { struct ubase_ctrlq_destroy_tp_req req = {0}; struct ubase_ctrlq_msg msg = {0}; @@ -176,24 +179,24 @@ static void ubase_destroy_tp_tpg_by_ctrlq(struct ubase_dev *udev, u32 vl) return; } - ubase_wait_tp_flush_done_by_ctrlq(udev, vl); + ubase_wait_tp_flush_done(udev, vl); } -static void ubase_destroy_multi_tp_tpg_by_ctrlq(struct ubase_dev *udev, u32 num) +static void ubase_destroy_multi_tp_tpg(struct ubase_dev *udev, u32 num) { u32 idx; for (idx = 0; idx < num; idx++) - ubase_destroy_tp_tpg_by_ctrlq(udev, idx); + ubase_destroy_tp_tpg(udev, idx); } -static int ubase_create_multi_tp_tpg_by_ctrlq(struct ubase_dev *udev) +static int ubase_create_multi_tp_tpg(struct ubase_dev *udev) { int ret; u32 i; for (i = 0; i < udev->caps.unic_caps.tpg.max_cnt; i++) { - ret = ubase_create_tp_tpg_by_ctrlq(udev, i); + ret = ubase_create_tp_tpg(udev, i); if (ret) { ubase_err(udev, "failed to create tp tpg, tpgn = %u, ret = %d.\n", i, ret); @@ -204,7 +207,7 @@ static int ubase_create_multi_tp_tpg_by_ctrlq(struct ubase_dev *udev) return 0; err_create_tp_tpg: - ubase_destroy_multi_tp_tpg_by_ctrlq(udev, i); + ubase_destroy_multi_tp_tpg(udev, i); return ret; } @@ -227,7 +230,7 @@ int ubase_dev_init_tp_tpg(struct ubase_dev *udev) } spin_unlock(&tp_ctx->tpg_lock); - ret = ubase_create_multi_tp_tpg_by_ctrlq(udev); + ret = ubase_create_multi_tp_tpg(udev); if (ret) { spin_lock(&tp_ctx->tpg_lock); devm_kfree(udev->dev, tp_ctx->tpg); @@ -251,7 +254,7 @@ void ubase_dev_uninit_tp_tpg(struct ubase_dev *udev) return; if (!test_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits)) - ubase_destroy_multi_tp_tpg_by_ctrlq(udev, num); + ubase_destroy_multi_tp_tpg(udev, num); spin_lock(&tp_ctx->tpg_lock); devm_kfree(udev->dev, tp_ctx->tpg); diff --git a/drivers/ub/ubase/ubase_tp.h b/drivers/ub/ubase/ubase_tp.h index 42a3cb4eb8c5..63ec0e61a79e 100644 --- a/drivers/ub/ubase/ubase_tp.h +++ b/drivers/ub/ubase/ubase_tp.h @@ -13,8 +13,6 @@ #define UBASE_TRANS_TYPE_UM_TP 0x2 -#define UBASE_TP_PORT_BITMAP_STEP 2 - #define UBASE_WAIT_TP_FLUSH_TOTAL_STEPS 12 struct ubase_tp_ctx { diff --git a/include/ub/ubase/ubase_comm_dev.h b/include/ub/ubase/ubase_comm_dev.h index 37950410345e..9d0f52ab75c1 100644 --- a/include/ub/ubase/ubase_comm_dev.h +++ b/include/ub/ubase/ubase_comm_dev.h @@ -18,7 +18,6 @@ struct iova_slot; #define UBASE_IOVA_COMM_PFN_CNT 1 #define UBASE_MAX_DSCP (64) #define UBASE_MAX_SL_NUM (16U) -#define UBASE_MAX_REQ_VL_NUM (8U) #define UBASE_MAX_VL_NUM (16U) #if UBASE_MAX_VL_NUM < IEEE_8021QAZ_MAX_TCS #error "UBASE_MAX_VL_NUM can't less than IEEE_8021QAZ_MAX_TCS" @@ -251,7 +250,6 @@ struct ubase_resource_space { /** * struct ubase_adev_qos - ubase auxiliary device qos information - * @rdma_vl_num: rdma vl number * @rdma_tp_vl_num: rdma tp vl number * @rdma_ctp_vl_num: rdma ctp vl number * @rdma_tp_resp_vl_offset: rdma tp response vl offset, @@ -260,15 +258,12 @@ struct ubase_resource_space { * rdma_ctp_resp_vl = rdma_ctp_resp_vl + rdma_ctp_resp_vl_offset * @max_vl: max vl number * @resv: reserved bits - * @rdma_sl_num: rdma sl number * @rdma_tp_sl_num: rdma tp sl number * @rdma_ctp_sl_num: rdma ctp sl number * @nic_sl_num: nic sl number * @nic_vl_num: nic vl number - * @rdma_vl: rdma vl * @rdma_tp_req_vl: rdma tp request vl * @rdma_ctp_req_vl: rdma ctp request vl - * @rdma_sl: rdma sl * @rdma_tp_sl: rdma tp sl * @rdma_ctp_sl: rdma ctp sl * @nic_sl: nic sl @@ -278,15 +273,11 @@ struct ubase_resource_space { */ struct ubase_adev_qos { /* udma/cdma resource */ - u8 sl_num; - u8 sl[UBASE_MAX_SL_NUM]; u8 tp_sl_num; u8 tp_sl[UBASE_MAX_SL_NUM]; u8 ctp_sl_num; u8 ctp_sl[UBASE_MAX_SL_NUM]; - u8 vl_num; - u8 vl[UBASE_MAX_VL_NUM]; u8 tp_vl_num; u8 tp_resp_vl_offset; u8 tp_req_vl[UBASE_MAX_VL_NUM]; @@ -318,22 +309,6 @@ struct ubase_ue_node { u16 bus_ue_id; }; -struct ubase_ue_caps { - u8 ceq_vector_num; - u8 aeq_vector_num; - u32 aeqe_depth; - u32 ceqe_depth; - u32 jfs_max_cnt; - u32 jfs_depth; - u32 jfr_max_cnt; - u32 jfr_depth; - u32 jfc_max_cnt; - u32 jfc_depth; - u32 rc_max_cnt; - u32 rc_depth; - u32 jtg_max_cnt; -}; - #define UBASE_BUS_EID_LEN 4 /** @@ -352,6 +327,7 @@ bool ubase_adev_prealloc_supported(struct auxiliary_device *aux_dev); struct ubase_resource_space *ubase_get_io_base(struct auxiliary_device *adev); struct ubase_resource_space *ubase_get_mem_base(struct auxiliary_device *adev); struct ubase_caps *ubase_get_dev_caps(struct auxiliary_device *adev); +const struct ubase_adev_com *ubase_get_mdrv_data(struct auxiliary_device *adev); struct ubase_adev_caps *ubase_get_unic_caps(struct auxiliary_device *adev); struct ubase_adev_caps *ubase_get_udma_caps(struct auxiliary_device *adev); struct ubase_adev_caps *ubase_get_cdma_caps(struct auxiliary_device *adev); -- Gitee From e911001387ed828279af9d3d962c9389c93ecbfc Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Tue, 9 Dec 2025 19:29:52 +0800 Subject: [PATCH 03/12] ub: ubase: Fix the issue of deadlock by quantities of log in the ctrlq crq task. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA -------------------------------------------------------------- To avoid deadlock crash by quantities of log, this patch adds the rate limited log and limits the number of times the ctrlq crq task handles ctrlq crq queue. Fixes: d7ce08663cc5 ("ub: ubase: Supports for ctrl queue management.") Signed-off-by: Zhang Lei --- drivers/ub/ubase/ubase_ctrlq.c | 39 ++++++++++++++++++++++++---------- drivers/ub/ubase/ubase_dev.c | 16 ++++++++++++++ drivers/ub/ubase/ubase_dev.h | 31 +++++++++++++++++++++++++++ drivers/ub/ubase/ubase_eq.c | 2 +- drivers/ub/ubase/ubase_eq.h | 2 +- 5 files changed, 77 insertions(+), 13 deletions(-) diff --git a/drivers/ub/ubase/ubase_ctrlq.c b/drivers/ub/ubase/ubase_ctrlq.c index 8827318f97a8..5f6b6cf2559e 100644 --- a/drivers/ub/ubase/ubase_ctrlq.c +++ b/drivers/ub/ubase/ubase_ctrlq.c @@ -987,15 +987,17 @@ void ubase_ctrlq_handle_crq_msg(struct ubase_dev *udev, spin_lock_bh(&csq->lock); ctx = &udev->ctrlq.msg_queue[seq]; if (!ctx->valid) { - ubase_warn(udev, - "seq is invalid, opcode = 0x%x, service_type = 0x%x, seq = %u.\n", - head->opcode, head->service_type, seq); - goto unlock; + spin_unlock_bh(&csq->lock); + ubase_warn_rl(udev, udev->log_rs.ctrlq_self_seq_invalid_log_cnt, + "seq is invalid, opcode = 0x%x, service_type = 0x%x, seq = %u.\n", + head->opcode, head->service_type, seq); + return; } if (ctx->is_sync) { ubase_ctrlq_notify_completed(udev, head, seq, msg_data, data_len); - goto unlock; + spin_unlock_bh(&csq->lock); + return; } ctx->valid = 0; spin_unlock_bh(&csq->lock); @@ -1003,9 +1005,6 @@ void ubase_ctrlq_handle_crq_msg(struct ubase_dev *udev, ubase_ctrlq_crq_event_callback(udev, head, msg_data, data_len, seq); return; - -unlock: - spin_unlock_bh(&csq->lock); } static void ubase_ctrlq_handle_self_msg(struct ubase_dev *udev, @@ -1049,9 +1048,10 @@ static void ubase_ctrlq_handle_other_msg(struct ubase_dev *udev, spin_lock_bh(&csq->lock); ctx = udev->ctrlq.msg_queue[seq]; if (!ctx.valid) { - ubase_warn(udev, "invalid seq = %u, opcode = 0x%x, service_type = 0x%x.\n", - seq, head->opcode, head->service_type); spin_unlock_bh(&csq->lock); + ubase_warn_rl(udev, udev->log_rs.ctrlq_other_seq_invalid_log_cnt, + "invalid seq = %u, opcode = 0x%x, service_type = 0x%x.\n", + seq, head->opcode, head->service_type); return; } if (!ctx.is_sync) @@ -1096,14 +1096,18 @@ static inline void ubase_ctrlq_reset_crq_ci(struct ubase_dev *udev) static void ubase_ctrlq_crq_handler(struct ubase_dev *udev) { +#define UBASE_CTRLQ_CRQ_POLLING_BUDGET 256 + struct ubase_ctrlq_ring *crq = &udev->ctrlq.crq; struct ub_entity *ue = to_ub_entity(udev->dev); struct ubase_ctrlq_base_block head = {0}; + u32 cnt = 0; u8 bb_num; u8 *addr; u16 seq; - while (!ubase_ctrlq_crq_is_empty(udev, &udev->hw)) { + while (cnt++ < UBASE_CTRLQ_CRQ_POLLING_BUDGET && + !ubase_ctrlq_crq_is_empty(udev, &udev->hw)) { if (!test_bit(UBASE_CTRLQ_STATE_ENABLE, &udev->ctrlq.state)) { ubase_warn(udev, "ctrlq is disabled in crq.\n"); return; @@ -1135,6 +1139,19 @@ static void ubase_ctrlq_crq_handler(struct ubase_dev *udev) ubase_ctrlq_update_crq_ci(udev, bb_num); } + + if (udev->log_rs.ctrlq_self_seq_invalid_log_cnt || + udev->log_rs.ctrlq_other_seq_invalid_log_cnt) { + ubase_warn(udev, + "ubase log rate is limited, ctrlq_self_seq_invalid_log_cnt = %u, ctrlq_other_seq_invalid_log_cnt = %u.\n", + udev->log_rs.ctrlq_self_seq_invalid_log_cnt, + udev->log_rs.ctrlq_other_seq_invalid_log_cnt); + udev->log_rs.ctrlq_self_seq_invalid_log_cnt = 0; + udev->log_rs.ctrlq_other_seq_invalid_log_cnt = 0; + } + + if (!ubase_ctrlq_crq_is_empty(udev, &udev->hw)) + ubase_ctrlq_task_schedule(udev); } void ubase_ctrlq_service_task(struct ubase_delay_work *ubase_work) diff --git a/drivers/ub/ubase/ubase_dev.c b/drivers/ub/ubase/ubase_dev.c index 086e16cef4b6..e9c289ee0e29 100644 --- a/drivers/ub/ubase/ubase_dev.c +++ b/drivers/ub/ubase/ubase_dev.c @@ -657,7 +657,23 @@ static int ubase_notify_drv_capbilities(struct ubase_dev *udev) return __ubase_cmd_send_in(udev, &in); } +static int ubase_log_rs_init(struct ubase_dev *udev) +{ +#define UBASE_RATELIMIT_INTERVAL (2 * HZ) +#define UBASE_RATELIMIT_BURST 40 + + raw_spin_lock_init(&udev->log_rs.rs.lock); + udev->log_rs.rs.interval = UBASE_RATELIMIT_INTERVAL; + udev->log_rs.rs.burst = UBASE_RATELIMIT_BURST; + + return 0; +} + static const struct ubase_init_function ubase_init_func_map[] = { + { + "init log rs", UBASE_SUP_ALL, 0, + ubase_log_rs_init, NULL + }, { "init work queue", UBASE_SUP_ALL, 0, ubase_wq_init, ubase_wq_uninit diff --git a/drivers/ub/ubase/ubase_dev.h b/drivers/ub/ubase/ubase_dev.h index 5270246540e7..ce2cac4b0917 100644 --- a/drivers/ub/ubase/ubase_dev.h +++ b/drivers/ub/ubase/ubase_dev.h @@ -42,6 +42,30 @@ dev_warn(_udev->dev, "(pid %d) " fmt, \ current->pid, ##__VA_ARGS__) +#define ubase_err_rl(_udev, log_cnt, fmt, ...) do { \ + if (__ratelimit(&(_udev->log_rs.rs))) \ + dev_err(_udev->dev, "(pid %d) " fmt, \ + current->pid, ##__VA_ARGS__); \ + else \ + (log_cnt)++; \ +} while (0) + +#define ubase_info_rl(_udev, log_cnt, fmt, ...) do { \ + if (__ratelimit(&(_udev->log_rs.rs))) \ + dev_info(_udev->dev, "(pid %d) " fmt, \ + current->pid, ##__VA_ARGS__); \ + else \ + (log_cnt)++; \ +} while (0) + +#define ubase_warn_rl(_udev, log_cnt, fmt, ...) do { \ + if (__ratelimit(&(_udev->log_rs.rs))) \ + dev_warn(_udev->dev, "(pid %d) " fmt, \ + current->pid, ##__VA_ARGS__); \ + else \ + (log_cnt)++; \ +} while (0) + struct ubase_adev { struct auxiliary_device adev; struct ubase_dev *udev; @@ -252,6 +276,12 @@ struct ubase_prealloc_mem_info { struct ubase_pmem_ctx udma; }; +struct ubase_log_rs { + struct ratelimit_state rs; + u16 ctrlq_self_seq_invalid_log_cnt; + u16 ctrlq_other_seq_invalid_log_cnt; +}; + struct ubase_dev { struct device *dev; int dev_id; @@ -292,6 +322,7 @@ struct ubase_dev { struct ubase_arq_msg_ring arq; struct ubase_prealloc_mem_info pmem_info; u8 dev_mac[ETH_ALEN]; + struct ubase_log_rs log_rs; }; #define UBASE_ERR_MSG_LEN 128 diff --git a/drivers/ub/ubase/ubase_eq.c b/drivers/ub/ubase/ubase_eq.c index db1dc72f2caf..2afe9c3bf7fc 100644 --- a/drivers/ub/ubase/ubase_eq.c +++ b/drivers/ub/ubase/ubase_eq.c @@ -210,7 +210,7 @@ static void ubase_errhandle_task_schedule(struct ubase_dev *udev) &udev->service_task.service_task, 0); } -static void ubase_ctrlq_task_schedule(struct ubase_dev *udev) +void ubase_ctrlq_task_schedule(struct ubase_dev *udev) { if (!test_and_set_bit(UBASE_STATE_CTRLQ_SERVICE_SCHED, &udev->service_task.state)) { diff --git a/drivers/ub/ubase/ubase_eq.h b/drivers/ub/ubase/ubase_eq.h index a4a15c9144f4..59fa2c620720 100644 --- a/drivers/ub/ubase/ubase_eq.h +++ b/drivers/ub/ubase/ubase_eq.h @@ -204,5 +204,5 @@ void ubase_unregister_ae_event(struct ubase_dev *udev); void ubase_enable_misc_vector(struct ubase_dev *udev, bool enable); void ubase_disable_ce_irqs(struct ubase_dev *udev); int ubase_enable_ce_irqs(struct ubase_dev *udev); - +void ubase_ctrlq_task_schedule(struct ubase_dev *udev); #endif -- Gitee From 51d1bd2812b6cc2e9d8d96631658706f5b54653f Mon Sep 17 00:00:00 2001 From: Chuan Wu Date: Tue, 9 Dec 2025 19:44:25 +0800 Subject: [PATCH 04/12] ub: ubase: optimize print format of fw_ver in debugfs. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ------------------------------------------------------------- This patch optimized the print format of fw_version in ubase debugfs, make it the same as the log format used in initial printing and 'ethtool -i'. Fixes: a15280279576 ("ub: ubase: support debugfs public interface.") Signed-off-by: Chuan Wu --- drivers/ub/ubase/debugfs/ubase_debugfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/ub/ubase/debugfs/ubase_debugfs.c b/drivers/ub/ubase/debugfs/ubase_debugfs.c index f8c7fbecf4b2..f5e43fac8143 100644 --- a/drivers/ub/ubase/debugfs/ubase_debugfs.c +++ b/drivers/ub/ubase/debugfs/ubase_debugfs.c @@ -95,13 +95,17 @@ static void ubase_dbg_dump_caps_info(struct seq_file *s, struct ubase_dev *udev) {"\tdie_id: %u\n", dev_caps->die_id}, {"\tue_id: %u\n", dev_caps->ue_id}, {"\tnl_id: %u\n", dev_caps->nl_id}, - {"\tfw_version: %u\n", dev_caps->fw_version}, }; int i; for (i = 0; i < ARRAY_SIZE(ubase_common_caps_info); i++) seq_printf(s, ubase_common_caps_info[i].format, ubase_common_caps_info[i].caps_info); + seq_printf(s, "\tfw_version: %u.%u.%u.%u\n", + u32_get_bits(dev_caps->fw_version, UBASE_FW_VERSION_BYTE3_MASK), + u32_get_bits(dev_caps->fw_version, UBASE_FW_VERSION_BYTE2_MASK), + u32_get_bits(dev_caps->fw_version, UBASE_FW_VERSION_BYTE1_MASK), + u32_get_bits(dev_caps->fw_version, UBASE_FW_VERSION_BYTE0_MASK)); } static void ubase_dbg_dump_common_caps(struct seq_file *s, struct ubase_dev *udev) -- Gitee From d39249c75421ee9f3f8a10c77ea88af049b79eb8 Mon Sep 17 00:00:00 2001 From: Chuan Wu Date: Tue, 9 Dec 2025 19:55:33 +0800 Subject: [PATCH 05/12] ub: ubase: add ip_over_urma API for udma. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ------------------------------------------------------------- This patch add two export API to query if ip over urma capabilities is supported or not for udma. Fixes: 313470c59d7f ("ub: ubase: add CMDQ&CTRLQ compatibility code") Signed-off-by: Chuan Wu --- drivers/ub/ubase/ubase_dev.c | 39 +++++++++++++++++++++++++++++++ include/ub/ubase/ubase_comm_dev.h | 8 +++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/drivers/ub/ubase/ubase_dev.c b/drivers/ub/ubase/ubase_dev.c index e9c289ee0e29..efa220bacdff 100644 --- a/drivers/ub/ubase/ubase_dev.c +++ b/drivers/ub/ubase/ubase_dev.c @@ -1403,6 +1403,45 @@ bool ubase_adev_mac_stats_supported(struct auxiliary_device *adev) } EXPORT_SYMBOL(ubase_adev_mac_stats_supported); +/** + * ubase_adev_ip_over_urma_supported() - determine whether to support IP over + * urma + * @adev: auxiliary device + * + * This function is used to determine whether to support IP over urma. + * + * Context: Any context. + * Return: true or false + */ +bool ubase_adev_ip_over_urma_supported(struct auxiliary_device *adev) +{ + if (!adev) + return false; + + return ubase_ip_over_urma_supported(__ubase_get_udev_by_adev(adev)); +} +EXPORT_SYMBOL(ubase_adev_ip_over_urma_supported); + +/** + * ubase_adev_ip_over_urma_utp_supported() - determine whether to support utp + * when IP over urma is supported + * @adev: auxiliary device + * + * This function is used to determine whether to support utp when IP over urma + * is supported + * + * Context: Any context. + * Return: true or false + */ +bool ubase_adev_ip_over_urma_utp_supported(struct auxiliary_device *adev) +{ + if (!adev) + return false; + + return ubase_ip_over_urma_utp_supported(__ubase_get_udev_by_adev(adev)); +} +EXPORT_SYMBOL(ubase_adev_ip_over_urma_utp_supported); + static void ubase_activate_notify(struct ubase_dev *udev, struct auxiliary_device *adev, bool activate) { diff --git a/include/ub/ubase/ubase_comm_dev.h b/include/ub/ubase/ubase_comm_dev.h index 9d0f52ab75c1..fbec3624c87b 100644 --- a/include/ub/ubase/ubase_comm_dev.h +++ b/include/ub/ubase/ubase_comm_dev.h @@ -143,7 +143,6 @@ struct ubase_caps { * struct ubase_res_caps - ubase resource capbilities * @max_cnt: the resource max count * @start_idx: start index - * @reserved_cnt: reserved count * @depth: the queue depth of the resource */ struct ubase_res_caps { @@ -172,10 +171,6 @@ struct ubase_pmem_caps { * @jtg_max_cnt: jetty group max count * @rc_max_cnt: rc max count * @rc_que_depth: rc queue depth - * @ccc_max_cnt: ccc max count - * @dest_addr_max_cnt: dest addr max count - * @seid_upi_max_cnt:seid upi max count - * @tpm_max_cnt: tpm max count * @cqe_size: cqe size */ struct ubase_adev_caps { @@ -324,6 +319,9 @@ bool ubase_adev_ctrlq_supported(struct auxiliary_device *adev); bool ubase_adev_eth_mac_supported(struct auxiliary_device *adev); bool ubase_adev_mac_stats_supported(struct auxiliary_device *aux_dev); bool ubase_adev_prealloc_supported(struct auxiliary_device *aux_dev); +bool ubase_adev_ip_over_urma_supported(struct auxiliary_device *adev); +bool ubase_adev_ip_over_urma_utp_supported(struct auxiliary_device *adev); + struct ubase_resource_space *ubase_get_io_base(struct auxiliary_device *adev); struct ubase_resource_space *ubase_get_mem_base(struct auxiliary_device *adev); struct ubase_caps *ubase_get_dev_caps(struct auxiliary_device *adev); -- Gitee From 4d49ef0166a7fd6c3bf6e329f1e73c94e9094aff Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Mon, 8 Dec 2025 10:56:12 +0800 Subject: [PATCH 06/12] ub: ubase: Fix the issue of mismatch between the ubase aeqe structure and the protocol. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ------------------------------------------------------------------ For ubase_aeqe structure, the field of num is 32 bits, but the protocol specifies that this field should be 20 bits. This patch modifies the bit width of the num field to be consistent with the protocol. Fixes: 9cc0f22b5d69 ("ub: ubase: support for async event process") Signed-off-by: Zhang Lei --- include/ub/ubase/ubase_comm_eq.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/ub/ubase/ubase_comm_eq.h b/include/ub/ubase/ubase_comm_eq.h index d1efad0a79b3..0ed03d7e6140 100644 --- a/include/ub/ubase/ubase_comm_eq.h +++ b/include/ub/ubase/ubase_comm_eq.h @@ -86,9 +86,10 @@ struct ubase_aeqe { union { struct { - u32 num; - u32 rsv0; + u32 num : 20; + u32 rsv0 : 12; u32 rsv1; + u32 rsv2; } queue_event; #pragma pack(push, 1) -- Gitee From ec8fa86dd06264e9a83181a68668f1bd43d48d75 Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Mon, 8 Dec 2025 14:55:49 +0800 Subject: [PATCH 07/12] net: unic: Restore default queue count per tc when tc number changes. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA -------------------------------------------------------------- This patch restores the number of queues for each tc to the default value of 1 when the number of tc changes. Fixes: c20baa942215 ("net: unic: support config/query the mapping between dscp and tc") Signed-off-by: Zhang Lei --- drivers/net/ub/unic/unic_dev.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/ub/unic/unic_dev.c b/drivers/net/ub/unic/unic_dev.c index 7d0405e751b0..24dd70339957 100644 --- a/drivers/net/ub/unic/unic_dev.c +++ b/drivers/net/ub/unic/unic_dev.c @@ -46,6 +46,7 @@ MODULE_PARM_DESC(debug, "enable unic debug log, 0:disable, others:enable, defaul #define DEFAULT_MSG_LEVEL (NETIF_MSG_PROBE | NETIF_MSG_LINK | \ NETIF_MSG_IFDOWN | NETIF_MSG_IFUP) +#define DEFAULT_RSS_SIZE 1 static struct workqueue_struct *unic_wq; @@ -308,7 +309,7 @@ static int unic_init_channels_attr(struct unic_dev *unic_dev) channels->vl.vl_num = 1; channels->rss_vl_num = 1; - channels->rss_size = 1; + channels->rss_size = DEFAULT_RSS_SIZE; channels->num = channels->rss_size * channels->rss_vl_num; channels->sqebb_depth = unic_caps->jfs.depth; channels->rqe_depth = unic_caps->jfr.depth; @@ -994,9 +995,6 @@ int unic_change_rss_size(struct unic_dev *unic_dev, u32 new_rss_size, struct unic_channels *channels = &unic_dev->channels; int ret; - dev_info(unic_dev->comdev.adev->dev.parent, - "change rss_size from %u to %u.\n", org_rss_size, new_rss_size); - mutex_lock(&channels->mutex); __unic_uninit_channels(unic_dev); @@ -1017,17 +1015,12 @@ int unic_change_rss_size(struct unic_dev *unic_dev, u32 new_rss_size, int unic_update_channels(struct unic_dev *unic_dev, u8 vl_num) { - struct auxiliary_device *adev = unic_dev->comdev.adev; struct unic_channels *channels = &unic_dev->channels; - u32 new_rss_size, old_rss_size = channels->rss_size; + u32 old_rss_size = channels->rss_size; channels->rss_vl_num = unic_get_rss_vl_num(unic_dev, vl_num); - if (old_rss_size * channels->rss_vl_num > unic_channels_max_num(adev)) - new_rss_size = unic_get_max_rss_size(unic_dev); - else - new_rss_size = old_rss_size; - return unic_change_rss_size(unic_dev, new_rss_size, old_rss_size); + return unic_change_rss_size(unic_dev, DEFAULT_RSS_SIZE, old_rss_size); } static struct net_device *unic_alloc_netdev(struct auxiliary_device *adev) -- Gitee From faa70acc5d7f1eaa902276086916019d3c2602e2 Mon Sep 17 00:00:00 2001 From: Shi Long Date: Tue, 9 Dec 2025 15:18:06 +0800 Subject: [PATCH 08/12] ub: ubase: add opcode to query ub port_bitmap. drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA --------------------------------------------------------- This patch fixes the following issues: 1.add 0x5105 opcode to query ub port_bitmap. Fixes: 3fb8b7d41539 ("ub: ubase: add support of ubase driver for ub network") Signed-off-by: Shi Long --- drivers/ub/ubase/ubase_hw.c | 21 ++++++++++++++++----- include/ub/ubase/ubase_comm_cmd.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/ub/ubase/ubase_hw.c b/drivers/ub/ubase/ubase_hw.c index d58fd69cd25f..534441fe5d69 100644 --- a/drivers/ub/ubase/ubase_hw.c +++ b/drivers/ub/ubase/ubase_hw.c @@ -649,16 +649,27 @@ int ubase_query_hw_oor_caps(struct ubase_dev *udev) int ubase_query_port_bitmap(struct ubase_dev *udev) { +#define OPCODE_CNT 2 + struct ubase_caps *dev_caps = &udev->caps.dev_caps; struct ubase_query_port_bitmap_resp resp = {0}; + enum ubase_opcode_type opcode[OPCODE_CNT]; struct ubase_cmd_buf in, out; - int ret; + int ret, i; - ubase_fill_inout_buf(&in, UBASE_OPC_QUERY_PORT_BITMAP, true, 0, NULL); - ubase_fill_inout_buf(&out, UBASE_OPC_QUERY_PORT_BITMAP, true, - sizeof(resp), &resp); + opcode[0] = UBASE_OPC_QUERY_UB_PORT_BITMAP; + opcode[1] = UBASE_OPC_QUERY_PORT_BITMAP; - ret = __ubase_cmd_send_inout(udev, &in, &out); + for (i = 0; i < OPCODE_CNT; i++) { + ubase_fill_inout_buf(&in, opcode[i], true, 0, NULL); + ubase_fill_inout_buf(&out, opcode[i], true, sizeof(resp), &resp); + ret = __ubase_cmd_send_inout(udev, &in, &out); + if (ret != -EOPNOTSUPP) + break; + + dev_warn(udev->dev, + "The function of querying real-time traffic in UBOE mode is not supported.\n"); + } if (ret && ret != -EPERM) { dev_err(udev->dev, "failed to query port bitmap, ret = %d.\n", ret); diff --git a/include/ub/ubase/ubase_comm_cmd.h b/include/ub/ubase/ubase_comm_cmd.h index 4efbf8402d9d..6a195bbdf699 100644 --- a/include/ub/ubase/ubase_comm_cmd.h +++ b/include/ub/ubase/ubase_comm_cmd.h @@ -87,6 +87,7 @@ enum ubase_opcode_type { UBASE_OPC_QUERY_FLUSH_STATUS = 0x5102, UBASE_OPC_START_PERF_STATS = 0x5103, UBASE_OPC_STOP_PERF_STATS = 0x5104, + UBASE_OPC_QUERY_UB_PORT_BITMAP = 0x5105, /* PHY commands */ UBASE_OPC_CONFIG_SPEED_DUP = 0x6100, -- Gitee From 8f6eb77901de59f314e3db4dfd66a2beeafad1df Mon Sep 17 00:00:00 2001 From: Xiaobo Zhang Date: Tue, 9 Dec 2025 20:55:07 +0800 Subject: [PATCH 09/12] ub: ubase: fix a issue of udma device's eid deleted when stop rx stream and reset concurrently drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ------------------------------------------------------------------ This patch used to fix a issue of udma device's eid deleted when stop rx stream and reset concurrently. Currently, when udma deleted tp/jetty, ubase sends twice fe disabling messages to control plane. As a result, the management and control plane cannot obtain the device eid from the hardware in the second deactivate message. To avoid this problem, ubase needs to send fe deactivate message after the reset is complete in the rx flow stop interface. In the rx flow recovery interface, directly returns the ebusy when resetting. Fixes: 5515a4226467 ("ub: ubase: support for activate/deactivate dev interface") Signed-off-by: Xiaobo Zhang --- drivers/ub/ubase/ubase_arq.c | 4 --- drivers/ub/ubase/ubase_dev.c | 62 ++++++++++++++++++++++++++++++---- drivers/ub/ubase/ubase_dev.h | 1 + drivers/ub/ubase/ubase_reset.c | 3 ++ 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/drivers/ub/ubase/ubase_arq.c b/drivers/ub/ubase/ubase_arq.c index 10735a68d7aa..4ae77f3cccbc 100644 --- a/drivers/ub/ubase/ubase_arq.c +++ b/drivers/ub/ubase/ubase_arq.c @@ -52,8 +52,6 @@ static int ubase_activate_ue(struct ubase_dev *udev, struct ub_entity *ue, int ret; ret = ub_activate_entity(ue, bus_ue_id); - if (ret == -EBUSY) - ret = ubase_activate_handler(udev, bus_ue_id); if (ret) dev_err(udev->dev, "failed to activate ue dev, ue id = %u, msn = %u, ret = %d.\n", @@ -68,8 +66,6 @@ static int ubase_deactivate_ue(struct ubase_dev *udev, struct ub_entity *ue, int ret; ret = ub_deactivate_entity(ue, bus_ue_id); - if (ret == -EBUSY) - ret = ubase_deactivate_handler(udev, bus_ue_id); if (ret) dev_err(udev->dev, "failed to deactivate ue dev, ue id=%u, msn=%u, ret=%d.\n", diff --git a/drivers/ub/ubase/ubase_dev.c b/drivers/ub/ubase/ubase_dev.c index efa220bacdff..d63a045137e1 100644 --- a/drivers/ub/ubase/ubase_dev.c +++ b/drivers/ub/ubase/ubase_dev.c @@ -1626,26 +1626,39 @@ int ubase_activate_dev(struct auxiliary_device *adev) { struct ubase_dev *udev; struct ub_entity *ue; - int ret; + int ret = 0; if (!adev) return 0; udev = __ubase_get_udev_by_adev(adev); + ubase_info(udev, "ubase activate dev, state_bits = 0x%lx.\n", + udev->state_bits); + + if (test_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits)) { + ubase_info(udev, "skip activate dev while resetting.\n"); + goto skip_activate_dev; + } + ue = container_of(udev->dev, struct ub_entity, dev); - if (ubase_activate_proxy_supported(udev) && - !test_bit(UBASE_STATE_DISABLED_B, &udev->state_bits)) + if (ubase_activate_proxy_supported(udev)) ret = ub_activate_entity(ue, ue->entity_idx); else ret = ubase_activate_handler(udev, ue->entity_idx); if (ret) { + if (test_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits)) { + ubase_info(udev, "skip activate dev while resetting.\n"); + ret = 0; + goto skip_activate_dev; + } ubase_err(udev, "failed to activate ubase dev, ret = %d.\n", ret); goto activate_dev_err; } +skip_activate_dev: ubase_activate_notify(udev, adev, true); activate_dev_err: @@ -1655,6 +1668,27 @@ int ubase_activate_dev(struct auxiliary_device *adev) } EXPORT_SYMBOL(ubase_activate_dev); +static int ubase_deactivate_wait_reset_done(struct ubase_dev *udev) +{ +#define UBASE_MAX_WAIT_RST_CNT 1000 +#define UBASE_WAIT_RST_TIME 10 + + u16 cnt = 0; + + while (test_bit(UBASE_STATE_RST_WAIT_DEACTIVE_B, &udev->state_bits)) { + if (!cnt) + ubase_info(udev, + "waitting for reset done in deactivate process.\n"); + msleep(UBASE_WAIT_RST_TIME); + if (++cnt >= UBASE_MAX_WAIT_RST_CNT) { + ubase_err(udev, "wait reset done timeout.\n"); + return -EBUSY; + } + } + + return 0; +} + /** * ubase_deactivate_dev() - deactivate device * @adev: auxiliary device @@ -1677,21 +1711,37 @@ int ubase_deactivate_dev(struct auxiliary_device *adev) udev = __ubase_get_udev_by_adev(adev); - ue = container_of(udev->dev, struct ub_entity, dev); + ubase_info(udev, "ubase deactivate dev, state_bits = 0x%lx.\n", + udev->state_bits); + + if (test_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits)) { + ret = ubase_deactivate_wait_reset_done(udev); + if (ret) { + ubase_update_activate_stats(udev, false, ret); + return ret; + } + ubase_activate_notify(udev, adev, false); + goto out; + } + ubase_activate_notify(udev, adev, false); - if (ubase_activate_proxy_supported(udev) && - !test_bit(UBASE_STATE_DISABLED_B, &udev->state_bits)) + ue = container_of(udev->dev, struct ub_entity, dev); + if (ubase_activate_proxy_supported(udev)) ret = ub_deactivate_entity(ue, ue->entity_idx); else ret = ubase_deactivate_handler(udev, ue->entity_idx); + if (ret && test_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits)) + ret = ubase_deactivate_wait_reset_done(udev); + if (ret) { ubase_err(udev, "failed to deactivate ubase dev, ret = %d.\n", ret); ubase_activate_notify(udev, adev, true); } +out: ubase_update_activate_stats(udev, false, ret); return ret; diff --git a/drivers/ub/ubase/ubase_dev.h b/drivers/ub/ubase/ubase_dev.h index ce2cac4b0917..69809bf1838d 100644 --- a/drivers/ub/ubase/ubase_dev.h +++ b/drivers/ub/ubase/ubase_dev.h @@ -148,6 +148,7 @@ enum ubase_dev_state_bit { UBASE_STATE_HIMAC_RESETTING_B, UBASE_STATE_CTX_READY_B, UBASE_STATE_PREALLOC_OK_B, + UBASE_STATE_RST_WAIT_DEACTIVE_B, }; struct ubase_crq_event_nbs { diff --git a/drivers/ub/ubase/ubase_reset.c b/drivers/ub/ubase/ubase_reset.c index b2fe6d9ef559..05c3b7005e31 100644 --- a/drivers/ub/ubase/ubase_reset.c +++ b/drivers/ub/ubase/ubase_reset.c @@ -217,6 +217,7 @@ void ubase_suspend(struct ubase_dev *udev) } set_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits); + set_bit(UBASE_STATE_RST_WAIT_DEACTIVE_B, &udev->state_bits); if (ubase_dev_pmu_supported(udev)) { __ubase_cmd_disable(udev); @@ -257,11 +258,13 @@ void ubase_resume(struct ubase_dev *udev) __ubase_cmd_enable(udev); udev->reset_stat.reset_done_cnt++; udev->reset_stat.hw_reset_done_cnt++; + clear_bit(UBASE_STATE_RST_WAIT_DEACTIVE_B, &udev->state_bits); clear_bit(UBASE_STATE_RST_HANDLING_B, &udev->state_bits); clear_bit(UBASE_STATE_DISABLED_B, &udev->state_bits); return; } + clear_bit(UBASE_STATE_RST_WAIT_DEACTIVE_B, &udev->state_bits); udev->reset_stat.hw_reset_done_cnt++; ubase_suspend_aux_devices(udev); ubase_dev_reset_uninit(udev); -- Gitee From 8ab9cc45a8e9141f20d4a8151bc4d3ab6b103a70 Mon Sep 17 00:00:00 2001 From: Fengyan Mu Date: Tue, 9 Dec 2025 22:57:46 +0800 Subject: [PATCH 10/12] ub: ubase: obtain rc_max_cnt from MAMI drivers inclusion category: Bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA ------------------------------------------------------------------ A VL uses only two RCT queues, which cannot meet the bandwidth requirements. Therefore, each FE needs to be configured with 8 RCT queues. To meet this requirement, UBASE obtains the number of RCT queues from the MAMI instead of the IMP. Fixes: 442b66e0c7b0 ("ub: ubase: Support to config and query the sl scheduling mode and weight in ETS and TM modes.") Signed-off-by: Xuanyu Pu Signed-off-by: Fengyan Mu --- drivers/ub/ubase/ubase_ctrlq.h | 2 +- drivers/ub/ubase/ubase_dev.h | 1 + drivers/ub/ubase/ubase_qos_hw.c | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/ub/ubase/ubase_ctrlq.h b/drivers/ub/ubase/ubase_ctrlq.h index 881f3342393a..e56728e4baae 100644 --- a/drivers/ub/ubase/ubase_ctrlq.h +++ b/drivers/ub/ubase/ubase_ctrlq.h @@ -69,7 +69,7 @@ struct ubase_ctrlq_query_vl_req { struct ubase_ctrlq_query_sl_resp { __le16 unic_sl_bitmap; - u8 rsv0[2]; + __le16 rc_max_cnt; __le16 udma_tp_sl_bitmap; __le16 udma_ctp_sl_bitmap; u8 rsv1[12]; diff --git a/drivers/ub/ubase/ubase_dev.h b/drivers/ub/ubase/ubase_dev.h index 69809bf1838d..f1cba478510a 100644 --- a/drivers/ub/ubase/ubase_dev.h +++ b/drivers/ub/ubase/ubase_dev.h @@ -289,6 +289,7 @@ struct ubase_dev { struct ubase_priv priv; struct ubase_hw hw; + bool use_fixed_rc_num; struct ubase_dev_caps caps; struct ubase_adev_qos qos; struct ubase_dbgfs dbgfs; diff --git a/drivers/ub/ubase/ubase_qos_hw.c b/drivers/ub/ubase/ubase_qos_hw.c index e7737e98e1e5..d7ce78489532 100644 --- a/drivers/ub/ubase/ubase_qos_hw.c +++ b/drivers/ub/ubase/ubase_qos_hw.c @@ -862,7 +862,7 @@ static void ubase_parse_max_vl(struct ubase_dev *udev) qos->ue_max_vl_id = ue_max_vl_id; - if (ubase_dev_urma_supported(udev)) + if (ubase_dev_urma_supported(udev) && !udev->use_fixed_rc_num) udma_caps->rc_max_cnt *= (ue_max_vl_id + 1); } @@ -966,6 +966,7 @@ static int ubase_ctrlq_query_sl(struct ubase_dev *udev) struct ubase_ctrlq_query_sl_resp resp = {0}; struct ubase_ctrlq_query_sl_req req = {0}; struct ubase_ctrlq_msg msg = {0}; + u16 rc_max_cnt; int ret; u8 i; @@ -986,6 +987,12 @@ static int ubase_ctrlq_query_sl(struct ubase_dev *udev) return ret; } + rc_max_cnt = le16_to_cpu(resp.rc_max_cnt); + if (rc_max_cnt != 0) { + udev->use_fixed_rc_num = true; + udev->caps.udma_caps.rc_max_cnt = rc_max_cnt; + } + unic_sl_bitmap = le16_to_cpu(resp.unic_sl_bitmap); udma_tp_sl_bitmap = le16_to_cpu(resp.udma_tp_sl_bitmap); udma_ctp_sl_bitmap = le16_to_cpu(resp.udma_ctp_sl_bitmap); -- Gitee From fe48921c10e2ecb67a88061b9b1f28b2750bc1be Mon Sep 17 00:00:00 2001 From: Fengyan Mu Date: Wed, 10 Dec 2025 10:01:36 +0800 Subject: [PATCH 11/12] net: unic: Restore tx and rx stats when setting coalesce parameters drivers inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID5SNV CVE: NA --------------------------------------------------------------- Restore tx and rx stats when setting coalesce parameters. The driver will try to destroy channels and rebuild them when received a set coalesc parameter command, if we don't restore driver tx&rx stats, stats information will be dropped in destroying channels. Fixes: e0ccc63cc72e ("net: unic: support querying and configuring coalesce parameters.") Signed-off-by: Fengyan Mu --- drivers/net/ub/unic/unic_ethtool.c | 62 +++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/net/ub/unic/unic_ethtool.c b/drivers/net/ub/unic/unic_ethtool.c index 886f6d691733..337d77b16ff4 100644 --- a/drivers/net/ub/unic/unic_ethtool.c +++ b/drivers/net/ub/unic/unic_ethtool.c @@ -426,6 +426,49 @@ unic_check_coalesce_para(struct net_device *netdev, return ret; } +static int unic_backup_stats(struct unic_dev *unic_dev, + struct unic_sq_stats **sq_stats, + struct unic_rq_stats **rq_stats) +{ + u32 i; + + *sq_stats = kcalloc(unic_dev->channels.num, sizeof(**sq_stats), + GFP_KERNEL); + if (ZERO_OR_NULL_PTR(*sq_stats)) + return -ENOMEM; + + *rq_stats = kcalloc(unic_dev->channels.num, sizeof(**rq_stats), + GFP_KERNEL); + if (ZERO_OR_NULL_PTR(*rq_stats)) { + if (unic_tx_changed(unic_dev)) + kfree(*sq_stats); + return -ENOMEM; + } + + for (i = 0; i < unic_dev->channels.num; i++) { + memcpy(sq_stats[i], &unic_dev->channels.c[i].sq->stats, + sizeof(struct unic_sq_stats)); + memcpy(rq_stats[i], &unic_dev->channels.c[i].rq->stats, + sizeof(struct unic_rq_stats)); + } + + return 0; +} + +static void unic_restore_stats(struct unic_dev *unic_dev, + struct unic_sq_stats *sq_stats, + struct unic_rq_stats *rq_stats) +{ + u32 i; + + for (i = 0; i < unic_dev->channels.num; i++) { + memcpy(&unic_dev->channels.c[i].rq->stats, &rq_stats[i], + sizeof(struct unic_rq_stats)); + memcpy(&unic_dev->channels.c[i].sq->stats, &sq_stats[i], + sizeof(struct unic_sq_stats)); + } +} + static int unic_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *cmd, struct kernel_ethtool_coalesce *kernel_coal, @@ -436,6 +479,8 @@ static int unic_set_coalesce(struct net_device *netdev, struct unic_coalesce *tx_coal = &unic_coal->tx_coal; struct unic_coalesce *rx_coal = &unic_coal->rx_coal; struct unic_coalesce old_tx_coal, old_rx_coal; + struct unic_sq_stats *sq_stats; + struct unic_rq_stats *rq_stats; int ret, ret1; if (netif_running(netdev)) { @@ -451,6 +496,13 @@ static int unic_set_coalesce(struct net_device *netdev, if (ret) return ret; + ret = unic_backup_stats(unic_dev, &sq_stats, &rq_stats); + if (ret) { + unic_err(unic_dev, "failed to backup txrx stats, ret = %d.\n", + ret); + return ret; + } + memcpy(&old_tx_coal, tx_coal, sizeof(struct unic_coalesce)); memcpy(&old_rx_coal, rx_coal, sizeof(struct unic_coalesce)); @@ -468,12 +520,20 @@ static int unic_set_coalesce(struct net_device *netdev, memcpy(tx_coal, &old_tx_coal, sizeof(struct unic_coalesce)); memcpy(rx_coal, &old_rx_coal, sizeof(struct unic_coalesce)); ret1 = unic_init_channels(unic_dev, unic_dev->channels.num); - if (ret1) + if (ret1) { unic_err(unic_dev, "failed to recover old channels, ret = %d.\n", ret1); + goto err_recover_channels; + } } + unic_restore_stats(unic_dev, sq_stats, rq_stats); + +err_recover_channels: + kfree(sq_stats); + kfree(rq_stats); + return ret; } -- Gitee From 81d95911c812a24d4daa342a11f077b9316eba89 Mon Sep 17 00:00:00 2001 From: Fengyan Mu Date: Wed, 10 Dec 2025 17:18:46 +0800 Subject: [PATCH 12/12] net: unic: Fixed the call trace issue triggered internally by the completion event interrupt drivers inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID7LHB CVE: NA ----------------------------------------------------------------- Solve the problem that in the scenario of modifying queue parameters at the same time during multi-network port MUE streaming, the unic completion event is interrupted when queue resources such as channel are destroyed. In the acquisition of queue resources such as rq sq, call trace hangs in this scenario. This submission fixes this problem by adding channel_invalid setting. Fixes: d8164d3745d4 ("net: unic: add io basic Rx/Tx functionality for unic") Signed-off-by: Yaoyao Tu Signed-off-by: Fengyan Mu --- drivers/net/ub/unic/unic_channel.c | 3 +++ drivers/net/ub/unic/unic_dev.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/net/ub/unic/unic_channel.c b/drivers/net/ub/unic/unic_channel.c index eb2d838035c7..66f70eebcfb9 100644 --- a/drivers/net/ub/unic/unic_channel.c +++ b/drivers/net/ub/unic/unic_channel.c @@ -235,11 +235,14 @@ static int unic_modify_channels(struct unic_dev *unic_dev, int ret; mutex_lock(&channels->mutex); + set_bit(UNIC_STATE_CHANNEL_INVALID, &unic_dev->state); unic_uninit_changed_channels(unic_dev); unic_dev_change_channels_param(unic_dev, new_param); ret = unic_init_changed_channels(unic_dev); + if (!ret) + clear_bit(UNIC_STATE_CHANNEL_INVALID, &unic_dev->state); mutex_unlock(&channels->mutex); return ret; diff --git a/drivers/net/ub/unic/unic_dev.c b/drivers/net/ub/unic/unic_dev.c index 24dd70339957..f99e0bef5642 100644 --- a/drivers/net/ub/unic/unic_dev.c +++ b/drivers/net/ub/unic/unic_dev.c @@ -996,6 +996,8 @@ int unic_change_rss_size(struct unic_dev *unic_dev, u32 new_rss_size, int ret; mutex_lock(&channels->mutex); + + set_bit(UNIC_STATE_CHANNEL_INVALID, &unic_dev->state); __unic_uninit_channels(unic_dev); channels->rss_size = new_rss_size; @@ -1007,6 +1009,8 @@ int unic_change_rss_size(struct unic_dev *unic_dev, u32 new_rss_size, if (ret) dev_err(unic_dev->comdev.adev->dev.parent, "failed to change rss_size, ret = %d.\n", ret); + else + clear_bit(UNIC_STATE_CHANNEL_INVALID, &unic_dev->state); mutex_unlock(&channels->mutex); -- Gitee