diff --git a/drivers/ub/hw/hns3/hns3_udma_dca.h b/drivers/ub/hw/hns3/hns3_udma_dca.h index d2c4c69a5c52d9f0c6073f34bccd63b00005e65d..573249bf2bdaea58ddc1ad57824a57f09b53eea9 100644 --- a/drivers/ub/hw/hns3/hns3_udma_dca.h +++ b/drivers/ub/hw/hns3/hns3_udma_dca.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Huawei UDMA Linux driver +/* Huawei HNS3_UDMA Linux driver * Copyright (c) 2023-2023 Hisilicon Limited. * * This program is free software; you can redistribute it and/or modify it diff --git a/drivers/ub/hw/hns3/hns3_udma_debugfs.c b/drivers/ub/hw/hns3/hns3_udma_debugfs.c index cf5c2d7413e1fa9e46966e13f84efce6e33f9f8a..58248f4ecdd62c14a41a89f3ceecf9e5aff7b936 100644 --- a/drivers/ub/hw/hns3/hns3_udma_debugfs.c +++ b/drivers/ub/hw/hns3/hns3_udma_debugfs.c @@ -389,9 +389,11 @@ void hns3_udma_unregister_debugfs(struct hns3_udma_dev *udma_dev) } /* debugfs for hns3_udma module */ -void hns3_udma_init_debugfs(void) +struct dentry *hns3_udma_init_debugfs(void) { hns3_udma_dbgfs_root = debugfs_create_dir("hns3_udma", NULL); + + return hns3_udma_dbgfs_root; } void hns3_udma_cleanup_debugfs(void) diff --git a/drivers/ub/hw/hns3/hns3_udma_debugfs.h b/drivers/ub/hw/hns3/hns3_udma_debugfs.h index c82eba97641bc5bdc94489999af6bbca5a42fb66..d1675b4aafd1f8f4fb58b03248d99895c72b2045 100644 --- a/drivers/ub/hw/hns3/hns3_udma_debugfs.h +++ b/drivers/ub/hw/hns3/hns3_udma_debugfs.h @@ -80,7 +80,7 @@ struct dca_qp_stats { uint32_t sge_size; }; -void hns3_udma_init_debugfs(void); +struct dentry *hns3_udma_init_debugfs(void); void hns3_udma_cleanup_debugfs(void); void hns3_udma_register_debugfs(struct hns3_udma_dev *udma_dev); void hns3_udma_unregister_debugfs(struct hns3_udma_dev *udma_dev); diff --git a/drivers/ub/hw/hns3/hns3_udma_device.h b/drivers/ub/hw/hns3/hns3_udma_device.h index 2aef7e74f7a08c7115fe08ebf3d2a2155f5845a4..8ec50924190e72c9bc20fd8debf3d872cbbd7276 100644 --- a/drivers/ub/hw/hns3/hns3_udma_device.h +++ b/drivers/ub/hw/hns3/hns3_udma_device.h @@ -252,8 +252,6 @@ struct hns3_udma_caps { uint32_t reserved_lkey; int mtpt_entry_sz; int qpc_sz; - int irrl_entry_sz; - int trrl_entry_sz; int cqc_entry_sz; int scc_ctx_sz; int qpc_timer_entry_sz; diff --git a/drivers/ub/hw/hns3/hns3_udma_dfx.c b/drivers/ub/hw/hns3/hns3_udma_dfx.c index e5ffa274296556bff8bf5b0a942f2a2c4a5695f9..d0caed65921ad1dddf7955820939885839aba305 100644 --- a/drivers/ub/hw/hns3/hns3_udma_dfx.c +++ b/drivers/ub/hw/hns3/hns3_udma_dfx.c @@ -1187,7 +1187,7 @@ static void hns3_udma_dfx_list_free(int num) DFX_LIST_FREE(jfc); } -static int hns3_udma_dfx_add_hns3_udma_device(struct hns3_udma_dev *udma_dev) +static int hns3_udma_dfx_add_device(struct hns3_udma_dev *udma_dev) { int ret; int i; @@ -1308,7 +1308,7 @@ int hns3_udma_dfx_init(struct hns3_udma_dev *udma_dev) dev_info(drv_device, "hns3_udma dfx create chr device success.\n"); } - ret = hns3_udma_dfx_add_hns3_udma_device(udma_dev); + ret = hns3_udma_dfx_add_device(udma_dev); if (ret) { dev_err(drv_device, "hns3_udma dfx add hns3_udma device failed.\n"); goto add_device_failed; @@ -1325,7 +1325,7 @@ int hns3_udma_dfx_init(struct hns3_udma_dev *udma_dev) return ret; } -static void hns3_udma_dfx_remove_hns3_udma_device(struct hns3_udma_dev *udma_dev) +static void hns3_udma_dfx_remove_device(struct hns3_udma_dev *udma_dev) { int i; @@ -1355,7 +1355,7 @@ void hns3_udma_dfx_uninit(struct hns3_udma_dev *udma_dev) return; } - hns3_udma_dfx_remove_hns3_udma_device(udma_dev); + hns3_udma_dfx_remove_device(udma_dev); if (!hns3_udma_dev_count) { dev_info(drv_device, "hns3_udma dfx remove chr device.\n"); hns3_udma_dfx_chrdev_destroy(); diff --git a/drivers/ub/hw/hns3/hns3_udma_hem.h b/drivers/ub/hw/hns3/hns3_udma_hem.h index d5eab53ff84bff4fb2772ef2ab2147d5cbe37efd..e9331ef753e1571b7041dbafcaf486b7ac4feba1 100644 --- a/drivers/ub/hw/hns3/hns3_udma_hem.h +++ b/drivers/ub/hw/hns3/hns3_udma_hem.h @@ -51,8 +51,6 @@ enum { HEM_TYPE_CQE, HEM_TYPE_SRQWQE, HEM_TYPE_INDEX, - HEM_TYPE_IRRL, - HEM_TYPE_TRRL, }; #define HNS3_UDMA_HEM_CHUNK_LEN \ diff --git a/drivers/ub/hw/hns3/hns3_udma_hw.c b/drivers/ub/hw/hns3/hns3_udma_hw.c index 1d8e4e96e6ae3aeb65d446daea10910dac6cf49d..670761d75b5f8a5bcad91292eb5130b51b8279c2 100644 --- a/drivers/ub/hw/hns3/hns3_udma_hw.c +++ b/drivers/ub/hw/hns3/hns3_udma_hw.c @@ -243,8 +243,6 @@ static void set_dev_cap_by_resp_ab(struct hns3_udma_caps *caps, caps->cqe_sz = resp_a->cqe_sz; caps->mtpt_entry_sz = resp_b->mtpt_entry_sz; - caps->irrl_entry_sz = resp_b->irrl_entry_sz; - caps->trrl_entry_sz = resp_b->trrl_entry_sz; caps->cqc_entry_sz = resp_b->cqc_entry_sz; caps->srqc_entry_sz = resp_b->srqc_entry_sz; caps->idx_entry_sz = resp_b->idx_entry_sz; @@ -2038,7 +2036,7 @@ static void hns3_udma_link_status_change(struct hnae3_handle *handle, bool linku dev = handle->priv; if (IS_ERR_OR_NULL(dev)) { - pr_err("[hns3-hns3_udma:link_status_change]: Invalid dev!\n"); + pr_err("[hns3-udma:link_status_change]: Invalid dev!\n"); return; } @@ -2083,7 +2081,9 @@ static struct hnae3_client hns3_udma_client = { static int __init hns3_udma_init(void) { - hns3_udma_init_debugfs(); + if (IS_ERR_OR_NULL(hns3_udma_init_debugfs())) + pr_err("[hns3-udma:hns3_udma_init]:fail to create debugfs!\n"); + return hnae3_register_client(&hns3_udma_client); } diff --git a/drivers/ub/hw/hns3/hns3_udma_jfr.c b/drivers/ub/hw/hns3/hns3_udma_jfr.c index 084680774ddc299101eb3f7c96c518fb01bbd3fe..1a617091e4693f02b0f3d5476d1d0ec56cbdbc93 100644 --- a/drivers/ub/hw/hns3/hns3_udma_jfr.c +++ b/drivers/ub/hw/hns3/hns3_udma_jfr.c @@ -589,6 +589,7 @@ static int alloc_jfr_um_qp(struct hns3_udma_dev *dev, struct hns3_udma_jfr *jfr) qp->qp_attr.jfr = jfr; qp->qp_attr.eid_index = to_hns3_udma_ucontext(jfr->ubcore_jfr.uctx)->eid_index; + qp->qp_attr.uctx = jfr->ubcore_jfr.uctx; udata.uctx = NULL; ret = hns3_udma_create_qp_common(dev, qp, &udata); if (ret) { diff --git a/drivers/ub/hw/hns3/hns3_udma_jfs.c b/drivers/ub/hw/hns3/hns3_udma_jfs.c index b891642364021a7aba3eca6afd962887fc0e60fe..1a5d6a72875867a9483e783b171f3da85822222e 100644 --- a/drivers/ub/hw/hns3/hns3_udma_jfs.c +++ b/drivers/ub/hw/hns3/hns3_udma_jfs.c @@ -123,19 +123,14 @@ static int create_jfs_um_qp(struct hns3_udma_dev *dev, struct hns3_udma_jfs *jfs return ret; } -static int destroy_jfs_qp(struct hns3_udma_dev *dev, struct hns3_udma_jfs *jfs) +static inline void destroy_jfs_qp(struct hns3_udma_dev *dev, struct hns3_udma_jfs *jfs) { - int ret = 0; - - ret = hns3_udma_modify_jfs_um_qp(dev, jfs, QPS_RESET); - if (ret) + if (hns3_udma_modify_jfs_um_qp(dev, jfs, QPS_RESET)) dev_err(dev->dev, "failed to modify qp(0x%llx) to RESET for um jfs.\n", jfs->um_qp.qpn); hns3_udma_destroy_qp_common(dev, &jfs->um_qp, NULL); - - return ret; } static int alloc_jfs_buf(struct hns3_udma_dev *udma_dev, struct hns3_udma_jfs *jfs, diff --git a/drivers/ub/hw/hns3/hns3_udma_main.c b/drivers/ub/hw/hns3/hns3_udma_main.c index e49e711c8ded525fe19c7724b4308e0418188d4e..1c215799881ef62be38d75d3e9d8a2ca6dd9a424 100644 --- a/drivers/ub/hw/hns3/hns3_udma_main.c +++ b/drivers/ub/hw/hns3/hns3_udma_main.c @@ -422,6 +422,7 @@ static int hns3_udma_query_device_attr(struct ubcore_device *dev, attr->tp_maintainer = true; attr->dev_cap.max_tp_in_tpg = HNS3_UDMA_MAX_TP_IN_TPG; attr->fe_idx = udma_dev->func_id; + attr->pattern = UBCORE_PATTERN_1; for (i = 0; i < udma_dev->caps.num_ports; i++) { net_dev = udma_dev->uboe.netdevs[i]; @@ -854,36 +855,12 @@ int hns3_udma_init_common_hem(struct hns3_udma_dev *udma_dev) } dev_info(dev, "init QPC hem table success.\n"); - ret = hns3_udma_init_hem_table(udma_dev, &udma_dev->qp_table.irrl_table, - HEM_TYPE_IRRL, udma_dev->caps.irrl_entry_sz * - udma_dev->caps.max_qp_init_rdma, - udma_dev->caps.num_qps); - if (ret) { - dev_err(dev, "Failed to init irrl_table memory.\n"); - goto err_unmap_qp; - } - dev_info(dev, "init IRRL hem table success.\n"); - - if (udma_dev->caps.trrl_entry_sz) { - ret = hns3_udma_init_hem_table(udma_dev, - &udma_dev->qp_table.trrl_table, - HEM_TYPE_TRRL, - udma_dev->caps.trrl_entry_sz * - udma_dev->caps.max_qp_dest_rdma, - udma_dev->caps.num_qps); - if (ret) { - dev_err(dev, "Failed to init trrl_table memory.\n"); - goto err_unmap_irrl; - } - dev_info(dev, "init TRRL hem table success.\n"); - } - ret = hns3_udma_init_hem_table(udma_dev, &udma_dev->jfc_table.table, HEM_TYPE_CQC, udma_dev->caps.cqc_entry_sz, udma_dev->caps.num_cqs); if (ret) { dev_err(dev, "Failed to init CQ context memory.\n"); - goto err_unmap_trrl; + goto err_unmap_qp; } dev_info(dev, "init CQC hem table success.\n"); @@ -934,12 +911,6 @@ int hns3_udma_init_common_hem(struct hns3_udma_dev *udma_dev) hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->jfr_table.table); err_unmap_cq: hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->jfc_table.table); -err_unmap_trrl: - if (udma_dev->caps.trrl_entry_sz) - hns3_udma_cleanup_hem_table(udma_dev, - &udma_dev->qp_table.trrl_table); -err_unmap_irrl: - hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->qp_table.irrl_table); err_unmap_qp: hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->qp_table.qp_table); err_unmap_dmpt: @@ -1000,11 +971,7 @@ void hns3_udma_cleanup_common_hem(struct hns3_udma_dev *udma_dev) if (udma_dev->caps.flags & HNS3_UDMA_CAP_FLAG_SRQ) hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->jfr_table.table); hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->jfc_table.table); - if (udma_dev->caps.trrl_entry_sz) - hns3_udma_cleanup_hem_table(udma_dev, - &udma_dev->qp_table.trrl_table); - hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->qp_table.irrl_table); hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->qp_table.qp_table); hns3_udma_cleanup_hem_table(udma_dev, &udma_dev->seg_table.table); } diff --git a/drivers/ub/hw/hns3/hns3_udma_qp.c b/drivers/ub/hw/hns3/hns3_udma_qp.c index 9b8131a8d59760bdcd6b18fc5c7d4c24fc616fa5..638cae474820d0e5e7844b93ab34a9e468cb2a7e 100644 --- a/drivers/ub/hw/hns3/hns3_udma_qp.c +++ b/drivers/ub/hw/hns3/hns3_udma_qp.c @@ -1530,7 +1530,7 @@ static int set_wqe_buf_attr(struct hns3_udma_dev *udma_dev, struct hns3_udma_qp return -EINVAL; buf_attr->region_count = idx; - buf_attr->page_shift = PAGE_SHIFT; + buf_attr->page_shift = dca_en ? HNS3_UDMA_HW_PAGE_SHIFT : PAGE_SHIFT; buf_attr->mtt_only = dca_en; return 0; @@ -1665,30 +1665,13 @@ static int alloc_qpc(struct hns3_udma_dev *udma_dev, struct hns3_udma_qp *qp) goto err_out; } - /* Alloc memory for IRRL */ - ret = hns3_udma_table_get(udma_dev, &qp_table->irrl_table, qp->qpn); - if (ret) { - dev_err(dev, "Failed to get IRRL table\n"); - goto err_put_qp; - } - - if (udma_dev->caps.trrl_entry_sz) { - /* Alloc memory for TRRL */ - ret = hns3_udma_table_get(udma_dev, &qp_table->trrl_table, - qp->qpn); - if (ret) { - dev_err(dev, "Failed to get TRRL table\n"); - goto err_put_irrl; - } - } - if (udma_dev->caps.flags & HNS3_UDMA_CAP_FLAG_QP_FLOW_CTRL) { /* Alloc memory for SCC CTX */ ret = hns3_udma_table_get(udma_dev, &qp_table->sccc_table, qp->qpn); if (ret) { dev_err(dev, "Failed to get SCC CTX table\n"); - goto err_put_trrl; + goto err_put_qp; } } @@ -1701,11 +1684,6 @@ static int alloc_qpc(struct hns3_udma_dev *udma_dev, struct hns3_udma_qp *qp) return 0; -err_put_trrl: - if (udma_dev->caps.trrl_entry_sz) - hns3_udma_table_put(udma_dev, &qp_table->trrl_table, qp->qpn); -err_put_irrl: - hns3_udma_table_put(udma_dev, &qp_table->irrl_table, qp->qpn); err_put_qp: hns3_udma_table_put(udma_dev, &qp_table->qp_table, qp->qpn); err_out: @@ -1745,15 +1723,8 @@ static void hns3_udma_qp_remove(struct hns3_udma_dev *udma_dev, struct hns3_udma static void free_qpc(struct hns3_udma_dev *udma_dev, struct hns3_udma_qp *qp) { - struct hns3_udma_qp_table *qp_table = &udma_dev->qp_table; - if (udma_dev->caps.reorder_cq_buffer_en) hns3_udma_free_reorder_cq_buf(udma_dev, &qp->qp_attr); - - if (udma_dev->caps.trrl_entry_sz) - hns3_udma_table_put(udma_dev, &qp_table->trrl_table, qp->qpn); - - hns3_udma_table_put(udma_dev, &qp_table->irrl_table, qp->qpn); } static void free_qp_db(struct hns3_udma_dev *udma_dev, struct hns3_udma_qp *qp) diff --git a/drivers/ub/hw/hns3/hns3_udma_sw_res.h b/drivers/ub/hw/hns3/hns3_udma_sw_res.h index 658f5084255777496f6f914435f748e0e53865f8..041392898ea882d173b51d2d60c12c8a947965dd 100644 --- a/drivers/ub/hw/hns3/hns3_udma_sw_res.h +++ b/drivers/ub/hw/hns3/hns3_udma_sw_res.h @@ -133,14 +133,14 @@ struct hns3_udma_uar { struct hns3_udma_ida { struct ida ida; - uint32_t min; /* Lowest ID to allocate. */ + uint32_t min; /* Lowest ID to allocate. */ uint32_t max; /* Highest ID to allocate. */ }; struct hns3_udma_bank { struct ida ida; uint32_t inuse; /* Number of IDs allocated */ - uint32_t min; /* Lowest ID to allocate. */ + uint32_t min; /* Lowest ID to allocate. */ uint32_t max; /* Highest ID to allocate. */ uint32_t next; /* Next ID to allocate. */ }; @@ -390,8 +390,6 @@ struct hns3_udma_eq { struct hns3_udma_qp_table { struct xarray xa; struct hns3_udma_hem_table qp_table; - struct hns3_udma_hem_table irrl_table; - struct hns3_udma_hem_table trrl_table; struct hns3_udma_hem_table sccc_table; struct hns3_udma_bank bank[HNS3_UDMA_QP_BANK_NUM]; struct mutex bank_mutex; diff --git a/drivers/ub/hw/hns3/hns3_udma_tp.c b/drivers/ub/hw/hns3/hns3_udma_tp.c index 2de1b3771711b8072af76c8193f98415f0848733..6220e32526fe76167b7aa95759b75999e501e090 100644 --- a/drivers/ub/hw/hns3/hns3_udma_tp.c +++ b/drivers/ub/hw/hns3/hns3_udma_tp.c @@ -552,6 +552,12 @@ int hns3_udma_modify_user_tp(struct ubcore_device *dev, uint32_t tpn, unsigned long flags; int ret; + if (attr->state != UBCORE_TP_STATE_RTS) { + dev_err(&dev->dev, "Invalid TP STATE %d, only supports TP STATE RTS.\n", + attr->state); + return -EINVAL; + } + xa_lock_irqsave(&udma_dev->qp_table.xa, flags); qp = (struct hns3_udma_qp *)xa_load(&udma_dev->qp_table.xa, tpn); if (qp)