| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2022 Microsoft Corporation. All rights reserved. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef _MANA_IB_H_ |
| 7 |
#define _MANA_IB_H_ |
| 8 |
|
| 9 |
#include <rdma/ib_verbs.h> |
| 10 |
#include <rdma/ib_mad.h> |
| 11 |
#include <rdma/ib_umem.h> |
| 12 |
#include <rdma/mana-abi.h> |
| 13 |
#include <rdma/uverbs_ioctl.h> |
| 14 |
#include <linux/dmapool.h> |
| 15 |
|
| 16 |
#include <net/mana/mana.h> |
| 17 |
#include "shadow_queue.h" |
| 18 |
#include "counters.h" |
| 19 |
|
| 20 |
#define PAGE_SZ_BM \ |
| 21 |
(SZ_4K | SZ_8K | SZ_16K | SZ_32K | SZ_64K | SZ_128K | SZ_256K | \ |
| 22 |
SZ_512K | SZ_1M | SZ_2M) |
| 23 |
|
| 24 |
/* MANA doesn't have any limit for MR size */ |
| 25 |
#define MANA_IB_MAX_MR_SIZE U64_MAX |
| 26 |
|
| 27 |
/* Send queue ID mask */ |
| 28 |
#define MANA_SENDQ_MASK BIT(31) |
| 29 |
|
| 30 |
/* |
| 31 |
* The hardware limit of number of MRs is greater than maximum number of MRs |
| 32 |
* that can possibly represent in 24 bits |
| 33 |
*/ |
| 34 |
#define MANA_IB_MAX_MR 0xFFFFFFu |
| 35 |
|
| 36 |
/* |
| 37 |
* The CA timeout is approx. 260ms (4us * 2^(DELAY)) |
| 38 |
*/ |
| 39 |
#define MANA_CA_ACK_DELAY 16 |
| 40 |
|
| 41 |
/* |
| 42 |
* The buffer used for writing AV |
| 43 |
*/ |
| 44 |
#define MANA_AV_BUFFER_SIZE 64 |
| 45 |
|
| 46 |
#define MANA_GSI_QPN (1) |
| 47 |
|
| 48 |
struct mana_ib_adapter_caps { |
| 49 |
u32 max_sq_id; |
| 50 |
u32 max_rq_id; |
| 51 |
u32 max_cq_id; |
| 52 |
u32 max_qp_count; |
| 53 |
u32 max_cq_count; |
| 54 |
u32 max_mr_count; |
| 55 |
u32 max_pd_count; |
| 56 |
u32 max_inbound_read_limit; |
| 57 |
u32 max_outbound_read_limit; |
| 58 |
u32 mw_count; |
| 59 |
u32 max_srq_count; |
| 60 |
u32 max_qp_wr; |
| 61 |
u32 max_send_sge_count; |
| 62 |
u32 max_recv_sge_count; |
| 63 |
u32 max_inline_data_size; |
| 64 |
u64 feature_flags; |
| 65 |
u64 page_size_cap; |
| 66 |
}; |
| 67 |
|
| 68 |
struct mana_ib_queue { |
| 69 |
struct ib_umem *umem; |
| 70 |
struct gdma_queue *kmem; |
| 71 |
u64 gdma_region; |
| 72 |
u64 id; |
| 73 |
}; |
| 74 |
|
| 75 |
struct mana_ib_dev { |
| 76 |
struct ib_device ib_dev; |
| 77 |
struct gdma_dev *gdma_dev; |
| 78 |
mana_handle_t adapter_handle; |
| 79 |
struct gdma_queue *fatal_err_eq; |
| 80 |
struct gdma_queue **eqs; |
| 81 |
struct xarray qp_table_wq; |
| 82 |
struct mana_ib_adapter_caps adapter_caps; |
| 83 |
struct dma_pool *av_pool; |
| 84 |
netdevice_tracker dev_tracker; |
| 85 |
struct notifier_block nb; |
| 86 |
}; |
| 87 |
|
| 88 |
struct mana_ib_wq { |
| 89 |
struct ib_wq ibwq; |
| 90 |
struct mana_ib_queue queue; |
| 91 |
int wqe; |
| 92 |
u32 wq_buf_size; |
| 93 |
mana_handle_t rx_object; |
| 94 |
}; |
| 95 |
|
| 96 |
struct mana_ib_pd { |
| 97 |
struct ib_pd ibpd; |
| 98 |
u32 pdn; |
| 99 |
mana_handle_t pd_handle; |
| 100 |
|
| 101 |
/* Mutex for sharing access to vport_use_count */ |
| 102 |
struct mutex vport_mutex; |
| 103 |
int vport_use_count; |
| 104 |
|
| 105 |
bool tx_shortform_allowed; |
| 106 |
u32 tx_vp_offset; |
| 107 |
}; |
| 108 |
|
| 109 |
struct mana_ib_av { |
| 110 |
u8 dest_ip[16]; |
| 111 |
u8 dest_mac[ETH_ALEN]; |
| 112 |
u16 udp_src_port; |
| 113 |
u8 src_ip[16]; |
| 114 |
u32 hop_limit : 8; |
| 115 |
u32 reserved1 : 12; |
| 116 |
u32 dscp : 6; |
| 117 |
u32 reserved2 : 5; |
| 118 |
u32 is_ipv6 : 1; |
| 119 |
u32 reserved3 : 32; |
| 120 |
}; |
| 121 |
|
| 122 |
struct mana_ib_ah { |
| 123 |
struct ib_ah ibah; |
| 124 |
struct mana_ib_av *av; |
| 125 |
dma_addr_t dma_handle; |
| 126 |
}; |
| 127 |
|
| 128 |
struct mana_ib_mr { |
| 129 |
struct ib_mr ibmr; |
| 130 |
struct ib_umem *umem; |
| 131 |
mana_handle_t mr_handle; |
| 132 |
}; |
| 133 |
|
| 134 |
struct mana_ib_dm { |
| 135 |
struct ib_dm ibdm; |
| 136 |
mana_handle_t dm_handle; |
| 137 |
}; |
| 138 |
|
| 139 |
struct mana_ib_cq { |
| 140 |
struct ib_cq ibcq; |
| 141 |
struct mana_ib_queue queue; |
| 142 |
/* protects CQ polling */ |
| 143 |
spinlock_t cq_lock; |
| 144 |
struct list_head list_send_qp; |
| 145 |
struct list_head list_recv_qp; |
| 146 |
int cqe; |
| 147 |
u32 comp_vector; |
| 148 |
mana_handle_t cq_handle; |
| 149 |
}; |
| 150 |
|
| 151 |
enum mana_rc_queue_type { |
| 152 |
MANA_RC_SEND_QUEUE_REQUESTER = 0, |
| 153 |
MANA_RC_SEND_QUEUE_RESPONDER, |
| 154 |
MANA_RC_SEND_QUEUE_FMR, |
| 155 |
MANA_RC_RECV_QUEUE_REQUESTER, |
| 156 |
MANA_RC_RECV_QUEUE_RESPONDER, |
| 157 |
MANA_RC_QUEUE_TYPE_MAX, |
| 158 |
}; |
| 159 |
|
| 160 |
struct mana_ib_rc_qp { |
| 161 |
struct mana_ib_queue queues[MANA_RC_QUEUE_TYPE_MAX]; |
| 162 |
}; |
| 163 |
|
| 164 |
enum mana_ud_queue_type { |
| 165 |
MANA_UD_SEND_QUEUE = 0, |
| 166 |
MANA_UD_RECV_QUEUE, |
| 167 |
MANA_UD_QUEUE_TYPE_MAX, |
| 168 |
}; |
| 169 |
|
| 170 |
struct mana_ib_ud_qp { |
| 171 |
struct mana_ib_queue queues[MANA_UD_QUEUE_TYPE_MAX]; |
| 172 |
u32 sq_psn; |
| 173 |
}; |
| 174 |
|
| 175 |
struct mana_ib_qp { |
| 176 |
struct ib_qp ibqp; |
| 177 |
|
| 178 |
mana_handle_t qp_handle; |
| 179 |
union { |
| 180 |
struct mana_ib_queue raw_sq; |
| 181 |
struct mana_ib_rc_qp rc_qp; |
| 182 |
struct mana_ib_ud_qp ud_qp; |
| 183 |
}; |
| 184 |
|
| 185 |
/* The port on the IB device, starting with 1 */ |
| 186 |
u32 port; |
| 187 |
|
| 188 |
struct list_head cq_send_list; |
| 189 |
struct list_head cq_recv_list; |
| 190 |
struct shadow_queue shadow_rq; |
| 191 |
struct shadow_queue shadow_sq; |
| 192 |
|
| 193 |
refcount_t refcount; |
| 194 |
struct completion free; |
| 195 |
}; |
| 196 |
|
| 197 |
struct mana_ib_ucontext { |
| 198 |
struct ib_ucontext ibucontext; |
| 199 |
u32 doorbell; |
| 200 |
}; |
| 201 |
|
| 202 |
struct mana_ib_rwq_ind_table { |
| 203 |
struct ib_rwq_ind_table ib_ind_table; |
| 204 |
}; |
| 205 |
|
| 206 |
enum mana_ib_command_code { |
| 207 |
MANA_IB_GET_ADAPTER_CAP = 0x30001, |
| 208 |
MANA_IB_CREATE_ADAPTER = 0x30002, |
| 209 |
MANA_IB_DESTROY_ADAPTER = 0x30003, |
| 210 |
MANA_IB_CONFIG_IP_ADDR = 0x30004, |
| 211 |
MANA_IB_CONFIG_MAC_ADDR = 0x30005, |
| 212 |
MANA_IB_CREATE_UD_QP = 0x30006, |
| 213 |
MANA_IB_DESTROY_UD_QP = 0x30007, |
| 214 |
MANA_IB_CREATE_CQ = 0x30008, |
| 215 |
MANA_IB_DESTROY_CQ = 0x30009, |
| 216 |
MANA_IB_CREATE_RC_QP = 0x3000a, |
| 217 |
MANA_IB_DESTROY_RC_QP = 0x3000b, |
| 218 |
MANA_IB_SET_QP_STATE = 0x3000d, |
| 219 |
MANA_IB_QUERY_VF_COUNTERS = 0x30022, |
| 220 |
MANA_IB_QUERY_DEVICE_COUNTERS = 0x30023, |
| 221 |
}; |
| 222 |
|
| 223 |
struct mana_ib_query_adapter_caps_req { |
| 224 |
struct gdma_req_hdr hdr; |
| 225 |
}; /*HW Data */ |
| 226 |
|
| 227 |
enum mana_ib_adapter_features { |
| 228 |
MANA_IB_FEATURE_CLIENT_ERROR_CQE_SUPPORT = BIT(4), |
| 229 |
MANA_IB_FEATURE_DEV_COUNTERS_SUPPORT = BIT(5), |
| 230 |
MANA_IB_FEATURE_MULTI_PORTS_SUPPORT = BIT(6), |
| 231 |
}; |
| 232 |
|
| 233 |
struct mana_ib_query_adapter_caps_resp { |
| 234 |
struct gdma_resp_hdr hdr; |
| 235 |
u32 max_sq_id; |
| 236 |
u32 max_rq_id; |
| 237 |
u32 max_cq_id; |
| 238 |
u32 max_qp_count; |
| 239 |
u32 max_cq_count; |
| 240 |
u32 max_mr_count; |
| 241 |
u32 max_pd_count; |
| 242 |
u32 max_inbound_read_limit; |
| 243 |
u32 max_outbound_read_limit; |
| 244 |
u32 mw_count; |
| 245 |
u32 max_srq_count; |
| 246 |
u32 max_requester_sq_size; |
| 247 |
u32 max_responder_sq_size; |
| 248 |
u32 max_requester_rq_size; |
| 249 |
u32 max_responder_rq_size; |
| 250 |
u32 max_send_sge_count; |
| 251 |
u32 max_recv_sge_count; |
| 252 |
u32 max_inline_data_size; |
| 253 |
u64 feature_flags; |
| 254 |
}; /* HW Data */ |
| 255 |
|
| 256 |
enum mana_ib_adapter_features_request { |
| 257 |
MANA_IB_FEATURE_CLIENT_ERROR_CQE_REQUEST = BIT(1), |
| 258 |
}; /*HW Data */ |
| 259 |
|
| 260 |
struct mana_rnic_create_adapter_req { |
| 261 |
struct gdma_req_hdr hdr; |
| 262 |
u32 notify_eq_id; |
| 263 |
u32 reserved; |
| 264 |
u64 feature_flags; |
| 265 |
}; /*HW Data */ |
| 266 |
|
| 267 |
struct mana_rnic_create_adapter_resp { |
| 268 |
struct gdma_resp_hdr hdr; |
| 269 |
mana_handle_t adapter; |
| 270 |
}; /* HW Data */ |
| 271 |
|
| 272 |
struct mana_rnic_destroy_adapter_req { |
| 273 |
struct gdma_req_hdr hdr; |
| 274 |
mana_handle_t adapter; |
| 275 |
}; /*HW Data */ |
| 276 |
|
| 277 |
struct mana_rnic_destroy_adapter_resp { |
| 278 |
struct gdma_resp_hdr hdr; |
| 279 |
}; /* HW Data */ |
| 280 |
|
| 281 |
enum mana_ib_addr_op { |
| 282 |
ADDR_OP_ADD = 1, |
| 283 |
ADDR_OP_REMOVE = 2, |
| 284 |
}; |
| 285 |
|
| 286 |
enum sgid_entry_type { |
| 287 |
SGID_TYPE_IPV4 = 1, |
| 288 |
SGID_TYPE_IPV6 = 2, |
| 289 |
}; |
| 290 |
|
| 291 |
struct mana_rnic_config_addr_req { |
| 292 |
struct gdma_req_hdr hdr; |
| 293 |
mana_handle_t adapter; |
| 294 |
enum mana_ib_addr_op op; |
| 295 |
enum sgid_entry_type sgid_type; |
| 296 |
u8 ip_addr[16]; |
| 297 |
}; /* HW Data */ |
| 298 |
|
| 299 |
struct mana_rnic_config_addr_resp { |
| 300 |
struct gdma_resp_hdr hdr; |
| 301 |
}; /* HW Data */ |
| 302 |
|
| 303 |
struct mana_rnic_config_mac_addr_req { |
| 304 |
struct gdma_req_hdr hdr; |
| 305 |
mana_handle_t adapter; |
| 306 |
enum mana_ib_addr_op op; |
| 307 |
u8 mac_addr[ETH_ALEN]; |
| 308 |
u8 reserved[6]; |
| 309 |
}; /* HW Data */ |
| 310 |
|
| 311 |
struct mana_rnic_config_mac_addr_resp { |
| 312 |
struct gdma_resp_hdr hdr; |
| 313 |
}; /* HW Data */ |
| 314 |
|
| 315 |
struct mana_rnic_create_cq_req { |
| 316 |
struct gdma_req_hdr hdr; |
| 317 |
mana_handle_t adapter; |
| 318 |
u64 gdma_region; |
| 319 |
u32 eq_id; |
| 320 |
u32 doorbell_page; |
| 321 |
}; /* HW Data */ |
| 322 |
|
| 323 |
struct mana_rnic_create_cq_resp { |
| 324 |
struct gdma_resp_hdr hdr; |
| 325 |
mana_handle_t cq_handle; |
| 326 |
u32 cq_id; |
| 327 |
u32 reserved; |
| 328 |
}; /* HW Data */ |
| 329 |
|
| 330 |
struct mana_rnic_destroy_cq_req { |
| 331 |
struct gdma_req_hdr hdr; |
| 332 |
mana_handle_t adapter; |
| 333 |
mana_handle_t cq_handle; |
| 334 |
}; /* HW Data */ |
| 335 |
|
| 336 |
struct mana_rnic_destroy_cq_resp { |
| 337 |
struct gdma_resp_hdr hdr; |
| 338 |
}; /* HW Data */ |
| 339 |
|
| 340 |
enum mana_rnic_create_rc_flags { |
| 341 |
MANA_RC_FLAG_NO_FMR = 2, |
| 342 |
}; |
| 343 |
|
| 344 |
struct mana_rnic_create_qp_req { |
| 345 |
struct gdma_req_hdr hdr; |
| 346 |
mana_handle_t adapter; |
| 347 |
mana_handle_t pd_handle; |
| 348 |
mana_handle_t send_cq_handle; |
| 349 |
mana_handle_t recv_cq_handle; |
| 350 |
u64 dma_region[MANA_RC_QUEUE_TYPE_MAX]; |
| 351 |
u64 deprecated[2]; |
| 352 |
u64 flags; |
| 353 |
u32 doorbell_page; |
| 354 |
u32 max_send_wr; |
| 355 |
u32 max_recv_wr; |
| 356 |
u32 max_send_sge; |
| 357 |
u32 max_recv_sge; |
| 358 |
u32 reserved; |
| 359 |
}; /* HW Data */ |
| 360 |
|
| 361 |
struct mana_rnic_create_qp_resp { |
| 362 |
struct gdma_resp_hdr hdr; |
| 363 |
mana_handle_t rc_qp_handle; |
| 364 |
u32 queue_ids[MANA_RC_QUEUE_TYPE_MAX]; |
| 365 |
u32 reserved; |
| 366 |
}; /* HW Data*/ |
| 367 |
|
| 368 |
struct mana_rnic_destroy_rc_qp_req { |
| 369 |
struct gdma_req_hdr hdr; |
| 370 |
mana_handle_t adapter; |
| 371 |
mana_handle_t rc_qp_handle; |
| 372 |
}; /* HW Data */ |
| 373 |
|
| 374 |
struct mana_rnic_destroy_rc_qp_resp { |
| 375 |
struct gdma_resp_hdr hdr; |
| 376 |
}; /* HW Data */ |
| 377 |
|
| 378 |
struct mana_rnic_create_udqp_req { |
| 379 |
struct gdma_req_hdr hdr; |
| 380 |
mana_handle_t adapter; |
| 381 |
mana_handle_t pd_handle; |
| 382 |
mana_handle_t send_cq_handle; |
| 383 |
mana_handle_t recv_cq_handle; |
| 384 |
u64 dma_region[MANA_UD_QUEUE_TYPE_MAX]; |
| 385 |
u32 qp_type; |
| 386 |
u32 doorbell_page; |
| 387 |
u32 max_send_wr; |
| 388 |
u32 max_recv_wr; |
| 389 |
u32 max_send_sge; |
| 390 |
u32 max_recv_sge; |
| 391 |
}; /* HW Data */ |
| 392 |
|
| 393 |
struct mana_rnic_create_udqp_resp { |
| 394 |
struct gdma_resp_hdr hdr; |
| 395 |
mana_handle_t qp_handle; |
| 396 |
u32 queue_ids[MANA_UD_QUEUE_TYPE_MAX]; |
| 397 |
}; /* HW Data*/ |
| 398 |
|
| 399 |
struct mana_rnic_destroy_udqp_req { |
| 400 |
struct gdma_req_hdr hdr; |
| 401 |
mana_handle_t adapter; |
| 402 |
mana_handle_t qp_handle; |
| 403 |
}; /* HW Data */ |
| 404 |
|
| 405 |
struct mana_rnic_destroy_udqp_resp { |
| 406 |
struct gdma_resp_hdr hdr; |
| 407 |
}; /* HW Data */ |
| 408 |
|
| 409 |
struct mana_ib_ah_attr { |
| 410 |
u8 src_addr[16]; |
| 411 |
u8 dest_addr[16]; |
| 412 |
u8 src_mac[ETH_ALEN]; |
| 413 |
u8 dest_mac[ETH_ALEN]; |
| 414 |
u8 src_addr_type; |
| 415 |
u8 dest_addr_type; |
| 416 |
u8 hop_limit; |
| 417 |
u8 traffic_class; |
| 418 |
u16 src_port; |
| 419 |
u16 dest_port; |
| 420 |
u32 flow_label; |
| 421 |
}; |
| 422 |
|
| 423 |
struct mana_rnic_set_qp_state_req { |
| 424 |
struct gdma_req_hdr hdr; |
| 425 |
mana_handle_t adapter; |
| 426 |
mana_handle_t qp_handle; |
| 427 |
u64 attr_mask; |
| 428 |
u32 qp_state; |
| 429 |
u32 path_mtu; |
| 430 |
u32 rq_psn; |
| 431 |
u32 sq_psn; |
| 432 |
u32 dest_qpn; |
| 433 |
u32 max_dest_rd_atomic; |
| 434 |
u32 retry_cnt; |
| 435 |
u32 rnr_retry; |
| 436 |
u32 min_rnr_timer; |
| 437 |
u32 rate_limit; |
| 438 |
struct mana_ib_ah_attr ah_attr; |
| 439 |
u64 reserved1; |
| 440 |
u32 qkey; |
| 441 |
u32 qp_access_flags; |
| 442 |
u8 local_ack_timeout; |
| 443 |
u8 max_rd_atomic; |
| 444 |
u16 reserved2; |
| 445 |
u32 reserved3; |
| 446 |
}; /* HW Data */ |
| 447 |
|
| 448 |
struct mana_rnic_set_qp_state_resp { |
| 449 |
struct gdma_resp_hdr hdr; |
| 450 |
}; /* HW Data */ |
| 451 |
|
| 452 |
enum WQE_OPCODE_TYPES { |
| 453 |
WQE_TYPE_UD_SEND = 0, |
| 454 |
WQE_TYPE_UD_RECV = 8, |
| 455 |
}; /* HW DATA */ |
| 456 |
|
| 457 |
struct rdma_send_oob { |
| 458 |
u32 wqe_type : 5; |
| 459 |
u32 fence : 1; |
| 460 |
u32 signaled : 1; |
| 461 |
u32 solicited : 1; |
| 462 |
u32 psn : 24; |
| 463 |
|
| 464 |
u32 ssn_or_rqpn : 24; |
| 465 |
u32 reserved1 : 8; |
| 466 |
union { |
| 467 |
struct { |
| 468 |
u32 remote_qkey; |
| 469 |
u32 immediate; |
| 470 |
u32 reserved1; |
| 471 |
u32 reserved2; |
| 472 |
} ud_send; |
| 473 |
}; |
| 474 |
}; /* HW DATA */ |
| 475 |
|
| 476 |
struct mana_rdma_cqe { |
| 477 |
union { |
| 478 |
struct { |
| 479 |
u8 cqe_type; |
| 480 |
u8 data[GDMA_COMP_DATA_SIZE - 1]; |
| 481 |
}; |
| 482 |
struct { |
| 483 |
u32 cqe_type : 8; |
| 484 |
u32 vendor_error : 9; |
| 485 |
u32 reserved1 : 15; |
| 486 |
u32 sge_offset : 5; |
| 487 |
u32 tx_wqe_offset : 27; |
| 488 |
} ud_send; |
| 489 |
struct { |
| 490 |
u32 cqe_type : 8; |
| 491 |
u32 reserved1 : 24; |
| 492 |
u32 msg_len; |
| 493 |
u32 src_qpn : 24; |
| 494 |
u32 reserved2 : 8; |
| 495 |
u32 imm_data; |
| 496 |
u32 rx_wqe_offset; |
| 497 |
} ud_recv; |
| 498 |
}; |
| 499 |
}; /* HW DATA */ |
| 500 |
|
| 501 |
struct mana_rnic_query_vf_cntrs_req { |
| 502 |
struct gdma_req_hdr hdr; |
| 503 |
mana_handle_t adapter; |
| 504 |
}; /* HW Data */ |
| 505 |
|
| 506 |
struct mana_rnic_query_vf_cntrs_resp { |
| 507 |
struct gdma_resp_hdr hdr; |
| 508 |
u64 requester_timeout; |
| 509 |
u64 requester_oos_nak; |
| 510 |
u64 requester_rnr_nak; |
| 511 |
u64 responder_rnr_nak; |
| 512 |
u64 responder_oos; |
| 513 |
u64 responder_dup_request; |
| 514 |
u64 requester_implicit_nak; |
| 515 |
u64 requester_readresp_psn_mismatch; |
| 516 |
u64 nak_inv_req; |
| 517 |
u64 nak_access_err; |
| 518 |
u64 nak_opp_err; |
| 519 |
u64 nak_inv_read; |
| 520 |
u64 responder_local_len_err; |
| 521 |
u64 requestor_local_prot_err; |
| 522 |
u64 responder_rem_access_err; |
| 523 |
u64 responder_local_qp_err; |
| 524 |
u64 responder_malformed_wqe; |
| 525 |
u64 general_hw_err; |
| 526 |
u64 requester_rnr_nak_retries_exceeded; |
| 527 |
u64 requester_retries_exceeded; |
| 528 |
u64 total_fatal_err; |
| 529 |
u64 received_cnps; |
| 530 |
u64 num_qps_congested; |
| 531 |
u64 rate_inc_events; |
| 532 |
u64 num_qps_recovered; |
| 533 |
u64 current_rate; |
| 534 |
u64 dup_rx_req; |
| 535 |
u64 tx_bytes; |
| 536 |
u64 rx_bytes; |
| 537 |
u64 rx_send_req; |
| 538 |
u64 rx_write_req; |
| 539 |
u64 rx_read_req; |
| 540 |
u64 tx_pkt; |
| 541 |
u64 rx_pkt; |
| 542 |
}; /* HW Data */ |
| 543 |
|
| 544 |
struct mana_rnic_query_device_cntrs_req { |
| 545 |
struct gdma_req_hdr hdr; |
| 546 |
mana_handle_t adapter; |
| 547 |
}; /* HW Data */ |
| 548 |
|
| 549 |
struct mana_rnic_query_device_cntrs_resp { |
| 550 |
struct gdma_resp_hdr hdr; |
| 551 |
u32 sent_cnps; |
| 552 |
u32 received_ecns; |
| 553 |
u32 reserved1; |
| 554 |
u32 received_cnp_count; |
| 555 |
u32 qp_congested_events; |
| 556 |
u32 qp_recovered_events; |
| 557 |
u32 rate_inc_events; |
| 558 |
u32 reserved2; |
| 559 |
}; /* HW Data */ |
| 560 |
|
| 561 |
static inline struct gdma_context *mdev_to_gc(struct mana_ib_dev *mdev) |
| 562 |
{ |
| 563 |
return mdev->gdma_dev->gdma_context; |
| 564 |
} |
| 565 |
|
| 566 |
static inline struct mana_ib_qp *mana_get_qp_ref(struct mana_ib_dev *mdev, |
| 567 |
u32 qid, bool is_sq) |
| 568 |
{ |
| 569 |
struct mana_ib_qp *qp; |
| 570 |
unsigned long flag; |
| 571 |
|
| 572 |
if (is_sq) |
| 573 |
qid |= MANA_SENDQ_MASK; |
| 574 |
|
| 575 |
xa_lock_irqsave(&mdev->qp_table_wq, flag); |
| 576 |
qp = xa_load(&mdev->qp_table_wq, qid); |
| 577 |
if (qp) |
| 578 |
refcount_inc(&qp->refcount); |
| 579 |
xa_unlock_irqrestore(&mdev->qp_table_wq, flag); |
| 580 |
return qp; |
| 581 |
} |
| 582 |
|
| 583 |
static inline void mana_put_qp_ref(struct mana_ib_qp *qp) |
| 584 |
{ |
| 585 |
if (refcount_dec_and_test(&qp->refcount)) |
| 586 |
complete(&qp->free); |
| 587 |
} |
| 588 |
|
| 589 |
static inline bool mana_ib_is_rnic(struct mana_ib_dev *mdev) |
| 590 |
{ |
| 591 |
return mdev->gdma_dev->dev_id.type == GDMA_DEVICE_MANA_IB; |
| 592 |
} |
| 593 |
|
| 594 |
static inline struct net_device *mana_ib_get_netdev(struct ib_device *ibdev, u32 port) |
| 595 |
{ |
| 596 |
struct mana_ib_dev *mdev = container_of(ibdev, struct mana_ib_dev, ib_dev); |
| 597 |
struct gdma_context *gc = mdev_to_gc(mdev); |
| 598 |
struct mana_context *mc = gc->mana.driver_data; |
| 599 |
|
| 600 |
if (port < 1 || port > mc->num_ports) |
| 601 |
return NULL; |
| 602 |
return mc->ports[port - 1]; |
| 603 |
} |
| 604 |
|
| 605 |
static inline void copy_in_reverse(u8 *dst, const u8 *src, u32 size) |
| 606 |
{ |
| 607 |
u32 i; |
| 608 |
|
| 609 |
for (i = 0; i < size; i++) |
| 610 |
dst[size - 1 - i] = src[i]; |
| 611 |
} |
| 612 |
|
| 613 |
int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq); |
| 614 |
void mana_ib_remove_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq); |
| 615 |
|
| 616 |
int mana_ib_create_zero_offset_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, |
| 617 |
mana_handle_t *gdma_region); |
| 618 |
|
| 619 |
int mana_ib_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, |
| 620 |
mana_handle_t *gdma_region, u64 virt); |
| 621 |
|
| 622 |
int mana_ib_gd_destroy_dma_region(struct mana_ib_dev *dev, |
| 623 |
mana_handle_t gdma_region); |
| 624 |
|
| 625 |
int mana_ib_create_kernel_queue(struct mana_ib_dev *mdev, u32 size, enum gdma_queue_type type, |
| 626 |
struct mana_ib_queue *queue); |
| 627 |
int mana_ib_create_queue(struct mana_ib_dev *mdev, u64 addr, u32 size, |
| 628 |
struct mana_ib_queue *queue); |
| 629 |
void mana_ib_destroy_queue(struct mana_ib_dev *mdev, struct mana_ib_queue *queue); |
| 630 |
|
| 631 |
struct ib_wq *mana_ib_create_wq(struct ib_pd *pd, |
| 632 |
struct ib_wq_init_attr *init_attr, |
| 633 |
struct ib_udata *udata); |
| 634 |
|
| 635 |
int mana_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr, |
| 636 |
u32 wq_attr_mask, struct ib_udata *udata); |
| 637 |
|
| 638 |
int mana_ib_destroy_wq(struct ib_wq *ibwq, struct ib_udata *udata); |
| 639 |
|
| 640 |
int mana_ib_create_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_table, |
| 641 |
struct ib_rwq_ind_table_init_attr *init_attr, |
| 642 |
struct ib_udata *udata); |
| 643 |
|
| 644 |
int mana_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl); |
| 645 |
|
| 646 |
struct ib_mr *mana_ib_get_dma_mr(struct ib_pd *ibpd, int access_flags); |
| 647 |
|
| 648 |
struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, |
| 649 |
u64 iova, int access_flags, |
| 650 |
struct ib_dmah *dmah, |
| 651 |
struct ib_udata *udata); |
| 652 |
|
| 653 |
int mana_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); |
| 654 |
|
| 655 |
int mana_ib_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *qp_init_attr, |
| 656 |
struct ib_udata *udata); |
| 657 |
|
| 658 |
int mana_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, |
| 659 |
int attr_mask, struct ib_udata *udata); |
| 660 |
|
| 661 |
int mana_ib_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata); |
| 662 |
|
| 663 |
int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port_id, |
| 664 |
struct mana_ib_pd *pd, u32 doorbell_id); |
| 665 |
void mana_ib_uncfg_vport(struct mana_ib_dev *dev, struct mana_ib_pd *pd, |
| 666 |
u32 port); |
| 667 |
|
| 668 |
int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, |
| 669 |
struct uverbs_attr_bundle *attrs); |
| 670 |
|
| 671 |
int mana_ib_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata); |
| 672 |
|
| 673 |
int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata); |
| 674 |
int mana_ib_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata); |
| 675 |
|
| 676 |
int mana_ib_alloc_ucontext(struct ib_ucontext *ibcontext, |
| 677 |
struct ib_udata *udata); |
| 678 |
void mana_ib_dealloc_ucontext(struct ib_ucontext *ibcontext); |
| 679 |
|
| 680 |
int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma); |
| 681 |
|
| 682 |
int mana_ib_get_port_immutable(struct ib_device *ibdev, u32 port_num, |
| 683 |
struct ib_port_immutable *immutable); |
| 684 |
int mana_ib_query_device(struct ib_device *ibdev, struct ib_device_attr *props, |
| 685 |
struct ib_udata *uhw); |
| 686 |
int mana_ib_query_port(struct ib_device *ibdev, u32 port, |
| 687 |
struct ib_port_attr *props); |
| 688 |
int mana_ib_query_gid(struct ib_device *ibdev, u32 port, int index, |
| 689 |
union ib_gid *gid); |
| 690 |
|
| 691 |
void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext); |
| 692 |
|
| 693 |
int mana_ib_gd_query_adapter_caps(struct mana_ib_dev *mdev); |
| 694 |
int mana_eth_query_adapter_caps(struct mana_ib_dev *mdev); |
| 695 |
|
| 696 |
int mana_ib_create_eqs(struct mana_ib_dev *mdev); |
| 697 |
|
| 698 |
void mana_ib_destroy_eqs(struct mana_ib_dev *mdev); |
| 699 |
|
| 700 |
int mana_ib_gd_create_rnic_adapter(struct mana_ib_dev *mdev); |
| 701 |
|
| 702 |
int mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev); |
| 703 |
|
| 704 |
int mana_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index, u16 *pkey); |
| 705 |
|
| 706 |
enum rdma_link_layer mana_ib_get_link_layer(struct ib_device *device, u32 port_num); |
| 707 |
|
| 708 |
int mana_ib_gd_add_gid(const struct ib_gid_attr *attr, void **context); |
| 709 |
|
| 710 |
int mana_ib_gd_del_gid(const struct ib_gid_attr *attr, void **context); |
| 711 |
|
| 712 |
int mana_ib_gd_config_mac(struct mana_ib_dev *mdev, enum mana_ib_addr_op op, u8 *mac); |
| 713 |
|
| 714 |
int mana_ib_gd_create_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq, u32 doorbell); |
| 715 |
|
| 716 |
int mana_ib_gd_destroy_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq); |
| 717 |
|
| 718 |
int mana_ib_gd_create_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp, |
| 719 |
struct ib_qp_init_attr *attr, u32 doorbell, u64 flags); |
| 720 |
int mana_ib_gd_destroy_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp); |
| 721 |
|
| 722 |
int mana_ib_gd_create_ud_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp, |
| 723 |
struct ib_qp_init_attr *attr, u32 doorbell, u32 type); |
| 724 |
int mana_ib_gd_destroy_ud_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp); |
| 725 |
|
| 726 |
int mana_ib_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, |
| 727 |
struct ib_udata *udata); |
| 728 |
int mana_ib_destroy_ah(struct ib_ah *ah, u32 flags); |
| 729 |
|
| 730 |
int mana_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, |
| 731 |
const struct ib_recv_wr **bad_wr); |
| 732 |
int mana_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr, |
| 733 |
const struct ib_send_wr **bad_wr); |
| 734 |
|
| 735 |
void mana_drain_gsi_sqs(struct mana_ib_dev *mdev); |
| 736 |
int mana_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); |
| 737 |
int mana_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); |
| 738 |
|
| 739 |
struct ib_mr *mana_ib_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start, u64 length, |
| 740 |
u64 iova, int fd, int mr_access_flags, |
| 741 |
struct ib_dmah *dmah, |
| 742 |
struct uverbs_attr_bundle *attrs); |
| 743 |
|
| 744 |
struct ib_dm *mana_ib_alloc_dm(struct ib_device *dev, struct ib_ucontext *context, |
| 745 |
struct ib_dm_alloc_attr *attr, struct uverbs_attr_bundle *attrs); |
| 746 |
int mana_ib_dealloc_dm(struct ib_dm *dm, struct uverbs_attr_bundle *attrs); |
| 747 |
struct ib_mr *mana_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm, struct ib_dm_mr_attr *attr, |
| 748 |
struct uverbs_attr_bundle *attrs); |
| 749 |
|
| 750 |
#endif |