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

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

Pull rdma updates from Doug Ledford:

- a large cleanup of how device capabilities are checked for various
features

- additional cleanups in the MAD processing

- update to the srp driver

- creation and use of centralized log message helpers

- add const to a number of args to calls and clean up call chain

- add support for extended cq create verb

- add support for timestamps on cq completion

- add support for processing OPA MAD packets

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (92 commits)
IB/mad: Add final OPA MAD processing
IB/mad: Add partial Intel OPA MAD support
IB/mad: Add partial Intel OPA MAD support
IB/core: Add OPA MAD core capability flag
IB/mad: Add support for additional MAD info to/from drivers
IB/mad: Convert allocations from kmem_cache to kzalloc
IB/core: Add ability for drivers to report an alternate MAD size.
IB/mad: Support alternate Base Versions when creating MADs
IB/mad: Create a generic helper for DR forwarding checks
IB/mad: Create a generic helper for DR SMP Recv processing
IB/mad: Create a generic helper for DR SMP Send processing
IB/mad: Split IB SMI handling from MAD Recv handler
IB/mad cleanup: Generalize processing of MAD data
IB/mad cleanup: Clean up function params -- find_mad_agent
IB/mlx4: Add support for CQ time-stamping
IB/mlx4: Add mmap call to map the hardware clock
IB/core: Pass hardware specific data in query_device
IB/core: Add timestamp_mask and hca_core_clock to query_device
IB/core: Extend ib_uverbs_create_cq
IB/core: Add CQ creation time-stamping flag
...

+2898 -1361
+2 -2
drivers/infiniband/core/addr.c
··· 457 457 complete(&((struct resolve_cb_context *)context)->comp); 458 458 } 459 459 460 - int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *dmac, 461 - u16 *vlan_id) 460 + int rdma_addr_find_dmac_by_grh(const union ib_gid *sgid, const union ib_gid *dgid, 461 + u8 *dmac, u16 *vlan_id) 462 462 { 463 463 int ret = 0; 464 464 struct rdma_dev_addr dev_addr;
+14 -9
drivers/infiniband/core/agent.c
··· 54 54 static LIST_HEAD(ib_agent_port_list); 55 55 56 56 static struct ib_agent_port_private * 57 - __ib_get_agent_port(struct ib_device *device, int port_num) 57 + __ib_get_agent_port(const struct ib_device *device, int port_num) 58 58 { 59 59 struct ib_agent_port_private *entry; 60 60 ··· 67 67 } 68 68 69 69 static struct ib_agent_port_private * 70 - ib_get_agent_port(struct ib_device *device, int port_num) 70 + ib_get_agent_port(const struct ib_device *device, int port_num) 71 71 { 72 72 struct ib_agent_port_private *entry; 73 73 unsigned long flags; ··· 78 78 return entry; 79 79 } 80 80 81 - void agent_send_response(struct ib_mad *mad, struct ib_grh *grh, 82 - struct ib_wc *wc, struct ib_device *device, 83 - int port_num, int qpn) 81 + void agent_send_response(const struct ib_mad_hdr *mad_hdr, const struct ib_grh *grh, 82 + const struct ib_wc *wc, const struct ib_device *device, 83 + int port_num, int qpn, size_t resp_mad_len, bool opa) 84 84 { 85 85 struct ib_agent_port_private *port_priv; 86 86 struct ib_mad_agent *agent; ··· 106 106 return; 107 107 } 108 108 109 + if (opa && mad_hdr->base_version != OPA_MGMT_BASE_VERSION) 110 + resp_mad_len = IB_MGMT_MAD_SIZE; 111 + 109 112 send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0, 110 - IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA, 111 - GFP_KERNEL); 113 + IB_MGMT_MAD_HDR, 114 + resp_mad_len - IB_MGMT_MAD_HDR, 115 + GFP_KERNEL, 116 + mad_hdr->base_version); 112 117 if (IS_ERR(send_buf)) { 113 118 dev_err(&device->dev, "ib_create_send_mad error\n"); 114 119 goto err1; 115 120 } 116 121 117 - memcpy(send_buf->mad, mad, sizeof *mad); 122 + memcpy(send_buf->mad, mad_hdr, resp_mad_len); 118 123 send_buf->ah = ah; 119 124 120 125 if (device->node_type == RDMA_NODE_IB_SWITCH) { ··· 161 156 goto error1; 162 157 } 163 158 164 - if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) { 159 + if (rdma_cap_ib_smi(device, port_num)) { 165 160 /* Obtain send only MAD agent for SMI QP */ 166 161 port_priv->agent[0] = ib_register_mad_agent(device, port_num, 167 162 IB_QPT_SMI, NULL, 0,
+3 -3
drivers/infiniband/core/agent.h
··· 44 44 45 45 extern int ib_agent_port_close(struct ib_device *device, int port_num); 46 46 47 - extern void agent_send_response(struct ib_mad *mad, struct ib_grh *grh, 48 - struct ib_wc *wc, struct ib_device *device, 49 - int port_num, int qpn); 47 + extern void agent_send_response(const struct ib_mad_hdr *mad_hdr, const struct ib_grh *grh, 48 + const struct ib_wc *wc, const struct ib_device *device, 49 + int port_num, int qpn, size_t resp_mad_len, bool opa); 50 50 51 51 #endif /* __AGENT_H_ */
+29 -40
drivers/infiniband/core/cache.c
··· 58 58 u8 port_num; 59 59 }; 60 60 61 - static inline int start_port(struct ib_device *device) 62 - { 63 - return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1; 64 - } 65 - 66 - static inline int end_port(struct ib_device *device) 67 - { 68 - return (device->node_type == RDMA_NODE_IB_SWITCH) ? 69 - 0 : device->phys_port_cnt; 70 - } 71 - 72 61 int ib_get_cached_gid(struct ib_device *device, 73 62 u8 port_num, 74 63 int index, ··· 67 78 unsigned long flags; 68 79 int ret = 0; 69 80 70 - if (port_num < start_port(device) || port_num > end_port(device)) 81 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 71 82 return -EINVAL; 72 83 73 84 read_lock_irqsave(&device->cache.lock, flags); 74 85 75 - cache = device->cache.gid_cache[port_num - start_port(device)]; 86 + cache = device->cache.gid_cache[port_num - rdma_start_port(device)]; 76 87 77 88 if (index < 0 || index >= cache->table_len) 78 89 ret = -EINVAL; ··· 85 96 } 86 97 EXPORT_SYMBOL(ib_get_cached_gid); 87 98 88 - int ib_find_cached_gid(struct ib_device *device, 89 - union ib_gid *gid, 90 - u8 *port_num, 91 - u16 *index) 99 + int ib_find_cached_gid(struct ib_device *device, 100 + const union ib_gid *gid, 101 + u8 *port_num, 102 + u16 *index) 92 103 { 93 104 struct ib_gid_cache *cache; 94 105 unsigned long flags; ··· 101 112 102 113 read_lock_irqsave(&device->cache.lock, flags); 103 114 104 - for (p = 0; p <= end_port(device) - start_port(device); ++p) { 115 + for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) { 105 116 cache = device->cache.gid_cache[p]; 106 117 for (i = 0; i < cache->table_len; ++i) { 107 118 if (!memcmp(gid, &cache->table[i], sizeof *gid)) { 108 - *port_num = p + start_port(device); 119 + *port_num = p + rdma_start_port(device); 109 120 if (index) 110 121 *index = i; 111 122 ret = 0; ··· 129 140 unsigned long flags; 130 141 int ret = 0; 131 142 132 - if (port_num < start_port(device) || port_num > end_port(device)) 143 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 133 144 return -EINVAL; 134 145 135 146 read_lock_irqsave(&device->cache.lock, flags); 136 147 137 - cache = device->cache.pkey_cache[port_num - start_port(device)]; 148 + cache = device->cache.pkey_cache[port_num - rdma_start_port(device)]; 138 149 139 150 if (index < 0 || index >= cache->table_len) 140 151 ret = -EINVAL; ··· 158 169 int ret = -ENOENT; 159 170 int partial_ix = -1; 160 171 161 - if (port_num < start_port(device) || port_num > end_port(device)) 172 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 162 173 return -EINVAL; 163 174 164 175 read_lock_irqsave(&device->cache.lock, flags); 165 176 166 - cache = device->cache.pkey_cache[port_num - start_port(device)]; 177 + cache = device->cache.pkey_cache[port_num - rdma_start_port(device)]; 167 178 168 179 *index = -1; 169 180 ··· 198 209 int i; 199 210 int ret = -ENOENT; 200 211 201 - if (port_num < start_port(device) || port_num > end_port(device)) 212 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 202 213 return -EINVAL; 203 214 204 215 read_lock_irqsave(&device->cache.lock, flags); 205 216 206 - cache = device->cache.pkey_cache[port_num - start_port(device)]; 217 + cache = device->cache.pkey_cache[port_num - rdma_start_port(device)]; 207 218 208 219 *index = -1; 209 220 ··· 227 238 unsigned long flags; 228 239 int ret = 0; 229 240 230 - if (port_num < start_port(device) || port_num > end_port(device)) 241 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 231 242 return -EINVAL; 232 243 233 244 read_lock_irqsave(&device->cache.lock, flags); 234 - *lmc = device->cache.lmc_cache[port_num - start_port(device)]; 245 + *lmc = device->cache.lmc_cache[port_num - rdma_start_port(device)]; 235 246 read_unlock_irqrestore(&device->cache.lock, flags); 236 247 237 248 return ret; ··· 292 303 293 304 write_lock_irq(&device->cache.lock); 294 305 295 - old_pkey_cache = device->cache.pkey_cache[port - start_port(device)]; 296 - old_gid_cache = device->cache.gid_cache [port - start_port(device)]; 306 + old_pkey_cache = device->cache.pkey_cache[port - rdma_start_port(device)]; 307 + old_gid_cache = device->cache.gid_cache [port - rdma_start_port(device)]; 297 308 298 - device->cache.pkey_cache[port - start_port(device)] = pkey_cache; 299 - device->cache.gid_cache [port - start_port(device)] = gid_cache; 309 + device->cache.pkey_cache[port - rdma_start_port(device)] = pkey_cache; 310 + device->cache.gid_cache [port - rdma_start_port(device)] = gid_cache; 300 311 301 - device->cache.lmc_cache[port - start_port(device)] = tprops->lmc; 312 + device->cache.lmc_cache[port - rdma_start_port(device)] = tprops->lmc; 302 313 303 314 write_unlock_irq(&device->cache.lock); 304 315 ··· 352 363 353 364 device->cache.pkey_cache = 354 365 kmalloc(sizeof *device->cache.pkey_cache * 355 - (end_port(device) - start_port(device) + 1), GFP_KERNEL); 366 + (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL); 356 367 device->cache.gid_cache = 357 368 kmalloc(sizeof *device->cache.gid_cache * 358 - (end_port(device) - start_port(device) + 1), GFP_KERNEL); 369 + (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL); 359 370 360 371 device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache * 361 - (end_port(device) - 362 - start_port(device) + 1), 372 + (rdma_end_port(device) - 373 + rdma_start_port(device) + 1), 363 374 GFP_KERNEL); 364 375 365 376 if (!device->cache.pkey_cache || !device->cache.gid_cache || ··· 369 380 goto err; 370 381 } 371 382 372 - for (p = 0; p <= end_port(device) - start_port(device); ++p) { 383 + for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) { 373 384 device->cache.pkey_cache[p] = NULL; 374 385 device->cache.gid_cache [p] = NULL; 375 - ib_cache_update(device, p + start_port(device)); 386 + ib_cache_update(device, p + rdma_start_port(device)); 376 387 } 377 388 378 389 INIT_IB_EVENT_HANDLER(&device->cache.event_handler, ··· 383 394 return; 384 395 385 396 err_cache: 386 - for (p = 0; p <= end_port(device) - start_port(device); ++p) { 397 + for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) { 387 398 kfree(device->cache.pkey_cache[p]); 388 399 kfree(device->cache.gid_cache[p]); 389 400 } ··· 401 412 ib_unregister_event_handler(&device->cache.event_handler); 402 413 flush_workqueue(ib_wq); 403 414 404 - for (p = 0; p <= end_port(device) - start_port(device); ++p) { 415 + for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) { 405 416 kfree(device->cache.pkey_cache[p]); 406 417 kfree(device->cache.gid_cache[p]); 407 418 }
+21 -5
drivers/infiniband/core/cm.c
··· 267 267 m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn, 268 268 cm_id_priv->av.pkey_index, 269 269 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA, 270 - GFP_ATOMIC); 270 + GFP_ATOMIC, 271 + IB_MGMT_BASE_VERSION); 271 272 if (IS_ERR(m)) { 272 273 ib_destroy_ah(ah); 273 274 return PTR_ERR(m); ··· 298 297 299 298 m = ib_create_send_mad(port->mad_agent, 1, mad_recv_wc->wc->pkey_index, 300 299 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA, 301 - GFP_ATOMIC); 300 + GFP_ATOMIC, 301 + IB_MGMT_BASE_VERSION); 302 302 if (IS_ERR(m)) { 303 303 ib_destroy_ah(ah); 304 304 return PTR_ERR(m); ··· 3761 3759 }; 3762 3760 unsigned long flags; 3763 3761 int ret; 3762 + int count = 0; 3764 3763 u8 i; 3765 - 3766 - if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB) 3767 - return; 3768 3764 3769 3765 cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) * 3770 3766 ib_device->phys_port_cnt, GFP_KERNEL); ··· 3782 3782 3783 3783 set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); 3784 3784 for (i = 1; i <= ib_device->phys_port_cnt; i++) { 3785 + if (!rdma_cap_ib_cm(ib_device, i)) 3786 + continue; 3787 + 3785 3788 port = kzalloc(sizeof *port, GFP_KERNEL); 3786 3789 if (!port) 3787 3790 goto error1; ··· 3811 3808 ret = ib_modify_port(ib_device, i, 0, &port_modify); 3812 3809 if (ret) 3813 3810 goto error3; 3811 + 3812 + count++; 3814 3813 } 3814 + 3815 + if (!count) 3816 + goto free; 3817 + 3815 3818 ib_set_client_data(ib_device, &cm_client, cm_dev); 3816 3819 3817 3820 write_lock_irqsave(&cm.device_lock, flags); ··· 3833 3824 port_modify.set_port_cap_mask = 0; 3834 3825 port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; 3835 3826 while (--i) { 3827 + if (!rdma_cap_ib_cm(ib_device, i)) 3828 + continue; 3829 + 3836 3830 port = cm_dev->port[i-1]; 3837 3831 ib_modify_port(ib_device, port->port_num, 0, &port_modify); 3838 3832 ib_unregister_mad_agent(port->mad_agent); 3839 3833 cm_remove_port_fs(port); 3840 3834 } 3835 + free: 3841 3836 device_unregister(cm_dev->device); 3842 3837 kfree(cm_dev); 3843 3838 } ··· 3865 3852 write_unlock_irqrestore(&cm.device_lock, flags); 3866 3853 3867 3854 for (i = 1; i <= ib_device->phys_port_cnt; i++) { 3855 + if (!rdma_cap_ib_cm(ib_device, i)) 3856 + continue; 3857 + 3868 3858 port = cm_dev->port[i-1]; 3869 3859 ib_modify_port(ib_device, port->port_num, 0, &port_modify); 3870 3860 ib_unregister_mad_agent(port->mad_agent);
+129 -156
drivers/infiniband/core/cma.c
··· 65 65 #define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24) 66 66 #define CMA_IBOE_PACKET_LIFETIME 18 67 67 68 + static const char * const cma_events[] = { 69 + [RDMA_CM_EVENT_ADDR_RESOLVED] = "address resolved", 70 + [RDMA_CM_EVENT_ADDR_ERROR] = "address error", 71 + [RDMA_CM_EVENT_ROUTE_RESOLVED] = "route resolved ", 72 + [RDMA_CM_EVENT_ROUTE_ERROR] = "route error", 73 + [RDMA_CM_EVENT_CONNECT_REQUEST] = "connect request", 74 + [RDMA_CM_EVENT_CONNECT_RESPONSE] = "connect response", 75 + [RDMA_CM_EVENT_CONNECT_ERROR] = "connect error", 76 + [RDMA_CM_EVENT_UNREACHABLE] = "unreachable", 77 + [RDMA_CM_EVENT_REJECTED] = "rejected", 78 + [RDMA_CM_EVENT_ESTABLISHED] = "established", 79 + [RDMA_CM_EVENT_DISCONNECTED] = "disconnected", 80 + [RDMA_CM_EVENT_DEVICE_REMOVAL] = "device removal", 81 + [RDMA_CM_EVENT_MULTICAST_JOIN] = "multicast join", 82 + [RDMA_CM_EVENT_MULTICAST_ERROR] = "multicast error", 83 + [RDMA_CM_EVENT_ADDR_CHANGE] = "address change", 84 + [RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit", 85 + }; 86 + 87 + const char *rdma_event_msg(enum rdma_cm_event_type event) 88 + { 89 + size_t index = event; 90 + 91 + return (index < ARRAY_SIZE(cma_events) && cma_events[index]) ? 92 + cma_events[index] : "unrecognized event"; 93 + } 94 + EXPORT_SYMBOL(rdma_event_msg); 95 + 68 96 static void cma_add_one(struct ib_device *device); 69 97 static void cma_remove_one(struct ib_device *device); 70 98 ··· 377 349 return ret; 378 350 } 379 351 352 + static inline int cma_validate_port(struct ib_device *device, u8 port, 353 + union ib_gid *gid, int dev_type) 354 + { 355 + u8 found_port; 356 + int ret = -ENODEV; 357 + 358 + if ((dev_type == ARPHRD_INFINIBAND) && !rdma_protocol_ib(device, port)) 359 + return ret; 360 + 361 + if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) 362 + return ret; 363 + 364 + ret = ib_find_cached_gid(device, gid, &found_port, NULL); 365 + if (port != found_port) 366 + return -ENODEV; 367 + 368 + return ret; 369 + } 370 + 380 371 static int cma_acquire_dev(struct rdma_id_private *id_priv, 381 372 struct rdma_id_private *listen_id_priv) 382 373 { 383 374 struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; 384 375 struct cma_device *cma_dev; 385 - union ib_gid gid, iboe_gid; 376 + union ib_gid gid, iboe_gid, *gidp; 386 377 int ret = -ENODEV; 387 - u8 port, found_port; 388 - enum rdma_link_layer dev_ll = dev_addr->dev_type == ARPHRD_INFINIBAND ? 389 - IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET; 378 + u8 port; 390 379 391 - if (dev_ll != IB_LINK_LAYER_INFINIBAND && 380 + if (dev_addr->dev_type != ARPHRD_INFINIBAND && 392 381 id_priv->id.ps == RDMA_PS_IPOIB) 393 382 return -EINVAL; 394 383 ··· 415 370 416 371 memcpy(&gid, dev_addr->src_dev_addr + 417 372 rdma_addr_gid_offset(dev_addr), sizeof gid); 418 - if (listen_id_priv && 419 - rdma_port_get_link_layer(listen_id_priv->id.device, 420 - listen_id_priv->id.port_num) == dev_ll) { 373 + 374 + if (listen_id_priv) { 421 375 cma_dev = listen_id_priv->cma_dev; 422 376 port = listen_id_priv->id.port_num; 423 - if (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB && 424 - rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET) 425 - ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, 426 - &found_port, NULL); 427 - else 428 - ret = ib_find_cached_gid(cma_dev->device, &gid, 429 - &found_port, NULL); 377 + gidp = rdma_protocol_roce(cma_dev->device, port) ? 378 + &iboe_gid : &gid; 430 379 431 - if (!ret && (port == found_port)) { 432 - id_priv->id.port_num = found_port; 380 + ret = cma_validate_port(cma_dev->device, port, gidp, 381 + dev_addr->dev_type); 382 + if (!ret) { 383 + id_priv->id.port_num = port; 433 384 goto out; 434 385 } 435 386 } 387 + 436 388 list_for_each_entry(cma_dev, &dev_list, list) { 437 389 for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) { 438 390 if (listen_id_priv && 439 391 listen_id_priv->cma_dev == cma_dev && 440 392 listen_id_priv->id.port_num == port) 441 393 continue; 442 - if (rdma_port_get_link_layer(cma_dev->device, port) == dev_ll) { 443 - if (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB && 444 - rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET) 445 - ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL); 446 - else 447 - ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL); 448 394 449 - if (!ret && (port == found_port)) { 450 - id_priv->id.port_num = found_port; 451 - goto out; 452 - } 395 + gidp = rdma_protocol_roce(cma_dev->device, port) ? 396 + &iboe_gid : &gid; 397 + 398 + ret = cma_validate_port(cma_dev->device, port, gidp, 399 + dev_addr->dev_type); 400 + if (!ret) { 401 + id_priv->id.port_num = port; 402 + goto out; 453 403 } 454 404 } 455 405 } ··· 475 435 pkey = ntohs(addr->sib_pkey); 476 436 477 437 list_for_each_entry(cur_dev, &dev_list, list) { 478 - if (rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) 479 - continue; 480 - 481 438 for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { 439 + if (!rdma_cap_af_ib(cur_dev->device, p)) 440 + continue; 441 + 482 442 if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index)) 483 443 continue; 484 444 ··· 673 633 if (ret) 674 634 goto out; 675 635 676 - if (rdma_node_get_transport(id_priv->cma_dev->device->node_type) 677 - == RDMA_TRANSPORT_IB && 678 - rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) 679 - == IB_LINK_LAYER_ETHERNET) { 636 + BUG_ON(id_priv->cma_dev->device != id_priv->id.device); 637 + 638 + if (rdma_protocol_roce(id_priv->id.device, id_priv->id.port_num)) { 680 639 ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL); 681 640 682 641 if (ret) ··· 739 700 int ret; 740 701 u16 pkey; 741 702 742 - if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) == 743 - IB_LINK_LAYER_INFINIBAND) 744 - pkey = ib_addr_get_pkey(dev_addr); 745 - else 703 + if (rdma_cap_eth_ah(id_priv->id.device, id_priv->id.port_num)) 746 704 pkey = 0xffff; 705 + else 706 + pkey = ib_addr_get_pkey(dev_addr); 747 707 748 708 ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num, 749 709 pkey, &qp_attr->pkey_index); ··· 773 735 int ret = 0; 774 736 775 737 id_priv = container_of(id, struct rdma_id_private, id); 776 - switch (rdma_node_get_transport(id_priv->id.device->node_type)) { 777 - case RDMA_TRANSPORT_IB: 738 + if (rdma_cap_ib_cm(id->device, id->port_num)) { 778 739 if (!id_priv->cm_id.ib || (id_priv->id.qp_type == IB_QPT_UD)) 779 740 ret = cma_ib_init_qp_attr(id_priv, qp_attr, qp_attr_mask); 780 741 else ··· 782 745 783 746 if (qp_attr->qp_state == IB_QPS_RTR) 784 747 qp_attr->rq_psn = id_priv->seq_num; 785 - break; 786 - case RDMA_TRANSPORT_IWARP: 748 + } else if (rdma_cap_iw_cm(id->device, id->port_num)) { 787 749 if (!id_priv->cm_id.iw) { 788 750 qp_attr->qp_access_flags = 0; 789 751 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS; 790 752 } else 791 753 ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr, 792 754 qp_attr_mask); 793 - break; 794 - default: 755 + } else 795 756 ret = -ENOSYS; 796 - break; 797 - } 798 757 799 758 return ret; 800 759 } ··· 978 945 979 946 static void cma_cancel_route(struct rdma_id_private *id_priv) 980 947 { 981 - switch (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)) { 982 - case IB_LINK_LAYER_INFINIBAND: 948 + if (rdma_cap_ib_sa(id_priv->id.device, id_priv->id.port_num)) { 983 949 if (id_priv->query) 984 950 ib_sa_cancel_query(id_priv->query_id, id_priv->query); 985 - break; 986 - default: 987 - break; 988 951 } 989 952 } 990 953 ··· 1052 1023 mc = container_of(id_priv->mc_list.next, 1053 1024 struct cma_multicast, list); 1054 1025 list_del(&mc->list); 1055 - switch (rdma_port_get_link_layer(id_priv->cma_dev->device, id_priv->id.port_num)) { 1056 - case IB_LINK_LAYER_INFINIBAND: 1026 + if (rdma_cap_ib_mcast(id_priv->cma_dev->device, 1027 + id_priv->id.port_num)) { 1057 1028 ib_sa_free_multicast(mc->multicast.ib); 1058 1029 kfree(mc); 1059 - break; 1060 - case IB_LINK_LAYER_ETHERNET: 1030 + } else 1061 1031 kref_put(&mc->mcref, release_mc); 1062 - break; 1063 - default: 1064 - break; 1065 - } 1066 1032 } 1067 1033 } 1068 1034 ··· 1078 1054 mutex_unlock(&id_priv->handler_mutex); 1079 1055 1080 1056 if (id_priv->cma_dev) { 1081 - switch (rdma_node_get_transport(id_priv->id.device->node_type)) { 1082 - case RDMA_TRANSPORT_IB: 1057 + if (rdma_cap_ib_cm(id_priv->id.device, 1)) { 1083 1058 if (id_priv->cm_id.ib) 1084 1059 ib_destroy_cm_id(id_priv->cm_id.ib); 1085 - break; 1086 - case RDMA_TRANSPORT_IWARP: 1060 + } else if (rdma_cap_iw_cm(id_priv->id.device, 1)) { 1087 1061 if (id_priv->cm_id.iw) 1088 1062 iw_destroy_cm_id(id_priv->cm_id.iw); 1089 - break; 1090 - default: 1091 - break; 1092 1063 } 1093 1064 cma_leave_mc_groups(id_priv); 1094 1065 cma_release_dev(id_priv); ··· 1629 1610 if (IS_ERR(id)) 1630 1611 return PTR_ERR(id); 1631 1612 1613 + id->tos = id_priv->tos; 1632 1614 id_priv->cm_id.iw = id; 1633 1615 1634 1616 memcpy(&id_priv->cm_id.iw->local_addr, cma_src_addr(id_priv), ··· 1662 1642 struct rdma_cm_id *id; 1663 1643 int ret; 1664 1644 1665 - if (cma_family(id_priv) == AF_IB && 1666 - rdma_node_get_transport(cma_dev->device->node_type) != RDMA_TRANSPORT_IB) 1645 + if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1)) 1667 1646 return; 1668 1647 1669 1648 id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps, ··· 2003 1984 return -EINVAL; 2004 1985 2005 1986 atomic_inc(&id_priv->refcount); 2006 - switch (rdma_node_get_transport(id->device->node_type)) { 2007 - case RDMA_TRANSPORT_IB: 2008 - switch (rdma_port_get_link_layer(id->device, id->port_num)) { 2009 - case IB_LINK_LAYER_INFINIBAND: 2010 - ret = cma_resolve_ib_route(id_priv, timeout_ms); 2011 - break; 2012 - case IB_LINK_LAYER_ETHERNET: 2013 - ret = cma_resolve_iboe_route(id_priv); 2014 - break; 2015 - default: 2016 - ret = -ENOSYS; 2017 - } 2018 - break; 2019 - case RDMA_TRANSPORT_IWARP: 1987 + if (rdma_cap_ib_sa(id->device, id->port_num)) 1988 + ret = cma_resolve_ib_route(id_priv, timeout_ms); 1989 + else if (rdma_protocol_roce(id->device, id->port_num)) 1990 + ret = cma_resolve_iboe_route(id_priv); 1991 + else if (rdma_protocol_iwarp(id->device, id->port_num)) 2020 1992 ret = cma_resolve_iw_route(id_priv, timeout_ms); 2021 - break; 2022 - default: 1993 + else 2023 1994 ret = -ENOSYS; 2024 - break; 2025 - } 1995 + 2026 1996 if (ret) 2027 1997 goto err; 2028 1998 ··· 2053 2045 mutex_lock(&lock); 2054 2046 list_for_each_entry(cur_dev, &dev_list, list) { 2055 2047 if (cma_family(id_priv) == AF_IB && 2056 - rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) 2048 + !rdma_cap_ib_cm(cur_dev->device, 1)) 2057 2049 continue; 2058 2050 2059 2051 if (!cma_dev) ··· 2085 2077 goto out; 2086 2078 2087 2079 id_priv->id.route.addr.dev_addr.dev_type = 2088 - (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ? 2080 + (rdma_protocol_ib(cma_dev->device, p)) ? 2089 2081 ARPHRD_INFINIBAND : ARPHRD_ETHER; 2090 2082 2091 2083 rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid); ··· 2562 2554 2563 2555 id_priv->backlog = backlog; 2564 2556 if (id->device) { 2565 - switch (rdma_node_get_transport(id->device->node_type)) { 2566 - case RDMA_TRANSPORT_IB: 2557 + if (rdma_cap_ib_cm(id->device, 1)) { 2567 2558 ret = cma_ib_listen(id_priv); 2568 2559 if (ret) 2569 2560 goto err; 2570 - break; 2571 - case RDMA_TRANSPORT_IWARP: 2561 + } else if (rdma_cap_iw_cm(id->device, 1)) { 2572 2562 ret = cma_iw_listen(id_priv, backlog); 2573 2563 if (ret) 2574 2564 goto err; 2575 - break; 2576 - default: 2565 + } else { 2577 2566 ret = -ENOSYS; 2578 2567 goto err; 2579 2568 } ··· 2862 2857 if (IS_ERR(cm_id)) 2863 2858 return PTR_ERR(cm_id); 2864 2859 2860 + cm_id->tos = id_priv->tos; 2865 2861 id_priv->cm_id.iw = cm_id; 2866 2862 2867 2863 memcpy(&cm_id->local_addr, cma_src_addr(id_priv), ··· 2907 2901 id_priv->srq = conn_param->srq; 2908 2902 } 2909 2903 2910 - switch (rdma_node_get_transport(id->device->node_type)) { 2911 - case RDMA_TRANSPORT_IB: 2904 + if (rdma_cap_ib_cm(id->device, id->port_num)) { 2912 2905 if (id->qp_type == IB_QPT_UD) 2913 2906 ret = cma_resolve_ib_udp(id_priv, conn_param); 2914 2907 else 2915 2908 ret = cma_connect_ib(id_priv, conn_param); 2916 - break; 2917 - case RDMA_TRANSPORT_IWARP: 2909 + } else if (rdma_cap_iw_cm(id->device, id->port_num)) 2918 2910 ret = cma_connect_iw(id_priv, conn_param); 2919 - break; 2920 - default: 2911 + else 2921 2912 ret = -ENOSYS; 2922 - break; 2923 - } 2924 2913 if (ret) 2925 2914 goto err; 2926 2915 ··· 3018 3017 id_priv->srq = conn_param->srq; 3019 3018 } 3020 3019 3021 - switch (rdma_node_get_transport(id->device->node_type)) { 3022 - case RDMA_TRANSPORT_IB: 3020 + if (rdma_cap_ib_cm(id->device, id->port_num)) { 3023 3021 if (id->qp_type == IB_QPT_UD) { 3024 3022 if (conn_param) 3025 3023 ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS, ··· 3034 3034 else 3035 3035 ret = cma_rep_recv(id_priv); 3036 3036 } 3037 - break; 3038 - case RDMA_TRANSPORT_IWARP: 3037 + } else if (rdma_cap_iw_cm(id->device, id->port_num)) 3039 3038 ret = cma_accept_iw(id_priv, conn_param); 3040 - break; 3041 - default: 3039 + else 3042 3040 ret = -ENOSYS; 3043 - break; 3044 - } 3045 3041 3046 3042 if (ret) 3047 3043 goto reject; ··· 3081 3085 if (!id_priv->cm_id.ib) 3082 3086 return -EINVAL; 3083 3087 3084 - switch (rdma_node_get_transport(id->device->node_type)) { 3085 - case RDMA_TRANSPORT_IB: 3088 + if (rdma_cap_ib_cm(id->device, id->port_num)) { 3086 3089 if (id->qp_type == IB_QPT_UD) 3087 3090 ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0, 3088 3091 private_data, private_data_len); ··· 3089 3094 ret = ib_send_cm_rej(id_priv->cm_id.ib, 3090 3095 IB_CM_REJ_CONSUMER_DEFINED, NULL, 3091 3096 0, private_data, private_data_len); 3092 - break; 3093 - case RDMA_TRANSPORT_IWARP: 3097 + } else if (rdma_cap_iw_cm(id->device, id->port_num)) { 3094 3098 ret = iw_cm_reject(id_priv->cm_id.iw, 3095 3099 private_data, private_data_len); 3096 - break; 3097 - default: 3100 + } else 3098 3101 ret = -ENOSYS; 3099 - break; 3100 - } 3102 + 3101 3103 return ret; 3102 3104 } 3103 3105 EXPORT_SYMBOL(rdma_reject); ··· 3108 3116 if (!id_priv->cm_id.ib) 3109 3117 return -EINVAL; 3110 3118 3111 - switch (rdma_node_get_transport(id->device->node_type)) { 3112 - case RDMA_TRANSPORT_IB: 3119 + if (rdma_cap_ib_cm(id->device, id->port_num)) { 3113 3120 ret = cma_modify_qp_err(id_priv); 3114 3121 if (ret) 3115 3122 goto out; 3116 3123 /* Initiate or respond to a disconnect. */ 3117 3124 if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) 3118 3125 ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0); 3119 - break; 3120 - case RDMA_TRANSPORT_IWARP: 3126 + } else if (rdma_cap_iw_cm(id->device, id->port_num)) { 3121 3127 ret = iw_cm_disconnect(id_priv->cm_id.iw, 0); 3122 - break; 3123 - default: 3128 + } else 3124 3129 ret = -EINVAL; 3125 - break; 3126 - } 3130 + 3127 3131 out: 3128 3132 return ret; 3129 3133 } ··· 3365 3377 list_add(&mc->list, &id_priv->mc_list); 3366 3378 spin_unlock(&id_priv->lock); 3367 3379 3368 - switch (rdma_node_get_transport(id->device->node_type)) { 3369 - case RDMA_TRANSPORT_IB: 3370 - switch (rdma_port_get_link_layer(id->device, id->port_num)) { 3371 - case IB_LINK_LAYER_INFINIBAND: 3372 - ret = cma_join_ib_multicast(id_priv, mc); 3373 - break; 3374 - case IB_LINK_LAYER_ETHERNET: 3375 - kref_init(&mc->mcref); 3376 - ret = cma_iboe_join_multicast(id_priv, mc); 3377 - break; 3378 - default: 3379 - ret = -EINVAL; 3380 - } 3381 - break; 3382 - default: 3380 + if (rdma_protocol_roce(id->device, id->port_num)) { 3381 + kref_init(&mc->mcref); 3382 + ret = cma_iboe_join_multicast(id_priv, mc); 3383 + } else if (rdma_cap_ib_mcast(id->device, id->port_num)) 3384 + ret = cma_join_ib_multicast(id_priv, mc); 3385 + else 3383 3386 ret = -ENOSYS; 3384 - break; 3385 - } 3386 3387 3387 3388 if (ret) { 3388 3389 spin_lock_irq(&id_priv->lock); ··· 3399 3422 ib_detach_mcast(id->qp, 3400 3423 &mc->multicast.ib->rec.mgid, 3401 3424 be16_to_cpu(mc->multicast.ib->rec.mlid)); 3402 - if (rdma_node_get_transport(id_priv->cma_dev->device->node_type) == RDMA_TRANSPORT_IB) { 3403 - switch (rdma_port_get_link_layer(id->device, id->port_num)) { 3404 - case IB_LINK_LAYER_INFINIBAND: 3405 - ib_sa_free_multicast(mc->multicast.ib); 3406 - kfree(mc); 3407 - break; 3408 - case IB_LINK_LAYER_ETHERNET: 3409 - kref_put(&mc->mcref, release_mc); 3410 - break; 3411 - default: 3412 - break; 3413 - } 3414 - } 3425 + 3426 + BUG_ON(id_priv->cma_dev->device != id->device); 3427 + 3428 + if (rdma_cap_ib_mcast(id->device, id->port_num)) { 3429 + ib_sa_free_multicast(mc->multicast.ib); 3430 + kfree(mc); 3431 + } else if (rdma_protocol_roce(id->device, id->port_num)) 3432 + kref_put(&mc->mcref, release_mc); 3433 + 3415 3434 return; 3416 3435 } 3417 3436 }
+45 -49
drivers/infiniband/core/device.c
··· 92 92 IB_MANDATORY_FUNC(poll_cq), 93 93 IB_MANDATORY_FUNC(req_notify_cq), 94 94 IB_MANDATORY_FUNC(get_dma_mr), 95 - IB_MANDATORY_FUNC(dereg_mr) 95 + IB_MANDATORY_FUNC(dereg_mr), 96 + IB_MANDATORY_FUNC(get_port_immutable) 96 97 }; 97 98 int i; 98 99 ··· 150 149 151 150 strlcpy(name, buf, IB_DEVICE_NAME_MAX); 152 151 return 0; 153 - } 154 - 155 - static int start_port(struct ib_device *device) 156 - { 157 - return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1; 158 - } 159 - 160 - 161 - static int end_port(struct ib_device *device) 162 - { 163 - return (device->node_type == RDMA_NODE_IB_SWITCH) ? 164 - 0 : device->phys_port_cnt; 165 152 } 166 153 167 154 /** ··· 211 222 return 0; 212 223 } 213 224 214 - static int read_port_table_lengths(struct ib_device *device) 225 + static int verify_immutable(const struct ib_device *dev, u8 port) 215 226 { 216 - struct ib_port_attr *tprops = NULL; 217 - int num_ports, ret = -ENOMEM; 218 - u8 port_index; 227 + return WARN_ON(!rdma_cap_ib_mad(dev, port) && 228 + rdma_max_mad_size(dev, port) != 0); 229 + } 219 230 220 - tprops = kmalloc(sizeof *tprops, GFP_KERNEL); 221 - if (!tprops) 222 - goto out; 231 + static int read_port_immutable(struct ib_device *device) 232 + { 233 + int ret = -ENOMEM; 234 + u8 start_port = rdma_start_port(device); 235 + u8 end_port = rdma_end_port(device); 236 + u8 port; 223 237 224 - num_ports = end_port(device) - start_port(device) + 1; 225 - 226 - device->pkey_tbl_len = kmalloc(sizeof *device->pkey_tbl_len * num_ports, 227 - GFP_KERNEL); 228 - device->gid_tbl_len = kmalloc(sizeof *device->gid_tbl_len * num_ports, 229 - GFP_KERNEL); 230 - if (!device->pkey_tbl_len || !device->gid_tbl_len) 238 + /** 239 + * device->port_immutable is indexed directly by the port number to make 240 + * access to this data as efficient as possible. 241 + * 242 + * Therefore port_immutable is declared as a 1 based array with 243 + * potential empty slots at the beginning. 244 + */ 245 + device->port_immutable = kzalloc(sizeof(*device->port_immutable) 246 + * (end_port + 1), 247 + GFP_KERNEL); 248 + if (!device->port_immutable) 231 249 goto err; 232 250 233 - for (port_index = 0; port_index < num_ports; ++port_index) { 234 - ret = ib_query_port(device, port_index + start_port(device), 235 - tprops); 251 + for (port = start_port; port <= end_port; ++port) { 252 + ret = device->get_port_immutable(device, port, 253 + &device->port_immutable[port]); 236 254 if (ret) 237 255 goto err; 238 - device->pkey_tbl_len[port_index] = tprops->pkey_tbl_len; 239 - device->gid_tbl_len[port_index] = tprops->gid_tbl_len; 256 + 257 + if (verify_immutable(device, port)) { 258 + ret = -EINVAL; 259 + goto err; 260 + } 240 261 } 241 262 242 263 ret = 0; 243 264 goto out; 244 - 245 265 err: 246 - kfree(device->gid_tbl_len); 247 - kfree(device->pkey_tbl_len); 266 + kfree(device->port_immutable); 248 267 out: 249 - kfree(tprops); 250 268 return ret; 251 269 } 252 270 ··· 290 294 spin_lock_init(&device->event_handler_lock); 291 295 spin_lock_init(&device->client_data_lock); 292 296 293 - ret = read_port_table_lengths(device); 297 + ret = read_port_immutable(device); 294 298 if (ret) { 295 - printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n", 299 + printk(KERN_WARNING "Couldn't create per port immutable data %s\n", 296 300 device->name); 297 301 goto out; 298 302 } ··· 301 305 if (ret) { 302 306 printk(KERN_WARNING "Couldn't register device %s with driver model\n", 303 307 device->name); 304 - kfree(device->gid_tbl_len); 305 - kfree(device->pkey_tbl_len); 308 + kfree(device->port_immutable); 306 309 goto out; 307 310 } 308 311 ··· 342 347 client->remove(device); 343 348 344 349 list_del(&device->core_list); 345 - 346 - kfree(device->gid_tbl_len); 347 - kfree(device->pkey_tbl_len); 348 350 349 351 mutex_unlock(&device_mutex); 350 352 ··· 550 558 int ib_query_device(struct ib_device *device, 551 559 struct ib_device_attr *device_attr) 552 560 { 553 - return device->query_device(device, device_attr); 561 + struct ib_udata uhw = {.outlen = 0, .inlen = 0}; 562 + 563 + memset(device_attr, 0, sizeof(*device_attr)); 564 + 565 + return device->query_device(device, device_attr, &uhw); 554 566 } 555 567 EXPORT_SYMBOL(ib_query_device); 556 568 ··· 571 575 u8 port_num, 572 576 struct ib_port_attr *port_attr) 573 577 { 574 - if (port_num < start_port(device) || port_num > end_port(device)) 578 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 575 579 return -EINVAL; 576 580 577 581 return device->query_port(device, port_num, port_attr); ··· 649 653 if (!device->modify_port) 650 654 return -ENOSYS; 651 655 652 - if (port_num < start_port(device) || port_num > end_port(device)) 656 + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) 653 657 return -EINVAL; 654 658 655 659 return device->modify_port(device, port_num, port_modify_mask, ··· 672 676 union ib_gid tmp_gid; 673 677 int ret, port, i; 674 678 675 - for (port = start_port(device); port <= end_port(device); ++port) { 676 - for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) { 679 + for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) { 680 + for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) { 677 681 ret = ib_query_gid(device, port, i, &tmp_gid); 678 682 if (ret) 679 683 return ret; ··· 705 709 u16 tmp_pkey; 706 710 int partial_ix = -1; 707 711 708 - for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) { 712 + for (i = 0; i < device->port_immutable[port_num].pkey_tbl_len; ++i) { 709 713 ret = ib_query_pkey(device, port_num, i, &tmp_pkey); 710 714 if (ret) 711 715 return ret;
+430 -209
drivers/infiniband/core/mad.c
··· 3 3 * Copyright (c) 2005 Intel Corporation. All rights reserved. 4 4 * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. 5 5 * Copyright (c) 2009 HNR Consulting. All rights reserved. 6 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 6 7 * 7 8 * This software is available to you under a choice of one of two 8 9 * licenses. You may choose to be licensed under the terms of the GNU ··· 45 44 #include "mad_priv.h" 46 45 #include "mad_rmpp.h" 47 46 #include "smi.h" 47 + #include "opa_smi.h" 48 48 #include "agent.h" 49 49 50 50 MODULE_LICENSE("Dual BSD/GPL"); ··· 61 59 module_param_named(recv_queue_size, mad_recvq_size, int, 0444); 62 60 MODULE_PARM_DESC(recv_queue_size, "Size of receive queue in number of work requests"); 63 61 64 - static struct kmem_cache *ib_mad_cache; 65 - 66 62 static struct list_head ib_mad_port_list; 67 63 static u32 ib_mad_client_id = 0; 68 64 ··· 73 73 static void remove_mad_reg_req(struct ib_mad_agent_private *priv); 74 74 static struct ib_mad_agent_private *find_mad_agent( 75 75 struct ib_mad_port_private *port_priv, 76 - struct ib_mad *mad); 76 + const struct ib_mad_hdr *mad); 77 77 static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info, 78 78 struct ib_mad_private *mad); 79 79 static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv); ··· 179 179 return 0; 180 180 } 181 181 182 - int ib_response_mad(struct ib_mad *mad) 182 + int ib_response_mad(const struct ib_mad_hdr *hdr) 183 183 { 184 - return ((mad->mad_hdr.method & IB_MGMT_METHOD_RESP) || 185 - (mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) || 186 - ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_BM) && 187 - (mad->mad_hdr.attr_mod & IB_BM_ATTR_MOD_RESP))); 184 + return ((hdr->method & IB_MGMT_METHOD_RESP) || 185 + (hdr->method == IB_MGMT_METHOD_TRAP_REPRESS) || 186 + ((hdr->mgmt_class == IB_MGMT_CLASS_BM) && 187 + (hdr->attr_mod & IB_BM_ATTR_MOD_RESP))); 188 188 } 189 189 EXPORT_SYMBOL(ib_response_mad); 190 190 ··· 717 717 wc->port_num = port_num; 718 718 } 719 719 720 + static size_t mad_priv_size(const struct ib_mad_private *mp) 721 + { 722 + return sizeof(struct ib_mad_private) + mp->mad_size; 723 + } 724 + 725 + static struct ib_mad_private *alloc_mad_private(size_t mad_size, gfp_t flags) 726 + { 727 + size_t size = sizeof(struct ib_mad_private) + mad_size; 728 + struct ib_mad_private *ret = kzalloc(size, flags); 729 + 730 + if (ret) 731 + ret->mad_size = mad_size; 732 + 733 + return ret; 734 + } 735 + 736 + static size_t port_mad_size(const struct ib_mad_port_private *port_priv) 737 + { 738 + return rdma_max_mad_size(port_priv->device, port_priv->port_num); 739 + } 740 + 741 + static size_t mad_priv_dma_size(const struct ib_mad_private *mp) 742 + { 743 + return sizeof(struct ib_grh) + mp->mad_size; 744 + } 745 + 720 746 /* 721 747 * Return 0 if SMP is to be sent 722 748 * Return 1 if SMP was consumed locally (whether or not solicited) ··· 753 727 { 754 728 int ret = 0; 755 729 struct ib_smp *smp = mad_send_wr->send_buf.mad; 730 + struct opa_smp *opa_smp = (struct opa_smp *)smp; 756 731 unsigned long flags; 757 732 struct ib_mad_local_private *local; 758 733 struct ib_mad_private *mad_priv; ··· 763 736 u8 port_num; 764 737 struct ib_wc mad_wc; 765 738 struct ib_send_wr *send_wr = &mad_send_wr->send_wr; 739 + size_t mad_size = port_mad_size(mad_agent_priv->qp_info->port_priv); 740 + u16 out_mad_pkey_index = 0; 741 + u16 drslid; 742 + bool opa = rdma_cap_opa_mad(mad_agent_priv->qp_info->port_priv->device, 743 + mad_agent_priv->qp_info->port_priv->port_num); 766 744 767 745 if (device->node_type == RDMA_NODE_IB_SWITCH && 768 746 smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) ··· 781 749 * If we are at the start of the LID routed part, don't update the 782 750 * hop_ptr or hop_cnt. See section 14.2.2, Vol 1 IB spec. 783 751 */ 784 - if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) == 785 - IB_LID_PERMISSIVE && 786 - smi_handle_dr_smp_send(smp, device->node_type, port_num) == 787 - IB_SMI_DISCARD) { 788 - ret = -EINVAL; 789 - dev_err(&device->dev, "Invalid directed route\n"); 790 - goto out; 791 - } 752 + if (opa && smp->class_version == OPA_SMP_CLASS_VERSION) { 753 + u32 opa_drslid; 792 754 793 - /* Check to post send on QP or process locally */ 794 - if (smi_check_local_smp(smp, device) == IB_SMI_DISCARD && 795 - smi_check_local_returning_smp(smp, device) == IB_SMI_DISCARD) 796 - goto out; 755 + if ((opa_get_smp_direction(opa_smp) 756 + ? opa_smp->route.dr.dr_dlid : opa_smp->route.dr.dr_slid) == 757 + OPA_LID_PERMISSIVE && 758 + opa_smi_handle_dr_smp_send(opa_smp, device->node_type, 759 + port_num) == IB_SMI_DISCARD) { 760 + ret = -EINVAL; 761 + dev_err(&device->dev, "OPA Invalid directed route\n"); 762 + goto out; 763 + } 764 + opa_drslid = be32_to_cpu(opa_smp->route.dr.dr_slid); 765 + if (opa_drslid != OPA_LID_PERMISSIVE && 766 + opa_drslid & 0xffff0000) { 767 + ret = -EINVAL; 768 + dev_err(&device->dev, "OPA Invalid dr_slid 0x%x\n", 769 + opa_drslid); 770 + goto out; 771 + } 772 + drslid = (u16)(opa_drslid & 0x0000ffff); 773 + 774 + /* Check to post send on QP or process locally */ 775 + if (opa_smi_check_local_smp(opa_smp, device) == IB_SMI_DISCARD && 776 + opa_smi_check_local_returning_smp(opa_smp, device) == IB_SMI_DISCARD) 777 + goto out; 778 + } else { 779 + if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) == 780 + IB_LID_PERMISSIVE && 781 + smi_handle_dr_smp_send(smp, device->node_type, port_num) == 782 + IB_SMI_DISCARD) { 783 + ret = -EINVAL; 784 + dev_err(&device->dev, "Invalid directed route\n"); 785 + goto out; 786 + } 787 + drslid = be16_to_cpu(smp->dr_slid); 788 + 789 + /* Check to post send on QP or process locally */ 790 + if (smi_check_local_smp(smp, device) == IB_SMI_DISCARD && 791 + smi_check_local_returning_smp(smp, device) == IB_SMI_DISCARD) 792 + goto out; 793 + } 797 794 798 795 local = kmalloc(sizeof *local, GFP_ATOMIC); 799 796 if (!local) { ··· 832 771 } 833 772 local->mad_priv = NULL; 834 773 local->recv_mad_agent = NULL; 835 - mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_ATOMIC); 774 + mad_priv = alloc_mad_private(mad_size, GFP_ATOMIC); 836 775 if (!mad_priv) { 837 776 ret = -ENOMEM; 838 777 dev_err(&device->dev, "No memory for local response MAD\n"); ··· 841 780 } 842 781 843 782 build_smp_wc(mad_agent_priv->agent.qp, 844 - send_wr->wr_id, be16_to_cpu(smp->dr_slid), 783 + send_wr->wr_id, drslid, 845 784 send_wr->wr.ud.pkey_index, 846 785 send_wr->wr.ud.port_num, &mad_wc); 847 786 787 + if (opa && smp->base_version == OPA_MGMT_BASE_VERSION) { 788 + mad_wc.byte_len = mad_send_wr->send_buf.hdr_len 789 + + mad_send_wr->send_buf.data_len 790 + + sizeof(struct ib_grh); 791 + } 792 + 848 793 /* No GRH for DR SMP */ 849 794 ret = device->process_mad(device, 0, port_num, &mad_wc, NULL, 850 - (struct ib_mad *)smp, 851 - (struct ib_mad *)&mad_priv->mad); 795 + (const struct ib_mad_hdr *)smp, mad_size, 796 + (struct ib_mad_hdr *)mad_priv->mad, 797 + &mad_size, &out_mad_pkey_index); 852 798 switch (ret) 853 799 { 854 800 case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY: 855 - if (ib_response_mad(&mad_priv->mad.mad) && 801 + if (ib_response_mad((const struct ib_mad_hdr *)mad_priv->mad) && 856 802 mad_agent_priv->agent.recv_handler) { 857 803 local->mad_priv = mad_priv; 858 804 local->recv_mad_agent = mad_agent_priv; ··· 869 801 */ 870 802 atomic_inc(&mad_agent_priv->refcount); 871 803 } else 872 - kmem_cache_free(ib_mad_cache, mad_priv); 804 + kfree(mad_priv); 873 805 break; 874 806 case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED: 875 - kmem_cache_free(ib_mad_cache, mad_priv); 807 + kfree(mad_priv); 876 808 break; 877 809 case IB_MAD_RESULT_SUCCESS: 878 810 /* Treat like an incoming receive MAD */ 879 811 port_priv = ib_get_mad_port(mad_agent_priv->agent.device, 880 812 mad_agent_priv->agent.port_num); 881 813 if (port_priv) { 882 - memcpy(&mad_priv->mad.mad, smp, sizeof(struct ib_mad)); 814 + memcpy(mad_priv->mad, smp, mad_priv->mad_size); 883 815 recv_mad_agent = find_mad_agent(port_priv, 884 - &mad_priv->mad.mad); 816 + (const struct ib_mad_hdr *)mad_priv->mad); 885 817 } 886 818 if (!port_priv || !recv_mad_agent) { 887 819 /* 888 820 * No receiving agent so drop packet and 889 821 * generate send completion. 890 822 */ 891 - kmem_cache_free(ib_mad_cache, mad_priv); 823 + kfree(mad_priv); 892 824 break; 893 825 } 894 826 local->mad_priv = mad_priv; 895 827 local->recv_mad_agent = recv_mad_agent; 896 828 break; 897 829 default: 898 - kmem_cache_free(ib_mad_cache, mad_priv); 830 + kfree(mad_priv); 899 831 kfree(local); 900 832 ret = -EINVAL; 901 833 goto out; 902 834 } 903 835 904 836 local->mad_send_wr = mad_send_wr; 837 + if (opa) { 838 + local->mad_send_wr->send_wr.wr.ud.pkey_index = out_mad_pkey_index; 839 + local->return_wc_byte_len = mad_size; 840 + } 905 841 /* Reference MAD agent until send side of local completion handled */ 906 842 atomic_inc(&mad_agent_priv->refcount); 907 843 /* Queue local completion to local list */ ··· 919 847 return ret; 920 848 } 921 849 922 - static int get_pad_size(int hdr_len, int data_len) 850 + static int get_pad_size(int hdr_len, int data_len, size_t mad_size) 923 851 { 924 852 int seg_size, pad; 925 853 926 - seg_size = sizeof(struct ib_mad) - hdr_len; 854 + seg_size = mad_size - hdr_len; 927 855 if (data_len && seg_size) { 928 856 pad = seg_size - data_len % seg_size; 929 857 return pad == seg_size ? 0 : pad; ··· 942 870 } 943 871 944 872 static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr, 945 - gfp_t gfp_mask) 873 + size_t mad_size, gfp_t gfp_mask) 946 874 { 947 875 struct ib_mad_send_buf *send_buf = &send_wr->send_buf; 948 876 struct ib_rmpp_mad *rmpp_mad = send_buf->mad; 949 877 struct ib_rmpp_segment *seg = NULL; 950 878 int left, seg_size, pad; 951 879 952 - send_buf->seg_size = sizeof (struct ib_mad) - send_buf->hdr_len; 880 + send_buf->seg_size = mad_size - send_buf->hdr_len; 881 + send_buf->seg_rmpp_size = mad_size - IB_MGMT_RMPP_HDR; 953 882 seg_size = send_buf->seg_size; 954 883 pad = send_wr->pad; 955 884 ··· 983 910 return 0; 984 911 } 985 912 986 - int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent) 913 + int ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent) 987 914 { 988 915 return agent->rmpp_version && !(agent->flags & IB_MAD_USER_RMPP); 989 916 } ··· 993 920 u32 remote_qpn, u16 pkey_index, 994 921 int rmpp_active, 995 922 int hdr_len, int data_len, 996 - gfp_t gfp_mask) 923 + gfp_t gfp_mask, 924 + u8 base_version) 997 925 { 998 926 struct ib_mad_agent_private *mad_agent_priv; 999 927 struct ib_mad_send_wr_private *mad_send_wr; 1000 928 int pad, message_size, ret, size; 1001 929 void *buf; 930 + size_t mad_size; 931 + bool opa; 1002 932 1003 933 mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private, 1004 934 agent); 1005 - pad = get_pad_size(hdr_len, data_len); 935 + 936 + opa = rdma_cap_opa_mad(mad_agent->device, mad_agent->port_num); 937 + 938 + if (opa && base_version == OPA_MGMT_BASE_VERSION) 939 + mad_size = sizeof(struct opa_mad); 940 + else 941 + mad_size = sizeof(struct ib_mad); 942 + 943 + pad = get_pad_size(hdr_len, data_len, mad_size); 1006 944 message_size = hdr_len + data_len + pad; 1007 945 1008 946 if (ib_mad_kernel_rmpp_agent(mad_agent)) { 1009 - if (!rmpp_active && message_size > sizeof(struct ib_mad)) 947 + if (!rmpp_active && message_size > mad_size) 1010 948 return ERR_PTR(-EINVAL); 1011 949 } else 1012 - if (rmpp_active || message_size > sizeof(struct ib_mad)) 950 + if (rmpp_active || message_size > mad_size) 1013 951 return ERR_PTR(-EINVAL); 1014 952 1015 - size = rmpp_active ? hdr_len : sizeof(struct ib_mad); 953 + size = rmpp_active ? hdr_len : mad_size; 1016 954 buf = kzalloc(sizeof *mad_send_wr + size, gfp_mask); 1017 955 if (!buf) 1018 956 return ERR_PTR(-ENOMEM); ··· 1038 954 mad_send_wr->mad_agent_priv = mad_agent_priv; 1039 955 mad_send_wr->sg_list[0].length = hdr_len; 1040 956 mad_send_wr->sg_list[0].lkey = mad_agent->mr->lkey; 1041 - mad_send_wr->sg_list[1].length = sizeof(struct ib_mad) - hdr_len; 957 + 958 + /* OPA MADs don't have to be the full 2048 bytes */ 959 + if (opa && base_version == OPA_MGMT_BASE_VERSION && 960 + data_len < mad_size - hdr_len) 961 + mad_send_wr->sg_list[1].length = data_len; 962 + else 963 + mad_send_wr->sg_list[1].length = mad_size - hdr_len; 964 + 1042 965 mad_send_wr->sg_list[1].lkey = mad_agent->mr->lkey; 1043 966 1044 967 mad_send_wr->send_wr.wr_id = (unsigned long) mad_send_wr; ··· 1058 967 mad_send_wr->send_wr.wr.ud.pkey_index = pkey_index; 1059 968 1060 969 if (rmpp_active) { 1061 - ret = alloc_send_rmpp_list(mad_send_wr, gfp_mask); 970 + ret = alloc_send_rmpp_list(mad_send_wr, mad_size, gfp_mask); 1062 971 if (ret) { 1063 972 kfree(buf); 1064 973 return ERR_PTR(ret); ··· 1328 1237 recv_wc); 1329 1238 priv = container_of(mad_priv_hdr, struct ib_mad_private, 1330 1239 header); 1331 - kmem_cache_free(ib_mad_cache, priv); 1240 + kfree(priv); 1332 1241 } 1333 1242 } 1334 1243 EXPORT_SYMBOL(ib_free_recv_mad); ··· 1415 1324 } 1416 1325 1417 1326 static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class, 1418 - char *oui) 1327 + const char *oui) 1419 1328 { 1420 1329 int i; 1421 1330 ··· 1713 1622 1714 1623 static struct ib_mad_agent_private * 1715 1624 find_mad_agent(struct ib_mad_port_private *port_priv, 1716 - struct ib_mad *mad) 1625 + const struct ib_mad_hdr *mad_hdr) 1717 1626 { 1718 1627 struct ib_mad_agent_private *mad_agent = NULL; 1719 1628 unsigned long flags; 1720 1629 1721 1630 spin_lock_irqsave(&port_priv->reg_lock, flags); 1722 - if (ib_response_mad(mad)) { 1631 + if (ib_response_mad(mad_hdr)) { 1723 1632 u32 hi_tid; 1724 1633 struct ib_mad_agent_private *entry; 1725 1634 ··· 1727 1636 * Routing is based on high 32 bits of transaction ID 1728 1637 * of MAD. 1729 1638 */ 1730 - hi_tid = be64_to_cpu(mad->mad_hdr.tid) >> 32; 1639 + hi_tid = be64_to_cpu(mad_hdr->tid) >> 32; 1731 1640 list_for_each_entry(entry, &port_priv->agent_list, agent_list) { 1732 1641 if (entry->agent.hi_tid == hi_tid) { 1733 1642 mad_agent = entry; ··· 1739 1648 struct ib_mad_mgmt_method_table *method; 1740 1649 struct ib_mad_mgmt_vendor_class_table *vendor; 1741 1650 struct ib_mad_mgmt_vendor_class *vendor_class; 1742 - struct ib_vendor_mad *vendor_mad; 1651 + const struct ib_vendor_mad *vendor_mad; 1743 1652 int index; 1744 1653 1745 1654 /* 1746 1655 * Routing is based on version, class, and method 1747 1656 * For "newer" vendor MADs, also based on OUI 1748 1657 */ 1749 - if (mad->mad_hdr.class_version >= MAX_MGMT_VERSION) 1658 + if (mad_hdr->class_version >= MAX_MGMT_VERSION) 1750 1659 goto out; 1751 - if (!is_vendor_class(mad->mad_hdr.mgmt_class)) { 1660 + if (!is_vendor_class(mad_hdr->mgmt_class)) { 1752 1661 class = port_priv->version[ 1753 - mad->mad_hdr.class_version].class; 1662 + mad_hdr->class_version].class; 1754 1663 if (!class) 1755 1664 goto out; 1756 - if (convert_mgmt_class(mad->mad_hdr.mgmt_class) >= 1665 + if (convert_mgmt_class(mad_hdr->mgmt_class) >= 1757 1666 IB_MGMT_MAX_METHODS) 1758 1667 goto out; 1759 1668 method = class->method_table[convert_mgmt_class( 1760 - mad->mad_hdr.mgmt_class)]; 1669 + mad_hdr->mgmt_class)]; 1761 1670 if (method) 1762 - mad_agent = method->agent[mad->mad_hdr.method & 1671 + mad_agent = method->agent[mad_hdr->method & 1763 1672 ~IB_MGMT_METHOD_RESP]; 1764 1673 } else { 1765 1674 vendor = port_priv->version[ 1766 - mad->mad_hdr.class_version].vendor; 1675 + mad_hdr->class_version].vendor; 1767 1676 if (!vendor) 1768 1677 goto out; 1769 1678 vendor_class = vendor->vendor_class[vendor_class_index( 1770 - mad->mad_hdr.mgmt_class)]; 1679 + mad_hdr->mgmt_class)]; 1771 1680 if (!vendor_class) 1772 1681 goto out; 1773 1682 /* Find matching OUI */ 1774 - vendor_mad = (struct ib_vendor_mad *)mad; 1683 + vendor_mad = (const struct ib_vendor_mad *)mad_hdr; 1775 1684 index = find_vendor_oui(vendor_class, vendor_mad->oui); 1776 1685 if (index == -1) 1777 1686 goto out; 1778 1687 method = vendor_class->method_table[index]; 1779 1688 if (method) { 1780 - mad_agent = method->agent[mad->mad_hdr.method & 1689 + mad_agent = method->agent[mad_hdr->method & 1781 1690 ~IB_MGMT_METHOD_RESP]; 1782 1691 } 1783 1692 } ··· 1799 1708 return mad_agent; 1800 1709 } 1801 1710 1802 - static int validate_mad(struct ib_mad *mad, u32 qp_num) 1711 + static int validate_mad(const struct ib_mad_hdr *mad_hdr, 1712 + const struct ib_mad_qp_info *qp_info, 1713 + bool opa) 1803 1714 { 1804 1715 int valid = 0; 1716 + u32 qp_num = qp_info->qp->qp_num; 1805 1717 1806 1718 /* Make sure MAD base version is understood */ 1807 - if (mad->mad_hdr.base_version != IB_MGMT_BASE_VERSION) { 1808 - pr_err("MAD received with unsupported base version %d\n", 1809 - mad->mad_hdr.base_version); 1719 + if (mad_hdr->base_version != IB_MGMT_BASE_VERSION && 1720 + (!opa || mad_hdr->base_version != OPA_MGMT_BASE_VERSION)) { 1721 + pr_err("MAD received with unsupported base version %d %s\n", 1722 + mad_hdr->base_version, opa ? "(opa)" : ""); 1810 1723 goto out; 1811 1724 } 1812 1725 1813 1726 /* Filter SMI packets sent to other than QP0 */ 1814 - if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) || 1815 - (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) { 1727 + if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) || 1728 + (mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) { 1816 1729 if (qp_num == 0) 1817 1730 valid = 1; 1818 1731 } else { ··· 1829 1734 return valid; 1830 1735 } 1831 1736 1832 - static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv, 1833 - struct ib_mad_hdr *mad_hdr) 1737 + static int is_rmpp_data_mad(const struct ib_mad_agent_private *mad_agent_priv, 1738 + const struct ib_mad_hdr *mad_hdr) 1834 1739 { 1835 1740 struct ib_rmpp_mad *rmpp_mad; 1836 1741 ··· 1842 1747 (rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA); 1843 1748 } 1844 1749 1845 - static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr, 1846 - struct ib_mad_recv_wc *rwc) 1750 + static inline int rcv_has_same_class(const struct ib_mad_send_wr_private *wr, 1751 + const struct ib_mad_recv_wc *rwc) 1847 1752 { 1848 - return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class == 1753 + return ((struct ib_mad_hdr *)(wr->send_buf.mad))->mgmt_class == 1849 1754 rwc->recv_buf.mad->mad_hdr.mgmt_class; 1850 1755 } 1851 1756 1852 - static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv, 1853 - struct ib_mad_send_wr_private *wr, 1854 - struct ib_mad_recv_wc *rwc ) 1757 + static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_priv, 1758 + const struct ib_mad_send_wr_private *wr, 1759 + const struct ib_mad_recv_wc *rwc ) 1855 1760 { 1856 1761 struct ib_ah_attr attr; 1857 1762 u8 send_resp, rcv_resp; ··· 1860 1765 u8 port_num = mad_agent_priv->agent.port_num; 1861 1766 u8 lmc; 1862 1767 1863 - send_resp = ib_response_mad((struct ib_mad *)wr->send_buf.mad); 1864 - rcv_resp = ib_response_mad(rwc->recv_buf.mad); 1768 + send_resp = ib_response_mad((struct ib_mad_hdr *)wr->send_buf.mad); 1769 + rcv_resp = ib_response_mad(&rwc->recv_buf.mad->mad_hdr); 1865 1770 1866 1771 if (send_resp == rcv_resp) 1867 1772 /* both requests, or both responses. GIDs different */ ··· 1906 1811 } 1907 1812 1908 1813 struct ib_mad_send_wr_private* 1909 - ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, 1910 - struct ib_mad_recv_wc *wc) 1814 + ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv, 1815 + const struct ib_mad_recv_wc *wc) 1911 1816 { 1912 1817 struct ib_mad_send_wr_private *wr; 1913 - struct ib_mad *mad; 1818 + const struct ib_mad_hdr *mad_hdr; 1914 1819 1915 - mad = (struct ib_mad *)wc->recv_buf.mad; 1820 + mad_hdr = &wc->recv_buf.mad->mad_hdr; 1916 1821 1917 1822 list_for_each_entry(wr, &mad_agent_priv->wait_list, agent_list) { 1918 - if ((wr->tid == mad->mad_hdr.tid) && 1823 + if ((wr->tid == mad_hdr->tid) && 1919 1824 rcv_has_same_class(wr, wc) && 1920 1825 /* 1921 1826 * Don't check GID for direct routed MADs. 1922 1827 * These might have permissive LIDs. 1923 1828 */ 1924 - (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) || 1829 + (is_direct(mad_hdr->mgmt_class) || 1925 1830 rcv_has_same_gid(mad_agent_priv, wr, wc))) 1926 1831 return (wr->status == IB_WC_SUCCESS) ? wr : NULL; 1927 1832 } ··· 1931 1836 * been notified that the send has completed 1932 1837 */ 1933 1838 list_for_each_entry(wr, &mad_agent_priv->send_list, agent_list) { 1934 - if (is_data_mad(mad_agent_priv, wr->send_buf.mad) && 1935 - wr->tid == mad->mad_hdr.tid && 1839 + if (is_rmpp_data_mad(mad_agent_priv, wr->send_buf.mad) && 1840 + wr->tid == mad_hdr->tid && 1936 1841 wr->timeout && 1937 1842 rcv_has_same_class(wr, wc) && 1938 1843 /* 1939 1844 * Don't check GID for direct routed MADs. 1940 1845 * These might have permissive LIDs. 1941 1846 */ 1942 - (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) || 1847 + (is_direct(mad_hdr->mgmt_class) || 1943 1848 rcv_has_same_gid(mad_agent_priv, wr, wc))) 1944 1849 /* Verify request has not been canceled */ 1945 1850 return (wr->status == IB_WC_SUCCESS) ? wr : NULL; ··· 1974 1879 } 1975 1880 1976 1881 /* Complete corresponding request */ 1977 - if (ib_response_mad(mad_recv_wc->recv_buf.mad)) { 1882 + if (ib_response_mad(&mad_recv_wc->recv_buf.mad->mad_hdr)) { 1978 1883 spin_lock_irqsave(&mad_agent_priv->lock, flags); 1979 1884 mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc); 1980 1885 if (!mad_send_wr) { ··· 2019 1924 } 2020 1925 } 2021 1926 2022 - static bool generate_unmatched_resp(struct ib_mad_private *recv, 2023 - struct ib_mad_private *response) 1927 + static enum smi_action handle_ib_smi(const struct ib_mad_port_private *port_priv, 1928 + const struct ib_mad_qp_info *qp_info, 1929 + const struct ib_wc *wc, 1930 + int port_num, 1931 + struct ib_mad_private *recv, 1932 + struct ib_mad_private *response) 2024 1933 { 2025 - if (recv->mad.mad.mad_hdr.method == IB_MGMT_METHOD_GET || 2026 - recv->mad.mad.mad_hdr.method == IB_MGMT_METHOD_SET) { 2027 - memcpy(response, recv, sizeof *response); 1934 + enum smi_forward_action retsmi; 1935 + struct ib_smp *smp = (struct ib_smp *)recv->mad; 1936 + 1937 + if (smi_handle_dr_smp_recv(smp, 1938 + port_priv->device->node_type, 1939 + port_num, 1940 + port_priv->device->phys_port_cnt) == 1941 + IB_SMI_DISCARD) 1942 + return IB_SMI_DISCARD; 1943 + 1944 + retsmi = smi_check_forward_dr_smp(smp); 1945 + if (retsmi == IB_SMI_LOCAL) 1946 + return IB_SMI_HANDLE; 1947 + 1948 + if (retsmi == IB_SMI_SEND) { /* don't forward */ 1949 + if (smi_handle_dr_smp_send(smp, 1950 + port_priv->device->node_type, 1951 + port_num) == IB_SMI_DISCARD) 1952 + return IB_SMI_DISCARD; 1953 + 1954 + if (smi_check_local_smp(smp, port_priv->device) == IB_SMI_DISCARD) 1955 + return IB_SMI_DISCARD; 1956 + } else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) { 1957 + /* forward case for switches */ 1958 + memcpy(response, recv, mad_priv_size(response)); 2028 1959 response->header.recv_wc.wc = &response->header.wc; 2029 - response->header.recv_wc.recv_buf.mad = &response->mad.mad; 1960 + response->header.recv_wc.recv_buf.mad = (struct ib_mad *)response->mad; 2030 1961 response->header.recv_wc.recv_buf.grh = &response->grh; 2031 - response->mad.mad.mad_hdr.method = IB_MGMT_METHOD_GET_RESP; 2032 - response->mad.mad.mad_hdr.status = 2033 - cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB); 2034 - if (recv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 2035 - response->mad.mad.mad_hdr.status |= IB_SMP_DIRECTION; 1962 + 1963 + agent_send_response((const struct ib_mad_hdr *)response->mad, 1964 + &response->grh, wc, 1965 + port_priv->device, 1966 + smi_get_fwd_port(smp), 1967 + qp_info->qp->qp_num, 1968 + response->mad_size, 1969 + false); 1970 + 1971 + return IB_SMI_DISCARD; 1972 + } 1973 + return IB_SMI_HANDLE; 1974 + } 1975 + 1976 + static bool generate_unmatched_resp(const struct ib_mad_private *recv, 1977 + struct ib_mad_private *response, 1978 + size_t *resp_len, bool opa) 1979 + { 1980 + const struct ib_mad_hdr *recv_hdr = (const struct ib_mad_hdr *)recv->mad; 1981 + struct ib_mad_hdr *resp_hdr = (struct ib_mad_hdr *)response->mad; 1982 + 1983 + if (recv_hdr->method == IB_MGMT_METHOD_GET || 1984 + recv_hdr->method == IB_MGMT_METHOD_SET) { 1985 + memcpy(response, recv, mad_priv_size(response)); 1986 + response->header.recv_wc.wc = &response->header.wc; 1987 + response->header.recv_wc.recv_buf.mad = (struct ib_mad *)response->mad; 1988 + response->header.recv_wc.recv_buf.grh = &response->grh; 1989 + resp_hdr->method = IB_MGMT_METHOD_GET_RESP; 1990 + resp_hdr->status = cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB); 1991 + if (recv_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 1992 + resp_hdr->status |= IB_SMP_DIRECTION; 1993 + 1994 + if (opa && recv_hdr->base_version == OPA_MGMT_BASE_VERSION) { 1995 + if (recv_hdr->mgmt_class == 1996 + IB_MGMT_CLASS_SUBN_LID_ROUTED || 1997 + recv_hdr->mgmt_class == 1998 + IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 1999 + *resp_len = opa_get_smp_header_size( 2000 + (struct opa_smp *)recv->mad); 2001 + else 2002 + *resp_len = sizeof(struct ib_mad_hdr); 2003 + } 2036 2004 2037 2005 return true; 2038 2006 } else { 2039 2007 return false; 2040 2008 } 2041 2009 } 2010 + 2011 + static enum smi_action 2012 + handle_opa_smi(struct ib_mad_port_private *port_priv, 2013 + struct ib_mad_qp_info *qp_info, 2014 + struct ib_wc *wc, 2015 + int port_num, 2016 + struct ib_mad_private *recv, 2017 + struct ib_mad_private *response) 2018 + { 2019 + enum smi_forward_action retsmi; 2020 + struct opa_smp *smp = (struct opa_smp *)recv->mad; 2021 + 2022 + if (opa_smi_handle_dr_smp_recv(smp, 2023 + port_priv->device->node_type, 2024 + port_num, 2025 + port_priv->device->phys_port_cnt) == 2026 + IB_SMI_DISCARD) 2027 + return IB_SMI_DISCARD; 2028 + 2029 + retsmi = opa_smi_check_forward_dr_smp(smp); 2030 + if (retsmi == IB_SMI_LOCAL) 2031 + return IB_SMI_HANDLE; 2032 + 2033 + if (retsmi == IB_SMI_SEND) { /* don't forward */ 2034 + if (opa_smi_handle_dr_smp_send(smp, 2035 + port_priv->device->node_type, 2036 + port_num) == IB_SMI_DISCARD) 2037 + return IB_SMI_DISCARD; 2038 + 2039 + if (opa_smi_check_local_smp(smp, port_priv->device) == 2040 + IB_SMI_DISCARD) 2041 + return IB_SMI_DISCARD; 2042 + 2043 + } else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) { 2044 + /* forward case for switches */ 2045 + memcpy(response, recv, mad_priv_size(response)); 2046 + response->header.recv_wc.wc = &response->header.wc; 2047 + response->header.recv_wc.recv_buf.opa_mad = 2048 + (struct opa_mad *)response->mad; 2049 + response->header.recv_wc.recv_buf.grh = &response->grh; 2050 + 2051 + agent_send_response((const struct ib_mad_hdr *)response->mad, 2052 + &response->grh, wc, 2053 + port_priv->device, 2054 + opa_smi_get_fwd_port(smp), 2055 + qp_info->qp->qp_num, 2056 + recv->header.wc.byte_len, 2057 + true); 2058 + 2059 + return IB_SMI_DISCARD; 2060 + } 2061 + 2062 + return IB_SMI_HANDLE; 2063 + } 2064 + 2065 + static enum smi_action 2066 + handle_smi(struct ib_mad_port_private *port_priv, 2067 + struct ib_mad_qp_info *qp_info, 2068 + struct ib_wc *wc, 2069 + int port_num, 2070 + struct ib_mad_private *recv, 2071 + struct ib_mad_private *response, 2072 + bool opa) 2073 + { 2074 + struct ib_mad_hdr *mad_hdr = (struct ib_mad_hdr *)recv->mad; 2075 + 2076 + if (opa && mad_hdr->base_version == OPA_MGMT_BASE_VERSION && 2077 + mad_hdr->class_version == OPA_SMI_CLASS_VERSION) 2078 + return handle_opa_smi(port_priv, qp_info, wc, port_num, recv, 2079 + response); 2080 + 2081 + return handle_ib_smi(port_priv, qp_info, wc, port_num, recv, response); 2082 + } 2083 + 2042 2084 static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, 2043 2085 struct ib_wc *wc) 2044 2086 { ··· 2186 1954 struct ib_mad_agent_private *mad_agent; 2187 1955 int port_num; 2188 1956 int ret = IB_MAD_RESULT_SUCCESS; 1957 + size_t mad_size; 1958 + u16 resp_mad_pkey_index = 0; 1959 + bool opa; 2189 1960 2190 1961 mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id; 2191 1962 qp_info = mad_list->mad_queue->qp_info; 2192 1963 dequeue_mad(mad_list); 1964 + 1965 + opa = rdma_cap_opa_mad(qp_info->port_priv->device, 1966 + qp_info->port_priv->port_num); 2193 1967 2194 1968 mad_priv_hdr = container_of(mad_list, struct ib_mad_private_header, 2195 1969 mad_list); 2196 1970 recv = container_of(mad_priv_hdr, struct ib_mad_private, header); 2197 1971 ib_dma_unmap_single(port_priv->device, 2198 1972 recv->header.mapping, 2199 - sizeof(struct ib_mad_private) - 2200 - sizeof(struct ib_mad_private_header), 1973 + mad_priv_dma_size(recv), 2201 1974 DMA_FROM_DEVICE); 2202 1975 2203 1976 /* Setup MAD receive work completion from "normal" work completion */ 2204 1977 recv->header.wc = *wc; 2205 1978 recv->header.recv_wc.wc = &recv->header.wc; 2206 - recv->header.recv_wc.mad_len = sizeof(struct ib_mad); 2207 - recv->header.recv_wc.recv_buf.mad = &recv->mad.mad; 1979 + 1980 + if (opa && ((struct ib_mad_hdr *)(recv->mad))->base_version == OPA_MGMT_BASE_VERSION) { 1981 + recv->header.recv_wc.mad_len = wc->byte_len - sizeof(struct ib_grh); 1982 + recv->header.recv_wc.mad_seg_size = sizeof(struct opa_mad); 1983 + } else { 1984 + recv->header.recv_wc.mad_len = sizeof(struct ib_mad); 1985 + recv->header.recv_wc.mad_seg_size = sizeof(struct ib_mad); 1986 + } 1987 + 1988 + recv->header.recv_wc.recv_buf.mad = (struct ib_mad *)recv->mad; 2208 1989 recv->header.recv_wc.recv_buf.grh = &recv->grh; 2209 1990 2210 1991 if (atomic_read(&qp_info->snoop_count)) 2211 1992 snoop_recv(qp_info, &recv->header.recv_wc, IB_MAD_SNOOP_RECVS); 2212 1993 2213 1994 /* Validate MAD */ 2214 - if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num)) 1995 + if (!validate_mad((const struct ib_mad_hdr *)recv->mad, qp_info, opa)) 2215 1996 goto out; 2216 1997 2217 - response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL); 1998 + mad_size = recv->mad_size; 1999 + response = alloc_mad_private(mad_size, GFP_KERNEL); 2218 2000 if (!response) { 2219 2001 dev_err(&port_priv->device->dev, 2220 2002 "ib_mad_recv_done_handler no memory for response buffer\n"); ··· 2240 1994 else 2241 1995 port_num = port_priv->port_num; 2242 1996 2243 - if (recv->mad.mad.mad_hdr.mgmt_class == 1997 + if (((struct ib_mad_hdr *)recv->mad)->mgmt_class == 2244 1998 IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) { 2245 - enum smi_forward_action retsmi; 2246 - 2247 - if (smi_handle_dr_smp_recv(&recv->mad.smp, 2248 - port_priv->device->node_type, 2249 - port_num, 2250 - port_priv->device->phys_port_cnt) == 2251 - IB_SMI_DISCARD) 1999 + if (handle_smi(port_priv, qp_info, wc, port_num, recv, 2000 + response, opa) 2001 + == IB_SMI_DISCARD) 2252 2002 goto out; 2253 - 2254 - retsmi = smi_check_forward_dr_smp(&recv->mad.smp); 2255 - if (retsmi == IB_SMI_LOCAL) 2256 - goto local; 2257 - 2258 - if (retsmi == IB_SMI_SEND) { /* don't forward */ 2259 - if (smi_handle_dr_smp_send(&recv->mad.smp, 2260 - port_priv->device->node_type, 2261 - port_num) == IB_SMI_DISCARD) 2262 - goto out; 2263 - 2264 - if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD) 2265 - goto out; 2266 - } else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) { 2267 - /* forward case for switches */ 2268 - memcpy(response, recv, sizeof(*response)); 2269 - response->header.recv_wc.wc = &response->header.wc; 2270 - response->header.recv_wc.recv_buf.mad = &response->mad.mad; 2271 - response->header.recv_wc.recv_buf.grh = &response->grh; 2272 - 2273 - agent_send_response(&response->mad.mad, 2274 - &response->grh, wc, 2275 - port_priv->device, 2276 - smi_get_fwd_port(&recv->mad.smp), 2277 - qp_info->qp->qp_num); 2278 - 2279 - goto out; 2280 - } 2281 2003 } 2282 2004 2283 - local: 2284 2005 /* Give driver "right of first refusal" on incoming MAD */ 2285 2006 if (port_priv->device->process_mad) { 2286 2007 ret = port_priv->device->process_mad(port_priv->device, 0, 2287 2008 port_priv->port_num, 2288 2009 wc, &recv->grh, 2289 - &recv->mad.mad, 2290 - &response->mad.mad); 2010 + (const struct ib_mad_hdr *)recv->mad, 2011 + recv->mad_size, 2012 + (struct ib_mad_hdr *)response->mad, 2013 + &mad_size, &resp_mad_pkey_index); 2014 + 2015 + if (opa) 2016 + wc->pkey_index = resp_mad_pkey_index; 2017 + 2291 2018 if (ret & IB_MAD_RESULT_SUCCESS) { 2292 2019 if (ret & IB_MAD_RESULT_CONSUMED) 2293 2020 goto out; 2294 2021 if (ret & IB_MAD_RESULT_REPLY) { 2295 - agent_send_response(&response->mad.mad, 2022 + agent_send_response((const struct ib_mad_hdr *)response->mad, 2296 2023 &recv->grh, wc, 2297 2024 port_priv->device, 2298 2025 port_num, 2299 - qp_info->qp->qp_num); 2026 + qp_info->qp->qp_num, 2027 + mad_size, opa); 2300 2028 goto out; 2301 2029 } 2302 2030 } 2303 2031 } 2304 2032 2305 - mad_agent = find_mad_agent(port_priv, &recv->mad.mad); 2033 + mad_agent = find_mad_agent(port_priv, (const struct ib_mad_hdr *)recv->mad); 2306 2034 if (mad_agent) { 2307 2035 ib_mad_complete_recv(mad_agent, &recv->header.recv_wc); 2308 2036 /* ··· 2285 2065 */ 2286 2066 recv = NULL; 2287 2067 } else if ((ret & IB_MAD_RESULT_SUCCESS) && 2288 - generate_unmatched_resp(recv, response)) { 2289 - agent_send_response(&response->mad.mad, &recv->grh, wc, 2290 - port_priv->device, port_num, qp_info->qp->qp_num); 2068 + generate_unmatched_resp(recv, response, &mad_size, opa)) { 2069 + agent_send_response((const struct ib_mad_hdr *)response->mad, &recv->grh, wc, 2070 + port_priv->device, port_num, 2071 + qp_info->qp->qp_num, mad_size, opa); 2291 2072 } 2292 2073 2293 2074 out: 2294 2075 /* Post another receive request for this QP */ 2295 2076 if (response) { 2296 2077 ib_mad_post_receive_mads(qp_info, response); 2297 - if (recv) 2298 - kmem_cache_free(ib_mad_cache, recv); 2078 + kfree(recv); 2299 2079 } else 2300 2080 ib_mad_post_receive_mads(qp_info, recv); 2301 2081 } ··· 2631 2411 2632 2412 list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list, 2633 2413 agent_list) { 2634 - if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) && 2414 + if (is_rmpp_data_mad(mad_agent_priv, 2415 + mad_send_wr->send_buf.mad) && 2635 2416 &mad_send_wr->send_buf == send_buf) 2636 2417 return mad_send_wr; 2637 2418 } ··· 2689 2468 int free_mad; 2690 2469 struct ib_wc wc; 2691 2470 struct ib_mad_send_wc mad_send_wc; 2471 + bool opa; 2692 2472 2693 2473 mad_agent_priv = 2694 2474 container_of(work, struct ib_mad_agent_private, local_work); 2475 + 2476 + opa = rdma_cap_opa_mad(mad_agent_priv->qp_info->port_priv->device, 2477 + mad_agent_priv->qp_info->port_priv->port_num); 2695 2478 2696 2479 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2697 2480 while (!list_empty(&mad_agent_priv->local_list)) { ··· 2706 2481 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 2707 2482 free_mad = 0; 2708 2483 if (local->mad_priv) { 2484 + u8 base_version; 2709 2485 recv_mad_agent = local->recv_mad_agent; 2710 2486 if (!recv_mad_agent) { 2711 2487 dev_err(&mad_agent_priv->agent.device->dev, ··· 2722 2496 build_smp_wc(recv_mad_agent->agent.qp, 2723 2497 (unsigned long) local->mad_send_wr, 2724 2498 be16_to_cpu(IB_LID_PERMISSIVE), 2725 - 0, recv_mad_agent->agent.port_num, &wc); 2499 + local->mad_send_wr->send_wr.wr.ud.pkey_index, 2500 + recv_mad_agent->agent.port_num, &wc); 2726 2501 2727 2502 local->mad_priv->header.recv_wc.wc = &wc; 2728 - local->mad_priv->header.recv_wc.mad_len = 2729 - sizeof(struct ib_mad); 2503 + 2504 + base_version = ((struct ib_mad_hdr *)(local->mad_priv->mad))->base_version; 2505 + if (opa && base_version == OPA_MGMT_BASE_VERSION) { 2506 + local->mad_priv->header.recv_wc.mad_len = local->return_wc_byte_len; 2507 + local->mad_priv->header.recv_wc.mad_seg_size = sizeof(struct opa_mad); 2508 + } else { 2509 + local->mad_priv->header.recv_wc.mad_len = sizeof(struct ib_mad); 2510 + local->mad_priv->header.recv_wc.mad_seg_size = sizeof(struct ib_mad); 2511 + } 2512 + 2730 2513 INIT_LIST_HEAD(&local->mad_priv->header.recv_wc.rmpp_list); 2731 2514 list_add(&local->mad_priv->header.recv_wc.recv_buf.list, 2732 2515 &local->mad_priv->header.recv_wc.rmpp_list); 2733 2516 local->mad_priv->header.recv_wc.recv_buf.grh = NULL; 2734 2517 local->mad_priv->header.recv_wc.recv_buf.mad = 2735 - &local->mad_priv->mad.mad; 2518 + (struct ib_mad *)local->mad_priv->mad; 2736 2519 if (atomic_read(&recv_mad_agent->qp_info->snoop_count)) 2737 2520 snoop_recv(recv_mad_agent->qp_info, 2738 2521 &local->mad_priv->header.recv_wc, ··· 2769 2534 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2770 2535 atomic_dec(&mad_agent_priv->refcount); 2771 2536 if (free_mad) 2772 - kmem_cache_free(ib_mad_cache, local->mad_priv); 2537 + kfree(local->mad_priv); 2773 2538 kfree(local); 2774 2539 } 2775 2540 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); ··· 2884 2649 struct ib_mad_queue *recv_queue = &qp_info->recv_queue; 2885 2650 2886 2651 /* Initialize common scatter list fields */ 2887 - sg_list.length = sizeof *mad_priv - sizeof mad_priv->header; 2888 2652 sg_list.lkey = (*qp_info->port_priv->mr).lkey; 2889 2653 2890 2654 /* Initialize common receive WR fields */ ··· 2897 2663 mad_priv = mad; 2898 2664 mad = NULL; 2899 2665 } else { 2900 - mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL); 2666 + mad_priv = alloc_mad_private(port_mad_size(qp_info->port_priv), 2667 + GFP_ATOMIC); 2901 2668 if (!mad_priv) { 2902 2669 dev_err(&qp_info->port_priv->device->dev, 2903 2670 "No memory for receive buffer\n"); ··· 2906 2671 break; 2907 2672 } 2908 2673 } 2674 + sg_list.length = mad_priv_dma_size(mad_priv); 2909 2675 sg_list.addr = ib_dma_map_single(qp_info->port_priv->device, 2910 2676 &mad_priv->grh, 2911 - sizeof *mad_priv - 2912 - sizeof mad_priv->header, 2677 + mad_priv_dma_size(mad_priv), 2913 2678 DMA_FROM_DEVICE); 2914 2679 if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device, 2915 2680 sg_list.addr))) { ··· 2933 2698 spin_unlock_irqrestore(&recv_queue->lock, flags); 2934 2699 ib_dma_unmap_single(qp_info->port_priv->device, 2935 2700 mad_priv->header.mapping, 2936 - sizeof *mad_priv - 2937 - sizeof mad_priv->header, 2701 + mad_priv_dma_size(mad_priv), 2938 2702 DMA_FROM_DEVICE); 2939 - kmem_cache_free(ib_mad_cache, mad_priv); 2703 + kfree(mad_priv); 2940 2704 dev_err(&qp_info->port_priv->device->dev, 2941 2705 "ib_post_recv failed: %d\n", ret); 2942 2706 break; ··· 2972 2738 2973 2739 ib_dma_unmap_single(qp_info->port_priv->device, 2974 2740 recv->header.mapping, 2975 - sizeof(struct ib_mad_private) - 2976 - sizeof(struct ib_mad_private_header), 2741 + mad_priv_dma_size(recv), 2977 2742 DMA_FROM_DEVICE); 2978 - kmem_cache_free(ib_mad_cache, recv); 2743 + kfree(recv); 2979 2744 } 2980 2745 2981 2746 qp_info->recv_queue.count = 0; ··· 3155 2922 unsigned long flags; 3156 2923 char name[sizeof "ib_mad123"]; 3157 2924 int has_smi; 2925 + struct ib_cq_init_attr cq_attr = {}; 2926 + 2927 + if (WARN_ON(rdma_max_mad_size(device, port_num) < IB_MGMT_MAD_SIZE)) 2928 + return -EFAULT; 2929 + 2930 + if (WARN_ON(rdma_cap_opa_mad(device, port_num) && 2931 + rdma_max_mad_size(device, port_num) < OPA_MGMT_MAD_SIZE)) 2932 + return -EFAULT; 3158 2933 3159 2934 /* Create new device info */ 3160 2935 port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL); ··· 3179 2938 init_mad_qp(port_priv, &port_priv->qp_info[1]); 3180 2939 3181 2940 cq_size = mad_sendq_size + mad_recvq_size; 3182 - has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND; 2941 + has_smi = rdma_cap_ib_smi(device, port_num); 3183 2942 if (has_smi) 3184 2943 cq_size *= 2; 3185 2944 2945 + cq_attr.cqe = cq_size; 3186 2946 port_priv->cq = ib_create_cq(port_priv->device, 3187 2947 ib_mad_thread_completion_handler, 3188 - NULL, port_priv, cq_size, 0); 2948 + NULL, port_priv, &cq_attr); 3189 2949 if (IS_ERR(port_priv->cq)) { 3190 2950 dev_err(&device->dev, "Couldn't create ib_mad CQ\n"); 3191 2951 ret = PTR_ERR(port_priv->cq); ··· 3299 3057 { 3300 3058 int start, end, i; 3301 3059 3302 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 3303 - return; 3304 - 3305 3060 if (device->node_type == RDMA_NODE_IB_SWITCH) { 3306 3061 start = 0; 3307 3062 end = 0; ··· 3308 3069 } 3309 3070 3310 3071 for (i = start; i <= end; i++) { 3072 + if (!rdma_cap_ib_mad(device, i)) 3073 + continue; 3074 + 3311 3075 if (ib_mad_port_open(device, i)) { 3312 3076 dev_err(&device->dev, "Couldn't open port %d\n", i); 3313 3077 goto error; ··· 3328 3086 dev_err(&device->dev, "Couldn't close port %d\n", i); 3329 3087 3330 3088 error: 3331 - i--; 3089 + while (--i >= start) { 3090 + if (!rdma_cap_ib_mad(device, i)) 3091 + continue; 3332 3092 3333 - while (i >= start) { 3334 3093 if (ib_agent_port_close(device, i)) 3335 3094 dev_err(&device->dev, 3336 3095 "Couldn't close port %d for agents\n", i); 3337 3096 if (ib_mad_port_close(device, i)) 3338 3097 dev_err(&device->dev, "Couldn't close port %d\n", i); 3339 - i--; 3340 3098 } 3341 3099 } 3342 3100 3343 3101 static void ib_mad_remove_device(struct ib_device *device) 3344 3102 { 3345 - int i, num_ports, cur_port; 3346 - 3347 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 3348 - return; 3103 + int start, end, i; 3349 3104 3350 3105 if (device->node_type == RDMA_NODE_IB_SWITCH) { 3351 - num_ports = 1; 3352 - cur_port = 0; 3106 + start = 0; 3107 + end = 0; 3353 3108 } else { 3354 - num_ports = device->phys_port_cnt; 3355 - cur_port = 1; 3109 + start = 1; 3110 + end = device->phys_port_cnt; 3356 3111 } 3357 - for (i = 0; i < num_ports; i++, cur_port++) { 3358 - if (ib_agent_port_close(device, cur_port)) 3112 + 3113 + for (i = start; i <= end; i++) { 3114 + if (!rdma_cap_ib_mad(device, i)) 3115 + continue; 3116 + 3117 + if (ib_agent_port_close(device, i)) 3359 3118 dev_err(&device->dev, 3360 - "Couldn't close port %d for agents\n", 3361 - cur_port); 3362 - if (ib_mad_port_close(device, cur_port)) 3363 - dev_err(&device->dev, "Couldn't close port %d\n", 3364 - cur_port); 3119 + "Couldn't close port %d for agents\n", i); 3120 + if (ib_mad_port_close(device, i)) 3121 + dev_err(&device->dev, "Couldn't close port %d\n", i); 3365 3122 } 3366 3123 } 3367 3124 ··· 3372 3131 3373 3132 static int __init ib_mad_init_module(void) 3374 3133 { 3375 - int ret; 3376 - 3377 3134 mad_recvq_size = min(mad_recvq_size, IB_MAD_QP_MAX_SIZE); 3378 3135 mad_recvq_size = max(mad_recvq_size, IB_MAD_QP_MIN_SIZE); 3379 3136 3380 3137 mad_sendq_size = min(mad_sendq_size, IB_MAD_QP_MAX_SIZE); 3381 3138 mad_sendq_size = max(mad_sendq_size, IB_MAD_QP_MIN_SIZE); 3382 3139 3383 - ib_mad_cache = kmem_cache_create("ib_mad", 3384 - sizeof(struct ib_mad_private), 3385 - 0, 3386 - SLAB_HWCACHE_ALIGN, 3387 - NULL); 3388 - if (!ib_mad_cache) { 3389 - pr_err("Couldn't create ib_mad cache\n"); 3390 - ret = -ENOMEM; 3391 - goto error1; 3392 - } 3393 - 3394 3140 INIT_LIST_HEAD(&ib_mad_port_list); 3395 3141 3396 3142 if (ib_register_client(&mad_client)) { 3397 3143 pr_err("Couldn't register ib_mad client\n"); 3398 - ret = -EINVAL; 3399 - goto error2; 3144 + return -EINVAL; 3400 3145 } 3401 3146 3402 3147 return 0; 3403 - 3404 - error2: 3405 - kmem_cache_destroy(ib_mad_cache); 3406 - error1: 3407 - return ret; 3408 3148 } 3409 3149 3410 3150 static void __exit ib_mad_cleanup_module(void) 3411 3151 { 3412 3152 ib_unregister_client(&mad_client); 3413 - kmem_cache_destroy(ib_mad_cache); 3414 3153 } 3415 3154 3416 3155 module_init(ib_mad_init_module);
+7 -8
drivers/infiniband/core/mad_priv.h
··· 41 41 #include <linux/workqueue.h> 42 42 #include <rdma/ib_mad.h> 43 43 #include <rdma/ib_smi.h> 44 + #include <rdma/opa_smi.h> 44 45 45 46 #define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */ 46 47 ··· 57 56 58 57 /* Registration table sizes */ 59 58 #define MAX_MGMT_CLASS 80 60 - #define MAX_MGMT_VERSION 8 59 + #define MAX_MGMT_VERSION 0x83 61 60 #define MAX_MGMT_OUI 8 62 61 #define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \ 63 62 IB_MGMT_CLASS_VENDOR_RANGE2_START + 1) ··· 76 75 77 76 struct ib_mad_private { 78 77 struct ib_mad_private_header header; 78 + size_t mad_size; 79 79 struct ib_grh grh; 80 - union { 81 - struct ib_mad mad; 82 - struct ib_rmpp_mad rmpp_mad; 83 - struct ib_smp smp; 84 - } mad; 80 + u8 mad[0]; 85 81 } __attribute__ ((packed)); 86 82 87 83 struct ib_rmpp_segment { ··· 148 150 struct ib_mad_private *mad_priv; 149 151 struct ib_mad_agent_private *recv_mad_agent; 150 152 struct ib_mad_send_wr_private *mad_send_wr; 153 + size_t return_wc_byte_len; 151 154 }; 152 155 153 156 struct ib_mad_mgmt_method_table { ··· 212 213 int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr); 213 214 214 215 struct ib_mad_send_wr_private * 215 - ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, 216 - struct ib_mad_recv_wc *mad_recv_wc); 216 + ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv, 217 + const struct ib_mad_recv_wc *mad_recv_wc); 217 218 218 219 void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr, 219 220 struct ib_mad_send_wc *mad_send_wc);
+24 -9
drivers/infiniband/core/mad_rmpp.c
··· 1 1 /* 2 2 * Copyright (c) 2005 Intel Inc. All rights reserved. 3 3 * Copyright (c) 2005-2006 Voltaire, Inc. All rights reserved. 4 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 4 5 * 5 6 * This software is available to you under a choice of one of two 6 7 * licenses. You may choose to be licensed under the terms of the GNU ··· 68 67 u8 mgmt_class; 69 68 u8 class_version; 70 69 u8 method; 70 + u8 base_version; 71 71 }; 72 72 73 73 static inline void deref_rmpp_recv(struct mad_rmpp_recv *rmpp_recv) ··· 141 139 hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class); 142 140 msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp, 143 141 recv_wc->wc->pkey_index, 1, hdr_len, 144 - 0, GFP_KERNEL); 142 + 0, GFP_KERNEL, 143 + IB_MGMT_BASE_VERSION); 145 144 if (IS_ERR(msg)) 146 145 return; 147 146 ··· 168 165 hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class); 169 166 msg = ib_create_send_mad(agent, recv_wc->wc->src_qp, 170 167 recv_wc->wc->pkey_index, 1, 171 - hdr_len, 0, GFP_KERNEL); 168 + hdr_len, 0, GFP_KERNEL, 169 + IB_MGMT_BASE_VERSION); 172 170 if (IS_ERR(msg)) 173 171 ib_destroy_ah(ah); 174 172 else { ··· 320 316 rmpp_recv->mgmt_class = mad_hdr->mgmt_class; 321 317 rmpp_recv->class_version = mad_hdr->class_version; 322 318 rmpp_recv->method = mad_hdr->method; 319 + rmpp_recv->base_version = mad_hdr->base_version; 323 320 return rmpp_recv; 324 321 325 322 error: kfree(rmpp_recv); ··· 436 431 { 437 432 struct ib_rmpp_mad *rmpp_mad; 438 433 int hdr_size, data_size, pad; 434 + bool opa = rdma_cap_opa_mad(rmpp_recv->agent->qp_info->port_priv->device, 435 + rmpp_recv->agent->qp_info->port_priv->port_num); 439 436 440 437 rmpp_mad = (struct ib_rmpp_mad *)rmpp_recv->cur_seg_buf->mad; 441 438 442 439 hdr_size = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class); 443 - data_size = sizeof(struct ib_rmpp_mad) - hdr_size; 444 - pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin); 445 - if (pad > IB_MGMT_RMPP_DATA || pad < 0) 446 - pad = 0; 440 + if (opa && rmpp_recv->base_version == OPA_MGMT_BASE_VERSION) { 441 + data_size = sizeof(struct opa_rmpp_mad) - hdr_size; 442 + pad = OPA_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin); 443 + if (pad > OPA_MGMT_RMPP_DATA || pad < 0) 444 + pad = 0; 445 + } else { 446 + data_size = sizeof(struct ib_rmpp_mad) - hdr_size; 447 + pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin); 448 + if (pad > IB_MGMT_RMPP_DATA || pad < 0) 449 + pad = 0; 450 + } 447 451 448 452 return hdr_size + rmpp_recv->seg_num * data_size - pad; 449 453 } ··· 584 570 585 571 if (mad_send_wr->seg_num == 1) { 586 572 rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST; 587 - paylen = mad_send_wr->send_buf.seg_count * IB_MGMT_RMPP_DATA - 588 - mad_send_wr->pad; 573 + paylen = (mad_send_wr->send_buf.seg_count * 574 + mad_send_wr->send_buf.seg_rmpp_size) - 575 + mad_send_wr->pad; 589 576 } 590 577 591 578 if (mad_send_wr->seg_num == mad_send_wr->send_buf.seg_count) { 592 579 rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST; 593 - paylen = IB_MGMT_RMPP_DATA - mad_send_wr->pad; 580 + paylen = mad_send_wr->send_buf.seg_rmpp_size - mad_send_wr->pad; 594 581 } 595 582 rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen); 596 583
+3 -9
drivers/infiniband/core/multicast.c
··· 780 780 int index; 781 781 782 782 dev = container_of(handler, struct mcast_device, event_handler); 783 - if (rdma_port_get_link_layer(dev->device, event->element.port_num) != 784 - IB_LINK_LAYER_INFINIBAND) 783 + if (!rdma_cap_ib_mcast(dev->device, event->element.port_num)) 785 784 return; 786 785 787 786 index = event->element.port_num - dev->start_port; ··· 807 808 int i; 808 809 int count = 0; 809 810 810 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 811 - return; 812 - 813 811 dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port, 814 812 GFP_KERNEL); 815 813 if (!dev) ··· 820 824 } 821 825 822 826 for (i = 0; i <= dev->end_port - dev->start_port; i++) { 823 - if (rdma_port_get_link_layer(device, dev->start_port + i) != 824 - IB_LINK_LAYER_INFINIBAND) 827 + if (!rdma_cap_ib_mcast(device, dev->start_port + i)) 825 828 continue; 826 829 port = &dev->port[i]; 827 830 port->dev = dev; ··· 858 863 flush_workqueue(mcast_wq); 859 864 860 865 for (i = 0; i <= dev->end_port - dev->start_port; i++) { 861 - if (rdma_port_get_link_layer(device, dev->start_port + i) == 862 - IB_LINK_LAYER_INFINIBAND) { 866 + if (rdma_cap_ib_mcast(device, dev->start_port + i)) { 863 867 port = &dev->port[i]; 864 868 deref_port(port); 865 869 wait_for_completion(&port->comp);
+78
drivers/infiniband/core/opa_smi.h
··· 1 + /* 2 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 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 + */ 33 + 34 + #ifndef __OPA_SMI_H_ 35 + #define __OPA_SMI_H_ 36 + 37 + #include <rdma/ib_smi.h> 38 + #include <rdma/opa_smi.h> 39 + 40 + #include "smi.h" 41 + 42 + enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, u8 node_type, 43 + int port_num, int phys_port_cnt); 44 + int opa_smi_get_fwd_port(struct opa_smp *smp); 45 + extern enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp); 46 + extern enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp, 47 + u8 node_type, int port_num); 48 + 49 + /* 50 + * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM 51 + * via process_mad 52 + */ 53 + static inline enum smi_action opa_smi_check_local_smp(struct opa_smp *smp, 54 + struct ib_device *device) 55 + { 56 + /* C14-9:3 -- We're at the end of the DR segment of path */ 57 + /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */ 58 + return (device->process_mad && 59 + !opa_get_smp_direction(smp) && 60 + (smp->hop_ptr == smp->hop_cnt + 1)) ? 61 + IB_SMI_HANDLE : IB_SMI_DISCARD; 62 + } 63 + 64 + /* 65 + * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM 66 + * via process_mad 67 + */ 68 + static inline enum smi_action opa_smi_check_local_returning_smp(struct opa_smp *smp, 69 + struct ib_device *device) 70 + { 71 + /* C14-13:3 -- We're at the end of the DR segment of path */ 72 + /* C14-13:4 -- Hop Pointer == 0 -> give to SM */ 73 + return (device->process_mad && 74 + opa_get_smp_direction(smp) && 75 + !smp->hop_ptr) ? IB_SMI_HANDLE : IB_SMI_DISCARD; 76 + } 77 + 78 + #endif /* __OPA_SMI_H_ */
+19 -14
drivers/infiniband/core/sa_query.c
··· 450 450 struct ib_sa_port *port = 451 451 &sa_dev->port[event->element.port_num - sa_dev->start_port]; 452 452 453 - if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND) 453 + if (!rdma_cap_ib_sa(handler->device, port->port_num)) 454 454 return; 455 455 456 456 spin_lock_irqsave(&port->ah_lock, flags); ··· 540 540 ah_attr->port_num = port_num; 541 541 ah_attr->static_rate = rec->rate; 542 542 543 - force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET; 543 + force_grh = rdma_cap_eth_ah(device, port_num); 544 544 545 545 if (rec->hop_limit > 1 || force_grh) { 546 546 ah_attr->ah_flags = IB_AH_GRH; ··· 583 583 query->mad_buf = ib_create_send_mad(query->port->agent, 1, 584 584 query->sm_ah->pkey_index, 585 585 0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA, 586 - gfp_mask); 586 + gfp_mask, 587 + IB_MGMT_BASE_VERSION); 587 588 if (IS_ERR(query->mad_buf)) { 588 589 kref_put(&query->sm_ah->ref, free_sm_ah); 589 590 return -ENOMEM; ··· 1154 1153 { 1155 1154 struct ib_sa_device *sa_dev; 1156 1155 int s, e, i; 1157 - 1158 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 1159 - return; 1156 + int count = 0; 1160 1157 1161 1158 if (device->node_type == RDMA_NODE_IB_SWITCH) 1162 1159 s = e = 0; ··· 1174 1175 1175 1176 for (i = 0; i <= e - s; ++i) { 1176 1177 spin_lock_init(&sa_dev->port[i].ah_lock); 1177 - if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND) 1178 + if (!rdma_cap_ib_sa(device, i + 1)) 1178 1179 continue; 1179 1180 1180 1181 sa_dev->port[i].sm_ah = NULL; ··· 1188 1189 goto err; 1189 1190 1190 1191 INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah); 1192 + 1193 + count++; 1191 1194 } 1195 + 1196 + if (!count) 1197 + goto free; 1192 1198 1193 1199 ib_set_client_data(device, &sa_client, sa_dev); 1194 1200 ··· 1208 1204 if (ib_register_event_handler(&sa_dev->event_handler)) 1209 1205 goto err; 1210 1206 1211 - for (i = 0; i <= e - s; ++i) 1212 - if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) 1207 + for (i = 0; i <= e - s; ++i) { 1208 + if (rdma_cap_ib_sa(device, i + 1)) 1213 1209 update_sm_ah(&sa_dev->port[i].update_task); 1210 + } 1214 1211 1215 1212 return; 1216 1213 1217 1214 err: 1218 - while (--i >= 0) 1219 - if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) 1215 + while (--i >= 0) { 1216 + if (rdma_cap_ib_sa(device, i + 1)) 1220 1217 ib_unregister_mad_agent(sa_dev->port[i].agent); 1221 - 1218 + } 1219 + free: 1222 1220 kfree(sa_dev); 1223 - 1224 1221 return; 1225 1222 } 1226 1223 ··· 1238 1233 flush_workqueue(ib_wq); 1239 1234 1240 1235 for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) { 1241 - if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) { 1236 + if (rdma_cap_ib_sa(device, i + 1)) { 1242 1237 ib_unregister_mad_agent(sa_dev->port[i].agent); 1243 1238 if (sa_dev->port[i].sm_ah) 1244 1239 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
+156 -70
drivers/infiniband/core/smi.c
··· 5 5 * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved. 6 6 * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved. 7 7 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 8 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 8 9 * 9 10 * This software is available to you under a choice of one of two 10 11 * licenses. You may choose to be licensed under the terms of the GNU ··· 39 38 40 39 #include <rdma/ib_smi.h> 41 40 #include "smi.h" 41 + #include "opa_smi.h" 42 42 43 - /* 44 - * Fixup a directed route SMP for sending 45 - * Return 0 if the SMP should be discarded 46 - */ 47 - enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp, 48 - u8 node_type, int port_num) 43 + static enum smi_action __smi_handle_dr_smp_send(u8 node_type, int port_num, 44 + u8 *hop_ptr, u8 hop_cnt, 45 + const u8 *initial_path, 46 + const u8 *return_path, 47 + u8 direction, 48 + bool dr_dlid_is_permissive, 49 + bool dr_slid_is_permissive) 49 50 { 50 - u8 hop_ptr, hop_cnt; 51 - 52 - hop_ptr = smp->hop_ptr; 53 - hop_cnt = smp->hop_cnt; 54 - 55 51 /* See section 14.2.2.2, Vol 1 IB spec */ 56 52 /* C14-6 -- valid hop_cnt values are from 0 to 63 */ 57 53 if (hop_cnt >= IB_SMP_MAX_PATH_HOPS) 58 54 return IB_SMI_DISCARD; 59 55 60 - if (!ib_get_smp_direction(smp)) { 56 + if (!direction) { 61 57 /* C14-9:1 */ 62 - if (hop_cnt && hop_ptr == 0) { 63 - smp->hop_ptr++; 64 - return (smp->initial_path[smp->hop_ptr] == 58 + if (hop_cnt && *hop_ptr == 0) { 59 + (*hop_ptr)++; 60 + return (initial_path[*hop_ptr] == 65 61 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD); 66 62 } 67 63 68 64 /* C14-9:2 */ 69 - if (hop_ptr && hop_ptr < hop_cnt) { 65 + if (*hop_ptr && *hop_ptr < hop_cnt) { 70 66 if (node_type != RDMA_NODE_IB_SWITCH) 71 67 return IB_SMI_DISCARD; 72 68 73 - /* smp->return_path set when received */ 74 - smp->hop_ptr++; 75 - return (smp->initial_path[smp->hop_ptr] == 69 + /* return_path set when received */ 70 + (*hop_ptr)++; 71 + return (initial_path[*hop_ptr] == 76 72 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD); 77 73 } 78 74 79 75 /* C14-9:3 -- We're at the end of the DR segment of path */ 80 - if (hop_ptr == hop_cnt) { 81 - /* smp->return_path set when received */ 82 - smp->hop_ptr++; 76 + if (*hop_ptr == hop_cnt) { 77 + /* return_path set when received */ 78 + (*hop_ptr)++; 83 79 return (node_type == RDMA_NODE_IB_SWITCH || 84 - smp->dr_dlid == IB_LID_PERMISSIVE ? 80 + dr_dlid_is_permissive ? 85 81 IB_SMI_HANDLE : IB_SMI_DISCARD); 86 82 } 87 83 88 84 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */ 89 85 /* C14-9:5 -- Fail unreasonable hop pointer */ 90 - return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD); 86 + return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD); 91 87 92 88 } else { 93 89 /* C14-13:1 */ 94 - if (hop_cnt && hop_ptr == hop_cnt + 1) { 95 - smp->hop_ptr--; 96 - return (smp->return_path[smp->hop_ptr] == 90 + if (hop_cnt && *hop_ptr == hop_cnt + 1) { 91 + (*hop_ptr)--; 92 + return (return_path[*hop_ptr] == 97 93 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD); 98 94 } 99 95 100 96 /* C14-13:2 */ 101 - if (2 <= hop_ptr && hop_ptr <= hop_cnt) { 97 + if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) { 102 98 if (node_type != RDMA_NODE_IB_SWITCH) 103 99 return IB_SMI_DISCARD; 104 100 105 - smp->hop_ptr--; 106 - return (smp->return_path[smp->hop_ptr] == 101 + (*hop_ptr)--; 102 + return (return_path[*hop_ptr] == 107 103 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD); 108 104 } 109 105 110 106 /* C14-13:3 -- at the end of the DR segment of path */ 111 - if (hop_ptr == 1) { 112 - smp->hop_ptr--; 107 + if (*hop_ptr == 1) { 108 + (*hop_ptr)--; 113 109 /* C14-13:3 -- SMPs destined for SM shouldn't be here */ 114 110 return (node_type == RDMA_NODE_IB_SWITCH || 115 - smp->dr_slid == IB_LID_PERMISSIVE ? 111 + dr_slid_is_permissive ? 116 112 IB_SMI_HANDLE : IB_SMI_DISCARD); 117 113 } 118 114 119 115 /* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */ 120 - if (hop_ptr == 0) 116 + if (*hop_ptr == 0) 121 117 return IB_SMI_HANDLE; 122 118 123 119 /* C14-13:5 -- Check for unreasonable hop pointer */ ··· 123 125 } 124 126 125 127 /* 126 - * Adjust information for a received SMP 127 - * Return 0 if the SMP should be dropped 128 + * Fixup a directed route SMP for sending 129 + * Return IB_SMI_DISCARD if the SMP should be discarded 128 130 */ 129 - enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type, 130 - int port_num, int phys_port_cnt) 131 + enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp, 132 + u8 node_type, int port_num) 131 133 { 132 - u8 hop_ptr, hop_cnt; 134 + return __smi_handle_dr_smp_send(node_type, port_num, 135 + &smp->hop_ptr, smp->hop_cnt, 136 + smp->initial_path, 137 + smp->return_path, 138 + ib_get_smp_direction(smp), 139 + smp->dr_dlid == IB_LID_PERMISSIVE, 140 + smp->dr_slid == IB_LID_PERMISSIVE); 141 + } 133 142 134 - hop_ptr = smp->hop_ptr; 135 - hop_cnt = smp->hop_cnt; 143 + enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp, 144 + u8 node_type, int port_num) 145 + { 146 + return __smi_handle_dr_smp_send(node_type, port_num, 147 + &smp->hop_ptr, smp->hop_cnt, 148 + smp->route.dr.initial_path, 149 + smp->route.dr.return_path, 150 + opa_get_smp_direction(smp), 151 + smp->route.dr.dr_dlid == 152 + OPA_LID_PERMISSIVE, 153 + smp->route.dr.dr_slid == 154 + OPA_LID_PERMISSIVE); 155 + } 136 156 157 + static enum smi_action __smi_handle_dr_smp_recv(u8 node_type, int port_num, 158 + int phys_port_cnt, 159 + u8 *hop_ptr, u8 hop_cnt, 160 + const u8 *initial_path, 161 + u8 *return_path, 162 + u8 direction, 163 + bool dr_dlid_is_permissive, 164 + bool dr_slid_is_permissive) 165 + { 137 166 /* See section 14.2.2.2, Vol 1 IB spec */ 138 167 /* C14-6 -- valid hop_cnt values are from 0 to 63 */ 139 168 if (hop_cnt >= IB_SMP_MAX_PATH_HOPS) 140 169 return IB_SMI_DISCARD; 141 170 142 - if (!ib_get_smp_direction(smp)) { 171 + if (!direction) { 143 172 /* C14-9:1 -- sender should have incremented hop_ptr */ 144 - if (hop_cnt && hop_ptr == 0) 173 + if (hop_cnt && *hop_ptr == 0) 145 174 return IB_SMI_DISCARD; 146 175 147 176 /* C14-9:2 -- intermediate hop */ 148 - if (hop_ptr && hop_ptr < hop_cnt) { 177 + if (*hop_ptr && *hop_ptr < hop_cnt) { 149 178 if (node_type != RDMA_NODE_IB_SWITCH) 150 179 return IB_SMI_DISCARD; 151 180 152 - smp->return_path[hop_ptr] = port_num; 153 - /* smp->hop_ptr updated when sending */ 154 - return (smp->initial_path[hop_ptr+1] <= phys_port_cnt ? 181 + return_path[*hop_ptr] = port_num; 182 + /* hop_ptr updated when sending */ 183 + return (initial_path[*hop_ptr+1] <= phys_port_cnt ? 155 184 IB_SMI_HANDLE : IB_SMI_DISCARD); 156 185 } 157 186 158 187 /* C14-9:3 -- We're at the end of the DR segment of path */ 159 - if (hop_ptr == hop_cnt) { 188 + if (*hop_ptr == hop_cnt) { 160 189 if (hop_cnt) 161 - smp->return_path[hop_ptr] = port_num; 162 - /* smp->hop_ptr updated when sending */ 190 + return_path[*hop_ptr] = port_num; 191 + /* hop_ptr updated when sending */ 163 192 164 193 return (node_type == RDMA_NODE_IB_SWITCH || 165 - smp->dr_dlid == IB_LID_PERMISSIVE ? 194 + dr_dlid_is_permissive ? 166 195 IB_SMI_HANDLE : IB_SMI_DISCARD); 167 196 } 168 197 169 198 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */ 170 199 /* C14-9:5 -- fail unreasonable hop pointer */ 171 - return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD); 200 + return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD); 172 201 173 202 } else { 174 203 175 204 /* C14-13:1 */ 176 - if (hop_cnt && hop_ptr == hop_cnt + 1) { 177 - smp->hop_ptr--; 178 - return (smp->return_path[smp->hop_ptr] == 205 + if (hop_cnt && *hop_ptr == hop_cnt + 1) { 206 + (*hop_ptr)--; 207 + return (return_path[*hop_ptr] == 179 208 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD); 180 209 } 181 210 182 211 /* C14-13:2 */ 183 - if (2 <= hop_ptr && hop_ptr <= hop_cnt) { 212 + if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) { 184 213 if (node_type != RDMA_NODE_IB_SWITCH) 185 214 return IB_SMI_DISCARD; 186 215 187 - /* smp->hop_ptr updated when sending */ 188 - return (smp->return_path[hop_ptr-1] <= phys_port_cnt ? 216 + /* hop_ptr updated when sending */ 217 + return (return_path[*hop_ptr-1] <= phys_port_cnt ? 189 218 IB_SMI_HANDLE : IB_SMI_DISCARD); 190 219 } 191 220 192 221 /* C14-13:3 -- We're at the end of the DR segment of path */ 193 - if (hop_ptr == 1) { 194 - if (smp->dr_slid == IB_LID_PERMISSIVE) { 222 + if (*hop_ptr == 1) { 223 + if (dr_slid_is_permissive) { 195 224 /* giving SMP to SM - update hop_ptr */ 196 - smp->hop_ptr--; 225 + (*hop_ptr)--; 197 226 return IB_SMI_HANDLE; 198 227 } 199 - /* smp->hop_ptr updated when sending */ 228 + /* hop_ptr updated when sending */ 200 229 return (node_type == RDMA_NODE_IB_SWITCH ? 201 230 IB_SMI_HANDLE : IB_SMI_DISCARD); 202 231 } 203 232 204 233 /* C14-13:4 -- hop_ptr = 0 -> give to SM */ 205 234 /* C14-13:5 -- Check for unreasonable hop pointer */ 206 - return (hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD); 235 + return (*hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD); 207 236 } 208 237 } 209 238 210 - enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp) 239 + /* 240 + * Adjust information for a received SMP 241 + * Return IB_SMI_DISCARD if the SMP should be dropped 242 + */ 243 + enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type, 244 + int port_num, int phys_port_cnt) 211 245 { 212 - u8 hop_ptr, hop_cnt; 246 + return __smi_handle_dr_smp_recv(node_type, port_num, phys_port_cnt, 247 + &smp->hop_ptr, smp->hop_cnt, 248 + smp->initial_path, 249 + smp->return_path, 250 + ib_get_smp_direction(smp), 251 + smp->dr_dlid == IB_LID_PERMISSIVE, 252 + smp->dr_slid == IB_LID_PERMISSIVE); 253 + } 213 254 214 - hop_ptr = smp->hop_ptr; 215 - hop_cnt = smp->hop_cnt; 255 + /* 256 + * Adjust information for a received SMP 257 + * Return IB_SMI_DISCARD if the SMP should be dropped 258 + */ 259 + enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, u8 node_type, 260 + int port_num, int phys_port_cnt) 261 + { 262 + return __smi_handle_dr_smp_recv(node_type, port_num, phys_port_cnt, 263 + &smp->hop_ptr, smp->hop_cnt, 264 + smp->route.dr.initial_path, 265 + smp->route.dr.return_path, 266 + opa_get_smp_direction(smp), 267 + smp->route.dr.dr_dlid == 268 + OPA_LID_PERMISSIVE, 269 + smp->route.dr.dr_slid == 270 + OPA_LID_PERMISSIVE); 271 + } 216 272 217 - if (!ib_get_smp_direction(smp)) { 273 + static enum smi_forward_action __smi_check_forward_dr_smp(u8 hop_ptr, u8 hop_cnt, 274 + u8 direction, 275 + bool dr_dlid_is_permissive, 276 + bool dr_slid_is_permissive) 277 + { 278 + if (!direction) { 218 279 /* C14-9:2 -- intermediate hop */ 219 280 if (hop_ptr && hop_ptr < hop_cnt) 220 281 return IB_SMI_FORWARD; 221 282 222 283 /* C14-9:3 -- at the end of the DR segment of path */ 223 284 if (hop_ptr == hop_cnt) 224 - return (smp->dr_dlid == IB_LID_PERMISSIVE ? 285 + return (dr_dlid_is_permissive ? 225 286 IB_SMI_SEND : IB_SMI_LOCAL); 226 287 227 288 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */ ··· 293 236 294 237 /* C14-13:3 -- at the end of the DR segment of path */ 295 238 if (hop_ptr == 1) 296 - return (smp->dr_slid != IB_LID_PERMISSIVE ? 239 + return (!dr_slid_is_permissive ? 297 240 IB_SMI_SEND : IB_SMI_LOCAL); 298 241 } 299 242 return IB_SMI_LOCAL; 243 + 244 + } 245 + 246 + enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp) 247 + { 248 + return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt, 249 + ib_get_smp_direction(smp), 250 + smp->dr_dlid == IB_LID_PERMISSIVE, 251 + smp->dr_slid == IB_LID_PERMISSIVE); 252 + } 253 + 254 + enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp) 255 + { 256 + return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt, 257 + opa_get_smp_direction(smp), 258 + smp->route.dr.dr_dlid == 259 + OPA_LID_PERMISSIVE, 260 + smp->route.dr.dr_slid == 261 + OPA_LID_PERMISSIVE); 300 262 } 301 263 302 264 /* ··· 326 250 { 327 251 return (!ib_get_smp_direction(smp) ? smp->initial_path[smp->hop_ptr+1] : 328 252 smp->return_path[smp->hop_ptr-1]); 253 + } 254 + 255 + /* 256 + * Return the forwarding port number from initial_path for outgoing SMP and 257 + * from return_path for returning SMP 258 + */ 259 + int opa_smi_get_fwd_port(struct opa_smp *smp) 260 + { 261 + return !opa_get_smp_direction(smp) ? smp->route.dr.initial_path[smp->hop_ptr+1] : 262 + smp->route.dr.return_path[smp->hop_ptr-1]; 329 263 }
+7 -1
drivers/infiniband/core/sysfs.c
··· 326 326 int width = (tab_attr->index >> 16) & 0xff; 327 327 struct ib_mad *in_mad = NULL; 328 328 struct ib_mad *out_mad = NULL; 329 + size_t mad_size = sizeof(*out_mad); 330 + u16 out_mad_pkey_index = 0; 329 331 ssize_t ret; 330 332 331 333 if (!p->ibdev->process_mad) ··· 349 347 in_mad->data[41] = p->port_num; /* PortSelect field */ 350 348 351 349 if ((p->ibdev->process_mad(p->ibdev, IB_MAD_IGNORE_MKEY, 352 - p->port_num, NULL, NULL, in_mad, out_mad) & 350 + p->port_num, NULL, NULL, 351 + (const struct ib_mad_hdr *)in_mad, mad_size, 352 + (struct ib_mad_hdr *)out_mad, &mad_size, 353 + &out_mad_pkey_index) & 353 354 (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) != 354 355 (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) { 355 356 ret = -EINVAL; ··· 461 456 { 462 457 struct ib_device *dev = container_of(device, struct ib_device, dev); 463 458 459 + kfree(dev->port_immutable); 464 460 kfree(dev); 465 461 } 466 462
+1 -2
drivers/infiniband/core/ucm.c
··· 1253 1253 dev_t base; 1254 1254 struct ib_ucm_device *ucm_dev; 1255 1255 1256 - if (!device->alloc_ucontext || 1257 - rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 1256 + if (!device->alloc_ucontext || !rdma_cap_ib_cm(device, 1)) 1258 1257 return; 1259 1258 1260 1259 ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
+6 -19
drivers/infiniband/core/ucma.c
··· 722 722 723 723 resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid; 724 724 resp.port_num = ctx->cm_id->port_num; 725 - switch (rdma_node_get_transport(ctx->cm_id->device->node_type)) { 726 - case RDMA_TRANSPORT_IB: 727 - switch (rdma_port_get_link_layer(ctx->cm_id->device, 728 - ctx->cm_id->port_num)) { 729 - case IB_LINK_LAYER_INFINIBAND: 730 - ucma_copy_ib_route(&resp, &ctx->cm_id->route); 731 - break; 732 - case IB_LINK_LAYER_ETHERNET: 733 - ucma_copy_iboe_route(&resp, &ctx->cm_id->route); 734 - break; 735 - default: 736 - break; 737 - } 738 - break; 739 - case RDMA_TRANSPORT_IWARP: 725 + 726 + if (rdma_cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num)) 727 + ucma_copy_ib_route(&resp, &ctx->cm_id->route); 728 + else if (rdma_protocol_roce(ctx->cm_id->device, ctx->cm_id->port_num)) 729 + ucma_copy_iboe_route(&resp, &ctx->cm_id->route); 730 + else if (rdma_protocol_iwarp(ctx->cm_id->device, ctx->cm_id->port_num)) 740 731 ucma_copy_iw_route(&resp, &ctx->cm_id->route); 741 - break; 742 - default: 743 - break; 744 - } 745 732 746 733 out: 747 734 if (copy_to_user((void __user *)(unsigned long)cmd.response,
+37 -27
drivers/infiniband/core/user_mad.c
··· 99 99 }; 100 100 101 101 struct ib_umad_device { 102 - int start_port, end_port; 103 102 struct kobject kobj; 104 103 struct ib_umad_port port[0]; 105 104 }; ··· 262 263 { 263 264 struct ib_mad_recv_buf *recv_buf; 264 265 int left, seg_payload, offset, max_seg_payload; 266 + size_t seg_size; 267 + 268 + recv_buf = &packet->recv_wc->recv_buf; 269 + seg_size = packet->recv_wc->mad_seg_size; 265 270 266 271 /* We need enough room to copy the first (or only) MAD segment. */ 267 - recv_buf = &packet->recv_wc->recv_buf; 268 - if ((packet->length <= sizeof (*recv_buf->mad) && 272 + if ((packet->length <= seg_size && 269 273 count < hdr_size(file) + packet->length) || 270 - (packet->length > sizeof (*recv_buf->mad) && 271 - count < hdr_size(file) + sizeof (*recv_buf->mad))) 274 + (packet->length > seg_size && 275 + count < hdr_size(file) + seg_size)) 272 276 return -EINVAL; 273 277 274 278 if (copy_to_user(buf, &packet->mad, hdr_size(file))) 275 279 return -EFAULT; 276 280 277 281 buf += hdr_size(file); 278 - seg_payload = min_t(int, packet->length, sizeof (*recv_buf->mad)); 282 + seg_payload = min_t(int, packet->length, seg_size); 279 283 if (copy_to_user(buf, recv_buf->mad, seg_payload)) 280 284 return -EFAULT; 281 285 ··· 295 293 return -ENOSPC; 296 294 } 297 295 offset = ib_get_mad_data_offset(recv_buf->mad->mad_hdr.mgmt_class); 298 - max_seg_payload = sizeof (struct ib_mad) - offset; 296 + max_seg_payload = seg_size - offset; 299 297 300 298 for (left = packet->length - seg_payload, buf += seg_payload; 301 299 left; left -= seg_payload, buf += seg_payload) { ··· 428 426 * the same TID, reject the second as a duplicate. This is more 429 427 * restrictive than required by the spec. 430 428 */ 431 - if (!ib_response_mad((struct ib_mad *) hdr)) { 432 - if (!ib_response_mad((struct ib_mad *) sent_hdr)) 429 + if (!ib_response_mad(hdr)) { 430 + if (!ib_response_mad(sent_hdr)) 433 431 return 1; 434 432 continue; 435 - } else if (!ib_response_mad((struct ib_mad *) sent_hdr)) 433 + } else if (!ib_response_mad(sent_hdr)) 436 434 continue; 437 435 438 436 if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr)) ··· 453 451 struct ib_rmpp_mad *rmpp_mad; 454 452 __be64 *tid; 455 453 int ret, data_len, hdr_len, copy_offset, rmpp_active; 454 + u8 base_version; 456 455 457 456 if (count < hdr_size(file) + IB_MGMT_RMPP_HDR) 458 457 return -EINVAL; ··· 520 517 rmpp_active = 0; 521 518 } 522 519 520 + base_version = ((struct ib_mad_hdr *)&packet->mad.data)->base_version; 523 521 data_len = count - hdr_size(file) - hdr_len; 524 522 packet->msg = ib_create_send_mad(agent, 525 523 be32_to_cpu(packet->mad.hdr.qpn), 526 524 packet->mad.hdr.pkey_index, rmpp_active, 527 - hdr_len, data_len, GFP_KERNEL); 525 + hdr_len, data_len, GFP_KERNEL, 526 + base_version); 528 527 if (IS_ERR(packet->msg)) { 529 528 ret = PTR_ERR(packet->msg); 530 529 goto err_ah; ··· 1278 1273 { 1279 1274 struct ib_umad_device *umad_dev; 1280 1275 int s, e, i; 1276 + int count = 0; 1281 1277 1282 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 1283 - return; 1284 - 1285 - if (device->node_type == RDMA_NODE_IB_SWITCH) 1286 - s = e = 0; 1287 - else { 1288 - s = 1; 1289 - e = device->phys_port_cnt; 1290 - } 1278 + s = rdma_start_port(device); 1279 + e = rdma_end_port(device); 1291 1280 1292 1281 umad_dev = kzalloc(sizeof *umad_dev + 1293 1282 (e - s + 1) * sizeof (struct ib_umad_port), ··· 1291 1292 1292 1293 kobject_init(&umad_dev->kobj, &ib_umad_dev_ktype); 1293 1294 1294 - umad_dev->start_port = s; 1295 - umad_dev->end_port = e; 1296 - 1297 1295 for (i = s; i <= e; ++i) { 1296 + if (!rdma_cap_ib_mad(device, i)) 1297 + continue; 1298 + 1298 1299 umad_dev->port[i - s].umad_dev = umad_dev; 1299 1300 1300 1301 if (ib_umad_init_port(device, i, umad_dev, 1301 1302 &umad_dev->port[i - s])) 1302 1303 goto err; 1304 + 1305 + count++; 1303 1306 } 1307 + 1308 + if (!count) 1309 + goto free; 1304 1310 1305 1311 ib_set_client_data(device, &umad_client, umad_dev); 1306 1312 1307 1313 return; 1308 1314 1309 1315 err: 1310 - while (--i >= s) 1311 - ib_umad_kill_port(&umad_dev->port[i - s]); 1316 + while (--i >= s) { 1317 + if (!rdma_cap_ib_mad(device, i)) 1318 + continue; 1312 1319 1320 + ib_umad_kill_port(&umad_dev->port[i - s]); 1321 + } 1322 + free: 1313 1323 kobject_put(&umad_dev->kobj); 1314 1324 } 1315 1325 ··· 1330 1322 if (!umad_dev) 1331 1323 return; 1332 1324 1333 - for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) 1334 - ib_umad_kill_port(&umad_dev->port[i]); 1325 + for (i = 0; i <= rdma_end_port(device) - rdma_start_port(device); ++i) { 1326 + if (rdma_cap_ib_mad(device, i + rdma_start_port(device))) 1327 + ib_umad_kill_port(&umad_dev->port[i]); 1328 + } 1335 1329 1336 1330 kobject_put(&umad_dev->kobj); 1337 1331 }
+1
drivers/infiniband/core/uverbs.h
··· 259 259 IB_UVERBS_DECLARE_EX_CMD(create_flow); 260 260 IB_UVERBS_DECLARE_EX_CMD(destroy_flow); 261 261 IB_UVERBS_DECLARE_EX_CMD(query_device); 262 + IB_UVERBS_DECLARE_EX_CMD(create_cq); 262 263 263 264 #endif /* UVERBS_H */
+152 -36
drivers/infiniband/core/uverbs_cmd.c
··· 1330 1330 return in_len; 1331 1331 } 1332 1332 1333 - ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, 1334 - const char __user *buf, int in_len, 1335 - int out_len) 1333 + static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file, 1334 + struct ib_udata *ucore, 1335 + struct ib_udata *uhw, 1336 + struct ib_uverbs_ex_create_cq *cmd, 1337 + size_t cmd_sz, 1338 + int (*cb)(struct ib_uverbs_file *file, 1339 + struct ib_ucq_object *obj, 1340 + struct ib_uverbs_ex_create_cq_resp *resp, 1341 + struct ib_udata *udata, 1342 + void *context), 1343 + void *context) 1336 1344 { 1337 - struct ib_uverbs_create_cq cmd; 1338 - struct ib_uverbs_create_cq_resp resp; 1339 - struct ib_udata udata; 1340 1345 struct ib_ucq_object *obj; 1341 1346 struct ib_uverbs_event_file *ev_file = NULL; 1342 1347 struct ib_cq *cq; 1343 1348 int ret; 1349 + struct ib_uverbs_ex_create_cq_resp resp; 1350 + struct ib_cq_init_attr attr = {}; 1344 1351 1345 - if (out_len < sizeof resp) 1346 - return -ENOSPC; 1347 - 1348 - if (copy_from_user(&cmd, buf, sizeof cmd)) 1349 - return -EFAULT; 1350 - 1351 - INIT_UDATA(&udata, buf + sizeof cmd, 1352 - (unsigned long) cmd.response + sizeof resp, 1353 - in_len - sizeof cmd, out_len - sizeof resp); 1354 - 1355 - if (cmd.comp_vector >= file->device->num_comp_vectors) 1356 - return -EINVAL; 1352 + if (cmd->comp_vector >= file->device->num_comp_vectors) 1353 + return ERR_PTR(-EINVAL); 1357 1354 1358 1355 obj = kmalloc(sizeof *obj, GFP_KERNEL); 1359 1356 if (!obj) 1360 - return -ENOMEM; 1357 + return ERR_PTR(-ENOMEM); 1361 1358 1362 - init_uobj(&obj->uobject, cmd.user_handle, file->ucontext, &cq_lock_class); 1359 + init_uobj(&obj->uobject, cmd->user_handle, file->ucontext, &cq_lock_class); 1363 1360 down_write(&obj->uobject.mutex); 1364 1361 1365 - if (cmd.comp_channel >= 0) { 1366 - ev_file = ib_uverbs_lookup_comp_file(cmd.comp_channel); 1362 + if (cmd->comp_channel >= 0) { 1363 + ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel); 1367 1364 if (!ev_file) { 1368 1365 ret = -EINVAL; 1369 1366 goto err; ··· 1373 1376 INIT_LIST_HEAD(&obj->comp_list); 1374 1377 INIT_LIST_HEAD(&obj->async_list); 1375 1378 1376 - cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe, 1377 - cmd.comp_vector, 1378 - file->ucontext, &udata); 1379 + attr.cqe = cmd->cqe; 1380 + attr.comp_vector = cmd->comp_vector; 1381 + 1382 + if (cmd_sz > offsetof(typeof(*cmd), flags) + sizeof(cmd->flags)) 1383 + attr.flags = cmd->flags; 1384 + 1385 + cq = file->device->ib_dev->create_cq(file->device->ib_dev, &attr, 1386 + file->ucontext, uhw); 1379 1387 if (IS_ERR(cq)) { 1380 1388 ret = PTR_ERR(cq); 1381 1389 goto err_file; ··· 1399 1397 goto err_free; 1400 1398 1401 1399 memset(&resp, 0, sizeof resp); 1402 - resp.cq_handle = obj->uobject.id; 1403 - resp.cqe = cq->cqe; 1400 + resp.base.cq_handle = obj->uobject.id; 1401 + resp.base.cqe = cq->cqe; 1404 1402 1405 - if (copy_to_user((void __user *) (unsigned long) cmd.response, 1406 - &resp, sizeof resp)) { 1407 - ret = -EFAULT; 1408 - goto err_copy; 1409 - } 1403 + resp.response_length = offsetof(typeof(resp), response_length) + 1404 + sizeof(resp.response_length); 1405 + 1406 + ret = cb(file, obj, &resp, ucore, context); 1407 + if (ret) 1408 + goto err_cb; 1410 1409 1411 1410 mutex_lock(&file->mutex); 1412 1411 list_add_tail(&obj->uobject.list, &file->ucontext->cq_list); ··· 1417 1414 1418 1415 up_write(&obj->uobject.mutex); 1419 1416 1420 - return in_len; 1417 + return obj; 1421 1418 1422 - err_copy: 1419 + err_cb: 1423 1420 idr_remove_uobj(&ib_uverbs_cq_idr, &obj->uobject); 1424 1421 1425 1422 err_free: ··· 1431 1428 1432 1429 err: 1433 1430 put_uobj_write(&obj->uobject); 1434 - return ret; 1431 + 1432 + return ERR_PTR(ret); 1433 + } 1434 + 1435 + static int ib_uverbs_create_cq_cb(struct ib_uverbs_file *file, 1436 + struct ib_ucq_object *obj, 1437 + struct ib_uverbs_ex_create_cq_resp *resp, 1438 + struct ib_udata *ucore, void *context) 1439 + { 1440 + if (ib_copy_to_udata(ucore, &resp->base, sizeof(resp->base))) 1441 + return -EFAULT; 1442 + 1443 + return 0; 1444 + } 1445 + 1446 + ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, 1447 + const char __user *buf, int in_len, 1448 + int out_len) 1449 + { 1450 + struct ib_uverbs_create_cq cmd; 1451 + struct ib_uverbs_ex_create_cq cmd_ex; 1452 + struct ib_uverbs_create_cq_resp resp; 1453 + struct ib_udata ucore; 1454 + struct ib_udata uhw; 1455 + struct ib_ucq_object *obj; 1456 + 1457 + if (out_len < sizeof(resp)) 1458 + return -ENOSPC; 1459 + 1460 + if (copy_from_user(&cmd, buf, sizeof(cmd))) 1461 + return -EFAULT; 1462 + 1463 + INIT_UDATA(&ucore, buf, cmd.response, sizeof(cmd), sizeof(resp)); 1464 + 1465 + INIT_UDATA(&uhw, buf + sizeof(cmd), 1466 + (unsigned long)cmd.response + sizeof(resp), 1467 + in_len - sizeof(cmd), out_len - sizeof(resp)); 1468 + 1469 + memset(&cmd_ex, 0, sizeof(cmd_ex)); 1470 + cmd_ex.user_handle = cmd.user_handle; 1471 + cmd_ex.cqe = cmd.cqe; 1472 + cmd_ex.comp_vector = cmd.comp_vector; 1473 + cmd_ex.comp_channel = cmd.comp_channel; 1474 + 1475 + obj = create_cq(file, &ucore, &uhw, &cmd_ex, 1476 + offsetof(typeof(cmd_ex), comp_channel) + 1477 + sizeof(cmd.comp_channel), ib_uverbs_create_cq_cb, 1478 + NULL); 1479 + 1480 + if (IS_ERR(obj)) 1481 + return PTR_ERR(obj); 1482 + 1483 + return in_len; 1484 + } 1485 + 1486 + static int ib_uverbs_ex_create_cq_cb(struct ib_uverbs_file *file, 1487 + struct ib_ucq_object *obj, 1488 + struct ib_uverbs_ex_create_cq_resp *resp, 1489 + struct ib_udata *ucore, void *context) 1490 + { 1491 + if (ib_copy_to_udata(ucore, resp, resp->response_length)) 1492 + return -EFAULT; 1493 + 1494 + return 0; 1495 + } 1496 + 1497 + int ib_uverbs_ex_create_cq(struct ib_uverbs_file *file, 1498 + struct ib_udata *ucore, 1499 + struct ib_udata *uhw) 1500 + { 1501 + struct ib_uverbs_ex_create_cq_resp resp; 1502 + struct ib_uverbs_ex_create_cq cmd; 1503 + struct ib_ucq_object *obj; 1504 + int err; 1505 + 1506 + if (ucore->inlen < sizeof(cmd)) 1507 + return -EINVAL; 1508 + 1509 + err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); 1510 + if (err) 1511 + return err; 1512 + 1513 + if (cmd.comp_mask) 1514 + return -EINVAL; 1515 + 1516 + if (cmd.reserved) 1517 + return -EINVAL; 1518 + 1519 + if (ucore->outlen < (offsetof(typeof(resp), response_length) + 1520 + sizeof(resp.response_length))) 1521 + return -ENOSPC; 1522 + 1523 + obj = create_cq(file, ucore, uhw, &cmd, 1524 + min(ucore->inlen, sizeof(cmd)), 1525 + ib_uverbs_ex_create_cq_cb, NULL); 1526 + 1527 + if (IS_ERR(obj)) 1528 + return PTR_ERR(obj); 1529 + 1530 + return 0; 1435 1531 } 1436 1532 1437 1533 ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file, ··· 3426 3324 if (ucore->outlen < resp.response_length) 3427 3325 return -ENOSPC; 3428 3326 3429 - err = device->query_device(device, &attr); 3327 + memset(&attr, 0, sizeof(attr)); 3328 + 3329 + err = device->query_device(device, &attr, uhw); 3430 3330 if (err) 3431 3331 return err; 3432 3332 ··· 3451 3347 memset(&resp.odp_caps, 0, sizeof(resp.odp_caps)); 3452 3348 #endif 3453 3349 resp.response_length += sizeof(resp.odp_caps); 3350 + 3351 + if (ucore->outlen < resp.response_length + sizeof(resp.timestamp_mask)) 3352 + goto end; 3353 + 3354 + resp.timestamp_mask = attr.timestamp_mask; 3355 + resp.response_length += sizeof(resp.timestamp_mask); 3356 + 3357 + if (ucore->outlen < resp.response_length + sizeof(resp.hca_core_clock)) 3358 + goto end; 3359 + 3360 + resp.hca_core_clock = attr.hca_core_clock; 3361 + resp.response_length += sizeof(resp.hca_core_clock); 3454 3362 3455 3363 end: 3456 3364 err = ib_copy_to_udata(ucore, &resp, resp.response_length);
+1
drivers/infiniband/core/uverbs_main.c
··· 124 124 [IB_USER_VERBS_EX_CMD_CREATE_FLOW] = ib_uverbs_ex_create_flow, 125 125 [IB_USER_VERBS_EX_CMD_DESTROY_FLOW] = ib_uverbs_ex_destroy_flow, 126 126 [IB_USER_VERBS_EX_CMD_QUERY_DEVICE] = ib_uverbs_ex_query_device, 127 + [IB_USER_VERBS_EX_CMD_CREATE_CQ] = ib_uverbs_ex_create_cq, 127 128 }; 128 129 129 130 static void ib_uverbs_add_one(struct ib_device *device);
+75 -10
drivers/infiniband/core/verbs.c
··· 48 48 49 49 #include "core_priv.h" 50 50 51 + static const char * const ib_events[] = { 52 + [IB_EVENT_CQ_ERR] = "CQ error", 53 + [IB_EVENT_QP_FATAL] = "QP fatal error", 54 + [IB_EVENT_QP_REQ_ERR] = "QP request error", 55 + [IB_EVENT_QP_ACCESS_ERR] = "QP access error", 56 + [IB_EVENT_COMM_EST] = "communication established", 57 + [IB_EVENT_SQ_DRAINED] = "send queue drained", 58 + [IB_EVENT_PATH_MIG] = "path migration successful", 59 + [IB_EVENT_PATH_MIG_ERR] = "path migration error", 60 + [IB_EVENT_DEVICE_FATAL] = "device fatal error", 61 + [IB_EVENT_PORT_ACTIVE] = "port active", 62 + [IB_EVENT_PORT_ERR] = "port error", 63 + [IB_EVENT_LID_CHANGE] = "LID change", 64 + [IB_EVENT_PKEY_CHANGE] = "P_key change", 65 + [IB_EVENT_SM_CHANGE] = "SM change", 66 + [IB_EVENT_SRQ_ERR] = "SRQ error", 67 + [IB_EVENT_SRQ_LIMIT_REACHED] = "SRQ limit reached", 68 + [IB_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached", 69 + [IB_EVENT_CLIENT_REREGISTER] = "client reregister", 70 + [IB_EVENT_GID_CHANGE] = "GID changed", 71 + }; 72 + 73 + const char *ib_event_msg(enum ib_event_type event) 74 + { 75 + size_t index = event; 76 + 77 + return (index < ARRAY_SIZE(ib_events) && ib_events[index]) ? 78 + ib_events[index] : "unrecognized event"; 79 + } 80 + EXPORT_SYMBOL(ib_event_msg); 81 + 82 + static const char * const wc_statuses[] = { 83 + [IB_WC_SUCCESS] = "success", 84 + [IB_WC_LOC_LEN_ERR] = "local length error", 85 + [IB_WC_LOC_QP_OP_ERR] = "local QP operation error", 86 + [IB_WC_LOC_EEC_OP_ERR] = "local EE context operation error", 87 + [IB_WC_LOC_PROT_ERR] = "local protection error", 88 + [IB_WC_WR_FLUSH_ERR] = "WR flushed", 89 + [IB_WC_MW_BIND_ERR] = "memory management operation error", 90 + [IB_WC_BAD_RESP_ERR] = "bad response error", 91 + [IB_WC_LOC_ACCESS_ERR] = "local access error", 92 + [IB_WC_REM_INV_REQ_ERR] = "invalid request error", 93 + [IB_WC_REM_ACCESS_ERR] = "remote access error", 94 + [IB_WC_REM_OP_ERR] = "remote operation error", 95 + [IB_WC_RETRY_EXC_ERR] = "transport retry counter exceeded", 96 + [IB_WC_RNR_RETRY_EXC_ERR] = "RNR retry counter exceeded", 97 + [IB_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error", 98 + [IB_WC_REM_INV_RD_REQ_ERR] = "remote invalid RD request", 99 + [IB_WC_REM_ABORT_ERR] = "operation aborted", 100 + [IB_WC_INV_EECN_ERR] = "invalid EE context number", 101 + [IB_WC_INV_EEC_STATE_ERR] = "invalid EE context state", 102 + [IB_WC_FATAL_ERR] = "fatal error", 103 + [IB_WC_RESP_TIMEOUT_ERR] = "response timeout error", 104 + [IB_WC_GENERAL_ERR] = "general error", 105 + }; 106 + 107 + const char *ib_wc_status_msg(enum ib_wc_status status) 108 + { 109 + size_t index = status; 110 + 111 + return (index < ARRAY_SIZE(wc_statuses) && wc_statuses[index]) ? 112 + wc_statuses[index] : "unrecognized status"; 113 + } 114 + EXPORT_SYMBOL(ib_wc_status_msg); 115 + 51 116 __attribute_const__ int ib_rate_to_mult(enum ib_rate rate) 52 117 { 53 118 switch (rate) { ··· 257 192 } 258 193 EXPORT_SYMBOL(ib_create_ah); 259 194 260 - int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc, 261 - struct ib_grh *grh, struct ib_ah_attr *ah_attr) 195 + int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, 196 + const struct ib_wc *wc, const struct ib_grh *grh, 197 + struct ib_ah_attr *ah_attr) 262 198 { 263 199 u32 flow_class; 264 200 u16 gid_index; 265 201 int ret; 266 - int is_eth = (rdma_port_get_link_layer(device, port_num) == 267 - IB_LINK_LAYER_ETHERNET); 268 202 269 203 memset(ah_attr, 0, sizeof *ah_attr); 270 - if (is_eth) { 204 + if (rdma_cap_eth_ah(device, port_num)) { 271 205 if (!(wc->wc_flags & IB_WC_GRH)) 272 206 return -EPROTOTYPE; 273 207 ··· 308 244 } 309 245 EXPORT_SYMBOL(ib_init_ah_from_wc); 310 246 311 - struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, 312 - struct ib_grh *grh, u8 port_num) 247 + struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc, 248 + const struct ib_grh *grh, u8 port_num) 313 249 { 314 250 struct ib_ah_attr ah_attr; 315 251 int ret; ··· 935 871 union ib_gid sgid; 936 872 937 873 if ((*qp_attr_mask & IB_QP_AV) && 938 - (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) { 874 + (rdma_cap_eth_ah(qp->device, qp_attr->ah_attr.port_num))) { 939 875 ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num, 940 876 qp_attr->ah_attr.grh.sgid_index, &sgid); 941 877 if (ret) ··· 1076 1012 struct ib_cq *ib_create_cq(struct ib_device *device, 1077 1013 ib_comp_handler comp_handler, 1078 1014 void (*event_handler)(struct ib_event *, void *), 1079 - void *cq_context, int cqe, int comp_vector) 1015 + void *cq_context, 1016 + const struct ib_cq_init_attr *cq_attr) 1080 1017 { 1081 1018 struct ib_cq *cq; 1082 1019 1083 - cq = device->create_cq(device, cqe, comp_vector, NULL, NULL); 1020 + cq = device->create_cq(device, cq_attr, NULL, NULL); 1084 1021 1085 1022 if (!IS_ERR(cq)) { 1086 1023 cq->device = device;
+36 -6
drivers/infiniband/hw/amso1100/c2_provider.c
··· 63 63 #include "c2_provider.h" 64 64 #include "c2_user.h" 65 65 66 - static int c2_query_device(struct ib_device *ibdev, 67 - struct ib_device_attr *props) 66 + static int c2_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 67 + struct ib_udata *uhw) 68 68 { 69 69 struct c2_dev *c2dev = to_c2dev(ibdev); 70 70 71 71 pr_debug("%s:%u\n", __func__, __LINE__); 72 + 73 + if (uhw->inlen || uhw->outlen) 74 + return -EINVAL; 72 75 73 76 *props = c2dev->props; 74 77 return 0; ··· 289 286 return 0; 290 287 } 291 288 292 - static struct ib_cq *c2_create_cq(struct ib_device *ibdev, int entries, int vector, 289 + static struct ib_cq *c2_create_cq(struct ib_device *ibdev, 290 + const struct ib_cq_init_attr *attr, 293 291 struct ib_ucontext *context, 294 292 struct ib_udata *udata) 295 293 { 294 + int entries = attr->cqe; 296 295 struct c2_cq *cq; 297 296 int err; 297 + 298 + if (attr->flags) 299 + return ERR_PTR(-EINVAL); 298 300 299 301 cq = kmalloc(sizeof(*cq), GFP_KERNEL); 300 302 if (!cq) { ··· 590 582 static int c2_process_mad(struct ib_device *ibdev, 591 583 int mad_flags, 592 584 u8 port_num, 593 - struct ib_wc *in_wc, 594 - struct ib_grh *in_grh, 595 - struct ib_mad *in_mad, struct ib_mad *out_mad) 585 + const struct ib_wc *in_wc, 586 + const struct ib_grh *in_grh, 587 + const struct ib_mad_hdr *in_mad, 588 + size_t in_mad_size, 589 + struct ib_mad_hdr *out_mad, 590 + size_t *out_mad_size, 591 + u16 *out_mad_pkey_index) 596 592 { 597 593 pr_debug("%s:%u\n", __func__, __LINE__); 598 594 return -ENOSYS; ··· 769 757 return netdev; 770 758 } 771 759 760 + static int c2_port_immutable(struct ib_device *ibdev, u8 port_num, 761 + struct ib_port_immutable *immutable) 762 + { 763 + struct ib_port_attr attr; 764 + int err; 765 + 766 + err = c2_query_port(ibdev, port_num, &attr); 767 + if (err) 768 + return err; 769 + 770 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 771 + immutable->gid_tbl_len = attr.gid_tbl_len; 772 + immutable->core_cap_flags = RDMA_CORE_PORT_IWARP; 773 + 774 + return 0; 775 + } 776 + 772 777 int c2_register_device(struct c2_dev *dev) 773 778 { 774 779 int ret = -ENOMEM; ··· 849 820 dev->ibdev.reg_phys_mr = c2_reg_phys_mr; 850 821 dev->ibdev.reg_user_mr = c2_reg_user_mr; 851 822 dev->ibdev.dereg_mr = c2_dereg_mr; 823 + dev->ibdev.get_port_immutable = c2_port_immutable; 852 824 853 825 dev->ibdev.alloc_fmr = NULL; 854 826 dev->ibdev.unmap_fmr = NULL;
+39 -8
drivers/infiniband/hw/cxgb3/iwch_provider.c
··· 85 85 static int iwch_process_mad(struct ib_device *ibdev, 86 86 int mad_flags, 87 87 u8 port_num, 88 - struct ib_wc *in_wc, 89 - struct ib_grh *in_grh, 90 - struct ib_mad *in_mad, struct ib_mad *out_mad) 88 + const struct ib_wc *in_wc, 89 + const struct ib_grh *in_grh, 90 + const struct ib_mad_hdr *in_mad, 91 + size_t in_mad_size, 92 + struct ib_mad_hdr *out_mad, 93 + size_t *out_mad_size, 94 + u16 *out_mad_pkey_index) 91 95 { 92 96 return -ENOSYS; 93 97 } ··· 142 138 return 0; 143 139 } 144 140 145 - static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int vector, 146 - struct ib_ucontext *ib_context, 147 - struct ib_udata *udata) 141 + static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, 142 + const struct ib_cq_init_attr *attr, 143 + struct ib_ucontext *ib_context, 144 + struct ib_udata *udata) 148 145 { 146 + int entries = attr->cqe; 149 147 struct iwch_dev *rhp; 150 148 struct iwch_cq *chp; 151 149 struct iwch_create_cq_resp uresp; ··· 157 151 size_t resplen; 158 152 159 153 PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries); 154 + if (attr->flags) 155 + return ERR_PTR(-EINVAL); 156 + 160 157 rhp = to_iwch_dev(ibdev); 161 158 chp = kzalloc(sizeof(*chp), GFP_KERNEL); 162 159 if (!chp) ··· 1154 1145 (fw_mic & 0xffff); 1155 1146 } 1156 1147 1157 - static int iwch_query_device(struct ib_device *ibdev, 1158 - struct ib_device_attr *props) 1148 + static int iwch_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 1149 + struct ib_udata *uhw) 1159 1150 { 1160 1151 1161 1152 struct iwch_dev *dev; 1153 + 1162 1154 PDBG("%s ibdev %p\n", __func__, ibdev); 1155 + 1156 + if (uhw->inlen || uhw->outlen) 1157 + return -EINVAL; 1163 1158 1164 1159 dev = to_iwch_dev(ibdev); 1165 1160 memset(props, 0, sizeof *props); ··· 1356 1343 &dev_attr_board_id, 1357 1344 }; 1358 1345 1346 + static int iwch_port_immutable(struct ib_device *ibdev, u8 port_num, 1347 + struct ib_port_immutable *immutable) 1348 + { 1349 + struct ib_port_attr attr; 1350 + int err; 1351 + 1352 + err = iwch_query_port(ibdev, port_num, &attr); 1353 + if (err) 1354 + return err; 1355 + 1356 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 1357 + immutable->gid_tbl_len = attr.gid_tbl_len; 1358 + immutable->core_cap_flags = RDMA_CORE_PORT_IWARP; 1359 + 1360 + return 0; 1361 + } 1362 + 1359 1363 int iwch_register_device(struct iwch_dev *dev) 1360 1364 { 1361 1365 int ret; ··· 1450 1420 dev->ibdev.post_recv = iwch_post_receive; 1451 1421 dev->ibdev.get_protocol_stats = iwch_get_mib; 1452 1422 dev->ibdev.uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION; 1423 + dev->ibdev.get_port_immutable = iwch_port_immutable; 1453 1424 1454 1425 dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); 1455 1426 if (!dev->ibdev.iwcm)
+17 -14
drivers/infiniband/hw/cxgb4/cq.c
··· 156 156 goto err4; 157 157 158 158 cq->gen = 1; 159 + cq->gts = rdev->lldi.gts_reg; 159 160 cq->rdev = rdev; 160 - if (user) { 161 - u32 off = (cq->cqid << rdev->cqshift) & PAGE_MASK; 162 161 163 - cq->ugts = (u64)rdev->bar2_pa + off; 164 - } else if (is_t4(rdev->lldi.adapter_type)) { 165 - cq->gts = rdev->lldi.gts_reg; 166 - cq->qid_mask = -1U; 167 - } else { 168 - u32 off = ((cq->cqid << rdev->cqshift) & PAGE_MASK) + 12; 169 - 170 - cq->gts = rdev->bar2_kva + off; 171 - cq->qid_mask = rdev->qpmask; 162 + cq->bar2_va = c4iw_bar2_addrs(rdev, cq->cqid, T4_BAR2_QTYPE_INGRESS, 163 + &cq->bar2_qid, 164 + user ? &cq->bar2_pa : NULL); 165 + if (user && !cq->bar2_va) { 166 + pr_warn(MOD "%s: cqid %u not in BAR2 range.\n", 167 + pci_name(rdev->lldi.pdev), cq->cqid); 168 + ret = -EINVAL; 169 + goto err4; 172 170 } 173 171 return 0; 174 172 err4: ··· 864 866 return 0; 865 867 } 866 868 867 - struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries, 868 - int vector, struct ib_ucontext *ib_context, 869 + struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, 870 + const struct ib_cq_init_attr *attr, 871 + struct ib_ucontext *ib_context, 869 872 struct ib_udata *udata) 870 873 { 874 + int entries = attr->cqe; 875 + int vector = attr->comp_vector; 871 876 struct c4iw_dev *rhp; 872 877 struct c4iw_cq *chp; 873 878 struct c4iw_create_cq_resp uresp; ··· 880 879 struct c4iw_mm_entry *mm, *mm2; 881 880 882 881 PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries); 882 + if (attr->flags) 883 + return ERR_PTR(-EINVAL); 883 884 884 885 rhp = to_c4iw_dev(ibdev); 885 886 ··· 974 971 insert_mmap(ucontext, mm); 975 972 976 973 mm2->key = uresp.gts_key; 977 - mm2->addr = chp->cq.ugts; 974 + mm2->addr = chp->cq.bar2_pa; 978 975 mm2->len = PAGE_SIZE; 979 976 insert_mmap(ucontext, mm2); 980 977 }
+4 -12
drivers/infiniband/hw/cxgb4/device.c
··· 795 795 goto err1; 796 796 } 797 797 798 - /* 799 - * qpshift is the number of bits to shift the qpid left in order 800 - * to get the correct address of the doorbell for that qp. 801 - */ 802 - rdev->qpshift = PAGE_SHIFT - ilog2(rdev->lldi.udb_density); 803 798 rdev->qpmask = rdev->lldi.udb_density - 1; 804 - rdev->cqshift = PAGE_SHIFT - ilog2(rdev->lldi.ucq_density); 805 799 rdev->cqmask = rdev->lldi.ucq_density - 1; 806 800 PDBG("%s dev %s stag start 0x%0x size 0x%0x num stags %d " 807 801 "pbl start 0x%0x size 0x%0x rq start 0x%0x size 0x%0x " ··· 809 815 rdev->lldi.vr->qp.size, 810 816 rdev->lldi.vr->cq.start, 811 817 rdev->lldi.vr->cq.size); 812 - PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu " 813 - "qpmask 0x%x cqshift %lu cqmask 0x%x\n", 818 + PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p " 819 + "qpmask 0x%x cqmask 0x%x\n", 814 820 (unsigned)pci_resource_len(rdev->lldi.pdev, 2), 815 821 (void *)pci_resource_start(rdev->lldi.pdev, 2), 816 - rdev->lldi.db_reg, 817 - rdev->lldi.gts_reg, 818 - rdev->qpshift, rdev->qpmask, 819 - rdev->cqshift, rdev->cqmask); 822 + rdev->lldi.db_reg, rdev->lldi.gts_reg, 823 + rdev->qpmask, rdev->cqmask); 820 824 821 825 if (c4iw_num_stags(rdev) == 0) { 822 826 err = -EINVAL;
+7 -6
drivers/infiniband/hw/cxgb4/iw_cxgb4.h
··· 165 165 166 166 struct c4iw_rdev { 167 167 struct c4iw_resource resource; 168 - unsigned long qpshift; 169 168 u32 qpmask; 170 - unsigned long cqshift; 171 169 u32 cqmask; 172 170 struct c4iw_dev_ucontext uctx; 173 171 struct gen_pool *pbl_pool; ··· 990 992 int acc, u64 *iova_start); 991 993 int c4iw_dereg_mr(struct ib_mr *ib_mr); 992 994 int c4iw_destroy_cq(struct ib_cq *ib_cq); 993 - struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries, 994 - int vector, 995 - struct ib_ucontext *ib_context, 996 - struct ib_udata *udata); 995 + struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, 996 + const struct ib_cq_init_attr *attr, 997 + struct ib_ucontext *ib_context, 998 + struct ib_udata *udata); 997 999 int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata); 998 1000 int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); 999 1001 int c4iw_destroy_qp(struct ib_qp *ib_qp); ··· 1030 1032 1031 1033 extern struct cxgb4_client t4c_client; 1032 1034 extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS]; 1035 + void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, unsigned int qid, 1036 + enum cxgb4_bar2_qtype qtype, 1037 + unsigned int *pbar2_qid, u64 *pbar2_pa); 1033 1038 extern void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe); 1034 1039 extern int c4iw_wr_log; 1035 1040 extern int db_fc_threshold;
+31 -5
drivers/infiniband/hw/cxgb4/provider.c
··· 80 80 } 81 81 82 82 static int c4iw_process_mad(struct ib_device *ibdev, int mad_flags, 83 - u8 port_num, struct ib_wc *in_wc, 84 - struct ib_grh *in_grh, struct ib_mad *in_mad, 85 - struct ib_mad *out_mad) 83 + u8 port_num, const struct ib_wc *in_wc, 84 + const struct ib_grh *in_grh, 85 + const struct ib_mad_hdr *in_mad, 86 + size_t in_mad_size, 87 + struct ib_mad_hdr *out_mad, 88 + size_t *out_mad_size, 89 + u16 *out_mad_pkey_index) 86 90 { 87 91 return -ENOSYS; 88 92 } ··· 305 301 return 0; 306 302 } 307 303 308 - static int c4iw_query_device(struct ib_device *ibdev, 309 - struct ib_device_attr *props) 304 + static int c4iw_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 305 + struct ib_udata *uhw) 310 306 { 311 307 312 308 struct c4iw_dev *dev; 309 + 313 310 PDBG("%s ibdev %p\n", __func__, ibdev); 311 + 312 + if (uhw->inlen || uhw->outlen) 313 + return -EINVAL; 314 314 315 315 dev = to_c4iw_dev(ibdev); 316 316 memset(props, 0, sizeof *props); ··· 473 465 &dev_attr_board_id, 474 466 }; 475 467 468 + static int c4iw_port_immutable(struct ib_device *ibdev, u8 port_num, 469 + struct ib_port_immutable *immutable) 470 + { 471 + struct ib_port_attr attr; 472 + int err; 473 + 474 + err = c4iw_query_port(ibdev, port_num, &attr); 475 + if (err) 476 + return err; 477 + 478 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 479 + immutable->gid_tbl_len = attr.gid_tbl_len; 480 + immutable->core_cap_flags = RDMA_CORE_PORT_IWARP; 481 + 482 + return 0; 483 + } 484 + 476 485 int c4iw_register_device(struct c4iw_dev *dev) 477 486 { 478 487 int ret; ··· 567 542 dev->ibdev.post_recv = c4iw_post_receive; 568 543 dev->ibdev.get_protocol_stats = c4iw_get_mib; 569 544 dev->ibdev.uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION; 545 + dev->ibdev.get_port_immutable = c4iw_port_immutable; 570 546 571 547 dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); 572 548 if (!dev->ibdev.iwcm)
+42 -22
drivers/infiniband/hw/cxgb4/qp.c
··· 165 165 return 0; 166 166 } 167 167 168 + /* 169 + * Determine the BAR2 virtual address and qid. If pbar2_pa is not NULL, 170 + * then this is a user mapping so compute the page-aligned physical address 171 + * for mapping. 172 + */ 173 + void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, unsigned int qid, 174 + enum cxgb4_bar2_qtype qtype, 175 + unsigned int *pbar2_qid, u64 *pbar2_pa) 176 + { 177 + u64 bar2_qoffset; 178 + int ret; 179 + 180 + ret = cxgb4_bar2_sge_qregs(rdev->lldi.ports[0], qid, qtype, 181 + pbar2_pa ? 1 : 0, 182 + &bar2_qoffset, pbar2_qid); 183 + if (ret) 184 + return NULL; 185 + 186 + if (pbar2_pa) 187 + *pbar2_pa = (rdev->bar2_pa + bar2_qoffset) & PAGE_MASK; 188 + return rdev->bar2_kva + bar2_qoffset; 189 + } 190 + 168 191 static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, 169 192 struct t4_cq *rcq, struct t4_cq *scq, 170 193 struct c4iw_dev_ucontext *uctx) ··· 259 236 dma_unmap_addr_set(&wq->rq, mapping, wq->rq.dma_addr); 260 237 261 238 wq->db = rdev->lldi.db_reg; 262 - wq->gts = rdev->lldi.gts_reg; 263 - if (user || is_t5(rdev->lldi.adapter_type)) { 264 - u32 off; 265 239 266 - off = (wq->sq.qid << rdev->qpshift) & PAGE_MASK; 267 - if (user) { 268 - wq->sq.udb = (u64 __iomem *)(rdev->bar2_pa + off); 269 - } else { 270 - off += 128 * (wq->sq.qid & rdev->qpmask) + 8; 271 - wq->sq.udb = (u64 __iomem *)(rdev->bar2_kva + off); 272 - } 273 - off = (wq->rq.qid << rdev->qpshift) & PAGE_MASK; 274 - if (user) { 275 - wq->rq.udb = (u64 __iomem *)(rdev->bar2_pa + off); 276 - } else { 277 - off += 128 * (wq->rq.qid & rdev->qpmask) + 8; 278 - wq->rq.udb = (u64 __iomem *)(rdev->bar2_kva + off); 279 - } 240 + wq->sq.bar2_va = c4iw_bar2_addrs(rdev, wq->sq.qid, T4_BAR2_QTYPE_EGRESS, 241 + &wq->sq.bar2_qid, 242 + user ? &wq->sq.bar2_pa : NULL); 243 + wq->rq.bar2_va = c4iw_bar2_addrs(rdev, wq->rq.qid, T4_BAR2_QTYPE_EGRESS, 244 + &wq->rq.bar2_qid, 245 + user ? &wq->rq.bar2_pa : NULL); 246 + 247 + /* 248 + * User mode must have bar2 access. 249 + */ 250 + if (user && (!wq->sq.bar2_va || !wq->rq.bar2_va)) { 251 + pr_warn(MOD "%s: sqid %u or rqid %u not in BAR2 range.\n", 252 + pci_name(rdev->lldi.pdev), wq->sq.qid, wq->rq.qid); 253 + goto free_dma; 280 254 } 255 + 281 256 wq->rdev = rdev; 282 257 wq->rq.msn = 1; 283 258 ··· 357 336 if (ret) 358 337 goto free_dma; 359 338 360 - PDBG("%s sqid 0x%x rqid 0x%x kdb 0x%p squdb 0x%lx rqudb 0x%lx\n", 339 + PDBG("%s sqid 0x%x rqid 0x%x kdb 0x%p sq_bar2_addr %p rq_bar2_addr %p\n", 361 340 __func__, wq->sq.qid, wq->rq.qid, wq->db, 362 - (__force unsigned long) wq->sq.udb, 363 - (__force unsigned long) wq->rq.udb); 341 + wq->sq.bar2_va, wq->rq.bar2_va); 364 342 365 343 return 0; 366 344 free_dma: ··· 1786 1766 mm2->len = PAGE_ALIGN(qhp->wq.rq.memsize); 1787 1767 insert_mmap(ucontext, mm2); 1788 1768 mm3->key = uresp.sq_db_gts_key; 1789 - mm3->addr = (__force unsigned long)qhp->wq.sq.udb; 1769 + mm3->addr = (__force unsigned long)qhp->wq.sq.bar2_pa; 1790 1770 mm3->len = PAGE_SIZE; 1791 1771 insert_mmap(ucontext, mm3); 1792 1772 mm4->key = uresp.rq_db_gts_key; 1793 - mm4->addr = (__force unsigned long)qhp->wq.rq.udb; 1773 + mm4->addr = (__force unsigned long)qhp->wq.rq.bar2_pa; 1794 1774 mm4->len = PAGE_SIZE; 1795 1775 insert_mmap(ucontext, mm4); 1796 1776 if (mm5) {
+39 -21
drivers/infiniband/hw/cxgb4/t4.h
··· 33 33 34 34 #include "t4_hw.h" 35 35 #include "t4_regs.h" 36 + #include "t4_values.h" 36 37 #include "t4_msg.h" 37 38 #include "t4fw_ri_api.h" 38 39 ··· 291 290 unsigned long phys_addr; 292 291 struct t4_swsqe *sw_sq; 293 292 struct t4_swsqe *oldest_read; 294 - u64 __iomem *udb; 293 + void __iomem *bar2_va; 294 + u64 bar2_pa; 295 295 size_t memsize; 296 + u32 bar2_qid; 296 297 u32 qid; 297 298 u16 in_use; 298 299 u16 size; ··· 317 314 dma_addr_t dma_addr; 318 315 DEFINE_DMA_UNMAP_ADDR(mapping); 319 316 struct t4_swrqe *sw_rq; 320 - u64 __iomem *udb; 317 + void __iomem *bar2_va; 318 + u64 bar2_pa; 321 319 size_t memsize; 320 + u32 bar2_qid; 322 321 u32 qid; 323 322 u32 msn; 324 323 u32 rqt_hwaddr; ··· 337 332 struct t4_sq sq; 338 333 struct t4_rq rq; 339 334 void __iomem *db; 340 - void __iomem *gts; 341 335 struct c4iw_rdev *rdev; 342 336 int flushed; 343 337 }; ··· 461 457 462 458 /* Flush host queue memory writes. */ 463 459 wmb(); 464 - if (t5) { 465 - if (inc == 1 && wqe) { 460 + if (wq->sq.bar2_va) { 461 + if (inc == 1 && wq->sq.bar2_qid == 0 && wqe) { 466 462 PDBG("%s: WC wq->sq.pidx = %d\n", 467 463 __func__, wq->sq.pidx); 468 - pio_copy(wq->sq.udb + 7, (void *)wqe); 464 + pio_copy((u64 __iomem *) 465 + (wq->sq.bar2_va + SGE_UDB_WCDOORBELL), 466 + (u64 *)wqe); 469 467 } else { 470 468 PDBG("%s: DB wq->sq.pidx = %d\n", 471 469 __func__, wq->sq.pidx); 472 - writel(PIDX_T5_V(inc), wq->sq.udb); 470 + writel(PIDX_T5_V(inc) | QID_V(wq->sq.bar2_qid), 471 + wq->sq.bar2_va + SGE_UDB_KDOORBELL); 473 472 } 474 473 475 474 /* Flush user doorbell area writes. */ ··· 488 481 489 482 /* Flush host queue memory writes. */ 490 483 wmb(); 491 - if (t5) { 492 - if (inc == 1 && wqe) { 484 + if (wq->rq.bar2_va) { 485 + if (inc == 1 && wq->rq.bar2_qid == 0 && wqe) { 493 486 PDBG("%s: WC wq->rq.pidx = %d\n", 494 487 __func__, wq->rq.pidx); 495 - pio_copy(wq->rq.udb + 7, (void *)wqe); 488 + pio_copy((u64 __iomem *) 489 + (wq->rq.bar2_va + SGE_UDB_WCDOORBELL), 490 + (void *)wqe); 496 491 } else { 497 492 PDBG("%s: DB wq->rq.pidx = %d\n", 498 493 __func__, wq->rq.pidx); 499 - writel(PIDX_T5_V(inc), wq->rq.udb); 494 + writel(PIDX_T5_V(inc) | QID_V(wq->rq.bar2_qid), 495 + wq->rq.bar2_va + SGE_UDB_KDOORBELL); 500 496 } 501 497 502 498 /* Flush user doorbell area writes. */ ··· 544 534 DEFINE_DMA_UNMAP_ADDR(mapping); 545 535 struct t4_cqe *sw_queue; 546 536 void __iomem *gts; 537 + void __iomem *bar2_va; 538 + u64 bar2_pa; 539 + u32 bar2_qid; 547 540 struct c4iw_rdev *rdev; 548 - u64 ugts; 549 541 size_t memsize; 550 542 __be64 bits_type_ts; 551 543 u32 cqid; ··· 564 552 unsigned long flags; 565 553 }; 566 554 555 + static inline void write_gts(struct t4_cq *cq, u32 val) 556 + { 557 + if (cq->bar2_va) 558 + writel(val | INGRESSQID_V(cq->bar2_qid), 559 + cq->bar2_va + SGE_UDB_GTS); 560 + else 561 + writel(val | INGRESSQID_V(cq->cqid), cq->gts); 562 + } 563 + 567 564 static inline int t4_clear_cq_armed(struct t4_cq *cq) 568 565 { 569 566 return test_and_clear_bit(CQ_ARMED, &cq->flags); ··· 584 563 585 564 set_bit(CQ_ARMED, &cq->flags); 586 565 while (cq->cidx_inc > CIDXINC_M) { 587 - val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7) | 588 - INGRESSQID_V(cq->cqid & cq->qid_mask); 589 - writel(val, cq->gts); 566 + val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7); 567 + write_gts(cq, val); 590 568 cq->cidx_inc -= CIDXINC_M; 591 569 } 592 - val = SEINTARM_V(se) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(6) | 593 - INGRESSQID_V(cq->cqid & cq->qid_mask); 594 - writel(val, cq->gts); 570 + val = SEINTARM_V(se) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(6); 571 + write_gts(cq, val); 595 572 cq->cidx_inc = 0; 596 573 return 0; 597 574 } ··· 620 601 if (++cq->cidx_inc == (cq->size >> 4) || cq->cidx_inc == CIDXINC_M) { 621 602 u32 val; 622 603 623 - val = SEINTARM_V(0) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(7) | 624 - INGRESSQID_V(cq->cqid & cq->qid_mask); 625 - writel(val, cq->gts); 604 + val = SEINTARM_V(0) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(7); 605 + write_gts(cq, val); 626 606 cq->cidx_inc = 0; 627 607 } 628 608 if (++cq->cidx == cq->size) {
+6 -1
drivers/infiniband/hw/ehca/ehca_cq.c
··· 113 113 return ret; 114 114 } 115 115 116 - struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector, 116 + struct ib_cq *ehca_create_cq(struct ib_device *device, 117 + const struct ib_cq_init_attr *attr, 117 118 struct ib_ucontext *context, 118 119 struct ib_udata *udata) 119 120 { 121 + int cqe = attr->cqe; 120 122 static const u32 additional_cqe = 20; 121 123 struct ib_cq *cq; 122 124 struct ehca_cq *my_cq; ··· 132 130 u64 rpage, cqx_fec, h_ret; 133 131 int ipz_rc, i; 134 132 unsigned long flags; 133 + 134 + if (attr->flags) 135 + return ERR_PTR(-EINVAL); 135 136 136 137 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) 137 138 return ERR_PTR(-EINVAL);
+5 -1
drivers/infiniband/hw/ehca/ehca_hca.c
··· 50 50 return min_t(unsigned int, value, INT_MAX); 51 51 } 52 52 53 - int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) 53 + int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 54 + struct ib_udata *uhw) 54 55 { 55 56 int i, ret = 0; 56 57 struct ehca_shca *shca = container_of(ibdev, struct ehca_shca, ··· 71 70 IB_DEVICE_INIT_TYPE, HCA_CAP_INIT_TYPE, 72 71 IB_DEVICE_PORT_ACTIVE_EVENT, HCA_CAP_PORT_ACTIVE_EVENT, 73 72 }; 73 + 74 + if (uhw->inlen || uhw->outlen) 75 + return -EINVAL; 74 76 75 77 rblock = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 76 78 if (!rblock) {
+11 -5
drivers/infiniband/hw/ehca/ehca_iverbs.h
··· 44 44 45 45 #include "ehca_classes.h" 46 46 47 - int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props); 47 + int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 48 + struct ib_udata *uhw); 48 49 49 50 int ehca_query_port(struct ib_device *ibdev, u8 port, 50 51 struct ib_port_attr *props); 52 + 53 + enum rdma_protocol_type 54 + ehca_query_protocol(struct ib_device *device, u8 port_num); 51 55 52 56 int ehca_query_sma_attr(struct ehca_shca *shca, u8 port, 53 57 struct ehca_sma_attr *attr); ··· 130 126 void *ehca_poll_eq(struct ehca_shca *shca, struct ehca_eq *eq); 131 127 132 128 133 - struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector, 129 + struct ib_cq *ehca_create_cq(struct ib_device *device, 130 + const struct ib_cq_init_attr *attr, 134 131 struct ib_ucontext *context, 135 132 struct ib_udata *udata); 136 133 ··· 193 188 int ehca_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); 194 189 195 190 int ehca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 196 - struct ib_wc *in_wc, struct ib_grh *in_grh, 197 - struct ib_mad *in_mad, 198 - struct ib_mad *out_mad); 191 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 192 + const struct ib_mad_hdr *in, size_t in_mad_size, 193 + struct ib_mad_hdr *out, size_t *out_mad_size, 194 + u16 *out_mad_pkey_index); 199 195 200 196 void ehca_poll_eqs(unsigned long data); 201 197
+24 -1
drivers/infiniband/hw/ehca/ehca_main.c
··· 46 46 47 47 #include <linux/notifier.h> 48 48 #include <linux/memory.h> 49 + #include <rdma/ib_mad.h> 49 50 #include "ehca_classes.h" 50 51 #include "ehca_iverbs.h" 51 52 #include "ehca_mrmw.h" ··· 432 431 return ret; 433 432 } 434 433 434 + static int ehca_port_immutable(struct ib_device *ibdev, u8 port_num, 435 + struct ib_port_immutable *immutable) 436 + { 437 + struct ib_port_attr attr; 438 + int err; 439 + 440 + err = ehca_query_port(ibdev, port_num, &attr); 441 + if (err) 442 + return err; 443 + 444 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 445 + immutable->gid_tbl_len = attr.gid_tbl_len; 446 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB; 447 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 448 + 449 + return 0; 450 + } 451 + 435 452 static int ehca_init_device(struct ehca_shca *shca) 436 453 { 437 454 int ret; ··· 529 510 shca->ib_device.process_mad = ehca_process_mad; 530 511 shca->ib_device.mmap = ehca_mmap; 531 512 shca->ib_device.dma_ops = &ehca_dma_mapping_ops; 513 + shca->ib_device.get_port_immutable = ehca_port_immutable; 532 514 533 515 if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { 534 516 shca->ib_device.uverbs_cmd_mask |= ··· 554 534 struct ib_cq *ibcq; 555 535 struct ib_qp *ibqp; 556 536 struct ib_qp_init_attr qp_init_attr; 537 + struct ib_cq_init_attr cq_attr = {}; 557 538 int ret; 558 539 559 540 if (sport->ibcq_aqp1) { ··· 562 541 return -EPERM; 563 542 } 564 543 565 - ibcq = ib_create_cq(&shca->ib_device, NULL, NULL, (void *)(-1), 10, 0); 544 + cq_attr.cqe = 10; 545 + ibcq = ib_create_cq(&shca->ib_device, NULL, NULL, (void *)(-1), 546 + &cq_attr); 566 547 if (IS_ERR(ibcq)) { 567 548 ehca_err(&shca->ib_device, "Cannot create AQP1 CQ."); 568 549 return PTR_ERR(ibcq);
+14 -7
drivers/infiniband/hw/ehca/ehca_sqp.c
··· 140 140 } __attribute__ ((packed)); 141 141 142 142 static int ehca_process_perf(struct ib_device *ibdev, u8 port_num, 143 - struct ib_wc *in_wc, struct ib_grh *in_grh, 144 - struct ib_mad *in_mad, struct ib_mad *out_mad) 143 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 144 + const struct ib_mad *in_mad, struct ib_mad *out_mad) 145 145 { 146 - struct ib_perf *in_perf = (struct ib_perf *)in_mad; 146 + const struct ib_perf *in_perf = (const struct ib_perf *)in_mad; 147 147 struct ib_perf *out_perf = (struct ib_perf *)out_mad; 148 148 struct ib_class_port_info *poi = 149 149 (struct ib_class_port_info *)out_perf->data; ··· 187 187 188 188 /* if request was globally routed, copy route info */ 189 189 if (in_grh) { 190 - struct vertcfl *vertcfl = 191 - (struct vertcfl *)&in_grh->version_tclass_flow; 190 + const struct vertcfl *vertcfl = 191 + (const struct vertcfl *)&in_grh->version_tclass_flow; 192 192 memcpy(poi->redirect_gid, in_grh->dgid.raw, 193 193 sizeof(poi->redirect_gid)); 194 194 tcslfl->tc = vertcfl->tc; ··· 217 217 } 218 218 219 219 int ehca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 220 - struct ib_wc *in_wc, struct ib_grh *in_grh, 221 - struct ib_mad *in_mad, struct ib_mad *out_mad) 220 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 221 + const struct ib_mad_hdr *in, size_t in_mad_size, 222 + struct ib_mad_hdr *out, size_t *out_mad_size, 223 + u16 *out_mad_pkey_index) 222 224 { 223 225 int ret; 226 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 227 + struct ib_mad *out_mad = (struct ib_mad *)out; 228 + 229 + BUG_ON(in_mad_size != sizeof(*in_mad) || 230 + *out_mad_size != sizeof(*out_mad)); 224 231 225 232 if (!port_num || port_num > ibdev->phys_port_cnt || !in_wc) 226 233 return IB_MAD_RESULT_FAILURE;
+7 -2
drivers/infiniband/hw/ipath/ipath_cq.c
··· 188 188 /** 189 189 * ipath_create_cq - create a completion queue 190 190 * @ibdev: the device this completion queue is attached to 191 - * @entries: the minimum size of the completion queue 191 + * @attr: creation attributes 192 192 * @context: unused by the InfiniPath driver 193 193 * @udata: unused by the InfiniPath driver 194 194 * ··· 197 197 * 198 198 * Called by ib_create_cq() in the generic verbs code. 199 199 */ 200 - struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries, int comp_vector, 200 + struct ib_cq *ipath_create_cq(struct ib_device *ibdev, 201 + const struct ib_cq_init_attr *attr, 201 202 struct ib_ucontext *context, 202 203 struct ib_udata *udata) 203 204 { 205 + int entries = attr->cqe; 204 206 struct ipath_ibdev *dev = to_idev(ibdev); 205 207 struct ipath_cq *cq; 206 208 struct ipath_cq_wc *wc; 207 209 struct ib_cq *ret; 208 210 u32 sz; 211 + 212 + if (attr->flags) 213 + return ERR_PTR(-EINVAL); 209 214 210 215 if (entries < 1 || entries > ib_ipath_max_cqes) { 211 216 ret = ERR_PTR(-EINVAL);
+11 -4
drivers/infiniband/hw/ipath/ipath_mad.c
··· 1257 1257 } 1258 1258 1259 1259 static int process_subn(struct ib_device *ibdev, int mad_flags, 1260 - u8 port_num, struct ib_mad *in_mad, 1260 + u8 port_num, const struct ib_mad *in_mad, 1261 1261 struct ib_mad *out_mad) 1262 1262 { 1263 1263 struct ib_smp *smp = (struct ib_smp *)out_mad; ··· 1389 1389 } 1390 1390 1391 1391 static int process_perf(struct ib_device *ibdev, u8 port_num, 1392 - struct ib_mad *in_mad, 1392 + const struct ib_mad *in_mad, 1393 1393 struct ib_mad *out_mad) 1394 1394 { 1395 1395 struct ib_pma_mad *pmp = (struct ib_pma_mad *)out_mad; ··· 1490 1490 * This is called by the ib_mad module. 1491 1491 */ 1492 1492 int ipath_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 1493 - struct ib_wc *in_wc, struct ib_grh *in_grh, 1494 - struct ib_mad *in_mad, struct ib_mad *out_mad) 1493 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 1494 + const struct ib_mad_hdr *in, size_t in_mad_size, 1495 + struct ib_mad_hdr *out, size_t *out_mad_size, 1496 + u16 *out_mad_pkey_index) 1495 1497 { 1496 1498 int ret; 1499 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 1500 + struct ib_mad *out_mad = (struct ib_mad *)out; 1501 + 1502 + BUG_ON(in_mad_size != sizeof(*in_mad) || 1503 + *out_mad_size != sizeof(*out_mad)); 1497 1504 1498 1505 switch (in_mad->mad_hdr.mgmt_class) { 1499 1506 case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
+24 -2
drivers/infiniband/hw/ipath/ipath_verbs.c
··· 1495 1495 return 0; 1496 1496 } 1497 1497 1498 - static int ipath_query_device(struct ib_device *ibdev, 1499 - struct ib_device_attr *props) 1498 + static int ipath_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 1499 + struct ib_udata *uhw) 1500 1500 { 1501 1501 struct ipath_ibdev *dev = to_idev(ibdev); 1502 + 1503 + if (uhw->inlen || uhw->outlen) 1504 + return -EINVAL; 1502 1505 1503 1506 memset(props, 0, sizeof(*props)); 1504 1507 ··· 1983 1980 return 0; 1984 1981 } 1985 1982 1983 + static int ipath_port_immutable(struct ib_device *ibdev, u8 port_num, 1984 + struct ib_port_immutable *immutable) 1985 + { 1986 + struct ib_port_attr attr; 1987 + int err; 1988 + 1989 + err = ipath_query_port(ibdev, port_num, &attr); 1990 + if (err) 1991 + return err; 1992 + 1993 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 1994 + immutable->gid_tbl_len = attr.gid_tbl_len; 1995 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB; 1996 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 1997 + 1998 + return 0; 1999 + } 2000 + 1986 2001 /** 1987 2002 * ipath_register_ib_device - register our device with the infiniband core 1988 2003 * @dd: the device data structure ··· 2200 2179 dev->process_mad = ipath_process_mad; 2201 2180 dev->mmap = ipath_mmap; 2202 2181 dev->dma_ops = &ipath_dma_mapping_ops; 2182 + dev->get_port_immutable = ipath_port_immutable; 2203 2183 2204 2184 snprintf(dev->node_desc, sizeof(dev->node_desc), 2205 2185 IPATH_IDSTR " %s", init_utsname()->nodename);
+7 -4
drivers/infiniband/hw/ipath/ipath_verbs.h
··· 701 701 int ipath_process_mad(struct ib_device *ibdev, 702 702 int mad_flags, 703 703 u8 port_num, 704 - struct ib_wc *in_wc, 705 - struct ib_grh *in_grh, 706 - struct ib_mad *in_mad, struct ib_mad *out_mad); 704 + const struct ib_wc *in_wc, 705 + const struct ib_grh *in_grh, 706 + const struct ib_mad_hdr *in, size_t in_mad_size, 707 + struct ib_mad_hdr *out, size_t *out_mad_size, 708 + u16 *out_mad_pkey_index); 707 709 708 710 /* 709 711 * Compare the lower 24 bits of the two values. ··· 809 807 810 808 int ipath_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry); 811 809 812 - struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries, int comp_vector, 810 + struct ib_cq *ipath_create_cq(struct ib_device *ibdev, 811 + const struct ib_cq_init_attr *attr, 813 812 struct ib_ucontext *context, 814 813 struct ib_udata *udata); 815 814
+11 -2
drivers/infiniband/hw/mlx4/cq.c
··· 166 166 return err; 167 167 } 168 168 169 - struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector, 169 + #define CQ_CREATE_FLAGS_SUPPORTED IB_CQ_FLAGS_TIMESTAMP_COMPLETION 170 + struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, 171 + const struct ib_cq_init_attr *attr, 170 172 struct ib_ucontext *context, 171 173 struct ib_udata *udata) 172 174 { 175 + int entries = attr->cqe; 176 + int vector = attr->comp_vector; 173 177 struct mlx4_ib_dev *dev = to_mdev(ibdev); 174 178 struct mlx4_ib_cq *cq; 175 179 struct mlx4_uar *uar; 176 180 int err; 177 181 178 182 if (entries < 1 || entries > dev->dev->caps.max_cqes) 183 + return ERR_PTR(-EINVAL); 184 + 185 + if (attr->flags & ~CQ_CREATE_FLAGS_SUPPORTED) 179 186 return ERR_PTR(-EINVAL); 180 187 181 188 cq = kmalloc(sizeof *cq, GFP_KERNEL); ··· 195 188 spin_lock_init(&cq->lock); 196 189 cq->resize_buf = NULL; 197 190 cq->resize_umem = NULL; 191 + cq->create_flags = attr->flags; 198 192 INIT_LIST_HEAD(&cq->send_qp_list); 199 193 INIT_LIST_HEAD(&cq->recv_qp_list); 200 194 ··· 239 231 vector = dev->eq_table[vector % ibdev->num_comp_vectors]; 240 232 241 233 err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar, 242 - cq->db.dma, &cq->mcq, vector, 0, 0); 234 + cq->db.dma, &cq->mcq, vector, 0, 235 + !!(cq->create_flags & IB_CQ_FLAGS_TIMESTAMP_COMPLETION)); 243 236 if (err) 244 237 goto err_dbmap; 245 238
+24 -12
drivers/infiniband/hw/mlx4/mad.c
··· 111 111 } 112 112 113 113 int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags, 114 - int port, struct ib_wc *in_wc, struct ib_grh *in_grh, 115 - void *in_mad, void *response_mad) 114 + int port, const struct ib_wc *in_wc, 115 + const struct ib_grh *in_grh, 116 + const void *in_mad, void *response_mad) 116 117 { 117 118 struct mlx4_cmd_mailbox *inmailbox, *outmailbox; 118 119 void *inbox; ··· 221 220 * Snoop SM MADs for port info, GUID info, and P_Key table sets, so we can 222 221 * synthesize LID change, Client-Rereg, GID change, and P_Key change events. 223 222 */ 224 - static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad, 223 + static void smp_snoop(struct ib_device *ibdev, u8 port_num, const struct ib_mad *mad, 225 224 u16 prev_lid) 226 225 { 227 226 struct ib_port_info *pinfo; ··· 357 356 } 358 357 } 359 358 360 - static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, struct ib_mad *mad) 359 + static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_mad *mad) 361 360 { 362 361 int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED; 363 362 struct ib_mad_send_buf *send_buf; ··· 367 366 368 367 if (agent) { 369 368 send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR, 370 - IB_MGMT_MAD_DATA, GFP_ATOMIC); 369 + IB_MGMT_MAD_DATA, GFP_ATOMIC, 370 + IB_MGMT_BASE_VERSION); 371 371 if (IS_ERR(send_buf)) 372 372 return; 373 373 /* ··· 724 722 } 725 723 726 724 static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 727 - struct ib_wc *in_wc, struct ib_grh *in_grh, 728 - struct ib_mad *in_mad, struct ib_mad *out_mad) 725 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 726 + const struct ib_mad *in_mad, struct ib_mad *out_mad) 729 727 { 730 728 u16 slid, prev_lid = 0; 731 729 int err; ··· 827 825 } 828 826 829 827 static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 830 - struct ib_wc *in_wc, struct ib_grh *in_grh, 831 - struct ib_mad *in_mad, struct ib_mad *out_mad) 828 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 829 + const struct ib_mad *in_mad, struct ib_mad *out_mad) 832 830 { 833 831 struct mlx4_cmd_mailbox *mailbox; 834 832 struct mlx4_ib_dev *dev = to_mdev(ibdev); ··· 868 866 } 869 867 870 868 int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 871 - struct ib_wc *in_wc, struct ib_grh *in_grh, 872 - struct ib_mad *in_mad, struct ib_mad *out_mad) 869 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 870 + const struct ib_mad_hdr *in, size_t in_mad_size, 871 + struct ib_mad_hdr *out, size_t *out_mad_size, 872 + u16 *out_mad_pkey_index) 873 873 { 874 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 875 + struct ib_mad *out_mad = (struct ib_mad *)out; 876 + 877 + BUG_ON(in_mad_size != sizeof(*in_mad) || 878 + *out_mad_size != sizeof(*out_mad)); 879 + 874 880 switch (rdma_port_get_link_layer(ibdev, port_num)) { 875 881 case IB_LINK_LAYER_INFINIBAND: 876 882 return ib_process_mad(ibdev, mad_flags, port_num, in_wc, ··· 1783 1773 int create_tun, struct mlx4_ib_demux_pv_ctx *ctx) 1784 1774 { 1785 1775 int ret, cq_size; 1776 + struct ib_cq_init_attr cq_attr = {}; 1786 1777 1787 1778 if (ctx->state != DEMUX_PV_STATE_DOWN) 1788 1779 return -EEXIST; ··· 1812 1801 if (ctx->has_smi) 1813 1802 cq_size *= 2; 1814 1803 1804 + cq_attr.cqe = cq_size; 1815 1805 ctx->cq = ib_create_cq(ctx->ib_dev, mlx4_ib_tunnel_comp_handler, 1816 - NULL, ctx, cq_size, 0); 1806 + NULL, ctx, &cq_attr); 1817 1807 if (IS_ERR(ctx->cq)) { 1818 1808 ret = PTR_ERR(ctx->cq); 1819 1809 pr_err("Couldn't create tunnel CQ (%d)\n", ret);
+90 -5
drivers/infiniband/hw/mlx4/main.c
··· 132 132 } 133 133 134 134 static int mlx4_ib_query_device(struct ib_device *ibdev, 135 - struct ib_device_attr *props) 135 + struct ib_device_attr *props, 136 + struct ib_udata *uhw) 136 137 { 137 138 struct mlx4_ib_dev *dev = to_mdev(ibdev); 138 139 struct ib_smp *in_mad = NULL; 139 140 struct ib_smp *out_mad = NULL; 140 141 int err = -ENOMEM; 141 142 int have_ib_ports; 143 + struct mlx4_uverbs_ex_query_device cmd; 144 + struct mlx4_uverbs_ex_query_device_resp resp = {.comp_mask = 0}; 145 + struct mlx4_clock_params clock_params; 142 146 147 + if (uhw->inlen) { 148 + if (uhw->inlen < sizeof(cmd)) 149 + return -EINVAL; 150 + 151 + err = ib_copy_from_udata(&cmd, uhw, sizeof(cmd)); 152 + if (err) 153 + return err; 154 + 155 + if (cmd.comp_mask) 156 + return -EINVAL; 157 + 158 + if (cmd.reserved) 159 + return -EINVAL; 160 + } 161 + 162 + resp.response_length = offsetof(typeof(resp), response_length) + 163 + sizeof(resp.response_length); 143 164 in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); 144 165 out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); 145 166 if (!in_mad || !out_mad) ··· 250 229 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * 251 230 props->max_mcast_grp; 252 231 props->max_map_per_fmr = dev->dev->caps.max_fmr_maps; 232 + props->hca_core_clock = dev->dev->caps.hca_core_clock * 1000UL; 233 + props->timestamp_mask = 0xFFFFFFFFFFFFULL; 253 234 235 + err = mlx4_get_internal_clock_params(dev->dev, &clock_params); 236 + if (err) 237 + goto out; 238 + 239 + if (uhw->outlen >= resp.response_length + sizeof(resp.hca_core_clock_offset)) { 240 + resp.hca_core_clock_offset = clock_params.offset % PAGE_SIZE; 241 + resp.response_length += sizeof(resp.hca_core_clock_offset); 242 + resp.comp_mask |= QUERY_DEVICE_RESP_MASK_TIMESTAMP; 243 + } 244 + 245 + if (uhw->outlen) { 246 + err = ib_copy_to_udata(uhw, &resp, resp.response_length); 247 + if (err) 248 + goto out; 249 + } 254 250 out: 255 251 kfree(in_mad); 256 252 kfree(out_mad); ··· 750 712 dev->dev->caps.num_uars, 751 713 PAGE_SIZE, vma->vm_page_prot)) 752 714 return -EAGAIN; 753 - } else 715 + } else if (vma->vm_pgoff == 3) { 716 + struct mlx4_clock_params params; 717 + int ret = mlx4_get_internal_clock_params(dev->dev, &params); 718 + 719 + if (ret) 720 + return ret; 721 + 722 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 723 + if (io_remap_pfn_range(vma, vma->vm_start, 724 + (pci_resource_start(dev->dev->persist->pdev, 725 + params.bar) + 726 + params.offset) 727 + >> PAGE_SHIFT, 728 + PAGE_SIZE, vma->vm_page_prot)) 729 + return -EAGAIN; 730 + } else { 754 731 return -EINVAL; 732 + } 755 733 756 734 return 0; 757 735 } ··· 812 758 struct ib_udata *udata) 813 759 { 814 760 struct mlx4_ib_xrcd *xrcd; 761 + struct ib_cq_init_attr cq_attr = {}; 815 762 int err; 816 763 817 764 if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC)) ··· 832 777 goto err2; 833 778 } 834 779 835 - xrcd->cq = ib_create_cq(ibdev, NULL, NULL, xrcd, 1, 0); 780 + cq_attr.cqe = 1; 781 + xrcd->cq = ib_create_cq(ibdev, NULL, NULL, xrcd, &cq_attr); 836 782 if (IS_ERR(xrcd->cq)) { 837 783 err = PTR_ERR(xrcd->cq); 838 784 goto err3; ··· 1241 1185 &mflow->reg_id[i].id); 1242 1186 if (err) 1243 1187 goto err_create_flow; 1244 - i++; 1245 1188 if (is_bonded) { 1246 1189 /* Application always sees one port so the mirror rule 1247 1190 * must be on port #2 ··· 1255 1200 j++; 1256 1201 } 1257 1202 1203 + i++; 1258 1204 } 1259 1205 1260 1206 if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) { ··· 1263 1207 &mflow->reg_id[i].id); 1264 1208 if (err) 1265 1209 goto err_create_flow; 1266 - i++; 1210 + 1267 1211 if (is_bonded) { 1268 1212 flow_attr->port = 2; 1269 1213 err = mlx4_ib_tunnel_steer_add(qp, flow_attr, ··· 1274 1218 j++; 1275 1219 } 1276 1220 /* function to create mirror rule */ 1221 + i++; 1277 1222 } 1278 1223 1279 1224 return &mflow->ibflow; ··· 2171 2114 kfree(ibdev->eq_table); 2172 2115 } 2173 2116 2117 + static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num, 2118 + struct ib_port_immutable *immutable) 2119 + { 2120 + struct ib_port_attr attr; 2121 + int err; 2122 + 2123 + err = mlx4_ib_query_port(ibdev, port_num, &attr); 2124 + if (err) 2125 + return err; 2126 + 2127 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 2128 + immutable->gid_tbl_len = attr.gid_tbl_len; 2129 + 2130 + if (mlx4_ib_port_link_layer(ibdev, port_num) == IB_LINK_LAYER_INFINIBAND) 2131 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB; 2132 + else 2133 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE; 2134 + 2135 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 2136 + 2137 + return 0; 2138 + } 2139 + 2174 2140 static void *mlx4_ib_add(struct mlx4_dev *dev) 2175 2141 { 2176 2142 struct mlx4_ib_dev *ibdev; ··· 2321 2241 ibdev->ib_dev.attach_mcast = mlx4_ib_mcg_attach; 2322 2242 ibdev->ib_dev.detach_mcast = mlx4_ib_mcg_detach; 2323 2243 ibdev->ib_dev.process_mad = mlx4_ib_process_mad; 2244 + ibdev->ib_dev.get_port_immutable = mlx4_port_immutable; 2324 2245 2325 2246 if (!mlx4_is_slave(ibdev->dev)) { 2326 2247 ibdev->ib_dev.alloc_fmr = mlx4_ib_fmr_alloc; ··· 2358 2277 (1ull << IB_USER_VERBS_EX_CMD_CREATE_FLOW) | 2359 2278 (1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW); 2360 2279 } 2280 + 2281 + ibdev->ib_dev.uverbs_ex_cmd_mask |= 2282 + (1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE) | 2283 + (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ); 2361 2284 2362 2285 mlx4_ib_alloc_eqs(dev, ibdev); 2363 2286
+24 -5
drivers/infiniband/hw/mlx4/mlx4_ib.h
··· 110 110 struct mutex resize_mutex; 111 111 struct ib_umem *umem; 112 112 struct ib_umem *resize_umem; 113 + int create_flags; 113 114 /* List of qps that it serves.*/ 114 115 struct list_head send_qp_list; 115 116 struct list_head recv_qp_list; ··· 556 555 u8 port; 557 556 }; 558 557 558 + struct mlx4_uverbs_ex_query_device { 559 + __u32 comp_mask; 560 + __u32 reserved; 561 + }; 562 + 563 + enum query_device_resp_mask { 564 + QUERY_DEVICE_RESP_MASK_TIMESTAMP = 1UL << 0, 565 + }; 566 + 567 + struct mlx4_uverbs_ex_query_device_resp { 568 + __u32 comp_mask; 569 + __u32 response_length; 570 + __u64 hca_core_clock_offset; 571 + }; 572 + 559 573 static inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev) 560 574 { 561 575 return container_of(ibdev, struct mlx4_ib_dev, ib_dev); ··· 684 668 685 669 int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); 686 670 int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); 687 - struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector, 671 + struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, 672 + const struct ib_cq_init_attr *attr, 688 673 struct ib_ucontext *context, 689 674 struct ib_udata *udata); 690 675 int mlx4_ib_destroy_cq(struct ib_cq *cq); ··· 723 706 struct ib_recv_wr **bad_wr); 724 707 725 708 int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags, 726 - int port, struct ib_wc *in_wc, struct ib_grh *in_grh, 727 - void *in_mad, void *response_mad); 709 + int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh, 710 + const void *in_mad, void *response_mad); 728 711 int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 729 - struct ib_wc *in_wc, struct ib_grh *in_grh, 730 - struct ib_mad *in_mad, struct ib_mad *out_mad); 712 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 713 + const struct ib_mad_hdr *in, size_t in_mad_size, 714 + struct ib_mad_hdr *out, size_t *out_mad_size, 715 + u16 *out_mad_pkey_index); 731 716 int mlx4_ib_mad_init(struct mlx4_ib_dev *dev); 732 717 void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev); 733 718
+8 -2
drivers/infiniband/hw/mlx5/cq.c
··· 736 736 mlx5_db_free(dev->mdev, &cq->db); 737 737 } 738 738 739 - struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries, 740 - int vector, struct ib_ucontext *context, 739 + struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, 740 + const struct ib_cq_init_attr *attr, 741 + struct ib_ucontext *context, 741 742 struct ib_udata *udata) 742 743 { 744 + int entries = attr->cqe; 745 + int vector = attr->comp_vector; 743 746 struct mlx5_create_cq_mbox_in *cqb = NULL; 744 747 struct mlx5_ib_dev *dev = to_mdev(ibdev); 745 748 struct mlx5_ib_cq *cq; ··· 752 749 int irqn; 753 750 int eqn; 754 751 int err; 752 + 753 + if (attr->flags) 754 + return ERR_PTR(-EINVAL); 755 755 756 756 if (entries < 0) 757 757 return ERR_PTR(-EINVAL);
+11 -4
drivers/infiniband/hw/mlx5/mad.c
··· 41 41 }; 42 42 43 43 int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey, 44 - u8 port, struct ib_wc *in_wc, struct ib_grh *in_grh, 45 - void *in_mad, void *response_mad) 44 + u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh, 45 + const void *in_mad, void *response_mad) 46 46 { 47 47 u8 op_modifier = 0; 48 48 ··· 58 58 } 59 59 60 60 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 61 - struct ib_wc *in_wc, struct ib_grh *in_grh, 62 - struct ib_mad *in_mad, struct ib_mad *out_mad) 61 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 62 + const struct ib_mad_hdr *in, size_t in_mad_size, 63 + struct ib_mad_hdr *out, size_t *out_mad_size, 64 + u16 *out_mad_pkey_index) 63 65 { 64 66 u16 slid; 65 67 int err; 68 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 69 + struct ib_mad *out_mad = (struct ib_mad *)out; 70 + 71 + BUG_ON(in_mad_size != sizeof(*in_mad) || 72 + *out_mad_size != sizeof(*out_mad)); 66 73 67 74 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE); 68 75
+32 -5
drivers/infiniband/hw/mlx5/main.c
··· 63 63 DRIVER_VERSION " (" DRIVER_RELDATE ")\n"; 64 64 65 65 static int mlx5_ib_query_device(struct ib_device *ibdev, 66 - struct ib_device_attr *props) 66 + struct ib_device_attr *props, 67 + struct ib_udata *uhw) 67 68 { 68 69 struct mlx5_ib_dev *dev = to_mdev(ibdev); 69 70 struct ib_smp *in_mad = NULL; ··· 74 73 int max_rq_sg; 75 74 int max_sq_sg; 76 75 u64 flags; 76 + 77 + if (uhw->inlen || uhw->outlen) 78 + return -EINVAL; 77 79 78 80 gen = &dev->mdev->caps.gen; 79 81 in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); ··· 914 910 struct mlx5_general_caps *gen; 915 911 int err = -ENOMEM; 916 912 int port; 913 + struct ib_udata uhw = {.inlen = 0, .outlen = 0}; 917 914 918 915 gen = &dev->mdev->caps.gen; 919 916 pprops = kmalloc(sizeof(*pprops), GFP_KERNEL); ··· 925 920 if (!dprops) 926 921 goto out; 927 922 928 - err = mlx5_ib_query_device(&dev->ib_dev, dprops); 923 + err = mlx5_ib_query_device(&dev->ib_dev, dprops, &uhw); 929 924 if (err) { 930 925 mlx5_ib_warn(dev, "query_device failed %d\n", err); 931 926 goto out; ··· 976 971 struct ib_cq *cq; 977 972 struct ib_qp *qp; 978 973 struct ib_mr *mr; 974 + struct ib_cq_init_attr cq_attr = {}; 979 975 int ret; 980 976 981 977 attr = kzalloc(sizeof(*attr), GFP_KERNEL); ··· 1000 994 goto error_1; 1001 995 } 1002 996 1003 - cq = ib_create_cq(&dev->ib_dev, mlx5_umr_cq_handler, NULL, NULL, 128, 1004 - 0); 997 + cq_attr.cqe = 128; 998 + cq = ib_create_cq(&dev->ib_dev, mlx5_umr_cq_handler, NULL, NULL, 999 + &cq_attr); 1005 1000 if (IS_ERR(cq)) { 1006 1001 mlx5_ib_dbg(dev, "Couldn't create CQ for sync UMR QP\n"); 1007 1002 ret = PTR_ERR(cq); ··· 1094 1087 { 1095 1088 struct ib_srq_init_attr attr; 1096 1089 struct mlx5_ib_dev *dev; 1090 + struct ib_cq_init_attr cq_attr = {.cqe = 1}; 1097 1091 int ret = 0; 1098 1092 1099 1093 dev = container_of(devr, struct mlx5_ib_dev, devr); ··· 1108 1100 devr->p0->uobject = NULL; 1109 1101 atomic_set(&devr->p0->usecnt, 0); 1110 1102 1111 - devr->c0 = mlx5_ib_create_cq(&dev->ib_dev, 1, 0, NULL, NULL); 1103 + devr->c0 = mlx5_ib_create_cq(&dev->ib_dev, &cq_attr, NULL, NULL); 1112 1104 if (IS_ERR(devr->c0)) { 1113 1105 ret = PTR_ERR(devr->c0); 1114 1106 goto error1; ··· 1188 1180 mlx5_ib_dealloc_xrcd(devr->x1); 1189 1181 mlx5_ib_destroy_cq(devr->c0); 1190 1182 mlx5_ib_dealloc_pd(devr->p0); 1183 + } 1184 + 1185 + static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num, 1186 + struct ib_port_immutable *immutable) 1187 + { 1188 + struct ib_port_attr attr; 1189 + int err; 1190 + 1191 + err = mlx5_ib_query_port(ibdev, port_num, &attr); 1192 + if (err) 1193 + return err; 1194 + 1195 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 1196 + immutable->gid_tbl_len = attr.gid_tbl_len; 1197 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB; 1198 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 1199 + 1200 + return 0; 1191 1201 } 1192 1202 1193 1203 static void *mlx5_ib_add(struct mlx5_core_dev *mdev) ··· 1311 1285 dev->ib_dev.alloc_fast_reg_page_list = mlx5_ib_alloc_fast_reg_page_list; 1312 1286 dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; 1313 1287 dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; 1288 + dev->ib_dev.get_port_immutable = mlx5_port_immutable; 1314 1289 1315 1290 mlx5_ib_internal_query_odp_caps(dev); 1316 1291
+9 -6
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 525 525 void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); 526 526 void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index); 527 527 int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey, 528 - u8 port, struct ib_wc *in_wc, struct ib_grh *in_grh, 529 - void *in_mad, void *response_mad); 528 + u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh, 529 + const void *in_mad, void *response_mad); 530 530 struct ib_ah *create_ib_ah(struct ib_ah_attr *ah_attr, 531 531 struct mlx5_ib_ah *ah); 532 532 struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); ··· 556 556 void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n); 557 557 int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index, 558 558 void *buffer, u32 length); 559 - struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries, 560 - int vector, struct ib_ucontext *context, 559 + struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, 560 + const struct ib_cq_init_attr *attr, 561 + struct ib_ucontext *context, 561 562 struct ib_udata *udata); 562 563 int mlx5_ib_destroy_cq(struct ib_cq *cq); 563 564 int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); ··· 587 586 int mlx5_ib_unmap_fmr(struct list_head *fmr_list); 588 587 int mlx5_ib_fmr_dealloc(struct ib_fmr *ibfmr); 589 588 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 590 - struct ib_wc *in_wc, struct ib_grh *in_grh, 591 - struct ib_mad *in_mad, struct ib_mad *out_mad); 589 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 590 + const struct ib_mad_hdr *in, size_t in_mad_size, 591 + struct ib_mad_hdr *out, size_t *out_mad_size, 592 + u16 *out_mad_pkey_index); 592 593 struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, 593 594 struct ib_ucontext *context, 594 595 struct ib_udata *udata);
+2 -2
drivers/infiniband/hw/mthca/mthca_cmd.c
··· 1858 1858 } 1859 1859 1860 1860 int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey, 1861 - int port, struct ib_wc *in_wc, struct ib_grh *in_grh, 1862 - void *in_mad, void *response_mad) 1861 + int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh, 1862 + const void *in_mad, void *response_mad) 1863 1863 { 1864 1864 struct mthca_mailbox *inmailbox, *outmailbox; 1865 1865 void *inbox;
+2 -2
drivers/infiniband/hw/mthca/mthca_cmd.h
··· 312 312 struct mthca_mailbox *mailbox); 313 313 int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn); 314 314 int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey, 315 - int port, struct ib_wc *in_wc, struct ib_grh *in_grh, 316 - void *in_mad, void *response_mad); 315 + int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh, 316 + const void *in_mad, void *response_mad); 317 317 int mthca_READ_MGM(struct mthca_dev *dev, int index, 318 318 struct mthca_mailbox *mailbox); 319 319 int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
+5 -4
drivers/infiniband/hw/mthca/mthca_dev.h
··· 576 576 int mthca_process_mad(struct ib_device *ibdev, 577 577 int mad_flags, 578 578 u8 port_num, 579 - struct ib_wc *in_wc, 580 - struct ib_grh *in_grh, 581 - struct ib_mad *in_mad, 582 - struct ib_mad *out_mad); 579 + const struct ib_wc *in_wc, 580 + const struct ib_grh *in_grh, 581 + const struct ib_mad_hdr *in, size_t in_mad_size, 582 + struct ib_mad_hdr *out, size_t *out_mad_size, 583 + u16 *out_mad_pkey_index); 583 584 int mthca_create_agents(struct mthca_dev *dev); 584 585 void mthca_free_agents(struct mthca_dev *dev); 585 586
+14 -7
drivers/infiniband/hw/mthca/mthca_mad.c
··· 104 104 */ 105 105 static void smp_snoop(struct ib_device *ibdev, 106 106 u8 port_num, 107 - struct ib_mad *mad, 107 + const struct ib_mad *mad, 108 108 u16 prev_lid) 109 109 { 110 110 struct ib_event event; ··· 160 160 161 161 static void forward_trap(struct mthca_dev *dev, 162 162 u8 port_num, 163 - struct ib_mad *mad) 163 + const struct ib_mad *mad) 164 164 { 165 165 int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED; 166 166 struct ib_mad_send_buf *send_buf; ··· 170 170 171 171 if (agent) { 172 172 send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR, 173 - IB_MGMT_MAD_DATA, GFP_ATOMIC); 173 + IB_MGMT_MAD_DATA, GFP_ATOMIC, 174 + IB_MGMT_BASE_VERSION); 174 175 if (IS_ERR(send_buf)) 175 176 return; 176 177 /* ··· 196 195 int mthca_process_mad(struct ib_device *ibdev, 197 196 int mad_flags, 198 197 u8 port_num, 199 - struct ib_wc *in_wc, 200 - struct ib_grh *in_grh, 201 - struct ib_mad *in_mad, 202 - struct ib_mad *out_mad) 198 + const struct ib_wc *in_wc, 199 + const struct ib_grh *in_grh, 200 + const struct ib_mad_hdr *in, size_t in_mad_size, 201 + struct ib_mad_hdr *out, size_t *out_mad_size, 202 + u16 *out_mad_pkey_index) 203 203 { 204 204 int err; 205 205 u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE); 206 206 u16 prev_lid = 0; 207 207 struct ib_port_attr pattr; 208 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 209 + struct ib_mad *out_mad = (struct ib_mad *)out; 210 + 211 + BUG_ON(in_mad_size != sizeof(*in_mad) || 212 + *out_mad_size != sizeof(*out_mad)); 208 213 209 214 /* Forward locally generated traps to the SM */ 210 215 if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
+2 -6
drivers/infiniband/hw/mthca/mthca_profile.c
··· 77 77 u64 mem_base, mem_avail; 78 78 s64 total_size = 0; 79 79 struct mthca_resource *profile; 80 - struct mthca_resource tmp; 81 80 int i, j; 82 81 83 82 profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL); ··· 135 136 */ 136 137 for (i = MTHCA_RES_NUM; i > 0; --i) 137 138 for (j = 1; j < i; ++j) { 138 - if (profile[j].size > profile[j - 1].size) { 139 - tmp = profile[j]; 140 - profile[j] = profile[j - 1]; 141 - profile[j - 1] = tmp; 142 - } 139 + if (profile[j].size > profile[j - 1].size) 140 + swap(profile[j], profile[j - 1]); 143 141 } 144 142 145 143 for (i = 0; i < MTHCA_RES_NUM; ++i) {
+30 -4
drivers/infiniband/hw/mthca/mthca_provider.c
··· 57 57 mad->method = IB_MGMT_METHOD_GET; 58 58 } 59 59 60 - static int mthca_query_device(struct ib_device *ibdev, 61 - struct ib_device_attr *props) 60 + static int mthca_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 61 + struct ib_udata *uhw) 62 62 { 63 63 struct ib_smp *in_mad = NULL; 64 64 struct ib_smp *out_mad = NULL; 65 65 int err = -ENOMEM; 66 66 struct mthca_dev *mdev = to_mdev(ibdev); 67 + 68 + if (uhw->inlen || uhw->outlen) 69 + return -EINVAL; 67 70 68 71 in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); 69 72 out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); ··· 644 641 return 0; 645 642 } 646 643 647 - static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries, 648 - int comp_vector, 644 + static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, 645 + const struct ib_cq_init_attr *attr, 649 646 struct ib_ucontext *context, 650 647 struct ib_udata *udata) 651 648 { 649 + int entries = attr->cqe; 652 650 struct mthca_create_cq ucmd; 653 651 struct mthca_cq *cq; 654 652 int nent; 655 653 int err; 654 + 655 + if (attr->flags) 656 + return ERR_PTR(-EINVAL); 656 657 657 658 if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes) 658 659 return ERR_PTR(-EINVAL); ··· 1251 1244 return err; 1252 1245 } 1253 1246 1247 + static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num, 1248 + struct ib_port_immutable *immutable) 1249 + { 1250 + struct ib_port_attr attr; 1251 + int err; 1252 + 1253 + err = mthca_query_port(ibdev, port_num, &attr); 1254 + if (err) 1255 + return err; 1256 + 1257 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 1258 + immutable->gid_tbl_len = attr.gid_tbl_len; 1259 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB; 1260 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 1261 + 1262 + return 0; 1263 + } 1264 + 1254 1265 int mthca_register_device(struct mthca_dev *dev) 1255 1266 { 1256 1267 int ret; ··· 1348 1323 dev->ib_dev.reg_phys_mr = mthca_reg_phys_mr; 1349 1324 dev->ib_dev.reg_user_mr = mthca_reg_user_mr; 1350 1325 dev->ib_dev.dereg_mr = mthca_dereg_mr; 1326 + dev->ib_dev.get_port_immutable = mthca_port_immutable; 1351 1327 1352 1328 if (dev->mthca_flags & MTHCA_FLAG_FMR) { 1353 1329 dev->ib_dev.alloc_fmr = mthca_alloc_fmr;
+7
drivers/infiniband/hw/nes/nes_cm.c
··· 1616 1616 &cm_node->loc_addr, cm_node->loc_port, 1617 1617 &cm_node->rem_addr, cm_node->rem_port); 1618 1618 cm_node->listener = listener; 1619 + if (listener) 1620 + cm_node->tos = listener->tos; 1619 1621 cm_node->netdev = nesvnic->netdev; 1620 1622 cm_node->cm_id = cm_info->cm_id; 1621 1623 memcpy(cm_node->loc_mac, nesvnic->netdev->dev_addr, ETH_ALEN); ··· 2940 2938 2941 2939 nesqp->nesqp_context->misc2 |= cpu_to_le32(64 << NES_QPCONTEXT_MISC2_TTL_SHIFT); 2942 2940 2941 + nesqp->nesqp_context->misc2 |= cpu_to_le32( 2942 + cm_node->tos << NES_QPCONTEXT_MISC2_TOS_SHIFT); 2943 + 2943 2944 nesqp->nesqp_context->mss |= cpu_to_le32(((u32)cm_node->tcp_cntxt.mss) << 16); 2944 2945 2945 2946 nesqp->nesqp_context->tcp_state_flow_label |= cpu_to_le32( ··· 3617 3612 cm_node->ord_size = 1; 3618 3613 3619 3614 cm_node->apbvt_set = apbvt_set; 3615 + cm_node->tos = cm_id->tos; 3620 3616 nesqp->cm_node = cm_node; 3621 3617 cm_node->nesqp = nesqp; 3622 3618 nes_add_ref(&nesqp->ibqp); ··· 3672 3666 } 3673 3667 3674 3668 cm_id->provider_data = cm_node; 3669 + cm_node->tos = cm_id->tos; 3675 3670 3676 3671 if (!cm_node->reused_node) { 3677 3672 if (nes_create_mapinfo(&cm_info))
+2
drivers/infiniband/hw/nes/nes_cm.h
··· 303 303 int backlog; 304 304 enum nes_cm_listener_state listener_state; 305 305 u32 reused_node; 306 + u8 tos; 306 307 }; 307 308 308 309 /* per connection node and node state information */ ··· 353 352 struct list_head reset_entry; 354 353 struct nes_qp *nesqp; 355 354 atomic_t passive_state; 355 + u8 tos; 356 356 }; 357 357 358 358 /* structure for client or CM to fill when making CM api calls. */
+34 -7
drivers/infiniband/hw/nes/nes_verbs.c
··· 512 512 /** 513 513 * nes_query_device 514 514 */ 515 - static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *props) 515 + static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 516 + struct ib_udata *uhw) 516 517 { 517 518 struct nes_vnic *nesvnic = to_nesvnic(ibdev); 518 519 struct nes_device *nesdev = nesvnic->nesdev; 519 520 struct nes_ib_device *nesibdev = nesvnic->nesibdev; 521 + 522 + if (uhw->inlen || uhw->outlen) 523 + return -EINVAL; 520 524 521 525 memset(props, 0, sizeof(*props)); 522 526 memcpy(&props->sys_image_guid, nesvnic->netdev->dev_addr, 6); ··· 609 605 610 606 return 0; 611 607 } 612 - 613 608 614 609 /** 615 610 * nes_query_pkey ··· 1530 1527 /** 1531 1528 * nes_create_cq 1532 1529 */ 1533 - static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, 1534 - int comp_vector, 1535 - struct ib_ucontext *context, struct ib_udata *udata) 1530 + static struct ib_cq *nes_create_cq(struct ib_device *ibdev, 1531 + const struct ib_cq_init_attr *attr, 1532 + struct ib_ucontext *context, 1533 + struct ib_udata *udata) 1536 1534 { 1535 + int entries = attr->cqe; 1537 1536 u64 u64temp; 1538 1537 struct nes_vnic *nesvnic = to_nesvnic(ibdev); 1539 1538 struct nes_device *nesdev = nesvnic->nesdev; ··· 1554 1549 int err; 1555 1550 unsigned long flags; 1556 1551 int ret; 1552 + 1553 + if (attr->flags) 1554 + return ERR_PTR(-EINVAL); 1557 1555 1558 1556 if (entries > nesadapter->max_cqe) 1559 1557 return ERR_PTR(-EINVAL); ··· 3230 3222 * nes_process_mad 3231 3223 */ 3232 3224 static int nes_process_mad(struct ib_device *ibdev, int mad_flags, 3233 - u8 port_num, struct ib_wc *in_wc, struct ib_grh *in_grh, 3234 - struct ib_mad *in_mad, struct ib_mad *out_mad) 3225 + u8 port_num, const struct ib_wc *in_wc, const struct ib_grh *in_grh, 3226 + const struct ib_mad_hdr *in, size_t in_mad_size, 3227 + struct ib_mad_hdr *out, size_t *out_mad_size, 3228 + u16 *out_mad_pkey_index) 3235 3229 { 3236 3230 nes_debug(NES_DBG_INIT, "\n"); 3237 3231 return -ENOSYS; ··· 3838 3828 return 0; 3839 3829 } 3840 3830 3831 + static int nes_port_immutable(struct ib_device *ibdev, u8 port_num, 3832 + struct ib_port_immutable *immutable) 3833 + { 3834 + struct ib_port_attr attr; 3835 + int err; 3836 + 3837 + err = nes_query_port(ibdev, port_num, &attr); 3838 + if (err) 3839 + return err; 3840 + 3841 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 3842 + immutable->gid_tbl_len = attr.gid_tbl_len; 3843 + immutable->core_cap_flags = RDMA_CORE_PORT_IWARP; 3844 + 3845 + return 0; 3846 + } 3841 3847 3842 3848 /** 3843 3849 * nes_init_ofa_device ··· 3954 3928 nesibdev->ibdev.iwcm->reject = nes_reject; 3955 3929 nesibdev->ibdev.iwcm->create_listen = nes_create_listen; 3956 3930 nesibdev->ibdev.iwcm->destroy_listen = nes_destroy_listen; 3931 + nesibdev->ibdev.get_port_immutable = nes_port_immutable; 3957 3932 3958 3933 return nesibdev; 3959 3934 }
+10 -3
drivers/infiniband/hw/ocrdma/ocrdma_ah.c
··· 204 204 int ocrdma_process_mad(struct ib_device *ibdev, 205 205 int process_mad_flags, 206 206 u8 port_num, 207 - struct ib_wc *in_wc, 208 - struct ib_grh *in_grh, 209 - struct ib_mad *in_mad, struct ib_mad *out_mad) 207 + const struct ib_wc *in_wc, 208 + const struct ib_grh *in_grh, 209 + const struct ib_mad_hdr *in, size_t in_mad_size, 210 + struct ib_mad_hdr *out, size_t *out_mad_size, 211 + u16 *out_mad_pkey_index) 210 212 { 211 213 int status; 212 214 struct ocrdma_dev *dev; 215 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 216 + struct ib_mad *out_mad = (struct ib_mad *)out; 217 + 218 + BUG_ON(in_mad_size != sizeof(*in_mad) || 219 + *out_mad_size != sizeof(*out_mad)); 213 220 214 221 switch (in_mad->mad_hdr.mgmt_class) { 215 222 case IB_MGMT_CLASS_PERF_MGMT:
+5 -3
drivers/infiniband/hw/ocrdma/ocrdma_ah.h
··· 42 42 int ocrdma_process_mad(struct ib_device *, 43 43 int process_mad_flags, 44 44 u8 port_num, 45 - struct ib_wc *in_wc, 46 - struct ib_grh *in_grh, 47 - struct ib_mad *in_mad, struct ib_mad *out_mad); 45 + const struct ib_wc *in_wc, 46 + const struct ib_grh *in_grh, 47 + const struct ib_mad_hdr *in, size_t in_mad_size, 48 + struct ib_mad_hdr *out, size_t *out_mad_size, 49 + u16 *out_mad_pkey_index); 48 50 #endif /* __OCRDMA_AH_H__ */
+20
drivers/infiniband/hw/ocrdma/ocrdma_main.c
··· 30 30 #include <rdma/ib_verbs.h> 31 31 #include <rdma/ib_user_verbs.h> 32 32 #include <rdma/ib_addr.h> 33 + #include <rdma/ib_mad.h> 33 34 34 35 #include <linux/netdevice.h> 35 36 #include <net/addrconf.h> ··· 203 202 return IB_LINK_LAYER_ETHERNET; 204 203 } 205 204 205 + static int ocrdma_port_immutable(struct ib_device *ibdev, u8 port_num, 206 + struct ib_port_immutable *immutable) 207 + { 208 + struct ib_port_attr attr; 209 + int err; 210 + 211 + err = ocrdma_query_port(ibdev, port_num, &attr); 212 + if (err) 213 + return err; 214 + 215 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 216 + immutable->gid_tbl_len = attr.gid_tbl_len; 217 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE; 218 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 219 + 220 + return 0; 221 + } 222 + 206 223 static int ocrdma_register_device(struct ocrdma_dev *dev) 207 224 { 208 225 strlcpy(dev->ibdev.name, "ocrdma%d", IB_DEVICE_NAME_MAX); ··· 305 286 dev->ibdev.dma_device = &dev->nic_info.pdev->dev; 306 287 307 288 dev->ibdev.process_mad = ocrdma_process_mad; 289 + dev->ibdev.get_port_immutable = ocrdma_port_immutable; 308 290 309 291 if (ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R) { 310 292 dev->ibdev.uverbs_cmd_mask |=
+17 -4
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
··· 61 61 return 0; 62 62 } 63 63 64 - int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr) 64 + int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr, 65 + struct ib_udata *uhw) 65 66 { 66 67 struct ocrdma_dev *dev = get_ocrdma_dev(ibdev); 68 + 69 + if (uhw->inlen || uhw->outlen) 70 + return -EINVAL; 67 71 68 72 memset(attr, 0, sizeof *attr); 69 73 memcpy(&attr->fw_ver, &dev->attr.fw_ver[0], ··· 379 375 380 376 if (dev->pd_mgr->pd_prealloc_valid) { 381 377 status = ocrdma_get_pd_num(dev, pd); 382 - return (status == 0) ? pd : ERR_PTR(status); 378 + if (status == 0) { 379 + return pd; 380 + } else { 381 + kfree(pd); 382 + return ERR_PTR(status); 383 + } 383 384 } 384 385 385 386 retry: ··· 688 679 ocrdma_release_ucontext_pd(uctx); 689 680 } else { 690 681 status = _ocrdma_dealloc_pd(dev, pd); 691 - kfree(pd); 692 682 } 693 683 exit: 694 684 return ERR_PTR(status); ··· 1008 1000 return status; 1009 1001 } 1010 1002 1011 - struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev, int entries, int vector, 1003 + struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev, 1004 + const struct ib_cq_init_attr *attr, 1012 1005 struct ib_ucontext *ib_ctx, 1013 1006 struct ib_udata *udata) 1014 1007 { 1008 + int entries = attr->cqe; 1015 1009 struct ocrdma_cq *cq; 1016 1010 struct ocrdma_dev *dev = get_ocrdma_dev(ibdev); 1017 1011 struct ocrdma_ucontext *uctx = NULL; 1018 1012 u16 pd_id = 0; 1019 1013 int status; 1020 1014 struct ocrdma_create_cq_ureq ureq; 1015 + 1016 + if (attr->flags) 1017 + return ERR_PTR(-EINVAL); 1021 1018 1022 1019 if (udata) { 1023 1020 if (ib_copy_from_udata(&ureq, udata, sizeof(ureq)))
+9 -3
drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
··· 36 36 int ocrdma_poll_cq(struct ib_cq *, int num_entries, struct ib_wc *wc); 37 37 int ocrdma_arm_cq(struct ib_cq *, enum ib_cq_notify_flags flags); 38 38 39 - int ocrdma_query_device(struct ib_device *, struct ib_device_attr *props); 39 + int ocrdma_query_device(struct ib_device *, struct ib_device_attr *props, 40 + struct ib_udata *uhw); 40 41 int ocrdma_query_port(struct ib_device *, u8 port, struct ib_port_attr *props); 41 42 int ocrdma_modify_port(struct ib_device *, u8 port, int mask, 42 43 struct ib_port_modify *props); 44 + 45 + enum rdma_protocol_type 46 + ocrdma_query_protocol(struct ib_device *device, u8 port_num); 43 47 44 48 void ocrdma_get_guid(struct ocrdma_dev *, u8 *guid); 45 49 int ocrdma_query_gid(struct ib_device *, u8 port, ··· 60 56 struct ib_ucontext *, struct ib_udata *); 61 57 int ocrdma_dealloc_pd(struct ib_pd *pd); 62 58 63 - struct ib_cq *ocrdma_create_cq(struct ib_device *, int entries, int vector, 64 - struct ib_ucontext *, struct ib_udata *); 59 + struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev, 60 + const struct ib_cq_init_attr *attr, 61 + struct ib_ucontext *ib_ctx, 62 + struct ib_udata *udata); 65 63 int ocrdma_resize_cq(struct ib_cq *, int cqe, struct ib_udata *); 66 64 int ocrdma_destroy_cq(struct ib_cq *); 67 65
+8 -3
drivers/infiniband/hw/qib/qib_cq.c
··· 203 203 /** 204 204 * qib_create_cq - create a completion queue 205 205 * @ibdev: the device this completion queue is attached to 206 - * @entries: the minimum size of the completion queue 206 + * @attr: creation attributes 207 207 * @context: unused by the QLogic_IB driver 208 208 * @udata: user data for libibverbs.so 209 209 * ··· 212 212 * 213 213 * Called by ib_create_cq() in the generic verbs code. 214 214 */ 215 - struct ib_cq *qib_create_cq(struct ib_device *ibdev, int entries, 216 - int comp_vector, struct ib_ucontext *context, 215 + struct ib_cq *qib_create_cq(struct ib_device *ibdev, 216 + const struct ib_cq_init_attr *attr, 217 + struct ib_ucontext *context, 217 218 struct ib_udata *udata) 218 219 { 220 + int entries = attr->cqe; 219 221 struct qib_ibdev *dev = to_idev(ibdev); 220 222 struct qib_cq *cq; 221 223 struct qib_cq_wc *wc; 222 224 struct ib_cq *ret; 223 225 u32 sz; 226 + 227 + if (attr->flags) 228 + return ERR_PTR(-EINVAL); 224 229 225 230 if (entries < 1 || entries > ib_qib_max_cqes) { 226 231 ret = ERR_PTR(-EINVAL);
+2 -1
drivers/infiniband/hw/qib/qib_iba7322.c
··· 5502 5502 goto retry; 5503 5503 5504 5504 send_buf = ib_create_send_mad(agent, 0, 0, 0, IB_MGMT_MAD_HDR, 5505 - IB_MGMT_MAD_DATA, GFP_ATOMIC); 5505 + IB_MGMT_MAD_DATA, GFP_ATOMIC, 5506 + IB_MGMT_BASE_VERSION); 5506 5507 if (IS_ERR(send_buf)) 5507 5508 goto retry; 5508 5509
+14 -6
drivers/infiniband/hw/qib/qib_mad.c
··· 83 83 return; 84 84 85 85 send_buf = ib_create_send_mad(agent, 0, 0, 0, IB_MGMT_MAD_HDR, 86 - IB_MGMT_MAD_DATA, GFP_ATOMIC); 86 + IB_MGMT_MAD_DATA, GFP_ATOMIC, 87 + IB_MGMT_BASE_VERSION); 87 88 if (IS_ERR(send_buf)) 88 89 return; 89 90 ··· 1855 1854 } 1856 1855 1857 1856 static int process_subn(struct ib_device *ibdev, int mad_flags, 1858 - u8 port, struct ib_mad *in_mad, 1857 + u8 port, const struct ib_mad *in_mad, 1859 1858 struct ib_mad *out_mad) 1860 1859 { 1861 1860 struct ib_smp *smp = (struct ib_smp *)out_mad; ··· 2007 2006 } 2008 2007 2009 2008 static int process_perf(struct ib_device *ibdev, u8 port, 2010 - struct ib_mad *in_mad, 2009 + const struct ib_mad *in_mad, 2011 2010 struct ib_mad *out_mad) 2012 2011 { 2013 2012 struct ib_pma_mad *pmp = (struct ib_pma_mad *)out_mad; ··· 2300 2299 } 2301 2300 2302 2301 static int process_cc(struct ib_device *ibdev, int mad_flags, 2303 - u8 port, struct ib_mad *in_mad, 2302 + u8 port, const struct ib_mad *in_mad, 2304 2303 struct ib_mad *out_mad) 2305 2304 { 2306 2305 struct ib_cc_mad *ccp = (struct ib_cc_mad *)out_mad; ··· 2401 2400 * This is called by the ib_mad module. 2402 2401 */ 2403 2402 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port, 2404 - struct ib_wc *in_wc, struct ib_grh *in_grh, 2405 - struct ib_mad *in_mad, struct ib_mad *out_mad) 2403 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 2404 + const struct ib_mad_hdr *in, size_t in_mad_size, 2405 + struct ib_mad_hdr *out, size_t *out_mad_size, 2406 + u16 *out_mad_pkey_index) 2406 2407 { 2407 2408 int ret; 2408 2409 struct qib_ibport *ibp = to_iport(ibdev, port); 2409 2410 struct qib_pportdata *ppd = ppd_from_ibp(ibp); 2411 + const struct ib_mad *in_mad = (const struct ib_mad *)in; 2412 + struct ib_mad *out_mad = (struct ib_mad *)out; 2413 + 2414 + BUG_ON(in_mad_size != sizeof(*in_mad) || 2415 + *out_mad_size != sizeof(*out_mad)); 2410 2416 2411 2417 switch (in_mad->mad_hdr.mgmt_class) { 2412 2418 case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
+23 -2
drivers/infiniband/hw/qib/qib_verbs.c
··· 1550 1550 } 1551 1551 } 1552 1552 1553 - static int qib_query_device(struct ib_device *ibdev, 1554 - struct ib_device_attr *props) 1553 + static int qib_query_device(struct ib_device *ibdev, struct ib_device_attr *props, 1554 + struct ib_udata *uhw) 1555 1555 { 1556 1556 struct qib_devdata *dd = dd_from_ibdev(ibdev); 1557 1557 struct qib_ibdev *dev = to_idev(ibdev); 1558 1558 1559 + if (uhw->inlen || uhw->outlen) 1560 + return -EINVAL; 1559 1561 memset(props, 0, sizeof(*props)); 1560 1562 1561 1563 props->device_cap_flags = IB_DEVICE_BAD_PKEY_CNTR | ··· 2042 2040 RCU_INIT_POINTER(ibp->qp1, NULL); 2043 2041 } 2044 2042 2043 + static int qib_port_immutable(struct ib_device *ibdev, u8 port_num, 2044 + struct ib_port_immutable *immutable) 2045 + { 2046 + struct ib_port_attr attr; 2047 + int err; 2048 + 2049 + err = qib_query_port(ibdev, port_num, &attr); 2050 + if (err) 2051 + return err; 2052 + 2053 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 2054 + immutable->gid_tbl_len = attr.gid_tbl_len; 2055 + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB; 2056 + immutable->max_mad_size = IB_MGMT_MAD_SIZE; 2057 + 2058 + return 0; 2059 + } 2060 + 2045 2061 /** 2046 2062 * qib_register_ib_device - register our device with the infiniband core 2047 2063 * @dd: the device data structure ··· 2247 2227 ibdev->process_mad = qib_process_mad; 2248 2228 ibdev->mmap = qib_mmap; 2249 2229 ibdev->dma_ops = &qib_dma_mapping_ops; 2230 + ibdev->get_port_immutable = qib_port_immutable; 2250 2231 2251 2232 snprintf(ibdev->node_desc, sizeof(ibdev->node_desc), 2252 2233 "Intel Infiniband HCA %s", init_utsname()->nodename);
+7 -4
drivers/infiniband/hw/qib/qib_verbs.h
··· 872 872 void qib_sys_guid_chg(struct qib_ibport *ibp); 873 873 void qib_node_desc_chg(struct qib_ibport *ibp); 874 874 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 875 - struct ib_wc *in_wc, struct ib_grh *in_grh, 876 - struct ib_mad *in_mad, struct ib_mad *out_mad); 875 + const struct ib_wc *in_wc, const struct ib_grh *in_grh, 876 + const struct ib_mad_hdr *in, size_t in_mad_size, 877 + struct ib_mad_hdr *out, size_t *out_mad_size, 878 + u16 *out_mad_pkey_index); 877 879 int qib_create_agents(struct qib_ibdev *dev); 878 880 void qib_free_agents(struct qib_ibdev *dev); 879 881 ··· 1009 1007 1010 1008 int qib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry); 1011 1009 1012 - struct ib_cq *qib_create_cq(struct ib_device *ibdev, int entries, 1013 - int comp_vector, struct ib_ucontext *context, 1010 + struct ib_cq *qib_create_cq(struct ib_device *ibdev, 1011 + const struct ib_cq_init_attr *attr, 1012 + struct ib_ucontext *context, 1014 1013 struct ib_udata *udata); 1015 1014 1016 1015 int qib_destroy_cq(struct ib_cq *ibcq);
+17
drivers/infiniband/hw/usnic/usnic_ib_main.c
··· 300 300 }; 301 301 /* End of inet section*/ 302 302 303 + static int usnic_port_immutable(struct ib_device *ibdev, u8 port_num, 304 + struct ib_port_immutable *immutable) 305 + { 306 + struct ib_port_attr attr; 307 + int err; 308 + 309 + err = usnic_ib_query_port(ibdev, port_num, &attr); 310 + if (err) 311 + return err; 312 + 313 + immutable->pkey_tbl_len = attr.pkey_tbl_len; 314 + immutable->gid_tbl_len = attr.gid_tbl_len; 315 + 316 + return 0; 317 + } 318 + 303 319 /* Start of PF discovery section */ 304 320 static void *usnic_ib_device_add(struct pci_dev *dev) 305 321 { ··· 399 383 us_ibdev->ib_dev.poll_cq = usnic_ib_poll_cq; 400 384 us_ibdev->ib_dev.req_notify_cq = usnic_ib_req_notify_cq; 401 385 us_ibdev->ib_dev.get_dma_mr = usnic_ib_get_dma_mr; 386 + us_ibdev->ib_dev.get_port_immutable = usnic_port_immutable; 402 387 403 388 404 389 if (ib_register_device(&us_ibdev->ib_dev, NULL))
+12 -4
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
··· 248 248 } 249 249 250 250 int usnic_ib_query_device(struct ib_device *ibdev, 251 - struct ib_device_attr *props) 251 + struct ib_device_attr *props, 252 + struct ib_udata *uhw) 252 253 { 253 254 struct usnic_ib_dev *us_ibdev = to_usdev(ibdev); 254 255 union ib_gid gid; ··· 258 257 int qp_per_vf; 259 258 260 259 usnic_dbg("\n"); 260 + if (uhw->inlen || uhw->outlen) 261 + return -EINVAL; 262 + 261 263 mutex_lock(&us_ibdev->usdev_lock); 262 264 us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info); 263 265 us_ibdev->netdev->ethtool_ops->get_settings(us_ibdev->netdev, &cmd); ··· 574 570 return status; 575 571 } 576 572 577 - struct ib_cq *usnic_ib_create_cq(struct ib_device *ibdev, int entries, 578 - int vector, struct ib_ucontext *context, 579 - struct ib_udata *udata) 573 + struct ib_cq *usnic_ib_create_cq(struct ib_device *ibdev, 574 + const struct ib_cq_init_attr *attr, 575 + struct ib_ucontext *context, 576 + struct ib_udata *udata) 580 577 { 581 578 struct ib_cq *cq; 582 579 583 580 usnic_dbg("\n"); 581 + if (attr->flags) 582 + return ERR_PTR(-EINVAL); 583 + 584 584 cq = kzalloc(sizeof(*cq), GFP_KERNEL); 585 585 if (!cq) 586 586 return ERR_PTR(-EBUSY);
+8 -4
drivers/infiniband/hw/usnic/usnic_ib_verbs.h
··· 24 24 enum rdma_link_layer usnic_ib_port_link_layer(struct ib_device *device, 25 25 u8 port_num); 26 26 int usnic_ib_query_device(struct ib_device *ibdev, 27 - struct ib_device_attr *props); 27 + struct ib_device_attr *props, 28 + struct ib_udata *uhw); 28 29 int usnic_ib_query_port(struct ib_device *ibdev, u8 port, 29 30 struct ib_port_attr *props); 31 + enum rdma_protocol_type 32 + usnic_ib_query_protocol(struct ib_device *device, u8 port_num); 30 33 int usnic_ib_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr, 31 34 int qp_attr_mask, 32 35 struct ib_qp_init_attr *qp_init_attr); ··· 47 44 int usnic_ib_destroy_qp(struct ib_qp *qp); 48 45 int usnic_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 49 46 int attr_mask, struct ib_udata *udata); 50 - struct ib_cq *usnic_ib_create_cq(struct ib_device *ibdev, int entries, 51 - int vector, struct ib_ucontext *context, 52 - struct ib_udata *udata); 47 + struct ib_cq *usnic_ib_create_cq(struct ib_device *ibdev, 48 + const struct ib_cq_init_attr *attr, 49 + struct ib_ucontext *context, 50 + struct ib_udata *udata); 53 51 int usnic_ib_destroy_cq(struct ib_cq *cq); 54 52 struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length, 55 53 u64 virt_addr, int access_flags,
+3 -4
drivers/infiniband/hw/usnic/usnic_uiom.c
··· 472 472 return ERR_PTR(-ENOMEM); 473 473 474 474 pd->domain = domain = iommu_domain_alloc(&pci_bus_type); 475 - if (IS_ERR_OR_NULL(domain)) { 476 - usnic_err("Failed to allocate IOMMU domain with err %ld\n", 477 - PTR_ERR(pd->domain)); 475 + if (!domain) { 476 + usnic_err("Failed to allocate IOMMU domain"); 478 477 kfree(pd); 479 - return ERR_PTR(domain ? PTR_ERR(domain) : -ENOMEM); 478 + return ERR_PTR(-ENOMEM); 480 479 } 481 480 482 481 iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);
+10 -9
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 1128 1128 { 1129 1129 struct ipoib_neigh_table *ntbl = &priv->ntbl; 1130 1130 struct ipoib_neigh_hash *htbl; 1131 - struct ipoib_neigh **buckets; 1131 + struct ipoib_neigh __rcu **buckets; 1132 1132 u32 size; 1133 1133 1134 1134 clear_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags); ··· 1146 1146 htbl->size = size; 1147 1147 htbl->mask = (size - 1); 1148 1148 htbl->buckets = buckets; 1149 - ntbl->htbl = htbl; 1149 + RCU_INIT_POINTER(ntbl->htbl, htbl); 1150 1150 htbl->ntbl = ntbl; 1151 1151 atomic_set(&ntbl->entries, 0); 1152 1152 ··· 1685 1685 struct net_device *dev; 1686 1686 struct ipoib_dev_priv *priv; 1687 1687 int s, e, p; 1688 - 1689 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 1690 - return; 1688 + int count = 0; 1691 1689 1692 1690 dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); 1693 1691 if (!dev_list) ··· 1702 1704 } 1703 1705 1704 1706 for (p = s; p <= e; ++p) { 1705 - if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND) 1707 + if (!rdma_protocol_ib(device, p)) 1706 1708 continue; 1707 1709 dev = ipoib_add_port("ib%d", device, p); 1708 1710 if (!IS_ERR(dev)) { 1709 1711 priv = netdev_priv(dev); 1710 1712 list_add_tail(&priv->list, dev_list); 1713 + count++; 1711 1714 } 1715 + } 1716 + 1717 + if (!count) { 1718 + kfree(dev_list); 1719 + return; 1712 1720 } 1713 1721 1714 1722 ib_set_client_data(device, &ipoib_client, dev_list); ··· 1724 1720 { 1725 1721 struct ipoib_dev_priv *priv, *tmp; 1726 1722 struct list_head *dev_list; 1727 - 1728 - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 1729 - return; 1730 1723 1731 1724 dev_list = ib_get_client_data(device, &ipoib_client); 1732 1725 if (!dev_list)
+6 -2
drivers/infiniband/ulp/ipoib/ipoib_verbs.c
··· 141 141 .sq_sig_type = IB_SIGNAL_ALL_WR, 142 142 .qp_type = IB_QPT_UD 143 143 }; 144 + struct ib_cq_init_attr cq_attr = {}; 144 145 145 146 int ret, size; 146 147 int i; ··· 179 178 } else 180 179 goto out_free_wq; 181 180 182 - priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0); 181 + cq_attr.cqe = size; 182 + priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, 183 + dev, &cq_attr); 183 184 if (IS_ERR(priv->recv_cq)) { 184 185 printk(KERN_WARNING "%s: failed to create receive CQ\n", ca->name); 185 186 goto out_cm_dev_cleanup; 186 187 } 187 188 189 + cq_attr.cqe = ipoib_sendq_size; 188 190 priv->send_cq = ib_create_cq(priv->ca, ipoib_send_comp_handler, NULL, 189 - dev, ipoib_sendq_size, 0); 191 + dev, &cq_attr); 190 192 if (IS_ERR(priv->send_cq)) { 191 193 printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name); 192 194 goto out_free_recv_cq;
+22 -11
drivers/infiniband/ulp/iser/iser_verbs.c
··· 51 51 52 52 static void iser_cq_event_callback(struct ib_event *cause, void *context) 53 53 { 54 - iser_err("got cq event %d \n", cause->event); 54 + iser_err("cq event %s (%d)\n", 55 + ib_event_msg(cause->event), cause->event); 55 56 } 56 57 57 58 static void iser_qp_event_callback(struct ib_event *cause, void *context) 58 59 { 59 - iser_err("got qp event %d\n",cause->event); 60 + iser_err("qp event %s (%d)\n", 61 + ib_event_msg(cause->event), cause->event); 60 62 } 61 63 62 64 static void iser_event_handler(struct ib_event_handler *handler, 63 65 struct ib_event *event) 64 66 { 65 - iser_err("async event %d on device %s port %d\n", event->event, 66 - event->device->name, event->element.port_num); 67 + iser_err("async event %s (%d) on device %s port %d\n", 68 + ib_event_msg(event->event), event->event, 69 + event->device->name, event->element.port_num); 67 70 } 68 71 69 72 /** ··· 126 123 goto pd_err; 127 124 128 125 for (i = 0; i < device->comps_used; i++) { 126 + struct ib_cq_init_attr cq_attr = {}; 129 127 struct iser_comp *comp = &device->comps[i]; 130 128 131 129 comp->device = device; 130 + cq_attr.cqe = max_cqe; 131 + cq_attr.comp_vector = i; 132 132 comp->cq = ib_create_cq(device->ib_device, 133 133 iser_cq_callback, 134 134 iser_cq_event_callback, 135 135 (void *)comp, 136 - max_cqe, i); 136 + &cq_attr); 137 137 if (IS_ERR(comp->cq)) { 138 138 comp->cq = NULL; 139 139 goto cq_err; ··· 879 873 int ret = 0; 880 874 881 875 iser_conn = (struct iser_conn *)cma_id->context; 882 - iser_info("event %d status %d conn %p id %p\n", 883 - event->event, event->status, cma_id->context, cma_id); 876 + iser_info("%s (%d): status %d conn %p id %p\n", 877 + rdma_event_msg(event->event), event->event, 878 + event->status, cma_id->context, cma_id); 884 879 885 880 mutex_lock(&iser_conn->state_mutex); 886 881 switch (event->event) { ··· 920 913 } 921 914 break; 922 915 default: 923 - iser_err("Unexpected RDMA CM event (%d)\n", event->event); 916 + iser_err("Unexpected RDMA CM event: %s (%d)\n", 917 + rdma_event_msg(event->event), event->event); 924 918 break; 925 919 } 926 920 mutex_unlock(&iser_conn->state_mutex); ··· 1181 1173 } 1182 1174 } else { 1183 1175 if (wc->status != IB_WC_WR_FLUSH_ERR) 1184 - iser_err("wr id %llx status %d vend_err %x\n", 1185 - wc->wr_id, wc->status, wc->vendor_err); 1176 + iser_err("%s (%d): wr id %llx vend_err %x\n", 1177 + ib_wc_status_msg(wc->status), wc->status, 1178 + wc->wr_id, wc->vendor_err); 1186 1179 else 1187 - iser_dbg("flush error: wr id %llx\n", wc->wr_id); 1180 + iser_dbg("%s (%d): wr id %llx\n", 1181 + ib_wc_status_msg(wc->status), wc->status, 1182 + wc->wr_id); 1188 1183 1189 1184 if (wc->wr_id == ISER_BEACON_WRID) 1190 1185 /* all flush errors were consumed */
+17 -7
drivers/infiniband/ulp/isert/ib_isert.c
··· 80 80 { 81 81 struct isert_conn *isert_conn = context; 82 82 83 - isert_err("conn %p event: %d\n", isert_conn, e->event); 83 + isert_err("%s (%d): conn %p\n", 84 + ib_event_msg(e->event), e->event, isert_conn); 85 + 84 86 switch (e->event) { 85 87 case IB_EVENT_COMM_EST: 86 88 rdma_notify(isert_conn->cm_id, IB_EVENT_COMM_EST); ··· 320 318 max_cqe = min(ISER_MAX_CQ_LEN, attr->max_cqe); 321 319 322 320 for (i = 0; i < device->comps_used; i++) { 321 + struct ib_cq_init_attr cq_attr = {}; 323 322 struct isert_comp *comp = &device->comps[i]; 324 323 325 324 comp->device = device; 326 325 INIT_WORK(&comp->work, isert_cq_work); 326 + cq_attr.cqe = max_cqe; 327 + cq_attr.comp_vector = i; 327 328 comp->cq = ib_create_cq(device->ib_device, 328 329 isert_cq_callback, 329 330 isert_cq_event_callback, 330 331 (void *)comp, 331 - max_cqe, i); 332 + &cq_attr); 332 333 if (IS_ERR(comp->cq)) { 333 334 isert_err("Unable to allocate cq\n"); 334 335 ret = PTR_ERR(comp->cq); ··· 905 900 isert_np_cma_handler(struct isert_np *isert_np, 906 901 enum rdma_cm_event_type event) 907 902 { 908 - isert_dbg("isert np %p, handling event %d\n", isert_np, event); 903 + isert_dbg("%s (%d): isert np %p\n", 904 + rdma_event_msg(event), event, isert_np); 909 905 910 906 switch (event) { 911 907 case RDMA_CM_EVENT_DEVICE_REMOVAL: ··· 980 974 { 981 975 int ret = 0; 982 976 983 - isert_info("event %d status %d id %p np %p\n", event->event, 977 + isert_info("%s (%d): status %d id %p np %p\n", 978 + rdma_event_msg(event->event), event->event, 984 979 event->status, cma_id, cma_id->context); 985 980 986 981 switch (event->event) { ··· 2115 2108 } 2116 2109 } else { 2117 2110 if (wc->status != IB_WC_WR_FLUSH_ERR) 2118 - isert_err("wr id %llx status %d vend_err %x\n", 2119 - wc->wr_id, wc->status, wc->vendor_err); 2111 + isert_err("%s (%d): wr id %llx vend_err %x\n", 2112 + ib_wc_status_msg(wc->status), wc->status, 2113 + wc->wr_id, wc->vendor_err); 2120 2114 else 2121 - isert_dbg("flush error: wr id %llx\n", wc->wr_id); 2115 + isert_dbg("%s (%d): wr id %llx\n", 2116 + ib_wc_status_msg(wc->status), wc->status, 2117 + wc->wr_id); 2122 2118 2123 2119 if (wc->wr_id != ISER_FASTREG_LI_WRID) 2124 2120 isert_cq_comp_err(isert_conn, wc);
+69 -77
drivers/infiniband/ulp/srp/ib_srp.c
··· 59 59 #define DRV_RELDATE "July 1, 2013" 60 60 61 61 MODULE_AUTHOR("Roland Dreier"); 62 - MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol initiator " 63 - "v" DRV_VERSION " (" DRV_RELDATE ")"); 62 + MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol initiator"); 64 63 MODULE_LICENSE("Dual BSD/GPL"); 64 + MODULE_VERSION(DRV_VERSION); 65 + MODULE_INFO(release_date, DRV_RELDATE); 65 66 66 67 static unsigned int srp_sg_tablesize; 67 68 static unsigned int cmd_sg_entries; ··· 254 253 255 254 static void srp_qp_event(struct ib_event *event, void *context) 256 255 { 257 - pr_debug("QP event %d\n", event->event); 256 + pr_debug("QP event %s (%d)\n", 257 + ib_event_msg(event->event), event->event); 258 258 } 259 259 260 260 static int srp_init_qp(struct srp_target_port *target, ··· 467 465 */ 468 466 static void srp_destroy_qp(struct srp_rdma_ch *ch) 469 467 { 470 - struct srp_target_port *target = ch->target; 471 468 static struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR }; 472 469 static struct ib_recv_wr wr = { .wr_id = SRP_LAST_WR_ID }; 473 470 struct ib_recv_wr *bad_wr; 474 471 int ret; 475 472 476 473 /* Destroying a QP and reusing ch->done is only safe if not connected */ 477 - WARN_ON_ONCE(target->connected); 474 + WARN_ON_ONCE(ch->connected); 478 475 479 476 ret = ib_modify_qp(ch->qp, &attr, IB_QP_STATE); 480 477 WARN_ONCE(ret, "ib_cm_init_qp_attr() returned %d\n", ret); ··· 500 499 struct ib_fmr_pool *fmr_pool = NULL; 501 500 struct srp_fr_pool *fr_pool = NULL; 502 501 const int m = 1 + dev->use_fast_reg; 502 + struct ib_cq_init_attr cq_attr = {}; 503 503 int ret; 504 504 505 505 init_attr = kzalloc(sizeof *init_attr, GFP_KERNEL); ··· 508 506 return -ENOMEM; 509 507 510 508 /* + 1 for SRP_LAST_WR_ID */ 509 + cq_attr.cqe = target->queue_size + 1; 510 + cq_attr.comp_vector = ch->comp_vector; 511 511 recv_cq = ib_create_cq(dev->dev, srp_recv_completion, NULL, ch, 512 - target->queue_size + 1, ch->comp_vector); 512 + &cq_attr); 513 513 if (IS_ERR(recv_cq)) { 514 514 ret = PTR_ERR(recv_cq); 515 515 goto err; 516 516 } 517 517 518 + cq_attr.cqe = m * target->queue_size; 519 + cq_attr.comp_vector = ch->comp_vector; 518 520 send_cq = ib_create_cq(dev->dev, srp_send_completion, NULL, ch, 519 - m * target->queue_size, ch->comp_vector); 521 + &cq_attr); 520 522 if (IS_ERR(send_cq)) { 521 523 ret = PTR_ERR(send_cq); 522 524 goto err_recv_cq; ··· 787 781 shost_printk(KERN_DEBUG, target->scsi_host, 788 782 PFX "Topspin/Cisco initiator port ID workaround " 789 783 "activated for target GUID %016llx\n", 790 - (unsigned long long) be64_to_cpu(target->ioc_guid)); 784 + be64_to_cpu(target->ioc_guid)); 791 785 memset(req->priv.initiator_port_id, 0, 8); 792 786 memcpy(req->priv.initiator_port_id + 8, 793 787 &target->srp_host->srp_dev->dev->node_guid, 8); ··· 817 811 return changed; 818 812 } 819 813 820 - static bool srp_change_conn_state(struct srp_target_port *target, 821 - bool connected) 822 - { 823 - bool changed = false; 824 - 825 - spin_lock_irq(&target->lock); 826 - if (target->connected != connected) { 827 - target->connected = connected; 828 - changed = true; 829 - } 830 - spin_unlock_irq(&target->lock); 831 - 832 - return changed; 833 - } 834 - 835 814 static void srp_disconnect_target(struct srp_target_port *target) 836 815 { 837 816 struct srp_rdma_ch *ch; 838 817 int i; 839 818 840 - if (srp_change_conn_state(target, false)) { 841 - /* XXX should send SRP_I_LOGOUT request */ 819 + /* XXX should send SRP_I_LOGOUT request */ 842 820 843 - for (i = 0; i < target->ch_count; i++) { 844 - ch = &target->ch[i]; 845 - if (ch->cm_id && ib_send_cm_dreq(ch->cm_id, NULL, 0)) { 846 - shost_printk(KERN_DEBUG, target->scsi_host, 847 - PFX "Sending CM DREQ failed\n"); 848 - } 821 + for (i = 0; i < target->ch_count; i++) { 822 + ch = &target->ch[i]; 823 + ch->connected = false; 824 + if (ch->cm_id && ib_send_cm_dreq(ch->cm_id, NULL, 0)) { 825 + shost_printk(KERN_DEBUG, target->scsi_host, 826 + PFX "Sending CM DREQ failed\n"); 849 827 } 850 828 } 851 829 } ··· 842 852 struct srp_request *req; 843 853 int i; 844 854 845 - if (!ch->target || !ch->req_ring) 855 + if (!ch->req_ring) 846 856 return; 847 857 848 858 for (i = 0; i < target->req_ring_size; ++i) { ··· 976 986 srp_queue_remove_work(target); 977 987 } 978 988 989 + /** 990 + * srp_connected_ch() - number of connected channels 991 + * @target: SRP target port. 992 + */ 993 + static int srp_connected_ch(struct srp_target_port *target) 994 + { 995 + int i, c = 0; 996 + 997 + for (i = 0; i < target->ch_count; i++) 998 + c += target->ch[i].connected; 999 + 1000 + return c; 1001 + } 1002 + 979 1003 static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) 980 1004 { 981 1005 struct srp_target_port *target = ch->target; 982 1006 int ret; 983 1007 984 - WARN_ON_ONCE(!multich && target->connected); 985 - 986 - target->qp_in_error = false; 1008 + WARN_ON_ONCE(!multich && srp_connected_ch(target) > 0); 987 1009 988 1010 ret = srp_lookup_path(ch); 989 1011 if (ret) ··· 1018 1016 */ 1019 1017 switch (ch->status) { 1020 1018 case 0: 1021 - srp_change_conn_state(target, true); 1019 + ch->connected = true; 1022 1020 return 0; 1023 1021 1024 1022 case SRP_PORT_REDIRECT: ··· 1216 1214 */ 1217 1215 for (i = 0; i < target->ch_count; i++) { 1218 1216 ch = &target->ch[i]; 1219 - if (!ch->target) 1220 - break; 1221 1217 ret += srp_new_cm_id(ch); 1222 1218 } 1223 1219 for (i = 0; i < target->ch_count; i++) { 1224 1220 ch = &target->ch[i]; 1225 - if (!ch->target) 1226 - break; 1227 1221 for (j = 0; j < target->req_ring_size; ++j) { 1228 1222 struct srp_request *req = &ch->req_ring[j]; 1229 1223 ··· 1228 1230 } 1229 1231 for (i = 0; i < target->ch_count; i++) { 1230 1232 ch = &target->ch[i]; 1231 - if (!ch->target) 1232 - break; 1233 1233 /* 1234 1234 * Whether or not creating a new CM ID succeeded, create a new 1235 1235 * QP. This guarantees that all completion callback function ··· 1239 1243 for (j = 0; j < target->queue_size; ++j) 1240 1244 list_add(&ch->tx_ring[j]->list, &ch->free_tx); 1241 1245 } 1246 + 1247 + target->qp_in_error = false; 1248 + 1242 1249 for (i = 0; i < target->ch_count; i++) { 1243 1250 ch = &target->ch[i]; 1244 - if (ret || !ch->target) { 1245 - if (i > 1) 1246 - ret = 0; 1251 + if (ret) 1247 1252 break; 1248 - } 1249 1253 ret = srp_connect_ch(ch, multich); 1250 1254 multich = true; 1251 1255 } ··· 1838 1842 s32 delta = be32_to_cpu(req->req_lim_delta); 1839 1843 1840 1844 shost_printk(KERN_ERR, target->scsi_host, PFX 1841 - "ignoring AER for LUN %llu\n", be64_to_cpu(req->lun)); 1845 + "ignoring AER for LUN %llu\n", scsilun_to_int(&req->lun)); 1842 1846 1843 1847 if (srp_response_common(ch, delta, &rsp, sizeof(rsp))) 1844 1848 shost_printk(KERN_ERR, target->scsi_host, PFX ··· 1925 1929 return; 1926 1930 } 1927 1931 1928 - if (target->connected && !target->qp_in_error) { 1932 + if (ch->connected && !target->qp_in_error) { 1929 1933 if (wr_id & LOCAL_INV_WR_ID_MASK) { 1930 1934 shost_printk(KERN_ERR, target->scsi_host, PFX 1931 - "LOCAL_INV failed with status %d\n", 1932 - wc_status); 1935 + "LOCAL_INV failed with status %s (%d)\n", 1936 + ib_wc_status_msg(wc_status), wc_status); 1933 1937 } else if (wr_id & FAST_REG_WR_ID_MASK) { 1934 1938 shost_printk(KERN_ERR, target->scsi_host, PFX 1935 - "FAST_REG_MR failed status %d\n", 1936 - wc_status); 1939 + "FAST_REG_MR failed status %s (%d)\n", 1940 + ib_wc_status_msg(wc_status), wc_status); 1937 1941 } else { 1938 1942 shost_printk(KERN_ERR, target->scsi_host, 1939 - PFX "failed %s status %d for iu %p\n", 1943 + PFX "failed %s status %s (%d) for iu %p\n", 1940 1944 send_err ? "send" : "receive", 1941 - wc_status, (void *)(uintptr_t)wr_id); 1945 + ib_wc_status_msg(wc_status), wc_status, 1946 + (void *)(uintptr_t)wr_id); 1942 1947 } 1943 1948 queue_work(system_long_wq, &target->tl_err_work); 1944 1949 } ··· 2031 2034 memset(cmd, 0, sizeof *cmd); 2032 2035 2033 2036 cmd->opcode = SRP_CMD; 2034 - cmd->lun = cpu_to_be64((u64) scmnd->device->lun << 48); 2037 + int_to_scsilun(scmnd->device->lun, &cmd->lun); 2035 2038 cmd->tag = tag; 2036 2039 memcpy(cmd->cdb, scmnd->cmnd, scmnd->cmd_len); 2037 2040 ··· 2364 2367 case IB_CM_DREQ_RECEIVED: 2365 2368 shost_printk(KERN_WARNING, target->scsi_host, 2366 2369 PFX "DREQ received - connection closed\n"); 2367 - srp_change_conn_state(target, false); 2370 + ch->connected = false; 2368 2371 if (ib_send_cm_drep(cm_id, NULL, 0)) 2369 2372 shost_printk(KERN_ERR, target->scsi_host, 2370 2373 PFX "Sending CM DREP failed\n"); ··· 2411 2414 return scsi_change_queue_depth(sdev, qdepth); 2412 2415 } 2413 2416 2414 - static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, 2415 - unsigned int lun, u8 func) 2417 + static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, u64 lun, 2418 + u8 func) 2416 2419 { 2417 2420 struct srp_target_port *target = ch->target; 2418 2421 struct srp_rport *rport = target->rport; ··· 2420 2423 struct srp_iu *iu; 2421 2424 struct srp_tsk_mgmt *tsk_mgmt; 2422 2425 2423 - if (!target->connected || target->qp_in_error) 2426 + if (!ch->connected || target->qp_in_error) 2424 2427 return -1; 2425 2428 2426 2429 init_completion(&ch->tsk_mgmt_done); ··· 2446 2449 memset(tsk_mgmt, 0, sizeof *tsk_mgmt); 2447 2450 2448 2451 tsk_mgmt->opcode = SRP_TSK_MGMT; 2449 - tsk_mgmt->lun = cpu_to_be64((u64) lun << 48); 2452 + int_to_scsilun(lun, &tsk_mgmt->lun); 2450 2453 tsk_mgmt->tag = req_tag | SRP_TAG_TSK_MGMT; 2451 2454 tsk_mgmt->tsk_mgmt_func = func; 2452 2455 tsk_mgmt->task_tag = req_tag; ··· 2560 2563 { 2561 2564 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 2562 2565 2563 - return sprintf(buf, "0x%016llx\n", 2564 - (unsigned long long) be64_to_cpu(target->id_ext)); 2566 + return sprintf(buf, "0x%016llx\n", be64_to_cpu(target->id_ext)); 2565 2567 } 2566 2568 2567 2569 static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr, ··· 2568 2572 { 2569 2573 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 2570 2574 2571 - return sprintf(buf, "0x%016llx\n", 2572 - (unsigned long long) be64_to_cpu(target->ioc_guid)); 2575 + return sprintf(buf, "0x%016llx\n", be64_to_cpu(target->ioc_guid)); 2573 2576 } 2574 2577 2575 2578 static ssize_t show_service_id(struct device *dev, ··· 2576 2581 { 2577 2582 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 2578 2583 2579 - return sprintf(buf, "0x%016llx\n", 2580 - (unsigned long long) be64_to_cpu(target->service_id)); 2584 + return sprintf(buf, "0x%016llx\n", be64_to_cpu(target->service_id)); 2581 2585 } 2582 2586 2583 2587 static ssize_t show_pkey(struct device *dev, struct device_attribute *attr, ··· 2767 2773 2768 2774 target->state = SRP_TARGET_SCANNING; 2769 2775 sprintf(target->target_name, "SRP.T10:%016llX", 2770 - (unsigned long long) be64_to_cpu(target->id_ext)); 2776 + be64_to_cpu(target->id_ext)); 2771 2777 2772 2778 if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device)) 2773 2779 return -ENODEV; ··· 2791 2797 scsi_scan_target(&target->scsi_host->shost_gendev, 2792 2798 0, target->scsi_id, SCAN_WILD_CARD, 0); 2793 2799 2794 - if (!target->connected || target->qp_in_error) { 2800 + if (srp_connected_ch(target) < target->ch_count || 2801 + target->qp_in_error) { 2795 2802 shost_printk(KERN_INFO, target->scsi_host, 2796 2803 PFX "SCSI scan failed - removing SCSI host\n"); 2797 2804 srp_queue_remove_work(target); ··· 3141 3146 target_host->transportt = ib_srp_transport_template; 3142 3147 target_host->max_channel = 0; 3143 3148 target_host->max_id = 1; 3144 - target_host->max_lun = SRP_MAX_LUN; 3149 + target_host->max_lun = -1LL; 3145 3150 target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; 3146 3151 3147 3152 target = host_to_target(target_host); ··· 3167 3172 3168 3173 ret = srp_parse_options(buf, target); 3169 3174 if (ret) 3170 - goto err; 3175 + goto out; 3171 3176 3172 3177 ret = scsi_init_shared_tag_map(target_host, target_host->can_queue); 3173 3178 if (ret) 3174 - goto err; 3179 + goto out; 3175 3180 3176 3181 target->req_ring_size = target->queue_size - SRP_TSK_MGMT_SQ_SIZE; 3177 3182 ··· 3182 3187 be64_to_cpu(target->ioc_guid), 3183 3188 be64_to_cpu(target->initiator_ext)); 3184 3189 ret = -EEXIST; 3185 - goto err; 3190 + goto out; 3186 3191 } 3187 3192 3188 3193 if (!srp_dev->has_fmr && !srp_dev->has_fr && !target->allow_ext_sg && ··· 3203 3208 spin_lock_init(&target->lock); 3204 3209 ret = ib_query_gid(ibdev, host->port, 0, &target->sgid); 3205 3210 if (ret) 3206 - goto err; 3211 + goto out; 3207 3212 3208 3213 ret = -ENOMEM; 3209 3214 target->ch_count = max_t(unsigned, num_online_nodes(), ··· 3214 3219 target->ch = kcalloc(target->ch_count, sizeof(*target->ch), 3215 3220 GFP_KERNEL); 3216 3221 if (!target->ch) 3217 - goto err; 3222 + goto out; 3218 3223 3219 3224 node_idx = 0; 3220 3225 for_each_online_node(node) { ··· 3310 3315 } 3311 3316 3312 3317 kfree(target->ch); 3313 - 3314 - err: 3315 - scsi_host_put(target_host); 3316 3318 goto out; 3317 3319 } 3318 3320
+1 -2
drivers/infiniband/ulp/srp/ib_srp.h
··· 54 54 SRP_DLID_REDIRECT = 2, 55 55 SRP_STALE_CONN = 3, 56 56 57 - SRP_MAX_LUN = 512, 58 57 SRP_DEF_SG_TABLESIZE = 12, 59 58 60 59 SRP_DEFAULT_QUEUE_SIZE = 1 << 6, ··· 169 170 170 171 struct completion tsk_mgmt_done; 171 172 u8 tsk_mgmt_status; 173 + bool connected; 172 174 }; 173 175 174 176 /** ··· 214 214 __be16 pkey; 215 215 216 216 u32 rq_tmo_jiffies; 217 - bool connected; 218 217 219 218 int zero_req_lim; 220 219
+5 -2
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 476 476 rsp = ib_create_send_mad(mad_agent, mad_wc->wc->src_qp, 477 477 mad_wc->wc->pkey_index, 0, 478 478 IB_MGMT_DEVICE_HDR, IB_MGMT_DEVICE_DATA, 479 - GFP_KERNEL); 479 + GFP_KERNEL, 480 + IB_MGMT_BASE_VERSION); 480 481 if (IS_ERR(rsp)) 481 482 goto err_rsp; 482 483 ··· 2081 2080 struct srpt_port *sport = ch->sport; 2082 2081 struct srpt_device *sdev = sport->sdev; 2083 2082 u32 srp_sq_size = sport->port_attrib.srp_sq_size; 2083 + struct ib_cq_init_attr cq_attr = {}; 2084 2084 int ret; 2085 2085 2086 2086 WARN_ON(ch->rq_size < 1); ··· 2092 2090 goto out; 2093 2091 2094 2092 retry: 2093 + cq_attr.cqe = ch->rq_size + srp_sq_size; 2095 2094 ch->cq = ib_create_cq(sdev->device, srpt_completion, NULL, ch, 2096 - ch->rq_size + srp_sq_size, 0); 2095 + &cq_attr); 2097 2096 if (IS_ERR(ch->cq)) { 2098 2097 ret = PTR_ERR(ch->cq); 2099 2098 pr_err("failed to create CQ cqe= %d ret= %d\n",
+1
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
··· 1185 1185 int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter, 1186 1186 unsigned int qid, 1187 1187 enum t4_bar2_qtype qtype, 1188 + int user, 1188 1189 u64 *pbar2_qoffset, 1189 1190 unsigned int *pbar2_qid); 1190 1191
+3 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
··· 2145 2145 int cxgb4_bar2_sge_qregs(struct net_device *dev, 2146 2146 unsigned int qid, 2147 2147 enum cxgb4_bar2_qtype qtype, 2148 + int user, 2148 2149 u64 *pbar2_qoffset, 2149 2150 unsigned int *pbar2_qid) 2150 2151 { ··· 2154 2153 (qtype == CXGB4_BAR2_QTYPE_EGRESS 2155 2154 ? T4_BAR2_QTYPE_EGRESS 2156 2155 : T4_BAR2_QTYPE_INGRESS), 2156 + user, 2157 2157 pbar2_qoffset, 2158 2158 pbar2_qid); 2159 2159 } ··· 2353 2351 int ret; 2354 2352 2355 2353 ret = cxgb4_t4_bar2_sge_qregs(adap, qid, T4_BAR2_QTYPE_EGRESS, 2356 - &bar2_qoffset, &bar2_qid); 2354 + 0, &bar2_qoffset, &bar2_qid); 2357 2355 if (ret) 2358 2356 dev_err(adap->pdev_dev, "doorbell drop recovery: " 2359 2357 "qid=%d, pidx_inc=%d\n", qid, pidx_inc);
+1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
··· 306 306 int cxgb4_bar2_sge_qregs(struct net_device *dev, 307 307 unsigned int qid, 308 308 enum cxgb4_bar2_qtype qtype, 309 + int user, 309 310 u64 *pbar2_qoffset, 310 311 unsigned int *pbar2_qid); 311 312
+2 -2
drivers/net/ethernet/chelsio/cxgb4/sge.c
··· 2429 2429 u64 bar2_qoffset; 2430 2430 int ret; 2431 2431 2432 - ret = cxgb4_t4_bar2_sge_qregs(adapter, qid, qtype, 2433 - &bar2_qoffset, pbar2_qid); 2432 + ret = cxgb4_t4_bar2_sge_qregs(adapter, qid, qtype, 0, 2433 + &bar2_qoffset, pbar2_qid); 2434 2434 if (ret) 2435 2435 return NULL; 2436 2436
+4 -3
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 5102 5102 * @adapter: the adapter 5103 5103 * @qid: the Queue ID 5104 5104 * @qtype: the Ingress or Egress type for @qid 5105 + * @user: true if this request is for a user mode queue 5105 5106 * @pbar2_qoffset: BAR2 Queue Offset 5106 5107 * @pbar2_qid: BAR2 Queue ID or 0 for Queue ID inferred SGE Queues 5107 5108 * ··· 5126 5125 int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter, 5127 5126 unsigned int qid, 5128 5127 enum t4_bar2_qtype qtype, 5128 + int user, 5129 5129 u64 *pbar2_qoffset, 5130 5130 unsigned int *pbar2_qid) 5131 5131 { ··· 5134 5132 u64 bar2_page_offset, bar2_qoffset; 5135 5133 unsigned int bar2_qid, bar2_qid_offset, bar2_qinferred; 5136 5134 5137 - /* T4 doesn't support BAR2 SGE Queue registers. 5138 - */ 5139 - if (is_t4(adapter->params.chip)) 5135 + /* T4 doesn't support BAR2 SGE Queue registers for kernel mode queues */ 5136 + if (!user && is_t4(adapter->params.chip)) 5140 5137 return -EINVAL; 5141 5138 5142 5139 /* Get our SGE Page Size parameters.
+19
drivers/net/ethernet/mellanox/mlx4/main.c
··· 1674 1674 return 0; 1675 1675 } 1676 1676 1677 + int mlx4_get_internal_clock_params(struct mlx4_dev *dev, 1678 + struct mlx4_clock_params *params) 1679 + { 1680 + struct mlx4_priv *priv = mlx4_priv(dev); 1681 + 1682 + if (mlx4_is_slave(dev)) 1683 + return -ENOTSUPP; 1684 + 1685 + if (!params) 1686 + return -EINVAL; 1687 + 1688 + params->bar = priv->fw.clock_bar; 1689 + params->offset = priv->fw.clock_offset; 1690 + params->size = MLX4_CLOCK_SIZE; 1691 + 1692 + return 0; 1693 + } 1694 + EXPORT_SYMBOL_GPL(mlx4_get_internal_clock_params); 1695 + 1677 1696 static void unmap_internal_clock(struct mlx4_dev *dev) 1678 1697 { 1679 1698 struct mlx4_priv *priv = mlx4_priv(dev);
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/mad.c
··· 36 36 #include <linux/mlx5/cmd.h> 37 37 #include "mlx5_core.h" 38 38 39 - int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, void *inb, void *outb, 39 + int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb, 40 40 u16 opmod, u8 port) 41 41 { 42 42 struct mlx5_mad_ifc_mbox_in *in = NULL;
+3 -3
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 1053 1053 memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); 1054 1054 srp_cmd->opcode = SRP_CMD; 1055 1055 memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb)); 1056 - srp_cmd->lun = cpu_to_be64(((u64)lun) << 48); 1056 + int_to_scsilun(lun, &srp_cmd->lun); 1057 1057 1058 1058 if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { 1059 1059 if (!firmware_has_feature(FW_FEATURE_CMO)) ··· 1529 1529 /* Set up an abort SRP command */ 1530 1530 memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); 1531 1531 tsk_mgmt->opcode = SRP_TSK_MGMT; 1532 - tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48); 1532 + int_to_scsilun(lun, &tsk_mgmt->lun); 1533 1533 tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK; 1534 1534 tsk_mgmt->task_tag = (u64) found_evt; 1535 1535 ··· 1652 1652 /* Set up a lun reset SRP command */ 1653 1653 memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); 1654 1654 tsk_mgmt->opcode = SRP_TSK_MGMT; 1655 - tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48); 1655 + int_to_scsilun(lun, &tsk_mgmt->lun); 1656 1656 tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET; 1657 1657 1658 1658 evt->sync_srp = &srp_rsp;
+42 -25
drivers/scsi/scsi_transport_srp.c
··· 61 61 return dev_to_shost(r->dev.parent); 62 62 } 63 63 64 + static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost) 65 + { 66 + return transport_class_to_srp_rport(&shost->shost_gendev); 67 + } 68 + 64 69 /** 65 70 * srp_tmo_valid() - check timeout combination validity 66 71 * @reconnect_delay: Reconnect delay in seconds. ··· 401 396 } 402 397 } 403 398 399 + /** 400 + * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn() 401 + * @shost: SCSI host for which to count the number of scsi_request_fn() callers. 402 + * 403 + * To do: add support for scsi-mq in this function. 404 + */ 405 + static int scsi_request_fn_active(struct Scsi_Host *shost) 406 + { 407 + struct scsi_device *sdev; 408 + struct request_queue *q; 409 + int request_fn_active = 0; 410 + 411 + shost_for_each_device(sdev, shost) { 412 + q = sdev->request_queue; 413 + 414 + spin_lock_irq(q->queue_lock); 415 + request_fn_active += q->request_fn_active; 416 + spin_unlock_irq(q->queue_lock); 417 + } 418 + 419 + return request_fn_active; 420 + } 421 + 422 + /* Wait until ongoing shost->hostt->queuecommand() calls have finished. */ 423 + static void srp_wait_for_queuecommand(struct Scsi_Host *shost) 424 + { 425 + while (scsi_request_fn_active(shost)) 426 + msleep(20); 427 + } 428 + 404 429 static void __rport_fail_io_fast(struct srp_rport *rport) 405 430 { 406 431 struct Scsi_Host *shost = rport_to_shost(rport); ··· 444 409 445 410 /* Involve the LLD if possible to terminate all I/O on the rport. */ 446 411 i = to_srp_internal(shost->transportt); 447 - if (i->f->terminate_rport_io) 412 + if (i->f->terminate_rport_io) { 413 + srp_wait_for_queuecommand(shost); 448 414 i->f->terminate_rport_io(rport); 415 + } 449 416 } 450 417 451 418 /** ··· 541 504 EXPORT_SYMBOL(srp_start_tl_fail_timers); 542 505 543 506 /** 544 - * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn() 545 - * @shost: SCSI host for which to count the number of scsi_request_fn() callers. 546 - */ 547 - static int scsi_request_fn_active(struct Scsi_Host *shost) 548 - { 549 - struct scsi_device *sdev; 550 - struct request_queue *q; 551 - int request_fn_active = 0; 552 - 553 - shost_for_each_device(sdev, shost) { 554 - q = sdev->request_queue; 555 - 556 - spin_lock_irq(q->queue_lock); 557 - request_fn_active += q->request_fn_active; 558 - spin_unlock_irq(q->queue_lock); 559 - } 560 - 561 - return request_fn_active; 562 - } 563 - 564 - /** 565 507 * srp_reconnect_rport() - reconnect to an SRP target port 566 508 * @rport: SRP target port. 567 509 * ··· 575 559 if (res) 576 560 goto out; 577 561 scsi_target_block(&shost->shost_gendev); 578 - while (scsi_request_fn_active(shost)) 579 - msleep(20); 562 + srp_wait_for_queuecommand(shost); 580 563 res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV; 581 564 pr_debug("%s (state %d): transport.reconnect() returned %d\n", 582 565 dev_name(&shost->shost_gendev), rport->state, res); ··· 633 618 struct scsi_device *sdev = scmd->device; 634 619 struct Scsi_Host *shost = sdev->host; 635 620 struct srp_internal *i = to_srp_internal(shost->transportt); 621 + struct srp_rport *rport = shost_to_rport(shost); 636 622 637 623 pr_debug("timeout for sdev %s\n", dev_name(&sdev->sdev_gendev)); 638 - return i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ? 624 + return rport->fast_io_fail_tmo < 0 && rport->dev_loss_tmo < 0 && 625 + i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ? 639 626 BLK_EH_RESET_TIMER : BLK_EH_NOT_HANDLED; 640 627 } 641 628
+4 -2
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
··· 647 647 kib_dev_t *dev; 648 648 struct ib_qp_init_attr *init_qp_attr; 649 649 struct kib_sched_info *sched; 650 + struct ib_cq_init_attr cq_attr = {}; 650 651 kib_conn_t *conn; 651 652 struct ib_cq *cq; 652 653 unsigned long flags; ··· 743 742 744 743 kiblnd_map_rx_descs(conn); 745 744 745 + cq_attr.cqe = IBLND_CQ_ENTRIES(version); 746 + cq_attr.comp_vector = kiblnd_get_completion_vector(conn, cpt); 746 747 cq = ib_create_cq(cmid->device, 747 748 kiblnd_cq_completion, kiblnd_cq_event, conn, 748 - IBLND_CQ_ENTRIES(version), 749 - kiblnd_get_completion_vector(conn, cpt)); 749 + &cq_attr); 750 750 if (IS_ERR(cq)) { 751 751 CERROR("Can't create CQ: %ld, cqe: %d\n", 752 752 PTR_ERR(cq), IBLND_CQ_ENTRIES(version));
+9
include/linux/mlx4/device.h
··· 829 829 struct mlx4_vf_dev *dev_vfs; 830 830 }; 831 831 832 + struct mlx4_clock_params { 833 + u64 offset; 834 + u8 bar; 835 + u8 size; 836 + }; 837 + 832 838 struct mlx4_eqe { 833 839 u8 reserved1; 834 840 u8 type; ··· 1490 1484 int mlx4_ACCESS_PTYS_REG(struct mlx4_dev *dev, 1491 1485 enum mlx4_access_reg_method method, 1492 1486 struct mlx4_ptys_reg *ptys_reg); 1487 + 1488 + int mlx4_get_internal_clock_params(struct mlx4_dev *dev, 1489 + struct mlx4_clock_params *params); 1493 1490 1494 1491 #endif /* MLX4_DEVICE_H */
+1 -1
include/linux/mlx5/driver.h
··· 696 696 u32 *mkey); 697 697 int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn); 698 698 int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn); 699 - int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, void *inb, void *outb, 699 + int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb, 700 700 u16 opmod, u8 port); 701 701 void mlx5_pagealloc_init(struct mlx5_core_dev *dev); 702 702 void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
+3 -3
include/rdma/ib_addr.h
··· 111 111 int rdma_addr_size(struct sockaddr *addr); 112 112 113 113 int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id); 114 - int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *smac, 115 - u16 *vlan_id); 114 + int rdma_addr_find_dmac_by_grh(const union ib_gid *sgid, const union ib_gid *dgid, 115 + u8 *smac, u16 *vlan_id); 116 116 117 117 static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr) 118 118 { ··· 160 160 } 161 161 162 162 /* Important - sockaddr should be a union of sockaddr_in and sockaddr_in6 */ 163 - static inline void rdma_gid2ip(struct sockaddr *out, union ib_gid *gid) 163 + static inline void rdma_gid2ip(struct sockaddr *out, const union ib_gid *gid) 164 164 { 165 165 if (ipv6_addr_v4mapped((struct in6_addr *)gid)) { 166 166 struct sockaddr_in *out_in = (struct sockaddr_in *)out;
+4 -4
include/rdma/ib_cache.h
··· 64 64 * ib_find_cached_gid() searches for the specified GID value in 65 65 * the local software cache. 66 66 */ 67 - int ib_find_cached_gid(struct ib_device *device, 68 - union ib_gid *gid, 69 - u8 *port_num, 70 - u16 *index); 67 + int ib_find_cached_gid(struct ib_device *device, 68 + const union ib_gid *gid, 69 + u8 *port_num, 70 + u16 *index); 71 71 72 72 /** 73 73 * ib_get_cached_pkey - Returns a cached PKey table entry
+35 -6
include/rdma/ib_mad.h
··· 42 42 #include <rdma/ib_verbs.h> 43 43 #include <uapi/rdma/ib_user_mad.h> 44 44 45 - /* Management base version */ 45 + /* Management base versions */ 46 46 #define IB_MGMT_BASE_VERSION 1 47 + #define OPA_MGMT_BASE_VERSION 0x80 48 + 49 + #define OPA_SMP_CLASS_VERSION 0x80 47 50 48 51 /* Management classes */ 49 52 #define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01 ··· 138 135 IB_MGMT_SA_DATA = 200, 139 136 IB_MGMT_DEVICE_HDR = 64, 140 137 IB_MGMT_DEVICE_DATA = 192, 138 + IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA, 139 + OPA_MGMT_MAD_DATA = 2024, 140 + OPA_MGMT_RMPP_DATA = 2012, 141 + OPA_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + OPA_MGMT_MAD_DATA, 141 142 }; 142 143 143 144 struct ib_mad_hdr { ··· 188 181 u8 data[IB_MGMT_MAD_DATA]; 189 182 }; 190 183 184 + struct opa_mad { 185 + struct ib_mad_hdr mad_hdr; 186 + u8 data[OPA_MGMT_MAD_DATA]; 187 + }; 188 + 191 189 struct ib_rmpp_mad { 192 190 struct ib_mad_hdr mad_hdr; 193 191 struct ib_rmpp_hdr rmpp_hdr; 194 192 u8 data[IB_MGMT_RMPP_DATA]; 193 + }; 194 + 195 + struct opa_rmpp_mad { 196 + struct ib_mad_hdr mad_hdr; 197 + struct ib_rmpp_hdr rmpp_hdr; 198 + u8 data[OPA_MGMT_RMPP_DATA]; 195 199 }; 196 200 197 201 struct ib_sa_mad { ··· 253 235 * includes the common MAD, RMPP, and class specific headers. 254 236 * @data_len: Indicates the total size of user-transferred data. 255 237 * @seg_count: The number of RMPP segments allocated for this send. 256 - * @seg_size: Size of each RMPP segment. 238 + * @seg_size: Size of the data in each RMPP segment. This does not include 239 + * class specific headers. 240 + * @seg_rmpp_size: Size of each RMPP segment including the class specific 241 + * headers. 257 242 * @timeout_ms: Time to wait for a response. 258 243 * @retries: Number of times to retry a request for a response. For MADs 259 244 * using RMPP, this applies per window. On completion, returns the number ··· 276 255 int data_len; 277 256 int seg_count; 278 257 int seg_size; 258 + int seg_rmpp_size; 279 259 int timeout_ms; 280 260 int retries; 281 261 }; ··· 285 263 * ib_response_mad - Returns if the specified MAD has been generated in 286 264 * response to a sent request or trap. 287 265 */ 288 - int ib_response_mad(struct ib_mad *mad); 266 + int ib_response_mad(const struct ib_mad_hdr *hdr); 289 267 290 268 /** 291 269 * ib_get_rmpp_resptime - Returns the RMPP response time. ··· 423 401 struct ib_mad_recv_buf { 424 402 struct list_head list; 425 403 struct ib_grh *grh; 426 - struct ib_mad *mad; 404 + union { 405 + struct ib_mad *mad; 406 + struct opa_mad *opa_mad; 407 + }; 427 408 }; 428 409 429 410 /** ··· 435 410 * @recv_buf: Specifies the location of the received data buffer(s). 436 411 * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers. 437 412 * @mad_len: The length of the received MAD, without duplicated headers. 413 + * @mad_seg_size: The size of individual MAD segments 438 414 * 439 415 * For received response, the wr_id contains a pointer to the ib_mad_send_buf 440 416 * for the corresponding send request. ··· 445 419 struct ib_mad_recv_buf recv_buf; 446 420 struct list_head rmpp_list; 447 421 int mad_len; 422 + size_t mad_seg_size; 448 423 }; 449 424 450 425 /** ··· 645 618 * automatically adjust the allocated buffer size to account for any 646 619 * additional padding that may be necessary. 647 620 * @gfp_mask: GFP mask used for the memory allocation. 621 + * @base_version: Base Version of this MAD 648 622 * 649 623 * This routine allocates a MAD for sending. The returned MAD send buffer 650 624 * will reference a data buffer usable for sending a MAD, along ··· 661 633 u32 remote_qpn, u16 pkey_index, 662 634 int rmpp_active, 663 635 int hdr_len, int data_len, 664 - gfp_t gfp_mask); 636 + gfp_t gfp_mask, 637 + u8 base_version); 665 638 666 639 /** 667 640 * ib_is_mad_class_rmpp - returns whether given management class ··· 704 675 * @agent: the agent in question 705 676 * @return: true if agent is performing rmpp, false otherwise. 706 677 */ 707 - int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent); 678 + int ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent); 708 679 709 680 #endif /* IB_MAD_H */
+376 -18
include/rdma/ib_verbs.h
··· 81 81 RDMA_TRANSPORT_USNIC_UDP 82 82 }; 83 83 84 + enum rdma_protocol_type { 85 + RDMA_PROTOCOL_IB, 86 + RDMA_PROTOCOL_IBOE, 87 + RDMA_PROTOCOL_IWARP, 88 + RDMA_PROTOCOL_USNIC_UDP 89 + }; 90 + 84 91 __attribute_const__ enum rdma_transport_type 85 92 rdma_node_get_transport(enum rdma_node_type node_type); 86 93 ··· 173 166 } per_transport_caps; 174 167 }; 175 168 169 + enum ib_cq_creation_flags { 170 + IB_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0, 171 + }; 172 + 173 + struct ib_cq_init_attr { 174 + unsigned int cqe; 175 + int comp_vector; 176 + u32 flags; 177 + }; 178 + 176 179 struct ib_device_attr { 177 180 u64 fw_ver; 178 181 __be64 sys_image_guid; ··· 227 210 int sig_prot_cap; 228 211 int sig_guard_cap; 229 212 struct ib_odp_caps odp_caps; 213 + uint64_t timestamp_mask; 214 + uint64_t hca_core_clock; /* in KHZ */ 230 215 }; 231 216 232 217 enum ib_mtu { ··· 365 346 struct iw_protocol_stats iw; 366 347 }; 367 348 349 + /* Define bits for the various functionality this port needs to be supported by 350 + * the core. 351 + */ 352 + /* Management 0x00000FFF */ 353 + #define RDMA_CORE_CAP_IB_MAD 0x00000001 354 + #define RDMA_CORE_CAP_IB_SMI 0x00000002 355 + #define RDMA_CORE_CAP_IB_CM 0x00000004 356 + #define RDMA_CORE_CAP_IW_CM 0x00000008 357 + #define RDMA_CORE_CAP_IB_SA 0x00000010 358 + #define RDMA_CORE_CAP_OPA_MAD 0x00000020 359 + 360 + /* Address format 0x000FF000 */ 361 + #define RDMA_CORE_CAP_AF_IB 0x00001000 362 + #define RDMA_CORE_CAP_ETH_AH 0x00002000 363 + 364 + /* Protocol 0xFFF00000 */ 365 + #define RDMA_CORE_CAP_PROT_IB 0x00100000 366 + #define RDMA_CORE_CAP_PROT_ROCE 0x00200000 367 + #define RDMA_CORE_CAP_PROT_IWARP 0x00400000 368 + 369 + #define RDMA_CORE_PORT_IBA_IB (RDMA_CORE_CAP_PROT_IB \ 370 + | RDMA_CORE_CAP_IB_MAD \ 371 + | RDMA_CORE_CAP_IB_SMI \ 372 + | RDMA_CORE_CAP_IB_CM \ 373 + | RDMA_CORE_CAP_IB_SA \ 374 + | RDMA_CORE_CAP_AF_IB) 375 + #define RDMA_CORE_PORT_IBA_ROCE (RDMA_CORE_CAP_PROT_ROCE \ 376 + | RDMA_CORE_CAP_IB_MAD \ 377 + | RDMA_CORE_CAP_IB_CM \ 378 + | RDMA_CORE_CAP_AF_IB \ 379 + | RDMA_CORE_CAP_ETH_AH) 380 + #define RDMA_CORE_PORT_IWARP (RDMA_CORE_CAP_PROT_IWARP \ 381 + | RDMA_CORE_CAP_IW_CM) 382 + #define RDMA_CORE_PORT_INTEL_OPA (RDMA_CORE_PORT_IBA_IB \ 383 + | RDMA_CORE_CAP_OPA_MAD) 384 + 368 385 struct ib_port_attr { 369 386 enum ib_port_state state; 370 387 enum ib_mtu max_mtu; ··· 466 411 IB_EVENT_CLIENT_REREGISTER, 467 412 IB_EVENT_GID_CHANGE, 468 413 }; 414 + 415 + __attribute_const__ const char *ib_event_msg(enum ib_event_type event); 469 416 470 417 struct ib_event { 471 418 struct ib_device *device; ··· 719 662 IB_WC_RESP_TIMEOUT_ERR, 720 663 IB_WC_GENERAL_ERR 721 664 }; 665 + 666 + __attribute_const__ const char *ib_wc_status_msg(enum ib_wc_status status); 722 667 723 668 enum ib_wc_opcode { 724 669 IB_WC_SEND, ··· 1466 1407 struct ib_uobject *uobject; 1467 1408 }; 1468 1409 1469 - struct ib_mad; 1410 + struct ib_mad_hdr; 1470 1411 struct ib_grh; 1471 1412 1472 1413 enum ib_process_mad_flags { ··· 1533 1474 1534 1475 struct iw_cm_verbs; 1535 1476 1477 + struct ib_port_immutable { 1478 + int pkey_tbl_len; 1479 + int gid_tbl_len; 1480 + u32 core_cap_flags; 1481 + u32 max_mad_size; 1482 + }; 1483 + 1536 1484 struct ib_device { 1537 1485 struct device *dma_device; 1538 1486 ··· 1553 1487 struct list_head client_data_list; 1554 1488 1555 1489 struct ib_cache cache; 1556 - int *pkey_tbl_len; 1557 - int *gid_tbl_len; 1490 + /** 1491 + * port_immutable is indexed by port number 1492 + */ 1493 + struct ib_port_immutable *port_immutable; 1558 1494 1559 1495 int num_comp_vectors; 1560 1496 ··· 1565 1497 int (*get_protocol_stats)(struct ib_device *device, 1566 1498 union rdma_protocol_stats *stats); 1567 1499 int (*query_device)(struct ib_device *device, 1568 - struct ib_device_attr *device_attr); 1500 + struct ib_device_attr *device_attr, 1501 + struct ib_udata *udata); 1569 1502 int (*query_port)(struct ib_device *device, 1570 1503 u8 port_num, 1571 1504 struct ib_port_attr *port_attr); ··· 1630 1561 int (*post_recv)(struct ib_qp *qp, 1631 1562 struct ib_recv_wr *recv_wr, 1632 1563 struct ib_recv_wr **bad_recv_wr); 1633 - struct ib_cq * (*create_cq)(struct ib_device *device, int cqe, 1634 - int comp_vector, 1564 + struct ib_cq * (*create_cq)(struct ib_device *device, 1565 + const struct ib_cq_init_attr *attr, 1635 1566 struct ib_ucontext *context, 1636 1567 struct ib_udata *udata); 1637 1568 int (*modify_cq)(struct ib_cq *cq, u16 cq_count, ··· 1706 1637 int (*process_mad)(struct ib_device *device, 1707 1638 int process_mad_flags, 1708 1639 u8 port_num, 1709 - struct ib_wc *in_wc, 1710 - struct ib_grh *in_grh, 1711 - struct ib_mad *in_mad, 1712 - struct ib_mad *out_mad); 1640 + const struct ib_wc *in_wc, 1641 + const struct ib_grh *in_grh, 1642 + const struct ib_mad_hdr *in_mad, 1643 + size_t in_mad_size, 1644 + struct ib_mad_hdr *out_mad, 1645 + size_t *out_mad_size, 1646 + u16 *out_mad_pkey_index); 1713 1647 struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device, 1714 1648 struct ib_ucontext *ucontext, 1715 1649 struct ib_udata *udata); ··· 1747 1675 u32 local_dma_lkey; 1748 1676 u8 node_type; 1749 1677 u8 phys_port_cnt; 1678 + 1679 + /** 1680 + * The following mandatory functions are used only at device 1681 + * registration. Keep functions such as these at the end of this 1682 + * structure to avoid cache line misses when accessing struct ib_device 1683 + * in fast paths. 1684 + */ 1685 + int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *); 1750 1686 }; 1751 1687 1752 1688 struct ib_client { ··· 1823 1743 enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, 1824 1744 u8 port_num); 1825 1745 1746 + /** 1747 + * rdma_start_port - Return the first valid port number for the device 1748 + * specified 1749 + * 1750 + * @device: Device to be checked 1751 + * 1752 + * Return start port number 1753 + */ 1754 + static inline u8 rdma_start_port(const struct ib_device *device) 1755 + { 1756 + return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1; 1757 + } 1758 + 1759 + /** 1760 + * rdma_end_port - Return the last valid port number for the device 1761 + * specified 1762 + * 1763 + * @device: Device to be checked 1764 + * 1765 + * Return last port number 1766 + */ 1767 + static inline u8 rdma_end_port(const struct ib_device *device) 1768 + { 1769 + return (device->node_type == RDMA_NODE_IB_SWITCH) ? 1770 + 0 : device->phys_port_cnt; 1771 + } 1772 + 1773 + static inline bool rdma_protocol_ib(const struct ib_device *device, u8 port_num) 1774 + { 1775 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IB; 1776 + } 1777 + 1778 + static inline bool rdma_protocol_roce(const struct ib_device *device, u8 port_num) 1779 + { 1780 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE; 1781 + } 1782 + 1783 + static inline bool rdma_protocol_iwarp(const struct ib_device *device, u8 port_num) 1784 + { 1785 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IWARP; 1786 + } 1787 + 1788 + static inline bool rdma_ib_or_roce(const struct ib_device *device, u8 port_num) 1789 + { 1790 + return device->port_immutable[port_num].core_cap_flags & 1791 + (RDMA_CORE_CAP_PROT_IB | RDMA_CORE_CAP_PROT_ROCE); 1792 + } 1793 + 1794 + /** 1795 + * rdma_cap_ib_mad - Check if the port of a device supports Infiniband 1796 + * Management Datagrams. 1797 + * @device: Device to check 1798 + * @port_num: Port number to check 1799 + * 1800 + * Management Datagrams (MAD) are a required part of the InfiniBand 1801 + * specification and are supported on all InfiniBand devices. A slightly 1802 + * extended version are also supported on OPA interfaces. 1803 + * 1804 + * Return: true if the port supports sending/receiving of MAD packets. 1805 + */ 1806 + static inline bool rdma_cap_ib_mad(const struct ib_device *device, u8 port_num) 1807 + { 1808 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_MAD; 1809 + } 1810 + 1811 + /** 1812 + * rdma_cap_opa_mad - Check if the port of device provides support for OPA 1813 + * Management Datagrams. 1814 + * @device: Device to check 1815 + * @port_num: Port number to check 1816 + * 1817 + * Intel OmniPath devices extend and/or replace the InfiniBand Management 1818 + * datagrams with their own versions. These OPA MADs share many but not all of 1819 + * the characteristics of InfiniBand MADs. 1820 + * 1821 + * OPA MADs differ in the following ways: 1822 + * 1823 + * 1) MADs are variable size up to 2K 1824 + * IBTA defined MADs remain fixed at 256 bytes 1825 + * 2) OPA SMPs must carry valid PKeys 1826 + * 3) OPA SMP packets are a different format 1827 + * 1828 + * Return: true if the port supports OPA MAD packet formats. 1829 + */ 1830 + static inline bool rdma_cap_opa_mad(struct ib_device *device, u8 port_num) 1831 + { 1832 + return (device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_OPA_MAD) 1833 + == RDMA_CORE_CAP_OPA_MAD; 1834 + } 1835 + 1836 + /** 1837 + * rdma_cap_ib_smi - Check if the port of a device provides an Infiniband 1838 + * Subnet Management Agent (SMA) on the Subnet Management Interface (SMI). 1839 + * @device: Device to check 1840 + * @port_num: Port number to check 1841 + * 1842 + * Each InfiniBand node is required to provide a Subnet Management Agent 1843 + * that the subnet manager can access. Prior to the fabric being fully 1844 + * configured by the subnet manager, the SMA is accessed via a well known 1845 + * interface called the Subnet Management Interface (SMI). This interface 1846 + * uses directed route packets to communicate with the SM to get around the 1847 + * chicken and egg problem of the SM needing to know what's on the fabric 1848 + * in order to configure the fabric, and needing to configure the fabric in 1849 + * order to send packets to the devices on the fabric. These directed 1850 + * route packets do not need the fabric fully configured in order to reach 1851 + * their destination. The SMI is the only method allowed to send 1852 + * directed route packets on an InfiniBand fabric. 1853 + * 1854 + * Return: true if the port provides an SMI. 1855 + */ 1856 + static inline bool rdma_cap_ib_smi(const struct ib_device *device, u8 port_num) 1857 + { 1858 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SMI; 1859 + } 1860 + 1861 + /** 1862 + * rdma_cap_ib_cm - Check if the port of device has the capability Infiniband 1863 + * Communication Manager. 1864 + * @device: Device to check 1865 + * @port_num: Port number to check 1866 + * 1867 + * The InfiniBand Communication Manager is one of many pre-defined General 1868 + * Service Agents (GSA) that are accessed via the General Service 1869 + * Interface (GSI). It's role is to facilitate establishment of connections 1870 + * between nodes as well as other management related tasks for established 1871 + * connections. 1872 + * 1873 + * Return: true if the port supports an IB CM (this does not guarantee that 1874 + * a CM is actually running however). 1875 + */ 1876 + static inline bool rdma_cap_ib_cm(const struct ib_device *device, u8 port_num) 1877 + { 1878 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_CM; 1879 + } 1880 + 1881 + /** 1882 + * rdma_cap_iw_cm - Check if the port of device has the capability IWARP 1883 + * Communication Manager. 1884 + * @device: Device to check 1885 + * @port_num: Port number to check 1886 + * 1887 + * Similar to above, but specific to iWARP connections which have a different 1888 + * managment protocol than InfiniBand. 1889 + * 1890 + * Return: true if the port supports an iWARP CM (this does not guarantee that 1891 + * a CM is actually running however). 1892 + */ 1893 + static inline bool rdma_cap_iw_cm(const struct ib_device *device, u8 port_num) 1894 + { 1895 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IW_CM; 1896 + } 1897 + 1898 + /** 1899 + * rdma_cap_ib_sa - Check if the port of device has the capability Infiniband 1900 + * Subnet Administration. 1901 + * @device: Device to check 1902 + * @port_num: Port number to check 1903 + * 1904 + * An InfiniBand Subnet Administration (SA) service is a pre-defined General 1905 + * Service Agent (GSA) provided by the Subnet Manager (SM). On InfiniBand 1906 + * fabrics, devices should resolve routes to other hosts by contacting the 1907 + * SA to query the proper route. 1908 + * 1909 + * Return: true if the port should act as a client to the fabric Subnet 1910 + * Administration interface. This does not imply that the SA service is 1911 + * running locally. 1912 + */ 1913 + static inline bool rdma_cap_ib_sa(const struct ib_device *device, u8 port_num) 1914 + { 1915 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SA; 1916 + } 1917 + 1918 + /** 1919 + * rdma_cap_ib_mcast - Check if the port of device has the capability Infiniband 1920 + * Multicast. 1921 + * @device: Device to check 1922 + * @port_num: Port number to check 1923 + * 1924 + * InfiniBand multicast registration is more complex than normal IPv4 or 1925 + * IPv6 multicast registration. Each Host Channel Adapter must register 1926 + * with the Subnet Manager when it wishes to join a multicast group. It 1927 + * should do so only once regardless of how many queue pairs it subscribes 1928 + * to this group. And it should leave the group only after all queue pairs 1929 + * attached to the group have been detached. 1930 + * 1931 + * Return: true if the port must undertake the additional adminstrative 1932 + * overhead of registering/unregistering with the SM and tracking of the 1933 + * total number of queue pairs attached to the multicast group. 1934 + */ 1935 + static inline bool rdma_cap_ib_mcast(const struct ib_device *device, u8 port_num) 1936 + { 1937 + return rdma_cap_ib_sa(device, port_num); 1938 + } 1939 + 1940 + /** 1941 + * rdma_cap_af_ib - Check if the port of device has the capability 1942 + * Native Infiniband Address. 1943 + * @device: Device to check 1944 + * @port_num: Port number to check 1945 + * 1946 + * InfiniBand addressing uses a port's GUID + Subnet Prefix to make a default 1947 + * GID. RoCE uses a different mechanism, but still generates a GID via 1948 + * a prescribed mechanism and port specific data. 1949 + * 1950 + * Return: true if the port uses a GID address to identify devices on the 1951 + * network. 1952 + */ 1953 + static inline bool rdma_cap_af_ib(const struct ib_device *device, u8 port_num) 1954 + { 1955 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_AF_IB; 1956 + } 1957 + 1958 + /** 1959 + * rdma_cap_eth_ah - Check if the port of device has the capability 1960 + * Ethernet Address Handle. 1961 + * @device: Device to check 1962 + * @port_num: Port number to check 1963 + * 1964 + * RoCE is InfiniBand over Ethernet, and it uses a well defined technique 1965 + * to fabricate GIDs over Ethernet/IP specific addresses native to the 1966 + * port. Normally, packet headers are generated by the sending host 1967 + * adapter, but when sending connectionless datagrams, we must manually 1968 + * inject the proper headers for the fabric we are communicating over. 1969 + * 1970 + * Return: true if we are running as a RoCE port and must force the 1971 + * addition of a Global Route Header built from our Ethernet Address 1972 + * Handle into our header list for connectionless packets. 1973 + */ 1974 + static inline bool rdma_cap_eth_ah(const struct ib_device *device, u8 port_num) 1975 + { 1976 + return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_ETH_AH; 1977 + } 1978 + 1979 + /** 1980 + * rdma_cap_read_multi_sge - Check if the port of device has the capability 1981 + * RDMA Read Multiple Scatter-Gather Entries. 1982 + * @device: Device to check 1983 + * @port_num: Port number to check 1984 + * 1985 + * iWARP has a restriction that RDMA READ requests may only have a single 1986 + * Scatter/Gather Entry (SGE) in the work request. 1987 + * 1988 + * NOTE: although the linux kernel currently assumes all devices are either 1989 + * single SGE RDMA READ devices or identical SGE maximums for RDMA READs and 1990 + * WRITEs, according to Tom Talpey, this is not accurate. There are some 1991 + * devices out there that support more than a single SGE on RDMA READ 1992 + * requests, but do not support the same number of SGEs as they do on 1993 + * RDMA WRITE requests. The linux kernel would need rearchitecting to 1994 + * support these imbalanced READ/WRITE SGEs allowed devices. So, for now, 1995 + * suffice with either the device supports the same READ/WRITE SGEs, or 1996 + * it only gets one READ sge. 1997 + * 1998 + * Return: true for any device that allows more than one SGE in RDMA READ 1999 + * requests. 2000 + */ 2001 + static inline bool rdma_cap_read_multi_sge(struct ib_device *device, 2002 + u8 port_num) 2003 + { 2004 + return !(device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IWARP); 2005 + } 2006 + 2007 + /** 2008 + * rdma_max_mad_size - Return the max MAD size required by this RDMA Port. 2009 + * 2010 + * @device: Device 2011 + * @port_num: Port number 2012 + * 2013 + * This MAD size includes the MAD headers and MAD payload. No other headers 2014 + * are included. 2015 + * 2016 + * Return the max MAD size required by the Port. Will return 0 if the port 2017 + * does not support MADs 2018 + */ 2019 + static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_num) 2020 + { 2021 + return device->port_immutable[port_num].max_mad_size; 2022 + } 2023 + 1826 2024 int ib_query_gid(struct ib_device *device, 1827 2025 u8 port_num, int index, union ib_gid *gid); 1828 2026 ··· 2157 1799 * @ah_attr: Returned attributes that can be used when creating an address 2158 1800 * handle for replying to the message. 2159 1801 */ 2160 - int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc, 2161 - struct ib_grh *grh, struct ib_ah_attr *ah_attr); 1802 + int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, 1803 + const struct ib_wc *wc, const struct ib_grh *grh, 1804 + struct ib_ah_attr *ah_attr); 2162 1805 2163 1806 /** 2164 1807 * ib_create_ah_from_wc - Creates an address handle associated with the ··· 2173 1814 * The address handle is used to reference a local or global destination 2174 1815 * in all UD QP post sends. 2175 1816 */ 2176 - struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, 2177 - struct ib_grh *grh, u8 port_num); 1817 + struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc, 1818 + const struct ib_grh *grh, u8 port_num); 2178 1819 2179 1820 /** 2180 1821 * ib_modify_ah - Modifies the address vector associated with an address ··· 2370 2011 * asynchronous event not associated with a completion occurs on the CQ. 2371 2012 * @cq_context: Context associated with the CQ returned to the user via 2372 2013 * the associated completion and event handlers. 2373 - * @cqe: The minimum size of the CQ. 2374 - * @comp_vector - Completion vector used to signal completion events. 2375 - * Must be >= 0 and < context->num_comp_vectors. 2014 + * @cq_attr: The attributes the CQ should be created upon. 2376 2015 * 2377 2016 * Users can examine the cq structure to determine the actual CQ size. 2378 2017 */ 2379 2018 struct ib_cq *ib_create_cq(struct ib_device *device, 2380 2019 ib_comp_handler comp_handler, 2381 2020 void (*event_handler)(struct ib_event *, void *), 2382 - void *cq_context, int cqe, int comp_vector); 2021 + void *cq_context, 2022 + const struct ib_cq_init_attr *cq_attr); 2383 2023 2384 2024 /** 2385 2025 * ib_resize_cq - Modifies the capacity of the CQ.
+1
include/rdma/iw_cm.h
··· 91 91 /* Used by provider to add and remove refs on IW cm_id */ 92 92 void (*add_ref)(struct iw_cm_id *); 93 93 void (*rem_ref)(struct iw_cm_id *); 94 + u8 tos; 94 95 }; 95 96 96 97 struct iw_cm_conn_param {
+106
include/rdma/opa_smi.h
··· 1 + /* 2 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 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 + 33 + #if !defined(OPA_SMI_H) 34 + #define OPA_SMI_H 35 + 36 + #include <rdma/ib_mad.h> 37 + #include <rdma/ib_smi.h> 38 + 39 + #define OPA_SMP_LID_DATA_SIZE 2016 40 + #define OPA_SMP_DR_DATA_SIZE 1872 41 + #define OPA_SMP_MAX_PATH_HOPS 64 42 + 43 + #define OPA_SMI_CLASS_VERSION 0x80 44 + 45 + #define OPA_LID_PERMISSIVE cpu_to_be32(0xFFFFFFFF) 46 + 47 + struct opa_smp { 48 + u8 base_version; 49 + u8 mgmt_class; 50 + u8 class_version; 51 + u8 method; 52 + __be16 status; 53 + u8 hop_ptr; 54 + u8 hop_cnt; 55 + __be64 tid; 56 + __be16 attr_id; 57 + __be16 resv; 58 + __be32 attr_mod; 59 + __be64 mkey; 60 + union { 61 + struct { 62 + uint8_t data[OPA_SMP_LID_DATA_SIZE]; 63 + } lid; 64 + struct { 65 + __be32 dr_slid; 66 + __be32 dr_dlid; 67 + u8 initial_path[OPA_SMP_MAX_PATH_HOPS]; 68 + u8 return_path[OPA_SMP_MAX_PATH_HOPS]; 69 + u8 reserved[8]; 70 + u8 data[OPA_SMP_DR_DATA_SIZE]; 71 + } dr; 72 + } route; 73 + } __packed; 74 + 75 + 76 + static inline u8 77 + opa_get_smp_direction(struct opa_smp *smp) 78 + { 79 + return ib_get_smp_direction((struct ib_smp *)smp); 80 + } 81 + 82 + static inline u8 *opa_get_smp_data(struct opa_smp *smp) 83 + { 84 + if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 85 + return smp->route.dr.data; 86 + 87 + return smp->route.lid.data; 88 + } 89 + 90 + static inline size_t opa_get_smp_data_size(struct opa_smp *smp) 91 + { 92 + if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 93 + return sizeof(smp->route.dr.data); 94 + 95 + return sizeof(smp->route.lid.data); 96 + } 97 + 98 + static inline size_t opa_get_smp_header_size(struct opa_smp *smp) 99 + { 100 + if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 101 + return sizeof(*smp) - sizeof(smp->route.dr.data); 102 + 103 + return sizeof(*smp) - sizeof(smp->route.lid.data); 104 + } 105 + 106 + #endif /* OPA_SMI_H */
+2
include/rdma/rdma_cm.h
··· 62 62 RDMA_CM_EVENT_TIMEWAIT_EXIT 63 63 }; 64 64 65 + __attribute_const__ const char *rdma_event_msg(enum rdma_cm_event_type event); 66 + 65 67 enum rdma_port_space { 66 68 RDMA_PS_SDP = 0x0001, 67 69 RDMA_PS_IPOIB = 0x0002,
+4 -3
include/scsi/srp.h
··· 42 42 */ 43 43 44 44 #include <linux/types.h> 45 + #include <scsi/scsi.h> 45 46 46 47 enum { 47 48 SRP_LOGIN_REQ = 0x00, ··· 180 179 u8 reserved1[6]; 181 180 u64 tag; 182 181 u8 reserved2[4]; 183 - __be64 lun __attribute__((packed)); 182 + struct scsi_lun lun; 184 183 u8 reserved3[2]; 185 184 u8 tsk_mgmt_func; 186 185 u8 reserved4; ··· 201 200 u8 data_in_desc_cnt; 202 201 u64 tag; 203 202 u8 reserved2[4]; 204 - __be64 lun __attribute__((packed)); 203 + struct scsi_lun lun; 205 204 u8 reserved3; 206 205 u8 task_attr; 207 206 u8 reserved4; ··· 266 265 __be32 req_lim_delta; 267 266 u64 tag; 268 267 u32 reserved2; 269 - __be64 lun; 268 + struct scsi_lun lun; 270 269 __be32 sense_data_len; 271 270 u32 reserved3; 272 271 u8 sense_data[0];
+19
include/uapi/rdma/ib_user_verbs.h
··· 91 91 92 92 enum { 93 93 IB_USER_VERBS_EX_CMD_QUERY_DEVICE = IB_USER_VERBS_CMD_QUERY_DEVICE, 94 + IB_USER_VERBS_EX_CMD_CREATE_CQ = IB_USER_VERBS_CMD_CREATE_CQ, 94 95 IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD, 95 96 IB_USER_VERBS_EX_CMD_DESTROY_FLOW, 96 97 }; ··· 223 222 __u32 comp_mask; 224 223 __u32 response_length; 225 224 struct ib_uverbs_odp_caps odp_caps; 225 + __u64 timestamp_mask; 226 + __u64 hca_core_clock; /* in KHZ */ 226 227 }; 227 228 228 229 struct ib_uverbs_query_port { ··· 356 353 __u64 driver_data[0]; 357 354 }; 358 355 356 + struct ib_uverbs_ex_create_cq { 357 + __u64 user_handle; 358 + __u32 cqe; 359 + __u32 comp_vector; 360 + __s32 comp_channel; 361 + __u32 comp_mask; 362 + __u32 flags; 363 + __u32 reserved; 364 + }; 365 + 359 366 struct ib_uverbs_create_cq_resp { 360 367 __u32 cq_handle; 361 368 __u32 cqe; 369 + }; 370 + 371 + struct ib_uverbs_ex_create_cq_resp { 372 + struct ib_uverbs_create_cq_resp base; 373 + __u32 comp_mask; 374 + __u32 response_length; 362 375 }; 363 376 364 377 struct ib_uverbs_resize_cq {
+3 -1
net/9p/trans_rdma.c
··· 648 648 struct rdma_conn_param conn_param; 649 649 struct ib_qp_init_attr qp_attr; 650 650 struct ib_device_attr devattr; 651 + struct ib_cq_init_attr cq_attr = {}; 651 652 652 653 /* Parse the transport specific mount options */ 653 654 err = parse_opts(args, &opts); ··· 706 705 goto error; 707 706 708 707 /* Create the Completion Queue */ 708 + cq_attr.cqe = opts.sq_depth + opts.rq_depth + 1; 709 709 rdma->cq = ib_create_cq(rdma->cm_id->device, cq_comp_handler, 710 710 cq_event_handler, client, 711 - opts.sq_depth + opts.rq_depth + 1, 0); 711 + &cq_attr); 712 712 if (IS_ERR(rdma->cq)) 713 713 goto error; 714 714 ib_req_notify_cq(rdma->cq, IB_CQ_NEXT_COMP);
-9
net/rds/af_rds.c
··· 40 40 41 41 #include "rds.h" 42 42 43 - char *rds_str_array(char **array, size_t elements, size_t index) 44 - { 45 - if ((index < elements) && array[index]) 46 - return array[index]; 47 - else 48 - return "unknown"; 49 - } 50 - EXPORT_SYMBOL(rds_str_array); 51 - 52 43 /* this is just used for stats gathering :/ */ 53 44 static DEFINE_SPINLOCK(rds_sock_lock); 54 45 static unsigned long rds_sock_count;
-1
net/rds/ib.h
··· 339 339 extern wait_queue_head_t rds_ib_ring_empty_wait; 340 340 341 341 /* ib_send.c */ 342 - char *rds_ib_wc_status_str(enum ib_wc_status status); 343 342 void rds_ib_xmit_complete(struct rds_connection *conn); 344 343 int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, 345 344 unsigned int hdr_off, unsigned int sg, unsigned int off);
+8 -35
net/rds/ib_cm.c
··· 39 39 #include "rds.h" 40 40 #include "ib.h" 41 41 42 - static char *rds_ib_event_type_strings[] = { 43 - #define RDS_IB_EVENT_STRING(foo) \ 44 - [IB_EVENT_##foo] = __stringify(IB_EVENT_##foo) 45 - RDS_IB_EVENT_STRING(CQ_ERR), 46 - RDS_IB_EVENT_STRING(QP_FATAL), 47 - RDS_IB_EVENT_STRING(QP_REQ_ERR), 48 - RDS_IB_EVENT_STRING(QP_ACCESS_ERR), 49 - RDS_IB_EVENT_STRING(COMM_EST), 50 - RDS_IB_EVENT_STRING(SQ_DRAINED), 51 - RDS_IB_EVENT_STRING(PATH_MIG), 52 - RDS_IB_EVENT_STRING(PATH_MIG_ERR), 53 - RDS_IB_EVENT_STRING(DEVICE_FATAL), 54 - RDS_IB_EVENT_STRING(PORT_ACTIVE), 55 - RDS_IB_EVENT_STRING(PORT_ERR), 56 - RDS_IB_EVENT_STRING(LID_CHANGE), 57 - RDS_IB_EVENT_STRING(PKEY_CHANGE), 58 - RDS_IB_EVENT_STRING(SM_CHANGE), 59 - RDS_IB_EVENT_STRING(SRQ_ERR), 60 - RDS_IB_EVENT_STRING(SRQ_LIMIT_REACHED), 61 - RDS_IB_EVENT_STRING(QP_LAST_WQE_REACHED), 62 - RDS_IB_EVENT_STRING(CLIENT_REREGISTER), 63 - #undef RDS_IB_EVENT_STRING 64 - }; 65 - 66 - static char *rds_ib_event_str(enum ib_event_type type) 67 - { 68 - return rds_str_array(rds_ib_event_type_strings, 69 - ARRAY_SIZE(rds_ib_event_type_strings), type); 70 - }; 71 - 72 42 /* 73 43 * Set the selected protocol version 74 44 */ ··· 213 243 static void rds_ib_cq_event_handler(struct ib_event *event, void *data) 214 244 { 215 245 rdsdebug("event %u (%s) data %p\n", 216 - event->event, rds_ib_event_str(event->event), data); 246 + event->event, ib_event_msg(event->event), data); 217 247 } 218 248 219 249 static void rds_ib_qp_event_handler(struct ib_event *event, void *data) ··· 222 252 struct rds_ib_connection *ic = conn->c_transport_data; 223 253 224 254 rdsdebug("conn %p ic %p event %u (%s)\n", conn, ic, event->event, 225 - rds_ib_event_str(event->event)); 255 + ib_event_msg(event->event)); 226 256 227 257 switch (event->event) { 228 258 case IB_EVENT_COMM_EST: ··· 231 261 default: 232 262 rdsdebug("Fatal QP Event %u (%s) " 233 263 "- connection %pI4->%pI4, reconnecting\n", 234 - event->event, rds_ib_event_str(event->event), 264 + event->event, ib_event_msg(event->event), 235 265 &conn->c_laddr, &conn->c_faddr); 236 266 rds_conn_drop(conn); 237 267 break; ··· 247 277 struct rds_ib_connection *ic = conn->c_transport_data; 248 278 struct ib_device *dev = ic->i_cm_id->device; 249 279 struct ib_qp_init_attr attr; 280 + struct ib_cq_init_attr cq_attr = {}; 250 281 struct rds_ib_device *rds_ibdev; 251 282 int ret; 252 283 ··· 271 300 ic->i_pd = rds_ibdev->pd; 272 301 ic->i_mr = rds_ibdev->mr; 273 302 303 + cq_attr.cqe = ic->i_send_ring.w_nr + 1; 274 304 ic->i_send_cq = ib_create_cq(dev, rds_ib_send_cq_comp_handler, 275 305 rds_ib_cq_event_handler, conn, 276 - ic->i_send_ring.w_nr + 1, 0); 306 + &cq_attr); 277 307 if (IS_ERR(ic->i_send_cq)) { 278 308 ret = PTR_ERR(ic->i_send_cq); 279 309 ic->i_send_cq = NULL; ··· 282 310 goto out; 283 311 } 284 312 313 + cq_attr.cqe = ic->i_recv_ring.w_nr; 285 314 ic->i_recv_cq = ib_create_cq(dev, rds_ib_recv_cq_comp_handler, 286 315 rds_ib_cq_event_handler, conn, 287 - ic->i_recv_ring.w_nr, 0); 316 + &cq_attr); 288 317 if (IS_ERR(ic->i_recv_cq)) { 289 318 ret = PTR_ERR(ic->i_recv_cq); 290 319 ic->i_recv_cq = NULL;
+2 -2
net/rds/ib_recv.c
··· 956 956 while (ib_poll_cq(ic->i_recv_cq, 1, &wc) > 0) { 957 957 rdsdebug("wc wr_id 0x%llx status %u (%s) byte_len %u imm_data %u\n", 958 958 (unsigned long long)wc.wr_id, wc.status, 959 - rds_ib_wc_status_str(wc.status), wc.byte_len, 959 + ib_wc_status_msg(wc.status), wc.byte_len, 960 960 be32_to_cpu(wc.ex.imm_data)); 961 961 rds_ib_stats_inc(s_ib_rx_cq_event); 962 962 ··· 978 978 "status %u (%s), disconnecting and " 979 979 "reconnecting\n", &conn->c_faddr, 980 980 wc.status, 981 - rds_ib_wc_status_str(wc.status)); 981 + ib_wc_status_msg(wc.status)); 982 982 } 983 983 984 984 /*
+13 -42
net/rds/ib_send.c
··· 39 39 #include "rds.h" 40 40 #include "ib.h" 41 41 42 - static char *rds_ib_wc_status_strings[] = { 43 - #define RDS_IB_WC_STATUS_STR(foo) \ 44 - [IB_WC_##foo] = __stringify(IB_WC_##foo) 45 - RDS_IB_WC_STATUS_STR(SUCCESS), 46 - RDS_IB_WC_STATUS_STR(LOC_LEN_ERR), 47 - RDS_IB_WC_STATUS_STR(LOC_QP_OP_ERR), 48 - RDS_IB_WC_STATUS_STR(LOC_EEC_OP_ERR), 49 - RDS_IB_WC_STATUS_STR(LOC_PROT_ERR), 50 - RDS_IB_WC_STATUS_STR(WR_FLUSH_ERR), 51 - RDS_IB_WC_STATUS_STR(MW_BIND_ERR), 52 - RDS_IB_WC_STATUS_STR(BAD_RESP_ERR), 53 - RDS_IB_WC_STATUS_STR(LOC_ACCESS_ERR), 54 - RDS_IB_WC_STATUS_STR(REM_INV_REQ_ERR), 55 - RDS_IB_WC_STATUS_STR(REM_ACCESS_ERR), 56 - RDS_IB_WC_STATUS_STR(REM_OP_ERR), 57 - RDS_IB_WC_STATUS_STR(RETRY_EXC_ERR), 58 - RDS_IB_WC_STATUS_STR(RNR_RETRY_EXC_ERR), 59 - RDS_IB_WC_STATUS_STR(LOC_RDD_VIOL_ERR), 60 - RDS_IB_WC_STATUS_STR(REM_INV_RD_REQ_ERR), 61 - RDS_IB_WC_STATUS_STR(REM_ABORT_ERR), 62 - RDS_IB_WC_STATUS_STR(INV_EECN_ERR), 63 - RDS_IB_WC_STATUS_STR(INV_EEC_STATE_ERR), 64 - RDS_IB_WC_STATUS_STR(FATAL_ERR), 65 - RDS_IB_WC_STATUS_STR(RESP_TIMEOUT_ERR), 66 - RDS_IB_WC_STATUS_STR(GENERAL_ERR), 67 - #undef RDS_IB_WC_STATUS_STR 68 - }; 69 - 70 - char *rds_ib_wc_status_str(enum ib_wc_status status) 71 - { 72 - return rds_str_array(rds_ib_wc_status_strings, 73 - ARRAY_SIZE(rds_ib_wc_status_strings), status); 74 - } 75 - 76 42 /* 77 43 * Convert IB-specific error message to RDS error message and call core 78 44 * completion handler. ··· 259 293 while (ib_poll_cq(cq, 1, &wc) > 0) { 260 294 rdsdebug("wc wr_id 0x%llx status %u (%s) byte_len %u imm_data %u\n", 261 295 (unsigned long long)wc.wr_id, wc.status, 262 - rds_ib_wc_status_str(wc.status), wc.byte_len, 296 + ib_wc_status_msg(wc.status), wc.byte_len, 263 297 be32_to_cpu(wc.ex.imm_data)); 264 298 rds_ib_stats_inc(s_ib_tx_cq_event); 265 299 ··· 310 344 rds_ib_conn_error(conn, "send completion on %pI4 had status " 311 345 "%u (%s), disconnecting and reconnecting\n", 312 346 &conn->c_faddr, wc.status, 313 - rds_ib_wc_status_str(wc.status)); 347 + ib_wc_status_msg(wc.status)); 314 348 } 315 349 } 316 350 } ··· 571 605 } 572 606 573 607 rds_message_addref(rm); 608 + rm->data.op_dmasg = 0; 609 + rm->data.op_dmaoff = 0; 574 610 ic->i_data_op = &rm->data; 575 611 576 612 /* Finalize the header */ ··· 626 658 send = &ic->i_sends[pos]; 627 659 first = send; 628 660 prev = NULL; 629 - scat = &ic->i_data_op->op_sg[sg]; 661 + scat = &ic->i_data_op->op_sg[rm->data.op_dmasg]; 630 662 i = 0; 631 663 do { 632 664 unsigned int len = 0; ··· 648 680 /* Set up the data, if present */ 649 681 if (i < work_alloc 650 682 && scat != &rm->data.op_sg[rm->data.op_count]) { 651 - len = min(RDS_FRAG_SIZE, ib_sg_dma_len(dev, scat) - off); 683 + len = min(RDS_FRAG_SIZE, 684 + ib_sg_dma_len(dev, scat) - rm->data.op_dmaoff); 652 685 send->s_wr.num_sge = 2; 653 686 654 - send->s_sge[1].addr = ib_sg_dma_address(dev, scat) + off; 687 + send->s_sge[1].addr = ib_sg_dma_address(dev, scat); 688 + send->s_sge[1].addr += rm->data.op_dmaoff; 655 689 send->s_sge[1].length = len; 656 690 657 691 bytes_sent += len; 658 - off += len; 659 - if (off == ib_sg_dma_len(dev, scat)) { 692 + rm->data.op_dmaoff += len; 693 + if (rm->data.op_dmaoff == ib_sg_dma_len(dev, scat)) { 660 694 scat++; 661 - off = 0; 695 + rm->data.op_dmasg++; 696 + rm->data.op_dmaoff = 0; 662 697 } 663 698 } 664 699
+5 -2
net/rds/iw_cm.c
··· 179 179 void *context) 180 180 { 181 181 struct ib_device *dev = rds_iwdev->dev; 182 + struct ib_cq_init_attr cq_attr = {}; 182 183 unsigned int send_size, recv_size; 183 184 int ret; 184 185 ··· 199 198 attr->sq_sig_type = IB_SIGNAL_REQ_WR; 200 199 attr->qp_type = IB_QPT_RC; 201 200 201 + cq_attr.cqe = send_size; 202 202 attr->send_cq = ib_create_cq(dev, send_cq_handler, 203 203 rds_iw_cq_event_handler, 204 - context, send_size, 0); 204 + context, &cq_attr); 205 205 if (IS_ERR(attr->send_cq)) { 206 206 ret = PTR_ERR(attr->send_cq); 207 207 attr->send_cq = NULL; ··· 210 208 goto out; 211 209 } 212 210 211 + cq_attr.cqe = recv_size; 213 212 attr->recv_cq = ib_create_cq(dev, recv_cq_handler, 214 213 rds_iw_cq_event_handler, 215 - context, recv_size, 0); 214 + context, &cq_attr); 216 215 if (IS_ERR(attr->recv_cq)) { 217 216 ret = PTR_ERR(attr->recv_cq); 218 217 attr->recv_cq = NULL;
+11 -7
net/rds/iw_send.c
··· 581 581 ic->i_unsignaled_wrs = rds_iw_sysctl_max_unsig_wrs; 582 582 ic->i_unsignaled_bytes = rds_iw_sysctl_max_unsig_bytes; 583 583 rds_message_addref(rm); 584 + rm->data.op_dmasg = 0; 585 + rm->data.op_dmaoff = 0; 584 586 ic->i_rm = rm; 585 587 586 588 /* Finalize the header */ ··· 624 622 send = &ic->i_sends[pos]; 625 623 first = send; 626 624 prev = NULL; 627 - scat = &rm->data.op_sg[sg]; 625 + scat = &rm->data.op_sg[rm->data.op_dmasg]; 628 626 sent = 0; 629 627 i = 0; 630 628 ··· 658 656 659 657 send = &ic->i_sends[pos]; 660 658 661 - len = min(RDS_FRAG_SIZE, ib_sg_dma_len(dev, scat) - off); 659 + len = min(RDS_FRAG_SIZE, 660 + ib_sg_dma_len(dev, scat) - rm->data.op_dmaoff); 662 661 rds_iw_xmit_populate_wr(ic, send, pos, 663 - ib_sg_dma_address(dev, scat) + off, len, 664 - send_flags); 662 + ib_sg_dma_address(dev, scat) + rm->data.op_dmaoff, len, 663 + send_flags); 665 664 666 665 /* 667 666 * We want to delay signaling completions just enough to get ··· 690 687 &send->s_wr, send->s_wr.num_sge, send->s_wr.next); 691 688 692 689 sent += len; 693 - off += len; 694 - if (off == ib_sg_dma_len(dev, scat)) { 690 + rm->data.op_dmaoff += len; 691 + if (rm->data.op_dmaoff == ib_sg_dma_len(dev, scat)) { 695 692 scat++; 696 - off = 0; 693 + rm->data.op_dmaoff = 0; 694 + rm->data.op_dmasg++; 697 695 } 698 696 699 697 add_header:
+3 -31
net/rds/rdma_transport.c
··· 37 37 38 38 static struct rdma_cm_id *rds_rdma_listen_id; 39 39 40 - static char *rds_cm_event_strings[] = { 41 - #define RDS_CM_EVENT_STRING(foo) \ 42 - [RDMA_CM_EVENT_##foo] = __stringify(RDMA_CM_EVENT_##foo) 43 - RDS_CM_EVENT_STRING(ADDR_RESOLVED), 44 - RDS_CM_EVENT_STRING(ADDR_ERROR), 45 - RDS_CM_EVENT_STRING(ROUTE_RESOLVED), 46 - RDS_CM_EVENT_STRING(ROUTE_ERROR), 47 - RDS_CM_EVENT_STRING(CONNECT_REQUEST), 48 - RDS_CM_EVENT_STRING(CONNECT_RESPONSE), 49 - RDS_CM_EVENT_STRING(CONNECT_ERROR), 50 - RDS_CM_EVENT_STRING(UNREACHABLE), 51 - RDS_CM_EVENT_STRING(REJECTED), 52 - RDS_CM_EVENT_STRING(ESTABLISHED), 53 - RDS_CM_EVENT_STRING(DISCONNECTED), 54 - RDS_CM_EVENT_STRING(DEVICE_REMOVAL), 55 - RDS_CM_EVENT_STRING(MULTICAST_JOIN), 56 - RDS_CM_EVENT_STRING(MULTICAST_ERROR), 57 - RDS_CM_EVENT_STRING(ADDR_CHANGE), 58 - RDS_CM_EVENT_STRING(TIMEWAIT_EXIT), 59 - #undef RDS_CM_EVENT_STRING 60 - }; 61 - 62 - static char *rds_cm_event_str(enum rdma_cm_event_type type) 63 - { 64 - return rds_str_array(rds_cm_event_strings, 65 - ARRAY_SIZE(rds_cm_event_strings), type); 66 - }; 67 - 68 40 int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id, 69 41 struct rdma_cm_event *event) 70 42 { ··· 46 74 int ret = 0; 47 75 48 76 rdsdebug("conn %p id %p handling event %u (%s)\n", conn, cm_id, 49 - event->event, rds_cm_event_str(event->event)); 77 + event->event, rdma_event_msg(event->event)); 50 78 51 79 if (cm_id->device->node_type == RDMA_NODE_RNIC) 52 80 trans = &rds_iw_transport; ··· 111 139 default: 112 140 /* things like device disconnect? */ 113 141 printk(KERN_ERR "RDS: unknown event %u (%s)!\n", 114 - event->event, rds_cm_event_str(event->event)); 142 + event->event, rdma_event_msg(event->event)); 115 143 break; 116 144 } 117 145 ··· 120 148 mutex_unlock(&conn->c_cm_lock); 121 149 122 150 rdsdebug("id %p event %u (%s) handling ret %d\n", cm_id, event->event, 123 - rds_cm_event_str(event->event), ret); 151 + rdma_event_msg(event->event), ret); 124 152 125 153 return ret; 126 154 }
+2 -1
net/rds/rds.h
··· 363 363 unsigned int op_active:1; 364 364 unsigned int op_nents; 365 365 unsigned int op_count; 366 + unsigned int op_dmasg; 367 + unsigned int op_dmaoff; 366 368 struct scatterlist *op_sg; 367 369 } data; 368 370 }; ··· 577 575 }; 578 576 579 577 /* af_rds.c */ 580 - char *rds_str_array(char **array, size_t elements, size_t index); 581 578 void rds_sock_addref(struct rds_sock *rs); 582 579 void rds_sock_put(struct rds_sock *rs); 583 580 void rds_wake_sk_sleep(struct rds_sock *rs);
+2 -2
net/sunrpc/xprtrdma/frwr_ops.c
··· 128 128 129 129 /* WARNING: Only wr_id and status are reliable at this point */ 130 130 r = (struct rpcrdma_mw *)(unsigned long)wc->wr_id; 131 - dprintk("RPC: %s: frmr %p (stale), status %d\n", 132 - __func__, r, wc->status); 131 + dprintk("RPC: %s: frmr %p (stale), status %s (%d)\n", 132 + __func__, r, ib_wc_status_msg(wc->status), wc->status); 133 133 r->r.frmr.fr_state = FRMR_IS_STALE; 134 134 } 135 135
+2 -2
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
··· 117 117 118 118 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count) 119 119 { 120 - if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) == 121 - RDMA_TRANSPORT_IWARP) 120 + if (!rdma_cap_read_multi_sge(xprt->sc_cm_id->device, 121 + xprt->sc_cm_id->port_num)) 122 122 return 1; 123 123 else 124 124 return min_t(int, sge_count, xprt->sc_max_sge);
+41 -42
net/sunrpc/xprtrdma/svc_rdma_transport.c
··· 175 175 static void cq_event_handler(struct ib_event *event, void *context) 176 176 { 177 177 struct svc_xprt *xprt = context; 178 - dprintk("svcrdma: received CQ event id=%d, context=%p\n", 179 - event->event, context); 178 + dprintk("svcrdma: received CQ event %s (%d), context=%p\n", 179 + ib_event_msg(event->event), event->event, context); 180 180 set_bit(XPT_CLOSE, &xprt->xpt_flags); 181 181 } 182 182 ··· 191 191 case IB_EVENT_COMM_EST: 192 192 case IB_EVENT_SQ_DRAINED: 193 193 case IB_EVENT_QP_LAST_WQE_REACHED: 194 - dprintk("svcrdma: QP event %d received for QP=%p\n", 195 - event->event, event->element.qp); 194 + dprintk("svcrdma: QP event %s (%d) received for QP=%p\n", 195 + ib_event_msg(event->event), event->event, 196 + event->element.qp); 196 197 break; 197 198 /* These are considered fatal events */ 198 199 case IB_EVENT_PATH_MIG_ERR: ··· 202 201 case IB_EVENT_QP_ACCESS_ERR: 203 202 case IB_EVENT_DEVICE_FATAL: 204 203 default: 205 - dprintk("svcrdma: QP ERROR event %d received for QP=%p, " 204 + dprintk("svcrdma: QP ERROR event %s (%d) received for QP=%p, " 206 205 "closing transport\n", 207 - event->event, event->element.qp); 206 + ib_event_msg(event->event), event->event, 207 + event->element.qp); 208 208 set_bit(XPT_CLOSE, &xprt->xpt_flags); 209 209 break; 210 210 } ··· 404 402 for (i = 0; i < ret; i++) { 405 403 wc = &wc_a[i]; 406 404 if (wc->status != IB_WC_SUCCESS) { 407 - dprintk("svcrdma: sq wc err status %d\n", 405 + dprintk("svcrdma: sq wc err status %s (%d)\n", 406 + ib_wc_status_msg(wc->status), 408 407 wc->status); 409 408 410 409 /* Close the transport */ ··· 619 616 switch (event->event) { 620 617 case RDMA_CM_EVENT_CONNECT_REQUEST: 621 618 dprintk("svcrdma: Connect request on cma_id=%p, xprt = %p, " 622 - "event=%d\n", cma_id, cma_id->context, event->event); 619 + "event = %s (%d)\n", cma_id, cma_id->context, 620 + rdma_event_msg(event->event), event->event); 623 621 handle_connect_req(cma_id, 624 622 event->param.conn.initiator_depth); 625 623 break; ··· 640 636 641 637 default: 642 638 dprintk("svcrdma: Unexpected event on listening endpoint %p, " 643 - "event=%d\n", cma_id, event->event); 639 + "event = %s (%d)\n", cma_id, 640 + rdma_event_msg(event->event), event->event); 644 641 break; 645 642 } 646 643 ··· 674 669 break; 675 670 case RDMA_CM_EVENT_DEVICE_REMOVAL: 676 671 dprintk("svcrdma: Device removal cma_id=%p, xprt = %p, " 677 - "event=%d\n", cma_id, xprt, event->event); 672 + "event = %s (%d)\n", cma_id, xprt, 673 + rdma_event_msg(event->event), event->event); 678 674 if (xprt) { 679 675 set_bit(XPT_CLOSE, &xprt->xpt_flags); 680 676 svc_xprt_enqueue(xprt); ··· 683 677 break; 684 678 default: 685 679 dprintk("svcrdma: Unexpected event on DTO endpoint %p, " 686 - "event=%d\n", cma_id, event->event); 680 + "event = %s (%d)\n", cma_id, 681 + rdma_event_msg(event->event), event->event); 687 682 break; 688 683 } 689 684 return 0; ··· 855 848 struct svcxprt_rdma *listen_rdma; 856 849 struct svcxprt_rdma *newxprt = NULL; 857 850 struct rdma_conn_param conn_param; 851 + struct ib_cq_init_attr cq_attr = {}; 858 852 struct ib_qp_init_attr qp_attr; 859 853 struct ib_device_attr devattr; 860 854 int uninitialized_var(dma_mr_acc); 861 - int need_dma_mr; 855 + int need_dma_mr = 0; 862 856 int ret; 863 857 int i; 864 858 ··· 908 900 dprintk("svcrdma: error creating PD for connect request\n"); 909 901 goto errout; 910 902 } 903 + cq_attr.cqe = newxprt->sc_sq_depth; 911 904 newxprt->sc_sq_cq = ib_create_cq(newxprt->sc_cm_id->device, 912 905 sq_comp_handler, 913 906 cq_event_handler, 914 907 newxprt, 915 - newxprt->sc_sq_depth, 916 - 0); 908 + &cq_attr); 917 909 if (IS_ERR(newxprt->sc_sq_cq)) { 918 910 dprintk("svcrdma: error creating SQ CQ for connect request\n"); 919 911 goto errout; 920 912 } 913 + cq_attr.cqe = newxprt->sc_max_requests; 921 914 newxprt->sc_rq_cq = ib_create_cq(newxprt->sc_cm_id->device, 922 915 rq_comp_handler, 923 916 cq_event_handler, 924 917 newxprt, 925 - newxprt->sc_max_requests, 926 - 0); 918 + &cq_attr); 927 919 if (IS_ERR(newxprt->sc_rq_cq)) { 928 920 dprintk("svcrdma: error creating RQ CQ for connect request\n"); 929 921 goto errout; ··· 993 985 /* 994 986 * Determine if a DMA MR is required and if so, what privs are required 995 987 */ 996 - switch (rdma_node_get_transport(newxprt->sc_cm_id->device->node_type)) { 997 - case RDMA_TRANSPORT_IWARP: 998 - newxprt->sc_dev_caps |= SVCRDMA_DEVCAP_READ_W_INV; 999 - if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG)) { 1000 - need_dma_mr = 1; 1001 - dma_mr_acc = 1002 - (IB_ACCESS_LOCAL_WRITE | 1003 - IB_ACCESS_REMOTE_WRITE); 1004 - } else if (!(devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)) { 1005 - need_dma_mr = 1; 1006 - dma_mr_acc = IB_ACCESS_LOCAL_WRITE; 1007 - } else 1008 - need_dma_mr = 0; 1009 - break; 1010 - case RDMA_TRANSPORT_IB: 1011 - if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG)) { 1012 - need_dma_mr = 1; 1013 - dma_mr_acc = IB_ACCESS_LOCAL_WRITE; 1014 - } else if (!(devattr.device_cap_flags & 1015 - IB_DEVICE_LOCAL_DMA_LKEY)) { 1016 - need_dma_mr = 1; 1017 - dma_mr_acc = IB_ACCESS_LOCAL_WRITE; 1018 - } else 1019 - need_dma_mr = 0; 1020 - break; 1021 - default: 988 + if (!rdma_protocol_iwarp(newxprt->sc_cm_id->device, 989 + newxprt->sc_cm_id->port_num) && 990 + !rdma_ib_or_roce(newxprt->sc_cm_id->device, 991 + newxprt->sc_cm_id->port_num)) 1022 992 goto errout; 993 + 994 + if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG) || 995 + !(devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)) { 996 + need_dma_mr = 1; 997 + dma_mr_acc = IB_ACCESS_LOCAL_WRITE; 998 + if (rdma_protocol_iwarp(newxprt->sc_cm_id->device, 999 + newxprt->sc_cm_id->port_num) && 1000 + !(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG)) 1001 + dma_mr_acc |= IB_ACCESS_REMOTE_WRITE; 1023 1002 } 1003 + 1004 + if (rdma_protocol_iwarp(newxprt->sc_cm_id->device, 1005 + newxprt->sc_cm_id->port_num)) 1006 + newxprt->sc_dev_caps |= SVCRDMA_DEVCAP_READ_W_INV; 1024 1007 1025 1008 /* Create the DMA MR if needed, otherwise, use the DMA LKEY */ 1026 1009 if (need_dma_mr) {
+10 -89
net/sunrpc/xprtrdma/verbs.c
··· 105 105 106 106 static DECLARE_TASKLET(rpcrdma_tasklet_g, rpcrdma_run_tasklet, 0UL); 107 107 108 - static const char * const async_event[] = { 109 - "CQ error", 110 - "QP fatal error", 111 - "QP request error", 112 - "QP access error", 113 - "communication established", 114 - "send queue drained", 115 - "path migration successful", 116 - "path mig error", 117 - "device fatal error", 118 - "port active", 119 - "port error", 120 - "LID change", 121 - "P_key change", 122 - "SM change", 123 - "SRQ error", 124 - "SRQ limit reached", 125 - "last WQE reached", 126 - "client reregister", 127 - "GID change", 128 - }; 129 - 130 - #define ASYNC_MSG(status) \ 131 - ((status) < ARRAY_SIZE(async_event) ? \ 132 - async_event[(status)] : "unknown async error") 133 - 134 108 static void 135 109 rpcrdma_schedule_tasklet(struct list_head *sched_list) 136 110 { ··· 122 148 struct rpcrdma_ep *ep = context; 123 149 124 150 pr_err("RPC: %s: %s on device %s ep %p\n", 125 - __func__, ASYNC_MSG(event->event), 151 + __func__, ib_event_msg(event->event), 126 152 event->device->name, context); 127 153 if (ep->rep_connected == 1) { 128 154 ep->rep_connected = -EIO; ··· 137 163 struct rpcrdma_ep *ep = context; 138 164 139 165 pr_err("RPC: %s: %s on device %s ep %p\n", 140 - __func__, ASYNC_MSG(event->event), 166 + __func__, ib_event_msg(event->event), 141 167 event->device->name, context); 142 168 if (ep->rep_connected == 1) { 143 169 ep->rep_connected = -EIO; ··· 145 171 wake_up_all(&ep->rep_connect_wait); 146 172 } 147 173 } 148 - 149 - static const char * const wc_status[] = { 150 - "success", 151 - "local length error", 152 - "local QP operation error", 153 - "local EE context operation error", 154 - "local protection error", 155 - "WR flushed", 156 - "memory management operation error", 157 - "bad response error", 158 - "local access error", 159 - "remote invalid request error", 160 - "remote access error", 161 - "remote operation error", 162 - "transport retry counter exceeded", 163 - "RNR retry counter exceeded", 164 - "local RDD violation error", 165 - "remove invalid RD request", 166 - "operation aborted", 167 - "invalid EE context number", 168 - "invalid EE context state", 169 - "fatal error", 170 - "response timeout error", 171 - "general error", 172 - }; 173 - 174 - #define COMPLETION_MSG(status) \ 175 - ((status) < ARRAY_SIZE(wc_status) ? \ 176 - wc_status[(status)] : "unexpected completion error") 177 174 178 175 static void 179 176 rpcrdma_sendcq_process_wc(struct ib_wc *wc) ··· 154 209 if (wc->status != IB_WC_SUCCESS && 155 210 wc->status != IB_WC_WR_FLUSH_ERR) 156 211 pr_err("RPC: %s: SEND: %s\n", 157 - __func__, COMPLETION_MSG(wc->status)); 212 + __func__, ib_wc_status_msg(wc->status)); 158 213 } else { 159 214 struct rpcrdma_mw *r; 160 215 ··· 247 302 out_fail: 248 303 if (wc->status != IB_WC_WR_FLUSH_ERR) 249 304 pr_err("RPC: %s: rep %p: %s\n", 250 - __func__, rep, COMPLETION_MSG(wc->status)); 305 + __func__, rep, ib_wc_status_msg(wc->status)); 251 306 rep->rr_len = ~0U; 252 307 goto out_schedule; 253 308 } ··· 331 386 rpcrdma_sendcq_process_wc(&wc); 332 387 } 333 388 334 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 335 - static const char * const conn[] = { 336 - "address resolved", 337 - "address error", 338 - "route resolved", 339 - "route error", 340 - "connect request", 341 - "connect response", 342 - "connect error", 343 - "unreachable", 344 - "rejected", 345 - "established", 346 - "disconnected", 347 - "device removal", 348 - "multicast join", 349 - "multicast error", 350 - "address change", 351 - "timewait exit", 352 - }; 353 - 354 - #define CONNECTION_MSG(status) \ 355 - ((status) < ARRAY_SIZE(conn) ? \ 356 - conn[(status)] : "unrecognized connection error") 357 - #endif 358 - 359 389 static int 360 390 rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event) 361 391 { ··· 396 476 default: 397 477 dprintk("RPC: %s: %pIS:%u (ep 0x%p): %s\n", 398 478 __func__, sap, rpc_get_port(sap), ep, 399 - CONNECTION_MSG(event->event)); 479 + rdma_event_msg(event->event)); 400 480 break; 401 481 } 402 482 ··· 644 724 { 645 725 struct ib_device_attr *devattr = &ia->ri_devattr; 646 726 struct ib_cq *sendcq, *recvcq; 727 + struct ib_cq_init_attr cq_attr = {}; 647 728 int rc, err; 648 729 649 730 /* check provider's send/recv wr limits */ ··· 692 771 init_waitqueue_head(&ep->rep_connect_wait); 693 772 INIT_DELAYED_WORK(&ep->rep_connect_worker, rpcrdma_connect_worker); 694 773 774 + cq_attr.cqe = ep->rep_attr.cap.max_send_wr + 1; 695 775 sendcq = ib_create_cq(ia->ri_id->device, rpcrdma_sendcq_upcall, 696 - rpcrdma_cq_async_error_upcall, ep, 697 - ep->rep_attr.cap.max_send_wr + 1, 0); 776 + rpcrdma_cq_async_error_upcall, ep, &cq_attr); 698 777 if (IS_ERR(sendcq)) { 699 778 rc = PTR_ERR(sendcq); 700 779 dprintk("RPC: %s: failed to create send CQ: %i\n", ··· 709 788 goto out2; 710 789 } 711 790 791 + cq_attr.cqe = ep->rep_attr.cap.max_recv_wr + 1; 712 792 recvcq = ib_create_cq(ia->ri_id->device, rpcrdma_recvcq_upcall, 713 - rpcrdma_cq_async_error_upcall, ep, 714 - ep->rep_attr.cap.max_recv_wr + 1, 0); 793 + rpcrdma_cq_async_error_upcall, ep, &cq_attr); 715 794 if (IS_ERR(recvcq)) { 716 795 rc = PTR_ERR(recvcq); 717 796 dprintk("RPC: %s: failed to create recv CQ: %i\n",