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() ...
Unified · Split
| @@ -37,7 +37,6 @@ · 36 unmodified lines | |||
| 37 | #include <linux/inetdevice.h> | 37 | #include <linux/inetdevice.h> |
| 38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
| 39 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
| 40 | #include <linux/module.h> | ||
| 41 | #include <net/arp.h> | 40 | #include <net/arp.h> |
| 42 | #include <net/neighbour.h> | 41 | #include <net/neighbour.h> |
| 43 | #include <net/route.h> | 42 | #include <net/route.h> |
| @@ -34,7 +34,6 @@ · 33 unmodified lines | |||
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #include <linux/if_vlan.h> | 36 | #include <linux/if_vlan.h> |
| 37 | #include <linux/module.h> | ||
| 38 | #include <linux/errno.h> | 37 | #include <linux/errno.h> |
| 39 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
| 40 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
| @@ -2642,7 +2642,7 @@ int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout) · 2641 unmodified lines | |||
| 2642 | { | 2642 | { |
| 2643 | struct rdma_id_private *id_priv; | 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 | return -EINVAL; | 2646 | return -EINVAL; |
| 2647 | 2647 | ||
| 2648 | id_priv = container_of(id, struct rdma_id_private, id); | 2648 | id_priv = container_of(id, struct rdma_id_private, id); |
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | * SOFTWARE. | 30 | * SOFTWARE. |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/configfs.h> | 33 | #include <linux/configfs.h> |
| 35 | #include <rdma/ib_verbs.h> | 34 | #include <rdma/ib_verbs.h> |
| 36 | #include <rdma/rdma_cm.h> | 35 | #include <rdma/rdma_cm.h> |
| @@ -2,7 +2,6 @@ · 1 unmodified line | |||
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2015 HGST, a Western Digital Company. | 3 | * Copyright (c) 2015 HGST, a Western Digital Company. |
| 4 | */ | 4 | */ |
| 5 | #include <linux/module.h> | ||
| 6 | #include <linux/err.h> | 5 | #include <linux/err.h> |
| 7 | #include <linux/slab.h> | 6 | #include <linux/slab.h> |
| 8 | #include <rdma/ib_verbs.h> | 7 | #include <rdma/ib_verbs.h> |
| @@ -33,7 +33,6 @@ · 32 unmodified lines | |||
| 33 | #ifndef _IWPM_UTIL_H | 33 | #ifndef _IWPM_UTIL_H |
| 34 | #define _IWPM_UTIL_H | 34 | #define _IWPM_UTIL_H |
| 35 | 35 | ||
| 36 | #include <linux/module.h> | ||
| 37 | #include <linux/io.h> | 36 | #include <linux/io.h> |
| 38 | #include <linux/in.h> | 37 | #include <linux/in.h> |
| 39 | #include <linux/in6.h> | 38 | #include <linux/in6.h> |
| @@ -1951,9 +1951,10 @@ static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[], · 1950 unmodified lines | |||
| 1951 | u32 port) | 1951 | u32 port) |
| 1952 | { | 1952 | { |
| 1953 | struct rdma_hw_stats *stats; | 1953 | struct rdma_hw_stats *stats; |
| 1954 | int rem, i, index, ret = 0; | ||
| 1955 | struct nlattr *entry_attr; | 1954 | struct nlattr *entry_attr; |
| 1956 | unsigned long *target; | 1955 | unsigned long *target; |
| 1956 | int rem, i, ret = 0; | ||
| 1957 | u32 index; | ||
| 1957 | 1958 | ||
| 1958 | stats = ib_get_hw_stats_port(device, port); | 1959 | stats = ib_get_hw_stats_port(device, port); |
| 1959 | if (!stats) | 1960 | if (!stats) |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | * SOFTWARE. | 32 | * SOFTWARE. |
| 33 | */ | 33 | */ |
| 34 | 34 | ||
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| 37 | #include <linux/err.h> | 36 | #include <linux/err.h> |
| 38 | #include <linux/random.h> | 37 | #include <linux/random.h> |
| @@ -268,9 +268,6 @@ struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags, · 267 unmodified lines | |||
| 268 | return ERR_PTR(-ENOMEM); | 268 | return ERR_PTR(-ENOMEM); |
| 269 | 269 | ||
| 270 | pd->device = device; | 270 | pd->device = device; |
| 271 | pd->uobject = NULL; | ||
| 272 | pd->__internal_mr = NULL; | ||
| 273 | atomic_set(&pd->usecnt, 0); | ||
| 274 | pd->flags = flags; | 271 | pd->flags = flags; |
| 275 | 272 | ||
| 276 | rdma_restrack_new(&pd->res, RDMA_RESTRACK_PD); | 273 | rdma_restrack_new(&pd->res, RDMA_RESTRACK_PD); |
| @@ -341,11 +338,6 @@ int ib_dealloc_pd_user(struct ib_pd *pd, struct ib_udata *udata) · 64 unmodified lines | |||
| 341 | pd->__internal_mr = NULL; | 338 | pd->__internal_mr = NULL; |
| 342 | } | 339 | } |
| 343 | 340 | ||
| 344 | /* uverbs manipulates usecnt with proper locking, while the kabi | ||
| 345 | * requires the caller to guarantee we can't race here. | ||
| 346 | */ | ||
| 347 | WARN_ON(atomic_read(&pd->usecnt)); | ||
| 348 | |||
| 349 | ret = pd->device->ops.dealloc_pd(pd, udata); | 341 | ret = pd->device->ops.dealloc_pd(pd, udata); |
| 350 | if (ret) | 342 | if (ret) |
| 351 | return ret; | 343 | return ret; |
| @@ -2153,6 +2145,7 @@ struct ib_mr *ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, · 1801 unmodified lines | |||
| 2153 | return mr; | 2145 | return mr; |
| 2154 | 2146 | ||
| 2155 | mr->device = pd->device; | 2147 | mr->device = pd->device; |
| 2148 | mr->type = IB_MR_TYPE_USER; | ||
| 2156 | mr->pd = pd; | 2149 | mr->pd = pd; |
| 2157 | mr->dm = NULL; | 2150 | mr->dm = NULL; |
| 2158 | atomic_inc(&pd->usecnt); | 2151 | atomic_inc(&pd->usecnt); |
| @@ -5,7 +5,6 @@ · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | #include <linux/topology.h> | 6 | #include <linux/topology.h> |
| 7 | #include <linux/cpumask.h> | 7 | #include <linux/cpumask.h> |
| 8 | #include <linux/module.h> | ||
| 9 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
| 10 | #include <linux/numa.h> | 9 | #include <linux/numa.h> |
| 11 | 10 | ||
| @@ -667,7 +666,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) · 655 unmodified lines | |||
| 667 | * engines, use the same CPU cores as general/control | 666 | * engines, use the same CPU cores as general/control |
| 668 | * context. | 667 | * context. |
| 669 | */ | 668 | */ |
| 670 | if (cpumask_weight(&entry->def_intr.mask) == 0) | 669 | if (cpumask_empty(&entry->def_intr.mask)) |
| 671 | cpumask_copy(&entry->def_intr.mask, | 670 | cpumask_copy(&entry->def_intr.mask, |
| 672 | &entry->general_intr_mask); | 671 | &entry->general_intr_mask); |
| 673 | } | 672 | } |
| @@ -687,7 +686,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) · 13 unmodified lines | |||
| 687 | * vectors, use the same CPU core as the general/control | 686 | * vectors, use the same CPU core as the general/control |
| 688 | * context. | 687 | * context. |
| 689 | */ | 688 | */ |
| 690 | if (cpumask_weight(&entry->comp_vect_mask) == 0) | 689 | if (cpumask_empty(&entry->comp_vect_mask)) |
| 691 | cpumask_copy(&entry->comp_vect_mask, | 690 | cpumask_copy(&entry->comp_vect_mask, |
| 692 | &entry->general_intr_mask); | 691 | &entry->general_intr_mask); |
| 693 | } | 692 | } |
| @@ -7,7 +7,6 @@ · 6 unmodified lines | |||
| 7 | #include <linux/seq_file.h> | 7 | #include <linux/seq_file.h> |
| 8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
| 9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
| 10 | #include <linux/module.h> | ||
| 11 | #include <linux/string.h> | 10 | #include <linux/string.h> |
| 12 | #include <linux/types.h> | 11 | #include <linux/types.h> |
| 13 | #include <linux/ratelimit.h> | 12 | #include <linux/ratelimit.h> |
| @@ -4,7 +4,6 @@ · 3 unmodified lines | |||
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include <linux/cdev.h> | 6 | #include <linux/cdev.h> |
| 7 | #include <linux/module.h> | ||
| 8 | #include <linux/device.h> | 7 | #include <linux/device.h> |
| 9 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
| 10 | 9 | ||
| @@ -6,7 +6,6 @@ · 5 unmodified lines | |||
| 6 | #include <linux/debugfs.h> | 6 | #include <linux/debugfs.h> |
| 7 | #include <linux/seq_file.h> | 7 | #include <linux/seq_file.h> |
| 8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
| 9 | #include <linux/module.h> | ||
| 10 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 11 | #include <linux/bitmap.h> | 10 | #include <linux/bitmap.h> |
| 12 | 11 | ||
| @@ -5,7 +5,6 @@ · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | #include <linux/firmware.h> | 6 | #include <linux/firmware.h> |
| 7 | #include <linux/mutex.h> | 7 | #include <linux/mutex.h> |
| 8 | #include <linux/module.h> | ||
| 9 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
| 10 | #include <linux/crc32.h> | 9 | #include <linux/crc32.h> |
| 11 | 10 | ||
| @@ -1397,8 +1397,7 @@ static int query_port(struct rvt_dev_info *rdi, u32 port_num, · 1396 unmodified lines | |||
| 1397 | 4096 : hfi1_max_mtu), IB_MTU_4096); | 1397 | 4096 : hfi1_max_mtu), IB_MTU_4096); |
| 1398 | props->active_mtu = !valid_ib_mtu(ppd->ibmtu) ? props->max_mtu : | 1398 | props->active_mtu = !valid_ib_mtu(ppd->ibmtu) ? props->max_mtu : |
| 1399 | mtu_to_enum(ppd->ibmtu, IB_MTU_4096); | 1399 | mtu_to_enum(ppd->ibmtu, IB_MTU_4096); |
| 1400 | props->phys_mtu = HFI1_CAP_IS_KSET(AIP) ? hfi1_max_mtu : | 1400 | props->phys_mtu = hfi1_max_mtu; |
| 1401 | ib_mtu_enum_to_int(props->max_mtu); | ||
| 1402 | 1401 | ||
| 1403 | return 0; | 1402 | return 0; |
| 1404 | } | 1403 | } |
| @@ -38,45 +38,36 @@ · 37 unmodified lines | |||
| 38 | #define CMD_POLL_TOKEN 0xffff | 38 | #define CMD_POLL_TOKEN 0xffff |
| 39 | #define CMD_MAX_NUM 32 | 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, | 41 | static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, |
| 42 | u64 out_param, u32 in_modifier, | 42 | struct hns_roce_mbox_msg *mbox_msg) |
| 43 | u8 op_modifier, u16 op, u16 token, | ||
| 44 | int event) | ||
| 45 | { | 43 | { |
| 46 | return hr_dev->hw->post_mbox(hr_dev, in_param, out_param, in_modifier, | 44 | return hr_dev->hw->post_mbox(hr_dev, mbox_msg); |
| 47 | op_modifier, op, token, event); | ||
| 48 | } | 45 | } |
| 49 | 46 | ||
| 50 | /* this should be called with "poll_sem" */ | 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, | 48 | static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, |
| 52 | u64 out_param, unsigned long in_modifier, | 49 | struct hns_roce_mbox_msg *mbox_msg) |
| 53 | u8 op_modifier, u16 op, | ||
| 54 | unsigned int timeout) | ||
| 55 | { | 50 | { |
| 56 | int ret; | 51 | int ret; |
| 57 | 52 | ||
| 58 | ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param, | 53 | ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg); |
| 59 | in_modifier, op_modifier, op, | ||
| 60 | CMD_POLL_TOKEN, 0); | ||
| 61 | if (ret) { | 54 | if (ret) { |
| 62 | dev_err_ratelimited(hr_dev->dev, | 55 | dev_err_ratelimited(hr_dev->dev, |
| 63 | "failed to post mailbox 0x%x in poll mode, ret = %d.\n", | 56 | "failed to post mailbox 0x%x in poll mode, ret = %d.\n", |
| 64 | op, ret); | 57 | mbox_msg->cmd, ret); |
| 65 | return ret; | 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, | 64 | static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, |
| 72 | u64 out_param, unsigned long in_modifier, | 65 | struct hns_roce_mbox_msg *mbox_msg) |
| 73 | u8 op_modifier, u16 op, unsigned int timeout) | ||
| 74 | { | 66 | { |
| 75 | int ret; | 67 | int ret; |
| 76 | 68 | ||
| 77 | down(&hr_dev->cmd.poll_sem); | 69 | down(&hr_dev->cmd.poll_sem); |
| 78 | ret = __hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param, in_modifier, | 70 | ret = __hns_roce_cmd_mbox_poll(hr_dev, mbox_msg); |
| 79 | op_modifier, op, timeout); | ||
| 80 | up(&hr_dev->cmd.poll_sem); | 71 | up(&hr_dev->cmd.poll_sem); |
| 81 | 72 | ||
| 82 | return ret; | 73 | return ret; |
| @@ -100,10 +91,8 @@ void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status, · 17 unmodified lines | |||
| 100 | complete(&context->done); | 91 | complete(&context->done); |
| 101 | } | 92 | } |
| 102 | 93 | ||
| 103 | static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, | 94 | static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, |
| 104 | u64 out_param, unsigned long in_modifier, | 95 | struct hns_roce_mbox_msg *mbox_msg) |
| 105 | u8 op_modifier, u16 op, | ||
| 106 | unsigned int timeout) | ||
| 107 | { | 96 | { |
| 108 | struct hns_roce_cmdq *cmd = &hr_dev->cmd; | 97 | struct hns_roce_cmdq *cmd = &hr_dev->cmd; |
| 109 | struct hns_roce_cmd_context *context; | 98 | struct hns_roce_cmd_context *context; |
| @@ -124,20 +113,19 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, · 14 unmodified lines | |||
| 124 | 113 | ||
| 125 | reinit_completion(&context->done); | 114 | reinit_completion(&context->done); |
| 126 | 115 | ||
| 127 | ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param, | 116 | mbox_msg->token = context->token; |
| 128 | in_modifier, op_modifier, op, | 117 | ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg); |
| 129 | context->token, 1); | ||
| 130 | if (ret) { | 118 | if (ret) { |
| 131 | dev_err_ratelimited(dev, | 119 | dev_err_ratelimited(dev, |
| 132 | "failed to post mailbox 0x%x in event mode, ret = %d.\n", | 120 | "failed to post mailbox 0x%x in event mode, ret = %d.\n", |
| 133 | op, ret); | 121 | mbox_msg->cmd, ret); |
| 134 | goto out; | 122 | goto out; |
| 135 | } | 123 | } |
| 136 | 124 | ||
| 137 | if (!wait_for_completion_timeout(&context->done, | 125 | if (!wait_for_completion_timeout(&context->done, |
| 138 | msecs_to_jiffies(timeout))) { | 126 | msecs_to_jiffies(HNS_ROCE_CMD_TIMEOUT_MSECS))) { |
| 139 | dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x timeout.\n", | 127 | dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x timeout.\n", |
| 140 | context->token, op); | 128 | context->token, mbox_msg->cmd); |
| 141 | ret = -EBUSY; | 129 | ret = -EBUSY; |
| 142 | goto out; | 130 | goto out; |
| 143 | } | 131 | } |
| @@ -145,45 +133,50 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, · 1 unmodified line | |||
| 145 | ret = context->result; | 133 | ret = context->result; |
| 146 | if (ret) | 134 | if (ret) |
| 147 | dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x error %d.\n", | 135 | dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x error %d.\n", |
| 148 | context->token, op, ret); | 136 | context->token, mbox_msg->cmd, ret); |
| 149 | 137 | ||
| 150 | out: | 138 | out: |
| 151 | context->busy = 0; | 139 | context->busy = 0; |
| 152 | return ret; | 140 | return ret; |
| 153 | } | 141 | } |
| 154 | 142 | ||
| 155 | static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, | 143 | static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, |
| 156 | u64 out_param, unsigned long in_modifier, | 144 | struct hns_roce_mbox_msg *mbox_msg) |
| 157 | u8 op_modifier, u16 op, unsigned int timeout) | ||
| 158 | { | 145 | { |
| 159 | int ret; | 146 | int ret; |
| 160 | 147 | ||
| 161 | down(&hr_dev->cmd.event_sem); | 148 | down(&hr_dev->cmd.event_sem); |
| 162 | ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, in_modifier, | 149 | ret = __hns_roce_cmd_mbox_wait(hr_dev, mbox_msg); |
| 163 | op_modifier, op, timeout); | ||
| 164 | up(&hr_dev->cmd.event_sem); | 150 | up(&hr_dev->cmd.event_sem); |
| 165 | 151 | ||
| 166 | return ret; | 152 | return ret; |
| 167 | } | 153 | } |
| 168 | 154 | ||
| 169 | int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, | 155 | int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, |
| 170 | unsigned long in_modifier, u8 op_modifier, u16 op, | 156 | u8 cmd, unsigned long tag) |
| 171 | unsigned int timeout) | ||
| 172 | { | 157 | { |
| 158 | struct hns_roce_mbox_msg mbox_msg = {}; | ||
| 173 | bool is_busy; | 159 | bool is_busy; |
| 174 | 160 | ||
| 175 | if (hr_dev->hw->chk_mbox_avail) | 161 | if (hr_dev->hw->chk_mbox_avail) |
| 176 | if (!hr_dev->hw->chk_mbox_avail(hr_dev, &is_busy)) | 162 | if (!hr_dev->hw->chk_mbox_avail(hr_dev, &is_busy)) |
| 177 | return is_busy ? -EBUSY : 0; | 163 | return is_busy ? -EBUSY : 0; |
| 178 | 164 | ||
| 179 | if (hr_dev->cmd.use_events) | 165 | mbox_msg.in_param = in_param; |
| 180 | return hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, | 166 | mbox_msg.out_param = out_param; |
| 181 | in_modifier, op_modifier, op, | 167 | mbox_msg.cmd = cmd; |
| 182 | timeout); | 168 | mbox_msg.tag = tag; |
| 183 | else | 169 | |
| 184 | return hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param, | 170 | if (hr_dev->cmd.use_events) { |
| 185 | in_modifier, op_modifier, op, | 171 | mbox_msg.event_en = 1; |
| 186 | timeout); | 172 | |
| 173 | return hns_roce_cmd_mbox_wait(hr_dev, &mbox_msg); | ||
| 174 | } else { | ||
| 175 | mbox_msg.event_en = 0; | ||
| 176 | mbox_msg.token = CMD_POLL_TOKEN; | ||
| 177 | |||
| 178 | return hns_roce_cmd_mbox_poll(hr_dev, &mbox_msg); | ||
| 179 | } | ||
| 187 | } | 180 | } |
| 188 | 181 | ||
| 189 | int hns_roce_cmd_init(struct hns_roce_dev *hr_dev) | 182 | int hns_roce_cmd_init(struct hns_roce_dev *hr_dev) |
| @@ -269,3 +262,15 @@ void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev, · 79 unmodified lines | |||
| 269 | dma_pool_free(hr_dev->cmd.pool, mailbox->buf, mailbox->dma); | 262 | dma_pool_free(hr_dev->cmd.pool, mailbox->buf, mailbox->dma); |
| 270 | kfree(mailbox); | 263 | kfree(mailbox); |
| 271 | } | 264 | } |
| 265 | |||
| 266 | int hns_roce_create_hw_ctx(struct hns_roce_dev *dev, | ||
| 267 | struct hns_roce_cmd_mailbox *mailbox, | ||
| 268 | u8 cmd, unsigned long idx) | ||
| 269 | { | ||
| 270 | return hns_roce_cmd_mbox(dev, mailbox->dma, 0, cmd, idx); | ||
| 271 | } | ||
| 272 | |||
| 273 | int hns_roce_destroy_hw_ctx(struct hns_roce_dev *dev, u8 cmd, unsigned long idx) | ||
| 274 | { | ||
| 275 | return hns_roce_cmd_mbox(dev, 0, 0, cmd, idx); | ||
| 276 | } | ||
| @@ -140,12 +140,16 @@ enum { · 139 unmodified lines | |||
| 140 | }; | 140 | }; |
| 141 | 141 | ||
| 142 | int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, | 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, | 143 | u8 cmd, unsigned long tag); |
| 144 | unsigned int timeout); | ||
| 145 | 144 | ||
| 146 | struct hns_roce_cmd_mailbox * | 145 | struct hns_roce_cmd_mailbox * |
| 147 | hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev); | 146 | hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev); |
| 148 | void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev, | 147 | void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev, |
| 149 | struct hns_roce_cmd_mailbox *mailbox); | 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 | #endif /* _HNS_ROCE_CMD_H */ | 155 | #endif /* _HNS_ROCE_CMD_H */ |
| @@ -100,12 +100,39 @@ static void free_cqn(struct hns_roce_dev *hr_dev, unsigned long cqn) · 99 unmodified lines | |||
| 100 | mutex_unlock(&cq_table->bank_mutex); | 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 | static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) | 131 | static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) |
| 104 | { | 132 | { |
| 105 | struct hns_roce_cq_table *cq_table = &hr_dev->cq_table; | 133 | struct hns_roce_cq_table *cq_table = &hr_dev->cq_table; |
| 106 | struct ib_device *ibdev = &hr_dev->ib_dev; | 134 | struct ib_device *ibdev = &hr_dev->ib_dev; |
| 107 | struct hns_roce_cmd_mailbox *mailbox; | 135 | u64 mtts[MTT_MIN_COUNT] = {}; |
| 108 | u64 mtts[MTT_MIN_COUNT] = { 0 }; | ||
| 109 | dma_addr_t dma_handle; | 136 | dma_addr_t dma_handle; |
| 110 | int ret; | 137 | int ret; |
| 111 | 138 | ||
| @@ -121,7 +148,7 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) · 9 unmodified lines | |||
| 121 | if (ret) { | 148 | if (ret) { |
| 122 | ibdev_err(ibdev, "failed to get CQ(0x%lx) context, ret = %d.\n", | 149 | ibdev_err(ibdev, "failed to get CQ(0x%lx) context, ret = %d.\n", |
| 123 | hr_cq->cqn, ret); | 150 | hr_cq->cqn, ret); |
| 124 | goto err_out; | 151 | return ret; |
| 125 | } | 152 | } |
| 126 | 153 | ||
| 127 | ret = xa_err(xa_store(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL)); | 154 | ret = xa_err(xa_store(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL)); |
| @@ -130,41 +157,17 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) · 2 unmodified lines | |||
| 130 | goto err_put; | 157 | goto err_put; |
| 131 | } | 158 | } |
| 132 | 159 | ||
| 133 | /* Allocate mailbox memory */ | 160 | ret = hns_roce_create_cqc(hr_dev, hr_cq, mtts, dma_handle); |
| 134 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); | 161 | if (ret) |
| 135 | if (IS_ERR(mailbox)) { | ||
| 136 | ret = PTR_ERR(mailbox); | ||
| 137 | goto err_xa; | ||
| 138 | } | ||
| 139 | |||
| 140 | hr_dev->hw->write_cqc(hr_dev, hr_cq, mailbox->buf, mtts, dma_handle); | ||
| 141 | |||
| 142 | /* Send mailbox to hw */ | ||
| 143 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, 0, | ||
| 144 | HNS_ROCE_CMD_CREATE_CQC, HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 145 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | ||
| 146 | if (ret) { | ||
| 147 | ibdev_err(ibdev, | ||
| 148 | "failed to send create cmd for CQ(0x%lx), ret = %d.\n", | ||
| 149 | hr_cq->cqn, ret); | ||
| 150 | goto err_xa; | 162 | goto err_xa; |
| 151 | } | ||
| 152 | |||
| 153 | hr_cq->cons_index = 0; | ||
| 154 | hr_cq->arm_sn = 1; | ||
| 155 | |||
| 156 | refcount_set(&hr_cq->refcount, 1); | ||
| 157 | init_completion(&hr_cq->free); | ||
| 158 | 163 | ||
| 159 | return 0; | 164 | return 0; |
| 160 | 165 | ||
| 161 | err_xa: | 166 | err_xa: |
| 162 | xa_erase(&cq_table->array, hr_cq->cqn); | 167 | xa_erase(&cq_table->array, hr_cq->cqn); |
| 163 | |||
| 164 | err_put: | 168 | err_put: |
| 165 | hns_roce_table_put(hr_dev, &cq_table->table, hr_cq->cqn); | 169 | hns_roce_table_put(hr_dev, &cq_table->table, hr_cq->cqn); |
| 166 | 170 | ||
| 167 | err_out: | ||
| 168 | return ret; | 171 | return ret; |
| 169 | } | 172 | } |
| 170 | 173 | ||
| @@ -174,9 +177,8 @@ static void free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) · 3 unmodified lines | |||
| 174 | struct device *dev = hr_dev->dev; | 177 | struct device *dev = hr_dev->dev; |
| 175 | int ret; | 178 | int ret; |
| 176 | 179 | ||
| 177 | ret = hns_roce_cmd_mbox(hr_dev, 0, 0, hr_cq->cqn, 1, | 180 | ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_CQC, |
| 178 | HNS_ROCE_CMD_DESTROY_CQC, | 181 | hr_cq->cqn); |
| 179 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 180 | if (ret) | 182 | if (ret) |
| 181 | dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret, | 183 | dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret, |
| 182 | hr_cq->cqn); | 184 | hr_cq->cqn); |
| @@ -413,6 +415,11 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr, · 230 unmodified lines | |||
| 413 | goto err_cqc; | 415 | goto err_cqc; |
| 414 | } | 416 | } |
| 415 | 417 | ||
| 418 | hr_cq->cons_index = 0; | ||
| 419 | hr_cq->arm_sn = 1; | ||
| 420 | refcount_set(&hr_cq->refcount, 1); | ||
| 421 | init_completion(&hr_cq->free); | ||
| 422 | |||
| 416 | return 0; | 423 | return 0; |
| 417 | 424 | ||
| 418 | err_cqc: | 425 | err_cqc: |
| @@ -561,6 +561,15 @@ struct hns_roce_cmd_mailbox { · 560 unmodified lines | |||
| 561 | dma_addr_t dma; | 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 | struct hns_roce_dev; | 573 | struct hns_roce_dev; |
| 565 | 574 | ||
| 566 | struct hns_roce_rinl_sge { | 575 | struct hns_roce_rinl_sge { |
| @@ -624,6 +633,7 @@ struct hns_roce_qp { · 57 unmodified lines | |||
| 624 | u32 next_sge; | 633 | u32 next_sge; |
| 625 | enum ib_mtu path_mtu; | 634 | enum ib_mtu path_mtu; |
| 626 | u32 max_inline_data; | 635 | u32 max_inline_data; |
| 636 | u8 free_mr_en; | ||
| 627 | 637 | ||
| 628 | /* 0: flush needed, 1: unneeded */ | 638 | /* 0: flush needed, 1: unneeded */ |
| 629 | unsigned long flush_flag; | 639 | unsigned long flush_flag; |
| @@ -851,11 +861,9 @@ struct hns_roce_hw { · 221 unmodified lines | |||
| 851 | int (*hw_profile)(struct hns_roce_dev *hr_dev); | 861 | int (*hw_profile)(struct hns_roce_dev *hr_dev); |
| 852 | int (*hw_init)(struct hns_roce_dev *hr_dev); | 862 | int (*hw_init)(struct hns_roce_dev *hr_dev); |
| 853 | void (*hw_exit)(struct hns_roce_dev *hr_dev); | 863 | void (*hw_exit)(struct hns_roce_dev *hr_dev); |
| 854 | int (*post_mbox)(struct hns_roce_dev *hr_dev, u64 in_param, | 864 | int (*post_mbox)(struct hns_roce_dev *hr_dev, |
| 855 | u64 out_param, u32 in_modifier, u8 op_modifier, u16 op, | 865 | struct hns_roce_mbox_msg *mbox_msg); |
| 856 | u16 token, int event); | 866 | int (*poll_mbox_done)(struct hns_roce_dev *hr_dev); |
| 857 | int (*poll_mbox_done)(struct hns_roce_dev *hr_dev, | ||
| 858 | unsigned int timeout); | ||
| 859 | bool (*chk_mbox_avail)(struct hns_roce_dev *hr_dev, bool *is_busy); | 867 | bool (*chk_mbox_avail)(struct hns_roce_dev *hr_dev, bool *is_busy); |
| 860 | int (*set_gid)(struct hns_roce_dev *hr_dev, int gid_index, | 868 | int (*set_gid)(struct hns_roce_dev *hr_dev, int gid_index, |
| 861 | const union ib_gid *gid, const struct ib_gid_attr *attr); | 869 | const union ib_gid *gid, const struct ib_gid_attr *attr); |
| @@ -873,15 +881,16 @@ struct hns_roce_hw { · 11 unmodified lines | |||
| 873 | struct hns_roce_cq *hr_cq, void *mb_buf, u64 *mtts, | 881 | struct hns_roce_cq *hr_cq, void *mb_buf, u64 *mtts, |
| 874 | dma_addr_t dma_handle); | 882 | dma_addr_t dma_handle); |
| 875 | int (*set_hem)(struct hns_roce_dev *hr_dev, | 883 | int (*set_hem)(struct hns_roce_dev *hr_dev, |
| 876 | struct hns_roce_hem_table *table, int obj, int step_idx); | 884 | struct hns_roce_hem_table *table, int obj, u32 step_idx); |
| 877 | int (*clear_hem)(struct hns_roce_dev *hr_dev, | 885 | int (*clear_hem)(struct hns_roce_dev *hr_dev, |
| 878 | struct hns_roce_hem_table *table, int obj, | 886 | struct hns_roce_hem_table *table, int obj, |
| 879 | int step_idx); | 887 | u32 step_idx); |
| 880 | int (*modify_qp)(struct ib_qp *ibqp, const struct ib_qp_attr *attr, | 888 | int (*modify_qp)(struct ib_qp *ibqp, const struct ib_qp_attr *attr, |
| 881 | int attr_mask, enum ib_qp_state cur_state, | 889 | int attr_mask, enum ib_qp_state cur_state, |
| 882 | enum ib_qp_state new_state); | 890 | enum ib_qp_state new_state); |
| 883 | int (*qp_flow_control_init)(struct hns_roce_dev *hr_dev, | 891 | int (*qp_flow_control_init)(struct hns_roce_dev *hr_dev, |
| 884 | struct hns_roce_qp *hr_qp); | 892 | struct hns_roce_qp *hr_qp); |
| 893 | void (*dereg_mr)(struct hns_roce_dev *hr_dev); | ||
| 885 | int (*init_eq)(struct hns_roce_dev *hr_dev); | 894 | int (*init_eq)(struct hns_roce_dev *hr_dev); |
| 886 | void (*cleanup_eq)(struct hns_roce_dev *hr_dev); | 895 | void (*cleanup_eq)(struct hns_roce_dev *hr_dev); |
| 887 | int (*write_srqc)(struct hns_roce_srq *srq, void *mb_buf); | 896 | int (*write_srqc)(struct hns_roce_srq *srq, void *mb_buf); |
| @@ -1145,9 +1154,6 @@ struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, · 257 unmodified lines | |||
| 1145 | int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, | 1154 | int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, |
| 1146 | unsigned int *sg_offset); | 1155 | unsigned int *sg_offset); |
| 1147 | int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); | 1156 | int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); |
| 1148 | int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev, | ||
| 1149 | struct hns_roce_cmd_mailbox *mailbox, | ||
| 1150 | unsigned long mpt_index); | ||
| 1151 | unsigned long key_to_hw_index(u32 key); | 1157 | unsigned long key_to_hw_index(u32 key); |
| 1152 | 1158 | ||
| 1153 | int hns_roce_alloc_mw(struct ib_mw *mw, struct ib_udata *udata); | 1159 | int hns_roce_alloc_mw(struct ib_mw *mw, struct ib_udata *udata); |
| @@ -488,7 +488,7 @@ static int set_mhop_hem(struct hns_roce_dev *hr_dev, · 487 unmodified lines | |||
| 488 | struct hns_roce_hem_index *index) | 488 | struct hns_roce_hem_index *index) |
| 489 | { | 489 | { |
| 490 | struct ib_device *ibdev = &hr_dev->ib_dev; | 490 | struct ib_device *ibdev = &hr_dev->ib_dev; |
| 491 | int step_idx; | 491 | u32 step_idx; |
| 492 | int ret = 0; | 492 | int ret = 0; |
| 493 | 493 | ||
| 494 | if (index->inited & HEM_INDEX_L0) { | 494 | if (index->inited & HEM_INDEX_L0) { |
| @@ -618,7 +618,7 @@ static void clear_mhop_hem(struct hns_roce_dev *hr_dev, · 123 unmodified lines | |||
| 618 | struct ib_device *ibdev = &hr_dev->ib_dev; | 618 | struct ib_device *ibdev = &hr_dev->ib_dev; |
| 619 | u32 hop_num = mhop->hop_num; | 619 | u32 hop_num = mhop->hop_num; |
| 620 | u32 chunk_ba_num; | 620 | u32 chunk_ba_num; |
| 621 | int step_idx; | 621 | u32 step_idx; |
| 622 | 622 | ||
| 623 | index->inited = HEM_INDEX_BUF; | 623 | index->inited = HEM_INDEX_BUF; |
| 624 | chunk_ba_num = mhop->bt_chunk_size / BA_BYTE_LEN; | 624 | chunk_ba_num = mhop->bt_chunk_size / BA_BYTE_LEN; |
| @@ -1344,17 +1344,17 @@ static int hns_roce_cmq_send(struct hns_roce_dev *hr_dev, · 1343 unmodified lines | |||
| 1344 | return ret; | 1344 | return ret; |
| 1345 | } | 1345 | } |
| 1346 | 1346 | ||
| 1347 | static int config_hem_ba_to_hw(struct hns_roce_dev *hr_dev, unsigned long obj, | 1347 | static int config_hem_ba_to_hw(struct hns_roce_dev *hr_dev, |
| 1348 | dma_addr_t base_addr, u16 op) | 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 | int ret; | 1351 | int ret; |
| 1352 | 1352 | ||
| 1353 | mbox = hns_roce_alloc_cmd_mailbox(hr_dev); | ||
| 1353 | if (IS_ERR(mbox)) | 1354 | if (IS_ERR(mbox)) |
| 1354 | return PTR_ERR(mbox); | 1355 | return PTR_ERR(mbox); |
| 1355 | 1356 | ||
| 1356 | ret = hns_roce_cmd_mbox(hr_dev, base_addr, mbox->dma, obj, 0, op, | 1357 | ret = hns_roce_cmd_mbox(hr_dev, base_addr, mbox->dma, cmd, tag); |
| 1357 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 1358 | hns_roce_free_cmd_mailbox(hr_dev, mbox); | 1358 | hns_roce_free_cmd_mailbox(hr_dev, mbox); |
| 1359 | return ret; | 1359 | return ret; |
| 1360 | } | 1360 | } |
| @@ -2664,6 +2664,194 @@ static void free_dip_list(struct hns_roce_dev *hr_dev) · 1303 unmodified lines | |||
| 2664 | spin_unlock_irqrestore(&hr_dev->dip_list_lock, flags); | 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 | static int get_hem_table(struct hns_roce_dev *hr_dev) | 2855 | static int get_hem_table(struct hns_roce_dev *hr_dev) |
| 2668 | { | 2856 | { |
| 2669 | unsigned int qpc_count; | 2857 | unsigned int qpc_count; |
| @@ -2780,21 +2968,21 @@ static void hns_roce_v2_exit(struct hns_roce_dev *hr_dev) · 110 unmodified lines | |||
| 2780 | free_dip_list(hr_dev); | 2968 | free_dip_list(hr_dev); |
| 2781 | } | 2969 | } |
| 2782 | 2970 | ||
| 2783 | static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev, u64 in_param, | 2971 | static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev, |
| 2784 | u64 out_param, u32 in_modifier, u8 op_modifier, | 2972 | struct hns_roce_mbox_msg *mbox_msg) |
| 2785 | u16 op, u16 token, int event) | ||
| 2786 | { | 2973 | { |
| 2787 | struct hns_roce_cmq_desc desc; | 2974 | struct hns_roce_cmq_desc desc; |
| 2788 | struct hns_roce_post_mbox *mb = (struct hns_roce_post_mbox *)desc.data; | 2975 | struct hns_roce_post_mbox *mb = (struct hns_roce_post_mbox *)desc.data; |
| 2789 | 2976 | ||
| 2790 | hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_POST_MB, false); | 2977 | hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_POST_MB, false); |
| 2791 | 2978 | ||
| 2792 | mb->in_param_l = cpu_to_le32(in_param); | 2979 | mb->in_param_l = cpu_to_le32(mbox_msg->in_param); |
| 2793 | mb->in_param_h = cpu_to_le32(in_param >> 32); | 2980 | mb->in_param_h = cpu_to_le32(mbox_msg->in_param >> 32); |
| 2794 | mb->out_param_l = cpu_to_le32(out_param); | 2981 | mb->out_param_l = cpu_to_le32(mbox_msg->out_param); |
| 2795 | mb->out_param_h = cpu_to_le32(out_param >> 32); | 2982 | mb->out_param_h = cpu_to_le32(mbox_msg->out_param >> 32); |
| 2796 | mb->cmd_tag = cpu_to_le32(in_modifier << 8 | op); | 2983 | mb->cmd_tag = cpu_to_le32(mbox_msg->tag << 8 | mbox_msg->cmd); |
| 2797 | mb->token_event_en = cpu_to_le32(event << 16 | token); | 2984 | mb->token_event_en = cpu_to_le32(mbox_msg->event_en << 16 | |
| 2985 | mbox_msg->token); | ||
| 2798 | 2986 | ||
| 2799 | return hns_roce_cmq_send(hr_dev, &desc, 1); | 2987 | return hns_roce_cmq_send(hr_dev, &desc, 1); |
| 2800 | } | 2988 | } |
| @@ -2847,9 +3035,8 @@ static int v2_wait_mbox_complete(struct hns_roce_dev *hr_dev, u32 timeout, · 46 unmodified lines | |||
| 2847 | return ret; | 3035 | return ret; |
| 2848 | } | 3036 | } |
| 2849 | 3037 | ||
| 2850 | static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param, | 3038 | static int v2_post_mbox(struct hns_roce_dev *hr_dev, |
| 2851 | u64 out_param, u32 in_modifier, u8 op_modifier, | 3039 | struct hns_roce_mbox_msg *mbox_msg) |
| 2852 | u16 op, u16 token, int event) | ||
| 2853 | { | 3040 | { |
| 2854 | u8 status = 0; | 3041 | u8 status = 0; |
| 2855 | int ret; | 3042 | int ret; |
| @@ -2865,8 +3052,7 @@ static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param, · 9 unmodified lines | |||
| 2865 | } | 3052 | } |
| 2866 | 3053 | ||
| 2867 | /* Post new message to mbox */ | 3054 | /* Post new message to mbox */ |
| 2868 | ret = hns_roce_mbox_post(hr_dev, in_param, out_param, in_modifier, | 3055 | ret = hns_roce_mbox_post(hr_dev, mbox_msg); |
| 2869 | op_modifier, op, token, event); | ||
| 2870 | if (ret) | 3056 | if (ret) |
| 2871 | dev_err_ratelimited(hr_dev->dev, | 3057 | dev_err_ratelimited(hr_dev->dev, |
| 2872 | "failed to post mailbox, ret = %d.\n", ret); | 3058 | "failed to post mailbox, ret = %d.\n", ret); |
| @@ -2874,12 +3060,13 @@ static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param, · 1 unmodified line | |||
| 2874 | return ret; | 3060 | return ret; |
| 2875 | } | 3061 | } |
| 2876 | 3062 | ||
| 2877 | static int v2_poll_mbox_done(struct hns_roce_dev *hr_dev, unsigned int timeout) | 3063 | static int v2_poll_mbox_done(struct hns_roce_dev *hr_dev) |
| 2878 | { | 3064 | { |
| 2879 | u8 status = 0; | 3065 | u8 status = 0; |
| 2880 | int ret; | 3066 | int ret; |
| 2881 | 3067 | ||
| 2882 | ret = v2_wait_mbox_complete(hr_dev, timeout, &status); | 3068 | ret = v2_wait_mbox_complete(hr_dev, HNS_ROCE_CMD_TIMEOUT_MSECS, |
| 3069 | &status); | ||
| 2883 | if (!ret) { | 3070 | if (!ret) { |
| 2884 | if (status != MB_ST_COMPLETE_SUCC) | 3071 | if (status != MB_ST_COMPLETE_SUCC) |
| 2885 | return -EBUSY; | 3072 | return -EBUSY; |
| @@ -3245,6 +3432,98 @@ static int hns_roce_v2_mw_write_mtpt(void *mb_buf, struct hns_roce_mw *mw) · 359 unmodified lines | |||
| 3245 | return 0; | 3432 | return 0; |
| 3246 | } | 3433 | } |
| 3247 | 3434 | ||
| 3435 | static int free_mr_post_send_lp_wqe(struct hns_roce_qp *hr_qp) | ||
| 3436 | { | ||
| 3437 | struct hns_roce_dev *hr_dev = to_hr_dev(hr_qp->ibqp.device); | ||
| 3438 | struct ib_device *ibdev = &hr_dev->ib_dev; | ||
| 3439 | const struct ib_send_wr *bad_wr; | ||
| 3440 | struct ib_rdma_wr rdma_wr = {}; | ||
| 3441 | struct ib_send_wr *send_wr; | ||
| 3442 | int ret; | ||
| 3443 | |||
| 3444 | send_wr = &rdma_wr.wr; | ||
| 3445 | send_wr->opcode = IB_WR_RDMA_WRITE; | ||
| 3446 | |||
| 3447 | ret = hns_roce_v2_post_send(&hr_qp->ibqp, send_wr, &bad_wr); | ||
| 3448 | if (ret) { | ||
| 3449 | ibdev_err(ibdev, "failed to post wqe for free mr, ret = %d.\n", | ||
| 3450 | ret); | ||
| 3451 | return ret; | ||
| 3452 | } | ||
| 3453 | |||
| 3454 | return 0; | ||
| 3455 | } | ||
| 3456 | |||
| 3457 | static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries, | ||
| 3458 | struct ib_wc *wc); | ||
| 3459 | |||
| 3460 | static void free_mr_send_cmd_to_hw(struct hns_roce_dev *hr_dev) | ||
| 3461 | { | ||
| 3462 | struct hns_roce_v2_priv *priv = hr_dev->priv; | ||
| 3463 | struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; | ||
| 3464 | struct ib_wc wc[ARRAY_SIZE(free_mr->rsv_qp)]; | ||
| 3465 | struct ib_device *ibdev = &hr_dev->ib_dev; | ||
| 3466 | struct hns_roce_qp *hr_qp; | ||
| 3467 | unsigned long end; | ||
| 3468 | int cqe_cnt = 0; | ||
| 3469 | int npolled; | ||
| 3470 | int ret; | ||
| 3471 | int i; | ||
| 3472 | |||
| 3473 | /* | ||
| 3474 | * If the device initialization is not complete or in the uninstall | ||
| 3475 | * process, then there is no need to execute free mr. | ||
| 3476 | */ | ||
| 3477 | if (priv->handle->rinfo.reset_state == HNS_ROCE_STATE_RST_INIT || | ||
| 3478 | priv->handle->rinfo.instance_state == HNS_ROCE_STATE_INIT || | ||
| 3479 | hr_dev->state == HNS_ROCE_DEVICE_STATE_UNINIT) | ||
| 3480 | return; | ||
| 3481 | |||
| 3482 | mutex_lock(&free_mr->mutex); | ||
| 3483 | |||
| 3484 | for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) { | ||
| 3485 | hr_qp = to_hr_qp(free_mr->rsv_qp[i]); | ||
| 3486 | |||
| 3487 | ret = free_mr_post_send_lp_wqe(hr_qp); | ||
| 3488 | if (ret) { | ||
| 3489 | ibdev_err(ibdev, | ||
| 3490 | "failed to send wqe (qp:0x%lx) for free mr, ret = %d.\n", | ||
| 3491 | hr_qp->qpn, ret); | ||
| 3492 | break; | ||
| 3493 | } | ||
| 3494 | |||
| 3495 | cqe_cnt++; | ||
| 3496 | } | ||
| 3497 | |||
| 3498 | end = msecs_to_jiffies(HNS_ROCE_V2_FREE_MR_TIMEOUT) + jiffies; | ||
| 3499 | while (cqe_cnt) { | ||
| 3500 | npolled = hns_roce_v2_poll_cq(free_mr->rsv_cq, cqe_cnt, wc); | ||
| 3501 | if (npolled < 0) { | ||
| 3502 | ibdev_err(ibdev, | ||
| 3503 | "failed to poll cqe for free mr, remain %d cqe.\n", | ||
| 3504 | cqe_cnt); | ||
| 3505 | goto out; | ||
| 3506 | } | ||
| 3507 | |||
| 3508 | if (time_after(jiffies, end)) { | ||
| 3509 | ibdev_err(ibdev, | ||
| 3510 | "failed to poll cqe for free mr and timeout, remain %d cqe.\n", | ||
| 3511 | cqe_cnt); | ||
| 3512 | goto out; | ||
| 3513 | } | ||
| 3514 | cqe_cnt -= npolled; | ||
| 3515 | } | ||
| 3516 | |||
| 3517 | out: | ||
| 3518 | mutex_unlock(&free_mr->mutex); | ||
| 3519 | } | ||
| 3520 | |||
| 3521 | static void hns_roce_v2_dereg_mr(struct hns_roce_dev *hr_dev) | ||
| 3522 | { | ||
| 3523 | if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) | ||
| 3524 | free_mr_send_cmd_to_hw(hr_dev); | ||
| 3525 | } | ||
| 3526 | |||
| 3248 | static void *get_cqe_v2(struct hns_roce_cq *hr_cq, int n) | 3527 | static void *get_cqe_v2(struct hns_roce_cq *hr_cq, int n) |
| 3249 | { | 3528 | { |
| 3250 | return hns_roce_buf_offset(hr_cq->mtr.kmem, n * hr_cq->cqe_size); | 3529 | return hns_roce_buf_offset(hr_cq->mtr.kmem, n * hr_cq->cqe_size); |
| @@ -3818,38 +4097,38 @@ out: · 567 unmodified lines | |||
| 3818 | } | 4097 | } |
| 3819 | 4098 | ||
| 3820 | static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type, | 4099 | static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type, |
| 3821 | int step_idx, u16 *mbox_op) | 4100 | u32 step_idx, u8 *mbox_cmd) |
| 3822 | { | 4101 | { |
| 3823 | u16 op; | 4102 | u8 cmd; |
| 3824 | 4103 | ||
| 3825 | switch (type) { | 4104 | switch (type) { |
| 3826 | case HEM_TYPE_QPC: | 4105 | case HEM_TYPE_QPC: |
| 3827 | op = HNS_ROCE_CMD_WRITE_QPC_BT0; | 4106 | cmd = HNS_ROCE_CMD_WRITE_QPC_BT0; |
| 3828 | break; | 4107 | break; |
| 3829 | case HEM_TYPE_MTPT: | 4108 | case HEM_TYPE_MTPT: |
| 3830 | op = HNS_ROCE_CMD_WRITE_MPT_BT0; | 4109 | cmd = HNS_ROCE_CMD_WRITE_MPT_BT0; |
| 3831 | break; | 4110 | break; |
| 3832 | case HEM_TYPE_CQC: | 4111 | case HEM_TYPE_CQC: |
| 3833 | op = HNS_ROCE_CMD_WRITE_CQC_BT0; | 4112 | cmd = HNS_ROCE_CMD_WRITE_CQC_BT0; |
| 3834 | break; | 4113 | break; |
| 3835 | case HEM_TYPE_SRQC: | 4114 | case HEM_TYPE_SRQC: |
| 3836 | op = HNS_ROCE_CMD_WRITE_SRQC_BT0; | 4115 | cmd = HNS_ROCE_CMD_WRITE_SRQC_BT0; |
| 3837 | break; | 4116 | break; |
| 3838 | case HEM_TYPE_SCCC: | 4117 | case HEM_TYPE_SCCC: |
| 3839 | op = HNS_ROCE_CMD_WRITE_SCCC_BT0; | 4118 | cmd = HNS_ROCE_CMD_WRITE_SCCC_BT0; |
| 3840 | break; | 4119 | break; |
| 3841 | case HEM_TYPE_QPC_TIMER: | 4120 | case HEM_TYPE_QPC_TIMER: |
| 3842 | op = HNS_ROCE_CMD_WRITE_QPC_TIMER_BT0; | 4121 | cmd = HNS_ROCE_CMD_WRITE_QPC_TIMER_BT0; |
| 3843 | break; | 4122 | break; |
| 3844 | case HEM_TYPE_CQC_TIMER: | 4123 | case HEM_TYPE_CQC_TIMER: |
| 3845 | op = HNS_ROCE_CMD_WRITE_CQC_TIMER_BT0; | 4124 | cmd = HNS_ROCE_CMD_WRITE_CQC_TIMER_BT0; |
| 3846 | break; | 4125 | break; |
| 3847 | default: | 4126 | default: |
| 3848 | dev_warn(hr_dev->dev, "failed to check hem type %u.\n", type); | 4127 | dev_warn(hr_dev->dev, "failed to check hem type %u.\n", type); |
| 3849 | return -EINVAL; | 4128 | return -EINVAL; |
| 3850 | } | 4129 | } |
| 3851 | 4130 | ||
| 3852 | *mbox_op = op + step_idx; | 4131 | *mbox_cmd = cmd + step_idx; |
| 3853 | 4132 | ||
| 3854 | return 0; | 4133 | return 0; |
| 3855 | } | 4134 | } |
| @@ -3872,10 +4151,10 @@ static int config_gmv_ba_to_hw(struct hns_roce_dev *hr_dev, unsigned long obj, · 16 unmodified lines | |||
| 3872 | } | 4151 | } |
| 3873 | 4152 | ||
| 3874 | static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj, | 4153 | static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj, |
| 3875 | dma_addr_t base_addr, u32 hem_type, int step_idx) | 4154 | dma_addr_t base_addr, u32 hem_type, u32 step_idx) |
| 3876 | { | 4155 | { |
| 3877 | int ret; | 4156 | int ret; |
| 3878 | u16 op; | 4157 | u8 cmd; |
| 3879 | 4158 | ||
| 3880 | if (unlikely(hem_type == HEM_TYPE_GMV)) | 4159 | if (unlikely(hem_type == HEM_TYPE_GMV)) |
| 3881 | return config_gmv_ba_to_hw(hr_dev, obj, base_addr); | 4160 | return config_gmv_ba_to_hw(hr_dev, obj, base_addr); |
| @@ -3883,16 +4162,16 @@ static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj, · 1 unmodified line | |||
| 3883 | if (unlikely(hem_type == HEM_TYPE_SCCC && step_idx)) | 4162 | if (unlikely(hem_type == HEM_TYPE_SCCC && step_idx)) |
| 3884 | return 0; | 4163 | return 0; |
| 3885 | 4164 | ||
| 3886 | ret = get_op_for_set_hem(hr_dev, hem_type, step_idx, &op); | 4165 | ret = get_op_for_set_hem(hr_dev, hem_type, step_idx, &cmd); |
| 3887 | if (ret < 0) | 4166 | if (ret < 0) |
| 3888 | return ret; | 4167 | return ret; |
| 3889 | 4168 | ||
| 3890 | return config_hem_ba_to_hw(hr_dev, obj, base_addr, op); | 4169 | return config_hem_ba_to_hw(hr_dev, base_addr, cmd, obj); |
| 3891 | } | 4170 | } |
| 3892 | 4171 | ||
| 3893 | static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, | 4172 | static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, |
| 3894 | struct hns_roce_hem_table *table, int obj, | 4173 | struct hns_roce_hem_table *table, int obj, |
| 3895 | int step_idx) | 4174 | u32 step_idx) |
| 3896 | { | 4175 | { |
| 3897 | struct hns_roce_hem_iter iter; | 4176 | struct hns_roce_hem_iter iter; |
| 3898 | struct hns_roce_hem_mhop mhop; | 4177 | struct hns_roce_hem_mhop mhop; |
| @@ -3950,29 +4229,29 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, · 51 unmodified lines | |||
| 3950 | } | 4229 | } |
| 3951 | 4230 | ||
| 3952 | static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, | 4231 | static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, |
| 3953 | struct hns_roce_hem_table *table, int obj, | 4232 | struct hns_roce_hem_table *table, |
| 3954 | int step_idx) | 4233 | int tag, u32 step_idx) |
| 3955 | { | 4234 | { |
| 3956 | struct device *dev = hr_dev->dev; | ||
| 3957 | struct hns_roce_cmd_mailbox *mailbox; | 4235 | struct hns_roce_cmd_mailbox *mailbox; |
| 4236 | struct device *dev = hr_dev->dev; | ||
| 4237 | u8 cmd = 0xff; | ||
| 3958 | int ret; | 4238 | int ret; |
| 3959 | u16 op = 0xff; | ||
| 3960 | 4239 | ||
| 3961 | if (!hns_roce_check_whether_mhop(hr_dev, table->type)) | 4240 | if (!hns_roce_check_whether_mhop(hr_dev, table->type)) |
| 3962 | return 0; | 4241 | return 0; |
| 3963 | 4242 | ||
| 3964 | switch (table->type) { | 4243 | switch (table->type) { |
| 3965 | case HEM_TYPE_QPC: | 4244 | case HEM_TYPE_QPC: |
| 3966 | op = HNS_ROCE_CMD_DESTROY_QPC_BT0; | 4245 | cmd = HNS_ROCE_CMD_DESTROY_QPC_BT0; |
| 3967 | break; | 4246 | break; |
| 3968 | case HEM_TYPE_MTPT: | 4247 | case HEM_TYPE_MTPT: |
| 3969 | op = HNS_ROCE_CMD_DESTROY_MPT_BT0; | 4248 | cmd = HNS_ROCE_CMD_DESTROY_MPT_BT0; |
| 3970 | break; | 4249 | break; |
| 3971 | case HEM_TYPE_CQC: | 4250 | case HEM_TYPE_CQC: |
| 3972 | op = HNS_ROCE_CMD_DESTROY_CQC_BT0; | 4251 | cmd = HNS_ROCE_CMD_DESTROY_CQC_BT0; |
| 3973 | break; | 4252 | break; |
| 3974 | case HEM_TYPE_SRQC: | 4253 | case HEM_TYPE_SRQC: |
| 3975 | op = HNS_ROCE_CMD_DESTROY_SRQC_BT0; | 4254 | cmd = HNS_ROCE_CMD_DESTROY_SRQC_BT0; |
| 3976 | break; | 4255 | break; |
| 3977 | case HEM_TYPE_SCCC: | 4256 | case HEM_TYPE_SCCC: |
| 3978 | case HEM_TYPE_QPC_TIMER: | 4257 | case HEM_TYPE_QPC_TIMER: |
| @@ -3985,15 +4264,13 @@ static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, · 6 unmodified lines | |||
| 3985 | return 0; | 4264 | return 0; |
| 3986 | } | 4265 | } |
| 3987 | 4266 | ||
| 3988 | op += step_idx; | 4267 | cmd += step_idx; |
| 3989 | 4268 | ||
| 3990 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); | 4269 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); |
| 3991 | if (IS_ERR(mailbox)) | 4270 | if (IS_ERR(mailbox)) |
| 3992 | return PTR_ERR(mailbox); | 4271 | return PTR_ERR(mailbox); |
| 3993 | 4272 | ||
| 3994 | /* configure the tag and op */ | 4273 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, cmd, tag); |
| 3995 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, obj, 0, op, | ||
| 3996 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 3997 | 4274 | ||
| 3998 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | 4275 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); |
| 3999 | return ret; | 4276 | return ret; |
| @@ -4017,9 +4294,8 @@ static int hns_roce_v2_qp_modify(struct hns_roce_dev *hr_dev, · 17 unmodified lines | |||
| 4017 | memcpy(mailbox->buf, context, qpc_size); | 4294 | memcpy(mailbox->buf, context, qpc_size); |
| 4018 | memcpy(mailbox->buf + qpc_size, qpc_mask, qpc_size); | 4295 | memcpy(mailbox->buf + qpc_size, qpc_mask, qpc_size); |
| 4019 | 4296 | ||
| 4020 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_qp->qpn, 0, | 4297 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, |
| 4021 | HNS_ROCE_CMD_MODIFY_QPC, | 4298 | HNS_ROCE_CMD_MODIFY_QPC, hr_qp->qpn); |
| 4022 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 4023 | 4299 | ||
| 4024 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | 4300 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); |
| 4025 | 4301 | ||
| @@ -4667,6 +4943,18 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp, · 641 unmodified lines | |||
| 4667 | u8 hr_port; | 4943 | u8 hr_port; |
| 4668 | int ret; | 4944 | int ret; |
| 4669 | 4945 | ||
| 4946 | /* | ||
| 4947 | * If free_mr_en of qp is set, it means that this qp comes from | ||
| 4948 | * free mr. This qp will perform the loopback operation. | ||
| 4949 | * In the loopback scenario, only sl needs to be set. | ||
| 4950 | */ | ||
| 4951 | if (hr_qp->free_mr_en) { | ||
| 4952 | hr_reg_write(context, QPC_SL, rdma_ah_get_sl(&attr->ah_attr)); | ||
| 4953 | hr_reg_clear(qpc_mask, QPC_SL); | ||
| 4954 | hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr); | ||
| 4955 | return 0; | ||
| 4956 | } | ||
| 4957 | |||
| 4670 | ib_port = (attr_mask & IB_QP_PORT) ? attr->port_num : hr_qp->port + 1; | 4958 | ib_port = (attr_mask & IB_QP_PORT) ? attr->port_num : hr_qp->port + 1; |
| 4671 | hr_port = ib_port - 1; | 4959 | hr_port = ib_port - 1; |
| 4672 | is_roce_protocol = rdma_cap_eth_ah(&hr_dev->ib_dev, ib_port) && | 4960 | is_roce_protocol = rdma_cap_eth_ah(&hr_dev->ib_dev, ib_port) && |
| @@ -5092,9 +5380,8 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev, · 419 unmodified lines | |||
| 5092 | if (IS_ERR(mailbox)) | 5380 | if (IS_ERR(mailbox)) |
| 5093 | return PTR_ERR(mailbox); | 5381 | return PTR_ERR(mailbox); |
| 5094 | 5382 | ||
| 5095 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, hr_qp->qpn, 0, | 5383 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_QPC, |
| 5096 | HNS_ROCE_CMD_QUERY_QPC, | 5384 | hr_qp->qpn); |
| 5097 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 5098 | if (ret) | 5385 | if (ret) |
| 5099 | goto out; | 5386 | goto out; |
| 5100 | 5387 | ||
| @@ -5460,9 +5747,8 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq, · 359 unmodified lines | |||
| 5460 | hr_reg_write(srq_context, SRQC_LIMIT_WL, srq_attr->srq_limit); | 5747 | hr_reg_write(srq_context, SRQC_LIMIT_WL, srq_attr->srq_limit); |
| 5461 | hr_reg_clear(srqc_mask, SRQC_LIMIT_WL); | 5748 | hr_reg_clear(srqc_mask, SRQC_LIMIT_WL); |
| 5462 | 5749 | ||
| 5463 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, srq->srqn, 0, | 5750 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, |
| 5464 | HNS_ROCE_CMD_MODIFY_SRQC, | 5751 | HNS_ROCE_CMD_MODIFY_SRQC, srq->srqn); |
| 5465 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 5466 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | 5752 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); |
| 5467 | if (ret) { | 5753 | if (ret) { |
| 5468 | ibdev_err(&hr_dev->ib_dev, | 5754 | ibdev_err(&hr_dev->ib_dev, |
| @@ -5488,9 +5774,8 @@ static int hns_roce_v2_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr) · 19 unmodified lines | |||
| 5488 | return PTR_ERR(mailbox); | 5774 | return PTR_ERR(mailbox); |
| 5489 | 5775 | ||
| 5490 | srq_context = mailbox->buf; | 5776 | srq_context = mailbox->buf; |
| 5491 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, srq->srqn, 0, | 5777 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, |
| 5492 | HNS_ROCE_CMD_QUERY_SRQC, | 5778 | HNS_ROCE_CMD_QUERY_SRQC, srq->srqn); |
| 5493 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 5494 | if (ret) { | 5779 | if (ret) { |
| 5495 | ibdev_err(&hr_dev->ib_dev, | 5780 | ibdev_err(&hr_dev->ib_dev, |
| 5496 | "failed to process cmd of querying SRQ, ret = %d.\n", | 5781 | "failed to process cmd of querying SRQ, ret = %d.\n", |
| @@ -5540,9 +5825,8 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period) · 43 unmodified lines | |||
| 5540 | hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period); | 5825 | hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period); |
| 5541 | hr_reg_clear(cqc_mask, CQC_CQ_PERIOD); | 5826 | hr_reg_clear(cqc_mask, CQC_CQ_PERIOD); |
| 5542 | 5827 | ||
| 5543 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, 1, | 5828 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, |
| 5544 | HNS_ROCE_CMD_MODIFY_CQC, | 5829 | HNS_ROCE_CMD_MODIFY_CQC, hr_cq->cqn); |
| 5545 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 5546 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | 5830 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); |
| 5547 | if (ret) | 5831 | if (ret) |
| 5548 | ibdev_err(&hr_dev->ib_dev, | 5832 | ibdev_err(&hr_dev->ib_dev, |
| @@ -5869,15 +6153,14 @@ static void hns_roce_v2_destroy_eqc(struct hns_roce_dev *hr_dev, u32 eqn) · 320 unmodified lines | |||
| 5869 | { | 6153 | { |
| 5870 | struct device *dev = hr_dev->dev; | 6154 | struct device *dev = hr_dev->dev; |
| 5871 | int ret; | 6155 | int ret; |
| 6156 | u8 cmd; | ||
| 5872 | 6157 | ||
| 5873 | if (eqn < hr_dev->caps.num_comp_vectors) | 6158 | if (eqn < hr_dev->caps.num_comp_vectors) |
| 5874 | ret = hns_roce_cmd_mbox(hr_dev, 0, 0, eqn & HNS_ROCE_V2_EQN_M, | 6159 | cmd = HNS_ROCE_CMD_DESTROY_CEQC; |
| 5875 | 0, HNS_ROCE_CMD_DESTROY_CEQC, | ||
| 5876 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 5877 | else | 6160 | else |
| 5878 | ret = hns_roce_cmd_mbox(hr_dev, 0, 0, eqn & HNS_ROCE_V2_EQN_M, | 6161 | cmd = HNS_ROCE_CMD_DESTROY_AEQC; |
| 5879 | 0, HNS_ROCE_CMD_DESTROY_AEQC, | 6162 | |
| 5880 | HNS_ROCE_CMD_TIMEOUT_MSECS); | 6163 | ret = hns_roce_destroy_hw_ctx(hr_dev, cmd, eqn & HNS_ROCE_V2_EQN_M); |
| 5881 | if (ret) | 6164 | if (ret) |
| 5882 | dev_err(dev, "[mailbox cmd] destroy eqc(%u) failed.\n", eqn); | 6165 | dev_err(dev, "[mailbox cmd] destroy eqc(%u) failed.\n", eqn); |
| 5883 | } | 6166 | } |
| @@ -5983,16 +6266,15 @@ static int alloc_eq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq) · 99 unmodified lines | |||
| 5983 | } | 6266 | } |
| 5984 | 6267 | ||
| 5985 | static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev, | 6268 | static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev, |
| 5986 | struct hns_roce_eq *eq, | 6269 | struct hns_roce_eq *eq, u8 eq_cmd) |
| 5987 | unsigned int eq_cmd) | ||
| 5988 | { | 6270 | { |
| 5989 | struct hns_roce_cmd_mailbox *mailbox; | 6271 | struct hns_roce_cmd_mailbox *mailbox; |
| 5990 | int ret; | 6272 | int ret; |
| 5991 | 6273 | ||
| 5992 | /* Allocate mailbox memory */ | 6274 | /* Allocate mailbox memory */ |
| 5993 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); | 6275 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); |
| 5994 | if (IS_ERR_OR_NULL(mailbox)) | 6276 | if (IS_ERR(mailbox)) |
| 5995 | return -ENOMEM; | 6277 | return PTR_ERR(mailbox); |
| 5996 | 6278 | ||
| 5997 | ret = alloc_eq_buf(hr_dev, eq); | 6279 | ret = alloc_eq_buf(hr_dev, eq); |
| 5998 | if (ret) | 6280 | if (ret) |
| @@ -6002,8 +6284,7 @@ static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev, · 3 unmodified lines | |||
| 6002 | if (ret) | 6284 | if (ret) |
| 6003 | goto err_cmd_mbox; | 6285 | goto err_cmd_mbox; |
| 6004 | 6286 | ||
| 6005 | ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, eq->eqn, 0, | 6287 | ret = hns_roce_create_hw_ctx(hr_dev, mailbox, eq_cmd, eq->eqn); |
| 6006 | eq_cmd, HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 6007 | if (ret) { | 6288 | if (ret) { |
| 6008 | dev_err(hr_dev->dev, "[mailbox cmd] create eqc failed.\n"); | 6289 | dev_err(hr_dev->dev, "[mailbox cmd] create eqc failed.\n"); |
| 6009 | goto err_cmd_mbox; | 6290 | goto err_cmd_mbox; |
| @@ -6114,14 +6395,14 @@ static int hns_roce_v2_init_eq_table(struct hns_roce_dev *hr_dev) · 104 unmodified lines | |||
| 6114 | struct hns_roce_eq_table *eq_table = &hr_dev->eq_table; | 6395 | struct hns_roce_eq_table *eq_table = &hr_dev->eq_table; |
| 6115 | struct device *dev = hr_dev->dev; | 6396 | struct device *dev = hr_dev->dev; |
| 6116 | struct hns_roce_eq *eq; | 6397 | struct hns_roce_eq *eq; |
| 6117 | unsigned int eq_cmd; | ||
| 6118 | int irq_num; | ||
| 6119 | int eq_num; | ||
| 6120 | int other_num; | 6398 | int other_num; |
| 6121 | int comp_num; | 6399 | int comp_num; |
| 6122 | int aeq_num; | 6400 | int aeq_num; |
| 6123 | int i; | 6401 | int irq_num; |
| 6402 | int eq_num; | ||
| 6403 | u8 eq_cmd; | ||
| 6124 | int ret; | 6404 | int ret; |
| 6405 | int i; | ||
| 6125 | 6406 | ||
| 6126 | other_num = hr_dev->caps.num_other_vectors; | 6407 | other_num = hr_dev->caps.num_other_vectors; |
| 6127 | comp_num = hr_dev->caps.num_comp_vectors; | 6408 | comp_num = hr_dev->caps.num_comp_vectors; |
| @@ -6258,6 +6539,7 @@ static const struct hns_roce_hw hns_roce_hw_v2 = { · 130 unmodified lines | |||
| 6258 | .set_hem = hns_roce_v2_set_hem, | 6539 | .set_hem = hns_roce_v2_set_hem, |
| 6259 | .clear_hem = hns_roce_v2_clear_hem, | 6540 | .clear_hem = hns_roce_v2_clear_hem, |
| 6260 | .modify_qp = hns_roce_v2_modify_qp, | 6541 | .modify_qp = hns_roce_v2_modify_qp, |
| 6542 | .dereg_mr = hns_roce_v2_dereg_mr, | ||
| 6261 | .qp_flow_control_init = hns_roce_v2_qp_flow_control_init, | 6543 | .qp_flow_control_init = hns_roce_v2_qp_flow_control_init, |
| 6262 | .init_eq = hns_roce_v2_init_eq_table, | 6544 | .init_eq = hns_roce_v2_init_eq_table, |
| 6263 | .cleanup_eq = hns_roce_v2_cleanup_eq_table, | 6545 | .cleanup_eq = hns_roce_v2_cleanup_eq_table, |
| @@ -6339,14 +6621,25 @@ static int __hns_roce_hw_v2_init_instance(struct hnae3_handle *handle) · 75 unmodified lines | |||
| 6339 | ret = hns_roce_init(hr_dev); | 6621 | ret = hns_roce_init(hr_dev); |
| 6340 | if (ret) { | 6622 | if (ret) { |
| 6341 | dev_err(hr_dev->dev, "RoCE Engine init failed!\n"); | 6623 | dev_err(hr_dev->dev, "RoCE Engine init failed!\n"); |
| 6342 | goto error_failed_get_cfg; | 6624 | goto error_failed_cfg; |
| 6625 | } | ||
| 6626 | |||
| 6627 | if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) { | ||
| 6628 | ret = free_mr_init(hr_dev); | ||
| 6629 | if (ret) { | ||
| 6630 | dev_err(hr_dev->dev, "failed to init free mr!\n"); | ||
| 6631 | goto error_failed_roce_init; | ||
| 6632 | } | ||
| 6343 | } | 6633 | } |
| 6344 | 6634 | ||
| 6345 | handle->priv = hr_dev; | 6635 | handle->priv = hr_dev; |
| 6346 | 6636 | ||
| 6347 | return 0; | 6637 | return 0; |
| 6348 | 6638 | ||
| 6349 | error_failed_get_cfg: | 6639 | error_failed_roce_init: |
| 6640 | hns_roce_exit(hr_dev); | ||
| 6641 | |||
| 6642 | error_failed_cfg: | ||
| 6350 | kfree(hr_dev->priv); | 6643 | kfree(hr_dev->priv); |
| 6351 | 6644 | ||
| 6352 | error_failed_kzalloc: | 6645 | error_failed_kzalloc: |
| @@ -6368,6 +6661,9 @@ static void __hns_roce_hw_v2_uninit_instance(struct hnae3_handle *handle, · 15 unmodified lines | |||
| 6368 | hr_dev->state = HNS_ROCE_DEVICE_STATE_UNINIT; | 6661 | hr_dev->state = HNS_ROCE_DEVICE_STATE_UNINIT; |
| 6369 | hns_roce_handle_device_err(hr_dev); | 6662 | hns_roce_handle_device_err(hr_dev); |
| 6370 | 6663 | ||
| 6664 | if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) | ||
| 6665 | free_mr_exit(hr_dev); | ||
| 6666 | |||
| 6371 | hns_roce_exit(hr_dev); | 6667 | hns_roce_exit(hr_dev); |
| 6372 | kfree(hr_dev->priv); | 6668 | kfree(hr_dev->priv); |
| 6373 | ib_dealloc_device(&hr_dev->ib_dev); | 6669 | ib_dealloc_device(&hr_dev->ib_dev); |
| @@ -139,6 +139,18 @@ enum { · 138 unmodified lines | |||
| 139 | #define CMD_CSQ_DESC_NUM 1024 | 139 | #define CMD_CSQ_DESC_NUM 1024 |
| 140 | #define CMD_CRQ_DESC_NUM 1024 | 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 | enum { | 154 | enum { |
| 143 | NO_ARMED = 0x0, | 155 | NO_ARMED = 0x0, |
| 144 | REG_NXT_CEQE = 0x2, | 156 | REG_NXT_CEQE = 0x2, |
| @@ -1418,10 +1430,18 @@ struct hns_roce_link_table { · 1273 unmodified lines | |||
| 1418 | #define HNS_ROCE_EXT_LLM_ENTRY(addr, id) (((id) << (64 - 12)) | ((addr) >> 12)) | 1430 | #define HNS_ROCE_EXT_LLM_ENTRY(addr, id) (((id) << (64 - 12)) | ((addr) >> 12)) |
| 1419 | #define HNS_ROCE_EXT_LLM_MIN_PAGES(que_num) ((que_num) * 4 + 2) | 1431 | #define HNS_ROCE_EXT_LLM_MIN_PAGES(que_num) ((que_num) * 4 + 2) |
| 1420 | 1432 | ||
| 1433 | struct hns_roce_v2_free_mr { | ||
| 1434 | struct ib_qp *rsv_qp[HNS_ROCE_FREE_MR_USED_QP_NUM]; | ||
| 1435 | struct ib_cq *rsv_cq; | ||
| 1436 | struct ib_pd *rsv_pd; | ||
| 1437 | struct mutex mutex; | ||
| 1438 | }; | ||
| 1439 | |||
| 1421 | struct hns_roce_v2_priv { | 1440 | struct hns_roce_v2_priv { |
| 1422 | struct hnae3_handle *handle; | 1441 | struct hnae3_handle *handle; |
| 1423 | struct hns_roce_v2_cmq cmq; | 1442 | struct hns_roce_v2_cmq cmq; |
| 1424 | struct hns_roce_link_table ext_llm; | 1443 | struct hns_roce_link_table ext_llm; |
| 1444 | struct hns_roce_v2_free_mr free_mr; | ||
| 1425 | }; | 1445 | }; |
| 1426 | 1446 | ||
| 1427 | struct hns_roce_dip { | 1447 | struct hns_roce_dip { |
| @@ -18,9 +18,8 @@ int hns_roce_v2_query_cqc_info(struct hns_roce_dev *hr_dev, u32 cqn, · 17 unmodified lines | |||
| 18 | return PTR_ERR(mailbox); | 18 | return PTR_ERR(mailbox); |
| 19 | 19 | ||
| 20 | cq_context = mailbox->buf; | 20 | cq_context = mailbox->buf; |
| 21 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, cqn, 0, | 21 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_CQC, |
| 22 | HNS_ROCE_CMD_QUERY_CQC, | 22 | cqn); |
| 23 | HNS_ROCE_CMD_TIMEOUT_MSECS); | ||
| 24 | if (ret) { | 23 | if (ret) { |
| 25 | dev_err(hr_dev->dev, "QUERY cqc cmd process error\n"); | 24 | dev_err(hr_dev->dev, "QUERY cqc cmd process error\n"); |
| 26 | goto err_mailbox; | 25 | goto err_mailbox; |
| @@ -47,24 +47,6 @@ unsigned long key_to_hw_index(u32 key) · 46 unmodified lines | |||
| 47 | return (key << 24) | (key >> 8); | 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 | static int alloc_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) | 50 | static int alloc_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) |
| 69 | { | 51 | { |
| 70 | struct hns_roce_ida *mtpt_ida = &hr_dev->mr_table.mtpt_ida; | 52 | struct hns_roce_ida *mtpt_ida = &hr_dev->mr_table.mtpt_ida; |
| @@ -137,14 +119,13 @@ static void free_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) · 66 unmodified lines | |||
| 137 | hns_roce_mtr_destroy(hr_dev, &mr->pbl_mtr); | 119 | hns_roce_mtr_destroy(hr_dev, &mr->pbl_mtr); |
| 138 | } | 120 | } |
| 139 | 121 | ||
| 140 | static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, | 122 | static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) |
| 141 | struct hns_roce_mr *mr) | ||
| 142 | { | 123 | { |
| 143 | struct ib_device *ibdev = &hr_dev->ib_dev; | 124 | struct ib_device *ibdev = &hr_dev->ib_dev; |
| 144 | int ret; | 125 | int ret; |
| 145 | 126 | ||
| 146 | if (mr->enabled) { | 127 | if (mr->enabled) { |
| 147 | ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, | 128 | ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_MPT, |
| 148 | key_to_hw_index(mr->key) & | 129 | key_to_hw_index(mr->key) & |
| 149 | (hr_dev->caps.num_mtpts - 1)); | 130 | (hr_dev->caps.num_mtpts - 1)); |
| 150 | if (ret) | 131 | if (ret) |
| @@ -166,10 +147,8 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev, · 15 unmodified lines | |||
| 166 | 147 | ||
| 167 | /* Allocate mailbox memory */ | 148 | /* Allocate mailbox memory */ |
| 168 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); | 149 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); |
| 169 | if (IS_ERR(mailbox)) { | 150 | if (IS_ERR(mailbox)) |
| 170 | ret = PTR_ERR(mailbox); | 151 | return PTR_ERR(mailbox); |
| 171 | return ret; | ||
| 172 | } | ||
| 173 | 152 | ||
| 174 | if (mr->type != MR_TYPE_FRMR) | 153 | if (mr->type != MR_TYPE_FRMR) |
| 175 | ret = hr_dev->hw->write_mtpt(hr_dev, mailbox->buf, mr); | 154 | ret = hr_dev->hw->write_mtpt(hr_dev, mailbox->buf, mr); |
| @@ -180,7 +159,7 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev, · 4 unmodified lines | |||
| 180 | goto err_page; | 159 | goto err_page; |
| 181 | } | 160 | } |
| 182 | 161 | ||
| 183 | ret = hns_roce_hw_create_mpt(hr_dev, mailbox, | 162 | ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_MPT, |
| 184 | mtpt_idx & (hr_dev->caps.num_mtpts - 1)); | 163 | mtpt_idx & (hr_dev->caps.num_mtpts - 1)); |
| 185 | if (ret) { | 164 | if (ret) { |
| 186 | dev_err(dev, "failed to create mpt, ret = %d.\n", ret); | 165 | dev_err(dev, "failed to create mpt, ret = %d.\n", ret); |
| @@ -303,13 +282,14 @@ struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, · 116 unmodified lines | |||
| 303 | return ERR_CAST(mailbox); | 282 | return ERR_CAST(mailbox); |
| 304 | 283 | ||
| 305 | mtpt_idx = key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1); | 284 | mtpt_idx = key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1); |
| 306 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, mtpt_idx, 0, | 285 | |
| 307 | HNS_ROCE_CMD_QUERY_MPT, | 286 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_MPT, |
| 308 | HNS_ROCE_CMD_TIMEOUT_MSECS); | 287 | mtpt_idx); |
| 309 | if (ret) | 288 | if (ret) |
| 310 | goto free_cmd_mbox; | 289 | goto free_cmd_mbox; |
| 311 | 290 | ||
| 312 | ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, mtpt_idx); | 291 | ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_MPT, |
| 292 | mtpt_idx); | ||
| 313 | if (ret) | 293 | if (ret) |
| 314 | ibdev_warn(ib_dev, "failed to destroy MPT, ret = %d.\n", ret); | 294 | ibdev_warn(ib_dev, "failed to destroy MPT, ret = %d.\n", ret); |
| 315 | 295 | ||
| @@ -339,7 +319,8 @@ struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, · 23 unmodified lines | |||
| 339 | goto free_cmd_mbox; | 319 | goto free_cmd_mbox; |
| 340 | } | 320 | } |
| 341 | 321 | ||
| 342 | ret = hns_roce_hw_create_mpt(hr_dev, mailbox, mtpt_idx); | 322 | ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_MPT, |
| 323 | mtpt_idx); | ||
| 343 | if (ret) { | 324 | if (ret) { |
| 344 | ibdev_err(ib_dev, "failed to create MPT, ret = %d.\n", ret); | 325 | ibdev_err(ib_dev, "failed to create MPT, ret = %d.\n", ret); |
| 345 | goto free_cmd_mbox; | 326 | goto free_cmd_mbox; |
| @@ -361,6 +342,9 @@ int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) · 15 unmodified lines | |||
| 361 | struct hns_roce_mr *mr = to_hr_mr(ibmr); | 342 | struct hns_roce_mr *mr = to_hr_mr(ibmr); |
| 362 | int ret = 0; | 343 | int ret = 0; |
| 363 | 344 | ||
| 345 | if (hr_dev->hw->dereg_mr) | ||
| 346 | hr_dev->hw->dereg_mr(hr_dev); | ||
| 347 | |||
| 364 | hns_roce_mr_free(hr_dev, mr); | 348 | hns_roce_mr_free(hr_dev, mr); |
| 365 | kfree(mr); | 349 | kfree(mr); |
| 366 | 350 | ||
| @@ -480,7 +464,7 @@ static void hns_roce_mw_free(struct hns_roce_dev *hr_dev, · 113 unmodified lines | |||
| 480 | int ret; | 464 | int ret; |
| 481 | 465 | ||
| 482 | if (mw->enabled) { | 466 | if (mw->enabled) { |
| 483 | ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, | 467 | ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_MPT, |
| 484 | key_to_hw_index(mw->rkey) & | 468 | key_to_hw_index(mw->rkey) & |
| 485 | (hr_dev->caps.num_mtpts - 1)); | 469 | (hr_dev->caps.num_mtpts - 1)); |
| 486 | if (ret) | 470 | if (ret) |
| @@ -520,7 +504,7 @@ static int hns_roce_mw_enable(struct hns_roce_dev *hr_dev, · 33 unmodified lines | |||
| 520 | goto err_page; | 504 | goto err_page; |
| 521 | } | 505 | } |
| 522 | 506 | ||
| 523 | ret = hns_roce_hw_create_mpt(hr_dev, mailbox, | 507 | ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_MPT, |
| 524 | mtpt_idx & (hr_dev->caps.num_mtpts - 1)); | 508 | mtpt_idx & (hr_dev->caps.num_mtpts - 1)); |
| 525 | if (ret) { | 509 | if (ret) { |
| 526 | dev_err(dev, "MW CREATE_MPT failed (%d)\n", ret); | 510 | dev_err(dev, "MW CREATE_MPT failed (%d)\n", ret); |
| @@ -59,58 +59,39 @@ static void hns_roce_ib_srq_event(struct hns_roce_srq *srq, · 58 unmodified lines | |||
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static int hns_roce_hw_create_srq(struct hns_roce_dev *dev, | 62 | static int alloc_srqn(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) |
| 63 | struct hns_roce_cmd_mailbox *mailbox, | ||
| 64 | unsigned long srq_num) | ||
| 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 | struct hns_roce_ida *srq_ida = &hr_dev->srq_table.srq_ida; | 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 | int id; | 65 | int id; |
| 88 | 66 | ||
| 89 | id = ida_alloc_range(&srq_ida->ida, srq_ida->min, srq_ida->max, | 67 | id = ida_alloc_range(&srq_ida->ida, srq_ida->min, srq_ida->max, |
| 90 | GFP_KERNEL); | 68 | GFP_KERNEL); |
| 91 | if (id < 0) { | 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 | return -ENOMEM; | 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); | 74 | srq->srqn = id; |
| 98 | if (ret) { | ||
| 99 | ibdev_err(ibdev, "failed to get SRQC table, ret = %d.\n", ret); | ||
| 100 | goto err_out; | ||
| 101 | } | ||
| 102 | 75 | ||
| 103 | ret = xa_err(xa_store(&srq_table->xa, srq->srqn, srq, GFP_KERNEL)); | 76 | return 0; |
| 104 | if (ret) { | 77 | } |
| 105 | ibdev_err(ibdev, "failed to store SRQC, ret = %d.\n", ret); | 78 | |
| 106 | goto err_put; | 79 | static void free_srqn(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) |
| 107 | } | 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 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); | 91 | mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); |
| 110 | if (IS_ERR_OR_NULL(mailbox)) { | 92 | if (IS_ERR(mailbox)) { |
| 111 | ibdev_err(ibdev, "failed to alloc mailbox for SRQC.\n"); | 93 | ibdev_err(ibdev, "failed to alloc mailbox for SRQC.\n"); |
| 112 | ret = -ENOMEM; | 94 | return PTR_ERR(mailbox); |
| 113 | goto err_xa; | ||
| 114 | } | 95 | } |
| 115 | 96 | ||
| 116 | ret = hr_dev->hw->write_srqc(srq, mailbox->buf); | 97 | ret = hr_dev->hw->write_srqc(srq, mailbox->buf); |
| @@ -119,24 +100,44 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) · 2 unmodified lines | |||
| 119 | goto err_mbox; | 100 | goto err_mbox; |
| 120 | } | 101 | } |
| 121 | 102 | ||
| 122 | ret = hns_roce_hw_create_srq(hr_dev, mailbox, srq->srqn); | 103 | ret = hns_roce_create_hw_ctx(hr_dev, mailbox, HNS_ROCE_CMD_CREATE_SRQ, |
| 123 | if (ret) { | 104 | srq->srqn); |
| 105 | if (ret) | ||
| 124 | ibdev_err(ibdev, "failed to config SRQC, ret = %d.\n", ret); | 106 | ibdev_err(ibdev, "failed to config SRQC, ret = %d.\n", ret); |
| 125 | goto err_mbox; | ||
| 126 | } | ||
| 127 | 107 | ||
| 108 | err_mbox: | ||
| 128 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | 109 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); |
| 110 | return ret; | ||
| 111 | } | ||
| 112 | |||
| 113 | static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) | ||
| 114 | { | ||
| 115 | struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; | ||
| 116 | struct ib_device *ibdev = &hr_dev->ib_dev; | ||
| 117 | int ret; | ||
| 118 | |||
| 119 | ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn); | ||
| 120 | if (ret) { | ||
| 121 | ibdev_err(ibdev, "failed to get SRQC table, ret = %d.\n", ret); | ||
| 122 | return ret; | ||
| 123 | } | ||
| 124 | |||
| 125 | ret = xa_err(xa_store(&srq_table->xa, srq->srqn, srq, GFP_KERNEL)); | ||
| 126 | if (ret) { | ||
| 127 | ibdev_err(ibdev, "failed to store SRQC, ret = %d.\n", ret); | ||
| 128 | goto err_put; | ||
| 129 | } | ||
| 130 | |||
| 131 | ret = hns_roce_create_srqc(hr_dev, srq); | ||
| 132 | if (ret) | ||
| 133 | goto err_xa; | ||
| 129 | 134 | ||
| 130 | return 0; | 135 | return 0; |
| 131 | 136 | ||
| 132 | err_mbox: | ||
| 133 | hns_roce_free_cmd_mailbox(hr_dev, mailbox); | ||
| 134 | err_xa: | 137 | err_xa: |
| 135 | xa_erase(&srq_table->xa, srq->srqn); | 138 | xa_erase(&srq_table->xa, srq->srqn); |
| 136 | err_put: | 139 | err_put: |
| 137 | hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); | 140 | hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); |
| 138 | err_out: | ||
| 139 | ida_free(&srq_ida->ida, id); | ||
| 140 | 141 | ||
| 141 | return ret; | 142 | return ret; |
| 142 | } | 143 | } |
| @@ -146,7 +147,8 @@ static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) · 3 unmodified lines | |||
| 146 | struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; | 147 | struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; |
| 147 | int ret; | 148 | int ret; |
| 148 | 149 | ||
| 149 | ret = hns_roce_hw_destroy_srq(hr_dev, NULL, srq->srqn); | 150 | ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_SRQ, |
| 151 | srq->srqn); | ||
| 150 | if (ret) | 152 | if (ret) |
| 151 | dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n", | 153 | dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n", |
| 152 | ret, srq->srqn); | 154 | ret, srq->srqn); |
| @@ -158,7 +160,6 @@ static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) · 5 unmodified lines | |||
| 158 | wait_for_completion(&srq->free); | 160 | wait_for_completion(&srq->free); |
| 159 | 161 | ||
| 160 | hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); | 162 | hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); |
| 161 | ida_free(&srq_table->srq_ida.ida, (int)srq->srqn); | ||
| 162 | } | 163 | } |
| 163 | 164 | ||
| 164 | static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, | 165 | static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, |
| @@ -406,10 +407,14 @@ int hns_roce_create_srq(struct ib_srq *ib_srq, · 241 unmodified lines | |||
| 406 | if (ret) | 407 | if (ret) |
| 407 | return ret; | 408 | return ret; |
| 408 | 409 | ||
| 409 | ret = alloc_srqc(hr_dev, srq); | 410 | ret = alloc_srqn(hr_dev, srq); |
| 410 | if (ret) | 411 | if (ret) |
| 411 | goto err_srq_buf; | 412 | goto err_srq_buf; |
| 412 | 413 | ||
| 414 | ret = alloc_srqc(hr_dev, srq); | ||
| 415 | if (ret) | ||
| 416 | goto err_srqn; | ||
| 417 | |||
| 413 | if (udata) { | 418 | if (udata) { |
| 414 | resp.srqn = srq->srqn; | 419 | resp.srqn = srq->srqn; |
| 415 | if (ib_copy_to_udata(udata, &resp, | 420 | if (ib_copy_to_udata(udata, &resp, |
| @@ -428,6 +433,8 @@ int hns_roce_create_srq(struct ib_srq *ib_srq, · 12 unmodified lines | |||
| 428 | 433 | ||
| 429 | err_srqc: | 434 | err_srqc: |
| 430 | free_srqc(hr_dev, srq); | 435 | free_srqc(hr_dev, srq); |
| 436 | err_srqn: | ||
| 437 | free_srqn(hr_dev, srq); | ||
| 431 | err_srq_buf: | 438 | err_srq_buf: |
| 432 | free_srq_buf(hr_dev, srq); | 439 | free_srq_buf(hr_dev, srq); |
| 433 | 440 | ||
| @@ -440,6 +447,7 @@ int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) · 6 unmodified lines | |||
| 440 | struct hns_roce_srq *srq = to_hr_srq(ibsrq); | 447 | struct hns_roce_srq *srq = to_hr_srq(ibsrq); |
| 441 | 448 | ||
| 442 | free_srqc(hr_dev, srq); | 449 | free_srqc(hr_dev, srq); |
| 450 | free_srqn(hr_dev, srq); | ||
| 443 | free_srq_buf(hr_dev, srq); | 451 | free_srq_buf(hr_dev, srq); |
| 444 | return 0; | 452 | return 0; |
| 445 | } | 453 | } |
| @@ -1501,15 +1501,14 @@ irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port, · 1500 unmodified lines | |||
| 1501 | * @cm_info: CM info for parent listen node | 1501 | * @cm_info: CM info for parent listen node |
| 1502 | * @cm_parent_listen_node: The parent listen node | 1502 | * @cm_parent_listen_node: The parent listen node |
| 1503 | */ | 1503 | */ |
| 1504 | static enum irdma_status_code | 1504 | static int irdma_del_multiple_qhash(struct irdma_device *iwdev, |
| 1505 | irdma_del_multiple_qhash(struct irdma_device *iwdev, | 1505 | struct irdma_cm_info *cm_info, |
| 1506 | struct irdma_cm_info *cm_info, | 1506 | struct irdma_cm_listener *cm_parent_listen_node) |
| 1507 | struct irdma_cm_listener *cm_parent_listen_node) | ||
| 1508 | { | 1507 | { |
| 1509 | struct irdma_cm_listener *child_listen_node; | 1508 | struct irdma_cm_listener *child_listen_node; |
| 1510 | enum irdma_status_code ret = IRDMA_ERR_CFG; | ||
| 1511 | struct list_head *pos, *tpos; | 1509 | struct list_head *pos, *tpos; |
| 1512 | unsigned long flags; | 1510 | unsigned long flags; |
| 1511 | int ret = -EINVAL; | ||
| 1513 | 1512 | ||
| 1514 | spin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags); | 1513 | spin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags); |
| 1515 | list_for_each_safe (pos, tpos, | 1514 | list_for_each_safe (pos, tpos, |
| @@ -1618,16 +1617,16 @@ u16 irdma_get_vlan_ipv4(u32 *addr) · 102 unmodified lines | |||
| 1618 | * Adds a qhash and a child listen node for every IPv6 address | 1617 | * Adds a qhash and a child listen node for every IPv6 address |
| 1619 | * on the adapter and adds the associated qhash filter | 1618 | * on the adapter and adds the associated qhash filter |
| 1620 | */ | 1619 | */ |
| 1621 | static enum irdma_status_code | 1620 | static int irdma_add_mqh_6(struct irdma_device *iwdev, |
| 1622 | irdma_add_mqh_6(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, | 1621 | struct irdma_cm_info *cm_info, |
| 1623 | struct irdma_cm_listener *cm_parent_listen_node) | 1622 | struct irdma_cm_listener *cm_parent_listen_node) |
| 1624 | { | 1623 | { |
| 1625 | struct net_device *ip_dev; | 1624 | struct net_device *ip_dev; |
| 1626 | struct inet6_dev *idev; | 1625 | struct inet6_dev *idev; |
| 1627 | struct inet6_ifaddr *ifp, *tmp; | 1626 | struct inet6_ifaddr *ifp, *tmp; |
| 1628 | enum irdma_status_code ret = 0; | ||
| 1629 | struct irdma_cm_listener *child_listen_node; | 1627 | struct irdma_cm_listener *child_listen_node; |
| 1630 | unsigned long flags; | 1628 | unsigned long flags; |
| 1629 | int ret = 0; | ||
| 1631 | 1630 | ||
| 1632 | rtnl_lock(); | 1631 | rtnl_lock(); |
| 1633 | for_each_netdev(&init_net, ip_dev) { | 1632 | for_each_netdev(&init_net, ip_dev) { |
| @@ -1653,7 +1652,7 @@ irdma_add_mqh_6(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, · 19 unmodified lines | |||
| 1653 | child_listen_node); | 1652 | child_listen_node); |
| 1654 | if (!child_listen_node) { | 1653 | if (!child_listen_node) { |
| 1655 | ibdev_dbg(&iwdev->ibdev, "CM: listener memory allocation\n"); | 1654 | ibdev_dbg(&iwdev->ibdev, "CM: listener memory allocation\n"); |
| 1656 | ret = IRDMA_ERR_NO_MEMORY; | 1655 | ret = -ENOMEM; |
| 1657 | goto exit; | 1656 | goto exit; |
| 1658 | } | 1657 | } |
| 1659 | 1658 | ||
| @@ -1700,16 +1699,16 @@ exit: · 40 unmodified lines | |||
| 1700 | * Adds a qhash and a child listen node for every IPv4 address | 1699 | * Adds a qhash and a child listen node for every IPv4 address |
| 1701 | * on the adapter and adds the associated qhash filter | 1700 | * on the adapter and adds the associated qhash filter |
| 1702 | */ | 1701 | */ |
| 1703 | static enum irdma_status_code | 1702 | static int irdma_add_mqh_4(struct irdma_device *iwdev, |
| 1704 | irdma_add_mqh_4(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, | 1703 | struct irdma_cm_info *cm_info, |
| 1705 | struct irdma_cm_listener *cm_parent_listen_node) | 1704 | struct irdma_cm_listener *cm_parent_listen_node) |
| 1706 | { | 1705 | { |
| 1707 | struct net_device *ip_dev; | 1706 | struct net_device *ip_dev; |
| 1708 | struct in_device *idev; | 1707 | struct in_device *idev; |
| 1709 | struct irdma_cm_listener *child_listen_node; | 1708 | struct irdma_cm_listener *child_listen_node; |
| 1710 | enum irdma_status_code ret = 0; | ||
| 1711 | unsigned long flags; | 1709 | unsigned long flags; |
| 1712 | const struct in_ifaddr *ifa; | 1710 | const struct in_ifaddr *ifa; |
| 1711 | int ret = 0; | ||
| 1713 | 1712 | ||
| 1714 | rtnl_lock(); | 1713 | rtnl_lock(); |
| 1715 | for_each_netdev(&init_net, ip_dev) { | 1714 | for_each_netdev(&init_net, ip_dev) { |
| @@ -1734,7 +1733,7 @@ irdma_add_mqh_4(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, · 18 unmodified lines | |||
| 1734 | if (!child_listen_node) { | 1733 | if (!child_listen_node) { |
| 1735 | ibdev_dbg(&iwdev->ibdev, "CM: listener memory allocation\n"); | 1734 | ibdev_dbg(&iwdev->ibdev, "CM: listener memory allocation\n"); |
| 1736 | in_dev_put(idev); | 1735 | in_dev_put(idev); |
| 1737 | ret = IRDMA_ERR_NO_MEMORY; | 1736 | ret = -ENOMEM; |
| 1738 | goto exit; | 1737 | goto exit; |
| 1739 | } | 1738 | } |
| 1740 | 1739 | ||
| @@ -1781,9 +1780,9 @@ exit: · 40 unmodified lines | |||
| 1781 | * @cm_info: CM info for parent listen node | 1780 | * @cm_info: CM info for parent listen node |
| 1782 | * @cm_listen_node: The parent listen node | 1781 | * @cm_listen_node: The parent listen node |
| 1783 | */ | 1782 | */ |
| 1784 | static enum irdma_status_code | 1783 | static int irdma_add_mqh(struct irdma_device *iwdev, |
| 1785 | irdma_add_mqh(struct irdma_device *iwdev, struct irdma_cm_info *cm_info, | 1784 | struct irdma_cm_info *cm_info, |
| 1786 | struct irdma_cm_listener *cm_listen_node) | 1785 | struct irdma_cm_listener *cm_listen_node) |
| 1787 | { | 1786 | { |
| 1788 | if (cm_info->ipv4) | 1787 | if (cm_info->ipv4) |
| 1789 | return irdma_add_mqh_4(iwdev, cm_info, cm_listen_node); | 1788 | return irdma_add_mqh_4(iwdev, cm_info, cm_listen_node); |
| @@ -2200,7 +2199,7 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, · 410 unmodified lines | |||
| 2200 | /* set our node specific transport info */ | 2199 | /* set our node specific transport info */ |
| 2201 | cm_node->ipv4 = cm_info->ipv4; | 2200 | cm_node->ipv4 = cm_info->ipv4; |
| 2202 | cm_node->vlan_id = cm_info->vlan_id; | 2201 | cm_node->vlan_id = cm_info->vlan_id; |
| 2203 | if (cm_node->vlan_id >= VLAN_N_VID && iwdev->dcb) | 2202 | if (cm_node->vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode) |
| 2204 | cm_node->vlan_id = 0; | 2203 | cm_node->vlan_id = 0; |
| 2205 | cm_node->tos = cm_info->tos; | 2204 | cm_node->tos = cm_info->tos; |
| 2206 | cm_node->user_pri = cm_info->user_pri; | 2205 | cm_node->user_pri = cm_info->user_pri; |
| @@ -2209,8 +2208,12 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, · 2 unmodified lines | |||
| 2209 | ibdev_warn(&iwdev->ibdev, | 2208 | ibdev_warn(&iwdev->ibdev, |
| 2210 | "application TOS[%d] and remote client TOS[%d] mismatch\n", | 2209 | "application TOS[%d] and remote client TOS[%d] mismatch\n", |
| 2211 | listener->tos, cm_info->tos); | 2210 | listener->tos, cm_info->tos); |
| 2212 | cm_node->tos = max(listener->tos, cm_info->tos); | 2211 | if (iwdev->vsi.dscp_mode) { |
| 2213 | cm_node->user_pri = rt_tos2priority(cm_node->tos); | 2212 | cm_node->user_pri = listener->user_pri; |
| 2213 | } else { | ||
| 2214 | cm_node->tos = max(listener->tos, cm_info->tos); | ||
| 2215 | cm_node->user_pri = rt_tos2priority(cm_node->tos); | ||
| 2216 | } | ||
| 2214 | ibdev_dbg(&iwdev->ibdev, | 2217 | ibdev_dbg(&iwdev->ibdev, |
| 2215 | "DCB: listener: TOS:[%d] UP:[%d]\n", cm_node->tos, | 2218 | "DCB: listener: TOS:[%d] UP:[%d]\n", cm_node->tos, |
| 2216 | cm_node->user_pri); | 2219 | cm_node->user_pri); |
| @@ -3201,8 +3204,7 @@ static void irdma_cm_free_ah_nop(struct irdma_cm_node *cm_node) · 984 unmodified lines | |||
| 3201 | * @iwdev: iwarp device structure | 3204 | * @iwdev: iwarp device structure |
| 3202 | * @rdma_ver: HW version | 3205 | * @rdma_ver: HW version |
| 3203 | */ | 3206 | */ |
| 3204 | enum irdma_status_code irdma_setup_cm_core(struct irdma_device *iwdev, | 3207 | int irdma_setup_cm_core(struct irdma_device *iwdev, u8 rdma_ver) |
| 3205 | u8 rdma_ver) | ||
| 3206 | { | 3208 | { |
| 3207 | struct irdma_cm_core *cm_core = &iwdev->cm_core; | 3209 | struct irdma_cm_core *cm_core = &iwdev->cm_core; |
| 3208 | 3210 | ||
| @@ -3212,7 +3214,7 @@ enum irdma_status_code irdma_setup_cm_core(struct irdma_device *iwdev, · 3 unmodified lines | |||
| 3212 | /* Handles CM event work items send to Iwarp core */ | 3214 | /* Handles CM event work items send to Iwarp core */ |
| 3213 | cm_core->event_wq = alloc_ordered_workqueue("iwarp-event-wq", 0); | 3215 | cm_core->event_wq = alloc_ordered_workqueue("iwarp-event-wq", 0); |
| 3214 | if (!cm_core->event_wq) | 3216 | if (!cm_core->event_wq) |
| 3215 | return IRDMA_ERR_NO_MEMORY; | 3217 | return -ENOMEM; |
| 3216 | 3218 | ||
| 3217 | INIT_LIST_HEAD(&cm_core->listen_list); | 3219 | INIT_LIST_HEAD(&cm_core->listen_list); |
| 3218 | 3220 | ||
| @@ -3835,7 +3837,11 @@ int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) · 616 unmodified lines | |||
| 3835 | cm_info.cm_id = cm_id; | 3837 | cm_info.cm_id = cm_id; |
| 3836 | cm_info.qh_qpid = iwdev->vsi.ilq->qp_id; | 3838 | cm_info.qh_qpid = iwdev->vsi.ilq->qp_id; |
| 3837 | cm_info.tos = cm_id->tos; | 3839 | cm_info.tos = cm_id->tos; |
| 3838 | cm_info.user_pri = rt_tos2priority(cm_id->tos); | 3840 | if (iwdev->vsi.dscp_mode) |
| 3841 | cm_info.user_pri = | ||
| 3842 | iwqp->sc_qp.vsi->dscp_map[irdma_tos2dscp(cm_info.tos)]; | ||
| 3843 | else | ||
| 3844 | cm_info.user_pri = rt_tos2priority(cm_id->tos); | ||
| 3839 | 3845 | ||
| 3840 | if (iwqp->sc_qp.dev->ws_add(iwqp->sc_qp.vsi, cm_info.user_pri)) | 3846 | if (iwqp->sc_qp.dev->ws_add(iwqp->sc_qp.vsi, cm_info.user_pri)) |
| 3841 | return -ENOMEM; | 3847 | return -ENOMEM; |
| @@ -3915,10 +3921,10 @@ int irdma_create_listen(struct iw_cm_id *cm_id, int backlog) · 73 unmodified lines | |||
| 3915 | struct irdma_device *iwdev; | 3921 | struct irdma_device *iwdev; |
| 3916 | struct irdma_cm_listener *cm_listen_node; | 3922 | struct irdma_cm_listener *cm_listen_node; |
| 3917 | struct irdma_cm_info cm_info = {}; | 3923 | struct irdma_cm_info cm_info = {}; |
| 3918 | enum irdma_status_code err; | ||
| 3919 | struct sockaddr_in *laddr; | 3924 | struct sockaddr_in *laddr; |
| 3920 | struct sockaddr_in6 *laddr6; | 3925 | struct sockaddr_in6 *laddr6; |
| 3921 | bool wildcard = false; | 3926 | bool wildcard = false; |
| 3927 | int err; | ||
| 3922 | 3928 | ||
| 3923 | iwdev = to_iwdev(cm_id->device); | 3929 | iwdev = to_iwdev(cm_id->device); |
| 3924 | if (!iwdev) | 3930 | if (!iwdev) |
| @@ -3959,7 +3965,7 @@ int irdma_create_listen(struct iw_cm_id *cm_id, int backlog) · 34 unmodified lines | |||
| 3959 | } | 3965 | } |
| 3960 | } | 3966 | } |
| 3961 | 3967 | ||
| 3962 | if (cm_info.vlan_id >= VLAN_N_VID && iwdev->dcb) | 3968 | if (cm_info.vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode) |
| 3963 | cm_info.vlan_id = 0; | 3969 | cm_info.vlan_id = 0; |
| 3964 | cm_info.backlog = backlog; | 3970 | cm_info.backlog = backlog; |
| 3965 | cm_info.cm_id = cm_id; | 3971 | cm_info.cm_id = cm_id; |
| @@ -3977,7 +3983,11 @@ int irdma_create_listen(struct iw_cm_id *cm_id, int backlog) · 11 unmodified lines | |||
| 3977 | cm_id->provider_data = cm_listen_node; | 3983 | cm_id->provider_data = cm_listen_node; |
| 3978 | 3984 | ||
| 3979 | cm_listen_node->tos = cm_id->tos; | 3985 | cm_listen_node->tos = cm_id->tos; |
| 3980 | cm_listen_node->user_pri = rt_tos2priority(cm_id->tos); | 3986 | if (iwdev->vsi.dscp_mode) |
| 3987 | cm_listen_node->user_pri = | ||
| 3988 | iwdev->vsi.dscp_map[irdma_tos2dscp(cm_id->tos)]; | ||
| 3989 | else | ||
| 3990 | cm_listen_node->user_pri = rt_tos2priority(cm_id->tos); | ||
| 3981 | cm_info.user_pri = cm_listen_node->user_pri; | 3991 | cm_info.user_pri = cm_listen_node->user_pri; |
| 3982 | if (!cm_listen_node->reused_node) { | 3992 | if (!cm_listen_node->reused_node) { |
| 3983 | if (wildcard) { | 3993 | if (wildcard) { |
| @@ -4325,11 +4335,11 @@ static void irdma_qhash_ctrl(struct irdma_device *iwdev, · 341 unmodified lines | |||
| 4325 | struct list_head *child_listen_list = &parent_listen_node->child_listen_list; | 4335 | struct list_head *child_listen_list = &parent_listen_node->child_listen_list; |
| 4326 | struct irdma_cm_listener *child_listen_node; | 4336 | struct irdma_cm_listener *child_listen_node; |
| 4327 | struct list_head *pos, *tpos; | 4337 | struct list_head *pos, *tpos; |
| 4328 | enum irdma_status_code err; | ||
| 4329 | bool node_allocated = false; | 4338 | bool node_allocated = false; |
| 4330 | enum irdma_quad_hash_manage_type op = ifup ? | 4339 | enum irdma_quad_hash_manage_type op = ifup ? |
| 4331 | IRDMA_QHASH_MANAGE_TYPE_ADD : | 4340 | IRDMA_QHASH_MANAGE_TYPE_ADD : |
| 4332 | IRDMA_QHASH_MANAGE_TYPE_DELETE; | 4341 | IRDMA_QHASH_MANAGE_TYPE_DELETE; |
| 4342 | int err; | ||
| 4333 | 4343 | ||
| 4334 | list_for_each_safe (pos, tpos, child_listen_list) { | 4344 | list_for_each_safe (pos, tpos, child_listen_list) { |
| 4335 | child_listen_node = list_entry(pos, struct irdma_cm_listener, | 4345 | child_listen_node = list_entry(pos, struct irdma_cm_listener, |
| @@ -384,6 +384,13 @@ int irdma_schedule_cm_timer(struct irdma_cm_node *cm_node, · 383 unmodified lines | |||
| 384 | struct irdma_puda_buf *sqbuf, | 384 | struct irdma_puda_buf *sqbuf, |
| 385 | enum irdma_timer_type type, int send_retrans, | 385 | enum irdma_timer_type type, int send_retrans, |
| 386 | int close_when_complete); | 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 | int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); | 394 | int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); |
| 388 | int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len); | 395 | int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len); |
| 389 | int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); | 396 | int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); |
| @@ -3,7 +3,6 @@ · 2 unmodified lines | |||
| 3 | #include <linux/etherdevice.h> | 3 | #include <linux/etherdevice.h> |
| 4 | 4 | ||
| 5 | #include "osdep.h" | 5 | #include "osdep.h" |
| 6 | #include "status.h" | ||
| 7 | #include "hmc.h" | 6 | #include "hmc.h" |
| 8 | #include "defs.h" | 7 | #include "defs.h" |
| 9 | #include "type.h" | 8 | #include "type.h" |
| @@ -70,6 +69,31 @@ void irdma_sc_suspend_resume_qps(struct irdma_sc_vsi *vsi, u8 op) · 60 unmodified lines | |||
| 70 | } | 69 | } |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 72 | static void irdma_set_qos_info(struct irdma_sc_vsi *vsi, | ||
| 73 | struct irdma_l2params *l2p) | ||
| 74 | { | ||
| 75 | u8 i; | ||
| 76 | |||
| 77 | vsi->qos_rel_bw = l2p->vsi_rel_bw; | ||
| 78 | vsi->qos_prio_type = l2p->vsi_prio_type; | ||
| 79 | vsi->dscp_mode = l2p->dscp_mode; | ||
| 80 | if (l2p->dscp_mode) { | ||
| 81 | memcpy(vsi->dscp_map, l2p->dscp_map, sizeof(vsi->dscp_map)); | ||
| 82 | for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) | ||
| 83 | l2p->up2tc[i] = i; | ||
| 84 | } | ||
| 85 | for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) { | ||
| 86 | if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) | ||
| 87 | vsi->qos[i].qs_handle = l2p->qs_handle_list[i]; | ||
| 88 | vsi->qos[i].traffic_class = l2p->up2tc[i]; | ||
| 89 | vsi->qos[i].rel_bw = | ||
| 90 | l2p->tc_info[vsi->qos[i].traffic_class].rel_bw; | ||
| 91 | vsi->qos[i].prio_type = | ||
| 92 | l2p->tc_info[vsi->qos[i].traffic_class].prio_type; | ||
| 93 | vsi->qos[i].valid = false; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 73 | /** | 97 | /** |
| 74 | * irdma_change_l2params - given the new l2 parameters, change all qp | 98 | * irdma_change_l2params - given the new l2 parameters, change all qp |
| 75 | * @vsi: RDMA VSI pointer | 99 | * @vsi: RDMA VSI pointer |
| @@ -88,6 +112,7 @@ void irdma_change_l2params(struct irdma_sc_vsi *vsi, · 12 unmodified lines | |||
| 88 | return; | 112 | return; |
| 89 | 113 | ||
| 90 | vsi->tc_change_pending = false; | 114 | vsi->tc_change_pending = false; |
| 115 | irdma_set_qos_info(vsi, l2params); | ||
| 91 | irdma_sc_suspend_resume_qps(vsi, IRDMA_OP_RESUME); | 116 | irdma_sc_suspend_resume_qps(vsi, IRDMA_OP_RESUME); |
| 92 | } | 117 | } |
| 93 | 118 | ||
| @@ -154,17 +179,16 @@ void irdma_sc_pd_init(struct irdma_sc_dev *dev, struct irdma_sc_pd *pd, u32 pd_i · 60 unmodified lines | |||
| 154 | * @scratch: u64 saved to be used during cqp completion | 179 | * @scratch: u64 saved to be used during cqp completion |
| 155 | * @post_sq: flag for cqp db to ring | 180 | * @post_sq: flag for cqp db to ring |
| 156 | */ | 181 | */ |
| 157 | static enum irdma_status_code | 182 | static int irdma_sc_add_arp_cache_entry(struct irdma_sc_cqp *cqp, |
| 158 | irdma_sc_add_arp_cache_entry(struct irdma_sc_cqp *cqp, | 183 | struct irdma_add_arp_cache_entry_info *info, |
| 159 | struct irdma_add_arp_cache_entry_info *info, | 184 | u64 scratch, bool post_sq) |
| 160 | u64 scratch, bool post_sq) | ||
| 161 | { | 185 | { |
| 162 | __le64 *wqe; | 186 | __le64 *wqe; |
| 163 | u64 hdr; | 187 | u64 hdr; |
| 164 | 188 | ||
| 165 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 189 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 166 | if (!wqe) | 190 | if (!wqe) |
| 167 | return IRDMA_ERR_RING_FULL; | 191 | return -ENOMEM; |
| 168 | set_64bit_val(wqe, 8, info->reach_max); | 192 | set_64bit_val(wqe, 8, info->reach_max); |
| 169 | set_64bit_val(wqe, 16, ether_addr_to_u64(info->mac_addr)); | 193 | set_64bit_val(wqe, 16, ether_addr_to_u64(info->mac_addr)); |
| 170 | 194 | ||
| @@ -192,16 +216,15 @@ irdma_sc_add_arp_cache_entry(struct irdma_sc_cqp *cqp, · 21 unmodified lines | |||
| 192 | * @arp_index: arp index to delete arp entry | 216 | * @arp_index: arp index to delete arp entry |
| 193 | * @post_sq: flag for cqp db to ring | 217 | * @post_sq: flag for cqp db to ring |
| 194 | */ | 218 | */ |
| 195 | static enum irdma_status_code | 219 | static int irdma_sc_del_arp_cache_entry(struct irdma_sc_cqp *cqp, u64 scratch, |
| 196 | irdma_sc_del_arp_cache_entry(struct irdma_sc_cqp *cqp, u64 scratch, | 220 | u16 arp_index, bool post_sq) |
| 197 | u16 arp_index, bool post_sq) | ||
| 198 | { | 221 | { |
| 199 | __le64 *wqe; | 222 | __le64 *wqe; |
| 200 | u64 hdr; | 223 | u64 hdr; |
| 201 | 224 | ||
| 202 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 225 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 203 | if (!wqe) | 226 | if (!wqe) |
| 204 | return IRDMA_ERR_RING_FULL; | 227 | return -ENOMEM; |
| 205 | 228 | ||
| 206 | hdr = arp_index | | 229 | hdr = arp_index | |
| 207 | FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_MANAGE_ARP) | | 230 | FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_MANAGE_ARP) | |
| @@ -226,17 +249,16 @@ irdma_sc_del_arp_cache_entry(struct irdma_sc_cqp *cqp, u64 scratch, · 18 unmodified lines | |||
| 226 | * @scratch: u64 saved to be used during cqp completion | 249 | * @scratch: u64 saved to be used during cqp completion |
| 227 | * @post_sq: flag for cqp db to ring | 250 | * @post_sq: flag for cqp db to ring |
| 228 | */ | 251 | */ |
| 229 | static enum irdma_status_code | 252 | static int irdma_sc_manage_apbvt_entry(struct irdma_sc_cqp *cqp, |
| 230 | irdma_sc_manage_apbvt_entry(struct irdma_sc_cqp *cqp, | 253 | struct irdma_apbvt_info *info, |
| 231 | struct irdma_apbvt_info *info, u64 scratch, | 254 | u64 scratch, bool post_sq) |
| 232 | bool post_sq) | ||
| 233 | { | 255 | { |
| 234 | __le64 *wqe; | 256 | __le64 *wqe; |
| 235 | u64 hdr; | 257 | u64 hdr; |
| 236 | 258 | ||
| 237 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 259 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 238 | if (!wqe) | 260 | if (!wqe) |
| 239 | return IRDMA_ERR_RING_FULL; | 261 | return -ENOMEM; |
| 240 | 262 | ||
| 241 | set_64bit_val(wqe, 16, info->port); | 263 | set_64bit_val(wqe, 16, info->port); |
| 242 | 264 | ||
| @@ -274,7 +296,7 @@ irdma_sc_manage_apbvt_entry(struct irdma_sc_cqp *cqp, · 31 unmodified lines | |||
| 274 | * quad hash entry in the hardware will point to iwarp's qp | 296 | * quad hash entry in the hardware will point to iwarp's qp |
| 275 | * number and requires no calls from the driver. | 297 | * number and requires no calls from the driver. |
| 276 | */ | 298 | */ |
| 277 | static enum irdma_status_code | 299 | static int |
| 278 | irdma_sc_manage_qhash_table_entry(struct irdma_sc_cqp *cqp, | 300 | irdma_sc_manage_qhash_table_entry(struct irdma_sc_cqp *cqp, |
| 279 | struct irdma_qhash_table_info *info, | 301 | struct irdma_qhash_table_info *info, |
| 280 | u64 scratch, bool post_sq) | 302 | u64 scratch, bool post_sq) |
| @@ -287,7 +309,7 @@ irdma_sc_manage_qhash_table_entry(struct irdma_sc_cqp *cqp, · 6 unmodified lines | |||
| 287 | 309 | ||
| 288 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 310 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 289 | if (!wqe) | 311 | if (!wqe) |
| 290 | return IRDMA_ERR_RING_FULL; | 312 | return -ENOMEM; |
| 291 | 313 | ||
| 292 | set_64bit_val(wqe, 0, ether_addr_to_u64(info->mac_addr)); | 314 | set_64bit_val(wqe, 0, ether_addr_to_u64(info->mac_addr)); |
| 293 | 315 | ||
| @@ -350,10 +372,9 @@ irdma_sc_manage_qhash_table_entry(struct irdma_sc_cqp *cqp, · 56 unmodified lines | |||
| 350 | * @qp: sc qp | 372 | * @qp: sc qp |
| 351 | * @info: initialization qp info | 373 | * @info: initialization qp info |
| 352 | */ | 374 | */ |
| 353 | enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, | 375 | int irdma_sc_qp_init(struct irdma_sc_qp *qp, struct irdma_qp_init_info *info) |
| 354 | struct irdma_qp_init_info *info) | ||
| 355 | { | 376 | { |
| 356 | enum irdma_status_code ret_code; | 377 | int ret_code; |
| 357 | u32 pble_obj_cnt; | 378 | u32 pble_obj_cnt; |
| 358 | u16 wqe_size; | 379 | u16 wqe_size; |
| 359 | 380 | ||
| @@ -361,7 +382,7 @@ enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, · 1 unmodified line | |||
| 361 | info->pd->dev->hw_attrs.uk_attrs.max_hw_wq_frags || | 382 | info->pd->dev->hw_attrs.uk_attrs.max_hw_wq_frags || |
| 362 | info->qp_uk_init_info.max_rq_frag_cnt > | 383 | info->qp_uk_init_info.max_rq_frag_cnt > |
| 363 | info->pd->dev->hw_attrs.uk_attrs.max_hw_wq_frags) | 384 | info->pd->dev->hw_attrs.uk_attrs.max_hw_wq_frags) |
| 364 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 385 | return -EINVAL; |
| 365 | 386 | ||
| 366 | qp->dev = info->pd->dev; | 387 | qp->dev = info->pd->dev; |
| 367 | qp->vsi = info->vsi; | 388 | qp->vsi = info->vsi; |
| @@ -384,7 +405,7 @@ enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, · 16 unmodified lines | |||
| 384 | 405 | ||
| 385 | if ((info->virtual_map && info->sq_pa >= pble_obj_cnt) || | 406 | if ((info->virtual_map && info->sq_pa >= pble_obj_cnt) || |
| 386 | (info->virtual_map && info->rq_pa >= pble_obj_cnt)) | 407 | (info->virtual_map && info->rq_pa >= pble_obj_cnt)) |
| 387 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 408 | return -EINVAL; |
| 388 | 409 | ||
| 389 | qp->llp_stream_handle = (void *)(-1); | 410 | qp->llp_stream_handle = (void *)(-1); |
| 390 | qp->hw_sq_size = irdma_get_encoded_wqe_size(qp->qp_uk.sq_ring.size, | 411 | qp->hw_sq_size = irdma_get_encoded_wqe_size(qp->qp_uk.sq_ring.size, |
| @@ -424,8 +445,8 @@ enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, · 33 unmodified lines | |||
| 424 | * @scratch: u64 saved to be used during cqp completion | 445 | * @scratch: u64 saved to be used during cqp completion |
| 425 | * @post_sq: flag for cqp db to ring | 446 | * @post_sq: flag for cqp db to ring |
| 426 | */ | 447 | */ |
| 427 | enum irdma_status_code irdma_sc_qp_create(struct irdma_sc_qp *qp, struct irdma_create_qp_info *info, | 448 | int irdma_sc_qp_create(struct irdma_sc_qp *qp, struct irdma_create_qp_info *info, |
| 428 | u64 scratch, bool post_sq) | 449 | u64 scratch, bool post_sq) |
| 429 | { | 450 | { |
| 430 | struct irdma_sc_cqp *cqp; | 451 | struct irdma_sc_cqp *cqp; |
| 431 | __le64 *wqe; | 452 | __le64 *wqe; |
| @@ -433,12 +454,12 @@ enum irdma_status_code irdma_sc_qp_create(struct irdma_sc_qp *qp, struct irdma_c · 1 unmodified line | |||
| 433 | 454 | ||
| 434 | cqp = qp->dev->cqp; | 455 | cqp = qp->dev->cqp; |
| 435 | if (qp->qp_uk.qp_id < cqp->dev->hw_attrs.min_hw_qp_id || | 456 | if (qp->qp_uk.qp_id < cqp->dev->hw_attrs.min_hw_qp_id || |
| 436 | qp->qp_uk.qp_id > (cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_QP].max_cnt - 1)) | 457 | qp->qp_uk.qp_id >= cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_QP].max_cnt) |
| 437 | return IRDMA_ERR_INVALID_QP_ID; | 458 | return -EINVAL; |
| 438 | 459 | ||
| 439 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 460 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 440 | if (!wqe) | 461 | if (!wqe) |
| 441 | return IRDMA_ERR_RING_FULL; | 462 | return -ENOMEM; |
| 442 | 463 | ||
| 443 | set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); | 464 | set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); |
| 444 | set_64bit_val(wqe, 40, qp->shadow_area_pa); | 465 | set_64bit_val(wqe, 40, qp->shadow_area_pa); |
| @@ -475,9 +496,8 @@ enum irdma_status_code irdma_sc_qp_create(struct irdma_sc_qp *qp, struct irdma_c · 30 unmodified lines | |||
| 475 | * @scratch: u64 saved to be used during cqp completion | 496 | * @scratch: u64 saved to be used during cqp completion |
| 476 | * @post_sq: flag for cqp db to ring | 497 | * @post_sq: flag for cqp db to ring |
| 477 | */ | 498 | */ |
| 478 | enum irdma_status_code irdma_sc_qp_modify(struct irdma_sc_qp *qp, | 499 | int irdma_sc_qp_modify(struct irdma_sc_qp *qp, struct irdma_modify_qp_info *info, |
| 479 | struct irdma_modify_qp_info *info, | 500 | u64 scratch, bool post_sq) |
| 480 | u64 scratch, bool post_sq) | ||
| 481 | { | 501 | { |
| 482 | __le64 *wqe; | 502 | __le64 *wqe; |
| 483 | struct irdma_sc_cqp *cqp; | 503 | struct irdma_sc_cqp *cqp; |
| @@ -488,7 +508,7 @@ enum irdma_status_code irdma_sc_qp_modify(struct irdma_sc_qp *qp, · 4 unmodified lines | |||
| 488 | cqp = qp->dev->cqp; | 508 | cqp = qp->dev->cqp; |
| 489 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 509 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 490 | if (!wqe) | 510 | if (!wqe) |
| 491 | return IRDMA_ERR_RING_FULL; | 511 | return -ENOMEM; |
| 492 | 512 | ||
| 493 | if (info->next_iwarp_state == IRDMA_QP_STATE_TERMINATE) { | 513 | if (info->next_iwarp_state == IRDMA_QP_STATE_TERMINATE) { |
| 494 | if (info->dont_send_fin) | 514 | if (info->dont_send_fin) |
| @@ -546,9 +566,8 @@ enum irdma_status_code irdma_sc_qp_modify(struct irdma_sc_qp *qp, · 51 unmodified lines | |||
| 546 | * @ignore_mw_bnd: memory window bind flag | 566 | * @ignore_mw_bnd: memory window bind flag |
| 547 | * @post_sq: flag for cqp db to ring | 567 | * @post_sq: flag for cqp db to ring |
| 548 | */ | 568 | */ |
| 549 | enum irdma_status_code irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, | 569 | int irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, |
| 550 | bool remove_hash_idx, bool ignore_mw_bnd, | 570 | bool remove_hash_idx, bool ignore_mw_bnd, bool post_sq) |
| 551 | bool post_sq) | ||
| 552 | { | 571 | { |
| 553 | __le64 *wqe; | 572 | __le64 *wqe; |
| 554 | struct irdma_sc_cqp *cqp; | 573 | struct irdma_sc_cqp *cqp; |
| @@ -557,7 +576,7 @@ enum irdma_status_code irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, · 2 unmodified lines | |||
| 557 | cqp = qp->dev->cqp; | 576 | cqp = qp->dev->cqp; |
| 558 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 577 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 559 | if (!wqe) | 578 | if (!wqe) |
| 560 | return IRDMA_ERR_RING_FULL; | 579 | return -ENOMEM; |
| 561 | 580 | ||
| 562 | set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); | 581 | set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); |
| 563 | set_64bit_val(wqe, 40, qp->shadow_area_pa); | 582 | set_64bit_val(wqe, 40, qp->shadow_area_pa); |
| @@ -739,16 +758,15 @@ void irdma_sc_qp_setctx_roce(struct irdma_sc_qp *qp, __le64 *qp_ctx, · 175 unmodified lines | |||
| 739 | * @scratch: u64 saved to be used during cqp completion | 758 | * @scratch: u64 saved to be used during cqp completion |
| 740 | * @post_sq: flag for cqp db to ring | 759 | * @post_sq: flag for cqp db to ring |
| 741 | */ | 760 | */ |
| 742 | static enum irdma_status_code | 761 | static int irdma_sc_alloc_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, |
| 743 | irdma_sc_alloc_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, | 762 | bool post_sq) |
| 744 | bool post_sq) | ||
| 745 | { | 763 | { |
| 746 | __le64 *wqe; | 764 | __le64 *wqe; |
| 747 | u64 hdr; | 765 | u64 hdr; |
| 748 | 766 | ||
| 749 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 767 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 750 | if (!wqe) | 768 | if (!wqe) |
| 751 | return IRDMA_ERR_RING_FULL; | 769 | return -ENOMEM; |
| 752 | 770 | ||
| 753 | hdr = FIELD_PREP(IRDMA_CQPSQ_OPCODE, | 771 | hdr = FIELD_PREP(IRDMA_CQPSQ_OPCODE, |
| 754 | IRDMA_CQP_OP_ALLOCATE_LOC_MAC_TABLE_ENTRY) | | 772 | IRDMA_CQP_OP_ALLOCATE_LOC_MAC_TABLE_ENTRY) | |
| @@ -774,17 +792,16 @@ irdma_sc_alloc_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, · 19 unmodified lines | |||
| 774 | * @scratch: u64 saved to be used during cqp completion | 792 | * @scratch: u64 saved to be used during cqp completion |
| 775 | * @post_sq: flag for cqp db to ring | 793 | * @post_sq: flag for cqp db to ring |
| 776 | */ | 794 | */ |
| 777 | static enum irdma_status_code | 795 | static int irdma_sc_add_local_mac_entry(struct irdma_sc_cqp *cqp, |
| 778 | irdma_sc_add_local_mac_entry(struct irdma_sc_cqp *cqp, | 796 | struct irdma_local_mac_entry_info *info, |
| 779 | struct irdma_local_mac_entry_info *info, | 797 | u64 scratch, bool post_sq) |
| 780 | u64 scratch, bool post_sq) | ||
| 781 | { | 798 | { |
| 782 | __le64 *wqe; | 799 | __le64 *wqe; |
| 783 | u64 header; | 800 | u64 header; |
| 784 | 801 | ||
| 785 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 802 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 786 | if (!wqe) | 803 | if (!wqe) |
| 787 | return IRDMA_ERR_RING_FULL; | 804 | return -ENOMEM; |
| 788 | 805 | ||
| 789 | set_64bit_val(wqe, 32, ether_addr_to_u64(info->mac_addr)); | 806 | set_64bit_val(wqe, 32, ether_addr_to_u64(info->mac_addr)); |
| 790 | 807 | ||
| @@ -813,16 +830,16 @@ irdma_sc_add_local_mac_entry(struct irdma_sc_cqp *cqp, · 22 unmodified lines | |||
| 813 | * @ignore_ref_count: to force mac adde delete | 830 | * @ignore_ref_count: to force mac adde delete |
| 814 | * @post_sq: flag for cqp db to ring | 831 | * @post_sq: flag for cqp db to ring |
| 815 | */ | 832 | */ |
| 816 | static enum irdma_status_code | 833 | static int irdma_sc_del_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, |
| 817 | irdma_sc_del_local_mac_entry(struct irdma_sc_cqp *cqp, u64 scratch, | 834 | u16 entry_idx, u8 ignore_ref_count, |
| 818 | u16 entry_idx, u8 ignore_ref_count, bool post_sq) | 835 | bool post_sq) |
| 819 | { | 836 | { |
| 820 | __le64 *wqe; | 837 | __le64 *wqe; |
| 821 | u64 header; | 838 | u64 header; |
| 822 | 839 | ||
| 823 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 840 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 824 | if (!wqe) | 841 | if (!wqe) |
| 825 | return IRDMA_ERR_RING_FULL; | 842 | return -ENOMEM; |
| 826 | header = FIELD_PREP(IRDMA_CQPSQ_MLM_TABLEIDX, entry_idx) | | 843 | header = FIELD_PREP(IRDMA_CQPSQ_MLM_TABLEIDX, entry_idx) | |
| 827 | FIELD_PREP(IRDMA_CQPSQ_OPCODE, | 844 | FIELD_PREP(IRDMA_CQPSQ_OPCODE, |
| 828 | IRDMA_CQP_OP_MANAGE_LOC_MAC_TABLE) | | 845 | IRDMA_CQP_OP_MANAGE_LOC_MAC_TABLE) | |
| @@ -1035,10 +1052,9 @@ void irdma_sc_qp_setctx(struct irdma_sc_qp *qp, __le64 *qp_ctx, · 206 unmodified lines | |||
| 1035 | * @scratch: u64 saved to be used during cqp completion | 1052 | * @scratch: u64 saved to be used during cqp completion |
| 1036 | * @post_sq: flag for cqp db to ring | 1053 | * @post_sq: flag for cqp db to ring |
| 1037 | */ | 1054 | */ |
| 1038 | static enum irdma_status_code | 1055 | static int irdma_sc_alloc_stag(struct irdma_sc_dev *dev, |
| 1039 | irdma_sc_alloc_stag(struct irdma_sc_dev *dev, | 1056 | struct irdma_allocate_stag_info *info, |
| 1040 | struct irdma_allocate_stag_info *info, u64 scratch, | 1057 | u64 scratch, bool post_sq) |
| 1041 | bool post_sq) | ||
| 1042 | { | 1058 | { |
| 1043 | __le64 *wqe; | 1059 | __le64 *wqe; |
| 1044 | struct irdma_sc_cqp *cqp; | 1060 | struct irdma_sc_cqp *cqp; |
| @@ -1055,7 +1071,7 @@ irdma_sc_alloc_stag(struct irdma_sc_dev *dev, · 10 unmodified lines | |||
| 1055 | cqp = dev->cqp; | 1071 | cqp = dev->cqp; |
| 1056 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 1072 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 1057 | if (!wqe) | 1073 | if (!wqe) |
| 1058 | return IRDMA_ERR_RING_FULL; | 1074 | return -ENOMEM; |
| 1059 | 1075 | ||
| 1060 | set_64bit_val(wqe, 8, | 1076 | set_64bit_val(wqe, 8, |
| 1061 | FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID) | | 1077 | FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID) | |
| @@ -1097,10 +1113,9 @@ irdma_sc_alloc_stag(struct irdma_sc_dev *dev, · 35 unmodified lines | |||
| 1097 | * @scratch: u64 saved to be used during cqp completion | 1113 | * @scratch: u64 saved to be used during cqp completion |
| 1098 | * @post_sq: flag for cqp db to ring | 1114 | * @post_sq: flag for cqp db to ring |
| 1099 | */ | 1115 | */ |
| 1100 | static enum irdma_status_code | 1116 | static int irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, |
| 1101 | irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, | 1117 | struct irdma_reg_ns_stag_info *info, |
| 1102 | struct irdma_reg_ns_stag_info *info, u64 scratch, | 1118 | u64 scratch, bool post_sq) |
| 1103 | bool post_sq) | ||
| 1104 | { | 1119 | { |
| 1105 | __le64 *wqe; | 1120 | __le64 *wqe; |
| 1106 | u64 fbo; | 1121 | u64 fbo; |
| @@ -1118,7 +1133,7 @@ irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, · 11 unmodified lines | |||
| 1118 | else if (info->page_size == 0x1000) | 1133 | else if (info->page_size == 0x1000) |
| 1119 | page_size = IRDMA_PAGE_SIZE_4K; | 1134 | page_size = IRDMA_PAGE_SIZE_4K; |
| 1120 | else | 1135 | else |
| 1121 | return IRDMA_ERR_PARAM; | 1136 | return -EINVAL; |
| 1122 | 1137 | ||
| 1123 | if (info->access_rights & (IRDMA_ACCESS_FLAGS_REMOTEREAD_ONLY | | 1138 | if (info->access_rights & (IRDMA_ACCESS_FLAGS_REMOTEREAD_ONLY | |
| 1124 | IRDMA_ACCESS_FLAGS_REMOTEWRITE_ONLY)) | 1139 | IRDMA_ACCESS_FLAGS_REMOTEWRITE_ONLY)) |
| @@ -1128,12 +1143,12 @@ irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, · 3 unmodified lines | |||
| 1128 | 1143 | ||
| 1129 | pble_obj_cnt = dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; | 1144 | pble_obj_cnt = dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; |
| 1130 | if (info->chunk_size && info->first_pm_pbl_index >= pble_obj_cnt) | 1145 | if (info->chunk_size && info->first_pm_pbl_index >= pble_obj_cnt) |
| 1131 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 1146 | return -EINVAL; |
| 1132 | 1147 | ||
| 1133 | cqp = dev->cqp; | 1148 | cqp = dev->cqp; |
| 1134 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 1149 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 1135 | if (!wqe) | 1150 | if (!wqe) |
| 1136 | return IRDMA_ERR_RING_FULL; | 1151 | return -ENOMEM; |
| 1137 | fbo = info->va & (info->page_size - 1); | 1152 | fbo = info->va & (info->page_size - 1); |
| 1138 | 1153 | ||
| 1139 | set_64bit_val(wqe, 0, | 1154 | set_64bit_val(wqe, 0, |
| @@ -1186,10 +1201,9 @@ irdma_sc_mr_reg_non_shared(struct irdma_sc_dev *dev, · 46 unmodified lines | |||
| 1186 | * @scratch: u64 saved to be used during cqp completion | 1201 | * @scratch: u64 saved to be used during cqp completion |
| 1187 | * @post_sq: flag for cqp db to ring | 1202 | * @post_sq: flag for cqp db to ring |
| 1188 | */ | 1203 | */ |
| 1189 | static enum irdma_status_code | 1204 | static int irdma_sc_dealloc_stag(struct irdma_sc_dev *dev, |
| 1190 | irdma_sc_dealloc_stag(struct irdma_sc_dev *dev, | 1205 | struct irdma_dealloc_stag_info *info, |
| 1191 | struct irdma_dealloc_stag_info *info, u64 scratch, | 1206 | u64 scratch, bool post_sq) |
| 1192 | bool post_sq) | ||
| 1193 | { | 1207 | { |
| 1194 | u64 hdr; | 1208 | u64 hdr; |
| 1195 | __le64 *wqe; | 1209 | __le64 *wqe; |
| @@ -1198,7 +1212,7 @@ irdma_sc_dealloc_stag(struct irdma_sc_dev *dev, · 2 unmodified lines | |||
| 1198 | cqp = dev->cqp; | 1212 | cqp = dev->cqp; |
| 1199 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 1213 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 1200 | if (!wqe) | 1214 | if (!wqe) |
| 1201 | return IRDMA_ERR_RING_FULL; | 1215 | return -ENOMEM; |
| 1202 | 1216 | ||
| 1203 | set_64bit_val(wqe, 8, | 1217 | set_64bit_val(wqe, 8, |
| 1204 | FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID)); | 1218 | FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID)); |
| @@ -1227,9 +1241,9 @@ irdma_sc_dealloc_stag(struct irdma_sc_dev *dev, · 22 unmodified lines | |||
| 1227 | * @scratch: u64 saved to be used during cqp completion | 1241 | * @scratch: u64 saved to be used during cqp completion |
| 1228 | * @post_sq: flag for cqp db to ring | 1242 | * @post_sq: flag for cqp db to ring |
| 1229 | */ | 1243 | */ |
| 1230 | static enum irdma_status_code | 1244 | static int irdma_sc_mw_alloc(struct irdma_sc_dev *dev, |
| 1231 | irdma_sc_mw_alloc(struct irdma_sc_dev *dev, struct irdma_mw_alloc_info *info, | 1245 | struct irdma_mw_alloc_info *info, u64 scratch, |
| 1232 | u64 scratch, bool post_sq) | 1246 | bool post_sq) |
| 1233 | { | 1247 | { |
| 1234 | u64 hdr; | 1248 | u64 hdr; |
| 1235 | struct irdma_sc_cqp *cqp; | 1249 | struct irdma_sc_cqp *cqp; |
| @@ -1238,7 +1252,7 @@ irdma_sc_mw_alloc(struct irdma_sc_dev *dev, struct irdma_mw_alloc_info *info, · 2 unmodified lines | |||
| 1238 | cqp = dev->cqp; | 1252 | cqp = dev->cqp; |
| 1239 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 1253 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 1240 | if (!wqe) | 1254 | if (!wqe) |
| 1241 | return IRDMA_ERR_RING_FULL; | 1255 | return -ENOMEM; |
| 1242 | 1256 | ||
| 1243 | set_64bit_val(wqe, 8, | 1257 | set_64bit_val(wqe, 8, |
| 1244 | FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID)); | 1258 | FLD_LS_64(dev, info->pd_id, IRDMA_CQPSQ_STAG_PDID)); |
| @@ -1268,9 +1282,9 @@ irdma_sc_mw_alloc(struct irdma_sc_dev *dev, struct irdma_mw_alloc_info *info, · 23 unmodified lines | |||
| 1268 | * @info: fast mr info | 1282 | * @info: fast mr info |
| 1269 | * @post_sq: flag for cqp db to ring | 1283 | * @post_sq: flag for cqp db to ring |
| 1270 | */ | 1284 | */ |
| 1271 | enum irdma_status_code | 1285 | int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, |
| 1272 | irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, | 1286 | struct irdma_fast_reg_stag_info *info, |
| 1273 | struct irdma_fast_reg_stag_info *info, bool post_sq) | 1287 | bool post_sq) |
| 1274 | { | 1288 | { |
| 1275 | u64 temp, hdr; | 1289 | u64 temp, hdr; |
| 1276 | __le64 *wqe; | 1290 | __le64 *wqe; |
| @@ -1292,7 +1306,7 @@ irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, · 15 unmodified lines | |||
| 1292 | wqe = irdma_qp_get_next_send_wqe(&qp->qp_uk, &wqe_idx, | 1306 | wqe = irdma_qp_get_next_send_wqe(&qp->qp_uk, &wqe_idx, |
| 1293 | IRDMA_QP_WQE_MIN_QUANTA, 0, &sq_info); | 1307 | IRDMA_QP_WQE_MIN_QUANTA, 0, &sq_info); |
| 1294 | if (!wqe) | 1308 | if (!wqe) |
| 1295 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 1309 | return -ENOMEM; |
| 1296 | 1310 | ||
| 1297 | irdma_clr_wqes(&qp->qp_uk, wqe_idx); | 1311 | irdma_clr_wqes(&qp->qp_uk, wqe_idx); |
| 1298 | 1312 | ||
| @@ -1821,8 +1835,7 @@ void irdma_terminate_received(struct irdma_sc_qp *qp, · 522 unmodified lines | |||
| 1821 | } | 1835 | } |
| 1822 | } | 1836 | } |
| 1823 | 1837 | ||
| 1824 | static enum irdma_status_code irdma_null_ws_add(struct irdma_sc_vsi *vsi, | 1838 | static int irdma_null_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) |
| 1825 | u8 user_pri) | ||
| 1826 | { | 1839 | { |
| 1827 | return 0; | 1840 | return 0; |
| 1828 | } | 1841 | } |
| @@ -1845,7 +1858,6 @@ static void irdma_null_ws_reset(struct irdma_sc_vsi *vsi) · 16 unmodified lines | |||
| 1845 | void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, | 1858 | void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, |
| 1846 | struct irdma_vsi_init_info *info) | 1859 | struct irdma_vsi_init_info *info) |
| 1847 | { | 1860 | { |
| 1848 | struct irdma_l2params *l2p; | ||
| 1849 | int i; | 1861 | int i; |
| 1850 | 1862 | ||
| 1851 | vsi->dev = info->dev; | 1863 | vsi->dev = info->dev; |
| @@ -1858,18 +1870,8 @@ void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, · 6 unmodified lines | |||
| 1858 | if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) | 1870 | if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) |
| 1859 | vsi->fcn_id = info->dev->hmc_fn_id; | 1871 | vsi->fcn_id = info->dev->hmc_fn_id; |
| 1860 | 1872 | ||
| 1861 | l2p = info->params; | 1873 | irdma_set_qos_info(vsi, info->params); |
| 1862 | vsi->qos_rel_bw = l2p->vsi_rel_bw; | ||
| 1863 | vsi->qos_prio_type = l2p->vsi_prio_type; | ||
| 1864 | for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) { | 1874 | for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) { |
| 1865 | if (vsi->dev->hw_attrs.uk_attrs.hw_rev == IRDMA_GEN_1) | ||
| 1866 | vsi->qos[i].qs_handle = l2p->qs_handle_list[i]; | ||
| 1867 | vsi->qos[i].traffic_class = info->params->up2tc[i]; | ||
| 1868 | vsi->qos[i].rel_bw = | ||
| 1869 | l2p->tc_info[vsi->qos[i].traffic_class].rel_bw; | ||
| 1870 | vsi->qos[i].prio_type = | ||
| 1871 | l2p->tc_info[vsi->qos[i].traffic_class].prio_type; | ||
| 1872 | vsi->qos[i].valid = false; | ||
| 1873 | mutex_init(&vsi->qos[i].qos_mutex); | 1875 | mutex_init(&vsi->qos[i].qos_mutex); |
| 1874 | INIT_LIST_HEAD(&vsi->qos[i].qplist); | 1876 | INIT_LIST_HEAD(&vsi->qos[i].qplist); |
| 1875 | } | 1877 | } |
| @@ -1918,8 +1920,8 @@ static u8 irdma_get_fcn_id(struct irdma_sc_vsi *vsi) · 42 unmodified lines | |||
| 1918 | * @vsi: pointer to the vsi structure | 1920 | * @vsi: pointer to the vsi structure |
| 1919 | * @info: The info structure used for initialization | 1921 | * @info: The info structure used for initialization |
| 1920 | */ | 1922 | */ |
| 1921 | enum irdma_status_code irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, | 1923 | int irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, |
| 1922 | struct irdma_vsi_stats_info *info) | 1924 | struct irdma_vsi_stats_info *info) |
| 1923 | { | 1925 | { |
| 1924 | u8 fcn_id = info->fcn_id; | 1926 | u8 fcn_id = info->fcn_id; |
| 1925 | struct irdma_dma_mem *stats_buff_mem; | 1927 | struct irdma_dma_mem *stats_buff_mem; |
| @@ -1934,7 +1936,7 @@ enum irdma_status_code irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, · 8 unmodified lines | |||
| 1934 | &stats_buff_mem->pa, | 1936 | &stats_buff_mem->pa, |
| 1935 | GFP_KERNEL); | 1937 | GFP_KERNEL); |
| 1936 | if (!stats_buff_mem->va) | 1938 | if (!stats_buff_mem->va) |
| 1937 | return IRDMA_ERR_NO_MEMORY; | 1939 | return -ENOMEM; |
| 1938 | 1940 | ||
| 1939 | vsi->pestat->gather_info.gather_stats_va = stats_buff_mem->va; | 1941 | vsi->pestat->gather_info.gather_stats_va = stats_buff_mem->va; |
| 1940 | vsi->pestat->gather_info.last_gather_stats_va = | 1942 | vsi->pestat->gather_info.last_gather_stats_va = |
| @@ -1961,7 +1963,7 @@ stats_error: · 20 unmodified lines | |||
| 1961 | stats_buff_mem->va, stats_buff_mem->pa); | 1963 | stats_buff_mem->va, stats_buff_mem->pa); |
| 1962 | stats_buff_mem->va = NULL; | 1964 | stats_buff_mem->va = NULL; |
| 1963 | 1965 | ||
| 1964 | return IRDMA_ERR_CQP_COMPL_ERROR; | 1966 | return -EIO; |
| 1965 | } | 1967 | } |
| 1966 | 1968 | ||
| 1967 | /** | 1969 | /** |
| @@ -2023,19 +2025,19 @@ u8 irdma_get_encoded_wqe_size(u32 wqsize, enum irdma_queue_type queue_type) · 55 unmodified lines | |||
| 2023 | * @info: gather stats info structure | 2025 | * @info: gather stats info structure |
| 2024 | * @scratch: u64 saved to be used during cqp completion | 2026 | * @scratch: u64 saved to be used during cqp completion |
| 2025 | */ | 2027 | */ |
| 2026 | static enum irdma_status_code | 2028 | static int irdma_sc_gather_stats(struct irdma_sc_cqp *cqp, |
| 2027 | irdma_sc_gather_stats(struct irdma_sc_cqp *cqp, | 2029 | struct irdma_stats_gather_info *info, |
| 2028 | struct irdma_stats_gather_info *info, u64 scratch) | 2030 | u64 scratch) |
| 2029 | { | 2031 | { |
| 2030 | __le64 *wqe; | 2032 | __le64 *wqe; |
| 2031 | u64 temp; | 2033 | u64 temp; |
| 2032 | 2034 | ||
| 2033 | if (info->stats_buff_mem.size < IRDMA_GATHER_STATS_BUF_SIZE) | 2035 | if (info->stats_buff_mem.size < IRDMA_GATHER_STATS_BUF_SIZE) |
| 2034 | return IRDMA_ERR_BUF_TOO_SHORT; | 2036 | return -ENOMEM; |
| 2035 | 2037 | ||
| 2036 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2038 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2037 | if (!wqe) | 2039 | if (!wqe) |
| 2038 | return IRDMA_ERR_RING_FULL; | 2040 | return -ENOMEM; |
| 2039 | 2041 | ||
| 2040 | set_64bit_val(wqe, 40, | 2042 | set_64bit_val(wqe, 40, |
| 2041 | FIELD_PREP(IRDMA_CQPSQ_STATS_HMC_FCN_INDEX, info->hmc_fcn_index)); | 2043 | FIELD_PREP(IRDMA_CQPSQ_STATS_HMC_FCN_INDEX, info->hmc_fcn_index)); |
| @@ -2070,17 +2072,16 @@ irdma_sc_gather_stats(struct irdma_sc_cqp *cqp, · 28 unmodified lines | |||
| 2070 | * @alloc: alloc vs. delete flag | 2072 | * @alloc: alloc vs. delete flag |
| 2071 | * @scratch: u64 saved to be used during cqp completion | 2073 | * @scratch: u64 saved to be used during cqp completion |
| 2072 | */ | 2074 | */ |
| 2073 | static enum irdma_status_code | 2075 | static int irdma_sc_manage_stats_inst(struct irdma_sc_cqp *cqp, |
| 2074 | irdma_sc_manage_stats_inst(struct irdma_sc_cqp *cqp, | 2076 | struct irdma_stats_inst_info *info, |
| 2075 | struct irdma_stats_inst_info *info, bool alloc, | 2077 | bool alloc, u64 scratch) |
| 2076 | u64 scratch) | ||
| 2077 | { | 2078 | { |
| 2078 | __le64 *wqe; | 2079 | __le64 *wqe; |
| 2079 | u64 temp; | 2080 | u64 temp; |
| 2080 | 2081 | ||
| 2081 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2082 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2082 | if (!wqe) | 2083 | if (!wqe) |
| 2083 | return IRDMA_ERR_RING_FULL; | 2084 | return -ENOMEM; |
| 2084 | 2085 | ||
| 2085 | set_64bit_val(wqe, 40, | 2086 | set_64bit_val(wqe, 40, |
| 2086 | FIELD_PREP(IRDMA_CQPSQ_STATS_HMC_FCN_INDEX, info->hmc_fn_id)); | 2087 | FIELD_PREP(IRDMA_CQPSQ_STATS_HMC_FCN_INDEX, info->hmc_fn_id)); |
| @@ -2108,9 +2109,8 @@ irdma_sc_manage_stats_inst(struct irdma_sc_cqp *cqp, · 21 unmodified lines | |||
| 2108 | * @info: User priority map info | 2109 | * @info: User priority map info |
| 2109 | * @scratch: u64 saved to be used during cqp completion | 2110 | * @scratch: u64 saved to be used during cqp completion |
| 2110 | */ | 2111 | */ |
| 2111 | static enum irdma_status_code irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, | 2112 | static int irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, |
| 2112 | struct irdma_up_info *info, | 2113 | struct irdma_up_info *info, u64 scratch) |
| 2113 | u64 scratch) | ||
| 2114 | { | 2114 | { |
| 2115 | __le64 *wqe; | 2115 | __le64 *wqe; |
| 2116 | u64 temp = 0; | 2116 | u64 temp = 0; |
| @@ -2118,7 +2118,7 @@ static enum irdma_status_code irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, · 1 unmodified line | |||
| 2118 | 2118 | ||
| 2119 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2119 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2120 | if (!wqe) | 2120 | if (!wqe) |
| 2121 | return IRDMA_ERR_RING_FULL; | 2121 | return -ENOMEM; |
| 2122 | 2122 | ||
| 2123 | for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) | 2123 | for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) |
| 2124 | temp |= (u64)info->map[i] << (i * 8); | 2124 | temp |= (u64)info->map[i] << (i * 8); |
| @@ -2151,17 +2151,16 @@ static enum irdma_status_code irdma_sc_set_up_map(struct irdma_sc_cqp *cqp, · 26 unmodified lines | |||
| 2151 | * @node_op: 0 for add 1 for modify, 2 for delete | 2151 | * @node_op: 0 for add 1 for modify, 2 for delete |
| 2152 | * @scratch: u64 saved to be used during cqp completion | 2152 | * @scratch: u64 saved to be used during cqp completion |
| 2153 | */ | 2153 | */ |
| 2154 | static enum irdma_status_code | 2154 | static int irdma_sc_manage_ws_node(struct irdma_sc_cqp *cqp, |
| 2155 | irdma_sc_manage_ws_node(struct irdma_sc_cqp *cqp, | 2155 | struct irdma_ws_node_info *info, |
| 2156 | struct irdma_ws_node_info *info, | 2156 | enum irdma_ws_node_op node_op, u64 scratch) |
| 2157 | enum irdma_ws_node_op node_op, u64 scratch) | ||
| 2158 | { | 2157 | { |
| 2159 | __le64 *wqe; | 2158 | __le64 *wqe; |
| 2160 | u64 temp = 0; | 2159 | u64 temp = 0; |
| 2161 | 2160 | ||
| 2162 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2161 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2163 | if (!wqe) | 2162 | if (!wqe) |
| 2164 | return IRDMA_ERR_RING_FULL; | 2163 | return -ENOMEM; |
| 2165 | 2164 | ||
| 2166 | set_64bit_val(wqe, 32, | 2165 | set_64bit_val(wqe, 32, |
| 2167 | FIELD_PREP(IRDMA_CQPSQ_WS_VSI, info->vsi) | | 2166 | FIELD_PREP(IRDMA_CQPSQ_WS_VSI, info->vsi) | |
| @@ -2194,9 +2193,9 @@ irdma_sc_manage_ws_node(struct irdma_sc_cqp *cqp, · 26 unmodified lines | |||
| 2194 | * @scratch: u64 saved to be used during cqp completion | 2193 | * @scratch: u64 saved to be used during cqp completion |
| 2195 | * @post_sq: flag for cqp db to ring | 2194 | * @post_sq: flag for cqp db to ring |
| 2196 | */ | 2195 | */ |
| 2197 | enum irdma_status_code irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, | 2196 | int irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, |
| 2198 | struct irdma_qp_flush_info *info, | 2197 | struct irdma_qp_flush_info *info, u64 scratch, |
| 2199 | u64 scratch, bool post_sq) | 2198 | bool post_sq) |
| 2200 | { | 2199 | { |
| 2201 | u64 temp = 0; | 2200 | u64 temp = 0; |
| 2202 | __le64 *wqe; | 2201 | __le64 *wqe; |
| @@ -2215,13 +2214,13 @@ enum irdma_status_code irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, · 12 unmodified lines | |||
| 2215 | ibdev_dbg(to_ibdev(qp->dev), | 2214 | ibdev_dbg(to_ibdev(qp->dev), |
| 2216 | "CQP: Additional flush request ignored for qp %x\n", | 2215 | "CQP: Additional flush request ignored for qp %x\n", |
| 2217 | qp->qp_uk.qp_id); | 2216 | qp->qp_uk.qp_id); |
| 2218 | return IRDMA_ERR_FLUSHED_Q; | 2217 | return -EALREADY; |
| 2219 | } | 2218 | } |
| 2220 | 2219 | ||
| 2221 | cqp = qp->pd->dev->cqp; | 2220 | cqp = qp->pd->dev->cqp; |
| 2222 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2221 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2223 | if (!wqe) | 2222 | if (!wqe) |
| 2224 | return IRDMA_ERR_RING_FULL; | 2223 | return -ENOMEM; |
| 2225 | 2224 | ||
| 2226 | if (info->userflushcode) { | 2225 | if (info->userflushcode) { |
| 2227 | if (flush_rq) | 2226 | if (flush_rq) |
| @@ -2268,9 +2267,9 @@ enum irdma_status_code irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, · 40 unmodified lines | |||
| 2268 | * @scratch: u64 saved to be used during cqp completion | 2267 | * @scratch: u64 saved to be used during cqp completion |
| 2269 | * @post_sq: flag for cqp db to ring | 2268 | * @post_sq: flag for cqp db to ring |
| 2270 | */ | 2269 | */ |
| 2271 | static enum irdma_status_code irdma_sc_gen_ae(struct irdma_sc_qp *qp, | 2270 | static int irdma_sc_gen_ae(struct irdma_sc_qp *qp, |
| 2272 | struct irdma_gen_ae_info *info, | 2271 | struct irdma_gen_ae_info *info, u64 scratch, |
| 2273 | u64 scratch, bool post_sq) | 2272 | bool post_sq) |
| 2274 | { | 2273 | { |
| 2275 | u64 temp; | 2274 | u64 temp; |
| 2276 | __le64 *wqe; | 2275 | __le64 *wqe; |
| @@ -2280,7 +2279,7 @@ static enum irdma_status_code irdma_sc_gen_ae(struct irdma_sc_qp *qp, · 3 unmodified lines | |||
| 2280 | cqp = qp->pd->dev->cqp; | 2279 | cqp = qp->pd->dev->cqp; |
| 2281 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2280 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2282 | if (!wqe) | 2281 | if (!wqe) |
| 2283 | return IRDMA_ERR_RING_FULL; | 2282 | return -ENOMEM; |
| 2284 | 2283 | ||
| 2285 | temp = info->ae_code | FIELD_PREP(IRDMA_CQPSQ_FWQE_AESOURCE, | 2284 | temp = info->ae_code | FIELD_PREP(IRDMA_CQPSQ_FWQE_AESOURCE, |
| 2286 | info->ae_src); | 2285 | info->ae_src); |
| @@ -2308,10 +2307,9 @@ static enum irdma_status_code irdma_sc_gen_ae(struct irdma_sc_qp *qp, · 21 unmodified lines | |||
| 2308 | * @scratch: u64 saved to be used during cqp completion | 2307 | * @scratch: u64 saved to be used during cqp completion |
| 2309 | * @post_sq: flag for cqp db to ring | 2308 | * @post_sq: flag for cqp db to ring |
| 2310 | */ | 2309 | */ |
| 2311 | static enum irdma_status_code | 2310 | static int irdma_sc_qp_upload_context(struct irdma_sc_dev *dev, |
| 2312 | irdma_sc_qp_upload_context(struct irdma_sc_dev *dev, | 2311 | struct irdma_upload_context_info *info, |
| 2313 | struct irdma_upload_context_info *info, u64 scratch, | 2312 | u64 scratch, bool post_sq) |
| 2314 | bool post_sq) | ||
| 2315 | { | 2313 | { |
| 2316 | __le64 *wqe; | 2314 | __le64 *wqe; |
| 2317 | struct irdma_sc_cqp *cqp; | 2315 | struct irdma_sc_cqp *cqp; |
| @@ -2320,7 +2318,7 @@ irdma_sc_qp_upload_context(struct irdma_sc_dev *dev, · 2 unmodified lines | |||
| 2320 | cqp = dev->cqp; | 2318 | cqp = dev->cqp; |
| 2321 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2319 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2322 | if (!wqe) | 2320 | if (!wqe) |
| 2323 | return IRDMA_ERR_RING_FULL; | 2321 | return -ENOMEM; |
| 2324 | 2322 | ||
| 2325 | set_64bit_val(wqe, 16, info->buf_pa); | 2323 | set_64bit_val(wqe, 16, info->buf_pa); |
| 2326 | 2324 | ||
| @@ -2349,21 +2347,20 @@ irdma_sc_qp_upload_context(struct irdma_sc_dev *dev, · 22 unmodified lines | |||
| 2349 | * @scratch: u64 saved to be used during cqp completion | 2347 | * @scratch: u64 saved to be used during cqp completion |
| 2350 | * @post_sq: flag for cqp db to ring | 2348 | * @post_sq: flag for cqp db to ring |
| 2351 | */ | 2349 | */ |
| 2352 | static enum irdma_status_code | 2350 | static int irdma_sc_manage_push_page(struct irdma_sc_cqp *cqp, |
| 2353 | irdma_sc_manage_push_page(struct irdma_sc_cqp *cqp, | 2351 | struct irdma_cqp_manage_push_page_info *info, |
| 2354 | struct irdma_cqp_manage_push_page_info *info, | 2352 | u64 scratch, bool post_sq) |
| 2355 | u64 scratch, bool post_sq) | ||
| 2356 | { | 2353 | { |
| 2357 | __le64 *wqe; | 2354 | __le64 *wqe; |
| 2358 | u64 hdr; | 2355 | u64 hdr; |
| 2359 | 2356 | ||
| 2360 | if (info->free_page && | 2357 | if (info->free_page && |
| 2361 | info->push_idx >= cqp->dev->hw_attrs.max_hw_device_pages) | 2358 | info->push_idx >= cqp->dev->hw_attrs.max_hw_device_pages) |
| 2362 | return IRDMA_ERR_INVALID_PUSH_PAGE_INDEX; | 2359 | return -EINVAL; |
| 2363 | 2360 | ||
| 2364 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2361 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2365 | if (!wqe) | 2362 | if (!wqe) |
| 2366 | return IRDMA_ERR_RING_FULL; | 2363 | return -ENOMEM; |
| 2367 | 2364 | ||
| 2368 | set_64bit_val(wqe, 16, info->qs_handle); | 2365 | set_64bit_val(wqe, 16, info->qs_handle); |
| 2369 | hdr = FIELD_PREP(IRDMA_CQPSQ_MPP_PPIDX, info->push_idx) | | 2366 | hdr = FIELD_PREP(IRDMA_CQPSQ_MPP_PPIDX, info->push_idx) | |
| @@ -2389,16 +2386,15 @@ irdma_sc_manage_push_page(struct irdma_sc_cqp *cqp, · 19 unmodified lines | |||
| 2389 | * @qp: sc qp struct | 2386 | * @qp: sc qp struct |
| 2390 | * @scratch: u64 saved to be used during cqp completion | 2387 | * @scratch: u64 saved to be used during cqp completion |
| 2391 | */ | 2388 | */ |
| 2392 | static enum irdma_status_code irdma_sc_suspend_qp(struct irdma_sc_cqp *cqp, | 2389 | static int irdma_sc_suspend_qp(struct irdma_sc_cqp *cqp, struct irdma_sc_qp *qp, |
| 2393 | struct irdma_sc_qp *qp, | 2390 | u64 scratch) |
| 2394 | u64 scratch) | ||
| 2395 | { | 2391 | { |
| 2396 | u64 hdr; | 2392 | u64 hdr; |
| 2397 | __le64 *wqe; | 2393 | __le64 *wqe; |
| 2398 | 2394 | ||
| 2399 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2395 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2400 | if (!wqe) | 2396 | if (!wqe) |
| 2401 | return IRDMA_ERR_RING_FULL; | 2397 | return -ENOMEM; |
| 2402 | 2398 | ||
| 2403 | hdr = FIELD_PREP(IRDMA_CQPSQ_SUSPENDQP_QPID, qp->qp_uk.qp_id) | | 2399 | hdr = FIELD_PREP(IRDMA_CQPSQ_SUSPENDQP_QPID, qp->qp_uk.qp_id) | |
| 2404 | FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_SUSPEND_QP) | | 2400 | FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_SUSPEND_QP) | |
| @@ -2420,16 +2416,15 @@ static enum irdma_status_code irdma_sc_suspend_qp(struct irdma_sc_cqp *cqp, · 15 unmodified lines | |||
| 2420 | * @qp: sc qp struct | 2416 | * @qp: sc qp struct |
| 2421 | * @scratch: u64 saved to be used during cqp completion | 2417 | * @scratch: u64 saved to be used during cqp completion |
| 2422 | */ | 2418 | */ |
| 2423 | static enum irdma_status_code irdma_sc_resume_qp(struct irdma_sc_cqp *cqp, | 2419 | static int irdma_sc_resume_qp(struct irdma_sc_cqp *cqp, struct irdma_sc_qp *qp, |
| 2424 | struct irdma_sc_qp *qp, | 2420 | u64 scratch) |
| 2425 | u64 scratch) | ||
| 2426 | { | 2421 | { |
| 2427 | u64 hdr; | 2422 | u64 hdr; |
| 2428 | __le64 *wqe; | 2423 | __le64 *wqe; |
| 2429 | 2424 | ||
| 2430 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2425 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2431 | if (!wqe) | 2426 | if (!wqe) |
| 2432 | return IRDMA_ERR_RING_FULL; | 2427 | return -ENOMEM; |
| 2433 | 2428 | ||
| 2434 | set_64bit_val(wqe, 16, | 2429 | set_64bit_val(wqe, 16, |
| 2435 | FIELD_PREP(IRDMA_CQPSQ_RESUMEQP_QSHANDLE, qp->qs_handle)); | 2430 | FIELD_PREP(IRDMA_CQPSQ_RESUMEQP_QSHANDLE, qp->qs_handle)); |
| @@ -2462,14 +2457,13 @@ static inline void irdma_sc_cq_ack(struct irdma_sc_cq *cq) · 26 unmodified lines | |||
| 2462 | * @cq: cq struct | 2457 | * @cq: cq struct |
| 2463 | * @info: cq initialization info | 2458 | * @info: cq initialization info |
| 2464 | */ | 2459 | */ |
| 2465 | enum irdma_status_code irdma_sc_cq_init(struct irdma_sc_cq *cq, | 2460 | int irdma_sc_cq_init(struct irdma_sc_cq *cq, struct irdma_cq_init_info *info) |
| 2466 | struct irdma_cq_init_info *info) | ||
| 2467 | { | 2461 | { |
| 2468 | u32 pble_obj_cnt; | 2462 | u32 pble_obj_cnt; |
| 2469 | 2463 | ||
| 2470 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; | 2464 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; |
| 2471 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) | 2465 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) |
| 2472 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 2466 | return -EINVAL; |
| 2473 | 2467 | ||
| 2474 | cq->cq_pa = info->cq_base_pa; | 2468 | cq->cq_pa = info->cq_base_pa; |
| 2475 | cq->dev = info->dev; | 2469 | cq->dev = info->dev; |
| @@ -2500,23 +2494,21 @@ enum irdma_status_code irdma_sc_cq_init(struct irdma_sc_cq *cq, · 24 unmodified lines | |||
| 2500 | * @check_overflow: flag for overflow check | 2494 | * @check_overflow: flag for overflow check |
| 2501 | * @post_sq: flag for cqp db to ring | 2495 | * @post_sq: flag for cqp db to ring |
| 2502 | */ | 2496 | */ |
| 2503 | static enum irdma_status_code irdma_sc_cq_create(struct irdma_sc_cq *cq, | 2497 | static int irdma_sc_cq_create(struct irdma_sc_cq *cq, u64 scratch, |
| 2504 | u64 scratch, | 2498 | bool check_overflow, bool post_sq) |
| 2505 | bool check_overflow, | ||
| 2506 | bool post_sq) | ||
| 2507 | { | 2499 | { |
| 2508 | __le64 *wqe; | 2500 | __le64 *wqe; |
| 2509 | struct irdma_sc_cqp *cqp; | 2501 | struct irdma_sc_cqp *cqp; |
| 2510 | u64 hdr; | 2502 | u64 hdr; |
| 2511 | struct irdma_sc_ceq *ceq; | 2503 | struct irdma_sc_ceq *ceq; |
| 2512 | enum irdma_status_code ret_code = 0; | 2504 | int ret_code = 0; |
| 2513 | 2505 | ||
| 2514 | cqp = cq->dev->cqp; | 2506 | cqp = cq->dev->cqp; |
| 2515 | if (cq->cq_uk.cq_id > (cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].max_cnt - 1)) | 2507 | if (cq->cq_uk.cq_id >= cqp->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].max_cnt) |
| 2516 | return IRDMA_ERR_INVALID_CQ_ID; | 2508 | return -EINVAL; |
| 2517 | 2509 | ||
| 2518 | if (cq->ceq_id > (cq->dev->hmc_fpm_misc.max_ceqs - 1)) | 2510 | if (cq->ceq_id >= cq->dev->hmc_fpm_misc.max_ceqs) |
| 2519 | return IRDMA_ERR_INVALID_CEQ_ID; | 2511 | return -EINVAL; |
| 2520 | 2512 | ||
| 2521 | ceq = cq->dev->ceq[cq->ceq_id]; | 2513 | ceq = cq->dev->ceq[cq->ceq_id]; |
| 2522 | if (ceq && ceq->reg_cq) | 2514 | if (ceq && ceq->reg_cq) |
| @@ -2529,7 +2521,7 @@ static enum irdma_status_code irdma_sc_cq_create(struct irdma_sc_cq *cq, · 6 unmodified lines | |||
| 2529 | if (!wqe) { | 2521 | if (!wqe) { |
| 2530 | if (ceq && ceq->reg_cq) | 2522 | if (ceq && ceq->reg_cq) |
| 2531 | irdma_sc_remove_cq_ctx(ceq, cq); | 2523 | irdma_sc_remove_cq_ctx(ceq, cq); |
| 2532 | return IRDMA_ERR_RING_FULL; | 2524 | return -ENOMEM; |
| 2533 | } | 2525 | } |
| 2534 | 2526 | ||
| 2535 | set_64bit_val(wqe, 0, cq->cq_uk.cq_size); | 2527 | set_64bit_val(wqe, 0, cq->cq_uk.cq_size); |
| @@ -2575,8 +2567,7 @@ static enum irdma_status_code irdma_sc_cq_create(struct irdma_sc_cq *cq, · 39 unmodified lines | |||
| 2575 | * @scratch: u64 saved to be used during cqp completion | 2567 | * @scratch: u64 saved to be used during cqp completion |
| 2576 | * @post_sq: flag for cqp db to ring | 2568 | * @post_sq: flag for cqp db to ring |
| 2577 | */ | 2569 | */ |
| 2578 | enum irdma_status_code irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, | 2570 | int irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, bool post_sq) |
| 2579 | bool post_sq) | ||
| 2580 | { | 2571 | { |
| 2581 | struct irdma_sc_cqp *cqp; | 2572 | struct irdma_sc_cqp *cqp; |
| 2582 | __le64 *wqe; | 2573 | __le64 *wqe; |
| @@ -2586,7 +2577,7 @@ enum irdma_status_code irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, · 3 unmodified lines | |||
| 2586 | cqp = cq->dev->cqp; | 2577 | cqp = cq->dev->cqp; |
| 2587 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2578 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2588 | if (!wqe) | 2579 | if (!wqe) |
| 2589 | return IRDMA_ERR_RING_FULL; | 2580 | return -ENOMEM; |
| 2590 | 2581 | ||
| 2591 | ceq = cq->dev->ceq[cq->ceq_id]; | 2582 | ceq = cq->dev->ceq[cq->ceq_id]; |
| 2592 | if (ceq && ceq->reg_cq) | 2583 | if (ceq && ceq->reg_cq) |
| @@ -2642,9 +2633,9 @@ void irdma_sc_cq_resize(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *inf · 49 unmodified lines | |||
| 2642 | * @scratch: u64 saved to be used during cqp completion | 2633 | * @scratch: u64 saved to be used during cqp completion |
| 2643 | * @post_sq: flag to post to sq | 2634 | * @post_sq: flag to post to sq |
| 2644 | */ | 2635 | */ |
| 2645 | static enum irdma_status_code | 2636 | static int irdma_sc_cq_modify(struct irdma_sc_cq *cq, |
| 2646 | irdma_sc_cq_modify(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *info, | 2637 | struct irdma_modify_cq_info *info, u64 scratch, |
| 2647 | u64 scratch, bool post_sq) | 2638 | bool post_sq) |
| 2648 | { | 2639 | { |
| 2649 | struct irdma_sc_cqp *cqp; | 2640 | struct irdma_sc_cqp *cqp; |
| 2650 | __le64 *wqe; | 2641 | __le64 *wqe; |
| @@ -2654,12 +2645,12 @@ irdma_sc_cq_modify(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *info, · 3 unmodified lines | |||
| 2654 | pble_obj_cnt = cq->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; | 2645 | pble_obj_cnt = cq->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; |
| 2655 | if (info->cq_resize && info->virtual_map && | 2646 | if (info->cq_resize && info->virtual_map && |
| 2656 | info->first_pm_pbl_idx >= pble_obj_cnt) | 2647 | info->first_pm_pbl_idx >= pble_obj_cnt) |
| 2657 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 2648 | return -EINVAL; |
| 2658 | 2649 | ||
| 2659 | cqp = cq->dev->cqp; | 2650 | cqp = cq->dev->cqp; |
| 2660 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 2651 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 2661 | if (!wqe) | 2652 | if (!wqe) |
| 2662 | return IRDMA_ERR_RING_FULL; | 2653 | return -ENOMEM; |
| 2663 | 2654 | ||
| 2664 | set_64bit_val(wqe, 0, info->cq_size); | 2655 | set_64bit_val(wqe, 0, info->cq_size); |
| 2665 | set_64bit_val(wqe, 8, (uintptr_t)cq >> 1); | 2656 | set_64bit_val(wqe, 8, (uintptr_t)cq >> 1); |
| @@ -2733,8 +2724,8 @@ static inline void irdma_get_cqp_reg_info(struct irdma_sc_cqp *cqp, u32 *val, · 67 unmodified lines | |||
| 2733 | * @tail: wqtail register value | 2724 | * @tail: wqtail register value |
| 2734 | * @count: how many times to try for completion | 2725 | * @count: how many times to try for completion |
| 2735 | */ | 2726 | */ |
| 2736 | static enum irdma_status_code irdma_cqp_poll_registers(struct irdma_sc_cqp *cqp, | 2727 | static int irdma_cqp_poll_registers(struct irdma_sc_cqp *cqp, u32 tail, |
| 2737 | u32 tail, u32 count) | 2728 | u32 count) |
| 2738 | { | 2729 | { |
| 2739 | u32 i = 0; | 2730 | u32 i = 0; |
| 2740 | u32 newtail, error, val; | 2731 | u32 newtail, error, val; |
| @@ -2746,7 +2737,7 @@ static enum irdma_status_code irdma_cqp_poll_registers(struct irdma_sc_cqp *cqp, · 5 unmodified lines | |||
| 2746 | ibdev_dbg(to_ibdev(cqp->dev), | 2737 | ibdev_dbg(to_ibdev(cqp->dev), |
| 2747 | "CQP: CQPERRCODES error_code[x%08X]\n", | 2738 | "CQP: CQPERRCODES error_code[x%08X]\n", |
| 2748 | error); | 2739 | error); |
| 2749 | return IRDMA_ERR_CQP_COMPL_ERROR; | 2740 | return -EIO; |
| 2750 | } | 2741 | } |
| 2751 | if (newtail != tail) { | 2742 | if (newtail != tail) { |
| 2752 | /* SUCCESS */ | 2743 | /* SUCCESS */ |
| @@ -2757,7 +2748,7 @@ static enum irdma_status_code irdma_cqp_poll_registers(struct irdma_sc_cqp *cqp, · 4 unmodified lines | |||
| 2757 | udelay(cqp->dev->hw_attrs.max_sleep_count); | 2748 | udelay(cqp->dev->hw_attrs.max_sleep_count); |
| 2758 | } | 2749 | } |
| 2759 | 2750 | ||
| 2760 | return IRDMA_ERR_TIMEOUT; | 2751 | return -ETIMEDOUT; |
| 2761 | } | 2752 | } |
| 2762 | 2753 | ||
| 2763 | /** | 2754 | /** |
| @@ -2912,10 +2903,9 @@ static u64 irdma_sc_decode_fpm_query(__le64 *buf, u32 buf_idx, · 148 unmodified lines | |||
| 2912 | * parses fpm query buffer and copy max_cnt and | 2903 | * parses fpm query buffer and copy max_cnt and |
| 2913 | * size value of hmc objects in hmc_info | 2904 | * size value of hmc objects in hmc_info |
| 2914 | */ | 2905 | */ |
| 2915 | static enum irdma_status_code | 2906 | static int irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, |
| 2916 | irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, | 2907 | struct irdma_hmc_info *hmc_info, |
| 2917 | struct irdma_hmc_info *hmc_info, | 2908 | struct irdma_hmc_fpm_misc *hmc_fpm_misc) |
| 2918 | struct irdma_hmc_fpm_misc *hmc_fpm_misc) | ||
| 2919 | { | 2909 | { |
| 2920 | struct irdma_hmc_obj_info *obj_info; | 2910 | struct irdma_hmc_obj_info *obj_info; |
| 2921 | u64 temp; | 2911 | u64 temp; |
| @@ -2954,7 +2944,7 @@ irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, · 32 unmodified lines | |||
| 2954 | obj_info[IRDMA_HMC_IW_XFFL].size = 4; | 2944 | obj_info[IRDMA_HMC_IW_XFFL].size = 4; |
| 2955 | hmc_fpm_misc->xf_block_size = FIELD_GET(IRDMA_QUERY_FPM_XFBLOCKSIZE, temp); | 2945 | hmc_fpm_misc->xf_block_size = FIELD_GET(IRDMA_QUERY_FPM_XFBLOCKSIZE, temp); |
| 2956 | if (!hmc_fpm_misc->xf_block_size) | 2946 | if (!hmc_fpm_misc->xf_block_size) |
| 2957 | return IRDMA_ERR_INVALID_SIZE; | 2947 | return -EINVAL; |
| 2958 | 2948 | ||
| 2959 | irdma_sc_decode_fpm_query(buf, 72, obj_info, IRDMA_HMC_IW_Q1); | 2949 | irdma_sc_decode_fpm_query(buf, 72, obj_info, IRDMA_HMC_IW_Q1); |
| 2960 | get_64bit_val(buf, 80, &temp); | 2950 | get_64bit_val(buf, 80, &temp); |
| @@ -2963,7 +2953,7 @@ irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, · 2 unmodified lines | |||
| 2963 | 2953 | ||
| 2964 | hmc_fpm_misc->q1_block_size = FIELD_GET(IRDMA_QUERY_FPM_Q1BLOCKSIZE, temp); | 2954 | hmc_fpm_misc->q1_block_size = FIELD_GET(IRDMA_QUERY_FPM_Q1BLOCKSIZE, temp); |
| 2965 | if (!hmc_fpm_misc->q1_block_size) | 2955 | if (!hmc_fpm_misc->q1_block_size) |
| 2966 | return IRDMA_ERR_INVALID_SIZE; | 2956 | return -EINVAL; |
| 2967 | 2957 | ||
| 2968 | irdma_sc_decode_fpm_query(buf, 88, obj_info, IRDMA_HMC_IW_TIMER); | 2958 | irdma_sc_decode_fpm_query(buf, 88, obj_info, IRDMA_HMC_IW_TIMER); |
| 2969 | 2959 | ||
| @@ -2987,7 +2977,7 @@ irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, · 17 unmodified lines | |||
| 2987 | hmc_fpm_misc->rrf_block_size = FIELD_GET(IRDMA_QUERY_FPM_RRFBLOCKSIZE, temp); | 2977 | hmc_fpm_misc->rrf_block_size = FIELD_GET(IRDMA_QUERY_FPM_RRFBLOCKSIZE, temp); |
| 2988 | if (!hmc_fpm_misc->rrf_block_size && | 2978 | if (!hmc_fpm_misc->rrf_block_size && |
| 2989 | obj_info[IRDMA_HMC_IW_RRFFL].max_cnt) | 2979 | obj_info[IRDMA_HMC_IW_RRFFL].max_cnt) |
| 2990 | return IRDMA_ERR_INVALID_SIZE; | 2980 | return -EINVAL; |
| 2991 | 2981 | ||
| 2992 | irdma_sc_decode_fpm_query(buf, 144, obj_info, IRDMA_HMC_IW_HDR); | 2982 | irdma_sc_decode_fpm_query(buf, 144, obj_info, IRDMA_HMC_IW_HDR); |
| 2993 | irdma_sc_decode_fpm_query(buf, 152, obj_info, IRDMA_HMC_IW_MD); | 2983 | irdma_sc_decode_fpm_query(buf, 152, obj_info, IRDMA_HMC_IW_MD); |
| @@ -2999,7 +2989,7 @@ irdma_sc_parse_fpm_query_buf(struct irdma_sc_dev *dev, __le64 *buf, · 5 unmodified lines | |||
| 2999 | hmc_fpm_misc->ooiscf_block_size = FIELD_GET(IRDMA_QUERY_FPM_OOISCFBLOCKSIZE, temp); | 2989 | hmc_fpm_misc->ooiscf_block_size = FIELD_GET(IRDMA_QUERY_FPM_OOISCFBLOCKSIZE, temp); |
| 3000 | if (!hmc_fpm_misc->ooiscf_block_size && | 2990 | if (!hmc_fpm_misc->ooiscf_block_size && |
| 3001 | obj_info[IRDMA_HMC_IW_OOISCFFL].max_cnt) | 2991 | obj_info[IRDMA_HMC_IW_OOISCFFL].max_cnt) |
| 3002 | return IRDMA_ERR_INVALID_SIZE; | 2992 | return -EINVAL; |
| 3003 | 2993 | ||
| 3004 | return 0; | 2994 | return 0; |
| 3005 | } | 2995 | } |
| @@ -3027,8 +3017,7 @@ static u32 irdma_sc_find_reg_cq(struct irdma_sc_ceq *ceq, · 21 unmodified lines | |||
| 3027 | * @ceq: ceq sc structure | 3017 | * @ceq: ceq sc structure |
| 3028 | * @cq: cq sc structure | 3018 | * @cq: cq sc structure |
| 3029 | */ | 3019 | */ |
| 3030 | enum irdma_status_code irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, | 3020 | int irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq) |
| 3031 | struct irdma_sc_cq *cq) | ||
| 3032 | { | 3021 | { |
| 3033 | unsigned long flags; | 3022 | unsigned long flags; |
| 3034 | 3023 | ||
| @@ -3036,7 +3025,7 @@ enum irdma_status_code irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, · 1 unmodified line | |||
| 3036 | 3025 | ||
| 3037 | if (ceq->reg_cq_size == ceq->elem_cnt) { | 3026 | if (ceq->reg_cq_size == ceq->elem_cnt) { |
| 3038 | spin_unlock_irqrestore(&ceq->req_cq_lock, flags); | 3027 | spin_unlock_irqrestore(&ceq->req_cq_lock, flags); |
| 3039 | return IRDMA_ERR_REG_CQ_FULL; | 3028 | return -ENOMEM; |
| 3040 | } | 3029 | } |
| 3041 | 3030 | ||
| 3042 | ceq->reg_cq[ceq->reg_cq_size++] = cq; | 3031 | ceq->reg_cq[ceq->reg_cq_size++] = cq; |
| @@ -3077,15 +3066,15 @@ exit: · 34 unmodified lines | |||
| 3077 | * | 3066 | * |
| 3078 | * Initializes the object and context buffers for a control Queue Pair. | 3067 | * Initializes the object and context buffers for a control Queue Pair. |
| 3079 | */ | 3068 | */ |
| 3080 | enum irdma_status_code irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, | 3069 | int irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, |
| 3081 | struct irdma_cqp_init_info *info) | 3070 | struct irdma_cqp_init_info *info) |
| 3082 | { | 3071 | { |
| 3083 | u8 hw_sq_size; | 3072 | u8 hw_sq_size; |
| 3084 | 3073 | ||
| 3085 | if (info->sq_size > IRDMA_CQP_SW_SQSIZE_2048 || | 3074 | if (info->sq_size > IRDMA_CQP_SW_SQSIZE_2048 || |
| 3086 | info->sq_size < IRDMA_CQP_SW_SQSIZE_4 || | 3075 | info->sq_size < IRDMA_CQP_SW_SQSIZE_4 || |
| 3087 | ((info->sq_size & (info->sq_size - 1)))) | 3076 | ((info->sq_size & (info->sq_size - 1)))) |
| 3088 | return IRDMA_ERR_INVALID_SIZE; | 3077 | return -EINVAL; |
| 3089 | 3078 | ||
| 3090 | hw_sq_size = irdma_get_encoded_wqe_size(info->sq_size, | 3079 | hw_sq_size = irdma_get_encoded_wqe_size(info->sq_size, |
| 3091 | IRDMA_QUEUE_TYPE_CQP); | 3080 | IRDMA_QUEUE_TYPE_CQP); |
| @@ -3135,13 +3124,12 @@ enum irdma_status_code irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, · 43 unmodified lines | |||
| 3135 | * @maj_err: If error, major err number | 3124 | * @maj_err: If error, major err number |
| 3136 | * @min_err: If error, minor err number | 3125 | * @min_err: If error, minor err number |
| 3137 | */ | 3126 | */ |
| 3138 | enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, | 3127 | int irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, u16 *min_err) |
| 3139 | u16 *min_err) | ||
| 3140 | { | 3128 | { |
| 3141 | u64 temp; | 3129 | u64 temp; |
| 3142 | u8 hw_rev; | 3130 | u8 hw_rev; |
| 3143 | u32 cnt = 0, p1, p2, val = 0, err_code; | 3131 | u32 cnt = 0, p1, p2, val = 0, err_code; |
| 3144 | enum irdma_status_code ret_code; | 3132 | int ret_code; |
| 3145 | 3133 | ||
| 3146 | hw_rev = cqp->dev->hw_attrs.uk_attrs.hw_rev; | 3134 | hw_rev = cqp->dev->hw_attrs.uk_attrs.hw_rev; |
| 3147 | cqp->sdbuf.size = ALIGN(IRDMA_UPDATE_SD_BUFF_SIZE * cqp->sq_size, | 3135 | cqp->sdbuf.size = ALIGN(IRDMA_UPDATE_SD_BUFF_SIZE * cqp->sq_size, |
| @@ -3150,7 +3138,7 @@ enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_er · 2 unmodified lines | |||
| 3150 | cqp->sdbuf.size, &cqp->sdbuf.pa, | 3138 | cqp->sdbuf.size, &cqp->sdbuf.pa, |
| 3151 | GFP_KERNEL); | 3139 | GFP_KERNEL); |
| 3152 | if (!cqp->sdbuf.va) | 3140 | if (!cqp->sdbuf.va) |
| 3153 | return IRDMA_ERR_NO_MEMORY; | 3141 | return -ENOMEM; |
| 3154 | 3142 | ||
| 3155 | spin_lock_init(&cqp->dev->cqp_lock); | 3143 | spin_lock_init(&cqp->dev->cqp_lock); |
| 3156 | 3144 | ||
| @@ -3205,7 +3193,7 @@ enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_er · 48 unmodified lines | |||
| 3205 | 3193 | ||
| 3206 | do { | 3194 | do { |
| 3207 | if (cnt++ > cqp->dev->hw_attrs.max_done_count) { | 3195 | if (cnt++ > cqp->dev->hw_attrs.max_done_count) { |
| 3208 | ret_code = IRDMA_ERR_TIMEOUT; | 3196 | ret_code = -ETIMEDOUT; |
| 3209 | goto err; | 3197 | goto err; |
| 3210 | } | 3198 | } |
| 3211 | udelay(cqp->dev->hw_attrs.max_sleep_count); | 3199 | udelay(cqp->dev->hw_attrs.max_sleep_count); |
| @@ -3213,7 +3201,7 @@ enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_er · 1 unmodified line | |||
| 3213 | } while (!val); | 3201 | } while (!val); |
| 3214 | 3202 | ||
| 3215 | if (FLD_RS_32(cqp->dev, val, IRDMA_CCQPSTATUS_CCQP_ERR)) { | 3203 | if (FLD_RS_32(cqp->dev, val, IRDMA_CCQPSTATUS_CCQP_ERR)) { |
| 3216 | ret_code = IRDMA_ERR_DEVICE_NOT_SUPPORTED; | 3204 | ret_code = -EOPNOTSUPP; |
| 3217 | goto err; | 3205 | goto err; |
| 3218 | } | 3206 | } |
| 3219 | 3207 | ||
| @@ -3254,7 +3242,7 @@ __le64 *irdma_sc_cqp_get_next_send_wqe_idx(struct irdma_sc_cqp *cqp, u64 scratch · 34 unmodified lines | |||
| 3254 | u32 *wqe_idx) | 3242 | u32 *wqe_idx) |
| 3255 | { | 3243 | { |
| 3256 | __le64 *wqe = NULL; | 3244 | __le64 *wqe = NULL; |
| 3257 | enum irdma_status_code ret_code; | 3245 | int ret_code; |
| 3258 | 3246 | ||
| 3259 | if (IRDMA_RING_FULL_ERR(cqp->sq_ring)) { | 3247 | if (IRDMA_RING_FULL_ERR(cqp->sq_ring)) { |
| 3260 | ibdev_dbg(to_ibdev(cqp->dev), | 3248 | ibdev_dbg(to_ibdev(cqp->dev), |
| @@ -3281,16 +3269,16 @@ __le64 *irdma_sc_cqp_get_next_send_wqe_idx(struct irdma_sc_cqp *cqp, u64 scratch · 20 unmodified lines | |||
| 3281 | * irdma_sc_cqp_destroy - destroy cqp during close | 3269 | * irdma_sc_cqp_destroy - destroy cqp during close |
| 3282 | * @cqp: struct for cqp hw | 3270 | * @cqp: struct for cqp hw |
| 3283 | */ | 3271 | */ |
| 3284 | enum irdma_status_code irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp) | 3272 | int irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp) |
| 3285 | { | 3273 | { |
| 3286 | u32 cnt = 0, val; | 3274 | u32 cnt = 0, val; |
| 3287 | enum irdma_status_code ret_code = 0; | 3275 | int ret_code = 0; |
| 3288 | 3276 | ||
| 3289 | writel(0, cqp->dev->hw_regs[IRDMA_CCQPHIGH]); | 3277 | writel(0, cqp->dev->hw_regs[IRDMA_CCQPHIGH]); |
| 3290 | writel(0, cqp->dev->hw_regs[IRDMA_CCQPLOW]); | 3278 | writel(0, cqp->dev->hw_regs[IRDMA_CCQPLOW]); |
| 3291 | do { | 3279 | do { |
| 3292 | if (cnt++ > cqp->dev->hw_attrs.max_done_count) { | 3280 | if (cnt++ > cqp->dev->hw_attrs.max_done_count) { |
| 3293 | ret_code = IRDMA_ERR_TIMEOUT; | 3281 | ret_code = -ETIMEDOUT; |
| 3294 | break; | 3282 | break; |
| 3295 | } | 3283 | } |
| 3296 | udelay(cqp->dev->hw_attrs.max_sleep_count); | 3284 | udelay(cqp->dev->hw_attrs.max_sleep_count); |
| @@ -3335,8 +3323,8 @@ void irdma_sc_ccq_arm(struct irdma_sc_cq *ccq) · 38 unmodified lines | |||
| 3335 | * @ccq: ccq sc struct | 3323 | * @ccq: ccq sc struct |
| 3336 | * @info: completion q entry to return | 3324 | * @info: completion q entry to return |
| 3337 | */ | 3325 | */ |
| 3338 | enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, | 3326 | int irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, |
| 3339 | struct irdma_ccq_cqe_info *info) | 3327 | struct irdma_ccq_cqe_info *info) |
| 3340 | { | 3328 | { |
| 3341 | u64 qp_ctx, temp, temp1; | 3329 | u64 qp_ctx, temp, temp1; |
| 3342 | __le64 *cqe; | 3330 | __le64 *cqe; |
| @@ -3344,7 +3332,7 @@ enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, · 1 unmodified line | |||
| 3344 | u32 wqe_idx; | 3332 | u32 wqe_idx; |
| 3345 | u32 error; | 3333 | u32 error; |
| 3346 | u8 polarity; | 3334 | u8 polarity; |
| 3347 | enum irdma_status_code ret_code = 0; | 3335 | int ret_code = 0; |
| 3348 | 3336 | ||
| 3349 | if (ccq->cq_uk.avoid_mem_cflct) | 3337 | if (ccq->cq_uk.avoid_mem_cflct) |
| 3350 | cqe = IRDMA_GET_CURRENT_EXTENDED_CQ_ELEM(&ccq->cq_uk); | 3338 | cqe = IRDMA_GET_CURRENT_EXTENDED_CQ_ELEM(&ccq->cq_uk); |
| @@ -3354,7 +3342,7 @@ enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, · 3 unmodified lines | |||
| 3354 | get_64bit_val(cqe, 24, &temp); | 3342 | get_64bit_val(cqe, 24, &temp); |
| 3355 | polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, temp); | 3343 | polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, temp); |
| 3356 | if (polarity != ccq->cq_uk.polarity) | 3344 | if (polarity != ccq->cq_uk.polarity) |
| 3357 | return IRDMA_ERR_Q_EMPTY; | 3345 | return -ENOENT; |
| 3358 | 3346 | ||
| 3359 | get_64bit_val(cqe, 8, &qp_ctx); | 3347 | get_64bit_val(cqe, 8, &qp_ctx); |
| 3360 | cqp = (struct irdma_sc_cqp *)(unsigned long)qp_ctx; | 3348 | cqp = (struct irdma_sc_cqp *)(unsigned long)qp_ctx; |
| @@ -3401,25 +3389,25 @@ enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, · 40 unmodified lines | |||
| 3401 | * @op_code: cqp opcode for completion | 3389 | * @op_code: cqp opcode for completion |
| 3402 | * @compl_info: completion q entry to return | 3390 | * @compl_info: completion q entry to return |
| 3403 | */ | 3391 | */ |
| 3404 | enum irdma_status_code irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 op_code, | 3392 | int irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 op_code, |
| 3405 | struct irdma_ccq_cqe_info *compl_info) | 3393 | struct irdma_ccq_cqe_info *compl_info) |
| 3406 | { | 3394 | { |
| 3407 | struct irdma_ccq_cqe_info info = {}; | 3395 | struct irdma_ccq_cqe_info info = {}; |
| 3408 | struct irdma_sc_cq *ccq; | 3396 | struct irdma_sc_cq *ccq; |
| 3409 | enum irdma_status_code ret_code = 0; | 3397 | int ret_code = 0; |
| 3410 | u32 cnt = 0; | 3398 | u32 cnt = 0; |
| 3411 | 3399 | ||
| 3412 | ccq = cqp->dev->ccq; | 3400 | ccq = cqp->dev->ccq; |
| 3413 | while (1) { | 3401 | while (1) { |
| 3414 | if (cnt++ > 100 * cqp->dev->hw_attrs.max_done_count) | 3402 | if (cnt++ > 100 * cqp->dev->hw_attrs.max_done_count) |
| 3415 | return IRDMA_ERR_TIMEOUT; | 3403 | return -ETIMEDOUT; |
| 3416 | 3404 | ||
| 3417 | if (irdma_sc_ccq_get_cqe_info(ccq, &info)) { | 3405 | if (irdma_sc_ccq_get_cqe_info(ccq, &info)) { |
| 3418 | udelay(cqp->dev->hw_attrs.max_sleep_count); | 3406 | udelay(cqp->dev->hw_attrs.max_sleep_count); |
| 3419 | continue; | 3407 | continue; |
| 3420 | } | 3408 | } |
| 3421 | if (info.error && info.op_code != IRDMA_CQP_OP_QUERY_STAG) { | 3409 | if (info.error && info.op_code != IRDMA_CQP_OP_QUERY_STAG) { |
| 3422 | ret_code = IRDMA_ERR_CQP_COMPL_ERROR; | 3410 | ret_code = -EIO; |
| 3423 | break; | 3411 | break; |
| 3424 | } | 3412 | } |
| 3425 | /* make sure op code matches*/ | 3413 | /* make sure op code matches*/ |
| @@ -3443,17 +3431,16 @@ enum irdma_status_code irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u · 17 unmodified lines | |||
| 3443 | * @info: info for the manage function table operation | 3431 | * @info: info for the manage function table operation |
| 3444 | * @post_sq: flag for cqp db to ring | 3432 | * @post_sq: flag for cqp db to ring |
| 3445 | */ | 3433 | */ |
| 3446 | static enum irdma_status_code | 3434 | static int irdma_sc_manage_hmc_pm_func_table(struct irdma_sc_cqp *cqp, |
| 3447 | irdma_sc_manage_hmc_pm_func_table(struct irdma_sc_cqp *cqp, | 3435 | struct irdma_hmc_fcn_info *info, |
| 3448 | struct irdma_hmc_fcn_info *info, | 3436 | u64 scratch, bool post_sq) |
| 3449 | u64 scratch, bool post_sq) | ||
| 3450 | { | 3437 | { |
| 3451 | __le64 *wqe; | 3438 | __le64 *wqe; |
| 3452 | u64 hdr; | 3439 | u64 hdr; |
| 3453 | 3440 | ||
| 3454 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3441 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3455 | if (!wqe) | 3442 | if (!wqe) |
| 3456 | return IRDMA_ERR_RING_FULL; | 3443 | return -ENOMEM; |
| 3457 | 3444 | ||
| 3458 | set_64bit_val(wqe, 0, 0); | 3445 | set_64bit_val(wqe, 0, 0); |
| 3459 | set_64bit_val(wqe, 8, 0); | 3446 | set_64bit_val(wqe, 8, 0); |
| @@ -3486,8 +3473,7 @@ irdma_sc_manage_hmc_pm_func_table(struct irdma_sc_cqp *cqp, · 26 unmodified lines | |||
| 3486 | * for fpm commit | 3473 | * for fpm commit |
| 3487 | * @cqp: struct for cqp hw | 3474 | * @cqp: struct for cqp hw |
| 3488 | */ | 3475 | */ |
| 3489 | static enum irdma_status_code | 3476 | static int irdma_sc_commit_fpm_val_done(struct irdma_sc_cqp *cqp) |
| 3490 | irdma_sc_commit_fpm_val_done(struct irdma_sc_cqp *cqp) | ||
| 3491 | { | 3477 | { |
| 3492 | return irdma_sc_poll_for_cqp_op_done(cqp, IRDMA_CQP_OP_COMMIT_FPM_VAL, | 3478 | return irdma_sc_poll_for_cqp_op_done(cqp, IRDMA_CQP_OP_COMMIT_FPM_VAL, |
| 3493 | NULL); | 3479 | NULL); |
| @@ -3502,19 +3488,19 @@ irdma_sc_commit_fpm_val_done(struct irdma_sc_cqp *cqp) · 8 unmodified lines | |||
| 3502 | * @post_sq: flag for cqp db to ring | 3488 | * @post_sq: flag for cqp db to ring |
| 3503 | * @wait_type: poll ccq or cqp registers for cqp completion | 3489 | * @wait_type: poll ccq or cqp registers for cqp completion |
| 3504 | */ | 3490 | */ |
| 3505 | static enum irdma_status_code | 3491 | static int irdma_sc_commit_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, |
| 3506 | irdma_sc_commit_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, u8 hmc_fn_id, | 3492 | u8 hmc_fn_id, |
| 3507 | struct irdma_dma_mem *commit_fpm_mem, bool post_sq, | 3493 | struct irdma_dma_mem *commit_fpm_mem, |
| 3508 | u8 wait_type) | 3494 | bool post_sq, u8 wait_type) |
| 3509 | { | 3495 | { |
| 3510 | __le64 *wqe; | 3496 | __le64 *wqe; |
| 3511 | u64 hdr; | 3497 | u64 hdr; |
| 3512 | u32 tail, val, error; | 3498 | u32 tail, val, error; |
| 3513 | enum irdma_status_code ret_code = 0; | 3499 | int ret_code = 0; |
| 3514 | 3500 | ||
| 3515 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3501 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3516 | if (!wqe) | 3502 | if (!wqe) |
| 3517 | return IRDMA_ERR_RING_FULL; | 3503 | return -ENOMEM; |
| 3518 | 3504 | ||
| 3519 | set_64bit_val(wqe, 16, hmc_fn_id); | 3505 | set_64bit_val(wqe, 16, hmc_fn_id); |
| 3520 | set_64bit_val(wqe, 32, commit_fpm_mem->pa); | 3506 | set_64bit_val(wqe, 32, commit_fpm_mem->pa); |
| @@ -3548,8 +3534,7 @@ irdma_sc_commit_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, u8 hmc_fn_id, · 27 unmodified lines | |||
| 3548 | * query fpm | 3534 | * query fpm |
| 3549 | * @cqp: struct for cqp hw | 3535 | * @cqp: struct for cqp hw |
| 3550 | */ | 3536 | */ |
| 3551 | static enum irdma_status_code | 3537 | static int irdma_sc_query_fpm_val_done(struct irdma_sc_cqp *cqp) |
| 3552 | irdma_sc_query_fpm_val_done(struct irdma_sc_cqp *cqp) | ||
| 3553 | { | 3538 | { |
| 3554 | return irdma_sc_poll_for_cqp_op_done(cqp, IRDMA_CQP_OP_QUERY_FPM_VAL, | 3539 | return irdma_sc_poll_for_cqp_op_done(cqp, IRDMA_CQP_OP_QUERY_FPM_VAL, |
| 3555 | NULL); | 3540 | NULL); |
| @@ -3564,19 +3549,19 @@ irdma_sc_query_fpm_val_done(struct irdma_sc_cqp *cqp) · 8 unmodified lines | |||
| 3564 | * @post_sq: flag for cqp db to ring | 3549 | * @post_sq: flag for cqp db to ring |
| 3565 | * @wait_type: poll ccq or cqp registers for cqp completion | 3550 | * @wait_type: poll ccq or cqp registers for cqp completion |
| 3566 | */ | 3551 | */ |
| 3567 | static enum irdma_status_code | 3552 | static int irdma_sc_query_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, |
| 3568 | irdma_sc_query_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, u8 hmc_fn_id, | 3553 | u8 hmc_fn_id, |
| 3569 | struct irdma_dma_mem *query_fpm_mem, bool post_sq, | 3554 | struct irdma_dma_mem *query_fpm_mem, |
| 3570 | u8 wait_type) | 3555 | bool post_sq, u8 wait_type) |
| 3571 | { | 3556 | { |
| 3572 | __le64 *wqe; | 3557 | __le64 *wqe; |
| 3573 | u64 hdr; | 3558 | u64 hdr; |
| 3574 | u32 tail, val, error; | 3559 | u32 tail, val, error; |
| 3575 | enum irdma_status_code ret_code = 0; | 3560 | int ret_code = 0; |
| 3576 | 3561 | ||
| 3577 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3562 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3578 | if (!wqe) | 3563 | if (!wqe) |
| 3579 | return IRDMA_ERR_RING_FULL; | 3564 | return -ENOMEM; |
| 3580 | 3565 | ||
| 3581 | set_64bit_val(wqe, 16, hmc_fn_id); | 3566 | set_64bit_val(wqe, 16, hmc_fn_id); |
| 3582 | set_64bit_val(wqe, 32, query_fpm_mem->pa); | 3567 | set_64bit_val(wqe, 32, query_fpm_mem->pa); |
| @@ -3608,21 +3593,21 @@ irdma_sc_query_fpm_val(struct irdma_sc_cqp *cqp, u64 scratch, u8 hmc_fn_id, · 25 unmodified lines | |||
| 3608 | * @ceq: ceq sc structure | 3593 | * @ceq: ceq sc structure |
| 3609 | * @info: ceq initialization info | 3594 | * @info: ceq initialization info |
| 3610 | */ | 3595 | */ |
| 3611 | enum irdma_status_code irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, | 3596 | int irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, |
| 3612 | struct irdma_ceq_init_info *info) | 3597 | struct irdma_ceq_init_info *info) |
| 3613 | { | 3598 | { |
| 3614 | u32 pble_obj_cnt; | 3599 | u32 pble_obj_cnt; |
| 3615 | 3600 | ||
| 3616 | if (info->elem_cnt < info->dev->hw_attrs.min_hw_ceq_size || | 3601 | if (info->elem_cnt < info->dev->hw_attrs.min_hw_ceq_size || |
| 3617 | info->elem_cnt > info->dev->hw_attrs.max_hw_ceq_size) | 3602 | info->elem_cnt > info->dev->hw_attrs.max_hw_ceq_size) |
| 3618 | return IRDMA_ERR_INVALID_SIZE; | 3603 | return -EINVAL; |
| 3619 | 3604 | ||
| 3620 | if (info->ceq_id > (info->dev->hmc_fpm_misc.max_ceqs - 1)) | 3605 | if (info->ceq_id >= info->dev->hmc_fpm_misc.max_ceqs) |
| 3621 | return IRDMA_ERR_INVALID_CEQ_ID; | 3606 | return -EINVAL; |
| 3622 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; | 3607 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; |
| 3623 | 3608 | ||
| 3624 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) | 3609 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) |
| 3625 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 3610 | return -EINVAL; |
| 3626 | 3611 | ||
| 3627 | ceq->size = sizeof(*ceq); | 3612 | ceq->size = sizeof(*ceq); |
| 3628 | ceq->ceqe_base = (struct irdma_ceqe *)info->ceqe_base; | 3613 | ceq->ceqe_base = (struct irdma_ceqe *)info->ceqe_base; |
| @@ -3655,8 +3640,8 @@ enum irdma_status_code irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, · 26 unmodified lines | |||
| 3655 | * @post_sq: flag for cqp db to ring | 3640 | * @post_sq: flag for cqp db to ring |
| 3656 | */ | 3641 | */ |
| 3657 | 3642 | ||
| 3658 | static enum irdma_status_code irdma_sc_ceq_create(struct irdma_sc_ceq *ceq, u64 scratch, | 3643 | static int irdma_sc_ceq_create(struct irdma_sc_ceq *ceq, u64 scratch, |
| 3659 | bool post_sq) | 3644 | bool post_sq) |
| 3660 | { | 3645 | { |
| 3661 | struct irdma_sc_cqp *cqp; | 3646 | struct irdma_sc_cqp *cqp; |
| 3662 | __le64 *wqe; | 3647 | __le64 *wqe; |
| @@ -3665,7 +3650,7 @@ static enum irdma_status_code irdma_sc_ceq_create(struct irdma_sc_ceq *ceq, u64 · 2 unmodified lines | |||
| 3665 | cqp = ceq->dev->cqp; | 3650 | cqp = ceq->dev->cqp; |
| 3666 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3651 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3667 | if (!wqe) | 3652 | if (!wqe) |
| 3668 | return IRDMA_ERR_RING_FULL; | 3653 | return -ENOMEM; |
| 3669 | set_64bit_val(wqe, 16, ceq->elem_cnt); | 3654 | set_64bit_val(wqe, 16, ceq->elem_cnt); |
| 3670 | set_64bit_val(wqe, 32, | 3655 | set_64bit_val(wqe, 32, |
| 3671 | (ceq->virtual_map ? 0 : ceq->ceq_elem_pa)); | 3656 | (ceq->virtual_map ? 0 : ceq->ceq_elem_pa)); |
| @@ -3697,8 +3682,7 @@ static enum irdma_status_code irdma_sc_ceq_create(struct irdma_sc_ceq *ceq, u64 · 25 unmodified lines | |||
| 3697 | * irdma_sc_cceq_create_done - poll for control ceq wqe to complete | 3682 | * irdma_sc_cceq_create_done - poll for control ceq wqe to complete |
| 3698 | * @ceq: ceq sc structure | 3683 | * @ceq: ceq sc structure |
| 3699 | */ | 3684 | */ |
| 3700 | static enum irdma_status_code | 3685 | static int irdma_sc_cceq_create_done(struct irdma_sc_ceq *ceq) |
| 3701 | irdma_sc_cceq_create_done(struct irdma_sc_ceq *ceq) | ||
| 3702 | { | 3686 | { |
| 3703 | struct irdma_sc_cqp *cqp; | 3687 | struct irdma_sc_cqp *cqp; |
| 3704 | 3688 | ||
| @@ -3711,7 +3695,7 @@ irdma_sc_cceq_create_done(struct irdma_sc_ceq *ceq) · 6 unmodified lines | |||
| 3711 | * irdma_sc_cceq_destroy_done - poll for destroy cceq to complete | 3695 | * irdma_sc_cceq_destroy_done - poll for destroy cceq to complete |
| 3712 | * @ceq: ceq sc structure | 3696 | * @ceq: ceq sc structure |
| 3713 | */ | 3697 | */ |
| 3714 | enum irdma_status_code irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq) | 3698 | int irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq) |
| 3715 | { | 3699 | { |
| 3716 | struct irdma_sc_cqp *cqp; | 3700 | struct irdma_sc_cqp *cqp; |
| 3717 | 3701 | ||
| @@ -3730,9 +3714,9 @@ enum irdma_status_code irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq) · 12 unmodified lines | |||
| 3730 | * @ceq: ceq sc structure | 3714 | * @ceq: ceq sc structure |
| 3731 | * @scratch: u64 saved to be used during cqp completion | 3715 | * @scratch: u64 saved to be used during cqp completion |
| 3732 | */ | 3716 | */ |
| 3733 | enum irdma_status_code irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch) | 3717 | int irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch) |
| 3734 | { | 3718 | { |
| 3735 | enum irdma_status_code ret_code; | 3719 | int ret_code; |
| 3736 | struct irdma_sc_dev *dev = ceq->dev; | 3720 | struct irdma_sc_dev *dev = ceq->dev; |
| 3737 | 3721 | ||
| 3738 | dev->ccq->vsi = ceq->vsi; | 3722 | dev->ccq->vsi = ceq->vsi; |
| @@ -3755,8 +3739,7 @@ enum irdma_status_code irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratc · 16 unmodified lines | |||
| 3755 | * @scratch: u64 saved to be used during cqp completion | 3739 | * @scratch: u64 saved to be used during cqp completion |
| 3756 | * @post_sq: flag for cqp db to ring | 3740 | * @post_sq: flag for cqp db to ring |
| 3757 | */ | 3741 | */ |
| 3758 | enum irdma_status_code irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, | 3742 | int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq) |
| 3759 | bool post_sq) | ||
| 3760 | { | 3743 | { |
| 3761 | struct irdma_sc_cqp *cqp; | 3744 | struct irdma_sc_cqp *cqp; |
| 3762 | __le64 *wqe; | 3745 | __le64 *wqe; |
| @@ -3765,7 +3748,7 @@ enum irdma_status_code irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratc · 2 unmodified lines | |||
| 3765 | cqp = ceq->dev->cqp; | 3748 | cqp = ceq->dev->cqp; |
| 3766 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3749 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3767 | if (!wqe) | 3750 | if (!wqe) |
| 3768 | return IRDMA_ERR_RING_FULL; | 3751 | return -ENOMEM; |
| 3769 | 3752 | ||
| 3770 | set_64bit_val(wqe, 16, ceq->elem_cnt); | 3753 | set_64bit_val(wqe, 16, ceq->elem_cnt); |
| 3771 | set_64bit_val(wqe, 48, ceq->first_pm_pbl_idx); | 3754 | set_64bit_val(wqe, 48, ceq->first_pm_pbl_idx); |
| @@ -3884,19 +3867,19 @@ void irdma_sc_cleanup_ceqes(struct irdma_sc_cq *cq, struct irdma_sc_ceq *ceq) · 112 unmodified lines | |||
| 3884 | * @aeq: aeq structure ptr | 3867 | * @aeq: aeq structure ptr |
| 3885 | * @info: aeq initialization info | 3868 | * @info: aeq initialization info |
| 3886 | */ | 3869 | */ |
| 3887 | enum irdma_status_code irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, | 3870 | int irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, |
| 3888 | struct irdma_aeq_init_info *info) | 3871 | struct irdma_aeq_init_info *info) |
| 3889 | { | 3872 | { |
| 3890 | u32 pble_obj_cnt; | 3873 | u32 pble_obj_cnt; |
| 3891 | 3874 | ||
| 3892 | if (info->elem_cnt < info->dev->hw_attrs.min_hw_aeq_size || | 3875 | if (info->elem_cnt < info->dev->hw_attrs.min_hw_aeq_size || |
| 3893 | info->elem_cnt > info->dev->hw_attrs.max_hw_aeq_size) | 3876 | info->elem_cnt > info->dev->hw_attrs.max_hw_aeq_size) |
| 3894 | return IRDMA_ERR_INVALID_SIZE; | 3877 | return -EINVAL; |
| 3895 | 3878 | ||
| 3896 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; | 3879 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; |
| 3897 | 3880 | ||
| 3898 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) | 3881 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) |
| 3899 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 3882 | return -EINVAL; |
| 3900 | 3883 | ||
| 3901 | aeq->size = sizeof(*aeq); | 3884 | aeq->size = sizeof(*aeq); |
| 3902 | aeq->polarity = 1; | 3885 | aeq->polarity = 1; |
| @@ -3921,8 +3904,8 @@ enum irdma_status_code irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, · 18 unmodified lines | |||
| 3921 | * @scratch: u64 saved to be used during cqp completion | 3904 | * @scratch: u64 saved to be used during cqp completion |
| 3922 | * @post_sq: flag for cqp db to ring | 3905 | * @post_sq: flag for cqp db to ring |
| 3923 | */ | 3906 | */ |
| 3924 | static enum irdma_status_code irdma_sc_aeq_create(struct irdma_sc_aeq *aeq, | 3907 | static int irdma_sc_aeq_create(struct irdma_sc_aeq *aeq, u64 scratch, |
| 3925 | u64 scratch, bool post_sq) | 3908 | bool post_sq) |
| 3926 | { | 3909 | { |
| 3927 | __le64 *wqe; | 3910 | __le64 *wqe; |
| 3928 | struct irdma_sc_cqp *cqp; | 3911 | struct irdma_sc_cqp *cqp; |
| @@ -3931,7 +3914,7 @@ static enum irdma_status_code irdma_sc_aeq_create(struct irdma_sc_aeq *aeq, · 2 unmodified lines | |||
| 3931 | cqp = aeq->dev->cqp; | 3914 | cqp = aeq->dev->cqp; |
| 3932 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3915 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3933 | if (!wqe) | 3916 | if (!wqe) |
| 3934 | return IRDMA_ERR_RING_FULL; | 3917 | return -ENOMEM; |
| 3935 | set_64bit_val(wqe, 16, aeq->elem_cnt); | 3918 | set_64bit_val(wqe, 16, aeq->elem_cnt); |
| 3936 | set_64bit_val(wqe, 32, | 3919 | set_64bit_val(wqe, 32, |
| 3937 | (aeq->virtual_map ? 0 : aeq->aeq_elem_pa)); | 3920 | (aeq->virtual_map ? 0 : aeq->aeq_elem_pa)); |
| @@ -3960,8 +3943,8 @@ static enum irdma_status_code irdma_sc_aeq_create(struct irdma_sc_aeq *aeq, · 22 unmodified lines | |||
| 3960 | * @scratch: u64 saved to be used during cqp completion | 3943 | * @scratch: u64 saved to be used during cqp completion |
| 3961 | * @post_sq: flag for cqp db to ring | 3944 | * @post_sq: flag for cqp db to ring |
| 3962 | */ | 3945 | */ |
| 3963 | static enum irdma_status_code irdma_sc_aeq_destroy(struct irdma_sc_aeq *aeq, | 3946 | static int irdma_sc_aeq_destroy(struct irdma_sc_aeq *aeq, u64 scratch, |
| 3964 | u64 scratch, bool post_sq) | 3947 | bool post_sq) |
| 3965 | { | 3948 | { |
| 3966 | __le64 *wqe; | 3949 | __le64 *wqe; |
| 3967 | struct irdma_sc_cqp *cqp; | 3950 | struct irdma_sc_cqp *cqp; |
| @@ -3974,7 +3957,7 @@ static enum irdma_status_code irdma_sc_aeq_destroy(struct irdma_sc_aeq *aeq, · 6 unmodified lines | |||
| 3974 | cqp = dev->cqp; | 3957 | cqp = dev->cqp; |
| 3975 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 3958 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 3976 | if (!wqe) | 3959 | if (!wqe) |
| 3977 | return IRDMA_ERR_RING_FULL; | 3960 | return -ENOMEM; |
| 3978 | set_64bit_val(wqe, 16, aeq->elem_cnt); | 3961 | set_64bit_val(wqe, 16, aeq->elem_cnt); |
| 3979 | set_64bit_val(wqe, 48, aeq->first_pm_pbl_idx); | 3962 | set_64bit_val(wqe, 48, aeq->first_pm_pbl_idx); |
| 3980 | hdr = FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_DESTROY_AEQ) | | 3963 | hdr = FIELD_PREP(IRDMA_CQPSQ_OPCODE, IRDMA_CQP_OP_DESTROY_AEQ) | |
| @@ -3997,8 +3980,8 @@ static enum irdma_status_code irdma_sc_aeq_destroy(struct irdma_sc_aeq *aeq, · 16 unmodified lines | |||
| 3997 | * @aeq: aeq structure ptr | 3980 | * @aeq: aeq structure ptr |
| 3998 | * @info: aeqe info to be returned | 3981 | * @info: aeqe info to be returned |
| 3999 | */ | 3982 | */ |
| 4000 | enum irdma_status_code irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, | 3983 | int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, |
| 4001 | struct irdma_aeqe_info *info) | 3984 | struct irdma_aeqe_info *info) |
| 4002 | { | 3985 | { |
| 4003 | u64 temp, compl_ctx; | 3986 | u64 temp, compl_ctx; |
| 4004 | __le64 *aeqe; | 3987 | __le64 *aeqe; |
| @@ -4012,7 +3995,7 @@ enum irdma_status_code irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, · 7 unmodified lines | |||
| 4012 | polarity = (u8)FIELD_GET(IRDMA_AEQE_VALID, temp); | 3995 | polarity = (u8)FIELD_GET(IRDMA_AEQE_VALID, temp); |
| 4013 | 3996 | ||
| 4014 | if (aeq->polarity != polarity) | 3997 | if (aeq->polarity != polarity) |
| 4015 | return IRDMA_ERR_Q_EMPTY; | 3998 | return -ENOENT; |
| 4016 | 3999 | ||
| 4017 | print_hex_dump_debug("WQE: AEQ_ENTRY WQE", DUMP_PREFIX_OFFSET, 16, 8, | 4000 | print_hex_dump_debug("WQE: AEQ_ENTRY WQE", DUMP_PREFIX_OFFSET, 16, 8, |
| 4018 | aeqe, 16, false); | 4001 | aeqe, 16, false); |
| @@ -4157,22 +4140,21 @@ void irdma_sc_repost_aeq_entries(struct irdma_sc_dev *dev, u32 count) · 138 unmodified lines | |||
| 4157 | * @cq: sc's cq ctruct | 4140 | * @cq: sc's cq ctruct |
| 4158 | * @info: info for control cq initialization | 4141 | * @info: info for control cq initialization |
| 4159 | */ | 4142 | */ |
| 4160 | enum irdma_status_code irdma_sc_ccq_init(struct irdma_sc_cq *cq, | 4143 | int irdma_sc_ccq_init(struct irdma_sc_cq *cq, struct irdma_ccq_init_info *info) |
| 4161 | struct irdma_ccq_init_info *info) | ||
| 4162 | { | 4144 | { |
| 4163 | u32 pble_obj_cnt; | 4145 | u32 pble_obj_cnt; |
| 4164 | 4146 | ||
| 4165 | if (info->num_elem < info->dev->hw_attrs.uk_attrs.min_hw_cq_size || | 4147 | if (info->num_elem < info->dev->hw_attrs.uk_attrs.min_hw_cq_size || |
| 4166 | info->num_elem > info->dev->hw_attrs.uk_attrs.max_hw_cq_size) | 4148 | info->num_elem > info->dev->hw_attrs.uk_attrs.max_hw_cq_size) |
| 4167 | return IRDMA_ERR_INVALID_SIZE; | 4149 | return -EINVAL; |
| 4168 | 4150 | ||
| 4169 | if (info->ceq_id > (info->dev->hmc_fpm_misc.max_ceqs - 1)) | 4151 | if (info->ceq_id >= info->dev->hmc_fpm_misc.max_ceqs) |
| 4170 | return IRDMA_ERR_INVALID_CEQ_ID; | 4152 | return -EINVAL; |
| 4171 | 4153 | ||
| 4172 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; | 4154 | pble_obj_cnt = info->dev->hmc_info->hmc_obj[IRDMA_HMC_IW_PBLE].cnt; |
| 4173 | 4155 | ||
| 4174 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) | 4156 | if (info->virtual_map && info->first_pm_pbl_idx >= pble_obj_cnt) |
| 4175 | return IRDMA_ERR_INVALID_PBLE_INDEX; | 4157 | return -EINVAL; |
| 4176 | 4158 | ||
| 4177 | cq->cq_pa = info->cq_pa; | 4159 | cq->cq_pa = info->cq_pa; |
| 4178 | cq->cq_uk.cq_base = info->cq_base; | 4160 | cq->cq_uk.cq_base = info->cq_base; |
| @@ -4209,7 +4191,7 @@ enum irdma_status_code irdma_sc_ccq_init(struct irdma_sc_cq *cq, · 30 unmodified lines | |||
| 4209 | * irdma_sc_ccq_create_done - poll cqp for ccq create | 4191 | * irdma_sc_ccq_create_done - poll cqp for ccq create |
| 4210 | * @ccq: ccq sc struct | 4192 | * @ccq: ccq sc struct |
| 4211 | */ | 4193 | */ |
| 4212 | static inline enum irdma_status_code irdma_sc_ccq_create_done(struct irdma_sc_cq *ccq) | 4194 | static inline int irdma_sc_ccq_create_done(struct irdma_sc_cq *ccq) |
| 4213 | { | 4195 | { |
| 4214 | struct irdma_sc_cqp *cqp; | 4196 | struct irdma_sc_cqp *cqp; |
| 4215 | 4197 | ||
| @@ -4225,10 +4207,10 @@ static inline enum irdma_status_code irdma_sc_ccq_create_done(struct irdma_sc_cq · 9 unmodified lines | |||
| 4225 | * @check_overflow: overlow flag for ccq | 4207 | * @check_overflow: overlow flag for ccq |
| 4226 | * @post_sq: flag for cqp db to ring | 4208 | * @post_sq: flag for cqp db to ring |
| 4227 | */ | 4209 | */ |
| 4228 | enum irdma_status_code irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, | 4210 | int irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, |
| 4229 | bool check_overflow, bool post_sq) | 4211 | bool check_overflow, bool post_sq) |
| 4230 | { | 4212 | { |
| 4231 | enum irdma_status_code ret_code; | 4213 | int ret_code; |
| 4232 | 4214 | ||
| 4233 | ret_code = irdma_sc_cq_create(ccq, scratch, check_overflow, post_sq); | 4215 | ret_code = irdma_sc_cq_create(ccq, scratch, check_overflow, post_sq); |
| 4234 | if (ret_code) | 4216 | if (ret_code) |
| @@ -4250,19 +4232,18 @@ enum irdma_status_code irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, · 15 unmodified lines | |||
| 4250 | * @scratch: u64 saved to be used during cqp completion | 4232 | * @scratch: u64 saved to be used during cqp completion |
| 4251 | * @post_sq: flag for cqp db to ring | 4233 | * @post_sq: flag for cqp db to ring |
| 4252 | */ | 4234 | */ |
| 4253 | enum irdma_status_code irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, | 4235 | int irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, bool post_sq) |
| 4254 | bool post_sq) | ||
| 4255 | { | 4236 | { |
| 4256 | struct irdma_sc_cqp *cqp; | 4237 | struct irdma_sc_cqp *cqp; |
| 4257 | __le64 *wqe; | 4238 | __le64 *wqe; |
| 4258 | u64 hdr; | 4239 | u64 hdr; |
| 4259 | enum irdma_status_code ret_code = 0; | 4240 | int ret_code = 0; |
| 4260 | u32 tail, val, error; | 4241 | u32 tail, val, error; |
| 4261 | 4242 | ||
| 4262 | cqp = ccq->dev->cqp; | 4243 | cqp = ccq->dev->cqp; |
| 4263 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 4244 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 4264 | if (!wqe) | 4245 | if (!wqe) |
| 4265 | return IRDMA_ERR_RING_FULL; | 4246 | return -ENOMEM; |
| 4266 | 4247 | ||
| 4267 | set_64bit_val(wqe, 0, ccq->cq_uk.cq_size); | 4248 | set_64bit_val(wqe, 0, ccq->cq_uk.cq_size); |
| 4268 | set_64bit_val(wqe, 8, (uintptr_t)ccq >> 1); | 4249 | set_64bit_val(wqe, 8, (uintptr_t)ccq >> 1); |
| @@ -4301,13 +4282,12 @@ enum irdma_status_code irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch · 32 unmodified lines | |||
| 4301 | * @dev : ptr to irdma_dev struct | 4282 | * @dev : ptr to irdma_dev struct |
| 4302 | * @hmc_fn_id: hmc function id | 4283 | * @hmc_fn_id: hmc function id |
| 4303 | */ | 4284 | */ |
| 4304 | enum irdma_status_code irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, | 4285 | int irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, u8 hmc_fn_id) |
| 4305 | u8 hmc_fn_id) | ||
| 4306 | { | 4286 | { |
| 4307 | struct irdma_hmc_info *hmc_info; | 4287 | struct irdma_hmc_info *hmc_info; |
| 4308 | struct irdma_hmc_fpm_misc *hmc_fpm_misc; | 4288 | struct irdma_hmc_fpm_misc *hmc_fpm_misc; |
| 4309 | struct irdma_dma_mem query_fpm_mem; | 4289 | struct irdma_dma_mem query_fpm_mem; |
| 4310 | enum irdma_status_code ret_code = 0; | 4290 | int ret_code = 0; |
| 4311 | u8 wait_type; | 4291 | u8 wait_type; |
| 4312 | 4292 | ||
| 4313 | hmc_info = dev->hmc_info; | 4293 | hmc_info = dev->hmc_info; |
| @@ -4338,14 +4318,13 @@ enum irdma_status_code irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, · 24 unmodified lines | |||
| 4338 | * @dev : ptr to irdma_dev struct | 4318 | * @dev : ptr to irdma_dev struct |
| 4339 | * @hmc_fn_id: hmc function id | 4319 | * @hmc_fn_id: hmc function id |
| 4340 | */ | 4320 | */ |
| 4341 | static enum irdma_status_code irdma_sc_cfg_iw_fpm(struct irdma_sc_dev *dev, | 4321 | static int irdma_sc_cfg_iw_fpm(struct irdma_sc_dev *dev, u8 hmc_fn_id) |
| 4342 | u8 hmc_fn_id) | ||
| 4343 | { | 4322 | { |
| 4344 | struct irdma_hmc_info *hmc_info; | 4323 | struct irdma_hmc_info *hmc_info; |
| 4345 | struct irdma_hmc_obj_info *obj_info; | 4324 | struct irdma_hmc_obj_info *obj_info; |
| 4346 | __le64 *buf; | 4325 | __le64 *buf; |
| 4347 | struct irdma_dma_mem commit_fpm_mem; | 4326 | struct irdma_dma_mem commit_fpm_mem; |
| 4348 | enum irdma_status_code ret_code = 0; | 4327 | int ret_code = 0; |
| 4349 | u8 wait_type; | 4328 | u8 wait_type; |
| 4350 | 4329 | ||
| 4351 | hmc_info = dev->hmc_info; | 4330 | hmc_info = dev->hmc_info; |
| @@ -4408,9 +4387,8 @@ static enum irdma_status_code irdma_sc_cfg_iw_fpm(struct irdma_sc_dev *dev, · 56 unmodified lines | |||
| 4408 | * @info: sd info for wqe | 4387 | * @info: sd info for wqe |
| 4409 | * @scratch: u64 saved to be used during cqp completion | 4388 | * @scratch: u64 saved to be used during cqp completion |
| 4410 | */ | 4389 | */ |
| 4411 | static enum irdma_status_code | 4390 | static int cqp_sds_wqe_fill(struct irdma_sc_cqp *cqp, |
| 4412 | cqp_sds_wqe_fill(struct irdma_sc_cqp *cqp, struct irdma_update_sds_info *info, | 4391 | struct irdma_update_sds_info *info, u64 scratch) |
| 4413 | u64 scratch) | ||
| 4414 | { | 4392 | { |
| 4415 | u64 data; | 4393 | u64 data; |
| 4416 | u64 hdr; | 4394 | u64 hdr; |
| @@ -4422,7 +4400,7 @@ cqp_sds_wqe_fill(struct irdma_sc_cqp *cqp, struct irdma_update_sds_info *info, · 5 unmodified lines | |||
| 4422 | 4400 | ||
| 4423 | wqe = irdma_sc_cqp_get_next_send_wqe_idx(cqp, scratch, &wqe_idx); | 4401 | wqe = irdma_sc_cqp_get_next_send_wqe_idx(cqp, scratch, &wqe_idx); |
| 4424 | if (!wqe) | 4402 | if (!wqe) |
| 4425 | return IRDMA_ERR_RING_FULL; | 4403 | return -ENOMEM; |
| 4426 | 4404 | ||
| 4427 | wqe_entries = (info->cnt > 3) ? 3 : info->cnt; | 4405 | wqe_entries = (info->cnt > 3) ? 3 : info->cnt; |
| 4428 | mem_entries = info->cnt - wqe_entries; | 4406 | mem_entries = info->cnt - wqe_entries; |
| @@ -4488,12 +4466,11 @@ cqp_sds_wqe_fill(struct irdma_sc_cqp *cqp, struct irdma_update_sds_info *info, · 59 unmodified lines | |||
| 4488 | * @info: sd info for sd's | 4466 | * @info: sd info for sd's |
| 4489 | * @scratch: u64 saved to be used during cqp completion | 4467 | * @scratch: u64 saved to be used during cqp completion |
| 4490 | */ | 4468 | */ |
| 4491 | static enum irdma_status_code | 4469 | static int irdma_update_pe_sds(struct irdma_sc_dev *dev, |
| 4492 | irdma_update_pe_sds(struct irdma_sc_dev *dev, | 4470 | struct irdma_update_sds_info *info, u64 scratch) |
| 4493 | struct irdma_update_sds_info *info, u64 scratch) | ||
| 4494 | { | 4471 | { |
| 4495 | struct irdma_sc_cqp *cqp = dev->cqp; | 4472 | struct irdma_sc_cqp *cqp = dev->cqp; |
| 4496 | enum irdma_status_code ret_code; | 4473 | int ret_code; |
| 4497 | 4474 | ||
| 4498 | ret_code = cqp_sds_wqe_fill(cqp, info, scratch); | 4475 | ret_code = cqp_sds_wqe_fill(cqp, info, scratch); |
| 4499 | if (!ret_code) | 4476 | if (!ret_code) |
| @@ -4507,13 +4484,12 @@ irdma_update_pe_sds(struct irdma_sc_dev *dev, · 7 unmodified lines | |||
| 4507 | * @dev: sc device struct | 4484 | * @dev: sc device struct |
| 4508 | * @info: sd info for sd's | 4485 | * @info: sd info for sd's |
| 4509 | */ | 4486 | */ |
| 4510 | enum irdma_status_code | 4487 | int irdma_update_sds_noccq(struct irdma_sc_dev *dev, |
| 4511 | irdma_update_sds_noccq(struct irdma_sc_dev *dev, | 4488 | struct irdma_update_sds_info *info) |
| 4512 | struct irdma_update_sds_info *info) | ||
| 4513 | { | 4489 | { |
| 4514 | u32 error, val, tail; | 4490 | u32 error, val, tail; |
| 4515 | struct irdma_sc_cqp *cqp = dev->cqp; | 4491 | struct irdma_sc_cqp *cqp = dev->cqp; |
| 4516 | enum irdma_status_code ret_code; | 4492 | int ret_code; |
| 4517 | 4493 | ||
| 4518 | ret_code = cqp_sds_wqe_fill(cqp, info, 0); | 4494 | ret_code = cqp_sds_wqe_fill(cqp, info, 0); |
| 4519 | if (ret_code) | 4495 | if (ret_code) |
| @@ -4534,10 +4510,9 @@ irdma_update_sds_noccq(struct irdma_sc_dev *dev, · 14 unmodified lines | |||
| 4534 | * @post_sq: flag for cqp db to ring | 4510 | * @post_sq: flag for cqp db to ring |
| 4535 | * @poll_registers: flag to poll register for cqp completion | 4511 | * @poll_registers: flag to poll register for cqp completion |
| 4536 | */ | 4512 | */ |
| 4537 | enum irdma_status_code | 4513 | int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, |
| 4538 | irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, | 4514 | u8 hmc_fn_id, bool post_sq, |
| 4539 | u8 hmc_fn_id, bool post_sq, | 4515 | bool poll_registers) |
| 4540 | bool poll_registers) | ||
| 4541 | { | 4516 | { |
| 4542 | u64 hdr; | 4517 | u64 hdr; |
| 4543 | __le64 *wqe; | 4518 | __le64 *wqe; |
| @@ -4545,7 +4520,7 @@ irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, · 1 unmodified line | |||
| 4545 | 4520 | ||
| 4546 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 4521 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 4547 | if (!wqe) | 4522 | if (!wqe) |
| 4548 | return IRDMA_ERR_RING_FULL; | 4523 | return -ENOMEM; |
| 4549 | 4524 | ||
| 4550 | set_64bit_val(wqe, 16, | 4525 | set_64bit_val(wqe, 16, |
| 4551 | FIELD_PREP(IRDMA_SHMC_PAGE_ALLOCATED_HMC_FN_ID, hmc_fn_id)); | 4526 | FIELD_PREP(IRDMA_SHMC_PAGE_ALLOCATED_HMC_FN_ID, hmc_fn_id)); |
| @@ -4620,8 +4595,7 @@ static u32 irdma_est_sd(struct irdma_sc_dev *dev, · 68 unmodified lines | |||
| 4620 | * irdma_sc_query_rdma_features_done - poll cqp for query features done | 4595 | * irdma_sc_query_rdma_features_done - poll cqp for query features done |
| 4621 | * @cqp: struct for cqp hw | 4596 | * @cqp: struct for cqp hw |
| 4622 | */ | 4597 | */ |
| 4623 | static enum irdma_status_code | 4598 | static int irdma_sc_query_rdma_features_done(struct irdma_sc_cqp *cqp) |
| 4624 | irdma_sc_query_rdma_features_done(struct irdma_sc_cqp *cqp) | ||
| 4625 | { | 4599 | { |
| 4626 | return irdma_sc_poll_for_cqp_op_done(cqp, | 4600 | return irdma_sc_poll_for_cqp_op_done(cqp, |
| 4627 | IRDMA_CQP_OP_QUERY_RDMA_FEATURES, | 4601 | IRDMA_CQP_OP_QUERY_RDMA_FEATURES, |
| @@ -4634,16 +4608,15 @@ irdma_sc_query_rdma_features_done(struct irdma_sc_cqp *cqp) · 6 unmodified lines | |||
| 4634 | * @buf: buffer to hold query info | 4608 | * @buf: buffer to hold query info |
| 4635 | * @scratch: u64 saved to be used during cqp completion | 4609 | * @scratch: u64 saved to be used during cqp completion |
| 4636 | */ | 4610 | */ |
| 4637 | static enum irdma_status_code | 4611 | static int irdma_sc_query_rdma_features(struct irdma_sc_cqp *cqp, |
| 4638 | irdma_sc_query_rdma_features(struct irdma_sc_cqp *cqp, | 4612 | struct irdma_dma_mem *buf, u64 scratch) |
| 4639 | struct irdma_dma_mem *buf, u64 scratch) | ||
| 4640 | { | 4613 | { |
| 4641 | __le64 *wqe; | 4614 | __le64 *wqe; |
| 4642 | u64 temp; | 4615 | u64 temp; |
| 4643 | 4616 | ||
| 4644 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 4617 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 4645 | if (!wqe) | 4618 | if (!wqe) |
| 4646 | return IRDMA_ERR_RING_FULL; | 4619 | return -ENOMEM; |
| 4647 | 4620 | ||
| 4648 | temp = buf->pa; | 4621 | temp = buf->pa; |
| 4649 | set_64bit_val(wqe, 32, temp); | 4622 | set_64bit_val(wqe, 32, temp); |
| @@ -4667,9 +4640,9 @@ irdma_sc_query_rdma_features(struct irdma_sc_cqp *cqp, · 17 unmodified lines | |||
| 4667 | * irdma_get_rdma_features - get RDMA features | 4640 | * irdma_get_rdma_features - get RDMA features |
| 4668 | * @dev: sc device struct | 4641 | * @dev: sc device struct |
| 4669 | */ | 4642 | */ |
| 4670 | enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev) | 4643 | int irdma_get_rdma_features(struct irdma_sc_dev *dev) |
| 4671 | { | 4644 | { |
| 4672 | enum irdma_status_code ret_code; | 4645 | int ret_code; |
| 4673 | struct irdma_dma_mem feat_buf; | 4646 | struct irdma_dma_mem feat_buf; |
| 4674 | u64 temp; | 4647 | u64 temp; |
| 4675 | u16 byte_idx, feat_type, feat_cnt, feat_idx; | 4648 | u16 byte_idx, feat_type, feat_cnt, feat_idx; |
| @@ -4679,7 +4652,7 @@ enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev) · 3 unmodified lines | |||
| 4679 | feat_buf.va = dma_alloc_coherent(dev->hw->device, feat_buf.size, | 4652 | feat_buf.va = dma_alloc_coherent(dev->hw->device, feat_buf.size, |
| 4680 | &feat_buf.pa, GFP_KERNEL); | 4653 | &feat_buf.pa, GFP_KERNEL); |
| 4681 | if (!feat_buf.va) | 4654 | if (!feat_buf.va) |
| 4682 | return IRDMA_ERR_NO_MEMORY; | 4655 | return -ENOMEM; |
| 4683 | 4656 | ||
| 4684 | ret_code = irdma_sc_query_rdma_features(dev->cqp, &feat_buf, 0); | 4657 | ret_code = irdma_sc_query_rdma_features(dev->cqp, &feat_buf, 0); |
| 4685 | if (!ret_code) | 4658 | if (!ret_code) |
| @@ -4690,7 +4663,7 @@ enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev) · 4 unmodified lines | |||
| 4690 | get_64bit_val(feat_buf.va, 0, &temp); | 4663 | get_64bit_val(feat_buf.va, 0, &temp); |
| 4691 | feat_cnt = (u16)FIELD_GET(IRDMA_FEATURE_CNT, temp); | 4664 | feat_cnt = (u16)FIELD_GET(IRDMA_FEATURE_CNT, temp); |
| 4692 | if (feat_cnt < 2) { | 4665 | if (feat_cnt < 2) { |
| 4693 | ret_code = IRDMA_ERR_INVALID_FEAT_CNT; | 4666 | ret_code = -EINVAL; |
| 4694 | goto exit; | 4667 | goto exit; |
| 4695 | } else if (feat_cnt > IRDMA_MAX_FEATURES) { | 4668 | } else if (feat_cnt > IRDMA_MAX_FEATURES) { |
| 4696 | ibdev_dbg(to_ibdev(dev), | 4669 | ibdev_dbg(to_ibdev(dev), |
| @@ -4704,7 +4677,7 @@ enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev) · 7 unmodified lines | |||
| 4704 | feat_buf.size, &feat_buf.pa, | 4677 | feat_buf.size, &feat_buf.pa, |
| 4705 | GFP_KERNEL); | 4678 | GFP_KERNEL); |
| 4706 | if (!feat_buf.va) | 4679 | if (!feat_buf.va) |
| 4707 | return IRDMA_ERR_NO_MEMORY; | 4680 | return -ENOMEM; |
| 4708 | 4681 | ||
| 4709 | ret_code = irdma_sc_query_rdma_features(dev->cqp, &feat_buf, 0); | 4682 | ret_code = irdma_sc_query_rdma_features(dev->cqp, &feat_buf, 0); |
| 4710 | if (!ret_code) | 4683 | if (!ret_code) |
| @@ -4715,7 +4688,7 @@ enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev) · 4 unmodified lines | |||
| 4715 | get_64bit_val(feat_buf.va, 0, &temp); | 4688 | get_64bit_val(feat_buf.va, 0, &temp); |
| 4716 | feat_cnt = (u16)FIELD_GET(IRDMA_FEATURE_CNT, temp); | 4689 | feat_cnt = (u16)FIELD_GET(IRDMA_FEATURE_CNT, temp); |
| 4717 | if (feat_cnt < 2) { | 4690 | if (feat_cnt < 2) { |
| 4718 | ret_code = IRDMA_ERR_INVALID_FEAT_CNT; | 4691 | ret_code = -EINVAL; |
| 4719 | goto exit; | 4692 | goto exit; |
| 4720 | } | 4693 | } |
| 4721 | } | 4694 | } |
| @@ -4794,7 +4767,7 @@ static void cfg_fpm_value_gen_2(struct irdma_sc_dev *dev, · 72 unmodified lines | |||
| 4794 | * @dev: sc device struct | 4767 | * @dev: sc device struct |
| 4795 | * @qp_count: desired qp count | 4768 | * @qp_count: desired qp count |
| 4796 | */ | 4769 | */ |
| 4797 | enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) | 4770 | int irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) |
| 4798 | { | 4771 | { |
| 4799 | struct irdma_virt_mem virt_mem; | 4772 | struct irdma_virt_mem virt_mem; |
| 4800 | u32 i, mem_size; | 4773 | u32 i, mem_size; |
| @@ -4805,7 +4778,7 @@ enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) · 4 unmodified lines | |||
| 4805 | u32 loop_count = 0; | 4778 | u32 loop_count = 0; |
| 4806 | struct irdma_hmc_info *hmc_info; | 4779 | struct irdma_hmc_info *hmc_info; |
| 4807 | struct irdma_hmc_fpm_misc *hmc_fpm_misc; | 4780 | struct irdma_hmc_fpm_misc *hmc_fpm_misc; |
| 4808 | enum irdma_status_code ret_code = 0; | 4781 | int ret_code = 0; |
| 4809 | 4782 | ||
| 4810 | hmc_info = dev->hmc_info; | 4783 | hmc_info = dev->hmc_info; |
| 4811 | hmc_fpm_misc = &dev->hmc_fpm_misc; | 4784 | hmc_fpm_misc = &dev->hmc_fpm_misc; |
| @@ -4932,7 +4905,7 @@ enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) · 120 unmodified lines | |||
| 4932 | ibdev_dbg(to_ibdev(dev), | 4905 | ibdev_dbg(to_ibdev(dev), |
| 4933 | "HMC: cfg_fpm failed loop_cnt=%d, sd_needed=%d, max sd count %d\n", | 4906 | "HMC: cfg_fpm failed loop_cnt=%d, sd_needed=%d, max sd count %d\n", |
| 4934 | loop_count, sd_needed, hmc_info->sd_table.sd_cnt); | 4907 | loop_count, sd_needed, hmc_info->sd_table.sd_cnt); |
| 4935 | return IRDMA_ERR_CFG; | 4908 | return -EINVAL; |
| 4936 | } | 4909 | } |
| 4937 | 4910 | ||
| 4938 | if (loop_count > 1 && sd_needed < hmc_fpm_misc->max_sds) { | 4911 | if (loop_count > 1 && sd_needed < hmc_fpm_misc->max_sds) { |
| @@ -4968,7 +4941,7 @@ enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) · 29 unmodified lines | |||
| 4968 | if (!virt_mem.va) { | 4941 | if (!virt_mem.va) { |
| 4969 | ibdev_dbg(to_ibdev(dev), | 4942 | ibdev_dbg(to_ibdev(dev), |
| 4970 | "HMC: failed to allocate memory for sd_entry buffer\n"); | 4943 | "HMC: failed to allocate memory for sd_entry buffer\n"); |
| 4971 | return IRDMA_ERR_NO_MEMORY; | 4944 | return -ENOMEM; |
| 4972 | } | 4945 | } |
| 4973 | hmc_info->sd_table.sd_entry = virt_mem.va; | 4946 | hmc_info->sd_table.sd_entry = virt_mem.va; |
| 4974 | 4947 | ||
| @@ -4980,10 +4953,10 @@ enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count) · 5 unmodified lines | |||
| 4980 | * @dev: rdma device | 4953 | * @dev: rdma device |
| 4981 | * @pcmdinfo: cqp command info | 4954 | * @pcmdinfo: cqp command info |
| 4982 | */ | 4955 | */ |
| 4983 | static enum irdma_status_code irdma_exec_cqp_cmd(struct irdma_sc_dev *dev, | 4956 | static int irdma_exec_cqp_cmd(struct irdma_sc_dev *dev, |
| 4984 | struct cqp_cmds_info *pcmdinfo) | 4957 | struct cqp_cmds_info *pcmdinfo) |
| 4985 | { | 4958 | { |
| 4986 | enum irdma_status_code status; | 4959 | int status; |
| 4987 | struct irdma_dma_mem val_mem; | 4960 | struct irdma_dma_mem val_mem; |
| 4988 | bool alloc = false; | 4961 | bool alloc = false; |
| 4989 | 4962 | ||
| @@ -5245,7 +5218,7 @@ static enum irdma_status_code irdma_exec_cqp_cmd(struct irdma_sc_dev *dev, · 255 unmodified lines | |||
| 5245 | pcmdinfo->in.u.mc_modify.scratch); | 5218 | pcmdinfo->in.u.mc_modify.scratch); |
| 5246 | break; | 5219 | break; |
| 5247 | default: | 5220 | default: |
| 5248 | status = IRDMA_NOT_SUPPORTED; | 5221 | status = -EOPNOTSUPP; |
| 5249 | break; | 5222 | break; |
| 5250 | } | 5223 | } |
| 5251 | 5224 | ||
| @@ -5257,10 +5230,10 @@ static enum irdma_status_code irdma_exec_cqp_cmd(struct irdma_sc_dev *dev, · 5 unmodified lines | |||
| 5257 | * @dev: sc device struct | 5230 | * @dev: sc device struct |
| 5258 | * @pcmdinfo: cqp command info | 5231 | * @pcmdinfo: cqp command info |
| 5259 | */ | 5232 | */ |
| 5260 | enum irdma_status_code irdma_process_cqp_cmd(struct irdma_sc_dev *dev, | 5233 | int irdma_process_cqp_cmd(struct irdma_sc_dev *dev, |
| 5261 | struct cqp_cmds_info *pcmdinfo) | 5234 | struct cqp_cmds_info *pcmdinfo) |
| 5262 | { | 5235 | { |
| 5263 | enum irdma_status_code status = 0; | 5236 | int status = 0; |
| 5264 | unsigned long flags; | 5237 | unsigned long flags; |
| 5265 | 5238 | ||
| 5266 | spin_lock_irqsave(&dev->cqp_lock, flags); | 5239 | spin_lock_irqsave(&dev->cqp_lock, flags); |
| @@ -5276,9 +5249,9 @@ enum irdma_status_code irdma_process_cqp_cmd(struct irdma_sc_dev *dev, · 9 unmodified lines | |||
| 5276 | * irdma_process_bh - called from tasklet for cqp list | 5249 | * irdma_process_bh - called from tasklet for cqp list |
| 5277 | * @dev: sc device struct | 5250 | * @dev: sc device struct |
| 5278 | */ | 5251 | */ |
| 5279 | enum irdma_status_code irdma_process_bh(struct irdma_sc_dev *dev) | 5252 | int irdma_process_bh(struct irdma_sc_dev *dev) |
| 5280 | { | 5253 | { |
| 5281 | enum irdma_status_code status = 0; | 5254 | int status = 0; |
| 5282 | struct cqp_cmds_info *pcmdinfo; | 5255 | struct cqp_cmds_info *pcmdinfo; |
| 5283 | unsigned long flags; | 5256 | unsigned long flags; |
| 5284 | 5257 | ||
| @@ -5366,12 +5339,11 @@ static inline void irdma_sc_init_hw(struct irdma_sc_dev *dev) · 81 unmodified lines | |||
| 5366 | * @dev: Device pointer | 5339 | * @dev: Device pointer |
| 5367 | * @info: Device init info | 5340 | * @info: Device init info |
| 5368 | */ | 5341 | */ |
| 5369 | enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver, | 5342 | int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev, |
| 5370 | struct irdma_sc_dev *dev, | 5343 | struct irdma_device_init_info *info) |
| 5371 | struct irdma_device_init_info *info) | ||
| 5372 | { | 5344 | { |
| 5373 | u32 val; | 5345 | u32 val; |
| 5374 | enum irdma_status_code ret_code = 0; | 5346 | int ret_code = 0; |
| 5375 | u8 db_size; | 5347 | u8 db_size; |
| 5376 | 5348 | ||
| 5377 | INIT_LIST_HEAD(&dev->cqp_cmd_head); /* for CQP command backlog */ | 5349 | INIT_LIST_HEAD(&dev->cqp_cmd_head); /* for CQP command backlog */ |
| @@ -5415,7 +5387,7 @@ enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver, · 37 unmodified lines | |||
| 5415 | irdma_sc_init_hw(dev); | 5387 | irdma_sc_init_hw(dev); |
| 5416 | 5388 | ||
| 5417 | if (irdma_wait_pe_ready(dev)) | 5389 | if (irdma_wait_pe_ready(dev)) |
| 5418 | return IRDMA_ERR_TIMEOUT; | 5390 | return -ETIMEDOUT; |
| 5419 | 5391 | ||
| 5420 | val = readl(dev->hw_regs[IRDMA_GLPCI_LBARCTRL]); | 5392 | val = readl(dev->hw_regs[IRDMA_GLPCI_LBARCTRL]); |
| 5421 | db_size = (u8)FIELD_GET(IRDMA_GLPCI_LBARCTRL_PE_DB_SIZE, val); | 5393 | db_size = (u8)FIELD_GET(IRDMA_GLPCI_LBARCTRL_PE_DB_SIZE, val); |
| @@ -5423,7 +5395,7 @@ enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver, · 1 unmodified line | |||
| 5423 | ibdev_dbg(to_ibdev(dev), | 5395 | ibdev_dbg(to_ibdev(dev), |
| 5424 | "DEV: RDMA PE doorbell is not enabled in CSR val 0x%x db_size=%d\n", | 5396 | "DEV: RDMA PE doorbell is not enabled in CSR val 0x%x db_size=%d\n", |
| 5425 | val, db_size); | 5397 | val, db_size); |
| 5426 | return IRDMA_ERR_PE_DOORBELL_NOT_ENA; | 5398 | return -ENODEV; |
| 5427 | } | 5399 | } |
| 5428 | dev->db_addr = dev->hw->hw_addr + (uintptr_t)dev->hw_regs[IRDMA_DB_ADDR_OFFSET]; | 5400 | dev->db_addr = dev->hw->hw_addr + (uintptr_t)dev->hw_regs[IRDMA_DB_ADDR_OFFSET]; |
| 5429 | 5401 | ||
| @@ -964,7 +964,7 @@ enum irdma_cqp_op_type { · 963 unmodified lines | |||
| 964 | (_ring).head = ((_ring).head + 1) % size; \ | 964 | (_ring).head = ((_ring).head + 1) % size; \ |
| 965 | (_retcode) = 0; \ | 965 | (_retcode) = 0; \ |
| 966 | } else { \ | 966 | } else { \ |
| 967 | (_retcode) = IRDMA_ERR_RING_FULL; \ | 967 | (_retcode) = -ENOMEM; \ |
| 968 | } \ | 968 | } \ |
| 969 | } | 969 | } |
| 970 | #define IRDMA_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ | 970 | #define IRDMA_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ |
| @@ -975,7 +975,7 @@ enum irdma_cqp_op_type { · 4 unmodified lines | |||
| 975 | (_ring).head = ((_ring).head + (_count)) % size; \ | 975 | (_ring).head = ((_ring).head + (_count)) % size; \ |
| 976 | (_retcode) = 0; \ | 976 | (_retcode) = 0; \ |
| 977 | } else { \ | 977 | } else { \ |
| 978 | (_retcode) = IRDMA_ERR_RING_FULL; \ | 978 | (_retcode) = -ENOMEM; \ |
| 979 | } \ | 979 | } \ |
| 980 | } | 980 | } |
| 981 | #define IRDMA_SQ_RING_MOVE_HEAD(_ring, _retcode) \ | 981 | #define IRDMA_SQ_RING_MOVE_HEAD(_ring, _retcode) \ |
| @@ -986,7 +986,7 @@ enum irdma_cqp_op_type { · 4 unmodified lines | |||
| 986 | (_ring).head = ((_ring).head + 1) % size; \ | 986 | (_ring).head = ((_ring).head + 1) % size; \ |
| 987 | (_retcode) = 0; \ | 987 | (_retcode) = 0; \ |
| 988 | } else { \ | 988 | } else { \ |
| 989 | (_retcode) = IRDMA_ERR_RING_FULL; \ | 989 | (_retcode) = -ENOMEM; \ |
| 990 | } \ | 990 | } \ |
| 991 | } | 991 | } |
| 992 | #define IRDMA_SQ_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ | 992 | #define IRDMA_SQ_RING_MOVE_HEAD_BY_COUNT(_ring, _count, _retcode) \ |
| @@ -997,7 +997,7 @@ enum irdma_cqp_op_type { · 4 unmodified lines | |||
| 997 | (_ring).head = ((_ring).head + (_count)) % size; \ | 997 | (_ring).head = ((_ring).head + (_count)) % size; \ |
| 998 | (_retcode) = 0; \ | 998 | (_retcode) = 0; \ |
| 999 | } else { \ | 999 | } else { \ |
| 1000 | (_retcode) = IRDMA_ERR_RING_FULL; \ | 1000 | (_retcode) = -ENOMEM; \ |
| 1001 | } \ | 1001 | } \ |
| 1002 | } | 1002 | } |
| 1003 | #define IRDMA_RING_MOVE_HEAD_BY_COUNT_NOCHECK(_ring, _count) \ | 1003 | #define IRDMA_RING_MOVE_HEAD_BY_COUNT_NOCHECK(_ring, _count) \ |
| @@ -1,7 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB | 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB |
| 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ | 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ |
| 3 | #include "osdep.h" | 3 | #include "osdep.h" |
| 4 | #include "status.h" | ||
| 5 | #include "hmc.h" | 4 | #include "hmc.h" |
| 6 | #include "defs.h" | 5 | #include "defs.h" |
| 7 | #include "type.h" | 6 | #include "type.h" |
| @@ -121,10 +120,8 @@ static inline void irdma_invalidate_pf_hmc_pd(struct irdma_sc_dev *dev, u32 sd_i · 113 unmodified lines | |||
| 121 | * @type: paged or direct sd | 120 | * @type: paged or direct sd |
| 122 | * @setsd: flag to set or clear sd | 121 | * @setsd: flag to set or clear sd |
| 123 | */ | 122 | */ |
| 124 | enum irdma_status_code irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, | 123 | int irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, u64 pa, u32 sd_idx, |
| 125 | u64 pa, u32 sd_idx, | 124 | enum irdma_sd_entry_type type, bool setsd) |
| 126 | enum irdma_sd_entry_type type, | ||
| 127 | bool setsd) | ||
| 128 | { | 125 | { |
| 129 | struct irdma_update_sds_info sdinfo; | 126 | struct irdma_update_sds_info sdinfo; |
| 130 | 127 | ||
| @@ -145,16 +142,15 @@ enum irdma_status_code irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, · 14 unmodified lines | |||
| 145 | * @sd_cnt: number of sd entries | 142 | * @sd_cnt: number of sd entries |
| 146 | * @setsd: flag to set or clear sd | 143 | * @setsd: flag to set or clear sd |
| 147 | */ | 144 | */ |
| 148 | static enum irdma_status_code irdma_hmc_sd_grp(struct irdma_sc_dev *dev, | 145 | static int irdma_hmc_sd_grp(struct irdma_sc_dev *dev, |
| 149 | struct irdma_hmc_info *hmc_info, | 146 | struct irdma_hmc_info *hmc_info, u32 sd_index, |
| 150 | u32 sd_index, u32 sd_cnt, | 147 | u32 sd_cnt, bool setsd) |
| 151 | bool setsd) | ||
| 152 | { | 148 | { |
| 153 | struct irdma_hmc_sd_entry *sd_entry; | 149 | struct irdma_hmc_sd_entry *sd_entry; |
| 154 | struct irdma_update_sds_info sdinfo = {}; | 150 | struct irdma_update_sds_info sdinfo = {}; |
| 155 | u64 pa; | 151 | u64 pa; |
| 156 | u32 i; | 152 | u32 i; |
| 157 | enum irdma_status_code ret_code = 0; | 153 | int ret_code = 0; |
| 158 | 154 | ||
| 159 | sdinfo.hmc_fn_id = hmc_info->hmc_fn_id; | 155 | sdinfo.hmc_fn_id = hmc_info->hmc_fn_id; |
| 160 | for (i = sd_index; i < sd_index + sd_cnt; i++) { | 156 | for (i = sd_index; i < sd_index + sd_cnt; i++) { |
| @@ -196,16 +192,15 @@ static enum irdma_status_code irdma_hmc_sd_grp(struct irdma_sc_dev *dev, · 35 unmodified lines | |||
| 196 | * @dev: pointer to the device structure | 192 | * @dev: pointer to the device structure |
| 197 | * @info: create obj info | 193 | * @info: create obj info |
| 198 | */ | 194 | */ |
| 199 | static enum irdma_status_code | 195 | static int irdma_hmc_finish_add_sd_reg(struct irdma_sc_dev *dev, |
| 200 | irdma_hmc_finish_add_sd_reg(struct irdma_sc_dev *dev, | 196 | struct irdma_hmc_create_obj_info *info) |
| 201 | struct irdma_hmc_create_obj_info *info) | ||
| 202 | { | 197 | { |
| 203 | if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) | 198 | if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) |
| 204 | return IRDMA_ERR_INVALID_HMC_OBJ_INDEX; | 199 | return -EINVAL; |
| 205 | 200 | ||
| 206 | if ((info->start_idx + info->count) > | 201 | if ((info->start_idx + info->count) > |
| 207 | info->hmc_info->hmc_obj[info->rsrc_type].cnt) | 202 | info->hmc_info->hmc_obj[info->rsrc_type].cnt) |
| 208 | return IRDMA_ERR_INVALID_HMC_OBJ_COUNT; | 203 | return -EINVAL; |
| 209 | 204 | ||
| 210 | if (!info->add_sd_cnt) | 205 | if (!info->add_sd_cnt) |
| 211 | return 0; | 206 | return 0; |
| @@ -222,9 +217,8 @@ irdma_hmc_finish_add_sd_reg(struct irdma_sc_dev *dev, · 10 unmodified lines | |||
| 222 | * This will allocate memory for PDs and backing pages and populate | 217 | * This will allocate memory for PDs and backing pages and populate |
| 223 | * the sd and pd entries. | 218 | * the sd and pd entries. |
| 224 | */ | 219 | */ |
| 225 | enum irdma_status_code | 220 | int irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, |
| 226 | irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, | 221 | struct irdma_hmc_create_obj_info *info) |
| 227 | struct irdma_hmc_create_obj_info *info) | ||
| 228 | { | 222 | { |
| 229 | struct irdma_hmc_sd_entry *sd_entry; | 223 | struct irdma_hmc_sd_entry *sd_entry; |
| 230 | u32 sd_idx, sd_lmt; | 224 | u32 sd_idx, sd_lmt; |
| @@ -232,10 +226,10 @@ irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, · 1 unmodified line | |||
| 232 | u32 pd_idx1 = 0, pd_lmt1 = 0; | 226 | u32 pd_idx1 = 0, pd_lmt1 = 0; |
| 233 | u32 i, j; | 227 | u32 i, j; |
| 234 | bool pd_error = false; | 228 | bool pd_error = false; |
| 235 | enum irdma_status_code ret_code = 0; | 229 | int ret_code = 0; |
| 236 | 230 | ||
| 237 | if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) | 231 | if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) |
| 238 | return IRDMA_ERR_INVALID_HMC_OBJ_INDEX; | 232 | return -EINVAL; |
| 239 | 233 | ||
| 240 | if ((info->start_idx + info->count) > | 234 | if ((info->start_idx + info->count) > |
| 241 | info->hmc_info->hmc_obj[info->rsrc_type].cnt) { | 235 | info->hmc_info->hmc_obj[info->rsrc_type].cnt) { |
| @@ -243,7 +237,7 @@ irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, · 1 unmodified line | |||
| 243 | "HMC: error type %u, start = %u, req cnt %u, cnt = %u\n", | 237 | "HMC: error type %u, start = %u, req cnt %u, cnt = %u\n", |
| 244 | info->rsrc_type, info->start_idx, info->count, | 238 | info->rsrc_type, info->start_idx, info->count, |
| 245 | info->hmc_info->hmc_obj[info->rsrc_type].cnt); | 239 | info->hmc_info->hmc_obj[info->rsrc_type].cnt); |
| 246 | return IRDMA_ERR_INVALID_HMC_OBJ_COUNT; | 240 | return -EINVAL; |
| 247 | } | 241 | } |
| 248 | 242 | ||
| 249 | irdma_find_sd_index_limit(info->hmc_info, info->rsrc_type, | 243 | irdma_find_sd_index_limit(info->hmc_info, info->rsrc_type, |
| @@ -251,7 +245,7 @@ irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, · 1 unmodified line | |||
| 251 | &sd_lmt); | 245 | &sd_lmt); |
| 252 | if (sd_idx >= info->hmc_info->sd_table.sd_cnt || | 246 | if (sd_idx >= info->hmc_info->sd_table.sd_cnt || |
| 253 | sd_lmt > info->hmc_info->sd_table.sd_cnt) { | 247 | sd_lmt > info->hmc_info->sd_table.sd_cnt) { |
| 254 | return IRDMA_ERR_INVALID_SD_INDEX; | 248 | return -EINVAL; |
| 255 | } | 249 | } |
| 256 | 250 | ||
| 257 | irdma_find_pd_index_limit(info->hmc_info, info->rsrc_type, | 251 | irdma_find_pd_index_limit(info->hmc_info, info->rsrc_type, |
| @@ -312,7 +306,7 @@ exit_sd_error: · 54 unmodified lines | |||
| 312 | irdma_prep_remove_pd_page(info->hmc_info, (j - 1)); | 306 | irdma_prep_remove_pd_page(info->hmc_info, (j - 1)); |
| 313 | break; | 307 | break; |
| 314 | default: | 308 | default: |
| 315 | ret_code = IRDMA_ERR_INVALID_SD_TYPE; | 309 | ret_code = -EINVAL; |
| 316 | break; | 310 | break; |
| 317 | } | 311 | } |
| 318 | j--; | 312 | j--; |
| @@ -327,12 +321,12 @@ exit_sd_error: · 8 unmodified lines | |||
| 327 | * @info: dele obj info | 321 | * @info: dele obj info |
| 328 | * @reset: true if called before reset | 322 | * @reset: true if called before reset |
| 329 | */ | 323 | */ |
| 330 | static enum irdma_status_code | 324 | static int irdma_finish_del_sd_reg(struct irdma_sc_dev *dev, |
| 331 | irdma_finish_del_sd_reg(struct irdma_sc_dev *dev, | 325 | struct irdma_hmc_del_obj_info *info, |
| 332 | struct irdma_hmc_del_obj_info *info, bool reset) | 326 | bool reset) |
| 333 | { | 327 | { |
| 334 | struct irdma_hmc_sd_entry *sd_entry; | 328 | struct irdma_hmc_sd_entry *sd_entry; |
| 335 | enum irdma_status_code ret_code = 0; | 329 | int ret_code = 0; |
| 336 | u32 i, sd_idx; | 330 | u32 i, sd_idx; |
| 337 | struct irdma_dma_mem *mem; | 331 | struct irdma_dma_mem *mem; |
| 338 | 332 | ||
| @@ -373,22 +367,21 @@ irdma_finish_del_sd_reg(struct irdma_sc_dev *dev, · 34 unmodified lines | |||
| 373 | * caller should deallocate memory allocated previously for | 367 | * caller should deallocate memory allocated previously for |
| 374 | * book-keeping information about PDs and backing storage. | 368 | * book-keeping information about PDs and backing storage. |
| 375 | */ | 369 | */ |
| 376 | enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, | 370 | int irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, |
| 377 | struct irdma_hmc_del_obj_info *info, | 371 | struct irdma_hmc_del_obj_info *info, bool reset) |
| 378 | bool reset) | ||
| 379 | { | 372 | { |
| 380 | struct irdma_hmc_pd_table *pd_table; | 373 | struct irdma_hmc_pd_table *pd_table; |
| 381 | u32 sd_idx, sd_lmt; | 374 | u32 sd_idx, sd_lmt; |
| 382 | u32 pd_idx, pd_lmt, rel_pd_idx; | 375 | u32 pd_idx, pd_lmt, rel_pd_idx; |
| 383 | u32 i, j; | 376 | u32 i, j; |
| 384 | enum irdma_status_code ret_code = 0; | 377 | int ret_code = 0; |
| 385 | 378 | ||
| 386 | if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) { | 379 | if (info->start_idx >= info->hmc_info->hmc_obj[info->rsrc_type].cnt) { |
| 387 | ibdev_dbg(to_ibdev(dev), | 380 | ibdev_dbg(to_ibdev(dev), |
| 388 | "HMC: error start_idx[%04d] >= [type %04d].cnt[%04d]\n", | 381 | "HMC: error start_idx[%04d] >= [type %04d].cnt[%04d]\n", |
| 389 | info->start_idx, info->rsrc_type, | 382 | info->start_idx, info->rsrc_type, |
| 390 | info->hmc_info->hmc_obj[info->rsrc_type].cnt); | 383 | info->hmc_info->hmc_obj[info->rsrc_type].cnt); |
| 391 | return IRDMA_ERR_INVALID_HMC_OBJ_INDEX; | 384 | return -EINVAL; |
| 392 | } | 385 | } |
| 393 | 386 | ||
| 394 | if ((info->start_idx + info->count) > | 387 | if ((info->start_idx + info->count) > |
| @@ -397,7 +390,7 @@ enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, · 2 unmodified lines | |||
| 397 | "HMC: error start_idx[%04d] + count %04d >= [type %04d].cnt[%04d]\n", | 390 | "HMC: error start_idx[%04d] + count %04d >= [type %04d].cnt[%04d]\n", |
| 398 | info->start_idx, info->count, info->rsrc_type, | 391 | info->start_idx, info->count, info->rsrc_type, |
| 399 | info->hmc_info->hmc_obj[info->rsrc_type].cnt); | 392 | info->hmc_info->hmc_obj[info->rsrc_type].cnt); |
| 400 | return IRDMA_ERR_INVALID_HMC_OBJ_COUNT; | 393 | return -EINVAL; |
| 401 | } | 394 | } |
| 402 | 395 | ||
| 403 | irdma_find_pd_index_limit(info->hmc_info, info->rsrc_type, | 396 | irdma_find_pd_index_limit(info->hmc_info, info->rsrc_type, |
| @@ -433,7 +426,7 @@ enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, · 29 unmodified lines | |||
| 433 | if (sd_idx >= info->hmc_info->sd_table.sd_cnt || | 426 | if (sd_idx >= info->hmc_info->sd_table.sd_cnt || |
| 434 | sd_lmt > info->hmc_info->sd_table.sd_cnt) { | 427 | sd_lmt > info->hmc_info->sd_table.sd_cnt) { |
| 435 | ibdev_dbg(to_ibdev(dev), "HMC: invalid sd_idx\n"); | 428 | ibdev_dbg(to_ibdev(dev), "HMC: invalid sd_idx\n"); |
| 436 | return IRDMA_ERR_INVALID_SD_INDEX; | 429 | return -EINVAL; |
| 437 | } | 430 | } |
| 438 | 431 | ||
| 439 | for (i = sd_idx; i < sd_lmt; i++) { | 432 | for (i = sd_idx; i < sd_lmt; i++) { |
| @@ -477,11 +470,9 @@ enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, · 37 unmodified lines | |||
| 477 | * @type: what type of segment descriptor we're manipulating | 470 | * @type: what type of segment descriptor we're manipulating |
| 478 | * @direct_mode_sz: size to alloc in direct mode | 471 | * @direct_mode_sz: size to alloc in direct mode |
| 479 | */ | 472 | */ |
| 480 | enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, | 473 | int irdma_add_sd_table_entry(struct irdma_hw *hw, |
| 481 | struct irdma_hmc_info *hmc_info, | 474 | struct irdma_hmc_info *hmc_info, u32 sd_index, |
| 482 | u32 sd_index, | 475 | enum irdma_sd_entry_type type, u64 direct_mode_sz) |
| 483 | enum irdma_sd_entry_type type, | ||
| 484 | u64 direct_mode_sz) | ||
| 485 | { | 476 | { |
| 486 | struct irdma_hmc_sd_entry *sd_entry; | 477 | struct irdma_hmc_sd_entry *sd_entry; |
| 487 | struct irdma_dma_mem dma_mem; | 478 | struct irdma_dma_mem dma_mem; |
| @@ -499,7 +490,7 @@ enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, · 11 unmodified lines | |||
| 499 | dma_mem.va = dma_alloc_coherent(hw->device, dma_mem.size, | 490 | dma_mem.va = dma_alloc_coherent(hw->device, dma_mem.size, |
| 500 | &dma_mem.pa, GFP_KERNEL); | 491 | &dma_mem.pa, GFP_KERNEL); |
| 501 | if (!dma_mem.va) | 492 | if (!dma_mem.va) |
| 502 | return IRDMA_ERR_NO_MEMORY; | 493 | return -ENOMEM; |
| 503 | if (type == IRDMA_SD_TYPE_PAGED) { | 494 | if (type == IRDMA_SD_TYPE_PAGED) { |
| 504 | struct irdma_virt_mem *vmem = | 495 | struct irdma_virt_mem *vmem = |
| 505 | &sd_entry->u.pd_table.pd_entry_virt_mem; | 496 | &sd_entry->u.pd_table.pd_entry_virt_mem; |
| @@ -510,7 +501,7 @@ enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, · 4 unmodified lines | |||
| 510 | dma_free_coherent(hw->device, dma_mem.size, | 501 | dma_free_coherent(hw->device, dma_mem.size, |
| 511 | dma_mem.va, dma_mem.pa); | 502 | dma_mem.va, dma_mem.pa); |
| 512 | dma_mem.va = NULL; | 503 | dma_mem.va = NULL; |
| 513 | return IRDMA_ERR_NO_MEMORY; | 504 | return -ENOMEM; |
| 514 | } | 505 | } |
| 515 | sd_entry->u.pd_table.pd_entry = vmem->va; | 506 | sd_entry->u.pd_table.pd_entry = vmem->va; |
| 516 | 507 | ||
| @@ -549,10 +540,9 @@ enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, · 32 unmodified lines | |||
| 549 | * aligned on 4K boundary and zeroed memory. | 540 | * aligned on 4K boundary and zeroed memory. |
| 550 | * 2. It should be 4K in size. | 541 | * 2. It should be 4K in size. |
| 551 | */ | 542 | */ |
| 552 | enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, | 543 | int irdma_add_pd_table_entry(struct irdma_sc_dev *dev, |
| 553 | struct irdma_hmc_info *hmc_info, | 544 | struct irdma_hmc_info *hmc_info, u32 pd_index, |
| 554 | u32 pd_index, | 545 | struct irdma_dma_mem *rsrc_pg) |
| 555 | struct irdma_dma_mem *rsrc_pg) | ||
| 556 | { | 546 | { |
| 557 | struct irdma_hmc_pd_table *pd_table; | 547 | struct irdma_hmc_pd_table *pd_table; |
| 558 | struct irdma_hmc_pd_entry *pd_entry; | 548 | struct irdma_hmc_pd_entry *pd_entry; |
| @@ -563,7 +553,7 @@ enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, · 4 unmodified lines | |||
| 563 | u64 page_desc; | 553 | u64 page_desc; |
| 564 | 554 | ||
| 565 | if (pd_index / IRDMA_HMC_PD_CNT_IN_SD >= hmc_info->sd_table.sd_cnt) | 555 | if (pd_index / IRDMA_HMC_PD_CNT_IN_SD >= hmc_info->sd_table.sd_cnt) |
| 566 | return IRDMA_ERR_INVALID_PAGE_DESC_INDEX; | 556 | return -EINVAL; |
| 567 | 557 | ||
| 568 | sd_idx = (pd_index / IRDMA_HMC_PD_CNT_IN_SD); | 558 | sd_idx = (pd_index / IRDMA_HMC_PD_CNT_IN_SD); |
| 569 | if (hmc_info->sd_table.sd_entry[sd_idx].entry_type != | 559 | if (hmc_info->sd_table.sd_entry[sd_idx].entry_type != |
| @@ -584,7 +574,7 @@ enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, · 14 unmodified lines | |||
| 584 | page->size, &page->pa, | 574 | page->size, &page->pa, |
| 585 | GFP_KERNEL); | 575 | GFP_KERNEL); |
| 586 | if (!page->va) | 576 | if (!page->va) |
| 587 | return IRDMA_ERR_NO_MEMORY; | 577 | return -ENOMEM; |
| 588 | 578 | ||
| 589 | pd_entry->rsrc_pg = false; | 579 | pd_entry->rsrc_pg = false; |
| 590 | } | 580 | } |
| @@ -621,9 +611,8 @@ enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, · 30 unmodified lines | |||
| 621 | * 1. Caller can deallocate the memory used by backing storage after this | 611 | * 1. Caller can deallocate the memory used by backing storage after this |
| 622 | * function returns. | 612 | * function returns. |
| 623 | */ | 613 | */ |
| 624 | enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, | 614 | int irdma_remove_pd_bp(struct irdma_sc_dev *dev, |
| 625 | struct irdma_hmc_info *hmc_info, | 615 | struct irdma_hmc_info *hmc_info, u32 idx) |
| 626 | u32 idx) | ||
| 627 | { | 616 | { |
| 628 | struct irdma_hmc_pd_entry *pd_entry; | 617 | struct irdma_hmc_pd_entry *pd_entry; |
| 629 | struct irdma_hmc_pd_table *pd_table; | 618 | struct irdma_hmc_pd_table *pd_table; |
| @@ -635,11 +624,11 @@ enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, · 5 unmodified lines | |||
| 635 | sd_idx = idx / IRDMA_HMC_PD_CNT_IN_SD; | 624 | sd_idx = idx / IRDMA_HMC_PD_CNT_IN_SD; |
| 636 | rel_pd_idx = idx % IRDMA_HMC_PD_CNT_IN_SD; | 625 | rel_pd_idx = idx % IRDMA_HMC_PD_CNT_IN_SD; |
| 637 | if (sd_idx >= hmc_info->sd_table.sd_cnt) | 626 | if (sd_idx >= hmc_info->sd_table.sd_cnt) |
| 638 | return IRDMA_ERR_INVALID_PAGE_DESC_INDEX; | 627 | return -EINVAL; |
| 639 | 628 | ||
| 640 | sd_entry = &hmc_info->sd_table.sd_entry[sd_idx]; | 629 | sd_entry = &hmc_info->sd_table.sd_entry[sd_idx]; |
| 641 | if (sd_entry->entry_type != IRDMA_SD_TYPE_PAGED) | 630 | if (sd_entry->entry_type != IRDMA_SD_TYPE_PAGED) |
| 642 | return IRDMA_ERR_INVALID_SD_TYPE; | 631 | return -EINVAL; |
| 643 | 632 | ||
| 644 | pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table; | 633 | pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table; |
| 645 | pd_entry = &pd_table->pd_entry[rel_pd_idx]; | 634 | pd_entry = &pd_table->pd_entry[rel_pd_idx]; |
| @@ -656,7 +645,7 @@ enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, · 10 unmodified lines | |||
| 656 | if (!pd_entry->rsrc_pg) { | 645 | if (!pd_entry->rsrc_pg) { |
| 657 | mem = &pd_entry->bp.addr; | 646 | mem = &pd_entry->bp.addr; |
| 658 | if (!mem || !mem->va) | 647 | if (!mem || !mem->va) |
| 659 | return IRDMA_ERR_PARAM; | 648 | return -EINVAL; |
| 660 | 649 | ||
| 661 | dma_free_coherent(dev->hw->device, mem->size, mem->va, | 650 | dma_free_coherent(dev->hw->device, mem->size, mem->va, |
| 662 | mem->pa); | 651 | mem->pa); |
| @@ -673,14 +662,13 @@ enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, · 10 unmodified lines | |||
| 673 | * @hmc_info: pointer to the HMC configuration information structure | 662 | * @hmc_info: pointer to the HMC configuration information structure |
| 674 | * @idx: the page index | 663 | * @idx: the page index |
| 675 | */ | 664 | */ |
| 676 | enum irdma_status_code irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, | 665 | int irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, u32 idx) |
| 677 | u32 idx) | ||
| 678 | { | 666 | { |
| 679 | struct irdma_hmc_sd_entry *sd_entry; | 667 | struct irdma_hmc_sd_entry *sd_entry; |
| 680 | 668 | ||
| 681 | sd_entry = &hmc_info->sd_table.sd_entry[idx]; | 669 | sd_entry = &hmc_info->sd_table.sd_entry[idx]; |
| 682 | if (--sd_entry->u.bp.use_cnt) | 670 | if (--sd_entry->u.bp.use_cnt) |
| 683 | return IRDMA_ERR_NOT_READY; | 671 | return -EBUSY; |
| 684 | 672 | ||
| 685 | hmc_info->sd_table.use_cnt--; | 673 | hmc_info->sd_table.use_cnt--; |
| 686 | sd_entry->valid = false; | 674 | sd_entry->valid = false; |
| @@ -693,15 +681,14 @@ enum irdma_status_code irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, · 6 unmodified lines | |||
| 693 | * @hmc_info: pointer to the HMC configuration information structure | 681 | * @hmc_info: pointer to the HMC configuration information structure |
| 694 | * @idx: segment descriptor index to find the relevant page descriptor | 682 | * @idx: segment descriptor index to find the relevant page descriptor |
| 695 | */ | 683 | */ |
| 696 | enum irdma_status_code | 684 | int irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx) |
| 697 | irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx) | ||
| 698 | { | 685 | { |
| 699 | struct irdma_hmc_sd_entry *sd_entry; | 686 | struct irdma_hmc_sd_entry *sd_entry; |
| 700 | 687 | ||
| 701 | sd_entry = &hmc_info->sd_table.sd_entry[idx]; | 688 | sd_entry = &hmc_info->sd_table.sd_entry[idx]; |
| 702 | 689 | ||
| 703 | if (sd_entry->u.pd_table.use_cnt) | 690 | if (sd_entry->u.pd_table.use_cnt) |
| 704 | return IRDMA_ERR_NOT_READY; | 691 | return -EBUSY; |
| 705 | 692 | ||
| 706 | sd_entry->valid = false; | 693 | sd_entry->valid = false; |
| 707 | hmc_info->sd_table.use_cnt--; | 694 | hmc_info->sd_table.use_cnt--; |
| @@ -141,40 +141,29 @@ struct irdma_hmc_del_obj_info { · 140 unmodified lines | |||
| 141 | bool privileged; | 141 | bool privileged; |
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | enum irdma_status_code irdma_copy_dma_mem(struct irdma_hw *hw, void *dest_buf, | 144 | int irdma_copy_dma_mem(struct irdma_hw *hw, void *dest_buf, |
| 145 | struct irdma_dma_mem *src_mem, | 145 | struct irdma_dma_mem *src_mem, u64 src_offset, u64 size); |
| 146 | u64 src_offset, u64 size); | 146 | int irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, |
| 147 | enum irdma_status_code | 147 | struct irdma_hmc_create_obj_info *info); |
| 148 | irdma_sc_create_hmc_obj(struct irdma_sc_dev *dev, | 148 | int irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, |
| 149 | struct irdma_hmc_create_obj_info *info); | 149 | struct irdma_hmc_del_obj_info *info, bool reset); |
| 150 | enum irdma_status_code irdma_sc_del_hmc_obj(struct irdma_sc_dev *dev, | 150 | int irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, u64 pa, u32 sd_idx, |
| 151 | struct irdma_hmc_del_obj_info *info, | 151 | enum irdma_sd_entry_type type, |
| 152 | bool reset); | 152 | bool setsd); |
| 153 | enum irdma_status_code irdma_hmc_sd_one(struct irdma_sc_dev *dev, u8 hmc_fn_id, | 153 | int irdma_update_sds_noccq(struct irdma_sc_dev *dev, |
| 154 | u64 pa, u32 sd_idx, | 154 | struct irdma_update_sds_info *info); |
| 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); | ||
| 160 | struct irdma_vfdev *irdma_vfdev_from_fpm(struct irdma_sc_dev *dev, | 155 | struct irdma_vfdev *irdma_vfdev_from_fpm(struct irdma_sc_dev *dev, |
| 161 | u8 hmc_fn_id); | 156 | u8 hmc_fn_id); |
| 162 | struct irdma_hmc_info *irdma_vf_hmcinfo_from_fpm(struct irdma_sc_dev *dev, | 157 | struct irdma_hmc_info *irdma_vf_hmcinfo_from_fpm(struct irdma_sc_dev *dev, |
| 163 | u8 hmc_fn_id); | 158 | u8 hmc_fn_id); |
| 164 | enum irdma_status_code irdma_add_sd_table_entry(struct irdma_hw *hw, | 159 | int irdma_add_sd_table_entry(struct irdma_hw *hw, |
| 165 | struct irdma_hmc_info *hmc_info, | 160 | struct irdma_hmc_info *hmc_info, u32 sd_index, |
| 166 | u32 sd_index, | 161 | enum irdma_sd_entry_type type, u64 direct_mode_sz); |
| 167 | enum irdma_sd_entry_type type, | 162 | int irdma_add_pd_table_entry(struct irdma_sc_dev *dev, |
| 168 | u64 direct_mode_sz); | 163 | struct irdma_hmc_info *hmc_info, u32 pd_index, |
| 169 | enum irdma_status_code irdma_add_pd_table_entry(struct irdma_sc_dev *dev, | 164 | struct irdma_dma_mem *rsrc_pg); |
| 170 | struct irdma_hmc_info *hmc_info, | 165 | int irdma_remove_pd_bp(struct irdma_sc_dev *dev, |
| 171 | u32 pd_index, | 166 | struct irdma_hmc_info *hmc_info, u32 idx); |
| 172 | struct irdma_dma_mem *rsrc_pg); | 167 | int irdma_prep_remove_sd_bp(struct irdma_hmc_info *hmc_info, u32 idx); |
| 173 | enum irdma_status_code irdma_remove_pd_bp(struct irdma_sc_dev *dev, | 168 | int irdma_prep_remove_pd_page(struct irdma_hmc_info *hmc_info, u32 idx); |
| 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); | ||
| 180 | #endif /* IRDMA_HMC_H */ | 169 | #endif /* IRDMA_HMC_H */ |
| @@ -75,12 +75,12 @@ static void irdma_puda_ce_handler(struct irdma_pci_f *rf, · 74 unmodified lines | |||
| 75 | struct irdma_sc_cq *cq) | 75 | struct irdma_sc_cq *cq) |
| 76 | { | 76 | { |
| 77 | struct irdma_sc_dev *dev = &rf->sc_dev; | 77 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 78 | enum irdma_status_code status; | ||
| 79 | u32 compl_error; | 78 | u32 compl_error; |
| 79 | int status; | ||
| 80 | 80 | ||
| 81 | do { | 81 | do { |
| 82 | status = irdma_puda_poll_cmpl(dev, cq, &compl_error); | 82 | status = irdma_puda_poll_cmpl(dev, cq, &compl_error); |
| 83 | if (status == IRDMA_ERR_Q_EMPTY) | 83 | if (status == -ENOENT) |
| 84 | break; | 84 | break; |
| 85 | if (status) { | 85 | if (status) { |
| 86 | ibdev_dbg(to_ibdev(dev), "ERR: puda status = %d\n", status); | 86 | ibdev_dbg(to_ibdev(dev), "ERR: puda status = %d\n", status); |
| @@ -456,7 +456,7 @@ static void irdma_ceq_dpc(struct tasklet_struct *t) · 369 unmodified lines | |||
| 456 | * Allocate iwdev msix table and copy the msix info to the table | 456 | * Allocate iwdev msix table and copy the msix info to the table |
| 457 | * Return 0 if successful, otherwise return error | 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 | struct irdma_qvlist_info *iw_qvlist; | 461 | struct irdma_qvlist_info *iw_qvlist; |
| 462 | struct irdma_qv_info *iw_qvinfo; | 462 | struct irdma_qv_info *iw_qvinfo; |
| @@ -466,13 +466,13 @@ static enum irdma_status_code irdma_save_msix_info(struct irdma_pci_f *rf) · 3 unmodified lines | |||
| 466 | size_t size; | 466 | size_t size; |
| 467 | 467 | ||
| 468 | if (!rf->msix_count) | 468 | if (!rf->msix_count) |
| 469 | return IRDMA_ERR_NO_INTR; | 469 | return -EINVAL; |
| 470 | 470 | ||
| 471 | size = sizeof(struct irdma_msix_vector) * rf->msix_count; | 471 | size = sizeof(struct irdma_msix_vector) * rf->msix_count; |
| 472 | size += struct_size(iw_qvlist, qv_info, rf->msix_count); | 472 | size += struct_size(iw_qvlist, qv_info, rf->msix_count); |
| 473 | rf->iw_msixtbl = kzalloc(size, GFP_KERNEL); | 473 | rf->iw_msixtbl = kzalloc(size, GFP_KERNEL); |
| 474 | if (!rf->iw_msixtbl) | 474 | if (!rf->iw_msixtbl) |
| 475 | return IRDMA_ERR_NO_MEMORY; | 475 | return -ENOMEM; |
| 476 | 476 | ||
| 477 | rf->iw_qvlist = (struct irdma_qvlist_info *) | 477 | rf->iw_qvlist = (struct irdma_qvlist_info *) |
| 478 | (&rf->iw_msixtbl[rf->msix_count]); | 478 | (&rf->iw_msixtbl[rf->msix_count]); |
| @@ -564,9 +564,9 @@ static void irdma_destroy_irq(struct irdma_pci_f *rf, · 85 unmodified lines | |||
| 564 | */ | 564 | */ |
| 565 | static void irdma_destroy_cqp(struct irdma_pci_f *rf, bool free_hwcqp) | 565 | static void irdma_destroy_cqp(struct irdma_pci_f *rf, bool free_hwcqp) |
| 566 | { | 566 | { |
| 567 | enum irdma_status_code status = 0; | ||
| 568 | struct irdma_sc_dev *dev = &rf->sc_dev; | 567 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 569 | struct irdma_cqp *cqp = &rf->cqp; | 568 | struct irdma_cqp *cqp = &rf->cqp; |
| 569 | int status = 0; | ||
| 570 | 570 | ||
| 571 | if (rf->cqp_cmpl_wq) | 571 | if (rf->cqp_cmpl_wq) |
| 572 | destroy_workqueue(rf->cqp_cmpl_wq); | 572 | destroy_workqueue(rf->cqp_cmpl_wq); |
| @@ -606,9 +606,9 @@ static void irdma_destroy_virt_aeq(struct irdma_pci_f *rf) · 33 unmodified lines | |||
| 606 | */ | 606 | */ |
| 607 | static void irdma_destroy_aeq(struct irdma_pci_f *rf) | 607 | static void irdma_destroy_aeq(struct irdma_pci_f *rf) |
| 608 | { | 608 | { |
| 609 | enum irdma_status_code status = IRDMA_ERR_NOT_READY; | ||
| 610 | struct irdma_sc_dev *dev = &rf->sc_dev; | 609 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 611 | struct irdma_aeq *aeq = &rf->aeq; | 610 | struct irdma_aeq *aeq = &rf->aeq; |
| 611 | int status = -EBUSY; | ||
| 612 | 612 | ||
| 613 | if (!rf->msix_shared) { | 613 | if (!rf->msix_shared) { |
| 614 | rf->sc_dev.irq_ops->irdma_cfg_aeq(&rf->sc_dev, rf->iw_msixtbl->idx, false); | 614 | rf->sc_dev.irq_ops->irdma_cfg_aeq(&rf->sc_dev, rf->iw_msixtbl->idx, false); |
| @@ -642,8 +642,8 @@ exit: · 27 unmodified lines | |||
| 642 | */ | 642 | */ |
| 643 | static void irdma_destroy_ceq(struct irdma_pci_f *rf, struct irdma_ceq *iwceq) | 643 | static void irdma_destroy_ceq(struct irdma_pci_f *rf, struct irdma_ceq *iwceq) |
| 644 | { | 644 | { |
| 645 | enum irdma_status_code status; | ||
| 646 | struct irdma_sc_dev *dev = &rf->sc_dev; | 645 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 646 | int status; | ||
| 647 | 647 | ||
| 648 | if (rf->reset) | 648 | if (rf->reset) |
| 649 | goto exit; | 649 | goto exit; |
| @@ -733,7 +733,7 @@ static void irdma_destroy_ccq(struct irdma_pci_f *rf) · 83 unmodified lines | |||
| 733 | { | 733 | { |
| 734 | struct irdma_sc_dev *dev = &rf->sc_dev; | 734 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 735 | struct irdma_ccq *ccq = &rf->ccq; | 735 | struct irdma_ccq *ccq = &rf->ccq; |
| 736 | enum irdma_status_code status = 0; | 736 | int status = 0; |
| 737 | 737 | ||
| 738 | if (!rf->reset) | 738 | if (!rf->reset) |
| 739 | status = irdma_sc_ccq_destroy(dev->ccq, 0, true); | 739 | status = irdma_sc_ccq_destroy(dev->ccq, 0, true); |
| @@ -796,9 +796,8 @@ static void irdma_del_hmc_objects(struct irdma_sc_dev *dev, · 56 unmodified lines | |||
| 796 | * @dev: hardware control device structure | 796 | * @dev: hardware control device structure |
| 797 | * @info: information for the hmc object to create | 797 | * @info: information for the hmc object to create |
| 798 | */ | 798 | */ |
| 799 | static enum irdma_status_code | 799 | static int irdma_create_hmc_obj_type(struct irdma_sc_dev *dev, |
| 800 | irdma_create_hmc_obj_type(struct irdma_sc_dev *dev, | 800 | struct irdma_hmc_create_obj_info *info) |
| 801 | struct irdma_hmc_create_obj_info *info) | ||
| 802 | { | 801 | { |
| 803 | return irdma_sc_create_hmc_obj(dev, info); | 802 | return irdma_sc_create_hmc_obj(dev, info); |
| 804 | } | 803 | } |
| @@ -812,13 +811,12 @@ irdma_create_hmc_obj_type(struct irdma_sc_dev *dev, · 7 unmodified lines | |||
| 812 | * Create the device hmc objects and allocate hmc pages | 811 | * Create the device hmc objects and allocate hmc pages |
| 813 | * Return 0 if successful, otherwise clean up and return error | 812 | * Return 0 if successful, otherwise clean up and return error |
| 814 | */ | 813 | */ |
| 815 | static enum irdma_status_code | 814 | static int irdma_create_hmc_objs(struct irdma_pci_f *rf, bool privileged, |
| 816 | irdma_create_hmc_objs(struct irdma_pci_f *rf, bool privileged, enum irdma_vers vers) | 815 | enum irdma_vers vers) |
| 817 | { | 816 | { |
| 818 | struct irdma_sc_dev *dev = &rf->sc_dev; | 817 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 819 | struct irdma_hmc_create_obj_info info = {}; | 818 | struct irdma_hmc_create_obj_info info = {}; |
| 820 | enum irdma_status_code status = 0; | 819 | int i, status = 0; |
| 821 | int i; | ||
| 822 | 820 | ||
| 823 | info.hmc_info = dev->hmc_info; | 821 | info.hmc_info = dev->hmc_info; |
| 824 | info.privileged = privileged; | 822 | info.privileged = privileged; |
| @@ -868,9 +866,9 @@ irdma_create_hmc_objs(struct irdma_pci_f *rf, bool privileged, enum irdma_vers v · 43 unmodified lines | |||
| 868 | * update the memptr to point to the new aligned memory | 866 | * update the memptr to point to the new aligned memory |
| 869 | * Return 0 if successful, otherwise return no memory error | 867 | * Return 0 if successful, otherwise return no memory error |
| 870 | */ | 868 | */ |
| 871 | static enum irdma_status_code | 869 | static int irdma_obj_aligned_mem(struct irdma_pci_f *rf, |
| 872 | irdma_obj_aligned_mem(struct irdma_pci_f *rf, struct irdma_dma_mem *memptr, | 870 | struct irdma_dma_mem *memptr, u32 size, |
| 873 | u32 size, u32 mask) | 871 | u32 mask) |
| 874 | { | 872 | { |
| 875 | unsigned long va, newva; | 873 | unsigned long va, newva; |
| 876 | unsigned long extra; | 874 | unsigned long extra; |
| @@ -884,7 +882,7 @@ irdma_obj_aligned_mem(struct irdma_pci_f *rf, struct irdma_dma_mem *memptr, · 7 unmodified lines | |||
| 884 | memptr->pa = rf->obj_next.pa + extra; | 882 | memptr->pa = rf->obj_next.pa + extra; |
| 885 | memptr->size = size; | 883 | memptr->size = size; |
| 886 | if (((u8 *)memptr->va + size) > ((u8 *)rf->obj_mem.va + rf->obj_mem.size)) | 884 | if (((u8 *)memptr->va + size) > ((u8 *)rf->obj_mem.va + rf->obj_mem.size)) |
| 887 | return IRDMA_ERR_NO_MEMORY; | 885 | return -ENOMEM; |
| 888 | 886 | ||
| 889 | rf->obj_next.va = (u8 *)memptr->va + size; | 887 | rf->obj_next.va = (u8 *)memptr->va + size; |
| 890 | rf->obj_next.pa = memptr->pa + size; | 888 | rf->obj_next.pa = memptr->pa + size; |
| @@ -899,25 +897,24 @@ irdma_obj_aligned_mem(struct irdma_pci_f *rf, struct irdma_dma_mem *memptr, · 8 unmodified lines | |||
| 899 | * Return 0, if the cqp and all the resources associated with it | 897 | * Return 0, if the cqp and all the resources associated with it |
| 900 | * are successfully created, otherwise return error | 898 | * are successfully created, otherwise return error |
| 901 | */ | 899 | */ |
| 902 | static enum irdma_status_code irdma_create_cqp(struct irdma_pci_f *rf) | 900 | static int irdma_create_cqp(struct irdma_pci_f *rf) |
| 903 | { | 901 | { |
| 904 | enum irdma_status_code status; | ||
| 905 | u32 sqsize = IRDMA_CQP_SW_SQSIZE_2048; | 902 | u32 sqsize = IRDMA_CQP_SW_SQSIZE_2048; |
| 906 | struct irdma_dma_mem mem; | 903 | struct irdma_dma_mem mem; |
| 907 | struct irdma_sc_dev *dev = &rf->sc_dev; | 904 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 908 | struct irdma_cqp_init_info cqp_init_info = {}; | 905 | struct irdma_cqp_init_info cqp_init_info = {}; |
| 909 | struct irdma_cqp *cqp = &rf->cqp; | 906 | struct irdma_cqp *cqp = &rf->cqp; |
| 910 | u16 maj_err, min_err; | 907 | u16 maj_err, min_err; |
| 911 | int i; | 908 | int i, status; |
| 912 | 909 | ||
| 913 | cqp->cqp_requests = kcalloc(sqsize, sizeof(*cqp->cqp_requests), GFP_KERNEL); | 910 | cqp->cqp_requests = kcalloc(sqsize, sizeof(*cqp->cqp_requests), GFP_KERNEL); |
| 914 | if (!cqp->cqp_requests) | 911 | if (!cqp->cqp_requests) |
| 915 | return IRDMA_ERR_NO_MEMORY; | 912 | return -ENOMEM; |
| 916 | 913 | ||
| 917 | cqp->scratch_array = kcalloc(sqsize, sizeof(*cqp->scratch_array), GFP_KERNEL); | 914 | cqp->scratch_array = kcalloc(sqsize, sizeof(*cqp->scratch_array), GFP_KERNEL); |
| 918 | if (!cqp->scratch_array) { | 915 | if (!cqp->scratch_array) { |
| 919 | kfree(cqp->cqp_requests); | 916 | kfree(cqp->cqp_requests); |
| 920 | return IRDMA_ERR_NO_MEMORY; | 917 | return -ENOMEM; |
| 921 | } | 918 | } |
| 922 | 919 | ||
| 923 | dev->cqp = &cqp->sc_cqp; | 920 | dev->cqp = &cqp->sc_cqp; |
| @@ -929,7 +926,7 @@ static enum irdma_status_code irdma_create_cqp(struct irdma_pci_f *rf) · 5 unmodified lines | |||
| 929 | if (!cqp->sq.va) { | 926 | if (!cqp->sq.va) { |
| 930 | kfree(cqp->scratch_array); | 927 | kfree(cqp->scratch_array); |
| 931 | kfree(cqp->cqp_requests); | 928 | kfree(cqp->cqp_requests); |
| 932 | return IRDMA_ERR_NO_MEMORY; | 929 | return -ENOMEM; |
| 933 | } | 930 | } |
| 934 | 931 | ||
| 935 | status = irdma_obj_aligned_mem(rf, &mem, sizeof(struct irdma_cqp_ctx), | 932 | status = irdma_obj_aligned_mem(rf, &mem, sizeof(struct irdma_cqp_ctx), |
| @@ -999,12 +996,12 @@ exit: · 63 unmodified lines | |||
| 999 | * Return 0, if the ccq and the resources associated with it | 996 | * Return 0, if the ccq and the resources associated with it |
| 1000 | * are successfully created, otherwise return error | 997 | * are successfully created, otherwise return error |
| 1001 | */ | 998 | */ |
| 1002 | static enum irdma_status_code irdma_create_ccq(struct irdma_pci_f *rf) | 999 | static int irdma_create_ccq(struct irdma_pci_f *rf) |
| 1003 | { | 1000 | { |
| 1004 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1001 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1005 | enum irdma_status_code status; | ||
| 1006 | struct irdma_ccq_init_info info = {}; | 1002 | struct irdma_ccq_init_info info = {}; |
| 1007 | struct irdma_ccq *ccq = &rf->ccq; | 1003 | struct irdma_ccq *ccq = &rf->ccq; |
| 1004 | int status; | ||
| 1008 | 1005 | ||
| 1009 | dev->ccq = &ccq->sc_cq; | 1006 | dev->ccq = &ccq->sc_cq; |
| 1010 | dev->ccq->dev = dev; | 1007 | dev->ccq->dev = dev; |
| @@ -1015,7 +1012,7 @@ static enum irdma_status_code irdma_create_ccq(struct irdma_pci_f *rf) · 4 unmodified lines | |||
| 1015 | ccq->mem_cq.va = dma_alloc_coherent(dev->hw->device, ccq->mem_cq.size, | 1012 | ccq->mem_cq.va = dma_alloc_coherent(dev->hw->device, ccq->mem_cq.size, |
| 1016 | &ccq->mem_cq.pa, GFP_KERNEL); | 1013 | &ccq->mem_cq.pa, GFP_KERNEL); |
| 1017 | if (!ccq->mem_cq.va) | 1014 | if (!ccq->mem_cq.va) |
| 1018 | return IRDMA_ERR_NO_MEMORY; | 1015 | return -ENOMEM; |
| 1019 | 1016 | ||
| 1020 | status = irdma_obj_aligned_mem(rf, &ccq->shadow_area, | 1017 | status = irdma_obj_aligned_mem(rf, &ccq->shadow_area, |
| 1021 | ccq->shadow_area.size, | 1018 | ccq->shadow_area.size, |
| @@ -1054,9 +1051,9 @@ exit: · 32 unmodified lines | |||
| 1054 | * Allocate a mac ip entry and add it to the hw table Return 0 | 1051 | * Allocate a mac ip entry and add it to the hw table Return 0 |
| 1055 | * if successful, otherwise return error | 1052 | * if successful, otherwise return error |
| 1056 | */ | 1053 | */ |
| 1057 | static enum irdma_status_code irdma_alloc_set_mac(struct irdma_device *iwdev) | 1054 | static int irdma_alloc_set_mac(struct irdma_device *iwdev) |
| 1058 | { | 1055 | { |
| 1059 | enum irdma_status_code status; | 1056 | int status; |
| 1060 | 1057 | ||
| 1061 | status = irdma_alloc_local_mac_entry(iwdev->rf, | 1058 | status = irdma_alloc_local_mac_entry(iwdev->rf, |
| 1062 | &iwdev->mac_ip_table_idx); | 1059 | &iwdev->mac_ip_table_idx); |
| @@ -1082,9 +1079,8 @@ static enum irdma_status_code irdma_alloc_set_mac(struct irdma_device *iwdev) · 19 unmodified lines | |||
| 1082 | * Allocate interrupt resources and enable irq handling | 1079 | * Allocate interrupt resources and enable irq handling |
| 1083 | * Return 0 if successful, otherwise return error | 1080 | * Return 0 if successful, otherwise return error |
| 1084 | */ | 1081 | */ |
| 1085 | static enum irdma_status_code | 1082 | static int irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, |
| 1086 | irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, | 1083 | u32 ceq_id, struct irdma_msix_vector *msix_vec) |
| 1087 | u32 ceq_id, struct irdma_msix_vector *msix_vec) | ||
| 1088 | { | 1084 | { |
| 1089 | int status; | 1085 | int status; |
| 1090 | 1086 | ||
| @@ -1103,7 +1099,7 @@ irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, · 12 unmodified lines | |||
| 1103 | irq_update_affinity_hint(msix_vec->irq, &msix_vec->mask); | 1099 | irq_update_affinity_hint(msix_vec->irq, &msix_vec->mask); |
| 1104 | if (status) { | 1100 | if (status) { |
| 1105 | ibdev_dbg(&rf->iwdev->ibdev, "ERR: ceq irq config fail\n"); | 1101 | ibdev_dbg(&rf->iwdev->ibdev, "ERR: ceq irq config fail\n"); |
| 1106 | return IRDMA_ERR_CFG; | 1102 | return status; |
| 1107 | } | 1103 | } |
| 1108 | 1104 | ||
| 1109 | msix_vec->ceq_id = ceq_id; | 1105 | msix_vec->ceq_id = ceq_id; |
| @@ -1119,7 +1115,7 @@ irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, · 9 unmodified lines | |||
| 1119 | * Allocate interrupt resources and enable irq handling | 1115 | * Allocate interrupt resources and enable irq handling |
| 1120 | * Return 0 if successful, otherwise return error | 1116 | * Return 0 if successful, otherwise return error |
| 1121 | */ | 1117 | */ |
| 1122 | static enum irdma_status_code irdma_cfg_aeq_vector(struct irdma_pci_f *rf) | 1118 | static int irdma_cfg_aeq_vector(struct irdma_pci_f *rf) |
| 1123 | { | 1119 | { |
| 1124 | struct irdma_msix_vector *msix_vec = rf->iw_msixtbl; | 1120 | struct irdma_msix_vector *msix_vec = rf->iw_msixtbl; |
| 1125 | u32 ret = 0; | 1121 | u32 ret = 0; |
| @@ -1131,7 +1127,7 @@ static enum irdma_status_code irdma_cfg_aeq_vector(struct irdma_pci_f *rf) · 5 unmodified lines | |||
| 1131 | } | 1127 | } |
| 1132 | if (ret) { | 1128 | if (ret) { |
| 1133 | ibdev_dbg(&rf->iwdev->ibdev, "ERR: aeq irq config fail\n"); | 1129 | ibdev_dbg(&rf->iwdev->ibdev, "ERR: aeq irq config fail\n"); |
| 1134 | return IRDMA_ERR_CFG; | 1130 | return -EINVAL; |
| 1135 | } | 1131 | } |
| 1136 | 1132 | ||
| 1137 | rf->sc_dev.irq_ops->irdma_cfg_aeq(&rf->sc_dev, msix_vec->idx, true); | 1133 | rf->sc_dev.irq_ops->irdma_cfg_aeq(&rf->sc_dev, msix_vec->idx, true); |
| @@ -1149,12 +1145,10 @@ static enum irdma_status_code irdma_cfg_aeq_vector(struct irdma_pci_f *rf) · 11 unmodified lines | |||
| 1149 | * Return 0, if the ceq and the resources associated with it | 1145 | * Return 0, if the ceq and the resources associated with it |
| 1150 | * are successfully created, otherwise return error | 1146 | * are successfully created, otherwise return error |
| 1151 | */ | 1147 | */ |
| 1152 | static enum irdma_status_code irdma_create_ceq(struct irdma_pci_f *rf, | 1148 | static int irdma_create_ceq(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, |
| 1153 | struct irdma_ceq *iwceq, | 1149 | u32 ceq_id, struct irdma_sc_vsi *vsi) |
| 1154 | u32 ceq_id, | ||
| 1155 | struct irdma_sc_vsi *vsi) | ||
| 1156 | { | 1150 | { |
| 1157 | enum irdma_status_code status; | 1151 | int status; |
| 1158 | struct irdma_ceq_init_info info = {}; | 1152 | struct irdma_ceq_init_info info = {}; |
| 1159 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1153 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1160 | u64 scratch; | 1154 | u64 scratch; |
| @@ -1169,7 +1163,7 @@ static enum irdma_status_code irdma_create_ceq(struct irdma_pci_f *rf, · 8 unmodified lines | |||
| 1169 | iwceq->mem.va = dma_alloc_coherent(dev->hw->device, iwceq->mem.size, | 1163 | iwceq->mem.va = dma_alloc_coherent(dev->hw->device, iwceq->mem.size, |
| 1170 | &iwceq->mem.pa, GFP_KERNEL); | 1164 | &iwceq->mem.pa, GFP_KERNEL); |
| 1171 | if (!iwceq->mem.va) | 1165 | if (!iwceq->mem.va) |
| 1172 | return IRDMA_ERR_NO_MEMORY; | 1166 | return -ENOMEM; |
| 1173 | 1167 | ||
| 1174 | info.ceq_id = ceq_id; | 1168 | info.ceq_id = ceq_id; |
| 1175 | info.ceqe_base = iwceq->mem.va; | 1169 | info.ceqe_base = iwceq->mem.va; |
| @@ -1205,18 +1199,18 @@ static enum irdma_status_code irdma_create_ceq(struct irdma_pci_f *rf, · 29 unmodified lines | |||
| 1205 | * Create the ceq 0 and configure it's msix interrupt vector | 1199 | * Create the ceq 0 and configure it's msix interrupt vector |
| 1206 | * Return 0, if successfully set up, otherwise return error | 1200 | * Return 0, if successfully set up, otherwise return error |
| 1207 | */ | 1201 | */ |
| 1208 | static enum irdma_status_code irdma_setup_ceq_0(struct irdma_pci_f *rf) | 1202 | static int irdma_setup_ceq_0(struct irdma_pci_f *rf) |
| 1209 | { | 1203 | { |
| 1210 | struct irdma_ceq *iwceq; | 1204 | struct irdma_ceq *iwceq; |
| 1211 | struct irdma_msix_vector *msix_vec; | 1205 | struct irdma_msix_vector *msix_vec; |
| 1212 | u32 i; | 1206 | u32 i; |
| 1213 | enum irdma_status_code status = 0; | 1207 | int status = 0; |
| 1214 | u32 num_ceqs; | 1208 | u32 num_ceqs; |
| 1215 | 1209 | ||
| 1216 | num_ceqs = min(rf->msix_count, rf->sc_dev.hmc_fpm_misc.max_ceqs); | 1210 | num_ceqs = min(rf->msix_count, rf->sc_dev.hmc_fpm_misc.max_ceqs); |
| 1217 | rf->ceqlist = kcalloc(num_ceqs, sizeof(*rf->ceqlist), GFP_KERNEL); | 1211 | rf->ceqlist = kcalloc(num_ceqs, sizeof(*rf->ceqlist), GFP_KERNEL); |
| 1218 | if (!rf->ceqlist) { | 1212 | if (!rf->ceqlist) { |
| 1219 | status = IRDMA_ERR_NO_MEMORY; | 1213 | status = -ENOMEM; |
| 1220 | goto exit; | 1214 | goto exit; |
| 1221 | } | 1215 | } |
| 1222 | 1216 | ||
| @@ -1262,14 +1256,13 @@ exit: · 39 unmodified lines | |||
| 1262 | * Create the ceq's and configure their msix interrupt vectors | 1256 | * Create the ceq's and configure their msix interrupt vectors |
| 1263 | * Return 0, if ceqs are successfully set up, otherwise return error | 1257 | * Return 0, if ceqs are successfully set up, otherwise return error |
| 1264 | */ | 1258 | */ |
| 1265 | static enum irdma_status_code irdma_setup_ceqs(struct irdma_pci_f *rf, | 1259 | static int irdma_setup_ceqs(struct irdma_pci_f *rf, struct irdma_sc_vsi *vsi) |
| 1266 | struct irdma_sc_vsi *vsi) | ||
| 1267 | { | 1260 | { |
| 1268 | u32 i; | 1261 | u32 i; |
| 1269 | u32 ceq_id; | 1262 | u32 ceq_id; |
| 1270 | struct irdma_ceq *iwceq; | 1263 | struct irdma_ceq *iwceq; |
| 1271 | struct irdma_msix_vector *msix_vec; | 1264 | struct irdma_msix_vector *msix_vec; |
| 1272 | enum irdma_status_code status; | 1265 | int status; |
| 1273 | u32 num_ceqs; | 1266 | u32 num_ceqs; |
| 1274 | 1267 | ||
| 1275 | num_ceqs = min(rf->msix_count, rf->sc_dev.hmc_fpm_misc.max_ceqs); | 1268 | num_ceqs = min(rf->msix_count, rf->sc_dev.hmc_fpm_misc.max_ceqs); |
| @@ -1303,22 +1296,21 @@ del_ceqs: · 27 unmodified lines | |||
| 1303 | return status; | 1296 | return status; |
| 1304 | } | 1297 | } |
| 1305 | 1298 | ||
| 1306 | static enum irdma_status_code irdma_create_virt_aeq(struct irdma_pci_f *rf, | 1299 | static int irdma_create_virt_aeq(struct irdma_pci_f *rf, u32 size) |
| 1307 | u32 size) | ||
| 1308 | { | 1300 | { |
| 1309 | enum irdma_status_code status = IRDMA_ERR_NO_MEMORY; | ||
| 1310 | struct irdma_aeq *aeq = &rf->aeq; | 1301 | struct irdma_aeq *aeq = &rf->aeq; |
| 1311 | dma_addr_t *pg_arr; | 1302 | dma_addr_t *pg_arr; |
| 1312 | u32 pg_cnt; | 1303 | u32 pg_cnt; |
| 1304 | int status; | ||
| 1313 | 1305 | ||
| 1314 | if (rf->rdma_ver < IRDMA_GEN_2) | 1306 | if (rf->rdma_ver < IRDMA_GEN_2) |
| 1315 | return IRDMA_NOT_SUPPORTED; | 1307 | return -EOPNOTSUPP; |
| 1316 | 1308 | ||
| 1317 | aeq->mem.size = sizeof(struct irdma_sc_aeqe) * size; | 1309 | aeq->mem.size = sizeof(struct irdma_sc_aeqe) * size; |
| 1318 | aeq->mem.va = vzalloc(aeq->mem.size); | 1310 | aeq->mem.va = vzalloc(aeq->mem.size); |
| 1319 | 1311 | ||
| 1320 | if (!aeq->mem.va) | 1312 | if (!aeq->mem.va) |
| 1321 | return status; | 1313 | return -ENOMEM; |
| 1322 | 1314 | ||
| 1323 | pg_cnt = DIV_ROUND_UP(aeq->mem.size, PAGE_SIZE); | 1315 | pg_cnt = DIV_ROUND_UP(aeq->mem.size, PAGE_SIZE); |
| 1324 | status = irdma_get_pble(rf->pble_rsrc, &aeq->palloc, pg_cnt, true); | 1316 | status = irdma_get_pble(rf->pble_rsrc, &aeq->palloc, pg_cnt, true); |
| @@ -1345,15 +1337,15 @@ static enum irdma_status_code irdma_create_virt_aeq(struct irdma_pci_f *rf, · 20 unmodified lines | |||
| 1345 | * Return 0, if the aeq and the resources associated with it | 1337 | * Return 0, if the aeq and the resources associated with it |
| 1346 | * are successfully created, otherwise return error | 1338 | * are successfully created, otherwise return error |
| 1347 | */ | 1339 | */ |
| 1348 | static enum irdma_status_code irdma_create_aeq(struct irdma_pci_f *rf) | 1340 | static int irdma_create_aeq(struct irdma_pci_f *rf) |
| 1349 | { | 1341 | { |
| 1350 | enum irdma_status_code status; | ||
| 1351 | struct irdma_aeq_init_info info = {}; | 1342 | struct irdma_aeq_init_info info = {}; |
| 1352 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1343 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1353 | struct irdma_aeq *aeq = &rf->aeq; | 1344 | struct irdma_aeq *aeq = &rf->aeq; |
| 1354 | struct irdma_hmc_info *hmc_info = rf->sc_dev.hmc_info; | 1345 | struct irdma_hmc_info *hmc_info = rf->sc_dev.hmc_info; |
| 1355 | u32 aeq_size; | 1346 | u32 aeq_size; |
| 1356 | u8 multiplier = (rf->protocol_used == IRDMA_IWARP_PROTOCOL_ONLY) ? 2 : 1; | 1347 | u8 multiplier = (rf->protocol_used == IRDMA_IWARP_PROTOCOL_ONLY) ? 2 : 1; |
| 1348 | int status; | ||
| 1357 | 1349 | ||
| 1358 | aeq_size = multiplier * hmc_info->hmc_obj[IRDMA_HMC_IW_QP].cnt + | 1350 | aeq_size = multiplier * hmc_info->hmc_obj[IRDMA_HMC_IW_QP].cnt + |
| 1359 | hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].cnt; | 1351 | hmc_info->hmc_obj[IRDMA_HMC_IW_CQ].cnt; |
| @@ -1412,10 +1404,10 @@ err: · 52 unmodified lines | |||
| 1412 | * Create the aeq and configure its msix interrupt vector | 1404 | * Create the aeq and configure its msix interrupt vector |
| 1413 | * Return 0 if successful, otherwise return error | 1405 | * Return 0 if successful, otherwise return error |
| 1414 | */ | 1406 | */ |
| 1415 | static enum irdma_status_code irdma_setup_aeq(struct irdma_pci_f *rf) | 1407 | static int irdma_setup_aeq(struct irdma_pci_f *rf) |
| 1416 | { | 1408 | { |
| 1417 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1409 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1418 | enum irdma_status_code status; | 1410 | int status; |
| 1419 | 1411 | ||
| 1420 | status = irdma_create_aeq(rf); | 1412 | status = irdma_create_aeq(rf); |
| 1421 | if (status) | 1413 | if (status) |
| @@ -1439,10 +1431,10 @@ static enum irdma_status_code irdma_setup_aeq(struct irdma_pci_f *rf) · 17 unmodified lines | |||
| 1439 | * | 1431 | * |
| 1440 | * Return 0 if successful, otherwise return error | 1432 | * Return 0 if successful, otherwise return error |
| 1441 | */ | 1433 | */ |
| 1442 | static enum irdma_status_code irdma_initialize_ilq(struct irdma_device *iwdev) | 1434 | static int irdma_initialize_ilq(struct irdma_device *iwdev) |
| 1443 | { | 1435 | { |
| 1444 | struct irdma_puda_rsrc_info info = {}; | 1436 | struct irdma_puda_rsrc_info info = {}; |
| 1445 | enum irdma_status_code status; | 1437 | int status; |
| 1446 | 1438 | ||
| 1447 | info.type = IRDMA_PUDA_RSRC_TYPE_ILQ; | 1439 | info.type = IRDMA_PUDA_RSRC_TYPE_ILQ; |
| 1448 | info.cq_id = 1; | 1440 | info.cq_id = 1; |
| @@ -1469,10 +1461,10 @@ static enum irdma_status_code irdma_initialize_ilq(struct irdma_device *iwdev) · 20 unmodified lines | |||
| 1469 | * | 1461 | * |
| 1470 | * Return 0 if successful, otherwise return error | 1462 | * Return 0 if successful, otherwise return error |
| 1471 | */ | 1463 | */ |
| 1472 | static enum irdma_status_code irdma_initialize_ieq(struct irdma_device *iwdev) | 1464 | static int irdma_initialize_ieq(struct irdma_device *iwdev) |
| 1473 | { | 1465 | { |
| 1474 | struct irdma_puda_rsrc_info info = {}; | 1466 | struct irdma_puda_rsrc_info info = {}; |
| 1475 | enum irdma_status_code status; | 1467 | int status; |
| 1476 | 1468 | ||
| 1477 | info.type = IRDMA_PUDA_RSRC_TYPE_IEQ; | 1469 | info.type = IRDMA_PUDA_RSRC_TYPE_IEQ; |
| 1478 | info.cq_id = 2; | 1470 | info.cq_id = 2; |
| @@ -1515,9 +1507,9 @@ void irdma_reinitialize_ieq(struct irdma_sc_vsi *vsi) · 36 unmodified lines | |||
| 1515 | * the hmc objects and create the objects | 1507 | * the hmc objects and create the objects |
| 1516 | * Return 0 if successful, otherwise return error | 1508 | * Return 0 if successful, otherwise return error |
| 1517 | */ | 1509 | */ |
| 1518 | static enum irdma_status_code irdma_hmc_setup(struct irdma_pci_f *rf) | 1510 | static int irdma_hmc_setup(struct irdma_pci_f *rf) |
| 1519 | { | 1511 | { |
| 1520 | enum irdma_status_code status; | 1512 | int status; |
| 1521 | u32 qpcnt; | 1513 | u32 qpcnt; |
| 1522 | 1514 | ||
| 1523 | if (rf->rdma_ver == IRDMA_GEN_1) | 1515 | if (rf->rdma_ver == IRDMA_GEN_1) |
| @@ -1570,9 +1562,9 @@ static void irdma_del_init_mem(struct irdma_pci_f *rf) · 46 unmodified lines | |||
| 1570 | * Return 0 if successful, otherwise clean up the resources | 1562 | * Return 0 if successful, otherwise clean up the resources |
| 1571 | * and return error | 1563 | * and return error |
| 1572 | */ | 1564 | */ |
| 1573 | static enum irdma_status_code irdma_initialize_dev(struct irdma_pci_f *rf) | 1565 | static int irdma_initialize_dev(struct irdma_pci_f *rf) |
| 1574 | { | 1566 | { |
| 1575 | enum irdma_status_code status; | 1567 | int status; |
| 1576 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1568 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1577 | struct irdma_device_init_info info = {}; | 1569 | struct irdma_device_init_info info = {}; |
| 1578 | struct irdma_dma_mem mem; | 1570 | struct irdma_dma_mem mem; |
| @@ -1584,7 +1576,7 @@ static enum irdma_status_code irdma_initialize_dev(struct irdma_pci_f *rf) · 5 unmodified lines | |||
| 1584 | 1576 | ||
| 1585 | rf->hmc_info_mem = kzalloc(size, GFP_KERNEL); | 1577 | rf->hmc_info_mem = kzalloc(size, GFP_KERNEL); |
| 1586 | if (!rf->hmc_info_mem) | 1578 | if (!rf->hmc_info_mem) |
| 1587 | return IRDMA_ERR_NO_MEMORY; | 1579 | return -ENOMEM; |
| 1588 | 1580 | ||
| 1589 | rf->pble_rsrc = (struct irdma_hmc_pble_rsrc *)rf->hmc_info_mem; | 1581 | rf->pble_rsrc = (struct irdma_hmc_pble_rsrc *)rf->hmc_info_mem; |
| 1590 | dev->hmc_info = &rf->hw.hmc; | 1582 | dev->hmc_info = &rf->hw.hmc; |
| @@ -1608,7 +1600,7 @@ static enum irdma_status_code irdma_initialize_dev(struct irdma_pci_f *rf) · 17 unmodified lines | |||
| 1608 | info.fpm_commit_buf = mem.va; | 1600 | info.fpm_commit_buf = mem.va; |
| 1609 | 1601 | ||
| 1610 | info.bar0 = rf->hw.hw_addr; | 1602 | info.bar0 = rf->hw.hw_addr; |
| 1611 | info.hmc_fn_id = PCI_FUNC(rf->pcidev->devfn); | 1603 | info.hmc_fn_id = rf->pf_id; |
| 1612 | info.hw = &rf->hw; | 1604 | info.hw = &rf->hw; |
| 1613 | status = irdma_sc_dev_init(rf->rdma_ver, &rf->sc_dev, &info); | 1605 | status = irdma_sc_dev_init(rf->rdma_ver, &rf->sc_dev, &info); |
| 1614 | if (status) | 1606 | if (status) |
| @@ -1667,9 +1659,9 @@ void irdma_rt_deinit_hw(struct irdma_device *iwdev) · 52 unmodified lines | |||
| 1667 | destroy_workqueue(iwdev->cleanup_wq); | 1659 | destroy_workqueue(iwdev->cleanup_wq); |
| 1668 | } | 1660 | } |
| 1669 | 1661 | ||
| 1670 | static enum irdma_status_code irdma_setup_init_state(struct irdma_pci_f *rf) | 1662 | static int irdma_setup_init_state(struct irdma_pci_f *rf) |
| 1671 | { | 1663 | { |
| 1672 | enum irdma_status_code status; | 1664 | int status; |
| 1673 | 1665 | ||
| 1674 | status = irdma_save_msix_info(rf); | 1666 | status = irdma_save_msix_info(rf); |
| 1675 | if (status) | 1667 | if (status) |
| @@ -1680,7 +1672,7 @@ static enum irdma_status_code irdma_setup_init_state(struct irdma_pci_f *rf) · 4 unmodified lines | |||
| 1680 | rf->obj_mem.va = dma_alloc_coherent(rf->hw.device, rf->obj_mem.size, | 1672 | rf->obj_mem.va = dma_alloc_coherent(rf->hw.device, rf->obj_mem.size, |
| 1681 | &rf->obj_mem.pa, GFP_KERNEL); | 1673 | &rf->obj_mem.pa, GFP_KERNEL); |
| 1682 | if (!rf->obj_mem.va) { | 1674 | if (!rf->obj_mem.va) { |
| 1683 | status = IRDMA_ERR_NO_MEMORY; | 1675 | status = -ENOMEM; |
| 1684 | goto clean_msixtbl; | 1676 | goto clean_msixtbl; |
| 1685 | } | 1677 | } |
| 1686 | 1678 | ||
| @@ -1763,14 +1755,14 @@ void irdma_ctrl_deinit_hw(struct irdma_pci_f *rf) · 76 unmodified lines | |||
| 1763 | * Create device queues ILQ, IEQ, CEQs and PBLEs. Setup irdma | 1755 | * Create device queues ILQ, IEQ, CEQs and PBLEs. Setup irdma |
| 1764 | * device resource objects. | 1756 | * device resource objects. |
| 1765 | */ | 1757 | */ |
| 1766 | enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, | 1758 | int irdma_rt_init_hw(struct irdma_device *iwdev, |
| 1767 | struct irdma_l2params *l2params) | 1759 | struct irdma_l2params *l2params) |
| 1768 | { | 1760 | { |
| 1769 | struct irdma_pci_f *rf = iwdev->rf; | 1761 | struct irdma_pci_f *rf = iwdev->rf; |
| 1770 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1762 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1771 | enum irdma_status_code status; | ||
| 1772 | struct irdma_vsi_init_info vsi_info = {}; | 1763 | struct irdma_vsi_init_info vsi_info = {}; |
| 1773 | struct irdma_vsi_stats_info stats_info = {}; | 1764 | struct irdma_vsi_stats_info stats_info = {}; |
| 1765 | int status; | ||
| 1774 | 1766 | ||
| 1775 | vsi_info.dev = dev; | 1767 | vsi_info.dev = dev; |
| 1776 | vsi_info.back_vsi = iwdev; | 1768 | vsi_info.back_vsi = iwdev; |
| @@ -1788,7 +1780,7 @@ enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, · 11 unmodified lines | |||
| 1788 | stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL); | 1780 | stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL); |
| 1789 | if (!stats_info.pestat) { | 1781 | if (!stats_info.pestat) { |
| 1790 | irdma_cleanup_cm_core(&iwdev->cm_core); | 1782 | irdma_cleanup_cm_core(&iwdev->cm_core); |
| 1791 | return IRDMA_ERR_NO_MEMORY; | 1783 | return -ENOMEM; |
| 1792 | } | 1784 | } |
| 1793 | stats_info.fcn_id = dev->hmc_fn_id; | 1785 | stats_info.fcn_id = dev->hmc_fn_id; |
| 1794 | status = irdma_vsi_stats_init(&iwdev->vsi, &stats_info); | 1786 | status = irdma_vsi_stats_init(&iwdev->vsi, &stats_info); |
| @@ -1850,7 +1842,7 @@ enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, · 55 unmodified lines | |||
| 1850 | iwdev->cleanup_wq = alloc_workqueue("irdma-cleanup-wq", | 1842 | iwdev->cleanup_wq = alloc_workqueue("irdma-cleanup-wq", |
| 1851 | WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE); | 1843 | WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE); |
| 1852 | if (!iwdev->cleanup_wq) | 1844 | if (!iwdev->cleanup_wq) |
| 1853 | return IRDMA_ERR_NO_MEMORY; | 1845 | return -ENOMEM; |
| 1854 | irdma_get_used_rsrc(iwdev); | 1846 | irdma_get_used_rsrc(iwdev); |
| 1855 | init_waitqueue_head(&iwdev->suspend_wq); | 1847 | init_waitqueue_head(&iwdev->suspend_wq); |
| 1856 | 1848 | ||
| @@ -1870,10 +1862,10 @@ enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, · 13 unmodified lines | |||
| 1870 | * | 1862 | * |
| 1871 | * Create admin queues, HMC obejcts and RF resource objects | 1863 | * Create admin queues, HMC obejcts and RF resource objects |
| 1872 | */ | 1864 | */ |
| 1873 | enum irdma_status_code irdma_ctrl_init_hw(struct irdma_pci_f *rf) | 1865 | int irdma_ctrl_init_hw(struct irdma_pci_f *rf) |
| 1874 | { | 1866 | { |
| 1875 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1867 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1876 | enum irdma_status_code status; | 1868 | int status; |
| 1877 | do { | 1869 | do { |
| 1878 | status = irdma_setup_init_state(rf); | 1870 | status = irdma_setup_init_state(rf); |
| 1879 | if (status) | 1871 | if (status) |
| @@ -1915,7 +1907,7 @@ enum irdma_status_code irdma_ctrl_init_hw(struct irdma_pci_f *rf) · 35 unmodified lines | |||
| 1915 | rf->cqp_cmpl_wq = alloc_ordered_workqueue("cqp_cmpl_wq", | 1907 | rf->cqp_cmpl_wq = alloc_ordered_workqueue("cqp_cmpl_wq", |
| 1916 | WQ_HIGHPRI | WQ_UNBOUND); | 1908 | WQ_HIGHPRI | WQ_UNBOUND); |
| 1917 | if (!rf->cqp_cmpl_wq) { | 1909 | if (!rf->cqp_cmpl_wq) { |
| 1918 | status = IRDMA_ERR_NO_MEMORY; | 1910 | status = -ENOMEM; |
| 1919 | break; | 1911 | break; |
| 1920 | } | 1912 | } |
| 1921 | INIT_WORK(&rf->cqp_cmpl_work, cqp_compl_worker); | 1913 | INIT_WORK(&rf->cqp_cmpl_work, cqp_compl_worker); |
| @@ -2202,11 +2194,11 @@ int irdma_add_local_mac_entry(struct irdma_pci_f *rf, const u8 *mac_addr, u16 id · 280 unmodified lines | |||
| 2202 | struct irdma_cqp *iwcqp = &rf->cqp; | 2194 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 2203 | struct irdma_cqp_request *cqp_request; | 2195 | struct irdma_cqp_request *cqp_request; |
| 2204 | struct cqp_cmds_info *cqp_info; | 2196 | struct cqp_cmds_info *cqp_info; |
| 2205 | enum irdma_status_code status; | 2197 | int status; |
| 2206 | 2198 | ||
| 2207 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); | 2199 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); |
| 2208 | if (!cqp_request) | 2200 | if (!cqp_request) |
| 2209 | return IRDMA_ERR_NO_MEMORY; | 2201 | return -ENOMEM; |
| 2210 | 2202 | ||
| 2211 | cqp_info = &cqp_request->info; | 2203 | cqp_info = &cqp_request->info; |
| 2212 | cqp_info->post_sq = 1; | 2204 | cqp_info->post_sq = 1; |
| @@ -2238,11 +2230,11 @@ int irdma_alloc_local_mac_entry(struct irdma_pci_f *rf, u16 *mac_tbl_idx) · 25 unmodified lines | |||
| 2238 | struct irdma_cqp *iwcqp = &rf->cqp; | 2230 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 2239 | struct irdma_cqp_request *cqp_request; | 2231 | struct irdma_cqp_request *cqp_request; |
| 2240 | struct cqp_cmds_info *cqp_info; | 2232 | struct cqp_cmds_info *cqp_info; |
| 2241 | enum irdma_status_code status = 0; | 2233 | int status = 0; |
| 2242 | 2234 | ||
| 2243 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); | 2235 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); |
| 2244 | if (!cqp_request) | 2236 | if (!cqp_request) |
| 2245 | return IRDMA_ERR_NO_MEMORY; | 2237 | return -ENOMEM; |
| 2246 | 2238 | ||
| 2247 | cqp_info = &cqp_request->info; | 2239 | cqp_info = &cqp_request->info; |
| 2248 | cqp_info->cqp_cmd = IRDMA_OP_ALLOC_LOCAL_MAC_ENTRY; | 2240 | cqp_info->cqp_cmd = IRDMA_OP_ALLOC_LOCAL_MAC_ENTRY; |
| @@ -2264,18 +2256,17 @@ int irdma_alloc_local_mac_entry(struct irdma_pci_f *rf, u16 *mac_tbl_idx) · 15 unmodified lines | |||
| 2264 | * @accel_local_port: port for apbvt | 2256 | * @accel_local_port: port for apbvt |
| 2265 | * @add_port: add ordelete port | 2257 | * @add_port: add ordelete port |
| 2266 | */ | 2258 | */ |
| 2267 | static enum irdma_status_code | 2259 | static int irdma_cqp_manage_apbvt_cmd(struct irdma_device *iwdev, |
| 2268 | irdma_cqp_manage_apbvt_cmd(struct irdma_device *iwdev, u16 accel_local_port, | 2260 | u16 accel_local_port, bool add_port) |
| 2269 | bool add_port) | ||
| 2270 | { | 2261 | { |
| 2271 | struct irdma_apbvt_info *info; | 2262 | struct irdma_apbvt_info *info; |
| 2272 | struct irdma_cqp_request *cqp_request; | 2263 | struct irdma_cqp_request *cqp_request; |
| 2273 | struct cqp_cmds_info *cqp_info; | 2264 | struct cqp_cmds_info *cqp_info; |
| 2274 | enum irdma_status_code status; | 2265 | int status; |
| 2275 | 2266 | ||
| 2276 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, add_port); | 2267 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, add_port); |
| 2277 | if (!cqp_request) | 2268 | if (!cqp_request) |
| 2278 | return IRDMA_ERR_NO_MEMORY; | 2269 | return -ENOMEM; |
| 2279 | 2270 | ||
| 2280 | cqp_info = &cqp_request->info; | 2271 | cqp_info = &cqp_request->info; |
| 2281 | info = &cqp_info->in.u.manage_apbvt_entry.info; | 2272 | info = &cqp_info->in.u.manage_apbvt_entry.info; |
| @@ -2429,22 +2420,21 @@ static void irdma_send_syn_cqp_callback(struct irdma_cqp_request *cqp_request) · 147 unmodified lines | |||
| 2429 | * @cmnode: cmnode associated with connection | 2420 | * @cmnode: cmnode associated with connection |
| 2430 | * @wait: wait for completion | 2421 | * @wait: wait for completion |
| 2431 | */ | 2422 | */ |
| 2432 | enum irdma_status_code | 2423 | int irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, |
| 2433 | irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, | 2424 | enum irdma_quad_entry_type etype, |
| 2434 | enum irdma_quad_entry_type etype, | 2425 | enum irdma_quad_hash_manage_type mtype, void *cmnode, |
| 2435 | enum irdma_quad_hash_manage_type mtype, void *cmnode, | 2426 | bool wait) |
| 2436 | bool wait) | ||
| 2437 | { | 2427 | { |
| 2438 | struct irdma_qhash_table_info *info; | 2428 | struct irdma_qhash_table_info *info; |
| 2439 | enum irdma_status_code status; | ||
| 2440 | struct irdma_cqp *iwcqp = &iwdev->rf->cqp; | 2429 | struct irdma_cqp *iwcqp = &iwdev->rf->cqp; |
| 2441 | struct irdma_cqp_request *cqp_request; | 2430 | struct irdma_cqp_request *cqp_request; |
| 2442 | struct cqp_cmds_info *cqp_info; | 2431 | struct cqp_cmds_info *cqp_info; |
| 2443 | struct irdma_cm_node *cm_node = cmnode; | 2432 | struct irdma_cm_node *cm_node = cmnode; |
| 2433 | int status; | ||
| 2444 | 2434 | ||
| 2445 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); | 2435 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); |
| 2446 | if (!cqp_request) | 2436 | if (!cqp_request) |
| 2447 | return IRDMA_ERR_NO_MEMORY; | 2437 | return -ENOMEM; |
| 2448 | 2438 | ||
| 2449 | cqp_info = &cqp_request->info; | 2439 | cqp_info = &cqp_request->info; |
| 2450 | info = &cqp_info->in.u.manage_qhash_table_entry.info; | 2440 | info = &cqp_info->in.u.manage_qhash_table_entry.info; |
| @@ -2558,12 +2548,10 @@ static void irdma_hw_flush_wqes_callback(struct irdma_cqp_request *cqp_request) · 107 unmodified lines | |||
| 2558 | * @info: info for flush | 2548 | * @info: info for flush |
| 2559 | * @wait: flag wait for completion | 2549 | * @wait: flag wait for completion |
| 2560 | */ | 2550 | */ |
| 2561 | enum irdma_status_code irdma_hw_flush_wqes(struct irdma_pci_f *rf, | 2551 | int irdma_hw_flush_wqes(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, |
| 2562 | struct irdma_sc_qp *qp, | 2552 | struct irdma_qp_flush_info *info, bool wait) |
| 2563 | struct irdma_qp_flush_info *info, | ||
| 2564 | bool wait) | ||
| 2565 | { | 2553 | { |
| 2566 | enum irdma_status_code status; | 2554 | int status; |
| 2567 | struct irdma_qp_flush_info *hw_info; | 2555 | struct irdma_qp_flush_info *hw_info; |
| 2568 | struct irdma_cqp_request *cqp_request; | 2556 | struct irdma_cqp_request *cqp_request; |
| 2569 | struct cqp_cmds_info *cqp_info; | 2557 | struct cqp_cmds_info *cqp_info; |
| @@ -2571,7 +2559,7 @@ enum irdma_status_code irdma_hw_flush_wqes(struct irdma_pci_f *rf, · 1 unmodified line | |||
| 2571 | 2559 | ||
| 2572 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); | 2560 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); |
| 2573 | if (!cqp_request) | 2561 | if (!cqp_request) |
| 2574 | return IRDMA_ERR_NO_MEMORY; | 2562 | return -ENOMEM; |
| 2575 | 2563 | ||
| 2576 | cqp_info = &cqp_request->info; | 2564 | cqp_info = &cqp_request->info; |
| 2577 | if (!wait) | 2565 | if (!wait) |
| @@ -2619,7 +2607,7 @@ enum irdma_status_code irdma_hw_flush_wqes(struct irdma_pci_f *rf, · 41 unmodified lines | |||
| 2619 | info->sq = true; | 2607 | info->sq = true; |
| 2620 | new_req = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 2608 | new_req = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 2621 | if (!new_req) { | 2609 | if (!new_req) { |
| 2622 | status = IRDMA_ERR_NO_MEMORY; | 2610 | status = -ENOMEM; |
| 2623 | goto put_cqp; | 2611 | goto put_cqp; |
| 2624 | } | 2612 | } |
| 2625 | cqp_info = &new_req->info; | 2613 | cqp_info = &new_req->info; |
| @@ -3,7 +3,6 @@ · 2 unmodified lines | |||
| 3 | #include "osdep.h" | 3 | #include "osdep.h" |
| 4 | #include "type.h" | 4 | #include "type.h" |
| 5 | #include "i40iw_hw.h" | 5 | #include "i40iw_hw.h" |
| 6 | #include "status.h" | ||
| 7 | #include "protos.h" | 6 | #include "protos.h" |
| 8 | 7 | ||
| 9 | static u32 i40iw_regs[IRDMA_MAX_REGS] = { | 8 | static u32 i40iw_regs[IRDMA_MAX_REGS] = { |
| @@ -77,6 +77,7 @@ static void i40iw_fill_device_info(struct irdma_device *iwdev, struct i40e_info · 76 unmodified lines | |||
| 77 | rf->rdma_ver = IRDMA_GEN_1; | 77 | rf->rdma_ver = IRDMA_GEN_1; |
| 78 | rf->gen_ops.request_reset = i40iw_request_reset; | 78 | rf->gen_ops.request_reset = i40iw_request_reset; |
| 79 | rf->pcidev = cdev_info->pcidev; | 79 | rf->pcidev = cdev_info->pcidev; |
| 80 | rf->pf_id = cdev_info->fid; | ||
| 80 | rf->hw.hw_addr = cdev_info->hw_addr; | 81 | rf->hw.hw_addr = cdev_info->hw_addr; |
| 81 | rf->cdev = cdev_info; | 82 | rf->cdev = cdev_info; |
| 82 | rf->msix_count = cdev_info->msix_count; | 83 | rf->msix_count = cdev_info->msix_count; |
| @@ -138,7 +139,7 @@ static int i40iw_open(struct i40e_info *cdev_info, struct i40e_client *client) · 55 unmodified lines | |||
| 138 | if (last_qset == IRDMA_NO_QSET) | 139 | if (last_qset == IRDMA_NO_QSET) |
| 139 | last_qset = qset; | 140 | last_qset = qset; |
| 140 | else if ((qset != last_qset) && (qset != IRDMA_NO_QSET)) | 141 | else if ((qset != last_qset) && (qset != IRDMA_NO_QSET)) |
| 141 | iwdev->dcb = true; | 142 | iwdev->dcb_vlan_mode = true; |
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | if (irdma_rt_init_hw(iwdev, &l2params)) { | 145 | if (irdma_rt_init_hw(iwdev, &l2params)) { |
| @@ -79,6 +79,10 @@ static void irdma_fill_qos_info(struct irdma_l2params *l2params, · 78 unmodified lines | |||
| 79 | } | 79 | } |
| 80 | for (i = 0; i < IIDC_MAX_USER_PRIORITY; i++) | 80 | for (i = 0; i < IIDC_MAX_USER_PRIORITY; i++) |
| 81 | l2params->up2tc[i] = qos_info->up2tc[i]; | 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 | static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_event *event) | 88 | static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_event *event) |
| @@ -108,8 +112,9 @@ static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_event *event · 23 unmodified lines | |||
| 108 | l2params.tc_changed = true; | 112 | l2params.tc_changed = true; |
| 109 | ibdev_dbg(&iwdev->ibdev, "CLNT: TC Change\n"); | 113 | ibdev_dbg(&iwdev->ibdev, "CLNT: TC Change\n"); |
| 110 | ice_get_qos_params(pf, &qos_info); | 114 | ice_get_qos_params(pf, &qos_info); |
| 111 | iwdev->dcb = qos_info.num_tc > 1; | ||
| 112 | irdma_fill_qos_info(&l2params, &qos_info); | 115 | irdma_fill_qos_info(&l2params, &qos_info); |
| 116 | if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) | ||
| 117 | iwdev->dcb_vlan_mode = qos_info.num_tc > 1 && !l2params.dscp_mode; | ||
| 113 | irdma_change_l2params(&iwdev->vsi, &l2params); | 118 | irdma_change_l2params(&iwdev->vsi, &l2params); |
| 114 | } else if (*event->type & BIT(IIDC_EVENT_CRIT_ERR)) { | 119 | } else if (*event->type & BIT(IIDC_EVENT_CRIT_ERR)) { |
| 115 | ibdev_warn(&iwdev->ibdev, "ICE OICR event notification: oicr = 0x%08x\n", | 120 | ibdev_warn(&iwdev->ibdev, "ICE OICR event notification: oicr = 0x%08x\n", |
| @@ -157,8 +162,8 @@ static void irdma_request_reset(struct irdma_pci_f *rf) · 41 unmodified lines | |||
| 157 | * @vsi: vsi structure | 162 | * @vsi: vsi structure |
| 158 | * @tc_node: Traffic class node | 163 | * @tc_node: Traffic class node |
| 159 | */ | 164 | */ |
| 160 | static enum irdma_status_code irdma_lan_register_qset(struct irdma_sc_vsi *vsi, | 165 | static int irdma_lan_register_qset(struct irdma_sc_vsi *vsi, |
| 161 | struct irdma_ws_node *tc_node) | 166 | struct irdma_ws_node *tc_node) |
| 162 | { | 167 | { |
| 163 | struct irdma_device *iwdev = vsi->back_vsi; | 168 | struct irdma_device *iwdev = vsi->back_vsi; |
| 164 | struct ice_pf *pf = iwdev->rf->cdev; | 169 | struct ice_pf *pf = iwdev->rf->cdev; |
| @@ -171,7 +176,7 @@ static enum irdma_status_code irdma_lan_register_qset(struct irdma_sc_vsi *vsi, · 6 unmodified lines | |||
| 171 | ret = ice_add_rdma_qset(pf, &qset); | 176 | ret = ice_add_rdma_qset(pf, &qset); |
| 172 | if (ret) { | 177 | if (ret) { |
| 173 | ibdev_dbg(&iwdev->ibdev, "WS: LAN alloc_res for rdma qset failed.\n"); | 178 | ibdev_dbg(&iwdev->ibdev, "WS: LAN alloc_res for rdma qset failed.\n"); |
| 174 | return IRDMA_ERR_REG_QSET; | 179 | return ret; |
| 175 | } | 180 | } |
| 176 | 181 | ||
| 177 | tc_node->l2_sched_node_id = qset.teid; | 182 | tc_node->l2_sched_node_id = qset.teid; |
| @@ -226,6 +231,7 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf · 48 unmodified lines | |||
| 226 | rf->hw.hw_addr = pf->hw.hw_addr; | 231 | rf->hw.hw_addr = pf->hw.hw_addr; |
| 227 | rf->pcidev = pf->pdev; | 232 | rf->pcidev = pf->pdev; |
| 228 | rf->msix_count = pf->num_rdma_msix; | 233 | rf->msix_count = pf->num_rdma_msix; |
| 234 | rf->pf_id = pf->hw.pf_id; | ||
| 229 | rf->msix_entries = &pf->msix_entries[pf->rdma_base_vector]; | 235 | rf->msix_entries = &pf->msix_entries[pf->rdma_base_vector]; |
| 230 | rf->default_vsi.vsi_idx = vsi->vsi_num; | 236 | rf->default_vsi.vsi_idx = vsi->vsi_num; |
| 231 | rf->protocol_used = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? | 237 | rf->protocol_used = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? |
| @@ -236,7 +242,7 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf · 4 unmodified lines | |||
| 236 | rf->gen_ops.request_reset = irdma_request_reset; | 242 | rf->gen_ops.request_reset = irdma_request_reset; |
| 237 | rf->limits_sel = 7; | 243 | rf->limits_sel = 7; |
| 238 | rf->iwdev = iwdev; | 244 | rf->iwdev = iwdev; |
| 239 | 245 | mutex_init(&iwdev->ah_tbl_lock); | |
| 240 | iwdev->netdev = vsi->netdev; | 246 | iwdev->netdev = vsi->netdev; |
| 241 | iwdev->vsi_num = vsi->vsi_num; | 247 | iwdev->vsi_num = vsi->vsi_num; |
| 242 | iwdev->init_state = INITIAL_STATE; | 248 | iwdev->init_state = INITIAL_STATE; |
| @@ -275,18 +281,19 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_ · 32 unmodified lines | |||
| 275 | irdma_fill_device_info(iwdev, pf, vsi); | 281 | irdma_fill_device_info(iwdev, pf, vsi); |
| 276 | rf = iwdev->rf; | 282 | rf = iwdev->rf; |
| 277 | 283 | ||
| 278 | if (irdma_ctrl_init_hw(rf)) { | 284 | err = irdma_ctrl_init_hw(rf); |
| 279 | err = -EIO; | 285 | if (err) |
| 280 | goto err_ctrl_init; | 286 | goto err_ctrl_init; |
| 281 | } | ||
| 282 | 287 | ||
| 283 | l2params.mtu = iwdev->netdev->mtu; | 288 | l2params.mtu = iwdev->netdev->mtu; |
| 284 | ice_get_qos_params(pf, &qos_info); | 289 | ice_get_qos_params(pf, &qos_info); |
| 285 | irdma_fill_qos_info(&l2params, &qos_info); | 290 | irdma_fill_qos_info(&l2params, &qos_info); |
| 286 | if (irdma_rt_init_hw(iwdev, &l2params)) { | 291 | if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY) |
| 287 | err = -EIO; | 292 | iwdev->dcb_vlan_mode = l2params.num_tc > 1 && !l2params.dscp_mode; |
| 293 | |||
| 294 | err = irdma_rt_init_hw(iwdev, &l2params); | ||
| 295 | if (err) | ||
| 288 | goto err_rt_init; | 296 | goto err_rt_init; |
| 289 | } | ||
| 290 | 297 | ||
| 291 | err = irdma_ib_register_device(iwdev); | 298 | err = irdma_ib_register_device(iwdev); |
| 292 | if (err) | 299 | if (err) |
| @@ -40,7 +40,6 @@ · 39 unmodified lines | |||
| 40 | #include <rdma/ib_umem.h> | 40 | #include <rdma/ib_umem.h> |
| 41 | #include <rdma/ib_cache.h> | 41 | #include <rdma/ib_cache.h> |
| 42 | #include <rdma/uverbs_ioctl.h> | 42 | #include <rdma/uverbs_ioctl.h> |
| 43 | #include "status.h" | ||
| 44 | #include "osdep.h" | 43 | #include "osdep.h" |
| 45 | #include "defs.h" | 44 | #include "defs.h" |
| 46 | #include "hmc.h" | 45 | #include "hmc.h" |
| @@ -242,8 +241,8 @@ struct irdma_qvlist_info { · 195 unmodified lines | |||
| 242 | 241 | ||
| 243 | struct irdma_gen_ops { | 242 | struct irdma_gen_ops { |
| 244 | void (*request_reset)(struct irdma_pci_f *rf); | 243 | void (*request_reset)(struct irdma_pci_f *rf); |
| 245 | enum irdma_status_code (*register_qset)(struct irdma_sc_vsi *vsi, | 244 | int (*register_qset)(struct irdma_sc_vsi *vsi, |
| 246 | struct irdma_ws_node *tc_node); | 245 | struct irdma_ws_node *tc_node); |
| 247 | void (*unregister_qset)(struct irdma_sc_vsi *vsi, | 246 | void (*unregister_qset)(struct irdma_sc_vsi *vsi, |
| 248 | struct irdma_ws_node *tc_node); | 247 | struct irdma_ws_node *tc_node); |
| 249 | }; | 248 | }; |
| @@ -257,6 +256,7 @@ struct irdma_pci_f { · 7 unmodified lines | |||
| 257 | u8 *mem_rsrc; | 256 | u8 *mem_rsrc; |
| 258 | u8 rdma_ver; | 257 | u8 rdma_ver; |
| 259 | u8 rst_to; | 258 | u8 rst_to; |
| 259 | u8 pf_id; | ||
| 260 | enum irdma_protocol_used protocol_used; | 260 | enum irdma_protocol_used protocol_used; |
| 261 | u32 sd_type; | 261 | u32 sd_type; |
| 262 | u32 msix_count; | 262 | u32 msix_count; |
| @@ -332,6 +332,8 @@ struct irdma_device { · 69 unmodified lines | |||
| 332 | struct workqueue_struct *cleanup_wq; | 332 | struct workqueue_struct *cleanup_wq; |
| 333 | struct irdma_sc_vsi vsi; | 333 | struct irdma_sc_vsi vsi; |
| 334 | struct irdma_cm_core cm_core; | 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 | u32 roce_cwnd; | 337 | u32 roce_cwnd; |
| 336 | u32 roce_ackcreds; | 338 | u32 roce_ackcreds; |
| 337 | u32 vendor_id; | 339 | u32 vendor_id; |
| @@ -345,7 +347,7 @@ struct irdma_device { · 7 unmodified lines | |||
| 345 | u8 iw_status; | 347 | u8 iw_status; |
| 346 | bool roce_mode:1; | 348 | bool roce_mode:1; |
| 347 | bool roce_dcqcn_en:1; | 349 | bool roce_dcqcn_en:1; |
| 348 | bool dcb:1; | 350 | bool dcb_vlan_mode:1; |
| 349 | bool iw_ooo:1; | 351 | bool iw_ooo:1; |
| 350 | enum init_completion_state init_state; | 352 | enum init_completion_state init_state; |
| 351 | 353 | ||
| @@ -457,10 +459,10 @@ static inline void irdma_free_rsrc(struct irdma_pci_f *rf, · 105 unmodified lines | |||
| 457 | spin_unlock_irqrestore(&rf->rsrc_lock, flags); | 459 | spin_unlock_irqrestore(&rf->rsrc_lock, flags); |
| 458 | } | 460 | } |
| 459 | 461 | ||
| 460 | enum irdma_status_code irdma_ctrl_init_hw(struct irdma_pci_f *rf); | 462 | int irdma_ctrl_init_hw(struct irdma_pci_f *rf); |
| 461 | void irdma_ctrl_deinit_hw(struct irdma_pci_f *rf); | 463 | void irdma_ctrl_deinit_hw(struct irdma_pci_f *rf); |
| 462 | enum irdma_status_code irdma_rt_init_hw(struct irdma_device *iwdev, | 464 | int irdma_rt_init_hw(struct irdma_device *iwdev, |
| 463 | struct irdma_l2params *l2params); | 465 | struct irdma_l2params *l2params); |
| 464 | void irdma_rt_deinit_hw(struct irdma_device *iwdev); | 466 | void irdma_rt_deinit_hw(struct irdma_device *iwdev); |
| 465 | void irdma_qp_add_ref(struct ib_qp *ibqp); | 467 | void irdma_qp_add_ref(struct ib_qp *ibqp); |
| 466 | void irdma_qp_rem_ref(struct ib_qp *ibqp); | 468 | void irdma_qp_rem_ref(struct ib_qp *ibqp); |
| @@ -489,9 +491,8 @@ void irdma_cm_disconn(struct irdma_qp *qp); · 22 unmodified lines | |||
| 489 | 491 | ||
| 490 | bool irdma_cqp_crit_err(struct irdma_sc_dev *dev, u8 cqp_cmd, | 492 | bool irdma_cqp_crit_err(struct irdma_sc_dev *dev, u8 cqp_cmd, |
| 491 | u16 maj_err_code, u16 min_err_code); | 493 | u16 maj_err_code, u16 min_err_code); |
| 492 | enum irdma_status_code | 494 | int irdma_handle_cqp_op(struct irdma_pci_f *rf, |
| 493 | irdma_handle_cqp_op(struct irdma_pci_f *rf, | 495 | struct irdma_cqp_request *cqp_request); |
| 494 | struct irdma_cqp_request *cqp_request); | ||
| 495 | 496 | ||
| 496 | int irdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, | 497 | int irdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, |
| 497 | struct ib_udata *udata); | 498 | struct ib_udata *udata); |
| @@ -500,21 +501,17 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 2 unmodified lines | |||
| 500 | void irdma_cq_wq_destroy(struct irdma_pci_f *rf, struct irdma_sc_cq *cq); | 501 | void irdma_cq_wq_destroy(struct irdma_pci_f *rf, struct irdma_sc_cq *cq); |
| 501 | 502 | ||
| 502 | void irdma_cleanup_pending_cqp_op(struct irdma_pci_f *rf); | 503 | void irdma_cleanup_pending_cqp_op(struct irdma_pci_f *rf); |
| 503 | enum irdma_status_code irdma_hw_modify_qp(struct irdma_device *iwdev, | 504 | int irdma_hw_modify_qp(struct irdma_device *iwdev, struct irdma_qp *iwqp, |
| 504 | struct irdma_qp *iwqp, | 505 | struct irdma_modify_qp_info *info, bool wait); |
| 505 | struct irdma_modify_qp_info *info, | 506 | int irdma_qp_suspend_resume(struct irdma_sc_qp *qp, bool suspend); |
| 506 | bool wait); | 507 | int irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, |
| 507 | enum irdma_status_code irdma_qp_suspend_resume(struct irdma_sc_qp *qp, | 508 | enum irdma_quad_entry_type etype, |
| 508 | bool suspend); | 509 | enum irdma_quad_hash_manage_type mtype, void *cmnode, |
| 509 | enum irdma_status_code | 510 | bool wait); |
| 510 | irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo, | ||
| 511 | enum irdma_quad_entry_type etype, | ||
| 512 | enum irdma_quad_hash_manage_type mtype, void *cmnode, | ||
| 513 | bool wait); | ||
| 514 | void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf); | 511 | void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf); |
| 515 | void irdma_free_sqbuf(struct irdma_sc_vsi *vsi, void *bufp); | 512 | void irdma_free_sqbuf(struct irdma_sc_vsi *vsi, void *bufp); |
| 516 | void irdma_free_qp_rsrc(struct irdma_qp *iwqp); | 513 | void irdma_free_qp_rsrc(struct irdma_qp *iwqp); |
| 517 | enum irdma_status_code irdma_setup_cm_core(struct irdma_device *iwdev, u8 ver); | 514 | int irdma_setup_cm_core(struct irdma_device *iwdev, u8 ver); |
| 518 | void irdma_cleanup_cm_core(struct irdma_cm_core *cm_core); | 515 | void irdma_cleanup_cm_core(struct irdma_cm_core *cm_core); |
| 519 | void irdma_next_iw_state(struct irdma_qp *iwqp, u8 state, u8 del_hash, u8 term, | 516 | void irdma_next_iw_state(struct irdma_qp *iwqp, u8 state, u8 del_hash, u8 term, |
| 520 | u8 term_len); | 517 | u8 term_len); |
| @@ -523,10 +520,8 @@ int irdma_send_reset(struct irdma_cm_node *cm_node); · 2 unmodified lines | |||
| 523 | struct irdma_cm_node *irdma_find_node(struct irdma_cm_core *cm_core, | 520 | struct irdma_cm_node *irdma_find_node(struct irdma_cm_core *cm_core, |
| 524 | u16 rem_port, u32 *rem_addr, u16 loc_port, | 521 | u16 rem_port, u32 *rem_addr, u16 loc_port, |
| 525 | u32 *loc_addr, u16 vlan_id); | 522 | u32 *loc_addr, u16 vlan_id); |
| 526 | enum irdma_status_code irdma_hw_flush_wqes(struct irdma_pci_f *rf, | 523 | int irdma_hw_flush_wqes(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, |
| 527 | struct irdma_sc_qp *qp, | 524 | struct irdma_qp_flush_info *info, bool wait); |
| 528 | struct irdma_qp_flush_info *info, | ||
| 529 | bool wait); | ||
| 530 | void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, | 525 | void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, |
| 531 | struct irdma_gen_ae_info *info, bool wait); | 526 | struct irdma_gen_ae_info *info, bool wait); |
| 532 | void irdma_copy_ip_ntohl(u32 *dst, __be32 *src); | 527 | void irdma_copy_ip_ntohl(u32 *dst, __be32 *src); |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | #include <linux/pci.h> | 6 | #include <linux/pci.h> |
| 7 | #include <linux/bitfield.h> | 7 | #include <linux/bitfield.h> |
| 8 | #include <linux/net/intel/iidc.h> | ||
| 8 | #include <crypto/hash.h> | 9 | #include <crypto/hash.h> |
| 9 | #include <rdma/ib_verbs.h> | 10 | #include <rdma/ib_verbs.h> |
| 10 | 11 | ||
| @@ -42,32 +43,28 @@ enum irdma_status_code irdma_vf_wait_vchnl_resp(struct irdma_sc_dev *dev); · 31 unmodified lines | |||
| 42 | bool irdma_vf_clear_to_send(struct irdma_sc_dev *dev); | 43 | bool irdma_vf_clear_to_send(struct irdma_sc_dev *dev); |
| 43 | void irdma_add_dev_ref(struct irdma_sc_dev *dev); | 44 | void irdma_add_dev_ref(struct irdma_sc_dev *dev); |
| 44 | void irdma_put_dev_ref(struct irdma_sc_dev *dev); | 45 | void irdma_put_dev_ref(struct irdma_sc_dev *dev); |
| 45 | enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc, | 46 | int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len, |
| 46 | void *addr, u32 len, u32 val); | 47 | u32 val); |
| 47 | struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev, | 48 | struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev, |
| 48 | struct irdma_puda_buf *buf); | 49 | struct irdma_puda_buf *buf); |
| 49 | void irdma_send_ieq_ack(struct irdma_sc_qp *qp); | 50 | void irdma_send_ieq_ack(struct irdma_sc_qp *qp); |
| 50 | void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, | 51 | void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, |
| 51 | u32 seqnum); | 52 | u32 seqnum); |
| 52 | void irdma_free_hash_desc(struct shash_desc *hash_desc); | 53 | void irdma_free_hash_desc(struct shash_desc *hash_desc); |
| 53 | enum irdma_status_code irdma_init_hash_desc(struct shash_desc **hash_desc); | 54 | int irdma_init_hash_desc(struct shash_desc **hash_desc); |
| 54 | enum irdma_status_code | 55 | int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, |
| 55 | irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, | 56 | struct irdma_puda_buf *buf); |
| 56 | struct irdma_puda_buf *buf); | 57 | int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, |
| 57 | enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, | 58 | struct irdma_update_sds_info *info); |
| 58 | struct irdma_update_sds_info *info); | 59 | int irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, |
| 59 | enum irdma_status_code | 60 | struct irdma_hmc_fcn_info *hmcfcninfo, |
| 60 | irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, | 61 | u16 *pmf_idx); |
| 61 | struct irdma_hmc_fcn_info *hmcfcninfo, | 62 | int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, |
| 62 | u16 *pmf_idx); | 63 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); |
| 63 | enum irdma_status_code | 64 | int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, |
| 64 | irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, | 65 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); |
| 65 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); | 66 | int irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, |
| 66 | enum irdma_status_code | 67 | struct irdma_dma_mem *mem); |
| 67 | irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, | ||
| 68 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); | ||
| 69 | enum irdma_status_code irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, | ||
| 70 | struct irdma_dma_mem *mem); | ||
| 71 | void *irdma_remove_cqp_head(struct irdma_sc_dev *dev); | 68 | void *irdma_remove_cqp_head(struct irdma_sc_dev *dev); |
| 72 | void irdma_term_modify_qp(struct irdma_sc_qp *qp, u8 next_state, u8 term, | 69 | void irdma_term_modify_qp(struct irdma_sc_qp *qp, u8 next_state, u8 term, |
| 73 | u8 term_len); | 70 | u8 term_len); |
| @@ -79,7 +76,7 @@ void irdma_hw_stats_stop_timer(struct irdma_sc_vsi *vsi); · 5 unmodified lines | |||
| 79 | void wr32(struct irdma_hw *hw, u32 reg, u32 val); | 76 | void wr32(struct irdma_hw *hw, u32 reg, u32 val); |
| 80 | u32 rd32(struct irdma_hw *hw, u32 reg); | 77 | u32 rd32(struct irdma_hw *hw, u32 reg); |
| 81 | u64 rd64(struct irdma_hw *hw, u32 reg); | 78 | u64 rd64(struct irdma_hw *hw, u32 reg); |
| 82 | enum irdma_status_code irdma_map_vm_page_list(struct irdma_hw *hw, void *va, | 79 | int irdma_map_vm_page_list(struct irdma_hw *hw, void *va, dma_addr_t *pg_dma, |
| 83 | dma_addr_t *pg_dma, u32 pg_cnt); | 80 | u32 pg_cnt); |
| 84 | void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt); | 81 | void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt); |
| 85 | #endif /* IRDMA_OSDEP_H */ | 82 | #endif /* IRDMA_OSDEP_H */ |
| @@ -1,15 +1,13 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB | 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB |
| 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ | 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ |
| 3 | #include "osdep.h" | 3 | #include "osdep.h" |
| 4 | #include "status.h" | ||
| 5 | #include "hmc.h" | 4 | #include "hmc.h" |
| 6 | #include "defs.h" | 5 | #include "defs.h" |
| 7 | #include "type.h" | 6 | #include "type.h" |
| 8 | #include "protos.h" | 7 | #include "protos.h" |
| 9 | #include "pble.h" | 8 | #include "pble.h" |
| 10 | 9 | ||
| 11 | static enum irdma_status_code | 10 | static int add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); |
| 12 | add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); | ||
| 13 | 11 | ||
| 14 | /** | 12 | /** |
| 15 | * irdma_destroy_pble_prm - destroy prm during module unload | 13 | * irdma_destroy_pble_prm - destroy prm during module unload |
| @@ -35,13 +33,12 @@ void irdma_destroy_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc) · 19 unmodified lines | |||
| 35 | * @dev: irdma_sc_dev struct | 33 | * @dev: irdma_sc_dev struct |
| 36 | * @pble_rsrc: pble resources | 34 | * @pble_rsrc: pble resources |
| 37 | */ | 35 | */ |
| 38 | enum irdma_status_code | 36 | int irdma_hmc_init_pble(struct irdma_sc_dev *dev, |
| 39 | irdma_hmc_init_pble(struct irdma_sc_dev *dev, | 37 | struct irdma_hmc_pble_rsrc *pble_rsrc) |
| 40 | struct irdma_hmc_pble_rsrc *pble_rsrc) | ||
| 41 | { | 38 | { |
| 42 | struct irdma_hmc_info *hmc_info; | 39 | struct irdma_hmc_info *hmc_info; |
| 43 | u32 fpm_idx = 0; | 40 | u32 fpm_idx = 0; |
| 44 | enum irdma_status_code status = 0; | 41 | int status = 0; |
| 45 | 42 | ||
| 46 | hmc_info = dev->hmc_info; | 43 | hmc_info = dev->hmc_info; |
| 47 | pble_rsrc->dev = dev; | 44 | pble_rsrc->dev = dev; |
| @@ -60,7 +57,7 @@ irdma_hmc_init_pble(struct irdma_sc_dev *dev, · 12 unmodified lines | |||
| 60 | INIT_LIST_HEAD(&pble_rsrc->pinfo.clist); | 57 | INIT_LIST_HEAD(&pble_rsrc->pinfo.clist); |
| 61 | if (add_pble_prm(pble_rsrc)) { | 58 | if (add_pble_prm(pble_rsrc)) { |
| 62 | irdma_destroy_pble_prm(pble_rsrc); | 59 | irdma_destroy_pble_prm(pble_rsrc); |
| 63 | status = IRDMA_ERR_NO_MEMORY; | 60 | status = -ENOMEM; |
| 64 | } | 61 | } |
| 65 | 62 | ||
| 66 | return status; | 63 | return status; |
| @@ -84,12 +81,11 @@ static void get_sd_pd_idx(struct irdma_hmc_pble_rsrc *pble_rsrc, · 17 unmodified lines | |||
| 84 | * @pble_rsrc: pble resource ptr | 81 | * @pble_rsrc: pble resource ptr |
| 85 | * @info: page info for sd | 82 | * @info: page info for sd |
| 86 | */ | 83 | */ |
| 87 | static enum irdma_status_code | 84 | static int add_sd_direct(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 88 | add_sd_direct(struct irdma_hmc_pble_rsrc *pble_rsrc, | 85 | struct irdma_add_page_info *info) |
| 89 | struct irdma_add_page_info *info) | ||
| 90 | { | 86 | { |
| 91 | struct irdma_sc_dev *dev = pble_rsrc->dev; | 87 | struct irdma_sc_dev *dev = pble_rsrc->dev; |
| 92 | enum irdma_status_code ret_code = 0; | 88 | int ret_code = 0; |
| 93 | struct sd_pd_idx *idx = &info->idx; | 89 | struct sd_pd_idx *idx = &info->idx; |
| 94 | struct irdma_chunk *chunk = info->chunk; | 90 | struct irdma_chunk *chunk = info->chunk; |
| 95 | struct irdma_hmc_info *hmc_info = info->hmc_info; | 91 | struct irdma_hmc_info *hmc_info = info->hmc_info; |
| @@ -137,9 +133,8 @@ static u32 fpm_to_idx(struct irdma_hmc_pble_rsrc *pble_rsrc, u64 addr) · 41 unmodified lines | |||
| 137 | * @pble_rsrc: pble resource management | 133 | * @pble_rsrc: pble resource management |
| 138 | * @info: page info for sd | 134 | * @info: page info for sd |
| 139 | */ | 135 | */ |
| 140 | static enum irdma_status_code | 136 | static int add_bp_pages(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 141 | add_bp_pages(struct irdma_hmc_pble_rsrc *pble_rsrc, | 137 | struct irdma_add_page_info *info) |
| 142 | struct irdma_add_page_info *info) | ||
| 143 | { | 138 | { |
| 144 | struct irdma_sc_dev *dev = pble_rsrc->dev; | 139 | struct irdma_sc_dev *dev = pble_rsrc->dev; |
| 145 | u8 *addr; | 140 | u8 *addr; |
| @@ -148,13 +143,13 @@ add_bp_pages(struct irdma_hmc_pble_rsrc *pble_rsrc, · 2 unmodified lines | |||
| 148 | struct irdma_hmc_sd_entry *sd_entry = info->sd_entry; | 143 | struct irdma_hmc_sd_entry *sd_entry = info->sd_entry; |
| 149 | struct irdma_hmc_info *hmc_info = info->hmc_info; | 144 | struct irdma_hmc_info *hmc_info = info->hmc_info; |
| 150 | struct irdma_chunk *chunk = info->chunk; | 145 | struct irdma_chunk *chunk = info->chunk; |
| 151 | enum irdma_status_code status = 0; | 146 | int status = 0; |
| 152 | u32 rel_pd_idx = info->idx.rel_pd_idx; | 147 | u32 rel_pd_idx = info->idx.rel_pd_idx; |
| 153 | u32 pd_idx = info->idx.pd_idx; | 148 | u32 pd_idx = info->idx.pd_idx; |
| 154 | u32 i; | 149 | u32 i; |
| 155 | 150 | ||
| 156 | if (irdma_pble_get_paged_mem(chunk, info->pages)) | 151 | if (irdma_pble_get_paged_mem(chunk, info->pages)) |
| 157 | return IRDMA_ERR_NO_MEMORY; | 152 | return -ENOMEM; |
| 158 | 153 | ||
| 159 | status = irdma_add_sd_table_entry(dev->hw, hmc_info, info->idx.sd_idx, | 154 | status = irdma_add_sd_table_entry(dev->hw, hmc_info, info->idx.sd_idx, |
| 160 | IRDMA_SD_TYPE_PAGED, | 155 | IRDMA_SD_TYPE_PAGED, |
| @@ -207,8 +202,7 @@ static enum irdma_sd_entry_type irdma_get_type(struct irdma_sc_dev *dev, · 46 unmodified lines | |||
| 207 | * add_pble_prm - add a sd entry for pble resoure | 202 | * add_pble_prm - add a sd entry for pble resoure |
| 208 | * @pble_rsrc: pble resource management | 203 | * @pble_rsrc: pble resource management |
| 209 | */ | 204 | */ |
| 210 | static enum irdma_status_code | 205 | static int add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc) |
| 211 | add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc) | ||
| 212 | { | 206 | { |
| 213 | struct irdma_sc_dev *dev = pble_rsrc->dev; | 207 | struct irdma_sc_dev *dev = pble_rsrc->dev; |
| 214 | struct irdma_hmc_sd_entry *sd_entry; | 208 | struct irdma_hmc_sd_entry *sd_entry; |
| @@ -216,22 +210,22 @@ add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc) · 1 unmodified line | |||
| 216 | struct irdma_chunk *chunk; | 210 | struct irdma_chunk *chunk; |
| 217 | struct irdma_add_page_info info; | 211 | struct irdma_add_page_info info; |
| 218 | struct sd_pd_idx *idx = &info.idx; | 212 | struct sd_pd_idx *idx = &info.idx; |
| 219 | enum irdma_status_code ret_code = 0; | 213 | int ret_code = 0; |
| 220 | enum irdma_sd_entry_type sd_entry_type; | 214 | enum irdma_sd_entry_type sd_entry_type; |
| 221 | u64 sd_reg_val = 0; | 215 | u64 sd_reg_val = 0; |
| 222 | struct irdma_virt_mem chunkmem; | 216 | struct irdma_virt_mem chunkmem; |
| 223 | u32 pages; | 217 | u32 pages; |
| 224 | 218 | ||
| 225 | if (pble_rsrc->unallocated_pble < PBLE_PER_PAGE) | 219 | if (pble_rsrc->unallocated_pble < PBLE_PER_PAGE) |
| 226 | return IRDMA_ERR_NO_MEMORY; | 220 | return -ENOMEM; |
| 227 | 221 | ||
| 228 | if (pble_rsrc->next_fpm_addr & 0xfff) | 222 | if (pble_rsrc->next_fpm_addr & 0xfff) |
| 229 | return IRDMA_ERR_INVALID_PAGE_DESC_INDEX; | 223 | return -EINVAL; |
| 230 | 224 | ||
| 231 | chunkmem.size = sizeof(*chunk); | 225 | chunkmem.size = sizeof(*chunk); |
| 232 | chunkmem.va = kzalloc(chunkmem.size, GFP_KERNEL); | 226 | chunkmem.va = kzalloc(chunkmem.size, GFP_KERNEL); |
| 233 | if (!chunkmem.va) | 227 | if (!chunkmem.va) |
| 234 | return IRDMA_ERR_NO_MEMORY; | 228 | return -ENOMEM; |
| 235 | 229 | ||
| 236 | chunk = chunkmem.va; | 230 | chunk = chunkmem.va; |
| 237 | chunk->chunkmem = chunkmem; | 231 | chunk->chunkmem = chunkmem; |
| @@ -337,9 +331,8 @@ static void free_lvl2(struct irdma_hmc_pble_rsrc *pble_rsrc, · 99 unmodified lines | |||
| 337 | * @pble_rsrc: pble resource management | 331 | * @pble_rsrc: pble resource management |
| 338 | * @palloc: level 2 pble allocation | 332 | * @palloc: level 2 pble allocation |
| 339 | */ | 333 | */ |
| 340 | static enum irdma_status_code | 334 | static int get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 341 | get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, | 335 | struct irdma_pble_alloc *palloc) |
| 342 | struct irdma_pble_alloc *palloc) | ||
| 343 | { | 336 | { |
| 344 | u32 lf4k, lflast, total, i; | 337 | u32 lf4k, lflast, total, i; |
| 345 | u32 pblcnt = PBLE_PER_PAGE; | 338 | u32 pblcnt = PBLE_PER_PAGE; |
| @@ -347,7 +340,7 @@ get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 1 unmodified line | |||
| 347 | struct irdma_pble_level2 *lvl2 = &palloc->level2; | 340 | struct irdma_pble_level2 *lvl2 = &palloc->level2; |
| 348 | struct irdma_pble_info *root = &lvl2->root; | 341 | struct irdma_pble_info *root = &lvl2->root; |
| 349 | struct irdma_pble_info *leaf; | 342 | struct irdma_pble_info *leaf; |
| 350 | enum irdma_status_code ret_code; | 343 | int ret_code; |
| 351 | u64 fpm_addr; | 344 | u64 fpm_addr; |
| 352 | 345 | ||
| 353 | /* number of full 512 (4K) leafs) */ | 346 | /* number of full 512 (4K) leafs) */ |
| @@ -359,7 +352,7 @@ get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 5 unmodified lines | |||
| 359 | lvl2->leafmem.size = (sizeof(*leaf) * total); | 352 | lvl2->leafmem.size = (sizeof(*leaf) * total); |
| 360 | lvl2->leafmem.va = kzalloc(lvl2->leafmem.size, GFP_KERNEL); | 353 | lvl2->leafmem.va = kzalloc(lvl2->leafmem.size, GFP_KERNEL); |
| 361 | if (!lvl2->leafmem.va) | 354 | if (!lvl2->leafmem.va) |
| 362 | return IRDMA_ERR_NO_MEMORY; | 355 | return -ENOMEM; |
| 363 | 356 | ||
| 364 | lvl2->leaf = lvl2->leafmem.va; | 357 | lvl2->leaf = lvl2->leafmem.va; |
| 365 | leaf = lvl2->leaf; | 358 | leaf = lvl2->leaf; |
| @@ -368,7 +361,7 @@ get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 2 unmodified lines | |||
| 368 | if (ret_code) { | 361 | if (ret_code) { |
| 369 | kfree(lvl2->leafmem.va); | 362 | kfree(lvl2->leafmem.va); |
| 370 | lvl2->leaf = NULL; | 363 | lvl2->leaf = NULL; |
| 371 | return IRDMA_ERR_NO_MEMORY; | 364 | return -ENOMEM; |
| 372 | } | 365 | } |
| 373 | 366 | ||
| 374 | root->idx = fpm_to_idx(pble_rsrc, fpm_addr); | 367 | root->idx = fpm_to_idx(pble_rsrc, fpm_addr); |
| @@ -397,7 +390,7 @@ get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 22 unmodified lines | |||
| 397 | error: | 390 | error: |
| 398 | free_lvl2(pble_rsrc, palloc); | 391 | free_lvl2(pble_rsrc, palloc); |
| 399 | 392 | ||
| 400 | return IRDMA_ERR_NO_MEMORY; | 393 | return -ENOMEM; |
| 401 | } | 394 | } |
| 402 | 395 | ||
| 403 | /** | 396 | /** |
| @@ -405,11 +398,10 @@ error: · 1 unmodified line | |||
| 405 | * @pble_rsrc: pble resource management | 398 | * @pble_rsrc: pble resource management |
| 406 | * @palloc: level 1 pble allocation | 399 | * @palloc: level 1 pble allocation |
| 407 | */ | 400 | */ |
| 408 | static enum irdma_status_code | 401 | static int get_lvl1_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 409 | get_lvl1_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, | 402 | struct irdma_pble_alloc *palloc) |
| 410 | struct irdma_pble_alloc *palloc) | ||
| 411 | { | 403 | { |
| 412 | enum irdma_status_code ret_code; | 404 | int ret_code; |
| 413 | u64 fpm_addr; | 405 | u64 fpm_addr; |
| 414 | struct irdma_pble_info *lvl1 = &palloc->level1; | 406 | struct irdma_pble_info *lvl1 = &palloc->level1; |
| 415 | 407 | ||
| @@ -417,7 +409,7 @@ get_lvl1_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 1 unmodified line | |||
| 417 | palloc->total_cnt << 3, &lvl1->addr, | 409 | palloc->total_cnt << 3, &lvl1->addr, |
| 418 | &fpm_addr); | 410 | &fpm_addr); |
| 419 | if (ret_code) | 411 | if (ret_code) |
| 420 | return IRDMA_ERR_NO_MEMORY; | 412 | return -ENOMEM; |
| 421 | 413 | ||
| 422 | palloc->level = PBLE_LEVEL_1; | 414 | palloc->level = PBLE_LEVEL_1; |
| 423 | lvl1->idx = fpm_to_idx(pble_rsrc, fpm_addr); | 415 | lvl1->idx = fpm_to_idx(pble_rsrc, fpm_addr); |
| @@ -433,11 +425,10 @@ get_lvl1_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 9 unmodified lines | |||
| 433 | * @palloc: contains all inforamtion regarding pble (idx + pble addr) | 425 | * @palloc: contains all inforamtion regarding pble (idx + pble addr) |
| 434 | * @level1_only: flag for a level 1 PBLE | 426 | * @level1_only: flag for a level 1 PBLE |
| 435 | */ | 427 | */ |
| 436 | static enum irdma_status_code | 428 | static int get_lvl1_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 437 | get_lvl1_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, | 429 | struct irdma_pble_alloc *palloc, bool level1_only) |
| 438 | struct irdma_pble_alloc *palloc, bool level1_only) | ||
| 439 | { | 430 | { |
| 440 | enum irdma_status_code status = 0; | 431 | int status = 0; |
| 441 | 432 | ||
| 442 | status = get_lvl1_pble(pble_rsrc, palloc); | 433 | status = get_lvl1_pble(pble_rsrc, palloc); |
| 443 | if (!status || level1_only || palloc->total_cnt <= PBLE_PER_PAGE) | 434 | if (!status || level1_only || palloc->total_cnt <= PBLE_PER_PAGE) |
| @@ -455,11 +446,11 @@ get_lvl1_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, · 11 unmodified lines | |||
| 455 | * @pble_cnt: #of pbles requested | 446 | * @pble_cnt: #of pbles requested |
| 456 | * @level1_only: true if only pble level 1 to acquire | 447 | * @level1_only: true if only pble level 1 to acquire |
| 457 | */ | 448 | */ |
| 458 | enum irdma_status_code irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, | 449 | int irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 459 | struct irdma_pble_alloc *palloc, | 450 | struct irdma_pble_alloc *palloc, u32 pble_cnt, |
| 460 | u32 pble_cnt, bool level1_only) | 451 | bool level1_only) |
| 461 | { | 452 | { |
| 462 | enum irdma_status_code status = 0; | 453 | int status = 0; |
| 463 | int max_sds = 0; | 454 | int max_sds = 0; |
| 464 | int i; | 455 | int i; |
| 465 | 456 | ||
| @@ -108,20 +108,18 @@ struct irdma_hmc_pble_rsrc { · 107 unmodified lines | |||
| 108 | }; | 108 | }; |
| 109 | 109 | ||
| 110 | void irdma_destroy_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); | 110 | void irdma_destroy_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc); |
| 111 | enum irdma_status_code | 111 | int irdma_hmc_init_pble(struct irdma_sc_dev *dev, |
| 112 | irdma_hmc_init_pble(struct irdma_sc_dev *dev, | 112 | struct irdma_hmc_pble_rsrc *pble_rsrc); |
| 113 | struct irdma_hmc_pble_rsrc *pble_rsrc); | ||
| 114 | void irdma_free_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, | 113 | void irdma_free_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 115 | struct irdma_pble_alloc *palloc); | 114 | struct irdma_pble_alloc *palloc); |
| 116 | enum irdma_status_code irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, | 115 | int irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 117 | struct irdma_pble_alloc *palloc, | 116 | struct irdma_pble_alloc *palloc, u32 pble_cnt, |
| 118 | u32 pble_cnt, bool level1_only); | 117 | bool level1_only); |
| 119 | enum irdma_status_code irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, | 118 | int irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, |
| 120 | struct irdma_chunk *pchunk); | 119 | struct irdma_chunk *pchunk); |
| 121 | enum irdma_status_code | 120 | int irdma_prm_get_pbles(struct irdma_pble_prm *pprm, |
| 122 | irdma_prm_get_pbles(struct irdma_pble_prm *pprm, | 121 | struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, |
| 123 | struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, | 122 | u64 **vaddr, u64 *fpm_addr); |
| 124 | u64 **vaddr, u64 *fpm_addr); | ||
| 125 | void irdma_prm_return_pbles(struct irdma_pble_prm *pprm, | 123 | void irdma_prm_return_pbles(struct irdma_pble_prm *pprm, |
| 126 | struct irdma_pble_chunkinfo *chunkinfo); | 124 | struct irdma_pble_chunkinfo *chunkinfo); |
| 127 | void irdma_pble_acquire_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, | 125 | void irdma_pble_acquire_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| @@ -129,7 +127,6 @@ void irdma_pble_acquire_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, · 1 unmodified line | |||
| 129 | void irdma_pble_release_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, | 127 | void irdma_pble_release_lock(struct irdma_hmc_pble_rsrc *pble_rsrc, |
| 130 | unsigned long *flags); | 128 | unsigned long *flags); |
| 131 | void irdma_pble_free_paged_mem(struct irdma_chunk *chunk); | 129 | void irdma_pble_free_paged_mem(struct irdma_chunk *chunk); |
| 132 | enum irdma_status_code irdma_pble_get_paged_mem(struct irdma_chunk *chunk, | 130 | int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt); |
| 133 | u32 pg_cnt); | ||
| 134 | void irdma_prm_rem_bitmapmem(struct irdma_hw *hw, struct irdma_chunk *chunk); | 131 | void irdma_prm_rem_bitmapmem(struct irdma_hw *hw, struct irdma_chunk *chunk); |
| 135 | #endif /* IRDMA_PBLE_H */ | 132 | #endif /* IRDMA_PBLE_H */ |
| @@ -12,58 +12,51 @@ · 11 unmodified lines | |||
| 12 | #define CQP_TIMEOUT_THRESHOLD 500 | 12 | #define CQP_TIMEOUT_THRESHOLD 500 |
| 13 | 13 | ||
| 14 | /* init operations */ | 14 | /* init operations */ |
| 15 | enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver, | 15 | int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev, |
| 16 | struct irdma_sc_dev *dev, | 16 | struct irdma_device_init_info *info); |
| 17 | struct irdma_device_init_info *info); | ||
| 18 | void irdma_sc_rt_init(struct irdma_sc_dev *dev); | 17 | void irdma_sc_rt_init(struct irdma_sc_dev *dev); |
| 19 | void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp); | 18 | void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp); |
| 20 | __le64 *irdma_sc_cqp_get_next_send_wqe(struct irdma_sc_cqp *cqp, u64 scratch); | 19 | __le64 *irdma_sc_cqp_get_next_send_wqe(struct irdma_sc_cqp *cqp, u64 scratch); |
| 21 | enum irdma_status_code | 20 | int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, |
| 22 | irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, | 21 | struct irdma_fast_reg_stag_info *info, |
| 23 | struct irdma_fast_reg_stag_info *info, bool post_sq); | 22 | bool post_sq); |
| 24 | /* HMC/FPM functions */ | 23 | /* HMC/FPM functions */ |
| 25 | enum irdma_status_code irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, | 24 | int irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, u8 hmc_fn_id); |
| 26 | u8 hmc_fn_id); | ||
| 27 | /* stats misc */ | 25 | /* stats misc */ |
| 28 | enum irdma_status_code | 26 | int irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, |
| 29 | irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, | 27 | struct irdma_vsi_pestat *pestat, bool wait); |
| 30 | struct irdma_vsi_pestat *pestat, bool wait); | ||
| 31 | void irdma_cqp_gather_stats_gen1(struct irdma_sc_dev *dev, | 28 | void irdma_cqp_gather_stats_gen1(struct irdma_sc_dev *dev, |
| 32 | struct irdma_vsi_pestat *pestat); | 29 | struct irdma_vsi_pestat *pestat); |
| 33 | void irdma_hw_stats_read_all(struct irdma_vsi_pestat *stats, | 30 | void irdma_hw_stats_read_all(struct irdma_vsi_pestat *stats, |
| 34 | struct irdma_dev_hw_stats *stats_values, | 31 | struct irdma_dev_hw_stats *stats_values, |
| 35 | u64 *hw_stats_regs_32, u64 *hw_stats_regs_64, | 32 | u64 *hw_stats_regs_32, u64 *hw_stats_regs_64, |
| 36 | u8 hw_rev); | 33 | u8 hw_rev); |
| 37 | enum irdma_status_code | 34 | int irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, |
| 38 | irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, | 35 | struct irdma_ws_node_info *node_info); |
| 39 | struct irdma_ws_node_info *node_info); | 36 | int irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_ceq *sc_ceq, |
| 40 | enum irdma_status_code irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, | 37 | u8 op); |
| 41 | struct irdma_sc_ceq *sc_ceq, u8 op); | 38 | int irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_aeq *sc_aeq, |
| 42 | enum irdma_status_code irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, | 39 | u8 op); |
| 43 | struct irdma_sc_aeq *sc_aeq, u8 op); | 40 | int irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, |
| 44 | enum irdma_status_code | 41 | struct irdma_stats_inst_info *stats_info); |
| 45 | irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, | ||
| 46 | struct irdma_stats_inst_info *stats_info); | ||
| 47 | u16 irdma_alloc_ws_node_id(struct irdma_sc_dev *dev); | 42 | u16 irdma_alloc_ws_node_id(struct irdma_sc_dev *dev); |
| 48 | void irdma_free_ws_node_id(struct irdma_sc_dev *dev, u16 node_id); | 43 | void irdma_free_ws_node_id(struct irdma_sc_dev *dev, u16 node_id); |
| 49 | void irdma_update_stats(struct irdma_dev_hw_stats *hw_stats, | 44 | void irdma_update_stats(struct irdma_dev_hw_stats *hw_stats, |
| 50 | struct irdma_gather_stats *gather_stats, | 45 | struct irdma_gather_stats *gather_stats, |
| 51 | struct irdma_gather_stats *last_gather_stats); | 46 | struct irdma_gather_stats *last_gather_stats); |
| 52 | /* vsi functions */ | 47 | /* vsi functions */ |
| 53 | enum irdma_status_code irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, | 48 | int irdma_vsi_stats_init(struct irdma_sc_vsi *vsi, |
| 54 | struct irdma_vsi_stats_info *info); | 49 | struct irdma_vsi_stats_info *info); |
| 55 | void irdma_vsi_stats_free(struct irdma_sc_vsi *vsi); | 50 | void irdma_vsi_stats_free(struct irdma_sc_vsi *vsi); |
| 56 | void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, | 51 | void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi, |
| 57 | struct irdma_vsi_init_info *info); | 52 | struct irdma_vsi_init_info *info); |
| 58 | enum irdma_status_code irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, | 53 | int irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq); |
| 59 | struct irdma_sc_cq *cq); | ||
| 60 | void irdma_sc_remove_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq); | 54 | void irdma_sc_remove_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq); |
| 61 | /* misc L2 param change functions */ | 55 | /* misc L2 param change functions */ |
| 62 | void irdma_change_l2params(struct irdma_sc_vsi *vsi, | 56 | void irdma_change_l2params(struct irdma_sc_vsi *vsi, |
| 63 | struct irdma_l2params *l2params); | 57 | struct irdma_l2params *l2params); |
| 64 | void irdma_sc_suspend_resume_qps(struct irdma_sc_vsi *vsi, u8 suspend); | 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, | 59 | int irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, u8 cmd); |
| 66 | u8 cmd); | ||
| 67 | void irdma_qp_add_qos(struct irdma_sc_qp *qp); | 60 | void irdma_qp_add_qos(struct irdma_sc_qp *qp); |
| 68 | void irdma_qp_rem_qos(struct irdma_sc_qp *qp); | 61 | void irdma_qp_rem_qos(struct irdma_sc_qp *qp); |
| 69 | struct irdma_sc_qp *irdma_get_qp_from_list(struct list_head *head, | 62 | struct irdma_sc_qp *irdma_get_qp_from_list(struct list_head *head, |
| @@ -81,31 +74,26 @@ void irdma_terminate_received(struct irdma_sc_qp *qp, · 11 unmodified lines | |||
| 81 | /* misc */ | 74 | /* misc */ |
| 82 | u8 irdma_get_encoded_wqe_size(u32 wqsize, enum irdma_queue_type queue_type); | 75 | u8 irdma_get_encoded_wqe_size(u32 wqsize, enum irdma_queue_type queue_type); |
| 83 | void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp); | 76 | void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp); |
| 84 | enum irdma_status_code | 77 | int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, |
| 85 | irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, | 78 | u8 hmc_fn_id, bool post_sq, |
| 86 | u8 hmc_fn_id, bool post_sq, | 79 | bool poll_registers); |
| 87 | bool poll_registers); | 80 | int irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count); |
| 88 | enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev, | 81 | int irdma_get_rdma_features(struct irdma_sc_dev *dev); |
| 89 | u32 qp_count); | ||
| 90 | enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev); | ||
| 91 | void free_sd_mem(struct irdma_sc_dev *dev); | 82 | void free_sd_mem(struct irdma_sc_dev *dev); |
| 92 | enum irdma_status_code irdma_process_cqp_cmd(struct irdma_sc_dev *dev, | 83 | int irdma_process_cqp_cmd(struct irdma_sc_dev *dev, |
| 93 | struct cqp_cmds_info *pcmdinfo); | 84 | struct cqp_cmds_info *pcmdinfo); |
| 94 | enum irdma_status_code irdma_process_bh(struct irdma_sc_dev *dev); | 85 | int irdma_process_bh(struct irdma_sc_dev *dev); |
| 95 | enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, | 86 | int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, |
| 96 | struct irdma_update_sds_info *info); | 87 | struct irdma_update_sds_info *info); |
| 97 | enum irdma_status_code | 88 | int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, |
| 98 | irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, | 89 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); |
| 99 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); | 90 | int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, |
| 100 | enum irdma_status_code | 91 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); |
| 101 | irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, | 92 | int irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, |
| 102 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id); | 93 | struct irdma_dma_mem *mem); |
| 103 | enum irdma_status_code irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev, | 94 | int irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, |
| 104 | struct irdma_dma_mem *mem); | 95 | struct irdma_hmc_fcn_info *hmcfcninfo, |
| 105 | enum irdma_status_code | 96 | u16 *pmf_idx); |
| 106 | irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev, | ||
| 107 | struct irdma_hmc_fcn_info *hmcfcninfo, | ||
| 108 | u16 *pmf_idx); | ||
| 109 | void irdma_add_dev_ref(struct irdma_sc_dev *dev); | 97 | void irdma_add_dev_ref(struct irdma_sc_dev *dev); |
| 110 | void irdma_put_dev_ref(struct irdma_sc_dev *dev); | 98 | void irdma_put_dev_ref(struct irdma_sc_dev *dev); |
| 111 | void *irdma_remove_cqp_head(struct irdma_sc_dev *dev); | 99 | void *irdma_remove_cqp_head(struct irdma_sc_dev *dev); |
| @@ -1,7 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB | 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB |
| 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ | 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ |
| 3 | #include "osdep.h" | 3 | #include "osdep.h" |
| 4 | #include "status.h" | ||
| 5 | #include "hmc.h" | 4 | #include "hmc.h" |
| 6 | #include "defs.h" | 5 | #include "defs.h" |
| 7 | #include "type.h" | 6 | #include "type.h" |
| @@ -114,8 +113,7 @@ static void irdma_puda_post_recvbuf(struct irdma_puda_rsrc *rsrc, u32 wqe_idx, · 106 unmodified lines | |||
| 114 | * @rsrc: resource to use for buffer | 113 | * @rsrc: resource to use for buffer |
| 115 | * @initial: flag if during init time | 114 | * @initial: flag if during init time |
| 116 | */ | 115 | */ |
| 117 | static enum irdma_status_code | 116 | static int irdma_puda_replenish_rq(struct irdma_puda_rsrc *rsrc, bool initial) |
| 118 | irdma_puda_replenish_rq(struct irdma_puda_rsrc *rsrc, bool initial) | ||
| 119 | { | 117 | { |
| 120 | u32 i; | 118 | u32 i; |
| 121 | u32 invalid_cnt = rsrc->rxq_invalid_cnt; | 119 | u32 invalid_cnt = rsrc->rxq_invalid_cnt; |
| @@ -124,7 +122,7 @@ irdma_puda_replenish_rq(struct irdma_puda_rsrc *rsrc, bool initial) · 2 unmodified lines | |||
| 124 | for (i = 0; i < invalid_cnt; i++) { | 122 | for (i = 0; i < invalid_cnt; i++) { |
| 125 | buf = irdma_puda_get_bufpool(rsrc); | 123 | buf = irdma_puda_get_bufpool(rsrc); |
| 126 | if (!buf) | 124 | if (!buf) |
| 127 | return IRDMA_ERR_list_empty; | 125 | return -ENOBUFS; |
| 128 | irdma_puda_post_recvbuf(rsrc, rsrc->rx_wqe_idx, buf, initial); | 126 | irdma_puda_post_recvbuf(rsrc, rsrc->rx_wqe_idx, buf, initial); |
| 129 | rsrc->rx_wqe_idx = ((rsrc->rx_wqe_idx + 1) % rsrc->rq_size); | 127 | rsrc->rx_wqe_idx = ((rsrc->rx_wqe_idx + 1) % rsrc->rq_size); |
| 130 | rsrc->rxq_invalid_cnt--; | 128 | rsrc->rxq_invalid_cnt--; |
| @@ -194,7 +192,7 @@ static __le64 *irdma_puda_get_next_send_wqe(struct irdma_qp_uk *qp, · 63 unmodified lines | |||
| 194 | u32 *wqe_idx) | 192 | u32 *wqe_idx) |
| 195 | { | 193 | { |
| 196 | __le64 *wqe = NULL; | 194 | __le64 *wqe = NULL; |
| 197 | enum irdma_status_code ret_code = 0; | 195 | int ret_code = 0; |
| 198 | 196 | ||
| 199 | *wqe_idx = IRDMA_RING_CURRENT_HEAD(qp->sq_ring); | 197 | *wqe_idx = IRDMA_RING_CURRENT_HEAD(qp->sq_ring); |
| 200 | if (!*wqe_idx) | 198 | if (!*wqe_idx) |
| @@ -213,8 +211,8 @@ static __le64 *irdma_puda_get_next_send_wqe(struct irdma_qp_uk *qp, · 12 unmodified lines | |||
| 213 | * @cq: cq for poll | 211 | * @cq: cq for poll |
| 214 | * @info: info return for successful completion | 212 | * @info: info return for successful completion |
| 215 | */ | 213 | */ |
| 216 | static enum irdma_status_code | 214 | static int irdma_puda_poll_info(struct irdma_sc_cq *cq, |
| 217 | irdma_puda_poll_info(struct irdma_sc_cq *cq, struct irdma_puda_cmpl_info *info) | 215 | struct irdma_puda_cmpl_info *info) |
| 218 | { | 216 | { |
| 219 | struct irdma_cq_uk *cq_uk = &cq->cq_uk; | 217 | struct irdma_cq_uk *cq_uk = &cq->cq_uk; |
| 220 | u64 qword0, qword2, qword3, qword6; | 218 | u64 qword0, qword2, qword3, qword6; |
| @@ -233,7 +231,7 @@ irdma_puda_poll_info(struct irdma_sc_cq *cq, struct irdma_puda_cmpl_info *info) · 12 unmodified lines | |||
| 233 | get_64bit_val(cqe, 24, &qword3); | 231 | get_64bit_val(cqe, 24, &qword3); |
| 234 | valid_bit = (bool)FIELD_GET(IRDMA_CQ_VALID, qword3); | 232 | valid_bit = (bool)FIELD_GET(IRDMA_CQ_VALID, qword3); |
| 235 | if (valid_bit != cq_uk->polarity) | 233 | if (valid_bit != cq_uk->polarity) |
| 236 | return IRDMA_ERR_Q_EMPTY; | 234 | return -ENOENT; |
| 237 | 235 | ||
| 238 | if (cq->dev->hw_attrs.uk_attrs.hw_rev >= IRDMA_GEN_2) | 236 | if (cq->dev->hw_attrs.uk_attrs.hw_rev >= IRDMA_GEN_2) |
| 239 | ext_valid = (bool)FIELD_GET(IRDMA_CQ_EXTCQE, qword3); | 237 | ext_valid = (bool)FIELD_GET(IRDMA_CQ_EXTCQE, qword3); |
| @@ -246,7 +244,7 @@ irdma_puda_poll_info(struct irdma_sc_cq *cq, struct irdma_puda_cmpl_info *info) · 6 unmodified lines | |||
| 246 | if (!peek_head) | 244 | if (!peek_head) |
| 247 | polarity ^= 1; | 245 | polarity ^= 1; |
| 248 | if (polarity != cq_uk->polarity) | 246 | if (polarity != cq_uk->polarity) |
| 249 | return IRDMA_ERR_Q_EMPTY; | 247 | return -ENOENT; |
| 250 | 248 | ||
| 251 | IRDMA_RING_MOVE_HEAD_NOCHECK(cq_uk->cq_ring); | 249 | IRDMA_RING_MOVE_HEAD_NOCHECK(cq_uk->cq_ring); |
| 252 | if (!IRDMA_RING_CURRENT_HEAD(cq_uk->cq_ring)) | 250 | if (!IRDMA_RING_CURRENT_HEAD(cq_uk->cq_ring)) |
| @@ -267,7 +265,7 @@ irdma_puda_poll_info(struct irdma_sc_cq *cq, struct irdma_puda_cmpl_info *info) · 14 unmodified lines | |||
| 267 | major_err = (u32)(FIELD_GET(IRDMA_CQ_MAJERR, qword3)); | 265 | major_err = (u32)(FIELD_GET(IRDMA_CQ_MAJERR, qword3)); |
| 268 | minor_err = (u32)(FIELD_GET(IRDMA_CQ_MINERR, qword3)); | 266 | minor_err = (u32)(FIELD_GET(IRDMA_CQ_MINERR, qword3)); |
| 269 | info->compl_error = major_err << 16 | minor_err; | 267 | info->compl_error = major_err << 16 | minor_err; |
| 270 | return IRDMA_ERR_CQ_COMPL_ERROR; | 268 | return -EIO; |
| 271 | } | 269 | } |
| 272 | 270 | ||
| 273 | get_64bit_val(cqe, 0, &qword0); | 271 | get_64bit_val(cqe, 0, &qword0); |
| @@ -319,14 +317,13 @@ irdma_puda_poll_info(struct irdma_sc_cq *cq, struct irdma_puda_cmpl_info *info) · 45 unmodified lines | |||
| 319 | * @cq: cq getting interrupt | 317 | * @cq: cq getting interrupt |
| 320 | * @compl_err: return any completion err | 318 | * @compl_err: return any completion err |
| 321 | */ | 319 | */ |
| 322 | enum irdma_status_code irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, | 320 | int irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq, |
| 323 | struct irdma_sc_cq *cq, | 321 | u32 *compl_err) |
| 324 | u32 *compl_err) | ||
| 325 | { | 322 | { |
| 326 | struct irdma_qp_uk *qp; | 323 | struct irdma_qp_uk *qp; |
| 327 | struct irdma_cq_uk *cq_uk = &cq->cq_uk; | 324 | struct irdma_cq_uk *cq_uk = &cq->cq_uk; |
| 328 | struct irdma_puda_cmpl_info info = {}; | 325 | struct irdma_puda_cmpl_info info = {}; |
| 329 | enum irdma_status_code ret = 0; | 326 | int ret = 0; |
| 330 | struct irdma_puda_buf *buf; | 327 | struct irdma_puda_buf *buf; |
| 331 | struct irdma_puda_rsrc *rsrc; | 328 | struct irdma_puda_rsrc *rsrc; |
| 332 | u8 cq_type = cq->cq_type; | 329 | u8 cq_type = cq->cq_type; |
| @@ -337,24 +334,24 @@ enum irdma_status_code irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, · 4 unmodified lines | |||
| 337 | cq->vsi->ieq; | 334 | cq->vsi->ieq; |
| 338 | } else { | 335 | } else { |
| 339 | ibdev_dbg(to_ibdev(dev), "PUDA: qp_type error\n"); | 336 | ibdev_dbg(to_ibdev(dev), "PUDA: qp_type error\n"); |
| 340 | return IRDMA_ERR_BAD_PTR; | 337 | return -EINVAL; |
| 341 | } | 338 | } |
| 342 | 339 | ||
| 343 | ret = irdma_puda_poll_info(cq, &info); | 340 | ret = irdma_puda_poll_info(cq, &info); |
| 344 | *compl_err = info.compl_error; | 341 | *compl_err = info.compl_error; |
| 345 | if (ret == IRDMA_ERR_Q_EMPTY) | 342 | if (ret == -ENOENT) |
| 346 | return ret; | 343 | return ret; |
| 347 | if (ret) | 344 | if (ret) |
| 348 | goto done; | 345 | goto done; |
| 349 | 346 | ||
| 350 | qp = info.qp; | 347 | qp = info.qp; |
| 351 | if (!qp || !rsrc) { | 348 | if (!qp || !rsrc) { |
| 352 | ret = IRDMA_ERR_BAD_PTR; | 349 | ret = -EFAULT; |
| 353 | goto done; | 350 | goto done; |
| 354 | } | 351 | } |
| 355 | 352 | ||
| 356 | if (qp->qp_id != rsrc->qp_id) { | 353 | if (qp->qp_id != rsrc->qp_id) { |
| 357 | ret = IRDMA_ERR_BAD_PTR; | 354 | ret = -EFAULT; |
| 358 | goto done; | 355 | goto done; |
| 359 | } | 356 | } |
| 360 | 357 | ||
| @@ -422,8 +419,7 @@ done: · 61 unmodified lines | |||
| 422 | * @qp: puda qp for send | 419 | * @qp: puda qp for send |
| 423 | * @info: buffer information for transmit | 420 | * @info: buffer information for transmit |
| 424 | */ | 421 | */ |
| 425 | enum irdma_status_code irdma_puda_send(struct irdma_sc_qp *qp, | 422 | int irdma_puda_send(struct irdma_sc_qp *qp, struct irdma_puda_send_info *info) |
| 426 | struct irdma_puda_send_info *info) | ||
| 427 | { | 423 | { |
| 428 | __le64 *wqe; | 424 | __le64 *wqe; |
| 429 | u32 iplen, l4len; | 425 | u32 iplen, l4len; |
| @@ -443,7 +439,7 @@ enum irdma_status_code irdma_puda_send(struct irdma_sc_qp *qp, · 13 unmodified lines | |||
| 443 | 439 | ||
| 444 | wqe = irdma_puda_get_next_send_wqe(&qp->qp_uk, &wqe_idx); | 440 | wqe = irdma_puda_get_next_send_wqe(&qp->qp_uk, &wqe_idx); |
| 445 | if (!wqe) | 441 | if (!wqe) |
| 446 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 442 | return -ENOMEM; |
| 447 | 443 | ||
| 448 | qp->qp_uk.sq_wrtrk_array[wqe_idx].wrid = (uintptr_t)info->scratch; | 444 | qp->qp_uk.sq_wrtrk_array[wqe_idx].wrid = (uintptr_t)info->scratch; |
| 449 | /* Third line of WQE descriptor */ | 445 | /* Third line of WQE descriptor */ |
| @@ -503,7 +499,7 @@ void irdma_puda_send_buf(struct irdma_puda_rsrc *rsrc, · 53 unmodified lines | |||
| 503 | struct irdma_puda_buf *buf) | 499 | struct irdma_puda_buf *buf) |
| 504 | { | 500 | { |
| 505 | struct irdma_puda_send_info info; | 501 | struct irdma_puda_send_info info; |
| 506 | enum irdma_status_code ret = 0; | 502 | int ret = 0; |
| 507 | unsigned long flags; | 503 | unsigned long flags; |
| 508 | 504 | ||
| 509 | spin_lock_irqsave(&rsrc->bufpool_lock, flags); | 505 | spin_lock_irqsave(&rsrc->bufpool_lock, flags); |
| @@ -603,19 +599,18 @@ static void irdma_puda_qp_setctx(struct irdma_puda_rsrc *rsrc) · 93 unmodified lines | |||
| 603 | * @dev: Device | 599 | * @dev: Device |
| 604 | * @qp: Resource qp | 600 | * @qp: Resource qp |
| 605 | */ | 601 | */ |
| 606 | static enum irdma_status_code irdma_puda_qp_wqe(struct irdma_sc_dev *dev, | 602 | static int irdma_puda_qp_wqe(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) |
| 607 | struct irdma_sc_qp *qp) | ||
| 608 | { | 603 | { |
| 609 | struct irdma_sc_cqp *cqp; | 604 | struct irdma_sc_cqp *cqp; |
| 610 | __le64 *wqe; | 605 | __le64 *wqe; |
| 611 | u64 hdr; | 606 | u64 hdr; |
| 612 | struct irdma_ccq_cqe_info compl_info; | 607 | struct irdma_ccq_cqe_info compl_info; |
| 613 | enum irdma_status_code status = 0; | 608 | int status = 0; |
| 614 | 609 | ||
| 615 | cqp = dev->cqp; | 610 | cqp = dev->cqp; |
| 616 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, 0); | 611 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, 0); |
| 617 | if (!wqe) | 612 | if (!wqe) |
| 618 | return IRDMA_ERR_RING_FULL; | 613 | return -ENOMEM; |
| 619 | 614 | ||
| 620 | set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); | 615 | set_64bit_val(wqe, 16, qp->hw_host_ctx_pa); |
| 621 | set_64bit_val(wqe, 40, qp->shadow_area_pa); | 616 | set_64bit_val(wqe, 40, qp->shadow_area_pa); |
| @@ -643,11 +638,11 @@ static enum irdma_status_code irdma_puda_qp_wqe(struct irdma_sc_dev *dev, · 21 unmodified lines | |||
| 643 | * irdma_puda_qp_create - create qp for resource | 638 | * irdma_puda_qp_create - create qp for resource |
| 644 | * @rsrc: resource to use for buffer | 639 | * @rsrc: resource to use for buffer |
| 645 | */ | 640 | */ |
| 646 | static enum irdma_status_code irdma_puda_qp_create(struct irdma_puda_rsrc *rsrc) | 641 | static int irdma_puda_qp_create(struct irdma_puda_rsrc *rsrc) |
| 647 | { | 642 | { |
| 648 | struct irdma_sc_qp *qp = &rsrc->qp; | 643 | struct irdma_sc_qp *qp = &rsrc->qp; |
| 649 | struct irdma_qp_uk *ukqp = &qp->qp_uk; | 644 | struct irdma_qp_uk *ukqp = &qp->qp_uk; |
| 650 | enum irdma_status_code ret = 0; | 645 | int ret = 0; |
| 651 | u32 sq_size, rq_size; | 646 | u32 sq_size, rq_size; |
| 652 | struct irdma_dma_mem *mem; | 647 | struct irdma_dma_mem *mem; |
| 653 | 648 | ||
| @@ -659,7 +654,7 @@ static enum irdma_status_code irdma_puda_qp_create(struct irdma_puda_rsrc *rsrc) · 5 unmodified lines | |||
| 659 | rsrc->qpmem.size, &rsrc->qpmem.pa, | 654 | rsrc->qpmem.size, &rsrc->qpmem.pa, |
| 660 | GFP_KERNEL); | 655 | GFP_KERNEL); |
| 661 | if (!rsrc->qpmem.va) | 656 | if (!rsrc->qpmem.va) |
| 662 | return IRDMA_ERR_NO_MEMORY; | 657 | return -ENOMEM; |
| 663 | 658 | ||
| 664 | mem = &rsrc->qpmem; | 659 | mem = &rsrc->qpmem; |
| 665 | memset(mem->va, 0, rsrc->qpmem.size); | 660 | memset(mem->va, 0, rsrc->qpmem.size); |
| @@ -722,19 +717,18 @@ static enum irdma_status_code irdma_puda_qp_create(struct irdma_puda_rsrc *rsrc) · 56 unmodified lines | |||
| 722 | * @dev: Device | 717 | * @dev: Device |
| 723 | * @cq: resource for cq | 718 | * @cq: resource for cq |
| 724 | */ | 719 | */ |
| 725 | static enum irdma_status_code irdma_puda_cq_wqe(struct irdma_sc_dev *dev, | 720 | static int irdma_puda_cq_wqe(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq) |
| 726 | struct irdma_sc_cq *cq) | ||
| 727 | { | 721 | { |
| 728 | __le64 *wqe; | 722 | __le64 *wqe; |
| 729 | struct irdma_sc_cqp *cqp; | 723 | struct irdma_sc_cqp *cqp; |
| 730 | u64 hdr; | 724 | u64 hdr; |
| 731 | struct irdma_ccq_cqe_info compl_info; | 725 | struct irdma_ccq_cqe_info compl_info; |
| 732 | enum irdma_status_code status = 0; | 726 | int status = 0; |
| 733 | 727 | ||
| 734 | cqp = dev->cqp; | 728 | cqp = dev->cqp; |
| 735 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, 0); | 729 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, 0); |
| 736 | if (!wqe) | 730 | if (!wqe) |
| 737 | return IRDMA_ERR_RING_FULL; | 731 | return -ENOMEM; |
| 738 | 732 | ||
| 739 | set_64bit_val(wqe, 0, cq->cq_uk.cq_size); | 733 | set_64bit_val(wqe, 0, cq->cq_uk.cq_size); |
| 740 | set_64bit_val(wqe, 8, (uintptr_t)cq >> 1); | 734 | set_64bit_val(wqe, 8, (uintptr_t)cq >> 1); |
| @@ -775,11 +769,11 @@ static enum irdma_status_code irdma_puda_cq_wqe(struct irdma_sc_dev *dev, · 34 unmodified lines | |||
| 775 | * irdma_puda_cq_create - create cq for resource | 769 | * irdma_puda_cq_create - create cq for resource |
| 776 | * @rsrc: resource for which cq to create | 770 | * @rsrc: resource for which cq to create |
| 777 | */ | 771 | */ |
| 778 | static enum irdma_status_code irdma_puda_cq_create(struct irdma_puda_rsrc *rsrc) | 772 | static int irdma_puda_cq_create(struct irdma_puda_rsrc *rsrc) |
| 779 | { | 773 | { |
| 780 | struct irdma_sc_dev *dev = rsrc->dev; | 774 | struct irdma_sc_dev *dev = rsrc->dev; |
| 781 | struct irdma_sc_cq *cq = &rsrc->cq; | 775 | struct irdma_sc_cq *cq = &rsrc->cq; |
| 782 | enum irdma_status_code ret = 0; | 776 | int ret = 0; |
| 783 | u32 cqsize; | 777 | u32 cqsize; |
| 784 | struct irdma_dma_mem *mem; | 778 | struct irdma_dma_mem *mem; |
| 785 | struct irdma_cq_init_info info = {}; | 779 | struct irdma_cq_init_info info = {}; |
| @@ -792,7 +786,7 @@ static enum irdma_status_code irdma_puda_cq_create(struct irdma_puda_rsrc *rsrc) · 6 unmodified lines | |||
| 792 | rsrc->cqmem.va = dma_alloc_coherent(dev->hw->device, rsrc->cqmem.size, | 786 | rsrc->cqmem.va = dma_alloc_coherent(dev->hw->device, rsrc->cqmem.size, |
| 793 | &rsrc->cqmem.pa, GFP_KERNEL); | 787 | &rsrc->cqmem.pa, GFP_KERNEL); |
| 794 | if (!rsrc->cqmem.va) | 788 | if (!rsrc->cqmem.va) |
| 795 | return IRDMA_ERR_NO_MEMORY; | 789 | return -ENOMEM; |
| 796 | 790 | ||
| 797 | mem = &rsrc->cqmem; | 791 | mem = &rsrc->cqmem; |
| 798 | info.dev = dev; | 792 | info.dev = dev; |
| @@ -833,7 +827,7 @@ error: · 34 unmodified lines | |||
| 833 | */ | 827 | */ |
| 834 | static void irdma_puda_free_qp(struct irdma_puda_rsrc *rsrc) | 828 | static void irdma_puda_free_qp(struct irdma_puda_rsrc *rsrc) |
| 835 | { | 829 | { |
| 836 | enum irdma_status_code ret; | 830 | int ret; |
| 837 | struct irdma_ccq_cqe_info compl_info; | 831 | struct irdma_ccq_cqe_info compl_info; |
| 838 | struct irdma_sc_dev *dev = rsrc->dev; | 832 | struct irdma_sc_dev *dev = rsrc->dev; |
| 839 | 833 | ||
| @@ -865,7 +859,7 @@ static void irdma_puda_free_qp(struct irdma_puda_rsrc *rsrc) · 25 unmodified lines | |||
| 865 | */ | 859 | */ |
| 866 | static void irdma_puda_free_cq(struct irdma_puda_rsrc *rsrc) | 860 | static void irdma_puda_free_cq(struct irdma_puda_rsrc *rsrc) |
| 867 | { | 861 | { |
| 868 | enum irdma_status_code ret; | 862 | int ret; |
| 869 | struct irdma_ccq_cqe_info compl_info; | 863 | struct irdma_ccq_cqe_info compl_info; |
| 870 | struct irdma_sc_dev *dev = rsrc->dev; | 864 | struct irdma_sc_dev *dev = rsrc->dev; |
| 871 | 865 | ||
| @@ -967,8 +961,7 @@ void irdma_puda_dele_rsrc(struct irdma_sc_vsi *vsi, enum puda_rsrc_type type, · 95 unmodified lines | |||
| 967 | * @rsrc: resource for buffer allocation | 961 | * @rsrc: resource for buffer allocation |
| 968 | * @count: number of buffers to create | 962 | * @count: number of buffers to create |
| 969 | */ | 963 | */ |
| 970 | static enum irdma_status_code irdma_puda_allocbufs(struct irdma_puda_rsrc *rsrc, | 964 | static int irdma_puda_allocbufs(struct irdma_puda_rsrc *rsrc, u32 count) |
| 971 | u32 count) | ||
| 972 | { | 965 | { |
| 973 | u32 i; | 966 | u32 i; |
| 974 | struct irdma_puda_buf *buf; | 967 | struct irdma_puda_buf *buf; |
| @@ -978,7 +971,7 @@ static enum irdma_status_code irdma_puda_allocbufs(struct irdma_puda_rsrc *rsrc, · 3 unmodified lines | |||
| 978 | buf = irdma_puda_alloc_buf(rsrc->dev, rsrc->buf_size); | 971 | buf = irdma_puda_alloc_buf(rsrc->dev, rsrc->buf_size); |
| 979 | if (!buf) { | 972 | if (!buf) { |
| 980 | rsrc->stats_buf_alloc_fail++; | 973 | rsrc->stats_buf_alloc_fail++; |
| 981 | return IRDMA_ERR_NO_MEMORY; | 974 | return -ENOMEM; |
| 982 | } | 975 | } |
| 983 | irdma_puda_ret_bufpool(rsrc, buf); | 976 | irdma_puda_ret_bufpool(rsrc, buf); |
| 984 | rsrc->alloc_buf_count++; | 977 | rsrc->alloc_buf_count++; |
| @@ -1001,11 +994,11 @@ static enum irdma_status_code irdma_puda_allocbufs(struct irdma_puda_rsrc *rsrc, · 16 unmodified lines | |||
| 1001 | * @vsi: sc VSI struct | 994 | * @vsi: sc VSI struct |
| 1002 | * @info: resource information | 995 | * @info: resource information |
| 1003 | */ | 996 | */ |
| 1004 | enum irdma_status_code irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, | 997 | int irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, |
| 1005 | struct irdma_puda_rsrc_info *info) | 998 | struct irdma_puda_rsrc_info *info) |
| 1006 | { | 999 | { |
| 1007 | struct irdma_sc_dev *dev = vsi->dev; | 1000 | struct irdma_sc_dev *dev = vsi->dev; |
| 1008 | enum irdma_status_code ret = 0; | 1001 | int ret = 0; |
| 1009 | struct irdma_puda_rsrc *rsrc; | 1002 | struct irdma_puda_rsrc *rsrc; |
| 1010 | u32 pudasize; | 1003 | u32 pudasize; |
| 1011 | u32 sqwridsize, rqwridsize; | 1004 | u32 sqwridsize, rqwridsize; |
| @@ -1023,12 +1016,12 @@ enum irdma_status_code irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, · 11 unmodified lines | |||
| 1023 | vmem = &vsi->ieq_mem; | 1016 | vmem = &vsi->ieq_mem; |
| 1024 | break; | 1017 | break; |
| 1025 | default: | 1018 | default: |
| 1026 | return IRDMA_NOT_SUPPORTED; | 1019 | return -EOPNOTSUPP; |
| 1027 | } | 1020 | } |
| 1028 | vmem->size = pudasize + sqwridsize + rqwridsize; | 1021 | vmem->size = pudasize + sqwridsize + rqwridsize; |
| 1029 | vmem->va = kzalloc(vmem->size, GFP_KERNEL); | 1022 | vmem->va = kzalloc(vmem->size, GFP_KERNEL); |
| 1030 | if (!vmem->va) | 1023 | if (!vmem->va) |
| 1031 | return IRDMA_ERR_NO_MEMORY; | 1024 | return -ENOMEM; |
| 1032 | 1025 | ||
| 1033 | rsrc = vmem->va; | 1026 | rsrc = vmem->va; |
| 1034 | spin_lock_init(&rsrc->bufpool_lock); | 1027 | spin_lock_init(&rsrc->bufpool_lock); |
| @@ -1046,7 +1039,7 @@ enum irdma_status_code irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, · 11 unmodified lines | |||
| 1046 | rsrc->xmit_complete = irdma_ieq_tx_compl; | 1039 | rsrc->xmit_complete = irdma_ieq_tx_compl; |
| 1047 | break; | 1040 | break; |
| 1048 | default: | 1041 | default: |
| 1049 | return IRDMA_NOT_SUPPORTED; | 1042 | return -EOPNOTSUPP; |
| 1050 | } | 1043 | } |
| 1051 | 1044 | ||
| 1052 | rsrc->type = info->type; | 1045 | rsrc->type = info->type; |
| @@ -1323,12 +1316,12 @@ static void irdma_ieq_compl_pfpdu(struct irdma_puda_rsrc *ieq, · 270 unmodified lines | |||
| 1323 | * @buf: first receive buffer | 1316 | * @buf: first receive buffer |
| 1324 | * @fpdu_len: total length of fpdu | 1317 | * @fpdu_len: total length of fpdu |
| 1325 | */ | 1318 | */ |
| 1326 | static enum irdma_status_code | 1319 | static int irdma_ieq_create_pbufl(struct irdma_pfpdu *pfpdu, |
| 1327 | irdma_ieq_create_pbufl(struct irdma_pfpdu *pfpdu, struct list_head *rxlist, | 1320 | struct list_head *rxlist, |
| 1328 | struct list_head *pbufl, struct irdma_puda_buf *buf, | 1321 | struct list_head *pbufl, |
| 1329 | u16 fpdu_len) | 1322 | struct irdma_puda_buf *buf, u16 fpdu_len) |
| 1330 | { | 1323 | { |
| 1331 | enum irdma_status_code status = 0; | 1324 | int status = 0; |
| 1332 | struct irdma_puda_buf *nextbuf; | 1325 | struct irdma_puda_buf *nextbuf; |
| 1333 | u32 nextseqnum; | 1326 | u32 nextseqnum; |
| 1334 | u16 plen = fpdu_len - buf->datalen; | 1327 | u16 plen = fpdu_len - buf->datalen; |
| @@ -1338,13 +1331,13 @@ irdma_ieq_create_pbufl(struct irdma_pfpdu *pfpdu, struct list_head *rxlist, · 3 unmodified lines | |||
| 1338 | do { | 1331 | do { |
| 1339 | nextbuf = irdma_puda_get_listbuf(rxlist); | 1332 | nextbuf = irdma_puda_get_listbuf(rxlist); |
| 1340 | if (!nextbuf) { | 1333 | if (!nextbuf) { |
| 1341 | status = IRDMA_ERR_list_empty; | 1334 | status = -ENOBUFS; |
| 1342 | break; | 1335 | break; |
| 1343 | } | 1336 | } |
| 1344 | list_add_tail(&nextbuf->list, pbufl); | 1337 | list_add_tail(&nextbuf->list, pbufl); |
| 1345 | if (nextbuf->seqnum != nextseqnum) { | 1338 | if (nextbuf->seqnum != nextseqnum) { |
| 1346 | pfpdu->bad_seq_num++; | 1339 | pfpdu->bad_seq_num++; |
| 1347 | status = IRDMA_ERR_SEQ_NUM; | 1340 | status = -ERANGE; |
| 1348 | break; | 1341 | break; |
| 1349 | } | 1342 | } |
| 1350 | if (nextbuf->datalen >= plen) { | 1343 | if (nextbuf->datalen >= plen) { |
| @@ -1366,11 +1359,11 @@ irdma_ieq_create_pbufl(struct irdma_pfpdu *pfpdu, struct list_head *rxlist, · 15 unmodified lines | |||
| 1366 | * @buf: receive buffer | 1359 | * @buf: receive buffer |
| 1367 | * @fpdu_len: fpdu len in the buffer | 1360 | * @fpdu_len: fpdu len in the buffer |
| 1368 | */ | 1361 | */ |
| 1369 | static enum irdma_status_code | 1362 | static int irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, |
| 1370 | irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, struct irdma_pfpdu *pfpdu, | 1363 | struct irdma_pfpdu *pfpdu, |
| 1371 | struct irdma_puda_buf *buf, u16 fpdu_len) | 1364 | struct irdma_puda_buf *buf, u16 fpdu_len) |
| 1372 | { | 1365 | { |
| 1373 | enum irdma_status_code status = 0; | 1366 | int status = 0; |
| 1374 | u8 *crcptr; | 1367 | u8 *crcptr; |
| 1375 | u32 mpacrc; | 1368 | u32 mpacrc; |
| 1376 | u32 seqnum = buf->seqnum; | 1369 | u32 seqnum = buf->seqnum; |
| @@ -1390,7 +1383,7 @@ irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, struct irdma_pfpdu *pfpdu, · 13 unmodified lines | |||
| 1390 | txbuf = irdma_puda_get_bufpool(ieq); | 1383 | txbuf = irdma_puda_get_bufpool(ieq); |
| 1391 | if (!txbuf) { | 1384 | if (!txbuf) { |
| 1392 | pfpdu->no_tx_bufs++; | 1385 | pfpdu->no_tx_bufs++; |
| 1393 | status = IRDMA_ERR_NO_TXBUFS; | 1386 | status = -ENOBUFS; |
| 1394 | goto error; | 1387 | goto error; |
| 1395 | } | 1388 | } |
| 1396 | 1389 | ||
| @@ -1434,9 +1427,9 @@ error: · 37 unmodified lines | |||
| 1434 | * @pfpdu: partial management per user qp | 1427 | * @pfpdu: partial management per user qp |
| 1435 | * @buf: receive buffer | 1428 | * @buf: receive buffer |
| 1436 | */ | 1429 | */ |
| 1437 | static enum irdma_status_code irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, | 1430 | static int irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, |
| 1438 | struct irdma_pfpdu *pfpdu, | 1431 | struct irdma_pfpdu *pfpdu, |
| 1439 | struct irdma_puda_buf *buf) | 1432 | struct irdma_puda_buf *buf) |
| 1440 | { | 1433 | { |
| 1441 | u16 fpdu_len = 0; | 1434 | u16 fpdu_len = 0; |
| 1442 | u16 datalen = buf->datalen; | 1435 | u16 datalen = buf->datalen; |
| @@ -1450,7 +1443,7 @@ static enum irdma_status_code irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, · 7 unmodified lines | |||
| 1450 | bool partial = false; | 1443 | bool partial = false; |
| 1451 | struct irdma_puda_buf *txbuf; | 1444 | struct irdma_puda_buf *txbuf; |
| 1452 | struct list_head *rxlist = &pfpdu->rxlist; | 1445 | struct list_head *rxlist = &pfpdu->rxlist; |
| 1453 | enum irdma_status_code ret = 0; | 1446 | int ret = 0; |
| 1454 | 1447 | ||
| 1455 | ioffset = (u16)(buf->data - (u8 *)buf->mem.va); | 1448 | ioffset = (u16)(buf->data - (u8 *)buf->mem.va); |
| 1456 | while (datalen) { | 1449 | while (datalen) { |
| @@ -1459,7 +1452,7 @@ static enum irdma_status_code irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, · 2 unmodified lines | |||
| 1459 | ibdev_dbg(to_ibdev(ieq->dev), | 1452 | ibdev_dbg(to_ibdev(ieq->dev), |
| 1460 | "IEQ: error bad fpdu len\n"); | 1453 | "IEQ: error bad fpdu len\n"); |
| 1461 | list_add(&buf->list, rxlist); | 1454 | list_add(&buf->list, rxlist); |
| 1462 | return IRDMA_ERR_MPA_CRC; | 1455 | return -EINVAL; |
| 1463 | } | 1456 | } |
| 1464 | 1457 | ||
| 1465 | if (datalen < fpdu_len) { | 1458 | if (datalen < fpdu_len) { |
| @@ -1475,7 +1468,7 @@ static enum irdma_status_code irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, · 9 unmodified lines | |||
| 1475 | list_add(&buf->list, rxlist); | 1468 | list_add(&buf->list, rxlist); |
| 1476 | ibdev_dbg(to_ibdev(ieq->dev), | 1469 | ibdev_dbg(to_ibdev(ieq->dev), |
| 1477 | "ERR: IRDMA_ERR_MPA_CRC\n"); | 1470 | "ERR: IRDMA_ERR_MPA_CRC\n"); |
| 1478 | return IRDMA_ERR_MPA_CRC; | 1471 | return -EINVAL; |
| 1479 | } | 1472 | } |
| 1480 | full++; | 1473 | full++; |
| 1481 | pfpdu->fpdu_processed++; | 1474 | pfpdu->fpdu_processed++; |
| @@ -1490,7 +1483,7 @@ static enum irdma_status_code irdma_ieq_process_buf(struct irdma_puda_rsrc *ieq, · 8 unmodified lines | |||
| 1490 | if (!txbuf) { | 1483 | if (!txbuf) { |
| 1491 | pfpdu->no_tx_bufs++; | 1484 | pfpdu->no_tx_bufs++; |
| 1492 | list_add(&buf->list, rxlist); | 1485 | list_add(&buf->list, rxlist); |
| 1493 | return IRDMA_ERR_NO_TXBUFS; | 1486 | return -ENOBUFS; |
| 1494 | } | 1487 | } |
| 1495 | /* modify txbuf's buffer header */ | 1488 | /* modify txbuf's buffer header */ |
| 1496 | irdma_ieq_setup_tx_buf(buf, txbuf); | 1489 | irdma_ieq_setup_tx_buf(buf, txbuf); |
| @@ -1539,7 +1532,7 @@ void irdma_ieq_process_fpdus(struct irdma_sc_qp *qp, · 42 unmodified lines | |||
| 1539 | struct irdma_pfpdu *pfpdu = &qp->pfpdu; | 1532 | struct irdma_pfpdu *pfpdu = &qp->pfpdu; |
| 1540 | struct list_head *rxlist = &pfpdu->rxlist; | 1533 | struct list_head *rxlist = &pfpdu->rxlist; |
| 1541 | struct irdma_puda_buf *buf; | 1534 | struct irdma_puda_buf *buf; |
| 1542 | enum irdma_status_code status; | 1535 | int status; |
| 1543 | 1536 | ||
| 1544 | do { | 1537 | do { |
| 1545 | if (list_empty(rxlist)) | 1538 | if (list_empty(rxlist)) |
| @@ -1557,7 +1550,7 @@ void irdma_ieq_process_fpdus(struct irdma_sc_qp *qp, · 11 unmodified lines | |||
| 1557 | } | 1550 | } |
| 1558 | /* keep processing buffers from the head of the list */ | 1551 | /* keep processing buffers from the head of the list */ |
| 1559 | status = irdma_ieq_process_buf(ieq, pfpdu, buf); | 1552 | status = irdma_ieq_process_buf(ieq, pfpdu, buf); |
| 1560 | if (status == IRDMA_ERR_MPA_CRC) { | 1553 | if (status == -EINVAL) { |
| 1561 | pfpdu->mpa_crc_err = true; | 1554 | pfpdu->mpa_crc_err = true; |
| 1562 | while (!list_empty(rxlist)) { | 1555 | while (!list_empty(rxlist)) { |
| 1563 | buf = irdma_puda_get_listbuf(rxlist); | 1556 | buf = irdma_puda_get_listbuf(rxlist); |
| @@ -1576,8 +1569,7 @@ void irdma_ieq_process_fpdus(struct irdma_sc_qp *qp, · 12 unmodified lines | |||
| 1576 | * @qp: qp pointer | 1569 | * @qp: qp pointer |
| 1577 | * @buf: buf received on IEQ used to create AH | 1570 | * @buf: buf received on IEQ used to create AH |
| 1578 | */ | 1571 | */ |
| 1579 | static enum irdma_status_code irdma_ieq_create_ah(struct irdma_sc_qp *qp, | 1572 | static int irdma_ieq_create_ah(struct irdma_sc_qp *qp, struct irdma_puda_buf *buf) |
| 1580 | struct irdma_puda_buf *buf) | ||
| 1581 | { | 1573 | { |
| 1582 | struct irdma_ah_info ah_info = {}; | 1574 | struct irdma_ah_info ah_info = {}; |
| 1583 | 1575 | ||
| @@ -151,42 +151,33 @@ void irdma_puda_ret_bufpool(struct irdma_puda_rsrc *rsrc, · 150 unmodified lines | |||
| 151 | struct irdma_puda_buf *buf); | 151 | struct irdma_puda_buf *buf); |
| 152 | void irdma_puda_send_buf(struct irdma_puda_rsrc *rsrc, | 152 | void irdma_puda_send_buf(struct irdma_puda_rsrc *rsrc, |
| 153 | struct irdma_puda_buf *buf); | 153 | struct irdma_puda_buf *buf); |
| 154 | enum irdma_status_code irdma_puda_send(struct irdma_sc_qp *qp, | 154 | int irdma_puda_send(struct irdma_sc_qp *qp, struct irdma_puda_send_info *info); |
| 155 | struct irdma_puda_send_info *info); | 155 | int irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, |
| 156 | enum irdma_status_code | 156 | struct irdma_puda_rsrc_info *info); |
| 157 | irdma_puda_create_rsrc(struct irdma_sc_vsi *vsi, | ||
| 158 | struct irdma_puda_rsrc_info *info); | ||
| 159 | void irdma_puda_dele_rsrc(struct irdma_sc_vsi *vsi, enum puda_rsrc_type type, | 157 | void irdma_puda_dele_rsrc(struct irdma_sc_vsi *vsi, enum puda_rsrc_type type, |
| 160 | bool reset); | 158 | bool reset); |
| 161 | enum irdma_status_code irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, | 159 | int irdma_puda_poll_cmpl(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq, |
| 162 | struct irdma_sc_cq *cq, | 160 | u32 *compl_err); |
| 163 | u32 *compl_err); | ||
| 164 | 161 | ||
| 165 | struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev, | 162 | struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev, |
| 166 | struct irdma_puda_buf *buf); | 163 | struct irdma_puda_buf *buf); |
| 167 | enum irdma_status_code | 164 | int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, |
| 168 | irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, | 165 | struct irdma_puda_buf *buf); |
| 169 | struct irdma_puda_buf *buf); | 166 | int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len, u32 val); |
| 170 | enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc, | 167 | int irdma_init_hash_desc(struct shash_desc **desc); |
| 171 | void *addr, u32 len, u32 val); | ||
| 172 | enum irdma_status_code irdma_init_hash_desc(struct shash_desc **desc); | ||
| 173 | void irdma_ieq_mpa_crc_ae(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); | 168 | void irdma_ieq_mpa_crc_ae(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); |
| 174 | void irdma_free_hash_desc(struct shash_desc *desc); | 169 | void irdma_free_hash_desc(struct shash_desc *desc); |
| 175 | void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, | 170 | void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, u32 seqnum); |
| 176 | u32 seqnum); | 171 | int irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp); |
| 177 | enum irdma_status_code irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, | 172 | int irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq); |
| 178 | struct irdma_sc_qp *qp); | 173 | int irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, 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); | ||
| 182 | void irdma_cqp_cq_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq); | 174 | void irdma_cqp_cq_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq); |
| 183 | void irdma_puda_ieq_get_ah_info(struct irdma_sc_qp *qp, | 175 | void irdma_puda_ieq_get_ah_info(struct irdma_sc_qp *qp, |
| 184 | struct irdma_ah_info *ah_info); | 176 | struct irdma_ah_info *ah_info); |
| 185 | enum irdma_status_code irdma_puda_create_ah(struct irdma_sc_dev *dev, | 177 | int irdma_puda_create_ah(struct irdma_sc_dev *dev, |
| 186 | struct irdma_ah_info *ah_info, | 178 | struct irdma_ah_info *ah_info, bool wait, |
| 187 | bool wait, enum puda_rsrc_type type, | 179 | enum puda_rsrc_type type, void *cb_param, |
| 188 | void *cb_param, | 180 | struct irdma_sc_ah **ah); |
| 189 | struct irdma_sc_ah **ah); | ||
| 190 | void irdma_puda_free_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah); | 181 | void irdma_puda_free_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah); |
| 191 | void irdma_ieq_process_fpdus(struct irdma_sc_qp *qp, | 182 | void irdma_ieq_process_fpdus(struct irdma_sc_qp *qp, |
| 192 | struct irdma_puda_rsrc *ieq); | 183 | struct irdma_puda_rsrc *ieq); |
| @@ -1,71 +0,0 @@ | |||
| 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 */ | ||
| @@ -2,7 +2,6 @@ · 1 unmodified line | |||
| 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ | 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ |
| 3 | #ifndef IRDMA_TYPE_H | 3 | #ifndef IRDMA_TYPE_H |
| 4 | #define IRDMA_TYPE_H | 4 | #define IRDMA_TYPE_H |
| 5 | #include "status.h" | ||
| 6 | #include "osdep.h" | 5 | #include "osdep.h" |
| 7 | #include "irdma.h" | 6 | #include "irdma.h" |
| 8 | #include "user.h" | 7 | #include "user.h" |
| @@ -402,8 +401,8 @@ struct irdma_sc_cqp { · 393 unmodified lines | |||
| 402 | u64 host_ctx_pa; | 401 | u64 host_ctx_pa; |
| 403 | void *back_cqp; | 402 | void *back_cqp; |
| 404 | struct irdma_sc_dev *dev; | 403 | struct irdma_sc_dev *dev; |
| 405 | enum irdma_status_code (*process_cqp_sds)(struct irdma_sc_dev *dev, | 404 | int (*process_cqp_sds)(struct irdma_sc_dev *dev, |
| 406 | struct irdma_update_sds_info *info); | 405 | struct irdma_update_sds_info *info); |
| 407 | struct irdma_dma_mem sdbuf; | 406 | struct irdma_dma_mem sdbuf; |
| 408 | struct irdma_ring sq_ring; | 407 | struct irdma_ring sq_ring; |
| 409 | struct irdma_cqp_quanta *sq_base; | 408 | struct irdma_cqp_quanta *sq_base; |
| @@ -605,12 +604,14 @@ struct irdma_sc_vsi { · 195 unmodified lines | |||
| 605 | struct irdma_qos qos[IRDMA_MAX_USER_PRIORITY]; | 604 | struct irdma_qos qos[IRDMA_MAX_USER_PRIORITY]; |
| 606 | struct irdma_vsi_pestat *pestat; | 605 | struct irdma_vsi_pestat *pestat; |
| 607 | atomic_t qp_suspend_reqs; | 606 | atomic_t qp_suspend_reqs; |
| 608 | enum irdma_status_code (*register_qset)(struct irdma_sc_vsi *vsi, | 607 | int (*register_qset)(struct irdma_sc_vsi *vsi, |
| 609 | struct irdma_ws_node *tc_node); | 608 | struct irdma_ws_node *tc_node); |
| 610 | void (*unregister_qset)(struct irdma_sc_vsi *vsi, | 609 | void (*unregister_qset)(struct irdma_sc_vsi *vsi, |
| 611 | struct irdma_ws_node *tc_node); | 610 | struct irdma_ws_node *tc_node); |
| 612 | u8 qos_rel_bw; | 611 | u8 qos_rel_bw; |
| 613 | u8 qos_prio_type; | 612 | u8 qos_prio_type; |
| 613 | u8 dscp_map[IIDC_MAX_DSCP_MAPPING]; | ||
| 614 | bool dscp_mode:1; | ||
| 614 | }; | 615 | }; |
| 615 | 616 | ||
| 616 | struct irdma_sc_dev { | 617 | struct irdma_sc_dev { |
| @@ -655,7 +656,7 @@ struct irdma_sc_dev { · 38 unmodified lines | |||
| 655 | bool vchnl_up:1; | 656 | bool vchnl_up:1; |
| 656 | bool ceq_valid:1; | 657 | bool ceq_valid:1; |
| 657 | u8 pci_rev; | 658 | u8 pci_rev; |
| 658 | enum irdma_status_code (*ws_add)(struct irdma_sc_vsi *vsi, u8 user_pri); | 659 | int (*ws_add)(struct irdma_sc_vsi *vsi, u8 user_pri); |
| 659 | void (*ws_remove)(struct irdma_sc_vsi *vsi, u8 user_pri); | 660 | void (*ws_remove)(struct irdma_sc_vsi *vsi, u8 user_pri); |
| 660 | void (*ws_reset)(struct irdma_sc_vsi *vsi); | 661 | void (*ws_reset)(struct irdma_sc_vsi *vsi); |
| 661 | }; | 662 | }; |
| @@ -735,11 +736,13 @@ struct irdma_l2params { · 73 unmodified lines | |||
| 735 | u16 qs_handle_list[IRDMA_MAX_USER_PRIORITY]; | 736 | u16 qs_handle_list[IRDMA_MAX_USER_PRIORITY]; |
| 736 | u16 mtu; | 737 | u16 mtu; |
| 737 | u8 up2tc[IRDMA_MAX_USER_PRIORITY]; | 738 | u8 up2tc[IRDMA_MAX_USER_PRIORITY]; |
| 739 | u8 dscp_map[IIDC_MAX_DSCP_MAPPING]; | ||
| 738 | u8 num_tc; | 740 | u8 num_tc; |
| 739 | u8 vsi_rel_bw; | 741 | u8 vsi_rel_bw; |
| 740 | u8 vsi_prio_type; | 742 | u8 vsi_prio_type; |
| 741 | bool mtu_changed:1; | 743 | bool mtu_changed:1; |
| 742 | bool tc_changed:1; | 744 | bool tc_changed:1; |
| 745 | bool dscp_mode:1; | ||
| 743 | }; | 746 | }; |
| 744 | 747 | ||
| 745 | struct irdma_vsi_init_info { | 748 | struct irdma_vsi_init_info { |
| @@ -750,8 +753,8 @@ struct irdma_vsi_init_info { · 4 unmodified lines | |||
| 750 | u16 pf_data_vsi_num; | 753 | u16 pf_data_vsi_num; |
| 751 | enum irdma_vm_vf_type vm_vf_type; | 754 | enum irdma_vm_vf_type vm_vf_type; |
| 752 | u16 vm_id; | 755 | u16 vm_id; |
| 753 | enum irdma_status_code (*register_qset)(struct irdma_sc_vsi *vsi, | 756 | int (*register_qset)(struct irdma_sc_vsi *vsi, |
| 754 | struct irdma_ws_node *tc_node); | 757 | struct irdma_ws_node *tc_node); |
| 755 | void (*unregister_qset)(struct irdma_sc_vsi *vsi, | 758 | void (*unregister_qset)(struct irdma_sc_vsi *vsi, |
| 756 | struct irdma_ws_node *tc_node); | 759 | struct irdma_ws_node *tc_node); |
| 757 | }; | 760 | }; |
| @@ -1198,29 +1201,27 @@ struct irdma_irq_ops { · 440 unmodified lines | |||
| 1198 | }; | 1201 | }; |
| 1199 | 1202 | ||
| 1200 | void irdma_sc_ccq_arm(struct irdma_sc_cq *ccq); | 1203 | void irdma_sc_ccq_arm(struct irdma_sc_cq *ccq); |
| 1201 | enum irdma_status_code irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, | 1204 | int irdma_sc_ccq_create(struct irdma_sc_cq *ccq, u64 scratch, |
| 1202 | bool check_overflow, bool post_sq); | 1205 | bool check_overflow, bool post_sq); |
| 1203 | enum irdma_status_code irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, | 1206 | int irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, bool post_sq); |
| 1204 | bool post_sq); | 1207 | int irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, |
| 1205 | enum irdma_status_code irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq, | 1208 | struct irdma_ccq_cqe_info *info); |
| 1206 | struct irdma_ccq_cqe_info *info); | 1209 | int irdma_sc_ccq_init(struct irdma_sc_cq *ccq, |
| 1207 | enum irdma_status_code irdma_sc_ccq_init(struct irdma_sc_cq *ccq, | 1210 | struct irdma_ccq_init_info *info); |
| 1208 | struct irdma_ccq_init_info *info); | 1211 | |
| 1209 | 1212 | int irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch); | |
| 1210 | enum irdma_status_code irdma_sc_cceq_create(struct irdma_sc_ceq *ceq, u64 scratch); | 1213 | int irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq); |
| 1211 | enum irdma_status_code irdma_sc_cceq_destroy_done(struct irdma_sc_ceq *ceq); | 1214 | |
| 1212 | 1215 | int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq); | |
| 1213 | enum irdma_status_code irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, | 1216 | int irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, |
| 1214 | bool post_sq); | 1217 | struct irdma_ceq_init_info *info); |
| 1215 | enum irdma_status_code irdma_sc_ceq_init(struct irdma_sc_ceq *ceq, | ||
| 1216 | struct irdma_ceq_init_info *info); | ||
| 1217 | void irdma_sc_cleanup_ceqes(struct irdma_sc_cq *cq, struct irdma_sc_ceq *ceq); | 1218 | void irdma_sc_cleanup_ceqes(struct irdma_sc_cq *cq, struct irdma_sc_ceq *ceq); |
| 1218 | void *irdma_sc_process_ceq(struct irdma_sc_dev *dev, struct irdma_sc_ceq *ceq); | 1219 | void *irdma_sc_process_ceq(struct irdma_sc_dev *dev, struct irdma_sc_ceq *ceq); |
| 1219 | 1220 | ||
| 1220 | enum irdma_status_code irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, | 1221 | int irdma_sc_aeq_init(struct irdma_sc_aeq *aeq, |
| 1221 | struct irdma_aeq_init_info *info); | 1222 | struct irdma_aeq_init_info *info); |
| 1222 | enum irdma_status_code irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, | 1223 | int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, |
| 1223 | struct irdma_aeqe_info *info); | 1224 | struct irdma_aeqe_info *info); |
| 1224 | void irdma_sc_repost_aeq_entries(struct irdma_sc_dev *dev, u32 count); | 1225 | void irdma_sc_repost_aeq_entries(struct irdma_sc_dev *dev, u32 count); |
| 1225 | 1226 | ||
| 1226 | void irdma_sc_pd_init(struct irdma_sc_dev *dev, struct irdma_sc_pd *pd, u32 pd_id, | 1227 | void irdma_sc_pd_init(struct irdma_sc_dev *dev, struct irdma_sc_pd *pd, u32 pd_id, |
| @@ -1228,31 +1229,27 @@ void irdma_sc_pd_init(struct irdma_sc_dev *dev, struct irdma_sc_pd *pd, u32 pd_i · 1 unmodified line | |||
| 1228 | void irdma_cfg_aeq(struct irdma_sc_dev *dev, u32 idx, bool enable); | 1229 | void irdma_cfg_aeq(struct irdma_sc_dev *dev, u32 idx, bool enable); |
| 1229 | void irdma_check_cqp_progress(struct irdma_cqp_timeout *cqp_timeout, | 1230 | void irdma_check_cqp_progress(struct irdma_cqp_timeout *cqp_timeout, |
| 1230 | struct irdma_sc_dev *dev); | 1231 | struct irdma_sc_dev *dev); |
| 1231 | enum irdma_status_code irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, | 1232 | int irdma_sc_cqp_create(struct irdma_sc_cqp *cqp, u16 *maj_err, u16 *min_err); |
| 1232 | u16 *min_err); | 1233 | int irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp); |
| 1233 | enum irdma_status_code irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp); | 1234 | int irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, |
| 1234 | enum irdma_status_code irdma_sc_cqp_init(struct irdma_sc_cqp *cqp, | 1235 | struct irdma_cqp_init_info *info); |
| 1235 | struct irdma_cqp_init_info *info); | ||
| 1236 | void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp); | 1236 | void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp); |
| 1237 | enum irdma_status_code irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 opcode, | 1237 | int irdma_sc_poll_for_cqp_op_done(struct irdma_sc_cqp *cqp, u8 opcode, |
| 1238 | struct irdma_ccq_cqe_info *cmpl_info); | 1238 | struct irdma_ccq_cqe_info *cmpl_info); |
| 1239 | enum irdma_status_code irdma_sc_fast_register(struct irdma_sc_qp *qp, | 1239 | int irdma_sc_fast_register(struct irdma_sc_qp *qp, |
| 1240 | struct irdma_fast_reg_stag_info *info, | 1240 | struct irdma_fast_reg_stag_info *info, bool post_sq); |
| 1241 | bool post_sq); | 1241 | int irdma_sc_qp_create(struct irdma_sc_qp *qp, |
| 1242 | enum irdma_status_code irdma_sc_qp_create(struct irdma_sc_qp *qp, | 1242 | struct irdma_create_qp_info *info, u64 scratch, |
| 1243 | struct irdma_create_qp_info *info, | 1243 | bool post_sq); |
| 1244 | u64 scratch, bool post_sq); | 1244 | int irdma_sc_qp_destroy(struct irdma_sc_qp *qp, u64 scratch, |
| 1245 | enum irdma_status_code irdma_sc_qp_destroy(struct irdma_sc_qp *qp, | 1245 | bool remove_hash_idx, bool ignore_mw_bnd, bool post_sq); |
| 1246 | u64 scratch, bool remove_hash_idx, | 1246 | int irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, |
| 1247 | bool ignore_mw_bnd, bool post_sq); | 1247 | struct irdma_qp_flush_info *info, u64 scratch, |
| 1248 | enum irdma_status_code irdma_sc_qp_flush_wqes(struct irdma_sc_qp *qp, | 1248 | bool post_sq); |
| 1249 | struct irdma_qp_flush_info *info, | 1249 | int irdma_sc_qp_init(struct irdma_sc_qp *qp, struct irdma_qp_init_info *info); |
| 1250 | u64 scratch, bool post_sq); | 1250 | int irdma_sc_qp_modify(struct irdma_sc_qp *qp, |
| 1251 | enum irdma_status_code irdma_sc_qp_init(struct irdma_sc_qp *qp, | 1251 | struct irdma_modify_qp_info *info, u64 scratch, |
| 1252 | struct irdma_qp_init_info *info); | 1252 | bool post_sq); |
| 1253 | enum irdma_status_code irdma_sc_qp_modify(struct irdma_sc_qp *qp, | ||
| 1254 | struct irdma_modify_qp_info *info, | ||
| 1255 | u64 scratch, bool post_sq); | ||
| 1256 | void irdma_sc_send_lsmm(struct irdma_sc_qp *qp, void *lsmm_buf, u32 size, | 1253 | void irdma_sc_send_lsmm(struct irdma_sc_qp *qp, void *lsmm_buf, u32 size, |
| 1257 | irdma_stag stag); | 1254 | irdma_stag stag); |
| 1258 | 1255 | ||
| @@ -1261,14 +1258,12 @@ void irdma_sc_qp_setctx(struct irdma_sc_qp *qp, __le64 *qp_ctx, · 2 unmodified lines | |||
| 1261 | struct irdma_qp_host_ctx_info *info); | 1258 | struct irdma_qp_host_ctx_info *info); |
| 1262 | void irdma_sc_qp_setctx_roce(struct irdma_sc_qp *qp, __le64 *qp_ctx, | 1259 | void irdma_sc_qp_setctx_roce(struct irdma_sc_qp *qp, __le64 *qp_ctx, |
| 1263 | struct irdma_qp_host_ctx_info *info); | 1260 | struct irdma_qp_host_ctx_info *info); |
| 1264 | enum irdma_status_code irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, | 1261 | int irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, bool post_sq); |
| 1265 | bool post_sq); | 1262 | int irdma_sc_cq_init(struct irdma_sc_cq *cq, struct irdma_cq_init_info *info); |
| 1266 | enum irdma_status_code irdma_sc_cq_init(struct irdma_sc_cq *cq, | ||
| 1267 | struct irdma_cq_init_info *info); | ||
| 1268 | void irdma_sc_cq_resize(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *info); | 1263 | void irdma_sc_cq_resize(struct irdma_sc_cq *cq, struct irdma_modify_cq_info *info); |
| 1269 | enum irdma_status_code irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, | 1264 | int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch, |
| 1270 | u64 scratch, u8 hmc_fn_id, | 1265 | u8 hmc_fn_id, bool post_sq, |
| 1271 | bool post_sq, bool poll_registers); | 1266 | bool poll_registers); |
| 1272 | 1267 | ||
| 1273 | void sc_vsi_update_stats(struct irdma_sc_vsi *vsi); | 1268 | void sc_vsi_update_stats(struct irdma_sc_vsi *vsi); |
| 1274 | struct cqp_info { | 1269 | struct cqp_info { |
| @@ -3,7 +3,6 @@ · 2 unmodified lines | |||
| 3 | #include <linux/etherdevice.h> | 3 | #include <linux/etherdevice.h> |
| 4 | 4 | ||
| 5 | #include "osdep.h" | 5 | #include "osdep.h" |
| 6 | #include "status.h" | ||
| 7 | #include "hmc.h" | 6 | #include "hmc.h" |
| 8 | #include "defs.h" | 7 | #include "defs.h" |
| 9 | #include "type.h" | 8 | #include "type.h" |
| @@ -18,16 +17,15 @@ · 8 unmodified lines | |||
| 18 | * @op: Operation | 17 | * @op: Operation |
| 19 | * @scratch: u64 saved to be used during cqp completion | 18 | * @scratch: u64 saved to be used during cqp completion |
| 20 | */ | 19 | */ |
| 21 | enum irdma_status_code irdma_sc_access_ah(struct irdma_sc_cqp *cqp, | 20 | int irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info, |
| 22 | struct irdma_ah_info *info, | 21 | u32 op, u64 scratch) |
| 23 | u32 op, u64 scratch) | ||
| 24 | { | 22 | { |
| 25 | __le64 *wqe; | 23 | __le64 *wqe; |
| 26 | u64 qw1, qw2; | 24 | u64 qw1, qw2; |
| 27 | 25 | ||
| 28 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 26 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 29 | if (!wqe) | 27 | if (!wqe) |
| 30 | return IRDMA_ERR_RING_FULL; | 28 | return -ENOMEM; |
| 31 | 29 | ||
| 32 | set_64bit_val(wqe, 0, ether_addr_to_u64(info->mac_addr) << 16); | 30 | set_64bit_val(wqe, 0, ether_addr_to_u64(info->mac_addr) << 16); |
| 33 | qw1 = FIELD_PREP(IRDMA_UDA_CQPSQ_MAV_PDINDEXLO, info->pd_idx) | | 31 | qw1 = FIELD_PREP(IRDMA_UDA_CQPSQ_MAV_PDINDEXLO, info->pd_idx) | |
| @@ -86,8 +84,7 @@ enum irdma_status_code irdma_sc_access_ah(struct irdma_sc_cqp *cqp, · 52 unmodified lines | |||
| 86 | * irdma_create_mg_ctx() - create a mcg context | 84 | * irdma_create_mg_ctx() - create a mcg context |
| 87 | * @info: multicast group context info | 85 | * @info: multicast group context info |
| 88 | */ | 86 | */ |
| 89 | static enum irdma_status_code | 87 | static void irdma_create_mg_ctx(struct irdma_mcast_grp_info *info) |
| 90 | irdma_create_mg_ctx(struct irdma_mcast_grp_info *info) | ||
| 91 | { | 88 | { |
| 92 | struct irdma_mcast_grp_ctx_entry_info *entry_info = NULL; | 89 | struct irdma_mcast_grp_ctx_entry_info *entry_info = NULL; |
| 93 | u8 idx = 0; /* index in the array */ | 90 | u8 idx = 0; /* index in the array */ |
| @@ -106,8 +103,6 @@ irdma_create_mg_ctx(struct irdma_mcast_grp_info *info) · 12 unmodified lines | |||
| 106 | ctx_idx++; | 103 | ctx_idx++; |
| 107 | } | 104 | } |
| 108 | } | 105 | } |
| 109 | |||
| 110 | return 0; | ||
| 111 | } | 106 | } |
| 112 | 107 | ||
| 113 | /** | 108 | /** |
| @@ -117,27 +112,24 @@ irdma_create_mg_ctx(struct irdma_mcast_grp_info *info) · 3 unmodified lines | |||
| 117 | * @op: operation to perform | 112 | * @op: operation to perform |
| 118 | * @scratch: u64 saved to be used during cqp completion | 113 | * @scratch: u64 saved to be used during cqp completion |
| 119 | */ | 114 | */ |
| 120 | enum irdma_status_code irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, | 115 | int irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, |
| 121 | struct irdma_mcast_grp_info *info, | 116 | struct irdma_mcast_grp_info *info, u32 op, |
| 122 | u32 op, u64 scratch) | 117 | u64 scratch) |
| 123 | { | 118 | { |
| 124 | __le64 *wqe; | 119 | __le64 *wqe; |
| 125 | enum irdma_status_code ret_code = 0; | ||
| 126 | 120 | ||
| 127 | if (info->mg_id >= IRDMA_UDA_MAX_FSI_MGS) { | 121 | if (info->mg_id >= IRDMA_UDA_MAX_FSI_MGS) { |
| 128 | ibdev_dbg(to_ibdev(cqp->dev), "WQE: mg_id out of range\n"); | 122 | ibdev_dbg(to_ibdev(cqp->dev), "WQE: mg_id out of range\n"); |
| 129 | return IRDMA_ERR_PARAM; | 123 | return -EINVAL; |
| 130 | } | 124 | } |
| 131 | 125 | ||
| 132 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); | 126 | wqe = irdma_sc_cqp_get_next_send_wqe(cqp, scratch); |
| 133 | if (!wqe) { | 127 | if (!wqe) { |
| 134 | ibdev_dbg(to_ibdev(cqp->dev), "WQE: ring full\n"); | 128 | ibdev_dbg(to_ibdev(cqp->dev), "WQE: ring full\n"); |
| 135 | return IRDMA_ERR_RING_FULL; | 129 | return -ENOMEM; |
| 136 | } | 130 | } |
| 137 | 131 | ||
| 138 | ret_code = irdma_create_mg_ctx(info); | 132 | irdma_create_mg_ctx(info); |
| 139 | if (ret_code) | ||
| 140 | return ret_code; | ||
| 141 | 133 | ||
| 142 | set_64bit_val(wqe, 32, info->dma_mem_mc.pa); | 134 | set_64bit_val(wqe, 32, info->dma_mem_mc.pa); |
| 143 | set_64bit_val(wqe, 16, | 135 | set_64bit_val(wqe, 16, |
| @@ -198,8 +190,8 @@ static bool irdma_compare_mgs(struct irdma_mcast_grp_ctx_entry_info *entry1, · 54 unmodified lines | |||
| 198 | * @ctx: Multcast group context | 190 | * @ctx: Multcast group context |
| 199 | * @mg: Multcast group info | 191 | * @mg: Multcast group info |
| 200 | */ | 192 | */ |
| 201 | enum irdma_status_code irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, | 193 | int irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, |
| 202 | struct irdma_mcast_grp_ctx_entry_info *mg) | 194 | struct irdma_mcast_grp_ctx_entry_info *mg) |
| 203 | { | 195 | { |
| 204 | u32 idx; | 196 | u32 idx; |
| 205 | bool free_entry_found = false; | 197 | bool free_entry_found = false; |
| @@ -228,7 +220,7 @@ enum irdma_status_code irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, · 22 unmodified lines | |||
| 228 | return 0; | 220 | return 0; |
| 229 | } | 221 | } |
| 230 | 222 | ||
| 231 | return IRDMA_ERR_NO_MEMORY; | 223 | return -ENOMEM; |
| 232 | } | 224 | } |
| 233 | 225 | ||
| 234 | /** | 226 | /** |
| @@ -239,8 +231,8 @@ enum irdma_status_code irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, · 4 unmodified lines | |||
| 239 | * Finds and removes a specific mulicast group from context, all | 231 | * Finds and removes a specific mulicast group from context, all |
| 240 | * parameters must match to remove a multicast group. | 232 | * parameters must match to remove a multicast group. |
| 241 | */ | 233 | */ |
| 242 | enum irdma_status_code irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, | 234 | int irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, |
| 243 | struct irdma_mcast_grp_ctx_entry_info *mg) | 235 | struct irdma_mcast_grp_ctx_entry_info *mg) |
| 244 | { | 236 | { |
| 245 | u32 idx; | 237 | u32 idx; |
| 246 | 238 | ||
| @@ -269,5 +261,5 @@ enum irdma_status_code irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, · 22 unmodified lines | |||
| 269 | } | 261 | } |
| 270 | } | 262 | } |
| 271 | 263 | ||
| 272 | return IRDMA_ERR_PARAM; | 264 | return -EINVAL; |
| 273 | } | 265 | } |
| @@ -32,56 +32,54 @@ struct irdma_sc_ah { · 31 unmodified lines | |||
| 32 | struct irdma_ah_info ah_info; | 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, | 35 | int irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx, |
| 36 | struct irdma_mcast_grp_ctx_entry_info *mg); | 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, | 37 | int irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx, |
| 38 | struct irdma_mcast_grp_ctx_entry_info *mg); | 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, | 39 | int irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info, |
| 40 | u32 op, u64 scratch); | 40 | u32 op, u64 scratch); |
| 41 | enum irdma_status_code irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, | 41 | int irdma_access_mcast_grp(struct irdma_sc_cqp *cqp, |
| 42 | struct irdma_mcast_grp_info *info, | 42 | struct irdma_mcast_grp_info *info, u32 op, |
| 43 | u32 op, u64 scratch); | 43 | u64 scratch); |
| 44 | 44 | ||
| 45 | static inline void irdma_sc_init_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah) | 45 | static inline void irdma_sc_init_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah) |
| 46 | { | 46 | { |
| 47 | ah->dev = dev; | 47 | ah->dev = dev; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static inline enum irdma_status_code irdma_sc_create_ah(struct irdma_sc_cqp *cqp, | 50 | static inline int irdma_sc_create_ah(struct irdma_sc_cqp *cqp, |
| 51 | struct irdma_ah_info *info, | 51 | struct irdma_ah_info *info, u64 scratch) |
| 52 | u64 scratch) | ||
| 53 | { | 52 | { |
| 54 | return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_CREATE_ADDR_HANDLE, | 53 | return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_CREATE_ADDR_HANDLE, |
| 55 | scratch); | 54 | scratch); |
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | static inline enum irdma_status_code irdma_sc_destroy_ah(struct irdma_sc_cqp *cqp, | 57 | static inline int irdma_sc_destroy_ah(struct irdma_sc_cqp *cqp, |
| 59 | struct irdma_ah_info *info, | 58 | struct irdma_ah_info *info, u64 scratch) |
| 60 | u64 scratch) | ||
| 61 | { | 59 | { |
| 62 | return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_DESTROY_ADDR_HANDLE, | 60 | return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_DESTROY_ADDR_HANDLE, |
| 63 | scratch); | 61 | scratch); |
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | static inline enum irdma_status_code irdma_sc_create_mcast_grp(struct irdma_sc_cqp *cqp, | 64 | static inline int irdma_sc_create_mcast_grp(struct irdma_sc_cqp *cqp, |
| 67 | struct irdma_mcast_grp_info *info, | 65 | struct irdma_mcast_grp_info *info, |
| 68 | u64 scratch) | 66 | u64 scratch) |
| 69 | { | 67 | { |
| 70 | return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_CREATE_MCAST_GRP, | 68 | return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_CREATE_MCAST_GRP, |
| 71 | scratch); | 69 | scratch); |
| 72 | } | 70 | } |
| 73 | 71 | ||
| 74 | static inline enum irdma_status_code irdma_sc_modify_mcast_grp(struct irdma_sc_cqp *cqp, | 72 | static inline int irdma_sc_modify_mcast_grp(struct irdma_sc_cqp *cqp, |
| 75 | struct irdma_mcast_grp_info *info, | 73 | struct irdma_mcast_grp_info *info, |
| 76 | u64 scratch) | 74 | u64 scratch) |
| 77 | { | 75 | { |
| 78 | return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_MODIFY_MCAST_GRP, | 76 | return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_MODIFY_MCAST_GRP, |
| 79 | scratch); | 77 | scratch); |
| 80 | } | 78 | } |
| 81 | 79 | ||
| 82 | static inline enum irdma_status_code irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp *cqp, | 80 | static inline int irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp *cqp, |
| 83 | struct irdma_mcast_grp_info *info, | 81 | struct irdma_mcast_grp_info *info, |
| 84 | u64 scratch) | 82 | u64 scratch) |
| 85 | { | 83 | { |
| 86 | return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_DESTROY_MCAST_GRP, | 84 | return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_DESTROY_MCAST_GRP, |
| 87 | scratch); | 85 | scratch); |
| @@ -1,7 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB | 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB |
| 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ | 2 | /* Copyright (c) 2015 - 2021 Intel Corporation */ |
| 3 | #include "osdep.h" | 3 | #include "osdep.h" |
| 4 | #include "status.h" | ||
| 5 | #include "defs.h" | 4 | #include "defs.h" |
| 6 | #include "user.h" | 5 | #include "user.h" |
| 7 | #include "irdma.h" | 6 | #include "irdma.h" |
| @@ -56,7 +55,7 @@ static void irdma_set_fragment_gen_1(__le64 *wqe, u32 offset, · 48 unmodified lines | |||
| 56 | * irdma_nop_1 - insert a NOP wqe | 55 | * irdma_nop_1 - insert a NOP wqe |
| 57 | * @qp: hw qp ptr | 56 | * @qp: hw qp ptr |
| 58 | */ | 57 | */ |
| 59 | static enum irdma_status_code irdma_nop_1(struct irdma_qp_uk *qp) | 58 | static int irdma_nop_1(struct irdma_qp_uk *qp) |
| 60 | { | 59 | { |
| 61 | u64 hdr; | 60 | u64 hdr; |
| 62 | __le64 *wqe; | 61 | __le64 *wqe; |
| @@ -64,7 +63,7 @@ static enum irdma_status_code irdma_nop_1(struct irdma_qp_uk *qp) · 1 unmodified line | |||
| 64 | bool signaled = false; | 63 | bool signaled = false; |
| 65 | 64 | ||
| 66 | if (!qp->sq_ring.head) | 65 | if (!qp->sq_ring.head) |
| 67 | return IRDMA_ERR_PARAM; | 66 | return -EINVAL; |
| 68 | 67 | ||
| 69 | wqe_idx = IRDMA_RING_CURRENT_HEAD(qp->sq_ring); | 68 | wqe_idx = IRDMA_RING_CURRENT_HEAD(qp->sq_ring); |
| 70 | wqe = qp->sq_base[wqe_idx].elem; | 69 | wqe = qp->sq_base[wqe_idx].elem; |
| @@ -245,7 +244,7 @@ __le64 *irdma_qp_get_next_send_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx, · 174 unmodified lines | |||
| 245 | __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx) | 244 | __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx) |
| 246 | { | 245 | { |
| 247 | __le64 *wqe; | 246 | __le64 *wqe; |
| 248 | enum irdma_status_code ret_code; | 247 | int ret_code; |
| 249 | 248 | ||
| 250 | if (IRDMA_RING_FULL_ERR(qp->rq_ring)) | 249 | if (IRDMA_RING_FULL_ERR(qp->rq_ring)) |
| 251 | return NULL; | 250 | return NULL; |
| @@ -268,16 +267,15 @@ __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx) · 16 unmodified lines | |||
| 268 | * @info: post sq information | 267 | * @info: post sq information |
| 269 | * @post_sq: flag to post sq | 268 | * @post_sq: flag to post sq |
| 270 | */ | 269 | */ |
| 271 | enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, | 270 | int irdma_uk_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, |
| 272 | struct irdma_post_sq_info *info, | 271 | bool post_sq) |
| 273 | bool post_sq) | ||
| 274 | { | 272 | { |
| 275 | u64 hdr; | 273 | u64 hdr; |
| 276 | __le64 *wqe; | 274 | __le64 *wqe; |
| 277 | struct irdma_rdma_write *op_info; | 275 | struct irdma_rdma_write *op_info; |
| 278 | u32 i, wqe_idx; | 276 | u32 i, wqe_idx; |
| 279 | u32 total_size = 0, byte_off; | 277 | u32 total_size = 0, byte_off; |
| 280 | enum irdma_status_code ret_code; | 278 | int ret_code; |
| 281 | u32 frag_cnt, addl_frag_cnt; | 279 | u32 frag_cnt, addl_frag_cnt; |
| 282 | bool read_fence = false; | 280 | bool read_fence = false; |
| 283 | u16 quanta; | 281 | u16 quanta; |
| @@ -286,7 +284,7 @@ enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, · 2 unmodified lines | |||
| 286 | 284 | ||
| 287 | op_info = &info->op.rdma_write; | 285 | op_info = &info->op.rdma_write; |
| 288 | if (op_info->num_lo_sges > qp->max_sq_frag_cnt) | 286 | if (op_info->num_lo_sges > qp->max_sq_frag_cnt) |
| 289 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 287 | return -EINVAL; |
| 290 | 288 | ||
| 291 | for (i = 0; i < op_info->num_lo_sges; i++) | 289 | for (i = 0; i < op_info->num_lo_sges; i++) |
| 292 | total_size += op_info->lo_sg_list[i].length; | 290 | total_size += op_info->lo_sg_list[i].length; |
| @@ -305,7 +303,7 @@ enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, · 12 unmodified lines | |||
| 305 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, | 303 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, |
| 306 | info); | 304 | info); |
| 307 | if (!wqe) | 305 | if (!wqe) |
| 308 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 306 | return -ENOMEM; |
| 309 | 307 | ||
| 310 | irdma_clr_wqes(qp, wqe_idx); | 308 | irdma_clr_wqes(qp, wqe_idx); |
| 311 | 309 | ||
| @@ -370,12 +368,11 @@ enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, · 58 unmodified lines | |||
| 370 | * @inv_stag: flag for inv_stag | 368 | * @inv_stag: flag for inv_stag |
| 371 | * @post_sq: flag to post sq | 369 | * @post_sq: flag to post sq |
| 372 | */ | 370 | */ |
| 373 | enum irdma_status_code irdma_uk_rdma_read(struct irdma_qp_uk *qp, | 371 | int irdma_uk_rdma_read(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, |
| 374 | struct irdma_post_sq_info *info, | 372 | bool inv_stag, bool post_sq) |
| 375 | bool inv_stag, bool post_sq) | ||
| 376 | { | 373 | { |
| 377 | struct irdma_rdma_read *op_info; | 374 | struct irdma_rdma_read *op_info; |
| 378 | enum irdma_status_code ret_code; | 375 | int ret_code; |
| 379 | u32 i, byte_off, total_size = 0; | 376 | u32 i, byte_off, total_size = 0; |
| 380 | bool local_fence = false; | 377 | bool local_fence = false; |
| 381 | u32 addl_frag_cnt; | 378 | u32 addl_frag_cnt; |
| @@ -388,7 +385,7 @@ enum irdma_status_code irdma_uk_rdma_read(struct irdma_qp_uk *qp, · 6 unmodified lines | |||
| 388 | 385 | ||
| 389 | op_info = &info->op.rdma_read; | 386 | op_info = &info->op.rdma_read; |
| 390 | if (qp->max_sq_frag_cnt < op_info->num_lo_sges) | 387 | if (qp->max_sq_frag_cnt < op_info->num_lo_sges) |
| 391 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 388 | return -EINVAL; |
| 392 | 389 | ||
| 393 | for (i = 0; i < op_info->num_lo_sges; i++) | 390 | for (i = 0; i < op_info->num_lo_sges; i++) |
| 394 | total_size += op_info->lo_sg_list[i].length; | 391 | total_size += op_info->lo_sg_list[i].length; |
| @@ -400,7 +397,7 @@ enum irdma_status_code irdma_uk_rdma_read(struct irdma_qp_uk *qp, · 5 unmodified lines | |||
| 400 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, | 397 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, |
| 401 | info); | 398 | info); |
| 402 | if (!wqe) | 399 | if (!wqe) |
| 403 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 400 | return -ENOMEM; |
| 404 | 401 | ||
| 405 | irdma_clr_wqes(qp, wqe_idx); | 402 | irdma_clr_wqes(qp, wqe_idx); |
| 406 | 403 | ||
| @@ -457,15 +454,14 @@ enum irdma_status_code irdma_uk_rdma_read(struct irdma_qp_uk *qp, · 50 unmodified lines | |||
| 457 | * @info: post sq information | 454 | * @info: post sq information |
| 458 | * @post_sq: flag to post sq | 455 | * @post_sq: flag to post sq |
| 459 | */ | 456 | */ |
| 460 | enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp, | 457 | int irdma_uk_send(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, |
| 461 | struct irdma_post_sq_info *info, | 458 | bool post_sq) |
| 462 | bool post_sq) | ||
| 463 | { | 459 | { |
| 464 | __le64 *wqe; | 460 | __le64 *wqe; |
| 465 | struct irdma_post_send *op_info; | 461 | struct irdma_post_send *op_info; |
| 466 | u64 hdr; | 462 | u64 hdr; |
| 467 | u32 i, wqe_idx, total_size = 0, byte_off; | 463 | u32 i, wqe_idx, total_size = 0, byte_off; |
| 468 | enum irdma_status_code ret_code; | 464 | int ret_code; |
| 469 | u32 frag_cnt, addl_frag_cnt; | 465 | u32 frag_cnt, addl_frag_cnt; |
| 470 | bool read_fence = false; | 466 | bool read_fence = false; |
| 471 | u16 quanta; | 467 | u16 quanta; |
| @@ -474,7 +470,7 @@ enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp, · 2 unmodified lines | |||
| 474 | 470 | ||
| 475 | op_info = &info->op.send; | 471 | op_info = &info->op.send; |
| 476 | if (qp->max_sq_frag_cnt < op_info->num_sges) | 472 | if (qp->max_sq_frag_cnt < op_info->num_sges) |
| 477 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 473 | return -EINVAL; |
| 478 | 474 | ||
| 479 | for (i = 0; i < op_info->num_sges; i++) | 475 | for (i = 0; i < op_info->num_sges; i++) |
| 480 | total_size += op_info->sg_list[i].length; | 476 | total_size += op_info->sg_list[i].length; |
| @@ -490,7 +486,7 @@ enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp, · 9 unmodified lines | |||
| 490 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, | 486 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, total_size, |
| 491 | info); | 487 | info); |
| 492 | if (!wqe) | 488 | if (!wqe) |
| 493 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 489 | return -ENOMEM; |
| 494 | 490 | ||
| 495 | irdma_clr_wqes(qp, wqe_idx); | 491 | irdma_clr_wqes(qp, wqe_idx); |
| 496 | 492 | ||
| @@ -678,9 +674,8 @@ static u16 irdma_inline_data_size_to_quanta(u32 data_size) · 181 unmodified lines | |||
| 678 | * @info: post sq information | 674 | * @info: post sq information |
| 679 | * @post_sq: flag to post sq | 675 | * @post_sq: flag to post sq |
| 680 | */ | 676 | */ |
| 681 | enum irdma_status_code | 677 | int irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, |
| 682 | irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, | 678 | struct irdma_post_sq_info *info, bool post_sq) |
| 683 | bool post_sq) | ||
| 684 | { | 679 | { |
| 685 | __le64 *wqe; | 680 | __le64 *wqe; |
| 686 | struct irdma_inline_rdma_write *op_info; | 681 | struct irdma_inline_rdma_write *op_info; |
| @@ -693,13 +688,13 @@ irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *in · 6 unmodified lines | |||
| 693 | op_info = &info->op.inline_rdma_write; | 688 | op_info = &info->op.inline_rdma_write; |
| 694 | 689 | ||
| 695 | if (op_info->len > qp->max_inline_data) | 690 | if (op_info->len > qp->max_inline_data) |
| 696 | return IRDMA_ERR_INVALID_INLINE_DATA_SIZE; | 691 | return -EINVAL; |
| 697 | 692 | ||
| 698 | quanta = qp->wqe_ops.iw_inline_data_size_to_quanta(op_info->len); | 693 | quanta = qp->wqe_ops.iw_inline_data_size_to_quanta(op_info->len); |
| 699 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, op_info->len, | 694 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, op_info->len, |
| 700 | info); | 695 | info); |
| 701 | if (!wqe) | 696 | if (!wqe) |
| 702 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 697 | return -ENOMEM; |
| 703 | 698 | ||
| 704 | irdma_clr_wqes(qp, wqe_idx); | 699 | irdma_clr_wqes(qp, wqe_idx); |
| 705 | 700 | ||
| @@ -745,9 +740,8 @@ irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *in · 39 unmodified lines | |||
| 745 | * @info: post sq information | 740 | * @info: post sq information |
| 746 | * @post_sq: flag to post sq | 741 | * @post_sq: flag to post sq |
| 747 | */ | 742 | */ |
| 748 | enum irdma_status_code irdma_uk_inline_send(struct irdma_qp_uk *qp, | 743 | int irdma_uk_inline_send(struct irdma_qp_uk *qp, |
| 749 | struct irdma_post_sq_info *info, | 744 | struct irdma_post_sq_info *info, bool post_sq) |
| 750 | bool post_sq) | ||
| 751 | { | 745 | { |
| 752 | __le64 *wqe; | 746 | __le64 *wqe; |
| 753 | struct irdma_post_inline_send *op_info; | 747 | struct irdma_post_inline_send *op_info; |
| @@ -760,13 +754,13 @@ enum irdma_status_code irdma_uk_inline_send(struct irdma_qp_uk *qp, · 6 unmodified lines | |||
| 760 | op_info = &info->op.inline_send; | 754 | op_info = &info->op.inline_send; |
| 761 | 755 | ||
| 762 | if (op_info->len > qp->max_inline_data) | 756 | if (op_info->len > qp->max_inline_data) |
| 763 | return IRDMA_ERR_INVALID_INLINE_DATA_SIZE; | 757 | return -EINVAL; |
| 764 | 758 | ||
| 765 | quanta = qp->wqe_ops.iw_inline_data_size_to_quanta(op_info->len); | 759 | quanta = qp->wqe_ops.iw_inline_data_size_to_quanta(op_info->len); |
| 766 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, op_info->len, | 760 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, quanta, op_info->len, |
| 767 | info); | 761 | info); |
| 768 | if (!wqe) | 762 | if (!wqe) |
| 769 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 763 | return -ENOMEM; |
| 770 | 764 | ||
| 771 | irdma_clr_wqes(qp, wqe_idx); | 765 | irdma_clr_wqes(qp, wqe_idx); |
| 772 | 766 | ||
| @@ -817,9 +811,9 @@ enum irdma_status_code irdma_uk_inline_send(struct irdma_qp_uk *qp, · 44 unmodified lines | |||
| 817 | * @info: post sq information | 811 | * @info: post sq information |
| 818 | * @post_sq: flag to post sq | 812 | * @post_sq: flag to post sq |
| 819 | */ | 813 | */ |
| 820 | enum irdma_status_code | 814 | int irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, |
| 821 | irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, | 815 | struct irdma_post_sq_info *info, |
| 822 | struct irdma_post_sq_info *info, bool post_sq) | 816 | bool post_sq) |
| 823 | { | 817 | { |
| 824 | __le64 *wqe; | 818 | __le64 *wqe; |
| 825 | struct irdma_inv_local_stag *op_info; | 819 | struct irdma_inv_local_stag *op_info; |
| @@ -835,7 +829,7 @@ irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, · 9 unmodified lines | |||
| 835 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, IRDMA_QP_WQE_MIN_QUANTA, | 829 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, IRDMA_QP_WQE_MIN_QUANTA, |
| 836 | 0, info); | 830 | 0, info); |
| 837 | if (!wqe) | 831 | if (!wqe) |
| 838 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 832 | return -ENOMEM; |
| 839 | 833 | ||
| 840 | irdma_clr_wqes(qp, wqe_idx); | 834 | irdma_clr_wqes(qp, wqe_idx); |
| 841 | 835 | ||
| @@ -871,8 +865,8 @@ irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, · 29 unmodified lines | |||
| 871 | * @qp: hw qp ptr | 865 | * @qp: hw qp ptr |
| 872 | * @info: post rq information | 866 | * @info: post rq information |
| 873 | */ | 867 | */ |
| 874 | enum irdma_status_code irdma_uk_post_receive(struct irdma_qp_uk *qp, | 868 | int irdma_uk_post_receive(struct irdma_qp_uk *qp, |
| 875 | struct irdma_post_rq_info *info) | 869 | struct irdma_post_rq_info *info) |
| 876 | { | 870 | { |
| 877 | u32 wqe_idx, i, byte_off; | 871 | u32 wqe_idx, i, byte_off; |
| 878 | u32 addl_frag_cnt; | 872 | u32 addl_frag_cnt; |
| @@ -880,11 +874,11 @@ enum irdma_status_code irdma_uk_post_receive(struct irdma_qp_uk *qp, · 1 unmodified line | |||
| 880 | u64 hdr; | 874 | u64 hdr; |
| 881 | 875 | ||
| 882 | if (qp->max_rq_frag_cnt < info->num_sges) | 876 | if (qp->max_rq_frag_cnt < info->num_sges) |
| 883 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 877 | return -EINVAL; |
| 884 | 878 | ||
| 885 | wqe = irdma_qp_get_next_recv_wqe(qp, &wqe_idx); | 879 | wqe = irdma_qp_get_next_recv_wqe(qp, &wqe_idx); |
| 886 | if (!wqe) | 880 | if (!wqe) |
| 887 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 881 | return -ENOMEM; |
| 888 | 882 | ||
| 889 | qp->rq_wrid_array[wqe_idx] = info->wr_id; | 883 | qp->rq_wrid_array[wqe_idx] = info->wr_id; |
| 890 | addl_frag_cnt = info->num_sges > 1 ? (info->num_sges - 1) : 0; | 884 | addl_frag_cnt = info->num_sges > 1 ? (info->num_sges - 1) : 0; |
| @@ -1000,15 +994,15 @@ void irdma_uk_cq_request_notification(struct irdma_cq_uk *cq, · 109 unmodified lines | |||
| 1000 | * @cq: hw cq | 994 | * @cq: hw cq |
| 1001 | * @info: cq poll information returned | 995 | * @info: cq poll information returned |
| 1002 | */ | 996 | */ |
| 1003 | enum irdma_status_code | 997 | int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, |
| 1004 | irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) | 998 | struct irdma_cq_poll_info *info) |
| 1005 | { | 999 | { |
| 1006 | u64 comp_ctx, qword0, qword2, qword3; | 1000 | u64 comp_ctx, qword0, qword2, qword3; |
| 1007 | __le64 *cqe; | 1001 | __le64 *cqe; |
| 1008 | struct irdma_qp_uk *qp; | 1002 | struct irdma_qp_uk *qp; |
| 1009 | struct irdma_ring *pring = NULL; | 1003 | struct irdma_ring *pring = NULL; |
| 1010 | u32 wqe_idx, q_type; | 1004 | u32 wqe_idx, q_type; |
| 1011 | enum irdma_status_code ret_code; | 1005 | int ret_code; |
| 1012 | bool move_cq_head = true; | 1006 | bool move_cq_head = true; |
| 1013 | u8 polarity; | 1007 | u8 polarity; |
| 1014 | bool ext_valid; | 1008 | bool ext_valid; |
| @@ -1022,7 +1016,7 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) · 7 unmodified lines | |||
| 1022 | get_64bit_val(cqe, 24, &qword3); | 1016 | get_64bit_val(cqe, 24, &qword3); |
| 1023 | polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3); | 1017 | polarity = (u8)FIELD_GET(IRDMA_CQ_VALID, qword3); |
| 1024 | if (polarity != cq->polarity) | 1018 | if (polarity != cq->polarity) |
| 1025 | return IRDMA_ERR_Q_EMPTY; | 1019 | return -ENOENT; |
| 1026 | 1020 | ||
| 1027 | /* Ensure CQE contents are read after valid bit is checked */ | 1021 | /* Ensure CQE contents are read after valid bit is checked */ |
| 1028 | dma_rmb(); | 1022 | dma_rmb(); |
| @@ -1045,7 +1039,7 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) · 16 unmodified lines | |||
| 1045 | polarity ^= 1; | 1039 | polarity ^= 1; |
| 1046 | } | 1040 | } |
| 1047 | if (polarity != cq->polarity) | 1041 | if (polarity != cq->polarity) |
| 1048 | return IRDMA_ERR_Q_EMPTY; | 1042 | return -ENOENT; |
| 1049 | 1043 | ||
| 1050 | /* Ensure ext CQE contents are read after ext valid bit is checked */ | 1044 | /* Ensure ext CQE contents are read after ext valid bit is checked */ |
| 1051 | dma_rmb(); | 1045 | dma_rmb(); |
| @@ -1112,7 +1106,7 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) · 60 unmodified lines | |||
| 1112 | info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3); | 1106 | info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3); |
| 1113 | qp = (struct irdma_qp_uk *)(unsigned long)comp_ctx; | 1107 | qp = (struct irdma_qp_uk *)(unsigned long)comp_ctx; |
| 1114 | if (!qp || qp->destroy_pending) { | 1108 | if (!qp || qp->destroy_pending) { |
| 1115 | ret_code = IRDMA_ERR_Q_DESTROYED; | 1109 | ret_code = -EFAULT; |
| 1116 | goto exit; | 1110 | goto exit; |
| 1117 | } | 1111 | } |
| 1118 | wqe_idx = (u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3); | 1112 | wqe_idx = (u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3); |
| @@ -1126,7 +1120,7 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) · 7 unmodified lines | |||
| 1126 | if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED || | 1120 | if (info->comp_status == IRDMA_COMPL_STATUS_FLUSHED || |
| 1127 | info->comp_status == IRDMA_COMPL_STATUS_UNKNOWN) { | 1121 | info->comp_status == IRDMA_COMPL_STATUS_UNKNOWN) { |
| 1128 | if (!IRDMA_RING_MORE_WORK(qp->rq_ring)) { | 1122 | if (!IRDMA_RING_MORE_WORK(qp->rq_ring)) { |
| 1129 | ret_code = IRDMA_ERR_Q_EMPTY; | 1123 | ret_code = -ENOENT; |
| 1130 | goto exit; | 1124 | goto exit; |
| 1131 | } | 1125 | } |
| 1132 | 1126 | ||
| @@ -1186,7 +1180,7 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, struct irdma_cq_poll_info *info) · 53 unmodified lines | |||
| 1186 | wqe_idx + qp->sq_wrtrk_array[wqe_idx].quanta); | 1180 | wqe_idx + qp->sq_wrtrk_array[wqe_idx].quanta); |
| 1187 | } else { | 1181 | } else { |
| 1188 | if (!IRDMA_RING_MORE_WORK(qp->sq_ring)) { | 1182 | if (!IRDMA_RING_MORE_WORK(qp->sq_ring)) { |
| 1189 | ret_code = IRDMA_ERR_Q_EMPTY; | 1183 | ret_code = -ENOENT; |
| 1190 | goto exit; | 1184 | goto exit; |
| 1191 | } | 1185 | } |
| 1192 | 1186 | ||
| @@ -1303,15 +1297,15 @@ void irdma_get_wqe_shift(struct irdma_uk_attrs *uk_attrs, u32 sge, · 110 unmodified lines | |||
| 1303 | * @sqdepth: depth of SQ | 1297 | * @sqdepth: depth of SQ |
| 1304 | * | 1298 | * |
| 1305 | */ | 1299 | */ |
| 1306 | enum irdma_status_code irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, | 1300 | int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift, |
| 1307 | u32 sq_size, u8 shift, u32 *sqdepth) | 1301 | u32 *sqdepth) |
| 1308 | { | 1302 | { |
| 1309 | *sqdepth = irdma_qp_round_up((sq_size << shift) + IRDMA_SQ_RSVD); | 1303 | *sqdepth = irdma_qp_round_up((sq_size << shift) + IRDMA_SQ_RSVD); |
| 1310 | 1304 | ||
| 1311 | if (*sqdepth < (IRDMA_QP_SW_MIN_WQSIZE << shift)) | 1305 | if (*sqdepth < (IRDMA_QP_SW_MIN_WQSIZE << shift)) |
| 1312 | *sqdepth = IRDMA_QP_SW_MIN_WQSIZE << shift; | 1306 | *sqdepth = IRDMA_QP_SW_MIN_WQSIZE << shift; |
| 1313 | else if (*sqdepth > uk_attrs->max_hw_wq_quanta) | 1307 | else if (*sqdepth > uk_attrs->max_hw_wq_quanta) |
| 1314 | return IRDMA_ERR_INVALID_SIZE; | 1308 | return -EINVAL; |
| 1315 | 1309 | ||
| 1316 | return 0; | 1310 | return 0; |
| 1317 | } | 1311 | } |
| @@ -1323,15 +1317,15 @@ enum irdma_status_code irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, · 5 unmodified lines | |||
| 1323 | * @shift: shift which determines size of WQE | 1317 | * @shift: shift which determines size of WQE |
| 1324 | * @rqdepth: depth of RQ | 1318 | * @rqdepth: depth of RQ |
| 1325 | */ | 1319 | */ |
| 1326 | enum irdma_status_code irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, | 1320 | int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift, |
| 1327 | u32 rq_size, u8 shift, u32 *rqdepth) | 1321 | u32 *rqdepth) |
| 1328 | { | 1322 | { |
| 1329 | *rqdepth = irdma_qp_round_up((rq_size << shift) + IRDMA_RQ_RSVD); | 1323 | *rqdepth = irdma_qp_round_up((rq_size << shift) + IRDMA_RQ_RSVD); |
| 1330 | 1324 | ||
| 1331 | if (*rqdepth < (IRDMA_QP_SW_MIN_WQSIZE << shift)) | 1325 | if (*rqdepth < (IRDMA_QP_SW_MIN_WQSIZE << shift)) |
| 1332 | *rqdepth = IRDMA_QP_SW_MIN_WQSIZE << shift; | 1326 | *rqdepth = IRDMA_QP_SW_MIN_WQSIZE << shift; |
| 1333 | else if (*rqdepth > uk_attrs->max_hw_rq_quanta) | 1327 | else if (*rqdepth > uk_attrs->max_hw_rq_quanta) |
| 1334 | return IRDMA_ERR_INVALID_SIZE; | 1328 | return -EINVAL; |
| 1335 | 1329 | ||
| 1336 | return 0; | 1330 | return 0; |
| 1337 | } | 1331 | } |
| @@ -1381,17 +1375,16 @@ static void irdma_setup_connection_wqes(struct irdma_qp_uk *qp, · 43 unmodified lines | |||
| 1381 | * allowed. Then size of wqe * the number of wqes should be the | 1375 | * allowed. Then size of wqe * the number of wqes should be the |
| 1382 | * amount of memory allocated for sq and rq. | 1376 | * amount of memory allocated for sq and rq. |
| 1383 | */ | 1377 | */ |
| 1384 | enum irdma_status_code irdma_uk_qp_init(struct irdma_qp_uk *qp, | 1378 | int irdma_uk_qp_init(struct irdma_qp_uk *qp, struct irdma_qp_uk_init_info *info) |
| 1385 | struct irdma_qp_uk_init_info *info) | ||
| 1386 | { | 1379 | { |
| 1387 | enum irdma_status_code ret_code = 0; | 1380 | int ret_code = 0; |
| 1388 | u32 sq_ring_size; | 1381 | u32 sq_ring_size; |
| 1389 | u8 sqshift, rqshift; | 1382 | u8 sqshift, rqshift; |
| 1390 | 1383 | ||
| 1391 | qp->uk_attrs = info->uk_attrs; | 1384 | qp->uk_attrs = info->uk_attrs; |
| 1392 | if (info->max_sq_frag_cnt > qp->uk_attrs->max_hw_wq_frags || | 1385 | if (info->max_sq_frag_cnt > qp->uk_attrs->max_hw_wq_frags || |
| 1393 | info->max_rq_frag_cnt > qp->uk_attrs->max_hw_wq_frags) | 1386 | info->max_rq_frag_cnt > qp->uk_attrs->max_hw_wq_frags) |
| 1394 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 1387 | return -EINVAL; |
| 1395 | 1388 | ||
| 1396 | irdma_get_wqe_shift(qp->uk_attrs, info->max_rq_frag_cnt, 0, &rqshift); | 1389 | irdma_get_wqe_shift(qp->uk_attrs, info->max_rq_frag_cnt, 0, &rqshift); |
| 1397 | if (qp->uk_attrs->hw_rev == IRDMA_GEN_1) { | 1390 | if (qp->uk_attrs->hw_rev == IRDMA_GEN_1) { |
| @@ -1502,8 +1495,7 @@ void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq) · 104 unmodified lines | |||
| 1502 | * @signaled: signaled for completion | 1495 | * @signaled: signaled for completion |
| 1503 | * @post_sq: ring doorbell | 1496 | * @post_sq: ring doorbell |
| 1504 | */ | 1497 | */ |
| 1505 | enum irdma_status_code irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, | 1498 | int irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, bool post_sq) |
| 1506 | bool signaled, bool post_sq) | ||
| 1507 | { | 1499 | { |
| 1508 | __le64 *wqe; | 1500 | __le64 *wqe; |
| 1509 | u64 hdr; | 1501 | u64 hdr; |
| @@ -1515,7 +1507,7 @@ enum irdma_status_code irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, · 5 unmodified lines | |||
| 1515 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, IRDMA_QP_WQE_MIN_QUANTA, | 1507 | wqe = irdma_qp_get_next_send_wqe(qp, &wqe_idx, IRDMA_QP_WQE_MIN_QUANTA, |
| 1516 | 0, &info); | 1508 | 0, &info); |
| 1517 | if (!wqe) | 1509 | if (!wqe) |
| 1518 | return IRDMA_ERR_QP_TOOMANY_WRS_POSTED; | 1510 | return -ENOMEM; |
| 1519 | 1511 | ||
| 1520 | irdma_clr_wqes(qp, wqe_idx); | 1512 | irdma_clr_wqes(qp, wqe_idx); |
| 1521 | 1513 | ||
| @@ -1541,7 +1533,7 @@ enum irdma_status_code irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, · 19 unmodified lines | |||
| 1541 | * @frag_cnt: number of fragments | 1533 | * @frag_cnt: number of fragments |
| 1542 | * @quanta: quanta for frag_cnt | 1534 | * @quanta: quanta for frag_cnt |
| 1543 | */ | 1535 | */ |
| 1544 | enum irdma_status_code irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta) | 1536 | int irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta) |
| 1545 | { | 1537 | { |
| 1546 | switch (frag_cnt) { | 1538 | switch (frag_cnt) { |
| 1547 | case 0: | 1539 | case 0: |
| @@ -1577,7 +1569,7 @@ enum irdma_status_code irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta) · 29 unmodified lines | |||
| 1577 | *quanta = 8; | 1569 | *quanta = 8; |
| 1578 | break; | 1570 | break; |
| 1579 | default: | 1571 | default: |
| 1580 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 1572 | return -EINVAL; |
| 1581 | } | 1573 | } |
| 1582 | 1574 | ||
| 1583 | return 0; | 1575 | return 0; |
| @@ -1588,7 +1580,7 @@ enum irdma_status_code irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta) · 4 unmodified lines | |||
| 1588 | * @frag_cnt: number of fragments | 1580 | * @frag_cnt: number of fragments |
| 1589 | * @wqe_size: size in bytes given frag_cnt | 1581 | * @wqe_size: size in bytes given frag_cnt |
| 1590 | */ | 1582 | */ |
| 1591 | enum irdma_status_code irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size) | 1583 | int irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size) |
| 1592 | { | 1584 | { |
| 1593 | switch (frag_cnt) { | 1585 | switch (frag_cnt) { |
| 1594 | case 0: | 1586 | case 0: |
| @@ -1615,7 +1607,7 @@ enum irdma_status_code irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size) · 20 unmodified lines | |||
| 1615 | *wqe_size = 256; | 1607 | *wqe_size = 256; |
| 1616 | break; | 1608 | break; |
| 1617 | default: | 1609 | default: |
| 1618 | return IRDMA_ERR_INVALID_FRAG_COUNT; | 1610 | return -EINVAL; |
| 1619 | } | 1611 | } |
| 1620 | 1612 | ||
| 1621 | return 0; | 1613 | return 0; |
| @@ -270,29 +270,24 @@ struct irdma_cq_poll_info { · 269 unmodified lines | |||
| 270 | bool imm_valid:1; | 270 | bool imm_valid:1; |
| 271 | }; | 271 | }; |
| 272 | 272 | ||
| 273 | enum irdma_status_code irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, | 273 | int irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp, |
| 274 | struct irdma_post_sq_info *info, | 274 | struct irdma_post_sq_info *info, bool post_sq); |
| 275 | bool post_sq); | 275 | int irdma_uk_inline_send(struct irdma_qp_uk *qp, |
| 276 | enum irdma_status_code irdma_uk_inline_send(struct irdma_qp_uk *qp, | 276 | struct irdma_post_sq_info *info, bool post_sq); |
| 277 | struct irdma_post_sq_info *info, | 277 | int irdma_uk_post_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, |
| 278 | bool post_sq); | 278 | bool post_sq); |
| 279 | 279 | int irdma_uk_post_receive(struct irdma_qp_uk *qp, | |
| 280 | enum irdma_status_code irdma_uk_post_nop(struct irdma_qp_uk *qp, u64 wr_id, | 280 | struct irdma_post_rq_info *info); |
| 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); | ||
| 284 | void irdma_uk_qp_post_wr(struct irdma_qp_uk *qp); | 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, | 282 | int irdma_uk_rdma_read(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, |
| 286 | struct irdma_post_sq_info *info, | 283 | bool inv_stag, bool post_sq); |
| 287 | bool inv_stag, bool post_sq); | 284 | int irdma_uk_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, |
| 288 | enum irdma_status_code irdma_uk_rdma_write(struct irdma_qp_uk *qp, | 285 | bool post_sq); |
| 289 | struct irdma_post_sq_info *info, | 286 | int irdma_uk_send(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info, |
| 290 | bool post_sq); | 287 | bool post_sq); |
| 291 | enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp, | 288 | int irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, |
| 292 | struct irdma_post_sq_info *info, bool post_sq); | 289 | struct irdma_post_sq_info *info, |
| 293 | enum irdma_status_code irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp, | 290 | bool post_sq); |
| 294 | struct irdma_post_sq_info *info, | ||
| 295 | bool post_sq); | ||
| 296 | 291 | ||
| 297 | struct irdma_wqe_uk_ops { | 292 | struct irdma_wqe_uk_ops { |
| 298 | void (*iw_copy_inline_data)(u8 *dest, u8 *src, u32 len, u8 polarity); | 293 | void (*iw_copy_inline_data)(u8 *dest, u8 *src, u32 len, u8 polarity); |
| @@ -303,16 +298,16 @@ struct irdma_wqe_uk_ops { · 4 unmodified lines | |||
| 303 | struct irdma_bind_window *op_info); | 298 | struct irdma_bind_window *op_info); |
| 304 | }; | 299 | }; |
| 305 | 300 | ||
| 306 | enum irdma_status_code irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, | 301 | int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq, |
| 307 | struct irdma_cq_poll_info *info); | 302 | struct irdma_cq_poll_info *info); |
| 308 | void irdma_uk_cq_request_notification(struct irdma_cq_uk *cq, | 303 | void irdma_uk_cq_request_notification(struct irdma_cq_uk *cq, |
| 309 | enum irdma_cmpl_notify cq_notify); | 304 | enum irdma_cmpl_notify cq_notify); |
| 310 | void irdma_uk_cq_resize(struct irdma_cq_uk *cq, void *cq_base, int size); | 305 | void irdma_uk_cq_resize(struct irdma_cq_uk *cq, void *cq_base, int size); |
| 311 | void irdma_uk_cq_set_resized_cnt(struct irdma_cq_uk *qp, u16 cnt); | 306 | void irdma_uk_cq_set_resized_cnt(struct irdma_cq_uk *qp, u16 cnt); |
| 312 | void irdma_uk_cq_init(struct irdma_cq_uk *cq, | 307 | void irdma_uk_cq_init(struct irdma_cq_uk *cq, |
| 313 | struct irdma_cq_uk_init_info *info); | 308 | struct irdma_cq_uk_init_info *info); |
| 314 | enum irdma_status_code irdma_uk_qp_init(struct irdma_qp_uk *qp, | 309 | int irdma_uk_qp_init(struct irdma_qp_uk *qp, |
| 315 | struct irdma_qp_uk_init_info *info); | 310 | struct irdma_qp_uk_init_info *info); |
| 316 | struct irdma_sq_uk_wr_trk_info { | 311 | struct irdma_sq_uk_wr_trk_info { |
| 317 | u64 wrid; | 312 | u64 wrid; |
| 318 | u32 wr_len; | 313 | u32 wr_len; |
| @@ -413,16 +408,15 @@ __le64 *irdma_qp_get_next_send_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx, · 94 unmodified lines | |||
| 413 | struct irdma_post_sq_info *info); | 408 | struct irdma_post_sq_info *info); |
| 414 | __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx); | 409 | __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx); |
| 415 | void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq); | 410 | void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq); |
| 416 | enum irdma_status_code irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, | 411 | int irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, bool post_sq); |
| 417 | bool signaled, bool post_sq); | 412 | int irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta); |
| 418 | enum irdma_status_code irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta); | 413 | int irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size); |
| 419 | enum irdma_status_code irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size); | ||
| 420 | void irdma_get_wqe_shift(struct irdma_uk_attrs *uk_attrs, u32 sge, | 414 | void irdma_get_wqe_shift(struct irdma_uk_attrs *uk_attrs, u32 sge, |
| 421 | u32 inline_data, u8 *shift); | 415 | u32 inline_data, u8 *shift); |
| 422 | enum irdma_status_code irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, | 416 | int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift, |
| 423 | u32 sq_size, u8 shift, u32 *wqdepth); | 417 | u32 *wqdepth); |
| 424 | enum irdma_status_code irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, | 418 | int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift, |
| 425 | u32 rq_size, u8 shift, u32 *wqdepth); | 419 | u32 *wqdepth); |
| 426 | void irdma_qp_push_wqe(struct irdma_qp_uk *qp, __le64 *wqe, u16 quanta, | 420 | void irdma_qp_push_wqe(struct irdma_qp_uk *qp, __le64 *wqe, u16 quanta, |
| 427 | u32 wqe_idx, bool post_sq); | 421 | u32 wqe_idx, bool post_sq); |
| 428 | void irdma_clr_wqes(struct irdma_qp_uk *qp, u32 qp_wqe_idx); | 422 | void irdma_clr_wqes(struct irdma_qp_uk *qp, u32 qp_wqe_idx); |
| @@ -150,31 +150,35 @@ int irdma_inetaddr_event(struct notifier_block *notifier, unsigned long event, · 149 unmodified lines | |||
| 150 | void *ptr) | 150 | void *ptr) |
| 151 | { | 151 | { |
| 152 | struct in_ifaddr *ifa = ptr; | 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 | struct irdma_device *iwdev; | 154 | struct irdma_device *iwdev; |
| 155 | struct ib_device *ibdev; | 155 | struct ib_device *ibdev; |
| 156 | u32 local_ipaddr; | 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 | if (!ibdev) | 163 | if (!ibdev) |
| 160 | return NOTIFY_DONE; | 164 | return NOTIFY_DONE; |
| 161 | 165 | ||
| 162 | iwdev = to_iwdev(ibdev); | 166 | iwdev = to_iwdev(ibdev); |
| 163 | local_ipaddr = ntohl(ifa->ifa_address); | 167 | local_ipaddr = ntohl(ifa->ifa_address); |
| 164 | ibdev_dbg(&iwdev->ibdev, | 168 | ibdev_dbg(&iwdev->ibdev, |
| 165 | "DEV: netdev %p event %lu local_ip=%pI4 MAC=%pM\n", netdev, | 169 | "DEV: netdev %p event %lu local_ip=%pI4 MAC=%pM\n", real_dev, |
| 166 | event, &local_ipaddr, netdev->dev_addr); | 170 | event, &local_ipaddr, real_dev->dev_addr); |
| 167 | switch (event) { | 171 | switch (event) { |
| 168 | case NETDEV_DOWN: | 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 | &local_ipaddr, true, IRDMA_ARP_DELETE); | 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 | irdma_gid_change_event(&iwdev->ibdev); | 176 | irdma_gid_change_event(&iwdev->ibdev); |
| 173 | break; | 177 | break; |
| 174 | case NETDEV_UP: | 178 | case NETDEV_UP: |
| 175 | case NETDEV_CHANGEADDR: | 179 | case NETDEV_CHANGEADDR: |
| 176 | irdma_add_arp(iwdev->rf, &local_ipaddr, true, netdev->dev_addr); | 180 | irdma_add_arp(iwdev->rf, &local_ipaddr, true, real_dev->dev_addr); |
| 177 | irdma_if_notify(iwdev, netdev, &local_ipaddr, true, true); | 181 | irdma_if_notify(iwdev, real_dev, &local_ipaddr, true, true); |
| 178 | irdma_gid_change_event(&iwdev->ibdev); | 182 | irdma_gid_change_event(&iwdev->ibdev); |
| 179 | break; | 183 | break; |
| 180 | default: | 184 | default: |
| @@ -196,32 +200,36 @@ int irdma_inet6addr_event(struct notifier_block *notifier, unsigned long event, · 15 unmodified lines | |||
| 196 | void *ptr) | 200 | void *ptr) |
| 197 | { | 201 | { |
| 198 | struct inet6_ifaddr *ifa = ptr; | 202 | struct inet6_ifaddr *ifa = ptr; |
| 199 | struct net_device *netdev = ifa->idev->dev; | 203 | struct net_device *real_dev, *netdev = ifa->idev->dev; |
| 200 | struct irdma_device *iwdev; | 204 | struct irdma_device *iwdev; |
| 201 | struct ib_device *ibdev; | 205 | struct ib_device *ibdev; |
| 202 | u32 local_ipaddr6[4]; | 206 | u32 local_ipaddr6[4]; |
| 203 | 207 | ||
| 204 | ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_IRDMA); | 208 | real_dev = rdma_vlan_dev_real_dev(netdev); |
| 209 | if (!real_dev) | ||
| 210 | real_dev = netdev; | ||
| 211 | |||
| 212 | ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); | ||
| 205 | if (!ibdev) | 213 | if (!ibdev) |
| 206 | return NOTIFY_DONE; | 214 | return NOTIFY_DONE; |
| 207 | 215 | ||
| 208 | iwdev = to_iwdev(ibdev); | 216 | iwdev = to_iwdev(ibdev); |
| 209 | irdma_copy_ip_ntohl(local_ipaddr6, ifa->addr.in6_u.u6_addr32); | 217 | irdma_copy_ip_ntohl(local_ipaddr6, ifa->addr.in6_u.u6_addr32); |
| 210 | ibdev_dbg(&iwdev->ibdev, | 218 | ibdev_dbg(&iwdev->ibdev, |
| 211 | "DEV: netdev %p event %lu local_ip=%pI6 MAC=%pM\n", netdev, | 219 | "DEV: netdev %p event %lu local_ip=%pI6 MAC=%pM\n", real_dev, |
| 212 | event, local_ipaddr6, netdev->dev_addr); | 220 | event, local_ipaddr6, real_dev->dev_addr); |
| 213 | switch (event) { | 221 | switch (event) { |
| 214 | case NETDEV_DOWN: | 222 | case NETDEV_DOWN: |
| 215 | irdma_manage_arp_cache(iwdev->rf, netdev->dev_addr, | 223 | irdma_manage_arp_cache(iwdev->rf, real_dev->dev_addr, |
| 216 | local_ipaddr6, false, IRDMA_ARP_DELETE); | 224 | local_ipaddr6, false, IRDMA_ARP_DELETE); |
| 217 | irdma_if_notify(iwdev, netdev, local_ipaddr6, false, false); | 225 | irdma_if_notify(iwdev, real_dev, local_ipaddr6, false, false); |
| 218 | irdma_gid_change_event(&iwdev->ibdev); | 226 | irdma_gid_change_event(&iwdev->ibdev); |
| 219 | break; | 227 | break; |
| 220 | case NETDEV_UP: | 228 | case NETDEV_UP: |
| 221 | case NETDEV_CHANGEADDR: | 229 | case NETDEV_CHANGEADDR: |
| 222 | irdma_add_arp(iwdev->rf, local_ipaddr6, false, | 230 | irdma_add_arp(iwdev->rf, local_ipaddr6, false, |
| 223 | netdev->dev_addr); | 231 | real_dev->dev_addr); |
| 224 | irdma_if_notify(iwdev, netdev, local_ipaddr6, false, true); | 232 | irdma_if_notify(iwdev, real_dev, local_ipaddr6, false, true); |
| 225 | irdma_gid_change_event(&iwdev->ibdev); | 233 | irdma_gid_change_event(&iwdev->ibdev); |
| 226 | break; | 234 | break; |
| 227 | default: | 235 | default: |
| @@ -243,14 +251,18 @@ int irdma_net_event(struct notifier_block *notifier, unsigned long event, · 15 unmodified lines | |||
| 243 | void *ptr) | 251 | void *ptr) |
| 244 | { | 252 | { |
| 245 | struct neighbour *neigh = ptr; | 253 | struct neighbour *neigh = ptr; |
| 254 | struct net_device *real_dev, *netdev = (struct net_device *)neigh->dev; | ||
| 246 | struct irdma_device *iwdev; | 255 | struct irdma_device *iwdev; |
| 247 | struct ib_device *ibdev; | 256 | struct ib_device *ibdev; |
| 248 | __be32 *p; | 257 | __be32 *p; |
| 249 | u32 local_ipaddr[4] = {}; | 258 | u32 local_ipaddr[4] = {}; |
| 250 | bool ipv4 = true; | 259 | bool ipv4 = true; |
| 251 | 260 | ||
| 252 | ibdev = ib_device_get_by_netdev((struct net_device *)neigh->dev, | 261 | real_dev = rdma_vlan_dev_real_dev(netdev); |
| 253 | RDMA_DRIVER_IRDMA); | 262 | if (!real_dev) |
| 263 | real_dev = netdev; | ||
| 264 | |||
| 265 | ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); | ||
| 254 | if (!ibdev) | 266 | if (!ibdev) |
| 255 | return NOTIFY_DONE; | 267 | return NOTIFY_DONE; |
| 256 | 268 | ||
| @@ -551,12 +563,12 @@ void irdma_cleanup_pending_cqp_op(struct irdma_pci_f *rf) · 294 unmodified lines | |||
| 551 | * @rf: RDMA PCI function | 563 | * @rf: RDMA PCI function |
| 552 | * @cqp_request: cqp request to wait | 564 | * @cqp_request: cqp request to wait |
| 553 | */ | 565 | */ |
| 554 | static enum irdma_status_code irdma_wait_event(struct irdma_pci_f *rf, | 566 | static int irdma_wait_event(struct irdma_pci_f *rf, |
| 555 | struct irdma_cqp_request *cqp_request) | 567 | struct irdma_cqp_request *cqp_request) |
| 556 | { | 568 | { |
| 557 | struct irdma_cqp_timeout cqp_timeout = {}; | 569 | struct irdma_cqp_timeout cqp_timeout = {}; |
| 558 | bool cqp_error = false; | 570 | bool cqp_error = false; |
| 559 | enum irdma_status_code err_code = 0; | 571 | int err_code = 0; |
| 560 | 572 | ||
| 561 | cqp_timeout.compl_cqp_cmds = rf->sc_dev.cqp_cmd_stats[IRDMA_OP_CMPL_CMDS]; | 573 | cqp_timeout.compl_cqp_cmds = rf->sc_dev.cqp_cmd_stats[IRDMA_OP_CMPL_CMDS]; |
| 562 | do { | 574 | do { |
| @@ -575,12 +587,12 @@ static enum irdma_status_code irdma_wait_event(struct irdma_pci_f *rf, · 12 unmodified lines | |||
| 575 | rf->reset = true; | 587 | rf->reset = true; |
| 576 | rf->gen_ops.request_reset(rf); | 588 | rf->gen_ops.request_reset(rf); |
| 577 | } | 589 | } |
| 578 | return IRDMA_ERR_TIMEOUT; | 590 | return -ETIMEDOUT; |
| 579 | } while (1); | 591 | } while (1); |
| 580 | 592 | ||
| 581 | cqp_error = cqp_request->compl_info.error; | 593 | cqp_error = cqp_request->compl_info.error; |
| 582 | if (cqp_error) { | 594 | if (cqp_error) { |
| 583 | err_code = IRDMA_ERR_CQP_COMPL_ERROR; | 595 | err_code = -EIO; |
| 584 | if (cqp_request->compl_info.maj_err_code == 0xFFFF && | 596 | if (cqp_request->compl_info.maj_err_code == 0xFFFF && |
| 585 | cqp_request->compl_info.min_err_code == 0x8029) { | 597 | cqp_request->compl_info.min_err_code == 0x8029) { |
| 586 | if (!rf->reset) { | 598 | if (!rf->reset) { |
| @@ -680,16 +692,16 @@ bool irdma_cqp_crit_err(struct irdma_sc_dev *dev, u8 cqp_cmd, · 93 unmodified lines | |||
| 680 | * @rf: RDMA PCI function | 692 | * @rf: RDMA PCI function |
| 681 | * @cqp_request: cqp request to process | 693 | * @cqp_request: cqp request to process |
| 682 | */ | 694 | */ |
| 683 | enum irdma_status_code irdma_handle_cqp_op(struct irdma_pci_f *rf, | 695 | int irdma_handle_cqp_op(struct irdma_pci_f *rf, |
| 684 | struct irdma_cqp_request *cqp_request) | 696 | struct irdma_cqp_request *cqp_request) |
| 685 | { | 697 | { |
| 686 | struct irdma_sc_dev *dev = &rf->sc_dev; | 698 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 687 | struct cqp_cmds_info *info = &cqp_request->info; | 699 | struct cqp_cmds_info *info = &cqp_request->info; |
| 688 | enum irdma_status_code status; | 700 | int status; |
| 689 | bool put_cqp_request = true; | 701 | bool put_cqp_request = true; |
| 690 | 702 | ||
| 691 | if (rf->reset) | 703 | if (rf->reset) |
| 692 | return IRDMA_ERR_NOT_READY; | 704 | return -EBUSY; |
| 693 | 705 | ||
| 694 | irdma_get_cqp_request(cqp_request); | 706 | irdma_get_cqp_request(cqp_request); |
| 695 | status = irdma_process_cqp_cmd(dev, info); | 707 | status = irdma_process_cqp_cmd(dev, info); |
| @@ -791,17 +803,17 @@ void *irdma_remove_cqp_head(struct irdma_sc_dev *dev) · 95 unmodified lines | |||
| 791 | * @sdinfo: information for sd cqp | 803 | * @sdinfo: information for sd cqp |
| 792 | * | 804 | * |
| 793 | */ | 805 | */ |
| 794 | enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, | 806 | int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, |
| 795 | struct irdma_update_sds_info *sdinfo) | 807 | struct irdma_update_sds_info *sdinfo) |
| 796 | { | 808 | { |
| 797 | struct irdma_cqp_request *cqp_request; | 809 | struct irdma_cqp_request *cqp_request; |
| 798 | struct cqp_cmds_info *cqp_info; | 810 | struct cqp_cmds_info *cqp_info; |
| 799 | struct irdma_pci_f *rf = dev_to_rf(dev); | 811 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 800 | enum irdma_status_code status; | 812 | int status; |
| 801 | 813 | ||
| 802 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 814 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 803 | if (!cqp_request) | 815 | if (!cqp_request) |
| 804 | return IRDMA_ERR_NO_MEMORY; | 816 | return -ENOMEM; |
| 805 | 817 | ||
| 806 | cqp_info = &cqp_request->info; | 818 | cqp_info = &cqp_request->info; |
| 807 | memcpy(&cqp_info->in.u.update_pe_sds.info, sdinfo, | 819 | memcpy(&cqp_info->in.u.update_pe_sds.info, sdinfo, |
| @@ -822,19 +834,18 @@ enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev, · 14 unmodified lines | |||
| 822 | * @qp: hardware control qp | 834 | * @qp: hardware control qp |
| 823 | * @op: suspend or resume | 835 | * @op: suspend or resume |
| 824 | */ | 836 | */ |
| 825 | enum irdma_status_code irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, | 837 | int irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, u8 op) |
| 826 | u8 op) | ||
| 827 | { | 838 | { |
| 828 | struct irdma_sc_dev *dev = qp->dev; | 839 | struct irdma_sc_dev *dev = qp->dev; |
| 829 | struct irdma_cqp_request *cqp_request; | 840 | struct irdma_cqp_request *cqp_request; |
| 830 | struct irdma_sc_cqp *cqp = dev->cqp; | 841 | struct irdma_sc_cqp *cqp = dev->cqp; |
| 831 | struct cqp_cmds_info *cqp_info; | 842 | struct cqp_cmds_info *cqp_info; |
| 832 | struct irdma_pci_f *rf = dev_to_rf(dev); | 843 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 833 | enum irdma_status_code status; | 844 | int status; |
| 834 | 845 | ||
| 835 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, false); | 846 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, false); |
| 836 | if (!cqp_request) | 847 | if (!cqp_request) |
| 837 | return IRDMA_ERR_NO_MEMORY; | 848 | return -ENOMEM; |
| 838 | 849 | ||
| 839 | cqp_info = &cqp_request->info; | 850 | cqp_info = &cqp_request->info; |
| 840 | cqp_info->cqp_cmd = op; | 851 | cqp_info->cqp_cmd = op; |
| @@ -940,18 +951,17 @@ void irdma_terminate_del_timer(struct irdma_sc_qp *qp) · 99 unmodified lines | |||
| 940 | * @val_mem: buffer for fpm | 951 | * @val_mem: buffer for fpm |
| 941 | * @hmc_fn_id: function id for fpm | 952 | * @hmc_fn_id: function id for fpm |
| 942 | */ | 953 | */ |
| 943 | enum irdma_status_code | 954 | int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, |
| 944 | irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, | 955 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id) |
| 945 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id) | ||
| 946 | { | 956 | { |
| 947 | struct irdma_cqp_request *cqp_request; | 957 | struct irdma_cqp_request *cqp_request; |
| 948 | struct cqp_cmds_info *cqp_info; | 958 | struct cqp_cmds_info *cqp_info; |
| 949 | struct irdma_pci_f *rf = dev_to_rf(dev); | 959 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 950 | enum irdma_status_code status; | 960 | int status; |
| 951 | 961 | ||
| 952 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 962 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 953 | if (!cqp_request) | 963 | if (!cqp_request) |
| 954 | return IRDMA_ERR_NO_MEMORY; | 964 | return -ENOMEM; |
| 955 | 965 | ||
| 956 | cqp_info = &cqp_request->info; | 966 | cqp_info = &cqp_request->info; |
| 957 | cqp_request->param = NULL; | 967 | cqp_request->param = NULL; |
| @@ -975,18 +985,17 @@ irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev, · 17 unmodified lines | |||
| 975 | * @val_mem: buffer with fpm values | 985 | * @val_mem: buffer with fpm values |
| 976 | * @hmc_fn_id: function id for fpm | 986 | * @hmc_fn_id: function id for fpm |
| 977 | */ | 987 | */ |
| 978 | enum irdma_status_code | 988 | int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, |
| 979 | irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, | 989 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id) |
| 980 | struct irdma_dma_mem *val_mem, u8 hmc_fn_id) | ||
| 981 | { | 990 | { |
| 982 | struct irdma_cqp_request *cqp_request; | 991 | struct irdma_cqp_request *cqp_request; |
| 983 | struct cqp_cmds_info *cqp_info; | 992 | struct cqp_cmds_info *cqp_info; |
| 984 | struct irdma_pci_f *rf = dev_to_rf(dev); | 993 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 985 | enum irdma_status_code status; | 994 | int status; |
| 986 | 995 | ||
| 987 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 996 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 988 | if (!cqp_request) | 997 | if (!cqp_request) |
| 989 | return IRDMA_ERR_NO_MEMORY; | 998 | return -ENOMEM; |
| 990 | 999 | ||
| 991 | cqp_info = &cqp_request->info; | 1000 | cqp_info = &cqp_request->info; |
| 992 | cqp_request->param = NULL; | 1001 | cqp_request->param = NULL; |
| @@ -1009,18 +1018,17 @@ irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev, · 16 unmodified lines | |||
| 1009 | * @dev: device pointer | 1018 | * @dev: device pointer |
| 1010 | * @cq: pointer to created cq | 1019 | * @cq: pointer to created cq |
| 1011 | */ | 1020 | */ |
| 1012 | enum irdma_status_code irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, | 1021 | int irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq) |
| 1013 | struct irdma_sc_cq *cq) | ||
| 1014 | { | 1022 | { |
| 1015 | struct irdma_pci_f *rf = dev_to_rf(dev); | 1023 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 1016 | struct irdma_cqp *iwcqp = &rf->cqp; | 1024 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 1017 | struct irdma_cqp_request *cqp_request; | 1025 | struct irdma_cqp_request *cqp_request; |
| 1018 | struct cqp_cmds_info *cqp_info; | 1026 | struct cqp_cmds_info *cqp_info; |
| 1019 | enum irdma_status_code status; | 1027 | int status; |
| 1020 | 1028 | ||
| 1021 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); | 1029 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); |
| 1022 | if (!cqp_request) | 1030 | if (!cqp_request) |
| 1023 | return IRDMA_ERR_NO_MEMORY; | 1031 | return -ENOMEM; |
| 1024 | 1032 | ||
| 1025 | cqp_info = &cqp_request->info; | 1033 | cqp_info = &cqp_request->info; |
| 1026 | cqp_info->cqp_cmd = IRDMA_OP_CQ_CREATE; | 1034 | cqp_info->cqp_cmd = IRDMA_OP_CQ_CREATE; |
| @@ -1039,19 +1047,18 @@ enum irdma_status_code irdma_cqp_cq_create_cmd(struct irdma_sc_dev *dev, · 12 unmodified lines | |||
| 1039 | * @dev: device pointer | 1047 | * @dev: device pointer |
| 1040 | * @qp: pointer to created qp | 1048 | * @qp: pointer to created qp |
| 1041 | */ | 1049 | */ |
| 1042 | enum irdma_status_code irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, | 1050 | int irdma_cqp_qp_create_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) |
| 1043 | struct irdma_sc_qp *qp) | ||
| 1044 | { | 1051 | { |
| 1045 | struct irdma_pci_f *rf = dev_to_rf(dev); | 1052 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 1046 | struct irdma_cqp *iwcqp = &rf->cqp; | 1053 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 1047 | struct irdma_cqp_request *cqp_request; | 1054 | struct irdma_cqp_request *cqp_request; |
| 1048 | struct cqp_cmds_info *cqp_info; | 1055 | struct cqp_cmds_info *cqp_info; |
| 1049 | struct irdma_create_qp_info *qp_info; | 1056 | struct irdma_create_qp_info *qp_info; |
| 1050 | enum irdma_status_code status; | 1057 | int status; |
| 1051 | 1058 | ||
| 1052 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); | 1059 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); |
| 1053 | if (!cqp_request) | 1060 | if (!cqp_request) |
| 1054 | return IRDMA_ERR_NO_MEMORY; | 1061 | return -ENOMEM; |
| 1055 | 1062 | ||
| 1056 | cqp_info = &cqp_request->info; | 1063 | cqp_info = &cqp_request->info; |
| 1057 | qp_info = &cqp_request->info.in.u.qp_create.info; | 1064 | qp_info = &cqp_request->info.in.u.qp_create.info; |
| @@ -1079,7 +1086,7 @@ static void irdma_dealloc_push_page(struct irdma_pci_f *rf, · 21 unmodified lines | |||
| 1079 | { | 1086 | { |
| 1080 | struct irdma_cqp_request *cqp_request; | 1087 | struct irdma_cqp_request *cqp_request; |
| 1081 | struct cqp_cmds_info *cqp_info; | 1088 | struct cqp_cmds_info *cqp_info; |
| 1082 | enum irdma_status_code status; | 1089 | int status; |
| 1083 | 1090 | ||
| 1084 | if (qp->push_idx == IRDMA_INVALID_PUSH_PAGE_INDEX) | 1091 | if (qp->push_idx == IRDMA_INVALID_PUSH_PAGE_INDEX) |
| 1085 | return; | 1092 | return; |
| @@ -1179,12 +1186,10 @@ static void irdma_hw_modify_qp_callback(struct irdma_cqp_request *cqp_request) · 93 unmodified lines | |||
| 1179 | * @info: info for modify qp | 1186 | * @info: info for modify qp |
| 1180 | * @wait: flag to wait or not for modify qp completion | 1187 | * @wait: flag to wait or not for modify qp completion |
| 1181 | */ | 1188 | */ |
| 1182 | enum irdma_status_code irdma_hw_modify_qp(struct irdma_device *iwdev, | 1189 | int irdma_hw_modify_qp(struct irdma_device *iwdev, struct irdma_qp *iwqp, |
| 1183 | struct irdma_qp *iwqp, | 1190 | struct irdma_modify_qp_info *info, bool wait) |
| 1184 | struct irdma_modify_qp_info *info, | ||
| 1185 | bool wait) | ||
| 1186 | { | 1191 | { |
| 1187 | enum irdma_status_code status; | 1192 | int status; |
| 1188 | struct irdma_pci_f *rf = iwdev->rf; | 1193 | struct irdma_pci_f *rf = iwdev->rf; |
| 1189 | struct irdma_cqp_request *cqp_request; | 1194 | struct irdma_cqp_request *cqp_request; |
| 1190 | struct cqp_cmds_info *cqp_info; | 1195 | struct cqp_cmds_info *cqp_info; |
| @@ -1192,7 +1197,7 @@ enum irdma_status_code irdma_hw_modify_qp(struct irdma_device *iwdev, · 1 unmodified line | |||
| 1192 | 1197 | ||
| 1193 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); | 1198 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, wait); |
| 1194 | if (!cqp_request) | 1199 | if (!cqp_request) |
| 1195 | return IRDMA_ERR_NO_MEMORY; | 1200 | return -ENOMEM; |
| 1196 | 1201 | ||
| 1197 | if (!wait) { | 1202 | if (!wait) { |
| 1198 | cqp_request->callback_fcn = irdma_hw_modify_qp_callback; | 1203 | cqp_request->callback_fcn = irdma_hw_modify_qp_callback; |
| @@ -1230,7 +1235,7 @@ enum irdma_status_code irdma_hw_modify_qp(struct irdma_device *iwdev, · 31 unmodified lines | |||
| 1230 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, | 1235 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, |
| 1231 | wait); | 1236 | wait); |
| 1232 | if (!cqp_request) | 1237 | if (!cqp_request) |
| 1233 | return IRDMA_ERR_NO_MEMORY; | 1238 | return -ENOMEM; |
| 1234 | 1239 | ||
| 1235 | cqp_info = &cqp_request->info; | 1240 | cqp_info = &cqp_request->info; |
| 1236 | m_info = &cqp_info->in.u.qp_modify.info; | 1241 | m_info = &cqp_info->in.u.qp_modify.info; |
| @@ -1271,17 +1276,17 @@ void irdma_cqp_cq_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_cq *cq) · 34 unmodified lines | |||
| 1271 | * @dev: device pointer | 1276 | * @dev: device pointer |
| 1272 | * @qp: pointer to qp | 1277 | * @qp: pointer to qp |
| 1273 | */ | 1278 | */ |
| 1274 | enum irdma_status_code irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) | 1279 | int irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) |
| 1275 | { | 1280 | { |
| 1276 | struct irdma_pci_f *rf = dev_to_rf(dev); | 1281 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 1277 | struct irdma_cqp *iwcqp = &rf->cqp; | 1282 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 1278 | struct irdma_cqp_request *cqp_request; | 1283 | struct irdma_cqp_request *cqp_request; |
| 1279 | struct cqp_cmds_info *cqp_info; | 1284 | struct cqp_cmds_info *cqp_info; |
| 1280 | enum irdma_status_code status; | 1285 | int status; |
| 1281 | 1286 | ||
| 1282 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); | 1287 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, true); |
| 1283 | if (!cqp_request) | 1288 | if (!cqp_request) |
| 1284 | return IRDMA_ERR_NO_MEMORY; | 1289 | return -ENOMEM; |
| 1285 | 1290 | ||
| 1286 | cqp_info = &cqp_request->info; | 1291 | cqp_info = &cqp_request->info; |
| 1287 | memset(cqp_info, 0, sizeof(*cqp_info)); | 1292 | memset(cqp_info, 0, sizeof(*cqp_info)); |
| @@ -1317,20 +1322,20 @@ void irdma_ieq_mpa_crc_ae(struct irdma_sc_dev *dev, struct irdma_sc_qp *qp) · 29 unmodified lines | |||
| 1317 | * irdma_init_hash_desc - initialize hash for crc calculation | 1322 | * irdma_init_hash_desc - initialize hash for crc calculation |
| 1318 | * @desc: cryption type | 1323 | * @desc: cryption type |
| 1319 | */ | 1324 | */ |
| 1320 | enum irdma_status_code irdma_init_hash_desc(struct shash_desc **desc) | 1325 | int irdma_init_hash_desc(struct shash_desc **desc) |
| 1321 | { | 1326 | { |
| 1322 | struct crypto_shash *tfm; | 1327 | struct crypto_shash *tfm; |
| 1323 | struct shash_desc *tdesc; | 1328 | struct shash_desc *tdesc; |
| 1324 | 1329 | ||
| 1325 | tfm = crypto_alloc_shash("crc32c", 0, 0); | 1330 | tfm = crypto_alloc_shash("crc32c", 0, 0); |
| 1326 | if (IS_ERR(tfm)) | 1331 | if (IS_ERR(tfm)) |
| 1327 | return IRDMA_ERR_MPA_CRC; | 1332 | return -EINVAL; |
| 1328 | 1333 | ||
| 1329 | tdesc = kzalloc(sizeof(*tdesc) + crypto_shash_descsize(tfm), | 1334 | tdesc = kzalloc(sizeof(*tdesc) + crypto_shash_descsize(tfm), |
| 1330 | GFP_KERNEL); | 1335 | GFP_KERNEL); |
| 1331 | if (!tdesc) { | 1336 | if (!tdesc) { |
| 1332 | crypto_free_shash(tfm); | 1337 | crypto_free_shash(tfm); |
| 1333 | return IRDMA_ERR_MPA_CRC; | 1338 | return -EINVAL; |
| 1334 | } | 1339 | } |
| 1335 | 1340 | ||
| 1336 | tdesc->tfm = tfm; | 1341 | tdesc->tfm = tfm; |
| @@ -1358,19 +1363,19 @@ void irdma_free_hash_desc(struct shash_desc *desc) · 21 unmodified lines | |||
| 1358 | * @len: length of buffer | 1363 | * @len: length of buffer |
| 1359 | * @val: value to be compared | 1364 | * @val: value to be compared |
| 1360 | */ | 1365 | */ |
| 1361 | enum irdma_status_code irdma_ieq_check_mpacrc(struct shash_desc *desc, | 1366 | int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len, |
| 1362 | void *addr, u32 len, u32 val) | 1367 | u32 val) |
| 1363 | { | 1368 | { |
| 1364 | u32 crc = 0; | 1369 | u32 crc = 0; |
| 1365 | int ret; | 1370 | int ret; |
| 1366 | enum irdma_status_code ret_code = 0; | 1371 | int ret_code = 0; |
| 1367 | 1372 | ||
| 1368 | crypto_shash_init(desc); | 1373 | crypto_shash_init(desc); |
| 1369 | ret = crypto_shash_update(desc, addr, len); | 1374 | ret = crypto_shash_update(desc, addr, len); |
| 1370 | if (!ret) | 1375 | if (!ret) |
| 1371 | crypto_shash_final(desc, (u8 *)&crc); | 1376 | crypto_shash_final(desc, (u8 *)&crc); |
| 1372 | if (crc != val) | 1377 | if (crc != val) |
| 1373 | ret_code = IRDMA_ERR_MPA_CRC; | 1378 | ret_code = -EINVAL; |
| 1374 | 1379 | ||
| 1375 | return ret_code; | 1380 | return ret_code; |
| 1376 | } | 1381 | } |
| @@ -1524,9 +1529,8 @@ void irdma_ieq_update_tcpip_info(struct irdma_puda_buf *buf, u16 len, · 147 unmodified lines | |||
| 1524 | * @info: to get information | 1529 | * @info: to get information |
| 1525 | * @buf: puda buffer | 1530 | * @buf: puda buffer |
| 1526 | */ | 1531 | */ |
| 1527 | static enum irdma_status_code | 1532 | static int irdma_gen1_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, |
| 1528 | irdma_gen1_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, | 1533 | struct irdma_puda_buf *buf) |
| 1529 | struct irdma_puda_buf *buf) | ||
| 1530 | { | 1534 | { |
| 1531 | struct iphdr *iph; | 1535 | struct iphdr *iph; |
| 1532 | struct ipv6hdr *ip6h; | 1536 | struct ipv6hdr *ip6h; |
| @@ -1563,7 +1567,7 @@ irdma_gen1_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, · 30 unmodified lines | |||
| 1563 | ibdev_dbg(to_ibdev(buf->vsi->dev), | 1567 | ibdev_dbg(to_ibdev(buf->vsi->dev), |
| 1564 | "ERR: payload_len = 0x%x totallen expected0x%x\n", | 1568 | "ERR: payload_len = 0x%x totallen expected0x%x\n", |
| 1565 | info->payload_len, buf->totallen); | 1569 | info->payload_len, buf->totallen); |
| 1566 | return IRDMA_ERR_INVALID_SIZE; | 1570 | return -EINVAL; |
| 1567 | } | 1571 | } |
| 1568 | 1572 | ||
| 1569 | buf->tcphlen = tcph->doff << 2; | 1573 | buf->tcphlen = tcph->doff << 2; |
| @@ -1580,9 +1584,8 @@ irdma_gen1_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, · 10 unmodified lines | |||
| 1580 | * @info: to get information | 1584 | * @info: to get information |
| 1581 | * @buf: puda buffer | 1585 | * @buf: puda buffer |
| 1582 | */ | 1586 | */ |
| 1583 | enum irdma_status_code | 1587 | int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, |
| 1584 | irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info *info, | 1588 | struct irdma_puda_buf *buf) |
| 1585 | struct irdma_puda_buf *buf) | ||
| 1586 | { | 1589 | { |
| 1587 | struct tcphdr *tcph; | 1590 | struct tcphdr *tcph; |
| 1588 | u32 pkt_len; | 1591 | u32 pkt_len; |
| @@ -1861,20 +1864,19 @@ static void irdma_process_cqp_stats(struct irdma_cqp_request *cqp_request) · 272 unmodified lines | |||
| 1861 | * @pestat: pointer to stats info | 1864 | * @pestat: pointer to stats info |
| 1862 | * @wait: flag to wait or not wait for stats | 1865 | * @wait: flag to wait or not wait for stats |
| 1863 | */ | 1866 | */ |
| 1864 | enum irdma_status_code | 1867 | int irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, |
| 1865 | irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, | 1868 | struct irdma_vsi_pestat *pestat, bool wait) |
| 1866 | struct irdma_vsi_pestat *pestat, bool wait) | ||
| 1867 | 1869 | ||
| 1868 | { | 1870 | { |
| 1869 | struct irdma_pci_f *rf = dev_to_rf(dev); | 1871 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 1870 | struct irdma_cqp *iwcqp = &rf->cqp; | 1872 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 1871 | struct irdma_cqp_request *cqp_request; | 1873 | struct irdma_cqp_request *cqp_request; |
| 1872 | struct cqp_cmds_info *cqp_info; | 1874 | struct cqp_cmds_info *cqp_info; |
| 1873 | enum irdma_status_code status; | 1875 | int status; |
| 1874 | 1876 | ||
| 1875 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); | 1877 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); |
| 1876 | if (!cqp_request) | 1878 | if (!cqp_request) |
| 1877 | return IRDMA_ERR_NO_MEMORY; | 1879 | return -ENOMEM; |
| 1878 | 1880 | ||
| 1879 | cqp_info = &cqp_request->info; | 1881 | cqp_info = &cqp_request->info; |
| 1880 | memset(cqp_info, 0, sizeof(*cqp_info)); | 1882 | memset(cqp_info, 0, sizeof(*cqp_info)); |
| @@ -1900,22 +1902,21 @@ irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev, · 19 unmodified lines | |||
| 1900 | * @cmd: command to allocate or free | 1902 | * @cmd: command to allocate or free |
| 1901 | * @stats_info: pointer to allocate stats info | 1903 | * @stats_info: pointer to allocate stats info |
| 1902 | */ | 1904 | */ |
| 1903 | enum irdma_status_code | 1905 | int irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, |
| 1904 | irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, | 1906 | struct irdma_stats_inst_info *stats_info) |
| 1905 | struct irdma_stats_inst_info *stats_info) | ||
| 1906 | { | 1907 | { |
| 1907 | struct irdma_pci_f *rf = dev_to_rf(vsi->dev); | 1908 | struct irdma_pci_f *rf = dev_to_rf(vsi->dev); |
| 1908 | struct irdma_cqp *iwcqp = &rf->cqp; | 1909 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 1909 | struct irdma_cqp_request *cqp_request; | 1910 | struct irdma_cqp_request *cqp_request; |
| 1910 | struct cqp_cmds_info *cqp_info; | 1911 | struct cqp_cmds_info *cqp_info; |
| 1911 | enum irdma_status_code status; | 1912 | int status; |
| 1912 | bool wait = false; | 1913 | bool wait = false; |
| 1913 | 1914 | ||
| 1914 | if (cmd == IRDMA_OP_STATS_ALLOCATE) | 1915 | if (cmd == IRDMA_OP_STATS_ALLOCATE) |
| 1915 | wait = true; | 1916 | wait = true; |
| 1916 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); | 1917 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, wait); |
| 1917 | if (!cqp_request) | 1918 | if (!cqp_request) |
| 1918 | return IRDMA_ERR_NO_MEMORY; | 1919 | return -ENOMEM; |
| 1919 | 1920 | ||
| 1920 | cqp_info = &cqp_request->info; | 1921 | cqp_info = &cqp_request->info; |
| 1921 | memset(cqp_info, 0, sizeof(*cqp_info)); | 1922 | memset(cqp_info, 0, sizeof(*cqp_info)); |
| @@ -1938,17 +1939,17 @@ irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd, · 16 unmodified lines | |||
| 1938 | * @sc_ceq: pointer to ceq structure | 1939 | * @sc_ceq: pointer to ceq structure |
| 1939 | * @op: Create or Destroy | 1940 | * @op: Create or Destroy |
| 1940 | */ | 1941 | */ |
| 1941 | enum irdma_status_code irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, | 1942 | int irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_ceq *sc_ceq, |
| 1942 | struct irdma_sc_ceq *sc_ceq, u8 op) | 1943 | u8 op) |
| 1943 | { | 1944 | { |
| 1944 | struct irdma_cqp_request *cqp_request; | 1945 | struct irdma_cqp_request *cqp_request; |
| 1945 | struct cqp_cmds_info *cqp_info; | 1946 | struct cqp_cmds_info *cqp_info; |
| 1946 | struct irdma_pci_f *rf = dev_to_rf(dev); | 1947 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 1947 | enum irdma_status_code status; | 1948 | int status; |
| 1948 | 1949 | ||
| 1949 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 1950 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 1950 | if (!cqp_request) | 1951 | if (!cqp_request) |
| 1951 | return IRDMA_ERR_NO_MEMORY; | 1952 | return -ENOMEM; |
| 1952 | 1953 | ||
| 1953 | cqp_info = &cqp_request->info; | 1954 | cqp_info = &cqp_request->info; |
| 1954 | cqp_info->post_sq = 1; | 1955 | cqp_info->post_sq = 1; |
| @@ -1968,17 +1969,17 @@ enum irdma_status_code irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, · 13 unmodified lines | |||
| 1968 | * @sc_aeq: pointer to aeq structure | 1969 | * @sc_aeq: pointer to aeq structure |
| 1969 | * @op: Create or Destroy | 1970 | * @op: Create or Destroy |
| 1970 | */ | 1971 | */ |
| 1971 | enum irdma_status_code irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, | 1972 | int irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_aeq *sc_aeq, |
| 1972 | struct irdma_sc_aeq *sc_aeq, u8 op) | 1973 | u8 op) |
| 1973 | { | 1974 | { |
| 1974 | struct irdma_cqp_request *cqp_request; | 1975 | struct irdma_cqp_request *cqp_request; |
| 1975 | struct cqp_cmds_info *cqp_info; | 1976 | struct cqp_cmds_info *cqp_info; |
| 1976 | struct irdma_pci_f *rf = dev_to_rf(dev); | 1977 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 1977 | enum irdma_status_code status; | 1978 | int status; |
| 1978 | 1979 | ||
| 1979 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 1980 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 1980 | if (!cqp_request) | 1981 | if (!cqp_request) |
| 1981 | return IRDMA_ERR_NO_MEMORY; | 1982 | return -ENOMEM; |
| 1982 | 1983 | ||
| 1983 | cqp_info = &cqp_request->info; | 1984 | cqp_info = &cqp_request->info; |
| 1984 | cqp_info->post_sq = 1; | 1985 | cqp_info->post_sq = 1; |
| @@ -1998,16 +1999,15 @@ enum irdma_status_code irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, · 13 unmodified lines | |||
| 1998 | * @cmd: Add, modify or delete | 1999 | * @cmd: Add, modify or delete |
| 1999 | * @node_info: pointer to ws node info | 2000 | * @node_info: pointer to ws node info |
| 2000 | */ | 2001 | */ |
| 2001 | enum irdma_status_code | 2002 | int irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, |
| 2002 | irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, | 2003 | struct irdma_ws_node_info *node_info) |
| 2003 | struct irdma_ws_node_info *node_info) | ||
| 2004 | { | 2004 | { |
| 2005 | struct irdma_pci_f *rf = dev_to_rf(dev); | 2005 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| 2006 | struct irdma_cqp *iwcqp = &rf->cqp; | 2006 | struct irdma_cqp *iwcqp = &rf->cqp; |
| 2007 | struct irdma_sc_cqp *cqp = &iwcqp->sc_cqp; | 2007 | struct irdma_sc_cqp *cqp = &iwcqp->sc_cqp; |
| 2008 | struct irdma_cqp_request *cqp_request; | 2008 | struct irdma_cqp_request *cqp_request; |
| 2009 | struct cqp_cmds_info *cqp_info; | 2009 | struct cqp_cmds_info *cqp_info; |
| 2010 | enum irdma_status_code status; | 2010 | int status; |
| 2011 | bool poll; | 2011 | bool poll; |
| 2012 | 2012 | ||
| 2013 | if (!rf->sc_dev.ceq_valid) | 2013 | if (!rf->sc_dev.ceq_valid) |
| @@ -2017,7 +2017,7 @@ irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd, · 3 unmodified lines | |||
| 2017 | 2017 | ||
| 2018 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, !poll); | 2018 | cqp_request = irdma_alloc_and_get_cqp_request(iwcqp, !poll); |
| 2019 | if (!cqp_request) | 2019 | if (!cqp_request) |
| 2020 | return IRDMA_ERR_NO_MEMORY; | 2020 | return -ENOMEM; |
| 2021 | 2021 | ||
| 2022 | cqp_info = &cqp_request->info; | 2022 | cqp_info = &cqp_request->info; |
| 2023 | memset(cqp_info, 0, sizeof(*cqp_info)); | 2023 | memset(cqp_info, 0, sizeof(*cqp_info)); |
| @@ -2066,7 +2066,7 @@ int irdma_ah_cqp_op(struct irdma_pci_f *rf, struct irdma_sc_ah *sc_ah, u8 cmd, · 42 unmodified lines | |||
| 2066 | { | 2066 | { |
| 2067 | struct irdma_cqp_request *cqp_request; | 2067 | struct irdma_cqp_request *cqp_request; |
| 2068 | struct cqp_cmds_info *cqp_info; | 2068 | struct cqp_cmds_info *cqp_info; |
| 2069 | enum irdma_status_code status; | 2069 | int status; |
| 2070 | 2070 | ||
| 2071 | if (cmd != IRDMA_OP_AH_CREATE && cmd != IRDMA_OP_AH_DESTROY) | 2071 | if (cmd != IRDMA_OP_AH_CREATE && cmd != IRDMA_OP_AH_DESTROY) |
| 2072 | return -EINVAL; | 2072 | return -EINVAL; |
| @@ -2148,11 +2148,10 @@ static void irdma_ilq_ah_cb(struct irdma_cqp_request *cqp_request) · 75 unmodified lines | |||
| 2148 | * @ah_ret: Returned pointer to address handle if created | 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, | 2151 | int irdma_puda_create_ah(struct irdma_sc_dev *dev, |
| 2152 | struct irdma_ah_info *ah_info, | 2152 | struct irdma_ah_info *ah_info, bool wait, |
| 2153 | bool wait, enum puda_rsrc_type type, | 2153 | enum puda_rsrc_type type, void *cb_param, |
| 2154 | void *cb_param, | 2154 | struct irdma_sc_ah **ah_ret) |
| 2155 | struct irdma_sc_ah **ah_ret) | ||
| 2156 | { | 2155 | { |
| 2157 | struct irdma_sc_ah *ah; | 2156 | struct irdma_sc_ah *ah; |
| 2158 | struct irdma_pci_f *rf = dev_to_rf(dev); | 2157 | struct irdma_pci_f *rf = dev_to_rf(dev); |
| @@ -2161,7 +2160,7 @@ enum irdma_status_code irdma_puda_create_ah(struct irdma_sc_dev *dev, · 2 unmodified lines | |||
| 2161 | ah = kzalloc(sizeof(*ah), GFP_ATOMIC); | 2160 | ah = kzalloc(sizeof(*ah), GFP_ATOMIC); |
| 2162 | *ah_ret = ah; | 2161 | *ah_ret = ah; |
| 2163 | if (!ah) | 2162 | if (!ah) |
| 2164 | return IRDMA_ERR_NO_MEMORY; | 2163 | return -ENOMEM; |
| 2165 | 2164 | ||
| 2166 | err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, | 2165 | err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, |
| 2167 | &ah_info->ah_idx, &rf->next_ah); | 2166 | &ah_info->ah_idx, &rf->next_ah); |
| @@ -2187,7 +2186,7 @@ error: · 19 unmodified lines | |||
| 2187 | err_free: | 2186 | err_free: |
| 2188 | kfree(ah); | 2187 | kfree(ah); |
| 2189 | *ah_ret = NULL; | 2188 | *ah_ret = NULL; |
| 2190 | return IRDMA_ERR_NO_MEMORY; | 2189 | return -ENOMEM; |
| 2191 | } | 2190 | } |
| 2192 | 2191 | ||
| 2193 | /** | 2192 | /** |
| @@ -2229,19 +2228,19 @@ void irdma_gsi_ud_qp_ah_cb(struct irdma_cqp_request *cqp_request) · 35 unmodified lines | |||
| 2229 | * @pprm: pble resource manager | 2228 | * @pprm: pble resource manager |
| 2230 | * @pchunk: chunk of memory to add | 2229 | * @pchunk: chunk of memory to add |
| 2231 | */ | 2230 | */ |
| 2232 | enum irdma_status_code irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, | 2231 | int irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, |
| 2233 | struct irdma_chunk *pchunk) | 2232 | struct irdma_chunk *pchunk) |
| 2234 | { | 2233 | { |
| 2235 | u64 sizeofbitmap; | 2234 | u64 sizeofbitmap; |
| 2236 | 2235 | ||
| 2237 | if (pchunk->size & 0xfff) | 2236 | if (pchunk->size & 0xfff) |
| 2238 | return IRDMA_ERR_PARAM; | 2237 | return -EINVAL; |
| 2239 | 2238 | ||
| 2240 | sizeofbitmap = (u64)pchunk->size >> pprm->pble_shift; | 2239 | sizeofbitmap = (u64)pchunk->size >> pprm->pble_shift; |
| 2241 | 2240 | ||
| 2242 | pchunk->bitmapbuf = bitmap_zalloc(sizeofbitmap, GFP_KERNEL); | 2241 | pchunk->bitmapbuf = bitmap_zalloc(sizeofbitmap, GFP_KERNEL); |
| 2243 | if (!pchunk->bitmapbuf) | 2242 | if (!pchunk->bitmapbuf) |
| 2244 | return IRDMA_ERR_NO_MEMORY; | 2243 | return -ENOMEM; |
| 2245 | 2244 | ||
| 2246 | pchunk->sizeofbitmap = sizeofbitmap; | 2245 | pchunk->sizeofbitmap = sizeofbitmap; |
| 2247 | /* each pble is 8 bytes hence shift by 3 */ | 2246 | /* each pble is 8 bytes hence shift by 3 */ |
| @@ -2259,10 +2258,9 @@ enum irdma_status_code irdma_prm_add_pble_mem(struct irdma_pble_prm *pprm, · 11 unmodified lines | |||
| 2259 | * @vaddr: returns virtual address of pble memory | 2258 | * @vaddr: returns virtual address of pble memory |
| 2260 | * @fpm_addr: returns fpm address of pble memory | 2259 | * @fpm_addr: returns fpm address of pble memory |
| 2261 | */ | 2260 | */ |
| 2262 | enum irdma_status_code | 2261 | int irdma_prm_get_pbles(struct irdma_pble_prm *pprm, |
| 2263 | irdma_prm_get_pbles(struct irdma_pble_prm *pprm, | 2262 | struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, |
| 2264 | struct irdma_pble_chunkinfo *chunkinfo, u64 mem_size, | 2263 | u64 **vaddr, u64 *fpm_addr) |
| 2265 | u64 **vaddr, u64 *fpm_addr) | ||
| 2266 | { | 2264 | { |
| 2267 | u64 bits_needed; | 2265 | u64 bits_needed; |
| 2268 | u64 bit_idx = PBLE_INVALID_IDX; | 2266 | u64 bit_idx = PBLE_INVALID_IDX; |
| @@ -2290,7 +2288,7 @@ irdma_prm_get_pbles(struct irdma_pble_prm *pprm, · 21 unmodified lines | |||
| 2290 | 2288 | ||
| 2291 | if (!pchunk || bit_idx >= pchunk->sizeofbitmap) { | 2289 | if (!pchunk || bit_idx >= pchunk->sizeofbitmap) { |
| 2292 | spin_unlock_irqrestore(&pprm->prm_lock, flags); | 2290 | spin_unlock_irqrestore(&pprm->prm_lock, flags); |
| 2293 | return IRDMA_ERR_NO_MEMORY; | 2291 | return -ENOMEM; |
| 2294 | } | 2292 | } |
| 2295 | 2293 | ||
| 2296 | bitmap_set(pchunk->bitmapbuf, bit_idx, bits_needed); | 2294 | bitmap_set(pchunk->bitmapbuf, bit_idx, bits_needed); |
| @@ -2325,8 +2323,8 @@ void irdma_prm_return_pbles(struct irdma_pble_prm *pprm, · 28 unmodified lines | |||
| 2325 | spin_unlock_irqrestore(&pprm->prm_lock, flags); | 2323 | spin_unlock_irqrestore(&pprm->prm_lock, flags); |
| 2326 | } | 2324 | } |
| 2327 | 2325 | ||
| 2328 | enum irdma_status_code irdma_map_vm_page_list(struct irdma_hw *hw, void *va, | 2326 | int irdma_map_vm_page_list(struct irdma_hw *hw, void *va, dma_addr_t *pg_dma, |
| 2329 | dma_addr_t *pg_dma, u32 pg_cnt) | 2327 | u32 pg_cnt) |
| 2330 | { | 2328 | { |
| 2331 | struct page *vm_page; | 2329 | struct page *vm_page; |
| 2332 | int i; | 2330 | int i; |
| @@ -2350,7 +2348,7 @@ enum irdma_status_code irdma_map_vm_page_list(struct irdma_hw *hw, void *va, · 17 unmodified lines | |||
| 2350 | 2348 | ||
| 2351 | err: | 2349 | err: |
| 2352 | irdma_unmap_vm_page_list(hw, pg_dma, i); | 2350 | irdma_unmap_vm_page_list(hw, pg_dma, i); |
| 2353 | return IRDMA_ERR_NO_MEMORY; | 2351 | return -ENOMEM; |
| 2354 | } | 2352 | } |
| 2355 | 2353 | ||
| 2356 | void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt) | 2354 | void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt) |
| @@ -2386,15 +2384,14 @@ done: · 29 unmodified lines | |||
| 2386 | * @chunk: chunk to add for paged memory | 2384 | * @chunk: chunk to add for paged memory |
| 2387 | * @pg_cnt: number of pages needed | 2385 | * @pg_cnt: number of pages needed |
| 2388 | */ | 2386 | */ |
| 2389 | enum irdma_status_code irdma_pble_get_paged_mem(struct irdma_chunk *chunk, | 2387 | int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt) |
| 2390 | u32 pg_cnt) | ||
| 2391 | { | 2388 | { |
| 2392 | u32 size; | 2389 | u32 size; |
| 2393 | void *va; | 2390 | void *va; |
| 2394 | 2391 | ||
| 2395 | chunk->dmainfo.dmaaddrs = kzalloc(pg_cnt << 3, GFP_KERNEL); | 2392 | chunk->dmainfo.dmaaddrs = kzalloc(pg_cnt << 3, GFP_KERNEL); |
| 2396 | if (!chunk->dmainfo.dmaaddrs) | 2393 | if (!chunk->dmainfo.dmaaddrs) |
| 2397 | return IRDMA_ERR_NO_MEMORY; | 2394 | return -ENOMEM; |
| 2398 | 2395 | ||
| 2399 | size = PAGE_SIZE * pg_cnt; | 2396 | size = PAGE_SIZE * pg_cnt; |
| 2400 | va = vmalloc(size); | 2397 | va = vmalloc(size); |
| @@ -2416,7 +2413,7 @@ err: · 15 unmodified lines | |||
| 2416 | kfree(chunk->dmainfo.dmaaddrs); | 2413 | kfree(chunk->dmainfo.dmaaddrs); |
| 2417 | chunk->dmainfo.dmaaddrs = NULL; | 2414 | chunk->dmainfo.dmaaddrs = NULL; |
| 2418 | 2415 | ||
| 2419 | return IRDMA_ERR_NO_MEMORY; | 2416 | return -ENOMEM; |
| 2420 | } | 2417 | } |
| 2421 | 2418 | ||
| 2422 | /** | 2419 | /** |
| @@ -256,7 +256,7 @@ static void irdma_alloc_push_page(struct irdma_qp *iwqp) · 255 unmodified lines | |||
| 256 | struct cqp_cmds_info *cqp_info; | 256 | struct cqp_cmds_info *cqp_info; |
| 257 | struct irdma_device *iwdev = iwqp->iwdev; | 257 | struct irdma_device *iwdev = iwqp->iwdev; |
| 258 | struct irdma_sc_qp *qp = &iwqp->sc_qp; | 258 | struct irdma_sc_qp *qp = &iwqp->sc_qp; |
| 259 | enum irdma_status_code status; | 259 | int status; |
| 260 | 260 | ||
| 261 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); | 261 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); |
| 262 | if (!cqp_request) | 262 | if (!cqp_request) |
| @@ -592,7 +592,7 @@ static int irdma_setup_kmode_qp(struct irdma_device *iwdev, · 329 unmodified lines | |||
| 592 | u32 sqdepth, rqdepth; | 592 | u32 sqdepth, rqdepth; |
| 593 | u8 sqshift, rqshift; | 593 | u8 sqshift, rqshift; |
| 594 | u32 size; | 594 | u32 size; |
| 595 | enum irdma_status_code status; | 595 | int status; |
| 596 | struct irdma_qp_uk_init_info *ukinfo = &info->qp_uk_init_info; | 596 | struct irdma_qp_uk_init_info *ukinfo = &info->qp_uk_init_info; |
| 597 | struct irdma_uk_attrs *uk_attrs = &iwdev->rf->sc_dev.hw_attrs.uk_attrs; | 597 | struct irdma_uk_attrs *uk_attrs = &iwdev->rf->sc_dev.hw_attrs.uk_attrs; |
| 598 | 598 | ||
| @@ -603,7 +603,7 @@ static int irdma_setup_kmode_qp(struct irdma_device *iwdev, · 4 unmodified lines | |||
| 603 | status = irdma_get_sqdepth(uk_attrs, ukinfo->sq_size, sqshift, | 603 | status = irdma_get_sqdepth(uk_attrs, ukinfo->sq_size, sqshift, |
| 604 | &sqdepth); | 604 | &sqdepth); |
| 605 | if (status) | 605 | if (status) |
| 606 | return -ENOMEM; | 606 | return status; |
| 607 | 607 | ||
| 608 | if (uk_attrs->hw_rev == IRDMA_GEN_1) | 608 | if (uk_attrs->hw_rev == IRDMA_GEN_1) |
| 609 | rqshift = IRDMA_MAX_RQ_WQE_SHIFT_GEN1; | 609 | rqshift = IRDMA_MAX_RQ_WQE_SHIFT_GEN1; |
| @@ -614,7 +614,7 @@ static int irdma_setup_kmode_qp(struct irdma_device *iwdev, · 4 unmodified lines | |||
| 614 | status = irdma_get_rqdepth(uk_attrs, ukinfo->rq_size, rqshift, | 614 | status = irdma_get_rqdepth(uk_attrs, ukinfo->rq_size, rqshift, |
| 615 | &rqdepth); | 615 | &rqdepth); |
| 616 | if (status) | 616 | if (status) |
| 617 | return -ENOMEM; | 617 | return status; |
| 618 | 618 | ||
| 619 | iwqp->kqp.sq_wrid_mem = | 619 | iwqp->kqp.sq_wrid_mem = |
| 620 | kcalloc(sqdepth, sizeof(*iwqp->kqp.sq_wrid_mem), GFP_KERNEL); | 620 | kcalloc(sqdepth, sizeof(*iwqp->kqp.sq_wrid_mem), GFP_KERNEL); |
| @@ -668,7 +668,7 @@ static int irdma_cqp_create_qp_cmd(struct irdma_qp *iwqp) · 47 unmodified lines | |||
| 668 | struct irdma_cqp_request *cqp_request; | 668 | struct irdma_cqp_request *cqp_request; |
| 669 | struct cqp_cmds_info *cqp_info; | 669 | struct cqp_cmds_info *cqp_info; |
| 670 | struct irdma_create_qp_info *qp_info; | 670 | struct irdma_create_qp_info *qp_info; |
| 671 | enum irdma_status_code status; | 671 | int status; |
| 672 | 672 | ||
| 673 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); | 673 | cqp_request = irdma_alloc_and_get_cqp_request(&rf->cqp, true); |
| 674 | if (!cqp_request) | 674 | if (!cqp_request) |
| @@ -688,7 +688,7 @@ static int irdma_cqp_create_qp_cmd(struct irdma_qp *iwqp) · 13 unmodified lines | |||
| 688 | status = irdma_handle_cqp_op(rf, cqp_request); | 688 | status = irdma_handle_cqp_op(rf, cqp_request); |
| 689 | irdma_put_cqp_request(&rf->cqp, cqp_request); | 689 | irdma_put_cqp_request(&rf->cqp, cqp_request); |
| 690 | 690 | ||
| 691 | return status ? -ENOMEM : 0; | 691 | return status; |
| 692 | } | 692 | } |
| 693 | 693 | ||
| 694 | static void irdma_roce_fill_and_set_qpctx_info(struct irdma_qp *iwqp, | 694 | static void irdma_roce_fill_and_set_qpctx_info(struct irdma_qp *iwqp, |
| @@ -806,7 +806,6 @@ static int irdma_create_qp(struct ib_qp *ibqp, · 111 unmodified lines | |||
| 806 | struct irdma_create_qp_req req; | 806 | struct irdma_create_qp_req req; |
| 807 | struct irdma_create_qp_resp uresp = {}; | 807 | struct irdma_create_qp_resp uresp = {}; |
| 808 | u32 qp_num = 0; | 808 | u32 qp_num = 0; |
| 809 | enum irdma_status_code ret; | ||
| 810 | int err_code; | 809 | int err_code; |
| 811 | int sq_size; | 810 | int sq_size; |
| 812 | int rq_size; | 811 | int rq_size; |
| @@ -936,9 +935,8 @@ static int irdma_create_qp(struct ib_qp *ibqp, · 123 unmodified lines | |||
| 936 | if (dev->hw_attrs.uk_attrs.hw_rev > IRDMA_GEN_1) | 935 | if (dev->hw_attrs.uk_attrs.hw_rev > IRDMA_GEN_1) |
| 937 | init_info.qp_uk_init_info.qp_caps |= IRDMA_PUSH_MODE; | 936 | init_info.qp_uk_init_info.qp_caps |= IRDMA_PUSH_MODE; |
| 938 | 937 | ||
| 939 | ret = irdma_sc_qp_init(qp, &init_info); | 938 | err_code = irdma_sc_qp_init(qp, &init_info); |
| 940 | if (ret) { | 939 | if (err_code) { |
| 941 | err_code = -EPROTO; | ||
| 942 | ibdev_dbg(&iwdev->ibdev, "VERBS: qp_init fail\n"); | 940 | ibdev_dbg(&iwdev->ibdev, "VERBS: qp_init fail\n"); |
| 943 | goto error; | 941 | goto error; |
| 944 | } | 942 | } |
| @@ -1189,7 +1187,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 244 unmodified lines | |||
| 1189 | if (ret) | 1187 | if (ret) |
| 1190 | return ret; | 1188 | return ret; |
| 1191 | 1189 | ||
| 1192 | if (vlan_id >= VLAN_N_VID && iwdev->dcb) | 1190 | if (vlan_id >= VLAN_N_VID && iwdev->dcb_vlan_mode) |
| 1193 | vlan_id = 0; | 1191 | vlan_id = 0; |
| 1194 | if (vlan_id < VLAN_N_VID) { | 1192 | if (vlan_id < VLAN_N_VID) { |
| 1195 | udp_info->insert_vlan_tag = true; | 1193 | udp_info->insert_vlan_tag = true; |
| @@ -1202,7 +1200,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 6 unmodified lines | |||
| 1202 | av->attrs = attr->ah_attr; | 1200 | av->attrs = attr->ah_attr; |
| 1203 | rdma_gid2ip((struct sockaddr *)&av->sgid_addr, &sgid_attr->gid); | 1201 | rdma_gid2ip((struct sockaddr *)&av->sgid_addr, &sgid_attr->gid); |
| 1204 | rdma_gid2ip((struct sockaddr *)&av->dgid_addr, &attr->ah_attr.grh.dgid); | 1202 | rdma_gid2ip((struct sockaddr *)&av->dgid_addr, &attr->ah_attr.grh.dgid); |
| 1205 | if (av->sgid_addr.saddr.sa_family == AF_INET6) { | 1203 | if (av->net_type == RDMA_NETWORK_IPV6) { |
| 1206 | __be32 *daddr = | 1204 | __be32 *daddr = |
| 1207 | av->dgid_addr.saddr_in6.sin6_addr.in6_u.u6_addr32; | 1205 | av->dgid_addr.saddr_in6.sin6_addr.in6_u.u6_addr32; |
| 1208 | __be32 *saddr = | 1206 | __be32 *saddr = |
| @@ -1218,7 +1216,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 9 unmodified lines | |||
| 1218 | &local_ip[0], | 1216 | &local_ip[0], |
| 1219 | false, NULL, | 1217 | false, NULL, |
| 1220 | IRDMA_ARP_RESOLVE); | 1218 | IRDMA_ARP_RESOLVE); |
| 1221 | } else { | 1219 | } else if (av->net_type == RDMA_NETWORK_IPV4) { |
| 1222 | __be32 saddr = av->sgid_addr.saddr_in.sin_addr.s_addr; | 1220 | __be32 saddr = av->sgid_addr.saddr_in.sin_addr.s_addr; |
| 1223 | __be32 daddr = av->dgid_addr.saddr_in.sin_addr.s_addr; | 1221 | __be32 daddr = av->dgid_addr.saddr_in.sin_addr.s_addr; |
| 1224 | 1222 | ||
| @@ -1792,7 +1790,6 @@ static int irdma_resize_cq(struct ib_cq *ibcq, int entries, · 567 unmodified lines | |||
| 1792 | struct irdma_device *iwdev; | 1790 | struct irdma_device *iwdev; |
| 1793 | struct irdma_pci_f *rf; | 1791 | struct irdma_pci_f *rf; |
| 1794 | struct irdma_cq_buf *cq_buf = NULL; | 1792 | struct irdma_cq_buf *cq_buf = NULL; |
| 1795 | enum irdma_status_code status = 0; | ||
| 1796 | unsigned long flags; | 1793 | unsigned long flags; |
| 1797 | int ret; | 1794 | int ret; |
| 1798 | 1795 | ||
| @@ -1885,12 +1882,10 @@ static int irdma_resize_cq(struct ib_cq *ibcq, int entries, · 86 unmodified lines | |||
| 1885 | cqp_info->in.u.cq_modify.cq = &iwcq->sc_cq; | 1882 | cqp_info->in.u.cq_modify.cq = &iwcq->sc_cq; |
| 1886 | cqp_info->in.u.cq_modify.scratch = (uintptr_t)cqp_request; | 1883 | cqp_info->in.u.cq_modify.scratch = (uintptr_t)cqp_request; |
| 1887 | cqp_info->post_sq = 1; | 1884 | cqp_info->post_sq = 1; |
| 1888 | status = irdma_handle_cqp_op(rf, cqp_request); | 1885 | ret = irdma_handle_cqp_op(rf, cqp_request); |
| 1889 | irdma_put_cqp_request(&rf->cqp, cqp_request); | 1886 | irdma_put_cqp_request(&rf->cqp, cqp_request); |
| 1890 | if (status) { | 1887 | if (ret) |
| 1891 | ret = -EPROTO; | ||
| 1892 | goto error; | 1888 | goto error; |
| 1893 | } | ||
| 1894 | 1889 | ||
| 1895 | spin_lock_irqsave(&iwcq->lock, flags); | 1890 | spin_lock_irqsave(&iwcq->lock, flags); |
| 1896 | if (cq_buf) { | 1891 | if (cq_buf) { |
| @@ -1945,7 +1940,6 @@ static int irdma_create_cq(struct ib_cq *ibcq, · 48 unmodified lines | |||
| 1945 | struct irdma_sc_cq *cq; | 1940 | struct irdma_sc_cq *cq; |
| 1946 | struct irdma_sc_dev *dev = &rf->sc_dev; | 1941 | struct irdma_sc_dev *dev = &rf->sc_dev; |
| 1947 | struct irdma_cq_init_info info = {}; | 1942 | struct irdma_cq_init_info info = {}; |
| 1948 | enum irdma_status_code status; | ||
| 1949 | struct irdma_cqp_request *cqp_request; | 1943 | struct irdma_cqp_request *cqp_request; |
| 1950 | struct cqp_cmds_info *cqp_info; | 1944 | struct cqp_cmds_info *cqp_info; |
| 1951 | struct irdma_cq_uk_init_info *ukinfo = &info.cq_uk_init_info; | 1945 | struct irdma_cq_uk_init_info *ukinfo = &info.cq_uk_init_info; |
| @@ -2095,12 +2089,10 @@ static int irdma_create_cq(struct ib_cq *ibcq, · 143 unmodified lines | |||
| 2095 | cqp_info->in.u.cq_create.cq = cq; | 2089 | cqp_info->in.u.cq_create.cq = cq; |
| 2096 | cqp_info->in.u.cq_create.check_overflow = true; | 2090 | cqp_info->in.u.cq_create.check_overflow = true; |
| 2097 | cqp_info->in.u.cq_create.scratch = (uintptr_t)cqp_request; | 2091 | cqp_info->in.u.cq_create.scratch = (uintptr_t)cqp_request; |
| 2098 | status = irdma_handle_cqp_op(rf, cqp_request); | 2092 | err_code = irdma_handle_cqp_op(rf, cqp_request); |
| 2099 | irdma_put_cqp_request(&rf->cqp, cqp_request); | 2093 | irdma_put_cqp_request(&rf->cqp, cqp_request); |
| 2100 | if (status) { | 2094 | if (err_code) |
| 2101 | err_code = -ENOMEM; | ||
| 2102 | goto cq_free_rsrc; | 2095 | goto cq_free_rsrc; |
| 2103 | } | ||
| 2104 | 2096 | ||
| 2105 | if (udata) { | 2097 | if (udata) { |
| 2106 | struct irdma_create_cq_resp resp = {}; | 2098 | struct irdma_create_cq_resp resp = {}; |
| @@ -2309,14 +2301,14 @@ static int irdma_setup_pbles(struct irdma_pci_f *rf, struct irdma_mr *iwmr, · 202 unmodified lines | |||
| 2309 | struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc; | 2301 | struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc; |
| 2310 | struct irdma_pble_info *pinfo; | 2302 | struct irdma_pble_info *pinfo; |
| 2311 | u64 *pbl; | 2303 | u64 *pbl; |
| 2312 | enum irdma_status_code status; | 2304 | int status; |
| 2313 | enum irdma_pble_level level = PBLE_LEVEL_1; | 2305 | enum irdma_pble_level level = PBLE_LEVEL_1; |
| 2314 | 2306 | ||
| 2315 | if (use_pbles) { | 2307 | if (use_pbles) { |
| 2316 | status = irdma_get_pble(rf->pble_rsrc, palloc, iwmr->page_cnt, | 2308 | status = irdma_get_pble(rf->pble_rsrc, palloc, iwmr->page_cnt, |
| 2317 | false); | 2309 | false); |
| 2318 | if (status) | 2310 | if (status) |
| 2319 | return -ENOMEM; | 2311 | return status; |
| 2320 | 2312 | ||
| 2321 | iwpbl->pbl_allocated = true; | 2313 | iwpbl->pbl_allocated = true; |
| 2322 | level = palloc->level; | 2314 | level = palloc->level; |
| @@ -2434,7 +2426,7 @@ static int irdma_hw_alloc_mw(struct irdma_device *iwdev, struct irdma_mr *iwmr) · 111 unmodified lines | |||
| 2434 | struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); | 2426 | struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); |
| 2435 | struct irdma_cqp_request *cqp_request; | 2427 | struct irdma_cqp_request *cqp_request; |
| 2436 | struct cqp_cmds_info *cqp_info; | 2428 | struct cqp_cmds_info *cqp_info; |
| 2437 | enum irdma_status_code status; | 2429 | int status; |
| 2438 | 2430 | ||
| 2439 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); | 2431 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); |
| 2440 | if (!cqp_request) | 2432 | if (!cqp_request) |
| @@ -2457,7 +2449,7 @@ static int irdma_hw_alloc_mw(struct irdma_device *iwdev, struct irdma_mr *iwmr) · 16 unmodified lines | |||
| 2457 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); | 2449 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); |
| 2458 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); | 2450 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); |
| 2459 | 2451 | ||
| 2460 | return status ? -ENOMEM : 0; | 2452 | return status; |
| 2461 | } | 2453 | } |
| 2462 | 2454 | ||
| 2463 | /** | 2455 | /** |
| @@ -2509,7 +2501,7 @@ static int irdma_dealloc_mw(struct ib_mw *ibmw) · 45 unmodified lines | |||
| 2509 | cqp_info = &cqp_request->info; | 2501 | cqp_info = &cqp_request->info; |
| 2510 | info = &cqp_info->in.u.dealloc_stag.info; | 2502 | info = &cqp_info->in.u.dealloc_stag.info; |
| 2511 | memset(info, 0, sizeof(*info)); | 2503 | memset(info, 0, sizeof(*info)); |
| 2512 | info->pd_id = iwpd->sc_pd.pd_id & 0x00007fff; | 2504 | info->pd_id = iwpd->sc_pd.pd_id; |
| 2513 | info->stag_idx = ibmw->rkey >> IRDMA_CQPSQ_STAG_IDX_S; | 2505 | info->stag_idx = ibmw->rkey >> IRDMA_CQPSQ_STAG_IDX_S; |
| 2514 | info->mr = false; | 2506 | info->mr = false; |
| 2515 | cqp_info->cqp_cmd = IRDMA_OP_DEALLOC_STAG; | 2507 | cqp_info->cqp_cmd = IRDMA_OP_DEALLOC_STAG; |
| @@ -2533,8 +2525,7 @@ static int irdma_hw_alloc_stag(struct irdma_device *iwdev, · 17 unmodified lines | |||
| 2533 | { | 2525 | { |
| 2534 | struct irdma_allocate_stag_info *info; | 2526 | struct irdma_allocate_stag_info *info; |
| 2535 | struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); | 2527 | struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); |
| 2536 | enum irdma_status_code status; | 2528 | int status; |
| 2537 | int err = 0; | ||
| 2538 | struct irdma_cqp_request *cqp_request; | 2529 | struct irdma_cqp_request *cqp_request; |
| 2539 | struct cqp_cmds_info *cqp_info; | 2530 | struct cqp_cmds_info *cqp_info; |
| 2540 | 2531 | ||
| @@ -2556,10 +2547,8 @@ static int irdma_hw_alloc_stag(struct irdma_device *iwdev, · 15 unmodified lines | |||
| 2556 | cqp_info->in.u.alloc_stag.scratch = (uintptr_t)cqp_request; | 2547 | cqp_info->in.u.alloc_stag.scratch = (uintptr_t)cqp_request; |
| 2557 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); | 2548 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); |
| 2558 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); | 2549 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); |
| 2559 | if (status) | ||
| 2560 | err = -ENOMEM; | ||
| 2561 | 2550 | ||
| 2562 | return err; | 2551 | return status; |
| 2563 | } | 2552 | } |
| 2564 | 2553 | ||
| 2565 | /** | 2554 | /** |
| @@ -2575,9 +2564,8 @@ static struct ib_mr *irdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, · 9 unmodified lines | |||
| 2575 | struct irdma_pble_alloc *palloc; | 2564 | struct irdma_pble_alloc *palloc; |
| 2576 | struct irdma_pbl *iwpbl; | 2565 | struct irdma_pbl *iwpbl; |
| 2577 | struct irdma_mr *iwmr; | 2566 | struct irdma_mr *iwmr; |
| 2578 | enum irdma_status_code status; | ||
| 2579 | u32 stag; | 2567 | u32 stag; |
| 2580 | int err_code = -ENOMEM; | 2568 | int err_code; |
| 2581 | 2569 | ||
| 2582 | iwmr = kzalloc(sizeof(*iwmr), GFP_KERNEL); | 2570 | iwmr = kzalloc(sizeof(*iwmr), GFP_KERNEL); |
| 2583 | if (!iwmr) | 2571 | if (!iwmr) |
| @@ -2599,9 +2587,9 @@ static struct ib_mr *irdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, · 15 unmodified lines | |||
| 2599 | iwmr->type = IRDMA_MEMREG_TYPE_MEM; | 2587 | iwmr->type = IRDMA_MEMREG_TYPE_MEM; |
| 2600 | palloc = &iwpbl->pble_alloc; | 2588 | palloc = &iwpbl->pble_alloc; |
| 2601 | iwmr->page_cnt = max_num_sg; | 2589 | iwmr->page_cnt = max_num_sg; |
| 2602 | status = irdma_get_pble(iwdev->rf->pble_rsrc, palloc, iwmr->page_cnt, | 2590 | err_code = irdma_get_pble(iwdev->rf->pble_rsrc, palloc, iwmr->page_cnt, |
| 2603 | true); | 2591 | true); |
| 2604 | if (status) | 2592 | if (err_code) |
| 2605 | goto err_get_pble; | 2593 | goto err_get_pble; |
| 2606 | 2594 | ||
| 2607 | err_code = irdma_hw_alloc_stag(iwdev, iwmr); | 2595 | err_code = irdma_hw_alloc_stag(iwdev, iwmr); |
| @@ -2672,10 +2660,9 @@ static int irdma_hwreg_mr(struct irdma_device *iwdev, struct irdma_mr *iwmr, · 64 unmodified lines | |||
| 2672 | struct irdma_reg_ns_stag_info *stag_info; | 2660 | struct irdma_reg_ns_stag_info *stag_info; |
| 2673 | struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); | 2661 | struct irdma_pd *iwpd = to_iwpd(iwmr->ibmr.pd); |
| 2674 | struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc; | 2662 | struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc; |
| 2675 | enum irdma_status_code status; | ||
| 2676 | int err = 0; | ||
| 2677 | struct irdma_cqp_request *cqp_request; | 2663 | struct irdma_cqp_request *cqp_request; |
| 2678 | struct cqp_cmds_info *cqp_info; | 2664 | struct cqp_cmds_info *cqp_info; |
| 2665 | int ret; | ||
| 2679 | 2666 | ||
| 2680 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); | 2667 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); |
| 2681 | if (!cqp_request) | 2668 | if (!cqp_request) |
| @@ -2712,12 +2699,10 @@ static int irdma_hwreg_mr(struct irdma_device *iwdev, struct irdma_mr *iwmr, · 30 unmodified lines | |||
| 2712 | cqp_info->post_sq = 1; | 2699 | cqp_info->post_sq = 1; |
| 2713 | cqp_info->in.u.mr_reg_non_shared.dev = &iwdev->rf->sc_dev; | 2700 | cqp_info->in.u.mr_reg_non_shared.dev = &iwdev->rf->sc_dev; |
| 2714 | cqp_info->in.u.mr_reg_non_shared.scratch = (uintptr_t)cqp_request; | 2701 | cqp_info->in.u.mr_reg_non_shared.scratch = (uintptr_t)cqp_request; |
| 2715 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); | 2702 | ret = irdma_handle_cqp_op(iwdev->rf, cqp_request); |
| 2716 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); | 2703 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); |
| 2717 | if (status) | ||
| 2718 | err = -ENOMEM; | ||
| 2719 | 2704 | ||
| 2720 | return err; | 2705 | return ret; |
| 2721 | } | 2706 | } |
| 2722 | 2707 | ||
| 2723 | /** | 2708 | /** |
| @@ -2897,7 +2882,6 @@ struct ib_mr *irdma_reg_phys_mr(struct ib_pd *pd, u64 addr, u64 size, int access · 173 unmodified lines | |||
| 2897 | struct irdma_device *iwdev = to_iwdev(pd->device); | 2882 | struct irdma_device *iwdev = to_iwdev(pd->device); |
| 2898 | struct irdma_pbl *iwpbl; | 2883 | struct irdma_pbl *iwpbl; |
| 2899 | struct irdma_mr *iwmr; | 2884 | struct irdma_mr *iwmr; |
| 2900 | enum irdma_status_code status; | ||
| 2901 | u32 stag; | 2885 | u32 stag; |
| 2902 | int ret; | 2886 | int ret; |
| 2903 | 2887 | ||
| @@ -2925,10 +2909,9 @@ struct ib_mr *irdma_reg_phys_mr(struct ib_pd *pd, u64 addr, u64 size, int access · 21 unmodified lines | |||
| 2925 | iwmr->pgaddrmem[0] = addr; | 2909 | iwmr->pgaddrmem[0] = addr; |
| 2926 | iwmr->len = size; | 2910 | iwmr->len = size; |
| 2927 | iwmr->page_size = SZ_4K; | 2911 | iwmr->page_size = SZ_4K; |
| 2928 | status = irdma_hwreg_mr(iwdev, iwmr, access); | 2912 | ret = irdma_hwreg_mr(iwdev, iwmr, access); |
| 2929 | if (status) { | 2913 | if (ret) { |
| 2930 | irdma_free_stag(iwdev, stag); | 2914 | irdma_free_stag(iwdev, stag); |
| 2931 | ret = -ENOMEM; | ||
| 2932 | goto err; | 2915 | goto err; |
| 2933 | } | 2916 | } |
| 2934 | 2917 | ||
| @@ -3021,7 +3004,7 @@ static int irdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata) · 86 unmodified lines | |||
| 3021 | cqp_info = &cqp_request->info; | 3004 | cqp_info = &cqp_request->info; |
| 3022 | info = &cqp_info->in.u.dealloc_stag.info; | 3005 | info = &cqp_info->in.u.dealloc_stag.info; |
| 3023 | memset(info, 0, sizeof(*info)); | 3006 | memset(info, 0, sizeof(*info)); |
| 3024 | info->pd_id = iwpd->sc_pd.pd_id & 0x00007fff; | 3007 | info->pd_id = iwpd->sc_pd.pd_id; |
| 3025 | info->stag_idx = ib_mr->rkey >> IRDMA_CQPSQ_STAG_IDX_S; | 3008 | info->stag_idx = ib_mr->rkey >> IRDMA_CQPSQ_STAG_IDX_S; |
| 3026 | info->mr = true; | 3009 | info->mr = true; |
| 3027 | if (iwpbl->pbl_allocated) | 3010 | if (iwpbl->pbl_allocated) |
| @@ -3057,7 +3040,6 @@ static int irdma_post_send(struct ib_qp *ibqp, · 29 unmodified lines | |||
| 3057 | struct irdma_qp_uk *ukqp; | 3040 | struct irdma_qp_uk *ukqp; |
| 3058 | struct irdma_sc_dev *dev; | 3041 | struct irdma_sc_dev *dev; |
| 3059 | struct irdma_post_sq_info info; | 3042 | struct irdma_post_sq_info info; |
| 3060 | enum irdma_status_code ret; | ||
| 3061 | int err = 0; | 3043 | int err = 0; |
| 3062 | unsigned long flags; | 3044 | unsigned long flags; |
| 3063 | bool inv_stag; | 3045 | bool inv_stag; |
| @@ -3116,7 +3098,7 @@ static int irdma_post_send(struct ib_qp *ibqp, · 52 unmodified lines | |||
| 3116 | info.op.inline_send.qkey = ud_wr(ib_wr)->remote_qkey; | 3098 | info.op.inline_send.qkey = ud_wr(ib_wr)->remote_qkey; |
| 3117 | info.op.inline_send.dest_qp = ud_wr(ib_wr)->remote_qpn; | 3099 | info.op.inline_send.dest_qp = ud_wr(ib_wr)->remote_qpn; |
| 3118 | } | 3100 | } |
| 3119 | ret = irdma_uk_inline_send(ukqp, &info, false); | 3101 | err = irdma_uk_inline_send(ukqp, &info, false); |
| 3120 | } else { | 3102 | } else { |
| 3121 | info.op.send.num_sges = ib_wr->num_sge; | 3103 | info.op.send.num_sges = ib_wr->num_sge; |
| 3122 | info.op.send.sg_list = ib_wr->sg_list; | 3104 | info.op.send.sg_list = ib_wr->sg_list; |
| @@ -3127,14 +3109,7 @@ static int irdma_post_send(struct ib_qp *ibqp, · 4 unmodified lines | |||
| 3127 | info.op.send.qkey = ud_wr(ib_wr)->remote_qkey; | 3109 | info.op.send.qkey = ud_wr(ib_wr)->remote_qkey; |
| 3128 | info.op.send.dest_qp = ud_wr(ib_wr)->remote_qpn; | 3110 | info.op.send.dest_qp = ud_wr(ib_wr)->remote_qpn; |
| 3129 | } | 3111 | } |
| 3130 | ret = irdma_uk_send(ukqp, &info, false); | 3112 | err = irdma_uk_send(ukqp, &info, false); |
| 3131 | } | ||
| 3132 | |||
| 3133 | if (ret) { | ||
| 3134 | if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) | ||
| 3135 | err = -ENOMEM; | ||
| 3136 | else | ||
| 3137 | err = -EINVAL; | ||
| 3138 | } | 3113 | } |
| 3139 | break; | 3114 | break; |
| 3140 | case IB_WR_RDMA_WRITE_WITH_IMM: | 3115 | case IB_WR_RDMA_WRITE_WITH_IMM: |
| @@ -3160,20 +3135,13 @@ static int irdma_post_send(struct ib_qp *ibqp, · 19 unmodified lines | |||
| 3160 | rdma_wr(ib_wr)->remote_addr; | 3135 | rdma_wr(ib_wr)->remote_addr; |
| 3161 | info.op.inline_rdma_write.rem_addr.lkey = | 3136 | info.op.inline_rdma_write.rem_addr.lkey = |
| 3162 | rdma_wr(ib_wr)->rkey; | 3137 | rdma_wr(ib_wr)->rkey; |
| 3163 | ret = irdma_uk_inline_rdma_write(ukqp, &info, false); | 3138 | err = irdma_uk_inline_rdma_write(ukqp, &info, false); |
| 3164 | } else { | 3139 | } else { |
| 3165 | info.op.rdma_write.lo_sg_list = (void *)ib_wr->sg_list; | 3140 | info.op.rdma_write.lo_sg_list = (void *)ib_wr->sg_list; |
| 3166 | info.op.rdma_write.num_lo_sges = ib_wr->num_sge; | 3141 | info.op.rdma_write.num_lo_sges = ib_wr->num_sge; |
| 3167 | info.op.rdma_write.rem_addr.addr = rdma_wr(ib_wr)->remote_addr; | 3142 | info.op.rdma_write.rem_addr.addr = rdma_wr(ib_wr)->remote_addr; |
| 3168 | info.op.rdma_write.rem_addr.lkey = rdma_wr(ib_wr)->rkey; | 3143 | info.op.rdma_write.rem_addr.lkey = rdma_wr(ib_wr)->rkey; |
| 3169 | ret = irdma_uk_rdma_write(ukqp, &info, false); | 3144 | err = irdma_uk_rdma_write(ukqp, &info, false); |
| 3170 | } | ||
| 3171 | |||
| 3172 | if (ret) { | ||
| 3173 | if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) | ||
| 3174 | err = -ENOMEM; | ||
| 3175 | else | ||
| 3176 | err = -EINVAL; | ||
| 3177 | } | 3145 | } |
| 3178 | break; | 3146 | break; |
| 3179 | case IB_WR_RDMA_READ_WITH_INV: | 3147 | case IB_WR_RDMA_READ_WITH_INV: |
| @@ -3190,21 +3158,12 @@ static int irdma_post_send(struct ib_qp *ibqp, · 10 unmodified lines | |||
| 3190 | info.op.rdma_read.rem_addr.lkey = rdma_wr(ib_wr)->rkey; | 3158 | info.op.rdma_read.rem_addr.lkey = rdma_wr(ib_wr)->rkey; |
| 3191 | info.op.rdma_read.lo_sg_list = (void *)ib_wr->sg_list; | 3159 | info.op.rdma_read.lo_sg_list = (void *)ib_wr->sg_list; |
| 3192 | info.op.rdma_read.num_lo_sges = ib_wr->num_sge; | 3160 | info.op.rdma_read.num_lo_sges = ib_wr->num_sge; |
| 3193 | 3161 | err = irdma_uk_rdma_read(ukqp, &info, inv_stag, false); | |
| 3194 | ret = irdma_uk_rdma_read(ukqp, &info, inv_stag, false); | ||
| 3195 | if (ret) { | ||
| 3196 | if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) | ||
| 3197 | err = -ENOMEM; | ||
| 3198 | else | ||
| 3199 | err = -EINVAL; | ||
| 3200 | } | ||
| 3201 | break; | 3162 | break; |
| 3202 | case IB_WR_LOCAL_INV: | 3163 | case IB_WR_LOCAL_INV: |
| 3203 | info.op_type = IRDMA_OP_TYPE_INV_STAG; | 3164 | info.op_type = IRDMA_OP_TYPE_INV_STAG; |
| 3204 | info.op.inv_local_stag.target_stag = ib_wr->ex.invalidate_rkey; | 3165 | info.op.inv_local_stag.target_stag = ib_wr->ex.invalidate_rkey; |
| 3205 | ret = irdma_uk_stag_local_invalidate(ukqp, &info, true); | 3166 | err = irdma_uk_stag_local_invalidate(ukqp, &info, true); |
| 3206 | if (ret) | ||
| 3207 | err = -ENOMEM; | ||
| 3208 | break; | 3167 | break; |
| 3209 | case IB_WR_REG_MR: { | 3168 | case IB_WR_REG_MR: { |
| 3210 | struct irdma_mr *iwmr = to_iwmr(reg_wr(ib_wr)->mr); | 3169 | struct irdma_mr *iwmr = to_iwmr(reg_wr(ib_wr)->mr); |
| @@ -3226,10 +3185,8 @@ static int irdma_post_send(struct ib_qp *ibqp, · 15 unmodified lines | |||
| 3226 | stag_info.local_fence = ib_wr->send_flags & IB_SEND_FENCE; | 3185 | stag_info.local_fence = ib_wr->send_flags & IB_SEND_FENCE; |
| 3227 | if (iwmr->npages > IRDMA_MIN_PAGES_PER_FMR) | 3186 | if (iwmr->npages > IRDMA_MIN_PAGES_PER_FMR) |
| 3228 | stag_info.chunk_size = 1; | 3187 | stag_info.chunk_size = 1; |
| 3229 | ret = irdma_sc_mr_fast_register(&iwqp->sc_qp, &stag_info, | 3188 | err = irdma_sc_mr_fast_register(&iwqp->sc_qp, &stag_info, |
| 3230 | true); | 3189 | true); |
| 3231 | if (ret) | ||
| 3232 | err = -ENOMEM; | ||
| 3233 | break; | 3190 | break; |
| 3234 | } | 3191 | } |
| 3235 | default: | 3192 | default: |
| @@ -3274,7 +3231,6 @@ static int irdma_post_recv(struct ib_qp *ibqp, · 38 unmodified lines | |||
| 3274 | struct irdma_qp *iwqp; | 3231 | struct irdma_qp *iwqp; |
| 3275 | struct irdma_qp_uk *ukqp; | 3232 | struct irdma_qp_uk *ukqp; |
| 3276 | struct irdma_post_rq_info post_recv = {}; | 3233 | struct irdma_post_rq_info post_recv = {}; |
| 3277 | enum irdma_status_code ret = 0; | ||
| 3278 | unsigned long flags; | 3234 | unsigned long flags; |
| 3279 | int err = 0; | 3235 | int err = 0; |
| 3280 | bool reflush = false; | 3236 | bool reflush = false; |
| @@ -3289,14 +3245,10 @@ static int irdma_post_recv(struct ib_qp *ibqp, · 8 unmodified lines | |||
| 3289 | post_recv.num_sges = ib_wr->num_sge; | 3245 | post_recv.num_sges = ib_wr->num_sge; |
| 3290 | post_recv.wr_id = ib_wr->wr_id; | 3246 | post_recv.wr_id = ib_wr->wr_id; |
| 3291 | post_recv.sg_list = ib_wr->sg_list; | 3247 | post_recv.sg_list = ib_wr->sg_list; |
| 3292 | ret = irdma_uk_post_receive(ukqp, &post_recv); | 3248 | err = irdma_uk_post_receive(ukqp, &post_recv); |
| 3293 | if (ret) { | 3249 | if (err) { |
| 3294 | ibdev_dbg(&iwqp->iwdev->ibdev, | 3250 | ibdev_dbg(&iwqp->iwdev->ibdev, |
| 3295 | "VERBS: post_recv err %d\n", ret); | 3251 | "VERBS: post_recv err %d\n", err); |
| 3296 | if (ret == IRDMA_ERR_QP_TOOMANY_WRS_POSTED) | ||
| 3297 | err = -ENOMEM; | ||
| 3298 | else | ||
| 3299 | err = -EINVAL; | ||
| 3300 | goto out; | 3252 | goto out; |
| 3301 | } | 3253 | } |
| 3302 | 3254 | ||
| @@ -3483,7 +3435,7 @@ static int __irdma_poll_cq(struct irdma_cq *iwcq, int num_entries, struct ib_wc · 180 unmodified lines | |||
| 3483 | struct irdma_cq_buf *last_buf = NULL; | 3435 | struct irdma_cq_buf *last_buf = NULL; |
| 3484 | struct irdma_cq_poll_info *cur_cqe = &iwcq->cur_cqe; | 3436 | struct irdma_cq_poll_info *cur_cqe = &iwcq->cur_cqe; |
| 3485 | struct irdma_cq_buf *cq_buf; | 3437 | struct irdma_cq_buf *cq_buf; |
| 3486 | enum irdma_status_code ret; | 3438 | int ret; |
| 3487 | struct irdma_device *iwdev; | 3439 | struct irdma_device *iwdev; |
| 3488 | struct irdma_cq_uk *ukcq; | 3440 | struct irdma_cq_uk *ukcq; |
| 3489 | bool cq_new_cqe = false; | 3441 | bool cq_new_cqe = false; |
| @@ -3503,10 +3455,10 @@ static int __irdma_poll_cq(struct irdma_cq *iwcq, int num_entries, struct ib_wc · 13 unmodified lines | |||
| 3503 | cq_new_cqe = true; | 3455 | cq_new_cqe = true; |
| 3504 | continue; | 3456 | continue; |
| 3505 | } | 3457 | } |
| 3506 | if (ret == IRDMA_ERR_Q_EMPTY) | 3458 | if (ret == -ENOENT) |
| 3507 | break; | 3459 | break; |
| 3508 | /* QP using the CQ is destroyed. Skip reporting this CQE */ | 3460 | /* QP using the CQ is destroyed. Skip reporting this CQE */ |
| 3509 | if (ret == IRDMA_ERR_Q_DESTROYED) { | 3461 | if (ret == -EFAULT) { |
| 3510 | cq_new_cqe = true; | 3462 | cq_new_cqe = true; |
| 3511 | continue; | 3463 | continue; |
| 3512 | } | 3464 | } |
| @@ -3528,10 +3480,10 @@ static int __irdma_poll_cq(struct irdma_cq *iwcq, int num_entries, struct ib_wc · 15 unmodified lines | |||
| 3528 | continue; | 3480 | continue; |
| 3529 | } | 3481 | } |
| 3530 | 3482 | ||
| 3531 | if (ret == IRDMA_ERR_Q_EMPTY) | 3483 | if (ret == -ENOENT) |
| 3532 | break; | 3484 | break; |
| 3533 | /* QP using the CQ is destroyed. Skip reporting this CQE */ | 3485 | /* QP using the CQ is destroyed. Skip reporting this CQE */ |
| 3534 | if (ret == IRDMA_ERR_Q_DESTROYED) { | 3486 | if (ret == -EFAULT) { |
| 3535 | cq_new_cqe = true; | 3487 | cq_new_cqe = true; |
| 3536 | continue; | 3488 | continue; |
| 3537 | } | 3489 | } |
| @@ -3553,7 +3505,7 @@ error: · 15 unmodified lines | |||
| 3553 | ibdev_dbg(&iwdev->ibdev, "%s: Error polling CQ, irdma_err: %d\n", | 3505 | ibdev_dbg(&iwdev->ibdev, "%s: Error polling CQ, irdma_err: %d\n", |
| 3554 | __func__, ret); | 3506 | __func__, ret); |
| 3555 | 3507 | ||
| 3556 | return -EINVAL; | 3508 | return ret; |
| 3557 | } | 3509 | } |
| 3558 | 3510 | ||
| 3559 | /** | 3511 | /** |
| @@ -3859,7 +3811,7 @@ static int irdma_mcast_cqp_op(struct irdma_device *iwdev, · 299 unmodified lines | |||
| 3859 | { | 3811 | { |
| 3860 | struct cqp_cmds_info *cqp_info; | 3812 | struct cqp_cmds_info *cqp_info; |
| 3861 | struct irdma_cqp_request *cqp_request; | 3813 | struct irdma_cqp_request *cqp_request; |
| 3862 | enum irdma_status_code status; | 3814 | int status; |
| 3863 | 3815 | ||
| 3864 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); | 3816 | cqp_request = irdma_alloc_and_get_cqp_request(&iwdev->rf->cqp, true); |
| 3865 | if (!cqp_request) | 3817 | if (!cqp_request) |
| @@ -3873,10 +3825,8 @@ static int irdma_mcast_cqp_op(struct irdma_device *iwdev, · 7 unmodified lines | |||
| 3873 | cqp_info->in.u.mc_create.cqp = &iwdev->rf->cqp.sc_cqp; | 3825 | cqp_info->in.u.mc_create.cqp = &iwdev->rf->cqp.sc_cqp; |
| 3874 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); | 3826 | status = irdma_handle_cqp_op(iwdev->rf, cqp_request); |
| 3875 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); | 3827 | irdma_put_cqp_request(&iwdev->rf->cqp, cqp_request); |
| 3876 | if (status) | ||
| 3877 | return -ENOMEM; | ||
| 3878 | 3828 | ||
| 3879 | return 0; | 3829 | return status; |
| 3880 | } | 3830 | } |
| 3881 | 3831 | ||
| 3882 | /** | 3832 | /** |
| @@ -3932,11 +3882,7 @@ static int irdma_attach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid) · 49 unmodified lines | |||
| 3932 | int ret = 0; | 3882 | int ret = 0; |
| 3933 | bool ipv4; | 3883 | bool ipv4; |
| 3934 | u16 vlan_id; | 3884 | u16 vlan_id; |
| 3935 | union { | 3885 | union irdma_sockaddr sgid_addr; |
| 3936 | struct sockaddr saddr; | ||
| 3937 | struct sockaddr_in saddr_in; | ||
| 3938 | struct sockaddr_in6 saddr_in6; | ||
| 3939 | } sgid_addr; | ||
| 3940 | unsigned char dmac[ETH_ALEN]; | 3886 | unsigned char dmac[ETH_ALEN]; |
| 3941 | 3887 | ||
| 3942 | rdma_gid2ip((struct sockaddr *)&sgid_addr, ibgid); | 3888 | rdma_gid2ip((struct sockaddr *)&sgid_addr, ibgid); |
| @@ -4072,11 +4018,7 @@ static int irdma_detach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid) · 129 unmodified lines | |||
| 4072 | struct irdma_mcast_grp_ctx_entry_info mcg_info = {}; | 4018 | struct irdma_mcast_grp_ctx_entry_info mcg_info = {}; |
| 4073 | int ret; | 4019 | int ret; |
| 4074 | unsigned long flags; | 4020 | unsigned long flags; |
| 4075 | union { | 4021 | union irdma_sockaddr sgid_addr; |
| 4076 | struct sockaddr saddr; | ||
| 4077 | struct sockaddr_in saddr_in; | ||
| 4078 | struct sockaddr_in6 saddr_in6; | ||
| 4079 | } sgid_addr; | ||
| 4080 | 4022 | ||
| 4081 | rdma_gid2ip((struct sockaddr *)&sgid_addr, ibgid); | 4023 | rdma_gid2ip((struct sockaddr *)&sgid_addr, ibgid); |
| 4082 | if (!ipv6_addr_v4mapped((struct in6_addr *)ibgid)) | 4024 | if (!ipv6_addr_v4mapped((struct in6_addr *)ibgid)) |
| @@ -4132,17 +4074,47 @@ static int irdma_detach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid) · 49 unmodified lines | |||
| 4132 | return 0; | 4074 | return 0; |
| 4133 | } | 4075 | } |
| 4134 | 4076 | ||
| 4135 | /** | 4077 | static int irdma_create_hw_ah(struct irdma_device *iwdev, struct irdma_ah *ah, bool sleep) |
| 4136 | * irdma_create_ah - create address handle | 4078 | { |
| 4137 | * @ibah: address handle | 4079 | struct irdma_pci_f *rf = iwdev->rf; |
| 4138 | * @attr: address handle attributes | 4080 | int err; |
| 4139 | * @udata: User data | 4081 | |
| 4140 | * | 4082 | err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, &ah->sc_ah.ah_info.ah_idx, |
| 4141 | * returns 0 on success, error otherwise | 4083 | &rf->next_ah); |
| 4142 | */ | 4084 | if (err) |
| 4143 | static int irdma_create_ah(struct ib_ah *ibah, | 4085 | return err; |
| 4144 | struct rdma_ah_init_attr *attr, | 4086 | |
| 4145 | struct ib_udata *udata) | 4087 | err = irdma_ah_cqp_op(rf, &ah->sc_ah, IRDMA_OP_AH_CREATE, sleep, |
| 4088 | irdma_gsi_ud_qp_ah_cb, &ah->sc_ah); | ||
| 4089 | |||
| 4090 | if (err) { | ||
| 4091 | ibdev_dbg(&iwdev->ibdev, "VERBS: CQP-OP Create AH fail"); | ||
| 4092 | goto err_ah_create; | ||
| 4093 | } | ||
| 4094 | |||
| 4095 | if (!sleep) { | ||
| 4096 | int cnt = CQP_COMPL_WAIT_TIME_MS * CQP_TIMEOUT_THRESHOLD; | ||
| 4097 | |||
| 4098 | do { | ||
| 4099 | irdma_cqp_ce_handler(rf, &rf->ccq.sc_cq); | ||
| 4100 | mdelay(1); | ||
| 4101 | } while (!ah->sc_ah.ah_info.ah_valid && --cnt); | ||
| 4102 | |||
| 4103 | if (!cnt) { | ||
| 4104 | ibdev_dbg(&iwdev->ibdev, "VERBS: CQP create AH timed out"); | ||
| 4105 | err = -ETIMEDOUT; | ||
| 4106 | goto err_ah_create; | ||
| 4107 | } | ||
| 4108 | } | ||
| 4109 | return 0; | ||
| 4110 | |||
| 4111 | err_ah_create: | ||
| 4112 | irdma_free_rsrc(iwdev->rf, iwdev->rf->allocated_ahs, ah->sc_ah.ah_info.ah_idx); | ||
| 4113 | |||
| 4114 | return err; | ||
| 4115 | } | ||
| 4116 | |||
| 4117 | static int irdma_setup_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *attr) | ||
| 4146 | { | 4118 | { |
| 4147 | struct irdma_pd *pd = to_iwpd(ibah->pd); | 4119 | struct irdma_pd *pd = to_iwpd(ibah->pd); |
| 4148 | struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); | 4120 | struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); |
| @@ -4151,25 +4123,13 @@ static int irdma_create_ah(struct ib_ah *ibah, · 2 unmodified lines | |||
| 4151 | struct irdma_device *iwdev = to_iwdev(ibah->pd->device); | 4123 | struct irdma_device *iwdev = to_iwdev(ibah->pd->device); |
| 4152 | struct irdma_pci_f *rf = iwdev->rf; | 4124 | struct irdma_pci_f *rf = iwdev->rf; |
| 4153 | struct irdma_sc_ah *sc_ah; | 4125 | struct irdma_sc_ah *sc_ah; |
| 4154 | u32 ah_id = 0; | ||
| 4155 | struct irdma_ah_info *ah_info; | 4126 | struct irdma_ah_info *ah_info; |
| 4156 | struct irdma_create_ah_resp uresp; | 4127 | union irdma_sockaddr sgid_addr, dgid_addr; |
| 4157 | union { | ||
| 4158 | struct sockaddr saddr; | ||
| 4159 | struct sockaddr_in saddr_in; | ||
| 4160 | struct sockaddr_in6 saddr_in6; | ||
| 4161 | } sgid_addr, dgid_addr; | ||
| 4162 | int err; | 4128 | int err; |
| 4163 | u8 dmac[ETH_ALEN]; | 4129 | u8 dmac[ETH_ALEN]; |
| 4164 | 4130 | ||
| 4165 | err = irdma_alloc_rsrc(rf, rf->allocated_ahs, rf->max_ah, &ah_id, | ||
| 4166 | &rf->next_ah); | ||
| 4167 | if (err) | ||
| 4168 | return err; | ||
| 4169 | |||
| 4170 | ah->pd = pd; | 4131 | ah->pd = pd; |
| 4171 | sc_ah = &ah->sc_ah; | 4132 | sc_ah = &ah->sc_ah; |
| 4172 | sc_ah->ah_info.ah_idx = ah_id; | ||
| 4173 | sc_ah->ah_info.vsi = &iwdev->vsi; | 4133 | sc_ah->ah_info.vsi = &iwdev->vsi; |
| 4174 | irdma_sc_init_ah(&rf->sc_dev, sc_ah); | 4134 | irdma_sc_init_ah(&rf->sc_dev, sc_ah); |
| 4175 | ah->sgid_index = ah_attr->grh.sgid_index; | 4135 | ah->sgid_index = ah_attr->grh.sgid_index; |
| @@ -4179,10 +4139,7 @@ static int irdma_create_ah(struct ib_ah *ibah, · 3 unmodified lines | |||
| 4179 | rdma_gid2ip((struct sockaddr *)&dgid_addr, &ah_attr->grh.dgid); | 4139 | rdma_gid2ip((struct sockaddr *)&dgid_addr, &ah_attr->grh.dgid); |
| 4180 | ah->av.attrs = *ah_attr; | 4140 | ah->av.attrs = *ah_attr; |
| 4181 | ah->av.net_type = rdma_gid_attr_network_type(sgid_attr); | 4141 | ah->av.net_type = rdma_gid_attr_network_type(sgid_attr); |
| 4182 | ah->av.sgid_addr.saddr = sgid_addr.saddr; | ||
| 4183 | ah->av.dgid_addr.saddr = dgid_addr.saddr; | ||
| 4184 | ah_info = &sc_ah->ah_info; | 4142 | ah_info = &sc_ah->ah_info; |
| 4185 | ah_info->ah_idx = ah_id; | ||
| 4186 | ah_info->pd_idx = pd->sc_pd.pd_id; | 4143 | ah_info->pd_idx = pd->sc_pd.pd_id; |
| 4187 | if (ah_attr->ah_flags & IB_AH_GRH) { | 4144 | if (ah_attr->ah_flags & IB_AH_GRH) { |
| 4188 | ah_info->flow_label = ah_attr->grh.flow_label; | 4145 | ah_info->flow_label = ah_attr->grh.flow_label; |
| @@ -4191,7 +4148,7 @@ static int irdma_create_ah(struct ib_ah *ibah, · 2 unmodified lines | |||
| 4191 | } | 4148 | } |
| 4192 | 4149 | ||
| 4193 | ether_addr_copy(dmac, ah_attr->roce.dmac); | 4150 | ether_addr_copy(dmac, ah_attr->roce.dmac); |
| 4194 | if (rdma_gid_attr_network_type(sgid_attr) == RDMA_NETWORK_IPV4) { | 4151 | if (ah->av.net_type == RDMA_NETWORK_IPV4) { |
| 4195 | ah_info->ipv4_valid = true; | 4152 | ah_info->ipv4_valid = true; |
| 4196 | ah_info->dest_ip_addr[0] = | 4153 | ah_info->dest_ip_addr[0] = |
| 4197 | ntohl(dgid_addr.saddr_in.sin_addr.s_addr); | 4154 | ntohl(dgid_addr.saddr_in.sin_addr.s_addr); |
| @@ -4219,17 +4176,15 @@ static int irdma_create_ah(struct ib_ah *ibah, · 21 unmodified lines | |||
| 4219 | err = rdma_read_gid_l2_fields(sgid_attr, &ah_info->vlan_tag, | 4176 | err = rdma_read_gid_l2_fields(sgid_attr, &ah_info->vlan_tag, |
| 4220 | ah_info->mac_addr); | 4177 | ah_info->mac_addr); |
| 4221 | if (err) | 4178 | if (err) |
| 4222 | goto error; | 4179 | return err; |
| 4223 | 4180 | ||
| 4224 | ah_info->dst_arpindex = irdma_add_arp(iwdev->rf, ah_info->dest_ip_addr, | 4181 | ah_info->dst_arpindex = irdma_add_arp(iwdev->rf, ah_info->dest_ip_addr, |
| 4225 | ah_info->ipv4_valid, dmac); | 4182 | ah_info->ipv4_valid, dmac); |
| 4226 | 4183 | ||
| 4227 | if (ah_info->dst_arpindex == -1) { | 4184 | if (ah_info->dst_arpindex == -1) |
| 4228 | err = -EINVAL; | 4185 | return -EINVAL; |
| 4229 | goto error; | ||
| 4230 | } | ||
| 4231 | 4186 | ||
| 4232 | if (ah_info->vlan_tag >= VLAN_N_VID && iwdev->dcb) | 4187 | if (ah_info->vlan_tag >= VLAN_N_VID && iwdev->dcb_vlan_mode) |
| 4233 | ah_info->vlan_tag = 0; | 4188 | ah_info->vlan_tag = 0; |
| 4234 | 4189 | ||
| 4235 | if (ah_info->vlan_tag < VLAN_N_VID) { | 4190 | if (ah_info->vlan_tag < VLAN_N_VID) { |
| @@ -4238,43 +4193,38 @@ static int irdma_create_ah(struct ib_ah *ibah, · 2 unmodified lines | |||
| 4238 | rt_tos2priority(ah_info->tc_tos) << VLAN_PRIO_SHIFT; | 4193 | rt_tos2priority(ah_info->tc_tos) << VLAN_PRIO_SHIFT; |
| 4239 | } | 4194 | } |
| 4240 | 4195 | ||
| 4241 | err = irdma_ah_cqp_op(iwdev->rf, sc_ah, IRDMA_OP_AH_CREATE, | 4196 | return 0; |
| 4242 | attr->flags & RDMA_CREATE_AH_SLEEPABLE, | 4197 | } |
| 4243 | irdma_gsi_ud_qp_ah_cb, sc_ah); | ||
| 4244 | |||
| 4245 | if (err) { | ||
| 4246 | ibdev_dbg(&iwdev->ibdev, | ||
| 4247 | "VERBS: CQP-OP Create AH fail"); | ||
| 4248 | goto error; | ||
| 4249 | } | ||
| 4250 | |||
| 4251 | if (!(attr->flags & RDMA_CREATE_AH_SLEEPABLE)) { | ||
| 4252 | int cnt = CQP_COMPL_WAIT_TIME_MS * CQP_TIMEOUT_THRESHOLD; | ||
| 4253 | |||
| 4254 | do { | ||
| 4255 | irdma_cqp_ce_handler(rf, &rf->ccq.sc_cq); | ||
| 4256 | mdelay(1); | ||
| 4257 | } while (!sc_ah->ah_info.ah_valid && --cnt); | ||
| 4258 | 4198 | ||
| 4259 | if (!cnt) { | 4199 | /** |
| 4260 | ibdev_dbg(&iwdev->ibdev, | 4200 | * irdma_ah_exists - Check for existing identical AH |
| 4261 | "VERBS: CQP create AH timed out"); | 4201 | * @iwdev: irdma device |
| 4262 | err = -ETIMEDOUT; | 4202 | * @new_ah: AH to check for |
| 4263 | goto error; | 4203 | * |
| 4204 | * returns true if AH is found, false if not found. | ||
| 4205 | */ | ||
| 4206 | static bool irdma_ah_exists(struct irdma_device *iwdev, | ||
| 4207 | struct irdma_ah *new_ah) | ||
| 4208 | { | ||
| 4209 | struct irdma_ah *ah; | ||
| 4210 | u32 key = new_ah->sc_ah.ah_info.dest_ip_addr[0] ^ | ||
| 4211 | new_ah->sc_ah.ah_info.dest_ip_addr[1] ^ | ||
| 4212 | new_ah->sc_ah.ah_info.dest_ip_addr[2] ^ | ||
| 4213 | new_ah->sc_ah.ah_info.dest_ip_addr[3]; | ||
| 4214 | |||
| 4215 | hash_for_each_possible(iwdev->ah_hash_tbl, ah, list, key) { | ||
| 4216 | /* Set ah_valid and ah_id the same so memcmp can work */ | ||
| 4217 | new_ah->sc_ah.ah_info.ah_idx = ah->sc_ah.ah_info.ah_idx; | ||
| 4218 | new_ah->sc_ah.ah_info.ah_valid = ah->sc_ah.ah_info.ah_valid; | ||
| 4219 | if (!memcmp(&ah->sc_ah.ah_info, &new_ah->sc_ah.ah_info, | ||
| 4220 | sizeof(ah->sc_ah.ah_info))) { | ||
| 4221 | refcount_inc(&ah->refcnt); | ||
| 4222 | new_ah->parent_ah = ah; | ||
| 4223 | return true; | ||
| 4264 | } | 4224 | } |
| 4265 | } | 4225 | } |
| 4266 | 4226 | ||
| 4267 | if (udata) { | 4227 | return false; |
| 4268 | uresp.ah_id = ah->sc_ah.ah_info.ah_idx; | ||
| 4269 | err = ib_copy_to_udata(udata, &uresp, | ||
| 4270 | min(sizeof(uresp), udata->outlen)); | ||
| 4271 | } | ||
| 4272 | return 0; | ||
| 4273 | |||
| 4274 | error: | ||
| 4275 | irdma_free_rsrc(iwdev->rf, iwdev->rf->allocated_ahs, ah_id); | ||
| 4276 | |||
| 4277 | return err; | ||
| 4278 | } | 4228 | } |
| 4279 | 4229 | ||
| 4280 | /** | 4230 | /** |
| @@ -4287,6 +4237,17 @@ static int irdma_destroy_ah(struct ib_ah *ibah, u32 ah_flags) · 6 unmodified lines | |||
| 4287 | struct irdma_device *iwdev = to_iwdev(ibah->device); | 4237 | struct irdma_device *iwdev = to_iwdev(ibah->device); |
| 4288 | struct irdma_ah *ah = to_iwah(ibah); | 4238 | struct irdma_ah *ah = to_iwah(ibah); |
| 4289 | 4239 | ||
| 4240 | if ((ah_flags & RDMA_DESTROY_AH_SLEEPABLE) && ah->parent_ah) { | ||
| 4241 | mutex_lock(&iwdev->ah_tbl_lock); | ||
| 4242 | if (!refcount_dec_and_test(&ah->parent_ah->refcnt)) { | ||
| 4243 | mutex_unlock(&iwdev->ah_tbl_lock); | ||
| 4244 | return 0; | ||
| 4245 | } | ||
| 4246 | hash_del(&ah->parent_ah->list); | ||
| 4247 | kfree(ah->parent_ah); | ||
| 4248 | mutex_unlock(&iwdev->ah_tbl_lock); | ||
| 4249 | } | ||
| 4250 | |||
| 4290 | irdma_ah_cqp_op(iwdev->rf, &ah->sc_ah, IRDMA_OP_AH_DESTROY, | 4251 | irdma_ah_cqp_op(iwdev->rf, &ah->sc_ah, IRDMA_OP_AH_DESTROY, |
| 4291 | false, NULL, ah); | 4252 | false, NULL, ah); |
| 4292 | 4253 | ||
| @@ -4296,6 +4257,80 @@ static int irdma_destroy_ah(struct ib_ah *ibah, u32 ah_flags) · 3 unmodified lines | |||
| 4296 | return 0; | 4257 | return 0; |
| 4297 | } | 4258 | } |
| 4298 | 4259 | ||
| 4260 | /** | ||
| 4261 | * irdma_create_user_ah - create user address handle | ||
| 4262 | * @ibah: address handle | ||
| 4263 | * @attr: address handle attributes | ||
| 4264 | * @udata: User data | ||
| 4265 | * | ||
| 4266 | * returns 0 on success, error otherwise | ||
| 4267 | */ | ||
| 4268 | static int irdma_create_user_ah(struct ib_ah *ibah, | ||
| 4269 | struct rdma_ah_init_attr *attr, | ||
| 4270 | struct ib_udata *udata) | ||
| 4271 | { | ||
| 4272 | struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); | ||
| 4273 | struct irdma_device *iwdev = to_iwdev(ibah->pd->device); | ||
| 4274 | struct irdma_create_ah_resp uresp; | ||
| 4275 | struct irdma_ah *parent_ah; | ||
| 4276 | int err; | ||
| 4277 | |||
| 4278 | err = irdma_setup_ah(ibah, attr); | ||
| 4279 | if (err) | ||
| 4280 | return err; | ||
| 4281 | mutex_lock(&iwdev->ah_tbl_lock); | ||
| 4282 | if (!irdma_ah_exists(iwdev, ah)) { | ||
| 4283 | err = irdma_create_hw_ah(iwdev, ah, true); | ||
| 4284 | if (err) { | ||
| 4285 | mutex_unlock(&iwdev->ah_tbl_lock); | ||
| 4286 | return err; | ||
| 4287 | } | ||
| 4288 | /* Add new AH to list */ | ||
| 4289 | parent_ah = kmemdup(ah, sizeof(*ah), GFP_KERNEL); | ||
| 4290 | if (parent_ah) { | ||
| 4291 | u32 key = parent_ah->sc_ah.ah_info.dest_ip_addr[0] ^ | ||
| 4292 | parent_ah->sc_ah.ah_info.dest_ip_addr[1] ^ | ||
| 4293 | parent_ah->sc_ah.ah_info.dest_ip_addr[2] ^ | ||
| 4294 | parent_ah->sc_ah.ah_info.dest_ip_addr[3]; | ||
| 4295 | |||
| 4296 | ah->parent_ah = parent_ah; | ||
| 4297 | hash_add(iwdev->ah_hash_tbl, &parent_ah->list, key); | ||
| 4298 | refcount_set(&parent_ah->refcnt, 1); | ||
| 4299 | } | ||
| 4300 | } | ||
| 4301 | mutex_unlock(&iwdev->ah_tbl_lock); | ||
| 4302 | |||
| 4303 | uresp.ah_id = ah->sc_ah.ah_info.ah_idx; | ||
| 4304 | err = ib_copy_to_udata(udata, &uresp, min(sizeof(uresp), udata->outlen)); | ||
| 4305 | if (err) | ||
| 4306 | irdma_destroy_ah(ibah, attr->flags); | ||
| 4307 | |||
| 4308 | return err; | ||
| 4309 | } | ||
| 4310 | |||
| 4311 | /** | ||
| 4312 | * irdma_create_ah - create address handle | ||
| 4313 | * @ibah: address handle | ||
| 4314 | * @attr: address handle attributes | ||
| 4315 | * @udata: NULL | ||
| 4316 | * | ||
| 4317 | * returns 0 on success, error otherwise | ||
| 4318 | */ | ||
| 4319 | static int irdma_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *attr, | ||
| 4320 | struct ib_udata *udata) | ||
| 4321 | { | ||
| 4322 | struct irdma_ah *ah = container_of(ibah, struct irdma_ah, ibah); | ||
| 4323 | struct irdma_device *iwdev = to_iwdev(ibah->pd->device); | ||
| 4324 | int err; | ||
| 4325 | |||
| 4326 | err = irdma_setup_ah(ibah, attr); | ||
| 4327 | if (err) | ||
| 4328 | return err; | ||
| 4329 | err = irdma_create_hw_ah(iwdev, ah, attr->flags & RDMA_CREATE_AH_SLEEPABLE); | ||
| 4330 | |||
| 4331 | return err; | ||
| 4332 | } | ||
| 4333 | |||
| 4299 | /** | 4334 | /** |
| 4300 | * irdma_query_ah - Query address handle | 4335 | * irdma_query_ah - Query address handle |
| 4301 | * @ibah: pointer to address handle | 4336 | * @ibah: pointer to address handle |
| @@ -4329,7 +4364,7 @@ static enum rdma_link_layer irdma_get_link_layer(struct ib_device *ibdev, · 27 unmodified lines | |||
| 4329 | static const struct ib_device_ops irdma_roce_dev_ops = { | 4364 | static const struct ib_device_ops irdma_roce_dev_ops = { |
| 4330 | .attach_mcast = irdma_attach_mcast, | 4365 | .attach_mcast = irdma_attach_mcast, |
| 4331 | .create_ah = irdma_create_ah, | 4366 | .create_ah = irdma_create_ah, |
| 4332 | .create_user_ah = irdma_create_ah, | 4367 | .create_user_ah = irdma_create_user_ah, |
| 4333 | .destroy_ah = irdma_destroy_ah, | 4368 | .destroy_ah = irdma_destroy_ah, |
| 4334 | .detach_mcast = irdma_detach_mcast, | 4369 | .detach_mcast = irdma_detach_mcast, |
| 4335 | .get_link_layer = irdma_get_link_layer, | 4370 | .get_link_layer = irdma_get_link_layer, |
| @@ -25,14 +25,16 @@ struct irdma_pd { · 24 unmodified lines | |||
| 25 | struct irdma_sc_pd sc_pd; | 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 | struct irdma_av { | 33 | struct irdma_av { |
| 29 | u8 macaddr[16]; | 34 | u8 macaddr[16]; |
| 30 | struct rdma_ah_attr attrs; | 35 | struct rdma_ah_attr attrs; |
| 31 | union { | 36 | union irdma_sockaddr sgid_addr; |
| 32 | struct sockaddr saddr; | 37 | union irdma_sockaddr dgid_addr; |
| 33 | struct sockaddr_in saddr_in; | ||
| 34 | struct sockaddr_in6 saddr_in6; | ||
| 35 | } sgid_addr, dgid_addr; | ||
| 36 | u8 net_type; | 38 | u8 net_type; |
| 37 | }; | 39 | }; |
| 38 | 40 | ||
| @@ -43,6 +45,9 @@ struct irdma_ah { · 4 unmodified lines | |||
| 43 | struct irdma_av av; | 45 | struct irdma_av av; |
| 44 | u8 sgid_index; | 46 | u8 sgid_index; |
| 45 | union ib_gid dgid; | 47 | union ib_gid dgid; |
| 48 | struct hlist_node list; | ||
| 49 | refcount_t refcnt; | ||
| 50 | struct irdma_ah *parent_ah; /* AH from cached list */ | ||
| 46 | }; | 51 | }; |
| 47 | 52 | ||
| 48 | struct irdma_hmc_pble { | 53 | struct irdma_hmc_pble { |
| @@ -1,7 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB | 1 | // SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB |
| 2 | /* Copyright (c) 2017 - 2021 Intel Corporation */ | 2 | /* Copyright (c) 2017 - 2021 Intel Corporation */ |
| 3 | #include "osdep.h" | 3 | #include "osdep.h" |
| 4 | #include "status.h" | ||
| 5 | #include "hmc.h" | 4 | #include "hmc.h" |
| 6 | #include "defs.h" | 5 | #include "defs.h" |
| 7 | #include "type.h" | 6 | #include "type.h" |
| @@ -87,8 +86,8 @@ static void irdma_free_node(struct irdma_sc_vsi *vsi, · 79 unmodified lines | |||
| 87 | * @node: pointer to node | 86 | * @node: pointer to node |
| 88 | * @cmd: add, remove or modify | 87 | * @cmd: add, remove or modify |
| 89 | */ | 88 | */ |
| 90 | static enum irdma_status_code | 89 | static int irdma_ws_cqp_cmd(struct irdma_sc_vsi *vsi, |
| 91 | irdma_ws_cqp_cmd(struct irdma_sc_vsi *vsi, struct irdma_ws_node *node, u8 cmd) | 90 | struct irdma_ws_node *node, u8 cmd) |
| 92 | { | 91 | { |
| 93 | struct irdma_ws_node_info node_info = {}; | 92 | struct irdma_ws_node_info node_info = {}; |
| 94 | 93 | ||
| @@ -106,7 +105,7 @@ irdma_ws_cqp_cmd(struct irdma_sc_vsi *vsi, struct irdma_ws_node *node, u8 cmd) · 11 unmodified lines | |||
| 106 | node_info.enable = node->enable; | 105 | node_info.enable = node->enable; |
| 107 | if (irdma_cqp_ws_node_cmd(vsi->dev, cmd, &node_info)) { | 106 | if (irdma_cqp_ws_node_cmd(vsi->dev, cmd, &node_info)) { |
| 108 | ibdev_dbg(to_ibdev(vsi->dev), "WS: CQP WS CMD failed\n"); | 107 | ibdev_dbg(to_ibdev(vsi->dev), "WS: CQP WS CMD failed\n"); |
| 109 | return IRDMA_ERR_NO_MEMORY; | 108 | return -ENOMEM; |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | if (node->type_leaf && cmd == IRDMA_OP_WS_ADD_NODE) { | 111 | if (node->type_leaf && cmd == IRDMA_OP_WS_ADD_NODE) { |
| @@ -234,18 +233,18 @@ static void irdma_remove_leaf(struct irdma_sc_vsi *vsi, u8 user_pri) · 121 unmodified lines | |||
| 234 | * @vsi: vsi pointer | 233 | * @vsi: vsi pointer |
| 235 | * @user_pri: user priority | 234 | * @user_pri: user priority |
| 236 | */ | 235 | */ |
| 237 | enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) | 236 | int irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) |
| 238 | { | 237 | { |
| 239 | struct irdma_ws_node *ws_tree_root; | 238 | struct irdma_ws_node *ws_tree_root; |
| 240 | struct irdma_ws_node *vsi_node; | 239 | struct irdma_ws_node *vsi_node; |
| 241 | struct irdma_ws_node *tc_node; | 240 | struct irdma_ws_node *tc_node; |
| 242 | u16 traffic_class; | 241 | u16 traffic_class; |
| 243 | enum irdma_status_code ret = 0; | 242 | int ret = 0; |
| 244 | int i; | 243 | int i; |
| 245 | 244 | ||
| 246 | mutex_lock(&vsi->dev->ws_mutex); | 245 | mutex_lock(&vsi->dev->ws_mutex); |
| 247 | if (vsi->tc_change_pending) { | 246 | if (vsi->tc_change_pending) { |
| 248 | ret = IRDMA_ERR_NOT_READY; | 247 | ret = -EBUSY; |
| 249 | goto exit; | 248 | goto exit; |
| 250 | } | 249 | } |
| 251 | 250 | ||
| @@ -258,7 +257,7 @@ enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) · 6 unmodified lines | |||
| 258 | ws_tree_root = irdma_alloc_node(vsi, user_pri, | 257 | ws_tree_root = irdma_alloc_node(vsi, user_pri, |
| 259 | WS_NODE_TYPE_PARENT, NULL); | 258 | WS_NODE_TYPE_PARENT, NULL); |
| 260 | if (!ws_tree_root) { | 259 | if (!ws_tree_root) { |
| 261 | ret = IRDMA_ERR_NO_MEMORY; | 260 | ret = -ENOMEM; |
| 262 | goto exit; | 261 | goto exit; |
| 263 | } | 262 | } |
| 264 | 263 | ||
| @@ -283,7 +282,7 @@ enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) · 18 unmodified lines | |||
| 283 | vsi_node = irdma_alloc_node(vsi, user_pri, WS_NODE_TYPE_PARENT, | 282 | vsi_node = irdma_alloc_node(vsi, user_pri, WS_NODE_TYPE_PARENT, |
| 284 | ws_tree_root); | 283 | ws_tree_root); |
| 285 | if (!vsi_node) { | 284 | if (!vsi_node) { |
| 286 | ret = IRDMA_ERR_NO_MEMORY; | 285 | ret = -ENOMEM; |
| 287 | goto vsi_add_err; | 286 | goto vsi_add_err; |
| 288 | } | 287 | } |
| 289 | 288 | ||
| @@ -310,7 +309,7 @@ enum irdma_status_code irdma_ws_add(struct irdma_sc_vsi *vsi, u8 user_pri) · 20 unmodified lines | |||
| 310 | tc_node = irdma_alloc_node(vsi, user_pri, WS_NODE_TYPE_LEAF, | 309 | tc_node = irdma_alloc_node(vsi, user_pri, WS_NODE_TYPE_LEAF, |
| 311 | vsi_node); | 310 | vsi_node); |
| 312 | if (!tc_node) { | 311 | if (!tc_node) { |
| 313 | ret = IRDMA_ERR_NO_MEMORY; | 312 | ret = -ENOMEM; |
| 314 | goto leaf_add_err; | 313 | goto leaf_add_err; |
| 315 | } | 314 | } |
| 316 | 315 | ||
| @@ -34,7 +34,7 @@ struct irdma_ws_node { · 33 unmodified lines | |||
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | struct irdma_sc_vsi; | 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 | void irdma_ws_remove(struct irdma_sc_vsi *vsi, u8 user_pri); | 38 | void irdma_ws_remove(struct irdma_sc_vsi *vsi, u8 user_pri); |
| 39 | void irdma_ws_reset(struct irdma_sc_vsi *vsi); | 39 | void irdma_ws_reset(struct irdma_sc_vsi *vsi); |
| 40 | 40 | ||
| @@ -38,7 +38,6 @@ · 37 unmodified lines | |||
| 38 | #include <rdma/ib_sa.h> | 38 | #include <rdma/ib_sa.h> |
| 39 | #include <rdma/ib_pack.h> | 39 | #include <rdma/ib_pack.h> |
| 40 | #include <linux/mlx4/cmd.h> | 40 | #include <linux/mlx4/cmd.h> |
| 41 | #include <linux/module.h> | ||
| 42 | #include <linux/init.h> | 41 | #include <linux/init.h> |
| 43 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
| 44 | #include <rdma/ib_user_verbs.h> | 43 | #include <rdma/ib_user_verbs.h> |
| @@ -320,7 +320,6 @@ int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, · 319 unmodified lines | |||
| 320 | if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) { | 320 | if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) { |
| 321 | err = -EIO; | 321 | err = -EIO; |
| 322 | *bad_wr = wr; | 322 | *bad_wr = wr; |
| 323 | nreq = 0; | ||
| 324 | goto out; | 323 | goto out; |
| 325 | } | 324 | } |
| 326 | 325 | ||
| @@ -1895,8 +1895,10 @@ subscribe_event_xa_alloc(struct mlx5_devx_event_table *devx_event_table, · 1894 unmodified lines | |||
| 1895 | key_level2, | 1895 | key_level2, |
| 1896 | obj_event, | 1896 | obj_event, |
| 1897 | GFP_KERNEL); | 1897 | GFP_KERNEL); |
| 1898 | if (err) | 1898 | if (err) { |
| 1899 | kfree(obj_event); | ||
| 1899 | return err; | 1900 | return err; |
| 1901 | } | ||
| 1900 | INIT_LIST_HEAD(&obj_event->obj_sub_list); | 1902 | INIT_LIST_HEAD(&obj_event->obj_sub_list); |
| 1901 | } | 1903 | } |
| 1902 | 1904 | ||
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | * SOFTWARE. | 30 | * SOFTWARE. |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/mlx5/vport.h> | 33 | #include <linux/mlx5/vport.h> |
| 35 | #include "mlx5_ib.h" | 34 | #include "mlx5_ib.h" |
| 36 | 35 | ||
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | * SOFTWARE. | 30 | * SOFTWARE. |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <linux/module.h> | ||
| 34 | #include <rdma/ib_umem.h> | 33 | #include <rdma/ib_umem.h> |
| 35 | #include <rdma/ib_umem_odp.h> | 34 | #include <rdma/ib_umem_odp.h> |
| 36 | #include "mlx5_ib.h" | 35 | #include "mlx5_ib.h" |
| @@ -763,9 +763,9 @@ struct mlx5_cache_ent { · 762 unmodified lines | |||
| 763 | 763 | ||
| 764 | char name[4]; | 764 | char name[4]; |
| 765 | u32 order; | 765 | u32 order; |
| 766 | u32 xlt; | ||
| 767 | u32 access_mode; | 766 | u32 access_mode; |
| 768 | u32 page; | 767 | u32 page; |
| 768 | unsigned int ndescs; | ||
| 769 | 769 | ||
| 770 | u8 disabled:1; | 770 | u8 disabled:1; |
| 771 | u8 fill_to_high_water:1; | 771 | u8 fill_to_high_water:1; |
| @@ -788,7 +788,6 @@ struct mlx5_cache_ent { · 16 unmodified lines | |||
| 788 | u32 miss; | 788 | u32 miss; |
| 789 | 789 | ||
| 790 | struct mlx5_ib_dev *dev; | 790 | struct mlx5_ib_dev *dev; |
| 791 | struct work_struct work; | ||
| 792 | struct delayed_work dwork; | 791 | struct delayed_work dwork; |
| 793 | }; | 792 | }; |
| 794 | 793 | ||
| @@ -1344,7 +1343,8 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev); · 549 unmodified lines | |||
| 1344 | int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev); | 1343 | int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev); |
| 1345 | 1344 | ||
| 1346 | struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, | 1345 | struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, |
| 1347 | unsigned int entry, int access_flags); | 1346 | struct mlx5_cache_ent *ent, |
| 1347 | int access_flags); | ||
| 1348 | 1348 | ||
| 1349 | int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask, | 1349 | int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask, |
| 1350 | struct ib_mr_status *mr_status); | 1350 | struct ib_mr_status *mr_status); |
| @@ -1539,12 +1539,6 @@ static inline int get_uars_per_sys_page(struct mlx5_ib_dev *dev, bool lib_suppor · 188 unmodified lines | |||
| 1539 | MLX5_UARS_IN_PAGE : 1; | 1539 | MLX5_UARS_IN_PAGE : 1; |
| 1540 | } | 1540 | } |
| 1541 | 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 | } | ||
| 1547 | |||
| 1548 | extern void *xlt_emergency_page; | 1542 | extern void *xlt_emergency_page; |
| 1549 | 1543 | ||
| 1550 | int bfregn_to_uar_index(struct mlx5_ib_dev *dev, | 1544 | int bfregn_to_uar_index(struct mlx5_ib_dev *dev, |
| @@ -68,7 +68,6 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr, · 67 unmodified lines | |||
| 68 | struct ib_pd *pd) | 68 | struct ib_pd *pd) |
| 69 | { | 69 | { |
| 70 | struct mlx5_ib_dev *dev = to_mdev(pd->device); | 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 | MLX5_SET(mkc, mkc, a, !!(acc & IB_ACCESS_REMOTE_ATOMIC)); | 72 | MLX5_SET(mkc, mkc, a, !!(acc & IB_ACCESS_REMOTE_ATOMIC)); |
| 74 | MLX5_SET(mkc, mkc, rw, !!(acc & IB_ACCESS_REMOTE_WRITE)); | 73 | MLX5_SET(mkc, mkc, rw, !!(acc & IB_ACCESS_REMOTE_WRITE)); |
| @@ -76,12 +75,13 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr, · 1 unmodified line | |||
| 76 | MLX5_SET(mkc, mkc, lw, !!(acc & IB_ACCESS_LOCAL_WRITE)); | 75 | MLX5_SET(mkc, mkc, lw, !!(acc & IB_ACCESS_LOCAL_WRITE)); |
| 77 | MLX5_SET(mkc, mkc, lr, 1); | 76 | MLX5_SET(mkc, mkc, lr, 1); |
| 78 | 77 | ||
| 79 | if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_write)) | 78 | if ((acc & IB_ACCESS_RELAXED_ORDERING) && |
| 80 | MLX5_SET(mkc, mkc, relaxed_ordering_write, | 79 | pcie_relaxed_ordering_enabled(dev->mdev->pdev)) { |
| 81 | (acc & IB_ACCESS_RELAXED_ORDERING) && ro_pci_enabled); | 80 | if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_write)) |
| 82 | if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_read)) | 81 | MLX5_SET(mkc, mkc, relaxed_ordering_write, 1); |
| 83 | MLX5_SET(mkc, mkc, relaxed_ordering_read, | 82 | if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_read)) |
| 84 | (acc & IB_ACCESS_RELAXED_ORDERING) && ro_pci_enabled); | 83 | MLX5_SET(mkc, mkc, relaxed_ordering_read, 1); |
| 84 | } | ||
| 85 | 85 | ||
| 86 | MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn); | 86 | MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn); |
| 87 | MLX5_SET(mkc, mkc, qpn, 0xffffff); | 87 | MLX5_SET(mkc, mkc, qpn, 0xffffff); |
| @@ -189,6 +189,25 @@ static void create_mkey_callback(int status, struct mlx5_async_work *context) · 101 unmodified lines | |||
| 189 | spin_unlock_irqrestore(&ent->lock, flags); | 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 | static struct mlx5_ib_mr *alloc_cache_mr(struct mlx5_cache_ent *ent, void *mkc) | 211 | static struct mlx5_ib_mr *alloc_cache_mr(struct mlx5_cache_ent *ent, void *mkc) |
| 193 | { | 212 | { |
| 194 | struct mlx5_ib_mr *mr; | 213 | struct mlx5_ib_mr *mr; |
| @@ -204,7 +223,8 @@ static struct mlx5_ib_mr *alloc_cache_mr(struct mlx5_cache_ent *ent, void *mkc) · 9 unmodified lines | |||
| 204 | MLX5_SET(mkc, mkc, access_mode_1_0, ent->access_mode & 0x3); | 223 | MLX5_SET(mkc, mkc, access_mode_1_0, ent->access_mode & 0x3); |
| 205 | MLX5_SET(mkc, mkc, access_mode_4_2, (ent->access_mode >> 2) & 0x7); | 224 | MLX5_SET(mkc, mkc, access_mode_4_2, (ent->access_mode >> 2) & 0x7); |
| 206 | 225 | ||
| 207 | MLX5_SET(mkc, mkc, translations_octword_size, ent->xlt); | 226 | MLX5_SET(mkc, mkc, translations_octword_size, |
| 227 | get_mkc_octo_size(ent->access_mode, ent->ndescs)); | ||
| 208 | MLX5_SET(mkc, mkc, log_page_size, ent->page); | 228 | MLX5_SET(mkc, mkc, log_page_size, ent->page); |
| 209 | return mr; | 229 | return mr; |
| 210 | } | 230 | } |
| @@ -478,14 +498,14 @@ static void queue_adjust_cache_locked(struct mlx5_cache_ent *ent) · 267 unmodified lines | |||
| 478 | return; | 498 | return; |
| 479 | if (ent->available_mrs < ent->limit) { | 499 | if (ent->available_mrs < ent->limit) { |
| 480 | ent->fill_to_high_water = true; | 500 | ent->fill_to_high_water = true; |
| 481 | queue_work(ent->dev->cache.wq, &ent->work); | 501 | mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0); |
| 482 | } else if (ent->fill_to_high_water && | 502 | } else if (ent->fill_to_high_water && |
| 483 | ent->available_mrs + ent->pending < 2 * ent->limit) { | 503 | ent->available_mrs + ent->pending < 2 * ent->limit) { |
| 484 | /* | 504 | /* |
| 485 | * Once we start populating due to hitting a low water mark | 505 | * Once we start populating due to hitting a low water mark |
| 486 | * continue until we pass the high water mark. | 506 | * continue until we pass the high water mark. |
| 487 | */ | 507 | */ |
| 488 | queue_work(ent->dev->cache.wq, &ent->work); | 508 | mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0); |
| 489 | } else if (ent->available_mrs == 2 * ent->limit) { | 509 | } else if (ent->available_mrs == 2 * ent->limit) { |
| 490 | ent->fill_to_high_water = false; | 510 | ent->fill_to_high_water = false; |
| 491 | } else if (ent->available_mrs > 2 * ent->limit) { | 511 | } else if (ent->available_mrs > 2 * ent->limit) { |
| @@ -495,7 +515,7 @@ static void queue_adjust_cache_locked(struct mlx5_cache_ent *ent) · 3 unmodified lines | |||
| 495 | queue_delayed_work(ent->dev->cache.wq, &ent->dwork, | 515 | queue_delayed_work(ent->dev->cache.wq, &ent->dwork, |
| 496 | msecs_to_jiffies(1000)); | 516 | msecs_to_jiffies(1000)); |
| 497 | else | 517 | else |
| 498 | queue_work(ent->dev->cache.wq, &ent->work); | 518 | mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0); |
| 499 | } | 519 | } |
| 500 | } | 520 | } |
| 501 | 521 | ||
| @@ -571,33 +591,20 @@ static void delayed_cache_work_func(struct work_struct *work) · 69 unmodified lines | |||
| 571 | __cache_work_func(ent); | 591 | __cache_work_func(ent); |
| 572 | } | 592 | } |
| 573 | 593 | ||
| 574 | static void cache_work_func(struct work_struct *work) | ||
| 575 | { | ||
| 576 | struct mlx5_cache_ent *ent; | ||
| 577 | |||
| 578 | ent = container_of(work, struct mlx5_cache_ent, work); | ||
| 579 | __cache_work_func(ent); | ||
| 580 | } | ||
| 581 | |||
| 582 | /* Allocate a special entry from the cache */ | ||
| 583 | struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, | 594 | struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, |
| 584 | unsigned int entry, int access_flags) | 595 | struct mlx5_cache_ent *ent, |
| 596 | int access_flags) | ||
| 585 | { | 597 | { |
| 586 | struct mlx5_mr_cache *cache = &dev->cache; | ||
| 587 | struct mlx5_cache_ent *ent; | ||
| 588 | struct mlx5_ib_mr *mr; | 598 | struct mlx5_ib_mr *mr; |
| 589 | 599 | ||
| 590 | if (WARN_ON(entry <= MR_CACHE_LAST_STD_ENTRY || | ||
| 591 | entry >= ARRAY_SIZE(cache->ent))) | ||
| 592 | return ERR_PTR(-EINVAL); | ||
| 593 | |||
| 594 | /* Matches access in alloc_cache_mr() */ | 600 | /* Matches access in alloc_cache_mr() */ |
| 595 | if (!mlx5_ib_can_reconfig_with_umr(dev, 0, access_flags)) | 601 | if (!mlx5_ib_can_reconfig_with_umr(dev, 0, access_flags)) |
| 596 | return ERR_PTR(-EOPNOTSUPP); | 602 | return ERR_PTR(-EOPNOTSUPP); |
| 597 | 603 | ||
| 598 | ent = &cache->ent[entry]; | ||
| 599 | spin_lock_irq(&ent->lock); | 604 | spin_lock_irq(&ent->lock); |
| 600 | if (list_empty(&ent->head)) { | 605 | if (list_empty(&ent->head)) { |
| 606 | queue_adjust_cache_locked(ent); | ||
| 607 | ent->miss++; | ||
| 601 | spin_unlock_irq(&ent->lock); | 608 | spin_unlock_irq(&ent->lock); |
| 602 | mr = create_cache_mr(ent); | 609 | mr = create_cache_mr(ent); |
| 603 | if (IS_ERR(mr)) | 610 | if (IS_ERR(mr)) |
| @@ -611,32 +618,9 @@ struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, · 7 unmodified lines | |||
| 611 | 618 | ||
| 612 | mlx5_clear_mr(mr); | 619 | mlx5_clear_mr(mr); |
| 613 | } | 620 | } |
| 614 | mr->access_flags = access_flags; | ||
| 615 | return mr; | 621 | return mr; |
| 616 | } | 622 | } |
| 617 | 623 | ||
| 618 | /* Return a MR already available in the cache */ | ||
| 619 | static struct mlx5_ib_mr *get_cache_mr(struct mlx5_cache_ent *req_ent) | ||
| 620 | { | ||
| 621 | struct mlx5_ib_mr *mr = NULL; | ||
| 622 | struct mlx5_cache_ent *ent = req_ent; | ||
| 623 | |||
| 624 | spin_lock_irq(&ent->lock); | ||
| 625 | if (!list_empty(&ent->head)) { | ||
| 626 | mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list); | ||
| 627 | list_del(&mr->list); | ||
| 628 | ent->available_mrs--; | ||
| 629 | queue_adjust_cache_locked(ent); | ||
| 630 | spin_unlock_irq(&ent->lock); | ||
| 631 | mlx5_clear_mr(mr); | ||
| 632 | return mr; | ||
| 633 | } | ||
| 634 | queue_adjust_cache_locked(ent); | ||
| 635 | spin_unlock_irq(&ent->lock); | ||
| 636 | req_ent->miss++; | ||
| 637 | return NULL; | ||
| 638 | } | ||
| 639 | |||
| 640 | static void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) | 624 | static void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) |
| 641 | { | 625 | { |
| 642 | struct mlx5_cache_ent *ent = mr->cache_ent; | 626 | struct mlx5_cache_ent *ent = mr->cache_ent; |
| @@ -739,7 +723,6 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) · 96 unmodified lines | |||
| 739 | ent->dev = dev; | 723 | ent->dev = dev; |
| 740 | ent->limit = 0; | 724 | ent->limit = 0; |
| 741 | 725 | ||
| 742 | INIT_WORK(&ent->work, cache_work_func); | ||
| 743 | INIT_DELAYED_WORK(&ent->dwork, delayed_cache_work_func); | 726 | INIT_DELAYED_WORK(&ent->dwork, delayed_cache_work_func); |
| 744 | 727 | ||
| 745 | if (i > MR_CACHE_LAST_STD_ENTRY) { | 728 | if (i > MR_CACHE_LAST_STD_ENTRY) { |
| @@ -751,8 +734,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) · 5 unmodified lines | |||
| 751 | continue; | 734 | continue; |
| 752 | 735 | ||
| 753 | ent->page = PAGE_SHIFT; | 736 | ent->page = PAGE_SHIFT; |
| 754 | ent->xlt = (1 << ent->order) * sizeof(struct mlx5_mtt) / | 737 | ent->ndescs = 1 << ent->order; |
| 755 | MLX5_IB_UMR_OCTOWORD; | ||
| 756 | ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; | 738 | ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; |
| 757 | if ((dev->mdev->profile.mask & MLX5_PROF_MASK_MR_CACHE) && | 739 | if ((dev->mdev->profile.mask & MLX5_PROF_MASK_MR_CACHE) && |
| 758 | !dev->is_rep && mlx5_core_is_pf(dev->mdev) && | 740 | !dev->is_rep && mlx5_core_is_pf(dev->mdev) && |
| @@ -783,7 +765,6 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) · 24 unmodified lines | |||
| 783 | spin_lock_irq(&ent->lock); | 765 | spin_lock_irq(&ent->lock); |
| 784 | ent->disabled = true; | 766 | ent->disabled = true; |
| 785 | spin_unlock_irq(&ent->lock); | 767 | spin_unlock_irq(&ent->lock); |
| 786 | cancel_work_sync(&ent->work); | ||
| 787 | cancel_delayed_work_sync(&ent->dwork); | 768 | cancel_delayed_work_sync(&ent->dwork); |
| 788 | } | 769 | } |
| 789 | 770 | ||
| @@ -972,16 +953,9 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd, · 182 unmodified lines | |||
| 972 | return mr; | 953 | return mr; |
| 973 | } | 954 | } |
| 974 | 955 | ||
| 975 | mr = get_cache_mr(ent); | 956 | mr = mlx5_mr_cache_alloc(dev, ent, access_flags); |
| 976 | if (!mr) { | 957 | if (IS_ERR(mr)) |
| 977 | mr = create_cache_mr(ent); | 958 | return mr; |
| 978 | /* | ||
| 979 | * The above already tried to do the same stuff as reg_create(), | ||
| 980 | * no reason to try it again. | ||
| 981 | */ | ||
| 982 | if (IS_ERR(mr)) | ||
| 983 | return mr; | ||
| 984 | } | ||
| 985 | 959 | ||
| 986 | mr->ibmr.pd = pd; | 960 | mr->ibmr.pd = pd; |
| 987 | mr->umem = umem; | 961 | mr->umem = umem; |
| @@ -407,6 +407,7 @@ static void mlx5_ib_page_fault_resume(struct mlx5_ib_dev *dev, · 406 unmodified lines | |||
| 407 | static struct mlx5_ib_mr *implicit_get_child_mr(struct mlx5_ib_mr *imr, | 407 | static struct mlx5_ib_mr *implicit_get_child_mr(struct mlx5_ib_mr *imr, |
| 408 | unsigned long idx) | 408 | unsigned long idx) |
| 409 | { | 409 | { |
| 410 | struct mlx5_ib_dev *dev = mr_to_mdev(imr); | ||
| 410 | struct ib_umem_odp *odp; | 411 | struct ib_umem_odp *odp; |
| 411 | struct mlx5_ib_mr *mr; | 412 | struct mlx5_ib_mr *mr; |
| 412 | struct mlx5_ib_mr *ret; | 413 | struct mlx5_ib_mr *ret; |
| @@ -418,13 +419,14 @@ static struct mlx5_ib_mr *implicit_get_child_mr(struct mlx5_ib_mr *imr, · 5 unmodified lines | |||
| 418 | if (IS_ERR(odp)) | 419 | if (IS_ERR(odp)) |
| 419 | return ERR_CAST(odp); | 420 | return ERR_CAST(odp); |
| 420 | 421 | ||
| 421 | mr = mlx5_mr_cache_alloc( | 422 | mr = mlx5_mr_cache_alloc(dev, &dev->cache.ent[MLX5_IMR_MTT_CACHE_ENTRY], |
| 422 | mr_to_mdev(imr), MLX5_IMR_MTT_CACHE_ENTRY, imr->access_flags); | 423 | imr->access_flags); |
| 423 | if (IS_ERR(mr)) { | 424 | if (IS_ERR(mr)) { |
| 424 | ib_umem_odp_release(odp); | 425 | ib_umem_odp_release(odp); |
| 425 | return mr; | 426 | return mr; |
| 426 | } | 427 | } |
| 427 | 428 | ||
| 429 | mr->access_flags = imr->access_flags; | ||
| 428 | mr->ibmr.pd = imr->ibmr.pd; | 430 | mr->ibmr.pd = imr->ibmr.pd; |
| 429 | mr->ibmr.device = &mr_to_mdev(imr)->ib_dev; | 431 | mr->ibmr.device = &mr_to_mdev(imr)->ib_dev; |
| 430 | mr->umem = &odp->umem; | 432 | mr->umem = &odp->umem; |
| @@ -493,12 +495,15 @@ struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd, · 62 unmodified lines | |||
| 493 | if (IS_ERR(umem_odp)) | 495 | if (IS_ERR(umem_odp)) |
| 494 | return ERR_CAST(umem_odp); | 496 | return ERR_CAST(umem_odp); |
| 495 | 497 | ||
| 496 | imr = mlx5_mr_cache_alloc(dev, MLX5_IMR_KSM_CACHE_ENTRY, access_flags); | 498 | imr = mlx5_mr_cache_alloc(dev, |
| 499 | &dev->cache.ent[MLX5_IMR_KSM_CACHE_ENTRY], | ||
| 500 | access_flags); | ||
| 497 | if (IS_ERR(imr)) { | 501 | if (IS_ERR(imr)) { |
| 498 | ib_umem_odp_release(umem_odp); | 502 | ib_umem_odp_release(umem_odp); |
| 499 | return imr; | 503 | return imr; |
| 500 | } | 504 | } |
| 501 | 505 | ||
| 506 | imr->access_flags = access_flags; | ||
| 502 | imr->ibmr.pd = &pd->ibpd; | 507 | imr->ibmr.pd = &pd->ibpd; |
| 503 | imr->ibmr.iova = 0; | 508 | imr->ibmr.iova = 0; |
| 504 | imr->umem = &umem_odp->umem; | 509 | imr->umem = &umem_odp->umem; |
| @@ -1593,18 +1598,14 @@ void mlx5_odp_init_mr_cache_entry(struct mlx5_cache_ent *ent) · 1088 unmodified lines | |||
| 1593 | switch (ent->order - 2) { | 1598 | switch (ent->order - 2) { |
| 1594 | case MLX5_IMR_MTT_CACHE_ENTRY: | 1599 | case MLX5_IMR_MTT_CACHE_ENTRY: |
| 1595 | ent->page = PAGE_SHIFT; | 1600 | ent->page = PAGE_SHIFT; |
| 1596 | ent->xlt = MLX5_IMR_MTT_ENTRIES * | 1601 | ent->ndescs = MLX5_IMR_MTT_ENTRIES; |
| 1597 | sizeof(struct mlx5_mtt) / | ||
| 1598 | MLX5_IB_UMR_OCTOWORD; | ||
| 1599 | ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; | 1602 | ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT; |
| 1600 | ent->limit = 0; | 1603 | ent->limit = 0; |
| 1601 | break; | 1604 | break; |
| 1602 | 1605 | ||
| 1603 | case MLX5_IMR_KSM_CACHE_ENTRY: | 1606 | case MLX5_IMR_KSM_CACHE_ENTRY: |
| 1604 | ent->page = MLX5_KSM_PAGE_SHIFT; | 1607 | ent->page = MLX5_KSM_PAGE_SHIFT; |
| 1605 | ent->xlt = mlx5_imr_ksm_entries * | 1608 | ent->ndescs = mlx5_imr_ksm_entries; |
| 1606 | sizeof(struct mlx5_klm) / | ||
| 1607 | MLX5_IB_UMR_OCTOWORD; | ||
| 1608 | ent->access_mode = MLX5_MKC_ACCESS_MODE_KSM; | 1609 | ent->access_mode = MLX5_MKC_ACCESS_MODE_KSM; |
| 1609 | ent->limit = 0; | 1610 | ent->limit = 0; |
| 1610 | break; | 1611 | break; |
| @@ -31,7 +31,6 @@ · 30 unmodified lines | |||
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <linux/etherdevice.h> | 33 | #include <linux/etherdevice.h> |
| 34 | #include <linux/module.h> | ||
| 35 | #include <rdma/ib_umem.h> | 34 | #include <rdma/ib_umem.h> |
| 36 | #include <rdma/ib_cache.h> | 35 | #include <rdma/ib_cache.h> |
| 37 | #include <rdma/ib_user_verbs.h> | 36 | #include <rdma/ib_user_verbs.h> |
| @@ -615,7 +614,8 @@ enum { · 577 unmodified lines | |||
| 615 | 614 | ||
| 616 | static int max_bfregs(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi) | 615 | static int max_bfregs(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi) |
| 617 | { | 616 | { |
| 618 | return get_num_static_uars(dev, bfregi) * MLX5_NON_FP_BFREGS_PER_UAR; | 617 | return get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * |
| 618 | bfregi->num_static_sys_pages * MLX5_NON_FP_BFREGS_PER_UAR; | ||
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | static int num_med_bfreg(struct mlx5_ib_dev *dev, | 621 | static int num_med_bfreg(struct mlx5_ib_dev *dev, |
| @@ -3,7 +3,6 @@ · 2 unmodified lines | |||
| 3 | * Copyright (c) 2013-2018, Mellanox Technologies inc. All rights reserved. | 3 | * Copyright (c) 2013-2018, Mellanox Technologies inc. All rights reserved. |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include <linux/module.h> | ||
| 7 | #include <linux/mlx5/qp.h> | 6 | #include <linux/mlx5/qp.h> |
| 8 | #include <linux/slab.h> | 7 | #include <linux/slab.h> |
| 9 | #include <rdma/ib_umem.h> | 8 | #include <rdma/ib_umem.h> |
| @@ -939,12 +939,8 @@ static int __mthca_init_one(struct pci_dev *pdev, int hca_type) · 938 unmodified lines | |||
| 939 | 939 | ||
| 940 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); | 940 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
| 941 | if (err) { | 941 | if (err) { |
| 942 | dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n"); | 942 | dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); |
| 943 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); | 943 | goto err_free_res; |
| 944 | if (err) { | ||
| 945 | dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); | ||
| 946 | goto err_free_res; | ||
| 947 | } | ||
| 948 | } | 944 | } |
| 949 | 945 | ||
| 950 | /* We can handle large RDMA requests, so allow larger segments. */ | 946 | /* We can handle large RDMA requests, so allow larger segments. */ |
| @@ -31,8 +31,6 @@ · 30 unmodified lines | |||
| 31 | * SOFTWARE. | 31 | * SOFTWARE. |
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #include <linux/module.h> | ||
| 35 | #include <linux/moduleparam.h> | ||
| 36 | #include <linux/string.h> | 34 | #include <linux/string.h> |
| 37 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
| 38 | 36 | ||
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | * SOFTWARE. | 32 | * SOFTWARE. |
| 33 | */ | 33 | */ |
| 34 | 34 | ||
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/fs.h> | 35 | #include <linux/fs.h> |
| 37 | #include <linux/fs_context.h> | 36 | #include <linux/fs_context.h> |
| 38 | #include <linux/mount.h> | 37 | #include <linux/mount.h> |
| @@ -634,7 +634,7 @@ static const struct qib_hwerror_msgs qib_7220_hwerror_msgs[] = { · 633 unmodified lines | |||
| 634 | QLOGIC_IB_HWE_MSG(QLOGIC_IB_HWE_PCIECPLTIMEOUT, | 634 | QLOGIC_IB_HWE_MSG(QLOGIC_IB_HWE_PCIECPLTIMEOUT, |
| 635 | "PCIe completion timeout"), | 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 | * parity or memory parity error failures, because most likely we | 638 | * parity or memory parity error failures, because most likely we |
| 639 | * won't be able to talk to the core of the chip. Nonetheless, we | 639 | * won't be able to talk to the core of the chip. Nonetheless, we |
| 640 | * might see them, if they are in parts of the PCIe core that aren't | 640 | * might see them, if they are in parts of the PCIe core that aren't |
| @@ -2988,7 +2988,7 @@ done: · 2347 unmodified lines | |||
| 2988 | * the utility. Names need to be 12 chars or less (w/o newline), for proper | 2988 | * the utility. Names need to be 12 chars or less (w/o newline), for proper |
| 2989 | * display by utility. | 2989 | * display by utility. |
| 2990 | * Non-error counters are first. | 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 | * "error" counter, and doesn't count in label length. | 2992 | * "error" counter, and doesn't count in label length. |
| 2993 | * The EgrOvfl list needs to be last so we truncate them at the configured | 2993 | * The EgrOvfl list needs to be last so we truncate them at the configured |
| 2994 | * context count for the device. | 2994 | * context count for the device. |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #include <linux/debugfs.h> | 34 | #include <linux/debugfs.h> |
| 35 | #include <linux/module.h> | ||
| 36 | 35 | ||
| 37 | #include "usnic.h" | 36 | #include "usnic.h" |
| 38 | #include "usnic_log.h" | 37 | #include "usnic_log.h" |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | */ | 32 | */ |
| 33 | #include <linux/bug.h> | 33 | #include <linux/bug.h> |
| 34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
| 37 | 36 | ||
| 38 | #include "usnic_log.h" | 37 | #include "usnic_log.h" |
| @@ -31,7 +31,6 @@ · 30 unmodified lines | |||
| 31 | * | 31 | * |
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #include <linux/module.h> | ||
| 35 | #include <linux/init.h> | 34 | #include <linux/init.h> |
| 36 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
| 37 | 36 | ||
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | * SOFTWARE. | 30 | * SOFTWARE. |
| 31 | * | 31 | * |
| 32 | */ | 32 | */ |
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/init.h> | 33 | #include <linux/init.h> |
| 35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
| 36 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | */ | 32 | */ |
| 33 | #include <linux/bitmap.h> | 33 | #include <linux/bitmap.h> |
| 34 | #include <linux/file.h> | 34 | #include <linux/file.h> |
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
| 37 | #include <net/inet_sock.h> | 36 | #include <net/inet_sock.h> |
| 38 | 37 | ||
| @@ -31,7 +31,6 @@ · 30 unmodified lines | |||
| 31 | * | 31 | * |
| 32 | */ | 32 | */ |
| 33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
| 34 | #include <linux/module.h> | ||
| 35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
| 36 | 35 | ||
| 37 | #include "usnic_ib.h" | 36 | #include "usnic_ib.h" |
| @@ -811,12 +811,10 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, · 810 unmodified lines | |||
| 811 | } | 811 | } |
| 812 | 812 | ||
| 813 | /* Enable 64-Bit DMA */ | 813 | /* Enable 64-Bit DMA */ |
| 814 | if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0) { | 814 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
| 815 | ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); | 815 | if (ret) { |
| 816 | if (ret != 0) { | 816 | dev_err(&pdev->dev, "dma_set_mask failed\n"); |
| 817 | dev_err(&pdev->dev, "dma_set_mask failed\n"); | 817 | goto err_free_resource; |
| 818 | goto err_free_resource; | ||
| 819 | } | ||
| 820 | } | 818 | } |
| 821 | dma_set_max_seg_size(&pdev->dev, UINT_MAX); | 819 | dma_set_max_seg_size(&pdev->dev, UINT_MAX); |
| 822 | pci_set_master(pdev); | 820 | pci_set_master(pdev); |
| @@ -28,8 +28,8 @@ void rxe_dealloc(struct ib_device *ib_dev) · 27 unmodified lines | |||
| 28 | rxe_pool_cleanup(&rxe->cq_pool); | 28 | rxe_pool_cleanup(&rxe->cq_pool); |
| 29 | rxe_pool_cleanup(&rxe->mr_pool); | 29 | rxe_pool_cleanup(&rxe->mr_pool); |
| 30 | rxe_pool_cleanup(&rxe->mw_pool); | 30 | rxe_pool_cleanup(&rxe->mw_pool); |
| 31 | rxe_pool_cleanup(&rxe->mc_grp_pool); | 31 | |
| 32 | rxe_pool_cleanup(&rxe->mc_elem_pool); | 32 | WARN_ON(!RB_EMPTY_ROOT(&rxe->mcg_tree)); |
| 33 | 33 | ||
| 34 | if (rxe->tfm) | 34 | if (rxe->tfm) |
| 35 | crypto_free_shash(rxe->tfm); | 35 | crypto_free_shash(rxe->tfm); |
| @@ -114,106 +114,37 @@ static void rxe_init_ports(struct rxe_dev *rxe) · 78 unmodified lines | |||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | /* init pools of managed objects */ | 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; | 119 | rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC); |
| 120 | 120 | rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD); | |
| 121 | err = rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC, | 121 | rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH); |
| 122 | rxe->max_ucontext); | 122 | rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ); |
| 123 | if (err) | 123 | rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP); |
| 124 | goto err1; | 124 | rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ); |
| 125 | 125 | rxe_pool_init(rxe, &rxe->mr_pool, RXE_TYPE_MR); | |
| 126 | err = rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD, | 126 | rxe_pool_init(rxe, &rxe->mw_pool, RXE_TYPE_MW); |
| 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; | ||
| 193 | } | 127 | } |
| 194 | 128 | ||
| 195 | /* initialize rxe device state */ | 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 | /* init default device parameters */ | 132 | /* init default device parameters */ |
| 201 | rxe_init_device_param(rxe); | 133 | rxe_init_device_param(rxe); |
| 202 | 134 | ||
| 203 | rxe_init_ports(rxe); | 135 | rxe_init_ports(rxe); |
| 204 | 136 | rxe_init_pools(rxe); | |
| 205 | err = rxe_init_pools(rxe); | ||
| 206 | if (err) | ||
| 207 | return err; | ||
| 208 | 137 | ||
| 209 | /* init pending mmap list */ | 138 | /* init pending mmap list */ |
| 210 | spin_lock_init(&rxe->mmap_offset_lock); | 139 | spin_lock_init(&rxe->mmap_offset_lock); |
| 211 | spin_lock_init(&rxe->pending_lock); | 140 | spin_lock_init(&rxe->pending_lock); |
| 212 | INIT_LIST_HEAD(&rxe->pending_mmaps); | 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 | void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu) | 150 | void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu) |
| @@ -235,12 +166,7 @@ void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu) · 15 unmodified lines | |||
| 235 | */ | 166 | */ |
| 236 | int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name) | 167 | int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name) |
| 237 | { | 168 | { |
| 238 | int err; | 169 | rxe_init(rxe); |
| 239 | |||
| 240 | err = rxe_init(rxe); | ||
| 241 | if (err) | ||
| 242 | return err; | ||
| 243 | |||
| 244 | rxe_set_mtu(rxe, mtu); | 170 | rxe_set_mtu(rxe, mtu); |
| 245 | 171 | ||
| 246 | return rxe_register_device(rxe, ibdev_name); | 172 | return rxe_register_device(rxe, ibdev_name); |
| @@ -12,7 +12,6 @@ · 11 unmodified lines | |||
| 12 | #endif | 12 | #endif |
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 14 | 14 | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/skbuff.h> | 15 | #include <linux/skbuff.h> |
| 17 | 16 | ||
| 18 | #include <rdma/ib_verbs.h> | 17 | #include <rdma/ib_verbs.h> |
| @@ -99,11 +99,14 @@ void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr) · 98 unmodified lines | |||
| 99 | av->network_type = type; | 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 | struct rxe_ah *ah; | 104 | struct rxe_ah *ah; |
| 105 | u32 ah_num; | 105 | u32 ah_num; |
| 106 | 106 | ||
| 107 | if (ahp) | ||
| 108 | *ahp = NULL; | ||
| 109 | |||
| 107 | if (!pkt || !pkt->qp) | 110 | if (!pkt || !pkt->qp) |
| 108 | return NULL; | 111 | return NULL; |
| 109 | 112 | ||
| @@ -117,10 +120,22 @@ struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt) · 7 unmodified lines | |||
| 117 | if (ah_num) { | 120 | if (ah_num) { |
| 118 | /* only new user provider or kernel client */ | 121 | /* only new user provider or kernel client */ |
| 119 | ah = rxe_pool_get_index(&pkt->rxe->ah_pool, ah_num); | 122 | ah = rxe_pool_get_index(&pkt->rxe->ah_pool, ah_num); |
| 120 | if (!ah || ah->ah_num != ah_num || rxe_ah_pd(ah) != pkt->qp->pd) { | 123 | if (!ah) { |
| 121 | pr_warn("Unable to find AH matching ah_num\n"); | 124 | pr_warn("Unable to find AH matching ah_num\n"); |
| 122 | return NULL; | 125 | return NULL; |
| 123 | } | 126 | } |
| 127 | |||
| 128 | if (rxe_ah_pd(ah) != pkt->qp->pd) { | ||
| 129 | pr_warn("PDs don't match for AH and QP\n"); | ||
| 130 | rxe_put(ah); | ||
| 131 | return NULL; | ||
| 132 | } | ||
| 133 | |||
| 134 | if (ahp) | ||
| 135 | *ahp = ah; | ||
| 136 | else | ||
| 137 | rxe_put(ah); | ||
| 138 | |||
| 124 | return &ah->av; | 139 | return &ah->av; |
| 125 | } | 140 | } |
| 126 | 141 | ||
| @@ -526,7 +526,7 @@ static void rxe_drain_resp_pkts(struct rxe_qp *qp, bool notify) · 525 unmodified lines | |||
| 526 | struct rxe_queue *q = qp->sq.queue; | 526 | struct rxe_queue *q = qp->sq.queue; |
| 527 | 527 | ||
| 528 | while ((skb = skb_dequeue(&qp->resp_pkts))) { | 528 | while ((skb = skb_dequeue(&qp->resp_pkts))) { |
| 529 | rxe_drop_ref(qp); | 529 | rxe_put(qp); |
| 530 | kfree_skb(skb); | 530 | kfree_skb(skb); |
| 531 | ib_device_put(qp->ibqp.device); | 531 | ib_device_put(qp->ibqp.device); |
| 532 | } | 532 | } |
| @@ -548,7 +548,7 @@ static void free_pkt(struct rxe_pkt_info *pkt) · 15 unmodified lines | |||
| 548 | struct ib_device *dev = qp->ibqp.device; | 548 | struct ib_device *dev = qp->ibqp.device; |
| 549 | 549 | ||
| 550 | kfree_skb(skb); | 550 | kfree_skb(skb); |
| 551 | rxe_drop_ref(qp); | 551 | rxe_put(qp); |
| 552 | ib_device_put(dev); | 552 | ib_device_put(dev); |
| 553 | } | 553 | } |
| 554 | 554 | ||
| @@ -562,7 +562,7 @@ int rxe_completer(void *arg) · 7 unmodified lines | |||
| 562 | enum comp_state state; | 562 | enum comp_state state; |
| 563 | int ret = 0; | 563 | int ret = 0; |
| 564 | 564 | ||
| 565 | rxe_add_ref(qp); | 565 | rxe_get(qp); |
| 566 | 566 | ||
| 567 | if (!qp->valid || qp->req.state == QP_STATE_ERROR || | 567 | if (!qp->valid || qp->req.state == QP_STATE_ERROR || |
| 568 | qp->req.state == QP_STATE_RESET) { | 568 | qp->req.state == QP_STATE_RESET) { |
| @@ -761,7 +761,7 @@ int rxe_completer(void *arg) · 192 unmodified lines | |||
| 761 | done: | 761 | done: |
| 762 | if (pkt) | 762 | if (pkt) |
| 763 | free_pkt(pkt); | 763 | free_pkt(pkt); |
| 764 | rxe_drop_ref(qp); | 764 | rxe_put(qp); |
| 765 | 765 | ||
| 766 | return ret; | 766 | return ret; |
| 767 | } | 767 | } |
| @@ -42,13 +42,14 @@ err1: · 41 unmodified lines | |||
| 42 | static void rxe_send_complete(struct tasklet_struct *t) | 42 | static void rxe_send_complete(struct tasklet_struct *t) |
| 43 | { | 43 | { |
| 44 | struct rxe_cq *cq = from_tasklet(cq, t, comp_task); | 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 | if (cq->is_dying) { | 48 | if (cq->is_dying) { |
| 48 | spin_unlock_bh(&cq->cq_lock); | 49 | spin_unlock_irqrestore(&cq->cq_lock, flags); |
| 49 | return; | 50 | return; |
| 50 | } | 51 | } |
| 51 | spin_unlock_bh(&cq->cq_lock); | 52 | spin_unlock_irqrestore(&cq->cq_lock, flags); |
| 52 | 53 | ||
| 53 | cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context); | 54 | cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context); |
| 54 | } | 55 | } |
| @@ -107,12 +108,13 @@ int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited) · 52 unmodified lines | |||
| 107 | struct ib_event ev; | 108 | struct ib_event ev; |
| 108 | int full; | 109 | int full; |
| 109 | void *addr; | 110 | void *addr; |
| 111 | unsigned long flags; | ||
| 110 | 112 | ||
| 111 | spin_lock_bh(&cq->cq_lock); | 113 | spin_lock_irqsave(&cq->cq_lock, flags); |
| 112 | 114 | ||
| 113 | full = queue_full(cq->queue, QUEUE_TYPE_TO_CLIENT); | 115 | full = queue_full(cq->queue, QUEUE_TYPE_TO_CLIENT); |
| 114 | if (unlikely(full)) { | 116 | if (unlikely(full)) { |
| 115 | spin_unlock_bh(&cq->cq_lock); | 117 | spin_unlock_irqrestore(&cq->cq_lock, flags); |
| 116 | if (cq->ibcq.event_handler) { | 118 | if (cq->ibcq.event_handler) { |
| 117 | ev.device = cq->ibcq.device; | 119 | ev.device = cq->ibcq.device; |
| 118 | ev.element.cq = &cq->ibcq; | 120 | ev.element.cq = &cq->ibcq; |
| @@ -128,7 +130,7 @@ int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited) · 9 unmodified lines | |||
| 128 | 130 | ||
| 129 | queue_advance_producer(cq->queue, QUEUE_TYPE_TO_CLIENT); | 131 | queue_advance_producer(cq->queue, QUEUE_TYPE_TO_CLIENT); |
| 130 | 132 | ||
| 131 | spin_unlock_bh(&cq->cq_lock); | 133 | spin_unlock_irqrestore(&cq->cq_lock, flags); |
| 132 | 134 | ||
| 133 | if ((cq->notify == IB_CQ_NEXT_COMP) || | 135 | if ((cq->notify == IB_CQ_NEXT_COMP) || |
| 134 | (cq->notify == IB_CQ_SOLICITED && solicited)) { | 136 | (cq->notify == IB_CQ_SOLICITED && solicited)) { |
| @@ -141,9 +143,11 @@ int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited) · 6 unmodified lines | |||
| 141 | 143 | ||
| 142 | void rxe_cq_disable(struct rxe_cq *cq) | 144 | void rxe_cq_disable(struct rxe_cq *cq) |
| 143 | { | 145 | { |
| 144 | spin_lock_bh(&cq->cq_lock); | 146 | unsigned long flags; |
| 147 | |||
| 148 | spin_lock_irqsave(&cq->cq_lock, flags); | ||
| 145 | cq->is_dying = true; | 149 | cq->is_dying = true; |
| 146 | spin_unlock_bh(&cq->cq_lock); | 150 | spin_unlock_irqrestore(&cq->cq_lock, flags); |
| 147 | } | 151 | } |
| 148 | 152 | ||
| 149 | void rxe_cq_cleanup(struct rxe_pool_elem *elem) | 153 | void rxe_cq_cleanup(struct rxe_pool_elem *elem) |
| @@ -19,7 +19,7 @@ void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr); · 18 unmodified lines | |||
| 19 | 19 | ||
| 20 | void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr); | 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 | /* rxe_cq.c */ | 24 | /* rxe_cq.c */ |
| 25 | int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq, | 25 | int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq, |
| @@ -40,18 +40,10 @@ void rxe_cq_disable(struct rxe_cq *cq); · 14 unmodified lines | |||
| 40 | void rxe_cq_cleanup(struct rxe_pool_elem *arg); | 40 | void rxe_cq_cleanup(struct rxe_pool_elem *arg); |
| 41 | 41 | ||
| 42 | /* rxe_mcast.c */ | 42 | /* rxe_mcast.c */ |
| 43 | int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, | 43 | struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid); |
| 44 | struct rxe_mc_grp **grp_p); | 44 | int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); |
| 45 | 45 | int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); | |
| 46 | int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, | 46 | void rxe_cleanup_mcg(struct kref *kref); |
| 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); | ||
| 55 | 47 | ||
| 56 | /* rxe_mmap.c */ | 48 | /* rxe_mmap.c */ |
| 57 | struct rxe_mmap_info { | 49 | struct rxe_mmap_info { |
| @@ -102,35 +94,27 @@ void rxe_mw_cleanup(struct rxe_pool_elem *arg); · 44 unmodified lines | |||
| 102 | /* rxe_net.c */ | 94 | /* rxe_net.c */ |
| 103 | struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, | 95 | struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, |
| 104 | int paylen, struct rxe_pkt_info *pkt); | 96 | int paylen, struct rxe_pkt_info *pkt); |
| 105 | int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb); | 97 | int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, |
| 98 | struct sk_buff *skb); | ||
| 106 | int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, | 99 | int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, |
| 107 | struct sk_buff *skb); | 100 | struct sk_buff *skb); |
| 108 | const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num); | 101 | const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num); |
| 109 | int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid); | ||
| 110 | int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid); | ||
| 111 | 102 | ||
| 112 | /* rxe_qp.c */ | 103 | /* rxe_qp.c */ |
| 113 | int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init); | 104 | int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init); |
| 114 | |||
| 115 | int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, | 105 | int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, |
| 116 | struct ib_qp_init_attr *init, | 106 | struct ib_qp_init_attr *init, |
| 117 | struct rxe_create_qp_resp __user *uresp, | 107 | struct rxe_create_qp_resp __user *uresp, |
| 118 | struct ib_pd *ibpd, struct ib_udata *udata); | 108 | struct ib_pd *ibpd, struct ib_udata *udata); |
| 119 | |||
| 120 | int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init); | 109 | int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init); |
| 121 | |||
| 122 | int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, | 110 | int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, |
| 123 | struct ib_qp_attr *attr, int mask); | 111 | struct ib_qp_attr *attr, int mask); |
| 124 | |||
| 125 | int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, | 112 | int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, |
| 126 | int mask, struct ib_udata *udata); | 113 | int mask, struct ib_udata *udata); |
| 127 | |||
| 128 | int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask); | 114 | int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask); |
| 129 | |||
| 130 | void rxe_qp_error(struct rxe_qp *qp); | 115 | void rxe_qp_error(struct rxe_qp *qp); |
| 131 | 116 | int rxe_qp_chk_destroy(struct rxe_qp *qp); | |
| 132 | void rxe_qp_destroy(struct rxe_qp *qp); | 117 | void rxe_qp_destroy(struct rxe_qp *qp); |
| 133 | |||
| 134 | void rxe_qp_cleanup(struct rxe_pool_elem *elem); | 118 | void rxe_qp_cleanup(struct rxe_pool_elem *elem); |
| 135 | 119 | ||
| 136 | static inline int qp_num(struct rxe_qp *qp) | 120 | static inline int qp_num(struct rxe_qp *qp) |
| @@ -1,178 +1,488 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | 1 | // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2022 Hewlett Packard Enterprise, Inc. All rights reserved. | ||
| 3 | * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. | 4 | * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. |
| 4 | * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. | 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 | #include "rxe.h" | 22 | #include "rxe.h" |
| 8 | #include "rxe_loc.h" | ||
| 9 | 23 | ||
| 10 | /* caller should hold mc_grp_pool->pool_lock */ | 24 | /** |
| 11 | static struct rxe_mc_grp *create_grp(struct rxe_dev *rxe, | 25 | * rxe_mcast_add - add multicast address to rxe device |
| 12 | struct rxe_pool *pool, | 26 | * @rxe: rxe device object |
| 13 | union ib_gid *mgid) | 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; | 33 | unsigned char ll_addr[ETH_ALEN]; |
| 16 | struct rxe_mc_grp *grp; | ||
| 17 | 34 | ||
| 18 | grp = rxe_alloc_locked(&rxe->mc_grp_pool); | 35 | ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr); |
| 19 | if (!grp) | ||
| 20 | return ERR_PTR(-ENOMEM); | ||
| 21 | 36 | ||
| 22 | INIT_LIST_HEAD(&grp->qp_list); | 37 | return dev_mc_add(rxe->ndev, ll_addr); |
| 23 | spin_lock_init(&grp->mcg_lock); | 38 | } |
| 24 | grp->rxe = rxe; | ||
| 25 | rxe_add_key_locked(grp, mgid); | ||
| 26 | 39 | ||
| 27 | err = rxe_mcast_add(rxe, mgid); | 40 | /** |
| 28 | if (unlikely(err)) { | 41 | * rxe_mcast_delete - delete multicast address from rxe device |
| 29 | rxe_drop_key_locked(grp); | 42 | * @rxe: rxe device object |
| 30 | rxe_drop_ref(grp); | 43 | * @mgid: multicast address as a gid |
| 31 | return ERR_PTR(err); | 44 | * |
| 45 | * Returns 0 on success else an error | ||
| 46 | */ | ||
| 47 | static int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid) | ||
| 48 | { | ||
| 49 | unsigned char ll_addr[ETH_ALEN]; | ||
| 50 | |||
| 51 | ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr); | ||
| 52 | |||
| 53 | return dev_mc_del(rxe->ndev, ll_addr); | ||
| 54 | } | ||
| 55 | |||
| 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; | ||
| 70 | |||
| 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; | ||
| 32 | } | 80 | } |
| 33 | 81 | ||
| 34 | return grp; | 82 | rb_link_node(&mcg->node, node, link); |
| 83 | rb_insert_color(&mcg->node, tree); | ||
| 35 | } | 84 | } |
| 36 | 85 | ||
| 37 | int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, | 86 | /** |
| 38 | struct rxe_mc_grp **grp_p) | 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) | ||
| 39 | { | 93 | { |
| 40 | int err; | 94 | rb_erase(&mcg->node, &mcg->rxe->mcg_tree); |
| 41 | struct rxe_mc_grp *grp; | 95 | } |
| 42 | struct rxe_pool *pool = &rxe->mc_grp_pool; | ||
| 43 | 96 | ||
| 44 | if (rxe->attr.max_mcast_qp_attach == 0) | 97 | /** |
| 45 | return -EINVAL; | 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; | ||
| 46 | 112 | ||
| 47 | write_lock_bh(&pool->pool_lock); | 113 | node = tree->rb_node; |
| 48 | 114 | ||
| 49 | grp = rxe_pool_get_key_locked(pool, mgid); | 115 | while (node) { |
| 50 | if (grp) | 116 | mcg = rb_entry(node, struct rxe_mcg, node); |
| 51 | goto done; | ||
| 52 | 117 | ||
| 53 | grp = create_grp(rxe, pool, mgid); | 118 | cmp = memcmp(&mcg->mgid, mgid, sizeof(*mgid)); |
| 54 | if (IS_ERR(grp)) { | 119 | |
| 55 | write_unlock_bh(&pool->pool_lock); | 120 | if (cmp > 0) |
| 56 | err = PTR_ERR(grp); | 121 | node = node->rb_left; |
| 57 | return err; | 122 | else if (cmp < 0) |
| 123 | node = node->rb_right; | ||
| 124 | else | ||
| 125 | break; | ||
| 58 | } | 126 | } |
| 59 | 127 | ||
| 60 | done: | 128 | if (node) { |
| 61 | write_unlock_bh(&pool->pool_lock); | 129 | kref_get(&mcg->ref_cnt); |
| 62 | *grp_p = grp; | 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 | return 0; | 188 | return 0; |
| 64 | } | 189 | } |
| 65 | 190 | ||
| 66 | int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, | 191 | /** |
| 67 | struct rxe_mc_grp *grp) | 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 | int err; | 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 */ | 204 | if (rxe->attr.max_mcast_grp == 0) |
| 73 | spin_lock_bh(&qp->grp_lock); | 205 | return ERR_PTR(-EINVAL); |
| 74 | spin_lock_bh(&grp->mcg_lock); | ||
| 75 | list_for_each_entry(elem, &grp->qp_list, qp_list) { | ||
| 76 | if (elem->qp == qp) { | ||
| 77 | err = 0; | ||
| 78 | goto out; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | 206 | ||
| 82 | if (grp->num_qp >= rxe->attr.max_mcast_qp_attach) { | 207 | /* check to see if mcg already exists */ |
| 83 | err = -ENOMEM; | 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; | ||
| 84 | goto out; | 223 | goto out; |
| 85 | } | 224 | } |
| 86 | 225 | ||
| 87 | elem = rxe_alloc_locked(&rxe->mc_elem_pool); | 226 | if (atomic_inc_return(&rxe->mcg_num) > rxe->attr.max_mcast_grp) { |
| 88 | if (!elem) { | ||
| 89 | err = -ENOMEM; | 227 | err = -ENOMEM; |
| 90 | goto out; | 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; | ||
| 91 | } | 311 | } |
| 92 | 312 | ||
| 93 | /* each qp holds a ref on the grp */ | 313 | n = atomic_inc_return(&mcg->qp_num); |
| 94 | rxe_add_ref(grp); | 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); | ||
| 95 | 321 | ||
| 96 | grp->num_qp++; | 322 | rxe_get(qp); |
| 97 | elem->qp = qp; | 323 | mca->qp = qp; |
| 98 | elem->grp = grp; | ||
| 99 | 324 | ||
| 100 | list_add(&elem->qp_list, &grp->qp_list); | 325 | list_add_tail(&mca->qp_list, &mcg->qp_list); |
| 101 | list_add(&elem->grp_list, &qp->grp_list); | ||
| 102 | 326 | ||
| 103 | err = 0; | 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); | ||
| 365 | err = 0; | ||
| 366 | goto out; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | err = __rxe_init_mca(qp, mcg, mca); | ||
| 371 | if (err) | ||
| 372 | kfree(mca); | ||
| 104 | out: | 373 | out: |
| 105 | spin_unlock_bh(&grp->mcg_lock); | 374 | spin_unlock_irqrestore(&rxe->mcg_lock, flags); |
| 106 | spin_unlock_bh(&qp->grp_lock); | ||
| 107 | return err; | 375 | return err; |
| 108 | } | 376 | } |
| 109 | 377 | ||
| 110 | int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp, | 378 | /** |
| 111 | union ib_gid *mgid) | 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; | 387 | list_del(&mca->qp_list); |
| 114 | struct rxe_mc_elem *elem, *tmp; | ||
| 115 | 388 | ||
| 116 | grp = rxe_pool_get_key(&rxe->mc_grp_pool, mgid); | 389 | atomic_dec(&mcg->qp_num); |
| 117 | if (!grp) | 390 | atomic_dec(&mcg->rxe->mcg_attach); |
| 118 | goto err1; | 391 | atomic_dec(&mca->qp->mcg_num); |
| 392 | rxe_put(mca->qp); | ||
| 119 | 393 | ||
| 120 | spin_lock_bh(&qp->grp_lock); | 394 | kfree(mca); |
| 121 | spin_lock_bh(&grp->mcg_lock); | 395 | } |
| 122 | 396 | ||
| 123 | list_for_each_entry_safe(elem, tmp, &grp->qp_list, qp_list) { | 397 | /** |
| 124 | if (elem->qp == qp) { | 398 | * rxe_detach_mcg - detach qp from mcg |
| 125 | list_del(&elem->qp_list); | 399 | * @mcg: mcg object |
| 126 | list_del(&elem->grp_list); | 400 | * @qp: qp object |
| 127 | grp->num_qp--; | 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); | 410 | spin_lock_irqsave(&rxe->mcg_lock, flags); |
| 130 | spin_unlock_bh(&qp->grp_lock); | 411 | list_for_each_entry_safe(mca, tmp, &mcg->qp_list, qp_list) { |
| 131 | rxe_drop_ref(elem); | 412 | if (mca->qp == qp) { |
| 132 | rxe_drop_ref(grp); /* ref held by QP */ | 413 | __rxe_cleanup_mca(mca, mcg); |
| 133 | rxe_drop_ref(grp); /* ref from get_key */ | 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 | return 0; | 425 | return 0; |
| 135 | } | 426 | } |
| 136 | } | 427 | } |
| 137 | 428 | ||
| 138 | spin_unlock_bh(&grp->mcg_lock); | 429 | /* we didn't find the qp on the list */ |
| 139 | spin_unlock_bh(&qp->grp_lock); | 430 | spin_unlock_irqrestore(&rxe->mcg_lock, flags); |
| 140 | rxe_drop_ref(grp); /* ref from get_key */ | ||
| 141 | err1: | ||
| 142 | return -EINVAL; | 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; | 444 | int err; |
| 148 | struct rxe_mc_elem *elem; | 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) { | 449 | /* takes a ref on mcg if successful */ |
| 151 | spin_lock_bh(&qp->grp_lock); | 450 | mcg = rxe_get_mcg(rxe, mgid); |
| 152 | if (list_empty(&qp->grp_list)) { | 451 | if (IS_ERR(mcg)) |
| 153 | spin_unlock_bh(&qp->grp_lock); | 452 | return PTR_ERR(mcg); |
| 154 | break; | 453 | |
| 155 | } | 454 | err = rxe_attach_mcg(mcg, qp); |
| 156 | elem = list_first_entry(&qp->grp_list, struct rxe_mc_elem, | 455 | |
| 157 | grp_list); | 456 | /* if we failed to attach the first qp to mcg tear it down */ |
| 158 | list_del(&elem->grp_list); | 457 | if (atomic_read(&mcg->qp_num) == 0) |
| 159 | spin_unlock_bh(&qp->grp_lock); | 458 | rxe_destroy_mcg(mcg); |
| 160 | 459 | ||
| 161 | grp = elem->grp; | 460 | kref_put(&mcg->ref_cnt, rxe_cleanup_mcg); |
| 162 | spin_lock_bh(&grp->mcg_lock); | 461 | |
| 163 | list_del(&elem->qp_list); | 462 | return err; |
| 164 | grp->num_qp--; | ||
| 165 | spin_unlock_bh(&grp->mcg_lock); | ||
| 166 | rxe_drop_ref(grp); | ||
| 167 | rxe_drop_ref(elem); | ||
| 168 | } | ||
| 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); | 475 | struct rxe_dev *rxe = to_rdev(ibqp->device); |
| 174 | struct rxe_dev *rxe = grp->rxe; | 476 | struct rxe_qp *qp = to_rqp(ibqp); |
| 477 | struct rxe_mcg *mcg; | ||
| 478 | int err; | ||
| 175 | 479 | ||
| 176 | rxe_drop_key(grp); | 480 | mcg = rxe_lookup_mcg(rxe, mgid); |
| 177 | rxe_mcast_delete(rxe, &grp->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 | } |
| @@ -4,7 +4,6 @@ · 3 unmodified lines | |||
| 4 | * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. | 4 | * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <linux/module.h> | ||
| 8 | #include <linux/vmalloc.h> | 7 | #include <linux/vmalloc.h> |
| 9 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
| 10 | #include <linux/errno.h> | 9 | #include <linux/errno.h> |
| @@ -459,7 +459,7 @@ int copy_data( · 458 unmodified lines | |||
| 459 | 459 | ||
| 460 | if (offset >= sge->length) { | 460 | if (offset >= sge->length) { |
| 461 | if (mr) { | 461 | if (mr) { |
| 462 | rxe_drop_ref(mr); | 462 | rxe_put(mr); |
| 463 | mr = NULL; | 463 | mr = NULL; |
| 464 | } | 464 | } |
| 465 | sge++; | 465 | sge++; |
| @@ -504,13 +504,13 @@ int copy_data( · 38 unmodified lines | |||
| 504 | dma->resid = resid; | 504 | dma->resid = resid; |
| 505 | 505 | ||
| 506 | if (mr) | 506 | if (mr) |
| 507 | rxe_drop_ref(mr); | 507 | rxe_put(mr); |
| 508 | 508 | ||
| 509 | return 0; | 509 | return 0; |
| 510 | 510 | ||
| 511 | err2: | 511 | err2: |
| 512 | if (mr) | 512 | if (mr) |
| 513 | rxe_drop_ref(mr); | 513 | rxe_put(mr); |
| 514 | err1: | 514 | err1: |
| 515 | return err; | 515 | return err; |
| 516 | } | 516 | } |
| @@ -569,7 +569,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, · 52 unmodified lines | |||
| 569 | (type == RXE_LOOKUP_REMOTE && mr->rkey != key) || | 569 | (type == RXE_LOOKUP_REMOTE && mr->rkey != key) || |
| 570 | mr_pd(mr) != pd || (access && !(access & mr->access)) || | 570 | mr_pd(mr) != pd || (access && !(access & mr->access)) || |
| 571 | mr->state != RXE_MR_STATE_VALID)) { | 571 | mr->state != RXE_MR_STATE_VALID)) { |
| 572 | rxe_drop_ref(mr); | 572 | rxe_put(mr); |
| 573 | mr = NULL; | 573 | mr = NULL; |
| 574 | } | 574 | } |
| 575 | 575 | ||
| @@ -613,7 +613,7 @@ int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey) · 37 unmodified lines | |||
| 613 | ret = 0; | 613 | ret = 0; |
| 614 | 614 | ||
| 615 | err_drop_ref: | 615 | err_drop_ref: |
| 616 | rxe_drop_ref(mr); | 616 | rxe_put(mr); |
| 617 | err: | 617 | err: |
| 618 | return ret; | 618 | return ret; |
| 619 | } | 619 | } |
| @@ -690,9 +690,8 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) · 70 unmodified lines | |||
| 690 | } | 690 | } |
| 691 | 691 | ||
| 692 | mr->state = RXE_MR_STATE_INVALID; | 692 | mr->state = RXE_MR_STATE_INVALID; |
| 693 | rxe_drop_ref(mr_pd(mr)); | 693 | rxe_put(mr_pd(mr)); |
| 694 | rxe_drop_index(mr); | 694 | rxe_put(mr); |
| 695 | rxe_drop_ref(mr); | ||
| 696 | 695 | ||
| 697 | return 0; | 696 | return 0; |
| 698 | } | 697 | } |
| @@ -12,15 +12,14 @@ int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata) · 11 unmodified lines | |||
| 12 | struct rxe_dev *rxe = to_rdev(ibmw->device); | 12 | struct rxe_dev *rxe = to_rdev(ibmw->device); |
| 13 | int ret; | 13 | int ret; |
| 14 | 14 | ||
| 15 | rxe_add_ref(pd); | 15 | rxe_get(pd); |
| 16 | 16 | ||
| 17 | ret = rxe_add_to_pool(&rxe->mw_pool, mw); | 17 | ret = rxe_add_to_pool(&rxe->mw_pool, mw); |
| 18 | if (ret) { | 18 | if (ret) { |
| 19 | rxe_drop_ref(pd); | 19 | rxe_put(pd); |
| 20 | return ret; | 20 | return ret; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | rxe_add_index(mw); | ||
| 24 | mw->rkey = ibmw->rkey = (mw->elem.index << 8) | rxe_get_next_key(-1); | 23 | mw->rkey = ibmw->rkey = (mw->elem.index << 8) | rxe_get_next_key(-1); |
| 25 | mw->state = (mw->ibmw.type == IB_MW_TYPE_2) ? | 24 | mw->state = (mw->ibmw.type == IB_MW_TYPE_2) ? |
| 26 | RXE_MW_STATE_FREE : RXE_MW_STATE_VALID; | 25 | RXE_MW_STATE_FREE : RXE_MW_STATE_VALID; |
| @@ -36,14 +35,14 @@ static void rxe_do_dealloc_mw(struct rxe_mw *mw) · 9 unmodified lines | |||
| 36 | 35 | ||
| 37 | mw->mr = NULL; | 36 | mw->mr = NULL; |
| 38 | atomic_dec(&mr->num_mw); | 37 | atomic_dec(&mr->num_mw); |
| 39 | rxe_drop_ref(mr); | 38 | rxe_put(mr); |
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | if (mw->qp) { | 41 | if (mw->qp) { |
| 43 | struct rxe_qp *qp = mw->qp; | 42 | struct rxe_qp *qp = mw->qp; |
| 44 | 43 | ||
| 45 | mw->qp = NULL; | 44 | mw->qp = NULL; |
| 46 | rxe_drop_ref(qp); | 45 | rxe_put(qp); |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | mw->access = 0; | 48 | mw->access = 0; |
| @@ -61,8 +60,8 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) · 11 unmodified lines | |||
| 61 | rxe_do_dealloc_mw(mw); | 60 | rxe_do_dealloc_mw(mw); |
| 62 | spin_unlock_bh(&mw->lock); | 61 | spin_unlock_bh(&mw->lock); |
| 63 | 62 | ||
| 64 | rxe_drop_ref(mw); | 63 | rxe_put(mw); |
| 65 | rxe_drop_ref(pd); | 64 | rxe_put(pd); |
| 66 | 65 | ||
| 67 | return 0; | 66 | return 0; |
| 68 | } | 67 | } |
| @@ -171,7 +170,7 @@ static void rxe_do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, · 102 unmodified lines | |||
| 171 | mw->length = wqe->wr.wr.mw.length; | 170 | mw->length = wqe->wr.wr.mw.length; |
| 172 | 171 | ||
| 173 | if (mw->mr) { | 172 | if (mw->mr) { |
| 174 | rxe_drop_ref(mw->mr); | 173 | rxe_put(mw->mr); |
| 175 | atomic_dec(&mw->mr->num_mw); | 174 | atomic_dec(&mw->mr->num_mw); |
| 176 | mw->mr = NULL; | 175 | mw->mr = NULL; |
| 177 | } | 176 | } |
| @@ -179,11 +178,11 @@ static void rxe_do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, · 1 unmodified line | |||
| 179 | if (mw->length) { | 178 | if (mw->length) { |
| 180 | mw->mr = mr; | 179 | mw->mr = mr; |
| 181 | atomic_inc(&mr->num_mw); | 180 | atomic_inc(&mr->num_mw); |
| 182 | rxe_add_ref(mr); | 181 | rxe_get(mr); |
| 183 | } | 182 | } |
| 184 | 183 | ||
| 185 | if (mw->ibmw.type == IB_MW_TYPE_2) { | 184 | if (mw->ibmw.type == IB_MW_TYPE_2) { |
| 186 | rxe_add_ref(qp); | 185 | rxe_get(qp); |
| 187 | mw->qp = qp; | 186 | mw->qp = qp; |
| 188 | } | 187 | } |
| 189 | } | 188 | } |
| @@ -234,9 +233,9 @@ err_unlock: · 44 unmodified lines | |||
| 234 | spin_unlock_bh(&mw->lock); | 233 | spin_unlock_bh(&mw->lock); |
| 235 | err_drop_mr: | 234 | err_drop_mr: |
| 236 | if (mr) | 235 | if (mr) |
| 237 | rxe_drop_ref(mr); | 236 | rxe_put(mr); |
| 238 | err_drop_mw: | 237 | err_drop_mw: |
| 239 | rxe_drop_ref(mw); | 238 | rxe_put(mw); |
| 240 | err: | 239 | err: |
| 241 | return ret; | 240 | return ret; |
| 242 | } | 241 | } |
| @@ -261,13 +260,13 @@ static void rxe_do_invalidate_mw(struct rxe_mw *mw) · 18 unmodified lines | |||
| 261 | /* valid type 2 MW will always have a QP pointer */ | 260 | /* valid type 2 MW will always have a QP pointer */ |
| 262 | qp = mw->qp; | 261 | qp = mw->qp; |
| 263 | mw->qp = NULL; | 262 | mw->qp = NULL; |
| 264 | rxe_drop_ref(qp); | 263 | rxe_put(qp); |
| 265 | 264 | ||
| 266 | /* valid type 2 MW will always have an MR pointer */ | 265 | /* valid type 2 MW will always have an MR pointer */ |
| 267 | mr = mw->mr; | 266 | mr = mw->mr; |
| 268 | mw->mr = NULL; | 267 | mw->mr = NULL; |
| 269 | atomic_dec(&mr->num_mw); | 268 | atomic_dec(&mr->num_mw); |
| 270 | rxe_drop_ref(mr); | 269 | rxe_put(mr); |
| 271 | 270 | ||
| 272 | mw->access = 0; | 271 | mw->access = 0; |
| 273 | mw->addr = 0; | 272 | mw->addr = 0; |
| @@ -302,7 +301,7 @@ int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey) · 28 unmodified lines | |||
| 302 | err_unlock: | 301 | err_unlock: |
| 303 | spin_unlock_bh(&mw->lock); | 302 | spin_unlock_bh(&mw->lock); |
| 304 | err_drop_ref: | 303 | err_drop_ref: |
| 305 | rxe_drop_ref(mw); | 304 | rxe_put(mw); |
| 306 | err: | 305 | err: |
| 307 | return ret; | 306 | return ret; |
| 308 | } | 307 | } |
| @@ -323,16 +322,9 @@ struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey) · 14 unmodified lines | |||
| 323 | (mw->length == 0) || | 322 | (mw->length == 0) || |
| 324 | (access && !(access & mw->access)) || | 323 | (access && !(access & mw->access)) || |
| 325 | mw->state != RXE_MW_STATE_VALID)) { | 324 | mw->state != RXE_MW_STATE_VALID)) { |
| 326 | rxe_drop_ref(mw); | 325 | rxe_put(mw); |
| 327 | return NULL; | 326 | return NULL; |
| 328 | } | 327 | } |
| 329 | 328 | ||
| 330 | return mw; | 329 | return mw; |
| 331 | } | 330 | } |
| 332 | |||
| 333 | void rxe_mw_cleanup(struct rxe_pool_elem *elem) | ||
| 334 | { | ||
| 335 | struct rxe_mw *mw = container_of(elem, typeof(*mw), elem); | ||
| 336 | |||
| 337 | rxe_drop_index(mw); | ||
| 338 | } | ||
| @@ -20,24 +20,6 @@ · 19 unmodified lines | |||
| 20 | 20 | ||
| 21 | static struct rxe_recv_sockets recv_sockets; | 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 | static struct dst_entry *rxe_find_route4(struct net_device *ndev, | 23 | static struct dst_entry *rxe_find_route4(struct net_device *ndev, |
| 42 | struct in_addr *saddr, | 24 | struct in_addr *saddr, |
| 43 | struct in_addr *daddr) | 25 | struct in_addr *daddr) |
| @@ -289,13 +271,13 @@ static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb, · 245 unmodified lines | |||
| 289 | ip6h->payload_len = htons(skb->len - sizeof(*ip6h)); | 271 | ip6h->payload_len = htons(skb->len - sizeof(*ip6h)); |
| 290 | } | 272 | } |
| 291 | 273 | ||
| 292 | static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb) | 274 | static int prepare4(struct rxe_av *av, struct rxe_pkt_info *pkt, |
| 275 | struct sk_buff *skb) | ||
| 293 | { | 276 | { |
| 294 | struct rxe_qp *qp = pkt->qp; | 277 | struct rxe_qp *qp = pkt->qp; |
| 295 | struct dst_entry *dst; | 278 | struct dst_entry *dst; |
| 296 | bool xnet = false; | 279 | bool xnet = false; |
| 297 | __be16 df = htons(IP_DF); | 280 | __be16 df = htons(IP_DF); |
| 298 | struct rxe_av *av = rxe_get_av(pkt); | ||
| 299 | struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr; | 281 | struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr; |
| 300 | struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr; | 282 | struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr; |
| 301 | 283 | ||
| @@ -315,11 +297,11 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb) · 13 unmodified lines | |||
| 315 | return 0; | 297 | return 0; |
| 316 | } | 298 | } |
| 317 | 299 | ||
| 318 | static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb) | 300 | static int prepare6(struct rxe_av *av, struct rxe_pkt_info *pkt, |
| 301 | struct sk_buff *skb) | ||
| 319 | { | 302 | { |
| 320 | struct rxe_qp *qp = pkt->qp; | 303 | struct rxe_qp *qp = pkt->qp; |
| 321 | struct dst_entry *dst; | 304 | struct dst_entry *dst; |
| 322 | struct rxe_av *av = rxe_get_av(pkt); | ||
| 323 | struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr; | 305 | struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr; |
| 324 | struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr; | 306 | struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr; |
| 325 | 307 | ||
| @@ -340,16 +322,17 @@ static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb) · 14 unmodified lines | |||
| 340 | return 0; | 322 | return 0; |
| 341 | } | 323 | } |
| 342 | 324 | ||
| 343 | int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb) | 325 | int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, |
| 326 | struct sk_buff *skb) | ||
| 344 | { | 327 | { |
| 345 | int err = 0; | 328 | int err = 0; |
| 346 | 329 | ||
| 347 | if (skb->protocol == htons(ETH_P_IP)) | 330 | if (skb->protocol == htons(ETH_P_IP)) |
| 348 | err = prepare4(pkt, skb); | 331 | err = prepare4(av, pkt, skb); |
| 349 | else if (skb->protocol == htons(ETH_P_IPV6)) | 332 | else if (skb->protocol == htons(ETH_P_IPV6)) |
| 350 | err = prepare6(pkt, skb); | 333 | err = prepare6(av, pkt, skb); |
| 351 | 334 | ||
| 352 | if (ether_addr_equal(skb->dev->dev_addr, rxe_get_av(pkt)->dmac)) | 335 | if (ether_addr_equal(skb->dev->dev_addr, av->dmac)) |
| 353 | pkt->mask |= RXE_LOOPBACK_MASK; | 336 | pkt->mask |= RXE_LOOPBACK_MASK; |
| 354 | 337 | ||
| 355 | return err; | 338 | return err; |
| @@ -365,7 +348,7 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb) · 9 unmodified lines | |||
| 365 | skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) | 348 | skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) |
| 366 | rxe_run_task(&qp->req.task, 1); | 349 | rxe_run_task(&qp->req.task, 1); |
| 367 | 350 | ||
| 368 | rxe_drop_ref(qp); | 351 | rxe_put(qp); |
| 369 | } | 352 | } |
| 370 | 353 | ||
| 371 | static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) | 354 | static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) |
| @@ -375,7 +358,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) · 3 unmodified lines | |||
| 375 | skb->destructor = rxe_skb_tx_dtor; | 358 | skb->destructor = rxe_skb_tx_dtor; |
| 376 | skb->sk = pkt->qp->sk->sk; | 359 | skb->sk = pkt->qp->sk->sk; |
| 377 | 360 | ||
| 378 | rxe_add_ref(pkt->qp); | 361 | rxe_get(pkt->qp); |
| 379 | atomic_inc(&pkt->qp->skb_out); | 362 | atomic_inc(&pkt->qp->skb_out); |
| 380 | 363 | ||
| 381 | if (skb->protocol == htons(ETH_P_IP)) { | 364 | if (skb->protocol == htons(ETH_P_IP)) { |
| @@ -385,7 +368,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) · 3 unmodified lines | |||
| 385 | } else { | 368 | } else { |
| 386 | pr_err("Unknown layer 3 protocol: %d\n", skb->protocol); | 369 | pr_err("Unknown layer 3 protocol: %d\n", skb->protocol); |
| 387 | atomic_dec(&pkt->qp->skb_out); | 370 | atomic_dec(&pkt->qp->skb_out); |
| 388 | rxe_drop_ref(pkt->qp); | 371 | rxe_put(pkt->qp); |
| 389 | kfree_skb(skb); | 372 | kfree_skb(skb); |
| 390 | return -EINVAL; | 373 | return -EINVAL; |
| 391 | } | 374 | } |
| @@ -12,129 +12,93 @@ static const struct rxe_type_info { · 11 unmodified lines | |||
| 12 | const char *name; | 12 | const char *name; |
| 13 | size_t size; | 13 | size_t size; |
| 14 | size_t elem_offset; | 14 | size_t elem_offset; |
| 15 | void (*cleanup)(struct rxe_pool_elem *obj); | 15 | void (*cleanup)(struct rxe_pool_elem *elem); |
| 16 | enum rxe_pool_flags flags; | 16 | enum rxe_pool_flags flags; |
| 17 | u32 min_index; | 17 | u32 min_index; |
| 18 | u32 max_index; | 18 | u32 max_index; |
| 19 | size_t key_offset; | 19 | u32 max_elem; |
| 20 | size_t key_size; | ||
| 21 | } rxe_type_info[RXE_NUM_TYPES] = { | 20 | } rxe_type_info[RXE_NUM_TYPES] = { |
| 22 | [RXE_TYPE_UC] = { | 21 | [RXE_TYPE_UC] = { |
| 23 | .name = "rxe-uc", | 22 | .name = "uc", |
| 24 | .size = sizeof(struct rxe_ucontext), | 23 | .size = sizeof(struct rxe_ucontext), |
| 25 | .elem_offset = offsetof(struct rxe_ucontext, elem), | 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 | [RXE_TYPE_PD] = { | 29 | [RXE_TYPE_PD] = { |
| 29 | .name = "rxe-pd", | 30 | .name = "pd", |
| 30 | .size = sizeof(struct rxe_pd), | 31 | .size = sizeof(struct rxe_pd), |
| 31 | .elem_offset = offsetof(struct rxe_pd, elem), | 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 | [RXE_TYPE_AH] = { | 37 | [RXE_TYPE_AH] = { |
| 35 | .name = "rxe-ah", | 38 | .name = "ah", |
| 36 | .size = sizeof(struct rxe_ah), | 39 | .size = sizeof(struct rxe_ah), |
| 37 | .elem_offset = offsetof(struct rxe_ah, elem), | 40 | .elem_offset = offsetof(struct rxe_ah, elem), |
| 38 | .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, | ||
| 39 | .min_index = RXE_MIN_AH_INDEX, | 41 | .min_index = RXE_MIN_AH_INDEX, |
| 40 | .max_index = RXE_MAX_AH_INDEX, | 42 | .max_index = RXE_MAX_AH_INDEX, |
| 43 | .max_elem = RXE_MAX_AH_INDEX - RXE_MIN_AH_INDEX + 1, | ||
| 41 | }, | 44 | }, |
| 42 | [RXE_TYPE_SRQ] = { | 45 | [RXE_TYPE_SRQ] = { |
| 43 | .name = "rxe-srq", | 46 | .name = "srq", |
| 44 | .size = sizeof(struct rxe_srq), | 47 | .size = sizeof(struct rxe_srq), |
| 45 | .elem_offset = offsetof(struct rxe_srq, elem), | 48 | .elem_offset = offsetof(struct rxe_srq, elem), |
| 46 | .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, | ||
| 47 | .min_index = RXE_MIN_SRQ_INDEX, | 49 | .min_index = RXE_MIN_SRQ_INDEX, |
| 48 | .max_index = RXE_MAX_SRQ_INDEX, | 50 | .max_index = RXE_MAX_SRQ_INDEX, |
| 51 | .max_elem = RXE_MAX_SRQ_INDEX - RXE_MIN_SRQ_INDEX + 1, | ||
| 49 | }, | 52 | }, |
| 50 | [RXE_TYPE_QP] = { | 53 | [RXE_TYPE_QP] = { |
| 51 | .name = "rxe-qp", | 54 | .name = "qp", |
| 52 | .size = sizeof(struct rxe_qp), | 55 | .size = sizeof(struct rxe_qp), |
| 53 | .elem_offset = offsetof(struct rxe_qp, elem), | 56 | .elem_offset = offsetof(struct rxe_qp, elem), |
| 54 | .cleanup = rxe_qp_cleanup, | 57 | .cleanup = rxe_qp_cleanup, |
| 55 | .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, | ||
| 56 | .min_index = RXE_MIN_QP_INDEX, | 58 | .min_index = RXE_MIN_QP_INDEX, |
| 57 | .max_index = RXE_MAX_QP_INDEX, | 59 | .max_index = RXE_MAX_QP_INDEX, |
| 60 | .max_elem = RXE_MAX_QP_INDEX - RXE_MIN_QP_INDEX + 1, | ||
| 58 | }, | 61 | }, |
| 59 | [RXE_TYPE_CQ] = { | 62 | [RXE_TYPE_CQ] = { |
| 60 | .name = "rxe-cq", | 63 | .name = "cq", |
| 61 | .size = sizeof(struct rxe_cq), | 64 | .size = sizeof(struct rxe_cq), |
| 62 | .elem_offset = offsetof(struct rxe_cq, elem), | 65 | .elem_offset = offsetof(struct rxe_cq, elem), |
| 63 | .flags = RXE_POOL_NO_ALLOC, | ||
| 64 | .cleanup = rxe_cq_cleanup, | 66 | .cleanup = rxe_cq_cleanup, |
| 67 | .min_index = 1, | ||
| 68 | .max_index = UINT_MAX, | ||
| 69 | .max_elem = UINT_MAX, | ||
| 65 | }, | 70 | }, |
| 66 | [RXE_TYPE_MR] = { | 71 | [RXE_TYPE_MR] = { |
| 67 | .name = "rxe-mr", | 72 | .name = "mr", |
| 68 | .size = sizeof(struct rxe_mr), | 73 | .size = sizeof(struct rxe_mr), |
| 69 | .elem_offset = offsetof(struct rxe_mr, elem), | 74 | .elem_offset = offsetof(struct rxe_mr, elem), |
| 70 | .cleanup = rxe_mr_cleanup, | 75 | .cleanup = rxe_mr_cleanup, |
| 71 | .flags = RXE_POOL_INDEX, | 76 | .flags = RXE_POOL_ALLOC, |
| 72 | .min_index = RXE_MIN_MR_INDEX, | 77 | .min_index = RXE_MIN_MR_INDEX, |
| 73 | .max_index = RXE_MAX_MR_INDEX, | 78 | .max_index = RXE_MAX_MR_INDEX, |
| 79 | .max_elem = RXE_MAX_MR_INDEX - RXE_MIN_MR_INDEX + 1, | ||
| 74 | }, | 80 | }, |
| 75 | [RXE_TYPE_MW] = { | 81 | [RXE_TYPE_MW] = { |
| 76 | .name = "rxe-mw", | 82 | .name = "mw", |
| 77 | .size = sizeof(struct rxe_mw), | 83 | .size = sizeof(struct rxe_mw), |
| 78 | .elem_offset = offsetof(struct rxe_mw, elem), | 84 | .elem_offset = offsetof(struct rxe_mw, elem), |
| 79 | .cleanup = rxe_mw_cleanup, | ||
| 80 | .flags = RXE_POOL_INDEX | RXE_POOL_NO_ALLOC, | ||
| 81 | .min_index = RXE_MIN_MW_INDEX, | 85 | .min_index = RXE_MIN_MW_INDEX, |
| 82 | .max_index = RXE_MAX_MW_INDEX, | 86 | .max_index = RXE_MAX_MW_INDEX, |
| 83 | }, | 87 | .max_elem = RXE_MAX_MW_INDEX - RXE_MIN_MW_INDEX + 1, |
| 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), | ||
| 97 | }, | 88 | }, |
| 98 | }; | 89 | }; |
| 99 | 90 | ||
| 100 | static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min) | 91 | void rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, |
| 101 | { | 92 | enum rxe_elem_type type) |
| 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) | ||
| 128 | { | 93 | { |
| 129 | const struct rxe_type_info *info = &rxe_type_info[type]; | 94 | const struct rxe_type_info *info = &rxe_type_info[type]; |
| 130 | int err = 0; | ||
| 131 | 95 | ||
| 132 | memset(pool, 0, sizeof(*pool)); | 96 | memset(pool, 0, sizeof(*pool)); |
| 133 | 97 | ||
| 134 | pool->rxe = rxe; | 98 | pool->rxe = rxe; |
| 135 | pool->name = info->name; | 99 | pool->name = info->name; |
| 136 | pool->type = type; | 100 | pool->type = type; |
| 137 | pool->max_elem = max_elem; | 101 | pool->max_elem = info->max_elem; |
| 138 | pool->elem_size = ALIGN(info->size, RXE_POOL_ALIGN); | 102 | pool->elem_size = ALIGN(info->size, RXE_POOL_ALIGN); |
| 139 | pool->elem_offset = info->elem_offset; | 103 | pool->elem_offset = info->elem_offset; |
| 140 | pool->flags = info->flags; | 104 | pool->flags = info->flags; |
| @@ -142,225 +106,31 @@ int rxe_pool_init( · 1 unmodified line | |||
| 142 | 106 | ||
| 143 | atomic_set(&pool->num_elem, 0); | 107 | atomic_set(&pool->num_elem, 0); |
| 144 | 108 | ||
| 145 | rwlock_init(&pool->pool_lock); | 109 | xa_init_flags(&pool->xa, XA_FLAGS_ALLOC); |
| 146 | 110 | pool->limit.min = info->min_index; | |
| 147 | if (pool->flags & RXE_POOL_INDEX) { | 111 | pool->limit.max = info->max_index; |
| 148 | pool->index.tree = RB_ROOT; | ||
| 149 | err = rxe_pool_init_index(pool, info->max_index, | ||
| 150 | info->min_index); | ||
| 151 | if (err) | ||
| 152 | goto out; | ||
| 153 | } | ||
| 154 | |||
| 155 | if (pool->flags & RXE_POOL_KEY) { | ||
| 156 | pool->key.tree = RB_ROOT; | ||
| 157 | pool->key.key_offset = info->key_offset; | ||
| 158 | pool->key.key_size = info->key_size; | ||
| 159 | } | ||
| 160 | |||
| 161 | out: | ||
| 162 | return err; | ||
| 163 | } | 112 | } |
| 164 | 113 | ||
| 165 | void rxe_pool_cleanup(struct rxe_pool *pool) | 114 | void rxe_pool_cleanup(struct rxe_pool *pool) |
| 166 | { | 115 | { |
| 167 | if (atomic_read(&pool->num_elem) > 0) | 116 | WARN_ON(!xa_empty(&pool->xa)); |
| 168 | pr_warn("%s pool destroyed with unfree'd elem\n", | ||
| 169 | pool->name); | ||
| 170 | |||
| 171 | if (pool->flags & RXE_POOL_INDEX) | ||
| 172 | bitmap_free(pool->index.table); | ||
| 173 | } | ||
| 174 | |||
| 175 | static u32 alloc_index(struct rxe_pool *pool) | ||
| 176 | { | ||
| 177 | u32 index; | ||
| 178 | u32 range = pool->index.max_index - pool->index.min_index + 1; | ||
| 179 | |||
| 180 | index = find_next_zero_bit(pool->index.table, range, pool->index.last); | ||
| 181 | if (index >= range) | ||
| 182 | index = find_first_zero_bit(pool->index.table, range); | ||
| 183 | |||
| 184 | WARN_ON_ONCE(index >= range); | ||
| 185 | set_bit(index, pool->index.table); | ||
| 186 | pool->index.last = index; | ||
| 187 | return index + pool->index.min_index; | ||
| 188 | } | ||
| 189 | |||
| 190 | static int rxe_insert_index(struct rxe_pool *pool, struct rxe_pool_elem *new) | ||
| 191 | { | ||
| 192 | struct rb_node **link = &pool->index.tree.rb_node; | ||
| 193 | struct rb_node *parent = NULL; | ||
| 194 | struct rxe_pool_elem *elem; | ||
| 195 | |||
| 196 | while (*link) { | ||
| 197 | parent = *link; | ||
| 198 | elem = rb_entry(parent, struct rxe_pool_elem, index_node); | ||
| 199 | |||
| 200 | if (elem->index == new->index) { | ||
| 201 | pr_warn("element already exists!\n"); | ||
| 202 | return -EINVAL; | ||
| 203 | } | ||
| 204 | |||
| 205 | if (elem->index > new->index) | ||
| 206 | link = &(*link)->rb_left; | ||
| 207 | else | ||
| 208 | link = &(*link)->rb_right; | ||
| 209 | } | ||
| 210 | |||
| 211 | rb_link_node(&new->index_node, parent, link); | ||
| 212 | rb_insert_color(&new->index_node, &pool->index.tree); | ||
| 213 | |||
| 214 | return 0; | ||
| 215 | } | ||
| 216 | |||
| 217 | static int rxe_insert_key(struct rxe_pool *pool, struct rxe_pool_elem *new) | ||
| 218 | { | ||
| 219 | struct rb_node **link = &pool->key.tree.rb_node; | ||
| 220 | struct rb_node *parent = NULL; | ||
| 221 | struct rxe_pool_elem *elem; | ||
| 222 | int cmp; | ||
| 223 | |||
| 224 | while (*link) { | ||
| 225 | parent = *link; | ||
| 226 | elem = rb_entry(parent, struct rxe_pool_elem, key_node); | ||
| 227 | |||
| 228 | cmp = memcmp((u8 *)elem + pool->key.key_offset, | ||
| 229 | (u8 *)new + pool->key.key_offset, | ||
| 230 | pool->key.key_size); | ||
| 231 | |||
| 232 | if (cmp == 0) { | ||
| 233 | pr_warn("key already exists!\n"); | ||
| 234 | return -EINVAL; | ||
| 235 | } | ||
| 236 | |||
| 237 | if (cmp > 0) | ||
| 238 | link = &(*link)->rb_left; | ||
| 239 | else | ||
| 240 | link = &(*link)->rb_right; | ||
| 241 | } | ||
| 242 | |||
| 243 | rb_link_node(&new->key_node, parent, link); | ||
| 244 | rb_insert_color(&new->key_node, &pool->key.tree); | ||
| 245 | |||
| 246 | return 0; | ||
| 247 | } | ||
| 248 | |||
| 249 | int __rxe_add_key_locked(struct rxe_pool_elem *elem, void *key) | ||
| 250 | { | ||
| 251 | struct rxe_pool *pool = elem->pool; | ||
| 252 | int err; | ||
| 253 | |||
| 254 | memcpy((u8 *)elem + pool->key.key_offset, key, pool->key.key_size); | ||
| 255 | err = rxe_insert_key(pool, elem); | ||
| 256 | |||
| 257 | return err; | ||
| 258 | } | ||
| 259 | |||
| 260 | int __rxe_add_key(struct rxe_pool_elem *elem, void *key) | ||
| 261 | { | ||
| 262 | struct rxe_pool *pool = elem->pool; | ||
| 263 | int err; | ||
| 264 | |||
| 265 | write_lock_bh(&pool->pool_lock); | ||
| 266 | err = __rxe_add_key_locked(elem, key); | ||
| 267 | write_unlock_bh(&pool->pool_lock); | ||
| 268 | |||
| 269 | return err; | ||
| 270 | } | ||
| 271 | |||
| 272 | void __rxe_drop_key_locked(struct rxe_pool_elem *elem) | ||
| 273 | { | ||
| 274 | struct rxe_pool *pool = elem->pool; | ||
| 275 | |||
| 276 | rb_erase(&elem->key_node, &pool->key.tree); | ||
| 277 | } | ||
| 278 | |||
| 279 | void __rxe_drop_key(struct rxe_pool_elem *elem) | ||
| 280 | { | ||
| 281 | struct rxe_pool *pool = elem->pool; | ||
| 282 | |||
| 283 | write_lock_bh(&pool->pool_lock); | ||
| 284 | __rxe_drop_key_locked(elem); | ||
| 285 | write_unlock_bh(&pool->pool_lock); | ||
| 286 | } | ||
| 287 | |||
| 288 | int __rxe_add_index_locked(struct rxe_pool_elem *elem) | ||
| 289 | { | ||
| 290 | struct rxe_pool *pool = elem->pool; | ||
| 291 | int err; | ||
| 292 | |||
| 293 | elem->index = alloc_index(pool); | ||
| 294 | err = rxe_insert_index(pool, elem); | ||
| 295 | |||
| 296 | return err; | ||
| 297 | } | ||
| 298 | |||
| 299 | int __rxe_add_index(struct rxe_pool_elem *elem) | ||
| 300 | { | ||
| 301 | struct rxe_pool *pool = elem->pool; | ||
| 302 | int err; | ||
| 303 | |||
| 304 | write_lock_bh(&pool->pool_lock); | ||
| 305 | err = __rxe_add_index_locked(elem); | ||
| 306 | write_unlock_bh(&pool->pool_lock); | ||
| 307 | |||
| 308 | return err; | ||
| 309 | } | ||
| 310 | |||
| 311 | void __rxe_drop_index_locked(struct rxe_pool_elem *elem) | ||
| 312 | { | ||
| 313 | struct rxe_pool *pool = elem->pool; | ||
| 314 | |||
| 315 | clear_bit(elem->index - pool->index.min_index, pool->index.table); | ||
| 316 | rb_erase(&elem->index_node, &pool->index.tree); | ||
| 317 | } | ||
| 318 | |||
| 319 | void __rxe_drop_index(struct rxe_pool_elem *elem) | ||
| 320 | { | ||
| 321 | struct rxe_pool *pool = elem->pool; | ||
| 322 | |||
| 323 | write_lock_bh(&pool->pool_lock); | ||
| 324 | __rxe_drop_index_locked(elem); | ||
| 325 | write_unlock_bh(&pool->pool_lock); | ||
| 326 | } | ||
| 327 | |||
| 328 | void *rxe_alloc_locked(struct rxe_pool *pool) | ||
| 329 | { | ||
| 330 | struct rxe_pool_elem *elem; | ||
| 331 | void *obj; | ||
| 332 | |||
| 333 | if (atomic_inc_return(&pool->num_elem) > pool->max_elem) | ||
| 334 | goto out_cnt; | ||
| 335 | |||
| 336 | obj = kzalloc(pool->elem_size, GFP_ATOMIC); | ||
| 337 | if (!obj) | ||
| 338 | goto out_cnt; | ||
| 339 | |||
| 340 | elem = (struct rxe_pool_elem *)((u8 *)obj + pool->elem_offset); | ||
| 341 | |||
| 342 | elem->pool = pool; | ||
| 343 | elem->obj = obj; | ||
| 344 | kref_init(&elem->ref_cnt); | ||
| 345 | |||
| 346 | return obj; | ||
| 347 | |||
| 348 | out_cnt: | ||
| 349 | atomic_dec(&pool->num_elem); | ||
| 350 | return NULL; | ||
| 351 | } | 117 | } |
| 352 | 118 | ||
| 353 | void *rxe_alloc(struct rxe_pool *pool) | 119 | void *rxe_alloc(struct rxe_pool *pool) |
| 354 | { | 120 | { |
| 355 | struct rxe_pool_elem *elem; | 121 | struct rxe_pool_elem *elem; |
| 356 | void *obj; | 122 | void *obj; |
| 123 | int err; | ||
| 124 | |||
| 125 | if (WARN_ON(!(pool->flags & RXE_POOL_ALLOC))) | ||
| 126 | return NULL; | ||
| 357 | 127 | ||
| 358 | if (atomic_inc_return(&pool->num_elem) > pool->max_elem) | 128 | if (atomic_inc_return(&pool->num_elem) > pool->max_elem) |
| 359 | goto out_cnt; | 129 | goto err_cnt; |
| 360 | 130 | ||
| 361 | obj = kzalloc(pool->elem_size, GFP_KERNEL); | 131 | obj = kzalloc(pool->elem_size, GFP_KERNEL); |
| 362 | if (!obj) | 132 | if (!obj) |
| 363 | goto out_cnt; | 133 | goto err_cnt; |
| 364 | 134 | ||
| 365 | elem = (struct rxe_pool_elem *)((u8 *)obj + pool->elem_offset); | 135 | elem = (struct rxe_pool_elem *)((u8 *)obj + pool->elem_offset); |
| 366 | 136 | ||
| @@ -368,127 +138,86 @@ void *rxe_alloc(struct rxe_pool *pool) · 1 unmodified line | |||
| 368 | elem->obj = obj; | 138 | elem->obj = obj; |
| 369 | kref_init(&elem->ref_cnt); | 139 | kref_init(&elem->ref_cnt); |
| 370 | 140 | ||
| 141 | err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit, | ||
| 142 | &pool->next, GFP_KERNEL); | ||
| 143 | if (err) | ||
| 144 | goto err_free; | ||
| 145 | |||
| 371 | return obj; | 146 | return obj; |
| 372 | 147 | ||
| 373 | out_cnt: | 148 | err_free: |
| 149 | kfree(obj); | ||
| 150 | err_cnt: | ||
| 374 | atomic_dec(&pool->num_elem); | 151 | atomic_dec(&pool->num_elem); |
| 375 | return NULL; | 152 | return NULL; |
| 376 | } | 153 | } |
| 377 | 154 | ||
| 378 | int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem) | 155 | int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem) |
| 379 | { | 156 | { |
| 157 | int err; | ||
| 158 | |||
| 159 | if (WARN_ON(pool->flags & RXE_POOL_ALLOC)) | ||
| 160 | return -EINVAL; | ||
| 161 | |||
| 380 | if (atomic_inc_return(&pool->num_elem) > pool->max_elem) | 162 | if (atomic_inc_return(&pool->num_elem) > pool->max_elem) |
| 381 | goto out_cnt; | 163 | goto err_cnt; |
| 382 | 164 | ||
| 383 | elem->pool = pool; | 165 | elem->pool = pool; |
| 384 | elem->obj = (u8 *)elem - pool->elem_offset; | 166 | elem->obj = (u8 *)elem - pool->elem_offset; |
| 385 | kref_init(&elem->ref_cnt); | 167 | kref_init(&elem->ref_cnt); |
| 386 | 168 | ||
| 169 | err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit, | ||
| 170 | &pool->next, GFP_KERNEL); | ||
| 171 | if (err) | ||
| 172 | goto err_cnt; | ||
| 173 | |||
| 387 | return 0; | 174 | return 0; |
| 388 | 175 | ||
| 389 | out_cnt: | 176 | err_cnt: |
| 390 | atomic_dec(&pool->num_elem); | 177 | atomic_dec(&pool->num_elem); |
| 391 | return -EINVAL; | 178 | return -EINVAL; |
| 392 | } | 179 | } |
| 393 | 180 | ||
| 394 | void rxe_elem_release(struct kref *kref) | 181 | void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) |
| 395 | { | ||
| 396 | struct rxe_pool_elem *elem = | ||
| 397 | container_of(kref, struct rxe_pool_elem, ref_cnt); | ||
| 398 | struct rxe_pool *pool = elem->pool; | ||
| 399 | void *obj; | ||
| 400 | |||
| 401 | if (pool->cleanup) | ||
| 402 | pool->cleanup(elem); | ||
| 403 | |||
| 404 | if (!(pool->flags & RXE_POOL_NO_ALLOC)) { | ||
| 405 | obj = elem->obj; | ||
| 406 | kfree(obj); | ||
| 407 | } | ||
| 408 | |||
| 409 | atomic_dec(&pool->num_elem); | ||
| 410 | } | ||
| 411 | |||
| 412 | void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index) | ||
| 413 | { | 182 | { |
| 414 | struct rb_node *node; | ||
| 415 | struct rxe_pool_elem *elem; | 183 | struct rxe_pool_elem *elem; |
| 184 | struct xarray *xa = &pool->xa; | ||
| 185 | unsigned long flags; | ||
| 416 | void *obj; | 186 | void *obj; |
| 417 | 187 | ||
| 418 | node = pool->index.tree.rb_node; | 188 | xa_lock_irqsave(xa, flags); |
| 419 | 189 | elem = xa_load(xa, index); | |
| 420 | while (node) { | 190 | if (elem && kref_get_unless_zero(&elem->ref_cnt)) |
| 421 | elem = rb_entry(node, struct rxe_pool_elem, index_node); | ||
| 422 | |||
| 423 | if (elem->index > index) | ||
| 424 | node = node->rb_left; | ||
| 425 | else if (elem->index < index) | ||
| 426 | node = node->rb_right; | ||
| 427 | else | ||
| 428 | break; | ||
| 429 | } | ||
| 430 | |||
| 431 | if (node) { | ||
| 432 | kref_get(&elem->ref_cnt); | ||
| 433 | obj = elem->obj; | 191 | obj = elem->obj; |
| 434 | } else { | 192 | else |
| 435 | obj = NULL; | 193 | obj = NULL; |
| 436 | } | 194 | xa_unlock_irqrestore(xa, flags); |
| 437 | |||
| 438 | return obj; | ||
| 439 | } | ||
| 440 | |||
| 441 | void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) | ||
| 442 | { | ||
| 443 | void *obj; | ||
| 444 | |||
| 445 | read_lock_bh(&pool->pool_lock); | ||
| 446 | obj = rxe_pool_get_index_locked(pool, index); | ||
| 447 | read_unlock_bh(&pool->pool_lock); | ||
| 448 | 195 | ||
| 449 | return obj; | 196 | return obj; |
| 450 | } | 197 | } |
| 451 | 198 | ||
| 452 | void *rxe_pool_get_key_locked(struct rxe_pool *pool, void *key) | 199 | static void rxe_elem_release(struct kref *kref) |
| 453 | { | 200 | { |
| 454 | struct rb_node *node; | 201 | struct rxe_pool_elem *elem = container_of(kref, typeof(*elem), ref_cnt); |
| 455 | struct rxe_pool_elem *elem; | 202 | struct rxe_pool *pool = elem->pool; |
| 456 | void *obj; | ||
| 457 | int cmp; | ||
| 458 | |||
| 459 | node = pool->key.tree.rb_node; | ||
| 460 | 203 | ||
| 461 | while (node) { | 204 | xa_erase(&pool->xa, elem->index); |
| 462 | elem = rb_entry(node, struct rxe_pool_elem, key_node); | ||
| 463 | 205 | ||
| 464 | cmp = memcmp((u8 *)elem + pool->key.key_offset, | 206 | if (pool->cleanup) |
| 465 | key, pool->key.key_size); | 207 | pool->cleanup(elem); |
| 466 | 208 | ||
| 467 | if (cmp > 0) | 209 | if (pool->flags & RXE_POOL_ALLOC) |
| 468 | node = node->rb_left; | 210 | kfree(elem->obj); |
| 469 | else if (cmp < 0) | ||
| 470 | node = node->rb_right; | ||
| 471 | else | ||
| 472 | break; | ||
| 473 | } | ||
| 474 | 211 | ||
| 475 | if (node) { | 212 | atomic_dec(&pool->num_elem); |
| 476 | kref_get(&elem->ref_cnt); | ||
| 477 | obj = elem->obj; | ||
| 478 | } else { | ||
| 479 | obj = NULL; | ||
| 480 | } | ||
| 481 | |||
| 482 | return obj; | ||
| 483 | } | 213 | } |
| 484 | 214 | ||
| 485 | void *rxe_pool_get_key(struct rxe_pool *pool, void *key) | 215 | int __rxe_get(struct rxe_pool_elem *elem) |
| 486 | { | 216 | { |
| 487 | void *obj; | 217 | return kref_get_unless_zero(&elem->ref_cnt); |
| 488 | 218 | } | |
| 489 | read_lock_bh(&pool->pool_lock); | ||
| 490 | obj = rxe_pool_get_key_locked(pool, key); | ||
| 491 | read_unlock_bh(&pool->pool_lock); | ||
| 492 | 219 | ||
| 493 | return obj; | 220 | int __rxe_put(struct rxe_pool_elem *elem) |
| 221 | { | ||
| 222 | return kref_put(&elem->ref_cnt, rxe_elem_release); | ||
| 494 | } | 223 | } |
| @@ -8,9 +8,7 @@ · 7 unmodified lines | |||
| 8 | #define RXE_POOL_H | 8 | #define RXE_POOL_H |
| 9 | 9 | ||
| 10 | enum rxe_pool_flags { | 10 | enum rxe_pool_flags { |
| 11 | RXE_POOL_INDEX = BIT(1), | 11 | RXE_POOL_ALLOC = BIT(1), |
| 12 | RXE_POOL_KEY = BIT(2), | ||
| 13 | RXE_POOL_NO_ALLOC = BIT(4), | ||
| 14 | }; | 12 | }; |
| 15 | 13 | ||
| 16 | enum rxe_elem_type { | 14 | enum rxe_elem_type { |
| @@ -22,8 +20,6 @@ enum rxe_elem_type { · 5 unmodified lines | |||
| 22 | RXE_TYPE_CQ, | 20 | RXE_TYPE_CQ, |
| 23 | RXE_TYPE_MR, | 21 | RXE_TYPE_MR, |
| 24 | RXE_TYPE_MW, | 22 | RXE_TYPE_MW, |
| 25 | RXE_TYPE_MC_GRP, | ||
| 26 | RXE_TYPE_MC_ELEM, | ||
| 27 | RXE_NUM_TYPES, /* keep me last */ | 23 | RXE_NUM_TYPES, /* keep me last */ |
| 28 | }; | 24 | }; |
| 29 | 25 | ||
| @@ -32,20 +28,13 @@ struct rxe_pool_elem { · 2 unmodified lines | |||
| 32 | void *obj; | 28 | void *obj; |
| 33 | struct kref ref_cnt; | 29 | struct kref ref_cnt; |
| 34 | struct list_head list; | 30 | struct list_head list; |
| 35 | |||
| 36 | /* only used if keyed */ | ||
| 37 | struct rb_node key_node; | ||
| 38 | |||
| 39 | /* only used if indexed */ | ||
| 40 | struct rb_node index_node; | ||
| 41 | u32 index; | 31 | u32 index; |
| 42 | }; | 32 | }; |
| 43 | 33 | ||
| 44 | struct rxe_pool { | 34 | struct rxe_pool { |
| 45 | struct rxe_dev *rxe; | 35 | struct rxe_dev *rxe; |
| 46 | const char *name; | 36 | const char *name; |
| 47 | rwlock_t pool_lock; /* protects pool add/del/search */ | 37 | void (*cleanup)(struct rxe_pool_elem *elem); |
| 48 | void (*cleanup)(struct rxe_pool_elem *obj); | ||
| 49 | enum rxe_pool_flags flags; | 38 | enum rxe_pool_flags flags; |
| 50 | enum rxe_elem_type type; | 39 | enum rxe_elem_type type; |
| 51 | 40 | ||
| @@ -54,36 +43,22 @@ struct rxe_pool { · 2 unmodified lines | |||
| 54 | size_t elem_size; | 43 | size_t elem_size; |
| 55 | size_t elem_offset; | 44 | size_t elem_offset; |
| 56 | 45 | ||
| 57 | /* only used if indexed */ | 46 | struct xarray xa; |
| 58 | struct { | 47 | struct xa_limit limit; |
| 59 | struct rb_root tree; | 48 | u32 next; |
| 60 | unsigned long *table; | ||
| 61 | u32 last; | ||
| 62 | u32 max_index; | ||
| 63 | u32 min_index; | ||
| 64 | } index; | ||
| 65 | |||
| 66 | /* only used if keyed */ | ||
| 67 | struct { | ||
| 68 | struct rb_root tree; | ||
| 69 | size_t key_offset; | ||
| 70 | size_t key_size; | ||
| 71 | } key; | ||
| 72 | }; | 49 | }; |
| 73 | 50 | ||
| 74 | /* initialize a pool of objects with given limit on | 51 | /* initialize a pool of objects with given limit on |
| 75 | * number of elements. gets parameters from rxe_type_info | 52 | * number of elements. gets parameters from rxe_type_info |
| 76 | * pool elements will be allocated out of a slab cache | 53 | * pool elements will be allocated out of a slab cache |
| 77 | */ | 54 | */ |
| 78 | int rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, | 55 | void rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool, |
| 79 | enum rxe_elem_type type, u32 max_elem); | 56 | enum rxe_elem_type type); |
| 80 | 57 | ||
| 81 | /* free resources from object pool */ | 58 | /* free resources from object pool */ |
| 82 | void rxe_pool_cleanup(struct rxe_pool *pool); | 59 | void rxe_pool_cleanup(struct rxe_pool *pool); |
| 83 | 60 | ||
| 84 | /* allocate an object from pool holding and not holding the pool lock */ | 61 | /* allocate an object from pool */ |
| 85 | void *rxe_alloc_locked(struct rxe_pool *pool); | ||
| 86 | |||
| 87 | void *rxe_alloc(struct rxe_pool *pool); | 62 | void *rxe_alloc(struct rxe_pool *pool); |
| 88 | 63 | ||
| 89 | /* connect already allocated object to pool */ | 64 | /* connect already allocated object to pool */ |
| @@ -91,69 +66,17 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem); · 1 unmodified line | |||
| 91 | 66 | ||
| 92 | #define rxe_add_to_pool(pool, obj) __rxe_add_to_pool(pool, &(obj)->elem) | 67 | #define rxe_add_to_pool(pool, obj) __rxe_add_to_pool(pool, &(obj)->elem) |
| 93 | 68 | ||
| 94 | /* assign an index to an indexed object and insert object into | 69 | /* lookup an indexed object from index. takes a reference on object */ |
| 95 | * pool's rb tree holding and not holding the pool_lock | ||
| 96 | */ | ||
| 97 | int __rxe_add_index_locked(struct rxe_pool_elem *elem); | ||
| 98 | |||
| 99 | #define rxe_add_index_locked(obj) __rxe_add_index_locked(&(obj)->elem) | ||
| 100 | |||
| 101 | int __rxe_add_index(struct rxe_pool_elem *elem); | ||
| 102 | |||
| 103 | #define rxe_add_index(obj) __rxe_add_index(&(obj)->elem) | ||
| 104 | |||
| 105 | /* drop an index and remove object from rb tree | ||
| 106 | * holding and not holding the pool_lock | ||
| 107 | */ | ||
| 108 | void __rxe_drop_index_locked(struct rxe_pool_elem *elem); | ||
| 109 | |||
| 110 | #define rxe_drop_index_locked(obj) __rxe_drop_index_locked(&(obj)->elem) | ||
| 111 | |||
| 112 | void __rxe_drop_index(struct rxe_pool_elem *elem); | ||
| 113 | |||
| 114 | #define rxe_drop_index(obj) __rxe_drop_index(&(obj)->elem) | ||
| 115 | |||
| 116 | /* assign a key to a keyed object and insert object into | ||
| 117 | * pool's rb tree holding and not holding pool_lock | ||
| 118 | */ | ||
| 119 | int __rxe_add_key_locked(struct rxe_pool_elem *elem, void *key); | ||
| 120 | |||
| 121 | #define rxe_add_key_locked(obj, key) __rxe_add_key_locked(&(obj)->elem, key) | ||
| 122 | |||
| 123 | int __rxe_add_key(struct rxe_pool_elem *elem, void *key); | ||
| 124 | |||
| 125 | #define rxe_add_key(obj, key) __rxe_add_key(&(obj)->elem, key) | ||
| 126 | |||
| 127 | /* remove elem from rb tree holding and not holding the pool_lock */ | ||
| 128 | void __rxe_drop_key_locked(struct rxe_pool_elem *elem); | ||
| 129 | |||
| 130 | #define rxe_drop_key_locked(obj) __rxe_drop_key_locked(&(obj)->elem) | ||
| 131 | |||
| 132 | void __rxe_drop_key(struct rxe_pool_elem *elem); | ||
| 133 | |||
| 134 | #define rxe_drop_key(obj) __rxe_drop_key(&(obj)->elem) | ||
| 135 | |||
| 136 | /* lookup an indexed object from index holding and not holding the pool_lock. | ||
| 137 | * takes a reference on object | ||
| 138 | */ | ||
| 139 | void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index); | ||
| 140 | |||
| 141 | void *rxe_pool_get_index(struct rxe_pool *pool, u32 index); | 70 | void *rxe_pool_get_index(struct rxe_pool *pool, u32 index); |
| 142 | 71 | ||
| 143 | /* lookup keyed object from key holding and not holding the pool_lock. | 72 | int __rxe_get(struct rxe_pool_elem *elem); |
| 144 | * takes a reference on the objecti | ||
| 145 | */ | ||
| 146 | void *rxe_pool_get_key_locked(struct rxe_pool *pool, void *key); | ||
| 147 | 73 | ||
| 148 | void *rxe_pool_get_key(struct rxe_pool *pool, void *key); | 74 | #define rxe_get(obj) __rxe_get(&(obj)->elem) |
| 149 | 75 | ||
| 150 | /* cleanup an object when all references are dropped */ | 76 | int __rxe_put(struct rxe_pool_elem *elem); |
| 151 | void rxe_elem_release(struct kref *kref); | ||
| 152 | 77 | ||
| 153 | /* take a reference on an object */ | 78 | #define rxe_put(obj) __rxe_put(&(obj)->elem) |
| 154 | #define rxe_add_ref(obj) kref_get(&(obj)->elem.ref_cnt) | ||
| 155 | 79 | ||
| 156 | /* drop a reference on an object */ | 80 | #define rxe_read(obj) kref_read(&(obj)->elem.ref_cnt) |
| 157 | #define rxe_drop_ref(obj) kref_put(&(obj)->elem.ref_cnt, rxe_elem_release) | ||
| 158 | 81 | ||
| 159 | #endif /* RXE_POOL_H */ | 82 | #endif /* RXE_POOL_H */ |
| @@ -135,12 +135,8 @@ static void free_rd_atomic_resources(struct rxe_qp *qp) · 134 unmodified lines | |||
| 135 | 135 | ||
| 136 | void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res) | 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 | kfree_skb(res->atomic.skb); | 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 | res->type = 0; | 140 | res->type = 0; |
| 145 | } | 141 | } |
| 146 | 142 | ||
| @@ -188,9 +184,6 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp, · 41 unmodified lines | |||
| 188 | break; | 184 | break; |
| 189 | } | 185 | } |
| 190 | 186 | ||
| 191 | INIT_LIST_HEAD(&qp->grp_list); | ||
| 192 | |||
| 193 | spin_lock_init(&qp->grp_lock); | ||
| 194 | spin_lock_init(&qp->state_lock); | 187 | spin_lock_init(&qp->state_lock); |
| 195 | 188 | ||
| 196 | atomic_set(&qp->ssn, 0); | 189 | atomic_set(&qp->ssn, 0); |
| @@ -330,11 +323,11 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, · 133 unmodified lines | |||
| 330 | struct rxe_cq *scq = to_rcq(init->send_cq); | 323 | struct rxe_cq *scq = to_rcq(init->send_cq); |
| 331 | struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; | 324 | struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; |
| 332 | 325 | ||
| 333 | rxe_add_ref(pd); | 326 | rxe_get(pd); |
| 334 | rxe_add_ref(rcq); | 327 | rxe_get(rcq); |
| 335 | rxe_add_ref(scq); | 328 | rxe_get(scq); |
| 336 | if (srq) | 329 | if (srq) |
| 337 | rxe_add_ref(srq); | 330 | rxe_get(srq); |
| 338 | 331 | ||
| 339 | qp->pd = pd; | 332 | qp->pd = pd; |
| 340 | qp->rcq = rcq; | 333 | qp->rcq = rcq; |
| @@ -366,10 +359,10 @@ err1: · 25 unmodified lines | |||
| 366 | qp->srq = NULL; | 359 | qp->srq = NULL; |
| 367 | 360 | ||
| 368 | if (srq) | 361 | if (srq) |
| 369 | rxe_drop_ref(srq); | 362 | rxe_put(srq); |
| 370 | rxe_drop_ref(scq); | 363 | rxe_put(scq); |
| 371 | rxe_drop_ref(rcq); | 364 | rxe_put(rcq); |
| 372 | rxe_drop_ref(pd); | 365 | rxe_put(pd); |
| 373 | 366 | ||
| 374 | return err; | 367 | return err; |
| 375 | } | 368 | } |
| @@ -528,7 +521,7 @@ static void rxe_qp_reset(struct rxe_qp *qp) · 152 unmodified lines | |||
| 528 | qp->resp.sent_psn_nak = 0; | 521 | qp->resp.sent_psn_nak = 0; |
| 529 | 522 | ||
| 530 | if (qp->resp.mr) { | 523 | if (qp->resp.mr) { |
| 531 | rxe_drop_ref(qp->resp.mr); | 524 | rxe_put(qp->resp.mr); |
| 532 | qp->resp.mr = NULL; | 525 | qp->resp.mr = NULL; |
| 533 | } | 526 | } |
| 534 | 527 | ||
| @@ -770,6 +763,20 @@ int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask) · 235 unmodified lines | |||
| 770 | return 0; | 763 | return 0; |
| 771 | } | 764 | } |
| 772 | 765 | ||
| 766 | int rxe_qp_chk_destroy(struct rxe_qp *qp) | ||
| 767 | { | ||
| 768 | /* See IBA o10-2.2.3 | ||
| 769 | * An attempt to destroy a QP while attached to a mcast group | ||
| 770 | * will fail immediately. | ||
| 771 | */ | ||
| 772 | if (atomic_read(&qp->mcg_num)) { | ||
| 773 | pr_debug("Attempt to destroy QP while attached to multicast group\n"); | ||
| 774 | return -EBUSY; | ||
| 775 | } | ||
| 776 | |||
| 777 | return 0; | ||
| 778 | } | ||
| 779 | |||
| 773 | /* called by the destroy qp verb */ | 780 | /* called by the destroy qp verb */ |
| 774 | void rxe_qp_destroy(struct rxe_qp *qp) | 781 | void rxe_qp_destroy(struct rxe_qp *qp) |
| 775 | { | 782 | { |
| @@ -798,28 +805,24 @@ static void rxe_qp_do_cleanup(struct work_struct *work) · 22 unmodified lines | |||
| 798 | { | 805 | { |
| 799 | struct rxe_qp *qp = container_of(work, typeof(*qp), cleanup_work.work); | 806 | struct rxe_qp *qp = container_of(work, typeof(*qp), cleanup_work.work); |
| 800 | 807 | ||
| 801 | rxe_drop_all_mcast_groups(qp); | ||
| 802 | |||
| 803 | if (qp->sq.queue) | 808 | if (qp->sq.queue) |
| 804 | rxe_queue_cleanup(qp->sq.queue); | 809 | rxe_queue_cleanup(qp->sq.queue); |
| 805 | 810 | ||
| 806 | if (qp->srq) | 811 | if (qp->srq) |
| 807 | rxe_drop_ref(qp->srq); | 812 | rxe_put(qp->srq); |
| 808 | 813 | ||
| 809 | if (qp->rq.queue) | 814 | if (qp->rq.queue) |
| 810 | rxe_queue_cleanup(qp->rq.queue); | 815 | rxe_queue_cleanup(qp->rq.queue); |
| 811 | 816 | ||
| 812 | if (qp->scq) | 817 | if (qp->scq) |
| 813 | rxe_drop_ref(qp->scq); | 818 | rxe_put(qp->scq); |
| 814 | if (qp->rcq) | 819 | if (qp->rcq) |
| 815 | rxe_drop_ref(qp->rcq); | 820 | rxe_put(qp->rcq); |
| 816 | if (qp->pd) | 821 | if (qp->pd) |
| 817 | rxe_drop_ref(qp->pd); | 822 | rxe_put(qp->pd); |
| 818 | 823 | ||
| 819 | if (qp->resp.mr) { | 824 | if (qp->resp.mr) |
| 820 | rxe_drop_ref(qp->resp.mr); | 825 | rxe_put(qp->resp.mr); |
| 821 | qp->resp.mr = NULL; | ||
| 822 | } | ||
| 823 | 826 | ||
| 824 | if (qp_type(qp) == IB_QPT_RC) | 827 | if (qp_type(qp) == IB_QPT_RC) |
| 825 | sk_dst_reset(qp->sk->sk); | 828 | sk_dst_reset(qp->sk->sk); |
| @@ -151,6 +151,8 @@ int rxe_queue_resize(struct rxe_queue *q, unsigned int *num_elem_p, · 150 unmodified lines | |||
| 151 | struct rxe_queue *new_q; | 151 | struct rxe_queue *new_q; |
| 152 | unsigned int num_elem = *num_elem_p; | 152 | unsigned int num_elem = *num_elem_p; |
| 153 | int err; | 153 | int err; |
| 154 | unsigned long producer_flags; | ||
| 155 | unsigned long consumer_flags; | ||
| 154 | 156 | ||
| 155 | new_q = rxe_queue_init(q->rxe, &num_elem, elem_size, q->type); | 157 | new_q = rxe_queue_init(q->rxe, &num_elem, elem_size, q->type); |
| 156 | if (!new_q) | 158 | if (!new_q) |
| @@ -164,17 +166,17 @@ int rxe_queue_resize(struct rxe_queue *q, unsigned int *num_elem_p, · 7 unmodified lines | |||
| 164 | goto err1; | 166 | goto err1; |
| 165 | } | 167 | } |
| 166 | 168 | ||
| 167 | spin_lock_bh(consumer_lock); | 169 | spin_lock_irqsave(consumer_lock, consumer_flags); |
| 168 | 170 | ||
| 169 | if (producer_lock) { | 171 | if (producer_lock) { |
| 170 | spin_lock_bh(producer_lock); | 172 | spin_lock_irqsave(producer_lock, producer_flags); |
| 171 | err = resize_finish(q, new_q, num_elem); | 173 | err = resize_finish(q, new_q, num_elem); |
| 172 | spin_unlock_bh(producer_lock); | 174 | spin_unlock_irqrestore(producer_lock, producer_flags); |
| 173 | } else { | 175 | } else { |
| 174 | err = resize_finish(q, new_q, num_elem); | 176 | err = resize_finish(q, new_q, num_elem); |
| 175 | } | 177 | } |
| 176 | 178 | ||
| 177 | spin_unlock_bh(consumer_lock); | 179 | spin_unlock_irqrestore(consumer_lock, consumer_flags); |
| 178 | 180 | ||
| 179 | rxe_queue_cleanup(new_q); /* new/old dep on err */ | 181 | rxe_queue_cleanup(new_q); /* new/old dep on err */ |
| 180 | if (err) | 182 | if (err) |
| @@ -217,7 +217,7 @@ static int hdr_check(struct rxe_pkt_info *pkt) · 216 unmodified lines | |||
| 217 | return 0; | 217 | return 0; |
| 218 | 218 | ||
| 219 | err2: | 219 | err2: |
| 220 | rxe_drop_ref(qp); | 220 | rxe_put(qp); |
| 221 | err1: | 221 | err1: |
| 222 | return -EINVAL; | 222 | return -EINVAL; |
| 223 | } | 223 | } |
| @@ -233,8 +233,8 @@ static inline void rxe_rcv_pkt(struct rxe_pkt_info *pkt, struct sk_buff *skb) · 9 unmodified lines | |||
| 233 | static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) | 233 | static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) |
| 234 | { | 234 | { |
| 235 | struct rxe_pkt_info *pkt = SKB_TO_PKT(skb); | 235 | struct rxe_pkt_info *pkt = SKB_TO_PKT(skb); |
| 236 | struct rxe_mc_grp *mcg; | 236 | struct rxe_mcg *mcg; |
| 237 | struct rxe_mc_elem *mce; | 237 | struct rxe_mca *mca; |
| 238 | struct rxe_qp *qp; | 238 | struct rxe_qp *qp; |
| 239 | union ib_gid dgid; | 239 | union ib_gid dgid; |
| 240 | int err; | 240 | int err; |
| @@ -246,19 +246,19 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) · 5 unmodified lines | |||
| 246 | memcpy(&dgid, &ipv6_hdr(skb)->daddr, sizeof(dgid)); | 246 | memcpy(&dgid, &ipv6_hdr(skb)->daddr, sizeof(dgid)); |
| 247 | 247 | ||
| 248 | /* lookup mcast group corresponding to mgid, takes a ref */ | 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 | if (!mcg) | 250 | if (!mcg) |
| 251 | goto drop; /* mcast group not registered */ | 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 | /* this is unreliable datagram service so we let | 255 | /* this is unreliable datagram service so we let |
| 256 | * failures to deliver a multicast packet to a | 256 | * failures to deliver a multicast packet to a |
| 257 | * single QP happen and just move on and try | 257 | * single QP happen and just move on and try |
| 258 | * the rest of them on the list | 258 | * the rest of them on the list |
| 259 | */ | 259 | */ |
| 260 | list_for_each_entry(mce, &mcg->qp_list, qp_list) { | 260 | list_for_each_entry(mca, &mcg->qp_list, qp_list) { |
| 261 | qp = mce->qp; | 261 | qp = mca->qp; |
| 262 | 262 | ||
| 263 | /* validate qp for incoming packet */ | 263 | /* validate qp for incoming packet */ |
| 264 | err = check_type_state(rxe, pkt, qp); | 264 | err = check_type_state(rxe, pkt, qp); |
| @@ -273,7 +273,7 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) · 8 unmodified lines | |||
| 273 | * skb and pass to the QP. Pass the original skb to | 273 | * skb and pass to the QP. Pass the original skb to |
| 274 | * the last QP in the list. | 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 | struct sk_buff *cskb; | 277 | struct sk_buff *cskb; |
| 278 | struct rxe_pkt_info *cpkt; | 278 | struct rxe_pkt_info *cpkt; |
| 279 | 279 | ||
| @@ -288,19 +288,19 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) · 8 unmodified lines | |||
| 288 | 288 | ||
| 289 | cpkt = SKB_TO_PKT(cskb); | 289 | cpkt = SKB_TO_PKT(cskb); |
| 290 | cpkt->qp = qp; | 290 | cpkt->qp = qp; |
| 291 | rxe_add_ref(qp); | 291 | rxe_get(qp); |
| 292 | rxe_rcv_pkt(cpkt, cskb); | 292 | rxe_rcv_pkt(cpkt, cskb); |
| 293 | } else { | 293 | } else { |
| 294 | pkt->qp = qp; | 294 | pkt->qp = qp; |
| 295 | rxe_add_ref(qp); | 295 | rxe_get(qp); |
| 296 | rxe_rcv_pkt(pkt, skb); | 296 | rxe_rcv_pkt(pkt, skb); |
| 297 | skb = NULL; /* mark consumed */ | 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 | if (likely(!skb)) | 305 | if (likely(!skb)) |
| 306 | return; | 306 | return; |
| @@ -397,7 +397,7 @@ void rxe_rcv(struct sk_buff *skb) · 90 unmodified lines | |||
| 397 | 397 | ||
| 398 | drop: | 398 | drop: |
| 399 | if (pkt->qp) | 399 | if (pkt->qp) |
| 400 | rxe_drop_ref(pkt->qp); | 400 | rxe_put(pkt->qp); |
| 401 | 401 | ||
| 402 | kfree_skb(skb); | 402 | kfree_skb(skb); |
| 403 | ib_device_put(&rxe->ib_dev); | 403 | ib_device_put(&rxe->ib_dev); |
| @@ -358,14 +358,14 @@ static inline int get_mtu(struct rxe_qp *qp) · 357 unmodified lines | |||
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | static struct sk_buff *init_req_packet(struct rxe_qp *qp, | 360 | static struct sk_buff *init_req_packet(struct rxe_qp *qp, |
| 361 | struct rxe_av *av, | ||
| 361 | struct rxe_send_wqe *wqe, | 362 | struct rxe_send_wqe *wqe, |
| 362 | int opcode, int payload, | 363 | int opcode, u32 payload, |
| 363 | struct rxe_pkt_info *pkt) | 364 | struct rxe_pkt_info *pkt) |
| 364 | { | 365 | { |
| 365 | struct rxe_dev *rxe = to_rdev(qp->ibqp.device); | 366 | struct rxe_dev *rxe = to_rdev(qp->ibqp.device); |
| 366 | struct sk_buff *skb; | 367 | struct sk_buff *skb; |
| 367 | struct rxe_send_wr *ibwr = &wqe->wr; | 368 | struct rxe_send_wr *ibwr = &wqe->wr; |
| 368 | struct rxe_av *av; | ||
| 369 | int pad = (-payload) & 0x3; | 369 | int pad = (-payload) & 0x3; |
| 370 | int paylen; | 370 | int paylen; |
| 371 | int solicited; | 371 | int solicited; |
| @@ -374,21 +374,9 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, · 2 unmodified lines | |||
| 374 | 374 | ||
| 375 | /* length from start of bth to end of icrc */ | 375 | /* length from start of bth to end of icrc */ |
| 376 | paylen = rxe_opcode[opcode].length + payload + pad + RXE_ICRC_SIZE; | 376 | paylen = rxe_opcode[opcode].length + payload + pad + RXE_ICRC_SIZE; |
| 377 | 377 | pkt->paylen = paylen; | |
| 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; | ||
| 386 | 378 | ||
| 387 | /* init skb */ | 379 | /* init skb */ |
| 388 | av = rxe_get_av(pkt); | ||
| 389 | if (!av) | ||
| 390 | return NULL; | ||
| 391 | |||
| 392 | skb = rxe_init_packet(rxe, av, paylen, pkt); | 380 | skb = rxe_init_packet(rxe, av, paylen, pkt); |
| 393 | if (unlikely(!skb)) | 381 | if (unlikely(!skb)) |
| 394 | return NULL; | 382 | return NULL; |
| @@ -447,13 +435,13 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, · 52 unmodified lines | |||
| 447 | return skb; | 435 | return skb; |
| 448 | } | 436 | } |
| 449 | 437 | ||
| 450 | static int finish_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe, | 438 | static int finish_packet(struct rxe_qp *qp, struct rxe_av *av, |
| 451 | struct rxe_pkt_info *pkt, struct sk_buff *skb, | 439 | struct rxe_send_wqe *wqe, struct rxe_pkt_info *pkt, |
| 452 | int paylen) | 440 | struct sk_buff *skb, u32 paylen) |
| 453 | { | 441 | { |
| 454 | int err; | 442 | int err; |
| 455 | 443 | ||
| 456 | err = rxe_prepare(pkt, skb); | 444 | err = rxe_prepare(av, pkt, skb); |
| 457 | if (err) | 445 | if (err) |
| 458 | return err; | 446 | return err; |
| 459 | 447 | ||
| @@ -497,7 +485,7 @@ static void update_wqe_state(struct rxe_qp *qp, · 37 unmodified lines | |||
| 497 | static void update_wqe_psn(struct rxe_qp *qp, | 485 | static void update_wqe_psn(struct rxe_qp *qp, |
| 498 | struct rxe_send_wqe *wqe, | 486 | struct rxe_send_wqe *wqe, |
| 499 | struct rxe_pkt_info *pkt, | 487 | struct rxe_pkt_info *pkt, |
| 500 | int payload) | 488 | u32 payload) |
| 501 | { | 489 | { |
| 502 | /* number of packets left to send including current one */ | 490 | /* number of packets left to send including current one */ |
| 503 | int num_pkt = (wqe->dma.resid + payload + qp->mtu - 1) / qp->mtu; | 491 | int num_pkt = (wqe->dma.resid + payload + qp->mtu - 1) / qp->mtu; |
| @@ -540,7 +528,7 @@ static void rollback_state(struct rxe_send_wqe *wqe, · 36 unmodified lines | |||
| 540 | } | 528 | } |
| 541 | 529 | ||
| 542 | static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, | 530 | static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, |
| 543 | struct rxe_pkt_info *pkt, int payload) | 531 | struct rxe_pkt_info *pkt) |
| 544 | { | 532 | { |
| 545 | qp->req.opcode = pkt->opcode; | 533 | qp->req.opcode = pkt->opcode; |
| 546 | 534 | ||
| @@ -608,19 +596,22 @@ static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) · 61 unmodified lines | |||
| 608 | int rxe_requester(void *arg) | 596 | int rxe_requester(void *arg) |
| 609 | { | 597 | { |
| 610 | struct rxe_qp *qp = (struct rxe_qp *)arg; | 598 | struct rxe_qp *qp = (struct rxe_qp *)arg; |
| 599 | struct rxe_dev *rxe = to_rdev(qp->ibqp.device); | ||
| 611 | struct rxe_pkt_info pkt; | 600 | struct rxe_pkt_info pkt; |
| 612 | struct sk_buff *skb; | 601 | struct sk_buff *skb; |
| 613 | struct rxe_send_wqe *wqe; | 602 | struct rxe_send_wqe *wqe; |
| 614 | enum rxe_hdr_mask mask; | 603 | enum rxe_hdr_mask mask; |
| 615 | int payload; | 604 | u32 payload; |
| 616 | int mtu; | 605 | int mtu; |
| 617 | int opcode; | 606 | int opcode; |
| 618 | int ret; | 607 | int ret; |
| 619 | struct rxe_send_wqe rollback_wqe; | 608 | struct rxe_send_wqe rollback_wqe; |
| 620 | u32 rollback_psn; | 609 | u32 rollback_psn; |
| 621 | struct rxe_queue *q = qp->sq.queue; | 610 | struct rxe_queue *q = qp->sq.queue; |
| 611 | struct rxe_ah *ah; | ||
| 612 | struct rxe_av *av; | ||
| 622 | 613 | ||
| 623 | rxe_add_ref(qp); | 614 | rxe_get(qp); |
| 624 | 615 | ||
| 625 | next_wqe: | 616 | next_wqe: |
| 626 | if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) | 617 | if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) |
| @@ -699,20 +690,34 @@ next_wqe: · 72 unmodified lines | |||
| 699 | wqe->state = wqe_state_done; | 690 | wqe->state = wqe_state_done; |
| 700 | wqe->status = IB_WC_SUCCESS; | 691 | wqe->status = IB_WC_SUCCESS; |
| 701 | __rxe_do_task(&qp->comp.task); | 692 | __rxe_do_task(&qp->comp.task); |
| 702 | rxe_drop_ref(qp); | 693 | rxe_put(qp); |
| 703 | return 0; | 694 | return 0; |
| 704 | } | 695 | } |
| 705 | payload = mtu; | 696 | payload = mtu; |
| 706 | } | 697 | } |
| 707 | 698 | ||
| 708 | skb = init_req_packet(qp, wqe, opcode, payload, &pkt); | 699 | pkt.rxe = rxe; |
| 700 | pkt.opcode = opcode; | ||
| 701 | pkt.qp = qp; | ||
| 702 | pkt.psn = qp->req.psn; | ||
| 703 | pkt.mask = rxe_opcode[opcode].mask; | ||
| 704 | pkt.wqe = wqe; | ||
| 705 | |||
| 706 | av = rxe_get_av(&pkt, &ah); | ||
| 707 | if (unlikely(!av)) { | ||
| 708 | pr_err("qp#%d Failed no address vector\n", qp_num(qp)); | ||
| 709 | wqe->status = IB_WC_LOC_QP_OP_ERR; | ||
| 710 | goto err_drop_ah; | ||
| 711 | } | ||
| 712 | |||
| 713 | skb = init_req_packet(qp, av, wqe, opcode, payload, &pkt); | ||
| 709 | if (unlikely(!skb)) { | 714 | if (unlikely(!skb)) { |
| 710 | pr_err("qp#%d Failed allocating skb\n", qp_num(qp)); | 715 | pr_err("qp#%d Failed allocating skb\n", qp_num(qp)); |
| 711 | wqe->status = IB_WC_LOC_QP_OP_ERR; | 716 | wqe->status = IB_WC_LOC_QP_OP_ERR; |
| 712 | goto err; | 717 | goto err_drop_ah; |
| 713 | } | 718 | } |
| 714 | 719 | ||
| 715 | ret = finish_packet(qp, wqe, &pkt, skb, payload); | 720 | ret = finish_packet(qp, av, wqe, &pkt, skb, payload); |
| 716 | if (unlikely(ret)) { | 721 | if (unlikely(ret)) { |
| 717 | pr_debug("qp#%d Error during finish packet\n", qp_num(qp)); | 722 | pr_debug("qp#%d Error during finish packet\n", qp_num(qp)); |
| 718 | if (ret == -EFAULT) | 723 | if (ret == -EFAULT) |
| @@ -720,9 +725,12 @@ next_wqe: · 1 unmodified line | |||
| 720 | else | 725 | else |
| 721 | wqe->status = IB_WC_LOC_QP_OP_ERR; | 726 | wqe->status = IB_WC_LOC_QP_OP_ERR; |
| 722 | kfree_skb(skb); | 727 | kfree_skb(skb); |
| 723 | goto err; | 728 | goto err_drop_ah; |
| 724 | } | 729 | } |
| 725 | 730 | ||
| 731 | if (ah) | ||
| 732 | rxe_put(ah); | ||
| 733 | |||
| 726 | /* | 734 | /* |
| 727 | * To prevent a race on wqe access between requester and completer, | 735 | * To prevent a race on wqe access between requester and completer, |
| 728 | * wqe members state and psn need to be set before calling | 736 | * wqe members state and psn need to be set before calling |
| @@ -747,15 +755,18 @@ next_wqe: · 18 unmodified lines | |||
| 747 | goto err; | 755 | goto err; |
| 748 | } | 756 | } |
| 749 | 757 | ||
| 750 | update_state(qp, wqe, &pkt, payload); | 758 | update_state(qp, wqe, &pkt); |
| 751 | 759 | ||
| 752 | goto next_wqe; | 760 | goto next_wqe; |
| 753 | 761 | ||
| 762 | err_drop_ah: | ||
| 763 | if (ah) | ||
| 764 | rxe_put(ah); | ||
| 754 | err: | 765 | err: |
| 755 | wqe->state = wqe_state_error; | 766 | wqe->state = wqe_state_error; |
| 756 | __rxe_do_task(&qp->comp.task); | 767 | __rxe_do_task(&qp->comp.task); |
| 757 | 768 | ||
| 758 | exit: | 769 | exit: |
| 759 | rxe_drop_ref(qp); | 770 | rxe_put(qp); |
| 760 | return -EAGAIN; | 771 | return -EAGAIN; |
| 761 | } | 772 | } |
| @@ -99,7 +99,7 @@ static inline enum resp_states get_req(struct rxe_qp *qp, · 98 unmodified lines | |||
| 99 | 99 | ||
| 100 | if (qp->resp.state == QP_STATE_ERROR) { | 100 | if (qp->resp.state == QP_STATE_ERROR) { |
| 101 | while ((skb = skb_dequeue(&qp->req_pkts))) { | 101 | while ((skb = skb_dequeue(&qp->req_pkts))) { |
| 102 | rxe_drop_ref(qp); | 102 | rxe_put(qp); |
| 103 | kfree_skb(skb); | 103 | kfree_skb(skb); |
| 104 | ib_device_put(qp->ibqp.device); | 104 | ib_device_put(qp->ibqp.device); |
| 105 | } | 105 | } |
| @@ -297,21 +297,22 @@ static enum resp_states get_srq_wqe(struct rxe_qp *qp) · 191 unmodified lines | |||
| 297 | struct ib_event ev; | 297 | struct ib_event ev; |
| 298 | unsigned int count; | 298 | unsigned int count; |
| 299 | size_t size; | 299 | size_t size; |
| 300 | unsigned long flags; | ||
| 300 | 301 | ||
| 301 | if (srq->error) | 302 | if (srq->error) |
| 302 | return RESPST_ERR_RNR; | 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 | wqe = queue_head(q, QUEUE_TYPE_FROM_CLIENT); | 307 | wqe = queue_head(q, QUEUE_TYPE_FROM_CLIENT); |
| 307 | if (!wqe) { | 308 | if (!wqe) { |
| 308 | spin_unlock_bh(&srq->rq.consumer_lock); | 309 | spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); |
| 309 | return RESPST_ERR_RNR; | 310 | return RESPST_ERR_RNR; |
| 310 | } | 311 | } |
| 311 | 312 | ||
| 312 | /* don't trust user space data */ | 313 | /* don't trust user space data */ |
| 313 | if (unlikely(wqe->dma.num_sge > srq->rq.max_sge)) { | 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 | pr_warn("%s: invalid num_sge in SRQ entry\n", __func__); | 316 | pr_warn("%s: invalid num_sge in SRQ entry\n", __func__); |
| 316 | return RESPST_ERR_MALFORMED_WQE; | 317 | return RESPST_ERR_MALFORMED_WQE; |
| 317 | } | 318 | } |
| @@ -327,11 +328,11 @@ static enum resp_states get_srq_wqe(struct rxe_qp *qp) · 9 unmodified lines | |||
| 327 | goto event; | 328 | goto event; |
| 328 | } | 329 | } |
| 329 | 330 | ||
| 330 | spin_unlock_bh(&srq->rq.consumer_lock); | 331 | spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); |
| 331 | return RESPST_CHK_LENGTH; | 332 | return RESPST_CHK_LENGTH; |
| 332 | 333 | ||
| 333 | event: | 334 | event: |
| 334 | spin_unlock_bh(&srq->rq.consumer_lock); | 335 | spin_unlock_irqrestore(&srq->rq.consumer_lock, flags); |
| 335 | ev.device = qp->ibqp.device; | 336 | ev.device = qp->ibqp.device; |
| 336 | ev.element.srq = qp->ibqp.srq; | 337 | ev.element.srq = qp->ibqp.srq; |
| 337 | ev.event = IB_EVENT_SRQ_LIMIT_REACHED; | 338 | ev.event = IB_EVENT_SRQ_LIMIT_REACHED; |
| @@ -463,8 +464,8 @@ static enum resp_states check_rkey(struct rxe_qp *qp, · 125 unmodified lines | |||
| 463 | if (mw->access & IB_ZERO_BASED) | 464 | if (mw->access & IB_ZERO_BASED) |
| 464 | qp->resp.offset = mw->addr; | 465 | qp->resp.offset = mw->addr; |
| 465 | 466 | ||
| 466 | rxe_drop_ref(mw); | 467 | rxe_put(mw); |
| 467 | rxe_add_ref(mr); | 468 | rxe_get(mr); |
| 468 | } else { | 469 | } else { |
| 469 | mr = lookup_mr(qp->pd, access, rkey, RXE_LOOKUP_REMOTE); | 470 | mr = lookup_mr(qp->pd, access, rkey, RXE_LOOKUP_REMOTE); |
| 470 | if (!mr) { | 471 | if (!mr) { |
| @@ -507,9 +508,9 @@ static enum resp_states check_rkey(struct rxe_qp *qp, · 36 unmodified lines | |||
| 507 | 508 | ||
| 508 | err: | 509 | err: |
| 509 | if (mr) | 510 | if (mr) |
| 510 | rxe_drop_ref(mr); | 511 | rxe_put(mr); |
| 511 | if (mw) | 512 | if (mw) |
| 512 | rxe_drop_ref(mw); | 513 | rxe_put(mw); |
| 513 | 514 | ||
| 514 | return state; | 515 | return state; |
| 515 | } | 516 | } |
| @@ -632,7 +633,7 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp, · 116 unmodified lines | |||
| 632 | if (ack->mask & RXE_ATMACK_MASK) | 633 | if (ack->mask & RXE_ATMACK_MASK) |
| 633 | atmack_set_orig(ack, qp->resp.atomic_orig); | 634 | atmack_set_orig(ack, qp->resp.atomic_orig); |
| 634 | 635 | ||
| 635 | err = rxe_prepare(ack, skb); | 636 | err = rxe_prepare(&qp->pri_av, ack, skb); |
| 636 | if (err) { | 637 | if (err) { |
| 637 | kfree_skb(skb); | 638 | kfree_skb(skb); |
| 638 | return NULL; | 639 | return NULL; |
| @@ -641,6 +642,78 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp, · 2 unmodified lines | |||
| 641 | return skb; | 642 | return skb; |
| 642 | } | 643 | } |
| 643 | 644 | ||
| 645 | static struct resp_res *rxe_prepare_read_res(struct rxe_qp *qp, | ||
| 646 | struct rxe_pkt_info *pkt) | ||
| 647 | { | ||
| 648 | struct resp_res *res; | ||
| 649 | u32 pkts; | ||
| 650 | |||
| 651 | res = &qp->resp.resources[qp->resp.res_head]; | ||
| 652 | rxe_advance_resp_resource(qp); | ||
| 653 | free_rd_atomic_resource(qp, res); | ||
| 654 | |||
| 655 | res->type = RXE_READ_MASK; | ||
| 656 | res->replay = 0; | ||
| 657 | res->read.va = qp->resp.va + qp->resp.offset; | ||
| 658 | res->read.va_org = qp->resp.va + qp->resp.offset; | ||
| 659 | res->read.resid = qp->resp.resid; | ||
| 660 | res->read.length = qp->resp.resid; | ||
| 661 | res->read.rkey = qp->resp.rkey; | ||
| 662 | |||
| 663 | pkts = max_t(u32, (reth_len(pkt) + qp->mtu - 1)/qp->mtu, 1); | ||
| 664 | res->first_psn = pkt->psn; | ||
| 665 | res->cur_psn = pkt->psn; | ||
| 666 | res->last_psn = (pkt->psn + pkts - 1) & BTH_PSN_MASK; | ||
| 667 | |||
| 668 | res->state = rdatm_res_state_new; | ||
| 669 | |||
| 670 | return res; | ||
| 671 | } | ||
| 672 | |||
| 673 | /** | ||
| 674 | * rxe_recheck_mr - revalidate MR from rkey and get a reference | ||
| 675 | * @qp: the qp | ||
| 676 | * @rkey: the rkey | ||
| 677 | * | ||
| 678 | * This code allows the MR to be invalidated or deregistered or | ||
| 679 | * the MW if one was used to be invalidated or deallocated. | ||
| 680 | * It is assumed that the access permissions if originally good | ||
| 681 | * are OK and the mappings to be unchanged. | ||
| 682 | * | ||
| 683 | * Return: mr on success else NULL | ||
| 684 | */ | ||
| 685 | static struct rxe_mr *rxe_recheck_mr(struct rxe_qp *qp, u32 rkey) | ||
| 686 | { | ||
| 687 | struct rxe_dev *rxe = to_rdev(qp->ibqp.device); | ||
| 688 | struct rxe_mr *mr; | ||
| 689 | struct rxe_mw *mw; | ||
| 690 | |||
| 691 | if (rkey_is_mw(rkey)) { | ||
| 692 | mw = rxe_pool_get_index(&rxe->mw_pool, rkey >> 8); | ||
| 693 | if (!mw || mw->rkey != rkey) | ||
| 694 | return NULL; | ||
| 695 | |||
| 696 | if (mw->state != RXE_MW_STATE_VALID) { | ||
| 697 | rxe_put(mw); | ||
| 698 | return NULL; | ||
| 699 | } | ||
| 700 | |||
| 701 | mr = mw->mr; | ||
| 702 | rxe_put(mw); | ||
| 703 | } else { | ||
| 704 | mr = rxe_pool_get_index(&rxe->mr_pool, rkey >> 8); | ||
| 705 | if (!mr || mr->rkey != rkey) | ||
| 706 | return NULL; | ||
| 707 | } | ||
| 708 | |||
| 709 | if (mr->state != RXE_MR_STATE_VALID) { | ||
| 710 | rxe_put(mr); | ||
| 711 | return NULL; | ||
| 712 | } | ||
| 713 | |||
| 714 | return mr; | ||
| 715 | } | ||
| 716 | |||
| 644 | /* RDMA read response. If res is not NULL, then we have a current RDMA request | 717 | /* RDMA read response. If res is not NULL, then we have a current RDMA request |
| 645 | * being processed or replayed. | 718 | * being processed or replayed. |
| 646 | */ | 719 | */ |
| @@ -655,53 +728,26 @@ static enum resp_states read_reply(struct rxe_qp *qp, · 8 unmodified lines | |||
| 655 | int opcode; | 728 | int opcode; |
| 656 | int err; | 729 | int err; |
| 657 | struct resp_res *res = qp->resp.res; | 730 | struct resp_res *res = qp->resp.res; |
| 731 | struct rxe_mr *mr; | ||
| 658 | 732 | ||
| 659 | if (!res) { | 733 | if (!res) { |
| 660 | /* This is the first time we process that request. Get a | 734 | res = rxe_prepare_read_res(qp, req_pkt); |
| 661 | * resource | 735 | qp->resp.res = res; |
| 662 | */ | ||
| 663 | res = &qp->resp.resources[qp->resp.res_head]; | ||
| 664 | |||
| 665 | free_rd_atomic_resource(qp, res); | ||
| 666 | rxe_advance_resp_resource(qp); | ||
| 667 | |||
| 668 | res->type = RXE_READ_MASK; | ||
| 669 | res->replay = 0; | ||
| 670 | |||
| 671 | res->read.va = qp->resp.va + | ||
| 672 | qp->resp.offset; | ||
| 673 | res->read.va_org = qp->resp.va + | ||
| 674 | qp->resp.offset; | ||
| 675 | |||
| 676 | res->first_psn = req_pkt->psn; | ||
| 677 | |||
| 678 | if (reth_len(req_pkt)) { | ||
| 679 | res->last_psn = (req_pkt->psn + | ||
| 680 | (reth_len(req_pkt) + mtu - 1) / | ||
| 681 | mtu - 1) & BTH_PSN_MASK; | ||
| 682 | } else { | ||
| 683 | res->last_psn = res->first_psn; | ||
| 684 | } | ||
| 685 | res->cur_psn = req_pkt->psn; | ||
| 686 | |||
| 687 | res->read.resid = qp->resp.resid; | ||
| 688 | res->read.length = qp->resp.resid; | ||
| 689 | res->read.rkey = qp->resp.rkey; | ||
| 690 | |||
| 691 | /* note res inherits the reference to mr from qp */ | ||
| 692 | res->read.mr = qp->resp.mr; | ||
| 693 | qp->resp.mr = NULL; | ||
| 694 | |||
| 695 | qp->resp.res = res; | ||
| 696 | res->state = rdatm_res_state_new; | ||
| 697 | } | 736 | } |
| 698 | 737 | ||
| 699 | if (res->state == rdatm_res_state_new) { | 738 | if (res->state == rdatm_res_state_new) { |
| 739 | mr = qp->resp.mr; | ||
| 740 | qp->resp.mr = NULL; | ||
| 741 | |||
| 700 | if (res->read.resid <= mtu) | 742 | if (res->read.resid <= mtu) |
| 701 | opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_ONLY; | 743 | opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_ONLY; |
| 702 | else | 744 | else |
| 703 | opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST; | 745 | opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST; |
| 704 | } else { | 746 | } else { |
| 747 | mr = rxe_recheck_mr(qp, res->read.rkey); | ||
| 748 | if (!mr) | ||
| 749 | return RESPST_ERR_RKEY_VIOLATION; | ||
| 750 | |||
| 705 | if (res->read.resid > mtu) | 751 | if (res->read.resid > mtu) |
| 706 | opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE; | 752 | opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE; |
| 707 | else | 753 | else |
| @@ -717,10 +763,12 @@ static enum resp_states read_reply(struct rxe_qp *qp, · 9 unmodified lines | |||
| 717 | if (!skb) | 763 | if (!skb) |
| 718 | return RESPST_ERR_RNR; | 764 | return RESPST_ERR_RNR; |
| 719 | 765 | ||
| 720 | err = rxe_mr_copy(res->read.mr, res->read.va, payload_addr(&ack_pkt), | 766 | err = rxe_mr_copy(mr, res->read.va, payload_addr(&ack_pkt), |
| 721 | payload, RXE_FROM_MR_OBJ); | 767 | payload, RXE_FROM_MR_OBJ); |
| 722 | if (err) | 768 | if (err) |
| 723 | pr_err("Failed copying memory\n"); | 769 | pr_err("Failed copying memory\n"); |
| 770 | if (mr) | ||
| 771 | rxe_put(mr); | ||
| 724 | 772 | ||
| 725 | if (bth_pad(&ack_pkt)) { | 773 | if (bth_pad(&ack_pkt)) { |
| 726 | u8 *pad = payload_addr(&ack_pkt) + payload; | 774 | u8 *pad = payload_addr(&ack_pkt) + payload; |
| @@ -814,6 +862,10 @@ static enum resp_states execute(struct rxe_qp *qp, struct rxe_pkt_info *pkt) · 87 unmodified lines | |||
| 814 | return RESPST_ERR_INVALIDATE_RKEY; | 862 | return RESPST_ERR_INVALIDATE_RKEY; |
| 815 | } | 863 | } |
| 816 | 864 | ||
| 865 | if (pkt->mask & RXE_END_MASK) | ||
| 866 | /* We successfully processed this new request. */ | ||
| 867 | qp->resp.msn++; | ||
| 868 | |||
| 817 | /* next expected psn, read handles this separately */ | 869 | /* next expected psn, read handles this separately */ |
| 818 | qp->resp.psn = (pkt->psn + 1) & BTH_PSN_MASK; | 870 | qp->resp.psn = (pkt->psn + 1) & BTH_PSN_MASK; |
| 819 | qp->resp.ack_psn = qp->resp.psn; | 871 | qp->resp.ack_psn = qp->resp.psn; |
| @@ -821,11 +873,9 @@ static enum resp_states execute(struct rxe_qp *qp, struct rxe_pkt_info *pkt) · 1 unmodified line | |||
| 821 | qp->resp.opcode = pkt->opcode; | 873 | qp->resp.opcode = pkt->opcode; |
| 822 | qp->resp.status = IB_WC_SUCCESS; | 874 | qp->resp.status = IB_WC_SUCCESS; |
| 823 | 875 | ||
| 824 | if (pkt->mask & RXE_COMP_MASK) { | 876 | if (pkt->mask & RXE_COMP_MASK) |
| 825 | /* We successfully processed this new request. */ | ||
| 826 | qp->resp.msn++; | ||
| 827 | return RESPST_COMPLETE; | 877 | return RESPST_COMPLETE; |
| 828 | } else if (qp_type(qp) == IB_QPT_RC) | 878 | else if (qp_type(qp) == IB_QPT_RC) |
| 829 | return RESPST_ACKNOWLEDGE; | 879 | return RESPST_ACKNOWLEDGE; |
| 830 | else | 880 | else |
| 831 | return RESPST_CLEANUP; | 881 | return RESPST_CLEANUP; |
| @@ -987,7 +1037,7 @@ static int send_atomic_ack(struct rxe_qp *qp, struct rxe_pkt_info *pkt, · 155 unmodified lines | |||
| 987 | rc = rxe_xmit_packet(qp, &ack_pkt, skb); | 1037 | rc = rxe_xmit_packet(qp, &ack_pkt, skb); |
| 988 | if (rc) { | 1038 | if (rc) { |
| 989 | pr_err_ratelimited("Failed sending ack\n"); | 1039 | pr_err_ratelimited("Failed sending ack\n"); |
| 990 | rxe_drop_ref(qp); | 1040 | rxe_put(qp); |
| 991 | } | 1041 | } |
| 992 | out: | 1042 | out: |
| 993 | return rc; | 1043 | return rc; |
| @@ -1016,13 +1066,13 @@ static enum resp_states cleanup(struct rxe_qp *qp, · 22 unmodified lines | |||
| 1016 | 1066 | ||
| 1017 | if (pkt) { | 1067 | if (pkt) { |
| 1018 | skb = skb_dequeue(&qp->req_pkts); | 1068 | skb = skb_dequeue(&qp->req_pkts); |
| 1019 | rxe_drop_ref(qp); | 1069 | rxe_put(qp); |
| 1020 | kfree_skb(skb); | 1070 | kfree_skb(skb); |
| 1021 | ib_device_put(qp->ibqp.device); | 1071 | ib_device_put(qp->ibqp.device); |
| 1022 | } | 1072 | } |
| 1023 | 1073 | ||
| 1024 | if (qp->resp.mr) { | 1074 | if (qp->resp.mr) { |
| 1025 | rxe_drop_ref(qp->resp.mr); | 1075 | rxe_put(qp->resp.mr); |
| 1026 | qp->resp.mr = NULL; | 1076 | qp->resp.mr = NULL; |
| 1027 | } | 1077 | } |
| 1028 | 1078 | ||
| @@ -1166,7 +1216,7 @@ static enum resp_states do_class_d1e_error(struct rxe_qp *qp) · 137 unmodified lines | |||
| 1166 | } | 1216 | } |
| 1167 | 1217 | ||
| 1168 | if (qp->resp.mr) { | 1218 | if (qp->resp.mr) { |
| 1169 | rxe_drop_ref(qp->resp.mr); | 1219 | rxe_put(qp->resp.mr); |
| 1170 | qp->resp.mr = NULL; | 1220 | qp->resp.mr = NULL; |
| 1171 | } | 1221 | } |
| 1172 | 1222 | ||
| @@ -1180,7 +1230,7 @@ static void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify) · 7 unmodified lines | |||
| 1180 | struct rxe_queue *q = qp->rq.queue; | 1230 | struct rxe_queue *q = qp->rq.queue; |
| 1181 | 1231 | ||
| 1182 | while ((skb = skb_dequeue(&qp->req_pkts))) { | 1232 | while ((skb = skb_dequeue(&qp->req_pkts))) { |
| 1183 | rxe_drop_ref(qp); | 1233 | rxe_put(qp); |
| 1184 | kfree_skb(skb); | 1234 | kfree_skb(skb); |
| 1185 | ib_device_put(qp->ibqp.device); | 1235 | ib_device_put(qp->ibqp.device); |
| 1186 | } | 1236 | } |
| @@ -1200,7 +1250,7 @@ int rxe_responder(void *arg) · 13 unmodified lines | |||
| 1200 | struct rxe_pkt_info *pkt = NULL; | 1250 | struct rxe_pkt_info *pkt = NULL; |
| 1201 | int ret = 0; | 1251 | int ret = 0; |
| 1202 | 1252 | ||
| 1203 | rxe_add_ref(qp); | 1253 | rxe_get(qp); |
| 1204 | 1254 | ||
| 1205 | qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED; | 1255 | qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED; |
| 1206 | 1256 | ||
| @@ -1387,6 +1437,6 @@ int rxe_responder(void *arg) · 180 unmodified lines | |||
| 1387 | exit: | 1437 | exit: |
| 1388 | ret = -EAGAIN; | 1438 | ret = -EAGAIN; |
| 1389 | done: | 1439 | done: |
| 1390 | rxe_drop_ref(qp); | 1440 | rxe_put(qp); |
| 1391 | return ret; | 1441 | return ret; |
| 1392 | } | 1442 | } |
| @@ -115,7 +115,7 @@ static void rxe_dealloc_ucontext(struct ib_ucontext *ibuc) · 114 unmodified lines | |||
| 115 | { | 115 | { |
| 116 | struct rxe_ucontext *uc = to_ruc(ibuc); | 116 | struct rxe_ucontext *uc = to_ruc(ibuc); |
| 117 | 117 | ||
| 118 | rxe_drop_ref(uc); | 118 | rxe_put(uc); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | static int rxe_port_immutable(struct ib_device *dev, u32 port_num, | 121 | static int rxe_port_immutable(struct ib_device *dev, u32 port_num, |
| @@ -149,7 +149,7 @@ static int rxe_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) · 27 unmodified lines | |||
| 149 | { | 149 | { |
| 150 | struct rxe_pd *pd = to_rpd(ibpd); | 150 | struct rxe_pd *pd = to_rpd(ibpd); |
| 151 | 151 | ||
| 152 | rxe_drop_ref(pd); | 152 | rxe_put(pd); |
| 153 | return 0; | 153 | return 0; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| @@ -181,7 +181,6 @@ static int rxe_create_ah(struct ib_ah *ibah, · 25 unmodified lines | |||
| 181 | return err; | 181 | return err; |
| 182 | 182 | ||
| 183 | /* create index > 0 */ | 183 | /* create index > 0 */ |
| 184 | rxe_add_index(ah); | ||
| 185 | ah->ah_num = ah->elem.index; | 184 | ah->ah_num = ah->elem.index; |
| 186 | 185 | ||
| 187 | if (uresp) { | 186 | if (uresp) { |
| @@ -189,8 +188,7 @@ static int rxe_create_ah(struct ib_ah *ibah, · 1 unmodified line | |||
| 189 | err = copy_to_user(&uresp->ah_num, &ah->ah_num, | 188 | err = copy_to_user(&uresp->ah_num, &ah->ah_num, |
| 190 | sizeof(uresp->ah_num)); | 189 | sizeof(uresp->ah_num)); |
| 191 | if (err) { | 190 | if (err) { |
| 192 | rxe_drop_index(ah); | 191 | rxe_put(ah); |
| 193 | rxe_drop_ref(ah); | ||
| 194 | return -EFAULT; | 192 | return -EFAULT; |
| 195 | } | 193 | } |
| 196 | } else if (ah->is_user) { | 194 | } else if (ah->is_user) { |
| @@ -230,8 +228,7 @@ static int rxe_destroy_ah(struct ib_ah *ibah, u32 flags) · 33 unmodified lines | |||
| 230 | { | 228 | { |
| 231 | struct rxe_ah *ah = to_rah(ibah); | 229 | struct rxe_ah *ah = to_rah(ibah); |
| 232 | 230 | ||
| 233 | rxe_drop_index(ah); | 231 | rxe_put(ah); |
| 234 | rxe_drop_ref(ah); | ||
| 235 | return 0; | 232 | return 0; |
| 236 | } | 233 | } |
| 237 | 234 | ||
| @@ -306,7 +303,7 @@ static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init, · 68 unmodified lines | |||
| 306 | if (err) | 303 | if (err) |
| 307 | goto err1; | 304 | goto err1; |
| 308 | 305 | ||
| 309 | rxe_add_ref(pd); | 306 | rxe_get(pd); |
| 310 | srq->pd = pd; | 307 | srq->pd = pd; |
| 311 | 308 | ||
| 312 | err = rxe_srq_from_init(rxe, srq, init, udata, uresp); | 309 | err = rxe_srq_from_init(rxe, srq, init, udata, uresp); |
| @@ -316,8 +313,8 @@ static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init, · 3 unmodified lines | |||
| 316 | return 0; | 313 | return 0; |
| 317 | 314 | ||
| 318 | err2: | 315 | err2: |
| 319 | rxe_drop_ref(pd); | 316 | rxe_put(pd); |
| 320 | rxe_drop_ref(srq); | 317 | rxe_put(srq); |
| 321 | err1: | 318 | err1: |
| 322 | return err; | 319 | return err; |
| 323 | } | 320 | } |
| @@ -374,8 +371,8 @@ static int rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) · 50 unmodified lines | |||
| 374 | if (srq->rq.queue) | 371 | if (srq->rq.queue) |
| 375 | rxe_queue_cleanup(srq->rq.queue); | 372 | rxe_queue_cleanup(srq->rq.queue); |
| 376 | 373 | ||
| 377 | rxe_drop_ref(srq->pd); | 374 | rxe_put(srq->pd); |
| 378 | rxe_drop_ref(srq); | 375 | rxe_put(srq); |
| 379 | return 0; | 376 | return 0; |
| 380 | } | 377 | } |
| 381 | 378 | ||
| @@ -384,8 +381,9 @@ static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, · 2 unmodified lines | |||
| 384 | { | 381 | { |
| 385 | int err = 0; | 382 | int err = 0; |
| 386 | struct rxe_srq *srq = to_rsrq(ibsrq); | 383 | struct rxe_srq *srq = to_rsrq(ibsrq); |
| 384 | unsigned long flags; | ||
| 387 | 385 | ||
| 388 | spin_lock_bh(&srq->rq.producer_lock); | 386 | spin_lock_irqsave(&srq->rq.producer_lock, flags); |
| 389 | 387 | ||
| 390 | while (wr) { | 388 | while (wr) { |
| 391 | err = post_one_recv(&srq->rq, wr); | 389 | err = post_one_recv(&srq->rq, wr); |
| @@ -394,7 +392,7 @@ static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, · 2 unmodified lines | |||
| 394 | wr = wr->next; | 392 | wr = wr->next; |
| 395 | } | 393 | } |
| 396 | 394 | ||
| 397 | spin_unlock_bh(&srq->rq.producer_lock); | 395 | spin_unlock_irqrestore(&srq->rq.producer_lock, flags); |
| 398 | 396 | ||
| 399 | if (err) | 397 | if (err) |
| 400 | *bad_wr = wr; | 398 | *bad_wr = wr; |
| @@ -437,7 +435,6 @@ static int rxe_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init, · 36 unmodified lines | |||
| 437 | if (err) | 435 | if (err) |
| 438 | return err; | 436 | return err; |
| 439 | 437 | ||
| 440 | rxe_add_index(qp); | ||
| 441 | err = rxe_qp_from_init(rxe, qp, pd, init, uresp, ibqp->pd, udata); | 438 | err = rxe_qp_from_init(rxe, qp, pd, init, uresp, ibqp->pd, udata); |
| 442 | if (err) | 439 | if (err) |
| 443 | goto qp_init; | 440 | goto qp_init; |
| @@ -445,8 +442,7 @@ static int rxe_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init, · 1 unmodified line | |||
| 445 | return 0; | 442 | return 0; |
| 446 | 443 | ||
| 447 | qp_init: | 444 | qp_init: |
| 448 | rxe_drop_index(qp); | 445 | rxe_put(qp); |
| 449 | rxe_drop_ref(qp); | ||
| 450 | return err; | 446 | return err; |
| 451 | } | 447 | } |
| 452 | 448 | ||
| @@ -493,10 +489,14 @@ static int rxe_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 40 unmodified lines | |||
| 493 | static int rxe_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) | 489 | static int rxe_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) |
| 494 | { | 490 | { |
| 495 | struct rxe_qp *qp = to_rqp(ibqp); | 491 | struct rxe_qp *qp = to_rqp(ibqp); |
| 492 | int ret; | ||
| 493 | |||
| 494 | ret = rxe_qp_chk_destroy(qp); | ||
| 495 | if (ret) | ||
| 496 | return ret; | ||
| 496 | 497 | ||
| 497 | rxe_qp_destroy(qp); | 498 | rxe_qp_destroy(qp); |
| 498 | rxe_drop_index(qp); | 499 | rxe_put(qp); |
| 499 | rxe_drop_ref(qp); | ||
| 500 | return 0; | 500 | return 0; |
| 501 | } | 501 | } |
| 502 | 502 | ||
| @@ -638,18 +638,19 @@ static int post_one_send(struct rxe_qp *qp, const struct ib_send_wr *ibwr, · 135 unmodified lines | |||
| 638 | int err; | 638 | int err; |
| 639 | struct rxe_sq *sq = &qp->sq; | 639 | struct rxe_sq *sq = &qp->sq; |
| 640 | struct rxe_send_wqe *send_wqe; | 640 | struct rxe_send_wqe *send_wqe; |
| 641 | unsigned long flags; | ||
| 641 | int full; | 642 | int full; |
| 642 | 643 | ||
| 643 | err = validate_send_wr(qp, ibwr, mask, length); | 644 | err = validate_send_wr(qp, ibwr, mask, length); |
| 644 | if (err) | 645 | if (err) |
| 645 | return err; | 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 | full = queue_full(sq->queue, QUEUE_TYPE_TO_DRIVER); | 650 | full = queue_full(sq->queue, QUEUE_TYPE_TO_DRIVER); |
| 650 | 651 | ||
| 651 | if (unlikely(full)) { | 652 | if (unlikely(full)) { |
| 652 | spin_unlock_bh(&qp->sq.sq_lock); | 653 | spin_unlock_irqrestore(&qp->sq.sq_lock, flags); |
| 653 | return -ENOMEM; | 654 | return -ENOMEM; |
| 654 | } | 655 | } |
| 655 | 656 | ||
| @@ -658,7 +659,7 @@ static int post_one_send(struct rxe_qp *qp, const struct ib_send_wr *ibwr, · 2 unmodified lines | |||
| 658 | 659 | ||
| 659 | queue_advance_producer(sq->queue, QUEUE_TYPE_TO_DRIVER); | 660 | queue_advance_producer(sq->queue, QUEUE_TYPE_TO_DRIVER); |
| 660 | 661 | ||
| 661 | spin_unlock_bh(&qp->sq.sq_lock); | 662 | spin_unlock_irqrestore(&qp->sq.sq_lock, flags); |
| 662 | 663 | ||
| 663 | return 0; | 664 | return 0; |
| 664 | } | 665 | } |
| @@ -738,6 +739,7 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, · 73 unmodified lines | |||
| 738 | int err = 0; | 739 | int err = 0; |
| 739 | struct rxe_qp *qp = to_rqp(ibqp); | 740 | struct rxe_qp *qp = to_rqp(ibqp); |
| 740 | struct rxe_rq *rq = &qp->rq; | 741 | struct rxe_rq *rq = &qp->rq; |
| 742 | unsigned long flags; | ||
| 741 | 743 | ||
| 742 | if (unlikely((qp_state(qp) < IB_QPS_INIT) || !qp->valid)) { | 744 | if (unlikely((qp_state(qp) < IB_QPS_INIT) || !qp->valid)) { |
| 743 | *bad_wr = wr; | 745 | *bad_wr = wr; |
| @@ -751,7 +753,7 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, · 7 unmodified lines | |||
| 751 | goto err1; | 753 | goto err1; |
| 752 | } | 754 | } |
| 753 | 755 | ||
| 754 | spin_lock_bh(&rq->producer_lock); | 756 | spin_lock_irqsave(&rq->producer_lock, flags); |
| 755 | 757 | ||
| 756 | while (wr) { | 758 | while (wr) { |
| 757 | err = post_one_recv(rq, wr); | 759 | err = post_one_recv(rq, wr); |
| @@ -762,7 +764,7 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, · 4 unmodified lines | |||
| 762 | wr = wr->next; | 764 | wr = wr->next; |
| 763 | } | 765 | } |
| 764 | 766 | ||
| 765 | spin_unlock_bh(&rq->producer_lock); | 767 | spin_unlock_irqrestore(&rq->producer_lock, flags); |
| 766 | 768 | ||
| 767 | if (qp->resp.state == QP_STATE_ERROR) | 769 | if (qp->resp.state == QP_STATE_ERROR) |
| 768 | rxe_run_task(&qp->resp.task, 1); | 770 | rxe_run_task(&qp->resp.task, 1); |
| @@ -807,7 +809,7 @@ static int rxe_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) · 38 unmodified lines | |||
| 807 | 809 | ||
| 808 | rxe_cq_disable(cq); | 810 | rxe_cq_disable(cq); |
| 809 | 811 | ||
| 810 | rxe_drop_ref(cq); | 812 | rxe_put(cq); |
| 811 | return 0; | 813 | return 0; |
| 812 | } | 814 | } |
| 813 | 815 | ||
| @@ -843,8 +845,9 @@ static int rxe_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) · 29 unmodified lines | |||
| 843 | int i; | 845 | int i; |
| 844 | struct rxe_cq *cq = to_rcq(ibcq); | 846 | struct rxe_cq *cq = to_rcq(ibcq); |
| 845 | struct rxe_cqe *cqe; | 847 | struct rxe_cqe *cqe; |
| 848 | unsigned long flags; | ||
| 846 | 849 | ||
| 847 | spin_lock_bh(&cq->cq_lock); | 850 | spin_lock_irqsave(&cq->cq_lock, flags); |
| 848 | for (i = 0; i < num_entries; i++) { | 851 | for (i = 0; i < num_entries; i++) { |
| 849 | cqe = queue_head(cq->queue, QUEUE_TYPE_FROM_DRIVER); | 852 | cqe = queue_head(cq->queue, QUEUE_TYPE_FROM_DRIVER); |
| 850 | if (!cqe) | 853 | if (!cqe) |
| @@ -853,7 +856,7 @@ static int rxe_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) · 2 unmodified lines | |||
| 853 | memcpy(wc++, &cqe->ibwc, sizeof(*wc)); | 856 | memcpy(wc++, &cqe->ibwc, sizeof(*wc)); |
| 854 | queue_advance_consumer(cq->queue, QUEUE_TYPE_FROM_DRIVER); | 857 | queue_advance_consumer(cq->queue, QUEUE_TYPE_FROM_DRIVER); |
| 855 | } | 858 | } |
| 856 | spin_unlock_bh(&cq->cq_lock); | 859 | spin_unlock_irqrestore(&cq->cq_lock, flags); |
| 857 | 860 | ||
| 858 | return i; | 861 | return i; |
| 859 | } | 862 | } |
| @@ -873,8 +876,9 @@ static int rxe_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) · 13 unmodified lines | |||
| 873 | struct rxe_cq *cq = to_rcq(ibcq); | 876 | struct rxe_cq *cq = to_rcq(ibcq); |
| 874 | int ret = 0; | 877 | int ret = 0; |
| 875 | int empty; | 878 | int empty; |
| 879 | unsigned long irq_flags; | ||
| 876 | 880 | ||
| 877 | spin_lock_bh(&cq->cq_lock); | 881 | spin_lock_irqsave(&cq->cq_lock, irq_flags); |
| 878 | if (cq->notify != IB_CQ_NEXT_COMP) | 882 | if (cq->notify != IB_CQ_NEXT_COMP) |
| 879 | cq->notify = flags & IB_CQ_SOLICITED_MASK; | 883 | cq->notify = flags & IB_CQ_SOLICITED_MASK; |
| 880 | 884 | ||
| @@ -883,7 +887,7 @@ static int rxe_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) · 2 unmodified lines | |||
| 883 | if ((flags & IB_CQ_REPORT_MISSED_EVENTS) && !empty) | 887 | if ((flags & IB_CQ_REPORT_MISSED_EVENTS) && !empty) |
| 884 | ret = 1; | 888 | ret = 1; |
| 885 | 889 | ||
| 886 | spin_unlock_bh(&cq->cq_lock); | 890 | spin_unlock_irqrestore(&cq->cq_lock, irq_flags); |
| 887 | 891 | ||
| 888 | return ret; | 892 | return ret; |
| 889 | } | 893 | } |
| @@ -898,8 +902,7 @@ static struct ib_mr *rxe_get_dma_mr(struct ib_pd *ibpd, int access) · 8 unmodified lines | |||
| 898 | if (!mr) | 902 | if (!mr) |
| 899 | return ERR_PTR(-ENOMEM); | 903 | return ERR_PTR(-ENOMEM); |
| 900 | 904 | ||
| 901 | rxe_add_index(mr); | 905 | rxe_get(pd); |
| 902 | rxe_add_ref(pd); | ||
| 903 | rxe_mr_init_dma(pd, access, mr); | 906 | rxe_mr_init_dma(pd, access, mr); |
| 904 | 907 | ||
| 905 | return &mr->ibmr; | 908 | return &mr->ibmr; |
| @@ -922,9 +925,8 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, · 16 unmodified lines | |||
| 922 | goto err2; | 925 | goto err2; |
| 923 | } | 926 | } |
| 924 | 927 | ||
| 925 | rxe_add_index(mr); | ||
| 926 | 928 | ||
| 927 | rxe_add_ref(pd); | 929 | rxe_get(pd); |
| 928 | 930 | ||
| 929 | err = rxe_mr_init_user(pd, start, length, iova, access, mr); | 931 | err = rxe_mr_init_user(pd, start, length, iova, access, mr); |
| 930 | if (err) | 932 | if (err) |
| @@ -933,9 +935,8 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, · 2 unmodified lines | |||
| 933 | return &mr->ibmr; | 935 | return &mr->ibmr; |
| 934 | 936 | ||
| 935 | err3: | 937 | err3: |
| 936 | rxe_drop_ref(pd); | 938 | rxe_put(pd); |
| 937 | rxe_drop_index(mr); | 939 | rxe_put(mr); |
| 938 | rxe_drop_ref(mr); | ||
| 939 | err2: | 940 | err2: |
| 940 | return ERR_PTR(err); | 941 | return ERR_PTR(err); |
| 941 | } | 942 | } |
| @@ -957,9 +958,7 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type, · 15 unmodified lines | |||
| 957 | goto err1; | 958 | goto err1; |
| 958 | } | 959 | } |
| 959 | 960 | ||
| 960 | rxe_add_index(mr); | 961 | rxe_get(pd); |
| 961 | |||
| 962 | rxe_add_ref(pd); | ||
| 963 | 962 | ||
| 964 | err = rxe_mr_init_fast(pd, max_num_sg, mr); | 963 | err = rxe_mr_init_fast(pd, max_num_sg, mr); |
| 965 | if (err) | 964 | if (err) |
| @@ -968,9 +967,8 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type, · 2 unmodified lines | |||
| 968 | return &mr->ibmr; | 967 | return &mr->ibmr; |
| 969 | 968 | ||
| 970 | err2: | 969 | err2: |
| 971 | rxe_drop_ref(pd); | 970 | rxe_put(pd); |
| 972 | rxe_drop_index(mr); | 971 | rxe_put(mr); |
| 973 | rxe_drop_ref(mr); | ||
| 974 | err1: | 972 | err1: |
| 975 | return ERR_PTR(err); | 973 | return ERR_PTR(err); |
| 976 | } | 974 | } |
| @@ -999,32 +997,6 @@ static int rxe_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, · 22 unmodified lines | |||
| 999 | return n; | 997 | return n; |
| 1000 | } | 998 | } |
| 1001 | 999 | ||
| 1002 | static int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) | ||
| 1003 | { | ||
| 1004 | int err; | ||
| 1005 | struct rxe_dev *rxe = to_rdev(ibqp->device); | ||
| 1006 | struct rxe_qp *qp = to_rqp(ibqp); | ||
| 1007 | struct rxe_mc_grp *grp; | ||
| 1008 | |||
| 1009 | /* takes a ref on grp if successful */ | ||
| 1010 | err = rxe_mcast_get_grp(rxe, mgid, &grp); | ||
| 1011 | if (err) | ||
| 1012 | return err; | ||
| 1013 | |||
| 1014 | err = rxe_mcast_add_grp_elem(rxe, qp, grp); | ||
| 1015 | |||
| 1016 | rxe_drop_ref(grp); | ||
| 1017 | return err; | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | static int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) | ||
| 1021 | { | ||
| 1022 | struct rxe_dev *rxe = to_rdev(ibqp->device); | ||
| 1023 | struct rxe_qp *qp = to_rqp(ibqp); | ||
| 1024 | |||
| 1025 | return rxe_mcast_drop_grp_elem(rxe, qp, mgid); | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | static ssize_t parent_show(struct device *device, | 1000 | static ssize_t parent_show(struct device *device, |
| 1029 | struct device_attribute *attr, char *buf) | 1001 | struct device_attribute *attr, char *buf) |
| 1030 | { | 1002 | { |
| @@ -157,7 +157,6 @@ struct resp_res { · 156 unmodified lines | |||
| 157 | struct sk_buff *skb; | 157 | struct sk_buff *skb; |
| 158 | } atomic; | 158 | } atomic; |
| 159 | struct { | 159 | struct { |
| 160 | struct rxe_mr *mr; | ||
| 161 | u64 va_org; | 160 | u64 va_org; |
| 162 | u32 rkey; | 161 | u32 rkey; |
| 163 | u32 length; | 162 | u32 length; |
| @@ -232,9 +231,7 @@ struct rxe_qp { · 68 unmodified lines | |||
| 232 | struct rxe_av pri_av; | 231 | struct rxe_av pri_av; |
| 233 | struct rxe_av alt_av; | 232 | struct rxe_av alt_av; |
| 234 | 233 | ||
| 235 | /* list of mcast groups qp has joined (for cleanup) */ | 234 | atomic_t mcg_num; |
| 236 | struct list_head grp_list; | ||
| 237 | spinlock_t grp_lock; /* guard grp_list */ | ||
| 238 | 235 | ||
| 239 | struct sk_buff_head req_pkts; | 236 | struct sk_buff_head req_pkts; |
| 240 | struct sk_buff_head resp_pkts; | 237 | struct sk_buff_head resp_pkts; |
| @@ -353,23 +350,20 @@ struct rxe_mw { · 112 unmodified lines | |||
| 353 | u64 length; | 350 | u64 length; |
| 354 | }; | 351 | }; |
| 355 | 352 | ||
| 356 | struct rxe_mc_grp { | 353 | struct rxe_mcg { |
| 357 | struct rxe_pool_elem elem; | 354 | struct rb_node node; |
| 358 | spinlock_t mcg_lock; /* guard group */ | 355 | struct kref ref_cnt; |
| 359 | struct rxe_dev *rxe; | 356 | struct rxe_dev *rxe; |
| 360 | struct list_head qp_list; | 357 | struct list_head qp_list; |
| 361 | union ib_gid mgid; | 358 | union ib_gid mgid; |
| 362 | int num_qp; | 359 | atomic_t qp_num; |
| 363 | u32 qkey; | 360 | u32 qkey; |
| 364 | u16 pkey; | 361 | u16 pkey; |
| 365 | }; | 362 | }; |
| 366 | 363 | ||
| 367 | struct rxe_mc_elem { | 364 | struct rxe_mca { |
| 368 | struct rxe_pool_elem elem; | ||
| 369 | struct list_head qp_list; | 365 | struct list_head qp_list; |
| 370 | struct list_head grp_list; | ||
| 371 | struct rxe_qp *qp; | 366 | struct rxe_qp *qp; |
| 372 | struct rxe_mc_grp *grp; | ||
| 373 | }; | 367 | }; |
| 374 | 368 | ||
| 375 | struct rxe_port { | 369 | struct rxe_port { |
| @@ -401,7 +395,12 @@ struct rxe_dev { · 25 unmodified lines | |||
| 401 | struct rxe_pool mr_pool; | 395 | struct rxe_pool mr_pool; |
| 402 | struct rxe_pool mw_pool; | 396 | struct rxe_pool mw_pool; |
| 403 | struct rxe_pool mc_grp_pool; | 397 | struct rxe_pool mc_grp_pool; |
| 404 | struct rxe_pool mc_elem_pool; | 398 | |
| 399 | /* multicast support */ | ||
| 400 | spinlock_t mcg_lock; | ||
| 401 | struct rb_root mcg_tree; | ||
| 402 | atomic_t mcg_num; | ||
| 403 | atomic_t mcg_attach; | ||
| 405 | 404 | ||
| 406 | spinlock_t pending_lock; /* guard pending_mmaps */ | 405 | spinlock_t pending_lock; /* guard pending_mmaps */ |
| 407 | struct list_head pending_mmaps; | 406 | struct list_head pending_mmaps; |
| @@ -482,6 +481,4 @@ static inline struct rxe_pd *rxe_mw_pd(struct rxe_mw *mw) · 74 unmodified lines | |||
| 482 | 481 | ||
| 483 | int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name); | 482 | int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name); |
| 484 | 483 | ||
| 485 | void rxe_mc_cleanup(struct rxe_pool_elem *elem); | ||
| 486 | |||
| 487 | #endif /* RXE_VERBS_H */ | 484 | #endif /* RXE_VERBS_H */ |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | 32 | ||
| 33 | #include <linux/netdevice.h> | 33 | #include <linux/netdevice.h> |
| 34 | #include <linux/if_arp.h> /* For ARPHRD_xxx */ | 34 | #include <linux/if_arp.h> /* For ARPHRD_xxx */ |
| 35 | #include <linux/module.h> | ||
| 36 | #include <net/rtnetlink.h> | 35 | #include <net/rtnetlink.h> |
| 37 | #include "ipoib.h" | 36 | #include "ipoib.h" |
| 38 | 37 | ||
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | * SOFTWARE. | 30 | * SOFTWARE. |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/sched/signal.h> | 33 | #include <linux/sched/signal.h> |
| 35 | 34 | ||
| 36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| @@ -203,12 +203,12 @@ struct iser_reg_resources; · 202 unmodified lines | |||
| 203 | * | 203 | * |
| 204 | * @sge: memory region sg element | 204 | * @sge: memory region sg element |
| 205 | * @rkey: memory region remote key | 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 | struct iser_mem_reg { | 208 | struct iser_mem_reg { |
| 209 | struct ib_sge sge; | 209 | struct ib_sge sge; |
| 210 | u32 rkey; | 210 | u32 rkey; |
| 211 | void *mem_h; | 211 | struct iser_fr_desc *desc; |
| 212 | }; | 212 | }; |
| 213 | 213 | ||
| 214 | enum iser_desc_type { | 214 | enum iser_desc_type { |
| @@ -531,13 +531,12 @@ int iser_post_recvm(struct iser_conn *iser_conn, · 316 unmodified lines | |||
| 531 | int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc); | 531 | int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc); |
| 532 | 532 | ||
| 533 | int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, | 533 | int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, |
| 534 | struct iser_data_buf *data, | ||
| 535 | enum iser_data_dir iser_dir, | 534 | enum iser_data_dir iser_dir, |
| 536 | enum dma_data_direction dma_dir); | 535 | enum dma_data_direction dma_dir); |
| 537 | 536 | ||
| 538 | void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, | 537 | void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, |
| 539 | struct iser_data_buf *data, | 538 | enum iser_data_dir iser_dir, |
| 540 | enum dma_data_direction dir); | 539 | enum dma_data_direction dma_dir); |
| 541 | 540 | ||
| 542 | int iser_initialize_task_headers(struct iscsi_task *task, | 541 | int iser_initialize_task_headers(struct iscsi_task *task, |
| 543 | struct iser_tx_desc *tx_desc); | 542 | struct iser_tx_desc *tx_desc); |
| @@ -52,30 +52,17 @@ static int iser_prepare_read_cmd(struct iscsi_task *task) · 51 unmodified lines | |||
| 52 | struct iser_mem_reg *mem_reg; | 52 | struct iser_mem_reg *mem_reg; |
| 53 | int err; | 53 | int err; |
| 54 | struct iser_ctrl *hdr = &iser_task->desc.iser_header; | 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 | err = iser_dma_map_task_data(iser_task, | 56 | err = iser_dma_map_task_data(iser_task, |
| 58 | buf_in, | ||
| 59 | ISER_DIR_IN, | 57 | ISER_DIR_IN, |
| 60 | DMA_FROM_DEVICE); | 58 | DMA_FROM_DEVICE); |
| 61 | if (err) | 59 | if (err) |
| 62 | return err; | 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 | err = iser_reg_mem_fastreg(iser_task, ISER_DIR_IN, false); | 62 | err = iser_reg_mem_fastreg(iser_task, ISER_DIR_IN, false); |
| 76 | if (err) { | 63 | if (err) { |
| 77 | iser_err("Failed to set up Data-IN RDMA\n"); | 64 | iser_err("Failed to set up Data-IN RDMA\n"); |
| 78 | return err; | 65 | goto out_err; |
| 79 | } | 66 | } |
| 80 | mem_reg = &iser_task->rdma_reg[ISER_DIR_IN]; | 67 | mem_reg = &iser_task->rdma_reg[ISER_DIR_IN]; |
| 81 | 68 | ||
| @@ -88,6 +75,10 @@ static int iser_prepare_read_cmd(struct iscsi_task *task) · 6 unmodified lines | |||
| 88 | (unsigned long long)mem_reg->sge.addr); | 75 | (unsigned long long)mem_reg->sge.addr); |
| 89 | 76 | ||
| 90 | return 0; | 77 | return 0; |
| 78 | |||
| 79 | out_err: | ||
| 80 | iser_dma_unmap_task_data(iser_task, ISER_DIR_IN, DMA_FROM_DEVICE); | ||
| 81 | return err; | ||
| 91 | } | 82 | } |
| 92 | 83 | ||
| 93 | /* Register user buffer memory and initialize passive rdma | 84 | /* Register user buffer memory and initialize passive rdma |
| @@ -106,28 +97,16 @@ static int iser_prepare_write_cmd(struct iscsi_task *task, unsigned int imm_sz, · 12 unmodified lines | |||
| 106 | struct ib_sge *tx_dsg = &iser_task->desc.tx_sg[1]; | 97 | struct ib_sge *tx_dsg = &iser_task->desc.tx_sg[1]; |
| 107 | 98 | ||
| 108 | err = iser_dma_map_task_data(iser_task, | 99 | err = iser_dma_map_task_data(iser_task, |
| 109 | buf_out, | ||
| 110 | ISER_DIR_OUT, | 100 | ISER_DIR_OUT, |
| 111 | DMA_TO_DEVICE); | 101 | DMA_TO_DEVICE); |
| 112 | if (err) | 102 | if (err) |
| 113 | return err; | 103 | return err; |
| 114 | 104 | ||
| 115 | if (scsi_prot_sg_count(iser_task->sc)) { | ||
| 116 | struct iser_data_buf *pbuf_out = &iser_task->prot[ISER_DIR_OUT]; | ||
| 117 | |||
| 118 | err = iser_dma_map_task_data(iser_task, | ||
| 119 | pbuf_out, | ||
| 120 | ISER_DIR_OUT, | ||
| 121 | DMA_TO_DEVICE); | ||
| 122 | if (err) | ||
| 123 | return err; | ||
| 124 | } | ||
| 125 | |||
| 126 | err = iser_reg_mem_fastreg(iser_task, ISER_DIR_OUT, | 105 | err = iser_reg_mem_fastreg(iser_task, ISER_DIR_OUT, |
| 127 | buf_out->data_len == imm_sz); | 106 | buf_out->data_len == imm_sz); |
| 128 | if (err != 0) { | 107 | if (err) { |
| 129 | iser_err("Failed to register write cmd RDMA mem\n"); | 108 | iser_err("Failed to register write cmd RDMA mem\n"); |
| 130 | return err; | 109 | goto out_err; |
| 131 | } | 110 | } |
| 132 | 111 | ||
| 133 | mem_reg = &iser_task->rdma_reg[ISER_DIR_OUT]; | 112 | mem_reg = &iser_task->rdma_reg[ISER_DIR_OUT]; |
| @@ -154,6 +133,10 @@ static int iser_prepare_write_cmd(struct iscsi_task *task, unsigned int imm_sz, · 20 unmodified lines | |||
| 154 | } | 133 | } |
| 155 | 134 | ||
| 156 | return 0; | 135 | return 0; |
| 136 | |||
| 137 | out_err: | ||
| 138 | iser_dma_unmap_task_data(iser_task, ISER_DIR_OUT, DMA_TO_DEVICE); | ||
| 139 | return err; | ||
| 157 | } | 140 | } |
| 158 | 141 | ||
| 159 | /* creates a new tx descriptor and adds header regd buffer */ | 142 | /* creates a new tx descriptor and adds header regd buffer */ |
| @@ -619,13 +602,13 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc, · 459 unmodified lines | |||
| 619 | struct iser_fr_desc *desc; | 602 | struct iser_fr_desc *desc; |
| 620 | 603 | ||
| 621 | if (iser_task->dir[ISER_DIR_IN]) { | 604 | if (iser_task->dir[ISER_DIR_IN]) { |
| 622 | desc = iser_task->rdma_reg[ISER_DIR_IN].mem_h; | 605 | desc = iser_task->rdma_reg[ISER_DIR_IN].desc; |
| 623 | if (unlikely(iser_inv_desc(desc, rkey))) | 606 | if (unlikely(iser_inv_desc(desc, rkey))) |
| 624 | return -EINVAL; | 607 | return -EINVAL; |
| 625 | } | 608 | } |
| 626 | 609 | ||
| 627 | if (iser_task->dir[ISER_DIR_OUT]) { | 610 | if (iser_task->dir[ISER_DIR_OUT]) { |
| 628 | desc = iser_task->rdma_reg[ISER_DIR_OUT].mem_h; | 611 | desc = iser_task->rdma_reg[ISER_DIR_OUT].desc; |
| 629 | if (unlikely(iser_inv_desc(desc, rkey))) | 612 | if (unlikely(iser_inv_desc(desc, rkey))) |
| 630 | return -EINVAL; | 613 | return -EINVAL; |
| 631 | } | 614 | } |
| @@ -740,27 +723,16 @@ void iser_task_rdma_init(struct iscsi_iser_task *iser_task) · 108 unmodified lines | |||
| 740 | 723 | ||
| 741 | void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task) | 724 | void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task) |
| 742 | { | 725 | { |
| 743 | int prot_count = scsi_prot_sg_count(iser_task->sc); | ||
| 744 | 726 | ||
| 745 | if (iser_task->dir[ISER_DIR_IN]) { | 727 | if (iser_task->dir[ISER_DIR_IN]) { |
| 746 | iser_unreg_mem_fastreg(iser_task, ISER_DIR_IN); | 728 | iser_unreg_mem_fastreg(iser_task, ISER_DIR_IN); |
| 747 | iser_dma_unmap_task_data(iser_task, | 729 | iser_dma_unmap_task_data(iser_task, ISER_DIR_IN, |
| 748 | &iser_task->data[ISER_DIR_IN], | ||
| 749 | DMA_FROM_DEVICE); | 730 | DMA_FROM_DEVICE); |
| 750 | if (prot_count) | ||
| 751 | iser_dma_unmap_task_data(iser_task, | ||
| 752 | &iser_task->prot[ISER_DIR_IN], | ||
| 753 | DMA_FROM_DEVICE); | ||
| 754 | } | 731 | } |
| 755 | 732 | ||
| 756 | if (iser_task->dir[ISER_DIR_OUT]) { | 733 | if (iser_task->dir[ISER_DIR_OUT]) { |
| 757 | iser_unreg_mem_fastreg(iser_task, ISER_DIR_OUT); | 734 | iser_unreg_mem_fastreg(iser_task, ISER_DIR_OUT); |
| 758 | iser_dma_unmap_task_data(iser_task, | 735 | iser_dma_unmap_task_data(iser_task, ISER_DIR_OUT, |
| 759 | &iser_task->data[ISER_DIR_OUT], | ||
| 760 | DMA_TO_DEVICE); | 736 | DMA_TO_DEVICE); |
| 761 | if (prot_count) | ||
| 762 | iser_dma_unmap_task_data(iser_task, | ||
| 763 | &iser_task->prot[ISER_DIR_OUT], | ||
| 764 | DMA_TO_DEVICE); | ||
| 765 | } | 737 | } |
| 766 | } | 738 | } |
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 31 | * SOFTWARE. | 31 | * SOFTWARE. |
| 32 | */ | 32 | */ |
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
| 35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
| 36 | #include <linux/mm.h> | 35 | #include <linux/mm.h> |
| @@ -71,10 +70,10 @@ static void iser_reg_desc_put_fr(struct ib_conn *ib_conn, · 34 unmodified lines | |||
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, | 72 | int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, |
| 74 | struct iser_data_buf *data, | ||
| 75 | enum iser_data_dir iser_dir, | 73 | enum iser_data_dir iser_dir, |
| 76 | enum dma_data_direction dma_dir) | 74 | enum dma_data_direction dma_dir) |
| 77 | { | 75 | { |
| 76 | struct iser_data_buf *data = &iser_task->data[iser_dir]; | ||
| 78 | struct ib_device *dev; | 77 | struct ib_device *dev; |
| 79 | 78 | ||
| 80 | iser_task->dir[iser_dir] = 1; | 79 | iser_task->dir[iser_dir] = 1; |
| @@ -85,17 +84,40 @@ int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, · 4 unmodified lines | |||
| 85 | iser_err("dma_map_sg failed!!!\n"); | 84 | iser_err("dma_map_sg failed!!!\n"); |
| 86 | return -EINVAL; | 85 | return -EINVAL; |
| 87 | } | 86 | } |
| 87 | |||
| 88 | if (scsi_prot_sg_count(iser_task->sc)) { | ||
| 89 | struct iser_data_buf *pdata = &iser_task->prot[iser_dir]; | ||
| 90 | |||
| 91 | pdata->dma_nents = ib_dma_map_sg(dev, pdata->sg, pdata->size, dma_dir); | ||
| 92 | if (unlikely(pdata->dma_nents == 0)) { | ||
| 93 | iser_err("protection dma_map_sg failed!!!\n"); | ||
| 94 | goto out_unmap; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 88 | return 0; | 98 | return 0; |
| 99 | |||
| 100 | out_unmap: | ||
| 101 | ib_dma_unmap_sg(dev, data->sg, data->size, dma_dir); | ||
| 102 | return -EINVAL; | ||
| 89 | } | 103 | } |
| 90 | 104 | ||
| 105 | |||
| 91 | void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, | 106 | void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, |
| 92 | struct iser_data_buf *data, | 107 | enum iser_data_dir iser_dir, |
| 93 | enum dma_data_direction dir) | 108 | enum dma_data_direction dma_dir) |
| 94 | { | 109 | { |
| 110 | struct iser_data_buf *data = &iser_task->data[iser_dir]; | ||
| 95 | struct ib_device *dev; | 111 | struct ib_device *dev; |
| 96 | 112 | ||
| 97 | dev = iser_task->iser_conn->ib_conn.device->ib_device; | 113 | dev = iser_task->iser_conn->ib_conn.device->ib_device; |
| 98 | ib_dma_unmap_sg(dev, data->sg, data->size, dir); | 114 | ib_dma_unmap_sg(dev, data->sg, data->size, dma_dir); |
| 115 | |||
| 116 | if (scsi_prot_sg_count(iser_task->sc)) { | ||
| 117 | struct iser_data_buf *pdata = &iser_task->prot[iser_dir]; | ||
| 118 | |||
| 119 | ib_dma_unmap_sg(dev, pdata->sg, pdata->size, dma_dir); | ||
| 120 | } | ||
| 99 | } | 121 | } |
| 100 | 122 | ||
| 101 | static int iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem, | 123 | static int iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem, |
| @@ -130,7 +152,7 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task, · 28 unmodified lines | |||
| 130 | struct iser_fr_desc *desc; | 152 | struct iser_fr_desc *desc; |
| 131 | struct ib_mr_status mr_status; | 153 | struct ib_mr_status mr_status; |
| 132 | 154 | ||
| 133 | desc = reg->mem_h; | 155 | desc = reg->desc; |
| 134 | if (!desc) | 156 | if (!desc) |
| 135 | return; | 157 | return; |
| 136 | 158 | ||
| @@ -147,8 +169,8 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task, · 10 unmodified lines | |||
| 147 | ib_check_mr_status(desc->rsc.sig_mr, IB_MR_CHECK_SIG_STATUS, | 169 | ib_check_mr_status(desc->rsc.sig_mr, IB_MR_CHECK_SIG_STATUS, |
| 148 | &mr_status); | 170 | &mr_status); |
| 149 | } | 171 | } |
| 150 | iser_reg_desc_put_fr(&iser_task->iser_conn->ib_conn, reg->mem_h); | 172 | iser_reg_desc_put_fr(&iser_task->iser_conn->ib_conn, reg->desc); |
| 151 | reg->mem_h = NULL; | 173 | reg->desc = NULL; |
| 152 | } | 174 | } |
| 153 | 175 | ||
| 154 | static void iser_set_dif_domain(struct scsi_cmnd *sc, | 176 | static void iser_set_dif_domain(struct scsi_cmnd *sc, |
| @@ -327,40 +349,26 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task, · 172 unmodified lines | |||
| 327 | return 0; | 349 | return 0; |
| 328 | } | 350 | } |
| 329 | 351 | ||
| 330 | static int iser_reg_data_sg(struct iscsi_iser_task *task, | ||
| 331 | struct iser_data_buf *mem, | ||
| 332 | struct iser_fr_desc *desc, bool use_dma_key, | ||
| 333 | struct iser_mem_reg *reg) | ||
| 334 | { | ||
| 335 | struct iser_device *device = task->iser_conn->ib_conn.device; | ||
| 336 | |||
| 337 | if (use_dma_key) | ||
| 338 | return iser_reg_dma(device, mem, reg); | ||
| 339 | |||
| 340 | return iser_fast_reg_mr(task, mem, &desc->rsc, reg); | ||
| 341 | } | ||
| 342 | |||
| 343 | int iser_reg_mem_fastreg(struct iscsi_iser_task *task, | 352 | int iser_reg_mem_fastreg(struct iscsi_iser_task *task, |
| 344 | enum iser_data_dir dir, | 353 | enum iser_data_dir dir, |
| 345 | bool all_imm) | 354 | bool all_imm) |
| 346 | { | 355 | { |
| 347 | struct ib_conn *ib_conn = &task->iser_conn->ib_conn; | 356 | struct ib_conn *ib_conn = &task->iser_conn->ib_conn; |
| 357 | struct iser_device *device = ib_conn->device; | ||
| 348 | struct iser_data_buf *mem = &task->data[dir]; | 358 | struct iser_data_buf *mem = &task->data[dir]; |
| 349 | struct iser_mem_reg *reg = &task->rdma_reg[dir]; | 359 | struct iser_mem_reg *reg = &task->rdma_reg[dir]; |
| 350 | struct iser_fr_desc *desc = NULL; | 360 | struct iser_fr_desc *desc; |
| 351 | bool use_dma_key; | 361 | bool use_dma_key; |
| 352 | int err; | 362 | int err; |
| 353 | 363 | ||
| 354 | use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) && | 364 | use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) && |
| 355 | scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL; | 365 | scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL; |
| 366 | if (use_dma_key) | ||
| 367 | return iser_reg_dma(device, mem, reg); | ||
| 356 | 368 | ||
| 357 | if (!use_dma_key) { | 369 | desc = iser_reg_desc_get_fr(ib_conn); |
| 358 | desc = iser_reg_desc_get_fr(ib_conn); | ||
| 359 | reg->mem_h = desc; | ||
| 360 | } | ||
| 361 | |||
| 362 | if (scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL) { | 370 | if (scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL) { |
| 363 | err = iser_reg_data_sg(task, mem, desc, use_dma_key, reg); | 371 | err = iser_fast_reg_mr(task, mem, &desc->rsc, reg); |
| 364 | if (unlikely(err)) | 372 | if (unlikely(err)) |
| 365 | goto err_reg; | 373 | goto err_reg; |
| 366 | } else { | 374 | } else { |
| @@ -372,11 +380,12 @@ int iser_reg_mem_fastreg(struct iscsi_iser_task *task, · 5 unmodified lines | |||
| 372 | desc->sig_protected = true; | 380 | desc->sig_protected = true; |
| 373 | } | 381 | } |
| 374 | 382 | ||
| 383 | reg->desc = desc; | ||
| 384 | |||
| 375 | return 0; | 385 | return 0; |
| 376 | 386 | ||
| 377 | err_reg: | 387 | err_reg: |
| 378 | if (desc) | 388 | iser_reg_desc_put_fr(ib_conn, desc); |
| 379 | iser_reg_desc_put_fr(ib_conn, desc); | ||
| 380 | 389 | ||
| 381 | return err; | 390 | return err; |
| 382 | } | 391 | } |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | * SOFTWARE. | 32 | * SOFTWARE. |
| 33 | */ | 33 | */ |
| 34 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
| 37 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
| 38 | 37 | ||
| @@ -905,7 +904,7 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, · 866 unmodified lines | |||
| 905 | enum iser_data_dir cmd_dir, sector_t *sector) | 904 | enum iser_data_dir cmd_dir, sector_t *sector) |
| 906 | { | 905 | { |
| 907 | struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; | 906 | struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; |
| 908 | struct iser_fr_desc *desc = reg->mem_h; | 907 | struct iser_fr_desc *desc = reg->desc; |
| 909 | unsigned long sector_size = iser_task->sc->device->sector_size; | 908 | unsigned long sector_size = iser_task->sc->device->sector_size; |
| 910 | struct ib_mr_status mr_status; | 909 | struct ib_mr_status mr_status; |
| 911 | int ret; | 910 | int ret; |
| @@ -50,7 +50,6 @@ · 49 unmodified lines | |||
| 50 | * netdev functionality. | 50 | * netdev functionality. |
| 51 | */ | 51 | */ |
| 52 | 52 | ||
| 53 | #include <linux/module.h> | ||
| 54 | #include <linux/if_vlan.h> | 53 | #include <linux/if_vlan.h> |
| 55 | #include <linux/crc32.h> | 54 | #include <linux/crc32.h> |
| 56 | 55 | ||
| @@ -156,8 +156,7 @@ static DEVICE_ATTR_RW(mpath_policy); · 155 unmodified lines | |||
| 156 | static ssize_t add_path_show(struct device *dev, | 156 | static ssize_t add_path_show(struct device *dev, |
| 157 | struct device_attribute *attr, char *page) | 157 | struct device_attribute *attr, char *page) |
| 158 | { | 158 | { |
| 159 | return sysfs_emit( | 159 | return sysfs_emit(page, |
| 160 | page, | ||
| 161 | "Usage: echo [<source addr>@]<destination addr> > %s\n\n*addr ::= [ ip:<ipv4|ipv6> | gid:<gid> ]\n", | 160 | "Usage: echo [<source addr>@]<destination addr> > %s\n\n*addr ::= [ ip:<ipv4|ipv6> | gid:<gid> ]\n", |
| 162 | attr->attr.name); | 161 | attr->attr.name); |
| 163 | } | 162 | } |
| @@ -297,6 +297,7 @@ static bool rtrs_clt_change_state_from_to(struct rtrs_clt_path *clt_path, · 296 unmodified lines | |||
| 297 | return changed; | 297 | return changed; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path); | ||
| 300 | static void rtrs_rdma_error_recovery(struct rtrs_clt_con *con) | 301 | static void rtrs_rdma_error_recovery(struct rtrs_clt_con *con) |
| 301 | { | 302 | { |
| 302 | struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); | 303 | struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); |
| @@ -304,16 +305,7 @@ static void rtrs_rdma_error_recovery(struct rtrs_clt_con *con) · 1 unmodified line | |||
| 304 | if (rtrs_clt_change_state_from_to(clt_path, | 305 | if (rtrs_clt_change_state_from_to(clt_path, |
| 305 | RTRS_CLT_CONNECTED, | 306 | RTRS_CLT_CONNECTED, |
| 306 | RTRS_CLT_RECONNECTING)) { | 307 | RTRS_CLT_RECONNECTING)) { |
| 307 | struct rtrs_clt_sess *clt = clt_path->clt; | 308 | queue_work(rtrs_wq, &clt_path->err_recovery_work); |
| 308 | unsigned int delay_ms; | ||
| 309 | |||
| 310 | /* | ||
| 311 | * Normal scenario, reconnect if we were successfully connected | ||
| 312 | */ | ||
| 313 | delay_ms = clt->reconnect_delay_sec * 1000; | ||
| 314 | queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, | ||
| 315 | msecs_to_jiffies(delay_ms + | ||
| 316 | prandom_u32() % RTRS_RECONNECT_SEED)); | ||
| 317 | } else { | 309 | } else { |
| 318 | /* | 310 | /* |
| 319 | * Error can happen just on establishing new connection, | 311 | * Error can happen just on establishing new connection, |
| @@ -917,7 +909,7 @@ static inline void path_it_deinit(struct path_it *it) · 597 unmodified lines | |||
| 917 | { | 909 | { |
| 918 | struct list_head *skip, *tmp; | 910 | struct list_head *skip, *tmp; |
| 919 | /* | 911 | /* |
| 920 | * The skip_list is used only for the MIN_INFLIGHT policy. | 912 | * The skip_list is used only for the MIN_INFLIGHT and MIN_LATENCY policies. |
| 921 | * We need to remove paths from it, so that next IO can insert | 913 | * We need to remove paths from it, so that next IO can insert |
| 922 | * paths (->mp_skip_entry) into a skip_list again. | 914 | * paths (->mp_skip_entry) into a skip_list again. |
| 923 | */ | 915 | */ |
| @@ -1511,6 +1503,22 @@ static void rtrs_clt_init_hb(struct rtrs_clt_path *clt_path) · 587 unmodified lines | |||
| 1511 | static void rtrs_clt_reconnect_work(struct work_struct *work); | 1503 | static void rtrs_clt_reconnect_work(struct work_struct *work); |
| 1512 | static void rtrs_clt_close_work(struct work_struct *work); | 1504 | static void rtrs_clt_close_work(struct work_struct *work); |
| 1513 | 1505 | ||
| 1506 | static void rtrs_clt_err_recovery_work(struct work_struct *work) | ||
| 1507 | { | ||
| 1508 | struct rtrs_clt_path *clt_path; | ||
| 1509 | struct rtrs_clt_sess *clt; | ||
| 1510 | int delay_ms; | ||
| 1511 | |||
| 1512 | clt_path = container_of(work, struct rtrs_clt_path, err_recovery_work); | ||
| 1513 | clt = clt_path->clt; | ||
| 1514 | delay_ms = clt->reconnect_delay_sec * 1000; | ||
| 1515 | rtrs_clt_stop_and_destroy_conns(clt_path); | ||
| 1516 | queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, | ||
| 1517 | msecs_to_jiffies(delay_ms + | ||
| 1518 | prandom_u32() % | ||
| 1519 | RTRS_RECONNECT_SEED)); | ||
| 1520 | } | ||
| 1521 | |||
| 1514 | static struct rtrs_clt_path *alloc_path(struct rtrs_clt_sess *clt, | 1522 | static struct rtrs_clt_path *alloc_path(struct rtrs_clt_sess *clt, |
| 1515 | const struct rtrs_addr *path, | 1523 | const struct rtrs_addr *path, |
| 1516 | size_t con_num, u32 nr_poll_queues) | 1524 | size_t con_num, u32 nr_poll_queues) |
| @@ -1562,6 +1570,7 @@ static struct rtrs_clt_path *alloc_path(struct rtrs_clt_sess *clt, · 45 unmodified lines | |||
| 1562 | clt_path->state = RTRS_CLT_CONNECTING; | 1570 | clt_path->state = RTRS_CLT_CONNECTING; |
| 1563 | atomic_set(&clt_path->connected_cnt, 0); | 1571 | atomic_set(&clt_path->connected_cnt, 0); |
| 1564 | INIT_WORK(&clt_path->close_work, rtrs_clt_close_work); | 1572 | INIT_WORK(&clt_path->close_work, rtrs_clt_close_work); |
| 1573 | INIT_WORK(&clt_path->err_recovery_work, rtrs_clt_err_recovery_work); | ||
| 1565 | INIT_DELAYED_WORK(&clt_path->reconnect_dwork, rtrs_clt_reconnect_work); | 1574 | INIT_DELAYED_WORK(&clt_path->reconnect_dwork, rtrs_clt_reconnect_work); |
| 1566 | rtrs_clt_init_hb(clt_path); | 1575 | rtrs_clt_init_hb(clt_path); |
| 1567 | 1576 | ||
| @@ -2326,6 +2335,7 @@ static void rtrs_clt_close_work(struct work_struct *work) · 758 unmodified lines | |||
| 2326 | 2335 | ||
| 2327 | clt_path = container_of(work, struct rtrs_clt_path, close_work); | 2336 | clt_path = container_of(work, struct rtrs_clt_path, close_work); |
| 2328 | 2337 | ||
| 2338 | cancel_work_sync(&clt_path->err_recovery_work); | ||
| 2329 | cancel_delayed_work_sync(&clt_path->reconnect_dwork); | 2339 | cancel_delayed_work_sync(&clt_path->reconnect_dwork); |
| 2330 | rtrs_clt_stop_and_destroy_conns(clt_path); | 2340 | rtrs_clt_stop_and_destroy_conns(clt_path); |
| 2331 | rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CLOSED, NULL); | 2341 | rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CLOSED, NULL); |
| @@ -2638,7 +2648,6 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) · 306 unmodified lines | |||
| 2638 | { | 2648 | { |
| 2639 | struct rtrs_clt_path *clt_path; | 2649 | struct rtrs_clt_path *clt_path; |
| 2640 | struct rtrs_clt_sess *clt; | 2650 | struct rtrs_clt_sess *clt; |
| 2641 | unsigned int delay_ms; | ||
| 2642 | int err; | 2651 | int err; |
| 2643 | 2652 | ||
| 2644 | clt_path = container_of(to_delayed_work(work), struct rtrs_clt_path, | 2653 | clt_path = container_of(to_delayed_work(work), struct rtrs_clt_path, |
| @@ -2655,8 +2664,6 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) · 10 unmodified lines | |||
| 2655 | } | 2664 | } |
| 2656 | clt_path->reconnect_attempts++; | 2665 | clt_path->reconnect_attempts++; |
| 2657 | 2666 | ||
| 2658 | /* Stop everything */ | ||
| 2659 | rtrs_clt_stop_and_destroy_conns(clt_path); | ||
| 2660 | msleep(RTRS_RECONNECT_BACKOFF); | 2667 | msleep(RTRS_RECONNECT_BACKOFF); |
| 2661 | if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING, NULL)) { | 2668 | if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING, NULL)) { |
| 2662 | err = init_path(clt_path); | 2669 | err = init_path(clt_path); |
| @@ -2669,11 +2676,7 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) · 6 unmodified lines | |||
| 2669 | reconnect_again: | 2676 | reconnect_again: |
| 2670 | if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_RECONNECTING, NULL)) { | 2677 | if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_RECONNECTING, NULL)) { |
| 2671 | clt_path->stats->reconnects.fail_cnt++; | 2678 | clt_path->stats->reconnects.fail_cnt++; |
| 2672 | delay_ms = clt->reconnect_delay_sec * 1000; | 2679 | queue_work(rtrs_wq, &clt_path->err_recovery_work); |
| 2673 | queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, | ||
| 2674 | msecs_to_jiffies(delay_ms + | ||
| 2675 | prandom_u32() % | ||
| 2676 | RTRS_RECONNECT_SEED)); | ||
| 2677 | } | 2680 | } |
| 2678 | } | 2681 | } |
| 2679 | 2682 | ||
| @@ -2908,6 +2911,7 @@ int rtrs_clt_reconnect_from_sysfs(struct rtrs_clt_path *clt_path) · 228 unmodified lines | |||
| 2908 | &old_state); | 2911 | &old_state); |
| 2909 | if (changed) { | 2912 | if (changed) { |
| 2910 | clt_path->reconnect_attempts = 0; | 2913 | clt_path->reconnect_attempts = 0; |
| 2914 | rtrs_clt_stop_and_destroy_conns(clt_path); | ||
| 2911 | queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 0); | 2915 | queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 0); |
| 2912 | } | 2916 | } |
| 2913 | if (changed || old_state == RTRS_CLT_RECONNECTING) { | 2917 | if (changed || old_state == RTRS_CLT_RECONNECTING) { |
| @@ -134,6 +134,7 @@ struct rtrs_clt_path { · 133 unmodified lines | |||
| 134 | struct rtrs_clt_io_req *reqs; | 134 | struct rtrs_clt_io_req *reqs; |
| 135 | struct delayed_work reconnect_dwork; | 135 | struct delayed_work reconnect_dwork; |
| 136 | struct work_struct close_work; | 136 | struct work_struct close_work; |
| 137 | struct work_struct err_recovery_work; | ||
| 137 | unsigned int reconnect_attempts; | 138 | unsigned int reconnect_attempts; |
| 138 | bool established; | 139 | bool established; |
| 139 | struct rtrs_rbuf *rbufs; | 140 | struct rtrs_rbuf *rbufs; |
| @@ -479,7 +479,6 @@ static int rtrs_str_to_sockaddr(const char *addr, size_t len, · 478 unmodified lines | |||
| 479 | */ | 479 | */ |
| 480 | int sockaddr_to_str(const struct sockaddr *addr, char *buf, size_t len) | 480 | int sockaddr_to_str(const struct sockaddr *addr, char *buf, size_t len) |
| 481 | { | 481 | { |
| 482 | |||
| 483 | switch (addr->sa_family) { | 482 | switch (addr->sa_family) { |
| 484 | case AF_IB: | 483 | case AF_IB: |
| 485 | return scnprintf(buf, len, "gid:%pI6", | 484 | return scnprintf(buf, len, "gid:%pI6", |
| @@ -92,6 +92,9 @@ enum srp_iu_type { · 91 unmodified lines | |||
| 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 | * @mr_page_mask: HCA memory registration page mask. | 98 | * @mr_page_mask: HCA memory registration page mask. |
| 96 | * @mr_page_size: HCA memory registration page size. | 99 | * @mr_page_size: HCA memory registration page size. |
| 97 | * @mr_max_size: Maximum size in bytes of a single FR registration request. | 100 | * @mr_max_size: Maximum size in bytes of a single FR registration request. |
| @@ -109,6 +112,12 @@ struct srp_device { · 11 unmodified lines | |||
| 109 | bool use_fast_reg; | 112 | bool use_fast_reg; |
| 110 | }; | 113 | }; |
| 111 | 114 | ||
| 115 | /* | ||
| 116 | * One port of an RDMA adapter in the initiator system. | ||
| 117 | * | ||
| 118 | * @target_list: List of connected target ports (struct srp_target_port). | ||
| 119 | * @target_lock: Protects @target_list. | ||
| 120 | */ | ||
| 112 | struct srp_host { | 121 | struct srp_host { |
| 113 | struct srp_device *srp_dev; | 122 | struct srp_device *srp_dev; |
| 114 | u8 port; | 123 | u8 port; |
| @@ -183,7 +192,7 @@ struct srp_rdma_ch { · 68 unmodified lines | |||
| 183 | }; | 192 | }; |
| 184 | 193 | ||
| 185 | /** | 194 | /** |
| 186 | * struct srp_target_port | 195 | * struct srp_target_port - RDMA port in the SRP target system |
| 187 | * @comp_vector: Completion vector used by the first RDMA channel created for | 196 | * @comp_vector: Completion vector used by the first RDMA channel created for |
| 188 | * this target port. | 197 | * this target port. |
| 189 | */ | 198 | */ |