Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
| 2 | * Copyright (c) 2015-2017 QLogic Corporation |
| 3 | * |
| 4 | * This software is available to you under a choice of one of two |
| 5 | * licenses. You may choose to be licensed under the terms of the GNU |
| 6 | * General Public License (GPL) Version 2, available from the file |
| 7 | * COPYING in the main directory of this source tree, or the |
| 8 | * OpenIB.org BSD license below: |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or |
| 11 | * without modification, are permitted provided that the following |
| 12 | * conditions are met: |
| 13 | * |
| 14 | * - Redistributions of source code must retain the above |
| 15 | * copyright notice, this list of conditions and the following |
| 16 | * disclaimer. |
| 17 | * |
| 18 | * - Redistributions in binary form must reproduce the above |
| 19 | * copyright notice, this list of conditions and the following |
| 20 | * disclaimer in the documentation and /or other materials |
| 21 | * provided with the distribution. |
| 22 | * |
| 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 30 | * SOFTWARE. |
| 31 | */ |
| 32 | #include <linux/types.h> |
| 33 | #include <asm/byteorder.h> |
| 34 | #include <linux/bitops.h> |
| 35 | #include <linux/delay.h> |
| 36 | #include <linux/dma-mapping.h> |
| 37 | #include <linux/errno.h> |
| 38 | #include <linux/io.h> |
| 39 | #include <linux/kernel.h> |
| 40 | #include <linux/list.h> |
| 41 | #include <linux/module.h> |
| 42 | #include <linux/mutex.h> |
| 43 | #include <linux/pci.h> |
| 44 | #include <linux/slab.h> |
| 45 | #include <linux/spinlock.h> |
| 46 | #include <linux/string.h> |
| 47 | #include "qed.h" |
| 48 | #include "qed_cxt.h" |
| 49 | #include "qed_hsi.h" |
| 50 | #include "qed_hw.h" |
| 51 | #include "qed_init_ops.h" |
| 52 | #include "qed_int.h" |
| 53 | #include "qed_ll2.h" |
| 54 | #include "qed_mcp.h" |
| 55 | #include "qed_reg_addr.h" |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 56 | #include <linux/qed/qed_roce_if.h> |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 57 | #include "qed_rdma.h" |
| 58 | #include "qed_roce.h" |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 59 | #include "qed_sp.h" |
| 60 | |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 61 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 62 | int qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, |
| 63 | struct qed_bmap *bmap, u32 max_count, char *name) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 64 | { |
| 65 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "max_count = %08x\n", max_count); |
| 66 | |
| 67 | bmap->max_count = max_count; |
| 68 | |
| 69 | bmap->bitmap = kcalloc(BITS_TO_LONGS(max_count), sizeof(long), |
| 70 | GFP_KERNEL); |
| 71 | if (!bmap->bitmap) |
| 72 | return -ENOMEM; |
| 73 | |
| 74 | snprintf(bmap->name, QED_RDMA_MAX_BMAP_NAME, "%s", name); |
| 75 | |
| 76 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "0\n"); |
| 77 | return 0; |
| 78 | } |
| 79 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 80 | int qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, |
| 81 | struct qed_bmap *bmap, u32 *id_num) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 82 | { |
| 83 | *id_num = find_first_zero_bit(bmap->bitmap, bmap->max_count); |
| 84 | if (*id_num >= bmap->max_count) |
| 85 | return -EINVAL; |
| 86 | |
| 87 | __set_bit(*id_num, bmap->bitmap); |
| 88 | |
| 89 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "%s bitmap: allocated id %d\n", |
| 90 | bmap->name, *id_num); |
| 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 95 | void qed_bmap_set_id(struct qed_hwfn *p_hwfn, |
| 96 | struct qed_bmap *bmap, u32 id_num) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 97 | { |
| 98 | if (id_num >= bmap->max_count) |
| 99 | return; |
| 100 | |
| 101 | __set_bit(id_num, bmap->bitmap); |
| 102 | } |
| 103 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 104 | void qed_bmap_release_id(struct qed_hwfn *p_hwfn, |
| 105 | struct qed_bmap *bmap, u32 id_num) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 106 | { |
| 107 | bool b_acquired; |
| 108 | |
| 109 | if (id_num >= bmap->max_count) |
| 110 | return; |
| 111 | |
| 112 | b_acquired = test_and_clear_bit(id_num, bmap->bitmap); |
| 113 | if (!b_acquired) { |
| 114 | DP_NOTICE(p_hwfn, "%s bitmap: id %d already released\n", |
| 115 | bmap->name, id_num); |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "%s bitmap: released id %d\n", |
| 120 | bmap->name, id_num); |
| 121 | } |
| 122 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 123 | int qed_bmap_test_id(struct qed_hwfn *p_hwfn, |
| 124 | struct qed_bmap *bmap, u32 id_num) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 125 | { |
| 126 | if (id_num >= bmap->max_count) |
| 127 | return -1; |
| 128 | |
| 129 | return test_bit(id_num, bmap->bitmap); |
| 130 | } |
| 131 | |
| 132 | static bool qed_bmap_is_empty(struct qed_bmap *bmap) |
| 133 | { |
| 134 | return bmap->max_count == find_first_bit(bmap->bitmap, bmap->max_count); |
| 135 | } |
| 136 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 137 | u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 138 | { |
| 139 | /* First sb id for RoCE is after all the l2 sb */ |
| 140 | return FEAT_NUM((struct qed_hwfn *)p_hwfn, QED_PF_L2_QUE) + rel_sb_id; |
| 141 | } |
| 142 | |
| 143 | static int qed_rdma_alloc(struct qed_hwfn *p_hwfn, |
| 144 | struct qed_ptt *p_ptt, |
| 145 | struct qed_rdma_start_in_params *params) |
| 146 | { |
| 147 | struct qed_rdma_info *p_rdma_info; |
| 148 | u32 num_cons, num_tasks; |
| 149 | int rc = -ENOMEM; |
| 150 | |
| 151 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocating RDMA\n"); |
| 152 | |
| 153 | /* Allocate a struct with current pf rdma info */ |
| 154 | p_rdma_info = kzalloc(sizeof(*p_rdma_info), GFP_KERNEL); |
| 155 | if (!p_rdma_info) |
| 156 | return rc; |
| 157 | |
| 158 | p_hwfn->p_rdma_info = p_rdma_info; |
| 159 | p_rdma_info->proto = PROTOCOLID_ROCE; |
| 160 | |
| 161 | num_cons = qed_cxt_get_proto_cid_count(p_hwfn, p_rdma_info->proto, |
| 162 | NULL); |
| 163 | |
| 164 | p_rdma_info->num_qps = num_cons / 2; |
| 165 | |
| 166 | num_tasks = qed_cxt_get_proto_tid_count(p_hwfn, PROTOCOLID_ROCE); |
| 167 | |
| 168 | /* Each MR uses a single task */ |
| 169 | p_rdma_info->num_mrs = num_tasks; |
| 170 | |
| 171 | /* Queue zone lines are shared between RoCE and L2 in such a way that |
| 172 | * they can be used by each without obstructing the other. |
| 173 | */ |
| 174 | p_rdma_info->queue_zone_base = (u16)RESC_START(p_hwfn, QED_L2_QUEUE); |
| 175 | p_rdma_info->max_queue_zones = (u16)RESC_NUM(p_hwfn, QED_L2_QUEUE); |
| 176 | |
| 177 | /* Allocate a struct with device params and fill it */ |
| 178 | p_rdma_info->dev = kzalloc(sizeof(*p_rdma_info->dev), GFP_KERNEL); |
| 179 | if (!p_rdma_info->dev) |
| 180 | goto free_rdma_info; |
| 181 | |
| 182 | /* Allocate a struct with port params and fill it */ |
| 183 | p_rdma_info->port = kzalloc(sizeof(*p_rdma_info->port), GFP_KERNEL); |
| 184 | if (!p_rdma_info->port) |
| 185 | goto free_rdma_dev; |
| 186 | |
| 187 | /* Allocate bit map for pd's */ |
| 188 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->pd_map, RDMA_MAX_PDS, |
| 189 | "PD"); |
| 190 | if (rc) { |
| 191 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 192 | "Failed to allocate pd_map, rc = %d\n", |
| 193 | rc); |
| 194 | goto free_rdma_port; |
| 195 | } |
| 196 | |
| 197 | /* Allocate DPI bitmap */ |
| 198 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->dpi_map, |
| 199 | p_hwfn->dpi_count, "DPI"); |
| 200 | if (rc) { |
| 201 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 202 | "Failed to allocate DPI bitmap, rc = %d\n", rc); |
| 203 | goto free_pd_map; |
| 204 | } |
| 205 | |
| 206 | /* Allocate bitmap for cq's. The maximum number of CQs is bounded to |
| 207 | * twice the number of QPs. |
| 208 | */ |
| 209 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->cq_map, |
| 210 | p_rdma_info->num_qps * 2, "CQ"); |
| 211 | if (rc) { |
| 212 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 213 | "Failed to allocate cq bitmap, rc = %d\n", rc); |
| 214 | goto free_dpi_map; |
| 215 | } |
| 216 | |
| 217 | /* Allocate bitmap for toggle bit for cq icids |
| 218 | * We toggle the bit every time we create or resize cq for a given icid. |
| 219 | * The maximum number of CQs is bounded to twice the number of QPs. |
| 220 | */ |
| 221 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->toggle_bits, |
| 222 | p_rdma_info->num_qps * 2, "Toggle"); |
| 223 | if (rc) { |
| 224 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 225 | "Failed to allocate toogle bits, rc = %d\n", rc); |
| 226 | goto free_cq_map; |
| 227 | } |
| 228 | |
| 229 | /* Allocate bitmap for itids */ |
| 230 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->tid_map, |
| 231 | p_rdma_info->num_mrs, "MR"); |
| 232 | if (rc) { |
| 233 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 234 | "Failed to allocate itids bitmaps, rc = %d\n", rc); |
| 235 | goto free_toggle_map; |
| 236 | } |
| 237 | |
| 238 | /* Allocate bitmap for cids used for qps. */ |
| 239 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->cid_map, num_cons, |
| 240 | "CID"); |
| 241 | if (rc) { |
| 242 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 243 | "Failed to allocate cid bitmap, rc = %d\n", rc); |
| 244 | goto free_tid_map; |
| 245 | } |
| 246 | |
| 247 | /* Allocate bitmap for cids used for responders/requesters. */ |
| 248 | rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->real_cid_map, num_cons, |
| 249 | "REAL_CID"); |
| 250 | if (rc) { |
| 251 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 252 | "Failed to allocate real cid bitmap, rc = %d\n", rc); |
| 253 | goto free_cid_map; |
| 254 | } |
| 255 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocation successful\n"); |
| 256 | return 0; |
| 257 | |
| 258 | free_cid_map: |
| 259 | kfree(p_rdma_info->cid_map.bitmap); |
| 260 | free_tid_map: |
| 261 | kfree(p_rdma_info->tid_map.bitmap); |
| 262 | free_toggle_map: |
| 263 | kfree(p_rdma_info->toggle_bits.bitmap); |
| 264 | free_cq_map: |
| 265 | kfree(p_rdma_info->cq_map.bitmap); |
| 266 | free_dpi_map: |
| 267 | kfree(p_rdma_info->dpi_map.bitmap); |
| 268 | free_pd_map: |
| 269 | kfree(p_rdma_info->pd_map.bitmap); |
| 270 | free_rdma_port: |
| 271 | kfree(p_rdma_info->port); |
| 272 | free_rdma_dev: |
| 273 | kfree(p_rdma_info->dev); |
| 274 | free_rdma_info: |
| 275 | kfree(p_rdma_info); |
| 276 | |
| 277 | return rc; |
| 278 | } |
| 279 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 280 | void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, |
| 281 | struct qed_bmap *bmap, bool check) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 282 | { |
| 283 | int weight = bitmap_weight(bmap->bitmap, bmap->max_count); |
| 284 | int last_line = bmap->max_count / (64 * 8); |
| 285 | int last_item = last_line * 8 + |
| 286 | DIV_ROUND_UP(bmap->max_count % (64 * 8), 64); |
| 287 | u64 *pmap = (u64 *)bmap->bitmap; |
| 288 | int line, item, offset; |
| 289 | u8 str_last_line[200] = { 0 }; |
| 290 | |
| 291 | if (!weight || !check) |
| 292 | goto end; |
| 293 | |
| 294 | DP_NOTICE(p_hwfn, |
| 295 | "%s bitmap not free - size=%d, weight=%d, 512 bits per line\n", |
| 296 | bmap->name, bmap->max_count, weight); |
| 297 | |
| 298 | /* print aligned non-zero lines, if any */ |
| 299 | for (item = 0, line = 0; line < last_line; line++, item += 8) |
| 300 | if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8)) |
| 301 | DP_NOTICE(p_hwfn, |
| 302 | "line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", |
| 303 | line, |
| 304 | pmap[item], |
| 305 | pmap[item + 1], |
| 306 | pmap[item + 2], |
| 307 | pmap[item + 3], |
| 308 | pmap[item + 4], |
| 309 | pmap[item + 5], |
| 310 | pmap[item + 6], pmap[item + 7]); |
| 311 | |
| 312 | /* print last unaligned non-zero line, if any */ |
| 313 | if ((bmap->max_count % (64 * 8)) && |
| 314 | (bitmap_weight((unsigned long *)&pmap[item], |
| 315 | bmap->max_count - item * 64))) { |
| 316 | offset = sprintf(str_last_line, "line 0x%04x: ", line); |
| 317 | for (; item < last_item; item++) |
| 318 | offset += sprintf(str_last_line + offset, |
| 319 | "0x%016llx ", pmap[item]); |
| 320 | DP_NOTICE(p_hwfn, "%s\n", str_last_line); |
| 321 | } |
| 322 | |
| 323 | end: |
| 324 | kfree(bmap->bitmap); |
| 325 | bmap->bitmap = NULL; |
| 326 | } |
| 327 | |
| 328 | static void qed_rdma_resc_free(struct qed_hwfn *p_hwfn) |
| 329 | { |
| 330 | struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; |
| 331 | |
| 332 | qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->cid_map, 1); |
| 333 | qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->pd_map, 1); |
| 334 | qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, 1); |
| 335 | qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->cq_map, 1); |
| 336 | qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->toggle_bits, 0); |
| 337 | qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->tid_map, 1); |
| 338 | |
| 339 | kfree(p_rdma_info->port); |
| 340 | kfree(p_rdma_info->dev); |
| 341 | |
| 342 | kfree(p_rdma_info); |
| 343 | } |
| 344 | |
| 345 | static void qed_rdma_free(struct qed_hwfn *p_hwfn) |
| 346 | { |
| 347 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Freeing RDMA\n"); |
| 348 | |
| 349 | qed_rdma_resc_free(p_hwfn); |
| 350 | } |
| 351 | |
| 352 | static void qed_rdma_get_guid(struct qed_hwfn *p_hwfn, u8 *guid) |
| 353 | { |
| 354 | guid[0] = p_hwfn->hw_info.hw_mac_addr[0] ^ 2; |
| 355 | guid[1] = p_hwfn->hw_info.hw_mac_addr[1]; |
| 356 | guid[2] = p_hwfn->hw_info.hw_mac_addr[2]; |
| 357 | guid[3] = 0xff; |
| 358 | guid[4] = 0xfe; |
| 359 | guid[5] = p_hwfn->hw_info.hw_mac_addr[3]; |
| 360 | guid[6] = p_hwfn->hw_info.hw_mac_addr[4]; |
| 361 | guid[7] = p_hwfn->hw_info.hw_mac_addr[5]; |
| 362 | } |
| 363 | |
| 364 | static void qed_rdma_init_events(struct qed_hwfn *p_hwfn, |
| 365 | struct qed_rdma_start_in_params *params) |
| 366 | { |
| 367 | struct qed_rdma_events *events; |
| 368 | |
| 369 | events = &p_hwfn->p_rdma_info->events; |
| 370 | |
| 371 | events->unaffiliated_event = params->events->unaffiliated_event; |
| 372 | events->affiliated_event = params->events->affiliated_event; |
| 373 | events->context = params->events->context; |
| 374 | } |
| 375 | |
| 376 | static void qed_rdma_init_devinfo(struct qed_hwfn *p_hwfn, |
| 377 | struct qed_rdma_start_in_params *params) |
| 378 | { |
| 379 | struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; |
| 380 | struct qed_dev *cdev = p_hwfn->cdev; |
| 381 | u32 pci_status_control; |
| 382 | u32 num_qps; |
| 383 | |
| 384 | /* Vendor specific information */ |
| 385 | dev->vendor_id = cdev->vendor_id; |
| 386 | dev->vendor_part_id = cdev->device_id; |
| 387 | dev->hw_ver = 0; |
| 388 | dev->fw_ver = (FW_MAJOR_VERSION << 24) | (FW_MINOR_VERSION << 16) | |
| 389 | (FW_REVISION_VERSION << 8) | (FW_ENGINEERING_VERSION); |
| 390 | |
| 391 | qed_rdma_get_guid(p_hwfn, (u8 *)&dev->sys_image_guid); |
| 392 | dev->node_guid = dev->sys_image_guid; |
| 393 | |
| 394 | dev->max_sge = min_t(u32, RDMA_MAX_SGE_PER_SQ_WQE, |
| 395 | RDMA_MAX_SGE_PER_RQ_WQE); |
| 396 | |
| 397 | if (cdev->rdma_max_sge) |
| 398 | dev->max_sge = min_t(u32, cdev->rdma_max_sge, dev->max_sge); |
| 399 | |
| 400 | dev->max_inline = ROCE_REQ_MAX_INLINE_DATA_SIZE; |
| 401 | |
| 402 | dev->max_inline = (cdev->rdma_max_inline) ? |
| 403 | min_t(u32, cdev->rdma_max_inline, dev->max_inline) : |
| 404 | dev->max_inline; |
| 405 | |
| 406 | dev->max_wqe = QED_RDMA_MAX_WQE; |
| 407 | dev->max_cnq = (u8)FEAT_NUM(p_hwfn, QED_RDMA_CNQ); |
| 408 | |
| 409 | /* The number of QPs may be higher than QED_ROCE_MAX_QPS, because |
| 410 | * it is up-aligned to 16 and then to ILT page size within qed cxt. |
| 411 | * This is OK in terms of ILT but we don't want to configure the FW |
| 412 | * above its abilities |
| 413 | */ |
| 414 | num_qps = ROCE_MAX_QPS; |
| 415 | num_qps = min_t(u64, num_qps, p_hwfn->p_rdma_info->num_qps); |
| 416 | dev->max_qp = num_qps; |
| 417 | |
| 418 | /* CQs uses the same icids that QPs use hence they are limited by the |
| 419 | * number of icids. There are two icids per QP. |
| 420 | */ |
| 421 | dev->max_cq = num_qps * 2; |
| 422 | |
| 423 | /* The number of mrs is smaller by 1 since the first is reserved */ |
| 424 | dev->max_mr = p_hwfn->p_rdma_info->num_mrs - 1; |
| 425 | dev->max_mr_size = QED_RDMA_MAX_MR_SIZE; |
| 426 | |
| 427 | /* The maximum CQE capacity per CQ supported. |
| 428 | * max number of cqes will be in two layer pbl, |
| 429 | * 8 is the pointer size in bytes |
| 430 | * 32 is the size of cq element in bytes |
| 431 | */ |
| 432 | if (params->cq_mode == QED_RDMA_CQ_MODE_32_BITS) |
| 433 | dev->max_cqe = QED_RDMA_MAX_CQE_32_BIT; |
| 434 | else |
| 435 | dev->max_cqe = QED_RDMA_MAX_CQE_16_BIT; |
| 436 | |
| 437 | dev->max_mw = 0; |
| 438 | dev->max_fmr = QED_RDMA_MAX_FMR; |
| 439 | dev->max_mr_mw_fmr_pbl = (PAGE_SIZE / 8) * (PAGE_SIZE / 8); |
| 440 | dev->max_mr_mw_fmr_size = dev->max_mr_mw_fmr_pbl * PAGE_SIZE; |
| 441 | dev->max_pkey = QED_RDMA_MAX_P_KEY; |
| 442 | |
| 443 | dev->max_qp_resp_rd_atomic_resc = RDMA_RING_PAGE_SIZE / |
| 444 | (RDMA_RESP_RD_ATOMIC_ELM_SIZE * 2); |
| 445 | dev->max_qp_req_rd_atomic_resc = RDMA_RING_PAGE_SIZE / |
| 446 | RDMA_REQ_RD_ATOMIC_ELM_SIZE; |
| 447 | dev->max_dev_resp_rd_atomic_resc = dev->max_qp_resp_rd_atomic_resc * |
| 448 | p_hwfn->p_rdma_info->num_qps; |
| 449 | dev->page_size_caps = QED_RDMA_PAGE_SIZE_CAPS; |
| 450 | dev->dev_ack_delay = QED_RDMA_ACK_DELAY; |
| 451 | dev->max_pd = RDMA_MAX_PDS; |
| 452 | dev->max_ah = p_hwfn->p_rdma_info->num_qps; |
| 453 | dev->max_stats_queues = (u8)RESC_NUM(p_hwfn, QED_RDMA_STATS_QUEUE); |
| 454 | |
| 455 | /* Set capablities */ |
| 456 | dev->dev_caps = 0; |
| 457 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_RNR_NAK, 1); |
| 458 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_PORT_ACTIVE_EVENT, 1); |
| 459 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_PORT_CHANGE_EVENT, 1); |
| 460 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_RESIZE_CQ, 1); |
| 461 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_BASE_MEMORY_EXT, 1); |
| 462 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_BASE_QUEUE_EXT, 1); |
| 463 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_ZBVA, 1); |
| 464 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_LOCAL_INV_FENCE, 1); |
| 465 | |
| 466 | /* Check atomic operations support in PCI configuration space. */ |
| 467 | pci_read_config_dword(cdev->pdev, |
| 468 | cdev->pdev->pcie_cap + PCI_EXP_DEVCTL2, |
| 469 | &pci_status_control); |
| 470 | |
| 471 | if (pci_status_control & PCI_EXP_DEVCTL2_LTR_EN) |
| 472 | SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_ATOMIC_OP, 1); |
| 473 | } |
| 474 | |
| 475 | static void qed_rdma_init_port(struct qed_hwfn *p_hwfn) |
| 476 | { |
| 477 | struct qed_rdma_port *port = p_hwfn->p_rdma_info->port; |
| 478 | struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; |
| 479 | |
| 480 | port->port_state = p_hwfn->mcp_info->link_output.link_up ? |
| 481 | QED_RDMA_PORT_UP : QED_RDMA_PORT_DOWN; |
| 482 | |
| 483 | port->max_msg_size = min_t(u64, |
| 484 | (dev->max_mr_mw_fmr_size * |
| 485 | p_hwfn->cdev->rdma_max_sge), |
| 486 | BIT(31)); |
| 487 | |
| 488 | port->pkey_bad_counter = 0; |
| 489 | } |
| 490 | |
| 491 | static int qed_rdma_init_hw(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
| 492 | { |
| 493 | u32 ll2_ethertype_en; |
| 494 | |
| 495 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Initializing HW\n"); |
| 496 | p_hwfn->b_rdma_enabled_in_prs = false; |
| 497 | |
| 498 | qed_wr(p_hwfn, p_ptt, PRS_REG_ROCE_DEST_QP_MAX_PF, 0); |
| 499 | |
| 500 | p_hwfn->rdma_prs_search_reg = PRS_REG_SEARCH_ROCE; |
| 501 | |
| 502 | /* We delay writing to this reg until first cid is allocated. See |
| 503 | * qed_cxt_dynamic_ilt_alloc function for more details |
| 504 | */ |
| 505 | ll2_ethertype_en = qed_rd(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN); |
| 506 | qed_wr(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN, |
| 507 | (ll2_ethertype_en | 0x01)); |
| 508 | |
| 509 | if (qed_cxt_get_proto_cid_start(p_hwfn, PROTOCOLID_ROCE) % 2) { |
| 510 | DP_NOTICE(p_hwfn, "The first RoCE's cid should be even\n"); |
| 511 | return -EINVAL; |
| 512 | } |
| 513 | |
| 514 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Initializing HW - Done\n"); |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | static int qed_rdma_start_fw(struct qed_hwfn *p_hwfn, |
| 519 | struct qed_rdma_start_in_params *params, |
| 520 | struct qed_ptt *p_ptt) |
| 521 | { |
| 522 | struct rdma_init_func_ramrod_data *p_ramrod; |
| 523 | struct qed_rdma_cnq_params *p_cnq_pbl_list; |
| 524 | struct rdma_init_func_hdr *p_params_header; |
| 525 | struct rdma_cnq_params *p_cnq_params; |
| 526 | struct qed_sp_init_data init_data; |
| 527 | struct qed_spq_entry *p_ent; |
| 528 | u32 cnq_id, sb_id; |
| 529 | u16 igu_sb_id; |
| 530 | int rc; |
| 531 | |
| 532 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Starting FW\n"); |
| 533 | |
| 534 | /* Save the number of cnqs for the function close ramrod */ |
| 535 | p_hwfn->p_rdma_info->num_cnqs = params->desired_cnq; |
| 536 | |
| 537 | /* Get SPQ entry */ |
| 538 | memset(&init_data, 0, sizeof(init_data)); |
| 539 | init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; |
| 540 | init_data.comp_mode = QED_SPQ_MODE_EBLOCK; |
| 541 | |
| 542 | rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_FUNC_INIT, |
| 543 | p_hwfn->p_rdma_info->proto, &init_data); |
| 544 | if (rc) |
| 545 | return rc; |
| 546 | |
| 547 | p_ramrod = &p_ent->ramrod.roce_init_func.rdma; |
| 548 | |
| 549 | p_params_header = &p_ramrod->params_header; |
| 550 | p_params_header->cnq_start_offset = (u8)RESC_START(p_hwfn, |
| 551 | QED_RDMA_CNQ_RAM); |
| 552 | p_params_header->num_cnqs = params->desired_cnq; |
| 553 | |
| 554 | if (params->cq_mode == QED_RDMA_CQ_MODE_16_BITS) |
| 555 | p_params_header->cq_ring_mode = 1; |
| 556 | else |
| 557 | p_params_header->cq_ring_mode = 0; |
| 558 | |
| 559 | for (cnq_id = 0; cnq_id < params->desired_cnq; cnq_id++) { |
| 560 | sb_id = qed_rdma_get_sb_id(p_hwfn, cnq_id); |
| 561 | igu_sb_id = qed_get_igu_sb_id(p_hwfn, sb_id); |
| 562 | p_ramrod->cnq_params[cnq_id].sb_num = cpu_to_le16(igu_sb_id); |
| 563 | p_cnq_params = &p_ramrod->cnq_params[cnq_id]; |
| 564 | p_cnq_pbl_list = ¶ms->cnq_pbl_list[cnq_id]; |
| 565 | |
| 566 | p_cnq_params->sb_index = p_hwfn->pf_params.rdma_pf_params.gl_pi; |
| 567 | p_cnq_params->num_pbl_pages = p_cnq_pbl_list->num_pbl_pages; |
| 568 | |
| 569 | DMA_REGPAIR_LE(p_cnq_params->pbl_base_addr, |
| 570 | p_cnq_pbl_list->pbl_ptr); |
| 571 | |
| 572 | /* we assume here that cnq_id and qz_offset are the same */ |
| 573 | p_cnq_params->queue_zone_num = |
| 574 | cpu_to_le16(p_hwfn->p_rdma_info->queue_zone_base + |
| 575 | cnq_id); |
| 576 | } |
| 577 | |
| 578 | return qed_spq_post(p_hwfn, p_ent, NULL); |
| 579 | } |
| 580 | |
| 581 | static int qed_rdma_alloc_tid(void *rdma_cxt, u32 *itid) |
| 582 | { |
| 583 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 584 | int rc; |
| 585 | |
| 586 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID\n"); |
| 587 | |
| 588 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 589 | rc = qed_rdma_bmap_alloc_id(p_hwfn, |
| 590 | &p_hwfn->p_rdma_info->tid_map, itid); |
| 591 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 592 | if (rc) |
| 593 | goto out; |
| 594 | |
| 595 | rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_TASK, *itid); |
| 596 | out: |
| 597 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID - done, rc = %d\n", rc); |
| 598 | return rc; |
| 599 | } |
| 600 | |
| 601 | static int qed_rdma_reserve_lkey(struct qed_hwfn *p_hwfn) |
| 602 | { |
| 603 | struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; |
| 604 | |
| 605 | /* The first DPI is reserved for the Kernel */ |
| 606 | __set_bit(0, p_hwfn->p_rdma_info->dpi_map.bitmap); |
| 607 | |
| 608 | /* Tid 0 will be used as the key for "reserved MR". |
| 609 | * The driver should allocate memory for it so it can be loaded but no |
| 610 | * ramrod should be passed on it. |
| 611 | */ |
| 612 | qed_rdma_alloc_tid(p_hwfn, &dev->reserved_lkey); |
| 613 | if (dev->reserved_lkey != RDMA_RESERVED_LKEY) { |
| 614 | DP_NOTICE(p_hwfn, |
| 615 | "Reserved lkey should be equal to RDMA_RESERVED_LKEY\n"); |
| 616 | return -EINVAL; |
| 617 | } |
| 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | static int qed_rdma_setup(struct qed_hwfn *p_hwfn, |
| 623 | struct qed_ptt *p_ptt, |
| 624 | struct qed_rdma_start_in_params *params) |
| 625 | { |
| 626 | int rc; |
| 627 | |
| 628 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA setup\n"); |
| 629 | |
| 630 | spin_lock_init(&p_hwfn->p_rdma_info->lock); |
| 631 | |
| 632 | qed_rdma_init_devinfo(p_hwfn, params); |
| 633 | qed_rdma_init_port(p_hwfn); |
| 634 | qed_rdma_init_events(p_hwfn, params); |
| 635 | |
| 636 | rc = qed_rdma_reserve_lkey(p_hwfn); |
| 637 | if (rc) |
| 638 | return rc; |
| 639 | |
| 640 | rc = qed_rdma_init_hw(p_hwfn, p_ptt); |
| 641 | if (rc) |
| 642 | return rc; |
| 643 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 644 | qed_roce_setup(p_hwfn); |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 645 | |
| 646 | return qed_rdma_start_fw(p_hwfn, params, p_ptt); |
| 647 | } |
| 648 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 649 | int qed_rdma_stop(void *rdma_cxt) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 650 | { |
| 651 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 652 | struct rdma_close_func_ramrod_data *p_ramrod; |
| 653 | struct qed_sp_init_data init_data; |
| 654 | struct qed_spq_entry *p_ent; |
| 655 | struct qed_ptt *p_ptt; |
| 656 | u32 ll2_ethertype_en; |
| 657 | int rc = -EBUSY; |
| 658 | |
| 659 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA stop\n"); |
| 660 | |
| 661 | p_ptt = qed_ptt_acquire(p_hwfn); |
| 662 | if (!p_ptt) { |
| 663 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Failed to acquire PTT\n"); |
| 664 | return rc; |
| 665 | } |
| 666 | |
| 667 | /* Disable RoCE search */ |
| 668 | qed_wr(p_hwfn, p_ptt, p_hwfn->rdma_prs_search_reg, 0); |
| 669 | p_hwfn->b_rdma_enabled_in_prs = false; |
| 670 | |
| 671 | qed_wr(p_hwfn, p_ptt, PRS_REG_ROCE_DEST_QP_MAX_PF, 0); |
| 672 | |
| 673 | ll2_ethertype_en = qed_rd(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN); |
| 674 | |
| 675 | qed_wr(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN, |
| 676 | (ll2_ethertype_en & 0xFFFE)); |
| 677 | |
| 678 | qed_roce_stop(p_hwfn); |
| 679 | qed_ptt_release(p_hwfn, p_ptt); |
| 680 | |
| 681 | /* Get SPQ entry */ |
| 682 | memset(&init_data, 0, sizeof(init_data)); |
| 683 | init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; |
| 684 | init_data.comp_mode = QED_SPQ_MODE_EBLOCK; |
| 685 | |
| 686 | /* Stop RoCE */ |
| 687 | rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_FUNC_CLOSE, |
| 688 | p_hwfn->p_rdma_info->proto, &init_data); |
| 689 | if (rc) |
| 690 | goto out; |
| 691 | |
| 692 | p_ramrod = &p_ent->ramrod.rdma_close_func; |
| 693 | |
| 694 | p_ramrod->num_cnqs = p_hwfn->p_rdma_info->num_cnqs; |
| 695 | p_ramrod->cnq_start_offset = (u8)RESC_START(p_hwfn, QED_RDMA_CNQ_RAM); |
| 696 | |
| 697 | rc = qed_spq_post(p_hwfn, p_ent, NULL); |
| 698 | |
| 699 | out: |
| 700 | qed_rdma_free(p_hwfn); |
| 701 | |
| 702 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA stop done, rc = %d\n", rc); |
| 703 | return rc; |
| 704 | } |
| 705 | |
| 706 | static int qed_rdma_add_user(void *rdma_cxt, |
| 707 | struct qed_rdma_add_user_out_params *out_params) |
| 708 | { |
| 709 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 710 | u32 dpi_start_offset; |
| 711 | u32 returned_id = 0; |
| 712 | int rc; |
| 713 | |
| 714 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Adding User\n"); |
| 715 | |
| 716 | /* Allocate DPI */ |
| 717 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 718 | rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, |
| 719 | &returned_id); |
| 720 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 721 | |
| 722 | out_params->dpi = (u16)returned_id; |
| 723 | |
| 724 | /* Calculate the corresponding DPI address */ |
| 725 | dpi_start_offset = p_hwfn->dpi_start_offset; |
| 726 | |
| 727 | out_params->dpi_addr = (u64)((u8 __iomem *)p_hwfn->doorbells + |
| 728 | dpi_start_offset + |
| 729 | ((out_params->dpi) * p_hwfn->dpi_size)); |
| 730 | |
| 731 | out_params->dpi_phys_addr = p_hwfn->cdev->db_phys_addr + |
| 732 | dpi_start_offset + |
| 733 | ((out_params->dpi) * p_hwfn->dpi_size); |
| 734 | |
| 735 | out_params->dpi_size = p_hwfn->dpi_size; |
| 736 | out_params->wid_count = p_hwfn->wid_count; |
| 737 | |
| 738 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Adding user - done, rc = %d\n", rc); |
| 739 | return rc; |
| 740 | } |
| 741 | |
| 742 | static struct qed_rdma_port *qed_rdma_query_port(void *rdma_cxt) |
| 743 | { |
| 744 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 745 | struct qed_rdma_port *p_port = p_hwfn->p_rdma_info->port; |
| 746 | |
| 747 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA Query port\n"); |
| 748 | |
| 749 | /* Link may have changed */ |
| 750 | p_port->port_state = p_hwfn->mcp_info->link_output.link_up ? |
| 751 | QED_RDMA_PORT_UP : QED_RDMA_PORT_DOWN; |
| 752 | |
| 753 | p_port->link_speed = p_hwfn->mcp_info->link_output.speed; |
| 754 | |
| 755 | p_port->max_msg_size = RDMA_MAX_DATA_SIZE_IN_WQE; |
| 756 | |
| 757 | return p_port; |
| 758 | } |
| 759 | |
| 760 | static struct qed_rdma_device *qed_rdma_query_device(void *rdma_cxt) |
| 761 | { |
| 762 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 763 | |
| 764 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Query device\n"); |
| 765 | |
| 766 | /* Return struct with device parameters */ |
| 767 | return p_hwfn->p_rdma_info->dev; |
| 768 | } |
| 769 | |
| 770 | static void qed_rdma_free_tid(void *rdma_cxt, u32 itid) |
| 771 | { |
| 772 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 773 | |
| 774 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", itid); |
| 775 | |
| 776 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 777 | qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->tid_map, itid); |
| 778 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 779 | } |
| 780 | |
| 781 | static void qed_rdma_cnq_prod_update(void *rdma_cxt, u8 qz_offset, u16 prod) |
| 782 | { |
| 783 | struct qed_hwfn *p_hwfn; |
| 784 | u16 qz_num; |
| 785 | u32 addr; |
| 786 | |
| 787 | p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 788 | |
| 789 | if (qz_offset > p_hwfn->p_rdma_info->max_queue_zones) { |
| 790 | DP_NOTICE(p_hwfn, |
| 791 | "queue zone offset %d is too large (max is %d)\n", |
| 792 | qz_offset, p_hwfn->p_rdma_info->max_queue_zones); |
| 793 | return; |
| 794 | } |
| 795 | |
| 796 | qz_num = p_hwfn->p_rdma_info->queue_zone_base + qz_offset; |
| 797 | addr = GTT_BAR0_MAP_REG_USDM_RAM + |
| 798 | USTORM_COMMON_QUEUE_CONS_OFFSET(qz_num); |
| 799 | |
| 800 | REG_WR16(p_hwfn, addr, prod); |
| 801 | |
| 802 | /* keep prod updates ordered */ |
| 803 | wmb(); |
| 804 | } |
| 805 | |
| 806 | static int qed_fill_rdma_dev_info(struct qed_dev *cdev, |
| 807 | struct qed_dev_rdma_info *info) |
| 808 | { |
| 809 | struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); |
| 810 | |
| 811 | memset(info, 0, sizeof(*info)); |
| 812 | |
| 813 | info->rdma_type = QED_RDMA_TYPE_ROCE; |
| 814 | info->user_dpm_enabled = (p_hwfn->db_bar_no_edpm == 0); |
| 815 | |
| 816 | qed_fill_dev_info(cdev, &info->common); |
| 817 | |
| 818 | return 0; |
| 819 | } |
| 820 | |
| 821 | static int qed_rdma_get_sb_start(struct qed_dev *cdev) |
| 822 | { |
| 823 | int feat_num; |
| 824 | |
| 825 | if (cdev->num_hwfns > 1) |
| 826 | feat_num = FEAT_NUM(QED_LEADING_HWFN(cdev), QED_PF_L2_QUE); |
| 827 | else |
| 828 | feat_num = FEAT_NUM(QED_LEADING_HWFN(cdev), QED_PF_L2_QUE) * |
| 829 | cdev->num_hwfns; |
| 830 | |
| 831 | return feat_num; |
| 832 | } |
| 833 | |
| 834 | static int qed_rdma_get_min_cnq_msix(struct qed_dev *cdev) |
| 835 | { |
| 836 | int n_cnq = FEAT_NUM(QED_LEADING_HWFN(cdev), QED_RDMA_CNQ); |
| 837 | int n_msix = cdev->int_params.rdma_msix_cnt; |
| 838 | |
| 839 | return min_t(int, n_cnq, n_msix); |
| 840 | } |
| 841 | |
| 842 | static int qed_rdma_set_int(struct qed_dev *cdev, u16 cnt) |
| 843 | { |
| 844 | int limit = 0; |
| 845 | |
| 846 | /* Mark the fastpath as free/used */ |
| 847 | cdev->int_params.fp_initialized = cnt ? true : false; |
| 848 | |
| 849 | if (cdev->int_params.out.int_mode != QED_INT_MODE_MSIX) { |
| 850 | DP_ERR(cdev, |
| 851 | "qed roce supports only MSI-X interrupts (detected %d).\n", |
| 852 | cdev->int_params.out.int_mode); |
| 853 | return -EINVAL; |
| 854 | } else if (cdev->int_params.fp_msix_cnt) { |
| 855 | limit = cdev->int_params.rdma_msix_cnt; |
| 856 | } |
| 857 | |
| 858 | if (!limit) |
| 859 | return -ENOMEM; |
| 860 | |
| 861 | return min_t(int, cnt, limit); |
| 862 | } |
| 863 | |
| 864 | static int qed_rdma_get_int(struct qed_dev *cdev, struct qed_int_info *info) |
| 865 | { |
| 866 | memset(info, 0, sizeof(*info)); |
| 867 | |
| 868 | if (!cdev->int_params.fp_initialized) { |
| 869 | DP_INFO(cdev, |
| 870 | "Protocol driver requested interrupt information, but its support is not yet configured\n"); |
| 871 | return -EINVAL; |
| 872 | } |
| 873 | |
| 874 | if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { |
| 875 | int msix_base = cdev->int_params.rdma_msix_base; |
| 876 | |
| 877 | info->msix_cnt = cdev->int_params.rdma_msix_cnt; |
| 878 | info->msix = &cdev->int_params.msix_table[msix_base]; |
| 879 | |
| 880 | DP_VERBOSE(cdev, QED_MSG_RDMA, "msix_cnt = %d msix_base=%d\n", |
| 881 | info->msix_cnt, msix_base); |
| 882 | } |
| 883 | |
| 884 | return 0; |
| 885 | } |
| 886 | |
| 887 | static int qed_rdma_alloc_pd(void *rdma_cxt, u16 *pd) |
| 888 | { |
| 889 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 890 | u32 returned_id; |
| 891 | int rc; |
| 892 | |
| 893 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc PD\n"); |
| 894 | |
| 895 | /* Allocates an unused protection domain */ |
| 896 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 897 | rc = qed_rdma_bmap_alloc_id(p_hwfn, |
| 898 | &p_hwfn->p_rdma_info->pd_map, &returned_id); |
| 899 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 900 | |
| 901 | *pd = (u16)returned_id; |
| 902 | |
| 903 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc PD - done, rc = %d\n", rc); |
| 904 | return rc; |
| 905 | } |
| 906 | |
| 907 | static void qed_rdma_free_pd(void *rdma_cxt, u16 pd) |
| 908 | { |
| 909 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 910 | |
| 911 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "pd = %08x\n", pd); |
| 912 | |
| 913 | /* Returns a previously allocated protection domain for reuse */ |
| 914 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 915 | qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->pd_map, pd); |
| 916 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 917 | } |
| 918 | |
| 919 | static enum qed_rdma_toggle_bit |
| 920 | qed_rdma_toggle_bit_create_resize_cq(struct qed_hwfn *p_hwfn, u16 icid) |
| 921 | { |
| 922 | struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; |
| 923 | enum qed_rdma_toggle_bit toggle_bit; |
| 924 | u32 bmap_id; |
| 925 | |
| 926 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", icid); |
| 927 | |
| 928 | /* the function toggle the bit that is related to a given icid |
| 929 | * and returns the new toggle bit's value |
| 930 | */ |
| 931 | bmap_id = icid - qed_cxt_get_proto_cid_start(p_hwfn, p_info->proto); |
| 932 | |
| 933 | spin_lock_bh(&p_info->lock); |
| 934 | toggle_bit = !test_and_change_bit(bmap_id, |
| 935 | p_info->toggle_bits.bitmap); |
| 936 | spin_unlock_bh(&p_info->lock); |
| 937 | |
| 938 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "QED_RDMA_TOGGLE_BIT_= %d\n", |
| 939 | toggle_bit); |
| 940 | |
| 941 | return toggle_bit; |
| 942 | } |
| 943 | |
| 944 | static int qed_rdma_create_cq(void *rdma_cxt, |
| 945 | struct qed_rdma_create_cq_in_params *params, |
| 946 | u16 *icid) |
| 947 | { |
| 948 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 949 | struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; |
| 950 | struct rdma_create_cq_ramrod_data *p_ramrod; |
| 951 | enum qed_rdma_toggle_bit toggle_bit; |
| 952 | struct qed_sp_init_data init_data; |
| 953 | struct qed_spq_entry *p_ent; |
| 954 | u32 returned_id, start_cid; |
| 955 | int rc; |
| 956 | |
| 957 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "cq_handle = %08x%08x\n", |
| 958 | params->cq_handle_hi, params->cq_handle_lo); |
| 959 | |
| 960 | /* Allocate icid */ |
| 961 | spin_lock_bh(&p_info->lock); |
| 962 | rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_info->cq_map, &returned_id); |
| 963 | spin_unlock_bh(&p_info->lock); |
| 964 | |
| 965 | if (rc) { |
| 966 | DP_NOTICE(p_hwfn, "Can't create CQ, rc = %d\n", rc); |
| 967 | return rc; |
| 968 | } |
| 969 | |
| 970 | start_cid = qed_cxt_get_proto_cid_start(p_hwfn, |
| 971 | p_info->proto); |
| 972 | *icid = returned_id + start_cid; |
| 973 | |
| 974 | /* Check if icid requires a page allocation */ |
| 975 | rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_CXT, *icid); |
| 976 | if (rc) |
| 977 | goto err; |
| 978 | |
| 979 | /* Get SPQ entry */ |
| 980 | memset(&init_data, 0, sizeof(init_data)); |
| 981 | init_data.cid = *icid; |
| 982 | init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; |
| 983 | init_data.comp_mode = QED_SPQ_MODE_EBLOCK; |
| 984 | |
| 985 | /* Send create CQ ramrod */ |
| 986 | rc = qed_sp_init_request(p_hwfn, &p_ent, |
| 987 | RDMA_RAMROD_CREATE_CQ, |
| 988 | p_info->proto, &init_data); |
| 989 | if (rc) |
| 990 | goto err; |
| 991 | |
| 992 | p_ramrod = &p_ent->ramrod.rdma_create_cq; |
| 993 | |
| 994 | p_ramrod->cq_handle.hi = cpu_to_le32(params->cq_handle_hi); |
| 995 | p_ramrod->cq_handle.lo = cpu_to_le32(params->cq_handle_lo); |
| 996 | p_ramrod->dpi = cpu_to_le16(params->dpi); |
| 997 | p_ramrod->is_two_level_pbl = params->pbl_two_level; |
| 998 | p_ramrod->max_cqes = cpu_to_le32(params->cq_size); |
| 999 | DMA_REGPAIR_LE(p_ramrod->pbl_addr, params->pbl_ptr); |
| 1000 | p_ramrod->pbl_num_pages = cpu_to_le16(params->pbl_num_pages); |
| 1001 | p_ramrod->cnq_id = (u8)RESC_START(p_hwfn, QED_RDMA_CNQ_RAM) + |
| 1002 | params->cnq_id; |
| 1003 | p_ramrod->int_timeout = params->int_timeout; |
| 1004 | |
| 1005 | /* toggle the bit for every resize or create cq for a given icid */ |
| 1006 | toggle_bit = qed_rdma_toggle_bit_create_resize_cq(p_hwfn, *icid); |
| 1007 | |
| 1008 | p_ramrod->toggle_bit = toggle_bit; |
| 1009 | |
| 1010 | rc = qed_spq_post(p_hwfn, p_ent, NULL); |
| 1011 | if (rc) { |
| 1012 | /* restore toggle bit */ |
| 1013 | qed_rdma_toggle_bit_create_resize_cq(p_hwfn, *icid); |
| 1014 | goto err; |
| 1015 | } |
| 1016 | |
| 1017 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Created CQ, rc = %d\n", rc); |
| 1018 | return rc; |
| 1019 | |
| 1020 | err: |
| 1021 | /* release allocated icid */ |
| 1022 | spin_lock_bh(&p_info->lock); |
| 1023 | qed_bmap_release_id(p_hwfn, &p_info->cq_map, returned_id); |
| 1024 | spin_unlock_bh(&p_info->lock); |
| 1025 | DP_NOTICE(p_hwfn, "Create CQ failed, rc = %d\n", rc); |
| 1026 | |
| 1027 | return rc; |
| 1028 | } |
| 1029 | |
| 1030 | static int |
| 1031 | qed_rdma_destroy_cq(void *rdma_cxt, |
| 1032 | struct qed_rdma_destroy_cq_in_params *in_params, |
| 1033 | struct qed_rdma_destroy_cq_out_params *out_params) |
| 1034 | { |
| 1035 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1036 | struct rdma_destroy_cq_output_params *p_ramrod_res; |
| 1037 | struct rdma_destroy_cq_ramrod_data *p_ramrod; |
| 1038 | struct qed_sp_init_data init_data; |
| 1039 | struct qed_spq_entry *p_ent; |
| 1040 | dma_addr_t ramrod_res_phys; |
| 1041 | enum protocol_type proto; |
| 1042 | int rc = -ENOMEM; |
| 1043 | |
| 1044 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", in_params->icid); |
| 1045 | |
| 1046 | p_ramrod_res = |
| 1047 | (struct rdma_destroy_cq_output_params *) |
| 1048 | dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, |
| 1049 | sizeof(struct rdma_destroy_cq_output_params), |
| 1050 | &ramrod_res_phys, GFP_KERNEL); |
| 1051 | if (!p_ramrod_res) { |
| 1052 | DP_NOTICE(p_hwfn, |
| 1053 | "qed destroy cq failed: cannot allocate memory (ramrod)\n"); |
| 1054 | return rc; |
| 1055 | } |
| 1056 | |
| 1057 | /* Get SPQ entry */ |
| 1058 | memset(&init_data, 0, sizeof(init_data)); |
| 1059 | init_data.cid = in_params->icid; |
| 1060 | init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; |
| 1061 | init_data.comp_mode = QED_SPQ_MODE_EBLOCK; |
| 1062 | proto = p_hwfn->p_rdma_info->proto; |
| 1063 | /* Send destroy CQ ramrod */ |
| 1064 | rc = qed_sp_init_request(p_hwfn, &p_ent, |
| 1065 | RDMA_RAMROD_DESTROY_CQ, |
| 1066 | proto, &init_data); |
| 1067 | if (rc) |
| 1068 | goto err; |
| 1069 | |
| 1070 | p_ramrod = &p_ent->ramrod.rdma_destroy_cq; |
| 1071 | DMA_REGPAIR_LE(p_ramrod->output_params_addr, ramrod_res_phys); |
| 1072 | |
| 1073 | rc = qed_spq_post(p_hwfn, p_ent, NULL); |
| 1074 | if (rc) |
| 1075 | goto err; |
| 1076 | |
| 1077 | out_params->num_cq_notif = le16_to_cpu(p_ramrod_res->cnq_num); |
| 1078 | |
| 1079 | dma_free_coherent(&p_hwfn->cdev->pdev->dev, |
| 1080 | sizeof(struct rdma_destroy_cq_output_params), |
| 1081 | p_ramrod_res, ramrod_res_phys); |
| 1082 | |
| 1083 | /* Free icid */ |
| 1084 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 1085 | |
| 1086 | qed_bmap_release_id(p_hwfn, |
| 1087 | &p_hwfn->p_rdma_info->cq_map, |
| 1088 | (in_params->icid - |
| 1089 | qed_cxt_get_proto_cid_start(p_hwfn, proto))); |
| 1090 | |
| 1091 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 1092 | |
| 1093 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Destroyed CQ, rc = %d\n", rc); |
| 1094 | return rc; |
| 1095 | |
| 1096 | err: dma_free_coherent(&p_hwfn->cdev->pdev->dev, |
| 1097 | sizeof(struct rdma_destroy_cq_output_params), |
| 1098 | p_ramrod_res, ramrod_res_phys); |
| 1099 | |
| 1100 | return rc; |
| 1101 | } |
| 1102 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 1103 | void qed_rdma_set_fw_mac(u16 *p_fw_mac, u8 *p_qed_mac) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1104 | { |
| 1105 | p_fw_mac[0] = cpu_to_le16((p_qed_mac[0] << 8) + p_qed_mac[1]); |
| 1106 | p_fw_mac[1] = cpu_to_le16((p_qed_mac[2] << 8) + p_qed_mac[3]); |
| 1107 | p_fw_mac[2] = cpu_to_le16((p_qed_mac[4] << 8) + p_qed_mac[5]); |
| 1108 | } |
| 1109 | |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1110 | static int qed_rdma_query_qp(void *rdma_cxt, |
| 1111 | struct qed_rdma_qp *qp, |
| 1112 | struct qed_rdma_query_qp_out_params *out_params) |
| 1113 | { |
| 1114 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1115 | int rc; |
| 1116 | |
| 1117 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); |
| 1118 | |
| 1119 | /* The following fields are filled in from qp and not FW as they can't |
| 1120 | * be modified by FW |
| 1121 | */ |
| 1122 | out_params->mtu = qp->mtu; |
| 1123 | out_params->dest_qp = qp->dest_qp; |
| 1124 | out_params->incoming_atomic_en = qp->incoming_atomic_en; |
| 1125 | out_params->e2e_flow_control_en = qp->e2e_flow_control_en; |
| 1126 | out_params->incoming_rdma_read_en = qp->incoming_rdma_read_en; |
| 1127 | out_params->incoming_rdma_write_en = qp->incoming_rdma_write_en; |
| 1128 | out_params->dgid = qp->dgid; |
| 1129 | out_params->flow_label = qp->flow_label; |
| 1130 | out_params->hop_limit_ttl = qp->hop_limit_ttl; |
| 1131 | out_params->traffic_class_tos = qp->traffic_class_tos; |
| 1132 | out_params->timeout = qp->ack_timeout; |
| 1133 | out_params->rnr_retry = qp->rnr_retry_cnt; |
| 1134 | out_params->retry_cnt = qp->retry_cnt; |
| 1135 | out_params->min_rnr_nak_timer = qp->min_rnr_nak_timer; |
| 1136 | out_params->pkey_index = 0; |
| 1137 | out_params->max_rd_atomic = qp->max_rd_atomic_req; |
| 1138 | out_params->max_dest_rd_atomic = qp->max_rd_atomic_resp; |
| 1139 | out_params->sqd_async = qp->sqd_async; |
| 1140 | |
| 1141 | rc = qed_roce_query_qp(p_hwfn, qp, out_params); |
| 1142 | |
| 1143 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Query QP, rc = %d\n", rc); |
| 1144 | return rc; |
| 1145 | } |
| 1146 | |
| 1147 | static int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp) |
| 1148 | { |
| 1149 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1150 | int rc = 0; |
| 1151 | |
| 1152 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); |
| 1153 | |
| 1154 | rc = qed_roce_destroy_qp(p_hwfn, qp); |
| 1155 | |
| 1156 | /* free qp params struct */ |
| 1157 | kfree(qp); |
| 1158 | |
| 1159 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "QP destroyed\n"); |
| 1160 | return rc; |
| 1161 | } |
| 1162 | |
| 1163 | static struct qed_rdma_qp * |
| 1164 | qed_rdma_create_qp(void *rdma_cxt, |
| 1165 | struct qed_rdma_create_qp_in_params *in_params, |
| 1166 | struct qed_rdma_create_qp_out_params *out_params) |
| 1167 | { |
| 1168 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1169 | struct qed_rdma_qp *qp; |
| 1170 | u8 max_stats_queues; |
| 1171 | int rc; |
| 1172 | |
| 1173 | if (!rdma_cxt || !in_params || !out_params || !p_hwfn->p_rdma_info) { |
| 1174 | DP_ERR(p_hwfn->cdev, |
| 1175 | "qed roce create qp failed due to NULL entry (rdma_cxt=%p, in=%p, out=%p, roce_info=?\n", |
| 1176 | rdma_cxt, in_params, out_params); |
| 1177 | return NULL; |
| 1178 | } |
| 1179 | |
| 1180 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 1181 | "qed rdma create qp called with qp_handle = %08x%08x\n", |
| 1182 | in_params->qp_handle_hi, in_params->qp_handle_lo); |
| 1183 | |
| 1184 | /* Some sanity checks... */ |
| 1185 | max_stats_queues = p_hwfn->p_rdma_info->dev->max_stats_queues; |
| 1186 | if (in_params->stats_queue >= max_stats_queues) { |
| 1187 | DP_ERR(p_hwfn->cdev, |
| 1188 | "qed rdma create qp failed due to invalid statistics queue %d. maximum is %d\n", |
| 1189 | in_params->stats_queue, max_stats_queues); |
| 1190 | return NULL; |
| 1191 | } |
| 1192 | |
| 1193 | qp = kzalloc(sizeof(*qp), GFP_KERNEL); |
| 1194 | if (!qp) |
| 1195 | return NULL; |
| 1196 | |
| 1197 | rc = qed_roce_alloc_cid(p_hwfn, &qp->icid); |
| 1198 | qp->qpid = ((0xFF << 16) | qp->icid); |
| 1199 | |
| 1200 | DP_INFO(p_hwfn, "ROCE qpid=%x\n", qp->qpid); |
| 1201 | |
| 1202 | if (rc) { |
| 1203 | kfree(qp); |
| 1204 | return NULL; |
| 1205 | } |
| 1206 | |
| 1207 | qp->cur_state = QED_ROCE_QP_STATE_RESET; |
| 1208 | qp->qp_handle.hi = cpu_to_le32(in_params->qp_handle_hi); |
| 1209 | qp->qp_handle.lo = cpu_to_le32(in_params->qp_handle_lo); |
| 1210 | qp->qp_handle_async.hi = cpu_to_le32(in_params->qp_handle_async_hi); |
| 1211 | qp->qp_handle_async.lo = cpu_to_le32(in_params->qp_handle_async_lo); |
| 1212 | qp->use_srq = in_params->use_srq; |
| 1213 | qp->signal_all = in_params->signal_all; |
| 1214 | qp->fmr_and_reserved_lkey = in_params->fmr_and_reserved_lkey; |
| 1215 | qp->pd = in_params->pd; |
| 1216 | qp->dpi = in_params->dpi; |
| 1217 | qp->sq_cq_id = in_params->sq_cq_id; |
| 1218 | qp->sq_num_pages = in_params->sq_num_pages; |
| 1219 | qp->sq_pbl_ptr = in_params->sq_pbl_ptr; |
| 1220 | qp->rq_cq_id = in_params->rq_cq_id; |
| 1221 | qp->rq_num_pages = in_params->rq_num_pages; |
| 1222 | qp->rq_pbl_ptr = in_params->rq_pbl_ptr; |
| 1223 | qp->srq_id = in_params->srq_id; |
| 1224 | qp->req_offloaded = false; |
| 1225 | qp->resp_offloaded = false; |
| 1226 | qp->e2e_flow_control_en = qp->use_srq ? false : true; |
| 1227 | qp->stats_queue = in_params->stats_queue; |
| 1228 | |
| 1229 | out_params->icid = qp->icid; |
| 1230 | out_params->qp_id = qp->qpid; |
| 1231 | |
| 1232 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Create QP, rc = %d\n", rc); |
| 1233 | return qp; |
| 1234 | } |
| 1235 | |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1236 | static int qed_rdma_modify_qp(void *rdma_cxt, |
| 1237 | struct qed_rdma_qp *qp, |
| 1238 | struct qed_rdma_modify_qp_in_params *params) |
| 1239 | { |
| 1240 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1241 | enum qed_roce_qp_state prev_state; |
| 1242 | int rc = 0; |
| 1243 | |
| 1244 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x params->new_state=%d\n", |
| 1245 | qp->icid, params->new_state); |
| 1246 | |
| 1247 | if (rc) { |
| 1248 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); |
| 1249 | return rc; |
| 1250 | } |
| 1251 | |
| 1252 | if (GET_FIELD(params->modify_flags, |
| 1253 | QED_RDMA_MODIFY_QP_VALID_RDMA_OPS_EN)) { |
| 1254 | qp->incoming_rdma_read_en = params->incoming_rdma_read_en; |
| 1255 | qp->incoming_rdma_write_en = params->incoming_rdma_write_en; |
| 1256 | qp->incoming_atomic_en = params->incoming_atomic_en; |
| 1257 | } |
| 1258 | |
| 1259 | /* Update QP structure with the updated values */ |
| 1260 | if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_ROCE_MODE)) |
| 1261 | qp->roce_mode = params->roce_mode; |
| 1262 | if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_PKEY)) |
| 1263 | qp->pkey = params->pkey; |
| 1264 | if (GET_FIELD(params->modify_flags, |
| 1265 | QED_ROCE_MODIFY_QP_VALID_E2E_FLOW_CONTROL_EN)) |
| 1266 | qp->e2e_flow_control_en = params->e2e_flow_control_en; |
| 1267 | if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_DEST_QP)) |
| 1268 | qp->dest_qp = params->dest_qp; |
| 1269 | if (GET_FIELD(params->modify_flags, |
| 1270 | QED_ROCE_MODIFY_QP_VALID_ADDRESS_VECTOR)) { |
| 1271 | /* Indicates that the following parameters have changed: |
| 1272 | * Traffic class, flow label, hop limit, source GID, |
| 1273 | * destination GID, loopback indicator |
| 1274 | */ |
| 1275 | qp->traffic_class_tos = params->traffic_class_tos; |
| 1276 | qp->flow_label = params->flow_label; |
| 1277 | qp->hop_limit_ttl = params->hop_limit_ttl; |
| 1278 | |
| 1279 | qp->sgid = params->sgid; |
| 1280 | qp->dgid = params->dgid; |
| 1281 | qp->udp_src_port = 0; |
| 1282 | qp->vlan_id = params->vlan_id; |
| 1283 | qp->mtu = params->mtu; |
| 1284 | qp->lb_indication = params->lb_indication; |
| 1285 | memcpy((u8 *)&qp->remote_mac_addr[0], |
| 1286 | (u8 *)¶ms->remote_mac_addr[0], ETH_ALEN); |
| 1287 | if (params->use_local_mac) { |
| 1288 | memcpy((u8 *)&qp->local_mac_addr[0], |
| 1289 | (u8 *)¶ms->local_mac_addr[0], ETH_ALEN); |
| 1290 | } else { |
| 1291 | memcpy((u8 *)&qp->local_mac_addr[0], |
| 1292 | (u8 *)&p_hwfn->hw_info.hw_mac_addr, ETH_ALEN); |
| 1293 | } |
| 1294 | } |
| 1295 | if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_RQ_PSN)) |
| 1296 | qp->rq_psn = params->rq_psn; |
| 1297 | if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_SQ_PSN)) |
| 1298 | qp->sq_psn = params->sq_psn; |
| 1299 | if (GET_FIELD(params->modify_flags, |
| 1300 | QED_RDMA_MODIFY_QP_VALID_MAX_RD_ATOMIC_REQ)) |
| 1301 | qp->max_rd_atomic_req = params->max_rd_atomic_req; |
| 1302 | if (GET_FIELD(params->modify_flags, |
| 1303 | QED_RDMA_MODIFY_QP_VALID_MAX_RD_ATOMIC_RESP)) |
| 1304 | qp->max_rd_atomic_resp = params->max_rd_atomic_resp; |
| 1305 | if (GET_FIELD(params->modify_flags, |
| 1306 | QED_ROCE_MODIFY_QP_VALID_ACK_TIMEOUT)) |
| 1307 | qp->ack_timeout = params->ack_timeout; |
| 1308 | if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_RETRY_CNT)) |
| 1309 | qp->retry_cnt = params->retry_cnt; |
| 1310 | if (GET_FIELD(params->modify_flags, |
| 1311 | QED_ROCE_MODIFY_QP_VALID_RNR_RETRY_CNT)) |
| 1312 | qp->rnr_retry_cnt = params->rnr_retry_cnt; |
| 1313 | if (GET_FIELD(params->modify_flags, |
| 1314 | QED_ROCE_MODIFY_QP_VALID_MIN_RNR_NAK_TIMER)) |
| 1315 | qp->min_rnr_nak_timer = params->min_rnr_nak_timer; |
| 1316 | |
| 1317 | qp->sqd_async = params->sqd_async; |
| 1318 | |
| 1319 | prev_state = qp->cur_state; |
| 1320 | if (GET_FIELD(params->modify_flags, |
| 1321 | QED_RDMA_MODIFY_QP_VALID_NEW_STATE)) { |
| 1322 | qp->cur_state = params->new_state; |
| 1323 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "qp->cur_state=%d\n", |
| 1324 | qp->cur_state); |
| 1325 | } |
| 1326 | |
| 1327 | rc = qed_roce_modify_qp(p_hwfn, qp, prev_state, params); |
| 1328 | |
| 1329 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Modify QP, rc = %d\n", rc); |
| 1330 | return rc; |
| 1331 | } |
| 1332 | |
| 1333 | static int |
| 1334 | qed_rdma_register_tid(void *rdma_cxt, |
| 1335 | struct qed_rdma_register_tid_in_params *params) |
| 1336 | { |
| 1337 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1338 | struct rdma_register_tid_ramrod_data *p_ramrod; |
| 1339 | struct qed_sp_init_data init_data; |
| 1340 | struct qed_spq_entry *p_ent; |
| 1341 | enum rdma_tid_type tid_type; |
| 1342 | u8 fw_return_code; |
| 1343 | int rc; |
| 1344 | |
| 1345 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", params->itid); |
| 1346 | |
| 1347 | /* Get SPQ entry */ |
| 1348 | memset(&init_data, 0, sizeof(init_data)); |
| 1349 | init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; |
| 1350 | init_data.comp_mode = QED_SPQ_MODE_EBLOCK; |
| 1351 | |
| 1352 | rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_REGISTER_MR, |
| 1353 | p_hwfn->p_rdma_info->proto, &init_data); |
| 1354 | if (rc) { |
| 1355 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); |
| 1356 | return rc; |
| 1357 | } |
| 1358 | |
| 1359 | if (p_hwfn->p_rdma_info->last_tid < params->itid) |
| 1360 | p_hwfn->p_rdma_info->last_tid = params->itid; |
| 1361 | |
| 1362 | p_ramrod = &p_ent->ramrod.rdma_register_tid; |
| 1363 | |
| 1364 | p_ramrod->flags = 0; |
| 1365 | SET_FIELD(p_ramrod->flags, |
| 1366 | RDMA_REGISTER_TID_RAMROD_DATA_TWO_LEVEL_PBL, |
| 1367 | params->pbl_two_level); |
| 1368 | |
| 1369 | SET_FIELD(p_ramrod->flags, |
| 1370 | RDMA_REGISTER_TID_RAMROD_DATA_ZERO_BASED, params->zbva); |
| 1371 | |
| 1372 | SET_FIELD(p_ramrod->flags, |
| 1373 | RDMA_REGISTER_TID_RAMROD_DATA_PHY_MR, params->phy_mr); |
| 1374 | |
| 1375 | /* Don't initialize D/C field, as it may override other bits. */ |
| 1376 | if (!(params->tid_type == QED_RDMA_TID_FMR) && !(params->dma_mr)) |
| 1377 | SET_FIELD(p_ramrod->flags, |
| 1378 | RDMA_REGISTER_TID_RAMROD_DATA_PAGE_SIZE_LOG, |
| 1379 | params->page_size_log - 12); |
| 1380 | |
| 1381 | SET_FIELD(p_ramrod->flags, |
| 1382 | RDMA_REGISTER_TID_RAMROD_DATA_REMOTE_READ, |
| 1383 | params->remote_read); |
| 1384 | |
| 1385 | SET_FIELD(p_ramrod->flags, |
| 1386 | RDMA_REGISTER_TID_RAMROD_DATA_REMOTE_WRITE, |
| 1387 | params->remote_write); |
| 1388 | |
| 1389 | SET_FIELD(p_ramrod->flags, |
| 1390 | RDMA_REGISTER_TID_RAMROD_DATA_REMOTE_ATOMIC, |
| 1391 | params->remote_atomic); |
| 1392 | |
| 1393 | SET_FIELD(p_ramrod->flags, |
| 1394 | RDMA_REGISTER_TID_RAMROD_DATA_LOCAL_WRITE, |
| 1395 | params->local_write); |
| 1396 | |
| 1397 | SET_FIELD(p_ramrod->flags, |
| 1398 | RDMA_REGISTER_TID_RAMROD_DATA_LOCAL_READ, params->local_read); |
| 1399 | |
| 1400 | SET_FIELD(p_ramrod->flags, |
| 1401 | RDMA_REGISTER_TID_RAMROD_DATA_ENABLE_MW_BIND, |
| 1402 | params->mw_bind); |
| 1403 | |
| 1404 | SET_FIELD(p_ramrod->flags1, |
| 1405 | RDMA_REGISTER_TID_RAMROD_DATA_PBL_PAGE_SIZE_LOG, |
| 1406 | params->pbl_page_size_log - 12); |
| 1407 | |
| 1408 | SET_FIELD(p_ramrod->flags2, |
| 1409 | RDMA_REGISTER_TID_RAMROD_DATA_DMA_MR, params->dma_mr); |
| 1410 | |
| 1411 | switch (params->tid_type) { |
| 1412 | case QED_RDMA_TID_REGISTERED_MR: |
| 1413 | tid_type = RDMA_TID_REGISTERED_MR; |
| 1414 | break; |
| 1415 | case QED_RDMA_TID_FMR: |
| 1416 | tid_type = RDMA_TID_FMR; |
| 1417 | break; |
| 1418 | case QED_RDMA_TID_MW_TYPE1: |
| 1419 | tid_type = RDMA_TID_MW_TYPE1; |
| 1420 | break; |
| 1421 | case QED_RDMA_TID_MW_TYPE2A: |
| 1422 | tid_type = RDMA_TID_MW_TYPE2A; |
| 1423 | break; |
| 1424 | default: |
| 1425 | rc = -EINVAL; |
| 1426 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); |
| 1427 | return rc; |
| 1428 | } |
| 1429 | SET_FIELD(p_ramrod->flags1, |
| 1430 | RDMA_REGISTER_TID_RAMROD_DATA_TID_TYPE, tid_type); |
| 1431 | |
| 1432 | p_ramrod->itid = cpu_to_le32(params->itid); |
| 1433 | p_ramrod->key = params->key; |
| 1434 | p_ramrod->pd = cpu_to_le16(params->pd); |
| 1435 | p_ramrod->length_hi = (u8)(params->length >> 32); |
| 1436 | p_ramrod->length_lo = DMA_LO_LE(params->length); |
| 1437 | if (params->zbva) { |
| 1438 | /* Lower 32 bits of the registered MR address. |
| 1439 | * In case of zero based MR, will hold FBO |
| 1440 | */ |
| 1441 | p_ramrod->va.hi = 0; |
| 1442 | p_ramrod->va.lo = cpu_to_le32(params->fbo); |
| 1443 | } else { |
| 1444 | DMA_REGPAIR_LE(p_ramrod->va, params->vaddr); |
| 1445 | } |
| 1446 | DMA_REGPAIR_LE(p_ramrod->pbl_base, params->pbl_ptr); |
| 1447 | |
| 1448 | /* DIF */ |
| 1449 | if (params->dif_enabled) { |
| 1450 | SET_FIELD(p_ramrod->flags2, |
| 1451 | RDMA_REGISTER_TID_RAMROD_DATA_DIF_ON_HOST_FLG, 1); |
| 1452 | DMA_REGPAIR_LE(p_ramrod->dif_error_addr, |
| 1453 | params->dif_error_addr); |
| 1454 | DMA_REGPAIR_LE(p_ramrod->dif_runt_addr, params->dif_runt_addr); |
| 1455 | } |
| 1456 | |
| 1457 | rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); |
| 1458 | if (rc) |
| 1459 | return rc; |
| 1460 | |
| 1461 | if (fw_return_code != RDMA_RETURN_OK) { |
| 1462 | DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code); |
| 1463 | return -EINVAL; |
| 1464 | } |
| 1465 | |
| 1466 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Register TID, rc = %d\n", rc); |
| 1467 | return rc; |
| 1468 | } |
| 1469 | |
| 1470 | static int qed_rdma_deregister_tid(void *rdma_cxt, u32 itid) |
| 1471 | { |
| 1472 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1473 | struct rdma_deregister_tid_ramrod_data *p_ramrod; |
| 1474 | struct qed_sp_init_data init_data; |
| 1475 | struct qed_spq_entry *p_ent; |
| 1476 | struct qed_ptt *p_ptt; |
| 1477 | u8 fw_return_code; |
| 1478 | int rc; |
| 1479 | |
| 1480 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", itid); |
| 1481 | |
| 1482 | /* Get SPQ entry */ |
| 1483 | memset(&init_data, 0, sizeof(init_data)); |
| 1484 | init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; |
| 1485 | init_data.comp_mode = QED_SPQ_MODE_EBLOCK; |
| 1486 | |
| 1487 | rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_DEREGISTER_MR, |
| 1488 | p_hwfn->p_rdma_info->proto, &init_data); |
| 1489 | if (rc) { |
| 1490 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); |
| 1491 | return rc; |
| 1492 | } |
| 1493 | |
| 1494 | p_ramrod = &p_ent->ramrod.rdma_deregister_tid; |
| 1495 | p_ramrod->itid = cpu_to_le32(itid); |
| 1496 | |
| 1497 | rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); |
| 1498 | if (rc) { |
| 1499 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); |
| 1500 | return rc; |
| 1501 | } |
| 1502 | |
| 1503 | if (fw_return_code == RDMA_RETURN_DEREGISTER_MR_BAD_STATE_ERR) { |
| 1504 | DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code); |
| 1505 | return -EINVAL; |
| 1506 | } else if (fw_return_code == RDMA_RETURN_NIG_DRAIN_REQ) { |
| 1507 | /* Bit indicating that the TID is in use and a nig drain is |
| 1508 | * required before sending the ramrod again |
| 1509 | */ |
| 1510 | p_ptt = qed_ptt_acquire(p_hwfn); |
| 1511 | if (!p_ptt) { |
| 1512 | rc = -EBUSY; |
| 1513 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 1514 | "Failed to acquire PTT\n"); |
| 1515 | return rc; |
| 1516 | } |
| 1517 | |
| 1518 | rc = qed_mcp_drain(p_hwfn, p_ptt); |
| 1519 | if (rc) { |
| 1520 | qed_ptt_release(p_hwfn, p_ptt); |
| 1521 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 1522 | "Drain failed\n"); |
| 1523 | return rc; |
| 1524 | } |
| 1525 | |
| 1526 | qed_ptt_release(p_hwfn, p_ptt); |
| 1527 | |
| 1528 | /* Resend the ramrod */ |
| 1529 | rc = qed_sp_init_request(p_hwfn, &p_ent, |
| 1530 | RDMA_RAMROD_DEREGISTER_MR, |
| 1531 | p_hwfn->p_rdma_info->proto, |
| 1532 | &init_data); |
| 1533 | if (rc) { |
| 1534 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 1535 | "Failed to init sp-element\n"); |
| 1536 | return rc; |
| 1537 | } |
| 1538 | |
| 1539 | rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); |
| 1540 | if (rc) { |
| 1541 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 1542 | "Ramrod failed\n"); |
| 1543 | return rc; |
| 1544 | } |
| 1545 | |
| 1546 | if (fw_return_code != RDMA_RETURN_OK) { |
| 1547 | DP_NOTICE(p_hwfn, "fw_return_code = %d\n", |
| 1548 | fw_return_code); |
| 1549 | return rc; |
| 1550 | } |
| 1551 | } |
| 1552 | |
| 1553 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "De-registered TID, rc = %d\n", rc); |
| 1554 | return rc; |
| 1555 | } |
| 1556 | |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1557 | static void *qed_rdma_get_rdma_ctx(struct qed_dev *cdev) |
| 1558 | { |
| 1559 | return QED_LEADING_HWFN(cdev); |
| 1560 | } |
| 1561 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 1562 | bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1563 | { |
| 1564 | bool result; |
| 1565 | |
| 1566 | /* if rdma info has not been allocated, naturally there are no qps */ |
| 1567 | if (!p_hwfn->p_rdma_info) |
| 1568 | return false; |
| 1569 | |
| 1570 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 1571 | if (!p_hwfn->p_rdma_info->cid_map.bitmap) |
| 1572 | result = false; |
| 1573 | else |
| 1574 | result = !qed_bmap_is_empty(&p_hwfn->p_rdma_info->cid_map); |
| 1575 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 1576 | return result; |
| 1577 | } |
| 1578 | |
Kalderon, Michal | b71b9af | 2017-06-21 16:22:45 +0300 | [diff] [blame^] | 1579 | void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1580 | { |
| 1581 | u32 val; |
| 1582 | |
| 1583 | val = (p_hwfn->dcbx_no_edpm || p_hwfn->db_bar_no_edpm) ? 0 : 1; |
| 1584 | |
| 1585 | qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_DPM_ENABLE, val); |
| 1586 | DP_VERBOSE(p_hwfn, (QED_MSG_DCB | QED_MSG_RDMA), |
| 1587 | "Changing DPM_EN state to %d (DCBX=%d, DB_BAR=%d)\n", |
| 1588 | val, p_hwfn->dcbx_no_edpm, p_hwfn->db_bar_no_edpm); |
| 1589 | } |
| 1590 | |
Kalderon, Michal | f1372ee | 2017-06-21 16:22:44 +0300 | [diff] [blame] | 1591 | |
| 1592 | void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
| 1593 | { |
| 1594 | p_hwfn->db_bar_no_edpm = true; |
| 1595 | |
| 1596 | qed_rdma_dpm_conf(p_hwfn, p_ptt); |
| 1597 | } |
| 1598 | |
| 1599 | static int qed_rdma_start(void *rdma_cxt, |
| 1600 | struct qed_rdma_start_in_params *params) |
| 1601 | { |
| 1602 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1603 | struct qed_ptt *p_ptt; |
| 1604 | int rc = -EBUSY; |
| 1605 | |
| 1606 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 1607 | "desired_cnq = %08x\n", params->desired_cnq); |
| 1608 | |
| 1609 | p_ptt = qed_ptt_acquire(p_hwfn); |
| 1610 | if (!p_ptt) |
| 1611 | goto err; |
| 1612 | |
| 1613 | rc = qed_rdma_alloc(p_hwfn, p_ptt, params); |
| 1614 | if (rc) |
| 1615 | goto err1; |
| 1616 | |
| 1617 | rc = qed_rdma_setup(p_hwfn, p_ptt, params); |
| 1618 | if (rc) |
| 1619 | goto err2; |
| 1620 | |
| 1621 | qed_ptt_release(p_hwfn, p_ptt); |
| 1622 | |
| 1623 | return rc; |
| 1624 | |
| 1625 | err2: |
| 1626 | qed_rdma_free(p_hwfn); |
| 1627 | err1: |
| 1628 | qed_ptt_release(p_hwfn, p_ptt); |
| 1629 | err: |
| 1630 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA start - error, rc = %d\n", rc); |
| 1631 | return rc; |
| 1632 | } |
| 1633 | |
| 1634 | static int qed_rdma_init(struct qed_dev *cdev, |
| 1635 | struct qed_rdma_start_in_params *params) |
| 1636 | { |
| 1637 | return qed_rdma_start(QED_LEADING_HWFN(cdev), params); |
| 1638 | } |
| 1639 | |
| 1640 | static void qed_rdma_remove_user(void *rdma_cxt, u16 dpi) |
| 1641 | { |
| 1642 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; |
| 1643 | |
| 1644 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "dpi = %08x\n", dpi); |
| 1645 | |
| 1646 | spin_lock_bh(&p_hwfn->p_rdma_info->lock); |
| 1647 | qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, dpi); |
| 1648 | spin_unlock_bh(&p_hwfn->p_rdma_info->lock); |
| 1649 | } |
| 1650 | |
| 1651 | static int qed_roce_ll2_set_mac_filter(struct qed_dev *cdev, |
| 1652 | u8 *old_mac_address, |
| 1653 | u8 *new_mac_address) |
| 1654 | { |
| 1655 | struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); |
| 1656 | struct qed_ptt *p_ptt; |
| 1657 | int rc = 0; |
| 1658 | |
| 1659 | p_ptt = qed_ptt_acquire(p_hwfn); |
| 1660 | if (!p_ptt) { |
| 1661 | DP_ERR(cdev, |
| 1662 | "qed roce ll2 mac filter set: failed to acquire PTT\n"); |
| 1663 | return -EINVAL; |
| 1664 | } |
| 1665 | |
| 1666 | if (old_mac_address) |
| 1667 | qed_llh_remove_mac_filter(p_hwfn, p_ptt, old_mac_address); |
| 1668 | if (new_mac_address) |
| 1669 | rc = qed_llh_add_mac_filter(p_hwfn, p_ptt, new_mac_address); |
| 1670 | |
| 1671 | qed_ptt_release(p_hwfn, p_ptt); |
| 1672 | |
| 1673 | if (rc) |
| 1674 | DP_ERR(cdev, |
| 1675 | "qed roce ll2 mac filter set: failed to add MAC filter\n"); |
| 1676 | |
| 1677 | return rc; |
| 1678 | } |
| 1679 | |
| 1680 | static const struct qed_rdma_ops qed_rdma_ops_pass = { |
| 1681 | .common = &qed_common_ops_pass, |
| 1682 | .fill_dev_info = &qed_fill_rdma_dev_info, |
| 1683 | .rdma_get_rdma_ctx = &qed_rdma_get_rdma_ctx, |
| 1684 | .rdma_init = &qed_rdma_init, |
| 1685 | .rdma_add_user = &qed_rdma_add_user, |
| 1686 | .rdma_remove_user = &qed_rdma_remove_user, |
| 1687 | .rdma_stop = &qed_rdma_stop, |
| 1688 | .rdma_query_port = &qed_rdma_query_port, |
| 1689 | .rdma_query_device = &qed_rdma_query_device, |
| 1690 | .rdma_get_start_sb = &qed_rdma_get_sb_start, |
| 1691 | .rdma_get_rdma_int = &qed_rdma_get_int, |
| 1692 | .rdma_set_rdma_int = &qed_rdma_set_int, |
| 1693 | .rdma_get_min_cnq_msix = &qed_rdma_get_min_cnq_msix, |
| 1694 | .rdma_cnq_prod_update = &qed_rdma_cnq_prod_update, |
| 1695 | .rdma_alloc_pd = &qed_rdma_alloc_pd, |
| 1696 | .rdma_dealloc_pd = &qed_rdma_free_pd, |
| 1697 | .rdma_create_cq = &qed_rdma_create_cq, |
| 1698 | .rdma_destroy_cq = &qed_rdma_destroy_cq, |
| 1699 | .rdma_create_qp = &qed_rdma_create_qp, |
| 1700 | .rdma_modify_qp = &qed_rdma_modify_qp, |
| 1701 | .rdma_query_qp = &qed_rdma_query_qp, |
| 1702 | .rdma_destroy_qp = &qed_rdma_destroy_qp, |
| 1703 | .rdma_alloc_tid = &qed_rdma_alloc_tid, |
| 1704 | .rdma_free_tid = &qed_rdma_free_tid, |
| 1705 | .rdma_register_tid = &qed_rdma_register_tid, |
| 1706 | .rdma_deregister_tid = &qed_rdma_deregister_tid, |
| 1707 | .ll2_acquire_connection = &qed_ll2_acquire_connection, |
| 1708 | .ll2_establish_connection = &qed_ll2_establish_connection, |
| 1709 | .ll2_terminate_connection = &qed_ll2_terminate_connection, |
| 1710 | .ll2_release_connection = &qed_ll2_release_connection, |
| 1711 | .ll2_post_rx_buffer = &qed_ll2_post_rx_buffer, |
| 1712 | .ll2_prepare_tx_packet = &qed_ll2_prepare_tx_packet, |
| 1713 | .ll2_set_fragment_of_tx_packet = &qed_ll2_set_fragment_of_tx_packet, |
| 1714 | .ll2_set_mac_filter = &qed_roce_ll2_set_mac_filter, |
| 1715 | .ll2_get_stats = &qed_ll2_get_stats, |
| 1716 | }; |
| 1717 | |
| 1718 | const struct qed_rdma_ops *qed_get_rdma_ops(void) |
| 1719 | { |
| 1720 | return &qed_rdma_ops_pass; |
| 1721 | } |
| 1722 | EXPORT_SYMBOL(qed_get_rdma_ops); |