irdma_utils.c (01fbb86991d524288a785b544c29d9c5ea1b61fb) | irdma_utils.c (5b5f7d0e77a9eee73eb5d596f43aef4e1a3674d8) |
---|---|
1/*- 2 * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 3 * 4 * Copyright (c) 2015 - 2023 Intel Corporation 5 * 6 * This software is available to you under a choice of one of two 7 * licenses. You may choose to be licensed under the terms of the GNU 8 * General Public License (GPL) Version 2, available from the file --- 150 unchanged lines hidden (view full) --- 159 "iWARP error: Received a terminate message"}, 160 {IRDMA_AE_LLP_TOO_MANY_RETRIES, "Connection error: The max number of retries has been reached"}, 161 {IRDMA_AE_LLP_TOO_MANY_KEEPALIVE_RETRIES, 162 "Connection error: The max number of keepalive retries has been reached"}, 163 {IRDMA_AE_LLP_DOUBT_REACHABILITY, 164 "Connection error: Doubt reachability (usually occurs after the max number of retries has been reached)"}, 165 {IRDMA_AE_LLP_CONNECTION_ESTABLISHED, 166 "iWARP event: Connection established"}, | 1/*- 2 * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 3 * 4 * Copyright (c) 2015 - 2023 Intel Corporation 5 * 6 * This software is available to you under a choice of one of two 7 * licenses. You may choose to be licensed under the terms of the GNU 8 * General Public License (GPL) Version 2, available from the file --- 150 unchanged lines hidden (view full) --- 159 "iWARP error: Received a terminate message"}, 160 {IRDMA_AE_LLP_TOO_MANY_RETRIES, "Connection error: The max number of retries has been reached"}, 161 {IRDMA_AE_LLP_TOO_MANY_KEEPALIVE_RETRIES, 162 "Connection error: The max number of keepalive retries has been reached"}, 163 {IRDMA_AE_LLP_DOUBT_REACHABILITY, 164 "Connection error: Doubt reachability (usually occurs after the max number of retries has been reached)"}, 165 {IRDMA_AE_LLP_CONNECTION_ESTABLISHED, 166 "iWARP event: Connection established"}, |
167 {IRDMA_AE_LLP_TOO_MANY_RNRS, "RoCEv2: Too many RNR NACKs"}, |
|
167 {IRDMA_AE_RESOURCE_EXHAUSTION, 168 "QP error: Resource exhaustion"}, 169 {IRDMA_AE_RESET_SENT, 170 "Reset sent (as requested via Modify QP)"}, 171 {IRDMA_AE_TERMINATE_SENT, 172 "Terminate sent (as requested via Modify QP)"}, 173 {IRDMA_AE_RESET_NOT_SENT, 174 "Reset not sent (but requested via Modify QP)"}, --- 257 unchanged lines hidden (view full) --- 432 * irdma_free_pending_cqp_request -free pending cqp request objs 433 * @cqp: cqp ptr 434 * @cqp_request: to be put back in cqp list 435 */ 436static void 437irdma_free_pending_cqp_request(struct irdma_cqp *cqp, 438 struct irdma_cqp_request *cqp_request) 439{ | 168 {IRDMA_AE_RESOURCE_EXHAUSTION, 169 "QP error: Resource exhaustion"}, 170 {IRDMA_AE_RESET_SENT, 171 "Reset sent (as requested via Modify QP)"}, 172 {IRDMA_AE_TERMINATE_SENT, 173 "Terminate sent (as requested via Modify QP)"}, 174 {IRDMA_AE_RESET_NOT_SENT, 175 "Reset not sent (but requested via Modify QP)"}, --- 257 unchanged lines hidden (view full) --- 433 * irdma_free_pending_cqp_request -free pending cqp request objs 434 * @cqp: cqp ptr 435 * @cqp_request: to be put back in cqp list 436 */ 437static void 438irdma_free_pending_cqp_request(struct irdma_cqp *cqp, 439 struct irdma_cqp_request *cqp_request) 440{ |
440 if (cqp_request->waiting) { 441 cqp_request->compl_info.error = true; 442 WRITE_ONCE(cqp_request->request_done, true); | 441 cqp_request->compl_info.error = true; 442 WRITE_ONCE(cqp_request->request_done, true); 443 444 if (cqp_request->waiting) |
443 wake_up(&cqp_request->waitq); | 445 wake_up(&cqp_request->waitq); |
444 } | |
445 wait_event_timeout(cqp->remove_wq, 446 atomic_read(&cqp_request->refcnt) == 1, 1000); 447 irdma_put_cqp_request(cqp, cqp_request); 448} 449 450/** 451 * irdma_cleanup_pending_cqp_op - clean-up cqp with no 452 * completions --- 100 unchanged lines hidden (view full) --- 553 [IRDMA_OP_MW_ALLOC] = "Allocate Memory Window Cmd", 554 [IRDMA_OP_QP_FLUSH_WQES] = "Flush QP Cmd", 555 [IRDMA_OP_ADD_ARP_CACHE_ENTRY] = "Add ARP Cache Cmd", 556 [IRDMA_OP_MANAGE_PUSH_PAGE] = "Manage Push Page Cmd", 557 [IRDMA_OP_UPDATE_PE_SDS] = "Update PE SDs Cmd", 558 [IRDMA_OP_MANAGE_HMC_PM_FUNC_TABLE] = "Manage HMC PM Function Table Cmd", 559 [IRDMA_OP_SUSPEND] = "Suspend QP Cmd", 560 [IRDMA_OP_RESUME] = "Resume QP Cmd", | 446 wait_event_timeout(cqp->remove_wq, 447 atomic_read(&cqp_request->refcnt) == 1, 1000); 448 irdma_put_cqp_request(cqp, cqp_request); 449} 450 451/** 452 * irdma_cleanup_pending_cqp_op - clean-up cqp with no 453 * completions --- 100 unchanged lines hidden (view full) --- 554 [IRDMA_OP_MW_ALLOC] = "Allocate Memory Window Cmd", 555 [IRDMA_OP_QP_FLUSH_WQES] = "Flush QP Cmd", 556 [IRDMA_OP_ADD_ARP_CACHE_ENTRY] = "Add ARP Cache Cmd", 557 [IRDMA_OP_MANAGE_PUSH_PAGE] = "Manage Push Page Cmd", 558 [IRDMA_OP_UPDATE_PE_SDS] = "Update PE SDs Cmd", 559 [IRDMA_OP_MANAGE_HMC_PM_FUNC_TABLE] = "Manage HMC PM Function Table Cmd", 560 [IRDMA_OP_SUSPEND] = "Suspend QP Cmd", 561 [IRDMA_OP_RESUME] = "Resume QP Cmd", |
561 [IRDMA_OP_MANAGE_VCHNL_REQ_PBLE_BP] = 562 "Manage Virtual Channel Requester Function PBLE Backing Pages Cmd", | |
563 [IRDMA_OP_QUERY_FPM_VAL] = "Query FPM Values Cmd", 564 [IRDMA_OP_COMMIT_FPM_VAL] = "Commit FPM Values Cmd", 565 [IRDMA_OP_AH_CREATE] = "Create Address Handle Cmd", 566 [IRDMA_OP_AH_MODIFY] = "Modify Address Handle Cmd", 567 [IRDMA_OP_AH_DESTROY] = "Destroy Address Handle Cmd", 568 [IRDMA_OP_MC_CREATE] = "Create Multicast Group Cmd", 569 [IRDMA_OP_MC_DESTROY] = "Destroy Multicast Group Cmd", 570 [IRDMA_OP_MC_MODIFY] = "Modify Multicast Group Cmd", --- 15 unchanged lines hidden (view full) --- 586}; 587 588static const struct irdma_cqp_err_info irdma_noncrit_err_list[] = { 589 {0xffff, 0x8002, "Invalid State"}, 590 {0xffff, 0x8006, "Flush No Wqe Pending"}, 591 {0xffff, 0x8007, "Modify QP Bad Close"}, 592 {0xffff, 0x8009, "LLP Closed"}, 593 {0xffff, 0x800a, "Reset Not Sent"}, | 562 [IRDMA_OP_QUERY_FPM_VAL] = "Query FPM Values Cmd", 563 [IRDMA_OP_COMMIT_FPM_VAL] = "Commit FPM Values Cmd", 564 [IRDMA_OP_AH_CREATE] = "Create Address Handle Cmd", 565 [IRDMA_OP_AH_MODIFY] = "Modify Address Handle Cmd", 566 [IRDMA_OP_AH_DESTROY] = "Destroy Address Handle Cmd", 567 [IRDMA_OP_MC_CREATE] = "Create Multicast Group Cmd", 568 [IRDMA_OP_MC_DESTROY] = "Destroy Multicast Group Cmd", 569 [IRDMA_OP_MC_MODIFY] = "Modify Multicast Group Cmd", --- 15 unchanged lines hidden (view full) --- 585}; 586 587static const struct irdma_cqp_err_info irdma_noncrit_err_list[] = { 588 {0xffff, 0x8002, "Invalid State"}, 589 {0xffff, 0x8006, "Flush No Wqe Pending"}, 590 {0xffff, 0x8007, "Modify QP Bad Close"}, 591 {0xffff, 0x8009, "LLP Closed"}, 592 {0xffff, 0x800a, "Reset Not Sent"}, |
594 {0xffff, 0x200, "Failover Pending"} | 593 {0xffff, 0x0200, "Failover Pending"}, |
595}; 596 597/** 598 * irdma_cqp_crit_err - check if CQP error is critical 599 * @dev: pointer to dev structure 600 * @cqp_cmd: code for last CQP operation 601 * @maj_err_code: major error code 602 * @min_err_code: minot error code --- 447 unchanged lines hidden (view full) --- 1050 irdma_put_cqp_request(iwcqp, cqp_request); 1051 1052 return status; 1053} 1054 1055/** 1056 * irdma_dealloc_push_page - free a push page for qp 1057 * @rf: RDMA PCI function | 594}; 595 596/** 597 * irdma_cqp_crit_err - check if CQP error is critical 598 * @dev: pointer to dev structure 599 * @cqp_cmd: code for last CQP operation 600 * @maj_err_code: major error code 601 * @min_err_code: minot error code --- 447 unchanged lines hidden (view full) --- 1049 irdma_put_cqp_request(iwcqp, cqp_request); 1050 1051 return status; 1052} 1053 1054/** 1055 * irdma_dealloc_push_page - free a push page for qp 1056 * @rf: RDMA PCI function |
1058 * @qp: hardware control qp | 1057 * @iwqp: QP pointer |
1059 */ 1060void 1061irdma_dealloc_push_page(struct irdma_pci_f *rf, | 1058 */ 1059void 1060irdma_dealloc_push_page(struct irdma_pci_f *rf, |
1062 struct irdma_sc_qp *qp) | 1061 struct irdma_qp *iwqp) |
1063{ 1064 struct irdma_cqp_request *cqp_request; 1065 struct cqp_cmds_info *cqp_info; 1066 int status; | 1062{ 1063 struct irdma_cqp_request *cqp_request; 1064 struct cqp_cmds_info *cqp_info; 1065 int status; |
1066 struct irdma_sc_qp *qp = &iwqp->sc_qp; |
|
1067 1068 if (qp->push_idx == IRDMA_INVALID_PUSH_PAGE_INDEX) 1069 return; 1070 1071 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, false); 1072 if (!cqp_request) 1073 return; 1074 --- 485 unchanged lines hidden (view full) --- 1560irdma_hw_stats_stop_timer(struct irdma_sc_vsi *vsi) 1561{ 1562 struct irdma_vsi_pestat *devstat = vsi->pestat; 1563 1564 del_timer_sync(&devstat->stats_timer); 1565} 1566 1567/** | 1067 1068 if (qp->push_idx == IRDMA_INVALID_PUSH_PAGE_INDEX) 1069 return; 1070 1071 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, false); 1072 if (!cqp_request) 1073 return; 1074 --- 485 unchanged lines hidden (view full) --- 1560irdma_hw_stats_stop_timer(struct irdma_sc_vsi *vsi) 1561{ 1562 struct irdma_vsi_pestat *devstat = vsi->pestat; 1563 1564 del_timer_sync(&devstat->stats_timer); 1565} 1566 1567/** |
1568 * irdma_process_stats - Checking for wrap and update stats 1569 * @pestat: stats structure pointer 1570 */ 1571static inline void 1572irdma_process_stats(struct irdma_vsi_pestat *pestat) 1573{ 1574 sc_vsi_update_stats(pestat->vsi); 1575} 1576 1577/** | |
1578 * irdma_process_cqp_stats - Checking for wrap and update stats 1579 * @cqp_request: cqp_request structure pointer 1580 */ 1581static void 1582irdma_process_cqp_stats(struct irdma_cqp_request *cqp_request) 1583{ 1584 struct irdma_vsi_pestat *pestat = cqp_request->param; 1585 | 1568 * irdma_process_cqp_stats - Checking for wrap and update stats 1569 * @cqp_request: cqp_request structure pointer 1570 */ 1571static void 1572irdma_process_cqp_stats(struct irdma_cqp_request *cqp_request) 1573{ 1574 struct irdma_vsi_pestat *pestat = cqp_request->param; 1575 |
1586 irdma_process_stats(pestat); | 1576 sc_vsi_update_stats(pestat->vsi); |
1587} 1588 1589/** 1590 * irdma_cqp_gather_stats_cmd - Gather stats 1591 * @dev: pointer to device structure 1592 * @pestat: pointer to stats info 1593 * @wait: flag to wait or not wait for stats 1594 */ --- 19 unchanged lines hidden (view full) --- 1614 cqp_info->in.u.stats_gather.info = pestat->gather_info; 1615 cqp_info->in.u.stats_gather.scratch = (uintptr_t)cqp_request; 1616 cqp_info->in.u.stats_gather.cqp = &rf->cqp.sc_cqp; 1617 cqp_request->param = pestat; 1618 if (!wait) 1619 cqp_request->callback_fcn = irdma_process_cqp_stats; 1620 status = irdma_handle_cqp_op(rf, cqp_request); 1621 if (wait) | 1577} 1578 1579/** 1580 * irdma_cqp_gather_stats_cmd - Gather stats 1581 * @dev: pointer to device structure 1582 * @pestat: pointer to stats info 1583 * @wait: flag to wait or not wait for stats 1584 */ --- 19 unchanged lines hidden (view full) --- 1604 cqp_info->in.u.stats_gather.info = pestat->gather_info; 1605 cqp_info->in.u.stats_gather.scratch = (uintptr_t)cqp_request; 1606 cqp_info->in.u.stats_gather.cqp = &rf->cqp.sc_cqp; 1607 cqp_request->param = pestat; 1608 if (!wait) 1609 cqp_request->callback_fcn = irdma_process_cqp_stats; 1610 status = irdma_handle_cqp_op(rf, cqp_request); 1611 if (wait) |
1622 irdma_process_stats(pestat); | 1612 sc_vsi_update_stats(pestat->vsi); |
1623 irdma_put_cqp_request(&rf->cqp, cqp_request); 1624 1625 return status; 1626} 1627 1628/** 1629 * irdma_cqp_stats_inst_cmd - Allocate/free stats instance 1630 * @vsi: pointer to vsi structure --- 178 unchanged lines hidden (view full) --- 1809 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); 1810 if (!cqp_request) 1811 return -ENOMEM; 1812 1813 cqp_info = &cqp_request->info; 1814 cqp_info->cqp_cmd = cmd; 1815 cqp_info->post_sq = 1; 1816 if (cmd == IRDMA_OP_AH_CREATE) { | 1613 irdma_put_cqp_request(&rf->cqp, cqp_request); 1614 1615 return status; 1616} 1617 1618/** 1619 * irdma_cqp_stats_inst_cmd - Allocate/free stats instance 1620 * @vsi: pointer to vsi structure --- 178 unchanged lines hidden (view full) --- 1799 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); 1800 if (!cqp_request) 1801 return -ENOMEM; 1802 1803 cqp_info = &cqp_request->info; 1804 cqp_info->cqp_cmd = cmd; 1805 cqp_info->post_sq = 1; 1806 if (cmd == IRDMA_OP_AH_CREATE) { |
1807 if (!wait) 1808 irdma_get_cqp_request(cqp_request); 1809 sc_ah->ah_info.cqp_request = cqp_request; 1810 |
|
1817 cqp_info->in.u.ah_create.info = sc_ah->ah_info; 1818 cqp_info->in.u.ah_create.scratch = (uintptr_t)cqp_request; 1819 cqp_info->in.u.ah_create.cqp = &rf->cqp.sc_cqp; 1820 } else if (cmd == IRDMA_OP_AH_DESTROY) { 1821 cqp_info->in.u.ah_destroy.info = sc_ah->ah_info; 1822 cqp_info->in.u.ah_destroy.scratch = (uintptr_t)cqp_request; 1823 cqp_info->in.u.ah_destroy.cqp = &rf->cqp.sc_cqp; 1824 } --- 119 unchanged lines hidden (view full) --- 1944 irdma_ah_cqp_op(rf, ah, IRDMA_OP_AH_DESTROY, false, NULL, NULL); 1945 irdma_free_rsrc(rf, rf->allocated_ahs, ah->ah_info.ah_idx); 1946 } 1947 1948 kfree(ah); 1949} 1950 1951/** | 1811 cqp_info->in.u.ah_create.info = sc_ah->ah_info; 1812 cqp_info->in.u.ah_create.scratch = (uintptr_t)cqp_request; 1813 cqp_info->in.u.ah_create.cqp = &rf->cqp.sc_cqp; 1814 } else if (cmd == IRDMA_OP_AH_DESTROY) { 1815 cqp_info->in.u.ah_destroy.info = sc_ah->ah_info; 1816 cqp_info->in.u.ah_destroy.scratch = (uintptr_t)cqp_request; 1817 cqp_info->in.u.ah_destroy.cqp = &rf->cqp.sc_cqp; 1818 } --- 119 unchanged lines hidden (view full) --- 1938 irdma_ah_cqp_op(rf, ah, IRDMA_OP_AH_DESTROY, false, NULL, NULL); 1939 irdma_free_rsrc(rf, rf->allocated_ahs, ah->ah_info.ah_idx); 1940 } 1941 1942 kfree(ah); 1943} 1944 1945/** |
1952 * irdma_gsi_ud_qp_ah_cb - callback after creation of AH for GSI/ID QP 1953 * @cqp_request: pointer to cqp_request of create AH 1954 */ 1955void 1956irdma_gsi_ud_qp_ah_cb(struct irdma_cqp_request *cqp_request) 1957{ 1958 struct irdma_sc_ah *sc_ah = cqp_request->param; 1959 1960 if (!cqp_request->compl_info.op_ret_val) 1961 sc_ah->ah_info.ah_valid = true; 1962 else 1963 sc_ah->ah_info.ah_valid = false; 1964} 1965 1966/** | |
1967 * irdma_prm_add_pble_mem - add moemory to pble resources 1968 * @pprm: pble resource manager 1969 * @pchunk: chunk of memory to add 1970 */ 1971int 1972irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, 1973 struct irdma_chunk *pchunk) 1974{ --- 30 unchanged lines hidden (view full) --- 2005 u64 **vaddr, u64 *fpm_addr) 2006{ 2007 u64 bits_needed; 2008 u64 bit_idx = PBLE_INVALID_IDX; 2009 struct irdma_chunk *pchunk = NULL; 2010 struct list_head *chunk_entry = (&pprm->clist)->next; 2011 u32 offset; 2012 unsigned long flags; | 1946 * irdma_prm_add_pble_mem - add moemory to pble resources 1947 * @pprm: pble resource manager 1948 * @pchunk: chunk of memory to add 1949 */ 1950int 1951irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, 1952 struct irdma_chunk *pchunk) 1953{ --- 30 unchanged lines hidden (view full) --- 1984 u64 **vaddr, u64 *fpm_addr) 1985{ 1986 u64 bits_needed; 1987 u64 bit_idx = PBLE_INVALID_IDX; 1988 struct irdma_chunk *pchunk = NULL; 1989 struct list_head *chunk_entry = (&pprm->clist)->next; 1990 u32 offset; 1991 unsigned long flags; |
1992 |
|
2013 *vaddr = NULL; 2014 *fpm_addr = 0; 2015 2016 bits_needed = DIV_ROUND_UP_ULL(mem_size, BIT_ULL(pprm->pble_shift)); 2017 2018 spin_lock_irqsave(&pprm->prm_lock, flags); 2019 while (chunk_entry != &pprm->clist) { 2020 pchunk = (struct irdma_chunk *)chunk_entry; --- 529 unchanged lines hidden --- | 1993 *vaddr = NULL; 1994 *fpm_addr = 0; 1995 1996 bits_needed = DIV_ROUND_UP_ULL(mem_size, BIT_ULL(pprm->pble_shift)); 1997 1998 spin_lock_irqsave(&pprm->prm_lock, flags); 1999 while (chunk_entry != &pprm->clist) { 2000 pchunk = (struct irdma_chunk *)chunk_entry; --- 529 unchanged lines hidden --- |