Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma

Pull rdma updates from Jason Gunthorpe:

- Minor bug fixes in mlx5, mthca, pvrdma, rtrs, mlx4, hfi1, hns

- Minor cleanups: coding style, useless includes and documentation

- Reorganize how multicast processing works in rxe

- Replace a red/black tree with xarray in rxe which improves performance

- DSCP support and HW address handle re-use in irdma

- Simplify the mailbox command handling in hns

- Simplify iser now that FMR is eliminated

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (93 commits)
RDMA/nldev: Prevent underflow in nldev_stat_set_counter_dynamic_doit()
IB/iser: Fix error flow in case of registration failure
IB/iser: Generalize map/unmap dma tasks
IB/iser: Use iser_fr_desc as registration context
IB/iser: Remove iser_reg_data_sg helper function
RDMA/rxe: Use standard names for ref counting
RDMA/rxe: Replace red-black trees by xarrays
RDMA/rxe: Shorten pool names in rxe_pool.c
RDMA/rxe: Move max_elem into rxe_type_info
RDMA/rxe: Replace obj by elem in declaration
RDMA/rxe: Delete _locked() APIs for pool objects
RDMA/rxe: Reverse the sense of RXE_POOL_NO_ALLOC
RDMA/rxe: Replace mr by rkey in responder resources
RDMA/rxe: Fix ref error in rxe_av.c
RDMA/hns: Use the reserved loopback QPs to free MR before destroying MPT
RDMA/irdma: Add support for address handle re-use
RDMA/qib: Fix typos in comments
RDMA/mlx5: Fix memory leak in error flow for subscribe event routine
Revert "RDMA/core: Fix ib_qp_usecnt_dec() called when error"
RDMA/rxe: Remove useless argument for update_state()
...

+2881 -2886
-1
drivers/infiniband/core/addr.c
··· 37 37 #include <linux/inetdevice.h> 38 38 #include <linux/slab.h> 39 39 #include <linux/workqueue.h> 40 - #include <linux/module.h> 41 40 #include <net/arp.h> 42 41 #include <net/neighbour.h> 43 42 #include <net/route.h>
-1
drivers/infiniband/core/cache.c
··· 34 34 */ 35 35 36 36 #include <linux/if_vlan.h> 37 - #include <linux/module.h> 38 37 #include <linux/errno.h> 39 38 #include <linux/slab.h> 40 39 #include <linux/workqueue.h>
+1 -1
drivers/infiniband/core/cma.c
··· 2642 2642 { 2643 2643 struct rdma_id_private *id_priv; 2644 2644 2645 - if (id->qp_type != IB_QPT_RC) 2645 + if (id->qp_type != IB_QPT_RC && id->qp_type != IB_QPT_XRC_INI) 2646 2646 return -EINVAL; 2647 2647 2648 2648 id_priv = container_of(id, struct rdma_id_private, id);
-1
drivers/infiniband/core/cma_configfs.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/module.h> 34 33 #include <linux/configfs.h> 35 34 #include <rdma/ib_verbs.h> 36 35 #include <rdma/rdma_cm.h>
-1
drivers/infiniband/core/cq.c
··· 2 2 /* 3 3 * Copyright (c) 2015 HGST, a Western Digital Company. 4 4 */ 5 - #include <linux/module.h> 6 5 #include <linux/err.h> 7 6 #include <linux/slab.h> 8 7 #include <rdma/ib_verbs.h>
-1
drivers/infiniband/core/iwpm_util.h
··· 33 33 #ifndef _IWPM_UTIL_H 34 34 #define _IWPM_UTIL_H 35 35 36 - #include <linux/module.h> 37 36 #include <linux/io.h> 38 37 #include <linux/in.h> 39 38 #include <linux/in6.h>
+2 -1
drivers/infiniband/core/nldev.c
··· 1951 1951 u32 port) 1952 1952 { 1953 1953 struct rdma_hw_stats *stats; 1954 - int rem, i, index, ret = 0; 1955 1954 struct nlattr *entry_attr; 1956 1955 unsigned long *target; 1956 + int rem, i, ret = 0; 1957 + u32 index; 1957 1958 1958 1959 stats = ib_get_hw_stats_port(device, port); 1959 1960 if (!stats)
-1
drivers/infiniband/core/sa_query.c
··· 32 32 * SOFTWARE. 33 33 */ 34 34 35 - #include <linux/module.h> 36 35 #include <linux/init.h> 37 36 #include <linux/err.h> 38 37 #include <linux/random.h>
+1 -8
drivers/infiniband/core/verbs.c
··· 268 268 return ERR_PTR(-ENOMEM); 269 269 270 270 pd->device = device; 271 - pd->uobject = NULL; 272 - pd->__internal_mr = NULL; 273 - atomic_set(&pd->usecnt, 0); 274 271 pd->flags = flags; 275 272 276 273 rdma_restrack_new(&pd->res, RDMA_RESTRACK_PD); ··· 337 340 WARN_ON(ret); 338 341 pd->__internal_mr = NULL; 339 342 } 340 - 341 - /* uverbs manipulates usecnt with proper locking, while the kabi 342 - * requires the caller to guarantee we can't race here. 343 - */ 344 - WARN_ON(atomic_read(&pd->usecnt)); 345 343 346 344 ret = pd->device->ops.dealloc_pd(pd, udata); 347 345 if (ret) ··· 2145 2153 return mr; 2146 2154 2147 2155 mr->device = pd->device; 2156 + mr->type = IB_MR_TYPE_USER; 2148 2157 mr->pd = pd; 2149 2158 mr->dm = NULL; 2150 2159 atomic_inc(&pd->usecnt);
+2 -3
drivers/infiniband/hw/hfi1/affinity.c
··· 5 5 6 6 #include <linux/topology.h> 7 7 #include <linux/cpumask.h> 8 - #include <linux/module.h> 9 8 #include <linux/interrupt.h> 10 9 #include <linux/numa.h> 11 10 ··· 666 667 * engines, use the same CPU cores as general/control 667 668 * context. 668 669 */ 669 - if (cpumask_weight(&entry->def_intr.mask) == 0) 670 + if (cpumask_empty(&entry->def_intr.mask)) 670 671 cpumask_copy(&entry->def_intr.mask, 671 672 &entry->general_intr_mask); 672 673 } ··· 686 687 * vectors, use the same CPU core as the general/control 687 688 * context. 688 689 */ 689 - if (cpumask_weight(&entry->comp_vect_mask) == 0) 690 + if (cpumask_empty(&entry->comp_vect_mask)) 690 691 cpumask_copy(&entry->comp_vect_mask, 691 692 &entry->general_intr_mask); 692 693 }
-1
drivers/infiniband/hw/hfi1/debugfs.c
··· 7 7 #include <linux/seq_file.h> 8 8 #include <linux/kernel.h> 9 9 #include <linux/export.h> 10 - #include <linux/module.h> 11 10 #include <linux/string.h> 12 11 #include <linux/types.h> 13 12 #include <linux/ratelimit.h>
-1
drivers/infiniband/hw/hfi1/device.c
··· 4 4 */ 5 5 6 6 #include <linux/cdev.h> 7 - #include <linux/module.h> 8 7 #include <linux/device.h> 9 8 #include <linux/fs.h> 10 9
-1
drivers/infiniband/hw/hfi1/fault.c
··· 6 6 #include <linux/debugfs.h> 7 7 #include <linux/seq_file.h> 8 8 #include <linux/kernel.h> 9 - #include <linux/module.h> 10 9 #include <linux/types.h> 11 10 #include <linux/bitmap.h> 12 11
-1
drivers/infiniband/hw/hfi1/firmware.c
··· 5 5 6 6 #include <linux/firmware.h> 7 7 #include <linux/mutex.h> 8 - #include <linux/module.h> 9 8 #include <linux/delay.h> 10 9 #include <linux/crc32.h> 11 10
+1 -2
drivers/infiniband/hw/hfi1/verbs.c
··· 1397 1397 4096 : hfi1_max_mtu), IB_MTU_4096); 1398 1398 props->active_mtu = !valid_ib_mtu(ppd->ibmtu) ? props->max_mtu : 1399 1399 mtu_to_enum(ppd->ibmtu, IB_MTU_4096); 1400 - props->phys_mtu = HFI1_CAP_IS_KSET(AIP) ? hfi1_max_mtu : 1401 - ib_mtu_enum_to_int(props->max_mtu); 1400 + props->phys_mtu = hfi1_max_mtu; 1402 1401 1403 1402 return 0; 1404 1403 }
+51 -46
drivers/infiniband/hw/hns/hns_roce_cmd.c
··· 38 38 #define CMD_POLL_TOKEN 0xffff 39 39 #define CMD_MAX_NUM 32 40 40 41 - static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param, 42 - u64 out_param, u32 in_modifier, 43 - u8 op_modifier, u16 op, u16 token, 44 - int event) 41 + static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, 42 + struct hns_roce_mbox_msg *mbox_msg) 45 43 { 46 - return hr_dev->hw->post_mbox(hr_dev, in_param, out_param, in_modifier, 47 - op_modifier, op, token, event); 44 + return hr_dev->hw->post_mbox(hr_dev, mbox_msg); 48 45 } 49 46 50 47 /* this should be called with "poll_sem" */ 51 - static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param, 52 - u64 out_param, unsigned long in_modifier, 53 - u8 op_modifier, u16 op, 54 - unsigned int timeout) 48 + static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, 49 + struct hns_roce_mbox_msg *mbox_msg) 55 50 { 56 51 int ret; 57 52 58 - ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param, 59 - in_modifier, op_modifier, op, 60 - CMD_POLL_TOKEN, 0); 53 + ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg); 61 54 if (ret) { 62 55 dev_err_ratelimited(hr_dev->dev, 63 56 "failed to post mailbox 0x%x in poll mode, ret = %d.\n", 64 - op, ret); 57 + mbox_msg->cmd, ret); 65 58 return ret; 66 59 } 67 60 68 - return hr_dev->hw->poll_mbox_done(hr_dev, timeout); 61 + return hr_dev->hw->poll_mbox_done(hr_dev); 69 62 } 70 63 71 - static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param, 72 - u64 out_param, unsigned long in_modifier, 73 - u8 op_modifier, u16 op, unsigned int timeout) 64 + static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, 65 + struct hns_roce_mbox_msg *mbox_msg) 74 66 { 75 67 int ret; 76 68 77 69 down(&hr_dev->cmd.poll_sem); 78 - ret = __hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param, in_modifier, 79 - op_modifier, op, timeout); 70 + ret = __hns_roce_cmd_mbox_poll(hr_dev, mbox_msg); 80 71 up(&hr_dev->cmd.poll_sem); 81 72 82 73 return ret; ··· 91 100 complete(&context->done); 92 101 } 93 102 94 - static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, 95 - u64 out_param, unsigned long in_modifier, 96 - u8 op_modifier, u16 op, 97 - unsigned int timeout) 103 + static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, 104 + struct hns_roce_mbox_msg *mbox_msg) 98 105 { 99 106 struct hns_roce_cmdq *cmd = &hr_dev->cmd; 100 107 struct hns_roce_cmd_context *context; ··· 113 124 114 125 reinit_completion(&context->done); 115 126 116 - ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param, 117 - in_modifier, op_modifier, op, 118 - context->token, 1); 127 + mbox_msg->token = context->token; 128 + ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg); 119 129 if (ret) { 120 130 dev_err_ratelimited(dev, 121 131 "failed to post mailbox 0x%x in event mode, ret = %d.\n", 122 - op, ret); 132 + mbox_msg->cmd, ret); 123 133 goto out; 124 134 } 125 135 126 136 if (!wait_for_completion_timeout(&context->done, 127 - msecs_to_jiffies(timeout))) { 137 + msecs_to_jiffies(HNS_ROCE_CMD_TIMEOUT_MSECS))) { 128 138 dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x timeout.\n", 129 - context->token, op); 139 + context->token, mbox_msg->cmd); 130 140 ret = -EBUSY; 131 141 goto out; 132 142 } ··· 133 145 ret = context->result; 134 146 if (ret) 135 147 dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x error %d.\n", 136 - context->token, op, ret); 148 + context->token, mbox_msg->cmd, ret); 137 149 138 150 out: 139 151 context->busy = 0; 140 152 return ret; 141 153 } 142 154 143 - static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, 144 - u64 out_param, unsigned long in_modifier, 145 - u8 op_modifier, u16 op, unsigned int timeout) 155 + static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, 156 + struct hns_roce_mbox_msg *mbox_msg) 146 157 { 147 158 int ret; 148 159 149 160 down(&hr_dev->cmd.event_sem); 150 - ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, in_modifier, 151 - op_modifier, op, timeout); 161 + ret = __hns_roce_cmd_mbox_wait(hr_dev, mbox_msg); 152 162 up(&hr_dev->cmd.event_sem); 153 163 154 164 return ret; 155 165 } 156 166 157 167 int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, 158 - unsigned long in_modifier, u8 op_modifier, u16 op, 159 - unsigned int timeout) 168 + u8 cmd, unsigned long tag) 160 169 { 170 + struct hns_roce_mbox_msg mbox_msg = {}; 161 171 bool is_busy; 162 172 163 173 if (hr_dev->hw->chk_mbox_avail) 164 174 if (!hr_dev->hw->chk_mbox_avail(hr_dev, &is_busy)) 165 175 return is_busy ? -EBUSY : 0; 166 176 167 - if (hr_dev->cmd.use_events) 168 - return hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, 169 - in_modifier, op_modifier, op, 170 - timeout); 171 - else 172 - return hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param, 173 - in_modifier, op_modifier, op, 174 - timeout); 177 + mbox_msg.in_param = in_param; 178 + mbox_msg.out_param = out_param; 179 + mbox_msg.cmd = cmd; 180 + mbox_msg.tag = tag; 181 + 182 + if (hr_dev->cmd.use_events) { 183 + mbox_msg.event_en = 1; 184 + 185 + return hns_roce_cmd_mbox_wait(hr_dev, &mbox_msg); 186 + } else { 187 + mbox_msg.event_en = 0; 188 + mbox_msg.token = CMD_POLL_TOKEN; 189 + 190 + return hns_roce_cmd_mbox_poll(hr_dev, &mbox_msg); 191 + } 175 192 } 176 193 177 194 int hns_roce_cmd_init(struct hns_roce_dev *hr_dev) ··· 261 268 262 269 dma_pool_free(hr_dev->cmd.pool, mailbox->buf, mailbox->dma); 263 270 kfree(mailbox); 271 + } 272 + 273 + int hns_roce_create_hw_ctx(struct hns_roce_dev *dev, 274 + struct hns_roce_cmd_mailbox *mailbox, 275 + u8 cmd, unsigned long idx) 276 + { 277 + return hns_roce_cmd_mbox(dev, mailbox->dma, 0, cmd, idx); 278 + } 279 + 280 + int hns_roce_destroy_hw_ctx(struct hns_roce_dev *dev, u8 cmd, unsigned long idx) 281 + { 282 + return hns_roce_cmd_mbox(dev, 0, 0, cmd, idx); 264 283 }
+6 -2
drivers/infiniband/hw/hns/hns_roce_cmd.h
··· 140 140 }; 141 141 142 142 int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, 143 - unsigned long in_modifier, u8 op_modifier, u16 op, 144 - unsigned int timeout); 143 + u8 cmd, unsigned long tag); 145 144 146 145 struct hns_roce_cmd_mailbox * 147 146 hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev); 148 147 void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev, 149 148 struct hns_roce_cmd_mailbox *mailbox); 149 + int hns_roce_create_hw_ctx(struct hns_roce_dev *dev, 150 + struct hns_roce_cmd_mailbox *mailbox, 151 + u8 cmd, unsigned long idx); 152 + int hns_roce_destroy_hw_ctx(struct hns_roce_dev *dev, u8 cmd, 153 + unsigned long idx); 150 154 151 155 #endif /* _HNS_ROCE_CMD_H */
+39 -32
drivers/infiniband/hw/hns/hns_roce_cq.c
··· 100 100 mutex_unlock(&cq_table->bank_mutex); 101 101 } 102 102 103 + static int hns_roce_create_cqc(struct hns_roce_dev *hr_dev, 104 + struct hns_roce_cq *hr_cq, 105 + u64 *mtts, dma_addr_t dma_handle) 106 + { 107 + struct ib_device *ibdev = &hr_dev->ib_dev; 108 + struct hns_roce_cmd_mailbox *mailbox; 109 + int ret; 110 + 111 + mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); 112 + if (IS_ERR(mailbox)) { 113 + ibdev_err(ibdev, "failed to alloc mailbox for CQC.\n"); 114 + return PTR_ERR(mailbox); 115 + } 116 + 117 + hr_dev->hw->write_cqc(hr_dev, hr_cq, mailbox->buf, mtts, dma_handle); 118 + 119 + ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_CQC, 120 + hr_cq->cqn); 121 + if (ret) 122 + ibdev_err(ibdev, 123 + "failed to send create cmd for CQ(0x%lx), ret = %d.\n", 124 + hr_cq->cqn, ret); 125 + 126 + hns_roce_free_cmd_mailbox(hr_dev, mailbox); 127 + 128 + return ret; 129 + } 130 + 103 131 static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) 104 132 { 105 133 struct hns_roce_cq_table *cq_table = &hr_dev->cq_table; 106 134 struct ib_device *ibdev = &hr_dev->ib_dev; 107 - struct hns_roce_cmd_mailbox *mailbox; 108 - u64 mtts[MTT_MIN_COUNT] = { 0 }; 135 + u64 mtts[MTT_MIN_COUNT] = {}; 109 136 dma_addr_t dma_handle; 110 137 int ret; 111 138 ··· 148 121 if (ret) { 149 122 ibdev_err(ibdev, "failed to get CQ(0x%lx) context, ret = %d.\n", 150 123 hr_cq->cqn, ret); 151 - goto err_out; 124 + return ret; 152 125 } 153 126 154 127 ret = xa_err(xa_store(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL)); ··· 157 130 goto err_put; 158 131 } 159 132 160 - /* Allocate mailbox memory */ 161 - mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); 162 - if (IS_ERR(mailbox)) { 163 - ret = PTR_ERR(mailbox); 133 + ret = hns_roce_create_cqc(hr_dev, hr_cq, mtts, dma_handle); 134 + if (ret) 164 135 goto err_xa; 165 - } 166 - 167 - hr_dev->hw->write_cqc(hr_dev, hr_cq, mailbox->buf, mtts, dma_handle); 168 - 169 - /* Send mailbox to hw */ 170 - ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, 0, 171 - HNS_ROCE_CMD_CREATE_CQC, HNS_ROCE_CMD_TIMEOUT_MSECS); 172 - hns_roce_free_cmd_mailbox(hr_dev, mailbox); 173 - if (ret) { 174 - ibdev_err(ibdev, 175 - "failed to send create cmd for CQ(0x%lx), ret = %d.\n", 176 - hr_cq->cqn, ret); 177 - goto err_xa; 178 - } 179 - 180 - hr_cq->cons_index = 0; 181 - hr_cq->arm_sn = 1; 182 - 183 - refcount_set(&hr_cq->refcount, 1); 184 - init_completion(&hr_cq->free); 185 136 186 137 return 0; 187 138 188 139 err_xa: 189 140 xa_erase(&cq_table->array, hr_cq->cqn); 190 - 191 141 err_put: 192 142 hns_roce_table_put(hr_dev, &cq_table->table, hr_cq->cqn); 193 143 194 - err_out: 195 144 return ret; 196 145 } 197 146 ··· 177 174 struct device *dev = hr_dev->dev; 178 175 int ret; 179 176 180 - ret = hns_roce_cmd_mbox(hr_dev, 0, 0, hr_cq->cqn, 1, 181 - HNS_ROCE_CMD_DESTROY_CQC, 182 - HNS_ROCE_CMD_TIMEOUT_MSECS); 177 + ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_CQC, 178 + hr_cq->cqn); 183 179 if (ret) 184 180 dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret, 185 181 hr_cq->cqn); ··· 414 412 if (ret) 415 413 goto err_cqc; 416 414 } 415 + 416 + hr_cq->cons_index = 0; 417 + hr_cq->arm_sn = 1; 418 + refcount_set(&hr_cq->refcount, 1); 419 + init_completion(&hr_cq->free); 417 420 418 421 return 0; 419 422
+16 -10
drivers/infiniband/hw/hns/hns_roce_device.h
··· 561 561 dma_addr_t dma; 562 562 }; 563 563 564 + struct hns_roce_mbox_msg { 565 + u64 in_param; 566 + u64 out_param; 567 + u8 cmd; 568 + u32 tag; 569 + u16 token; 570 + u8 event_en; 571 + }; 572 + 564 573 struct hns_roce_dev; 565 574 566 575 struct hns_roce_rinl_sge { ··· 633 624 u32 next_sge; 634 625 enum ib_mtu path_mtu; 635 626 u32 max_inline_data; 627 + u8 free_mr_en; 636 628 637 629 /* 0: flush needed, 1: unneeded */ 638 630 unsigned long flush_flag; ··· 861 851 int (*hw_profile)(struct hns_roce_dev *hr_dev); 862 852 int (*hw_init)(struct hns_roce_dev *hr_dev); 863 853 void (*hw_exit)(struct hns_roce_dev *hr_dev); 864 - int (*post_mbox)(struct hns_roce_dev *hr_dev, u64 in_param, 865 - u64 out_param, u32 in_modifier, u8 op_modifier, u16 op, 866 - u16 token, int event); 867 - int (*poll_mbox_done)(struct hns_roce_dev *hr_dev, 868 - unsigned int timeout); 854 + int (*post_mbox)(struct hns_roce_dev *hr_dev, 855 + struct hns_roce_mbox_msg *mbox_msg); 856 + int (*poll_mbox_done)(struct hns_roce_dev *hr_dev); 869 857 bool (*chk_mbox_avail)(struct hns_roce_dev *hr_dev, bool *is_busy); 870 858 int (*set_gid)(struct hns_roce_dev *hr_dev, int gid_index, 871 859 const union ib_gid *gid, const struct ib_gid_attr *attr); ··· 881 873 struct hns_roce_cq *hr_cq, void *mb_buf, u64 *mtts, 882 874 dma_addr_t dma_handle); 883 875 int (*set_hem)(struct hns_roce_dev *hr_dev, 884 - struct hns_roce_hem_table *table, int obj, int step_idx); 876 + struct hns_roce_hem_table *table, int obj, u32 step_idx); 885 877 int (*clear_hem)(struct hns_roce_dev *hr_dev, 886 878 struct hns_roce_hem_table *table, int obj, 887 - int step_idx); 879 + u32 step_idx); 888 880 int (*modify_qp)(struct ib_qp *ibqp, const struct ib_qp_attr *attr, 889 881 int attr_mask, enum ib_qp_state cur_state, 890 882 enum ib_qp_state new_state); 891 883 int (*qp_flow_control_init)(struct hns_roce_dev *hr_dev, 892 884 struct hns_roce_qp *hr_qp); 885 + void (*dereg_mr)(struct hns_roce_dev *hr_dev); 893 886 int (*init_eq)(struct hns_roce_dev *hr_dev); 894 887 void (*cleanup_eq)(struct hns_roce_dev *hr_dev); 895 888 int (*write_srqc)(struct hns_roce_srq *srq, void *mb_buf); ··· 1154 1145 int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, 1155 1146 unsigned int *sg_offset); 1156 1147 int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); 1157 - int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev, 1158 - struct hns_roce_cmd_mailbox *mailbox, 1159 - unsigned long mpt_index); 1160 1148 unsigned long key_to_hw_index(u32 key); 1161 1149 1162 1150 int hns_roce_alloc_mw(struct ib_mw *mw, struct ib_udata *udata);
+2 -2
drivers/infiniband/hw/hns/hns_roce_hem.c
··· 488 488 struct hns_roce_hem_index *index) 489 489 { 490 490 struct ib_device *ibdev = &hr_dev->ib_dev; 491 - int step_idx; 491 + u32 step_idx; 492 492 int ret = 0; 493 493 494 494 if (index->inited & HEM_INDEX_L0) { ··· 618 618 struct ib_device *ibdev = &hr_dev->ib_dev; 619 619 u32 hop_num = mhop->hop_num; 620 620 u32 chunk_ba_num; 621 - int step_idx; 621 + u32 step_idx; 622 622 623 623 index->inited = HEM_INDEX_BUF; 624 624 chunk_ba_num = mhop->bt_chunk_size / BA_BYTE_LEN;
+377 -81
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
··· 1344 1344 return ret; 1345 1345 } 1346 1346 1347 - static int config_hem_ba_to_hw(struct hns_roce_dev *hr_dev, unsigned long obj, 1348 - dma_addr_t base_addr, u16 op) 1347 + static int config_hem_ba_to_hw(struct hns_roce_dev *hr_dev, 1348 + dma_addr_t base_addr, u8 cmd, unsigned long tag) 1349 1349 { 1350 - struct hns_roce_cmd_mailbox *mbox = hns_roce_alloc_cmd_mailbox(hr_dev); 1350 + struct hns_roce_cmd_mailbox *mbox; 1351 1351 int ret; 1352 1352 1353 + mbox = hns_roce_alloc_cmd_mailbox(hr_dev); 1353 1354 if (IS_ERR(mbox)) 1354 1355 return PTR_ERR(mbox); 1355 1356 1356 - ret = hns_roce_cmd_mbox(hr_dev, base_addr, mbox->dma, obj, 0, op, 1357 - HNS_ROCE_CMD_TIMEOUT_MSECS); 1357 + ret = hns_roce_cmd_mbox(hr_dev, base_addr, mbox->dma, cmd, tag); 1358 1358 hns_roce_free_cmd_mailbox(hr_dev, mbox); 1359 1359 return ret; 1360 1360 } ··· 2664 2664 spin_unlock_irqrestore(&hr_dev->dip_list_lock, flags); 2665 2665 } 2666 2666 2667 + static void free_mr_exit(struct hns_roce_dev *hr_dev) 2668 + { 2669 + struct hns_roce_v2_priv *priv = hr_dev->priv; 2670 + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; 2671 + int ret; 2672 + int i; 2673 + 2674 + for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) { 2675 + if (free_mr->rsv_qp[i]) { 2676 + ret = ib_destroy_qp(free_mr->rsv_qp[i]); 2677 + if (ret) 2678 + ibdev_err(&hr_dev->ib_dev, 2679 + "failed to destroy qp in free mr.\n"); 2680 + 2681 + free_mr->rsv_qp[i] = NULL; 2682 + } 2683 + } 2684 + 2685 + if (free_mr->rsv_cq) { 2686 + ib_destroy_cq(free_mr->rsv_cq); 2687 + free_mr->rsv_cq = NULL; 2688 + } 2689 + 2690 + if (free_mr->rsv_pd) { 2691 + ib_dealloc_pd(free_mr->rsv_pd); 2692 + free_mr->rsv_pd = NULL; 2693 + } 2694 + } 2695 + 2696 + static int free_mr_alloc_res(struct hns_roce_dev *hr_dev) 2697 + { 2698 + struct hns_roce_v2_priv *priv = hr_dev->priv; 2699 + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; 2700 + struct ib_device *ibdev = &hr_dev->ib_dev; 2701 + struct ib_cq_init_attr cq_init_attr = {}; 2702 + struct ib_qp_init_attr qp_init_attr = {}; 2703 + struct ib_pd *pd; 2704 + struct ib_cq *cq; 2705 + struct ib_qp *qp; 2706 + int ret; 2707 + int i; 2708 + 2709 + pd = ib_alloc_pd(ibdev, 0); 2710 + if (IS_ERR(pd)) { 2711 + ibdev_err(ibdev, "failed to create pd for free mr.\n"); 2712 + return PTR_ERR(pd); 2713 + } 2714 + free_mr->rsv_pd = pd; 2715 + 2716 + cq_init_attr.cqe = HNS_ROCE_FREE_MR_USED_CQE_NUM; 2717 + cq = ib_create_cq(ibdev, NULL, NULL, NULL, &cq_init_attr); 2718 + if (IS_ERR(cq)) { 2719 + ibdev_err(ibdev, "failed to create cq for free mr.\n"); 2720 + ret = PTR_ERR(cq); 2721 + goto create_failed; 2722 + } 2723 + free_mr->rsv_cq = cq; 2724 + 2725 + qp_init_attr.qp_type = IB_QPT_RC; 2726 + qp_init_attr.sq_sig_type = IB_SIGNAL_ALL_WR; 2727 + qp_init_attr.send_cq = free_mr->rsv_cq; 2728 + qp_init_attr.recv_cq = free_mr->rsv_cq; 2729 + for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) { 2730 + qp_init_attr.cap.max_send_wr = HNS_ROCE_FREE_MR_USED_SQWQE_NUM; 2731 + qp_init_attr.cap.max_send_sge = HNS_ROCE_FREE_MR_USED_SQSGE_NUM; 2732 + qp_init_attr.cap.max_recv_wr = HNS_ROCE_FREE_MR_USED_RQWQE_NUM; 2733 + qp_init_attr.cap.max_recv_sge = HNS_ROCE_FREE_MR_USED_RQSGE_NUM; 2734 + 2735 + qp = ib_create_qp(free_mr->rsv_pd, &qp_init_attr); 2736 + if (IS_ERR(qp)) { 2737 + ibdev_err(ibdev, "failed to create qp for free mr.\n"); 2738 + ret = PTR_ERR(qp); 2739 + goto create_failed; 2740 + } 2741 + 2742 + free_mr->rsv_qp[i] = qp; 2743 + } 2744 + 2745 + return 0; 2746 + 2747 + create_failed: 2748 + free_mr_exit(hr_dev); 2749 + 2750 + return ret; 2751 + } 2752 + 2753 + static int free_mr_modify_rsv_qp(struct hns_roce_dev *hr_dev, 2754 + struct ib_qp_attr *attr, int sl_num) 2755 + { 2756 + struct hns_roce_v2_priv *priv = hr_dev->priv; 2757 + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; 2758 + struct ib_device *ibdev = &hr_dev->ib_dev; 2759 + struct hns_roce_qp *hr_qp; 2760 + int loopback; 2761 + int mask; 2762 + int ret; 2763 + 2764 + hr_qp = to_hr_qp(free_mr->rsv_qp[sl_num]); 2765 + hr_qp->free_mr_en = 1; 2766 + 2767 + mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT | IB_QP_ACCESS_FLAGS; 2768 + attr->qp_state = IB_QPS_INIT; 2769 + attr->port_num = 1; 2770 + attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE; 2771 + ret = ib_modify_qp(&hr_qp->ibqp, attr, mask); 2772 + if (ret) { 2773 + ibdev_err(ibdev, "failed to modify qp to init, ret = %d.\n", 2774 + ret); 2775 + return ret; 2776 + } 2777 + 2778 + loopback = hr_dev->loop_idc; 2779 + /* Set qpc lbi = 1 incidate loopback IO */ 2780 + hr_dev->loop_idc = 1; 2781 + 2782 + mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU | IB_QP_DEST_QPN | 2783 + IB_QP_RQ_PSN | IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER; 2784 + attr->qp_state = IB_QPS_RTR; 2785 + attr->ah_attr.type = RDMA_AH_ATTR_TYPE_ROCE; 2786 + attr->path_mtu = IB_MTU_256; 2787 + attr->dest_qp_num = hr_qp->qpn; 2788 + attr->rq_psn = HNS_ROCE_FREE_MR_USED_PSN; 2789 + 2790 + rdma_ah_set_sl(&attr->ah_attr, (u8)sl_num); 2791 + 2792 + ret = ib_modify_qp(&hr_qp->ibqp, attr, mask); 2793 + hr_dev->loop_idc = loopback; 2794 + if (ret) { 2795 + ibdev_err(ibdev, "failed to modify qp to rtr, ret = %d.\n", 2796 + ret); 2797 + return ret; 2798 + } 2799 + 2800 + mask = IB_QP_STATE | IB_QP_SQ_PSN | IB_QP_RETRY_CNT | IB_QP_TIMEOUT | 2801 + IB_QP_RNR_RETRY | IB_QP_MAX_QP_RD_ATOMIC; 2802 + attr->qp_state = IB_QPS_RTS; 2803 + attr->sq_psn = HNS_ROCE_FREE_MR_USED_PSN; 2804 + attr->retry_cnt = HNS_ROCE_FREE_MR_USED_QP_RETRY_CNT; 2805 + attr->timeout = HNS_ROCE_FREE_MR_USED_QP_TIMEOUT; 2806 + ret = ib_modify_qp(&hr_qp->ibqp, attr, mask); 2807 + if (ret) 2808 + ibdev_err(ibdev, "failed to modify qp to rts, ret = %d.\n", 2809 + ret); 2810 + 2811 + return ret; 2812 + } 2813 + 2814 + static int free_mr_modify_qp(struct hns_roce_dev *hr_dev) 2815 + { 2816 + struct hns_roce_v2_priv *priv = hr_dev->priv; 2817 + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; 2818 + struct ib_qp_attr attr = {}; 2819 + int ret; 2820 + int i; 2821 + 2822 + rdma_ah_set_grh(&attr.ah_attr, NULL, 0, 0, 1, 0); 2823 + rdma_ah_set_static_rate(&attr.ah_attr, 3); 2824 + rdma_ah_set_port_num(&attr.ah_attr, 1); 2825 + 2826 + for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) { 2827 + ret = free_mr_modify_rsv_qp(hr_dev, &attr, i); 2828 + if (ret) 2829 + return ret; 2830 + } 2831 + 2832 + return 0; 2833 + } 2834 + 2835 + static int free_mr_init(struct hns_roce_dev *hr_dev) 2836 + { 2837 + int ret; 2838 + 2839 + ret = free_mr_alloc_res(hr_dev); 2840 + if (ret) 2841 + return ret; 2842 + 2843 + ret = free_mr_modify_qp(hr_dev); 2844 + if (ret) 2845 + goto err_modify_qp; 2846 + 2847 + return 0; 2848 + 2849 + err_modify_qp: 2850 + free_mr_exit(hr_dev); 2851 + 2852 + return ret; 2853 + } 2854 + 2667 2855 static int get_hem_table(struct hns_roce_dev *hr_dev) 2668 2856 { 2669 2857 unsigned int qpc_count; ··· 2968 2780 free_dip_list(hr_dev); 2969 2781 } 2970 2782 2971 - static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev, u64 in_param, 2972 - u64 out_param, u32 in_modifier, u8 op_modifier, 2973 - u16 op, u16 token, int event) 2783 + static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev, 2784 + struct hns_roce_mbox_msg *mbox_msg) 2974 2785 { 2975 2786 struct hns_roce_cmq_desc desc; 2976 2787 struct hns_roce_post_mbox *mb = (struct hns_roce_post_mbox *)desc.data; 2977 2788 2978 2789 hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_POST_MB, false); 2979 2790 2980 - mb->in_param_l = cpu_to_le32(in_param); 2981 - mb->in_param_h = cpu_to_le32(in_param >> 32); 2982 - mb->out_param_l = cpu_to_le32(out_param); 2983 - mb->out_param_h = cpu_to_le32(out_param >> 32); 2984 - mb->cmd_tag = cpu_to_le32(in_modifier << 8 | op); 2985 - mb->token_event_en = cpu_to_le32(event << 16 | token); 2791 + mb->in_param_l = cpu_to_le32(mbox_msg->in_param); 2792 + mb->in_param_h = cpu_to_le32(mbox_msg->in_param >> 32); 2793 + mb->out_param_l = cpu_to_le32(mbox_msg->out_param); 2794 + mb->out_param_h = cpu_to_le32(mbox_msg->out_param >> 32); 2795 + mb->cmd_tag = cpu_to_le32(mbox_msg->tag << 8 | mbox_msg->cmd); 2796 + mb->token_event_en = cpu_to_le32(mbox_msg->event_en << 16 | 2797 + mbox_msg->token); 2986 2798 2987 2799 return hns_roce_cmq_send(hr_dev, &desc, 1); 2988 2800 } ··· 3035 2847 return ret; 3036 2848 } 3037 2849 3038 - static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param, 3039 - u64 out_param, u32 in_modifier, u8 op_modifier, 3040 - u16 op, u16 token, int event) 2850 + static int v2_post_mbox(struct hns_roce_dev *hr_dev, 2851 + struct hns_roce_mbox_msg *mbox_msg) 3041 2852 { 3042 2853 u8 status = 0; 3043 2854 int ret; ··· 3052 2865 } 3053 2866 3054 2867 /* Post new message to mbox */ 3055 - ret = hns_roce_mbox_post(hr_dev, in_param, out_param, in_modifier, 3056 - op_modifier, op, token, event); 2868 + ret = hns_roce_mbox_post(hr_dev, mbox_msg); 3057 2869 if (ret) 3058 2870 dev_err_ratelimited(hr_dev->dev, 3059 2871 "failed to post mailbox, ret = %d.\n", ret); ··· 3060 2874 return ret; 3061 2875 } 3062 2876 3063 - static int v2_poll_mbox_done(struct hns_roce_dev *hr_dev, unsigned int timeout) 2877 + static int v2_poll_mbox_done(struct hns_roce_dev *hr_dev) 3064 2878 { 3065 2879 u8 status = 0; 3066 2880 int ret; 3067 2881 3068 - ret = v2_wait_mbox_complete(hr_dev, timeout, &status); 2882 + ret = v2_wait_mbox_complete(hr_dev, HNS_ROCE_CMD_TIMEOUT_MSECS, 2883 + &status); 3069 2884 if (!ret) { 3070 2885 if (status != MB_ST_COMPLETE_SUCC) 3071 2886 return -EBUSY; ··· 3430 3243 mpt_entry->lkey = cpu_to_le32(mw->rkey); 3431 3244 3432 3245 return 0; 3246 + } 3247 + 3248 + static int free_mr_post_send_lp_wqe(struct hns_roce_qp *hr_qp) 3249 + { 3250 + struct hns_roce_dev *hr_dev = to_hr_dev(hr_qp->ibqp.device); 3251 + struct ib_device *ibdev = &hr_dev->ib_dev; 3252 + const struct ib_send_wr *bad_wr; 3253 + struct ib_rdma_wr rdma_wr = {}; 3254 + struct ib_send_wr *send_wr; 3255 + int ret; 3256 + 3257 + send_wr = &rdma_wr.wr; 3258 + send_wr->opcode = IB_WR_RDMA_WRITE; 3259 + 3260 + ret = hns_roce_v2_post_send(&hr_qp->ibqp, send_wr, &bad_wr); 3261 + if (ret) { 3262 + ibdev_err(ibdev, "failed to post wqe for free mr, ret = %d.\n", 3263 + ret); 3264 + return ret; 3265 + } 3266 + 3267 + return 0; 3268 + } 3269 + 3270 + static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries, 3271 + struct ib_wc *wc); 3272 + 3273 + static void free_mr_send_cmd_to_hw(struct hns_roce_dev *hr_dev) 3274 + { 3275 + struct hns_roce_v2_priv *priv = hr_dev->priv; 3276 + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; 3277 + struct ib_wc wc[ARRAY_SIZE(free_mr->rsv_qp)]; 3278 + struct ib_device *ibdev = &hr_dev->ib_dev; 3279 + struct hns_roce_qp *hr_qp; 3280 + unsigned long end; 3281 + int cqe_cnt = 0; 3282 + int npolled; 3283 + int ret; 3284 + int i; 3285 + 3286 + /* 3287 + * If the device initialization is not complete or in the uninstall 3288 + * process, then there is no need to execute free mr. 3289 + */ 3290 + if (priv->handle->rinfo.reset_state == HNS_ROCE_STATE_RST_INIT || 3291 + priv->handle->rinfo.instance_state == HNS_ROCE_STATE_INIT || 3292 + hr_dev->state == HNS_ROCE_DEVICE_STATE_UNINIT) 3293 + return; 3294 + 3295 + mutex_lock(&free_mr->mutex); 3296 + 3297 + for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) { 3298 + hr_qp = to_hr_qp(free_mr->rsv_qp[i]); 3299 + 3300 + ret = free_mr_post_send_lp_wqe(hr_qp); 3301 + if (ret) { 3302 + ibdev_err(ibdev, 3303 + "failed to send wqe (qp:0x%lx) for free mr, ret = %d.\n", 3304 + hr_qp->qpn, ret); 3305 + break; 3306 + } 3307 + 3308 + cqe_cnt++; 3309 + } 3310 + 3311 + end = msecs_to_jiffies(HNS_ROCE_V2_FREE_MR_TIMEOUT) + jiffies; 3312 + while (cqe_cnt) { 3313 + npolled = hns_roce_v2_poll_cq(free_mr->rsv_cq, cqe_cnt, wc); 3314 + if (npolled < 0) { 3315 + ibdev_err(ibdev, 3316 + "failed to poll cqe for free mr, remain %d cqe.\n", 3317 + cqe_cnt); 3318 + goto out; 3319 + } 3320 + 3321 + if (time_after(jiffies, end)) { 3322 + ibdev_err(ibdev, 3323 + "failed to poll cqe for free mr and timeout, remain %d cqe.\n", 3324 + cqe_cnt); 3325 + goto out; 3326 + } 3327 + cqe_cnt -= npolled; 3328 + } 3329 + 3330 + out: 3331 + mutex_unlock(&free_mr->mutex); 3332 + } 3333 + 3334 + static void hns_roce_v2_dereg_mr(struct hns_roce_dev *hr_dev) 3335 + { 3336 + if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) 3337 + free_mr_send_cmd_to_hw(hr_dev); 3433 3338 } 3434 3339 3435 3340 static void *get_cqe_v2(struct hns_roce_cq *hr_cq, int n) ··· 4097 3818 } 4098 3819 4099 3820 static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type, 4100 - int step_idx, u16 *mbox_op) 3821 + u32 step_idx, u8 *mbox_cmd) 4101 3822 { 4102 - u16 op; 3823 + u8 cmd; 4103 3824 4104 3825 switch (type) { 4105 3826 case HEM_TYPE_QPC: 4106 - op = HNS_ROCE_CMD_WRITE_QPC_BT0; 3827 + cmd = HNS_ROCE_CMD_WRITE_QPC_BT0; 4107 3828 break; 4108 3829 case HEM_TYPE_MTPT: 4109 - op = HNS_ROCE_CMD_WRITE_MPT_BT0; 3830 + cmd = HNS_ROCE_CMD_WRITE_MPT_BT0; 4110 3831 break; 4111 3832 case HEM_TYPE_CQC: 4112 - op = HNS_ROCE_CMD_WRITE_CQC_BT0; 3833 + cmd = HNS_ROCE_CMD_WRITE_CQC_BT0; 4113 3834 break; 4114 3835 case HEM_TYPE_SRQC: 4115 - op = HNS_ROCE_CMD_WRITE_SRQC_BT0; 3836 + cmd = HNS_ROCE_CMD_WRITE_SRQC_BT0; 4116 3837 break; 4117 3838 case HEM_TYPE_SCCC: 4118 - op = HNS_ROCE_CMD_WRITE_SCCC_BT0; 3839 + cmd = HNS_ROCE_CMD_WRITE_SCCC_BT0; 4119 3840 break; 4120 3841 case HEM_TYPE_QPC_TIMER: 4121 - op = HNS_ROCE_CMD_WRITE_QPC_TIMER_BT0; 3842 + cmd = HNS_ROCE_CMD_WRITE_QPC_TIMER_BT0; 4122 3843 break; 4123 3844 case HEM_TYPE_CQC_TIMER: 4124 - op = HNS_ROCE_CMD_WRITE_CQC_TIMER_BT0; 3845 + cmd = HNS_ROCE_CMD_WRITE_CQC_TIMER_BT0; 4125 3846 break; 4126 3847 default: 4127 3848 dev_warn(hr_dev->dev, "failed to check hem type %u.\n", type); 4128 3849 return -EINVAL; 4129 3850 } 4130 3851 4131 - *mbox_op = op + step_idx; 3852 + *mbox_cmd = cmd + step_idx; 4132 3853 4133 3854 return 0; 4134 3855 } ··· 4151 3872 } 4152 3873 4153 3874 static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj, 4154 - dma_addr_t base_addr, u32 hem_type, int step_idx) 3875 + dma_addr_t base_addr, u32 hem_type, u32 step_idx) 4155 3876 { 4156 3877 int ret; 4157 - u16 op; 3878 + u8 cmd; 4158 3879 4159 3880 if (unlikely(hem_type == HEM_TYPE_GMV)) 4160 3881 return config_gmv_ba_to_hw(hr_dev, obj, base_addr); ··· 4162 3883 if (unlikely(hem_type == HEM_TYPE_SCCC && step_idx)) 4163 3884 return 0; 4164 3885 4165 - ret = get_op_for_set_hem(hr_dev, hem_type, step_idx, &op); 3886 + ret = get_op_for_set_hem(hr_dev, hem_type, step_idx, &cmd); 4166 3887 if (ret < 0) 4167 3888 return ret; 4168 3889 4169 - return config_hem_ba_to_hw(hr_dev, obj, base_addr, op); 3890 + return config_hem_ba_to_hw(hr_dev, base_addr, cmd, obj); 4170 3891 } 4171 3892 4172 3893 static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, 4173 3894 struct hns_roce_hem_table *table, int obj, 4174 - int step_idx) 3895 + u32 step_idx) 4175 3896 { 4176 3897 struct hns_roce_hem_iter iter; 4177 3898 struct hns_roce_hem_mhop mhop; ··· 4229 3950 } 4230 3951 4231 3952 static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, 4232 - struct hns_roce_hem_table *table, int obj, 4233 - int step_idx) 3953 + struct hns_roce_hem_table *table, 3954 + int tag, u32 step_idx) 4234 3955 { 4235 - struct device *dev = hr_dev->dev; 4236 3956 struct hns_roce_cmd_mailbox *mailbox; 3957 + struct device *dev = hr_dev->dev; 3958 + u8 cmd = 0xff; 4237 3959 int ret; 4238 - u16 op = 0xff; 4239 3960 4240 3961 if (!hns_roce_check_whether_mhop(hr_dev, table->type)) 4241 3962 return 0; 4242 3963 4243 3964 switch (table->type) { 4244 3965 case HEM_TYPE_QPC: 4245 - op = HNS_ROCE_CMD_DESTROY_QPC_BT0; 3966 + cmd = HNS_ROCE_CMD_DESTROY_QPC_BT0; 4246 3967 break; 4247 3968 case HEM_TYPE_MTPT: 4248 - op = HNS_ROCE_CMD_DESTROY_MPT_BT0; 3969 + cmd = HNS_ROCE_CMD_DESTROY_MPT_BT0; 4249 3970 break; 4250 3971 case HEM_TYPE_CQC: 4251 - op = HNS_ROCE_CMD_DESTROY_CQC_BT0; 3972 + cmd = HNS_ROCE_CMD_DESTROY_CQC_BT0; 4252 3973 break; 4253 3974 case HEM_TYPE_SRQC: 4254 - op = HNS_ROCE_CMD_DESTROY_SRQC_BT0; 3975 + cmd = HNS_ROCE_CMD_DESTROY_SRQC_BT0; 4255 3976 break; 4256 3977 case HEM_TYPE_SCCC: 4257 3978 case HEM_TYPE_QPC_TIMER: ··· 4264 3985 return 0; 4265 3986 } 4266 3987 4267 - op += step_idx; 3988 + cmd += step_idx; 4268 3989 4269 3990 mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); 4270 3991 if (IS_ERR(mailbox)) 4271 3992 return PTR_ERR(mailbox); 4272 3993 4273 - /* configure the tag and op */ 4274 - ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, obj, 0, op, 4275 - HNS_ROCE_CMD_TIMEOUT_MSECS); 3994 + ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, cmd, tag); 4276 3995 4277 3996 hns_roce_free_cmd_mailbox(hr_dev, mailbox); 4278 3997 return ret; ··· 4294 4017 memcpy(mailbox->buf, context, qpc_size); 4295 4018 memcpy(mailbox->buf + qpc_size, qpc_mask, qpc_size); 4296 4019 4297 - ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_qp->qpn, 0, 4298 - HNS_ROCE_CMD_MODIFY_QPC, 4299 - HNS_ROCE_CMD_TIMEOUT_MSECS); 4020 + ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, 4021 + HNS_ROCE_CMD_MODIFY_QPC, hr_qp->qpn); 4300 4022 4301 4023 hns_roce_free_cmd_mailbox(hr_dev, mailbox); 4302 4024 ··· 4943 4667 u8 hr_port; 4944 4668 int ret; 4945 4669 4670 + /* 4671 + * If free_mr_en of qp is set, it means that this qp comes from 4672 + * free mr. This qp will perform the loopback operation. 4673 + * In the loopback scenario, only sl needs to be set. 4674 + */ 4675 + if (hr_qp->free_mr_en) { 4676 + hr_reg_write(context, QPC_SL, rdma_ah_get_sl(&attr->ah_attr)); 4677 + hr_reg_clear(qpc_mask, QPC_SL); 4678 + hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr); 4679 + return 0; 4680 + } 4681 + 4946 4682 ib_port = (attr_mask & IB_QP_PORT) ? attr->port_num : hr_qp->port + 1; 4947 4683 hr_port = ib_port - 1; 4948 4684 is_roce_protocol = rdma_cap_eth_ah(&hr_dev->ib_dev, ib_port) && ··· 5380 5092 if (IS_ERR(mailbox)) 5381 5093 return PTR_ERR(mailbox); 5382 5094 5383 - ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, hr_qp->qpn, 0, 5384 - HNS_ROCE_CMD_QUERY_QPC, 5385 - HNS_ROCE_CMD_TIMEOUT_MSECS); 5095 + ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_QPC, 5096 + hr_qp->qpn); 5386 5097 if (ret) 5387 5098 goto out; 5388 5099 ··· 5747 5460 hr_reg_write(srq_context, SRQC_LIMIT_WL, srq_attr->srq_limit); 5748 5461 hr_reg_clear(srqc_mask, SRQC_LIMIT_WL); 5749 5462 5750 - ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, srq->srqn, 0, 5751 - HNS_ROCE_CMD_MODIFY_SRQC, 5752 - HNS_ROCE_CMD_TIMEOUT_MSECS); 5463 + ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, 5464 + HNS_ROCE_CMD_MODIFY_SRQC, srq->srqn); 5753 5465 hns_roce_free_cmd_mailbox(hr_dev, mailbox); 5754 5466 if (ret) { 5755 5467 ibdev_err(&hr_dev->ib_dev, ··· 5774 5488 return PTR_ERR(mailbox); 5775 5489 5776 5490 srq_context = mailbox->buf; 5777 - ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, srq->srqn, 0, 5778 - HNS_ROCE_CMD_QUERY_SRQC, 5779 - HNS_ROCE_CMD_TIMEOUT_MSECS); 5491 + ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, 5492 + HNS_ROCE_CMD_QUERY_SRQC, srq->srqn); 5780 5493 if (ret) { 5781 5494 ibdev_err(&hr_dev->ib_dev, 5782 5495 "failed to process cmd of querying SRQ, ret = %d.\n", ··· 5825 5540 hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period); 5826 5541 hr_reg_clear(cqc_mask, CQC_CQ_PERIOD); 5827 5542 5828 - ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, 1, 5829 - HNS_ROCE_CMD_MODIFY_CQC, 5830 - HNS_ROCE_CMD_TIMEOUT_MSECS); 5543 + ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, 5544 + HNS_ROCE_CMD_MODIFY_CQC, hr_cq->cqn); 5831 5545 hns_roce_free_cmd_mailbox(hr_dev, mailbox); 5832 5546 if (ret) 5833 5547 ibdev_err(&hr_dev->ib_dev, ··· 6153 5869 { 6154 5870 struct device *dev = hr_dev->dev; 6155 5871 int ret; 5872 + u8 cmd; 6156 5873 6157 5874 if (eqn < hr_dev->caps.num_comp_vectors) 6158 - ret = hns_roce_cmd_mbox(hr_dev, 0, 0, eqn & HNS_ROCE_V2_EQN_M, 6159 - 0, HNS_ROCE_CMD_DESTROY_CEQC, 6160 - HNS_ROCE_CMD_TIMEOUT_MSECS); 5875 + cmd = HNS_ROCE_CMD_DESTROY_CEQC; 6161 5876 else 6162 - ret = hns_roce_cmd_mbox(hr_dev, 0, 0, eqn & HNS_ROCE_V2_EQN_M, 6163 - 0, HNS_ROCE_CMD_DESTROY_AEQC, 6164 - HNS_ROCE_CMD_TIMEOUT_MSECS); 5877 + cmd = HNS_ROCE_CMD_DESTROY_AEQC; 5878 + 5879 + ret = hns_roce_destroy_hw_ctx(hr_dev, cmd, eqn & HNS_ROCE_V2_EQN_M); 6165 5880 if (ret) 6166 5881 dev_err(dev, "[mailbox cmd] destroy eqc(%u) failed.\n", eqn); 6167 5882 } ··· 6266 5983 } 6267 5984 6268 5985 static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev, 6269 - struct hns_roce_eq *eq, 6270 - unsigned int eq_cmd) 5986 + struct hns_roce_eq *eq, u8 eq_cmd) 6271 5987 { 6272 5988 struct hns_roce_cmd_mailbox *mailbox; 6273 5989 int ret; 6274 5990 6275 5991 /* Allocate mailbox memory */ 6276 5992 mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); 6277 - if (IS_ERR_OR_NULL(mailbox)) 6278 - return -ENOMEM; 5993 + if (IS_ERR(mailbox)) 5994 + return PTR_ERR(mailbox); 6279 5995 6280 5996 ret = alloc_eq_buf(hr_dev, eq); 6281 5997 if (ret) ··· 6284 6002 if (ret) 6285 6003 goto err_cmd_mbox; 6286 6004 6287 - ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, eq->eqn, 0, 6288 - eq_cmd, HNS_ROCE_CMD_TIMEOUT_MSECS); 6005 + ret = hns_roce_create_hw_ctx(hr_dev, mailbox, eq_cmd, eq->eqn); 6289 6006 if (ret) { 6290 6007 dev_err(hr_dev->dev, "[mailbox cmd] create eqc failed.\n"); 6291 6008 goto err_cmd_mbox; ··· 6395 6114 struct hns_roce_eq_table *eq_table = &hr_dev->eq_table; 6396 6115 struct device *dev = hr_dev->dev; 6397 6116 struct hns_roce_eq *eq; 6398 - unsigned int eq_cmd; 6399 - int irq_num; 6400 - int eq_num; 6401 6117 int other_num; 6402 6118 int comp_num; 6403 6119 int aeq_num; 6404 - int i; 6120 + int irq_num; 6121 + int eq_num; 6122 + u8 eq_cmd; 6405 6123 int ret; 6124 + int i; 6406 6125 6407 6126 other_num = hr_dev->caps.num_other_vectors; 6408 6127 comp_num = hr_dev->caps.num_comp_vectors; ··· 6539 6258 .set_hem = hns_roce_v2_set_hem, 6540 6259 .clear_hem = hns_roce_v2_clear_hem, 6541 6260 .modify_qp = hns_roce_v2_modify_qp, 6261 + .dereg_mr = hns_roce_v2_dereg_mr, 6542 6262 .qp_flow_control_init = hns_roce_v2_qp_flow_control_init, 6543 6263 .init_eq = hns_roce_v2_init_eq_table, 6544 6264 .cleanup_eq = hns_roce_v2_cleanup_eq_table, ··· 6621 6339 ret = hns_roce_init(hr_dev); 6622 6340 if (ret) { 6623 6341 dev_err(hr_dev->dev, "RoCE Engine init failed!\n"); 6624 - goto error_failed_get_cfg; 6342 + goto error_failed_cfg; 6343 + } 6344 + 6345 + if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) { 6346 + ret = free_mr_init(hr_dev); 6347 + if (ret) { 6348 + dev_err(hr_dev->dev, "failed to init free mr!\n"); 6349 + goto error_failed_roce_init; 6350 + } 6625 6351 } 6626 6352 6627 6353 handle->priv = hr_dev; 6628 6354 6629 6355 return 0; 6630 6356 6631 - error_failed_get_cfg: 6357 + error_failed_roce_init: 6358 + hns_roce_exit(hr_dev); 6359 + 6360 + error_failed_cfg: 6632 6361 kfree(hr_dev->priv); 6633 6362 6634 6363 error_failed_kzalloc: ··· 6660 6367 6661 6368 hr_dev->state = HNS_ROCE_DEVICE_STATE_UNINIT; 6662 6369 hns_roce_handle_device_err(hr_dev); 6370 + 6371 + if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) 6372 + free_mr_exit(hr_dev); 6663 6373 6664 6374 hns_roce_exit(hr_dev); 6665 6375 kfree(hr_dev->priv);
+20
drivers/infiniband/hw/hns/hns_roce_hw_v2.h
··· 139 139 #define CMD_CSQ_DESC_NUM 1024 140 140 #define CMD_CRQ_DESC_NUM 1024 141 141 142 + /* Free mr used parameters */ 143 + #define HNS_ROCE_FREE_MR_USED_CQE_NUM 128 144 + #define HNS_ROCE_FREE_MR_USED_QP_NUM 0x8 145 + #define HNS_ROCE_FREE_MR_USED_PSN 0x0808 146 + #define HNS_ROCE_FREE_MR_USED_QP_RETRY_CNT 0x7 147 + #define HNS_ROCE_FREE_MR_USED_QP_TIMEOUT 0x12 148 + #define HNS_ROCE_FREE_MR_USED_SQWQE_NUM 128 149 + #define HNS_ROCE_FREE_MR_USED_SQSGE_NUM 0x2 150 + #define HNS_ROCE_FREE_MR_USED_RQWQE_NUM 128 151 + #define HNS_ROCE_FREE_MR_USED_RQSGE_NUM 0x2 152 + #define HNS_ROCE_V2_FREE_MR_TIMEOUT 4500 153 + 142 154 enum { 143 155 NO_ARMED = 0x0, 144 156 REG_NXT_CEQE = 0x2, ··· 1430 1418 #define HNS_ROCE_EXT_LLM_ENTRY(addr, id) (((id) << (64 - 12)) | ((addr) >> 12)) 1431 1419 #define HNS_ROCE_EXT_LLM_MIN_PAGES(que_num) ((que_num) * 4 + 2) 1432 1420 1421 + struct hns_roce_v2_free_mr { 1422 + struct ib_qp *rsv_qp[HNS_ROCE_FREE_MR_USED_QP_NUM]; 1423 + struct ib_cq *rsv_cq; 1424 + struct ib_pd *rsv_pd; 1425 + struct mutex mutex; 1426 + }; 1427 + 1433 1428 struct hns_roce_v2_priv { 1434 1429 struct hnae3_handle *handle; 1435 1430 struct hns_roce_v2_cmq cmq; 1436 1431 struct hns_roce_link_table ext_llm; 1432 + struct hns_roce_v2_free_mr free_mr; 1437 1433 }; 1438 1434 1439 1435 struct hns_roce_dip {
+2 -3
drivers/infiniband/hw/hns/hns_roce_hw_v2_dfx.c
··· 18 18 return PTR_ERR(mailbox); 19 19 20 20 cq_context = mailbox->buf; 21 - ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, cqn, 0, 22 - HNS_ROCE_CMD_QUERY_CQC, 23 - HNS_ROCE_CMD_TIMEOUT_MSECS); 21 + ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_CQC, 22 + cqn); 24 23 if (ret) { 25 24 dev_err(hr_dev->dev, "QUERY cqc cmd process error\n"); 26 25 goto err_mailbox;
+17 -33
drivers/infiniband/hw/hns/hns_roce_mr.c
··· 47 47 return (key << 24) | (key >> 8); 48 48 } 49 49 50 - static int hns_roce_hw_create_mpt(struct hns_roce_dev *hr_dev, 51 - struct hns_roce_cmd_mailbox *mailbox, 52 - unsigned long mpt_index) 53 - { 54 - return hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, mpt_index, 0, 55 - HNS_ROCE_CMD_CREATE_MPT, 56 - HNS_ROCE_CMD_TIMEOUT_MSECS); 57 - } 58 - 59 - int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev, 60 - struct hns_roce_cmd_mailbox *mailbox, 61 - unsigned long mpt_index) 62 - { 63 - return hns_roce_cmd_mbox(hr_dev, 0, mailbox ? mailbox->dma : 0, 64 - mpt_index, !mailbox, HNS_ROCE_CMD_DESTROY_MPT, 65 - HNS_ROCE_CMD_TIMEOUT_MSECS); 66 - } 67 - 68 50 static int alloc_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) 69 51 { 70 52 struct hns_roce_ida *mtpt_ida = &hr_dev->mr_table.mtpt_ida; ··· 119 137 hns_roce_mtr_destroy(hr_dev, &mr->pbl_mtr); 120 138 } 121 139 122 - static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, 123 - struct hns_roce_mr *mr) 140 + static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) 124 141 { 125 142 struct ib_device *ibdev = &hr_dev->ib_dev; 126 143 int ret; 127 144 128 145 if (mr->enabled) { 129 - ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, 146 + ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_MPT, 130 147 key_to_hw_index(mr->key) & 131 148 (hr_dev->caps.num_mtpts - 1)); 132 149 if (ret) ··· 147 166 148 167 /* Allocate mailbox memory */ 149 168 mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); 150 - if (IS_ERR(mailbox)) { 151 - ret = PTR_ERR(mailbox); 152 - return ret; 153 - } 169 + if (IS_ERR(mailbox)) 170 + return PTR_ERR(mailbox); 154 171 155 172 if (mr->type != MR_TYPE_FRMR) 156 173 ret = hr_dev->hw->write_mtpt(hr_dev, mailbox->buf, mr); ··· 159 180 goto err_page; 160 181 } 161 182 162 - ret = hns_roce_hw_create_mpt(hr_dev, mailbox, 183 + ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_MPT, 163 184 mtpt_idx & (hr_dev->caps.num_mtpts - 1)); 164 185 if (ret) { 165 186 dev_err(dev, "failed to create mpt, ret = %d.\n", ret); ··· 282 303 return ERR_CAST(mailbox); 283 304 284 305 mtpt_idx = key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1); 285 - ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, mtpt_idx, 0, 286 - HNS_ROCE_CMD_QUERY_MPT, 287 - HNS_ROCE_CMD_TIMEOUT_MSECS); 306 + 307 + ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_MPT, 308 + mtpt_idx); 288 309 if (ret) 289 310 goto free_cmd_mbox; 290 311 291 - ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, mtpt_idx); 312 + ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_MPT, 313 + mtpt_idx); 292 314 if (ret) 293 315 ibdev_warn(ib_dev, "failed to destroy MPT, ret = %d.\n", ret); 294 316 ··· 319 339 goto free_cmd_mbox; 320 340 } 321 341 322 - ret = hns_roce_hw_create_mpt(hr_dev, mailbox, mtpt_idx); 342 + ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_MPT, 343 + mtpt_idx); 323 344 if (ret) { 324 345 ibdev_err(ib_dev, "failed to create MPT, ret = %d.\n", ret); 325 346 goto free_cmd_mbox; ··· 341 360 struct hns_roce_dev *hr_dev = to_hr_dev(ibmr->device); 342 361 struct hns_roce_mr *mr = to_hr_mr(ibmr); 343 362 int ret = 0; 363 + 364 + if (hr_dev->hw->dereg_mr) 365 + hr_dev->hw->dereg_mr(hr_dev); 344 366 345 367 hns_roce_mr_free(hr_dev, mr); 346 368 kfree(mr); ··· 464 480 int ret; 465 481 466 482 if (mw->enabled) { 467 - ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, 483 + ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_MPT, 468 484 key_to_hw_index(mw->rkey) & 469 485 (hr_dev->caps.num_mtpts - 1)); 470 486 if (ret) ··· 504 520 goto err_page; 505 521 } 506 522 507 - ret = hns_roce_hw_create_mpt(hr_dev, mailbox, 523 + ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_MPT, 508 524 mtpt_idx & (hr_dev->caps.num_mtpts - 1)); 509 525 if (ret) { 510 526 dev_err(dev, "MW CREATE_MPT failed (%d)\n", ret);
+59 -51
drivers/infiniband/hw/hns/hns_roce_srq.c
··· 59 59 } 60 60 } 61 61 62 - static int hns_roce_hw_create_srq(struct hns_roce_dev *dev, 63 - struct hns_roce_cmd_mailbox *mailbox, 64 - unsigned long srq_num) 62 + static int alloc_srqn(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) 65 63 { 66 - return hns_roce_cmd_mbox(dev, mailbox->dma, 0, srq_num, 0, 67 - HNS_ROCE_CMD_CREATE_SRQ, 68 - HNS_ROCE_CMD_TIMEOUT_MSECS); 69 - } 70 - 71 - static int hns_roce_hw_destroy_srq(struct hns_roce_dev *dev, 72 - struct hns_roce_cmd_mailbox *mailbox, 73 - unsigned long srq_num) 74 - { 75 - return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, srq_num, 76 - mailbox ? 0 : 1, HNS_ROCE_CMD_DESTROY_SRQ, 77 - HNS_ROCE_CMD_TIMEOUT_MSECS); 78 - } 79 - 80 - static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) 81 - { 82 - struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; 83 64 struct hns_roce_ida *srq_ida = &hr_dev->srq_table.srq_ida; 84 - struct ib_device *ibdev = &hr_dev->ib_dev; 85 - struct hns_roce_cmd_mailbox *mailbox; 86 - int ret; 87 65 int id; 88 66 89 67 id = ida_alloc_range(&srq_ida->ida, srq_ida->min, srq_ida->max, 90 68 GFP_KERNEL); 91 69 if (id < 0) { 92 - ibdev_err(ibdev, "failed to alloc srq(%d).\n", id); 70 + ibdev_err(&hr_dev->ib_dev, "failed to alloc srq(%d).\n", id); 93 71 return -ENOMEM; 94 72 } 95 - srq->srqn = (unsigned long)id; 96 73 97 - ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn); 98 - if (ret) { 99 - ibdev_err(ibdev, "failed to get SRQC table, ret = %d.\n", ret); 100 - goto err_out; 101 - } 74 + srq->srqn = id; 102 75 103 - ret = xa_err(xa_store(&srq_table->xa, srq->srqn, srq, GFP_KERNEL)); 104 - if (ret) { 105 - ibdev_err(ibdev, "failed to store SRQC, ret = %d.\n", ret); 106 - goto err_put; 107 - } 76 + return 0; 77 + } 78 + 79 + static void free_srqn(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) 80 + { 81 + ida_free(&hr_dev->srq_table.srq_ida.ida, (int)srq->srqn); 82 + } 83 + 84 + static int hns_roce_create_srqc(struct hns_roce_dev *hr_dev, 85 + struct hns_roce_srq *srq) 86 + { 87 + struct ib_device *ibdev = &hr_dev->ib_dev; 88 + struct hns_roce_cmd_mailbox *mailbox; 89 + int ret; 108 90 109 91 mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); 110 - if (IS_ERR_OR_NULL(mailbox)) { 92 + if (IS_ERR(mailbox)) { 111 93 ibdev_err(ibdev, "failed to alloc mailbox for SRQC.\n"); 112 - ret = -ENOMEM; 113 - goto err_xa; 94 + return PTR_ERR(mailbox); 114 95 } 115 96 116 97 ret = hr_dev->hw->write_srqc(srq, mailbox->buf); ··· 100 119 goto err_mbox; 101 120 } 102 121 103 - ret = hns_roce_hw_create_srq(hr_dev, mailbox, srq->srqn); 104 - if (ret) { 122 + ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_SRQ, 123 + srq->srqn); 124 + if (ret) 105 125 ibdev_err(ibdev, "failed to config SRQC, ret = %d.\n", ret); 106 - goto err_mbox; 107 - } 108 - 109 - hns_roce_free_cmd_mailbox(hr_dev, mailbox); 110 - 111 - return 0; 112 126 113 127 err_mbox: 114 128 hns_roce_free_cmd_mailbox(hr_dev, mailbox); 129 + return ret; 130 + } 131 + 132 + static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) 133 + { 134 + struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; 135 + struct ib_device *ibdev = &hr_dev->ib_dev; 136 + int ret; 137 + 138 + ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn); 139 + if (ret) { 140 + ibdev_err(ibdev, "failed to get SRQC table, ret = %d.\n", ret); 141 + return ret; 142 + } 143 + 144 + ret = xa_err(xa_store(&srq_table->xa, srq->srqn, srq, GFP_KERNEL)); 145 + if (ret) { 146 + ibdev_err(ibdev, "failed to store SRQC, ret = %d.\n", ret); 147 + goto err_put; 148 + } 149 + 150 + ret = hns_roce_create_srqc(hr_dev, srq); 151 + if (ret) 152 + goto err_xa; 153 + 154 + return 0; 155 + 115 156 err_xa: 116 157 xa_erase(&srq_table->xa, srq->srqn); 117 158 err_put: 118 159 hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); 119 - err_out: 120 - ida_free(&srq_ida->ida, id); 121 160 122 161 return ret; 123 162 } ··· 147 146 struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; 148 147 int ret; 149 148 150 - ret = hns_roce_hw_destroy_srq(hr_dev, NULL, srq->srqn); 149 + ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_SRQ, 150 + srq->srqn); 151 151 if (ret) 152 152 dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n", 153 153 ret, srq->srqn); ··· 160 158 wait_for_completion(&srq->free); 161 159 162 160 hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); 163 - ida_free(&srq_table->srq_ida.ida, (int)srq->srqn); 164 161 } 165 162 166 163 static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, ··· 407 406 if (ret) 408 407 return ret; 409 408 410 - ret = alloc_srqc(hr_dev, srq); 409 + ret = alloc_srqn(hr_dev, srq); 411 410 if (ret) 412 411 goto err_srq_buf; 412 + 413 + ret = alloc_srqc(hr_dev, srq); 414 + if (ret) 415 + goto err_srqn; 413 416 414 417 if (udata) { 415 418 resp.srqn = srq->srqn; ··· 433 428 434 429 err_srqc: 435 430 free_srqc(hr_dev, srq); 431 + err_srqn: 432 + free_srqn(hr_dev, srq); 436 433 err_srq_buf: 437 434 free_srq_buf(hr_dev, srq); 438 435 ··· 447 440 struct hns_roce_srq *srq = to_hr_srq(ibsrq); 448 441 449 442 free_srqc(hr_dev, srq); 443 + free_srqn(hr_dev, srq); 450 444 free_srq_buf(hr_dev, srq); 451 445 return 0; 452 446 }
+39 -29
drivers/infiniband/hw/irdma/cm.c
··· 1501 1501 * @cm_info: CM info for parent listen node 1502 1502 * @cm_parent_listen_node: The parent listen node 1503 1503 */ 1504 - static enum irdma_status_code 1505 - irdma_del_multiple_qhash(struct irdma_device *iwdev, 1506 - struct irdma_cm_info *cm_info, 1507 - struct irdma_cm_listener *cm_parent_listen_node) 1504 + static int irdma_del_multiple_qhash(struct irdma_device *iwdev, 1505 + struct irdma_cm_info *cm_info, 1506 + struct irdma_cm_listener *cm_parent_listen_node) 1508 1507 { 1509 1508 struct irdma_cm_listener *child_listen_node; 1510 - enum irdma_status_code ret = IRDMA_ERR_CFG; 1511 1509 struct list_head *pos, *tpos; 1512 1510 unsigned long flags; 1511 + int ret = -EINVAL; 1513 1512 1514 1513 spin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags); 1515 1514 list_for_each_safe (pos, tpos, ··· 1617 1618 * Adds a qhash and a child listen node for every IPv6 address 1618 1619 * on the adapter and adds the associated qhash filter 1619 1620 */ 1620 - static enum irdma_status_code 1621 - irdma_add_mqh_6(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, 1622 - struct irdma_cm_listener *cm_parent_listen_node) 1621 + static int irdma_add_mqh_6(struct irdma_device *iwdev, 1622 + struct irdma_cm_info *cm_info, 1623 + struct irdma_cm_listener *cm_parent_listen_node) 1623 1624 { 1624 1625 struct net_device *ip_dev; 1625 1626 struct inet6_dev *idev; 1626 1627 struct inet6_ifaddr *ifp, *tmp; 1627 - enum irdma_status_code ret = 0; 1628 1628 struct irdma_cm_listener *child_listen_node; 1629 1629 unsigned long flags; 1630 + int ret = 0; 1630 1631 1631 1632 rtnl_lock(); 1632 1633 for_each_netdev(&init_net, ip_dev) { ··· 1652 1653 child_listen_node); 1653 1654 if (!child_listen_node) { 1654 1655 ibdev_dbg(&iwdev->ibdev, "CM: listener memory allocation\n"); 1655 - ret = IRDMA_ERR_NO_MEMORY; 1656 + ret = -ENOMEM; 1656 1657 goto exit; 1657 1658 } 1658 1659 ··· 1699 1700 * Adds a qhash and a child listen node for every IPv4 address 1700 1701 * on the adapter and adds the associated qhash filter 1701 1702 */ 1702 - static enum irdma_status_code 1703 - irdma_add_mqh_4(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, 1704 - struct irdma_cm_listener *cm_parent_listen_node) 1703 + static int irdma_add_mqh_4(struct irdma_device *iwdev, 1704 + struct irdma_cm_info *cm_info, 1705 + struct irdma_cm_listener *cm_parent_listen_node) 1705 1706 { 1706 1707 struct net_device *ip_dev; 1707 1708 struct in_device *idev; 1708 1709 struct irdma_cm_listener *child_listen_node; 1709 - enum irdma_status_code ret = 0; 1710 1710 unsigned long flags; 1711 1711 const struct in_ifaddr *ifa; 1712 + int ret = 0; 1712 1713 1713 1714 rtnl_lock(); 1714 1715 for_each_netdev(&init_net, ip_dev) { ··· 1733 1734 if (!child_listen_node) { 1734 1735 ibdev_dbg(&iwdev->ibdev, "CM: listener memory allocation\n"); 1735 1736 in_dev_put(idev); 1736 - ret = IRDMA_ERR_NO_MEMORY; 1737 + ret = -ENOMEM; 1737 1738 goto exit; 1738 1739 } 1739 1740 ··· 1780 1781 * @cm_info: CM info for parent listen node 1781 1782 * @cm_listen_node: The parent listen node 1782 1783 */ 1783 - static enum irdma_status_code 1784 - irdma_add_mqh(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, 1785 - struct irdma_cm_listener *cm_listen_node) 1784 + static int irdma_add_mqh(struct irdma_device *iwdev, 1785 + struct irdma_cm_info *cm_info, 1786 + struct irdma_cm_listener *cm_listen_node) 1786 1787 { 1787 1788 if (cm_info->ipv4) 1788 1789 return irdma_add_mqh_4(iwdev, cm_info, cm_listen_node); ··· 2199 2200 /* set our node specific transport info */ 2200 2201 cm_node->ipv4 = cm_info->ipv4; 2201 2202 cm_node->vlan_id = cm_info->vlan_id; 2202 - if (cm_node->vlan_id >= VLAN_N_VID && iwdev->dcb) 2203 + if (cm_node->vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode) 2203 2204 cm_node->vlan_id = 0; 2204 2205 cm_node->tos = cm_info->tos; 2205 2206 cm_node->user_pri = cm_info->user_pri; ··· 2208 2209 ibdev_warn(&iwdev->ibdev, 2209 2210 "application TOS[%d] and remote client TOS[%d] mismatch\n", 2210 2211 listener->tos, cm_info->tos); 2211 - cm_node->tos = max(listener->tos, cm_info->tos); 2212 - cm_node->user_pri = rt_tos2priority(cm_node->tos); 2212 + if (iwdev->vsi.dscp_mode) { 2213 + cm_node->user_pri = listener->user_pri; 2214 + } else { 2215 + cm_node->tos = max(listener->tos, cm_info->tos); 2216 + cm_node->user_pri = rt_tos2priority(cm_node->tos); 2217 + } 2213 2218 ibdev_dbg(&iwdev->ibdev, 2214 2219 "DCB: listener: TOS:[%d] UP:[%d]\n", cm_node->tos, 2215 2220 cm_node->user_pri); ··· 3204 3201 * @iwdev: iwarp device structure 3205 3202 * @rdma_ver: HW version 3206 3203 */ 3207 - enum irdma_status_code irdma_setup_cm_core(struct irdma_device *iwdev, 3208 - u8 rdma_ver) 3204 + int irdma_setup_cm_core(struct irdma_device *iwdev, u8 rdma_ver) 3209 3205 { 3210 3206 struct irdma_cm_core *cm_core = &iwdev->cm_core; 3211 3207 ··· 3214 3212 /* Handles CM event work items send to Iwarp core */ 3215 3213 cm_core->event_wq = alloc_ordered_workqueue("iwarp-event-wq", 0); 3216 3214 if (!cm_core->event_wq) 3217 - return IRDMA_ERR_NO_MEMORY; 3215 + return -ENOMEM; 3218 3216 3219 3217 INIT_LIST_HEAD(&cm_core->listen_list); 3220 3218 ··· 3837 3835 cm_info.cm_id = cm_id; 3838 3836 cm_info.qh_qpid = iwdev->vsi.ilq->qp_id; 3839 3837 cm_info.tos = cm_id->tos; 3840 - cm_info.user_pri = rt_tos2priority(cm_id->tos); 3838 + if (iwdev->vsi.dscp_mode) 3839 + cm_info.user_pri = 3840 + iwqp->sc_qp.vsi->dscp_map[irdma_tos2dscp(cm_info.tos)]; 3841 + else 3842 + cm_info.user_pri = rt_tos2priority(cm_id->tos); 3841 3843 3842 3844 if (iwqp->sc_qp.dev->ws_add(iwqp->sc_qp.vsi, cm_info.user_pri)) 3843 3845 return -ENOMEM; ··· 3921 3915 struct irdma_device *iwdev; 3922 3916 struct irdma_cm_listener *cm_listen_node; 3923 3917 struct irdma_cm_info cm_info = {}; 3924 - enum irdma_status_code err; 3925 3918 struct sockaddr_in *laddr; 3926 3919 struct sockaddr_in6 *laddr6; 3927 3920 bool wildcard = false; 3921 + int err; 3928 3922 3929 3923 iwdev = to_iwdev(cm_id->device); 3930 3924 if (!iwdev) ··· 3965 3959 } 3966 3960 } 3967 3961 3968 - if (cm_info.vlan_id >= VLAN_N_VID && iwdev->dcb) 3962 + if (cm_info.vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode) 3969 3963 cm_info.vlan_id = 0; 3970 3964 cm_info.backlog = backlog; 3971 3965 cm_info.cm_id = cm_id; ··· 3983 3977 cm_id->provider_data = cm_listen_node; 3984 3978 3985 3979 cm_listen_node->tos = cm_id->tos; 3986 - cm_listen_node->user_pri = rt_tos2priority(cm_id->tos); 3980 + if (iwdev->vsi.dscp_mode) 3981 + cm_listen_node->user_pri = 3982 + iwdev->vsi.dscp_map[irdma_tos2dscp(cm_id->tos)]; 3983 + else 3984 + cm_listen_node->user_pri = rt_tos2priority(cm_id->tos); 3987 3985 cm_info.user_pri = cm_listen_node->user_pri; 3988 3986 if (!cm_listen_node->reused_node) { 3989 3987 if (wildcard) { ··· 4335 4325 struct list_head *child_listen_list = &parent_listen_node->child_listen_list; 4336 4326 struct irdma_cm_listener *child_listen_node; 4337 4327 struct list_head *pos, *tpos; 4338 - enum irdma_status_code err; 4339 4328 bool node_allocated = false; 4340 4329 enum irdma_quad_hash_manage_type op = ifup ? 4341 4330 IRDMA_QHASH_MANAGE_TYPE_ADD : 4342 4331 IRDMA_QHASH_MANAGE_TYPE_DELETE; 4332 + int err; 4343 4333 4344 4334 list_for_each_safe (pos, tpos, child_listen_list) { 4345 4335 child_listen_node = list_entry(pos, struct irdma_cm_listener,
+7
drivers/infiniband/hw/irdma/cm.h
··· 384 384 struct irdma_puda_buf *sqbuf, 385 385 enum irdma_timer_type type, int send_retrans, 386 386 int close_when_complete); 387 + 388 + static inline u8 irdma_tos2dscp(u8 tos) 389 + { 390 + #define IRDMA_DSCP_VAL GENMASK(7, 2) 391 + return (u8)FIELD_GET(IRDMA_DSCP_VAL, tos); 392 + } 393 + 387 394 int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); 388 395 int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len); 389 396 int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
+287 -315
drivers/infiniband/hw/irdma/ctrl.c
··· 3 3 #include <linux/etherdevice.h> 4 4 5 5 #include "osdep.h" 6 - #include "status.h" 7 6 #include "hmc.h" 8 7 #include "defs.h" 9 8 #include "type.h" ··· 69 70 } 70 71 } 71 72 73 + static void irdma_set_qos_info(struct irdma_sc_vsi *vsi, 74 + struct irdma_l2params *l2p) 75 + { 76 + u8 i; 77 + 78 + vsi->qos_rel_bw = l2p->vsi_rel_bw; 79 + vsi->qos_prio_type = l2p->vsi_prio_type; 80 + vsi->dscp_mode = l2p->dscp_mode; 81 + if (l2p->dscp_mode) { 82 + memcpy(vsi->dscp_map, l2p->dscp_map, sizeof(vsi->dscp_map)); 83 + for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) 84 + l2p->up2tc[i] = i; 85 + } 86 + for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) { 87 + if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) 88 + vsi->qos[i].qs_handle = l2p->qs_handle_list[i]; 89 + vsi->qos[i].traffic_class = l2p->up2tc[i]; 90 + vsi->qos[i].rel_bw = 91 + l2p->tc_info[vsi->qos[i].traffic_class].rel_bw; 92 + vsi->qos[i].prio_type = 93 + l2p->tc_info[vsi->qos[i].traffic_class].prio_type; 94 + vsi->qos[i].valid = false; 95 + } 96 + } 97 + 72 98 /** 73 99 * irdma_change_l2params - given the new l2 parameters, change all qp 74 100 * @vsi: RDMA VSI pointer ··· 112 88 return; 113 89 114 90 vsi->tc_change_pending = false; 91 + irdma_set_qos_info(vsi, l2params); 115 92 irdma_sc_suspend_resume_qps(vsi, IRDMA_OP_RESUME); 116 93 } 117 94 ··· 179 154 * @scratch: u64 saved to be used during cqp completion 180 155 * @post_sq: flag for cqp db to ring 181 156 */ 182 - static enum irdma_status_code 183 - irdma_sc_add_arp_cache_entry(struct irdma_sc_cqp *cqp, 184 - struct irdma_add_arp_cache_entry_info *info, 185 - u64 scratch, bool post_sq) 157 + static int irdma_sc_add_arp_cache_entry(struct irdma_sc_cqp *cqp, 158 + struct irdma_add_arp_cache_entry_info *info, 159 + u64 scratch, bool post_sq) 186 160 { 187 161 __le64 *wqe; 188 162 u64 hdr; 189 163 190 164 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 191 165 if (!wqe) 192 - return IRDMA_ERR_RING_FULL; 166 + return -ENOMEM; 193 167 set_64bit_val(wqe, 8, info->reach_max); 194 168 set_64bit_val(wqe, 16, ether_addr_to_u64(info->mac_addr)); 195 169 ··· 216 192 * @arp_index: arp index to delete arp entry 217 193 * @post_sq: flag for cqp db to ring 218 194 */ 219 - static enum irdma_status_code 220 - irdma_sc_del_arp_cache_entry(struct irdma_sc_cqp *cqp, u64 scratch, 221 - u16 arp_index, bool post_sq) 195 + static int irdma_sc_del_arp_cache_entry(struct irdma_sc_cqp *cqp, u64 scratch, 196 + u16 arp_index, bool post_sq) 222 197 { 223 198 __le64 *wqe; 224 199 u64 hdr; 225 200 226 201 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 227 202 if (!wqe) 228 - return IRDMA_ERR_RING_FULL; 203 + return -ENOMEM; 229 204 230 205 hdr = arp_index | 231 206 FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_MANAGE_ARP) | ··· 249 226 * @scratch: u64 saved to be used during cqp completion 250 227 * @post_sq: flag for cqp db to ring 251 228 */ 252 - static enum irdma_status_code 253 - irdma_sc_manage_apbvt_entry(struct irdma_sc_cqp *cqp, 254 - struct irdma_apbvt_info *info, u64 scratch, 255 - bool post_sq) 229 + static int irdma_sc_manage_apbvt_entry(struct irdma_sc_cqp *cqp, 230 + struct irdma_apbvt_info *info, 231 + u64 scratch, bool post_sq) 256 232 { 257 233 __le64 *wqe; 258 234 u64 hdr; 259 235 260 236 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 261 237 if (!wqe) 262 - return IRDMA_ERR_RING_FULL; 238 + return -ENOMEM; 263 239 264 240 set_64bit_val(wqe, 16, info->port); 265 241 ··· 296 274 * quad hash entry in the hardware will point to iwarp's qp 297 275 * number and requires no calls from the driver. 298 276 */ 299 - static enum irdma_status_code 277 + static int 300 278 irdma_sc_manage_qhash_table_entry(struct irdma_sc_cqp *cqp, 301 279 struct irdma_qhash_table_info *info, 302 280 u64 scratch, bool post_sq) ··· 309 287 310 288 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 311 289 if (!wqe) 312 - return IRDMA_ERR_RING_FULL; 290 + return -ENOMEM; 313 291 314 292 set_64bit_val(wqe, 0, ether_addr_to_u64(info->mac_addr)); 315 293 ··· 372 350 * @qp: sc qp 373 351 * @info: initialization qp info 374 352 */ 375 - enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, 376 - struct irdma_qp_init_info *info) 353 + int irdma_sc_qp_init(struct irdma_sc_qp *qp, struct irdma_qp_init_info *info) 377 354 { 378 - enum irdma_status_code ret_code; 355 + int ret_code; 379 356 u32 pble_obj_cnt; 380 357 u16 wqe_size; 381 358 ··· 382 361 info->pd->dev->hw_attrs.uk_attrs.max_hw_wq_frags || 383 362 info->qp_uk_init_info.max_rq_frag_cnt > 384 363 info->pd->dev->hw_attrs.uk_attrs.max_hw_wq_frags) 385 - return IRDMA_ERR_INVALID_FRAG_COUNT; 364 + return -EINVAL; 386 365 387 366 qp->dev = info->pd->dev; 388 367 qp->vsi = info->vsi; ··· 405 384 406 385 if ((info->virtual_map && info->sq_pa >= pble_obj_cnt) || 407 386 (info->virtual_map && info->rq_pa >= pble_obj_cnt)) 408 - return IRDMA_ERR_INVALID_PBLE_INDEX; 387 + return -EINVAL; 409 388 410 389 qp->llp_stream_handle = (void *)(-1); 411 390 qp->hw_sq_size = irdma_get_encoded_wqe_size(qp->qp_uk.sq_ring.size, ··· 445 424 * @scratch: u64 saved to be used during cqp completion 446 425 * @post_sq: flag for cqp db to ring 447 426 */ 448 - enum irdma_status_code irdma_sc_qp_create(struct irdma_sc_qp *qp, struct irdma_create_qp_info *info, 449 - u64 scratch, bool post_sq) 427 + int irdma_sc_qp_create(struct irdma_sc_qp *qp, struct irdma_create_qp_info *info, 428 + u64 scratch, bool post_sq) 450 429 { 451 430 struct irdma_sc_cqp *cqp; 452 431 __le64 *wqe; ··· 454 433 455 434 cqp = qp->dev->cqp; 456 435 if (qp->qp_uk.qp_id < cqp->dev->hw_attrs.min_hw_qp_id || 457 - qp->qp_uk.qp_id > (cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_QP].max_cnt - 1)) 458 - return IRDMA_ERR_INVALID_QP_ID; 436 + qp->qp_uk.qp_id >= cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_QP].max_cnt) 437 + return -EINVAL; 459 438 460 439 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 461 440 if (!wqe) 462 - return IRDMA_ERR_RING_FULL; 441 + return -ENOMEM; 463 442 464 443 set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); 465 444 set_64bit_val(wqe, 40, qp->shadow_area_pa); ··· 496 475 * @scratch: u64 saved to be used during cqp completion 497 476 * @post_sq: flag for cqp db to ring 498 477 */ 499 - enum irdma_status_code irdma_sc_qp_modify(struct irdma_sc_qp *qp, 500 - struct irdma_modify_qp_info *info, 501 - u64 scratch, bool post_sq) 478 + int irdma_sc_qp_modify(struct irdma_sc_qp *qp, struct irdma_modify_qp_info *info, 479 + u64 scratch, bool post_sq) 502 480 { 503 481 __le64 *wqe; 504 482 struct irdma_sc_cqp *cqp; ··· 508 488 cqp = qp->dev->cqp; 509 489 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 510 490 if (!wqe) 511 - return IRDMA_ERR_RING_FULL; 491 + return -ENOMEM; 512 492 513 493 if (info->next_iwarp_state == IRDMA_QP_STATE_TERMINATE) { 514 494 if (info->dont_send_fin) ··· 566 546 * @ignore_mw_bnd: memory window bind flag 567 547 * @post_sq: flag for cqp db to ring 568 548 */ 569 - enum irdma_status_code irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, 570 - bool remove_hash_idx, bool ignore_mw_bnd, 571 - bool post_sq) 549 + int irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, 550 + bool remove_hash_idx, bool ignore_mw_bnd, bool post_sq) 572 551 { 573 552 __le64 *wqe; 574 553 struct irdma_sc_cqp *cqp; ··· 576 557 cqp = qp->dev->cqp; 577 558 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 578 559 if (!wqe) 579 - return IRDMA_ERR_RING_FULL; 560 + return -ENOMEM; 580 561 581 562 set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); 582 563 set_64bit_val(wqe, 40, qp->shadow_area_pa); ··· 758 739 * @scratch: u64 saved to be used during cqp completion 759 740 * @post_sq: flag for cqp db to ring 760 741 */ 761 - static enum irdma_status_code 762 - irdma_sc_alloc_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, 763 - bool post_sq) 742 + static int irdma_sc_alloc_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, 743 + bool post_sq) 764 744 { 765 745 __le64 *wqe; 766 746 u64 hdr; 767 747 768 748 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 769 749 if (!wqe) 770 - return IRDMA_ERR_RING_FULL; 750 + return -ENOMEM; 771 751 772 752 hdr = FIELD_PREP(IRDMA_CQPSQ_OPCODE, 773 753 IRDMA_CQP_OP_ALLOCATE_LOC_MAC_TABLE_ENTRY) | ··· 792 774 * @scratch: u64 saved to be used during cqp completion 793 775 * @post_sq: flag for cqp db to ring 794 776 */ 795 - static enum irdma_status_code 796 - irdma_sc_add_local_mac_entry(struct irdma_sc_cqp *cqp, 797 - struct irdma_local_mac_entry_info *info, 798 - u64 scratch, bool post_sq) 777 + static int irdma_sc_add_local_mac_entry(struct irdma_sc_cqp *cqp, 778 + struct irdma_local_mac_entry_info *info, 779 + u64 scratch, bool post_sq) 799 780 { 800 781 __le64 *wqe; 801 782 u64 header; 802 783 803 784 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 804 785 if (!wqe) 805 - return IRDMA_ERR_RING_FULL; 786 + return -ENOMEM; 806 787 807 788 set_64bit_val(wqe, 32, ether_addr_to_u64(info->mac_addr)); 808 789 ··· 830 813 * @ignore_ref_count: to force mac adde delete 831 814 * @post_sq: flag for cqp db to ring 832 815 */ 833 - static enum irdma_status_code 834 - irdma_sc_del_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, 835 - u16 entry_idx, u8 ignore_ref_count, bool post_sq) 816 + static int irdma_sc_del_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, 817 + u16 entry_idx, u8 ignore_ref_count, 818 + bool post_sq) 836 819 { 837 820 __le64 *wqe; 838 821 u64 header; 839 822 840 823 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 841 824 if (!wqe) 842 - return IRDMA_ERR_RING_FULL; 825 + return -ENOMEM; 843 826 header = FIELD_PREP(IRDMA_CQPSQ_MLM_TABLEIDX, entry_idx) | 844 827 FIELD_PREP(IRDMA_CQPSQ_OPCODE, 845 828 IRDMA_CQP_OP_MANAGE_LOC_MAC_TABLE) | ··· 1052 1035 * @scratch: u64 saved to be used during cqp completion 1053 1036 * @post_sq: flag for cqp db to ring 1054 1037 */ 1055 - static enum irdma_status_code 1056 - irdma_sc_alloc_stag(struct irdma_sc_dev *dev, 1057 - struct irdma_allocate_stag_info *info, u64 scratch, 1058 - bool post_sq) 1038 + static int irdma_sc_alloc_stag(struct irdma_sc_dev *dev, 1039 + struct irdma_allocate_stag_info *info, 1040 + u64 scratch, bool post_sq) 1059 1041 { 1060 1042 __le64 *wqe; 1061 1043 struct irdma_sc_cqp *cqp; ··· 1071 1055 cqp = dev->cqp; 1072 1056 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 1073 1057 if (!wqe) 1074 - return IRDMA_ERR_RING_FULL; 1058 + return -ENOMEM; 1075 1059 1076 1060 set_64bit_val(wqe, 8, 1077 1061 FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID) | ··· 1113 1097 * @scratch: u64 saved to be used during cqp completion 1114 1098 * @post_sq: flag for cqp db to ring 1115 1099 */ 1116 - static enum irdma_status_code 1117 - irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, 1118 - struct irdma_reg_ns_stag_info *info, u64 scratch, 1119 - bool post_sq) 1100 + static int irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, 1101 + struct irdma_reg_ns_stag_info *info, 1102 + u64 scratch, bool post_sq) 1120 1103 { 1121 1104 __le64 *wqe; 1122 1105 u64 fbo; ··· 1133 1118 else if (info->page_size == 0x1000) 1134 1119 page_size = IRDMA_PAGE_SIZE_4K; 1135 1120 else 1136 - return IRDMA_ERR_PARAM; 1121 + return -EINVAL; 1137 1122 1138 1123 if (info->access_rights & (IRDMA_ACCESS_FLAGS_REMOTEREAD_ONLY | 1139 1124 IRDMA_ACCESS_FLAGS_REMOTEWRITE_ONLY)) ··· 1143 1128 1144 1129 pble_obj_cnt = dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; 1145 1130 if (info->chunk_size && info->first_pm_pbl_index >= pble_obj_cnt) 1146 - return IRDMA_ERR_INVALID_PBLE_INDEX; 1131 + return -EINVAL; 1147 1132 1148 1133 cqp = dev->cqp; 1149 1134 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 1150 1135 if (!wqe) 1151 - return IRDMA_ERR_RING_FULL; 1136 + return -ENOMEM; 1152 1137 fbo = info->va & (info->page_size - 1); 1153 1138 1154 1139 set_64bit_val(wqe, 0, ··· 1201 1186 * @scratch: u64 saved to be used during cqp completion 1202 1187 * @post_sq: flag for cqp db to ring 1203 1188 */ 1204 - static enum irdma_status_code 1205 - irdma_sc_dealloc_stag(struct irdma_sc_dev *dev, 1206 - struct irdma_dealloc_stag_info *info, u64 scratch, 1207 - bool post_sq) 1189 + static int irdma_sc_dealloc_stag(struct irdma_sc_dev *dev, 1190 + struct irdma_dealloc_stag_info *info, 1191 + u64 scratch, bool post_sq) 1208 1192 { 1209 1193 u64 hdr; 1210 1194 __le64 *wqe; ··· 1212 1198 cqp = dev->cqp; 1213 1199 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 1214 1200 if (!wqe) 1215 - return IRDMA_ERR_RING_FULL; 1201 + return -ENOMEM; 1216 1202 1217 1203 set_64bit_val(wqe, 8, 1218 1204 FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID)); ··· 1241 1227 * @scratch: u64 saved to be used during cqp completion 1242 1228 * @post_sq: flag for cqp db to ring 1243 1229 */ 1244 - static enum irdma_status_code 1245 - irdma_sc_mw_alloc(struct irdma_sc_dev *dev, struct irdma_mw_alloc_info *info, 1246 - u64 scratch, bool post_sq) 1230 + static int irdma_sc_mw_alloc(struct irdma_sc_dev *dev, 1231 + struct irdma_mw_alloc_info *info, u64 scratch, 1232 + bool post_sq) 1247 1233 { 1248 1234 u64 hdr; 1249 1235 struct irdma_sc_cqp *cqp; ··· 1252 1238 cqp = dev->cqp; 1253 1239 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 1254 1240 if (!wqe) 1255 - return IRDMA_ERR_RING_FULL; 1241 + return -ENOMEM; 1256 1242 1257 1243 set_64bit_val(wqe, 8, 1258 1244 FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID)); ··· 1282 1268 * @info: fast mr info 1283 1269 * @post_sq: flag for cqp db to ring 1284 1270 */ 1285 - enum irdma_status_code 1286 - irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, 1287 - struct irdma_fast_reg_stag_info *info, bool post_sq) 1271 + int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, 1272 + struct irdma_fast_reg_stag_info *info, 1273 + bool post_sq) 1288 1274 { 1289 1275 u64 temp, hdr; 1290 1276 __le64 *wqe; ··· 1306 1292 wqe = irdma_qp_get_next_send_wqe(&qp->qp_uk, &wqe_idx, 1307 1293 IRDMA_QP_WQE_MIN_QUANTA, 0, &sq_info); 1308 1294 if (!wqe) 1309 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 1295 + return -ENOMEM; 1310 1296 1311 1297 irdma_clr_wqes(&qp->qp_uk, wqe_idx); 1312 1298 ··· 1835 1821 } 1836 1822 } 1837 1823 1838 - static enum irdma_status_code irdma_null_ws_add(struct irdma_sc_vsi *vsi, 1839 - u8 user_pri) 1824 + static int irdma_null_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) 1840 1825 { 1841 1826 return 0; 1842 1827 } ··· 1858 1845 void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, 1859 1846 struct irdma_vsi_init_info *info) 1860 1847 { 1861 - struct irdma_l2params *l2p; 1862 1848 int i; 1863 1849 1864 1850 vsi->dev = info->dev; ··· 1870 1858 if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) 1871 1859 vsi->fcn_id = info->dev->hmc_fn_id; 1872 1860 1873 - l2p = info->params; 1874 - vsi->qos_rel_bw = l2p->vsi_rel_bw; 1875 - vsi->qos_prio_type = l2p->vsi_prio_type; 1861 + irdma_set_qos_info(vsi, info->params); 1876 1862 for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) { 1877 - if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) 1878 - vsi->qos[i].qs_handle = l2p->qs_handle_list[i]; 1879 - vsi->qos[i].traffic_class = info->params->up2tc[i]; 1880 - vsi->qos[i].rel_bw = 1881 - l2p->tc_info[vsi->qos[i].traffic_class].rel_bw; 1882 - vsi->qos[i].prio_type = 1883 - l2p->tc_info[vsi->qos[i].traffic_class].prio_type; 1884 - vsi->qos[i].valid = false; 1885 1863 mutex_init(&vsi->qos[i].qos_mutex); 1886 1864 INIT_LIST_HEAD(&vsi->qos[i].qplist); 1887 1865 } ··· 1920 1918 * @vsi: pointer to the vsi structure 1921 1919 * @info: The info structure used for initialization 1922 1920 */ 1923 - enum irdma_status_code irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, 1924 - struct irdma_vsi_stats_info *info) 1921 + int irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, 1922 + struct irdma_vsi_stats_info *info) 1925 1923 { 1926 1924 u8 fcn_id = info->fcn_id; 1927 1925 struct irdma_dma_mem *stats_buff_mem; ··· 1936 1934 &stats_buff_mem->pa, 1937 1935 GFP_KERNEL); 1938 1936 if (!stats_buff_mem->va) 1939 - return IRDMA_ERR_NO_MEMORY; 1937 + return -ENOMEM; 1940 1938 1941 1939 vsi->pestat->gather_info.gather_stats_va = stats_buff_mem->va; 1942 1940 vsi->pestat->gather_info.last_gather_stats_va = ··· 1963 1961 stats_buff_mem->va, stats_buff_mem->pa); 1964 1962 stats_buff_mem->va = NULL; 1965 1963 1966 - return IRDMA_ERR_CQP_COMPL_ERROR; 1964 + return -EIO; 1967 1965 } 1968 1966 1969 1967 /** ··· 2025 2023 * @info: gather stats info structure 2026 2024 * @scratch: u64 saved to be used during cqp completion 2027 2025 */ 2028 - static enum irdma_status_code 2029 - irdma_sc_gather_stats(struct irdma_sc_cqp *cqp, 2030 - struct irdma_stats_gather_info *info, u64 scratch) 2026 + static int irdma_sc_gather_stats(struct irdma_sc_cqp *cqp, 2027 + struct irdma_stats_gather_info *info, 2028 + u64 scratch) 2031 2029 { 2032 2030 __le64 *wqe; 2033 2031 u64 temp; 2034 2032 2035 2033 if (info->stats_buff_mem.size < IRDMA_GATHER_STATS_BUF_SIZE) 2036 - return IRDMA_ERR_BUF_TOO_SHORT; 2034 + return -ENOMEM; 2037 2035 2038 2036 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2039 2037 if (!wqe) 2040 - return IRDMA_ERR_RING_FULL; 2038 + return -ENOMEM; 2041 2039 2042 2040 set_64bit_val(wqe, 40, 2043 2041 FIELD_PREP(IRDMA_CQPSQ_STATS_HMC_FCN_INDEX, info->hmc_fcn_index)); ··· 2072 2070 * @alloc: alloc vs. delete flag 2073 2071 * @scratch: u64 saved to be used during cqp completion 2074 2072 */ 2075 - static enum irdma_status_code 2076 - irdma_sc_manage_stats_inst(struct irdma_sc_cqp *cqp, 2077 - struct irdma_stats_inst_info *info, bool alloc, 2078 - u64 scratch) 2073 + static int irdma_sc_manage_stats_inst(struct irdma_sc_cqp *cqp, 2074 + struct irdma_stats_inst_info *info, 2075 + bool alloc, u64 scratch) 2079 2076 { 2080 2077 __le64 *wqe; 2081 2078 u64 temp; 2082 2079 2083 2080 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2084 2081 if (!wqe) 2085 - return IRDMA_ERR_RING_FULL; 2082 + return -ENOMEM; 2086 2083 2087 2084 set_64bit_val(wqe, 40, 2088 2085 FIELD_PREP(IRDMA_CQPSQ_STATS_HMC_FCN_INDEX, info->hmc_fn_id)); ··· 2109 2108 * @info: User priority map info 2110 2109 * @scratch: u64 saved to be used during cqp completion 2111 2110 */ 2112 - static enum irdma_status_code irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, 2113 - struct irdma_up_info *info, 2114 - u64 scratch) 2111 + static int irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, 2112 + struct irdma_up_info *info, u64 scratch) 2115 2113 { 2116 2114 __le64 *wqe; 2117 2115 u64 temp = 0; ··· 2118 2118 2119 2119 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2120 2120 if (!wqe) 2121 - return IRDMA_ERR_RING_FULL; 2121 + return -ENOMEM; 2122 2122 2123 2123 for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) 2124 2124 temp |= (u64)info->map[i] << (i * 8); ··· 2151 2151 * @node_op: 0 for add 1 for modify, 2 for delete 2152 2152 * @scratch: u64 saved to be used during cqp completion 2153 2153 */ 2154 - static enum irdma_status_code 2155 - irdma_sc_manage_ws_node(struct irdma_sc_cqp *cqp, 2156 - struct irdma_ws_node_info *info, 2157 - enum irdma_ws_node_op node_op, u64 scratch) 2154 + static int irdma_sc_manage_ws_node(struct irdma_sc_cqp *cqp, 2155 + struct irdma_ws_node_info *info, 2156 + enum irdma_ws_node_op node_op, u64 scratch) 2158 2157 { 2159 2158 __le64 *wqe; 2160 2159 u64 temp = 0; 2161 2160 2162 2161 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2163 2162 if (!wqe) 2164 - return IRDMA_ERR_RING_FULL; 2163 + return -ENOMEM; 2165 2164 2166 2165 set_64bit_val(wqe, 32, 2167 2166 FIELD_PREP(IRDMA_CQPSQ_WS_VSI, info->vsi) | ··· 2193 2194 * @scratch: u64 saved to be used during cqp completion 2194 2195 * @post_sq: flag for cqp db to ring 2195 2196 */ 2196 - enum irdma_status_code irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, 2197 - struct irdma_qp_flush_info *info, 2198 - u64 scratch, bool post_sq) 2197 + int irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, 2198 + struct irdma_qp_flush_info *info, u64 scratch, 2199 + bool post_sq) 2199 2200 { 2200 2201 u64 temp = 0; 2201 2202 __le64 *wqe; ··· 2214 2215 ibdev_dbg(to_ibdev(qp->dev), 2215 2216 "CQP: Additional flush request ignored for qp %x\n", 2216 2217 qp->qp_uk.qp_id); 2217 - return IRDMA_ERR_FLUSHED_Q; 2218 + return -EALREADY; 2218 2219 } 2219 2220 2220 2221 cqp = qp->pd->dev->cqp; 2221 2222 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2222 2223 if (!wqe) 2223 - return IRDMA_ERR_RING_FULL; 2224 + return -ENOMEM; 2224 2225 2225 2226 if (info->userflushcode) { 2226 2227 if (flush_rq) ··· 2267 2268 * @scratch: u64 saved to be used during cqp completion 2268 2269 * @post_sq: flag for cqp db to ring 2269 2270 */ 2270 - static enum irdma_status_code irdma_sc_gen_ae(struct irdma_sc_qp *qp, 2271 - struct irdma_gen_ae_info *info, 2272 - u64 scratch, bool post_sq) 2271 + static int irdma_sc_gen_ae(struct irdma_sc_qp *qp, 2272 + struct irdma_gen_ae_info *info, u64 scratch, 2273 + bool post_sq) 2273 2274 { 2274 2275 u64 temp; 2275 2276 __le64 *wqe; ··· 2279 2280 cqp = qp->pd->dev->cqp; 2280 2281 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2281 2282 if (!wqe) 2282 - return IRDMA_ERR_RING_FULL; 2283 + return -ENOMEM; 2283 2284 2284 2285 temp = info->ae_code | FIELD_PREP(IRDMA_CQPSQ_FWQE_AESOURCE, 2285 2286 info->ae_src); ··· 2307 2308 * @scratch: u64 saved to be used during cqp completion 2308 2309 * @post_sq: flag for cqp db to ring 2309 2310 */ 2310 - static enum irdma_status_code 2311 - irdma_sc_qp_upload_context(struct irdma_sc_dev *dev, 2312 - struct irdma_upload_context_info *info, u64 scratch, 2313 - bool post_sq) 2311 + static int irdma_sc_qp_upload_context(struct irdma_sc_dev *dev, 2312 + struct irdma_upload_context_info *info, 2313 + u64 scratch, bool post_sq) 2314 2314 { 2315 2315 __le64 *wqe; 2316 2316 struct irdma_sc_cqp *cqp; ··· 2318 2320 cqp = dev->cqp; 2319 2321 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2320 2322 if (!wqe) 2321 - return IRDMA_ERR_RING_FULL; 2323 + return -ENOMEM; 2322 2324 2323 2325 set_64bit_val(wqe, 16, info->buf_pa); 2324 2326 ··· 2347 2349 * @scratch: u64 saved to be used during cqp completion 2348 2350 * @post_sq: flag for cqp db to ring 2349 2351 */ 2350 - static enum irdma_status_code 2351 - irdma_sc_manage_push_page(struct irdma_sc_cqp *cqp, 2352 - struct irdma_cqp_manage_push_page_info *info, 2353 - u64 scratch, bool post_sq) 2352 + static int irdma_sc_manage_push_page(struct irdma_sc_cqp *cqp, 2353 + struct irdma_cqp_manage_push_page_info *info, 2354 + u64 scratch, bool post_sq) 2354 2355 { 2355 2356 __le64 *wqe; 2356 2357 u64 hdr; 2357 2358 2358 2359 if (info->free_page && 2359 2360 info->push_idx >= cqp->dev->hw_attrs.max_hw_device_pages) 2360 - return IRDMA_ERR_INVALID_PUSH_PAGE_INDEX; 2361 + return -EINVAL; 2361 2362 2362 2363 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2363 2364 if (!wqe) 2364 - return IRDMA_ERR_RING_FULL; 2365 + return -ENOMEM; 2365 2366 2366 2367 set_64bit_val(wqe, 16, info->qs_handle); 2367 2368 hdr = FIELD_PREP(IRDMA_CQPSQ_MPP_PPIDX, info->push_idx) | ··· 2386 2389 * @qp: sc qp struct 2387 2390 * @scratch: u64 saved to be used during cqp completion 2388 2391 */ 2389 - static enum irdma_status_code irdma_sc_suspend_qp(struct irdma_sc_cqp *cqp, 2390 - struct irdma_sc_qp *qp, 2391 - u64 scratch) 2392 + static int irdma_sc_suspend_qp(struct irdma_sc_cqp *cqp, struct irdma_sc_qp *qp, 2393 + u64 scratch) 2392 2394 { 2393 2395 u64 hdr; 2394 2396 __le64 *wqe; 2395 2397 2396 2398 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2397 2399 if (!wqe) 2398 - return IRDMA_ERR_RING_FULL; 2400 + return -ENOMEM; 2399 2401 2400 2402 hdr = FIELD_PREP(IRDMA_CQPSQ_SUSPENDQP_QPID, qp->qp_uk.qp_id) | 2401 2403 FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_SUSPEND_QP) | ··· 2416 2420 * @qp: sc qp struct 2417 2421 * @scratch: u64 saved to be used during cqp completion 2418 2422 */ 2419 - static enum irdma_status_code irdma_sc_resume_qp(struct irdma_sc_cqp *cqp, 2420 - struct irdma_sc_qp *qp, 2421 - u64 scratch) 2423 + static int irdma_sc_resume_qp(struct irdma_sc_cqp *cqp, struct irdma_sc_qp *qp, 2424 + u64 scratch) 2422 2425 { 2423 2426 u64 hdr; 2424 2427 __le64 *wqe; 2425 2428 2426 2429 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2427 2430 if (!wqe) 2428 - return IRDMA_ERR_RING_FULL; 2431 + return -ENOMEM; 2429 2432 2430 2433 set_64bit_val(wqe, 16, 2431 2434 FIELD_PREP(IRDMA_CQPSQ_RESUMEQP_QSHANDLE, qp->qs_handle)); ··· 2457 2462 * @cq: cq struct 2458 2463 * @info: cq initialization info 2459 2464 */ 2460 - enum irdma_status_code irdma_sc_cq_init(struct irdma_sc_cq *cq, 2461 - struct irdma_cq_init_info *info) 2465 + int irdma_sc_cq_init(struct irdma_sc_cq *cq, struct irdma_cq_init_info *info) 2462 2466 { 2463 2467 u32 pble_obj_cnt; 2464 2468 2465 2469 pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; 2466 2470 if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) 2467 - return IRDMA_ERR_INVALID_PBLE_INDEX; 2471 + return -EINVAL; 2468 2472 2469 2473 cq->cq_pa = info->cq_base_pa; 2470 2474 cq->dev = info->dev; ··· 2494 2500 * @check_overflow: flag for overflow check 2495 2501 * @post_sq: flag for cqp db to ring 2496 2502 */ 2497 - static enum irdma_status_code irdma_sc_cq_create(struct irdma_sc_cq *cq, 2498 - u64 scratch, 2499 - bool check_overflow, 2500 - bool post_sq) 2503 + static int irdma_sc_cq_create(struct irdma_sc_cq *cq, u64 scratch, 2504 + bool check_overflow, bool post_sq) 2501 2505 { 2502 2506 __le64 *wqe; 2503 2507 struct irdma_sc_cqp *cqp; 2504 2508 u64 hdr; 2505 2509 struct irdma_sc_ceq *ceq; 2506 - enum irdma_status_code ret_code = 0; 2510 + int ret_code = 0; 2507 2511 2508 2512 cqp = cq->dev->cqp; 2509 - if (cq->cq_uk.cq_id > (cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].max_cnt - 1)) 2510 - return IRDMA_ERR_INVALID_CQ_ID; 2513 + if (cq->cq_uk.cq_id >= cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].max_cnt) 2514 + return -EINVAL; 2511 2515 2512 - if (cq->ceq_id > (cq->dev->hmc_fpm_misc.max_ceqs - 1)) 2513 - return IRDMA_ERR_INVALID_CEQ_ID; 2516 + if (cq->ceq_id >= cq->dev->hmc_fpm_misc.max_ceqs) 2517 + return -EINVAL; 2514 2518 2515 2519 ceq = cq->dev->ceq[cq->ceq_id]; 2516 2520 if (ceq && ceq->reg_cq) ··· 2521 2529 if (!wqe) { 2522 2530 if (ceq && ceq->reg_cq) 2523 2531 irdma_sc_remove_cq_ctx(ceq, cq); 2524 - return IRDMA_ERR_RING_FULL; 2532 + return -ENOMEM; 2525 2533 } 2526 2534 2527 2535 set_64bit_val(wqe, 0, cq->cq_uk.cq_size); ··· 2567 2575 * @scratch: u64 saved to be used during cqp completion 2568 2576 * @post_sq: flag for cqp db to ring 2569 2577 */ 2570 - enum irdma_status_code irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, 2571 - bool post_sq) 2578 + int irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, bool post_sq) 2572 2579 { 2573 2580 struct irdma_sc_cqp *cqp; 2574 2581 __le64 *wqe; ··· 2577 2586 cqp = cq->dev->cqp; 2578 2587 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2579 2588 if (!wqe) 2580 - return IRDMA_ERR_RING_FULL; 2589 + return -ENOMEM; 2581 2590 2582 2591 ceq = cq->dev->ceq[cq->ceq_id]; 2583 2592 if (ceq && ceq->reg_cq) ··· 2633 2642 * @scratch: u64 saved to be used during cqp completion 2634 2643 * @post_sq: flag to post to sq 2635 2644 */ 2636 - static enum irdma_status_code 2637 - irdma_sc_cq_modify(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *info, 2638 - u64 scratch, bool post_sq) 2645 + static int irdma_sc_cq_modify(struct irdma_sc_cq *cq, 2646 + struct irdma_modify_cq_info *info, u64 scratch, 2647 + bool post_sq) 2639 2648 { 2640 2649 struct irdma_sc_cqp *cqp; 2641 2650 __le64 *wqe; ··· 2645 2654 pble_obj_cnt = cq->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; 2646 2655 if (info->cq_resize && info->virtual_map && 2647 2656 info->first_pm_pbl_idx >= pble_obj_cnt) 2648 - return IRDMA_ERR_INVALID_PBLE_INDEX; 2657 + return -EINVAL; 2649 2658 2650 2659 cqp = cq->dev->cqp; 2651 2660 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 2652 2661 if (!wqe) 2653 - return IRDMA_ERR_RING_FULL; 2662 + return -ENOMEM; 2654 2663 2655 2664 set_64bit_val(wqe, 0, info->cq_size); 2656 2665 set_64bit_val(wqe, 8, (uintptr_t)cq >> 1); ··· 2724 2733 * @tail: wqtail register value 2725 2734 * @count: how many times to try for completion 2726 2735 */ 2727 - static enum irdma_status_code irdma_cqp_poll_registers(struct irdma_sc_cqp *cqp, 2728 - u32 tail, u32 count) 2736 + static int irdma_cqp_poll_registers(struct irdma_sc_cqp *cqp, u32 tail, 2737 + u32 count) 2729 2738 { 2730 2739 u32 i = 0; 2731 2740 u32 newtail, error, val; ··· 2737 2746 ibdev_dbg(to_ibdev(cqp->dev), 2738 2747 "CQP: CQPERRCODES error_code[x%08X]\n", 2739 2748 error); 2740 - return IRDMA_ERR_CQP_COMPL_ERROR; 2749 + return -EIO; 2741 2750 } 2742 2751 if (newtail != tail) { 2743 2752 /* SUCCESS */ ··· 2748 2757 udelay(cqp->dev->hw_attrs.max_sleep_count); 2749 2758 } 2750 2759 2751 - return IRDMA_ERR_TIMEOUT; 2760 + return -ETIMEDOUT; 2752 2761 } 2753 2762 2754 2763 /** ··· 2903 2912 * parses fpm query buffer and copy max_cnt and 2904 2913 * size value of hmc objects in hmc_info 2905 2914 */ 2906 - static enum irdma_status_code 2907 - irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, 2908 - struct irdma_hmc_info *hmc_info, 2909 - struct irdma_hmc_fpm_misc *hmc_fpm_misc) 2915 + static int irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, 2916 + struct irdma_hmc_info *hmc_info, 2917 + struct irdma_hmc_fpm_misc *hmc_fpm_misc) 2910 2918 { 2911 2919 struct irdma_hmc_obj_info *obj_info; 2912 2920 u64 temp; ··· 2944 2954 obj_info[IRDMA_HMC_IW_XFFL].size = 4; 2945 2955 hmc_fpm_misc->xf_block_size = FIELD_GET(IRDMA_QUERY_FPM_XFBLOCKSIZE, temp); 2946 2956 if (!hmc_fpm_misc->xf_block_size) 2947 - return IRDMA_ERR_INVALID_SIZE; 2957 + return -EINVAL; 2948 2958 2949 2959 irdma_sc_decode_fpm_query(buf, 72, obj_info, IRDMA_HMC_IW_Q1); 2950 2960 get_64bit_val(buf, 80, &temp); ··· 2953 2963 2954 2964 hmc_fpm_misc->q1_block_size = FIELD_GET(IRDMA_QUERY_FPM_Q1BLOCKSIZE, temp); 2955 2965 if (!hmc_fpm_misc->q1_block_size) 2956 - return IRDMA_ERR_INVALID_SIZE; 2966 + return -EINVAL; 2957 2967 2958 2968 irdma_sc_decode_fpm_query(buf, 88, obj_info, IRDMA_HMC_IW_TIMER); 2959 2969 ··· 2977 2987 hmc_fpm_misc->rrf_block_size = FIELD_GET(IRDMA_QUERY_FPM_RRFBLOCKSIZE, temp); 2978 2988 if (!hmc_fpm_misc->rrf_block_size && 2979 2989 obj_info[IRDMA_HMC_IW_RRFFL].max_cnt) 2980 - return IRDMA_ERR_INVALID_SIZE; 2990 + return -EINVAL; 2981 2991 2982 2992 irdma_sc_decode_fpm_query(buf, 144, obj_info, IRDMA_HMC_IW_HDR); 2983 2993 irdma_sc_decode_fpm_query(buf, 152, obj_info, IRDMA_HMC_IW_MD); ··· 2989 2999 hmc_fpm_misc->ooiscf_block_size = FIELD_GET(IRDMA_QUERY_FPM_OOISCFBLOCKSIZE, temp); 2990 3000 if (!hmc_fpm_misc->ooiscf_block_size && 2991 3001 obj_info[IRDMA_HMC_IW_OOISCFFL].max_cnt) 2992 - return IRDMA_ERR_INVALID_SIZE; 3002 + return -EINVAL; 2993 3003 2994 3004 return 0; 2995 3005 } ··· 3017 3027 * @ceq: ceq sc structure 3018 3028 * @cq: cq sc structure 3019 3029 */ 3020 - enum irdma_status_code irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, 3021 - struct irdma_sc_cq *cq) 3030 + int irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq) 3022 3031 { 3023 3032 unsigned long flags; 3024 3033 ··· 3025 3036 3026 3037 if (ceq->reg_cq_size == ceq->elem_cnt) { 3027 3038 spin_unlock_irqrestore(&ceq->req_cq_lock, flags); 3028 - return IRDMA_ERR_REG_CQ_FULL; 3039 + return -ENOMEM; 3029 3040 } 3030 3041 3031 3042 ceq->reg_cq[ceq->reg_cq_size++] = cq; ··· 3066 3077 * 3067 3078 * Initializes the object and context buffers for a control Queue Pair. 3068 3079 */ 3069 - enum irdma_status_code irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, 3070 - struct irdma_cqp_init_info *info) 3080 + int irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, 3081 + struct irdma_cqp_init_info *info) 3071 3082 { 3072 3083 u8 hw_sq_size; 3073 3084 3074 3085 if (info->sq_size > IRDMA_CQP_SW_SQSIZE_2048 || 3075 3086 info->sq_size < IRDMA_CQP_SW_SQSIZE_4 || 3076 3087 ((info->sq_size & (info->sq_size - 1)))) 3077 - return IRDMA_ERR_INVALID_SIZE; 3088 + return -EINVAL; 3078 3089 3079 3090 hw_sq_size = irdma_get_encoded_wqe_size(info->sq_size, 3080 3091 IRDMA_QUEUE_TYPE_CQP); ··· 3124 3135 * @maj_err: If error, major err number 3125 3136 * @min_err: If error, minor err number 3126 3137 */ 3127 - enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, 3128 - u16 *min_err) 3138 + int irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, u16 *min_err) 3129 3139 { 3130 3140 u64 temp; 3131 3141 u8 hw_rev; 3132 3142 u32 cnt = 0, p1, p2, val = 0, err_code; 3133 - enum irdma_status_code ret_code; 3143 + int ret_code; 3134 3144 3135 3145 hw_rev = cqp->dev->hw_attrs.uk_attrs.hw_rev; 3136 3146 cqp->sdbuf.size = ALIGN(IRDMA_UPDATE_SD_BUFF_SIZE * cqp->sq_size, ··· 3138 3150 cqp->sdbuf.size, &cqp->sdbuf.pa, 3139 3151 GFP_KERNEL); 3140 3152 if (!cqp->sdbuf.va) 3141 - return IRDMA_ERR_NO_MEMORY; 3153 + return -ENOMEM; 3142 3154 3143 3155 spin_lock_init(&cqp->dev->cqp_lock); 3144 3156 ··· 3193 3205 3194 3206 do { 3195 3207 if (cnt++ > cqp->dev->hw_attrs.max_done_count) { 3196 - ret_code = IRDMA_ERR_TIMEOUT; 3208 + ret_code = -ETIMEDOUT; 3197 3209 goto err; 3198 3210 } 3199 3211 udelay(cqp->dev->hw_attrs.max_sleep_count); ··· 3201 3213 } while (!val); 3202 3214 3203 3215 if (FLD_RS_32(cqp->dev, val, IRDMA_CCQPSTATUS_CCQP_ERR)) { 3204 - ret_code = IRDMA_ERR_DEVICE_NOT_SUPPORTED; 3216 + ret_code = -EOPNOTSUPP; 3205 3217 goto err; 3206 3218 } 3207 3219 ··· 3242 3254 u32 *wqe_idx) 3243 3255 { 3244 3256 __le64 *wqe = NULL; 3245 - enum irdma_status_code ret_code; 3257 + int ret_code; 3246 3258 3247 3259 if (IRDMA_RING_FULL_ERR(cqp->sq_ring)) { 3248 3260 ibdev_dbg(to_ibdev(cqp->dev), ··· 3269 3281 * irdma_sc_cqp_destroy - destroy cqp during close 3270 3282 * @cqp: struct for cqp hw 3271 3283 */ 3272 - enum irdma_status_code irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp) 3284 + int irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp) 3273 3285 { 3274 3286 u32 cnt = 0, val; 3275 - enum irdma_status_code ret_code = 0; 3287 + int ret_code = 0; 3276 3288 3277 3289 writel(0, cqp->dev->hw_regs[IRDMA_CCQPHIGH]); 3278 3290 writel(0, cqp->dev->hw_regs[IRDMA_CCQPLOW]); 3279 3291 do { 3280 3292 if (cnt++ > cqp->dev->hw_attrs.max_done_count) { 3281 - ret_code = IRDMA_ERR_TIMEOUT; 3293 + ret_code = -ETIMEDOUT; 3282 3294 break; 3283 3295 } 3284 3296 udelay(cqp->dev->hw_attrs.max_sleep_count); ··· 3323 3335 * @ccq: ccq sc struct 3324 3336 * @info: completion q entry to return 3325 3337 */ 3326 - enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, 3327 - struct irdma_ccq_cqe_info *info) 3338 + int irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, 3339 + struct irdma_ccq_cqe_info *info) 3328 3340 { 3329 3341 u64 qp_ctx, temp, temp1; 3330 3342 __le64 *cqe; ··· 3332 3344 u32 wqe_idx; 3333 3345 u32 error; 3334 3346 u8 polarity; 3335 - enum irdma_status_code ret_code = 0; 3347 + int ret_code = 0; 3336 3348 3337 3349 if (ccq->cq_uk.avoid_mem_cflct) 3338 3350 cqe = IRDMA_GET_CURRENT_EXTENDED_CQ_ELEM(&ccq->cq_uk); ··· 3342 3354 get_64bit_val(cqe, 24, &temp); 3343 3355 polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, temp); 3344 3356 if (polarity != ccq->cq_uk.polarity) 3345 - return IRDMA_ERR_Q_EMPTY; 3357 + return -ENOENT; 3346 3358 3347 3359 get_64bit_val(cqe, 8, &qp_ctx); 3348 3360 cqp = (struct irdma_sc_cqp *)(unsigned long)qp_ctx; ··· 3389 3401 * @op_code: cqp opcode for completion 3390 3402 * @compl_info: completion q entry to return 3391 3403 */ 3392 - enum irdma_status_code irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 op_code, 3393 - struct irdma_ccq_cqe_info *compl_info) 3404 + int irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 op_code, 3405 + struct irdma_ccq_cqe_info *compl_info) 3394 3406 { 3395 3407 struct irdma_ccq_cqe_info info = {}; 3396 3408 struct irdma_sc_cq *ccq; 3397 - enum irdma_status_code ret_code = 0; 3409 + int ret_code = 0; 3398 3410 u32 cnt = 0; 3399 3411 3400 3412 ccq = cqp->dev->ccq; 3401 3413 while (1) { 3402 3414 if (cnt++ > 100 * cqp->dev->hw_attrs.max_done_count) 3403 - return IRDMA_ERR_TIMEOUT; 3415 + return -ETIMEDOUT; 3404 3416 3405 3417 if (irdma_sc_ccq_get_cqe_info(ccq, &info)) { 3406 3418 udelay(cqp->dev->hw_attrs.max_sleep_count); 3407 3419 continue; 3408 3420 } 3409 3421 if (info.error && info.op_code != IRDMA_CQP_OP_QUERY_STAG) { 3410 - ret_code = IRDMA_ERR_CQP_COMPL_ERROR; 3422 + ret_code = -EIO; 3411 3423 break; 3412 3424 } 3413 3425 /* make sure op code matches*/ ··· 3431 3443 * @info: info for the manage function table operation 3432 3444 * @post_sq: flag for cqp db to ring 3433 3445 */ 3434 - static enum irdma_status_code 3435 - irdma_sc_manage_hmc_pm_func_table(struct irdma_sc_cqp *cqp, 3436 - struct irdma_hmc_fcn_info *info, 3437 - u64 scratch, bool post_sq) 3446 + static int irdma_sc_manage_hmc_pm_func_table(struct irdma_sc_cqp *cqp, 3447 + struct irdma_hmc_fcn_info *info, 3448 + u64 scratch, bool post_sq) 3438 3449 { 3439 3450 __le64 *wqe; 3440 3451 u64 hdr; 3441 3452 3442 3453 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3443 3454 if (!wqe) 3444 - return IRDMA_ERR_RING_FULL; 3455 + return -ENOMEM; 3445 3456 3446 3457 set_64bit_val(wqe, 0, 0); 3447 3458 set_64bit_val(wqe, 8, 0); ··· 3473 3486 * for fpm commit 3474 3487 * @cqp: struct for cqp hw 3475 3488 */ 3476 - static enum irdma_status_code 3477 - irdma_sc_commit_fpm_val_done(struct irdma_sc_cqp *cqp) 3489 + static int irdma_sc_commit_fpm_val_done(struct irdma_sc_cqp *cqp) 3478 3490 { 3479 3491 return irdma_sc_poll_for_cqp_op_done(cqp, IRDMA_CQP_OP_COMMIT_FPM_VAL, 3480 3492 NULL); ··· 3488 3502 * @post_sq: flag for cqp db to ring 3489 3503 * @wait_type: poll ccq or cqp registers for cqp completion 3490 3504 */ 3491 - static enum irdma_status_code 3492 - irdma_sc_commit_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, u8 hmc_fn_id, 3493 - struct irdma_dma_mem *commit_fpm_mem, bool post_sq, 3494 - u8 wait_type) 3505 + static int irdma_sc_commit_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, 3506 + u8 hmc_fn_id, 3507 + struct irdma_dma_mem *commit_fpm_mem, 3508 + bool post_sq, u8 wait_type) 3495 3509 { 3496 3510 __le64 *wqe; 3497 3511 u64 hdr; 3498 3512 u32 tail, val, error; 3499 - enum irdma_status_code ret_code = 0; 3513 + int ret_code = 0; 3500 3514 3501 3515 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3502 3516 if (!wqe) 3503 - return IRDMA_ERR_RING_FULL; 3517 + return -ENOMEM; 3504 3518 3505 3519 set_64bit_val(wqe, 16, hmc_fn_id); 3506 3520 set_64bit_val(wqe, 32, commit_fpm_mem->pa); ··· 3534 3548 * query fpm 3535 3549 * @cqp: struct for cqp hw 3536 3550 */ 3537 - static enum irdma_status_code 3538 - irdma_sc_query_fpm_val_done(struct irdma_sc_cqp *cqp) 3551 + static int irdma_sc_query_fpm_val_done(struct irdma_sc_cqp *cqp) 3539 3552 { 3540 3553 return irdma_sc_poll_for_cqp_op_done(cqp, IRDMA_CQP_OP_QUERY_FPM_VAL, 3541 3554 NULL); ··· 3549 3564 * @post_sq: flag for cqp db to ring 3550 3565 * @wait_type: poll ccq or cqp registers for cqp completion 3551 3566 */ 3552 - static enum irdma_status_code 3553 - irdma_sc_query_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, u8 hmc_fn_id, 3554 - struct irdma_dma_mem *query_fpm_mem, bool post_sq, 3555 - u8 wait_type) 3567 + static int irdma_sc_query_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, 3568 + u8 hmc_fn_id, 3569 + struct irdma_dma_mem *query_fpm_mem, 3570 + bool post_sq, u8 wait_type) 3556 3571 { 3557 3572 __le64 *wqe; 3558 3573 u64 hdr; 3559 3574 u32 tail, val, error; 3560 - enum irdma_status_code ret_code = 0; 3575 + int ret_code = 0; 3561 3576 3562 3577 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3563 3578 if (!wqe) 3564 - return IRDMA_ERR_RING_FULL; 3579 + return -ENOMEM; 3565 3580 3566 3581 set_64bit_val(wqe, 16, hmc_fn_id); 3567 3582 set_64bit_val(wqe, 32, query_fpm_mem->pa); ··· 3593 3608 * @ceq: ceq sc structure 3594 3609 * @info: ceq initialization info 3595 3610 */ 3596 - enum irdma_status_code irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, 3597 - struct irdma_ceq_init_info *info) 3611 + int irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, 3612 + struct irdma_ceq_init_info *info) 3598 3613 { 3599 3614 u32 pble_obj_cnt; 3600 3615 3601 3616 if (info->elem_cnt < info->dev->hw_attrs.min_hw_ceq_size || 3602 3617 info->elem_cnt > info->dev->hw_attrs.max_hw_ceq_size) 3603 - return IRDMA_ERR_INVALID_SIZE; 3618 + return -EINVAL; 3604 3619 3605 - if (info->ceq_id > (info->dev->hmc_fpm_misc.max_ceqs - 1)) 3606 - return IRDMA_ERR_INVALID_CEQ_ID; 3620 + if (info->ceq_id >= info->dev->hmc_fpm_misc.max_ceqs) 3621 + return -EINVAL; 3607 3622 pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; 3608 3623 3609 3624 if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) 3610 - return IRDMA_ERR_INVALID_PBLE_INDEX; 3625 + return -EINVAL; 3611 3626 3612 3627 ceq->size = sizeof(*ceq); 3613 3628 ceq->ceqe_base = (struct irdma_ceqe *)info->ceqe_base; ··· 3640 3655 * @post_sq: flag for cqp db to ring 3641 3656 */ 3642 3657 3643 - static enum irdma_status_code irdma_sc_ceq_create(struct irdma_sc_ceq *ceq, u64 scratch, 3644 - bool post_sq) 3658 + static int irdma_sc_ceq_create(struct irdma_sc_ceq *ceq, u64 scratch, 3659 + bool post_sq) 3645 3660 { 3646 3661 struct irdma_sc_cqp *cqp; 3647 3662 __le64 *wqe; ··· 3650 3665 cqp = ceq->dev->cqp; 3651 3666 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3652 3667 if (!wqe) 3653 - return IRDMA_ERR_RING_FULL; 3668 + return -ENOMEM; 3654 3669 set_64bit_val(wqe, 16, ceq->elem_cnt); 3655 3670 set_64bit_val(wqe, 32, 3656 3671 (ceq->virtual_map ? 0 : ceq->ceq_elem_pa)); ··· 3682 3697 * irdma_sc_cceq_create_done - poll for control ceq wqe to complete 3683 3698 * @ceq: ceq sc structure 3684 3699 */ 3685 - static enum irdma_status_code 3686 - irdma_sc_cceq_create_done(struct irdma_sc_ceq *ceq) 3700 + static int irdma_sc_cceq_create_done(struct irdma_sc_ceq *ceq) 3687 3701 { 3688 3702 struct irdma_sc_cqp *cqp; 3689 3703 ··· 3695 3711 * irdma_sc_cceq_destroy_done - poll for destroy cceq to complete 3696 3712 * @ceq: ceq sc structure 3697 3713 */ 3698 - enum irdma_status_code irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq) 3714 + int irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq) 3699 3715 { 3700 3716 struct irdma_sc_cqp *cqp; 3701 3717 ··· 3714 3730 * @ceq: ceq sc structure 3715 3731 * @scratch: u64 saved to be used during cqp completion 3716 3732 */ 3717 - enum irdma_status_code irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch) 3733 + int irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch) 3718 3734 { 3719 - enum irdma_status_code ret_code; 3735 + int ret_code; 3720 3736 struct irdma_sc_dev *dev = ceq->dev; 3721 3737 3722 3738 dev->ccq->vsi = ceq->vsi; ··· 3739 3755 * @scratch: u64 saved to be used during cqp completion 3740 3756 * @post_sq: flag for cqp db to ring 3741 3757 */ 3742 - enum irdma_status_code irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, 3743 - bool post_sq) 3758 + int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq) 3744 3759 { 3745 3760 struct irdma_sc_cqp *cqp; 3746 3761 __le64 *wqe; ··· 3748 3765 cqp = ceq->dev->cqp; 3749 3766 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3750 3767 if (!wqe) 3751 - return IRDMA_ERR_RING_FULL; 3768 + return -ENOMEM; 3752 3769 3753 3770 set_64bit_val(wqe, 16, ceq->elem_cnt); 3754 3771 set_64bit_val(wqe, 48, ceq->first_pm_pbl_idx); ··· 3867 3884 * @aeq: aeq structure ptr 3868 3885 * @info: aeq initialization info 3869 3886 */ 3870 - enum irdma_status_code irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, 3871 - struct irdma_aeq_init_info *info) 3887 + int irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, 3888 + struct irdma_aeq_init_info *info) 3872 3889 { 3873 3890 u32 pble_obj_cnt; 3874 3891 3875 3892 if (info->elem_cnt < info->dev->hw_attrs.min_hw_aeq_size || 3876 3893 info->elem_cnt > info->dev->hw_attrs.max_hw_aeq_size) 3877 - return IRDMA_ERR_INVALID_SIZE; 3894 + return -EINVAL; 3878 3895 3879 3896 pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; 3880 3897 3881 3898 if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) 3882 - return IRDMA_ERR_INVALID_PBLE_INDEX; 3899 + return -EINVAL; 3883 3900 3884 3901 aeq->size = sizeof(*aeq); 3885 3902 aeq->polarity = 1; ··· 3904 3921 * @scratch: u64 saved to be used during cqp completion 3905 3922 * @post_sq: flag for cqp db to ring 3906 3923 */ 3907 - static enum irdma_status_code irdma_sc_aeq_create(struct irdma_sc_aeq *aeq, 3908 - u64 scratch, bool post_sq) 3924 + static int irdma_sc_aeq_create(struct irdma_sc_aeq *aeq, u64 scratch, 3925 + bool post_sq) 3909 3926 { 3910 3927 __le64 *wqe; 3911 3928 struct irdma_sc_cqp *cqp; ··· 3914 3931 cqp = aeq->dev->cqp; 3915 3932 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3916 3933 if (!wqe) 3917 - return IRDMA_ERR_RING_FULL; 3934 + return -ENOMEM; 3918 3935 set_64bit_val(wqe, 16, aeq->elem_cnt); 3919 3936 set_64bit_val(wqe, 32, 3920 3937 (aeq->virtual_map ? 0 : aeq->aeq_elem_pa)); ··· 3943 3960 * @scratch: u64 saved to be used during cqp completion 3944 3961 * @post_sq: flag for cqp db to ring 3945 3962 */ 3946 - static enum irdma_status_code irdma_sc_aeq_destroy(struct irdma_sc_aeq *aeq, 3947 - u64 scratch, bool post_sq) 3963 + static int irdma_sc_aeq_destroy(struct irdma_sc_aeq *aeq, u64 scratch, 3964 + bool post_sq) 3948 3965 { 3949 3966 __le64 *wqe; 3950 3967 struct irdma_sc_cqp *cqp; ··· 3957 3974 cqp = dev->cqp; 3958 3975 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 3959 3976 if (!wqe) 3960 - return IRDMA_ERR_RING_FULL; 3977 + return -ENOMEM; 3961 3978 set_64bit_val(wqe, 16, aeq->elem_cnt); 3962 3979 set_64bit_val(wqe, 48, aeq->first_pm_pbl_idx); 3963 3980 hdr = FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_DESTROY_AEQ) | ··· 3980 3997 * @aeq: aeq structure ptr 3981 3998 * @info: aeqe info to be returned 3982 3999 */ 3983 - enum irdma_status_code irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, 3984 - struct irdma_aeqe_info *info) 4000 + int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, 4001 + struct irdma_aeqe_info *info) 3985 4002 { 3986 4003 u64 temp, compl_ctx; 3987 4004 __le64 *aeqe; ··· 3995 4012 polarity = (u8)FIELD_GET(IRDMA_AEQE_VALID, temp); 3996 4013 3997 4014 if (aeq->polarity != polarity) 3998 - return IRDMA_ERR_Q_EMPTY; 4015 + return -ENOENT; 3999 4016 4000 4017 print_hex_dump_debug("WQE: AEQ_ENTRY WQE", DUMP_PREFIX_OFFSET, 16, 8, 4001 4018 aeqe, 16, false); ··· 4140 4157 * @cq: sc's cq ctruct 4141 4158 * @info: info for control cq initialization 4142 4159 */ 4143 - enum irdma_status_code irdma_sc_ccq_init(struct irdma_sc_cq *cq, 4144 - struct irdma_ccq_init_info *info) 4160 + int irdma_sc_ccq_init(struct irdma_sc_cq *cq, struct irdma_ccq_init_info *info) 4145 4161 { 4146 4162 u32 pble_obj_cnt; 4147 4163 4148 4164 if (info->num_elem < info->dev->hw_attrs.uk_attrs.min_hw_cq_size || 4149 4165 info->num_elem > info->dev->hw_attrs.uk_attrs.max_hw_cq_size) 4150 - return IRDMA_ERR_INVALID_SIZE; 4166 + return -EINVAL; 4151 4167 4152 - if (info->ceq_id > (info->dev->hmc_fpm_misc.max_ceqs - 1)) 4153 - return IRDMA_ERR_INVALID_CEQ_ID; 4168 + if (info->ceq_id >= info->dev->hmc_fpm_misc.max_ceqs) 4169 + return -EINVAL; 4154 4170 4155 4171 pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; 4156 4172 4157 4173 if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) 4158 - return IRDMA_ERR_INVALID_PBLE_INDEX; 4174 + return -EINVAL; 4159 4175 4160 4176 cq->cq_pa = info->cq_pa; 4161 4177 cq->cq_uk.cq_base = info->cq_base; ··· 4191 4209 * irdma_sc_ccq_create_done - poll cqp for ccq create 4192 4210 * @ccq: ccq sc struct 4193 4211 */ 4194 - static inline enum irdma_status_code irdma_sc_ccq_create_done(struct irdma_sc_cq *ccq) 4212 + static inline int irdma_sc_ccq_create_done(struct irdma_sc_cq *ccq) 4195 4213 { 4196 4214 struct irdma_sc_cqp *cqp; 4197 4215 ··· 4207 4225 * @check_overflow: overlow flag for ccq 4208 4226 * @post_sq: flag for cqp db to ring 4209 4227 */ 4210 - enum irdma_status_code irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, 4211 - bool check_overflow, bool post_sq) 4228 + int irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, 4229 + bool check_overflow, bool post_sq) 4212 4230 { 4213 - enum irdma_status_code ret_code; 4231 + int ret_code; 4214 4232 4215 4233 ret_code = irdma_sc_cq_create(ccq, scratch, check_overflow, post_sq); 4216 4234 if (ret_code) ··· 4232 4250 * @scratch: u64 saved to be used during cqp completion 4233 4251 * @post_sq: flag for cqp db to ring 4234 4252 */ 4235 - enum irdma_status_code irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, 4236 - bool post_sq) 4253 + int irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, bool post_sq) 4237 4254 { 4238 4255 struct irdma_sc_cqp *cqp; 4239 4256 __le64 *wqe; 4240 4257 u64 hdr; 4241 - enum irdma_status_code ret_code = 0; 4258 + int ret_code = 0; 4242 4259 u32 tail, val, error; 4243 4260 4244 4261 cqp = ccq->dev->cqp; 4245 4262 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 4246 4263 if (!wqe) 4247 - return IRDMA_ERR_RING_FULL; 4264 + return -ENOMEM; 4248 4265 4249 4266 set_64bit_val(wqe, 0, ccq->cq_uk.cq_size); 4250 4267 set_64bit_val(wqe, 8, (uintptr_t)ccq >> 1); ··· 4282 4301 * @dev : ptr to irdma_dev struct 4283 4302 * @hmc_fn_id: hmc function id 4284 4303 */ 4285 - enum irdma_status_code irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, 4286 - u8 hmc_fn_id) 4304 + int irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, u8 hmc_fn_id) 4287 4305 { 4288 4306 struct irdma_hmc_info *hmc_info; 4289 4307 struct irdma_hmc_fpm_misc *hmc_fpm_misc; 4290 4308 struct irdma_dma_mem query_fpm_mem; 4291 - enum irdma_status_code ret_code = 0; 4309 + int ret_code = 0; 4292 4310 u8 wait_type; 4293 4311 4294 4312 hmc_info = dev->hmc_info; ··· 4318 4338 * @dev : ptr to irdma_dev struct 4319 4339 * @hmc_fn_id: hmc function id 4320 4340 */ 4321 - static enum irdma_status_code irdma_sc_cfg_iw_fpm(struct irdma_sc_dev *dev, 4322 - u8 hmc_fn_id) 4341 + static int irdma_sc_cfg_iw_fpm(struct irdma_sc_dev *dev, u8 hmc_fn_id) 4323 4342 { 4324 4343 struct irdma_hmc_info *hmc_info; 4325 4344 struct irdma_hmc_obj_info *obj_info; 4326 4345 __le64 *buf; 4327 4346 struct irdma_dma_mem commit_fpm_mem; 4328 - enum irdma_status_code ret_code = 0; 4347 + int ret_code = 0; 4329 4348 u8 wait_type; 4330 4349 4331 4350 hmc_info = dev->hmc_info; ··· 4387 4408 * @info: sd info for wqe 4388 4409 * @scratch: u64 saved to be used during cqp completion 4389 4410 */ 4390 - static enum irdma_status_code 4391 - cqp_sds_wqe_fill(struct irdma_sc_cqp *cqp, struct irdma_update_sds_info *info, 4392 - u64 scratch) 4411 + static int cqp_sds_wqe_fill(struct irdma_sc_cqp *cqp, 4412 + struct irdma_update_sds_info *info, u64 scratch) 4393 4413 { 4394 4414 u64 data; 4395 4415 u64 hdr; ··· 4400 4422 4401 4423 wqe = irdma_sc_cqp_get_next_send_wqe_idx(cqp, scratch, &wqe_idx); 4402 4424 if (!wqe) 4403 - return IRDMA_ERR_RING_FULL; 4425 + return -ENOMEM; 4404 4426 4405 4427 wqe_entries = (info->cnt > 3) ? 3 : info->cnt; 4406 4428 mem_entries = info->cnt - wqe_entries; ··· 4466 4488 * @info: sd info for sd's 4467 4489 * @scratch: u64 saved to be used during cqp completion 4468 4490 */ 4469 - static enum irdma_status_code 4470 - irdma_update_pe_sds(struct irdma_sc_dev *dev, 4471 - struct irdma_update_sds_info *info, u64 scratch) 4491 + static int irdma_update_pe_sds(struct irdma_sc_dev *dev, 4492 + struct irdma_update_sds_info *info, u64 scratch) 4472 4493 { 4473 4494 struct irdma_sc_cqp *cqp = dev->cqp; 4474 - enum irdma_status_code ret_code; 4495 + int ret_code; 4475 4496 4476 4497 ret_code = cqp_sds_wqe_fill(cqp, info, scratch); 4477 4498 if (!ret_code) ··· 4484 4507 * @dev: sc device struct 4485 4508 * @info: sd info for sd's 4486 4509 */ 4487 - enum irdma_status_code 4488 - irdma_update_sds_noccq(struct irdma_sc_dev *dev, 4489 - struct irdma_update_sds_info *info) 4510 + int irdma_update_sds_noccq(struct irdma_sc_dev *dev, 4511 + struct irdma_update_sds_info *info) 4490 4512 { 4491 4513 u32 error, val, tail; 4492 4514 struct irdma_sc_cqp *cqp = dev->cqp; 4493 - enum irdma_status_code ret_code; 4515 + int ret_code; 4494 4516 4495 4517 ret_code = cqp_sds_wqe_fill(cqp, info, 0); 4496 4518 if (ret_code) ··· 4510 4534 * @post_sq: flag for cqp db to ring 4511 4535 * @poll_registers: flag to poll register for cqp completion 4512 4536 */ 4513 - enum irdma_status_code 4514 - irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, 4515 - u8 hmc_fn_id, bool post_sq, 4516 - bool poll_registers) 4537 + int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, 4538 + u8 hmc_fn_id, bool post_sq, 4539 + bool poll_registers) 4517 4540 { 4518 4541 u64 hdr; 4519 4542 __le64 *wqe; ··· 4520 4545 4521 4546 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 4522 4547 if (!wqe) 4523 - return IRDMA_ERR_RING_FULL; 4548 + return -ENOMEM; 4524 4549 4525 4550 set_64bit_val(wqe, 16, 4526 4551 FIELD_PREP(IRDMA_SHMC_PAGE_ALLOCATED_HMC_FN_ID, hmc_fn_id)); ··· 4595 4620 * irdma_sc_query_rdma_features_done - poll cqp for query features done 4596 4621 * @cqp: struct for cqp hw 4597 4622 */ 4598 - static enum irdma_status_code 4599 - irdma_sc_query_rdma_features_done(struct irdma_sc_cqp *cqp) 4623 + static int irdma_sc_query_rdma_features_done(struct irdma_sc_cqp *cqp) 4600 4624 { 4601 4625 return irdma_sc_poll_for_cqp_op_done(cqp, 4602 4626 IRDMA_CQP_OP_QUERY_RDMA_FEATURES, ··· 4608 4634 * @buf: buffer to hold query info 4609 4635 * @scratch: u64 saved to be used during cqp completion 4610 4636 */ 4611 - static enum irdma_status_code 4612 - irdma_sc_query_rdma_features(struct irdma_sc_cqp *cqp, 4613 - struct irdma_dma_mem *buf, u64 scratch) 4637 + static int irdma_sc_query_rdma_features(struct irdma_sc_cqp *cqp, 4638 + struct irdma_dma_mem *buf, u64 scratch) 4614 4639 { 4615 4640 __le64 *wqe; 4616 4641 u64 temp; 4617 4642 4618 4643 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 4619 4644 if (!wqe) 4620 - return IRDMA_ERR_RING_FULL; 4645 + return -ENOMEM; 4621 4646 4622 4647 temp = buf->pa; 4623 4648 set_64bit_val(wqe, 32, temp); ··· 4640 4667 * irdma_get_rdma_features - get RDMA features 4641 4668 * @dev: sc device struct 4642 4669 */ 4643 - enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev) 4670 + int irdma_get_rdma_features(struct irdma_sc_dev *dev) 4644 4671 { 4645 - enum irdma_status_code ret_code; 4672 + int ret_code; 4646 4673 struct irdma_dma_mem feat_buf; 4647 4674 u64 temp; 4648 4675 u16 byte_idx, feat_type, feat_cnt, feat_idx; ··· 4652 4679 feat_buf.va = dma_alloc_coherent(dev->hw->device, feat_buf.size, 4653 4680 &feat_buf.pa, GFP_KERNEL); 4654 4681 if (!feat_buf.va) 4655 - return IRDMA_ERR_NO_MEMORY; 4682 + return -ENOMEM; 4656 4683 4657 4684 ret_code = irdma_sc_query_rdma_features(dev->cqp, &feat_buf, 0); 4658 4685 if (!ret_code) ··· 4663 4690 get_64bit_val(feat_buf.va, 0, &temp); 4664 4691 feat_cnt = (u16)FIELD_GET(IRDMA_FEATURE_CNT, temp); 4665 4692 if (feat_cnt < 2) { 4666 - ret_code = IRDMA_ERR_INVALID_FEAT_CNT; 4693 + ret_code = -EINVAL; 4667 4694 goto exit; 4668 4695 } else if (feat_cnt > IRDMA_MAX_FEATURES) { 4669 4696 ibdev_dbg(to_ibdev(dev), ··· 4677 4704 feat_buf.size, &feat_buf.pa, 4678 4705 GFP_KERNEL); 4679 4706 if (!feat_buf.va) 4680 - return IRDMA_ERR_NO_MEMORY; 4707 + return -ENOMEM; 4681 4708 4682 4709 ret_code = irdma_sc_query_rdma_features(dev->cqp, &feat_buf, 0); 4683 4710 if (!ret_code) ··· 4688 4715 get_64bit_val(feat_buf.va, 0, &temp); 4689 4716 feat_cnt = (u16)FIELD_GET(IRDMA_FEATURE_CNT, temp); 4690 4717 if (feat_cnt < 2) { 4691 - ret_code = IRDMA_ERR_INVALID_FEAT_CNT; 4718 + ret_code = -EINVAL; 4692 4719 goto exit; 4693 4720 } 4694 4721 } ··· 4767 4794 * @dev: sc device struct 4768 4795 * @qp_count: desired qp count 4769 4796 */ 4770 - enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) 4797 + int irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) 4771 4798 { 4772 4799 struct irdma_virt_mem virt_mem; 4773 4800 u32 i, mem_size; ··· 4778 4805 u32 loop_count = 0; 4779 4806 struct irdma_hmc_info *hmc_info; 4780 4807 struct irdma_hmc_fpm_misc *hmc_fpm_misc; 4781 - enum irdma_status_code ret_code = 0; 4808 + int ret_code = 0; 4782 4809 4783 4810 hmc_info = dev->hmc_info; 4784 4811 hmc_fpm_misc = &dev->hmc_fpm_misc; ··· 4905 4932 ibdev_dbg(to_ibdev(dev), 4906 4933 "HMC: cfg_fpm failed loop_cnt=%d, sd_needed=%d, max sd count %d\n", 4907 4934 loop_count, sd_needed, hmc_info->sd_table.sd_cnt); 4908 - return IRDMA_ERR_CFG; 4935 + return -EINVAL; 4909 4936 } 4910 4937 4911 4938 if (loop_count > 1 && sd_needed < hmc_fpm_misc->max_sds) { ··· 4941 4968 if (!virt_mem.va) { 4942 4969 ibdev_dbg(to_ibdev(dev), 4943 4970 "HMC: failed to allocate memory for sd_entry buffer\n"); 4944 - return IRDMA_ERR_NO_MEMORY; 4971 + return -ENOMEM; 4945 4972 } 4946 4973 hmc_info->sd_table.sd_entry = virt_mem.va; 4947 4974 ··· 4953 4980 * @dev: rdma device 4954 4981 * @pcmdinfo: cqp command info 4955 4982 */ 4956 - static enum irdma_status_code irdma_exec_cqp_cmd(struct irdma_sc_dev *dev, 4957 - struct cqp_cmds_info *pcmdinfo) 4983 + static int irdma_exec_cqp_cmd(struct irdma_sc_dev *dev, 4984 + struct cqp_cmds_info *pcmdinfo) 4958 4985 { 4959 - enum irdma_status_code status; 4986 + int status; 4960 4987 struct irdma_dma_mem val_mem; 4961 4988 bool alloc = false; 4962 4989 ··· 5218 5245 pcmdinfo->in.u.mc_modify.scratch); 5219 5246 break; 5220 5247 default: 5221 - status = IRDMA_NOT_SUPPORTED; 5248 + status = -EOPNOTSUPP; 5222 5249 break; 5223 5250 } 5224 5251 ··· 5230 5257 * @dev: sc device struct 5231 5258 * @pcmdinfo: cqp command info 5232 5259 */ 5233 - enum irdma_status_code irdma_process_cqp_cmd(struct irdma_sc_dev *dev, 5234 - struct cqp_cmds_info *pcmdinfo) 5260 + int irdma_process_cqp_cmd(struct irdma_sc_dev *dev, 5261 + struct cqp_cmds_info *pcmdinfo) 5235 5262 { 5236 - enum irdma_status_code status = 0; 5263 + int status = 0; 5237 5264 unsigned long flags; 5238 5265 5239 5266 spin_lock_irqsave(&dev->cqp_lock, flags); ··· 5249 5276 * irdma_process_bh - called from tasklet for cqp list 5250 5277 * @dev: sc device struct 5251 5278 */ 5252 - enum irdma_status_code irdma_process_bh(struct irdma_sc_dev *dev) 5279 + int irdma_process_bh(struct irdma_sc_dev *dev) 5253 5280 { 5254 - enum irdma_status_code status = 0; 5281 + int status = 0; 5255 5282 struct cqp_cmds_info *pcmdinfo; 5256 5283 unsigned long flags; 5257 5284 ··· 5339 5366 * @dev: Device pointer 5340 5367 * @info: Device init info 5341 5368 */ 5342 - enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver, 5343 - struct irdma_sc_dev *dev, 5344 - struct irdma_device_init_info *info) 5369 + int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev, 5370 + struct irdma_device_init_info *info) 5345 5371 { 5346 5372 u32 val; 5347 - enum irdma_status_code ret_code = 0; 5373 + int ret_code = 0; 5348 5374 u8 db_size; 5349 5375 5350 5376 INIT_LIST_HEAD(&dev->cqp_cmd_head); /* for CQP command backlog */ ··· 5387 5415 irdma_sc_init_hw(dev); 5388 5416 5389 5417 if (irdma_wait_pe_ready(dev)) 5390 - return IRDMA_ERR_TIMEOUT; 5418 + return -ETIMEDOUT; 5391 5419 5392 5420 val = readl(dev->hw_regs[IRDMA_GLPCI_LBARCTRL]); 5393 5421 db_size = (u8)FIELD_GET(IRDMA_GLPCI_LBARCTRL_PE_DB_SIZE, val); ··· 5395 5423 ibdev_dbg(to_ibdev(dev), 5396 5424 "DEV: RDMA PE doorbell is not enabled in CSR val 0x%x db_size=%d\n", 5397 5425 val, db_size); 5398 - return IRDMA_ERR_PE_DOORBELL_NOT_ENA; 5426 + return -ENODEV; 5399 5427 } 5400 5428 dev->db_addr = dev->hw->hw_addr + (uintptr_t)dev->hw_regs[IRDMA_DB_ADDR_OFFSET]; 5401 5429
+4 -4
drivers/infiniband/hw/irdma/defs.h
··· 964 964 (_ring).head = ((_ring).head + 1) % size; \ 965 965 (_retcode) = 0; \ 966 966 } else { \ 967 - (_retcode) = IRDMA_ERR_RING_FULL; \ 967 + (_retcode) = -ENOMEM; \ 968 968 } \ 969 969 } 970 970 #define IRDMA_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ ··· 975 975 (_ring).head = ((_ring).head + (_count)) % size; \ 976 976 (_retcode) = 0; \ 977 977 } else { \ 978 - (_retcode) = IRDMA_ERR_RING_FULL; \ 978 + (_retcode) = -ENOMEM; \ 979 979 } \ 980 980 } 981 981 #define IRDMA_SQ_RING_MOVE_HEAD(_ring, _retcode) \ ··· 986 986 (_ring).head = ((_ring).head + 1) % size; \ 987 987 (_retcode) = 0; \ 988 988 } else { \ 989 - (_retcode) = IRDMA_ERR_RING_FULL; \ 989 + (_retcode) = -ENOMEM; \ 990 990 } \ 991 991 } 992 992 #define IRDMA_SQ_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ ··· 997 997 (_ring).head = ((_ring).head + (_count)) % size; \ 998 998 (_retcode) = 0; \ 999 999 } else { \ 1000 - (_retcode) = IRDMA_ERR_RING_FULL; \ 1000 + (_retcode) = -ENOMEM; \ 1001 1001 } \ 1002 1002 } 1003 1003 #define IRDMA_RING_MOVE_HEAD_BY_COUNT_NOCHECK(_ring, _count) \
+46 -59
drivers/infiniband/hw/irdma/hmc.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 2 2 /* Copyright (c) 2015 - 2021 Intel Corporation */ 3 3 #include "osdep.h" 4 - #include "status.h" 5 4 #include "hmc.h" 6 5 #include "defs.h" 7 6 #include "type.h" ··· 120 121 * @type: paged or direct sd 121 122 * @setsd: flag to set or clear sd 122 123 */ 123 - enum irdma_status_code irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, 124 - u64 pa, u32 sd_idx, 125 - enum irdma_sd_entry_type type, 126 - bool setsd) 124 + int irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, u64 pa, u32 sd_idx, 125 + enum irdma_sd_entry_type type, bool setsd) 127 126 { 128 127 struct irdma_update_sds_info sdinfo; 129 128 ··· 142 145 * @sd_cnt: number of sd entries 143 146 * @setsd: flag to set or clear sd 144 147 */ 145 - static enum irdma_status_code irdma_hmc_sd_grp(struct irdma_sc_dev *dev, 146 - struct irdma_hmc_info *hmc_info, 147 - u32 sd_index, u32 sd_cnt, 148 - bool setsd) 148 + static int irdma_hmc_sd_grp(struct irdma_sc_dev *dev, 149 + struct irdma_hmc_info *hmc_info, u32 sd_index, 150 + u32 sd_cnt, bool setsd) 149 151 { 150 152 struct irdma_hmc_sd_entry *sd_entry; 151 153 struct irdma_update_sds_info sdinfo = {}; 152 154 u64 pa; 153 155 u32 i; 154 - enum irdma_status_code ret_code = 0; 156 + int ret_code = 0; 155 157 156 158 sdinfo.hmc_fn_id = hmc_info->hmc_fn_id; 157 159 for (i = sd_index; i < sd_index + sd_cnt; i++) { ··· 192 196 * @dev: pointer to the device structure 193 197 * @info: create obj info 194 198 */ 195 - static enum irdma_status_code 196 - irdma_hmc_finish_add_sd_reg(struct irdma_sc_dev *dev, 197 - struct irdma_hmc_create_obj_info *info) 199 + static int irdma_hmc_finish_add_sd_reg(struct irdma_sc_dev *dev, 200 + struct irdma_hmc_create_obj_info *info) 198 201 { 199 202 if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) 200 - return IRDMA_ERR_INVALID_HMC_OBJ_INDEX; 203 + return -EINVAL; 201 204 202 205 if ((info->start_idx + info->count) > 203 206 info->hmc_info->hmc_obj[info->rsrc_type].cnt) 204 - return IRDMA_ERR_INVALID_HMC_OBJ_COUNT; 207 + return -EINVAL; 205 208 206 209 if (!info->add_sd_cnt) 207 210 return 0; ··· 217 222 * This will allocate memory for PDs and backing pages and populate 218 223 * the sd and pd entries. 219 224 */ 220 - enum irdma_status_code 221 - irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, 222 - struct irdma_hmc_create_obj_info *info) 225 + int irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, 226 + struct irdma_hmc_create_obj_info *info) 223 227 { 224 228 struct irdma_hmc_sd_entry *sd_entry; 225 229 u32 sd_idx, sd_lmt; ··· 226 232 u32 pd_idx1 = 0, pd_lmt1 = 0; 227 233 u32 i, j; 228 234 bool pd_error = false; 229 - enum irdma_status_code ret_code = 0; 235 + int ret_code = 0; 230 236 231 237 if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) 232 - return IRDMA_ERR_INVALID_HMC_OBJ_INDEX; 238 + return -EINVAL; 233 239 234 240 if ((info->start_idx + info->count) > 235 241 info->hmc_info->hmc_obj[info->rsrc_type].cnt) { ··· 237 243 "HMC: error type %u, start = %u, req cnt %u, cnt = %u\n", 238 244 info->rsrc_type, info->start_idx, info->count, 239 245 info->hmc_info->hmc_obj[info->rsrc_type].cnt); 240 - return IRDMA_ERR_INVALID_HMC_OBJ_COUNT; 246 + return -EINVAL; 241 247 } 242 248 243 249 irdma_find_sd_index_limit(info->hmc_info, info->rsrc_type, ··· 245 251 &sd_lmt); 246 252 if (sd_idx >= info->hmc_info->sd_table.sd_cnt || 247 253 sd_lmt > info->hmc_info->sd_table.sd_cnt) { 248 - return IRDMA_ERR_INVALID_SD_INDEX; 254 + return -EINVAL; 249 255 } 250 256 251 257 irdma_find_pd_index_limit(info->hmc_info, info->rsrc_type, ··· 306 312 irdma_prep_remove_pd_page(info->hmc_info, (j - 1)); 307 313 break; 308 314 default: 309 - ret_code = IRDMA_ERR_INVALID_SD_TYPE; 315 + ret_code = -EINVAL; 310 316 break; 311 317 } 312 318 j--; ··· 321 327 * @info: dele obj info 322 328 * @reset: true if called before reset 323 329 */ 324 - static enum irdma_status_code 325 - irdma_finish_del_sd_reg(struct irdma_sc_dev *dev, 326 - struct irdma_hmc_del_obj_info *info, bool reset) 330 + static int irdma_finish_del_sd_reg(struct irdma_sc_dev *dev, 331 + struct irdma_hmc_del_obj_info *info, 332 + bool reset) 327 333 { 328 334 struct irdma_hmc_sd_entry *sd_entry; 329 - enum irdma_status_code ret_code = 0; 335 + int ret_code = 0; 330 336 u32 i, sd_idx; 331 337 struct irdma_dma_mem *mem; 332 338 ··· 367 373 * caller should deallocate memory allocated previously for 368 374 * book-keeping information about PDs and backing storage. 369 375 */ 370 - enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, 371 - struct irdma_hmc_del_obj_info *info, 372 - bool reset) 376 + int irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, 377 + struct irdma_hmc_del_obj_info *info, bool reset) 373 378 { 374 379 struct irdma_hmc_pd_table *pd_table; 375 380 u32 sd_idx, sd_lmt; 376 381 u32 pd_idx, pd_lmt, rel_pd_idx; 377 382 u32 i, j; 378 - enum irdma_status_code ret_code = 0; 383 + int ret_code = 0; 379 384 380 385 if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) { 381 386 ibdev_dbg(to_ibdev(dev), 382 387 "HMC: error start_idx[%04d] >= [type %04d].cnt[%04d]\n", 383 388 info->start_idx, info->rsrc_type, 384 389 info->hmc_info->hmc_obj[info->rsrc_type].cnt); 385 - return IRDMA_ERR_INVALID_HMC_OBJ_INDEX; 390 + return -EINVAL; 386 391 } 387 392 388 393 if ((info->start_idx + info->count) > ··· 390 397 "HMC: error start_idx[%04d] + count %04d >= [type %04d].cnt[%04d]\n", 391 398 info->start_idx, info->count, info->rsrc_type, 392 399 info->hmc_info->hmc_obj[info->rsrc_type].cnt); 393 - return IRDMA_ERR_INVALID_HMC_OBJ_COUNT; 400 + return -EINVAL; 394 401 } 395 402 396 403 irdma_find_pd_index_limit(info->hmc_info, info->rsrc_type, ··· 426 433 if (sd_idx >= info->hmc_info->sd_table.sd_cnt || 427 434 sd_lmt > info->hmc_info->sd_table.sd_cnt) { 428 435 ibdev_dbg(to_ibdev(dev), "HMC: invalid sd_idx\n"); 429 - return IRDMA_ERR_INVALID_SD_INDEX; 436 + return -EINVAL; 430 437 } 431 438 432 439 for (i = sd_idx; i < sd_lmt; i++) { ··· 470 477 * @type: what type of segment descriptor we're manipulating 471 478 * @direct_mode_sz: size to alloc in direct mode 472 479 */ 473 - enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, 474 - struct irdma_hmc_info *hmc_info, 475 - u32 sd_index, 476 - enum irdma_sd_entry_type type, 477 - u64 direct_mode_sz) 480 + int irdma_add_sd_table_entry(struct irdma_hw *hw, 481 + struct irdma_hmc_info *hmc_info, u32 sd_index, 482 + enum irdma_sd_entry_type type, u64 direct_mode_sz) 478 483 { 479 484 struct irdma_hmc_sd_entry *sd_entry; 480 485 struct irdma_dma_mem dma_mem; ··· 490 499 dma_mem.va = dma_alloc_coherent(hw->device, dma_mem.size, 491 500 &dma_mem.pa, GFP_KERNEL); 492 501 if (!dma_mem.va) 493 - return IRDMA_ERR_NO_MEMORY; 502 + return -ENOMEM; 494 503 if (type == IRDMA_SD_TYPE_PAGED) { 495 504 struct irdma_virt_mem *vmem = 496 505 &sd_entry->u.pd_table.pd_entry_virt_mem; ··· 501 510 dma_free_coherent(hw->device, dma_mem.size, 502 511 dma_mem.va, dma_mem.pa); 503 512 dma_mem.va = NULL; 504 - return IRDMA_ERR_NO_MEMORY; 513 + return -ENOMEM; 505 514 } 506 515 sd_entry->u.pd_table.pd_entry = vmem->va; 507 516 ··· 540 549 * aligned on 4K boundary and zeroed memory. 541 550 * 2. It should be 4K in size. 542 551 */ 543 - enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, 544 - struct irdma_hmc_info *hmc_info, 545 - u32 pd_index, 546 - struct irdma_dma_mem *rsrc_pg) 552 + int irdma_add_pd_table_entry(struct irdma_sc_dev *dev, 553 + struct irdma_hmc_info *hmc_info, u32 pd_index, 554 + struct irdma_dma_mem *rsrc_pg) 547 555 { 548 556 struct irdma_hmc_pd_table *pd_table; 549 557 struct irdma_hmc_pd_entry *pd_entry; ··· 553 563 u64 page_desc; 554 564 555 565 if (pd_index / IRDMA_HMC_PD_CNT_IN_SD >= hmc_info->sd_table.sd_cnt) 556 - return IRDMA_ERR_INVALID_PAGE_DESC_INDEX; 566 + return -EINVAL; 557 567 558 568 sd_idx = (pd_index / IRDMA_HMC_PD_CNT_IN_SD); 559 569 if (hmc_info->sd_table.sd_entry[sd_idx].entry_type != ··· 574 584 page->size, &page->pa, 575 585 GFP_KERNEL); 576 586 if (!page->va) 577 - return IRDMA_ERR_NO_MEMORY; 587 + return -ENOMEM; 578 588 579 589 pd_entry->rsrc_pg = false; 580 590 } ··· 611 621 * 1. Caller can deallocate the memory used by backing storage after this 612 622 * function returns. 613 623 */ 614 - enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, 615 - struct irdma_hmc_info *hmc_info, 616 - u32 idx) 624 + int irdma_remove_pd_bp(struct irdma_sc_dev *dev, 625 + struct irdma_hmc_info *hmc_info, u32 idx) 617 626 { 618 627 struct irdma_hmc_pd_entry *pd_entry; 619 628 struct irdma_hmc_pd_table *pd_table; ··· 624 635 sd_idx = idx / IRDMA_HMC_PD_CNT_IN_SD; 625 636 rel_pd_idx = idx % IRDMA_HMC_PD_CNT_IN_SD; 626 637 if (sd_idx >= hmc_info->sd_table.sd_cnt) 627 - return IRDMA_ERR_INVALID_PAGE_DESC_INDEX; 638 + return -EINVAL; 628 639 629 640 sd_entry = &hmc_info->sd_table.sd_entry[sd_idx]; 630 641 if (sd_entry->entry_type != IRDMA_SD_TYPE_PAGED) 631 - return IRDMA_ERR_INVALID_SD_TYPE; 642 + return -EINVAL; 632 643 633 644 pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table; 634 645 pd_entry = &pd_table->pd_entry[rel_pd_idx]; ··· 645 656 if (!pd_entry->rsrc_pg) { 646 657 mem = &pd_entry->bp.addr; 647 658 if (!mem || !mem->va) 648 - return IRDMA_ERR_PARAM; 659 + return -EINVAL; 649 660 650 661 dma_free_coherent(dev->hw->device, mem->size, mem->va, 651 662 mem->pa); ··· 662 673 * @hmc_info: pointer to the HMC configuration information structure 663 674 * @idx: the page index 664 675 */ 665 - enum irdma_status_code irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, 666 - u32 idx) 676 + int irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, u32 idx) 667 677 { 668 678 struct irdma_hmc_sd_entry *sd_entry; 669 679 670 680 sd_entry = &hmc_info->sd_table.sd_entry[idx]; 671 681 if (--sd_entry->u.bp.use_cnt) 672 - return IRDMA_ERR_NOT_READY; 682 + return -EBUSY; 673 683 674 684 hmc_info->sd_table.use_cnt--; 675 685 sd_entry->valid = false; ··· 681 693 * @hmc_info: pointer to the HMC configuration information structure 682 694 * @idx: segment descriptor index to find the relevant page descriptor 683 695 */ 684 - enum irdma_status_code 685 - irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx) 696 + int irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx) 686 697 { 687 698 struct irdma_hmc_sd_entry *sd_entry; 688 699 689 700 sd_entry = &hmc_info->sd_table.sd_entry[idx]; 690 701 691 702 if (sd_entry->u.pd_table.use_cnt) 692 - return IRDMA_ERR_NOT_READY; 703 + return -EBUSY; 693 704 694 705 sd_entry->valid = false; 695 706 hmc_info->sd_table.use_cnt--;
+21 -32
drivers/infiniband/hw/irdma/hmc.h
··· 141 141 bool privileged; 142 142 }; 143 143 144 - enum irdma_status_code irdma_copy_dma_mem(struct irdma_hw *hw, void *dest_buf, 145 - struct irdma_dma_mem *src_mem, 146 - u64 src_offset, u64 size); 147 - enum irdma_status_code 148 - irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, 149 - struct irdma_hmc_create_obj_info *info); 150 - enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, 151 - struct irdma_hmc_del_obj_info *info, 152 - bool reset); 153 - enum irdma_status_code irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, 154 - u64 pa, u32 sd_idx, 155 - enum irdma_sd_entry_type type, 156 - bool setsd); 157 - enum irdma_status_code 158 - irdma_update_sds_noccq(struct irdma_sc_dev *dev, 159 - struct irdma_update_sds_info *info); 144 + int irdma_copy_dma_mem(struct irdma_hw *hw, void *dest_buf, 145 + struct irdma_dma_mem *src_mem, u64 src_offset, u64 size); 146 + int irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, 147 + struct irdma_hmc_create_obj_info *info); 148 + int irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, 149 + struct irdma_hmc_del_obj_info *info, bool reset); 150 + int irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, u64 pa, u32 sd_idx, 151 + enum irdma_sd_entry_type type, 152 + bool setsd); 153 + int irdma_update_sds_noccq(struct irdma_sc_dev *dev, 154 + struct irdma_update_sds_info *info); 160 155 struct irdma_vfdev *irdma_vfdev_from_fpm(struct irdma_sc_dev *dev, 161 156 u8 hmc_fn_id); 162 157 struct irdma_hmc_info *irdma_vf_hmcinfo_from_fpm(struct irdma_sc_dev *dev, 163 158 u8 hmc_fn_id); 164 - enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, 165 - struct irdma_hmc_info *hmc_info, 166 - u32 sd_index, 167 - enum irdma_sd_entry_type type, 168 - u64 direct_mode_sz); 169 - enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, 170 - struct irdma_hmc_info *hmc_info, 171 - u32 pd_index, 172 - struct irdma_dma_mem *rsrc_pg); 173 - enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, 174 - struct irdma_hmc_info *hmc_info, 175 - u32 idx); 176 - enum irdma_status_code irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, 177 - u32 idx); 178 - enum irdma_status_code 179 - irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx); 159 + int irdma_add_sd_table_entry(struct irdma_hw *hw, 160 + struct irdma_hmc_info *hmc_info, u32 sd_index, 161 + enum irdma_sd_entry_type type, u64 direct_mode_sz); 162 + int irdma_add_pd_table_entry(struct irdma_sc_dev *dev, 163 + struct irdma_hmc_info *hmc_info, u32 pd_index, 164 + struct irdma_dma_mem *rsrc_pg); 165 + int irdma_remove_pd_bp(struct irdma_sc_dev *dev, 166 + struct irdma_hmc_info *hmc_info, u32 idx); 167 + int irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, u32 idx); 168 + int irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx); 180 169 #endif /* IRDMA_HMC_H */
+90 -102
drivers/infiniband/hw/irdma/hw.c
··· 75 75 struct irdma_sc_cq *cq) 76 76 { 77 77 struct irdma_sc_dev *dev = &rf->sc_dev; 78 - enum irdma_status_code status; 79 78 u32 compl_error; 79 + int status; 80 80 81 81 do { 82 82 status = irdma_puda_poll_cmpl(dev, cq, &compl_error); 83 - if (status == IRDMA_ERR_Q_EMPTY) 83 + if (status == -ENOENT) 84 84 break; 85 85 if (status) { 86 86 ibdev_dbg(to_ibdev(dev), "ERR: puda status = %d\n", status); ··· 456 456 * Allocate iwdev msix table and copy the msix info to the table 457 457 * Return 0 if successful, otherwise return error 458 458 */ 459 - static enum irdma_status_code irdma_save_msix_info(struct irdma_pci_f *rf) 459 + static int irdma_save_msix_info(struct irdma_pci_f *rf) 460 460 { 461 461 struct irdma_qvlist_info *iw_qvlist; 462 462 struct irdma_qv_info *iw_qvinfo; ··· 466 466 size_t size; 467 467 468 468 if (!rf->msix_count) 469 - return IRDMA_ERR_NO_INTR; 469 + return -EINVAL; 470 470 471 471 size = sizeof(struct irdma_msix_vector) * rf->msix_count; 472 472 size += struct_size(iw_qvlist, qv_info, rf->msix_count); 473 473 rf->iw_msixtbl = kzalloc(size, GFP_KERNEL); 474 474 if (!rf->iw_msixtbl) 475 - return IRDMA_ERR_NO_MEMORY; 475 + return -ENOMEM; 476 476 477 477 rf->iw_qvlist = (struct irdma_qvlist_info *) 478 478 (&rf->iw_msixtbl[rf->msix_count]); ··· 564 564 */ 565 565 static void irdma_destroy_cqp(struct irdma_pci_f *rf, bool free_hwcqp) 566 566 { 567 - enum irdma_status_code status = 0; 568 567 struct irdma_sc_dev *dev = &rf->sc_dev; 569 568 struct irdma_cqp *cqp = &rf->cqp; 569 + int status = 0; 570 570 571 571 if (rf->cqp_cmpl_wq) 572 572 destroy_workqueue(rf->cqp_cmpl_wq); ··· 606 606 */ 607 607 static void irdma_destroy_aeq(struct irdma_pci_f *rf) 608 608 { 609 - enum irdma_status_code status = IRDMA_ERR_NOT_READY; 610 609 struct irdma_sc_dev *dev = &rf->sc_dev; 611 610 struct irdma_aeq *aeq = &rf->aeq; 611 + int status = -EBUSY; 612 612 613 613 if (!rf->msix_shared) { 614 614 rf->sc_dev.irq_ops->irdma_cfg_aeq(&rf->sc_dev, rf->iw_msixtbl->idx, false); ··· 642 642 */ 643 643 static void irdma_destroy_ceq(struct irdma_pci_f *rf, struct irdma_ceq *iwceq) 644 644 { 645 - enum irdma_status_code status; 646 645 struct irdma_sc_dev *dev = &rf->sc_dev; 646 + int status; 647 647 648 648 if (rf->reset) 649 649 goto exit; ··· 733 733 { 734 734 struct irdma_sc_dev *dev = &rf->sc_dev; 735 735 struct irdma_ccq *ccq = &rf->ccq; 736 - enum irdma_status_code status = 0; 736 + int status = 0; 737 737 738 738 if (!rf->reset) 739 739 status = irdma_sc_ccq_destroy(dev->ccq, 0, true); ··· 796 796 * @dev: hardware control device structure 797 797 * @info: information for the hmc object to create 798 798 */ 799 - static enum irdma_status_code 800 - irdma_create_hmc_obj_type(struct irdma_sc_dev *dev, 801 - struct irdma_hmc_create_obj_info *info) 799 + static int irdma_create_hmc_obj_type(struct irdma_sc_dev *dev, 800 + struct irdma_hmc_create_obj_info *info) 802 801 { 803 802 return irdma_sc_create_hmc_obj(dev, info); 804 803 } ··· 811 812 * Create the device hmc objects and allocate hmc pages 812 813 * Return 0 if successful, otherwise clean up and return error 813 814 */ 814 - static enum irdma_status_code 815 - irdma_create_hmc_objs(struct irdma_pci_f *rf, bool privileged, enum irdma_vers vers) 815 + static int irdma_create_hmc_objs(struct irdma_pci_f *rf, bool privileged, 816 + enum irdma_vers vers) 816 817 { 817 818 struct irdma_sc_dev *dev = &rf->sc_dev; 818 819 struct irdma_hmc_create_obj_info info = {}; 819 - enum irdma_status_code status = 0; 820 - int i; 820 + int i, status = 0; 821 821 822 822 info.hmc_info = dev->hmc_info; 823 823 info.privileged = privileged; ··· 866 868 * update the memptr to point to the new aligned memory 867 869 * Return 0 if successful, otherwise return no memory error 868 870 */ 869 - static enum irdma_status_code 870 - irdma_obj_aligned_mem(struct irdma_pci_f *rf, struct irdma_dma_mem *memptr, 871 - u32 size, u32 mask) 871 + static int irdma_obj_aligned_mem(struct irdma_pci_f *rf, 872 + struct irdma_dma_mem *memptr, u32 size, 873 + u32 mask) 872 874 { 873 875 unsigned long va, newva; 874 876 unsigned long extra; ··· 882 884 memptr->pa = rf->obj_next.pa + extra; 883 885 memptr->size = size; 884 886 if (((u8 *)memptr->va + size) > ((u8 *)rf->obj_mem.va + rf->obj_mem.size)) 885 - return IRDMA_ERR_NO_MEMORY; 887 + return -ENOMEM; 886 888 887 889 rf->obj_next.va = (u8 *)memptr->va + size; 888 890 rf->obj_next.pa = memptr->pa + size; ··· 897 899 * Return 0, if the cqp and all the resources associated with it 898 900 * are successfully created, otherwise return error 899 901 */ 900 - static enum irdma_status_code irdma_create_cqp(struct irdma_pci_f *rf) 902 + static int irdma_create_cqp(struct irdma_pci_f *rf) 901 903 { 902 - enum irdma_status_code status; 903 904 u32 sqsize = IRDMA_CQP_SW_SQSIZE_2048; 904 905 struct irdma_dma_mem mem; 905 906 struct irdma_sc_dev *dev = &rf->sc_dev; 906 907 struct irdma_cqp_init_info cqp_init_info = {}; 907 908 struct irdma_cqp *cqp = &rf->cqp; 908 909 u16 maj_err, min_err; 909 - int i; 910 + int i, status; 910 911 911 912 cqp->cqp_requests = kcalloc(sqsize, sizeof(*cqp->cqp_requests), GFP_KERNEL); 912 913 if (!cqp->cqp_requests) 913 - return IRDMA_ERR_NO_MEMORY; 914 + return -ENOMEM; 914 915 915 916 cqp->scratch_array = kcalloc(sqsize, sizeof(*cqp->scratch_array), GFP_KERNEL); 916 917 if (!cqp->scratch_array) { 917 918 kfree(cqp->cqp_requests); 918 - return IRDMA_ERR_NO_MEMORY; 919 + return -ENOMEM; 919 920 } 920 921 921 922 dev->cqp = &cqp->sc_cqp; ··· 926 929 if (!cqp->sq.va) { 927 930 kfree(cqp->scratch_array); 928 931 kfree(cqp->cqp_requests); 929 - return IRDMA_ERR_NO_MEMORY; 932 + return -ENOMEM; 930 933 } 931 934 932 935 status = irdma_obj_aligned_mem(rf, &mem, sizeof(struct irdma_cqp_ctx), ··· 996 999 * Return 0, if the ccq and the resources associated with it 997 1000 * are successfully created, otherwise return error 998 1001 */ 999 - static enum irdma_status_code irdma_create_ccq(struct irdma_pci_f *rf) 1002 + static int irdma_create_ccq(struct irdma_pci_f *rf) 1000 1003 { 1001 1004 struct irdma_sc_dev *dev = &rf->sc_dev; 1002 - enum irdma_status_code status; 1003 1005 struct irdma_ccq_init_info info = {}; 1004 1006 struct irdma_ccq *ccq = &rf->ccq; 1007 + int status; 1005 1008 1006 1009 dev->ccq = &ccq->sc_cq; 1007 1010 dev->ccq->dev = dev; ··· 1012 1015 ccq->mem_cq.va = dma_alloc_coherent(dev->hw->device, ccq->mem_cq.size, 1013 1016 &ccq->mem_cq.pa, GFP_KERNEL); 1014 1017 if (!ccq->mem_cq.va) 1015 - return IRDMA_ERR_NO_MEMORY; 1018 + return -ENOMEM; 1016 1019 1017 1020 status = irdma_obj_aligned_mem(rf, &ccq->shadow_area, 1018 1021 ccq->shadow_area.size, ··· 1051 1054 * Allocate a mac ip entry and add it to the hw table Return 0 1052 1055 * if successful, otherwise return error 1053 1056 */ 1054 - static enum irdma_status_code irdma_alloc_set_mac(struct irdma_device *iwdev) 1057 + static int irdma_alloc_set_mac(struct irdma_device *iwdev) 1055 1058 { 1056 - enum irdma_status_code status; 1059 + int status; 1057 1060 1058 1061 status = irdma_alloc_local_mac_entry(iwdev->rf, 1059 1062 &iwdev->mac_ip_table_idx); ··· 1079 1082 * Allocate interrupt resources and enable irq handling 1080 1083 * Return 0 if successful, otherwise return error 1081 1084 */ 1082 - static enum irdma_status_code 1083 - irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, 1084 - u32 ceq_id, struct irdma_msix_vector *msix_vec) 1085 + static int irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, 1086 + u32 ceq_id, struct irdma_msix_vector *msix_vec) 1085 1087 { 1086 1088 int status; 1087 1089 ··· 1099 1103 irq_update_affinity_hint(msix_vec->irq, &msix_vec->mask); 1100 1104 if (status) { 1101 1105 ibdev_dbg(&rf->iwdev->ibdev, "ERR: ceq irq config fail\n"); 1102 - return IRDMA_ERR_CFG; 1106 + return status; 1103 1107 } 1104 1108 1105 1109 msix_vec->ceq_id = ceq_id; ··· 1115 1119 * Allocate interrupt resources and enable irq handling 1116 1120 * Return 0 if successful, otherwise return error 1117 1121 */ 1118 - static enum irdma_status_code irdma_cfg_aeq_vector(struct irdma_pci_f *rf) 1122 + static int irdma_cfg_aeq_vector(struct irdma_pci_f *rf) 1119 1123 { 1120 1124 struct irdma_msix_vector *msix_vec = rf->iw_msixtbl; 1121 1125 u32 ret = 0; ··· 1127 1131 } 1128 1132 if (ret) { 1129 1133 ibdev_dbg(&rf->iwdev->ibdev, "ERR: aeq irq config fail\n"); 1130 - return IRDMA_ERR_CFG; 1134 + return -EINVAL; 1131 1135 } 1132 1136 1133 1137 rf->sc_dev.irq_ops->irdma_cfg_aeq(&rf->sc_dev, msix_vec->idx, true); ··· 1145 1149 * Return 0, if the ceq and the resources associated with it 1146 1150 * are successfully created, otherwise return error 1147 1151 */ 1148 - static enum irdma_status_code irdma_create_ceq(struct irdma_pci_f *rf, 1149 - struct irdma_ceq *iwceq, 1150 - u32 ceq_id, 1151 - struct irdma_sc_vsi *vsi) 1152 + static int irdma_create_ceq(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, 1153 + u32 ceq_id, struct irdma_sc_vsi *vsi) 1152 1154 { 1153 - enum irdma_status_code status; 1155 + int status; 1154 1156 struct irdma_ceq_init_info info = {}; 1155 1157 struct irdma_sc_dev *dev = &rf->sc_dev; 1156 1158 u64 scratch; ··· 1163 1169 iwceq->mem.va = dma_alloc_coherent(dev->hw->device, iwceq->mem.size, 1164 1170 &iwceq->mem.pa, GFP_KERNEL); 1165 1171 if (!iwceq->mem.va) 1166 - return IRDMA_ERR_NO_MEMORY; 1172 + return -ENOMEM; 1167 1173 1168 1174 info.ceq_id = ceq_id; 1169 1175 info.ceqe_base = iwceq->mem.va; ··· 1199 1205 * Create the ceq 0 and configure it's msix interrupt vector 1200 1206 * Return 0, if successfully set up, otherwise return error 1201 1207 */ 1202 - static enum irdma_status_code irdma_setup_ceq_0(struct irdma_pci_f *rf) 1208 + static int irdma_setup_ceq_0(struct irdma_pci_f *rf) 1203 1209 { 1204 1210 struct irdma_ceq *iwceq; 1205 1211 struct irdma_msix_vector *msix_vec; 1206 1212 u32 i; 1207 - enum irdma_status_code status = 0; 1213 + int status = 0; 1208 1214 u32 num_ceqs; 1209 1215 1210 1216 num_ceqs = min(rf->msix_count, rf->sc_dev.hmc_fpm_misc.max_ceqs); 1211 1217 rf->ceqlist = kcalloc(num_ceqs, sizeof(*rf->ceqlist), GFP_KERNEL); 1212 1218 if (!rf->ceqlist) { 1213 - status = IRDMA_ERR_NO_MEMORY; 1219 + status = -ENOMEM; 1214 1220 goto exit; 1215 1221 } 1216 1222 ··· 1256 1262 * Create the ceq's and configure their msix interrupt vectors 1257 1263 * Return 0, if ceqs are successfully set up, otherwise return error 1258 1264 */ 1259 - static enum irdma_status_code irdma_setup_ceqs(struct irdma_pci_f *rf, 1260 - struct irdma_sc_vsi *vsi) 1265 + static int irdma_setup_ceqs(struct irdma_pci_f *rf, struct irdma_sc_vsi *vsi) 1261 1266 { 1262 1267 u32 i; 1263 1268 u32 ceq_id; 1264 1269 struct irdma_ceq *iwceq; 1265 1270 struct irdma_msix_vector *msix_vec; 1266 - enum irdma_status_code status; 1271 + int status; 1267 1272 u32 num_ceqs; 1268 1273 1269 1274 num_ceqs = min(rf->msix_count, rf->sc_dev.hmc_fpm_misc.max_ceqs); ··· 1296 1303 return status; 1297 1304 } 1298 1305 1299 - static enum irdma_status_code irdma_create_virt_aeq(struct irdma_pci_f *rf, 1300 - u32 size) 1306 + static int irdma_create_virt_aeq(struct irdma_pci_f *rf, u32 size) 1301 1307 { 1302 - enum irdma_status_code status = IRDMA_ERR_NO_MEMORY; 1303 1308 struct irdma_aeq *aeq = &rf->aeq; 1304 1309 dma_addr_t *pg_arr; 1305 1310 u32 pg_cnt; 1311 + int status; 1306 1312 1307 1313 if (rf->rdma_ver < IRDMA_GEN_2) 1308 - return IRDMA_NOT_SUPPORTED; 1314 + return -EOPNOTSUPP; 1309 1315 1310 1316 aeq->mem.size = sizeof(struct irdma_sc_aeqe) * size; 1311 1317 aeq->mem.va = vzalloc(aeq->mem.size); 1312 1318 1313 1319 if (!aeq->mem.va) 1314 - return status; 1320 + return -ENOMEM; 1315 1321 1316 1322 pg_cnt = DIV_ROUND_UP(aeq->mem.size, PAGE_SIZE); 1317 1323 status = irdma_get_pble(rf->pble_rsrc, &aeq->palloc, pg_cnt, true); ··· 1337 1345 * Return 0, if the aeq and the resources associated with it 1338 1346 * are successfully created, otherwise return error 1339 1347 */ 1340 - static enum irdma_status_code irdma_create_aeq(struct irdma_pci_f *rf) 1348 + static int irdma_create_aeq(struct irdma_pci_f *rf) 1341 1349 { 1342 - enum irdma_status_code status; 1343 1350 struct irdma_aeq_init_info info = {}; 1344 1351 struct irdma_sc_dev *dev = &rf->sc_dev; 1345 1352 struct irdma_aeq *aeq = &rf->aeq; 1346 1353 struct irdma_hmc_info *hmc_info = rf->sc_dev.hmc_info; 1347 1354 u32 aeq_size; 1348 1355 u8 multiplier = (rf->protocol_used == IRDMA_IWARP_PROTOCOL_ONLY) ? 2 : 1; 1356 + int status; 1349 1357 1350 1358 aeq_size = multiplier * hmc_info->hmc_obj[IRDMA_HMC_IW_QP].cnt + 1351 1359 hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].cnt; ··· 1404 1412 * Create the aeq and configure its msix interrupt vector 1405 1413 * Return 0 if successful, otherwise return error 1406 1414 */ 1407 - static enum irdma_status_code irdma_setup_aeq(struct irdma_pci_f *rf) 1415 + static int irdma_setup_aeq(struct irdma_pci_f *rf) 1408 1416 { 1409 1417 struct irdma_sc_dev *dev = &rf->sc_dev; 1410 - enum irdma_status_code status; 1418 + int status; 1411 1419 1412 1420 status = irdma_create_aeq(rf); 1413 1421 if (status) ··· 1431 1439 * 1432 1440 * Return 0 if successful, otherwise return error 1433 1441 */ 1434 - static enum irdma_status_code irdma_initialize_ilq(struct irdma_device *iwdev) 1442 + static int irdma_initialize_ilq(struct irdma_device *iwdev) 1435 1443 { 1436 1444 struct irdma_puda_rsrc_info info = {}; 1437 - enum irdma_status_code status; 1445 + int status; 1438 1446 1439 1447 info.type = IRDMA_PUDA_RSRC_TYPE_ILQ; 1440 1448 info.cq_id = 1; ··· 1461 1469 * 1462 1470 * Return 0 if successful, otherwise return error 1463 1471 */ 1464 - static enum irdma_status_code irdma_initialize_ieq(struct irdma_device *iwdev) 1472 + static int irdma_initialize_ieq(struct irdma_device *iwdev) 1465 1473 { 1466 1474 struct irdma_puda_rsrc_info info = {}; 1467 - enum irdma_status_code status; 1475 + int status; 1468 1476 1469 1477 info.type = IRDMA_PUDA_RSRC_TYPE_IEQ; 1470 1478 info.cq_id = 2; ··· 1507 1515 * the hmc objects and create the objects 1508 1516 * Return 0 if successful, otherwise return error 1509 1517 */ 1510 - static enum irdma_status_code irdma_hmc_setup(struct irdma_pci_f *rf) 1518 + static int irdma_hmc_setup(struct irdma_pci_f *rf) 1511 1519 { 1512 - enum irdma_status_code status; 1520 + int status; 1513 1521 u32 qpcnt; 1514 1522 1515 1523 if (rf->rdma_ver == IRDMA_GEN_1) ··· 1562 1570 * Return 0 if successful, otherwise clean up the resources 1563 1571 * and return error 1564 1572 */ 1565 - static enum irdma_status_code irdma_initialize_dev(struct irdma_pci_f *rf) 1573 + static int irdma_initialize_dev(struct irdma_pci_f *rf) 1566 1574 { 1567 - enum irdma_status_code status; 1575 + int status; 1568 1576 struct irdma_sc_dev *dev = &rf->sc_dev; 1569 1577 struct irdma_device_init_info info = {}; 1570 1578 struct irdma_dma_mem mem; ··· 1576 1584 1577 1585 rf->hmc_info_mem = kzalloc(size, GFP_KERNEL); 1578 1586 if (!rf->hmc_info_mem) 1579 - return IRDMA_ERR_NO_MEMORY; 1587 + return -ENOMEM; 1580 1588 1581 1589 rf->pble_rsrc = (struct irdma_hmc_pble_rsrc *)rf->hmc_info_mem; 1582 1590 dev->hmc_info = &rf->hw.hmc; ··· 1600 1608 info.fpm_commit_buf = mem.va; 1601 1609 1602 1610 info.bar0 = rf->hw.hw_addr; 1603 - info.hmc_fn_id = PCI_FUNC(rf->pcidev->devfn); 1611 + info.hmc_fn_id = rf->pf_id; 1604 1612 info.hw = &rf->hw; 1605 1613 status = irdma_sc_dev_init(rf->rdma_ver, &rf->sc_dev, &info); 1606 1614 if (status) ··· 1659 1667 destroy_workqueue(iwdev->cleanup_wq); 1660 1668 } 1661 1669 1662 - static enum irdma_status_code irdma_setup_init_state(struct irdma_pci_f *rf) 1670 + static int irdma_setup_init_state(struct irdma_pci_f *rf) 1663 1671 { 1664 - enum irdma_status_code status; 1672 + int status; 1665 1673 1666 1674 status = irdma_save_msix_info(rf); 1667 1675 if (status) ··· 1672 1680 rf->obj_mem.va = dma_alloc_coherent(rf->hw.device, rf->obj_mem.size, 1673 1681 &rf->obj_mem.pa, GFP_KERNEL); 1674 1682 if (!rf->obj_mem.va) { 1675 - status = IRDMA_ERR_NO_MEMORY; 1683 + status = -ENOMEM; 1676 1684 goto clean_msixtbl; 1677 1685 } 1678 1686 ··· 1755 1763 * Create device queues ILQ, IEQ, CEQs and PBLEs. Setup irdma 1756 1764 * device resource objects. 1757 1765 */ 1758 - enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, 1759 - struct irdma_l2params *l2params) 1766 + int irdma_rt_init_hw(struct irdma_device *iwdev, 1767 + struct irdma_l2params *l2params) 1760 1768 { 1761 1769 struct irdma_pci_f *rf = iwdev->rf; 1762 1770 struct irdma_sc_dev *dev = &rf->sc_dev; 1763 - enum irdma_status_code status; 1764 1771 struct irdma_vsi_init_info vsi_info = {}; 1765 1772 struct irdma_vsi_stats_info stats_info = {}; 1773 + int status; 1766 1774 1767 1775 vsi_info.dev = dev; 1768 1776 vsi_info.back_vsi = iwdev; ··· 1780 1788 stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL); 1781 1789 if (!stats_info.pestat) { 1782 1790 irdma_cleanup_cm_core(&iwdev->cm_core); 1783 - return IRDMA_ERR_NO_MEMORY; 1791 + return -ENOMEM; 1784 1792 } 1785 1793 stats_info.fcn_id = dev->hmc_fn_id; 1786 1794 status = irdma_vsi_stats_init(&iwdev->vsi, &stats_info); ··· 1842 1850 iwdev->cleanup_wq = alloc_workqueue("irdma-cleanup-wq", 1843 1851 WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE); 1844 1852 if (!iwdev->cleanup_wq) 1845 - return IRDMA_ERR_NO_MEMORY; 1853 + return -ENOMEM; 1846 1854 irdma_get_used_rsrc(iwdev); 1847 1855 init_waitqueue_head(&iwdev->suspend_wq); 1848 1856 ··· 1862 1870 * 1863 1871 * Create admin queues, HMC obejcts and RF resource objects 1864 1872 */ 1865 - enum irdma_status_code irdma_ctrl_init_hw(struct irdma_pci_f *rf) 1873 + int irdma_ctrl_init_hw(struct irdma_pci_f *rf) 1866 1874 { 1867 1875 struct irdma_sc_dev *dev = &rf->sc_dev; 1868 - enum irdma_status_code status; 1876 + int status; 1869 1877 do { 1870 1878 status = irdma_setup_init_state(rf); 1871 1879 if (status) ··· 1907 1915 rf->cqp_cmpl_wq = alloc_ordered_workqueue("cqp_cmpl_wq", 1908 1916 WQ_HIGHPRI | WQ_UNBOUND); 1909 1917 if (!rf->cqp_cmpl_wq) { 1910 - status = IRDMA_ERR_NO_MEMORY; 1918 + status = -ENOMEM; 1911 1919 break; 1912 1920 } 1913 1921 INIT_WORK(&rf->cqp_cmpl_work, cqp_compl_worker); ··· 2194 2202 struct irdma_cqp *iwcqp = &rf->cqp; 2195 2203 struct irdma_cqp_request *cqp_request; 2196 2204 struct cqp_cmds_info *cqp_info; 2197 - enum irdma_status_code status; 2205 + int status; 2198 2206 2199 2207 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); 2200 2208 if (!cqp_request) 2201 - return IRDMA_ERR_NO_MEMORY; 2209 + return -ENOMEM; 2202 2210 2203 2211 cqp_info = &cqp_request->info; 2204 2212 cqp_info->post_sq = 1; ··· 2230 2238 struct irdma_cqp *iwcqp = &rf->cqp; 2231 2239 struct irdma_cqp_request *cqp_request; 2232 2240 struct cqp_cmds_info *cqp_info; 2233 - enum irdma_status_code status = 0; 2241 + int status = 0; 2234 2242 2235 2243 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); 2236 2244 if (!cqp_request) 2237 - return IRDMA_ERR_NO_MEMORY; 2245 + return -ENOMEM; 2238 2246 2239 2247 cqp_info = &cqp_request->info; 2240 2248 cqp_info->cqp_cmd = IRDMA_OP_ALLOC_LOCAL_MAC_ENTRY; ··· 2256 2264 * @accel_local_port: port for apbvt 2257 2265 * @add_port: add ordelete port 2258 2266 */ 2259 - static enum irdma_status_code 2260 - irdma_cqp_manage_apbvt_cmd(struct irdma_device *iwdev, u16 accel_local_port, 2261 - bool add_port) 2267 + static int irdma_cqp_manage_apbvt_cmd(struct irdma_device *iwdev, 2268 + u16 accel_local_port, bool add_port) 2262 2269 { 2263 2270 struct irdma_apbvt_info *info; 2264 2271 struct irdma_cqp_request *cqp_request; 2265 2272 struct cqp_cmds_info *cqp_info; 2266 - enum irdma_status_code status; 2273 + int status; 2267 2274 2268 2275 cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, add_port); 2269 2276 if (!cqp_request) 2270 - return IRDMA_ERR_NO_MEMORY; 2277 + return -ENOMEM; 2271 2278 2272 2279 cqp_info = &cqp_request->info; 2273 2280 info = &cqp_info->in.u.manage_apbvt_entry.info; ··· 2420 2429 * @cmnode: cmnode associated with connection 2421 2430 * @wait: wait for completion 2422 2431 */ 2423 - enum irdma_status_code 2424 - irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, 2425 - enum irdma_quad_entry_type etype, 2426 - enum irdma_quad_hash_manage_type mtype, void *cmnode, 2427 - bool wait) 2432 + int irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, 2433 + enum irdma_quad_entry_type etype, 2434 + enum irdma_quad_hash_manage_type mtype, void *cmnode, 2435 + bool wait) 2428 2436 { 2429 2437 struct irdma_qhash_table_info *info; 2430 - enum irdma_status_code status; 2431 2438 struct irdma_cqp *iwcqp = &iwdev->rf->cqp; 2432 2439 struct irdma_cqp_request *cqp_request; 2433 2440 struct cqp_cmds_info *cqp_info; 2434 2441 struct irdma_cm_node *cm_node = cmnode; 2442 + int status; 2435 2443 2436 2444 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); 2437 2445 if (!cqp_request) 2438 - return IRDMA_ERR_NO_MEMORY; 2446 + return -ENOMEM; 2439 2447 2440 2448 cqp_info = &cqp_request->info; 2441 2449 info = &cqp_info->in.u.manage_qhash_table_entry.info; ··· 2548 2558 * @info: info for flush 2549 2559 * @wait: flag wait for completion 2550 2560 */ 2551 - enum irdma_status_code irdma_hw_flush_wqes(struct irdma_pci_f *rf, 2552 - struct irdma_sc_qp *qp, 2553 - struct irdma_qp_flush_info *info, 2554 - bool wait) 2561 + int irdma_hw_flush_wqes(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, 2562 + struct irdma_qp_flush_info *info, bool wait) 2555 2563 { 2556 - enum irdma_status_code status; 2564 + int status; 2557 2565 struct irdma_qp_flush_info *hw_info; 2558 2566 struct irdma_cqp_request *cqp_request; 2559 2567 struct cqp_cmds_info *cqp_info; ··· 2559 2571 2560 2572 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); 2561 2573 if (!cqp_request) 2562 - return IRDMA_ERR_NO_MEMORY; 2574 + return -ENOMEM; 2563 2575 2564 2576 cqp_info = &cqp_request->info; 2565 2577 if (!wait) ··· 2607 2619 info->sq = true; 2608 2620 new_req = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 2609 2621 if (!new_req) { 2610 - status = IRDMA_ERR_NO_MEMORY; 2622 + status = -ENOMEM; 2611 2623 goto put_cqp; 2612 2624 } 2613 2625 cqp_info = &new_req->info;
-1
drivers/infiniband/hw/irdma/i40iw_hw.c
··· 3 3 #include "osdep.h" 4 4 #include "type.h" 5 5 #include "i40iw_hw.h" 6 - #include "status.h" 7 6 #include "protos.h" 8 7 9 8 static u32 i40iw_regs[IRDMA_MAX_REGS] = {
+2 -1
drivers/infiniband/hw/irdma/i40iw_if.c
··· 77 77 rf->rdma_ver = IRDMA_GEN_1; 78 78 rf->gen_ops.request_reset = i40iw_request_reset; 79 79 rf->pcidev = cdev_info->pcidev; 80 + rf->pf_id = cdev_info->fid; 80 81 rf->hw.hw_addr = cdev_info->hw_addr; 81 82 rf->cdev = cdev_info; 82 83 rf->msix_count = cdev_info->msix_count; ··· 139 138 if (last_qset == IRDMA_NO_QSET) 140 139 last_qset = qset; 141 140 else if ((qset != last_qset) && (qset != IRDMA_NO_QSET)) 142 - iwdev->dcb = true; 141 + iwdev->dcb_vlan_mode = true; 143 142 } 144 143 145 144 if (irdma_rt_init_hw(iwdev, &l2params)) {
+18 -11
drivers/infiniband/hw/irdma/main.c
··· 79 79 } 80 80 for (i = 0; i < IIDC_MAX_USER_PRIORITY; i++) 81 81 l2params->up2tc[i] = qos_info->up2tc[i]; 82 + if (qos_info->pfc_mode == IIDC_DSCP_PFC_MODE) { 83 + l2params->dscp_mode = true; 84 + memcpy(l2params->dscp_map, qos_info->dscp_map, sizeof(l2params->dscp_map)); 85 + } 82 86 } 83 87 84 88 static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_event *event) ··· 112 108 l2params.tc_changed = true; 113 109 ibdev_dbg(&iwdev->ibdev, "CLNT: TC Change\n"); 114 110 ice_get_qos_params(pf, &qos_info); 115 - iwdev->dcb = qos_info.num_tc > 1; 116 111 irdma_fill_qos_info(&l2params, &qos_info); 112 + if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 113 + iwdev->dcb_vlan_mode = qos_info.num_tc > 1 && !l2params.dscp_mode; 117 114 irdma_change_l2params(&iwdev->vsi, &l2params); 118 115 } else if (*event->type & BIT(IIDC_EVENT_CRIT_ERR)) { 119 116 ibdev_warn(&iwdev->ibdev, "ICE OICR event notification: oicr = 0x%08x\n", ··· 162 157 * @vsi: vsi structure 163 158 * @tc_node: Traffic class node 164 159 */ 165 - static enum irdma_status_code irdma_lan_register_qset(struct irdma_sc_vsi *vsi, 166 - struct irdma_ws_node *tc_node) 160 + static int irdma_lan_register_qset(struct irdma_sc_vsi *vsi, 161 + struct irdma_ws_node *tc_node) 167 162 { 168 163 struct irdma_device *iwdev = vsi->back_vsi; 169 164 struct ice_pf *pf = iwdev->rf->cdev; ··· 176 171 ret = ice_add_rdma_qset(pf, &qset); 177 172 if (ret) { 178 173 ibdev_dbg(&iwdev->ibdev, "WS: LAN alloc_res for rdma qset failed.\n"); 179 - return IRDMA_ERR_REG_QSET; 174 + return ret; 180 175 } 181 176 182 177 tc_node->l2_sched_node_id = qset.teid; ··· 231 226 rf->hw.hw_addr = pf->hw.hw_addr; 232 227 rf->pcidev = pf->pdev; 233 228 rf->msix_count = pf->num_rdma_msix; 229 + rf->pf_id = pf->hw.pf_id; 234 230 rf->msix_entries = &pf->msix_entries[pf->rdma_base_vector]; 235 231 rf->default_vsi.vsi_idx = vsi->vsi_num; 236 232 rf->protocol_used = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? ··· 242 236 rf->gen_ops.request_reset = irdma_request_reset; 243 237 rf->limits_sel = 7; 244 238 rf->iwdev = iwdev; 245 - 239 + mutex_init(&iwdev->ah_tbl_lock); 246 240 iwdev->netdev = vsi->netdev; 247 241 iwdev->vsi_num = vsi->vsi_num; 248 242 iwdev->init_state = INITIAL_STATE; ··· 281 275 irdma_fill_device_info(iwdev, pf, vsi); 282 276 rf = iwdev->rf; 283 277 284 - if (irdma_ctrl_init_hw(rf)) { 285 - err = -EIO; 278 + err = irdma_ctrl_init_hw(rf); 279 + if (err) 286 280 goto err_ctrl_init; 287 - } 288 281 289 282 l2params.mtu = iwdev->netdev->mtu; 290 283 ice_get_qos_params(pf, &qos_info); 291 284 irdma_fill_qos_info(&l2params, &qos_info); 292 - if (irdma_rt_init_hw(iwdev, &l2params)) { 293 - err = -EIO; 285 + if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) 286 + iwdev->dcb_vlan_mode = l2params.num_tc > 1 && !l2params.dscp_mode; 287 + 288 + err = irdma_rt_init_hw(iwdev, &l2params); 289 + if (err) 294 290 goto err_rt_init; 295 - } 296 291 297 292 err = irdma_ib_register_device(iwdev); 298 293 if (err)
+21 -26
drivers/infiniband/hw/irdma/main.h
··· 40 40 #include <rdma/ib_umem.h> 41 41 #include <rdma/ib_cache.h> 42 42 #include <rdma/uverbs_ioctl.h> 43 - #include "status.h" 44 43 #include "osdep.h" 45 44 #include "defs.h" 46 45 #include "hmc.h" ··· 241 242 242 243 struct irdma_gen_ops { 243 244 void (*request_reset)(struct irdma_pci_f *rf); 244 - enum irdma_status_code (*register_qset)(struct irdma_sc_vsi *vsi, 245 - struct irdma_ws_node *tc_node); 245 + int (*register_qset)(struct irdma_sc_vsi *vsi, 246 + struct irdma_ws_node *tc_node); 246 247 void (*unregister_qset)(struct irdma_sc_vsi *vsi, 247 248 struct irdma_ws_node *tc_node); 248 249 }; ··· 256 257 u8 *mem_rsrc; 257 258 u8 rdma_ver; 258 259 u8 rst_to; 260 + u8 pf_id; 259 261 enum irdma_protocol_used protocol_used; 260 262 u32 sd_type; 261 263 u32 msix_count; ··· 332 332 struct workqueue_struct *cleanup_wq; 333 333 struct irdma_sc_vsi vsi; 334 334 struct irdma_cm_core cm_core; 335 + DECLARE_HASHTABLE(ah_hash_tbl, 8); 336 + struct mutex ah_tbl_lock; /* protect AH hash table access */ 335 337 u32 roce_cwnd; 336 338 u32 roce_ackcreds; 337 339 u32 vendor_id; ··· 347 345 u8 iw_status; 348 346 bool roce_mode:1; 349 347 bool roce_dcqcn_en:1; 350 - bool dcb:1; 348 + bool dcb_vlan_mode:1; 351 349 bool iw_ooo:1; 352 350 enum init_completion_state init_state; 353 351 ··· 459 457 spin_unlock_irqrestore(&rf->rsrc_lock, flags); 460 458 } 461 459 462 - enum irdma_status_code irdma_ctrl_init_hw(struct irdma_pci_f *rf); 460 + int irdma_ctrl_init_hw(struct irdma_pci_f *rf); 463 461 void irdma_ctrl_deinit_hw(struct irdma_pci_f *rf); 464 - enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, 465 - struct irdma_l2params *l2params); 462 + int irdma_rt_init_hw(struct irdma_device *iwdev, 463 + struct irdma_l2params *l2params); 466 464 void irdma_rt_deinit_hw(struct irdma_device *iwdev); 467 465 void irdma_qp_add_ref(struct ib_qp *ibqp); 468 466 void irdma_qp_rem_ref(struct ib_qp *ibqp); ··· 491 489 492 490 bool irdma_cqp_crit_err(struct irdma_sc_dev *dev, u8 cqp_cmd, 493 491 u16 maj_err_code, u16 min_err_code); 494 - enum irdma_status_code 495 - irdma_handle_cqp_op(struct irdma_pci_f *rf, 496 - struct irdma_cqp_request *cqp_request); 492 + int irdma_handle_cqp_op(struct irdma_pci_f *rf, 493 + struct irdma_cqp_request *cqp_request); 497 494 498 495 int irdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, 499 496 struct ib_udata *udata); ··· 501 500 void irdma_cq_wq_destroy(struct irdma_pci_f *rf, struct irdma_sc_cq *cq); 502 501 503 502 void irdma_cleanup_pending_cqp_op(struct irdma_pci_f *rf); 504 - enum irdma_status_code irdma_hw_modify_qp(struct irdma_device *iwdev, 505 - struct irdma_qp *iwqp, 506 - struct irdma_modify_qp_info *info, 507 - bool wait); 508 - enum irdma_status_code irdma_qp_suspend_resume(struct irdma_sc_qp *qp, 509 - bool suspend); 510 - enum irdma_status_code 511 - irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, 512 - enum irdma_quad_entry_type etype, 513 - enum irdma_quad_hash_manage_type mtype, void *cmnode, 514 - bool wait); 503 + int irdma_hw_modify_qp(struct irdma_device *iwdev, struct irdma_qp *iwqp, 504 + struct irdma_modify_qp_info *info, bool wait); 505 + int irdma_qp_suspend_resume(struct irdma_sc_qp *qp, bool suspend); 506 + int irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, 507 + enum irdma_quad_entry_type etype, 508 + enum irdma_quad_hash_manage_type mtype, void *cmnode, 509 + bool wait); 515 510 void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf); 516 511 void irdma_free_sqbuf(struct irdma_sc_vsi *vsi, void *bufp); 517 512 void irdma_free_qp_rsrc(struct irdma_qp *iwqp); 518 - enum irdma_status_code irdma_setup_cm_core(struct irdma_device *iwdev, u8 ver); 513 + int irdma_setup_cm_core(struct irdma_device *iwdev, u8 ver); 519 514 void irdma_cleanup_cm_core(struct irdma_cm_core *cm_core); 520 515 void irdma_next_iw_state(struct irdma_qp *iwqp, u8 state, u8 del_hash, u8 term, 521 516 u8 term_len); ··· 520 523 struct irdma_cm_node *irdma_find_node(struct irdma_cm_core *cm_core, 521 524 u16 rem_port, u32 *rem_addr, u16 loc_port, 522 525 u32 *loc_addr, u16 vlan_id); 523 - enum irdma_status_code irdma_hw_flush_wqes(struct irdma_pci_f *rf, 524 - struct irdma_sc_qp *qp, 525 - struct irdma_qp_flush_info *info, 526 - bool wait); 526 + int irdma_hw_flush_wqes(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, 527 + struct irdma_qp_flush_info *info, bool wait); 527 528 void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, 528 529 struct irdma_gen_ae_info *info, bool wait); 529 530 void irdma_copy_ip_ntohl(u32 *dst, __be32 *src);
+19 -22
drivers/infiniband/hw/irdma/osdep.h
··· 5 5 6 6 #include <linux/pci.h> 7 7 #include <linux/bitfield.h> 8 + #include <linux/net/intel/iidc.h> 8 9 #include <crypto/hash.h> 9 10 #include <rdma/ib_verbs.h> 10 11 ··· 43 42 bool irdma_vf_clear_to_send(struct irdma_sc_dev *dev); 44 43 void irdma_add_dev_ref(struct irdma_sc_dev *dev); 45 44 void irdma_put_dev_ref(struct irdma_sc_dev *dev); 46 - enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc, 47 - void *addr, u32 len, u32 val); 45 + int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len, 46 + u32 val); 48 47 struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev, 49 48 struct irdma_puda_buf *buf); 50 49 void irdma_send_ieq_ack(struct irdma_sc_qp *qp); 51 50 void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, 52 51 u32 seqnum); 53 52 void irdma_free_hash_desc(struct shash_desc *hash_desc); 54 - enum irdma_status_code irdma_init_hash_desc(struct shash_desc **hash_desc); 55 - enum irdma_status_code 56 - irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 57 - struct irdma_puda_buf *buf); 58 - enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, 59 - struct irdma_update_sds_info *info); 60 - enum irdma_status_code 61 - irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, 62 - struct irdma_hmc_fcn_info *hmcfcninfo, 63 - u16 *pmf_idx); 64 - enum irdma_status_code 65 - irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, 66 - struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 67 - enum irdma_status_code 68 - irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, 69 - struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 70 - enum irdma_status_code irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, 71 - struct irdma_dma_mem *mem); 53 + int irdma_init_hash_desc(struct shash_desc **hash_desc); 54 + int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 55 + struct irdma_puda_buf *buf); 56 + int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, 57 + struct irdma_update_sds_info *info); 58 + int irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, 59 + struct irdma_hmc_fcn_info *hmcfcninfo, 60 + u16 *pmf_idx); 61 + int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, 62 + struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 63 + int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, 64 + struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 65 + int irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, 66 + struct irdma_dma_mem *mem); 72 67 void *irdma_remove_cqp_head(struct irdma_sc_dev *dev); 73 68 void irdma_term_modify_qp(struct irdma_sc_qp *qp, u8 next_state, u8 term, 74 69 u8 term_len); ··· 76 79 void wr32(struct irdma_hw *hw, u32 reg, u32 val); 77 80 u32 rd32(struct irdma_hw *hw, u32 reg); 78 81 u64 rd64(struct irdma_hw *hw, u32 reg); 79 - enum irdma_status_code irdma_map_vm_page_list(struct irdma_hw *hw, void *va, 80 - dma_addr_t *pg_dma, u32 pg_cnt); 82 + int irdma_map_vm_page_list(struct irdma_hw *hw, void *va, dma_addr_t *pg_dma, 83 + u32 pg_cnt); 81 84 void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt); 82 85 #endif /* IRDMA_OSDEP_H */
+34 -43
drivers/infiniband/hw/irdma/pble.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 2 2 /* Copyright (c) 2015 - 2021 Intel Corporation */ 3 3 #include "osdep.h" 4 - #include "status.h" 5 4 #include "hmc.h" 6 5 #include "defs.h" 7 6 #include "type.h" 8 7 #include "protos.h" 9 8 #include "pble.h" 10 9 11 - static enum irdma_status_code 12 - add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); 10 + static int add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); 13 11 14 12 /** 15 13 * irdma_destroy_pble_prm - destroy prm during module unload ··· 33 35 * @dev: irdma_sc_dev struct 34 36 * @pble_rsrc: pble resources 35 37 */ 36 - enum irdma_status_code 37 - irdma_hmc_init_pble(struct irdma_sc_dev *dev, 38 - struct irdma_hmc_pble_rsrc *pble_rsrc) 38 + int irdma_hmc_init_pble(struct irdma_sc_dev *dev, 39 + struct irdma_hmc_pble_rsrc *pble_rsrc) 39 40 { 40 41 struct irdma_hmc_info *hmc_info; 41 42 u32 fpm_idx = 0; 42 - enum irdma_status_code status = 0; 43 + int status = 0; 43 44 44 45 hmc_info = dev->hmc_info; 45 46 pble_rsrc->dev = dev; ··· 57 60 INIT_LIST_HEAD(&pble_rsrc->pinfo.clist); 58 61 if (add_pble_prm(pble_rsrc)) { 59 62 irdma_destroy_pble_prm(pble_rsrc); 60 - status = IRDMA_ERR_NO_MEMORY; 63 + status = -ENOMEM; 61 64 } 62 65 63 66 return status; ··· 81 84 * @pble_rsrc: pble resource ptr 82 85 * @info: page info for sd 83 86 */ 84 - static enum irdma_status_code 85 - add_sd_direct(struct irdma_hmc_pble_rsrc *pble_rsrc, 86 - struct irdma_add_page_info *info) 87 + static int add_sd_direct(struct irdma_hmc_pble_rsrc *pble_rsrc, 88 + struct irdma_add_page_info *info) 87 89 { 88 90 struct irdma_sc_dev *dev = pble_rsrc->dev; 89 - enum irdma_status_code ret_code = 0; 91 + int ret_code = 0; 90 92 struct sd_pd_idx *idx = &info->idx; 91 93 struct irdma_chunk *chunk = info->chunk; 92 94 struct irdma_hmc_info *hmc_info = info->hmc_info; ··· 133 137 * @pble_rsrc: pble resource management 134 138 * @info: page info for sd 135 139 */ 136 - static enum irdma_status_code 137 - add_bp_pages(struct irdma_hmc_pble_rsrc *pble_rsrc, 138 - struct irdma_add_page_info *info) 140 + static int add_bp_pages(struct irdma_hmc_pble_rsrc *pble_rsrc, 141 + struct irdma_add_page_info *info) 139 142 { 140 143 struct irdma_sc_dev *dev = pble_rsrc->dev; 141 144 u8 *addr; ··· 143 148 struct irdma_hmc_sd_entry *sd_entry = info->sd_entry; 144 149 struct irdma_hmc_info *hmc_info = info->hmc_info; 145 150 struct irdma_chunk *chunk = info->chunk; 146 - enum irdma_status_code status = 0; 151 + int status = 0; 147 152 u32 rel_pd_idx = info->idx.rel_pd_idx; 148 153 u32 pd_idx = info->idx.pd_idx; 149 154 u32 i; 150 155 151 156 if (irdma_pble_get_paged_mem(chunk, info->pages)) 152 - return IRDMA_ERR_NO_MEMORY; 157 + return -ENOMEM; 153 158 154 159 status = irdma_add_sd_table_entry(dev->hw, hmc_info, info->idx.sd_idx, 155 160 IRDMA_SD_TYPE_PAGED, ··· 202 207 * add_pble_prm - add a sd entry for pble resoure 203 208 * @pble_rsrc: pble resource management 204 209 */ 205 - static enum irdma_status_code 206 - add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc) 210 + static int add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc) 207 211 { 208 212 struct irdma_sc_dev *dev = pble_rsrc->dev; 209 213 struct irdma_hmc_sd_entry *sd_entry; ··· 210 216 struct irdma_chunk *chunk; 211 217 struct irdma_add_page_info info; 212 218 struct sd_pd_idx *idx = &info.idx; 213 - enum irdma_status_code ret_code = 0; 219 + int ret_code = 0; 214 220 enum irdma_sd_entry_type sd_entry_type; 215 221 u64 sd_reg_val = 0; 216 222 struct irdma_virt_mem chunkmem; 217 223 u32 pages; 218 224 219 225 if (pble_rsrc->unallocated_pble < PBLE_PER_PAGE) 220 - return IRDMA_ERR_NO_MEMORY; 226 + return -ENOMEM; 221 227 222 228 if (pble_rsrc->next_fpm_addr & 0xfff) 223 - return IRDMA_ERR_INVALID_PAGE_DESC_INDEX; 229 + return -EINVAL; 224 230 225 231 chunkmem.size = sizeof(*chunk); 226 232 chunkmem.va = kzalloc(chunkmem.size, GFP_KERNEL); 227 233 if (!chunkmem.va) 228 - return IRDMA_ERR_NO_MEMORY; 234 + return -ENOMEM; 229 235 230 236 chunk = chunkmem.va; 231 237 chunk->chunkmem = chunkmem; ··· 331 337 * @pble_rsrc: pble resource management 332 338 * @palloc: level 2 pble allocation 333 339 */ 334 - static enum irdma_status_code 335 - get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 336 - struct irdma_pble_alloc *palloc) 340 + static int get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 341 + struct irdma_pble_alloc *palloc) 337 342 { 338 343 u32 lf4k, lflast, total, i; 339 344 u32 pblcnt = PBLE_PER_PAGE; ··· 340 347 struct irdma_pble_level2 *lvl2 = &palloc->level2; 341 348 struct irdma_pble_info *root = &lvl2->root; 342 349 struct irdma_pble_info *leaf; 343 - enum irdma_status_code ret_code; 350 + int ret_code; 344 351 u64 fpm_addr; 345 352 346 353 /* number of full 512 (4K) leafs) */ ··· 352 359 lvl2->leafmem.size = (sizeof(*leaf) * total); 353 360 lvl2->leafmem.va = kzalloc(lvl2->leafmem.size, GFP_KERNEL); 354 361 if (!lvl2->leafmem.va) 355 - return IRDMA_ERR_NO_MEMORY; 362 + return -ENOMEM; 356 363 357 364 lvl2->leaf = lvl2->leafmem.va; 358 365 leaf = lvl2->leaf; ··· 361 368 if (ret_code) { 362 369 kfree(lvl2->leafmem.va); 363 370 lvl2->leaf = NULL; 364 - return IRDMA_ERR_NO_MEMORY; 371 + return -ENOMEM; 365 372 } 366 373 367 374 root->idx = fpm_to_idx(pble_rsrc, fpm_addr); ··· 390 397 error: 391 398 free_lvl2(pble_rsrc, palloc); 392 399 393 - return IRDMA_ERR_NO_MEMORY; 400 + return -ENOMEM; 394 401 } 395 402 396 403 /** ··· 398 405 * @pble_rsrc: pble resource management 399 406 * @palloc: level 1 pble allocation 400 407 */ 401 - static enum irdma_status_code 402 - get_lvl1_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 403 - struct irdma_pble_alloc *palloc) 408 + static int get_lvl1_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 409 + struct irdma_pble_alloc *palloc) 404 410 { 405 - enum irdma_status_code ret_code; 411 + int ret_code; 406 412 u64 fpm_addr; 407 413 struct irdma_pble_info *lvl1 = &palloc->level1; 408 414 ··· 409 417 palloc->total_cnt << 3, &lvl1->addr, 410 418 &fpm_addr); 411 419 if (ret_code) 412 - return IRDMA_ERR_NO_MEMORY; 420 + return -ENOMEM; 413 421 414 422 palloc->level = PBLE_LEVEL_1; 415 423 lvl1->idx = fpm_to_idx(pble_rsrc, fpm_addr); ··· 425 433 * @palloc: contains all inforamtion regarding pble (idx + pble addr) 426 434 * @level1_only: flag for a level 1 PBLE 427 435 */ 428 - static enum irdma_status_code 429 - get_lvl1_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 430 - struct irdma_pble_alloc *palloc, bool level1_only) 436 + static int get_lvl1_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 437 + struct irdma_pble_alloc *palloc, bool level1_only) 431 438 { 432 - enum irdma_status_code status = 0; 439 + int status = 0; 433 440 434 441 status = get_lvl1_pble(pble_rsrc, palloc); 435 442 if (!status || level1_only || palloc->total_cnt <= PBLE_PER_PAGE) ··· 446 455 * @pble_cnt: #of pbles requested 447 456 * @level1_only: true if only pble level 1 to acquire 448 457 */ 449 - enum irdma_status_code irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 450 - struct irdma_pble_alloc *palloc, 451 - u32 pble_cnt, bool level1_only) 458 + int irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 459 + struct irdma_pble_alloc *palloc, u32 pble_cnt, 460 + bool level1_only) 452 461 { 453 - enum irdma_status_code status = 0; 462 + int status = 0; 454 463 int max_sds = 0; 455 464 int i; 456 465
+11 -14
drivers/infiniband/hw/irdma/pble.h
··· 108 108 }; 109 109 110 110 void irdma_destroy_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); 111 - enum irdma_status_code 112 - irdma_hmc_init_pble(struct irdma_sc_dev *dev, 113 - struct irdma_hmc_pble_rsrc *pble_rsrc); 111 + int irdma_hmc_init_pble(struct irdma_sc_dev *dev, 112 + struct irdma_hmc_pble_rsrc *pble_rsrc); 114 113 void irdma_free_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 115 114 struct irdma_pble_alloc *palloc); 116 - enum irdma_status_code irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 117 - struct irdma_pble_alloc *palloc, 118 - u32 pble_cnt, bool level1_only); 119 - enum irdma_status_code irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, 120 - struct irdma_chunk *pchunk); 121 - enum irdma_status_code 122 - irdma_prm_get_pbles(struct irdma_pble_prm *pprm, 123 - struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, 124 - u64 **vaddr, u64 *fpm_addr); 115 + int irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, 116 + struct irdma_pble_alloc *palloc, u32 pble_cnt, 117 + bool level1_only); 118 + int irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, 119 + struct irdma_chunk *pchunk); 120 + int irdma_prm_get_pbles(struct irdma_pble_prm *pprm, 121 + struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, 122 + u64 **vaddr, u64 *fpm_addr); 125 123 void irdma_prm_return_pbles(struct irdma_pble_prm *pprm, 126 124 struct irdma_pble_chunkinfo *chunkinfo); 127 125 void irdma_pble_acquire_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, ··· 127 129 void irdma_pble_release_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, 128 130 unsigned long *flags); 129 131 void irdma_pble_free_paged_mem(struct irdma_chunk *chunk); 130 - enum irdma_status_code irdma_pble_get_paged_mem(struct irdma_chunk *chunk, 131 - u32 pg_cnt); 132 + int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt); 132 133 void irdma_prm_rem_bitmapmem(struct irdma_hw *hw, struct irdma_chunk *chunk); 133 134 #endif /* IRDMA_PBLE_H */
+39 -51
drivers/infiniband/hw/irdma/protos.h
··· 12 12 #define CQP_TIMEOUT_THRESHOLD 500 13 13 14 14 /* init operations */ 15 - enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver, 16 - struct irdma_sc_dev *dev, 17 - struct irdma_device_init_info *info); 15 + int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev, 16 + struct irdma_device_init_info *info); 18 17 void irdma_sc_rt_init(struct irdma_sc_dev *dev); 19 18 void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp); 20 19 __le64 *irdma_sc_cqp_get_next_send_wqe(struct irdma_sc_cqp *cqp, u64 scratch); 21 - enum irdma_status_code 22 - irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, 23 - struct irdma_fast_reg_stag_info *info, bool post_sq); 20 + int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, 21 + struct irdma_fast_reg_stag_info *info, 22 + bool post_sq); 24 23 /* HMC/FPM functions */ 25 - enum irdma_status_code irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, 26 - u8 hmc_fn_id); 24 + int irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, u8 hmc_fn_id); 27 25 /* stats misc */ 28 - enum irdma_status_code 29 - irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, 30 - struct irdma_vsi_pestat *pestat, bool wait); 26 + int irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, 27 + struct irdma_vsi_pestat *pestat, bool wait); 31 28 void irdma_cqp_gather_stats_gen1(struct irdma_sc_dev *dev, 32 29 struct irdma_vsi_pestat *pestat); 33 30 void irdma_hw_stats_read_all(struct irdma_vsi_pestat *stats, 34 31 struct irdma_dev_hw_stats *stats_values, 35 32 u64 *hw_stats_regs_32, u64 *hw_stats_regs_64, 36 33 u8 hw_rev); 37 - enum irdma_status_code 38 - irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, 39 - struct irdma_ws_node_info *node_info); 40 - enum irdma_status_code irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, 41 - struct irdma_sc_ceq *sc_ceq, u8 op); 42 - enum irdma_status_code irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, 43 - struct irdma_sc_aeq *sc_aeq, u8 op); 44 - enum irdma_status_code 45 - irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, 46 - struct irdma_stats_inst_info *stats_info); 34 + int irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, 35 + struct irdma_ws_node_info *node_info); 36 + int irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_ceq *sc_ceq, 37 + u8 op); 38 + int irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_aeq *sc_aeq, 39 + u8 op); 40 + int irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, 41 + struct irdma_stats_inst_info *stats_info); 47 42 u16 irdma_alloc_ws_node_id(struct irdma_sc_dev *dev); 48 43 void irdma_free_ws_node_id(struct irdma_sc_dev *dev, u16 node_id); 49 44 void irdma_update_stats(struct irdma_dev_hw_stats *hw_stats, 50 45 struct irdma_gather_stats *gather_stats, 51 46 struct irdma_gather_stats *last_gather_stats); 52 47 /* vsi functions */ 53 - enum irdma_status_code irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, 54 - struct irdma_vsi_stats_info *info); 48 + int irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, 49 + struct irdma_vsi_stats_info *info); 55 50 void irdma_vsi_stats_free(struct irdma_sc_vsi *vsi); 56 51 void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, 57 52 struct irdma_vsi_init_info *info); 58 - enum irdma_status_code irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, 59 - struct irdma_sc_cq *cq); 53 + int irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq); 60 54 void irdma_sc_remove_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq); 61 55 /* misc L2 param change functions */ 62 56 void irdma_change_l2params(struct irdma_sc_vsi *vsi, 63 57 struct irdma_l2params *l2params); 64 58 void irdma_sc_suspend_resume_qps(struct irdma_sc_vsi *vsi, u8 suspend); 65 - enum irdma_status_code irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, 66 - u8 cmd); 59 + int irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, u8 cmd); 67 60 void irdma_qp_add_qos(struct irdma_sc_qp *qp); 68 61 void irdma_qp_rem_qos(struct irdma_sc_qp *qp); 69 62 struct irdma_sc_qp *irdma_get_qp_from_list(struct list_head *head, ··· 74 81 /* misc */ 75 82 u8 irdma_get_encoded_wqe_size(u32 wqsize, enum irdma_queue_type queue_type); 76 83 void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp); 77 - enum irdma_status_code 78 - irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, 79 - u8 hmc_fn_id, bool post_sq, 80 - bool poll_registers); 81 - enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, 82 - u32 qp_count); 83 - enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev); 84 + int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, 85 + u8 hmc_fn_id, bool post_sq, 86 + bool poll_registers); 87 + int irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count); 88 + int irdma_get_rdma_features(struct irdma_sc_dev *dev); 84 89 void free_sd_mem(struct irdma_sc_dev *dev); 85 - enum irdma_status_code irdma_process_cqp_cmd(struct irdma_sc_dev *dev, 86 - struct cqp_cmds_info *pcmdinfo); 87 - enum irdma_status_code irdma_process_bh(struct irdma_sc_dev *dev); 88 - enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, 89 - struct irdma_update_sds_info *info); 90 - enum irdma_status_code 91 - irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, 92 - struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 93 - enum irdma_status_code 94 - irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, 95 - struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 96 - enum irdma_status_code irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, 97 - struct irdma_dma_mem *mem); 98 - enum irdma_status_code 99 - irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, 100 - struct irdma_hmc_fcn_info *hmcfcninfo, 101 - u16 *pmf_idx); 90 + int irdma_process_cqp_cmd(struct irdma_sc_dev *dev, 91 + struct cqp_cmds_info *pcmdinfo); 92 + int irdma_process_bh(struct irdma_sc_dev *dev); 93 + int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, 94 + struct irdma_update_sds_info *info); 95 + int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, 96 + struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 97 + int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, 98 + struct irdma_dma_mem *val_mem, u8 hmc_fn_id); 99 + int irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, 100 + struct irdma_dma_mem *mem); 101 + int irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, 102 + struct irdma_hmc_fcn_info *hmcfcninfo, 103 + u16 *pmf_idx); 102 104 void irdma_add_dev_ref(struct irdma_sc_dev *dev); 103 105 void irdma_put_dev_ref(struct irdma_sc_dev *dev); 104 106 void *irdma_remove_cqp_head(struct irdma_sc_dev *dev);
+62 -70
drivers/infiniband/hw/irdma/puda.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 2 2 /* Copyright (c) 2015 - 2021 Intel Corporation */ 3 3 #include "osdep.h" 4 - #include "status.h" 5 4 #include "hmc.h" 6 5 #include "defs.h" 7 6 #include "type.h" ··· 113 114 * @rsrc: resource to use for buffer 114 115 * @initial: flag if during init time 115 116 */ 116 - static enum irdma_status_code 117 - irdma_puda_replenish_rq(struct irdma_puda_rsrc *rsrc, bool initial) 117 + static int irdma_puda_replenish_rq(struct irdma_puda_rsrc *rsrc, bool initial) 118 118 { 119 119 u32 i; 120 120 u32 invalid_cnt = rsrc->rxq_invalid_cnt; ··· 122 124 for (i = 0; i < invalid_cnt; i++) { 123 125 buf = irdma_puda_get_bufpool(rsrc); 124 126 if (!buf) 125 - return IRDMA_ERR_list_empty; 127 + return -ENOBUFS; 126 128 irdma_puda_post_recvbuf(rsrc, rsrc->rx_wqe_idx, buf, initial); 127 129 rsrc->rx_wqe_idx = ((rsrc->rx_wqe_idx + 1) % rsrc->rq_size); 128 130 rsrc->rxq_invalid_cnt--; ··· 192 194 u32 *wqe_idx) 193 195 { 194 196 __le64 *wqe = NULL; 195 - enum irdma_status_code ret_code = 0; 197 + int ret_code = 0; 196 198 197 199 *wqe_idx = IRDMA_RING_CURRENT_HEAD(qp->sq_ring); 198 200 if (!*wqe_idx) ··· 211 213 * @cq: cq for poll 212 214 * @info: info return for successful completion 213 215 */ 214 - static enum irdma_status_code 215 - irdma_puda_poll_info(struct irdma_sc_cq *cq, struct irdma_puda_cmpl_info *info) 216 + static int irdma_puda_poll_info(struct irdma_sc_cq *cq, 217 + struct irdma_puda_cmpl_info *info) 216 218 { 217 219 struct irdma_cq_uk *cq_uk = &cq->cq_uk; 218 220 u64 qword0, qword2, qword3, qword6; ··· 231 233 get_64bit_val(cqe, 24, &qword3); 232 234 valid_bit = (bool)FIELD_GET(IRDMA_CQ_VALID, qword3); 233 235 if (valid_bit != cq_uk->polarity) 234 - return IRDMA_ERR_Q_EMPTY; 236 + return -ENOENT; 235 237 236 238 if (cq->dev->hw_attrs.uk_attrs.hw_rev >= IRDMA_GEN_2) 237 239 ext_valid = (bool)FIELD_GET(IRDMA_CQ_EXTCQE, qword3); ··· 244 246 if (!peek_head) 245 247 polarity ^= 1; 246 248 if (polarity != cq_uk->polarity) 247 - return IRDMA_ERR_Q_EMPTY; 249 + return -ENOENT; 248 250 249 251 IRDMA_RING_MOVE_HEAD_NOCHECK(cq_uk->cq_ring); 250 252 if (!IRDMA_RING_CURRENT_HEAD(cq_uk->cq_ring)) ··· 265 267 major_err = (u32)(FIELD_GET(IRDMA_CQ_MAJERR, qword3)); 266 268 minor_err = (u32)(FIELD_GET(IRDMA_CQ_MINERR, qword3)); 267 269 info->compl_error = major_err << 16 | minor_err; 268 - return IRDMA_ERR_CQ_COMPL_ERROR; 270 + return -EIO; 269 271 } 270 272 271 273 get_64bit_val(cqe, 0, &qword0); ··· 317 319 * @cq: cq getting interrupt 318 320 * @compl_err: return any completion err 319 321 */ 320 - enum irdma_status_code irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, 321 - struct irdma_sc_cq *cq, 322 - u32 *compl_err) 322 + int irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq, 323 + u32 *compl_err) 323 324 { 324 325 struct irdma_qp_uk *qp; 325 326 struct irdma_cq_uk *cq_uk = &cq->cq_uk; 326 327 struct irdma_puda_cmpl_info info = {}; 327 - enum irdma_status_code ret = 0; 328 + int ret = 0; 328 329 struct irdma_puda_buf *buf; 329 330 struct irdma_puda_rsrc *rsrc; 330 331 u8 cq_type = cq->cq_type; ··· 334 337 cq->vsi->ieq; 335 338 } else { 336 339 ibdev_dbg(to_ibdev(dev), "PUDA: qp_type error\n"); 337 - return IRDMA_ERR_BAD_PTR; 340 + return -EINVAL; 338 341 } 339 342 340 343 ret = irdma_puda_poll_info(cq, &info); 341 344 *compl_err = info.compl_error; 342 - if (ret == IRDMA_ERR_Q_EMPTY) 345 + if (ret == -ENOENT) 343 346 return ret; 344 347 if (ret) 345 348 goto done; 346 349 347 350 qp = info.qp; 348 351 if (!qp || !rsrc) { 349 - ret = IRDMA_ERR_BAD_PTR; 352 + ret = -EFAULT; 350 353 goto done; 351 354 } 352 355 353 356 if (qp->qp_id != rsrc->qp_id) { 354 - ret = IRDMA_ERR_BAD_PTR; 357 + ret = -EFAULT; 355 358 goto done; 356 359 } 357 360 ··· 419 422 * @qp: puda qp for send 420 423 * @info: buffer information for transmit 421 424 */ 422 - enum irdma_status_code irdma_puda_send(struct irdma_sc_qp *qp, 423 - struct irdma_puda_send_info *info) 425 + int irdma_puda_send(struct irdma_sc_qp *qp, struct irdma_puda_send_info *info) 424 426 { 425 427 __le64 *wqe; 426 428 u32 iplen, l4len; ··· 439 443 440 444 wqe = irdma_puda_get_next_send_wqe(&qp->qp_uk, &wqe_idx); 441 445 if (!wqe) 442 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 446 + return -ENOMEM; 443 447 444 448 qp->qp_uk.sq_wrtrk_array[wqe_idx].wrid = (uintptr_t)info->scratch; 445 449 /* Third line of WQE descriptor */ ··· 499 503 struct irdma_puda_buf *buf) 500 504 { 501 505 struct irdma_puda_send_info info; 502 - enum irdma_status_code ret = 0; 506 + int ret = 0; 503 507 unsigned long flags; 504 508 505 509 spin_lock_irqsave(&rsrc->bufpool_lock, flags); ··· 599 603 * @dev: Device 600 604 * @qp: Resource qp 601 605 */ 602 - static enum irdma_status_code irdma_puda_qp_wqe(struct irdma_sc_dev *dev, 603 - struct irdma_sc_qp *qp) 606 + static int irdma_puda_qp_wqe(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) 604 607 { 605 608 struct irdma_sc_cqp *cqp; 606 609 __le64 *wqe; 607 610 u64 hdr; 608 611 struct irdma_ccq_cqe_info compl_info; 609 - enum irdma_status_code status = 0; 612 + int status = 0; 610 613 611 614 cqp = dev->cqp; 612 615 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, 0); 613 616 if (!wqe) 614 - return IRDMA_ERR_RING_FULL; 617 + return -ENOMEM; 615 618 616 619 set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); 617 620 set_64bit_val(wqe, 40, qp->shadow_area_pa); ··· 638 643 * irdma_puda_qp_create - create qp for resource 639 644 * @rsrc: resource to use for buffer 640 645 */ 641 - static enum irdma_status_code irdma_puda_qp_create(struct irdma_puda_rsrc *rsrc) 646 + static int irdma_puda_qp_create(struct irdma_puda_rsrc *rsrc) 642 647 { 643 648 struct irdma_sc_qp *qp = &rsrc->qp; 644 649 struct irdma_qp_uk *ukqp = &qp->qp_uk; 645 - enum irdma_status_code ret = 0; 650 + int ret = 0; 646 651 u32 sq_size, rq_size; 647 652 struct irdma_dma_mem *mem; 648 653 ··· 654 659 rsrc->qpmem.size, &rsrc->qpmem.pa, 655 660 GFP_KERNEL); 656 661 if (!rsrc->qpmem.va) 657 - return IRDMA_ERR_NO_MEMORY; 662 + return -ENOMEM; 658 663 659 664 mem = &rsrc->qpmem; 660 665 memset(mem->va, 0, rsrc->qpmem.size); ··· 717 722 * @dev: Device 718 723 * @cq: resource for cq 719 724 */ 720 - static enum irdma_status_code irdma_puda_cq_wqe(struct irdma_sc_dev *dev, 721 - struct irdma_sc_cq *cq) 725 + static int irdma_puda_cq_wqe(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq) 722 726 { 723 727 __le64 *wqe; 724 728 struct irdma_sc_cqp *cqp; 725 729 u64 hdr; 726 730 struct irdma_ccq_cqe_info compl_info; 727 - enum irdma_status_code status = 0; 731 + int status = 0; 728 732 729 733 cqp = dev->cqp; 730 734 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, 0); 731 735 if (!wqe) 732 - return IRDMA_ERR_RING_FULL; 736 + return -ENOMEM; 733 737 734 738 set_64bit_val(wqe, 0, cq->cq_uk.cq_size); 735 739 set_64bit_val(wqe, 8, (uintptr_t)cq >> 1); ··· 769 775 * irdma_puda_cq_create - create cq for resource 770 776 * @rsrc: resource for which cq to create 771 777 */ 772 - static enum irdma_status_code irdma_puda_cq_create(struct irdma_puda_rsrc *rsrc) 778 + static int irdma_puda_cq_create(struct irdma_puda_rsrc *rsrc) 773 779 { 774 780 struct irdma_sc_dev *dev = rsrc->dev; 775 781 struct irdma_sc_cq *cq = &rsrc->cq; 776 - enum irdma_status_code ret = 0; 782 + int ret = 0; 777 783 u32 cqsize; 778 784 struct irdma_dma_mem *mem; 779 785 struct irdma_cq_init_info info = {}; ··· 786 792 rsrc->cqmem.va = dma_alloc_coherent(dev->hw->device, rsrc->cqmem.size, 787 793 &rsrc->cqmem.pa, GFP_KERNEL); 788 794 if (!rsrc->cqmem.va) 789 - return IRDMA_ERR_NO_MEMORY; 795 + return -ENOMEM; 790 796 791 797 mem = &rsrc->cqmem; 792 798 info.dev = dev; ··· 827 833 */ 828 834 static void irdma_puda_free_qp(struct irdma_puda_rsrc *rsrc) 829 835 { 830 - enum irdma_status_code ret; 836 + int ret; 831 837 struct irdma_ccq_cqe_info compl_info; 832 838 struct irdma_sc_dev *dev = rsrc->dev; 833 839 ··· 859 865 */ 860 866 static void irdma_puda_free_cq(struct irdma_puda_rsrc *rsrc) 861 867 { 862 - enum irdma_status_code ret; 868 + int ret; 863 869 struct irdma_ccq_cqe_info compl_info; 864 870 struct irdma_sc_dev *dev = rsrc->dev; 865 871 ··· 961 967 * @rsrc: resource for buffer allocation 962 968 * @count: number of buffers to create 963 969 */ 964 - static enum irdma_status_code irdma_puda_allocbufs(struct irdma_puda_rsrc *rsrc, 965 - u32 count) 970 + static int irdma_puda_allocbufs(struct irdma_puda_rsrc *rsrc, u32 count) 966 971 { 967 972 u32 i; 968 973 struct irdma_puda_buf *buf; ··· 971 978 buf = irdma_puda_alloc_buf(rsrc->dev, rsrc->buf_size); 972 979 if (!buf) { 973 980 rsrc->stats_buf_alloc_fail++; 974 - return IRDMA_ERR_NO_MEMORY; 981 + return -ENOMEM; 975 982 } 976 983 irdma_puda_ret_bufpool(rsrc, buf); 977 984 rsrc->alloc_buf_count++; ··· 994 1001 * @vsi: sc VSI struct 995 1002 * @info: resource information 996 1003 */ 997 - enum irdma_status_code irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, 998 - struct irdma_puda_rsrc_info *info) 1004 + int irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, 1005 + struct irdma_puda_rsrc_info *info) 999 1006 { 1000 1007 struct irdma_sc_dev *dev = vsi->dev; 1001 - enum irdma_status_code ret = 0; 1008 + int ret = 0; 1002 1009 struct irdma_puda_rsrc *rsrc; 1003 1010 u32 pudasize; 1004 1011 u32 sqwridsize, rqwridsize; ··· 1016 1023 vmem = &vsi->ieq_mem; 1017 1024 break; 1018 1025 default: 1019 - return IRDMA_NOT_SUPPORTED; 1026 + return -EOPNOTSUPP; 1020 1027 } 1021 1028 vmem->size = pudasize + sqwridsize + rqwridsize; 1022 1029 vmem->va = kzalloc(vmem->size, GFP_KERNEL); 1023 1030 if (!vmem->va) 1024 - return IRDMA_ERR_NO_MEMORY; 1031 + return -ENOMEM; 1025 1032 1026 1033 rsrc = vmem->va; 1027 1034 spin_lock_init(&rsrc->bufpool_lock); ··· 1039 1046 rsrc->xmit_complete = irdma_ieq_tx_compl; 1040 1047 break; 1041 1048 default: 1042 - return IRDMA_NOT_SUPPORTED; 1049 + return -EOPNOTSUPP; 1043 1050 } 1044 1051 1045 1052 rsrc->type = info->type; ··· 1316 1323 * @buf: first receive buffer 1317 1324 * @fpdu_len: total length of fpdu 1318 1325 */ 1319 - static enum irdma_status_code 1320 - irdma_ieq_create_pbufl(struct irdma_pfpdu *pfpdu, struct list_head *rxlist, 1321 - struct list_head *pbufl, struct irdma_puda_buf *buf, 1322 - u16 fpdu_len) 1326 + static int irdma_ieq_create_pbufl(struct irdma_pfpdu *pfpdu, 1327 + struct list_head *rxlist, 1328 + struct list_head *pbufl, 1329 + struct irdma_puda_buf *buf, u16 fpdu_len) 1323 1330 { 1324 - enum irdma_status_code status = 0; 1331 + int status = 0; 1325 1332 struct irdma_puda_buf *nextbuf; 1326 1333 u32 nextseqnum; 1327 1334 u16 plen = fpdu_len - buf->datalen; ··· 1331 1338 do { 1332 1339 nextbuf = irdma_puda_get_listbuf(rxlist); 1333 1340 if (!nextbuf) { 1334 - status = IRDMA_ERR_list_empty; 1341 + status = -ENOBUFS; 1335 1342 break; 1336 1343 } 1337 1344 list_add_tail(&nextbuf->list, pbufl); 1338 1345 if (nextbuf->seqnum != nextseqnum) { 1339 1346 pfpdu->bad_seq_num++; 1340 - status = IRDMA_ERR_SEQ_NUM; 1347 + status = -ERANGE; 1341 1348 break; 1342 1349 } 1343 1350 if (nextbuf->datalen >= plen) { ··· 1359 1366 * @buf: receive buffer 1360 1367 * @fpdu_len: fpdu len in the buffer 1361 1368 */ 1362 - static enum irdma_status_code 1363 - irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, struct irdma_pfpdu *pfpdu, 1364 - struct irdma_puda_buf *buf, u16 fpdu_len) 1369 + static int irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, 1370 + struct irdma_pfpdu *pfpdu, 1371 + struct irdma_puda_buf *buf, u16 fpdu_len) 1365 1372 { 1366 - enum irdma_status_code status = 0; 1373 + int status = 0; 1367 1374 u8 *crcptr; 1368 1375 u32 mpacrc; 1369 1376 u32 seqnum = buf->seqnum; ··· 1383 1390 txbuf = irdma_puda_get_bufpool(ieq); 1384 1391 if (!txbuf) { 1385 1392 pfpdu->no_tx_bufs++; 1386 - status = IRDMA_ERR_NO_TXBUFS; 1393 + status = -ENOBUFS; 1387 1394 goto error; 1388 1395 } 1389 1396 ··· 1427 1434 * @pfpdu: partial management per user qp 1428 1435 * @buf: receive buffer 1429 1436 */ 1430 - static enum irdma_status_code irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, 1431 - struct irdma_pfpdu *pfpdu, 1432 - struct irdma_puda_buf *buf) 1437 + static int irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, 1438 + struct irdma_pfpdu *pfpdu, 1439 + struct irdma_puda_buf *buf) 1433 1440 { 1434 1441 u16 fpdu_len = 0; 1435 1442 u16 datalen = buf->datalen; ··· 1443 1450 bool partial = false; 1444 1451 struct irdma_puda_buf *txbuf; 1445 1452 struct list_head *rxlist = &pfpdu->rxlist; 1446 - enum irdma_status_code ret = 0; 1453 + int ret = 0; 1447 1454 1448 1455 ioffset = (u16)(buf->data - (u8 *)buf->mem.va); 1449 1456 while (datalen) { ··· 1452 1459 ibdev_dbg(to_ibdev(ieq->dev), 1453 1460 "IEQ: error bad fpdu len\n"); 1454 1461 list_add(&buf->list, rxlist); 1455 - return IRDMA_ERR_MPA_CRC; 1462 + return -EINVAL; 1456 1463 } 1457 1464 1458 1465 if (datalen < fpdu_len) { ··· 1468 1475 list_add(&buf->list, rxlist); 1469 1476 ibdev_dbg(to_ibdev(ieq->dev), 1470 1477 "ERR: IRDMA_ERR_MPA_CRC\n"); 1471 - return IRDMA_ERR_MPA_CRC; 1478 + return -EINVAL; 1472 1479 } 1473 1480 full++; 1474 1481 pfpdu->fpdu_processed++; ··· 1483 1490 if (!txbuf) { 1484 1491 pfpdu->no_tx_bufs++; 1485 1492 list_add(&buf->list, rxlist); 1486 - return IRDMA_ERR_NO_TXBUFS; 1493 + return -ENOBUFS; 1487 1494 } 1488 1495 /* modify txbuf's buffer header */ 1489 1496 irdma_ieq_setup_tx_buf(buf, txbuf); ··· 1532 1539 struct irdma_pfpdu *pfpdu = &qp->pfpdu; 1533 1540 struct list_head *rxlist = &pfpdu->rxlist; 1534 1541 struct irdma_puda_buf *buf; 1535 - enum irdma_status_code status; 1542 + int status; 1536 1543 1537 1544 do { 1538 1545 if (list_empty(rxlist)) ··· 1550 1557 } 1551 1558 /* keep processing buffers from the head of the list */ 1552 1559 status = irdma_ieq_process_buf(ieq, pfpdu, buf); 1553 - if (status == IRDMA_ERR_MPA_CRC) { 1560 + if (status == -EINVAL) { 1554 1561 pfpdu->mpa_crc_err = true; 1555 1562 while (!list_empty(rxlist)) { 1556 1563 buf = irdma_puda_get_listbuf(rxlist); ··· 1569 1576 * @qp: qp pointer 1570 1577 * @buf: buf received on IEQ used to create AH 1571 1578 */ 1572 - static enum irdma_status_code irdma_ieq_create_ah(struct irdma_sc_qp *qp, 1573 - struct irdma_puda_buf *buf) 1579 + static int irdma_ieq_create_ah(struct irdma_sc_qp *qp, struct irdma_puda_buf *buf) 1574 1580 { 1575 1581 struct irdma_ah_info ah_info = {}; 1576 1582
+17 -26
drivers/infiniband/hw/irdma/puda.h
··· 151 151 struct irdma_puda_buf *buf); 152 152 void irdma_puda_send_buf(struct irdma_puda_rsrc *rsrc, 153 153 struct irdma_puda_buf *buf); 154 - enum irdma_status_code irdma_puda_send(struct irdma_sc_qp *qp, 155 - struct irdma_puda_send_info *info); 156 - enum irdma_status_code 157 - irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, 158 - struct irdma_puda_rsrc_info *info); 154 + int irdma_puda_send(struct irdma_sc_qp *qp, struct irdma_puda_send_info *info); 155 + int irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, 156 + struct irdma_puda_rsrc_info *info); 159 157 void irdma_puda_dele_rsrc(struct irdma_sc_vsi *vsi, enum puda_rsrc_type type, 160 158 bool reset); 161 - enum irdma_status_code irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, 162 - struct irdma_sc_cq *cq, 163 - u32 *compl_err); 159 + int irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq, 160 + u32 *compl_err); 164 161 165 162 struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev, 166 163 struct irdma_puda_buf *buf); 167 - enum irdma_status_code 168 - irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 169 - struct irdma_puda_buf *buf); 170 - enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc, 171 - void *addr, u32 len, u32 val); 172 - enum irdma_status_code irdma_init_hash_desc(struct shash_desc **desc); 164 + int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 165 + struct irdma_puda_buf *buf); 166 + int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len, u32 val); 167 + int irdma_init_hash_desc(struct shash_desc **desc); 173 168 void irdma_ieq_mpa_crc_ae(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); 174 169 void irdma_free_hash_desc(struct shash_desc *desc); 175 - void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, 176 - u32 seqnum); 177 - enum irdma_status_code irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, 178 - struct irdma_sc_qp *qp); 179 - enum irdma_status_code irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, 180 - struct irdma_sc_cq *cq); 181 - enum irdma_status_code irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); 170 + void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, u32 seqnum); 171 + int irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); 172 + int irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq); 173 + int irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); 182 174 void irdma_cqp_cq_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq); 183 175 void irdma_puda_ieq_get_ah_info(struct irdma_sc_qp *qp, 184 176 struct irdma_ah_info *ah_info); 185 - enum irdma_status_code irdma_puda_create_ah(struct irdma_sc_dev *dev, 186 - struct irdma_ah_info *ah_info, 187 - bool wait, enum puda_rsrc_type type, 188 - void *cb_param, 189 - struct irdma_sc_ah **ah); 177 + int irdma_puda_create_ah(struct irdma_sc_dev *dev, 178 + struct irdma_ah_info *ah_info, bool wait, 179 + enum puda_rsrc_type type, void *cb_param, 180 + struct irdma_sc_ah **ah); 190 181 void irdma_puda_free_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah); 191 182 void irdma_ieq_process_fpdus(struct irdma_sc_qp *qp, 192 183 struct irdma_puda_rsrc *ieq);
-71
drivers/infiniband/hw/irdma/status.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB */ 2 - /* Copyright (c) 2015 - 2020 Intel Corporation */ 3 - #ifndef IRDMA_STATUS_H 4 - #define IRDMA_STATUS_H 5 - 6 - /* Error Codes */ 7 - enum irdma_status_code { 8 - IRDMA_SUCCESS = 0, 9 - IRDMA_ERR_NVM = -1, 10 - IRDMA_ERR_NVM_CHECKSUM = -2, 11 - IRDMA_ERR_CFG = -4, 12 - IRDMA_ERR_PARAM = -5, 13 - IRDMA_ERR_DEVICE_NOT_SUPPORTED = -6, 14 - IRDMA_ERR_RESET_FAILED = -7, 15 - IRDMA_ERR_SWFW_SYNC = -8, 16 - IRDMA_ERR_NO_MEMORY = -9, 17 - IRDMA_ERR_BAD_PTR = -10, 18 - IRDMA_ERR_INVALID_PD_ID = -11, 19 - IRDMA_ERR_INVALID_QP_ID = -12, 20 - IRDMA_ERR_INVALID_CQ_ID = -13, 21 - IRDMA_ERR_INVALID_CEQ_ID = -14, 22 - IRDMA_ERR_INVALID_AEQ_ID = -15, 23 - IRDMA_ERR_INVALID_SIZE = -16, 24 - IRDMA_ERR_INVALID_ARP_INDEX = -17, 25 - IRDMA_ERR_INVALID_FPM_FUNC_ID = -18, 26 - IRDMA_ERR_QP_INVALID_MSG_SIZE = -19, 27 - IRDMA_ERR_QP_TOOMANY_WRS_POSTED = -20, 28 - IRDMA_ERR_INVALID_FRAG_COUNT = -21, 29 - IRDMA_ERR_Q_EMPTY = -22, 30 - IRDMA_ERR_INVALID_ALIGNMENT = -23, 31 - IRDMA_ERR_FLUSHED_Q = -24, 32 - IRDMA_ERR_INVALID_PUSH_PAGE_INDEX = -25, 33 - IRDMA_ERR_INVALID_INLINE_DATA_SIZE = -26, 34 - IRDMA_ERR_TIMEOUT = -27, 35 - IRDMA_ERR_OPCODE_MISMATCH = -28, 36 - IRDMA_ERR_CQP_COMPL_ERROR = -29, 37 - IRDMA_ERR_INVALID_VF_ID = -30, 38 - IRDMA_ERR_INVALID_HMCFN_ID = -31, 39 - IRDMA_ERR_BACKING_PAGE_ERROR = -32, 40 - IRDMA_ERR_NO_PBLCHUNKS_AVAILABLE = -33, 41 - IRDMA_ERR_INVALID_PBLE_INDEX = -34, 42 - IRDMA_ERR_INVALID_SD_INDEX = -35, 43 - IRDMA_ERR_INVALID_PAGE_DESC_INDEX = -36, 44 - IRDMA_ERR_INVALID_SD_TYPE = -37, 45 - IRDMA_ERR_MEMCPY_FAILED = -38, 46 - IRDMA_ERR_INVALID_HMC_OBJ_INDEX = -39, 47 - IRDMA_ERR_INVALID_HMC_OBJ_COUNT = -40, 48 - IRDMA_ERR_BUF_TOO_SHORT = -43, 49 - IRDMA_ERR_BAD_IWARP_CQE = -44, 50 - IRDMA_ERR_NVM_BLANK_MODE = -45, 51 - IRDMA_ERR_NOT_IMPL = -46, 52 - IRDMA_ERR_PE_DOORBELL_NOT_ENA = -47, 53 - IRDMA_ERR_NOT_READY = -48, 54 - IRDMA_NOT_SUPPORTED = -49, 55 - IRDMA_ERR_FIRMWARE_API_VER = -50, 56 - IRDMA_ERR_RING_FULL = -51, 57 - IRDMA_ERR_MPA_CRC = -61, 58 - IRDMA_ERR_NO_TXBUFS = -62, 59 - IRDMA_ERR_SEQ_NUM = -63, 60 - IRDMA_ERR_list_empty = -64, 61 - IRDMA_ERR_INVALID_MAC_ADDR = -65, 62 - IRDMA_ERR_BAD_STAG = -66, 63 - IRDMA_ERR_CQ_COMPL_ERROR = -67, 64 - IRDMA_ERR_Q_DESTROYED = -68, 65 - IRDMA_ERR_INVALID_FEAT_CNT = -69, 66 - IRDMA_ERR_REG_CQ_FULL = -70, 67 - IRDMA_ERR_VF_MSG_ERROR = -71, 68 - IRDMA_ERR_NO_INTR = -72, 69 - IRDMA_ERR_REG_QSET = -73, 70 - }; 71 - #endif /* IRDMA_STATUS_H */
+52 -57
drivers/infiniband/hw/irdma/type.h
··· 2 2 /* Copyright (c) 2015 - 2021 Intel Corporation */ 3 3 #ifndef IRDMA_TYPE_H 4 4 #define IRDMA_TYPE_H 5 - #include "status.h" 6 5 #include "osdep.h" 7 6 #include "irdma.h" 8 7 #include "user.h" ··· 401 402 u64 host_ctx_pa; 402 403 void *back_cqp; 403 404 struct irdma_sc_dev *dev; 404 - enum irdma_status_code (*process_cqp_sds)(struct irdma_sc_dev *dev, 405 - struct irdma_update_sds_info *info); 405 + int (*process_cqp_sds)(struct irdma_sc_dev *dev, 406 + struct irdma_update_sds_info *info); 406 407 struct irdma_dma_mem sdbuf; 407 408 struct irdma_ring sq_ring; 408 409 struct irdma_cqp_quanta *sq_base; ··· 604 605 struct irdma_qos qos[IRDMA_MAX_USER_PRIORITY]; 605 606 struct irdma_vsi_pestat *pestat; 606 607 atomic_t qp_suspend_reqs; 607 - enum irdma_status_code (*register_qset)(struct irdma_sc_vsi *vsi, 608 - struct irdma_ws_node *tc_node); 608 + int (*register_qset)(struct irdma_sc_vsi *vsi, 609 + struct irdma_ws_node *tc_node); 609 610 void (*unregister_qset)(struct irdma_sc_vsi *vsi, 610 611 struct irdma_ws_node *tc_node); 611 612 u8 qos_rel_bw; 612 613 u8 qos_prio_type; 614 + u8 dscp_map[IIDC_MAX_DSCP_MAPPING]; 615 + bool dscp_mode:1; 613 616 }; 614 617 615 618 struct irdma_sc_dev { ··· 656 655 bool vchnl_up:1; 657 656 bool ceq_valid:1; 658 657 u8 pci_rev; 659 - enum irdma_status_code (*ws_add)(struct irdma_sc_vsi *vsi, u8 user_pri); 658 + int (*ws_add)(struct irdma_sc_vsi *vsi, u8 user_pri); 660 659 void (*ws_remove)(struct irdma_sc_vsi *vsi, u8 user_pri); 661 660 void (*ws_reset)(struct irdma_sc_vsi *vsi); 662 661 }; ··· 736 735 u16 qs_handle_list[IRDMA_MAX_USER_PRIORITY]; 737 736 u16 mtu; 738 737 u8 up2tc[IRDMA_MAX_USER_PRIORITY]; 738 + u8 dscp_map[IIDC_MAX_DSCP_MAPPING]; 739 739 u8 num_tc; 740 740 u8 vsi_rel_bw; 741 741 u8 vsi_prio_type; 742 742 bool mtu_changed:1; 743 743 bool tc_changed:1; 744 + bool dscp_mode:1; 744 745 }; 745 746 746 747 struct irdma_vsi_init_info { ··· 753 750 u16 pf_data_vsi_num; 754 751 enum irdma_vm_vf_type vm_vf_type; 755 752 u16 vm_id; 756 - enum irdma_status_code (*register_qset)(struct irdma_sc_vsi *vsi, 757 - struct irdma_ws_node *tc_node); 753 + int (*register_qset)(struct irdma_sc_vsi *vsi, 754 + struct irdma_ws_node *tc_node); 758 755 void (*unregister_qset)(struct irdma_sc_vsi *vsi, 759 756 struct irdma_ws_node *tc_node); 760 757 }; ··· 1201 1198 }; 1202 1199 1203 1200 void irdma_sc_ccq_arm(struct irdma_sc_cq *ccq); 1204 - enum irdma_status_code irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, 1205 - bool check_overflow, bool post_sq); 1206 - enum irdma_status_code irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, 1207 - bool post_sq); 1208 - enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, 1209 - struct irdma_ccq_cqe_info *info); 1210 - enum irdma_status_code irdma_sc_ccq_init(struct irdma_sc_cq *ccq, 1211 - struct irdma_ccq_init_info *info); 1201 + int irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, 1202 + bool check_overflow, bool post_sq); 1203 + int irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, bool post_sq); 1204 + int irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, 1205 + struct irdma_ccq_cqe_info *info); 1206 + int irdma_sc_ccq_init(struct irdma_sc_cq *ccq, 1207 + struct irdma_ccq_init_info *info); 1212 1208 1213 - enum irdma_status_code irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch); 1214 - enum irdma_status_code irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq); 1209 + int irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch); 1210 + int irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq); 1215 1211 1216 - enum irdma_status_code irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, 1217 - bool post_sq); 1218 - enum irdma_status_code irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, 1219 - struct irdma_ceq_init_info *info); 1212 + int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq); 1213 + int irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, 1214 + struct irdma_ceq_init_info *info); 1220 1215 void irdma_sc_cleanup_ceqes(struct irdma_sc_cq *cq, struct irdma_sc_ceq *ceq); 1221 1216 void *irdma_sc_process_ceq(struct irdma_sc_dev *dev, struct irdma_sc_ceq *ceq); 1222 1217 1223 - enum irdma_status_code irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, 1224 - struct irdma_aeq_init_info *info); 1225 - enum irdma_status_code irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, 1226 - struct irdma_aeqe_info *info); 1218 + int irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, 1219 + struct irdma_aeq_init_info *info); 1220 + int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, 1221 + struct irdma_aeqe_info *info); 1227 1222 void irdma_sc_repost_aeq_entries(struct irdma_sc_dev *dev, u32 count); 1228 1223 1229 1224 void irdma_sc_pd_init(struct irdma_sc_dev *dev, struct irdma_sc_pd *pd, u32 pd_id, ··· 1229 1228 void irdma_cfg_aeq(struct irdma_sc_dev *dev, u32 idx, bool enable); 1230 1229 void irdma_check_cqp_progress(struct irdma_cqp_timeout *cqp_timeout, 1231 1230 struct irdma_sc_dev *dev); 1232 - enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, 1233 - u16 *min_err); 1234 - enum irdma_status_code irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp); 1235 - enum irdma_status_code irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, 1236 - struct irdma_cqp_init_info *info); 1231 + int irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, u16 *min_err); 1232 + int irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp); 1233 + int irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, 1234 + struct irdma_cqp_init_info *info); 1237 1235 void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp); 1238 - enum irdma_status_code irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 opcode, 1239 - struct irdma_ccq_cqe_info *cmpl_info); 1240 - enum irdma_status_code irdma_sc_fast_register(struct irdma_sc_qp *qp, 1241 - struct irdma_fast_reg_stag_info *info, 1242 - bool post_sq); 1243 - enum irdma_status_code irdma_sc_qp_create(struct irdma_sc_qp *qp, 1244 - struct irdma_create_qp_info *info, 1245 - u64 scratch, bool post_sq); 1246 - enum irdma_status_code irdma_sc_qp_destroy(struct irdma_sc_qp *qp, 1247 - u64 scratch, bool remove_hash_idx, 1248 - bool ignore_mw_bnd, bool post_sq); 1249 - enum irdma_status_code irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, 1250 - struct irdma_qp_flush_info *info, 1251 - u64 scratch, bool post_sq); 1252 - enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, 1253 - struct irdma_qp_init_info *info); 1254 - enum irdma_status_code irdma_sc_qp_modify(struct irdma_sc_qp *qp, 1255 - struct irdma_modify_qp_info *info, 1256 - u64 scratch, bool post_sq); 1236 + int irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 opcode, 1237 + struct irdma_ccq_cqe_info *cmpl_info); 1238 + int irdma_sc_fast_register(struct irdma_sc_qp *qp, 1239 + struct irdma_fast_reg_stag_info *info, bool post_sq); 1240 + int irdma_sc_qp_create(struct irdma_sc_qp *qp, 1241 + struct irdma_create_qp_info *info, u64 scratch, 1242 + bool post_sq); 1243 + int irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, 1244 + bool remove_hash_idx, bool ignore_mw_bnd, bool post_sq); 1245 + int irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, 1246 + struct irdma_qp_flush_info *info, u64 scratch, 1247 + bool post_sq); 1248 + int irdma_sc_qp_init(struct irdma_sc_qp *qp, struct irdma_qp_init_info *info); 1249 + int irdma_sc_qp_modify(struct irdma_sc_qp *qp, 1250 + struct irdma_modify_qp_info *info, u64 scratch, 1251 + bool post_sq); 1257 1252 void irdma_sc_send_lsmm(struct irdma_sc_qp *qp, void *lsmm_buf, u32 size, 1258 1253 irdma_stag stag); 1259 1254 ··· 1258 1261 struct irdma_qp_host_ctx_info *info); 1259 1262 void irdma_sc_qp_setctx_roce(struct irdma_sc_qp *qp, __le64 *qp_ctx, 1260 1263 struct irdma_qp_host_ctx_info *info); 1261 - enum irdma_status_code irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, 1262 - bool post_sq); 1263 - enum irdma_status_code irdma_sc_cq_init(struct irdma_sc_cq *cq, 1264 - struct irdma_cq_init_info *info); 1264 + int irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, bool post_sq); 1265 + int irdma_sc_cq_init(struct irdma_sc_cq *cq, struct irdma_cq_init_info *info); 1265 1266 void irdma_sc_cq_resize(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *info); 1266 - enum irdma_status_code irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, 1267 - u64 scratch, u8 hmc_fn_id, 1268 - bool post_sq, bool poll_registers); 1267 + int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, 1268 + u8 hmc_fn_id, bool post_sq, 1269 + bool poll_registers); 1269 1270 1270 1271 void sc_vsi_update_stats(struct irdma_sc_vsi *vsi); 1271 1272 struct cqp_info {
+16 -24
drivers/infiniband/hw/irdma/uda.c
··· 3 3 #include <linux/etherdevice.h> 4 4 5 5 #include "osdep.h" 6 - #include "status.h" 7 6 #include "hmc.h" 8 7 #include "defs.h" 9 8 #include "type.h" ··· 17 18 * @op: Operation 18 19 * @scratch: u64 saved to be used during cqp completion 19 20 */ 20 - enum irdma_status_code irdma_sc_access_ah(struct irdma_sc_cqp *cqp, 21 - struct irdma_ah_info *info, 22 - u32 op, u64 scratch) 21 + int irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info, 22 + u32 op, u64 scratch) 23 23 { 24 24 __le64 *wqe; 25 25 u64 qw1, qw2; 26 26 27 27 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 28 28 if (!wqe) 29 - return IRDMA_ERR_RING_FULL; 29 + return -ENOMEM; 30 30 31 31 set_64bit_val(wqe, 0, ether_addr_to_u64(info->mac_addr) << 16); 32 32 qw1 = FIELD_PREP(IRDMA_UDA_CQPSQ_MAV_PDINDEXLO, info->pd_idx) | ··· 84 86 * irdma_create_mg_ctx() - create a mcg context 85 87 * @info: multicast group context info 86 88 */ 87 - static enum irdma_status_code 88 - irdma_create_mg_ctx(struct irdma_mcast_grp_info *info) 89 + static void irdma_create_mg_ctx(struct irdma_mcast_grp_info *info) 89 90 { 90 91 struct irdma_mcast_grp_ctx_entry_info *entry_info = NULL; 91 92 u8 idx = 0; /* index in the array */ ··· 103 106 ctx_idx++; 104 107 } 105 108 } 106 - 107 - return 0; 108 109 } 109 110 110 111 /** ··· 112 117 * @op: operation to perform 113 118 * @scratch: u64 saved to be used during cqp completion 114 119 */ 115 - enum irdma_status_code irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, 116 - struct irdma_mcast_grp_info *info, 117 - u32 op, u64 scratch) 120 + int irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, 121 + struct irdma_mcast_grp_info *info, u32 op, 122 + u64 scratch) 118 123 { 119 124 __le64 *wqe; 120 - enum irdma_status_code ret_code = 0; 121 125 122 126 if (info->mg_id >= IRDMA_UDA_MAX_FSI_MGS) { 123 127 ibdev_dbg(to_ibdev(cqp->dev), "WQE: mg_id out of range\n"); 124 - return IRDMA_ERR_PARAM; 128 + return -EINVAL; 125 129 } 126 130 127 131 wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); 128 132 if (!wqe) { 129 133 ibdev_dbg(to_ibdev(cqp->dev), "WQE: ring full\n"); 130 - return IRDMA_ERR_RING_FULL; 134 + return -ENOMEM; 131 135 } 132 136 133 - ret_code = irdma_create_mg_ctx(info); 134 - if (ret_code) 135 - return ret_code; 137 + irdma_create_mg_ctx(info); 136 138 137 139 set_64bit_val(wqe, 32, info->dma_mem_mc.pa); 138 140 set_64bit_val(wqe, 16, ··· 190 198 * @ctx: Multcast group context 191 199 * @mg: Multcast group info 192 200 */ 193 - enum irdma_status_code irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, 194 - struct irdma_mcast_grp_ctx_entry_info *mg) 201 + int irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, 202 + struct irdma_mcast_grp_ctx_entry_info *mg) 195 203 { 196 204 u32 idx; 197 205 bool free_entry_found = false; ··· 220 228 return 0; 221 229 } 222 230 223 - return IRDMA_ERR_NO_MEMORY; 231 + return -ENOMEM; 224 232 } 225 233 226 234 /** ··· 231 239 * Finds and removes a specific mulicast group from context, all 232 240 * parameters must match to remove a multicast group. 233 241 */ 234 - enum irdma_status_code irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, 235 - struct irdma_mcast_grp_ctx_entry_info *mg) 242 + int irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, 243 + struct irdma_mcast_grp_ctx_entry_info *mg) 236 244 { 237 245 u32 idx; 238 246 ··· 261 269 } 262 270 } 263 271 264 - return IRDMA_ERR_PARAM; 272 + return -EINVAL; 265 273 }
+22 -24
drivers/infiniband/hw/irdma/uda.h
··· 32 32 struct irdma_ah_info ah_info; 33 33 }; 34 34 35 - enum irdma_status_code irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, 36 - struct irdma_mcast_grp_ctx_entry_info *mg); 37 - enum irdma_status_code irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, 38 - struct irdma_mcast_grp_ctx_entry_info *mg); 39 - enum irdma_status_code irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info, 40 - u32 op, u64 scratch); 41 - enum irdma_status_code irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, 42 - struct irdma_mcast_grp_info *info, 43 - u32 op, u64 scratch); 35 + int irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, 36 + struct irdma_mcast_grp_ctx_entry_info *mg); 37 + int irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, 38 + struct irdma_mcast_grp_ctx_entry_info *mg); 39 + int irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info, 40 + u32 op, u64 scratch); 41 + int irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, 42 + struct irdma_mcast_grp_info *info, u32 op, 43 + u64 scratch); 44 44 45 45 static inline void irdma_sc_init_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah) 46 46 { 47 47 ah->dev = dev; 48 48 } 49 49 50 - static inline enum irdma_status_code irdma_sc_create_ah(struct irdma_sc_cqp *cqp, 51 - struct irdma_ah_info *info, 52 - u64 scratch) 50 + static inline int irdma_sc_create_ah(struct irdma_sc_cqp *cqp, 51 + struct irdma_ah_info *info, u64 scratch) 53 52 { 54 53 return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_CREATE_ADDR_HANDLE, 55 54 scratch); 56 55 } 57 56 58 - static inline enum irdma_status_code irdma_sc_destroy_ah(struct irdma_sc_cqp *cqp, 59 - struct irdma_ah_info *info, 60 - u64 scratch) 57 + static inline int irdma_sc_destroy_ah(struct irdma_sc_cqp *cqp, 58 + struct irdma_ah_info *info, u64 scratch) 61 59 { 62 60 return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_DESTROY_ADDR_HANDLE, 63 61 scratch); 64 62 } 65 63 66 - static inline enum irdma_status_code irdma_sc_create_mcast_grp(struct irdma_sc_cqp *cqp, 67 - struct irdma_mcast_grp_info *info, 68 - u64 scratch) 64 + static inline int irdma_sc_create_mcast_grp(struct irdma_sc_cqp *cqp, 65 + struct irdma_mcast_grp_info *info, 66 + u64 scratch) 69 67 { 70 68 return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_CREATE_MCAST_GRP, 71 69 scratch); 72 70 } 73 71 74 - static inline enum irdma_status_code irdma_sc_modify_mcast_grp(struct irdma_sc_cqp *cqp, 75 - struct irdma_mcast_grp_info *info, 76 - u64 scratch) 72 + static inline int irdma_sc_modify_mcast_grp(struct irdma_sc_cqp *cqp, 73 + struct irdma_mcast_grp_info *info, 74 + u64 scratch) 77 75 { 78 76 return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_MODIFY_MCAST_GRP, 79 77 scratch); 80 78 } 81 79 82 - static inline enum irdma_status_code irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp *cqp, 83 - struct irdma_mcast_grp_info *info, 84 - u64 scratch) 80 + static inline int irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp *cqp, 81 + struct irdma_mcast_grp_info *info, 82 + u64 scratch) 85 83 { 86 84 return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_DESTROY_MCAST_GRP, 87 85 scratch);
+57 -65
drivers/infiniband/hw/irdma/uk.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 2 2 /* Copyright (c) 2015 - 2021 Intel Corporation */ 3 3 #include "osdep.h" 4 - #include "status.h" 5 4 #include "defs.h" 6 5 #include "user.h" 7 6 #include "irdma.h" ··· 55 56 * irdma_nop_1 - insert a NOP wqe 56 57 * @qp: hw qp ptr 57 58 */ 58 - static enum irdma_status_code irdma_nop_1(struct irdma_qp_uk *qp) 59 + static int irdma_nop_1(struct irdma_qp_uk *qp) 59 60 { 60 61 u64 hdr; 61 62 __le64 *wqe; ··· 63 64 bool signaled = false; 64 65 65 66 if (!qp->sq_ring.head) 66 - return IRDMA_ERR_PARAM; 67 + return -EINVAL; 67 68 68 69 wqe_idx = IRDMA_RING_CURRENT_HEAD(qp->sq_ring); 69 70 wqe = qp->sq_base[wqe_idx].elem; ··· 244 245 __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx) 245 246 { 246 247 __le64 *wqe; 247 - enum irdma_status_code ret_code; 248 + int ret_code; 248 249 249 250 if (IRDMA_RING_FULL_ERR(qp->rq_ring)) 250 251 return NULL; ··· 267 268 * @info: post sq information 268 269 * @post_sq: flag to post sq 269 270 */ 270 - enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, 271 - struct irdma_post_sq_info *info, 272 - bool post_sq) 271 + int irdma_uk_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 272 + bool post_sq) 273 273 { 274 274 u64 hdr; 275 275 __le64 *wqe; 276 276 struct irdma_rdma_write *op_info; 277 277 u32 i, wqe_idx; 278 278 u32 total_size = 0, byte_off; 279 - enum irdma_status_code ret_code; 279 + int ret_code; 280 280 u32 frag_cnt, addl_frag_cnt; 281 281 bool read_fence = false; 282 282 u16 quanta; ··· 284 286 285 287 op_info = &info->op.rdma_write; 286 288 if (op_info->num_lo_sges > qp->max_sq_frag_cnt) 287 - return IRDMA_ERR_INVALID_FRAG_COUNT; 289 + return -EINVAL; 288 290 289 291 for (i = 0; i < op_info->num_lo_sges; i++) 290 292 total_size += op_info->lo_sg_list[i].length; ··· 303 305 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, 304 306 info); 305 307 if (!wqe) 306 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 308 + return -ENOMEM; 307 309 308 310 irdma_clr_wqes(qp, wqe_idx); 309 311 ··· 368 370 * @inv_stag: flag for inv_stag 369 371 * @post_sq: flag to post sq 370 372 */ 371 - enum irdma_status_code irdma_uk_rdma_read(struct irdma_qp_uk *qp, 372 - struct irdma_post_sq_info *info, 373 - bool inv_stag, bool post_sq) 373 + int irdma_uk_rdma_read(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 374 + bool inv_stag, bool post_sq) 374 375 { 375 376 struct irdma_rdma_read *op_info; 376 - enum irdma_status_code ret_code; 377 + int ret_code; 377 378 u32 i, byte_off, total_size = 0; 378 379 bool local_fence = false; 379 380 u32 addl_frag_cnt; ··· 385 388 386 389 op_info = &info->op.rdma_read; 387 390 if (qp->max_sq_frag_cnt < op_info->num_lo_sges) 388 - return IRDMA_ERR_INVALID_FRAG_COUNT; 391 + return -EINVAL; 389 392 390 393 for (i = 0; i < op_info->num_lo_sges; i++) 391 394 total_size += op_info->lo_sg_list[i].length; ··· 397 400 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, 398 401 info); 399 402 if (!wqe) 400 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 403 + return -ENOMEM; 401 404 402 405 irdma_clr_wqes(qp, wqe_idx); 403 406 ··· 454 457 * @info: post sq information 455 458 * @post_sq: flag to post sq 456 459 */ 457 - enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp, 458 - struct irdma_post_sq_info *info, 459 - bool post_sq) 460 + int irdma_uk_send(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 461 + bool post_sq) 460 462 { 461 463 __le64 *wqe; 462 464 struct irdma_post_send *op_info; 463 465 u64 hdr; 464 466 u32 i, wqe_idx, total_size = 0, byte_off; 465 - enum irdma_status_code ret_code; 467 + int ret_code; 466 468 u32 frag_cnt, addl_frag_cnt; 467 469 bool read_fence = false; 468 470 u16 quanta; ··· 470 474 471 475 op_info = &info->op.send; 472 476 if (qp->max_sq_frag_cnt < op_info->num_sges) 473 - return IRDMA_ERR_INVALID_FRAG_COUNT; 477 + return -EINVAL; 474 478 475 479 for (i = 0; i < op_info->num_sges; i++) 476 480 total_size += op_info->sg_list[i].length; ··· 486 490 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, 487 491 info); 488 492 if (!wqe) 489 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 493 + return -ENOMEM; 490 494 491 495 irdma_clr_wqes(qp, wqe_idx); 492 496 ··· 674 678 * @info: post sq information 675 679 * @post_sq: flag to post sq 676 680 */ 677 - enum irdma_status_code 678 - irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 679 - bool post_sq) 681 + int irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, 682 + struct irdma_post_sq_info *info, bool post_sq) 680 683 { 681 684 __le64 *wqe; 682 685 struct irdma_inline_rdma_write *op_info; ··· 688 693 op_info = &info->op.inline_rdma_write; 689 694 690 695 if (op_info->len > qp->max_inline_data) 691 - return IRDMA_ERR_INVALID_INLINE_DATA_SIZE; 696 + return -EINVAL; 692 697 693 698 quanta = qp->wqe_ops.iw_inline_data_size_to_quanta(op_info->len); 694 699 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, op_info->len, 695 700 info); 696 701 if (!wqe) 697 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 702 + return -ENOMEM; 698 703 699 704 irdma_clr_wqes(qp, wqe_idx); 700 705 ··· 740 745 * @info: post sq information 741 746 * @post_sq: flag to post sq 742 747 */ 743 - enum irdma_status_code irdma_uk_inline_send(struct irdma_qp_uk *qp, 744 - struct irdma_post_sq_info *info, 745 - bool post_sq) 748 + int irdma_uk_inline_send(struct irdma_qp_uk *qp, 749 + struct irdma_post_sq_info *info, bool post_sq) 746 750 { 747 751 __le64 *wqe; 748 752 struct irdma_post_inline_send *op_info; ··· 754 760 op_info = &info->op.inline_send; 755 761 756 762 if (op_info->len > qp->max_inline_data) 757 - return IRDMA_ERR_INVALID_INLINE_DATA_SIZE; 763 + return -EINVAL; 758 764 759 765 quanta = qp->wqe_ops.iw_inline_data_size_to_quanta(op_info->len); 760 766 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, op_info->len, 761 767 info); 762 768 if (!wqe) 763 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 769 + return -ENOMEM; 764 770 765 771 irdma_clr_wqes(qp, wqe_idx); 766 772 ··· 811 817 * @info: post sq information 812 818 * @post_sq: flag to post sq 813 819 */ 814 - enum irdma_status_code 815 - irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, 816 - struct irdma_post_sq_info *info, bool post_sq) 820 + int irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, 821 + struct irdma_post_sq_info *info, 822 + bool post_sq) 817 823 { 818 824 __le64 *wqe; 819 825 struct irdma_inv_local_stag *op_info; ··· 829 835 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, IRDMA_QP_WQE_MIN_QUANTA, 830 836 0, info); 831 837 if (!wqe) 832 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 838 + return -ENOMEM; 833 839 834 840 irdma_clr_wqes(qp, wqe_idx); 835 841 ··· 865 871 * @qp: hw qp ptr 866 872 * @info: post rq information 867 873 */ 868 - enum irdma_status_code irdma_uk_post_receive(struct irdma_qp_uk *qp, 869 - struct irdma_post_rq_info *info) 874 + int irdma_uk_post_receive(struct irdma_qp_uk *qp, 875 + struct irdma_post_rq_info *info) 870 876 { 871 877 u32 wqe_idx, i, byte_off; 872 878 u32 addl_frag_cnt; ··· 874 880 u64 hdr; 875 881 876 882 if (qp->max_rq_frag_cnt < info->num_sges) 877 - return IRDMA_ERR_INVALID_FRAG_COUNT; 883 + return -EINVAL; 878 884 879 885 wqe = irdma_qp_get_next_recv_wqe(qp, &wqe_idx); 880 886 if (!wqe) 881 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 887 + return -ENOMEM; 882 888 883 889 qp->rq_wrid_array[wqe_idx] = info->wr_id; 884 890 addl_frag_cnt = info->num_sges > 1 ? (info->num_sges - 1) : 0; ··· 994 1000 * @cq: hw cq 995 1001 * @info: cq poll information returned 996 1002 */ 997 - enum irdma_status_code 998 - irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) 1003 + int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, 1004 + struct irdma_cq_poll_info *info) 999 1005 { 1000 1006 u64 comp_ctx, qword0, qword2, qword3; 1001 1007 __le64 *cqe; 1002 1008 struct irdma_qp_uk *qp; 1003 1009 struct irdma_ring *pring = NULL; 1004 1010 u32 wqe_idx, q_type; 1005 - enum irdma_status_code ret_code; 1011 + int ret_code; 1006 1012 bool move_cq_head = true; 1007 1013 u8 polarity; 1008 1014 bool ext_valid; ··· 1016 1022 get_64bit_val(cqe, 24, &qword3); 1017 1023 polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3); 1018 1024 if (polarity != cq->polarity) 1019 - return IRDMA_ERR_Q_EMPTY; 1025 + return -ENOENT; 1020 1026 1021 1027 /* Ensure CQE contents are read after valid bit is checked */ 1022 1028 dma_rmb(); ··· 1039 1045 polarity ^= 1; 1040 1046 } 1041 1047 if (polarity != cq->polarity) 1042 - return IRDMA_ERR_Q_EMPTY; 1048 + return -ENOENT; 1043 1049 1044 1050 /* Ensure ext CQE contents are read after ext valid bit is checked */ 1045 1051 dma_rmb(); ··· 1106 1112 info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3); 1107 1113 qp = (struct irdma_qp_uk *)(unsigned long)comp_ctx; 1108 1114 if (!qp || qp->destroy_pending) { 1109 - ret_code = IRDMA_ERR_Q_DESTROYED; 1115 + ret_code = -EFAULT; 1110 1116 goto exit; 1111 1117 } 1112 1118 wqe_idx = (u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3); ··· 1120 1126 if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED || 1121 1127 info->comp_status == IRDMA_COMPL_STATUS_UNKNOWN) { 1122 1128 if (!IRDMA_RING_MORE_WORK(qp->rq_ring)) { 1123 - ret_code = IRDMA_ERR_Q_EMPTY; 1129 + ret_code = -ENOENT; 1124 1130 goto exit; 1125 1131 } 1126 1132 ··· 1180 1186 wqe_idx + qp->sq_wrtrk_array[wqe_idx].quanta); 1181 1187 } else { 1182 1188 if (!IRDMA_RING_MORE_WORK(qp->sq_ring)) { 1183 - ret_code = IRDMA_ERR_Q_EMPTY; 1189 + ret_code = -ENOENT; 1184 1190 goto exit; 1185 1191 } 1186 1192 ··· 1297 1303 * @sqdepth: depth of SQ 1298 1304 * 1299 1305 */ 1300 - enum irdma_status_code irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, 1301 - u32 sq_size, u8 shift, u32 *sqdepth) 1306 + int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift, 1307 + u32 *sqdepth) 1302 1308 { 1303 1309 *sqdepth = irdma_qp_round_up((sq_size << shift) + IRDMA_SQ_RSVD); 1304 1310 1305 1311 if (*sqdepth < (IRDMA_QP_SW_MIN_WQSIZE << shift)) 1306 1312 *sqdepth = IRDMA_QP_SW_MIN_WQSIZE << shift; 1307 1313 else if (*sqdepth > uk_attrs->max_hw_wq_quanta) 1308 - return IRDMA_ERR_INVALID_SIZE; 1314 + return -EINVAL; 1309 1315 1310 1316 return 0; 1311 1317 } ··· 1317 1323 * @shift: shift which determines size of WQE 1318 1324 * @rqdepth: depth of RQ 1319 1325 */ 1320 - enum irdma_status_code irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, 1321 - u32 rq_size, u8 shift, u32 *rqdepth) 1326 + int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift, 1327 + u32 *rqdepth) 1322 1328 { 1323 1329 *rqdepth = irdma_qp_round_up((rq_size << shift) + IRDMA_RQ_RSVD); 1324 1330 1325 1331 if (*rqdepth < (IRDMA_QP_SW_MIN_WQSIZE << shift)) 1326 1332 *rqdepth = IRDMA_QP_SW_MIN_WQSIZE << shift; 1327 1333 else if (*rqdepth > uk_attrs->max_hw_rq_quanta) 1328 - return IRDMA_ERR_INVALID_SIZE; 1334 + return -EINVAL; 1329 1335 1330 1336 return 0; 1331 1337 } ··· 1375 1381 * allowed. Then size of wqe * the number of wqes should be the 1376 1382 * amount of memory allocated for sq and rq. 1377 1383 */ 1378 - enum irdma_status_code irdma_uk_qp_init(struct irdma_qp_uk *qp, 1379 - struct irdma_qp_uk_init_info *info) 1384 + int irdma_uk_qp_init(struct irdma_qp_uk *qp, struct irdma_qp_uk_init_info *info) 1380 1385 { 1381 - enum irdma_status_code ret_code = 0; 1386 + int ret_code = 0; 1382 1387 u32 sq_ring_size; 1383 1388 u8 sqshift, rqshift; 1384 1389 1385 1390 qp->uk_attrs = info->uk_attrs; 1386 1391 if (info->max_sq_frag_cnt > qp->uk_attrs->max_hw_wq_frags || 1387 1392 info->max_rq_frag_cnt > qp->uk_attrs->max_hw_wq_frags) 1388 - return IRDMA_ERR_INVALID_FRAG_COUNT; 1393 + return -EINVAL; 1389 1394 1390 1395 irdma_get_wqe_shift(qp->uk_attrs, info->max_rq_frag_cnt, 0, &rqshift); 1391 1396 if (qp->uk_attrs->hw_rev == IRDMA_GEN_1) { ··· 1495 1502 * @signaled: signaled for completion 1496 1503 * @post_sq: ring doorbell 1497 1504 */ 1498 - enum irdma_status_code irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, 1499 - bool signaled, bool post_sq) 1505 + int irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, bool post_sq) 1500 1506 { 1501 1507 __le64 *wqe; 1502 1508 u64 hdr; ··· 1507 1515 wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, IRDMA_QP_WQE_MIN_QUANTA, 1508 1516 0, &info); 1509 1517 if (!wqe) 1510 - return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; 1518 + return -ENOMEM; 1511 1519 1512 1520 irdma_clr_wqes(qp, wqe_idx); 1513 1521 ··· 1533 1541 * @frag_cnt: number of fragments 1534 1542 * @quanta: quanta for frag_cnt 1535 1543 */ 1536 - enum irdma_status_code irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta) 1544 + int irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta) 1537 1545 { 1538 1546 switch (frag_cnt) { 1539 1547 case 0: ··· 1569 1577 *quanta = 8; 1570 1578 break; 1571 1579 default: 1572 - return IRDMA_ERR_INVALID_FRAG_COUNT; 1580 + return -EINVAL; 1573 1581 } 1574 1582 1575 1583 return 0; ··· 1580 1588 * @frag_cnt: number of fragments 1581 1589 * @wqe_size: size in bytes given frag_cnt 1582 1590 */ 1583 - enum irdma_status_code irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size) 1591 + int irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size) 1584 1592 { 1585 1593 switch (frag_cnt) { 1586 1594 case 0: ··· 1607 1615 *wqe_size = 256; 1608 1616 break; 1609 1617 default: 1610 - return IRDMA_ERR_INVALID_FRAG_COUNT; 1618 + return -EINVAL; 1611 1619 } 1612 1620 1613 1621 return 0;
+28 -34
drivers/infiniband/hw/irdma/user.h
··· 270 270 bool imm_valid:1; 271 271 }; 272 272 273 - enum irdma_status_code irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, 274 - struct irdma_post_sq_info *info, 275 - bool post_sq); 276 - enum irdma_status_code irdma_uk_inline_send(struct irdma_qp_uk *qp, 277 - struct irdma_post_sq_info *info, 278 - bool post_sq); 279 - 280 - enum irdma_status_code irdma_uk_post_nop(struct irdma_qp_uk *qp, u64 wr_id, 281 - bool signaled, bool post_sq); 282 - enum irdma_status_code irdma_uk_post_receive(struct irdma_qp_uk *qp, 283 - struct irdma_post_rq_info *info); 273 + int irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, 274 + struct irdma_post_sq_info *info, bool post_sq); 275 + int irdma_uk_inline_send(struct irdma_qp_uk *qp, 276 + struct irdma_post_sq_info *info, bool post_sq); 277 + int irdma_uk_post_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, 278 + bool post_sq); 279 + int irdma_uk_post_receive(struct irdma_qp_uk *qp, 280 + struct irdma_post_rq_info *info); 284 281 void irdma_uk_qp_post_wr(struct irdma_qp_uk *qp); 285 - enum irdma_status_code irdma_uk_rdma_read(struct irdma_qp_uk *qp, 286 - struct irdma_post_sq_info *info, 287 - bool inv_stag, bool post_sq); 288 - enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, 289 - struct irdma_post_sq_info *info, 290 - bool post_sq); 291 - enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp, 292 - struct irdma_post_sq_info *info, bool post_sq); 293 - enum irdma_status_code irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, 294 - struct irdma_post_sq_info *info, 295 - bool post_sq); 282 + int irdma_uk_rdma_read(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 283 + bool inv_stag, bool post_sq); 284 + int irdma_uk_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 285 + bool post_sq); 286 + int irdma_uk_send(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, 287 + bool post_sq); 288 + int irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, 289 + struct irdma_post_sq_info *info, 290 + bool post_sq); 296 291 297 292 struct irdma_wqe_uk_ops { 298 293 void (*iw_copy_inline_data)(u8 *dest, u8 *src, u32 len, u8 polarity); ··· 298 303 struct irdma_bind_window *op_info); 299 304 }; 300 305 301 - enum irdma_status_code irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, 302 - struct irdma_cq_poll_info *info); 306 + int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, 307 + struct irdma_cq_poll_info *info); 303 308 void irdma_uk_cq_request_notification(struct irdma_cq_uk *cq, 304 309 enum irdma_cmpl_notify cq_notify); 305 310 void irdma_uk_cq_resize(struct irdma_cq_uk *cq, void *cq_base, int size); 306 311 void irdma_uk_cq_set_resized_cnt(struct irdma_cq_uk *qp, u16 cnt); 307 312 void irdma_uk_cq_init(struct irdma_cq_uk *cq, 308 313 struct irdma_cq_uk_init_info *info); 309 - enum irdma_status_code irdma_uk_qp_init(struct irdma_qp_uk *qp, 310 - struct irdma_qp_uk_init_info *info); 314 + int irdma_uk_qp_init(struct irdma_qp_uk *qp, 315 + struct irdma_qp_uk_init_info *info); 311 316 struct irdma_sq_uk_wr_trk_info { 312 317 u64 wrid; 313 318 u32 wr_len; ··· 408 413 struct irdma_post_sq_info *info); 409 414 __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx); 410 415 void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq); 411 - enum irdma_status_code irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, 412 - bool signaled, bool post_sq); 413 - enum irdma_status_code irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta); 414 - enum irdma_status_code irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size); 416 + int irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, bool post_sq); 417 + int irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta); 418 + int irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size); 415 419 void irdma_get_wqe_shift(struct irdma_uk_attrs *uk_attrs, u32 sge, 416 420 u32 inline_data, u8 *shift); 417 - enum irdma_status_code irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, 418 - u32 sq_size, u8 shift, u32 *wqdepth); 419 - enum irdma_status_code irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, 420 - u32 rq_size, u8 shift, u32 *wqdepth); 421 + int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift, 422 + u32 *wqdepth); 423 + int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift, 424 + u32 *wqdepth); 421 425 void irdma_qp_push_wqe(struct irdma_qp_uk *qp, __le64 *wqe, u16 quanta, 422 426 u32 wqe_idx, bool post_sq); 423 427 void irdma_clr_wqes(struct irdma_qp_uk *qp, u32 qp_wqe_idx);
+122 -125
drivers/infiniband/hw/irdma/utils.c
··· 150 150 void *ptr) 151 151 { 152 152 struct in_ifaddr *ifa = ptr; 153 - struct net_device *netdev = ifa->ifa_dev->dev; 153 + struct net_device *real_dev, *netdev = ifa->ifa_dev->dev; 154 154 struct irdma_device *iwdev; 155 155 struct ib_device *ibdev; 156 156 u32 local_ipaddr; 157 157 158 - ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_IRDMA); 158 + real_dev = rdma_vlan_dev_real_dev(netdev); 159 + if (!real_dev) 160 + real_dev = netdev; 161 + 162 + ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); 159 163 if (!ibdev) 160 164 return NOTIFY_DONE; 161 165 162 166 iwdev = to_iwdev(ibdev); 163 167 local_ipaddr = ntohl(ifa->ifa_address); 164 168 ibdev_dbg(&iwdev->ibdev, 165 - "DEV: netdev %p event %lu local_ip=%pI4 MAC=%pM\n", netdev, 166 - event, &local_ipaddr, netdev->dev_addr); 169 + "DEV: netdev %p event %lu local_ip=%pI4 MAC=%pM\n", real_dev, 170 + event, &local_ipaddr, real_dev->dev_addr); 167 171 switch (event) { 168 172 case NETDEV_DOWN: 169 - irdma_manage_arp_cache(iwdev->rf, netdev->dev_addr, 173 + irdma_manage_arp_cache(iwdev->rf, real_dev->dev_addr, 170 174 &local_ipaddr, true, IRDMA_ARP_DELETE); 171 - irdma_if_notify(iwdev, netdev, &local_ipaddr, true, false); 175 + irdma_if_notify(iwdev, real_dev, &local_ipaddr, true, false); 172 176 irdma_gid_change_event(&iwdev->ibdev); 173 177 break; 174 178 case NETDEV_UP: 175 179 case NETDEV_CHANGEADDR: 176 - irdma_add_arp(iwdev->rf, &local_ipaddr, true, netdev->dev_addr); 177 - irdma_if_notify(iwdev, netdev, &local_ipaddr, true, true); 180 + irdma_add_arp(iwdev->rf, &local_ipaddr, true, real_dev->dev_addr); 181 + irdma_if_notify(iwdev, real_dev, &local_ipaddr, true, true); 178 182 irdma_gid_change_event(&iwdev->ibdev); 179 183 break; 180 184 default: ··· 200 196 void *ptr) 201 197 { 202 198 struct inet6_ifaddr *ifa = ptr; 203 - struct net_device *netdev = ifa->idev->dev; 199 + struct net_device *real_dev, *netdev = ifa->idev->dev; 204 200 struct irdma_device *iwdev; 205 201 struct ib_device *ibdev; 206 202 u32 local_ipaddr6[4]; 207 203 208 - ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_IRDMA); 204 + real_dev = rdma_vlan_dev_real_dev(netdev); 205 + if (!real_dev) 206 + real_dev = netdev; 207 + 208 + ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); 209 209 if (!ibdev) 210 210 return NOTIFY_DONE; 211 211 212 212 iwdev = to_iwdev(ibdev); 213 213 irdma_copy_ip_ntohl(local_ipaddr6, ifa->addr.in6_u.u6_addr32); 214 214 ibdev_dbg(&iwdev->ibdev, 215 - "DEV: netdev %p event %lu local_ip=%pI6 MAC=%pM\n", netdev, 216 - event, local_ipaddr6, netdev->dev_addr); 215 + "DEV: netdev %p event %lu local_ip=%pI6 MAC=%pM\n", real_dev, 216 + event, local_ipaddr6, real_dev->dev_addr); 217 217 switch (event) { 218 218 case NETDEV_DOWN: 219 - irdma_manage_arp_cache(iwdev->rf, netdev->dev_addr, 219 + irdma_manage_arp_cache(iwdev->rf, real_dev->dev_addr, 220 220 local_ipaddr6, false, IRDMA_ARP_DELETE); 221 - irdma_if_notify(iwdev, netdev, local_ipaddr6, false, false); 221 + irdma_if_notify(iwdev, real_dev, local_ipaddr6, false, false); 222 222 irdma_gid_change_event(&iwdev->ibdev); 223 223 break; 224 224 case NETDEV_UP: 225 225 case NETDEV_CHANGEADDR: 226 226 irdma_add_arp(iwdev->rf, local_ipaddr6, false, 227 - netdev->dev_addr); 228 - irdma_if_notify(iwdev, netdev, local_ipaddr6, false, true); 227 + real_dev->dev_addr); 228 + irdma_if_notify(iwdev, real_dev, local_ipaddr6, false, true); 229 229 irdma_gid_change_event(&iwdev->ibdev); 230 230 break; 231 231 default: ··· 251 243 void *ptr) 252 244 { 253 245 struct neighbour *neigh = ptr; 246 + struct net_device *real_dev, *netdev = (struct net_device *)neigh->dev; 254 247 struct irdma_device *iwdev; 255 248 struct ib_device *ibdev; 256 249 __be32 *p; 257 250 u32 local_ipaddr[4] = {}; 258 251 bool ipv4 = true; 259 252 260 - ibdev = ib_device_get_by_netdev((struct net_device *)neigh->dev, 261 - RDMA_DRIVER_IRDMA); 253 + real_dev = rdma_vlan_dev_real_dev(netdev); 254 + if (!real_dev) 255 + real_dev = netdev; 256 + 257 + ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); 262 258 if (!ibdev) 263 259 return NOTIFY_DONE; 264 260 ··· 563 551 * @rf: RDMA PCI function 564 552 * @cqp_request: cqp request to wait 565 553 */ 566 - static enum irdma_status_code irdma_wait_event(struct irdma_pci_f *rf, 567 - struct irdma_cqp_request *cqp_request) 554 + static int irdma_wait_event(struct irdma_pci_f *rf, 555 + struct irdma_cqp_request *cqp_request) 568 556 { 569 557 struct irdma_cqp_timeout cqp_timeout = {}; 570 558 bool cqp_error = false; 571 - enum irdma_status_code err_code = 0; 559 + int err_code = 0; 572 560 573 561 cqp_timeout.compl_cqp_cmds = rf->sc_dev.cqp_cmd_stats[IRDMA_OP_CMPL_CMDS]; 574 562 do { ··· 587 575 rf->reset = true; 588 576 rf->gen_ops.request_reset(rf); 589 577 } 590 - return IRDMA_ERR_TIMEOUT; 578 + return -ETIMEDOUT; 591 579 } while (1); 592 580 593 581 cqp_error = cqp_request->compl_info.error; 594 582 if (cqp_error) { 595 - err_code = IRDMA_ERR_CQP_COMPL_ERROR; 583 + err_code = -EIO; 596 584 if (cqp_request->compl_info.maj_err_code == 0xFFFF && 597 585 cqp_request->compl_info.min_err_code == 0x8029) { 598 586 if (!rf->reset) { ··· 692 680 * @rf: RDMA PCI function 693 681 * @cqp_request: cqp request to process 694 682 */ 695 - enum irdma_status_code irdma_handle_cqp_op(struct irdma_pci_f *rf, 696 - struct irdma_cqp_request *cqp_request) 683 + int irdma_handle_cqp_op(struct irdma_pci_f *rf, 684 + struct irdma_cqp_request *cqp_request) 697 685 { 698 686 struct irdma_sc_dev *dev = &rf->sc_dev; 699 687 struct cqp_cmds_info *info = &cqp_request->info; 700 - enum irdma_status_code status; 688 + int status; 701 689 bool put_cqp_request = true; 702 690 703 691 if (rf->reset) 704 - return IRDMA_ERR_NOT_READY; 692 + return -EBUSY; 705 693 706 694 irdma_get_cqp_request(cqp_request); 707 695 status = irdma_process_cqp_cmd(dev, info); ··· 803 791 * @sdinfo: information for sd cqp 804 792 * 805 793 */ 806 - enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, 807 - struct irdma_update_sds_info *sdinfo) 794 + int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, 795 + struct irdma_update_sds_info *sdinfo) 808 796 { 809 797 struct irdma_cqp_request *cqp_request; 810 798 struct cqp_cmds_info *cqp_info; 811 799 struct irdma_pci_f *rf = dev_to_rf(dev); 812 - enum irdma_status_code status; 800 + int status; 813 801 814 802 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 815 803 if (!cqp_request) 816 - return IRDMA_ERR_NO_MEMORY; 804 + return -ENOMEM; 817 805 818 806 cqp_info = &cqp_request->info; 819 807 memcpy(&cqp_info->in.u.update_pe_sds.info, sdinfo, ··· 834 822 * @qp: hardware control qp 835 823 * @op: suspend or resume 836 824 */ 837 - enum irdma_status_code irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, 838 - u8 op) 825 + int irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, u8 op) 839 826 { 840 827 struct irdma_sc_dev *dev = qp->dev; 841 828 struct irdma_cqp_request *cqp_request; 842 829 struct irdma_sc_cqp *cqp = dev->cqp; 843 830 struct cqp_cmds_info *cqp_info; 844 831 struct irdma_pci_f *rf = dev_to_rf(dev); 845 - enum irdma_status_code status; 832 + int status; 846 833 847 834 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, false); 848 835 if (!cqp_request) 849 - return IRDMA_ERR_NO_MEMORY; 836 + return -ENOMEM; 850 837 851 838 cqp_info = &cqp_request->info; 852 839 cqp_info->cqp_cmd = op; ··· 951 940 * @val_mem: buffer for fpm 952 941 * @hmc_fn_id: function id for fpm 953 942 */ 954 - enum irdma_status_code 955 - irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, 956 - struct irdma_dma_mem *val_mem, u8 hmc_fn_id) 943 + int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, 944 + struct irdma_dma_mem *val_mem, u8 hmc_fn_id) 957 945 { 958 946 struct irdma_cqp_request *cqp_request; 959 947 struct cqp_cmds_info *cqp_info; 960 948 struct irdma_pci_f *rf = dev_to_rf(dev); 961 - enum irdma_status_code status; 949 + int status; 962 950 963 951 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 964 952 if (!cqp_request) 965 - return IRDMA_ERR_NO_MEMORY; 953 + return -ENOMEM; 966 954 967 955 cqp_info = &cqp_request->info; 968 956 cqp_request->param = NULL; ··· 985 975 * @val_mem: buffer with fpm values 986 976 * @hmc_fn_id: function id for fpm 987 977 */ 988 - enum irdma_status_code 989 - irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, 990 - struct irdma_dma_mem *val_mem, u8 hmc_fn_id) 978 + int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, 979 + struct irdma_dma_mem *val_mem, u8 hmc_fn_id) 991 980 { 992 981 struct irdma_cqp_request *cqp_request; 993 982 struct cqp_cmds_info *cqp_info; 994 983 struct irdma_pci_f *rf = dev_to_rf(dev); 995 - enum irdma_status_code status; 984 + int status; 996 985 997 986 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 998 987 if (!cqp_request) 999 - return IRDMA_ERR_NO_MEMORY; 988 + return -ENOMEM; 1000 989 1001 990 cqp_info = &cqp_request->info; 1002 991 cqp_request->param = NULL; ··· 1018 1009 * @dev: device pointer 1019 1010 * @cq: pointer to created cq 1020 1011 */ 1021 - enum irdma_status_code irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, 1022 - struct irdma_sc_cq *cq) 1012 + int irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq) 1023 1013 { 1024 1014 struct irdma_pci_f *rf = dev_to_rf(dev); 1025 1015 struct irdma_cqp *iwcqp = &rf->cqp; 1026 1016 struct irdma_cqp_request *cqp_request; 1027 1017 struct cqp_cmds_info *cqp_info; 1028 - enum irdma_status_code status; 1018 + int status; 1029 1019 1030 1020 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); 1031 1021 if (!cqp_request) 1032 - return IRDMA_ERR_NO_MEMORY; 1022 + return -ENOMEM; 1033 1023 1034 1024 cqp_info = &cqp_request->info; 1035 1025 cqp_info->cqp_cmd = IRDMA_OP_CQ_CREATE; ··· 1047 1039 * @dev: device pointer 1048 1040 * @qp: pointer to created qp 1049 1041 */ 1050 - enum irdma_status_code irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, 1051 - struct irdma_sc_qp *qp) 1042 + int irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) 1052 1043 { 1053 1044 struct irdma_pci_f *rf = dev_to_rf(dev); 1054 1045 struct irdma_cqp *iwcqp = &rf->cqp; 1055 1046 struct irdma_cqp_request *cqp_request; 1056 1047 struct cqp_cmds_info *cqp_info; 1057 1048 struct irdma_create_qp_info *qp_info; 1058 - enum irdma_status_code status; 1049 + int status; 1059 1050 1060 1051 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); 1061 1052 if (!cqp_request) 1062 - return IRDMA_ERR_NO_MEMORY; 1053 + return -ENOMEM; 1063 1054 1064 1055 cqp_info = &cqp_request->info; 1065 1056 qp_info = &cqp_request->info.in.u.qp_create.info; ··· 1086 1079 { 1087 1080 struct irdma_cqp_request *cqp_request; 1088 1081 struct cqp_cmds_info *cqp_info; 1089 - enum irdma_status_code status; 1082 + int status; 1090 1083 1091 1084 if (qp->push_idx == IRDMA_INVALID_PUSH_PAGE_INDEX) 1092 1085 return; ··· 1186 1179 * @info: info for modify qp 1187 1180 * @wait: flag to wait or not for modify qp completion 1188 1181 */ 1189 - enum irdma_status_code irdma_hw_modify_qp(struct irdma_device *iwdev, 1190 - struct irdma_qp *iwqp, 1191 - struct irdma_modify_qp_info *info, 1192 - bool wait) 1182 + int irdma_hw_modify_qp(struct irdma_device *iwdev, struct irdma_qp *iwqp, 1183 + struct irdma_modify_qp_info *info, bool wait) 1193 1184 { 1194 - enum irdma_status_code status; 1185 + int status; 1195 1186 struct irdma_pci_f *rf = iwdev->rf; 1196 1187 struct irdma_cqp_request *cqp_request; 1197 1188 struct cqp_cmds_info *cqp_info; ··· 1197 1192 1198 1193 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); 1199 1194 if (!cqp_request) 1200 - return IRDMA_ERR_NO_MEMORY; 1195 + return -ENOMEM; 1201 1196 1202 1197 if (!wait) { 1203 1198 cqp_request->callback_fcn = irdma_hw_modify_qp_callback; ··· 1235 1230 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, 1236 1231 wait); 1237 1232 if (!cqp_request) 1238 - return IRDMA_ERR_NO_MEMORY; 1233 + return -ENOMEM; 1239 1234 1240 1235 cqp_info = &cqp_request->info; 1241 1236 m_info = &cqp_info->in.u.qp_modify.info; ··· 1276 1271 * @dev: device pointer 1277 1272 * @qp: pointer to qp 1278 1273 */ 1279 - enum irdma_status_code irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) 1274 + int irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) 1280 1275 { 1281 1276 struct irdma_pci_f *rf = dev_to_rf(dev); 1282 1277 struct irdma_cqp *iwcqp = &rf->cqp; 1283 1278 struct irdma_cqp_request *cqp_request; 1284 1279 struct cqp_cmds_info *cqp_info; 1285 - enum irdma_status_code status; 1280 + int status; 1286 1281 1287 1282 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); 1288 1283 if (!cqp_request) 1289 - return IRDMA_ERR_NO_MEMORY; 1284 + return -ENOMEM; 1290 1285 1291 1286 cqp_info = &cqp_request->info; 1292 1287 memset(cqp_info, 0, sizeof(*cqp_info)); ··· 1322 1317 * irdma_init_hash_desc - initialize hash for crc calculation 1323 1318 * @desc: cryption type 1324 1319 */ 1325 - enum irdma_status_code irdma_init_hash_desc(struct shash_desc **desc) 1320 + int irdma_init_hash_desc(struct shash_desc **desc) 1326 1321 { 1327 1322 struct crypto_shash *tfm; 1328 1323 struct shash_desc *tdesc; 1329 1324 1330 1325 tfm = crypto_alloc_shash("crc32c", 0, 0); 1331 1326 if (IS_ERR(tfm)) 1332 - return IRDMA_ERR_MPA_CRC; 1327 + return -EINVAL; 1333 1328 1334 1329 tdesc = kzalloc(sizeof(*tdesc) + crypto_shash_descsize(tfm), 1335 1330 GFP_KERNEL); 1336 1331 if (!tdesc) { 1337 1332 crypto_free_shash(tfm); 1338 - return IRDMA_ERR_MPA_CRC; 1333 + return -EINVAL; 1339 1334 } 1340 1335 1341 1336 tdesc->tfm = tfm; ··· 1363 1358 * @len: length of buffer 1364 1359 * @val: value to be compared 1365 1360 */ 1366 - enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc, 1367 - void *addr, u32 len, u32 val) 1361 + int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len, 1362 + u32 val) 1368 1363 { 1369 1364 u32 crc = 0; 1370 1365 int ret; 1371 - enum irdma_status_code ret_code = 0; 1366 + int ret_code = 0; 1372 1367 1373 1368 crypto_shash_init(desc); 1374 1369 ret = crypto_shash_update(desc, addr, len); 1375 1370 if (!ret) 1376 1371 crypto_shash_final(desc, (u8 *)&crc); 1377 1372 if (crc != val) 1378 - ret_code = IRDMA_ERR_MPA_CRC; 1373 + ret_code = -EINVAL; 1379 1374 1380 1375 return ret_code; 1381 1376 } ··· 1529 1524 * @info: to get information 1530 1525 * @buf: puda buffer 1531 1526 */ 1532 - static enum irdma_status_code 1533 - irdma_gen1_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 1534 - struct irdma_puda_buf *buf) 1527 + static int irdma_gen1_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 1528 + struct irdma_puda_buf *buf) 1535 1529 { 1536 1530 struct iphdr *iph; 1537 1531 struct ipv6hdr *ip6h; ··· 1567 1563 ibdev_dbg(to_ibdev(buf->vsi->dev), 1568 1564 "ERR: payload_len = 0x%x totallen expected0x%x\n", 1569 1565 info->payload_len, buf->totallen); 1570 - return IRDMA_ERR_INVALID_SIZE; 1566 + return -EINVAL; 1571 1567 } 1572 1568 1573 1569 buf->tcphlen = tcph->doff << 2; ··· 1584 1580 * @info: to get information 1585 1581 * @buf: puda buffer 1586 1582 */ 1587 - enum irdma_status_code 1588 - irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 1589 - struct irdma_puda_buf *buf) 1583 + int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, 1584 + struct irdma_puda_buf *buf) 1590 1585 { 1591 1586 struct tcphdr *tcph; 1592 1587 u32 pkt_len; ··· 1864 1861 * @pestat: pointer to stats info 1865 1862 * @wait: flag to wait or not wait for stats 1866 1863 */ 1867 - enum irdma_status_code 1868 - irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, 1869 - struct irdma_vsi_pestat *pestat, bool wait) 1864 + int irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, 1865 + struct irdma_vsi_pestat *pestat, bool wait) 1870 1866 1871 1867 { 1872 1868 struct irdma_pci_f *rf = dev_to_rf(dev); 1873 1869 struct irdma_cqp *iwcqp = &rf->cqp; 1874 1870 struct irdma_cqp_request *cqp_request; 1875 1871 struct cqp_cmds_info *cqp_info; 1876 - enum irdma_status_code status; 1872 + int status; 1877 1873 1878 1874 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); 1879 1875 if (!cqp_request) 1880 - return IRDMA_ERR_NO_MEMORY; 1876 + return -ENOMEM; 1881 1877 1882 1878 cqp_info = &cqp_request->info; 1883 1879 memset(cqp_info, 0, sizeof(*cqp_info)); ··· 1902 1900 * @cmd: command to allocate or free 1903 1901 * @stats_info: pointer to allocate stats info 1904 1902 */ 1905 - enum irdma_status_code 1906 - irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, 1907 - struct irdma_stats_inst_info *stats_info) 1903 + int irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, 1904 + struct irdma_stats_inst_info *stats_info) 1908 1905 { 1909 1906 struct irdma_pci_f *rf = dev_to_rf(vsi->dev); 1910 1907 struct irdma_cqp *iwcqp = &rf->cqp; 1911 1908 struct irdma_cqp_request *cqp_request; 1912 1909 struct cqp_cmds_info *cqp_info; 1913 - enum irdma_status_code status; 1910 + int status; 1914 1911 bool wait = false; 1915 1912 1916 1913 if (cmd == IRDMA_OP_STATS_ALLOCATE) 1917 1914 wait = true; 1918 1915 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); 1919 1916 if (!cqp_request) 1920 - return IRDMA_ERR_NO_MEMORY; 1917 + return -ENOMEM; 1921 1918 1922 1919 cqp_info = &cqp_request->info; 1923 1920 memset(cqp_info, 0, sizeof(*cqp_info)); ··· 1939 1938 * @sc_ceq: pointer to ceq structure 1940 1939 * @op: Create or Destroy 1941 1940 */ 1942 - enum irdma_status_code irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, 1943 - struct irdma_sc_ceq *sc_ceq, u8 op) 1941 + int irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_ceq *sc_ceq, 1942 + u8 op) 1944 1943 { 1945 1944 struct irdma_cqp_request *cqp_request; 1946 1945 struct cqp_cmds_info *cqp_info; 1947 1946 struct irdma_pci_f *rf = dev_to_rf(dev); 1948 - enum irdma_status_code status; 1947 + int status; 1949 1948 1950 1949 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 1951 1950 if (!cqp_request) 1952 - return IRDMA_ERR_NO_MEMORY; 1951 + return -ENOMEM; 1953 1952 1954 1953 cqp_info = &cqp_request->info; 1955 1954 cqp_info->post_sq = 1; ··· 1969 1968 * @sc_aeq: pointer to aeq structure 1970 1969 * @op: Create or Destroy 1971 1970 */ 1972 - enum irdma_status_code irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, 1973 - struct irdma_sc_aeq *sc_aeq, u8 op) 1971 + int irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_aeq *sc_aeq, 1972 + u8 op) 1974 1973 { 1975 1974 struct irdma_cqp_request *cqp_request; 1976 1975 struct cqp_cmds_info *cqp_info; 1977 1976 struct irdma_pci_f *rf = dev_to_rf(dev); 1978 - enum irdma_status_code status; 1977 + int status; 1979 1978 1980 1979 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 1981 1980 if (!cqp_request) 1982 - return IRDMA_ERR_NO_MEMORY; 1981 + return -ENOMEM; 1983 1982 1984 1983 cqp_info = &cqp_request->info; 1985 1984 cqp_info->post_sq = 1; ··· 1999 1998 * @cmd: Add, modify or delete 2000 1999 * @node_info: pointer to ws node info 2001 2000 */ 2002 - enum irdma_status_code 2003 - irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, 2004 - struct irdma_ws_node_info *node_info) 2001 + int irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, 2002 + struct irdma_ws_node_info *node_info) 2005 2003 { 2006 2004 struct irdma_pci_f *rf = dev_to_rf(dev); 2007 2005 struct irdma_cqp *iwcqp = &rf->cqp; 2008 2006 struct irdma_sc_cqp *cqp = &iwcqp->sc_cqp; 2009 2007 struct irdma_cqp_request *cqp_request; 2010 2008 struct cqp_cmds_info *cqp_info; 2011 - enum irdma_status_code status; 2009 + int status; 2012 2010 bool poll; 2013 2011 2014 2012 if (!rf->sc_dev.ceq_valid) ··· 2017 2017 2018 2018 cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, !poll); 2019 2019 if (!cqp_request) 2020 - return IRDMA_ERR_NO_MEMORY; 2020 + return -ENOMEM; 2021 2021 2022 2022 cqp_info = &cqp_request->info; 2023 2023 memset(cqp_info, 0, sizeof(*cqp_info)); ··· 2066 2066 { 2067 2067 struct irdma_cqp_request *cqp_request; 2068 2068 struct cqp_cmds_info *cqp_info; 2069 - enum irdma_status_code status; 2069 + int status; 2070 2070 2071 2071 if (cmd != IRDMA_OP_AH_CREATE && cmd != IRDMA_OP_AH_DESTROY) 2072 2072 return -EINVAL; ··· 2148 2148 * @ah_ret: Returned pointer to address handle if created 2149 2149 * 2150 2150 */ 2151 - enum irdma_status_code irdma_puda_create_ah(struct irdma_sc_dev *dev, 2152 - struct irdma_ah_info *ah_info, 2153 - bool wait, enum puda_rsrc_type type, 2154 - void *cb_param, 2155 - struct irdma_sc_ah **ah_ret) 2151 + int irdma_puda_create_ah(struct irdma_sc_dev *dev, 2152 + struct irdma_ah_info *ah_info, bool wait, 2153 + enum puda_rsrc_type type, void *cb_param, 2154 + struct irdma_sc_ah **ah_ret) 2156 2155 { 2157 2156 struct irdma_sc_ah *ah; 2158 2157 struct irdma_pci_f *rf = dev_to_rf(dev); ··· 2160 2161 ah = kzalloc(sizeof(*ah), GFP_ATOMIC); 2161 2162 *ah_ret = ah; 2162 2163 if (!ah) 2163 - return IRDMA_ERR_NO_MEMORY; 2164 + return -ENOMEM; 2164 2165 2165 2166 err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, 2166 2167 &ah_info->ah_idx, &rf->next_ah); ··· 2186 2187 err_free: 2187 2188 kfree(ah); 2188 2189 *ah_ret = NULL; 2189 - return IRDMA_ERR_NO_MEMORY; 2190 + return -ENOMEM; 2190 2191 } 2191 2192 2192 2193 /** ··· 2228 2229 * @pprm: pble resource manager 2229 2230 * @pchunk: chunk of memory to add 2230 2231 */ 2231 - enum irdma_status_code irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, 2232 - struct irdma_chunk *pchunk) 2232 + int irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, 2233 + struct irdma_chunk *pchunk) 2233 2234 { 2234 2235 u64 sizeofbitmap; 2235 2236 2236 2237 if (pchunk->size & 0xfff) 2237 - return IRDMA_ERR_PARAM; 2238 + return -EINVAL; 2238 2239 2239 2240 sizeofbitmap = (u64)pchunk->size >> pprm->pble_shift; 2240 2241 2241 2242 pchunk->bitmapbuf = bitmap_zalloc(sizeofbitmap, GFP_KERNEL); 2242 2243 if (!pchunk->bitmapbuf) 2243 - return IRDMA_ERR_NO_MEMORY; 2244 + return -ENOMEM; 2244 2245 2245 2246 pchunk->sizeofbitmap = sizeofbitmap; 2246 2247 /* each pble is 8 bytes hence shift by 3 */ ··· 2258 2259 * @vaddr: returns virtual address of pble memory 2259 2260 * @fpm_addr: returns fpm address of pble memory 2260 2261 */ 2261 - enum irdma_status_code 2262 - irdma_prm_get_pbles(struct irdma_pble_prm *pprm, 2263 - struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, 2264 - u64 **vaddr, u64 *fpm_addr) 2262 + int irdma_prm_get_pbles(struct irdma_pble_prm *pprm, 2263 + struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, 2264 + u64 **vaddr, u64 *fpm_addr) 2265 2265 { 2266 2266 u64 bits_needed; 2267 2267 u64 bit_idx = PBLE_INVALID_IDX; ··· 2288 2290 2289 2291 if (!pchunk || bit_idx >= pchunk->sizeofbitmap) { 2290 2292 spin_unlock_irqrestore(&pprm->prm_lock, flags); 2291 - return IRDMA_ERR_NO_MEMORY; 2293 + return -ENOMEM; 2292 2294 } 2293 2295 2294 2296 bitmap_set(pchunk->bitmapbuf, bit_idx, bits_needed); ··· 2323 2325 spin_unlock_irqrestore(&pprm->prm_lock, flags); 2324 2326 } 2325 2327 2326 - enum irdma_status_code irdma_map_vm_page_list(struct irdma_hw *hw, void *va, 2327 - dma_addr_t *pg_dma, u32 pg_cnt) 2328 + int irdma_map_vm_page_list(struct irdma_hw *hw, void *va, dma_addr_t *pg_dma, 2329 + u32 pg_cnt) 2328 2330 { 2329 2331 struct page *vm_page; 2330 2332 int i; ··· 2348 2350 2349 2351 err: 2350 2352 irdma_unmap_vm_page_list(hw, pg_dma, i); 2351 - return IRDMA_ERR_NO_MEMORY; 2353 + return -ENOMEM; 2352 2354 } 2353 2355 2354 2356 void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt) ··· 2384 2386 * @chunk: chunk to add for paged memory 2385 2387 * @pg_cnt: number of pages needed 2386 2388 */ 2387 - enum irdma_status_code irdma_pble_get_paged_mem(struct irdma_chunk *chunk, 2388 - u32 pg_cnt) 2389 + int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt) 2389 2390 { 2390 2391 u32 size; 2391 2392 void *va; 2392 2393 2393 2394 chunk->dmainfo.dmaaddrs = kzalloc(pg_cnt << 3, GFP_KERNEL); 2394 2395 if (!chunk->dmainfo.dmaaddrs) 2395 - return IRDMA_ERR_NO_MEMORY; 2396 + return -ENOMEM; 2396 2397 2397 2398 size = PAGE_SIZE * pg_cnt; 2398 2399 va = vmalloc(size); ··· 2413 2416 kfree(chunk->dmainfo.dmaaddrs); 2414 2417 chunk->dmainfo.dmaaddrs = NULL; 2415 2418 2416 - return IRDMA_ERR_NO_MEMORY; 2419 + return -ENOMEM; 2417 2420 } 2418 2421 2419 2422 /**
+212 -177
drivers/infiniband/hw/irdma/verbs.c
··· 256 256 struct cqp_cmds_info *cqp_info; 257 257 struct irdma_device *iwdev = iwqp->iwdev; 258 258 struct irdma_sc_qp *qp = &iwqp->sc_qp; 259 - enum irdma_status_code status; 259 + int status; 260 260 261 261 cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); 262 262 if (!cqp_request) ··· 592 592 u32 sqdepth, rqdepth; 593 593 u8 sqshift, rqshift; 594 594 u32 size; 595 - enum irdma_status_code status; 595 + int status; 596 596 struct irdma_qp_uk_init_info *ukinfo = &info->qp_uk_init_info; 597 597 struct irdma_uk_attrs *uk_attrs = &iwdev->rf->sc_dev.hw_attrs.uk_attrs; 598 598 ··· 603 603 status = irdma_get_sqdepth(uk_attrs, ukinfo->sq_size, sqshift, 604 604 &sqdepth); 605 605 if (status) 606 - return -ENOMEM; 606 + return status; 607 607 608 608 if (uk_attrs->hw_rev == IRDMA_GEN_1) 609 609 rqshift = IRDMA_MAX_RQ_WQE_SHIFT_GEN1; ··· 614 614 status = irdma_get_rqdepth(uk_attrs, ukinfo->rq_size, rqshift, 615 615 &rqdepth); 616 616 if (status) 617 - return -ENOMEM; 617 + return status; 618 618 619 619 iwqp->kqp.sq_wrid_mem = 620 620 kcalloc(sqdepth, sizeof(*iwqp->kqp.sq_wrid_mem), GFP_KERNEL); ··· 668 668 struct irdma_cqp_request *cqp_request; 669 669 struct cqp_cmds_info *cqp_info; 670 670 struct irdma_create_qp_info *qp_info; 671 - enum irdma_status_code status; 671 + int status; 672 672 673 673 cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); 674 674 if (!cqp_request) ··· 688 688 status = irdma_handle_cqp_op(rf, cqp_request); 689 689 irdma_put_cqp_request(&rf->cqp, cqp_request); 690 690 691 - return status ? -ENOMEM : 0; 691 + return status; 692 692 } 693 693 694 694 static void irdma_roce_fill_and_set_qpctx_info(struct irdma_qp *iwqp, ··· 806 806 struct irdma_create_qp_req req; 807 807 struct irdma_create_qp_resp uresp = {}; 808 808 u32 qp_num = 0; 809 - enum irdma_status_code ret; 810 809 int err_code; 811 810 int sq_size; 812 811 int rq_size; ··· 935 936 if (dev->hw_attrs.uk_attrs.hw_rev > IRDMA_GEN_1) 936 937 init_info.qp_uk_init_info.qp_caps |= IRDMA_PUSH_MODE; 937 938 938 - ret = irdma_sc_qp_init(qp, &init_info); 939 - if (ret) { 940 - err_code = -EPROTO; 939 + err_code = irdma_sc_qp_init(qp, &init_info); 940 + if (err_code) { 941 941 ibdev_dbg(&iwdev->ibdev, "VERBS: qp_init fail\n"); 942 942 goto error; 943 943 } ··· 1187 1189 if (ret) 1188 1190 return ret; 1189 1191 1190 - if (vlan_id >= VLAN_N_VID && iwdev->dcb) 1192 + if (vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode) 1191 1193 vlan_id = 0; 1192 1194 if (vlan_id < VLAN_N_VID) { 1193 1195 udp_info->insert_vlan_tag = true; ··· 1200 1202 av->attrs = attr->ah_attr; 1201 1203 rdma_gid2ip((struct sockaddr *)&av->sgid_addr, &sgid_attr->gid); 1202 1204 rdma_gid2ip((struct sockaddr *)&av->dgid_addr, &attr->ah_attr.grh.dgid); 1203 - if (av->sgid_addr.saddr.sa_family == AF_INET6) { 1205 + if (av->net_type == RDMA_NETWORK_IPV6) { 1204 1206 __be32 *daddr = 1205 1207 av->dgid_addr.saddr_in6.sin6_addr.in6_u.u6_addr32; 1206 1208 __be32 *saddr = ··· 1216 1218 &local_ip[0], 1217 1219 false, NULL, 1218 1220 IRDMA_ARP_RESOLVE); 1219 - } else { 1221 + } else if (av->net_type == RDMA_NETWORK_IPV4) { 1220 1222 __be32 saddr = av->sgid_addr.saddr_in.sin_addr.s_addr; 1221 1223 __be32 daddr = av->dgid_addr.saddr_in.sin_addr.s_addr; 1222 1224 ··· 1790 1792 struct irdma_device *iwdev; 1791 1793 struct irdma_pci_f *rf; 1792 1794 struct irdma_cq_buf *cq_buf = NULL; 1793 - enum irdma_status_code status = 0; 1794 1795 unsigned long flags; 1795 1796 int ret; 1796 1797 ··· 1882 1885 cqp_info->in.u.cq_modify.cq = &iwcq->sc_cq; 1883 1886 cqp_info->in.u.cq_modify.scratch = (uintptr_t)cqp_request; 1884 1887 cqp_info->post_sq = 1; 1885 - status = irdma_handle_cqp_op(rf, cqp_request); 1888 + ret = irdma_handle_cqp_op(rf, cqp_request); 1886 1889 irdma_put_cqp_request(&rf->cqp, cqp_request); 1887 - if (status) { 1888 - ret = -EPROTO; 1890 + if (ret) 1889 1891 goto error; 1890 - } 1891 1892 1892 1893 spin_lock_irqsave(&iwcq->lock, flags); 1893 1894 if (cq_buf) { ··· 1940 1945 struct irdma_sc_cq *cq; 1941 1946 struct irdma_sc_dev *dev = &rf->sc_dev; 1942 1947 struct irdma_cq_init_info info = {}; 1943 - enum irdma_status_code status; 1944 1948 struct irdma_cqp_request *cqp_request; 1945 1949 struct cqp_cmds_info *cqp_info; 1946 1950 struct irdma_cq_uk_init_info *ukinfo = &info.cq_uk_init_info; ··· 2089 2095 cqp_info->in.u.cq_create.cq = cq; 2090 2096 cqp_info->in.u.cq_create.check_overflow = true; 2091 2097 cqp_info->in.u.cq_create.scratch = (uintptr_t)cqp_request; 2092 - status = irdma_handle_cqp_op(rf, cqp_request); 2098 + err_code = irdma_handle_cqp_op(rf, cqp_request); 2093 2099 irdma_put_cqp_request(&rf->cqp, cqp_request); 2094 - if (status) { 2095 - err_code = -ENOMEM; 2100 + if (err_code) 2096 2101 goto cq_free_rsrc; 2097 - } 2098 2102 2099 2103 if (udata) { 2100 2104 struct irdma_create_cq_resp resp = {}; ··· 2301 2309 struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc; 2302 2310 struct irdma_pble_info *pinfo; 2303 2311 u64 *pbl; 2304 - enum irdma_status_code status; 2312 + int status; 2305 2313 enum irdma_pble_level level = PBLE_LEVEL_1; 2306 2314 2307 2315 if (use_pbles) { 2308 2316 status = irdma_get_pble(rf->pble_rsrc, palloc, iwmr->page_cnt, 2309 2317 false); 2310 2318 if (status) 2311 - return -ENOMEM; 2319 + return status; 2312 2320 2313 2321 iwpbl->pbl_allocated = true; 2314 2322 level = palloc->level; ··· 2426 2434 struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); 2427 2435 struct irdma_cqp_request *cqp_request; 2428 2436 struct cqp_cmds_info *cqp_info; 2429 - enum irdma_status_code status; 2437 + int status; 2430 2438 2431 2439 cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); 2432 2440 if (!cqp_request) ··· 2449 2457 status = irdma_handle_cqp_op(iwdev->rf, cqp_request); 2450 2458 irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); 2451 2459 2452 - return status ? -ENOMEM : 0; 2460 + return status; 2453 2461 } 2454 2462 2455 2463 /** ··· 2501 2509 cqp_info = &cqp_request->info; 2502 2510 info = &cqp_info->in.u.dealloc_stag.info; 2503 2511 memset(info, 0, sizeof(*info)); 2504 - info->pd_id = iwpd->sc_pd.pd_id & 0x00007fff; 2512 + info->pd_id = iwpd->sc_pd.pd_id; 2505 2513 info->stag_idx = ibmw->rkey >> IRDMA_CQPSQ_STAG_IDX_S; 2506 2514 info->mr = false; 2507 2515 cqp_info->cqp_cmd = IRDMA_OP_DEALLOC_STAG; ··· 2525 2533 { 2526 2534 struct irdma_allocate_stag_info *info; 2527 2535 struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); 2528 - enum irdma_status_code status; 2529 - int err = 0; 2536 + int status; 2530 2537 struct irdma_cqp_request *cqp_request; 2531 2538 struct cqp_cmds_info *cqp_info; 2532 2539 ··· 2547 2556 cqp_info->in.u.alloc_stag.scratch = (uintptr_t)cqp_request; 2548 2557 status = irdma_handle_cqp_op(iwdev->rf, cqp_request); 2549 2558 irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); 2550 - if (status) 2551 - err = -ENOMEM; 2552 2559 2553 - return err; 2560 + return status; 2554 2561 } 2555 2562 2556 2563 /** ··· 2564 2575 struct irdma_pble_alloc *palloc; 2565 2576 struct irdma_pbl *iwpbl; 2566 2577 struct irdma_mr *iwmr; 2567 - enum irdma_status_code status; 2568 2578 u32 stag; 2569 - int err_code = -ENOMEM; 2579 + int err_code; 2570 2580 2571 2581 iwmr = kzalloc(sizeof(*iwmr), GFP_KERNEL); 2572 2582 if (!iwmr) ··· 2587 2599 iwmr->type = IRDMA_MEMREG_TYPE_MEM; 2588 2600 palloc = &iwpbl->pble_alloc; 2589 2601 iwmr->page_cnt = max_num_sg; 2590 - status = irdma_get_pble(iwdev->rf->pble_rsrc, palloc, iwmr->page_cnt, 2591 - true); 2592 - if (status) 2602 + err_code = irdma_get_pble(iwdev->rf->pble_rsrc, palloc, iwmr->page_cnt, 2603 + true); 2604 + if (err_code) 2593 2605 goto err_get_pble; 2594 2606 2595 2607 err_code = irdma_hw_alloc_stag(iwdev, iwmr); ··· 2660 2672 struct irdma_reg_ns_stag_info *stag_info; 2661 2673 struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); 2662 2674 struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc; 2663 - enum irdma_status_code status; 2664 - int err = 0; 2665 2675 struct irdma_cqp_request *cqp_request; 2666 2676 struct cqp_cmds_info *cqp_info; 2677 + int ret; 2667 2678 2668 2679 cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); 2669 2680 if (!cqp_request) ··· 2699 2712 cqp_info->post_sq = 1; 2700 2713 cqp_info->in.u.mr_reg_non_shared.dev = &iwdev->rf->sc_dev; 2701 2714 cqp_info->in.u.mr_reg_non_shared.scratch = (uintptr_t)cqp_request; 2702 - status = irdma_handle_cqp_op(iwdev->rf, cqp_request); 2715 + ret = irdma_handle_cqp_op(iwdev->rf, cqp_request); 2703 2716 irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); 2704 - if (status) 2705 - err = -ENOMEM; 2706 2717 2707 - return err; 2718 + return ret; 2708 2719 } 2709 2720 2710 2721 /** ··· 2882 2897 struct irdma_device *iwdev = to_iwdev(pd->device); 2883 2898 struct irdma_pbl *iwpbl; 2884 2899 struct irdma_mr *iwmr; 2885 - enum irdma_status_code status; 2886 2900 u32 stag; 2887 2901 int ret; 2888 2902 ··· 2909 2925 iwmr->pgaddrmem[0] = addr; 2910 2926 iwmr->len = size; 2911 2927 iwmr->page_size = SZ_4K; 2912 - status = irdma_hwreg_mr(iwdev, iwmr, access); 2913 - if (status) { 2928 + ret = irdma_hwreg_mr(iwdev, iwmr, access); 2929 + if (ret) { 2914 2930 irdma_free_stag(iwdev, stag); 2915 - ret = -ENOMEM; 2916 2931 goto err; 2917 2932 } 2918 2933 ··· 3004 3021 cqp_info = &cqp_request->info; 3005 3022 info = &cqp_info->in.u.dealloc_stag.info; 3006 3023 memset(info, 0, sizeof(*info)); 3007 - info->pd_id = iwpd->sc_pd.pd_id & 0x00007fff; 3024 + info->pd_id = iwpd->sc_pd.pd_id; 3008 3025 info->stag_idx = ib_mr->rkey >> IRDMA_CQPSQ_STAG_IDX_S; 3009 3026 info->mr = true; 3010 3027 if (iwpbl->pbl_allocated) ··· 3040 3057 struct irdma_qp_uk *ukqp; 3041 3058 struct irdma_sc_dev *dev; 3042 3059 struct irdma_post_sq_info info; 3043 - enum irdma_status_code ret; 3044 3060 int err = 0; 3045 3061 unsigned long flags; 3046 3062 bool inv_stag; ··· 3098 3116 info.op.inline_send.qkey = ud_wr(ib_wr)->remote_qkey; 3099 3117 info.op.inline_send.dest_qp = ud_wr(ib_wr)->remote_qpn; 3100 3118 } 3101 - ret = irdma_uk_inline_send(ukqp, &info, false); 3119 + err = irdma_uk_inline_send(ukqp, &info, false); 3102 3120 } else { 3103 3121 info.op.send.num_sges = ib_wr->num_sge; 3104 3122 info.op.send.sg_list = ib_wr->sg_list; ··· 3109 3127 info.op.send.qkey = ud_wr(ib_wr)->remote_qkey; 3110 3128 info.op.send.dest_qp = ud_wr(ib_wr)->remote_qpn; 3111 3129 } 3112 - ret = irdma_uk_send(ukqp, &info, false); 3113 - } 3114 - 3115 - if (ret) { 3116 - if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) 3117 - err = -ENOMEM; 3118 - else 3119 - err = -EINVAL; 3130 + err = irdma_uk_send(ukqp, &info, false); 3120 3131 } 3121 3132 break; 3122 3133 case IB_WR_RDMA_WRITE_WITH_IMM: ··· 3135 3160 rdma_wr(ib_wr)->remote_addr; 3136 3161 info.op.inline_rdma_write.rem_addr.lkey = 3137 3162 rdma_wr(ib_wr)->rkey; 3138 - ret = irdma_uk_inline_rdma_write(ukqp, &info, false); 3163 + err = irdma_uk_inline_rdma_write(ukqp, &info, false); 3139 3164 } else { 3140 3165 info.op.rdma_write.lo_sg_list = (void *)ib_wr->sg_list; 3141 3166 info.op.rdma_write.num_lo_sges = ib_wr->num_sge; 3142 3167 info.op.rdma_write.rem_addr.addr = rdma_wr(ib_wr)->remote_addr; 3143 3168 info.op.rdma_write.rem_addr.lkey = rdma_wr(ib_wr)->rkey; 3144 - ret = irdma_uk_rdma_write(ukqp, &info, false); 3145 - } 3146 - 3147 - if (ret) { 3148 - if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) 3149 - err = -ENOMEM; 3150 - else 3151 - err = -EINVAL; 3169 + err = irdma_uk_rdma_write(ukqp, &info, false); 3152 3170 } 3153 3171 break; 3154 3172 case IB_WR_RDMA_READ_WITH_INV: ··· 3158 3190 info.op.rdma_read.rem_addr.lkey = rdma_wr(ib_wr)->rkey; 3159 3191 info.op.rdma_read.lo_sg_list = (void *)ib_wr->sg_list; 3160 3192 info.op.rdma_read.num_lo_sges = ib_wr->num_sge; 3161 - 3162 - ret = irdma_uk_rdma_read(ukqp, &info, inv_stag, false); 3163 - if (ret) { 3164 - if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) 3165 - err = -ENOMEM; 3166 - else 3167 - err = -EINVAL; 3168 - } 3193 + err = irdma_uk_rdma_read(ukqp, &info, inv_stag, false); 3169 3194 break; 3170 3195 case IB_WR_LOCAL_INV: 3171 3196 info.op_type = IRDMA_OP_TYPE_INV_STAG; 3172 3197 info.op.inv_local_stag.target_stag = ib_wr->ex.invalidate_rkey; 3173 - ret = irdma_uk_stag_local_invalidate(ukqp, &info, true); 3174 - if (ret) 3175 - err = -ENOMEM; 3198 + err = irdma_uk_stag_local_invalidate(ukqp, &info, true); 3176 3199 break; 3177 3200 case IB_WR_REG_MR: { 3178 3201 struct irdma_mr *iwmr = to_iwmr(reg_wr(ib_wr)->mr); ··· 3185 3226 stag_info.local_fence = ib_wr->send_flags & IB_SEND_FENCE; 3186 3227 if (iwmr->npages > IRDMA_MIN_PAGES_PER_FMR) 3187 3228 stag_info.chunk_size = 1; 3188 - ret = irdma_sc_mr_fast_register(&iwqp->sc_qp, &stag_info, 3229 + err = irdma_sc_mr_fast_register(&iwqp->sc_qp, &stag_info, 3189 3230 true); 3190 - if (ret) 3191 - err = -ENOMEM; 3192 3231 break; 3193 3232 } 3194 3233 default: ··· 3231 3274 struct irdma_qp *iwqp; 3232 3275 struct irdma_qp_uk *ukqp; 3233 3276 struct irdma_post_rq_info post_recv = {}; 3234 - enum irdma_status_code ret = 0; 3235 3277 unsigned long flags; 3236 3278 int err = 0; 3237 3279 bool reflush = false; ··· 3245 3289 post_recv.num_sges = ib_wr->num_sge; 3246 3290 post_recv.wr_id = ib_wr->wr_id; 3247 3291 post_recv.sg_list = ib_wr->sg_list; 3248 - ret = irdma_uk_post_receive(ukqp, &post_recv); 3249 - if (ret) { 3292 + err = irdma_uk_post_receive(ukqp, &post_recv); 3293 + if (err) { 3250 3294 ibdev_dbg(&iwqp->iwdev->ibdev, 3251 - "VERBS: post_recv err %d\n", ret); 3252 - if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) 3253 - err = -ENOMEM; 3254 - else 3255 - err = -EINVAL; 3295 + "VERBS: post_recv err %d\n", err); 3256 3296 goto out; 3257 3297 } 3258 3298 ··· 3435 3483 struct irdma_cq_buf *last_buf = NULL; 3436 3484 struct irdma_cq_poll_info *cur_cqe = &iwcq->cur_cqe; 3437 3485 struct irdma_cq_buf *cq_buf; 3438 - enum irdma_status_code ret; 3486 + int ret; 3439 3487 struct irdma_device *iwdev; 3440 3488 struct irdma_cq_uk *ukcq; 3441 3489 bool cq_new_cqe = false; ··· 3455 3503 cq_new_cqe = true; 3456 3504 continue; 3457 3505 } 3458 - if (ret == IRDMA_ERR_Q_EMPTY) 3506 + if (ret == -ENOENT) 3459 3507 break; 3460 3508 /* QP using the CQ is destroyed. Skip reporting this CQE */ 3461 - if (ret == IRDMA_ERR_Q_DESTROYED) { 3509 + if (ret == -EFAULT) { 3462 3510 cq_new_cqe = true; 3463 3511 continue; 3464 3512 } ··· 3480 3528 continue; 3481 3529 } 3482 3530 3483 - if (ret == IRDMA_ERR_Q_EMPTY) 3531 + if (ret == -ENOENT) 3484 3532 break; 3485 3533 /* QP using the CQ is destroyed. Skip reporting this CQE */ 3486 - if (ret == IRDMA_ERR_Q_DESTROYED) { 3534 + if (ret == -EFAULT) { 3487 3535 cq_new_cqe = true; 3488 3536 continue; 3489 3537 } ··· 3505 3553 ibdev_dbg(&iwdev->ibdev, "%s: Error polling CQ, irdma_err: %d\n", 3506 3554 __func__, ret); 3507 3555 3508 - return -EINVAL; 3556 + return ret; 3509 3557 } 3510 3558 3511 3559 /** ··· 3811 3859 { 3812 3860 struct cqp_cmds_info *cqp_info; 3813 3861 struct irdma_cqp_request *cqp_request; 3814 - enum irdma_status_code status; 3862 + int status; 3815 3863 3816 3864 cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); 3817 3865 if (!cqp_request) ··· 3825 3873 cqp_info->in.u.mc_create.cqp = &iwdev->rf->cqp.sc_cqp; 3826 3874 status = irdma_handle_cqp_op(iwdev->rf, cqp_request); 3827 3875 irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); 3828 - if (status) 3829 - return -ENOMEM; 3830 3876 3831 - return 0; 3877 + return status; 3832 3878 } 3833 3879 3834 3880 /** ··· 3882 3932 int ret = 0; 3883 3933 bool ipv4; 3884 3934 u16 vlan_id; 3885 - union { 3886 - struct sockaddr saddr; 3887 - struct sockaddr_in saddr_in; 3888 - struct sockaddr_in6 saddr_in6; 3889 - } sgid_addr; 3935 + union irdma_sockaddr sgid_addr; 3890 3936 unsigned char dmac[ETH_ALEN]; 3891 3937 3892 3938 rdma_gid2ip((struct sockaddr *)&sgid_addr, ibgid); ··· 4018 4072 struct irdma_mcast_grp_ctx_entry_info mcg_info = {}; 4019 4073 int ret; 4020 4074 unsigned long flags; 4021 - union { 4022 - struct sockaddr saddr; 4023 - struct sockaddr_in saddr_in; 4024 - struct sockaddr_in6 saddr_in6; 4025 - } sgid_addr; 4075 + union irdma_sockaddr sgid_addr; 4026 4076 4027 4077 rdma_gid2ip((struct sockaddr *)&sgid_addr, ibgid); 4028 4078 if (!ipv6_addr_v4mapped((struct in6_addr *)ibgid)) ··· 4074 4132 return 0; 4075 4133 } 4076 4134 4077 - /** 4078 - * irdma_create_ah - create address handle 4079 - * @ibah: address handle 4080 - * @attr: address handle attributes 4081 - * @udata: User data 4082 - * 4083 - * returns 0 on success, error otherwise 4084 - */ 4085 - static int irdma_create_ah(struct ib_ah *ibah, 4086 - struct rdma_ah_init_attr *attr, 4087 - struct ib_udata *udata) 4135 + static int irdma_create_hw_ah(struct irdma_device *iwdev, struct irdma_ah *ah, bool sleep) 4136 + { 4137 + struct irdma_pci_f *rf = iwdev->rf; 4138 + int err; 4139 + 4140 + err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, &ah->sc_ah.ah_info.ah_idx, 4141 + &rf->next_ah); 4142 + if (err) 4143 + return err; 4144 + 4145 + err = irdma_ah_cqp_op(rf, &ah->sc_ah, IRDMA_OP_AH_CREATE, sleep, 4146 + irdma_gsi_ud_qp_ah_cb, &ah->sc_ah); 4147 + 4148 + if (err) { 4149 + ibdev_dbg(&iwdev->ibdev, "VERBS: CQP-OP Create AH fail"); 4150 + goto err_ah_create; 4151 + } 4152 + 4153 + if (!sleep) { 4154 + int cnt = CQP_COMPL_WAIT_TIME_MS * CQP_TIMEOUT_THRESHOLD; 4155 + 4156 + do { 4157 + irdma_cqp_ce_handler(rf, &rf->ccq.sc_cq); 4158 + mdelay(1); 4159 + } while (!ah->sc_ah.ah_info.ah_valid && --cnt); 4160 + 4161 + if (!cnt) { 4162 + ibdev_dbg(&iwdev->ibdev, "VERBS: CQP create AH timed out"); 4163 + err = -ETIMEDOUT; 4164 + goto err_ah_create; 4165 + } 4166 + } 4167 + return 0; 4168 + 4169 + err_ah_create: 4170 + irdma_free_rsrc(iwdev->rf, iwdev->rf->allocated_ahs, ah->sc_ah.ah_info.ah_idx); 4171 + 4172 + return err; 4173 + } 4174 + 4175 + static int irdma_setup_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *attr) 4088 4176 { 4089 4177 struct irdma_pd *pd = to_iwpd(ibah->pd); 4090 4178 struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); ··· 4123 4151 struct irdma_device *iwdev = to_iwdev(ibah->pd->device); 4124 4152 struct irdma_pci_f *rf = iwdev->rf; 4125 4153 struct irdma_sc_ah *sc_ah; 4126 - u32 ah_id = 0; 4127 4154 struct irdma_ah_info *ah_info; 4128 - struct irdma_create_ah_resp uresp; 4129 - union { 4130 - struct sockaddr saddr; 4131 - struct sockaddr_in saddr_in; 4132 - struct sockaddr_in6 saddr_in6; 4133 - } sgid_addr, dgid_addr; 4155 + union irdma_sockaddr sgid_addr, dgid_addr; 4134 4156 int err; 4135 4157 u8 dmac[ETH_ALEN]; 4136 4158 4137 - err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, &ah_id, 4138 - &rf->next_ah); 4139 - if (err) 4140 - return err; 4141 - 4142 4159 ah->pd = pd; 4143 4160 sc_ah = &ah->sc_ah; 4144 - sc_ah->ah_info.ah_idx = ah_id; 4145 4161 sc_ah->ah_info.vsi = &iwdev->vsi; 4146 4162 irdma_sc_init_ah(&rf->sc_dev, sc_ah); 4147 4163 ah->sgid_index = ah_attr->grh.sgid_index; ··· 4139 4179 rdma_gid2ip((struct sockaddr *)&dgid_addr, &ah_attr->grh.dgid); 4140 4180 ah->av.attrs = *ah_attr; 4141 4181 ah->av.net_type = rdma_gid_attr_network_type(sgid_attr); 4142 - ah->av.sgid_addr.saddr = sgid_addr.saddr; 4143 - ah->av.dgid_addr.saddr = dgid_addr.saddr; 4144 4182 ah_info = &sc_ah->ah_info; 4145 - ah_info->ah_idx = ah_id; 4146 4183 ah_info->pd_idx = pd->sc_pd.pd_id; 4147 4184 if (ah_attr->ah_flags & IB_AH_GRH) { 4148 4185 ah_info->flow_label = ah_attr->grh.flow_label; ··· 4148 4191 } 4149 4192 4150 4193 ether_addr_copy(dmac, ah_attr->roce.dmac); 4151 - if (rdma_gid_attr_network_type(sgid_attr) == RDMA_NETWORK_IPV4) { 4194 + if (ah->av.net_type == RDMA_NETWORK_IPV4) { 4152 4195 ah_info->ipv4_valid = true; 4153 4196 ah_info->dest_ip_addr[0] = 4154 4197 ntohl(dgid_addr.saddr_in.sin_addr.s_addr); ··· 4176 4219 err = rdma_read_gid_l2_fields(sgid_attr, &ah_info->vlan_tag, 4177 4220 ah_info->mac_addr); 4178 4221 if (err) 4179 - goto error; 4222 + return err; 4180 4223 4181 4224 ah_info->dst_arpindex = irdma_add_arp(iwdev->rf, ah_info->dest_ip_addr, 4182 4225 ah_info->ipv4_valid, dmac); 4183 4226 4184 - if (ah_info->dst_arpindex == -1) { 4185 - err = -EINVAL; 4186 - goto error; 4187 - } 4227 + if (ah_info->dst_arpindex == -1) 4228 + return -EINVAL; 4188 4229 4189 - if (ah_info->vlan_tag >= VLAN_N_VID && iwdev->dcb) 4230 + if (ah_info->vlan_tag >= VLAN_N_VID && iwdev->dcb_vlan_mode) 4190 4231 ah_info->vlan_tag = 0; 4191 4232 4192 4233 if (ah_info->vlan_tag < VLAN_N_VID) { ··· 4193 4238 rt_tos2priority(ah_info->tc_tos) << VLAN_PRIO_SHIFT; 4194 4239 } 4195 4240 4196 - err = irdma_ah_cqp_op(iwdev->rf, sc_ah, IRDMA_OP_AH_CREATE, 4197 - attr->flags & RDMA_CREATE_AH_SLEEPABLE, 4198 - irdma_gsi_ud_qp_ah_cb, sc_ah); 4241 + return 0; 4242 + } 4199 4243 4200 - if (err) { 4201 - ibdev_dbg(&iwdev->ibdev, 4202 - "VERBS: CQP-OP Create AH fail"); 4203 - goto error; 4204 - } 4244 + /** 4245 + * irdma_ah_exists - Check for existing identical AH 4246 + * @iwdev: irdma device 4247 + * @new_ah: AH to check for 4248 + * 4249 + * returns true if AH is found, false if not found. 4250 + */ 4251 + static bool irdma_ah_exists(struct irdma_device *iwdev, 4252 + struct irdma_ah *new_ah) 4253 + { 4254 + struct irdma_ah *ah; 4255 + u32 key = new_ah->sc_ah.ah_info.dest_ip_addr[0] ^ 4256 + new_ah->sc_ah.ah_info.dest_ip_addr[1] ^ 4257 + new_ah->sc_ah.ah_info.dest_ip_addr[2] ^ 4258 + new_ah->sc_ah.ah_info.dest_ip_addr[3]; 4205 4259 4206 - if (!(attr->flags & RDMA_CREATE_AH_SLEEPABLE)) { 4207 - int cnt = CQP_COMPL_WAIT_TIME_MS * CQP_TIMEOUT_THRESHOLD; 4208 - 4209 - do { 4210 - irdma_cqp_ce_handler(rf, &rf->ccq.sc_cq); 4211 - mdelay(1); 4212 - } while (!sc_ah->ah_info.ah_valid && --cnt); 4213 - 4214 - if (!cnt) { 4215 - ibdev_dbg(&iwdev->ibdev, 4216 - "VERBS: CQP create AH timed out"); 4217 - err = -ETIMEDOUT; 4218 - goto error; 4260 + hash_for_each_possible(iwdev->ah_hash_tbl, ah, list, key) { 4261 + /* Set ah_valid and ah_id the same so memcmp can work */ 4262 + new_ah->sc_ah.ah_info.ah_idx = ah->sc_ah.ah_info.ah_idx; 4263 + new_ah->sc_ah.ah_info.ah_valid = ah->sc_ah.ah_info.ah_valid; 4264 + if (!memcmp(&ah->sc_ah.ah_info, &new_ah->sc_ah.ah_info, 4265 + sizeof(ah->sc_ah.ah_info))) { 4266 + refcount_inc(&ah->refcnt); 4267 + new_ah->parent_ah = ah; 4268 + return true; 4219 4269 } 4220 4270 } 4221 4271 4222 - if (udata) { 4223 - uresp.ah_id = ah->sc_ah.ah_info.ah_idx; 4224 - err = ib_copy_to_udata(udata, &uresp, 4225 - min(sizeof(uresp), udata->outlen)); 4226 - } 4227 - return 0; 4228 - 4229 - error: 4230 - irdma_free_rsrc(iwdev->rf, iwdev->rf->allocated_ahs, ah_id); 4231 - 4232 - return err; 4272 + return false; 4233 4273 } 4234 4274 4235 4275 /** ··· 4237 4287 struct irdma_device *iwdev = to_iwdev(ibah->device); 4238 4288 struct irdma_ah *ah = to_iwah(ibah); 4239 4289 4290 + if ((ah_flags & RDMA_DESTROY_AH_SLEEPABLE) && ah->parent_ah) { 4291 + mutex_lock(&iwdev->ah_tbl_lock); 4292 + if (!refcount_dec_and_test(&ah->parent_ah->refcnt)) { 4293 + mutex_unlock(&iwdev->ah_tbl_lock); 4294 + return 0; 4295 + } 4296 + hash_del(&ah->parent_ah->list); 4297 + kfree(ah->parent_ah); 4298 + mutex_unlock(&iwdev->ah_tbl_lock); 4299 + } 4300 + 4240 4301 irdma_ah_cqp_op(iwdev->rf, &ah->sc_ah, IRDMA_OP_AH_DESTROY, 4241 4302 false, NULL, ah); 4242 4303 ··· 4255 4294 ah->sc_ah.ah_info.ah_idx); 4256 4295 4257 4296 return 0; 4297 + } 4298 + 4299 + /** 4300 + * irdma_create_user_ah - create user address handle 4301 + * @ibah: address handle 4302 + * @attr: address handle attributes 4303 + * @udata: User data 4304 + * 4305 + * returns 0 on success, error otherwise 4306 + */ 4307 + static int irdma_create_user_ah(struct ib_ah *ibah, 4308 + struct rdma_ah_init_attr *attr, 4309 + struct ib_udata *udata) 4310 + { 4311 + struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); 4312 + struct irdma_device *iwdev = to_iwdev(ibah->pd->device); 4313 + struct irdma_create_ah_resp uresp; 4314 + struct irdma_ah *parent_ah; 4315 + int err; 4316 + 4317 + err = irdma_setup_ah(ibah, attr); 4318 + if (err) 4319 + return err; 4320 + mutex_lock(&iwdev->ah_tbl_lock); 4321 + if (!irdma_ah_exists(iwdev, ah)) { 4322 + err = irdma_create_hw_ah(iwdev, ah, true); 4323 + if (err) { 4324 + mutex_unlock(&iwdev->ah_tbl_lock); 4325 + return err; 4326 + } 4327 + /* Add new AH to list */ 4328 + parent_ah = kmemdup(ah, sizeof(*ah), GFP_KERNEL); 4329 + if (parent_ah) { 4330 + u32 key = parent_ah->sc_ah.ah_info.dest_ip_addr[0] ^ 4331 + parent_ah->sc_ah.ah_info.dest_ip_addr[1] ^ 4332 + parent_ah->sc_ah.ah_info.dest_ip_addr[2] ^ 4333 + parent_ah->sc_ah.ah_info.dest_ip_addr[3]; 4334 + 4335 + ah->parent_ah = parent_ah; 4336 + hash_add(iwdev->ah_hash_tbl, &parent_ah->list, key); 4337 + refcount_set(&parent_ah->refcnt, 1); 4338 + } 4339 + } 4340 + mutex_unlock(&iwdev->ah_tbl_lock); 4341 + 4342 + uresp.ah_id = ah->sc_ah.ah_info.ah_idx; 4343 + err = ib_copy_to_udata(udata, &uresp, min(sizeof(uresp), udata->outlen)); 4344 + if (err) 4345 + irdma_destroy_ah(ibah, attr->flags); 4346 + 4347 + return err; 4348 + } 4349 + 4350 + /** 4351 + * irdma_create_ah - create address handle 4352 + * @ibah: address handle 4353 + * @attr: address handle attributes 4354 + * @udata: NULL 4355 + * 4356 + * returns 0 on success, error otherwise 4357 + */ 4358 + static int irdma_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *attr, 4359 + struct ib_udata *udata) 4360 + { 4361 + struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); 4362 + struct irdma_device *iwdev = to_iwdev(ibah->pd->device); 4363 + int err; 4364 + 4365 + err = irdma_setup_ah(ibah, attr); 4366 + if (err) 4367 + return err; 4368 + err = irdma_create_hw_ah(iwdev, ah, attr->flags & RDMA_CREATE_AH_SLEEPABLE); 4369 + 4370 + return err; 4258 4371 } 4259 4372 4260 4373 /** ··· 4364 4329 static const struct ib_device_ops irdma_roce_dev_ops = { 4365 4330 .attach_mcast = irdma_attach_mcast, 4366 4331 .create_ah = irdma_create_ah, 4367 - .create_user_ah = irdma_create_ah, 4332 + .create_user_ah = irdma_create_user_ah, 4368 4333 .destroy_ah = irdma_destroy_ah, 4369 4334 .detach_mcast = irdma_detach_mcast, 4370 4335 .get_link_layer = irdma_get_link_layer,
+10 -5
drivers/infiniband/hw/irdma/verbs.h
··· 25 25 struct irdma_sc_pd sc_pd; 26 26 }; 27 27 28 + union irdma_sockaddr { 29 + struct sockaddr_in saddr_in; 30 + struct sockaddr_in6 saddr_in6; 31 + }; 32 + 28 33 struct irdma_av { 29 34 u8 macaddr[16]; 30 35 struct rdma_ah_attr attrs; 31 - union { 32 - struct sockaddr saddr; 33 - struct sockaddr_in saddr_in; 34 - struct sockaddr_in6 saddr_in6; 35 - } sgid_addr, dgid_addr; 36 + union irdma_sockaddr sgid_addr; 37 + union irdma_sockaddr dgid_addr; 36 38 u8 net_type; 37 39 }; 38 40 ··· 45 43 struct irdma_av av; 46 44 u8 sgid_index; 47 45 union ib_gid dgid; 46 + struct hlist_node list; 47 + refcount_t refcnt; 48 + struct irdma_ah *parent_ah; /* AH from cached list */ 48 49 }; 49 50 50 51 struct irdma_hmc_pble {
+9 -10
drivers/infiniband/hw/irdma/ws.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB 2 2 /* Copyright (c) 2017 - 2021 Intel Corporation */ 3 3 #include "osdep.h" 4 - #include "status.h" 5 4 #include "hmc.h" 6 5 #include "defs.h" 7 6 #include "type.h" ··· 86 87 * @node: pointer to node 87 88 * @cmd: add, remove or modify 88 89 */ 89 - static enum irdma_status_code 90 - irdma_ws_cqp_cmd(struct irdma_sc_vsi *vsi, struct irdma_ws_node *node, u8 cmd) 90 + static int irdma_ws_cqp_cmd(struct irdma_sc_vsi *vsi, 91 + struct irdma_ws_node *node, u8 cmd) 91 92 { 92 93 struct irdma_ws_node_info node_info = {}; 93 94 ··· 105 106 node_info.enable = node->enable; 106 107 if (irdma_cqp_ws_node_cmd(vsi->dev, cmd, &node_info)) { 107 108 ibdev_dbg(to_ibdev(vsi->dev), "WS: CQP WS CMD failed\n"); 108 - return IRDMA_ERR_NO_MEMORY; 109 + return -ENOMEM; 109 110 } 110 111 111 112 if (node->type_leaf && cmd == IRDMA_OP_WS_ADD_NODE) { ··· 233 234 * @vsi: vsi pointer 234 235 * @user_pri: user priority 235 236 */ 236 - enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) 237 + int irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) 237 238 { 238 239 struct irdma_ws_node *ws_tree_root; 239 240 struct irdma_ws_node *vsi_node; 240 241 struct irdma_ws_node *tc_node; 241 242 u16 traffic_class; 242 - enum irdma_status_code ret = 0; 243 + int ret = 0; 243 244 int i; 244 245 245 246 mutex_lock(&vsi->dev->ws_mutex); 246 247 if (vsi->tc_change_pending) { 247 - ret = IRDMA_ERR_NOT_READY; 248 + ret = -EBUSY; 248 249 goto exit; 249 250 } 250 251 ··· 257 258 ws_tree_root = irdma_alloc_node(vsi, user_pri, 258 259 WS_NODE_TYPE_PARENT, NULL); 259 260 if (!ws_tree_root) { 260 - ret = IRDMA_ERR_NO_MEMORY; 261 + ret = -ENOMEM; 261 262 goto exit; 262 263 } 263 264 ··· 282 283 vsi_node = irdma_alloc_node(vsi, user_pri, WS_NODE_TYPE_PARENT, 283 284 ws_tree_root); 284 285 if (!vsi_node) { 285 - ret = IRDMA_ERR_NO_MEMORY; 286 + ret = -ENOMEM; 286 287 goto vsi_add_err; 287 288 } 288 289 ··· 309 310 tc_node = irdma_alloc_node(vsi, user_pri, WS_NODE_TYPE_LEAF, 310 311 vsi_node); 311 312 if (!tc_node) { 312 - ret = IRDMA_ERR_NO_MEMORY; 313 + ret = -ENOMEM; 313 314 goto leaf_add_err; 314 315 } 315 316
+1 -1
drivers/infiniband/hw/irdma/ws.h
··· 34 34 }; 35 35 36 36 struct irdma_sc_vsi; 37 - enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri); 37 + int irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri); 38 38 void irdma_ws_remove(struct irdma_sc_vsi *vsi, u8 user_pri); 39 39 void irdma_ws_reset(struct irdma_sc_vsi *vsi); 40 40
-1
drivers/infiniband/hw/mlx4/alias_GUID.c
··· 38 38 #include <rdma/ib_sa.h> 39 39 #include <rdma/ib_pack.h> 40 40 #include <linux/mlx4/cmd.h> 41 - #include <linux/module.h> 42 41 #include <linux/init.h> 43 42 #include <linux/errno.h> 44 43 #include <rdma/ib_user_verbs.h>
-1
drivers/infiniband/hw/mlx4/srq.c
··· 320 320 if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) { 321 321 err = -EIO; 322 322 *bad_wr = wr; 323 - nreq = 0; 324 323 goto out; 325 324 } 326 325
+3 -1
drivers/infiniband/hw/mlx5/devx.c
··· 1895 1895 key_level2, 1896 1896 obj_event, 1897 1897 GFP_KERNEL); 1898 - if (err) 1898 + if (err) { 1899 + kfree(obj_event); 1899 1900 return err; 1901 + } 1900 1902 INIT_LIST_HEAD(&obj_event->obj_sub_list); 1901 1903 } 1902 1904
-1
drivers/infiniband/hw/mlx5/ib_virt.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/module.h> 34 33 #include <linux/mlx5/vport.h> 35 34 #include "mlx5_ib.h" 36 35
-1
drivers/infiniband/hw/mlx5/mem.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/module.h> 34 33 #include <rdma/ib_umem.h> 35 34 #include <rdma/ib_umem_odp.h> 36 35 #include "mlx5_ib.h"
+3 -9
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 763 763 764 764 char name[4]; 765 765 u32 order; 766 - u32 xlt; 767 766 u32 access_mode; 768 767 u32 page; 768 + unsigned int ndescs; 769 769 770 770 u8 disabled:1; 771 771 u8 fill_to_high_water:1; ··· 788 788 u32 miss; 789 789 790 790 struct mlx5_ib_dev *dev; 791 - struct work_struct work; 792 791 struct delayed_work dwork; 793 792 }; 794 793 ··· 1343 1344 int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev); 1344 1345 1345 1346 struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, 1346 - unsigned int entry, int access_flags); 1347 + struct mlx5_cache_ent *ent, 1348 + int access_flags); 1347 1349 1348 1350 int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask, 1349 1351 struct ib_mr_status *mr_status); ··· 1537 1537 { 1538 1538 return lib_support && MLX5_CAP_GEN(dev->mdev, uar_4k) ? 1539 1539 MLX5_UARS_IN_PAGE : 1; 1540 - } 1541 - 1542 - static inline int get_num_static_uars(struct mlx5_ib_dev *dev, 1543 - struct mlx5_bfreg_info *bfregi) 1544 - { 1545 - return get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * bfregi->num_static_sys_pages; 1546 1540 } 1547 1541 1548 1542 extern void *xlt_emergency_page;
+39 -65
drivers/infiniband/hw/mlx5/mr.c
··· 68 68 struct ib_pd *pd) 69 69 { 70 70 struct mlx5_ib_dev *dev = to_mdev(pd->device); 71 - bool ro_pci_enabled = pcie_relaxed_ordering_enabled(dev->mdev->pdev); 72 71 73 72 MLX5_SET(mkc, mkc, a, !!(acc & IB_ACCESS_REMOTE_ATOMIC)); 74 73 MLX5_SET(mkc, mkc, rw, !!(acc & IB_ACCESS_REMOTE_WRITE)); ··· 75 76 MLX5_SET(mkc, mkc, lw, !!(acc & IB_ACCESS_LOCAL_WRITE)); 76 77 MLX5_SET(mkc, mkc, lr, 1); 77 78 78 - if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_write)) 79 - MLX5_SET(mkc, mkc, relaxed_ordering_write, 80 - (acc & IB_ACCESS_RELAXED_ORDERING) && ro_pci_enabled); 81 - if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_read)) 82 - MLX5_SET(mkc, mkc, relaxed_ordering_read, 83 - (acc & IB_ACCESS_RELAXED_ORDERING) && ro_pci_enabled); 79 + if ((acc & IB_ACCESS_RELAXED_ORDERING) && 80 + pcie_relaxed_ordering_enabled(dev->mdev->pdev)) { 81 + if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_write)) 82 + MLX5_SET(mkc, mkc, relaxed_ordering_write, 1); 83 + if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_read)) 84 + MLX5_SET(mkc, mkc, relaxed_ordering_read, 1); 85 + } 84 86 85 87 MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn); 86 88 MLX5_SET(mkc, mkc, qpn, 0xffffff); ··· 189 189 spin_unlock_irqrestore(&ent->lock, flags); 190 190 } 191 191 192 + static int get_mkc_octo_size(unsigned int access_mode, unsigned int ndescs) 193 + { 194 + int ret = 0; 195 + 196 + switch (access_mode) { 197 + case MLX5_MKC_ACCESS_MODE_MTT: 198 + ret = DIV_ROUND_UP(ndescs, MLX5_IB_UMR_OCTOWORD / 199 + sizeof(struct mlx5_mtt)); 200 + break; 201 + case MLX5_MKC_ACCESS_MODE_KSM: 202 + ret = DIV_ROUND_UP(ndescs, MLX5_IB_UMR_OCTOWORD / 203 + sizeof(struct mlx5_klm)); 204 + break; 205 + default: 206 + WARN_ON(1); 207 + } 208 + return ret; 209 + } 210 + 192 211 static struct mlx5_ib_mr *alloc_cache_mr(struct mlx5_cache_ent *ent, void *mkc) 193 212 { 194 213 struct mlx5_ib_mr *mr; ··· 223 204 MLX5_SET(mkc, mkc, access_mode_1_0, ent->access_mode & 0x3); 224 205 MLX5_SET(mkc, mkc, access_mode_4_2, (ent->access_mode >> 2) & 0x7); 225 206 226 - MLX5_SET(mkc, mkc, translations_octword_size, ent->xlt); 207 + MLX5_SET(mkc, mkc, translations_octword_size, 208 + get_mkc_octo_size(ent->access_mode, ent->ndescs)); 227 209 MLX5_SET(mkc, mkc, log_page_size, ent->page); 228 210 return mr; 229 211 } ··· 498 478 return; 499 479 if (ent->available_mrs < ent->limit) { 500 480 ent->fill_to_high_water = true; 501 - queue_work(ent->dev->cache.wq, &ent->work); 481 + mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0); 502 482 } else if (ent->fill_to_high_water && 503 483 ent->available_mrs + ent->pending < 2 * ent->limit) { 504 484 /* 505 485 * Once we start populating due to hitting a low water mark 506 486 * continue until we pass the high water mark. 507 487 */ 508 - queue_work(ent->dev->cache.wq, &ent->work); 488 + mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0); 509 489 } else if (ent->available_mrs == 2 * ent->limit) { 510 490 ent->fill_to_high_water = false; 511 491 } else if (ent->available_mrs > 2 * ent->limit) { ··· 515 495 queue_delayed_work(ent->dev->cache.wq, &ent->dwork, 516 496 msecs_to_jiffies(1000)); 517 497 else 518 - queue_work(ent->dev->cache.wq, &ent->work); 498 + mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0); 519 499 } 520 500 } 521 501 ··· 591 571 __cache_work_func(ent); 592 572 } 593 573 594 - static void cache_work_func(struct work_struct *work) 595 - { 596 - struct mlx5_cache_ent *ent; 597 - 598 - ent = container_of(work, struct mlx5_cache_ent, work); 599 - __cache_work_func(ent); 600 - } 601 - 602 - /* Allocate a special entry from the cache */ 603 574 struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, 604 - unsigned int entry, int access_flags) 575 + struct mlx5_cache_ent *ent, 576 + int access_flags) 605 577 { 606 - struct mlx5_mr_cache *cache = &dev->cache; 607 - struct mlx5_cache_ent *ent; 608 578 struct mlx5_ib_mr *mr; 609 - 610 - if (WARN_ON(entry <= MR_CACHE_LAST_STD_ENTRY || 611 - entry >= ARRAY_SIZE(cache->ent))) 612 - return ERR_PTR(-EINVAL); 613 579 614 580 /* Matches access in alloc_cache_mr() */ 615 581 if (!mlx5_ib_can_reconfig_with_umr(dev, 0, access_flags)) 616 582 return ERR_PTR(-EOPNOTSUPP); 617 583 618 - ent = &cache->ent[entry]; 619 584 spin_lock_irq(&ent->lock); 620 585 if (list_empty(&ent->head)) { 586 + queue_adjust_cache_locked(ent); 587 + ent->miss++; 621 588 spin_unlock_irq(&ent->lock); 622 589 mr = create_cache_mr(ent); 623 590 if (IS_ERR(mr)) ··· 618 611 619 612 mlx5_clear_mr(mr); 620 613 } 621 - mr->access_flags = access_flags; 622 614 return mr; 623 - } 624 - 625 - /* Return a MR already available in the cache */ 626 - static struct mlx5_ib_mr *get_cache_mr(struct mlx5_cache_ent *req_ent) 627 - { 628 - struct mlx5_ib_mr *mr = NULL; 629 - struct mlx5_cache_ent *ent = req_ent; 630 - 631 - spin_lock_irq(&ent->lock); 632 - if (!list_empty(&ent->head)) { 633 - mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list); 634 - list_del(&mr->list); 635 - ent->available_mrs--; 636 - queue_adjust_cache_locked(ent); 637 - spin_unlock_irq(&ent->lock); 638 - mlx5_clear_mr(mr); 639 - return mr; 640 - } 641 - queue_adjust_cache_locked(ent); 642 - spin_unlock_irq(&ent->lock); 643 - req_ent->miss++; 644 - return NULL; 645 615 } 646 616 647 617 static void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) ··· 723 739 ent->dev = dev; 724 740 ent->limit = 0; 725 741 726 - INIT_WORK(&ent->work, cache_work_func); 727 742 INIT_DELAYED_WORK(&ent->dwork, delayed_cache_work_func); 728 743 729 744 if (i > MR_CACHE_LAST_STD_ENTRY) { ··· 734 751 continue; 735 752 736 753 ent->page = PAGE_SHIFT; 737 - ent->xlt = (1 << ent->order) * sizeof(struct mlx5_mtt) / 738 - MLX5_IB_UMR_OCTOWORD; 754 + ent->ndescs = 1 << ent->order; 739 755 ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; 740 756 if ((dev->mdev->profile.mask & MLX5_PROF_MASK_MR_CACHE) && 741 757 !dev->is_rep && mlx5_core_is_pf(dev->mdev) && ··· 765 783 spin_lock_irq(&ent->lock); 766 784 ent->disabled = true; 767 785 spin_unlock_irq(&ent->lock); 768 - cancel_work_sync(&ent->work); 769 786 cancel_delayed_work_sync(&ent->dwork); 770 787 } 771 788 ··· 953 972 return mr; 954 973 } 955 974 956 - mr = get_cache_mr(ent); 957 - if (!mr) { 958 - mr = create_cache_mr(ent); 959 - /* 960 - * The above already tried to do the same stuff as reg_create(), 961 - * no reason to try it again. 962 - */ 963 - if (IS_ERR(mr)) 964 - return mr; 965 - } 975 + mr = mlx5_mr_cache_alloc(dev, ent, access_flags); 976 + if (IS_ERR(mr)) 977 + return mr; 966 978 967 979 mr->ibmr.pd = pd; 968 980 mr->umem = umem;
+10 -9
drivers/infiniband/hw/mlx5/odp.c
··· 407 407 static struct mlx5_ib_mr *implicit_get_child_mr(struct mlx5_ib_mr *imr, 408 408 unsigned long idx) 409 409 { 410 + struct mlx5_ib_dev *dev = mr_to_mdev(imr); 410 411 struct ib_umem_odp *odp; 411 412 struct mlx5_ib_mr *mr; 412 413 struct mlx5_ib_mr *ret; ··· 419 418 if (IS_ERR(odp)) 420 419 return ERR_CAST(odp); 421 420 422 - mr = mlx5_mr_cache_alloc( 423 - mr_to_mdev(imr), MLX5_IMR_MTT_CACHE_ENTRY, imr->access_flags); 421 + mr = mlx5_mr_cache_alloc(dev, &dev->cache.ent[MLX5_IMR_MTT_CACHE_ENTRY], 422 + imr->access_flags); 424 423 if (IS_ERR(mr)) { 425 424 ib_umem_odp_release(odp); 426 425 return mr; 427 426 } 428 427 428 + mr->access_flags = imr->access_flags; 429 429 mr->ibmr.pd = imr->ibmr.pd; 430 430 mr->ibmr.device = &mr_to_mdev(imr)->ib_dev; 431 431 mr->umem = &odp->umem; ··· 495 493 if (IS_ERR(umem_odp)) 496 494 return ERR_CAST(umem_odp); 497 495 498 - imr = mlx5_mr_cache_alloc(dev, MLX5_IMR_KSM_CACHE_ENTRY, access_flags); 496 + imr = mlx5_mr_cache_alloc(dev, 497 + &dev->cache.ent[MLX5_IMR_KSM_CACHE_ENTRY], 498 + access_flags); 499 499 if (IS_ERR(imr)) { 500 500 ib_umem_odp_release(umem_odp); 501 501 return imr; 502 502 } 503 503 504 + imr->access_flags = access_flags; 504 505 imr->ibmr.pd = &pd->ibpd; 505 506 imr->ibmr.iova = 0; 506 507 imr->umem = &umem_odp->umem; ··· 1598 1593 switch (ent->order - 2) { 1599 1594 case MLX5_IMR_MTT_CACHE_ENTRY: 1600 1595 ent->page = PAGE_SHIFT; 1601 - ent->xlt = MLX5_IMR_MTT_ENTRIES * 1602 - sizeof(struct mlx5_mtt) / 1603 - MLX5_IB_UMR_OCTOWORD; 1596 + ent->ndescs = MLX5_IMR_MTT_ENTRIES; 1604 1597 ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; 1605 1598 ent->limit = 0; 1606 1599 break; 1607 1600 1608 1601 case MLX5_IMR_KSM_CACHE_ENTRY: 1609 1602 ent->page = MLX5_KSM_PAGE_SHIFT; 1610 - ent->xlt = mlx5_imr_ksm_entries * 1611 - sizeof(struct mlx5_klm) / 1612 - MLX5_IB_UMR_OCTOWORD; 1603 + ent->ndescs = mlx5_imr_ksm_entries; 1613 1604 ent->access_mode = MLX5_MKC_ACCESS_MODE_KSM; 1614 1605 ent->limit = 0; 1615 1606 break;
+2 -2
drivers/infiniband/hw/mlx5/qp.c
··· 31 31 */ 32 32 33 33 #include <linux/etherdevice.h> 34 - #include <linux/module.h> 35 34 #include <rdma/ib_umem.h> 36 35 #include <rdma/ib_cache.h> 37 36 #include <rdma/ib_user_verbs.h> ··· 614 615 615 616 static int max_bfregs(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi) 616 617 { 617 - return get_num_static_uars(dev, bfregi) * MLX5_NON_FP_BFREGS_PER_UAR; 618 + return get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * 619 + bfregi->num_static_sys_pages * MLX5_NON_FP_BFREGS_PER_UAR; 618 620 } 619 621 620 622 static int num_med_bfreg(struct mlx5_ib_dev *dev,
-1
drivers/infiniband/hw/mlx5/srq.c
··· 3 3 * Copyright (c) 2013-2018, Mellanox Technologies inc. All rights reserved. 4 4 */ 5 5 6 - #include <linux/module.h> 7 6 #include <linux/mlx5/qp.h> 8 7 #include <linux/slab.h> 9 8 #include <rdma/ib_umem.h>
+2 -6
drivers/infiniband/hw/mthca/mthca_main.c
··· 939 939 940 940 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 941 941 if (err) { 942 - dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n"); 943 - err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 944 - if (err) { 945 - dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); 946 - goto err_free_res; 947 - } 942 + dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); 943 + goto err_free_res; 948 944 } 949 945 950 946 /* We can handle large RDMA requests, so allow larger segments. */
-2
drivers/infiniband/hw/mthca/mthca_profile.c
··· 31 31 * SOFTWARE. 32 32 */ 33 33 34 - #include <linux/module.h> 35 - #include <linux/moduleparam.h> 36 34 #include <linux/string.h> 37 35 #include <linux/slab.h> 38 36
-1
drivers/infiniband/hw/qib/qib_fs.c
··· 32 32 * SOFTWARE. 33 33 */ 34 34 35 - #include <linux/module.h> 36 35 #include <linux/fs.h> 37 36 #include <linux/fs_context.h> 38 37 #include <linux/mount.h>
+2 -2
drivers/infiniband/hw/qib/qib_iba7220.c
··· 634 634 QLOGIC_IB_HWE_MSG(QLOGIC_IB_HWE_PCIECPLTIMEOUT, 635 635 "PCIe completion timeout"), 636 636 /* 637 - * In practice, it's unlikely wthat we'll see PCIe PLL, or bus 637 + * In practice, it's unlikely that we'll see PCIe PLL, or bus 638 638 * parity or memory parity error failures, because most likely we 639 639 * won't be able to talk to the core of the chip. Nonetheless, we 640 640 * might see them, if they are in parts of the PCIe core that aren't ··· 2988 2988 * the utility. Names need to be 12 chars or less (w/o newline), for proper 2989 2989 * display by utility. 2990 2990 * Non-error counters are first. 2991 - * Start of "error" conters is indicated by a leading "E " on the first 2991 + * Start of "error" counters is indicated by a leading "E " on the first 2992 2992 * "error" counter, and doesn't count in label length. 2993 2993 * The EgrOvfl list needs to be last so we truncate them at the configured 2994 2994 * context count for the device.
-1
drivers/infiniband/hw/usnic/usnic_debugfs.c
··· 32 32 */ 33 33 34 34 #include <linux/debugfs.h> 35 - #include <linux/module.h> 36 35 37 36 #include "usnic.h" 38 37 #include "usnic_log.h"
-1
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
··· 32 32 */ 33 33 #include <linux/bug.h> 34 34 #include <linux/errno.h> 35 - #include <linux/module.h> 36 35 #include <linux/spinlock.h> 37 36 38 37 #include "usnic_log.h"
-1
drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
··· 31 31 * 32 32 */ 33 33 34 - #include <linux/module.h> 35 34 #include <linux/init.h> 36 35 #include <linux/errno.h> 37 36
-1
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
··· 30 30 * SOFTWARE. 31 31 * 32 32 */ 33 - #include <linux/module.h> 34 33 #include <linux/init.h> 35 34 #include <linux/slab.h> 36 35 #include <linux/errno.h>
-1
drivers/infiniband/hw/usnic/usnic_transport.c
··· 32 32 */ 33 33 #include <linux/bitmap.h> 34 34 #include <linux/file.h> 35 - #include <linux/module.h> 36 35 #include <linux/slab.h> 37 36 #include <net/inet_sock.h> 38 37
-1
drivers/infiniband/hw/usnic/usnic_vnic.c
··· 31 31 * 32 32 */ 33 33 #include <linux/errno.h> 34 - #include <linux/module.h> 35 34 #include <linux/pci.h> 36 35 37 36 #include "usnic_ib.h"
+4 -6
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
··· 811 811 } 812 812 813 813 /* Enable 64-Bit DMA */ 814 - if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0) { 815 - ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 816 - if (ret != 0) { 817 - dev_err(&pdev->dev, "dma_set_mask failed\n"); 818 - goto err_free_resource; 819 - } 814 + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 815 + if (ret) { 816 + dev_err(&pdev->dev, "dma_set_mask failed\n"); 817 + goto err_free_resource; 820 818 } 821 819 dma_set_max_seg_size(&pdev->dev, UINT_MAX); 822 820 pci_set_master(pdev);
+18 -92
drivers/infiniband/sw/rxe/rxe.c
··· 28 28 rxe_pool_cleanup(&rxe->cq_pool); 29 29 rxe_pool_cleanup(&rxe->mr_pool); 30 30 rxe_pool_cleanup(&rxe->mw_pool); 31 - rxe_pool_cleanup(&rxe->mc_grp_pool); 32 - rxe_pool_cleanup(&rxe->mc_elem_pool); 31 + 32 + WARN_ON(!RB_EMPTY_ROOT(&rxe->mcg_tree)); 33 33 34 34 if (rxe->tfm) 35 35 crypto_free_shash(rxe->tfm); ··· 114 114 } 115 115 116 116 /* init pools of managed objects */ 117 - static int rxe_init_pools(struct rxe_dev *rxe) 117 + static void rxe_init_pools(struct rxe_dev *rxe) 118 118 { 119 - int err; 120 - 121 - err = rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC, 122 - rxe->max_ucontext); 123 - if (err) 124 - goto err1; 125 - 126 - err = rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD, 127 - rxe->attr.max_pd); 128 - if (err) 129 - goto err2; 130 - 131 - err = rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH, 132 - rxe->attr.max_ah); 133 - if (err) 134 - goto err3; 135 - 136 - err = rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ, 137 - rxe->attr.max_srq); 138 - if (err) 139 - goto err4; 140 - 141 - err = rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP, 142 - rxe->attr.max_qp); 143 - if (err) 144 - goto err5; 145 - 146 - err = rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ, 147 - rxe->attr.max_cq); 148 - if (err) 149 - goto err6; 150 - 151 - err = rxe_pool_init(rxe, &rxe->mr_pool, RXE_TYPE_MR, 152 - rxe->attr.max_mr); 153 - if (err) 154 - goto err7; 155 - 156 - err = rxe_pool_init(rxe, &rxe->mw_pool, RXE_TYPE_MW, 157 - rxe->attr.max_mw); 158 - if (err) 159 - goto err8; 160 - 161 - err = rxe_pool_init(rxe, &rxe->mc_grp_pool, RXE_TYPE_MC_GRP, 162 - rxe->attr.max_mcast_grp); 163 - if (err) 164 - goto err9; 165 - 166 - err = rxe_pool_init(rxe, &rxe->mc_elem_pool, RXE_TYPE_MC_ELEM, 167 - rxe->attr.max_total_mcast_qp_attach); 168 - if (err) 169 - goto err10; 170 - 171 - return 0; 172 - 173 - err10: 174 - rxe_pool_cleanup(&rxe->mc_grp_pool); 175 - err9: 176 - rxe_pool_cleanup(&rxe->mw_pool); 177 - err8: 178 - rxe_pool_cleanup(&rxe->mr_pool); 179 - err7: 180 - rxe_pool_cleanup(&rxe->cq_pool); 181 - err6: 182 - rxe_pool_cleanup(&rxe->qp_pool); 183 - err5: 184 - rxe_pool_cleanup(&rxe->srq_pool); 185 - err4: 186 - rxe_pool_cleanup(&rxe->ah_pool); 187 - err3: 188 - rxe_pool_cleanup(&rxe->pd_pool); 189 - err2: 190 - rxe_pool_cleanup(&rxe->uc_pool); 191 - err1: 192 - return err; 119 + rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC); 120 + rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD); 121 + rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH); 122 + rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ); 123 + rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP); 124 + rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ); 125 + rxe_pool_init(rxe, &rxe->mr_pool, RXE_TYPE_MR); 126 + rxe_pool_init(rxe, &rxe->mw_pool, RXE_TYPE_MW); 193 127 } 194 128 195 129 /* initialize rxe device state */ 196 - static int rxe_init(struct rxe_dev *rxe) 130 + static void rxe_init(struct rxe_dev *rxe) 197 131 { 198 - int err; 199 - 200 132 /* init default device parameters */ 201 133 rxe_init_device_param(rxe); 202 134 203 135 rxe_init_ports(rxe); 204 - 205 - err = rxe_init_pools(rxe); 206 - if (err) 207 - return err; 136 + rxe_init_pools(rxe); 208 137 209 138 /* init pending mmap list */ 210 139 spin_lock_init(&rxe->mmap_offset_lock); 211 140 spin_lock_init(&rxe->pending_lock); 212 141 INIT_LIST_HEAD(&rxe->pending_mmaps); 213 142 214 - mutex_init(&rxe->usdev_lock); 143 + /* init multicast support */ 144 + spin_lock_init(&rxe->mcg_lock); 145 + rxe->mcg_tree = RB_ROOT; 215 146 216 - return 0; 147 + mutex_init(&rxe->usdev_lock); 217 148 } 218 149 219 150 void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu) ··· 166 235 */ 167 236 int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name) 168 237 { 169 - int err; 170 - 171 - err = rxe_init(rxe); 172 - if (err) 173 - return err; 174 - 238 + rxe_init(rxe); 175 239 rxe_set_mtu(rxe, mtu); 176 240 177 241 return rxe_register_device(rxe, ibdev_name);
-1
drivers/infiniband/sw/rxe/rxe.h
··· 12 12 #endif 13 13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 14 14 15 - #include <linux/module.h> 16 15 #include <linux/skbuff.h> 17 16 18 17 #include <rdma/ib_verbs.h>
+17 -2
drivers/infiniband/sw/rxe/rxe_av.c
··· 99 99 av->network_type = type; 100 100 } 101 101 102 - struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt) 102 + struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp) 103 103 { 104 104 struct rxe_ah *ah; 105 105 u32 ah_num; 106 + 107 + if (ahp) 108 + *ahp = NULL; 106 109 107 110 if (!pkt || !pkt->qp) 108 111 return NULL; ··· 120 117 if (ah_num) { 121 118 /* only new user provider or kernel client */ 122 119 ah = rxe_pool_get_index(&pkt->rxe->ah_pool, ah_num); 123 - if (!ah || ah->ah_num != ah_num || rxe_ah_pd(ah) != pkt->qp->pd) { 120 + if (!ah) { 124 121 pr_warn("Unable to find AH matching ah_num\n"); 125 122 return NULL; 126 123 } 124 + 125 + if (rxe_ah_pd(ah) != pkt->qp->pd) { 126 + pr_warn("PDs don't match for AH and QP\n"); 127 + rxe_put(ah); 128 + return NULL; 129 + } 130 + 131 + if (ahp) 132 + *ahp = ah; 133 + else 134 + rxe_put(ah); 135 + 127 136 return &ah->av; 128 137 } 129 138
+4 -4
drivers/infiniband/sw/rxe/rxe_comp.c
··· 526 526 struct rxe_queue *q = qp->sq.queue; 527 527 528 528 while ((skb = skb_dequeue(&qp->resp_pkts))) { 529 - rxe_drop_ref(qp); 529 + rxe_put(qp); 530 530 kfree_skb(skb); 531 531 ib_device_put(qp->ibqp.device); 532 532 } ··· 548 548 struct ib_device *dev = qp->ibqp.device; 549 549 550 550 kfree_skb(skb); 551 - rxe_drop_ref(qp); 551 + rxe_put(qp); 552 552 ib_device_put(dev); 553 553 } 554 554 ··· 562 562 enum comp_state state; 563 563 int ret = 0; 564 564 565 - rxe_add_ref(qp); 565 + rxe_get(qp); 566 566 567 567 if (!qp->valid || qp->req.state == QP_STATE_ERROR || 568 568 qp->req.state == QP_STATE_RESET) { ··· 761 761 done: 762 762 if (pkt) 763 763 free_pkt(pkt); 764 - rxe_drop_ref(qp); 764 + rxe_put(qp); 765 765 766 766 return ret; 767 767 }
+12 -8
drivers/infiniband/sw/rxe/rxe_cq.c
··· 42 42 static void rxe_send_complete(struct tasklet_struct *t) 43 43 { 44 44 struct rxe_cq *cq = from_tasklet(cq, t, comp_task); 45 + unsigned long flags; 45 46 46 - spin_lock_bh(&cq->cq_lock); 47 + spin_lock_irqsave(&cq->cq_lock, flags); 47 48 if (cq->is_dying) { 48 - spin_unlock_bh(&cq->cq_lock); 49 + spin_unlock_irqrestore(&cq->cq_lock, flags); 49 50 return; 50 51 } 51 - spin_unlock_bh(&cq->cq_lock); 52 + spin_unlock_irqrestore(&cq->cq_lock, flags); 52 53 53 54 cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context); 54 55 } ··· 108 107 struct ib_event ev; 109 108 int full; 110 109 void *addr; 110 + unsigned long flags; 111 111 112 - spin_lock_bh(&cq->cq_lock); 112 + spin_lock_irqsave(&cq->cq_lock, flags); 113 113 114 114 full = queue_full(cq->queue, QUEUE_TYPE_TO_CLIENT); 115 115 if (unlikely(full)) { 116 - spin_unlock_bh(&cq->cq_lock); 116 + spin_unlock_irqrestore(&cq->cq_lock, flags); 117 117 if (cq->ibcq.event_handler) { 118 118 ev.device = cq->ibcq.device; 119 119 ev.element.cq = &cq->ibcq; ··· 130 128 131 129 queue_advance_producer(cq->queue, QUEUE_TYPE_TO_CLIENT); 132 130 133 - spin_unlock_bh(&cq->cq_lock); 131 + spin_unlock_irqrestore(&cq->cq_lock, flags); 134 132 135 133 if ((cq->notify == IB_CQ_NEXT_COMP) || 136 134 (cq->notify == IB_CQ_SOLICITED && solicited)) { ··· 143 141 144 142 void rxe_cq_disable(struct rxe_cq *cq) 145 143 { 146 - spin_lock_bh(&cq->cq_lock); 144 + unsigned long flags; 145 + 146 + spin_lock_irqsave(&cq->cq_lock, flags); 147 147 cq->is_dying = true; 148 - spin_unlock_bh(&cq->cq_lock); 148 + spin_unlock_irqrestore(&cq->cq_lock, flags); 149 149 } 150 150 151 151 void rxe_cq_cleanup(struct rxe_pool_elem *elem)
+8 -24
drivers/infiniband/sw/rxe/rxe_loc.h
··· 19 19 20 20 void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr); 21 21 22 - struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt); 22 + struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp); 23 23 24 24 /* rxe_cq.c */ 25 25 int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq, ··· 40 40 void rxe_cq_cleanup(struct rxe_pool_elem *arg); 41 41 42 42 /* rxe_mcast.c */ 43 - int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, 44 - struct rxe_mc_grp **grp_p); 45 - 46 - int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, 47 - struct rxe_mc_grp *grp); 48 - 49 - int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, 50 - union ib_gid *mgid); 51 - 52 - void rxe_drop_all_mcast_groups(struct rxe_qp *qp); 53 - 54 - void rxe_mc_cleanup(struct rxe_pool_elem *arg); 43 + struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid); 44 + int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); 45 + int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); 46 + void rxe_cleanup_mcg(struct kref *kref); 55 47 56 48 /* rxe_mmap.c */ 57 49 struct rxe_mmap_info { ··· 94 102 /* rxe_net.c */ 95 103 struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, 96 104 int paylen, struct rxe_pkt_info *pkt); 97 - int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb); 105 + int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, 106 + struct sk_buff *skb); 98 107 int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, 99 108 struct sk_buff *skb); 100 109 const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num); 101 - int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid); 102 - int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid); 103 110 104 111 /* rxe_qp.c */ 105 112 int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init); 106 - 107 113 int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, 108 114 struct ib_qp_init_attr *init, 109 115 struct rxe_create_qp_resp __user *uresp, 110 116 struct ib_pd *ibpd, struct ib_udata *udata); 111 - 112 117 int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init); 113 - 114 118 int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, 115 119 struct ib_qp_attr *attr, int mask); 116 - 117 120 int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, 118 121 int mask, struct ib_udata *udata); 119 - 120 122 int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask); 121 - 122 123 void rxe_qp_error(struct rxe_qp *qp); 123 - 124 + int rxe_qp_chk_destroy(struct rxe_qp *qp); 124 125 void rxe_qp_destroy(struct rxe_qp *qp); 125 - 126 126 void rxe_qp_cleanup(struct rxe_pool_elem *elem); 127 127 128 128 static inline int qp_num(struct rxe_qp *qp)
+433 -123
drivers/infiniband/sw/rxe/rxe_mcast.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2 2 /* 3 + * Copyright (c) 2022 Hewlett Packard Enterprise, Inc. All rights reserved. 3 4 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. 4 5 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. 5 6 */ 6 7 8 + /* 9 + * rxe_mcast.c implements driver support for multicast transport. 10 + * It is based on two data structures struct rxe_mcg ('mcg') and 11 + * struct rxe_mca ('mca'). An mcg is allocated each time a qp is 12 + * attached to a new mgid for the first time. These are indexed by 13 + * a red-black tree using the mgid. This data structure is searched 14 + * for the mcg when a multicast packet is received and when another 15 + * qp is attached to the same mgid. It is cleaned up when the last qp 16 + * is detached from the mcg. Each time a qp is attached to an mcg an 17 + * mca is created. It holds a pointer to the qp and is added to a list 18 + * of qp's that are attached to the mcg. The qp_list is used to replicate 19 + * mcast packets in the rxe receive path. 20 + */ 21 + 7 22 #include "rxe.h" 8 - #include "rxe_loc.h" 9 23 10 - /* caller should hold mc_grp_pool->pool_lock */ 11 - static struct rxe_mc_grp *create_grp(struct rxe_dev *rxe, 12 - struct rxe_pool *pool, 13 - union ib_gid *mgid) 24 + /** 25 + * rxe_mcast_add - add multicast address to rxe device 26 + * @rxe: rxe device object 27 + * @mgid: multicast address as a gid 28 + * 29 + * Returns 0 on success else an error 30 + */ 31 + static int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid) 14 32 { 15 - int err; 16 - struct rxe_mc_grp *grp; 33 + unsigned char ll_addr[ETH_ALEN]; 17 34 18 - grp = rxe_alloc_locked(&rxe->mc_grp_pool); 19 - if (!grp) 20 - return ERR_PTR(-ENOMEM); 35 + ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr); 21 36 22 - INIT_LIST_HEAD(&grp->qp_list); 23 - spin_lock_init(&grp->mcg_lock); 24 - grp->rxe = rxe; 25 - rxe_add_key_locked(grp, mgid); 26 - 27 - err = rxe_mcast_add(rxe, mgid); 28 - if (unlikely(err)) { 29 - rxe_drop_key_locked(grp); 30 - rxe_drop_ref(grp); 31 - return ERR_PTR(err); 32 - } 33 - 34 - return grp; 37 + return dev_mc_add(rxe->ndev, ll_addr); 35 38 } 36 39 37 - int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, 38 - struct rxe_mc_grp **grp_p) 40 + /** 41 + * rxe_mcast_delete - delete multicast address from rxe device 42 + * @rxe: rxe device object 43 + * @mgid: multicast address as a gid 44 + * 45 + * Returns 0 on success else an error 46 + */ 47 + static int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid) 39 48 { 40 - int err; 41 - struct rxe_mc_grp *grp; 42 - struct rxe_pool *pool = &rxe->mc_grp_pool; 49 + unsigned char ll_addr[ETH_ALEN]; 43 50 44 - if (rxe->attr.max_mcast_qp_attach == 0) 45 - return -EINVAL; 51 + ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr); 46 52 47 - write_lock_bh(&pool->pool_lock); 53 + return dev_mc_del(rxe->ndev, ll_addr); 54 + } 48 55 49 - grp = rxe_pool_get_key_locked(pool, mgid); 50 - if (grp) 51 - goto done; 56 + /** 57 + * __rxe_insert_mcg - insert an mcg into red-black tree (rxe->mcg_tree) 58 + * @mcg: mcg object with an embedded red-black tree node 59 + * 60 + * Context: caller must hold a reference to mcg and rxe->mcg_lock and 61 + * is responsible to avoid adding the same mcg twice to the tree. 62 + */ 63 + static void __rxe_insert_mcg(struct rxe_mcg *mcg) 64 + { 65 + struct rb_root *tree = &mcg->rxe->mcg_tree; 66 + struct rb_node **link = &tree->rb_node; 67 + struct rb_node *node = NULL; 68 + struct rxe_mcg *tmp; 69 + int cmp; 52 70 53 - grp = create_grp(rxe, pool, mgid); 54 - if (IS_ERR(grp)) { 55 - write_unlock_bh(&pool->pool_lock); 56 - err = PTR_ERR(grp); 57 - return err; 71 + while (*link) { 72 + node = *link; 73 + tmp = rb_entry(node, struct rxe_mcg, node); 74 + 75 + cmp = memcmp(&tmp->mgid, &mcg->mgid, sizeof(mcg->mgid)); 76 + if (cmp > 0) 77 + link = &(*link)->rb_left; 78 + else 79 + link = &(*link)->rb_right; 58 80 } 59 81 60 - done: 61 - write_unlock_bh(&pool->pool_lock); 62 - *grp_p = grp; 82 + rb_link_node(&mcg->node, node, link); 83 + rb_insert_color(&mcg->node, tree); 84 + } 85 + 86 + /** 87 + * __rxe_remove_mcg - remove an mcg from red-black tree holding lock 88 + * @mcg: mcast group object with an embedded red-black tree node 89 + * 90 + * Context: caller must hold a reference to mcg and rxe->mcg_lock 91 + */ 92 + static void __rxe_remove_mcg(struct rxe_mcg *mcg) 93 + { 94 + rb_erase(&mcg->node, &mcg->rxe->mcg_tree); 95 + } 96 + 97 + /** 98 + * __rxe_lookup_mcg - lookup mcg in rxe->mcg_tree while holding lock 99 + * @rxe: rxe device object 100 + * @mgid: multicast IP address 101 + * 102 + * Context: caller must hold rxe->mcg_lock 103 + * Returns: mcg on success and takes a ref to mcg else NULL 104 + */ 105 + static struct rxe_mcg *__rxe_lookup_mcg(struct rxe_dev *rxe, 106 + union ib_gid *mgid) 107 + { 108 + struct rb_root *tree = &rxe->mcg_tree; 109 + struct rxe_mcg *mcg; 110 + struct rb_node *node; 111 + int cmp; 112 + 113 + node = tree->rb_node; 114 + 115 + while (node) { 116 + mcg = rb_entry(node, struct rxe_mcg, node); 117 + 118 + cmp = memcmp(&mcg->mgid, mgid, sizeof(*mgid)); 119 + 120 + if (cmp > 0) 121 + node = node->rb_left; 122 + else if (cmp < 0) 123 + node = node->rb_right; 124 + else 125 + break; 126 + } 127 + 128 + if (node) { 129 + kref_get(&mcg->ref_cnt); 130 + return mcg; 131 + } 132 + 133 + return NULL; 134 + } 135 + 136 + /** 137 + * rxe_lookup_mcg - lookup up mcg in red-back tree 138 + * @rxe: rxe device object 139 + * @mgid: multicast IP address 140 + * 141 + * Returns: mcg if found else NULL 142 + */ 143 + struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid) 144 + { 145 + struct rxe_mcg *mcg; 146 + unsigned long flags; 147 + 148 + spin_lock_irqsave(&rxe->mcg_lock, flags); 149 + mcg = __rxe_lookup_mcg(rxe, mgid); 150 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 151 + 152 + return mcg; 153 + } 154 + 155 + /** 156 + * __rxe_init_mcg - initialize a new mcg 157 + * @rxe: rxe device 158 + * @mgid: multicast address as a gid 159 + * @mcg: new mcg object 160 + * 161 + * Context: caller should hold rxe->mcg lock 162 + * Returns: 0 on success else an error 163 + */ 164 + static int __rxe_init_mcg(struct rxe_dev *rxe, union ib_gid *mgid, 165 + struct rxe_mcg *mcg) 166 + { 167 + int err; 168 + 169 + err = rxe_mcast_add(rxe, mgid); 170 + if (unlikely(err)) 171 + return err; 172 + 173 + kref_init(&mcg->ref_cnt); 174 + memcpy(&mcg->mgid, mgid, sizeof(mcg->mgid)); 175 + INIT_LIST_HEAD(&mcg->qp_list); 176 + mcg->rxe = rxe; 177 + 178 + /* caller holds a ref on mcg but that will be 179 + * dropped when mcg goes out of scope. We need to take a ref 180 + * on the pointer that will be saved in the red-black tree 181 + * by __rxe_insert_mcg and used to lookup mcg from mgid later. 182 + * Inserting mcg makes it visible to outside so this should 183 + * be done last after the object is ready. 184 + */ 185 + kref_get(&mcg->ref_cnt); 186 + __rxe_insert_mcg(mcg); 187 + 63 188 return 0; 64 189 } 65 190 66 - int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, 67 - struct rxe_mc_grp *grp) 191 + /** 192 + * rxe_get_mcg - lookup or allocate a mcg 193 + * @rxe: rxe device object 194 + * @mgid: multicast IP address as a gid 195 + * 196 + * Returns: mcg on success else ERR_PTR(error) 197 + */ 198 + static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid) 68 199 { 200 + struct rxe_mcg *mcg, *tmp; 201 + unsigned long flags; 69 202 int err; 70 - struct rxe_mc_elem *elem; 71 203 72 - /* check to see of the qp is already a member of the group */ 73 - spin_lock_bh(&qp->grp_lock); 74 - spin_lock_bh(&grp->mcg_lock); 75 - list_for_each_entry(elem, &grp->qp_list, qp_list) { 76 - if (elem->qp == qp) { 204 + if (rxe->attr.max_mcast_grp == 0) 205 + return ERR_PTR(-EINVAL); 206 + 207 + /* check to see if mcg already exists */ 208 + mcg = rxe_lookup_mcg(rxe, mgid); 209 + if (mcg) 210 + return mcg; 211 + 212 + /* speculative alloc of new mcg */ 213 + mcg = kzalloc(sizeof(*mcg), GFP_KERNEL); 214 + if (!mcg) 215 + return ERR_PTR(-ENOMEM); 216 + 217 + spin_lock_irqsave(&rxe->mcg_lock, flags); 218 + /* re-check to see if someone else just added it */ 219 + tmp = __rxe_lookup_mcg(rxe, mgid); 220 + if (tmp) { 221 + kfree(mcg); 222 + mcg = tmp; 223 + goto out; 224 + } 225 + 226 + if (atomic_inc_return(&rxe->mcg_num) > rxe->attr.max_mcast_grp) { 227 + err = -ENOMEM; 228 + goto err_dec; 229 + } 230 + 231 + err = __rxe_init_mcg(rxe, mgid, mcg); 232 + if (err) 233 + goto err_dec; 234 + out: 235 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 236 + return mcg; 237 + 238 + err_dec: 239 + atomic_dec(&rxe->mcg_num); 240 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 241 + kfree(mcg); 242 + return ERR_PTR(err); 243 + } 244 + 245 + /** 246 + * rxe_cleanup_mcg - cleanup mcg for kref_put 247 + * @kref: struct kref embnedded in mcg 248 + */ 249 + void rxe_cleanup_mcg(struct kref *kref) 250 + { 251 + struct rxe_mcg *mcg = container_of(kref, typeof(*mcg), ref_cnt); 252 + 253 + kfree(mcg); 254 + } 255 + 256 + /** 257 + * __rxe_destroy_mcg - destroy mcg object holding rxe->mcg_lock 258 + * @mcg: the mcg object 259 + * 260 + * Context: caller is holding rxe->mcg_lock 261 + * no qp's are attached to mcg 262 + */ 263 + static void __rxe_destroy_mcg(struct rxe_mcg *mcg) 264 + { 265 + struct rxe_dev *rxe = mcg->rxe; 266 + 267 + /* remove mcg from red-black tree then drop ref */ 268 + __rxe_remove_mcg(mcg); 269 + kref_put(&mcg->ref_cnt, rxe_cleanup_mcg); 270 + 271 + rxe_mcast_delete(mcg->rxe, &mcg->mgid); 272 + atomic_dec(&rxe->mcg_num); 273 + } 274 + 275 + /** 276 + * rxe_destroy_mcg - destroy mcg object 277 + * @mcg: the mcg object 278 + * 279 + * Context: no qp's are attached to mcg 280 + */ 281 + static void rxe_destroy_mcg(struct rxe_mcg *mcg) 282 + { 283 + unsigned long flags; 284 + 285 + spin_lock_irqsave(&mcg->rxe->mcg_lock, flags); 286 + __rxe_destroy_mcg(mcg); 287 + spin_unlock_irqrestore(&mcg->rxe->mcg_lock, flags); 288 + } 289 + 290 + /** 291 + * __rxe_init_mca - initialize a new mca holding lock 292 + * @qp: qp object 293 + * @mcg: mcg object 294 + * @mca: empty space for new mca 295 + * 296 + * Context: caller must hold references on qp and mcg, rxe->mcg_lock 297 + * and pass memory for new mca 298 + * 299 + * Returns: 0 on success else an error 300 + */ 301 + static int __rxe_init_mca(struct rxe_qp *qp, struct rxe_mcg *mcg, 302 + struct rxe_mca *mca) 303 + { 304 + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); 305 + int n; 306 + 307 + n = atomic_inc_return(&rxe->mcg_attach); 308 + if (n > rxe->attr.max_total_mcast_qp_attach) { 309 + atomic_dec(&rxe->mcg_attach); 310 + return -ENOMEM; 311 + } 312 + 313 + n = atomic_inc_return(&mcg->qp_num); 314 + if (n > rxe->attr.max_mcast_qp_attach) { 315 + atomic_dec(&mcg->qp_num); 316 + atomic_dec(&rxe->mcg_attach); 317 + return -ENOMEM; 318 + } 319 + 320 + atomic_inc(&qp->mcg_num); 321 + 322 + rxe_get(qp); 323 + mca->qp = qp; 324 + 325 + list_add_tail(&mca->qp_list, &mcg->qp_list); 326 + 327 + return 0; 328 + } 329 + 330 + /** 331 + * rxe_attach_mcg - attach qp to mcg if not already attached 332 + * @qp: qp object 333 + * @mcg: mcg object 334 + * 335 + * Context: caller must hold reference on qp and mcg. 336 + * Returns: 0 on success else an error 337 + */ 338 + static int rxe_attach_mcg(struct rxe_mcg *mcg, struct rxe_qp *qp) 339 + { 340 + struct rxe_dev *rxe = mcg->rxe; 341 + struct rxe_mca *mca, *tmp; 342 + unsigned long flags; 343 + int err; 344 + 345 + /* check to see if the qp is already a member of the group */ 346 + spin_lock_irqsave(&rxe->mcg_lock, flags); 347 + list_for_each_entry(mca, &mcg->qp_list, qp_list) { 348 + if (mca->qp == qp) { 349 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 350 + return 0; 351 + } 352 + } 353 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 354 + 355 + /* speculative alloc new mca without using GFP_ATOMIC */ 356 + mca = kzalloc(sizeof(*mca), GFP_KERNEL); 357 + if (!mca) 358 + return -ENOMEM; 359 + 360 + spin_lock_irqsave(&rxe->mcg_lock, flags); 361 + /* re-check to see if someone else just attached qp */ 362 + list_for_each_entry(tmp, &mcg->qp_list, qp_list) { 363 + if (tmp->qp == qp) { 364 + kfree(mca); 77 365 err = 0; 78 366 goto out; 79 367 } 80 368 } 81 369 82 - if (grp->num_qp >= rxe->attr.max_mcast_qp_attach) { 83 - err = -ENOMEM; 84 - goto out; 85 - } 86 - 87 - elem = rxe_alloc_locked(&rxe->mc_elem_pool); 88 - if (!elem) { 89 - err = -ENOMEM; 90 - goto out; 91 - } 92 - 93 - /* each qp holds a ref on the grp */ 94 - rxe_add_ref(grp); 95 - 96 - grp->num_qp++; 97 - elem->qp = qp; 98 - elem->grp = grp; 99 - 100 - list_add(&elem->qp_list, &grp->qp_list); 101 - list_add(&elem->grp_list, &qp->grp_list); 102 - 103 - err = 0; 370 + err = __rxe_init_mca(qp, mcg, mca); 371 + if (err) 372 + kfree(mca); 104 373 out: 105 - spin_unlock_bh(&grp->mcg_lock); 106 - spin_unlock_bh(&qp->grp_lock); 374 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 107 375 return err; 108 376 } 109 377 110 - int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, 111 - union ib_gid *mgid) 378 + /** 379 + * __rxe_cleanup_mca - cleanup mca object holding lock 380 + * @mca: mca object 381 + * @mcg: mcg object 382 + * 383 + * Context: caller must hold a reference to mcg and rxe->mcg_lock 384 + */ 385 + static void __rxe_cleanup_mca(struct rxe_mca *mca, struct rxe_mcg *mcg) 112 386 { 113 - struct rxe_mc_grp *grp; 114 - struct rxe_mc_elem *elem, *tmp; 387 + list_del(&mca->qp_list); 115 388 116 - grp = rxe_pool_get_key(&rxe->mc_grp_pool, mgid); 117 - if (!grp) 118 - goto err1; 389 + atomic_dec(&mcg->qp_num); 390 + atomic_dec(&mcg->rxe->mcg_attach); 391 + atomic_dec(&mca->qp->mcg_num); 392 + rxe_put(mca->qp); 119 393 120 - spin_lock_bh(&qp->grp_lock); 121 - spin_lock_bh(&grp->mcg_lock); 394 + kfree(mca); 395 + } 122 396 123 - list_for_each_entry_safe(elem, tmp, &grp->qp_list, qp_list) { 124 - if (elem->qp == qp) { 125 - list_del(&elem->qp_list); 126 - list_del(&elem->grp_list); 127 - grp->num_qp--; 397 + /** 398 + * rxe_detach_mcg - detach qp from mcg 399 + * @mcg: mcg object 400 + * @qp: qp object 401 + * 402 + * Returns: 0 on success else an error if qp is not attached. 403 + */ 404 + static int rxe_detach_mcg(struct rxe_mcg *mcg, struct rxe_qp *qp) 405 + { 406 + struct rxe_dev *rxe = mcg->rxe; 407 + struct rxe_mca *mca, *tmp; 408 + unsigned long flags; 128 409 129 - spin_unlock_bh(&grp->mcg_lock); 130 - spin_unlock_bh(&qp->grp_lock); 131 - rxe_drop_ref(elem); 132 - rxe_drop_ref(grp); /* ref held by QP */ 133 - rxe_drop_ref(grp); /* ref from get_key */ 410 + spin_lock_irqsave(&rxe->mcg_lock, flags); 411 + list_for_each_entry_safe(mca, tmp, &mcg->qp_list, qp_list) { 412 + if (mca->qp == qp) { 413 + __rxe_cleanup_mca(mca, mcg); 414 + 415 + /* if the number of qp's attached to the 416 + * mcast group falls to zero go ahead and 417 + * tear it down. This will not free the 418 + * object since we are still holding a ref 419 + * from the caller 420 + */ 421 + if (atomic_read(&mcg->qp_num) <= 0) 422 + __rxe_destroy_mcg(mcg); 423 + 424 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 134 425 return 0; 135 426 } 136 427 } 137 428 138 - spin_unlock_bh(&grp->mcg_lock); 139 - spin_unlock_bh(&qp->grp_lock); 140 - rxe_drop_ref(grp); /* ref from get_key */ 141 - err1: 429 + /* we didn't find the qp on the list */ 430 + spin_unlock_irqrestore(&rxe->mcg_lock, flags); 142 431 return -EINVAL; 143 432 } 144 433 145 - void rxe_drop_all_mcast_groups(struct rxe_qp *qp) 434 + /** 435 + * rxe_attach_mcast - attach qp to multicast group (see IBA-11.3.1) 436 + * @ibqp: (IB) qp object 437 + * @mgid: multicast IP address 438 + * @mlid: multicast LID, ignored for RoCEv2 (see IBA-A17.5.6) 439 + * 440 + * Returns: 0 on success else an errno 441 + */ 442 + int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) 146 443 { 147 - struct rxe_mc_grp *grp; 148 - struct rxe_mc_elem *elem; 444 + int err; 445 + struct rxe_dev *rxe = to_rdev(ibqp->device); 446 + struct rxe_qp *qp = to_rqp(ibqp); 447 + struct rxe_mcg *mcg; 149 448 150 - while (1) { 151 - spin_lock_bh(&qp->grp_lock); 152 - if (list_empty(&qp->grp_list)) { 153 - spin_unlock_bh(&qp->grp_lock); 154 - break; 155 - } 156 - elem = list_first_entry(&qp->grp_list, struct rxe_mc_elem, 157 - grp_list); 158 - list_del(&elem->grp_list); 159 - spin_unlock_bh(&qp->grp_lock); 449 + /* takes a ref on mcg if successful */ 450 + mcg = rxe_get_mcg(rxe, mgid); 451 + if (IS_ERR(mcg)) 452 + return PTR_ERR(mcg); 160 453 161 - grp = elem->grp; 162 - spin_lock_bh(&grp->mcg_lock); 163 - list_del(&elem->qp_list); 164 - grp->num_qp--; 165 - spin_unlock_bh(&grp->mcg_lock); 166 - rxe_drop_ref(grp); 167 - rxe_drop_ref(elem); 168 - } 454 + err = rxe_attach_mcg(mcg, qp); 455 + 456 + /* if we failed to attach the first qp to mcg tear it down */ 457 + if (atomic_read(&mcg->qp_num) == 0) 458 + rxe_destroy_mcg(mcg); 459 + 460 + kref_put(&mcg->ref_cnt, rxe_cleanup_mcg); 461 + 462 + return err; 169 463 } 170 464 171 - void rxe_mc_cleanup(struct rxe_pool_elem *elem) 465 + /** 466 + * rxe_detach_mcast - detach qp from multicast group (see IBA-11.3.2) 467 + * @ibqp: address of (IB) qp object 468 + * @mgid: multicast IP address 469 + * @mlid: multicast LID, ignored for RoCEv2 (see IBA-A17.5.6) 470 + * 471 + * Returns: 0 on success else an errno 472 + */ 473 + int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) 172 474 { 173 - struct rxe_mc_grp *grp = container_of(elem, typeof(*grp), elem); 174 - struct rxe_dev *rxe = grp->rxe; 475 + struct rxe_dev *rxe = to_rdev(ibqp->device); 476 + struct rxe_qp *qp = to_rqp(ibqp); 477 + struct rxe_mcg *mcg; 478 + int err; 175 479 176 - rxe_drop_key(grp); 177 - rxe_mcast_delete(rxe, &grp->mgid); 480 + mcg = rxe_lookup_mcg(rxe, mgid); 481 + if (!mcg) 482 + return -EINVAL; 483 + 484 + err = rxe_detach_mcg(mcg, qp); 485 + kref_put(&mcg->ref_cnt, rxe_cleanup_mcg); 486 + 487 + return err; 178 488 }
-1
drivers/infiniband/sw/rxe/rxe_mmap.c
··· 4 4 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. 5 5 */ 6 6 7 - #include <linux/module.h> 8 7 #include <linux/vmalloc.h> 9 8 #include <linux/mm.h> 10 9 #include <linux/errno.h>
+7 -8
drivers/infiniband/sw/rxe/rxe_mr.c
··· 459 459 460 460 if (offset >= sge->length) { 461 461 if (mr) { 462 - rxe_drop_ref(mr); 462 + rxe_put(mr); 463 463 mr = NULL; 464 464 } 465 465 sge++; ··· 504 504 dma->resid = resid; 505 505 506 506 if (mr) 507 - rxe_drop_ref(mr); 507 + rxe_put(mr); 508 508 509 509 return 0; 510 510 511 511 err2: 512 512 if (mr) 513 - rxe_drop_ref(mr); 513 + rxe_put(mr); 514 514 err1: 515 515 return err; 516 516 } ··· 569 569 (type == RXE_LOOKUP_REMOTE && mr->rkey != key) || 570 570 mr_pd(mr) != pd || (access && !(access & mr->access)) || 571 571 mr->state != RXE_MR_STATE_VALID)) { 572 - rxe_drop_ref(mr); 572 + rxe_put(mr); 573 573 mr = NULL; 574 574 } 575 575 ··· 613 613 ret = 0; 614 614 615 615 err_drop_ref: 616 - rxe_drop_ref(mr); 616 + rxe_put(mr); 617 617 err: 618 618 return ret; 619 619 } ··· 690 690 } 691 691 692 692 mr->state = RXE_MR_STATE_INVALID; 693 - rxe_drop_ref(mr_pd(mr)); 694 - rxe_drop_index(mr); 695 - rxe_drop_ref(mr); 693 + rxe_put(mr_pd(mr)); 694 + rxe_put(mr); 696 695 697 696 return 0; 698 697 }
+15 -23
drivers/infiniband/sw/rxe/rxe_mw.c
··· 12 12 struct rxe_dev *rxe = to_rdev(ibmw->device); 13 13 int ret; 14 14 15 - rxe_add_ref(pd); 15 + rxe_get(pd); 16 16 17 17 ret = rxe_add_to_pool(&rxe->mw_pool, mw); 18 18 if (ret) { 19 - rxe_drop_ref(pd); 19 + rxe_put(pd); 20 20 return ret; 21 21 } 22 22 23 - rxe_add_index(mw); 24 23 mw->rkey = ibmw->rkey = (mw->elem.index << 8) | rxe_get_next_key(-1); 25 24 mw->state = (mw->ibmw.type == IB_MW_TYPE_2) ? 26 25 RXE_MW_STATE_FREE : RXE_MW_STATE_VALID; ··· 35 36 36 37 mw->mr = NULL; 37 38 atomic_dec(&mr->num_mw); 38 - rxe_drop_ref(mr); 39 + rxe_put(mr); 39 40 } 40 41 41 42 if (mw->qp) { 42 43 struct rxe_qp *qp = mw->qp; 43 44 44 45 mw->qp = NULL; 45 - rxe_drop_ref(qp); 46 + rxe_put(qp); 46 47 } 47 48 48 49 mw->access = 0; ··· 60 61 rxe_do_dealloc_mw(mw); 61 62 spin_unlock_bh(&mw->lock); 62 63 63 - rxe_drop_ref(mw); 64 - rxe_drop_ref(pd); 64 + rxe_put(mw); 65 + rxe_put(pd); 65 66 66 67 return 0; 67 68 } ··· 170 171 mw->length = wqe->wr.wr.mw.length; 171 172 172 173 if (mw->mr) { 173 - rxe_drop_ref(mw->mr); 174 + rxe_put(mw->mr); 174 175 atomic_dec(&mw->mr->num_mw); 175 176 mw->mr = NULL; 176 177 } ··· 178 179 if (mw->length) { 179 180 mw->mr = mr; 180 181 atomic_inc(&mr->num_mw); 181 - rxe_add_ref(mr); 182 + rxe_get(mr); 182 183 } 183 184 184 185 if (mw->ibmw.type == IB_MW_TYPE_2) { 185 - rxe_add_ref(qp); 186 + rxe_get(qp); 186 187 mw->qp = qp; 187 188 } 188 189 } ··· 233 234 spin_unlock_bh(&mw->lock); 234 235 err_drop_mr: 235 236 if (mr) 236 - rxe_drop_ref(mr); 237 + rxe_put(mr); 237 238 err_drop_mw: 238 - rxe_drop_ref(mw); 239 + rxe_put(mw); 239 240 err: 240 241 return ret; 241 242 } ··· 260 261 /* valid type 2 MW will always have a QP pointer */ 261 262 qp = mw->qp; 262 263 mw->qp = NULL; 263 - rxe_drop_ref(qp); 264 + rxe_put(qp); 264 265 265 266 /* valid type 2 MW will always have an MR pointer */ 266 267 mr = mw->mr; 267 268 mw->mr = NULL; 268 269 atomic_dec(&mr->num_mw); 269 - rxe_drop_ref(mr); 270 + rxe_put(mr); 270 271 271 272 mw->access = 0; 272 273 mw->addr = 0; ··· 301 302 err_unlock: 302 303 spin_unlock_bh(&mw->lock); 303 304 err_drop_ref: 304 - rxe_drop_ref(mw); 305 + rxe_put(mw); 305 306 err: 306 307 return ret; 307 308 } ··· 322 323 (mw->length == 0) || 323 324 (access && !(access & mw->access)) || 324 325 mw->state != RXE_MW_STATE_VALID)) { 325 - rxe_drop_ref(mw); 326 + rxe_put(mw); 326 327 return NULL; 327 328 } 328 329 329 330 return mw; 330 - } 331 - 332 - void rxe_mw_cleanup(struct rxe_pool_elem *elem) 333 - { 334 - struct rxe_mw *mw = container_of(elem, typeof(*mw), elem); 335 - 336 - rxe_drop_index(mw); 337 331 }
+12 -29
drivers/infiniband/sw/rxe/rxe_net.c
··· 20 20 21 21 static struct rxe_recv_sockets recv_sockets; 22 22 23 - int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid) 24 - { 25 - unsigned char ll_addr[ETH_ALEN]; 26 - 27 - ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr); 28 - 29 - return dev_mc_add(rxe->ndev, ll_addr); 30 - } 31 - 32 - int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid) 33 - { 34 - unsigned char ll_addr[ETH_ALEN]; 35 - 36 - ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr); 37 - 38 - return dev_mc_del(rxe->ndev, ll_addr); 39 - } 40 - 41 23 static struct dst_entry *rxe_find_route4(struct net_device *ndev, 42 24 struct in_addr *saddr, 43 25 struct in_addr *daddr) ··· 271 289 ip6h->payload_len = htons(skb->len - sizeof(*ip6h)); 272 290 } 273 291 274 - static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb) 292 + static int prepare4(struct rxe_av *av, struct rxe_pkt_info *pkt, 293 + struct sk_buff *skb) 275 294 { 276 295 struct rxe_qp *qp = pkt->qp; 277 296 struct dst_entry *dst; 278 297 bool xnet = false; 279 298 __be16 df = htons(IP_DF); 280 - struct rxe_av *av = rxe_get_av(pkt); 281 299 struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr; 282 300 struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr; 283 301 ··· 297 315 return 0; 298 316 } 299 317 300 - static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb) 318 + static int prepare6(struct rxe_av *av, struct rxe_pkt_info *pkt, 319 + struct sk_buff *skb) 301 320 { 302 321 struct rxe_qp *qp = pkt->qp; 303 322 struct dst_entry *dst; 304 - struct rxe_av *av = rxe_get_av(pkt); 305 323 struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr; 306 324 struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr; 307 325 ··· 322 340 return 0; 323 341 } 324 342 325 - int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb) 343 + int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, 344 + struct sk_buff *skb) 326 345 { 327 346 int err = 0; 328 347 329 348 if (skb->protocol == htons(ETH_P_IP)) 330 - err = prepare4(pkt, skb); 349 + err = prepare4(av, pkt, skb); 331 350 else if (skb->protocol == htons(ETH_P_IPV6)) 332 - err = prepare6(pkt, skb); 351 + err = prepare6(av, pkt, skb); 333 352 334 - if (ether_addr_equal(skb->dev->dev_addr, rxe_get_av(pkt)->dmac)) 353 + if (ether_addr_equal(skb->dev->dev_addr, av->dmac)) 335 354 pkt->mask |= RXE_LOOPBACK_MASK; 336 355 337 356 return err; ··· 348 365 skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) 349 366 rxe_run_task(&qp->req.task, 1); 350 367 351 - rxe_drop_ref(qp); 368 + rxe_put(qp); 352 369 } 353 370 354 371 static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) ··· 358 375 skb->destructor = rxe_skb_tx_dtor; 359 376 skb->sk = pkt->qp->sk->sk; 360 377 361 - rxe_add_ref(pkt->qp); 378 + rxe_get(pkt->qp); 362 379 atomic_inc(&pkt->qp->skb_out); 363 380 364 381 if (skb->protocol == htons(ETH_P_IP)) { ··· 368 385 } else { 369 386 pr_err("Unknown layer 3 protocol: %d\n", skb->protocol); 370 387 atomic_dec(&pkt->qp->skb_out); 371 - rxe_drop_ref(pkt->qp); 388 + rxe_put(pkt->qp); 372 389 kfree_skb(skb); 373 390 return -EINVAL; 374 391 }
+86 -357
drivers/infiniband/sw/rxe/rxe_pool.c
··· 12 12 const char *name; 13 13 size_t size; 14 14 size_t elem_offset; 15 - void (*cleanup)(struct rxe_pool_elem *obj); 15 + void (*cleanup)(struct rxe_pool_elem *elem); 16 16 enum rxe_pool_flags flags; 17 17 u32 min_index; 18 18 u32 max_index; 19 - size_t key_offset; 20 - size_t key_size; 19 + u32 max_elem; 21 20 } rxe_type_info[RXE_NUM_TYPES] = { 22 21 [RXE_TYPE_UC] = { 23 - .name = "rxe-uc", 22 + .name = "uc", 24 23 .size = sizeof(struct rxe_ucontext), 25 24 .elem_offset = offsetof(struct rxe_ucontext, elem), 26 - .flags = RXE_POOL_NO_ALLOC, 25 + .min_index = 1, 26 + .max_index = UINT_MAX, 27 + .max_elem = UINT_MAX, 27 28 }, 28 29 [RXE_TYPE_PD] = { 29 - .name = "rxe-pd", 30 + .name = "pd", 30 31 .size = sizeof(struct rxe_pd), 31 32 .elem_offset = offsetof(struct rxe_pd, elem), 32 - .flags = RXE_POOL_NO_ALLOC, 33 + .min_index = 1, 34 + .max_index = UINT_MAX, 35 + .max_elem = UINT_MAX, 33 36 }, 34 37 [RXE_TYPE_AH] = { 35 - .name = "rxe-ah", 38 + .name = "ah", 36 39 .size = sizeof(struct rxe_ah), 37 40 .elem_offset = offsetof(struct rxe_ah, elem), 38 - .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, 39 41 .min_index = RXE_MIN_AH_INDEX, 40 42 .max_index = RXE_MAX_AH_INDEX, 43 + .max_elem = RXE_MAX_AH_INDEX - RXE_MIN_AH_INDEX + 1, 41 44 }, 42 45 [RXE_TYPE_SRQ] = { 43 - .name = "rxe-srq", 46 + .name = "srq", 44 47 .size = sizeof(struct rxe_srq), 45 48 .elem_offset = offsetof(struct rxe_srq, elem), 46 - .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, 47 49 .min_index = RXE_MIN_SRQ_INDEX, 48 50 .max_index = RXE_MAX_SRQ_INDEX, 51 + .max_elem = RXE_MAX_SRQ_INDEX - RXE_MIN_SRQ_INDEX + 1, 49 52 }, 50 53 [RXE_TYPE_QP] = { 51 - .name = "rxe-qp", 54 + .name = "qp", 52 55 .size = sizeof(struct rxe_qp), 53 56 .elem_offset = offsetof(struct rxe_qp, elem), 54 57 .cleanup = rxe_qp_cleanup, 55 - .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, 56 58 .min_index = RXE_MIN_QP_INDEX, 57 59 .max_index = RXE_MAX_QP_INDEX, 60 + .max_elem = RXE_MAX_QP_INDEX - RXE_MIN_QP_INDEX + 1, 58 61 }, 59 62 [RXE_TYPE_CQ] = { 60 - .name = "rxe-cq", 63 + .name = "cq", 61 64 .size = sizeof(struct rxe_cq), 62 65 .elem_offset = offsetof(struct rxe_cq, elem), 63 - .flags = RXE_POOL_NO_ALLOC, 64 66 .cleanup = rxe_cq_cleanup, 67 + .min_index = 1, 68 + .max_index = UINT_MAX, 69 + .max_elem = UINT_MAX, 65 70 }, 66 71 [RXE_TYPE_MR] = { 67 - .name = "rxe-mr", 72 + .name = "mr", 68 73 .size = sizeof(struct rxe_mr), 69 74 .elem_offset = offsetof(struct rxe_mr, elem), 70 75 .cleanup = rxe_mr_cleanup, 71 - .flags = RXE_POOL_INDEX, 76 + .flags = RXE_POOL_ALLOC, 72 77 .min_index = RXE_MIN_MR_INDEX, 73 78 .max_index = RXE_MAX_MR_INDEX, 79 + .max_elem = RXE_MAX_MR_INDEX - RXE_MIN_MR_INDEX + 1, 74 80 }, 75 81 [RXE_TYPE_MW] = { 76 - .name = "rxe-mw", 82 + .name = "mw", 77 83 .size = sizeof(struct rxe_mw), 78 84 .elem_offset = offsetof(struct rxe_mw, elem), 79 - .cleanup = rxe_mw_cleanup, 80 - .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, 81 85 .min_index = RXE_MIN_MW_INDEX, 82 86 .max_index = RXE_MAX_MW_INDEX, 83 - }, 84 - [RXE_TYPE_MC_GRP] = { 85 - .name = "rxe-mc_grp", 86 - .size = sizeof(struct rxe_mc_grp), 87 - .elem_offset = offsetof(struct rxe_mc_grp, elem), 88 - .cleanup = rxe_mc_cleanup, 89 - .flags = RXE_POOL_KEY, 90 - .key_offset = offsetof(struct rxe_mc_grp, mgid), 91 - .key_size = sizeof(union ib_gid), 92 - }, 93 - [RXE_TYPE_MC_ELEM] = { 94 - .name = "rxe-mc_elem", 95 - .size = sizeof(struct rxe_mc_elem), 96 - .elem_offset = offsetof(struct rxe_mc_elem, elem), 87 + .max_elem = RXE_MAX_MW_INDEX - RXE_MIN_MW_INDEX + 1, 97 88 }, 98 89 }; 99 90 100 - static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min) 101 - { 102 - int err = 0; 103 - 104 - if ((max - min + 1) < pool->max_elem) { 105 - pr_warn("not enough indices for max_elem\n"); 106 - err = -EINVAL; 107 - goto out; 108 - } 109 - 110 - pool->index.max_index = max; 111 - pool->index.min_index = min; 112 - 113 - pool->index.table = bitmap_zalloc(max - min + 1, GFP_KERNEL); 114 - if (!pool->index.table) { 115 - err = -ENOMEM; 116 - goto out; 117 - } 118 - 119 - out: 120 - return err; 121 - } 122 - 123 - int rxe_pool_init( 124 - struct rxe_dev *rxe, 125 - struct rxe_pool *pool, 126 - enum rxe_elem_type type, 127 - unsigned int max_elem) 91 + void rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, 92 + enum rxe_elem_type type) 128 93 { 129 94 const struct rxe_type_info *info = &rxe_type_info[type]; 130 - int err = 0; 131 95 132 96 memset(pool, 0, sizeof(*pool)); 133 97 134 98 pool->rxe = rxe; 135 99 pool->name = info->name; 136 100 pool->type = type; 137 - pool->max_elem = max_elem; 101 + pool->max_elem = info->max_elem; 138 102 pool->elem_size = ALIGN(info->size, RXE_POOL_ALIGN); 139 103 pool->elem_offset = info->elem_offset; 140 104 pool->flags = info->flags; ··· 106 142 107 143 atomic_set(&pool->num_elem, 0); 108 144 109 - rwlock_init(&pool->pool_lock); 110 - 111 - if (pool->flags & RXE_POOL_INDEX) { 112 - pool->index.tree = RB_ROOT; 113 - err = rxe_pool_init_index(pool, info->max_index, 114 - info->min_index); 115 - if (err) 116 - goto out; 117 - } 118 - 119 - if (pool->flags & RXE_POOL_KEY) { 120 - pool->key.tree = RB_ROOT; 121 - pool->key.key_offset = info->key_offset; 122 - pool->key.key_size = info->key_size; 123 - } 124 - 125 - out: 126 - return err; 145 + xa_init_flags(&pool->xa, XA_FLAGS_ALLOC); 146 + pool->limit.min = info->min_index; 147 + pool->limit.max = info->max_index; 127 148 } 128 149 129 150 void rxe_pool_cleanup(struct rxe_pool *pool) 130 151 { 131 - if (atomic_read(&pool->num_elem) > 0) 132 - pr_warn("%s pool destroyed with unfree'd elem\n", 133 - pool->name); 134 - 135 - if (pool->flags & RXE_POOL_INDEX) 136 - bitmap_free(pool->index.table); 137 - } 138 - 139 - static u32 alloc_index(struct rxe_pool *pool) 140 - { 141 - u32 index; 142 - u32 range = pool->index.max_index - pool->index.min_index + 1; 143 - 144 - index = find_next_zero_bit(pool->index.table, range, pool->index.last); 145 - if (index >= range) 146 - index = find_first_zero_bit(pool->index.table, range); 147 - 148 - WARN_ON_ONCE(index >= range); 149 - set_bit(index, pool->index.table); 150 - pool->index.last = index; 151 - return index + pool->index.min_index; 152 - } 153 - 154 - static int rxe_insert_index(struct rxe_pool *pool, struct rxe_pool_elem *new) 155 - { 156 - struct rb_node **link = &pool->index.tree.rb_node; 157 - struct rb_node *parent = NULL; 158 - struct rxe_pool_elem *elem; 159 - 160 - while (*link) { 161 - parent = *link; 162 - elem = rb_entry(parent, struct rxe_pool_elem, index_node); 163 - 164 - if (elem->index == new->index) { 165 - pr_warn("element already exists!\n"); 166 - return -EINVAL; 167 - } 168 - 169 - if (elem->index > new->index) 170 - link = &(*link)->rb_left; 171 - else 172 - link = &(*link)->rb_right; 173 - } 174 - 175 - rb_link_node(&new->index_node, parent, link); 176 - rb_insert_color(&new->index_node, &pool->index.tree); 177 - 178 - return 0; 179 - } 180 - 181 - static int rxe_insert_key(struct rxe_pool *pool, struct rxe_pool_elem *new) 182 - { 183 - struct rb_node **link = &pool->key.tree.rb_node; 184 - struct rb_node *parent = NULL; 185 - struct rxe_pool_elem *elem; 186 - int cmp; 187 - 188 - while (*link) { 189 - parent = *link; 190 - elem = rb_entry(parent, struct rxe_pool_elem, key_node); 191 - 192 - cmp = memcmp((u8 *)elem + pool->key.key_offset, 193 - (u8 *)new + pool->key.key_offset, 194 - pool->key.key_size); 195 - 196 - if (cmp == 0) { 197 - pr_warn("key already exists!\n"); 198 - return -EINVAL; 199 - } 200 - 201 - if (cmp > 0) 202 - link = &(*link)->rb_left; 203 - else 204 - link = &(*link)->rb_right; 205 - } 206 - 207 - rb_link_node(&new->key_node, parent, link); 208 - rb_insert_color(&new->key_node, &pool->key.tree); 209 - 210 - return 0; 211 - } 212 - 213 - int __rxe_add_key_locked(struct rxe_pool_elem *elem, void *key) 214 - { 215 - struct rxe_pool *pool = elem->pool; 216 - int err; 217 - 218 - memcpy((u8 *)elem + pool->key.key_offset, key, pool->key.key_size); 219 - err = rxe_insert_key(pool, elem); 220 - 221 - return err; 222 - } 223 - 224 - int __rxe_add_key(struct rxe_pool_elem *elem, void *key) 225 - { 226 - struct rxe_pool *pool = elem->pool; 227 - int err; 228 - 229 - write_lock_bh(&pool->pool_lock); 230 - err = __rxe_add_key_locked(elem, key); 231 - write_unlock_bh(&pool->pool_lock); 232 - 233 - return err; 234 - } 235 - 236 - void __rxe_drop_key_locked(struct rxe_pool_elem *elem) 237 - { 238 - struct rxe_pool *pool = elem->pool; 239 - 240 - rb_erase(&elem->key_node, &pool->key.tree); 241 - } 242 - 243 - void __rxe_drop_key(struct rxe_pool_elem *elem) 244 - { 245 - struct rxe_pool *pool = elem->pool; 246 - 247 - write_lock_bh(&pool->pool_lock); 248 - __rxe_drop_key_locked(elem); 249 - write_unlock_bh(&pool->pool_lock); 250 - } 251 - 252 - int __rxe_add_index_locked(struct rxe_pool_elem *elem) 253 - { 254 - struct rxe_pool *pool = elem->pool; 255 - int err; 256 - 257 - elem->index = alloc_index(pool); 258 - err = rxe_insert_index(pool, elem); 259 - 260 - return err; 261 - } 262 - 263 - int __rxe_add_index(struct rxe_pool_elem *elem) 264 - { 265 - struct rxe_pool *pool = elem->pool; 266 - int err; 267 - 268 - write_lock_bh(&pool->pool_lock); 269 - err = __rxe_add_index_locked(elem); 270 - write_unlock_bh(&pool->pool_lock); 271 - 272 - return err; 273 - } 274 - 275 - void __rxe_drop_index_locked(struct rxe_pool_elem *elem) 276 - { 277 - struct rxe_pool *pool = elem->pool; 278 - 279 - clear_bit(elem->index - pool->index.min_index, pool->index.table); 280 - rb_erase(&elem->index_node, &pool->index.tree); 281 - } 282 - 283 - void __rxe_drop_index(struct rxe_pool_elem *elem) 284 - { 285 - struct rxe_pool *pool = elem->pool; 286 - 287 - write_lock_bh(&pool->pool_lock); 288 - __rxe_drop_index_locked(elem); 289 - write_unlock_bh(&pool->pool_lock); 290 - } 291 - 292 - void *rxe_alloc_locked(struct rxe_pool *pool) 293 - { 294 - struct rxe_pool_elem *elem; 295 - void *obj; 296 - 297 - if (atomic_inc_return(&pool->num_elem) > pool->max_elem) 298 - goto out_cnt; 299 - 300 - obj = kzalloc(pool->elem_size, GFP_ATOMIC); 301 - if (!obj) 302 - goto out_cnt; 303 - 304 - elem = (struct rxe_pool_elem *)((u8 *)obj + pool->elem_offset); 305 - 306 - elem->pool = pool; 307 - elem->obj = obj; 308 - kref_init(&elem->ref_cnt); 309 - 310 - return obj; 311 - 312 - out_cnt: 313 - atomic_dec(&pool->num_elem); 314 - return NULL; 152 + WARN_ON(!xa_empty(&pool->xa)); 315 153 } 316 154 317 155 void *rxe_alloc(struct rxe_pool *pool) 318 156 { 319 157 struct rxe_pool_elem *elem; 320 158 void *obj; 159 + int err; 160 + 161 + if (WARN_ON(!(pool->flags & RXE_POOL_ALLOC))) 162 + return NULL; 321 163 322 164 if (atomic_inc_return(&pool->num_elem) > pool->max_elem) 323 - goto out_cnt; 165 + goto err_cnt; 324 166 325 167 obj = kzalloc(pool->elem_size, GFP_KERNEL); 326 168 if (!obj) 327 - goto out_cnt; 169 + goto err_cnt; 328 170 329 171 elem = (struct rxe_pool_elem *)((u8 *)obj + pool->elem_offset); 330 172 ··· 138 368 elem->obj = obj; 139 369 kref_init(&elem->ref_cnt); 140 370 371 + err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit, 372 + &pool->next, GFP_KERNEL); 373 + if (err) 374 + goto err_free; 375 + 141 376 return obj; 142 377 143 - out_cnt: 378 + err_free: 379 + kfree(obj); 380 + err_cnt: 144 381 atomic_dec(&pool->num_elem); 145 382 return NULL; 146 383 } 147 384 148 385 int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem) 149 386 { 387 + int err; 388 + 389 + if (WARN_ON(pool->flags & RXE_POOL_ALLOC)) 390 + return -EINVAL; 391 + 150 392 if (atomic_inc_return(&pool->num_elem) > pool->max_elem) 151 - goto out_cnt; 393 + goto err_cnt; 152 394 153 395 elem->pool = pool; 154 396 elem->obj = (u8 *)elem - pool->elem_offset; 155 397 kref_init(&elem->ref_cnt); 156 398 399 + err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit, 400 + &pool->next, GFP_KERNEL); 401 + if (err) 402 + goto err_cnt; 403 + 157 404 return 0; 158 405 159 - out_cnt: 406 + err_cnt: 160 407 atomic_dec(&pool->num_elem); 161 408 return -EINVAL; 162 409 } 163 410 164 - void rxe_elem_release(struct kref *kref) 411 + void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) 165 412 { 166 - struct rxe_pool_elem *elem = 167 - container_of(kref, struct rxe_pool_elem, ref_cnt); 168 - struct rxe_pool *pool = elem->pool; 413 + struct rxe_pool_elem *elem; 414 + struct xarray *xa = &pool->xa; 415 + unsigned long flags; 169 416 void *obj; 417 + 418 + xa_lock_irqsave(xa, flags); 419 + elem = xa_load(xa, index); 420 + if (elem && kref_get_unless_zero(&elem->ref_cnt)) 421 + obj = elem->obj; 422 + else 423 + obj = NULL; 424 + xa_unlock_irqrestore(xa, flags); 425 + 426 + return obj; 427 + } 428 + 429 + static void rxe_elem_release(struct kref *kref) 430 + { 431 + struct rxe_pool_elem *elem = container_of(kref, typeof(*elem), ref_cnt); 432 + struct rxe_pool *pool = elem->pool; 433 + 434 + xa_erase(&pool->xa, elem->index); 170 435 171 436 if (pool->cleanup) 172 437 pool->cleanup(elem); 173 438 174 - if (!(pool->flags & RXE_POOL_NO_ALLOC)) { 175 - obj = elem->obj; 176 - kfree(obj); 177 - } 439 + if (pool->flags & RXE_POOL_ALLOC) 440 + kfree(elem->obj); 178 441 179 442 atomic_dec(&pool->num_elem); 180 443 } 181 444 182 - void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index) 445 + int __rxe_get(struct rxe_pool_elem *elem) 183 446 { 184 - struct rb_node *node; 185 - struct rxe_pool_elem *elem; 186 - void *obj; 187 - 188 - node = pool->index.tree.rb_node; 189 - 190 - while (node) { 191 - elem = rb_entry(node, struct rxe_pool_elem, index_node); 192 - 193 - if (elem->index > index) 194 - node = node->rb_left; 195 - else if (elem->index < index) 196 - node = node->rb_right; 197 - else 198 - break; 199 - } 200 - 201 - if (node) { 202 - kref_get(&elem->ref_cnt); 203 - obj = elem->obj; 204 - } else { 205 - obj = NULL; 206 - } 207 - 208 - return obj; 447 + return kref_get_unless_zero(&elem->ref_cnt); 209 448 } 210 449 211 - void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) 450 + int __rxe_put(struct rxe_pool_elem *elem) 212 451 { 213 - void *obj; 214 - 215 - read_lock_bh(&pool->pool_lock); 216 - obj = rxe_pool_get_index_locked(pool, index); 217 - read_unlock_bh(&pool->pool_lock); 218 - 219 - return obj; 220 - } 221 - 222 - void *rxe_pool_get_key_locked(struct rxe_pool *pool, void *key) 223 - { 224 - struct rb_node *node; 225 - struct rxe_pool_elem *elem; 226 - void *obj; 227 - int cmp; 228 - 229 - node = pool->key.tree.rb_node; 230 - 231 - while (node) { 232 - elem = rb_entry(node, struct rxe_pool_elem, key_node); 233 - 234 - cmp = memcmp((u8 *)elem + pool->key.key_offset, 235 - key, pool->key.key_size); 236 - 237 - if (cmp > 0) 238 - node = node->rb_left; 239 - else if (cmp < 0) 240 - node = node->rb_right; 241 - else 242 - break; 243 - } 244 - 245 - if (node) { 246 - kref_get(&elem->ref_cnt); 247 - obj = elem->obj; 248 - } else { 249 - obj = NULL; 250 - } 251 - 252 - return obj; 253 - } 254 - 255 - void *rxe_pool_get_key(struct rxe_pool *pool, void *key) 256 - { 257 - void *obj; 258 - 259 - read_lock_bh(&pool->pool_lock); 260 - obj = rxe_pool_get_key_locked(pool, key); 261 - read_unlock_bh(&pool->pool_lock); 262 - 263 - return obj; 452 + return kref_put(&elem->ref_cnt, rxe_elem_release); 264 453 }
+14 -91
drivers/infiniband/sw/rxe/rxe_pool.h
··· 8 8 #define RXE_POOL_H 9 9 10 10 enum rxe_pool_flags { 11 - RXE_POOL_INDEX = BIT(1), 12 - RXE_POOL_KEY = BIT(2), 13 - RXE_POOL_NO_ALLOC = BIT(4), 11 + RXE_POOL_ALLOC = BIT(1), 14 12 }; 15 13 16 14 enum rxe_elem_type { ··· 20 22 RXE_TYPE_CQ, 21 23 RXE_TYPE_MR, 22 24 RXE_TYPE_MW, 23 - RXE_TYPE_MC_GRP, 24 - RXE_TYPE_MC_ELEM, 25 25 RXE_NUM_TYPES, /* keep me last */ 26 26 }; 27 27 ··· 28 32 void *obj; 29 33 struct kref ref_cnt; 30 34 struct list_head list; 31 - 32 - /* only used if keyed */ 33 - struct rb_node key_node; 34 - 35 - /* only used if indexed */ 36 - struct rb_node index_node; 37 35 u32 index; 38 36 }; 39 37 40 38 struct rxe_pool { 41 39 struct rxe_dev *rxe; 42 40 const char *name; 43 - rwlock_t pool_lock; /* protects pool add/del/search */ 44 - void (*cleanup)(struct rxe_pool_elem *obj); 41 + void (*cleanup)(struct rxe_pool_elem *elem); 45 42 enum rxe_pool_flags flags; 46 43 enum rxe_elem_type type; 47 44 ··· 43 54 size_t elem_size; 44 55 size_t elem_offset; 45 56 46 - /* only used if indexed */ 47 - struct { 48 - struct rb_root tree; 49 - unsigned long *table; 50 - u32 last; 51 - u32 max_index; 52 - u32 min_index; 53 - } index; 54 - 55 - /* only used if keyed */ 56 - struct { 57 - struct rb_root tree; 58 - size_t key_offset; 59 - size_t key_size; 60 - } key; 57 + struct xarray xa; 58 + struct xa_limit limit; 59 + u32 next; 61 60 }; 62 61 63 62 /* initialize a pool of objects with given limit on 64 63 * number of elements. gets parameters from rxe_type_info 65 64 * pool elements will be allocated out of a slab cache 66 65 */ 67 - int rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, 68 - enum rxe_elem_type type, u32 max_elem); 66 + void rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, 67 + enum rxe_elem_type type); 69 68 70 69 /* free resources from object pool */ 71 70 void rxe_pool_cleanup(struct rxe_pool *pool); 72 71 73 - /* allocate an object from pool holding and not holding the pool lock */ 74 - void *rxe_alloc_locked(struct rxe_pool *pool); 75 - 72 + /* allocate an object from pool */ 76 73 void *rxe_alloc(struct rxe_pool *pool); 77 74 78 75 /* connect already allocated object to pool */ ··· 66 91 67 92 #define rxe_add_to_pool(pool, obj) __rxe_add_to_pool(pool, &(obj)->elem) 68 93 69 - /* assign an index to an indexed object and insert object into 70 - * pool's rb tree holding and not holding the pool_lock 71 - */ 72 - int __rxe_add_index_locked(struct rxe_pool_elem *elem); 73 - 74 - #define rxe_add_index_locked(obj) __rxe_add_index_locked(&(obj)->elem) 75 - 76 - int __rxe_add_index(struct rxe_pool_elem *elem); 77 - 78 - #define rxe_add_index(obj) __rxe_add_index(&(obj)->elem) 79 - 80 - /* drop an index and remove object from rb tree 81 - * holding and not holding the pool_lock 82 - */ 83 - void __rxe_drop_index_locked(struct rxe_pool_elem *elem); 84 - 85 - #define rxe_drop_index_locked(obj) __rxe_drop_index_locked(&(obj)->elem) 86 - 87 - void __rxe_drop_index(struct rxe_pool_elem *elem); 88 - 89 - #define rxe_drop_index(obj) __rxe_drop_index(&(obj)->elem) 90 - 91 - /* assign a key to a keyed object and insert object into 92 - * pool's rb tree holding and not holding pool_lock 93 - */ 94 - int __rxe_add_key_locked(struct rxe_pool_elem *elem, void *key); 95 - 96 - #define rxe_add_key_locked(obj, key) __rxe_add_key_locked(&(obj)->elem, key) 97 - 98 - int __rxe_add_key(struct rxe_pool_elem *elem, void *key); 99 - 100 - #define rxe_add_key(obj, key) __rxe_add_key(&(obj)->elem, key) 101 - 102 - /* remove elem from rb tree holding and not holding the pool_lock */ 103 - void __rxe_drop_key_locked(struct rxe_pool_elem *elem); 104 - 105 - #define rxe_drop_key_locked(obj) __rxe_drop_key_locked(&(obj)->elem) 106 - 107 - void __rxe_drop_key(struct rxe_pool_elem *elem); 108 - 109 - #define rxe_drop_key(obj) __rxe_drop_key(&(obj)->elem) 110 - 111 - /* lookup an indexed object from index holding and not holding the pool_lock. 112 - * takes a reference on object 113 - */ 114 - void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index); 115 - 94 + /* lookup an indexed object from index. takes a reference on object */ 116 95 void *rxe_pool_get_index(struct rxe_pool *pool, u32 index); 117 96 118 - /* lookup keyed object from key holding and not holding the pool_lock. 119 - * takes a reference on the objecti 120 - */ 121 - void *rxe_pool_get_key_locked(struct rxe_pool *pool, void *key); 97 + int __rxe_get(struct rxe_pool_elem *elem); 122 98 123 - void *rxe_pool_get_key(struct rxe_pool *pool, void *key); 99 + #define rxe_get(obj) __rxe_get(&(obj)->elem) 124 100 125 - /* cleanup an object when all references are dropped */ 126 - void rxe_elem_release(struct kref *kref); 101 + int __rxe_put(struct rxe_pool_elem *elem); 127 102 128 - /* take a reference on an object */ 129 - #define rxe_add_ref(obj) kref_get(&(obj)->elem.ref_cnt) 103 + #define rxe_put(obj) __rxe_put(&(obj)->elem) 130 104 131 - /* drop a reference on an object */ 132 - #define rxe_drop_ref(obj) kref_put(&(obj)->elem.ref_cnt, rxe_elem_release) 105 + #define rxe_read(obj) kref_read(&(obj)->elem.ref_cnt) 133 106 134 107 #endif /* RXE_POOL_H */
+30 -27
drivers/infiniband/sw/rxe/rxe_qp.c
··· 135 135 136 136 void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res) 137 137 { 138 - if (res->type == RXE_ATOMIC_MASK) { 138 + if (res->type == RXE_ATOMIC_MASK) 139 139 kfree_skb(res->atomic.skb); 140 - } else if (res->type == RXE_READ_MASK) { 141 - if (res->read.mr) 142 - rxe_drop_ref(res->read.mr); 143 - } 144 140 res->type = 0; 145 141 } 146 142 ··· 184 188 break; 185 189 } 186 190 187 - INIT_LIST_HEAD(&qp->grp_list); 188 - 189 - spin_lock_init(&qp->grp_lock); 190 191 spin_lock_init(&qp->state_lock); 191 192 192 193 atomic_set(&qp->ssn, 0); ··· 323 330 struct rxe_cq *scq = to_rcq(init->send_cq); 324 331 struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; 325 332 326 - rxe_add_ref(pd); 327 - rxe_add_ref(rcq); 328 - rxe_add_ref(scq); 333 + rxe_get(pd); 334 + rxe_get(rcq); 335 + rxe_get(scq); 329 336 if (srq) 330 - rxe_add_ref(srq); 337 + rxe_get(srq); 331 338 332 339 qp->pd = pd; 333 340 qp->rcq = rcq; ··· 359 366 qp->srq = NULL; 360 367 361 368 if (srq) 362 - rxe_drop_ref(srq); 363 - rxe_drop_ref(scq); 364 - rxe_drop_ref(rcq); 365 - rxe_drop_ref(pd); 369 + rxe_put(srq); 370 + rxe_put(scq); 371 + rxe_put(rcq); 372 + rxe_put(pd); 366 373 367 374 return err; 368 375 } ··· 521 528 qp->resp.sent_psn_nak = 0; 522 529 523 530 if (qp->resp.mr) { 524 - rxe_drop_ref(qp->resp.mr); 531 + rxe_put(qp->resp.mr); 525 532 qp->resp.mr = NULL; 526 533 } 527 534 ··· 763 770 return 0; 764 771 } 765 772 773 + int rxe_qp_chk_destroy(struct rxe_qp *qp) 774 + { 775 + /* See IBA o10-2.2.3 776 + * An attempt to destroy a QP while attached to a mcast group 777 + * will fail immediately. 778 + */ 779 + if (atomic_read(&qp->mcg_num)) { 780 + pr_debug("Attempt to destroy QP while attached to multicast group\n"); 781 + return -EBUSY; 782 + } 783 + 784 + return 0; 785 + } 786 + 766 787 /* called by the destroy qp verb */ 767 788 void rxe_qp_destroy(struct rxe_qp *qp) 768 789 { ··· 805 798 { 806 799 struct rxe_qp *qp = container_of(work, typeof(*qp), cleanup_work.work); 807 800 808 - rxe_drop_all_mcast_groups(qp); 809 - 810 801 if (qp->sq.queue) 811 802 rxe_queue_cleanup(qp->sq.queue); 812 803 813 804 if (qp->srq) 814 - rxe_drop_ref(qp->srq); 805 + rxe_put(qp->srq); 815 806 816 807 if (qp->rq.queue) 817 808 rxe_queue_cleanup(qp->rq.queue); 818 809 819 810 if (qp->scq) 820 - rxe_drop_ref(qp->scq); 811 + rxe_put(qp->scq); 821 812 if (qp->rcq) 822 - rxe_drop_ref(qp->rcq); 813 + rxe_put(qp->rcq); 823 814 if (qp->pd) 824 - rxe_drop_ref(qp->pd); 815 + rxe_put(qp->pd); 825 816 826 - if (qp->resp.mr) { 827 - rxe_drop_ref(qp->resp.mr); 828 - qp->resp.mr = NULL; 829 - } 817 + if (qp->resp.mr) 818 + rxe_put(qp->resp.mr); 830 819 831 820 if (qp_type(qp) == IB_QPT_RC) 832 821 sk_dst_reset(qp->sk->sk);
+6 -4
drivers/infiniband/sw/rxe/rxe_queue.c
··· 151 151 struct rxe_queue *new_q; 152 152 unsigned int num_elem = *num_elem_p; 153 153 int err; 154 + unsigned long producer_flags; 155 + unsigned long consumer_flags; 154 156 155 157 new_q = rxe_queue_init(q->rxe, &num_elem, elem_size, q->type); 156 158 if (!new_q) ··· 166 164 goto err1; 167 165 } 168 166 169 - spin_lock_bh(consumer_lock); 167 + spin_lock_irqsave(consumer_lock, consumer_flags); 170 168 171 169 if (producer_lock) { 172 - spin_lock_bh(producer_lock); 170 + spin_lock_irqsave(producer_lock, producer_flags); 173 171 err = resize_finish(q, new_q, num_elem); 174 - spin_unlock_bh(producer_lock); 172 + spin_unlock_irqrestore(producer_lock, producer_flags); 175 173 } else { 176 174 err = resize_finish(q, new_q, num_elem); 177 175 } 178 176 179 - spin_unlock_bh(consumer_lock); 177 + spin_unlock_irqrestore(consumer_lock, consumer_flags); 180 178 181 179 rxe_queue_cleanup(new_q); /* new/old dep on err */ 182 180 if (err)
+13 -13
drivers/infiniband/sw/rxe/rxe_recv.c
··· 217 217 return 0; 218 218 219 219 err2: 220 - rxe_drop_ref(qp); 220 + rxe_put(qp); 221 221 err1: 222 222 return -EINVAL; 223 223 } ··· 233 233 static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) 234 234 { 235 235 struct rxe_pkt_info *pkt = SKB_TO_PKT(skb); 236 - struct rxe_mc_grp *mcg; 237 - struct rxe_mc_elem *mce; 236 + struct rxe_mcg *mcg; 237 + struct rxe_mca *mca; 238 238 struct rxe_qp *qp; 239 239 union ib_gid dgid; 240 240 int err; ··· 246 246 memcpy(&dgid, &ipv6_hdr(skb)->daddr, sizeof(dgid)); 247 247 248 248 /* lookup mcast group corresponding to mgid, takes a ref */ 249 - mcg = rxe_pool_get_key(&rxe->mc_grp_pool, &dgid); 249 + mcg = rxe_lookup_mcg(rxe, &dgid); 250 250 if (!mcg) 251 251 goto drop; /* mcast group not registered */ 252 252 253 - spin_lock_bh(&mcg->mcg_lock); 253 + spin_lock_bh(&rxe->mcg_lock); 254 254 255 255 /* this is unreliable datagram service so we let 256 256 * failures to deliver a multicast packet to a 257 257 * single QP happen and just move on and try 258 258 * the rest of them on the list 259 259 */ 260 - list_for_each_entry(mce, &mcg->qp_list, qp_list) { 261 - qp = mce->qp; 260 + list_for_each_entry(mca, &mcg->qp_list, qp_list) { 261 + qp = mca->qp; 262 262 263 263 /* validate qp for incoming packet */ 264 264 err = check_type_state(rxe, pkt, qp); ··· 273 273 * skb and pass to the QP. Pass the original skb to 274 274 * the last QP in the list. 275 275 */ 276 - if (mce->qp_list.next != &mcg->qp_list) { 276 + if (mca->qp_list.next != &mcg->qp_list) { 277 277 struct sk_buff *cskb; 278 278 struct rxe_pkt_info *cpkt; 279 279 ··· 288 288 289 289 cpkt = SKB_TO_PKT(cskb); 290 290 cpkt->qp = qp; 291 - rxe_add_ref(qp); 291 + rxe_get(qp); 292 292 rxe_rcv_pkt(cpkt, cskb); 293 293 } else { 294 294 pkt->qp = qp; 295 - rxe_add_ref(qp); 295 + rxe_get(qp); 296 296 rxe_rcv_pkt(pkt, skb); 297 297 skb = NULL; /* mark consumed */ 298 298 } 299 299 } 300 300 301 - spin_unlock_bh(&mcg->mcg_lock); 301 + spin_unlock_bh(&rxe->mcg_lock); 302 302 303 - rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */ 303 + kref_put(&mcg->ref_cnt, rxe_cleanup_mcg); 304 304 305 305 if (likely(!skb)) 306 306 return; ··· 397 397 398 398 drop: 399 399 if (pkt->qp) 400 - rxe_drop_ref(pkt->qp); 400 + rxe_put(pkt->qp); 401 401 402 402 kfree_skb(skb); 403 403 ib_device_put(&rxe->ib_dev);
+41 -30
drivers/infiniband/sw/rxe/rxe_req.c
··· 358 358 } 359 359 360 360 static struct sk_buff *init_req_packet(struct rxe_qp *qp, 361 + struct rxe_av *av, 361 362 struct rxe_send_wqe *wqe, 362 - int opcode, int payload, 363 + int opcode, u32 payload, 363 364 struct rxe_pkt_info *pkt) 364 365 { 365 366 struct rxe_dev *rxe = to_rdev(qp->ibqp.device); 366 367 struct sk_buff *skb; 367 368 struct rxe_send_wr *ibwr = &wqe->wr; 368 - struct rxe_av *av; 369 369 int pad = (-payload) & 0x3; 370 370 int paylen; 371 371 int solicited; ··· 374 374 375 375 /* length from start of bth to end of icrc */ 376 376 paylen = rxe_opcode[opcode].length + payload + pad + RXE_ICRC_SIZE; 377 - 378 - /* pkt->hdr, port_num and mask are initialized in ifc layer */ 379 - pkt->rxe = rxe; 380 - pkt->opcode = opcode; 381 - pkt->qp = qp; 382 - pkt->psn = qp->req.psn; 383 - pkt->mask = rxe_opcode[opcode].mask; 384 - pkt->paylen = paylen; 385 - pkt->wqe = wqe; 377 + pkt->paylen = paylen; 386 378 387 379 /* init skb */ 388 - av = rxe_get_av(pkt); 389 - if (!av) 390 - return NULL; 391 - 392 380 skb = rxe_init_packet(rxe, av, paylen, pkt); 393 381 if (unlikely(!skb)) 394 382 return NULL; ··· 435 447 return skb; 436 448 } 437 449 438 - static int finish_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe, 439 - struct rxe_pkt_info *pkt, struct sk_buff *skb, 440 - int paylen) 450 + static int finish_packet(struct rxe_qp *qp, struct rxe_av *av, 451 + struct rxe_send_wqe *wqe, struct rxe_pkt_info *pkt, 452 + struct sk_buff *skb, u32 paylen) 441 453 { 442 454 int err; 443 455 444 - err = rxe_prepare(pkt, skb); 456 + err = rxe_prepare(av, pkt, skb); 445 457 if (err) 446 458 return err; 447 459 ··· 485 497 static void update_wqe_psn(struct rxe_qp *qp, 486 498 struct rxe_send_wqe *wqe, 487 499 struct rxe_pkt_info *pkt, 488 - int payload) 500 + u32 payload) 489 501 { 490 502 /* number of packets left to send including current one */ 491 503 int num_pkt = (wqe->dma.resid + payload + qp->mtu - 1) / qp->mtu; ··· 528 540 } 529 541 530 542 static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, 531 - struct rxe_pkt_info *pkt, int payload) 543 + struct rxe_pkt_info *pkt) 532 544 { 533 545 qp->req.opcode = pkt->opcode; 534 546 ··· 596 608 int rxe_requester(void *arg) 597 609 { 598 610 struct rxe_qp *qp = (struct rxe_qp *)arg; 611 + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); 599 612 struct rxe_pkt_info pkt; 600 613 struct sk_buff *skb; 601 614 struct rxe_send_wqe *wqe; 602 615 enum rxe_hdr_mask mask; 603 - int payload; 616 + u32 payload; 604 617 int mtu; 605 618 int opcode; 606 619 int ret; 607 620 struct rxe_send_wqe rollback_wqe; 608 621 u32 rollback_psn; 609 622 struct rxe_queue *q = qp->sq.queue; 623 + struct rxe_ah *ah; 624 + struct rxe_av *av; 610 625 611 - rxe_add_ref(qp); 626 + rxe_get(qp); 612 627 613 628 next_wqe: 614 629 if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) ··· 690 699 wqe->state = wqe_state_done; 691 700 wqe->status = IB_WC_SUCCESS; 692 701 __rxe_do_task(&qp->comp.task); 693 - rxe_drop_ref(qp); 702 + rxe_put(qp); 694 703 return 0; 695 704 } 696 705 payload = mtu; 697 706 } 698 707 699 - skb = init_req_packet(qp, wqe, opcode, payload, &pkt); 708 + pkt.rxe = rxe; 709 + pkt.opcode = opcode; 710 + pkt.qp = qp; 711 + pkt.psn = qp->req.psn; 712 + pkt.mask = rxe_opcode[opcode].mask; 713 + pkt.wqe = wqe; 714 + 715 + av = rxe_get_av(&pkt, &ah); 716 + if (unlikely(!av)) { 717 + pr_err("qp#%d Failed no address vector\n", qp_num(qp)); 718 + wqe->status = IB_WC_LOC_QP_OP_ERR; 719 + goto err_drop_ah; 720 + } 721 + 722 + skb = init_req_packet(qp, av, wqe, opcode, payload, &pkt); 700 723 if (unlikely(!skb)) { 701 724 pr_err("qp#%d Failed allocating skb\n", qp_num(qp)); 702 725 wqe->status = IB_WC_LOC_QP_OP_ERR; 703 - goto err; 726 + goto err_drop_ah; 704 727 } 705 728 706 - ret = finish_packet(qp, wqe, &pkt, skb, payload); 729 + ret = finish_packet(qp, av, wqe, &pkt, skb, payload); 707 730 if (unlikely(ret)) { 708 731 pr_debug("qp#%d Error during finish packet\n", qp_num(qp)); 709 732 if (ret == -EFAULT) ··· 725 720 else 726 721 wqe->status = IB_WC_LOC_QP_OP_ERR; 727 722 kfree_skb(skb); 728 - goto err; 723 + goto err_drop_ah; 729 724 } 725 + 726 + if (ah) 727 + rxe_put(ah); 730 728 731 729 /* 732 730 * To prevent a race on wqe access between requester and completer, ··· 755 747 goto err; 756 748 } 757 749 758 - update_state(qp, wqe, &pkt, payload); 750 + update_state(qp, wqe, &pkt); 759 751 760 752 goto next_wqe; 761 753 754 + err_drop_ah: 755 + if (ah) 756 + rxe_put(ah); 762 757 err: 763 758 wqe->state = wqe_state_error; 764 759 __rxe_do_task(&qp->comp.task); 765 760 766 761 exit: 767 - rxe_drop_ref(qp); 762 + rxe_put(qp); 768 763 return -EAGAIN; 769 764 }
+110 -60
drivers/infiniband/sw/rxe/rxe_resp.c
··· 99 99 100 100 if (qp->resp.state == QP_STATE_ERROR) { 101 101 while ((skb = skb_dequeue(&qp->req_pkts))) { 102 - rxe_drop_ref(qp); 102 + rxe_put(qp); 103 103 kfree_skb(skb); 104 104 ib_device_put(qp->ibqp.device); 105 105 } ··· 297 297 struct ib_event ev; 298 298 unsigned int count; 299 299 size_t size; 300 + unsigned long flags; 300 301 301 302 if (srq->error) 302 303 return RESPST_ERR_RNR; 303 304 304 - spin_lock_bh(&srq->rq.consumer_lock); 305 + spin_lock_irqsave(&srq->rq.consumer_lock, flags); 305 306 306 307 wqe = queue_head(q, QUEUE_TYPE_FROM_CLIENT); 307 308 if (!wqe) { 308 - spin_unlock_bh(&srq->rq.consumer_lock); 309 + spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); 309 310 return RESPST_ERR_RNR; 310 311 } 311 312 312 313 /* don't trust user space data */ 313 314 if (unlikely(wqe->dma.num_sge > srq->rq.max_sge)) { 314 - spin_unlock_bh(&srq->rq.consumer_lock); 315 + spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); 315 316 pr_warn("%s: invalid num_sge in SRQ entry\n", __func__); 316 317 return RESPST_ERR_MALFORMED_WQE; 317 318 } ··· 328 327 goto event; 329 328 } 330 329 331 - spin_unlock_bh(&srq->rq.consumer_lock); 330 + spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); 332 331 return RESPST_CHK_LENGTH; 333 332 334 333 event: 335 - spin_unlock_bh(&srq->rq.consumer_lock); 334 + spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); 336 335 ev.device = qp->ibqp.device; 337 336 ev.element.srq = qp->ibqp.srq; 338 337 ev.event = IB_EVENT_SRQ_LIMIT_REACHED; ··· 464 463 if (mw->access & IB_ZERO_BASED) 465 464 qp->resp.offset = mw->addr; 466 465 467 - rxe_drop_ref(mw); 468 - rxe_add_ref(mr); 466 + rxe_put(mw); 467 + rxe_get(mr); 469 468 } else { 470 469 mr = lookup_mr(qp->pd, access, rkey, RXE_LOOKUP_REMOTE); 471 470 if (!mr) { ··· 508 507 509 508 err: 510 509 if (mr) 511 - rxe_drop_ref(mr); 510 + rxe_put(mr); 512 511 if (mw) 513 - rxe_drop_ref(mw); 512 + rxe_put(mw); 514 513 515 514 return state; 516 515 } ··· 633 632 if (ack->mask & RXE_ATMACK_MASK) 634 633 atmack_set_orig(ack, qp->resp.atomic_orig); 635 634 636 - err = rxe_prepare(ack, skb); 635 + err = rxe_prepare(&qp->pri_av, ack, skb); 637 636 if (err) { 638 637 kfree_skb(skb); 639 638 return NULL; 640 639 } 641 640 642 641 return skb; 642 + } 643 + 644 + static struct resp_res *rxe_prepare_read_res(struct rxe_qp *qp, 645 + struct rxe_pkt_info *pkt) 646 + { 647 + struct resp_res *res; 648 + u32 pkts; 649 + 650 + res = &qp->resp.resources[qp->resp.res_head]; 651 + rxe_advance_resp_resource(qp); 652 + free_rd_atomic_resource(qp, res); 653 + 654 + res->type = RXE_READ_MASK; 655 + res->replay = 0; 656 + res->read.va = qp->resp.va + qp->resp.offset; 657 + res->read.va_org = qp->resp.va + qp->resp.offset; 658 + res->read.resid = qp->resp.resid; 659 + res->read.length = qp->resp.resid; 660 + res->read.rkey = qp->resp.rkey; 661 + 662 + pkts = max_t(u32, (reth_len(pkt) + qp->mtu - 1)/qp->mtu, 1); 663 + res->first_psn = pkt->psn; 664 + res->cur_psn = pkt->psn; 665 + res->last_psn = (pkt->psn + pkts - 1) & BTH_PSN_MASK; 666 + 667 + res->state = rdatm_res_state_new; 668 + 669 + return res; 670 + } 671 + 672 + /** 673 + * rxe_recheck_mr - revalidate MR from rkey and get a reference 674 + * @qp: the qp 675 + * @rkey: the rkey 676 + * 677 + * This code allows the MR to be invalidated or deregistered or 678 + * the MW if one was used to be invalidated or deallocated. 679 + * It is assumed that the access permissions if originally good 680 + * are OK and the mappings to be unchanged. 681 + * 682 + * Return: mr on success else NULL 683 + */ 684 + static struct rxe_mr *rxe_recheck_mr(struct rxe_qp *qp, u32 rkey) 685 + { 686 + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); 687 + struct rxe_mr *mr; 688 + struct rxe_mw *mw; 689 + 690 + if (rkey_is_mw(rkey)) { 691 + mw = rxe_pool_get_index(&rxe->mw_pool, rkey >> 8); 692 + if (!mw || mw->rkey != rkey) 693 + return NULL; 694 + 695 + if (mw->state != RXE_MW_STATE_VALID) { 696 + rxe_put(mw); 697 + return NULL; 698 + } 699 + 700 + mr = mw->mr; 701 + rxe_put(mw); 702 + } else { 703 + mr = rxe_pool_get_index(&rxe->mr_pool, rkey >> 8); 704 + if (!mr || mr->rkey != rkey) 705 + return NULL; 706 + } 707 + 708 + if (mr->state != RXE_MR_STATE_VALID) { 709 + rxe_put(mr); 710 + return NULL; 711 + } 712 + 713 + return mr; 643 714 } 644 715 645 716 /* RDMA read response. If res is not NULL, then we have a current RDMA request ··· 728 655 int opcode; 729 656 int err; 730 657 struct resp_res *res = qp->resp.res; 658 + struct rxe_mr *mr; 731 659 732 660 if (!res) { 733 - /* This is the first time we process that request. Get a 734 - * resource 735 - */ 736 - res = &qp->resp.resources[qp->resp.res_head]; 737 - 738 - free_rd_atomic_resource(qp, res); 739 - rxe_advance_resp_resource(qp); 740 - 741 - res->type = RXE_READ_MASK; 742 - res->replay = 0; 743 - 744 - res->read.va = qp->resp.va + 745 - qp->resp.offset; 746 - res->read.va_org = qp->resp.va + 747 - qp->resp.offset; 748 - 749 - res->first_psn = req_pkt->psn; 750 - 751 - if (reth_len(req_pkt)) { 752 - res->last_psn = (req_pkt->psn + 753 - (reth_len(req_pkt) + mtu - 1) / 754 - mtu - 1) & BTH_PSN_MASK; 755 - } else { 756 - res->last_psn = res->first_psn; 757 - } 758 - res->cur_psn = req_pkt->psn; 759 - 760 - res->read.resid = qp->resp.resid; 761 - res->read.length = qp->resp.resid; 762 - res->read.rkey = qp->resp.rkey; 763 - 764 - /* note res inherits the reference to mr from qp */ 765 - res->read.mr = qp->resp.mr; 766 - qp->resp.mr = NULL; 767 - 768 - qp->resp.res = res; 769 - res->state = rdatm_res_state_new; 661 + res = rxe_prepare_read_res(qp, req_pkt); 662 + qp->resp.res = res; 770 663 } 771 664 772 665 if (res->state == rdatm_res_state_new) { 666 + mr = qp->resp.mr; 667 + qp->resp.mr = NULL; 668 + 773 669 if (res->read.resid <= mtu) 774 670 opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_ONLY; 775 671 else 776 672 opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST; 777 673 } else { 674 + mr = rxe_recheck_mr(qp, res->read.rkey); 675 + if (!mr) 676 + return RESPST_ERR_RKEY_VIOLATION; 677 + 778 678 if (res->read.resid > mtu) 779 679 opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE; 780 680 else ··· 763 717 if (!skb) 764 718 return RESPST_ERR_RNR; 765 719 766 - err = rxe_mr_copy(res->read.mr, res->read.va, payload_addr(&ack_pkt), 720 + err = rxe_mr_copy(mr, res->read.va, payload_addr(&ack_pkt), 767 721 payload, RXE_FROM_MR_OBJ); 768 722 if (err) 769 723 pr_err("Failed copying memory\n"); 724 + if (mr) 725 + rxe_put(mr); 770 726 771 727 if (bth_pad(&ack_pkt)) { 772 728 u8 *pad = payload_addr(&ack_pkt) + payload; ··· 862 814 return RESPST_ERR_INVALIDATE_RKEY; 863 815 } 864 816 817 + if (pkt->mask & RXE_END_MASK) 818 + /* We successfully processed this new request. */ 819 + qp->resp.msn++; 820 + 865 821 /* next expected psn, read handles this separately */ 866 822 qp->resp.psn = (pkt->psn + 1) & BTH_PSN_MASK; 867 823 qp->resp.ack_psn = qp->resp.psn; ··· 873 821 qp->resp.opcode = pkt->opcode; 874 822 qp->resp.status = IB_WC_SUCCESS; 875 823 876 - if (pkt->mask & RXE_COMP_MASK) { 877 - /* We successfully processed this new request. */ 878 - qp->resp.msn++; 824 + if (pkt->mask & RXE_COMP_MASK) 879 825 return RESPST_COMPLETE; 880 - } else if (qp_type(qp) == IB_QPT_RC) 826 + else if (qp_type(qp) == IB_QPT_RC) 881 827 return RESPST_ACKNOWLEDGE; 882 828 else 883 829 return RESPST_CLEANUP; ··· 1037 987 rc = rxe_xmit_packet(qp, &ack_pkt, skb); 1038 988 if (rc) { 1039 989 pr_err_ratelimited("Failed sending ack\n"); 1040 - rxe_drop_ref(qp); 990 + rxe_put(qp); 1041 991 } 1042 992 out: 1043 993 return rc; ··· 1066 1016 1067 1017 if (pkt) { 1068 1018 skb = skb_dequeue(&qp->req_pkts); 1069 - rxe_drop_ref(qp); 1019 + rxe_put(qp); 1070 1020 kfree_skb(skb); 1071 1021 ib_device_put(qp->ibqp.device); 1072 1022 } 1073 1023 1074 1024 if (qp->resp.mr) { 1075 - rxe_drop_ref(qp->resp.mr); 1025 + rxe_put(qp->resp.mr); 1076 1026 qp->resp.mr = NULL; 1077 1027 } 1078 1028 ··· 1216 1166 } 1217 1167 1218 1168 if (qp->resp.mr) { 1219 - rxe_drop_ref(qp->resp.mr); 1169 + rxe_put(qp->resp.mr); 1220 1170 qp->resp.mr = NULL; 1221 1171 } 1222 1172 ··· 1230 1180 struct rxe_queue *q = qp->rq.queue; 1231 1181 1232 1182 while ((skb = skb_dequeue(&qp->req_pkts))) { 1233 - rxe_drop_ref(qp); 1183 + rxe_put(qp); 1234 1184 kfree_skb(skb); 1235 1185 ib_device_put(qp->ibqp.device); 1236 1186 } ··· 1250 1200 struct rxe_pkt_info *pkt = NULL; 1251 1201 int ret = 0; 1252 1202 1253 - rxe_add_ref(qp); 1203 + rxe_get(qp); 1254 1204 1255 1205 qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED; 1256 1206 ··· 1437 1387 exit: 1438 1388 ret = -EAGAIN; 1439 1389 done: 1440 - rxe_drop_ref(qp); 1390 + rxe_put(qp); 1441 1391 return ret; 1442 1392 }
+40 -68
drivers/infiniband/sw/rxe/rxe_verbs.c
··· 115 115 { 116 116 struct rxe_ucontext *uc = to_ruc(ibuc); 117 117 118 - rxe_drop_ref(uc); 118 + rxe_put(uc); 119 119 } 120 120 121 121 static int rxe_port_immutable(struct ib_device *dev, u32 port_num, ··· 149 149 { 150 150 struct rxe_pd *pd = to_rpd(ibpd); 151 151 152 - rxe_drop_ref(pd); 152 + rxe_put(pd); 153 153 return 0; 154 154 } 155 155 ··· 181 181 return err; 182 182 183 183 /* create index > 0 */ 184 - rxe_add_index(ah); 185 184 ah->ah_num = ah->elem.index; 186 185 187 186 if (uresp) { ··· 188 189 err = copy_to_user(&uresp->ah_num, &ah->ah_num, 189 190 sizeof(uresp->ah_num)); 190 191 if (err) { 191 - rxe_drop_index(ah); 192 - rxe_drop_ref(ah); 192 + rxe_put(ah); 193 193 return -EFAULT; 194 194 } 195 195 } else if (ah->is_user) { ··· 228 230 { 229 231 struct rxe_ah *ah = to_rah(ibah); 230 232 231 - rxe_drop_index(ah); 232 - rxe_drop_ref(ah); 233 + rxe_put(ah); 233 234 return 0; 234 235 } 235 236 ··· 303 306 if (err) 304 307 goto err1; 305 308 306 - rxe_add_ref(pd); 309 + rxe_get(pd); 307 310 srq->pd = pd; 308 311 309 312 err = rxe_srq_from_init(rxe, srq, init, udata, uresp); ··· 313 316 return 0; 314 317 315 318 err2: 316 - rxe_drop_ref(pd); 317 - rxe_drop_ref(srq); 319 + rxe_put(pd); 320 + rxe_put(srq); 318 321 err1: 319 322 return err; 320 323 } ··· 371 374 if (srq->rq.queue) 372 375 rxe_queue_cleanup(srq->rq.queue); 373 376 374 - rxe_drop_ref(srq->pd); 375 - rxe_drop_ref(srq); 377 + rxe_put(srq->pd); 378 + rxe_put(srq); 376 379 return 0; 377 380 } 378 381 ··· 381 384 { 382 385 int err = 0; 383 386 struct rxe_srq *srq = to_rsrq(ibsrq); 387 + unsigned long flags; 384 388 385 - spin_lock_bh(&srq->rq.producer_lock); 389 + spin_lock_irqsave(&srq->rq.producer_lock, flags); 386 390 387 391 while (wr) { 388 392 err = post_one_recv(&srq->rq, wr); ··· 392 394 wr = wr->next; 393 395 } 394 396 395 - spin_unlock_bh(&srq->rq.producer_lock); 397 + spin_unlock_irqrestore(&srq->rq.producer_lock, flags); 396 398 397 399 if (err) 398 400 *bad_wr = wr; ··· 435 437 if (err) 436 438 return err; 437 439 438 - rxe_add_index(qp); 439 440 err = rxe_qp_from_init(rxe, qp, pd, init, uresp, ibqp->pd, udata); 440 441 if (err) 441 442 goto qp_init; ··· 442 445 return 0; 443 446 444 447 qp_init: 445 - rxe_drop_index(qp); 446 - rxe_drop_ref(qp); 448 + rxe_put(qp); 447 449 return err; 448 450 } 449 451 ··· 489 493 static int rxe_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) 490 494 { 491 495 struct rxe_qp *qp = to_rqp(ibqp); 496 + int ret; 497 + 498 + ret = rxe_qp_chk_destroy(qp); 499 + if (ret) 500 + return ret; 492 501 493 502 rxe_qp_destroy(qp); 494 - rxe_drop_index(qp); 495 - rxe_drop_ref(qp); 503 + rxe_put(qp); 496 504 return 0; 497 505 } 498 506 ··· 638 638 int err; 639 639 struct rxe_sq *sq = &qp->sq; 640 640 struct rxe_send_wqe *send_wqe; 641 + unsigned long flags; 641 642 int full; 642 643 643 644 err = validate_send_wr(qp, ibwr, mask, length); 644 645 if (err) 645 646 return err; 646 647 647 - spin_lock_bh(&qp->sq.sq_lock); 648 + spin_lock_irqsave(&qp->sq.sq_lock, flags); 648 649 649 650 full = queue_full(sq->queue, QUEUE_TYPE_TO_DRIVER); 650 651 651 652 if (unlikely(full)) { 652 - spin_unlock_bh(&qp->sq.sq_lock); 653 + spin_unlock_irqrestore(&qp->sq.sq_lock, flags); 653 654 return -ENOMEM; 654 655 } 655 656 ··· 659 658 660 659 queue_advance_producer(sq->queue, QUEUE_TYPE_TO_DRIVER); 661 660 662 - spin_unlock_bh(&qp->sq.sq_lock); 661 + spin_unlock_irqrestore(&qp->sq.sq_lock, flags); 663 662 664 663 return 0; 665 664 } ··· 739 738 int err = 0; 740 739 struct rxe_qp *qp = to_rqp(ibqp); 741 740 struct rxe_rq *rq = &qp->rq; 741 + unsigned long flags; 742 742 743 743 if (unlikely((qp_state(qp) < IB_QPS_INIT) || !qp->valid)) { 744 744 *bad_wr = wr; ··· 753 751 goto err1; 754 752 } 755 753 756 - spin_lock_bh(&rq->producer_lock); 754 + spin_lock_irqsave(&rq->producer_lock, flags); 757 755 758 756 while (wr) { 759 757 err = post_one_recv(rq, wr); ··· 764 762 wr = wr->next; 765 763 } 766 764 767 - spin_unlock_bh(&rq->producer_lock); 765 + spin_unlock_irqrestore(&rq->producer_lock, flags); 768 766 769 767 if (qp->resp.state == QP_STATE_ERROR) 770 768 rxe_run_task(&qp->resp.task, 1); ··· 809 807 810 808 rxe_cq_disable(cq); 811 809 812 - rxe_drop_ref(cq); 810 + rxe_put(cq); 813 811 return 0; 814 812 } 815 813 ··· 845 843 int i; 846 844 struct rxe_cq *cq = to_rcq(ibcq); 847 845 struct rxe_cqe *cqe; 846 + unsigned long flags; 848 847 849 - spin_lock_bh(&cq->cq_lock); 848 + spin_lock_irqsave(&cq->cq_lock, flags); 850 849 for (i = 0; i < num_entries; i++) { 851 850 cqe = queue_head(cq->queue, QUEUE_TYPE_FROM_DRIVER); 852 851 if (!cqe) ··· 856 853 memcpy(wc++, &cqe->ibwc, sizeof(*wc)); 857 854 queue_advance_consumer(cq->queue, QUEUE_TYPE_FROM_DRIVER); 858 855 } 859 - spin_unlock_bh(&cq->cq_lock); 856 + spin_unlock_irqrestore(&cq->cq_lock, flags); 860 857 861 858 return i; 862 859 } ··· 876 873 struct rxe_cq *cq = to_rcq(ibcq); 877 874 int ret = 0; 878 875 int empty; 876 + unsigned long irq_flags; 879 877 880 - spin_lock_bh(&cq->cq_lock); 878 + spin_lock_irqsave(&cq->cq_lock, irq_flags); 881 879 if (cq->notify != IB_CQ_NEXT_COMP) 882 880 cq->notify = flags & IB_CQ_SOLICITED_MASK; 883 881 ··· 887 883 if ((flags & IB_CQ_REPORT_MISSED_EVENTS) && !empty) 888 884 ret = 1; 889 885 890 - spin_unlock_bh(&cq->cq_lock); 886 + spin_unlock_irqrestore(&cq->cq_lock, irq_flags); 891 887 892 888 return ret; 893 889 } ··· 902 898 if (!mr) 903 899 return ERR_PTR(-ENOMEM); 904 900 905 - rxe_add_index(mr); 906 - rxe_add_ref(pd); 901 + rxe_get(pd); 907 902 rxe_mr_init_dma(pd, access, mr); 908 903 909 904 return &mr->ibmr; ··· 925 922 goto err2; 926 923 } 927 924 928 - rxe_add_index(mr); 929 925 930 - rxe_add_ref(pd); 926 + rxe_get(pd); 931 927 932 928 err = rxe_mr_init_user(pd, start, length, iova, access, mr); 933 929 if (err) ··· 935 933 return &mr->ibmr; 936 934 937 935 err3: 938 - rxe_drop_ref(pd); 939 - rxe_drop_index(mr); 940 - rxe_drop_ref(mr); 936 + rxe_put(pd); 937 + rxe_put(mr); 941 938 err2: 942 939 return ERR_PTR(err); 943 940 } ··· 958 957 goto err1; 959 958 } 960 959 961 - rxe_add_index(mr); 962 - 963 - rxe_add_ref(pd); 960 + rxe_get(pd); 964 961 965 962 err = rxe_mr_init_fast(pd, max_num_sg, mr); 966 963 if (err) ··· 967 968 return &mr->ibmr; 968 969 969 970 err2: 970 - rxe_drop_ref(pd); 971 - rxe_drop_index(mr); 972 - rxe_drop_ref(mr); 971 + rxe_put(pd); 972 + rxe_put(mr); 973 973 err1: 974 974 return ERR_PTR(err); 975 975 } ··· 995 997 set->offset = set->iova & set->page_mask; 996 998 997 999 return n; 998 - } 999 - 1000 - static int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) 1001 - { 1002 - int err; 1003 - struct rxe_dev *rxe = to_rdev(ibqp->device); 1004 - struct rxe_qp *qp = to_rqp(ibqp); 1005 - struct rxe_mc_grp *grp; 1006 - 1007 - /* takes a ref on grp if successful */ 1008 - err = rxe_mcast_get_grp(rxe, mgid, &grp); 1009 - if (err) 1010 - return err; 1011 - 1012 - err = rxe_mcast_add_grp_elem(rxe, qp, grp); 1013 - 1014 - rxe_drop_ref(grp); 1015 - return err; 1016 - } 1017 - 1018 - static int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) 1019 - { 1020 - struct rxe_dev *rxe = to_rdev(ibqp->device); 1021 - struct rxe_qp *qp = to_rqp(ibqp); 1022 - 1023 - return rxe_mcast_drop_grp_elem(rxe, qp, mgid); 1024 1000 } 1025 1001 1026 1002 static ssize_t parent_show(struct device *device,
+12 -15
drivers/infiniband/sw/rxe/rxe_verbs.h
··· 157 157 struct sk_buff *skb; 158 158 } atomic; 159 159 struct { 160 - struct rxe_mr *mr; 161 160 u64 va_org; 162 161 u32 rkey; 163 162 u32 length; ··· 231 232 struct rxe_av pri_av; 232 233 struct rxe_av alt_av; 233 234 234 - /* list of mcast groups qp has joined (for cleanup) */ 235 - struct list_head grp_list; 236 - spinlock_t grp_lock; /* guard grp_list */ 235 + atomic_t mcg_num; 237 236 238 237 struct sk_buff_head req_pkts; 239 238 struct sk_buff_head resp_pkts; ··· 350 353 u64 length; 351 354 }; 352 355 353 - struct rxe_mc_grp { 354 - struct rxe_pool_elem elem; 355 - spinlock_t mcg_lock; /* guard group */ 356 + struct rxe_mcg { 357 + struct rb_node node; 358 + struct kref ref_cnt; 356 359 struct rxe_dev *rxe; 357 360 struct list_head qp_list; 358 361 union ib_gid mgid; 359 - int num_qp; 362 + atomic_t qp_num; 360 363 u32 qkey; 361 364 u16 pkey; 362 365 }; 363 366 364 - struct rxe_mc_elem { 365 - struct rxe_pool_elem elem; 367 + struct rxe_mca { 366 368 struct list_head qp_list; 367 - struct list_head grp_list; 368 369 struct rxe_qp *qp; 369 - struct rxe_mc_grp *grp; 370 370 }; 371 371 372 372 struct rxe_port { ··· 395 401 struct rxe_pool mr_pool; 396 402 struct rxe_pool mw_pool; 397 403 struct rxe_pool mc_grp_pool; 398 - struct rxe_pool mc_elem_pool; 404 + 405 + /* multicast support */ 406 + spinlock_t mcg_lock; 407 + struct rb_root mcg_tree; 408 + atomic_t mcg_num; 409 + atomic_t mcg_attach; 399 410 400 411 spinlock_t pending_lock; /* guard pending_mmaps */ 401 412 struct list_head pending_mmaps; ··· 480 481 } 481 482 482 483 int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name); 483 - 484 - void rxe_mc_cleanup(struct rxe_pool_elem *elem); 485 484 486 485 #endif /* RXE_VERBS_H */
-1
drivers/infiniband/ulp/ipoib/ipoib_netlink.c
··· 32 32 33 33 #include <linux/netdevice.h> 34 34 #include <linux/if_arp.h> /* For ARPHRD_xxx */ 35 - #include <linux/module.h> 36 35 #include <net/rtnetlink.h> 37 36 #include "ipoib.h" 38 37
-1
drivers/infiniband/ulp/ipoib/ipoib_vlan.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/module.h> 34 33 #include <linux/sched/signal.h> 35 34 36 35 #include <linux/init.h>
+6 -7
drivers/infiniband/ulp/iser/iscsi_iser.h
··· 203 203 * 204 204 * @sge: memory region sg element 205 205 * @rkey: memory region remote key 206 - * @mem_h: pointer to registration context (FMR/Fastreg) 206 + * @desc: pointer to fast registration context 207 207 */ 208 208 struct iser_mem_reg { 209 - struct ib_sge sge; 210 - u32 rkey; 211 - void *mem_h; 209 + struct ib_sge sge; 210 + u32 rkey; 211 + struct iser_fr_desc *desc; 212 212 }; 213 213 214 214 enum iser_desc_type { ··· 531 531 int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc); 532 532 533 533 int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, 534 - struct iser_data_buf *data, 535 534 enum iser_data_dir iser_dir, 536 535 enum dma_data_direction dma_dir); 537 536 538 537 void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, 539 - struct iser_data_buf *data, 540 - enum dma_data_direction dir); 538 + enum iser_data_dir iser_dir, 539 + enum dma_data_direction dma_dir); 541 540 542 541 int iser_initialize_task_headers(struct iscsi_task *task, 543 542 struct iser_tx_desc *tx_desc);
+15 -43
drivers/infiniband/ulp/iser/iser_initiator.c
··· 52 52 struct iser_mem_reg *mem_reg; 53 53 int err; 54 54 struct iser_ctrl *hdr = &iser_task->desc.iser_header; 55 - struct iser_data_buf *buf_in = &iser_task->data[ISER_DIR_IN]; 56 55 57 56 err = iser_dma_map_task_data(iser_task, 58 - buf_in, 59 57 ISER_DIR_IN, 60 58 DMA_FROM_DEVICE); 61 59 if (err) 62 60 return err; 63 61 64 - if (scsi_prot_sg_count(iser_task->sc)) { 65 - struct iser_data_buf *pbuf_in = &iser_task->prot[ISER_DIR_IN]; 66 - 67 - err = iser_dma_map_task_data(iser_task, 68 - pbuf_in, 69 - ISER_DIR_IN, 70 - DMA_FROM_DEVICE); 71 - if (err) 72 - return err; 73 - } 74 - 75 62 err = iser_reg_mem_fastreg(iser_task, ISER_DIR_IN, false); 76 63 if (err) { 77 64 iser_err("Failed to set up Data-IN RDMA\n"); 78 - return err; 65 + goto out_err; 79 66 } 80 67 mem_reg = &iser_task->rdma_reg[ISER_DIR_IN]; 81 68 ··· 75 88 (unsigned long long)mem_reg->sge.addr); 76 89 77 90 return 0; 91 + 92 + out_err: 93 + iser_dma_unmap_task_data(iser_task, ISER_DIR_IN, DMA_FROM_DEVICE); 94 + return err; 78 95 } 79 96 80 97 /* Register user buffer memory and initialize passive rdma ··· 97 106 struct ib_sge *tx_dsg = &iser_task->desc.tx_sg[1]; 98 107 99 108 err = iser_dma_map_task_data(iser_task, 100 - buf_out, 101 109 ISER_DIR_OUT, 102 110 DMA_TO_DEVICE); 103 111 if (err) 104 112 return err; 105 113 106 - if (scsi_prot_sg_count(iser_task->sc)) { 107 - struct iser_data_buf *pbuf_out = &iser_task->prot[ISER_DIR_OUT]; 108 - 109 - err = iser_dma_map_task_data(iser_task, 110 - pbuf_out, 111 - ISER_DIR_OUT, 112 - DMA_TO_DEVICE); 113 - if (err) 114 - return err; 115 - } 116 - 117 114 err = iser_reg_mem_fastreg(iser_task, ISER_DIR_OUT, 118 115 buf_out->data_len == imm_sz); 119 - if (err != 0) { 116 + if (err) { 120 117 iser_err("Failed to register write cmd RDMA mem\n"); 121 - return err; 118 + goto out_err; 122 119 } 123 120 124 121 mem_reg = &iser_task->rdma_reg[ISER_DIR_OUT]; ··· 133 154 } 134 155 135 156 return 0; 157 + 158 + out_err: 159 + iser_dma_unmap_task_data(iser_task, ISER_DIR_OUT, DMA_TO_DEVICE); 160 + return err; 136 161 } 137 162 138 163 /* creates a new tx descriptor and adds header regd buffer */ ··· 602 619 struct iser_fr_desc *desc; 603 620 604 621 if (iser_task->dir[ISER_DIR_IN]) { 605 - desc = iser_task->rdma_reg[ISER_DIR_IN].mem_h; 622 + desc = iser_task->rdma_reg[ISER_DIR_IN].desc; 606 623 if (unlikely(iser_inv_desc(desc, rkey))) 607 624 return -EINVAL; 608 625 } 609 626 610 627 if (iser_task->dir[ISER_DIR_OUT]) { 611 - desc = iser_task->rdma_reg[ISER_DIR_OUT].mem_h; 628 + desc = iser_task->rdma_reg[ISER_DIR_OUT].desc; 612 629 if (unlikely(iser_inv_desc(desc, rkey))) 613 630 return -EINVAL; 614 631 } ··· 723 740 724 741 void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task) 725 742 { 726 - int prot_count = scsi_prot_sg_count(iser_task->sc); 727 743 728 744 if (iser_task->dir[ISER_DIR_IN]) { 729 745 iser_unreg_mem_fastreg(iser_task, ISER_DIR_IN); 730 - iser_dma_unmap_task_data(iser_task, 731 - &iser_task->data[ISER_DIR_IN], 746 + iser_dma_unmap_task_data(iser_task, ISER_DIR_IN, 732 747 DMA_FROM_DEVICE); 733 - if (prot_count) 734 - iser_dma_unmap_task_data(iser_task, 735 - &iser_task->prot[ISER_DIR_IN], 736 - DMA_FROM_DEVICE); 737 748 } 738 749 739 750 if (iser_task->dir[ISER_DIR_OUT]) { 740 751 iser_unreg_mem_fastreg(iser_task, ISER_DIR_OUT); 741 - iser_dma_unmap_task_data(iser_task, 742 - &iser_task->data[ISER_DIR_OUT], 752 + iser_dma_unmap_task_data(iser_task, ISER_DIR_OUT, 743 753 DMA_TO_DEVICE); 744 - if (prot_count) 745 - iser_dma_unmap_task_data(iser_task, 746 - &iser_task->prot[ISER_DIR_OUT], 747 - DMA_TO_DEVICE); 748 754 } 749 755 }
+39 -30
drivers/infiniband/ulp/iser/iser_memory.c
··· 30 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 31 * SOFTWARE. 32 32 */ 33 - #include <linux/module.h> 34 33 #include <linux/kernel.h> 35 34 #include <linux/slab.h> 36 35 #include <linux/mm.h> ··· 70 71 } 71 72 72 73 int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, 73 - struct iser_data_buf *data, 74 74 enum iser_data_dir iser_dir, 75 75 enum dma_data_direction dma_dir) 76 76 { 77 + struct iser_data_buf *data = &iser_task->data[iser_dir]; 77 78 struct ib_device *dev; 78 79 79 80 iser_task->dir[iser_dir] = 1; ··· 84 85 iser_err("dma_map_sg failed!!!\n"); 85 86 return -EINVAL; 86 87 } 88 + 89 + if (scsi_prot_sg_count(iser_task->sc)) { 90 + struct iser_data_buf *pdata = &iser_task->prot[iser_dir]; 91 + 92 + pdata->dma_nents = ib_dma_map_sg(dev, pdata->sg, pdata->size, dma_dir); 93 + if (unlikely(pdata->dma_nents == 0)) { 94 + iser_err("protection dma_map_sg failed!!!\n"); 95 + goto out_unmap; 96 + } 97 + } 98 + 87 99 return 0; 100 + 101 + out_unmap: 102 + ib_dma_unmap_sg(dev, data->sg, data->size, dma_dir); 103 + return -EINVAL; 88 104 } 89 105 106 + 90 107 void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, 91 - struct iser_data_buf *data, 92 - enum dma_data_direction dir) 108 + enum iser_data_dir iser_dir, 109 + enum dma_data_direction dma_dir) 93 110 { 111 + struct iser_data_buf *data = &iser_task->data[iser_dir]; 94 112 struct ib_device *dev; 95 113 96 114 dev = iser_task->iser_conn->ib_conn.device->ib_device; 97 - ib_dma_unmap_sg(dev, data->sg, data->size, dir); 115 + ib_dma_unmap_sg(dev, data->sg, data->size, dma_dir); 116 + 117 + if (scsi_prot_sg_count(iser_task->sc)) { 118 + struct iser_data_buf *pdata = &iser_task->prot[iser_dir]; 119 + 120 + ib_dma_unmap_sg(dev, pdata->sg, pdata->size, dma_dir); 121 + } 98 122 } 99 123 100 124 static int iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem, ··· 152 130 struct iser_fr_desc *desc; 153 131 struct ib_mr_status mr_status; 154 132 155 - desc = reg->mem_h; 133 + desc = reg->desc; 156 134 if (!desc) 157 135 return; 158 136 ··· 169 147 ib_check_mr_status(desc->rsc.sig_mr, IB_MR_CHECK_SIG_STATUS, 170 148 &mr_status); 171 149 } 172 - iser_reg_desc_put_fr(&iser_task->iser_conn->ib_conn, reg->mem_h); 173 - reg->mem_h = NULL; 150 + iser_reg_desc_put_fr(&iser_task->iser_conn->ib_conn, reg->desc); 151 + reg->desc = NULL; 174 152 } 175 153 176 154 static void iser_set_dif_domain(struct scsi_cmnd *sc, ··· 349 327 return 0; 350 328 } 351 329 352 - static int iser_reg_data_sg(struct iscsi_iser_task *task, 353 - struct iser_data_buf *mem, 354 - struct iser_fr_desc *desc, bool use_dma_key, 355 - struct iser_mem_reg *reg) 356 - { 357 - struct iser_device *device = task->iser_conn->ib_conn.device; 358 - 359 - if (use_dma_key) 360 - return iser_reg_dma(device, mem, reg); 361 - 362 - return iser_fast_reg_mr(task, mem, &desc->rsc, reg); 363 - } 364 - 365 330 int iser_reg_mem_fastreg(struct iscsi_iser_task *task, 366 331 enum iser_data_dir dir, 367 332 bool all_imm) 368 333 { 369 334 struct ib_conn *ib_conn = &task->iser_conn->ib_conn; 335 + struct iser_device *device = ib_conn->device; 370 336 struct iser_data_buf *mem = &task->data[dir]; 371 337 struct iser_mem_reg *reg = &task->rdma_reg[dir]; 372 - struct iser_fr_desc *desc = NULL; 338 + struct iser_fr_desc *desc; 373 339 bool use_dma_key; 374 340 int err; 375 341 376 342 use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) && 377 343 scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL; 344 + if (use_dma_key) 345 + return iser_reg_dma(device, mem, reg); 378 346 379 - if (!use_dma_key) { 380 - desc = iser_reg_desc_get_fr(ib_conn); 381 - reg->mem_h = desc; 382 - } 383 - 347 + desc = iser_reg_desc_get_fr(ib_conn); 384 348 if (scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL) { 385 - err = iser_reg_data_sg(task, mem, desc, use_dma_key, reg); 349 + err = iser_fast_reg_mr(task, mem, &desc->rsc, reg); 386 350 if (unlikely(err)) 387 351 goto err_reg; 388 352 } else { ··· 380 372 desc->sig_protected = true; 381 373 } 382 374 375 + reg->desc = desc; 376 + 383 377 return 0; 384 378 385 379 err_reg: 386 - if (desc) 387 - iser_reg_desc_put_fr(ib_conn, desc); 380 + iser_reg_desc_put_fr(ib_conn, desc); 388 381 389 382 return err; 390 383 }
+1 -2
drivers/infiniband/ulp/iser/iser_verbs.c
··· 32 32 * SOFTWARE. 33 33 */ 34 34 #include <linux/kernel.h> 35 - #include <linux/module.h> 36 35 #include <linux/slab.h> 37 36 #include <linux/delay.h> 38 37 ··· 904 905 enum iser_data_dir cmd_dir, sector_t *sector) 905 906 { 906 907 struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; 907 - struct iser_fr_desc *desc = reg->mem_h; 908 + struct iser_fr_desc *desc = reg->desc; 908 909 unsigned long sector_size = iser_task->sc->device->sector_size; 909 910 struct ib_mr_status mr_status; 910 911 int ret;
-1
drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c
··· 50 50 * netdev functionality. 51 51 */ 52 52 53 - #include <linux/module.h> 54 53 #include <linux/if_vlan.h> 55 54 #include <linux/crc32.h> 56 55
+1 -2
drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
··· 156 156 static ssize_t add_path_show(struct device *dev, 157 157 struct device_attribute *attr, char *page) 158 158 { 159 - return sysfs_emit( 160 - page, 159 + return sysfs_emit(page, 161 160 "Usage: echo [<source addr>@]<destination addr> > %s\n\n*addr ::= [ ip:<ipv4|ipv6> | gid:<gid> ]\n", 162 161 attr->attr.name); 163 162 }
+23 -19
drivers/infiniband/ulp/rtrs/rtrs-clt.c
··· 297 297 return changed; 298 298 } 299 299 300 + static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path); 300 301 static void rtrs_rdma_error_recovery(struct rtrs_clt_con *con) 301 302 { 302 303 struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); ··· 305 304 if (rtrs_clt_change_state_from_to(clt_path, 306 305 RTRS_CLT_CONNECTED, 307 306 RTRS_CLT_RECONNECTING)) { 308 - struct rtrs_clt_sess *clt = clt_path->clt; 309 - unsigned int delay_ms; 310 - 311 - /* 312 - * Normal scenario, reconnect if we were successfully connected 313 - */ 314 - delay_ms = clt->reconnect_delay_sec * 1000; 315 - queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 316 - msecs_to_jiffies(delay_ms + 317 - prandom_u32() % RTRS_RECONNECT_SEED)); 307 + queue_work(rtrs_wq, &clt_path->err_recovery_work); 318 308 } else { 319 309 /* 320 310 * Error can happen just on establishing new connection, ··· 909 917 { 910 918 struct list_head *skip, *tmp; 911 919 /* 912 - * The skip_list is used only for the MIN_INFLIGHT policy. 920 + * The skip_list is used only for the MIN_INFLIGHT and MIN_LATENCY policies. 913 921 * We need to remove paths from it, so that next IO can insert 914 922 * paths (->mp_skip_entry) into a skip_list again. 915 923 */ ··· 1503 1511 static void rtrs_clt_reconnect_work(struct work_struct *work); 1504 1512 static void rtrs_clt_close_work(struct work_struct *work); 1505 1513 1514 + static void rtrs_clt_err_recovery_work(struct work_struct *work) 1515 + { 1516 + struct rtrs_clt_path *clt_path; 1517 + struct rtrs_clt_sess *clt; 1518 + int delay_ms; 1519 + 1520 + clt_path = container_of(work, struct rtrs_clt_path, err_recovery_work); 1521 + clt = clt_path->clt; 1522 + delay_ms = clt->reconnect_delay_sec * 1000; 1523 + rtrs_clt_stop_and_destroy_conns(clt_path); 1524 + queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 1525 + msecs_to_jiffies(delay_ms + 1526 + prandom_u32() % 1527 + RTRS_RECONNECT_SEED)); 1528 + } 1529 + 1506 1530 static struct rtrs_clt_path *alloc_path(struct rtrs_clt_sess *clt, 1507 1531 const struct rtrs_addr *path, 1508 1532 size_t con_num, u32 nr_poll_queues) ··· 1570 1562 clt_path->state = RTRS_CLT_CONNECTING; 1571 1563 atomic_set(&clt_path->connected_cnt, 0); 1572 1564 INIT_WORK(&clt_path->close_work, rtrs_clt_close_work); 1565 + INIT_WORK(&clt_path->err_recovery_work, rtrs_clt_err_recovery_work); 1573 1566 INIT_DELAYED_WORK(&clt_path->reconnect_dwork, rtrs_clt_reconnect_work); 1574 1567 rtrs_clt_init_hb(clt_path); 1575 1568 ··· 2335 2326 2336 2327 clt_path = container_of(work, struct rtrs_clt_path, close_work); 2337 2328 2329 + cancel_work_sync(&clt_path->err_recovery_work); 2338 2330 cancel_delayed_work_sync(&clt_path->reconnect_dwork); 2339 2331 rtrs_clt_stop_and_destroy_conns(clt_path); 2340 2332 rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CLOSED, NULL); ··· 2648 2638 { 2649 2639 struct rtrs_clt_path *clt_path; 2650 2640 struct rtrs_clt_sess *clt; 2651 - unsigned int delay_ms; 2652 2641 int err; 2653 2642 2654 2643 clt_path = container_of(to_delayed_work(work), struct rtrs_clt_path, ··· 2664 2655 } 2665 2656 clt_path->reconnect_attempts++; 2666 2657 2667 - /* Stop everything */ 2668 - rtrs_clt_stop_and_destroy_conns(clt_path); 2669 2658 msleep(RTRS_RECONNECT_BACKOFF); 2670 2659 if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING, NULL)) { 2671 2660 err = init_path(clt_path); ··· 2676 2669 reconnect_again: 2677 2670 if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_RECONNECTING, NULL)) { 2678 2671 clt_path->stats->reconnects.fail_cnt++; 2679 - delay_ms = clt->reconnect_delay_sec * 1000; 2680 - queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 2681 - msecs_to_jiffies(delay_ms + 2682 - prandom_u32() % 2683 - RTRS_RECONNECT_SEED)); 2672 + queue_work(rtrs_wq, &clt_path->err_recovery_work); 2684 2673 } 2685 2674 } 2686 2675 ··· 2911 2908 &old_state); 2912 2909 if (changed) { 2913 2910 clt_path->reconnect_attempts = 0; 2911 + rtrs_clt_stop_and_destroy_conns(clt_path); 2914 2912 queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 0); 2915 2913 } 2916 2914 if (changed || old_state == RTRS_CLT_RECONNECTING) {
+1
drivers/infiniband/ulp/rtrs/rtrs-clt.h
··· 134 134 struct rtrs_clt_io_req *reqs; 135 135 struct delayed_work reconnect_dwork; 136 136 struct work_struct close_work; 137 + struct work_struct err_recovery_work; 137 138 unsigned int reconnect_attempts; 138 139 bool established; 139 140 struct rtrs_rbuf *rbufs;
-1
drivers/infiniband/ulp/rtrs/rtrs.c
··· 479 479 */ 480 480 int sockaddr_to_str(const struct sockaddr *addr, char *buf, size_t len) 481 481 { 482 - 483 482 switch (addr->sa_family) { 484 483 case AF_IB: 485 484 return scnprintf(buf, len, "gid:%pI6",
+10 -1
drivers/infiniband/ulp/srp/ib_srp.h
··· 92 92 }; 93 93 94 94 /* 95 + * RDMA adapter in the initiator system. 96 + * 97 + * @dev_list: List of RDMA ports associated with this RDMA adapter (srp_host). 95 98 * @mr_page_mask: HCA memory registration page mask. 96 99 * @mr_page_size: HCA memory registration page size. 97 100 * @mr_max_size: Maximum size in bytes of a single FR registration request. ··· 112 109 bool use_fast_reg; 113 110 }; 114 111 112 + /* 113 + * One port of an RDMA adapter in the initiator system. 114 + * 115 + * @target_list: List of connected target ports (struct srp_target_port). 116 + * @target_lock: Protects @target_list. 117 + */ 115 118 struct srp_host { 116 119 struct srp_device *srp_dev; 117 120 u8 port; ··· 192 183 }; 193 184 194 185 /** 195 - * struct srp_target_port 186 + * struct srp_target_port - RDMA port in the SRP target system 196 187 * @comp_vector: Completion vector used by the first RDMA channel created for 197 188 * this target port. 198 189 */