18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2009-2010 Chelsio, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 58c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 118c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 128c2ecf20Sopenharmony_ci * conditions are met: 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 158c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 168c2ecf20Sopenharmony_ci * disclaimer. 178c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 188c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 198c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 208c2ecf20Sopenharmony_ci * provided with the distribution. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 238c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 248c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 258c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 268c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 278c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 288c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 298c2ecf20Sopenharmony_ci * SOFTWARE. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci#ifndef __IW_CXGB4_H__ 328c2ecf20Sopenharmony_ci#define __IW_CXGB4_H__ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#include <linux/mutex.h> 358c2ecf20Sopenharmony_ci#include <linux/list.h> 368c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 378c2ecf20Sopenharmony_ci#include <linux/xarray.h> 388c2ecf20Sopenharmony_ci#include <linux/completion.h> 398c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 408c2ecf20Sopenharmony_ci#include <linux/sched/mm.h> 418c2ecf20Sopenharmony_ci#include <linux/pci.h> 428c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 438c2ecf20Sopenharmony_ci#include <linux/inet.h> 448c2ecf20Sopenharmony_ci#include <linux/wait.h> 458c2ecf20Sopenharmony_ci#include <linux/kref.h> 468c2ecf20Sopenharmony_ci#include <linux/timer.h> 478c2ecf20Sopenharmony_ci#include <linux/io.h> 488c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#include <net/net_namespace.h> 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h> 558c2ecf20Sopenharmony_ci#include <rdma/iw_cm.h> 568c2ecf20Sopenharmony_ci#include <rdma/rdma_netlink.h> 578c2ecf20Sopenharmony_ci#include <rdma/iw_portmap.h> 588c2ecf20Sopenharmony_ci#include <rdma/restrack.h> 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#include "cxgb4.h" 618c2ecf20Sopenharmony_ci#include "cxgb4_uld.h" 628c2ecf20Sopenharmony_ci#include "l2t.h" 638c2ecf20Sopenharmony_ci#include <rdma/cxgb4-abi.h> 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define DRV_NAME "iw_cxgb4" 668c2ecf20Sopenharmony_ci#define MOD DRV_NAME ":" 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#ifdef pr_fmt 698c2ecf20Sopenharmony_ci#undef pr_fmt 708c2ecf20Sopenharmony_ci#endif 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#include "t4.h" 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define PBL_OFF(rdev_p, a) ((a) - (rdev_p)->lldi.vr->pbl.start) 778c2ecf20Sopenharmony_ci#define RQT_OFF(rdev_p, a) ((a) - (rdev_p)->lldi.vr->rq.start) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic inline void *cplhdr(struct sk_buff *skb) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci return skb->data; 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define C4IW_ID_TABLE_F_RANDOM 1 /* Pseudo-randomize the id's returned */ 858c2ecf20Sopenharmony_ci#define C4IW_ID_TABLE_F_EMPTY 2 /* Table is initially empty */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistruct c4iw_id_table { 888c2ecf20Sopenharmony_ci u32 flags; 898c2ecf20Sopenharmony_ci u32 start; /* logical minimal id */ 908c2ecf20Sopenharmony_ci u32 last; /* hint for find */ 918c2ecf20Sopenharmony_ci u32 max; 928c2ecf20Sopenharmony_ci spinlock_t lock; 938c2ecf20Sopenharmony_ci unsigned long *table; 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistruct c4iw_resource { 978c2ecf20Sopenharmony_ci struct c4iw_id_table tpt_table; 988c2ecf20Sopenharmony_ci struct c4iw_id_table qid_table; 998c2ecf20Sopenharmony_ci struct c4iw_id_table pdid_table; 1008c2ecf20Sopenharmony_ci struct c4iw_id_table srq_table; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistruct c4iw_qid_list { 1048c2ecf20Sopenharmony_ci struct list_head entry; 1058c2ecf20Sopenharmony_ci u32 qid; 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistruct c4iw_dev_ucontext { 1098c2ecf20Sopenharmony_ci struct list_head qpids; 1108c2ecf20Sopenharmony_ci struct list_head cqids; 1118c2ecf20Sopenharmony_ci struct mutex lock; 1128c2ecf20Sopenharmony_ci struct kref kref; 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cienum c4iw_rdev_flags { 1168c2ecf20Sopenharmony_ci T4_FATAL_ERROR = (1<<0), 1178c2ecf20Sopenharmony_ci T4_STATUS_PAGE_DISABLED = (1<<1), 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistruct c4iw_stat { 1218c2ecf20Sopenharmony_ci u64 total; 1228c2ecf20Sopenharmony_ci u64 cur; 1238c2ecf20Sopenharmony_ci u64 max; 1248c2ecf20Sopenharmony_ci u64 fail; 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistruct c4iw_stats { 1288c2ecf20Sopenharmony_ci struct mutex lock; 1298c2ecf20Sopenharmony_ci struct c4iw_stat qid; 1308c2ecf20Sopenharmony_ci struct c4iw_stat pd; 1318c2ecf20Sopenharmony_ci struct c4iw_stat stag; 1328c2ecf20Sopenharmony_ci struct c4iw_stat pbl; 1338c2ecf20Sopenharmony_ci struct c4iw_stat rqt; 1348c2ecf20Sopenharmony_ci struct c4iw_stat srqt; 1358c2ecf20Sopenharmony_ci struct c4iw_stat srq; 1368c2ecf20Sopenharmony_ci struct c4iw_stat ocqp; 1378c2ecf20Sopenharmony_ci u64 db_full; 1388c2ecf20Sopenharmony_ci u64 db_empty; 1398c2ecf20Sopenharmony_ci u64 db_drop; 1408c2ecf20Sopenharmony_ci u64 db_state_transitions; 1418c2ecf20Sopenharmony_ci u64 db_fc_interruptions; 1428c2ecf20Sopenharmony_ci u64 tcam_full; 1438c2ecf20Sopenharmony_ci u64 act_ofld_conn_fails; 1448c2ecf20Sopenharmony_ci u64 pas_ofld_conn_fails; 1458c2ecf20Sopenharmony_ci u64 neg_adv; 1468c2ecf20Sopenharmony_ci}; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_cistruct c4iw_hw_queue { 1498c2ecf20Sopenharmony_ci int t4_eq_status_entries; 1508c2ecf20Sopenharmony_ci int t4_max_eq_size; 1518c2ecf20Sopenharmony_ci int t4_max_iq_size; 1528c2ecf20Sopenharmony_ci int t4_max_rq_size; 1538c2ecf20Sopenharmony_ci int t4_max_sq_size; 1548c2ecf20Sopenharmony_ci int t4_max_qp_depth; 1558c2ecf20Sopenharmony_ci int t4_max_cq_depth; 1568c2ecf20Sopenharmony_ci int t4_stat_len; 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistruct wr_log_entry { 1608c2ecf20Sopenharmony_ci ktime_t post_host_time; 1618c2ecf20Sopenharmony_ci ktime_t poll_host_time; 1628c2ecf20Sopenharmony_ci u64 post_sge_ts; 1638c2ecf20Sopenharmony_ci u64 cqe_sge_ts; 1648c2ecf20Sopenharmony_ci u64 poll_sge_ts; 1658c2ecf20Sopenharmony_ci u16 qid; 1668c2ecf20Sopenharmony_ci u16 wr_id; 1678c2ecf20Sopenharmony_ci u8 opcode; 1688c2ecf20Sopenharmony_ci u8 valid; 1698c2ecf20Sopenharmony_ci}; 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistruct c4iw_rdev { 1728c2ecf20Sopenharmony_ci struct c4iw_resource resource; 1738c2ecf20Sopenharmony_ci u32 qpmask; 1748c2ecf20Sopenharmony_ci u32 cqmask; 1758c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext uctx; 1768c2ecf20Sopenharmony_ci struct gen_pool *pbl_pool; 1778c2ecf20Sopenharmony_ci struct gen_pool *rqt_pool; 1788c2ecf20Sopenharmony_ci struct gen_pool *ocqp_pool; 1798c2ecf20Sopenharmony_ci u32 flags; 1808c2ecf20Sopenharmony_ci struct cxgb4_lld_info lldi; 1818c2ecf20Sopenharmony_ci unsigned long bar2_pa; 1828c2ecf20Sopenharmony_ci void __iomem *bar2_kva; 1838c2ecf20Sopenharmony_ci unsigned long oc_mw_pa; 1848c2ecf20Sopenharmony_ci void __iomem *oc_mw_kva; 1858c2ecf20Sopenharmony_ci struct c4iw_stats stats; 1868c2ecf20Sopenharmony_ci struct c4iw_hw_queue hw_queue; 1878c2ecf20Sopenharmony_ci struct t4_dev_status_page *status_page; 1888c2ecf20Sopenharmony_ci atomic_t wr_log_idx; 1898c2ecf20Sopenharmony_ci struct wr_log_entry *wr_log; 1908c2ecf20Sopenharmony_ci int wr_log_size; 1918c2ecf20Sopenharmony_ci struct workqueue_struct *free_workq; 1928c2ecf20Sopenharmony_ci struct completion rqt_compl; 1938c2ecf20Sopenharmony_ci struct completion pbl_compl; 1948c2ecf20Sopenharmony_ci struct kref rqt_kref; 1958c2ecf20Sopenharmony_ci struct kref pbl_kref; 1968c2ecf20Sopenharmony_ci}; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_cistatic inline int c4iw_fatal_error(struct c4iw_rdev *rdev) 1998c2ecf20Sopenharmony_ci{ 2008c2ecf20Sopenharmony_ci return rdev->flags & T4_FATAL_ERROR; 2018c2ecf20Sopenharmony_ci} 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistatic inline int c4iw_num_stags(struct c4iw_rdev *rdev) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci return (int)(rdev->lldi.vr->stag.size >> 5); 2068c2ecf20Sopenharmony_ci} 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci#define C4IW_WR_TO (60*HZ) 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistruct c4iw_wr_wait { 2118c2ecf20Sopenharmony_ci struct completion completion; 2128c2ecf20Sopenharmony_ci int ret; 2138c2ecf20Sopenharmony_ci struct kref kref; 2148c2ecf20Sopenharmony_ci}; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_civoid _c4iw_free_wr_wait(struct kref *kref); 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistatic inline void c4iw_put_wr_wait(struct c4iw_wr_wait *wr_waitp) 2198c2ecf20Sopenharmony_ci{ 2208c2ecf20Sopenharmony_ci pr_debug("wr_wait %p ref before put %u\n", wr_waitp, 2218c2ecf20Sopenharmony_ci kref_read(&wr_waitp->kref)); 2228c2ecf20Sopenharmony_ci WARN_ON(kref_read(&wr_waitp->kref) == 0); 2238c2ecf20Sopenharmony_ci kref_put(&wr_waitp->kref, _c4iw_free_wr_wait); 2248c2ecf20Sopenharmony_ci} 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_cistatic inline void c4iw_get_wr_wait(struct c4iw_wr_wait *wr_waitp) 2278c2ecf20Sopenharmony_ci{ 2288c2ecf20Sopenharmony_ci pr_debug("wr_wait %p ref before get %u\n", wr_waitp, 2298c2ecf20Sopenharmony_ci kref_read(&wr_waitp->kref)); 2308c2ecf20Sopenharmony_ci WARN_ON(kref_read(&wr_waitp->kref) == 0); 2318c2ecf20Sopenharmony_ci kref_get(&wr_waitp->kref); 2328c2ecf20Sopenharmony_ci} 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic inline void c4iw_init_wr_wait(struct c4iw_wr_wait *wr_waitp) 2358c2ecf20Sopenharmony_ci{ 2368c2ecf20Sopenharmony_ci wr_waitp->ret = 0; 2378c2ecf20Sopenharmony_ci init_completion(&wr_waitp->completion); 2388c2ecf20Sopenharmony_ci} 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_cistatic inline void _c4iw_wake_up(struct c4iw_wr_wait *wr_waitp, int ret, 2418c2ecf20Sopenharmony_ci bool deref) 2428c2ecf20Sopenharmony_ci{ 2438c2ecf20Sopenharmony_ci wr_waitp->ret = ret; 2448c2ecf20Sopenharmony_ci complete(&wr_waitp->completion); 2458c2ecf20Sopenharmony_ci if (deref) 2468c2ecf20Sopenharmony_ci c4iw_put_wr_wait(wr_waitp); 2478c2ecf20Sopenharmony_ci} 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_cistatic inline void c4iw_wake_up_noref(struct c4iw_wr_wait *wr_waitp, int ret) 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci _c4iw_wake_up(wr_waitp, ret, false); 2528c2ecf20Sopenharmony_ci} 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_cistatic inline void c4iw_wake_up_deref(struct c4iw_wr_wait *wr_waitp, int ret) 2558c2ecf20Sopenharmony_ci{ 2568c2ecf20Sopenharmony_ci _c4iw_wake_up(wr_waitp, ret, true); 2578c2ecf20Sopenharmony_ci} 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistatic inline int c4iw_wait_for_reply(struct c4iw_rdev *rdev, 2608c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp, 2618c2ecf20Sopenharmony_ci u32 hwtid, u32 qpid, 2628c2ecf20Sopenharmony_ci const char *func) 2638c2ecf20Sopenharmony_ci{ 2648c2ecf20Sopenharmony_ci int ret; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci if (c4iw_fatal_error(rdev)) { 2678c2ecf20Sopenharmony_ci wr_waitp->ret = -EIO; 2688c2ecf20Sopenharmony_ci goto out; 2698c2ecf20Sopenharmony_ci } 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci ret = wait_for_completion_timeout(&wr_waitp->completion, C4IW_WR_TO); 2728c2ecf20Sopenharmony_ci if (!ret) { 2738c2ecf20Sopenharmony_ci pr_err("%s - Device %s not responding (disabling device) - tid %u qpid %u\n", 2748c2ecf20Sopenharmony_ci func, pci_name(rdev->lldi.pdev), hwtid, qpid); 2758c2ecf20Sopenharmony_ci rdev->flags |= T4_FATAL_ERROR; 2768c2ecf20Sopenharmony_ci wr_waitp->ret = -EIO; 2778c2ecf20Sopenharmony_ci goto out; 2788c2ecf20Sopenharmony_ci } 2798c2ecf20Sopenharmony_ci if (wr_waitp->ret) 2808c2ecf20Sopenharmony_ci pr_debug("%s: FW reply %d tid %u qpid %u\n", 2818c2ecf20Sopenharmony_ci pci_name(rdev->lldi.pdev), wr_waitp->ret, hwtid, qpid); 2828c2ecf20Sopenharmony_ciout: 2838c2ecf20Sopenharmony_ci return wr_waitp->ret; 2848c2ecf20Sopenharmony_ci} 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ciint c4iw_ofld_send(struct c4iw_rdev *rdev, struct sk_buff *skb); 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_cistatic inline int c4iw_ref_send_wait(struct c4iw_rdev *rdev, 2898c2ecf20Sopenharmony_ci struct sk_buff *skb, 2908c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp, 2918c2ecf20Sopenharmony_ci u32 hwtid, u32 qpid, 2928c2ecf20Sopenharmony_ci const char *func) 2938c2ecf20Sopenharmony_ci{ 2948c2ecf20Sopenharmony_ci int ret; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci pr_debug("%s wr_wait %p hwtid %u qpid %u\n", func, wr_waitp, hwtid, 2978c2ecf20Sopenharmony_ci qpid); 2988c2ecf20Sopenharmony_ci c4iw_get_wr_wait(wr_waitp); 2998c2ecf20Sopenharmony_ci ret = c4iw_ofld_send(rdev, skb); 3008c2ecf20Sopenharmony_ci if (ret) { 3018c2ecf20Sopenharmony_ci c4iw_put_wr_wait(wr_waitp); 3028c2ecf20Sopenharmony_ci return ret; 3038c2ecf20Sopenharmony_ci } 3048c2ecf20Sopenharmony_ci return c4iw_wait_for_reply(rdev, wr_waitp, hwtid, qpid, func); 3058c2ecf20Sopenharmony_ci} 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cienum db_state { 3088c2ecf20Sopenharmony_ci NORMAL = 0, 3098c2ecf20Sopenharmony_ci FLOW_CONTROL = 1, 3108c2ecf20Sopenharmony_ci RECOVERY = 2, 3118c2ecf20Sopenharmony_ci STOPPED = 3 3128c2ecf20Sopenharmony_ci}; 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_cistruct c4iw_dev { 3158c2ecf20Sopenharmony_ci struct ib_device ibdev; 3168c2ecf20Sopenharmony_ci struct c4iw_rdev rdev; 3178c2ecf20Sopenharmony_ci u32 device_cap_flags; 3188c2ecf20Sopenharmony_ci struct xarray cqs; 3198c2ecf20Sopenharmony_ci struct xarray qps; 3208c2ecf20Sopenharmony_ci struct xarray mrs; 3218c2ecf20Sopenharmony_ci struct mutex db_mutex; 3228c2ecf20Sopenharmony_ci struct dentry *debugfs_root; 3238c2ecf20Sopenharmony_ci enum db_state db_state; 3248c2ecf20Sopenharmony_ci struct xarray hwtids; 3258c2ecf20Sopenharmony_ci struct xarray atids; 3268c2ecf20Sopenharmony_ci struct xarray stids; 3278c2ecf20Sopenharmony_ci struct list_head db_fc_list; 3288c2ecf20Sopenharmony_ci u32 avail_ird; 3298c2ecf20Sopenharmony_ci wait_queue_head_t wait; 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistruct uld_ctx { 3338c2ecf20Sopenharmony_ci struct list_head entry; 3348c2ecf20Sopenharmony_ci struct cxgb4_lld_info lldi; 3358c2ecf20Sopenharmony_ci struct c4iw_dev *dev; 3368c2ecf20Sopenharmony_ci struct work_struct reg_work; 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic inline struct c4iw_dev *to_c4iw_dev(struct ib_device *ibdev) 3408c2ecf20Sopenharmony_ci{ 3418c2ecf20Sopenharmony_ci return container_of(ibdev, struct c4iw_dev, ibdev); 3428c2ecf20Sopenharmony_ci} 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_cistatic inline struct c4iw_dev *rdev_to_c4iw_dev(struct c4iw_rdev *rdev) 3458c2ecf20Sopenharmony_ci{ 3468c2ecf20Sopenharmony_ci return container_of(rdev, struct c4iw_dev, rdev); 3478c2ecf20Sopenharmony_ci} 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_cistatic inline struct c4iw_cq *get_chp(struct c4iw_dev *rhp, u32 cqid) 3508c2ecf20Sopenharmony_ci{ 3518c2ecf20Sopenharmony_ci return xa_load(&rhp->cqs, cqid); 3528c2ecf20Sopenharmony_ci} 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cistatic inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qpid) 3558c2ecf20Sopenharmony_ci{ 3568c2ecf20Sopenharmony_ci return xa_load(&rhp->qps, qpid); 3578c2ecf20Sopenharmony_ci} 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ciextern uint c4iw_max_read_depth; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_cistatic inline int cur_max_read_depth(struct c4iw_dev *dev) 3628c2ecf20Sopenharmony_ci{ 3638c2ecf20Sopenharmony_ci return min(dev->rdev.lldi.max_ordird_qp, c4iw_max_read_depth); 3648c2ecf20Sopenharmony_ci} 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_cistruct c4iw_pd { 3678c2ecf20Sopenharmony_ci struct ib_pd ibpd; 3688c2ecf20Sopenharmony_ci u32 pdid; 3698c2ecf20Sopenharmony_ci struct c4iw_dev *rhp; 3708c2ecf20Sopenharmony_ci}; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_cistatic inline struct c4iw_pd *to_c4iw_pd(struct ib_pd *ibpd) 3738c2ecf20Sopenharmony_ci{ 3748c2ecf20Sopenharmony_ci return container_of(ibpd, struct c4iw_pd, ibpd); 3758c2ecf20Sopenharmony_ci} 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistruct tpt_attributes { 3788c2ecf20Sopenharmony_ci u64 len; 3798c2ecf20Sopenharmony_ci u64 va_fbo; 3808c2ecf20Sopenharmony_ci enum fw_ri_mem_perms perms; 3818c2ecf20Sopenharmony_ci u32 stag; 3828c2ecf20Sopenharmony_ci u32 pdid; 3838c2ecf20Sopenharmony_ci u32 qpid; 3848c2ecf20Sopenharmony_ci u32 pbl_addr; 3858c2ecf20Sopenharmony_ci u32 pbl_size; 3868c2ecf20Sopenharmony_ci u32 state:1; 3878c2ecf20Sopenharmony_ci u32 type:2; 3888c2ecf20Sopenharmony_ci u32 rsvd:1; 3898c2ecf20Sopenharmony_ci u32 remote_invaliate_disable:1; 3908c2ecf20Sopenharmony_ci u32 zbva:1; 3918c2ecf20Sopenharmony_ci u32 mw_bind_enable:1; 3928c2ecf20Sopenharmony_ci u32 page_size:5; 3938c2ecf20Sopenharmony_ci}; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistruct c4iw_mr { 3968c2ecf20Sopenharmony_ci struct ib_mr ibmr; 3978c2ecf20Sopenharmony_ci struct ib_umem *umem; 3988c2ecf20Sopenharmony_ci struct c4iw_dev *rhp; 3998c2ecf20Sopenharmony_ci struct sk_buff *dereg_skb; 4008c2ecf20Sopenharmony_ci u64 kva; 4018c2ecf20Sopenharmony_ci struct tpt_attributes attr; 4028c2ecf20Sopenharmony_ci u64 *mpl; 4038c2ecf20Sopenharmony_ci dma_addr_t mpl_addr; 4048c2ecf20Sopenharmony_ci u32 max_mpl_len; 4058c2ecf20Sopenharmony_ci u32 mpl_len; 4068c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp; 4078c2ecf20Sopenharmony_ci}; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_cistatic inline struct c4iw_mr *to_c4iw_mr(struct ib_mr *ibmr) 4108c2ecf20Sopenharmony_ci{ 4118c2ecf20Sopenharmony_ci return container_of(ibmr, struct c4iw_mr, ibmr); 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_cistruct c4iw_mw { 4158c2ecf20Sopenharmony_ci struct ib_mw ibmw; 4168c2ecf20Sopenharmony_ci struct c4iw_dev *rhp; 4178c2ecf20Sopenharmony_ci struct sk_buff *dereg_skb; 4188c2ecf20Sopenharmony_ci u64 kva; 4198c2ecf20Sopenharmony_ci struct tpt_attributes attr; 4208c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp; 4218c2ecf20Sopenharmony_ci}; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_cistatic inline struct c4iw_mw *to_c4iw_mw(struct ib_mw *ibmw) 4248c2ecf20Sopenharmony_ci{ 4258c2ecf20Sopenharmony_ci return container_of(ibmw, struct c4iw_mw, ibmw); 4268c2ecf20Sopenharmony_ci} 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_cistruct c4iw_cq { 4298c2ecf20Sopenharmony_ci struct ib_cq ibcq; 4308c2ecf20Sopenharmony_ci struct c4iw_dev *rhp; 4318c2ecf20Sopenharmony_ci struct sk_buff *destroy_skb; 4328c2ecf20Sopenharmony_ci struct t4_cq cq; 4338c2ecf20Sopenharmony_ci spinlock_t lock; 4348c2ecf20Sopenharmony_ci spinlock_t comp_handler_lock; 4358c2ecf20Sopenharmony_ci atomic_t refcnt; 4368c2ecf20Sopenharmony_ci wait_queue_head_t wait; 4378c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp; 4388c2ecf20Sopenharmony_ci}; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_cistatic inline struct c4iw_cq *to_c4iw_cq(struct ib_cq *ibcq) 4418c2ecf20Sopenharmony_ci{ 4428c2ecf20Sopenharmony_ci return container_of(ibcq, struct c4iw_cq, ibcq); 4438c2ecf20Sopenharmony_ci} 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistruct c4iw_mpa_attributes { 4468c2ecf20Sopenharmony_ci u8 initiator; 4478c2ecf20Sopenharmony_ci u8 recv_marker_enabled; 4488c2ecf20Sopenharmony_ci u8 xmit_marker_enabled; 4498c2ecf20Sopenharmony_ci u8 crc_enabled; 4508c2ecf20Sopenharmony_ci u8 enhanced_rdma_conn; 4518c2ecf20Sopenharmony_ci u8 version; 4528c2ecf20Sopenharmony_ci u8 p2p_type; 4538c2ecf20Sopenharmony_ci}; 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_cistruct c4iw_qp_attributes { 4568c2ecf20Sopenharmony_ci u32 scq; 4578c2ecf20Sopenharmony_ci u32 rcq; 4588c2ecf20Sopenharmony_ci u32 sq_num_entries; 4598c2ecf20Sopenharmony_ci u32 rq_num_entries; 4608c2ecf20Sopenharmony_ci u32 sq_max_sges; 4618c2ecf20Sopenharmony_ci u32 sq_max_sges_rdma_write; 4628c2ecf20Sopenharmony_ci u32 rq_max_sges; 4638c2ecf20Sopenharmony_ci u32 state; 4648c2ecf20Sopenharmony_ci u8 enable_rdma_read; 4658c2ecf20Sopenharmony_ci u8 enable_rdma_write; 4668c2ecf20Sopenharmony_ci u8 enable_bind; 4678c2ecf20Sopenharmony_ci u8 enable_mmid0_fastreg; 4688c2ecf20Sopenharmony_ci u32 max_ord; 4698c2ecf20Sopenharmony_ci u32 max_ird; 4708c2ecf20Sopenharmony_ci u32 pd; 4718c2ecf20Sopenharmony_ci u32 next_state; 4728c2ecf20Sopenharmony_ci char terminate_buffer[52]; 4738c2ecf20Sopenharmony_ci u32 terminate_msg_len; 4748c2ecf20Sopenharmony_ci u8 is_terminate_local; 4758c2ecf20Sopenharmony_ci struct c4iw_mpa_attributes mpa_attr; 4768c2ecf20Sopenharmony_ci struct c4iw_ep *llp_stream_handle; 4778c2ecf20Sopenharmony_ci u8 layer_etype; 4788c2ecf20Sopenharmony_ci u8 ecode; 4798c2ecf20Sopenharmony_ci u16 sq_db_inc; 4808c2ecf20Sopenharmony_ci u16 rq_db_inc; 4818c2ecf20Sopenharmony_ci u8 send_term; 4828c2ecf20Sopenharmony_ci}; 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_cistruct c4iw_qp { 4858c2ecf20Sopenharmony_ci struct ib_qp ibqp; 4868c2ecf20Sopenharmony_ci struct list_head db_fc_entry; 4878c2ecf20Sopenharmony_ci struct c4iw_dev *rhp; 4888c2ecf20Sopenharmony_ci struct c4iw_ep *ep; 4898c2ecf20Sopenharmony_ci struct c4iw_qp_attributes attr; 4908c2ecf20Sopenharmony_ci struct t4_wq wq; 4918c2ecf20Sopenharmony_ci spinlock_t lock; 4928c2ecf20Sopenharmony_ci struct mutex mutex; 4938c2ecf20Sopenharmony_ci wait_queue_head_t wait; 4948c2ecf20Sopenharmony_ci int sq_sig_all; 4958c2ecf20Sopenharmony_ci struct c4iw_srq *srq; 4968c2ecf20Sopenharmony_ci struct c4iw_ucontext *ucontext; 4978c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp; 4988c2ecf20Sopenharmony_ci struct completion qp_rel_comp; 4998c2ecf20Sopenharmony_ci refcount_t qp_refcnt; 5008c2ecf20Sopenharmony_ci}; 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_cistatic inline struct c4iw_qp *to_c4iw_qp(struct ib_qp *ibqp) 5038c2ecf20Sopenharmony_ci{ 5048c2ecf20Sopenharmony_ci return container_of(ibqp, struct c4iw_qp, ibqp); 5058c2ecf20Sopenharmony_ci} 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_cistruct c4iw_srq { 5088c2ecf20Sopenharmony_ci struct ib_srq ibsrq; 5098c2ecf20Sopenharmony_ci struct list_head db_fc_entry; 5108c2ecf20Sopenharmony_ci struct c4iw_dev *rhp; 5118c2ecf20Sopenharmony_ci struct t4_srq wq; 5128c2ecf20Sopenharmony_ci struct sk_buff *destroy_skb; 5138c2ecf20Sopenharmony_ci u32 srq_limit; 5148c2ecf20Sopenharmony_ci u32 pdid; 5158c2ecf20Sopenharmony_ci int idx; 5168c2ecf20Sopenharmony_ci u32 flags; 5178c2ecf20Sopenharmony_ci spinlock_t lock; /* protects srq */ 5188c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp; 5198c2ecf20Sopenharmony_ci bool armed; 5208c2ecf20Sopenharmony_ci}; 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_cistatic inline struct c4iw_srq *to_c4iw_srq(struct ib_srq *ibsrq) 5238c2ecf20Sopenharmony_ci{ 5248c2ecf20Sopenharmony_ci return container_of(ibsrq, struct c4iw_srq, ibsrq); 5258c2ecf20Sopenharmony_ci} 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_cistruct c4iw_ucontext { 5288c2ecf20Sopenharmony_ci struct ib_ucontext ibucontext; 5298c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext uctx; 5308c2ecf20Sopenharmony_ci u32 key; 5318c2ecf20Sopenharmony_ci spinlock_t mmap_lock; 5328c2ecf20Sopenharmony_ci struct list_head mmaps; 5338c2ecf20Sopenharmony_ci bool is_32b_cqe; 5348c2ecf20Sopenharmony_ci}; 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_cistatic inline struct c4iw_ucontext *to_c4iw_ucontext(struct ib_ucontext *c) 5378c2ecf20Sopenharmony_ci{ 5388c2ecf20Sopenharmony_ci return container_of(c, struct c4iw_ucontext, ibucontext); 5398c2ecf20Sopenharmony_ci} 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_cistruct c4iw_mm_entry { 5428c2ecf20Sopenharmony_ci struct list_head entry; 5438c2ecf20Sopenharmony_ci u64 addr; 5448c2ecf20Sopenharmony_ci u32 key; 5458c2ecf20Sopenharmony_ci unsigned len; 5468c2ecf20Sopenharmony_ci}; 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_cistatic inline struct c4iw_mm_entry *remove_mmap(struct c4iw_ucontext *ucontext, 5498c2ecf20Sopenharmony_ci u32 key, unsigned len) 5508c2ecf20Sopenharmony_ci{ 5518c2ecf20Sopenharmony_ci struct list_head *pos, *nxt; 5528c2ecf20Sopenharmony_ci struct c4iw_mm_entry *mm; 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci spin_lock(&ucontext->mmap_lock); 5558c2ecf20Sopenharmony_ci list_for_each_safe(pos, nxt, &ucontext->mmaps) { 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci mm = list_entry(pos, struct c4iw_mm_entry, entry); 5588c2ecf20Sopenharmony_ci if (mm->key == key && mm->len == len) { 5598c2ecf20Sopenharmony_ci list_del_init(&mm->entry); 5608c2ecf20Sopenharmony_ci spin_unlock(&ucontext->mmap_lock); 5618c2ecf20Sopenharmony_ci pr_debug("key 0x%x addr 0x%llx len %d\n", key, 5628c2ecf20Sopenharmony_ci (unsigned long long)mm->addr, mm->len); 5638c2ecf20Sopenharmony_ci return mm; 5648c2ecf20Sopenharmony_ci } 5658c2ecf20Sopenharmony_ci } 5668c2ecf20Sopenharmony_ci spin_unlock(&ucontext->mmap_lock); 5678c2ecf20Sopenharmony_ci return NULL; 5688c2ecf20Sopenharmony_ci} 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_cistatic inline void insert_mmap(struct c4iw_ucontext *ucontext, 5718c2ecf20Sopenharmony_ci struct c4iw_mm_entry *mm) 5728c2ecf20Sopenharmony_ci{ 5738c2ecf20Sopenharmony_ci spin_lock(&ucontext->mmap_lock); 5748c2ecf20Sopenharmony_ci pr_debug("key 0x%x addr 0x%llx len %d\n", 5758c2ecf20Sopenharmony_ci mm->key, (unsigned long long)mm->addr, mm->len); 5768c2ecf20Sopenharmony_ci list_add_tail(&mm->entry, &ucontext->mmaps); 5778c2ecf20Sopenharmony_ci spin_unlock(&ucontext->mmap_lock); 5788c2ecf20Sopenharmony_ci} 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_cienum c4iw_qp_attr_mask { 5818c2ecf20Sopenharmony_ci C4IW_QP_ATTR_NEXT_STATE = 1 << 0, 5828c2ecf20Sopenharmony_ci C4IW_QP_ATTR_SQ_DB = 1<<1, 5838c2ecf20Sopenharmony_ci C4IW_QP_ATTR_RQ_DB = 1<<2, 5848c2ecf20Sopenharmony_ci C4IW_QP_ATTR_ENABLE_RDMA_READ = 1 << 7, 5858c2ecf20Sopenharmony_ci C4IW_QP_ATTR_ENABLE_RDMA_WRITE = 1 << 8, 5868c2ecf20Sopenharmony_ci C4IW_QP_ATTR_ENABLE_RDMA_BIND = 1 << 9, 5878c2ecf20Sopenharmony_ci C4IW_QP_ATTR_MAX_ORD = 1 << 11, 5888c2ecf20Sopenharmony_ci C4IW_QP_ATTR_MAX_IRD = 1 << 12, 5898c2ecf20Sopenharmony_ci C4IW_QP_ATTR_LLP_STREAM_HANDLE = 1 << 22, 5908c2ecf20Sopenharmony_ci C4IW_QP_ATTR_STREAM_MSG_BUFFER = 1 << 23, 5918c2ecf20Sopenharmony_ci C4IW_QP_ATTR_MPA_ATTR = 1 << 24, 5928c2ecf20Sopenharmony_ci C4IW_QP_ATTR_QP_CONTEXT_ACTIVATE = 1 << 25, 5938c2ecf20Sopenharmony_ci C4IW_QP_ATTR_VALID_MODIFY = (C4IW_QP_ATTR_ENABLE_RDMA_READ | 5948c2ecf20Sopenharmony_ci C4IW_QP_ATTR_ENABLE_RDMA_WRITE | 5958c2ecf20Sopenharmony_ci C4IW_QP_ATTR_MAX_ORD | 5968c2ecf20Sopenharmony_ci C4IW_QP_ATTR_MAX_IRD | 5978c2ecf20Sopenharmony_ci C4IW_QP_ATTR_LLP_STREAM_HANDLE | 5988c2ecf20Sopenharmony_ci C4IW_QP_ATTR_STREAM_MSG_BUFFER | 5998c2ecf20Sopenharmony_ci C4IW_QP_ATTR_MPA_ATTR | 6008c2ecf20Sopenharmony_ci C4IW_QP_ATTR_QP_CONTEXT_ACTIVATE) 6018c2ecf20Sopenharmony_ci}; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ciint c4iw_modify_qp(struct c4iw_dev *rhp, 6048c2ecf20Sopenharmony_ci struct c4iw_qp *qhp, 6058c2ecf20Sopenharmony_ci enum c4iw_qp_attr_mask mask, 6068c2ecf20Sopenharmony_ci struct c4iw_qp_attributes *attrs, 6078c2ecf20Sopenharmony_ci int internal); 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_cienum c4iw_qp_state { 6108c2ecf20Sopenharmony_ci C4IW_QP_STATE_IDLE, 6118c2ecf20Sopenharmony_ci C4IW_QP_STATE_RTS, 6128c2ecf20Sopenharmony_ci C4IW_QP_STATE_ERROR, 6138c2ecf20Sopenharmony_ci C4IW_QP_STATE_TERMINATE, 6148c2ecf20Sopenharmony_ci C4IW_QP_STATE_CLOSING, 6158c2ecf20Sopenharmony_ci C4IW_QP_STATE_TOT 6168c2ecf20Sopenharmony_ci}; 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_cistatic inline int c4iw_convert_state(enum ib_qp_state ib_state) 6198c2ecf20Sopenharmony_ci{ 6208c2ecf20Sopenharmony_ci switch (ib_state) { 6218c2ecf20Sopenharmony_ci case IB_QPS_RESET: 6228c2ecf20Sopenharmony_ci case IB_QPS_INIT: 6238c2ecf20Sopenharmony_ci return C4IW_QP_STATE_IDLE; 6248c2ecf20Sopenharmony_ci case IB_QPS_RTS: 6258c2ecf20Sopenharmony_ci return C4IW_QP_STATE_RTS; 6268c2ecf20Sopenharmony_ci case IB_QPS_SQD: 6278c2ecf20Sopenharmony_ci return C4IW_QP_STATE_CLOSING; 6288c2ecf20Sopenharmony_ci case IB_QPS_SQE: 6298c2ecf20Sopenharmony_ci return C4IW_QP_STATE_TERMINATE; 6308c2ecf20Sopenharmony_ci case IB_QPS_ERR: 6318c2ecf20Sopenharmony_ci return C4IW_QP_STATE_ERROR; 6328c2ecf20Sopenharmony_ci default: 6338c2ecf20Sopenharmony_ci return -1; 6348c2ecf20Sopenharmony_ci } 6358c2ecf20Sopenharmony_ci} 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cistatic inline int to_ib_qp_state(int c4iw_qp_state) 6388c2ecf20Sopenharmony_ci{ 6398c2ecf20Sopenharmony_ci switch (c4iw_qp_state) { 6408c2ecf20Sopenharmony_ci case C4IW_QP_STATE_IDLE: 6418c2ecf20Sopenharmony_ci return IB_QPS_INIT; 6428c2ecf20Sopenharmony_ci case C4IW_QP_STATE_RTS: 6438c2ecf20Sopenharmony_ci return IB_QPS_RTS; 6448c2ecf20Sopenharmony_ci case C4IW_QP_STATE_CLOSING: 6458c2ecf20Sopenharmony_ci return IB_QPS_SQD; 6468c2ecf20Sopenharmony_ci case C4IW_QP_STATE_TERMINATE: 6478c2ecf20Sopenharmony_ci return IB_QPS_SQE; 6488c2ecf20Sopenharmony_ci case C4IW_QP_STATE_ERROR: 6498c2ecf20Sopenharmony_ci return IB_QPS_ERR; 6508c2ecf20Sopenharmony_ci } 6518c2ecf20Sopenharmony_ci return IB_QPS_ERR; 6528c2ecf20Sopenharmony_ci} 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_cistatic inline u32 c4iw_ib_to_tpt_access(int a) 6558c2ecf20Sopenharmony_ci{ 6568c2ecf20Sopenharmony_ci return (a & IB_ACCESS_REMOTE_WRITE ? FW_RI_MEM_ACCESS_REM_WRITE : 0) | 6578c2ecf20Sopenharmony_ci (a & IB_ACCESS_REMOTE_READ ? FW_RI_MEM_ACCESS_REM_READ : 0) | 6588c2ecf20Sopenharmony_ci (a & IB_ACCESS_LOCAL_WRITE ? FW_RI_MEM_ACCESS_LOCAL_WRITE : 0) | 6598c2ecf20Sopenharmony_ci FW_RI_MEM_ACCESS_LOCAL_READ; 6608c2ecf20Sopenharmony_ci} 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_cistatic inline u32 c4iw_ib_to_tpt_bind_access(int acc) 6638c2ecf20Sopenharmony_ci{ 6648c2ecf20Sopenharmony_ci return (acc & IB_ACCESS_REMOTE_WRITE ? FW_RI_MEM_ACCESS_REM_WRITE : 0) | 6658c2ecf20Sopenharmony_ci (acc & IB_ACCESS_REMOTE_READ ? FW_RI_MEM_ACCESS_REM_READ : 0); 6668c2ecf20Sopenharmony_ci} 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_cienum c4iw_mmid_state { 6698c2ecf20Sopenharmony_ci C4IW_STAG_STATE_VALID, 6708c2ecf20Sopenharmony_ci C4IW_STAG_STATE_INVALID 6718c2ecf20Sopenharmony_ci}; 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci#define C4IW_NODE_DESC "cxgb4 Chelsio Communications" 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci#define MPA_KEY_REQ "MPA ID Req Frame" 6768c2ecf20Sopenharmony_ci#define MPA_KEY_REP "MPA ID Rep Frame" 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci#define MPA_MAX_PRIVATE_DATA 256 6798c2ecf20Sopenharmony_ci#define MPA_ENHANCED_RDMA_CONN 0x10 6808c2ecf20Sopenharmony_ci#define MPA_REJECT 0x20 6818c2ecf20Sopenharmony_ci#define MPA_CRC 0x40 6828c2ecf20Sopenharmony_ci#define MPA_MARKERS 0x80 6838c2ecf20Sopenharmony_ci#define MPA_FLAGS_MASK 0xE0 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci#define MPA_V2_PEER2PEER_MODEL 0x8000 6868c2ecf20Sopenharmony_ci#define MPA_V2_ZERO_LEN_FPDU_RTR 0x4000 6878c2ecf20Sopenharmony_ci#define MPA_V2_RDMA_WRITE_RTR 0x8000 6888c2ecf20Sopenharmony_ci#define MPA_V2_RDMA_READ_RTR 0x4000 6898c2ecf20Sopenharmony_ci#define MPA_V2_IRD_ORD_MASK 0x3FFF 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci#define c4iw_put_ep(ep) { \ 6928c2ecf20Sopenharmony_ci pr_debug("put_ep ep %p refcnt %d\n", \ 6938c2ecf20Sopenharmony_ci ep, kref_read(&((ep)->kref))); \ 6948c2ecf20Sopenharmony_ci WARN_ON(kref_read(&((ep)->kref)) < 1); \ 6958c2ecf20Sopenharmony_ci kref_put(&((ep)->kref), _c4iw_free_ep); \ 6968c2ecf20Sopenharmony_ci} 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci#define c4iw_get_ep(ep) { \ 6998c2ecf20Sopenharmony_ci pr_debug("get_ep ep %p, refcnt %d\n", \ 7008c2ecf20Sopenharmony_ci ep, kref_read(&((ep)->kref))); \ 7018c2ecf20Sopenharmony_ci kref_get(&((ep)->kref)); \ 7028c2ecf20Sopenharmony_ci} 7038c2ecf20Sopenharmony_civoid _c4iw_free_ep(struct kref *kref); 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_cistruct mpa_message { 7068c2ecf20Sopenharmony_ci u8 key[16]; 7078c2ecf20Sopenharmony_ci u8 flags; 7088c2ecf20Sopenharmony_ci u8 revision; 7098c2ecf20Sopenharmony_ci __be16 private_data_size; 7108c2ecf20Sopenharmony_ci u8 private_data[]; 7118c2ecf20Sopenharmony_ci}; 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_cistruct mpa_v2_conn_params { 7148c2ecf20Sopenharmony_ci __be16 ird; 7158c2ecf20Sopenharmony_ci __be16 ord; 7168c2ecf20Sopenharmony_ci}; 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_cistruct terminate_message { 7198c2ecf20Sopenharmony_ci u8 layer_etype; 7208c2ecf20Sopenharmony_ci u8 ecode; 7218c2ecf20Sopenharmony_ci __be16 hdrct_rsvd; 7228c2ecf20Sopenharmony_ci u8 len_hdrs[]; 7238c2ecf20Sopenharmony_ci}; 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci#define TERM_MAX_LENGTH (sizeof(struct terminate_message) + 2 + 18 + 28) 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_cienum c4iw_layers_types { 7288c2ecf20Sopenharmony_ci LAYER_RDMAP = 0x00, 7298c2ecf20Sopenharmony_ci LAYER_DDP = 0x10, 7308c2ecf20Sopenharmony_ci LAYER_MPA = 0x20, 7318c2ecf20Sopenharmony_ci RDMAP_LOCAL_CATA = 0x00, 7328c2ecf20Sopenharmony_ci RDMAP_REMOTE_PROT = 0x01, 7338c2ecf20Sopenharmony_ci RDMAP_REMOTE_OP = 0x02, 7348c2ecf20Sopenharmony_ci DDP_LOCAL_CATA = 0x00, 7358c2ecf20Sopenharmony_ci DDP_TAGGED_ERR = 0x01, 7368c2ecf20Sopenharmony_ci DDP_UNTAGGED_ERR = 0x02, 7378c2ecf20Sopenharmony_ci DDP_LLP = 0x03 7388c2ecf20Sopenharmony_ci}; 7398c2ecf20Sopenharmony_ci 7408c2ecf20Sopenharmony_cienum c4iw_rdma_ecodes { 7418c2ecf20Sopenharmony_ci RDMAP_INV_STAG = 0x00, 7428c2ecf20Sopenharmony_ci RDMAP_BASE_BOUNDS = 0x01, 7438c2ecf20Sopenharmony_ci RDMAP_ACC_VIOL = 0x02, 7448c2ecf20Sopenharmony_ci RDMAP_STAG_NOT_ASSOC = 0x03, 7458c2ecf20Sopenharmony_ci RDMAP_TO_WRAP = 0x04, 7468c2ecf20Sopenharmony_ci RDMAP_INV_VERS = 0x05, 7478c2ecf20Sopenharmony_ci RDMAP_INV_OPCODE = 0x06, 7488c2ecf20Sopenharmony_ci RDMAP_STREAM_CATA = 0x07, 7498c2ecf20Sopenharmony_ci RDMAP_GLOBAL_CATA = 0x08, 7508c2ecf20Sopenharmony_ci RDMAP_CANT_INV_STAG = 0x09, 7518c2ecf20Sopenharmony_ci RDMAP_UNSPECIFIED = 0xff 7528c2ecf20Sopenharmony_ci}; 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_cienum c4iw_ddp_ecodes { 7558c2ecf20Sopenharmony_ci DDPT_INV_STAG = 0x00, 7568c2ecf20Sopenharmony_ci DDPT_BASE_BOUNDS = 0x01, 7578c2ecf20Sopenharmony_ci DDPT_STAG_NOT_ASSOC = 0x02, 7588c2ecf20Sopenharmony_ci DDPT_TO_WRAP = 0x03, 7598c2ecf20Sopenharmony_ci DDPT_INV_VERS = 0x04, 7608c2ecf20Sopenharmony_ci DDPU_INV_QN = 0x01, 7618c2ecf20Sopenharmony_ci DDPU_INV_MSN_NOBUF = 0x02, 7628c2ecf20Sopenharmony_ci DDPU_INV_MSN_RANGE = 0x03, 7638c2ecf20Sopenharmony_ci DDPU_INV_MO = 0x04, 7648c2ecf20Sopenharmony_ci DDPU_MSG_TOOBIG = 0x05, 7658c2ecf20Sopenharmony_ci DDPU_INV_VERS = 0x06 7668c2ecf20Sopenharmony_ci}; 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_cienum c4iw_mpa_ecodes { 7698c2ecf20Sopenharmony_ci MPA_CRC_ERR = 0x02, 7708c2ecf20Sopenharmony_ci MPA_MARKER_ERR = 0x03, 7718c2ecf20Sopenharmony_ci MPA_LOCAL_CATA = 0x05, 7728c2ecf20Sopenharmony_ci MPA_INSUFF_IRD = 0x06, 7738c2ecf20Sopenharmony_ci MPA_NOMATCH_RTR = 0x07, 7748c2ecf20Sopenharmony_ci}; 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_cienum c4iw_ep_state { 7778c2ecf20Sopenharmony_ci IDLE = 0, 7788c2ecf20Sopenharmony_ci LISTEN, 7798c2ecf20Sopenharmony_ci CONNECTING, 7808c2ecf20Sopenharmony_ci MPA_REQ_WAIT, 7818c2ecf20Sopenharmony_ci MPA_REQ_SENT, 7828c2ecf20Sopenharmony_ci MPA_REQ_RCVD, 7838c2ecf20Sopenharmony_ci MPA_REP_SENT, 7848c2ecf20Sopenharmony_ci FPDU_MODE, 7858c2ecf20Sopenharmony_ci ABORTING, 7868c2ecf20Sopenharmony_ci CLOSING, 7878c2ecf20Sopenharmony_ci MORIBUND, 7888c2ecf20Sopenharmony_ci DEAD, 7898c2ecf20Sopenharmony_ci}; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_cienum c4iw_ep_flags { 7928c2ecf20Sopenharmony_ci PEER_ABORT_IN_PROGRESS = 0, 7938c2ecf20Sopenharmony_ci ABORT_REQ_IN_PROGRESS = 1, 7948c2ecf20Sopenharmony_ci RELEASE_RESOURCES = 2, 7958c2ecf20Sopenharmony_ci CLOSE_SENT = 3, 7968c2ecf20Sopenharmony_ci TIMEOUT = 4, 7978c2ecf20Sopenharmony_ci QP_REFERENCED = 5, 7988c2ecf20Sopenharmony_ci STOP_MPA_TIMER = 7, 7998c2ecf20Sopenharmony_ci}; 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_cienum c4iw_ep_history { 8028c2ecf20Sopenharmony_ci ACT_OPEN_REQ = 0, 8038c2ecf20Sopenharmony_ci ACT_OFLD_CONN = 1, 8048c2ecf20Sopenharmony_ci ACT_OPEN_RPL = 2, 8058c2ecf20Sopenharmony_ci ACT_ESTAB = 3, 8068c2ecf20Sopenharmony_ci PASS_ACCEPT_REQ = 4, 8078c2ecf20Sopenharmony_ci PASS_ESTAB = 5, 8088c2ecf20Sopenharmony_ci ABORT_UPCALL = 6, 8098c2ecf20Sopenharmony_ci ESTAB_UPCALL = 7, 8108c2ecf20Sopenharmony_ci CLOSE_UPCALL = 8, 8118c2ecf20Sopenharmony_ci ULP_ACCEPT = 9, 8128c2ecf20Sopenharmony_ci ULP_REJECT = 10, 8138c2ecf20Sopenharmony_ci TIMEDOUT = 11, 8148c2ecf20Sopenharmony_ci PEER_ABORT = 12, 8158c2ecf20Sopenharmony_ci PEER_CLOSE = 13, 8168c2ecf20Sopenharmony_ci CONNREQ_UPCALL = 14, 8178c2ecf20Sopenharmony_ci ABORT_CONN = 15, 8188c2ecf20Sopenharmony_ci DISCONN_UPCALL = 16, 8198c2ecf20Sopenharmony_ci EP_DISC_CLOSE = 17, 8208c2ecf20Sopenharmony_ci EP_DISC_ABORT = 18, 8218c2ecf20Sopenharmony_ci CONN_RPL_UPCALL = 19, 8228c2ecf20Sopenharmony_ci ACT_RETRY_NOMEM = 20, 8238c2ecf20Sopenharmony_ci ACT_RETRY_INUSE = 21, 8248c2ecf20Sopenharmony_ci CLOSE_CON_RPL = 22, 8258c2ecf20Sopenharmony_ci EP_DISC_FAIL = 24, 8268c2ecf20Sopenharmony_ci QP_REFED = 25, 8278c2ecf20Sopenharmony_ci QP_DEREFED = 26, 8288c2ecf20Sopenharmony_ci CM_ID_REFED = 27, 8298c2ecf20Sopenharmony_ci CM_ID_DEREFED = 28, 8308c2ecf20Sopenharmony_ci}; 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_cienum conn_pre_alloc_buffers { 8338c2ecf20Sopenharmony_ci CN_ABORT_REQ_BUF, 8348c2ecf20Sopenharmony_ci CN_ABORT_RPL_BUF, 8358c2ecf20Sopenharmony_ci CN_CLOSE_CON_REQ_BUF, 8368c2ecf20Sopenharmony_ci CN_DESTROY_BUF, 8378c2ecf20Sopenharmony_ci CN_FLOWC_BUF, 8388c2ecf20Sopenharmony_ci CN_MAX_CON_BUF 8398c2ecf20Sopenharmony_ci}; 8408c2ecf20Sopenharmony_ci 8418c2ecf20Sopenharmony_cienum { 8428c2ecf20Sopenharmony_ci FLOWC_LEN = offsetof(struct fw_flowc_wr, mnemval[FW_FLOWC_MNEM_MAX]) 8438c2ecf20Sopenharmony_ci}; 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ciunion cpl_wr_size { 8468c2ecf20Sopenharmony_ci struct cpl_abort_req abrt_req; 8478c2ecf20Sopenharmony_ci struct cpl_abort_rpl abrt_rpl; 8488c2ecf20Sopenharmony_ci struct fw_ri_wr ri_req; 8498c2ecf20Sopenharmony_ci struct cpl_close_con_req close_req; 8508c2ecf20Sopenharmony_ci char flowc_buf[FLOWC_LEN]; 8518c2ecf20Sopenharmony_ci}; 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_cistruct c4iw_ep_common { 8548c2ecf20Sopenharmony_ci struct iw_cm_id *cm_id; 8558c2ecf20Sopenharmony_ci struct c4iw_qp *qp; 8568c2ecf20Sopenharmony_ci struct c4iw_dev *dev; 8578c2ecf20Sopenharmony_ci struct sk_buff_head ep_skb_list; 8588c2ecf20Sopenharmony_ci enum c4iw_ep_state state; 8598c2ecf20Sopenharmony_ci struct kref kref; 8608c2ecf20Sopenharmony_ci struct mutex mutex; 8618c2ecf20Sopenharmony_ci struct sockaddr_storage local_addr; 8628c2ecf20Sopenharmony_ci struct sockaddr_storage remote_addr; 8638c2ecf20Sopenharmony_ci struct c4iw_wr_wait *wr_waitp; 8648c2ecf20Sopenharmony_ci unsigned long flags; 8658c2ecf20Sopenharmony_ci unsigned long history; 8668c2ecf20Sopenharmony_ci}; 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_cistruct c4iw_listen_ep { 8698c2ecf20Sopenharmony_ci struct c4iw_ep_common com; 8708c2ecf20Sopenharmony_ci unsigned int stid; 8718c2ecf20Sopenharmony_ci int backlog; 8728c2ecf20Sopenharmony_ci}; 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_cistruct c4iw_ep_stats { 8758c2ecf20Sopenharmony_ci unsigned connect_neg_adv; 8768c2ecf20Sopenharmony_ci unsigned abort_neg_adv; 8778c2ecf20Sopenharmony_ci}; 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_cistruct c4iw_ep { 8808c2ecf20Sopenharmony_ci struct c4iw_ep_common com; 8818c2ecf20Sopenharmony_ci struct c4iw_ep *parent_ep; 8828c2ecf20Sopenharmony_ci struct timer_list timer; 8838c2ecf20Sopenharmony_ci struct list_head entry; 8848c2ecf20Sopenharmony_ci unsigned int atid; 8858c2ecf20Sopenharmony_ci u32 hwtid; 8868c2ecf20Sopenharmony_ci u32 snd_seq; 8878c2ecf20Sopenharmony_ci u32 rcv_seq; 8888c2ecf20Sopenharmony_ci struct l2t_entry *l2t; 8898c2ecf20Sopenharmony_ci struct dst_entry *dst; 8908c2ecf20Sopenharmony_ci struct sk_buff *mpa_skb; 8918c2ecf20Sopenharmony_ci struct c4iw_mpa_attributes mpa_attr; 8928c2ecf20Sopenharmony_ci u8 mpa_pkt[sizeof(struct mpa_message) + MPA_MAX_PRIVATE_DATA]; 8938c2ecf20Sopenharmony_ci unsigned int mpa_pkt_len; 8948c2ecf20Sopenharmony_ci u32 ird; 8958c2ecf20Sopenharmony_ci u32 ord; 8968c2ecf20Sopenharmony_ci u32 smac_idx; 8978c2ecf20Sopenharmony_ci u32 tx_chan; 8988c2ecf20Sopenharmony_ci u32 mtu; 8998c2ecf20Sopenharmony_ci u16 mss; 9008c2ecf20Sopenharmony_ci u16 emss; 9018c2ecf20Sopenharmony_ci u16 plen; 9028c2ecf20Sopenharmony_ci u16 rss_qid; 9038c2ecf20Sopenharmony_ci u16 txq_idx; 9048c2ecf20Sopenharmony_ci u16 ctrlq_idx; 9058c2ecf20Sopenharmony_ci u8 tos; 9068c2ecf20Sopenharmony_ci u8 retry_with_mpa_v1; 9078c2ecf20Sopenharmony_ci u8 tried_with_mpa_v1; 9088c2ecf20Sopenharmony_ci unsigned int retry_count; 9098c2ecf20Sopenharmony_ci int snd_win; 9108c2ecf20Sopenharmony_ci int rcv_win; 9118c2ecf20Sopenharmony_ci u32 snd_wscale; 9128c2ecf20Sopenharmony_ci struct c4iw_ep_stats stats; 9138c2ecf20Sopenharmony_ci u32 srqe_idx; 9148c2ecf20Sopenharmony_ci u32 rx_pdu_out_cnt; 9158c2ecf20Sopenharmony_ci struct sk_buff *peer_abort_skb; 9168c2ecf20Sopenharmony_ci}; 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_cistatic inline struct c4iw_ep *to_ep(struct iw_cm_id *cm_id) 9198c2ecf20Sopenharmony_ci{ 9208c2ecf20Sopenharmony_ci return cm_id->provider_data; 9218c2ecf20Sopenharmony_ci} 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_cistatic inline struct c4iw_listen_ep *to_listen_ep(struct iw_cm_id *cm_id) 9248c2ecf20Sopenharmony_ci{ 9258c2ecf20Sopenharmony_ci return cm_id->provider_data; 9268c2ecf20Sopenharmony_ci} 9278c2ecf20Sopenharmony_ci 9288c2ecf20Sopenharmony_cistatic inline int ocqp_supported(const struct cxgb4_lld_info *infop) 9298c2ecf20Sopenharmony_ci{ 9308c2ecf20Sopenharmony_ci#if defined(__i386__) || defined(__x86_64__) || defined(CONFIG_PPC64) 9318c2ecf20Sopenharmony_ci return infop->vr->ocq.size > 0; 9328c2ecf20Sopenharmony_ci#else 9338c2ecf20Sopenharmony_ci return 0; 9348c2ecf20Sopenharmony_ci#endif 9358c2ecf20Sopenharmony_ci} 9368c2ecf20Sopenharmony_ci 9378c2ecf20Sopenharmony_ciu32 c4iw_id_alloc(struct c4iw_id_table *alloc); 9388c2ecf20Sopenharmony_civoid c4iw_id_free(struct c4iw_id_table *alloc, u32 obj); 9398c2ecf20Sopenharmony_ciint c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num, 9408c2ecf20Sopenharmony_ci u32 reserved, u32 flags); 9418c2ecf20Sopenharmony_civoid c4iw_id_table_free(struct c4iw_id_table *alloc); 9428c2ecf20Sopenharmony_ci 9438c2ecf20Sopenharmony_citypedef int (*c4iw_handler_func)(struct c4iw_dev *dev, struct sk_buff *skb); 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_ciint c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, 9468c2ecf20Sopenharmony_ci struct l2t_entry *l2t); 9478c2ecf20Sopenharmony_civoid c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qpid, 9488c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext *uctx); 9498c2ecf20Sopenharmony_ciu32 c4iw_get_resource(struct c4iw_id_table *id_table); 9508c2ecf20Sopenharmony_civoid c4iw_put_resource(struct c4iw_id_table *id_table, u32 entry); 9518c2ecf20Sopenharmony_ciint c4iw_init_resource(struct c4iw_rdev *rdev, u32 nr_tpt, 9528c2ecf20Sopenharmony_ci u32 nr_pdid, u32 nr_srqt); 9538c2ecf20Sopenharmony_ciint c4iw_init_ctrl_qp(struct c4iw_rdev *rdev); 9548c2ecf20Sopenharmony_ciint c4iw_pblpool_create(struct c4iw_rdev *rdev); 9558c2ecf20Sopenharmony_ciint c4iw_rqtpool_create(struct c4iw_rdev *rdev); 9568c2ecf20Sopenharmony_ciint c4iw_ocqp_pool_create(struct c4iw_rdev *rdev); 9578c2ecf20Sopenharmony_civoid c4iw_pblpool_destroy(struct c4iw_rdev *rdev); 9588c2ecf20Sopenharmony_civoid c4iw_rqtpool_destroy(struct c4iw_rdev *rdev); 9598c2ecf20Sopenharmony_civoid c4iw_ocqp_pool_destroy(struct c4iw_rdev *rdev); 9608c2ecf20Sopenharmony_civoid c4iw_destroy_resource(struct c4iw_resource *rscp); 9618c2ecf20Sopenharmony_ciint c4iw_destroy_ctrl_qp(struct c4iw_rdev *rdev); 9628c2ecf20Sopenharmony_civoid c4iw_register_device(struct work_struct *work); 9638c2ecf20Sopenharmony_civoid c4iw_unregister_device(struct c4iw_dev *dev); 9648c2ecf20Sopenharmony_ciint __init c4iw_cm_init(void); 9658c2ecf20Sopenharmony_civoid c4iw_cm_term(void); 9668c2ecf20Sopenharmony_civoid c4iw_release_dev_ucontext(struct c4iw_rdev *rdev, 9678c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext *uctx); 9688c2ecf20Sopenharmony_civoid c4iw_init_dev_ucontext(struct c4iw_rdev *rdev, 9698c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext *uctx); 9708c2ecf20Sopenharmony_ciint c4iw_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); 9718c2ecf20Sopenharmony_ciint c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr, 9728c2ecf20Sopenharmony_ci const struct ib_send_wr **bad_wr); 9738c2ecf20Sopenharmony_ciint c4iw_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr, 9748c2ecf20Sopenharmony_ci const struct ib_recv_wr **bad_wr); 9758c2ecf20Sopenharmony_ciint c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); 9768c2ecf20Sopenharmony_ciint c4iw_create_listen(struct iw_cm_id *cm_id, int backlog); 9778c2ecf20Sopenharmony_ciint c4iw_destroy_listen(struct iw_cm_id *cm_id); 9788c2ecf20Sopenharmony_ciint c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); 9798c2ecf20Sopenharmony_ciint c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len); 9808c2ecf20Sopenharmony_civoid c4iw_qp_add_ref(struct ib_qp *qp); 9818c2ecf20Sopenharmony_civoid c4iw_qp_rem_ref(struct ib_qp *qp); 9828c2ecf20Sopenharmony_cistruct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, 9838c2ecf20Sopenharmony_ci u32 max_num_sg); 9848c2ecf20Sopenharmony_ciint c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, 9858c2ecf20Sopenharmony_ci unsigned int *sg_offset); 9868c2ecf20Sopenharmony_ciint c4iw_dealloc_mw(struct ib_mw *mw); 9878c2ecf20Sopenharmony_civoid c4iw_dealloc(struct uld_ctx *ctx); 9888c2ecf20Sopenharmony_ciint c4iw_alloc_mw(struct ib_mw *mw, struct ib_udata *udata); 9898c2ecf20Sopenharmony_cistruct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, 9908c2ecf20Sopenharmony_ci u64 length, u64 virt, int acc, 9918c2ecf20Sopenharmony_ci struct ib_udata *udata); 9928c2ecf20Sopenharmony_cistruct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc); 9938c2ecf20Sopenharmony_ciint c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata); 9948c2ecf20Sopenharmony_ciint c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata); 9958c2ecf20Sopenharmony_ciint c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, 9968c2ecf20Sopenharmony_ci struct ib_udata *udata); 9978c2ecf20Sopenharmony_ciint c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); 9988c2ecf20Sopenharmony_ciint c4iw_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *attr, 9998c2ecf20Sopenharmony_ci enum ib_srq_attr_mask srq_attr_mask, 10008c2ecf20Sopenharmony_ci struct ib_udata *udata); 10018c2ecf20Sopenharmony_ciint c4iw_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata); 10028c2ecf20Sopenharmony_ciint c4iw_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *attrs, 10038c2ecf20Sopenharmony_ci struct ib_udata *udata); 10048c2ecf20Sopenharmony_ciint c4iw_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata); 10058c2ecf20Sopenharmony_cistruct ib_qp *c4iw_create_qp(struct ib_pd *pd, 10068c2ecf20Sopenharmony_ci struct ib_qp_init_attr *attrs, 10078c2ecf20Sopenharmony_ci struct ib_udata *udata); 10088c2ecf20Sopenharmony_ciint c4iw_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 10098c2ecf20Sopenharmony_ci int attr_mask, struct ib_udata *udata); 10108c2ecf20Sopenharmony_ciint c4iw_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 10118c2ecf20Sopenharmony_ci int attr_mask, struct ib_qp_init_attr *init_attr); 10128c2ecf20Sopenharmony_cistruct ib_qp *c4iw_get_qp(struct ib_device *dev, int qpn); 10138c2ecf20Sopenharmony_ciu32 c4iw_rqtpool_alloc(struct c4iw_rdev *rdev, int size); 10148c2ecf20Sopenharmony_civoid c4iw_rqtpool_free(struct c4iw_rdev *rdev, u32 addr, int size); 10158c2ecf20Sopenharmony_ciu32 c4iw_pblpool_alloc(struct c4iw_rdev *rdev, int size); 10168c2ecf20Sopenharmony_civoid c4iw_pblpool_free(struct c4iw_rdev *rdev, u32 addr, int size); 10178c2ecf20Sopenharmony_ciu32 c4iw_ocqp_pool_alloc(struct c4iw_rdev *rdev, int size); 10188c2ecf20Sopenharmony_civoid c4iw_ocqp_pool_free(struct c4iw_rdev *rdev, u32 addr, int size); 10198c2ecf20Sopenharmony_civoid c4iw_flush_hw_cq(struct c4iw_cq *chp, struct c4iw_qp *flush_qhp); 10208c2ecf20Sopenharmony_civoid c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count); 10218c2ecf20Sopenharmony_ciint c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp); 10228c2ecf20Sopenharmony_ciint c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count); 10238c2ecf20Sopenharmony_ciint c4iw_flush_sq(struct c4iw_qp *qhp); 10248c2ecf20Sopenharmony_ciint c4iw_ev_handler(struct c4iw_dev *rnicp, u32 qid); 10258c2ecf20Sopenharmony_ciu16 c4iw_rqes_posted(struct c4iw_qp *qhp); 10268c2ecf20Sopenharmony_ciint c4iw_post_terminate(struct c4iw_qp *qhp, struct t4_cqe *err_cqe); 10278c2ecf20Sopenharmony_ciu32 c4iw_get_cqid(struct c4iw_rdev *rdev, struct c4iw_dev_ucontext *uctx); 10288c2ecf20Sopenharmony_civoid c4iw_put_cqid(struct c4iw_rdev *rdev, u32 qid, 10298c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext *uctx); 10308c2ecf20Sopenharmony_ciu32 c4iw_get_qpid(struct c4iw_rdev *rdev, struct c4iw_dev_ucontext *uctx); 10318c2ecf20Sopenharmony_civoid c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qid, 10328c2ecf20Sopenharmony_ci struct c4iw_dev_ucontext *uctx); 10338c2ecf20Sopenharmony_civoid c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe *err_cqe); 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ciextern struct cxgb4_client t4c_client; 10368c2ecf20Sopenharmony_ciextern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS]; 10378c2ecf20Sopenharmony_civoid __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, unsigned int qid, 10388c2ecf20Sopenharmony_ci enum cxgb4_bar2_qtype qtype, 10398c2ecf20Sopenharmony_ci unsigned int *pbar2_qid, u64 *pbar2_pa); 10408c2ecf20Sopenharmony_ciint c4iw_alloc_srq_idx(struct c4iw_rdev *rdev); 10418c2ecf20Sopenharmony_civoid c4iw_free_srq_idx(struct c4iw_rdev *rdev, int idx); 10428c2ecf20Sopenharmony_ciextern void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe); 10438c2ecf20Sopenharmony_ciextern int c4iw_wr_log; 10448c2ecf20Sopenharmony_ciextern int db_fc_threshold; 10458c2ecf20Sopenharmony_ciextern int db_coalescing_threshold; 10468c2ecf20Sopenharmony_ciextern int use_dsgl; 10478c2ecf20Sopenharmony_civoid c4iw_invalidate_mr(struct c4iw_dev *rhp, u32 rkey); 10488c2ecf20Sopenharmony_civoid c4iw_dispatch_srq_limit_reached_event(struct c4iw_srq *srq); 10498c2ecf20Sopenharmony_civoid c4iw_copy_wr_to_srq(struct t4_srq *srq, union t4_recv_wr *wqe, u8 len16); 10508c2ecf20Sopenharmony_civoid c4iw_flush_srqidx(struct c4iw_qp *qhp, u32 srqidx); 10518c2ecf20Sopenharmony_ciint c4iw_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, 10528c2ecf20Sopenharmony_ci const struct ib_recv_wr **bad_wr); 10538c2ecf20Sopenharmony_cistruct c4iw_wr_wait *c4iw_alloc_wr_wait(gfp_t gfp); 10548c2ecf20Sopenharmony_ci 10558c2ecf20Sopenharmony_ciint c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr); 10568c2ecf20Sopenharmony_ciint c4iw_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq); 10578c2ecf20Sopenharmony_ciint c4iw_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp); 10588c2ecf20Sopenharmony_ciint c4iw_fill_res_cm_id_entry(struct sk_buff *msg, struct rdma_cm_id *cm_id); 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci#endif 1061